@clevertask/scribe 0.0.0

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