@pagelines/sdk 1.0.298 → 1.0.300

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/AgentProvider.vue_vue_type_script_setup_true_lang-BbIV7Wql.js +4292 -0
  2. package/dist/AgentProvider.vue_vue_type_script_setup_true_lang-BbIV7Wql.js.map +1 -0
  3. package/dist/{AgentWidgetInline-DSsDV1ks.js → AgentWidgetInline-D-EnK-U4.js} +3 -3
  4. package/dist/{AgentWidgetInline-DSsDV1ks.js.map → AgentWidgetInline-D-EnK-U4.js.map} +1 -1
  5. package/dist/{AgentWidgetModal-DLL8guTy.js → AgentWidgetModal-atkbqtwM.js} +3 -3
  6. package/dist/{AgentWidgetModal-DLL8guTy.js.map → AgentWidgetModal-atkbqtwM.js.map} +1 -1
  7. package/dist/AgentWrap.vue_vue_type_script_setup_true_lang-Dq-gz8bM.js +2493 -0
  8. package/dist/AgentWrap.vue_vue_type_script_setup_true_lang-Dq-gz8bM.js.map +1 -0
  9. package/dist/agent/ui/ElAgentChat.vue.d.ts +6 -0
  10. package/dist/agent.js +13 -12
  11. package/dist/agent.js.map +1 -1
  12. package/dist/clients/types.d.ts +1 -1
  13. package/dist/index-BHMEO2s_.js +374 -0
  14. package/dist/index-BHMEO2s_.js.map +1 -0
  15. package/dist/sdk.css +1 -1
  16. package/dist/widget/PLWidget.d.ts +2 -0
  17. package/dist/widget/index.d.ts +1 -0
  18. package/dist/widget/ui/AgentWidgetPopup.vue.d.ts +2 -4
  19. package/dist/widget.js +4 -214
  20. package/dist/widget.js.map +1 -1
  21. package/package.json +1 -1
  22. package/dist/AgentProvider.vue_vue_type_script_setup_true_lang-Bg_PPQPT.js +0 -44
  23. package/dist/AgentProvider.vue_vue_type_script_setup_true_lang-Bg_PPQPT.js.map +0 -1
  24. package/dist/AgentWidgetPopup-CUrXOmYA.js +0 -119
  25. package/dist/AgentWidgetPopup-CUrXOmYA.js.map +0 -1
  26. package/dist/AgentWrap.vue_vue_type_script_setup_true_lang-CwKY5BM_.js +0 -6717
  27. package/dist/AgentWrap.vue_vue_type_script_setup_true_lang-CwKY5BM_.js.map +0 -1
  28. package/dist/useWidgetState-BGtx6NKD.js +0 -15
  29. package/dist/useWidgetState-BGtx6NKD.js.map +0 -1
@@ -0,0 +1,2493 @@
1
+ var En = Object.defineProperty;
2
+ var ks = (l, t, e) => t in l ? En(l, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[t] = e;
3
+ var h = (l, t) => En(l, "name", { value: t, configurable: !0 });
4
+ var E = (l, t, e) => ks(l, typeof t != "symbol" ? t + "" : t, e);
5
+ import { defineComponent as xt, openBlock as v, createElementBlock as S, createElementVNode as y, normalizeClass as _, ref as ne, watch as Wt, unref as jt, Fragment as ve, toDisplayString as ce, computed as Q, onMounted as jn, nextTick as Nt, createVNode as zt, createCommentVNode as q, renderList as Pt, createTextVNode as xs, withDirectives as bs, normalizeStyle as ws, vModelText as ys, shallowRef as Ts, renderSlot as vs } from "vue";
6
+ import { SettingsObject as Ss, Agent as dt, getDefaultAvatarUrl as qn, createLogger as As } from "@pagelines/core";
7
+ import { P as Es } from "./sdkClient-6j3pmwVP.js";
8
+ const _s = { class: "spinner max-w-sm" }, Rs = {
9
+ class: "ring-circular h-full w-full origin-center",
10
+ viewBox: "25 25 50 50"
11
+ }, _n = /* @__PURE__ */ xt({
12
+ __name: "FSpinner",
13
+ props: {
14
+ width: { type: String, default: "" },
15
+ colorMode: { type: String, default: "primary" }
16
+ },
17
+ setup(l) {
18
+ return (t, e) => (v(), S("div", _s, [
19
+ (v(), S("svg", Rs, [
20
+ y("circle", {
21
+ class: _([l.colorMode, "ring-path"]),
22
+ cx: "50",
23
+ cy: "50",
24
+ r: "20",
25
+ fill: "none",
26
+ stroke: "currentColor",
27
+ "stroke-width": "5",
28
+ "stroke-miterlimit": "30"
29
+ }, null, 2)
30
+ ]))
31
+ ]));
32
+ }
33
+ }), rn = class rn extends Ss {
34
+ constructor(e) {
35
+ super("AgentChatController", e);
36
+ E(this, "isTextMode", !1);
37
+ E(this, "lastMessage", { hash: "", time: 0 });
38
+ E(this, "isConnecting", !1);
39
+ // Chat conversation tracking (server-managed persistence)
40
+ E(this, "conversationId");
41
+ E(this, "textState", ne({
42
+ isActive: !1,
43
+ isConnected: !1,
44
+ isThinking: !1,
45
+ connectionStatus: "disconnected"
46
+ }));
47
+ E(this, "agentMode", ne("self"));
48
+ E(this, "sharedMessages", ne([]));
49
+ E(this, "_agent");
50
+ this._agent = e.agent instanceof dt ? e.agent : new dt({ config: e.agent }), this.setupModeWatcher();
51
+ }
52
+ get chatEnabled() {
53
+ return this._agent.chatAvailable.value;
54
+ }
55
+ get chatUnavailableReason() {
56
+ return this._agent.chatUnavailable.value;
57
+ }
58
+ mapChatError(e) {
59
+ return e.includes("429") || e.includes("Too many") ? "Too many messages. Please wait a moment." : e.includes("503") || e.includes("not available") ? "Agent is currently offline." : e.includes("timed out") || e.includes("starting up") ? "Agent is starting up. Please try again." : e.includes("404") ? "Agent not found." : "Something went wrong. Please try again.";
60
+ }
61
+ isTransientError(e) {
62
+ return e.includes("timed out") || e.includes("starting up") || e.includes("503");
63
+ }
64
+ isDuplicateMessage(e, n) {
65
+ const s = `${n}:${e.toLowerCase().trim()}`, r = Date.now(), a = s === this.lastMessage.hash && r - this.lastMessage.time < 500;
66
+ return a || (this.lastMessage = { hash: s, time: r }), a;
67
+ }
68
+ addMessage(e, n, s) {
69
+ this.isDuplicateMessage(e, n) || (this.sharedMessages.value = [
70
+ ...this.sharedMessages.value,
71
+ { id: Date.now().toString(), text: e, sender: n, timestamp: /* @__PURE__ */ new Date(), attachments: s }
72
+ ]);
73
+ }
74
+ getDynamicSettings() {
75
+ const { sdk: e } = this.settings;
76
+ if (!e) return { context: this.settings.context || "", firstMessage: this.settings.firstMessage || "" };
77
+ const n = e.activeUser.value, s = n?.agents?.find((a) => a.agentId === n.primaryAgentId), r = n ? `
78
+
79
+ Current User:
80
+ - Name: ${s?.name || "Anonymous"}
81
+ - Email: ${n.email}
82
+ - Title: ${s?.title || ""}
83
+ - About: ${s?.summary || ""}
84
+ ` : "";
85
+ return {
86
+ context: `${this.settings.context || ""}${r}`.trim(),
87
+ firstMessage: this.settings.firstMessage || ""
88
+ };
89
+ }
90
+ updateState(e, n) {
91
+ e.value = { ...e.value, ...n };
92
+ }
93
+ resetState() {
94
+ this.updateState(this.textState, {
95
+ isActive: !1,
96
+ isConnected: !1,
97
+ isThinking: !1,
98
+ connectionStatus: "disconnected",
99
+ error: void 0
100
+ });
101
+ }
102
+ setupModeWatcher() {
103
+ Wt(this.agentMode, async (e, n) => {
104
+ this.logger.info(`Mode changed from ${n} to ${e}`), this.isTextMode && (n === "talk" || n === "chat") && await this.endConversation();
105
+ });
106
+ }
107
+ handleError(e) {
108
+ const n = e.message;
109
+ this.logger.error("Conversation error:", e), this.resetState(), this.updateState(this.textState, {
110
+ error: n,
111
+ connectionStatus: "error"
112
+ });
113
+ }
114
+ async setMode(e) {
115
+ this.agentMode.value !== e && (this.agentMode.value = e);
116
+ }
117
+ // HTTP per-message model — mark connected immediately
118
+ async startTextConversation(e = {}) {
119
+ if (this.isConnecting) {
120
+ this.logger.info("Text conversation already connecting, ignoring duplicate request");
121
+ return;
122
+ }
123
+ this.isConnecting = !0, this.isTextMode = !0, this.updateState(this.textState, { isActive: !0, connectionStatus: "connecting" });
124
+ try {
125
+ if (!this.settings.chatStreamFn && !this.chatEnabled) {
126
+ this.isConnecting = !1, this.updateState(this.textState, {
127
+ isConnected: !1,
128
+ connectionStatus: "disconnected",
129
+ error: this.chatUnavailableReason
130
+ });
131
+ return;
132
+ }
133
+ this.isConnecting = !1, this.updateState(this.textState, { isConnected: !0, connectionStatus: "connected" }), e.onConnect?.(), this.logger.info("Text conversation ready");
134
+ } catch (n) {
135
+ throw this.isConnecting = !1, this.handleError(n), n;
136
+ }
137
+ }
138
+ async endConversation() {
139
+ if (!this.isTextMode) {
140
+ this.resetState();
141
+ return;
142
+ }
143
+ try {
144
+ this.conversationId = void 0, this.resetState(), this.isTextMode = !1;
145
+ } catch {
146
+ this.isTextMode = !1;
147
+ }
148
+ }
149
+ async sendChatMessage(e, n) {
150
+ if (!this.isTextMode)
151
+ return;
152
+ const { chatStreamFn: s } = this.settings;
153
+ if (!s && !this.chatEnabled) {
154
+ this.addMessage("Agent is currently offline.", "system");
155
+ return;
156
+ }
157
+ const { sdk: r } = this.settings;
158
+ if (!s && !this._agent.handle.value) {
159
+ this.handleError(new Error("Agent handle required for chat"));
160
+ return;
161
+ }
162
+ this.addMessage(e, "user", n), this.updateState(this.textState, { isThinking: !0 });
163
+ const a = `stream-${Date.now()}`, o = /* @__PURE__ */ h((d) => {
164
+ this.textState.value.isThinking && (this.updateState(this.textState, { isThinking: !1 }), this.sharedMessages.value = [
165
+ ...this.sharedMessages.value,
166
+ { id: a, text: "", sender: "agent", timestamp: /* @__PURE__ */ new Date() }
167
+ ]);
168
+ const m = this.sharedMessages.value, b = m[m.length - 1];
169
+ b?.id === a && (b.text += d, this.sharedMessages.value = [...m]);
170
+ }, "onDelta"), c = /* @__PURE__ */ h((d) => {
171
+ d && (this.conversationId = d), this.updateState(this.textState, { isThinking: !1 });
172
+ }, "onDone"), p = /* @__PURE__ */ h((d) => {
173
+ const m = this.sharedMessages.value, b = m[m.length - 1];
174
+ b?.id === a && !b.text && (this.sharedMessages.value = m.slice(0, -1));
175
+ const L = this.mapChatError(d);
176
+ this.isTransientError(d) ? (this.addMessage(L, "system"), this.updateState(this.textState, { isThinking: !1 })) : this.handleError(new Error(L));
177
+ }, "onError"), f = /* @__PURE__ */ h((d) => {
178
+ this.addMessage(d, "system");
179
+ }, "onStatus");
180
+ try {
181
+ if (s)
182
+ await s({
183
+ message: e,
184
+ attachments: n,
185
+ conversationId: this.conversationId,
186
+ history: this.buildHistory(),
187
+ onDelta: o,
188
+ onDone: c,
189
+ onError: p,
190
+ onStatus: f
191
+ });
192
+ else {
193
+ const { context: d } = this.getDynamicSettings();
194
+ await r.chatStream({
195
+ handle: this._agent.handle.value,
196
+ message: e,
197
+ attachments: n,
198
+ conversationId: this.conversationId,
199
+ history: this.buildHistory(),
200
+ visitorId: r.generateAnonId(),
201
+ context: d || void 0,
202
+ onDelta: o,
203
+ onDone: c,
204
+ onError: p,
205
+ onStatus: f
206
+ });
207
+ }
208
+ } catch (d) {
209
+ this.handleError(d);
210
+ }
211
+ }
212
+ buildHistory() {
213
+ return this.sharedMessages.value.filter((e) => e.sender === "user" || e.sender === "agent").slice(-20).map((e) => ({
214
+ role: e.sender === "user" ? "user" : "assistant",
215
+ content: e.text,
216
+ ...e.attachments?.length ? { attachments: e.attachments } : {}
217
+ })).filter((e) => e.content.length > 0 || e.attachments && e.attachments.length > 0);
218
+ }
219
+ async destroy() {
220
+ await this.endConversation();
221
+ }
222
+ };
223
+ h(rn, "AgentChatController");
224
+ let Rn = rn;
225
+ function Dn(l) {
226
+ return l ? typeof l == "string" ? l : l.src || "" : "";
227
+ }
228
+ h(Dn, "getImageSrc");
229
+ function Si(l) {
230
+ return Dn(l.cover) || Dn(l.avatar) || qn(l.name);
231
+ }
232
+ h(Si, "getAgentAvatarUrl");
233
+ function Cn(l) {
234
+ const t = l.target;
235
+ t.dataset.fallbackUsed || (t.dataset.fallbackUsed = "true", t.src = qn());
236
+ }
237
+ h(Cn, "handleImageError");
238
+ function Ai(l) {
239
+ const { template: t, agent: e } = l;
240
+ return t.replace(/{name}/g, e.name || "Digital Agent").replace(/{title}/g, e.title || "").replace(/{handle}/g, e.handle || "").replace(/{orgName}/g, e.org?.name || "");
241
+ }
242
+ h(Ai, "parseButtonTemplate");
243
+ const Ds = { class: "relative flex-shrink-0" }, Cs = ["src", "alt"], Ms = { class: "absolute top-1 right-1" }, Is = {
244
+ key: 1,
245
+ class: "size-3 bg-theme-400 rounded-full ring-2 ring-white"
246
+ }, Ls = { class: "min-w-0" }, Os = /* @__PURE__ */ xt({
247
+ __name: "ElModeHeader",
248
+ props: {
249
+ agent: {},
250
+ size: { default: "md" },
251
+ isOnline: { type: Boolean, default: !1 },
252
+ layout: { default: "centered" }
253
+ },
254
+ setup(l) {
255
+ return (t, e) => (v(), S("div", {
256
+ class: _(["flex gap-4", [
257
+ l.layout === "centered" ? "flex-col items-center text-center" : "flex-row items-center justify-center"
258
+ ]])
259
+ }, [
260
+ y("div", Ds, [
261
+ y("div", {
262
+ class: _(["rounded-full overflow-hidden border-white", l.size === "lg" ? "w-20 h-20 sm:w-24 sm:h-24 border-4" : "w-16 sm:size-16 border-2"])
263
+ }, [
264
+ y("img", {
265
+ src: l.agent.avatarUrl.value,
266
+ alt: l.agent.displayName.value,
267
+ class: "w-full h-full object-cover",
268
+ onError: e[0] || (e[0] = //@ts-ignore
269
+ (...n) => jt(Cn) && jt(Cn)(...n))
270
+ }, null, 40, Cs)
271
+ ], 2),
272
+ y("div", Ms, [
273
+ l.isOnline ? (v(), S(ve, { key: 0 }, [
274
+ e[1] || (e[1] = y("div", {
275
+ class: "size-3 bg-green-500 rounded-full ring-2 ring-white absolute animate-ping",
276
+ style: { "animation-duration": "3s" }
277
+ }, null, -1)),
278
+ e[2] || (e[2] = y("div", { class: "size-3 bg-green-500 rounded-full ring-2 ring-white" }, null, -1))
279
+ ], 64)) : (v(), S("div", Is))
280
+ ])
281
+ ]),
282
+ y("div", Ls, [
283
+ y("h1", {
284
+ class: _(["font-light text-white mb-1 truncate", [
285
+ l.size === "lg" ? "text-3xl mb-2" : "text-xl sm:text-2xl tracking-wide leading-tight",
286
+ l.layout === "horizontal" ? "text-white/95" : ""
287
+ ]])
288
+ }, ce(l.agent.displayName.value), 3),
289
+ y("p", {
290
+ class: _(["font-light line-clamp-1", [
291
+ l.size === "lg" ? "text-base text-white/60" : "text-sm sm:text-base",
292
+ l.layout === "horizontal" ? "text-white/70 truncate" : "text-white/60"
293
+ ]])
294
+ }, ce(l.layout === "horizontal" ? l.agent.title.value || "Digital Agent" : l.agent.title.value), 3)
295
+ ])
296
+ ], 2));
297
+ }
298
+ });
299
+ const {
300
+ entries: Yn,
301
+ setPrototypeOf: Mn,
302
+ isFrozen: Ns,
303
+ getPrototypeOf: zs,
304
+ getOwnPropertyDescriptor: Ps
305
+ } = Object;
306
+ let {
307
+ freeze: Z,
308
+ seal: J,
309
+ create: pt
310
+ } = Object, {
311
+ apply: qt,
312
+ construct: Yt
313
+ } = typeof Reflect < "u" && Reflect;
314
+ Z || (Z = /* @__PURE__ */ h(function(t) {
315
+ return t;
316
+ }, "freeze"));
317
+ J || (J = /* @__PURE__ */ h(function(t) {
318
+ return t;
319
+ }, "seal"));
320
+ qt || (qt = /* @__PURE__ */ h(function(t, e) {
321
+ for (var n = arguments.length, s = new Array(n > 2 ? n - 2 : 0), r = 2; r < n; r++)
322
+ s[r - 2] = arguments[r];
323
+ return t.apply(e, s);
324
+ }, "apply"));
325
+ Yt || (Yt = /* @__PURE__ */ h(function(t) {
326
+ for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), s = 1; s < e; s++)
327
+ n[s - 1] = arguments[s];
328
+ return new t(...n);
329
+ }, "construct"));
330
+ const ct = X(Array.prototype.forEach), $s = X(Array.prototype.lastIndexOf), In = X(Array.prototype.pop), Ge = X(Array.prototype.push), Us = X(Array.prototype.splice), ft = X(String.prototype.toLowerCase), $t = X(String.prototype.toString), Ut = X(String.prototype.match), We = X(String.prototype.replace), Bs = X(String.prototype.indexOf), Fs = X(String.prototype.trim), K = X(Object.prototype.hasOwnProperty), j = X(RegExp.prototype.test), je = Hs(TypeError);
331
+ function X(l) {
332
+ return function(t) {
333
+ t instanceof RegExp && (t.lastIndex = 0);
334
+ for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), s = 1; s < e; s++)
335
+ n[s - 1] = arguments[s];
336
+ return qt(l, t, n);
337
+ };
338
+ }
339
+ h(X, "unapply");
340
+ function Hs(l) {
341
+ return function() {
342
+ for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++)
343
+ e[n] = arguments[n];
344
+ return Yt(l, e);
345
+ };
346
+ }
347
+ h(Hs, "unconstruct");
348
+ function T(l, t) {
349
+ let e = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ft;
350
+ Mn && Mn(l, null);
351
+ let n = t.length;
352
+ for (; n--; ) {
353
+ let s = t[n];
354
+ if (typeof s == "string") {
355
+ const r = e(s);
356
+ r !== s && (Ns(t) || (t[n] = r), s = r);
357
+ }
358
+ l[s] = !0;
359
+ }
360
+ return l;
361
+ }
362
+ h(T, "addToSet");
363
+ function Gs(l) {
364
+ for (let t = 0; t < l.length; t++)
365
+ K(l, t) || (l[t] = null);
366
+ return l;
367
+ }
368
+ h(Gs, "cleanArray");
369
+ function le(l) {
370
+ const t = pt(null);
371
+ for (const [e, n] of Yn(l))
372
+ K(l, e) && (Array.isArray(n) ? t[e] = Gs(n) : n && typeof n == "object" && n.constructor === Object ? t[e] = le(n) : t[e] = n);
373
+ return t;
374
+ }
375
+ h(le, "clone");
376
+ function qe(l, t) {
377
+ for (; l !== null; ) {
378
+ const n = Ps(l, t);
379
+ if (n) {
380
+ if (n.get)
381
+ return X(n.get);
382
+ if (typeof n.value == "function")
383
+ return X(n.value);
384
+ }
385
+ l = zs(l);
386
+ }
387
+ function e() {
388
+ return null;
389
+ }
390
+ return h(e, "fallbackValue"), e;
391
+ }
392
+ h(qe, "lookupGetter");
393
+ const Ln = Z(["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"]), Bt = Z(["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"]), Ft = Z(["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"]), Ws = Z(["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"]), Ht = Z(["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"]), js = Z(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), On = Z(["#text"]), Nn = Z(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "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", "slot"]), Gt = Z(["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", "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", "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-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "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"]), zn = Z(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "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"]), ut = Z(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), qs = J(/\{\{[\w\W]*|[\w\W]*\}\}/gm), Ys = J(/<%[\w\W]*|[\w\W]*%>/gm), Zs = J(/\$\{[\w\W]*/gm), Xs = J(/^data-[\-\w.\u00B7-\uFFFF]+$/), Vs = J(/^aria-[\-\w]+$/), Zn = J(
394
+ /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
395
+ // eslint-disable-line no-useless-escape
396
+ ), Qs = J(/^(?:\w+script|data):/i), Ks = J(
397
+ /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
398
+ // eslint-disable-line no-control-regex
399
+ ), Xn = J(/^html$/i), Js = J(/^[a-z][.\w]*(-[.\w]+)+$/i);
400
+ var Pn = /* @__PURE__ */ Object.freeze({
401
+ __proto__: null,
402
+ ARIA_ATTR: Vs,
403
+ ATTR_WHITESPACE: Ks,
404
+ CUSTOM_ELEMENT: Js,
405
+ DATA_ATTR: Xs,
406
+ DOCTYPE_NAME: Xn,
407
+ ERB_EXPR: Ys,
408
+ IS_ALLOWED_URI: Zn,
409
+ IS_SCRIPT_OR_DATA: Qs,
410
+ MUSTACHE_EXPR: qs,
411
+ TMPLIT_EXPR: Zs
412
+ });
413
+ const Ye = {
414
+ element: 1,
415
+ text: 3,
416
+ // Deprecated
417
+ progressingInstruction: 7,
418
+ comment: 8,
419
+ document: 9
420
+ }, er = /* @__PURE__ */ h(function() {
421
+ return typeof window > "u" ? null : window;
422
+ }, "getGlobal"), tr = /* @__PURE__ */ h(function(t, e) {
423
+ if (typeof t != "object" || typeof t.createPolicy != "function")
424
+ return null;
425
+ let n = null;
426
+ const s = "data-tt-policy-suffix";
427
+ e && e.hasAttribute(s) && (n = e.getAttribute(s));
428
+ const r = "dompurify" + (n ? "#" + n : "");
429
+ try {
430
+ return t.createPolicy(r, {
431
+ createHTML(a) {
432
+ return a;
433
+ },
434
+ createScriptURL(a) {
435
+ return a;
436
+ }
437
+ });
438
+ } catch {
439
+ return console.warn("TrustedTypes policy " + r + " could not be created."), null;
440
+ }
441
+ }, "_createTrustedTypesPolicy"), $n = /* @__PURE__ */ h(function() {
442
+ return {
443
+ afterSanitizeAttributes: [],
444
+ afterSanitizeElements: [],
445
+ afterSanitizeShadowDOM: [],
446
+ beforeSanitizeAttributes: [],
447
+ beforeSanitizeElements: [],
448
+ beforeSanitizeShadowDOM: [],
449
+ uponSanitizeAttribute: [],
450
+ uponSanitizeElement: [],
451
+ uponSanitizeShadowNode: []
452
+ };
453
+ }, "_createHooksMap");
454
+ function Vn() {
455
+ let l = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : er();
456
+ const t = /* @__PURE__ */ h((k) => Vn(k), "DOMPurify");
457
+ if (t.version = "3.3.2", t.removed = [], !l || !l.document || l.document.nodeType !== Ye.document || !l.Element)
458
+ return t.isSupported = !1, t;
459
+ let {
460
+ document: e
461
+ } = l;
462
+ const n = e, s = n.currentScript, {
463
+ DocumentFragment: r,
464
+ HTMLTemplateElement: a,
465
+ Node: o,
466
+ Element: c,
467
+ NodeFilter: p,
468
+ NamedNodeMap: f = l.NamedNodeMap || l.MozNamedAttrMap,
469
+ HTMLFormElement: d,
470
+ DOMParser: m,
471
+ trustedTypes: b
472
+ } = l, L = c.prototype, D = qe(L, "cloneNode"), H = qe(L, "remove"), _e = qe(L, "nextSibling"), me = qe(L, "childNodes"), ee = qe(L, "parentNode");
473
+ if (typeof a == "function") {
474
+ const k = e.createElement("template");
475
+ k.content && k.content.ownerDocument && (e = k.content.ownerDocument);
476
+ }
477
+ let $, W = "";
478
+ const {
479
+ implementation: te,
480
+ createNodeIterator: ue,
481
+ createDocumentFragment: Ke,
482
+ getElementsByTagName: Je
483
+ } = e, {
484
+ importNode: yt
485
+ } = n;
486
+ let B = $n();
487
+ t.isSupported = typeof Yn == "function" && typeof ee == "function" && te && te.createHTMLDocument !== void 0;
488
+ const {
489
+ MUSTACHE_EXPR: $e,
490
+ ERB_EXPR: O,
491
+ TMPLIT_EXPR: Ue,
492
+ DATA_ATTR: Tt,
493
+ ARIA_ATTR: vt,
494
+ IS_SCRIPT_OR_DATA: et,
495
+ ATTR_WHITESPACE: Be,
496
+ CUSTOM_ELEMENT: A
497
+ } = Pn;
498
+ let {
499
+ IS_ALLOWED_URI: w
500
+ } = Pn, x = null;
501
+ const I = T({}, [...Ln, ...Bt, ...Ft, ...Ht, ...On]);
502
+ let C = null;
503
+ const he = T({}, [...Nn, ...Gt, ...zn, ...ut]);
504
+ let N = Object.seal(pt(null, {
505
+ tagNameCheck: {
506
+ writable: !0,
507
+ configurable: !1,
508
+ enumerable: !0,
509
+ value: null
510
+ },
511
+ attributeNameCheck: {
512
+ writable: !0,
513
+ configurable: !1,
514
+ enumerable: !0,
515
+ value: null
516
+ },
517
+ allowCustomizedBuiltInElements: {
518
+ writable: !0,
519
+ configurable: !1,
520
+ enumerable: !0,
521
+ value: !1
522
+ }
523
+ })), pe = null, tt = null;
524
+ const ke = Object.seal(pt(null, {
525
+ tagCheck: {
526
+ writable: !0,
527
+ configurable: !1,
528
+ enumerable: !0,
529
+ value: null
530
+ },
531
+ attributeCheck: {
532
+ writable: !0,
533
+ configurable: !1,
534
+ enumerable: !0,
535
+ value: null
536
+ }
537
+ }));
538
+ let an = !0, St = !0, ln = !1, on = !0, Re = !1, nt = !0, ye = !1, At = !1, Et = !1, De = !1, st = !1, rt = !1, cn = !0, un = !1;
539
+ const cs = "user-content-";
540
+ let _t = !0, Fe = !1, Ce = {}, ie = null;
541
+ const Rt = T({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
542
+ let hn = null;
543
+ const pn = T({}, ["audio", "video", "img", "source", "image", "track"]);
544
+ let Dt = null;
545
+ const fn = T({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), it = "http://www.w3.org/1998/Math/MathML", at = "http://www.w3.org/2000/svg", fe = "http://www.w3.org/1999/xhtml";
546
+ let Me = fe, Ct = !1, Mt = null;
547
+ const us = T({}, [it, at, fe], $t);
548
+ let lt = T({}, ["mi", "mo", "mn", "ms", "mtext"]), ot = T({}, ["annotation-xml"]);
549
+ const hs = T({}, ["title", "style", "font", "a", "script"]);
550
+ let He = null;
551
+ const ps = ["application/xhtml+xml", "text/html"], fs = "text/html";
552
+ let U = null, Ie = null;
553
+ const ds = e.createElement("form"), dn = /* @__PURE__ */ h(function(i) {
554
+ return i instanceof RegExp || i instanceof Function;
555
+ }, "isRegexOrFunction"), It = /* @__PURE__ */ h(function() {
556
+ let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
557
+ if (!(Ie && Ie === i)) {
558
+ if ((!i || typeof i != "object") && (i = {}), i = le(i), He = // eslint-disable-next-line unicorn/prefer-includes
559
+ ps.indexOf(i.PARSER_MEDIA_TYPE) === -1 ? fs : i.PARSER_MEDIA_TYPE, U = He === "application/xhtml+xml" ? $t : ft, x = K(i, "ALLOWED_TAGS") ? T({}, i.ALLOWED_TAGS, U) : I, C = K(i, "ALLOWED_ATTR") ? T({}, i.ALLOWED_ATTR, U) : he, Mt = K(i, "ALLOWED_NAMESPACES") ? T({}, i.ALLOWED_NAMESPACES, $t) : us, Dt = K(i, "ADD_URI_SAFE_ATTR") ? T(le(fn), i.ADD_URI_SAFE_ATTR, U) : fn, hn = K(i, "ADD_DATA_URI_TAGS") ? T(le(pn), i.ADD_DATA_URI_TAGS, U) : pn, ie = K(i, "FORBID_CONTENTS") ? T({}, i.FORBID_CONTENTS, U) : Rt, pe = K(i, "FORBID_TAGS") ? T({}, i.FORBID_TAGS, U) : le({}), tt = K(i, "FORBID_ATTR") ? T({}, i.FORBID_ATTR, U) : le({}), Ce = K(i, "USE_PROFILES") ? i.USE_PROFILES : !1, an = i.ALLOW_ARIA_ATTR !== !1, St = i.ALLOW_DATA_ATTR !== !1, ln = i.ALLOW_UNKNOWN_PROTOCOLS || !1, on = i.ALLOW_SELF_CLOSE_IN_ATTR !== !1, Re = i.SAFE_FOR_TEMPLATES || !1, nt = i.SAFE_FOR_XML !== !1, ye = i.WHOLE_DOCUMENT || !1, De = i.RETURN_DOM || !1, st = i.RETURN_DOM_FRAGMENT || !1, rt = i.RETURN_TRUSTED_TYPE || !1, Et = i.FORCE_BODY || !1, cn = i.SANITIZE_DOM !== !1, un = i.SANITIZE_NAMED_PROPS || !1, _t = i.KEEP_CONTENT !== !1, Fe = i.IN_PLACE || !1, w = i.ALLOWED_URI_REGEXP || Zn, Me = i.NAMESPACE || fe, lt = i.MATHML_TEXT_INTEGRATION_POINTS || lt, ot = i.HTML_INTEGRATION_POINTS || ot, N = i.CUSTOM_ELEMENT_HANDLING || {}, i.CUSTOM_ELEMENT_HANDLING && dn(i.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (N.tagNameCheck = i.CUSTOM_ELEMENT_HANDLING.tagNameCheck), i.CUSTOM_ELEMENT_HANDLING && dn(i.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (N.attributeNameCheck = i.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), i.CUSTOM_ELEMENT_HANDLING && typeof i.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (N.allowCustomizedBuiltInElements = i.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), Re && (St = !1), st && (De = !0), Ce && (x = T({}, On), C = pt(null), Ce.html === !0 && (T(x, Ln), T(C, Nn)), Ce.svg === !0 && (T(x, Bt), T(C, Gt), T(C, ut)), Ce.svgFilters === !0 && (T(x, Ft), T(C, Gt), T(C, ut)), Ce.mathMl === !0 && (T(x, Ht), T(C, zn), T(C, ut))), K(i, "ADD_TAGS") || (ke.tagCheck = null), K(i, "ADD_ATTR") || (ke.attributeCheck = null), i.ADD_TAGS && (typeof i.ADD_TAGS == "function" ? ke.tagCheck = i.ADD_TAGS : (x === I && (x = le(x)), T(x, i.ADD_TAGS, U))), i.ADD_ATTR && (typeof i.ADD_ATTR == "function" ? ke.attributeCheck = i.ADD_ATTR : (C === he && (C = le(C)), T(C, i.ADD_ATTR, U))), i.ADD_URI_SAFE_ATTR && T(Dt, i.ADD_URI_SAFE_ATTR, U), i.FORBID_CONTENTS && (ie === Rt && (ie = le(ie)), T(ie, i.FORBID_CONTENTS, U)), i.ADD_FORBID_CONTENTS && (ie === Rt && (ie = le(ie)), T(ie, i.ADD_FORBID_CONTENTS, U)), _t && (x["#text"] = !0), ye && T(x, ["html", "head", "body"]), x.table && (T(x, ["tbody"]), delete pe.tbody), i.TRUSTED_TYPES_POLICY) {
560
+ if (typeof i.TRUSTED_TYPES_POLICY.createHTML != "function")
561
+ throw je('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
562
+ if (typeof i.TRUSTED_TYPES_POLICY.createScriptURL != "function")
563
+ throw je('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
564
+ $ = i.TRUSTED_TYPES_POLICY, W = $.createHTML("");
565
+ } else
566
+ $ === void 0 && ($ = tr(b, s)), $ !== null && typeof W == "string" && (W = $.createHTML(""));
567
+ Z && Z(i), Ie = i;
568
+ }
569
+ }, "_parseConfig"), gn = T({}, [...Bt, ...Ft, ...Ws]), mn = T({}, [...Ht, ...js]), gs = /* @__PURE__ */ h(function(i) {
570
+ let u = ee(i);
571
+ (!u || !u.tagName) && (u = {
572
+ namespaceURI: Me,
573
+ tagName: "template"
574
+ });
575
+ const g = ft(i.tagName), z = ft(u.tagName);
576
+ return Mt[i.namespaceURI] ? i.namespaceURI === at ? u.namespaceURI === fe ? g === "svg" : u.namespaceURI === it ? g === "svg" && (z === "annotation-xml" || lt[z]) : !!gn[g] : i.namespaceURI === it ? u.namespaceURI === fe ? g === "math" : u.namespaceURI === at ? g === "math" && ot[z] : !!mn[g] : i.namespaceURI === fe ? u.namespaceURI === at && !ot[z] || u.namespaceURI === it && !lt[z] ? !1 : !mn[g] && (hs[g] || !gn[g]) : !!(He === "application/xhtml+xml" && Mt[i.namespaceURI]) : !1;
577
+ }, "_checkValidNamespace"), ae = /* @__PURE__ */ h(function(i) {
578
+ Ge(t.removed, {
579
+ element: i
580
+ });
581
+ try {
582
+ ee(i).removeChild(i);
583
+ } catch {
584
+ H(i);
585
+ }
586
+ }, "_forceRemove"), Te = /* @__PURE__ */ h(function(i, u) {
587
+ try {
588
+ Ge(t.removed, {
589
+ attribute: u.getAttributeNode(i),
590
+ from: u
591
+ });
592
+ } catch {
593
+ Ge(t.removed, {
594
+ attribute: null,
595
+ from: u
596
+ });
597
+ }
598
+ if (u.removeAttribute(i), i === "is")
599
+ if (De || st)
600
+ try {
601
+ ae(u);
602
+ } catch {
603
+ }
604
+ else
605
+ try {
606
+ u.setAttribute(i, "");
607
+ } catch {
608
+ }
609
+ }, "_removeAttribute"), kn = /* @__PURE__ */ h(function(i) {
610
+ let u = null, g = null;
611
+ if (Et)
612
+ i = "<remove></remove>" + i;
613
+ else {
614
+ const P = Ut(i, /^[\r\n\t ]+/);
615
+ g = P && P[0];
616
+ }
617
+ He === "application/xhtml+xml" && Me === fe && (i = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + i + "</body></html>");
618
+ const z = $ ? $.createHTML(i) : i;
619
+ if (Me === fe)
620
+ try {
621
+ u = new m().parseFromString(z, He);
622
+ } catch {
623
+ }
624
+ if (!u || !u.documentElement) {
625
+ u = te.createDocument(Me, "template", null);
626
+ try {
627
+ u.documentElement.innerHTML = Ct ? W : z;
628
+ } catch {
629
+ }
630
+ }
631
+ const G = u.body || u.documentElement;
632
+ return i && g && G.insertBefore(e.createTextNode(g), G.childNodes[0] || null), Me === fe ? Je.call(u, ye ? "html" : "body")[0] : ye ? u.documentElement : G;
633
+ }, "_initDocument"), xn = /* @__PURE__ */ h(function(i) {
634
+ return ue.call(
635
+ i.ownerDocument || i,
636
+ i,
637
+ // eslint-disable-next-line no-bitwise
638
+ p.SHOW_ELEMENT | p.SHOW_COMMENT | p.SHOW_TEXT | p.SHOW_PROCESSING_INSTRUCTION | p.SHOW_CDATA_SECTION,
639
+ null
640
+ );
641
+ }, "_createNodeIterator"), Lt = /* @__PURE__ */ h(function(i) {
642
+ return i instanceof d && (typeof i.nodeName != "string" || typeof i.textContent != "string" || typeof i.removeChild != "function" || !(i.attributes instanceof f) || typeof i.removeAttribute != "function" || typeof i.setAttribute != "function" || typeof i.namespaceURI != "string" || typeof i.insertBefore != "function" || typeof i.hasChildNodes != "function");
643
+ }, "_isClobbered"), bn = /* @__PURE__ */ h(function(i) {
644
+ return typeof o == "function" && i instanceof o;
645
+ }, "_isNode");
646
+ function de(k, i, u) {
647
+ ct(k, (g) => {
648
+ g.call(t, i, u, Ie);
649
+ });
650
+ }
651
+ h(de, "_executeHooks");
652
+ const wn = /* @__PURE__ */ h(function(i) {
653
+ let u = null;
654
+ if (de(B.beforeSanitizeElements, i, null), Lt(i))
655
+ return ae(i), !0;
656
+ const g = U(i.nodeName);
657
+ if (de(B.uponSanitizeElement, i, {
658
+ tagName: g,
659
+ allowedTags: x
660
+ }), nt && i.hasChildNodes() && !bn(i.firstElementChild) && j(/<[/\w!]/g, i.innerHTML) && j(/<[/\w!]/g, i.textContent) || i.nodeType === Ye.progressingInstruction || nt && i.nodeType === Ye.comment && j(/<[/\w]/g, i.data))
661
+ return ae(i), !0;
662
+ if (!(ke.tagCheck instanceof Function && ke.tagCheck(g)) && (!x[g] || pe[g])) {
663
+ if (!pe[g] && Tn(g) && (N.tagNameCheck instanceof RegExp && j(N.tagNameCheck, g) || N.tagNameCheck instanceof Function && N.tagNameCheck(g)))
664
+ return !1;
665
+ if (_t && !ie[g]) {
666
+ const z = ee(i) || i.parentNode, G = me(i) || i.childNodes;
667
+ if (G && z) {
668
+ const P = G.length;
669
+ for (let V = P - 1; V >= 0; --V) {
670
+ const ge = D(G[V], !0);
671
+ ge.__removalCount = (i.__removalCount || 0) + 1, z.insertBefore(ge, _e(i));
672
+ }
673
+ }
674
+ }
675
+ return ae(i), !0;
676
+ }
677
+ return i instanceof c && !gs(i) || (g === "noscript" || g === "noembed" || g === "noframes") && j(/<\/no(script|embed|frames)/i, i.innerHTML) ? (ae(i), !0) : (Re && i.nodeType === Ye.text && (u = i.textContent, ct([$e, O, Ue], (z) => {
678
+ u = We(u, z, " ");
679
+ }), i.textContent !== u && (Ge(t.removed, {
680
+ element: i.cloneNode()
681
+ }), i.textContent = u)), de(B.afterSanitizeElements, i, null), !1);
682
+ }, "_sanitizeElements"), yn = /* @__PURE__ */ h(function(i, u, g) {
683
+ if (tt[u] || cn && (u === "id" || u === "name") && (g in e || g in ds))
684
+ return !1;
685
+ if (!(St && !tt[u] && j(Tt, u))) {
686
+ if (!(an && j(vt, u))) {
687
+ if (!(ke.attributeCheck instanceof Function && ke.attributeCheck(u, i))) {
688
+ if (!C[u] || tt[u]) {
689
+ if (
690
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
691
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
692
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
693
+ !(Tn(i) && (N.tagNameCheck instanceof RegExp && j(N.tagNameCheck, i) || N.tagNameCheck instanceof Function && N.tagNameCheck(i)) && (N.attributeNameCheck instanceof RegExp && j(N.attributeNameCheck, u) || N.attributeNameCheck instanceof Function && N.attributeNameCheck(u, i)) || // Alternative, second condition checks if it's an `is`-attribute, AND
694
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
695
+ u === "is" && N.allowCustomizedBuiltInElements && (N.tagNameCheck instanceof RegExp && j(N.tagNameCheck, g) || N.tagNameCheck instanceof Function && N.tagNameCheck(g)))
696
+ ) return !1;
697
+ } else if (!Dt[u]) {
698
+ if (!j(w, We(g, Be, ""))) {
699
+ if (!((u === "src" || u === "xlink:href" || u === "href") && i !== "script" && Bs(g, "data:") === 0 && hn[i])) {
700
+ if (!(ln && !j(et, We(g, Be, "")))) {
701
+ if (g)
702
+ return !1;
703
+ }
704
+ }
705
+ }
706
+ }
707
+ }
708
+ }
709
+ }
710
+ return !0;
711
+ }, "_isValidAttribute"), Tn = /* @__PURE__ */ h(function(i) {
712
+ return i !== "annotation-xml" && Ut(i, A);
713
+ }, "_isBasicCustomElement"), vn = /* @__PURE__ */ h(function(i) {
714
+ de(B.beforeSanitizeAttributes, i, null);
715
+ const {
716
+ attributes: u
717
+ } = i;
718
+ if (!u || Lt(i))
719
+ return;
720
+ const g = {
721
+ attrName: "",
722
+ attrValue: "",
723
+ keepAttr: !0,
724
+ allowedAttributes: C,
725
+ forceKeepAttr: void 0
726
+ };
727
+ let z = u.length;
728
+ for (; z--; ) {
729
+ const G = u[z], {
730
+ name: P,
731
+ namespaceURI: V,
732
+ value: ge
733
+ } = G, Le = U(P), Ot = ge;
734
+ let F = P === "value" ? Ot : Fs(Ot);
735
+ if (g.attrName = Le, g.attrValue = F, g.keepAttr = !0, g.forceKeepAttr = void 0, de(B.uponSanitizeAttribute, i, g), F = g.attrValue, un && (Le === "id" || Le === "name") && (Te(P, i), F = cs + F), nt && j(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, F)) {
736
+ Te(P, i);
737
+ continue;
738
+ }
739
+ if (Le === "attributename" && Ut(F, "href")) {
740
+ Te(P, i);
741
+ continue;
742
+ }
743
+ if (g.forceKeepAttr)
744
+ continue;
745
+ if (!g.keepAttr) {
746
+ Te(P, i);
747
+ continue;
748
+ }
749
+ if (!on && j(/\/>/i, F)) {
750
+ Te(P, i);
751
+ continue;
752
+ }
753
+ Re && ct([$e, O, Ue], (An) => {
754
+ F = We(F, An, " ");
755
+ });
756
+ const Sn = U(i.nodeName);
757
+ if (!yn(Sn, Le, F)) {
758
+ Te(P, i);
759
+ continue;
760
+ }
761
+ if ($ && typeof b == "object" && typeof b.getAttributeType == "function" && !V)
762
+ switch (b.getAttributeType(Sn, Le)) {
763
+ case "TrustedHTML": {
764
+ F = $.createHTML(F);
765
+ break;
766
+ }
767
+ case "TrustedScriptURL": {
768
+ F = $.createScriptURL(F);
769
+ break;
770
+ }
771
+ }
772
+ if (F !== Ot)
773
+ try {
774
+ V ? i.setAttributeNS(V, P, F) : i.setAttribute(P, F), Lt(i) ? ae(i) : In(t.removed);
775
+ } catch {
776
+ Te(P, i);
777
+ }
778
+ }
779
+ de(B.afterSanitizeAttributes, i, null);
780
+ }, "_sanitizeAttributes"), ms = /* @__PURE__ */ h(function k(i) {
781
+ let u = null;
782
+ const g = xn(i);
783
+ for (de(B.beforeSanitizeShadowDOM, i, null); u = g.nextNode(); )
784
+ de(B.uponSanitizeShadowNode, u, null), wn(u), vn(u), u.content instanceof r && k(u.content);
785
+ de(B.afterSanitizeShadowDOM, i, null);
786
+ }, "_sanitizeShadowDOM");
787
+ return t.sanitize = function(k) {
788
+ let i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, u = null, g = null, z = null, G = null;
789
+ if (Ct = !k, Ct && (k = "<!-->"), typeof k != "string" && !bn(k))
790
+ if (typeof k.toString == "function") {
791
+ if (k = k.toString(), typeof k != "string")
792
+ throw je("dirty is not a string, aborting");
793
+ } else
794
+ throw je("toString is not a function");
795
+ if (!t.isSupported)
796
+ return k;
797
+ if (At || It(i), t.removed = [], typeof k == "string" && (Fe = !1), Fe) {
798
+ if (k.nodeName) {
799
+ const ge = U(k.nodeName);
800
+ if (!x[ge] || pe[ge])
801
+ throw je("root node is forbidden and cannot be sanitized in-place");
802
+ }
803
+ } else if (k instanceof o)
804
+ u = kn("<!---->"), g = u.ownerDocument.importNode(k, !0), g.nodeType === Ye.element && g.nodeName === "BODY" || g.nodeName === "HTML" ? u = g : u.appendChild(g);
805
+ else {
806
+ if (!De && !Re && !ye && // eslint-disable-next-line unicorn/prefer-includes
807
+ k.indexOf("<") === -1)
808
+ return $ && rt ? $.createHTML(k) : k;
809
+ if (u = kn(k), !u)
810
+ return De ? null : rt ? W : "";
811
+ }
812
+ u && Et && ae(u.firstChild);
813
+ const P = xn(Fe ? k : u);
814
+ for (; z = P.nextNode(); )
815
+ wn(z), vn(z), z.content instanceof r && ms(z.content);
816
+ if (Fe)
817
+ return k;
818
+ if (De) {
819
+ if (st)
820
+ for (G = Ke.call(u.ownerDocument); u.firstChild; )
821
+ G.appendChild(u.firstChild);
822
+ else
823
+ G = u;
824
+ return (C.shadowroot || C.shadowrootmode) && (G = yt.call(n, G, !0)), G;
825
+ }
826
+ let V = ye ? u.outerHTML : u.innerHTML;
827
+ return ye && x["!doctype"] && u.ownerDocument && u.ownerDocument.doctype && u.ownerDocument.doctype.name && j(Xn, u.ownerDocument.doctype.name) && (V = "<!DOCTYPE " + u.ownerDocument.doctype.name + `>
828
+ ` + V), Re && ct([$e, O, Ue], (ge) => {
829
+ V = We(V, ge, " ");
830
+ }), $ && rt ? $.createHTML(V) : V;
831
+ }, t.setConfig = function() {
832
+ let k = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
833
+ It(k), At = !0;
834
+ }, t.clearConfig = function() {
835
+ Ie = null, At = !1;
836
+ }, t.isValidAttribute = function(k, i, u) {
837
+ Ie || It({});
838
+ const g = U(k), z = U(i);
839
+ return yn(g, z, u);
840
+ }, t.addHook = function(k, i) {
841
+ typeof i == "function" && Ge(B[k], i);
842
+ }, t.removeHook = function(k, i) {
843
+ if (i !== void 0) {
844
+ const u = $s(B[k], i);
845
+ return u === -1 ? void 0 : Us(B[k], u, 1)[0];
846
+ }
847
+ return In(B[k]);
848
+ }, t.removeHooks = function(k) {
849
+ B[k] = [];
850
+ }, t.removeAllHooks = function() {
851
+ B = $n();
852
+ }, t;
853
+ }
854
+ h(Vn, "createDOMPurify");
855
+ var nr = Vn();
856
+ function Xt() {
857
+ return { async: !1, breaks: !1, extensions: null, gfm: !0, hooks: null, pedantic: !1, renderer: null, silent: !1, tokenizer: null, walkTokens: null };
858
+ }
859
+ h(Xt, "M");
860
+ var Ee = Xt();
861
+ function Qn(l) {
862
+ Ee = l;
863
+ }
864
+ h(Qn, "G");
865
+ var Se = { exec: /* @__PURE__ */ h(() => null, "exec") };
866
+ function R(l, t = "") {
867
+ let e = typeof l == "string" ? l : l.source, n = { replace: /* @__PURE__ */ h((s, r) => {
868
+ let a = typeof r == "string" ? r : r.source;
869
+ return a = a.replace(Y.caret, "$1"), e = e.replace(s, a), n;
870
+ }, "replace"), getRegex: /* @__PURE__ */ h(() => new RegExp(e, t), "getRegex") };
871
+ return n;
872
+ }
873
+ h(R, "k");
874
+ var sr = (() => {
875
+ try {
876
+ return !!new RegExp("(?<=1)(?<!1)");
877
+ } catch {
878
+ return !1;
879
+ }
880
+ })(), Y = { 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, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ 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, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: /* @__PURE__ */ h((l) => new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`), "listItemRegex"), nextBulletRegex: /* @__PURE__ */ h((l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), "nextBulletRegex"), hrRegex: /* @__PURE__ */ h((l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), "hrRegex"), fencesBeginRegex: /* @__PURE__ */ h((l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}(?:\`\`\`|~~~)`), "fencesBeginRegex"), headingBeginRegex: /* @__PURE__ */ h((l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}#`), "headingBeginRegex"), htmlBeginRegex: /* @__PURE__ */ h((l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}<(?:[a-z].*>|!--)`, "i"), "htmlBeginRegex"), blockquoteBeginRegex: /* @__PURE__ */ h((l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}>`), "blockquoteBeginRegex") }, rr = /^(?:[ \t]*(?:\n|$))+/, ir = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, ar = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, Qe = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, lr = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, Vt = / {0,3}(?:[*+-]|\d{1,9}[.)])/, Kn = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, Jn = R(Kn).replace(/bull/g, Vt).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(), or = R(Kn).replace(/bull/g, Vt).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(), Qt = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, cr = /^[^\n]+/, Kt = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, ur = R(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Kt).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), hr = R(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, Vt).getRegex(), bt = "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", Jt = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, pr = R("^ {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", Jt).replace("tag", bt).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), es = R(Qt).replace("hr", Qe).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[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", bt).getRegex(), fr = R(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", es).getRegex(), en = { blockquote: fr, code: ir, def: ur, fences: ar, heading: lr, hr: Qe, html: pr, lheading: Jn, list: hr, newline: rr, paragraph: es, table: Se, text: cr }, Un = R("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", Qe).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[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", bt).getRegex(), dr = { ...en, lheading: or, table: Un, paragraph: R(Qt).replace("hr", Qe).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", Un).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", bt).getRegex() }, gr = { ...en, html: R(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", Jt).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: Se, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: R(Qt).replace("hr", Qe).replace("heading", ` *#{1,6} *[^
881
+ ]`).replace("lheading", Jn).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() }, mr = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, kr = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, ts = /^( {2,}|\\)\n(?!\s*$)/, xr = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, wt = /[\p{P}\p{S}]/u, tn = /[\s\p{P}\p{S}]/u, ns = /[^\s\p{P}\p{S}]/u, br = R(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, tn).getRegex(), ss = /(?!~)[\p{P}\p{S}]/u, wr = /(?!~)[\s\p{P}\p{S}]/u, yr = /(?:[^\s\p{P}\p{S}]|~)/u, rs = /(?![*_])[\p{P}\p{S}]/u, Tr = /(?![*_])[\s\p{P}\p{S}]/u, vr = /(?:[^\s\p{P}\p{S}]|[*_])/u, Sr = R(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", sr ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), is = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, Ar = R(is, "u").replace(/punct/g, wt).getRegex(), Er = R(is, "u").replace(/punct/g, ss).getRegex(), as = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", _r = R(as, "gu").replace(/notPunctSpace/g, ns).replace(/punctSpace/g, tn).replace(/punct/g, wt).getRegex(), Rr = R(as, "gu").replace(/notPunctSpace/g, yr).replace(/punctSpace/g, wr).replace(/punct/g, ss).getRegex(), Dr = R("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, ns).replace(/punctSpace/g, tn).replace(/punct/g, wt).getRegex(), Cr = R(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, rs).getRegex(), Mr = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)", Ir = R(Mr, "gu").replace(/notPunctSpace/g, vr).replace(/punctSpace/g, Tr).replace(/punct/g, rs).getRegex(), Lr = R(/\\(punct)/, "gu").replace(/punct/g, wt).getRegex(), Or = R(/^<(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(), Nr = R(Jt).replace("(?:-->|$)", "-->").getRegex(), zr = R("^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", Nr).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), gt = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/, Pr = R(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", gt).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), ls = R(/^!?\[(label)\]\[(ref)\]/).replace("label", gt).replace("ref", Kt).getRegex(), os = R(/^!?\[(ref)\](?:\[\])?/).replace("ref", Kt).getRegex(), $r = R("reflink|nolink(?!\\()", "g").replace("reflink", ls).replace("nolink", os).getRegex(), Bn = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, nn = { _backpedal: Se, anyPunctuation: Lr, autolink: Or, blockSkip: Sr, br: ts, code: kr, del: Se, delLDelim: Se, delRDelim: Se, emStrongLDelim: Ar, emStrongRDelimAst: _r, emStrongRDelimUnd: Dr, escape: mr, link: Pr, nolink: os, punctuation: br, reflink: ls, reflinkSearch: $r, tag: zr, text: xr, url: Se }, Ur = { ...nn, link: R(/^!?\[(label)\]\((.*?)\)/).replace("label", gt).getRegex(), reflink: R(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", gt).getRegex() }, Zt = { ...nn, emStrongRDelimAst: Rr, emStrongLDelim: Er, delLDelim: Cr, delRDelim: Ir, url: R(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", Bn).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\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: R(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", Bn).getRegex() }, Br = { ...Zt, br: R(ts).replace("{2,}", "*").getRegex(), text: R(Zt.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() }, ht = { normal: en, gfm: dr, pedantic: gr }, Ze = { normal: nn, gfm: Zt, breaks: Br, pedantic: Ur }, Fr = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, Fn = /* @__PURE__ */ h((l) => Fr[l], "de");
882
+ function oe(l, t) {
883
+ if (t) {
884
+ if (Y.escapeTest.test(l)) return l.replace(Y.escapeReplace, Fn);
885
+ } else if (Y.escapeTestNoEncode.test(l)) return l.replace(Y.escapeReplaceNoEncode, Fn);
886
+ return l;
887
+ }
888
+ h(oe, "O");
889
+ function Hn(l) {
890
+ try {
891
+ l = encodeURI(l).replace(Y.percentDecode, "%");
892
+ } catch {
893
+ return null;
894
+ }
895
+ return l;
896
+ }
897
+ h(Hn, "X");
898
+ function Gn(l, t) {
899
+ let e = l.replace(Y.findPipe, (r, a, o) => {
900
+ let c = !1, p = a;
901
+ for (; --p >= 0 && o[p] === "\\"; ) c = !c;
902
+ return c ? "|" : " |";
903
+ }), n = e.split(Y.splitPipe), s = 0;
904
+ if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), t) if (n.length > t) n.splice(t);
905
+ else for (; n.length < t; ) n.push("");
906
+ for (; s < n.length; s++) n[s] = n[s].trim().replace(Y.slashPipe, "|");
907
+ return n;
908
+ }
909
+ h(Gn, "J");
910
+ function Xe(l, t, e) {
911
+ let n = l.length;
912
+ if (n === 0) return "";
913
+ let s = 0;
914
+ for (; s < n && l.charAt(n - s - 1) === t; )
915
+ s++;
916
+ return l.slice(0, n - s);
917
+ }
918
+ h(Xe, "E");
919
+ function Hr(l, t) {
920
+ if (l.indexOf(t[1]) === -1) return -1;
921
+ let e = 0;
922
+ for (let n = 0; n < l.length; n++) if (l[n] === "\\") n++;
923
+ else if (l[n] === t[0]) e++;
924
+ else if (l[n] === t[1] && (e--, e < 0)) return n;
925
+ return e > 0 ? -2 : -1;
926
+ }
927
+ h(Hr, "ge");
928
+ function Gr(l, t = 0) {
929
+ let e = t, n = "";
930
+ for (let s of l) if (s === " ") {
931
+ let r = 4 - e % 4;
932
+ n += " ".repeat(r), e += r;
933
+ } else n += s, e++;
934
+ return n;
935
+ }
936
+ h(Gr, "fe");
937
+ function Wn(l, t, e, n, s) {
938
+ let r = t.href, a = t.title || null, o = l[1].replace(s.other.outputLinkReplace, "$1");
939
+ n.state.inLink = !0;
940
+ let c = { type: l[0].charAt(0) === "!" ? "image" : "link", raw: e, href: r, title: a, text: o, tokens: n.inlineTokens(o) };
941
+ return n.state.inLink = !1, c;
942
+ }
943
+ h(Wn, "me");
944
+ function Wr(l, t, e) {
945
+ let n = l.match(e.other.indentCodeCompensation);
946
+ if (n === null) return t;
947
+ let s = n[1];
948
+ return t.split(`
949
+ `).map((r) => {
950
+ let a = r.match(e.other.beginningSpace);
951
+ if (a === null) return r;
952
+ let [o] = a;
953
+ return o.length >= s.length ? r.slice(s.length) : r;
954
+ }).join(`
955
+ `);
956
+ }
957
+ h(Wr, "it");
958
+ var Oe, mt = (Oe = class {
959
+ constructor(t) {
960
+ E(this, "options");
961
+ E(this, "rules");
962
+ E(this, "lexer");
963
+ this.options = t || Ee;
964
+ }
965
+ space(t) {
966
+ let e = this.rules.block.newline.exec(t);
967
+ if (e && e[0].length > 0) return { type: "space", raw: e[0] };
968
+ }
969
+ code(t) {
970
+ let e = this.rules.block.code.exec(t);
971
+ if (e) {
972
+ let n = e[0].replace(this.rules.other.codeRemoveIndent, "");
973
+ return { type: "code", raw: e[0], codeBlockStyle: "indented", text: this.options.pedantic ? n : Xe(n, `
974
+ `) };
975
+ }
976
+ }
977
+ fences(t) {
978
+ let e = this.rules.block.fences.exec(t);
979
+ if (e) {
980
+ let n = e[0], s = Wr(n, e[3] || "", this.rules);
981
+ return { type: "code", raw: n, lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2], text: s };
982
+ }
983
+ }
984
+ heading(t) {
985
+ let e = this.rules.block.heading.exec(t);
986
+ if (e) {
987
+ let n = e[2].trim();
988
+ if (this.rules.other.endingHash.test(n)) {
989
+ let s = Xe(n, "#");
990
+ (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
991
+ }
992
+ return { type: "heading", raw: e[0], depth: e[1].length, text: n, tokens: this.lexer.inline(n) };
993
+ }
994
+ }
995
+ hr(t) {
996
+ let e = this.rules.block.hr.exec(t);
997
+ if (e) return { type: "hr", raw: Xe(e[0], `
998
+ `) };
999
+ }
1000
+ blockquote(t) {
1001
+ let e = this.rules.block.blockquote.exec(t);
1002
+ if (e) {
1003
+ let n = Xe(e[0], `
1004
+ `).split(`
1005
+ `), s = "", r = "", a = [];
1006
+ for (; n.length > 0; ) {
1007
+ let o = !1, c = [], p;
1008
+ for (p = 0; p < n.length; p++) if (this.rules.other.blockquoteStart.test(n[p])) c.push(n[p]), o = !0;
1009
+ else if (!o) c.push(n[p]);
1010
+ else break;
1011
+ n = n.slice(p);
1012
+ let f = c.join(`
1013
+ `), d = f.replace(this.rules.other.blockquoteSetextReplace, `
1014
+ $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
1015
+ s = s ? `${s}
1016
+ ${f}` : f, r = r ? `${r}
1017
+ ${d}` : d;
1018
+ let m = this.lexer.state.top;
1019
+ if (this.lexer.state.top = !0, this.lexer.blockTokens(d, a, !0), this.lexer.state.top = m, n.length === 0) break;
1020
+ let b = a.at(-1);
1021
+ if (b?.type === "code") break;
1022
+ if (b?.type === "blockquote") {
1023
+ let L = b, D = L.raw + `
1024
+ ` + n.join(`
1025
+ `), H = this.blockquote(D);
1026
+ a[a.length - 1] = H, s = s.substring(0, s.length - L.raw.length) + H.raw, r = r.substring(0, r.length - L.text.length) + H.text;
1027
+ break;
1028
+ } else if (b?.type === "list") {
1029
+ let L = b, D = L.raw + `
1030
+ ` + n.join(`
1031
+ `), H = this.list(D);
1032
+ a[a.length - 1] = H, s = s.substring(0, s.length - b.raw.length) + H.raw, r = r.substring(0, r.length - L.raw.length) + H.raw, n = D.substring(a.at(-1).raw.length).split(`
1033
+ `);
1034
+ continue;
1035
+ }
1036
+ }
1037
+ return { type: "blockquote", raw: s, tokens: a, text: r };
1038
+ }
1039
+ }
1040
+ list(t) {
1041
+ let e = this.rules.block.list.exec(t);
1042
+ if (e) {
1043
+ let n = e[1].trim(), s = n.length > 1, r = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: !1, items: [] };
1044
+ n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
1045
+ let a = this.rules.other.listItemRegex(n), o = !1;
1046
+ for (; t; ) {
1047
+ let p = !1, f = "", d = "";
1048
+ if (!(e = a.exec(t)) || this.rules.block.hr.test(t)) break;
1049
+ f = e[0], t = t.substring(f.length);
1050
+ let m = Gr(e[2].split(`
1051
+ `, 1)[0], e[1].length), b = t.split(`
1052
+ `, 1)[0], L = !m.trim(), D = 0;
1053
+ if (this.options.pedantic ? (D = 2, d = m.trimStart()) : L ? D = e[1].length + 1 : (D = m.search(this.rules.other.nonSpaceChar), D = D > 4 ? 1 : D, d = m.slice(D), D += e[1].length), L && this.rules.other.blankLine.test(b) && (f += b + `
1054
+ `, t = t.substring(b.length + 1), p = !0), !p) {
1055
+ let H = this.rules.other.nextBulletRegex(D), _e = this.rules.other.hrRegex(D), me = this.rules.other.fencesBeginRegex(D), ee = this.rules.other.headingBeginRegex(D), $ = this.rules.other.htmlBeginRegex(D), W = this.rules.other.blockquoteBeginRegex(D);
1056
+ for (; t; ) {
1057
+ let te = t.split(`
1058
+ `, 1)[0], ue;
1059
+ if (b = te, this.options.pedantic ? (b = b.replace(this.rules.other.listReplaceNesting, " "), ue = b) : ue = b.replace(this.rules.other.tabCharGlobal, " "), me.test(b) || ee.test(b) || $.test(b) || W.test(b) || H.test(b) || _e.test(b)) break;
1060
+ if (ue.search(this.rules.other.nonSpaceChar) >= D || !b.trim()) d += `
1061
+ ` + ue.slice(D);
1062
+ else {
1063
+ if (L || m.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || me.test(m) || ee.test(m) || _e.test(m)) break;
1064
+ d += `
1065
+ ` + b;
1066
+ }
1067
+ L = !b.trim(), f += te + `
1068
+ `, t = t.substring(te.length + 1), m = ue.slice(D);
1069
+ }
1070
+ }
1071
+ r.loose || (o ? r.loose = !0 : this.rules.other.doubleBlankLine.test(f) && (o = !0)), r.items.push({ type: "list_item", raw: f, task: !!this.options.gfm && this.rules.other.listIsTask.test(d), loose: !1, text: d, tokens: [] }), r.raw += f;
1072
+ }
1073
+ let c = r.items.at(-1);
1074
+ if (c) c.raw = c.raw.trimEnd(), c.text = c.text.trimEnd();
1075
+ else return;
1076
+ r.raw = r.raw.trimEnd();
1077
+ for (let p of r.items) {
1078
+ if (this.lexer.state.top = !1, p.tokens = this.lexer.blockTokens(p.text, []), p.task) {
1079
+ if (p.text = p.text.replace(this.rules.other.listReplaceTask, ""), p.tokens[0]?.type === "text" || p.tokens[0]?.type === "paragraph") {
1080
+ p.tokens[0].raw = p.tokens[0].raw.replace(this.rules.other.listReplaceTask, ""), p.tokens[0].text = p.tokens[0].text.replace(this.rules.other.listReplaceTask, "");
1081
+ for (let d = this.lexer.inlineQueue.length - 1; d >= 0; d--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)) {
1082
+ this.lexer.inlineQueue[d].src = this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask, "");
1083
+ break;
1084
+ }
1085
+ }
1086
+ let f = this.rules.other.listTaskCheckbox.exec(p.raw);
1087
+ if (f) {
1088
+ let d = { type: "checkbox", raw: f[0] + " ", checked: f[0] !== "[ ]" };
1089
+ p.checked = d.checked, r.loose ? p.tokens[0] && ["paragraph", "text"].includes(p.tokens[0].type) && "tokens" in p.tokens[0] && p.tokens[0].tokens ? (p.tokens[0].raw = d.raw + p.tokens[0].raw, p.tokens[0].text = d.raw + p.tokens[0].text, p.tokens[0].tokens.unshift(d)) : p.tokens.unshift({ type: "paragraph", raw: d.raw, text: d.raw, tokens: [d] }) : p.tokens.unshift(d);
1090
+ }
1091
+ }
1092
+ if (!r.loose) {
1093
+ let f = p.tokens.filter((m) => m.type === "space"), d = f.length > 0 && f.some((m) => this.rules.other.anyLine.test(m.raw));
1094
+ r.loose = d;
1095
+ }
1096
+ }
1097
+ if (r.loose) for (let p of r.items) {
1098
+ p.loose = !0;
1099
+ for (let f of p.tokens) f.type === "text" && (f.type = "paragraph");
1100
+ }
1101
+ return r;
1102
+ }
1103
+ }
1104
+ html(t) {
1105
+ let e = this.rules.block.html.exec(t);
1106
+ if (e) return { type: "html", block: !0, raw: e[0], pre: e[1] === "pre" || e[1] === "script" || e[1] === "style", text: e[0] };
1107
+ }
1108
+ def(t) {
1109
+ let e = this.rules.block.def.exec(t);
1110
+ if (e) {
1111
+ let n = e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = e[2] ? e[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
1112
+ return { type: "def", tag: n, raw: e[0], href: s, title: r };
1113
+ }
1114
+ }
1115
+ table(t) {
1116
+ let e = this.rules.block.table.exec(t);
1117
+ if (!e || !this.rules.other.tableDelimiter.test(e[2])) return;
1118
+ let n = Gn(e[1]), s = e[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = e[3]?.trim() ? e[3].replace(this.rules.other.tableRowBlankLine, "").split(`
1119
+ `) : [], a = { type: "table", raw: e[0], header: [], align: [], rows: [] };
1120
+ if (n.length === s.length) {
1121
+ for (let o of s) this.rules.other.tableAlignRight.test(o) ? a.align.push("right") : this.rules.other.tableAlignCenter.test(o) ? a.align.push("center") : this.rules.other.tableAlignLeft.test(o) ? a.align.push("left") : a.align.push(null);
1122
+ for (let o = 0; o < n.length; o++) a.header.push({ text: n[o], tokens: this.lexer.inline(n[o]), header: !0, align: a.align[o] });
1123
+ for (let o of r) a.rows.push(Gn(o, a.header.length).map((c, p) => ({ text: c, tokens: this.lexer.inline(c), header: !1, align: a.align[p] })));
1124
+ return a;
1125
+ }
1126
+ }
1127
+ lheading(t) {
1128
+ let e = this.rules.block.lheading.exec(t);
1129
+ if (e) return { type: "heading", raw: e[0], depth: e[2].charAt(0) === "=" ? 1 : 2, text: e[1], tokens: this.lexer.inline(e[1]) };
1130
+ }
1131
+ paragraph(t) {
1132
+ let e = this.rules.block.paragraph.exec(t);
1133
+ if (e) {
1134
+ let n = e[1].charAt(e[1].length - 1) === `
1135
+ ` ? e[1].slice(0, -1) : e[1];
1136
+ return { type: "paragraph", raw: e[0], text: n, tokens: this.lexer.inline(n) };
1137
+ }
1138
+ }
1139
+ text(t) {
1140
+ let e = this.rules.block.text.exec(t);
1141
+ if (e) return { type: "text", raw: e[0], text: e[0], tokens: this.lexer.inline(e[0]) };
1142
+ }
1143
+ escape(t) {
1144
+ let e = this.rules.inline.escape.exec(t);
1145
+ if (e) return { type: "escape", raw: e[0], text: e[1] };
1146
+ }
1147
+ tag(t) {
1148
+ let e = this.rules.inline.tag.exec(t);
1149
+ if (e) return !this.lexer.state.inLink && this.rules.other.startATag.test(e[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(e[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(e[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(e[0]) && (this.lexer.state.inRawBlock = !1), { type: "html", raw: e[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: !1, text: e[0] };
1150
+ }
1151
+ link(t) {
1152
+ let e = this.rules.inline.link.exec(t);
1153
+ if (e) {
1154
+ let n = e[2].trim();
1155
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
1156
+ if (!this.rules.other.endAngleBracket.test(n)) return;
1157
+ let a = Xe(n.slice(0, -1), "\\");
1158
+ if ((n.length - a.length) % 2 === 0) return;
1159
+ } else {
1160
+ let a = Hr(e[2], "()");
1161
+ if (a === -2) return;
1162
+ if (a > -1) {
1163
+ let o = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + a;
1164
+ e[2] = e[2].substring(0, a), e[0] = e[0].substring(0, o).trim(), e[3] = "";
1165
+ }
1166
+ }
1167
+ let s = e[2], r = "";
1168
+ if (this.options.pedantic) {
1169
+ let a = this.rules.other.pedanticHrefTitle.exec(s);
1170
+ a && (s = a[1], r = a[3]);
1171
+ } else r = e[3] ? e[3].slice(1, -1) : "";
1172
+ 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)), Wn(e, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: r && r.replace(this.rules.inline.anyPunctuation, "$1") }, e[0], this.lexer, this.rules);
1173
+ }
1174
+ }
1175
+ reflink(t, e) {
1176
+ let n;
1177
+ if ((n = this.rules.inline.reflink.exec(t)) || (n = this.rules.inline.nolink.exec(t))) {
1178
+ let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = e[s.toLowerCase()];
1179
+ if (!r) {
1180
+ let a = n[0].charAt(0);
1181
+ return { type: "text", raw: a, text: a };
1182
+ }
1183
+ return Wn(n, r, n[0], this.lexer, this.rules);
1184
+ }
1185
+ }
1186
+ emStrong(t, e, n = "") {
1187
+ let s = this.rules.inline.emStrongLDelim.exec(t);
1188
+ if (!(!s || s[3] && n.match(this.rules.other.unicodeAlphaNumeric)) && (!(s[1] || s[2]) || !n || this.rules.inline.punctuation.exec(n))) {
1189
+ let r = [...s[0]].length - 1, a, o, c = r, p = 0, f = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
1190
+ for (f.lastIndex = 0, e = e.slice(-1 * t.length + r); (s = f.exec(e)) != null; ) {
1191
+ if (a = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !a) continue;
1192
+ if (o = [...a].length, s[3] || s[4]) {
1193
+ c += o;
1194
+ continue;
1195
+ } else if ((s[5] || s[6]) && r % 3 && !((r + o) % 3)) {
1196
+ p += o;
1197
+ continue;
1198
+ }
1199
+ if (c -= o, c > 0) continue;
1200
+ o = Math.min(o, o + c + p);
1201
+ let d = [...s[0]][0].length, m = t.slice(0, r + s.index + d + o);
1202
+ if (Math.min(r, o) % 2) {
1203
+ let L = m.slice(1, -1);
1204
+ return { type: "em", raw: m, text: L, tokens: this.lexer.inlineTokens(L) };
1205
+ }
1206
+ let b = m.slice(2, -2);
1207
+ return { type: "strong", raw: m, text: b, tokens: this.lexer.inlineTokens(b) };
1208
+ }
1209
+ }
1210
+ }
1211
+ codespan(t) {
1212
+ let e = this.rules.inline.code.exec(t);
1213
+ if (e) {
1214
+ let n = e[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(n), r = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
1215
+ return s && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: e[0], text: n };
1216
+ }
1217
+ }
1218
+ br(t) {
1219
+ let e = this.rules.inline.br.exec(t);
1220
+ if (e) return { type: "br", raw: e[0] };
1221
+ }
1222
+ del(t, e, n = "") {
1223
+ let s = this.rules.inline.delLDelim.exec(t);
1224
+ if (s && (!s[1] || !n || this.rules.inline.punctuation.exec(n))) {
1225
+ let r = [...s[0]].length - 1, a, o, c = r, p = this.rules.inline.delRDelim;
1226
+ for (p.lastIndex = 0, e = e.slice(-1 * t.length + r); (s = p.exec(e)) != null; ) {
1227
+ if (a = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !a || (o = [...a].length, o !== r)) continue;
1228
+ if (s[3] || s[4]) {
1229
+ c += o;
1230
+ continue;
1231
+ }
1232
+ if (c -= o, c > 0) continue;
1233
+ o = Math.min(o, o + c);
1234
+ let f = [...s[0]][0].length, d = t.slice(0, r + s.index + f + o), m = d.slice(r, -r);
1235
+ return { type: "del", raw: d, text: m, tokens: this.lexer.inlineTokens(m) };
1236
+ }
1237
+ }
1238
+ }
1239
+ autolink(t) {
1240
+ let e = this.rules.inline.autolink.exec(t);
1241
+ if (e) {
1242
+ let n, s;
1243
+ return e[2] === "@" ? (n = e[1], s = "mailto:" + n) : (n = e[1], s = n), { type: "link", raw: e[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
1244
+ }
1245
+ }
1246
+ url(t) {
1247
+ let e;
1248
+ if (e = this.rules.inline.url.exec(t)) {
1249
+ let n, s;
1250
+ if (e[2] === "@") n = e[0], s = "mailto:" + n;
1251
+ else {
1252
+ let r;
1253
+ do
1254
+ r = e[0], e[0] = this.rules.inline._backpedal.exec(e[0])?.[0] ?? "";
1255
+ while (r !== e[0]);
1256
+ n = e[0], e[1] === "www." ? s = "http://" + e[0] : s = e[0];
1257
+ }
1258
+ return { type: "link", raw: e[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
1259
+ }
1260
+ }
1261
+ inlineText(t) {
1262
+ let e = this.rules.inline.text.exec(t);
1263
+ if (e) {
1264
+ let n = this.lexer.state.inRawBlock;
1265
+ return { type: "text", raw: e[0], text: e[0], escaped: n };
1266
+ }
1267
+ }
1268
+ }, h(Oe, "w"), Oe), be, se = (be = class {
1269
+ constructor(t) {
1270
+ E(this, "tokens");
1271
+ E(this, "options");
1272
+ E(this, "state");
1273
+ E(this, "inlineQueue");
1274
+ E(this, "tokenizer");
1275
+ this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = t || Ee, this.options.tokenizer = this.options.tokenizer || new mt(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: !1, inRawBlock: !1, top: !0 };
1276
+ let e = { other: Y, block: ht.normal, inline: Ze.normal };
1277
+ this.options.pedantic ? (e.block = ht.pedantic, e.inline = Ze.pedantic) : this.options.gfm && (e.block = ht.gfm, this.options.breaks ? e.inline = Ze.breaks : e.inline = Ze.gfm), this.tokenizer.rules = e;
1278
+ }
1279
+ static get rules() {
1280
+ return { block: ht, inline: Ze };
1281
+ }
1282
+ static lex(t, e) {
1283
+ return new be(e).lex(t);
1284
+ }
1285
+ static lexInline(t, e) {
1286
+ return new be(e).inlineTokens(t);
1287
+ }
1288
+ lex(t) {
1289
+ t = t.replace(Y.carriageReturn, `
1290
+ `), this.blockTokens(t, this.tokens);
1291
+ for (let e = 0; e < this.inlineQueue.length; e++) {
1292
+ let n = this.inlineQueue[e];
1293
+ this.inlineTokens(n.src, n.tokens);
1294
+ }
1295
+ return this.inlineQueue = [], this.tokens;
1296
+ }
1297
+ blockTokens(t, e = [], n = !1) {
1298
+ for (this.options.pedantic && (t = t.replace(Y.tabCharGlobal, " ").replace(Y.spaceLine, "")); t; ) {
1299
+ let s;
1300
+ if (this.options.extensions?.block?.some((a) => (s = a.call({ lexer: this }, t, e)) ? (t = t.substring(s.raw.length), e.push(s), !0) : !1)) continue;
1301
+ if (s = this.tokenizer.space(t)) {
1302
+ t = t.substring(s.raw.length);
1303
+ let a = e.at(-1);
1304
+ s.raw.length === 1 && a !== void 0 ? a.raw += `
1305
+ ` : e.push(s);
1306
+ continue;
1307
+ }
1308
+ if (s = this.tokenizer.code(t)) {
1309
+ t = t.substring(s.raw.length);
1310
+ let a = e.at(-1);
1311
+ a?.type === "paragraph" || a?.type === "text" ? (a.raw += (a.raw.endsWith(`
1312
+ `) ? "" : `
1313
+ `) + s.raw, a.text += `
1314
+ ` + s.text, this.inlineQueue.at(-1).src = a.text) : e.push(s);
1315
+ continue;
1316
+ }
1317
+ if (s = this.tokenizer.fences(t)) {
1318
+ t = t.substring(s.raw.length), e.push(s);
1319
+ continue;
1320
+ }
1321
+ if (s = this.tokenizer.heading(t)) {
1322
+ t = t.substring(s.raw.length), e.push(s);
1323
+ continue;
1324
+ }
1325
+ if (s = this.tokenizer.hr(t)) {
1326
+ t = t.substring(s.raw.length), e.push(s);
1327
+ continue;
1328
+ }
1329
+ if (s = this.tokenizer.blockquote(t)) {
1330
+ t = t.substring(s.raw.length), e.push(s);
1331
+ continue;
1332
+ }
1333
+ if (s = this.tokenizer.list(t)) {
1334
+ t = t.substring(s.raw.length), e.push(s);
1335
+ continue;
1336
+ }
1337
+ if (s = this.tokenizer.html(t)) {
1338
+ t = t.substring(s.raw.length), e.push(s);
1339
+ continue;
1340
+ }
1341
+ if (s = this.tokenizer.def(t)) {
1342
+ t = t.substring(s.raw.length);
1343
+ let a = e.at(-1);
1344
+ a?.type === "paragraph" || a?.type === "text" ? (a.raw += (a.raw.endsWith(`
1345
+ `) ? "" : `
1346
+ `) + s.raw, a.text += `
1347
+ ` + s.raw, this.inlineQueue.at(-1).src = a.text) : this.tokens.links[s.tag] || (this.tokens.links[s.tag] = { href: s.href, title: s.title }, e.push(s));
1348
+ continue;
1349
+ }
1350
+ if (s = this.tokenizer.table(t)) {
1351
+ t = t.substring(s.raw.length), e.push(s);
1352
+ continue;
1353
+ }
1354
+ if (s = this.tokenizer.lheading(t)) {
1355
+ t = t.substring(s.raw.length), e.push(s);
1356
+ continue;
1357
+ }
1358
+ let r = t;
1359
+ if (this.options.extensions?.startBlock) {
1360
+ let a = 1 / 0, o = t.slice(1), c;
1361
+ this.options.extensions.startBlock.forEach((p) => {
1362
+ c = p.call({ lexer: this }, o), typeof c == "number" && c >= 0 && (a = Math.min(a, c));
1363
+ }), a < 1 / 0 && a >= 0 && (r = t.substring(0, a + 1));
1364
+ }
1365
+ if (this.state.top && (s = this.tokenizer.paragraph(r))) {
1366
+ let a = e.at(-1);
1367
+ n && a?.type === "paragraph" ? (a.raw += (a.raw.endsWith(`
1368
+ `) ? "" : `
1369
+ `) + s.raw, a.text += `
1370
+ ` + s.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : e.push(s), n = r.length !== t.length, t = t.substring(s.raw.length);
1371
+ continue;
1372
+ }
1373
+ if (s = this.tokenizer.text(t)) {
1374
+ t = t.substring(s.raw.length);
1375
+ let a = e.at(-1);
1376
+ a?.type === "text" ? (a.raw += (a.raw.endsWith(`
1377
+ `) ? "" : `
1378
+ `) + s.raw, a.text += `
1379
+ ` + s.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : e.push(s);
1380
+ continue;
1381
+ }
1382
+ if (t) {
1383
+ let a = "Infinite loop on byte: " + t.charCodeAt(0);
1384
+ if (this.options.silent) {
1385
+ console.error(a);
1386
+ break;
1387
+ } else throw new Error(a);
1388
+ }
1389
+ }
1390
+ return this.state.top = !0, e;
1391
+ }
1392
+ inline(t, e = []) {
1393
+ return this.inlineQueue.push({ src: t, tokens: e }), e;
1394
+ }
1395
+ inlineTokens(t, e = []) {
1396
+ let n = t, s = null;
1397
+ if (this.tokens.links) {
1398
+ let c = Object.keys(this.tokens.links);
1399
+ if (c.length > 0) for (; (s = this.tokenizer.rules.inline.reflinkSearch.exec(n)) != null; ) c.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
1400
+ }
1401
+ for (; (s = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null; ) n = n.slice(0, s.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1402
+ let r;
1403
+ for (; (s = this.tokenizer.rules.inline.blockSkip.exec(n)) != null; ) r = s[2] ? s[2].length : 0, n = n.slice(0, s.index + r) + "[" + "a".repeat(s[0].length - r - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1404
+ n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
1405
+ let a = !1, o = "";
1406
+ for (; t; ) {
1407
+ a || (o = ""), a = !1;
1408
+ let c;
1409
+ if (this.options.extensions?.inline?.some((f) => (c = f.call({ lexer: this }, t, e)) ? (t = t.substring(c.raw.length), e.push(c), !0) : !1)) continue;
1410
+ if (c = this.tokenizer.escape(t)) {
1411
+ t = t.substring(c.raw.length), e.push(c);
1412
+ continue;
1413
+ }
1414
+ if (c = this.tokenizer.tag(t)) {
1415
+ t = t.substring(c.raw.length), e.push(c);
1416
+ continue;
1417
+ }
1418
+ if (c = this.tokenizer.link(t)) {
1419
+ t = t.substring(c.raw.length), e.push(c);
1420
+ continue;
1421
+ }
1422
+ if (c = this.tokenizer.reflink(t, this.tokens.links)) {
1423
+ t = t.substring(c.raw.length);
1424
+ let f = e.at(-1);
1425
+ c.type === "text" && f?.type === "text" ? (f.raw += c.raw, f.text += c.text) : e.push(c);
1426
+ continue;
1427
+ }
1428
+ if (c = this.tokenizer.emStrong(t, n, o)) {
1429
+ t = t.substring(c.raw.length), e.push(c);
1430
+ continue;
1431
+ }
1432
+ if (c = this.tokenizer.codespan(t)) {
1433
+ t = t.substring(c.raw.length), e.push(c);
1434
+ continue;
1435
+ }
1436
+ if (c = this.tokenizer.br(t)) {
1437
+ t = t.substring(c.raw.length), e.push(c);
1438
+ continue;
1439
+ }
1440
+ if (c = this.tokenizer.del(t, n, o)) {
1441
+ t = t.substring(c.raw.length), e.push(c);
1442
+ continue;
1443
+ }
1444
+ if (c = this.tokenizer.autolink(t)) {
1445
+ t = t.substring(c.raw.length), e.push(c);
1446
+ continue;
1447
+ }
1448
+ if (!this.state.inLink && (c = this.tokenizer.url(t))) {
1449
+ t = t.substring(c.raw.length), e.push(c);
1450
+ continue;
1451
+ }
1452
+ let p = t;
1453
+ if (this.options.extensions?.startInline) {
1454
+ let f = 1 / 0, d = t.slice(1), m;
1455
+ this.options.extensions.startInline.forEach((b) => {
1456
+ m = b.call({ lexer: this }, d), typeof m == "number" && m >= 0 && (f = Math.min(f, m));
1457
+ }), f < 1 / 0 && f >= 0 && (p = t.substring(0, f + 1));
1458
+ }
1459
+ if (c = this.tokenizer.inlineText(p)) {
1460
+ t = t.substring(c.raw.length), c.raw.slice(-1) !== "_" && (o = c.raw.slice(-1)), a = !0;
1461
+ let f = e.at(-1);
1462
+ f?.type === "text" ? (f.raw += c.raw, f.text += c.text) : e.push(c);
1463
+ continue;
1464
+ }
1465
+ if (t) {
1466
+ let f = "Infinite loop on byte: " + t.charCodeAt(0);
1467
+ if (this.options.silent) {
1468
+ console.error(f);
1469
+ break;
1470
+ } else throw new Error(f);
1471
+ }
1472
+ }
1473
+ return e;
1474
+ }
1475
+ }, h(be, "u"), be), Ne, kt = (Ne = class {
1476
+ constructor(t) {
1477
+ E(this, "options");
1478
+ E(this, "parser");
1479
+ this.options = t || Ee;
1480
+ }
1481
+ space(t) {
1482
+ return "";
1483
+ }
1484
+ code({ text: t, lang: e, escaped: n }) {
1485
+ let s = (e || "").match(Y.notSpaceStart)?.[0], r = t.replace(Y.endingNewline, "") + `
1486
+ `;
1487
+ return s ? '<pre><code class="language-' + oe(s) + '">' + (n ? r : oe(r, !0)) + `</code></pre>
1488
+ ` : "<pre><code>" + (n ? r : oe(r, !0)) + `</code></pre>
1489
+ `;
1490
+ }
1491
+ blockquote({ tokens: t }) {
1492
+ return `<blockquote>
1493
+ ${this.parser.parse(t)}</blockquote>
1494
+ `;
1495
+ }
1496
+ html({ text: t }) {
1497
+ return t;
1498
+ }
1499
+ def(t) {
1500
+ return "";
1501
+ }
1502
+ heading({ tokens: t, depth: e }) {
1503
+ return `<h${e}>${this.parser.parseInline(t)}</h${e}>
1504
+ `;
1505
+ }
1506
+ hr(t) {
1507
+ return `<hr>
1508
+ `;
1509
+ }
1510
+ list(t) {
1511
+ let e = t.ordered, n = t.start, s = "";
1512
+ for (let o = 0; o < t.items.length; o++) {
1513
+ let c = t.items[o];
1514
+ s += this.listitem(c);
1515
+ }
1516
+ let r = e ? "ol" : "ul", a = e && n !== 1 ? ' start="' + n + '"' : "";
1517
+ return "<" + r + a + `>
1518
+ ` + s + "</" + r + `>
1519
+ `;
1520
+ }
1521
+ listitem(t) {
1522
+ return `<li>${this.parser.parse(t.tokens)}</li>
1523
+ `;
1524
+ }
1525
+ checkbox({ checked: t }) {
1526
+ return "<input " + (t ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
1527
+ }
1528
+ paragraph({ tokens: t }) {
1529
+ return `<p>${this.parser.parseInline(t)}</p>
1530
+ `;
1531
+ }
1532
+ table(t) {
1533
+ let e = "", n = "";
1534
+ for (let r = 0; r < t.header.length; r++) n += this.tablecell(t.header[r]);
1535
+ e += this.tablerow({ text: n });
1536
+ let s = "";
1537
+ for (let r = 0; r < t.rows.length; r++) {
1538
+ let a = t.rows[r];
1539
+ n = "";
1540
+ for (let o = 0; o < a.length; o++) n += this.tablecell(a[o]);
1541
+ s += this.tablerow({ text: n });
1542
+ }
1543
+ return s && (s = `<tbody>${s}</tbody>`), `<table>
1544
+ <thead>
1545
+ ` + e + `</thead>
1546
+ ` + s + `</table>
1547
+ `;
1548
+ }
1549
+ tablerow({ text: t }) {
1550
+ return `<tr>
1551
+ ${t}</tr>
1552
+ `;
1553
+ }
1554
+ tablecell(t) {
1555
+ let e = this.parser.parseInline(t.tokens), n = t.header ? "th" : "td";
1556
+ return (t.align ? `<${n} align="${t.align}">` : `<${n}>`) + e + `</${n}>
1557
+ `;
1558
+ }
1559
+ strong({ tokens: t }) {
1560
+ return `<strong>${this.parser.parseInline(t)}</strong>`;
1561
+ }
1562
+ em({ tokens: t }) {
1563
+ return `<em>${this.parser.parseInline(t)}</em>`;
1564
+ }
1565
+ codespan({ text: t }) {
1566
+ return `<code>${oe(t, !0)}</code>`;
1567
+ }
1568
+ br(t) {
1569
+ return "<br>";
1570
+ }
1571
+ del({ tokens: t }) {
1572
+ return `<del>${this.parser.parseInline(t)}</del>`;
1573
+ }
1574
+ link({ href: t, title: e, tokens: n }) {
1575
+ let s = this.parser.parseInline(n), r = Hn(t);
1576
+ if (r === null) return s;
1577
+ t = r;
1578
+ let a = '<a href="' + t + '"';
1579
+ return e && (a += ' title="' + oe(e) + '"'), a += ">" + s + "</a>", a;
1580
+ }
1581
+ image({ href: t, title: e, text: n, tokens: s }) {
1582
+ s && (n = this.parser.parseInline(s, this.parser.textRenderer));
1583
+ let r = Hn(t);
1584
+ if (r === null) return oe(n);
1585
+ t = r;
1586
+ let a = `<img src="${t}" alt="${oe(n)}"`;
1587
+ return e && (a += ` title="${oe(e)}"`), a += ">", a;
1588
+ }
1589
+ text(t) {
1590
+ return "tokens" in t && t.tokens ? this.parser.parseInline(t.tokens) : "escaped" in t && t.escaped ? t.text : oe(t.text);
1591
+ }
1592
+ }, h(Ne, "y"), Ne), ze, sn = (ze = class {
1593
+ strong({ text: t }) {
1594
+ return t;
1595
+ }
1596
+ em({ text: t }) {
1597
+ return t;
1598
+ }
1599
+ codespan({ text: t }) {
1600
+ return t;
1601
+ }
1602
+ del({ text: t }) {
1603
+ return t;
1604
+ }
1605
+ html({ text: t }) {
1606
+ return t;
1607
+ }
1608
+ text({ text: t }) {
1609
+ return t;
1610
+ }
1611
+ link({ text: t }) {
1612
+ return "" + t;
1613
+ }
1614
+ image({ text: t }) {
1615
+ return "" + t;
1616
+ }
1617
+ br() {
1618
+ return "";
1619
+ }
1620
+ checkbox({ raw: t }) {
1621
+ return t;
1622
+ }
1623
+ }, h(ze, "$"), ze), we, re = (we = class {
1624
+ constructor(t) {
1625
+ E(this, "options");
1626
+ E(this, "renderer");
1627
+ E(this, "textRenderer");
1628
+ this.options = t || Ee, this.options.renderer = this.options.renderer || new kt(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new sn();
1629
+ }
1630
+ static parse(t, e) {
1631
+ return new we(e).parse(t);
1632
+ }
1633
+ static parseInline(t, e) {
1634
+ return new we(e).parseInline(t);
1635
+ }
1636
+ parse(t) {
1637
+ let e = "";
1638
+ for (let n = 0; n < t.length; n++) {
1639
+ let s = t[n];
1640
+ if (this.options.extensions?.renderers?.[s.type]) {
1641
+ let a = s, o = this.options.extensions.renderers[a.type].call({ parser: this }, a);
1642
+ if (o !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(a.type)) {
1643
+ e += o || "";
1644
+ continue;
1645
+ }
1646
+ }
1647
+ let r = s;
1648
+ switch (r.type) {
1649
+ case "space": {
1650
+ e += this.renderer.space(r);
1651
+ break;
1652
+ }
1653
+ case "hr": {
1654
+ e += this.renderer.hr(r);
1655
+ break;
1656
+ }
1657
+ case "heading": {
1658
+ e += this.renderer.heading(r);
1659
+ break;
1660
+ }
1661
+ case "code": {
1662
+ e += this.renderer.code(r);
1663
+ break;
1664
+ }
1665
+ case "table": {
1666
+ e += this.renderer.table(r);
1667
+ break;
1668
+ }
1669
+ case "blockquote": {
1670
+ e += this.renderer.blockquote(r);
1671
+ break;
1672
+ }
1673
+ case "list": {
1674
+ e += this.renderer.list(r);
1675
+ break;
1676
+ }
1677
+ case "checkbox": {
1678
+ e += this.renderer.checkbox(r);
1679
+ break;
1680
+ }
1681
+ case "html": {
1682
+ e += this.renderer.html(r);
1683
+ break;
1684
+ }
1685
+ case "def": {
1686
+ e += this.renderer.def(r);
1687
+ break;
1688
+ }
1689
+ case "paragraph": {
1690
+ e += this.renderer.paragraph(r);
1691
+ break;
1692
+ }
1693
+ case "text": {
1694
+ e += this.renderer.text(r);
1695
+ break;
1696
+ }
1697
+ default: {
1698
+ let a = 'Token with "' + r.type + '" type was not found.';
1699
+ if (this.options.silent) return console.error(a), "";
1700
+ throw new Error(a);
1701
+ }
1702
+ }
1703
+ }
1704
+ return e;
1705
+ }
1706
+ parseInline(t, e = this.renderer) {
1707
+ let n = "";
1708
+ for (let s = 0; s < t.length; s++) {
1709
+ let r = t[s];
1710
+ if (this.options.extensions?.renderers?.[r.type]) {
1711
+ let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
1712
+ if (o !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
1713
+ n += o || "";
1714
+ continue;
1715
+ }
1716
+ }
1717
+ let a = r;
1718
+ switch (a.type) {
1719
+ case "escape": {
1720
+ n += e.text(a);
1721
+ break;
1722
+ }
1723
+ case "html": {
1724
+ n += e.html(a);
1725
+ break;
1726
+ }
1727
+ case "link": {
1728
+ n += e.link(a);
1729
+ break;
1730
+ }
1731
+ case "image": {
1732
+ n += e.image(a);
1733
+ break;
1734
+ }
1735
+ case "checkbox": {
1736
+ n += e.checkbox(a);
1737
+ break;
1738
+ }
1739
+ case "strong": {
1740
+ n += e.strong(a);
1741
+ break;
1742
+ }
1743
+ case "em": {
1744
+ n += e.em(a);
1745
+ break;
1746
+ }
1747
+ case "codespan": {
1748
+ n += e.codespan(a);
1749
+ break;
1750
+ }
1751
+ case "br": {
1752
+ n += e.br(a);
1753
+ break;
1754
+ }
1755
+ case "del": {
1756
+ n += e.del(a);
1757
+ break;
1758
+ }
1759
+ case "text": {
1760
+ n += e.text(a);
1761
+ break;
1762
+ }
1763
+ default: {
1764
+ let o = 'Token with "' + a.type + '" type was not found.';
1765
+ if (this.options.silent) return console.error(o), "";
1766
+ throw new Error(o);
1767
+ }
1768
+ }
1769
+ }
1770
+ return n;
1771
+ }
1772
+ }, h(we, "u"), we), xe, Ve = (xe = class {
1773
+ constructor(t) {
1774
+ E(this, "options");
1775
+ E(this, "block");
1776
+ this.options = t || Ee;
1777
+ }
1778
+ preprocess(t) {
1779
+ return t;
1780
+ }
1781
+ postprocess(t) {
1782
+ return t;
1783
+ }
1784
+ processAllTokens(t) {
1785
+ return t;
1786
+ }
1787
+ emStrongMask(t) {
1788
+ return t;
1789
+ }
1790
+ provideLexer() {
1791
+ return this.block ? se.lex : se.lexInline;
1792
+ }
1793
+ provideParser() {
1794
+ return this.block ? re.parse : re.parseInline;
1795
+ }
1796
+ }, h(xe, "P"), E(xe, "passThroughHooks", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"])), E(xe, "passThroughHooksRespectAsync", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"])), xe), Pe, jr = (Pe = class {
1797
+ constructor(...t) {
1798
+ E(this, "defaults", Xt());
1799
+ E(this, "options", this.setOptions);
1800
+ E(this, "parse", this.parseMarkdown(!0));
1801
+ E(this, "parseInline", this.parseMarkdown(!1));
1802
+ E(this, "Parser", re);
1803
+ E(this, "Renderer", kt);
1804
+ E(this, "TextRenderer", sn);
1805
+ E(this, "Lexer", se);
1806
+ E(this, "Tokenizer", mt);
1807
+ E(this, "Hooks", Ve);
1808
+ this.use(...t);
1809
+ }
1810
+ walkTokens(t, e) {
1811
+ let n = [];
1812
+ for (let s of t) switch (n = n.concat(e.call(this, s)), s.type) {
1813
+ case "table": {
1814
+ let r = s;
1815
+ for (let a of r.header) n = n.concat(this.walkTokens(a.tokens, e));
1816
+ for (let a of r.rows) for (let o of a) n = n.concat(this.walkTokens(o.tokens, e));
1817
+ break;
1818
+ }
1819
+ case "list": {
1820
+ let r = s;
1821
+ n = n.concat(this.walkTokens(r.items, e));
1822
+ break;
1823
+ }
1824
+ default: {
1825
+ let r = s;
1826
+ this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((a) => {
1827
+ let o = r[a].flat(1 / 0);
1828
+ n = n.concat(this.walkTokens(o, e));
1829
+ }) : r.tokens && (n = n.concat(this.walkTokens(r.tokens, e)));
1830
+ }
1831
+ }
1832
+ return n;
1833
+ }
1834
+ use(...t) {
1835
+ let e = this.defaults.extensions || { renderers: {}, childTokens: {} };
1836
+ return t.forEach((n) => {
1837
+ let s = { ...n };
1838
+ if (s.async = this.defaults.async || s.async || !1, n.extensions && (n.extensions.forEach((r) => {
1839
+ if (!r.name) throw new Error("extension name required");
1840
+ if ("renderer" in r) {
1841
+ let a = e.renderers[r.name];
1842
+ a ? e.renderers[r.name] = function(...o) {
1843
+ let c = r.renderer.apply(this, o);
1844
+ return c === !1 && (c = a.apply(this, o)), c;
1845
+ } : e.renderers[r.name] = r.renderer;
1846
+ }
1847
+ if ("tokenizer" in r) {
1848
+ if (!r.level || r.level !== "block" && r.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
1849
+ let a = e[r.level];
1850
+ a ? a.unshift(r.tokenizer) : e[r.level] = [r.tokenizer], r.start && (r.level === "block" ? e.startBlock ? e.startBlock.push(r.start) : e.startBlock = [r.start] : r.level === "inline" && (e.startInline ? e.startInline.push(r.start) : e.startInline = [r.start]));
1851
+ }
1852
+ "childTokens" in r && r.childTokens && (e.childTokens[r.name] = r.childTokens);
1853
+ }), s.extensions = e), n.renderer) {
1854
+ let r = this.defaults.renderer || new kt(this.defaults);
1855
+ for (let a in n.renderer) {
1856
+ if (!(a in r)) throw new Error(`renderer '${a}' does not exist`);
1857
+ if (["options", "parser"].includes(a)) continue;
1858
+ let o = a, c = n.renderer[o], p = r[o];
1859
+ r[o] = (...f) => {
1860
+ let d = c.apply(r, f);
1861
+ return d === !1 && (d = p.apply(r, f)), d || "";
1862
+ };
1863
+ }
1864
+ s.renderer = r;
1865
+ }
1866
+ if (n.tokenizer) {
1867
+ let r = this.defaults.tokenizer || new mt(this.defaults);
1868
+ for (let a in n.tokenizer) {
1869
+ if (!(a in r)) throw new Error(`tokenizer '${a}' does not exist`);
1870
+ if (["options", "rules", "lexer"].includes(a)) continue;
1871
+ let o = a, c = n.tokenizer[o], p = r[o];
1872
+ r[o] = (...f) => {
1873
+ let d = c.apply(r, f);
1874
+ return d === !1 && (d = p.apply(r, f)), d;
1875
+ };
1876
+ }
1877
+ s.tokenizer = r;
1878
+ }
1879
+ if (n.hooks) {
1880
+ let r = this.defaults.hooks || new Ve();
1881
+ for (let a in n.hooks) {
1882
+ if (!(a in r)) throw new Error(`hook '${a}' does not exist`);
1883
+ if (["options", "block"].includes(a)) continue;
1884
+ let o = a, c = n.hooks[o], p = r[o];
1885
+ Ve.passThroughHooks.has(a) ? r[o] = (f) => {
1886
+ if (this.defaults.async && Ve.passThroughHooksRespectAsync.has(a)) return (async () => {
1887
+ let m = await c.call(r, f);
1888
+ return p.call(r, m);
1889
+ })();
1890
+ let d = c.call(r, f);
1891
+ return p.call(r, d);
1892
+ } : r[o] = (...f) => {
1893
+ if (this.defaults.async) return (async () => {
1894
+ let m = await c.apply(r, f);
1895
+ return m === !1 && (m = await p.apply(r, f)), m;
1896
+ })();
1897
+ let d = c.apply(r, f);
1898
+ return d === !1 && (d = p.apply(r, f)), d;
1899
+ };
1900
+ }
1901
+ s.hooks = r;
1902
+ }
1903
+ if (n.walkTokens) {
1904
+ let r = this.defaults.walkTokens, a = n.walkTokens;
1905
+ s.walkTokens = function(o) {
1906
+ let c = [];
1907
+ return c.push(a.call(this, o)), r && (c = c.concat(r.call(this, o))), c;
1908
+ };
1909
+ }
1910
+ this.defaults = { ...this.defaults, ...s };
1911
+ }), this;
1912
+ }
1913
+ setOptions(t) {
1914
+ return this.defaults = { ...this.defaults, ...t }, this;
1915
+ }
1916
+ lexer(t, e) {
1917
+ return se.lex(t, e ?? this.defaults);
1918
+ }
1919
+ parser(t, e) {
1920
+ return re.parse(t, e ?? this.defaults);
1921
+ }
1922
+ parseMarkdown(t) {
1923
+ return (e, n) => {
1924
+ let s = { ...n }, r = { ...this.defaults, ...s }, a = this.onError(!!r.silent, !!r.async);
1925
+ if (this.defaults.async === !0 && s.async === !1) return a(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."));
1926
+ if (typeof e > "u" || e === null) return a(new Error("marked(): input parameter is undefined or null"));
1927
+ if (typeof e != "string") return a(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(e) + ", string expected"));
1928
+ if (r.hooks && (r.hooks.options = r, r.hooks.block = t), r.async) return (async () => {
1929
+ let o = r.hooks ? await r.hooks.preprocess(e) : e, c = await (r.hooks ? await r.hooks.provideLexer() : t ? se.lex : se.lexInline)(o, r), p = r.hooks ? await r.hooks.processAllTokens(c) : c;
1930
+ r.walkTokens && await Promise.all(this.walkTokens(p, r.walkTokens));
1931
+ let f = await (r.hooks ? await r.hooks.provideParser() : t ? re.parse : re.parseInline)(p, r);
1932
+ return r.hooks ? await r.hooks.postprocess(f) : f;
1933
+ })().catch(a);
1934
+ try {
1935
+ r.hooks && (e = r.hooks.preprocess(e));
1936
+ let o = (r.hooks ? r.hooks.provideLexer() : t ? se.lex : se.lexInline)(e, r);
1937
+ r.hooks && (o = r.hooks.processAllTokens(o)), r.walkTokens && this.walkTokens(o, r.walkTokens);
1938
+ let c = (r.hooks ? r.hooks.provideParser() : t ? re.parse : re.parseInline)(o, r);
1939
+ return r.hooks && (c = r.hooks.postprocess(c)), c;
1940
+ } catch (o) {
1941
+ return a(o);
1942
+ }
1943
+ };
1944
+ }
1945
+ onError(t, e) {
1946
+ return (n) => {
1947
+ if (n.message += `
1948
+ Please report this to https://github.com/markedjs/marked.`, t) {
1949
+ let s = "<p>An error occurred:</p><pre>" + oe(n.message + "", !0) + "</pre>";
1950
+ return e ? Promise.resolve(s) : s;
1951
+ }
1952
+ if (e) return Promise.reject(n);
1953
+ throw n;
1954
+ };
1955
+ }
1956
+ }, h(Pe, "B"), Pe), Ae = new jr();
1957
+ function M(l, t) {
1958
+ return Ae.parse(l, t);
1959
+ }
1960
+ h(M, "g");
1961
+ M.options = M.setOptions = function(l) {
1962
+ return Ae.setOptions(l), M.defaults = Ae.defaults, Qn(M.defaults), M;
1963
+ };
1964
+ M.getDefaults = Xt;
1965
+ M.defaults = Ee;
1966
+ M.use = function(...l) {
1967
+ return Ae.use(...l), M.defaults = Ae.defaults, Qn(M.defaults), M;
1968
+ };
1969
+ M.walkTokens = function(l, t) {
1970
+ return Ae.walkTokens(l, t);
1971
+ };
1972
+ M.parseInline = Ae.parseInline;
1973
+ M.Parser = re;
1974
+ M.parser = re.parse;
1975
+ M.Renderer = kt;
1976
+ M.TextRenderer = sn;
1977
+ M.Lexer = se;
1978
+ M.lexer = se.lex;
1979
+ M.Tokenizer = mt;
1980
+ M.Hooks = Ve;
1981
+ M.parse = M;
1982
+ M.options;
1983
+ M.setOptions;
1984
+ M.use;
1985
+ M.walkTokens;
1986
+ M.parseInline;
1987
+ re.parse;
1988
+ se.lex;
1989
+ const qr = { class: "flex flex-col h-full relative" }, Yr = {
1990
+ key: 0,
1991
+ class: "pb-4"
1992
+ }, Zr = {
1993
+ key: 0,
1994
+ class: "flex flex-col items-center justify-center pt-12 pb-6 px-4"
1995
+ }, Xr = ["src", "alt"], Vr = {
1996
+ key: 0,
1997
+ class: "flex items-center gap-3 py-3 px-2"
1998
+ }, Qr = ["src", "alt"], Kr = ["src", "alt"], Jr = ["src"], ei = ["href"], ti = ["innerHTML"], ni = {
1999
+ key: 1,
2000
+ class: "flex gap-2 justify-start items-end mb-4"
2001
+ }, si = { class: "flex-shrink-0" }, ri = ["src", "alt"], ii = { class: "flex-shrink-0 pt-4 pb-2 px-3" }, ai = {
2002
+ key: 0,
2003
+ class: "flex items-center gap-2 px-3 pb-2 overflow-x-auto"
2004
+ }, li = ["src", "alt"], oi = { class: "max-w-20 truncate" }, ci = ["onClick"], ui = {
2005
+ key: 0,
2006
+ class: "shrink-0 flex items-center justify-center size-14"
2007
+ }, hi = ["disabled"], pi = {
2008
+ key: 0,
2009
+ class: "i-svg-spinners-ring-resize size-4"
2010
+ }, fi = {
2011
+ key: 1,
2012
+ class: "i-tabler-paperclip size-5"
2013
+ }, di = ["placeholder", "disabled"], gi = ["disabled"], mi = /* @__PURE__ */ xt({
2014
+ __name: "ElAgentChat",
2015
+ props: {
2016
+ chatController: {},
2017
+ agent: {},
2018
+ variant: { default: "dark" },
2019
+ scale: { default: "md" },
2020
+ uploadFn: { type: Function },
2021
+ scope: { default: "private" },
2022
+ scopeName: {},
2023
+ setupHint: {},
2024
+ emptyStateMessage: {},
2025
+ subtitle: {}
2026
+ },
2027
+ setup(l) {
2028
+ const t = new M.Renderer();
2029
+ t.link = ({ href: A, text: w }) => `<a href="${A}" target="_blank" rel="noopener noreferrer">${w}</a>`, M.setOptions({ breaks: !0, gfm: !0, renderer: t });
2030
+ function e(A) {
2031
+ if (!A)
2032
+ return "";
2033
+ const w = M.parse(A, { async: !1 });
2034
+ return nr.sanitize(w, { ADD_ATTR: ["target"] });
2035
+ }
2036
+ h(e, "renderMarkdown");
2037
+ const n = {
2038
+ private: "",
2039
+ org: "",
2040
+ public: ""
2041
+ }, s = {
2042
+ private: "Full access to tools.",
2043
+ org: "Visible to workspace members.",
2044
+ public: "Public conversation."
2045
+ }, r = Q(() => l.setupHint ?? n[l.scope]), a = Q(() => l.emptyStateMessage ? l.emptyStateMessage : l.scope === "org" && l.scopeName ? `Visible to ${l.scopeName} members.` : s[l.scope]), o = Q(() => l.scale === "lg"), c = ne(""), p = ne(), f = ne(), d = ne(), m = ne([]), b = ne(!1);
2046
+ function L(A, w) {
2047
+ const x = A[w], I = A[w + 1];
2048
+ return !I || I.sender !== x.sender;
2049
+ }
2050
+ h(L, "shouldShowAvatar");
2051
+ const D = Q(() => l.chatController?.textState.value), H = Q(() => D.value?.isConnected ?? !1), _e = Q(() => D.value?.isThinking ?? !1), me = Q(() => D.value?.connectionStatus === "disconnected" && !!D.value?.error), ee = Q(() => D.value?.connectionStatus !== "connected" && !D.value?.error), $ = Q(() => D.value?.error), W = Q(() => l.chatController?.sharedMessages.value?.filter((A) => A.sender !== "system") ?? []), te = Q(() => !H.value), ue = Q(() => me.value ? "Agent is offline" : ee.value ? "Connecting..." : "Message"), Ke = Q(() => (c.value.trim() || m.value.length > 0) && !te.value && !b.value);
2052
+ jn(async () => {
2053
+ if (l.chatController && !H.value)
2054
+ try {
2055
+ await l.chatController.startTextConversation();
2056
+ } catch (A) {
2057
+ console.error("Failed to start text conversation:", A);
2058
+ }
2059
+ });
2060
+ async function Je() {
2061
+ const A = c.value.trim(), w = m.value.length > 0;
2062
+ if (!A && !w || !l.chatController || !H.value || b.value)
2063
+ return;
2064
+ const x = c.value, I = w ? [...m.value] : void 0;
2065
+ c.value = "", m.value = [], f.value && (f.value.style.height = "auto", f.value.focus());
2066
+ try {
2067
+ await l.chatController.sendChatMessage(x, I), B();
2068
+ } catch (C) {
2069
+ console.error("Error sending message:", C);
2070
+ }
2071
+ }
2072
+ h(Je, "sendMessage");
2073
+ function yt(A) {
2074
+ A.key === "Enter" && !A.shiftKey && (A.preventDefault(), Je());
2075
+ }
2076
+ h(yt, "handleKeydown");
2077
+ function B() {
2078
+ p.value && Nt(() => {
2079
+ p.value.scrollTop = p.value.scrollHeight;
2080
+ });
2081
+ }
2082
+ h(B, "scrollToBottom");
2083
+ function $e() {
2084
+ f.value && (f.value.style.height = "auto", f.value.style.height = `${Math.min(f.value.scrollHeight, 150)}px`);
2085
+ }
2086
+ h($e, "adjustTextareaHeight"), Wt(c, () => Nt(() => $e()));
2087
+ const O = Q(() => l.variant === "light");
2088
+ function Ue() {
2089
+ d.value?.click();
2090
+ }
2091
+ h(Ue, "triggerFileInput");
2092
+ async function Tt(A) {
2093
+ const w = A.target, x = w.files?.[0];
2094
+ if (!(!x || !l.uploadFn)) {
2095
+ b.value = !0;
2096
+ try {
2097
+ const I = await l.uploadFn(x);
2098
+ m.value = [...m.value, I];
2099
+ } catch (I) {
2100
+ console.error("Upload failed:", I);
2101
+ } finally {
2102
+ b.value = !1, w.value = "";
2103
+ }
2104
+ }
2105
+ }
2106
+ h(Tt, "handleFileSelect");
2107
+ function vt(A) {
2108
+ m.value = m.value.filter((w, x) => x !== A);
2109
+ }
2110
+ h(vt, "removeAttachment");
2111
+ function et(A, w) {
2112
+ if (w === 0) {
2113
+ const pe = A[w];
2114
+ return pe?.timestamp ? Be(new Date(pe.timestamp)) : null;
2115
+ }
2116
+ const x = A[w - 1], I = A[w];
2117
+ if (!x?.timestamp || !I?.timestamp) return null;
2118
+ const C = new Date(x.timestamp).getTime();
2119
+ return new Date(I.timestamp).getTime() - C > 36e5 ? Be(new Date(I.timestamp)) : null;
2120
+ }
2121
+ h(et, "shouldShowTimeDivider");
2122
+ function Be(A) {
2123
+ const w = /* @__PURE__ */ new Date(), x = A.toDateString() === w.toDateString(), I = new Date(w);
2124
+ I.setDate(I.getDate() - 1);
2125
+ const C = A.toDateString() === I.toDateString(), he = A.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" });
2126
+ if (x) return he;
2127
+ if (C) return `Yesterday, ${he}`;
2128
+ const N = A.getFullYear() === w.getFullYear();
2129
+ return `${A.toLocaleDateString("en-US", {
2130
+ weekday: "long",
2131
+ month: "short",
2132
+ day: "numeric",
2133
+ ...N ? {} : { year: "numeric" }
2134
+ })}, ${he}`;
2135
+ }
2136
+ return h(Be, "formatTimeDivider"), Wt(W, (A) => {
2137
+ A.length > 0 && Nt(() => B());
2138
+ }, { immediate: !0, deep: !0 }), (A, w) => (v(), S("div", qr, [
2139
+ O.value ? q("", !0) : (v(), S("div", Yr, [
2140
+ zt(Os, {
2141
+ agent: l.agent,
2142
+ "is-online": H.value
2143
+ }, null, 8, ["agent", "is-online"])
2144
+ ])),
2145
+ me.value ? (v(), S("div", {
2146
+ key: 1,
2147
+ class: _(["py-16 flex flex-col items-center justify-center gap-3 text-sm", O.value ? "text-theme-400" : "text-white/60"])
2148
+ }, [
2149
+ y("i", {
2150
+ class: _(["i-heroicons-cloud-arrow-down size-8", O.value ? "text-theme-300" : "text-white/40"])
2151
+ }, null, 2),
2152
+ y("span", null, ce($.value), 1)
2153
+ ], 2)) : ee.value ? (v(), S("div", {
2154
+ key: 2,
2155
+ class: _(["py-16 flex flex-col items-center justify-center gap-2 text-sm", O.value ? "text-theme-400" : "text-theme-600"])
2156
+ }, [
2157
+ zt(_n, { class: "size-4" })
2158
+ ], 2)) : (v(), S("div", {
2159
+ key: 3,
2160
+ class: _(["flex items-center justify-center gap-1.5 py-2 text-[11px]", O.value ? "text-theme-300" : "text-white/30"])
2161
+ }, [
2162
+ r.value ? (v(), S(ve, { key: 0 }, [
2163
+ w[2] || (w[2] = y("i", { class: "i-tabler-tool size-3" }, null, -1)),
2164
+ y("span", null, ce(r.value), 1)
2165
+ ], 64)) : q("", !0)
2166
+ ], 2)),
2167
+ y("div", {
2168
+ ref_key: "messagesContainer",
2169
+ ref: p,
2170
+ class: "flex-1 overflow-y-auto overflow-x-hidden py-4 px-3 space-y-1 min-h-0 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden"
2171
+ }, [
2172
+ W.value.length === 0 && !ee.value && !me.value ? (v(), S("div", Zr, [
2173
+ y("img", {
2174
+ src: l.agent.avatarUrl.value,
2175
+ alt: l.agent.displayName.value,
2176
+ class: _(["rounded-full object-cover mb-3", o.value ? "size-28" : "size-20"])
2177
+ }, null, 10, Xr),
2178
+ y("div", {
2179
+ class: _(["font-semibold", [O.value ? "text-theme-900" : "text-white", o.value ? "text-lg" : "text-base"]])
2180
+ }, ce(l.agent.displayName.value), 3),
2181
+ l.subtitle || l.agent.hasCustomHandle.value ? (v(), S("div", {
2182
+ key: 0,
2183
+ class: _(["mt-0.5", [O.value ? "text-theme-400" : "text-white/50", o.value ? "text-sm" : "text-xs"]])
2184
+ }, ce(l.subtitle || l.agent.displayHandle.value), 3)) : q("", !0),
2185
+ y("p", {
2186
+ class: _(["text-center mt-3 leading-relaxed line-clamp-2", [O.value ? "text-theme-400" : "text-white/50", o.value ? "text-base max-w-[300px]" : "text-sm max-w-[240px]"]])
2187
+ }, ce(a.value), 3)
2188
+ ])) : q("", !0),
2189
+ (v(!0), S(ve, null, Pt(W.value, (x, I) => (v(), S(ve, {
2190
+ key: x.id
2191
+ }, [
2192
+ et(W.value, I) ? (v(), S("div", Vr, [
2193
+ y("div", {
2194
+ class: _(["flex-1 h-px", O.value ? "bg-theme-200" : "bg-white/10"])
2195
+ }, null, 2),
2196
+ y("span", {
2197
+ class: _(["font-medium shrink-0", [O.value ? "text-theme-400" : "text-white/40", o.value ? "text-xs" : "text-[11px]"]])
2198
+ }, ce(et(W.value, I)), 3),
2199
+ y("div", {
2200
+ class: _(["flex-1 h-px", O.value ? "bg-theme-200" : "bg-white/10"])
2201
+ }, null, 2)
2202
+ ])) : q("", !0),
2203
+ y("div", {
2204
+ class: _(["flex gap-2 items-end", {
2205
+ "justify-end": x.sender === "user",
2206
+ "justify-start": x.sender === "agent",
2207
+ "mb-4": L(W.value, I)
2208
+ }])
2209
+ }, [
2210
+ x.sender === "agent" ? (v(), S("div", {
2211
+ key: 0,
2212
+ class: _(["flex-shrink-0", o.value ? "size-10" : "size-8"])
2213
+ }, [
2214
+ L(W.value, I) ? (v(), S("img", {
2215
+ key: 0,
2216
+ src: l.agent.avatarUrl.value,
2217
+ alt: l.agent.displayName.value,
2218
+ class: _(["rounded-full object-cover", o.value ? "size-10" : "size-7"])
2219
+ }, null, 10, Qr)) : q("", !0)
2220
+ ], 2)) : q("", !0),
2221
+ y("div", {
2222
+ class: _(x.sender === "user" ? "max-w-[75%]" : "max-w-[85%]")
2223
+ }, [
2224
+ x.attachments?.length ? (v(), S("div", {
2225
+ key: 0,
2226
+ class: _(["mb-1 space-y-1", x.sender === "user" ? "flex flex-col items-end" : ""])
2227
+ }, [
2228
+ (v(!0), S(ve, null, Pt(x.attachments, (C, he) => (v(), S(ve, { key: he }, [
2229
+ C.type === "image" ? (v(), S("img", {
2230
+ key: 0,
2231
+ src: C.url,
2232
+ alt: C.name,
2233
+ class: _(["rounded-xl object-cover max-h-48", o.value ? "max-w-[320px]" : "max-w-[240px]"])
2234
+ }, null, 10, Kr)) : C.type === "audio" ? (v(), S("audio", {
2235
+ key: 1,
2236
+ src: C.url,
2237
+ controls: "",
2238
+ class: "max-w-full"
2239
+ }, null, 8, Jr)) : (v(), S("a", {
2240
+ key: 2,
2241
+ href: C.url,
2242
+ target: "_blank",
2243
+ rel: "noopener",
2244
+ class: _(["inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs", O.value ? "bg-theme-100 text-theme-600 hover:bg-theme-200" : "bg-white/10 text-white/80 hover:bg-white/20"])
2245
+ }, [
2246
+ w[3] || (w[3] = y("i", { class: "i-tabler-file size-3.5" }, null, -1)),
2247
+ xs(" " + ce(C.name), 1)
2248
+ ], 10, ei))
2249
+ ], 64))), 128))
2250
+ ], 2)) : q("", !0),
2251
+ x.text ? (v(), S("div", {
2252
+ key: 1,
2253
+ class: _(["rounded-2xl px-3.5 py-2", x.sender === "user" ? "bg-primary-500 text-white" : O.value ? "bg-theme-100 text-theme-800" : "bg-white/15 backdrop-blur-sm text-white/95"])
2254
+ }, [
2255
+ y("div", {
2256
+ class: _(["chat-msg-prose break-words", o.value ? "text-[15px] leading-[1.6]" : "text-[13px] leading-[1.55]"]),
2257
+ innerHTML: e(x.text)
2258
+ }, null, 10, ti)
2259
+ ], 2)) : q("", !0)
2260
+ ], 2)
2261
+ ], 2)
2262
+ ], 64))), 128)),
2263
+ _e.value ? (v(), S("div", ni, [
2264
+ y("div", si, [
2265
+ y("img", {
2266
+ src: l.agent.avatarUrl.value,
2267
+ alt: l.agent.displayName.value,
2268
+ class: _(["rounded-full object-cover", o.value ? "size-10" : "size-8"])
2269
+ }, null, 10, ri)
2270
+ ]),
2271
+ y("div", {
2272
+ class: _(["rounded-2xl px-4 py-2.5 flex items-center", O.value ? "bg-theme-100" : "bg-white/15 backdrop-blur-sm"])
2273
+ }, [
2274
+ y("i", {
2275
+ class: _(["i-svg-spinners-3-dots-fade size-6", O.value ? "text-theme-400" : "text-white/70"])
2276
+ }, null, 2)
2277
+ ], 2)
2278
+ ])) : q("", !0)
2279
+ ], 512),
2280
+ y("div", ii, [
2281
+ m.value.length > 0 ? (v(), S("div", ai, [
2282
+ (v(!0), S(ve, null, Pt(m.value, (x, I) => (v(), S("div", {
2283
+ key: I,
2284
+ class: "relative shrink-0 group"
2285
+ }, [
2286
+ x.type === "image" ? (v(), S("img", {
2287
+ key: 0,
2288
+ src: x.url,
2289
+ alt: x.name,
2290
+ class: _(["size-14 rounded-lg object-cover border", O.value ? "border-theme-200" : "border-white/20"])
2291
+ }, null, 10, li)) : (v(), S("div", {
2292
+ key: 1,
2293
+ class: _(["h-14 px-3 rounded-lg flex items-center gap-1.5 text-xs border", O.value ? "border-theme-200 bg-theme-50 text-theme-600" : "border-white/20 bg-white/10 text-white/70"])
2294
+ }, [
2295
+ w[4] || (w[4] = y("i", { class: "i-tabler-file size-4" }, null, -1)),
2296
+ y("span", oi, ce(x.name), 1)
2297
+ ], 2)),
2298
+ y("button", {
2299
+ class: "absolute -top-1.5 -right-1.5 size-5 flex items-center justify-center rounded-full bg-theme-600 text-white text-xs opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",
2300
+ onClick: /* @__PURE__ */ h((C) => vt(I), "onClick")
2301
+ }, [...w[5] || (w[5] = [
2302
+ y("i", { class: "i-tabler-x size-3" }, null, -1)
2303
+ ])], 8, ci)
2304
+ ]))), 128)),
2305
+ b.value ? (v(), S("div", ui, [
2306
+ zt(_n, { class: "size-5" })
2307
+ ])) : q("", !0)
2308
+ ])) : q("", !0),
2309
+ l.uploadFn ? (v(), S("input", {
2310
+ key: 1,
2311
+ ref_key: "fileInput",
2312
+ ref: d,
2313
+ type: "file",
2314
+ accept: "image/*,audio/*,video/*",
2315
+ class: "hidden",
2316
+ onChange: Tt
2317
+ }, null, 544)) : q("", !0),
2318
+ y("div", {
2319
+ class: _(["flex items-end gap-1 w-full rounded-3xl px-3 py-1.5", O.value ? "bg-theme-50 border border-theme-200 focus-within:border-theme-300" : "bg-white/10 backdrop-blur-sm border border-white/20 focus-within:border-white/40"])
2320
+ }, [
2321
+ l.uploadFn ? (v(), S("button", {
2322
+ key: 0,
2323
+ class: _(["shrink-0 flex items-center justify-center rounded-full transition-colors mb-0.5 cursor-pointer", [
2324
+ o.value ? "size-10" : "size-9",
2325
+ O.value ? "text-theme-400 hover:text-theme-600" : "text-white/50 hover:text-white/80",
2326
+ b.value ? "opacity-50 pointer-events-none" : ""
2327
+ ]]),
2328
+ disabled: te.value || b.value,
2329
+ onClick: Ue
2330
+ }, [
2331
+ b.value ? (v(), S("i", pi)) : (v(), S("i", fi))
2332
+ ], 10, hi)) : q("", !0),
2333
+ bs(y("textarea", {
2334
+ ref_key: "textarea",
2335
+ ref: f,
2336
+ "onUpdate:modelValue": w[0] || (w[0] = (x) => c.value = x),
2337
+ rows: "1",
2338
+ enterkeyhint: "send",
2339
+ placeholder: ue.value,
2340
+ disabled: te.value,
2341
+ style: ws({ fontSize: (o.value, "16px"), resize: "none" }),
2342
+ class: _(["flex-1 min-w-0 bg-transparent px-2 py-1.5 focus:outline-none disabled:opacity-50 overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden", O.value ? "text-theme-800 placeholder-theme-400" : "text-white placeholder-white/50"]),
2343
+ onKeydown: yt
2344
+ }, null, 46, di), [
2345
+ [ys, c.value]
2346
+ ]),
2347
+ y("button", {
2348
+ class: _(["shrink-0 flex items-center justify-center rounded-full transition-colors mb-0.5", [
2349
+ o.value ? "size-10" : "size-9",
2350
+ Ke.value ? "bg-primary-500 text-white hover:bg-primary-600 cursor-pointer" : O.value ? "bg-theme-100 text-theme-300" : "bg-white/10 text-white/30"
2351
+ ]]),
2352
+ disabled: !Ke.value,
2353
+ onClick: w[1] || (w[1] = (x) => Je())
2354
+ }, [...w[6] || (w[6] = [
2355
+ y("i", { class: "i-tabler-arrow-up size-5" }, null, -1)
2356
+ ])], 10, gi)
2357
+ ], 2),
2358
+ y("div", {
2359
+ class: _(["hidden lg:block text-[10px] text-center mt-2", O.value ? "text-theme-300" : "text-white/40"])
2360
+ }, " Press Enter to send, Shift+Enter for new line ", 2)
2361
+ ])
2362
+ ]));
2363
+ }
2364
+ }), ki = /* @__PURE__ */ h((l, t) => {
2365
+ const e = l.__vccOpts || l;
2366
+ for (const [n, s] of t)
2367
+ e[n] = s;
2368
+ return e;
2369
+ }, "_export_sfc"), Ei = /* @__PURE__ */ ki(mi, [["__scopeId", "data-v-0653d193"]]), xi = { class: "agent-wrap" }, bi = {
2370
+ key: 0,
2371
+ class: "flex items-center justify-center h-full"
2372
+ }, _i = /* @__PURE__ */ xt({
2373
+ __name: "AgentWrap",
2374
+ props: {
2375
+ sdk: {},
2376
+ agent: {},
2377
+ handle: {},
2378
+ context: {},
2379
+ firstMessage: {},
2380
+ buttonText: {},
2381
+ buttonIcon: {},
2382
+ hasClose: { type: Boolean },
2383
+ apiBase: {}
2384
+ },
2385
+ setup(l) {
2386
+ const t = As("AgentWrap"), e = l, n = e.sdk || Es.getInstance({
2387
+ isDev: typeof window < "u" ? window.location.hostname === "localhost" || window.location.hostname.includes("127.0.0.1") : !1,
2388
+ ...e.apiBase && { apiBase: e.apiBase }
2389
+ }), s = ne(!e.agent), r = Ts(e.agent ? new dt({ config: e.agent }) : void 0), a = ne();
2390
+ return jn(async () => {
2391
+ if (e.agent) {
2392
+ t.debug("Agent provided via props, skipping fetch", {
2393
+ agentId: e.agent.agentId,
2394
+ handle: e.agent.handle
2395
+ }), s.value = !1;
2396
+ return;
2397
+ }
2398
+ if (!e.handle) {
2399
+ a.value = "No handle or agent provided", t.warn("AgentWrap mounted without handle or agent", {
2400
+ propsReceived: {
2401
+ handle: e.handle,
2402
+ agent: e.agent,
2403
+ context: e.context,
2404
+ apiBase: e.apiBase
2405
+ },
2406
+ sdkState: {
2407
+ isDev: n.isDev,
2408
+ apiBase: n.apiBase
2409
+ }
2410
+ }), s.value = !1;
2411
+ return;
2412
+ }
2413
+ try {
2414
+ s.value = !0, t.debug("Fetching public agent", { handle: e.handle });
2415
+ const o = await n.getPublicAgent({ handle: e.handle });
2416
+ o ? (r.value = new dt({ config: o }), t.debug("Successfully fetched public agent", {
2417
+ agentId: o.agentId,
2418
+ handle: o.handle
2419
+ }), o.agentId && n.track({
2420
+ event: "view_profile",
2421
+ agentId: o.agentId,
2422
+ properties: {
2423
+ viewSource: "widget"
2424
+ }
2425
+ })) : (a.value = n.error.value || "Agent not found", t.error("Failed to fetch public agent - no data returned", {
2426
+ handle: e.handle,
2427
+ sdkError: n.error.value,
2428
+ sdkState: {
2429
+ isDev: n.isDev,
2430
+ apiBase: n.apiBase,
2431
+ loading: n.loading.value
2432
+ }
2433
+ }));
2434
+ } catch (o) {
2435
+ a.value = o instanceof Error ? o.message : "Failed to fetch agent", t.error("Exception while fetching public agent", {
2436
+ handle: e.handle,
2437
+ error: o instanceof Error ? {
2438
+ message: o.message,
2439
+ stack: o.stack
2440
+ } : o,
2441
+ sdkState: {
2442
+ isDev: n.isDev,
2443
+ apiBase: n.apiBase,
2444
+ error: n.error.value
2445
+ }
2446
+ });
2447
+ } finally {
2448
+ s.value = !1, r.value || t.debug("AgentWrap component will render empty (silent failure)", {
2449
+ state: {
2450
+ loading: s.value,
2451
+ hasAgent: !!r.value,
2452
+ error: a.value
2453
+ },
2454
+ props: {
2455
+ handle: e.handle,
2456
+ context: e.context,
2457
+ apiBase: e.apiBase
2458
+ },
2459
+ sdkState: {
2460
+ isDev: n.isDev,
2461
+ apiBase: n.apiBase,
2462
+ error: n.error.value
2463
+ }
2464
+ });
2465
+ }
2466
+ }), (o, c) => (v(), S("div", xi, [
2467
+ s.value ? (v(), S("div", bi, [...c[0] || (c[0] = [
2468
+ y("div", { class: "animate-spin rounded-full size-6 border-b-2 border-white" }, null, -1)
2469
+ ])])) : r.value ? vs(o.$slots, "default", {
2470
+ key: 1,
2471
+ sdk: jt(n),
2472
+ agent: r.value,
2473
+ context: l.context,
2474
+ firstMessage: l.firstMessage,
2475
+ buttonText: l.buttonText,
2476
+ buttonIcon: l.buttonIcon,
2477
+ loading: s.value
2478
+ }) : q("", !0)
2479
+ ]));
2480
+ }
2481
+ });
2482
+ export {
2483
+ Rn as A,
2484
+ Ei as E,
2485
+ _i as _,
2486
+ ki as a,
2487
+ _n as b,
2488
+ Os as c,
2489
+ Si as g,
2490
+ Cn as h,
2491
+ Ai as p
2492
+ };
2493
+ //# sourceMappingURL=AgentWrap.vue_vue_type_script_setup_true_lang-Dq-gz8bM.js.map