supamde 0.0.0-stage → 0.1.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 (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1225 -2
  3. package/dist/commands/block.d.ts +20 -0
  4. package/dist/commands/history.d.ts +6 -0
  5. package/dist/commands/indent.d.ts +18 -0
  6. package/dist/commands/inline.d.ts +9 -0
  7. package/dist/commands/keymap.d.ts +8 -0
  8. package/dist/commands/link-image.d.ts +13 -0
  9. package/dist/commands/list.d.ts +20 -0
  10. package/dist/commands/prefixes.d.ts +29 -0
  11. package/dist/commands/queries.d.ts +25 -0
  12. package/dist/commands/table.d.ts +7 -0
  13. package/dist/commands/types.d.ts +17 -0
  14. package/dist/editor/extensions.d.ts +14 -0
  15. package/dist/editor/highlight.d.ts +11 -0
  16. package/dist/editor/link-click.d.ts +53 -0
  17. package/dist/editor/link-hover-cursor.d.ts +44 -0
  18. package/dist/editor/math.d.ts +8 -0
  19. package/dist/editor/setup.d.ts +26 -0
  20. package/dist/editor/theme.d.ts +7 -0
  21. package/dist/editor/tokens.d.ts +16 -0
  22. package/dist/editor/value.d.ts +10 -0
  23. package/dist/features/autosave.d.ts +31 -0
  24. package/dist/features/image-upload.d.ts +73 -0
  25. package/dist/features/storage.d.ts +30 -0
  26. package/dist/features/upload-dom.d.ts +20 -0
  27. package/dist/features/upload-placeholder.d.ts +35 -0
  28. package/dist/features/word-count.d.ts +5 -0
  29. package/dist/i18n/de.d.ts +3 -0
  30. package/dist/i18n/en.d.ts +3 -0
  31. package/dist/i18n/facet.d.ts +9 -0
  32. package/dist/i18n/translator.d.ts +17 -0
  33. package/dist/i18n/types.d.ts +82 -0
  34. package/dist/index.d.ts +133 -0
  35. package/dist/livepreview/index.d.ts +22 -0
  36. package/dist/livepreview/plugin.d.ts +3 -0
  37. package/dist/livepreview/ranges.d.ts +62 -0
  38. package/dist/markdown/katex-marked.d.ts +20 -0
  39. package/dist/markdown/parse.d.ts +27 -0
  40. package/dist/markdown/sanitize.d.ts +6 -0
  41. package/dist/options.d.ts +80 -0
  42. package/dist/supamde.css +2 -0
  43. package/dist/supamde.mjs +3556 -0
  44. package/dist/supamde.mjs.map +1 -0
  45. package/dist/ui/actions.d.ts +51 -0
  46. package/dist/ui/fullscreen.d.ts +16 -0
  47. package/dist/ui/icons.d.ts +4 -0
  48. package/dist/ui/inject-styles.d.ts +13 -0
  49. package/dist/ui/preview.d.ts +27 -0
  50. package/dist/ui/shortcut-label.d.ts +24 -0
  51. package/dist/ui/statusbar.d.ts +28 -0
  52. package/dist/ui/toolbar-config.d.ts +36 -0
  53. package/dist/ui/toolbar.d.ts +16 -0
  54. package/dist/ui/update-listener.d.ts +15 -0
  55. package/dist/util/text-format.d.ts +11 -0
  56. package/dist/utils/html.d.ts +2 -0
  57. package/dist/utils/text.d.ts +41 -0
  58. package/dist/version.d.ts +2 -0
  59. package/package.json +96 -4
@@ -0,0 +1,3556 @@
1
+ import { Decoration as e, EditorView as t, ViewPlugin as n, keymap as r, placeholder as i } from "@codemirror/view";
2
+ import { Compartment as a, EditorState as o, Facet as s, RangeSet as c, StateEffect as l, StateField as u } from "@codemirror/state";
3
+ import { HighlightStyle as d, getIndentUnit as f, indentUnit as p, syntaxHighlighting as m, syntaxTree as ee } from "@codemirror/language";
4
+ import { copyLineDown as te, copyLineUp as ne, defaultKeymap as re, deleteLine as ie, history as ae, historyKeymap as oe, moveLineDown as se, moveLineUp as ce, redo as le, undo as ue } from "@codemirror/commands";
5
+ import { deleteMarkupBackward as de, markdown as fe } from "@codemirror/lang-markdown";
6
+ import { GFM as pe } from "@lezer/markdown";
7
+ import { tags as h } from "@lezer/highlight";
8
+ //#region src/version.ts
9
+ var me = "0.1.0";
10
+ //#endregion
11
+ //#region src/livepreview/ranges.ts
12
+ function he(e) {
13
+ return new Map(e.map((e) => [e, void 0]));
14
+ }
15
+ function ge(e) {
16
+ return (t) => t.startsWith(e);
17
+ }
18
+ var _e = {
19
+ inline: new Map([...he(["EmphasisMark", "StrikethroughMark"]), ["CodeMark", (e) => e === "InlineCode"]]),
20
+ block: new Map([...he(["QuoteMark"]), ["HeaderMark", ge("ATXHeading")]])
21
+ };
22
+ function ve(e, t) {
23
+ return t.some((t) => t.from <= e.to && t.to >= e.from);
24
+ }
25
+ function ye(e, t, n) {
26
+ let r = e.doc.lineAt(t.from), i = e.doc.sliceString(r.from, r.to);
27
+ if (t.to >= n.to) {
28
+ let e = t.from;
29
+ for (; e > r.from && i[e - r.from - 1] === " ";) e--;
30
+ return {
31
+ from: e,
32
+ to: t.to
33
+ };
34
+ }
35
+ let a = t.to;
36
+ for (; a < r.to && i[a - r.from] === " ";) a++;
37
+ return {
38
+ from: t.from,
39
+ to: a
40
+ };
41
+ }
42
+ function be(e, t, n = _e) {
43
+ let r = e.selection.ranges, i = [], a = ee(e);
44
+ for (let o of t) a.iterate({
45
+ from: o.from,
46
+ to: o.to,
47
+ enter: (t) => {
48
+ let a = t.name, o = n.inline.has(a), s = n.block.has(a);
49
+ if (!o && !s) return;
50
+ let c = t.node.parent;
51
+ if (!c) return;
52
+ let l = s ? n.block.get(a) : n.inline.get(a);
53
+ (!l || l(c.name)) && (ve(c, r) || i.push(s ? ye(e, t.node, c) : {
54
+ from: t.from,
55
+ to: t.to
56
+ }));
57
+ }
58
+ });
59
+ i.sort((e, t) => e.from - t.from || e.to - t.to);
60
+ let o = [];
61
+ for (let e of i) {
62
+ let t = o[o.length - 1];
63
+ t && e.from <= t.to ? e.to > t.to && (t.to = e.to) : o.push({ ...e });
64
+ }
65
+ return o;
66
+ }
67
+ //#endregion
68
+ //#region src/livepreview/plugin.ts
69
+ var xe = e.replace({});
70
+ function Se(e) {
71
+ let t = be(e.state, e.visibleRanges);
72
+ return c.of(t.map((e) => xe.range(e.from, e.to)), !1);
73
+ }
74
+ var Ce = n.fromClass(class {
75
+ decorations;
76
+ constructor(e) {
77
+ this.decorations = Se(e);
78
+ }
79
+ update(e) {
80
+ (e.docChanged || e.selectionSet || e.viewportChanged) && (this.decorations = Se(e.view));
81
+ }
82
+ }, {
83
+ decorations: (e) => e.decorations,
84
+ provide: (n) => t.atomicRanges.of((t) => t.plugin(n)?.decorations ?? e.none)
85
+ }), we = ["source", "live"], Te = Ce, Ee = new a();
86
+ function De(e) {
87
+ return e === "live" ? Te : [];
88
+ }
89
+ //#endregion
90
+ //#region src/options.ts
91
+ function Oe(e) {
92
+ return e === void 0 ? "source" : we.includes(e) ? e : (console.warn(`SupaMDE: unknown editorMode "${String(e)}" — using "source".`), "source");
93
+ }
94
+ function ke(e) {
95
+ return {
96
+ lineWrapping: e.lineWrapping ?? !0,
97
+ placeholder: e.placeholder ?? null,
98
+ autofocus: e.autofocus ?? !1,
99
+ tabSize: e.tabSize ?? 2,
100
+ indentUnit: e.indentUnit ?? 2,
101
+ extraKeys: e.extraKeys ?? [],
102
+ editorMode: Oe(e.editorMode)
103
+ };
104
+ }
105
+ //#endregion
106
+ //#region src/editor/tokens.ts
107
+ var Ae = {
108
+ quote: "#6a737d",
109
+ link: "#0366d6",
110
+ border: "#ddd"
111
+ }, je = "system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif", Me = d.define([
112
+ {
113
+ tag: h.heading1,
114
+ fontSize: "1.6em",
115
+ fontWeight: "bold"
116
+ },
117
+ {
118
+ tag: h.heading2,
119
+ fontSize: "1.4em",
120
+ fontWeight: "bold"
121
+ },
122
+ {
123
+ tag: h.heading3,
124
+ fontSize: "1.25em",
125
+ fontWeight: "bold"
126
+ },
127
+ {
128
+ tag: h.heading4,
129
+ fontSize: "1.15em",
130
+ fontWeight: "bold"
131
+ },
132
+ {
133
+ tag: [h.heading5, h.heading6],
134
+ fontWeight: "bold"
135
+ },
136
+ {
137
+ tag: h.strong,
138
+ fontWeight: "bold"
139
+ },
140
+ {
141
+ tag: h.emphasis,
142
+ fontStyle: "italic"
143
+ },
144
+ {
145
+ tag: h.strikethrough,
146
+ textDecoration: "line-through"
147
+ },
148
+ {
149
+ tag: h.monospace,
150
+ fontFamily: "monospace"
151
+ },
152
+ {
153
+ tag: h.quote,
154
+ color: Ae.quote,
155
+ fontStyle: "italic"
156
+ },
157
+ {
158
+ tag: h.link,
159
+ color: Ae.link,
160
+ textDecoration: "underline"
161
+ },
162
+ {
163
+ tag: h.url,
164
+ color: Ae.link
165
+ }
166
+ ]), Ne = m(Me), Pe = 36;
167
+ function Fe(e, t, n) {
168
+ if (t != Pe || e.char(n + 1) != Pe) return -1;
169
+ let r = e.text.indexOf("$$", n + 2 - e.offset);
170
+ if (r < 0) return -1;
171
+ let i = r + e.offset + 2;
172
+ return e.addElement(e.elt("BlockMath", n, i));
173
+ }
174
+ function Ie(e, t, n) {
175
+ if (t != Pe) return -1;
176
+ let r = e.text.indexOf("$", n + 1 - e.offset);
177
+ if (r < 0) return -1;
178
+ let i = r + e.offset + 1;
179
+ return i == n + 2 ? -1 : e.addElement(e.elt("InlineMath", n, i));
180
+ }
181
+ var Le = {
182
+ defineNodes: ["InlineMath", "BlockMath"],
183
+ parseInline: [{
184
+ name: "BlockMath",
185
+ before: "Escape",
186
+ parse: Fe
187
+ }, {
188
+ name: "InlineMath",
189
+ before: "Escape",
190
+ parse: Ie
191
+ }]
192
+ }, Re = /^(https?:\/\/|mailto:)/i, ze = /^[^\s@]+@[^\s@]+$/, Be = /^www\./i, Ve = /* @__PURE__ */ new Set([
193
+ "/",
194
+ ":",
195
+ "@",
196
+ "."
197
+ ]);
198
+ function He(e, t) {
199
+ return Re.test(e) ? e : Be.test(e) ? `https://${e}` : ze.test(e) ? t !== void 0 && Ve.has(t) ? null : `mailto:${e}` : e;
200
+ }
201
+ function Ue(e) {
202
+ for (let t = e; t; t = t.parent) if (t.name === "Link" || t.name === "Autolink") return t;
203
+ return null;
204
+ }
205
+ function We(e) {
206
+ for (let t = e; t; t = t.parent) {
207
+ if (t.name === "URL") return t;
208
+ if (t.name === "Link" || t.name === "Autolink") return null;
209
+ }
210
+ return null;
211
+ }
212
+ function Ge(e, t) {
213
+ let n = ee(e).resolveInner(t, 0), r = Ue(n);
214
+ if (r) {
215
+ let t = r.getChild("URL");
216
+ if (!t) return null;
217
+ let n = e.doc.sliceString(t.from, t.to);
218
+ return Re.test(n) ? n : null;
219
+ }
220
+ let i = We(n);
221
+ if (i) {
222
+ let t = i.from > 0 ? e.doc.sliceString(i.from - 1, i.from) : void 0, n = He(e.doc.sliceString(i.from, i.to), t);
223
+ return n === null ? null : Re.test(n) ? n : null;
224
+ }
225
+ return null;
226
+ }
227
+ function Ke(e, t) {
228
+ if (!e.metaKey && !e.ctrlKey) return !1;
229
+ let n = t.posAtCoords({
230
+ x: e.clientX,
231
+ y: e.clientY
232
+ });
233
+ if (n === null) return !1;
234
+ let r = Ge(t.state, n);
235
+ return r ? (window.open(r, "_blank", "noopener,noreferrer"), e.preventDefault(), !0) : !1;
236
+ }
237
+ var qe = t.domEventHandlers({ mousedown: Ke }), Je = "supamde-link-hover";
238
+ function Ye(e) {
239
+ return e.ctrlKey || e.metaKey;
240
+ }
241
+ var Xe = class {
242
+ view;
243
+ lastX = 0;
244
+ lastY = 0;
245
+ hasMousePosition = !1;
246
+ modifierDown = !1;
247
+ onMouseMove = (e) => {
248
+ this.lastX = e.clientX, this.lastY = e.clientY, this.hasMousePosition = !0, this.updateState();
249
+ };
250
+ onKeyDown = (e) => {
251
+ Ye(e) && (this.modifierDown = !0, this.updateState());
252
+ };
253
+ onKeyUp = (e) => {
254
+ (e.key === "Control" || e.key === "Meta") && (this.modifierDown = e.ctrlKey || e.metaKey, this.updateState());
255
+ };
256
+ onBlur = () => {
257
+ this.modifierDown = !1, this.updateState();
258
+ };
259
+ constructor(e) {
260
+ this.view = e, window.addEventListener("mousemove", this.onMouseMove), window.addEventListener("keydown", this.onKeyDown), window.addEventListener("keyup", this.onKeyUp), window.addEventListener("blur", this.onBlur);
261
+ }
262
+ update(e) {
263
+ this.modifierDown && this.hasMousePosition && this.view.requestMeasure({ read: () => this.updateState() });
264
+ }
265
+ destroy() {
266
+ window.removeEventListener("mousemove", this.onMouseMove), window.removeEventListener("keydown", this.onKeyDown), window.removeEventListener("keyup", this.onKeyUp), window.removeEventListener("blur", this.onBlur);
267
+ }
268
+ updateState() {
269
+ let e = this.modifierDown && this.hasMousePosition && this.pointerIsOverLink();
270
+ this.view.contentDOM.classList.toggle(Je, e);
271
+ }
272
+ pointerIsOverLink() {
273
+ let e = this.view.posAtCoords({
274
+ x: this.lastX,
275
+ y: this.lastY
276
+ });
277
+ return e !== null && Ge(this.view.state, e) !== null;
278
+ }
279
+ }, Ze = n.fromClass(Xe), Qe = t.theme({
280
+ "&": {
281
+ fontFamily: je,
282
+ fontSize: "16px"
283
+ },
284
+ ".cm-content": {
285
+ padding: "10px 12px",
286
+ lineHeight: "1.5"
287
+ },
288
+ ".cm-scroller": { fontFamily: "inherit" },
289
+ [`.cm-content.${Je}`]: { cursor: "pointer" }
290
+ }), $e = [
291
+ /^#{1,6} /,
292
+ /^> /,
293
+ /^- \[[ xX]\] /,
294
+ /^\d+\. /,
295
+ /^[-*] /
296
+ ];
297
+ function et(e) {
298
+ let t = /^[ \t]*/.exec(e)[0], n = e.slice(t.length);
299
+ for (let e of $e) {
300
+ let r = e.exec(n);
301
+ if (r) return {
302
+ indent: t,
303
+ prefix: r[0],
304
+ rest: n.slice(r[0].length)
305
+ };
306
+ }
307
+ return null;
308
+ }
309
+ function tt(e, t) {
310
+ if (e.startsWith(" ")) return 1;
311
+ let n = 0;
312
+ for (; n < t && e[n] === " ";) n++;
313
+ return n;
314
+ }
315
+ //#endregion
316
+ //#region src/utils/text.ts
317
+ function g(e, t) {
318
+ let n = e.state.changes(t);
319
+ e.dispatch({
320
+ changes: n,
321
+ selection: e.state.selection.map(n, 1)
322
+ });
323
+ }
324
+ function _(e) {
325
+ let t = e.selection.main, n = e.doc.lineAt(t.from), r = e.doc.lineAt(t.to);
326
+ return {
327
+ from: n.from,
328
+ to: r.to,
329
+ firstLine: n.number,
330
+ lastLine: r.number
331
+ };
332
+ }
333
+ function nt(e, t) {
334
+ let n = _(e.state), r = [];
335
+ for (let i = n.firstLine; i <= n.lastLine; i++) {
336
+ let n = t(e.state.doc.line(i));
337
+ n !== null && r.push(n);
338
+ }
339
+ return r.length !== 0 && (g(e, r), !0);
340
+ }
341
+ function rt(e, t) {
342
+ let { state: n } = e, r = _(n), i = [], a = !0;
343
+ for (let e = r.firstLine; e <= r.lastLine; e++) if (!n.doc.line(e).text.startsWith(t)) {
344
+ a = !1;
345
+ break;
346
+ }
347
+ for (let e = r.firstLine; e <= r.lastLine; e++) {
348
+ let r = n.doc.line(e);
349
+ a ? i.push({
350
+ from: r.from,
351
+ to: r.from + t.length,
352
+ insert: ""
353
+ }) : r.text.startsWith(t) || i.push({
354
+ from: r.from,
355
+ to: r.from,
356
+ insert: t
357
+ });
358
+ }
359
+ return i.length !== 0 && (g(e, i), !0);
360
+ }
361
+ function it(e, t, n) {
362
+ let r = e.state.selection.main;
363
+ return e.dispatch({
364
+ changes: [{
365
+ from: r.from,
366
+ insert: t
367
+ }, {
368
+ from: r.to,
369
+ insert: n
370
+ }],
371
+ selection: r.empty ? { anchor: r.from + t.length } : {
372
+ anchor: r.from + t.length,
373
+ head: r.to + t.length
374
+ }
375
+ }), !0;
376
+ }
377
+ //#endregion
378
+ //#region src/commands/queries.ts
379
+ function v(e, t) {
380
+ let n = e.selection.main, r = ee(e).resolveInner(n.from, 1);
381
+ for (; r;) {
382
+ if (r.name === t && r.from <= n.from && r.to >= n.to) return r;
383
+ r = r.parent;
384
+ }
385
+ return null;
386
+ }
387
+ function y(e) {
388
+ let { firstLine: t } = _(e);
389
+ return e.doc.line(t).text;
390
+ }
391
+ function at(e) {
392
+ return v(e, "StrongEmphasis") !== null;
393
+ }
394
+ function ot(e) {
395
+ return v(e, "Emphasis") !== null;
396
+ }
397
+ function st(e) {
398
+ return v(e, "Strikethrough") !== null;
399
+ }
400
+ function ct(e) {
401
+ return v(e, "InlineCode") !== null;
402
+ }
403
+ function b(e) {
404
+ let t = /^(#{1,6}) /.exec(y(e));
405
+ return t ? t[0].length - 1 : 0;
406
+ }
407
+ function lt(e) {
408
+ return y(e).startsWith("> ");
409
+ }
410
+ function ut(e) {
411
+ let t = y(e);
412
+ return /^[-*] /.test(t) && !/^- \[[ xX]\] /.test(t);
413
+ }
414
+ function dt(e) {
415
+ return /^\d+\. /.test(y(e));
416
+ }
417
+ function ft(e) {
418
+ return /^- \[[ xX]\] /.test(y(e));
419
+ }
420
+ //#endregion
421
+ //#region src/commands/block.ts
422
+ function x(e, t) {
423
+ let n = _(e.state), r = [];
424
+ for (let i = n.firstLine; i <= n.lastLine; i++) {
425
+ let n = e.state.doc.line(i), a = /^(#{1,6}) /.exec(n.text), o = a ? a[0].length : 0, s = t === 0 ? "" : "#".repeat(t) + " ";
426
+ r.push({
427
+ from: n.from,
428
+ to: n.from + o,
429
+ insert: s
430
+ });
431
+ }
432
+ return r.some((e) => e.from !== e.to || e.insert !== "") ? (e.dispatch({ changes: r }), !0) : !1;
433
+ }
434
+ function S(e) {
435
+ return (t) => x(t, b(t.state) === e ? 0 : e);
436
+ }
437
+ var pt = (e) => x(e, Math.min(b(e.state) + 1, 6)), mt = (e) => x(e, Math.max(b(e.state) - 1, 0)), ht = (e) => rt(e, "> "), gt = (e) => {
438
+ let t = e.state.selection.main, n = "```\n", r = "\n```", i = e.state.sliceDoc(Math.max(0, t.from - 4), t.from), a = e.state.sliceDoc(t.to, Math.min(e.state.doc.length, t.to + 4));
439
+ return i === n && a === r ? (e.dispatch({ changes: [{
440
+ from: t.from - 4,
441
+ to: t.from,
442
+ insert: ""
443
+ }, {
444
+ from: t.to,
445
+ to: t.to + 4,
446
+ insert: ""
447
+ }] }), !0) : it(e, n, r);
448
+ }, _t = (e) => {
449
+ let t = e.state.doc.lineAt(e.state.selection.main.head);
450
+ return e.dispatch({ changes: {
451
+ from: t.to,
452
+ insert: "\n---\n"
453
+ } }), !0;
454
+ }, vt = (e) => {
455
+ let t = _(e.state), n = [];
456
+ for (let r = t.firstLine; r <= t.lastLine; r++) {
457
+ let t = e.state.doc.line(r), i = et(t.text);
458
+ if (i) {
459
+ let e = t.from + i.indent.length;
460
+ n.push({
461
+ from: e,
462
+ to: e + i.prefix.length,
463
+ insert: ""
464
+ });
465
+ }
466
+ }
467
+ return n.length !== 0 && (e.dispatch({ changes: n }), !0);
468
+ }, yt = /^[-*] $/;
469
+ function bt(e) {
470
+ let t = et(e);
471
+ if (t === null) return {
472
+ indent: /^[ \t]*/.exec(e)[0],
473
+ bullet: null,
474
+ hasPrefix: !1
475
+ };
476
+ let n = yt.test(t.prefix);
477
+ return {
478
+ indent: t.indent,
479
+ bullet: n ? t.prefix : null,
480
+ hasPrefix: !0
481
+ };
482
+ }
483
+ function xt(e, t) {
484
+ let n = _(e.state), r = [];
485
+ for (let t = n.firstLine; t <= n.lastLine; t++) {
486
+ let n = e.state.doc.line(t);
487
+ r.push({
488
+ from: n.from,
489
+ ...bt(n.text)
490
+ });
491
+ }
492
+ let i = r.every((e) => e.bullet === t), a = [];
493
+ for (let e of r) {
494
+ let { indent: n, bullet: r, hasPrefix: o } = e, s = e.from + n.length;
495
+ i ? a.push({
496
+ from: s,
497
+ to: s + t.length,
498
+ insert: ""
499
+ }) : r === null ? o || a.push({
500
+ from: s,
501
+ to: s,
502
+ insert: t
503
+ }) : a.push({
504
+ from: s,
505
+ to: s + r.length,
506
+ insert: t
507
+ });
508
+ }
509
+ return a.length !== 0 && (g(e, a), !0);
510
+ }
511
+ var St = (e) => xt(e, "- "), Ct = (e) => xt(e, "* "), wt = (e) => rt(e, "- [ ] "), Tt = (e) => {
512
+ let t = _(e.state), n = !0;
513
+ for (let r = t.firstLine; r <= t.lastLine; r++) if (!/^\d+\. /.test(e.state.doc.line(r).text)) {
514
+ n = !1;
515
+ break;
516
+ }
517
+ let r = [], i = 1;
518
+ for (let a = t.firstLine; a <= t.lastLine; a++) {
519
+ let t = e.state.doc.line(a);
520
+ if (n) {
521
+ let e = /^\d+\. /.exec(t.text), n = e ? e[0].length : 0;
522
+ r.push({
523
+ from: t.from,
524
+ to: t.from + n,
525
+ insert: ""
526
+ });
527
+ } else r.push({
528
+ from: t.from,
529
+ to: t.from,
530
+ insert: `${i}. `
531
+ }), i++;
532
+ }
533
+ return g(e, r), !0;
534
+ };
535
+ function Et(e) {
536
+ if (/^- \[[ xX]\] $/.test(e)) return "- [ ] ";
537
+ let t = /^(\d+)\. $/.exec(e);
538
+ return t ? `${Number(t[1]) + 1}. ` : e === "* " || e === "- " ? e : null;
539
+ }
540
+ function Dt(e) {
541
+ let t = e.state.selection.main, n = e.state.doc.lineAt(t.head), r = et(n.text);
542
+ if (r === null) return !1;
543
+ let i = Et(r.prefix);
544
+ if (i === null) return !1;
545
+ let a = n.from + r.indent.length + r.prefix.length;
546
+ if (t.from < a) return !1;
547
+ if (r.rest.length === 0) return e.dispatch({
548
+ changes: {
549
+ from: n.from,
550
+ to: n.to,
551
+ insert: ""
552
+ },
553
+ selection: { anchor: n.from }
554
+ }), !0;
555
+ let o = `\n${r.indent}${i}`;
556
+ return e.dispatch({
557
+ changes: {
558
+ from: t.head,
559
+ insert: o
560
+ },
561
+ selection: { anchor: t.head + o.length }
562
+ }), !0;
563
+ }
564
+ //#endregion
565
+ //#region src/commands/indent.ts
566
+ var Ot = (e) => {
567
+ let t = " ".repeat(f(e.state));
568
+ return nt(e, (e) => ({
569
+ from: e.from,
570
+ to: e.from,
571
+ insert: t
572
+ })), !0;
573
+ }, kt = (e) => {
574
+ let t = f(e.state);
575
+ return nt(e, (e) => {
576
+ let n = tt(e.text, t);
577
+ return n > 0 ? {
578
+ from: e.from,
579
+ to: e.from + n,
580
+ insert: ""
581
+ } : null;
582
+ }), !0;
583
+ };
584
+ //#endregion
585
+ //#region src/commands/inline.ts
586
+ function At(e, t) {
587
+ return v(e.state, t.node);
588
+ }
589
+ function jt(e, t, n) {
590
+ let r = [];
591
+ for (let e = t.firstChild; e; e = e.nextSibling) e.name === n && r.push({
592
+ from: e.from,
593
+ to: e.to
594
+ });
595
+ return r.length !== 0 && (e.dispatch({ changes: r.map((e) => ({
596
+ from: e.from,
597
+ to: e.to,
598
+ insert: ""
599
+ })) }), !0);
600
+ }
601
+ function C(e) {
602
+ return (t) => {
603
+ let n = At(t, e);
604
+ return n ? jt(t, n, e.mark) : it(t, e.before, e.after);
605
+ };
606
+ }
607
+ var Mt = C({
608
+ node: "StrongEmphasis",
609
+ mark: "EmphasisMark",
610
+ before: "**",
611
+ after: "**"
612
+ }), Nt = C({
613
+ node: "Emphasis",
614
+ mark: "EmphasisMark",
615
+ before: "*",
616
+ after: "*"
617
+ }), Pt = C({
618
+ node: "Strikethrough",
619
+ mark: "StrikethroughMark",
620
+ before: "~~",
621
+ after: "~~"
622
+ }), Ft = C({
623
+ node: "InlineCode",
624
+ mark: "CodeMark",
625
+ before: "`",
626
+ after: "`"
627
+ }), w = {
628
+ code: "en",
629
+ texts: {
630
+ "toolbar.bold": "Bold",
631
+ "toolbar.italic": "Italic",
632
+ "toolbar.strikethrough": "Strikethrough",
633
+ "toolbar.code": "Inline code",
634
+ "toolbar.heading-smaller": "Smaller heading",
635
+ "toolbar.heading-bigger": "Bigger heading",
636
+ "toolbar.heading-1": "Heading 1",
637
+ "toolbar.heading-2": "Heading 2",
638
+ "toolbar.heading-3": "Heading 3",
639
+ "toolbar.heading-4": "Heading 4",
640
+ "toolbar.heading-5": "Heading 5",
641
+ "toolbar.heading-6": "Heading 6",
642
+ "toolbar.quote": "Blockquote",
643
+ "toolbar.code-block": "Code block",
644
+ "toolbar.horizontal-rule": "Horizontal rule",
645
+ "toolbar.clean-block": "Clear formatting",
646
+ "toolbar.unordered-list": "Bulleted list",
647
+ "toolbar.ordered-list": "Numbered list",
648
+ "toolbar.check-list": "Checklist",
649
+ "toolbar.link": "Link",
650
+ "toolbar.image": "Image",
651
+ "toolbar.table": "Table",
652
+ "toolbar.undo": "Undo",
653
+ "toolbar.redo": "Redo",
654
+ "toolbar.side-by-side": "Side-by-side preview",
655
+ "toolbar.fullscreen": "Fullscreen",
656
+ "toolbar.preview-fullscreen": "Fullscreen preview",
657
+ "toolbar.editor-mode": "Live preview",
658
+ "toolbar.upload-image": "Upload image",
659
+ "status.lines": {
660
+ one: "{count} line",
661
+ other: "{count} lines"
662
+ },
663
+ "status.words": {
664
+ one: "{count} word",
665
+ other: "{count} words"
666
+ },
667
+ "status.autosaved": "Saved: {time}",
668
+ "upload.placeholder": "![Uploading {name}…]()",
669
+ "upload.statusInit": "Drag an image here or paste it",
670
+ "upload.statusUploading": "Uploading {name}…",
671
+ "upload.statusDone": "{name} uploaded",
672
+ "upload.errorTooLarge": "{name} is too large (max. {maxSize}).",
673
+ "upload.errorType": "{name} is not a supported image format.",
674
+ "upload.errorFailed": "Upload of {name} failed.",
675
+ "prompt.linkUrl": "Link URL:",
676
+ "prompt.imageUrl": "Image URL:",
677
+ "table.column": "Column {n}"
678
+ }
679
+ };
680
+ //#endregion
681
+ //#region src/util/text-format.ts
682
+ function It(e, t) {
683
+ return e.replace(/\{(\w+)\}/g, (e, n) => Object.prototype.hasOwnProperty.call(t, n) ? t[n] : e);
684
+ }
685
+ function Lt(e) {
686
+ return e >= 1048576 ? `${Math.round(e / 1048576)} MB` : e >= 1024 ? `${Math.round(e / 1024)} KB` : `${e} B`;
687
+ }
688
+ //#endregion
689
+ //#region src/i18n/translator.ts
690
+ var T = "en", Rt = {
691
+ hour: "2-digit",
692
+ minute: "2-digit"
693
+ };
694
+ function zt(e, t) {
695
+ return typeof e == "string" ? typeof t == "string" : typeof t == "object" && !!t && typeof t.other == "string";
696
+ }
697
+ function Bt(e) {
698
+ let t = { ...w.texts };
699
+ for (let n of e) if (typeof n == "object" && n) for (let e of Object.keys(w.texts)) {
700
+ let r = n[e];
701
+ zt(w.texts[e], r) && (t[e] = r);
702
+ }
703
+ return t;
704
+ }
705
+ function Vt(e) {
706
+ if (typeof e == "string") try {
707
+ return {
708
+ code: e,
709
+ rules: new Intl.PluralRules(e),
710
+ time: new Intl.DateTimeFormat(e, Rt)
711
+ };
712
+ } catch {}
713
+ return console.warn(`SupaMDE: invalid locale code "${String(e)}" — using "${T}" for plural rules and time format.`), {
714
+ code: T,
715
+ rules: new Intl.PluralRules(T),
716
+ time: new Intl.DateTimeFormat(T, Rt)
717
+ };
718
+ }
719
+ function E(e, t) {
720
+ let n = Bt([e?.texts, t]), r = Vt(e == null ? T : e.code), i = n;
721
+ return {
722
+ code: r.code,
723
+ t(e, t = {}) {
724
+ let n = i[e];
725
+ return typeof n == "string" ? It(n, t) : e;
726
+ },
727
+ plural(e, t, i = {}) {
728
+ let a = n[e], o = a[r.rules.select(t)];
729
+ return It(typeof o == "string" ? o : a.other, {
730
+ ...i,
731
+ count: String(t)
732
+ });
733
+ },
734
+ formatTime(e) {
735
+ return r.time.format(e);
736
+ }
737
+ };
738
+ }
739
+ //#endregion
740
+ //#region src/i18n/facet.ts
741
+ var Ht = E(), D = s.define({ combine: (e) => e[0] ?? Ht });
742
+ //#endregion
743
+ //#region src/commands/link-image.ts
744
+ function Ut(e, t) {
745
+ return (n) => {
746
+ if (!e) return !1;
747
+ let r = n.state.selection.main, i = `[${t ?? n.state.sliceDoc(r.from, r.to)}](${e})`;
748
+ return n.dispatch({
749
+ changes: {
750
+ from: r.from,
751
+ to: r.to,
752
+ insert: i
753
+ },
754
+ selection: { anchor: r.from + i.length }
755
+ }), !0;
756
+ };
757
+ }
758
+ function Wt(e, t) {
759
+ return (n) => {
760
+ if (!e) return !1;
761
+ let r = n.state.selection.main, i = `![${t ?? n.state.sliceDoc(r.from, r.to)}](${e})`;
762
+ return n.dispatch({
763
+ changes: {
764
+ from: r.from,
765
+ to: r.to,
766
+ insert: i
767
+ },
768
+ selection: { anchor: r.from + i.length }
769
+ }), !0;
770
+ };
771
+ }
772
+ function Gt(e) {
773
+ let t = window.prompt(e.state.facet(D).t("prompt.linkUrl"), "https://");
774
+ return t ? Ut(t)(e) : !1;
775
+ }
776
+ function Kt(e) {
777
+ let t = window.prompt(e.state.facet(D).t("prompt.imageUrl"), "https://");
778
+ return t ? Wt(t)(e) : !1;
779
+ }
780
+ //#endregion
781
+ //#region src/commands/table.ts
782
+ var qt = (e) => {
783
+ let t = e.state.facet(D), n = `| ${t.t("table.column", { n: "1" })} | ${t.t("table.column", { n: "2" })} |\n| --- | --- |\n| | |\n`, r = e.state.selection.main;
784
+ return e.dispatch({
785
+ changes: {
786
+ from: r.from,
787
+ to: r.to,
788
+ insert: n
789
+ },
790
+ selection: { anchor: r.from + n.length }
791
+ }), !0;
792
+ };
793
+ //#endregion
794
+ //#region src/ui/actions.ts
795
+ function O(e) {
796
+ return (t) => b(t) === e;
797
+ }
798
+ var Jt = {
799
+ bold: {
800
+ kind: "command",
801
+ command: Mt,
802
+ query: at,
803
+ icon: "bold",
804
+ shortcut: "Mod-b"
805
+ },
806
+ italic: {
807
+ kind: "command",
808
+ command: Nt,
809
+ query: ot,
810
+ icon: "italic",
811
+ shortcut: "Mod-i"
812
+ },
813
+ strikethrough: {
814
+ kind: "command",
815
+ command: Pt,
816
+ query: st,
817
+ icon: "strikethrough"
818
+ },
819
+ code: {
820
+ kind: "command",
821
+ command: Ft,
822
+ query: ct,
823
+ icon: "code"
824
+ },
825
+ "heading-smaller": {
826
+ kind: "command",
827
+ command: pt,
828
+ icon: "heading",
829
+ shortcut: "Mod-h"
830
+ },
831
+ "heading-bigger": {
832
+ kind: "command",
833
+ command: mt,
834
+ icon: "heading",
835
+ shortcut: "Shift-Mod-h"
836
+ },
837
+ "heading-1": {
838
+ kind: "command",
839
+ command: S(1),
840
+ query: O(1),
841
+ icon: "heading",
842
+ shortcut: "Ctrl-Alt-1"
843
+ },
844
+ "heading-2": {
845
+ kind: "command",
846
+ command: S(2),
847
+ query: O(2),
848
+ icon: "heading",
849
+ shortcut: "Ctrl-Alt-2"
850
+ },
851
+ "heading-3": {
852
+ kind: "command",
853
+ command: S(3),
854
+ query: O(3),
855
+ icon: "heading",
856
+ shortcut: "Ctrl-Alt-3"
857
+ },
858
+ "heading-4": {
859
+ kind: "command",
860
+ command: S(4),
861
+ query: O(4),
862
+ icon: "heading",
863
+ shortcut: "Ctrl-Alt-4"
864
+ },
865
+ "heading-5": {
866
+ kind: "command",
867
+ command: S(5),
868
+ query: O(5),
869
+ icon: "heading",
870
+ shortcut: "Ctrl-Alt-5"
871
+ },
872
+ "heading-6": {
873
+ kind: "command",
874
+ command: S(6),
875
+ query: O(6),
876
+ icon: "heading",
877
+ shortcut: "Ctrl-Alt-6"
878
+ },
879
+ quote: {
880
+ kind: "command",
881
+ command: ht,
882
+ query: lt,
883
+ icon: "quote",
884
+ shortcut: "Mod-'"
885
+ },
886
+ "code-block": {
887
+ kind: "command",
888
+ command: gt,
889
+ icon: "code-block",
890
+ shortcut: "Mod-Alt-c"
891
+ },
892
+ "horizontal-rule": {
893
+ kind: "command",
894
+ command: _t,
895
+ icon: "horizontal-rule"
896
+ },
897
+ "clean-block": {
898
+ kind: "command",
899
+ command: vt,
900
+ icon: "clean-block",
901
+ shortcut: "Mod-e"
902
+ },
903
+ "unordered-list": {
904
+ kind: "command",
905
+ command: St,
906
+ query: ut,
907
+ icon: "unordered-list",
908
+ shortcut: "Mod-l"
909
+ },
910
+ "ordered-list": {
911
+ kind: "command",
912
+ command: Tt,
913
+ query: dt,
914
+ icon: "ordered-list",
915
+ shortcut: "Mod-Alt-l"
916
+ },
917
+ "check-list": {
918
+ kind: "command",
919
+ command: wt,
920
+ query: ft,
921
+ icon: "check-list",
922
+ shortcut: "Shift-Mod-l"
923
+ },
924
+ link: {
925
+ kind: "command",
926
+ command: Gt,
927
+ icon: "link",
928
+ shortcut: "Mod-k"
929
+ },
930
+ image: {
931
+ kind: "command",
932
+ command: Kt,
933
+ icon: "image",
934
+ shortcut: "Mod-Alt-i"
935
+ },
936
+ table: {
937
+ kind: "command",
938
+ command: qt,
939
+ icon: "table"
940
+ },
941
+ undo: {
942
+ kind: "command",
943
+ command: ue,
944
+ icon: "undo",
945
+ shortcut: "Mod-z"
946
+ },
947
+ redo: {
948
+ kind: "command",
949
+ command: le,
950
+ icon: "redo",
951
+ shortcut: {
952
+ default: "Mod-y",
953
+ mac: "Mod-Shift-z"
954
+ }
955
+ },
956
+ "side-by-side": {
957
+ kind: "view",
958
+ run: (e) => e.toggleSideBySide(),
959
+ active: (e) => e.isSideBySideActive(),
960
+ icon: "side-by-side",
961
+ shortcut: "F9"
962
+ },
963
+ fullscreen: {
964
+ kind: "view",
965
+ run: (e) => e.toggleFullScreen(),
966
+ active: (e) => e.isFullscreenActive(),
967
+ icon: "fullscreen",
968
+ shortcut: {
969
+ default: "F11",
970
+ mac: "Mod-Shift-F"
971
+ }
972
+ },
973
+ "preview-fullscreen": {
974
+ kind: "view",
975
+ run: (e) => e.togglePreviewFullScreen(),
976
+ active: (e) => e.isPreviewFullScreenActive(),
977
+ icon: "preview-fullscreen",
978
+ shortcut: "F8"
979
+ },
980
+ "editor-mode": {
981
+ kind: "view",
982
+ run: (e) => e.toggleEditorMode(),
983
+ active: (e) => e.getEditorMode() === "live",
984
+ icon: "editor-mode",
985
+ shortcut: "F10"
986
+ },
987
+ "upload-image": {
988
+ kind: "view",
989
+ run: (e) => e.openBrowseFileWindow(),
990
+ icon: "upload-image"
991
+ }
992
+ };
993
+ function Yt(e) {
994
+ return Jt[e];
995
+ }
996
+ //#endregion
997
+ //#region src/commands/keymap.ts
998
+ var Xt = /* @__PURE__ */ new Set(["undo", "redo"]);
999
+ function Zt(e) {
1000
+ return typeof e == "string" ? e : e.default;
1001
+ }
1002
+ var Qt = Object.entries(Jt).filter((e) => e[1].kind === "command" && !!e[1].shortcut && !Xt.has(e[0])).map(([, e]) => ({
1003
+ key: Zt(e.shortcut),
1004
+ run: e.command,
1005
+ preventDefault: !0
1006
+ })), $t = [
1007
+ {
1008
+ key: "Ctrl-Alt-q",
1009
+ run: ht,
1010
+ preventDefault: !0
1011
+ },
1012
+ {
1013
+ key: "Shift-Alt-Mod-l",
1014
+ run: Ct,
1015
+ preventDefault: !0
1016
+ },
1017
+ {
1018
+ key: "Enter",
1019
+ run: Dt
1020
+ },
1021
+ {
1022
+ key: "Backspace",
1023
+ run: de
1024
+ },
1025
+ {
1026
+ key: "Tab",
1027
+ run: Ot,
1028
+ preventDefault: !0
1029
+ },
1030
+ {
1031
+ key: "Shift-Tab",
1032
+ run: kt,
1033
+ preventDefault: !0
1034
+ },
1035
+ {
1036
+ key: "Shift-Mod-k",
1037
+ run: ie,
1038
+ preventDefault: !0
1039
+ },
1040
+ {
1041
+ key: "Shift-Alt-ArrowDown",
1042
+ run: te,
1043
+ preventDefault: !0
1044
+ },
1045
+ {
1046
+ key: "Shift-Alt-ArrowUp",
1047
+ run: ne,
1048
+ preventDefault: !0
1049
+ },
1050
+ {
1051
+ key: "Alt-ArrowDown",
1052
+ run: se,
1053
+ preventDefault: !0
1054
+ },
1055
+ {
1056
+ key: "Alt-ArrowUp",
1057
+ run: ce,
1058
+ preventDefault: !0
1059
+ }
1060
+ ], en = [...Qt, ...$t];
1061
+ //#endregion
1062
+ //#region src/ui/update-listener.ts
1063
+ function tn(e) {
1064
+ return t.updateListener.of((t) => {
1065
+ (t.docChanged || t.selectionSet) && e.onUpdate({
1066
+ state: t.state,
1067
+ docChanged: t.docChanged,
1068
+ selectionSet: t.selectionSet
1069
+ });
1070
+ });
1071
+ }
1072
+ //#endregion
1073
+ //#region src/editor/extensions.ts
1074
+ function nn(e, n, a) {
1075
+ let s = [
1076
+ fe({
1077
+ extensions: [pe, Le],
1078
+ addKeymap: !1
1079
+ }),
1080
+ Ne,
1081
+ Ee.of(De(e.editorMode)),
1082
+ qe,
1083
+ Ze,
1084
+ ae(),
1085
+ r.of([
1086
+ ...e.extraKeys,
1087
+ ...en,
1088
+ ...oe,
1089
+ ...re
1090
+ ]),
1091
+ Qe,
1092
+ o.tabSize.of(e.tabSize),
1093
+ p.of(" ".repeat(e.indentUnit))
1094
+ ];
1095
+ return e.lineWrapping && s.push(t.lineWrapping), e.placeholder !== null && s.push(i(e.placeholder)), n && s.push(tn(n)), a && s.push(...a), s;
1096
+ }
1097
+ //#endregion
1098
+ //#region src/editor/setup.ts
1099
+ function rn(e, n, r) {
1100
+ let i = e.element;
1101
+ if (!i) throw Error("SupaMDE: `element` is required (a <textarea>).");
1102
+ if (!(i instanceof HTMLTextAreaElement)) throw Error("SupaMDE: `element` must be a <textarea>.");
1103
+ let a = i, o = ke(e), s = e.initialValue ?? a.value, c = new t({
1104
+ doc: s,
1105
+ extensions: nn(o, n, r)
1106
+ });
1107
+ a.parentNode?.insertBefore(c.dom, a);
1108
+ let l = a.style.display;
1109
+ a.style.display = "none";
1110
+ let u = () => {
1111
+ a.value = c.state.doc.toString();
1112
+ }, d = () => u(), f = a.form;
1113
+ return f?.addEventListener("submit", d), o.autofocus && c.focus(), {
1114
+ view: c,
1115
+ toTextArea: () => (u(), f?.removeEventListener("submit", d), c.destroy(), c.dom.remove(), a.style.display = l, a),
1116
+ forceSync: u,
1117
+ resolved: o
1118
+ };
1119
+ }
1120
+ //#endregion
1121
+ //#region src/editor/value.ts
1122
+ function an(e) {
1123
+ return e.state.doc.toString();
1124
+ }
1125
+ function on(e, t) {
1126
+ e.dispatch({ changes: {
1127
+ from: 0,
1128
+ to: e.state.doc.length,
1129
+ insert: t
1130
+ } });
1131
+ }
1132
+ //#endregion
1133
+ //#region src/ui/toolbar-config.ts
1134
+ var sn = /* @__PURE__ */ "bold.italic.strikethrough.code.|.heading-smaller.heading-bigger.|.quote.unordered-list.ordered-list.check-list.|.code-block.horizontal-rule.|.link.image.table.|.clean-block.|.undo.redo.|.preview-fullscreen".split(".");
1135
+ function cn(e) {
1136
+ if (e === !1) return null;
1137
+ let t = e ?? sn, n = [];
1138
+ for (let e of t) if (typeof e == "string") {
1139
+ if (e === "|") {
1140
+ n.push({ kind: "separator" });
1141
+ continue;
1142
+ }
1143
+ let t = Yt(e);
1144
+ if (!t) {
1145
+ console.warn(`SupaMDE: unknown toolbar action "${e}" is skipped.`);
1146
+ continue;
1147
+ }
1148
+ n.push({
1149
+ kind: "builtin",
1150
+ name: e,
1151
+ action: t
1152
+ });
1153
+ } else n.push({
1154
+ kind: "custom",
1155
+ button: e
1156
+ });
1157
+ return n;
1158
+ }
1159
+ //#endregion
1160
+ //#region node_modules/lucide/dist/esm/defaultAttributes.mjs
1161
+ var ln = {
1162
+ xmlns: "http://www.w3.org/2000/svg",
1163
+ width: 24,
1164
+ height: 24,
1165
+ viewBox: "0 0 24 24",
1166
+ fill: "none",
1167
+ stroke: "currentColor",
1168
+ "stroke-width": 2,
1169
+ "stroke-linecap": "round",
1170
+ "stroke-linejoin": "round"
1171
+ }, un = ([e, t, n]) => {
1172
+ let r = document.createElementNS("http://www.w3.org/2000/svg", e);
1173
+ return Object.keys(t).forEach((e) => {
1174
+ r.setAttribute(e, String(t[e]));
1175
+ }), n?.length && n.forEach((e) => {
1176
+ let t = un(e);
1177
+ r.appendChild(t);
1178
+ }), r;
1179
+ }, dn = (e, t = {}) => un([
1180
+ "svg",
1181
+ {
1182
+ ...ln,
1183
+ ...t
1184
+ },
1185
+ e
1186
+ ]), fn = {
1187
+ bold: [["path", { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" }]],
1188
+ italic: [
1189
+ ["line", {
1190
+ x1: "19",
1191
+ x2: "10",
1192
+ y1: "4",
1193
+ y2: "4"
1194
+ }],
1195
+ ["line", {
1196
+ x1: "14",
1197
+ x2: "5",
1198
+ y1: "20",
1199
+ y2: "20"
1200
+ }],
1201
+ ["line", {
1202
+ x1: "15",
1203
+ x2: "9",
1204
+ y1: "4",
1205
+ y2: "20"
1206
+ }]
1207
+ ],
1208
+ strikethrough: [
1209
+ ["path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }],
1210
+ ["path", { d: "M14 12a4 4 0 0 1 0 8H6" }],
1211
+ ["line", {
1212
+ x1: "4",
1213
+ x2: "20",
1214
+ y1: "12",
1215
+ y2: "12"
1216
+ }]
1217
+ ],
1218
+ code: [["path", { d: "m16 18 6-6-6-6" }], ["path", { d: "m8 6-6 6 6 6" }]],
1219
+ heading: [
1220
+ ["path", { d: "M6 12h12" }],
1221
+ ["path", { d: "M6 20V4" }],
1222
+ ["path", { d: "M18 20V4" }]
1223
+ ],
1224
+ quote: [["path", { d: "M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" }], ["path", { d: "M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" }]],
1225
+ "code-block": [
1226
+ ["path", { d: "m10 9-3 3 3 3" }],
1227
+ ["path", { d: "m14 15 3-3-3-3" }],
1228
+ ["rect", {
1229
+ x: "3",
1230
+ y: "3",
1231
+ width: "18",
1232
+ height: "18",
1233
+ rx: "2"
1234
+ }]
1235
+ ],
1236
+ "horizontal-rule": [["path", { d: "M5 12h14" }]],
1237
+ "clean-block": [["path", { d: "M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21" }], ["path", { d: "m5.082 11.09 8.828 8.828" }]],
1238
+ "unordered-list": [
1239
+ ["path", { d: "M3 5h.01" }],
1240
+ ["path", { d: "M3 12h.01" }],
1241
+ ["path", { d: "M3 19h.01" }],
1242
+ ["path", { d: "M8 5h13" }],
1243
+ ["path", { d: "M8 12h13" }],
1244
+ ["path", { d: "M8 19h13" }]
1245
+ ],
1246
+ "ordered-list": [
1247
+ ["path", { d: "M11 5h10" }],
1248
+ ["path", { d: "M11 12h10" }],
1249
+ ["path", { d: "M11 19h10" }],
1250
+ ["path", { d: "M4 4h1v5" }],
1251
+ ["path", { d: "M4 9h2" }],
1252
+ ["path", { d: "M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02" }]
1253
+ ],
1254
+ "check-list": [
1255
+ ["path", { d: "M13 5h8" }],
1256
+ ["path", { d: "M13 12h8" }],
1257
+ ["path", { d: "M13 19h8" }],
1258
+ ["path", { d: "m3 17 2 2 4-4" }],
1259
+ ["path", { d: "m3 7 2 2 4-4" }]
1260
+ ],
1261
+ link: [["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }], ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" }]],
1262
+ image: [
1263
+ ["rect", {
1264
+ width: "18",
1265
+ height: "18",
1266
+ x: "3",
1267
+ y: "3",
1268
+ rx: "2",
1269
+ ry: "2"
1270
+ }],
1271
+ ["circle", {
1272
+ cx: "9",
1273
+ cy: "9",
1274
+ r: "2"
1275
+ }],
1276
+ ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" }]
1277
+ ],
1278
+ table: [
1279
+ ["path", { d: "M12 3v18" }],
1280
+ ["rect", {
1281
+ width: "18",
1282
+ height: "18",
1283
+ x: "3",
1284
+ y: "3",
1285
+ rx: "2"
1286
+ }],
1287
+ ["path", { d: "M3 9h18" }],
1288
+ ["path", { d: "M3 15h18" }]
1289
+ ],
1290
+ undo: [["path", { d: "M3 7v6h6" }], ["path", { d: "M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13" }]],
1291
+ redo: [["path", { d: "M21 7v6h-6" }], ["path", { d: "M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7" }]],
1292
+ "side-by-side": [["rect", {
1293
+ width: "18",
1294
+ height: "18",
1295
+ x: "3",
1296
+ y: "3",
1297
+ rx: "2"
1298
+ }], ["path", { d: "M12 3v18" }]],
1299
+ fullscreen: [
1300
+ ["path", { d: "M3 7V5a2 2 0 0 1 2-2h2" }],
1301
+ ["path", { d: "M17 3h2a2 2 0 0 1 2 2v2" }],
1302
+ ["path", { d: "M21 17v2a2 2 0 0 1-2 2h-2" }],
1303
+ ["path", { d: "M7 21H5a2 2 0 0 1-2-2v-2" }],
1304
+ ["rect", {
1305
+ width: "10",
1306
+ height: "8",
1307
+ x: "7",
1308
+ y: "8",
1309
+ rx: "1"
1310
+ }]
1311
+ ],
1312
+ "preview-fullscreen": [
1313
+ ["path", { d: "M15 3h6v6" }],
1314
+ ["path", { d: "m21 3-7 7" }],
1315
+ ["path", { d: "m3 21 7-7" }],
1316
+ ["path", { d: "M9 21H3v-6" }]
1317
+ ],
1318
+ "editor-mode": [["path", { d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" }], ["circle", {
1319
+ cx: "12",
1320
+ cy: "12",
1321
+ r: "3"
1322
+ }]],
1323
+ "upload-image": [
1324
+ ["path", { d: "M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21" }],
1325
+ ["path", { d: "m14 19.5 3-3 3 3" }],
1326
+ ["path", { d: "M17 22v-5.5" }],
1327
+ ["circle", {
1328
+ cx: "9",
1329
+ cy: "9",
1330
+ r: "2"
1331
+ }]
1332
+ ]
1333
+ };
1334
+ function pn(e) {
1335
+ let t = fn[e];
1336
+ if (!t) throw Error(`SupaMDE: unknown icon "${e}".`);
1337
+ return dn(t);
1338
+ }
1339
+ //#endregion
1340
+ //#region src/ui/shortcut-label.ts
1341
+ function mn() {
1342
+ try {
1343
+ let e = navigator;
1344
+ if (typeof navigator < "u" && e.userAgentData?.platform) return e.userAgentData.platform.toLowerCase().includes("mac");
1345
+ if (typeof navigator < "u" && navigator.userAgent) return /mac/i.test(navigator.userAgent);
1346
+ } catch {}
1347
+ return !1;
1348
+ }
1349
+ function hn(e, t) {
1350
+ let n = t ?? mn(), r = typeof e == "string" ? e : n ? e.mac : e.default, i = r.split("-");
1351
+ if (i.length === 0) return r;
1352
+ let a = i[i.length - 1];
1353
+ if (!a) return r;
1354
+ let o = a, s = i.slice(0, -1);
1355
+ return n ? gn(s, o) : _n(s, o);
1356
+ }
1357
+ function gn(e, t) {
1358
+ let n = [], r = !1, i = !1, a = !1, o = !1, s = !1;
1359
+ for (let t of e) t === "Mod" ? r = !0 : t === "Cmd" ? i = !0 : t === "Ctrl" ? a = !0 : t === "Alt" ? o = !0 : t === "Shift" && (s = !0);
1360
+ r && n.push("⌘"), i && n.push("⌘"), a && n.push("⌃"), o && n.push("⌥"), s && n.push("⇧");
1361
+ let c = t.length === 1 ? t.toUpperCase() : t;
1362
+ return n.join("") + c;
1363
+ }
1364
+ function _n(e, t) {
1365
+ let n = [], r = !1, i = !1, a = !1;
1366
+ for (let t of e) t === "Mod" || t === "Ctrl" ? r = !0 : t === "Alt" ? i = !0 : t === "Shift" && (a = !0);
1367
+ r && n.push("Ctrl"), i && n.push("Alt"), a && n.push("Shift");
1368
+ let o = t.length === 1 ? t.toUpperCase() : t;
1369
+ return n.push(o), n.join("+");
1370
+ }
1371
+ //#endregion
1372
+ //#region src/ui/toolbar.ts
1373
+ function vn(e) {
1374
+ return typeof e == "object" && !!e && typeof e.toggleSideBySide == "function" && typeof e.toggleFullScreen == "function" && typeof e.isSideBySideActive == "function" && typeof e.isFullscreenActive == "function";
1375
+ }
1376
+ function yn(e, t, n, r, i, a) {
1377
+ if (t.kind === "separator") {
1378
+ let e = document.createElement("i");
1379
+ return e.className = "supamde-separator", e;
1380
+ }
1381
+ let o = document.createElement("button");
1382
+ if (o.type = "button", t.kind === "builtin") {
1383
+ let { action: s, name: c } = t, l = r.t(`toolbar.${c}`), u = s.shortcut ? `${l} (${hn(s.shortcut)})` : l;
1384
+ if (o.title = u, o.setAttribute("aria-label", u), o.dataset.action = c, o.appendChild(pn(s.icon)), s.kind === "command") {
1385
+ let t = s.command;
1386
+ o.addEventListener("click", () => {
1387
+ e.focus(), t(e);
1388
+ }), s.query && i.push({
1389
+ el: o,
1390
+ query: (e) => s.query(e)
1391
+ });
1392
+ } else {
1393
+ let e = s.run;
1394
+ o.addEventListener("click", () => e(n)), s.active && a.push({
1395
+ el: o,
1396
+ active: s.active
1397
+ });
1398
+ }
1399
+ } else {
1400
+ let { button: e } = t;
1401
+ if (o.title = e.title ?? e.name, o.dataset.action = e.name, e.className) {
1402
+ let t = document.createElement("i");
1403
+ t.className = e.className, o.appendChild(t);
1404
+ } else o.textContent = e.name;
1405
+ o.addEventListener("click", () => e.action(n));
1406
+ }
1407
+ return o;
1408
+ }
1409
+ function bn(e, t, n, r = E()) {
1410
+ let i = cn(t);
1411
+ if (i === null) return null;
1412
+ let a = document.createElement("div");
1413
+ a.className = "supamde-toolbar";
1414
+ let o = [], s = [];
1415
+ for (let t of i) a.appendChild(yn(e, t, n, r, o, s));
1416
+ let c = !1;
1417
+ return {
1418
+ dom: a,
1419
+ update: (e) => {
1420
+ for (let { el: t, query: n } of o) t.classList.toggle("active", n(e));
1421
+ if (s.length > 0) {
1422
+ if (vn(n)) for (let { el: e, active: t } of s) e.classList.toggle("active", t(n));
1423
+ else c || (c = !0, console.warn("SupaMDE: toolbar contains view buttons (preview-fullscreen/side-by-side/fullscreen/editor-mode), but the given editor instance does not satisfy SupaLike (toggleSideBySide/toggleFullScreen/isSideBySideActive/isFullscreenActive) — the active state of these buttons is not updated."));
1424
+ }
1425
+ },
1426
+ destroy: () => {
1427
+ a.remove();
1428
+ }
1429
+ };
1430
+ }
1431
+ //#endregion
1432
+ //#region src/features/word-count.ts
1433
+ function xn(e) {
1434
+ let t = e.trim();
1435
+ return t.length === 0 ? 0 : t.split(/\s+/).length;
1436
+ }
1437
+ //#endregion
1438
+ //#region src/ui/statusbar.ts
1439
+ var Sn = [
1440
+ "lines",
1441
+ "words",
1442
+ "cursor"
1443
+ ], Cn = /* @__PURE__ */ new Set([
1444
+ "lines",
1445
+ "words",
1446
+ "cursor",
1447
+ "autosave",
1448
+ "upload-image"
1449
+ ]), wn = /* @__PURE__ */ new Set(["autosave", "upload-image"]);
1450
+ function Tn(e, t, n) {
1451
+ switch (e) {
1452
+ case "lines": return n.plural("status.lines", t.doc.lines);
1453
+ case "words": return n.plural("status.words", xn(t.doc.toString()));
1454
+ case "cursor": {
1455
+ let e = t.selection.main.head, n = t.doc.lineAt(e);
1456
+ return `${n.number}:${e - n.from + 1}`;
1457
+ }
1458
+ case "autosave":
1459
+ case "upload-image": return "";
1460
+ default: return "";
1461
+ }
1462
+ }
1463
+ function En(e, t = E()) {
1464
+ if (e === !1) return null;
1465
+ let n = e ?? Sn, r = document.createElement("div");
1466
+ r.className = "supamde-statusbar";
1467
+ let i = [], a = [];
1468
+ for (let e of n) {
1469
+ let t = document.createElement("span");
1470
+ typeof e == "string" ? (t.className = `supamde-status-${e}`, r.appendChild(t), Cn.has(e) && i.push({
1471
+ name: e,
1472
+ el: t
1473
+ })) : (t.className = `supamde-status-custom ${e.className}`, t.textContent = e.defaultValue ?? "", r.appendChild(t), a.push({
1474
+ item: e,
1475
+ el: t
1476
+ }));
1477
+ }
1478
+ return {
1479
+ dom: r,
1480
+ update: (e, n) => {
1481
+ for (let { name: n, el: r } of i) wn.has(n) || (r.textContent = Tn(n, e, t));
1482
+ for (let { item: e, el: t } of a) n.docChanged && e.onUpdate?.(t), n.selectionSet && e.onActivity?.(t);
1483
+ },
1484
+ setItem: (e, t) => {
1485
+ let n = i.find((t) => t.name === e);
1486
+ n && (n.el.textContent = t);
1487
+ },
1488
+ destroy: () => {
1489
+ r.remove();
1490
+ }
1491
+ };
1492
+ }
1493
+ //#endregion
1494
+ //#region src/ui/preview.ts
1495
+ function Dn(e, t) {
1496
+ let n = document.createElement("div");
1497
+ if (n.className = "supamde-preview-side", t.previewClass) {
1498
+ let e = Array.isArray(t.previewClass) ? t.previewClass : [t.previewClass];
1499
+ n.classList.add(...e);
1500
+ }
1501
+ n.style.display = "none";
1502
+ let r = !1, i = t.syncScroll ?? !0, a = (e) => {
1503
+ n.innerHTML = t.render(e.doc.toString());
1504
+ }, o = null, s = e.scrollDOM, c = (e) => {
1505
+ let t = () => {
1506
+ o === e && (o = null);
1507
+ };
1508
+ typeof requestAnimationFrame == "function" ? requestAnimationFrame(t) : t();
1509
+ }, l = () => {
1510
+ if (!r || !i) return;
1511
+ if (o === "preview") {
1512
+ o = null;
1513
+ return;
1514
+ }
1515
+ o = "editor";
1516
+ let e = s.scrollHeight - s.clientHeight, t = e > 0 ? s.scrollTop / e : 0;
1517
+ n.scrollTop = (n.scrollHeight - n.clientHeight) * t, c("editor");
1518
+ }, u = () => {
1519
+ if (!r || !i) return;
1520
+ if (o === "editor") {
1521
+ o = null;
1522
+ return;
1523
+ }
1524
+ o = "preview";
1525
+ let e = n.scrollHeight - n.clientHeight, t = e > 0 ? n.scrollTop / e : 0;
1526
+ s.scrollTop = (s.scrollHeight - s.clientHeight) * t, c("preview");
1527
+ };
1528
+ i && (s.addEventListener("scroll", l), n.addEventListener("scroll", u));
1529
+ let d = (t) => {
1530
+ t !== r && (r = t, n.style.display = r ? "" : "none", r && a(e.state));
1531
+ };
1532
+ return {
1533
+ dom: n,
1534
+ toggle: () => d(!r),
1535
+ set: d,
1536
+ isActive: () => r,
1537
+ update: (e) => {
1538
+ r && a(e);
1539
+ },
1540
+ destroy: () => {
1541
+ i && (s.removeEventListener("scroll", l), n.removeEventListener("scroll", u)), n.remove();
1542
+ }
1543
+ };
1544
+ }
1545
+ //#endregion
1546
+ //#region src/ui/fullscreen.ts
1547
+ var k = 0, On = "";
1548
+ function kn(e, t = {}) {
1549
+ let n = !1, r = (r) => {
1550
+ r !== n && (n = r, e.classList.toggle("supamde-fullscreen", n), n ? (k === 0 && (On = document.body.style.overflow), k += 1, document.body.style.overflow = "hidden") : (k = Math.max(0, k - 1), k === 0 && (document.body.style.overflow = On)), t.onToggleFullScreen?.(n));
1551
+ }, i = (e) => {
1552
+ e.key === "Escape" && n && r(!1);
1553
+ };
1554
+ return e.addEventListener("keydown", i), {
1555
+ toggle: () => r(!n),
1556
+ set: r,
1557
+ isActive: () => n,
1558
+ destroy: () => {
1559
+ e.removeEventListener("keydown", i), n && r(!1);
1560
+ }
1561
+ };
1562
+ }
1563
+ //#endregion
1564
+ //#region src/ui/toolbar.css?inline
1565
+ var An = ".supamde-container{--supamde-border-color:#d0d0d0;--supamde-border-width:1px;--supamde-border-top-width:var(--supamde-border-width);--supamde-border-right-width:var(--supamde-border-width);--supamde-border-bottom-width:var(--supamde-border-width);--supamde-border-left-width:var(--supamde-border-width);--supamde-radius:4px;--supamde-divider-toolbar-width:1px;--supamde-divider-statusbar-width:1px;--supamde-divider-preview-width:1px;--supamde-toolbar-bg:#f7f7f7;--supamde-btn-hover:#e6e6e6;--supamde-btn-active:#d8e6ff;--supamde-btn-text:#333;border-style:solid;border-color:var(--supamde-border-color);border-top-width:var(--supamde-border-top-width);border-right-width:var(--supamde-border-right-width);border-bottom-width:var(--supamde-border-bottom-width);border-left-width:var(--supamde-border-left-width);border-radius:var(--supamde-radius);overflow:hidden}.supamde-toolbar{border-bottom:var(--supamde-divider-toolbar-width) solid var(--supamde-border-color);background:var(--supamde-toolbar-bg);flex-wrap:wrap;align-items:center;gap:2px;padding:4px;display:flex}.supamde-toolbar button{width:28px;height:28px;color:var(--supamde-btn-text);cursor:pointer;background:0 0;border:1px solid #0000;border-radius:3px;justify-content:center;align-items:center;padding:0;display:inline-flex}.supamde-toolbar button:hover{background:var(--supamde-btn-hover)}.supamde-toolbar button.active{background:var(--supamde-btn-active)}.supamde-toolbar button svg{width:16px;height:16px}.supamde-separator{background:var(--supamde-border-color);width:1px;height:20px;margin:0 4px;display:inline-block}", jn = ".supamde-statusbar{border-top:var(--supamde-divider-statusbar-width,1px) solid var(--supamde-border-color,#d0d0d0);background:var(--supamde-statusbar-bg,#f7f7f7);color:#666;gap:12px;padding:4px 8px;font-size:12px;display:flex}.supamde-statusbar span{white-space:nowrap}", Mn = ".supamde-editor-row{flex-direction:row;align-items:stretch;display:flex}.supamde-editor-row .cm-editor{flex:1;min-width:0}.supamde-container.supamde-sided .supamde-editor-row .cm-editor{flex:0 0 50%;width:50%}.supamde-preview-side{border-left:var(--supamde-divider-preview-width,1px) solid var(--supamde-border-color,#ddd);box-sizing:border-box;width:50%;padding:.5rem 1rem;overflow-y:auto}", Nn = ".supamde-container.supamde-fullscreen{z-index:1000;background:var(--supamde-bg,#fff);flex-direction:column;max-width:none;display:flex;position:fixed;inset:0}.supamde-container.supamde-fullscreen .supamde-editor-row{flex:1;min-height:0}.supamde-container.supamde-fullscreen .supamde-editor-row .cm-editor{height:100%}", Pn = "data-supamde-styles", Fn = [
1566
+ An,
1567
+ jn,
1568
+ Mn,
1569
+ Nn
1570
+ ].join("\n");
1571
+ function In(e = document) {
1572
+ let t = e.head;
1573
+ if (!t || t.querySelector(`style[${Pn}]`)) return;
1574
+ let n = e.createElement("style");
1575
+ n.setAttribute(Pn, ""), n.textContent = Fn, t.insertBefore(n, t.firstChild);
1576
+ }
1577
+ //#endregion
1578
+ //#region node_modules/marked/lib/marked.esm.js
1579
+ function Ln() {
1580
+ return {
1581
+ async: !1,
1582
+ breaks: !1,
1583
+ extensions: null,
1584
+ gfm: !0,
1585
+ hooks: null,
1586
+ pedantic: !1,
1587
+ renderer: null,
1588
+ silent: !1,
1589
+ tokenizer: null,
1590
+ walkTokens: null
1591
+ };
1592
+ }
1593
+ var A = Ln();
1594
+ function Rn(e) {
1595
+ A = e;
1596
+ }
1597
+ var j = { exec: () => null };
1598
+ function M(e) {
1599
+ let t = [];
1600
+ return (n) => {
1601
+ let r = Math.max(0, Math.min(3, n - 1)), i = t[r];
1602
+ return i || (i = e(r), t[r] = i), i;
1603
+ };
1604
+ }
1605
+ function N(e, t = "") {
1606
+ let n = typeof e == "string" ? e : e.source, r = {
1607
+ replace: (e, t) => {
1608
+ let i = typeof t == "string" ? t : t.source;
1609
+ return i = i.replace(P.caret, "$1"), n = n.replace(e, i), r;
1610
+ },
1611
+ getRegex: () => new RegExp(n, t)
1612
+ };
1613
+ return r;
1614
+ }
1615
+ var zn = ((e = "") => {
1616
+ try {
1617
+ return !!RegExp("(?<=1)(?<!1)" + e);
1618
+ } catch {
1619
+ return !1;
1620
+ }
1621
+ })(), P = {
1622
+ codeRemoveIndent: /^(?: {0,3}\t| {1,4})/gm,
1623
+ outputLinkReplace: /\\([\[\]])/g,
1624
+ indentCodeCompensation: /^(\s+)(?:```)/,
1625
+ beginningSpace: /^\s+/,
1626
+ endingHash: /#$/,
1627
+ startingSpaceChar: /^ /,
1628
+ endingSpaceChar: / $/,
1629
+ endingSpaceTabChar: /[ \t]$/,
1630
+ nonSpaceChar: /[^ ]/,
1631
+ newLineCharGlobal: /\n/g,
1632
+ tabCharGlobal: /\t/g,
1633
+ leadingSpaceTab: /^[ \t]+/,
1634
+ multipleSpaceGlobal: /\s+/g,
1635
+ blankLine: /^[ \t]*$/,
1636
+ doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
1637
+ blockquoteStart: /^ {0,3}>/,
1638
+ blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
1639
+ blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
1640
+ listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
1641
+ listIsTask: /^\[[ xX]\] +\S/,
1642
+ listReplaceTask: /^\[[ xX]\] +/,
1643
+ listTaskCheckbox: /\[[ xX]\]/,
1644
+ anyLine: /\n.*\n/,
1645
+ hrefBrackets: /^<(.*)>$/,
1646
+ tableDelimiter: /[:|]/,
1647
+ tableAlignChars: /^\||\| *$/g,
1648
+ tableRowBlankLine: /\n[ \t]*$/,
1649
+ tableAlignRight: /^ *-+: *$/,
1650
+ tableAlignCenter: /^ *:-+: *$/,
1651
+ tableAlignLeft: /^ *:-+ *$/,
1652
+ startATag: /^<a /i,
1653
+ endATag: /^<\/a>/i,
1654
+ startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
1655
+ endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
1656
+ startAngleBracket: /^</,
1657
+ endAngleBracket: />$/,
1658
+ pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
1659
+ unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
1660
+ numericCharacterReference: /&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/g,
1661
+ escapeTest: /[&<>"']/,
1662
+ escapeReplace: /[&<>"']/g,
1663
+ escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
1664
+ escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
1665
+ caret: /(^|[^\[])\^/g,
1666
+ percentDecode: /%25/g,
1667
+ findPipe: /\|/g,
1668
+ splitPipe: / \|/,
1669
+ slashPipe: /\\\|/g,
1670
+ carriageReturn: /\r\n|\r/g,
1671
+ spaceLine: /^ +$/gm,
1672
+ notSpaceStart: /^\S*/,
1673
+ endingNewline: /\n$/,
1674
+ listItemRegex: (e) => RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),
1675
+ nextBulletRegex: M((e) => RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),
1676
+ hrRegex: M((e) => RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),
1677
+ fencesBeginRegex: M((e) => RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),
1678
+ headingBeginRegex: M((e) => RegExp(`^ {0,${e}}#`)),
1679
+ htmlBeginRegex: M((e) => RegExp(`^ {0,${e}}(?:</?(?:${I})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`, "i")),
1680
+ blockquoteBeginRegex: M((e) => RegExp(`^ {0,${e}}>`))
1681
+ }, Bn = /^(?:[ \t]*(?:\n|$))+/, Vn = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, Hn = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, F = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Un = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, Wn = / {0,3}(?:[*+-]|\d{1,9}[.)])/, Gn = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, Kn = N(Gn).replace(/bull/g, Wn).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}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(), qn = N(Gn).replace(/bull/g, Wn).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}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), Jn = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/, Yn = /^[^\n]+/, Xn = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, Zn = N(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Xn).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Qn = N(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, Wn).getRegex(), I = "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", $n = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, er = N("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", $n).replace("tag", I).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), tr = (e) => N(Jn).replace("hr", F).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", e).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", I).getRegex(), nr = tr(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/), rr = tr(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/), ir = {
1682
+ blockquote: N(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", rr).getRegex(),
1683
+ code: Vn,
1684
+ def: Zn,
1685
+ fences: Hn,
1686
+ heading: Un,
1687
+ hr: F,
1688
+ html: er,
1689
+ lheading: Kn,
1690
+ list: Qn,
1691
+ newline: Bn,
1692
+ paragraph: nr,
1693
+ table: j,
1694
+ text: Yn
1695
+ }, ar = N("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", F).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", I).getRegex(), or = {
1696
+ ...ir,
1697
+ lheading: qn,
1698
+ table: ar,
1699
+ paragraph: N(Jn).replace("hr", F).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", ar).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", I).getRegex()
1700
+ }, sr = {
1701
+ ...ir,
1702
+ html: N("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment", $n).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(),
1703
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
1704
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
1705
+ fences: j,
1706
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
1707
+ paragraph: N(Jn).replace("hr", F).replace("heading", " *#{1,6} *[^\n]").replace("lheading", Kn).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
1708
+ }, cr = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, lr = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, ur = /^( {2,}|\\)\n(?!\s*$)[ \t]*/, dr = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, L = /[\p{P}\p{S}]/u, R = /[\s\p{P}\p{S}]/u, z = /[^\s\p{P}\p{S}]/u, fr = N(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, R).getRegex(), pr = /[\p{Pi}\p{Ps}"']/u, mr = /(?!~)[\p{P}\p{S}]/u, hr = /(?!~)[\s\p{P}\p{S}]/u, gr = /(?:[^\s\p{P}\p{S}]|~)/u, _r = N(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", zn ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), vr = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/, yr = N(vr, "u").replace(/punct/g, L).getRegex(), br = N(vr, "u").replace(/punct/g, mr).getRegex(), xr = N(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/, "u").replace(/openQuote/g, pr).replace(/punct/g, L).getRegex(), Sr = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", Cr = N(Sr, "gu").replace(/notPunctSpace/g, z).replace(/punctSpace/g, R).replace(/punct/g, L).getRegex(), wr = N(Sr, "gu").replace(/notPunctSpace/g, gr).replace(/punctSpace/g, hr).replace(/punct/g, mr).getRegex(), Tr = N("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, z).replace(/punctSpace/g, R).replace(/punct/g, L).getRegex(), Er = N("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, z).replace(/punctSpace/g, R).replace(/punct/g, L).getRegex(), Dr = N("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, z).replace(/punctSpace/g, R).replace(/punct/g, L).getRegex(), Or = N(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, L).getRegex(), kr = N("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, z).replace(/punctSpace/g, R).replace(/punct/g, L).getRegex(), Ar = N(/\\(punct)/, "gu").replace(/punct/g, L).getRegex(), jr = N(/^<(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(), Mr = N($n).replace("(?:-->|$)", "-->").getRegex(), Nr = N("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Mr).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Pr = /\[(?:\\[\s\S]|[^\[\]\\])*\]/, B = N(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets", Pr).getRegex(), Fr = N(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label", B).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), Ir = N(/^!?\[(label)\]\[(ref)\]/).replace("label", B).replace("ref", Xn).getRegex(), Lr = N(/^!?\[(ref)\](?:\[\])?/).replace("ref", Xn).getRegex(), Rr = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/, zr = N(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets", Pr).getRegex(), Br = N("reflink|nolink(?!\\()", "g").replace("reflink", N(/^!?\[(label)\]\[(ref)\]/).replace("label", zr).replace("ref", Rr).getRegex()).replace("nolink", N(/^!?\[(ref)\](?:\[\])?/).replace("ref", Rr).getRegex()).getRegex(), Vr = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, Hr = N(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g, /[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(), Ur = {
1709
+ _backpedal: j,
1710
+ anyPunctuation: Ar,
1711
+ autolink: jr,
1712
+ blockSkip: _r,
1713
+ br: ur,
1714
+ code: lr,
1715
+ del: j,
1716
+ delLDelim: j,
1717
+ delRDelim: j,
1718
+ emStrongLDelim: yr,
1719
+ emStrongRDelimAst: Cr,
1720
+ emStrongRDelimUnd: Er,
1721
+ escape: cr,
1722
+ link: Fr,
1723
+ nolink: Lr,
1724
+ punctuation: fr,
1725
+ reflink: Ir,
1726
+ reflinkSearch: Br,
1727
+ tag: Nr,
1728
+ text: dr,
1729
+ url: j
1730
+ }, Wr = {
1731
+ ...Ur,
1732
+ emStrongLDelim: xr,
1733
+ emStrongRDelimAst: Tr,
1734
+ emStrongRDelimUnd: Dr,
1735
+ link: N(/^!?\[(label)\]\((.*?)\)/).replace("label", B).getRegex(),
1736
+ reflink: N(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", B).getRegex()
1737
+ }, V = {
1738
+ ...Ur,
1739
+ emStrongRDelimAst: wr,
1740
+ emStrongLDelim: br,
1741
+ delLDelim: Or,
1742
+ delRDelim: kr,
1743
+ url: N(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol", Hr).replace("protocol", Vr).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),
1744
+ _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
1745
+ del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,
1746
+ text: N(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol", Vr).replace(/emailProtocol/g, /(?:mailto|xmpp):/).getRegex()
1747
+ }, Gr = {
1748
+ ...V,
1749
+ br: N(ur).replace("{2,}", "*").getRegex(),
1750
+ text: N(V.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
1751
+ }, H = {
1752
+ normal: ir,
1753
+ gfm: or,
1754
+ pedantic: sr
1755
+ }, U = {
1756
+ normal: Ur,
1757
+ gfm: V,
1758
+ breaks: Gr,
1759
+ pedantic: Wr
1760
+ }, Kr = {
1761
+ "&": "&amp;",
1762
+ "<": "&lt;",
1763
+ ">": "&gt;",
1764
+ "\"": "&quot;",
1765
+ "'": "&#39;"
1766
+ }, qr = (e) => Kr[e];
1767
+ function W(e, t) {
1768
+ if (t) {
1769
+ if (P.escapeTest.test(e)) return e.replace(P.escapeReplace, qr);
1770
+ } else if (P.escapeTestNoEncode.test(e)) return e.replace(P.escapeReplaceNoEncode, qr);
1771
+ return e;
1772
+ }
1773
+ function Jr(e) {
1774
+ return e.replace(P.numericCharacterReference, (e, t, n) => {
1775
+ let r = t === void 0 ? Number.parseInt(n, 16) : Number.parseInt(t, 10);
1776
+ return r === 0 || r > 1114111 || r >= 55296 && r <= 57343 ? "�" : String.fromCodePoint(r);
1777
+ });
1778
+ }
1779
+ function Yr(e) {
1780
+ try {
1781
+ e = encodeURI(e).replace(P.percentDecode, "%");
1782
+ } catch {
1783
+ return null;
1784
+ }
1785
+ return e;
1786
+ }
1787
+ function Xr(e, t) {
1788
+ let n = e.replace(P.findPipe, (e, t, n) => {
1789
+ let r = !1, i = t;
1790
+ for (; --i >= 0 && n[i] === "\\";) r = !r;
1791
+ return r ? "|" : " |";
1792
+ }).split(P.splitPipe), r = 0;
1793
+ if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), t) {
1794
+ if (n.length > t) n.splice(t);
1795
+ else for (; n.length < t;) n.push("");
1796
+ }
1797
+ for (; r < n.length; r++) n[r] = n[r].trim().replace(P.slashPipe, "|");
1798
+ return n;
1799
+ }
1800
+ function G(e, t, n) {
1801
+ let r = e.length;
1802
+ if (r === 0) return "";
1803
+ let i = 0;
1804
+ for (; i < r;) {
1805
+ let a = e.charAt(r - i - 1);
1806
+ if (a === t && !n) i++;
1807
+ else if (a !== t && n) i++;
1808
+ else break;
1809
+ }
1810
+ return e.slice(0, r - i);
1811
+ }
1812
+ function Zr(e) {
1813
+ let t = e.split("\n"), n = t.length - 1;
1814
+ for (; n >= 0 && P.blankLine.test(t[n]);) n--;
1815
+ return t.length - n <= 2 ? e : t.slice(0, n + 1).join("\n");
1816
+ }
1817
+ function K(e) {
1818
+ return e.trim().toLowerCase().toUpperCase().toLowerCase();
1819
+ }
1820
+ function Qr(e, t) {
1821
+ if (e.indexOf(t[0]) === -1 && e.indexOf(t[1]) === -1) return -1;
1822
+ let n = 0;
1823
+ for (let r = 0; r < e.length; r++) if (e[r] === "\\") r++;
1824
+ else if (e[r] === t[0]) n++;
1825
+ else if (e[r] === t[1] && (n--, n < 0)) return r;
1826
+ return n > 0 ? -2 : -1;
1827
+ }
1828
+ function $r(e, t = 0) {
1829
+ let n = t, r = "";
1830
+ for (let t of e) if (t === " ") {
1831
+ let e = 4 - n % 4;
1832
+ r += " ".repeat(e), n += e;
1833
+ } else r += t, n++;
1834
+ return r;
1835
+ }
1836
+ function ei(e, t, n, r, i) {
1837
+ let a = t.href, o = t.title || null, s = e[1].replace(i.other.outputLinkReplace, "$1"), c = e[0].charAt(0) === "!";
1838
+ r.state.inLink = !0;
1839
+ let l = r.state.linkEmitted, u = r.state.inRawBlock;
1840
+ r.state.linkEmitted = !1;
1841
+ let d = r.inlineTokens(s), f = r.state.linkEmitted;
1842
+ if (r.state.linkEmitted = l, r.state.inLink = !1, !c) {
1843
+ if (f) {
1844
+ r.state.inRawBlock = u;
1845
+ return;
1846
+ }
1847
+ r.state.linkEmitted = !0;
1848
+ }
1849
+ return {
1850
+ type: c ? "image" : "link",
1851
+ raw: n,
1852
+ href: a,
1853
+ title: o,
1854
+ text: s,
1855
+ tokens: d
1856
+ };
1857
+ }
1858
+ function ti(e, t, n) {
1859
+ let r = e.match(n.other.indentCodeCompensation);
1860
+ if (r === null) return t;
1861
+ let i = r[1];
1862
+ return t.split("\n").map((e) => {
1863
+ let t = e.match(n.other.beginningSpace);
1864
+ if (t === null) return e;
1865
+ let [r] = t;
1866
+ return e.slice(Math.min(r.length, i.length));
1867
+ }).join("\n");
1868
+ }
1869
+ function ni(e, t, n, r) {
1870
+ if (!t.includes("<")) return !1;
1871
+ for (let i = 0; i < t.length; i++) {
1872
+ if (t[i] === "\\") {
1873
+ i++;
1874
+ continue;
1875
+ }
1876
+ if (t[i] === "`") {
1877
+ let e = r.inline.code.exec(t.slice(i));
1878
+ if (e) {
1879
+ i += e[0].length - 1;
1880
+ continue;
1881
+ }
1882
+ }
1883
+ if (t[i] !== "<") continue;
1884
+ let a = e.slice(n + i), o = r.inline.tag.exec(a) || r.inline.autolink.exec(a);
1885
+ if (o) {
1886
+ if (o[0].length > t.length - i) return !0;
1887
+ i += o[0].length - 1;
1888
+ }
1889
+ }
1890
+ return !1;
1891
+ }
1892
+ var q = class {
1893
+ options;
1894
+ rules;
1895
+ lexer;
1896
+ constructor(e) {
1897
+ this.options = e || A;
1898
+ }
1899
+ space(e) {
1900
+ let t = this.rules.block.newline.exec(e);
1901
+ if (t && t[0].length > 0) return {
1902
+ type: "space",
1903
+ raw: t[0]
1904
+ };
1905
+ }
1906
+ code(e) {
1907
+ let t = this.rules.block.code.exec(e);
1908
+ if (t) {
1909
+ let e = this.options.pedantic ? t[0] : Zr(t[0]);
1910
+ return {
1911
+ type: "code",
1912
+ raw: e,
1913
+ codeBlockStyle: "indented",
1914
+ text: e.replace(this.rules.other.codeRemoveIndent, "")
1915
+ };
1916
+ }
1917
+ }
1918
+ fences(e) {
1919
+ let t = this.rules.block.fences.exec(e);
1920
+ if (t) {
1921
+ let e = t[0], n = ti(e, t[3] || "", this.rules);
1922
+ return {
1923
+ type: "code",
1924
+ raw: e,
1925
+ lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
1926
+ text: n
1927
+ };
1928
+ }
1929
+ }
1930
+ heading(e) {
1931
+ let t = this.rules.block.heading.exec(e);
1932
+ if (t) {
1933
+ let e = t[2].trim();
1934
+ if (this.rules.other.endingHash.test(e)) {
1935
+ let t = G(e, "#");
1936
+ (this.options.pedantic || !t || this.rules.other.endingSpaceTabChar.test(t)) && (e = t.trim());
1937
+ }
1938
+ return {
1939
+ type: "heading",
1940
+ raw: G(t[0], "\n"),
1941
+ depth: t[1].length,
1942
+ text: e,
1943
+ tokens: this.lexer.inline(e)
1944
+ };
1945
+ }
1946
+ }
1947
+ hr(e) {
1948
+ let t = this.rules.block.hr.exec(e);
1949
+ if (t) return {
1950
+ type: "hr",
1951
+ raw: G(t[0], "\n")
1952
+ };
1953
+ }
1954
+ blockquote(e) {
1955
+ let t = this.rules.block.blockquote.exec(e);
1956
+ if (t) {
1957
+ let e = G(t[0], "\n").split("\n"), n = "", r = "", i = [];
1958
+ for (; e.length > 0;) {
1959
+ let t = !1, a = [], o = 0;
1960
+ for (; o < e.length; o++) if (this.rules.other.blockquoteStart.test(e[o])) a.push(e[o]), t = !0;
1961
+ else if (!t) a.push(e[o]);
1962
+ else break;
1963
+ e = e.slice(o);
1964
+ let s = a.join("\n"), c = s.replace(this.rules.other.blockquoteSetextReplace, "\n $1").replace(this.rules.other.blockquoteSetextReplace2, "");
1965
+ n = n ? `${n}
1966
+ ${s}` : s, r = r ? `${r}
1967
+ ${c}` : c;
1968
+ let l = this.lexer.state.top;
1969
+ if (this.lexer.state.top = !0, this.lexer.blockTokens(c, i, !0), this.lexer.state.top = l, e.length === 0) break;
1970
+ let u = i.at(-1);
1971
+ if (u?.type === "code") break;
1972
+ if (u?.type === "blockquote") {
1973
+ let t = u, a = e.join("\n"), o = t.raw + "\n" + a.replace(this.rules.other.blockquoteSetextReplace2, ""), s = this.blockquote(o);
1974
+ i[i.length - 1] = s;
1975
+ let c = o.substring(s.raw.length).replace(/^\n/, ""), l = c ? c.split("\n").length : 0, d = l ? e.slice(0, -l) : e;
1976
+ d.length > 0 && (n = `${n}
1977
+ ${d.join("\n")}`), r = r.substring(0, r.length - t.text.length) + s.text;
1978
+ break;
1979
+ }
1980
+ if (u?.type === "list") {
1981
+ let t = u, a = t.raw + "\n" + e.join("\n"), o = this.list(a);
1982
+ i[i.length - 1] = o, n = n.substring(0, n.length - u.raw.length) + o.raw, r = r.substring(0, r.length - t.raw.length) + o.raw, e = a.substring(i.at(-1).raw.length).split("\n");
1983
+ }
1984
+ }
1985
+ return {
1986
+ type: "blockquote",
1987
+ raw: n,
1988
+ tokens: i,
1989
+ text: r
1990
+ };
1991
+ }
1992
+ }
1993
+ list(e) {
1994
+ let t = this.rules.block.list.exec(e);
1995
+ if (t) {
1996
+ let n = t[1].trim(), r = n.length > 1, i = {
1997
+ type: "list",
1998
+ raw: "",
1999
+ ordered: r,
2000
+ start: r ? +n.slice(0, -1) : "",
2001
+ loose: !1,
2002
+ items: []
2003
+ };
2004
+ n = r ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = r ? n : "[*+-]");
2005
+ let a = this.rules.other.listItemRegex(n), o = !1;
2006
+ for (; e;) {
2007
+ let n = !1, r = "", s = "";
2008
+ if (!(t = a.exec(e)) || this.rules.block.hr.test(e)) break;
2009
+ r = t[0], e = e.substring(r.length);
2010
+ let c = t[2].split("\n", 1)[0], l = t[1].length, u = this.options.pedantic ? $r(c, l) : c.replace(this.rules.other.leadingSpaceTab, (e) => $r(e, l)), d = e.split("\n", 1)[0], f = !u.trim(), p = 0;
2011
+ if (this.options.pedantic ? (p = 2, s = u.trimStart()) : f ? p = l + 1 : (p = u.search(this.rules.other.nonSpaceChar), p = p > 4 ? 1 : p, s = u.slice(p), p += l), f && this.rules.other.blankLine.test(d) && (r += d + "\n", e = e.substring(d.length + 1), n = !0), !n) {
2012
+ let t = this.rules.other.nextBulletRegex(p), n = this.rules.other.hrRegex(p), i = this.rules.other.fencesBeginRegex(p), a = this.rules.other.headingBeginRegex(p), o = this.rules.other.htmlBeginRegex(p), c = this.rules.other.blockquoteBeginRegex(p);
2013
+ for (; e;) {
2014
+ let l = e.split("\n", 1)[0], m;
2015
+ if (d = l, this.options.pedantic ? (d = d.replace(this.rules.other.listReplaceNesting, " "), m = d) : m = d.replace(this.rules.other.leadingSpaceTab, (e) => e.replace(this.rules.other.tabCharGlobal, " ")), i.test(d) || a.test(d) || o.test(d) || c.test(d) || t.test(d) || n.test(d)) break;
2016
+ if (m.search(this.rules.other.nonSpaceChar) >= p || !d.trim()) s += "\n" + m.slice(p);
2017
+ else {
2018
+ if (f || u.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || i.test(u) || a.test(u) || n.test(u)) break;
2019
+ s += "\n" + d;
2020
+ }
2021
+ f = !d.trim(), r += l + "\n", e = e.substring(l.length + 1), u = m.slice(p);
2022
+ }
2023
+ }
2024
+ i.loose || (o ? i.loose = !0 : this.rules.other.doubleBlankLine.test(r) && (o = !0)), i.items.push({
2025
+ type: "list_item",
2026
+ raw: r,
2027
+ task: !!this.options.gfm && this.rules.other.listIsTask.test(s),
2028
+ loose: !1,
2029
+ text: s,
2030
+ tokens: []
2031
+ }), i.raw += r;
2032
+ }
2033
+ let s = i.items.at(-1);
2034
+ if (s) s.raw = s.raw.trimEnd(), s.text = s.text.trimEnd();
2035
+ else return;
2036
+ i.raw = i.raw.trimEnd();
2037
+ for (let e of i.items) if (this.lexer.state.top = !1, e.tokens = this.lexer.blockTokens(e.text, []), !i.loose) {
2038
+ let t = e.tokens.filter((e) => e.type === "space");
2039
+ i.loose = t.length > 0 && t.some((e) => this.rules.other.anyLine.test(e.raw));
2040
+ }
2041
+ for (let e of i.items) {
2042
+ let t = e.tokens[0];
2043
+ if (e.task && (t?.type === "text" || t?.type === "paragraph")) {
2044
+ e.text = e.text.replace(this.rules.other.listReplaceTask, ""), t.raw = t.raw.replace(this.rules.other.listReplaceTask, ""), t.text = t.text.replace(this.rules.other.listReplaceTask, "");
2045
+ for (let e = this.lexer.inlineQueue.length - 1; e >= 0; e--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)) {
2046
+ this.lexer.inlineQueue[e].src = this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask, "");
2047
+ break;
2048
+ }
2049
+ let n = this.rules.other.listTaskCheckbox.exec(e.raw);
2050
+ if (n) {
2051
+ let t = {
2052
+ type: "checkbox",
2053
+ raw: n[0] + " ",
2054
+ checked: n[0] !== "[ ]"
2055
+ };
2056
+ e.checked = t.checked, i.loose ? e.tokens[0] && ["paragraph", "text"].includes(e.tokens[0].type) && "tokens" in e.tokens[0] && e.tokens[0].tokens ? (e.tokens[0].raw = t.raw + e.tokens[0].raw, e.tokens[0].text = t.raw + e.tokens[0].text, e.tokens[0].tokens.unshift(t)) : e.tokens.unshift({
2057
+ type: "paragraph",
2058
+ raw: t.raw,
2059
+ text: t.raw,
2060
+ tokens: [t]
2061
+ }) : e.tokens.unshift(t);
2062
+ }
2063
+ } else e.task &&= !1;
2064
+ }
2065
+ if (i.loose) for (let e of i.items) {
2066
+ e.loose = !0;
2067
+ for (let t of e.tokens) t.type === "text" && (t.type = "paragraph");
2068
+ }
2069
+ return i;
2070
+ }
2071
+ }
2072
+ html(e) {
2073
+ let t = this.rules.block.html.exec(e);
2074
+ if (t) {
2075
+ let e = Zr(t[0]);
2076
+ return {
2077
+ type: "html",
2078
+ block: !0,
2079
+ raw: e,
2080
+ pre: t[1] === "pre" || t[1] === "script" || t[1] === "style",
2081
+ text: e
2082
+ };
2083
+ }
2084
+ }
2085
+ def(e) {
2086
+ let t = this.rules.block.def.exec(e);
2087
+ if (t) {
2088
+ if (!this.rules.other.startAngleBracket.test(t[2]) && Qr(t[2], "()") !== -1) return;
2089
+ let e = K(t[1]).replace(this.rules.other.multipleSpaceGlobal, " "), n = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
2090
+ return {
2091
+ type: "def",
2092
+ tag: e,
2093
+ raw: G(t[0], "\n"),
2094
+ href: n,
2095
+ title: r
2096
+ };
2097
+ }
2098
+ }
2099
+ table(e) {
2100
+ let t = this.rules.block.table.exec(e);
2101
+ if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
2102
+ let n = Xr(t[1]), r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [], a = {
2103
+ type: "table",
2104
+ raw: G(t[0], "\n"),
2105
+ header: [],
2106
+ align: [],
2107
+ rows: []
2108
+ };
2109
+ if (n.length === r.length) {
2110
+ for (let e of r) this.rules.other.tableAlignRight.test(e) ? a.align.push("right") : this.rules.other.tableAlignCenter.test(e) ? a.align.push("center") : this.rules.other.tableAlignLeft.test(e) ? a.align.push("left") : a.align.push(null);
2111
+ for (let e = 0; e < n.length; e++) a.header.push({
2112
+ text: n[e],
2113
+ tokens: this.lexer.inline(n[e]),
2114
+ header: !0,
2115
+ align: a.align[e]
2116
+ });
2117
+ for (let e of i) a.rows.push(Xr(e, a.header.length).map((e, t) => ({
2118
+ text: e,
2119
+ tokens: this.lexer.inline(e),
2120
+ header: !1,
2121
+ align: a.align[t]
2122
+ })));
2123
+ return a;
2124
+ }
2125
+ }
2126
+ lheading(e) {
2127
+ let t = this.rules.block.lheading.exec(e);
2128
+ if (t) {
2129
+ let e = t[1].trim();
2130
+ return {
2131
+ type: "heading",
2132
+ raw: G(t[0], "\n"),
2133
+ depth: t[2].charAt(0) === "=" ? 1 : 2,
2134
+ text: e,
2135
+ tokens: this.lexer.inline(e)
2136
+ };
2137
+ }
2138
+ }
2139
+ paragraph(e) {
2140
+ let t = this.rules.block.paragraph.exec(e);
2141
+ if (t) {
2142
+ let e = t[1].charAt(t[1].length - 1) === "\n" ? t[1].slice(0, -1) : t[1];
2143
+ return {
2144
+ type: "paragraph",
2145
+ raw: t[0],
2146
+ text: e,
2147
+ tokens: this.lexer.inline(e)
2148
+ };
2149
+ }
2150
+ }
2151
+ text(e) {
2152
+ let t = this.rules.block.text.exec(e);
2153
+ if (t) return {
2154
+ type: "text",
2155
+ raw: t[0],
2156
+ text: t[0],
2157
+ tokens: this.lexer.inline(t[0])
2158
+ };
2159
+ }
2160
+ escape(e) {
2161
+ let t = this.rules.inline.escape.exec(e);
2162
+ if (t) return {
2163
+ type: "escape",
2164
+ raw: t[0],
2165
+ text: t[1]
2166
+ };
2167
+ }
2168
+ tag(e) {
2169
+ let t = this.rules.inline.tag.exec(e);
2170
+ if (t) 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), {
2171
+ type: "html",
2172
+ raw: t[0],
2173
+ inLink: this.lexer.state.inLink,
2174
+ inRawBlock: this.lexer.state.inRawBlock,
2175
+ block: !1,
2176
+ text: t[0]
2177
+ };
2178
+ }
2179
+ link(e) {
2180
+ if (this.lexer.state.linkParenPossible === !1) return;
2181
+ let t = this.rules.inline.link.exec(e);
2182
+ if (t) {
2183
+ let n = t[0].charAt(0) === "!" ? 2 : 1;
2184
+ if (!this.options.pedantic && ni(e, t[1], n, this.rules)) return;
2185
+ let r = t[2].trim();
2186
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(r)) {
2187
+ if (!this.rules.other.endAngleBracket.test(r)) return;
2188
+ let e = G(r.slice(0, -1), "\\");
2189
+ if ((r.length - e.length) % 2 == 0) return;
2190
+ } else {
2191
+ let e = Qr(t[2], "()");
2192
+ if (e === -2) return;
2193
+ if (e > -1) {
2194
+ let n = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + e;
2195
+ t[2] = t[2].substring(0, e), t[0] = t[0].substring(0, n).trim(), t[3] = "";
2196
+ }
2197
+ }
2198
+ let i = t[2], a = "";
2199
+ if (this.options.pedantic) {
2200
+ let e = this.rules.other.pedanticHrefTitle.exec(i);
2201
+ e && (i = e[1], a = e[3]);
2202
+ } else a = t[3] ? t[3].slice(1, -1) : "";
2203
+ return i = i.trim(), this.rules.other.startAngleBracket.test(i) && (i = this.options.pedantic && !this.rules.other.endAngleBracket.test(r) ? i.slice(1) : i.slice(1, -1)), ei(t, {
2204
+ href: i && i.replace(this.rules.inline.anyPunctuation, "$1"),
2205
+ title: a && a.replace(this.rules.inline.anyPunctuation, "$1")
2206
+ }, t[0], this.lexer, this.rules);
2207
+ }
2208
+ }
2209
+ reflink(e, t) {
2210
+ let n;
2211
+ if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
2212
+ let r = n[0].charAt(0) === "!" ? 2 : 1;
2213
+ if (!this.options.pedantic && ni(e, n[1], r, this.rules)) return;
2214
+ let i = t[K((n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "))];
2215
+ if (!i) {
2216
+ let e = n[0].charAt(0);
2217
+ return {
2218
+ type: "text",
2219
+ raw: e,
2220
+ text: e
2221
+ };
2222
+ }
2223
+ return ei(n, i, n[0], this.lexer, this.rules);
2224
+ }
2225
+ }
2226
+ emStrong(e, t, n = "") {
2227
+ let r = this.rules.inline.emStrongLDelim.exec(e);
2228
+ if (!(!r || !r[1] && !r[2] && !r[3] && !r[4] || r[4] && n.match(this.rules.other.unicodeAlphaNumeric)) && (!(r[1] || r[3]) || !n || this.rules.inline.punctuation.exec(n))) {
2229
+ let i = [...r[0]].length - 1, a, o, s = i, c = 0, l = r[0][0], u = n === l, d = l === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
2230
+ for (d.lastIndex = 0, t = t.slice(-1 * e.length + i); (r = d.exec(t)) !== null;) {
2231
+ if (a = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !a) continue;
2232
+ if (o = [...a].length, r[3] || r[4]) {
2233
+ s += o;
2234
+ continue;
2235
+ }
2236
+ if (r[5] || r[6]) {
2237
+ if (i % 3 && !((i + o) % 3)) {
2238
+ c += o;
2239
+ continue;
2240
+ }
2241
+ if (u) break;
2242
+ }
2243
+ if (s -= o, s > 0) continue;
2244
+ o = Math.min(o, o + s + c);
2245
+ let t = [...r[0]][0].length, n = e.slice(0, i + r.index + t + o);
2246
+ if (Math.min(i, o) % 2) {
2247
+ let e = n.slice(1, -1);
2248
+ return {
2249
+ type: "em",
2250
+ raw: n,
2251
+ text: e,
2252
+ tokens: this.lexer.inlineTokens(e)
2253
+ };
2254
+ }
2255
+ let l = n.slice(2, -2);
2256
+ return {
2257
+ type: "strong",
2258
+ raw: n,
2259
+ text: l,
2260
+ tokens: this.lexer.inlineTokens(l)
2261
+ };
2262
+ }
2263
+ }
2264
+ }
2265
+ codespan(e) {
2266
+ let t = this.rules.inline.code.exec(e);
2267
+ if (t) {
2268
+ let e = t[2].replace(this.rules.other.newLineCharGlobal, " "), n = this.rules.other.nonSpaceChar.test(e), r = this.rules.other.startingSpaceChar.test(e) && this.rules.other.endingSpaceChar.test(e);
2269
+ return n && r && (e = e.substring(1, e.length - 1)), {
2270
+ type: "codespan",
2271
+ raw: t[0],
2272
+ text: e
2273
+ };
2274
+ }
2275
+ }
2276
+ br(e) {
2277
+ let t = this.rules.inline.br.exec(e);
2278
+ if (t) return {
2279
+ type: "br",
2280
+ raw: t[0]
2281
+ };
2282
+ }
2283
+ del(e, t, n = "") {
2284
+ let r = this.rules.inline.delLDelim.exec(e);
2285
+ if (r && (!r[1] || !n || this.rules.inline.punctuation.exec(n))) {
2286
+ let n = [...r[0]].length - 1, i, a, o = n, s = this.rules.inline.delRDelim;
2287
+ for (s.lastIndex = 0, t = t.slice(-1 * e.length + n); (r = s.exec(t)) !== null;) {
2288
+ if (i = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !i || (a = [...i].length, a !== n)) continue;
2289
+ if (r[3] || r[4]) {
2290
+ o += a;
2291
+ continue;
2292
+ }
2293
+ if (o -= a, o > 0) continue;
2294
+ a = Math.min(a, a + o);
2295
+ let t = [...r[0]][0].length, s = e.slice(0, n + r.index + t + a), c = s.slice(n, -n);
2296
+ return {
2297
+ type: "del",
2298
+ raw: s,
2299
+ text: c,
2300
+ tokens: this.lexer.inlineTokens(c)
2301
+ };
2302
+ }
2303
+ }
2304
+ }
2305
+ autolink(e) {
2306
+ let t = this.rules.inline.autolink.exec(e);
2307
+ if (t) {
2308
+ let e, n;
2309
+ return t[2] === "@" ? (e = t[1], n = "mailto:" + e) : (e = t[1], n = e), {
2310
+ type: "link",
2311
+ raw: t[0],
2312
+ text: e,
2313
+ href: n,
2314
+ autolink: !0,
2315
+ tokens: [{
2316
+ type: "text",
2317
+ raw: e,
2318
+ text: e
2319
+ }]
2320
+ };
2321
+ }
2322
+ }
2323
+ url(e) {
2324
+ let t;
2325
+ if (t = this.rules.inline.url.exec(e)) {
2326
+ let e, n;
2327
+ if (t[2] === "@") e = t[0], n = "mailto:" + e;
2328
+ else {
2329
+ let r;
2330
+ do
2331
+ r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
2332
+ while (r !== t[0]);
2333
+ e = t[0], n = t[1] === "www." ? "http://" + t[0] : t[0];
2334
+ }
2335
+ return {
2336
+ type: "link",
2337
+ raw: t[0],
2338
+ text: e,
2339
+ href: n,
2340
+ autolink: !0,
2341
+ tokens: [{
2342
+ type: "text",
2343
+ raw: e,
2344
+ text: e
2345
+ }]
2346
+ };
2347
+ }
2348
+ }
2349
+ inlineText(e) {
2350
+ let t = this.rules.inline.text.exec(e);
2351
+ if (t) {
2352
+ let e = this.lexer.state.inRawBlock;
2353
+ return {
2354
+ type: "text",
2355
+ raw: t[0],
2356
+ text: e ? t[0] : Jr(t[0]),
2357
+ escaped: e
2358
+ };
2359
+ }
2360
+ }
2361
+ }, J = class e {
2362
+ tokens;
2363
+ options;
2364
+ state;
2365
+ inlineQueue;
2366
+ tokenizer;
2367
+ constructor(e) {
2368
+ this.tokens = [], this.tokens.links = Object.create(null), this.options = e || A, this.options.tokenizer = this.options.tokenizer || new q(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
2369
+ inLink: !1,
2370
+ inRawBlock: !1,
2371
+ linkEmitted: !1,
2372
+ linkParenPossible: !0,
2373
+ top: !0
2374
+ };
2375
+ let t = {
2376
+ other: P,
2377
+ block: H.normal,
2378
+ inline: U.normal
2379
+ };
2380
+ this.options.pedantic ? (t.block = H.pedantic, t.inline = U.pedantic) : this.options.gfm && (t.block = H.gfm, t.inline = this.options.breaks ? U.breaks : U.gfm), this.tokenizer.rules = t;
2381
+ }
2382
+ static get rules() {
2383
+ return {
2384
+ block: H,
2385
+ inline: U
2386
+ };
2387
+ }
2388
+ static lex(t, n) {
2389
+ return new e(n).lex(t);
2390
+ }
2391
+ static lexInline(t, n) {
2392
+ return new e(n).inlineTokens(t);
2393
+ }
2394
+ lex(e) {
2395
+ e = e.replace(P.carriageReturn, "\n"), this.blockTokens(e, this.tokens);
2396
+ for (let e = 0; e < this.inlineQueue.length; e++) {
2397
+ let t = this.inlineQueue[e];
2398
+ this.inlineTokens(t.src, t.tokens);
2399
+ }
2400
+ return this.inlineQueue = [], this.tokens;
2401
+ }
2402
+ blockTokens(e, t = [], n = !1) {
2403
+ this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(P.tabCharGlobal, " ").replace(P.spaceLine, ""));
2404
+ let r = 1 / 0;
2405
+ for (; e;) {
2406
+ if (e.length < r) r = e.length;
2407
+ else {
2408
+ this.infiniteLoopError(e.charCodeAt(0));
2409
+ break;
2410
+ }
2411
+ let i;
2412
+ if (this.options.extensions?.block?.some((n) => (i = n.call({ lexer: this }, e, t)) ? (e = e.substring(i.raw.length), t.push(i), !0) : !1)) continue;
2413
+ if (i = this.tokenizer.space(e)) {
2414
+ e = e.substring(i.raw.length);
2415
+ let n = t.at(-1);
2416
+ i.raw.length === 1 && n !== void 0 ? n.raw += "\n" : t.push(i);
2417
+ continue;
2418
+ }
2419
+ if (i = this.tokenizer.code(e)) {
2420
+ e = e.substring(i.raw.length);
2421
+ let n = t.at(-1);
2422
+ n?.type === "paragraph" || n?.type === "text" ? (n.raw += (n.raw.endsWith("\n") ? "" : "\n") + i.raw, n.text += "\n" + i.text, this.inlineQueue.at(-1).src = n.text) : t.push(i);
2423
+ continue;
2424
+ }
2425
+ if ((i = this.tokenizer.fences(e)) || (i = this.tokenizer.heading(e)) || (i = this.tokenizer.hr(e)) || (i = this.tokenizer.blockquote(e)) || (i = this.tokenizer.list(e)) || (i = this.tokenizer.html(e))) {
2426
+ e = e.substring(i.raw.length), t.push(i);
2427
+ continue;
2428
+ }
2429
+ if (i = this.tokenizer.def(e)) {
2430
+ e = e.substring(i.raw.length);
2431
+ let n = t.at(-1);
2432
+ n?.type === "paragraph" || n?.type === "text" ? (n.raw += (n.raw.endsWith("\n") ? "" : "\n") + i.raw, n.text += "\n" + i.raw, this.inlineQueue.at(-1).src = n.text) : this.tokens.links[i.tag] || (this.tokens.links[i.tag] = {
2433
+ href: i.href,
2434
+ title: i.title
2435
+ }, t.push(i));
2436
+ continue;
2437
+ }
2438
+ if ((i = this.tokenizer.table(e)) || (i = this.tokenizer.lheading(e))) {
2439
+ e = e.substring(i.raw.length), t.push(i);
2440
+ continue;
2441
+ }
2442
+ let a = e;
2443
+ if (this.options.extensions?.startBlock) {
2444
+ let t = 1 / 0, n = e.slice(1), r;
2445
+ this.options.extensions.startBlock.forEach((e) => {
2446
+ r = e.call({ lexer: this }, n), typeof r == "number" && r >= 0 && (t = Math.min(t, r));
2447
+ }), t < 1 / 0 && t >= 0 && (a = e.substring(0, t + 1));
2448
+ }
2449
+ if (this.state.top && (i = this.tokenizer.paragraph(a))) {
2450
+ let r = t.at(-1);
2451
+ n && r?.type === "paragraph" ? (r.raw += (r.raw.endsWith("\n") ? "" : "\n") + i.raw, r.text += "\n" + i.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = r.text) : t.push(i), n = a.length !== e.length, e = e.substring(i.raw.length);
2452
+ } else if (i = this.tokenizer.text(e)) {
2453
+ e = e.substring(i.raw.length);
2454
+ let n = t.at(-1);
2455
+ n?.type === "text" ? (n.raw += (n.raw.endsWith("\n") ? "" : "\n") + i.raw, n.text += "\n" + i.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = n.text) : t.push(i);
2456
+ } else if (e) {
2457
+ this.infiniteLoopError(e.charCodeAt(0));
2458
+ break;
2459
+ }
2460
+ }
2461
+ return this.state.top = !0, t;
2462
+ }
2463
+ inline(e, t = []) {
2464
+ return this.inlineQueue.push({
2465
+ src: e,
2466
+ tokens: t
2467
+ }), t;
2468
+ }
2469
+ linkInText(e) {
2470
+ if (!e.includes("[")) return !1;
2471
+ let t = this.tokenizer.rules.inline.link;
2472
+ for (let n of e.matchAll(this.tokenizer.rules.inline.blockSkip)) if (t.test(n[0]) && e.charAt(n.index - 1) !== "!") return !0;
2473
+ for (let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)) {
2474
+ let e = t[0], n = e.lastIndexOf("[");
2475
+ if (e.charAt(0) !== "!" && Object.hasOwn(this.tokens.links, K(e.slice(n + 1, -1))) && !(n > 1 && this.linkInText(e.slice(1, n - 1)))) return !0;
2476
+ }
2477
+ return !1;
2478
+ }
2479
+ inlineTokens(e, t = []) {
2480
+ this.tokenizer.lexer = this;
2481
+ let n = this.state.linkParenPossible;
2482
+ this.state.linkParenPossible = n && e.includes(")");
2483
+ try {
2484
+ return this.#e(e, t);
2485
+ } finally {
2486
+ this.state.linkParenPossible = n;
2487
+ }
2488
+ }
2489
+ #e(e, t) {
2490
+ let n = e;
2491
+ if (this.tokens.links && e.includes("[")) {
2492
+ let e = this.tokenizer.rules.inline.reflinkSearch, t = (n) => {
2493
+ let r = n.lastIndexOf("[");
2494
+ if (!Object.hasOwn(this.tokens.links, K(n.slice(r + 1, -1)))) return n;
2495
+ if (r > 1 && n.charAt(0) !== "!") {
2496
+ let i = n.slice(1, r - 1);
2497
+ if (this.linkInText(i)) return "[" + i.replace(e, t) + "][" + "a".repeat(n.length - r - 2) + "]";
2498
+ }
2499
+ return "[" + "a".repeat(n.length - 2) + "]";
2500
+ };
2501
+ n = n.replace(e, t);
2502
+ }
2503
+ n = n.replace(this.tokenizer.rules.inline.anyPunctuation, (e) => "+".repeat(e.length)), n = n.replace(this.tokenizer.rules.inline.blockSkip, (e, t, n) => {
2504
+ let r = n ? n.length : 0;
2505
+ return e.slice(0, r) + "[" + "a".repeat(e.length - r - 2) + "]";
2506
+ }), n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
2507
+ let r = !1, i = "", a = 1 / 0;
2508
+ for (; e;) {
2509
+ if (e.length < a) a = e.length;
2510
+ else {
2511
+ this.infiniteLoopError(e.charCodeAt(0));
2512
+ break;
2513
+ }
2514
+ r || (i = ""), r = !1;
2515
+ let o;
2516
+ if (this.options.extensions?.inline?.some((n) => (o = n.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), !0) : !1)) continue;
2517
+ if ((o = this.tokenizer.escape(e)) || (o = this.tokenizer.tag(e)) || (o = this.tokenizer.link(e))) {
2518
+ e = e.substring(o.raw.length), t.push(o);
2519
+ continue;
2520
+ }
2521
+ if (o = this.tokenizer.reflink(e, this.tokens.links)) {
2522
+ e = e.substring(o.raw.length);
2523
+ let n = t.at(-1);
2524
+ o.type === "text" && n?.type === "text" ? (n.raw += o.raw, n.text += o.text) : t.push(o);
2525
+ continue;
2526
+ }
2527
+ if ((o = this.tokenizer.emStrong(e, n, i)) || (o = this.tokenizer.codespan(e)) || (o = this.tokenizer.br(e)) || (o = this.tokenizer.del(e, n, i)) || (o = this.tokenizer.autolink(e)) || !this.state.inLink && (o = this.tokenizer.url(e))) {
2528
+ e = e.substring(o.raw.length), t.push(o);
2529
+ continue;
2530
+ }
2531
+ let s = e;
2532
+ if (this.options.extensions?.startInline) {
2533
+ let t = 1 / 0, n = e.slice(1), r;
2534
+ this.options.extensions.startInline.forEach((e) => {
2535
+ r = e.call({ lexer: this }, n), typeof r == "number" && r >= 0 && (t = Math.min(t, r));
2536
+ }), t < 1 / 0 && t >= 0 && (s = e.substring(0, t + 1));
2537
+ }
2538
+ if (o = this.tokenizer.inlineText(s)) {
2539
+ e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (i = o.raw.slice(-1)), r = !0;
2540
+ let n = t.at(-1);
2541
+ n?.type === "text" ? (n.raw += o.raw, n.text += o.text) : t.push(o);
2542
+ } else if (e) {
2543
+ this.infiniteLoopError(e.charCodeAt(0));
2544
+ break;
2545
+ }
2546
+ }
2547
+ return t;
2548
+ }
2549
+ infiniteLoopError(e) {
2550
+ let t = "Infinite loop on byte: " + e;
2551
+ if (this.options.silent) console.error(t);
2552
+ else throw Error(t);
2553
+ }
2554
+ }, Y = class {
2555
+ options;
2556
+ parser;
2557
+ constructor(e) {
2558
+ this.options = e || A;
2559
+ }
2560
+ space(e) {
2561
+ return "";
2562
+ }
2563
+ code({ text: e, lang: t, escaped: n }) {
2564
+ let r = (t || "").match(P.notSpaceStart)?.[0], i = e ? e.replace(P.endingNewline, "") + "\n" : "";
2565
+ return r ? "<pre><code class=\"language-" + W(r) + "\">" + (n ? i : W(i, !0)) + "</code></pre>\n" : "<pre><code>" + (n ? i : W(i, !0)) + "</code></pre>\n";
2566
+ }
2567
+ blockquote({ tokens: e }) {
2568
+ return `<blockquote>
2569
+ ${this.parser.parse(e)}</blockquote>
2570
+ `;
2571
+ }
2572
+ html({ text: e }) {
2573
+ return e;
2574
+ }
2575
+ def(e) {
2576
+ return "";
2577
+ }
2578
+ heading({ tokens: e, depth: t }) {
2579
+ return `<h${t}>${this.parser.parseInline(e)}</h${t}>
2580
+ `;
2581
+ }
2582
+ hr(e) {
2583
+ return "<hr>\n";
2584
+ }
2585
+ list(e) {
2586
+ let t = e.ordered, n = e.start, r = "";
2587
+ for (let t = 0; t < e.items.length; t++) {
2588
+ let n = e.items[t];
2589
+ r += this.listitem(n);
2590
+ }
2591
+ let i = t ? "ol" : "ul", a = t && n !== 1 ? " start=\"" + n + "\"" : "";
2592
+ return "<" + i + a + ">\n" + r + "</" + i + ">\n";
2593
+ }
2594
+ listitem(e) {
2595
+ return `<li>${this.parser.parse(e.tokens)}</li>
2596
+ `;
2597
+ }
2598
+ checkbox({ checked: e }) {
2599
+ return "<input " + (e ? "checked=\"\" " : "") + "disabled=\"\" type=\"checkbox\"> ";
2600
+ }
2601
+ paragraph({ tokens: e }) {
2602
+ return `<p>${this.parser.parseInline(e)}</p>
2603
+ `;
2604
+ }
2605
+ table(e) {
2606
+ let t = "", n = "";
2607
+ for (let t = 0; t < e.header.length; t++) n += this.tablecell(e.header[t]);
2608
+ t += this.tablerow({ text: n });
2609
+ let r = "";
2610
+ for (let t = 0; t < e.rows.length; t++) {
2611
+ let i = e.rows[t];
2612
+ n = "";
2613
+ for (let e = 0; e < i.length; e++) n += this.tablecell(i[e]);
2614
+ r += this.tablerow({ text: n });
2615
+ }
2616
+ return r &&= `<tbody>${r}</tbody>`, "<table>\n<thead>\n" + t + "</thead>\n" + r + "</table>\n";
2617
+ }
2618
+ tablerow({ text: e }) {
2619
+ return `<tr>
2620
+ ${e}</tr>
2621
+ `;
2622
+ }
2623
+ tablecell(e) {
2624
+ let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
2625
+ return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
2626
+ `;
2627
+ }
2628
+ strong({ tokens: e }) {
2629
+ return `<strong>${this.parser.parseInline(e)}</strong>`;
2630
+ }
2631
+ em({ tokens: e }) {
2632
+ return `<em>${this.parser.parseInline(e)}</em>`;
2633
+ }
2634
+ codespan({ text: e }) {
2635
+ return `<code>${W(e, !0)}</code>`;
2636
+ }
2637
+ br(e) {
2638
+ return "<br>";
2639
+ }
2640
+ del({ tokens: e }) {
2641
+ return `<del>${this.parser.parseInline(e)}</del>`;
2642
+ }
2643
+ link({ href: e, title: t, text: n, tokens: r, autolink: i }) {
2644
+ let a = i ? W(n, !0) : this.parser.parseInline(r), o = Yr(e);
2645
+ if (o === null) return a;
2646
+ e = W(o, i);
2647
+ let s = "<a href=\"" + e + "\"";
2648
+ return t && (s += " title=\"" + W(t) + "\""), s += ">" + a + "</a>", s;
2649
+ }
2650
+ image({ href: e, title: t, text: n, tokens: r }) {
2651
+ r && (n = this.parser.parseInline(r, this.parser.textRenderer));
2652
+ let i = Yr(e);
2653
+ if (i === null) return W(n);
2654
+ e = i;
2655
+ let a = `<img src="${W(e)}" alt="${W(n)}"`;
2656
+ return t && (a += ` title="${W(t)}"`), a += ">", a;
2657
+ }
2658
+ text(e) {
2659
+ return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : W(e.text);
2660
+ }
2661
+ }, ri = class {
2662
+ strong({ text: e }) {
2663
+ return e;
2664
+ }
2665
+ em({ text: e }) {
2666
+ return e;
2667
+ }
2668
+ codespan({ text: e }) {
2669
+ return e;
2670
+ }
2671
+ del({ text: e }) {
2672
+ return e;
2673
+ }
2674
+ html({ text: e }) {
2675
+ return e;
2676
+ }
2677
+ text({ text: e }) {
2678
+ return e;
2679
+ }
2680
+ link({ text: e }) {
2681
+ return "" + e;
2682
+ }
2683
+ image({ text: e }) {
2684
+ return "" + e;
2685
+ }
2686
+ br() {
2687
+ return "";
2688
+ }
2689
+ checkbox({ raw: e }) {
2690
+ return e;
2691
+ }
2692
+ }, X = class e {
2693
+ options;
2694
+ renderer;
2695
+ textRenderer;
2696
+ constructor(e) {
2697
+ this.options = e || A, this.options.renderer = this.options.renderer || new Y(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new ri();
2698
+ }
2699
+ static parse(t, n) {
2700
+ return new e(n).parse(t);
2701
+ }
2702
+ static parseInline(t, n) {
2703
+ return new e(n).parseInline(t);
2704
+ }
2705
+ parse(e) {
2706
+ this.renderer.parser = this;
2707
+ let t = "";
2708
+ for (let n = 0; n < e.length; n++) {
2709
+ let r = e[n];
2710
+ if (this.options.extensions?.renderers?.[r.type]) {
2711
+ let e = r, n = this.options.extensions.renderers[e.type].call({ parser: this }, e);
2712
+ if (n !== !1 || ![
2713
+ "space",
2714
+ "hr",
2715
+ "heading",
2716
+ "code",
2717
+ "table",
2718
+ "blockquote",
2719
+ "list",
2720
+ "checkbox",
2721
+ "html",
2722
+ "def",
2723
+ "paragraph",
2724
+ "text"
2725
+ ].includes(e.type)) {
2726
+ t += n || "";
2727
+ continue;
2728
+ }
2729
+ }
2730
+ let i = r;
2731
+ switch (i.type) {
2732
+ case "space":
2733
+ t += this.renderer.space(i);
2734
+ break;
2735
+ case "hr":
2736
+ t += this.renderer.hr(i);
2737
+ break;
2738
+ case "heading":
2739
+ t += this.renderer.heading(i);
2740
+ break;
2741
+ case "code":
2742
+ t += this.renderer.code(i);
2743
+ break;
2744
+ case "table":
2745
+ t += this.renderer.table(i);
2746
+ break;
2747
+ case "blockquote":
2748
+ t += this.renderer.blockquote(i);
2749
+ break;
2750
+ case "list":
2751
+ t += this.renderer.list(i);
2752
+ break;
2753
+ case "checkbox":
2754
+ t += this.renderer.checkbox(i);
2755
+ break;
2756
+ case "html":
2757
+ t += this.renderer.html(i);
2758
+ break;
2759
+ case "def":
2760
+ t += this.renderer.def(i);
2761
+ break;
2762
+ case "paragraph":
2763
+ t += this.renderer.paragraph(i);
2764
+ break;
2765
+ case "text":
2766
+ t += this.renderer.text(i);
2767
+ break;
2768
+ default: {
2769
+ let e = "Token with \"" + i.type + "\" type was not found.";
2770
+ if (this.options.silent) return console.error(e), "";
2771
+ throw Error(e);
2772
+ }
2773
+ }
2774
+ }
2775
+ return t;
2776
+ }
2777
+ parseInline(e, t = this.renderer) {
2778
+ this.renderer.parser = this;
2779
+ let n = "";
2780
+ for (let r = 0; r < e.length; r++) {
2781
+ let i = e[r];
2782
+ if (this.options.extensions?.renderers?.[i.type]) {
2783
+ let e = this.options.extensions.renderers[i.type].call({ parser: this }, i);
2784
+ if (e !== !1 || ![
2785
+ "escape",
2786
+ "html",
2787
+ "link",
2788
+ "image",
2789
+ "checkbox",
2790
+ "strong",
2791
+ "em",
2792
+ "codespan",
2793
+ "br",
2794
+ "del",
2795
+ "text"
2796
+ ].includes(i.type)) {
2797
+ n += e || "";
2798
+ continue;
2799
+ }
2800
+ }
2801
+ let a = i;
2802
+ switch (a.type) {
2803
+ case "escape":
2804
+ n += t.text(a);
2805
+ break;
2806
+ case "html":
2807
+ n += t.html(a);
2808
+ break;
2809
+ case "link":
2810
+ n += t.link(a);
2811
+ break;
2812
+ case "image":
2813
+ n += t.image(a);
2814
+ break;
2815
+ case "checkbox":
2816
+ n += t.checkbox(a);
2817
+ break;
2818
+ case "strong":
2819
+ n += t.strong(a);
2820
+ break;
2821
+ case "em":
2822
+ n += t.em(a);
2823
+ break;
2824
+ case "codespan":
2825
+ n += t.codespan(a);
2826
+ break;
2827
+ case "br":
2828
+ n += t.br(a);
2829
+ break;
2830
+ case "del":
2831
+ n += t.del(a);
2832
+ break;
2833
+ case "text":
2834
+ n += t.text(a);
2835
+ break;
2836
+ default: {
2837
+ let e = "Token with \"" + a.type + "\" type was not found.";
2838
+ if (this.options.silent) return console.error(e), "";
2839
+ throw Error(e);
2840
+ }
2841
+ }
2842
+ }
2843
+ return n;
2844
+ }
2845
+ }, Z = class {
2846
+ options;
2847
+ block;
2848
+ constructor(e) {
2849
+ this.options = e || A;
2850
+ }
2851
+ static passThroughHooks = /* @__PURE__ */ new Set([
2852
+ "preprocess",
2853
+ "postprocess",
2854
+ "processAllTokens",
2855
+ "emStrongMask"
2856
+ ]);
2857
+ static passThroughHooksRespectAsync = /* @__PURE__ */ new Set([
2858
+ "preprocess",
2859
+ "postprocess",
2860
+ "processAllTokens"
2861
+ ]);
2862
+ preprocess(e) {
2863
+ return e;
2864
+ }
2865
+ postprocess(e) {
2866
+ return e;
2867
+ }
2868
+ processAllTokens(e) {
2869
+ return e;
2870
+ }
2871
+ emStrongMask(e) {
2872
+ return e;
2873
+ }
2874
+ provideLexer(e = this.block) {
2875
+ return e ? J.lex : J.lexInline;
2876
+ }
2877
+ provideParser(e = this.block) {
2878
+ return e ? X.parse : X.parseInline;
2879
+ }
2880
+ }, ii = class {
2881
+ defaults = Ln();
2882
+ options = this.setOptions;
2883
+ parse = this.parseMarkdown(!0);
2884
+ parseInline = this.parseMarkdown(!1);
2885
+ Parser = X;
2886
+ Renderer = Y;
2887
+ TextRenderer = ri;
2888
+ Lexer = J;
2889
+ Tokenizer = q;
2890
+ Hooks = Z;
2891
+ constructor(...e) {
2892
+ this.use(...e);
2893
+ }
2894
+ walkTokens(e, t) {
2895
+ let n = [];
2896
+ for (let r of e) switch (n = n.concat(t.call(this, r)), r.type) {
2897
+ case "table": {
2898
+ let e = r;
2899
+ for (let r of e.header) n = n.concat(this.walkTokens(r.tokens, t));
2900
+ for (let r of e.rows) for (let e of r) n = n.concat(this.walkTokens(e.tokens, t));
2901
+ break;
2902
+ }
2903
+ case "list": {
2904
+ let e = r;
2905
+ n = n.concat(this.walkTokens(e.items, t));
2906
+ break;
2907
+ }
2908
+ default: {
2909
+ let e = r;
2910
+ this.defaults.extensions?.childTokens?.[e.type] ? this.defaults.extensions.childTokens[e.type].forEach((r) => {
2911
+ let i = e[r].flat(1 / 0);
2912
+ n = n.concat(this.walkTokens(i, t));
2913
+ }) : e.tokens && (n = n.concat(this.walkTokens(e.tokens, t)));
2914
+ }
2915
+ }
2916
+ return n;
2917
+ }
2918
+ use(...e) {
2919
+ let t = this.defaults.extensions || {
2920
+ renderers: {},
2921
+ childTokens: {}
2922
+ };
2923
+ return e.forEach((e) => {
2924
+ let n = { ...e };
2925
+ if (n.async = this.defaults.async || n.async || !1, e.extensions && (e.extensions.forEach((e) => {
2926
+ if (!e.name) throw Error("extension name required");
2927
+ if ("renderer" in e) {
2928
+ let n = t.renderers[e.name];
2929
+ n ? t.renderers[e.name] = function(...t) {
2930
+ let r = e.renderer.apply(this, t);
2931
+ return r === !1 && (r = n.apply(this, t)), r;
2932
+ } : t.renderers[e.name] = e.renderer;
2933
+ }
2934
+ if ("tokenizer" in e) {
2935
+ if (!e.level || e.level !== "block" && e.level !== "inline") throw Error("extension level must be 'block' or 'inline'");
2936
+ let n = t[e.level];
2937
+ n ? n.unshift(e.tokenizer) : t[e.level] = [e.tokenizer], e.start && (e.level === "block" ? t.startBlock ? t.startBlock.push(e.start) : t.startBlock = [e.start] : e.level === "inline" && (t.startInline ? t.startInline.push(e.start) : t.startInline = [e.start]));
2938
+ }
2939
+ "childTokens" in e && e.childTokens && (t.childTokens[e.name] = e.childTokens);
2940
+ }), n.extensions = t), e.renderer) {
2941
+ let t = this.defaults.renderer || new Y(this.defaults);
2942
+ for (let n in e.renderer) {
2943
+ if (!(n in t)) throw Error(`renderer '${n}' does not exist`);
2944
+ if (["options", "parser"].includes(n)) continue;
2945
+ let r = n, i = e.renderer[r], a = t[r];
2946
+ t[r] = (...e) => {
2947
+ let n = i.apply(t, e);
2948
+ return n === !1 && (n = a.apply(t, e)), n || "";
2949
+ };
2950
+ }
2951
+ n.renderer = t;
2952
+ }
2953
+ if (e.tokenizer) {
2954
+ let t = this.defaults.tokenizer || new q(this.defaults);
2955
+ for (let n in e.tokenizer) {
2956
+ if (!(n in t)) throw Error(`tokenizer '${n}' does not exist`);
2957
+ if ([
2958
+ "options",
2959
+ "rules",
2960
+ "lexer"
2961
+ ].includes(n)) continue;
2962
+ let r = n, i = e.tokenizer[r], a = t[r];
2963
+ t[r] = (...e) => {
2964
+ let n = i.apply(t, e);
2965
+ return n === !1 && (n = a.apply(t, e)), n;
2966
+ };
2967
+ }
2968
+ n.tokenizer = t;
2969
+ }
2970
+ if (e.hooks) {
2971
+ let t = this.defaults.hooks || new Z();
2972
+ for (let n in e.hooks) {
2973
+ if (!(n in t)) throw Error(`hook '${n}' does not exist`);
2974
+ if (["options", "block"].includes(n)) continue;
2975
+ let r = n, i = e.hooks[r], a = t[r];
2976
+ t[r] = Z.passThroughHooks.has(n) ? (e) => {
2977
+ if (this.defaults.async && Z.passThroughHooksRespectAsync.has(n)) return (async () => {
2978
+ let n = await i.call(t, e);
2979
+ return a.call(t, n);
2980
+ })();
2981
+ let r = i.call(t, e);
2982
+ return a.call(t, r);
2983
+ } : (...e) => {
2984
+ if (this.defaults.async) return (async () => {
2985
+ let n = await i.apply(t, e);
2986
+ return n === !1 && (n = await a.apply(t, e)), n;
2987
+ })();
2988
+ let n = i.apply(t, e);
2989
+ return n === !1 && (n = a.apply(t, e)), n;
2990
+ };
2991
+ }
2992
+ n.hooks = t;
2993
+ }
2994
+ if (e.walkTokens) {
2995
+ let t = this.defaults.walkTokens, r = e.walkTokens;
2996
+ n.walkTokens = function(e) {
2997
+ let n = [];
2998
+ return n.push(r.call(this, e)), t && (n = n.concat(t.call(this, e))), n;
2999
+ };
3000
+ }
3001
+ this.defaults = {
3002
+ ...this.defaults,
3003
+ ...n
3004
+ };
3005
+ }), this;
3006
+ }
3007
+ setOptions(e) {
3008
+ return this.defaults = {
3009
+ ...this.defaults,
3010
+ ...e
3011
+ }, this;
3012
+ }
3013
+ lexer(e, t) {
3014
+ return J.lex(e, t ?? this.defaults);
3015
+ }
3016
+ parser(e, t) {
3017
+ return X.parse(e, t ?? this.defaults);
3018
+ }
3019
+ parseMarkdown(e) {
3020
+ return (t, n) => {
3021
+ let r = { ...n }, i = {
3022
+ ...this.defaults,
3023
+ ...r
3024
+ }, a = this.onError(!!i.silent, !!i.async);
3025
+ if (this.defaults.async === !0 && r.async === !1) return a(/* @__PURE__ */ Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
3026
+ if (typeof t > "u" || t === null) return a(/* @__PURE__ */ Error("marked(): input parameter is undefined or null"));
3027
+ if (typeof t != "string") return a(/* @__PURE__ */ Error("marked(): input parameter is of type " + Object.prototype.toString.call(t) + ", string expected"));
3028
+ if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => {
3029
+ let n = i.hooks ? await i.hooks.preprocess(t) : t, r = await (i.hooks ? await i.hooks.provideLexer(e) : e ? J.lex : J.lexInline)(n, i), a = i.hooks ? await i.hooks.processAllTokens(r) : r;
3030
+ i.walkTokens && await Promise.all(this.walkTokens(a, i.walkTokens));
3031
+ let o = await (i.hooks ? await i.hooks.provideParser(e) : e ? X.parse : X.parseInline)(a, i);
3032
+ return i.hooks ? await i.hooks.postprocess(o) : o;
3033
+ })().catch(a);
3034
+ try {
3035
+ i.hooks && (t = i.hooks.preprocess(t));
3036
+ let n = (i.hooks ? i.hooks.provideLexer(e) : e ? J.lex : J.lexInline)(t, i);
3037
+ i.hooks && (n = i.hooks.processAllTokens(n)), i.walkTokens && this.walkTokens(n, i.walkTokens);
3038
+ let r = (i.hooks ? i.hooks.provideParser(e) : e ? X.parse : X.parseInline)(n, i);
3039
+ return i.hooks && (r = i.hooks.postprocess(r)), r;
3040
+ } catch (e) {
3041
+ return a(e);
3042
+ }
3043
+ };
3044
+ }
3045
+ onError(e, t) {
3046
+ return (n) => {
3047
+ if (n.message += "\nPlease report this to https://github.com/markedjs/marked.", e) {
3048
+ let e = "<p>An error occurred:</p><pre>" + W(n.message + "", !0) + "</pre>";
3049
+ return t ? Promise.resolve(e) : e;
3050
+ }
3051
+ if (t) return Promise.reject(n);
3052
+ throw n;
3053
+ };
3054
+ }
3055
+ }, Q = new ii();
3056
+ function $(e, t) {
3057
+ return Q.parse(e, t);
3058
+ }
3059
+ $.options = $.setOptions = function(e) {
3060
+ return Q.setOptions(e), $.defaults = Q.defaults, Rn($.defaults), $;
3061
+ }, $.getDefaults = Ln, $.defaults = A;
3062
+ function ai(...e) {
3063
+ return Q.use(...e), $.defaults = Q.defaults, Rn($.defaults), $;
3064
+ }
3065
+ $.use = ai, $.walkTokens = function(e, t) {
3066
+ return Q.walkTokens(e, t);
3067
+ }, $.parseInline = Q.parseInline, $.Parser = X, $.parser = X.parse, $.Renderer = Y, $.TextRenderer = ri, $.Lexer = J, $.lexer = J.lex, $.Tokenizer = q, $.Hooks = Z, $.parse = $, $.options, $.setOptions, $.walkTokens, $.parseInline, X.parse, J.lex;
3068
+ //#endregion
3069
+ //#region src/utils/html.ts
3070
+ function oi(e) {
3071
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
3072
+ }
3073
+ function si() {
3074
+ return globalThis.katex ?? null;
3075
+ }
3076
+ function ci(e, t, n) {
3077
+ let r = si();
3078
+ return r ? r.renderToString(e, {
3079
+ displayMode: t,
3080
+ throwOnError: !1
3081
+ }) : oi(n);
3082
+ }
3083
+ var li = { extensions: [{
3084
+ name: "blockMath",
3085
+ level: "block",
3086
+ start(e) {
3087
+ return e.indexOf("$$");
3088
+ },
3089
+ tokenizer(e) {
3090
+ let t = /^\$\$([\s\S]+?)\$\$/.exec(e);
3091
+ if (t && t[1]) return {
3092
+ type: "blockMath",
3093
+ raw: t[0],
3094
+ text: t[1].trim()
3095
+ };
3096
+ },
3097
+ renderer(e) {
3098
+ let t = e;
3099
+ return ci(t.text, !0, t.raw);
3100
+ }
3101
+ }, {
3102
+ name: "inlineMath",
3103
+ level: "inline",
3104
+ start(e) {
3105
+ return e.indexOf("$");
3106
+ },
3107
+ tokenizer(e) {
3108
+ let t = /^\$(?! )((?:[^$\n]|\\\$)*?[^ $\n])\$/.exec(e);
3109
+ if (t && t[1]) return {
3110
+ type: "inlineMath",
3111
+ raw: t[0],
3112
+ text: t[1]
3113
+ };
3114
+ },
3115
+ renderer(e) {
3116
+ let t = e;
3117
+ return ci(t.text, !1, t.raw);
3118
+ }
3119
+ }] };
3120
+ //#endregion
3121
+ //#region src/markdown/sanitize.ts
3122
+ function ui(e) {
3123
+ return e.replace(/<a\b(?![^>]*\btarget=)([^>]*)>/gi, "<a target=\"_blank\" rel=\"noopener noreferrer\"$1>");
3124
+ }
3125
+ //#endregion
3126
+ //#region src/markdown/parse.ts
3127
+ function di(e) {
3128
+ return {
3129
+ singleLineBreaks: e.renderingConfig?.singleLineBreaks,
3130
+ previewRender: e.previewRender
3131
+ };
3132
+ }
3133
+ function fi(e, t = {}) {
3134
+ if (t.previewRender) return t.previewRender(e);
3135
+ let n = new ii({
3136
+ gfm: !0,
3137
+ breaks: t.singleLineBreaks ?? !0
3138
+ });
3139
+ return n.use(li), ui(n.parse(e, { async: !1 }));
3140
+ }
3141
+ //#endregion
3142
+ //#region src/features/storage.ts
3143
+ var pi = "supamde:";
3144
+ function mi(e = pi) {
3145
+ let t = (t) => `${e}${t}`;
3146
+ return {
3147
+ load: (e) => localStorage.getItem(t(e)),
3148
+ save: (e, n) => {
3149
+ localStorage.setItem(t(e), n);
3150
+ },
3151
+ clear: (e) => {
3152
+ localStorage.removeItem(t(e));
3153
+ }
3154
+ };
3155
+ }
3156
+ async function hi(e) {
3157
+ let t = "__supamde_probe__";
3158
+ try {
3159
+ await e.save(t, "1");
3160
+ let n = await e.load(t);
3161
+ return await e.clear(t), n === "1";
3162
+ } catch {
3163
+ return !1;
3164
+ }
3165
+ }
3166
+ function gi(e, t) {
3167
+ let n = e.enabled ?? !1, r = e.delay ?? 1e3, i = e.storage ?? mi(), a = e.key, o = t.getValue(), s = !1, c = null, l = !1, u = (e) => {
3168
+ l || (l = !0, console.warn(`SupaMDE: ${e}`));
3169
+ }, d = () => {
3170
+ c !== null && (clearTimeout(c), c = null);
3171
+ }, f = async () => {
3172
+ if (!s) return;
3173
+ let e = t.getValue();
3174
+ try {
3175
+ e.trim() === "" ? await i.clear(a) : await i.save(a, e), t.onSaved(/* @__PURE__ */ new Date());
3176
+ } catch {
3177
+ s = !1, d(), u("autosave storage is not writable — autosave is disabled.");
3178
+ }
3179
+ };
3180
+ return {
3181
+ start: async () => {
3182
+ if (!n) return;
3183
+ if (!a) {
3184
+ u("autosave.key is required — autosave stays off.");
3185
+ return;
3186
+ }
3187
+ if (!await hi(i)) {
3188
+ u("autosave storage is not available — autosave is disabled.");
3189
+ return;
3190
+ }
3191
+ s = !0;
3192
+ let r;
3193
+ try {
3194
+ r = await i.load(a);
3195
+ } catch {
3196
+ s = !1, u("autosave storage is not readable — autosave is disabled.");
3197
+ return;
3198
+ }
3199
+ let c = t.getValue();
3200
+ c === o && r && r.trim() !== "" && r !== c && (t.setValue(r), e.onRestore?.(r));
3201
+ },
3202
+ schedule: () => {
3203
+ s && (d(), c = setTimeout(() => {
3204
+ c = null, f();
3205
+ }, r));
3206
+ },
3207
+ clear: async () => {
3208
+ d();
3209
+ try {
3210
+ await i.clear(a);
3211
+ } catch {
3212
+ u("autosave entry could not be deleted.");
3213
+ }
3214
+ },
3215
+ stop: d,
3216
+ isActive: () => s
3217
+ };
3218
+ }
3219
+ //#endregion
3220
+ //#region src/features/upload-placeholder.ts
3221
+ var _i = l.define(), vi = l.define(), yi = u.define({
3222
+ create() {
3223
+ return /* @__PURE__ */ new Map();
3224
+ },
3225
+ update(e, t) {
3226
+ let n = e;
3227
+ if (t.docChanged && n.size > 0) {
3228
+ let e = /* @__PURE__ */ new Map();
3229
+ for (let [r, i] of n) {
3230
+ let n = t.changes.mapPos(i.from, 1), a = t.changes.mapPos(i.to, -1);
3231
+ a > n && e.set(r, {
3232
+ from: n,
3233
+ to: a
3234
+ });
3235
+ }
3236
+ n = e;
3237
+ }
3238
+ for (let e of t.effects) if (e.is(_i)) {
3239
+ let t = new Map(n);
3240
+ t.set(e.value.id, {
3241
+ from: e.value.from,
3242
+ to: e.value.to
3243
+ }), n = t;
3244
+ } else if (e.is(vi) && n.has(e.value)) {
3245
+ let t = new Map(n);
3246
+ t.delete(e.value), n = t;
3247
+ }
3248
+ return n;
3249
+ }
3250
+ });
3251
+ function bi(e, t) {
3252
+ return e.field(yi, !1)?.get(t) ?? null;
3253
+ }
3254
+ function xi() {
3255
+ let e = 0;
3256
+ return () => (e += 1, e);
3257
+ }
3258
+ var Si = [
3259
+ "image/png",
3260
+ "image/jpeg",
3261
+ "image/gif",
3262
+ "image/webp",
3263
+ "image/avif",
3264
+ "image/svg+xml"
3265
+ ], Ci = 2e3, wi = 6e3, Ti = {
3266
+ "too-large": "upload.errorTooLarge",
3267
+ "type-not-allowed": "upload.errorType",
3268
+ "upload-failed": "upload.errorFailed"
3269
+ };
3270
+ function Ei(e, t) {
3271
+ return `![${e.replace(/([[\]\\])/g, "\\$1")}](${/[\s()<>]/.test(t) ? `<${t.replace(/([<>\\])/g, "\\$1")}>` : t})`;
3272
+ }
3273
+ function Di(e, t) {
3274
+ return e.size > t.maxSize ? "too-large" : t.accept.includes(e.type) ? null : "type-not-allowed";
3275
+ }
3276
+ function Oi(e, t, n, r = E()) {
3277
+ let i = t.enabled ?? !1, a = t.maxSize ?? 2097152, o = t.accept ?? Si, s = xi(), c = 0, l = null, u = (e, t) => {
3278
+ n.setStatus(e), l !== null && (clearTimeout(l), l = null), t !== void 0 && (l = setTimeout(() => {
3279
+ l = null, c === 0 && n.setStatus(r.t("upload.statusInit"));
3280
+ }, t));
3281
+ }, d = (e, n, i) => {
3282
+ let o = {
3283
+ name: n.name,
3284
+ maxSize: Lt(a)
3285
+ };
3286
+ u(r.t(Ti[e], o), wi), t.onError?.({
3287
+ kind: e,
3288
+ file: n,
3289
+ cause: i
3290
+ });
3291
+ }, f = (n) => {
3292
+ let i = Di(n, {
3293
+ maxSize: a,
3294
+ accept: o
3295
+ });
3296
+ if (i) {
3297
+ d(i, n);
3298
+ return;
3299
+ }
3300
+ let l = s(), f = r.t("upload.placeholder", { name: n.name }), p = e.state.selection.main;
3301
+ e.dispatch({
3302
+ changes: {
3303
+ from: p.from,
3304
+ to: p.to,
3305
+ insert: f
3306
+ },
3307
+ effects: _i.of({
3308
+ id: l,
3309
+ from: p.from,
3310
+ to: p.from + f.length
3311
+ }),
3312
+ selection: { anchor: p.from + f.length }
3313
+ }), c += 1, u(r.t("upload.statusUploading", { name: n.name })), Promise.resolve().then(() => t.upload(n)).then((t) => {
3314
+ --c;
3315
+ let i = bi(e.state, l);
3316
+ i && (e.dispatch({
3317
+ changes: {
3318
+ from: i.from,
3319
+ to: i.to,
3320
+ insert: Ei(n.name, t)
3321
+ },
3322
+ effects: vi.of(l)
3323
+ }), u(r.t("upload.statusDone", { name: n.name }), Ci));
3324
+ }, (t) => {
3325
+ --c;
3326
+ let r = bi(e.state, l);
3327
+ r && e.dispatch({
3328
+ changes: {
3329
+ from: r.from,
3330
+ to: r.to,
3331
+ insert: ""
3332
+ },
3333
+ effects: vi.of(l)
3334
+ }), d("upload-failed", n, t);
3335
+ });
3336
+ };
3337
+ return {
3338
+ uploadFiles: (e) => {
3339
+ if (i) for (let t of Array.from(e)) f(t);
3340
+ },
3341
+ accept: () => o,
3342
+ isActive: () => i,
3343
+ destroy: () => {
3344
+ l !== null && (clearTimeout(l), l = null);
3345
+ }
3346
+ };
3347
+ }
3348
+ //#endregion
3349
+ //#region src/features/upload-dom.ts
3350
+ function ki(e) {
3351
+ if (!e) return [];
3352
+ let t = e.files;
3353
+ return !t || t.length === 0 ? [] : Array.from(t).filter((e) => e.type.startsWith("image/"));
3354
+ }
3355
+ function Ai(e) {
3356
+ return t.domEventHandlers({
3357
+ drop(t) {
3358
+ let n = ki(t.dataTransfer);
3359
+ return n.length !== 0 && (t.preventDefault(), e(n), !0);
3360
+ },
3361
+ paste(t) {
3362
+ let n = ki(t.clipboardData);
3363
+ return n.length !== 0 && (t.preventDefault(), e(n), !0);
3364
+ }
3365
+ });
3366
+ }
3367
+ function ji(e, t) {
3368
+ let n = document.createElement("input");
3369
+ n.type = "file", n.multiple = !0, n.accept = e.join(","), n.style.display = "none";
3370
+ let r = () => {
3371
+ n.remove();
3372
+ };
3373
+ n.addEventListener("change", () => {
3374
+ let e = n.files ? Array.from(n.files) : [];
3375
+ r(), e.length > 0 && t(e);
3376
+ }), n.addEventListener("cancel", r), document.body.appendChild(n), n.click();
3377
+ }
3378
+ //#endregion
3379
+ //#region src/i18n/de.ts
3380
+ var Mi = {
3381
+ code: "de",
3382
+ texts: {
3383
+ "toolbar.bold": "Fett",
3384
+ "toolbar.italic": "Kursiv",
3385
+ "toolbar.strikethrough": "Durchgestrichen",
3386
+ "toolbar.code": "Inline-Code",
3387
+ "toolbar.heading-smaller": "Überschrift kleiner",
3388
+ "toolbar.heading-bigger": "Überschrift größer",
3389
+ "toolbar.heading-1": "Überschrift 1",
3390
+ "toolbar.heading-2": "Überschrift 2",
3391
+ "toolbar.heading-3": "Überschrift 3",
3392
+ "toolbar.heading-4": "Überschrift 4",
3393
+ "toolbar.heading-5": "Überschrift 5",
3394
+ "toolbar.heading-6": "Überschrift 6",
3395
+ "toolbar.quote": "Blockzitat",
3396
+ "toolbar.code-block": "Codeblock",
3397
+ "toolbar.horizontal-rule": "Trennlinie",
3398
+ "toolbar.clean-block": "Formatierung entfernen",
3399
+ "toolbar.unordered-list": "Liste",
3400
+ "toolbar.ordered-list": "Nummerierte Liste",
3401
+ "toolbar.check-list": "Checkliste",
3402
+ "toolbar.link": "Link",
3403
+ "toolbar.image": "Bild",
3404
+ "toolbar.table": "Tabelle",
3405
+ "toolbar.undo": "Rückgängig",
3406
+ "toolbar.redo": "Wiederholen",
3407
+ "toolbar.side-by-side": "Nebeneinander-Vorschau",
3408
+ "toolbar.fullscreen": "Vollbild",
3409
+ "toolbar.preview-fullscreen": "Vorschau im Vollbild",
3410
+ "toolbar.editor-mode": "Live-Vorschau",
3411
+ "toolbar.upload-image": "Bild hochladen",
3412
+ "status.lines": {
3413
+ one: "{count} Zeile",
3414
+ other: "{count} Zeilen"
3415
+ },
3416
+ "status.words": {
3417
+ one: "{count} Wort",
3418
+ other: "{count} Wörter"
3419
+ },
3420
+ "status.autosaved": "Gespeichert: {time}",
3421
+ "upload.placeholder": "![Uploading {name}…]()",
3422
+ "upload.statusInit": "Bild hierher ziehen oder einfügen",
3423
+ "upload.statusUploading": "Lade {name} hoch…",
3424
+ "upload.statusDone": "{name} hochgeladen",
3425
+ "upload.errorTooLarge": "{name} ist zu groß (max. {maxSize}).",
3426
+ "upload.errorType": "{name} ist kein unterstütztes Bildformat.",
3427
+ "upload.errorFailed": "Upload von {name} fehlgeschlagen.",
3428
+ "prompt.linkUrl": "Link-URL:",
3429
+ "prompt.imageUrl": "Bild-URL:",
3430
+ "table.column": "Spalte {n}"
3431
+ }
3432
+ }, Ni = class {
3433
+ static version = me;
3434
+ options;
3435
+ codemirror;
3436
+ handle;
3437
+ container;
3438
+ editorRow;
3439
+ toolbar;
3440
+ statusbar;
3441
+ preview;
3442
+ fullscreen;
3443
+ autosave;
3444
+ uploader = null;
3445
+ onViewShortcuts;
3446
+ renderOpts;
3447
+ editorMode;
3448
+ translator;
3449
+ constructor(e = {}) {
3450
+ this.options = e, e.injectStyles !== !1 && In(), this.translator = E(e.locale, e.texts);
3451
+ let t = { onUpdate: (e) => {
3452
+ this.toolbar?.update(e.state), this.statusbar?.update(e.state, {
3453
+ docChanged: e.docChanged,
3454
+ selectionSet: e.selectionSet
3455
+ }), this.preview?.update(e.state), e.docChanged && this.autosave.schedule();
3456
+ } }, n = e.uploadImage?.enabled === !0, r = n ? [yi, Ai((e) => this.uploader?.uploadFiles(e))] : [];
3457
+ this.handle = rn(e, t, [D.of(this.translator), ...r]), this.codemirror = this.handle.view, this.editorMode = this.handle.resolved.editorMode;
3458
+ let i = !n && Array.isArray(e.toolbar) ? e.toolbar.filter((e) => e !== "upload-image") : e.toolbar;
3459
+ this.toolbar = bn(this.codemirror, i, this, this.translator), this.statusbar = En(e.status, this.translator), this.autosave = gi(e.autosave ?? {
3460
+ enabled: !1,
3461
+ key: ""
3462
+ }, {
3463
+ getValue: () => this.getValue(),
3464
+ setValue: (e) => this.setValue(e),
3465
+ onSaved: (e) => {
3466
+ this.statusbar?.setItem("autosave", this.translator.t("status.autosaved", { time: this.translator.formatTime(e) }));
3467
+ }
3468
+ }), n && e.uploadImage && (typeof e.uploadImage.upload == "function" ? (this.uploader = Oi(this.codemirror, e.uploadImage, { setStatus: (e) => this.statusbar?.setItem("upload-image", e) }, this.translator), !(Array.isArray(e.status) && e.status.includes("upload-image")) && !e.uploadImage.onError && console.warn("SupaMDE: uploadImage is enabled, but neither the status bar item 'upload-image' (status option) nor uploadImage.onError is set — upload progress and errors stay invisible."), this.statusbar?.setItem("upload-image", this.translator.t("upload.statusInit"))) : console.warn("SupaMDE: uploadImage.enabled is true, but uploadImage.upload is not a function — image upload stays off.")), this.renderOpts = di(e), this.preview = Dn(this.codemirror, {
3469
+ render: (e) => fi(e, this.renderOpts),
3470
+ previewClass: e.previewClass,
3471
+ syncScroll: e.syncSideBySidePreviewScroll
3472
+ }), this.container = document.createElement("div"), this.container.className = "supamde-container";
3473
+ let a = this.codemirror.dom;
3474
+ a.parentNode?.insertBefore(this.container, a), this.toolbar && this.container.appendChild(this.toolbar.dom), this.editorRow = document.createElement("div"), this.editorRow.className = "supamde-editor-row", this.editorRow.appendChild(a), this.editorRow.appendChild(this.preview.dom), this.container.appendChild(this.editorRow), this.statusbar && this.container.appendChild(this.statusbar.dom), this.fullscreen = kn(this.container, { onToggleFullScreen: (t) => {
3475
+ this.toolbar?.update(this.codemirror.state), e.onToggleFullScreen?.(t);
3476
+ } }), this.onViewShortcuts = (e) => {
3477
+ e.key === "F8" ? (e.preventDefault(), this.togglePreviewFullScreen()) : e.key === "F9" ? (e.preventDefault(), this.toggleSideBySide()) : e.key === "F10" ? (e.preventDefault(), this.toggleEditorMode()) : (e.key === "F11" || (e.metaKey || e.ctrlKey) && e.shiftKey && !e.altKey && (e.key === "F" || e.key === "f")) && (e.preventDefault(), this.toggleFullScreen());
3478
+ }, this.container.addEventListener("keydown", this.onViewShortcuts);
3479
+ let o = this.codemirror.state;
3480
+ this.toolbar?.update(o), this.statusbar?.update(o, {
3481
+ docChanged: !0,
3482
+ selectionSet: !0
3483
+ }), this.autosave.start();
3484
+ }
3485
+ value(e) {
3486
+ if (e === void 0) return this.getValue();
3487
+ this.setValue(e);
3488
+ }
3489
+ getValue() {
3490
+ return an(this.codemirror);
3491
+ }
3492
+ setValue(e) {
3493
+ on(this.codemirror, e);
3494
+ }
3495
+ updateStatusBar(e, t) {
3496
+ this.statusbar?.setItem(e, t);
3497
+ }
3498
+ markdown(e) {
3499
+ return fi(e, this.renderOpts);
3500
+ }
3501
+ setSideBySide(e) {
3502
+ this.preview?.set(e), this.container.classList.toggle("supamde-sided", this.isSideBySideActive()), this.toolbar?.update(this.codemirror.state);
3503
+ }
3504
+ toggleSideBySide() {
3505
+ this.setSideBySide(!this.isSideBySideActive());
3506
+ }
3507
+ isSideBySideActive() {
3508
+ return this.preview?.isActive() ?? !1;
3509
+ }
3510
+ setFullScreen(e) {
3511
+ this.fullscreen.set(e), this.toolbar?.update(this.codemirror.state);
3512
+ }
3513
+ toggleFullScreen() {
3514
+ this.setFullScreen(!this.isFullscreenActive());
3515
+ }
3516
+ isFullscreenActive() {
3517
+ return this.fullscreen.isActive();
3518
+ }
3519
+ togglePreviewFullScreen() {
3520
+ let e = !this.isPreviewFullScreenActive();
3521
+ this.setSideBySide(e), this.setFullScreen(e);
3522
+ }
3523
+ isPreviewFullScreenActive() {
3524
+ return this.isSideBySideActive() && this.isFullscreenActive();
3525
+ }
3526
+ getEditorMode() {
3527
+ return this.editorMode;
3528
+ }
3529
+ setEditorMode(e) {
3530
+ e !== this.editorMode && (this.editorMode = e, this.codemirror.dispatch({ effects: Ee.reconfigure(De(e)) }), this.toolbar?.update(this.codemirror.state));
3531
+ }
3532
+ toggleEditorMode() {
3533
+ this.setEditorMode(this.editorMode === "live" ? "source" : "live");
3534
+ }
3535
+ async clearAutosavedValue() {
3536
+ await this.autosave.clear(), this.statusbar?.setItem("autosave", "");
3537
+ }
3538
+ isAutosaveActive() {
3539
+ return this.autosave.isActive();
3540
+ }
3541
+ uploadImages(e) {
3542
+ this.uploader?.uploadFiles(e);
3543
+ }
3544
+ openBrowseFileWindow() {
3545
+ this.uploader && ji(this.uploader.accept(), (e) => this.uploader?.uploadFiles(e));
3546
+ }
3547
+ toTextArea() {
3548
+ this.autosave.stop(), this.uploader?.destroy(), this.container.removeEventListener("keydown", this.onViewShortcuts), this.toolbar?.destroy(), this.statusbar?.destroy(), this.preview?.destroy(), this.fullscreen.destroy();
3549
+ let e = this.handle.toTextArea();
3550
+ return this.container.remove(), e;
3551
+ }
3552
+ };
3553
+ //#endregion
3554
+ export { Ni as SupaMDE, Ni as default, me as VERSION, Mi as de, w as en };
3555
+
3556
+ //# sourceMappingURL=supamde.mjs.map