Files
replypier/backend/assets/widget.js
T
WangShen007 3017753b88 chore: settle product naming across app, widget and deployments
One word everywhere: ReplyPier in UI copy, package and image names, the
replypier.site domains (app/api/docs/help), REPLYPIER_* settings and the
--rp-* design tokens.

- public widget API is window.ReplyPier with replypierId / replypierBaseUrl /
  replypierConfig / replypierToken, loader at webclient/replypier.min.js;
  both bundles rebuilt from source
- NOTICE, llms.txt, CONTRIBUTING, HELP_CENTER_INFRA and the demo runtime
  config rewritten; the demo config ships no third-party keys
- migration adds the ReplyPier managed model value to the AI model enum
- local compose project, database, role, volume and Docker network carry the
  same name
2026-10-26 01:02:17 +08:00

12844 lines
428 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var hf = Object.defineProperty;
var df = (e, t, n) => t in e ? hf(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
var et = (e, t, n) => df(e, typeof t != "symbol" ? t + "" : t, n);
/**
* @vue/shared v3.5.18
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
/*! #__NO_SIDE_EFFECTS__ */
// @__NO_SIDE_EFFECTS__
function ta(e) {
const t = /* @__PURE__ */ Object.create(null);
for (const n of e.split(",")) t[n] = 1;
return (n) => n in t;
}
const tt = {}, Ms = [], yn = () => {
}, pf = () => !1, Ni = (e) => e.charCodeAt(0) === 111 && e.charCodeAt(1) === 110 && // uppercase letter
(e.charCodeAt(2) > 122 || e.charCodeAt(2) < 97), na = (e) => e.startsWith("onUpdate:"), Mt = Object.assign, sa = (e, t) => {
const n = e.indexOf(t);
n > -1 && e.splice(n, 1);
}, gf = Object.prototype.hasOwnProperty, je = (e, t) => gf.call(e, t), ve = Array.isArray, Ds = (e) => Mi(e) === "[object Map]", hc = (e) => Mi(e) === "[object Set]", ke = (e) => typeof e == "function", mt = (e) => typeof e == "string", ns = (e) => typeof e == "symbol", ut = (e) => e !== null && typeof e == "object", dc = (e) => (ut(e) || ke(e)) && ke(e.then) && ke(e.catch), pc = Object.prototype.toString, Mi = (e) => pc.call(e), mf = (e) => Mi(e).slice(8, -1), gc = (e) => Mi(e) === "[object Object]", ra = (e) => mt(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, wr = /* @__PURE__ */ ta(
// the leading comma is intentional so empty string "" is also included
",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
), Di = (e) => {
const t = /* @__PURE__ */ Object.create(null);
return (n) => t[n] || (t[n] = e(n));
}, _f = /-(\w)/g, Qn = Di(
(e) => e.replace(_f, (t, n) => n ? n.toUpperCase() : "")
), yf = /\B([A-Z])/g, ss = Di(
(e) => e.replace(yf, "-$1").toLowerCase()
), mc = Di((e) => e.charAt(0).toUpperCase() + e.slice(1)), ao = Di(
(e) => e ? `on${mc(e)}` : ""
), Xn = (e, t) => !Object.is(e, t), si = (e, ...t) => {
for (let n = 0; n < e.length; n++)
e[n](...t);
}, No = (e, t, n, s = !1) => {
Object.defineProperty(e, t, {
configurable: !0,
enumerable: !1,
writable: s,
value: n
});
}, Mo = (e) => {
const t = parseFloat(e);
return isNaN(t) ? e : t;
};
let Qa;
const Pi = () => Qa || (Qa = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {});
function Ee(e) {
if (ve(e)) {
const t = {};
for (let n = 0; n < e.length; n++) {
const s = e[n], r = mt(s) ? kf(s) : Ee(s);
if (r)
for (const i in r)
t[i] = r[i];
}
return t;
} else if (mt(e) || ut(e))
return e;
}
const vf = /;(?![^(]*\))/g, bf = /:([^]+)/, wf = /\/\*[^]*?\*\//g;
function kf(e) {
const t = {};
return e.replace(wf, "").split(vf).forEach((n) => {
if (n) {
const s = n.split(bf);
s.length > 1 && (t[s[0].trim()] = s[1].trim());
}
}), t;
}
function Ue(e) {
let t = "";
if (mt(e))
t = e;
else if (ve(e))
for (let n = 0; n < e.length; n++) {
const s = Ue(e[n]);
s && (t += s + " ");
}
else if (ut(e))
for (const n in e)
e[n] && (t += n + " ");
return t.trim();
}
const xf = "itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly", Tf = /* @__PURE__ */ ta(xf);
function _c(e) {
return !!e || e === "";
}
const yc = (e) => !!(e && e.__v_isRef === !0), se = (e) => mt(e) ? e : e == null ? "" : ve(e) || ut(e) && (e.toString === pc || !ke(e.toString)) ? yc(e) ? se(e.value) : JSON.stringify(e, vc, 2) : String(e), vc = (e, t) => yc(t) ? vc(e, t.value) : Ds(t) ? {
[`Map(${t.size})`]: [...t.entries()].reduce(
(n, [s, r], i) => (n[lo(s, i) + " =>"] = r, n),
{}
)
} : hc(t) ? {
[`Set(${t.size})`]: [...t.values()].map((n) => lo(n))
} : ns(t) ? lo(t) : ut(t) && !ve(t) && !gc(t) ? String(t) : t, lo = (e, t = "") => {
var n;
return (
// Symbol.description in es2019+ so we need to cast here to pass
// the lib: es2016 check
ns(e) ? `Symbol(${(n = e.description) != null ? n : t})` : e
);
};
/**
* @vue/reactivity v3.5.18
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
let Ht;
class Af {
constructor(t = !1) {
this.detached = t, this._active = !0, this._on = 0, this.effects = [], this.cleanups = [], this._isPaused = !1, this.parent = Ht, !t && Ht && (this.index = (Ht.scopes || (Ht.scopes = [])).push(
this
) - 1);
}
get active() {
return this._active;
}
pause() {
if (this._active) {
this._isPaused = !0;
let t, n;
if (this.scopes)
for (t = 0, n = this.scopes.length; t < n; t++)
this.scopes[t].pause();
for (t = 0, n = this.effects.length; t < n; t++)
this.effects[t].pause();
}
}
/**
* Resumes the effect scope, including all child scopes and effects.
*/
resume() {
if (this._active && this._isPaused) {
this._isPaused = !1;
let t, n;
if (this.scopes)
for (t = 0, n = this.scopes.length; t < n; t++)
this.scopes[t].resume();
for (t = 0, n = this.effects.length; t < n; t++)
this.effects[t].resume();
}
}
run(t) {
if (this._active) {
const n = Ht;
try {
return Ht = this, t();
} finally {
Ht = n;
}
}
}
/**
* This should only be called on non-detached scopes
* @internal
*/
on() {
++this._on === 1 && (this.prevScope = Ht, Ht = this);
}
/**
* This should only be called on non-detached scopes
* @internal
*/
off() {
this._on > 0 && --this._on === 0 && (Ht = this.prevScope, this.prevScope = void 0);
}
stop(t) {
if (this._active) {
this._active = !1;
let n, s;
for (n = 0, s = this.effects.length; n < s; n++)
this.effects[n].stop();
for (this.effects.length = 0, n = 0, s = this.cleanups.length; n < s; n++)
this.cleanups[n]();
if (this.cleanups.length = 0, this.scopes) {
for (n = 0, s = this.scopes.length; n < s; n++)
this.scopes[n].stop(!0);
this.scopes.length = 0;
}
if (!this.detached && this.parent && !t) {
const r = this.parent.scopes.pop();
r && r !== this && (this.parent.scopes[this.index] = r, r.index = this.index);
}
this.parent = void 0;
}
}
}
function Ef() {
return Ht;
}
let ot;
const co = /* @__PURE__ */ new WeakSet();
class bc {
constructor(t) {
this.fn = t, this.deps = void 0, this.depsTail = void 0, this.flags = 5, this.next = void 0, this.cleanup = void 0, this.scheduler = void 0, Ht && Ht.active && Ht.effects.push(this);
}
pause() {
this.flags |= 64;
}
resume() {
this.flags & 64 && (this.flags &= -65, co.has(this) && (co.delete(this), this.trigger()));
}
/**
* @internal
*/
notify() {
this.flags & 2 && !(this.flags & 32) || this.flags & 8 || kc(this);
}
run() {
if (!(this.flags & 1))
return this.fn();
this.flags |= 2, el(this), xc(this);
const t = ot, n = cn;
ot = this, cn = !0;
try {
return this.fn();
} finally {
Tc(this), ot = t, cn = n, this.flags &= -3;
}
}
stop() {
if (this.flags & 1) {
for (let t = this.deps; t; t = t.nextDep)
aa(t);
this.deps = this.depsTail = void 0, el(this), this.onStop && this.onStop(), this.flags &= -2;
}
}
trigger() {
this.flags & 64 ? co.add(this) : this.scheduler ? this.scheduler() : this.runIfDirty();
}
/**
* @internal
*/
runIfDirty() {
Do(this) && this.run();
}
get dirty() {
return Do(this);
}
}
let wc = 0, kr, xr;
function kc(e, t = !1) {
if (e.flags |= 8, t) {
e.next = xr, xr = e;
return;
}
e.next = kr, kr = e;
}
function ia() {
wc++;
}
function oa() {
if (--wc > 0)
return;
if (xr) {
let t = xr;
for (xr = void 0; t; ) {
const n = t.next;
t.next = void 0, t.flags &= -9, t = n;
}
}
let e;
for (; kr; ) {
let t = kr;
for (kr = void 0; t; ) {
const n = t.next;
if (t.next = void 0, t.flags &= -9, t.flags & 1)
try {
t.trigger();
} catch (s) {
e || (e = s);
}
t = n;
}
}
if (e) throw e;
}
function xc(e) {
for (let t = e.deps; t; t = t.nextDep)
t.version = -1, t.prevActiveLink = t.dep.activeLink, t.dep.activeLink = t;
}
function Tc(e) {
let t, n = e.depsTail, s = n;
for (; s; ) {
const r = s.prevDep;
s.version === -1 ? (s === n && (n = r), aa(s), Sf(s)) : t = s, s.dep.activeLink = s.prevActiveLink, s.prevActiveLink = void 0, s = r;
}
e.deps = t, e.depsTail = n;
}
function Do(e) {
for (let t = e.deps; t; t = t.nextDep)
if (t.dep.version !== t.version || t.dep.computed && (Ac(t.dep.computed) || t.dep.version !== t.version))
return !0;
return !!e._dirty;
}
function Ac(e) {
if (e.flags & 4 && !(e.flags & 16) || (e.flags &= -17, e.globalVersion === Rr) || (e.globalVersion = Rr, !e.isSSR && e.flags & 128 && (!e.deps && !e._dirty || !Do(e))))
return;
e.flags |= 2;
const t = e.dep, n = ot, s = cn;
ot = e, cn = !0;
try {
xc(e);
const r = e.fn(e._value);
(t.version === 0 || Xn(r, e._value)) && (e.flags |= 128, e._value = r, t.version++);
} catch (r) {
throw t.version++, r;
} finally {
ot = n, cn = s, Tc(e), e.flags &= -3;
}
}
function aa(e, t = !1) {
const { dep: n, prevSub: s, nextSub: r } = e;
if (s && (s.nextSub = r, e.prevSub = void 0), r && (r.prevSub = s, e.nextSub = void 0), n.subs === e && (n.subs = s, !s && n.computed)) {
n.computed.flags &= -5;
for (let i = n.computed.deps; i; i = i.nextDep)
aa(i, !0);
}
!t && !--n.sc && n.map && n.map.delete(n.key);
}
function Sf(e) {
const { prevDep: t, nextDep: n } = e;
t && (t.nextDep = n, e.prevDep = void 0), n && (n.prevDep = t, e.nextDep = void 0);
}
let cn = !0;
const Ec = [];
function Fn() {
Ec.push(cn), cn = !1;
}
function Bn() {
const e = Ec.pop();
cn = e === void 0 ? !0 : e;
}
function el(e) {
const { cleanup: t } = e;
if (e.cleanup = void 0, t) {
const n = ot;
ot = void 0;
try {
t();
} finally {
ot = n;
}
}
}
let Rr = 0;
class Cf {
constructor(t, n) {
this.sub = t, this.dep = n, this.version = n.version, this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
}
}
class la {
// TODO isolatedDeclarations "__v_skip"
constructor(t) {
this.computed = t, this.version = 0, this.activeLink = void 0, this.subs = void 0, this.map = void 0, this.key = void 0, this.sc = 0, this.__v_skip = !0;
}
track(t) {
if (!ot || !cn || ot === this.computed)
return;
let n = this.activeLink;
if (n === void 0 || n.sub !== ot)
n = this.activeLink = new Cf(ot, this), ot.deps ? (n.prevDep = ot.depsTail, ot.depsTail.nextDep = n, ot.depsTail = n) : ot.deps = ot.depsTail = n, Sc(n);
else if (n.version === -1 && (n.version = this.version, n.nextDep)) {
const s = n.nextDep;
s.prevDep = n.prevDep, n.prevDep && (n.prevDep.nextDep = s), n.prevDep = ot.depsTail, n.nextDep = void 0, ot.depsTail.nextDep = n, ot.depsTail = n, ot.deps === n && (ot.deps = s);
}
return n;
}
trigger(t) {
this.version++, Rr++, this.notify(t);
}
notify(t) {
ia();
try {
for (let n = this.subs; n; n = n.prevSub)
n.sub.notify() && n.sub.dep.notify();
} finally {
oa();
}
}
}
function Sc(e) {
if (e.dep.sc++, e.sub.flags & 4) {
const t = e.dep.computed;
if (t && !e.dep.subs) {
t.flags |= 20;
for (let s = t.deps; s; s = s.nextDep)
Sc(s);
}
const n = e.dep.subs;
n !== e && (e.prevSub = n, n && (n.nextSub = e)), e.dep.subs = e;
}
}
const Po = /* @__PURE__ */ new WeakMap(), _s = Symbol(
""
), Fo = Symbol(
""
), Ir = Symbol(
""
);
function Ot(e, t, n) {
if (cn && ot) {
let s = Po.get(e);
s || Po.set(e, s = /* @__PURE__ */ new Map());
let r = s.get(n);
r || (s.set(n, r = new la()), r.map = s, r.key = n), r.track();
}
}
function Nn(e, t, n, s, r, i) {
const o = Po.get(e);
if (!o) {
Rr++;
return;
}
const a = (l) => {
l && l.trigger();
};
if (ia(), t === "clear")
o.forEach(a);
else {
const l = ve(e), d = l && ra(n);
if (l && n === "length") {
const c = Number(s);
o.forEach((b, w) => {
(w === "length" || w === Ir || !ns(w) && w >= c) && a(b);
});
} else
switch ((n !== void 0 || o.has(void 0)) && a(o.get(n)), d && a(o.get(Ir)), t) {
case "add":
l ? d && a(o.get("length")) : (a(o.get(_s)), Ds(e) && a(o.get(Fo)));
break;
case "delete":
l || (a(o.get(_s)), Ds(e) && a(o.get(Fo)));
break;
case "set":
Ds(e) && a(o.get(_s));
break;
}
}
oa();
}
function Is(e) {
const t = qe(e);
return t === e ? t : (Ot(t, "iterate", Ir), rn(e) ? t : t.map(St));
}
function Fi(e) {
return Ot(e = qe(e), "iterate", Ir), e;
}
const Rf = {
__proto__: null,
[Symbol.iterator]() {
return uo(this, Symbol.iterator, St);
},
concat(...e) {
return Is(this).concat(
...e.map((t) => ve(t) ? Is(t) : t)
);
},
entries() {
return uo(this, "entries", (e) => (e[1] = St(e[1]), e));
},
every(e, t) {
return In(this, "every", e, t, void 0, arguments);
},
filter(e, t) {
return In(this, "filter", e, t, (n) => n.map(St), arguments);
},
find(e, t) {
return In(this, "find", e, t, St, arguments);
},
findIndex(e, t) {
return In(this, "findIndex", e, t, void 0, arguments);
},
findLast(e, t) {
return In(this, "findLast", e, t, St, arguments);
},
findLastIndex(e, t) {
return In(this, "findLastIndex", e, t, void 0, arguments);
},
// flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
forEach(e, t) {
return In(this, "forEach", e, t, void 0, arguments);
},
includes(...e) {
return fo(this, "includes", e);
},
indexOf(...e) {
return fo(this, "indexOf", e);
},
join(e) {
return Is(this).join(e);
},
// keys() iterator only reads `length`, no optimisation required
lastIndexOf(...e) {
return fo(this, "lastIndexOf", e);
},
map(e, t) {
return In(this, "map", e, t, void 0, arguments);
},
pop() {
return ar(this, "pop");
},
push(...e) {
return ar(this, "push", e);
},
reduce(e, ...t) {
return tl(this, "reduce", e, t);
},
reduceRight(e, ...t) {
return tl(this, "reduceRight", e, t);
},
shift() {
return ar(this, "shift");
},
// slice could use ARRAY_ITERATE but also seems to beg for range tracking
some(e, t) {
return In(this, "some", e, t, void 0, arguments);
},
splice(...e) {
return ar(this, "splice", e);
},
toReversed() {
return Is(this).toReversed();
},
toSorted(e) {
return Is(this).toSorted(e);
},
toSpliced(...e) {
return Is(this).toSpliced(...e);
},
unshift(...e) {
return ar(this, "unshift", e);
},
values() {
return uo(this, "values", St);
}
};
function uo(e, t, n) {
const s = Fi(e), r = s[t]();
return s !== e && !rn(e) && (r._next = r.next, r.next = () => {
const i = r._next();
return i.value && (i.value = n(i.value)), i;
}), r;
}
const If = Array.prototype;
function In(e, t, n, s, r, i) {
const o = Fi(e), a = o !== e && !rn(e), l = o[t];
if (l !== If[t]) {
const b = l.apply(e, i);
return a ? St(b) : b;
}
let d = n;
o !== e && (a ? d = function(b, w) {
return n.call(this, St(b), w, e);
} : n.length > 2 && (d = function(b, w) {
return n.call(this, b, w, e);
}));
const c = l.call(o, d, s);
return a && r ? r(c) : c;
}
function tl(e, t, n, s) {
const r = Fi(e);
let i = n;
return r !== e && (rn(e) ? n.length > 3 && (i = function(o, a, l) {
return n.call(this, o, a, l, e);
}) : i = function(o, a, l) {
return n.call(this, o, St(a), l, e);
}), r[t](i, ...s);
}
function fo(e, t, n) {
const s = qe(e);
Ot(s, "iterate", Ir);
const r = s[t](...n);
return (r === -1 || r === !1) && fa(n[0]) ? (n[0] = qe(n[0]), s[t](...n)) : r;
}
function ar(e, t, n = []) {
Fn(), ia();
const s = qe(e)[t].apply(e, n);
return oa(), Bn(), s;
}
const Lf = /* @__PURE__ */ ta("__proto__,__v_isRef,__isVue"), Cc = new Set(
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((e) => e !== "arguments" && e !== "caller").map((e) => Symbol[e]).filter(ns)
);
function Of(e) {
ns(e) || (e = String(e));
const t = qe(this);
return Ot(t, "has", e), t.hasOwnProperty(e);
}
class Rc {
constructor(t = !1, n = !1) {
this._isReadonly = t, this._isShallow = n;
}
get(t, n, s) {
if (n === "__v_skip") return t.__v_skip;
const r = this._isReadonly, i = this._isShallow;
if (n === "__v_isReactive")
return !r;
if (n === "__v_isReadonly")
return r;
if (n === "__v_isShallow")
return i;
if (n === "__v_raw")
return s === (r ? i ? Hf : Nc : i ? Oc : Lc).get(t) || // receiver is not the reactive proxy, but has the same prototype
// this means the receiver is a user proxy of the reactive proxy
Object.getPrototypeOf(t) === Object.getPrototypeOf(s) ? t : void 0;
const o = ve(t);
if (!r) {
let l;
if (o && (l = Rf[n]))
return l;
if (n === "hasOwnProperty")
return Of;
}
const a = Reflect.get(
t,
n,
// if this is a proxy wrapping a ref, return methods using the raw ref
// as receiver so that we don't have to call `toRaw` on the ref in all
// its class methods
Nt(t) ? t : s
);
return (ns(n) ? Cc.has(n) : Lf(n)) || (r || Ot(t, "get", n), i) ? a : Nt(a) ? o && ra(n) ? a : a.value : ut(a) ? r ? Mc(a) : Bi(a) : a;
}
}
class Ic extends Rc {
constructor(t = !1) {
super(!1, t);
}
set(t, n, s, r) {
let i = t[n];
if (!this._isShallow) {
const l = es(i);
if (!rn(s) && !es(s) && (i = qe(i), s = qe(s)), !ve(t) && Nt(i) && !Nt(s))
return l ? !1 : (i.value = s, !0);
}
const o = ve(t) && ra(n) ? Number(n) < t.length : je(t, n), a = Reflect.set(
t,
n,
s,
Nt(t) ? t : r
);
return t === qe(r) && (o ? Xn(s, i) && Nn(t, "set", n, s) : Nn(t, "add", n, s)), a;
}
deleteProperty(t, n) {
const s = je(t, n);
t[n];
const r = Reflect.deleteProperty(t, n);
return r && s && Nn(t, "delete", n, void 0), r;
}
has(t, n) {
const s = Reflect.has(t, n);
return (!ns(n) || !Cc.has(n)) && Ot(t, "has", n), s;
}
ownKeys(t) {
return Ot(
t,
"iterate",
ve(t) ? "length" : _s
), Reflect.ownKeys(t);
}
}
class Nf extends Rc {
constructor(t = !1) {
super(!0, t);
}
set(t, n) {
return !0;
}
deleteProperty(t, n) {
return !0;
}
}
const Mf = /* @__PURE__ */ new Ic(), Df = /* @__PURE__ */ new Nf(), Pf = /* @__PURE__ */ new Ic(!0);
const Bo = (e) => e, Zr = (e) => Reflect.getPrototypeOf(e);
function Ff(e, t, n) {
return function(...s) {
const r = this.__v_raw, i = qe(r), o = Ds(i), a = e === "entries" || e === Symbol.iterator && o, l = e === "keys" && o, d = r[e](...s), c = n ? Bo : t ? bi : St;
return !t && Ot(
i,
"iterate",
l ? Fo : _s
), {
// iterator protocol
next() {
const { value: b, done: w } = d.next();
return w ? { value: b, done: w } : {
value: a ? [c(b[0]), c(b[1])] : c(b),
done: w
};
},
// iterable protocol
[Symbol.iterator]() {
return this;
}
};
};
}
function Xr(e) {
return function(...t) {
return e === "delete" ? !1 : e === "clear" ? void 0 : this;
};
}
function Bf(e, t) {
const n = {
get(r) {
const i = this.__v_raw, o = qe(i), a = qe(r);
e || (Xn(r, a) && Ot(o, "get", r), Ot(o, "get", a));
const { has: l } = Zr(o), d = t ? Bo : e ? bi : St;
if (l.call(o, r))
return d(i.get(r));
if (l.call(o, a))
return d(i.get(a));
i !== o && i.get(r);
},
get size() {
const r = this.__v_raw;
return !e && Ot(qe(r), "iterate", _s), Reflect.get(r, "size", r);
},
has(r) {
const i = this.__v_raw, o = qe(i), a = qe(r);
return e || (Xn(r, a) && Ot(o, "has", r), Ot(o, "has", a)), r === a ? i.has(r) : i.has(r) || i.has(a);
},
forEach(r, i) {
const o = this, a = o.__v_raw, l = qe(a), d = t ? Bo : e ? bi : St;
return !e && Ot(l, "iterate", _s), a.forEach((c, b) => r.call(i, d(c), d(b), o));
}
};
return Mt(
n,
e ? {
add: Xr("add"),
set: Xr("set"),
delete: Xr("delete"),
clear: Xr("clear")
} : {
add(r) {
!t && !rn(r) && !es(r) && (r = qe(r));
const i = qe(this);
return Zr(i).has.call(i, r) || (i.add(r), Nn(i, "add", r, r)), this;
},
set(r, i) {
!t && !rn(i) && !es(i) && (i = qe(i));
const o = qe(this), { has: a, get: l } = Zr(o);
let d = a.call(o, r);
d || (r = qe(r), d = a.call(o, r));
const c = l.call(o, r);
return o.set(r, i), d ? Xn(i, c) && Nn(o, "set", r, i) : Nn(o, "add", r, i), this;
},
delete(r) {
const i = qe(this), { has: o, get: a } = Zr(i);
let l = o.call(i, r);
l || (r = qe(r), l = o.call(i, r)), a && a.call(i, r);
const d = i.delete(r);
return l && Nn(i, "delete", r, void 0), d;
},
clear() {
const r = qe(this), i = r.size !== 0, o = r.clear();
return i && Nn(
r,
"clear",
void 0,
void 0
), o;
}
}
), [
"keys",
"values",
"entries",
Symbol.iterator
].forEach((r) => {
n[r] = Ff(r, e, t);
}), n;
}
function ca(e, t) {
const n = Bf(e, t);
return (s, r, i) => r === "__v_isReactive" ? !e : r === "__v_isReadonly" ? e : r === "__v_raw" ? s : Reflect.get(
je(n, r) && r in s ? n : s,
r,
i
);
}
const $f = {
get: /* @__PURE__ */ ca(!1, !1)
}, Uf = {
get: /* @__PURE__ */ ca(!1, !0)
}, zf = {
get: /* @__PURE__ */ ca(!0, !1)
};
const Lc = /* @__PURE__ */ new WeakMap(), Oc = /* @__PURE__ */ new WeakMap(), Nc = /* @__PURE__ */ new WeakMap(), Hf = /* @__PURE__ */ new WeakMap();
function Wf(e) {
switch (e) {
case "Object":
case "Array":
return 1;
case "Map":
case "Set":
case "WeakMap":
case "WeakSet":
return 2;
default:
return 0;
}
}
function qf(e) {
return e.__v_skip || !Object.isExtensible(e) ? 0 : Wf(mf(e));
}
function Bi(e) {
return es(e) ? e : ua(
e,
!1,
Mf,
$f,
Lc
);
}
function jf(e) {
return ua(
e,
!1,
Pf,
Uf,
Oc
);
}
function Mc(e) {
return ua(
e,
!0,
Df,
zf,
Nc
);
}
function ua(e, t, n, s, r) {
if (!ut(e) || e.__v_raw && !(t && e.__v_isReactive))
return e;
const i = qf(e);
if (i === 0)
return e;
const o = r.get(e);
if (o)
return o;
const a = new Proxy(
e,
i === 2 ? s : n
);
return r.set(e, a), a;
}
function Ps(e) {
return es(e) ? Ps(e.__v_raw) : !!(e && e.__v_isReactive);
}
function es(e) {
return !!(e && e.__v_isReadonly);
}
function rn(e) {
return !!(e && e.__v_isShallow);
}
function fa(e) {
return e ? !!e.__v_raw : !1;
}
function qe(e) {
const t = e && e.__v_raw;
return t ? qe(t) : e;
}
function Vf(e) {
return !je(e, "__v_skip") && Object.isExtensible(e) && No(e, "__v_skip", !0), e;
}
const St = (e) => ut(e) ? Bi(e) : e, bi = (e) => ut(e) ? Mc(e) : e;
function Nt(e) {
return e ? e.__v_isRef === !0 : !1;
}
function ce(e) {
return Kf(e, !1);
}
function Kf(e, t) {
return Nt(e) ? e : new Gf(e, t);
}
class Gf {
constructor(t, n) {
this.dep = new la(), this.__v_isRef = !0, this.__v_isShallow = !1, this._rawValue = n ? t : qe(t), this._value = n ? t : St(t), this.__v_isShallow = n;
}
get value() {
return this.dep.track(), this._value;
}
set value(t) {
const n = this._rawValue, s = this.__v_isShallow || rn(t) || es(t);
t = s ? t : qe(t), Xn(t, n) && (this._rawValue = t, this._value = s ? t : St(t), this.dep.trigger());
}
}
function S(e) {
return Nt(e) ? e.value : e;
}
const Yf = {
get: (e, t, n) => t === "__v_raw" ? e : S(Reflect.get(e, t, n)),
set: (e, t, n, s) => {
const r = e[t];
return Nt(r) && !Nt(n) ? (r.value = n, !0) : Reflect.set(e, t, n, s);
}
};
function Dc(e) {
return Ps(e) ? e : new Proxy(e, Yf);
}
class Zf {
constructor(t, n, s) {
this.fn = t, this.setter = n, this._value = void 0, this.dep = new la(this), this.__v_isRef = !0, this.deps = void 0, this.depsTail = void 0, this.flags = 16, this.globalVersion = Rr - 1, this.next = void 0, this.effect = this, this.__v_isReadonly = !n, this.isSSR = s;
}
/**
* @internal
*/
notify() {
if (this.flags |= 16, !(this.flags & 8) && // avoid infinite self recursion
ot !== this)
return kc(this, !0), !0;
}
get value() {
const t = this.dep.track();
return Ac(this), t && (t.version = this.dep.version), this._value;
}
set value(t) {
this.setter && this.setter(t);
}
}
function Xf(e, t, n = !1) {
let s, r;
return ke(e) ? s = e : (s = e.get, r = e.set), new Zf(s, r, n);
}
const Jr = {}, wi = /* @__PURE__ */ new WeakMap();
let ps;
function Jf(e, t = !1, n = ps) {
if (n) {
let s = wi.get(n);
s || wi.set(n, s = []), s.push(e);
}
}
function Qf(e, t, n = tt) {
const { immediate: s, deep: r, once: i, scheduler: o, augmentJob: a, call: l } = n, d = (R) => r ? R : rn(R) || r === !1 || r === 0 ? Mn(R, 1) : Mn(R);
let c, b, w, z, I = !1, K = !1;
if (Nt(e) ? (b = () => e.value, I = rn(e)) : Ps(e) ? (b = () => d(e), I = !0) : ve(e) ? (K = !0, I = e.some((R) => Ps(R) || rn(R)), b = () => e.map((R) => {
if (Nt(R))
return R.value;
if (Ps(R))
return d(R);
if (ke(R))
return l ? l(R, 2) : R();
})) : ke(e) ? t ? b = l ? () => l(e, 2) : e : b = () => {
if (w) {
Fn();
try {
w();
} finally {
Bn();
}
}
const R = ps;
ps = c;
try {
return l ? l(e, 3, [z]) : e(z);
} finally {
ps = R;
}
} : b = yn, t && r) {
const R = b, N = r === !0 ? 1 / 0 : r;
b = () => Mn(R(), N);
}
const P = Ef(), oe = () => {
c.stop(), P && P.active && sa(P.effects, c);
};
if (i && t) {
const R = t;
t = (...N) => {
R(...N), oe();
};
}
let fe = K ? new Array(e.length).fill(Jr) : Jr;
const pe = (R) => {
if (!(!(c.flags & 1) || !c.dirty && !R))
if (t) {
const N = c.run();
if (r || I || (K ? N.some((Y, X) => Xn(Y, fe[X])) : Xn(N, fe))) {
w && w();
const Y = ps;
ps = c;
try {
const X = [
N,
// pass undefined as the old value when it's changed for the first time
fe === Jr ? void 0 : K && fe[0] === Jr ? [] : fe,
z
];
fe = N, l ? l(t, 3, X) : (
// @ts-expect-error
t(...X)
);
} finally {
ps = Y;
}
}
} else
c.run();
};
return a && a(pe), c = new bc(b), c.scheduler = o ? () => o(pe, !1) : pe, z = (R) => Jf(R, !1, c), w = c.onStop = () => {
const R = wi.get(c);
if (R) {
if (l)
l(R, 4);
else
for (const N of R) N();
wi.delete(c);
}
}, t ? s ? pe(!0) : fe = c.run() : o ? o(pe.bind(null, !0), !0) : c.run(), oe.pause = c.pause.bind(c), oe.resume = c.resume.bind(c), oe.stop = oe, oe;
}
function Mn(e, t = 1 / 0, n) {
if (t <= 0 || !ut(e) || e.__v_skip || (n = n || /* @__PURE__ */ new Set(), n.has(e)))
return e;
if (n.add(e), t--, Nt(e))
Mn(e.value, t, n);
else if (ve(e))
for (let s = 0; s < e.length; s++)
Mn(e[s], t, n);
else if (hc(e) || Ds(e))
e.forEach((s) => {
Mn(s, t, n);
});
else if (gc(e)) {
for (const s in e)
Mn(e[s], t, n);
for (const s of Object.getOwnPropertySymbols(e))
Object.prototype.propertyIsEnumerable.call(e, s) && Mn(e[s], t, n);
}
return e;
}
/**
* @vue/runtime-core v3.5.18
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
function Mr(e, t, n, s) {
try {
return s ? e(...s) : e();
} catch (r) {
$i(r, t, n);
}
}
function bn(e, t, n, s) {
if (ke(e)) {
const r = Mr(e, t, n, s);
return r && dc(r) && r.catch((i) => {
$i(i, t, n);
}), r;
}
if (ve(e)) {
const r = [];
for (let i = 0; i < e.length; i++)
r.push(bn(e[i], t, n, s));
return r;
}
}
function $i(e, t, n, s = !0) {
const r = t ? t.vnode : null, { errorHandler: i, throwUnhandledErrorInProduction: o } = t && t.appContext.config || tt;
if (t) {
let a = t.parent;
const l = t.proxy, d = `https://vuejs.org/error-reference/#runtime-${n}`;
for (; a; ) {
const c = a.ec;
if (c) {
for (let b = 0; b < c.length; b++)
if (c[b](e, l, d) === !1)
return;
}
a = a.parent;
}
if (i) {
Fn(), Mr(i, null, 10, [
e,
l,
d
]), Bn();
return;
}
}
eh(e, n, r, s, o);
}
function eh(e, t, n, s = !0, r = !1) {
if (r)
throw e;
console.error(e);
}
const Bt = [];
let mn = -1;
const Fs = [];
let Gn = null, Ls = 0;
const Pc = /* @__PURE__ */ Promise.resolve();
let ki = null;
function ys(e) {
const t = ki || Pc;
return e ? t.then(this ? e.bind(this) : e) : t;
}
function th(e) {
let t = mn + 1, n = Bt.length;
for (; t < n; ) {
const s = t + n >>> 1, r = Bt[s], i = Lr(r);
i < e || i === e && r.flags & 2 ? t = s + 1 : n = s;
}
return t;
}
function ha(e) {
if (!(e.flags & 1)) {
const t = Lr(e), n = Bt[Bt.length - 1];
!n || // fast path when the job id is larger than the tail
!(e.flags & 2) && t >= Lr(n) ? Bt.push(e) : Bt.splice(th(t), 0, e), e.flags |= 1, Fc();
}
}
function Fc() {
ki || (ki = Pc.then($c));
}
function nh(e) {
ve(e) ? Fs.push(...e) : Gn && e.id === -1 ? Gn.splice(Ls + 1, 0, e) : e.flags & 1 || (Fs.push(e), e.flags |= 1), Fc();
}
function nl(e, t, n = mn + 1) {
for (; n < Bt.length; n++) {
const s = Bt[n];
if (s && s.flags & 2) {
if (e && s.id !== e.uid)
continue;
Bt.splice(n, 1), n--, s.flags & 4 && (s.flags &= -2), s(), s.flags & 4 || (s.flags &= -2);
}
}
}
function Bc(e) {
if (Fs.length) {
const t = [...new Set(Fs)].sort(
(n, s) => Lr(n) - Lr(s)
);
if (Fs.length = 0, Gn) {
Gn.push(...t);
return;
}
for (Gn = t, Ls = 0; Ls < Gn.length; Ls++) {
const n = Gn[Ls];
n.flags & 4 && (n.flags &= -2), n.flags & 8 || n(), n.flags &= -2;
}
Gn = null, Ls = 0;
}
}
const Lr = (e) => e.id == null ? e.flags & 2 ? -1 : 1 / 0 : e.id;
function $c(e) {
try {
for (mn = 0; mn < Bt.length; mn++) {
const t = Bt[mn];
t && !(t.flags & 8) && (t.flags & 4 && (t.flags &= -2), Mr(
t,
t.i,
t.i ? 15 : 14
), t.flags & 4 || (t.flags &= -2));
}
} finally {
for (; mn < Bt.length; mn++) {
const t = Bt[mn];
t && (t.flags &= -2);
}
mn = -1, Bt.length = 0, Bc(), ki = null, (Bt.length || Fs.length) && $c();
}
}
let sn = null, Uc = null;
function xi(e) {
const t = sn;
return sn = e, Uc = e && e.type.__scopeId || null, t;
}
function sh(e, t = sn, n) {
if (!t || e._n)
return e;
const s = (...r) => {
s._d && fl(-1);
const i = xi(t);
let o;
try {
o = e(...r);
} finally {
xi(i), s._d && fl(1);
}
return o;
};
return s._n = !0, s._c = !0, s._d = !0, s;
}
function Vn(e, t) {
if (sn === null)
return e;
const n = ji(sn), s = e.dirs || (e.dirs = []);
for (let r = 0; r < t.length; r++) {
let [i, o, a, l = tt] = t[r];
i && (ke(i) && (i = {
mounted: i,
updated: i
}), i.deep && Mn(o), s.push({
dir: i,
instance: n,
value: o,
oldValue: void 0,
arg: a,
modifiers: l
}));
}
return e;
}
function us(e, t, n, s) {
const r = e.dirs, i = t && t.dirs;
for (let o = 0; o < r.length; o++) {
const a = r[o];
i && (a.oldValue = i[o].value);
let l = a.dir[s];
l && (Fn(), bn(l, n, 8, [
e.el,
a,
e,
t
]), Bn());
}
}
const rh = Symbol("_vte"), ih = (e) => e.__isTeleport;
function da(e, t) {
e.shapeFlag & 6 && e.component ? (e.transition = t, da(e.component.subTree, t)) : e.shapeFlag & 128 ? (e.ssContent.transition = t.clone(e.ssContent), e.ssFallback.transition = t.clone(e.ssFallback)) : e.transition = t;
}
/*! #__NO_SIDE_EFFECTS__ */
// @__NO_SIDE_EFFECTS__
function Ui(e, t) {
return ke(e) ? (
// #8236: extend call and options.name access are considered side-effects
// by Rollup, so we have to wrap it in a pure-annotated IIFE.
Mt({ name: e.name }, t, { setup: e })
) : e;
}
function zc(e) {
e.ids = [e.ids[0] + e.ids[2]++ + "-", 0, 0];
}
function Tr(e, t, n, s, r = !1) {
if (ve(e)) {
e.forEach(
(I, K) => Tr(
I,
t && (ve(t) ? t[K] : t),
n,
s,
r
)
);
return;
}
if (Ar(s) && !r) {
s.shapeFlag & 512 && s.type.__asyncResolved && s.component.subTree.component && Tr(e, t, n, s.component.subTree);
return;
}
const i = s.shapeFlag & 4 ? ji(s.component) : s.el, o = r ? null : i, { i: a, r: l } = e, d = t && t.r, c = a.refs === tt ? a.refs = {} : a.refs, b = a.setupState, w = qe(b), z = b === tt ? () => !1 : (I) => je(w, I);
if (d != null && d !== l && (mt(d) ? (c[d] = null, z(d) && (b[d] = null)) : Nt(d) && (d.value = null)), ke(l))
Mr(l, a, 12, [o, c]);
else {
const I = mt(l), K = Nt(l);
if (I || K) {
const P = () => {
if (e.f) {
const oe = I ? z(l) ? b[l] : c[l] : l.value;
r ? ve(oe) && sa(oe, i) : ve(oe) ? oe.includes(i) || oe.push(i) : I ? (c[l] = [i], z(l) && (b[l] = c[l])) : (l.value = [i], e.k && (c[e.k] = l.value));
} else I ? (c[l] = o, z(l) && (b[l] = o)) : K && (l.value = o, e.k && (c[e.k] = o));
};
o ? (P.id = -1, Vt(P, n)) : P();
}
}
}
Pi().requestIdleCallback;
Pi().cancelIdleCallback;
const Ar = (e) => !!e.type.__asyncLoader, Hc = (e) => e.type.__isKeepAlive;
function oh(e, t) {
Wc(e, "a", t);
}
function ah(e, t) {
Wc(e, "da", t);
}
function Wc(e, t, n = Ut) {
const s = e.__wdc || (e.__wdc = () => {
let r = n;
for (; r; ) {
if (r.isDeactivated)
return;
r = r.parent;
}
return e();
});
if (zi(t, s, n), n) {
let r = n.parent;
for (; r && r.parent; )
Hc(r.parent.vnode) && lh(s, t, n, r), r = r.parent;
}
}
function lh(e, t, n, s) {
const r = zi(
t,
e,
s,
!0
/* prepend */
);
Dr(() => {
sa(s[t], r);
}, n);
}
function zi(e, t, n = Ut, s = !1) {
if (n) {
const r = n[e] || (n[e] = []), i = t.__weh || (t.__weh = (...o) => {
Fn();
const a = Pr(n), l = bn(t, n, e, o);
return a(), Bn(), l;
});
return s ? r.unshift(i) : r.push(i), i;
}
}
const $n = (e) => (t, n = Ut) => {
(!Nr || e === "sp") && zi(e, (...s) => t(...s), n);
}, ch = $n("bm"), Hi = $n("m"), uh = $n(
"bu"
), fh = $n("u"), qc = $n(
"bum"
), Dr = $n("um"), hh = $n(
"sp"
), dh = $n("rtg"), ph = $n("rtc");
function gh(e, t = Ut) {
zi("ec", e, t);
}
const mh = Symbol.for("v-ndc");
function Et(e, t, n, s) {
let r;
const i = n, o = ve(e);
if (o || mt(e)) {
const a = o && Ps(e);
let l = !1, d = !1;
a && (l = !rn(e), d = es(e), e = Fi(e)), r = new Array(e.length);
for (let c = 0, b = e.length; c < b; c++)
r[c] = t(
l ? d ? bi(St(e[c])) : St(e[c]) : e[c],
c,
void 0,
i
);
} else if (typeof e == "number") {
r = new Array(e);
for (let a = 0; a < e; a++)
r[a] = t(a + 1, a, void 0, i);
} else if (ut(e))
if (e[Symbol.iterator])
r = Array.from(
e,
(a, l) => t(a, l, void 0, i)
);
else {
const a = Object.keys(e);
r = new Array(a.length);
for (let l = 0, d = a.length; l < d; l++) {
const c = a[l];
r[l] = t(e[c], c, l, i);
}
}
else
r = [];
return r;
}
const $o = (e) => e ? fu(e) ? ji(e) : $o(e.parent) : null, Er = (
// Move PURE marker to new line to workaround compiler discarding it
// due to type annotation
/* @__PURE__ */ Mt(/* @__PURE__ */ Object.create(null), {
$: (e) => e,
$el: (e) => e.vnode.el,
$data: (e) => e.data,
$props: (e) => e.props,
$attrs: (e) => e.attrs,
$slots: (e) => e.slots,
$refs: (e) => e.refs,
$parent: (e) => $o(e.parent),
$root: (e) => $o(e.root),
$host: (e) => e.ce,
$emit: (e) => e.emit,
$options: (e) => Vc(e),
$forceUpdate: (e) => e.f || (e.f = () => {
ha(e.update);
}),
$nextTick: (e) => e.n || (e.n = ys.bind(e.proxy)),
$watch: (e) => Bh.bind(e)
})
), ho = (e, t) => e !== tt && !e.__isScriptSetup && je(e, t), _h = {
get({ _: e }, t) {
if (t === "__v_skip")
return !0;
const { ctx: n, setupState: s, data: r, props: i, accessCache: o, type: a, appContext: l } = e;
let d;
if (t[0] !== "$") {
const z = o[t];
if (z !== void 0)
switch (z) {
case 1:
return s[t];
case 2:
return r[t];
case 4:
return n[t];
case 3:
return i[t];
}
else {
if (ho(s, t))
return o[t] = 1, s[t];
if (r !== tt && je(r, t))
return o[t] = 2, r[t];
if (
// only cache other properties when instance has declared (thus stable)
// props
(d = e.propsOptions[0]) && je(d, t)
)
return o[t] = 3, i[t];
if (n !== tt && je(n, t))
return o[t] = 4, n[t];
Uo && (o[t] = 0);
}
}
const c = Er[t];
let b, w;
if (c)
return t === "$attrs" && Ot(e.attrs, "get", ""), c(e);
if (
// css module (injected by vue-loader)
(b = a.__cssModules) && (b = b[t])
)
return b;
if (n !== tt && je(n, t))
return o[t] = 4, n[t];
if (
// global properties
w = l.config.globalProperties, je(w, t)
)
return w[t];
},
set({ _: e }, t, n) {
const { data: s, setupState: r, ctx: i } = e;
return ho(r, t) ? (r[t] = n, !0) : s !== tt && je(s, t) ? (s[t] = n, !0) : je(e.props, t) || t[0] === "$" && t.slice(1) in e ? !1 : (i[t] = n, !0);
},
has({
_: { data: e, setupState: t, accessCache: n, ctx: s, appContext: r, propsOptions: i }
}, o) {
let a;
return !!n[o] || e !== tt && je(e, o) || ho(t, o) || (a = i[0]) && je(a, o) || je(s, o) || je(Er, o) || je(r.config.globalProperties, o);
},
defineProperty(e, t, n) {
return n.get != null ? e._.accessCache[t] = 0 : je(n, "value") && this.set(e, t, n.value, null), Reflect.defineProperty(e, t, n);
}
};
function sl(e) {
return ve(e) ? e.reduce(
(t, n) => (t[n] = null, t),
{}
) : e;
}
let Uo = !0;
function yh(e) {
const t = Vc(e), n = e.proxy, s = e.ctx;
Uo = !1, t.beforeCreate && rl(t.beforeCreate, e, "bc");
const {
// state
data: r,
computed: i,
methods: o,
watch: a,
provide: l,
inject: d,
// lifecycle
created: c,
beforeMount: b,
mounted: w,
beforeUpdate: z,
updated: I,
activated: K,
deactivated: P,
beforeDestroy: oe,
beforeUnmount: fe,
destroyed: pe,
unmounted: R,
render: N,
renderTracked: Y,
renderTriggered: X,
errorCaptured: xe,
serverPrefetch: Oe,
// public API
expose: _e,
inheritAttrs: Pe,
// assets
components: be,
directives: Ke,
filters: Ge
} = t;
if (d && vh(d, s, null), o)
for (const ye in o) {
const me = o[ye];
ke(me) && (s[ye] = me.bind(n));
}
if (r) {
const ye = r.call(n, n);
ut(ye) && (e.data = Bi(ye));
}
if (Uo = !0, i)
for (const ye in i) {
const me = i[ye], nt = ke(me) ? me.bind(n, n) : ke(me.get) ? me.get.bind(n, n) : yn, Ze = !ke(me) && ke(me.set) ? me.set.bind(n) : yn, Te = de({
get: nt,
set: Ze
});
Object.defineProperty(s, ye, {
enumerable: !0,
configurable: !0,
get: () => Te.value,
set: (Je) => Te.value = Je
});
}
if (a)
for (const ye in a)
jc(a[ye], s, n, ye);
if (l) {
const ye = ke(l) ? l.call(n) : l;
Reflect.ownKeys(ye).forEach((me) => {
Ah(me, ye[me]);
});
}
c && rl(c, e, "c");
function ue(ye, me) {
ve(me) ? me.forEach((nt) => ye(nt.bind(n))) : me && ye(me.bind(n));
}
if (ue(ch, b), ue(Hi, w), ue(uh, z), ue(fh, I), ue(oh, K), ue(ah, P), ue(gh, xe), ue(ph, Y), ue(dh, X), ue(qc, fe), ue(Dr, R), ue(hh, Oe), ve(_e))
if (_e.length) {
const ye = e.exposed || (e.exposed = {});
_e.forEach((me) => {
Object.defineProperty(ye, me, {
get: () => n[me],
set: (nt) => n[me] = nt,
enumerable: !0
});
});
} else e.exposed || (e.exposed = {});
N && e.render === yn && (e.render = N), Pe != null && (e.inheritAttrs = Pe), be && (e.components = be), Ke && (e.directives = Ke), Oe && zc(e);
}
function vh(e, t, n = yn) {
ve(e) && (e = zo(e));
for (const s in e) {
const r = e[s];
let i;
ut(r) ? "default" in r ? i = ri(
r.from || s,
r.default,
!0
) : i = ri(r.from || s) : i = ri(r), Nt(i) ? Object.defineProperty(t, s, {
enumerable: !0,
configurable: !0,
get: () => i.value,
set: (o) => i.value = o
}) : t[s] = i;
}
}
function rl(e, t, n) {
bn(
ve(e) ? e.map((s) => s.bind(t.proxy)) : e.bind(t.proxy),
t,
n
);
}
function jc(e, t, n, s) {
let r = s.includes(".") ? iu(n, s) : () => n[s];
if (mt(e)) {
const i = t[e];
ke(i) && Ft(r, i);
} else if (ke(e))
Ft(r, e.bind(n));
else if (ut(e))
if (ve(e))
e.forEach((i) => jc(i, t, n, s));
else {
const i = ke(e.handler) ? e.handler.bind(n) : t[e.handler];
ke(i) && Ft(r, i, e);
}
}
function Vc(e) {
const t = e.type, { mixins: n, extends: s } = t, {
mixins: r,
optionsCache: i,
config: { optionMergeStrategies: o }
} = e.appContext, a = i.get(t);
let l;
return a ? l = a : !r.length && !n && !s ? l = t : (l = {}, r.length && r.forEach(
(d) => Ti(l, d, o, !0)
), Ti(l, t, o)), ut(t) && i.set(t, l), l;
}
function Ti(e, t, n, s = !1) {
const { mixins: r, extends: i } = t;
i && Ti(e, i, n, !0), r && r.forEach(
(o) => Ti(e, o, n, !0)
);
for (const o in t)
if (!(s && o === "expose")) {
const a = bh[o] || n && n[o];
e[o] = a ? a(e[o], t[o]) : t[o];
}
return e;
}
const bh = {
data: il,
props: ol,
emits: ol,
// objects
methods: yr,
computed: yr,
// lifecycle
beforeCreate: Pt,
created: Pt,
beforeMount: Pt,
mounted: Pt,
beforeUpdate: Pt,
updated: Pt,
beforeDestroy: Pt,
beforeUnmount: Pt,
destroyed: Pt,
unmounted: Pt,
activated: Pt,
deactivated: Pt,
errorCaptured: Pt,
serverPrefetch: Pt,
// assets
components: yr,
directives: yr,
// watch
watch: kh,
// provide / inject
provide: il,
inject: wh
};
function il(e, t) {
return t ? e ? function() {
return Mt(
ke(e) ? e.call(this, this) : e,
ke(t) ? t.call(this, this) : t
);
} : t : e;
}
function wh(e, t) {
return yr(zo(e), zo(t));
}
function zo(e) {
if (ve(e)) {
const t = {};
for (let n = 0; n < e.length; n++)
t[e[n]] = e[n];
return t;
}
return e;
}
function Pt(e, t) {
return e ? [...new Set([].concat(e, t))] : t;
}
function yr(e, t) {
return e ? Mt(/* @__PURE__ */ Object.create(null), e, t) : t;
}
function ol(e, t) {
return e ? ve(e) && ve(t) ? [.../* @__PURE__ */ new Set([...e, ...t])] : Mt(
/* @__PURE__ */ Object.create(null),
sl(e),
sl(t ?? {})
) : t;
}
function kh(e, t) {
if (!e) return t;
if (!t) return e;
const n = Mt(/* @__PURE__ */ Object.create(null), e);
for (const s in t)
n[s] = Pt(e[s], t[s]);
return n;
}
function Kc() {
return {
app: null,
config: {
isNativeTag: pf,
performance: !1,
globalProperties: {},
optionMergeStrategies: {},
errorHandler: void 0,
warnHandler: void 0,
compilerOptions: {}
},
mixins: [],
components: {},
directives: {},
provides: /* @__PURE__ */ Object.create(null),
optionsCache: /* @__PURE__ */ new WeakMap(),
propsCache: /* @__PURE__ */ new WeakMap(),
emitsCache: /* @__PURE__ */ new WeakMap()
};
}
let xh = 0;
function Th(e, t) {
return function(s, r = null) {
ke(s) || (s = Mt({}, s)), r != null && !ut(r) && (r = null);
const i = Kc(), o = /* @__PURE__ */ new WeakSet(), a = [];
let l = !1;
const d = i.app = {
_uid: xh++,
_component: s,
_props: r,
_container: null,
_context: i,
_instance: null,
version: id,
get config() {
return i.config;
},
set config(c) {
},
use(c, ...b) {
return o.has(c) || (c && ke(c.install) ? (o.add(c), c.install(d, ...b)) : ke(c) && (o.add(c), c(d, ...b))), d;
},
mixin(c) {
return i.mixins.includes(c) || i.mixins.push(c), d;
},
component(c, b) {
return b ? (i.components[c] = b, d) : i.components[c];
},
directive(c, b) {
return b ? (i.directives[c] = b, d) : i.directives[c];
},
mount(c, b, w) {
if (!l) {
const z = d._ceVNode || $t(s, r);
return z.appContext = i, w === !0 ? w = "svg" : w === !1 && (w = void 0), e(z, c, w), l = !0, d._container = c, c.__vue_app__ = d, ji(z.component);
}
},
onUnmount(c) {
a.push(c);
},
unmount() {
l && (bn(
a,
d._instance,
16
), e(null, d._container), delete d._container.__vue_app__);
},
provide(c, b) {
return i.provides[c] = b, d;
},
runWithContext(c) {
const b = Bs;
Bs = d;
try {
return c();
} finally {
Bs = b;
}
}
};
return d;
};
}
let Bs = null;
function Ah(e, t) {
if (Ut) {
let n = Ut.provides;
const s = Ut.parent && Ut.parent.provides;
s === n && (n = Ut.provides = Object.create(s)), n[e] = t;
}
}
function ri(e, t, n = !1) {
const s = Qh();
if (s || Bs) {
let r = Bs ? Bs._context.provides : s ? s.parent == null || s.ce ? s.vnode.appContext && s.vnode.appContext.provides : s.parent.provides : void 0;
if (r && e in r)
return r[e];
if (arguments.length > 1)
return n && ke(t) ? t.call(s && s.proxy) : t;
}
}
const Gc = {}, Yc = () => Object.create(Gc), Zc = (e) => Object.getPrototypeOf(e) === Gc;
function Eh(e, t, n, s = !1) {
const r = {}, i = Yc();
e.propsDefaults = /* @__PURE__ */ Object.create(null), Xc(e, t, r, i);
for (const o in e.propsOptions[0])
o in r || (r[o] = void 0);
n ? e.props = s ? r : jf(r) : e.type.props ? e.props = r : e.props = i, e.attrs = i;
}
function Sh(e, t, n, s) {
const {
props: r,
attrs: i,
vnode: { patchFlag: o }
} = e, a = qe(r), [l] = e.propsOptions;
let d = !1;
if (
// always force full diff in dev
// - #1942 if hmr is enabled with sfc component
// - vite#872 non-sfc component used by sfc component
(s || o > 0) && !(o & 16)
) {
if (o & 8) {
const c = e.vnode.dynamicProps;
for (let b = 0; b < c.length; b++) {
let w = c[b];
if (Wi(e.emitsOptions, w))
continue;
const z = t[w];
if (l)
if (je(i, w))
z !== i[w] && (i[w] = z, d = !0);
else {
const I = Qn(w);
r[I] = Ho(
l,
a,
I,
z,
e,
!1
);
}
else
z !== i[w] && (i[w] = z, d = !0);
}
}
} else {
Xc(e, t, r, i) && (d = !0);
let c;
for (const b in a)
(!t || // for camelCase
!je(t, b) && // it's possible the original props was passed in as kebab-case
// and converted to camelCase (#955)
((c = ss(b)) === b || !je(t, c))) && (l ? n && // for camelCase
(n[b] !== void 0 || // for kebab-case
n[c] !== void 0) && (r[b] = Ho(
l,
a,
b,
void 0,
e,
!0
)) : delete r[b]);
if (i !== a)
for (const b in i)
(!t || !je(t, b)) && (delete i[b], d = !0);
}
d && Nn(e.attrs, "set", "");
}
function Xc(e, t, n, s) {
const [r, i] = e.propsOptions;
let o = !1, a;
if (t)
for (let l in t) {
if (wr(l))
continue;
const d = t[l];
let c;
r && je(r, c = Qn(l)) ? !i || !i.includes(c) ? n[c] = d : (a || (a = {}))[c] = d : Wi(e.emitsOptions, l) || (!(l in s) || d !== s[l]) && (s[l] = d, o = !0);
}
if (i) {
const l = qe(n), d = a || tt;
for (let c = 0; c < i.length; c++) {
const b = i[c];
n[b] = Ho(
r,
l,
b,
d[b],
e,
!je(d, b)
);
}
}
return o;
}
function Ho(e, t, n, s, r, i) {
const o = e[n];
if (o != null) {
const a = je(o, "default");
if (a && s === void 0) {
const l = o.default;
if (o.type !== Function && !o.skipFactory && ke(l)) {
const { propsDefaults: d } = r;
if (n in d)
s = d[n];
else {
const c = Pr(r);
s = d[n] = l.call(
null,
t
), c();
}
} else
s = l;
r.ce && r.ce._setProp(n, s);
}
o[
0
/* shouldCast */
] && (i && !a ? s = !1 : o[
1
/* shouldCastTrue */
] && (s === "" || s === ss(n)) && (s = !0));
}
return s;
}
const Ch = /* @__PURE__ */ new WeakMap();
function Jc(e, t, n = !1) {
const s = n ? Ch : t.propsCache, r = s.get(e);
if (r)
return r;
const i = e.props, o = {}, a = [];
let l = !1;
if (!ke(e)) {
const c = (b) => {
l = !0;
const [w, z] = Jc(b, t, !0);
Mt(o, w), z && a.push(...z);
};
!n && t.mixins.length && t.mixins.forEach(c), e.extends && c(e.extends), e.mixins && e.mixins.forEach(c);
}
if (!i && !l)
return ut(e) && s.set(e, Ms), Ms;
if (ve(i))
for (let c = 0; c < i.length; c++) {
const b = Qn(i[c]);
al(b) && (o[b] = tt);
}
else if (i)
for (const c in i) {
const b = Qn(c);
if (al(b)) {
const w = i[c], z = o[b] = ve(w) || ke(w) ? { type: w } : Mt({}, w), I = z.type;
let K = !1, P = !0;
if (ve(I))
for (let oe = 0; oe < I.length; ++oe) {
const fe = I[oe], pe = ke(fe) && fe.name;
if (pe === "Boolean") {
K = !0;
break;
} else pe === "String" && (P = !1);
}
else
K = ke(I) && I.name === "Boolean";
z[
0
/* shouldCast */
] = K, z[
1
/* shouldCastTrue */
] = P, (K || je(z, "default")) && a.push(b);
}
}
const d = [o, a];
return ut(e) && s.set(e, d), d;
}
function al(e) {
return e[0] !== "$" && !wr(e);
}
const pa = (e) => e === "_" || e === "__" || e === "_ctx" || e === "$stable", ga = (e) => ve(e) ? e.map(_n) : [_n(e)], Rh = (e, t, n) => {
if (t._n)
return t;
const s = sh((...r) => ga(t(...r)), n);
return s._c = !1, s;
}, Qc = (e, t, n) => {
const s = e._ctx;
for (const r in e) {
if (pa(r)) continue;
const i = e[r];
if (ke(i))
t[r] = Rh(r, i, s);
else if (i != null) {
const o = ga(i);
t[r] = () => o;
}
}
}, eu = (e, t) => {
const n = ga(t);
e.slots.default = () => n;
}, tu = (e, t, n) => {
for (const s in t)
(n || !pa(s)) && (e[s] = t[s]);
}, Ih = (e, t, n) => {
const s = e.slots = Yc();
if (e.vnode.shapeFlag & 32) {
const r = t.__;
r && No(s, "__", r, !0);
const i = t._;
i ? (tu(s, t, n), n && No(s, "_", i, !0)) : Qc(t, s);
} else t && eu(e, t);
}, Lh = (e, t, n) => {
const { vnode: s, slots: r } = e;
let i = !0, o = tt;
if (s.shapeFlag & 32) {
const a = t._;
a ? n && a === 1 ? i = !1 : tu(r, t, n) : (i = !t.$stable, Qc(t, r)), o = t;
} else t && (eu(e, t), o = { default: 1 });
if (i)
for (const a in r)
!pa(a) && o[a] == null && delete r[a];
}, Vt = jh;
function Oh(e) {
return Nh(e);
}
function Nh(e, t) {
const n = Pi();
n.__VUE__ = !0;
const {
insert: s,
remove: r,
patchProp: i,
createElement: o,
createText: a,
createComment: l,
setText: d,
setElementText: c,
parentNode: b,
nextSibling: w,
setScopeId: z = yn,
insertStaticContent: I
} = e, K = (m, v, C, M = null, B = null, L = null, G = void 0, W = null, q = !!v.dynamicChildren) => {
if (m === v)
return;
m && !lr(m, v) && (M = pt(m), Je(m, B, L, !0), m = null), v.patchFlag === -2 && (q = !1, v.dynamicChildren = null);
const { type: U, ref: te, shapeFlag: Z } = v;
switch (U) {
case qi:
P(m, v, C, M);
break;
case ts:
oe(m, v, C, M);
break;
case ii:
m == null && fe(v, C, M, G);
break;
case ze:
be(
m,
v,
C,
M,
B,
L,
G,
W,
q
);
break;
default:
Z & 1 ? N(
m,
v,
C,
M,
B,
L,
G,
W,
q
) : Z & 6 ? Ke(
m,
v,
C,
M,
B,
L,
G,
W,
q
) : (Z & 64 || Z & 128) && U.process(
m,
v,
C,
M,
B,
L,
G,
W,
q,
Dt
);
}
te != null && B ? Tr(te, m && m.ref, L, v || m, !v) : te == null && m && m.ref != null && Tr(m.ref, null, L, m, !0);
}, P = (m, v, C, M) => {
if (m == null)
s(
v.el = a(v.children),
C,
M
);
else {
const B = v.el = m.el;
v.children !== m.children && d(B, v.children);
}
}, oe = (m, v, C, M) => {
m == null ? s(
v.el = l(v.children || ""),
C,
M
) : v.el = m.el;
}, fe = (m, v, C, M) => {
[m.el, m.anchor] = I(
m.children,
v,
C,
M,
m.el,
m.anchor
);
}, pe = ({ el: m, anchor: v }, C, M) => {
let B;
for (; m && m !== v; )
B = w(m), s(m, C, M), m = B;
s(v, C, M);
}, R = ({ el: m, anchor: v }) => {
let C;
for (; m && m !== v; )
C = w(m), r(m), m = C;
r(v);
}, N = (m, v, C, M, B, L, G, W, q) => {
v.type === "svg" ? G = "svg" : v.type === "math" && (G = "mathml"), m == null ? Y(
v,
C,
M,
B,
L,
G,
W,
q
) : Oe(
m,
v,
B,
L,
G,
W,
q
);
}, Y = (m, v, C, M, B, L, G, W) => {
let q, U;
const { props: te, shapeFlag: Z, transition: E, dirs: O } = m;
if (q = m.el = o(
m.type,
L,
te && te.is,
te
), Z & 8 ? c(q, m.children) : Z & 16 && xe(
m.children,
q,
null,
M,
B,
po(m, L),
G,
W
), O && us(m, null, M, "created"), X(q, m, m.scopeId, G, M), te) {
for (const J in te)
J !== "value" && !wr(J) && i(q, J, null, te[J], L, M);
"value" in te && i(q, "value", null, te.value, L), (U = te.onVnodeBeforeMount) && dn(U, M, m);
}
O && us(m, null, M, "beforeMount");
const V = Mh(B, E);
V && E.beforeEnter(q), s(q, v, C), ((U = te && te.onVnodeMounted) || V || O) && Vt(() => {
U && dn(U, M, m), V && E.enter(q), O && us(m, null, M, "mounted");
}, B);
}, X = (m, v, C, M, B) => {
if (C && z(m, C), M)
for (let L = 0; L < M.length; L++)
z(m, M[L]);
if (B) {
let L = B.subTree;
if (v === L || au(L.type) && (L.ssContent === v || L.ssFallback === v)) {
const G = B.vnode;
X(
m,
G,
G.scopeId,
G.slotScopeIds,
B.parent
);
}
}
}, xe = (m, v, C, M, B, L, G, W, q = 0) => {
for (let U = q; U < m.length; U++) {
const te = m[U] = W ? Yn(m[U]) : _n(m[U]);
K(
null,
te,
v,
C,
M,
B,
L,
G,
W
);
}
}, Oe = (m, v, C, M, B, L, G) => {
const W = v.el = m.el;
let { patchFlag: q, dynamicChildren: U, dirs: te } = v;
q |= m.patchFlag & 16;
const Z = m.props || tt, E = v.props || tt;
let O;
if (C && fs(C, !1), (O = E.onVnodeBeforeUpdate) && dn(O, C, v, m), te && us(v, m, C, "beforeUpdate"), C && fs(C, !0), (Z.innerHTML && E.innerHTML == null || Z.textContent && E.textContent == null) && c(W, ""), U ? _e(
m.dynamicChildren,
U,
W,
C,
M,
po(v, B),
L
) : G || me(
m,
v,
W,
null,
C,
M,
po(v, B),
L,
!1
), q > 0) {
if (q & 16)
Pe(W, Z, E, C, B);
else if (q & 2 && Z.class !== E.class && i(W, "class", null, E.class, B), q & 4 && i(W, "style", Z.style, E.style, B), q & 8) {
const V = v.dynamicProps;
for (let J = 0; J < V.length; J++) {
const ae = V[J], we = Z[ae], Se = E[ae];
(Se !== we || ae === "value") && i(W, ae, we, Se, B, C);
}
}
q & 1 && m.children !== v.children && c(W, v.children);
} else !G && U == null && Pe(W, Z, E, C, B);
((O = E.onVnodeUpdated) || te) && Vt(() => {
O && dn(O, C, v, m), te && us(v, m, C, "updated");
}, M);
}, _e = (m, v, C, M, B, L, G) => {
for (let W = 0; W < v.length; W++) {
const q = m[W], U = v[W], te = (
// oldVNode may be an errored async setup() component inside Suspense
// which will not have a mounted element
q.el && // - In the case of a Fragment, we need to provide the actual parent
// of the Fragment itself so it can move its children.
(q.type === ze || // - In the case of different nodes, there is going to be a replacement
// which also requires the correct parent container
!lr(q, U) || // - In the case of a component, it could contain anything.
q.shapeFlag & 198) ? b(q.el) : (
// In other cases, the parent container is not actually used so we
// just pass the block element here to avoid a DOM parentNode call.
C
)
);
K(
q,
U,
te,
null,
M,
B,
L,
G,
!0
);
}
}, Pe = (m, v, C, M, B) => {
if (v !== C) {
if (v !== tt)
for (const L in v)
!wr(L) && !(L in C) && i(
m,
L,
v[L],
null,
B,
M
);
for (const L in C) {
if (wr(L)) continue;
const G = C[L], W = v[L];
G !== W && L !== "value" && i(m, L, W, G, B, M);
}
"value" in C && i(m, "value", v.value, C.value, B);
}
}, be = (m, v, C, M, B, L, G, W, q) => {
const U = v.el = m ? m.el : a(""), te = v.anchor = m ? m.anchor : a("");
let { patchFlag: Z, dynamicChildren: E, slotScopeIds: O } = v;
O && (W = W ? W.concat(O) : O), m == null ? (s(U, C, M), s(te, C, M), xe(
// #10007
// such fragment like `<></>` will be compiled into
// a fragment which doesn't have a children.
// In this case fallback to an empty array
v.children || [],
C,
te,
B,
L,
G,
W,
q
)) : Z > 0 && Z & 64 && E && // #2715 the previous fragment could've been a BAILed one as a result
// of renderSlot() with no valid children
m.dynamicChildren ? (_e(
m.dynamicChildren,
E,
C,
B,
L,
G,
W
), // #2080 if the stable fragment has a key, it's a <template v-for> that may
// get moved around. Make sure all root level vnodes inherit el.
// #2134 or if it's a component root, it may also get moved around
// as the component is being moved.
(v.key != null || B && v === B.subTree) && nu(
m,
v,
!0
/* shallow */
)) : me(
m,
v,
C,
te,
B,
L,
G,
W,
q
);
}, Ke = (m, v, C, M, B, L, G, W, q) => {
v.slotScopeIds = W, m == null ? v.shapeFlag & 512 ? B.ctx.activate(
v,
C,
M,
G,
q
) : Ge(
v,
C,
M,
B,
L,
G,
q
) : at(m, v, q);
}, Ge = (m, v, C, M, B, L, G) => {
const W = m.component = Jh(
m,
M,
B
);
if (Hc(m) && (W.ctx.renderer = Dt), ed(W, !1, G), W.asyncDep) {
if (B && B.registerDep(W, ue, G), !m.el) {
const q = W.subTree = $t(ts);
oe(null, q, v, C), m.placeholder = q.el;
}
} else
ue(
W,
m,
v,
C,
B,
L,
G
);
}, at = (m, v, C) => {
const M = v.component = m.component;
if (Wh(m, v, C))
if (M.asyncDep && !M.asyncResolved) {
ye(M, v, C);
return;
} else
M.next = v, M.update();
else
v.el = m.el, M.vnode = v;
}, ue = (m, v, C, M, B, L, G) => {
const W = () => {
if (m.isMounted) {
let { next: Z, bu: E, u: O, parent: V, vnode: J } = m;
{
const f = su(m);
if (f) {
Z && (Z.el = J.el, ye(m, Z, G)), f.asyncDep.then(() => {
m.isUnmounted || W();
});
return;
}
}
let ae = Z, we;
fs(m, !1), Z ? (Z.el = J.el, ye(m, Z, G)) : Z = J, E && si(E), (we = Z.props && Z.props.onVnodeBeforeUpdate) && dn(we, V, Z, J), fs(m, !0);
const Se = cl(m), De = m.subTree;
m.subTree = Se, K(
De,
Se,
// parent may have changed if it's in a teleport
b(De.el),
// anchor may have changed if it's in a fragment
pt(De),
m,
B,
L
), Z.el = Se.el, ae === null && qh(m, Se.el), O && Vt(O, B), (we = Z.props && Z.props.onVnodeUpdated) && Vt(
() => dn(we, V, Z, J),
B
);
} else {
let Z;
const { el: E, props: O } = v, { bm: V, m: J, parent: ae, root: we, type: Se } = m, De = Ar(v);
fs(m, !1), V && si(V), !De && (Z = O && O.onVnodeBeforeMount) && dn(Z, ae, v), fs(m, !0);
{
we.ce && // @ts-expect-error _def is private
we.ce._def.shadowRoot !== !1 && we.ce._injectChildStyle(Se);
const f = m.subTree = cl(m);
K(
null,
f,
C,
M,
m,
B,
L
), v.el = f.el;
}
if (J && Vt(J, B), !De && (Z = O && O.onVnodeMounted)) {
const f = v;
Vt(
() => dn(Z, ae, f),
B
);
}
(v.shapeFlag & 256 || ae && Ar(ae.vnode) && ae.vnode.shapeFlag & 256) && m.a && Vt(m.a, B), m.isMounted = !0, v = C = M = null;
}
};
m.scope.on();
const q = m.effect = new bc(W);
m.scope.off();
const U = m.update = q.run.bind(q), te = m.job = q.runIfDirty.bind(q);
te.i = m, te.id = m.uid, q.scheduler = () => ha(te), fs(m, !0), U();
}, ye = (m, v, C) => {
v.component = m;
const M = m.vnode.props;
m.vnode = v, m.next = null, Sh(m, v.props, M, C), Lh(m, v.children, C), Fn(), nl(m), Bn();
}, me = (m, v, C, M, B, L, G, W, q = !1) => {
const U = m && m.children, te = m ? m.shapeFlag : 0, Z = v.children, { patchFlag: E, shapeFlag: O } = v;
if (E > 0) {
if (E & 128) {
Ze(
U,
Z,
C,
M,
B,
L,
G,
W,
q
);
return;
} else if (E & 256) {
nt(
U,
Z,
C,
M,
B,
L,
G,
W,
q
);
return;
}
}
O & 8 ? (te & 16 && yt(U, B, L), Z !== U && c(C, Z)) : te & 16 ? O & 16 ? Ze(
U,
Z,
C,
M,
B,
L,
G,
W,
q
) : yt(U, B, L, !0) : (te & 8 && c(C, ""), O & 16 && xe(
Z,
C,
M,
B,
L,
G,
W,
q
));
}, nt = (m, v, C, M, B, L, G, W, q) => {
m = m || Ms, v = v || Ms;
const U = m.length, te = v.length, Z = Math.min(U, te);
let E;
for (E = 0; E < Z; E++) {
const O = v[E] = q ? Yn(v[E]) : _n(v[E]);
K(
m[E],
O,
C,
null,
B,
L,
G,
W,
q
);
}
U > te ? yt(
m,
B,
L,
!0,
!1,
Z
) : xe(
v,
C,
M,
B,
L,
G,
W,
q,
Z
);
}, Ze = (m, v, C, M, B, L, G, W, q) => {
let U = 0;
const te = v.length;
let Z = m.length - 1, E = te - 1;
for (; U <= Z && U <= E; ) {
const O = m[U], V = v[U] = q ? Yn(v[U]) : _n(v[U]);
if (lr(O, V))
K(
O,
V,
C,
null,
B,
L,
G,
W,
q
);
else
break;
U++;
}
for (; U <= Z && U <= E; ) {
const O = m[Z], V = v[E] = q ? Yn(v[E]) : _n(v[E]);
if (lr(O, V))
K(
O,
V,
C,
null,
B,
L,
G,
W,
q
);
else
break;
Z--, E--;
}
if (U > Z) {
if (U <= E) {
const O = E + 1, V = O < te ? v[O].el : M;
for (; U <= E; )
K(
null,
v[U] = q ? Yn(v[U]) : _n(v[U]),
C,
V,
B,
L,
G,
W,
q
), U++;
}
} else if (U > E)
for (; U <= Z; )
Je(m[U], B, L, !0), U++;
else {
const O = U, V = U, J = /* @__PURE__ */ new Map();
for (U = V; U <= E; U++) {
const x = v[U] = q ? Yn(v[U]) : _n(v[U]);
x.key != null && J.set(x.key, U);
}
let ae, we = 0;
const Se = E - V + 1;
let De = !1, f = 0;
const y = new Array(Se);
for (U = 0; U < Se; U++) y[U] = 0;
for (U = O; U <= Z; U++) {
const x = m[U];
if (we >= Se) {
Je(x, B, L, !0);
continue;
}
let H;
if (x.key != null)
H = J.get(x.key);
else
for (ae = V; ae <= E; ae++)
if (y[ae - V] === 0 && lr(x, v[ae])) {
H = ae;
break;
}
H === void 0 ? Je(x, B, L, !0) : (y[H - V] = U + 1, H >= f ? f = H : De = !0, K(
x,
v[H],
C,
null,
B,
L,
G,
W,
q
), we++);
}
const D = De ? Dh(y) : Ms;
for (ae = D.length - 1, U = Se - 1; U >= 0; U--) {
const x = V + U, H = v[x], ne = v[x + 1], ee = x + 1 < te ? (
// #13559, fallback to el placeholder for unresolved async component
ne.el || ne.placeholder
) : M;
y[U] === 0 ? K(
null,
H,
C,
ee,
B,
L,
G,
W,
q
) : De && (ae < 0 || U !== D[ae] ? Te(H, C, ee, 2) : ae--);
}
}
}, Te = (m, v, C, M, B = null) => {
const { el: L, type: G, transition: W, children: q, shapeFlag: U } = m;
if (U & 6) {
Te(m.component.subTree, v, C, M);
return;
}
if (U & 128) {
m.suspense.move(v, C, M);
return;
}
if (U & 64) {
G.move(m, v, C, Dt);
return;
}
if (G === ze) {
s(L, v, C);
for (let Z = 0; Z < q.length; Z++)
Te(q[Z], v, C, M);
s(m.anchor, v, C);
return;
}
if (G === ii) {
pe(m, v, C);
return;
}
if (M !== 2 && U & 1 && W)
if (M === 0)
W.beforeEnter(L), s(L, v, C), Vt(() => W.enter(L), B);
else {
const { leave: Z, delayLeave: E, afterLeave: O } = W, V = () => {
m.ctx.isUnmounted ? r(L) : s(L, v, C);
}, J = () => {
Z(L, () => {
V(), O && O();
});
};
E ? E(L, V, J) : J();
}
else
s(L, v, C);
}, Je = (m, v, C, M = !1, B = !1) => {
const {
type: L,
props: G,
ref: W,
children: q,
dynamicChildren: U,
shapeFlag: te,
patchFlag: Z,
dirs: E,
cacheIndex: O
} = m;
if (Z === -2 && (B = !1), W != null && (Fn(), Tr(W, null, C, m, !0), Bn()), O != null && (v.renderCache[O] = void 0), te & 256) {
v.ctx.deactivate(m);
return;
}
const V = te & 1 && E, J = !Ar(m);
let ae;
if (J && (ae = G && G.onVnodeBeforeUnmount) && dn(ae, v, m), te & 6)
Re(m.component, C, M);
else {
if (te & 128) {
m.suspense.unmount(C, M);
return;
}
V && us(m, null, v, "beforeUnmount"), te & 64 ? m.type.remove(
m,
v,
C,
Dt,
M
) : U && // #5154
// when v-once is used inside a block, setBlockTracking(-1) marks the
// parent block with hasOnce: true
// so that it doesn't take the fast path during unmount - otherwise
// components nested in v-once are never unmounted.
!U.hasOnce && // #1153: fast path should not be taken for non-stable (v-for) fragments
(L !== ze || Z > 0 && Z & 64) ? yt(
U,
v,
C,
!1,
!0
) : (L === ze && Z & 384 || !B && te & 16) && yt(q, v, C), M && st(m);
}
(J && (ae = G && G.onVnodeUnmounted) || V) && Vt(() => {
ae && dn(ae, v, m), V && us(m, null, v, "unmounted");
}, C);
}, st = (m) => {
const { type: v, el: C, anchor: M, transition: B } = m;
if (v === ze) {
At(C, M);
return;
}
if (v === ii) {
R(m);
return;
}
const L = () => {
r(C), B && !B.persisted && B.afterLeave && B.afterLeave();
};
if (m.shapeFlag & 1 && B && !B.persisted) {
const { leave: G, delayLeave: W } = B, q = () => G(C, L);
W ? W(m.el, L, q) : q();
} else
L();
}, At = (m, v) => {
let C;
for (; m !== v; )
C = w(m), r(m), m = C;
r(v);
}, Re = (m, v, C) => {
const {
bum: M,
scope: B,
job: L,
subTree: G,
um: W,
m: q,
a: U,
parent: te,
slots: { __: Z }
} = m;
ll(q), ll(U), M && si(M), te && ve(Z) && Z.forEach((E) => {
te.renderCache[E] = void 0;
}), B.stop(), L && (L.flags |= 8, Je(G, m, v, C)), W && Vt(W, v), Vt(() => {
m.isUnmounted = !0;
}, v), v && v.pendingBranch && !v.isUnmounted && m.asyncDep && !m.asyncResolved && m.suspenseId === v.pendingId && (v.deps--, v.deps === 0 && v.resolve());
}, yt = (m, v, C, M = !1, B = !1, L = 0) => {
for (let G = L; G < m.length; G++)
Je(m[G], v, C, M, B);
}, pt = (m) => {
if (m.shapeFlag & 6)
return pt(m.component.subTree);
if (m.shapeFlag & 128)
return m.suspense.next();
const v = w(m.anchor || m.el), C = v && v[rh];
return C ? w(C) : v;
};
let Ct = !1;
const Rt = (m, v, C) => {
m == null ? v._vnode && Je(v._vnode, null, null, !0) : K(
v._vnode || null,
m,
v,
null,
null,
null,
C
), v._vnode = m, Ct || (Ct = !0, nl(), Bc(), Ct = !1);
}, Dt = {
p: K,
um: Je,
m: Te,
r: st,
mt: Ge,
mc: xe,
pc: me,
pbc: _e,
n: pt,
o: e
};
return {
render: Rt,
hydrate: void 0,
createApp: Th(Rt)
};
}
function po({ type: e, props: t }, n) {
return n === "svg" && e === "foreignObject" || n === "mathml" && e === "annotation-xml" && t && t.encoding && t.encoding.includes("html") ? void 0 : n;
}
function fs({ effect: e, job: t }, n) {
n ? (e.flags |= 32, t.flags |= 4) : (e.flags &= -33, t.flags &= -5);
}
function Mh(e, t) {
return (!e || e && !e.pendingBranch) && t && !t.persisted;
}
function nu(e, t, n = !1) {
const s = e.children, r = t.children;
if (ve(s) && ve(r))
for (let i = 0; i < s.length; i++) {
const o = s[i];
let a = r[i];
a.shapeFlag & 1 && !a.dynamicChildren && ((a.patchFlag <= 0 || a.patchFlag === 32) && (a = r[i] = Yn(r[i]), a.el = o.el), !n && a.patchFlag !== -2 && nu(o, a)), a.type === qi && (a.el = o.el), a.type === ts && !a.el && (a.el = o.el);
}
}
function Dh(e) {
const t = e.slice(), n = [0];
let s, r, i, o, a;
const l = e.length;
for (s = 0; s < l; s++) {
const d = e[s];
if (d !== 0) {
if (r = n[n.length - 1], e[r] < d) {
t[s] = r, n.push(s);
continue;
}
for (i = 0, o = n.length - 1; i < o; )
a = i + o >> 1, e[n[a]] < d ? i = a + 1 : o = a;
d < e[n[i]] && (i > 0 && (t[s] = n[i - 1]), n[i] = s);
}
}
for (i = n.length, o = n[i - 1]; i-- > 0; )
n[i] = o, o = t[o];
return n;
}
function su(e) {
const t = e.subTree.component;
if (t)
return t.asyncDep && !t.asyncResolved ? t : su(t);
}
function ll(e) {
if (e)
for (let t = 0; t < e.length; t++)
e[t].flags |= 8;
}
const Ph = Symbol.for("v-scx"), Fh = () => ri(Ph);
function Ft(e, t, n) {
return ru(e, t, n);
}
function ru(e, t, n = tt) {
const { immediate: s, deep: r, flush: i, once: o } = n, a = Mt({}, n), l = t && s || !t && i !== "post";
let d;
if (Nr) {
if (i === "sync") {
const z = Fh();
d = z.__watcherHandles || (z.__watcherHandles = []);
} else if (!l) {
const z = () => {
};
return z.stop = yn, z.resume = yn, z.pause = yn, z;
}
}
const c = Ut;
a.call = (z, I, K) => bn(z, c, I, K);
let b = !1;
i === "post" ? a.scheduler = (z) => {
Vt(z, c && c.suspense);
} : i !== "sync" && (b = !0, a.scheduler = (z, I) => {
I ? z() : ha(z);
}), a.augmentJob = (z) => {
t && (z.flags |= 4), b && (z.flags |= 2, c && (z.id = c.uid, z.i = c));
};
const w = Qf(e, t, a);
return Nr && (d ? d.push(w) : l && w()), w;
}
function Bh(e, t, n) {
const s = this.proxy, r = mt(e) ? e.includes(".") ? iu(s, e) : () => s[e] : e.bind(s, s);
let i;
ke(t) ? i = t : (i = t.handler, n = t);
const o = Pr(this), a = ru(r, i.bind(s), n);
return o(), a;
}
function iu(e, t) {
const n = t.split(".");
return () => {
let s = e;
for (let r = 0; r < n.length && s; r++)
s = s[n[r]];
return s;
};
}
const $h = (e, t) => t === "modelValue" || t === "model-value" ? e.modelModifiers : e[`${t}Modifiers`] || e[`${Qn(t)}Modifiers`] || e[`${ss(t)}Modifiers`];
function Uh(e, t, ...n) {
if (e.isUnmounted) return;
const s = e.vnode.props || tt;
let r = n;
const i = t.startsWith("update:"), o = i && $h(s, t.slice(7));
o && (o.trim && (r = n.map((c) => mt(c) ? c.trim() : c)), o.number && (r = n.map(Mo)));
let a, l = s[a = ao(t)] || // also try camelCase event handler (#2249)
s[a = ao(Qn(t))];
!l && i && (l = s[a = ao(ss(t))]), l && bn(
l,
e,
6,
r
);
const d = s[a + "Once"];
if (d) {
if (!e.emitted)
e.emitted = {};
else if (e.emitted[a])
return;
e.emitted[a] = !0, bn(
d,
e,
6,
r
);
}
}
function ou(e, t, n = !1) {
const s = t.emitsCache, r = s.get(e);
if (r !== void 0)
return r;
const i = e.emits;
let o = {}, a = !1;
if (!ke(e)) {
const l = (d) => {
const c = ou(d, t, !0);
c && (a = !0, Mt(o, c));
};
!n && t.mixins.length && t.mixins.forEach(l), e.extends && l(e.extends), e.mixins && e.mixins.forEach(l);
}
return !i && !a ? (ut(e) && s.set(e, null), null) : (ve(i) ? i.forEach((l) => o[l] = null) : Mt(o, i), ut(e) && s.set(e, o), o);
}
function Wi(e, t) {
return !e || !Ni(t) ? !1 : (t = t.slice(2).replace(/Once$/, ""), je(e, t[0].toLowerCase() + t.slice(1)) || je(e, ss(t)) || je(e, t));
}
function cl(e) {
const {
type: t,
vnode: n,
proxy: s,
withProxy: r,
propsOptions: [i],
slots: o,
attrs: a,
emit: l,
render: d,
renderCache: c,
props: b,
data: w,
setupState: z,
ctx: I,
inheritAttrs: K
} = e, P = xi(e);
let oe, fe;
try {
if (n.shapeFlag & 4) {
const R = r || s, N = R;
oe = _n(
d.call(
N,
R,
c,
b,
z,
w,
I
)
), fe = a;
} else {
const R = t;
oe = _n(
R.length > 1 ? R(
b,
{ attrs: a, slots: o, emit: l }
) : R(
b,
null
)
), fe = t.props ? a : zh(a);
}
} catch (R) {
Sr.length = 0, $i(R, e, 1), oe = $t(ts);
}
let pe = oe;
if (fe && K !== !1) {
const R = Object.keys(fe), { shapeFlag: N } = pe;
R.length && N & 7 && (i && R.some(na) && (fe = Hh(
fe,
i
)), pe = Hs(pe, fe, !1, !0));
}
return n.dirs && (pe = Hs(pe, null, !1, !0), pe.dirs = pe.dirs ? pe.dirs.concat(n.dirs) : n.dirs), n.transition && da(pe, n.transition), oe = pe, xi(P), oe;
}
const zh = (e) => {
let t;
for (const n in e)
(n === "class" || n === "style" || Ni(n)) && ((t || (t = {}))[n] = e[n]);
return t;
}, Hh = (e, t) => {
const n = {};
for (const s in e)
(!na(s) || !(s.slice(9) in t)) && (n[s] = e[s]);
return n;
};
function Wh(e, t, n) {
const { props: s, children: r, component: i } = e, { props: o, children: a, patchFlag: l } = t, d = i.emitsOptions;
if (t.dirs || t.transition)
return !0;
if (n && l >= 0) {
if (l & 1024)
return !0;
if (l & 16)
return s ? ul(s, o, d) : !!o;
if (l & 8) {
const c = t.dynamicProps;
for (let b = 0; b < c.length; b++) {
const w = c[b];
if (o[w] !== s[w] && !Wi(d, w))
return !0;
}
}
} else
return (r || a) && (!a || !a.$stable) ? !0 : s === o ? !1 : s ? o ? ul(s, o, d) : !0 : !!o;
return !1;
}
function ul(e, t, n) {
const s = Object.keys(t);
if (s.length !== Object.keys(e).length)
return !0;
for (let r = 0; r < s.length; r++) {
const i = s[r];
if (t[i] !== e[i] && !Wi(n, i))
return !0;
}
return !1;
}
function qh({ vnode: e, parent: t }, n) {
for (; t; ) {
const s = t.subTree;
if (s.suspense && s.suspense.activeBranch === e && (s.el = e.el), s === e)
(e = t.vnode).el = n, t = t.parent;
else
break;
}
}
const au = (e) => e.__isSuspense;
function jh(e, t) {
t && t.pendingBranch ? ve(e) ? t.effects.push(...e) : t.effects.push(e) : nh(e);
}
const ze = Symbol.for("v-fgt"), qi = Symbol.for("v-txt"), ts = Symbol.for("v-cmt"), ii = Symbol.for("v-stc"), Sr = [];
let Gt = null;
function T(e = !1) {
Sr.push(Gt = e ? null : []);
}
function Vh() {
Sr.pop(), Gt = Sr[Sr.length - 1] || null;
}
let Or = 1;
function fl(e, t = !1) {
Or += e, e < 0 && Gt && t && (Gt.hasOnce = !0);
}
function lu(e) {
return e.dynamicChildren = Or > 0 ? Gt || Ms : null, Vh(), Or > 0 && Gt && Gt.push(e), e;
}
function A(e, t, n, s, r, i) {
return lu(
_(
e,
t,
n,
s,
r,
i,
!0
)
);
}
function Ai(e, t, n, s, r) {
return lu(
$t(
e,
t,
n,
s,
r,
!0
)
);
}
function cu(e) {
return e ? e.__v_isVNode === !0 : !1;
}
function lr(e, t) {
return e.type === t.type && e.key === t.key;
}
const uu = ({ key: e }) => e ?? null, oi = ({
ref: e,
ref_key: t,
ref_for: n
}) => (typeof e == "number" && (e = "" + e), e != null ? mt(e) || Nt(e) || ke(e) ? { i: sn, r: e, k: t, f: !!n } : e : null);
function _(e, t = null, n = null, s = 0, r = null, i = e === ze ? 0 : 1, o = !1, a = !1) {
const l = {
__v_isVNode: !0,
__v_skip: !0,
type: e,
props: t,
key: t && uu(t),
ref: t && oi(t),
scopeId: Uc,
slotScopeIds: null,
children: n,
component: null,
suspense: null,
ssContent: null,
ssFallback: null,
dirs: null,
transition: null,
el: null,
anchor: null,
target: null,
targetStart: null,
targetAnchor: null,
staticCount: 0,
shapeFlag: i,
patchFlag: s,
dynamicProps: r,
dynamicChildren: null,
appContext: null,
ctx: sn
};
return a ? (ma(l, n), i & 128 && e.normalize(l)) : n && (l.shapeFlag |= mt(n) ? 8 : 16), Or > 0 && // avoid a block node from tracking itself
!o && // has current parent block
Gt && // presence of a patch flag indicates this node needs patching on updates.
// component nodes also should always be patched, because even if the
// component doesn't need to update, it needs to persist the instance on to
// the next vnode so that it can be properly unmounted later.
(l.patchFlag > 0 || i & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the
// vnode should not be considered dynamic due to handler caching.
l.patchFlag !== 32 && Gt.push(l), l;
}
const $t = Kh;
function Kh(e, t = null, n = null, s = 0, r = null, i = !1) {
if ((!e || e === mh) && (e = ts), cu(e)) {
const a = Hs(
e,
t,
!0
/* mergeRef: true */
);
return n && ma(a, n), Or > 0 && !i && Gt && (a.shapeFlag & 6 ? Gt[Gt.indexOf(e)] = a : Gt.push(a)), a.patchFlag = -2, a;
}
if (rd(e) && (e = e.__vccOpts), t) {
t = Gh(t);
let { class: a, style: l } = t;
a && !mt(a) && (t.class = Ue(a)), ut(l) && (fa(l) && !ve(l) && (l = Mt({}, l)), t.style = Ee(l));
}
const o = mt(e) ? 1 : au(e) ? 128 : ih(e) ? 64 : ut(e) ? 4 : ke(e) ? 2 : 0;
return _(
e,
t,
n,
s,
r,
o,
i,
!0
);
}
function Gh(e) {
return e ? fa(e) || Zc(e) ? Mt({}, e) : e : null;
}
function Hs(e, t, n = !1, s = !1) {
const { props: r, ref: i, patchFlag: o, children: a, transition: l } = e, d = t ? Yh(r || {}, t) : r, c = {
__v_isVNode: !0,
__v_skip: !0,
type: e.type,
props: d,
key: d && uu(d),
ref: t && t.ref ? (
// #2078 in the case of <component :is="vnode" ref="extra"/>
// if the vnode itself already has a ref, cloneVNode will need to merge
// the refs so the single vnode can be set on multiple refs
n && i ? ve(i) ? i.concat(oi(t)) : [i, oi(t)] : oi(t)
) : i,
scopeId: e.scopeId,
slotScopeIds: e.slotScopeIds,
children: a,
target: e.target,
targetStart: e.targetStart,
targetAnchor: e.targetAnchor,
staticCount: e.staticCount,
shapeFlag: e.shapeFlag,
// if the vnode is cloned with extra props, we can no longer assume its
// existing patch flag to be reliable and need to add the FULL_PROPS flag.
// note: preserve flag for fragments since they use the flag for children
// fast paths only.
patchFlag: t && e.type !== ze ? o === -1 ? 16 : o | 16 : o,
dynamicProps: e.dynamicProps,
dynamicChildren: e.dynamicChildren,
appContext: e.appContext,
dirs: e.dirs,
transition: l,
// These should technically only be non-null on mounted VNodes. However,
// they *should* be copied for kept-alive vnodes. So we just always copy
// them since them being non-null during a mount doesn't affect the logic as
// they will simply be overwritten.
component: e.component,
suspense: e.suspense,
ssContent: e.ssContent && Hs(e.ssContent),
ssFallback: e.ssFallback && Hs(e.ssFallback),
placeholder: e.placeholder,
el: e.el,
anchor: e.anchor,
ctx: e.ctx,
ce: e.ce
};
return l && s && da(
c,
l.clone(c)
), c;
}
function Ln(e = " ", t = 0) {
return $t(qi, null, e, t);
}
function go(e, t) {
const n = $t(ii, null, e);
return n.staticCount = t, n;
}
function le(e = "", t = !1) {
return t ? (T(), Ai(ts, null, e)) : $t(ts, null, e);
}
function _n(e) {
return e == null || typeof e == "boolean" ? $t(ts) : ve(e) ? $t(
ze,
null,
// #3666, avoid reference pollution when reusing vnode
e.slice()
) : cu(e) ? Yn(e) : $t(qi, null, String(e));
}
function Yn(e) {
return e.el === null && e.patchFlag !== -1 || e.memo ? e : Hs(e);
}
function ma(e, t) {
let n = 0;
const { shapeFlag: s } = e;
if (t == null)
t = null;
else if (ve(t))
n = 16;
else if (typeof t == "object")
if (s & 65) {
const r = t.default;
r && (r._c && (r._d = !1), ma(e, r()), r._c && (r._d = !0));
return;
} else {
n = 32;
const r = t._;
!r && !Zc(t) ? t._ctx = sn : r === 3 && sn && (sn.slots._ === 1 ? t._ = 1 : (t._ = 2, e.patchFlag |= 1024));
}
else ke(t) ? (t = { default: t, _ctx: sn }, n = 32) : (t = String(t), s & 64 ? (n = 16, t = [Ln(t)]) : n = 8);
e.children = t, e.shapeFlag |= n;
}
function Yh(...e) {
const t = {};
for (let n = 0; n < e.length; n++) {
const s = e[n];
for (const r in s)
if (r === "class")
t.class !== s.class && (t.class = Ue([t.class, s.class]));
else if (r === "style")
t.style = Ee([t.style, s.style]);
else if (Ni(r)) {
const i = t[r], o = s[r];
o && i !== o && !(ve(i) && i.includes(o)) && (t[r] = i ? [].concat(i, o) : o);
} else r !== "" && (t[r] = s[r]);
}
return t;
}
function dn(e, t, n, s = null) {
bn(e, t, 7, [
n,
s
]);
}
const Zh = Kc();
let Xh = 0;
function Jh(e, t, n) {
const s = e.type, r = (t ? t.appContext : e.appContext) || Zh, i = {
uid: Xh++,
vnode: e,
type: s,
parent: t,
appContext: r,
root: null,
// to be immediately set
next: null,
subTree: null,
// will be set synchronously right after creation
effect: null,
update: null,
// will be set synchronously right after creation
job: null,
scope: new Af(
!0
/* detached */
),
render: null,
proxy: null,
exposed: null,
exposeProxy: null,
withProxy: null,
provides: t ? t.provides : Object.create(r.provides),
ids: t ? t.ids : ["", 0, 0],
accessCache: null,
renderCache: [],
// local resolved assets
components: null,
directives: null,
// resolved props and emits options
propsOptions: Jc(s, r),
emitsOptions: ou(s, r),
// emit
emit: null,
// to be set immediately
emitted: null,
// props default value
propsDefaults: tt,
// inheritAttrs
inheritAttrs: s.inheritAttrs,
// state
ctx: tt,
data: tt,
props: tt,
attrs: tt,
slots: tt,
refs: tt,
setupState: tt,
setupContext: null,
// suspense related
suspense: n,
suspenseId: n ? n.pendingId : 0,
asyncDep: null,
asyncResolved: !1,
// lifecycle hooks
// not using enums here because it results in computed properties
isMounted: !1,
isUnmounted: !1,
isDeactivated: !1,
bc: null,
c: null,
bm: null,
m: null,
bu: null,
u: null,
um: null,
bum: null,
da: null,
a: null,
rtg: null,
rtc: null,
ec: null,
sp: null
};
return i.ctx = { _: i }, i.root = t ? t.root : i, i.emit = Uh.bind(null, i), e.ce && e.ce(i), i;
}
let Ut = null;
const Qh = () => Ut || sn;
let Ei, Wo;
{
const e = Pi(), t = (n, s) => {
let r;
return (r = e[n]) || (r = e[n] = []), r.push(s), (i) => {
r.length > 1 ? r.forEach((o) => o(i)) : r[0](i);
};
};
Ei = t(
"__VUE_INSTANCE_SETTERS__",
(n) => Ut = n
), Wo = t(
"__VUE_SSR_SETTERS__",
(n) => Nr = n
);
}
const Pr = (e) => {
const t = Ut;
return Ei(e), e.scope.on(), () => {
e.scope.off(), Ei(t);
};
}, hl = () => {
Ut && Ut.scope.off(), Ei(null);
};
function fu(e) {
return e.vnode.shapeFlag & 4;
}
let Nr = !1;
function ed(e, t = !1, n = !1) {
t && Wo(t);
const { props: s, children: r } = e.vnode, i = fu(e);
Eh(e, s, i, t), Ih(e, r, n || t);
const o = i ? td(e, t) : void 0;
return t && Wo(!1), o;
}
function td(e, t) {
const n = e.type;
e.accessCache = /* @__PURE__ */ Object.create(null), e.proxy = new Proxy(e.ctx, _h);
const { setup: s } = n;
if (s) {
Fn();
const r = e.setupContext = s.length > 1 ? sd(e) : null, i = Pr(e), o = Mr(
s,
e,
0,
[
e.props,
r
]
), a = dc(o);
if (Bn(), i(), (a || e.sp) && !Ar(e) && zc(e), a) {
if (o.then(hl, hl), t)
return o.then((l) => {
dl(e, l);
}).catch((l) => {
$i(l, e, 0);
});
e.asyncDep = o;
} else
dl(e, o);
} else
hu(e);
}
function dl(e, t, n) {
ke(t) ? e.type.__ssrInlineRender ? e.ssrRender = t : e.render = t : ut(t) && (e.setupState = Dc(t)), hu(e);
}
function hu(e, t, n) {
const s = e.type;
e.render || (e.render = s.render || yn);
{
const r = Pr(e);
Fn();
try {
yh(e);
} finally {
Bn(), r();
}
}
}
const nd = {
get(e, t) {
return Ot(e, "get", ""), e[t];
}
};
function sd(e) {
const t = (n) => {
e.exposed = n || {};
};
return {
attrs: new Proxy(e.attrs, nd),
slots: e.slots,
emit: e.emit,
expose: t
};
}
function ji(e) {
return e.exposed ? e.exposeProxy || (e.exposeProxy = new Proxy(Dc(Vf(e.exposed)), {
get(t, n) {
if (n in t)
return t[n];
if (n in Er)
return Er[n](e);
},
has(t, n) {
return n in t || n in Er;
}
})) : e.proxy;
}
function rd(e) {
return ke(e) && "__vccOpts" in e;
}
const de = (e, t) => Xf(e, t, Nr), id = "3.5.18";
/**
* @vue/runtime-dom v3.5.18
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
let qo;
const pl = typeof window < "u" && window.trustedTypes;
if (pl)
try {
qo = /* @__PURE__ */ pl.createPolicy("vue", {
createHTML: (e) => e
});
} catch {
}
const du = qo ? (e) => qo.createHTML(e) : (e) => e, od = "http://www.w3.org/2000/svg", ad = "http://www.w3.org/1998/Math/MathML", On = typeof document < "u" ? document : null, gl = On && /* @__PURE__ */ On.createElement("template"), ld = {
insert: (e, t, n) => {
t.insertBefore(e, n || null);
},
remove: (e) => {
const t = e.parentNode;
t && t.removeChild(e);
},
createElement: (e, t, n, s) => {
const r = t === "svg" ? On.createElementNS(od, e) : t === "mathml" ? On.createElementNS(ad, e) : n ? On.createElement(e, { is: n }) : On.createElement(e);
return e === "select" && s && s.multiple != null && r.setAttribute("multiple", s.multiple), r;
},
createText: (e) => On.createTextNode(e),
createComment: (e) => On.createComment(e),
setText: (e, t) => {
e.nodeValue = t;
},
setElementText: (e, t) => {
e.textContent = t;
},
parentNode: (e) => e.parentNode,
nextSibling: (e) => e.nextSibling,
querySelector: (e) => On.querySelector(e),
setScopeId(e, t) {
e.setAttribute(t, "");
},
// __UNSAFE__
// Reason: innerHTML.
// Static content here can only come from compiled templates.
// As long as the user only uses trusted templates, this is safe.
insertStaticContent(e, t, n, s, r, i) {
const o = n ? n.previousSibling : t.lastChild;
if (r && (r === i || r.nextSibling))
for (; t.insertBefore(r.cloneNode(!0), n), !(r === i || !(r = r.nextSibling)); )
;
else {
gl.innerHTML = du(
s === "svg" ? `<svg>${e}</svg>` : s === "mathml" ? `<math>${e}</math>` : e
);
const a = gl.content;
if (s === "svg" || s === "mathml") {
const l = a.firstChild;
for (; l.firstChild; )
a.appendChild(l.firstChild);
a.removeChild(l);
}
t.insertBefore(a, n);
}
return [
// first
o ? o.nextSibling : t.firstChild,
// last
n ? n.previousSibling : t.lastChild
];
}
}, cd = Symbol("_vtc");
function ud(e, t, n) {
const s = e[cd];
s && (t = (t ? [t, ...s] : [...s]).join(" ")), t == null ? e.removeAttribute("class") : n ? e.setAttribute("class", t) : e.className = t;
}
const Si = Symbol("_vod"), pu = Symbol("_vsh"), fd = {
beforeMount(e, { value: t }, { transition: n }) {
e[Si] = e.style.display === "none" ? "" : e.style.display, n && t ? n.beforeEnter(e) : cr(e, t);
},
mounted(e, { value: t }, { transition: n }) {
n && t && n.enter(e);
},
updated(e, { value: t, oldValue: n }, { transition: s }) {
!t != !n && (s ? t ? (s.beforeEnter(e), cr(e, !0), s.enter(e)) : s.leave(e, () => {
cr(e, !1);
}) : cr(e, t));
},
beforeUnmount(e, { value: t }) {
cr(e, t);
}
};
function cr(e, t) {
e.style.display = t ? e[Si] : "none", e[pu] = !t;
}
const hd = Symbol(""), dd = /(^|;)\s*display\s*:/;
function pd(e, t, n) {
const s = e.style, r = mt(n);
let i = !1;
if (n && !r) {
if (t)
if (mt(t))
for (const o of t.split(";")) {
const a = o.slice(0, o.indexOf(":")).trim();
n[a] == null && ai(s, a, "");
}
else
for (const o in t)
n[o] == null && ai(s, o, "");
for (const o in n)
o === "display" && (i = !0), ai(s, o, n[o]);
} else if (r) {
if (t !== n) {
const o = s[hd];
o && (n += ";" + o), s.cssText = n, i = dd.test(n);
}
} else t && e.removeAttribute("style");
Si in e && (e[Si] = i ? s.display : "", e[pu] && (s.display = "none"));
}
const ml = /\s*!important$/;
function ai(e, t, n) {
if (ve(n))
n.forEach((s) => ai(e, t, s));
else if (n == null && (n = ""), t.startsWith("--"))
e.setProperty(t, n);
else {
const s = gd(e, t);
ml.test(n) ? e.setProperty(
ss(s),
n.replace(ml, ""),
"important"
) : e[s] = n;
}
}
const _l = ["Webkit", "Moz", "ms"], mo = {};
function gd(e, t) {
const n = mo[t];
if (n)
return n;
let s = Qn(t);
if (s !== "filter" && s in e)
return mo[t] = s;
s = mc(s);
for (let r = 0; r < _l.length; r++) {
const i = _l[r] + s;
if (i in e)
return mo[t] = i;
}
return t;
}
const yl = "http://www.w3.org/1999/xlink";
function vl(e, t, n, s, r, i = Tf(t)) {
s && t.startsWith("xlink:") ? n == null ? e.removeAttributeNS(yl, t.slice(6, t.length)) : e.setAttributeNS(yl, t, n) : n == null || i && !_c(n) ? e.removeAttribute(t) : e.setAttribute(
t,
i ? "" : ns(n) ? String(n) : n
);
}
function bl(e, t, n, s, r) {
if (t === "innerHTML" || t === "textContent") {
n != null && (e[t] = t === "innerHTML" ? du(n) : n);
return;
}
const i = e.tagName;
if (t === "value" && i !== "PROGRESS" && // custom elements may use _value internally
!i.includes("-")) {
const a = i === "OPTION" ? e.getAttribute("value") || "" : e.value, l = n == null ? (
// #11647: value should be set as empty string for null and undefined,
// but <input type="checkbox"> should be set as 'on'.
e.type === "checkbox" ? "on" : ""
) : String(n);
(a !== l || !("_value" in e)) && (e.value = l), n == null && e.removeAttribute(t), e._value = n;
return;
}
let o = !1;
if (n === "" || n == null) {
const a = typeof e[t];
a === "boolean" ? n = _c(n) : n == null && a === "string" ? (n = "", o = !0) : a === "number" && (n = 0, o = !0);
}
try {
e[t] = n;
} catch {
}
o && e.removeAttribute(r || t);
}
function Os(e, t, n, s) {
e.addEventListener(t, n, s);
}
function md(e, t, n, s) {
e.removeEventListener(t, n, s);
}
const wl = Symbol("_vei");
function _d(e, t, n, s, r = null) {
const i = e[wl] || (e[wl] = {}), o = i[t];
if (s && o)
o.value = s;
else {
const [a, l] = yd(t);
if (s) {
const d = i[t] = wd(
s,
r
);
Os(e, a, d, l);
} else o && (md(e, a, o, l), i[t] = void 0);
}
}
const kl = /(?:Once|Passive|Capture)$/;
function yd(e) {
let t;
if (kl.test(e)) {
t = {};
let s;
for (; s = e.match(kl); )
e = e.slice(0, e.length - s[0].length), t[s[0].toLowerCase()] = !0;
}
return [e[2] === ":" ? e.slice(3) : ss(e.slice(2)), t];
}
let _o = 0;
const vd = /* @__PURE__ */ Promise.resolve(), bd = () => _o || (vd.then(() => _o = 0), _o = Date.now());
function wd(e, t) {
const n = (s) => {
if (!s._vts)
s._vts = Date.now();
else if (s._vts <= n.attached)
return;
bn(
kd(s, n.value),
t,
5,
[s]
);
};
return n.value = e, n.attached = bd(), n;
}
function kd(e, t) {
if (ve(t)) {
const n = e.stopImmediatePropagation;
return e.stopImmediatePropagation = () => {
n.call(e), e._stopped = !0;
}, t.map(
(s) => (r) => !r._stopped && s && s(r)
);
} else
return t;
}
const xl = (e) => e.charCodeAt(0) === 111 && e.charCodeAt(1) === 110 && // lowercase letter
e.charCodeAt(2) > 96 && e.charCodeAt(2) < 123, xd = (e, t, n, s, r, i) => {
const o = r === "svg";
t === "class" ? ud(e, s, o) : t === "style" ? pd(e, n, s) : Ni(t) ? na(t) || _d(e, t, n, s, i) : (t[0] === "." ? (t = t.slice(1), !0) : t[0] === "^" ? (t = t.slice(1), !1) : Td(e, t, s, o)) ? (bl(e, t, s), !e.tagName.includes("-") && (t === "value" || t === "checked" || t === "selected") && vl(e, t, s, o, i, t !== "value")) : /* #11081 force set props for possible async custom element */ e._isVueCE && (/[A-Z]/.test(t) || !mt(s)) ? bl(e, Qn(t), s, i, t) : (t === "true-value" ? e._trueValue = s : t === "false-value" && (e._falseValue = s), vl(e, t, s, o));
};
function Td(e, t, n, s) {
if (s)
return !!(t === "innerHTML" || t === "textContent" || t in e && xl(t) && ke(n));
if (t === "spellcheck" || t === "draggable" || t === "translate" || t === "autocorrect" || t === "form" || t === "list" && e.tagName === "INPUT" || t === "type" && e.tagName === "TEXTAREA")
return !1;
if (t === "width" || t === "height") {
const r = e.tagName;
if (r === "IMG" || r === "VIDEO" || r === "CANVAS" || r === "SOURCE")
return !1;
}
return xl(t) && mt(n) ? !1 : t in e;
}
const Tl = (e) => {
const t = e.props["onUpdate:modelValue"] || !1;
return ve(t) ? (n) => si(t, n) : t;
};
function Ad(e) {
e.target.composing = !0;
}
function Al(e) {
const t = e.target;
t.composing && (t.composing = !1, t.dispatchEvent(new Event("input")));
}
const yo = Symbol("_assign"), hs = {
created(e, { modifiers: { lazy: t, trim: n, number: s } }, r) {
e[yo] = Tl(r);
const i = s || r.props && r.props.type === "number";
Os(e, t ? "change" : "input", (o) => {
if (o.target.composing) return;
let a = e.value;
n && (a = a.trim()), i && (a = Mo(a)), e[yo](a);
}), n && Os(e, "change", () => {
e.value = e.value.trim();
}), t || (Os(e, "compositionstart", Ad), Os(e, "compositionend", Al), Os(e, "change", Al));
},
// set value on mounted so it's after min/max for type="range"
mounted(e, { value: t }) {
e.value = t ?? "";
},
beforeUpdate(e, { value: t, oldValue: n, modifiers: { lazy: s, trim: r, number: i } }, o) {
if (e[yo] = Tl(o), e.composing) return;
const a = (i || e.type === "number") && !/^0\d/.test(e.value) ? Mo(e.value) : e.value, l = t ?? "";
a !== l && (document.activeElement === e && e.type !== "range" && (s && t === n || r && e.value.trim() === l) || (e.value = l));
}
}, Ed = ["ctrl", "shift", "alt", "meta"], Sd = {
stop: (e) => e.stopPropagation(),
prevent: (e) => e.preventDefault(),
self: (e) => e.target !== e.currentTarget,
ctrl: (e) => !e.ctrlKey,
shift: (e) => !e.shiftKey,
alt: (e) => !e.altKey,
meta: (e) => !e.metaKey,
left: (e) => "button" in e && e.button !== 0,
middle: (e) => "button" in e && e.button !== 1,
right: (e) => "button" in e && e.button !== 2,
exact: (e, t) => Ed.some((n) => e[`${n}Key`] && !t.includes(n))
}, gs = (e, t) => {
const n = e._withMods || (e._withMods = {}), s = t.join(".");
return n[s] || (n[s] = (r, ...i) => {
for (let o = 0; o < t.length; o++) {
const a = Sd[t[o]];
if (a && a(r, t)) return;
}
return e(r, ...i);
});
}, Cd = {
esc: "escape",
space: " ",
up: "arrow-up",
left: "arrow-left",
right: "arrow-right",
down: "arrow-down",
delete: "backspace"
}, li = (e, t) => {
const n = e._withKeys || (e._withKeys = {}), s = t.join(".");
return n[s] || (n[s] = (r) => {
if (!("key" in r))
return;
const i = ss(r.key);
if (t.some(
(o) => o === i || Cd[o] === i
))
return e(r);
});
}, Rd = /* @__PURE__ */ Mt({ patchProp: xd }, ld);
let El;
function Id() {
return El || (El = Oh(Rd));
}
const Ld = (...e) => {
const t = Id().createApp(...e), { mount: n } = t;
return t.mount = (s) => {
const r = Nd(s);
if (!r) return;
const i = t._component;
!ke(i) && !i.render && !i.template && (i.template = r.innerHTML), r.nodeType === 1 && (r.textContent = "");
const o = n(r, !1, Od(r));
return r instanceof Element && (r.removeAttribute("v-cloak"), r.setAttribute("data-v-app", "")), o;
}, t;
};
function Od(e) {
if (e instanceof SVGElement)
return "svg";
if (typeof MathMLElement == "function" && e instanceof MathMLElement)
return "mathml";
}
function Nd(e) {
return mt(e) ? document.querySelector(e) : e;
}
const $s = (e) => {
const t = e.replace("#", ""), n = parseInt(t.substr(0, 2), 16), s = parseInt(t.substr(2, 2), 16), r = parseInt(t.substr(4, 2), 16);
return (n * 299 + s * 587 + r * 114) / 1e3 < 128;
}, Md = (e, t) => {
const n = e.replace("#", ""), s = parseInt(n.substr(0, 2), 16), r = parseInt(n.substr(2, 2), 16), i = parseInt(n.substr(4, 2), 16), o = $s(e), a = o ? Math.min(255, s + t) : Math.max(0, s - t), l = o ? Math.min(255, r + t) : Math.max(0, r - t), d = o ? Math.min(255, i + t) : Math.max(0, i - t);
return `#${a.toString(16).padStart(2, "0")}${l.toString(16).padStart(2, "0")}${d.toString(16).padStart(2, "0")}`;
}, ur = (e) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e), Dd = (e) => {
switch (e.type) {
case "connection_error":
return "Unable to connect. Please try again later.";
case "auth_error":
return "Authentication failed. Please refresh the page.";
case "chat_error":
return "Unable to send message. Please try again.";
case "ai_config_missing":
return "Chat service is currently unavailable.";
default:
return e.error || "Something went wrong. Please try again.";
}
};
function _a() {
return {
async: !1,
breaks: !1,
extensions: null,
gfm: !0,
hooks: null,
pedantic: !1,
renderer: null,
silent: !1,
tokenizer: null,
walkTokens: null
};
}
var bs = _a();
function gu(e) {
bs = e;
}
var Cr = { exec: () => null };
function Ve(e, t = "") {
let n = typeof e == "string" ? e : e.source;
const s = {
replace: (r, i) => {
let o = typeof i == "string" ? i : i.source;
return o = o.replace(zt.caret, "$1"), n = n.replace(r, o), s;
},
getRegex: () => new RegExp(n, t)
};
return s;
}
var zt = {
codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
outputLinkReplace: /\\([\[\]])/g,
indentCodeCompensation: /^(\s+)(?:```)/,
beginningSpace: /^\s+/,
endingHash: /#$/,
startingSpaceChar: /^ /,
endingSpaceChar: / $/,
nonSpaceChar: /[^ ]/,
newLineCharGlobal: /\n/g,
tabCharGlobal: /\t/g,
multipleSpaceGlobal: /\s+/g,
blankLine: /^[ \t]*$/,
doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
blockquoteStart: /^ {0,3}>/,
blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
listReplaceTabs: /^\t+/,
listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
listIsTask: /^\[[ xX]\] /,
listReplaceTask: /^\[[ xX]\] +/,
anyLine: /\n.*\n/,
hrefBrackets: /^<(.*)>$/,
tableDelimiter: /[:|]/,
tableAlignChars: /^\||\| *$/g,
tableRowBlankLine: /\n[ \t]*$/,
tableAlignRight: /^ *-+: *$/,
tableAlignCenter: /^ *:-+: *$/,
tableAlignLeft: /^ *:-+ *$/,
startATag: /^<a /i,
endATag: /^<\/a>/i,
startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
startAngleBracket: /^</,
endAngleBracket: />$/,
pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
escapeTest: /[&<>"']/,
escapeReplace: /[&<>"']/g,
escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
caret: /(^|[^\[])\^/g,
percentDecode: /%25/g,
findPipe: /\|/g,
splitPipe: / \|/,
slashPipe: /\\\|/g,
carriageReturn: /\r\n|\r/g,
spaceLine: /^ +$/gm,
notSpaceStart: /^\S*/,
endingNewline: /\n$/,
listItemRegex: (e) => new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),
nextBulletRegex: (e) => new RegExp(`^ {0,${Math.min(3, e - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
hrRegex: (e) => new RegExp(`^ {0,${Math.min(3, e - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
fencesBeginRegex: (e) => new RegExp(`^ {0,${Math.min(3, e - 1)}}(?:\`\`\`|~~~)`),
headingBeginRegex: (e) => new RegExp(`^ {0,${Math.min(3, e - 1)}}#`),
htmlBeginRegex: (e) => new RegExp(`^ {0,${Math.min(3, e - 1)}}<(?:[a-z].*>|!--)`, "i")
}, Pd = /^(?:[ \t]*(?:\n|$))+/, Fd = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, Bd = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, Fr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, $d = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, ya = /(?:[*+-]|\d{1,9}[.)])/, mu = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, _u = Ve(mu).replace(/bull/g, ya).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(), Ud = Ve(mu).replace(/bull/g, ya).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), va = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, zd = /^[^\n]+/, ba = /(?!\s*\])(?:\\.|[^\[\]\\])+/, Hd = Ve(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", ba).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Wd = Ve(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, ya).getRegex(), Vi = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", wa = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, qd = Ve(
"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))",
"i"
).replace("comment", wa).replace("tag", Vi).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), yu = Ve(va).replace("hr", Fr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Vi).getRegex(), jd = Ve(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", yu).getRegex(), ka = {
blockquote: jd,
code: Fd,
def: Hd,
fences: Bd,
heading: $d,
hr: Fr,
html: qd,
lheading: _u,
list: Wd,
newline: Pd,
paragraph: yu,
table: Cr,
text: zd
}, Sl = Ve(
"^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
).replace("hr", Fr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Vi).getRegex(), Vd = {
...ka,
lheading: Ud,
table: Sl,
paragraph: Ve(va).replace("hr", Fr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", Sl).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Vi).getRegex()
}, Kd = {
...ka,
html: Ve(
`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
).replace("comment", wa).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
heading: /^(#{1,6})(.*)(?:\n+|$)/,
fences: Cr,
// fences not supported
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
paragraph: Ve(va).replace("hr", Fr).replace("heading", ` *#{1,6} *[^
]`).replace("lheading", _u).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
}, Gd = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Yd = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, vu = /^( {2,}|\\)\n(?!\s*$)/, Zd = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, Ki = /[\p{P}\p{S}]/u, xa = /[\s\p{P}\p{S}]/u, bu = /[^\s\p{P}\p{S}]/u, Xd = Ve(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, xa).getRegex(), wu = /(?!~)[\p{P}\p{S}]/u, Jd = /(?!~)[\s\p{P}\p{S}]/u, Qd = /(?:[^\s\p{P}\p{S}]|~)/u, ep = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g, ku = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, tp = Ve(ku, "u").replace(/punct/g, Ki).getRegex(), np = Ve(ku, "u").replace(/punct/g, wu).getRegex(), xu = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", sp = Ve(xu, "gu").replace(/notPunctSpace/g, bu).replace(/punctSpace/g, xa).replace(/punct/g, Ki).getRegex(), rp = Ve(xu, "gu").replace(/notPunctSpace/g, Qd).replace(/punctSpace/g, Jd).replace(/punct/g, wu).getRegex(), ip = Ve(
"^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
"gu"
).replace(/notPunctSpace/g, bu).replace(/punctSpace/g, xa).replace(/punct/g, Ki).getRegex(), op = Ve(/\\(punct)/, "gu").replace(/punct/g, Ki).getRegex(), ap = Ve(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), lp = Ve(wa).replace("(?:-->|$)", "-->").getRegex(), cp = Ve(
"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
).replace("comment", lp).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Ci = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, up = Ve(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", Ci).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), Tu = Ve(/^!?\[(label)\]\[(ref)\]/).replace("label", Ci).replace("ref", ba).getRegex(), Au = Ve(/^!?\[(ref)\](?:\[\])?/).replace("ref", ba).getRegex(), fp = Ve("reflink|nolink(?!\\()", "g").replace("reflink", Tu).replace("nolink", Au).getRegex(), Ta = {
_backpedal: Cr,
// only used for GFM url
anyPunctuation: op,
autolink: ap,
blockSkip: ep,
br: vu,
code: Yd,
del: Cr,
emStrongLDelim: tp,
emStrongRDelimAst: sp,
emStrongRDelimUnd: ip,
escape: Gd,
link: up,
nolink: Au,
punctuation: Xd,
reflink: Tu,
reflinkSearch: fp,
tag: cp,
text: Zd,
url: Cr
}, hp = {
...Ta,
link: Ve(/^!?\[(label)\]\((.*?)\)/).replace("label", Ci).getRegex(),
reflink: Ve(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", Ci).getRegex()
}, jo = {
...Ta,
emStrongRDelimAst: rp,
emStrongLDelim: np,
url: Ve(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
}, dp = {
...jo,
br: Ve(vu).replace("{2,}", "*").getRegex(),
text: Ve(jo.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
}, Qr = {
normal: ka,
gfm: Vd,
pedantic: Kd
}, fr = {
normal: Ta,
gfm: jo,
breaks: dp,
pedantic: hp
}, pp = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
"'": "&#39;"
}, Cl = (e) => pp[e];
function gn(e, t) {
if (t) {
if (zt.escapeTest.test(e))
return e.replace(zt.escapeReplace, Cl);
} else if (zt.escapeTestNoEncode.test(e))
return e.replace(zt.escapeReplaceNoEncode, Cl);
return e;
}
function Rl(e) {
try {
e = encodeURI(e).replace(zt.percentDecode, "%");
} catch {
return null;
}
return e;
}
function Il(e, t) {
var i;
const n = e.replace(zt.findPipe, (o, a, l) => {
let d = !1, c = a;
for (; --c >= 0 && l[c] === "\\"; ) d = !d;
return d ? "|" : " |";
}), s = n.split(zt.splitPipe);
let r = 0;
if (s[0].trim() || s.shift(), s.length > 0 && !((i = s.at(-1)) != null && i.trim()) && s.pop(), t)
if (s.length > t)
s.splice(t);
else
for (; s.length < t; ) s.push("");
for (; r < s.length; r++)
s[r] = s[r].trim().replace(zt.slashPipe, "|");
return s;
}
function hr(e, t, n) {
const s = e.length;
if (s === 0)
return "";
let r = 0;
for (; r < s && e.charAt(s - r - 1) === t; )
r++;
return e.slice(0, s - r);
}
function gp(e, t) {
if (e.indexOf(t[1]) === -1)
return -1;
let n = 0;
for (let s = 0; s < e.length; s++)
if (e[s] === "\\")
s++;
else if (e[s] === t[0])
n++;
else if (e[s] === t[1] && (n--, n < 0))
return s;
return n > 0 ? -2 : -1;
}
function Ll(e, t, n, s, r) {
const i = t.href, o = t.title || null, a = e[1].replace(r.other.outputLinkReplace, "$1");
s.state.inLink = !0;
const l = {
type: e[0].charAt(0) === "!" ? "image" : "link",
raw: n,
href: i,
title: o,
text: a,
tokens: s.inlineTokens(a)
};
return s.state.inLink = !1, l;
}
function mp(e, t, n) {
const s = e.match(n.other.indentCodeCompensation);
if (s === null)
return t;
const r = s[1];
return t.split(`
`).map((i) => {
const o = i.match(n.other.beginningSpace);
if (o === null)
return i;
const [a] = o;
return a.length >= r.length ? i.slice(r.length) : i;
}).join(`
`);
}
var Ri = class {
// set by the lexer
constructor(e) {
et(this, "options");
et(this, "rules");
// set by the lexer
et(this, "lexer");
this.options = e || bs;
}
space(e) {
const t = this.rules.block.newline.exec(e);
if (t && t[0].length > 0)
return {
type: "space",
raw: t[0]
};
}
code(e) {
const t = this.rules.block.code.exec(e);
if (t) {
const n = t[0].replace(this.rules.other.codeRemoveIndent, "");
return {
type: "code",
raw: t[0],
codeBlockStyle: "indented",
text: this.options.pedantic ? n : hr(n, `
`)
};
}
}
fences(e) {
const t = this.rules.block.fences.exec(e);
if (t) {
const n = t[0], s = mp(n, t[3] || "", this.rules);
return {
type: "code",
raw: n,
lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
text: s
};
}
}
heading(e) {
const t = this.rules.block.heading.exec(e);
if (t) {
let n = t[2].trim();
if (this.rules.other.endingHash.test(n)) {
const s = hr(n, "#");
(this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
}
return {
type: "heading",
raw: t[0],
depth: t[1].length,
text: n,
tokens: this.lexer.inline(n)
};
}
}
hr(e) {
const t = this.rules.block.hr.exec(e);
if (t)
return {
type: "hr",
raw: hr(t[0], `
`)
};
}
blockquote(e) {
const t = this.rules.block.blockquote.exec(e);
if (t) {
let n = hr(t[0], `
`).split(`
`), s = "", r = "";
const i = [];
for (; n.length > 0; ) {
let o = !1;
const a = [];
let l;
for (l = 0; l < n.length; l++)
if (this.rules.other.blockquoteStart.test(n[l]))
a.push(n[l]), o = !0;
else if (!o)
a.push(n[l]);
else
break;
n = n.slice(l);
const d = a.join(`
`), c = d.replace(this.rules.other.blockquoteSetextReplace, `
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
s = s ? `${s}
${d}` : d, r = r ? `${r}
${c}` : c;
const b = this.lexer.state.top;
if (this.lexer.state.top = !0, this.lexer.blockTokens(c, i, !0), this.lexer.state.top = b, n.length === 0)
break;
const w = i.at(-1);
if ((w == null ? void 0 : w.type) === "code")
break;
if ((w == null ? void 0 : w.type) === "blockquote") {
const z = w, I = z.raw + `
` + n.join(`
`), K = this.blockquote(I);
i[i.length - 1] = K, s = s.substring(0, s.length - z.raw.length) + K.raw, r = r.substring(0, r.length - z.text.length) + K.text;
break;
} else if ((w == null ? void 0 : w.type) === "list") {
const z = w, I = z.raw + `
` + n.join(`
`), K = this.list(I);
i[i.length - 1] = K, s = s.substring(0, s.length - w.raw.length) + K.raw, r = r.substring(0, r.length - z.raw.length) + K.raw, n = I.substring(i.at(-1).raw.length).split(`
`);
continue;
}
}
return {
type: "blockquote",
raw: s,
tokens: i,
text: r
};
}
}
list(e) {
let t = this.rules.block.list.exec(e);
if (t) {
let n = t[1].trim();
const s = n.length > 1, r = {
type: "list",
raw: "",
ordered: s,
start: s ? +n.slice(0, -1) : "",
loose: !1,
items: []
};
n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
const i = this.rules.other.listItemRegex(n);
let o = !1;
for (; e; ) {
let l = !1, d = "", c = "";
if (!(t = i.exec(e)) || this.rules.block.hr.test(e))
break;
d = t[0], e = e.substring(d.length);
let b = t[2].split(`
`, 1)[0].replace(this.rules.other.listReplaceTabs, (oe) => " ".repeat(3 * oe.length)), w = e.split(`
`, 1)[0], z = !b.trim(), I = 0;
if (this.options.pedantic ? (I = 2, c = b.trimStart()) : z ? I = t[1].length + 1 : (I = t[2].search(this.rules.other.nonSpaceChar), I = I > 4 ? 1 : I, c = b.slice(I), I += t[1].length), z && this.rules.other.blankLine.test(w) && (d += w + `
`, e = e.substring(w.length + 1), l = !0), !l) {
const oe = this.rules.other.nextBulletRegex(I), fe = this.rules.other.hrRegex(I), pe = this.rules.other.fencesBeginRegex(I), R = this.rules.other.headingBeginRegex(I), N = this.rules.other.htmlBeginRegex(I);
for (; e; ) {
const Y = e.split(`
`, 1)[0];
let X;
if (w = Y, this.options.pedantic ? (w = w.replace(this.rules.other.listReplaceNesting, " "), X = w) : X = w.replace(this.rules.other.tabCharGlobal, " "), pe.test(w) || R.test(w) || N.test(w) || oe.test(w) || fe.test(w))
break;
if (X.search(this.rules.other.nonSpaceChar) >= I || !w.trim())
c += `
` + X.slice(I);
else {
if (z || b.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || pe.test(b) || R.test(b) || fe.test(b))
break;
c += `
` + w;
}
!z && !w.trim() && (z = !0), d += Y + `
`, e = e.substring(Y.length + 1), b = X.slice(I);
}
}
r.loose || (o ? r.loose = !0 : this.rules.other.doubleBlankLine.test(d) && (o = !0));
let K = null, P;
this.options.gfm && (K = this.rules.other.listIsTask.exec(c), K && (P = K[0] !== "[ ] ", c = c.replace(this.rules.other.listReplaceTask, ""))), r.items.push({
type: "list_item",
raw: d,
task: !!K,
checked: P,
loose: !1,
text: c,
tokens: []
}), r.raw += d;
}
const a = r.items.at(-1);
if (a)
a.raw = a.raw.trimEnd(), a.text = a.text.trimEnd();
else
return;
r.raw = r.raw.trimEnd();
for (let l = 0; l < r.items.length; l++)
if (this.lexer.state.top = !1, r.items[l].tokens = this.lexer.blockTokens(r.items[l].text, []), !r.loose) {
const d = r.items[l].tokens.filter((b) => b.type === "space"), c = d.length > 0 && d.some((b) => this.rules.other.anyLine.test(b.raw));
r.loose = c;
}
if (r.loose)
for (let l = 0; l < r.items.length; l++)
r.items[l].loose = !0;
return r;
}
}
html(e) {
const t = this.rules.block.html.exec(e);
if (t)
return {
type: "html",
block: !0,
raw: t[0],
pre: t[1] === "pre" || t[1] === "script" || t[1] === "style",
text: t[0]
};
}
def(e) {
const t = this.rules.block.def.exec(e);
if (t) {
const n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
return {
type: "def",
tag: n,
raw: t[0],
href: s,
title: r
};
}
}
table(e) {
var o;
const t = this.rules.block.table.exec(e);
if (!t || !this.rules.other.tableDelimiter.test(t[2]))
return;
const n = Il(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = (o = t[3]) != null && o.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
`) : [], i = {
type: "table",
raw: t[0],
header: [],
align: [],
rows: []
};
if (n.length === s.length) {
for (const a of s)
this.rules.other.tableAlignRight.test(a) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(a) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(a) ? i.align.push("left") : i.align.push(null);
for (let a = 0; a < n.length; a++)
i.header.push({
text: n[a],
tokens: this.lexer.inline(n[a]),
header: !0,
align: i.align[a]
});
for (const a of r)
i.rows.push(Il(a, i.header.length).map((l, d) => ({
text: l,
tokens: this.lexer.inline(l),
header: !1,
align: i.align[d]
})));
return i;
}
}
lheading(e) {
const t = this.rules.block.lheading.exec(e);
if (t)
return {
type: "heading",
raw: t[0],
depth: t[2].charAt(0) === "=" ? 1 : 2,
text: t[1],
tokens: this.lexer.inline(t[1])
};
}
paragraph(e) {
const t = this.rules.block.paragraph.exec(e);
if (t) {
const n = t[1].charAt(t[1].length - 1) === `
` ? t[1].slice(0, -1) : t[1];
return {
type: "paragraph",
raw: t[0],
text: n,
tokens: this.lexer.inline(n)
};
}
}
text(e) {
const t = this.rules.block.text.exec(e);
if (t)
return {
type: "text",
raw: t[0],
text: t[0],
tokens: this.lexer.inline(t[0])
};
}
escape(e) {
const t = this.rules.inline.escape.exec(e);
if (t)
return {
type: "escape",
raw: t[0],
text: t[1]
};
}
tag(e) {
const t = this.rules.inline.tag.exec(e);
if (t)
return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = !1), {
type: "html",
raw: t[0],
inLink: this.lexer.state.inLink,
inRawBlock: this.lexer.state.inRawBlock,
block: !1,
text: t[0]
};
}
link(e) {
const t = this.rules.inline.link.exec(e);
if (t) {
const n = t[2].trim();
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
if (!this.rules.other.endAngleBracket.test(n))
return;
const i = hr(n.slice(0, -1), "\\");
if ((n.length - i.length) % 2 === 0)
return;
} else {
const i = gp(t[2], "()");
if (i === -2)
return;
if (i > -1) {
const a = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, a).trim(), t[3] = "";
}
}
let s = t[2], r = "";
if (this.options.pedantic) {
const i = this.rules.other.pedanticHrefTitle.exec(s);
i && (s = i[1], r = i[3]);
} else
r = t[3] ? t[3].slice(1, -1) : "";
return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), Ll(t, {
href: s && s.replace(this.rules.inline.anyPunctuation, "$1"),
title: r && r.replace(this.rules.inline.anyPunctuation, "$1")
}, t[0], this.lexer, this.rules);
}
}
reflink(e, t) {
let n;
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
const s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()];
if (!r) {
const i = n[0].charAt(0);
return {
type: "text",
raw: i,
text: i
};
}
return Ll(n, r, n[0], this.lexer, this.rules);
}
}
emStrong(e, t, n = "") {
let s = this.rules.inline.emStrongLDelim.exec(e);
if (!s || s[3] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
if (!(s[1] || s[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
const i = [...s[0]].length - 1;
let o, a, l = i, d = 0;
const c = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
for (c.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = c.exec(t)) != null; ) {
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o) continue;
if (a = [...o].length, s[3] || s[4]) {
l += a;
continue;
} else if ((s[5] || s[6]) && i % 3 && !((i + a) % 3)) {
d += a;
continue;
}
if (l -= a, l > 0) continue;
a = Math.min(a, a + l + d);
const b = [...s[0]][0].length, w = e.slice(0, i + s.index + b + a);
if (Math.min(i, a) % 2) {
const I = w.slice(1, -1);
return {
type: "em",
raw: w,
text: I,
tokens: this.lexer.inlineTokens(I)
};
}
const z = w.slice(2, -2);
return {
type: "strong",
raw: w,
text: z,
tokens: this.lexer.inlineTokens(z)
};
}
}
}
codespan(e) {
const t = this.rules.inline.code.exec(e);
if (t) {
let n = t[2].replace(this.rules.other.newLineCharGlobal, " ");
const s = this.rules.other.nonSpaceChar.test(n), r = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
return s && r && (n = n.substring(1, n.length - 1)), {
type: "codespan",
raw: t[0],
text: n
};
}
}
br(e) {
const t = this.rules.inline.br.exec(e);
if (t)
return {
type: "br",
raw: t[0]
};
}
del(e) {
const t = this.rules.inline.del.exec(e);
if (t)
return {
type: "del",
raw: t[0],
text: t[2],
tokens: this.lexer.inlineTokens(t[2])
};
}
autolink(e) {
const t = this.rules.inline.autolink.exec(e);
if (t) {
let n, s;
return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), {
type: "link",
raw: t[0],
text: n,
href: s,
tokens: [
{
type: "text",
raw: n,
text: n
}
]
};
}
}
url(e) {
var n;
let t;
if (t = this.rules.inline.url.exec(e)) {
let s, r;
if (t[2] === "@")
s = t[0], r = "mailto:" + s;
else {
let i;
do
i = t[0], t[0] = ((n = this.rules.inline._backpedal.exec(t[0])) == null ? void 0 : n[0]) ?? "";
while (i !== t[0]);
s = t[0], t[1] === "www." ? r = "http://" + t[0] : r = t[0];
}
return {
type: "link",
raw: t[0],
text: s,
href: r,
tokens: [
{
type: "text",
raw: s,
text: s
}
]
};
}
}
inlineText(e) {
const t = this.rules.inline.text.exec(e);
if (t) {
const n = this.lexer.state.inRawBlock;
return {
type: "text",
raw: t[0],
text: t[0],
escaped: n
};
}
}
}, Dn = class Vo {
constructor(t) {
et(this, "tokens");
et(this, "options");
et(this, "state");
et(this, "tokenizer");
et(this, "inlineQueue");
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = t || bs, this.options.tokenizer = this.options.tokenizer || new Ri(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
inLink: !1,
inRawBlock: !1,
top: !0
};
const n = {
other: zt,
block: Qr.normal,
inline: fr.normal
};
this.options.pedantic ? (n.block = Qr.pedantic, n.inline = fr.pedantic) : this.options.gfm && (n.block = Qr.gfm, this.options.breaks ? n.inline = fr.breaks : n.inline = fr.gfm), this.tokenizer.rules = n;
}
/**
* Expose Rules
*/
static get rules() {
return {
block: Qr,
inline: fr
};
}
/**
* Static Lex Method
*/
static lex(t, n) {
return new Vo(n).lex(t);
}
/**
* Static Lex Inline Method
*/
static lexInline(t, n) {
return new Vo(n).inlineTokens(t);
}
/**
* Preprocessing
*/
lex(t) {
t = t.replace(zt.carriageReturn, `
`), this.blockTokens(t, this.tokens);
for (let n = 0; n < this.inlineQueue.length; n++) {
const s = this.inlineQueue[n];
this.inlineTokens(s.src, s.tokens);
}
return this.inlineQueue = [], this.tokens;
}
blockTokens(t, n = [], s = !1) {
var r, i, o;
for (this.options.pedantic && (t = t.replace(zt.tabCharGlobal, " ").replace(zt.spaceLine, "")); t; ) {
let a;
if ((i = (r = this.options.extensions) == null ? void 0 : r.block) != null && i.some((d) => (a = d.call({ lexer: this }, t, n)) ? (t = t.substring(a.raw.length), n.push(a), !0) : !1))
continue;
if (a = this.tokenizer.space(t)) {
t = t.substring(a.raw.length);
const d = n.at(-1);
a.raw.length === 1 && d !== void 0 ? d.raw += `
` : n.push(a);
continue;
}
if (a = this.tokenizer.code(t)) {
t = t.substring(a.raw.length);
const d = n.at(-1);
(d == null ? void 0 : d.type) === "paragraph" || (d == null ? void 0 : d.type) === "text" ? (d.raw += `
` + a.raw, d.text += `
` + a.text, this.inlineQueue.at(-1).src = d.text) : n.push(a);
continue;
}
if (a = this.tokenizer.fences(t)) {
t = t.substring(a.raw.length), n.push(a);
continue;
}
if (a = this.tokenizer.heading(t)) {
t = t.substring(a.raw.length), n.push(a);
continue;
}
if (a = this.tokenizer.hr(t)) {
t = t.substring(a.raw.length), n.push(a);
continue;
}
if (a = this.tokenizer.blockquote(t)) {
t = t.substring(a.raw.length), n.push(a);
continue;
}
if (a = this.tokenizer.list(t)) {
t = t.substring(a.raw.length), n.push(a);
continue;
}
if (a = this.tokenizer.html(t)) {
t = t.substring(a.raw.length), n.push(a);
continue;
}
if (a = this.tokenizer.def(t)) {
t = t.substring(a.raw.length);
const d = n.at(-1);
(d == null ? void 0 : d.type) === "paragraph" || (d == null ? void 0 : d.type) === "text" ? (d.raw += `
` + a.raw, d.text += `
` + a.raw, this.inlineQueue.at(-1).src = d.text) : this.tokens.links[a.tag] || (this.tokens.links[a.tag] = {
href: a.href,
title: a.title
});
continue;
}
if (a = this.tokenizer.table(t)) {
t = t.substring(a.raw.length), n.push(a);
continue;
}
if (a = this.tokenizer.lheading(t)) {
t = t.substring(a.raw.length), n.push(a);
continue;
}
let l = t;
if ((o = this.options.extensions) != null && o.startBlock) {
let d = 1 / 0;
const c = t.slice(1);
let b;
this.options.extensions.startBlock.forEach((w) => {
b = w.call({ lexer: this }, c), typeof b == "number" && b >= 0 && (d = Math.min(d, b));
}), d < 1 / 0 && d >= 0 && (l = t.substring(0, d + 1));
}
if (this.state.top && (a = this.tokenizer.paragraph(l))) {
const d = n.at(-1);
s && (d == null ? void 0 : d.type) === "paragraph" ? (d.raw += `
` + a.raw, d.text += `
` + a.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = d.text) : n.push(a), s = l.length !== t.length, t = t.substring(a.raw.length);
continue;
}
if (a = this.tokenizer.text(t)) {
t = t.substring(a.raw.length);
const d = n.at(-1);
(d == null ? void 0 : d.type) === "text" ? (d.raw += `
` + a.raw, d.text += `
` + a.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = d.text) : n.push(a);
continue;
}
if (t) {
const d = "Infinite loop on byte: " + t.charCodeAt(0);
if (this.options.silent) {
console.error(d);
break;
} else
throw new Error(d);
}
}
return this.state.top = !0, n;
}
inline(t, n = []) {
return this.inlineQueue.push({ src: t, tokens: n }), n;
}
/**
* Lexing/Compiling
*/
inlineTokens(t, n = []) {
var a, l, d;
let s = t, r = null;
if (this.tokens.links) {
const c = Object.keys(this.tokens.links);
if (c.length > 0)
for (; (r = this.tokenizer.rules.inline.reflinkSearch.exec(s)) != null; )
c.includes(r[0].slice(r[0].lastIndexOf("[") + 1, -1)) && (s = s.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
}
for (; (r = this.tokenizer.rules.inline.anyPunctuation.exec(s)) != null; )
s = s.slice(0, r.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
for (; (r = this.tokenizer.rules.inline.blockSkip.exec(s)) != null; )
s = s.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
let i = !1, o = "";
for (; t; ) {
i || (o = ""), i = !1;
let c;
if ((l = (a = this.options.extensions) == null ? void 0 : a.inline) != null && l.some((w) => (c = w.call({ lexer: this }, t, n)) ? (t = t.substring(c.raw.length), n.push(c), !0) : !1))
continue;
if (c = this.tokenizer.escape(t)) {
t = t.substring(c.raw.length), n.push(c);
continue;
}
if (c = this.tokenizer.tag(t)) {
t = t.substring(c.raw.length), n.push(c);
continue;
}
if (c = this.tokenizer.link(t)) {
t = t.substring(c.raw.length), n.push(c);
continue;
}
if (c = this.tokenizer.reflink(t, this.tokens.links)) {
t = t.substring(c.raw.length);
const w = n.at(-1);
c.type === "text" && (w == null ? void 0 : w.type) === "text" ? (w.raw += c.raw, w.text += c.text) : n.push(c);
continue;
}
if (c = this.tokenizer.emStrong(t, s, o)) {
t = t.substring(c.raw.length), n.push(c);
continue;
}
if (c = this.tokenizer.codespan(t)) {
t = t.substring(c.raw.length), n.push(c);
continue;
}
if (c = this.tokenizer.br(t)) {
t = t.substring(c.raw.length), n.push(c);
continue;
}
if (c = this.tokenizer.del(t)) {
t = t.substring(c.raw.length), n.push(c);
continue;
}
if (c = this.tokenizer.autolink(t)) {
t = t.substring(c.raw.length), n.push(c);
continue;
}
if (!this.state.inLink && (c = this.tokenizer.url(t))) {
t = t.substring(c.raw.length), n.push(c);
continue;
}
let b = t;
if ((d = this.options.extensions) != null && d.startInline) {
let w = 1 / 0;
const z = t.slice(1);
let I;
this.options.extensions.startInline.forEach((K) => {
I = K.call({ lexer: this }, z), typeof I == "number" && I >= 0 && (w = Math.min(w, I));
}), w < 1 / 0 && w >= 0 && (b = t.substring(0, w + 1));
}
if (c = this.tokenizer.inlineText(b)) {
t = t.substring(c.raw.length), c.raw.slice(-1) !== "_" && (o = c.raw.slice(-1)), i = !0;
const w = n.at(-1);
(w == null ? void 0 : w.type) === "text" ? (w.raw += c.raw, w.text += c.text) : n.push(c);
continue;
}
if (t) {
const w = "Infinite loop on byte: " + t.charCodeAt(0);
if (this.options.silent) {
console.error(w);
break;
} else
throw new Error(w);
}
}
return n;
}
}, Ii = class {
// set by the parser
constructor(e) {
et(this, "options");
et(this, "parser");
this.options = e || bs;
}
space(e) {
return "";
}
code({ text: e, lang: t, escaped: n }) {
var i;
const s = (i = (t || "").match(zt.notSpaceStart)) == null ? void 0 : i[0], r = e.replace(zt.endingNewline, "") + `
`;
return s ? '<pre><code class="language-' + gn(s) + '">' + (n ? r : gn(r, !0)) + `</code></pre>
` : "<pre><code>" + (n ? r : gn(r, !0)) + `</code></pre>
`;
}
blockquote({ tokens: e }) {
return `<blockquote>
${this.parser.parse(e)}</blockquote>
`;
}
html({ text: e }) {
return e;
}
heading({ tokens: e, depth: t }) {
return `<h${t}>${this.parser.parseInline(e)}</h${t}>
`;
}
hr(e) {
return `<hr>
`;
}
list(e) {
const t = e.ordered, n = e.start;
let s = "";
for (let o = 0; o < e.items.length; o++) {
const a = e.items[o];
s += this.listitem(a);
}
const r = t ? "ol" : "ul", i = t && n !== 1 ? ' start="' + n + '"' : "";
return "<" + r + i + `>
` + s + "</" + r + `>
`;
}
listitem(e) {
var n;
let t = "";
if (e.task) {
const s = this.checkbox({ checked: !!e.checked });
e.loose ? ((n = e.tokens[0]) == null ? void 0 : n.type) === "paragraph" ? (e.tokens[0].text = s + " " + e.tokens[0].text, e.tokens[0].tokens && e.tokens[0].tokens.length > 0 && e.tokens[0].tokens[0].type === "text" && (e.tokens[0].tokens[0].text = s + " " + gn(e.tokens[0].tokens[0].text), e.tokens[0].tokens[0].escaped = !0)) : e.tokens.unshift({
type: "text",
raw: s + " ",
text: s + " ",
escaped: !0
}) : t += s + " ";
}
return t += this.parser.parse(e.tokens, !!e.loose), `<li>${t}</li>
`;
}
checkbox({ checked: e }) {
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
}
paragraph({ tokens: e }) {
return `<p>${this.parser.parseInline(e)}</p>
`;
}
table(e) {
let t = "", n = "";
for (let r = 0; r < e.header.length; r++)
n += this.tablecell(e.header[r]);
t += this.tablerow({ text: n });
let s = "";
for (let r = 0; r < e.rows.length; r++) {
const i = e.rows[r];
n = "";
for (let o = 0; o < i.length; o++)
n += this.tablecell(i[o]);
s += this.tablerow({ text: n });
}
return s && (s = `<tbody>${s}</tbody>`), `<table>
<thead>
` + t + `</thead>
` + s + `</table>
`;
}
tablerow({ text: e }) {
return `<tr>
${e}</tr>
`;
}
tablecell(e) {
const t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
`;
}
/**
* span level renderer
*/
strong({ tokens: e }) {
return `<strong>${this.parser.parseInline(e)}</strong>`;
}
em({ tokens: e }) {
return `<em>${this.parser.parseInline(e)}</em>`;
}
codespan({ text: e }) {
return `<code>${gn(e, !0)}</code>`;
}
br(e) {
return "<br>";
}
del({ tokens: e }) {
return `<del>${this.parser.parseInline(e)}</del>`;
}
link({ href: e, title: t, tokens: n }) {
const s = this.parser.parseInline(n), r = Rl(e);
if (r === null)
return s;
e = r;
let i = '<a href="' + e + '"';
return t && (i += ' title="' + gn(t) + '"'), i += ">" + s + "</a>", i;
}
image({ href: e, title: t, text: n, tokens: s }) {
s && (n = this.parser.parseInline(s, this.parser.textRenderer));
const r = Rl(e);
if (r === null)
return gn(n);
e = r;
let i = `<img src="${e}" alt="${n}"`;
return t && (i += ` title="${gn(t)}"`), i += ">", i;
}
text(e) {
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : gn(e.text);
}
}, Aa = class {
// no need for block level renderers
strong({ text: e }) {
return e;
}
em({ text: e }) {
return e;
}
codespan({ text: e }) {
return e;
}
del({ text: e }) {
return e;
}
html({ text: e }) {
return e;
}
text({ text: e }) {
return e;
}
link({ text: e }) {
return "" + e;
}
image({ text: e }) {
return "" + e;
}
br() {
return "";
}
}, Pn = class Ko {
constructor(t) {
et(this, "options");
et(this, "renderer");
et(this, "textRenderer");
this.options = t || bs, this.options.renderer = this.options.renderer || new Ii(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new Aa();
}
/**
* Static Parse Method
*/
static parse(t, n) {
return new Ko(n).parse(t);
}
/**
* Static Parse Inline Method
*/
static parseInline(t, n) {
return new Ko(n).parseInline(t);
}
/**
* Parse Loop
*/
parse(t, n = !0) {
var r, i;
let s = "";
for (let o = 0; o < t.length; o++) {
const a = t[o];
if ((i = (r = this.options.extensions) == null ? void 0 : r.renderers) != null && i[a.type]) {
const d = a, c = this.options.extensions.renderers[d.type].call({ parser: this }, d);
if (c !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(d.type)) {
s += c || "";
continue;
}
}
const l = a;
switch (l.type) {
case "space": {
s += this.renderer.space(l);
continue;
}
case "hr": {
s += this.renderer.hr(l);
continue;
}
case "heading": {
s += this.renderer.heading(l);
continue;
}
case "code": {
s += this.renderer.code(l);
continue;
}
case "table": {
s += this.renderer.table(l);
continue;
}
case "blockquote": {
s += this.renderer.blockquote(l);
continue;
}
case "list": {
s += this.renderer.list(l);
continue;
}
case "html": {
s += this.renderer.html(l);
continue;
}
case "paragraph": {
s += this.renderer.paragraph(l);
continue;
}
case "text": {
let d = l, c = this.renderer.text(d);
for (; o + 1 < t.length && t[o + 1].type === "text"; )
d = t[++o], c += `
` + this.renderer.text(d);
n ? s += this.renderer.paragraph({
type: "paragraph",
raw: c,
text: c,
tokens: [{ type: "text", raw: c, text: c, escaped: !0 }]
}) : s += c;
continue;
}
default: {
const d = 'Token with "' + l.type + '" type was not found.';
if (this.options.silent)
return console.error(d), "";
throw new Error(d);
}
}
}
return s;
}
/**
* Parse Inline Tokens
*/
parseInline(t, n = this.renderer) {
var r, i;
let s = "";
for (let o = 0; o < t.length; o++) {
const a = t[o];
if ((i = (r = this.options.extensions) == null ? void 0 : r.renderers) != null && i[a.type]) {
const d = this.options.extensions.renderers[a.type].call({ parser: this }, a);
if (d !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(a.type)) {
s += d || "";
continue;
}
}
const l = a;
switch (l.type) {
case "escape": {
s += n.text(l);
break;
}
case "html": {
s += n.html(l);
break;
}
case "link": {
s += n.link(l);
break;
}
case "image": {
s += n.image(l);
break;
}
case "strong": {
s += n.strong(l);
break;
}
case "em": {
s += n.em(l);
break;
}
case "codespan": {
s += n.codespan(l);
break;
}
case "br": {
s += n.br(l);
break;
}
case "del": {
s += n.del(l);
break;
}
case "text": {
s += n.text(l);
break;
}
default: {
const d = 'Token with "' + l.type + '" type was not found.';
if (this.options.silent)
return console.error(d), "";
throw new Error(d);
}
}
}
return s;
}
}, Oo, ci = (Oo = class {
constructor(e) {
et(this, "options");
et(this, "block");
this.options = e || bs;
}
/**
* Process markdown before marked
*/
preprocess(e) {
return e;
}
/**
* Process HTML after marked is finished
*/
postprocess(e) {
return e;
}
/**
* Process all tokens before walk tokens
*/
processAllTokens(e) {
return e;
}
/**
* Provide function to tokenize markdown
*/
provideLexer() {
return this.block ? Dn.lex : Dn.lexInline;
}
/**
* Provide function to parse tokens
*/
provideParser() {
return this.block ? Pn.parse : Pn.parseInline;
}
}, et(Oo, "passThroughHooks", /* @__PURE__ */ new Set([
"preprocess",
"postprocess",
"processAllTokens"
])), Oo), _p = class {
constructor(...e) {
et(this, "defaults", _a());
et(this, "options", this.setOptions);
et(this, "parse", this.parseMarkdown(!0));
et(this, "parseInline", this.parseMarkdown(!1));
et(this, "Parser", Pn);
et(this, "Renderer", Ii);
et(this, "TextRenderer", Aa);
et(this, "Lexer", Dn);
et(this, "Tokenizer", Ri);
et(this, "Hooks", ci);
this.use(...e);
}
/**
* Run callback for every token
*/
walkTokens(e, t) {
var s, r;
let n = [];
for (const i of e)
switch (n = n.concat(t.call(this, i)), i.type) {
case "table": {
const o = i;
for (const a of o.header)
n = n.concat(this.walkTokens(a.tokens, t));
for (const a of o.rows)
for (const l of a)
n = n.concat(this.walkTokens(l.tokens, t));
break;
}
case "list": {
const o = i;
n = n.concat(this.walkTokens(o.items, t));
break;
}
default: {
const o = i;
(r = (s = this.defaults.extensions) == null ? void 0 : s.childTokens) != null && r[o.type] ? this.defaults.extensions.childTokens[o.type].forEach((a) => {
const l = o[a].flat(1 / 0);
n = n.concat(this.walkTokens(l, t));
}) : o.tokens && (n = n.concat(this.walkTokens(o.tokens, t)));
}
}
return n;
}
use(...e) {
const t = this.defaults.extensions || { renderers: {}, childTokens: {} };
return e.forEach((n) => {
const s = { ...n };
if (s.async = this.defaults.async || s.async || !1, n.extensions && (n.extensions.forEach((r) => {
if (!r.name)
throw new Error("extension name required");
if ("renderer" in r) {
const i = t.renderers[r.name];
i ? t.renderers[r.name] = function(...o) {
let a = r.renderer.apply(this, o);
return a === !1 && (a = i.apply(this, o)), a;
} : t.renderers[r.name] = r.renderer;
}
if ("tokenizer" in r) {
if (!r.level || r.level !== "block" && r.level !== "inline")
throw new Error("extension level must be 'block' or 'inline'");
const i = t[r.level];
i ? i.unshift(r.tokenizer) : t[r.level] = [r.tokenizer], r.start && (r.level === "block" ? t.startBlock ? t.startBlock.push(r.start) : t.startBlock = [r.start] : r.level === "inline" && (t.startInline ? t.startInline.push(r.start) : t.startInline = [r.start]));
}
"childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
}), s.extensions = t), n.renderer) {
const r = this.defaults.renderer || new Ii(this.defaults);
for (const i in n.renderer) {
if (!(i in r))
throw new Error(`renderer '${i}' does not exist`);
if (["options", "parser"].includes(i))
continue;
const o = i, a = n.renderer[o], l = r[o];
r[o] = (...d) => {
let c = a.apply(r, d);
return c === !1 && (c = l.apply(r, d)), c || "";
};
}
s.renderer = r;
}
if (n.tokenizer) {
const r = this.defaults.tokenizer || new Ri(this.defaults);
for (const i in n.tokenizer) {
if (!(i in r))
throw new Error(`tokenizer '${i}' does not exist`);
if (["options", "rules", "lexer"].includes(i))
continue;
const o = i, a = n.tokenizer[o], l = r[o];
r[o] = (...d) => {
let c = a.apply(r, d);
return c === !1 && (c = l.apply(r, d)), c;
};
}
s.tokenizer = r;
}
if (n.hooks) {
const r = this.defaults.hooks || new ci();
for (const i in n.hooks) {
if (!(i in r))
throw new Error(`hook '${i}' does not exist`);
if (["options", "block"].includes(i))
continue;
const o = i, a = n.hooks[o], l = r[o];
ci.passThroughHooks.has(i) ? r[o] = (d) => {
if (this.defaults.async)
return Promise.resolve(a.call(r, d)).then((b) => l.call(r, b));
const c = a.call(r, d);
return l.call(r, c);
} : r[o] = (...d) => {
let c = a.apply(r, d);
return c === !1 && (c = l.apply(r, d)), c;
};
}
s.hooks = r;
}
if (n.walkTokens) {
const r = this.defaults.walkTokens, i = n.walkTokens;
s.walkTokens = function(o) {
let a = [];
return a.push(i.call(this, o)), r && (a = a.concat(r.call(this, o))), a;
};
}
this.defaults = { ...this.defaults, ...s };
}), this;
}
setOptions(e) {
return this.defaults = { ...this.defaults, ...e }, this;
}
lexer(e, t) {
return Dn.lex(e, t ?? this.defaults);
}
parser(e, t) {
return Pn.parse(e, t ?? this.defaults);
}
parseMarkdown(e) {
return (n, s) => {
const r = { ...s }, i = { ...this.defaults, ...r }, o = this.onError(!!i.silent, !!i.async);
if (this.defaults.async === !0 && r.async === !1)
return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
if (typeof n > "u" || n === null)
return o(new Error("marked(): input parameter is undefined or null"));
if (typeof n != "string")
return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
i.hooks && (i.hooks.options = i, i.hooks.block = e);
const a = i.hooks ? i.hooks.provideLexer() : e ? Dn.lex : Dn.lexInline, l = i.hooks ? i.hooks.provideParser() : e ? Pn.parse : Pn.parseInline;
if (i.async)
return Promise.resolve(i.hooks ? i.hooks.preprocess(n) : n).then((d) => a(d, i)).then((d) => i.hooks ? i.hooks.processAllTokens(d) : d).then((d) => i.walkTokens ? Promise.all(this.walkTokens(d, i.walkTokens)).then(() => d) : d).then((d) => l(d, i)).then((d) => i.hooks ? i.hooks.postprocess(d) : d).catch(o);
try {
i.hooks && (n = i.hooks.preprocess(n));
let d = a(n, i);
i.hooks && (d = i.hooks.processAllTokens(d)), i.walkTokens && this.walkTokens(d, i.walkTokens);
let c = l(d, i);
return i.hooks && (c = i.hooks.postprocess(c)), c;
} catch (d) {
return o(d);
}
};
}
onError(e, t) {
return (n) => {
if (n.message += `
Please report this to https://github.com/markedjs/marked.`, e) {
const s = "<p>An error occurred:</p><pre>" + gn(n.message + "", !0) + "</pre>";
return t ? Promise.resolve(s) : s;
}
if (t)
return Promise.reject(n);
throw n;
};
}
}, vs = new _p();
function He(e, t) {
return vs.parse(e, t);
}
He.options = He.setOptions = function(e) {
return vs.setOptions(e), He.defaults = vs.defaults, gu(He.defaults), He;
};
He.getDefaults = _a;
He.defaults = bs;
He.use = function(...e) {
return vs.use(...e), He.defaults = vs.defaults, gu(He.defaults), He;
};
He.walkTokens = function(e, t) {
return vs.walkTokens(e, t);
};
He.parseInline = vs.parseInline;
He.Parser = Pn;
He.parser = Pn.parse;
He.Renderer = Ii;
He.TextRenderer = Aa;
He.Lexer = Dn;
He.lexer = Dn.lex;
He.Tokenizer = Ri;
He.Hooks = ci;
He.parse = He;
He.options;
He.setOptions;
He.use;
He.walkTokens;
He.parseInline;
Pn.parse;
Dn.lex;
/*! @license DOMPurify 3.4.15 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.15/LICENSE */
function Ol(e, t) {
(t == null || t > e.length) && (t = e.length);
for (var n = 0, s = Array(t); n < t; n++) s[n] = e[n];
return s;
}
function yp(e) {
if (Array.isArray(e)) return e;
}
function vp(e, t) {
var n = e == null ? null : typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
if (n != null) {
var s, r, i, o, a = [], l = !0, d = !1;
try {
if (i = (n = n.call(e)).next, t !== 0) for (; !(l = (s = i.call(n)).done) && (a.push(s.value), a.length !== t); l = !0) ;
} catch (c) {
d = !0, r = c;
} finally {
try {
if (!l && n.return != null && (o = n.return(), Object(o) !== o)) return;
} finally {
if (d) throw r;
}
}
return a;
}
}
function bp() {
throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function wp(e, t) {
return yp(e) || vp(e, t) || kp(e, t) || bp();
}
function kp(e, t) {
if (e) {
if (typeof e == "string") return Ol(e, t);
var n = {}.toString.call(e).slice(8, -1);
return n === "Object" && e.constructor && (n = e.constructor.name), n === "Map" || n === "Set" ? Array.from(e) : n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? Ol(e, t) : void 0;
}
}
const Eu = Object.entries, Nl = Object.setPrototypeOf, xp = Object.isFrozen, Tp = Object.getPrototypeOf, Ap = Object.getOwnPropertyDescriptor;
let bt = Object.freeze, Tt = Object.seal, Ns = Object.create, Su = typeof Reflect < "u" && Reflect, Go = Su.apply, Yo = Su.construct;
bt || (bt = function(t) {
return t;
});
Tt || (Tt = function(t) {
return t;
});
Go || (Go = function(t, n) {
for (var s = arguments.length, r = new Array(s > 2 ? s - 2 : 0), i = 2; i < s; i++)
r[i - 2] = arguments[i];
return t.apply(n, r);
});
Yo || (Yo = function(t) {
for (var n = arguments.length, s = new Array(n > 1 ? n - 1 : 0), r = 1; r < n; r++)
s[r - 1] = arguments[r];
return new t(...s);
});
const ms = _t(Array.prototype.forEach), Ep = _t(Array.prototype.lastIndexOf), Ml = _t(Array.prototype.pop), dr = _t(Array.prototype.push), Sp = _t(Array.prototype.splice), Us = Array.isArray, vr = _t(String.prototype.toLowerCase), vo = _t(String.prototype.toString), Dl = _t(String.prototype.match), pr = _t(String.prototype.replace), Pl = _t(String.prototype.indexOf), Cp = _t(String.prototype.trim), Rp = _t(Number.prototype.toString), Ip = _t(Boolean.prototype.toString), Fl = typeof BigInt > "u" ? null : _t(BigInt.prototype.toString), Bl = typeof Symbol > "u" ? null : _t(Symbol.prototype.toString), Wt = _t(Object.prototype.hasOwnProperty), gr = _t(Object.prototype.toString), Lt = _t(RegExp.prototype.test), ds = Lp(TypeError);
function _t(e) {
return function(t) {
t instanceof RegExp && (t.lastIndex = 0);
for (var n = arguments.length, s = new Array(n > 1 ? n - 1 : 0), r = 1; r < n; r++)
s[r - 1] = arguments[r];
return Go(e, t, s);
};
}
function Lp(e) {
return function() {
for (var t = arguments.length, n = new Array(t), s = 0; s < t; s++)
n[s] = arguments[s];
return Yo(e, n);
};
}
function Fe(e, t) {
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : vr;
if (Nl && Nl(e, null), !Us(t))
return e;
let s = t.length;
for (; s--; ) {
let r = t[s];
if (typeof r == "string") {
const i = n(r);
i !== r && (xp(t) || (t[s] = i), r = i);
}
e[r] = !0;
}
return e;
}
function Op(e) {
for (let t = 0; t < e.length; t++)
Wt(e, t) || (e[t] = null);
return e;
}
function Kt(e) {
const t = Ns(null);
for (const s of Eu(e)) {
var n = wp(s, 2);
const r = n[0], i = n[1];
Wt(e, r) && (Us(i) ? t[r] = Op(i) : i && typeof i == "object" && i.constructor === Object ? t[r] = Kt(i) : t[r] = i);
}
return t;
}
function Np(e) {
switch (typeof e) {
case "string":
return e;
case "number":
return Rp(e);
case "boolean":
return Ip(e);
case "bigint":
return Fl ? Fl(e) : "0";
case "symbol":
return Bl ? Bl(e) : "Symbol()";
case "undefined":
return gr(e);
case "function":
case "object": {
if (e === null)
return gr(e);
const t = e, n = en(t, "toString");
if (typeof n == "function") {
const s = n(t);
return typeof s == "string" ? s : gr(s);
}
return gr(e);
}
default:
return gr(e);
}
}
function en(e, t) {
for (; e !== null; ) {
const s = Ap(e, t);
if (s) {
if (s.get)
return _t(s.get);
if (typeof s.value == "function")
return _t(s.value);
}
e = Tp(e);
}
function n() {
return null;
}
return n;
}
function Mp(e) {
try {
return Lt(e, ""), !0;
} catch {
return !1;
}
}
const $l = bt(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), bo = bt(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), wo = bt(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), Dp = bt(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), ko = bt(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), Pp = bt(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), Ul = bt(["#text"]), zl = bt(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "command", "commandfor", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns"]), xo = bt(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dominant-baseline", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "pointer-events", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-orientation", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "vector-effect", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), Hl = bt(["accent", "accentunder", "align", "bevelled", "close", "columnalign", "columnlines", "columnspacing", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lquote", "lspace", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), ei = bt(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), Fp = Tt(/{{[\w\W]*|^[\w\W]*}}/g), Bp = Tt(/<%[\w\W]*|^[\w\W]*%>/g), $p = Tt(/\${[\w\W]*/g), Up = Tt(/^data-[\-\w.\u00B7-\uFFFF]+$/), zp = Tt(/^aria-[\-\w]+$/), Wl = Tt(
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
// eslint-disable-line no-useless-escape
), Hp = Tt(/^(?:\w+script|data):/i), Wp = Tt(
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
// eslint-disable-line no-control-regex
), qp = Tt(/^html$/i), jp = Tt(/^[a-z][.\w]*(-[.\w]+)+$/i), ql = Tt(/<[/\w!]/g), jl = Tt(/<[/\w]/g), Vp = Tt(/<\/no(script|embed|frames)/i), Kp = Tt(/\/>/i), jt = {
element: 1,
attribute: 2,
text: 3,
cdataSection: 4,
entityReference: 5,
// Deprecated
entityNode: 6,
// Deprecated
processingInstruction: 7,
comment: 8,
document: 9,
documentType: 10,
documentFragment: 11,
notation: 12
// Deprecated
}, Cu = ["style", "script", "xmp", "iframe", "noembed", "noframes", "plaintext", "noscript"], Gp = bt(Fe({}, Cu)), Yp = function() {
const e = {};
return ms(Cu, (t) => {
e[t] = Tt(new RegExp("</" + t + "(?=[\\t\\n\\f\\r />])", "i"));
}), bt(e);
}(), Zp = function() {
return typeof window > "u" ? null : window;
}, Xp = function(t, n) {
if (typeof t != "object" || typeof t.createPolicy != "function")
return null;
let s = null;
const r = "data-tt-policy-suffix";
n && n.hasAttribute(r) && (s = n.getAttribute(r));
const i = "dompurify" + (s ? "#" + s : "");
try {
return t.createPolicy(i, {
createHTML(o) {
return o;
},
createScriptURL(o) {
return o;
}
});
} catch {
return console.warn("TrustedTypes policy " + i + " could not be created."), null;
}
}, Vl = function() {
return {
afterSanitizeAttributes: [],
afterSanitizeElements: [],
afterSanitizeShadowDOM: [],
beforeSanitizeAttributes: [],
beforeSanitizeElements: [],
beforeSanitizeShadowDOM: [],
uponSanitizeAttribute: [],
uponSanitizeElement: [],
uponSanitizeShadowNode: []
};
}, Kn = function(t, n, s, r) {
return Wt(t, n) && Us(t[n]) ? Fe(r.base ? Kt(r.base) : {}, t[n], r.transform) : s;
}, To = function(t, n, s) {
const r = Wt(t, n) ? t[n] : void 0;
return r && typeof r == "object" ? Kt(r) : s();
};
function Ru() {
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Zp();
const t = (j) => Ru(j);
if (t.version = "3.4.15", t.removed = [], !e || !e.document || e.document.nodeType !== jt.document || !e.Element)
return t.isSupported = !1, t;
let n = e.document;
const s = n, r = s.currentScript;
e.DocumentFragment;
const i = e.HTMLTemplateElement, o = e.Node, a = e.Element, l = e.NodeFilter, d = e.NamedNodeMap;
d === void 0 && (e.NamedNodeMap || e.MozNamedAttrMap), e.HTMLFormElement;
const c = e.DOMParser, b = e.trustedTypes, w = a.prototype, z = en(w, "cloneNode"), I = en(w, "remove"), K = en(w, "removeAttributeNode"), P = en(w, "nextSibling"), oe = en(w, "childNodes"), fe = en(w, "parentNode"), pe = en(w, "shadowRoot"), R = en(w, "attributes"), N = o && o.prototype ? en(o.prototype, "nodeType") : null, Y = o && o.prototype ? en(o.prototype, "nodeName") : null, X = o && o.prototype ? en(o.prototype, "ownerDocument") : null, xe = function(p) {
return N ? N(p) : p.nodeType;
}, Oe = function(p) {
return Y ? Y(p) : p.nodeName;
};
if (typeof i == "function") {
const j = n.createElement("template");
j.content && j.content.ownerDocument && (n = j.content.ownerDocument);
}
let _e, Pe = "", be, Ke = !1, Ge = 0;
const at = function() {
if (Ge > 0)
throw ds('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.');
}, ue = function(p) {
at(), Ge++;
try {
return _e.createHTML(p);
} finally {
Ge--;
}
}, ye = function(p) {
at(), Ge++;
try {
return _e.createScriptURL(p);
} finally {
Ge--;
}
}, me = function() {
return Ke || (be = Xp(b, r), Ke = !0), be;
}, nt = n, Ze = nt.implementation, Te = nt.createNodeIterator, Je = nt.createDocumentFragment, st = nt.getElementsByTagName, At = s.importNode;
let Re = Vl();
t.isSupported = typeof Eu == "function" && typeof fe == "function" && Ze && Ze.createHTMLDocument !== void 0;
const yt = Fp, pt = Bp, Ct = $p, Rt = Up, Dt = zp, Yt = Hp, m = Wp, v = jp;
let C = Wl, M = null;
const B = Fe({}, [...$l, ...bo, ...wo, ...ko, ...Ul]);
let L = null;
const G = Fe({}, [...zl, ...xo, ...Hl, ...ei]);
let W = Object.seal(Ns(null, {
tagNameCheck: {
writable: !0,
configurable: !1,
enumerable: !0,
value: null
},
attributeNameCheck: {
writable: !0,
configurable: !1,
enumerable: !0,
value: null
},
allowCustomizedBuiltInElements: {
writable: !0,
configurable: !1,
enumerable: !0,
value: !1
}
})), q = null, U = null;
const te = Object.seal(Ns(null, {
tagCheck: {
writable: !0,
configurable: !1,
enumerable: !0,
value: null
},
attributeCheck: {
writable: !0,
configurable: !1,
enumerable: !0,
value: null
}
}));
let Z = !0, E = !0, O = !1, V = !0, J = !1, ae = !0, we = !1, Se = !1, De = null, f = null, y = !1, D = !1, x = !1, H = !1, ne = !0, ee = !1;
const Ie = "user-content-";
let Le = !0, Ce = !1, $e = {}, Xe = null;
const wt = Fe({}, [
"annotation-xml",
"audio",
"colgroup",
"desc",
"foreignobject",
"head",
"iframe",
"math",
"mi",
"mn",
"mo",
"ms",
"mtext",
"noembed",
"noframes",
"noscript",
"plaintext",
"script",
// <selectedcontent> mirrors the selected <option>'s subtree, cloned by
// the UA (customizable <select>) — including any on* handlers — and the
// engine re-mirrors synchronously whenever a removal changes which
// option/selectedcontent is current, even inside DOMPurify's inert
// DOMParser document. Hoisting its children on removal re-inserts a fresh
// mirror target ahead of the walk, which the engine refills, looping
// forever (DoS) and amplifying output. Dropping its content on removal
// (rather than hoisting) breaks that cascade; the content is a duplicate
// of the option, which is sanitized on its own. See campaign-3 F1/F6.
"selectedcontent",
"style",
"svg",
"template",
"thead",
"title",
"video",
"xmp"
]);
let on = null;
const kn = Fe({}, ["audio", "video", "img", "source", "image", "track"]);
let js = null;
const Vs = Fe({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), rs = "http://www.w3.org/1998/Math/MathML", is = "http://www.w3.org/2000/svg", qt = "http://www.w3.org/1999/xhtml";
let xn = qt, Ks = !1, os = null;
const ws = Fe({}, [rs, is, qt], vo), Gs = bt(["mi", "mo", "mn", "ms", "mtext"]);
let ks = Fe({}, Gs);
const Tn = bt(["annotation-xml"]);
let An = Fe({}, Tn);
const Ys = Fe({}, ["title", "style", "font", "a", "script"]);
let En = null;
const un = ["application/xhtml+xml", "text/html"], Br = "text/html";
let rt = null, Sn = null;
const Un = n.createElement("form"), $r = function(p) {
return p instanceof RegExp || p instanceof Function;
}, zn = function() {
let p = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
if (Sn && Sn === p)
return;
(!p || typeof p != "object") && (p = {}), p = Kt(p), En = // eslint-disable-next-line unicorn/prefer-includes
un.indexOf(p.PARSER_MEDIA_TYPE) === -1 ? Br : p.PARSER_MEDIA_TYPE, rt = En === "application/xhtml+xml" ? vo : vr, M = Kn(p, "ALLOWED_TAGS", B, {
transform: rt
}), L = Kn(p, "ALLOWED_ATTR", G, {
transform: rt
}), os = Kn(p, "ALLOWED_NAMESPACES", ws, {
transform: vo
}), js = Kn(p, "ADD_URI_SAFE_ATTR", Vs, {
transform: rt,
base: Vs
}), on = Kn(p, "ADD_DATA_URI_TAGS", kn, {
transform: rt,
base: kn
}), Xe = Kn(p, "FORBID_CONTENTS", wt, {
transform: rt
}), q = Kn(p, "FORBID_TAGS", Kt({}), {
transform: rt
}), U = Kn(p, "FORBID_ATTR", Kt({}), {
transform: rt
}), $e = Wt(p, "USE_PROFILES") ? p.USE_PROFILES && typeof p.USE_PROFILES == "object" ? Kt(p.USE_PROFILES) : p.USE_PROFILES : !1, Z = p.ALLOW_ARIA_ATTR !== !1, E = p.ALLOW_DATA_ATTR !== !1, O = p.ALLOW_UNKNOWN_PROTOCOLS || !1, V = p.ALLOW_SELF_CLOSE_IN_ATTR !== !1, J = p.SAFE_FOR_TEMPLATES || !1, ae = p.SAFE_FOR_XML !== !1, we = p.WHOLE_DOCUMENT || !1, D = p.RETURN_DOM || !1, x = p.RETURN_DOM_FRAGMENT || !1, H = p.RETURN_TRUSTED_TYPE || !1, y = p.FORCE_BODY || !1, ne = p.SANITIZE_DOM !== !1, ee = p.SANITIZE_NAMED_PROPS || !1, Le = p.KEEP_CONTENT !== !1, Ce = p.IN_PLACE || !1, C = Mp(p.ALLOWED_URI_REGEXP) ? p.ALLOWED_URI_REGEXP : Wl, xn = typeof p.NAMESPACE == "string" ? p.NAMESPACE : qt, ks = To(
p,
"MATHML_TEXT_INTEGRATION_POINTS",
() => Fe({}, Gs)
// Default built-in map
), An = To(
p,
"HTML_INTEGRATION_POINTS",
() => Fe({}, Tn)
// Default built-in map
);
const k = To(p, "CUSTOM_ELEMENT_HANDLING", () => Ns(null));
if (W = Ns(null), Wt(k, "tagNameCheck") && $r(k.tagNameCheck) && (W.tagNameCheck = k.tagNameCheck), Wt(k, "attributeNameCheck") && $r(k.attributeNameCheck) && (W.attributeNameCheck = k.attributeNameCheck), Wt(k, "allowCustomizedBuiltInElements") && typeof k.allowCustomizedBuiltInElements == "boolean" && (W.allowCustomizedBuiltInElements = k.allowCustomizedBuiltInElements), Tt(W), J && (E = !1), x && (D = !0), $e && (M = Fe({}, Ul), L = Ns(null), $e.html === !0 && (Fe(M, $l), Fe(L, zl)), $e.svg === !0 && (Fe(M, bo), Fe(L, xo), Fe(L, ei)), $e.svgFilters === !0 && (Fe(M, wo), Fe(L, xo), Fe(L, ei)), $e.mathMl === !0 && (Fe(M, ko), Fe(L, Hl), Fe(L, ei))), te.tagCheck = null, te.attributeCheck = null, Wt(p, "ADD_TAGS") && (typeof p.ADD_TAGS == "function" ? te.tagCheck = p.ADD_TAGS : Us(p.ADD_TAGS) && (M === B && (M = Kt(M)), Fe(M, p.ADD_TAGS, rt))), Wt(p, "ADD_ATTR") && (typeof p.ADD_ATTR == "function" ? te.attributeCheck = p.ADD_ATTR : Us(p.ADD_ATTR) && (L === G && (L = Kt(L)), Fe(L, p.ADD_ATTR, rt))), Wt(p, "ADD_FORBID_CONTENTS") && Us(p.ADD_FORBID_CONTENTS) && (Xe === wt && (Xe = Kt(Xe)), Fe(Xe, p.ADD_FORBID_CONTENTS, rt)), Le && (M["#text"] = !0), we && Fe(M, ["html", "head", "body"]), M.table && (Fe(M, ["tbody"]), delete q.tbody), p.TRUSTED_TYPES_POLICY) {
if (typeof p.TRUSTED_TYPES_POLICY.createHTML != "function")
throw ds('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
if (typeof p.TRUSTED_TYPES_POLICY.createScriptURL != "function")
throw ds('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
const $ = _e;
_e = p.TRUSTED_TYPES_POLICY;
try {
Pe = ue("");
} catch (Q) {
throw _e = $, Q;
}
} else p.TRUSTED_TYPES_POLICY === null ? (_e = void 0, Pe = "") : (_e === void 0 && (_e = me()), _e && typeof Pe == "string" && (Pe = ue("")));
bt && bt(p), Sn = p;
}, Zs = Fe({}, [...bo, ...wo, ...Dp]), Ur = Fe({}, [...ko, ...Pp]), zr = function(p, k, $) {
return k.namespaceURI === qt ? p === "svg" : k.namespaceURI === rs ? p === "svg" && ($ === "annotation-xml" || ks[$]) : !!Zs[p];
}, xs = function(p, k, $) {
return k.namespaceURI === qt ? p === "math" : k.namespaceURI === is ? p === "math" && An[$] : !!Ur[p];
}, Xs = function(p, k, $) {
return k.namespaceURI === is && !An[$] || k.namespaceURI === rs && !ks[$] ? !1 : !Ur[p] && (Ys[p] || !Zs[p]);
}, Zt = function(p) {
let k = fe(p);
(!k || !k.tagName) && (k = {
namespaceURI: xn,
tagName: "template"
});
const $ = vr(p.tagName), Q = vr(k.tagName);
return os[p.namespaceURI] ? p.namespaceURI === is ? zr($, k, Q) : p.namespaceURI === rs ? xs($, k, Q) : p.namespaceURI === qt ? Xs($, k, Q) : !!(En === "application/xhtml+xml" && os[p.namespaceURI]) : !1;
}, vt = function(p) {
dr(t.removed, {
element: p
});
try {
fe(p).removeChild(p);
} catch {
if (I(p), !fe(p))
throw ds("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
}
}, ft = function(p, k, $) {
try {
K(p, k);
} catch {
try {
p.removeAttribute($);
} catch {
}
}
}, ht = function(p) {
fn(p);
const k = oe(p);
if (k) {
const Q = [];
ms(k, (ie) => {
dr(Q, ie);
}), ms(Q, (ie) => {
try {
I(ie);
} catch {
}
});
}
const $ = R(p);
if ($)
for (let Q = $.length - 1; Q >= 0; --Q) {
const ie = $[Q], he = ie && ie.name;
typeof he == "string" && ft(p, ie, he);
}
}, Qe = function(p, k, $) {
if (!$)
try {
$ = k.getAttributeNode(p);
} catch {
$ = null;
}
dr(t.removed, {
attribute: $ || null,
from: k
});
try {
$ ? K(k, $) : k.removeAttribute(p);
} catch {
try {
k.removeAttribute(p);
} catch {
}
}
if (p === "is")
if (D || x)
try {
vt(k);
} catch {
}
else
try {
k.setAttribute(p, "");
} catch {
}
}, Cn = function(p) {
const k = R(p);
if (k)
for (let $ = k.length - 1; $ >= 0; --$) {
const Q = k[$], ie = Q && Q.name;
typeof ie != "string" || L[rt(ie)] || ft(p, Q, ie);
}
}, fn = function(p) {
const k = [p];
for (; k.length > 0; ) {
const $ = k.pop();
xe($) === jt.element && Cn($);
const ie = oe($);
if (ie)
for (let he = ie.length - 1; he >= 0; --he)
k.push(ie[he]);
}
}, Js = function(p, k) {
return ae ? p === "patchsrc" ? !0 : p === "for" && k !== "label" && k !== "output" : !1;
}, Rn = function(p) {
if (!ae)
return;
const k = [p];
for (; k.length > 0; ) {
const $ = k.pop(), Q = xe($);
if (Q === jt.processingInstruction || Q === jt.comment && Lt(jl, $.data)) {
try {
I($);
} catch {
}
continue;
}
if (Q === jt.element) {
const he = $, Ne = rt(Oe($));
try {
he.hasAttribute && he.hasAttribute("patchsrc") && he.removeAttribute("patchsrc"), he.hasAttribute && he.hasAttribute("for") && Js("for", Ne) && he.removeAttribute("for");
} catch {
}
}
const ie = oe($);
if (ie)
for (let he = ie.length - 1; he >= 0; --he)
k.push(ie[he]);
}
}, kt = function(p) {
let k = null, $ = null;
if (y)
p = "<remove></remove>" + p;
else {
const he = Dl(p, /^[\r\n\t ]+/);
$ = he && he[0];
}
En === "application/xhtml+xml" && xn === qt && (p = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + p + "</body></html>");
const Q = _e ? ue(p) : p;
if (xn === qt)
try {
k = new c().parseFromString(Q, En);
} catch {
}
if (!k || !k.documentElement) {
k = Ze.createDocument(xn, "template", null);
try {
k.documentElement.innerHTML = Ks ? Pe : Q;
} catch {
}
}
const ie = k.body || k.documentElement;
return p && $ && ie.insertBefore(n.createTextNode($), ie.childNodes[0] || null), xn === qt ? st.call(k, we ? "html" : "body")[0] : we ? k.documentElement : ie;
}, Hn = function(p) {
const k = X ? X(p) : p.ownerDocument;
return Te.call(
k || p,
p,
// eslint-disable-next-line no-bitwise
l.SHOW_ELEMENT | l.SHOW_COMMENT | l.SHOW_TEXT | l.SHOW_PROCESSING_INSTRUCTION | l.SHOW_CDATA_SECTION,
null
);
}, Xt = function(p) {
return p = pr(p, yt, " "), p = pr(p, pt, " "), p = pr(p, Ct, " "), p;
}, Qs = function(p) {
var k;
p.normalize();
const $ = X ? X(p) : p.ownerDocument, Q = Te.call(
$ || p,
p,
// eslint-disable-next-line no-bitwise
l.SHOW_TEXT | l.SHOW_COMMENT | l.SHOW_CDATA_SECTION | l.SHOW_PROCESSING_INSTRUCTION,
null
);
let ie = Q.nextNode();
for (; ie; )
ie.data = Xt(ie.data), ie = Q.nextNode();
const he = (k = p.querySelectorAll) === null || k === void 0 ? void 0 : k.call(p, "template");
he && ms(he, (Ne) => {
Wn(Ne.content) && Qs(Ne.content);
});
}, Ts = function(p) {
const k = Y ? Y(p) : null;
return typeof k != "string" || rt(k) !== "form" ? !1 : typeof p.nodeName != "string" || typeof p.textContent != "string" || typeof p.removeChild != "function" || // Realm-safe NamedNodeMap detection: equality against the cached
// prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
// makes the direct read diverge from the cached read; a clean form
// (same-realm OR foreign-realm) has both reads pointing at the same
// canonical NamedNodeMap.
p.attributes !== R(p) || typeof p.removeAttribute != "function" || // A form descendant named "removeAttributeNode" or "getAttributeNode"
// shadows these Attr-node methods via [LegacyOverrideBuiltIns].
// _removeAttribute() / _stripAttributeNode() reach for
// element.removeAttributeNode(attr) first; when it is shadowed the call
// throws and the name-based fallback element.removeAttribute(name)
// ASCII-lowercases its lookup key in an HTML document, silently missing
// a case-preserved event-handler attribute (e.g. an ONANIMATIONSTART
// that reached the sanitizer through an XML/XHTML parse). Flag the form
// so it is removed wholesale, exactly as for the other shadowed methods.
typeof p.removeAttributeNode != "function" || typeof p.getAttributeNode != "function" || typeof p.setAttribute != "function" || typeof p.namespaceURI != "string" || typeof p.insertBefore != "function" || typeof p.hasChildNodes != "function" || // NodeType clobbering probe. Cached Node.prototype.nodeType getter
// returns the integer 1 for any Element regardless of realm; direct
// read on a clobbered form (e.g. <input name="nodeType">) returns
// the named child element. Cheap addition — nodeType is read from
// an internal slot, no serialization cost — and removes a residual
// clobbering surface used by several mXSS / PI / comment branches
// in _sanitizeElements that compare currentNode.nodeType directly.
p.nodeType !== N(p) || // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
// "childNodes" shadows the prototype getter. Direct reads of
// form.childNodes from a clobbered form return the named child
// instead of the real NodeList, so any walk that reads it directly
// skips the form's real children. Compare the direct read to the
// cached Node.prototype getter — when the form's named-property
// getter intercepts the read, the two values differ and we flag
// the form. This catches every clobbering child type (input,
// select, etc.) regardless of whether the named child happens to
// carry a numeric .length, which a typeof-based probe would miss
// (e.g. HTMLSelectElement.length is a defined unsigned-long).
p.childNodes !== oe(p);
}, Wn = function(p) {
if (!N || typeof p != "object" || p === null)
return !1;
try {
return N(p) === jt.documentFragment;
} catch {
return !1;
}
}, as = function(p) {
if (!N || typeof p != "object" || p === null)
return !1;
try {
return typeof N(p) == "number";
} catch {
return !1;
}
};
function Jt(j, p, k) {
j.length !== 0 && ms(j, ($) => {
$.call(t, p, k, Sn);
});
}
const Xi = function(p, k) {
return !!(ae && p.hasChildNodes() && !as(p.firstElementChild) && Lt(ql, p.textContent) && Lt(ql, p.innerHTML) || ae && p.namespaceURI === qt && Gp[k] && (as(p.firstElementChild) || typeof p.textContent == "string" && Lt(Yp[k], p.textContent)) || p.nodeType === jt.processingInstruction || ae && p.nodeType === jt.comment && Lt(jl, p.data));
}, As = function(p, k) {
if (p instanceof RegExp)
return Lt(p, k);
if (p instanceof Function) {
for (var $ = arguments.length, Q = new Array($ > 2 ? $ - 2 : 0), ie = 2; ie < $; ie++)
Q[ie - 2] = arguments[ie];
return !!p(k, ...Q);
}
return !1;
}, It = function(p, k, $) {
if (!q[k] && er(k) && As(W.tagNameCheck, k))
return !1;
if (Le && !Xe[k]) {
const Q = fe(p), ie = oe(p);
if (ie && Q) {
const he = ie.length;
for (let Ne = he - 1; Ne >= 0; --Ne) {
const Be = p === $ ? z(ie[Ne], !0) : ie[Ne];
Q.insertBefore(Be, P(p));
}
}
}
return vt(p), !0;
}, Hr = function(p, k, $, Q) {
return p.length === 0 ? k : k === $ || k === Q ? Kt(k) : k;
}, Es = function(p, k) {
return p === k || fe(p) !== null ? !1 : (Ce && fn(p), !0);
}, Wr = function(p, k) {
if (Jt(Re.beforeSanitizeElements, p, null), Es(p, k))
return !0;
if (Ts(p))
return vt(p), !0;
const $ = rt(Oe(p));
if (M = Hr(Re.uponSanitizeElement, M, B, De), Jt(Re.uponSanitizeElement, p, {
tagName: $,
allowedTags: M
}), Es(p, k))
return !0;
if (Xi(p, $))
return vt(p), !0;
if (q[$] || !(te.tagCheck instanceof Function && te.tagCheck($)) && !M[$]) {
const ie = It(p, $, k);
return ie === !1 && Jt(Re.afterSanitizeElements, p, null), ie;
}
if (xe(p) === jt.element && !Zt(p) || ($ === "noscript" || $ === "noembed" || $ === "noframes") && Lt(Vp, p.innerHTML))
return vt(p), !0;
if (J && p.nodeType === jt.text) {
const ie = Xt(p.textContent);
p.textContent !== ie && (dr(t.removed, {
element: p.cloneNode()
}), p.textContent = ie);
}
return Jt(Re.afterSanitizeElements, p, null), !1;
}, qr = function(p, k, $) {
if (U[k] || Js(k, p) || ne && (k === "id" || k === "name") && ($ in n || $ in Un))
return !1;
const Q = L[k] || te.attributeCheck instanceof Function && te.attributeCheck(k, p);
return E && Lt(Rt, k) || Z && Lt(Dt, k) ? !0 : Q ? js[k] || Lt(C, pr($, m, "")) || (k === "src" || k === "xlink:href" || k === "href") && p !== "script" && Pl($, "data:") === 0 && on[p] || O && !Lt(Yt, pr($, m, "")) ? !0 : !$ : (
// Condition a) covers a basically valid custom element tag name whose
// tag passes the configured tagNameCheck and whose attribute name
// passes the configured attributeNameCheck ...
er(p) && As(W.tagNameCheck, p) && As(W.attributeNameCheck, k, p) || // Condition b) covers an `is` attribute whose value passes the
// configured tagNameCheck while customized built-in elements are
// allowed.
k === "is" && W.allowCustomizedBuiltInElements && As(W.tagNameCheck, $)
);
}, Ji = Fe({}, ["annotation-xml", "color-profile", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "missing-glyph"]), er = function(p) {
return !Ji[vr(p)] && Lt(v, p);
}, tr = function(p, k, $, Q) {
if (_e && typeof b == "object" && typeof b.getAttributeType == "function" && !$)
switch (b.getAttributeType(p, k)) {
case "TrustedHTML":
return ue(Q);
case "TrustedScriptURL":
return ye(Q);
}
return Q;
}, jr = function(p, k, $, Q) {
try {
return $ ? p.setAttributeNS($, k, Q) : p.setAttribute(k, Q), Ts(p) ? (vt(p), !1) : !0;
} catch {
return Qe(k, p), !1;
}
}, Vr = function(p) {
Jt(Re.beforeSanitizeAttributes, p, null);
const k = p.attributes;
if (!k || Ts(p))
return;
L = Hr(Re.uponSanitizeAttribute, L, G, f);
const $ = {
attrName: "",
attrValue: "",
keepAttr: !0,
allowedAttributes: L,
forceKeepAttr: void 0
};
let Q = k.length;
const ie = rt(p.nodeName);
for (; Q--; ) {
const he = k[Q], Ne = he.name, Be = he.namespaceURI, lt = he.value, dt = rt(Ne), hn = lt;
let xt = Ne === "value" ? hn : Cp(hn), nr = !1;
if ($.attrName = dt, $.attrValue = xt, $.keepAttr = !0, $.forceKeepAttr = void 0, Jt(Re.uponSanitizeAttribute, p, $), xt = $.attrValue, ee && (dt === "id" || dt === "name") && Pl(xt, Ie) !== 0 && (Qe(Ne, p, he), xt = Ie + xt, nr = !0), ae && Lt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, xt)) {
Qe(Ne, p, he);
continue;
}
if (dt === "attributename" && Dl(xt, "href")) {
Qe(Ne, p, he);
continue;
}
if (!$.forceKeepAttr) {
if (!$.keepAttr) {
Qe(Ne, p, he);
continue;
}
if (!V && Lt(Kp, xt)) {
Qe(Ne, p, he);
continue;
}
if (J && (xt = Xt(xt)), !qr(ie, dt, xt)) {
Qe(Ne, p, he);
continue;
}
xt = tr(ie, dt, Be, xt), xt !== hn && jr(p, Ne, Be, xt) && nr && Ml(t.removed);
}
}
Jt(Re.afterSanitizeAttributes, p, null);
}, Ss = function(p) {
let k = null;
const $ = Hn(p);
for (Jt(Re.beforeSanitizeShadowDOM, p, null); k = $.nextNode(); )
if (Jt(Re.uponSanitizeShadowNode, k, null), Wr(k, p), Vr(k), Wn(k.content) && Ss(k.content), xe(k) === jt.element) {
const Q = pe(k);
Wn(Q) && (ls(Q), Ss(Q));
}
Jt(Re.afterSanitizeShadowDOM, p, null);
}, ls = function(p) {
const k = [{
node: p,
shadow: null
}];
for (; k.length > 0; ) {
const $ = k.pop();
if ($.shadow) {
Ss($.shadow);
continue;
}
const Q = $.node, he = xe(Q) === jt.element, Ne = oe(Q);
if (Ne)
for (let Be = Ne.length - 1; Be >= 0; --Be)
k.push({
node: Ne[Be],
shadow: null
});
if (he) {
const Be = Y ? Y(Q) : null;
if (typeof Be == "string" && rt(Be) === "template") {
const lt = Q.content;
Wn(lt) && k.push({
node: lt,
shadow: null
});
}
}
if (he) {
const Be = pe(Q);
Wn(Be) && k.push({
node: null,
shadow: Be
}, {
node: Be,
shadow: null
});
}
}
};
return t.sanitize = function(j) {
let p = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, k = null, $ = null, Q = null, ie = null;
if (Ks = !j, Ks && (j = "<!-->"), typeof j != "string" && !as(j) && (j = Np(j), typeof j != "string"))
throw ds("dirty is not a string, aborting");
if (!t.isSupported)
return j;
Se ? (M = De, L = f) : zn(p), (Re.uponSanitizeElement.length > 0 || Re.uponSanitizeAttribute.length > 0) && (M = Kt(M)), Re.uponSanitizeAttribute.length > 0 && (L = Kt(L)), t.removed = [];
const he = Ce && typeof j != "string" && as(j);
if (he) {
Rn(j);
const lt = Oe(j);
if (typeof lt == "string") {
const dt = rt(lt);
if (!M[dt] || q[dt])
throw ht(j), ds("root node is forbidden and cannot be sanitized in-place");
}
if (Ts(j))
throw ht(j), ds("root node is clobbered and cannot be sanitized in-place");
try {
ls(j);
} catch (dt) {
throw ht(j), dt;
}
} else if (as(j))
k = kt("<!---->"), $ = k.ownerDocument.importNode(j, !0), $.nodeType === jt.element && $.nodeName === "BODY" || $.nodeName === "HTML" ? k = $ : k.appendChild($), ls(k);
else {
if (!D && !J && !we && // eslint-disable-next-line unicorn/prefer-includes
j.indexOf("<") === -1)
return _e && H ? ue(j) : j;
if (k = kt(j), !k)
return D ? null : H ? Pe : "";
}
k && y && vt(k.firstChild);
const Ne = he ? j : k;
try {
const lt = Hn(Ne);
for (; Q = lt.nextNode(); )
Wr(Q, Ne), Vr(Q), Wn(Q.content) && Ss(Q.content);
} catch (lt) {
throw he && (ht(j), ms(t.removed, (dt) => {
dt.element && fn(dt.element);
})), lt;
}
if (he)
return ms(t.removed, (lt) => {
lt.element && fn(lt.element);
}), J && Qs(j), j;
if (D) {
if (J && Qs(k), x)
for (ie = Je.call(k.ownerDocument); k.firstChild; )
ie.appendChild(k.firstChild);
else
ie = k;
return (L.shadowroot || L.shadowrootmode) && (ie = At.call(s, ie, !0)), ie;
}
let Be = we ? k.outerHTML : k.innerHTML;
return we && M["!doctype"] && k.ownerDocument && k.ownerDocument.doctype && k.ownerDocument.doctype.name && Lt(qp, k.ownerDocument.doctype.name) && (Be = "<!DOCTYPE " + k.ownerDocument.doctype.name + `>
` + Be), J && (Be = Xt(Be)), _e && H ? ue(Be) : Be;
}, t.setConfig = function() {
let j = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
zn(j), Se = !0, De = M, f = L;
}, t.clearConfig = function() {
Sn = null, Se = !1, De = null, f = null, _e = be, Pe = "";
}, t.isValidAttribute = function(j, p, k) {
Sn || zn({});
const $ = rt(j), Q = rt(p);
return qr($, Q, k);
}, t.addHook = function(j, p) {
typeof p == "function" && Wt(Re, j) && dr(Re[j], p);
}, t.removeHook = function(j, p) {
if (Wt(Re, j)) {
if (p !== void 0) {
const k = Ep(Re[j], p);
return k === -1 ? void 0 : Sp(Re[j], k, 1)[0];
}
return Ml(Re[j]);
}
}, t.removeHooks = function(j) {
Wt(Re, j) && (Re[j] = []);
}, t.removeAllHooks = function() {
Re = Vl();
}, t;
}
var Ea = Ru();
Ea.addHook("uponSanitizeElement", (e, t) => {
var r, i, o, a, l;
if (t.tagName === "svg") {
(r = e.parentNode) == null || r.removeChild(e);
return;
}
if (t.tagName === "math") {
(i = e.parentNode) == null || i.removeChild(e);
return;
}
if (t.tagName === "foreignobject") {
(o = e.parentNode) == null || o.removeChild(e);
return;
}
const n = e, s = (a = t.tagName) == null ? void 0 : a.toUpperCase();
(s === "IMG" || s === "AREA" || s === "MAP") && ((l = n.parentNode) == null || l.removeChild(n));
});
Ea.addHook("afterSanitizeAttributes", (e) => {
if (e.hasAttribute("href")) {
const t = e.getAttribute("href") || "";
try {
const n = decodeURIComponent(t.toLowerCase());
(n.includes("javascript:") || n.includes("data:text/html") || n.includes("vbscript:") || n.includes("about:") || n.includes("file:")) && e.removeAttribute("href");
} catch {
(t.toLowerCase().includes("javascript:") || t.toLowerCase().includes("data:text/html") || t.toLowerCase().includes("vbscript:") || t.toLowerCase().includes("about:") || t.toLowerCase().includes("file:")) && e.removeAttribute("href");
}
}
if (e.nodeName === "A") {
const t = (e.getAttribute("href") || "").trim();
/^(https?:|mailto:)/i.test(t) ? (e.setAttribute("target", "_blank"), e.setAttribute("rel", "noopener noreferrer nofollow")) : e.removeAttribute("href");
}
if (e.hasAttribute("src")) {
const t = e.getAttribute("src") || "";
try {
const n = decodeURIComponent(t.toLowerCase());
(n.includes("javascript:") || n.includes("data:text/html") || n.includes("vbscript:") || n.includes("about:") || n.includes("file:")) && e.removeAttribute("src");
} catch {
(t.toLowerCase().includes("javascript:") || t.toLowerCase().includes("data:text/html") || t.toLowerCase().includes("vbscript:") || t.toLowerCase().includes("about:") || t.toLowerCase().includes("file:")) && e.removeAttribute("src");
}
}
if (e.hasAttribute("style")) {
const t = e.getAttribute("style") || "";
try {
const n = decodeURIComponent(t.toLowerCase());
(n.includes("expression(") || n.includes("behavior:") || n.includes("-moz-binding") || n.includes("import") || n.includes("javascript:") || n.includes("vbscript:")) && e.removeAttribute("style");
} catch {
(t.toLowerCase().includes("expression(") || t.toLowerCase().includes("behavior:") || t.toLowerCase().includes("-moz-binding") || t.toLowerCase().includes("import") || t.toLowerCase().includes("javascript:") || t.toLowerCase().includes("vbscript:")) && e.removeAttribute("style");
}
}
Array.from(e.attributes).forEach((t) => {
t.name.toLowerCase().startsWith("on") && e.removeAttribute(t.name);
});
});
function Jp(e) {
const t = {
// Block all dangerous tags including SVG, form elements and images.
// NOTE: 'a' must NOT be in this list — FORBID_TAGS beats ALLOWED_TAGS, and
// anchors are intentionally kept (markdown links) then hardened by the
// afterSanitizeAttributes hook (http(s)/mailto only, forced target+rel).
FORBID_TAGS: [
"iframe",
"frame",
"frameset",
"object",
"embed",
"applet",
"script",
"base",
"link",
"meta",
"style",
"svg",
"math",
"form",
"input",
"button",
"textarea",
"select",
"option",
"xml",
"xss",
"import",
"video",
"audio",
"track",
"source",
"canvas",
"details",
"template",
"slot",
"noscript",
"marquee",
"bgsound",
"keygen",
"command",
"img",
"area",
"map"
// SECURITY: Remove image/map tags completely
],
// Block dangerous attributes
FORBID_ATTR: [
// Event handlers
"onerror",
"onload",
"onclick",
"onmouseover",
"onmouseout",
"onmousemove",
"onkeydown",
"onkeyup",
"onkeypress",
"onfocus",
"onblur",
"onchange",
"onsubmit",
"ondblclick",
"oncontextmenu",
"oninput",
"oninvalid",
"onreset",
"onsearch",
"onselect",
"onabort",
"oncanplay",
"oncanplaythrough",
"oncuechange",
"ondurationchange",
"onemptied",
"onended",
"onloadeddata",
"onloadedmetadata",
"onloadstart",
"onpause",
"onplay",
"onplaying",
"onprogress",
"onratechange",
"onseeked",
"onseeking",
"onstalled",
"onsuspend",
"ontimeupdate",
"onvolumechange",
"onwaiting",
"ontoggle",
"onauxclick",
"ongotpointercapture",
"onlostpointercapture",
"onpointercancel",
"onpointerdown",
"onpointerenter",
"onpointerleave",
"onpointermove",
"onpointerout",
"onpointerover",
"onpointerup",
"onwheel",
"onanimationcancel",
"onanimationend",
"onanimationiteration",
"onanimationstart",
"ontransitioncancel",
"ontransitionend",
"ontransitionrun",
"ontransitionstart",
"ondrag",
"ondragend",
"ondragenter",
"ondragleave",
"ondragover",
"ondragstart",
"ondrop",
"oncopy",
"oncut",
"onpaste",
"onscroll",
"onmessage",
"onmouseenter",
"onmouseleave",
"onmousewheel",
"onbeforeunload",
"onerrorupdate",
"onhelp",
"onmove",
"onreadystatechange",
"onresize",
"onstart",
"onstop",
"onunload",
"onactivate",
"onafterprint",
"onafterupdate",
"onbeforeactivate",
"onbeforecopy",
"onbeforecut",
"onbeforedeactivate",
"onbeforeeditfocus",
"onbeforepaste",
"onbeforeprint",
"onbeforeupdate",
"onbounce",
"oncellchange",
"oncontrolselect",
"ondataavailable",
"ondatasetchanged",
"ondatasetcomplete",
"ondeactivate",
"onfilterchange",
"onfinish",
"onfocusin",
"onfocusout",
"onlayoutcomplete",
"onlosecapture",
"onmoveend",
"onmovestart",
"onpropertychange",
"onresizeend",
"onresizestart",
"onrowenter",
"onrowexit",
"onrowsdelete",
"onrowsinserted",
"onselectionchange",
"onselectstart",
"onshow",
"onsort",
"onpointerrawupdate",
// Dangerous attributes
"formaction",
"action",
"form",
"srcdoc",
"srcset",
"dynsrc",
"lowsrc",
"ping",
"poster",
"background",
"code",
"codebase",
"archive",
"profile",
"xmlns",
"xlink:href",
"attributename",
"from",
"to",
"values",
"begin",
"autofocus",
"autoplay",
"controls",
"manifest",
"sandbox",
// SECURITY: block resource-loading attributes. 'href' is intentionally NOT
// here (FORBID_ATTR beats ALLOWED_ATTR): markdown links need it, and the
// afterSanitizeAttributes hook strips any href that isn't http(s)/mailto.
"src",
"data"
],
// Only allow safe protocols
ALLOWED_URI_REGEXP: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,
// SECURITY: Strip ALL HTML tags to prevent rendering exploits
// Only allow basic text formatting for markdown (no links, images, or any potentially dangerous tags)
ALLOWED_TAGS: [
"a",
"b",
"i",
"u",
"strong",
"em",
"p",
"br",
"ul",
"ol",
"li",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"blockquote",
"code",
"pre",
"table",
"thead",
"tbody",
"tr",
"th",
"td",
"span",
"div",
"del",
"hr",
"sup",
"sub",
"abbr",
"cite",
"dfn",
"kbd",
"mark",
"q",
"samp",
"small",
"time",
"var"
],
// Allow safe link attributes only (href is protocol-restricted + target/rel are
// forced by the afterSanitizeAttributes hook above). No src or resource-loading attrs.
ALLOWED_ATTR: [
"href",
"target",
"rel",
"title",
"class",
"id",
"align",
"colspan",
"rowspan"
],
// Return a string instead of a document
RETURN_DOM: !1,
RETURN_DOM_FRAGMENT: !1,
// Keep HTML comments removed
ALLOW_DATA_ATTR: !1
// NOTE: do NOT set USE_PROFILES here — it overrides ALLOWED_TAGS/ALLOWED_ATTR,
// which would drop the <a> tags we explicitly allow above. The explicit
// ALLOWED_TAGS/ALLOWED_ATTR allowlist is authoritative; protocols are still
// restricted by the afterSanitizeAttributes hook (href → http/https/mailto only).
};
return Ea.sanitize(e, t);
}
He.setOptions({
renderer: new He.Renderer(),
gfm: !0,
breaks: !0
});
const ui = (e) => Jp(He(e || "")), Qp = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2064%2048'%20fill='none'%3e%3cpath%20d='M29%2020%2039%206%2042%2021Z'%20fill='%23568B73'/%3e%3cpath%20d='M4%2016%2032%2026%2023%2043H15Z'%20fill='%232E6A5C'/%3e%3cpath%20d='M35%2026%2060%2016%2049%2043H27Z'%20fill='%238BB49C'/%3e%3c/svg%3e", eg = ["src", "width", "height"], tg = /* @__PURE__ */ Ui({
__name: "BrandMark",
props: {
size: { default: 20 }
},
setup(e) {
return (t, n) => (T(), A("img", {
src: S(Qp),
width: t.size,
height: t.size,
alt: "",
"aria-hidden": "true"
}, null, 8, eg));
}
}), Gi = (e, t) => {
const n = e.__vccOpts || e;
for (const [s, r] of t)
n[s] = r;
return n;
}, mr = /* @__PURE__ */ Gi(tg, [["__scopeId", "data-v-a09f9aae"]]), Kl = "*", ng = /* @__PURE__ */ new Set(["null", "about:blank", ""]);
let pn = null;
const fi = (e) => e && !ng.has(e) ? e : null, sg = (e) => {
if (!e) return null;
try {
return fi(new URL(e).origin);
} catch {
return null;
}
};
function rg() {
if (pn) return pn;
if (window.parent === window)
return pn = fi(window.location.origin) || Kl, pn;
try {
const e = fi(window.parent.location.origin);
if (e)
return pn = e, pn;
} catch {
}
try {
const e = window.location.ancestorOrigins, t = e && e.length ? fi(e[0]) : null;
if (t)
return pn = t, pn;
} catch {
}
return pn = sg(document.referrer) || Kl, pn;
}
function Zn(e) {
window.parent.postMessage(e, rg());
}
const Li = "开始新会话", Gl = "开始新会话?当前会话将结束。", ig = "开始新会话", og = "取消", Yl = "无法开始新会话,请重试。", ag = 15e3, lg = ["aria-label"], cg = { class: "new-chat-confirm__question" }, ug = { class: "new-chat-confirm__actions" }, fg = ["disabled"], hg = ["disabled"], dg = /* @__PURE__ */ Ui({
__name: "NewChatConfirm",
props: {
error: {},
busy: { type: Boolean }
},
emits: ["confirm", "cancel"],
setup(e, { emit: t }) {
const n = t;
return (s, r) => (T(), A("div", {
class: "new-chat-confirm",
role: "alertdialog",
"aria-live": "polite",
"aria-label": S(Gl)
}, [
_("p", cg, se(s.error || S(Gl)), 1),
_("div", ug, [
_("button", {
type: "button",
class: "new-chat-confirm__button",
disabled: s.busy,
onClick: r[0] || (r[0] = (i) => n("cancel"))
}, se(S(og)), 9, fg),
_("button", {
type: "button",
class: "new-chat-confirm__button new-chat-confirm__button--primary",
disabled: s.busy,
onClick: r[1] || (r[1] = (i) => n("confirm"))
}, se(S(ig)), 9, hg)
])
], 8, lg));
}
}), Iu = /* @__PURE__ */ Gi(dg, [["__scopeId", "data-v-080bebfe"]]), pg = { class: "askai" }, gg = { class: "askai__bar" }, mg = ["value", "placeholder", "disabled", "aria-label", "onKeydown"], _g = ["disabled", "title", "aria-label", "aria-expanded"], yg = { class: "askai__intro" }, vg = { class: "askai__title" }, bg = {
key: 0,
class: "askai__subtitle"
}, wg = {
key: 0,
class: "askai__suggestions"
}, kg = ["disabled", "onClick"], xg = ["aria-live"], Tg = {
key: 0,
class: "askai__question"
}, Ag = {
key: 1,
class: "askai__system"
}, Eg = ["innerHTML"], Sg = {
key: 0,
class: "askai__sources"
}, Cg = ["title"], Rg = {
key: 0,
class: "askai__thinking",
role: "status",
"aria-live": "polite"
}, Ig = { class: "askai__thinking-text" }, Lg = { class: "askai__foot" }, Og = { key: 0 }, Ng = /* @__PURE__ */ Ui({
__name: "AskAiPanel",
props: {
messages: {},
draft: {},
agentName: {},
suggestions: {},
welcomeTitle: {},
welcomeSubtitle: {},
placeholder: {},
inputEnabled: { type: Boolean },
typingEnabled: { type: Boolean },
loading: { type: Boolean },
showCitations: { type: Boolean },
disclaimer: {},
active: { type: Boolean },
hotkey: { type: Boolean },
citationLabel: { type: Function },
citationTooltip: { type: Function },
displayText: { type: Function },
isStreaming: { type: Function },
canStartNewChat: { type: Boolean },
startingNewChat: { type: Boolean },
newChatArmed: { type: Boolean },
newChatError: {}
},
emits: ["update:draft", "send", "ask", "close", "newChat", "confirmNewChat", "cancelNewChat"],
setup(e, { emit: t }) {
const n = e, s = t, r = ce(null), i = ce(null), o = ce(null), a = ["user", "bot", "agent", "system"], l = de(
() => n.messages.map((R, N) => ({ message: R, index: N })).filter(({ message: R }) => a.includes(R.message_type))
), d = de(() => l.value.length > 0), c = (R) => {
s("update:draft", R.target.value);
}, b = () => {
!(n.typingEnabled ?? n.inputEnabled) || !n.draft.trim() || s("send");
}, w = (R) => {
n.inputEnabled && s("ask", R);
}, z = typeof navigator < "u" && /Mac|iPod|iPhone|iPad/.test(navigator.platform || ""), I = (R) => {
if (R.key === "Escape") {
R.preventDefault(), s("close");
return;
}
const N = z ? R.metaKey && !R.ctrlKey : R.ctrlKey && !R.metaKey;
n.hotkey && N && !R.altKey && (R.key === "k" || R.key === "K") && (R.preventDefault(), s("close"));
}, K = () => {
ys(() => {
var R;
return (R = r.value) == null ? void 0 : R.focus();
});
};
let P = 0;
const oe = () => {
if (!o.value) return;
const R = o.value.closest(".askai"), N = i.value;
if (!R || !N) return;
const Y = R.offsetHeight - N.offsetHeight, X = getComputedStyle(N), xe = parseFloat(X.paddingTop) + parseFloat(X.paddingBottom), Oe = Math.ceil(Y + xe + o.value.getBoundingClientRect().height);
Math.abs(Oe - P) < 3 || (P = Oe, Zn({ type: "WIDGET_RESIZE", height: Oe }));
};
let fe = null;
const pe = de(
() => l.value.reduce((R, { message: N, index: Y }) => R + n.displayText(Y, N.message || "").length, 0)
);
return Ft(
() => [l.value.length, pe.value, n.loading],
() => ys(() => {
i.value && (i.value.scrollTop = i.value.scrollHeight);
})
), Ft(() => n.newChatArmed, () => ys(() => oe())), Ft(() => n.active, (R) => {
R && K();
}), Hi(() => {
n.active && K(), window.addEventListener("keydown", I), o.value && typeof ResizeObserver < "u" && (fe = new ResizeObserver(() => oe()), fe.observe(o.value)), oe();
}), qc(() => {
window.removeEventListener("keydown", I), fe == null || fe.disconnect(), fe = null;
}), (R, N) => (T(), A("div", pg, [
_("div", gg, [
N[6] || (N[6] = _("svg", {
class: "askai__bar-icon",
width: "18",
height: "18",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
"stroke-width": "1.8",
"stroke-linecap": "round",
"stroke-linejoin": "round",
"aria-hidden": "true"
}, [
_("path", { d: "M12 3l1.9 4.9L19 9.8l-4.9 1.9L12 17l-1.9-5.3L5 9.8l5.1-1.9L12 3z" })
], -1)),
_("input", {
ref_key: "inputEl",
ref: r,
type: "text",
class: "askai__input",
value: R.draft,
placeholder: R.placeholder,
disabled: !(R.typingEnabled ?? R.inputEnabled),
"aria-label": R.placeholder,
autocomplete: "off",
spellcheck: "false",
onInput: c,
onKeydown: li(gs(b, ["prevent"]), ["enter"])
}, null, 40, mg),
R.canStartNewChat ? (T(), A("button", {
key: 0,
type: "button",
class: Ue(["askai__new", { "askai__new--armed": R.newChatArmed }]),
disabled: R.startingNewChat,
title: S(Li),
"aria-label": S(Li),
"aria-expanded": R.newChatArmed,
onClick: N[0] || (N[0] = (Y) => s("newChat"))
}, N[4] || (N[4] = [
_("svg", {
width: "15",
height: "15",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
"stroke-width": "2",
"stroke-linecap": "round",
"stroke-linejoin": "round",
"aria-hidden": "true"
}, [
_("path", { d: "M12 20h9" }),
_("path", { d: "M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z" })
], -1)
]), 10, _g)) : le("", !0),
_("button", {
type: "button",
class: "askai__close",
"aria-label": "关闭",
title: "关闭(Esc)",
onClick: N[1] || (N[1] = (Y) => s("close"))
}, N[5] || (N[5] = [
_("span", { class: "askai__kbd" }, "Esc", -1)
]))
]),
R.newChatArmed && R.canStartNewChat ? (T(), Ai(Iu, {
key: 0,
busy: R.startingNewChat,
error: R.newChatError,
onConfirm: N[2] || (N[2] = (Y) => s("confirmNewChat")),
onCancel: N[3] || (N[3] = (Y) => s("cancelNewChat"))
}, null, 8, ["busy", "error"])) : le("", !0),
_("div", {
ref_key: "bodyEl",
ref: i,
class: "askai__body"
}, [
_("div", {
ref_key: "contentEl",
ref: o,
class: "askai__content"
}, [
d.value ? (T(), A(ze, { key: 1 }, [
(T(!0), A(ze, null, Et(l.value, ({ message: Y, index: X }) => (T(), A("div", {
key: X,
class: "askai__turn",
"aria-live": R.isStreaming(X) ? "off" : "polite"
}, [
Y.message_type === "user" ? (T(), A("p", Tg, se(Y.message), 1)) : Y.message_type === "system" ? (T(), A("p", Ag, se(Y.message), 1)) : (T(), A(ze, { key: 2 }, [
_("div", {
class: Ue(["askai__answer", { "askai__answer--streaming": R.isStreaming(X) }]),
innerHTML: S(ui)(R.isStreaming(X) ? R.displayText(X, Y.message || "") : Y.message || "")
}, null, 10, Eg),
R.showCitations && !R.isStreaming(X) && Y.sources && Y.sources.length ? (T(), A("div", Sg, [
N[9] || (N[9] = _("span", { class: "askai__label" }, "参考来源", -1)),
(T(!0), A(ze, null, Et(Y.sources, (xe, Oe) => (T(), A("span", {
key: Oe,
class: "askai__source",
title: R.citationTooltip(xe)
}, se(R.citationLabel(xe)), 9, Cg))), 128))
])) : le("", !0)
], 64))
], 8, xg))), 128)),
R.loading ? (T(), A("div", Rg, [
N[10] || (N[10] = _("span", { class: "askai__dot" }, null, -1)),
N[11] || (N[11] = _("span", { class: "askai__dot" }, null, -1)),
N[12] || (N[12] = _("span", { class: "askai__dot" }, null, -1)),
_("span", Ig, se(R.showCitations ? "正在检索知识库" : "思考中"), 1)
])) : le("", !0)
], 64)) : (T(), A(ze, { key: 0 }, [
_("div", yg, [
_("h2", vg, se(R.welcomeTitle || `向 ${R.agentName} 提问`), 1),
R.welcomeSubtitle ? (T(), A("p", bg, se(R.welcomeSubtitle), 1)) : le("", !0)
]),
R.suggestions.length && !R.draft.trim() ? (T(), A("div", wg, [
N[8] || (N[8] = _("p", { class: "askai__label" }, "推荐提问", -1)),
(T(!0), A(ze, null, Et(R.suggestions, (Y) => (T(), A("button", {
key: Y,
type: "button",
class: "askai__suggestion",
disabled: !R.inputEnabled,
onClick: (X) => w(Y)
}, [
_("span", null, se(Y), 1),
N[7] || (N[7] = _("svg", {
width: "15",
height: "15",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
"stroke-width": "2",
"stroke-linecap": "round",
"stroke-linejoin": "round",
"aria-hidden": "true"
}, [
_("path", { d: "M5 12h14M13 6l6 6-6 6" })
], -1))
], 8, kg))), 128))
])) : le("", !0)
], 64))
], 512)
], 512),
_("div", Lg, [
R.disclaimer ? (T(), A("span", Og, se(R.disclaimer), 1)) : le("", !0),
N[13] || (N[13] = _("a", {
class: "askai__brand",
href: "https://replypier.site",
target: "_blank",
rel: "noopener noreferrer"
}, "由 ReplyPier 提供支持", -1))
])
]));
}
}), Mg = /* @__PURE__ */ Gi(Ng, [["__scopeId", "data-v-9c300a6d"]]), Dg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" fill="#E3EADD"/><g transform="translate(9 18) scale(1.28)"><path d="M29 20 39 6 42 21Z" fill="#568B73"/><path d="M4 16 32 26 23 43H15Z" fill="#2E6A5C"/><path d="M35 26 60 16 49 43H27Z" fill="#8BB49C"/></g></svg>
`, Pg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" fill="#F1E8D9"/><path d="M20 31H80V71H20Z" fill="#D6B47C"/><path d="M20 71 50 45 80 71Z" fill="#ECD7AE"/><path d="M20 31 50 55 80 31Z" fill="#2E6A5C"/></svg>
`, Fg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" fill="#F0E6D8"/><path d="M50 50 26 21 53 29Z" fill="#B45132"/><path d="M50 50 79 26 71 53Z" fill="#D5AE68"/><path d="M50 50 74 79 47 71Z" fill="#8BB49C"/><path d="M50 50 21 74 29 47Z" fill="#2E6A5C"/><circle cx="50" cy="50" r="4" fill="#F4F1EB"/></svg>
`, Bg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" fill="#E3EADD"/><path d="M18 25 47 34V77L18 66Z" fill="#2E6A5C"/><path d="M53 34 82 25V66L53 77Z" fill="#8BB49C"/><path d="M23 20 47 29V36L23 27Z" fill="#F8F4E9"/><path d="M53 29 77 20V27L53 36Z" fill="#FFFDF6"/></svg>
`, $g = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" fill="#E5ECE4"/><path d="M17 43 83 22 57 79 45 54Z" fill="#8BB49C"/><path d="M17 43 45 54 83 22Z" fill="#2E6A5C"/><path d="M45 54 57 79 55 48 83 22Z" fill="#568B73"/></svg>
`, Ug = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" fill="#F2E8DC"/><path d="M51 15 77 43 51 72 25 43Z" fill="#D5AE68"/><path d="M51 15V72L25 43Z" fill="#B45132"/><path d="M51 72 48 81 55 87" fill="none" stroke="#8A6326" stroke-width="3" stroke-linecap="round"/></svg>
`, zg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" fill="#F2E6DC"/><path d="M19 36 31 24 47 24 50 33 53 24H69L81 36V50L50 78 19 50Z" fill="#B45132"/><path d="M50 33 69 24 81 36V50L50 78Z" fill="#D68C65"/></svg>
`, Hg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" fill="#E3EADD"/><path d="M23 48H77V78H23Z" fill="#8BB49C"/><path d="M16 48 50 20 84 48Z" fill="#2E6A5C"/><path d="M50 20 84 48H50Z" fill="#568B73"/><path d="M43 58H57V78H43Z" fill="#F4F1EB"/></svg>
`, Wg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" fill="#E8EBDC"/><path d="M25 76C15 40 36 19 78 22 80 60 59 81 25 76Z" fill="#8BB49C"/><path d="M25 76C15 40 36 19 78 22Z" fill="#2E6A5C"/></svg>
`, qg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" fill="#233E36"/><g transform="translate(9 18) scale(1.28)"><path d="M29 20 39 6 42 21Z" fill="#F4F1EB"/><path d="M4 16 32 26 23 43H15Z" fill="#DCE8DC"/><path d="M35 26 60 16 49 43H27Z" fill="#8BB49C"/></g></svg>
`, Lu = [Dg, Pg, Fg, Bg, $g, Ug, zg, Hg, Wg, qg], hi = Lu.length, jg = (e) => (e || "").split("").reduce((t, n) => t + n.charCodeAt(0), 0) % hi, Ou = (e, t) => ((typeof t == "number" && Number.isFinite(t) ? Math.trunc(t) : jg(e)) % hi + hi) % hi, Nu = (e, t) => `data:image/svg+xml,${encodeURIComponent(Lu[Ou(e, t)])}`, Vg = (e) => ({
background: `url("${Nu("", e)}") center / cover no-repeat`,
borderRadius: "50%"
}), Kg = (e, t) => Vg(Ou(e, t)), Gg = (e, t) => {
const n = t == null ? void 0 : t.customization_metadata;
return (n == null ? void 0 : n.avatar_style) === "orb" || !(t != null && t.photo_url) ? Nu(e, n == null ? void 0 : n.orb_variant) : t.photo_url;
}, Zl = (e) => {
var t;
return !!((t = e == null ? void 0 : e.attributes) != null && t.end_chat);
}, Xl = "AI 也可能出错,重要信息请核实。";
function Yg(e, t = !1) {
return e !== !1 && !t;
}
const Ao = {
ai: "在线 · 立即回复",
human: "在线 · 通常几分钟内回复",
away: "离开 · 回来后尽快回复"
};
function Zg(e, t = !1) {
return (t ? "human" : (e == null ? void 0 : e.mode) ?? "ai") === "ai" ? { text: Ao.ai, online: !0 } : (e == null ? void 0 : e.available) !== !1 ? { text: Ao.human, online: !0 } : { text: Ao.away, online: !1 };
}
const Mu = (e) => !!e && (/^https?:\/\//i.test(e) || e.startsWith("data:")), Xg = (e, t) => e ? Mu(e) || e.startsWith("blob:") ? e : `${t.replace(/\/api\/v1\/?$/, "")}${e.startsWith("/") ? "" : "/"}${e}` : "";
function Jl() {
return typeof window < "u" && window.APP_CONFIG ? window.APP_CONFIG : {};
}
const Ws = {
get API_URL() {
return Jl().API_URL || "http://127.0.0.1:8018/api/v1";
},
get WS_URL() {
return Jl().WS_URL || "ws://127.0.0.1:8018";
}
};
function Oi(e) {
return Xg(e, Ws.API_URL);
}
function Jg(e, t = { value: "" }) {
const n = de(() => ({
backgroundColor: "var(--rp-card)",
color: "var(--rp-text)"
})), s = de(() => ({
backgroundColor: e.value.chat_bubble_color || "#C9F24E",
color: $s(e.value.chat_bubble_color || "#C9F24E") ? "#FFFFFF" : "#000000"
})), r = de(() => ({
backgroundColor: "var(--rp-agent-bg)",
color: "var(--rp-text)"
})), i = de(() => ({
backgroundColor: "var(--rp-accent)",
color: "var(--rp-on-accent)"
})), o = de(() => ({
color: "var(--rp-text)"
})), a = de(() => ({
borderBottom: "1px solid var(--rp-hairline)"
})), l = de(() => Oi(Gg(t.value, e.value))), d = de(() => {
const c = e.value.chat_background_color || "#ffffff";
return {
boxShadow: `0 8px 5px ${$s(c) ? "rgba(0, 0, 0, 0.24)" : "rgba(0, 0, 0, 0.12)"}`
};
});
return {
chatStyles: n,
chatIconStyles: s,
agentBubbleStyles: r,
userBubbleStyles: i,
messageNameStyles: o,
headerBorderStyles: a,
photoUrl: l,
shadowStyle: d
};
}
const Qg = /* @__PURE__ */ new Set(["image/jpeg", "image/jpg", "image/png", "image/gif", "image/webp"]), em = /* @__PURE__ */ new Set([
"application/pdf",
"application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"text/plain",
"text/csv",
"application/vnd.ms-excel",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
]);
[...Qg, ...em];
function tm(e, t) {
const n = ce([]), s = ce(!1), r = ce(null), i = (N) => {
if (N === 0) return "0 Bytes";
const Y = 1024, X = ["Bytes", "KB", "MB", "GB"], xe = Math.floor(Math.log(N) / Math.log(Y));
return parseFloat((N / Math.pow(Y, xe)).toFixed(2)) + " " + X[xe];
}, o = (N) => N.startsWith("image/"), a = (N) => N ? Oi(N) : "", l = (N) => {
const Y = N.file_url || N.url;
return Y ? Oi(Y) : "";
}, d = async (N) => {
const Y = N.target;
Y.files && Y.files.length > 0 && (await K(Array.from(Y.files)), Y.value = "");
}, c = async (N) => {
var X;
N.preventDefault();
const Y = (X = N.dataTransfer) == null ? void 0 : X.files;
Y && Y.length > 0 && await K(Array.from(Y));
}, b = (N) => {
N.preventDefault();
}, w = (N) => {
N.preventDefault();
}, z = async (N) => {
var xe;
const Y = (xe = N.clipboardData) == null ? void 0 : xe.items;
if (!Y) return;
const X = [];
for (const Oe of Array.from(Y))
if (Oe.kind === "file") {
const _e = Oe.getAsFile();
_e && X.push(_e);
}
X.length > 0 && await K(X);
}, I = async (N, Y = 500) => new Promise((X, xe) => {
const Oe = new FileReader();
Oe.onload = (_e) => {
var be;
const Pe = new Image();
Pe.onload = () => {
const Ke = document.createElement("canvas");
let Ge = Pe.width, at = Pe.height;
const ue = 1920;
(Ge > ue || at > ue) && (Ge > at ? (at = at / Ge * ue, Ge = ue) : (Ge = Ge / at * ue, at = ue)), Ke.width = Ge, Ke.height = at;
const ye = Ke.getContext("2d");
if (!ye) {
xe(new Error("Failed to get canvas context"));
return;
}
ye.drawImage(Pe, 0, 0, Ge, at);
let me = 0.9;
const nt = () => {
Ke.toBlob((Ze) => {
if (!Ze) {
xe(new Error("Failed to compress image"));
return;
}
if (Ze.size / 1024 > Y && me > 0.3)
me -= 0.1, nt();
else {
const Je = new FileReader();
Je.onload = () => {
const st = Je.result.split(",")[1];
X({ blob: Ze, base64: st });
}, Je.readAsDataURL(Ze);
}
}, N.type === "image/png" ? "image/png" : "image/jpeg", me);
};
nt();
}, Pe.onerror = () => xe(new Error("Failed to load image")), Pe.src = (be = _e.target) == null ? void 0 : be.result;
}, Oe.onerror = () => xe(new Error("Failed to read file")), Oe.readAsDataURL(N);
}), K = async (N) => {
if (n.value.length >= 3) {
alert("每条消息最多 3 个文件");
return;
}
const _e = 3 - n.value.length, Pe = N.slice(0, _e);
N.length > _e && alert(`最多还能上传 ${_e} 个文件。每条消息最多 3 个文件。`);
for (const be of Pe)
try {
if (n.value.some((ue) => ue.filename === be.name)) {
console.warn(`File ${be.name} is already selected`), alert(`文件“${be.name}”已选择`);
continue;
}
const Ge = be.type.startsWith("image/"), at = Ge ? 5242880 : 10485760;
if (be.size > at) {
const ue = at / 1048576;
console.error(`File ${be.name} is too large. Maximum size is ${ue}MB`), alert(`文件“${be.name}”过大,${Ge ? "图片" : "文档"}最大为 ${ue}MB`);
continue;
}
if (Ge)
try {
const { blob: ue, base64: ye } = await I(be, 500), me = ue.size;
console.log(`Compressed ${be.name}: ${(be.size / 1024).toFixed(2)}KB → ${(me / 1024).toFixed(2)}KB`), n.value.push({
content: ye,
filename: be.name,
type: be.type,
size: me,
url: URL.createObjectURL(ue),
file_url: URL.createObjectURL(ue)
});
} catch (ue) {
console.error("Image compression failed, uploading original:", ue);
const ye = new FileReader();
ye.onload = (me) => {
var Te;
const Ze = ((Te = me.target) == null ? void 0 : Te.result).split(",")[1];
n.value.push({
content: Ze,
filename: be.name,
type: be.type,
size: be.size,
url: URL.createObjectURL(be),
file_url: URL.createObjectURL(be)
});
}, ye.readAsDataURL(be);
}
else {
const ue = new FileReader();
ue.onload = (ye) => {
var Ze;
const nt = ((Ze = ye.target) == null ? void 0 : Ze.result).split(",")[1];
n.value.push({
content: nt,
filename: be.name,
type: be.type || "application/octet-stream",
size: be.size,
url: "",
file_url: ""
});
}, ue.readAsDataURL(be);
}
} catch (Ke) {
console.error("File upload error:", Ke);
}
};
return {
uploadedAttachments: n,
previewModal: s,
previewFile: r,
formatFileSize: i,
isImageAttachment: o,
getDownloadUrl: a,
getPreviewUrl: l,
handleFileSelect: d,
handleDrop: c,
handleDragOver: b,
handleDragLeave: w,
handlePaste: z,
uploadFiles: K,
removeAttachment: async (N) => {
const Y = n.value[N];
if (Y) {
try {
let X = Y.url;
if (X.startsWith("/uploads/") ? X = X.substring(9) : X.startsWith("/") && (X = X.substring(1)), Mu(X))
try {
X = new URL(X).pathname.replace(/^\/+/, "");
} catch {
}
const xe = {};
e.value && (xe.Authorization = `Bearer ${e.value}`);
const Oe = await fetch(`${Ws.API_URL}/files/upload/${X}`, {
method: "DELETE",
headers: xe
});
if (Oe.ok)
console.log("File deleted successfully from backend.");
else {
const _e = await Oe.json();
console.error("Failed to delete file:", _e.detail);
}
} catch (X) {
console.error("Error calling delete API:", X);
}
Y.url && Y.url.startsWith("blob:") && URL.revokeObjectURL(Y.url), Y.file_url && Y.file_url.startsWith("blob:") && URL.revokeObjectURL(Y.file_url), n.value.splice(N, 1);
}
},
openPreview: (N) => {
r.value = N, s.value = !0;
},
closePreview: () => {
s.value = !1, setTimeout(() => {
r.value = null;
}, 300);
},
openFilePicker: () => {
var N;
(N = t.value) == null || N.click();
},
isImage: (N) => N.startsWith("image/")
};
}
const wn = /* @__PURE__ */ Object.create(null);
wn.open = "0";
wn.close = "1";
wn.ping = "2";
wn.pong = "3";
wn.message = "4";
wn.upgrade = "5";
wn.noop = "6";
const di = /* @__PURE__ */ Object.create(null);
Object.keys(wn).forEach((e) => {
di[wn[e]] = e;
});
const Zo = { type: "error", data: "parser error" }, Du = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Pu = typeof ArrayBuffer == "function", Fu = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e && e.buffer instanceof ArrayBuffer, Sa = ({ type: e, data: t }, n, s) => Du && t instanceof Blob ? n ? s(t) : Ql(t, s) : Pu && (t instanceof ArrayBuffer || Fu(t)) ? n ? s(t) : Ql(new Blob([t]), s) : s(wn[e] + (t || "")), Ql = (e, t) => {
const n = new FileReader();
return n.onload = function() {
const s = n.result.split(",")[1];
t("b" + (s || ""));
}, n.readAsDataURL(e);
};
function ec(e) {
return e instanceof Uint8Array ? e : e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
}
let Eo;
function nm(e, t) {
if (Du && e.data instanceof Blob)
return e.data.arrayBuffer().then(ec).then(t);
if (Pu && (e.data instanceof ArrayBuffer || Fu(e.data)))
return t(ec(e.data));
Sa(e, !1, (n) => {
Eo || (Eo = new TextEncoder()), t(Eo.encode(n));
});
}
const tc = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", br = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (let e = 0; e < tc.length; e++)
br[tc.charCodeAt(e)] = e;
const sm = (e) => {
let t = e.length * 0.75, n = e.length, s, r = 0, i, o, a, l;
e[e.length - 1] === "=" && (t--, e[e.length - 2] === "=" && t--);
const d = new ArrayBuffer(t), c = new Uint8Array(d);
for (s = 0; s < n; s += 4)
i = br[e.charCodeAt(s)], o = br[e.charCodeAt(s + 1)], a = br[e.charCodeAt(s + 2)], l = br[e.charCodeAt(s + 3)], c[r++] = i << 2 | o >> 4, c[r++] = (o & 15) << 4 | a >> 2, c[r++] = (a & 3) << 6 | l & 63;
return d;
}, rm = typeof ArrayBuffer == "function", Ca = (e, t) => {
if (typeof e != "string")
return {
type: "message",
data: Bu(e, t)
};
const n = e.charAt(0);
return n === "b" ? {
type: "message",
data: im(e.substring(1), t)
} : di[n] ? e.length > 1 ? {
type: di[n],
data: e.substring(1)
} : {
type: di[n]
} : Zo;
}, im = (e, t) => {
if (rm) {
const n = sm(e);
return Bu(n, t);
} else
return { base64: !0, data: e };
}, Bu = (e, t) => {
switch (t) {
case "blob":
return e instanceof Blob ? e : new Blob([e]);
case "arraybuffer":
default:
return e instanceof ArrayBuffer ? e : e.buffer;
}
}, $u = "", om = (e, t) => {
const n = e.length, s = new Array(n);
let r = 0;
e.forEach((i, o) => {
Sa(i, !1, (a) => {
s[o] = a, ++r === n && t(s.join($u));
});
});
}, am = (e, t) => {
const n = e.split($u), s = [];
for (let r = 0; r < n.length; r++) {
const i = Ca(n[r], t);
if (s.push(i), i.type === "error")
break;
}
return s;
};
function lm() {
return new TransformStream({
transform(e, t) {
nm(e, (n) => {
const s = n.length;
let r;
if (s < 126)
r = new Uint8Array(1), new DataView(r.buffer).setUint8(0, s);
else if (s < 65536) {
r = new Uint8Array(3);
const i = new DataView(r.buffer);
i.setUint8(0, 126), i.setUint16(1, s);
} else {
r = new Uint8Array(9);
const i = new DataView(r.buffer);
i.setUint8(0, 127), i.setBigUint64(1, BigInt(s));
}
e.data && typeof e.data != "string" && (r[0] |= 128), t.enqueue(r), t.enqueue(n);
});
}
});
}
let So;
function ti(e) {
return e.reduce((t, n) => t + n.length, 0);
}
function ni(e, t) {
if (e[0].length === t)
return e.shift();
const n = new Uint8Array(t);
let s = 0;
for (let r = 0; r < t; r++)
n[r] = e[0][s++], s === e[0].length && (e.shift(), s = 0);
return e.length && s < e[0].length && (e[0] = e[0].slice(s)), n;
}
function cm(e, t) {
So || (So = new TextDecoder());
const n = [];
let s = 0, r = -1, i = !1;
return new TransformStream({
transform(o, a) {
for (n.push(o); ; ) {
if (s === 0) {
if (ti(n) < 1)
break;
const l = ni(n, 1);
i = (l[0] & 128) === 128, r = l[0] & 127, r < 126 ? s = 3 : r === 126 ? s = 1 : s = 2;
} else if (s === 1) {
if (ti(n) < 2)
break;
const l = ni(n, 2);
r = new DataView(l.buffer, l.byteOffset, l.length).getUint16(0), s = 3;
} else if (s === 2) {
if (ti(n) < 8)
break;
const l = ni(n, 8), d = new DataView(l.buffer, l.byteOffset, l.length), c = d.getUint32(0);
if (c > Math.pow(2, 21) - 1) {
a.enqueue(Zo);
break;
}
r = c * Math.pow(2, 32) + d.getUint32(4), s = 3;
} else {
if (ti(n) < r)
break;
const l = ni(n, r);
a.enqueue(Ca(i ? l : So.decode(l), t)), s = 0;
}
if (r === 0 || r > e) {
a.enqueue(Zo);
break;
}
}
}
});
}
const Uu = 4;
function gt(e) {
if (e) return um(e);
}
function um(e) {
for (var t in gt.prototype)
e[t] = gt.prototype[t];
return e;
}
gt.prototype.on = gt.prototype.addEventListener = function(e, t) {
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + e] = this._callbacks["$" + e] || []).push(t), this;
};
gt.prototype.once = function(e, t) {
function n() {
this.off(e, n), t.apply(this, arguments);
}
return n.fn = t, this.on(e, n), this;
};
gt.prototype.off = gt.prototype.removeListener = gt.prototype.removeAllListeners = gt.prototype.removeEventListener = function(e, t) {
if (this._callbacks = this._callbacks || {}, arguments.length == 0)
return this._callbacks = {}, this;
var n = this._callbacks["$" + e];
if (!n) return this;
if (arguments.length == 1)
return delete this._callbacks["$" + e], this;
for (var s, r = 0; r < n.length; r++)
if (s = n[r], s === t || s.fn === t) {
n.splice(r, 1);
break;
}
return n.length === 0 && delete this._callbacks["$" + e], this;
};
gt.prototype.emit = function(e) {
this._callbacks = this._callbacks || {};
for (var t = new Array(arguments.length - 1), n = this._callbacks["$" + e], s = 1; s < arguments.length; s++)
t[s - 1] = arguments[s];
if (n) {
n = n.slice(0);
for (var s = 0, r = n.length; s < r; ++s)
n[s].apply(this, t);
}
return this;
};
gt.prototype.emitReserved = gt.prototype.emit;
gt.prototype.listeners = function(e) {
return this._callbacks = this._callbacks || {}, this._callbacks["$" + e] || [];
};
gt.prototype.hasListeners = function(e) {
return !!this.listeners(e).length;
};
const Yi = typeof Promise == "function" && typeof Promise.resolve == "function" ? (t) => Promise.resolve().then(t) : (t, n) => n(t, 0), tn = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), fm = "arraybuffer";
function zu(e, ...t) {
return t.reduce((n, s) => (e.hasOwnProperty(s) && (n[s] = e[s]), n), {});
}
const hm = tn.setTimeout, dm = tn.clearTimeout;
function Zi(e, t) {
t.useNativeTimers ? (e.setTimeoutFn = hm.bind(tn), e.clearTimeoutFn = dm.bind(tn)) : (e.setTimeoutFn = tn.setTimeout.bind(tn), e.clearTimeoutFn = tn.clearTimeout.bind(tn));
}
const pm = 1.33;
function gm(e) {
return typeof e == "string" ? mm(e) : Math.ceil((e.byteLength || e.size) * pm);
}
function mm(e) {
let t = 0, n = 0;
for (let s = 0, r = e.length; s < r; s++)
t = e.charCodeAt(s), t < 128 ? n += 1 : t < 2048 ? n += 2 : t < 55296 || t >= 57344 ? n += 3 : (s++, n += 4);
return n;
}
function Hu() {
return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
}
function _m(e) {
let t = "";
for (let n in e)
e.hasOwnProperty(n) && (t.length && (t += "&"), t += encodeURIComponent(n) + "=" + encodeURIComponent(e[n]));
return t;
}
function ym(e) {
let t = {}, n = e.split("&");
for (let s = 0, r = n.length; s < r; s++) {
let i = n[s].split("=");
t[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
}
return t;
}
class vm extends Error {
constructor(t, n, s) {
super(t), this.description = n, this.context = s, this.type = "TransportError";
}
}
class Ra extends gt {
/**
* Transport abstract constructor.
*
* @param {Object} opts - options
* @protected
*/
constructor(t) {
super(), this.writable = !1, Zi(this, t), this.opts = t, this.query = t.query, this.socket = t.socket, this.supportsBinary = !t.forceBase64;
}
/**
* Emits an error.
*
* @param {String} reason
* @param description
* @param context - the error context
* @return {Transport} for chaining
* @protected
*/
onError(t, n, s) {
return super.emitReserved("error", new vm(t, n, s)), this;
}
/**
* Opens the transport.
*/
open() {
return this.readyState = "opening", this.doOpen(), this;
}
/**
* Closes the transport.
*/
close() {
return (this.readyState === "opening" || this.readyState === "open") && (this.doClose(), this.onClose()), this;
}
/**
* Sends multiple packets.
*
* @param {Array} packets
*/
send(t) {
this.readyState === "open" && this.write(t);
}
/**
* Called upon open
*
* @protected
*/
onOpen() {
this.readyState = "open", this.writable = !0, super.emitReserved("open");
}
/**
* Called with data.
*
* @param {String} data
* @protected
*/
onData(t) {
const n = Ca(t, this.socket.binaryType);
this.onPacket(n);
}
/**
* Called with a decoded packet.
*
* @protected
*/
onPacket(t) {
super.emitReserved("packet", t);
}
/**
* Called upon close.
*
* @protected
*/
onClose(t) {
this.readyState = "closed", super.emitReserved("close", t);
}
/**
* Pauses the transport, in order not to lose packets during an upgrade.
*
* @param onPause
*/
pause(t) {
}
createUri(t, n = {}) {
return t + "://" + this._hostname() + this._port() + this.opts.path + this._query(n);
}
_hostname() {
const t = this.opts.hostname;
return t.indexOf(":") === -1 ? t : "[" + t + "]";
}
_port() {
return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
}
_query(t) {
const n = _m(t);
return n.length ? "?" + n : "";
}
}
class bm extends Ra {
constructor() {
super(...arguments), this._polling = !1;
}
get name() {
return "polling";
}
/**
* Opens the socket (triggers polling). We write a PING message to determine
* when the transport is open.
*
* @protected
*/
doOpen() {
this._poll();
}
/**
* Pauses polling.
*
* @param {Function} onPause - callback upon buffers are flushed and transport is paused
* @package
*/
pause(t) {
this.readyState = "pausing";
const n = () => {
this.readyState = "paused", t();
};
if (this._polling || !this.writable) {
let s = 0;
this._polling && (s++, this.once("pollComplete", function() {
--s || n();
})), this.writable || (s++, this.once("drain", function() {
--s || n();
}));
} else
n();
}
/**
* Starts polling cycle.
*
* @private
*/
_poll() {
this._polling = !0, this.doPoll(), this.emitReserved("poll");
}
/**
* Overloads onData to detect payloads.
*
* @protected
*/
onData(t) {
const n = (s) => {
if (this.readyState === "opening" && s.type === "open" && this.onOpen(), s.type === "close")
return this.onClose({ description: "transport closed by the server" }), !1;
this.onPacket(s);
};
am(t, this.socket.binaryType).forEach(n), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
}
/**
* For polling, send a close packet.
*
* @protected
*/
doClose() {
const t = () => {
this.write([{ type: "close" }]);
};
this.readyState === "open" ? t() : this.once("open", t);
}
/**
* Writes a packets payload.
*
* @param {Array} packets - data packets
* @protected
*/
write(t) {
this.writable = !1, om(t, (n) => {
this.doWrite(n, () => {
this.writable = !0, this.emitReserved("drain");
});
});
}
/**
* Generates uri for connection.
*
* @private
*/
uri() {
const t = this.opts.secure ? "https" : "http", n = this.query || {};
return this.opts.timestampRequests !== !1 && (n[this.opts.timestampParam] = Hu()), !this.supportsBinary && !n.sid && (n.b64 = 1), this.createUri(t, n);
}
}
let Wu = !1;
try {
Wu = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
} catch {
}
const wm = Wu;
function km() {
}
class xm extends bm {
/**
* XHR Polling constructor.
*
* @param {Object} opts
* @package
*/
constructor(t) {
if (super(t), typeof location < "u") {
const n = location.protocol === "https:";
let s = location.port;
s || (s = n ? "443" : "80"), this.xd = typeof location < "u" && t.hostname !== location.hostname || s !== t.port;
}
}
/**
* Sends data.
*
* @param {String} data - data to send.
* @param {Function} fn - called upon flush.
* @private
*/
doWrite(t, n) {
const s = this.request({
method: "POST",
data: t
});
s.on("success", n), s.on("error", (r, i) => {
this.onError("xhr post error", r, i);
});
}
/**
* Starts a poll cycle.
*
* @private
*/
doPoll() {
const t = this.request();
t.on("data", this.onData.bind(this)), t.on("error", (n, s) => {
this.onError("xhr poll error", n, s);
}), this.pollXhr = t;
}
}
class vn extends gt {
/**
* Request constructor
*
* @param {Object} options
* @package
*/
constructor(t, n, s) {
super(), this.createRequest = t, Zi(this, s), this._opts = s, this._method = s.method || "GET", this._uri = n, this._data = s.data !== void 0 ? s.data : null, this._create();
}
/**
* Creates the XHR object and sends the request.
*
* @private
*/
_create() {
var t;
const n = zu(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
n.xdomain = !!this._opts.xd;
const s = this._xhr = this.createRequest(n);
try {
s.open(this._method, this._uri, !0);
try {
if (this._opts.extraHeaders) {
s.setDisableHeaderCheck && s.setDisableHeaderCheck(!0);
for (let r in this._opts.extraHeaders)
this._opts.extraHeaders.hasOwnProperty(r) && s.setRequestHeader(r, this._opts.extraHeaders[r]);
}
} catch {
}
if (this._method === "POST")
try {
s.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
} catch {
}
try {
s.setRequestHeader("Accept", "*/*");
} catch {
}
(t = this._opts.cookieJar) === null || t === void 0 || t.addCookies(s), "withCredentials" in s && (s.withCredentials = this._opts.withCredentials), this._opts.requestTimeout && (s.timeout = this._opts.requestTimeout), s.onreadystatechange = () => {
var r;
s.readyState === 3 && ((r = this._opts.cookieJar) === null || r === void 0 || r.parseCookies(
// @ts-ignore
s.getResponseHeader("set-cookie")
)), s.readyState === 4 && (s.status === 200 || s.status === 1223 ? this._onLoad() : this.setTimeoutFn(() => {
this._onError(typeof s.status == "number" ? s.status : 0);
}, 0));
}, s.send(this._data);
} catch (r) {
this.setTimeoutFn(() => {
this._onError(r);
}, 0);
return;
}
typeof document < "u" && (this._index = vn.requestsCount++, vn.requests[this._index] = this);
}
/**
* Called upon error.
*
* @private
*/
_onError(t) {
this.emitReserved("error", t, this._xhr), this._cleanup(!0);
}
/**
* Cleans up house.
*
* @private
*/
_cleanup(t) {
if (!(typeof this._xhr > "u" || this._xhr === null)) {
if (this._xhr.onreadystatechange = km, t)
try {
this._xhr.abort();
} catch {
}
typeof document < "u" && delete vn.requests[this._index], this._xhr = null;
}
}
/**
* Called upon load.
*
* @private
*/
_onLoad() {
const t = this._xhr.responseText;
t !== null && (this.emitReserved("data", t), this.emitReserved("success"), this._cleanup());
}
/**
* Aborts the request.
*
* @package
*/
abort() {
this._cleanup();
}
}
vn.requestsCount = 0;
vn.requests = {};
if (typeof document < "u") {
if (typeof attachEvent == "function")
attachEvent("onunload", nc);
else if (typeof addEventListener == "function") {
const e = "onpagehide" in tn ? "pagehide" : "unload";
addEventListener(e, nc, !1);
}
}
function nc() {
for (let e in vn.requests)
vn.requests.hasOwnProperty(e) && vn.requests[e].abort();
}
const Tm = function() {
const e = qu({
xdomain: !1
});
return e && e.responseType !== null;
}();
class Am extends xm {
constructor(t) {
super(t);
const n = t && t.forceBase64;
this.supportsBinary = Tm && !n;
}
request(t = {}) {
return Object.assign(t, { xd: this.xd }, this.opts), new vn(qu, this.uri(), t);
}
}
function qu(e) {
const t = e.xdomain;
try {
if (typeof XMLHttpRequest < "u" && (!t || wm))
return new XMLHttpRequest();
} catch {
}
if (!t)
try {
return new tn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
} catch {
}
}
const ju = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
class Em extends Ra {
get name() {
return "websocket";
}
doOpen() {
const t = this.uri(), n = this.opts.protocols, s = ju ? {} : zu(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
this.opts.extraHeaders && (s.headers = this.opts.extraHeaders);
try {
this.ws = this.createSocket(t, n, s);
} catch (r) {
return this.emitReserved("error", r);
}
this.ws.binaryType = this.socket.binaryType, this.addEventListeners();
}
/**
* Adds event listeners to the socket
*
* @private
*/
addEventListeners() {
this.ws.onopen = () => {
this.opts.autoUnref && this.ws._socket.unref(), this.onOpen();
}, this.ws.onclose = (t) => this.onClose({
description: "websocket connection closed",
context: t
}), this.ws.onmessage = (t) => this.onData(t.data), this.ws.onerror = (t) => this.onError("websocket error", t);
}
write(t) {
this.writable = !1;
for (let n = 0; n < t.length; n++) {
const s = t[n], r = n === t.length - 1;
Sa(s, this.supportsBinary, (i) => {
try {
this.doWrite(s, i);
} catch {
}
r && Yi(() => {
this.writable = !0, this.emitReserved("drain");
}, this.setTimeoutFn);
});
}
}
doClose() {
typeof this.ws < "u" && (this.ws.onerror = () => {
}, this.ws.close(), this.ws = null);
}
/**
* Generates uri for connection.
*
* @private
*/
uri() {
const t = this.opts.secure ? "wss" : "ws", n = this.query || {};
return this.opts.timestampRequests && (n[this.opts.timestampParam] = Hu()), this.supportsBinary || (n.b64 = 1), this.createUri(t, n);
}
}
const Co = tn.WebSocket || tn.MozWebSocket;
class Sm extends Em {
createSocket(t, n, s) {
return ju ? new Co(t, n, s) : n ? new Co(t, n) : new Co(t);
}
doWrite(t, n) {
this.ws.send(n);
}
}
class Cm extends Ra {
get name() {
return "webtransport";
}
doOpen() {
try {
this._transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]);
} catch (t) {
return this.emitReserved("error", t);
}
this._transport.closed.then(() => {
this.onClose();
}).catch((t) => {
this.onError("webtransport error", t);
}), this._transport.ready.then(() => {
this._transport.createBidirectionalStream().then((t) => {
const n = cm(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = t.readable.pipeThrough(n).getReader(), r = lm();
r.readable.pipeTo(t.writable), this._writer = r.writable.getWriter();
const i = () => {
s.read().then(({ done: a, value: l }) => {
a || (this.onPacket(l), i());
}).catch((a) => {
});
};
i();
const o = { type: "open" };
this.query.sid && (o.data = `{"sid":"${this.query.sid}"}`), this._writer.write(o).then(() => this.onOpen());
});
});
}
write(t) {
this.writable = !1;
for (let n = 0; n < t.length; n++) {
const s = t[n], r = n === t.length - 1;
this._writer.write(s).then(() => {
r && Yi(() => {
this.writable = !0, this.emitReserved("drain");
}, this.setTimeoutFn);
});
}
}
doClose() {
var t;
(t = this._transport) === null || t === void 0 || t.close();
}
}
const Rm = {
websocket: Sm,
webtransport: Cm,
polling: Am
}, Im = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, Lm = [
"source",
"protocol",
"authority",
"userInfo",
"user",
"password",
"host",
"port",
"relative",
"path",
"directory",
"file",
"query",
"anchor"
];
function Xo(e) {
if (e.length > 8e3)
throw "URI too long";
const t = e, n = e.indexOf("["), s = e.indexOf("]");
n != -1 && s != -1 && (e = e.substring(0, n) + e.substring(n, s).replace(/:/g, ";") + e.substring(s, e.length));
let r = Im.exec(e || ""), i = {}, o = 14;
for (; o--; )
i[Lm[o]] = r[o] || "";
return n != -1 && s != -1 && (i.source = t, i.host = i.host.substring(1, i.host.length - 1).replace(/;/g, ":"), i.authority = i.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), i.ipv6uri = !0), i.pathNames = Om(i, i.path), i.queryKey = Nm(i, i.query), i;
}
function Om(e, t) {
const n = /\/{2,9}/g, s = t.replace(n, "/").split("/");
return (t.slice(0, 1) == "/" || t.length === 0) && s.splice(0, 1), t.slice(-1) == "/" && s.splice(s.length - 1, 1), s;
}
function Nm(e, t) {
const n = {};
return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(s, r, i) {
r && (n[r] = i);
}), n;
}
const Jo = typeof addEventListener == "function" && typeof removeEventListener == "function", pi = [];
Jo && addEventListener("offline", () => {
pi.forEach((e) => e());
}, !1);
class Jn extends gt {
/**
* Socket constructor.
*
* @param {String|Object} uri - uri or options
* @param {Object} opts - options
*/
constructor(t, n) {
if (super(), this.binaryType = fm, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, t && typeof t == "object" && (n = t, t = null), t) {
const s = Xo(t);
n.hostname = s.host, n.secure = s.protocol === "https" || s.protocol === "wss", n.port = s.port, s.query && (n.query = s.query);
} else n.host && (n.hostname = Xo(n.host).host);
Zi(this, n), this.secure = n.secure != null ? n.secure : typeof location < "u" && location.protocol === "https:", n.hostname && !n.port && (n.port = this.secure ? "443" : "80"), this.hostname = n.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = n.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, n.transports.forEach((s) => {
const r = s.prototype.name;
this.transports.push(r), this._transportsByName[r] = s;
}), this.opts = Object.assign({
path: "/engine.io",
agent: !1,
withCredentials: !1,
upgrade: !0,
timestampParam: "t",
rememberUpgrade: !1,
addTrailingSlash: !0,
rejectUnauthorized: !0,
perMessageDeflate: {
threshold: 1024
},
transportOptions: {},
closeOnBeforeunload: !1
}, n), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = ym(this.opts.query)), Jo && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
this.transport && (this.transport.removeAllListeners(), this.transport.close());
}, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
this._onClose("transport close", {
description: "network connection lost"
});
}, pi.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
}
/**
* Creates transport of the given type.
*
* @param {String} name - transport name
* @return {Transport}
* @private
*/
createTransport(t) {
const n = Object.assign({}, this.opts.query);
n.EIO = Uu, n.transport = t, this.id && (n.sid = this.id);
const s = Object.assign({}, this.opts, {
query: n,
socket: this,
hostname: this.hostname,
secure: this.secure,
port: this.port
}, this.opts.transportOptions[t]);
return new this._transportsByName[t](s);
}
/**
* Initializes transport to use and starts probe.
*
* @private
*/
_open() {
if (this.transports.length === 0) {
this.setTimeoutFn(() => {
this.emitReserved("error", "No transports available");
}, 0);
return;
}
const t = this.opts.rememberUpgrade && Jn.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
this.readyState = "opening";
const n = this.createTransport(t);
n.open(), this.setTransport(n);
}
/**
* Sets the current transport. Disables the existing one (if any).
*
* @private
*/
setTransport(t) {
this.transport && this.transport.removeAllListeners(), this.transport = t, t.on("drain", this._onDrain.bind(this)).on("packet", this._onPacket.bind(this)).on("error", this._onError.bind(this)).on("close", (n) => this._onClose("transport close", n));
}
/**
* Called when connection is deemed open.
*
* @private
*/
onOpen() {
this.readyState = "open", Jn.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
}
/**
* Handles a packet.
*
* @private
*/
_onPacket(t) {
if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing")
switch (this.emitReserved("packet", t), this.emitReserved("heartbeat"), t.type) {
case "open":
this.onHandshake(JSON.parse(t.data));
break;
case "ping":
this._sendPacket("pong"), this.emitReserved("ping"), this.emitReserved("pong"), this._resetPingTimeout();
break;
case "error":
const n = new Error("server error");
n.code = t.data, this._onError(n);
break;
case "message":
this.emitReserved("data", t.data), this.emitReserved("message", t.data);
break;
}
}
/**
* Called upon handshake completion.
*
* @param {Object} data - handshake obj
* @private
*/
onHandshake(t) {
this.emitReserved("handshake", t), this.id = t.sid, this.transport.query.sid = t.sid, this._pingInterval = t.pingInterval, this._pingTimeout = t.pingTimeout, this._maxPayload = t.maxPayload, this.onOpen(), this.readyState !== "closed" && this._resetPingTimeout();
}
/**
* Sets and resets ping timeout timer based on server pings.
*
* @private
*/
_resetPingTimeout() {
this.clearTimeoutFn(this._pingTimeoutTimer);
const t = this._pingInterval + this._pingTimeout;
this._pingTimeoutTime = Date.now() + t, this._pingTimeoutTimer = this.setTimeoutFn(() => {
this._onClose("ping timeout");
}, t), this.opts.autoUnref && this._pingTimeoutTimer.unref();
}
/**
* Called on `drain` event
*
* @private
*/
_onDrain() {
this.writeBuffer.splice(0, this._prevBufferLen), this._prevBufferLen = 0, this.writeBuffer.length === 0 ? this.emitReserved("drain") : this.flush();
}
/**
* Flush write buffers.
*
* @private
*/
flush() {
if (this.readyState !== "closed" && this.transport.writable && !this.upgrading && this.writeBuffer.length) {
const t = this._getWritablePackets();
this.transport.send(t), this._prevBufferLen = t.length, this.emitReserved("flush");
}
}
/**
* Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP
* long-polling)
*
* @private
*/
_getWritablePackets() {
if (!(this._maxPayload && this.transport.name === "polling" && this.writeBuffer.length > 1))
return this.writeBuffer;
let n = 1;
for (let s = 0; s < this.writeBuffer.length; s++) {
const r = this.writeBuffer[s].data;
if (r && (n += gm(r)), s > 0 && n > this._maxPayload)
return this.writeBuffer.slice(0, s);
n += 2;
}
return this.writeBuffer;
}
/**
* Checks whether the heartbeat timer has expired but the socket has not yet been notified.
*
* Note: this method is private for now because it does not really fit the WebSocket API, but if we put it in the
* `write()` method then the message would not be buffered by the Socket.IO client.
*
* @return {boolean}
* @private
*/
/* private */
_hasPingExpired() {
if (!this._pingTimeoutTime)
return !0;
const t = Date.now() > this._pingTimeoutTime;
return t && (this._pingTimeoutTime = 0, Yi(() => {
this._onClose("ping timeout");
}, this.setTimeoutFn)), t;
}
/**
* Sends a message.
*
* @param {String} msg - message.
* @param {Object} options.
* @param {Function} fn - callback function.
* @return {Socket} for chaining.
*/
write(t, n, s) {
return this._sendPacket("message", t, n, s), this;
}
/**
* Sends a message. Alias of {@link Socket#write}.
*
* @param {String} msg - message.
* @param {Object} options.
* @param {Function} fn - callback function.
* @return {Socket} for chaining.
*/
send(t, n, s) {
return this._sendPacket("message", t, n, s), this;
}
/**
* Sends a packet.
*
* @param {String} type - packet type.
* @param {String} data.
* @param {Object} options.
* @param {Function} fn - callback function.
* @private
*/
_sendPacket(t, n, s, r) {
if (typeof n == "function" && (r = n, n = void 0), typeof s == "function" && (r = s, s = null), this.readyState === "closing" || this.readyState === "closed")
return;
s = s || {}, s.compress = s.compress !== !1;
const i = {
type: t,
data: n,
options: s
};
this.emitReserved("packetCreate", i), this.writeBuffer.push(i), r && this.once("flush", r), this.flush();
}
/**
* Closes the connection.
*/
close() {
const t = () => {
this._onClose("forced close"), this.transport.close();
}, n = () => {
this.off("upgrade", n), this.off("upgradeError", n), t();
}, s = () => {
this.once("upgrade", n), this.once("upgradeError", n);
};
return (this.readyState === "opening" || this.readyState === "open") && (this.readyState = "closing", this.writeBuffer.length ? this.once("drain", () => {
this.upgrading ? s() : t();
}) : this.upgrading ? s() : t()), this;
}
/**
* Called upon transport error
*
* @private
*/
_onError(t) {
if (Jn.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
return this.transports.shift(), this._open();
this.emitReserved("error", t), this._onClose("transport error", t);
}
/**
* Called upon transport close.
*
* @private
*/
_onClose(t, n) {
if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), Jo && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
const s = pi.indexOf(this._offlineEventListener);
s !== -1 && pi.splice(s, 1);
}
this.readyState = "closed", this.id = null, this.emitReserved("close", t, n), this.writeBuffer = [], this._prevBufferLen = 0;
}
}
}
Jn.protocol = Uu;
class Mm extends Jn {
constructor() {
super(...arguments), this._upgrades = [];
}
onOpen() {
if (super.onOpen(), this.readyState === "open" && this.opts.upgrade)
for (let t = 0; t < this._upgrades.length; t++)
this._probe(this._upgrades[t]);
}
/**
* Probes a transport.
*
* @param {String} name - transport name
* @private
*/
_probe(t) {
let n = this.createTransport(t), s = !1;
Jn.priorWebsocketSuccess = !1;
const r = () => {
s || (n.send([{ type: "ping", data: "probe" }]), n.once("packet", (b) => {
if (!s)
if (b.type === "pong" && b.data === "probe") {
if (this.upgrading = !0, this.emitReserved("upgrading", n), !n)
return;
Jn.priorWebsocketSuccess = n.name === "websocket", this.transport.pause(() => {
s || this.readyState !== "closed" && (c(), this.setTransport(n), n.send([{ type: "upgrade" }]), this.emitReserved("upgrade", n), n = null, this.upgrading = !1, this.flush());
});
} else {
const w = new Error("probe error");
w.transport = n.name, this.emitReserved("upgradeError", w);
}
}));
};
function i() {
s || (s = !0, c(), n.close(), n = null);
}
const o = (b) => {
const w = new Error("probe error: " + b);
w.transport = n.name, i(), this.emitReserved("upgradeError", w);
};
function a() {
o("transport closed");
}
function l() {
o("socket closed");
}
function d(b) {
n && b.name !== n.name && i();
}
const c = () => {
n.removeListener("open", r), n.removeListener("error", o), n.removeListener("close", a), this.off("close", l), this.off("upgrading", d);
};
n.once("open", r), n.once("error", o), n.once("close", a), this.once("close", l), this.once("upgrading", d), this._upgrades.indexOf("webtransport") !== -1 && t !== "webtransport" ? this.setTimeoutFn(() => {
s || n.open();
}, 200) : n.open();
}
onHandshake(t) {
this._upgrades = this._filterUpgrades(t.upgrades), super.onHandshake(t);
}
/**
* Filters upgrades, returning only those matching client transports.
*
* @param {Array} upgrades - server upgrades
* @private
*/
_filterUpgrades(t) {
const n = [];
for (let s = 0; s < t.length; s++)
~this.transports.indexOf(t[s]) && n.push(t[s]);
return n;
}
}
let Dm = class extends Mm {
constructor(t, n = {}) {
const s = typeof t == "object", r = s ? { ...t } : { ...n };
(!r.transports || r.transports && typeof r.transports[0] == "string") && (r.transports = (r.transports || ["polling", "websocket", "webtransport"]).map((i) => Rm[i]).filter((i) => !!i)), super(s ? r : t, r);
}
};
function Pm(e, t = "", n) {
let s = e;
n = n || typeof location < "u" && location, e == null && (e = n.protocol + "//" + n.host), typeof e == "string" && (e.charAt(0) === "/" && (e.charAt(1) === "/" ? e = n.protocol + e : e = n.host + e), /^(https?|wss?):\/\//.test(e) || (typeof n < "u" ? e = n.protocol + "//" + e : e = "https://" + e), s = Xo(e)), s.port || (/^(http|ws)$/.test(s.protocol) ? s.port = "80" : /^(http|ws)s$/.test(s.protocol) && (s.port = "443")), s.path = s.path || "/";
const i = s.host.indexOf(":") !== -1 ? "[" + s.host + "]" : s.host;
return s.id = s.protocol + "://" + i + ":" + s.port + t, s.href = s.protocol + "://" + i + (n && n.port === s.port ? "" : ":" + s.port), s;
}
const Fm = typeof ArrayBuffer == "function", Bm = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e.buffer instanceof ArrayBuffer, Vu = Object.prototype.toString, $m = typeof Blob == "function" || typeof Blob < "u" && Vu.call(Blob) === "[object BlobConstructor]", Um = typeof File == "function" || typeof File < "u" && Vu.call(File) === "[object FileConstructor]";
function Ia(e) {
return Fm && (e instanceof ArrayBuffer || Bm(e)) || $m && e instanceof Blob || Um && e instanceof File;
}
function gi(e, t) {
if (!e || typeof e != "object")
return !1;
if (Array.isArray(e)) {
for (let n = 0, s = e.length; n < s; n++)
if (gi(e[n]))
return !0;
return !1;
}
if (Ia(e))
return !0;
if (e.toJSON && typeof e.toJSON == "function" && arguments.length === 1)
return gi(e.toJSON(), !0);
for (const n in e)
if (Object.prototype.hasOwnProperty.call(e, n) && gi(e[n]))
return !0;
return !1;
}
function zm(e) {
const t = [], n = e.data, s = e;
return s.data = mi(n, t), s.attachments = t.length, { packet: s, buffers: t };
}
function mi(e, t, n) {
if (!e)
return e;
if (Ia(e)) {
const s = { _placeholder: !0, num: t.length };
return t.push(e), s;
} else if (Array.isArray(e)) {
const s = new Array(e.length);
for (let r = 0; r < e.length; r++)
s[r] = mi(e[r], t);
return s;
} else if (typeof e == "object" && !(e instanceof Date)) {
if (e.toJSON && typeof e.toJSON == "function" && !n)
return mi(e.toJSON(), t, !0);
const s = {};
for (const r in e)
Object.prototype.hasOwnProperty.call(e, r) && (s[r] = mi(e[r], t));
return s;
}
return e;
}
function Hm(e, t) {
return e.data = Qo(e.data, t), delete e.attachments, e;
}
function Qo(e, t) {
if (!e)
return e;
if (e && e._placeholder === !0) {
if (typeof e.num == "number" && e.num >= 0 && e.num < t.length)
return t[e.num];
throw new Error("illegal attachments");
} else if (Array.isArray(e))
for (let n = 0; n < e.length; n++)
e[n] = Qo(e[n], t);
else if (typeof e == "object")
for (const n in e)
Object.prototype.hasOwnProperty.call(e, n) && (e[n] = Qo(e[n], t));
return e;
}
const Wm = [
"connect",
// used on the client side
"connect_error",
// used on the client side
"disconnect",
// used on both sides
"disconnecting",
// used on the server side
"newListener",
// used by the Node.js EventEmitter
"removeListener"
// used by the Node.js EventEmitter
];
var Me;
(function(e) {
e[e.CONNECT = 0] = "CONNECT", e[e.DISCONNECT = 1] = "DISCONNECT", e[e.EVENT = 2] = "EVENT", e[e.ACK = 3] = "ACK", e[e.CONNECT_ERROR = 4] = "CONNECT_ERROR", e[e.BINARY_EVENT = 5] = "BINARY_EVENT", e[e.BINARY_ACK = 6] = "BINARY_ACK";
})(Me || (Me = {}));
class qm {
/**
* Encoder constructor
*
* @param {function} replacer - custom replacer to pass down to JSON.parse
*/
constructor(t) {
this.replacer = t;
}
/**
* Encode a packet as a single string if non-binary, or as a
* buffer sequence, depending on packet type.
*
* @param {Object} obj - packet object
*/
encode(t) {
return (t.type === Me.EVENT || t.type === Me.ACK) && gi(t) ? this.encodeAsBinary({
type: t.type === Me.EVENT ? Me.BINARY_EVENT : Me.BINARY_ACK,
nsp: t.nsp,
data: t.data,
id: t.id
}) : [this.encodeAsString(t)];
}
/**
* Encode packet as string.
*/
encodeAsString(t) {
let n = "" + t.type;
return (t.type === Me.BINARY_EVENT || t.type === Me.BINARY_ACK) && (n += t.attachments + "-"), t.nsp && t.nsp !== "/" && (n += t.nsp + ","), t.id != null && (n += t.id), t.data != null && (n += JSON.stringify(t.data, this.replacer)), n;
}
/**
* Encode packet as 'buffer sequence' by removing blobs, and
* deconstructing packet into object with placeholders and
* a list of buffers.
*/
encodeAsBinary(t) {
const n = zm(t), s = this.encodeAsString(n.packet), r = n.buffers;
return r.unshift(s), r;
}
}
class La extends gt {
/**
* Decoder constructor
*/
constructor(t) {
super(), this.opts = Object.assign({
reviver: void 0,
maxAttachments: 10
}, typeof t == "function" ? { reviver: t } : t);
}
/**
* Decodes an encoded packet string into packet JSON.
*
* @param {String} obj - encoded packet
*/
add(t) {
let n;
if (typeof t == "string") {
if (this.reconstructor)
throw new Error("got plaintext data when reconstructing a packet");
n = this.decodeString(t);
const s = n.type === Me.BINARY_EVENT;
s || n.type === Me.BINARY_ACK ? (n.type = s ? Me.EVENT : Me.ACK, this.reconstructor = new jm(n)) : super.emitReserved("decoded", n);
} else if (Ia(t) || t.base64)
if (this.reconstructor)
n = this.reconstructor.takeBinaryData(t), n && (this.reconstructor = null, super.emitReserved("decoded", n));
else
throw new Error("got binary data when not reconstructing a packet");
else
throw new Error("Unknown type: " + t);
}
/**
* Decode a packet String (JSON data)
*
* @param {String} str
* @return {Object} packet
*/
decodeString(t) {
let n = 0;
const s = {
type: Number(t.charAt(0))
};
if (Me[s.type] === void 0)
throw new Error("unknown packet type " + s.type);
if (s.type === Me.BINARY_EVENT || s.type === Me.BINARY_ACK) {
const i = n + 1;
for (; t.charAt(++n) !== "-" && n != t.length; )
;
const o = t.substring(i, n);
if (o != Number(o) || t.charAt(n) !== "-")
throw new Error("Illegal attachments");
const a = Number(o);
if (!Vm(a) || a < 1)
throw new Error("Illegal attachments");
if (a > this.opts.maxAttachments)
throw new Error("too many attachments");
s.attachments = a;
}
if (t.charAt(n + 1) === "/") {
const i = n + 1;
for (; ++n && !(t.charAt(n) === "," || n === t.length); )
;
s.nsp = t.substring(i, n);
} else
s.nsp = "/";
const r = t.charAt(n + 1);
if (r !== "" && Number(r) == r) {
const i = n + 1;
for (; ++n; ) {
const o = t.charAt(n);
if (o == null || Number(o) != o) {
--n;
break;
}
if (n === t.length)
break;
}
s.id = Number(t.substring(i, n + 1));
}
if (t.charAt(++n)) {
const i = this.tryParse(t.substr(n));
if (La.isPayloadValid(s.type, i))
s.data = i;
else
throw new Error("invalid payload");
}
return s;
}
tryParse(t) {
try {
return JSON.parse(t, this.opts.reviver);
} catch {
return !1;
}
}
static isPayloadValid(t, n) {
switch (t) {
case Me.CONNECT:
return sc(n);
case Me.DISCONNECT:
return n === void 0;
case Me.CONNECT_ERROR:
return typeof n == "string" || sc(n);
case Me.EVENT:
case Me.BINARY_EVENT:
return Array.isArray(n) && (typeof n[0] == "number" || typeof n[0] == "string" && Wm.indexOf(n[0]) === -1);
case Me.ACK:
case Me.BINARY_ACK:
return Array.isArray(n);
}
}
/**
* Deallocates a parser's resources
*/
destroy() {
this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
}
}
class jm {
constructor(t) {
this.packet = t, this.buffers = [], this.reconPack = t;
}
/**
* Method to be called when binary data received from connection
* after a BINARY_EVENT packet.
*
* @param {Buffer | ArrayBuffer} binData - the raw binary data received
* @return {null | Object} returns null if more binary data is expected or
* a reconstructed packet object if all buffers have been received.
*/
takeBinaryData(t) {
if (this.buffers.push(t), this.buffers.length === this.reconPack.attachments) {
const n = Hm(this.reconPack, this.buffers);
return this.finishedReconstruction(), n;
}
return null;
}
/**
* Cleans up binary packet reconstruction variables.
*/
finishedReconstruction() {
this.reconPack = null, this.buffers = [];
}
}
const Vm = Number.isInteger || function(e) {
return typeof e == "number" && isFinite(e) && Math.floor(e) === e;
};
function sc(e) {
return Object.prototype.toString.call(e) === "[object Object]";
}
const Km = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
Decoder: La,
Encoder: qm,
get PacketType() {
return Me;
}
}, Symbol.toStringTag, { value: "Module" }));
function ln(e, t, n) {
return e.on(t, n), function() {
e.off(t, n);
};
}
const Gm = Object.freeze({
connect: 1,
connect_error: 1,
disconnect: 1,
disconnecting: 1,
// EventEmitter reserved events: https://nodejs.org/api/events.html#events_event_newlistener
newListener: 1,
removeListener: 1
});
class Ku extends gt {
/**
* `Socket` constructor.
*/
constructor(t, n, s) {
super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = t, this.nsp = n, s && s.auth && (this.auth = s.auth), this._opts = Object.assign({}, s), this.io._autoConnect && this.open();
}
/**
* Whether the socket is currently disconnected
*
* @example
* const socket = io();
*
* socket.on("connect", () => {
* console.log(socket.disconnected); // false
* });
*
* socket.on("disconnect", () => {
* console.log(socket.disconnected); // true
* });
*/
get disconnected() {
return !this.connected;
}
/**
* Subscribe to open, close and packet events
*
* @private
*/
subEvents() {
if (this.subs)
return;
const t = this.io;
this.subs = [
ln(t, "open", this.onopen.bind(this)),
ln(t, "packet", this.onpacket.bind(this)),
ln(t, "error", this.onerror.bind(this)),
ln(t, "close", this.onclose.bind(this))
];
}
/**
* Whether the Socket will try to reconnect when its Manager connects or reconnects.
*
* @example
* const socket = io();
*
* console.log(socket.active); // true
*
* socket.on("disconnect", (reason) => {
* if (reason === "io server disconnect") {
* // the disconnection was initiated by the server, you need to manually reconnect
* console.log(socket.active); // false
* }
* // else the socket will automatically try to reconnect
* console.log(socket.active); // true
* });
*/
get active() {
return !!this.subs;
}
/**
* "Opens" the socket.
*
* @example
* const socket = io({
* autoConnect: false
* });
*
* socket.connect();
*/
connect() {
return this.connected ? this : (this.subEvents(), this.io._reconnecting || this.io.open(), this.io._readyState === "open" && this.onopen(), this);
}
/**
* Alias for {@link connect()}.
*/
open() {
return this.connect();
}
/**
* Sends a `message` event.
*
* This method mimics the WebSocket.send() method.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send
*
* @example
* socket.send("hello");
*
* // this is equivalent to
* socket.emit("message", "hello");
*
* @return self
*/
send(...t) {
return t.unshift("message"), this.emit.apply(this, t), this;
}
/**
* Override `emit`.
* If the event is in `events`, it's emitted normally.
*
* @example
* socket.emit("hello", "world");
*
* // all serializable datastructures are supported (no need to call JSON.stringify)
* socket.emit("hello", 1, "2", { 3: ["4"], 5: Uint8Array.from([6]) });
*
* // with an acknowledgement from the server
* socket.emit("hello", "world", (val) => {
* // ...
* });
*
* @return self
*/
emit(t, ...n) {
var s, r, i;
if (Gm.hasOwnProperty(t))
throw new Error('"' + t.toString() + '" is a reserved event name');
if (n.unshift(t), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
return this._addToQueue(n), this;
const o = {
type: Me.EVENT,
data: n
};
if (o.options = {}, o.options.compress = this.flags.compress !== !1, typeof n[n.length - 1] == "function") {
const c = this.ids++, b = n.pop();
this._registerAckCallback(c, b), o.id = c;
}
const a = (r = (s = this.io.engine) === null || s === void 0 ? void 0 : s.transport) === null || r === void 0 ? void 0 : r.writable, l = this.connected && !(!((i = this.io.engine) === null || i === void 0) && i._hasPingExpired());
return this.flags.volatile && !a || (l ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
}
/**
* @private
*/
_registerAckCallback(t, n) {
var s;
const r = (s = this.flags.timeout) !== null && s !== void 0 ? s : this._opts.ackTimeout;
if (r === void 0) {
this.acks[t] = n;
return;
}
const i = this.io.setTimeoutFn(() => {
delete this.acks[t];
for (let a = 0; a < this.sendBuffer.length; a++)
this.sendBuffer[a].id === t && this.sendBuffer.splice(a, 1);
n.call(this, new Error("operation has timed out"));
}, r), o = (...a) => {
this.io.clearTimeoutFn(i), n.apply(this, a);
};
o.withError = !0, this.acks[t] = o;
}
/**
* Emits an event and waits for an acknowledgement
*
* @example
* // without timeout
* const response = await socket.emitWithAck("hello", "world");
*
* // with a specific timeout
* try {
* const response = await socket.timeout(1000).emitWithAck("hello", "world");
* } catch (err) {
* // the server did not acknowledge the event in the given delay
* }
*
* @return a Promise that will be fulfilled when the server acknowledges the event
*/
emitWithAck(t, ...n) {
return new Promise((s, r) => {
const i = (o, a) => o ? r(o) : s(a);
i.withError = !0, n.push(i), this.emit(t, ...n);
});
}
/**
* Add the packet to the queue.
* @param args
* @private
*/
_addToQueue(t) {
let n;
typeof t[t.length - 1] == "function" && (n = t.pop());
const s = {
id: this._queueSeq++,
tryCount: 0,
pending: !1,
args: t,
flags: Object.assign({ fromQueue: !0 }, this.flags)
};
t.push((r, ...i) => (this._queue[0], r !== null ? s.tryCount > this._opts.retries && (this._queue.shift(), n && n(r)) : (this._queue.shift(), n && n(null, ...i)), s.pending = !1, this._drainQueue())), this._queue.push(s), this._drainQueue();
}
/**
* Send the first packet of the queue, and wait for an acknowledgement from the server.
* @param force - whether to resend a packet that has not been acknowledged yet
*
* @private
*/
_drainQueue(t = !1) {
if (!this.connected || this._queue.length === 0)
return;
const n = this._queue[0];
n.pending && !t || (n.pending = !0, n.tryCount++, this.flags = n.flags, this.emit.apply(this, n.args));
}
/**
* Sends a packet.
*
* @param packet
* @private
*/
packet(t) {
t.nsp = this.nsp, this.io._packet(t);
}
/**
* Called upon engine `open`.
*
* @private
*/
onopen() {
typeof this.auth == "function" ? this.auth((t) => {
this._sendConnectPacket(t);
}) : this._sendConnectPacket(this.auth);
}
/**
* Sends a CONNECT packet to initiate the Socket.IO session.
*
* @param data
* @private
*/
_sendConnectPacket(t) {
this.packet({
type: Me.CONNECT,
data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, t) : t
});
}
/**
* Called upon engine or manager `error`.
*
* @param err
* @private
*/
onerror(t) {
this.connected || this.emitReserved("connect_error", t);
}
/**
* Called upon engine `close`.
*
* @param reason
* @param description
* @private
*/
onclose(t, n) {
this.connected = !1, delete this.id, this.emitReserved("disconnect", t, n), this._clearAcks();
}
/**
* Clears the acknowledgement handlers upon disconnection, since the client will never receive an acknowledgement from
* the server.
*
* @private
*/
_clearAcks() {
Object.keys(this.acks).forEach((t) => {
if (!this.sendBuffer.some((s) => String(s.id) === t)) {
const s = this.acks[t];
delete this.acks[t], s.withError && s.call(this, new Error("socket has been disconnected"));
}
});
}
/**
* Called with socket packet.
*
* @param packet
* @private
*/
onpacket(t) {
if (t.nsp === this.nsp)
switch (t.type) {
case Me.CONNECT:
t.data && t.data.sid ? this.onconnect(t.data.sid, t.data.pid) : this.emitReserved("connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
break;
case Me.EVENT:
case Me.BINARY_EVENT:
this.onevent(t);
break;
case Me.ACK:
case Me.BINARY_ACK:
this.onack(t);
break;
case Me.DISCONNECT:
this.ondisconnect();
break;
case Me.CONNECT_ERROR:
this.destroy();
const s = new Error(t.data.message);
s.data = t.data.data, this.emitReserved("connect_error", s);
break;
}
}
/**
* Called upon a server event.
*
* @param packet
* @private
*/
onevent(t) {
const n = t.data || [];
t.id != null && n.push(this.ack(t.id)), this.connected ? this.emitEvent(n) : this.receiveBuffer.push(Object.freeze(n));
}
emitEvent(t) {
if (this._anyListeners && this._anyListeners.length) {
const n = this._anyListeners.slice();
for (const s of n)
s.apply(this, t);
}
super.emit.apply(this, t), this._pid && t.length && typeof t[t.length - 1] == "string" && (this._lastOffset = t[t.length - 1]);
}
/**
* Produces an ack callback to emit with an event.
*
* @private
*/
ack(t) {
const n = this;
let s = !1;
return function(...r) {
s || (s = !0, n.packet({
type: Me.ACK,
id: t,
data: r
}));
};
}
/**
* Called upon a server acknowledgement.
*
* @param packet
* @private
*/
onack(t) {
const n = this.acks[t.id];
typeof n == "function" && (delete this.acks[t.id], n.withError && t.data.unshift(null), n.apply(this, t.data));
}
/**
* Called upon server connect.
*
* @private
*/
onconnect(t, n) {
this.id = t, this.recovered = n && this._pid === n, this._pid = n, this.connected = !0, this.emitBuffered(), this._drainQueue(!0), this.emitReserved("connect");
}
/**
* Emit buffered events (received and emitted).
*
* @private
*/
emitBuffered() {
this.receiveBuffer.forEach((t) => this.emitEvent(t)), this.receiveBuffer = [], this.sendBuffer.forEach((t) => {
this.notifyOutgoingListeners(t), this.packet(t);
}), this.sendBuffer = [];
}
/**
* Called upon server disconnect.
*
* @private
*/
ondisconnect() {
this.destroy(), this.onclose("io server disconnect");
}
/**
* Called upon forced client/server side disconnections,
* this method ensures the manager stops tracking us and
* that reconnections don't get triggered for this.
*
* @private
*/
destroy() {
this.subs && (this.subs.forEach((t) => t()), this.subs = void 0), this.io._destroy(this);
}
/**
* Disconnects the socket manually. In that case, the socket will not try to reconnect.
*
* If this is the last active Socket instance of the {@link Manager}, the low-level connection will be closed.
*
* @example
* const socket = io();
*
* socket.on("disconnect", (reason) => {
* // console.log(reason); prints "io client disconnect"
* });
*
* socket.disconnect();
*
* @return self
*/
disconnect() {
return this.connected && this.packet({ type: Me.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
}
/**
* Alias for {@link disconnect()}.
*
* @return self
*/
close() {
return this.disconnect();
}
/**
* Sets the compress flag.
*
* @example
* socket.compress(false).emit("hello");
*
* @param compress - if `true`, compresses the sending data
* @return self
*/
compress(t) {
return this.flags.compress = t, this;
}
/**
* Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not
* ready to send messages.
*
* @example
* socket.volatile.emit("hello"); // the server may or may not receive it
*
* @returns self
*/
get volatile() {
return this.flags.volatile = !0, this;
}
/**
* Sets a modifier for a subsequent event emission that the callback will be called with an error when the
* given number of milliseconds have elapsed without an acknowledgement from the server:
*
* @example
* socket.timeout(5000).emit("my-event", (err) => {
* if (err) {
* // the server did not acknowledge the event in the given delay
* }
* });
*
* @returns self
*/
timeout(t) {
return this.flags.timeout = t, this;
}
/**
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
* callback.
*
* @example
* socket.onAny((event, ...args) => {
* console.log(`got ${event}`);
* });
*
* @param listener
*/
onAny(t) {
return this._anyListeners = this._anyListeners || [], this._anyListeners.push(t), this;
}
/**
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
* callback. The listener is added to the beginning of the listeners array.
*
* @example
* socket.prependAny((event, ...args) => {
* console.log(`got event ${event}`);
* });
*
* @param listener
*/
prependAny(t) {
return this._anyListeners = this._anyListeners || [], this._anyListeners.unshift(t), this;
}
/**
* Removes the listener that will be fired when any event is emitted.
*
* @example
* const catchAllListener = (event, ...args) => {
* console.log(`got event ${event}`);
* }
*
* socket.onAny(catchAllListener);
*
* // remove a specific listener
* socket.offAny(catchAllListener);
*
* // or remove all listeners
* socket.offAny();
*
* @param listener
*/
offAny(t) {
if (!this._anyListeners)
return this;
if (t) {
const n = this._anyListeners;
for (let s = 0; s < n.length; s++)
if (t === n[s])
return n.splice(s, 1), this;
} else
this._anyListeners = [];
return this;
}
/**
* Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
* e.g. to remove listeners.
*/
listenersAny() {
return this._anyListeners || [];
}
/**
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
* callback.
*
* Note: acknowledgements sent to the server are not included.
*
* @example
* socket.onAnyOutgoing((event, ...args) => {
* console.log(`sent event ${event}`);
* });
*
* @param listener
*/
onAnyOutgoing(t) {
return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.push(t), this;
}
/**
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
* callback. The listener is added to the beginning of the listeners array.
*
* Note: acknowledgements sent to the server are not included.
*
* @example
* socket.prependAnyOutgoing((event, ...args) => {
* console.log(`sent event ${event}`);
* });
*
* @param listener
*/
prependAnyOutgoing(t) {
return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.unshift(t), this;
}
/**
* Removes the listener that will be fired when any event is emitted.
*
* @example
* const catchAllListener = (event, ...args) => {
* console.log(`sent event ${event}`);
* }
*
* socket.onAnyOutgoing(catchAllListener);
*
* // remove a specific listener
* socket.offAnyOutgoing(catchAllListener);
*
* // or remove all listeners
* socket.offAnyOutgoing();
*
* @param [listener] - the catch-all listener (optional)
*/
offAnyOutgoing(t) {
if (!this._anyOutgoingListeners)
return this;
if (t) {
const n = this._anyOutgoingListeners;
for (let s = 0; s < n.length; s++)
if (t === n[s])
return n.splice(s, 1), this;
} else
this._anyOutgoingListeners = [];
return this;
}
/**
* Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
* e.g. to remove listeners.
*/
listenersAnyOutgoing() {
return this._anyOutgoingListeners || [];
}
/**
* Notify the listeners for each packet sent
*
* @param packet
*
* @private
*/
notifyOutgoingListeners(t) {
if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {
const n = this._anyOutgoingListeners.slice();
for (const s of n)
s.apply(this, t.data);
}
}
}
function qs(e) {
e = e || {}, this.ms = e.min || 100, this.max = e.max || 1e4, this.factor = e.factor || 2, this.jitter = e.jitter > 0 && e.jitter <= 1 ? e.jitter : 0, this.attempts = 0;
}
qs.prototype.duration = function() {
var e = this.ms * Math.pow(this.factor, this.attempts++);
if (this.jitter) {
var t = Math.random(), n = Math.floor(t * this.jitter * e);
e = (Math.floor(t * 10) & 1) == 0 ? e - n : e + n;
}
return Math.min(e, this.max) | 0;
};
qs.prototype.reset = function() {
this.attempts = 0;
};
qs.prototype.setMin = function(e) {
this.ms = e;
};
qs.prototype.setMax = function(e) {
this.max = e;
};
qs.prototype.setJitter = function(e) {
this.jitter = e;
};
class ea extends gt {
constructor(t, n) {
var s;
super(), this.nsps = {}, this.subs = [], t && typeof t == "object" && (n = t, t = void 0), n = n || {}, n.path = n.path || "/socket.io", this.opts = n, Zi(this, n), this.reconnection(n.reconnection !== !1), this.reconnectionAttempts(n.reconnectionAttempts || 1 / 0), this.reconnectionDelay(n.reconnectionDelay || 1e3), this.reconnectionDelayMax(n.reconnectionDelayMax || 5e3), this.randomizationFactor((s = n.randomizationFactor) !== null && s !== void 0 ? s : 0.5), this.backoff = new qs({
min: this.reconnectionDelay(),
max: this.reconnectionDelayMax(),
jitter: this.randomizationFactor()
}), this.timeout(n.timeout == null ? 2e4 : n.timeout), this._readyState = "closed", this.uri = t;
const r = n.parser || Km;
this.encoder = new r.Encoder(), this.decoder = new r.Decoder(), this._autoConnect = n.autoConnect !== !1, this._autoConnect && this.open();
}
reconnection(t) {
return arguments.length ? (this._reconnection = !!t, t || (this.skipReconnect = !0), this) : this._reconnection;
}
reconnectionAttempts(t) {
return t === void 0 ? this._reconnectionAttempts : (this._reconnectionAttempts = t, this);
}
reconnectionDelay(t) {
var n;
return t === void 0 ? this._reconnectionDelay : (this._reconnectionDelay = t, (n = this.backoff) === null || n === void 0 || n.setMin(t), this);
}
randomizationFactor(t) {
var n;
return t === void 0 ? this._randomizationFactor : (this._randomizationFactor = t, (n = this.backoff) === null || n === void 0 || n.setJitter(t), this);
}
reconnectionDelayMax(t) {
var n;
return t === void 0 ? this._reconnectionDelayMax : (this._reconnectionDelayMax = t, (n = this.backoff) === null || n === void 0 || n.setMax(t), this);
}
timeout(t) {
return arguments.length ? (this._timeout = t, this) : this._timeout;
}
/**
* Starts trying to reconnect if reconnection is enabled and we have not
* started reconnecting yet
*
* @private
*/
maybeReconnectOnOpen() {
!this._reconnecting && this._reconnection && this.backoff.attempts === 0 && this.reconnect();
}
/**
* Sets the current transport `socket`.
*
* @param {Function} fn - optional, callback
* @return self
* @public
*/
open(t) {
if (~this._readyState.indexOf("open"))
return this;
this.engine = new Dm(this.uri, this.opts);
const n = this.engine, s = this;
this._readyState = "opening", this.skipReconnect = !1;
const r = ln(n, "open", function() {
s.onopen(), t && t();
}), i = (a) => {
this.cleanup(), this._readyState = "closed", this.emitReserved("error", a), t ? t(a) : this.maybeReconnectOnOpen();
}, o = ln(n, "error", i);
if (this._timeout !== !1) {
const a = this._timeout, l = this.setTimeoutFn(() => {
r(), i(new Error("timeout")), n.close();
}, a);
this.opts.autoUnref && l.unref(), this.subs.push(() => {
this.clearTimeoutFn(l);
});
}
return this.subs.push(r), this.subs.push(o), this;
}
/**
* Alias for open()
*
* @return self
* @public
*/
connect(t) {
return this.open(t);
}
/**
* Called upon transport open.
*
* @private
*/
onopen() {
this.cleanup(), this._readyState = "open", this.emitReserved("open");
const t = this.engine;
this.subs.push(
ln(t, "ping", this.onping.bind(this)),
ln(t, "data", this.ondata.bind(this)),
ln(t, "error", this.onerror.bind(this)),
ln(t, "close", this.onclose.bind(this)),
// @ts-ignore
ln(this.decoder, "decoded", this.ondecoded.bind(this))
);
}
/**
* Called upon a ping.
*
* @private
*/
onping() {
this.emitReserved("ping");
}
/**
* Called with data.
*
* @private
*/
ondata(t) {
try {
this.decoder.add(t);
} catch (n) {
this.onclose("parse error", n);
}
}
/**
* Called when parser fully decodes a packet.
*
* @private
*/
ondecoded(t) {
Yi(() => {
this.emitReserved("packet", t);
}, this.setTimeoutFn);
}
/**
* Called upon socket error.
*
* @private
*/
onerror(t) {
this.emitReserved("error", t);
}
/**
* Creates a new socket for the given `nsp`.
*
* @return {Socket}
* @public
*/
socket(t, n) {
let s = this.nsps[t];
return s ? this._autoConnect && !s.active && s.connect() : (s = new Ku(this, t, n), this.nsps[t] = s), s;
}
/**
* Called upon a socket close.
*
* @param socket
* @private
*/
_destroy(t) {
const n = Object.keys(this.nsps);
for (const s of n)
if (this.nsps[s].active)
return;
this._close();
}
/**
* Writes a packet.
*
* @param packet
* @private
*/
_packet(t) {
const n = this.encoder.encode(t);
for (let s = 0; s < n.length; s++)
this.engine.write(n[s], t.options);
}
/**
* Clean up transport subscriptions and packet buffer.
*
* @private
*/
cleanup() {
this.subs.forEach((t) => t()), this.subs.length = 0, this.decoder.destroy();
}
/**
* Close the current socket.
*
* @private
*/
_close() {
this.skipReconnect = !0, this._reconnecting = !1, this.onclose("forced close");
}
/**
* Alias for close()
*
* @private
*/
disconnect() {
return this._close();
}
/**
* Called when:
*
* - the low-level engine is closed
* - the parser encountered a badly formatted packet
* - all sockets are disconnected
*
* @private
*/
onclose(t, n) {
var s;
this.cleanup(), (s = this.engine) === null || s === void 0 || s.close(), this.backoff.reset(), this._readyState = "closed", this.emitReserved("close", t, n), this._reconnection && !this.skipReconnect && this.reconnect();
}
/**
* Attempt a reconnection.
*
* @private
*/
reconnect() {
if (this._reconnecting || this.skipReconnect)
return this;
const t = this;
if (this.backoff.attempts >= this._reconnectionAttempts)
this.backoff.reset(), this.emitReserved("reconnect_failed"), this._reconnecting = !1;
else {
const n = this.backoff.duration();
this._reconnecting = !0;
const s = this.setTimeoutFn(() => {
t.skipReconnect || (this.emitReserved("reconnect_attempt", t.backoff.attempts), !t.skipReconnect && t.open((r) => {
r ? (t._reconnecting = !1, t.reconnect(), this.emitReserved("reconnect_error", r)) : t.onreconnect();
}));
}, n);
this.opts.autoUnref && s.unref(), this.subs.push(() => {
this.clearTimeoutFn(s);
});
}
}
/**
* Called upon successful reconnect.
*
* @private
*/
onreconnect() {
const t = this.backoff.attempts;
this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", t);
}
}
const _r = {};
function _i(e, t) {
typeof e == "object" && (t = e, e = void 0), t = t || {};
const n = Pm(e, t.path || "/socket.io"), s = n.source, r = n.id, i = n.path, o = _r[r] && i in _r[r].nsps, a = t.forceNew || t["force new connection"] || t.multiplex === !1 || o;
let l;
return a ? l = new ea(s, t) : (_r[r] || (_r[r] = new ea(s, t)), l = _r[r]), n.query && !t.query && (t.query = n.queryKey), l.socket(n.path, t);
}
Object.assign(_i, {
Manager: ea,
Socket: Ku,
io: _i,
connect: _i
});
const Oa = "rpid", Ym = "identity_expired", rc = 0.8, Zm = 720 * 60 * 1e3, Ro = 30 * 1e3, Io = 1e3, zs = (e) => {
if (typeof e != "string") return e ? String(e) : null;
const t = e.trim();
return !t || t === "undefined" || t === "null" ? null : t;
}, yi = (e) => {
const t = zs(e);
if (!t) return null;
const [, n] = t.split(".");
if (!n) return null;
try {
const s = atob(n.replace(/-/g, "+").replace(/_/g, "/"));
return JSON.parse(s);
} catch {
return null;
}
}, Xm = () => {
try {
return zs(localStorage.getItem(Oa));
} catch {
return null;
}
}, ic = (e) => {
try {
localStorage.setItem(Oa, e);
} catch {
}
}, Jm = () => {
try {
localStorage.removeItem(Oa);
} catch {
}
};
function Qm(e = {}) {
const t = ce(null);
let n = null, s = null;
const r = () => {
n && (clearTimeout(n), n = null);
}, i = () => {
const I = yi(t.value);
return I != null && I.exp ? Number(I.exp) - Math.floor(Date.now() / Io) : null;
}, o = () => {
const I = yi(t.value);
if (!(I != null && I.exp)) return !1;
const K = I.iat ? Number(I.exp) - Number(I.iat) : 0, P = i() ?? 0;
return K <= 0 ? P <= 0 : P <= K * (1 - rc);
}, a = (I, { persist: K = !0 } = {}) => {
var oe;
const P = zs(I);
if (r(), t.value = P, !P) {
Jm();
return;
}
K && (ic(P), (oe = e.onTokenChanged) == null || oe.call(e, P)), c();
}, l = async (I) => {
if (!t.value || !I) return !1;
if (s) return s;
const K = t.value;
return s = (async () => {
var P, oe;
try {
const fe = await fetch(`${Ws.API_URL}/refresh-token`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${K}`
},
body: JSON.stringify({ widget_id: I })
});
if (fe.status === 401)
return (P = e.onIdentityExpired) == null || P.call(e), !1;
if (!fe.ok)
return c(Ro), !1;
const pe = await fe.json(), R = zs((oe = pe == null ? void 0 : pe.data) == null ? void 0 : oe.token);
return R ? (a(R), !0) : !1;
} catch {
return c(Ro), !1;
} finally {
s = null;
}
})(), s;
}, d = async (I) => t.value ? o() ? l(I) : !0 : !1, c = (I) => {
r();
const K = yi(t.value);
if (!(K != null && K.exp) || !(K != null && K.iat)) return;
const P = (Number(K.exp) - Number(K.iat)) * Io, oe = (i() ?? 0) * Io, fe = I ?? Math.min(
Zm,
Math.max(0, oe - P * (1 - rc))
);
n = setTimeout(() => {
n = null, d(b).then((pe) => {
c(pe ? void 0 : Ro);
});
}, fe);
};
let b = "";
return {
token: t,
start: (I, K) => {
b = I;
const P = zs(K) || Xm();
a(P, { persist: !1 }), P && ic(P);
},
stop: () => {
r(), s = null;
},
setToken: a,
ensureFresh: d
};
}
const e_ = 5e3;
function t_() {
const e = ce([]), t = ce(!1), n = ce(""), s = ce(!1), r = ce(!1), i = ce(!1), o = ce("connecting"), a = ce(0), l = 5, d = ce({}), c = ce(null), b = ce("");
let w = null;
const z = 6e4, I = () => {
t.value = !1, w && (clearTimeout(w), w = null);
}, K = () => {
t.value = !0, w && clearTimeout(w), w = setTimeout(I, z);
};
let P = null;
const oe = 1e3, fe = 15e3;
let pe = null;
const R = /* @__PURE__ */ new Set(["ai_config_missing", "customer_required"]);
let N = !1;
const Y = ce(null), X = () => {
pe && (clearTimeout(pe), pe = null);
}, xe = () => {
if (pe || N) return;
const E = Math.min(
oe * 2 ** Math.max(0, a.value - 1),
fe
);
pe = setTimeout(() => {
pe = null, P == null || P.connect();
}, E);
};
let Oe = null, _e = null, Pe = null, be = null, Ke = null, Ge, at, ue;
const ye = (E) => {
var O;
return (O = yi(E ?? null)) == null ? void 0 : O.sub;
}, me = (E) => {
Ge = E, E && P != null && P.connected && P.emit("refresh_token", { conversation_token: E });
}, nt = (E) => {
at = E;
}, Ze = () => {
var V;
const E = Ge || localStorage.getItem("rpid"), O = {};
E && (O.conversation_token = E), at && (O.widget_id = at);
try {
O.page_url = window.parent !== window && ((V = window.parent.location) != null && V.href) ? window.parent.location.href : document.referrer || window.location.href;
} catch {
O.page_url = document.referrer || "";
}
return O;
}, Te = (E) => (P = _i(`${Ws.WS_URL}/widget`, {
transports: ["websocket"],
reconnection: !0,
// Keep trying. The old cap of 5 attempts was ~15s of backoff, so a
// backend restart or a laptop waking from sleep left the widget dead
// until the visitor reloaded the page.
reconnectionAttempts: 1 / 0,
reconnectionDelay: 1e3,
reconnectionDelayMax: 15e3,
// Called before every attempt, so a token refreshed since the socket
// was created is the one that gets sent.
auth: (O) => O(Ze())
}), P.on("connect", () => {
ue = ye(Ze().conversation_token), o.value = "connected", X(), a.value = 0;
}), P.on("bot_typing", () => {
K();
}), P.on("disconnect", () => {
I(), o.value === "connected" && (console.log("Socket disconnected, setting connection status to connecting"), o.value = "connecting");
}), P.on("connect_error", (O) => {
var J;
const V = (J = O == null ? void 0 : O.data) == null ? void 0 : J.type;
if (V && R.has(V)) {
N = !0, Y.value = V, X(), o.value = "failed", V !== "customer_required" && Ct(O.data);
return;
}
a.value++, console.error("Socket connection failed, attempt:", a.value), a.value >= l && (o.value = "failed"), P && !P.active && xe();
}), P.on("chat_response", (O) => {
if (I(), O.session_id ? (console.log("Captured session_id from chat_response:", O.session_id), b.value = O.session_id) : console.warn("No session_id in chat_response data:", O), O.type === "agent_message") {
const V = {
message: O.message,
message_type: "agent",
created_at: (/* @__PURE__ */ new Date()).toISOString(),
session_id: "",
agent_name: O.agent_name,
stream: !0,
// live reply → client-side typewriter reveal
attributes: {
end_chat: O.end_chat,
end_chat_reason: O.end_chat_reason,
end_chat_description: O.end_chat_description,
request_rating: O.request_rating
}
};
O.attachments && Array.isArray(O.attachments) && (V.id = O.message_id, V.attachments = O.attachments.map((J, ae) => ({
id: O.message_id * 1e3 + ae,
filename: J.filename,
file_url: J.file_url,
content_type: J.content_type,
file_size: J.file_size
}))), e.value.push(V);
} else O.shopify_output && typeof O.shopify_output == "object" && O.shopify_output.products ? e.value.push({
message: O.message,
// Keep the accompanying text message
message_type: "product",
// Use 'product' type for rendering
created_at: (/* @__PURE__ */ new Date()).toISOString(),
session_id: "",
agent_name: O.agent_name,
// Assign the whole structured object
shopify_output: O.shopify_output,
// Remove the old flattened fields (product_id, product_title, etc.)
attributes: {
// Keep other attributes if needed
end_chat: O.end_chat,
request_rating: O.request_rating
}
}) : e.value.push({
message: O.message,
message_type: "bot",
created_at: (/* @__PURE__ */ new Date()).toISOString(),
session_id: "",
agent_name: O.agent_name,
stream: !0,
// live reply → client-side typewriter reveal
// Knowledge-base citations (display gated by show_citations in the widget)
sources: Array.isArray(O.sources) && O.sources.length ? O.sources : void 0,
attributes: {
end_chat: O.end_chat,
end_chat_reason: O.end_chat_reason,
end_chat_description: O.end_chat_description,
request_rating: O.request_rating
}
});
}), P.on("handle_taken_over", (O) => {
e.value.push({
message: `${O.user_name} 加入了会话`,
message_type: "system",
created_at: (/* @__PURE__ */ new Date()).toISOString(),
session_id: O.session_id
}), d.value = {
...d.value,
human_agent_name: O.user_name,
human_agent_profile_pic: O.profile_picture
}, I(), Oe && Oe(O);
}), P.on("session_initialized", (O) => {
O.session_id && (b.value = O.session_id, Ke = {
session_id: O.session_id,
authenticated: !!O.authenticated,
created: !!O.created
}, be == null || be(Ke));
}), P.on("error", Ct), P.on("chat_history", Rt), P.on("rating_submitted", Dt), P.on("display_form", Yt), P.on("form_submitted", m), P.on("workflow_state", v), P.on("workflow_proceeded", C), P), Je = async () => {
try {
return P != null && P.connected && ue && ue === ye(Ze().conversation_token) ? (o.value = "connected", !0) : (o.value = "connecting", a.value = 0, I(), X(), N = !1, Y.value = null, P && (P.removeAllListeners(), P.disconnect(), P = null), P = Te(""), new Promise((E) => {
P == null || P.on("connect", () => {
E(!0);
}), P == null || P.on("connect_error", () => {
(N || a.value >= l) && E(!1);
});
}));
} catch (E) {
return console.error("Socket initialization failed:", E), o.value = "failed", !1;
}
}, st = () => (P && P.disconnect(), Je()), At = (E) => {
Oe = E;
}, Re = (E) => {
be = E, Ke && E(Ke);
}, yt = (E) => {
_e = E;
}, pt = (E) => {
Pe = E;
}, Ct = (E) => {
I(), n.value = Dd(E), s.value = !0, setTimeout(() => {
s.value = !1, n.value = "";
}, 5e3);
}, Rt = (E) => {
if (E.type === "chat_history" && Array.isArray(E.messages)) {
const O = E.messages.map((V) => {
var ae, we;
const J = {
message: V.message,
message_type: V.message_type,
created_at: V.created_at,
session_id: "",
agent_name: V.agent_name || "",
user_name: V.user_name || "",
attributes: V.attributes || {},
attachments: V.attachments || []
// Include attachments
};
return Array.isArray((ae = V.attributes) == null ? void 0 : ae.sources) && V.attributes.sources.length && (J.sources = V.attributes.sources), (we = V.attributes) != null && we.shopify_output && typeof V.attributes.shopify_output == "object" ? {
...J,
message_type: "product",
shopify_output: V.attributes.shopify_output
} : J;
});
e.value = [
...O.filter(
(V) => !e.value.some(
(J) => J.message === V.message && J.created_at === V.created_at
)
),
...e.value
];
}
}, Dt = (E) => {
E.success && e.value.push({
message: "感谢你的反馈!",
message_type: "system",
created_at: (/* @__PURE__ */ new Date()).toISOString(),
session_id: ""
});
}, Yt = (E) => {
var O;
console.log("Form display handler in composable:", E), I(), c.value = E.form_data, console.log("Set currentForm in handleDisplayForm:", c.value), ((O = E.form_data) == null ? void 0 : O.form_full_screen) === !0 ? (console.log("Full screen form detected, triggering workflow state callback"), _e && _e({
type: "form",
form_data: E.form_data,
session_id: E.session_id
})) : e.value.push({
message: "",
message_type: "form",
created_at: (/* @__PURE__ */ new Date()).toISOString(),
session_id: E.session_id,
attributes: {
form_data: E.form_data
}
});
}, m = (E) => {
console.log("Form submitted confirmation received, clearing currentForm"), c.value = null, E.success && console.log("Form submitted successfully");
}, v = (E) => {
console.log("Workflow state received in composable:", E), (E.type === "form" || E.type === "display_form") && (console.log("Setting currentForm from workflow state:", E.form_data), c.value = E.form_data), _e && _e(E);
}, C = (E) => {
console.log("Workflow proceeded in composable:", E), Pe && Pe(E);
}, M = async (E, O) => {
!P || !E || P.emit("submit_rating", {
rating: E,
feedback: O
});
}, B = async (E) => {
var J;
if (console.log("Submitting form in socket:", E), console.log("Current form in socket:", c.value), console.log("Socket in socket:", P), !P) {
console.error("No socket available for form submission");
return;
}
if (!E || Object.keys(E).length === 0) {
console.error("No form data to submit");
return;
}
const V = ((J = c.value) == null ? void 0 : J.form_type) === "contact" ? "submit_contact_info" : "submit_form";
console.log(`Emitting ${V} event with data:`, E), P.emit(V, {
form_data: E
}), c.value = null;
}, L = async () => {
P && (console.log("Getting workflow state 12"), P.emit("get_workflow_state"));
}, G = async () => {
P && P.emit("proceed_workflow", {});
}, W = async (E, O, V = []) => {
if (!P || !E.trim() && V.length === 0) return;
const J = {
message: E,
message_type: "user",
created_at: (/* @__PURE__ */ new Date()).toISOString(),
session_id: ""
};
V.length > 0 && (J.attachments = V.map((ae, we) => {
let Se = "";
if (ae.content_type.startsWith("image/")) {
const De = atob(ae.content), f = new Array(De.length);
for (let x = 0; x < De.length; x++)
f[x] = De.charCodeAt(x);
const y = new Uint8Array(f), D = new Blob([y], { type: ae.content_type });
Se = URL.createObjectURL(D);
}
return {
id: Date.now() * 1e3 + we,
// Temporary ID
filename: ae.filename,
file_url: Se,
// Temporary blob URL, will be replaced
content_type: ae.content_type,
file_size: ae.size,
_isTemporary: !0
// Flag to identify temporary attachments
};
})), e.value.push(J), P.emit("chat", {
message: E,
email: O,
files: V
// Send files with base64 content
}), i.value = !0;
}, q = () => {
e.value = [], i.value = !1, b.value = "", I(), c.value = null;
};
return {
messages: e,
loading: t,
errorMessage: n,
showError: s,
loadingHistory: r,
hasStartedChat: i,
connectionStatus: o,
sendMessage: W,
endChat: (E = "CUSTOMER_REQUEST") => new Promise((O) => {
if (!P || !P.connected) {
O(!1);
return;
}
let V = !1;
const J = (De) => {
V || (V = !0, clearTimeout(Se), P == null || P.off("chat_ended", ae), P == null || P.off("error", we), De && q(), O(De));
}, ae = () => J(!0), we = (De) => {
(De == null ? void 0 : De.type) === "end_chat_error" && J(!1);
}, Se = setTimeout(() => J(!1), e_);
P.on("chat_ended", ae), P.on("error", we), P.emit("end_chat", { reason: E });
}),
loadChatHistory: async () => {
if (P)
try {
r.value = !0, P.emit("get_chat_history");
} catch (E) {
console.error("Failed to load chat history:", E);
} finally {
r.value = !1;
}
},
connect: Je,
reconnect: st,
cleanup: () => {
I(), X(), P && (P.removeAllListeners(), P.disconnect(), P = null), Oe = null, _e = null, Pe = null;
},
humanAgent: d,
onTakeover: At,
onSessionState: Re,
refusal: Y,
submitRating: M,
currentForm: c,
submitForm: B,
getWorkflowState: L,
proceedWorkflow: G,
onWorkflowState: yt,
onWorkflowProceeded: pt,
currentSessionId: b,
setToken: me,
setWidgetId: nt
};
}
function n_(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var Lo = { exports: {} }, oc;
function s_() {
return oc || (oc = 1, function(e) {
(function() {
function t(f, y, D) {
return f.call.apply(f.bind, arguments);
}
function n(f, y, D) {
if (!f) throw Error();
if (2 < arguments.length) {
var x = Array.prototype.slice.call(arguments, 2);
return function() {
var H = Array.prototype.slice.call(arguments);
return Array.prototype.unshift.apply(H, x), f.apply(y, H);
};
}
return function() {
return f.apply(y, arguments);
};
}
function s(f, y, D) {
return s = Function.prototype.bind && Function.prototype.bind.toString().indexOf("native code") != -1 ? t : n, s.apply(null, arguments);
}
var r = Date.now || function() {
return +/* @__PURE__ */ new Date();
};
function i(f, y) {
this.a = f, this.o = y || f, this.c = this.o.document;
}
var o = !!window.FontFace;
function a(f, y, D, x) {
if (y = f.c.createElement(y), D) for (var H in D) D.hasOwnProperty(H) && (H == "style" ? y.style.cssText = D[H] : y.setAttribute(H, D[H]));
return x && y.appendChild(f.c.createTextNode(x)), y;
}
function l(f, y, D) {
f = f.c.getElementsByTagName(y)[0], f || (f = document.documentElement), f.insertBefore(D, f.lastChild);
}
function d(f) {
f.parentNode && f.parentNode.removeChild(f);
}
function c(f, y, D) {
y = y || [], D = D || [];
for (var x = f.className.split(/\s+/), H = 0; H < y.length; H += 1) {
for (var ne = !1, ee = 0; ee < x.length; ee += 1) if (y[H] === x[ee]) {
ne = !0;
break;
}
ne || x.push(y[H]);
}
for (y = [], H = 0; H < x.length; H += 1) {
for (ne = !1, ee = 0; ee < D.length; ee += 1) if (x[H] === D[ee]) {
ne = !0;
break;
}
ne || y.push(x[H]);
}
f.className = y.join(" ").replace(/\s+/g, " ").replace(/^\s+|\s+$/, "");
}
function b(f, y) {
for (var D = f.className.split(/\s+/), x = 0, H = D.length; x < H; x++) if (D[x] == y) return !0;
return !1;
}
function w(f) {
return f.o.location.hostname || f.a.location.hostname;
}
function z(f, y, D) {
function x() {
Ie && H && ne && (Ie(ee), Ie = null);
}
y = a(f, "link", { rel: "stylesheet", href: y, media: "all" });
var H = !1, ne = !0, ee = null, Ie = D || null;
o ? (y.onload = function() {
H = !0, x();
}, y.onerror = function() {
H = !0, ee = Error("Stylesheet failed to load"), x();
}) : setTimeout(function() {
H = !0, x();
}, 0), l(f, "head", y);
}
function I(f, y, D, x) {
var H = f.c.getElementsByTagName("head")[0];
if (H) {
var ne = a(f, "script", { src: y }), ee = !1;
return ne.onload = ne.onreadystatechange = function() {
ee || this.readyState && this.readyState != "loaded" && this.readyState != "complete" || (ee = !0, D && D(null), ne.onload = ne.onreadystatechange = null, ne.parentNode.tagName == "HEAD" && H.removeChild(ne));
}, H.appendChild(ne), setTimeout(function() {
ee || (ee = !0, D && D(Error("Script load timeout")));
}, x || 5e3), ne;
}
return null;
}
function K() {
this.a = 0, this.c = null;
}
function P(f) {
return f.a++, function() {
f.a--, fe(f);
};
}
function oe(f, y) {
f.c = y, fe(f);
}
function fe(f) {
f.a == 0 && f.c && (f.c(), f.c = null);
}
function pe(f) {
this.a = f || "-";
}
pe.prototype.c = function(f) {
for (var y = [], D = 0; D < arguments.length; D++) y.push(arguments[D].replace(/[\W_]+/g, "").toLowerCase());
return y.join(this.a);
};
function R(f, y) {
this.c = f, this.f = 4, this.a = "n";
var D = (y || "n4").match(/^([nio])([1-9])$/i);
D && (this.a = D[1], this.f = parseInt(D[2], 10));
}
function N(f) {
return xe(f) + " " + (f.f + "00") + " 300px " + Y(f.c);
}
function Y(f) {
var y = [];
f = f.split(/,\s*/);
for (var D = 0; D < f.length; D++) {
var x = f[D].replace(/['"]/g, "");
x.indexOf(" ") != -1 || /^\d/.test(x) ? y.push("'" + x + "'") : y.push(x);
}
return y.join(",");
}
function X(f) {
return f.a + f.f;
}
function xe(f) {
var y = "normal";
return f.a === "o" ? y = "oblique" : f.a === "i" && (y = "italic"), y;
}
function Oe(f) {
var y = 4, D = "n", x = null;
return f && ((x = f.match(/(normal|oblique|italic)/i)) && x[1] && (D = x[1].substr(0, 1).toLowerCase()), (x = f.match(/([1-9]00|normal|bold)/i)) && x[1] && (/bold/i.test(x[1]) ? y = 7 : /[1-9]00/.test(x[1]) && (y = parseInt(x[1].substr(0, 1), 10)))), D + y;
}
function _e(f, y) {
this.c = f, this.f = f.o.document.documentElement, this.h = y, this.a = new pe("-"), this.j = y.events !== !1, this.g = y.classes !== !1;
}
function Pe(f) {
f.g && c(f.f, [f.a.c("wf", "loading")]), Ke(f, "loading");
}
function be(f) {
if (f.g) {
var y = b(f.f, f.a.c("wf", "active")), D = [], x = [f.a.c("wf", "loading")];
y || D.push(f.a.c("wf", "inactive")), c(f.f, D, x);
}
Ke(f, "inactive");
}
function Ke(f, y, D) {
f.j && f.h[y] && (D ? f.h[y](D.c, X(D)) : f.h[y]());
}
function Ge() {
this.c = {};
}
function at(f, y, D) {
var x = [], H;
for (H in y) if (y.hasOwnProperty(H)) {
var ne = f.c[H];
ne && x.push(ne(y[H], D));
}
return x;
}
function ue(f, y) {
this.c = f, this.f = y, this.a = a(this.c, "span", { "aria-hidden": "true" }, this.f);
}
function ye(f) {
l(f.c, "body", f.a);
}
function me(f) {
return "display:block;position:absolute;top:-9999px;left:-9999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;white-space:nowrap;font-family:" + Y(f.c) + ";" + ("font-style:" + xe(f) + ";font-weight:" + (f.f + "00") + ";");
}
function nt(f, y, D, x, H, ne) {
this.g = f, this.j = y, this.a = x, this.c = D, this.f = H || 3e3, this.h = ne || void 0;
}
nt.prototype.start = function() {
var f = this.c.o.document, y = this, D = r(), x = new Promise(function(ee, Ie) {
function Le() {
r() - D >= y.f ? Ie() : f.fonts.load(N(y.a), y.h).then(function(Ce) {
1 <= Ce.length ? ee() : setTimeout(Le, 25);
}, function() {
Ie();
});
}
Le();
}), H = null, ne = new Promise(function(ee, Ie) {
H = setTimeout(Ie, y.f);
});
Promise.race([ne, x]).then(function() {
H && (clearTimeout(H), H = null), y.g(y.a);
}, function() {
y.j(y.a);
});
};
function Ze(f, y, D, x, H, ne, ee) {
this.v = f, this.B = y, this.c = D, this.a = x, this.s = ee || "BESbswy", this.f = {}, this.w = H || 3e3, this.u = ne || null, this.m = this.j = this.h = this.g = null, this.g = new ue(this.c, this.s), this.h = new ue(this.c, this.s), this.j = new ue(this.c, this.s), this.m = new ue(this.c, this.s), f = new R(this.a.c + ",serif", X(this.a)), f = me(f), this.g.a.style.cssText = f, f = new R(this.a.c + ",sans-serif", X(this.a)), f = me(f), this.h.a.style.cssText = f, f = new R("serif", X(this.a)), f = me(f), this.j.a.style.cssText = f, f = new R("sans-serif", X(this.a)), f = me(f), this.m.a.style.cssText = f, ye(this.g), ye(this.h), ye(this.j), ye(this.m);
}
var Te = { D: "serif", C: "sans-serif" }, Je = null;
function st() {
if (Je === null) {
var f = /AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);
Je = !!f && (536 > parseInt(f[1], 10) || parseInt(f[1], 10) === 536 && 11 >= parseInt(f[2], 10));
}
return Je;
}
Ze.prototype.start = function() {
this.f.serif = this.j.a.offsetWidth, this.f["sans-serif"] = this.m.a.offsetWidth, this.A = r(), Re(this);
};
function At(f, y, D) {
for (var x in Te) if (Te.hasOwnProperty(x) && y === f.f[Te[x]] && D === f.f[Te[x]]) return !0;
return !1;
}
function Re(f) {
var y = f.g.a.offsetWidth, D = f.h.a.offsetWidth, x;
(x = y === f.f.serif && D === f.f["sans-serif"]) || (x = st() && At(f, y, D)), x ? r() - f.A >= f.w ? st() && At(f, y, D) && (f.u === null || f.u.hasOwnProperty(f.a.c)) ? pt(f, f.v) : pt(f, f.B) : yt(f) : pt(f, f.v);
}
function yt(f) {
setTimeout(s(function() {
Re(this);
}, f), 50);
}
function pt(f, y) {
setTimeout(s(function() {
d(this.g.a), d(this.h.a), d(this.j.a), d(this.m.a), y(this.a);
}, f), 0);
}
function Ct(f, y, D) {
this.c = f, this.a = y, this.f = 0, this.m = this.j = !1, this.s = D;
}
var Rt = null;
Ct.prototype.g = function(f) {
var y = this.a;
y.g && c(y.f, [y.a.c("wf", f.c, X(f).toString(), "active")], [y.a.c("wf", f.c, X(f).toString(), "loading"), y.a.c("wf", f.c, X(f).toString(), "inactive")]), Ke(y, "fontactive", f), this.m = !0, Dt(this);
}, Ct.prototype.h = function(f) {
var y = this.a;
if (y.g) {
var D = b(y.f, y.a.c("wf", f.c, X(f).toString(), "active")), x = [], H = [y.a.c("wf", f.c, X(f).toString(), "loading")];
D || x.push(y.a.c("wf", f.c, X(f).toString(), "inactive")), c(y.f, x, H);
}
Ke(y, "fontinactive", f), Dt(this);
};
function Dt(f) {
--f.f == 0 && f.j && (f.m ? (f = f.a, f.g && c(f.f, [f.a.c("wf", "active")], [f.a.c("wf", "loading"), f.a.c("wf", "inactive")]), Ke(f, "active")) : be(f.a));
}
function Yt(f) {
this.j = f, this.a = new Ge(), this.h = 0, this.f = this.g = !0;
}
Yt.prototype.load = function(f) {
this.c = new i(this.j, f.context || this.j), this.g = f.events !== !1, this.f = f.classes !== !1, v(this, new _e(this.c, f), f);
};
function m(f, y, D, x, H) {
var ne = --f.h == 0;
(f.f || f.g) && setTimeout(function() {
var ee = H || null, Ie = x || null || {};
if (D.length === 0 && ne) be(y.a);
else {
y.f += D.length, ne && (y.j = ne);
var Le, Ce = [];
for (Le = 0; Le < D.length; Le++) {
var $e = D[Le], Xe = Ie[$e.c], wt = y.a, on = $e;
if (wt.g && c(wt.f, [wt.a.c("wf", on.c, X(on).toString(), "loading")]), Ke(wt, "fontloading", on), wt = null, Rt === null) if (window.FontFace) {
var on = /Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent), kn = /OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent) && /Apple/.exec(window.navigator.vendor);
Rt = on ? 42 < parseInt(on[1], 10) : !kn;
} else Rt = !1;
Rt ? wt = new nt(s(y.g, y), s(y.h, y), y.c, $e, y.s, Xe) : wt = new Ze(s(y.g, y), s(y.h, y), y.c, $e, y.s, ee, Xe), Ce.push(wt);
}
for (Le = 0; Le < Ce.length; Le++) Ce[Le].start();
}
}, 0);
}
function v(f, y, D) {
var H = [], x = D.timeout;
Pe(y);
var H = at(f.a, D, f.c), ne = new Ct(f.c, y, x);
for (f.h = H.length, y = 0, D = H.length; y < D; y++) H[y].load(function(ee, Ie, Le) {
m(f, ne, ee, Ie, Le);
});
}
function C(f, y) {
this.c = f, this.a = y;
}
C.prototype.load = function(f) {
function y() {
if (ne["__mti_fntLst" + x]) {
var ee = ne["__mti_fntLst" + x](), Ie = [], Le;
if (ee) for (var Ce = 0; Ce < ee.length; Ce++) {
var $e = ee[Ce].fontfamily;
ee[Ce].fontStyle != null && ee[Ce].fontWeight != null ? (Le = ee[Ce].fontStyle + ee[Ce].fontWeight, Ie.push(new R($e, Le))) : Ie.push(new R($e));
}
f(Ie);
} else setTimeout(function() {
y();
}, 50);
}
var D = this, x = D.a.projectId, H = D.a.version;
if (x) {
var ne = D.c.o;
I(this.c, (D.a.api || "https://fast.fonts.net/jsapi") + "/" + x + ".js" + (H ? "?v=" + H : ""), function(ee) {
ee ? f([]) : (ne["__MonotypeConfiguration__" + x] = function() {
return D.a;
}, y());
}).id = "__MonotypeAPIScript__" + x;
} else f([]);
};
function M(f, y) {
this.c = f, this.a = y;
}
M.prototype.load = function(f) {
var y, D, x = this.a.urls || [], H = this.a.families || [], ne = this.a.testStrings || {}, ee = new K();
for (y = 0, D = x.length; y < D; y++) z(this.c, x[y], P(ee));
var Ie = [];
for (y = 0, D = H.length; y < D; y++) if (x = H[y].split(":"), x[1]) for (var Le = x[1].split(","), Ce = 0; Ce < Le.length; Ce += 1) Ie.push(new R(x[0], Le[Ce]));
else Ie.push(new R(x[0]));
oe(ee, function() {
f(Ie, ne);
});
};
function B(f, y) {
f ? this.c = f : this.c = L, this.a = [], this.f = [], this.g = y || "";
}
var L = "https://fonts.googleapis.com/css";
function G(f, y) {
for (var D = y.length, x = 0; x < D; x++) {
var H = y[x].split(":");
H.length == 3 && f.f.push(H.pop());
var ne = "";
H.length == 2 && H[1] != "" && (ne = ":"), f.a.push(H.join(ne));
}
}
function W(f) {
if (f.a.length == 0) throw Error("No fonts to load!");
if (f.c.indexOf("kit=") != -1) return f.c;
for (var y = f.a.length, D = [], x = 0; x < y; x++) D.push(f.a[x].replace(/ /g, "+"));
return y = f.c + "?family=" + D.join("%7C"), 0 < f.f.length && (y += "&subset=" + f.f.join(",")), 0 < f.g.length && (y += "&text=" + encodeURIComponent(f.g)), y;
}
function q(f) {
this.f = f, this.a = [], this.c = {};
}
var U = { latin: "BESbswy", "latin-ext": "çöüğş", cyrillic: "йяЖ", greek: "αβΣ", khmer: "កខគ", Hanuman: "កខគ" }, te = { thin: "1", extralight: "2", "extra-light": "2", ultralight: "2", "ultra-light": "2", light: "3", regular: "4", book: "4", medium: "5", "semi-bold": "6", semibold: "6", "demi-bold": "6", demibold: "6", bold: "7", "extra-bold": "8", extrabold: "8", "ultra-bold": "8", ultrabold: "8", black: "9", heavy: "9", l: "3", r: "4", b: "7" }, Z = { i: "i", italic: "i", n: "n", normal: "n" }, E = /^(thin|(?:(?:extra|ultra)-?)?light|regular|book|medium|(?:(?:semi|demi|extra|ultra)-?)?bold|black|heavy|l|r|b|[1-9]00)?(n|i|normal|italic)?$/;
function O(f) {
for (var y = f.f.length, D = 0; D < y; D++) {
var x = f.f[D].split(":"), H = x[0].replace(/\+/g, " "), ne = ["n4"];
if (2 <= x.length) {
var ee, Ie = x[1];
if (ee = [], Ie) for (var Ie = Ie.split(","), Le = Ie.length, Ce = 0; Ce < Le; Ce++) {
var $e;
if ($e = Ie[Ce], $e.match(/^[\w-]+$/)) {
var Xe = E.exec($e.toLowerCase());
if (Xe == null) $e = "";
else {
if ($e = Xe[2], $e = $e == null || $e == "" ? "n" : Z[$e], Xe = Xe[1], Xe == null || Xe == "") Xe = "4";
else var wt = te[Xe], Xe = wt || (isNaN(Xe) ? "4" : Xe.substr(0, 1));
$e = [$e, Xe].join("");
}
} else $e = "";
$e && ee.push($e);
}
0 < ee.length && (ne = ee), x.length == 3 && (x = x[2], ee = [], x = x ? x.split(",") : ee, 0 < x.length && (x = U[x[0]]) && (f.c[H] = x));
}
for (f.c[H] || (x = U[H]) && (f.c[H] = x), x = 0; x < ne.length; x += 1) f.a.push(new R(H, ne[x]));
}
}
function V(f, y) {
this.c = f, this.a = y;
}
var J = { Arimo: !0, Cousine: !0, Tinos: !0 };
V.prototype.load = function(f) {
var y = new K(), D = this.c, x = new B(this.a.api, this.a.text), H = this.a.families;
G(x, H);
var ne = new q(H);
O(ne), z(D, W(x), P(y)), oe(y, function() {
f(ne.a, ne.c, J);
});
};
function ae(f, y) {
this.c = f, this.a = y;
}
ae.prototype.load = function(f) {
var y = this.a.id, D = this.c.o;
y ? I(this.c, (this.a.api || "https://use.typekit.net") + "/" + y + ".js", function(x) {
if (x) f([]);
else if (D.Typekit && D.Typekit.config && D.Typekit.config.fn) {
x = D.Typekit.config.fn;
for (var H = [], ne = 0; ne < x.length; ne += 2) for (var ee = x[ne], Ie = x[ne + 1], Le = 0; Le < Ie.length; Le++) H.push(new R(ee, Ie[Le]));
try {
D.Typekit.load({ events: !1, classes: !1, async: !0 });
} catch {
}
f(H);
}
}, 2e3) : f([]);
};
function we(f, y) {
this.c = f, this.f = y, this.a = [];
}
we.prototype.load = function(f) {
var y = this.f.id, D = this.c.o, x = this;
y ? (D.__webfontfontdeckmodule__ || (D.__webfontfontdeckmodule__ = {}), D.__webfontfontdeckmodule__[y] = function(H, ne) {
for (var ee = 0, Ie = ne.fonts.length; ee < Ie; ++ee) {
var Le = ne.fonts[ee];
x.a.push(new R(Le.name, Oe("font-weight:" + Le.weight + ";font-style:" + Le.style)));
}
f(x.a);
}, I(this.c, (this.f.api || "https://f.fontdeck.com/s/css/js/") + w(this.c) + "/" + y + ".js", function(H) {
H && f([]);
})) : f([]);
};
var Se = new Yt(window);
Se.a.c.custom = function(f, y) {
return new M(y, f);
}, Se.a.c.fontdeck = function(f, y) {
return new we(y, f);
}, Se.a.c.monotype = function(f, y) {
return new C(y, f);
}, Se.a.c.typekit = function(f, y) {
return new ae(y, f);
}, Se.a.c.google = function(f, y) {
return new V(y, f);
};
var De = { load: s(Se.load, Se) };
e.exports ? e.exports = De : (window.WebFont = De, window.WebFontConfig && Se.load(window.WebFontConfig));
})();
}(Lo)), Lo.exports;
}
var r_ = s_();
const i_ = /* @__PURE__ */ n_(r_), ac = [
"Space Grotesk:400,500,600,700",
"Instrument Sans:400,500,600",
"JetBrains Mono:400,500,600"
], o_ = (e) => {
const t = [...ac], n = (e == null ? void 0 : e.split(",")[0].trim().replace(/['"]/g, "")) || "", s = ac.some(
(r) => r.toLowerCase().startsWith(n.toLowerCase())
);
n && !s && t.push(n), i_.load({
google: { families: t },
active: () => {
if (!e) return;
const r = document.querySelector(".chat-container");
r && (r.style.fontFamily = e.includes(",") ? e : `"${e}", system-ui, sans-serif`);
}
});
};
function a_() {
const e = ce({}), t = ce(""), n = (r) => {
var i;
e.value = r, r.photo_url && (e.value.photo_url = r.photo_url), o_(r.font_family), Zn({
type: "CUSTOMIZATION_UPDATE",
data: {
chat_bubble_color: r.chat_bubble_color || "#C9F24E",
chat_style: r.chat_style,
chat_initiation_messages: r.chat_initiation_messages || [],
// Dashboard "Widget placement" defaults — the embed loader merges these
// under any options the installing developer set.
widget_display: (i = r.customization_metadata) == null ? void 0 : i.widget_display
}
});
};
return {
customization: e,
agentName: t,
applyCustomization: n,
initializeFromData: () => {
const r = window.__INITIAL_DATA__;
r && (n(r.customization || {}), t.value = r.agentName || "");
}
};
}
const l_ = 13, c_ = 24;
function u_(e, t) {
const n = Bi({}), s = [];
let r = null;
const i = typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, o = (c) => {
r || s.length === 0 || (r = setTimeout(a, c));
}, a = () => {
r = null;
const c = s[0];
if (c === void 0) return;
const b = e.value[c], w = n[c], z = (b == null ? void 0 : b.message) ?? "";
if (!w || !b) {
s.shift(), o(0);
return;
}
if (w.shown >= z.length) {
w.done = !0, s.shift(), o(0);
return;
}
w.shown += 1;
const I = z[w.shown - 1];
t == null || t(), o(I === " " ? c_ : l_);
};
Ft(() => e.value.length, (c, b) => {
b !== void 0 && c < b && (Object.keys(n).forEach((w) => {
delete n[Number(w)];
}), s.length = 0);
for (let w = b ?? 0; w < c; w++) {
const z = e.value[w];
if (!z || !z.stream || w in n) continue;
const I = z.message ?? "";
i || !I ? n[w] = { shown: I.length, done: !0 } : (n[w] = { shown: 0, done: !1 }, s.push(w));
}
o(0);
});
const l = (c, b) => {
const w = n[c];
return w ? b.slice(0, w.shown) : b;
}, d = (c) => {
const b = n[c];
return !!b && !b.done;
};
return Dr(() => {
r && clearTimeout(r);
}), { displayText: l, isStreaming: d };
}
function f_(e) {
const t = ce(!0);
let n = 0;
const s = () => {
Zn({ type: "UNREAD_COUNT", count: n });
}, r = (i) => {
var o;
((o = i == null ? void 0 : i.data) == null ? void 0 : o.type) === "WIDGET_VISIBILITY" && (t.value = !!i.data.open, t.value && n !== 0 && (n = 0, s()));
};
Ft(() => e.value.length, (i, o) => {
if (i <= (o ?? 0) || t.value) return;
const a = e.value[i - 1];
a && (a.message_type === "bot" || a.message_type === "agent") && (n += 1, s());
}), Hi(() => window.addEventListener("message", r)), Dr(() => window.removeEventListener("message", r));
}
const h_ = {
light: !1,
mono: !1,
radius: 22,
bubble: 16,
glow: "rgba(157,140,255,.26)",
border: "rgba(157,140,255,.32)",
card: "linear-gradient(180deg,rgba(28,26,40,.94),rgba(15,14,22,.97))",
text: "#ECEAFA",
muted: "#9C97BE",
agentBg: "rgba(255,255,255,.06)",
accent: "#9D8CFF"
}, d_ = {
light: !1,
mono: !1,
radius: 26,
bubble: 18,
glow: "rgba(157,140,255,.32)",
border: "rgba(157,140,255,.40)",
card: "linear-gradient(180deg,#16131F,#0A0910)",
text: "#F2F3F8",
muted: "#A7A0CC",
agentBg: "rgba(255,255,255,.05)",
accent: "#9D8CFF"
}, p_ = {
light: !1,
mono: !0,
radius: 8,
bubble: 4,
glow: "rgba(201,242,78,.20)",
border: "rgba(201,242,78,.30)",
card: "#070907",
text: "#D7F7C8",
muted: "#7F9B57",
agentBg: "rgba(201,242,78,.045)",
accent: "#C9F24E"
}, g_ = {
light: !1,
mono: !1,
radius: 18,
bubble: 14,
glow: "rgba(95,227,214,.22)",
border: "rgba(95,227,214,.30)",
card: "linear-gradient(180deg,#0E1A1A,#0A1414)",
text: "#DDF7F3",
muted: "#6FAFA8",
agentBg: "rgba(255,255,255,.05)",
accent: "#5FE3D6"
}, m_ = {
light: !0,
mono: !1,
radius: 28,
bubble: 20,
glow: "rgba(255,138,115,.30)",
border: "rgba(0,0,0,.07)",
card: "#FFFFFF",
text: "#2A2730",
muted: "#736C7C",
agentBg: "#F4F1F6",
accent: "#FF8A73"
}, vi = {
light: !0,
mono: !1,
radius: 24,
bubble: 16,
glow: "rgba(255,138,115,.22)",
border: "rgba(0,0,0,.08)",
card: "#FFFFFF",
text: "#2A2A33",
muted: "#6E6E7B",
agentBg: "#F3F3F6",
accent: "#FF8A73"
}, __ = {
GLASS: h_,
AURORA: d_,
TERMINAL: p_,
CALM_MINT: g_,
PLAYFUL: m_,
SUNRISE: vi,
CHATBOT: vi,
ASK_ANYTHING: vi
}, y_ = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace", lc = "'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif";
function v_(e) {
return Math.max(4, Math.round(e * 0.3));
}
function cc(e) {
const t = (e || "").replace("#", "");
if (t.length < 6) return "#0B0C10";
const n = parseInt(t.slice(0, 2), 16), s = parseInt(t.slice(2, 4), 16), r = parseInt(t.slice(4, 6), 16);
return (0.299 * n + 0.587 * s + 0.114 * r) / 255 > 0.62 ? "#0B0C10" : "#FFFFFF";
}
function b_(e) {
return __[e || ""] || vi;
}
const w_ = "#212529";
function k_(e, t) {
const n = b_(e), s = (t == null ? void 0 : t.chat_background_color) || "", r = /^#[0-9a-fA-F]{6}$/.test(s), i = s || n.card, o = (t == null ? void 0 : t.chat_text_color) || "", l = /^#[0-9a-fA-F]{6}$/.test(o) && o.toLowerCase() !== w_ ? o : r ? $s(s) ? "#FFFFFF" : "#111111" : n.text, d = r ? $s(s) ? "rgba(255,255,255,0.7)" : "rgba(0,0,0,0.62)" : n.muted, c = r ? Md(s, 20) : n.agentBg, b = (t == null ? void 0 : t.accent_color) || n.accent, w = r ? !$s(s) : n.light, z = cc(b) === "#0B0C10", I = w === z ? d : b, K = n.mono ? y_ : t != null && t.font_family ? `${t.font_family}, ${lc}` : lc;
return {
"--rp-card": i,
"--rp-text": l,
"--rp-muted": d,
"--rp-agent-bg": c,
"--rp-accent": b,
"--rp-on-accent": cc(b),
"--rp-presence": I,
"--rp-border": n.border,
"--rp-glow": n.glow,
"--rp-radius": `${n.radius}px`,
"--rp-bubble": `${n.bubble}px`,
"--rp-bubble-tail": `${v_(n.bubble)}px`,
"--rp-field-radius": n.mono ? "7px" : "12px",
"--rp-avatar-radius": n.mono ? "28%" : "50%",
"--rp-hairline": n.light ? "rgba(0,0,0,0.07)" : "rgba(255,255,255,0.08)",
"--rp-body-font": K
};
}
const uc = (e) => {
try {
return new Intl.NumberFormat("en-US", { style: "currency", currency: e || "USD" }).resolvedOptions().maximumFractionDigits ?? 2;
} catch {
return 2;
}
};
function x_() {
const e = {
USD: "$",
EUR: "€",
GBP: "£",
JPY: "¥",
INR: "₹",
CAD: "CA$",
AUD: "A$",
CNY: "¥",
CHF: "CHF",
SEK: "kr",
NOK: "kr",
DKK: "kr",
NZD: "NZ$",
SGD: "S$",
HKD: "HK$",
KRW: "₩",
MXN: "MX$",
BRL: "R$",
ZAR: "R",
RUB: "₽",
TRY: "₺",
THB: "฿",
PLN: "zł",
AED: "د.إ",
SAR: "﷼",
ILS: "₪",
MYR: "RM"
};
return {
formatCurrency: (s, r) => {
if (!s && s !== 0) return "";
const i = r ? e[r] || r : "", o = typeof s == "number" ? s : Number(s), a = Number.isFinite(o) ? o.toLocaleString("en-US", {
minimumFractionDigits: uc(r),
maximumFractionDigits: uc(r)
}) : String(s);
return i ? `${i}${a}` : a;
},
getCurrencySymbol: (s) => e[s] || s,
currencySymbols: e
};
}
const T_ = {
key: 0,
class: "widget-unavailable-overlay"
}, A_ = { class: "widget-unavailable-card" }, E_ = { class: "widget-unavailable-footer" }, S_ = {
key: 1,
class: "auth-error-overlay"
}, C_ = { class: "auth-error-card" }, R_ = { class: "auth-error-message" }, I_ = {
key: 0,
class: "initializing-overlay"
}, L_ = {
key: 0,
class: "connecting-message"
}, O_ = {
key: 1,
class: "failed-message"
}, N_ = { class: "welcome-content" }, M_ = { class: "welcome-header" }, D_ = ["src", "alt"], P_ = { class: "welcome-title" }, F_ = { class: "welcome-subtitle" }, B_ = { class: "welcome-input-container" }, $_ = {
key: 0,
class: "email-input"
}, U_ = ["disabled"], z_ = { class: "welcome-message-input" }, H_ = ["placeholder", "disabled"], W_ = ["disabled"], q_ = {
key: 0,
width: "20",
height: "20",
viewBox: "0 0 24 24",
fill: "none",
xmlns: "http://www.w3.org/2000/svg"
}, j_ = {
key: 1,
width: "20",
height: "20",
viewBox: "0 0 24 24",
fill: "none",
xmlns: "http://www.w3.org/2000/svg"
}, V_ = { class: "landing-page-content" }, K_ = { class: "landing-page-header" }, G_ = { class: "landing-page-heading" }, Y_ = { class: "landing-page-text" }, Z_ = { class: "landing-page-actions" }, X_ = { class: "form-fullscreen-content" }, J_ = {
key: 0,
class: "form-header"
}, Q_ = {
key: 0,
class: "form-title"
}, ey = {
key: 1,
class: "form-description"
}, ty = { class: "form-fields" }, ny = ["for"], sy = {
key: 0,
class: "required-indicator"
}, ry = ["id", "type", "placeholder", "required", "minlength", "maxlength", "value", "onInput", "onBlur", "autocomplete", "inputmode"], iy = ["id", "placeholder", "required", "min", "max", "value", "onInput"], oy = ["id", "placeholder", "required", "minlength", "maxlength", "value", "onInput"], ay = ["id", "required", "value", "onChange"], ly = { value: "" }, cy = ["value"], uy = {
key: 4,
class: "checkbox-field"
}, fy = ["id", "required", "checked", "onChange"], hy = { class: "checkbox-label" }, dy = {
key: 5,
class: "radio-group"
}, py = ["name", "value", "required", "checked", "onChange"], gy = { class: "radio-label" }, my = {
key: 6,
class: "field-error"
}, _y = { class: "form-actions" }, yy = ["disabled"], vy = {
key: 0,
class: "loading-spinner-inline"
}, by = { key: 1 }, wy = { class: "header-content" }, ky = ["src", "alt"], xy = { class: "header-info" }, Ty = { class: "status" }, Ay = { class: "status-text rp-presence" }, Ey = { class: "header-actions" }, Sy = ["disabled", "title", "aria-label", "aria-expanded"], Cy = { class: "ask-anything-header" }, Ry = ["src", "alt"], Iy = { class: "header-info" }, Ly = {
key: 2,
class: "loading-history"
}, Oy = { class: "rp-email-gate-title" }, Ny = ["disabled"], My = {
key: 0,
class: "rp-email-gate-error"
}, Dy = ["disabled"], Py = {
key: 0,
class: "rp-welcome-block"
}, Fy = { class: "message agent-message rp-welcome-row" }, By = ["src", "alt"], $y = {
key: 0,
class: "rp-msg-avatar",
"aria-hidden": "true"
}, Uy = ["src"], zy = ["src"], Hy = { class: "message-col" }, Wy = {
key: 0,
class: "rating-content"
}, qy = { class: "rating-prompt" }, jy = ["onMouseover", "onMouseleave", "onClick", "disabled"], Vy = {
key: 0,
class: "feedback-wrapper"
}, Ky = { class: "feedback-section" }, Gy = ["onUpdate:modelValue", "disabled"], Yy = { class: "feedback-counter" }, Zy = ["onClick", "disabled"], Xy = {
key: 1,
class: "submitted-feedback-wrapper"
}, Jy = { class: "submitted-feedback" }, Qy = { class: "submitted-feedback-text" }, ev = {
key: 2,
class: "submitted-message"
}, tv = {
key: 1,
class: "form-content"
}, nv = {
key: 0,
class: "form-header"
}, sv = {
key: 0,
class: "form-title"
}, rv = {
key: 1,
class: "form-description"
}, iv = { class: "form-fields" }, ov = ["for"], av = {
key: 0,
class: "required-indicator"
}, lv = ["id", "type", "placeholder", "required", "minlength", "maxlength", "value", "onInput", "onBlur", "disabled", "autocomplete", "inputmode"], cv = ["id", "placeholder", "required", "min", "max", "value", "onInput", "disabled"], uv = ["id", "placeholder", "required", "minlength", "maxlength", "value", "onInput", "disabled"], fv = ["id", "required", "value", "onChange", "disabled"], hv = { value: "" }, dv = ["value"], pv = {
key: 4,
class: "checkbox-field"
}, gv = ["id", "checked", "onChange", "disabled"], mv = ["for"], _v = {
key: 5,
class: "radio-field"
}, yv = ["id", "name", "value", "checked", "onChange", "disabled"], vv = ["for"], bv = {
key: 6,
class: "field-error"
}, wv = { class: "form-actions" }, kv = ["onClick", "disabled"], xv = {
key: 2,
class: "user-input-content"
}, Tv = {
key: 0,
class: "user-input-prompt"
}, Av = {
key: 1,
class: "user-input-form"
}, Ev = ["onUpdate:modelValue", "onKeydown"], Sv = ["onClick", "disabled"], Cv = {
key: 2,
class: "user-input-submitted"
}, Rv = {
key: 0,
class: "user-input-confirmation"
}, Iv = {
key: 3,
class: "product-message-container"
}, Lv = ["innerHTML"], Ov = {
key: 1,
class: "products-carousel"
}, Nv = { class: "carousel-items" }, Mv = {
key: 0,
class: "product-image-compact"
}, Dv = ["src", "alt"], Pv = { class: "product-info-compact" }, Fv = { class: "product-text-area" }, Bv = { class: "product-title-compact" }, $v = {
key: 0,
class: "product-variant-compact"
}, Uv = { class: "product-price-compact" }, zv = { class: "product-actions-compact" }, Hv = ["onClick"], Wv = {
key: 2,
class: "no-products-message"
}, qv = {
key: 3,
class: "no-products-message"
}, jv = ["innerHTML"], Vv = ["innerHTML"], Kv = {
key: 2,
class: "message-attachments"
}, Gv = {
key: 0,
class: "attachment-image-container"
}, Yv = ["src", "alt", "onClick"], Zv = { class: "attachment-image-info" }, Xv = ["href"], Jv = { class: "attachment-size" }, Qv = ["href"], eb = { class: "attachment-size" }, tb = {
key: 0,
class: "citation-chips"
}, nb = ["title"], sb = { class: "message-info" }, rb = {
key: 0,
class: "agent-name"
}, ib = {
key: 5,
class: "rp-quick-actions-bar"
}, ob = ["disabled", "onClick"], ab = {
key: 0,
class: "file-previews-widget"
}, lb = {
class: "file-preview-content-widget",
style: { cursor: "pointer" }
}, cb = ["src", "alt", "onClick"], ub = ["onClick"], fb = { class: "file-preview-info-widget" }, hb = { class: "file-preview-name-widget" }, db = { class: "file-preview-size-widget" }, pb = ["onClick"], gb = {
key: 1,
class: "upload-progress-widget"
}, mb = { class: "message-input" }, _b = ["placeholder", "disabled"], yb = ["disabled", "title"], vb = ["disabled"], bb = {
key: 7,
class: "new-conversation-section"
}, wb = { class: "conversation-ended-message" }, kb = {
key: 8,
class: "ai-disclaimer"
}, xb = {
key: 8,
class: "rating-dialog"
}, Tb = { class: "rating-content" }, Ab = { class: "star-rating" }, Eb = ["onClick"], Sb = { class: "rating-actions" }, Cb = ["disabled"], Rb = {
key: 0,
class: "preview-modal-image-container"
}, Ib = ["src", "alt"], Lb = { class: "preview-modal-filename" }, Ob = {
key: 3,
class: "widget-loading"
}, fc = 3, Nb = "image/*,.pdf,.doc,.docx,.txt,.csv,.xlsx,.xls", Mb = /* @__PURE__ */ Ui({
__name: "WidgetBuilder",
props: {
widgetId: {},
token: {},
initialAuthError: {}
},
setup(e) {
const t = e, n = de(() => {
var h;
return t.widgetId || ((h = window.__INITIAL_DATA__) == null ? void 0 : h.widgetId);
}), {
customization: s,
agentName: r,
applyCustomization: i,
initializeFromData: o
} = a_(), { formatCurrency: a } = x_(), {
messages: l,
loading: d,
errorMessage: c,
showError: b,
loadingHistory: w,
hasStartedChat: z,
connectionStatus: I,
sendMessage: K,
endChat: P,
loadChatHistory: oe,
connect: fe,
reconnect: pe,
cleanup: R,
humanAgent: N,
onTakeover: Y,
refusal: X,
submitRating: xe,
submitForm: Oe,
currentForm: _e,
getWorkflowState: Pe,
proceedWorkflow: be,
onWorkflowState: Ke,
onWorkflowProceeded: Ge,
currentSessionId: at,
setToken: ue,
setWidgetId: ye,
onSessionState: me
} = t_(), { displayText: nt, isStreaming: Ze } = u_(l, () => ys(() => zn()));
f_(l);
const Te = ce(""), Je = ce(!0), st = ce(""), At = ce(!1), Re = (h) => {
const g = h.target;
Te.value = g.value;
};
let yt = null;
const pt = () => {
yt && yt.disconnect(), yt = new MutationObserver((g) => {
let u = !1, re = !1;
g.forEach((Ae) => {
if (Ae.type === "childList") {
const ge = Array.from(Ae.addedNodes).some(
(it) => {
var Ye;
return it.nodeType === Node.ELEMENT_NODE && (it.matches("input, textarea") || ((Ye = it.querySelector) == null ? void 0 : Ye.call(it, "input, textarea")));
}
), ct = Array.from(Ae.removedNodes).some(
(it) => {
var Ye;
return it.nodeType === Node.ELEMENT_NODE && (it.matches("input, textarea") || ((Ye = it.querySelector) == null ? void 0 : Ye.call(it, "input, textarea")));
}
);
ge && (re = !0, u = !0), ct && (u = !0);
}
}), u && (clearTimeout(pt.timeoutId), pt.timeoutId = setTimeout(() => {
v();
}, re ? 50 : 100));
});
const h = document.querySelector(".widget-container") || document.body;
yt.observe(h, {
childList: !0,
subtree: !0
});
};
pt.timeoutId = null;
let Ct = [];
const Rt = /* @__PURE__ */ new Set();
let Dt = !1;
const Yt = (h) => {
if (Dt) return;
const g = setTimeout(() => {
Rt.delete(g), v();
}, h);
Rt.add(g);
}, m = () => {
Rt.forEach(clearTimeout), Rt.clear();
}, v = () => {
C();
const h = [
'.widget-container input[type="text"]',
'.chat-container input[type="text"]',
".message-input input",
".welcome-message-field",
".ask-anything-field",
'input[placeholder*="message"]',
'input[placeholder*="Type"]',
'input[placeholder*="Ask"]',
"input.message-input",
"textarea",
// More specific selectors for the widget context
".widget-container input",
".chat-input input",
"input"
];
let g = [];
for (const u of h) {
const re = document.querySelectorAll(u);
if (re.length > 0) {
g = Array.from(re);
break;
}
}
g.length !== 0 && (Ct = g, g.forEach((u) => {
u.addEventListener("input", B, !0), u.addEventListener("keyup", B, !0), u.addEventListener("change", B, !0), u.addEventListener("keypress", L, !0), u.addEventListener("keydown", G, !0);
}));
}, C = () => {
Ct.forEach((h) => {
h.removeEventListener("input", B), h.removeEventListener("keyup", B), h.removeEventListener("change", B), h.removeEventListener("keypress", L), h.removeEventListener("keydown", G);
}), Ct = [];
}, M = (h) => !!(h && h.closest && h.closest(".form-message, .form-fullscreen, .rp-email-gate")), B = (h) => {
if (M(h.target)) return;
const g = h.target;
Te.value = g.value;
}, L = (h) => {
M(h.target) || h.key === "Enter" && !h.shiftKey && (h.preventDefault(), h.stopPropagation(), un());
}, G = (h) => {
M(h.target) || h.key === "Enter" && !h.shiftKey && (h.preventDefault(), h.stopPropagation(), un());
}, W = (h) => {
const g = h.target, u = document.querySelector(".header-menu-container");
document.querySelector(".header-menu-btn");
const re = document.querySelector(".header-dropdown-menu");
re && !(u != null && u.contains(g)) && (re.style.display = "none");
}, q = ce(!0), {
token: U,
start: te,
stop: Z,
setToken: E,
ensureFresh: O
} = Qm({
onTokenChanged: (h) => {
Zn({ type: "TOKEN_UPDATE", token: h }), ue(h);
},
onIdentityExpired: () => {
j();
}
});
de(() => !!U.value);
const V = ce(null), J = ce(!1), ae = ce(!1);
t.initialAuthError && (V.value = t.initialAuthError, J.value = !0, q.value = !1), o();
const we = window.__INITIAL_DATA__;
te((we == null ? void 0 : we.widgetId) || "", we == null ? void 0 : we.initialToken), U.value && (At.value = !0);
const Se = ce(!1);
(we == null ? void 0 : we.allowAttachments) !== void 0 && (Se.value = we.allowAttachments);
const De = ce(null), {
chatStyles: f,
chatIconStyles: y,
agentBubbleStyles: D,
userBubbleStyles: x,
messageNameStyles: H,
headerBorderStyles: ne,
photoUrl: ee,
shadowStyle: Ie
} = Jg(s, r), Le = ce(null), {
uploadedAttachments: Ce,
previewModal: $e,
previewFile: Xe,
formatFileSize: wt,
isImageAttachment: on,
getDownloadUrl: kn,
getPreviewUrl: js,
handleFileSelect: Vs,
handleDrop: rs,
handleDragOver: is,
handleDragLeave: qt,
handlePaste: xn,
removeAttachment: Ks,
openPreview: os,
closePreview: ws,
openFilePicker: Gs,
isImage: ks
} = tm(U, Le);
de(() => l.value.some(
(h) => h.message_type === "form" && (!h.isSubmitted || h.isSubmitted === !1)
));
const Tn = de(() => {
var h;
return z.value && At.value || !no.value ? I.value === "connected" && !d.value : ur(st.value.trim()) && I.value === "connected" && !d.value || ((h = window.__INITIAL_DATA__) == null ? void 0 : h.workflow);
}), An = de(() => Tn.value || d.value && I.value === "connected" && z.value), Ys = de(() => I.value === "connected" ? Qt.value ? "问我任何问题…" : "输入消息…" : "连接中…"), En = ce(!1), un = async () => {
if (!Te.value.trim() && Ce.value.length === 0) return;
if (d.value && z.value) {
En.value = !0;
return;
}
!z.value && st.value && await Un();
const h = Ce.value.map((u) => ({
content: u.content,
// base64 content
filename: u.filename,
content_type: u.type,
size: u.size
}));
await K(Te.value, st.value, h), Ce.value.forEach((u) => {
u.url && u.url.startsWith("blob:") && URL.revokeObjectURL(u.url), u.file_url && u.file_url.startsWith("blob:") && URL.revokeObjectURL(u.file_url);
}), Te.value = "", Ce.value = [];
const g = document.querySelector('input[placeholder*="输入消息"]');
g && (g.value = ""), Yt(500);
};
Ft(d, (h) => {
h || !En.value || (En.value = !1, I.value === "connected" && z.value && un());
});
const Br = (h) => {
Tn.value && (Te.value = h, un());
}, rt = () => {
Zn({ type: "WIDGET_MINIMIZE" });
}, Sn = (h) => {
h.key === "Enter" && !h.shiftKey && (h.preventDefault(), h.stopPropagation(), un());
}, Un = async ({ afterRefusal: h = !1 } = {}) => {
var g, u, re, Ae;
try {
if (!n.value)
return console.error("Widget ID is not available"), V.value = "Widget ID 不可用,请刷新后重试。", J.value = !0, !1;
await O(n.value);
const ge = new URL(`${Ws.API_URL}/widgets/${n.value}`);
st.value.trim() && ur(st.value.trim()) && ge.searchParams.append("email", st.value.trim());
const ct = {
Accept: "application/json",
"Content-Type": "application/json"
};
U.value && (ct.Authorization = `Bearer ${U.value}`);
const it = await fetch(ge, {
headers: ct,
cache: "no-store"
});
if (it.status === 401) {
At.value = !1;
try {
const jn = (await it.json()).detail;
if ((jn == null ? void 0 : jn.code) === Ym)
return j(), !1;
const Rs = typeof jn == "string" ? jn : "";
(Rs.includes("generate-token") || Rs.includes("API key") || Rs.includes("Token required")) && (ae.value = !0, V.value = "Widget 认证尚未配置,请联系网站管理员。", J.value = !0, E(null));
} catch {
V.value = "需要身份验证。你的令牌已过期或无效,请刷新页面。", J.value = !0, E(null);
}
return !1;
}
if (!it.ok) {
try {
const or = await it.json();
V.value = or.detail || `错误:${it.statusText}`;
} catch {
V.value = `错误:${it.statusText},请重试。`;
}
return J.value = !0, !1;
}
const Ye = await it.json();
Ye.token && E(Ye.token), At.value = !0, V.value = null, J.value = !1, ue(U.value || void 0);
const ir = await fe();
return !ir && X.value === "customer_required" && !h ? await Un({ afterRefusal: !0 }) : (ir || console.error("Chat service not reachable yet; retrying in the background"), await $r(), (g = Ye.agent) != null && g.customization && i(Ye.agent.customization), Ye.agent && !(Ye != null && Ye.human_agent) && (r.value = Ye.agent.name), Ye != null && Ye.human_agent && (N.value = Ye.human_agent), ((u = Ye.agent) == null ? void 0 : u.allow_attachments) !== void 0 && (Se.value = Ye.agent.allow_attachments), ((re = Ye.agent) == null ? void 0 : re.workflow) !== void 0 && (window.__INITIAL_DATA__ = window.__INITIAL_DATA__ || {}, window.__INITIAL_DATA__.workflow = Ye.agent.workflow), (Ae = Ye.agent) != null && Ae.workflow && await Pe(), !0);
} catch (ge) {
return console.error("Error checking authorization:", ge), V.value = "发生意外错误,请重试。", J.value = !0, At.value = !1, !1;
} finally {
q.value = !1;
}
}, $r = async () => {
!z.value && At.value && (z.value = !0, await oe());
}, zn = () => {
De.value && (De.value.scrollTop = De.value.scrollHeight);
};
Ft(() => l.value, (h) => {
ys(() => {
zn();
});
}, { deep: !0 }), Ft(I, (h, g) => {
h === "connected" && g !== "connected" && Yt(100);
}), Ft(() => l.value.length, (h, g) => {
h > 0 && g === 0 && Yt(100);
});
let Zs = null;
Ft(() => l.value, (h) => {
const g = h[h.length - 1];
!Zl(g) || g === Zs || (Zs = g, Qs(g));
}, { deep: !0 });
const Ur = async () => {
(await pe() || X.value === "customer_required") && await Un();
}, zr = ce(!1), xs = ce(0), Xs = ce(""), Zt = ce(0), vt = ce(!1), ft = ce({}), ht = ce(!1), Qe = ce({}), Cn = ce(!1), fn = ce(null), Js = ce("开始聊天"), Rn = ce(!1), kt = ce(null);
de(() => {
var g;
const h = l.value[l.value.length - 1];
return ((g = h == null ? void 0 : h.attributes) == null ? void 0 : g.request_rating) || !1;
});
const Hn = de(() => {
var g;
if (!((g = window.__INITIAL_DATA__) != null && g.workflow))
return !1;
const h = l.value.find((u) => u.message_type === "rating");
return (h == null ? void 0 : h.isSubmitted) === !0;
}), Xt = de(
() => Oi(N.value.human_agent_profile_pic)
), Qs = async (h) => {
var g, u, re, Ae, ge;
if (Zl(h)) {
try {
if (h.session_id && U.value && n.value) {
const ct = new URL(`${Ws.API_URL}/widgets/${n.value}/end-chat`);
ct.searchParams.append("session_id", h.session_id), (g = h.attributes) != null && g.end_chat_reason && ct.searchParams.append("reason", h.attributes.end_chat_reason), (u = h.attributes) != null && u.end_chat_description && ct.searchParams.append("description", h.attributes.end_chat_description);
const it = await fetch(ct, {
method: "POST",
headers: {
Authorization: `Bearer ${U.value}`,
"Content-Type": "application/json"
}
});
if (it.ok) {
const Ye = await it.json();
console.info(`✓ Chat session closed on backend: ${Ye.session_id}`);
} else
console.warn(`Failed to close session on backend: ${it.status}`);
}
} catch (ct) {
console.error("Error calling end-chat API:", ct);
}
if ((re = h.attributes) != null && re.end_chat && ((Ae = h.attributes) != null && Ae.request_rating)) {
const ct = h.agent_name || ((ge = N.value) == null ? void 0 : ge.human_agent_name) || r.value || "我们的客服";
l.value.push({
message: `请评价你与 ${ct} 的本次聊天`,
message_type: "rating",
created_at: (/* @__PURE__ */ new Date()).toISOString(),
session_id: h.session_id,
agent_name: ct,
showFeedback: !1
}), at.value = h.session_id;
}
}
}, Ts = (h) => {
vt.value || (Zt.value = h);
}, Wn = () => {
if (!vt.value) {
const h = l.value[l.value.length - 1];
Zt.value = (h == null ? void 0 : h.selectedRating) || 0;
}
}, as = async (h) => {
if (!vt.value) {
Zt.value = h;
const g = l.value[l.value.length - 1];
g && g.message_type === "rating" && (g.showFeedback = !0, g.selectedRating = h);
}
}, Jt = async (h, g, u = null) => {
try {
vt.value = !0, await xe(g, u);
const re = l.value.find((Ae) => Ae.message_type === "rating");
re && (re.isSubmitted = !0, re.finalRating = g, re.finalFeedback = u);
} catch (re) {
console.error("Failed to submit rating:", re);
} finally {
vt.value = !1;
}
}, Xi = (h) => {
const g = {};
for (const u of h.fields) {
const re = ft.value[u.name], Ae = Es(u, re);
Ae && (g[u.name] = Ae);
}
return Qe.value = g, Object.keys(g).length === 0;
}, As = async (h) => {
if (!(ht.value || !Xi(h)))
try {
ht.value = !0, await Oe(ft.value);
const u = l.value.findIndex(
(re) => re.message_type === "form" && (!re.isSubmitted || re.isSubmitted === !1)
);
u !== -1 && l.value.splice(u, 1), ft.value = {}, Qe.value = {};
} catch (u) {
console.error("Failed to submit form:", u);
} finally {
ht.value = !1;
}
}, It = (h, g) => {
var u, re;
if (ft.value[h] = g, g && g.toString().trim() !== "") {
let Ae = null;
if ((u = kt.value) != null && u.fields && (Ae = kt.value.fields.find((ge) => ge.name === h)), !Ae && ((re = _e.value) != null && re.fields) && (Ae = _e.value.fields.find((ge) => ge.name === h)), Ae) {
const ge = Es(Ae, g);
ge ? (Qe.value[h] = ge, console.log(`Validation error for ${h}:`, ge)) : delete Qe.value[h];
}
} else
delete Qe.value[h], console.log(`Cleared error for ${h}`);
}, Hr = (h) => {
const g = h.replace(/\D/g, "");
return g.length >= 7 && g.length <= 15;
}, Es = (h, g) => {
if (h.required && (!g || g.toString().trim() === ""))
return `${h.label} 为必填项`;
if (!g || g.toString().trim() === "")
return null;
if (h.type === "email" && !ur(g))
return "请输入有效的邮箱地址";
if (h.type === "tel" && !Hr(g))
return "请输入有效的电话号码";
if ((h.type === "text" || h.type === "textarea") && h.minLength && g.length < h.minLength)
return `${h.label} 至少需要 ${h.minLength} 个字符`;
if ((h.type === "text" || h.type === "textarea") && h.maxLength && g.length > h.maxLength)
return `${h.label} 不能超过 ${h.maxLength} 个字符`;
if (h.type === "number") {
const u = parseFloat(g);
if (isNaN(u))
return `${h.label} 必须是有效数字`;
if (h.minLength && u < h.minLength)
return `${h.label} 不能小于 ${h.minLength}`;
if (h.maxLength && u > h.maxLength)
return `${h.label} 不能大于 ${h.maxLength}`;
}
return null;
}, Wr = async () => {
if (!(ht.value || !kt.value))
try {
ht.value = !0, Qe.value = {};
let h = !1;
for (const g of kt.value.fields || []) {
const u = ft.value[g.name], re = Es(g, u);
re && (Qe.value[g.name] = re, h = !0, console.log(`Validation error for field ${g.name}:`, re));
}
if (h) {
ht.value = !1, console.log("Validation failed, not submitting");
return;
}
await Oe(ft.value), Rn.value = !1, kt.value = null, ft.value = {};
} catch (h) {
console.error("Failed to submit full screen form:", h);
} finally {
ht.value = !1, console.log("Full screen form submission completed");
}
}, qr = (h, g) => {
if (console.log("handleViewDetails called with:", { product: h, shopDomain: g }), !h) {
console.error("No product provided to handleViewDetails");
return;
}
let u = null;
if (h.handle && g)
u = `https://${g}/products/${h.handle}`;
else if (h.id && g)
u = `https://${g}/products/${h.id}`;
else if (g) {
if (!h.handle && !h.id) {
console.error("Product handle and ID are both missing! Product:", h), alert("无法打开商品:商品信息不完整。");
return;
}
} else {
console.error("Shop domain is missing! Product:", h), alert("无法打开商品:店铺域名不可用,请联系客服。");
return;
}
u && (console.log("Opening product URL:", u), window.open(u, "_blank"));
}, Ji = (h) => {
if (!h) return "";
let g = h.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, "");
const u = [];
return g = g.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (re, Ae, ge) => {
const ct = `__MARKDOWN_LINK_${u.length}__`;
return console.log("Found markdown link:", re, "-> placeholder:", ct), u.push(re), ct;
}), console.log("After replacing markdown links with placeholders:", g), console.log("Markdown links array:", u), g = g.replace(/https?:\/\/[^\s\)]+/g, "[链接已移除]"), console.log("After removing standalone URLs:", g), u.forEach((re, Ae) => {
g = g.replace(`__MARKDOWN_LINK_${Ae}__`, re), console.log(`Restored markdown link ${Ae}:`, re);
}), g = g.replace(/\n\s*\n\s*\n/g, `
`).trim(), g;
}, er = ce(!1);
ce(!1);
const tr = de(() => {
var h;
return !!((h = N.value) != null && h.human_agent_name);
}), jr = de(() => {
var h;
return Zg((h = window.__INITIAL_DATA__) == null ? void 0 : h.presence, tr.value);
}), Vr = de(() => Se.value && tr.value && Ce.value.length < fc), Ss = async () => {
try {
Cn.value = !1, fn.value = null, await be();
} catch (h) {
console.error("Failed to proceed workflow:", h);
}
}, ls = async (h) => {
try {
if (!h.userInputValue || !h.userInputValue.trim())
return;
const g = h.userInputValue.trim();
h.isSubmitted = !0, h.submittedValue = g, await K(g, st.value);
} catch (g) {
console.error("Failed to submit user input:", g), h.isSubmitted = !1, h.submittedValue = null;
}
}, j = () => {
Zn({ type: "IDENTITY_EXPIRED" });
}, p = async () => {
U.value && (E(null), await $());
}, k = async (h) => {
const g = zs(h);
!g || g === U.value || (E(g), await $());
}, $ = async () => {
var h, g, u;
try {
let re = 0;
const Ae = 50;
for (; !((h = window.__INITIAL_DATA__) != null && h.widgetId) && re < Ae; )
await new Promise((ct) => setTimeout(ct, 100)), re++;
return (g = window.__INITIAL_DATA__) != null && g.widgetId ? (ye(window.__INITIAL_DATA__.widgetId), await Un() ? ((u = window.__INITIAL_DATA__) != null && u.workflow && At.value && await Pe(), !0) : (I.value = "connected", !1)) : (console.error("Widget data not available after waiting"), !1);
} catch (re) {
return console.error("Failed to initialize widget:", re), !1;
}
};
window.addEventListener("message", (h) => {
h.source === window.parent && (!h.data || typeof h.data.type != "string" || (h.data.type === "SCROLL_TO_BOTTOM" && zn(), h.data.type === "IDENTITY_UNAVAILABLE" && p(), h.data.type === "TOKEN_REFRESH" && k(h.data.token), h.data.type === "WIDGET_VISIBILITY" && (za.value = !!h.data.open), h.data.type === "WIDGET_DISPLAY" && (so.value = {
mode: h.data.mode,
width: h.data.width,
height: h.data.height,
hotkey: h.data.hotkey
}), h.data.type === "PREFILL_MESSAGE" && typeof h.data.text == "string" && (Te.value = h.data.text.slice(0, 2e3), ys(() => {
const g = document.querySelector(
".message-input input, .welcome-message-field"
);
g == null || g.focus();
}))));
});
const Q = () => {
Y(async () => {
await Un();
}), me(({ session_id: h, authenticated: g, created: u }) => {
Zn({
type: "CHAT_SESSION",
sessionId: h,
authenticated: g,
created: u
});
}), Ke((h) => {
var g;
if (Js.value = h.button_text || "开始聊天", h.type === "landing_page")
fn.value = h.landing_page_data, Cn.value = !0, Rn.value = !1;
else if (h.type === "form" || h.type === "display_form")
if (((g = h.form_data) == null ? void 0 : g.form_full_screen) === !0)
kt.value = h.form_data, Rn.value = !0, Cn.value = !1;
else {
const u = {
message: "",
message_type: "form",
attributes: {
form_data: h.form_data
},
created_at: (/* @__PURE__ */ new Date()).toISOString(),
isSubmitted: !1
};
l.value.findIndex(
(Ae) => Ae.message_type === "form" && !Ae.isSubmitted
) === -1 && l.value.push(u), Cn.value = !1, Rn.value = !1;
}
else
Cn.value = !1, Rn.value = !1;
}), Ge((h) => {
console.log("Workflow proceeded:", h);
});
}, ie = async () => {
try {
await $(), await Pe();
} catch (h) {
throw console.error("Failed to start new conversation:", h), h;
}
}, he = de(
() => {
var h;
return s.value.allow_new_chat === !0 && l.value.length > 0 && !((h = N.value) != null && h.human_agent_name) && !cs.value;
}
), Ne = ce(!1), Be = ce(""), lt = ce(!1);
let dt = null;
const hn = () => {
lt.value = !1, Be.value = "", dt && (clearTimeout(dt), dt = null);
}, xt = () => {
if (!Ne.value) {
if (lt.value) {
hn();
return;
}
lt.value = !0, Be.value = "", dt = setTimeout(hn, ag);
}
};
Ft(he, (h) => {
h || hn();
});
const nr = async () => {
Ne.value || (dt && (clearTimeout(dt), dt = null), await Na(), Be.value || (lt.value = !1));
}, Na = async () => {
if (!Ne.value) {
Ne.value = !0, Be.value = "";
try {
if (!await P()) {
Be.value = Yl;
return;
}
N.value = {}, Te.value = "", Ce.value = [], await $();
} catch (h) {
console.error("Failed to start a new chat:", h), Be.value = Yl;
} finally {
Ne.value = !1;
}
}
}, Xu = async () => {
Hn.value = !1, l.value = [], N.value = {}, await ie();
};
Hi(async () => {
await $(), Q(), pt(), document.addEventListener("click", W), (() => {
const g = l.value.length > 0, u = I.value === "connected", re = document.querySelector('input[type="text"], textarea') !== null;
return g || u || re;
})() && Yt(100);
}), Dr(() => {
window.removeEventListener("message", (h) => {
h.data.type === "SCROLL_TO_BOTTOM" && zn();
}), document.removeEventListener("click", W), yt && (yt.disconnect(), yt = null), pt.timeoutId && (clearTimeout(pt.timeoutId), pt.timeoutId = null), Dt = !0, m(), C(), Z(), hn(), R();
});
const Cs = de(() => s.value.chat_style === "AURORA"), Qt = de(() => s.value.chat_style === "ASK_ANYTHING" || Cs.value), Ma = de(() => s.value.customization_metadata), Kr = de(() => {
var g;
const h = (g = Ma.value) == null ? void 0 : g.avatar_style;
return h === "orb" ? !0 : h === "photo" ? !1 : Cs.value && !s.value.photo_url;
}), sr = de(() => {
var h;
return Kg(r.value || "", (h = Ma.value) == null ? void 0 : h.orb_variant);
}), Ju = {
GLASS: "theme-glass",
TERMINAL: "theme-terminal",
PLAYFUL: "theme-playful",
CALM_MINT: "theme-calm",
SUNRISE: "theme-sunrise"
}, Qu = de(() => Ju[s.value.chat_style] || ""), ef = de(() => k_(s.value.chat_style, {
chat_background_color: s.value.chat_background_color,
chat_text_color: s.value.chat_text_color,
accent_color: s.value.accent_color,
font_family: s.value.font_family
})), Qi = de(
() => Array.isArray(s.value.quick_actions) ? s.value.quick_actions.filter((h) => !!h && h.trim().length > 0) : []
), Da = de(() => (s.value.welcome_message || "").trim()), Pa = de(
() => !Qt.value && l.value.length === 0 && !w.value && !cs.value
), tf = de(
() => Pa.value && Da.value.length > 0
), nf = de(
() => Pa.value && !Hn.value && Qi.value.length > 0
), Gr = de(() => s.value.show_citations === !0), Fa = de(() => Yg(s.value.show_ai_disclaimer, tr.value)), sf = (h) => /^[0-9a-f]{16,}$/i.test(h) || /^[0-9a-f-]{32,}$/i.test(h), eo = (h) => {
const g = (h || "").trim().toLowerCase();
return !g || g === "unknown" ? "知识库" : g.charAt(0).toUpperCase() + g.slice(1);
}, to = (h) => {
let g = ((h == null ? void 0 : h.name) || "").trim();
return !g || (g = g.replace(/^[0-9a-f]{16,}[_-]/i, "").replace(/\.(pdf|txt|md|html?|docx?|csv|json)$/i, ""), !g || sf(g)) ? eo(h == null ? void 0 : h.type) : g;
}, Ba = (h) => {
const g = to(h), u = eo(h == null ? void 0 : h.type);
return g === u ? u : `${g} · ${u}`;
}, no = de(() => s.value.collect_email === !0 && !Qt.value), $a = ce(!1), qn = ce(""), rr = ce(!1), cs = de(() => !z.value && no.value && !$a.value), Ua = async () => {
const h = st.value.trim();
if (!h) {
qn.value = "请输入邮箱地址。";
return;
}
if (!ur(h)) {
qn.value = "请输入有效的邮箱地址。";
return;
}
qn.value = "", rr.value = !0;
try {
await Un(), $a.value = !0;
} catch {
qn.value = "出错了,请重试。";
} finally {
rr.value = !1;
}
}, so = ce(null), za = ce(!0), ro = { mode: "floating", width: 400, height: 560 }, Yr = de(
() => {
var h;
return so.value || ((h = s.value.customization_metadata) == null ? void 0 : h.widget_display) || null;
}
), rf = de(() => {
const h = Yr.value;
return h ? typeof h.mode == "string" && h.mode !== ro.mode || typeof h.width == "number" && h.width !== ro.width || typeof h.height == "number" && h.height !== ro.height : !1;
}), of = de(() => {
var g;
const h = {
width: "100%",
height: "100%",
borderRadius: "var(--radius-lg)"
};
if (rf.value) {
const u = (g = Yr.value) == null ? void 0 : g.mode;
return u === "sidebar-left" || u === "sidebar-right" ? { ...h, borderRadius: "0" } : h;
}
return Qt.value ? window.innerWidth <= 768 ? {
...h,
width: "100vw",
height: "100vh",
maxWidth: "100vw",
maxHeight: "100vh",
minWidth: "unset",
borderRadius: "0"
} : window.innerWidth <= 1024 ? {
...h,
width: "95%",
maxWidth: "700px",
minWidth: "500px",
height: "650px"
} : {
...h,
width: "100%",
maxWidth: "400px",
minWidth: "400px",
height: "580px"
} : h;
}), Ha = de(() => Qt.value && l.value.length === 0), af = ["form", "user_input", "rating", "product", "shopify_output"], lf = de(
() => l.value.some(
(h) => af.includes(h.message_type) || Array.isArray(h.attachments) && h.attachments.length > 0
)
), cf = de(() => {
var g, u;
return Qt.value ? !0 : (((g = Yr.value) == null ? void 0 : g.mode) === "ask-ai" || ((u = Yr.value) == null ? void 0 : u.mode) === "search-bar") && !Se.value;
}), io = de(
() => cf.value && Je.value && !Cn.value && !Rn.value && !cs.value && !Hn.value && !lf.value
);
Ft(io, (h) => {
Zn({ type: "WIDGET_SURFACE", palette: h });
}, { immediate: !0 });
const uf = de(
() => s.value.welcome_subtitle || `向 ${r.value || "助手"} 提问,它会根据已知内容作答。`
), ff = de(() => {
var h;
return ((h = so.value) == null ? void 0 : h.hotkey) !== !1;
});
return (h, g) => J.value && ae.value ? (T(), A("div", T_, [
_("button", {
type: "button",
class: "rp-error-close",
"aria-label": "关闭聊天",
title: "关闭",
onClick: rt
}, "×"),
_("div", A_, [
g[21] || (g[21] = go('<div class="widget-unavailable-icon-wrapper" data-v-0e2df0b3><svg class="widget-unavailable-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" data-v-0e2df0b3><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" data-v-0e2df0b3></path><path d="M9 12l2 2 4-4" data-v-0e2df0b3></path></svg></div><h2 class="widget-unavailable-title" data-v-0e2df0b3>聊天不可用</h2><p class="widget-unavailable-message" data-v-0e2df0b3> 该聊天 Widget 尚未配置,请联系网站管理员开启聊天支持。 </p>', 3)),
_("div", E_, [
$t(mr, {
class: "replypier-logo-small",
size: 20
}),
g[20] || (g[20] = _("a", {
class: "rp-powered-link",
href: "https://replypier.site",
target: "_blank",
rel: "noopener"
}, [
_("span", { class: "rp-powered-prefix" }, "由 "),
_("strong", { class: "rp-brand" }, "ReplyPier"),
_("span", { class: "rp-powered-prefix" }, " 提供支持")
], -1))
])
])
])) : J.value ? (T(), A("div", S_, [
_("button", {
type: "button",
class: "rp-error-close",
"aria-label": "关闭聊天",
title: "关闭",
onClick: rt
}, "×"),
_("div", C_, [
g[22] || (g[22] = go('<div class="auth-error-header" data-v-0e2df0b3><svg class="auth-error-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" data-v-0e2df0b3><circle cx="12" cy="12" r="10" data-v-0e2df0b3></circle><line x1="12" y1="8" x2="12" y2="12" data-v-0e2df0b3></line><line x1="12" y1="16" x2="12.01" y2="16" data-v-0e2df0b3></line></svg><h2 data-v-0e2df0b3>身份验证错误</h2></div>', 1)),
_("p", R_, se(V.value), 1),
_("button", {
class: "auth-error-refresh-btn",
onClick: g[0] || (g[0] = () => h.window.location.reload())
}, " 刷新页面 ")
])
])) : n.value && !J.value ? (T(), A("div", {
key: 2,
class: Ue(["chat-container rp-surface", [{ collapsed: !Je.value, "ask-anything-style": Qt.value, aurora: Cs.value }, Qu.value]]),
style: Ee({ ...S(Ie), ...of.value, ...ef.value })
}, [
q.value ? (T(), A("div", I_, g[23] || (g[23] = [
go('<div class="loading-spinner" data-v-0e2df0b3><div class="dot" data-v-0e2df0b3></div><div class="dot" data-v-0e2df0b3></div><div class="dot" data-v-0e2df0b3></div></div><div class="loading-text" data-v-0e2df0b3>正在初始化聊天…</div>', 2)
]))) : le("", !0),
!q.value && S(I) !== "connected" ? (T(), A("div", {
key: 1,
class: Ue(["connection-status", S(I)])
}, [
S(I) === "connecting" ? (T(), A("div", L_, g[24] || (g[24] = [
Ln(" 正在连接聊天服务… ", -1),
_("div", { class: "loading-dots" }, [
_("div", { class: "dot" }),
_("div", { class: "dot" }),
_("div", { class: "dot" })
], -1)
]))) : S(I) === "failed" ? (T(), A("div", O_, [
g[25] || (g[25] = Ln(" 连接失败。 ", -1)),
_("button", {
onClick: Ur,
class: "reconnect-button"
}, " 点击重新连接 ")
])) : le("", !0)
], 2)) : le("", !0),
S(b) ? (T(), A("div", {
key: 2,
class: "error-alert",
style: Ee(S(y))
}, se(S(c)), 5)) : le("", !0),
io.value ? (T(), Ai(Mg, {
key: 3,
messages: S(l),
draft: Te.value,
"agent-name": S(r),
suggestions: Qi.value,
"welcome-title": S(s).welcome_title,
"welcome-subtitle": uf.value,
placeholder: Ys.value,
"input-enabled": Tn.value,
"typing-enabled": An.value,
loading: S(d),
"show-citations": Gr.value,
disclaimer: Fa.value ? S(Xl) : "",
active: za.value,
hotkey: ff.value,
"can-start-new-chat": he.value,
"starting-new-chat": Ne.value,
"new-chat-armed": lt.value,
"new-chat-error": Be.value,
onNewChat: xt,
onConfirmNewChat: nr,
onCancelNewChat: hn,
"citation-label": to,
"citation-tooltip": Ba,
"display-text": S(nt),
"is-streaming": S(Ze),
"onUpdate:draft": g[1] || (g[1] = (u) => Te.value = u),
onSend: un,
onAsk: Br,
onClose: rt
}, null, 8, ["messages", "draft", "agent-name", "suggestions", "welcome-title", "welcome-subtitle", "placeholder", "input-enabled", "typing-enabled", "loading", "show-citations", "disclaimer", "active", "hotkey", "can-start-new-chat", "starting-new-chat", "new-chat-armed", "new-chat-error", "display-text", "is-streaming"])) : Ha.value ? (T(), A("div", {
key: 4,
class: Ue(["welcome-message-section", { aurora: Cs.value }]),
style: Ee(S(f))
}, [
_("div", N_, [
_("div", M_, [
Kr.value ? (T(), A("div", {
key: 0,
class: "welcome-orb",
style: Ee(sr.value)
}, null, 4)) : S(ee) ? (T(), A("img", {
key: 1,
src: S(ee),
alt: S(r),
class: "welcome-avatar"
}, null, 8, D_)) : le("", !0),
_("h1", P_, se(S(s).welcome_title || `欢迎使用 ${S(r)}`), 1),
_("p", F_, se(S(s).welcome_subtitle || "我随时为你提供帮助,今天有什么可以帮你?"), 1)
])
]),
_("div", B_, [
!S(z) && !At.value && no.value ? (T(), A("div", $_, [
Vn(_("input", {
"onUpdate:modelValue": g[2] || (g[2] = (u) => st.value = u),
type: "email",
placeholder: "请输入邮箱地址",
disabled: S(d) || S(I) !== "connected",
class: Ue([{
invalid: st.value.trim() && !S(ur)(st.value.trim()),
disabled: S(I) !== "connected"
}, "welcome-email-input"])
}, null, 10, U_), [
[hs, st.value]
])
])) : le("", !0),
_("div", z_, [
Vn(_("input", {
"onUpdate:modelValue": g[3] || (g[3] = (u) => Te.value = u),
type: "text",
placeholder: Ys.value,
onKeypress: Sn,
onInput: Re,
onChange: Re,
disabled: !An.value,
class: Ue([{ disabled: !An.value }, "welcome-message-field"])
}, null, 42, H_), [
[hs, Te.value]
]),
_("button", {
class: Ue(["welcome-send-button", { "aurora-send": Cs.value }]),
style: Ee(S(x)),
onClick: un,
disabled: !Te.value.trim() || !Tn.value
}, [
Cs.value ? (T(), A("svg", q_, g[26] || (g[26] = [
_("path", {
d: "M12 19V5M12 5L5 12M12 5L19 12",
stroke: "currentColor",
"stroke-width": "2",
"stroke-linecap": "round",
"stroke-linejoin": "round"
}, null, -1)
]))) : (T(), A("svg", j_, g[27] || (g[27] = [
_("path", {
d: "M5 12L3 21L21 12L3 3L5 12ZM5 12L13 12",
stroke: "currentColor",
"stroke-width": "2",
"stroke-linecap": "round",
"stroke-linejoin": "round"
}, null, -1)
])))
], 14, W_)
])
]),
_("div", {
class: "powered-by-welcome",
style: Ee(S(H))
}, [
$t(mr, {
class: "replypier-logo",
size: 20
}),
g[28] || (g[28] = _("a", {
class: "rp-powered-link",
href: "https://replypier.site",
target: "_blank",
rel: "noopener"
}, [
_("span", { class: "rp-powered-prefix" }, "由 "),
_("strong", { class: "rp-brand" }, "ReplyPier"),
_("span", { class: "rp-powered-prefix" }, " 提供支持")
], -1))
], 4)
], 6)) : le("", !0),
Cn.value && fn.value ? (T(), A("div", {
key: 5,
class: "landing-page-fullscreen",
style: Ee(S(f))
}, [
_("div", V_, [
_("div", K_, [
_("h2", G_, se(fn.value.heading), 1),
_("div", Y_, se(fn.value.content), 1)
]),
_("div", Z_, [
_("button", {
class: "landing-page-button",
onClick: Ss
}, se(Js.value), 1)
])
]),
_("div", {
class: "powered-by-landing",
style: Ee(S(H))
}, [
$t(mr, {
class: "replypier-logo",
size: 20
}),
g[29] || (g[29] = _("a", {
class: "rp-powered-link",
href: "https://replypier.site",
target: "_blank",
rel: "noopener"
}, [
_("span", { class: "rp-powered-prefix" }, "由 "),
_("strong", { class: "rp-brand" }, "ReplyPier"),
_("span", { class: "rp-powered-prefix" }, " 提供支持")
], -1))
], 4)
], 4)) : Rn.value && kt.value ? (T(), A("div", {
key: 6,
class: "form-fullscreen",
style: Ee(S(f))
}, [
_("div", X_, [
kt.value.title || kt.value.description ? (T(), A("div", J_, [
kt.value.title ? (T(), A("h2", Q_, se(kt.value.title), 1)) : le("", !0),
kt.value.description ? (T(), A("p", ey, se(kt.value.description), 1)) : le("", !0)
])) : le("", !0),
_("div", ty, [
(T(!0), A(ze, null, Et(kt.value.fields, (u) => {
var re, Ae;
return T(), A("div", {
key: u.name,
class: "form-field"
}, [
_("label", {
for: `fullscreen-form-${u.name}`,
class: "field-label"
}, [
Ln(se(u.label) + " ", 1),
u.required ? (T(), A("span", sy, "*")) : le("", !0)
], 8, ny),
u.type === "text" || u.type === "email" || u.type === "tel" ? (T(), A("input", {
key: 0,
id: `fullscreen-form-${u.name}`,
type: u.type,
placeholder: u.placeholder || "",
required: u.required,
minlength: u.minLength,
maxlength: u.maxLength,
value: ft.value[u.name] || "",
onInput: (ge) => It(u.name, ge.target.value),
onBlur: (ge) => It(u.name, ge.target.value),
class: Ue(["form-input", { error: Qe.value[u.name] }]),
autocomplete: u.type === "email" ? "email" : u.type === "tel" ? "tel" : "off",
inputmode: u.type === "tel" ? "tel" : u.type === "email" ? "email" : "text"
}, null, 42, ry)) : u.type === "number" ? (T(), A("input", {
key: 1,
id: `fullscreen-form-${u.name}`,
type: "number",
placeholder: u.placeholder || "",
required: u.required,
min: u.minLength,
max: u.maxLength,
value: ft.value[u.name] || "",
onInput: (ge) => It(u.name, ge.target.value),
class: Ue(["form-input", { error: Qe.value[u.name] }])
}, null, 42, iy)) : u.type === "textarea" ? (T(), A("textarea", {
key: 2,
id: `fullscreen-form-${u.name}`,
placeholder: u.placeholder || "",
required: u.required,
minlength: u.minLength,
maxlength: u.maxLength,
value: ft.value[u.name] || "",
onInput: (ge) => It(u.name, ge.target.value),
class: Ue(["form-textarea", { error: Qe.value[u.name] }]),
rows: "4"
}, null, 42, oy)) : u.type === "select" ? (T(), A("select", {
key: 3,
id: `fullscreen-form-${u.name}`,
required: u.required,
value: ft.value[u.name] || "",
onChange: (ge) => It(u.name, ge.target.value),
class: Ue(["form-select", { error: Qe.value[u.name] }])
}, [
_("option", ly, se(u.placeholder || "请选择…"), 1),
(T(!0), A(ze, null, Et((Array.isArray(u.options) ? u.options : ((re = u.options) == null ? void 0 : re.split(`
`)) || []).filter((ge) => ge.trim()), (ge) => (T(), A("option", {
key: ge,
value: ge.trim()
}, se(ge.trim()), 9, cy))), 128))
], 42, ay)) : u.type === "checkbox" ? (T(), A("label", uy, [
_("input", {
id: `fullscreen-form-${u.name}`,
type: "checkbox",
required: u.required,
checked: ft.value[u.name] || !1,
onChange: (ge) => It(u.name, ge.target.checked),
class: "form-checkbox"
}, null, 40, fy),
_("span", hy, se(u.label), 1)
])) : u.type === "radio" ? (T(), A("div", dy, [
(T(!0), A(ze, null, Et((Array.isArray(u.options) ? u.options : ((Ae = u.options) == null ? void 0 : Ae.split(`
`)) || []).filter((ge) => ge.trim()), (ge) => (T(), A("label", {
key: ge,
class: "radio-field"
}, [
_("input", {
type: "radio",
name: `fullscreen-form-${u.name}`,
value: ge.trim(),
required: u.required,
checked: ft.value[u.name] === ge.trim(),
onChange: (ct) => It(u.name, ge.trim()),
class: "form-radio"
}, null, 40, py),
_("span", gy, se(ge.trim()), 1)
]))), 128))
])) : le("", !0),
Qe.value[u.name] ? (T(), A("div", my, se(Qe.value[u.name]), 1)) : le("", !0)
]);
}), 128))
]),
_("div", _y, [
_("button", {
onClick: g[4] || (g[4] = () => {
console.log("Submit button clicked!"), Wr();
}),
disabled: ht.value,
class: "submit-form-button",
style: Ee(S(x))
}, [
ht.value ? (T(), A("span", vy, g[30] || (g[30] = [
_("div", { class: "dot" }, null, -1),
_("div", { class: "dot" }, null, -1),
_("div", { class: "dot" }, null, -1)
]))) : (T(), A("span", by, se(kt.value.submit_button_text || "提交"), 1))
], 12, yy)
])
]),
_("div", {
class: "powered-by-landing",
style: Ee(S(H))
}, [
$t(mr, {
class: "replypier-logo",
size: 20
}),
g[31] || (g[31] = _("a", {
class: "rp-powered-link",
href: "https://replypier.site",
target: "_blank",
rel: "noopener"
}, [
_("span", { class: "rp-powered-prefix" }, "由 "),
_("strong", { class: "rp-brand" }, "ReplyPier"),
_("span", { class: "rp-powered-prefix" }, " 提供支持")
], -1))
], 4)
], 4)) : !Ha.value && Je.value && !io.value ? (T(), A("div", {
key: 7,
class: Ue(["chat-panel", { "ask-anything-chat": Qt.value }]),
style: Ee(S(f))
}, [
Qt.value ? (T(), A("div", {
key: 1,
class: "ask-anything-top",
style: Ee(S(ne))
}, [
_("div", Cy, [
Xt.value || S(ee) ? (T(), A("img", {
key: 0,
src: Xt.value || S(ee),
alt: S(N).human_agent_name || S(r),
class: "header-avatar"
}, null, 8, Ry)) : le("", !0),
_("div", Iy, [
_("h3", {
style: Ee(S(H))
}, se(S(r)), 5),
_("p", {
class: "ask-anything-subtitle",
style: Ee(S(H))
}, se(S(s).welcome_subtitle || "问我任何问题,我随时为你解答。"), 5)
])
])
], 4)) : (T(), A("div", {
key: 0,
class: "chat-header",
style: Ee(S(ne))
}, [
_("div", {
class: "rp-header-sheen",
style: Ee({ background: "linear-gradient(90deg, transparent, " + (S(s).accent_color || "#C9F24E") + ", transparent)" })
}, null, 4),
_("div", wy, [
!Xt.value && (Kr.value || !S(ee)) ? (T(), A("div", {
key: 0,
class: "header-orb",
style: Ee(sr.value)
}, null, 4)) : Xt.value || S(ee) ? (T(), A("img", {
key: 1,
src: Xt.value || S(ee),
alt: S(N).human_agent_name || S(r),
class: "header-avatar"
}, null, 8, ky)) : le("", !0),
_("div", xy, [
_("h3", {
style: Ee(S(H))
}, se(S(N).human_agent_name || S(r)), 5),
_("div", Ty, [
_("span", {
class: Ue(["status-indicator", jr.value.online ? "online" : "away"])
}, null, 2),
_("span", Ay, se(jr.value.text), 1)
])
])
]),
_("div", Ey, [
he.value ? (T(), A("button", {
key: 0,
type: "button",
class: Ue(["header-new-chat", { armed: lt.value }]),
style: Ee(S(H)),
disabled: Ne.value,
title: S(Li),
"aria-label": S(Li),
"aria-expanded": lt.value,
onClick: xt
}, g[32] || (g[32] = [
_("svg", {
width: "16",
height: "16",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
"stroke-width": "2",
"stroke-linecap": "round",
"stroke-linejoin": "round",
"aria-hidden": "true"
}, [
_("path", { d: "M12 20h9" }),
_("path", { d: "M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z" })
], -1)
]), 14, Sy)) : le("", !0),
_("button", {
type: "button",
class: "header-minimize",
style: Ee(S(H)),
title: "最小化",
"aria-label": "最小化聊天",
onClick: rt
}, g[33] || (g[33] = [
_("svg", {
width: "16",
height: "16",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
"stroke-width": "2.5",
"stroke-linecap": "round",
"stroke-linejoin": "round",
"aria-hidden": "true"
}, [
_("path", { d: "M6 9l6 6 6-6" })
], -1)
]), 4)
])
], 4)),
S(w) ? (T(), A("div", Ly, g[34] || (g[34] = [
_("div", { class: "loading-spinner" }, [
_("div", { class: "dot" }),
_("div", { class: "dot" }),
_("div", { class: "dot" })
], -1)
]))) : le("", !0),
cs.value ? (T(), A("div", {
key: 3,
class: "rp-email-gate",
style: Ee(S(f))
}, [
_("div", {
class: "rp-email-gate-orb",
style: Ee(sr.value)
}, null, 4),
_("h3", Oy, se(S(s).welcome_title || "开始之前"), 1),
g[35] || (g[35] = _("p", { class: "rp-email-gate-text" }, "请输入邮箱,随后继续聊天。", -1)),
Vn(_("input", {
"onUpdate:modelValue": g[5] || (g[5] = (u) => st.value = u),
type: "email",
inputmode: "email",
autocomplete: "email",
placeholder: "you@example.com",
class: Ue(["rp-email-gate-input", { invalid: !!qn.value }]),
disabled: rr.value,
onKeyup: li(Ua, ["enter"]),
onInput: g[6] || (g[6] = (u) => qn.value = "")
}, null, 42, Ny), [
[hs, st.value]
]),
qn.value ? (T(), A("p", My, se(qn.value), 1)) : le("", !0),
_("button", {
type: "button",
class: "rp-email-gate-btn",
style: Ee(S(x)),
disabled: rr.value,
onClick: Ua
}, se(rr.value ? "请稍候…" : "继续聊天"), 13, Dy)
], 4)) : le("", !0),
lt.value && he.value ? (T(), Ai(Iu, {
key: 4,
busy: Ne.value,
error: Be.value,
onConfirm: nr,
onCancel: hn
}, null, 8, ["busy", "error"])) : le("", !0),
Vn(_("div", {
class: "chat-messages",
ref_key: "messagesContainer",
ref: De,
role: "log",
"aria-label": "消息"
}, [
tf.value ? (T(), A("div", Py, [
_("div", Fy, [
Kr.value || !S(ee) ? (T(), A("div", {
key: 0,
class: "rp-welcome-orb",
style: Ee(sr.value)
}, null, 4)) : (T(), A("img", {
key: 1,
src: S(ee),
alt: S(r),
class: "rp-welcome-avatar"
}, null, 8, By)),
_("div", {
class: "message-bubble rp-welcome-bubble",
style: Ee(S(D))
}, se(Da.value), 5)
])
])) : le("", !0),
(T(!0), A(ze, null, Et(S(l), (u, re) => {
var Ae, ge, ct, it, Ye, ir, or, jn, Rs, Wa, qa, ja, Va, Ka, Ga, Ya, Za, Xa, Ja;
return T(), A("div", {
key: re,
class: Ue([
"message",
u.message_type === "bot" || u.message_type === "agent" ? "agent-message" : u.message_type === "system" ? "system-message" : u.message_type === "rating" ? "rating-message" : u.message_type === "form" ? "form-message" : u.message_type === "product" || u.shopify_output ? "product-message" : "user-message"
])
}, [
u.message_type === "bot" || u.message_type === "agent" ? (T(), A("div", $y, [
Xt.value ? (T(), A("img", {
key: 0,
src: Xt.value,
class: "rp-msg-avatar-img",
alt: ""
}, null, 8, Uy)) : !Kr.value && S(ee) ? (T(), A("img", {
key: 1,
src: S(ee),
class: "rp-msg-avatar-img",
alt: ""
}, null, 8, zy)) : (T(), A("div", {
key: 2,
class: "rp-msg-avatar-orb",
style: Ee(sr.value)
}, null, 4))
])) : le("", !0),
_("div", Hy, [
_("div", {
class: "message-bubble",
style: Ee(u.message_type === "system" || u.message_type === "rating" || u.message_type === "form" || u.message_type === "product" || u.shopify_output ? {} : u.message_type === "user" ? S(x) : S(D))
}, [
u.message_type === "rating" ? (T(), A("div", Wy, [
_("p", qy, "请评价你与 " + se(u.agent_name || S(N).human_agent_name || S(r) || "我们的客服") + " 的本次聊天", 1),
_("div", {
class: Ue(["star-rating", { submitted: vt.value || u.isSubmitted }])
}, [
(T(), A(ze, null, Et(5, (F) => _("button", {
key: F,
class: Ue(["star-button", {
warning: F <= (u.isSubmitted ? u.finalRating : Zt.value || u.selectedRating) && (u.isSubmitted ? u.finalRating : Zt.value || u.selectedRating) <= 3,
success: F <= (u.isSubmitted ? u.finalRating : Zt.value || u.selectedRating) && (u.isSubmitted ? u.finalRating : Zt.value || u.selectedRating) > 3,
selected: F <= (u.isSubmitted ? u.finalRating : Zt.value || u.selectedRating)
}]),
onMouseover: (an) => !u.isSubmitted && Ts(F),
onMouseleave: (an) => !u.isSubmitted && Wn,
onClick: (an) => !u.isSubmitted && as(F),
disabled: vt.value || u.isSubmitted
}, " ★ ", 42, jy)), 64))
], 2),
u.showFeedback && !u.isSubmitted ? (T(), A("div", Vy, [
_("div", Ky, [
Vn(_("input", {
"onUpdate:modelValue": (F) => u.feedback = F,
placeholder: "请分享你的反馈(可选)",
disabled: vt.value,
maxlength: "500",
class: "feedback-input"
}, null, 8, Gy), [
[hs, u.feedback]
]),
_("div", Yy, se(((Ae = u.feedback) == null ? void 0 : Ae.length) || 0) + "/500", 1)
]),
_("button", {
onClick: (F) => Jt(u.session_id, Zt.value, u.feedback),
disabled: vt.value || !Zt.value,
class: "submit-rating-button",
style: Ee({ backgroundColor: S(s).accent_color || "var(--accent-solid)" })
}, se(vt.value ? "提交中…" : "提交评价"), 13, Zy)
])) : le("", !0),
u.isSubmitted && u.finalFeedback ? (T(), A("div", Xy, [
_("div", Jy, [
_("p", Qy, se(u.finalFeedback), 1)
])
])) : u.isSubmitted ? (T(), A("div", ev, " 感谢你的评价! ")) : le("", !0)
])) : u.message_type === "form" ? (T(), A("div", tv, [
(ct = (ge = u.attributes) == null ? void 0 : ge.form_data) != null && ct.title || (Ye = (it = u.attributes) == null ? void 0 : it.form_data) != null && Ye.description ? (T(), A("div", nv, [
(or = (ir = u.attributes) == null ? void 0 : ir.form_data) != null && or.title ? (T(), A("h3", sv, se(u.attributes.form_data.title), 1)) : le("", !0),
(Rs = (jn = u.attributes) == null ? void 0 : jn.form_data) != null && Rs.description ? (T(), A("p", rv, se(u.attributes.form_data.description), 1)) : le("", !0)
])) : le("", !0),
_("div", iv, [
(T(!0), A(ze, null, Et((qa = (Wa = u.attributes) == null ? void 0 : Wa.form_data) == null ? void 0 : qa.fields, (F) => {
var an, oo;
return T(), A("div", {
key: F.name,
class: "form-field"
}, [
_("label", {
for: `form-${F.name}`,
class: "field-label"
}, [
Ln(se(F.label) + " ", 1),
F.required ? (T(), A("span", av, "*")) : le("", !0)
], 8, ov),
F.type === "text" || F.type === "email" || F.type === "tel" ? (T(), A("input", {
key: 0,
id: `form-${F.name}`,
type: F.type,
placeholder: F.placeholder || "",
required: F.required,
minlength: F.minLength,
maxlength: F.maxLength,
value: ft.value[F.name] || "",
onInput: (We) => It(F.name, We.target.value),
onBlur: (We) => It(F.name, We.target.value),
class: Ue(["form-input", { error: Qe.value[F.name] }]),
disabled: ht.value,
autocomplete: F.type === "email" ? "email" : F.type === "tel" ? "tel" : "off",
inputmode: F.type === "tel" ? "tel" : F.type === "email" ? "email" : "text"
}, null, 42, lv)) : F.type === "number" ? (T(), A("input", {
key: 1,
id: `form-${F.name}`,
type: "number",
placeholder: F.placeholder || "",
required: F.required,
min: F.min,
max: F.max,
value: ft.value[F.name] || "",
onInput: (We) => It(F.name, We.target.value),
class: Ue(["form-input", { error: Qe.value[F.name] }]),
disabled: ht.value
}, null, 42, cv)) : F.type === "textarea" ? (T(), A("textarea", {
key: 2,
id: `form-${F.name}`,
placeholder: F.placeholder || "",
required: F.required,
minlength: F.minLength,
maxlength: F.maxLength,
value: ft.value[F.name] || "",
onInput: (We) => It(F.name, We.target.value),
class: Ue(["form-textarea", { error: Qe.value[F.name] }]),
disabled: ht.value,
rows: "3"
}, null, 42, uv)) : F.type === "select" ? (T(), A("select", {
key: 3,
id: `form-${F.name}`,
required: F.required,
value: ft.value[F.name] || "",
onChange: (We) => It(F.name, We.target.value),
class: Ue(["form-select", { error: Qe.value[F.name] }]),
disabled: ht.value
}, [
_("option", hv, se(F.placeholder || "请选择"), 1),
(T(!0), A(ze, null, Et((Array.isArray(F.options) ? F.options : ((an = F.options) == null ? void 0 : an.split(`
`)) || []).filter((We) => We.trim()), (We) => (T(), A("option", {
key: We.trim(),
value: We.trim()
}, se(We.trim()), 9, dv))), 128))
], 42, fv)) : F.type === "checkbox" ? (T(), A("div", pv, [
_("input", {
id: `form-${F.name}`,
type: "checkbox",
checked: ft.value[F.name] || !1,
onChange: (We) => It(F.name, We.target.checked),
class: "form-checkbox",
disabled: ht.value
}, null, 40, gv),
_("label", {
for: `form-${F.name}`,
class: "checkbox-label"
}, se(F.placeholder || F.label), 9, mv)
])) : F.type === "radio" ? (T(), A("div", _v, [
(T(!0), A(ze, null, Et((Array.isArray(F.options) ? F.options : ((oo = F.options) == null ? void 0 : oo.split(`
`)) || []).filter((We) => We.trim()), (We) => (T(), A("div", {
key: We.trim(),
class: "radio-option"
}, [
_("input", {
id: `form-${F.name}-${We.trim()}`,
name: `form-${F.name}`,
type: "radio",
value: We.trim(),
checked: ft.value[F.name] === We.trim(),
onChange: ($b) => It(F.name, We.trim()),
class: "form-radio",
disabled: ht.value
}, null, 40, yv),
_("label", {
for: `form-${F.name}-${We.trim()}`,
class: "radio-label"
}, se(We.trim()), 9, vv)
]))), 128))
])) : le("", !0),
Qe.value[F.name] ? (T(), A("div", bv, se(Qe.value[F.name]), 1)) : le("", !0)
]);
}), 128))
]),
_("div", wv, [
_("button", {
onClick: () => {
var F;
console.log("Regular form submit button clicked!"), As((F = u.attributes) == null ? void 0 : F.form_data);
},
disabled: ht.value,
class: "form-submit-button",
style: Ee(S(x))
}, se(ht.value ? "提交中…" : ((Va = (ja = u.attributes) == null ? void 0 : ja.form_data) == null ? void 0 : Va.submit_button_text) || "提交"), 13, kv)
])
])) : u.message_type === "user_input" ? (T(), A("div", xv, [
(Ka = u.attributes) != null && Ka.prompt_message && u.attributes.prompt_message.trim() ? (T(), A("div", Tv, se(u.attributes.prompt_message), 1)) : le("", !0),
u.isSubmitted ? (T(), A("div", Cv, [
g[36] || (g[36] = _("strong", null, "你的输入:", -1)),
Ln(" " + se(u.submittedValue) + " ", 1),
(Ga = u.attributes) != null && Ga.confirmation_message && u.attributes.confirmation_message.trim() ? (T(), A("div", Rv, se(u.attributes.confirmation_message), 1)) : le("", !0)
])) : (T(), A("div", Av, [
Vn(_("textarea", {
"onUpdate:modelValue": (F) => u.userInputValue = F,
class: "user-input-textarea",
placeholder: "输入消息…",
rows: "3",
onKeydown: [
li(gs((F) => ls(u), ["ctrl"]), ["enter"]),
li(gs((F) => ls(u), ["meta"]), ["enter"])
]
}, null, 40, Ev), [
[hs, u.userInputValue]
]),
_("button", {
class: "user-input-submit-button",
onClick: (F) => ls(u),
disabled: !u.userInputValue || !u.userInputValue.trim()
}, " 提交 ", 8, Sv)
]))
])) : u.shopify_output || u.message_type === "product" ? (T(), A("div", Iv, [
u.message ? (T(), A("div", {
key: 0,
innerHTML: S(ui)(((Za = (Ya = u.shopify_output) == null ? void 0 : Ya.products) == null ? void 0 : Za.length) > 0 ? Ji(u.message) : u.message),
class: "product-message-text"
}, null, 8, Lv)) : le("", !0),
(Xa = u.shopify_output) != null && Xa.products && u.shopify_output.products.length > 0 ? (T(), A("div", Ov, [
g[38] || (g[38] = _("h3", { class: "carousel-title" }, "商品", -1)),
_("div", Nv, [
(T(!0), A(ze, null, Et(u.shopify_output.products, (F) => {
var an;
return T(), A("div", {
key: F.id,
class: "product-card-compact carousel-item"
}, [
(an = F.image) != null && an.src ? (T(), A("div", Mv, [
_("img", {
src: F.image.src,
alt: F.title,
class: "product-thumbnail"
}, null, 8, Dv)
])) : le("", !0),
_("div", Pv, [
_("div", Fv, [
_("div", Bv, se(F.title), 1),
F.variant_title && F.variant_title !== "Default Title" ? (T(), A("div", $v, se(F.variant_title), 1)) : le("", !0),
_("div", Uv, se(F.price_formatted || S(a)(F.price, F.currency)), 1)
]),
_("div", zv, [
_("button", {
class: "view-details-button-compact",
onClick: (oo) => {
var We;
return qr(F, (We = u.shopify_output) == null ? void 0 : We.shop_domain);
}
}, g[37] || (g[37] = [
Ln(" 查看商品 ", -1),
_("span", { class: "external-link-icon" }, "↗", -1)
]), 8, Hv)
])
])
]);
}), 128))
])
])) : !u.message && ((Ja = u.shopify_output) != null && Ja.products) && u.shopify_output.products.length === 0 ? (T(), A("div", Wv, g[39] || (g[39] = [
_("p", null, "未找到商品。", -1)
]))) : !u.message && u.shopify_output && !u.shopify_output.products ? (T(), A("div", qv, g[40] || (g[40] = [
_("p", null, "暂无可显示的商品。", -1)
]))) : le("", !0)
])) : (T(), A(ze, { key: 4 }, [
S(Ze)(re) ? (T(), A("div", {
key: 0,
class: "message-streaming",
innerHTML: S(ui)(S(nt)(re, u.message))
}, null, 8, jv)) : (T(), A("div", {
key: 1,
innerHTML: S(ui)(u.message)
}, null, 8, Vv)),
u.attachments && u.attachments.length > 0 ? (T(), A("div", Kv, [
(T(!0), A(ze, null, Et(u.attachments, (F) => (T(), A("div", {
key: F.id,
class: "attachment-item"
}, [
S(on)(F.content_type) ? (T(), A("div", Gv, [
_("img", {
src: S(kn)(F.file_url),
alt: F.filename,
class: "attachment-image",
onClick: gs((an) => S(os)({ url: F.file_url, filename: F.filename, type: F.content_type, file_url: S(kn)(F.file_url), size: void 0 }), ["stop"]),
style: { cursor: "pointer" }
}, null, 8, Yv),
_("div", Zv, [
_("a", {
href: S(kn)(F.file_url),
target: "_blank",
class: "attachment-link"
}, [
g[41] || (g[41] = _("svg", {
width: "14",
height: "14",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
"stroke-width": "2",
"stroke-linecap": "round",
"stroke-linejoin": "round"
}, [
_("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
_("polyline", { points: "7 10 12 15 17 10" }),
_("line", {
x1: "12",
y1: "15",
x2: "12",
y2: "3"
})
], -1)),
Ln(" " + se(F.filename) + " ", 1),
_("span", Jv, "(" + se(S(wt)(F.file_size)) + ")", 1)
], 8, Xv)
])
])) : (T(), A("a", {
key: 1,
href: S(kn)(F.file_url),
target: "_blank",
class: "attachment-link"
}, [
g[42] || (g[42] = _("svg", {
width: "14",
height: "14",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
"stroke-width": "2",
"stroke-linecap": "round",
"stroke-linejoin": "round"
}, [
_("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" })
], -1)),
Ln(" " + se(F.filename) + " ", 1),
_("span", eb, "(" + se(S(wt)(F.file_size)) + ")", 1)
], 8, Qv))
]))), 128))
])) : le("", !0)
], 64))
], 4),
Gr.value && (u.message_type === "bot" || u.message_type === "agent") && u.sources && u.sources.length ? (T(), A("div", tb, [
g[43] || (g[43] = _("span", { class: "citation-label" }, "来源", -1)),
(T(!0), A(ze, null, Et(u.sources, (F, an) => (T(), A("span", {
key: an,
class: "citation-chip",
title: Ba(F)
}, se(to(F)), 9, nb))), 128))
])) : le("", !0),
_("div", sb, [
u.message_type === "user" ? (T(), A("span", rb, " 你 ")) : le("", !0)
])
])
], 2);
}), 128)),
S(d) ? (T(), A("div", {
key: 1,
class: Ue(["typing-indicator", { "reading-indicator": Gr.value }])
}, [
Gr.value ? (T(), A(ze, { key: 0 }, [
g[44] || (g[44] = _("div", {
class: "reading-bars",
"aria-hidden": "true"
}, [
_("span"),
_("span"),
_("span")
], -1)),
g[45] || (g[45] = _("span", { class: "reading-label" }, "正在读取知识库", -1))
], 64)) : (T(), A("div", {
key: 1,
class: "rp-typing-bubble",
style: Ee(S(D))
}, g[46] || (g[46] = [
_("span", { class: "rp-typing-dot" }, null, -1),
_("span", { class: "rp-typing-dot" }, null, -1),
_("span", { class: "rp-typing-dot" }, null, -1)
]), 4))
], 2)) : le("", !0)
], 512), [
[fd, !cs.value]
]),
nf.value ? (T(), A("div", ib, [
(T(!0), A(ze, null, Et(Qi.value, (u) => (T(), A("button", {
key: u,
type: "button",
class: "rp-quick-action",
disabled: !Tn.value,
onClick: (re) => Br(u)
}, se(u), 9, ob))), 128))
])) : le("", !0),
!Hn.value && !cs.value ? (T(), A("div", {
key: 6,
class: Ue(["chat-input", { "ask-anything-input": Qt.value }])
}, [
_("input", {
ref_key: "fileInputRef",
ref: Le,
type: "file",
accept: Nb,
multiple: "",
style: { display: "none" },
onChange: g[7] || (g[7] = //@ts-ignore
(...u) => S(Vs) && S(Vs)(...u))
}, null, 544),
S(Ce).length > 0 ? (T(), A("div", ab, [
(T(!0), A(ze, null, Et(S(Ce), (u, re) => (T(), A("div", {
key: re,
class: "file-preview-widget"
}, [
_("div", lb, [
S(ks)(u.type) ? (T(), A("img", {
key: 0,
src: S(js)(u),
alt: u.filename,
class: "file-preview-image-widget",
onClick: gs((Ae) => S(os)(u), ["stop"]),
style: { cursor: "pointer" }
}, null, 8, cb)) : (T(), A("div", {
key: 1,
class: "file-preview-icon-widget",
onClick: gs((Ae) => S(os)(u), ["stop"]),
style: { cursor: "pointer" }
}, g[47] || (g[47] = [
_("svg", {
width: "20",
height: "20",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
"stroke-width": "2"
}, [
_("path", { d: "M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z" }),
_("polyline", { points: "13 2 13 9 20 9" })
], -1)
]), 8, ub))
]),
_("div", fb, [
_("div", hb, se(u.filename), 1),
_("div", db, se(S(wt)(u.size)), 1)
]),
_("button", {
type: "button",
class: "file-preview-remove-widget",
onClick: (Ae) => S(Ks)(re),
title: "移除文件"
}, " × ", 8, pb)
]))), 128))
])) : le("", !0),
er.value ? (T(), A("div", gb, g[48] || (g[48] = [
_("div", { class: "upload-spinner-widget" }, null, -1),
_("span", { class: "upload-text-widget" }, "正在上传文件…", -1)
]))) : le("", !0),
_("div", mb, [
Vn(_("input", {
"onUpdate:modelValue": g[8] || (g[8] = (u) => Te.value = u),
type: "text",
placeholder: Ys.value,
onKeypress: Sn,
onInput: Re,
onChange: Re,
onPaste: g[9] || (g[9] = //@ts-ignore
(...u) => S(xn) && S(xn)(...u)),
onDrop: g[10] || (g[10] = //@ts-ignore
(...u) => S(rs) && S(rs)(...u)),
onDragover: g[11] || (g[11] = //@ts-ignore
(...u) => S(is) && S(is)(...u)),
onDragleave: g[12] || (g[12] = //@ts-ignore
(...u) => S(qt) && S(qt)(...u)),
disabled: !An.value,
class: Ue({ disabled: !An.value, "ask-anything-field": Qt.value })
}, null, 42, _b), [
[hs, Te.value]
]),
Vr.value ? (T(), A("button", {
key: 0,
type: "button",
class: "attach-button",
disabled: er.value,
onClick: g[13] || (g[13] = //@ts-ignore
(...u) => S(Gs) && S(Gs)(...u)),
title: `添加文件(已用 ${S(Ce).length}/${fc})或粘贴截图`
}, g[49] || (g[49] = [
_("svg", {
width: "22",
height: "22",
viewBox: "0 0 24 24",
fill: "none",
xmlns: "http://www.w3.org/2000/svg"
}, [
_("path", {
d: "M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48",
stroke: "currentColor",
"stroke-width": "2.2",
"stroke-linecap": "round",
"stroke-linejoin": "round"
})
], -1),
_("span", { class: "attach-button-glow" }, null, -1)
]), 8, yb)) : le("", !0),
_("button", {
class: Ue(["send-button", { "ask-anything-send": Qt.value }]),
"aria-label": "发送消息",
style: Ee(S(x)),
onClick: un,
disabled: !Te.value.trim() && S(Ce).length === 0 || !Tn.value
}, g[50] || (g[50] = [
_("svg", {
width: "20",
height: "20",
viewBox: "0 0 24 24",
fill: "none",
xmlns: "http://www.w3.org/2000/svg"
}, [
_("path", {
d: "M12 19V5M5 12l7-7 7 7",
stroke: "currentColor",
"stroke-width": "2.2",
"stroke-linecap": "round",
"stroke-linejoin": "round"
})
], -1)
]), 14, vb)
])
], 2)) : Hn.value && !cs.value ? (T(), A("div", bb, [
_("div", wb, [
g[51] || (g[51] = _("p", { class: "ended-text" }, "本次聊天已结束。", -1)),
_("button", {
class: "start-new-conversation-button",
style: Ee(S(x)),
onClick: Xu
}, " 点击开始新对话 ", 4)
])
])) : le("", !0),
Fa.value ? (T(), A("div", kb, se(S(Xl)), 1)) : le("", !0),
_("div", {
class: "powered-by",
style: Ee(S(H))
}, [
$t(mr, {
class: "replypier-logo",
size: 20
}),
g[52] || (g[52] = _("a", {
class: "rp-powered-link",
href: "https://replypier.site",
target: "_blank",
rel: "noopener"
}, [
_("span", { class: "rp-powered-prefix" }, "由 "),
_("strong", { class: "rp-brand" }, "ReplyPier"),
_("span", { class: "rp-powered-prefix" }, " 提供支持")
], -1))
], 4)
], 6)) : le("", !0),
zr.value ? (T(), A("div", xb, [
_("div", Tb, [
g[53] || (g[53] = _("h3", null, "评价本次对话", -1)),
_("div", Ab, [
(T(), A(ze, null, Et(5, (u) => _("button", {
key: u,
onClick: (re) => xs.value = u,
class: Ue([{ active: u <= xs.value }, "star-button"])
}, " ★ ", 10, Eb)), 64))
]),
Vn(_("textarea", {
"onUpdate:modelValue": g[14] || (g[14] = (u) => Xs.value = u),
placeholder: "补充反馈(可选)",
class: "rating-feedback"
}, null, 512), [
[hs, Xs.value]
]),
_("div", Sb, [
_("button", {
onClick: g[15] || (g[15] = (u) => h.submitRating(xs.value, Xs.value)),
disabled: !xs.value,
class: "submit-button",
style: Ee(S(x))
}, " 提交 ", 12, Cb),
_("button", {
onClick: g[16] || (g[16] = (u) => zr.value = !1),
class: "skip-rating"
}, " 跳过 ")
])
])
])) : le("", !0),
S($e) ? (T(), A("div", {
key: 9,
class: "preview-modal-overlay",
onClick: g[19] || (g[19] = //@ts-ignore
(...u) => S(ws) && S(ws)(...u))
}, [
_("div", {
class: "preview-modal-content",
onClick: g[18] || (g[18] = gs(() => {
}, ["stop"]))
}, [
_("button", {
class: "preview-modal-close",
onClick: g[17] || (g[17] = //@ts-ignore
(...u) => S(ws) && S(ws)(...u))
}, "×"),
S(Xe) && S(ks)(S(Xe).type) ? (T(), A("div", Rb, [
_("img", {
src: S(js)(S(Xe)),
alt: S(Xe).filename,
class: "preview-modal-image"
}, null, 8, Ib),
_("div", Lb, se(S(Xe).filename), 1)
])) : le("", !0)
])
])) : le("", !0)
], 6)) : (T(), A("div", Ob));
}
}), Db = /* @__PURE__ */ Gi(Mb, [["__scopeId", "data-v-0e2df0b3"]]);
window.process || (window.process = { env: { NODE_ENV: "production" } });
const nn = window.__INITIAL_DATA__, Gu = new URL(window.location.href), Yu = Gu.searchParams.get("preview") === "true", Zu = (e) => {
const t = Gu.searchParams.get(e);
if (!(!t || t === "undefined" || t.trim() === ""))
return t;
}, Pb = Yu ? Zu("widget_id") || (nn == null ? void 0 : nn.widgetId) || void 0 : (nn == null ? void 0 : nn.widgetId) || void 0, Fb = Yu ? (nn == null ? void 0 : nn.initialToken) || Zu("token") || void 0 : (nn == null ? void 0 : nn.initialToken) || void 0, Bb = Ld(Db, {
widgetId: Pb,
token: Fb || void 0,
initialAuthError: null
// Let backend determine if auth is required
});
Bb.mount("#app");