@gui-chat-plugin/markdown 0.0.1

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.
package/dist/vue.js ADDED
@@ -0,0 +1,1730 @@
1
+ var Te = Object.defineProperty;
2
+ var ze = (n, e, t) => e in n ? Te(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var k = (n, e, t) => ze(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { samples as Ae, pluginCore as Ce } from "./core.js";
5
+ import { TOOL_DEFINITION as jt, executeMarkdown as Gt } from "./core.js";
6
+ import { defineComponent as de, ref as Le, computed as G, watch as le, nextTick as Pe, createElementBlock as P, openBlock as I, createElementVNode as x, Fragment as Ie, toDisplayString as ge, createTextVNode as Be, withDirectives as Ee, vModelText as qe } from "vue";
7
+ function F() {
8
+ return {
9
+ async: !1,
10
+ breaks: !1,
11
+ extensions: null,
12
+ gfm: !0,
13
+ hooks: null,
14
+ pedantic: !1,
15
+ renderer: null,
16
+ silent: !1,
17
+ tokenizer: null,
18
+ walkTokens: null
19
+ };
20
+ }
21
+ var S = F();
22
+ function fe(n) {
23
+ S = n;
24
+ }
25
+ var A = { exec: () => null };
26
+ function g(n, e = "") {
27
+ let t = typeof n == "string" ? n : n.source;
28
+ const r = {
29
+ replace: (s, i) => {
30
+ let c = typeof i == "string" ? i : i.source;
31
+ return c = c.replace(w.caret, "$1"), t = t.replace(s, c), r;
32
+ },
33
+ getRegex: () => new RegExp(t, e)
34
+ };
35
+ return r;
36
+ }
37
+ var w = {
38
+ codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
39
+ outputLinkReplace: /\\([\[\]])/g,
40
+ indentCodeCompensation: /^(\s+)(?:```)/,
41
+ beginningSpace: /^\s+/,
42
+ endingHash: /#$/,
43
+ startingSpaceChar: /^ /,
44
+ endingSpaceChar: / $/,
45
+ nonSpaceChar: /[^ ]/,
46
+ newLineCharGlobal: /\n/g,
47
+ tabCharGlobal: /\t/g,
48
+ multipleSpaceGlobal: /\s+/g,
49
+ blankLine: /^[ \t]*$/,
50
+ doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
51
+ blockquoteStart: /^ {0,3}>/,
52
+ blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
53
+ blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
54
+ listReplaceTabs: /^\t+/,
55
+ listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
56
+ listIsTask: /^\[[ xX]\] /,
57
+ listReplaceTask: /^\[[ xX]\] +/,
58
+ anyLine: /\n.*\n/,
59
+ hrefBrackets: /^<(.*)>$/,
60
+ tableDelimiter: /[:|]/,
61
+ tableAlignChars: /^\||\| *$/g,
62
+ tableRowBlankLine: /\n[ \t]*$/,
63
+ tableAlignRight: /^ *-+: *$/,
64
+ tableAlignCenter: /^ *:-+: *$/,
65
+ tableAlignLeft: /^ *:-+ *$/,
66
+ startATag: /^<a /i,
67
+ endATag: /^<\/a>/i,
68
+ startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
69
+ endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
70
+ startAngleBracket: /^</,
71
+ endAngleBracket: />$/,
72
+ pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
73
+ unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
74
+ escapeTest: /[&<>"']/,
75
+ escapeReplace: /[&<>"']/g,
76
+ escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
77
+ escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
78
+ unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
79
+ caret: /(^|[^\[])\^/g,
80
+ percentDecode: /%25/g,
81
+ findPipe: /\|/g,
82
+ splitPipe: / \|/,
83
+ slashPipe: /\\\|/g,
84
+ carriageReturn: /\r\n|\r/g,
85
+ spaceLine: /^ +$/gm,
86
+ notSpaceStart: /^\S*/,
87
+ endingNewline: /\n$/,
88
+ listItemRegex: (n) => new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),
89
+ nextBulletRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
90
+ hrRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
91
+ fencesBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:\`\`\`|~~~)`),
92
+ headingBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}#`),
93
+ htmlBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}<(?:[a-z].*>|!--)`, "i")
94
+ }, De = /^(?:[ \t]*(?:\n|$))+/, Me = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, Oe = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, C = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Ne = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, V = /(?:[*+-]|\d{1,9}[.)])/, ke = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, me = g(ke).replace(/bull/g, V).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(), Ze = g(ke).replace(/bull/g, V).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), X = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, je = /^[^\n]+/, W = /(?!\s*\])(?:\\.|[^\[\]\\])+/, Ge = g(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", W).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), He = g(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, V).getRegex(), M = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", Y = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Qe = g(
95
+ "^ {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|$))",
96
+ "i"
97
+ ).replace("comment", Y).replace("tag", M).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), be = g(X).replace("hr", C).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", M).getRegex(), Ue = g(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", be).getRegex(), J = {
98
+ blockquote: Ue,
99
+ code: Me,
100
+ def: Ge,
101
+ fences: Oe,
102
+ heading: Ne,
103
+ hr: C,
104
+ html: Qe,
105
+ lheading: me,
106
+ list: He,
107
+ newline: De,
108
+ paragraph: be,
109
+ table: A,
110
+ text: je
111
+ }, ae = g(
112
+ "^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
113
+ ).replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", M).getRegex(), Fe = {
114
+ ...J,
115
+ lheading: Ze,
116
+ table: ae,
117
+ paragraph: g(X).replace("hr", C).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", ae).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", M).getRegex()
118
+ }, Ve = {
119
+ ...J,
120
+ html: g(
121
+ `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
122
+ ).replace("comment", Y).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(),
123
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
124
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
125
+ fences: A,
126
+ // fences not supported
127
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
128
+ paragraph: g(X).replace("hr", C).replace("heading", ` *#{1,6} *[^
129
+ ]`).replace("lheading", me).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
130
+ }, Xe = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, We = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, xe = /^( {2,}|\\)\n(?!\s*$)/, Ye = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, O = /[\p{P}\p{S}]/u, K = /[\s\p{P}\p{S}]/u, we = /[^\s\p{P}\p{S}]/u, Je = g(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, K).getRegex(), ye = /(?!~)[\p{P}\p{S}]/u, Ke = /(?!~)[\s\p{P}\p{S}]/u, et = /(?:[^\s\p{P}\p{S}]|~)/u, tt = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g, ve = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, nt = g(ve, "u").replace(/punct/g, O).getRegex(), rt = g(ve, "u").replace(/punct/g, ye).getRegex(), Re = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", st = g(Re, "gu").replace(/notPunctSpace/g, we).replace(/punctSpace/g, K).replace(/punct/g, O).getRegex(), it = g(Re, "gu").replace(/notPunctSpace/g, et).replace(/punctSpace/g, Ke).replace(/punct/g, ye).getRegex(), lt = g(
131
+ "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
132
+ "gu"
133
+ ).replace(/notPunctSpace/g, we).replace(/punctSpace/g, K).replace(/punct/g, O).getRegex(), at = g(/\\(punct)/, "gu").replace(/punct/g, O).getRegex(), ot = g(/^<(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(), ct = g(Y).replace("(?:-->|$)", "-->").getRegex(), ht = g(
134
+ "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
135
+ ).replace("comment", ct).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), E = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, pt = g(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", E).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), $e = g(/^!?\[(label)\]\[(ref)\]/).replace("label", E).replace("ref", W).getRegex(), Se = g(/^!?\[(ref)\](?:\[\])?/).replace("ref", W).getRegex(), ut = g("reflink|nolink(?!\\()", "g").replace("reflink", $e).replace("nolink", Se).getRegex(), ee = {
136
+ _backpedal: A,
137
+ // only used for GFM url
138
+ anyPunctuation: at,
139
+ autolink: ot,
140
+ blockSkip: tt,
141
+ br: xe,
142
+ code: We,
143
+ del: A,
144
+ emStrongLDelim: nt,
145
+ emStrongRDelimAst: st,
146
+ emStrongRDelimUnd: lt,
147
+ escape: Xe,
148
+ link: pt,
149
+ nolink: Se,
150
+ punctuation: Je,
151
+ reflink: $e,
152
+ reflinkSearch: ut,
153
+ tag: ht,
154
+ text: Ye,
155
+ url: A
156
+ }, dt = {
157
+ ...ee,
158
+ link: g(/^!?\[(label)\]\((.*?)\)/).replace("label", E).getRegex(),
159
+ reflink: g(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", E).getRegex()
160
+ }, H = {
161
+ ...ee,
162
+ emStrongRDelimAst: it,
163
+ emStrongLDelim: rt,
164
+ url: g(/^((?: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(),
165
+ _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
166
+ del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
167
+ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
168
+ }, gt = {
169
+ ...H,
170
+ br: g(xe).replace("{2,}", "*").getRegex(),
171
+ text: g(H.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
172
+ }, L = {
173
+ normal: J,
174
+ gfm: Fe,
175
+ pedantic: Ve
176
+ }, T = {
177
+ normal: ee,
178
+ gfm: H,
179
+ breaks: gt,
180
+ pedantic: dt
181
+ }, ft = {
182
+ "&": "&amp;",
183
+ "<": "&lt;",
184
+ ">": "&gt;",
185
+ '"': "&quot;",
186
+ "'": "&#39;"
187
+ }, oe = (n) => ft[n];
188
+ function y(n, e) {
189
+ if (e) {
190
+ if (w.escapeTest.test(n))
191
+ return n.replace(w.escapeReplace, oe);
192
+ } else if (w.escapeTestNoEncode.test(n))
193
+ return n.replace(w.escapeReplaceNoEncode, oe);
194
+ return n;
195
+ }
196
+ function ce(n) {
197
+ try {
198
+ n = encodeURI(n).replace(w.percentDecode, "%");
199
+ } catch {
200
+ return null;
201
+ }
202
+ return n;
203
+ }
204
+ function he(n, e) {
205
+ var i;
206
+ const t = n.replace(w.findPipe, (c, l, h) => {
207
+ let a = !1, o = l;
208
+ for (; --o >= 0 && h[o] === "\\"; ) a = !a;
209
+ return a ? "|" : " |";
210
+ }), r = t.split(w.splitPipe);
211
+ let s = 0;
212
+ if (r[0].trim() || r.shift(), r.length > 0 && !((i = r.at(-1)) != null && i.trim()) && r.pop(), e)
213
+ if (r.length > e)
214
+ r.splice(e);
215
+ else
216
+ for (; r.length < e; ) r.push("");
217
+ for (; s < r.length; s++)
218
+ r[s] = r[s].trim().replace(w.slashPipe, "|");
219
+ return r;
220
+ }
221
+ function z(n, e, t) {
222
+ const r = n.length;
223
+ if (r === 0)
224
+ return "";
225
+ let s = 0;
226
+ for (; s < r && n.charAt(r - s - 1) === e; )
227
+ s++;
228
+ return n.slice(0, r - s);
229
+ }
230
+ function kt(n, e) {
231
+ if (n.indexOf(e[1]) === -1)
232
+ return -1;
233
+ let t = 0;
234
+ for (let r = 0; r < n.length; r++)
235
+ if (n[r] === "\\")
236
+ r++;
237
+ else if (n[r] === e[0])
238
+ t++;
239
+ else if (n[r] === e[1] && (t--, t < 0))
240
+ return r;
241
+ return t > 0 ? -2 : -1;
242
+ }
243
+ function pe(n, e, t, r, s) {
244
+ const i = e.href, c = e.title || null, l = n[1].replace(s.other.outputLinkReplace, "$1");
245
+ r.state.inLink = !0;
246
+ const h = {
247
+ type: n[0].charAt(0) === "!" ? "image" : "link",
248
+ raw: t,
249
+ href: i,
250
+ title: c,
251
+ text: l,
252
+ tokens: r.inlineTokens(l)
253
+ };
254
+ return r.state.inLink = !1, h;
255
+ }
256
+ function mt(n, e, t) {
257
+ const r = n.match(t.other.indentCodeCompensation);
258
+ if (r === null)
259
+ return e;
260
+ const s = r[1];
261
+ return e.split(`
262
+ `).map((i) => {
263
+ const c = i.match(t.other.beginningSpace);
264
+ if (c === null)
265
+ return i;
266
+ const [l] = c;
267
+ return l.length >= s.length ? i.slice(s.length) : i;
268
+ }).join(`
269
+ `);
270
+ }
271
+ var q = class {
272
+ // set by the lexer
273
+ constructor(n) {
274
+ k(this, "options");
275
+ k(this, "rules");
276
+ // set by the lexer
277
+ k(this, "lexer");
278
+ this.options = n || S;
279
+ }
280
+ space(n) {
281
+ const e = this.rules.block.newline.exec(n);
282
+ if (e && e[0].length > 0)
283
+ return {
284
+ type: "space",
285
+ raw: e[0]
286
+ };
287
+ }
288
+ code(n) {
289
+ const e = this.rules.block.code.exec(n);
290
+ if (e) {
291
+ const t = e[0].replace(this.rules.other.codeRemoveIndent, "");
292
+ return {
293
+ type: "code",
294
+ raw: e[0],
295
+ codeBlockStyle: "indented",
296
+ text: this.options.pedantic ? t : z(t, `
297
+ `)
298
+ };
299
+ }
300
+ }
301
+ fences(n) {
302
+ const e = this.rules.block.fences.exec(n);
303
+ if (e) {
304
+ const t = e[0], r = mt(t, e[3] || "", this.rules);
305
+ return {
306
+ type: "code",
307
+ raw: t,
308
+ lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2],
309
+ text: r
310
+ };
311
+ }
312
+ }
313
+ heading(n) {
314
+ const e = this.rules.block.heading.exec(n);
315
+ if (e) {
316
+ let t = e[2].trim();
317
+ if (this.rules.other.endingHash.test(t)) {
318
+ const r = z(t, "#");
319
+ (this.options.pedantic || !r || this.rules.other.endingSpaceChar.test(r)) && (t = r.trim());
320
+ }
321
+ return {
322
+ type: "heading",
323
+ raw: e[0],
324
+ depth: e[1].length,
325
+ text: t,
326
+ tokens: this.lexer.inline(t)
327
+ };
328
+ }
329
+ }
330
+ hr(n) {
331
+ const e = this.rules.block.hr.exec(n);
332
+ if (e)
333
+ return {
334
+ type: "hr",
335
+ raw: z(e[0], `
336
+ `)
337
+ };
338
+ }
339
+ blockquote(n) {
340
+ const e = this.rules.block.blockquote.exec(n);
341
+ if (e) {
342
+ let t = z(e[0], `
343
+ `).split(`
344
+ `), r = "", s = "";
345
+ const i = [];
346
+ for (; t.length > 0; ) {
347
+ let c = !1;
348
+ const l = [];
349
+ let h;
350
+ for (h = 0; h < t.length; h++)
351
+ if (this.rules.other.blockquoteStart.test(t[h]))
352
+ l.push(t[h]), c = !0;
353
+ else if (!c)
354
+ l.push(t[h]);
355
+ else
356
+ break;
357
+ t = t.slice(h);
358
+ const a = l.join(`
359
+ `), o = a.replace(this.rules.other.blockquoteSetextReplace, `
360
+ $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
361
+ r = r ? `${r}
362
+ ${a}` : a, s = s ? `${s}
363
+ ${o}` : o;
364
+ const u = this.lexer.state.top;
365
+ if (this.lexer.state.top = !0, this.lexer.blockTokens(o, i, !0), this.lexer.state.top = u, t.length === 0)
366
+ break;
367
+ const p = i.at(-1);
368
+ if ((p == null ? void 0 : p.type) === "code")
369
+ break;
370
+ if ((p == null ? void 0 : p.type) === "blockquote") {
371
+ const m = p, d = m.raw + `
372
+ ` + t.join(`
373
+ `), b = this.blockquote(d);
374
+ i[i.length - 1] = b, r = r.substring(0, r.length - m.raw.length) + b.raw, s = s.substring(0, s.length - m.text.length) + b.text;
375
+ break;
376
+ } else if ((p == null ? void 0 : p.type) === "list") {
377
+ const m = p, d = m.raw + `
378
+ ` + t.join(`
379
+ `), b = this.list(d);
380
+ i[i.length - 1] = b, r = r.substring(0, r.length - p.raw.length) + b.raw, s = s.substring(0, s.length - m.raw.length) + b.raw, t = d.substring(i.at(-1).raw.length).split(`
381
+ `);
382
+ continue;
383
+ }
384
+ }
385
+ return {
386
+ type: "blockquote",
387
+ raw: r,
388
+ tokens: i,
389
+ text: s
390
+ };
391
+ }
392
+ }
393
+ list(n) {
394
+ let e = this.rules.block.list.exec(n);
395
+ if (e) {
396
+ let t = e[1].trim();
397
+ const r = t.length > 1, s = {
398
+ type: "list",
399
+ raw: "",
400
+ ordered: r,
401
+ start: r ? +t.slice(0, -1) : "",
402
+ loose: !1,
403
+ items: []
404
+ };
405
+ t = r ? `\\d{1,9}\\${t.slice(-1)}` : `\\${t}`, this.options.pedantic && (t = r ? t : "[*+-]");
406
+ const i = this.rules.other.listItemRegex(t);
407
+ let c = !1;
408
+ for (; n; ) {
409
+ let h = !1, a = "", o = "";
410
+ if (!(e = i.exec(n)) || this.rules.block.hr.test(n))
411
+ break;
412
+ a = e[0], n = n.substring(a.length);
413
+ let u = e[2].split(`
414
+ `, 1)[0].replace(this.rules.other.listReplaceTabs, (N) => " ".repeat(3 * N.length)), p = n.split(`
415
+ `, 1)[0], m = !u.trim(), d = 0;
416
+ if (this.options.pedantic ? (d = 2, o = u.trimStart()) : m ? d = e[1].length + 1 : (d = e[2].search(this.rules.other.nonSpaceChar), d = d > 4 ? 1 : d, o = u.slice(d), d += e[1].length), m && this.rules.other.blankLine.test(p) && (a += p + `
417
+ `, n = n.substring(p.length + 1), h = !0), !h) {
418
+ const N = this.rules.other.nextBulletRegex(d), re = this.rules.other.hrRegex(d), se = this.rules.other.fencesBeginRegex(d), ie = this.rules.other.headingBeginRegex(d), _e = this.rules.other.htmlBeginRegex(d);
419
+ for (; n; ) {
420
+ const Z = n.split(`
421
+ `, 1)[0];
422
+ let _;
423
+ if (p = Z, this.options.pedantic ? (p = p.replace(this.rules.other.listReplaceNesting, " "), _ = p) : _ = p.replace(this.rules.other.tabCharGlobal, " "), se.test(p) || ie.test(p) || _e.test(p) || N.test(p) || re.test(p))
424
+ break;
425
+ if (_.search(this.rules.other.nonSpaceChar) >= d || !p.trim())
426
+ o += `
427
+ ` + _.slice(d);
428
+ else {
429
+ if (m || u.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || se.test(u) || ie.test(u) || re.test(u))
430
+ break;
431
+ o += `
432
+ ` + p;
433
+ }
434
+ !m && !p.trim() && (m = !0), a += Z + `
435
+ `, n = n.substring(Z.length + 1), u = _.slice(d);
436
+ }
437
+ }
438
+ s.loose || (c ? s.loose = !0 : this.rules.other.doubleBlankLine.test(a) && (c = !0));
439
+ let b = null, ne;
440
+ this.options.gfm && (b = this.rules.other.listIsTask.exec(o), b && (ne = b[0] !== "[ ] ", o = o.replace(this.rules.other.listReplaceTask, ""))), s.items.push({
441
+ type: "list_item",
442
+ raw: a,
443
+ task: !!b,
444
+ checked: ne,
445
+ loose: !1,
446
+ text: o,
447
+ tokens: []
448
+ }), s.raw += a;
449
+ }
450
+ const l = s.items.at(-1);
451
+ if (l)
452
+ l.raw = l.raw.trimEnd(), l.text = l.text.trimEnd();
453
+ else
454
+ return;
455
+ s.raw = s.raw.trimEnd();
456
+ for (let h = 0; h < s.items.length; h++)
457
+ if (this.lexer.state.top = !1, s.items[h].tokens = this.lexer.blockTokens(s.items[h].text, []), !s.loose) {
458
+ const a = s.items[h].tokens.filter((u) => u.type === "space"), o = a.length > 0 && a.some((u) => this.rules.other.anyLine.test(u.raw));
459
+ s.loose = o;
460
+ }
461
+ if (s.loose)
462
+ for (let h = 0; h < s.items.length; h++)
463
+ s.items[h].loose = !0;
464
+ return s;
465
+ }
466
+ }
467
+ html(n) {
468
+ const e = this.rules.block.html.exec(n);
469
+ if (e)
470
+ return {
471
+ type: "html",
472
+ block: !0,
473
+ raw: e[0],
474
+ pre: e[1] === "pre" || e[1] === "script" || e[1] === "style",
475
+ text: e[0]
476
+ };
477
+ }
478
+ def(n) {
479
+ const e = this.rules.block.def.exec(n);
480
+ if (e) {
481
+ const t = e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), r = e[2] ? e[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", s = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
482
+ return {
483
+ type: "def",
484
+ tag: t,
485
+ raw: e[0],
486
+ href: r,
487
+ title: s
488
+ };
489
+ }
490
+ }
491
+ table(n) {
492
+ var c;
493
+ const e = this.rules.block.table.exec(n);
494
+ if (!e || !this.rules.other.tableDelimiter.test(e[2]))
495
+ return;
496
+ const t = he(e[1]), r = e[2].replace(this.rules.other.tableAlignChars, "").split("|"), s = (c = e[3]) != null && c.trim() ? e[3].replace(this.rules.other.tableRowBlankLine, "").split(`
497
+ `) : [], i = {
498
+ type: "table",
499
+ raw: e[0],
500
+ header: [],
501
+ align: [],
502
+ rows: []
503
+ };
504
+ if (t.length === r.length) {
505
+ for (const l of r)
506
+ this.rules.other.tableAlignRight.test(l) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(l) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(l) ? i.align.push("left") : i.align.push(null);
507
+ for (let l = 0; l < t.length; l++)
508
+ i.header.push({
509
+ text: t[l],
510
+ tokens: this.lexer.inline(t[l]),
511
+ header: !0,
512
+ align: i.align[l]
513
+ });
514
+ for (const l of s)
515
+ i.rows.push(he(l, i.header.length).map((h, a) => ({
516
+ text: h,
517
+ tokens: this.lexer.inline(h),
518
+ header: !1,
519
+ align: i.align[a]
520
+ })));
521
+ return i;
522
+ }
523
+ }
524
+ lheading(n) {
525
+ const e = this.rules.block.lheading.exec(n);
526
+ if (e)
527
+ return {
528
+ type: "heading",
529
+ raw: e[0],
530
+ depth: e[2].charAt(0) === "=" ? 1 : 2,
531
+ text: e[1],
532
+ tokens: this.lexer.inline(e[1])
533
+ };
534
+ }
535
+ paragraph(n) {
536
+ const e = this.rules.block.paragraph.exec(n);
537
+ if (e) {
538
+ const t = e[1].charAt(e[1].length - 1) === `
539
+ ` ? e[1].slice(0, -1) : e[1];
540
+ return {
541
+ type: "paragraph",
542
+ raw: e[0],
543
+ text: t,
544
+ tokens: this.lexer.inline(t)
545
+ };
546
+ }
547
+ }
548
+ text(n) {
549
+ const e = this.rules.block.text.exec(n);
550
+ if (e)
551
+ return {
552
+ type: "text",
553
+ raw: e[0],
554
+ text: e[0],
555
+ tokens: this.lexer.inline(e[0])
556
+ };
557
+ }
558
+ escape(n) {
559
+ const e = this.rules.inline.escape.exec(n);
560
+ if (e)
561
+ return {
562
+ type: "escape",
563
+ raw: e[0],
564
+ text: e[1]
565
+ };
566
+ }
567
+ tag(n) {
568
+ const e = this.rules.inline.tag.exec(n);
569
+ if (e)
570
+ return !this.lexer.state.inLink && this.rules.other.startATag.test(e[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(e[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(e[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(e[0]) && (this.lexer.state.inRawBlock = !1), {
571
+ type: "html",
572
+ raw: e[0],
573
+ inLink: this.lexer.state.inLink,
574
+ inRawBlock: this.lexer.state.inRawBlock,
575
+ block: !1,
576
+ text: e[0]
577
+ };
578
+ }
579
+ link(n) {
580
+ const e = this.rules.inline.link.exec(n);
581
+ if (e) {
582
+ const t = e[2].trim();
583
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(t)) {
584
+ if (!this.rules.other.endAngleBracket.test(t))
585
+ return;
586
+ const i = z(t.slice(0, -1), "\\");
587
+ if ((t.length - i.length) % 2 === 0)
588
+ return;
589
+ } else {
590
+ const i = kt(e[2], "()");
591
+ if (i === -2)
592
+ return;
593
+ if (i > -1) {
594
+ const l = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + i;
595
+ e[2] = e[2].substring(0, i), e[0] = e[0].substring(0, l).trim(), e[3] = "";
596
+ }
597
+ }
598
+ let r = e[2], s = "";
599
+ if (this.options.pedantic) {
600
+ const i = this.rules.other.pedanticHrefTitle.exec(r);
601
+ i && (r = i[1], s = i[3]);
602
+ } else
603
+ s = e[3] ? e[3].slice(1, -1) : "";
604
+ return r = r.trim(), this.rules.other.startAngleBracket.test(r) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(t) ? r = r.slice(1) : r = r.slice(1, -1)), pe(e, {
605
+ href: r && r.replace(this.rules.inline.anyPunctuation, "$1"),
606
+ title: s && s.replace(this.rules.inline.anyPunctuation, "$1")
607
+ }, e[0], this.lexer, this.rules);
608
+ }
609
+ }
610
+ reflink(n, e) {
611
+ let t;
612
+ if ((t = this.rules.inline.reflink.exec(n)) || (t = this.rules.inline.nolink.exec(n))) {
613
+ const r = (t[2] || t[1]).replace(this.rules.other.multipleSpaceGlobal, " "), s = e[r.toLowerCase()];
614
+ if (!s) {
615
+ const i = t[0].charAt(0);
616
+ return {
617
+ type: "text",
618
+ raw: i,
619
+ text: i
620
+ };
621
+ }
622
+ return pe(t, s, t[0], this.lexer, this.rules);
623
+ }
624
+ }
625
+ emStrong(n, e, t = "") {
626
+ let r = this.rules.inline.emStrongLDelim.exec(n);
627
+ if (!r || r[3] && t.match(this.rules.other.unicodeAlphaNumeric)) return;
628
+ if (!(r[1] || r[2] || "") || !t || this.rules.inline.punctuation.exec(t)) {
629
+ const i = [...r[0]].length - 1;
630
+ let c, l, h = i, a = 0;
631
+ const o = r[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
632
+ for (o.lastIndex = 0, e = e.slice(-1 * n.length + i); (r = o.exec(e)) != null; ) {
633
+ if (c = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !c) continue;
634
+ if (l = [...c].length, r[3] || r[4]) {
635
+ h += l;
636
+ continue;
637
+ } else if ((r[5] || r[6]) && i % 3 && !((i + l) % 3)) {
638
+ a += l;
639
+ continue;
640
+ }
641
+ if (h -= l, h > 0) continue;
642
+ l = Math.min(l, l + h + a);
643
+ const u = [...r[0]][0].length, p = n.slice(0, i + r.index + u + l);
644
+ if (Math.min(i, l) % 2) {
645
+ const d = p.slice(1, -1);
646
+ return {
647
+ type: "em",
648
+ raw: p,
649
+ text: d,
650
+ tokens: this.lexer.inlineTokens(d)
651
+ };
652
+ }
653
+ const m = p.slice(2, -2);
654
+ return {
655
+ type: "strong",
656
+ raw: p,
657
+ text: m,
658
+ tokens: this.lexer.inlineTokens(m)
659
+ };
660
+ }
661
+ }
662
+ }
663
+ codespan(n) {
664
+ const e = this.rules.inline.code.exec(n);
665
+ if (e) {
666
+ let t = e[2].replace(this.rules.other.newLineCharGlobal, " ");
667
+ const r = this.rules.other.nonSpaceChar.test(t), s = this.rules.other.startingSpaceChar.test(t) && this.rules.other.endingSpaceChar.test(t);
668
+ return r && s && (t = t.substring(1, t.length - 1)), {
669
+ type: "codespan",
670
+ raw: e[0],
671
+ text: t
672
+ };
673
+ }
674
+ }
675
+ br(n) {
676
+ const e = this.rules.inline.br.exec(n);
677
+ if (e)
678
+ return {
679
+ type: "br",
680
+ raw: e[0]
681
+ };
682
+ }
683
+ del(n) {
684
+ const e = this.rules.inline.del.exec(n);
685
+ if (e)
686
+ return {
687
+ type: "del",
688
+ raw: e[0],
689
+ text: e[2],
690
+ tokens: this.lexer.inlineTokens(e[2])
691
+ };
692
+ }
693
+ autolink(n) {
694
+ const e = this.rules.inline.autolink.exec(n);
695
+ if (e) {
696
+ let t, r;
697
+ return e[2] === "@" ? (t = e[1], r = "mailto:" + t) : (t = e[1], r = t), {
698
+ type: "link",
699
+ raw: e[0],
700
+ text: t,
701
+ href: r,
702
+ tokens: [
703
+ {
704
+ type: "text",
705
+ raw: t,
706
+ text: t
707
+ }
708
+ ]
709
+ };
710
+ }
711
+ }
712
+ url(n) {
713
+ var t;
714
+ let e;
715
+ if (e = this.rules.inline.url.exec(n)) {
716
+ let r, s;
717
+ if (e[2] === "@")
718
+ r = e[0], s = "mailto:" + r;
719
+ else {
720
+ let i;
721
+ do
722
+ i = e[0], e[0] = ((t = this.rules.inline._backpedal.exec(e[0])) == null ? void 0 : t[0]) ?? "";
723
+ while (i !== e[0]);
724
+ r = e[0], e[1] === "www." ? s = "http://" + e[0] : s = e[0];
725
+ }
726
+ return {
727
+ type: "link",
728
+ raw: e[0],
729
+ text: r,
730
+ href: s,
731
+ tokens: [
732
+ {
733
+ type: "text",
734
+ raw: r,
735
+ text: r
736
+ }
737
+ ]
738
+ };
739
+ }
740
+ }
741
+ inlineText(n) {
742
+ const e = this.rules.inline.text.exec(n);
743
+ if (e) {
744
+ const t = this.lexer.state.inRawBlock;
745
+ return {
746
+ type: "text",
747
+ raw: e[0],
748
+ text: e[0],
749
+ escaped: t
750
+ };
751
+ }
752
+ }
753
+ }, v = class Q {
754
+ constructor(e) {
755
+ k(this, "tokens");
756
+ k(this, "options");
757
+ k(this, "state");
758
+ k(this, "tokenizer");
759
+ k(this, "inlineQueue");
760
+ this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || S, this.options.tokenizer = this.options.tokenizer || new q(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
761
+ inLink: !1,
762
+ inRawBlock: !1,
763
+ top: !0
764
+ };
765
+ const t = {
766
+ other: w,
767
+ block: L.normal,
768
+ inline: T.normal
769
+ };
770
+ this.options.pedantic ? (t.block = L.pedantic, t.inline = T.pedantic) : this.options.gfm && (t.block = L.gfm, this.options.breaks ? t.inline = T.breaks : t.inline = T.gfm), this.tokenizer.rules = t;
771
+ }
772
+ /**
773
+ * Expose Rules
774
+ */
775
+ static get rules() {
776
+ return {
777
+ block: L,
778
+ inline: T
779
+ };
780
+ }
781
+ /**
782
+ * Static Lex Method
783
+ */
784
+ static lex(e, t) {
785
+ return new Q(t).lex(e);
786
+ }
787
+ /**
788
+ * Static Lex Inline Method
789
+ */
790
+ static lexInline(e, t) {
791
+ return new Q(t).inlineTokens(e);
792
+ }
793
+ /**
794
+ * Preprocessing
795
+ */
796
+ lex(e) {
797
+ e = e.replace(w.carriageReturn, `
798
+ `), this.blockTokens(e, this.tokens);
799
+ for (let t = 0; t < this.inlineQueue.length; t++) {
800
+ const r = this.inlineQueue[t];
801
+ this.inlineTokens(r.src, r.tokens);
802
+ }
803
+ return this.inlineQueue = [], this.tokens;
804
+ }
805
+ blockTokens(e, t = [], r = !1) {
806
+ var s, i, c;
807
+ for (this.options.pedantic && (e = e.replace(w.tabCharGlobal, " ").replace(w.spaceLine, "")); e; ) {
808
+ let l;
809
+ if ((i = (s = this.options.extensions) == null ? void 0 : s.block) != null && i.some((a) => (l = a.call({ lexer: this }, e, t)) ? (e = e.substring(l.raw.length), t.push(l), !0) : !1))
810
+ continue;
811
+ if (l = this.tokenizer.space(e)) {
812
+ e = e.substring(l.raw.length);
813
+ const a = t.at(-1);
814
+ l.raw.length === 1 && a !== void 0 ? a.raw += `
815
+ ` : t.push(l);
816
+ continue;
817
+ }
818
+ if (l = this.tokenizer.code(e)) {
819
+ e = e.substring(l.raw.length);
820
+ const a = t.at(-1);
821
+ (a == null ? void 0 : a.type) === "paragraph" || (a == null ? void 0 : a.type) === "text" ? (a.raw += `
822
+ ` + l.raw, a.text += `
823
+ ` + l.text, this.inlineQueue.at(-1).src = a.text) : t.push(l);
824
+ continue;
825
+ }
826
+ if (l = this.tokenizer.fences(e)) {
827
+ e = e.substring(l.raw.length), t.push(l);
828
+ continue;
829
+ }
830
+ if (l = this.tokenizer.heading(e)) {
831
+ e = e.substring(l.raw.length), t.push(l);
832
+ continue;
833
+ }
834
+ if (l = this.tokenizer.hr(e)) {
835
+ e = e.substring(l.raw.length), t.push(l);
836
+ continue;
837
+ }
838
+ if (l = this.tokenizer.blockquote(e)) {
839
+ e = e.substring(l.raw.length), t.push(l);
840
+ continue;
841
+ }
842
+ if (l = this.tokenizer.list(e)) {
843
+ e = e.substring(l.raw.length), t.push(l);
844
+ continue;
845
+ }
846
+ if (l = this.tokenizer.html(e)) {
847
+ e = e.substring(l.raw.length), t.push(l);
848
+ continue;
849
+ }
850
+ if (l = this.tokenizer.def(e)) {
851
+ e = e.substring(l.raw.length);
852
+ const a = t.at(-1);
853
+ (a == null ? void 0 : a.type) === "paragraph" || (a == null ? void 0 : a.type) === "text" ? (a.raw += `
854
+ ` + l.raw, a.text += `
855
+ ` + l.raw, this.inlineQueue.at(-1).src = a.text) : this.tokens.links[l.tag] || (this.tokens.links[l.tag] = {
856
+ href: l.href,
857
+ title: l.title
858
+ });
859
+ continue;
860
+ }
861
+ if (l = this.tokenizer.table(e)) {
862
+ e = e.substring(l.raw.length), t.push(l);
863
+ continue;
864
+ }
865
+ if (l = this.tokenizer.lheading(e)) {
866
+ e = e.substring(l.raw.length), t.push(l);
867
+ continue;
868
+ }
869
+ let h = e;
870
+ if ((c = this.options.extensions) != null && c.startBlock) {
871
+ let a = 1 / 0;
872
+ const o = e.slice(1);
873
+ let u;
874
+ this.options.extensions.startBlock.forEach((p) => {
875
+ u = p.call({ lexer: this }, o), typeof u == "number" && u >= 0 && (a = Math.min(a, u));
876
+ }), a < 1 / 0 && a >= 0 && (h = e.substring(0, a + 1));
877
+ }
878
+ if (this.state.top && (l = this.tokenizer.paragraph(h))) {
879
+ const a = t.at(-1);
880
+ r && (a == null ? void 0 : a.type) === "paragraph" ? (a.raw += `
881
+ ` + l.raw, a.text += `
882
+ ` + l.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : t.push(l), r = h.length !== e.length, e = e.substring(l.raw.length);
883
+ continue;
884
+ }
885
+ if (l = this.tokenizer.text(e)) {
886
+ e = e.substring(l.raw.length);
887
+ const a = t.at(-1);
888
+ (a == null ? void 0 : a.type) === "text" ? (a.raw += `
889
+ ` + l.raw, a.text += `
890
+ ` + l.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : t.push(l);
891
+ continue;
892
+ }
893
+ if (e) {
894
+ const a = "Infinite loop on byte: " + e.charCodeAt(0);
895
+ if (this.options.silent) {
896
+ console.error(a);
897
+ break;
898
+ } else
899
+ throw new Error(a);
900
+ }
901
+ }
902
+ return this.state.top = !0, t;
903
+ }
904
+ inline(e, t = []) {
905
+ return this.inlineQueue.push({ src: e, tokens: t }), t;
906
+ }
907
+ /**
908
+ * Lexing/Compiling
909
+ */
910
+ inlineTokens(e, t = []) {
911
+ var l, h, a;
912
+ let r = e, s = null;
913
+ if (this.tokens.links) {
914
+ const o = Object.keys(this.tokens.links);
915
+ if (o.length > 0)
916
+ for (; (s = this.tokenizer.rules.inline.reflinkSearch.exec(r)) != null; )
917
+ o.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (r = r.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
918
+ }
919
+ for (; (s = this.tokenizer.rules.inline.anyPunctuation.exec(r)) != null; )
920
+ r = r.slice(0, s.index) + "++" + r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
921
+ for (; (s = this.tokenizer.rules.inline.blockSkip.exec(r)) != null; )
922
+ r = r.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
923
+ let i = !1, c = "";
924
+ for (; e; ) {
925
+ i || (c = ""), i = !1;
926
+ let o;
927
+ if ((h = (l = this.options.extensions) == null ? void 0 : l.inline) != null && h.some((p) => (o = p.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), !0) : !1))
928
+ continue;
929
+ if (o = this.tokenizer.escape(e)) {
930
+ e = e.substring(o.raw.length), t.push(o);
931
+ continue;
932
+ }
933
+ if (o = this.tokenizer.tag(e)) {
934
+ e = e.substring(o.raw.length), t.push(o);
935
+ continue;
936
+ }
937
+ if (o = this.tokenizer.link(e)) {
938
+ e = e.substring(o.raw.length), t.push(o);
939
+ continue;
940
+ }
941
+ if (o = this.tokenizer.reflink(e, this.tokens.links)) {
942
+ e = e.substring(o.raw.length);
943
+ const p = t.at(-1);
944
+ o.type === "text" && (p == null ? void 0 : p.type) === "text" ? (p.raw += o.raw, p.text += o.text) : t.push(o);
945
+ continue;
946
+ }
947
+ if (o = this.tokenizer.emStrong(e, r, c)) {
948
+ e = e.substring(o.raw.length), t.push(o);
949
+ continue;
950
+ }
951
+ if (o = this.tokenizer.codespan(e)) {
952
+ e = e.substring(o.raw.length), t.push(o);
953
+ continue;
954
+ }
955
+ if (o = this.tokenizer.br(e)) {
956
+ e = e.substring(o.raw.length), t.push(o);
957
+ continue;
958
+ }
959
+ if (o = this.tokenizer.del(e)) {
960
+ e = e.substring(o.raw.length), t.push(o);
961
+ continue;
962
+ }
963
+ if (o = this.tokenizer.autolink(e)) {
964
+ e = e.substring(o.raw.length), t.push(o);
965
+ continue;
966
+ }
967
+ if (!this.state.inLink && (o = this.tokenizer.url(e))) {
968
+ e = e.substring(o.raw.length), t.push(o);
969
+ continue;
970
+ }
971
+ let u = e;
972
+ if ((a = this.options.extensions) != null && a.startInline) {
973
+ let p = 1 / 0;
974
+ const m = e.slice(1);
975
+ let d;
976
+ this.options.extensions.startInline.forEach((b) => {
977
+ d = b.call({ lexer: this }, m), typeof d == "number" && d >= 0 && (p = Math.min(p, d));
978
+ }), p < 1 / 0 && p >= 0 && (u = e.substring(0, p + 1));
979
+ }
980
+ if (o = this.tokenizer.inlineText(u)) {
981
+ e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (c = o.raw.slice(-1)), i = !0;
982
+ const p = t.at(-1);
983
+ (p == null ? void 0 : p.type) === "text" ? (p.raw += o.raw, p.text += o.text) : t.push(o);
984
+ continue;
985
+ }
986
+ if (e) {
987
+ const p = "Infinite loop on byte: " + e.charCodeAt(0);
988
+ if (this.options.silent) {
989
+ console.error(p);
990
+ break;
991
+ } else
992
+ throw new Error(p);
993
+ }
994
+ }
995
+ return t;
996
+ }
997
+ }, D = class {
998
+ // set by the parser
999
+ constructor(n) {
1000
+ k(this, "options");
1001
+ k(this, "parser");
1002
+ this.options = n || S;
1003
+ }
1004
+ space(n) {
1005
+ return "";
1006
+ }
1007
+ code({ text: n, lang: e, escaped: t }) {
1008
+ var i;
1009
+ const r = (i = (e || "").match(w.notSpaceStart)) == null ? void 0 : i[0], s = n.replace(w.endingNewline, "") + `
1010
+ `;
1011
+ return r ? '<pre><code class="language-' + y(r) + '">' + (t ? s : y(s, !0)) + `</code></pre>
1012
+ ` : "<pre><code>" + (t ? s : y(s, !0)) + `</code></pre>
1013
+ `;
1014
+ }
1015
+ blockquote({ tokens: n }) {
1016
+ return `<blockquote>
1017
+ ${this.parser.parse(n)}</blockquote>
1018
+ `;
1019
+ }
1020
+ html({ text: n }) {
1021
+ return n;
1022
+ }
1023
+ heading({ tokens: n, depth: e }) {
1024
+ return `<h${e}>${this.parser.parseInline(n)}</h${e}>
1025
+ `;
1026
+ }
1027
+ hr(n) {
1028
+ return `<hr>
1029
+ `;
1030
+ }
1031
+ list(n) {
1032
+ const e = n.ordered, t = n.start;
1033
+ let r = "";
1034
+ for (let c = 0; c < n.items.length; c++) {
1035
+ const l = n.items[c];
1036
+ r += this.listitem(l);
1037
+ }
1038
+ const s = e ? "ol" : "ul", i = e && t !== 1 ? ' start="' + t + '"' : "";
1039
+ return "<" + s + i + `>
1040
+ ` + r + "</" + s + `>
1041
+ `;
1042
+ }
1043
+ listitem(n) {
1044
+ var t;
1045
+ let e = "";
1046
+ if (n.task) {
1047
+ const r = this.checkbox({ checked: !!n.checked });
1048
+ n.loose ? ((t = n.tokens[0]) == null ? void 0 : t.type) === "paragraph" ? (n.tokens[0].text = r + " " + n.tokens[0].text, n.tokens[0].tokens && n.tokens[0].tokens.length > 0 && n.tokens[0].tokens[0].type === "text" && (n.tokens[0].tokens[0].text = r + " " + y(n.tokens[0].tokens[0].text), n.tokens[0].tokens[0].escaped = !0)) : n.tokens.unshift({
1049
+ type: "text",
1050
+ raw: r + " ",
1051
+ text: r + " ",
1052
+ escaped: !0
1053
+ }) : e += r + " ";
1054
+ }
1055
+ return e += this.parser.parse(n.tokens, !!n.loose), `<li>${e}</li>
1056
+ `;
1057
+ }
1058
+ checkbox({ checked: n }) {
1059
+ return "<input " + (n ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
1060
+ }
1061
+ paragraph({ tokens: n }) {
1062
+ return `<p>${this.parser.parseInline(n)}</p>
1063
+ `;
1064
+ }
1065
+ table(n) {
1066
+ let e = "", t = "";
1067
+ for (let s = 0; s < n.header.length; s++)
1068
+ t += this.tablecell(n.header[s]);
1069
+ e += this.tablerow({ text: t });
1070
+ let r = "";
1071
+ for (let s = 0; s < n.rows.length; s++) {
1072
+ const i = n.rows[s];
1073
+ t = "";
1074
+ for (let c = 0; c < i.length; c++)
1075
+ t += this.tablecell(i[c]);
1076
+ r += this.tablerow({ text: t });
1077
+ }
1078
+ return r && (r = `<tbody>${r}</tbody>`), `<table>
1079
+ <thead>
1080
+ ` + e + `</thead>
1081
+ ` + r + `</table>
1082
+ `;
1083
+ }
1084
+ tablerow({ text: n }) {
1085
+ return `<tr>
1086
+ ${n}</tr>
1087
+ `;
1088
+ }
1089
+ tablecell(n) {
1090
+ const e = this.parser.parseInline(n.tokens), t = n.header ? "th" : "td";
1091
+ return (n.align ? `<${t} align="${n.align}">` : `<${t}>`) + e + `</${t}>
1092
+ `;
1093
+ }
1094
+ /**
1095
+ * span level renderer
1096
+ */
1097
+ strong({ tokens: n }) {
1098
+ return `<strong>${this.parser.parseInline(n)}</strong>`;
1099
+ }
1100
+ em({ tokens: n }) {
1101
+ return `<em>${this.parser.parseInline(n)}</em>`;
1102
+ }
1103
+ codespan({ text: n }) {
1104
+ return `<code>${y(n, !0)}</code>`;
1105
+ }
1106
+ br(n) {
1107
+ return "<br>";
1108
+ }
1109
+ del({ tokens: n }) {
1110
+ return `<del>${this.parser.parseInline(n)}</del>`;
1111
+ }
1112
+ link({ href: n, title: e, tokens: t }) {
1113
+ const r = this.parser.parseInline(t), s = ce(n);
1114
+ if (s === null)
1115
+ return r;
1116
+ n = s;
1117
+ let i = '<a href="' + n + '"';
1118
+ return e && (i += ' title="' + y(e) + '"'), i += ">" + r + "</a>", i;
1119
+ }
1120
+ image({ href: n, title: e, text: t, tokens: r }) {
1121
+ r && (t = this.parser.parseInline(r, this.parser.textRenderer));
1122
+ const s = ce(n);
1123
+ if (s === null)
1124
+ return y(t);
1125
+ n = s;
1126
+ let i = `<img src="${n}" alt="${t}"`;
1127
+ return e && (i += ` title="${y(e)}"`), i += ">", i;
1128
+ }
1129
+ text(n) {
1130
+ return "tokens" in n && n.tokens ? this.parser.parseInline(n.tokens) : "escaped" in n && n.escaped ? n.text : y(n.text);
1131
+ }
1132
+ }, te = class {
1133
+ // no need for block level renderers
1134
+ strong({ text: n }) {
1135
+ return n;
1136
+ }
1137
+ em({ text: n }) {
1138
+ return n;
1139
+ }
1140
+ codespan({ text: n }) {
1141
+ return n;
1142
+ }
1143
+ del({ text: n }) {
1144
+ return n;
1145
+ }
1146
+ html({ text: n }) {
1147
+ return n;
1148
+ }
1149
+ text({ text: n }) {
1150
+ return n;
1151
+ }
1152
+ link({ text: n }) {
1153
+ return "" + n;
1154
+ }
1155
+ image({ text: n }) {
1156
+ return "" + n;
1157
+ }
1158
+ br() {
1159
+ return "";
1160
+ }
1161
+ }, R = class U {
1162
+ constructor(e) {
1163
+ k(this, "options");
1164
+ k(this, "renderer");
1165
+ k(this, "textRenderer");
1166
+ this.options = e || S, this.options.renderer = this.options.renderer || new D(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new te();
1167
+ }
1168
+ /**
1169
+ * Static Parse Method
1170
+ */
1171
+ static parse(e, t) {
1172
+ return new U(t).parse(e);
1173
+ }
1174
+ /**
1175
+ * Static Parse Inline Method
1176
+ */
1177
+ static parseInline(e, t) {
1178
+ return new U(t).parseInline(e);
1179
+ }
1180
+ /**
1181
+ * Parse Loop
1182
+ */
1183
+ parse(e, t = !0) {
1184
+ var s, i;
1185
+ let r = "";
1186
+ for (let c = 0; c < e.length; c++) {
1187
+ const l = e[c];
1188
+ if ((i = (s = this.options.extensions) == null ? void 0 : s.renderers) != null && i[l.type]) {
1189
+ const a = l, o = this.options.extensions.renderers[a.type].call({ parser: this }, a);
1190
+ if (o !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(a.type)) {
1191
+ r += o || "";
1192
+ continue;
1193
+ }
1194
+ }
1195
+ const h = l;
1196
+ switch (h.type) {
1197
+ case "space": {
1198
+ r += this.renderer.space(h);
1199
+ continue;
1200
+ }
1201
+ case "hr": {
1202
+ r += this.renderer.hr(h);
1203
+ continue;
1204
+ }
1205
+ case "heading": {
1206
+ r += this.renderer.heading(h);
1207
+ continue;
1208
+ }
1209
+ case "code": {
1210
+ r += this.renderer.code(h);
1211
+ continue;
1212
+ }
1213
+ case "table": {
1214
+ r += this.renderer.table(h);
1215
+ continue;
1216
+ }
1217
+ case "blockquote": {
1218
+ r += this.renderer.blockquote(h);
1219
+ continue;
1220
+ }
1221
+ case "list": {
1222
+ r += this.renderer.list(h);
1223
+ continue;
1224
+ }
1225
+ case "html": {
1226
+ r += this.renderer.html(h);
1227
+ continue;
1228
+ }
1229
+ case "paragraph": {
1230
+ r += this.renderer.paragraph(h);
1231
+ continue;
1232
+ }
1233
+ case "text": {
1234
+ let a = h, o = this.renderer.text(a);
1235
+ for (; c + 1 < e.length && e[c + 1].type === "text"; )
1236
+ a = e[++c], o += `
1237
+ ` + this.renderer.text(a);
1238
+ t ? r += this.renderer.paragraph({
1239
+ type: "paragraph",
1240
+ raw: o,
1241
+ text: o,
1242
+ tokens: [{ type: "text", raw: o, text: o, escaped: !0 }]
1243
+ }) : r += o;
1244
+ continue;
1245
+ }
1246
+ default: {
1247
+ const a = 'Token with "' + h.type + '" type was not found.';
1248
+ if (this.options.silent)
1249
+ return console.error(a), "";
1250
+ throw new Error(a);
1251
+ }
1252
+ }
1253
+ }
1254
+ return r;
1255
+ }
1256
+ /**
1257
+ * Parse Inline Tokens
1258
+ */
1259
+ parseInline(e, t = this.renderer) {
1260
+ var s, i;
1261
+ let r = "";
1262
+ for (let c = 0; c < e.length; c++) {
1263
+ const l = e[c];
1264
+ if ((i = (s = this.options.extensions) == null ? void 0 : s.renderers) != null && i[l.type]) {
1265
+ const a = this.options.extensions.renderers[l.type].call({ parser: this }, l);
1266
+ if (a !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(l.type)) {
1267
+ r += a || "";
1268
+ continue;
1269
+ }
1270
+ }
1271
+ const h = l;
1272
+ switch (h.type) {
1273
+ case "escape": {
1274
+ r += t.text(h);
1275
+ break;
1276
+ }
1277
+ case "html": {
1278
+ r += t.html(h);
1279
+ break;
1280
+ }
1281
+ case "link": {
1282
+ r += t.link(h);
1283
+ break;
1284
+ }
1285
+ case "image": {
1286
+ r += t.image(h);
1287
+ break;
1288
+ }
1289
+ case "strong": {
1290
+ r += t.strong(h);
1291
+ break;
1292
+ }
1293
+ case "em": {
1294
+ r += t.em(h);
1295
+ break;
1296
+ }
1297
+ case "codespan": {
1298
+ r += t.codespan(h);
1299
+ break;
1300
+ }
1301
+ case "br": {
1302
+ r += t.br(h);
1303
+ break;
1304
+ }
1305
+ case "del": {
1306
+ r += t.del(h);
1307
+ break;
1308
+ }
1309
+ case "text": {
1310
+ r += t.text(h);
1311
+ break;
1312
+ }
1313
+ default: {
1314
+ const a = 'Token with "' + h.type + '" type was not found.';
1315
+ if (this.options.silent)
1316
+ return console.error(a), "";
1317
+ throw new Error(a);
1318
+ }
1319
+ }
1320
+ }
1321
+ return r;
1322
+ }
1323
+ }, j, B = (j = class {
1324
+ constructor(n) {
1325
+ k(this, "options");
1326
+ k(this, "block");
1327
+ this.options = n || S;
1328
+ }
1329
+ /**
1330
+ * Process markdown before marked
1331
+ */
1332
+ preprocess(n) {
1333
+ return n;
1334
+ }
1335
+ /**
1336
+ * Process HTML after marked is finished
1337
+ */
1338
+ postprocess(n) {
1339
+ return n;
1340
+ }
1341
+ /**
1342
+ * Process all tokens before walk tokens
1343
+ */
1344
+ processAllTokens(n) {
1345
+ return n;
1346
+ }
1347
+ /**
1348
+ * Provide function to tokenize markdown
1349
+ */
1350
+ provideLexer() {
1351
+ return this.block ? v.lex : v.lexInline;
1352
+ }
1353
+ /**
1354
+ * Provide function to parse tokens
1355
+ */
1356
+ provideParser() {
1357
+ return this.block ? R.parse : R.parseInline;
1358
+ }
1359
+ }, k(j, "passThroughHooks", /* @__PURE__ */ new Set([
1360
+ "preprocess",
1361
+ "postprocess",
1362
+ "processAllTokens"
1363
+ ])), j), bt = class {
1364
+ constructor(...n) {
1365
+ k(this, "defaults", F());
1366
+ k(this, "options", this.setOptions);
1367
+ k(this, "parse", this.parseMarkdown(!0));
1368
+ k(this, "parseInline", this.parseMarkdown(!1));
1369
+ k(this, "Parser", R);
1370
+ k(this, "Renderer", D);
1371
+ k(this, "TextRenderer", te);
1372
+ k(this, "Lexer", v);
1373
+ k(this, "Tokenizer", q);
1374
+ k(this, "Hooks", B);
1375
+ this.use(...n);
1376
+ }
1377
+ /**
1378
+ * Run callback for every token
1379
+ */
1380
+ walkTokens(n, e) {
1381
+ var r, s;
1382
+ let t = [];
1383
+ for (const i of n)
1384
+ switch (t = t.concat(e.call(this, i)), i.type) {
1385
+ case "table": {
1386
+ const c = i;
1387
+ for (const l of c.header)
1388
+ t = t.concat(this.walkTokens(l.tokens, e));
1389
+ for (const l of c.rows)
1390
+ for (const h of l)
1391
+ t = t.concat(this.walkTokens(h.tokens, e));
1392
+ break;
1393
+ }
1394
+ case "list": {
1395
+ const c = i;
1396
+ t = t.concat(this.walkTokens(c.items, e));
1397
+ break;
1398
+ }
1399
+ default: {
1400
+ const c = i;
1401
+ (s = (r = this.defaults.extensions) == null ? void 0 : r.childTokens) != null && s[c.type] ? this.defaults.extensions.childTokens[c.type].forEach((l) => {
1402
+ const h = c[l].flat(1 / 0);
1403
+ t = t.concat(this.walkTokens(h, e));
1404
+ }) : c.tokens && (t = t.concat(this.walkTokens(c.tokens, e)));
1405
+ }
1406
+ }
1407
+ return t;
1408
+ }
1409
+ use(...n) {
1410
+ const e = this.defaults.extensions || { renderers: {}, childTokens: {} };
1411
+ return n.forEach((t) => {
1412
+ const r = { ...t };
1413
+ if (r.async = this.defaults.async || r.async || !1, t.extensions && (t.extensions.forEach((s) => {
1414
+ if (!s.name)
1415
+ throw new Error("extension name required");
1416
+ if ("renderer" in s) {
1417
+ const i = e.renderers[s.name];
1418
+ i ? e.renderers[s.name] = function(...c) {
1419
+ let l = s.renderer.apply(this, c);
1420
+ return l === !1 && (l = i.apply(this, c)), l;
1421
+ } : e.renderers[s.name] = s.renderer;
1422
+ }
1423
+ if ("tokenizer" in s) {
1424
+ if (!s.level || s.level !== "block" && s.level !== "inline")
1425
+ throw new Error("extension level must be 'block' or 'inline'");
1426
+ const i = e[s.level];
1427
+ i ? i.unshift(s.tokenizer) : e[s.level] = [s.tokenizer], s.start && (s.level === "block" ? e.startBlock ? e.startBlock.push(s.start) : e.startBlock = [s.start] : s.level === "inline" && (e.startInline ? e.startInline.push(s.start) : e.startInline = [s.start]));
1428
+ }
1429
+ "childTokens" in s && s.childTokens && (e.childTokens[s.name] = s.childTokens);
1430
+ }), r.extensions = e), t.renderer) {
1431
+ const s = this.defaults.renderer || new D(this.defaults);
1432
+ for (const i in t.renderer) {
1433
+ if (!(i in s))
1434
+ throw new Error(`renderer '${i}' does not exist`);
1435
+ if (["options", "parser"].includes(i))
1436
+ continue;
1437
+ const c = i, l = t.renderer[c], h = s[c];
1438
+ s[c] = (...a) => {
1439
+ let o = l.apply(s, a);
1440
+ return o === !1 && (o = h.apply(s, a)), o || "";
1441
+ };
1442
+ }
1443
+ r.renderer = s;
1444
+ }
1445
+ if (t.tokenizer) {
1446
+ const s = this.defaults.tokenizer || new q(this.defaults);
1447
+ for (const i in t.tokenizer) {
1448
+ if (!(i in s))
1449
+ throw new Error(`tokenizer '${i}' does not exist`);
1450
+ if (["options", "rules", "lexer"].includes(i))
1451
+ continue;
1452
+ const c = i, l = t.tokenizer[c], h = s[c];
1453
+ s[c] = (...a) => {
1454
+ let o = l.apply(s, a);
1455
+ return o === !1 && (o = h.apply(s, a)), o;
1456
+ };
1457
+ }
1458
+ r.tokenizer = s;
1459
+ }
1460
+ if (t.hooks) {
1461
+ const s = this.defaults.hooks || new B();
1462
+ for (const i in t.hooks) {
1463
+ if (!(i in s))
1464
+ throw new Error(`hook '${i}' does not exist`);
1465
+ if (["options", "block"].includes(i))
1466
+ continue;
1467
+ const c = i, l = t.hooks[c], h = s[c];
1468
+ B.passThroughHooks.has(i) ? s[c] = (a) => {
1469
+ if (this.defaults.async)
1470
+ return Promise.resolve(l.call(s, a)).then((u) => h.call(s, u));
1471
+ const o = l.call(s, a);
1472
+ return h.call(s, o);
1473
+ } : s[c] = (...a) => {
1474
+ let o = l.apply(s, a);
1475
+ return o === !1 && (o = h.apply(s, a)), o;
1476
+ };
1477
+ }
1478
+ r.hooks = s;
1479
+ }
1480
+ if (t.walkTokens) {
1481
+ const s = this.defaults.walkTokens, i = t.walkTokens;
1482
+ r.walkTokens = function(c) {
1483
+ let l = [];
1484
+ return l.push(i.call(this, c)), s && (l = l.concat(s.call(this, c))), l;
1485
+ };
1486
+ }
1487
+ this.defaults = { ...this.defaults, ...r };
1488
+ }), this;
1489
+ }
1490
+ setOptions(n) {
1491
+ return this.defaults = { ...this.defaults, ...n }, this;
1492
+ }
1493
+ lexer(n, e) {
1494
+ return v.lex(n, e ?? this.defaults);
1495
+ }
1496
+ parser(n, e) {
1497
+ return R.parse(n, e ?? this.defaults);
1498
+ }
1499
+ parseMarkdown(n) {
1500
+ return (t, r) => {
1501
+ const s = { ...r }, i = { ...this.defaults, ...s }, c = this.onError(!!i.silent, !!i.async);
1502
+ if (this.defaults.async === !0 && s.async === !1)
1503
+ return c(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
1504
+ if (typeof t > "u" || t === null)
1505
+ return c(new Error("marked(): input parameter is undefined or null"));
1506
+ if (typeof t != "string")
1507
+ return c(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(t) + ", string expected"));
1508
+ i.hooks && (i.hooks.options = i, i.hooks.block = n);
1509
+ const l = i.hooks ? i.hooks.provideLexer() : n ? v.lex : v.lexInline, h = i.hooks ? i.hooks.provideParser() : n ? R.parse : R.parseInline;
1510
+ if (i.async)
1511
+ return Promise.resolve(i.hooks ? i.hooks.preprocess(t) : t).then((a) => l(a, i)).then((a) => i.hooks ? i.hooks.processAllTokens(a) : a).then((a) => i.walkTokens ? Promise.all(this.walkTokens(a, i.walkTokens)).then(() => a) : a).then((a) => h(a, i)).then((a) => i.hooks ? i.hooks.postprocess(a) : a).catch(c);
1512
+ try {
1513
+ i.hooks && (t = i.hooks.preprocess(t));
1514
+ let a = l(t, i);
1515
+ i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
1516
+ let o = h(a, i);
1517
+ return i.hooks && (o = i.hooks.postprocess(o)), o;
1518
+ } catch (a) {
1519
+ return c(a);
1520
+ }
1521
+ };
1522
+ }
1523
+ onError(n, e) {
1524
+ return (t) => {
1525
+ if (t.message += `
1526
+ Please report this to https://github.com/markedjs/marked.`, n) {
1527
+ const r = "<p>An error occurred:</p><pre>" + y(t.message + "", !0) + "</pre>";
1528
+ return e ? Promise.resolve(r) : r;
1529
+ }
1530
+ if (e)
1531
+ return Promise.reject(t);
1532
+ throw t;
1533
+ };
1534
+ }
1535
+ }, $ = new bt();
1536
+ function f(n, e) {
1537
+ return $.parse(n, e);
1538
+ }
1539
+ f.options = f.setOptions = function(n) {
1540
+ return $.setOptions(n), f.defaults = $.defaults, fe(f.defaults), f;
1541
+ };
1542
+ f.getDefaults = F;
1543
+ f.defaults = S;
1544
+ f.use = function(...n) {
1545
+ return $.use(...n), f.defaults = $.defaults, fe(f.defaults), f;
1546
+ };
1547
+ f.walkTokens = function(n, e) {
1548
+ return $.walkTokens(n, e);
1549
+ };
1550
+ f.parseInline = $.parseInline;
1551
+ f.Parser = R;
1552
+ f.parser = R.parse;
1553
+ f.Renderer = D;
1554
+ f.TextRenderer = te;
1555
+ f.Lexer = v;
1556
+ f.lexer = v.lex;
1557
+ f.Tokenizer = q;
1558
+ f.Hooks = B;
1559
+ f.parse = f;
1560
+ f.options;
1561
+ f.setOptions;
1562
+ f.use;
1563
+ f.walkTokens;
1564
+ f.parseInline;
1565
+ R.parse;
1566
+ v.lex;
1567
+ const xt = { class: "markdown-container" }, wt = {
1568
+ key: 0,
1569
+ class: "min-h-full p-8 flex items-center justify-center"
1570
+ }, yt = { class: "markdown-content-wrapper" }, vt = { class: "p-4" }, Rt = { class: "header-row" }, $t = { class: "document-title" }, St = ["innerHTML"], _t = { class: "markdown-source" }, Tt = ["disabled"], zt = /* @__PURE__ */ de({
1571
+ __name: "View",
1572
+ props: {
1573
+ selectedResult: {}
1574
+ },
1575
+ emits: ["updateResult"],
1576
+ setup(n, { emit: e }) {
1577
+ var a;
1578
+ const t = n, r = e, s = Le(((a = t.selectedResult.data) == null ? void 0 : a.markdown) || ""), i = G(() => {
1579
+ var o;
1580
+ return s.value !== ((o = t.selectedResult.data) == null ? void 0 : o.markdown);
1581
+ }), c = G(() => {
1582
+ var o;
1583
+ return (o = t.selectedResult.data) != null && o.markdown ? f(t.selectedResult.data.markdown) : (console.error("No markdown data in result:", t.selectedResult), "");
1584
+ });
1585
+ le(
1586
+ () => {
1587
+ var o, u;
1588
+ return (u = (o = t.selectedResult) == null ? void 0 : o.viewState) == null ? void 0 : u.scrollToAnchor;
1589
+ },
1590
+ (o) => {
1591
+ o && Pe(() => {
1592
+ const u = document.getElementById(o);
1593
+ u ? u.scrollIntoView({ behavior: "smooth", block: "start" }) : console.warn(`Anchor element with id "${o}" not found`);
1594
+ });
1595
+ }
1596
+ );
1597
+ const l = () => {
1598
+ var d, b;
1599
+ if (!((b = (d = t.selectedResult) == null ? void 0 : d.data) != null && b.markdown)) return;
1600
+ const o = new Blob([t.selectedResult.data.markdown], {
1601
+ type: "text/markdown"
1602
+ }), u = URL.createObjectURL(o), p = document.createElement("a");
1603
+ p.href = u;
1604
+ const m = t.selectedResult.title ? `${t.selectedResult.title.replace(/[^a-z0-9]/gi, "_").toLowerCase()}.md` : "document.md";
1605
+ p.download = m, document.body.appendChild(p), p.click(), document.body.removeChild(p), URL.revokeObjectURL(u);
1606
+ };
1607
+ function h() {
1608
+ const o = {
1609
+ ...t.selectedResult,
1610
+ data: {
1611
+ ...t.selectedResult.data,
1612
+ markdown: s.value,
1613
+ // Reset pdfPath since markdown has changed
1614
+ pdfPath: void 0
1615
+ }
1616
+ };
1617
+ r("updateResult", o);
1618
+ }
1619
+ return le(
1620
+ () => {
1621
+ var o;
1622
+ return (o = t.selectedResult.data) == null ? void 0 : o.markdown;
1623
+ },
1624
+ (o) => {
1625
+ s.value = o || "";
1626
+ }
1627
+ ), (o, u) => {
1628
+ var p;
1629
+ return I(), P("div", xt, [
1630
+ (p = n.selectedResult.data) != null && p.markdown ? (I(), P(Ie, { key: 1 }, [
1631
+ x("div", yt, [
1632
+ x("div", vt, [
1633
+ x("div", Rt, [
1634
+ x("h1", $t, ge(n.selectedResult.title || "Document"), 1),
1635
+ x("div", { class: "button-group" }, [
1636
+ x("button", {
1637
+ onClick: l,
1638
+ class: "download-btn download-btn-green"
1639
+ }, [...u[2] || (u[2] = [
1640
+ x("span", { class: "material-icons" }, "download", -1),
1641
+ Be(" MD ", -1)
1642
+ ])])
1643
+ ])
1644
+ ]),
1645
+ x("div", {
1646
+ class: "markdown-content prose prose-slate max-w-none",
1647
+ innerHTML: c.value
1648
+ }, null, 8, St)
1649
+ ])
1650
+ ]),
1651
+ x("details", _t, [
1652
+ u[3] || (u[3] = x("summary", null, "Edit Markdown Source", -1)),
1653
+ Ee(x("textarea", {
1654
+ "onUpdate:modelValue": u[0] || (u[0] = (m) => s.value = m),
1655
+ class: "markdown-editor",
1656
+ spellcheck: "false"
1657
+ }, null, 512), [
1658
+ [qe, s.value]
1659
+ ]),
1660
+ x("button", {
1661
+ onClick: h,
1662
+ class: "apply-btn",
1663
+ disabled: !i.value
1664
+ }, " Apply Changes ", 8, Tt)
1665
+ ])
1666
+ ], 64)) : (I(), P("div", wt, [...u[1] || (u[1] = [
1667
+ x("div", { class: "text-gray-500" }, "No markdown content available", -1)
1668
+ ])]))
1669
+ ]);
1670
+ };
1671
+ }
1672
+ }), At = (n, e) => {
1673
+ const t = n.__vccOpts || n;
1674
+ for (const [r, s] of e)
1675
+ t[r] = s;
1676
+ return t;
1677
+ }, Ct = /* @__PURE__ */ At(zt, [["__scopeId", "data-v-7bea9557"]]), Lt = { class: "text-center p-4 bg-purple-100 rounded" }, Pt = { class: "text-sm text-gray-800 mt-1 font-medium truncate" }, It = /* @__PURE__ */ de({
1678
+ __name: "Preview",
1679
+ props: {
1680
+ result: {}
1681
+ },
1682
+ setup(n) {
1683
+ const e = n, t = G(() => {
1684
+ var r;
1685
+ if (e.result.title)
1686
+ return e.result.title;
1687
+ if ((r = e.result.data) != null && r.markdown) {
1688
+ const s = e.result.data.markdown.match(/^#\s+(.+)$/m);
1689
+ if (s)
1690
+ return s[1];
1691
+ }
1692
+ return "Markdown Document";
1693
+ });
1694
+ return (r, s) => (I(), P("div", Lt, [
1695
+ s[0] || (s[0] = x("div", { class: "text-purple-600 font-medium" }, "Document", -1)),
1696
+ x("div", Pt, ge(t.value), 1)
1697
+ ]));
1698
+ }
1699
+ }), ue = "presentDocument", Bt = `Use the ${ue} tool to create structured documents with text and embedded images. This tool is ideal for:
1700
+ - Guides, tutorials, and how-to content ("create a guide about...", "explain how to...")
1701
+ - Educational content (lessons, explanations, timelines, concept visualizations)
1702
+ - Reports and presentations (business reports, data analysis, infographics)
1703
+ - Articles and blog posts with illustrations
1704
+ - Documentation with diagrams or screenshots
1705
+ - Recipes with step-by-step photos
1706
+ - Travel guides with location images
1707
+ - Product presentations or lookbooks
1708
+ - Any content that combines written information with supporting visuals
1709
+
1710
+ IMPORTANT: Use this tool instead of just generating standalone images when the user wants informational or educational content with visuals. This creates a cohesive document with formatted text (markdown) AND images embedded at appropriate locations. For example, if asked to "create a guide about photosynthesis with a diagram", use ${ue} to create a full guide with explanatory text and the diagram embedded, rather than just generating the diagram image alone.
1711
+
1712
+ Format embedded images as: ![Detailed image prompt](__too_be_replaced_image_path__)`, Et = {
1713
+ ...Ce,
1714
+ viewComponent: Ct,
1715
+ previewComponent: It,
1716
+ samples: Ae,
1717
+ systemPrompt: Bt
1718
+ }, Ot = { plugin: Et };
1719
+ export {
1720
+ It as Preview,
1721
+ Bt as SYSTEM_PROMPT,
1722
+ jt as TOOL_DEFINITION,
1723
+ ue as TOOL_NAME,
1724
+ Ct as View,
1725
+ Ot as default,
1726
+ Gt as executeMarkdown,
1727
+ Et as plugin,
1728
+ Ce as pluginCore,
1729
+ Ae as samples
1730
+ };