@jojovms/scripto 0.0.5 → 0.0.7

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,2371 @@
1
+ var Vn = Object.defineProperty;
2
+ var Jt = (l) => {
3
+ throw TypeError(l);
4
+ };
5
+ var Xn = (l, e, t) => e in l ? Vn(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
6
+ var A = (l, e, t) => Xn(l, typeof e != "symbol" ? e + "" : e, t), Qn = (l, e, t) => e.has(l) || Jt("Cannot " + t);
7
+ var en = (l, e, t) => e.has(l) ? Jt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(l) : e.set(l, t);
8
+ var Ue = (l, e, t) => (Qn(l, e, "access private method"), t);
9
+ import { jsxs as $, jsx as w } from "react/jsx-runtime";
10
+ import re, { useRef as Kn, useState as ie, useEffect as be } from "react";
11
+ var gn = {
12
+ color: void 0,
13
+ size: void 0,
14
+ className: void 0,
15
+ style: void 0,
16
+ attr: void 0
17
+ }, tn = re.createContext && re.createContext(gn), se = function() {
18
+ return se = Object.assign || function(l) {
19
+ for (var e, t = 1, n = arguments.length; t < n; t++) {
20
+ e = arguments[t];
21
+ for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (l[i] = e[i]);
22
+ }
23
+ return l;
24
+ }, se.apply(this, arguments);
25
+ }, Jn = function(l, e) {
26
+ var t = {};
27
+ for (var n in l) Object.prototype.hasOwnProperty.call(l, n) && e.indexOf(n) < 0 && (t[n] = l[n]);
28
+ if (l != null && typeof Object.getOwnPropertySymbols == "function") for (var i = 0, n = Object.getOwnPropertySymbols(l); i < n.length; i++)
29
+ e.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(l, n[i]) && (t[n[i]] = l[n[i]]);
30
+ return t;
31
+ };
32
+ function kn(l) {
33
+ return l && l.map(function(e, t) {
34
+ return re.createElement(e.tag, se({
35
+ key: t
36
+ }, e.attr), kn(e.child));
37
+ });
38
+ }
39
+ function G(l) {
40
+ return function(e) {
41
+ return re.createElement(ei, se({
42
+ attr: se({}, l.attr)
43
+ }, e), kn(l.child));
44
+ };
45
+ }
46
+ function ei(l) {
47
+ var e = function(t) {
48
+ var n = l.attr, i = l.size, o = l.title, r = Jn(l, ["attr", "size", "title"]), a = i || t.size || "1em", c;
49
+ return t.className && (c = t.className), l.className && (c = (c ? c + " " : "") + l.className), re.createElement("svg", se({
50
+ stroke: "currentColor",
51
+ fill: "currentColor",
52
+ strokeWidth: "0"
53
+ }, t.attr, n, r, {
54
+ className: c,
55
+ style: se(se({
56
+ color: l.color || t.color
57
+ }, t.style), l.style),
58
+ height: a,
59
+ width: a,
60
+ xmlns: "http://www.w3.org/2000/svg"
61
+ }), o && re.createElement("title", null, o), l.children);
62
+ };
63
+ return tn !== void 0 ? re.createElement(tn.Consumer, null, function(t) {
64
+ return e(t);
65
+ }) : e(gn);
66
+ }
67
+ function ti(l) {
68
+ return G({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "48", d: "M112 244l144-144 144 144M256 120v292" } }] })(l);
69
+ }
70
+ function ni(l) {
71
+ return G({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M416 128L192 384l-96-96" } }] })(l);
72
+ }
73
+ function ii(l) {
74
+ return G({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M368 368L144 144m224 0L144 368" } }] })(l);
75
+ }
76
+ function ri(l) {
77
+ return G({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M320 367.79h76c55 0 100-29.21 100-83.6s-53-81.47-96-83.6c-8.89-85.06-71-136.8-144-136.8-69 0-113.44 45.79-128 91.2-60 5.7-112 43.88-112 106.4s54 106.4 120 106.4h56" } }, { tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M320 255.79l-64-64-64 64m64 192.42V207.79" } }] })(l);
78
+ }
79
+ function si(l) {
80
+ return G({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "rect", attr: { width: "336", height: "336", x: "128", y: "128", fill: "none", strokeLinejoin: "round", strokeWidth: "32", rx: "57", ry: "57" } }, { tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M383.5 128l.5-24a56.16 56.16 0 00-56-56H112a64.19 64.19 0 00-64 64v216a56.16 56.16 0 0056 56h24" } }] })(l);
81
+ }
82
+ function oi(l) {
83
+ return G({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinejoin: "round", strokeWidth: "32", d: "M416 221.25V416a48 48 0 01-48 48H144a48 48 0 01-48-48V96a48 48 0 0148-48h98.75a32 32 0 0122.62 9.37l141.26 141.26a32 32 0 019.37 22.62z" } }, { tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M256 56v120a32 32 0 0032 32h120m-232 80h160m-160 80h160" } }] })(l);
84
+ }
85
+ function li(l) {
86
+ return G({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M336 176h40a40 40 0 0140 40v208a40 40 0 01-40 40H136a40 40 0 01-40-40V216a40 40 0 0140-40h40" } }, { tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M176 272l80 80 80-80M256 48v288" } }] })(l);
87
+ }
88
+ function ai(l) {
89
+ return G({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M160 136c0-30.62 4.51-61.61 16-88C99.57 81.27 48 159.32 48 248c0 119.29 96.71 216 216 216 88.68 0 166.73-51.57 200-128-26.39 11.49-57.38 16-88 16-119.29 0-216-96.71-216-216z" } }] })(l);
90
+ }
91
+ function ci(l) {
92
+ return G({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeMiterlimit: "10", strokeWidth: "32", d: "M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z" } }, { tag: "path", attr: { d: "M310.4 336H201.6a25.62 25.62 0 01-25.6-25.6V201.6a25.62 25.62 0 0125.6-25.6h108.8a25.62 25.62 0 0125.6 25.6v108.8a25.62 25.62 0 01-25.6 25.6z" } }] })(l);
93
+ }
94
+ function ui(l) {
95
+ return G({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeMiterlimit: "10", strokeWidth: "32", d: "M256 48v48m0 320v48m147.08-355.08l-33.94 33.94M142.86 369.14l-33.94 33.94M464 256h-48m-320 0H48m355.08 147.08l-33.94-33.94M142.86 142.86l-33.94-33.94" } }, { tag: "circle", attr: { cx: "256", cy: "256", r: "80", fill: "none", strokeLinecap: "round", strokeMiterlimit: "10", strokeWidth: "32" } }] })(l);
96
+ }
97
+ function pi(l) {
98
+ return G({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M126 192H56a8 8 0 00-8 8v112a8 8 0 008 8h69.65a15.93 15.93 0 0110.14 3.54l91.47 74.89A8 8 0 00240 392V120a8 8 0 00-12.74-6.43l-91.47 74.89A15 15 0 01126 192zm194 128c9.74-19.38 16-40.84 16-64 0-23.48-6-44.42-16-64m48 176c19.48-33.92 32-64.06 32-112s-12-77.74-32-112m48 272c30-46 48-91.43 48-160s-18-113-48-160" } }] })(l);
99
+ }
100
+ function hi(l) {
101
+ return G({ attr: { viewBox: "0 0 576 512" }, child: [{ tag: "path", attr: { d: "M288 288h-32v-64h32v64zm288-128v192H288v32H160v-32H0V160h576zm-416 32H32v128h64v-96h32v96h32V192zm160 0H192v160h64v-32h64V192zm224 0H352v128h64v-96h32v96h32v-96h32v96h32V192z" } }] })(l);
102
+ }
103
+ const fi = ({ onFileLoaded: l }) => {
104
+ const e = Kn(null), [t, n] = ie(!1), [i, o] = ie(""), [r, a] = ie(!1), c = (p) => {
105
+ if (p.length > 0) {
106
+ const _ = p[0];
107
+ g(_) ? f(_) : alert("Please upload a valid Markdown (.md) file.");
108
+ }
109
+ }, g = (p) => p.name.endsWith(".md") || p.name.endsWith(".markdown") || p.type === "text/markdown", f = (p) => {
110
+ const _ = new FileReader();
111
+ _.onload = (I) => {
112
+ l({ name: p.name, content: I.target.result });
113
+ }, _.readAsText(p);
114
+ }, T = (p) => {
115
+ p.preventDefault(), p.stopPropagation(), p.type === "dragenter" || p.type === "dragover" ? n(!0) : (p.type === "dragleave" || p.type === "drop") && n(!1);
116
+ }, h = (p) => {
117
+ p.preventDefault(), p.stopPropagation(), n(!1), p.dataTransfer.files && p.dataTransfer.files[0] && c(p.dataTransfer.files);
118
+ }, b = async () => {
119
+ const p = i.trim();
120
+ if (p) {
121
+ a(!0);
122
+ try {
123
+ const _ = m(p), I = await fetch(_);
124
+ if (!I.ok)
125
+ throw new Error(`HTTP error! status: ${I.status}`);
126
+ const q = await I.text();
127
+ let W = p.substring(p.lastIndexOf("/") + 1) || "remote-file.md";
128
+ W.includes("?") && (W = W.split("?")[0]), l({ name: W, content: q });
129
+ } catch (_) {
130
+ console.error("Fetch error:", _), alert(`Failed to load Markdown from URL.
131
+
132
+ Note: This might be due to CORS restrictions. Try a raw GitHub URL.`);
133
+ } finally {
134
+ a(!1);
135
+ }
136
+ }
137
+ }, m = (p) => {
138
+ try {
139
+ if (new URL(p).hostname === "github.com" && p.includes("/blob/"))
140
+ return p.replace("github.com", "raw.githubusercontent.com").replace("/blob/", "/");
141
+ } catch {
142
+ }
143
+ return p;
144
+ };
145
+ return /* @__PURE__ */ $(
146
+ "section",
147
+ {
148
+ className: `upload-zone ${t ? "drag-active" : ""}`,
149
+ onClick: () => e.current.click(),
150
+ onDragEnter: T,
151
+ onDragLeave: T,
152
+ onDragOver: T,
153
+ onDrop: h,
154
+ id: "upload-area",
155
+ children: [
156
+ /* @__PURE__ */ w(
157
+ "input",
158
+ {
159
+ type: "file",
160
+ ref: e,
161
+ accept: ".md,.markdown",
162
+ hidden: !0,
163
+ onChange: (p) => c(p.target.files)
164
+ }
165
+ ),
166
+ /* @__PURE__ */ $("div", { className: "upload-content", children: [
167
+ /* @__PURE__ */ w("div", { className: "icon-wrapper", children: /* @__PURE__ */ w(ri, {}) }),
168
+ /* @__PURE__ */ w("h2", { children: "Drop your Markdown file here" }),
169
+ /* @__PURE__ */ $("p", { children: [
170
+ "or ",
171
+ /* @__PURE__ */ w("span", { className: "browse-btn", children: "browse files" })
172
+ ] }),
173
+ /* @__PURE__ */ w("div", { className: "divider", children: /* @__PURE__ */ w("span", { children: "OR" }) }),
174
+ /* @__PURE__ */ $("div", { className: "url-input-container", onClick: (p) => p.stopPropagation(), children: [
175
+ /* @__PURE__ */ w(
176
+ "input",
177
+ {
178
+ type: "url",
179
+ id: "url-input",
180
+ placeholder: "Paste a raw Markdown URL...",
181
+ spellCheck: "false",
182
+ value: i,
183
+ onChange: (p) => o(p.target.value),
184
+ onKeyDown: (p) => p.key === "Enter" && b()
185
+ }
186
+ ),
187
+ /* @__PURE__ */ w("button", { id: "url-btn", onClick: b, disabled: r, children: r ? "..." : "Go" })
188
+ ] }),
189
+ /* @__PURE__ */ $("p", { className: "sub-text", children: [
190
+ "Supports ",
191
+ /* @__PURE__ */ w("span", { style: { color: "aqua" }, children: ".md" }),
192
+ " and ",
193
+ /* @__PURE__ */ w("span", { style: { color: "aqua" }, children: ".markdown" })
194
+ ] })
195
+ ] })
196
+ ]
197
+ }
198
+ );
199
+ };
200
+ function _t() {
201
+ return {
202
+ async: !1,
203
+ breaks: !1,
204
+ extensions: null,
205
+ gfm: !0,
206
+ hooks: null,
207
+ pedantic: !1,
208
+ renderer: null,
209
+ silent: !1,
210
+ tokenizer: null,
211
+ walkTokens: null
212
+ };
213
+ }
214
+ let ue = _t();
215
+ function bn(l) {
216
+ ue = l;
217
+ }
218
+ const Tn = /[&<>"']/, di = new RegExp(Tn.source, "g"), wn = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, mi = new RegExp(wn.source, "g"), gi = {
219
+ "&": "&amp;",
220
+ "<": "&lt;",
221
+ ">": "&gt;",
222
+ '"': "&quot;",
223
+ "'": "&#39;"
224
+ }, nn = (l) => gi[l];
225
+ function B(l, e) {
226
+ if (e) {
227
+ if (Tn.test(l))
228
+ return l.replace(di, nn);
229
+ } else if (wn.test(l))
230
+ return l.replace(mi, nn);
231
+ return l;
232
+ }
233
+ const ki = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
234
+ function bi(l) {
235
+ return l.replace(ki, (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)) : ""));
236
+ }
237
+ const Ti = /(^|[^\[])\^/g;
238
+ function E(l, e) {
239
+ let t = typeof l == "string" ? l : l.source;
240
+ e = e || "";
241
+ const n = {
242
+ replace: (i, o) => {
243
+ let r = typeof o == "string" ? o : o.source;
244
+ return r = r.replace(Ti, "$1"), t = t.replace(i, r), n;
245
+ },
246
+ getRegex: () => new RegExp(t, e)
247
+ };
248
+ return n;
249
+ }
250
+ function rn(l) {
251
+ try {
252
+ l = encodeURI(l).replace(/%25/g, "%");
253
+ } catch {
254
+ return null;
255
+ }
256
+ return l;
257
+ }
258
+ const Le = { exec: () => null };
259
+ function sn(l, e) {
260
+ const t = l.replace(/\|/g, (o, r, a) => {
261
+ let c = !1, g = r;
262
+ for (; --g >= 0 && a[g] === "\\"; )
263
+ c = !c;
264
+ return c ? "|" : " |";
265
+ }), n = t.split(/ \|/);
266
+ let i = 0;
267
+ if (n[0].trim() || n.shift(), n.length > 0 && !n[n.length - 1].trim() && n.pop(), e)
268
+ if (n.length > e)
269
+ n.splice(e);
270
+ else
271
+ for (; n.length < e; )
272
+ n.push("");
273
+ for (; i < n.length; i++)
274
+ n[i] = n[i].trim().replace(/\\\|/g, "|");
275
+ return n;
276
+ }
277
+ function Fe(l, e, t) {
278
+ const n = l.length;
279
+ if (n === 0)
280
+ return "";
281
+ let i = 0;
282
+ for (; i < n && l.charAt(n - i - 1) === e; )
283
+ i++;
284
+ return l.slice(0, n - i);
285
+ }
286
+ function wi(l, e) {
287
+ if (l.indexOf(e[1]) === -1)
288
+ return -1;
289
+ let t = 0;
290
+ for (let n = 0; n < l.length; n++)
291
+ if (l[n] === "\\")
292
+ n++;
293
+ else if (l[n] === e[0])
294
+ t++;
295
+ else if (l[n] === e[1] && (t--, t < 0))
296
+ return n;
297
+ return -1;
298
+ }
299
+ function on(l, e, t, n) {
300
+ const i = e.href, o = e.title ? B(e.title) : null, r = l[1].replace(/\\([\[\]])/g, "$1");
301
+ if (l[0].charAt(0) !== "!") {
302
+ n.state.inLink = !0;
303
+ const a = {
304
+ type: "link",
305
+ raw: t,
306
+ href: i,
307
+ title: o,
308
+ text: r,
309
+ tokens: n.inlineTokens(r)
310
+ };
311
+ return n.state.inLink = !1, a;
312
+ }
313
+ return {
314
+ type: "image",
315
+ raw: t,
316
+ href: i,
317
+ title: o,
318
+ text: B(r)
319
+ };
320
+ }
321
+ function xi(l, e) {
322
+ const t = l.match(/^(\s+)(?:```)/);
323
+ if (t === null)
324
+ return e;
325
+ const n = t[1];
326
+ return e.split(`
327
+ `).map((i) => {
328
+ const o = i.match(/^\s+/);
329
+ if (o === null)
330
+ return i;
331
+ const [r] = o;
332
+ return r.length >= n.length ? i.slice(n.length) : i;
333
+ }).join(`
334
+ `);
335
+ }
336
+ class Ge {
337
+ // set by the lexer
338
+ constructor(e) {
339
+ A(this, "options");
340
+ A(this, "rules");
341
+ // set by the lexer
342
+ A(this, "lexer");
343
+ this.options = e || ue;
344
+ }
345
+ space(e) {
346
+ const t = this.rules.block.newline.exec(e);
347
+ if (t && t[0].length > 0)
348
+ return {
349
+ type: "space",
350
+ raw: t[0]
351
+ };
352
+ }
353
+ code(e) {
354
+ const t = this.rules.block.code.exec(e);
355
+ if (t) {
356
+ const n = t[0].replace(/^ {1,4}/gm, "");
357
+ return {
358
+ type: "code",
359
+ raw: t[0],
360
+ codeBlockStyle: "indented",
361
+ text: this.options.pedantic ? n : Fe(n, `
362
+ `)
363
+ };
364
+ }
365
+ }
366
+ fences(e) {
367
+ const t = this.rules.block.fences.exec(e);
368
+ if (t) {
369
+ const n = t[0], i = xi(n, t[3] || "");
370
+ return {
371
+ type: "code",
372
+ raw: n,
373
+ lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
374
+ text: i
375
+ };
376
+ }
377
+ }
378
+ heading(e) {
379
+ const t = this.rules.block.heading.exec(e);
380
+ if (t) {
381
+ let n = t[2].trim();
382
+ if (/#$/.test(n)) {
383
+ const i = Fe(n, "#");
384
+ (this.options.pedantic || !i || / $/.test(i)) && (n = i.trim());
385
+ }
386
+ return {
387
+ type: "heading",
388
+ raw: t[0],
389
+ depth: t[1].length,
390
+ text: n,
391
+ tokens: this.lexer.inline(n)
392
+ };
393
+ }
394
+ }
395
+ hr(e) {
396
+ const t = this.rules.block.hr.exec(e);
397
+ if (t)
398
+ return {
399
+ type: "hr",
400
+ raw: t[0]
401
+ };
402
+ }
403
+ blockquote(e) {
404
+ const t = this.rules.block.blockquote.exec(e);
405
+ if (t) {
406
+ const n = Fe(t[0].replace(/^ *>[ \t]?/gm, ""), `
407
+ `), i = this.lexer.state.top;
408
+ this.lexer.state.top = !0;
409
+ const o = this.lexer.blockTokens(n);
410
+ return this.lexer.state.top = i, {
411
+ type: "blockquote",
412
+ raw: t[0],
413
+ tokens: o,
414
+ text: n
415
+ };
416
+ }
417
+ }
418
+ list(e) {
419
+ let t = this.rules.block.list.exec(e);
420
+ if (t) {
421
+ let n = t[1].trim();
422
+ const i = n.length > 1, o = {
423
+ type: "list",
424
+ raw: "",
425
+ ordered: i,
426
+ start: i ? +n.slice(0, -1) : "",
427
+ loose: !1,
428
+ items: []
429
+ };
430
+ n = i ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = i ? n : "[*+-]");
431
+ const r = new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`);
432
+ let a = "", c = "", g = !1;
433
+ for (; e; ) {
434
+ let f = !1;
435
+ if (!(t = r.exec(e)) || this.rules.block.hr.test(e))
436
+ break;
437
+ a = t[0], e = e.substring(a.length);
438
+ let T = t[2].split(`
439
+ `, 1)[0].replace(/^\t+/, (I) => " ".repeat(3 * I.length)), h = e.split(`
440
+ `, 1)[0], b = 0;
441
+ this.options.pedantic ? (b = 2, c = T.trimStart()) : (b = t[2].search(/[^ ]/), b = b > 4 ? 1 : b, c = T.slice(b), b += t[1].length);
442
+ let m = !1;
443
+ if (!T && /^ *$/.test(h) && (a += h + `
444
+ `, e = e.substring(h.length + 1), f = !0), !f) {
445
+ const I = new RegExp(`^ {0,${Math.min(3, b - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), q = new RegExp(`^ {0,${Math.min(3, b - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), W = new RegExp(`^ {0,${Math.min(3, b - 1)}}(?:\`\`\`|~~~)`), C = new RegExp(`^ {0,${Math.min(3, b - 1)}}#`);
446
+ for (; e; ) {
447
+ const J = e.split(`
448
+ `, 1)[0];
449
+ if (h = J, this.options.pedantic && (h = h.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ")), W.test(h) || C.test(h) || I.test(h) || q.test(e))
450
+ break;
451
+ if (h.search(/[^ ]/) >= b || !h.trim())
452
+ c += `
453
+ ` + h.slice(b);
454
+ else {
455
+ if (m || T.search(/[^ ]/) >= 4 || W.test(T) || C.test(T) || q.test(T))
456
+ break;
457
+ c += `
458
+ ` + h;
459
+ }
460
+ !m && !h.trim() && (m = !0), a += J + `
461
+ `, e = e.substring(J.length + 1), T = h.slice(b);
462
+ }
463
+ }
464
+ o.loose || (g ? o.loose = !0 : /\n *\n *$/.test(a) && (g = !0));
465
+ let p = null, _;
466
+ this.options.gfm && (p = /^\[[ xX]\] /.exec(c), p && (_ = p[0] !== "[ ] ", c = c.replace(/^\[[ xX]\] +/, ""))), o.items.push({
467
+ type: "list_item",
468
+ raw: a,
469
+ task: !!p,
470
+ checked: _,
471
+ loose: !1,
472
+ text: c,
473
+ tokens: []
474
+ }), o.raw += a;
475
+ }
476
+ o.items[o.items.length - 1].raw = a.trimEnd(), o.items[o.items.length - 1].text = c.trimEnd(), o.raw = o.raw.trimEnd();
477
+ for (let f = 0; f < o.items.length; f++)
478
+ if (this.lexer.state.top = !1, o.items[f].tokens = this.lexer.blockTokens(o.items[f].text, []), !o.loose) {
479
+ const T = o.items[f].tokens.filter((b) => b.type === "space"), h = T.length > 0 && T.some((b) => /\n.*\n/.test(b.raw));
480
+ o.loose = h;
481
+ }
482
+ if (o.loose)
483
+ for (let f = 0; f < o.items.length; f++)
484
+ o.items[f].loose = !0;
485
+ return o;
486
+ }
487
+ }
488
+ html(e) {
489
+ const t = this.rules.block.html.exec(e);
490
+ if (t)
491
+ return {
492
+ type: "html",
493
+ block: !0,
494
+ raw: t[0],
495
+ pre: t[1] === "pre" || t[1] === "script" || t[1] === "style",
496
+ text: t[0]
497
+ };
498
+ }
499
+ def(e) {
500
+ const t = this.rules.block.def.exec(e);
501
+ if (t) {
502
+ const n = t[1].toLowerCase().replace(/\s+/g, " "), i = 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];
503
+ return {
504
+ type: "def",
505
+ tag: n,
506
+ raw: t[0],
507
+ href: i,
508
+ title: o
509
+ };
510
+ }
511
+ }
512
+ table(e) {
513
+ const t = this.rules.block.table.exec(e);
514
+ if (!t || !/[:|]/.test(t[2]))
515
+ return;
516
+ const n = sn(t[1]), i = t[2].replace(/^\||\| *$/g, "").split("|"), o = t[3] && t[3].trim() ? t[3].replace(/\n[ \t]*$/, "").split(`
517
+ `) : [], r = {
518
+ type: "table",
519
+ raw: t[0],
520
+ header: [],
521
+ align: [],
522
+ rows: []
523
+ };
524
+ if (n.length === i.length) {
525
+ for (const a of i)
526
+ /^ *-+: *$/.test(a) ? r.align.push("right") : /^ *:-+: *$/.test(a) ? r.align.push("center") : /^ *:-+ *$/.test(a) ? r.align.push("left") : r.align.push(null);
527
+ for (const a of n)
528
+ r.header.push({
529
+ text: a,
530
+ tokens: this.lexer.inline(a)
531
+ });
532
+ for (const a of o)
533
+ r.rows.push(sn(a, r.header.length).map((c) => ({
534
+ text: c,
535
+ tokens: this.lexer.inline(c)
536
+ })));
537
+ return r;
538
+ }
539
+ }
540
+ lheading(e) {
541
+ const t = this.rules.block.lheading.exec(e);
542
+ if (t)
543
+ return {
544
+ type: "heading",
545
+ raw: t[0],
546
+ depth: t[2].charAt(0) === "=" ? 1 : 2,
547
+ text: t[1],
548
+ tokens: this.lexer.inline(t[1])
549
+ };
550
+ }
551
+ paragraph(e) {
552
+ const t = this.rules.block.paragraph.exec(e);
553
+ if (t) {
554
+ const n = t[1].charAt(t[1].length - 1) === `
555
+ ` ? t[1].slice(0, -1) : t[1];
556
+ return {
557
+ type: "paragraph",
558
+ raw: t[0],
559
+ text: n,
560
+ tokens: this.lexer.inline(n)
561
+ };
562
+ }
563
+ }
564
+ text(e) {
565
+ const t = this.rules.block.text.exec(e);
566
+ if (t)
567
+ return {
568
+ type: "text",
569
+ raw: t[0],
570
+ text: t[0],
571
+ tokens: this.lexer.inline(t[0])
572
+ };
573
+ }
574
+ escape(e) {
575
+ const t = this.rules.inline.escape.exec(e);
576
+ if (t)
577
+ return {
578
+ type: "escape",
579
+ raw: t[0],
580
+ text: B(t[1])
581
+ };
582
+ }
583
+ tag(e) {
584
+ const t = this.rules.inline.tag.exec(e);
585
+ if (t)
586
+ 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), {
587
+ type: "html",
588
+ raw: t[0],
589
+ inLink: this.lexer.state.inLink,
590
+ inRawBlock: this.lexer.state.inRawBlock,
591
+ block: !1,
592
+ text: t[0]
593
+ };
594
+ }
595
+ link(e) {
596
+ const t = this.rules.inline.link.exec(e);
597
+ if (t) {
598
+ const n = t[2].trim();
599
+ if (!this.options.pedantic && /^</.test(n)) {
600
+ if (!/>$/.test(n))
601
+ return;
602
+ const r = Fe(n.slice(0, -1), "\\");
603
+ if ((n.length - r.length) % 2 === 0)
604
+ return;
605
+ } else {
606
+ const r = wi(t[2], "()");
607
+ if (r > -1) {
608
+ const c = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + r;
609
+ t[2] = t[2].substring(0, r), t[0] = t[0].substring(0, c).trim(), t[3] = "";
610
+ }
611
+ }
612
+ let i = t[2], o = "";
613
+ if (this.options.pedantic) {
614
+ const r = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);
615
+ r && (i = r[1], o = r[3]);
616
+ } else
617
+ o = t[3] ? t[3].slice(1, -1) : "";
618
+ return i = i.trim(), /^</.test(i) && (this.options.pedantic && !/>$/.test(n) ? i = i.slice(1) : i = i.slice(1, -1)), on(t, {
619
+ href: i && i.replace(this.rules.inline.anyPunctuation, "$1"),
620
+ title: o && o.replace(this.rules.inline.anyPunctuation, "$1")
621
+ }, t[0], this.lexer);
622
+ }
623
+ }
624
+ reflink(e, t) {
625
+ let n;
626
+ if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
627
+ const i = (n[2] || n[1]).replace(/\s+/g, " "), o = t[i.toLowerCase()];
628
+ if (!o) {
629
+ const r = n[0].charAt(0);
630
+ return {
631
+ type: "text",
632
+ raw: r,
633
+ text: r
634
+ };
635
+ }
636
+ return on(n, o, n[0], this.lexer);
637
+ }
638
+ }
639
+ emStrong(e, t, n = "") {
640
+ let i = this.rules.inline.emStrongLDelim.exec(e);
641
+ if (!i || i[3] && n.match(/[\p{L}\p{N}]/u))
642
+ return;
643
+ if (!(i[1] || i[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
644
+ const r = [...i[0]].length - 1;
645
+ let a, c, g = r, f = 0;
646
+ const T = i[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
647
+ for (T.lastIndex = 0, t = t.slice(-1 * e.length + r); (i = T.exec(t)) != null; ) {
648
+ if (a = i[1] || i[2] || i[3] || i[4] || i[5] || i[6], !a)
649
+ continue;
650
+ if (c = [...a].length, i[3] || i[4]) {
651
+ g += c;
652
+ continue;
653
+ } else if ((i[5] || i[6]) && r % 3 && !((r + c) % 3)) {
654
+ f += c;
655
+ continue;
656
+ }
657
+ if (g -= c, g > 0)
658
+ continue;
659
+ c = Math.min(c, c + g + f);
660
+ const h = [...i[0]][0].length, b = e.slice(0, r + i.index + h + c);
661
+ if (Math.min(r, c) % 2) {
662
+ const p = b.slice(1, -1);
663
+ return {
664
+ type: "em",
665
+ raw: b,
666
+ text: p,
667
+ tokens: this.lexer.inlineTokens(p)
668
+ };
669
+ }
670
+ const m = b.slice(2, -2);
671
+ return {
672
+ type: "strong",
673
+ raw: b,
674
+ text: m,
675
+ tokens: this.lexer.inlineTokens(m)
676
+ };
677
+ }
678
+ }
679
+ }
680
+ codespan(e) {
681
+ const t = this.rules.inline.code.exec(e);
682
+ if (t) {
683
+ let n = t[2].replace(/\n/g, " ");
684
+ const i = /[^ ]/.test(n), o = /^ /.test(n) && / $/.test(n);
685
+ return i && o && (n = n.substring(1, n.length - 1)), n = B(n, !0), {
686
+ type: "codespan",
687
+ raw: t[0],
688
+ text: n
689
+ };
690
+ }
691
+ }
692
+ br(e) {
693
+ const t = this.rules.inline.br.exec(e);
694
+ if (t)
695
+ return {
696
+ type: "br",
697
+ raw: t[0]
698
+ };
699
+ }
700
+ del(e) {
701
+ const t = this.rules.inline.del.exec(e);
702
+ if (t)
703
+ return {
704
+ type: "del",
705
+ raw: t[0],
706
+ text: t[2],
707
+ tokens: this.lexer.inlineTokens(t[2])
708
+ };
709
+ }
710
+ autolink(e) {
711
+ const t = this.rules.inline.autolink.exec(e);
712
+ if (t) {
713
+ let n, i;
714
+ return t[2] === "@" ? (n = B(t[1]), i = "mailto:" + n) : (n = B(t[1]), i = n), {
715
+ type: "link",
716
+ raw: t[0],
717
+ text: n,
718
+ href: i,
719
+ tokens: [
720
+ {
721
+ type: "text",
722
+ raw: n,
723
+ text: n
724
+ }
725
+ ]
726
+ };
727
+ }
728
+ }
729
+ url(e) {
730
+ var n;
731
+ let t;
732
+ if (t = this.rules.inline.url.exec(e)) {
733
+ let i, o;
734
+ if (t[2] === "@")
735
+ i = B(t[0]), o = "mailto:" + i;
736
+ else {
737
+ let r;
738
+ do
739
+ r = t[0], t[0] = ((n = this.rules.inline._backpedal.exec(t[0])) == null ? void 0 : n[0]) ?? "";
740
+ while (r !== t[0]);
741
+ i = B(t[0]), t[1] === "www." ? o = "http://" + t[0] : o = t[0];
742
+ }
743
+ return {
744
+ type: "link",
745
+ raw: t[0],
746
+ text: i,
747
+ href: o,
748
+ tokens: [
749
+ {
750
+ type: "text",
751
+ raw: i,
752
+ text: i
753
+ }
754
+ ]
755
+ };
756
+ }
757
+ }
758
+ inlineText(e) {
759
+ const t = this.rules.inline.text.exec(e);
760
+ if (t) {
761
+ let n;
762
+ return this.lexer.state.inRawBlock ? n = t[0] : n = B(t[0]), {
763
+ type: "text",
764
+ raw: t[0],
765
+ text: n
766
+ };
767
+ }
768
+ }
769
+ }
770
+ const _i = /^(?: *(?:\n|$))+/, yi = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, Ei = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, Ie = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Ai = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, xn = /(?:[*+-]|\d{1,9}[.)])/, _n = E(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, xn).getRegex(), yt = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Si = /^[^\n]+/, Et = /(?!\s*\])(?:\\.|[^\[\]\\])+/, Ri = E(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", Et).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Li = E(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, xn).getRegex(), Ye = "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", At = /<!--(?!-?>)[\s\S]*?(?:-->|$)/, vi = E("^ {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", At).replace("tag", Ye).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), yn = E(yt).replace("hr", Ie).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", Ye).getRegex(), Ii = E(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", yn).getRegex(), St = {
771
+ blockquote: Ii,
772
+ code: yi,
773
+ def: Ri,
774
+ fences: Ei,
775
+ heading: Ai,
776
+ hr: Ie,
777
+ html: vi,
778
+ lheading: _n,
779
+ list: Li,
780
+ newline: _i,
781
+ paragraph: yn,
782
+ table: Le,
783
+ text: Si
784
+ }, ln = E("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", Ie).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", Ye).getRegex(), Ci = {
785
+ ...St,
786
+ table: ln,
787
+ paragraph: E(yt).replace("hr", Ie).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", ln).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", Ye).getRegex()
788
+ }, Oi = {
789
+ ...St,
790
+ html: E(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", At).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(),
791
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
792
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
793
+ fences: Le,
794
+ // fences not supported
795
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
796
+ paragraph: E(yt).replace("hr", Ie).replace("heading", ` *#{1,6} *[^
797
+ ]`).replace("lheading", _n).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
798
+ }, En = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Di = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, An = /^( {2,}|\\)\n(?!\s*$)/, Ni = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, Ce = "\\p{P}$+<=>`^|~", Mi = E(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, Ce).getRegex(), zi = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g, Pi = E(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, Ce).getRegex(), $i = E("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, Ce).getRegex(), Ui = E("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, Ce).getRegex(), Fi = E(/\\([punct])/, "gu").replace(/punct/g, Ce).getRegex(), Hi = E(/^<(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(), Bi = E(At).replace("(?:-->|$)", "-->").getRegex(), Wi = E("^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", Bi).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), qe = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, ji = E(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", qe).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), Sn = E(/^!?\[(label)\]\[(ref)\]/).replace("label", qe).replace("ref", Et).getRegex(), Rn = E(/^!?\[(ref)\](?:\[\])?/).replace("ref", Et).getRegex(), Gi = E("reflink|nolink(?!\\()", "g").replace("reflink", Sn).replace("nolink", Rn).getRegex(), Rt = {
799
+ _backpedal: Le,
800
+ // only used for GFM url
801
+ anyPunctuation: Fi,
802
+ autolink: Hi,
803
+ blockSkip: zi,
804
+ br: An,
805
+ code: Di,
806
+ del: Le,
807
+ emStrongLDelim: Pi,
808
+ emStrongRDelimAst: $i,
809
+ emStrongRDelimUnd: Ui,
810
+ escape: En,
811
+ link: ji,
812
+ nolink: Rn,
813
+ punctuation: Mi,
814
+ reflink: Sn,
815
+ reflinkSearch: Gi,
816
+ tag: Wi,
817
+ text: Ni,
818
+ url: Le
819
+ }, qi = {
820
+ ...Rt,
821
+ link: E(/^!?\[(label)\]\((.*?)\)/).replace("label", qe).getRegex(),
822
+ reflink: E(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", qe).getRegex()
823
+ }, kt = {
824
+ ...Rt,
825
+ escape: E(En).replace("])", "~|])").getRegex(),
826
+ url: E(/^((?: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(),
827
+ _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
828
+ del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
829
+ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
830
+ }, Zi = {
831
+ ...kt,
832
+ br: E(An).replace("{2,}", "*").getRegex(),
833
+ text: E(kt.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
834
+ }, He = {
835
+ normal: St,
836
+ gfm: Ci,
837
+ pedantic: Oi
838
+ }, _e = {
839
+ normal: Rt,
840
+ gfm: kt,
841
+ breaks: Zi,
842
+ pedantic: qi
843
+ };
844
+ class Q {
845
+ constructor(e) {
846
+ A(this, "tokens");
847
+ A(this, "options");
848
+ A(this, "state");
849
+ A(this, "tokenizer");
850
+ A(this, "inlineQueue");
851
+ this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || ue, this.options.tokenizer = this.options.tokenizer || new Ge(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
852
+ inLink: !1,
853
+ inRawBlock: !1,
854
+ top: !0
855
+ };
856
+ const t = {
857
+ block: He.normal,
858
+ inline: _e.normal
859
+ };
860
+ this.options.pedantic ? (t.block = He.pedantic, t.inline = _e.pedantic) : this.options.gfm && (t.block = He.gfm, this.options.breaks ? t.inline = _e.breaks : t.inline = _e.gfm), this.tokenizer.rules = t;
861
+ }
862
+ /**
863
+ * Expose Rules
864
+ */
865
+ static get rules() {
866
+ return {
867
+ block: He,
868
+ inline: _e
869
+ };
870
+ }
871
+ /**
872
+ * Static Lex Method
873
+ */
874
+ static lex(e, t) {
875
+ return new Q(t).lex(e);
876
+ }
877
+ /**
878
+ * Static Lex Inline Method
879
+ */
880
+ static lexInline(e, t) {
881
+ return new Q(t).inlineTokens(e);
882
+ }
883
+ /**
884
+ * Preprocessing
885
+ */
886
+ lex(e) {
887
+ e = e.replace(/\r\n|\r/g, `
888
+ `), this.blockTokens(e, this.tokens);
889
+ for (let t = 0; t < this.inlineQueue.length; t++) {
890
+ const n = this.inlineQueue[t];
891
+ this.inlineTokens(n.src, n.tokens);
892
+ }
893
+ return this.inlineQueue = [], this.tokens;
894
+ }
895
+ blockTokens(e, t = []) {
896
+ this.options.pedantic ? e = e.replace(/\t/g, " ").replace(/^ +$/gm, "") : e = e.replace(/^( *)(\t+)/gm, (a, c, g) => c + " ".repeat(g.length));
897
+ let n, i, o, r;
898
+ for (; e; )
899
+ 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))) {
900
+ if (n = this.tokenizer.space(e)) {
901
+ e = e.substring(n.raw.length), n.raw.length === 1 && t.length > 0 ? t[t.length - 1].raw += `
902
+ ` : t.push(n);
903
+ continue;
904
+ }
905
+ if (n = this.tokenizer.code(e)) {
906
+ e = e.substring(n.raw.length), i = t[t.length - 1], i && (i.type === "paragraph" || i.type === "text") ? (i.raw += `
907
+ ` + n.raw, i.text += `
908
+ ` + n.text, this.inlineQueue[this.inlineQueue.length - 1].src = i.text) : t.push(n);
909
+ continue;
910
+ }
911
+ if (n = this.tokenizer.fences(e)) {
912
+ e = e.substring(n.raw.length), t.push(n);
913
+ continue;
914
+ }
915
+ if (n = this.tokenizer.heading(e)) {
916
+ e = e.substring(n.raw.length), t.push(n);
917
+ continue;
918
+ }
919
+ if (n = this.tokenizer.hr(e)) {
920
+ e = e.substring(n.raw.length), t.push(n);
921
+ continue;
922
+ }
923
+ if (n = this.tokenizer.blockquote(e)) {
924
+ e = e.substring(n.raw.length), t.push(n);
925
+ continue;
926
+ }
927
+ if (n = this.tokenizer.list(e)) {
928
+ e = e.substring(n.raw.length), t.push(n);
929
+ continue;
930
+ }
931
+ if (n = this.tokenizer.html(e)) {
932
+ e = e.substring(n.raw.length), t.push(n);
933
+ continue;
934
+ }
935
+ if (n = this.tokenizer.def(e)) {
936
+ e = e.substring(n.raw.length), i = t[t.length - 1], i && (i.type === "paragraph" || i.type === "text") ? (i.raw += `
937
+ ` + n.raw, i.text += `
938
+ ` + n.raw, this.inlineQueue[this.inlineQueue.length - 1].src = i.text) : this.tokens.links[n.tag] || (this.tokens.links[n.tag] = {
939
+ href: n.href,
940
+ title: n.title
941
+ });
942
+ continue;
943
+ }
944
+ if (n = this.tokenizer.table(e)) {
945
+ e = e.substring(n.raw.length), t.push(n);
946
+ continue;
947
+ }
948
+ if (n = this.tokenizer.lheading(e)) {
949
+ e = e.substring(n.raw.length), t.push(n);
950
+ continue;
951
+ }
952
+ if (o = e, this.options.extensions && this.options.extensions.startBlock) {
953
+ let a = 1 / 0;
954
+ const c = e.slice(1);
955
+ let g;
956
+ this.options.extensions.startBlock.forEach((f) => {
957
+ g = f.call({ lexer: this }, c), typeof g == "number" && g >= 0 && (a = Math.min(a, g));
958
+ }), a < 1 / 0 && a >= 0 && (o = e.substring(0, a + 1));
959
+ }
960
+ if (this.state.top && (n = this.tokenizer.paragraph(o))) {
961
+ i = t[t.length - 1], r && i.type === "paragraph" ? (i.raw += `
962
+ ` + n.raw, i.text += `
963
+ ` + n.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = i.text) : t.push(n), r = o.length !== e.length, e = e.substring(n.raw.length);
964
+ continue;
965
+ }
966
+ if (n = this.tokenizer.text(e)) {
967
+ e = e.substring(n.raw.length), i = t[t.length - 1], i && i.type === "text" ? (i.raw += `
968
+ ` + n.raw, i.text += `
969
+ ` + n.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = i.text) : t.push(n);
970
+ continue;
971
+ }
972
+ if (e) {
973
+ const a = "Infinite loop on byte: " + e.charCodeAt(0);
974
+ if (this.options.silent) {
975
+ console.error(a);
976
+ break;
977
+ } else
978
+ throw new Error(a);
979
+ }
980
+ }
981
+ return this.state.top = !0, t;
982
+ }
983
+ inline(e, t = []) {
984
+ return this.inlineQueue.push({ src: e, tokens: t }), t;
985
+ }
986
+ /**
987
+ * Lexing/Compiling
988
+ */
989
+ inlineTokens(e, t = []) {
990
+ let n, i, o, r = e, a, c, g;
991
+ if (this.tokens.links) {
992
+ const f = Object.keys(this.tokens.links);
993
+ if (f.length > 0)
994
+ for (; (a = this.tokenizer.rules.inline.reflinkSearch.exec(r)) != null; )
995
+ f.includes(a[0].slice(a[0].lastIndexOf("[") + 1, -1)) && (r = r.slice(0, a.index) + "[" + "a".repeat(a[0].length - 2) + "]" + r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
996
+ }
997
+ for (; (a = this.tokenizer.rules.inline.blockSkip.exec(r)) != null; )
998
+ r = r.slice(0, a.index) + "[" + "a".repeat(a[0].length - 2) + "]" + r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
999
+ for (; (a = this.tokenizer.rules.inline.anyPunctuation.exec(r)) != null; )
1000
+ r = r.slice(0, a.index) + "++" + r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1001
+ for (; e; )
1002
+ if (c || (g = ""), c = !1, !(this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((f) => (n = f.call({ lexer: this }, e, t)) ? (e = e.substring(n.raw.length), t.push(n), !0) : !1))) {
1003
+ if (n = this.tokenizer.escape(e)) {
1004
+ e = e.substring(n.raw.length), t.push(n);
1005
+ continue;
1006
+ }
1007
+ if (n = this.tokenizer.tag(e)) {
1008
+ e = e.substring(n.raw.length), i = t[t.length - 1], i && n.type === "text" && i.type === "text" ? (i.raw += n.raw, i.text += n.text) : t.push(n);
1009
+ continue;
1010
+ }
1011
+ if (n = this.tokenizer.link(e)) {
1012
+ e = e.substring(n.raw.length), t.push(n);
1013
+ continue;
1014
+ }
1015
+ if (n = this.tokenizer.reflink(e, this.tokens.links)) {
1016
+ e = e.substring(n.raw.length), i = t[t.length - 1], i && n.type === "text" && i.type === "text" ? (i.raw += n.raw, i.text += n.text) : t.push(n);
1017
+ continue;
1018
+ }
1019
+ if (n = this.tokenizer.emStrong(e, r, g)) {
1020
+ e = e.substring(n.raw.length), t.push(n);
1021
+ continue;
1022
+ }
1023
+ if (n = this.tokenizer.codespan(e)) {
1024
+ e = e.substring(n.raw.length), t.push(n);
1025
+ continue;
1026
+ }
1027
+ if (n = this.tokenizer.br(e)) {
1028
+ e = e.substring(n.raw.length), t.push(n);
1029
+ continue;
1030
+ }
1031
+ if (n = this.tokenizer.del(e)) {
1032
+ e = e.substring(n.raw.length), t.push(n);
1033
+ continue;
1034
+ }
1035
+ if (n = this.tokenizer.autolink(e)) {
1036
+ e = e.substring(n.raw.length), t.push(n);
1037
+ continue;
1038
+ }
1039
+ if (!this.state.inLink && (n = this.tokenizer.url(e))) {
1040
+ e = e.substring(n.raw.length), t.push(n);
1041
+ continue;
1042
+ }
1043
+ if (o = e, this.options.extensions && this.options.extensions.startInline) {
1044
+ let f = 1 / 0;
1045
+ const T = e.slice(1);
1046
+ let h;
1047
+ this.options.extensions.startInline.forEach((b) => {
1048
+ h = b.call({ lexer: this }, T), typeof h == "number" && h >= 0 && (f = Math.min(f, h));
1049
+ }), f < 1 / 0 && f >= 0 && (o = e.substring(0, f + 1));
1050
+ }
1051
+ if (n = this.tokenizer.inlineText(o)) {
1052
+ e = e.substring(n.raw.length), n.raw.slice(-1) !== "_" && (g = n.raw.slice(-1)), c = !0, i = t[t.length - 1], i && i.type === "text" ? (i.raw += n.raw, i.text += n.text) : t.push(n);
1053
+ continue;
1054
+ }
1055
+ if (e) {
1056
+ const f = "Infinite loop on byte: " + e.charCodeAt(0);
1057
+ if (this.options.silent) {
1058
+ console.error(f);
1059
+ break;
1060
+ } else
1061
+ throw new Error(f);
1062
+ }
1063
+ }
1064
+ return t;
1065
+ }
1066
+ }
1067
+ class Ze {
1068
+ constructor(e) {
1069
+ A(this, "options");
1070
+ this.options = e || ue;
1071
+ }
1072
+ code(e, t, n) {
1073
+ var o;
1074
+ const i = (o = (t || "").match(/^\S*/)) == null ? void 0 : o[0];
1075
+ return e = e.replace(/\n$/, "") + `
1076
+ `, i ? '<pre><code class="language-' + B(i) + '">' + (n ? e : B(e, !0)) + `</code></pre>
1077
+ ` : "<pre><code>" + (n ? e : B(e, !0)) + `</code></pre>
1078
+ `;
1079
+ }
1080
+ blockquote(e) {
1081
+ return `<blockquote>
1082
+ ${e}</blockquote>
1083
+ `;
1084
+ }
1085
+ html(e, t) {
1086
+ return e;
1087
+ }
1088
+ heading(e, t, n) {
1089
+ return `<h${t}>${e}</h${t}>
1090
+ `;
1091
+ }
1092
+ hr() {
1093
+ return `<hr>
1094
+ `;
1095
+ }
1096
+ list(e, t, n) {
1097
+ const i = t ? "ol" : "ul", o = t && n !== 1 ? ' start="' + n + '"' : "";
1098
+ return "<" + i + o + `>
1099
+ ` + e + "</" + i + `>
1100
+ `;
1101
+ }
1102
+ listitem(e, t, n) {
1103
+ return `<li>${e}</li>
1104
+ `;
1105
+ }
1106
+ checkbox(e) {
1107
+ return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
1108
+ }
1109
+ paragraph(e) {
1110
+ return `<p>${e}</p>
1111
+ `;
1112
+ }
1113
+ table(e, t) {
1114
+ return t && (t = `<tbody>${t}</tbody>`), `<table>
1115
+ <thead>
1116
+ ` + e + `</thead>
1117
+ ` + t + `</table>
1118
+ `;
1119
+ }
1120
+ tablerow(e) {
1121
+ return `<tr>
1122
+ ${e}</tr>
1123
+ `;
1124
+ }
1125
+ tablecell(e, t) {
1126
+ const n = t.header ? "th" : "td";
1127
+ return (t.align ? `<${n} align="${t.align}">` : `<${n}>`) + e + `</${n}>
1128
+ `;
1129
+ }
1130
+ /**
1131
+ * span level renderer
1132
+ */
1133
+ strong(e) {
1134
+ return `<strong>${e}</strong>`;
1135
+ }
1136
+ em(e) {
1137
+ return `<em>${e}</em>`;
1138
+ }
1139
+ codespan(e) {
1140
+ return `<code>${e}</code>`;
1141
+ }
1142
+ br() {
1143
+ return "<br>";
1144
+ }
1145
+ del(e) {
1146
+ return `<del>${e}</del>`;
1147
+ }
1148
+ link(e, t, n) {
1149
+ const i = rn(e);
1150
+ if (i === null)
1151
+ return n;
1152
+ e = i;
1153
+ let o = '<a href="' + e + '"';
1154
+ return t && (o += ' title="' + t + '"'), o += ">" + n + "</a>", o;
1155
+ }
1156
+ image(e, t, n) {
1157
+ const i = rn(e);
1158
+ if (i === null)
1159
+ return n;
1160
+ e = i;
1161
+ let o = `<img src="${e}" alt="${n}"`;
1162
+ return t && (o += ` title="${t}"`), o += ">", o;
1163
+ }
1164
+ text(e) {
1165
+ return e;
1166
+ }
1167
+ }
1168
+ class Lt {
1169
+ // no need for block level renderers
1170
+ strong(e) {
1171
+ return e;
1172
+ }
1173
+ em(e) {
1174
+ return e;
1175
+ }
1176
+ codespan(e) {
1177
+ return e;
1178
+ }
1179
+ del(e) {
1180
+ return e;
1181
+ }
1182
+ html(e) {
1183
+ return e;
1184
+ }
1185
+ text(e) {
1186
+ return e;
1187
+ }
1188
+ link(e, t, n) {
1189
+ return "" + n;
1190
+ }
1191
+ image(e, t, n) {
1192
+ return "" + n;
1193
+ }
1194
+ br() {
1195
+ return "";
1196
+ }
1197
+ }
1198
+ class K {
1199
+ constructor(e) {
1200
+ A(this, "options");
1201
+ A(this, "renderer");
1202
+ A(this, "textRenderer");
1203
+ this.options = e || ue, this.options.renderer = this.options.renderer || new Ze(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.textRenderer = new Lt();
1204
+ }
1205
+ /**
1206
+ * Static Parse Method
1207
+ */
1208
+ static parse(e, t) {
1209
+ return new K(t).parse(e);
1210
+ }
1211
+ /**
1212
+ * Static Parse Inline Method
1213
+ */
1214
+ static parseInline(e, t) {
1215
+ return new K(t).parseInline(e);
1216
+ }
1217
+ /**
1218
+ * Parse Loop
1219
+ */
1220
+ parse(e, t = !0) {
1221
+ let n = "";
1222
+ for (let i = 0; i < e.length; i++) {
1223
+ const o = e[i];
1224
+ if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[o.type]) {
1225
+ const r = o, a = this.options.extensions.renderers[r.type].call({ parser: this }, r);
1226
+ if (a !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(r.type)) {
1227
+ n += a || "";
1228
+ continue;
1229
+ }
1230
+ }
1231
+ switch (o.type) {
1232
+ case "space":
1233
+ continue;
1234
+ case "hr": {
1235
+ n += this.renderer.hr();
1236
+ continue;
1237
+ }
1238
+ case "heading": {
1239
+ const r = o;
1240
+ n += this.renderer.heading(this.parseInline(r.tokens), r.depth, bi(this.parseInline(r.tokens, this.textRenderer)));
1241
+ continue;
1242
+ }
1243
+ case "code": {
1244
+ const r = o;
1245
+ n += this.renderer.code(r.text, r.lang, !!r.escaped);
1246
+ continue;
1247
+ }
1248
+ case "table": {
1249
+ const r = o;
1250
+ let a = "", c = "";
1251
+ for (let f = 0; f < r.header.length; f++)
1252
+ c += this.renderer.tablecell(this.parseInline(r.header[f].tokens), { header: !0, align: r.align[f] });
1253
+ a += this.renderer.tablerow(c);
1254
+ let g = "";
1255
+ for (let f = 0; f < r.rows.length; f++) {
1256
+ const T = r.rows[f];
1257
+ c = "";
1258
+ for (let h = 0; h < T.length; h++)
1259
+ c += this.renderer.tablecell(this.parseInline(T[h].tokens), { header: !1, align: r.align[h] });
1260
+ g += this.renderer.tablerow(c);
1261
+ }
1262
+ n += this.renderer.table(a, g);
1263
+ continue;
1264
+ }
1265
+ case "blockquote": {
1266
+ const r = o, a = this.parse(r.tokens);
1267
+ n += this.renderer.blockquote(a);
1268
+ continue;
1269
+ }
1270
+ case "list": {
1271
+ const r = o, a = r.ordered, c = r.start, g = r.loose;
1272
+ let f = "";
1273
+ for (let T = 0; T < r.items.length; T++) {
1274
+ const h = r.items[T], b = h.checked, m = h.task;
1275
+ let p = "";
1276
+ if (h.task) {
1277
+ const _ = this.renderer.checkbox(!!b);
1278
+ g ? h.tokens.length > 0 && h.tokens[0].type === "paragraph" ? (h.tokens[0].text = _ + " " + h.tokens[0].text, h.tokens[0].tokens && h.tokens[0].tokens.length > 0 && h.tokens[0].tokens[0].type === "text" && (h.tokens[0].tokens[0].text = _ + " " + h.tokens[0].tokens[0].text)) : h.tokens.unshift({
1279
+ type: "text",
1280
+ text: _ + " "
1281
+ }) : p += _ + " ";
1282
+ }
1283
+ p += this.parse(h.tokens, g), f += this.renderer.listitem(p, m, !!b);
1284
+ }
1285
+ n += this.renderer.list(f, a, c);
1286
+ continue;
1287
+ }
1288
+ case "html": {
1289
+ const r = o;
1290
+ n += this.renderer.html(r.text, r.block);
1291
+ continue;
1292
+ }
1293
+ case "paragraph": {
1294
+ const r = o;
1295
+ n += this.renderer.paragraph(this.parseInline(r.tokens));
1296
+ continue;
1297
+ }
1298
+ case "text": {
1299
+ let r = o, a = r.tokens ? this.parseInline(r.tokens) : r.text;
1300
+ for (; i + 1 < e.length && e[i + 1].type === "text"; )
1301
+ r = e[++i], a += `
1302
+ ` + (r.tokens ? this.parseInline(r.tokens) : r.text);
1303
+ n += t ? this.renderer.paragraph(a) : a;
1304
+ continue;
1305
+ }
1306
+ default: {
1307
+ const r = 'Token with "' + o.type + '" type was not found.';
1308
+ if (this.options.silent)
1309
+ return console.error(r), "";
1310
+ throw new Error(r);
1311
+ }
1312
+ }
1313
+ }
1314
+ return n;
1315
+ }
1316
+ /**
1317
+ * Parse Inline Tokens
1318
+ */
1319
+ parseInline(e, t) {
1320
+ t = t || this.renderer;
1321
+ let n = "";
1322
+ for (let i = 0; i < e.length; i++) {
1323
+ const o = e[i];
1324
+ if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[o.type]) {
1325
+ const r = this.options.extensions.renderers[o.type].call({ parser: this }, o);
1326
+ if (r !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(o.type)) {
1327
+ n += r || "";
1328
+ continue;
1329
+ }
1330
+ }
1331
+ switch (o.type) {
1332
+ case "escape": {
1333
+ const r = o;
1334
+ n += t.text(r.text);
1335
+ break;
1336
+ }
1337
+ case "html": {
1338
+ const r = o;
1339
+ n += t.html(r.text);
1340
+ break;
1341
+ }
1342
+ case "link": {
1343
+ const r = o;
1344
+ n += t.link(r.href, r.title, this.parseInline(r.tokens, t));
1345
+ break;
1346
+ }
1347
+ case "image": {
1348
+ const r = o;
1349
+ n += t.image(r.href, r.title, r.text);
1350
+ break;
1351
+ }
1352
+ case "strong": {
1353
+ const r = o;
1354
+ n += t.strong(this.parseInline(r.tokens, t));
1355
+ break;
1356
+ }
1357
+ case "em": {
1358
+ const r = o;
1359
+ n += t.em(this.parseInline(r.tokens, t));
1360
+ break;
1361
+ }
1362
+ case "codespan": {
1363
+ const r = o;
1364
+ n += t.codespan(r.text);
1365
+ break;
1366
+ }
1367
+ case "br": {
1368
+ n += t.br();
1369
+ break;
1370
+ }
1371
+ case "del": {
1372
+ const r = o;
1373
+ n += t.del(this.parseInline(r.tokens, t));
1374
+ break;
1375
+ }
1376
+ case "text": {
1377
+ const r = o;
1378
+ n += t.text(r.text);
1379
+ break;
1380
+ }
1381
+ default: {
1382
+ const r = 'Token with "' + o.type + '" type was not found.';
1383
+ if (this.options.silent)
1384
+ return console.error(r), "";
1385
+ throw new Error(r);
1386
+ }
1387
+ }
1388
+ }
1389
+ return n;
1390
+ }
1391
+ }
1392
+ class ve {
1393
+ constructor(e) {
1394
+ A(this, "options");
1395
+ this.options = e || ue;
1396
+ }
1397
+ /**
1398
+ * Process markdown before marked
1399
+ */
1400
+ preprocess(e) {
1401
+ return e;
1402
+ }
1403
+ /**
1404
+ * Process HTML after marked is finished
1405
+ */
1406
+ postprocess(e) {
1407
+ return e;
1408
+ }
1409
+ /**
1410
+ * Process all tokens before walk tokens
1411
+ */
1412
+ processAllTokens(e) {
1413
+ return e;
1414
+ }
1415
+ }
1416
+ A(ve, "passThroughHooks", /* @__PURE__ */ new Set([
1417
+ "preprocess",
1418
+ "postprocess",
1419
+ "processAllTokens"
1420
+ ]));
1421
+ var ce, bt, Ln;
1422
+ class Yi {
1423
+ constructor(...e) {
1424
+ en(this, ce);
1425
+ A(this, "defaults", _t());
1426
+ A(this, "options", this.setOptions);
1427
+ A(this, "parse", Ue(this, ce, bt).call(this, Q.lex, K.parse));
1428
+ A(this, "parseInline", Ue(this, ce, bt).call(this, Q.lexInline, K.parseInline));
1429
+ A(this, "Parser", K);
1430
+ A(this, "Renderer", Ze);
1431
+ A(this, "TextRenderer", Lt);
1432
+ A(this, "Lexer", Q);
1433
+ A(this, "Tokenizer", Ge);
1434
+ A(this, "Hooks", ve);
1435
+ this.use(...e);
1436
+ }
1437
+ /**
1438
+ * Run callback for every token
1439
+ */
1440
+ walkTokens(e, t) {
1441
+ var i, o;
1442
+ let n = [];
1443
+ for (const r of e)
1444
+ switch (n = n.concat(t.call(this, r)), r.type) {
1445
+ case "table": {
1446
+ const a = r;
1447
+ for (const c of a.header)
1448
+ n = n.concat(this.walkTokens(c.tokens, t));
1449
+ for (const c of a.rows)
1450
+ for (const g of c)
1451
+ n = n.concat(this.walkTokens(g.tokens, t));
1452
+ break;
1453
+ }
1454
+ case "list": {
1455
+ const a = r;
1456
+ n = n.concat(this.walkTokens(a.items, t));
1457
+ break;
1458
+ }
1459
+ default: {
1460
+ const a = r;
1461
+ (o = (i = this.defaults.extensions) == null ? void 0 : i.childTokens) != null && o[a.type] ? this.defaults.extensions.childTokens[a.type].forEach((c) => {
1462
+ const g = a[c].flat(1 / 0);
1463
+ n = n.concat(this.walkTokens(g, t));
1464
+ }) : a.tokens && (n = n.concat(this.walkTokens(a.tokens, t)));
1465
+ }
1466
+ }
1467
+ return n;
1468
+ }
1469
+ use(...e) {
1470
+ const t = this.defaults.extensions || { renderers: {}, childTokens: {} };
1471
+ return e.forEach((n) => {
1472
+ const i = { ...n };
1473
+ if (i.async = this.defaults.async || i.async || !1, n.extensions && (n.extensions.forEach((o) => {
1474
+ if (!o.name)
1475
+ throw new Error("extension name required");
1476
+ if ("renderer" in o) {
1477
+ const r = t.renderers[o.name];
1478
+ r ? t.renderers[o.name] = function(...a) {
1479
+ let c = o.renderer.apply(this, a);
1480
+ return c === !1 && (c = r.apply(this, a)), c;
1481
+ } : t.renderers[o.name] = o.renderer;
1482
+ }
1483
+ if ("tokenizer" in o) {
1484
+ if (!o.level || o.level !== "block" && o.level !== "inline")
1485
+ throw new Error("extension level must be 'block' or 'inline'");
1486
+ const r = t[o.level];
1487
+ r ? r.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]));
1488
+ }
1489
+ "childTokens" in o && o.childTokens && (t.childTokens[o.name] = o.childTokens);
1490
+ }), i.extensions = t), n.renderer) {
1491
+ const o = this.defaults.renderer || new Ze(this.defaults);
1492
+ for (const r in n.renderer) {
1493
+ if (!(r in o))
1494
+ throw new Error(`renderer '${r}' does not exist`);
1495
+ if (r === "options")
1496
+ continue;
1497
+ const a = r, c = n.renderer[a], g = o[a];
1498
+ o[a] = (...f) => {
1499
+ let T = c.apply(o, f);
1500
+ return T === !1 && (T = g.apply(o, f)), T || "";
1501
+ };
1502
+ }
1503
+ i.renderer = o;
1504
+ }
1505
+ if (n.tokenizer) {
1506
+ const o = this.defaults.tokenizer || new Ge(this.defaults);
1507
+ for (const r in n.tokenizer) {
1508
+ if (!(r in o))
1509
+ throw new Error(`tokenizer '${r}' does not exist`);
1510
+ if (["options", "rules", "lexer"].includes(r))
1511
+ continue;
1512
+ const a = r, c = n.tokenizer[a], g = o[a];
1513
+ o[a] = (...f) => {
1514
+ let T = c.apply(o, f);
1515
+ return T === !1 && (T = g.apply(o, f)), T;
1516
+ };
1517
+ }
1518
+ i.tokenizer = o;
1519
+ }
1520
+ if (n.hooks) {
1521
+ const o = this.defaults.hooks || new ve();
1522
+ for (const r in n.hooks) {
1523
+ if (!(r in o))
1524
+ throw new Error(`hook '${r}' does not exist`);
1525
+ if (r === "options")
1526
+ continue;
1527
+ const a = r, c = n.hooks[a], g = o[a];
1528
+ ve.passThroughHooks.has(r) ? o[a] = (f) => {
1529
+ if (this.defaults.async)
1530
+ return Promise.resolve(c.call(o, f)).then((h) => g.call(o, h));
1531
+ const T = c.call(o, f);
1532
+ return g.call(o, T);
1533
+ } : o[a] = (...f) => {
1534
+ let T = c.apply(o, f);
1535
+ return T === !1 && (T = g.apply(o, f)), T;
1536
+ };
1537
+ }
1538
+ i.hooks = o;
1539
+ }
1540
+ if (n.walkTokens) {
1541
+ const o = this.defaults.walkTokens, r = n.walkTokens;
1542
+ i.walkTokens = function(a) {
1543
+ let c = [];
1544
+ return c.push(r.call(this, a)), o && (c = c.concat(o.call(this, a))), c;
1545
+ };
1546
+ }
1547
+ this.defaults = { ...this.defaults, ...i };
1548
+ }), this;
1549
+ }
1550
+ setOptions(e) {
1551
+ return this.defaults = { ...this.defaults, ...e }, this;
1552
+ }
1553
+ lexer(e, t) {
1554
+ return Q.lex(e, t ?? this.defaults);
1555
+ }
1556
+ parser(e, t) {
1557
+ return K.parse(e, t ?? this.defaults);
1558
+ }
1559
+ }
1560
+ ce = new WeakSet(), bt = function(e, t) {
1561
+ return (n, i) => {
1562
+ const o = { ...i }, r = { ...this.defaults, ...o };
1563
+ this.defaults.async === !0 && o.async === !1 && (r.silent || console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."), r.async = !0);
1564
+ const a = Ue(this, ce, Ln).call(this, !!r.silent, !!r.async);
1565
+ if (typeof n > "u" || n === null)
1566
+ return a(new Error("marked(): input parameter is undefined or null"));
1567
+ if (typeof n != "string")
1568
+ return a(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
1569
+ if (r.hooks && (r.hooks.options = r), r.async)
1570
+ return Promise.resolve(r.hooks ? r.hooks.preprocess(n) : n).then((c) => e(c, r)).then((c) => r.hooks ? r.hooks.processAllTokens(c) : c).then((c) => r.walkTokens ? Promise.all(this.walkTokens(c, r.walkTokens)).then(() => c) : c).then((c) => t(c, r)).then((c) => r.hooks ? r.hooks.postprocess(c) : c).catch(a);
1571
+ try {
1572
+ r.hooks && (n = r.hooks.preprocess(n));
1573
+ let c = e(n, r);
1574
+ r.hooks && (c = r.hooks.processAllTokens(c)), r.walkTokens && this.walkTokens(c, r.walkTokens);
1575
+ let g = t(c, r);
1576
+ return r.hooks && (g = r.hooks.postprocess(g)), g;
1577
+ } catch (c) {
1578
+ return a(c);
1579
+ }
1580
+ };
1581
+ }, Ln = function(e, t) {
1582
+ return (n) => {
1583
+ if (n.message += `
1584
+ Please report this to https://github.com/markedjs/marked.`, e) {
1585
+ const i = "<p>An error occurred:</p><pre>" + B(n.message + "", !0) + "</pre>";
1586
+ return t ? Promise.resolve(i) : i;
1587
+ }
1588
+ if (t)
1589
+ return Promise.reject(n);
1590
+ throw n;
1591
+ };
1592
+ };
1593
+ const ae = new Yi();
1594
+ function y(l, e) {
1595
+ return ae.parse(l, e);
1596
+ }
1597
+ y.options = y.setOptions = function(l) {
1598
+ return ae.setOptions(l), y.defaults = ae.defaults, bn(y.defaults), y;
1599
+ };
1600
+ y.getDefaults = _t;
1601
+ y.defaults = ue;
1602
+ y.use = function(...l) {
1603
+ return ae.use(...l), y.defaults = ae.defaults, bn(y.defaults), y;
1604
+ };
1605
+ y.walkTokens = function(l, e) {
1606
+ return ae.walkTokens(l, e);
1607
+ };
1608
+ y.parseInline = ae.parseInline;
1609
+ y.Parser = K;
1610
+ y.parser = K.parse;
1611
+ y.Renderer = Ze;
1612
+ y.TextRenderer = Lt;
1613
+ y.Lexer = Q;
1614
+ y.lexer = Q.lex;
1615
+ y.Tokenizer = Ge;
1616
+ y.Hooks = ve;
1617
+ y.parse = y;
1618
+ y.options;
1619
+ y.setOptions;
1620
+ y.use;
1621
+ y.walkTokens;
1622
+ y.parseInline;
1623
+ K.parse;
1624
+ Q.lex;
1625
+ /*! @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 */
1626
+ const {
1627
+ entries: vn,
1628
+ setPrototypeOf: an,
1629
+ isFrozen: Vi,
1630
+ getPrototypeOf: Xi,
1631
+ getOwnPropertyDescriptor: Qi
1632
+ } = Object;
1633
+ let {
1634
+ freeze: U,
1635
+ seal: j,
1636
+ create: Tt
1637
+ } = Object, {
1638
+ apply: wt,
1639
+ construct: xt
1640
+ } = typeof Reflect < "u" && Reflect;
1641
+ U || (U = function(e) {
1642
+ return e;
1643
+ });
1644
+ j || (j = function(e) {
1645
+ return e;
1646
+ });
1647
+ wt || (wt = function(e, t) {
1648
+ for (var n = arguments.length, i = new Array(n > 2 ? n - 2 : 0), o = 2; o < n; o++)
1649
+ i[o - 2] = arguments[o];
1650
+ return e.apply(t, i);
1651
+ });
1652
+ xt || (xt = function(e) {
1653
+ for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), i = 1; i < t; i++)
1654
+ n[i - 1] = arguments[i];
1655
+ return new e(...n);
1656
+ });
1657
+ const Be = F(Array.prototype.forEach), Ki = F(Array.prototype.lastIndexOf), cn = F(Array.prototype.pop), ye = F(Array.prototype.push), Ji = F(Array.prototype.splice), je = F(String.prototype.toLowerCase), pt = F(String.prototype.toString), ht = F(String.prototype.match), Ee = F(String.prototype.replace), er = F(String.prototype.indexOf), tr = F(String.prototype.trim), Z = F(Object.prototype.hasOwnProperty), P = F(RegExp.prototype.test), Ae = nr(TypeError);
1658
+ function F(l) {
1659
+ return function(e) {
1660
+ e instanceof RegExp && (e.lastIndex = 0);
1661
+ for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), i = 1; i < t; i++)
1662
+ n[i - 1] = arguments[i];
1663
+ return wt(l, e, n);
1664
+ };
1665
+ }
1666
+ function nr(l) {
1667
+ return function() {
1668
+ for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
1669
+ t[n] = arguments[n];
1670
+ return xt(l, t);
1671
+ };
1672
+ }
1673
+ function x(l, e) {
1674
+ let t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : je;
1675
+ an && an(l, null);
1676
+ let n = e.length;
1677
+ for (; n--; ) {
1678
+ let i = e[n];
1679
+ if (typeof i == "string") {
1680
+ const o = t(i);
1681
+ o !== i && (Vi(e) || (e[n] = o), i = o);
1682
+ }
1683
+ l[i] = !0;
1684
+ }
1685
+ return l;
1686
+ }
1687
+ function ir(l) {
1688
+ for (let e = 0; e < l.length; e++)
1689
+ Z(l, e) || (l[e] = null);
1690
+ return l;
1691
+ }
1692
+ function X(l) {
1693
+ const e = Tt(null);
1694
+ for (const [t, n] of vn(l))
1695
+ Z(l, t) && (Array.isArray(n) ? e[t] = ir(n) : n && typeof n == "object" && n.constructor === Object ? e[t] = X(n) : e[t] = n);
1696
+ return e;
1697
+ }
1698
+ function Se(l, e) {
1699
+ for (; l !== null; ) {
1700
+ const n = Qi(l, e);
1701
+ if (n) {
1702
+ if (n.get)
1703
+ return F(n.get);
1704
+ if (typeof n.value == "function")
1705
+ return F(n.value);
1706
+ }
1707
+ l = Xi(l);
1708
+ }
1709
+ function t() {
1710
+ return null;
1711
+ }
1712
+ return t;
1713
+ }
1714
+ const un = U(["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"]), ft = U(["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"]), dt = U(["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"]), rr = U(["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"]), mt = U(["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"]), sr = U(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), pn = U(["#text"]), hn = U(["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 = U(["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"]), fn = U(["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"]), We = U(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), or = j(/\{\{[\w\W]*|[\w\W]*\}\}/gm), lr = j(/<%[\w\W]*|[\w\W]*%>/gm), ar = j(/\$\{[\w\W]*/gm), cr = j(/^data-[\-\w.\u00B7-\uFFFF]+$/), ur = j(/^aria-[\-\w]+$/), In = j(
1715
+ /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
1716
+ // eslint-disable-line no-useless-escape
1717
+ ), pr = j(/^(?:\w+script|data):/i), hr = j(
1718
+ /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
1719
+ // eslint-disable-line no-control-regex
1720
+ ), Cn = j(/^html$/i), fr = j(/^[a-z][.\w]*(-[.\w]+)+$/i);
1721
+ var dn = /* @__PURE__ */ Object.freeze({
1722
+ __proto__: null,
1723
+ ARIA_ATTR: ur,
1724
+ ATTR_WHITESPACE: hr,
1725
+ CUSTOM_ELEMENT: fr,
1726
+ DATA_ATTR: cr,
1727
+ DOCTYPE_NAME: Cn,
1728
+ ERB_EXPR: lr,
1729
+ IS_ALLOWED_URI: In,
1730
+ IS_SCRIPT_OR_DATA: pr,
1731
+ MUSTACHE_EXPR: or,
1732
+ TMPLIT_EXPR: ar
1733
+ });
1734
+ const Re = {
1735
+ element: 1,
1736
+ text: 3,
1737
+ // Deprecated
1738
+ progressingInstruction: 7,
1739
+ comment: 8,
1740
+ document: 9
1741
+ }, dr = function() {
1742
+ return typeof window > "u" ? null : window;
1743
+ }, mr = function(e, t) {
1744
+ if (typeof e != "object" || typeof e.createPolicy != "function")
1745
+ return null;
1746
+ let n = null;
1747
+ const i = "data-tt-policy-suffix";
1748
+ t && t.hasAttribute(i) && (n = t.getAttribute(i));
1749
+ const o = "dompurify" + (n ? "#" + n : "");
1750
+ try {
1751
+ return e.createPolicy(o, {
1752
+ createHTML(r) {
1753
+ return r;
1754
+ },
1755
+ createScriptURL(r) {
1756
+ return r;
1757
+ }
1758
+ });
1759
+ } catch {
1760
+ return console.warn("TrustedTypes policy " + o + " could not be created."), null;
1761
+ }
1762
+ }, mn = function() {
1763
+ return {
1764
+ afterSanitizeAttributes: [],
1765
+ afterSanitizeElements: [],
1766
+ afterSanitizeShadowDOM: [],
1767
+ beforeSanitizeAttributes: [],
1768
+ beforeSanitizeElements: [],
1769
+ beforeSanitizeShadowDOM: [],
1770
+ uponSanitizeAttribute: [],
1771
+ uponSanitizeElement: [],
1772
+ uponSanitizeShadowNode: []
1773
+ };
1774
+ };
1775
+ function On() {
1776
+ let l = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : dr();
1777
+ const e = (k) => On(k);
1778
+ if (e.version = "3.3.1", e.removed = [], !l || !l.document || l.document.nodeType !== Re.document || !l.Element)
1779
+ return e.isSupported = !1, e;
1780
+ let {
1781
+ document: t
1782
+ } = l;
1783
+ const n = t, i = n.currentScript, {
1784
+ DocumentFragment: o,
1785
+ HTMLTemplateElement: r,
1786
+ Node: a,
1787
+ Element: c,
1788
+ NodeFilter: g,
1789
+ NamedNodeMap: f = l.NamedNodeMap || l.MozNamedAttrMap,
1790
+ HTMLFormElement: T,
1791
+ DOMParser: h,
1792
+ trustedTypes: b
1793
+ } = l, m = c.prototype, p = Se(m, "cloneNode"), _ = Se(m, "remove"), I = Se(m, "nextSibling"), q = Se(m, "childNodes"), W = Se(m, "parentNode");
1794
+ if (typeof r == "function") {
1795
+ const k = t.createElement("template");
1796
+ k.content && k.content.ownerDocument && (t = k.content.ownerDocument);
1797
+ }
1798
+ let C, J = "";
1799
+ const {
1800
+ implementation: Ve,
1801
+ createNodeIterator: Dn,
1802
+ createDocumentFragment: Nn,
1803
+ getElementsByTagName: Mn
1804
+ } = t, {
1805
+ importNode: zn
1806
+ } = n;
1807
+ let z = mn();
1808
+ e.isSupported = typeof vn == "function" && typeof W == "function" && Ve && Ve.createHTMLDocument !== void 0;
1809
+ const {
1810
+ MUSTACHE_EXPR: Xe,
1811
+ ERB_EXPR: Qe,
1812
+ TMPLIT_EXPR: Ke,
1813
+ DATA_ATTR: Pn,
1814
+ ARIA_ATTR: $n,
1815
+ IS_SCRIPT_OR_DATA: Un,
1816
+ ATTR_WHITESPACE: vt,
1817
+ CUSTOM_ELEMENT: Fn
1818
+ } = dn;
1819
+ let {
1820
+ IS_ALLOWED_URI: It
1821
+ } = dn, O = null;
1822
+ const Ct = x({}, [...un, ...ft, ...dt, ...mt, ...pn]);
1823
+ let D = null;
1824
+ const Ot = x({}, [...hn, ...gt, ...fn, ...We]);
1825
+ let R = Object.seal(Tt(null, {
1826
+ tagNameCheck: {
1827
+ writable: !0,
1828
+ configurable: !1,
1829
+ enumerable: !0,
1830
+ value: null
1831
+ },
1832
+ attributeNameCheck: {
1833
+ writable: !0,
1834
+ configurable: !1,
1835
+ enumerable: !0,
1836
+ value: null
1837
+ },
1838
+ allowCustomizedBuiltInElements: {
1839
+ writable: !0,
1840
+ configurable: !1,
1841
+ enumerable: !0,
1842
+ value: !1
1843
+ }
1844
+ })), Te = null, Je = null;
1845
+ const pe = Object.seal(Tt(null, {
1846
+ tagCheck: {
1847
+ writable: !0,
1848
+ configurable: !1,
1849
+ enumerable: !0,
1850
+ value: null
1851
+ },
1852
+ attributeCheck: {
1853
+ writable: !0,
1854
+ configurable: !1,
1855
+ enumerable: !0,
1856
+ value: null
1857
+ }
1858
+ }));
1859
+ let Dt = !0, et = !0, Nt = !1, Mt = !0, he = !1, Oe = !0, oe = !1, tt = !1, nt = !1, fe = !1, De = !1, Ne = !1, zt = !0, Pt = !1;
1860
+ const Hn = "user-content-";
1861
+ let it = !0, we = !1, de = {}, Y = null;
1862
+ const rt = x({}, ["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"]);
1863
+ let $t = null;
1864
+ const Ut = x({}, ["audio", "video", "img", "source", "image", "track"]);
1865
+ let st = null;
1866
+ const Ft = x({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), Me = "http://www.w3.org/1998/Math/MathML", ze = "http://www.w3.org/2000/svg", ee = "http://www.w3.org/1999/xhtml";
1867
+ let me = ee, ot = !1, lt = null;
1868
+ const Bn = x({}, [Me, ze, ee], pt);
1869
+ let Pe = x({}, ["mi", "mo", "mn", "ms", "mtext"]), $e = x({}, ["annotation-xml"]);
1870
+ const Wn = x({}, ["title", "style", "font", "a", "script"]);
1871
+ let xe = null;
1872
+ const jn = ["application/xhtml+xml", "text/html"], Gn = "text/html";
1873
+ let v = null, ge = null;
1874
+ const qn = t.createElement("form"), Ht = function(s) {
1875
+ return s instanceof RegExp || s instanceof Function;
1876
+ }, at = function() {
1877
+ let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1878
+ if (!(ge && ge === s)) {
1879
+ if ((!s || typeof s != "object") && (s = {}), s = X(s), xe = // eslint-disable-next-line unicorn/prefer-includes
1880
+ jn.indexOf(s.PARSER_MEDIA_TYPE) === -1 ? Gn : s.PARSER_MEDIA_TYPE, v = xe === "application/xhtml+xml" ? pt : je, O = Z(s, "ALLOWED_TAGS") ? x({}, s.ALLOWED_TAGS, v) : Ct, D = Z(s, "ALLOWED_ATTR") ? x({}, s.ALLOWED_ATTR, v) : Ot, lt = Z(s, "ALLOWED_NAMESPACES") ? x({}, s.ALLOWED_NAMESPACES, pt) : Bn, st = Z(s, "ADD_URI_SAFE_ATTR") ? x(X(Ft), s.ADD_URI_SAFE_ATTR, v) : Ft, $t = Z(s, "ADD_DATA_URI_TAGS") ? x(X(Ut), s.ADD_DATA_URI_TAGS, v) : Ut, Y = Z(s, "FORBID_CONTENTS") ? x({}, s.FORBID_CONTENTS, v) : rt, Te = Z(s, "FORBID_TAGS") ? x({}, s.FORBID_TAGS, v) : X({}), Je = Z(s, "FORBID_ATTR") ? x({}, s.FORBID_ATTR, v) : X({}), de = Z(s, "USE_PROFILES") ? s.USE_PROFILES : !1, Dt = s.ALLOW_ARIA_ATTR !== !1, et = s.ALLOW_DATA_ATTR !== !1, Nt = s.ALLOW_UNKNOWN_PROTOCOLS || !1, Mt = s.ALLOW_SELF_CLOSE_IN_ATTR !== !1, he = s.SAFE_FOR_TEMPLATES || !1, Oe = s.SAFE_FOR_XML !== !1, oe = s.WHOLE_DOCUMENT || !1, fe = s.RETURN_DOM || !1, De = s.RETURN_DOM_FRAGMENT || !1, Ne = s.RETURN_TRUSTED_TYPE || !1, nt = s.FORCE_BODY || !1, zt = s.SANITIZE_DOM !== !1, Pt = s.SANITIZE_NAMED_PROPS || !1, it = s.KEEP_CONTENT !== !1, we = s.IN_PLACE || !1, It = s.ALLOWED_URI_REGEXP || In, me = s.NAMESPACE || ee, Pe = s.MATHML_TEXT_INTEGRATION_POINTS || Pe, $e = s.HTML_INTEGRATION_POINTS || $e, R = s.CUSTOM_ELEMENT_HANDLING || {}, s.CUSTOM_ELEMENT_HANDLING && Ht(s.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (R.tagNameCheck = s.CUSTOM_ELEMENT_HANDLING.tagNameCheck), s.CUSTOM_ELEMENT_HANDLING && Ht(s.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (R.attributeNameCheck = s.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), s.CUSTOM_ELEMENT_HANDLING && typeof s.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (R.allowCustomizedBuiltInElements = s.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), he && (et = !1), De && (fe = !0), de && (O = x({}, pn), D = [], de.html === !0 && (x(O, un), x(D, hn)), de.svg === !0 && (x(O, ft), x(D, gt), x(D, We)), de.svgFilters === !0 && (x(O, dt), x(D, gt), x(D, We)), de.mathMl === !0 && (x(O, mt), x(D, fn), x(D, We))), s.ADD_TAGS && (typeof s.ADD_TAGS == "function" ? pe.tagCheck = s.ADD_TAGS : (O === Ct && (O = X(O)), x(O, s.ADD_TAGS, v))), s.ADD_ATTR && (typeof s.ADD_ATTR == "function" ? pe.attributeCheck = s.ADD_ATTR : (D === Ot && (D = X(D)), x(D, s.ADD_ATTR, v))), s.ADD_URI_SAFE_ATTR && x(st, s.ADD_URI_SAFE_ATTR, v), s.FORBID_CONTENTS && (Y === rt && (Y = X(Y)), x(Y, s.FORBID_CONTENTS, v)), s.ADD_FORBID_CONTENTS && (Y === rt && (Y = X(Y)), x(Y, s.ADD_FORBID_CONTENTS, v)), it && (O["#text"] = !0), oe && x(O, ["html", "head", "body"]), O.table && (x(O, ["tbody"]), delete Te.tbody), s.TRUSTED_TYPES_POLICY) {
1881
+ if (typeof s.TRUSTED_TYPES_POLICY.createHTML != "function")
1882
+ throw Ae('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
1883
+ if (typeof s.TRUSTED_TYPES_POLICY.createScriptURL != "function")
1884
+ throw Ae('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
1885
+ C = s.TRUSTED_TYPES_POLICY, J = C.createHTML("");
1886
+ } else
1887
+ C === void 0 && (C = mr(b, i)), C !== null && typeof J == "string" && (J = C.createHTML(""));
1888
+ U && U(s), ge = s;
1889
+ }
1890
+ }, Bt = x({}, [...ft, ...dt, ...rr]), Wt = x({}, [...mt, ...sr]), Zn = function(s) {
1891
+ let u = W(s);
1892
+ (!u || !u.tagName) && (u = {
1893
+ namespaceURI: me,
1894
+ tagName: "template"
1895
+ });
1896
+ const d = je(s.tagName), S = je(u.tagName);
1897
+ return lt[s.namespaceURI] ? s.namespaceURI === ze ? u.namespaceURI === ee ? d === "svg" : u.namespaceURI === Me ? d === "svg" && (S === "annotation-xml" || Pe[S]) : !!Bt[d] : s.namespaceURI === Me ? u.namespaceURI === ee ? d === "math" : u.namespaceURI === ze ? d === "math" && $e[S] : !!Wt[d] : s.namespaceURI === ee ? u.namespaceURI === ze && !$e[S] || u.namespaceURI === Me && !Pe[S] ? !1 : !Wt[d] && (Wn[d] || !Bt[d]) : !!(xe === "application/xhtml+xml" && lt[s.namespaceURI]) : !1;
1898
+ }, V = function(s) {
1899
+ ye(e.removed, {
1900
+ element: s
1901
+ });
1902
+ try {
1903
+ W(s).removeChild(s);
1904
+ } catch {
1905
+ _(s);
1906
+ }
1907
+ }, le = function(s, u) {
1908
+ try {
1909
+ ye(e.removed, {
1910
+ attribute: u.getAttributeNode(s),
1911
+ from: u
1912
+ });
1913
+ } catch {
1914
+ ye(e.removed, {
1915
+ attribute: null,
1916
+ from: u
1917
+ });
1918
+ }
1919
+ if (u.removeAttribute(s), s === "is")
1920
+ if (fe || De)
1921
+ try {
1922
+ V(u);
1923
+ } catch {
1924
+ }
1925
+ else
1926
+ try {
1927
+ u.setAttribute(s, "");
1928
+ } catch {
1929
+ }
1930
+ }, jt = function(s) {
1931
+ let u = null, d = null;
1932
+ if (nt)
1933
+ s = "<remove></remove>" + s;
1934
+ else {
1935
+ const L = ht(s, /^[\r\n\t ]+/);
1936
+ d = L && L[0];
1937
+ }
1938
+ xe === "application/xhtml+xml" && me === ee && (s = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + s + "</body></html>");
1939
+ const S = C ? C.createHTML(s) : s;
1940
+ if (me === ee)
1941
+ try {
1942
+ u = new h().parseFromString(S, xe);
1943
+ } catch {
1944
+ }
1945
+ if (!u || !u.documentElement) {
1946
+ u = Ve.createDocument(me, "template", null);
1947
+ try {
1948
+ u.documentElement.innerHTML = ot ? J : S;
1949
+ } catch {
1950
+ }
1951
+ }
1952
+ const M = u.body || u.documentElement;
1953
+ return s && d && M.insertBefore(t.createTextNode(d), M.childNodes[0] || null), me === ee ? Mn.call(u, oe ? "html" : "body")[0] : oe ? u.documentElement : M;
1954
+ }, Gt = function(s) {
1955
+ return Dn.call(
1956
+ s.ownerDocument || s,
1957
+ s,
1958
+ // eslint-disable-next-line no-bitwise
1959
+ g.SHOW_ELEMENT | g.SHOW_COMMENT | g.SHOW_TEXT | g.SHOW_PROCESSING_INSTRUCTION | g.SHOW_CDATA_SECTION,
1960
+ null
1961
+ );
1962
+ }, ct = function(s) {
1963
+ return s instanceof T && (typeof s.nodeName != "string" || typeof s.textContent != "string" || typeof s.removeChild != "function" || !(s.attributes instanceof f) || typeof s.removeAttribute != "function" || typeof s.setAttribute != "function" || typeof s.namespaceURI != "string" || typeof s.insertBefore != "function" || typeof s.hasChildNodes != "function");
1964
+ }, qt = function(s) {
1965
+ return typeof a == "function" && s instanceof a;
1966
+ };
1967
+ function te(k, s, u) {
1968
+ Be(k, (d) => {
1969
+ d.call(e, s, u, ge);
1970
+ });
1971
+ }
1972
+ const Zt = function(s) {
1973
+ let u = null;
1974
+ if (te(z.beforeSanitizeElements, s, null), ct(s))
1975
+ return V(s), !0;
1976
+ const d = v(s.nodeName);
1977
+ if (te(z.uponSanitizeElement, s, {
1978
+ tagName: d,
1979
+ allowedTags: O
1980
+ }), Oe && s.hasChildNodes() && !qt(s.firstElementChild) && P(/<[/\w!]/g, s.innerHTML) && P(/<[/\w!]/g, s.textContent) || s.nodeType === Re.progressingInstruction || Oe && s.nodeType === Re.comment && P(/<[/\w]/g, s.data))
1981
+ return V(s), !0;
1982
+ if (!(pe.tagCheck instanceof Function && pe.tagCheck(d)) && (!O[d] || Te[d])) {
1983
+ if (!Te[d] && Vt(d) && (R.tagNameCheck instanceof RegExp && P(R.tagNameCheck, d) || R.tagNameCheck instanceof Function && R.tagNameCheck(d)))
1984
+ return !1;
1985
+ if (it && !Y[d]) {
1986
+ const S = W(s) || s.parentNode, M = q(s) || s.childNodes;
1987
+ if (M && S) {
1988
+ const L = M.length;
1989
+ for (let H = L - 1; H >= 0; --H) {
1990
+ const ne = p(M[H], !0);
1991
+ ne.__removalCount = (s.__removalCount || 0) + 1, S.insertBefore(ne, I(s));
1992
+ }
1993
+ }
1994
+ }
1995
+ return V(s), !0;
1996
+ }
1997
+ return s instanceof c && !Zn(s) || (d === "noscript" || d === "noembed" || d === "noframes") && P(/<\/no(script|embed|frames)/i, s.innerHTML) ? (V(s), !0) : (he && s.nodeType === Re.text && (u = s.textContent, Be([Xe, Qe, Ke], (S) => {
1998
+ u = Ee(u, S, " ");
1999
+ }), s.textContent !== u && (ye(e.removed, {
2000
+ element: s.cloneNode()
2001
+ }), s.textContent = u)), te(z.afterSanitizeElements, s, null), !1);
2002
+ }, Yt = function(s, u, d) {
2003
+ if (zt && (u === "id" || u === "name") && (d in t || d in qn))
2004
+ return !1;
2005
+ if (!(et && !Je[u] && P(Pn, u))) {
2006
+ if (!(Dt && P($n, u))) {
2007
+ if (!(pe.attributeCheck instanceof Function && pe.attributeCheck(u, s))) {
2008
+ if (!D[u] || Je[u]) {
2009
+ if (
2010
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
2011
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
2012
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
2013
+ !(Vt(s) && (R.tagNameCheck instanceof RegExp && P(R.tagNameCheck, s) || R.tagNameCheck instanceof Function && R.tagNameCheck(s)) && (R.attributeNameCheck instanceof RegExp && P(R.attributeNameCheck, u) || R.attributeNameCheck instanceof Function && R.attributeNameCheck(u, s)) || // Alternative, second condition checks if it's an `is`-attribute, AND
2014
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
2015
+ u === "is" && R.allowCustomizedBuiltInElements && (R.tagNameCheck instanceof RegExp && P(R.tagNameCheck, d) || R.tagNameCheck instanceof Function && R.tagNameCheck(d)))
2016
+ ) return !1;
2017
+ } else if (!st[u]) {
2018
+ if (!P(It, Ee(d, vt, ""))) {
2019
+ if (!((u === "src" || u === "xlink:href" || u === "href") && s !== "script" && er(d, "data:") === 0 && $t[s])) {
2020
+ if (!(Nt && !P(Un, Ee(d, vt, "")))) {
2021
+ if (d)
2022
+ return !1;
2023
+ }
2024
+ }
2025
+ }
2026
+ }
2027
+ }
2028
+ }
2029
+ }
2030
+ return !0;
2031
+ }, Vt = function(s) {
2032
+ return s !== "annotation-xml" && ht(s, Fn);
2033
+ }, Xt = function(s) {
2034
+ te(z.beforeSanitizeAttributes, s, null);
2035
+ const {
2036
+ attributes: u
2037
+ } = s;
2038
+ if (!u || ct(s))
2039
+ return;
2040
+ const d = {
2041
+ attrName: "",
2042
+ attrValue: "",
2043
+ keepAttr: !0,
2044
+ allowedAttributes: D,
2045
+ forceKeepAttr: void 0
2046
+ };
2047
+ let S = u.length;
2048
+ for (; S--; ) {
2049
+ const M = u[S], {
2050
+ name: L,
2051
+ namespaceURI: H,
2052
+ value: ne
2053
+ } = M, ke = v(L), ut = ne;
2054
+ let N = L === "value" ? ut : tr(ut);
2055
+ if (d.attrName = ke, d.attrValue = N, d.keepAttr = !0, d.forceKeepAttr = void 0, te(z.uponSanitizeAttribute, s, d), N = d.attrValue, Pt && (ke === "id" || ke === "name") && (le(L, s), N = Hn + N), Oe && P(/((--!?|])>)|<\/(style|title|textarea)/i, N)) {
2056
+ le(L, s);
2057
+ continue;
2058
+ }
2059
+ if (ke === "attributename" && ht(N, "href")) {
2060
+ le(L, s);
2061
+ continue;
2062
+ }
2063
+ if (d.forceKeepAttr)
2064
+ continue;
2065
+ if (!d.keepAttr) {
2066
+ le(L, s);
2067
+ continue;
2068
+ }
2069
+ if (!Mt && P(/\/>/i, N)) {
2070
+ le(L, s);
2071
+ continue;
2072
+ }
2073
+ he && Be([Xe, Qe, Ke], (Kt) => {
2074
+ N = Ee(N, Kt, " ");
2075
+ });
2076
+ const Qt = v(s.nodeName);
2077
+ if (!Yt(Qt, ke, N)) {
2078
+ le(L, s);
2079
+ continue;
2080
+ }
2081
+ if (C && typeof b == "object" && typeof b.getAttributeType == "function" && !H)
2082
+ switch (b.getAttributeType(Qt, ke)) {
2083
+ case "TrustedHTML": {
2084
+ N = C.createHTML(N);
2085
+ break;
2086
+ }
2087
+ case "TrustedScriptURL": {
2088
+ N = C.createScriptURL(N);
2089
+ break;
2090
+ }
2091
+ }
2092
+ if (N !== ut)
2093
+ try {
2094
+ H ? s.setAttributeNS(H, L, N) : s.setAttribute(L, N), ct(s) ? V(s) : cn(e.removed);
2095
+ } catch {
2096
+ le(L, s);
2097
+ }
2098
+ }
2099
+ te(z.afterSanitizeAttributes, s, null);
2100
+ }, Yn = function k(s) {
2101
+ let u = null;
2102
+ const d = Gt(s);
2103
+ for (te(z.beforeSanitizeShadowDOM, s, null); u = d.nextNode(); )
2104
+ te(z.uponSanitizeShadowNode, u, null), Zt(u), Xt(u), u.content instanceof o && k(u.content);
2105
+ te(z.afterSanitizeShadowDOM, s, null);
2106
+ };
2107
+ return e.sanitize = function(k) {
2108
+ let s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, u = null, d = null, S = null, M = null;
2109
+ if (ot = !k, ot && (k = "<!-->"), typeof k != "string" && !qt(k))
2110
+ if (typeof k.toString == "function") {
2111
+ if (k = k.toString(), typeof k != "string")
2112
+ throw Ae("dirty is not a string, aborting");
2113
+ } else
2114
+ throw Ae("toString is not a function");
2115
+ if (!e.isSupported)
2116
+ return k;
2117
+ if (tt || at(s), e.removed = [], typeof k == "string" && (we = !1), we) {
2118
+ if (k.nodeName) {
2119
+ const ne = v(k.nodeName);
2120
+ if (!O[ne] || Te[ne])
2121
+ throw Ae("root node is forbidden and cannot be sanitized in-place");
2122
+ }
2123
+ } else if (k instanceof a)
2124
+ u = jt("<!---->"), d = u.ownerDocument.importNode(k, !0), d.nodeType === Re.element && d.nodeName === "BODY" || d.nodeName === "HTML" ? u = d : u.appendChild(d);
2125
+ else {
2126
+ if (!fe && !he && !oe && // eslint-disable-next-line unicorn/prefer-includes
2127
+ k.indexOf("<") === -1)
2128
+ return C && Ne ? C.createHTML(k) : k;
2129
+ if (u = jt(k), !u)
2130
+ return fe ? null : Ne ? J : "";
2131
+ }
2132
+ u && nt && V(u.firstChild);
2133
+ const L = Gt(we ? k : u);
2134
+ for (; S = L.nextNode(); )
2135
+ Zt(S), Xt(S), S.content instanceof o && Yn(S.content);
2136
+ if (we)
2137
+ return k;
2138
+ if (fe) {
2139
+ if (De)
2140
+ for (M = Nn.call(u.ownerDocument); u.firstChild; )
2141
+ M.appendChild(u.firstChild);
2142
+ else
2143
+ M = u;
2144
+ return (D.shadowroot || D.shadowrootmode) && (M = zn.call(n, M, !0)), M;
2145
+ }
2146
+ let H = oe ? u.outerHTML : u.innerHTML;
2147
+ return oe && O["!doctype"] && u.ownerDocument && u.ownerDocument.doctype && u.ownerDocument.doctype.name && P(Cn, u.ownerDocument.doctype.name) && (H = "<!DOCTYPE " + u.ownerDocument.doctype.name + `>
2148
+ ` + H), he && Be([Xe, Qe, Ke], (ne) => {
2149
+ H = Ee(H, ne, " ");
2150
+ }), C && Ne ? C.createHTML(H) : H;
2151
+ }, e.setConfig = function() {
2152
+ let k = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2153
+ at(k), tt = !0;
2154
+ }, e.clearConfig = function() {
2155
+ ge = null, tt = !1;
2156
+ }, e.isValidAttribute = function(k, s, u) {
2157
+ ge || at({});
2158
+ const d = v(k), S = v(s);
2159
+ return Yt(d, S, u);
2160
+ }, e.addHook = function(k, s) {
2161
+ typeof s == "function" && ye(z[k], s);
2162
+ }, e.removeHook = function(k, s) {
2163
+ if (s !== void 0) {
2164
+ const u = Ki(z[k], s);
2165
+ return u === -1 ? void 0 : Ji(z[k], u, 1)[0];
2166
+ }
2167
+ return cn(z[k]);
2168
+ }, e.removeHooks = function(k) {
2169
+ z[k] = [];
2170
+ }, e.removeAllHooks = function() {
2171
+ z = mn();
2172
+ }, e;
2173
+ }
2174
+ var gr = On();
2175
+ const kr = {
2176
+ heading(l, e, t) {
2177
+ typeof l == "object" && l !== null && (t = l.raw || t, e = l.depth || l.level || e, l = l.text || "");
2178
+ const i = (t || String(l)).toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
2179
+ return `<h${e} id="${i}">${l}</h${e}>`;
2180
+ }
2181
+ };
2182
+ y.use({ renderer: kr });
2183
+ function br(l) {
2184
+ const e = y.parse(l);
2185
+ return gr.sanitize(e, {
2186
+ ADD_ATTR: ["id", "name"],
2187
+ // 'name' sometimes used for anchors too
2188
+ ADD_TAGS: ["h1", "h2", "h3", "h4", "h5", "h6"]
2189
+ // Ensure headers aren't stripped (redundant but safe)
2190
+ });
2191
+ }
2192
+ const Tr = ({ content: l, filename: e, onClose: t }) => {
2193
+ const [n, i] = ie(""), [o, r] = ie(!1), [a, c] = ie(!1);
2194
+ be(() => {
2195
+ if (l) {
2196
+ const h = br(l);
2197
+ i(h);
2198
+ }
2199
+ }, [l]), be(() => {
2200
+ const h = (m) => {
2201
+ var _;
2202
+ const p = (_ = m.target.getAttribute("href")) == null ? void 0 : _.substring(1);
2203
+ if (p) {
2204
+ const I = document.getElementById(p);
2205
+ I && (m.preventDefault(), I.scrollIntoView({ behavior: "smooth", block: "start" }));
2206
+ }
2207
+ }, b = document.querySelectorAll('.markdown-body a[href^="#"]');
2208
+ return b.forEach((m) => m.addEventListener("click", h)), () => {
2209
+ b.forEach((m) => m.removeEventListener("click", h));
2210
+ };
2211
+ }, [n]);
2212
+ const g = () => {
2213
+ var h;
2214
+ if (o)
2215
+ window.speechSynthesis.cancel(), r(!1);
2216
+ else {
2217
+ const b = (h = document.getElementById("markdown-content")) == null ? void 0 : h.innerText;
2218
+ if (!b) return;
2219
+ const m = new SpeechSynthesisUtterance(b);
2220
+ m.rate = 1, m.onend = () => r(!1), m.onerror = () => r(!1), window.speechSynthesis.speak(m), r(!0);
2221
+ }
2222
+ };
2223
+ return be(() => () => window.speechSynthesis.cancel(), []), /* @__PURE__ */ $("section", { className: "preview-zone", children: [
2224
+ /* @__PURE__ */ $("div", { className: "preview-header", children: [
2225
+ /* @__PURE__ */ w("span", { id: "filename-display", children: e || "filename.md" }),
2226
+ /* @__PURE__ */ $("div", { className: "header-actions", children: [
2227
+ /* @__PURE__ */ w(
2228
+ "button",
2229
+ {
2230
+ className: `icon-btn ${o ? "speaking" : ""}`,
2231
+ onClick: g,
2232
+ title: o ? "Stop Reading" : "Read Aloud",
2233
+ children: o ? /* @__PURE__ */ w(ci, {}) : /* @__PURE__ */ w(pi, {})
2234
+ }
2235
+ ),
2236
+ /* @__PURE__ */ w(
2237
+ "button",
2238
+ {
2239
+ className: "icon-btn",
2240
+ onClick: () => {
2241
+ const h = document.getElementById("markdown-content");
2242
+ if (!h) return;
2243
+ const b = h.innerText, m = h.innerHTML, p = new Blob([m], { type: "text/html" }), _ = new Blob([b], { type: "text/plain" }), I = [new ClipboardItem({
2244
+ "text/html": p,
2245
+ "text/plain": _
2246
+ })];
2247
+ navigator.clipboard.write(I).then(() => {
2248
+ c(!0), setTimeout(() => c(!1), 2e3);
2249
+ }).catch(() => {
2250
+ navigator.clipboard.writeText(b).then(() => {
2251
+ c(!0), setTimeout(() => c(!1), 2e3);
2252
+ });
2253
+ });
2254
+ },
2255
+ title: "Copy to Clipboard",
2256
+ style: { color: a ? "var(--accent-color)" : "" },
2257
+ children: a ? /* @__PURE__ */ w(ni, {}) : /* @__PURE__ */ w(si, {})
2258
+ }
2259
+ ),
2260
+ /* @__PURE__ */ w("button", { className: "icon-btn", onClick: () => {
2261
+ alert("💡 Tip: To preserve the visual theme in your PDF, make sure to check 'Background graphics' in the print settings window."), window.print();
2262
+ }, title: "Save as PDF", children: /* @__PURE__ */ w(li, {}) }),
2263
+ /* @__PURE__ */ w("button", { className: "icon-btn", onClick: t, title: "Close File", id: "close-btn", children: /* @__PURE__ */ w(ii, {}) })
2264
+ ] })
2265
+ ] }),
2266
+ /* @__PURE__ */ w(
2267
+ "div",
2268
+ {
2269
+ id: "markdown-content",
2270
+ className: "markdown-body",
2271
+ dangerouslySetInnerHTML: { __html: n }
2272
+ }
2273
+ )
2274
+ ] });
2275
+ }, yr = ({ url: l }) => {
2276
+ const [e, t] = ie("light"), [n, i] = ie(null), [o, r] = ie(!1), a = re.useRef(null);
2277
+ be(() => {
2278
+ const m = localStorage.getItem("theme"), p = window.matchMedia("(prefers-color-scheme: dark)").matches;
2279
+ t(m || (p ? "dark" : "light"));
2280
+ }, []);
2281
+ const c = () => {
2282
+ const m = e === "light" ? "dark" : "light";
2283
+ t(m), localStorage.setItem("theme", m);
2284
+ }, g = (m) => {
2285
+ try {
2286
+ if (new URL(m).hostname === "github.com" && m.includes("/blob/"))
2287
+ return m.replace("github.com", "raw.githubusercontent.com").replace("/blob/", "/");
2288
+ } catch {
2289
+ }
2290
+ return m;
2291
+ }, f = async (m) => {
2292
+ if (m)
2293
+ try {
2294
+ const p = g(m), _ = await fetch(p);
2295
+ if (!_.ok) throw new Error("Failed to fetch");
2296
+ const I = await _.text();
2297
+ let q = m.substring(m.lastIndexOf("/") + 1) || "remote-file.md";
2298
+ q.includes("?") && (q = q.split("?")[0]), i({ name: q, content: I });
2299
+ } catch (p) {
2300
+ console.error("Scripto Load Error:", p);
2301
+ }
2302
+ };
2303
+ be(() => {
2304
+ const m = a.current;
2305
+ if (!m) return;
2306
+ const p = () => {
2307
+ m.scrollTop > 300 ? r(!0) : r(!1);
2308
+ };
2309
+ return m.addEventListener("scroll", p), () => m.removeEventListener("scroll", p);
2310
+ }, []);
2311
+ const T = () => {
2312
+ a.current && a.current.scrollTo({ top: 0, behavior: "smooth" });
2313
+ }, h = (m) => {
2314
+ i(m), a.current && (a.current.scrollTop = 0);
2315
+ }, b = () => {
2316
+ i(null);
2317
+ const m = new URL(window.location);
2318
+ m.searchParams.delete("url"), window.history.pushState({}, "", m);
2319
+ };
2320
+ return be(() => {
2321
+ const m = new URLSearchParams(window.location.search), p = l || m.get("url");
2322
+ p && f(p);
2323
+ }, [l]), /* @__PURE__ */ $("div", { className: "scripto-wrapper", "data-theme": e, children: [
2324
+ /* @__PURE__ */ $("div", { className: "background-blobs", children: [
2325
+ /* @__PURE__ */ w("div", { className: "blob blob-1" }),
2326
+ /* @__PURE__ */ w("div", { className: "blob blob-2" }),
2327
+ /* @__PURE__ */ w("div", { className: "blob blob-3" })
2328
+ ] }),
2329
+ /* @__PURE__ */ w("button", { id: "theme-toggle", "aria-label": "Toggle Theme", onClick: c, children: e === "light" ? /* @__PURE__ */ w(ui, {}) : /* @__PURE__ */ w(ai, {}) }),
2330
+ /* @__PURE__ */ $("main", { className: "app-container", ref: a, children: [
2331
+ /* @__PURE__ */ $("header", { className: "glass-header", children: [
2332
+ /* @__PURE__ */ $("div", { className: "logo", children: [
2333
+ /* @__PURE__ */ w(oi, {}),
2334
+ /* @__PURE__ */ $("h1", { children: [
2335
+ "Scr!p",
2336
+ /* @__PURE__ */ w("span", { children: "tō" })
2337
+ ] })
2338
+ ] }),
2339
+ /* @__PURE__ */ w("p", { children: "“Simple, elegant visualization — where every mark becomes meaning.”" })
2340
+ ] }),
2341
+ n ? /* @__PURE__ */ w(
2342
+ Tr,
2343
+ {
2344
+ content: n.content,
2345
+ filename: n.name,
2346
+ onClose: b
2347
+ }
2348
+ ) : /* @__PURE__ */ w(fi, { onFileLoaded: h }),
2349
+ /* @__PURE__ */ w("footer", { className: "app-footer", children: /* @__PURE__ */ $("p", { children: [
2350
+ " Try it out on  ",
2351
+ /* @__PURE__ */ w("a", { href: "https://www.npmjs.com/package/@jojovms/scripto", target: "_blank", rel: "noopener noreferrer", className: "npm-link", title: "View on NPM", children: /* @__PURE__ */ w(hi, { style: { fontSize: "2.5em", verticalAlign: "middle", marginRight: "5px" } }) }),
2352
+ /* @__PURE__ */ w("span", { style: { margin: "0 10px", opacity: 0.5 }, children: "|" }),
2353
+ "🎯 App created by ",
2354
+ /* @__PURE__ */ w("a", { href: "https://bio.link/shijoshaji", target: "_blank", rel: "noopener noreferrer", children: "Shijo Shaji" })
2355
+ ] }) })
2356
+ ] }),
2357
+ /* @__PURE__ */ w(
2358
+ "button",
2359
+ {
2360
+ id: "scroll-top-btn",
2361
+ "aria-label": "Scroll to Top",
2362
+ className: o ? "visible" : "",
2363
+ onClick: T,
2364
+ children: /* @__PURE__ */ w(ti, {})
2365
+ }
2366
+ )
2367
+ ] });
2368
+ };
2369
+ export {
2370
+ yr as Scripto
2371
+ };