lee-ai-widget 1.0.6 → 1.0.8

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.
@@ -0,0 +1,2102 @@
1
+ var Un = Object.defineProperty;
2
+ var Zt = (l) => {
3
+ throw TypeError(l);
4
+ };
5
+ var Fn = (l, e, t) => e in l ? Un(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
6
+ var b = (l, e, t) => Fn(l, typeof e != "symbol" ? e + "" : e, t), Hn = (l, e, t) => e.has(l) || Zt("Cannot " + t);
7
+ var Yt = (l, e, t) => e.has(l) ? Zt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(l) : e.set(l, t);
8
+ var Ce = (l, e, t) => (Hn(l, e, "access private method"), t);
9
+ async function Bn(l, e, t, n, r, o) {
10
+ const i = `${l.baseUrl}/ai/chat`, a = {
11
+ provider: l.provider || "google",
12
+ // 默认 google
13
+ apiKey: l.apiKey,
14
+ // 可选
15
+ model: l.model,
16
+ // 可选,后端有默认值
17
+ contents: [
18
+ ...e,
19
+ { role: "user", parts: [{ text: t }] }
20
+ ],
21
+ options: {
22
+ systemInstruction: l.systemInstruction,
23
+ // 企业人设
24
+ enableSearch: l.enableSearch
25
+ }
26
+ };
27
+ try {
28
+ const c = await fetch(i, {
29
+ method: "POST",
30
+ headers: { "Content-Type": "application/json" },
31
+ body: JSON.stringify(a)
32
+ });
33
+ if (!c.ok) throw new Error(`Error: ${c.statusText}`);
34
+ if (!c.body) throw new Error("ReadableStream not supported");
35
+ const d = c.body.getReader(), h = new TextDecoder();
36
+ for (; ; ) {
37
+ const { done: m, value: g } = await d.read();
38
+ if (m) break;
39
+ const T = h.decode(g, { stream: !0 });
40
+ n(T);
41
+ }
42
+ r();
43
+ } catch (c) {
44
+ console.error("Chat API Error:", c), o(c.message || "网络连接失败");
45
+ }
46
+ }
47
+ function gt() {
48
+ return {
49
+ async: !1,
50
+ breaks: !1,
51
+ extensions: null,
52
+ gfm: !0,
53
+ hooks: null,
54
+ pedantic: !1,
55
+ renderer: null,
56
+ silent: !1,
57
+ tokenizer: null,
58
+ walkTokens: null
59
+ };
60
+ }
61
+ let ne = gt();
62
+ function an(l) {
63
+ ne = l;
64
+ }
65
+ const cn = /[&<>"']/, Gn = new RegExp(cn.source, "g"), un = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, Wn = new RegExp(un.source, "g"), qn = {
66
+ "&": "&amp;",
67
+ "<": "&lt;",
68
+ ">": "&gt;",
69
+ '"': "&quot;",
70
+ "'": "&#39;"
71
+ }, jt = (l) => qn[l];
72
+ function $(l, e) {
73
+ if (e) {
74
+ if (cn.test(l))
75
+ return l.replace(Gn, jt);
76
+ } else if (un.test(l))
77
+ return l.replace(Wn, jt);
78
+ return l;
79
+ }
80
+ const Zn = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
81
+ function Yn(l) {
82
+ return l.replace(Zn, (e, t) => (t = t.toLowerCase(), t === "colon" ? ":" : t.charAt(0) === "#" ? t.charAt(1) === "x" ? String.fromCharCode(parseInt(t.substring(2), 16)) : String.fromCharCode(+t.substring(1)) : ""));
83
+ }
84
+ const jn = /(^|[^\[])\^/g;
85
+ function w(l, e) {
86
+ let t = typeof l == "string" ? l : l.source;
87
+ e = e || "";
88
+ const n = {
89
+ replace: (r, o) => {
90
+ let i = typeof o == "string" ? o : o.source;
91
+ return i = i.replace(jn, "$1"), t = t.replace(r, i), n;
92
+ },
93
+ getRegex: () => new RegExp(t, e)
94
+ };
95
+ return n;
96
+ }
97
+ function Xt(l) {
98
+ try {
99
+ l = encodeURI(l).replace(/%25/g, "%");
100
+ } catch {
101
+ return null;
102
+ }
103
+ return l;
104
+ }
105
+ const xe = { exec: () => null };
106
+ function Qt(l, e) {
107
+ const t = l.replace(/\|/g, (o, i, a) => {
108
+ let c = !1, d = i;
109
+ for (; --d >= 0 && a[d] === "\\"; )
110
+ c = !c;
111
+ return c ? "|" : " |";
112
+ }), n = t.split(/ \|/);
113
+ let r = 0;
114
+ if (n[0].trim() || n.shift(), n.length > 0 && !n[n.length - 1].trim() && n.pop(), e)
115
+ if (n.length > e)
116
+ n.splice(e);
117
+ else
118
+ for (; n.length < e; )
119
+ n.push("");
120
+ for (; r < n.length; r++)
121
+ n[r] = n[r].trim().replace(/\\\|/g, "|");
122
+ return n;
123
+ }
124
+ function Me(l, e, t) {
125
+ const n = l.length;
126
+ if (n === 0)
127
+ return "";
128
+ let r = 0;
129
+ for (; r < n && l.charAt(n - r - 1) === e; )
130
+ r++;
131
+ return l.slice(0, n - r);
132
+ }
133
+ function Xn(l, e) {
134
+ if (l.indexOf(e[1]) === -1)
135
+ return -1;
136
+ let t = 0;
137
+ for (let n = 0; n < l.length; n++)
138
+ if (l[n] === "\\")
139
+ n++;
140
+ else if (l[n] === e[0])
141
+ t++;
142
+ else if (l[n] === e[1] && (t--, t < 0))
143
+ return n;
144
+ return -1;
145
+ }
146
+ function Vt(l, e, t, n) {
147
+ const r = e.href, o = e.title ? $(e.title) : null, i = l[1].replace(/\\([\[\]])/g, "$1");
148
+ if (l[0].charAt(0) !== "!") {
149
+ n.state.inLink = !0;
150
+ const a = {
151
+ type: "link",
152
+ raw: t,
153
+ href: r,
154
+ title: o,
155
+ text: i,
156
+ tokens: n.inlineTokens(i)
157
+ };
158
+ return n.state.inLink = !1, a;
159
+ }
160
+ return {
161
+ type: "image",
162
+ raw: t,
163
+ href: r,
164
+ title: o,
165
+ text: $(i)
166
+ };
167
+ }
168
+ function Qn(l, e) {
169
+ const t = l.match(/^(\s+)(?:```)/);
170
+ if (t === null)
171
+ return e;
172
+ const n = t[1];
173
+ return e.split(`
174
+ `).map((r) => {
175
+ const o = r.match(/^\s+/);
176
+ if (o === null)
177
+ return r;
178
+ const [i] = o;
179
+ return i.length >= n.length ? r.slice(n.length) : r;
180
+ }).join(`
181
+ `);
182
+ }
183
+ class $e {
184
+ // set by the lexer
185
+ constructor(e) {
186
+ b(this, "options");
187
+ b(this, "rules");
188
+ // set by the lexer
189
+ b(this, "lexer");
190
+ this.options = e || ne;
191
+ }
192
+ space(e) {
193
+ const t = this.rules.block.newline.exec(e);
194
+ if (t && t[0].length > 0)
195
+ return {
196
+ type: "space",
197
+ raw: t[0]
198
+ };
199
+ }
200
+ code(e) {
201
+ const t = this.rules.block.code.exec(e);
202
+ if (t) {
203
+ const n = t[0].replace(/^ {1,4}/gm, "");
204
+ return {
205
+ type: "code",
206
+ raw: t[0],
207
+ codeBlockStyle: "indented",
208
+ text: this.options.pedantic ? n : Me(n, `
209
+ `)
210
+ };
211
+ }
212
+ }
213
+ fences(e) {
214
+ const t = this.rules.block.fences.exec(e);
215
+ if (t) {
216
+ const n = t[0], r = Qn(n, t[3] || "");
217
+ return {
218
+ type: "code",
219
+ raw: n,
220
+ lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
221
+ text: r
222
+ };
223
+ }
224
+ }
225
+ heading(e) {
226
+ const t = this.rules.block.heading.exec(e);
227
+ if (t) {
228
+ let n = t[2].trim();
229
+ if (/#$/.test(n)) {
230
+ const r = Me(n, "#");
231
+ (this.options.pedantic || !r || / $/.test(r)) && (n = r.trim());
232
+ }
233
+ return {
234
+ type: "heading",
235
+ raw: t[0],
236
+ depth: t[1].length,
237
+ text: n,
238
+ tokens: this.lexer.inline(n)
239
+ };
240
+ }
241
+ }
242
+ hr(e) {
243
+ const t = this.rules.block.hr.exec(e);
244
+ if (t)
245
+ return {
246
+ type: "hr",
247
+ raw: t[0]
248
+ };
249
+ }
250
+ blockquote(e) {
251
+ const t = this.rules.block.blockquote.exec(e);
252
+ if (t) {
253
+ const n = Me(t[0].replace(/^ *>[ \t]?/gm, ""), `
254
+ `), r = this.lexer.state.top;
255
+ this.lexer.state.top = !0;
256
+ const o = this.lexer.blockTokens(n);
257
+ return this.lexer.state.top = r, {
258
+ type: "blockquote",
259
+ raw: t[0],
260
+ tokens: o,
261
+ text: n
262
+ };
263
+ }
264
+ }
265
+ list(e) {
266
+ let t = this.rules.block.list.exec(e);
267
+ if (t) {
268
+ let n = t[1].trim();
269
+ const r = n.length > 1, o = {
270
+ type: "list",
271
+ raw: "",
272
+ ordered: r,
273
+ start: r ? +n.slice(0, -1) : "",
274
+ loose: !1,
275
+ items: []
276
+ };
277
+ n = r ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = r ? n : "[*+-]");
278
+ const i = new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`);
279
+ let a = "", c = "", d = !1;
280
+ for (; e; ) {
281
+ let h = !1;
282
+ if (!(t = i.exec(e)) || this.rules.block.hr.test(e))
283
+ break;
284
+ a = t[0], e = e.substring(a.length);
285
+ let m = t[2].split(`
286
+ `, 1)[0].replace(/^\t+/, (ue) => " ".repeat(3 * ue.length)), g = e.split(`
287
+ `, 1)[0], T = 0;
288
+ this.options.pedantic ? (T = 2, c = m.trimStart()) : (T = t[2].search(/[^ ]/), T = T > 4 ? 1 : T, c = m.slice(T), T += t[1].length);
289
+ let v = !1;
290
+ if (!m && /^ *$/.test(g) && (a += g + `
291
+ `, e = e.substring(g.length + 1), h = !0), !h) {
292
+ const ue = new RegExp(`^ {0,${Math.min(3, T - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), Ae = new RegExp(`^ {0,${Math.min(3, T - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), V = new RegExp(`^ {0,${Math.min(3, T - 1)}}(?:\`\`\`|~~~)`), S = new RegExp(`^ {0,${Math.min(3, T - 1)}}#`);
293
+ for (; e; ) {
294
+ const Y = e.split(`
295
+ `, 1)[0];
296
+ if (g = Y, this.options.pedantic && (g = g.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ")), V.test(g) || S.test(g) || ue.test(g) || Ae.test(e))
297
+ break;
298
+ if (g.search(/[^ ]/) >= T || !g.trim())
299
+ c += `
300
+ ` + g.slice(T);
301
+ else {
302
+ if (v || m.search(/[^ ]/) >= 4 || V.test(m) || S.test(m) || Ae.test(m))
303
+ break;
304
+ c += `
305
+ ` + g;
306
+ }
307
+ !v && !g.trim() && (v = !0), a += Y + `
308
+ `, e = e.substring(Y.length + 1), m = g.slice(T);
309
+ }
310
+ }
311
+ o.loose || (d ? o.loose = !0 : /\n *\n *$/.test(a) && (d = !0));
312
+ let P = null, Z;
313
+ this.options.gfm && (P = /^\[[ xX]\] /.exec(c), P && (Z = P[0] !== "[ ] ", c = c.replace(/^\[[ xX]\] +/, ""))), o.items.push({
314
+ type: "list_item",
315
+ raw: a,
316
+ task: !!P,
317
+ checked: Z,
318
+ loose: !1,
319
+ text: c,
320
+ tokens: []
321
+ }), o.raw += a;
322
+ }
323
+ o.items[o.items.length - 1].raw = a.trimEnd(), o.items[o.items.length - 1].text = c.trimEnd(), o.raw = o.raw.trimEnd();
324
+ for (let h = 0; h < o.items.length; h++)
325
+ if (this.lexer.state.top = !1, o.items[h].tokens = this.lexer.blockTokens(o.items[h].text, []), !o.loose) {
326
+ const m = o.items[h].tokens.filter((T) => T.type === "space"), g = m.length > 0 && m.some((T) => /\n.*\n/.test(T.raw));
327
+ o.loose = g;
328
+ }
329
+ if (o.loose)
330
+ for (let h = 0; h < o.items.length; h++)
331
+ o.items[h].loose = !0;
332
+ return o;
333
+ }
334
+ }
335
+ html(e) {
336
+ const t = this.rules.block.html.exec(e);
337
+ if (t)
338
+ return {
339
+ type: "html",
340
+ block: !0,
341
+ raw: t[0],
342
+ pre: t[1] === "pre" || t[1] === "script" || t[1] === "style",
343
+ text: t[0]
344
+ };
345
+ }
346
+ def(e) {
347
+ const t = this.rules.block.def.exec(e);
348
+ if (t) {
349
+ const n = t[1].toLowerCase().replace(/\s+/g, " "), r = t[2] ? t[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", o = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
350
+ return {
351
+ type: "def",
352
+ tag: n,
353
+ raw: t[0],
354
+ href: r,
355
+ title: o
356
+ };
357
+ }
358
+ }
359
+ table(e) {
360
+ const t = this.rules.block.table.exec(e);
361
+ if (!t || !/[:|]/.test(t[2]))
362
+ return;
363
+ const n = Qt(t[1]), r = t[2].replace(/^\||\| *$/g, "").split("|"), o = t[3] && t[3].trim() ? t[3].replace(/\n[ \t]*$/, "").split(`
364
+ `) : [], i = {
365
+ type: "table",
366
+ raw: t[0],
367
+ header: [],
368
+ align: [],
369
+ rows: []
370
+ };
371
+ if (n.length === r.length) {
372
+ for (const a of r)
373
+ /^ *-+: *$/.test(a) ? i.align.push("right") : /^ *:-+: *$/.test(a) ? i.align.push("center") : /^ *:-+ *$/.test(a) ? i.align.push("left") : i.align.push(null);
374
+ for (const a of n)
375
+ i.header.push({
376
+ text: a,
377
+ tokens: this.lexer.inline(a)
378
+ });
379
+ for (const a of o)
380
+ i.rows.push(Qt(a, i.header.length).map((c) => ({
381
+ text: c,
382
+ tokens: this.lexer.inline(c)
383
+ })));
384
+ return i;
385
+ }
386
+ }
387
+ lheading(e) {
388
+ const t = this.rules.block.lheading.exec(e);
389
+ if (t)
390
+ return {
391
+ type: "heading",
392
+ raw: t[0],
393
+ depth: t[2].charAt(0) === "=" ? 1 : 2,
394
+ text: t[1],
395
+ tokens: this.lexer.inline(t[1])
396
+ };
397
+ }
398
+ paragraph(e) {
399
+ const t = this.rules.block.paragraph.exec(e);
400
+ if (t) {
401
+ const n = t[1].charAt(t[1].length - 1) === `
402
+ ` ? t[1].slice(0, -1) : t[1];
403
+ return {
404
+ type: "paragraph",
405
+ raw: t[0],
406
+ text: n,
407
+ tokens: this.lexer.inline(n)
408
+ };
409
+ }
410
+ }
411
+ text(e) {
412
+ const t = this.rules.block.text.exec(e);
413
+ if (t)
414
+ return {
415
+ type: "text",
416
+ raw: t[0],
417
+ text: t[0],
418
+ tokens: this.lexer.inline(t[0])
419
+ };
420
+ }
421
+ escape(e) {
422
+ const t = this.rules.inline.escape.exec(e);
423
+ if (t)
424
+ return {
425
+ type: "escape",
426
+ raw: t[0],
427
+ text: $(t[1])
428
+ };
429
+ }
430
+ tag(e) {
431
+ const t = this.rules.inline.tag.exec(e);
432
+ if (t)
433
+ return !this.lexer.state.inLink && /^<a /i.test(t[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && /^<\/a>/i.test(t[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(t[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0]) && (this.lexer.state.inRawBlock = !1), {
434
+ type: "html",
435
+ raw: t[0],
436
+ inLink: this.lexer.state.inLink,
437
+ inRawBlock: this.lexer.state.inRawBlock,
438
+ block: !1,
439
+ text: t[0]
440
+ };
441
+ }
442
+ link(e) {
443
+ const t = this.rules.inline.link.exec(e);
444
+ if (t) {
445
+ const n = t[2].trim();
446
+ if (!this.options.pedantic && /^</.test(n)) {
447
+ if (!/>$/.test(n))
448
+ return;
449
+ const i = Me(n.slice(0, -1), "\\");
450
+ if ((n.length - i.length) % 2 === 0)
451
+ return;
452
+ } else {
453
+ const i = Xn(t[2], "()");
454
+ if (i > -1) {
455
+ const c = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
456
+ t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, c).trim(), t[3] = "";
457
+ }
458
+ }
459
+ let r = t[2], o = "";
460
+ if (this.options.pedantic) {
461
+ const i = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(r);
462
+ i && (r = i[1], o = i[3]);
463
+ } else
464
+ o = t[3] ? t[3].slice(1, -1) : "";
465
+ return r = r.trim(), /^</.test(r) && (this.options.pedantic && !/>$/.test(n) ? r = r.slice(1) : r = r.slice(1, -1)), Vt(t, {
466
+ href: r && r.replace(this.rules.inline.anyPunctuation, "$1"),
467
+ title: o && o.replace(this.rules.inline.anyPunctuation, "$1")
468
+ }, t[0], this.lexer);
469
+ }
470
+ }
471
+ reflink(e, t) {
472
+ let n;
473
+ if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
474
+ const r = (n[2] || n[1]).replace(/\s+/g, " "), o = t[r.toLowerCase()];
475
+ if (!o) {
476
+ const i = n[0].charAt(0);
477
+ return {
478
+ type: "text",
479
+ raw: i,
480
+ text: i
481
+ };
482
+ }
483
+ return Vt(n, o, n[0], this.lexer);
484
+ }
485
+ }
486
+ emStrong(e, t, n = "") {
487
+ let r = this.rules.inline.emStrongLDelim.exec(e);
488
+ if (!r || r[3] && n.match(/[\p{L}\p{N}]/u))
489
+ return;
490
+ if (!(r[1] || r[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
491
+ const i = [...r[0]].length - 1;
492
+ let a, c, d = i, h = 0;
493
+ const m = r[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
494
+ for (m.lastIndex = 0, t = t.slice(-1 * e.length + i); (r = m.exec(t)) != null; ) {
495
+ if (a = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !a)
496
+ continue;
497
+ if (c = [...a].length, r[3] || r[4]) {
498
+ d += c;
499
+ continue;
500
+ } else if ((r[5] || r[6]) && i % 3 && !((i + c) % 3)) {
501
+ h += c;
502
+ continue;
503
+ }
504
+ if (d -= c, d > 0)
505
+ continue;
506
+ c = Math.min(c, c + d + h);
507
+ const g = [...r[0]][0].length, T = e.slice(0, i + r.index + g + c);
508
+ if (Math.min(i, c) % 2) {
509
+ const P = T.slice(1, -1);
510
+ return {
511
+ type: "em",
512
+ raw: T,
513
+ text: P,
514
+ tokens: this.lexer.inlineTokens(P)
515
+ };
516
+ }
517
+ const v = T.slice(2, -2);
518
+ return {
519
+ type: "strong",
520
+ raw: T,
521
+ text: v,
522
+ tokens: this.lexer.inlineTokens(v)
523
+ };
524
+ }
525
+ }
526
+ }
527
+ codespan(e) {
528
+ const t = this.rules.inline.code.exec(e);
529
+ if (t) {
530
+ let n = t[2].replace(/\n/g, " ");
531
+ const r = /[^ ]/.test(n), o = /^ /.test(n) && / $/.test(n);
532
+ return r && o && (n = n.substring(1, n.length - 1)), n = $(n, !0), {
533
+ type: "codespan",
534
+ raw: t[0],
535
+ text: n
536
+ };
537
+ }
538
+ }
539
+ br(e) {
540
+ const t = this.rules.inline.br.exec(e);
541
+ if (t)
542
+ return {
543
+ type: "br",
544
+ raw: t[0]
545
+ };
546
+ }
547
+ del(e) {
548
+ const t = this.rules.inline.del.exec(e);
549
+ if (t)
550
+ return {
551
+ type: "del",
552
+ raw: t[0],
553
+ text: t[2],
554
+ tokens: this.lexer.inlineTokens(t[2])
555
+ };
556
+ }
557
+ autolink(e) {
558
+ const t = this.rules.inline.autolink.exec(e);
559
+ if (t) {
560
+ let n, r;
561
+ return t[2] === "@" ? (n = $(t[1]), r = "mailto:" + n) : (n = $(t[1]), r = n), {
562
+ type: "link",
563
+ raw: t[0],
564
+ text: n,
565
+ href: r,
566
+ tokens: [
567
+ {
568
+ type: "text",
569
+ raw: n,
570
+ text: n
571
+ }
572
+ ]
573
+ };
574
+ }
575
+ }
576
+ url(e) {
577
+ var n;
578
+ let t;
579
+ if (t = this.rules.inline.url.exec(e)) {
580
+ let r, o;
581
+ if (t[2] === "@")
582
+ r = $(t[0]), o = "mailto:" + r;
583
+ else {
584
+ let i;
585
+ do
586
+ i = t[0], t[0] = ((n = this.rules.inline._backpedal.exec(t[0])) == null ? void 0 : n[0]) ?? "";
587
+ while (i !== t[0]);
588
+ r = $(t[0]), t[1] === "www." ? o = "http://" + t[0] : o = t[0];
589
+ }
590
+ return {
591
+ type: "link",
592
+ raw: t[0],
593
+ text: r,
594
+ href: o,
595
+ tokens: [
596
+ {
597
+ type: "text",
598
+ raw: r,
599
+ text: r
600
+ }
601
+ ]
602
+ };
603
+ }
604
+ }
605
+ inlineText(e) {
606
+ const t = this.rules.inline.text.exec(e);
607
+ if (t) {
608
+ let n;
609
+ return this.lexer.state.inRawBlock ? n = t[0] : n = $(t[0]), {
610
+ type: "text",
611
+ raw: t[0],
612
+ text: n
613
+ };
614
+ }
615
+ }
616
+ }
617
+ const Vn = /^(?: *(?:\n|$))+/, Kn = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, Jn = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, _e = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, ei = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, pn = /(?:[*+-]|\d{1,9}[.)])/, hn = w(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, pn).getRegex(), mt = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, ti = /^[^\n]+/, kt = /(?!\s*\])(?:\\.|[^\[\]\\])+/, ni = w(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", kt).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), ii = w(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, pn).getRegex(), He = "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|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", Tt = /<!--(?!-?>)[\s\S]*?(?:-->|$)/, si = w("^ {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", Tt).replace("tag", He).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), fn = w(mt).replace("hr", _e).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", He).getRegex(), ri = w(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", fn).getRegex(), bt = {
618
+ blockquote: ri,
619
+ code: Kn,
620
+ def: ni,
621
+ fences: Jn,
622
+ heading: ei,
623
+ hr: _e,
624
+ html: si,
625
+ lheading: hn,
626
+ list: ii,
627
+ newline: Vn,
628
+ paragraph: fn,
629
+ table: xe,
630
+ text: ti
631
+ }, Kt = w("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", _e).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", He).getRegex(), oi = {
632
+ ...bt,
633
+ table: Kt,
634
+ paragraph: w(mt).replace("hr", _e).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", Kt).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", He).getRegex()
635
+ }, li = {
636
+ ...bt,
637
+ html: w(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", Tt).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(),
638
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
639
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
640
+ fences: xe,
641
+ // fences not supported
642
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
643
+ paragraph: w(mt).replace("hr", _e).replace("heading", ` *#{1,6} *[^
644
+ ]`).replace("lheading", hn).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
645
+ }, dn = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, ai = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, gn = /^( {2,}|\\)\n(?!\s*$)/, ci = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, Ee = "\\p{P}$+<=>`^|~", ui = w(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, Ee).getRegex(), pi = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g, hi = w(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, Ee).getRegex(), fi = w("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, Ee).getRegex(), di = w("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, Ee).getRegex(), gi = w(/\\([punct])/, "gu").replace(/punct/g, Ee).getRegex(), mi = w(/^<(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(), ki = w(Tt).replace("(?:-->|$)", "-->").getRegex(), Ti = w("^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", ki).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Ue = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, bi = w(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", Ue).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), mn = w(/^!?\[(label)\]\[(ref)\]/).replace("label", Ue).replace("ref", kt).getRegex(), kn = w(/^!?\[(ref)\](?:\[\])?/).replace("ref", kt).getRegex(), xi = w("reflink|nolink(?!\\()", "g").replace("reflink", mn).replace("nolink", kn).getRegex(), xt = {
646
+ _backpedal: xe,
647
+ // only used for GFM url
648
+ anyPunctuation: gi,
649
+ autolink: mi,
650
+ blockSkip: pi,
651
+ br: gn,
652
+ code: ai,
653
+ del: xe,
654
+ emStrongLDelim: hi,
655
+ emStrongRDelimAst: fi,
656
+ emStrongRDelimUnd: di,
657
+ escape: dn,
658
+ link: bi,
659
+ nolink: kn,
660
+ punctuation: ui,
661
+ reflink: mn,
662
+ reflinkSearch: xi,
663
+ tag: Ti,
664
+ text: ci,
665
+ url: xe
666
+ }, wi = {
667
+ ...xt,
668
+ link: w(/^!?\[(label)\]\((.*?)\)/).replace("label", Ue).getRegex(),
669
+ reflink: w(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", Ue).getRegex()
670
+ }, ut = {
671
+ ...xt,
672
+ escape: w(dn).replace("])", "~|])").getRegex(),
673
+ url: w(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
674
+ _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
675
+ del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
676
+ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
677
+ }, _i = {
678
+ ...ut,
679
+ br: w(gn).replace("{2,}", "*").getRegex(),
680
+ text: w(ut.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
681
+ }, Ne = {
682
+ normal: bt,
683
+ gfm: oi,
684
+ pedantic: li
685
+ }, de = {
686
+ normal: xt,
687
+ gfm: ut,
688
+ breaks: _i,
689
+ pedantic: wi
690
+ };
691
+ class W {
692
+ constructor(e) {
693
+ b(this, "tokens");
694
+ b(this, "options");
695
+ b(this, "state");
696
+ b(this, "tokenizer");
697
+ b(this, "inlineQueue");
698
+ this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || ne, this.options.tokenizer = this.options.tokenizer || new $e(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
699
+ inLink: !1,
700
+ inRawBlock: !1,
701
+ top: !0
702
+ };
703
+ const t = {
704
+ block: Ne.normal,
705
+ inline: de.normal
706
+ };
707
+ this.options.pedantic ? (t.block = Ne.pedantic, t.inline = de.pedantic) : this.options.gfm && (t.block = Ne.gfm, this.options.breaks ? t.inline = de.breaks : t.inline = de.gfm), this.tokenizer.rules = t;
708
+ }
709
+ /**
710
+ * Expose Rules
711
+ */
712
+ static get rules() {
713
+ return {
714
+ block: Ne,
715
+ inline: de
716
+ };
717
+ }
718
+ /**
719
+ * Static Lex Method
720
+ */
721
+ static lex(e, t) {
722
+ return new W(t).lex(e);
723
+ }
724
+ /**
725
+ * Static Lex Inline Method
726
+ */
727
+ static lexInline(e, t) {
728
+ return new W(t).inlineTokens(e);
729
+ }
730
+ /**
731
+ * Preprocessing
732
+ */
733
+ lex(e) {
734
+ e = e.replace(/\r\n|\r/g, `
735
+ `), this.blockTokens(e, this.tokens);
736
+ for (let t = 0; t < this.inlineQueue.length; t++) {
737
+ const n = this.inlineQueue[t];
738
+ this.inlineTokens(n.src, n.tokens);
739
+ }
740
+ return this.inlineQueue = [], this.tokens;
741
+ }
742
+ blockTokens(e, t = []) {
743
+ this.options.pedantic ? e = e.replace(/\t/g, " ").replace(/^ +$/gm, "") : e = e.replace(/^( *)(\t+)/gm, (a, c, d) => c + " ".repeat(d.length));
744
+ let n, r, o, i;
745
+ for (; e; )
746
+ if (!(this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((a) => (n = a.call({ lexer: this }, e, t)) ? (e = e.substring(n.raw.length), t.push(n), !0) : !1))) {
747
+ if (n = this.tokenizer.space(e)) {
748
+ e = e.substring(n.raw.length), n.raw.length === 1 && t.length > 0 ? t[t.length - 1].raw += `
749
+ ` : t.push(n);
750
+ continue;
751
+ }
752
+ if (n = this.tokenizer.code(e)) {
753
+ e = e.substring(n.raw.length), r = t[t.length - 1], r && (r.type === "paragraph" || r.type === "text") ? (r.raw += `
754
+ ` + n.raw, r.text += `
755
+ ` + n.text, this.inlineQueue[this.inlineQueue.length - 1].src = r.text) : t.push(n);
756
+ continue;
757
+ }
758
+ if (n = this.tokenizer.fences(e)) {
759
+ e = e.substring(n.raw.length), t.push(n);
760
+ continue;
761
+ }
762
+ if (n = this.tokenizer.heading(e)) {
763
+ e = e.substring(n.raw.length), t.push(n);
764
+ continue;
765
+ }
766
+ if (n = this.tokenizer.hr(e)) {
767
+ e = e.substring(n.raw.length), t.push(n);
768
+ continue;
769
+ }
770
+ if (n = this.tokenizer.blockquote(e)) {
771
+ e = e.substring(n.raw.length), t.push(n);
772
+ continue;
773
+ }
774
+ if (n = this.tokenizer.list(e)) {
775
+ e = e.substring(n.raw.length), t.push(n);
776
+ continue;
777
+ }
778
+ if (n = this.tokenizer.html(e)) {
779
+ e = e.substring(n.raw.length), t.push(n);
780
+ continue;
781
+ }
782
+ if (n = this.tokenizer.def(e)) {
783
+ e = e.substring(n.raw.length), r = t[t.length - 1], r && (r.type === "paragraph" || r.type === "text") ? (r.raw += `
784
+ ` + n.raw, r.text += `
785
+ ` + n.raw, this.inlineQueue[this.inlineQueue.length - 1].src = r.text) : this.tokens.links[n.tag] || (this.tokens.links[n.tag] = {
786
+ href: n.href,
787
+ title: n.title
788
+ });
789
+ continue;
790
+ }
791
+ if (n = this.tokenizer.table(e)) {
792
+ e = e.substring(n.raw.length), t.push(n);
793
+ continue;
794
+ }
795
+ if (n = this.tokenizer.lheading(e)) {
796
+ e = e.substring(n.raw.length), t.push(n);
797
+ continue;
798
+ }
799
+ if (o = e, this.options.extensions && this.options.extensions.startBlock) {
800
+ let a = 1 / 0;
801
+ const c = e.slice(1);
802
+ let d;
803
+ this.options.extensions.startBlock.forEach((h) => {
804
+ d = h.call({ lexer: this }, c), typeof d == "number" && d >= 0 && (a = Math.min(a, d));
805
+ }), a < 1 / 0 && a >= 0 && (o = e.substring(0, a + 1));
806
+ }
807
+ if (this.state.top && (n = this.tokenizer.paragraph(o))) {
808
+ r = t[t.length - 1], i && r.type === "paragraph" ? (r.raw += `
809
+ ` + n.raw, r.text += `
810
+ ` + n.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = r.text) : t.push(n), i = o.length !== e.length, e = e.substring(n.raw.length);
811
+ continue;
812
+ }
813
+ if (n = this.tokenizer.text(e)) {
814
+ e = e.substring(n.raw.length), r = t[t.length - 1], r && r.type === "text" ? (r.raw += `
815
+ ` + n.raw, r.text += `
816
+ ` + n.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = r.text) : t.push(n);
817
+ continue;
818
+ }
819
+ if (e) {
820
+ const a = "Infinite loop on byte: " + e.charCodeAt(0);
821
+ if (this.options.silent) {
822
+ console.error(a);
823
+ break;
824
+ } else
825
+ throw new Error(a);
826
+ }
827
+ }
828
+ return this.state.top = !0, t;
829
+ }
830
+ inline(e, t = []) {
831
+ return this.inlineQueue.push({ src: e, tokens: t }), t;
832
+ }
833
+ /**
834
+ * Lexing/Compiling
835
+ */
836
+ inlineTokens(e, t = []) {
837
+ let n, r, o, i = e, a, c, d;
838
+ if (this.tokens.links) {
839
+ const h = Object.keys(this.tokens.links);
840
+ if (h.length > 0)
841
+ for (; (a = this.tokenizer.rules.inline.reflinkSearch.exec(i)) != null; )
842
+ h.includes(a[0].slice(a[0].lastIndexOf("[") + 1, -1)) && (i = i.slice(0, a.index) + "[" + "a".repeat(a[0].length - 2) + "]" + i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
843
+ }
844
+ for (; (a = this.tokenizer.rules.inline.blockSkip.exec(i)) != null; )
845
+ i = i.slice(0, a.index) + "[" + "a".repeat(a[0].length - 2) + "]" + i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
846
+ for (; (a = this.tokenizer.rules.inline.anyPunctuation.exec(i)) != null; )
847
+ i = i.slice(0, a.index) + "++" + i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
848
+ for (; e; )
849
+ if (c || (d = ""), c = !1, !(this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((h) => (n = h.call({ lexer: this }, e, t)) ? (e = e.substring(n.raw.length), t.push(n), !0) : !1))) {
850
+ if (n = this.tokenizer.escape(e)) {
851
+ e = e.substring(n.raw.length), t.push(n);
852
+ continue;
853
+ }
854
+ if (n = this.tokenizer.tag(e)) {
855
+ e = e.substring(n.raw.length), r = t[t.length - 1], r && n.type === "text" && r.type === "text" ? (r.raw += n.raw, r.text += n.text) : t.push(n);
856
+ continue;
857
+ }
858
+ if (n = this.tokenizer.link(e)) {
859
+ e = e.substring(n.raw.length), t.push(n);
860
+ continue;
861
+ }
862
+ if (n = this.tokenizer.reflink(e, this.tokens.links)) {
863
+ e = e.substring(n.raw.length), r = t[t.length - 1], r && n.type === "text" && r.type === "text" ? (r.raw += n.raw, r.text += n.text) : t.push(n);
864
+ continue;
865
+ }
866
+ if (n = this.tokenizer.emStrong(e, i, d)) {
867
+ e = e.substring(n.raw.length), t.push(n);
868
+ continue;
869
+ }
870
+ if (n = this.tokenizer.codespan(e)) {
871
+ e = e.substring(n.raw.length), t.push(n);
872
+ continue;
873
+ }
874
+ if (n = this.tokenizer.br(e)) {
875
+ e = e.substring(n.raw.length), t.push(n);
876
+ continue;
877
+ }
878
+ if (n = this.tokenizer.del(e)) {
879
+ e = e.substring(n.raw.length), t.push(n);
880
+ continue;
881
+ }
882
+ if (n = this.tokenizer.autolink(e)) {
883
+ e = e.substring(n.raw.length), t.push(n);
884
+ continue;
885
+ }
886
+ if (!this.state.inLink && (n = this.tokenizer.url(e))) {
887
+ e = e.substring(n.raw.length), t.push(n);
888
+ continue;
889
+ }
890
+ if (o = e, this.options.extensions && this.options.extensions.startInline) {
891
+ let h = 1 / 0;
892
+ const m = e.slice(1);
893
+ let g;
894
+ this.options.extensions.startInline.forEach((T) => {
895
+ g = T.call({ lexer: this }, m), typeof g == "number" && g >= 0 && (h = Math.min(h, g));
896
+ }), h < 1 / 0 && h >= 0 && (o = e.substring(0, h + 1));
897
+ }
898
+ if (n = this.tokenizer.inlineText(o)) {
899
+ e = e.substring(n.raw.length), n.raw.slice(-1) !== "_" && (d = n.raw.slice(-1)), c = !0, r = t[t.length - 1], r && r.type === "text" ? (r.raw += n.raw, r.text += n.text) : t.push(n);
900
+ continue;
901
+ }
902
+ if (e) {
903
+ const h = "Infinite loop on byte: " + e.charCodeAt(0);
904
+ if (this.options.silent) {
905
+ console.error(h);
906
+ break;
907
+ } else
908
+ throw new Error(h);
909
+ }
910
+ }
911
+ return t;
912
+ }
913
+ }
914
+ class Fe {
915
+ constructor(e) {
916
+ b(this, "options");
917
+ this.options = e || ne;
918
+ }
919
+ code(e, t, n) {
920
+ var o;
921
+ const r = (o = (t || "").match(/^\S*/)) == null ? void 0 : o[0];
922
+ return e = e.replace(/\n$/, "") + `
923
+ `, r ? '<pre><code class="language-' + $(r) + '">' + (n ? e : $(e, !0)) + `</code></pre>
924
+ ` : "<pre><code>" + (n ? e : $(e, !0)) + `</code></pre>
925
+ `;
926
+ }
927
+ blockquote(e) {
928
+ return `<blockquote>
929
+ ${e}</blockquote>
930
+ `;
931
+ }
932
+ html(e, t) {
933
+ return e;
934
+ }
935
+ heading(e, t, n) {
936
+ return `<h${t}>${e}</h${t}>
937
+ `;
938
+ }
939
+ hr() {
940
+ return `<hr>
941
+ `;
942
+ }
943
+ list(e, t, n) {
944
+ const r = t ? "ol" : "ul", o = t && n !== 1 ? ' start="' + n + '"' : "";
945
+ return "<" + r + o + `>
946
+ ` + e + "</" + r + `>
947
+ `;
948
+ }
949
+ listitem(e, t, n) {
950
+ return `<li>${e}</li>
951
+ `;
952
+ }
953
+ checkbox(e) {
954
+ return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
955
+ }
956
+ paragraph(e) {
957
+ return `<p>${e}</p>
958
+ `;
959
+ }
960
+ table(e, t) {
961
+ return t && (t = `<tbody>${t}</tbody>`), `<table>
962
+ <thead>
963
+ ` + e + `</thead>
964
+ ` + t + `</table>
965
+ `;
966
+ }
967
+ tablerow(e) {
968
+ return `<tr>
969
+ ${e}</tr>
970
+ `;
971
+ }
972
+ tablecell(e, t) {
973
+ const n = t.header ? "th" : "td";
974
+ return (t.align ? `<${n} align="${t.align}">` : `<${n}>`) + e + `</${n}>
975
+ `;
976
+ }
977
+ /**
978
+ * span level renderer
979
+ */
980
+ strong(e) {
981
+ return `<strong>${e}</strong>`;
982
+ }
983
+ em(e) {
984
+ return `<em>${e}</em>`;
985
+ }
986
+ codespan(e) {
987
+ return `<code>${e}</code>`;
988
+ }
989
+ br() {
990
+ return "<br>";
991
+ }
992
+ del(e) {
993
+ return `<del>${e}</del>`;
994
+ }
995
+ link(e, t, n) {
996
+ const r = Xt(e);
997
+ if (r === null)
998
+ return n;
999
+ e = r;
1000
+ let o = '<a href="' + e + '"';
1001
+ return t && (o += ' title="' + t + '"'), o += ">" + n + "</a>", o;
1002
+ }
1003
+ image(e, t, n) {
1004
+ const r = Xt(e);
1005
+ if (r === null)
1006
+ return n;
1007
+ e = r;
1008
+ let o = `<img src="${e}" alt="${n}"`;
1009
+ return t && (o += ` title="${t}"`), o += ">", o;
1010
+ }
1011
+ text(e) {
1012
+ return e;
1013
+ }
1014
+ }
1015
+ class wt {
1016
+ // no need for block level renderers
1017
+ strong(e) {
1018
+ return e;
1019
+ }
1020
+ em(e) {
1021
+ return e;
1022
+ }
1023
+ codespan(e) {
1024
+ return e;
1025
+ }
1026
+ del(e) {
1027
+ return e;
1028
+ }
1029
+ html(e) {
1030
+ return e;
1031
+ }
1032
+ text(e) {
1033
+ return e;
1034
+ }
1035
+ link(e, t, n) {
1036
+ return "" + n;
1037
+ }
1038
+ image(e, t, n) {
1039
+ return "" + n;
1040
+ }
1041
+ br() {
1042
+ return "";
1043
+ }
1044
+ }
1045
+ class q {
1046
+ constructor(e) {
1047
+ b(this, "options");
1048
+ b(this, "renderer");
1049
+ b(this, "textRenderer");
1050
+ this.options = e || ne, this.options.renderer = this.options.renderer || new Fe(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.textRenderer = new wt();
1051
+ }
1052
+ /**
1053
+ * Static Parse Method
1054
+ */
1055
+ static parse(e, t) {
1056
+ return new q(t).parse(e);
1057
+ }
1058
+ /**
1059
+ * Static Parse Inline Method
1060
+ */
1061
+ static parseInline(e, t) {
1062
+ return new q(t).parseInline(e);
1063
+ }
1064
+ /**
1065
+ * Parse Loop
1066
+ */
1067
+ parse(e, t = !0) {
1068
+ let n = "";
1069
+ for (let r = 0; r < e.length; r++) {
1070
+ const o = e[r];
1071
+ if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[o.type]) {
1072
+ const i = o, a = this.options.extensions.renderers[i.type].call({ parser: this }, i);
1073
+ if (a !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(i.type)) {
1074
+ n += a || "";
1075
+ continue;
1076
+ }
1077
+ }
1078
+ switch (o.type) {
1079
+ case "space":
1080
+ continue;
1081
+ case "hr": {
1082
+ n += this.renderer.hr();
1083
+ continue;
1084
+ }
1085
+ case "heading": {
1086
+ const i = o;
1087
+ n += this.renderer.heading(this.parseInline(i.tokens), i.depth, Yn(this.parseInline(i.tokens, this.textRenderer)));
1088
+ continue;
1089
+ }
1090
+ case "code": {
1091
+ const i = o;
1092
+ n += this.renderer.code(i.text, i.lang, !!i.escaped);
1093
+ continue;
1094
+ }
1095
+ case "table": {
1096
+ const i = o;
1097
+ let a = "", c = "";
1098
+ for (let h = 0; h < i.header.length; h++)
1099
+ c += this.renderer.tablecell(this.parseInline(i.header[h].tokens), { header: !0, align: i.align[h] });
1100
+ a += this.renderer.tablerow(c);
1101
+ let d = "";
1102
+ for (let h = 0; h < i.rows.length; h++) {
1103
+ const m = i.rows[h];
1104
+ c = "";
1105
+ for (let g = 0; g < m.length; g++)
1106
+ c += this.renderer.tablecell(this.parseInline(m[g].tokens), { header: !1, align: i.align[g] });
1107
+ d += this.renderer.tablerow(c);
1108
+ }
1109
+ n += this.renderer.table(a, d);
1110
+ continue;
1111
+ }
1112
+ case "blockquote": {
1113
+ const i = o, a = this.parse(i.tokens);
1114
+ n += this.renderer.blockquote(a);
1115
+ continue;
1116
+ }
1117
+ case "list": {
1118
+ const i = o, a = i.ordered, c = i.start, d = i.loose;
1119
+ let h = "";
1120
+ for (let m = 0; m < i.items.length; m++) {
1121
+ const g = i.items[m], T = g.checked, v = g.task;
1122
+ let P = "";
1123
+ if (g.task) {
1124
+ const Z = this.renderer.checkbox(!!T);
1125
+ d ? g.tokens.length > 0 && g.tokens[0].type === "paragraph" ? (g.tokens[0].text = Z + " " + g.tokens[0].text, g.tokens[0].tokens && g.tokens[0].tokens.length > 0 && g.tokens[0].tokens[0].type === "text" && (g.tokens[0].tokens[0].text = Z + " " + g.tokens[0].tokens[0].text)) : g.tokens.unshift({
1126
+ type: "text",
1127
+ text: Z + " "
1128
+ }) : P += Z + " ";
1129
+ }
1130
+ P += this.parse(g.tokens, d), h += this.renderer.listitem(P, v, !!T);
1131
+ }
1132
+ n += this.renderer.list(h, a, c);
1133
+ continue;
1134
+ }
1135
+ case "html": {
1136
+ const i = o;
1137
+ n += this.renderer.html(i.text, i.block);
1138
+ continue;
1139
+ }
1140
+ case "paragraph": {
1141
+ const i = o;
1142
+ n += this.renderer.paragraph(this.parseInline(i.tokens));
1143
+ continue;
1144
+ }
1145
+ case "text": {
1146
+ let i = o, a = i.tokens ? this.parseInline(i.tokens) : i.text;
1147
+ for (; r + 1 < e.length && e[r + 1].type === "text"; )
1148
+ i = e[++r], a += `
1149
+ ` + (i.tokens ? this.parseInline(i.tokens) : i.text);
1150
+ n += t ? this.renderer.paragraph(a) : a;
1151
+ continue;
1152
+ }
1153
+ default: {
1154
+ const i = 'Token with "' + o.type + '" type was not found.';
1155
+ if (this.options.silent)
1156
+ return console.error(i), "";
1157
+ throw new Error(i);
1158
+ }
1159
+ }
1160
+ }
1161
+ return n;
1162
+ }
1163
+ /**
1164
+ * Parse Inline Tokens
1165
+ */
1166
+ parseInline(e, t) {
1167
+ t = t || this.renderer;
1168
+ let n = "";
1169
+ for (let r = 0; r < e.length; r++) {
1170
+ const o = e[r];
1171
+ if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[o.type]) {
1172
+ const i = this.options.extensions.renderers[o.type].call({ parser: this }, o);
1173
+ if (i !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(o.type)) {
1174
+ n += i || "";
1175
+ continue;
1176
+ }
1177
+ }
1178
+ switch (o.type) {
1179
+ case "escape": {
1180
+ const i = o;
1181
+ n += t.text(i.text);
1182
+ break;
1183
+ }
1184
+ case "html": {
1185
+ const i = o;
1186
+ n += t.html(i.text);
1187
+ break;
1188
+ }
1189
+ case "link": {
1190
+ const i = o;
1191
+ n += t.link(i.href, i.title, this.parseInline(i.tokens, t));
1192
+ break;
1193
+ }
1194
+ case "image": {
1195
+ const i = o;
1196
+ n += t.image(i.href, i.title, i.text);
1197
+ break;
1198
+ }
1199
+ case "strong": {
1200
+ const i = o;
1201
+ n += t.strong(this.parseInline(i.tokens, t));
1202
+ break;
1203
+ }
1204
+ case "em": {
1205
+ const i = o;
1206
+ n += t.em(this.parseInline(i.tokens, t));
1207
+ break;
1208
+ }
1209
+ case "codespan": {
1210
+ const i = o;
1211
+ n += t.codespan(i.text);
1212
+ break;
1213
+ }
1214
+ case "br": {
1215
+ n += t.br();
1216
+ break;
1217
+ }
1218
+ case "del": {
1219
+ const i = o;
1220
+ n += t.del(this.parseInline(i.tokens, t));
1221
+ break;
1222
+ }
1223
+ case "text": {
1224
+ const i = o;
1225
+ n += t.text(i.text);
1226
+ break;
1227
+ }
1228
+ default: {
1229
+ const i = 'Token with "' + o.type + '" type was not found.';
1230
+ if (this.options.silent)
1231
+ return console.error(i), "";
1232
+ throw new Error(i);
1233
+ }
1234
+ }
1235
+ }
1236
+ return n;
1237
+ }
1238
+ }
1239
+ class we {
1240
+ constructor(e) {
1241
+ b(this, "options");
1242
+ this.options = e || ne;
1243
+ }
1244
+ /**
1245
+ * Process markdown before marked
1246
+ */
1247
+ preprocess(e) {
1248
+ return e;
1249
+ }
1250
+ /**
1251
+ * Process HTML after marked is finished
1252
+ */
1253
+ postprocess(e) {
1254
+ return e;
1255
+ }
1256
+ /**
1257
+ * Process all tokens before walk tokens
1258
+ */
1259
+ processAllTokens(e) {
1260
+ return e;
1261
+ }
1262
+ }
1263
+ b(we, "passThroughHooks", /* @__PURE__ */ new Set([
1264
+ "preprocess",
1265
+ "postprocess",
1266
+ "processAllTokens"
1267
+ ]));
1268
+ var te, pt, Tn;
1269
+ class Ei {
1270
+ constructor(...e) {
1271
+ Yt(this, te);
1272
+ b(this, "defaults", gt());
1273
+ b(this, "options", this.setOptions);
1274
+ b(this, "parse", Ce(this, te, pt).call(this, W.lex, q.parse));
1275
+ b(this, "parseInline", Ce(this, te, pt).call(this, W.lexInline, q.parseInline));
1276
+ b(this, "Parser", q);
1277
+ b(this, "Renderer", Fe);
1278
+ b(this, "TextRenderer", wt);
1279
+ b(this, "Lexer", W);
1280
+ b(this, "Tokenizer", $e);
1281
+ b(this, "Hooks", we);
1282
+ this.use(...e);
1283
+ }
1284
+ /**
1285
+ * Run callback for every token
1286
+ */
1287
+ walkTokens(e, t) {
1288
+ var r, o;
1289
+ let n = [];
1290
+ for (const i of e)
1291
+ switch (n = n.concat(t.call(this, i)), i.type) {
1292
+ case "table": {
1293
+ const a = i;
1294
+ for (const c of a.header)
1295
+ n = n.concat(this.walkTokens(c.tokens, t));
1296
+ for (const c of a.rows)
1297
+ for (const d of c)
1298
+ n = n.concat(this.walkTokens(d.tokens, t));
1299
+ break;
1300
+ }
1301
+ case "list": {
1302
+ const a = i;
1303
+ n = n.concat(this.walkTokens(a.items, t));
1304
+ break;
1305
+ }
1306
+ default: {
1307
+ const a = i;
1308
+ (o = (r = this.defaults.extensions) == null ? void 0 : r.childTokens) != null && o[a.type] ? this.defaults.extensions.childTokens[a.type].forEach((c) => {
1309
+ const d = a[c].flat(1 / 0);
1310
+ n = n.concat(this.walkTokens(d, t));
1311
+ }) : a.tokens && (n = n.concat(this.walkTokens(a.tokens, t)));
1312
+ }
1313
+ }
1314
+ return n;
1315
+ }
1316
+ use(...e) {
1317
+ const t = this.defaults.extensions || { renderers: {}, childTokens: {} };
1318
+ return e.forEach((n) => {
1319
+ const r = { ...n };
1320
+ if (r.async = this.defaults.async || r.async || !1, n.extensions && (n.extensions.forEach((o) => {
1321
+ if (!o.name)
1322
+ throw new Error("extension name required");
1323
+ if ("renderer" in o) {
1324
+ const i = t.renderers[o.name];
1325
+ i ? t.renderers[o.name] = function(...a) {
1326
+ let c = o.renderer.apply(this, a);
1327
+ return c === !1 && (c = i.apply(this, a)), c;
1328
+ } : t.renderers[o.name] = o.renderer;
1329
+ }
1330
+ if ("tokenizer" in o) {
1331
+ if (!o.level || o.level !== "block" && o.level !== "inline")
1332
+ throw new Error("extension level must be 'block' or 'inline'");
1333
+ const i = t[o.level];
1334
+ i ? i.unshift(o.tokenizer) : t[o.level] = [o.tokenizer], o.start && (o.level === "block" ? t.startBlock ? t.startBlock.push(o.start) : t.startBlock = [o.start] : o.level === "inline" && (t.startInline ? t.startInline.push(o.start) : t.startInline = [o.start]));
1335
+ }
1336
+ "childTokens" in o && o.childTokens && (t.childTokens[o.name] = o.childTokens);
1337
+ }), r.extensions = t), n.renderer) {
1338
+ const o = this.defaults.renderer || new Fe(this.defaults);
1339
+ for (const i in n.renderer) {
1340
+ if (!(i in o))
1341
+ throw new Error(`renderer '${i}' does not exist`);
1342
+ if (i === "options")
1343
+ continue;
1344
+ const a = i, c = n.renderer[a], d = o[a];
1345
+ o[a] = (...h) => {
1346
+ let m = c.apply(o, h);
1347
+ return m === !1 && (m = d.apply(o, h)), m || "";
1348
+ };
1349
+ }
1350
+ r.renderer = o;
1351
+ }
1352
+ if (n.tokenizer) {
1353
+ const o = this.defaults.tokenizer || new $e(this.defaults);
1354
+ for (const i in n.tokenizer) {
1355
+ if (!(i in o))
1356
+ throw new Error(`tokenizer '${i}' does not exist`);
1357
+ if (["options", "rules", "lexer"].includes(i))
1358
+ continue;
1359
+ const a = i, c = n.tokenizer[a], d = o[a];
1360
+ o[a] = (...h) => {
1361
+ let m = c.apply(o, h);
1362
+ return m === !1 && (m = d.apply(o, h)), m;
1363
+ };
1364
+ }
1365
+ r.tokenizer = o;
1366
+ }
1367
+ if (n.hooks) {
1368
+ const o = this.defaults.hooks || new we();
1369
+ for (const i in n.hooks) {
1370
+ if (!(i in o))
1371
+ throw new Error(`hook '${i}' does not exist`);
1372
+ if (i === "options")
1373
+ continue;
1374
+ const a = i, c = n.hooks[a], d = o[a];
1375
+ we.passThroughHooks.has(i) ? o[a] = (h) => {
1376
+ if (this.defaults.async)
1377
+ return Promise.resolve(c.call(o, h)).then((g) => d.call(o, g));
1378
+ const m = c.call(o, h);
1379
+ return d.call(o, m);
1380
+ } : o[a] = (...h) => {
1381
+ let m = c.apply(o, h);
1382
+ return m === !1 && (m = d.apply(o, h)), m;
1383
+ };
1384
+ }
1385
+ r.hooks = o;
1386
+ }
1387
+ if (n.walkTokens) {
1388
+ const o = this.defaults.walkTokens, i = n.walkTokens;
1389
+ r.walkTokens = function(a) {
1390
+ let c = [];
1391
+ return c.push(i.call(this, a)), o && (c = c.concat(o.call(this, a))), c;
1392
+ };
1393
+ }
1394
+ this.defaults = { ...this.defaults, ...r };
1395
+ }), this;
1396
+ }
1397
+ setOptions(e) {
1398
+ return this.defaults = { ...this.defaults, ...e }, this;
1399
+ }
1400
+ lexer(e, t) {
1401
+ return W.lex(e, t ?? this.defaults);
1402
+ }
1403
+ parser(e, t) {
1404
+ return q.parse(e, t ?? this.defaults);
1405
+ }
1406
+ }
1407
+ te = new WeakSet(), pt = function(e, t) {
1408
+ return (n, r) => {
1409
+ const o = { ...r }, i = { ...this.defaults, ...o };
1410
+ this.defaults.async === !0 && o.async === !1 && (i.silent || console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."), i.async = !0);
1411
+ const a = Ce(this, te, Tn).call(this, !!i.silent, !!i.async);
1412
+ if (typeof n > "u" || n === null)
1413
+ return a(new Error("marked(): input parameter is undefined or null"));
1414
+ if (typeof n != "string")
1415
+ return a(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
1416
+ if (i.hooks && (i.hooks.options = i), i.async)
1417
+ return Promise.resolve(i.hooks ? i.hooks.preprocess(n) : n).then((c) => e(c, i)).then((c) => i.hooks ? i.hooks.processAllTokens(c) : c).then((c) => i.walkTokens ? Promise.all(this.walkTokens(c, i.walkTokens)).then(() => c) : c).then((c) => t(c, i)).then((c) => i.hooks ? i.hooks.postprocess(c) : c).catch(a);
1418
+ try {
1419
+ i.hooks && (n = i.hooks.preprocess(n));
1420
+ let c = e(n, i);
1421
+ i.hooks && (c = i.hooks.processAllTokens(c)), i.walkTokens && this.walkTokens(c, i.walkTokens);
1422
+ let d = t(c, i);
1423
+ return i.hooks && (d = i.hooks.postprocess(d)), d;
1424
+ } catch (c) {
1425
+ return a(c);
1426
+ }
1427
+ };
1428
+ }, Tn = function(e, t) {
1429
+ return (n) => {
1430
+ if (n.message += `
1431
+ Please report this to https://github.com/markedjs/marked.`, e) {
1432
+ const r = "<p>An error occurred:</p><pre>" + $(n.message + "", !0) + "</pre>";
1433
+ return t ? Promise.resolve(r) : r;
1434
+ }
1435
+ if (t)
1436
+ return Promise.reject(n);
1437
+ throw n;
1438
+ };
1439
+ };
1440
+ const ee = new Ei();
1441
+ function x(l, e) {
1442
+ return ee.parse(l, e);
1443
+ }
1444
+ x.options = x.setOptions = function(l) {
1445
+ return ee.setOptions(l), x.defaults = ee.defaults, an(x.defaults), x;
1446
+ };
1447
+ x.getDefaults = gt;
1448
+ x.defaults = ne;
1449
+ x.use = function(...l) {
1450
+ return ee.use(...l), x.defaults = ee.defaults, an(x.defaults), x;
1451
+ };
1452
+ x.walkTokens = function(l, e) {
1453
+ return ee.walkTokens(l, e);
1454
+ };
1455
+ x.parseInline = ee.parseInline;
1456
+ x.Parser = q;
1457
+ x.parser = q.parse;
1458
+ x.Renderer = Fe;
1459
+ x.TextRenderer = wt;
1460
+ x.Lexer = W;
1461
+ x.lexer = W.lex;
1462
+ x.Tokenizer = $e;
1463
+ x.Hooks = we;
1464
+ x.parse = x;
1465
+ x.options;
1466
+ x.setOptions;
1467
+ x.use;
1468
+ x.walkTokens;
1469
+ x.parseInline;
1470
+ q.parse;
1471
+ W.lex;
1472
+ /*! @license DOMPurify 3.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.1/LICENSE */
1473
+ const {
1474
+ entries: bn,
1475
+ setPrototypeOf: Jt,
1476
+ isFrozen: Ai,
1477
+ getPrototypeOf: yi,
1478
+ getOwnPropertyDescriptor: Si
1479
+ } = Object;
1480
+ let {
1481
+ freeze: M,
1482
+ seal: U,
1483
+ create: ht
1484
+ } = Object, {
1485
+ apply: ft,
1486
+ construct: dt
1487
+ } = typeof Reflect < "u" && Reflect;
1488
+ M || (M = function(e) {
1489
+ return e;
1490
+ });
1491
+ U || (U = function(e) {
1492
+ return e;
1493
+ });
1494
+ ft || (ft = function(e, t) {
1495
+ for (var n = arguments.length, r = new Array(n > 2 ? n - 2 : 0), o = 2; o < n; o++)
1496
+ r[o - 2] = arguments[o];
1497
+ return e.apply(t, r);
1498
+ });
1499
+ dt || (dt = function(e) {
1500
+ for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), r = 1; r < t; r++)
1501
+ n[r - 1] = arguments[r];
1502
+ return new e(...n);
1503
+ });
1504
+ const ve = N(Array.prototype.forEach), Ri = N(Array.prototype.lastIndexOf), en = N(Array.prototype.pop), ge = N(Array.prototype.push), Li = N(Array.prototype.splice), Pe = N(String.prototype.toLowerCase), st = N(String.prototype.toString), rt = N(String.prototype.match), me = N(String.prototype.replace), Ii = N(String.prototype.indexOf), Oi = N(String.prototype.trim), F = N(Object.prototype.hasOwnProperty), C = N(RegExp.prototype.test), ke = Di(TypeError);
1505
+ function N(l) {
1506
+ return function(e) {
1507
+ e instanceof RegExp && (e.lastIndex = 0);
1508
+ for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), r = 1; r < t; r++)
1509
+ n[r - 1] = arguments[r];
1510
+ return ft(l, e, n);
1511
+ };
1512
+ }
1513
+ function Di(l) {
1514
+ return function() {
1515
+ for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
1516
+ t[n] = arguments[n];
1517
+ return dt(l, t);
1518
+ };
1519
+ }
1520
+ function k(l, e) {
1521
+ let t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : Pe;
1522
+ Jt && Jt(l, null);
1523
+ let n = e.length;
1524
+ for (; n--; ) {
1525
+ let r = e[n];
1526
+ if (typeof r == "string") {
1527
+ const o = t(r);
1528
+ o !== r && (Ai(e) || (e[n] = o), r = o);
1529
+ }
1530
+ l[r] = !0;
1531
+ }
1532
+ return l;
1533
+ }
1534
+ function Ci(l) {
1535
+ for (let e = 0; e < l.length; e++)
1536
+ F(l, e) || (l[e] = null);
1537
+ return l;
1538
+ }
1539
+ function G(l) {
1540
+ const e = ht(null);
1541
+ for (const [t, n] of bn(l))
1542
+ F(l, t) && (Array.isArray(n) ? e[t] = Ci(n) : n && typeof n == "object" && n.constructor === Object ? e[t] = G(n) : e[t] = n);
1543
+ return e;
1544
+ }
1545
+ function Te(l, e) {
1546
+ for (; l !== null; ) {
1547
+ const n = Si(l, e);
1548
+ if (n) {
1549
+ if (n.get)
1550
+ return N(n.get);
1551
+ if (typeof n.value == "function")
1552
+ return N(n.value);
1553
+ }
1554
+ l = yi(l);
1555
+ }
1556
+ function t() {
1557
+ return null;
1558
+ }
1559
+ return t;
1560
+ }
1561
+ const tn = M(["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"]), ot = M(["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"]), lt = M(["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"]), Mi = M(["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"]), at = M(["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"]), Ni = M(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), nn = M(["#text"]), sn = M(["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"]), ct = M(["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"]), rn = M(["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"]), ze = M(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), vi = U(/\{\{[\w\W]*|[\w\W]*\}\}/gm), zi = U(/<%[\w\W]*|[\w\W]*%>/gm), Pi = U(/\$\{[\w\W]*/gm), $i = U(/^data-[\-\w.\u00B7-\uFFFF]+$/), Ui = U(/^aria-[\-\w]+$/), xn = U(
1562
+ /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
1563
+ // eslint-disable-line no-useless-escape
1564
+ ), Fi = U(/^(?:\w+script|data):/i), Hi = U(
1565
+ /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
1566
+ // eslint-disable-line no-control-regex
1567
+ ), wn = U(/^html$/i), Bi = U(/^[a-z][.\w]*(-[.\w]+)+$/i);
1568
+ var on = /* @__PURE__ */ Object.freeze({
1569
+ __proto__: null,
1570
+ ARIA_ATTR: Ui,
1571
+ ATTR_WHITESPACE: Hi,
1572
+ CUSTOM_ELEMENT: Bi,
1573
+ DATA_ATTR: $i,
1574
+ DOCTYPE_NAME: wn,
1575
+ ERB_EXPR: zi,
1576
+ IS_ALLOWED_URI: xn,
1577
+ IS_SCRIPT_OR_DATA: Fi,
1578
+ MUSTACHE_EXPR: vi,
1579
+ TMPLIT_EXPR: Pi
1580
+ });
1581
+ const be = {
1582
+ element: 1,
1583
+ text: 3,
1584
+ // Deprecated
1585
+ progressingInstruction: 7,
1586
+ comment: 8,
1587
+ document: 9
1588
+ }, Gi = function() {
1589
+ return typeof window > "u" ? null : window;
1590
+ }, Wi = function(e, t) {
1591
+ if (typeof e != "object" || typeof e.createPolicy != "function")
1592
+ return null;
1593
+ let n = null;
1594
+ const r = "data-tt-policy-suffix";
1595
+ t && t.hasAttribute(r) && (n = t.getAttribute(r));
1596
+ const o = "dompurify" + (n ? "#" + n : "");
1597
+ try {
1598
+ return e.createPolicy(o, {
1599
+ createHTML(i) {
1600
+ return i;
1601
+ },
1602
+ createScriptURL(i) {
1603
+ return i;
1604
+ }
1605
+ });
1606
+ } catch {
1607
+ return console.warn("TrustedTypes policy " + o + " could not be created."), null;
1608
+ }
1609
+ }, ln = function() {
1610
+ return {
1611
+ afterSanitizeAttributes: [],
1612
+ afterSanitizeElements: [],
1613
+ afterSanitizeShadowDOM: [],
1614
+ beforeSanitizeAttributes: [],
1615
+ beforeSanitizeElements: [],
1616
+ beforeSanitizeShadowDOM: [],
1617
+ uponSanitizeAttribute: [],
1618
+ uponSanitizeElement: [],
1619
+ uponSanitizeShadowNode: []
1620
+ };
1621
+ };
1622
+ function _n() {
1623
+ let l = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Gi();
1624
+ const e = (f) => _n(f);
1625
+ if (e.version = "3.3.1", e.removed = [], !l || !l.document || l.document.nodeType !== be.document || !l.Element)
1626
+ return e.isSupported = !1, e;
1627
+ let {
1628
+ document: t
1629
+ } = l;
1630
+ const n = t, r = n.currentScript, {
1631
+ DocumentFragment: o,
1632
+ HTMLTemplateElement: i,
1633
+ Node: a,
1634
+ Element: c,
1635
+ NodeFilter: d,
1636
+ NamedNodeMap: h = l.NamedNodeMap || l.MozNamedAttrMap,
1637
+ HTMLFormElement: m,
1638
+ DOMParser: g,
1639
+ trustedTypes: T
1640
+ } = l, v = c.prototype, P = Te(v, "cloneNode"), Z = Te(v, "remove"), ue = Te(v, "nextSibling"), Ae = Te(v, "childNodes"), V = Te(v, "parentNode");
1641
+ if (typeof i == "function") {
1642
+ const f = t.createElement("template");
1643
+ f.content && f.content.ownerDocument && (t = f.content.ownerDocument);
1644
+ }
1645
+ let S, Y = "";
1646
+ const {
1647
+ implementation: Be,
1648
+ createNodeIterator: En,
1649
+ createDocumentFragment: An,
1650
+ getElementsByTagName: yn
1651
+ } = t, {
1652
+ importNode: Sn
1653
+ } = n;
1654
+ let D = ln();
1655
+ e.isSupported = typeof bn == "function" && typeof V == "function" && Be && Be.createHTMLDocument !== void 0;
1656
+ const {
1657
+ MUSTACHE_EXPR: Ge,
1658
+ ERB_EXPR: We,
1659
+ TMPLIT_EXPR: qe,
1660
+ DATA_ATTR: Rn,
1661
+ ARIA_ATTR: Ln,
1662
+ IS_SCRIPT_OR_DATA: In,
1663
+ ATTR_WHITESPACE: _t,
1664
+ CUSTOM_ELEMENT: On
1665
+ } = on;
1666
+ let {
1667
+ IS_ALLOWED_URI: Et
1668
+ } = on, R = null;
1669
+ const At = k({}, [...tn, ...ot, ...lt, ...at, ...nn]);
1670
+ let L = null;
1671
+ const yt = k({}, [...sn, ...ct, ...rn, ...ze]);
1672
+ let E = Object.seal(ht(null, {
1673
+ tagNameCheck: {
1674
+ writable: !0,
1675
+ configurable: !1,
1676
+ enumerable: !0,
1677
+ value: null
1678
+ },
1679
+ attributeNameCheck: {
1680
+ writable: !0,
1681
+ configurable: !1,
1682
+ enumerable: !0,
1683
+ value: null
1684
+ },
1685
+ allowCustomizedBuiltInElements: {
1686
+ writable: !0,
1687
+ configurable: !1,
1688
+ enumerable: !0,
1689
+ value: !1
1690
+ }
1691
+ })), pe = null, Ze = null;
1692
+ const ie = Object.seal(ht(null, {
1693
+ tagCheck: {
1694
+ writable: !0,
1695
+ configurable: !1,
1696
+ enumerable: !0,
1697
+ value: null
1698
+ },
1699
+ attributeCheck: {
1700
+ writable: !0,
1701
+ configurable: !1,
1702
+ enumerable: !0,
1703
+ value: null
1704
+ }
1705
+ }));
1706
+ let St = !0, Ye = !0, Rt = !1, Lt = !0, se = !1, ye = !0, K = !1, je = !1, Xe = !1, re = !1, Se = !1, Re = !1, It = !0, Ot = !1;
1707
+ const Dn = "user-content-";
1708
+ let Qe = !0, he = !1, oe = {}, H = null;
1709
+ const Ve = k({}, ["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"]);
1710
+ let Dt = null;
1711
+ const Ct = k({}, ["audio", "video", "img", "source", "image", "track"]);
1712
+ let Ke = null;
1713
+ const Mt = k({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), Le = "http://www.w3.org/1998/Math/MathML", Ie = "http://www.w3.org/2000/svg", j = "http://www.w3.org/1999/xhtml";
1714
+ let le = j, Je = !1, et = null;
1715
+ const Cn = k({}, [Le, Ie, j], st);
1716
+ let Oe = k({}, ["mi", "mo", "mn", "ms", "mtext"]), De = k({}, ["annotation-xml"]);
1717
+ const Mn = k({}, ["title", "style", "font", "a", "script"]);
1718
+ let fe = null;
1719
+ const Nn = ["application/xhtml+xml", "text/html"], vn = "text/html";
1720
+ let y = null, ae = null;
1721
+ const zn = t.createElement("form"), Nt = function(s) {
1722
+ return s instanceof RegExp || s instanceof Function;
1723
+ }, tt = function() {
1724
+ let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1725
+ if (!(ae && ae === s)) {
1726
+ if ((!s || typeof s != "object") && (s = {}), s = G(s), fe = // eslint-disable-next-line unicorn/prefer-includes
1727
+ Nn.indexOf(s.PARSER_MEDIA_TYPE) === -1 ? vn : s.PARSER_MEDIA_TYPE, y = fe === "application/xhtml+xml" ? st : Pe, R = F(s, "ALLOWED_TAGS") ? k({}, s.ALLOWED_TAGS, y) : At, L = F(s, "ALLOWED_ATTR") ? k({}, s.ALLOWED_ATTR, y) : yt, et = F(s, "ALLOWED_NAMESPACES") ? k({}, s.ALLOWED_NAMESPACES, st) : Cn, Ke = F(s, "ADD_URI_SAFE_ATTR") ? k(G(Mt), s.ADD_URI_SAFE_ATTR, y) : Mt, Dt = F(s, "ADD_DATA_URI_TAGS") ? k(G(Ct), s.ADD_DATA_URI_TAGS, y) : Ct, H = F(s, "FORBID_CONTENTS") ? k({}, s.FORBID_CONTENTS, y) : Ve, pe = F(s, "FORBID_TAGS") ? k({}, s.FORBID_TAGS, y) : G({}), Ze = F(s, "FORBID_ATTR") ? k({}, s.FORBID_ATTR, y) : G({}), oe = F(s, "USE_PROFILES") ? s.USE_PROFILES : !1, St = s.ALLOW_ARIA_ATTR !== !1, Ye = s.ALLOW_DATA_ATTR !== !1, Rt = s.ALLOW_UNKNOWN_PROTOCOLS || !1, Lt = s.ALLOW_SELF_CLOSE_IN_ATTR !== !1, se = s.SAFE_FOR_TEMPLATES || !1, ye = s.SAFE_FOR_XML !== !1, K = s.WHOLE_DOCUMENT || !1, re = s.RETURN_DOM || !1, Se = s.RETURN_DOM_FRAGMENT || !1, Re = s.RETURN_TRUSTED_TYPE || !1, Xe = s.FORCE_BODY || !1, It = s.SANITIZE_DOM !== !1, Ot = s.SANITIZE_NAMED_PROPS || !1, Qe = s.KEEP_CONTENT !== !1, he = s.IN_PLACE || !1, Et = s.ALLOWED_URI_REGEXP || xn, le = s.NAMESPACE || j, Oe = s.MATHML_TEXT_INTEGRATION_POINTS || Oe, De = s.HTML_INTEGRATION_POINTS || De, E = s.CUSTOM_ELEMENT_HANDLING || {}, s.CUSTOM_ELEMENT_HANDLING && Nt(s.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (E.tagNameCheck = s.CUSTOM_ELEMENT_HANDLING.tagNameCheck), s.CUSTOM_ELEMENT_HANDLING && Nt(s.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (E.attributeNameCheck = s.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), s.CUSTOM_ELEMENT_HANDLING && typeof s.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (E.allowCustomizedBuiltInElements = s.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), se && (Ye = !1), Se && (re = !0), oe && (R = k({}, nn), L = [], oe.html === !0 && (k(R, tn), k(L, sn)), oe.svg === !0 && (k(R, ot), k(L, ct), k(L, ze)), oe.svgFilters === !0 && (k(R, lt), k(L, ct), k(L, ze)), oe.mathMl === !0 && (k(R, at), k(L, rn), k(L, ze))), s.ADD_TAGS && (typeof s.ADD_TAGS == "function" ? ie.tagCheck = s.ADD_TAGS : (R === At && (R = G(R)), k(R, s.ADD_TAGS, y))), s.ADD_ATTR && (typeof s.ADD_ATTR == "function" ? ie.attributeCheck = s.ADD_ATTR : (L === yt && (L = G(L)), k(L, s.ADD_ATTR, y))), s.ADD_URI_SAFE_ATTR && k(Ke, s.ADD_URI_SAFE_ATTR, y), s.FORBID_CONTENTS && (H === Ve && (H = G(H)), k(H, s.FORBID_CONTENTS, y)), s.ADD_FORBID_CONTENTS && (H === Ve && (H = G(H)), k(H, s.ADD_FORBID_CONTENTS, y)), Qe && (R["#text"] = !0), K && k(R, ["html", "head", "body"]), R.table && (k(R, ["tbody"]), delete pe.tbody), s.TRUSTED_TYPES_POLICY) {
1728
+ if (typeof s.TRUSTED_TYPES_POLICY.createHTML != "function")
1729
+ throw ke('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
1730
+ if (typeof s.TRUSTED_TYPES_POLICY.createScriptURL != "function")
1731
+ throw ke('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
1732
+ S = s.TRUSTED_TYPES_POLICY, Y = S.createHTML("");
1733
+ } else
1734
+ S === void 0 && (S = Wi(T, r)), S !== null && typeof Y == "string" && (Y = S.createHTML(""));
1735
+ M && M(s), ae = s;
1736
+ }
1737
+ }, vt = k({}, [...ot, ...lt, ...Mi]), zt = k({}, [...at, ...Ni]), Pn = function(s) {
1738
+ let u = V(s);
1739
+ (!u || !u.tagName) && (u = {
1740
+ namespaceURI: le,
1741
+ tagName: "template"
1742
+ });
1743
+ const p = Pe(s.tagName), _ = Pe(u.tagName);
1744
+ return et[s.namespaceURI] ? s.namespaceURI === Ie ? u.namespaceURI === j ? p === "svg" : u.namespaceURI === Le ? p === "svg" && (_ === "annotation-xml" || Oe[_]) : !!vt[p] : s.namespaceURI === Le ? u.namespaceURI === j ? p === "math" : u.namespaceURI === Ie ? p === "math" && De[_] : !!zt[p] : s.namespaceURI === j ? u.namespaceURI === Ie && !De[_] || u.namespaceURI === Le && !Oe[_] ? !1 : !zt[p] && (Mn[p] || !vt[p]) : !!(fe === "application/xhtml+xml" && et[s.namespaceURI]) : !1;
1745
+ }, B = function(s) {
1746
+ ge(e.removed, {
1747
+ element: s
1748
+ });
1749
+ try {
1750
+ V(s).removeChild(s);
1751
+ } catch {
1752
+ Z(s);
1753
+ }
1754
+ }, J = function(s, u) {
1755
+ try {
1756
+ ge(e.removed, {
1757
+ attribute: u.getAttributeNode(s),
1758
+ from: u
1759
+ });
1760
+ } catch {
1761
+ ge(e.removed, {
1762
+ attribute: null,
1763
+ from: u
1764
+ });
1765
+ }
1766
+ if (u.removeAttribute(s), s === "is")
1767
+ if (re || Se)
1768
+ try {
1769
+ B(u);
1770
+ } catch {
1771
+ }
1772
+ else
1773
+ try {
1774
+ u.setAttribute(s, "");
1775
+ } catch {
1776
+ }
1777
+ }, Pt = function(s) {
1778
+ let u = null, p = null;
1779
+ if (Xe)
1780
+ s = "<remove></remove>" + s;
1781
+ else {
1782
+ const A = rt(s, /^[\r\n\t ]+/);
1783
+ p = A && A[0];
1784
+ }
1785
+ fe === "application/xhtml+xml" && le === j && (s = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + s + "</body></html>");
1786
+ const _ = S ? S.createHTML(s) : s;
1787
+ if (le === j)
1788
+ try {
1789
+ u = new g().parseFromString(_, fe);
1790
+ } catch {
1791
+ }
1792
+ if (!u || !u.documentElement) {
1793
+ u = Be.createDocument(le, "template", null);
1794
+ try {
1795
+ u.documentElement.innerHTML = Je ? Y : _;
1796
+ } catch {
1797
+ }
1798
+ }
1799
+ const O = u.body || u.documentElement;
1800
+ return s && p && O.insertBefore(t.createTextNode(p), O.childNodes[0] || null), le === j ? yn.call(u, K ? "html" : "body")[0] : K ? u.documentElement : O;
1801
+ }, $t = function(s) {
1802
+ return En.call(
1803
+ s.ownerDocument || s,
1804
+ s,
1805
+ // eslint-disable-next-line no-bitwise
1806
+ d.SHOW_ELEMENT | d.SHOW_COMMENT | d.SHOW_TEXT | d.SHOW_PROCESSING_INSTRUCTION | d.SHOW_CDATA_SECTION,
1807
+ null
1808
+ );
1809
+ }, nt = function(s) {
1810
+ return s instanceof m && (typeof s.nodeName != "string" || typeof s.textContent != "string" || typeof s.removeChild != "function" || !(s.attributes instanceof h) || typeof s.removeAttribute != "function" || typeof s.setAttribute != "function" || typeof s.namespaceURI != "string" || typeof s.insertBefore != "function" || typeof s.hasChildNodes != "function");
1811
+ }, Ut = function(s) {
1812
+ return typeof a == "function" && s instanceof a;
1813
+ };
1814
+ function X(f, s, u) {
1815
+ ve(f, (p) => {
1816
+ p.call(e, s, u, ae);
1817
+ });
1818
+ }
1819
+ const Ft = function(s) {
1820
+ let u = null;
1821
+ if (X(D.beforeSanitizeElements, s, null), nt(s))
1822
+ return B(s), !0;
1823
+ const p = y(s.nodeName);
1824
+ if (X(D.uponSanitizeElement, s, {
1825
+ tagName: p,
1826
+ allowedTags: R
1827
+ }), ye && s.hasChildNodes() && !Ut(s.firstElementChild) && C(/<[/\w!]/g, s.innerHTML) && C(/<[/\w!]/g, s.textContent) || s.nodeType === be.progressingInstruction || ye && s.nodeType === be.comment && C(/<[/\w]/g, s.data))
1828
+ return B(s), !0;
1829
+ if (!(ie.tagCheck instanceof Function && ie.tagCheck(p)) && (!R[p] || pe[p])) {
1830
+ if (!pe[p] && Bt(p) && (E.tagNameCheck instanceof RegExp && C(E.tagNameCheck, p) || E.tagNameCheck instanceof Function && E.tagNameCheck(p)))
1831
+ return !1;
1832
+ if (Qe && !H[p]) {
1833
+ const _ = V(s) || s.parentNode, O = Ae(s) || s.childNodes;
1834
+ if (O && _) {
1835
+ const A = O.length;
1836
+ for (let z = A - 1; z >= 0; --z) {
1837
+ const Q = P(O[z], !0);
1838
+ Q.__removalCount = (s.__removalCount || 0) + 1, _.insertBefore(Q, ue(s));
1839
+ }
1840
+ }
1841
+ }
1842
+ return B(s), !0;
1843
+ }
1844
+ return s instanceof c && !Pn(s) || (p === "noscript" || p === "noembed" || p === "noframes") && C(/<\/no(script|embed|frames)/i, s.innerHTML) ? (B(s), !0) : (se && s.nodeType === be.text && (u = s.textContent, ve([Ge, We, qe], (_) => {
1845
+ u = me(u, _, " ");
1846
+ }), s.textContent !== u && (ge(e.removed, {
1847
+ element: s.cloneNode()
1848
+ }), s.textContent = u)), X(D.afterSanitizeElements, s, null), !1);
1849
+ }, Ht = function(s, u, p) {
1850
+ if (It && (u === "id" || u === "name") && (p in t || p in zn))
1851
+ return !1;
1852
+ if (!(Ye && !Ze[u] && C(Rn, u))) {
1853
+ if (!(St && C(Ln, u))) {
1854
+ if (!(ie.attributeCheck instanceof Function && ie.attributeCheck(u, s))) {
1855
+ if (!L[u] || Ze[u]) {
1856
+ if (
1857
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
1858
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1859
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
1860
+ !(Bt(s) && (E.tagNameCheck instanceof RegExp && C(E.tagNameCheck, s) || E.tagNameCheck instanceof Function && E.tagNameCheck(s)) && (E.attributeNameCheck instanceof RegExp && C(E.attributeNameCheck, u) || E.attributeNameCheck instanceof Function && E.attributeNameCheck(u, s)) || // Alternative, second condition checks if it's an `is`-attribute, AND
1861
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1862
+ u === "is" && E.allowCustomizedBuiltInElements && (E.tagNameCheck instanceof RegExp && C(E.tagNameCheck, p) || E.tagNameCheck instanceof Function && E.tagNameCheck(p)))
1863
+ ) return !1;
1864
+ } else if (!Ke[u]) {
1865
+ if (!C(Et, me(p, _t, ""))) {
1866
+ if (!((u === "src" || u === "xlink:href" || u === "href") && s !== "script" && Ii(p, "data:") === 0 && Dt[s])) {
1867
+ if (!(Rt && !C(In, me(p, _t, "")))) {
1868
+ if (p)
1869
+ return !1;
1870
+ }
1871
+ }
1872
+ }
1873
+ }
1874
+ }
1875
+ }
1876
+ }
1877
+ return !0;
1878
+ }, Bt = function(s) {
1879
+ return s !== "annotation-xml" && rt(s, On);
1880
+ }, Gt = function(s) {
1881
+ X(D.beforeSanitizeAttributes, s, null);
1882
+ const {
1883
+ attributes: u
1884
+ } = s;
1885
+ if (!u || nt(s))
1886
+ return;
1887
+ const p = {
1888
+ attrName: "",
1889
+ attrValue: "",
1890
+ keepAttr: !0,
1891
+ allowedAttributes: L,
1892
+ forceKeepAttr: void 0
1893
+ };
1894
+ let _ = u.length;
1895
+ for (; _--; ) {
1896
+ const O = u[_], {
1897
+ name: A,
1898
+ namespaceURI: z,
1899
+ value: Q
1900
+ } = O, ce = y(A), it = Q;
1901
+ let I = A === "value" ? it : Oi(it);
1902
+ if (p.attrName = ce, p.attrValue = I, p.keepAttr = !0, p.forceKeepAttr = void 0, X(D.uponSanitizeAttribute, s, p), I = p.attrValue, Ot && (ce === "id" || ce === "name") && (J(A, s), I = Dn + I), ye && C(/((--!?|])>)|<\/(style|title|textarea)/i, I)) {
1903
+ J(A, s);
1904
+ continue;
1905
+ }
1906
+ if (ce === "attributename" && rt(I, "href")) {
1907
+ J(A, s);
1908
+ continue;
1909
+ }
1910
+ if (p.forceKeepAttr)
1911
+ continue;
1912
+ if (!p.keepAttr) {
1913
+ J(A, s);
1914
+ continue;
1915
+ }
1916
+ if (!Lt && C(/\/>/i, I)) {
1917
+ J(A, s);
1918
+ continue;
1919
+ }
1920
+ se && ve([Ge, We, qe], (qt) => {
1921
+ I = me(I, qt, " ");
1922
+ });
1923
+ const Wt = y(s.nodeName);
1924
+ if (!Ht(Wt, ce, I)) {
1925
+ J(A, s);
1926
+ continue;
1927
+ }
1928
+ if (S && typeof T == "object" && typeof T.getAttributeType == "function" && !z)
1929
+ switch (T.getAttributeType(Wt, ce)) {
1930
+ case "TrustedHTML": {
1931
+ I = S.createHTML(I);
1932
+ break;
1933
+ }
1934
+ case "TrustedScriptURL": {
1935
+ I = S.createScriptURL(I);
1936
+ break;
1937
+ }
1938
+ }
1939
+ if (I !== it)
1940
+ try {
1941
+ z ? s.setAttributeNS(z, A, I) : s.setAttribute(A, I), nt(s) ? B(s) : en(e.removed);
1942
+ } catch {
1943
+ J(A, s);
1944
+ }
1945
+ }
1946
+ X(D.afterSanitizeAttributes, s, null);
1947
+ }, $n = function f(s) {
1948
+ let u = null;
1949
+ const p = $t(s);
1950
+ for (X(D.beforeSanitizeShadowDOM, s, null); u = p.nextNode(); )
1951
+ X(D.uponSanitizeShadowNode, u, null), Ft(u), Gt(u), u.content instanceof o && f(u.content);
1952
+ X(D.afterSanitizeShadowDOM, s, null);
1953
+ };
1954
+ return e.sanitize = function(f) {
1955
+ let s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, u = null, p = null, _ = null, O = null;
1956
+ if (Je = !f, Je && (f = "<!-->"), typeof f != "string" && !Ut(f))
1957
+ if (typeof f.toString == "function") {
1958
+ if (f = f.toString(), typeof f != "string")
1959
+ throw ke("dirty is not a string, aborting");
1960
+ } else
1961
+ throw ke("toString is not a function");
1962
+ if (!e.isSupported)
1963
+ return f;
1964
+ if (je || tt(s), e.removed = [], typeof f == "string" && (he = !1), he) {
1965
+ if (f.nodeName) {
1966
+ const Q = y(f.nodeName);
1967
+ if (!R[Q] || pe[Q])
1968
+ throw ke("root node is forbidden and cannot be sanitized in-place");
1969
+ }
1970
+ } else if (f instanceof a)
1971
+ u = Pt("<!---->"), p = u.ownerDocument.importNode(f, !0), p.nodeType === be.element && p.nodeName === "BODY" || p.nodeName === "HTML" ? u = p : u.appendChild(p);
1972
+ else {
1973
+ if (!re && !se && !K && // eslint-disable-next-line unicorn/prefer-includes
1974
+ f.indexOf("<") === -1)
1975
+ return S && Re ? S.createHTML(f) : f;
1976
+ if (u = Pt(f), !u)
1977
+ return re ? null : Re ? Y : "";
1978
+ }
1979
+ u && Xe && B(u.firstChild);
1980
+ const A = $t(he ? f : u);
1981
+ for (; _ = A.nextNode(); )
1982
+ Ft(_), Gt(_), _.content instanceof o && $n(_.content);
1983
+ if (he)
1984
+ return f;
1985
+ if (re) {
1986
+ if (Se)
1987
+ for (O = An.call(u.ownerDocument); u.firstChild; )
1988
+ O.appendChild(u.firstChild);
1989
+ else
1990
+ O = u;
1991
+ return (L.shadowroot || L.shadowrootmode) && (O = Sn.call(n, O, !0)), O;
1992
+ }
1993
+ let z = K ? u.outerHTML : u.innerHTML;
1994
+ return K && R["!doctype"] && u.ownerDocument && u.ownerDocument.doctype && u.ownerDocument.doctype.name && C(wn, u.ownerDocument.doctype.name) && (z = "<!DOCTYPE " + u.ownerDocument.doctype.name + `>
1995
+ ` + z), se && ve([Ge, We, qe], (Q) => {
1996
+ z = me(z, Q, " ");
1997
+ }), S && Re ? S.createHTML(z) : z;
1998
+ }, e.setConfig = function() {
1999
+ let f = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2000
+ tt(f), je = !0;
2001
+ }, e.clearConfig = function() {
2002
+ ae = null, je = !1;
2003
+ }, e.isValidAttribute = function(f, s, u) {
2004
+ ae || tt({});
2005
+ const p = y(f), _ = y(s);
2006
+ return Ht(p, _, u);
2007
+ }, e.addHook = function(f, s) {
2008
+ typeof s == "function" && ge(D[f], s);
2009
+ }, e.removeHook = function(f, s) {
2010
+ if (s !== void 0) {
2011
+ const u = Ri(D[f], s);
2012
+ return u === -1 ? void 0 : Li(D[f], u, 1)[0];
2013
+ }
2014
+ return en(D[f]);
2015
+ }, e.removeHooks = function(f) {
2016
+ D[f] = [];
2017
+ }, e.removeAllHooks = function() {
2018
+ D = ln();
2019
+ }, e;
2020
+ }
2021
+ var qi = _n();
2022
+ class Zi {
2023
+ constructor(e) {
2024
+ b(this, "container");
2025
+ b(this, "box");
2026
+ b(this, "messagesDiv");
2027
+ b(this, "input");
2028
+ b(this, "sendBtn");
2029
+ b(this, "isOpen", !1);
2030
+ b(this, "history", []);
2031
+ // 维护前端历史记录
2032
+ b(this, "config");
2033
+ this.config = {
2034
+ title: "企业智能助手",
2035
+ welcomeMessage: "您好,有什么可以帮您?",
2036
+ provider: "google",
2037
+ // 默认值
2038
+ ...e
2039
+ }, this.initDOM();
2040
+ }
2041
+ initDOM() {
2042
+ this.container = document.createElement("div"), this.container.className = "lee-ai-container";
2043
+ const e = document.createElement("div");
2044
+ e.className = "lee-ai-launcher", e.innerHTML = '<svg viewBox="0 0 24 24"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z"></path></svg>', e.onclick = () => this.toggle(), this.box = document.createElement("div"), this.box.className = "lee-ai-box", this.box.innerHTML = `
2045
+ <div class="lee-ai-header">
2046
+ <span>${this.config.title}</span>
2047
+ <span style="cursor:pointer;font-size:20px" id="lee-ai-close">×</span>
2048
+ </div>
2049
+ <div class="lee-ai-messages">
2050
+ <div class="lee-ai-msg model">${this.config.welcomeMessage}</div>
2051
+ </div>
2052
+ <div class="lee-ai-input-area">
2053
+ <input type="text" class="lee-ai-input" placeholder="输入您的问题..." />
2054
+ <button class="lee-ai-send-btn">发送</button>
2055
+ </div>
2056
+ `, this.container.appendChild(this.box), this.container.appendChild(e), document.body.appendChild(this.container), this.messagesDiv = this.box.querySelector(".lee-ai-messages"), this.input = this.box.querySelector(".lee-ai-input"), this.sendBtn = this.box.querySelector(".lee-ai-send-btn");
2057
+ const t = this.box.querySelector("#lee-ai-close");
2058
+ t.onclick = () => this.toggle(!1), this.sendBtn.onclick = () => this.sendMessage(), this.input.onkeypress = (n) => {
2059
+ n.key === "Enter" && this.sendMessage();
2060
+ };
2061
+ }
2062
+ toggle(e) {
2063
+ this.isOpen = e ?? !this.isOpen, this.box.classList.toggle("open", this.isOpen), this.isOpen && setTimeout(() => this.input.focus(), 100);
2064
+ }
2065
+ async sendMessage() {
2066
+ const e = this.input.value.trim();
2067
+ if (!e) return;
2068
+ this.input.value = "", this.appendMessage(e, "user"), this.setLoading(!0);
2069
+ const t = this.appendMessage("", "model");
2070
+ let n = "";
2071
+ await Bn(
2072
+ this.config,
2073
+ this.history,
2074
+ e,
2075
+ (r) => {
2076
+ n += r, t.innerHTML = qi.sanitize(x.parse(n)), this.scrollToBottom();
2077
+ },
2078
+ () => {
2079
+ this.setLoading(!1), this.history.push({ role: "user", parts: [{ text: e }] }), this.history.push({ role: "model", parts: [{ text: n }] });
2080
+ },
2081
+ (r) => {
2082
+ t.innerHTML = `<span style="color:red">错误: ${r}</span>`, this.setLoading(!1);
2083
+ }
2084
+ );
2085
+ }
2086
+ appendMessage(e, t) {
2087
+ const n = document.createElement("div");
2088
+ return n.className = `lee-ai-msg ${t}`, t === "user" ? n.innerText = e : n.innerHTML = e, this.messagesDiv.appendChild(n), this.scrollToBottom(), n;
2089
+ }
2090
+ scrollToBottom() {
2091
+ this.messagesDiv.scrollTop = this.messagesDiv.scrollHeight;
2092
+ }
2093
+ setLoading(e) {
2094
+ this.sendBtn.disabled = e, this.sendBtn.innerText = e ? "..." : "发送", this.input.disabled = e;
2095
+ }
2096
+ }
2097
+ window.LeeAI = {
2098
+ init: (l) => new Zi(l)
2099
+ };
2100
+ export {
2101
+ Zi as Widget
2102
+ };