@arach/arc 0.4.5 → 0.6.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.
@@ -0,0 +1,1925 @@
1
+ import { EditorSelection as P, countColumn as z, Prec as st, EditorState as it } from "./index-CI-w1U9t.js";
2
+ import { E as ot, k as at } from "./index-CnGsbmkP.js";
3
+ import { Language as lt, defineLanguageFacet as ht, syntaxTree as X, foldService as ft, LanguageSupport as fe, indentUnit as ut, foldNodeProp as Ee, indentNodeProp as dt, languageDataProp as pt, LanguageDescription as ue, ParseContext as ct } from "./index-DBTOQDAV.js";
4
+ import { C as mt } from "./index-Ds2bIH9V.js";
5
+ import { P as gt, a as Q, N as v, T as kt, b as Ie, s as Me, p as Lt, t as m, c as H } from "./index-CvsZLy9v.js";
6
+ import { html as bt, htmlCompletionSource as wt } from "./index-Cg52_-j6.js";
7
+ class _ {
8
+ static create(e, r, n, s, i) {
9
+ let o = s + (s << 8) + e + (r << 4) | 0;
10
+ return new _(e, r, n, o, i, [], []);
11
+ }
12
+ constructor(e, r, n, s, i, o, a) {
13
+ this.type = e, this.value = r, this.from = n, this.hash = s, this.end = i, this.children = o, this.positions = a, this.hashProp = [[v.contextHash, s]];
14
+ }
15
+ addChild(e, r) {
16
+ e.prop(v.contextHash) != this.hash && (e = new H(e.type, e.children, e.positions, e.length, this.hashProp)), this.children.push(e), this.positions.push(r);
17
+ }
18
+ toTree(e, r = this.end) {
19
+ let n = this.children.length - 1;
20
+ return n >= 0 && (r = Math.max(r, this.positions[n] + this.children[n].length + this.from)), new H(e.types[this.type], this.children, this.positions, r - this.from).balance({
21
+ makeTree: (s, i, o) => new H(Q.none, s, i, o, this.hashProp)
22
+ });
23
+ }
24
+ }
25
+ var u;
26
+ (function(t) {
27
+ t[t.Document = 1] = "Document", t[t.CodeBlock = 2] = "CodeBlock", t[t.FencedCode = 3] = "FencedCode", t[t.Blockquote = 4] = "Blockquote", t[t.HorizontalRule = 5] = "HorizontalRule", t[t.BulletList = 6] = "BulletList", t[t.OrderedList = 7] = "OrderedList", t[t.ListItem = 8] = "ListItem", t[t.ATXHeading1 = 9] = "ATXHeading1", t[t.ATXHeading2 = 10] = "ATXHeading2", t[t.ATXHeading3 = 11] = "ATXHeading3", t[t.ATXHeading4 = 12] = "ATXHeading4", t[t.ATXHeading5 = 13] = "ATXHeading5", t[t.ATXHeading6 = 14] = "ATXHeading6", t[t.SetextHeading1 = 15] = "SetextHeading1", t[t.SetextHeading2 = 16] = "SetextHeading2", t[t.HTMLBlock = 17] = "HTMLBlock", t[t.LinkReference = 18] = "LinkReference", t[t.Paragraph = 19] = "Paragraph", t[t.CommentBlock = 20] = "CommentBlock", t[t.ProcessingInstructionBlock = 21] = "ProcessingInstructionBlock", t[t.Escape = 22] = "Escape", t[t.Entity = 23] = "Entity", t[t.HardBreak = 24] = "HardBreak", t[t.Emphasis = 25] = "Emphasis", t[t.StrongEmphasis = 26] = "StrongEmphasis", t[t.Link = 27] = "Link", t[t.Image = 28] = "Image", t[t.InlineCode = 29] = "InlineCode", t[t.HTMLTag = 30] = "HTMLTag", t[t.Comment = 31] = "Comment", t[t.ProcessingInstruction = 32] = "ProcessingInstruction", t[t.Autolink = 33] = "Autolink", t[t.HeaderMark = 34] = "HeaderMark", t[t.QuoteMark = 35] = "QuoteMark", t[t.ListMark = 36] = "ListMark", t[t.LinkMark = 37] = "LinkMark", t[t.EmphasisMark = 38] = "EmphasisMark", t[t.CodeMark = 39] = "CodeMark", t[t.CodeText = 40] = "CodeText", t[t.CodeInfo = 41] = "CodeInfo", t[t.LinkTitle = 42] = "LinkTitle", t[t.LinkLabel = 43] = "LinkLabel", t[t.URL = 44] = "URL";
28
+ })(u || (u = {}));
29
+ class St {
30
+ /**
31
+ @internal
32
+ */
33
+ constructor(e, r) {
34
+ this.start = e, this.content = r, this.marks = [], this.parsers = [];
35
+ }
36
+ }
37
+ class Ct {
38
+ constructor() {
39
+ this.text = "", this.baseIndent = 0, this.basePos = 0, this.depth = 0, this.markers = [], this.pos = 0, this.indent = 0, this.next = -1;
40
+ }
41
+ /**
42
+ @internal
43
+ */
44
+ forward() {
45
+ this.basePos > this.pos && this.forwardInner();
46
+ }
47
+ /**
48
+ @internal
49
+ */
50
+ forwardInner() {
51
+ let e = this.skipSpace(this.basePos);
52
+ this.indent = this.countIndent(e, this.pos, this.indent), this.pos = e, this.next = e == this.text.length ? -1 : this.text.charCodeAt(e);
53
+ }
54
+ /**
55
+ Skip whitespace after the given position, return the position of
56
+ the next non-space character or the end of the line if there's
57
+ only space after `from`.
58
+ */
59
+ skipSpace(e) {
60
+ return O(this.text, e);
61
+ }
62
+ /**
63
+ @internal
64
+ */
65
+ reset(e) {
66
+ for (this.text = e, this.baseIndent = this.basePos = this.pos = this.indent = 0, this.forwardInner(), this.depth = 1; this.markers.length; )
67
+ this.markers.pop();
68
+ }
69
+ /**
70
+ Move the line's base position forward to the given position.
71
+ This should only be called by composite [block
72
+ parsers](#BlockParser.parse) or [markup skipping
73
+ functions](#NodeSpec.composite).
74
+ */
75
+ moveBase(e) {
76
+ this.basePos = e, this.baseIndent = this.countIndent(e, this.pos, this.indent);
77
+ }
78
+ /**
79
+ Move the line's base position forward to the given _column_.
80
+ */
81
+ moveBaseColumn(e) {
82
+ this.baseIndent = e, this.basePos = this.findColumn(e);
83
+ }
84
+ /**
85
+ Store a composite-block-level marker. Should be called from
86
+ [markup skipping functions](#NodeSpec.composite) when they
87
+ consume any non-whitespace characters.
88
+ */
89
+ addMarker(e) {
90
+ this.markers.push(e);
91
+ }
92
+ /**
93
+ Find the column position at `to`, optionally starting at a given
94
+ position and column.
95
+ */
96
+ countIndent(e, r = 0, n = 0) {
97
+ for (let s = r; s < e; s++)
98
+ n += this.text.charCodeAt(s) == 9 ? 4 - n % 4 : 1;
99
+ return n;
100
+ }
101
+ /**
102
+ Find the position corresponding to the given column.
103
+ */
104
+ findColumn(e) {
105
+ let r = 0;
106
+ for (let n = 0; r < this.text.length && n < e; r++)
107
+ n += this.text.charCodeAt(r) == 9 ? 4 - n % 4 : 1;
108
+ return r;
109
+ }
110
+ /**
111
+ @internal
112
+ */
113
+ scrub() {
114
+ if (!this.baseIndent)
115
+ return this.text;
116
+ let e = "";
117
+ for (let r = 0; r < this.basePos; r++)
118
+ e += " ";
119
+ return e + this.text.slice(this.basePos);
120
+ }
121
+ }
122
+ function de(t, e, r) {
123
+ if (r.pos == r.text.length || t != e.block && r.indent >= e.stack[r.depth + 1].value + r.baseIndent)
124
+ return !0;
125
+ if (r.indent >= r.baseIndent + 4)
126
+ return !1;
127
+ let n = (t.type == u.OrderedList ? oe : ie)(r, e, !1);
128
+ return n > 0 && (t.type != u.BulletList || se(r, e, !1) < 0) && r.text.charCodeAt(r.pos + n - 1) == t.value;
129
+ }
130
+ const He = {
131
+ [u.Blockquote](t, e, r) {
132
+ return r.next != 62 ? !1 : (r.markers.push(k(u.QuoteMark, e.lineStart + r.pos, e.lineStart + r.pos + 1)), r.moveBase(r.pos + (x(r.text.charCodeAt(r.pos + 1)) ? 2 : 1)), t.end = e.lineStart + r.text.length, !0);
133
+ },
134
+ [u.ListItem](t, e, r) {
135
+ return r.indent < r.baseIndent + t.value && r.next > -1 ? !1 : (r.moveBaseColumn(r.baseIndent + t.value), !0);
136
+ },
137
+ [u.OrderedList]: de,
138
+ [u.BulletList]: de,
139
+ [u.Document]() {
140
+ return !0;
141
+ }
142
+ };
143
+ function x(t) {
144
+ return t == 32 || t == 9 || t == 10 || t == 13;
145
+ }
146
+ function O(t, e = 0) {
147
+ for (; e < t.length && x(t.charCodeAt(e)); )
148
+ e++;
149
+ return e;
150
+ }
151
+ function pe(t, e, r) {
152
+ for (; e > r && x(t.charCodeAt(e - 1)); )
153
+ e--;
154
+ return e;
155
+ }
156
+ function Pe(t) {
157
+ if (t.next != 96 && t.next != 126)
158
+ return -1;
159
+ let e = t.pos + 1;
160
+ for (; e < t.text.length && t.text.charCodeAt(e) == t.next; )
161
+ e++;
162
+ if (e < t.pos + 3)
163
+ return -1;
164
+ if (t.next == 96) {
165
+ for (let r = e; r < t.text.length; r++)
166
+ if (t.text.charCodeAt(r) == 96)
167
+ return -1;
168
+ }
169
+ return e;
170
+ }
171
+ function ve(t) {
172
+ return t.next != 62 ? -1 : t.text.charCodeAt(t.pos + 1) == 32 ? 2 : 1;
173
+ }
174
+ function se(t, e, r) {
175
+ if (t.next != 42 && t.next != 45 && t.next != 95)
176
+ return -1;
177
+ let n = 1;
178
+ for (let s = t.pos + 1; s < t.text.length; s++) {
179
+ let i = t.text.charCodeAt(s);
180
+ if (i == t.next)
181
+ n++;
182
+ else if (!x(i))
183
+ return -1;
184
+ }
185
+ return r && t.next == 45 && Re(t) > -1 && t.depth == e.stack.length && e.parser.leafBlockParsers.indexOf(De.SetextHeading) > -1 || n < 3 ? -1 : 1;
186
+ }
187
+ function Ne(t, e) {
188
+ for (let r = t.stack.length - 1; r >= 0; r--)
189
+ if (t.stack[r].type == e)
190
+ return !0;
191
+ return !1;
192
+ }
193
+ function ie(t, e, r) {
194
+ return (t.next == 45 || t.next == 43 || t.next == 42) && (t.pos == t.text.length - 1 || x(t.text.charCodeAt(t.pos + 1))) && (!r || Ne(e, u.BulletList) || t.skipSpace(t.pos + 2) < t.text.length) ? 1 : -1;
195
+ }
196
+ function oe(t, e, r) {
197
+ let n = t.pos, s = t.next;
198
+ for (; s >= 48 && s <= 57; ) {
199
+ n++;
200
+ if (n == t.text.length)
201
+ return -1;
202
+ s = t.text.charCodeAt(n);
203
+ }
204
+ return n == t.pos || n > t.pos + 9 || s != 46 && s != 41 || n < t.text.length - 1 && !x(t.text.charCodeAt(n + 1)) || r && !Ne(e, u.OrderedList) && (t.skipSpace(n + 1) == t.text.length || n > t.pos + 1 || t.next != 49) ? -1 : n + 1 - t.pos;
205
+ }
206
+ function ye(t) {
207
+ if (t.next != 35)
208
+ return -1;
209
+ let e = t.pos + 1;
210
+ for (; e < t.text.length && t.text.charCodeAt(e) == 35; )
211
+ e++;
212
+ if (e < t.text.length && t.text.charCodeAt(e) != 32)
213
+ return -1;
214
+ let r = e - t.pos;
215
+ return r > 6 ? -1 : r;
216
+ }
217
+ function Re(t) {
218
+ if (t.next != 45 && t.next != 61 || t.indent >= t.baseIndent + 4)
219
+ return -1;
220
+ let e = t.pos + 1;
221
+ for (; e < t.text.length && t.text.charCodeAt(e) == t.next; )
222
+ e++;
223
+ let r = e;
224
+ for (; e < t.text.length && x(t.text.charCodeAt(e)); )
225
+ e++;
226
+ return e == t.text.length ? r : -1;
227
+ }
228
+ const W = /^[ \t]*$/, Oe = /-->/, Te = /\?>/, ee = [
229
+ [/^<(?:script|pre|style)(?:\s|>|$)/i, /<\/(?:script|pre|style)>/i],
230
+ [/^\s*<!--/, Oe],
231
+ [/^\s*<\?/, Te],
232
+ [/^\s*<![A-Z]/, />/],
233
+ [/^\s*<!\[CDATA\[/, /\]\]>/],
234
+ [/^\s*<\/?(?: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|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i, W],
235
+ [/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i, W]
236
+ ];
237
+ function ze(t, e, r) {
238
+ if (t.next != 60)
239
+ return -1;
240
+ let n = t.text.slice(t.pos);
241
+ for (let s = 0, i = ee.length - (r ? 1 : 0); s < i; s++)
242
+ if (ee[s][0].test(n))
243
+ return s;
244
+ return -1;
245
+ }
246
+ function ce(t, e) {
247
+ let r = t.countIndent(e, t.pos, t.indent), n = t.skipSpace(e), s = t.countIndent(n, e, r);
248
+ return s >= r + 5 || n == t.text.length ? r + 1 : s;
249
+ }
250
+ function A(t, e, r) {
251
+ let n = t.length - 1;
252
+ n >= 0 && t[n].to == e && t[n].type == u.CodeText ? t[n].to = r : t.push(k(u.CodeText, e, r));
253
+ }
254
+ const $ = {
255
+ LinkReference: void 0,
256
+ IndentedCode(t, e) {
257
+ let r = e.baseIndent + 4;
258
+ if (e.indent < r)
259
+ return !1;
260
+ let n = e.findColumn(r), s = t.lineStart + n, i = t.lineStart + e.text.length, o = [], a = [];
261
+ for (A(o, s, i); t.nextLine() && e.depth >= t.stack.length; )
262
+ if (e.pos == e.text.length) {
263
+ A(a, t.lineStart - 1, t.lineStart);
264
+ for (let l of e.markers)
265
+ a.push(l);
266
+ } else {
267
+ if (e.indent < r)
268
+ break;
269
+ {
270
+ if (a.length) {
271
+ for (let h of a)
272
+ h.type == u.CodeText ? A(o, h.from, h.to) : o.push(h);
273
+ a = [];
274
+ }
275
+ A(o, t.lineStart - 1, t.lineStart);
276
+ for (let h of e.markers)
277
+ o.push(h);
278
+ i = t.lineStart + e.text.length;
279
+ let l = t.lineStart + e.findColumn(e.baseIndent + 4);
280
+ l < i && A(o, l, i);
281
+ }
282
+ }
283
+ return a.length && (a = a.filter((l) => l.type != u.CodeText), a.length && (e.markers = a.concat(e.markers))), t.addNode(t.buffer.writeElements(o, -s).finish(u.CodeBlock, i - s), s), !0;
284
+ },
285
+ FencedCode(t, e) {
286
+ let r = Pe(e);
287
+ if (r < 0)
288
+ return !1;
289
+ let n = t.lineStart + e.pos, s = e.next, i = r - e.pos, o = e.skipSpace(r), a = pe(e.text, e.text.length, o), l = [k(u.CodeMark, n, n + i)];
290
+ o < a && l.push(k(u.CodeInfo, t.lineStart + o, t.lineStart + a));
291
+ for (let h = !0, f = !0, p = !1; t.nextLine() && e.depth >= t.stack.length; h = !1) {
292
+ let d = e.pos;
293
+ if (e.indent - e.baseIndent < 4)
294
+ for (; d < e.text.length && e.text.charCodeAt(d) == s; )
295
+ d++;
296
+ if (d - e.pos >= i && e.skipSpace(d) == e.text.length) {
297
+ for (let c of e.markers)
298
+ l.push(c);
299
+ f && p && A(l, t.lineStart - 1, t.lineStart), l.push(k(u.CodeMark, t.lineStart + e.pos, t.lineStart + d)), t.nextLine();
300
+ break;
301
+ } else {
302
+ p = !0, h || (A(l, t.lineStart - 1, t.lineStart), f = !1);
303
+ for (let g of e.markers)
304
+ l.push(g);
305
+ let c = t.lineStart + e.basePos, L = t.lineStart + e.text.length;
306
+ c < L && (A(l, c, L), f = !1);
307
+ }
308
+ }
309
+ return t.addNode(t.buffer.writeElements(l, -n).finish(u.FencedCode, t.prevLineEnd() - n), n), !0;
310
+ },
311
+ Blockquote(t, e) {
312
+ let r = ve(e);
313
+ return r < 0 ? !1 : (t.startContext(u.Blockquote, e.pos), t.addNode(u.QuoteMark, t.lineStart + e.pos, t.lineStart + e.pos + 1), e.moveBase(e.pos + r), null);
314
+ },
315
+ HorizontalRule(t, e) {
316
+ if (se(e, t, !1) < 0)
317
+ return !1;
318
+ let r = t.lineStart + e.pos;
319
+ return t.nextLine(), t.addNode(u.HorizontalRule, r), !0;
320
+ },
321
+ BulletList(t, e) {
322
+ let r = ie(e, t, !1);
323
+ if (r < 0)
324
+ return !1;
325
+ t.block.type != u.BulletList && t.startContext(u.BulletList, e.basePos, e.next);
326
+ let n = ce(e, e.pos + 1);
327
+ return t.startContext(u.ListItem, e.basePos, n - e.baseIndent), t.addNode(u.ListMark, t.lineStart + e.pos, t.lineStart + e.pos + r), e.moveBaseColumn(n), null;
328
+ },
329
+ OrderedList(t, e) {
330
+ let r = oe(e, t, !1);
331
+ if (r < 0)
332
+ return !1;
333
+ t.block.type != u.OrderedList && t.startContext(u.OrderedList, e.basePos, e.text.charCodeAt(e.pos + r - 1));
334
+ let n = ce(e, e.pos + r);
335
+ return t.startContext(u.ListItem, e.basePos, n - e.baseIndent), t.addNode(u.ListMark, t.lineStart + e.pos, t.lineStart + e.pos + r), e.moveBaseColumn(n), null;
336
+ },
337
+ ATXHeading(t, e) {
338
+ let r = ye(e);
339
+ if (r < 0)
340
+ return !1;
341
+ let n = e.pos, s = t.lineStart + n, i = pe(e.text, e.text.length, n), o = i;
342
+ for (; o > n && e.text.charCodeAt(o - 1) == e.next; )
343
+ o--;
344
+ (o == i || o == n || !x(e.text.charCodeAt(o - 1))) && (o = e.text.length);
345
+ let a = t.buffer.write(u.HeaderMark, 0, r).writeElements(t.parser.parseInline(e.text.slice(n + r + 1, o), s + r + 1), -s);
346
+ o < e.text.length && a.write(u.HeaderMark, o - n, i - n);
347
+ let l = a.finish(u.ATXHeading1 - 1 + r, e.text.length - n);
348
+ return t.nextLine(), t.addNode(l, s), !0;
349
+ },
350
+ HTMLBlock(t, e) {
351
+ let r = ze(e, t, !1);
352
+ if (r < 0)
353
+ return !1;
354
+ let n = t.lineStart + e.pos, s = ee[r][1], i = [], o = s != W;
355
+ for (; !s.test(e.text) && t.nextLine(); ) {
356
+ if (e.depth < t.stack.length) {
357
+ o = !1;
358
+ break;
359
+ }
360
+ for (let h of e.markers)
361
+ i.push(h);
362
+ }
363
+ o && t.nextLine();
364
+ let a = s == Oe ? u.CommentBlock : s == Te ? u.ProcessingInstructionBlock : u.HTMLBlock, l = t.prevLineEnd();
365
+ return t.addNode(t.buffer.writeElements(i, -n).finish(a, l - n), n), !0;
366
+ },
367
+ SetextHeading: void 0
368
+ // Specifies relative precedence for block-continue function
369
+ };
370
+ class xt {
371
+ constructor(e) {
372
+ this.stage = 0, this.elts = [], this.pos = 0, this.start = e.start, this.advance(e.content);
373
+ }
374
+ nextLine(e, r, n) {
375
+ if (this.stage == -1)
376
+ return !1;
377
+ let s = n.content + `
378
+ ` + r.scrub(), i = this.advance(s);
379
+ return i > -1 && i < s.length ? this.complete(e, n, i) : !1;
380
+ }
381
+ finish(e, r) {
382
+ return (this.stage == 2 || this.stage == 3) && O(r.content, this.pos) == r.content.length ? this.complete(e, r, r.content.length) : !1;
383
+ }
384
+ complete(e, r, n) {
385
+ return e.addLeafElement(r, k(u.LinkReference, this.start, this.start + n, this.elts)), !0;
386
+ }
387
+ nextStage(e) {
388
+ return e ? (this.pos = e.to - this.start, this.elts.push(e), this.stage++, !0) : (e === !1 && (this.stage = -1), !1);
389
+ }
390
+ advance(e) {
391
+ for (; ; ) {
392
+ if (this.stage == -1)
393
+ return -1;
394
+ if (this.stage == 0) {
395
+ if (!this.nextStage(Ze(e, this.pos, this.start, !0)))
396
+ return -1;
397
+ if (e.charCodeAt(this.pos) != 58)
398
+ return this.stage = -1;
399
+ this.elts.push(k(u.LinkMark, this.pos + this.start, this.pos + this.start + 1)), this.pos++;
400
+ } else if (this.stage == 1) {
401
+ if (!this.nextStage(qe(e, O(e, this.pos), this.start)))
402
+ return -1;
403
+ } else if (this.stage == 2) {
404
+ let r = O(e, this.pos), n = 0;
405
+ if (r > this.pos) {
406
+ let s = Qe(e, r, this.start);
407
+ if (s) {
408
+ let i = V(e, s.to - this.start);
409
+ i > 0 && (this.nextStage(s), n = i);
410
+ }
411
+ }
412
+ return n || (n = V(e, this.pos)), n > 0 && n < e.length ? n : -1;
413
+ } else
414
+ return V(e, this.pos);
415
+ }
416
+ }
417
+ }
418
+ function V(t, e) {
419
+ for (; e < t.length; e++) {
420
+ let r = t.charCodeAt(e);
421
+ if (r == 10)
422
+ break;
423
+ if (!x(r))
424
+ return -1;
425
+ }
426
+ return e;
427
+ }
428
+ class At {
429
+ nextLine(e, r, n) {
430
+ let s = r.depth < e.stack.length ? -1 : Re(r), i = r.next;
431
+ if (s < 0)
432
+ return !1;
433
+ let o = k(u.HeaderMark, e.lineStart + r.pos, e.lineStart + s);
434
+ return e.nextLine(), e.addLeafElement(n, k(i == 61 ? u.SetextHeading1 : u.SetextHeading2, n.start, e.prevLineEnd(), [
435
+ ...e.parser.parseInline(n.content, n.start),
436
+ o
437
+ ])), !0;
438
+ }
439
+ finish() {
440
+ return !1;
441
+ }
442
+ }
443
+ const De = {
444
+ LinkReference(t, e) {
445
+ return e.content.charCodeAt(0) == 91 ? new xt(e) : null;
446
+ },
447
+ SetextHeading() {
448
+ return new At();
449
+ }
450
+ }, Bt = [
451
+ (t, e) => ye(e) >= 0,
452
+ (t, e) => Pe(e) >= 0,
453
+ (t, e) => ve(e) >= 0,
454
+ (t, e) => ie(e, t, !0) >= 0,
455
+ (t, e) => oe(e, t, !0) >= 0,
456
+ (t, e) => se(e, t, !0) >= 0,
457
+ (t, e) => ze(e, t, !0) >= 0
458
+ ], Et = { text: "", end: 0 };
459
+ class It {
460
+ /**
461
+ @internal
462
+ */
463
+ constructor(e, r, n, s) {
464
+ this.parser = e, this.input = r, this.ranges = s, this.line = new Ct(), this.atEnd = !1, this.reusePlaceholders = /* @__PURE__ */ new Map(), this.stoppedAt = null, this.rangeI = 0, this.to = s[s.length - 1].to, this.lineStart = this.absoluteLineStart = this.absoluteLineEnd = s[0].from, this.block = _.create(u.Document, 0, this.lineStart, 0, 0), this.stack = [this.block], this.fragments = n.length ? new Pt(n, r) : null, this.readLine();
465
+ }
466
+ get parsedPos() {
467
+ return this.absoluteLineStart;
468
+ }
469
+ advance() {
470
+ if (this.stoppedAt != null && this.absoluteLineStart > this.stoppedAt)
471
+ return this.finish();
472
+ let { line: e } = this;
473
+ for (; ; ) {
474
+ for (let n = 0; ; ) {
475
+ let s = e.depth < this.stack.length ? this.stack[this.stack.length - 1] : null;
476
+ for (; n < e.markers.length && (!s || e.markers[n].from < s.end); ) {
477
+ let i = e.markers[n++];
478
+ this.addNode(i.type, i.from, i.to);
479
+ }
480
+ if (!s)
481
+ break;
482
+ this.finishContext();
483
+ }
484
+ if (e.pos < e.text.length)
485
+ break;
486
+ if (!this.nextLine())
487
+ return this.finish();
488
+ }
489
+ if (this.fragments && this.reuseFragment(e.basePos))
490
+ return null;
491
+ e: for (; ; ) {
492
+ for (let n of this.parser.blockParsers)
493
+ if (n) {
494
+ let s = n(this, e);
495
+ if (s != !1) {
496
+ if (s == !0)
497
+ return null;
498
+ e.forward();
499
+ continue e;
500
+ }
501
+ }
502
+ break;
503
+ }
504
+ if (e.pos == e.text.length)
505
+ return this.nextLine() ? null : this.finish();
506
+ let r = new St(this.lineStart + e.pos, e.text.slice(e.pos));
507
+ for (let n of this.parser.leafBlockParsers)
508
+ if (n) {
509
+ let s = n(this, r);
510
+ s && r.parsers.push(s);
511
+ }
512
+ e: for (; this.nextLine() && e.pos != e.text.length; ) {
513
+ if (e.indent < e.baseIndent + 4) {
514
+ for (let n of this.parser.endLeafBlock)
515
+ if (n(this, e, r))
516
+ break e;
517
+ }
518
+ for (let n of r.parsers)
519
+ if (n.nextLine(this, e, r))
520
+ return null;
521
+ r.content += `
522
+ ` + e.scrub();
523
+ for (let n of e.markers)
524
+ r.marks.push(n);
525
+ }
526
+ return this.finishLeaf(r), null;
527
+ }
528
+ stopAt(e) {
529
+ if (this.stoppedAt != null && this.stoppedAt < e)
530
+ throw new RangeError("Can't move stoppedAt forward");
531
+ this.stoppedAt = e;
532
+ }
533
+ reuseFragment(e) {
534
+ if (!this.fragments.moveTo(this.absoluteLineStart + e, this.absoluteLineStart) || !this.fragments.matches(this.block.hash))
535
+ return !1;
536
+ let r = this.fragments.takeNodes(this);
537
+ return r ? (this.absoluteLineStart += r, this.lineStart = Ve(this.absoluteLineStart, this.ranges), this.moveRangeI(), this.absoluteLineStart < this.to ? (this.lineStart++, this.absoluteLineStart++, this.readLine()) : (this.atEnd = !0, this.readLine()), !0) : !1;
538
+ }
539
+ /**
540
+ The number of parent blocks surrounding the current block.
541
+ */
542
+ get depth() {
543
+ return this.stack.length;
544
+ }
545
+ /**
546
+ Get the type of the parent block at the given depth. When no
547
+ depth is passed, return the type of the innermost parent.
548
+ */
549
+ parentType(e = this.depth - 1) {
550
+ return this.parser.nodeSet.types[this.stack[e].type];
551
+ }
552
+ /**
553
+ Move to the next input line. This should only be called by
554
+ (non-composite) [block parsers](#BlockParser.parse) that consume
555
+ the line directly, or leaf block parser
556
+ [`nextLine`](#LeafBlockParser.nextLine) methods when they
557
+ consume the current line (and return true).
558
+ */
559
+ nextLine() {
560
+ return this.lineStart += this.line.text.length, this.absoluteLineEnd >= this.to ? (this.absoluteLineStart = this.absoluteLineEnd, this.atEnd = !0, this.readLine(), !1) : (this.lineStart++, this.absoluteLineStart = this.absoluteLineEnd + 1, this.moveRangeI(), this.readLine(), !0);
561
+ }
562
+ /**
563
+ Retrieve the text of the line after the current one, without
564
+ actually moving the context's current line forward.
565
+ */
566
+ peekLine() {
567
+ return this.scanLine(this.absoluteLineEnd + 1).text;
568
+ }
569
+ moveRangeI() {
570
+ for (; this.rangeI < this.ranges.length - 1 && this.absoluteLineStart >= this.ranges[this.rangeI].to; )
571
+ this.rangeI++, this.absoluteLineStart = Math.max(this.absoluteLineStart, this.ranges[this.rangeI].from);
572
+ }
573
+ /**
574
+ @internal
575
+ Collect the text for the next line.
576
+ */
577
+ scanLine(e) {
578
+ let r = Et;
579
+ if (r.end = e, e >= this.to)
580
+ r.text = "";
581
+ else if (r.text = this.lineChunkAt(e), r.end += r.text.length, this.ranges.length > 1) {
582
+ let n = this.absoluteLineStart, s = this.rangeI;
583
+ for (; this.ranges[s].to < r.end; ) {
584
+ s++;
585
+ let i = this.ranges[s].from, o = this.lineChunkAt(i);
586
+ r.end = i + o.length, r.text = r.text.slice(0, this.ranges[s - 1].to - n) + o, n = r.end - r.text.length;
587
+ }
588
+ }
589
+ return r;
590
+ }
591
+ /**
592
+ @internal
593
+ Populate this.line with the content of the next line. Skip
594
+ leading characters covered by composite blocks.
595
+ */
596
+ readLine() {
597
+ let { line: e } = this, { text: r, end: n } = this.scanLine(this.absoluteLineStart);
598
+ for (this.absoluteLineEnd = n, e.reset(r); e.depth < this.stack.length; e.depth++) {
599
+ let s = this.stack[e.depth], i = this.parser.skipContextMarkup[s.type];
600
+ if (!i)
601
+ throw new Error("Unhandled block context " + u[s.type]);
602
+ let o = this.line.markers.length;
603
+ if (!i(s, this, e)) {
604
+ this.line.markers.length > o && (s.end = this.line.markers[this.line.markers.length - 1].to), e.forward();
605
+ break;
606
+ }
607
+ e.forward();
608
+ }
609
+ }
610
+ lineChunkAt(e) {
611
+ let r = this.input.chunk(e), n;
612
+ if (this.input.lineChunks)
613
+ n = r == `
614
+ ` ? "" : r;
615
+ else {
616
+ let s = r.indexOf(`
617
+ `);
618
+ n = s < 0 ? r : r.slice(0, s);
619
+ }
620
+ return e + n.length > this.to ? n.slice(0, this.to - e) : n;
621
+ }
622
+ /**
623
+ The end position of the previous line.
624
+ */
625
+ prevLineEnd() {
626
+ return this.atEnd ? this.lineStart : this.lineStart - 1;
627
+ }
628
+ /**
629
+ @internal
630
+ */
631
+ startContext(e, r, n = 0) {
632
+ this.block = _.create(e, n, this.lineStart + r, this.block.hash, this.lineStart + this.line.text.length), this.stack.push(this.block);
633
+ }
634
+ /**
635
+ Start a composite block. Should only be called from [block
636
+ parser functions](#BlockParser.parse) that return null.
637
+ */
638
+ startComposite(e, r, n = 0) {
639
+ this.startContext(this.parser.getNodeType(e), r, n);
640
+ }
641
+ /**
642
+ @internal
643
+ */
644
+ addNode(e, r, n) {
645
+ typeof e == "number" && (e = new H(this.parser.nodeSet.types[e], N, N, (n ?? this.prevLineEnd()) - r)), this.block.addChild(e, r - this.block.from);
646
+ }
647
+ /**
648
+ Add a block element. Can be called by [block
649
+ parsers](#BlockParser.parse).
650
+ */
651
+ addElement(e) {
652
+ this.block.addChild(e.toTree(this.parser.nodeSet), e.from - this.block.from);
653
+ }
654
+ /**
655
+ Add a block element from a [leaf parser](#LeafBlockParser). This
656
+ makes sure any extra composite block markup (such as blockquote
657
+ markers) inside the block are also added to the syntax tree.
658
+ */
659
+ addLeafElement(e, r) {
660
+ this.addNode(this.buffer.writeElements(re(r.children, e.marks), -r.from).finish(r.type, r.to - r.from), r.from);
661
+ }
662
+ /**
663
+ @internal
664
+ */
665
+ finishContext() {
666
+ let e = this.stack.pop(), r = this.stack[this.stack.length - 1];
667
+ r.addChild(e.toTree(this.parser.nodeSet), e.from - r.from), this.block = r;
668
+ }
669
+ finish() {
670
+ for (; this.stack.length > 1; )
671
+ this.finishContext();
672
+ return this.addGaps(this.block.toTree(this.parser.nodeSet, this.lineStart));
673
+ }
674
+ addGaps(e) {
675
+ return this.ranges.length > 1 ? Fe(this.ranges, 0, e.topNode, this.ranges[0].from, this.reusePlaceholders) : e;
676
+ }
677
+ /**
678
+ @internal
679
+ */
680
+ finishLeaf(e) {
681
+ for (let n of e.parsers)
682
+ if (n.finish(this, e))
683
+ return;
684
+ let r = re(this.parser.parseInline(e.content, e.start), e.marks);
685
+ this.addNode(this.buffer.writeElements(r, -e.start).finish(u.Paragraph, e.content.length), e.start);
686
+ }
687
+ elt(e, r, n, s) {
688
+ return typeof e == "string" ? k(this.parser.getNodeType(e), r, n, s) : new Ue(e, r);
689
+ }
690
+ /**
691
+ @internal
692
+ */
693
+ get buffer() {
694
+ return new $e(this.parser.nodeSet);
695
+ }
696
+ }
697
+ function Fe(t, e, r, n, s) {
698
+ let i = t[e].to, o = [], a = [], l = r.from + n;
699
+ function h(f, p) {
700
+ for (; p ? f >= i : f > i; ) {
701
+ let d = t[e + 1].from - i;
702
+ n += d, f += d, e++, i = t[e].to;
703
+ }
704
+ }
705
+ for (let f = r.firstChild; f; f = f.nextSibling) {
706
+ h(f.from + n, !0);
707
+ let p = f.from + n, d, c = s.get(f.tree);
708
+ c ? d = c : f.to + n > i ? (d = Fe(t, e, f, n, s), h(f.to + n, !1)) : d = f.toTree(), o.push(d), a.push(p - l);
709
+ }
710
+ return h(r.to + n, !1), new H(r.type, o, a, r.to + n - l, r.tree ? r.tree.propValues : void 0);
711
+ }
712
+ class Z extends gt {
713
+ /**
714
+ @internal
715
+ */
716
+ constructor(e, r, n, s, i, o, a, l, h) {
717
+ super(), this.nodeSet = e, this.blockParsers = r, this.leafBlockParsers = n, this.blockNames = s, this.endLeafBlock = i, this.skipContextMarkup = o, this.inlineParsers = a, this.inlineNames = l, this.wrappers = h, this.nodeTypes = /* @__PURE__ */ Object.create(null);
718
+ for (let f of e.types)
719
+ this.nodeTypes[f.name] = f.id;
720
+ }
721
+ createParse(e, r, n) {
722
+ let s = new It(this, e, r, n);
723
+ for (let i of this.wrappers)
724
+ s = i(s, e, r, n);
725
+ return s;
726
+ }
727
+ /**
728
+ Reconfigure the parser.
729
+ */
730
+ configure(e) {
731
+ let r = te(e);
732
+ if (!r)
733
+ return this;
734
+ let { nodeSet: n, skipContextMarkup: s } = this, i = this.blockParsers.slice(), o = this.leafBlockParsers.slice(), a = this.blockNames.slice(), l = this.inlineParsers.slice(), h = this.inlineNames.slice(), f = this.endLeafBlock.slice(), p = this.wrappers;
735
+ if (R(r.defineNodes)) {
736
+ s = Object.assign({}, s);
737
+ let d = n.types.slice(), c;
738
+ for (let L of r.defineNodes) {
739
+ let { name: g, block: B, composite: w, style: S } = typeof L == "string" ? { name: L } : L;
740
+ if (d.some((I) => I.name == g))
741
+ continue;
742
+ w && (s[d.length] = (I, y, nt) => w(y, nt, I.value));
743
+ let b = d.length, E = w ? ["Block", "BlockContext"] : B ? b >= u.ATXHeading1 && b <= u.SetextHeading2 ? ["Block", "LeafBlock", "Heading"] : ["Block", "LeafBlock"] : void 0;
744
+ d.push(Q.define({
745
+ id: b,
746
+ name: g,
747
+ props: E && [[v.group, E]]
748
+ })), S && (c || (c = {}), Array.isArray(S) || S instanceof kt ? c[g] = S : Object.assign(c, S));
749
+ }
750
+ n = new Ie(d), c && (n = n.extend(Me(c)));
751
+ }
752
+ if (R(r.props) && (n = n.extend(...r.props)), R(r.remove))
753
+ for (let d of r.remove) {
754
+ let c = this.blockNames.indexOf(d), L = this.inlineNames.indexOf(d);
755
+ c > -1 && (i[c] = o[c] = void 0), L > -1 && (l[L] = void 0);
756
+ }
757
+ if (R(r.parseBlock))
758
+ for (let d of r.parseBlock) {
759
+ let c = a.indexOf(d.name);
760
+ if (c > -1)
761
+ i[c] = d.parse, o[c] = d.leaf;
762
+ else {
763
+ let L = d.before ? U(a, d.before) : d.after ? U(a, d.after) + 1 : a.length - 1;
764
+ i.splice(L, 0, d.parse), o.splice(L, 0, d.leaf), a.splice(L, 0, d.name);
765
+ }
766
+ d.endLeaf && f.push(d.endLeaf);
767
+ }
768
+ if (R(r.parseInline))
769
+ for (let d of r.parseInline) {
770
+ let c = h.indexOf(d.name);
771
+ if (c > -1)
772
+ l[c] = d.parse;
773
+ else {
774
+ let L = d.before ? U(h, d.before) : d.after ? U(h, d.after) + 1 : h.length - 1;
775
+ l.splice(L, 0, d.parse), h.splice(L, 0, d.name);
776
+ }
777
+ }
778
+ return r.wrap && (p = p.concat(r.wrap)), new Z(n, i, o, a, f, s, l, h, p);
779
+ }
780
+ /**
781
+ @internal
782
+ */
783
+ getNodeType(e) {
784
+ let r = this.nodeTypes[e];
785
+ if (r == null)
786
+ throw new RangeError(`Unknown node type '${e}'`);
787
+ return r;
788
+ }
789
+ /**
790
+ Parse the given piece of inline text at the given offset,
791
+ returning an array of [`Element`](#Element) objects representing
792
+ the inline content.
793
+ */
794
+ parseInline(e, r) {
795
+ let n = new ae(this, e, r);
796
+ e: for (let s = r; s < n.end; ) {
797
+ let i = n.char(s);
798
+ for (let o of this.inlineParsers)
799
+ if (o) {
800
+ let a = o(n, i, s);
801
+ if (a >= 0) {
802
+ s = a;
803
+ continue e;
804
+ }
805
+ }
806
+ s++;
807
+ }
808
+ return n.resolveMarkers(0);
809
+ }
810
+ }
811
+ function R(t) {
812
+ return t != null && t.length > 0;
813
+ }
814
+ function te(t) {
815
+ if (!Array.isArray(t))
816
+ return t;
817
+ if (t.length == 0)
818
+ return null;
819
+ let e = te(t[0]);
820
+ if (t.length == 1)
821
+ return e;
822
+ let r = te(t.slice(1));
823
+ if (!r || !e)
824
+ return e || r;
825
+ let n = (o, a) => (o || N).concat(a || N), s = e.wrap, i = r.wrap;
826
+ return {
827
+ props: n(e.props, r.props),
828
+ defineNodes: n(e.defineNodes, r.defineNodes),
829
+ parseBlock: n(e.parseBlock, r.parseBlock),
830
+ parseInline: n(e.parseInline, r.parseInline),
831
+ remove: n(e.remove, r.remove),
832
+ wrap: s ? i ? (o, a, l, h) => s(i(o, a, l, h), a, l, h) : s : i
833
+ };
834
+ }
835
+ function U(t, e) {
836
+ let r = t.indexOf(e);
837
+ if (r < 0)
838
+ throw new RangeError(`Position specified relative to unknown parser ${e}`);
839
+ return r;
840
+ }
841
+ let Xe = [Q.none];
842
+ for (let t = 1, e; e = u[t]; t++)
843
+ Xe[t] = Q.define({
844
+ id: t,
845
+ name: e,
846
+ props: t >= u.Escape ? [] : [[v.group, t in He ? ["Block", "BlockContext"] : ["Block", "LeafBlock"]]],
847
+ top: e == "Document"
848
+ });
849
+ const N = [];
850
+ class $e {
851
+ constructor(e) {
852
+ this.nodeSet = e, this.content = [], this.nodes = [];
853
+ }
854
+ write(e, r, n, s = 0) {
855
+ return this.content.push(e, r, n, 4 + s * 4), this;
856
+ }
857
+ writeElements(e, r = 0) {
858
+ for (let n of e)
859
+ n.writeTo(this, r);
860
+ return this;
861
+ }
862
+ finish(e, r) {
863
+ return H.build({
864
+ buffer: this.content,
865
+ nodeSet: this.nodeSet,
866
+ reused: this.nodes,
867
+ topID: e,
868
+ length: r
869
+ });
870
+ }
871
+ }
872
+ class D {
873
+ /**
874
+ @internal
875
+ */
876
+ constructor(e, r, n, s = N) {
877
+ this.type = e, this.from = r, this.to = n, this.children = s;
878
+ }
879
+ /**
880
+ @internal
881
+ */
882
+ writeTo(e, r) {
883
+ let n = e.content.length;
884
+ e.writeElements(this.children, r), e.content.push(this.type, this.from + r, this.to + r, e.content.length + 4 - n);
885
+ }
886
+ /**
887
+ @internal
888
+ */
889
+ toTree(e) {
890
+ return new $e(e).writeElements(this.children, -this.from).finish(this.type, this.to - this.from);
891
+ }
892
+ }
893
+ class Ue {
894
+ constructor(e, r) {
895
+ this.tree = e, this.from = r;
896
+ }
897
+ get to() {
898
+ return this.from + this.tree.length;
899
+ }
900
+ get type() {
901
+ return this.tree.type.id;
902
+ }
903
+ get children() {
904
+ return N;
905
+ }
906
+ writeTo(e, r) {
907
+ e.nodes.push(this.tree), e.content.push(e.nodes.length - 1, this.from + r, this.to + r, -1);
908
+ }
909
+ toTree() {
910
+ return this.tree;
911
+ }
912
+ }
913
+ function k(t, e, r, n) {
914
+ return new D(t, e, r, n);
915
+ }
916
+ const _e = { resolve: "Emphasis", mark: "EmphasisMark" }, je = { resolve: "Emphasis", mark: "EmphasisMark" }, M = {}, j = {};
917
+ class C {
918
+ constructor(e, r, n, s) {
919
+ this.type = e, this.from = r, this.to = n, this.side = s;
920
+ }
921
+ }
922
+ const me = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
923
+ let F = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;
924
+ try {
925
+ F = new RegExp("[\\p{S}|\\p{P}]", "u");
926
+ } catch {
927
+ }
928
+ const G = {
929
+ Escape(t, e, r) {
930
+ if (e != 92 || r == t.end - 1)
931
+ return -1;
932
+ let n = t.char(r + 1);
933
+ for (let s = 0; s < me.length; s++)
934
+ if (me.charCodeAt(s) == n)
935
+ return t.append(k(u.Escape, r, r + 2));
936
+ return -1;
937
+ },
938
+ Entity(t, e, r) {
939
+ if (e != 38)
940
+ return -1;
941
+ let n = /^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(t.slice(r + 1, r + 31));
942
+ return n ? t.append(k(u.Entity, r, r + 1 + n[0].length)) : -1;
943
+ },
944
+ InlineCode(t, e, r) {
945
+ if (e != 96 || r && t.char(r - 1) == 96)
946
+ return -1;
947
+ let n = r + 1;
948
+ for (; n < t.end && t.char(n) == 96; )
949
+ n++;
950
+ let s = n - r, i = 0;
951
+ for (; n < t.end; n++)
952
+ if (t.char(n) == 96) {
953
+ if (i++, i == s && t.char(n + 1) != 96)
954
+ return t.append(k(u.InlineCode, r, n + 1, [
955
+ k(u.CodeMark, r, r + s),
956
+ k(u.CodeMark, n + 1 - s, n + 1)
957
+ ]));
958
+ } else
959
+ i = 0;
960
+ return -1;
961
+ },
962
+ HTMLTag(t, e, r) {
963
+ if (e != 60 || r == t.end - 1)
964
+ return -1;
965
+ let n = t.slice(r + 1, t.end), s = /^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(n);
966
+ if (s)
967
+ return t.append(k(u.Autolink, r, r + 1 + s[0].length, [
968
+ k(u.LinkMark, r, r + 1),
969
+ // url[0] includes the closing bracket, so exclude it from this slice
970
+ k(u.URL, r + 1, r + s[0].length),
971
+ k(u.LinkMark, r + s[0].length, r + 1 + s[0].length)
972
+ ]));
973
+ let i = /^!--[^>](?:-[^-]|[^-])*?-->/i.exec(n);
974
+ if (i)
975
+ return t.append(k(u.Comment, r, r + 1 + i[0].length));
976
+ let o = /^\?[^]*?\?>/.exec(n);
977
+ if (o)
978
+ return t.append(k(u.ProcessingInstruction, r, r + 1 + o[0].length));
979
+ let a = /^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(n);
980
+ return a ? t.append(k(u.HTMLTag, r, r + 1 + a[0].length)) : -1;
981
+ },
982
+ Emphasis(t, e, r) {
983
+ if (e != 95 && e != 42)
984
+ return -1;
985
+ let n = r + 1;
986
+ for (; t.char(n) == e; )
987
+ n++;
988
+ let s = t.slice(r - 1, r), i = t.slice(n, n + 1), o = F.test(s), a = F.test(i), l = /\s|^$/.test(s), h = /\s|^$/.test(i), f = !h && (!a || l || o), p = !l && (!o || h || a), d = f && (e == 42 || !p || o), c = p && (e == 42 || !f || a);
989
+ return t.append(new C(e == 95 ? _e : je, r, n, (d ? 1 : 0) | (c ? 2 : 0)));
990
+ },
991
+ HardBreak(t, e, r) {
992
+ if (e == 92 && t.char(r + 1) == 10)
993
+ return t.append(k(u.HardBreak, r, r + 2));
994
+ if (e == 32) {
995
+ let n = r + 1;
996
+ for (; t.char(n) == 32; )
997
+ n++;
998
+ if (t.char(n) == 10 && n >= r + 2)
999
+ return t.append(k(u.HardBreak, r, n + 1));
1000
+ }
1001
+ return -1;
1002
+ },
1003
+ Link(t, e, r) {
1004
+ return e == 91 ? t.append(new C(
1005
+ M,
1006
+ r,
1007
+ r + 1,
1008
+ 1
1009
+ /* Mark.Open */
1010
+ )) : -1;
1011
+ },
1012
+ Image(t, e, r) {
1013
+ return e == 33 && t.char(r + 1) == 91 ? t.append(new C(
1014
+ j,
1015
+ r,
1016
+ r + 2,
1017
+ 1
1018
+ /* Mark.Open */
1019
+ )) : -1;
1020
+ },
1021
+ LinkEnd(t, e, r) {
1022
+ if (e != 93)
1023
+ return -1;
1024
+ for (let n = t.parts.length - 1; n >= 0; n--) {
1025
+ let s = t.parts[n];
1026
+ if (s instanceof C && (s.type == M || s.type == j)) {
1027
+ if (!s.side || t.skipSpace(s.to) == r && !/[(\[]/.test(t.slice(r + 1, r + 2)))
1028
+ return t.parts[n] = null, -1;
1029
+ let i = t.takeContent(n), o = t.parts[n] = Mt(t, i, s.type == M ? u.Link : u.Image, s.from, r + 1);
1030
+ if (s.type == M)
1031
+ for (let a = 0; a < n; a++) {
1032
+ let l = t.parts[a];
1033
+ l instanceof C && l.type == M && (l.side = 0);
1034
+ }
1035
+ return o.to;
1036
+ }
1037
+ }
1038
+ return -1;
1039
+ }
1040
+ };
1041
+ function Mt(t, e, r, n, s) {
1042
+ let { text: i } = t, o = t.char(s), a = s;
1043
+ if (e.unshift(k(u.LinkMark, n, n + (r == u.Image ? 2 : 1))), e.push(k(u.LinkMark, s - 1, s)), o == 40) {
1044
+ let l = t.skipSpace(s + 1), h = qe(i, l - t.offset, t.offset), f;
1045
+ h && (l = t.skipSpace(h.to), l != h.to && (f = Qe(i, l - t.offset, t.offset), f && (l = t.skipSpace(f.to)))), t.char(l) == 41 && (e.push(k(u.LinkMark, s, s + 1)), a = l + 1, h && e.push(h), f && e.push(f), e.push(k(u.LinkMark, l, a)));
1046
+ } else if (o == 91) {
1047
+ let l = Ze(i, s - t.offset, t.offset, !1);
1048
+ l && (e.push(l), a = l.to);
1049
+ }
1050
+ return k(r, n, a, e);
1051
+ }
1052
+ function qe(t, e, r) {
1053
+ if (t.charCodeAt(e) == 60) {
1054
+ for (let s = e + 1; s < t.length; s++) {
1055
+ let i = t.charCodeAt(s);
1056
+ if (i == 62)
1057
+ return k(u.URL, e + r, s + 1 + r);
1058
+ if (i == 60 || i == 10)
1059
+ return !1;
1060
+ }
1061
+ return null;
1062
+ } else {
1063
+ let s = 0, i = e;
1064
+ for (let o = !1; i < t.length; i++) {
1065
+ let a = t.charCodeAt(i);
1066
+ if (x(a))
1067
+ break;
1068
+ if (o)
1069
+ o = !1;
1070
+ else if (a == 40)
1071
+ s++;
1072
+ else if (a == 41) {
1073
+ if (!s)
1074
+ break;
1075
+ s--;
1076
+ } else a == 92 && (o = !0);
1077
+ }
1078
+ return i > e ? k(u.URL, e + r, i + r) : i == t.length ? null : !1;
1079
+ }
1080
+ }
1081
+ function Qe(t, e, r) {
1082
+ let n = t.charCodeAt(e);
1083
+ if (n != 39 && n != 34 && n != 40)
1084
+ return !1;
1085
+ let s = n == 40 ? 41 : n;
1086
+ for (let i = e + 1, o = !1; i < t.length; i++) {
1087
+ let a = t.charCodeAt(i);
1088
+ if (o)
1089
+ o = !1;
1090
+ else {
1091
+ if (a == s)
1092
+ return k(u.LinkTitle, e + r, i + 1 + r);
1093
+ a == 92 && (o = !0);
1094
+ }
1095
+ }
1096
+ return null;
1097
+ }
1098
+ function Ze(t, e, r, n) {
1099
+ for (let s = !1, i = e + 1, o = Math.min(t.length, i + 999); i < o; i++) {
1100
+ let a = t.charCodeAt(i);
1101
+ if (s)
1102
+ s = !1;
1103
+ else {
1104
+ if (a == 93)
1105
+ return n ? !1 : k(u.LinkLabel, e + r, i + 1 + r);
1106
+ if (n && !x(a) && (n = !1), a == 91)
1107
+ return !1;
1108
+ a == 92 && (s = !0);
1109
+ }
1110
+ }
1111
+ return null;
1112
+ }
1113
+ class ae {
1114
+ /**
1115
+ @internal
1116
+ */
1117
+ constructor(e, r, n) {
1118
+ this.parser = e, this.text = r, this.offset = n, this.parts = [];
1119
+ }
1120
+ /**
1121
+ Get the character code at the given (document-relative)
1122
+ position.
1123
+ */
1124
+ char(e) {
1125
+ return e >= this.end ? -1 : this.text.charCodeAt(e - this.offset);
1126
+ }
1127
+ /**
1128
+ The position of the end of this inline section.
1129
+ */
1130
+ get end() {
1131
+ return this.offset + this.text.length;
1132
+ }
1133
+ /**
1134
+ Get a substring of this inline section. Again uses
1135
+ document-relative positions.
1136
+ */
1137
+ slice(e, r) {
1138
+ return this.text.slice(e - this.offset, r - this.offset);
1139
+ }
1140
+ /**
1141
+ @internal
1142
+ */
1143
+ append(e) {
1144
+ return this.parts.push(e), e.to;
1145
+ }
1146
+ /**
1147
+ Add a [delimiter](#DelimiterType) at this given position. `open`
1148
+ and `close` indicate whether this delimiter is opening, closing,
1149
+ or both. Returns the end of the delimiter, for convenient
1150
+ returning from [parse functions](#InlineParser.parse).
1151
+ */
1152
+ addDelimiter(e, r, n, s, i) {
1153
+ return this.append(new C(e, r, n, (s ? 1 : 0) | (i ? 2 : 0)));
1154
+ }
1155
+ /**
1156
+ Returns true when there is an unmatched link or image opening
1157
+ token before the current position.
1158
+ */
1159
+ get hasOpenLink() {
1160
+ for (let e = this.parts.length - 1; e >= 0; e--) {
1161
+ let r = this.parts[e];
1162
+ if (r instanceof C && (r.type == M || r.type == j))
1163
+ return !0;
1164
+ }
1165
+ return !1;
1166
+ }
1167
+ /**
1168
+ Add an inline element. Returns the end of the element.
1169
+ */
1170
+ addElement(e) {
1171
+ return this.append(e);
1172
+ }
1173
+ /**
1174
+ Resolve markers between this.parts.length and from, wrapping matched markers in the
1175
+ appropriate node and updating the content of this.parts. @internal
1176
+ */
1177
+ resolveMarkers(e) {
1178
+ for (let n = e; n < this.parts.length; n++) {
1179
+ let s = this.parts[n];
1180
+ if (!(s instanceof C && s.type.resolve && s.side & 2))
1181
+ continue;
1182
+ let i = s.type == _e || s.type == je, o = s.to - s.from, a, l = n - 1;
1183
+ for (; l >= e; l--) {
1184
+ let g = this.parts[l];
1185
+ if (g instanceof C && g.side & 1 && g.type == s.type && // Ignore emphasis delimiters where the character count doesn't match
1186
+ !(i && (s.side & 1 || g.side & 2) && (g.to - g.from + o) % 3 == 0 && ((g.to - g.from) % 3 || o % 3))) {
1187
+ a = g;
1188
+ break;
1189
+ }
1190
+ }
1191
+ if (!a)
1192
+ continue;
1193
+ let h = s.type.resolve, f = [], p = a.from, d = s.to;
1194
+ if (i) {
1195
+ let g = Math.min(2, a.to - a.from, o);
1196
+ p = a.to - g, d = s.from + g, h = g == 1 ? "Emphasis" : "StrongEmphasis";
1197
+ }
1198
+ a.type.mark && f.push(this.elt(a.type.mark, p, a.to));
1199
+ for (let g = l + 1; g < n; g++)
1200
+ this.parts[g] instanceof D && f.push(this.parts[g]), this.parts[g] = null;
1201
+ s.type.mark && f.push(this.elt(s.type.mark, s.from, d));
1202
+ let c = this.elt(h, p, d, f);
1203
+ this.parts[l] = i && a.from != p ? new C(a.type, a.from, p, a.side) : null, (this.parts[n] = i && s.to != d ? new C(s.type, d, s.to, s.side) : null) ? this.parts.splice(n, 0, c) : this.parts[n] = c;
1204
+ }
1205
+ let r = [];
1206
+ for (let n = e; n < this.parts.length; n++) {
1207
+ let s = this.parts[n];
1208
+ s instanceof D && r.push(s);
1209
+ }
1210
+ return r;
1211
+ }
1212
+ /**
1213
+ Find an opening delimiter of the given type. Returns `null` if
1214
+ no delimiter is found, or an index that can be passed to
1215
+ [`takeContent`](#InlineContext.takeContent) otherwise.
1216
+ */
1217
+ findOpeningDelimiter(e) {
1218
+ for (let r = this.parts.length - 1; r >= 0; r--) {
1219
+ let n = this.parts[r];
1220
+ if (n instanceof C && n.type == e && n.side & 1)
1221
+ return r;
1222
+ }
1223
+ return null;
1224
+ }
1225
+ /**
1226
+ Remove all inline elements and delimiters starting from the
1227
+ given index (which you should get from
1228
+ [`findOpeningDelimiter`](#InlineContext.findOpeningDelimiter),
1229
+ resolve delimiters inside of them, and return them as an array
1230
+ of elements.
1231
+ */
1232
+ takeContent(e) {
1233
+ let r = this.resolveMarkers(e);
1234
+ return this.parts.length = e, r;
1235
+ }
1236
+ /**
1237
+ Return the delimiter at the given index. Mostly useful to get
1238
+ additional info out of a delimiter index returned by
1239
+ [`findOpeningDelimiter`](#InlineContext.findOpeningDelimiter).
1240
+ Returns null if there is no delimiter at this index.
1241
+ */
1242
+ getDelimiterAt(e) {
1243
+ let r = this.parts[e];
1244
+ return r instanceof C ? r : null;
1245
+ }
1246
+ /**
1247
+ Skip space after the given (document) position, returning either
1248
+ the position of the next non-space character or the end of the
1249
+ section.
1250
+ */
1251
+ skipSpace(e) {
1252
+ return O(this.text, e - this.offset) + this.offset;
1253
+ }
1254
+ elt(e, r, n, s) {
1255
+ return typeof e == "string" ? k(this.parser.getNodeType(e), r, n, s) : new Ue(e, r);
1256
+ }
1257
+ }
1258
+ ae.linkStart = M;
1259
+ ae.imageStart = j;
1260
+ function re(t, e) {
1261
+ if (!e.length)
1262
+ return t;
1263
+ if (!t.length)
1264
+ return e;
1265
+ let r = t.slice(), n = 0;
1266
+ for (let s of e) {
1267
+ for (; n < r.length && r[n].to < s.to; )
1268
+ n++;
1269
+ if (n < r.length && r[n].from < s.from) {
1270
+ let i = r[n];
1271
+ i instanceof D && (r[n] = new D(i.type, i.from, i.to, re(i.children, [s])));
1272
+ } else
1273
+ r.splice(n++, 0, s);
1274
+ }
1275
+ return r;
1276
+ }
1277
+ const Ht = [u.CodeBlock, u.ListItem, u.OrderedList, u.BulletList];
1278
+ class Pt {
1279
+ constructor(e, r) {
1280
+ this.fragments = e, this.input = r, this.i = 0, this.fragment = null, this.fragmentEnd = -1, this.cursor = null, e.length && (this.fragment = e[this.i++]);
1281
+ }
1282
+ nextFragment() {
1283
+ this.fragment = this.i < this.fragments.length ? this.fragments[this.i++] : null, this.cursor = null, this.fragmentEnd = -1;
1284
+ }
1285
+ moveTo(e, r) {
1286
+ for (; this.fragment && this.fragment.to <= e; )
1287
+ this.nextFragment();
1288
+ if (!this.fragment || this.fragment.from > (e ? e - 1 : 0))
1289
+ return !1;
1290
+ if (this.fragmentEnd < 0) {
1291
+ let i = this.fragment.to;
1292
+ for (; i > 0 && this.input.read(i - 1, i) != `
1293
+ `; )
1294
+ i--;
1295
+ this.fragmentEnd = i ? i - 1 : 0;
1296
+ }
1297
+ let n = this.cursor;
1298
+ n || (n = this.cursor = this.fragment.tree.cursor(), n.firstChild());
1299
+ let s = e + this.fragment.offset;
1300
+ for (; n.to <= s; )
1301
+ if (!n.parent())
1302
+ return !1;
1303
+ for (; ; ) {
1304
+ if (n.from >= s)
1305
+ return this.fragment.from <= r;
1306
+ if (!n.childAfter(s))
1307
+ return !1;
1308
+ }
1309
+ }
1310
+ matches(e) {
1311
+ let r = this.cursor.tree;
1312
+ return r && r.prop(v.contextHash) == e;
1313
+ }
1314
+ takeNodes(e) {
1315
+ let r = this.cursor, n = this.fragment.offset, s = this.fragmentEnd - (this.fragment.openEnd ? 1 : 0), i = e.absoluteLineStart, o = i, a = e.block.children.length, l = o, h = a;
1316
+ for (; ; ) {
1317
+ if (r.to - n > s) {
1318
+ if (r.type.isAnonymous && r.firstChild())
1319
+ continue;
1320
+ break;
1321
+ }
1322
+ let f = Ve(r.from - n, e.ranges);
1323
+ if (r.to - n <= e.ranges[e.rangeI].to)
1324
+ e.addNode(r.tree, f);
1325
+ else {
1326
+ let p = new H(e.parser.nodeSet.types[u.Paragraph], [], [], 0, e.block.hashProp);
1327
+ e.reusePlaceholders.set(p, r.tree), e.addNode(p, f);
1328
+ }
1329
+ if (r.type.is("Block") && (Ht.indexOf(r.type.id) < 0 ? (o = r.to - n, a = e.block.children.length) : (o = l, a = h), l = r.to - n, h = e.block.children.length), !r.nextSibling())
1330
+ break;
1331
+ }
1332
+ for (; e.block.children.length > a; )
1333
+ e.block.children.pop(), e.block.positions.pop();
1334
+ return o - i;
1335
+ }
1336
+ }
1337
+ function Ve(t, e) {
1338
+ let r = t;
1339
+ for (let n = 1; n < e.length; n++) {
1340
+ let s = e[n - 1].to, i = e[n].from;
1341
+ s < t && (r -= i - s);
1342
+ }
1343
+ return r;
1344
+ }
1345
+ const vt = Me({
1346
+ "Blockquote/...": m.quote,
1347
+ HorizontalRule: m.contentSeparator,
1348
+ "ATXHeading1/... SetextHeading1/...": m.heading1,
1349
+ "ATXHeading2/... SetextHeading2/...": m.heading2,
1350
+ "ATXHeading3/...": m.heading3,
1351
+ "ATXHeading4/...": m.heading4,
1352
+ "ATXHeading5/...": m.heading5,
1353
+ "ATXHeading6/...": m.heading6,
1354
+ "Comment CommentBlock": m.comment,
1355
+ Escape: m.escape,
1356
+ Entity: m.character,
1357
+ "Emphasis/...": m.emphasis,
1358
+ "StrongEmphasis/...": m.strong,
1359
+ "Link/... Image/...": m.link,
1360
+ "OrderedList/... BulletList/...": m.list,
1361
+ "BlockQuote/...": m.quote,
1362
+ "InlineCode CodeText": m.monospace,
1363
+ "URL Autolink": m.url,
1364
+ "HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark": m.processingInstruction,
1365
+ "CodeInfo LinkLabel": m.labelName,
1366
+ LinkTitle: m.string,
1367
+ Paragraph: m.content
1368
+ }), Nt = new Z(new Ie(Xe).extend(vt), Object.keys($).map((t) => $[t]), Object.keys($).map((t) => De[t]), Object.keys($), Bt, He, Object.keys(G).map((t) => G[t]), Object.keys(G), []);
1369
+ function yt(t, e, r) {
1370
+ let n = [];
1371
+ for (let s = t.firstChild, i = e; ; s = s.nextSibling) {
1372
+ let o = s ? s.from : r;
1373
+ if (o > i && n.push({ from: i, to: o }), !s)
1374
+ break;
1375
+ i = s.to;
1376
+ }
1377
+ return n;
1378
+ }
1379
+ function Rt(t) {
1380
+ let { codeParser: e, htmlParser: r } = t;
1381
+ return { wrap: Lt((s, i) => {
1382
+ let o = s.type.id;
1383
+ if (e && (o == u.CodeBlock || o == u.FencedCode)) {
1384
+ let a = "";
1385
+ if (o == u.FencedCode) {
1386
+ let h = s.node.getChild(u.CodeInfo);
1387
+ h && (a = i.read(h.from, h.to));
1388
+ }
1389
+ let l = e(a);
1390
+ if (l)
1391
+ return { parser: l, overlay: (h) => h.type.id == u.CodeText, bracketed: o == u.FencedCode };
1392
+ } else if (r && (o == u.HTMLBlock || o == u.HTMLTag || o == u.CommentBlock))
1393
+ return { parser: r, overlay: yt(s.node, s.from, s.to) };
1394
+ return null;
1395
+ }) };
1396
+ }
1397
+ const Ot = { resolve: "Strikethrough", mark: "StrikethroughMark" }, Tt = {
1398
+ defineNodes: [{
1399
+ name: "Strikethrough",
1400
+ style: { "Strikethrough/...": m.strikethrough }
1401
+ }, {
1402
+ name: "StrikethroughMark",
1403
+ style: m.processingInstruction
1404
+ }],
1405
+ parseInline: [{
1406
+ name: "Strikethrough",
1407
+ parse(t, e, r) {
1408
+ if (e != 126 || t.char(r + 1) != 126 || t.char(r + 2) == 126)
1409
+ return -1;
1410
+ let n = t.slice(r - 1, r), s = t.slice(r + 2, r + 3), i = /\s|^$/.test(n), o = /\s|^$/.test(s), a = F.test(n), l = F.test(s);
1411
+ return t.addDelimiter(Ot, r, r + 2, !o && (!l || i || a), !i && (!a || o || l));
1412
+ },
1413
+ after: "Emphasis"
1414
+ }]
1415
+ };
1416
+ function T(t, e, r = 0, n, s = 0) {
1417
+ let i = 0, o = !0, a = -1, l = -1, h = !1, f = () => {
1418
+ n.push(t.elt("TableCell", s + a, s + l, t.parser.parseInline(e.slice(a, l), s + a)));
1419
+ };
1420
+ for (let p = r; p < e.length; p++) {
1421
+ let d = e.charCodeAt(p);
1422
+ d == 124 && !h ? ((!o || a > -1) && i++, o = !1, n && (a > -1 && f(), n.push(t.elt("TableDelimiter", p + s, p + s + 1))), a = l = -1) : (h || d != 32 && d != 9) && (a < 0 && (a = p), l = p + 1), h = !h && d == 92;
1423
+ }
1424
+ return a > -1 && (i++, n && f()), i;
1425
+ }
1426
+ function ge(t, e) {
1427
+ for (let r = e; r < t.length; r++) {
1428
+ let n = t.charCodeAt(r);
1429
+ if (n == 124)
1430
+ return !0;
1431
+ n == 92 && r++;
1432
+ }
1433
+ return !1;
1434
+ }
1435
+ const Ge = /^[>\s]*\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;
1436
+ class ke {
1437
+ constructor() {
1438
+ this.rows = null;
1439
+ }
1440
+ nextLine(e, r, n) {
1441
+ if (this.rows == null) {
1442
+ this.rows = !1;
1443
+ let s;
1444
+ if ((r.next == 45 || r.next == 58 || r.next == 124) && Ge.test(s = r.text.slice(r.pos))) {
1445
+ let i = [];
1446
+ T(e, n.content, 0, i, n.start) == T(e, s, 0) && (this.rows = [
1447
+ e.elt("TableHeader", n.start, n.start + n.content.length, i),
1448
+ e.elt("TableDelimiter", e.lineStart + r.pos, e.lineStart + r.text.length)
1449
+ ]);
1450
+ }
1451
+ } else if (this.rows) {
1452
+ let s = [];
1453
+ T(e, r.text, r.pos, s, e.lineStart), this.rows.push(e.elt("TableRow", e.lineStart + r.pos, e.lineStart + r.text.length, s));
1454
+ }
1455
+ return !1;
1456
+ }
1457
+ finish(e, r) {
1458
+ return this.rows ? (e.addLeafElement(r, e.elt("Table", r.start, r.start + r.content.length, this.rows)), !0) : !1;
1459
+ }
1460
+ }
1461
+ const zt = {
1462
+ defineNodes: [
1463
+ { name: "Table", block: !0 },
1464
+ { name: "TableHeader", style: { "TableHeader/...": m.heading } },
1465
+ "TableRow",
1466
+ { name: "TableCell", style: m.content },
1467
+ { name: "TableDelimiter", style: m.processingInstruction }
1468
+ ],
1469
+ parseBlock: [{
1470
+ name: "Table",
1471
+ leaf(t, e) {
1472
+ return ge(e.content, 0) ? new ke() : null;
1473
+ },
1474
+ endLeaf(t, e, r) {
1475
+ if (r.parsers.some((s) => s instanceof ke) || !ge(e.text, e.basePos))
1476
+ return !1;
1477
+ let n = t.peekLine();
1478
+ return Ge.test(n) && T(t, e.text, e.basePos) == T(t, n, e.basePos);
1479
+ },
1480
+ before: "SetextHeading"
1481
+ }]
1482
+ };
1483
+ class Dt {
1484
+ nextLine() {
1485
+ return !1;
1486
+ }
1487
+ finish(e, r) {
1488
+ return e.addLeafElement(r, e.elt("Task", r.start, r.start + r.content.length, [
1489
+ e.elt("TaskMarker", r.start, r.start + 3),
1490
+ ...e.parser.parseInline(r.content.slice(3), r.start + 3)
1491
+ ])), !0;
1492
+ }
1493
+ }
1494
+ const Ft = {
1495
+ defineNodes: [
1496
+ { name: "Task", block: !0, style: m.list },
1497
+ { name: "TaskMarker", style: m.atom }
1498
+ ],
1499
+ parseBlock: [{
1500
+ name: "TaskList",
1501
+ leaf(t, e) {
1502
+ return /^\[[ xX]\][ \t]/.test(e.content) && t.parentType().name == "ListItem" ? new Dt() : null;
1503
+ },
1504
+ after: "SetextHeading"
1505
+ }]
1506
+ }, Le = /(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy, be = /[\w-]+(\.[\w-]+)+(:\d+)?(\/[^\s<]*)?/gy, Xt = /[\w-]+\.[\w-]+($|[/:])/, we = /[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy, Se = /\/[a-zA-Z\d@.]+/gy;
1507
+ function Ce(t, e, r, n) {
1508
+ let s = 0;
1509
+ for (let i = e; i < r; i++)
1510
+ t[i] == n && s++;
1511
+ return s;
1512
+ }
1513
+ function $t(t, e) {
1514
+ be.lastIndex = e;
1515
+ let r = be.exec(t);
1516
+ if (!r || Xt.exec(r[0])[0].indexOf("_") > -1)
1517
+ return -1;
1518
+ let n = e + r[0].length;
1519
+ for (; ; ) {
1520
+ let s = t[n - 1], i;
1521
+ if (/[?!.,:*_~]/.test(s) || s == ")" && Ce(t, e, n, ")") > Ce(t, e, n, "("))
1522
+ n--;
1523
+ else if (s == ";" && (i = /&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(t.slice(e, n))))
1524
+ n = e + i.index;
1525
+ else
1526
+ break;
1527
+ }
1528
+ return n;
1529
+ }
1530
+ function xe(t, e) {
1531
+ we.lastIndex = e;
1532
+ let r = we.exec(t);
1533
+ if (!r)
1534
+ return -1;
1535
+ let n = r[0][r[0].length - 1];
1536
+ return n == "_" || n == "-" ? -1 : e + r[0].length - (n == "." ? 1 : 0);
1537
+ }
1538
+ const Ut = {
1539
+ parseInline: [{
1540
+ name: "Autolink",
1541
+ parse(t, e, r) {
1542
+ let n = r - t.offset;
1543
+ if (n && /\w/.test(t.text[n - 1]))
1544
+ return -1;
1545
+ Le.lastIndex = n;
1546
+ let s = Le.exec(t.text), i = -1;
1547
+ if (!s)
1548
+ return -1;
1549
+ if (s[1] || s[2]) {
1550
+ if (i = $t(t.text, n + s[0].length), i > -1 && t.hasOpenLink) {
1551
+ let o = /([^\[\]]|\[[^\]]*\])*/.exec(t.text.slice(n, i));
1552
+ i = n + o[0].length;
1553
+ }
1554
+ } else s[3] ? i = xe(t.text, n) : (i = xe(t.text, n + s[0].length), i > -1 && s[0] == "xmpp:" && (Se.lastIndex = i, s = Se.exec(t.text), s && (i = s.index + s[0].length)));
1555
+ return i < 0 ? -1 : (t.addElement(t.elt("URL", r, i + t.offset)), i + t.offset);
1556
+ }
1557
+ }]
1558
+ }, _t = [zt, Ft, Tt, Ut];
1559
+ function Ke(t, e, r) {
1560
+ return (n, s, i) => {
1561
+ if (s != t || n.char(i + 1) == t)
1562
+ return -1;
1563
+ let o = [n.elt(r, i, i + 1)];
1564
+ for (let a = i + 1; a < n.end; a++) {
1565
+ let l = n.char(a);
1566
+ if (l == t)
1567
+ return n.addElement(n.elt(e, i, a + 1, o.concat(n.elt(r, a, a + 1))));
1568
+ if (l == 92 && o.push(n.elt("Escape", a, a++ + 2)), x(l))
1569
+ break;
1570
+ }
1571
+ return -1;
1572
+ };
1573
+ }
1574
+ const jt = {
1575
+ defineNodes: [
1576
+ { name: "Superscript", style: m.special(m.content) },
1577
+ { name: "SuperscriptMark", style: m.processingInstruction }
1578
+ ],
1579
+ parseInline: [{
1580
+ name: "Superscript",
1581
+ parse: Ke(94, "Superscript", "SuperscriptMark")
1582
+ }]
1583
+ }, qt = {
1584
+ defineNodes: [
1585
+ { name: "Subscript", style: m.special(m.content) },
1586
+ { name: "SubscriptMark", style: m.processingInstruction }
1587
+ ],
1588
+ parseInline: [{
1589
+ name: "Subscript",
1590
+ parse: Ke(126, "Subscript", "SubscriptMark")
1591
+ }]
1592
+ }, Qt = {
1593
+ defineNodes: [{ name: "Emoji", style: m.character }],
1594
+ parseInline: [{
1595
+ name: "Emoji",
1596
+ parse(t, e, r) {
1597
+ let n;
1598
+ return e != 58 || !(n = /^[a-zA-Z_0-9]+:/.exec(t.slice(r + 1, t.end))) ? -1 : t.addElement(t.elt("Emoji", r, r + 1 + n[0].length));
1599
+ }
1600
+ }]
1601
+ }, Je = /* @__PURE__ */ ht({ commentTokens: { block: { open: "<!--", close: "-->" } } }), Ye = /* @__PURE__ */ new v(), We = /* @__PURE__ */ Nt.configure({
1602
+ props: [
1603
+ /* @__PURE__ */ Ee.add((t) => !t.is("Block") || t.is("Document") || ne(t) != null || Zt(t) ? void 0 : (e, r) => ({ from: r.doc.lineAt(e.from).to, to: e.to })),
1604
+ /* @__PURE__ */ Ye.add(ne),
1605
+ /* @__PURE__ */ dt.add({
1606
+ Document: () => null
1607
+ }),
1608
+ /* @__PURE__ */ pt.add({
1609
+ Document: Je
1610
+ })
1611
+ ]
1612
+ });
1613
+ function ne(t) {
1614
+ let e = /^(?:ATX|Setext)Heading(\d)$/.exec(t.name);
1615
+ return e ? +e[1] : void 0;
1616
+ }
1617
+ function Zt(t) {
1618
+ return t.name == "OrderedList" || t.name == "BulletList";
1619
+ }
1620
+ function Vt(t, e) {
1621
+ let r = t;
1622
+ for (; ; ) {
1623
+ let n = r.nextSibling, s;
1624
+ if (!n || (s = ne(n.type)) != null && s <= e)
1625
+ break;
1626
+ r = n;
1627
+ }
1628
+ return r.to;
1629
+ }
1630
+ const Gt = /* @__PURE__ */ ft.of((t, e, r) => {
1631
+ for (let n = X(t).resolveInner(r, -1); n && !(n.from < e); n = n.parent) {
1632
+ let s = n.type.prop(Ye);
1633
+ if (s == null)
1634
+ continue;
1635
+ let i = Vt(n, s);
1636
+ if (i > r)
1637
+ return { from: r, to: i };
1638
+ }
1639
+ return null;
1640
+ });
1641
+ function le(t) {
1642
+ return new lt(Je, t, [], "markdown");
1643
+ }
1644
+ const Kt = /* @__PURE__ */ le(We), Jt = /* @__PURE__ */ We.configure([_t, qt, jt, Qt, {
1645
+ props: [
1646
+ /* @__PURE__ */ Ee.add({
1647
+ Table: (t, e) => ({ from: e.doc.lineAt(t.from).to, to: t.to })
1648
+ })
1649
+ ]
1650
+ }]), q = /* @__PURE__ */ le(Jt);
1651
+ function Yt(t, e) {
1652
+ return (r) => {
1653
+ if (r && t) {
1654
+ let n = null;
1655
+ if (r = /\S*/.exec(r)[0], typeof t == "function" ? n = t(r) : n = ue.matchLanguageName(t, r, !0), n instanceof ue)
1656
+ return n.support ? n.support.language.parser : ct.getSkippingParser(n.load());
1657
+ if (n)
1658
+ return n.parser;
1659
+ }
1660
+ return e ? e.parser : null;
1661
+ };
1662
+ }
1663
+ class K {
1664
+ constructor(e, r, n, s, i, o, a) {
1665
+ this.node = e, this.from = r, this.to = n, this.spaceBefore = s, this.spaceAfter = i, this.type = o, this.item = a;
1666
+ }
1667
+ blank(e, r = !0) {
1668
+ let n = this.spaceBefore + (this.node.name == "Blockquote" ? ">" : "");
1669
+ if (e != null) {
1670
+ for (; n.length < e; )
1671
+ n += " ";
1672
+ return n;
1673
+ } else {
1674
+ for (let s = this.to - this.from - n.length - this.spaceAfter.length; s > 0; s--)
1675
+ n += " ";
1676
+ return n + (r ? this.spaceAfter : "");
1677
+ }
1678
+ }
1679
+ marker(e, r) {
1680
+ let n = this.node.name == "OrderedList" ? String(+tt(this.item, e)[2] + r) : "";
1681
+ return this.spaceBefore + n + this.type + this.spaceAfter;
1682
+ }
1683
+ }
1684
+ function et(t, e) {
1685
+ let r = [], n = [];
1686
+ for (let s = t; s; s = s.parent) {
1687
+ if (s.name == "FencedCode")
1688
+ return n;
1689
+ (s.name == "ListItem" || s.name == "Blockquote") && r.push(s);
1690
+ }
1691
+ for (let s = r.length - 1; s >= 0; s--) {
1692
+ let i = r[s], o, a = e.lineAt(i.from), l = i.from - a.from;
1693
+ if (i.name == "Blockquote" && (o = /^ *>( ?)/.exec(a.text.slice(l))))
1694
+ n.push(new K(i, l, l + o[0].length, "", o[1], ">", null));
1695
+ else if (i.name == "ListItem" && i.parent.name == "OrderedList" && (o = /^( *)\d+([.)])( *)/.exec(a.text.slice(l)))) {
1696
+ let h = o[3], f = o[0].length;
1697
+ h.length >= 4 && (h = h.slice(0, h.length - 4), f -= 4), n.push(new K(i.parent, l, l + f, o[1], h, o[2], i));
1698
+ } else if (i.name == "ListItem" && i.parent.name == "BulletList" && (o = /^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(a.text.slice(l)))) {
1699
+ let h = o[4], f = o[0].length;
1700
+ h.length > 4 && (h = h.slice(0, h.length - 4), f -= 4);
1701
+ let p = o[2];
1702
+ o[3] && (p += o[3].replace(/[xX]/, " ")), n.push(new K(i.parent, l, l + f, o[1], h, p, i));
1703
+ }
1704
+ }
1705
+ return n;
1706
+ }
1707
+ function tt(t, e) {
1708
+ return /^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(t.from, t.from + 10));
1709
+ }
1710
+ function J(t, e, r, n = 0) {
1711
+ for (let s = -1, i = t; ; ) {
1712
+ if (i.name == "ListItem") {
1713
+ let a = tt(i, e), l = +a[2];
1714
+ if (s >= 0) {
1715
+ if (l != s + 1)
1716
+ return;
1717
+ r.push({ from: i.from + a[1].length, to: i.from + a[0].length, insert: String(s + 2 + n) });
1718
+ }
1719
+ s = l;
1720
+ }
1721
+ let o = i.nextSibling;
1722
+ if (!o)
1723
+ break;
1724
+ i = o;
1725
+ }
1726
+ }
1727
+ function he(t, e) {
1728
+ let r = /^[ \t]*/.exec(t)[0].length;
1729
+ if (!r || e.facet(ut) != " ")
1730
+ return t;
1731
+ let n = z(t, 4, r), s = "";
1732
+ for (let i = n; i > 0; )
1733
+ i >= 4 ? (s += " ", i -= 4) : (s += " ", i--);
1734
+ return s + t.slice(r);
1735
+ }
1736
+ const Wt = (t = {}) => ({ state: e, dispatch: r }) => {
1737
+ let n = X(e), { doc: s } = e, i = null, o = e.changeByRange((a) => {
1738
+ if (!a.empty || !q.isActiveAt(e, a.from, -1) && !q.isActiveAt(e, a.from, 1))
1739
+ return i = { range: a };
1740
+ let l = a.from, h = s.lineAt(l), f = et(n.resolveInner(l, -1), s);
1741
+ for (; f.length && f[f.length - 1].from > l - h.from; )
1742
+ f.pop();
1743
+ if (!f.length)
1744
+ return i = { range: a };
1745
+ let p = f[f.length - 1];
1746
+ if (p.to - p.spaceAfter.length > l - h.from)
1747
+ return i = { range: a };
1748
+ let d = l >= p.to - p.spaceAfter.length && !/\S/.test(h.text.slice(p.to));
1749
+ if (p.item && d) {
1750
+ if (p.item.from < h.from && !/^[\s>]*$/.test(h.text.slice(0, p.to)))
1751
+ return i = { range: a };
1752
+ let w = p.node.firstChild, S = p.node.getChild("ListItem", "ListItem");
1753
+ if (w.to >= l || S && S.to < l || h.from > 0 && !/[^\s>]/.test(s.lineAt(h.from - 1).text) || t.nonTightLists === !1) {
1754
+ let b = f.length > 1 ? f[f.length - 2] : null, E, I = "";
1755
+ b && b.item ? (E = h.from + b.from, I = b.marker(s, 1)) : E = h.from + (b ? b.to : 0);
1756
+ let y = [{ from: E, to: l, insert: I }];
1757
+ return p.node.name == "OrderedList" && J(p.item, s, y, -2), b && b.node.name == "OrderedList" && J(b.item, s, y), { range: P.cursor(E + I.length), changes: y };
1758
+ } else {
1759
+ let b = Be(f, e, h);
1760
+ return {
1761
+ range: P.cursor(l + b.length + 1),
1762
+ changes: { from: h.from, insert: b + e.lineBreak }
1763
+ };
1764
+ }
1765
+ }
1766
+ if (p.node.name == "Blockquote" && d && h.from) {
1767
+ let w = s.lineAt(h.from - 1), S = />\s*$/.exec(w.text);
1768
+ if (S && S.index == p.from) {
1769
+ let b = e.changes([
1770
+ { from: w.from + S.index, to: w.to },
1771
+ { from: h.from + p.from, to: h.to }
1772
+ ]);
1773
+ return { range: a.map(b), changes: b };
1774
+ }
1775
+ }
1776
+ let c = [];
1777
+ p.node.name == "OrderedList" && J(p.item, s, c);
1778
+ let L = p.item && p.item.from < h.from, g = "";
1779
+ if (!L || /^[\s\d.)\-+*>]*/.exec(h.text)[0].length >= p.to)
1780
+ for (let w = 0, S = f.length - 1; w <= S; w++)
1781
+ g += w == S && !L ? f[w].marker(s, 1) : f[w].blank(w < S ? z(h.text, 4, f[w + 1].from) - g.length : null);
1782
+ let B = l;
1783
+ for (; B > h.from && /\s/.test(h.text.charAt(B - h.from - 1)); )
1784
+ B--;
1785
+ return g = he(g, e), tr(p.node, e.doc) && (g = Be(f, e, h) + e.lineBreak + g), c.push({ from: B, to: l, insert: e.lineBreak + g }), { range: P.cursor(B + g.length + 1), changes: c };
1786
+ });
1787
+ return i ? !1 : (r(e.update(o, { scrollIntoView: !0, userEvent: "input" })), !0);
1788
+ }, er = /* @__PURE__ */ Wt();
1789
+ function Ae(t) {
1790
+ return t.name == "QuoteMark" || t.name == "ListMark";
1791
+ }
1792
+ function tr(t, e) {
1793
+ if (t.name != "OrderedList" && t.name != "BulletList")
1794
+ return !1;
1795
+ let r = t.firstChild, n = t.getChild("ListItem", "ListItem");
1796
+ if (!n)
1797
+ return !1;
1798
+ let s = e.lineAt(r.to), i = e.lineAt(n.from), o = /^[\s>]*$/.test(s.text);
1799
+ return s.number + (o ? 0 : 1) < i.number;
1800
+ }
1801
+ function Be(t, e, r) {
1802
+ let n = "";
1803
+ for (let s = 0, i = t.length - 2; s <= i; s++)
1804
+ n += t[s].blank(s < i ? z(r.text, 4, t[s + 1].from) - n.length : null, s < i);
1805
+ return he(n, e);
1806
+ }
1807
+ function rr(t, e) {
1808
+ let r = t.resolveInner(e, -1), n = e;
1809
+ Ae(r) && (n = r.from, r = r.parent);
1810
+ for (let s; s = r.childBefore(n); )
1811
+ if (Ae(s))
1812
+ n = s.from;
1813
+ else if (s.name == "OrderedList" || s.name == "BulletList")
1814
+ r = s.lastChild, n = r.to;
1815
+ else
1816
+ break;
1817
+ return r;
1818
+ }
1819
+ const nr = ({ state: t, dispatch: e }) => {
1820
+ let r = X(t), n = null, s = t.changeByRange((i) => {
1821
+ let o = i.from, { doc: a } = t;
1822
+ if (i.empty && q.isActiveAt(t, i.from)) {
1823
+ let l = a.lineAt(o), h = et(rr(r, o), a);
1824
+ if (h.length) {
1825
+ let f = h[h.length - 1], p = f.to - f.spaceAfter.length + (f.spaceAfter ? 1 : 0);
1826
+ if (o - l.from > p && !/\S/.test(l.text.slice(p, o - l.from)))
1827
+ return {
1828
+ range: P.cursor(l.from + p),
1829
+ changes: { from: l.from + p, to: o }
1830
+ };
1831
+ if (o - l.from == p && // Only apply this if we're on the line that has the
1832
+ // construct's syntax, or there's only indentation in the
1833
+ // target range
1834
+ (f.item && l.from <= f.item.from || /^[\s>]*$/.test(l.text.slice(0, f.to)))) {
1835
+ let d = l.from + f.from;
1836
+ if (f.item && f.node.from < f.item.from && /\S/.test(l.text.slice(f.from, f.to))) {
1837
+ let c = f.blank(z(l.text, 4, f.to) - z(l.text, 4, f.from));
1838
+ return d == l.from && (c = he(c, t)), {
1839
+ range: P.cursor(d + c.length),
1840
+ changes: { from: d, to: l.from + f.to, insert: c }
1841
+ };
1842
+ }
1843
+ if (d < o)
1844
+ return { range: P.cursor(d), changes: { from: d, to: o } };
1845
+ }
1846
+ }
1847
+ }
1848
+ return n = { range: i };
1849
+ });
1850
+ return n ? !1 : (e(t.update(s, { scrollIntoView: !0, userEvent: "delete" })), !0);
1851
+ }, sr = [
1852
+ { key: "Enter", run: er },
1853
+ { key: "Backspace", run: nr }
1854
+ ], rt = /* @__PURE__ */ bt({ matchClosingTags: !1 });
1855
+ function mr(t = {}) {
1856
+ let { codeLanguages: e, defaultCodeLanguage: r, addKeymap: n = !0, base: { parser: s } = Kt, completeHTMLTags: i = !0, pasteURLAsLink: o = !0, htmlTagLanguage: a = rt } = t;
1857
+ if (!(s instanceof Z))
1858
+ throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");
1859
+ let l = t.extensions ? [t.extensions] : [], h = [a.support, Gt], f;
1860
+ o && h.push(lr), r instanceof fe ? (h.push(r.support), f = r.language) : r && (f = r);
1861
+ let p = e || f ? Yt(e, f) : void 0;
1862
+ l.push(Rt({ codeParser: p, htmlParser: a.language.parser })), n && h.push(st.high(at.of(sr)));
1863
+ let d = le(s.configure(l));
1864
+ return i && h.push(d.data.of({ autocomplete: ir })), new fe(d, h);
1865
+ }
1866
+ function ir(t) {
1867
+ let { state: e, pos: r } = t, n = /<[:\-\.\w\u00b7-\uffff]*$/.exec(e.sliceDoc(r - 25, r));
1868
+ if (!n)
1869
+ return null;
1870
+ let s = X(e).resolveInner(r, -1);
1871
+ for (; s && !s.type.isTop; ) {
1872
+ if (s.name == "CodeBlock" || s.name == "FencedCode" || s.name == "ProcessingInstructionBlock" || s.name == "CommentBlock" || s.name == "Link" || s.name == "Image")
1873
+ return null;
1874
+ s = s.parent;
1875
+ }
1876
+ return {
1877
+ from: r - n[0].length,
1878
+ to: r,
1879
+ options: or(),
1880
+ validFor: /^<[:\-\.\w\u00b7-\uffff]*$/
1881
+ };
1882
+ }
1883
+ let Y = null;
1884
+ function or() {
1885
+ if (Y)
1886
+ return Y;
1887
+ let t = wt(new mt(it.create({ extensions: rt }), 0, !0));
1888
+ return Y = t ? t.options : [];
1889
+ }
1890
+ const ar = /code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i, lr = /* @__PURE__ */ ot.domEventHandlers({
1891
+ paste: (t, e) => {
1892
+ var r;
1893
+ let { main: n } = e.state.selection;
1894
+ if (n.empty)
1895
+ return !1;
1896
+ let s = (r = t.clipboardData) === null || r === void 0 ? void 0 : r.getData("text/plain");
1897
+ if (!s || !/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(s) || (/^www\./.test(s) && (s = "https://" + s), !q.isActiveAt(e.state, n.from, 1)))
1898
+ return !1;
1899
+ let i = X(e.state), o = !1;
1900
+ return i.iterate({
1901
+ from: n.from,
1902
+ to: n.to,
1903
+ enter: (a) => {
1904
+ (a.from > n.from || ar.test(a.name)) && (o = !0);
1905
+ },
1906
+ leave: (a) => {
1907
+ a.to < n.to && (o = !0);
1908
+ }
1909
+ }), o ? !1 : (e.dispatch({
1910
+ changes: [{ from: n.from, insert: "[" }, { from: n.to, insert: `](${s})` }],
1911
+ userEvent: "input.paste",
1912
+ scrollIntoView: !0
1913
+ }), !0);
1914
+ }
1915
+ });
1916
+ export {
1917
+ Kt as commonmarkLanguage,
1918
+ nr as deleteMarkupBackward,
1919
+ er as insertNewlineContinueMarkup,
1920
+ Wt as insertNewlineContinueMarkupCommand,
1921
+ mr as markdown,
1922
+ sr as markdownKeymap,
1923
+ q as markdownLanguage,
1924
+ lr as pasteURLAsLink
1925
+ };