@cliangdev/flux-plugin 0.2.0 → 0.3.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 (108) hide show
  1. package/README.md +11 -7
  2. package/agents/coder.md +150 -25
  3. package/bin/install.cjs +171 -16
  4. package/commands/breakdown.md +47 -10
  5. package/commands/dashboard.md +29 -0
  6. package/commands/flux.md +92 -12
  7. package/commands/implement.md +166 -17
  8. package/commands/linear.md +6 -5
  9. package/commands/prd.md +996 -82
  10. package/manifest.json +2 -1
  11. package/package.json +9 -11
  12. package/skills/flux-orchestrator/SKILL.md +11 -3
  13. package/skills/prd-writer/SKILL.md +761 -0
  14. package/skills/ux-ui-design/SKILL.md +346 -0
  15. package/skills/ux-ui-design/references/design-tokens.md +359 -0
  16. package/src/__tests__/version.test.ts +37 -0
  17. package/src/adapters/local/.gitkeep +0 -0
  18. package/src/dashboard/__tests__/api.test.ts +211 -0
  19. package/src/dashboard/browser.ts +35 -0
  20. package/src/dashboard/public/app.js +869 -0
  21. package/src/dashboard/public/index.html +90 -0
  22. package/src/dashboard/public/styles.css +807 -0
  23. package/src/dashboard/public/vendor/highlight.css +10 -0
  24. package/src/dashboard/public/vendor/highlight.min.js +8422 -0
  25. package/src/dashboard/public/vendor/marked.min.js +2210 -0
  26. package/src/dashboard/server.ts +296 -0
  27. package/src/dashboard/watchers.ts +83 -0
  28. package/src/server/__tests__/config.test.ts +163 -0
  29. package/src/server/adapters/__tests__/a-client-linear.test.ts +197 -0
  30. package/src/server/adapters/__tests__/adapter-factory.test.ts +230 -0
  31. package/src/server/adapters/__tests__/dependency-ops.test.ts +429 -0
  32. package/src/server/adapters/__tests__/document-ops.test.ts +306 -0
  33. package/src/server/adapters/__tests__/linear-adapter.test.ts +91 -0
  34. package/src/server/adapters/__tests__/linear-config.test.ts +425 -0
  35. package/src/server/adapters/__tests__/linear-criteria-parser.test.ts +287 -0
  36. package/src/server/adapters/__tests__/linear-description-test.ts +238 -0
  37. package/src/server/adapters/__tests__/linear-epic-crud.test.ts +496 -0
  38. package/src/server/adapters/__tests__/linear-mappers-description.test.ts +276 -0
  39. package/src/server/adapters/__tests__/linear-mappers-epic.test.ts +294 -0
  40. package/src/server/adapters/__tests__/linear-mappers-prd.test.ts +300 -0
  41. package/src/server/adapters/__tests__/linear-mappers-task.test.ts +197 -0
  42. package/src/server/adapters/__tests__/linear-prd-crud.test.ts +620 -0
  43. package/src/server/adapters/__tests__/linear-stats.test.ts +450 -0
  44. package/src/server/adapters/__tests__/linear-task-crud.test.ts +534 -0
  45. package/src/server/adapters/__tests__/linear-types.test.ts +243 -0
  46. package/src/server/adapters/__tests__/status-ops.test.ts +441 -0
  47. package/src/server/adapters/factory.ts +90 -0
  48. package/src/server/adapters/index.ts +9 -0
  49. package/src/server/adapters/linear/adapter.ts +1141 -0
  50. package/src/server/adapters/linear/client.ts +169 -0
  51. package/src/server/adapters/linear/config.ts +152 -0
  52. package/src/server/adapters/linear/helpers/criteria-parser.ts +197 -0
  53. package/src/server/adapters/linear/helpers/index.ts +7 -0
  54. package/src/server/adapters/linear/index.ts +16 -0
  55. package/src/server/adapters/linear/mappers/description.ts +136 -0
  56. package/src/server/adapters/linear/mappers/epic.ts +81 -0
  57. package/src/server/adapters/linear/mappers/index.ts +27 -0
  58. package/src/server/adapters/linear/mappers/prd.ts +178 -0
  59. package/src/server/adapters/linear/mappers/task.ts +82 -0
  60. package/src/server/adapters/linear/types.ts +264 -0
  61. package/src/server/adapters/local-adapter.ts +1009 -0
  62. package/src/server/adapters/types.ts +293 -0
  63. package/src/server/config.ts +73 -0
  64. package/src/server/db/__tests__/queries.test.ts +473 -0
  65. package/src/server/db/ids.ts +17 -0
  66. package/src/server/db/index.ts +69 -0
  67. package/src/server/db/queries.ts +142 -0
  68. package/src/server/db/refs.ts +60 -0
  69. package/src/server/db/schema.ts +97 -0
  70. package/src/server/db/sqlite.ts +10 -0
  71. package/src/server/index.ts +81 -0
  72. package/src/server/tools/__tests__/crud.test.ts +411 -0
  73. package/src/server/tools/__tests__/get-version.test.ts +27 -0
  74. package/src/server/tools/__tests__/mcp-interface.test.ts +479 -0
  75. package/src/server/tools/__tests__/query.test.ts +405 -0
  76. package/src/server/tools/__tests__/z-configure-linear.test.ts +511 -0
  77. package/src/server/tools/__tests__/z-get-linear-url.test.ts +108 -0
  78. package/src/server/tools/configure-linear.ts +373 -0
  79. package/src/server/tools/create-epic.ts +44 -0
  80. package/src/server/tools/create-prd.ts +40 -0
  81. package/src/server/tools/create-task.ts +47 -0
  82. package/src/server/tools/criteria.ts +50 -0
  83. package/src/server/tools/delete-entity.ts +76 -0
  84. package/src/server/tools/dependencies.ts +55 -0
  85. package/src/server/tools/get-entity.ts +240 -0
  86. package/src/server/tools/get-linear-url.ts +28 -0
  87. package/src/server/tools/get-stats.ts +52 -0
  88. package/src/server/tools/get-version.ts +20 -0
  89. package/src/server/tools/index.ts +158 -0
  90. package/src/server/tools/init-project.ts +108 -0
  91. package/src/server/tools/query-entities.ts +167 -0
  92. package/src/server/tools/render-status.ts +219 -0
  93. package/src/server/tools/update-entity.ts +140 -0
  94. package/src/server/tools/update-status.ts +166 -0
  95. package/src/server/utils/__tests__/mcp-response.test.ts +331 -0
  96. package/src/server/utils/logger.ts +9 -0
  97. package/src/server/utils/mcp-response.ts +254 -0
  98. package/src/server/utils/status-transitions.ts +160 -0
  99. package/src/status-line/__tests__/status-line.test.ts +215 -0
  100. package/src/status-line/index.ts +147 -0
  101. package/src/utils/__tests__/chalk-import.test.ts +32 -0
  102. package/src/utils/__tests__/display.test.ts +97 -0
  103. package/src/utils/__tests__/status-renderer.test.ts +310 -0
  104. package/src/utils/display.ts +62 -0
  105. package/src/utils/status-renderer.ts +214 -0
  106. package/src/version.ts +5 -0
  107. package/dist/server/index.js +0 -87063
  108. package/skills/prd-template/SKILL.md +0 -242
@@ -0,0 +1,2210 @@
1
+ /**
2
+ * marked v15.0.12 - a markdown parser
3
+ * Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed)
4
+ * https://github.com/markedjs/marked
5
+ */
6
+
7
+ /**
8
+ * DO NOT EDIT THIS FILE
9
+ * The code in this file is generated from files in ./src/
10
+ */
11
+ ((g, f) => {
12
+ if (typeof exports == "object" && typeof module < "u") {
13
+ module.exports = f();
14
+ } else if ("function" == typeof define && define.amd) {
15
+ define("marked", f);
16
+ } else {
17
+ g["marked"] = f();
18
+ }
19
+ })(
20
+ typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : this,
21
+ function () {
22
+ var exports = {};
23
+ var __exports = exports;
24
+ var module = { exports };
25
+ ("use strict");
26
+ var H = Object.defineProperty;
27
+ var be = Object.getOwnPropertyDescriptor;
28
+ var Te = Object.getOwnPropertyNames;
29
+ var we = Object.prototype.hasOwnProperty;
30
+ var ye = (l, e) => {
31
+ for (var t in e) H(l, t, { get: e[t], enumerable: !0 });
32
+ },
33
+ Re = (l, e, t, n) => {
34
+ if ((e && typeof e == "object") || typeof e == "function")
35
+ for (const s of Te(e))
36
+ !we.call(l, s) &&
37
+ s !== t &&
38
+ H(l, s, {
39
+ get: () => e[s],
40
+ enumerable: !(n = be(e, s)) || n.enumerable,
41
+ });
42
+ return l;
43
+ };
44
+ var Se = (l) => Re(H({}, "__esModule", { value: !0 }), l);
45
+ var kt = {};
46
+ ye(kt, {
47
+ Hooks: () => L,
48
+ Lexer: () => x,
49
+ Marked: () => E,
50
+ Parser: () => b,
51
+ Renderer: () => $,
52
+ TextRenderer: () => _,
53
+ Tokenizer: () => S,
54
+ defaults: () => w,
55
+ getDefaults: () => z,
56
+ lexer: () => ht,
57
+ marked: () => k,
58
+ options: () => it,
59
+ parse: () => pt,
60
+ parseInline: () => ct,
61
+ parser: () => ut,
62
+ setOptions: () => ot,
63
+ use: () => lt,
64
+ walkTokens: () => at,
65
+ });
66
+ module.exports = Se(kt);
67
+ function z() {
68
+ return {
69
+ async: !1,
70
+ breaks: !1,
71
+ extensions: null,
72
+ gfm: !0,
73
+ hooks: null,
74
+ pedantic: !1,
75
+ renderer: null,
76
+ silent: !1,
77
+ tokenizer: null,
78
+ walkTokens: null,
79
+ };
80
+ }
81
+ var w = z();
82
+ function N(l) {
83
+ w = l;
84
+ }
85
+ var I = { exec: () => null };
86
+ function h(l, e = "") {
87
+ let t = typeof l == "string" ? l : l.source,
88
+ n = {
89
+ replace: (s, i) => {
90
+ let r = typeof i == "string" ? i : i.source;
91
+ return (r = r.replace(m.caret, "$1")), (t = t.replace(s, r)), n;
92
+ },
93
+ getRegex: () => new RegExp(t, e),
94
+ };
95
+ return n;
96
+ }
97
+ var m = {
98
+ codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
99
+ outputLinkReplace: /\\([[\]])/g,
100
+ indentCodeCompensation: /^(\s+)(?:```)/,
101
+ beginningSpace: /^\s+/,
102
+ endingHash: /#$/,
103
+ startingSpaceChar: /^ /,
104
+ endingSpaceChar: / $/,
105
+ nonSpaceChar: /[^ ]/,
106
+ newLineCharGlobal: /\n/g,
107
+ tabCharGlobal: /\t/g,
108
+ multipleSpaceGlobal: /\s+/g,
109
+ blankLine: /^[ \t]*$/,
110
+ doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
111
+ blockquoteStart: /^ {0,3}>/,
112
+ blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
113
+ blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
114
+ listReplaceTabs: /^\t+/,
115
+ listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
116
+ listIsTask: /^\[[ xX]\] /,
117
+ listReplaceTask: /^\[[ xX]\] +/,
118
+ anyLine: /\n.*\n/,
119
+ hrefBrackets: /^<(.*)>$/,
120
+ tableDelimiter: /[:|]/,
121
+ tableAlignChars: /^\||\| *$/g,
122
+ tableRowBlankLine: /\n[ \t]*$/,
123
+ tableAlignRight: /^ *-+: *$/,
124
+ tableAlignCenter: /^ *:-+: *$/,
125
+ tableAlignLeft: /^ *:-+ *$/,
126
+ startATag: /^<a /i,
127
+ endATag: /^<\/a>/i,
128
+ startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
129
+ endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
130
+ startAngleBracket: /^</,
131
+ endAngleBracket: />$/,
132
+ pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
133
+ unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
134
+ escapeTest: /[&<>"']/,
135
+ escapeReplace: /[&<>"']/g,
136
+ escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
137
+ escapeReplaceNoEncode:
138
+ /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
139
+ unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,
140
+ caret: /(^|[^[])\^/g,
141
+ percentDecode: /%25/g,
142
+ findPipe: /\|/g,
143
+ splitPipe: / \|/,
144
+ slashPipe: /\\\|/g,
145
+ carriageReturn: /\r\n|\r/g,
146
+ spaceLine: /^ +$/gm,
147
+ notSpaceStart: /^\S*/,
148
+ endingNewline: /\n$/,
149
+ listItemRegex: (l) =>
150
+ new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`),
151
+ nextBulletRegex: (l) =>
152
+ new RegExp(
153
+ `^ {0,${Math.min(3, l - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`,
154
+ ),
155
+ hrRegex: (l) =>
156
+ new RegExp(
157
+ `^ {0,${Math.min(3, l - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`,
158
+ ),
159
+ fencesBeginRegex: (l) =>
160
+ new RegExp(`^ {0,${Math.min(3, l - 1)}}(?:\`\`\`|~~~)`),
161
+ headingBeginRegex: (l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}#`),
162
+ htmlBeginRegex: (l) =>
163
+ new RegExp(`^ {0,${Math.min(3, l - 1)}}<(?:[a-z].*>|!--)`, "i"),
164
+ },
165
+ $e = /^(?:[ \t]*(?:\n|$))+/,
166
+ _e = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,
167
+ Le =
168
+ /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
169
+ O = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,
170
+ ze = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
171
+ F = /(?:[*+-]|\d{1,9}[.)])/,
172
+ ie =
173
+ /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
174
+ oe = h(ie)
175
+ .replace(/bull/g, F)
176
+ .replace(/blockCode/g, /(?: {4}| {0,3}\t)/)
177
+ .replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/)
178
+ .replace(/blockquote/g, / {0,3}>/)
179
+ .replace(/heading/g, / {0,3}#{1,6}/)
180
+ .replace(/html/g, / {0,3}<[^\n>]+>\n/)
181
+ .replace(/\|table/g, "")
182
+ .getRegex(),
183
+ Me = h(ie)
184
+ .replace(/bull/g, F)
185
+ .replace(/blockCode/g, /(?: {4}| {0,3}\t)/)
186
+ .replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/)
187
+ .replace(/blockquote/g, / {0,3}>/)
188
+ .replace(/heading/g, / {0,3}#{1,6}/)
189
+ .replace(/html/g, / {0,3}<[^\n>]+>\n/)
190
+ .replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[:\- ]*\n/)
191
+ .getRegex(),
192
+ Q =
193
+ /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
194
+ Pe = /^[^\n]+/,
195
+ U = /(?!\s*\])(?:\\.|[^[\]\\])+/,
196
+ Ae = h(
197
+ /^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/,
198
+ )
199
+ .replace("label", U)
200
+ .replace(
201
+ "title",
202
+ /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,
203
+ )
204
+ .getRegex(),
205
+ Ee = h(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/)
206
+ .replace(/bull/g, F)
207
+ .getRegex(),
208
+ v =
209
+ "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",
210
+ K = /<!--(?:-?>|[\s\S]*?(?:-->|$))/,
211
+ Ce = h(
212
+ "^ {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|$))",
213
+ "i",
214
+ )
215
+ .replace("comment", K)
216
+ .replace("tag", v)
217
+ .replace(
218
+ "attribute",
219
+ / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/,
220
+ )
221
+ .getRegex(),
222
+ le = h(Q)
223
+ .replace("hr", O)
224
+ .replace("heading", " {0,3}#{1,6}(?:\\s|$)")
225
+ .replace("|lheading", "")
226
+ .replace("|table", "")
227
+ .replace("blockquote", " {0,3}>")
228
+ .replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n")
229
+ .replace("list", " {0,3}(?:[*+-]|1[.)]) ")
230
+ .replace(
231
+ "html",
232
+ "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)",
233
+ )
234
+ .replace("tag", v)
235
+ .getRegex(),
236
+ Ie = h(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/)
237
+ .replace("paragraph", le)
238
+ .getRegex(),
239
+ X = {
240
+ blockquote: Ie,
241
+ code: _e,
242
+ def: Ae,
243
+ fences: Le,
244
+ heading: ze,
245
+ hr: O,
246
+ html: Ce,
247
+ lheading: oe,
248
+ list: Ee,
249
+ newline: $e,
250
+ paragraph: le,
251
+ table: I,
252
+ text: Pe,
253
+ },
254
+ re = h(
255
+ "^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",
256
+ )
257
+ .replace("hr", O)
258
+ .replace("heading", " {0,3}#{1,6}(?:\\s|$)")
259
+ .replace("blockquote", " {0,3}>")
260
+ .replace("code", "(?: {4}| {0,3} )[^\\n]")
261
+ .replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n")
262
+ .replace("list", " {0,3}(?:[*+-]|1[.)]) ")
263
+ .replace(
264
+ "html",
265
+ "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)",
266
+ )
267
+ .replace("tag", v)
268
+ .getRegex(),
269
+ Oe = {
270
+ ...X,
271
+ lheading: Me,
272
+ table: re,
273
+ paragraph: h(Q)
274
+ .replace("hr", O)
275
+ .replace("heading", " {0,3}#{1,6}(?:\\s|$)")
276
+ .replace("|lheading", "")
277
+ .replace("table", re)
278
+ .replace("blockquote", " {0,3}>")
279
+ .replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n")
280
+ .replace("list", " {0,3}(?:[*+-]|1[.)]) ")
281
+ .replace(
282
+ "html",
283
+ "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)",
284
+ )
285
+ .replace("tag", v)
286
+ .getRegex(),
287
+ },
288
+ Be = {
289
+ ...X,
290
+ html: h(
291
+ `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`,
292
+ )
293
+ .replace("comment", K)
294
+ .replace(
295
+ /tag/g,
296
+ "(?!(?: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",
297
+ )
298
+ .getRegex(),
299
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
300
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
301
+ fences: I,
302
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
303
+ paragraph: h(Q)
304
+ .replace("hr", O)
305
+ .replace(
306
+ "heading",
307
+ ` *#{1,6} *[^
308
+ ]`,
309
+ )
310
+ .replace("lheading", oe)
311
+ .replace("|table", "")
312
+ .replace("blockquote", " {0,3}>")
313
+ .replace("|fences", "")
314
+ .replace("|list", "")
315
+ .replace("|html", "")
316
+ .replace("|tag", "")
317
+ .getRegex(),
318
+ },
319
+ qe = /^\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/,
320
+ ve = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
321
+ ae = /^( {2,}|\\)\n(?!\s*$)/,
322
+ De =
323
+ /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<![`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
324
+ D = /[\p{P}\p{S}]/u,
325
+ W = /[\s\p{P}\p{S}]/u,
326
+ ce = /[^\s\p{P}\p{S}]/u,
327
+ Ze = h(/^((?![*_])punctSpace)/, "u")
328
+ .replace(/punctSpace/g, W)
329
+ .getRegex(),
330
+ pe = /(?!~)[\p{P}\p{S}]/u,
331
+ Ge = /(?!~)[\s\p{P}\p{S}]/u,
332
+ He = /(?:[^\s\p{P}\p{S}]|~)/u,
333
+ Ne =
334
+ /\[[^[\]]*?\]\((?:\\.|[^\\()]|\((?:\\.|[^\\()])*\))*\)|`[^`]*?`|<[^<>]*?>/g,
335
+ ue = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,
336
+ je = h(ue, "u").replace(/punct/g, D).getRegex(),
337
+ Fe = h(ue, "u").replace(/punct/g, pe).getRegex(),
338
+ he =
339
+ "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",
340
+ Qe = h(he, "gu")
341
+ .replace(/notPunctSpace/g, ce)
342
+ .replace(/punctSpace/g, W)
343
+ .replace(/punct/g, D)
344
+ .getRegex(),
345
+ Ue = h(he, "gu")
346
+ .replace(/notPunctSpace/g, He)
347
+ .replace(/punctSpace/g, Ge)
348
+ .replace(/punct/g, pe)
349
+ .getRegex(),
350
+ Ke = h(
351
+ "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
352
+ "gu",
353
+ )
354
+ .replace(/notPunctSpace/g, ce)
355
+ .replace(/punctSpace/g, W)
356
+ .replace(/punct/g, D)
357
+ .getRegex(),
358
+ Xe = h(/\\(punct)/, "gu")
359
+ .replace(/punct/g, D)
360
+ .getRegex(),
361
+ We = h(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/)
362
+ .replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/)
363
+ .replace(
364
+ "email",
365
+ /[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])?)+(?![-_])/,
366
+ )
367
+ .getRegex(),
368
+ Je = h(K).replace("(?:-->|$)", "-->").getRegex(),
369
+ Ve = h(
370
+ "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",
371
+ )
372
+ .replace("comment", Je)
373
+ .replace(
374
+ "attribute",
375
+ /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,
376
+ )
377
+ .getRegex(),
378
+ q = /(?:\[(?:\\.|[^[\]\\])*\]|\\.|`[^`]*`|[^[\]\\`])*?/,
379
+ Ye = h(
380
+ /^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/,
381
+ )
382
+ .replace("label", q)
383
+ .replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/)
384
+ .replace(
385
+ "title",
386
+ /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,
387
+ )
388
+ .getRegex(),
389
+ ke = h(/^!?\[(label)\]\[(ref)\]/)
390
+ .replace("label", q)
391
+ .replace("ref", U)
392
+ .getRegex(),
393
+ ge = h(/^!?\[(ref)\](?:\[\])?/)
394
+ .replace("ref", U)
395
+ .getRegex(),
396
+ et = h("reflink|nolink(?!\\()", "g")
397
+ .replace("reflink", ke)
398
+ .replace("nolink", ge)
399
+ .getRegex(),
400
+ J = {
401
+ _backpedal: I,
402
+ anyPunctuation: Xe,
403
+ autolink: We,
404
+ blockSkip: Ne,
405
+ br: ae,
406
+ code: ve,
407
+ del: I,
408
+ emStrongLDelim: je,
409
+ emStrongRDelimAst: Qe,
410
+ emStrongRDelimUnd: Ke,
411
+ escape: qe,
412
+ link: Ye,
413
+ nolink: ge,
414
+ punctuation: Ze,
415
+ reflink: ke,
416
+ reflinkSearch: et,
417
+ tag: Ve,
418
+ text: De,
419
+ url: I,
420
+ },
421
+ tt = {
422
+ ...J,
423
+ link: h(/^!?\[(label)\]\((.*?)\)/)
424
+ .replace("label", q)
425
+ .getRegex(),
426
+ reflink: h(/^!?\[(label)\]\s*\[([^\]]*)\]/)
427
+ .replace("label", q)
428
+ .getRegex(),
429
+ },
430
+ j = {
431
+ ...J,
432
+ emStrongRDelimAst: Ue,
433
+ emStrongLDelim: Fe,
434
+ url: h(
435
+ /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9-]+\.?)+[^\s<]*|^email/,
436
+ "i",
437
+ )
438
+ .replace(
439
+ "email",
440
+ /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
441
+ )
442
+ .getRegex(),
443
+ _backpedal:
444
+ /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
445
+ del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
446
+ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+/=?_`{|}~-]+@)|[\s\S]*?(?:(?=[\\<![`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+/=?_`{|}~-](?=[a-zA-Z0-9.!#$%&'*+/=?_`{|}~-]+@)))/,
447
+ },
448
+ nt = {
449
+ ...j,
450
+ br: h(ae).replace("{2,}", "*").getRegex(),
451
+ text: h(j.text)
452
+ .replace("\\b_", "\\b_| {2,}\\n")
453
+ .replace(/\{2,\}/g, "*")
454
+ .getRegex(),
455
+ },
456
+ B = { normal: X, gfm: Oe, pedantic: Be },
457
+ P = { normal: J, gfm: j, breaks: nt, pedantic: tt };
458
+ var st = {
459
+ "&": "&amp;",
460
+ "<": "&lt;",
461
+ ">": "&gt;",
462
+ '"': "&quot;",
463
+ "'": "&#39;",
464
+ },
465
+ fe = (l) => st[l];
466
+ function R(l, e) {
467
+ if (e) {
468
+ if (m.escapeTest.test(l)) return l.replace(m.escapeReplace, fe);
469
+ } else if (m.escapeTestNoEncode.test(l))
470
+ return l.replace(m.escapeReplaceNoEncode, fe);
471
+ return l;
472
+ }
473
+ function V(l) {
474
+ try {
475
+ l = encodeURI(l).replace(m.percentDecode, "%");
476
+ } catch {
477
+ return null;
478
+ }
479
+ return l;
480
+ }
481
+ function Y(l, e) {
482
+ let t = l.replace(m.findPipe, (i, r, o) => {
483
+ let a = !1,
484
+ c = r;
485
+ for (; --c >= 0 && o[c] === "\\"; ) a = !a;
486
+ return a ? "|" : " |";
487
+ }),
488
+ n = t.split(m.splitPipe),
489
+ s = 0;
490
+ if (
491
+ (n[0].trim() || n.shift(),
492
+ n.length > 0 && !n.at(-1)?.trim() && n.pop(),
493
+ e)
494
+ )
495
+ if (n.length > e) n.splice(e);
496
+ else for (; n.length < e; ) n.push("");
497
+ for (; s < n.length; s++) n[s] = n[s].trim().replace(m.slashPipe, "|");
498
+ return n;
499
+ }
500
+ function A(l, e, t) {
501
+ const n = l.length;
502
+ if (n === 0) return "";
503
+ let s = 0;
504
+ for (; s < n; ) {
505
+ const i = l.charAt(n - s - 1);
506
+ if (i === e && !t) s++;
507
+ else if (i !== e && t) s++;
508
+ else break;
509
+ }
510
+ return l.slice(0, n - s);
511
+ }
512
+ function de(l, e) {
513
+ if (l.indexOf(e[1]) === -1) return -1;
514
+ let t = 0;
515
+ for (let n = 0; n < l.length; n++)
516
+ if (l[n] === "\\") n++;
517
+ else if (l[n] === e[0]) t++;
518
+ else if (l[n] === e[1] && (t--, t < 0)) return n;
519
+ return t > 0 ? -2 : -1;
520
+ }
521
+ function me(l, e, t, n, s) {
522
+ const i = e.href,
523
+ r = e.title || null,
524
+ o = l[1].replace(s.other.outputLinkReplace, "$1");
525
+ n.state.inLink = !0;
526
+ const a = {
527
+ type: l[0].charAt(0) === "!" ? "image" : "link",
528
+ raw: t,
529
+ href: i,
530
+ title: r,
531
+ text: o,
532
+ tokens: n.inlineTokens(o),
533
+ };
534
+ return (n.state.inLink = !1), a;
535
+ }
536
+ function rt(l, e, t) {
537
+ const n = l.match(t.other.indentCodeCompensation);
538
+ if (n === null) return e;
539
+ const s = n[1];
540
+ return e
541
+ .split(`
542
+ `)
543
+ .map((i) => {
544
+ const r = i.match(t.other.beginningSpace);
545
+ if (r === null) return i;
546
+ const [o] = r;
547
+ return o.length >= s.length ? i.slice(s.length) : i;
548
+ })
549
+ .join(`
550
+ `);
551
+ }
552
+ var S = class {
553
+ options;
554
+ rules;
555
+ lexer;
556
+ constructor(e) {
557
+ this.options = e || w;
558
+ }
559
+ space(e) {
560
+ const t = this.rules.block.newline.exec(e);
561
+ if (t && t[0].length > 0) return { type: "space", raw: t[0] };
562
+ }
563
+ code(e) {
564
+ const t = this.rules.block.code.exec(e);
565
+ if (t) {
566
+ const n = t[0].replace(this.rules.other.codeRemoveIndent, "");
567
+ return {
568
+ type: "code",
569
+ raw: t[0],
570
+ codeBlockStyle: "indented",
571
+ text: this.options.pedantic
572
+ ? n
573
+ : A(
574
+ n,
575
+ `
576
+ `,
577
+ ),
578
+ };
579
+ }
580
+ }
581
+ fences(e) {
582
+ const t = this.rules.block.fences.exec(e);
583
+ if (t) {
584
+ const n = t[0],
585
+ s = rt(n, t[3] || "", this.rules);
586
+ return {
587
+ type: "code",
588
+ raw: n,
589
+ lang: t[2]
590
+ ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1")
591
+ : t[2],
592
+ text: s,
593
+ };
594
+ }
595
+ }
596
+ heading(e) {
597
+ const t = this.rules.block.heading.exec(e);
598
+ if (t) {
599
+ let n = t[2].trim();
600
+ if (this.rules.other.endingHash.test(n)) {
601
+ const s = A(n, "#");
602
+ (this.options.pedantic ||
603
+ !s ||
604
+ this.rules.other.endingSpaceChar.test(s)) &&
605
+ (n = s.trim());
606
+ }
607
+ return {
608
+ type: "heading",
609
+ raw: t[0],
610
+ depth: t[1].length,
611
+ text: n,
612
+ tokens: this.lexer.inline(n),
613
+ };
614
+ }
615
+ }
616
+ hr(e) {
617
+ const t = this.rules.block.hr.exec(e);
618
+ if (t)
619
+ return {
620
+ type: "hr",
621
+ raw: A(
622
+ t[0],
623
+ `
624
+ `,
625
+ ),
626
+ };
627
+ }
628
+ blockquote(e) {
629
+ const t = this.rules.block.blockquote.exec(e);
630
+ if (t) {
631
+ let n = A(
632
+ t[0],
633
+ `
634
+ `,
635
+ ).split(`
636
+ `),
637
+ s = "",
638
+ i = "",
639
+ r = [];
640
+ for (; n.length > 0; ) {
641
+ let o = !1,
642
+ a = [],
643
+ c;
644
+ for (c = 0; c < n.length; c++)
645
+ if (this.rules.other.blockquoteStart.test(n[c]))
646
+ a.push(n[c]), (o = !0);
647
+ else if (!o) a.push(n[c]);
648
+ else break;
649
+ n = n.slice(c);
650
+ const p = a.join(`
651
+ `),
652
+ u = p
653
+ .replace(
654
+ this.rules.other.blockquoteSetextReplace,
655
+ `
656
+ $1`,
657
+ )
658
+ .replace(this.rules.other.blockquoteSetextReplace2, "");
659
+ (s = s
660
+ ? `${s}
661
+ ${p}`
662
+ : p),
663
+ (i = i
664
+ ? `${i}
665
+ ${u}`
666
+ : u);
667
+ const d = this.lexer.state.top;
668
+ if (
669
+ ((this.lexer.state.top = !0),
670
+ this.lexer.blockTokens(u, r, !0),
671
+ (this.lexer.state.top = d),
672
+ n.length === 0)
673
+ )
674
+ break;
675
+ const g = r.at(-1);
676
+ if (g?.type === "code") break;
677
+ if (g?.type === "blockquote") {
678
+ const T = g,
679
+ f =
680
+ T.raw +
681
+ `
682
+ ` +
683
+ n.join(`
684
+ `),
685
+ y = this.blockquote(f);
686
+ (r[r.length - 1] = y),
687
+ (s = s.substring(0, s.length - T.raw.length) + y.raw),
688
+ (i = i.substring(0, i.length - T.text.length) + y.text);
689
+ break;
690
+ } else if (g?.type === "list") {
691
+ const T = g,
692
+ f =
693
+ T.raw +
694
+ `
695
+ ` +
696
+ n.join(`
697
+ `),
698
+ y = this.list(f);
699
+ (r[r.length - 1] = y),
700
+ (s = s.substring(0, s.length - g.raw.length) + y.raw),
701
+ (i = i.substring(0, i.length - T.raw.length) + y.raw),
702
+ (n = f.substring(r.at(-1).raw.length).split(`
703
+ `));
704
+ }
705
+ }
706
+ return { type: "blockquote", raw: s, tokens: r, text: i };
707
+ }
708
+ }
709
+ list(e) {
710
+ let t = this.rules.block.list.exec(e);
711
+ if (t) {
712
+ let n = t[1].trim(),
713
+ s = n.length > 1,
714
+ i = {
715
+ type: "list",
716
+ raw: "",
717
+ ordered: s,
718
+ start: s ? +n.slice(0, -1) : "",
719
+ loose: !1,
720
+ items: [],
721
+ };
722
+ (n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`),
723
+ this.options.pedantic && (n = s ? n : "[*+-]");
724
+ let r = this.rules.other.listItemRegex(n),
725
+ o = !1;
726
+ for (; e; ) {
727
+ let c = !1,
728
+ p = "",
729
+ u = "";
730
+ if (!(t = r.exec(e)) || this.rules.block.hr.test(e)) break;
731
+ (p = t[0]), (e = e.substring(p.length));
732
+ let d = t[2]
733
+ .split(
734
+ `
735
+ `,
736
+ 1,
737
+ )[0]
738
+ .replace(this.rules.other.listReplaceTabs, (Z) =>
739
+ " ".repeat(3 * Z.length),
740
+ ),
741
+ g = e.split(
742
+ `
743
+ `,
744
+ 1,
745
+ )[0],
746
+ T = !d.trim(),
747
+ f = 0;
748
+ if (
749
+ (this.options.pedantic
750
+ ? ((f = 2), (u = d.trimStart()))
751
+ : T
752
+ ? (f = t[1].length + 1)
753
+ : ((f = t[2].search(this.rules.other.nonSpaceChar)),
754
+ (f = f > 4 ? 1 : f),
755
+ (u = d.slice(f)),
756
+ (f += t[1].length)),
757
+ T &&
758
+ this.rules.other.blankLine.test(g) &&
759
+ ((p +=
760
+ g +
761
+ `
762
+ `),
763
+ (e = e.substring(g.length + 1)),
764
+ (c = !0)),
765
+ !c)
766
+ ) {
767
+ const Z = this.rules.other.nextBulletRegex(f),
768
+ te = this.rules.other.hrRegex(f),
769
+ ne = this.rules.other.fencesBeginRegex(f),
770
+ se = this.rules.other.headingBeginRegex(f),
771
+ xe = this.rules.other.htmlBeginRegex(f);
772
+ for (; e; ) {
773
+ let G = e.split(
774
+ `
775
+ `,
776
+ 1,
777
+ )[0],
778
+ C;
779
+ if (
780
+ ((g = G),
781
+ this.options.pedantic
782
+ ? ((g = g.replace(
783
+ this.rules.other.listReplaceNesting,
784
+ " ",
785
+ )),
786
+ (C = g))
787
+ : (C = g.replace(this.rules.other.tabCharGlobal, " ")),
788
+ ne.test(g) ||
789
+ se.test(g) ||
790
+ xe.test(g) ||
791
+ Z.test(g) ||
792
+ te.test(g))
793
+ )
794
+ break;
795
+ if (C.search(this.rules.other.nonSpaceChar) >= f || !g.trim())
796
+ u +=
797
+ `
798
+ ` + C.slice(f);
799
+ else {
800
+ if (
801
+ T ||
802
+ d
803
+ .replace(this.rules.other.tabCharGlobal, " ")
804
+ .search(this.rules.other.nonSpaceChar) >= 4 ||
805
+ ne.test(d) ||
806
+ se.test(d) ||
807
+ te.test(d)
808
+ )
809
+ break;
810
+ u +=
811
+ `
812
+ ` + g;
813
+ }
814
+ !T && !g.trim() && (T = !0),
815
+ (p +=
816
+ G +
817
+ `
818
+ `),
819
+ (e = e.substring(G.length + 1)),
820
+ (d = C.slice(f));
821
+ }
822
+ }
823
+ i.loose ||
824
+ (o
825
+ ? (i.loose = !0)
826
+ : this.rules.other.doubleBlankLine.test(p) && (o = !0));
827
+ let y = null,
828
+ ee;
829
+ this.options.gfm &&
830
+ ((y = this.rules.other.listIsTask.exec(u)),
831
+ y &&
832
+ ((ee = y[0] !== "[ ] "),
833
+ (u = u.replace(this.rules.other.listReplaceTask, "")))),
834
+ i.items.push({
835
+ type: "list_item",
836
+ raw: p,
837
+ task: !!y,
838
+ checked: ee,
839
+ loose: !1,
840
+ text: u,
841
+ tokens: [],
842
+ }),
843
+ (i.raw += p);
844
+ }
845
+ const a = i.items.at(-1);
846
+ if (a) (a.raw = a.raw.trimEnd()), (a.text = a.text.trimEnd());
847
+ else return;
848
+ i.raw = i.raw.trimEnd();
849
+ for (let c = 0; c < i.items.length; c++)
850
+ if (
851
+ ((this.lexer.state.top = !1),
852
+ (i.items[c].tokens = this.lexer.blockTokens(i.items[c].text, [])),
853
+ !i.loose)
854
+ ) {
855
+ const p = i.items[c].tokens.filter((d) => d.type === "space"),
856
+ u =
857
+ p.length > 0 &&
858
+ p.some((d) => this.rules.other.anyLine.test(d.raw));
859
+ i.loose = u;
860
+ }
861
+ if (i.loose)
862
+ for (let c = 0; c < i.items.length; c++) i.items[c].loose = !0;
863
+ return i;
864
+ }
865
+ }
866
+ html(e) {
867
+ const t = this.rules.block.html.exec(e);
868
+ if (t)
869
+ return {
870
+ type: "html",
871
+ block: !0,
872
+ raw: t[0],
873
+ pre: t[1] === "pre" || t[1] === "script" || t[1] === "style",
874
+ text: t[0],
875
+ };
876
+ }
877
+ def(e) {
878
+ const t = this.rules.block.def.exec(e);
879
+ if (t) {
880
+ const n = t[1]
881
+ .toLowerCase()
882
+ .replace(this.rules.other.multipleSpaceGlobal, " "),
883
+ s = t[2]
884
+ ? t[2]
885
+ .replace(this.rules.other.hrefBrackets, "$1")
886
+ .replace(this.rules.inline.anyPunctuation, "$1")
887
+ : "",
888
+ i = t[3]
889
+ ? t[3]
890
+ .substring(1, t[3].length - 1)
891
+ .replace(this.rules.inline.anyPunctuation, "$1")
892
+ : t[3];
893
+ return { type: "def", tag: n, raw: t[0], href: s, title: i };
894
+ }
895
+ }
896
+ table(e) {
897
+ const t = this.rules.block.table.exec(e);
898
+ if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
899
+ const n = Y(t[1]),
900
+ s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"),
901
+ i = t[3]?.trim()
902
+ ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
903
+ `)
904
+ : [],
905
+ r = { type: "table", raw: t[0], header: [], align: [], rows: [] };
906
+ if (n.length === s.length) {
907
+ for (const o of s)
908
+ this.rules.other.tableAlignRight.test(o)
909
+ ? r.align.push("right")
910
+ : this.rules.other.tableAlignCenter.test(o)
911
+ ? r.align.push("center")
912
+ : this.rules.other.tableAlignLeft.test(o)
913
+ ? r.align.push("left")
914
+ : r.align.push(null);
915
+ for (let o = 0; o < n.length; o++)
916
+ r.header.push({
917
+ text: n[o],
918
+ tokens: this.lexer.inline(n[o]),
919
+ header: !0,
920
+ align: r.align[o],
921
+ });
922
+ for (const o of i)
923
+ r.rows.push(
924
+ Y(o, r.header.length).map((a, c) => ({
925
+ text: a,
926
+ tokens: this.lexer.inline(a),
927
+ header: !1,
928
+ align: r.align[c],
929
+ })),
930
+ );
931
+ return r;
932
+ }
933
+ }
934
+ lheading(e) {
935
+ const t = this.rules.block.lheading.exec(e);
936
+ if (t)
937
+ return {
938
+ type: "heading",
939
+ raw: t[0],
940
+ depth: t[2].charAt(0) === "=" ? 1 : 2,
941
+ text: t[1],
942
+ tokens: this.lexer.inline(t[1]),
943
+ };
944
+ }
945
+ paragraph(e) {
946
+ const t = this.rules.block.paragraph.exec(e);
947
+ if (t) {
948
+ const n =
949
+ t[1].charAt(t[1].length - 1) ===
950
+ `
951
+ `
952
+ ? t[1].slice(0, -1)
953
+ : t[1];
954
+ return {
955
+ type: "paragraph",
956
+ raw: t[0],
957
+ text: n,
958
+ tokens: this.lexer.inline(n),
959
+ };
960
+ }
961
+ }
962
+ text(e) {
963
+ const t = this.rules.block.text.exec(e);
964
+ if (t)
965
+ return {
966
+ type: "text",
967
+ raw: t[0],
968
+ text: t[0],
969
+ tokens: this.lexer.inline(t[0]),
970
+ };
971
+ }
972
+ escape(e) {
973
+ const t = this.rules.inline.escape.exec(e);
974
+ if (t) return { type: "escape", raw: t[0], text: t[1] };
975
+ }
976
+ tag(e) {
977
+ const t = this.rules.inline.tag.exec(e);
978
+ if (t)
979
+ return (
980
+ !this.lexer.state.inLink && this.rules.other.startATag.test(t[0])
981
+ ? (this.lexer.state.inLink = !0)
982
+ : this.lexer.state.inLink &&
983
+ this.rules.other.endATag.test(t[0]) &&
984
+ (this.lexer.state.inLink = !1),
985
+ !this.lexer.state.inRawBlock &&
986
+ this.rules.other.startPreScriptTag.test(t[0])
987
+ ? (this.lexer.state.inRawBlock = !0)
988
+ : this.lexer.state.inRawBlock &&
989
+ this.rules.other.endPreScriptTag.test(t[0]) &&
990
+ (this.lexer.state.inRawBlock = !1),
991
+ {
992
+ type: "html",
993
+ raw: t[0],
994
+ inLink: this.lexer.state.inLink,
995
+ inRawBlock: this.lexer.state.inRawBlock,
996
+ block: !1,
997
+ text: t[0],
998
+ }
999
+ );
1000
+ }
1001
+ link(e) {
1002
+ const t = this.rules.inline.link.exec(e);
1003
+ if (t) {
1004
+ const n = t[2].trim();
1005
+ if (
1006
+ !this.options.pedantic &&
1007
+ this.rules.other.startAngleBracket.test(n)
1008
+ ) {
1009
+ if (!this.rules.other.endAngleBracket.test(n)) return;
1010
+ const r = A(n.slice(0, -1), "\\");
1011
+ if ((n.length - r.length) % 2 === 0) return;
1012
+ } else {
1013
+ const r = de(t[2], "()");
1014
+ if (r === -2) return;
1015
+ if (r > -1) {
1016
+ const a = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + r;
1017
+ (t[2] = t[2].substring(0, r)),
1018
+ (t[0] = t[0].substring(0, a).trim()),
1019
+ (t[3] = "");
1020
+ }
1021
+ }
1022
+ let s = t[2],
1023
+ i = "";
1024
+ if (this.options.pedantic) {
1025
+ const r = this.rules.other.pedanticHrefTitle.exec(s);
1026
+ r && ((s = r[1]), (i = r[3]));
1027
+ } else i = t[3] ? t[3].slice(1, -1) : "";
1028
+ return (
1029
+ (s = s.trim()),
1030
+ this.rules.other.startAngleBracket.test(s) &&
1031
+ (this.options.pedantic &&
1032
+ !this.rules.other.endAngleBracket.test(n)
1033
+ ? (s = s.slice(1))
1034
+ : (s = s.slice(1, -1))),
1035
+ me(
1036
+ t,
1037
+ {
1038
+ href: s && s.replace(this.rules.inline.anyPunctuation, "$1"),
1039
+ title: i && i.replace(this.rules.inline.anyPunctuation, "$1"),
1040
+ },
1041
+ t[0],
1042
+ this.lexer,
1043
+ this.rules,
1044
+ )
1045
+ );
1046
+ }
1047
+ }
1048
+ reflink(e, t) {
1049
+ let n;
1050
+ if (
1051
+ (n = this.rules.inline.reflink.exec(e)) ||
1052
+ (n = this.rules.inline.nolink.exec(e))
1053
+ ) {
1054
+ const s = (n[2] || n[1]).replace(
1055
+ this.rules.other.multipleSpaceGlobal,
1056
+ " ",
1057
+ ),
1058
+ i = t[s.toLowerCase()];
1059
+ if (!i) {
1060
+ const r = n[0].charAt(0);
1061
+ return { type: "text", raw: r, text: r };
1062
+ }
1063
+ return me(n, i, n[0], this.lexer, this.rules);
1064
+ }
1065
+ }
1066
+ emStrong(e, t, n = "") {
1067
+ let s = this.rules.inline.emStrongLDelim.exec(e);
1068
+ if (!s || (s[3] && n.match(this.rules.other.unicodeAlphaNumeric)))
1069
+ return;
1070
+ if (
1071
+ !(s[1] || s[2] || "") ||
1072
+ !n ||
1073
+ this.rules.inline.punctuation.exec(n)
1074
+ ) {
1075
+ let r = [...s[0]].length - 1,
1076
+ o,
1077
+ a,
1078
+ c = r,
1079
+ p = 0,
1080
+ u =
1081
+ s[0][0] === "*"
1082
+ ? this.rules.inline.emStrongRDelimAst
1083
+ : this.rules.inline.emStrongRDelimUnd;
1084
+ for (
1085
+ u.lastIndex = 0, t = t.slice(-1 * e.length + r);
1086
+ (s = u.exec(t)) != null;
1087
+ ) {
1088
+ if (((o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6]), !o))
1089
+ continue;
1090
+ if (((a = [...o].length), s[3] || s[4])) {
1091
+ c += a;
1092
+ continue;
1093
+ } else if ((s[5] || s[6]) && r % 3 && !((r + a) % 3)) {
1094
+ p += a;
1095
+ continue;
1096
+ }
1097
+ if (((c -= a), c > 0)) continue;
1098
+ a = Math.min(a, a + c + p);
1099
+ const d = [...s[0]][0].length,
1100
+ g = e.slice(0, r + s.index + d + a);
1101
+ if (Math.min(r, a) % 2) {
1102
+ const f = g.slice(1, -1);
1103
+ return {
1104
+ type: "em",
1105
+ raw: g,
1106
+ text: f,
1107
+ tokens: this.lexer.inlineTokens(f),
1108
+ };
1109
+ }
1110
+ const T = g.slice(2, -2);
1111
+ return {
1112
+ type: "strong",
1113
+ raw: g,
1114
+ text: T,
1115
+ tokens: this.lexer.inlineTokens(T),
1116
+ };
1117
+ }
1118
+ }
1119
+ }
1120
+ codespan(e) {
1121
+ const t = this.rules.inline.code.exec(e);
1122
+ if (t) {
1123
+ let n = t[2].replace(this.rules.other.newLineCharGlobal, " "),
1124
+ s = this.rules.other.nonSpaceChar.test(n),
1125
+ i =
1126
+ this.rules.other.startingSpaceChar.test(n) &&
1127
+ this.rules.other.endingSpaceChar.test(n);
1128
+ return (
1129
+ s && i && (n = n.substring(1, n.length - 1)),
1130
+ { type: "codespan", raw: t[0], text: n }
1131
+ );
1132
+ }
1133
+ }
1134
+ br(e) {
1135
+ const t = this.rules.inline.br.exec(e);
1136
+ if (t) return { type: "br", raw: t[0] };
1137
+ }
1138
+ del(e) {
1139
+ const t = this.rules.inline.del.exec(e);
1140
+ if (t)
1141
+ return {
1142
+ type: "del",
1143
+ raw: t[0],
1144
+ text: t[2],
1145
+ tokens: this.lexer.inlineTokens(t[2]),
1146
+ };
1147
+ }
1148
+ autolink(e) {
1149
+ const t = this.rules.inline.autolink.exec(e);
1150
+ if (t) {
1151
+ let n, s;
1152
+ return (
1153
+ t[2] === "@"
1154
+ ? ((n = t[1]), (s = "mailto:" + n))
1155
+ : ((n = t[1]), (s = n)),
1156
+ {
1157
+ type: "link",
1158
+ raw: t[0],
1159
+ text: n,
1160
+ href: s,
1161
+ tokens: [{ type: "text", raw: n, text: n }],
1162
+ }
1163
+ );
1164
+ }
1165
+ }
1166
+ url(e) {
1167
+ let t;
1168
+ if ((t = this.rules.inline.url.exec(e))) {
1169
+ let n, s;
1170
+ if (t[2] === "@") (n = t[0]), (s = "mailto:" + n);
1171
+ else {
1172
+ let i;
1173
+ do
1174
+ (i = t[0]),
1175
+ (t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "");
1176
+ while (i !== t[0]);
1177
+ (n = t[0]), t[1] === "www." ? (s = "http://" + t[0]) : (s = t[0]);
1178
+ }
1179
+ return {
1180
+ type: "link",
1181
+ raw: t[0],
1182
+ text: n,
1183
+ href: s,
1184
+ tokens: [{ type: "text", raw: n, text: n }],
1185
+ };
1186
+ }
1187
+ }
1188
+ inlineText(e) {
1189
+ const t = this.rules.inline.text.exec(e);
1190
+ if (t) {
1191
+ const n = this.lexer.state.inRawBlock;
1192
+ return { type: "text", raw: t[0], text: t[0], escaped: n };
1193
+ }
1194
+ }
1195
+ };
1196
+ var x = class l {
1197
+ tokens;
1198
+ options;
1199
+ state;
1200
+ tokenizer;
1201
+ inlineQueue;
1202
+ constructor(e) {
1203
+ (this.tokens = []),
1204
+ (this.tokens.links = Object.create(null)),
1205
+ (this.options = e || w),
1206
+ (this.options.tokenizer = this.options.tokenizer || new S()),
1207
+ (this.tokenizer = this.options.tokenizer),
1208
+ (this.tokenizer.options = this.options),
1209
+ (this.tokenizer.lexer = this),
1210
+ (this.inlineQueue = []),
1211
+ (this.state = { inLink: !1, inRawBlock: !1, top: !0 });
1212
+ const t = { other: m, block: B.normal, inline: P.normal };
1213
+ this.options.pedantic
1214
+ ? ((t.block = B.pedantic), (t.inline = P.pedantic))
1215
+ : this.options.gfm &&
1216
+ ((t.block = B.gfm),
1217
+ this.options.breaks ? (t.inline = P.breaks) : (t.inline = P.gfm)),
1218
+ (this.tokenizer.rules = t);
1219
+ }
1220
+ static get rules() {
1221
+ return { block: B, inline: P };
1222
+ }
1223
+ static lex(e, t) {
1224
+ return new l(t).lex(e);
1225
+ }
1226
+ static lexInline(e, t) {
1227
+ return new l(t).inlineTokens(e);
1228
+ }
1229
+ lex(e) {
1230
+ (e = e.replace(
1231
+ m.carriageReturn,
1232
+ `
1233
+ `,
1234
+ )),
1235
+ this.blockTokens(e, this.tokens);
1236
+ for (let t = 0; t < this.inlineQueue.length; t++) {
1237
+ const n = this.inlineQueue[t];
1238
+ this.inlineTokens(n.src, n.tokens);
1239
+ }
1240
+ return (this.inlineQueue = []), this.tokens;
1241
+ }
1242
+ blockTokens(e, t = [], n = !1) {
1243
+ for (
1244
+ this.options.pedantic &&
1245
+ (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));
1246
+ e;
1247
+ ) {
1248
+ let s;
1249
+ if (
1250
+ this.options.extensions?.block?.some((r) =>
1251
+ (s = r.call({ lexer: this }, e, t))
1252
+ ? ((e = e.substring(s.raw.length)), t.push(s), !0)
1253
+ : !1,
1254
+ )
1255
+ )
1256
+ continue;
1257
+ if ((s = this.tokenizer.space(e))) {
1258
+ e = e.substring(s.raw.length);
1259
+ const r = t.at(-1);
1260
+ s.raw.length === 1 && r !== void 0
1261
+ ? (r.raw += `
1262
+ `)
1263
+ : t.push(s);
1264
+ continue;
1265
+ }
1266
+ if ((s = this.tokenizer.code(e))) {
1267
+ e = e.substring(s.raw.length);
1268
+ const r = t.at(-1);
1269
+ r?.type === "paragraph" || r?.type === "text"
1270
+ ? ((r.raw +=
1271
+ `
1272
+ ` + s.raw),
1273
+ (r.text +=
1274
+ `
1275
+ ` + s.text),
1276
+ (this.inlineQueue.at(-1).src = r.text))
1277
+ : t.push(s);
1278
+ continue;
1279
+ }
1280
+ if ((s = this.tokenizer.fences(e))) {
1281
+ (e = e.substring(s.raw.length)), t.push(s);
1282
+ continue;
1283
+ }
1284
+ if ((s = this.tokenizer.heading(e))) {
1285
+ (e = e.substring(s.raw.length)), t.push(s);
1286
+ continue;
1287
+ }
1288
+ if ((s = this.tokenizer.hr(e))) {
1289
+ (e = e.substring(s.raw.length)), t.push(s);
1290
+ continue;
1291
+ }
1292
+ if ((s = this.tokenizer.blockquote(e))) {
1293
+ (e = e.substring(s.raw.length)), t.push(s);
1294
+ continue;
1295
+ }
1296
+ if ((s = this.tokenizer.list(e))) {
1297
+ (e = e.substring(s.raw.length)), t.push(s);
1298
+ continue;
1299
+ }
1300
+ if ((s = this.tokenizer.html(e))) {
1301
+ (e = e.substring(s.raw.length)), t.push(s);
1302
+ continue;
1303
+ }
1304
+ if ((s = this.tokenizer.def(e))) {
1305
+ e = e.substring(s.raw.length);
1306
+ const r = t.at(-1);
1307
+ r?.type === "paragraph" || r?.type === "text"
1308
+ ? ((r.raw +=
1309
+ `
1310
+ ` + s.raw),
1311
+ (r.text +=
1312
+ `
1313
+ ` + s.raw),
1314
+ (this.inlineQueue.at(-1).src = r.text))
1315
+ : this.tokens.links[s.tag] ||
1316
+ (this.tokens.links[s.tag] = { href: s.href, title: s.title });
1317
+ continue;
1318
+ }
1319
+ if ((s = this.tokenizer.table(e))) {
1320
+ (e = e.substring(s.raw.length)), t.push(s);
1321
+ continue;
1322
+ }
1323
+ if ((s = this.tokenizer.lheading(e))) {
1324
+ (e = e.substring(s.raw.length)), t.push(s);
1325
+ continue;
1326
+ }
1327
+ let i = e;
1328
+ if (this.options.extensions?.startBlock) {
1329
+ let r = 1 / 0,
1330
+ o = e.slice(1),
1331
+ a;
1332
+ this.options.extensions.startBlock.forEach((c) => {
1333
+ (a = c.call({ lexer: this }, o)),
1334
+ typeof a == "number" && a >= 0 && (r = Math.min(r, a));
1335
+ }),
1336
+ r < 1 / 0 && r >= 0 && (i = e.substring(0, r + 1));
1337
+ }
1338
+ if (this.state.top && (s = this.tokenizer.paragraph(i))) {
1339
+ const r = t.at(-1);
1340
+ n && r?.type === "paragraph"
1341
+ ? ((r.raw +=
1342
+ `
1343
+ ` + s.raw),
1344
+ (r.text +=
1345
+ `
1346
+ ` + s.text),
1347
+ this.inlineQueue.pop(),
1348
+ (this.inlineQueue.at(-1).src = r.text))
1349
+ : t.push(s),
1350
+ (n = i.length !== e.length),
1351
+ (e = e.substring(s.raw.length));
1352
+ continue;
1353
+ }
1354
+ if ((s = this.tokenizer.text(e))) {
1355
+ e = e.substring(s.raw.length);
1356
+ const r = t.at(-1);
1357
+ r?.type === "text"
1358
+ ? ((r.raw +=
1359
+ `
1360
+ ` + s.raw),
1361
+ (r.text +=
1362
+ `
1363
+ ` + s.text),
1364
+ this.inlineQueue.pop(),
1365
+ (this.inlineQueue.at(-1).src = r.text))
1366
+ : t.push(s);
1367
+ continue;
1368
+ }
1369
+ if (e) {
1370
+ const r = "Infinite loop on byte: " + e.charCodeAt(0);
1371
+ if (this.options.silent) {
1372
+ console.error(r);
1373
+ break;
1374
+ } else throw new Error(r);
1375
+ }
1376
+ }
1377
+ return (this.state.top = !0), t;
1378
+ }
1379
+ inline(e, t = []) {
1380
+ return this.inlineQueue.push({ src: e, tokens: t }), t;
1381
+ }
1382
+ inlineTokens(e, t = []) {
1383
+ let n = e,
1384
+ s = null;
1385
+ if (this.tokens.links) {
1386
+ const o = Object.keys(this.tokens.links);
1387
+ if (o.length > 0)
1388
+ for (
1389
+ ;
1390
+ (s = this.tokenizer.rules.inline.reflinkSearch.exec(n)) != null;
1391
+ )
1392
+ o.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) &&
1393
+ (n =
1394
+ n.slice(0, s.index) +
1395
+ "[" +
1396
+ "a".repeat(s[0].length - 2) +
1397
+ "]" +
1398
+ n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
1399
+ }
1400
+ for (
1401
+ ;
1402
+ (s = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null;
1403
+ )
1404
+ n =
1405
+ n.slice(0, s.index) +
1406
+ "++" +
1407
+ n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1408
+ for (; (s = this.tokenizer.rules.inline.blockSkip.exec(n)) != null; )
1409
+ n =
1410
+ n.slice(0, s.index) +
1411
+ "[" +
1412
+ "a".repeat(s[0].length - 2) +
1413
+ "]" +
1414
+ n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1415
+ let i = !1,
1416
+ r = "";
1417
+ for (; e; ) {
1418
+ i || (r = ""), (i = !1);
1419
+ let o;
1420
+ if (
1421
+ this.options.extensions?.inline?.some((c) =>
1422
+ (o = c.call({ lexer: this }, e, t))
1423
+ ? ((e = e.substring(o.raw.length)), t.push(o), !0)
1424
+ : !1,
1425
+ )
1426
+ )
1427
+ continue;
1428
+ if ((o = this.tokenizer.escape(e))) {
1429
+ (e = e.substring(o.raw.length)), t.push(o);
1430
+ continue;
1431
+ }
1432
+ if ((o = this.tokenizer.tag(e))) {
1433
+ (e = e.substring(o.raw.length)), t.push(o);
1434
+ continue;
1435
+ }
1436
+ if ((o = this.tokenizer.link(e))) {
1437
+ (e = e.substring(o.raw.length)), t.push(o);
1438
+ continue;
1439
+ }
1440
+ if ((o = this.tokenizer.reflink(e, this.tokens.links))) {
1441
+ e = e.substring(o.raw.length);
1442
+ const c = t.at(-1);
1443
+ o.type === "text" && c?.type === "text"
1444
+ ? ((c.raw += o.raw), (c.text += o.text))
1445
+ : t.push(o);
1446
+ continue;
1447
+ }
1448
+ if ((o = this.tokenizer.emStrong(e, n, r))) {
1449
+ (e = e.substring(o.raw.length)), t.push(o);
1450
+ continue;
1451
+ }
1452
+ if ((o = this.tokenizer.codespan(e))) {
1453
+ (e = e.substring(o.raw.length)), t.push(o);
1454
+ continue;
1455
+ }
1456
+ if ((o = this.tokenizer.br(e))) {
1457
+ (e = e.substring(o.raw.length)), t.push(o);
1458
+ continue;
1459
+ }
1460
+ if ((o = this.tokenizer.del(e))) {
1461
+ (e = e.substring(o.raw.length)), t.push(o);
1462
+ continue;
1463
+ }
1464
+ if ((o = this.tokenizer.autolink(e))) {
1465
+ (e = e.substring(o.raw.length)), t.push(o);
1466
+ continue;
1467
+ }
1468
+ if (!this.state.inLink && (o = this.tokenizer.url(e))) {
1469
+ (e = e.substring(o.raw.length)), t.push(o);
1470
+ continue;
1471
+ }
1472
+ let a = e;
1473
+ if (this.options.extensions?.startInline) {
1474
+ let c = 1 / 0,
1475
+ p = e.slice(1),
1476
+ u;
1477
+ this.options.extensions.startInline.forEach((d) => {
1478
+ (u = d.call({ lexer: this }, p)),
1479
+ typeof u == "number" && u >= 0 && (c = Math.min(c, u));
1480
+ }),
1481
+ c < 1 / 0 && c >= 0 && (a = e.substring(0, c + 1));
1482
+ }
1483
+ if ((o = this.tokenizer.inlineText(a))) {
1484
+ (e = e.substring(o.raw.length)),
1485
+ o.raw.slice(-1) !== "_" && (r = o.raw.slice(-1)),
1486
+ (i = !0);
1487
+ const c = t.at(-1);
1488
+ c?.type === "text"
1489
+ ? ((c.raw += o.raw), (c.text += o.text))
1490
+ : t.push(o);
1491
+ continue;
1492
+ }
1493
+ if (e) {
1494
+ const c = "Infinite loop on byte: " + e.charCodeAt(0);
1495
+ if (this.options.silent) {
1496
+ console.error(c);
1497
+ break;
1498
+ } else throw new Error(c);
1499
+ }
1500
+ }
1501
+ return t;
1502
+ }
1503
+ };
1504
+ var $ = class {
1505
+ options;
1506
+ parser;
1507
+ constructor(e) {
1508
+ this.options = e || w;
1509
+ }
1510
+ space(e) {
1511
+ return "";
1512
+ }
1513
+ code({ text: e, lang: t, escaped: n }) {
1514
+ const s = (t || "").match(m.notSpaceStart)?.[0],
1515
+ i =
1516
+ e.replace(m.endingNewline, "") +
1517
+ `
1518
+ `;
1519
+ return s
1520
+ ? '<pre><code class="language-' +
1521
+ R(s) +
1522
+ '">' +
1523
+ (n ? i : R(i, !0)) +
1524
+ `</code></pre>
1525
+ `
1526
+ : "<pre><code>" +
1527
+ (n ? i : R(i, !0)) +
1528
+ `</code></pre>
1529
+ `;
1530
+ }
1531
+ blockquote({ tokens: e }) {
1532
+ return `<blockquote>
1533
+ ${this.parser.parse(e)}</blockquote>
1534
+ `;
1535
+ }
1536
+ html({ text: e }) {
1537
+ return e;
1538
+ }
1539
+ heading({ tokens: e, depth: t }) {
1540
+ return `<h${t}>${this.parser.parseInline(e)}</h${t}>
1541
+ `;
1542
+ }
1543
+ hr(e) {
1544
+ return `<hr>
1545
+ `;
1546
+ }
1547
+ list(e) {
1548
+ let t = e.ordered,
1549
+ n = e.start,
1550
+ s = "";
1551
+ for (let o = 0; o < e.items.length; o++) {
1552
+ const a = e.items[o];
1553
+ s += this.listitem(a);
1554
+ }
1555
+ const i = t ? "ol" : "ul",
1556
+ r = t && n !== 1 ? ' start="' + n + '"' : "";
1557
+ return (
1558
+ "<" +
1559
+ i +
1560
+ r +
1561
+ `>
1562
+ ` +
1563
+ s +
1564
+ "</" +
1565
+ i +
1566
+ `>
1567
+ `
1568
+ );
1569
+ }
1570
+ listitem(e) {
1571
+ let t = "";
1572
+ if (e.task) {
1573
+ const n = this.checkbox({ checked: !!e.checked });
1574
+ e.loose
1575
+ ? e.tokens[0]?.type === "paragraph"
1576
+ ? ((e.tokens[0].text = n + " " + e.tokens[0].text),
1577
+ e.tokens[0].tokens &&
1578
+ e.tokens[0].tokens.length > 0 &&
1579
+ e.tokens[0].tokens[0].type === "text" &&
1580
+ ((e.tokens[0].tokens[0].text =
1581
+ n + " " + R(e.tokens[0].tokens[0].text)),
1582
+ (e.tokens[0].tokens[0].escaped = !0)))
1583
+ : e.tokens.unshift({
1584
+ type: "text",
1585
+ raw: n + " ",
1586
+ text: n + " ",
1587
+ escaped: !0,
1588
+ })
1589
+ : (t += n + " ");
1590
+ }
1591
+ return (
1592
+ (t += this.parser.parse(e.tokens, !!e.loose)),
1593
+ `<li>${t}</li>
1594
+ `
1595
+ );
1596
+ }
1597
+ checkbox({ checked: e }) {
1598
+ return (
1599
+ "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox">'
1600
+ );
1601
+ }
1602
+ paragraph({ tokens: e }) {
1603
+ return `<p>${this.parser.parseInline(e)}</p>
1604
+ `;
1605
+ }
1606
+ table(e) {
1607
+ let t = "",
1608
+ n = "";
1609
+ for (let i = 0; i < e.header.length; i++)
1610
+ n += this.tablecell(e.header[i]);
1611
+ t += this.tablerow({ text: n });
1612
+ let s = "";
1613
+ for (let i = 0; i < e.rows.length; i++) {
1614
+ const r = e.rows[i];
1615
+ n = "";
1616
+ for (let o = 0; o < r.length; o++) n += this.tablecell(r[o]);
1617
+ s += this.tablerow({ text: n });
1618
+ }
1619
+ return (
1620
+ s && (s = `<tbody>${s}</tbody>`),
1621
+ `<table>
1622
+ <thead>
1623
+ ` +
1624
+ t +
1625
+ `</thead>
1626
+ ` +
1627
+ s +
1628
+ `</table>
1629
+ `
1630
+ );
1631
+ }
1632
+ tablerow({ text: e }) {
1633
+ return `<tr>
1634
+ ${e}</tr>
1635
+ `;
1636
+ }
1637
+ tablecell(e) {
1638
+ const t = this.parser.parseInline(e.tokens),
1639
+ n = e.header ? "th" : "td";
1640
+ return (
1641
+ (e.align ? `<${n} align="${e.align}">` : `<${n}>`) +
1642
+ t +
1643
+ `</${n}>
1644
+ `
1645
+ );
1646
+ }
1647
+ strong({ tokens: e }) {
1648
+ return `<strong>${this.parser.parseInline(e)}</strong>`;
1649
+ }
1650
+ em({ tokens: e }) {
1651
+ return `<em>${this.parser.parseInline(e)}</em>`;
1652
+ }
1653
+ codespan({ text: e }) {
1654
+ return `<code>${R(e, !0)}</code>`;
1655
+ }
1656
+ br(e) {
1657
+ return "<br>";
1658
+ }
1659
+ del({ tokens: e }) {
1660
+ return `<del>${this.parser.parseInline(e)}</del>`;
1661
+ }
1662
+ link({ href: e, title: t, tokens: n }) {
1663
+ const s = this.parser.parseInline(n),
1664
+ i = V(e);
1665
+ if (i === null) return s;
1666
+ e = i;
1667
+ let r = '<a href="' + e + '"';
1668
+ return t && (r += ' title="' + R(t) + '"'), (r += ">" + s + "</a>"), r;
1669
+ }
1670
+ image({ href: e, title: t, text: n, tokens: s }) {
1671
+ s && (n = this.parser.parseInline(s, this.parser.textRenderer));
1672
+ const i = V(e);
1673
+ if (i === null) return R(n);
1674
+ e = i;
1675
+ let r = `<img src="${e}" alt="${n}"`;
1676
+ return t && (r += ` title="${R(t)}"`), (r += ">"), r;
1677
+ }
1678
+ text(e) {
1679
+ return "tokens" in e && e.tokens
1680
+ ? this.parser.parseInline(e.tokens)
1681
+ : "escaped" in e && e.escaped
1682
+ ? e.text
1683
+ : R(e.text);
1684
+ }
1685
+ };
1686
+ var _ = class {
1687
+ strong({ text: e }) {
1688
+ return e;
1689
+ }
1690
+ em({ text: e }) {
1691
+ return e;
1692
+ }
1693
+ codespan({ text: e }) {
1694
+ return e;
1695
+ }
1696
+ del({ text: e }) {
1697
+ return e;
1698
+ }
1699
+ html({ text: e }) {
1700
+ return e;
1701
+ }
1702
+ text({ text: e }) {
1703
+ return e;
1704
+ }
1705
+ link({ text: e }) {
1706
+ return "" + e;
1707
+ }
1708
+ image({ text: e }) {
1709
+ return "" + e;
1710
+ }
1711
+ br() {
1712
+ return "";
1713
+ }
1714
+ };
1715
+ var b = class l {
1716
+ options;
1717
+ renderer;
1718
+ textRenderer;
1719
+ constructor(e) {
1720
+ (this.options = e || w),
1721
+ (this.options.renderer = this.options.renderer || new $()),
1722
+ (this.renderer = this.options.renderer),
1723
+ (this.renderer.options = this.options),
1724
+ (this.renderer.parser = this),
1725
+ (this.textRenderer = new _());
1726
+ }
1727
+ static parse(e, t) {
1728
+ return new l(t).parse(e);
1729
+ }
1730
+ static parseInline(e, t) {
1731
+ return new l(t).parseInline(e);
1732
+ }
1733
+ parse(e, t = !0) {
1734
+ let n = "";
1735
+ for (let s = 0; s < e.length; s++) {
1736
+ const i = e[s];
1737
+ if (this.options.extensions?.renderers?.[i.type]) {
1738
+ const o = i,
1739
+ a = this.options.extensions.renderers[o.type].call(
1740
+ { parser: this },
1741
+ o,
1742
+ );
1743
+ if (
1744
+ a !== !1 ||
1745
+ ![
1746
+ "space",
1747
+ "hr",
1748
+ "heading",
1749
+ "code",
1750
+ "table",
1751
+ "blockquote",
1752
+ "list",
1753
+ "html",
1754
+ "paragraph",
1755
+ "text",
1756
+ ].includes(o.type)
1757
+ ) {
1758
+ n += a || "";
1759
+ continue;
1760
+ }
1761
+ }
1762
+ const r = i;
1763
+ switch (r.type) {
1764
+ case "space": {
1765
+ n += this.renderer.space(r);
1766
+ continue;
1767
+ }
1768
+ case "hr": {
1769
+ n += this.renderer.hr(r);
1770
+ continue;
1771
+ }
1772
+ case "heading": {
1773
+ n += this.renderer.heading(r);
1774
+ continue;
1775
+ }
1776
+ case "code": {
1777
+ n += this.renderer.code(r);
1778
+ continue;
1779
+ }
1780
+ case "table": {
1781
+ n += this.renderer.table(r);
1782
+ continue;
1783
+ }
1784
+ case "blockquote": {
1785
+ n += this.renderer.blockquote(r);
1786
+ continue;
1787
+ }
1788
+ case "list": {
1789
+ n += this.renderer.list(r);
1790
+ continue;
1791
+ }
1792
+ case "html": {
1793
+ n += this.renderer.html(r);
1794
+ continue;
1795
+ }
1796
+ case "paragraph": {
1797
+ n += this.renderer.paragraph(r);
1798
+ continue;
1799
+ }
1800
+ case "text": {
1801
+ let o = r,
1802
+ a = this.renderer.text(o);
1803
+ for (; s + 1 < e.length && e[s + 1].type === "text"; )
1804
+ (o = e[++s]),
1805
+ (a +=
1806
+ `
1807
+ ` + this.renderer.text(o));
1808
+ t
1809
+ ? (n += this.renderer.paragraph({
1810
+ type: "paragraph",
1811
+ raw: a,
1812
+ text: a,
1813
+ tokens: [{ type: "text", raw: a, text: a, escaped: !0 }],
1814
+ }))
1815
+ : (n += a);
1816
+ continue;
1817
+ }
1818
+ default: {
1819
+ const o = 'Token with "' + r.type + '" type was not found.';
1820
+ if (this.options.silent) return console.error(o), "";
1821
+ throw new Error(o);
1822
+ }
1823
+ }
1824
+ }
1825
+ return n;
1826
+ }
1827
+ parseInline(e, t = this.renderer) {
1828
+ let n = "";
1829
+ for (let s = 0; s < e.length; s++) {
1830
+ const i = e[s];
1831
+ if (this.options.extensions?.renderers?.[i.type]) {
1832
+ const o = this.options.extensions.renderers[i.type].call(
1833
+ { parser: this },
1834
+ i,
1835
+ );
1836
+ if (
1837
+ o !== !1 ||
1838
+ ![
1839
+ "escape",
1840
+ "html",
1841
+ "link",
1842
+ "image",
1843
+ "strong",
1844
+ "em",
1845
+ "codespan",
1846
+ "br",
1847
+ "del",
1848
+ "text",
1849
+ ].includes(i.type)
1850
+ ) {
1851
+ n += o || "";
1852
+ continue;
1853
+ }
1854
+ }
1855
+ const r = i;
1856
+ switch (r.type) {
1857
+ case "escape": {
1858
+ n += t.text(r);
1859
+ break;
1860
+ }
1861
+ case "html": {
1862
+ n += t.html(r);
1863
+ break;
1864
+ }
1865
+ case "link": {
1866
+ n += t.link(r);
1867
+ break;
1868
+ }
1869
+ case "image": {
1870
+ n += t.image(r);
1871
+ break;
1872
+ }
1873
+ case "strong": {
1874
+ n += t.strong(r);
1875
+ break;
1876
+ }
1877
+ case "em": {
1878
+ n += t.em(r);
1879
+ break;
1880
+ }
1881
+ case "codespan": {
1882
+ n += t.codespan(r);
1883
+ break;
1884
+ }
1885
+ case "br": {
1886
+ n += t.br(r);
1887
+ break;
1888
+ }
1889
+ case "del": {
1890
+ n += t.del(r);
1891
+ break;
1892
+ }
1893
+ case "text": {
1894
+ n += t.text(r);
1895
+ break;
1896
+ }
1897
+ default: {
1898
+ const o = 'Token with "' + r.type + '" type was not found.';
1899
+ if (this.options.silent) return console.error(o), "";
1900
+ throw new Error(o);
1901
+ }
1902
+ }
1903
+ }
1904
+ return n;
1905
+ }
1906
+ };
1907
+ var L = class {
1908
+ options;
1909
+ block;
1910
+ constructor(e) {
1911
+ this.options = e || w;
1912
+ }
1913
+ static passThroughHooks = new Set([
1914
+ "preprocess",
1915
+ "postprocess",
1916
+ "processAllTokens",
1917
+ ]);
1918
+ preprocess(e) {
1919
+ return e;
1920
+ }
1921
+ postprocess(e) {
1922
+ return e;
1923
+ }
1924
+ processAllTokens(e) {
1925
+ return e;
1926
+ }
1927
+ provideLexer() {
1928
+ return this.block ? x.lex : x.lexInline;
1929
+ }
1930
+ provideParser() {
1931
+ return this.block ? b.parse : b.parseInline;
1932
+ }
1933
+ };
1934
+ var E = class {
1935
+ defaults = z();
1936
+ options = this.setOptions;
1937
+ parse = this.parseMarkdown(!0);
1938
+ parseInline = this.parseMarkdown(!1);
1939
+ Parser = b;
1940
+ Renderer = $;
1941
+ TextRenderer = _;
1942
+ Lexer = x;
1943
+ Tokenizer = S;
1944
+ Hooks = L;
1945
+ constructor(...e) {
1946
+ this.use(...e);
1947
+ }
1948
+ walkTokens(e, t) {
1949
+ let n = [];
1950
+ for (const s of e)
1951
+ switch (((n = n.concat(t.call(this, s))), s.type)) {
1952
+ case "table": {
1953
+ const i = s;
1954
+ for (const r of i.header)
1955
+ n = n.concat(this.walkTokens(r.tokens, t));
1956
+ for (const r of i.rows)
1957
+ for (const o of r) n = n.concat(this.walkTokens(o.tokens, t));
1958
+ break;
1959
+ }
1960
+ case "list": {
1961
+ const i = s;
1962
+ n = n.concat(this.walkTokens(i.items, t));
1963
+ break;
1964
+ }
1965
+ default: {
1966
+ const i = s;
1967
+ this.defaults.extensions?.childTokens?.[i.type]
1968
+ ? this.defaults.extensions.childTokens[i.type].forEach((r) => {
1969
+ const o = i[r].flat(1 / 0);
1970
+ n = n.concat(this.walkTokens(o, t));
1971
+ })
1972
+ : i.tokens && (n = n.concat(this.walkTokens(i.tokens, t)));
1973
+ }
1974
+ }
1975
+ return n;
1976
+ }
1977
+ use(...e) {
1978
+ const t = this.defaults.extensions || {
1979
+ renderers: {},
1980
+ childTokens: {},
1981
+ };
1982
+ return (
1983
+ e.forEach((n) => {
1984
+ const s = { ...n };
1985
+ if (
1986
+ ((s.async = this.defaults.async || s.async || !1),
1987
+ n.extensions &&
1988
+ (n.extensions.forEach((i) => {
1989
+ if (!i.name) throw new Error("extension name required");
1990
+ if ("renderer" in i) {
1991
+ const r = t.renderers[i.name];
1992
+ r
1993
+ ? (t.renderers[i.name] = function (...o) {
1994
+ let a = i.renderer.apply(this, o);
1995
+ return a === !1 && (a = r.apply(this, o)), a;
1996
+ })
1997
+ : (t.renderers[i.name] = i.renderer);
1998
+ }
1999
+ if ("tokenizer" in i) {
2000
+ if (
2001
+ !i.level ||
2002
+ (i.level !== "block" && i.level !== "inline")
2003
+ )
2004
+ throw new Error(
2005
+ "extension level must be 'block' or 'inline'",
2006
+ );
2007
+ const r = t[i.level];
2008
+ r ? r.unshift(i.tokenizer) : (t[i.level] = [i.tokenizer]),
2009
+ i.start &&
2010
+ (i.level === "block"
2011
+ ? t.startBlock
2012
+ ? t.startBlock.push(i.start)
2013
+ : (t.startBlock = [i.start])
2014
+ : i.level === "inline" &&
2015
+ (t.startInline
2016
+ ? t.startInline.push(i.start)
2017
+ : (t.startInline = [i.start])));
2018
+ }
2019
+ "childTokens" in i &&
2020
+ i.childTokens &&
2021
+ (t.childTokens[i.name] = i.childTokens);
2022
+ }),
2023
+ (s.extensions = t)),
2024
+ n.renderer)
2025
+ ) {
2026
+ const i = this.defaults.renderer || new $(this.defaults);
2027
+ for (const r in n.renderer) {
2028
+ if (!(r in i))
2029
+ throw new Error(`renderer '${r}' does not exist`);
2030
+ if (["options", "parser"].includes(r)) continue;
2031
+ const o = r,
2032
+ a = n.renderer[o],
2033
+ c = i[o];
2034
+ i[o] = (...p) => {
2035
+ let u = a.apply(i, p);
2036
+ return u === !1 && (u = c.apply(i, p)), u || "";
2037
+ };
2038
+ }
2039
+ s.renderer = i;
2040
+ }
2041
+ if (n.tokenizer) {
2042
+ const i = this.defaults.tokenizer || new S(this.defaults);
2043
+ for (const r in n.tokenizer) {
2044
+ if (!(r in i))
2045
+ throw new Error(`tokenizer '${r}' does not exist`);
2046
+ if (["options", "rules", "lexer"].includes(r)) continue;
2047
+ const o = r,
2048
+ a = n.tokenizer[o],
2049
+ c = i[o];
2050
+ i[o] = (...p) => {
2051
+ let u = a.apply(i, p);
2052
+ return u === !1 && (u = c.apply(i, p)), u;
2053
+ };
2054
+ }
2055
+ s.tokenizer = i;
2056
+ }
2057
+ if (n.hooks) {
2058
+ const i = this.defaults.hooks || new L();
2059
+ for (const r in n.hooks) {
2060
+ if (!(r in i)) throw new Error(`hook '${r}' does not exist`);
2061
+ if (["options", "block"].includes(r)) continue;
2062
+ const o = r,
2063
+ a = n.hooks[o],
2064
+ c = i[o];
2065
+ L.passThroughHooks.has(r)
2066
+ ? (i[o] = (p) => {
2067
+ if (this.defaults.async)
2068
+ return Promise.resolve(a.call(i, p)).then((d) =>
2069
+ c.call(i, d),
2070
+ );
2071
+ const u = a.call(i, p);
2072
+ return c.call(i, u);
2073
+ })
2074
+ : (i[o] = (...p) => {
2075
+ let u = a.apply(i, p);
2076
+ return u === !1 && (u = c.apply(i, p)), u;
2077
+ });
2078
+ }
2079
+ s.hooks = i;
2080
+ }
2081
+ if (n.walkTokens) {
2082
+ const i = this.defaults.walkTokens,
2083
+ r = n.walkTokens;
2084
+ s.walkTokens = function (o) {
2085
+ let a = [];
2086
+ return (
2087
+ a.push(r.call(this, o)),
2088
+ i && (a = a.concat(i.call(this, o))),
2089
+ a
2090
+ );
2091
+ };
2092
+ }
2093
+ this.defaults = { ...this.defaults, ...s };
2094
+ }),
2095
+ this
2096
+ );
2097
+ }
2098
+ setOptions(e) {
2099
+ return (this.defaults = { ...this.defaults, ...e }), this;
2100
+ }
2101
+ lexer(e, t) {
2102
+ return x.lex(e, t ?? this.defaults);
2103
+ }
2104
+ parser(e, t) {
2105
+ return b.parse(e, t ?? this.defaults);
2106
+ }
2107
+ parseMarkdown(e) {
2108
+ return (n, s) => {
2109
+ const i = { ...s },
2110
+ r = { ...this.defaults, ...i },
2111
+ o = this.onError(!!r.silent, !!r.async);
2112
+ if (this.defaults.async === !0 && i.async === !1)
2113
+ return o(
2114
+ new Error(
2115
+ "marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.",
2116
+ ),
2117
+ );
2118
+ if (typeof n > "u" || n === null)
2119
+ return o(
2120
+ new Error("marked(): input parameter is undefined or null"),
2121
+ );
2122
+ if (typeof n != "string")
2123
+ return o(
2124
+ new Error(
2125
+ "marked(): input parameter is of type " +
2126
+ Object.prototype.toString.call(n) +
2127
+ ", string expected",
2128
+ ),
2129
+ );
2130
+ r.hooks && ((r.hooks.options = r), (r.hooks.block = e));
2131
+ const a = r.hooks ? r.hooks.provideLexer() : e ? x.lex : x.lexInline,
2132
+ c = r.hooks ? r.hooks.provideParser() : e ? b.parse : b.parseInline;
2133
+ if (r.async)
2134
+ return Promise.resolve(r.hooks ? r.hooks.preprocess(n) : n)
2135
+ .then((p) => a(p, r))
2136
+ .then((p) => (r.hooks ? r.hooks.processAllTokens(p) : p))
2137
+ .then((p) =>
2138
+ r.walkTokens
2139
+ ? Promise.all(this.walkTokens(p, r.walkTokens)).then(() => p)
2140
+ : p,
2141
+ )
2142
+ .then((p) => c(p, r))
2143
+ .then((p) => (r.hooks ? r.hooks.postprocess(p) : p))
2144
+ .catch(o);
2145
+ try {
2146
+ r.hooks && (n = r.hooks.preprocess(n));
2147
+ let p = a(n, r);
2148
+ r.hooks && (p = r.hooks.processAllTokens(p)),
2149
+ r.walkTokens && this.walkTokens(p, r.walkTokens);
2150
+ let u = c(p, r);
2151
+ return r.hooks && (u = r.hooks.postprocess(u)), u;
2152
+ } catch (p) {
2153
+ return o(p);
2154
+ }
2155
+ };
2156
+ }
2157
+ onError(e, t) {
2158
+ return (n) => {
2159
+ if (
2160
+ ((n.message += `
2161
+ Please report this to https://github.com/markedjs/marked.`),
2162
+ e)
2163
+ ) {
2164
+ const s =
2165
+ "<p>An error occurred:</p><pre>" +
2166
+ R(n.message + "", !0) +
2167
+ "</pre>";
2168
+ return t ? Promise.resolve(s) : s;
2169
+ }
2170
+ if (t) return Promise.reject(n);
2171
+ throw n;
2172
+ };
2173
+ }
2174
+ };
2175
+ var M = new E();
2176
+ function k(l, e) {
2177
+ return M.parse(l, e);
2178
+ }
2179
+ k.options = k.setOptions = (l) => (
2180
+ M.setOptions(l), (k.defaults = M.defaults), N(k.defaults), k
2181
+ );
2182
+ k.getDefaults = z;
2183
+ k.defaults = w;
2184
+ k.use = (...l) => (
2185
+ M.use(...l), (k.defaults = M.defaults), N(k.defaults), k
2186
+ );
2187
+ k.walkTokens = (l, e) => M.walkTokens(l, e);
2188
+ k.parseInline = M.parseInline;
2189
+ k.Parser = b;
2190
+ k.parser = b.parse;
2191
+ k.Renderer = $;
2192
+ k.TextRenderer = _;
2193
+ k.Lexer = x;
2194
+ k.lexer = x.lex;
2195
+ k.Tokenizer = S;
2196
+ k.Hooks = L;
2197
+ k.parse = k;
2198
+ var it = k.options,
2199
+ ot = k.setOptions,
2200
+ lt = k.use,
2201
+ at = k.walkTokens,
2202
+ ct = k.parseInline,
2203
+ pt = k,
2204
+ ut = b.parse,
2205
+ ht = x.lex;
2206
+
2207
+ if (__exports != exports) module.exports = exports;
2208
+ return module.exports;
2209
+ },
2210
+ );