@rcarls/rc-markdown-editor 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5020 +0,0 @@
1
- import { css as On, LitElement as Jt, nothing as en, html as Ne, svg as se } from "lit";
2
- import { property as Q, query as St, state as Pn } from "lit/decorators.js";
3
- const Mt = document.createElement("i");
4
- function Xe(e) {
5
- const t = "&" + e + ";";
6
- Mt.innerHTML = t;
7
- const n = Mt.textContent;
8
- return n.charCodeAt(n.length - 1) === 59 && e !== "semi" || n === t ? !1 : n;
9
- }
10
- function oe(e, t, n, r) {
11
- const i = e.length;
12
- let a = 0, l;
13
- if (t < 0 ? t = -t > i ? 0 : i + t : t = t > i ? i : t, n = n > 0 ? n : 0, r.length < 1e4)
14
- l = Array.from(r), l.unshift(t, n), e.splice(...l);
15
- else
16
- for (n && e.splice(t, n); a < r.length; )
17
- l = r.slice(a, a + 1e4), l.unshift(t, 0), e.splice(...l), a += 1e4, t += 1e4;
18
- }
19
- function Y(e, t) {
20
- return e.length > 0 ? (oe(e, e.length, 0, t), e) : t;
21
- }
22
- const gt = {}.hasOwnProperty;
23
- function Dn(e) {
24
- const t = {};
25
- let n = -1;
26
- for (; ++n < e.length; )
27
- Hn(t, e[n]);
28
- return t;
29
- }
30
- function Hn(e, t) {
31
- let n;
32
- for (n in t) {
33
- const i = (gt.call(e, n) ? e[n] : void 0) || (e[n] = {}), a = t[n];
34
- let l;
35
- if (a)
36
- for (l in a) {
37
- gt.call(i, l) || (i[l] = []);
38
- const o = a[l];
39
- qn(
40
- // @ts-expect-error Looks like a list.
41
- i[l],
42
- Array.isArray(o) ? o : o ? [o] : []
43
- );
44
- }
45
- }
46
- }
47
- function qn(e, t) {
48
- let n = -1;
49
- const r = [];
50
- for (; ++n < t.length; )
51
- (t[n].add === "after" ? e : r).push(t[n]);
52
- oe(e, 0, 0, r);
53
- }
54
- function Vn(e) {
55
- const t = {};
56
- let n = -1;
57
- for (; ++n < e.length; )
58
- $n(t, e[n]);
59
- return t;
60
- }
61
- function $n(e, t) {
62
- let n;
63
- for (n in t) {
64
- const i = (gt.call(e, n) ? e[n] : void 0) || (e[n] = {}), a = t[n];
65
- let l;
66
- if (a)
67
- for (l in a)
68
- i[l] = a[l];
69
- }
70
- }
71
- function wt(e, t) {
72
- const n = Number.parseInt(e, t);
73
- return (
74
- // C0 except for HT, LF, FF, CR, space.
75
- n < 9 || n === 11 || n > 13 && n < 32 || // Control character (DEL) of C0, and C1 controls.
76
- n > 126 && n < 160 || // Lone high surrogates and low surrogates.
77
- n > 55295 && n < 57344 || // Noncharacters.
78
- n > 64975 && n < 65008 || /* eslint-disable no-bitwise */
79
- (n & 65535) === 65535 || (n & 65535) === 65534 || /* eslint-enable no-bitwise */
80
- // Out of range
81
- n > 1114111 ? "�" : String.fromCodePoint(n)
82
- );
83
- }
84
- const Un = { '"': "quot", "&": "amp", "<": "lt", ">": "gt" };
85
- function tn(e) {
86
- return e.replace(/["&<>]/g, t);
87
- function t(n) {
88
- return "&" + Un[
89
- /** @type {keyof typeof characterReferences} */
90
- n
91
- ] + ";";
92
- }
93
- }
94
- function Ie(e) {
95
- return e.replace(/[\t\n\r ]+/g, " ").replace(/^ | $/g, "").toLowerCase().toUpperCase();
96
- }
97
- const ye = Le(/[A-Za-z]/), le = Le(/[\dA-Za-z]/), jn = Le(/[#-'*+\--9=?A-Z^-~]/);
98
- function mt(e) {
99
- return (
100
- // Special whitespace codes (which have negative values), C0 and Control
101
- // character DEL
102
- e !== null && (e < 32 || e === 127)
103
- );
104
- }
105
- const kt = Le(/\d/), Wn = Le(/[\dA-Fa-f]/), Qn = Le(/[!-/:-@[-`{-~]/);
106
- function I(e) {
107
- return e !== null && e < -2;
108
- }
109
- function J(e) {
110
- return e !== null && (e < 0 || e === 32);
111
- }
112
- function R(e) {
113
- return e === -2 || e === -1 || e === 32;
114
- }
115
- const Kn = Le(new RegExp("\\p{P}|\\p{S}", "u")), Yn = Le(/\s/);
116
- function Le(e) {
117
- return t;
118
- function t(n) {
119
- return n !== null && n > -1 && e.test(String.fromCharCode(n));
120
- }
121
- }
122
- function je(e, t) {
123
- const n = tn(Gn(e || ""));
124
- if (!t)
125
- return n;
126
- const r = n.indexOf(":"), i = n.indexOf("?"), a = n.indexOf("#"), l = n.indexOf("/");
127
- return (
128
- // If there is no protocol, it’s relative.
129
- r < 0 || // If the first colon is after a `?`, `#`, or `/`, it’s not a protocol.
130
- l > -1 && r > l || i > -1 && r > i || a > -1 && r > a || // It is a protocol, it should be allowed.
131
- t.test(n.slice(0, r)) ? n : ""
132
- );
133
- }
134
- function Gn(e) {
135
- const t = [];
136
- let n = -1, r = 0, i = 0;
137
- for (; ++n < e.length; ) {
138
- const a = e.charCodeAt(n);
139
- let l = "";
140
- if (a === 37 && le(e.charCodeAt(n + 1)) && le(e.charCodeAt(n + 2)))
141
- i = 2;
142
- else if (a < 128)
143
- /[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a)) || (l = String.fromCharCode(a));
144
- else if (a > 55295 && a < 57344) {
145
- const o = e.charCodeAt(n + 1);
146
- a < 56320 && o > 56319 && o < 57344 ? (l = String.fromCharCode(a, o), i = 1) : l = "�";
147
- } else
148
- l = String.fromCharCode(a);
149
- l && (t.push(e.slice(r, n), encodeURIComponent(l)), r = n + i + 1, l = ""), i && (n += i, i = 0);
150
- }
151
- return t.join("") + e.slice(r);
152
- }
153
- const Rt = {}.hasOwnProperty, Nt = /^(https?|ircs?|mailto|xmpp)$/i, Xn = /^https?$/i;
154
- function Zn(e) {
155
- const t = e || {};
156
- let n = !0;
157
- const r = {}, i = [[]], a = [], l = [], u = (
158
- /** @type {NormalizedHtmlExtension} */
159
- Vn([{
160
- enter: {
161
- blockQuote: F,
162
- codeFenced: ce,
163
- codeFencedFenceInfo: z,
164
- codeFencedFenceMeta: z,
165
- codeIndented: he,
166
- codeText: X,
167
- content: Ue,
168
- definition: nt,
169
- definitionDestinationString: qe,
170
- definitionLabelString: z,
171
- definitionTitleString: z,
172
- emphasis: Ae,
173
- htmlFlow: ae,
174
- htmlText: ue,
175
- image: ie,
176
- label: z,
177
- link: we,
178
- listItemMarker: T,
179
- listItemValue: D,
180
- listOrdered: $,
181
- listUnordered: P,
182
- paragraph: U,
183
- reference: z,
184
- resource: _e,
185
- resourceDestinationString: ve,
186
- resourceTitleString: z,
187
- setextHeading: at,
188
- strong: Fe
189
- },
190
- exit: {
191
- atxHeading: ot,
192
- atxHeadingSequence: it,
193
- autolinkEmail: Nn,
194
- autolinkProtocol: Rn,
195
- blockQuote: W,
196
- characterEscapeValue: y,
197
- characterReferenceMarkerHexadecimal: zt,
198
- characterReferenceMarkerNumeric: zt,
199
- characterReferenceValue: Mn,
200
- codeFenced: f,
201
- codeFencedFence: re,
202
- codeFencedFenceInfo: h,
203
- codeFencedFenceMeta: M,
204
- codeFlowValue: A,
205
- codeIndented: f,
206
- codeText: Ee,
207
- codeTextData: y,
208
- data: y,
209
- definition: $e,
210
- definitionDestinationString: Ve,
211
- definitionLabelString: He,
212
- definitionTitleString: rt,
213
- emphasis: fe,
214
- hardBreakEscape: N,
215
- hardBreakTrailing: N,
216
- htmlFlow: ke,
217
- htmlFlowData: y,
218
- htmlText: ke,
219
- htmlTextData: y,
220
- image: De,
221
- label: Be,
222
- labelText: j,
223
- lineEnding: L,
224
- link: De,
225
- listOrdered: E,
226
- listUnordered: H,
227
- paragraph: ne,
228
- reference: M,
229
- referenceString: me,
230
- resource: M,
231
- resourceDestinationString: Me,
232
- resourceTitleString: tt,
233
- setextHeading: m,
234
- setextHeadingLineSequence: ut,
235
- setextHeadingText: lt,
236
- strong: An,
237
- thematicBreak: Fn
238
- }
239
- }, ...t.htmlExtensions || []])
240
- ), s = {
241
- definitions: r,
242
- tightStack: l
243
- }, d = {
244
- buffer: z,
245
- encode: k,
246
- getData: _,
247
- lineEndingIfNeeded: B,
248
- options: t,
249
- raw: C,
250
- resume: x,
251
- setData: b,
252
- tag: w
253
- };
254
- let p = t.defaultLineEnding;
255
- return g;
256
- function g(S) {
257
- let v = -1, K = 0;
258
- const de = [];
259
- let xe = [], Ce = [];
260
- for (; ++v < S.length; )
261
- !p && (S[v][1].type === "lineEnding" || S[v][1].type === "lineEndingBlank") && (p = /** @type {LineEnding} */
262
- S[v][2].sliceSerialize(S[v][1])), (S[v][1].type === "listOrdered" || S[v][1].type === "listUnordered") && (S[v][0] === "enter" ? de.push(v) : c(S.slice(de.pop(), v))), S[v][1].type === "definition" && (S[v][0] === "enter" ? (Ce = Y(Ce, S.slice(K, v)), K = v) : (xe = Y(xe, S.slice(K, v + 1)), K = v + 1));
263
- xe = Y(xe, Ce), xe = Y(xe, S.slice(K)), v = -1;
264
- const be = xe;
265
- for (u.enter.null && u.enter.null.call(d); ++v < S.length; ) {
266
- const Bt = u[be[v][0]], At = be[v][1].type, Ft = Bt[At];
267
- Rt.call(Bt, At) && Ft && Ft.call({
268
- sliceSerialize: be[v][2].sliceSerialize,
269
- ...d
270
- }, be[v][1]);
271
- }
272
- return u.exit.null && u.exit.null.call(d), i[0].join("");
273
- }
274
- function c(S) {
275
- const v = S.length;
276
- let K = 0, de = 0, xe = !1, Ce;
277
- for (; ++K < v; ) {
278
- const be = S[K];
279
- if (be[1]._container)
280
- Ce = void 0, be[0] === "enter" ? de++ : de--;
281
- else switch (be[1].type) {
282
- case "listItemPrefix": {
283
- be[0] === "exit" && (Ce = !0);
284
- break;
285
- }
286
- case "linePrefix":
287
- break;
288
- case "lineEndingBlank": {
289
- be[0] === "enter" && !de && (Ce ? Ce = void 0 : xe = !0);
290
- break;
291
- }
292
- default:
293
- Ce = void 0;
294
- }
295
- }
296
- S[0][1]._loose = xe;
297
- }
298
- function b(S, v) {
299
- s[S] = v;
300
- }
301
- function _(S) {
302
- return s[S];
303
- }
304
- function z() {
305
- i.push([]);
306
- }
307
- function x() {
308
- return i.pop().join("");
309
- }
310
- function w(S) {
311
- n && (b("lastWasTag", !0), i[i.length - 1].push(S));
312
- }
313
- function C(S) {
314
- b("lastWasTag"), i[i.length - 1].push(S);
315
- }
316
- function O() {
317
- C(p || `
318
- `);
319
- }
320
- function B() {
321
- const S = i[i.length - 1], v = S[S.length - 1], K = v ? v.charCodeAt(v.length - 1) : null;
322
- K === 10 || K === 13 || K === null || O();
323
- }
324
- function k(S) {
325
- return _("ignoreEncode") ? S : tn(S);
326
- }
327
- function M() {
328
- x();
329
- }
330
- function $(S) {
331
- l.push(!S._loose), B(), w("<ol"), b("expectFirstItem", !0);
332
- }
333
- function P(S) {
334
- l.push(!S._loose), B(), w("<ul"), b("expectFirstItem", !0);
335
- }
336
- function D(S) {
337
- if (_("expectFirstItem")) {
338
- const v = Number.parseInt(this.sliceSerialize(S), 10);
339
- v !== 1 && w(' start="' + k(String(v)) + '"');
340
- }
341
- }
342
- function T() {
343
- _("expectFirstItem") ? w(">") : V(), B(), w("<li>"), b("expectFirstItem"), b("lastWasTag");
344
- }
345
- function E() {
346
- V(), l.pop(), O(), w("</ol>");
347
- }
348
- function H() {
349
- V(), l.pop(), O(), w("</ul>");
350
- }
351
- function V() {
352
- _("lastWasTag") && !_("slurpAllLineEndings") && B(), w("</li>"), b("slurpAllLineEndings");
353
- }
354
- function F() {
355
- l.push(!1), B(), w("<blockquote>");
356
- }
357
- function W() {
358
- l.pop(), B(), w("</blockquote>"), b("slurpAllLineEndings");
359
- }
360
- function U() {
361
- l[l.length - 1] || (B(), w("<p>")), b("slurpAllLineEndings");
362
- }
363
- function ne() {
364
- l[l.length - 1] ? b("slurpAllLineEndings", !0) : w("</p>");
365
- }
366
- function ce() {
367
- B(), w("<pre><code"), b("fencesCount", 0);
368
- }
369
- function h() {
370
- const S = x();
371
- w(' class="language-' + S + '"');
372
- }
373
- function re() {
374
- const S = _("fencesCount") || 0;
375
- S || (w(">"), b("slurpOneLineEnding", !0)), b("fencesCount", S + 1);
376
- }
377
- function he() {
378
- B(), w("<pre><code>");
379
- }
380
- function f() {
381
- const S = _("fencesCount");
382
- S !== void 0 && S < 2 && s.tightStack.length > 0 && !_("lastWasTag") && O(), _("flowCodeSeenData") && B(), w("</code></pre>"), S !== void 0 && S < 2 && B(), b("flowCodeSeenData"), b("fencesCount"), b("slurpOneLineEnding");
383
- }
384
- function ie() {
385
- a.push({
386
- image: !0
387
- }), n = void 0;
388
- }
389
- function we() {
390
- a.push({});
391
- }
392
- function j(S) {
393
- a[a.length - 1].labelId = this.sliceSerialize(S);
394
- }
395
- function Be() {
396
- a[a.length - 1].label = x();
397
- }
398
- function me(S) {
399
- a[a.length - 1].referenceId = this.sliceSerialize(S);
400
- }
401
- function _e() {
402
- z(), a[a.length - 1].destination = "";
403
- }
404
- function ve() {
405
- z(), b("ignoreEncode", !0);
406
- }
407
- function Me() {
408
- a[a.length - 1].destination = x(), b("ignoreEncode");
409
- }
410
- function tt() {
411
- a[a.length - 1].title = x();
412
- }
413
- function De() {
414
- let S = a.length - 1;
415
- const v = a[S], K = v.referenceId || v.labelId, de = v.destination === void 0 ? r[Ie(K)] : v;
416
- for (n = !0; S--; )
417
- if (a[S].image) {
418
- n = void 0;
419
- break;
420
- }
421
- v.image ? (w('<img src="' + je(de.destination, t.allowDangerousProtocol ? void 0 : Xn) + '" alt="'), C(v.label), w('"')) : w('<a href="' + je(de.destination, t.allowDangerousProtocol ? void 0 : Nt) + '"'), w(de.title ? ' title="' + de.title + '"' : ""), v.image ? w(" />") : (w(">"), C(v.label), w("</a>")), a.pop();
422
- }
423
- function nt() {
424
- z(), a.push({});
425
- }
426
- function He(S) {
427
- x(), a[a.length - 1].labelId = this.sliceSerialize(S);
428
- }
429
- function qe() {
430
- z(), b("ignoreEncode", !0);
431
- }
432
- function Ve() {
433
- a[a.length - 1].destination = x(), b("ignoreEncode");
434
- }
435
- function rt() {
436
- a[a.length - 1].title = x();
437
- }
438
- function $e() {
439
- const S = a[a.length - 1], v = Ie(S.labelId);
440
- x(), Rt.call(r, v) || (r[v] = a[a.length - 1]), a.pop();
441
- }
442
- function Ue() {
443
- b("slurpAllLineEndings", !0);
444
- }
445
- function it(S) {
446
- _("headingRank") || (b("headingRank", this.sliceSerialize(S).length), B(), w("<h" + _("headingRank") + ">"));
447
- }
448
- function at() {
449
- z(), b("slurpAllLineEndings");
450
- }
451
- function lt() {
452
- b("slurpAllLineEndings", !0);
453
- }
454
- function ot() {
455
- w("</h" + _("headingRank") + ">"), b("headingRank");
456
- }
457
- function ut(S) {
458
- b("headingRank", this.sliceSerialize(S).charCodeAt(0) === 61 ? 1 : 2);
459
- }
460
- function m() {
461
- const S = x();
462
- B(), w("<h" + _("headingRank") + ">"), C(S), w("</h" + _("headingRank") + ">"), b("slurpAllLineEndings"), b("headingRank");
463
- }
464
- function y(S) {
465
- C(k(this.sliceSerialize(S)));
466
- }
467
- function L(S) {
468
- if (!_("slurpAllLineEndings")) {
469
- if (_("slurpOneLineEnding")) {
470
- b("slurpOneLineEnding");
471
- return;
472
- }
473
- if (_("inCodeText")) {
474
- C(" ");
475
- return;
476
- }
477
- C(k(this.sliceSerialize(S)));
478
- }
479
- }
480
- function A(S) {
481
- C(k(this.sliceSerialize(S))), b("flowCodeSeenData", !0);
482
- }
483
- function N() {
484
- w("<br />");
485
- }
486
- function ae() {
487
- B(), ue();
488
- }
489
- function ke() {
490
- b("ignoreEncode");
491
- }
492
- function ue() {
493
- t.allowDangerousHtml && b("ignoreEncode", !0);
494
- }
495
- function Ae() {
496
- w("<em>");
497
- }
498
- function Fe() {
499
- w("<strong>");
500
- }
501
- function X() {
502
- b("inCodeText", !0), w("<code>");
503
- }
504
- function Ee() {
505
- b("inCodeText"), w("</code>");
506
- }
507
- function fe() {
508
- w("</em>");
509
- }
510
- function An() {
511
- w("</strong>");
512
- }
513
- function Fn() {
514
- B(), w("<hr />");
515
- }
516
- function zt(S) {
517
- b("characterReferenceType", S.type);
518
- }
519
- function Mn(S) {
520
- const v = this.sliceSerialize(S), K = _("characterReferenceType") ? wt(v, _("characterReferenceType") === "characterReferenceMarkerNumeric" ? 10 : 16) : Xe(v);
521
- C(k(
522
- /** @type {string} */
523
- K
524
- )), b("characterReferenceType");
525
- }
526
- function Rn(S) {
527
- const v = this.sliceSerialize(S);
528
- w('<a href="' + je(v, t.allowDangerousProtocol ? void 0 : Nt) + '">'), C(k(v)), w("</a>");
529
- }
530
- function Nn(S) {
531
- const v = this.sliceSerialize(S);
532
- w('<a href="' + je("mailto:" + v) + '">'), C(k(v)), w("</a>");
533
- }
534
- }
535
- function q(e, t, n, r) {
536
- const i = r ? r - 1 : Number.POSITIVE_INFINITY;
537
- let a = 0;
538
- return l;
539
- function l(u) {
540
- return R(u) ? (e.enter(n), o(u)) : t(u);
541
- }
542
- function o(u) {
543
- return R(u) && a++ < i ? (e.consume(u), o) : (e.exit(n), t(u));
544
- }
545
- }
546
- const Jn = {
547
- tokenize: er
548
- };
549
- function er(e) {
550
- const t = e.attempt(this.parser.constructs.contentInitial, r, i);
551
- let n;
552
- return t;
553
- function r(o) {
554
- if (o === null) {
555
- e.consume(o);
556
- return;
557
- }
558
- return e.enter("lineEnding"), e.consume(o), e.exit("lineEnding"), q(e, t, "linePrefix");
559
- }
560
- function i(o) {
561
- return e.enter("paragraph"), a(o);
562
- }
563
- function a(o) {
564
- const u = e.enter("chunkText", {
565
- contentType: "text",
566
- previous: n
567
- });
568
- return n && (n.next = u), n = u, l(o);
569
- }
570
- function l(o) {
571
- if (o === null) {
572
- e.exit("chunkText"), e.exit("paragraph"), e.consume(o);
573
- return;
574
- }
575
- return I(o) ? (e.consume(o), e.exit("chunkText"), a) : (e.consume(o), l);
576
- }
577
- }
578
- const tr = {
579
- tokenize: nr
580
- }, Ot = {
581
- tokenize: rr
582
- };
583
- function nr(e) {
584
- const t = this, n = [];
585
- let r = 0, i, a, l;
586
- return o;
587
- function o(C) {
588
- if (r < n.length) {
589
- const O = n[r];
590
- return t.containerState = O[1], e.attempt(O[0].continuation, u, s)(C);
591
- }
592
- return s(C);
593
- }
594
- function u(C) {
595
- if (r++, t.containerState._closeFlow) {
596
- t.containerState._closeFlow = void 0, i && w();
597
- const O = t.events.length;
598
- let B = O, k;
599
- for (; B--; )
600
- if (t.events[B][0] === "exit" && t.events[B][1].type === "chunkFlow") {
601
- k = t.events[B][1].end;
602
- break;
603
- }
604
- x(r);
605
- let M = O;
606
- for (; M < t.events.length; )
607
- t.events[M][1].end = {
608
- ...k
609
- }, M++;
610
- return oe(t.events, B + 1, 0, t.events.slice(O)), t.events.length = M, s(C);
611
- }
612
- return o(C);
613
- }
614
- function s(C) {
615
- if (r === n.length) {
616
- if (!i)
617
- return g(C);
618
- if (i.currentConstruct && i.currentConstruct.concrete)
619
- return b(C);
620
- t.interrupt = !!(i.currentConstruct && !i._gfmTableDynamicInterruptHack);
621
- }
622
- return t.containerState = {}, e.check(Ot, d, p)(C);
623
- }
624
- function d(C) {
625
- return i && w(), x(r), g(C);
626
- }
627
- function p(C) {
628
- return t.parser.lazy[t.now().line] = r !== n.length, l = t.now().offset, b(C);
629
- }
630
- function g(C) {
631
- return t.containerState = {}, e.attempt(Ot, c, b)(C);
632
- }
633
- function c(C) {
634
- return r++, n.push([t.currentConstruct, t.containerState]), g(C);
635
- }
636
- function b(C) {
637
- if (C === null) {
638
- i && w(), x(0), e.consume(C);
639
- return;
640
- }
641
- return i = i || t.parser.flow(t.now()), e.enter("chunkFlow", {
642
- _tokenizer: i,
643
- contentType: "flow",
644
- previous: a
645
- }), _(C);
646
- }
647
- function _(C) {
648
- if (C === null) {
649
- z(e.exit("chunkFlow"), !0), x(0), e.consume(C);
650
- return;
651
- }
652
- return I(C) ? (e.consume(C), z(e.exit("chunkFlow")), r = 0, t.interrupt = void 0, o) : (e.consume(C), _);
653
- }
654
- function z(C, O) {
655
- const B = t.sliceStream(C);
656
- if (O && B.push(null), C.previous = a, a && (a.next = C), a = C, i.defineSkip(C.start), i.write(B), t.parser.lazy[C.start.line]) {
657
- let k = i.events.length;
658
- for (; k--; )
659
- if (
660
- // The token starts before the line ending…
661
- i.events[k][1].start.offset < l && // …and either is not ended yet…
662
- (!i.events[k][1].end || // …or ends after it.
663
- i.events[k][1].end.offset > l)
664
- )
665
- return;
666
- const M = t.events.length;
667
- let $ = M, P, D;
668
- for (; $--; )
669
- if (t.events[$][0] === "exit" && t.events[$][1].type === "chunkFlow") {
670
- if (P) {
671
- D = t.events[$][1].end;
672
- break;
673
- }
674
- P = !0;
675
- }
676
- for (x(r), k = M; k < t.events.length; )
677
- t.events[k][1].end = {
678
- ...D
679
- }, k++;
680
- oe(t.events, $ + 1, 0, t.events.slice(M)), t.events.length = k;
681
- }
682
- }
683
- function x(C) {
684
- let O = n.length;
685
- for (; O-- > C; ) {
686
- const B = n[O];
687
- t.containerState = B[1], B[0].exit.call(t, e);
688
- }
689
- n.length = C;
690
- }
691
- function w() {
692
- i.write([null]), a = void 0, i = void 0, t.containerState._closeFlow = void 0;
693
- }
694
- }
695
- function rr(e, t, n) {
696
- return q(e, e.attempt(this.parser.constructs.document, t, n), "linePrefix", this.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4);
697
- }
698
- function Ke(e) {
699
- if (e === null || J(e) || Yn(e))
700
- return 1;
701
- if (Kn(e))
702
- return 2;
703
- }
704
- function Ze(e, t, n) {
705
- const r = [];
706
- let i = -1;
707
- for (; ++i < e.length; ) {
708
- const a = e[i].resolveAll;
709
- a && !r.includes(a) && (t = a(t, n), r.push(a));
710
- }
711
- return t;
712
- }
713
- const xt = {
714
- name: "attention",
715
- resolveAll: ir,
716
- tokenize: ar
717
- };
718
- function ir(e, t) {
719
- let n = -1, r, i, a, l, o, u, s, d;
720
- for (; ++n < e.length; )
721
- if (e[n][0] === "enter" && e[n][1].type === "attentionSequence" && e[n][1]._close) {
722
- for (r = n; r--; )
723
- if (e[r][0] === "exit" && e[r][1].type === "attentionSequence" && e[r][1]._open && // If the markers are the same:
724
- t.sliceSerialize(e[r][1]).charCodeAt(0) === t.sliceSerialize(e[n][1]).charCodeAt(0)) {
725
- if ((e[r][1]._close || e[n][1]._open) && (e[n][1].end.offset - e[n][1].start.offset) % 3 && !((e[r][1].end.offset - e[r][1].start.offset + e[n][1].end.offset - e[n][1].start.offset) % 3))
726
- continue;
727
- u = e[r][1].end.offset - e[r][1].start.offset > 1 && e[n][1].end.offset - e[n][1].start.offset > 1 ? 2 : 1;
728
- const p = {
729
- ...e[r][1].end
730
- }, g = {
731
- ...e[n][1].start
732
- };
733
- Pt(p, -u), Pt(g, u), l = {
734
- type: u > 1 ? "strongSequence" : "emphasisSequence",
735
- start: p,
736
- end: {
737
- ...e[r][1].end
738
- }
739
- }, o = {
740
- type: u > 1 ? "strongSequence" : "emphasisSequence",
741
- start: {
742
- ...e[n][1].start
743
- },
744
- end: g
745
- }, a = {
746
- type: u > 1 ? "strongText" : "emphasisText",
747
- start: {
748
- ...e[r][1].end
749
- },
750
- end: {
751
- ...e[n][1].start
752
- }
753
- }, i = {
754
- type: u > 1 ? "strong" : "emphasis",
755
- start: {
756
- ...l.start
757
- },
758
- end: {
759
- ...o.end
760
- }
761
- }, e[r][1].end = {
762
- ...l.start
763
- }, e[n][1].start = {
764
- ...o.end
765
- }, s = [], e[r][1].end.offset - e[r][1].start.offset && (s = Y(s, [["enter", e[r][1], t], ["exit", e[r][1], t]])), s = Y(s, [["enter", i, t], ["enter", l, t], ["exit", l, t], ["enter", a, t]]), s = Y(s, Ze(t.parser.constructs.insideSpan.null, e.slice(r + 1, n), t)), s = Y(s, [["exit", a, t], ["enter", o, t], ["exit", o, t], ["exit", i, t]]), e[n][1].end.offset - e[n][1].start.offset ? (d = 2, s = Y(s, [["enter", e[n][1], t], ["exit", e[n][1], t]])) : d = 0, oe(e, r - 1, n - r + 3, s), n = r + s.length - d - 2;
766
- break;
767
- }
768
- }
769
- for (n = -1; ++n < e.length; )
770
- e[n][1].type === "attentionSequence" && (e[n][1].type = "data");
771
- return e;
772
- }
773
- function ar(e, t) {
774
- const n = this.parser.constructs.attentionMarkers.null, r = this.previous, i = Ke(r);
775
- let a;
776
- return l;
777
- function l(u) {
778
- return a = u, e.enter("attentionSequence"), o(u);
779
- }
780
- function o(u) {
781
- if (u === a)
782
- return e.consume(u), o;
783
- const s = e.exit("attentionSequence"), d = Ke(u), p = !d || d === 2 && i || n.includes(u), g = !i || i === 2 && d || n.includes(r);
784
- return s._open = !!(a === 42 ? p : p && (i || !g)), s._close = !!(a === 42 ? g : g && (d || !p)), t(u);
785
- }
786
- }
787
- function Pt(e, t) {
788
- e.column += t, e.offset += t, e._bufferIndex += t;
789
- }
790
- const lr = {
791
- name: "autolink",
792
- tokenize: or
793
- };
794
- function or(e, t, n) {
795
- let r = 0;
796
- return i;
797
- function i(c) {
798
- return e.enter("autolink"), e.enter("autolinkMarker"), e.consume(c), e.exit("autolinkMarker"), e.enter("autolinkProtocol"), a;
799
- }
800
- function a(c) {
801
- return ye(c) ? (e.consume(c), l) : c === 64 ? n(c) : s(c);
802
- }
803
- function l(c) {
804
- return c === 43 || c === 45 || c === 46 || le(c) ? (r = 1, o(c)) : s(c);
805
- }
806
- function o(c) {
807
- return c === 58 ? (e.consume(c), r = 0, u) : (c === 43 || c === 45 || c === 46 || le(c)) && r++ < 32 ? (e.consume(c), o) : (r = 0, s(c));
808
- }
809
- function u(c) {
810
- return c === 62 ? (e.exit("autolinkProtocol"), e.enter("autolinkMarker"), e.consume(c), e.exit("autolinkMarker"), e.exit("autolink"), t) : c === null || c === 32 || c === 60 || mt(c) ? n(c) : (e.consume(c), u);
811
- }
812
- function s(c) {
813
- return c === 64 ? (e.consume(c), d) : jn(c) ? (e.consume(c), s) : n(c);
814
- }
815
- function d(c) {
816
- return le(c) ? p(c) : n(c);
817
- }
818
- function p(c) {
819
- return c === 46 ? (e.consume(c), r = 0, d) : c === 62 ? (e.exit("autolinkProtocol").type = "autolinkEmail", e.enter("autolinkMarker"), e.consume(c), e.exit("autolinkMarker"), e.exit("autolink"), t) : g(c);
820
- }
821
- function g(c) {
822
- if ((c === 45 || le(c)) && r++ < 63) {
823
- const b = c === 45 ? g : p;
824
- return e.consume(c), b;
825
- }
826
- return n(c);
827
- }
828
- }
829
- const Je = {
830
- partial: !0,
831
- tokenize: ur
832
- };
833
- function ur(e, t, n) {
834
- return r;
835
- function r(a) {
836
- return R(a) ? q(e, i, "linePrefix")(a) : i(a);
837
- }
838
- function i(a) {
839
- return a === null || I(a) ? t(a) : n(a);
840
- }
841
- }
842
- const nn = {
843
- continuation: {
844
- tokenize: cr
845
- },
846
- exit: hr,
847
- name: "blockQuote",
848
- tokenize: sr
849
- };
850
- function sr(e, t, n) {
851
- const r = this;
852
- return i;
853
- function i(l) {
854
- if (l === 62) {
855
- const o = r.containerState;
856
- return o.open || (e.enter("blockQuote", {
857
- _container: !0
858
- }), o.open = !0), e.enter("blockQuotePrefix"), e.enter("blockQuoteMarker"), e.consume(l), e.exit("blockQuoteMarker"), a;
859
- }
860
- return n(l);
861
- }
862
- function a(l) {
863
- return R(l) ? (e.enter("blockQuotePrefixWhitespace"), e.consume(l), e.exit("blockQuotePrefixWhitespace"), e.exit("blockQuotePrefix"), t) : (e.exit("blockQuotePrefix"), t(l));
864
- }
865
- }
866
- function cr(e, t, n) {
867
- const r = this;
868
- return i;
869
- function i(l) {
870
- return R(l) ? q(e, a, "linePrefix", r.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(l) : a(l);
871
- }
872
- function a(l) {
873
- return e.attempt(nn, t, n)(l);
874
- }
875
- }
876
- function hr(e) {
877
- e.exit("blockQuote");
878
- }
879
- const rn = {
880
- name: "characterEscape",
881
- tokenize: fr
882
- };
883
- function fr(e, t, n) {
884
- return r;
885
- function r(a) {
886
- return e.enter("characterEscape"), e.enter("escapeMarker"), e.consume(a), e.exit("escapeMarker"), i;
887
- }
888
- function i(a) {
889
- return Qn(a) ? (e.enter("characterEscapeValue"), e.consume(a), e.exit("characterEscapeValue"), e.exit("characterEscape"), t) : n(a);
890
- }
891
- }
892
- const an = {
893
- name: "characterReference",
894
- tokenize: dr
895
- };
896
- function dr(e, t, n) {
897
- const r = this;
898
- let i = 0, a, l;
899
- return o;
900
- function o(p) {
901
- return e.enter("characterReference"), e.enter("characterReferenceMarker"), e.consume(p), e.exit("characterReferenceMarker"), u;
902
- }
903
- function u(p) {
904
- return p === 35 ? (e.enter("characterReferenceMarkerNumeric"), e.consume(p), e.exit("characterReferenceMarkerNumeric"), s) : (e.enter("characterReferenceValue"), a = 31, l = le, d(p));
905
- }
906
- function s(p) {
907
- return p === 88 || p === 120 ? (e.enter("characterReferenceMarkerHexadecimal"), e.consume(p), e.exit("characterReferenceMarkerHexadecimal"), e.enter("characterReferenceValue"), a = 6, l = Wn, d) : (e.enter("characterReferenceValue"), a = 7, l = kt, d(p));
908
- }
909
- function d(p) {
910
- if (p === 59 && i) {
911
- const g = e.exit("characterReferenceValue");
912
- return l === le && !Xe(r.sliceSerialize(g)) ? n(p) : (e.enter("characterReferenceMarker"), e.consume(p), e.exit("characterReferenceMarker"), e.exit("characterReference"), t);
913
- }
914
- return l(p) && i++ < a ? (e.consume(p), d) : n(p);
915
- }
916
- }
917
- const Dt = {
918
- partial: !0,
919
- tokenize: gr
920
- }, Ht = {
921
- concrete: !0,
922
- name: "codeFenced",
923
- tokenize: pr
924
- };
925
- function pr(e, t, n) {
926
- const r = this, i = {
927
- partial: !0,
928
- tokenize: B
929
- };
930
- let a = 0, l = 0, o;
931
- return u;
932
- function u(k) {
933
- return s(k);
934
- }
935
- function s(k) {
936
- const M = r.events[r.events.length - 1];
937
- return a = M && M[1].type === "linePrefix" ? M[2].sliceSerialize(M[1], !0).length : 0, o = k, e.enter("codeFenced"), e.enter("codeFencedFence"), e.enter("codeFencedFenceSequence"), d(k);
938
- }
939
- function d(k) {
940
- return k === o ? (l++, e.consume(k), d) : l < 3 ? n(k) : (e.exit("codeFencedFenceSequence"), R(k) ? q(e, p, "whitespace")(k) : p(k));
941
- }
942
- function p(k) {
943
- return k === null || I(k) ? (e.exit("codeFencedFence"), r.interrupt ? t(k) : e.check(Dt, _, O)(k)) : (e.enter("codeFencedFenceInfo"), e.enter("chunkString", {
944
- contentType: "string"
945
- }), g(k));
946
- }
947
- function g(k) {
948
- return k === null || I(k) ? (e.exit("chunkString"), e.exit("codeFencedFenceInfo"), p(k)) : R(k) ? (e.exit("chunkString"), e.exit("codeFencedFenceInfo"), q(e, c, "whitespace")(k)) : k === 96 && k === o ? n(k) : (e.consume(k), g);
949
- }
950
- function c(k) {
951
- return k === null || I(k) ? p(k) : (e.enter("codeFencedFenceMeta"), e.enter("chunkString", {
952
- contentType: "string"
953
- }), b(k));
954
- }
955
- function b(k) {
956
- return k === null || I(k) ? (e.exit("chunkString"), e.exit("codeFencedFenceMeta"), p(k)) : k === 96 && k === o ? n(k) : (e.consume(k), b);
957
- }
958
- function _(k) {
959
- return e.attempt(i, O, z)(k);
960
- }
961
- function z(k) {
962
- return e.enter("lineEnding"), e.consume(k), e.exit("lineEnding"), x;
963
- }
964
- function x(k) {
965
- return a > 0 && R(k) ? q(e, w, "linePrefix", a + 1)(k) : w(k);
966
- }
967
- function w(k) {
968
- return k === null || I(k) ? e.check(Dt, _, O)(k) : (e.enter("codeFlowValue"), C(k));
969
- }
970
- function C(k) {
971
- return k === null || I(k) ? (e.exit("codeFlowValue"), w(k)) : (e.consume(k), C);
972
- }
973
- function O(k) {
974
- return e.exit("codeFenced"), t(k);
975
- }
976
- function B(k, M, $) {
977
- let P = 0;
978
- return D;
979
- function D(F) {
980
- return k.enter("lineEnding"), k.consume(F), k.exit("lineEnding"), T;
981
- }
982
- function T(F) {
983
- return k.enter("codeFencedFence"), R(F) ? q(k, E, "linePrefix", r.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(F) : E(F);
984
- }
985
- function E(F) {
986
- return F === o ? (k.enter("codeFencedFenceSequence"), H(F)) : $(F);
987
- }
988
- function H(F) {
989
- return F === o ? (P++, k.consume(F), H) : P >= l ? (k.exit("codeFencedFenceSequence"), R(F) ? q(k, V, "whitespace")(F) : V(F)) : $(F);
990
- }
991
- function V(F) {
992
- return F === null || I(F) ? (k.exit("codeFencedFence"), M(F)) : $(F);
993
- }
994
- }
995
- }
996
- function gr(e, t, n) {
997
- const r = this;
998
- return i;
999
- function i(l) {
1000
- return l === null ? n(l) : (e.enter("lineEnding"), e.consume(l), e.exit("lineEnding"), a);
1001
- }
1002
- function a(l) {
1003
- return r.parser.lazy[r.now().line] ? n(l) : t(l);
1004
- }
1005
- }
1006
- const st = {
1007
- name: "codeIndented",
1008
- tokenize: kr
1009
- }, mr = {
1010
- partial: !0,
1011
- tokenize: xr
1012
- };
1013
- function kr(e, t, n) {
1014
- const r = this;
1015
- return i;
1016
- function i(s) {
1017
- return e.enter("codeIndented"), q(e, a, "linePrefix", 5)(s);
1018
- }
1019
- function a(s) {
1020
- const d = r.events[r.events.length - 1];
1021
- return d && d[1].type === "linePrefix" && d[2].sliceSerialize(d[1], !0).length >= 4 ? l(s) : n(s);
1022
- }
1023
- function l(s) {
1024
- return s === null ? u(s) : I(s) ? e.attempt(mr, l, u)(s) : (e.enter("codeFlowValue"), o(s));
1025
- }
1026
- function o(s) {
1027
- return s === null || I(s) ? (e.exit("codeFlowValue"), l(s)) : (e.consume(s), o);
1028
- }
1029
- function u(s) {
1030
- return e.exit("codeIndented"), t(s);
1031
- }
1032
- }
1033
- function xr(e, t, n) {
1034
- const r = this;
1035
- return i;
1036
- function i(l) {
1037
- return r.parser.lazy[r.now().line] ? n(l) : I(l) ? (e.enter("lineEnding"), e.consume(l), e.exit("lineEnding"), i) : q(e, a, "linePrefix", 5)(l);
1038
- }
1039
- function a(l) {
1040
- const o = r.events[r.events.length - 1];
1041
- return o && o[1].type === "linePrefix" && o[2].sliceSerialize(o[1], !0).length >= 4 ? t(l) : I(l) ? i(l) : n(l);
1042
- }
1043
- }
1044
- const br = {
1045
- name: "codeText",
1046
- previous: Sr,
1047
- resolve: yr,
1048
- tokenize: wr
1049
- };
1050
- function yr(e) {
1051
- let t = e.length - 4, n = 3, r, i;
1052
- if ((e[n][1].type === "lineEnding" || e[n][1].type === "space") && (e[t][1].type === "lineEnding" || e[t][1].type === "space")) {
1053
- for (r = n; ++r < t; )
1054
- if (e[r][1].type === "codeTextData") {
1055
- e[n][1].type = "codeTextPadding", e[t][1].type = "codeTextPadding", n += 2, t -= 2;
1056
- break;
1057
- }
1058
- }
1059
- for (r = n - 1, t++; ++r <= t; )
1060
- i === void 0 ? r !== t && e[r][1].type !== "lineEnding" && (i = r) : (r === t || e[r][1].type === "lineEnding") && (e[i][1].type = "codeTextData", r !== i + 2 && (e[i][1].end = e[r - 1][1].end, e.splice(i + 2, r - i - 2), t -= r - i - 2, r = i + 2), i = void 0);
1061
- return e;
1062
- }
1063
- function Sr(e) {
1064
- return e !== 96 || this.events[this.events.length - 1][1].type === "characterEscape";
1065
- }
1066
- function wr(e, t, n) {
1067
- let r = 0, i, a;
1068
- return l;
1069
- function l(p) {
1070
- return e.enter("codeText"), e.enter("codeTextSequence"), o(p);
1071
- }
1072
- function o(p) {
1073
- return p === 96 ? (e.consume(p), r++, o) : (e.exit("codeTextSequence"), u(p));
1074
- }
1075
- function u(p) {
1076
- return p === null ? n(p) : p === 32 ? (e.enter("space"), e.consume(p), e.exit("space"), u) : p === 96 ? (a = e.enter("codeTextSequence"), i = 0, d(p)) : I(p) ? (e.enter("lineEnding"), e.consume(p), e.exit("lineEnding"), u) : (e.enter("codeTextData"), s(p));
1077
- }
1078
- function s(p) {
1079
- return p === null || p === 32 || p === 96 || I(p) ? (e.exit("codeTextData"), u(p)) : (e.consume(p), s);
1080
- }
1081
- function d(p) {
1082
- return p === 96 ? (e.consume(p), i++, d) : i === r ? (e.exit("codeTextSequence"), e.exit("codeText"), t(p)) : (a.type = "codeTextData", s(p));
1083
- }
1084
- }
1085
- class Cr {
1086
- /**
1087
- * @param {ReadonlyArray<T> | null | undefined} [initial]
1088
- * Initial items (optional).
1089
- * @returns
1090
- * Splice buffer.
1091
- */
1092
- constructor(t) {
1093
- this.left = t ? [...t] : [], this.right = [];
1094
- }
1095
- /**
1096
- * Array access;
1097
- * does not move the cursor.
1098
- *
1099
- * @param {number} index
1100
- * Index.
1101
- * @return {T}
1102
- * Item.
1103
- */
1104
- get(t) {
1105
- if (t < 0 || t >= this.left.length + this.right.length)
1106
- throw new RangeError("Cannot access index `" + t + "` in a splice buffer of size `" + (this.left.length + this.right.length) + "`");
1107
- return t < this.left.length ? this.left[t] : this.right[this.right.length - t + this.left.length - 1];
1108
- }
1109
- /**
1110
- * The length of the splice buffer, one greater than the largest index in the
1111
- * array.
1112
- */
1113
- get length() {
1114
- return this.left.length + this.right.length;
1115
- }
1116
- /**
1117
- * Remove and return `list[0]`;
1118
- * moves the cursor to `0`.
1119
- *
1120
- * @returns {T | undefined}
1121
- * Item, optional.
1122
- */
1123
- shift() {
1124
- return this.setCursor(0), this.right.pop();
1125
- }
1126
- /**
1127
- * Slice the buffer to get an array;
1128
- * does not move the cursor.
1129
- *
1130
- * @param {number} start
1131
- * Start.
1132
- * @param {number | null | undefined} [end]
1133
- * End (optional).
1134
- * @returns {Array<T>}
1135
- * Array of items.
1136
- */
1137
- slice(t, n) {
1138
- const r = n ?? Number.POSITIVE_INFINITY;
1139
- return r < this.left.length ? this.left.slice(t, r) : t > this.left.length ? this.right.slice(this.right.length - r + this.left.length, this.right.length - t + this.left.length).reverse() : this.left.slice(t).concat(this.right.slice(this.right.length - r + this.left.length).reverse());
1140
- }
1141
- /**
1142
- * Mimics the behavior of Array.prototype.splice() except for the change of
1143
- * interface necessary to avoid segfaults when patching in very large arrays.
1144
- *
1145
- * This operation moves cursor is moved to `start` and results in the cursor
1146
- * placed after any inserted items.
1147
- *
1148
- * @param {number} start
1149
- * Start;
1150
- * zero-based index at which to start changing the array;
1151
- * negative numbers count backwards from the end of the array and values
1152
- * that are out-of bounds are clamped to the appropriate end of the array.
1153
- * @param {number | null | undefined} [deleteCount=0]
1154
- * Delete count (default: `0`);
1155
- * maximum number of elements to delete, starting from start.
1156
- * @param {Array<T> | null | undefined} [items=[]]
1157
- * Items to include in place of the deleted items (default: `[]`).
1158
- * @return {Array<T>}
1159
- * Any removed items.
1160
- */
1161
- splice(t, n, r) {
1162
- const i = n || 0;
1163
- this.setCursor(Math.trunc(t));
1164
- const a = this.right.splice(this.right.length - i, Number.POSITIVE_INFINITY);
1165
- return r && Re(this.left, r), a.reverse();
1166
- }
1167
- /**
1168
- * Remove and return the highest-numbered item in the array, so
1169
- * `list[list.length - 1]`;
1170
- * Moves the cursor to `length`.
1171
- *
1172
- * @returns {T | undefined}
1173
- * Item, optional.
1174
- */
1175
- pop() {
1176
- return this.setCursor(Number.POSITIVE_INFINITY), this.left.pop();
1177
- }
1178
- /**
1179
- * Inserts a single item to the high-numbered side of the array;
1180
- * moves the cursor to `length`.
1181
- *
1182
- * @param {T} item
1183
- * Item.
1184
- * @returns {undefined}
1185
- * Nothing.
1186
- */
1187
- push(t) {
1188
- this.setCursor(Number.POSITIVE_INFINITY), this.left.push(t);
1189
- }
1190
- /**
1191
- * Inserts many items to the high-numbered side of the array.
1192
- * Moves the cursor to `length`.
1193
- *
1194
- * @param {Array<T>} items
1195
- * Items.
1196
- * @returns {undefined}
1197
- * Nothing.
1198
- */
1199
- pushMany(t) {
1200
- this.setCursor(Number.POSITIVE_INFINITY), Re(this.left, t);
1201
- }
1202
- /**
1203
- * Inserts a single item to the low-numbered side of the array;
1204
- * Moves the cursor to `0`.
1205
- *
1206
- * @param {T} item
1207
- * Item.
1208
- * @returns {undefined}
1209
- * Nothing.
1210
- */
1211
- unshift(t) {
1212
- this.setCursor(0), this.right.push(t);
1213
- }
1214
- /**
1215
- * Inserts many items to the low-numbered side of the array;
1216
- * moves the cursor to `0`.
1217
- *
1218
- * @param {Array<T>} items
1219
- * Items.
1220
- * @returns {undefined}
1221
- * Nothing.
1222
- */
1223
- unshiftMany(t) {
1224
- this.setCursor(0), Re(this.right, t.reverse());
1225
- }
1226
- /**
1227
- * Move the cursor to a specific position in the array. Requires
1228
- * time proportional to the distance moved.
1229
- *
1230
- * If `n < 0`, the cursor will end up at the beginning.
1231
- * If `n > length`, the cursor will end up at the end.
1232
- *
1233
- * @param {number} n
1234
- * Position.
1235
- * @return {undefined}
1236
- * Nothing.
1237
- */
1238
- setCursor(t) {
1239
- if (!(t === this.left.length || t > this.left.length && this.right.length === 0 || t < 0 && this.left.length === 0))
1240
- if (t < this.left.length) {
1241
- const n = this.left.splice(t, Number.POSITIVE_INFINITY);
1242
- Re(this.right, n.reverse());
1243
- } else {
1244
- const n = this.right.splice(this.left.length + this.right.length - t, Number.POSITIVE_INFINITY);
1245
- Re(this.left, n.reverse());
1246
- }
1247
- }
1248
- }
1249
- function Re(e, t) {
1250
- let n = 0;
1251
- if (t.length < 1e4)
1252
- e.push(...t);
1253
- else
1254
- for (; n < t.length; )
1255
- e.push(...t.slice(n, n + 1e4)), n += 1e4;
1256
- }
1257
- function ln(e) {
1258
- const t = {};
1259
- let n = -1, r, i, a, l, o, u, s;
1260
- const d = new Cr(e);
1261
- for (; ++n < d.length; ) {
1262
- for (; n in t; )
1263
- n = t[n];
1264
- if (r = d.get(n), n && r[1].type === "chunkFlow" && d.get(n - 1)[1].type === "listItemPrefix" && (u = r[1]._tokenizer.events, a = 0, a < u.length && u[a][1].type === "lineEndingBlank" && (a += 2), a < u.length && u[a][1].type === "content"))
1265
- for (; ++a < u.length && u[a][1].type !== "content"; )
1266
- u[a][1].type === "chunkText" && (u[a][1]._isInFirstContentOfListItem = !0, a++);
1267
- if (r[0] === "enter")
1268
- r[1].contentType && (Object.assign(t, _r(d, n)), n = t[n], s = !0);
1269
- else if (r[1]._container) {
1270
- for (a = n, i = void 0; a--; )
1271
- if (l = d.get(a), l[1].type === "lineEnding" || l[1].type === "lineEndingBlank")
1272
- l[0] === "enter" && (i && (d.get(i)[1].type = "lineEndingBlank"), l[1].type = "lineEnding", i = a);
1273
- else if (!(l[1].type === "linePrefix" || l[1].type === "listItemIndent")) break;
1274
- i && (r[1].end = {
1275
- ...d.get(i)[1].start
1276
- }, o = d.slice(i, n), o.unshift(r), d.splice(i, n - i + 1, o));
1277
- }
1278
- }
1279
- return oe(e, 0, Number.POSITIVE_INFINITY, d.slice(0)), !s;
1280
- }
1281
- function _r(e, t) {
1282
- const n = e.get(t)[1], r = e.get(t)[2];
1283
- let i = t - 1;
1284
- const a = [];
1285
- let l = n._tokenizer;
1286
- l || (l = r.parser[n.contentType](n.start), n._contentTypeTextTrailing && (l._contentTypeTextTrailing = !0));
1287
- const o = l.events, u = [], s = {};
1288
- let d, p, g = -1, c = n, b = 0, _ = 0;
1289
- const z = [_];
1290
- for (; c; ) {
1291
- for (; e.get(++i)[1] !== c; )
1292
- ;
1293
- a.push(i), c._tokenizer || (d = r.sliceStream(c), c.next || d.push(null), p && l.defineSkip(c.start), c._isInFirstContentOfListItem && (l._gfmTasklistFirstContentOfListItem = !0), l.write(d), c._isInFirstContentOfListItem && (l._gfmTasklistFirstContentOfListItem = void 0)), p = c, c = c.next;
1294
- }
1295
- for (c = n; ++g < o.length; )
1296
- // Find a void token that includes a break.
1297
- o[g][0] === "exit" && o[g - 1][0] === "enter" && o[g][1].type === o[g - 1][1].type && o[g][1].start.line !== o[g][1].end.line && (_ = g + 1, z.push(_), c._tokenizer = void 0, c.previous = void 0, c = c.next);
1298
- for (l.events = [], c ? (c._tokenizer = void 0, c.previous = void 0) : z.pop(), g = z.length; g--; ) {
1299
- const x = o.slice(z[g], z[g + 1]), w = a.pop();
1300
- u.push([w, w + x.length - 1]), e.splice(w, 2, x);
1301
- }
1302
- for (u.reverse(), g = -1; ++g < u.length; )
1303
- s[b + u[g][0]] = b + u[g][1], b += u[g][1] - u[g][0] - 1;
1304
- return s;
1305
- }
1306
- const vr = {
1307
- resolve: Tr,
1308
- tokenize: Ir
1309
- }, Er = {
1310
- partial: !0,
1311
- tokenize: Lr
1312
- };
1313
- function Tr(e) {
1314
- return ln(e), e;
1315
- }
1316
- function Ir(e, t) {
1317
- let n;
1318
- return r;
1319
- function r(o) {
1320
- return e.enter("content"), n = e.enter("chunkContent", {
1321
- contentType: "content"
1322
- }), i(o);
1323
- }
1324
- function i(o) {
1325
- return o === null ? a(o) : I(o) ? e.check(Er, l, a)(o) : (e.consume(o), i);
1326
- }
1327
- function a(o) {
1328
- return e.exit("chunkContent"), e.exit("content"), t(o);
1329
- }
1330
- function l(o) {
1331
- return e.consume(o), e.exit("chunkContent"), n.next = e.enter("chunkContent", {
1332
- contentType: "content",
1333
- previous: n
1334
- }), n = n.next, i;
1335
- }
1336
- }
1337
- function Lr(e, t, n) {
1338
- const r = this;
1339
- return i;
1340
- function i(l) {
1341
- return e.exit("chunkContent"), e.enter("lineEnding"), e.consume(l), e.exit("lineEnding"), q(e, a, "linePrefix");
1342
- }
1343
- function a(l) {
1344
- if (l === null || I(l))
1345
- return n(l);
1346
- const o = r.events[r.events.length - 1];
1347
- return !r.parser.constructs.disable.null.includes("codeIndented") && o && o[1].type === "linePrefix" && o[2].sliceSerialize(o[1], !0).length >= 4 ? t(l) : e.interrupt(r.parser.constructs.flow, n, t)(l);
1348
- }
1349
- }
1350
- function on(e, t, n, r, i, a, l, o, u) {
1351
- const s = u || Number.POSITIVE_INFINITY;
1352
- let d = 0;
1353
- return p;
1354
- function p(x) {
1355
- return x === 60 ? (e.enter(r), e.enter(i), e.enter(a), e.consume(x), e.exit(a), g) : x === null || x === 32 || x === 41 || mt(x) ? n(x) : (e.enter(r), e.enter(l), e.enter(o), e.enter("chunkString", {
1356
- contentType: "string"
1357
- }), _(x));
1358
- }
1359
- function g(x) {
1360
- return x === 62 ? (e.enter(a), e.consume(x), e.exit(a), e.exit(i), e.exit(r), t) : (e.enter(o), e.enter("chunkString", {
1361
- contentType: "string"
1362
- }), c(x));
1363
- }
1364
- function c(x) {
1365
- return x === 62 ? (e.exit("chunkString"), e.exit(o), g(x)) : x === null || x === 60 || I(x) ? n(x) : (e.consume(x), x === 92 ? b : c);
1366
- }
1367
- function b(x) {
1368
- return x === 60 || x === 62 || x === 92 ? (e.consume(x), c) : c(x);
1369
- }
1370
- function _(x) {
1371
- return !d && (x === null || x === 41 || J(x)) ? (e.exit("chunkString"), e.exit(o), e.exit(l), e.exit(r), t(x)) : d < s && x === 40 ? (e.consume(x), d++, _) : x === 41 ? (e.consume(x), d--, _) : x === null || x === 32 || x === 40 || mt(x) ? n(x) : (e.consume(x), x === 92 ? z : _);
1372
- }
1373
- function z(x) {
1374
- return x === 40 || x === 41 || x === 92 ? (e.consume(x), _) : _(x);
1375
- }
1376
- }
1377
- function un(e, t, n, r, i, a) {
1378
- const l = this;
1379
- let o = 0, u;
1380
- return s;
1381
- function s(c) {
1382
- return e.enter(r), e.enter(i), e.consume(c), e.exit(i), e.enter(a), d;
1383
- }
1384
- function d(c) {
1385
- return o > 999 || c === null || c === 91 || c === 93 && !u || // To do: remove in the future once we’ve switched from
1386
- // `micromark-extension-footnote` to `micromark-extension-gfm-footnote`,
1387
- // which doesn’t need this.
1388
- // Hidden footnotes hook.
1389
- /* c8 ignore next 3 */
1390
- c === 94 && !o && "_hiddenFootnoteSupport" in l.parser.constructs ? n(c) : c === 93 ? (e.exit(a), e.enter(i), e.consume(c), e.exit(i), e.exit(r), t) : I(c) ? (e.enter("lineEnding"), e.consume(c), e.exit("lineEnding"), d) : (e.enter("chunkString", {
1391
- contentType: "string"
1392
- }), p(c));
1393
- }
1394
- function p(c) {
1395
- return c === null || c === 91 || c === 93 || I(c) || o++ > 999 ? (e.exit("chunkString"), d(c)) : (e.consume(c), u || (u = !R(c)), c === 92 ? g : p);
1396
- }
1397
- function g(c) {
1398
- return c === 91 || c === 92 || c === 93 ? (e.consume(c), o++, p) : p(c);
1399
- }
1400
- }
1401
- function sn(e, t, n, r, i, a) {
1402
- let l;
1403
- return o;
1404
- function o(g) {
1405
- return g === 34 || g === 39 || g === 40 ? (e.enter(r), e.enter(i), e.consume(g), e.exit(i), l = g === 40 ? 41 : g, u) : n(g);
1406
- }
1407
- function u(g) {
1408
- return g === l ? (e.enter(i), e.consume(g), e.exit(i), e.exit(r), t) : (e.enter(a), s(g));
1409
- }
1410
- function s(g) {
1411
- return g === l ? (e.exit(a), u(l)) : g === null ? n(g) : I(g) ? (e.enter("lineEnding"), e.consume(g), e.exit("lineEnding"), q(e, s, "linePrefix")) : (e.enter("chunkString", {
1412
- contentType: "string"
1413
- }), d(g));
1414
- }
1415
- function d(g) {
1416
- return g === l || g === null || I(g) ? (e.exit("chunkString"), s(g)) : (e.consume(g), g === 92 ? p : d);
1417
- }
1418
- function p(g) {
1419
- return g === l || g === 92 ? (e.consume(g), d) : d(g);
1420
- }
1421
- }
1422
- function Oe(e, t) {
1423
- let n;
1424
- return r;
1425
- function r(i) {
1426
- return I(i) ? (e.enter("lineEnding"), e.consume(i), e.exit("lineEnding"), n = !0, r) : R(i) ? q(e, r, n ? "linePrefix" : "lineSuffix")(i) : t(i);
1427
- }
1428
- }
1429
- const zr = {
1430
- name: "definition",
1431
- tokenize: Ar
1432
- }, Br = {
1433
- partial: !0,
1434
- tokenize: Fr
1435
- };
1436
- function Ar(e, t, n) {
1437
- const r = this;
1438
- let i;
1439
- return a;
1440
- function a(c) {
1441
- return e.enter("definition"), l(c);
1442
- }
1443
- function l(c) {
1444
- return un.call(
1445
- r,
1446
- e,
1447
- o,
1448
- // Note: we don’t need to reset the way `markdown-rs` does.
1449
- n,
1450
- "definitionLabel",
1451
- "definitionLabelMarker",
1452
- "definitionLabelString"
1453
- )(c);
1454
- }
1455
- function o(c) {
1456
- return i = Ie(r.sliceSerialize(r.events[r.events.length - 1][1]).slice(1, -1)), c === 58 ? (e.enter("definitionMarker"), e.consume(c), e.exit("definitionMarker"), u) : n(c);
1457
- }
1458
- function u(c) {
1459
- return J(c) ? Oe(e, s)(c) : s(c);
1460
- }
1461
- function s(c) {
1462
- return on(
1463
- e,
1464
- d,
1465
- // Note: we don’t need to reset the way `markdown-rs` does.
1466
- n,
1467
- "definitionDestination",
1468
- "definitionDestinationLiteral",
1469
- "definitionDestinationLiteralMarker",
1470
- "definitionDestinationRaw",
1471
- "definitionDestinationString"
1472
- )(c);
1473
- }
1474
- function d(c) {
1475
- return e.attempt(Br, p, p)(c);
1476
- }
1477
- function p(c) {
1478
- return R(c) ? q(e, g, "whitespace")(c) : g(c);
1479
- }
1480
- function g(c) {
1481
- return c === null || I(c) ? (e.exit("definition"), r.parser.defined.push(i), t(c)) : n(c);
1482
- }
1483
- }
1484
- function Fr(e, t, n) {
1485
- return r;
1486
- function r(o) {
1487
- return J(o) ? Oe(e, i)(o) : n(o);
1488
- }
1489
- function i(o) {
1490
- return sn(e, a, n, "definitionTitle", "definitionTitleMarker", "definitionTitleString")(o);
1491
- }
1492
- function a(o) {
1493
- return R(o) ? q(e, l, "whitespace")(o) : l(o);
1494
- }
1495
- function l(o) {
1496
- return o === null || I(o) ? t(o) : n(o);
1497
- }
1498
- }
1499
- const Mr = {
1500
- name: "hardBreakEscape",
1501
- tokenize: Rr
1502
- };
1503
- function Rr(e, t, n) {
1504
- return r;
1505
- function r(a) {
1506
- return e.enter("hardBreakEscape"), e.consume(a), i;
1507
- }
1508
- function i(a) {
1509
- return I(a) ? (e.exit("hardBreakEscape"), t(a)) : n(a);
1510
- }
1511
- }
1512
- const Nr = {
1513
- name: "headingAtx",
1514
- resolve: Or,
1515
- tokenize: Pr
1516
- };
1517
- function Or(e, t) {
1518
- let n = e.length - 2, r = 3, i, a;
1519
- return e[r][1].type === "whitespace" && (r += 2), n - 2 > r && e[n][1].type === "whitespace" && (n -= 2), e[n][1].type === "atxHeadingSequence" && (r === n - 1 || n - 4 > r && e[n - 2][1].type === "whitespace") && (n -= r + 1 === n ? 2 : 4), n > r && (i = {
1520
- type: "atxHeadingText",
1521
- start: e[r][1].start,
1522
- end: e[n][1].end
1523
- }, a = {
1524
- type: "chunkText",
1525
- start: e[r][1].start,
1526
- end: e[n][1].end,
1527
- contentType: "text"
1528
- }, oe(e, r, n - r + 1, [["enter", i, t], ["enter", a, t], ["exit", a, t], ["exit", i, t]])), e;
1529
- }
1530
- function Pr(e, t, n) {
1531
- let r = 0;
1532
- return i;
1533
- function i(d) {
1534
- return e.enter("atxHeading"), a(d);
1535
- }
1536
- function a(d) {
1537
- return e.enter("atxHeadingSequence"), l(d);
1538
- }
1539
- function l(d) {
1540
- return d === 35 && r++ < 6 ? (e.consume(d), l) : d === null || J(d) ? (e.exit("atxHeadingSequence"), o(d)) : n(d);
1541
- }
1542
- function o(d) {
1543
- return d === 35 ? (e.enter("atxHeadingSequence"), u(d)) : d === null || I(d) ? (e.exit("atxHeading"), t(d)) : R(d) ? q(e, o, "whitespace")(d) : (e.enter("atxHeadingText"), s(d));
1544
- }
1545
- function u(d) {
1546
- return d === 35 ? (e.consume(d), u) : (e.exit("atxHeadingSequence"), o(d));
1547
- }
1548
- function s(d) {
1549
- return d === null || d === 35 || J(d) ? (e.exit("atxHeadingText"), o(d)) : (e.consume(d), s);
1550
- }
1551
- }
1552
- const Dr = [
1553
- "address",
1554
- "article",
1555
- "aside",
1556
- "base",
1557
- "basefont",
1558
- "blockquote",
1559
- "body",
1560
- "caption",
1561
- "center",
1562
- "col",
1563
- "colgroup",
1564
- "dd",
1565
- "details",
1566
- "dialog",
1567
- "dir",
1568
- "div",
1569
- "dl",
1570
- "dt",
1571
- "fieldset",
1572
- "figcaption",
1573
- "figure",
1574
- "footer",
1575
- "form",
1576
- "frame",
1577
- "frameset",
1578
- "h1",
1579
- "h2",
1580
- "h3",
1581
- "h4",
1582
- "h5",
1583
- "h6",
1584
- "head",
1585
- "header",
1586
- "hr",
1587
- "html",
1588
- "iframe",
1589
- "legend",
1590
- "li",
1591
- "link",
1592
- "main",
1593
- "menu",
1594
- "menuitem",
1595
- "nav",
1596
- "noframes",
1597
- "ol",
1598
- "optgroup",
1599
- "option",
1600
- "p",
1601
- "param",
1602
- "search",
1603
- "section",
1604
- "summary",
1605
- "table",
1606
- "tbody",
1607
- "td",
1608
- "tfoot",
1609
- "th",
1610
- "thead",
1611
- "title",
1612
- "tr",
1613
- "track",
1614
- "ul"
1615
- ], qt = ["pre", "script", "style", "textarea"], Hr = {
1616
- concrete: !0,
1617
- name: "htmlFlow",
1618
- resolveTo: $r,
1619
- tokenize: Ur
1620
- }, qr = {
1621
- partial: !0,
1622
- tokenize: Wr
1623
- }, Vr = {
1624
- partial: !0,
1625
- tokenize: jr
1626
- };
1627
- function $r(e) {
1628
- let t = e.length;
1629
- for (; t-- && !(e[t][0] === "enter" && e[t][1].type === "htmlFlow"); )
1630
- ;
1631
- return t > 1 && e[t - 2][1].type === "linePrefix" && (e[t][1].start = e[t - 2][1].start, e[t + 1][1].start = e[t - 2][1].start, e.splice(t - 2, 2)), e;
1632
- }
1633
- function Ur(e, t, n) {
1634
- const r = this;
1635
- let i, a, l, o, u;
1636
- return s;
1637
- function s(f) {
1638
- return d(f);
1639
- }
1640
- function d(f) {
1641
- return e.enter("htmlFlow"), e.enter("htmlFlowData"), e.consume(f), p;
1642
- }
1643
- function p(f) {
1644
- return f === 33 ? (e.consume(f), g) : f === 47 ? (e.consume(f), a = !0, _) : f === 63 ? (e.consume(f), i = 3, r.interrupt ? t : h) : ye(f) ? (e.consume(f), l = String.fromCharCode(f), z) : n(f);
1645
- }
1646
- function g(f) {
1647
- return f === 45 ? (e.consume(f), i = 2, c) : f === 91 ? (e.consume(f), i = 5, o = 0, b) : ye(f) ? (e.consume(f), i = 4, r.interrupt ? t : h) : n(f);
1648
- }
1649
- function c(f) {
1650
- return f === 45 ? (e.consume(f), r.interrupt ? t : h) : n(f);
1651
- }
1652
- function b(f) {
1653
- const ie = "CDATA[";
1654
- return f === ie.charCodeAt(o++) ? (e.consume(f), o === ie.length ? r.interrupt ? t : E : b) : n(f);
1655
- }
1656
- function _(f) {
1657
- return ye(f) ? (e.consume(f), l = String.fromCharCode(f), z) : n(f);
1658
- }
1659
- function z(f) {
1660
- if (f === null || f === 47 || f === 62 || J(f)) {
1661
- const ie = f === 47, we = l.toLowerCase();
1662
- return !ie && !a && qt.includes(we) ? (i = 1, r.interrupt ? t(f) : E(f)) : Dr.includes(l.toLowerCase()) ? (i = 6, ie ? (e.consume(f), x) : r.interrupt ? t(f) : E(f)) : (i = 7, r.interrupt && !r.parser.lazy[r.now().line] ? n(f) : a ? w(f) : C(f));
1663
- }
1664
- return f === 45 || le(f) ? (e.consume(f), l += String.fromCharCode(f), z) : n(f);
1665
- }
1666
- function x(f) {
1667
- return f === 62 ? (e.consume(f), r.interrupt ? t : E) : n(f);
1668
- }
1669
- function w(f) {
1670
- return R(f) ? (e.consume(f), w) : D(f);
1671
- }
1672
- function C(f) {
1673
- return f === 47 ? (e.consume(f), D) : f === 58 || f === 95 || ye(f) ? (e.consume(f), O) : R(f) ? (e.consume(f), C) : D(f);
1674
- }
1675
- function O(f) {
1676
- return f === 45 || f === 46 || f === 58 || f === 95 || le(f) ? (e.consume(f), O) : B(f);
1677
- }
1678
- function B(f) {
1679
- return f === 61 ? (e.consume(f), k) : R(f) ? (e.consume(f), B) : C(f);
1680
- }
1681
- function k(f) {
1682
- return f === null || f === 60 || f === 61 || f === 62 || f === 96 ? n(f) : f === 34 || f === 39 ? (e.consume(f), u = f, M) : R(f) ? (e.consume(f), k) : $(f);
1683
- }
1684
- function M(f) {
1685
- return f === u ? (e.consume(f), u = null, P) : f === null || I(f) ? n(f) : (e.consume(f), M);
1686
- }
1687
- function $(f) {
1688
- return f === null || f === 34 || f === 39 || f === 47 || f === 60 || f === 61 || f === 62 || f === 96 || J(f) ? B(f) : (e.consume(f), $);
1689
- }
1690
- function P(f) {
1691
- return f === 47 || f === 62 || R(f) ? C(f) : n(f);
1692
- }
1693
- function D(f) {
1694
- return f === 62 ? (e.consume(f), T) : n(f);
1695
- }
1696
- function T(f) {
1697
- return f === null || I(f) ? E(f) : R(f) ? (e.consume(f), T) : n(f);
1698
- }
1699
- function E(f) {
1700
- return f === 45 && i === 2 ? (e.consume(f), W) : f === 60 && i === 1 ? (e.consume(f), U) : f === 62 && i === 4 ? (e.consume(f), re) : f === 63 && i === 3 ? (e.consume(f), h) : f === 93 && i === 5 ? (e.consume(f), ce) : I(f) && (i === 6 || i === 7) ? (e.exit("htmlFlowData"), e.check(qr, he, H)(f)) : f === null || I(f) ? (e.exit("htmlFlowData"), H(f)) : (e.consume(f), E);
1701
- }
1702
- function H(f) {
1703
- return e.check(Vr, V, he)(f);
1704
- }
1705
- function V(f) {
1706
- return e.enter("lineEnding"), e.consume(f), e.exit("lineEnding"), F;
1707
- }
1708
- function F(f) {
1709
- return f === null || I(f) ? H(f) : (e.enter("htmlFlowData"), E(f));
1710
- }
1711
- function W(f) {
1712
- return f === 45 ? (e.consume(f), h) : E(f);
1713
- }
1714
- function U(f) {
1715
- return f === 47 ? (e.consume(f), l = "", ne) : E(f);
1716
- }
1717
- function ne(f) {
1718
- if (f === 62) {
1719
- const ie = l.toLowerCase();
1720
- return qt.includes(ie) ? (e.consume(f), re) : E(f);
1721
- }
1722
- return ye(f) && l.length < 8 ? (e.consume(f), l += String.fromCharCode(f), ne) : E(f);
1723
- }
1724
- function ce(f) {
1725
- return f === 93 ? (e.consume(f), h) : E(f);
1726
- }
1727
- function h(f) {
1728
- return f === 62 ? (e.consume(f), re) : f === 45 && i === 2 ? (e.consume(f), h) : E(f);
1729
- }
1730
- function re(f) {
1731
- return f === null || I(f) ? (e.exit("htmlFlowData"), he(f)) : (e.consume(f), re);
1732
- }
1733
- function he(f) {
1734
- return e.exit("htmlFlow"), t(f);
1735
- }
1736
- }
1737
- function jr(e, t, n) {
1738
- const r = this;
1739
- return i;
1740
- function i(l) {
1741
- return I(l) ? (e.enter("lineEnding"), e.consume(l), e.exit("lineEnding"), a) : n(l);
1742
- }
1743
- function a(l) {
1744
- return r.parser.lazy[r.now().line] ? n(l) : t(l);
1745
- }
1746
- }
1747
- function Wr(e, t, n) {
1748
- return r;
1749
- function r(i) {
1750
- return e.enter("lineEnding"), e.consume(i), e.exit("lineEnding"), e.attempt(Je, t, n);
1751
- }
1752
- }
1753
- const Qr = {
1754
- name: "htmlText",
1755
- tokenize: Kr
1756
- };
1757
- function Kr(e, t, n) {
1758
- const r = this;
1759
- let i, a, l;
1760
- return o;
1761
- function o(h) {
1762
- return e.enter("htmlText"), e.enter("htmlTextData"), e.consume(h), u;
1763
- }
1764
- function u(h) {
1765
- return h === 33 ? (e.consume(h), s) : h === 47 ? (e.consume(h), B) : h === 63 ? (e.consume(h), C) : ye(h) ? (e.consume(h), $) : n(h);
1766
- }
1767
- function s(h) {
1768
- return h === 45 ? (e.consume(h), d) : h === 91 ? (e.consume(h), a = 0, b) : ye(h) ? (e.consume(h), w) : n(h);
1769
- }
1770
- function d(h) {
1771
- return h === 45 ? (e.consume(h), c) : n(h);
1772
- }
1773
- function p(h) {
1774
- return h === null ? n(h) : h === 45 ? (e.consume(h), g) : I(h) ? (l = p, U(h)) : (e.consume(h), p);
1775
- }
1776
- function g(h) {
1777
- return h === 45 ? (e.consume(h), c) : p(h);
1778
- }
1779
- function c(h) {
1780
- return h === 62 ? W(h) : h === 45 ? g(h) : p(h);
1781
- }
1782
- function b(h) {
1783
- const re = "CDATA[";
1784
- return h === re.charCodeAt(a++) ? (e.consume(h), a === re.length ? _ : b) : n(h);
1785
- }
1786
- function _(h) {
1787
- return h === null ? n(h) : h === 93 ? (e.consume(h), z) : I(h) ? (l = _, U(h)) : (e.consume(h), _);
1788
- }
1789
- function z(h) {
1790
- return h === 93 ? (e.consume(h), x) : _(h);
1791
- }
1792
- function x(h) {
1793
- return h === 62 ? W(h) : h === 93 ? (e.consume(h), x) : _(h);
1794
- }
1795
- function w(h) {
1796
- return h === null || h === 62 ? W(h) : I(h) ? (l = w, U(h)) : (e.consume(h), w);
1797
- }
1798
- function C(h) {
1799
- return h === null ? n(h) : h === 63 ? (e.consume(h), O) : I(h) ? (l = C, U(h)) : (e.consume(h), C);
1800
- }
1801
- function O(h) {
1802
- return h === 62 ? W(h) : C(h);
1803
- }
1804
- function B(h) {
1805
- return ye(h) ? (e.consume(h), k) : n(h);
1806
- }
1807
- function k(h) {
1808
- return h === 45 || le(h) ? (e.consume(h), k) : M(h);
1809
- }
1810
- function M(h) {
1811
- return I(h) ? (l = M, U(h)) : R(h) ? (e.consume(h), M) : W(h);
1812
- }
1813
- function $(h) {
1814
- return h === 45 || le(h) ? (e.consume(h), $) : h === 47 || h === 62 || J(h) ? P(h) : n(h);
1815
- }
1816
- function P(h) {
1817
- return h === 47 ? (e.consume(h), W) : h === 58 || h === 95 || ye(h) ? (e.consume(h), D) : I(h) ? (l = P, U(h)) : R(h) ? (e.consume(h), P) : W(h);
1818
- }
1819
- function D(h) {
1820
- return h === 45 || h === 46 || h === 58 || h === 95 || le(h) ? (e.consume(h), D) : T(h);
1821
- }
1822
- function T(h) {
1823
- return h === 61 ? (e.consume(h), E) : I(h) ? (l = T, U(h)) : R(h) ? (e.consume(h), T) : P(h);
1824
- }
1825
- function E(h) {
1826
- return h === null || h === 60 || h === 61 || h === 62 || h === 96 ? n(h) : h === 34 || h === 39 ? (e.consume(h), i = h, H) : I(h) ? (l = E, U(h)) : R(h) ? (e.consume(h), E) : (e.consume(h), V);
1827
- }
1828
- function H(h) {
1829
- return h === i ? (e.consume(h), i = void 0, F) : h === null ? n(h) : I(h) ? (l = H, U(h)) : (e.consume(h), H);
1830
- }
1831
- function V(h) {
1832
- return h === null || h === 34 || h === 39 || h === 60 || h === 61 || h === 96 ? n(h) : h === 47 || h === 62 || J(h) ? P(h) : (e.consume(h), V);
1833
- }
1834
- function F(h) {
1835
- return h === 47 || h === 62 || J(h) ? P(h) : n(h);
1836
- }
1837
- function W(h) {
1838
- return h === 62 ? (e.consume(h), e.exit("htmlTextData"), e.exit("htmlText"), t) : n(h);
1839
- }
1840
- function U(h) {
1841
- return e.exit("htmlTextData"), e.enter("lineEnding"), e.consume(h), e.exit("lineEnding"), ne;
1842
- }
1843
- function ne(h) {
1844
- return R(h) ? q(e, ce, "linePrefix", r.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(h) : ce(h);
1845
- }
1846
- function ce(h) {
1847
- return e.enter("htmlTextData"), l(h);
1848
- }
1849
- }
1850
- const Ct = {
1851
- name: "labelEnd",
1852
- resolveAll: Zr,
1853
- resolveTo: Jr,
1854
- tokenize: ei
1855
- }, Yr = {
1856
- tokenize: ti
1857
- }, Gr = {
1858
- tokenize: ni
1859
- }, Xr = {
1860
- tokenize: ri
1861
- };
1862
- function Zr(e) {
1863
- let t = -1;
1864
- const n = [];
1865
- for (; ++t < e.length; ) {
1866
- const r = e[t][1];
1867
- if (n.push(e[t]), r.type === "labelImage" || r.type === "labelLink" || r.type === "labelEnd") {
1868
- const i = r.type === "labelImage" ? 4 : 2;
1869
- r.type = "data", t += i;
1870
- }
1871
- }
1872
- return e.length !== n.length && oe(e, 0, e.length, n), e;
1873
- }
1874
- function Jr(e, t) {
1875
- let n = e.length, r = 0, i, a, l, o;
1876
- for (; n--; )
1877
- if (i = e[n][1], a) {
1878
- if (i.type === "link" || i.type === "labelLink" && i._inactive)
1879
- break;
1880
- e[n][0] === "enter" && i.type === "labelLink" && (i._inactive = !0);
1881
- } else if (l) {
1882
- if (e[n][0] === "enter" && (i.type === "labelImage" || i.type === "labelLink") && !i._balanced && (a = n, i.type !== "labelLink")) {
1883
- r = 2;
1884
- break;
1885
- }
1886
- } else i.type === "labelEnd" && (l = n);
1887
- const u = {
1888
- type: e[a][1].type === "labelLink" ? "link" : "image",
1889
- start: {
1890
- ...e[a][1].start
1891
- },
1892
- end: {
1893
- ...e[e.length - 1][1].end
1894
- }
1895
- }, s = {
1896
- type: "label",
1897
- start: {
1898
- ...e[a][1].start
1899
- },
1900
- end: {
1901
- ...e[l][1].end
1902
- }
1903
- }, d = {
1904
- type: "labelText",
1905
- start: {
1906
- ...e[a + r + 2][1].end
1907
- },
1908
- end: {
1909
- ...e[l - 2][1].start
1910
- }
1911
- };
1912
- return o = [["enter", u, t], ["enter", s, t]], o = Y(o, e.slice(a + 1, a + r + 3)), o = Y(o, [["enter", d, t]]), o = Y(o, Ze(t.parser.constructs.insideSpan.null, e.slice(a + r + 4, l - 3), t)), o = Y(o, [["exit", d, t], e[l - 2], e[l - 1], ["exit", s, t]]), o = Y(o, e.slice(l + 1)), o = Y(o, [["exit", u, t]]), oe(e, a, e.length, o), e;
1913
- }
1914
- function ei(e, t, n) {
1915
- const r = this;
1916
- let i = r.events.length, a, l;
1917
- for (; i--; )
1918
- if ((r.events[i][1].type === "labelImage" || r.events[i][1].type === "labelLink") && !r.events[i][1]._balanced) {
1919
- a = r.events[i][1];
1920
- break;
1921
- }
1922
- return o;
1923
- function o(g) {
1924
- return a ? a._inactive ? p(g) : (l = r.parser.defined.includes(Ie(r.sliceSerialize({
1925
- start: a.end,
1926
- end: r.now()
1927
- }))), e.enter("labelEnd"), e.enter("labelMarker"), e.consume(g), e.exit("labelMarker"), e.exit("labelEnd"), u) : n(g);
1928
- }
1929
- function u(g) {
1930
- return g === 40 ? e.attempt(Yr, d, l ? d : p)(g) : g === 91 ? e.attempt(Gr, d, l ? s : p)(g) : l ? d(g) : p(g);
1931
- }
1932
- function s(g) {
1933
- return e.attempt(Xr, d, p)(g);
1934
- }
1935
- function d(g) {
1936
- return t(g);
1937
- }
1938
- function p(g) {
1939
- return a._balanced = !0, n(g);
1940
- }
1941
- }
1942
- function ti(e, t, n) {
1943
- return r;
1944
- function r(p) {
1945
- return e.enter("resource"), e.enter("resourceMarker"), e.consume(p), e.exit("resourceMarker"), i;
1946
- }
1947
- function i(p) {
1948
- return J(p) ? Oe(e, a)(p) : a(p);
1949
- }
1950
- function a(p) {
1951
- return p === 41 ? d(p) : on(e, l, o, "resourceDestination", "resourceDestinationLiteral", "resourceDestinationLiteralMarker", "resourceDestinationRaw", "resourceDestinationString", 32)(p);
1952
- }
1953
- function l(p) {
1954
- return J(p) ? Oe(e, u)(p) : d(p);
1955
- }
1956
- function o(p) {
1957
- return n(p);
1958
- }
1959
- function u(p) {
1960
- return p === 34 || p === 39 || p === 40 ? sn(e, s, n, "resourceTitle", "resourceTitleMarker", "resourceTitleString")(p) : d(p);
1961
- }
1962
- function s(p) {
1963
- return J(p) ? Oe(e, d)(p) : d(p);
1964
- }
1965
- function d(p) {
1966
- return p === 41 ? (e.enter("resourceMarker"), e.consume(p), e.exit("resourceMarker"), e.exit("resource"), t) : n(p);
1967
- }
1968
- }
1969
- function ni(e, t, n) {
1970
- const r = this;
1971
- return i;
1972
- function i(o) {
1973
- return un.call(r, e, a, l, "reference", "referenceMarker", "referenceString")(o);
1974
- }
1975
- function a(o) {
1976
- return r.parser.defined.includes(Ie(r.sliceSerialize(r.events[r.events.length - 1][1]).slice(1, -1))) ? t(o) : n(o);
1977
- }
1978
- function l(o) {
1979
- return n(o);
1980
- }
1981
- }
1982
- function ri(e, t, n) {
1983
- return r;
1984
- function r(a) {
1985
- return e.enter("reference"), e.enter("referenceMarker"), e.consume(a), e.exit("referenceMarker"), i;
1986
- }
1987
- function i(a) {
1988
- return a === 93 ? (e.enter("referenceMarker"), e.consume(a), e.exit("referenceMarker"), e.exit("reference"), t) : n(a);
1989
- }
1990
- }
1991
- const ii = {
1992
- name: "labelStartImage",
1993
- resolveAll: Ct.resolveAll,
1994
- tokenize: ai
1995
- };
1996
- function ai(e, t, n) {
1997
- const r = this;
1998
- return i;
1999
- function i(o) {
2000
- return e.enter("labelImage"), e.enter("labelImageMarker"), e.consume(o), e.exit("labelImageMarker"), a;
2001
- }
2002
- function a(o) {
2003
- return o === 91 ? (e.enter("labelMarker"), e.consume(o), e.exit("labelMarker"), e.exit("labelImage"), l) : n(o);
2004
- }
2005
- function l(o) {
2006
- return o === 94 && "_hiddenFootnoteSupport" in r.parser.constructs ? n(o) : t(o);
2007
- }
2008
- }
2009
- const li = {
2010
- name: "labelStartLink",
2011
- resolveAll: Ct.resolveAll,
2012
- tokenize: oi
2013
- };
2014
- function oi(e, t, n) {
2015
- const r = this;
2016
- return i;
2017
- function i(l) {
2018
- return e.enter("labelLink"), e.enter("labelMarker"), e.consume(l), e.exit("labelMarker"), e.exit("labelLink"), a;
2019
- }
2020
- function a(l) {
2021
- return l === 94 && "_hiddenFootnoteSupport" in r.parser.constructs ? n(l) : t(l);
2022
- }
2023
- }
2024
- const ct = {
2025
- name: "lineEnding",
2026
- tokenize: ui
2027
- };
2028
- function ui(e, t) {
2029
- return n;
2030
- function n(r) {
2031
- return e.enter("lineEnding"), e.consume(r), e.exit("lineEnding"), q(e, t, "linePrefix");
2032
- }
2033
- }
2034
- const We = {
2035
- name: "thematicBreak",
2036
- tokenize: si
2037
- };
2038
- function si(e, t, n) {
2039
- let r = 0, i;
2040
- return a;
2041
- function a(s) {
2042
- return e.enter("thematicBreak"), l(s);
2043
- }
2044
- function l(s) {
2045
- return i = s, o(s);
2046
- }
2047
- function o(s) {
2048
- return s === i ? (e.enter("thematicBreakSequence"), u(s)) : r >= 3 && (s === null || I(s)) ? (e.exit("thematicBreak"), t(s)) : n(s);
2049
- }
2050
- function u(s) {
2051
- return s === i ? (e.consume(s), r++, u) : (e.exit("thematicBreakSequence"), R(s) ? q(e, o, "whitespace")(s) : o(s));
2052
- }
2053
- }
2054
- const Z = {
2055
- continuation: {
2056
- tokenize: di
2057
- },
2058
- exit: gi,
2059
- name: "list",
2060
- tokenize: fi
2061
- }, ci = {
2062
- partial: !0,
2063
- tokenize: mi
2064
- }, hi = {
2065
- partial: !0,
2066
- tokenize: pi
2067
- };
2068
- function fi(e, t, n) {
2069
- const r = this, i = r.events[r.events.length - 1];
2070
- let a = i && i[1].type === "linePrefix" ? i[2].sliceSerialize(i[1], !0).length : 0, l = 0;
2071
- return o;
2072
- function o(c) {
2073
- const b = r.containerState.type || (c === 42 || c === 43 || c === 45 ? "listUnordered" : "listOrdered");
2074
- if (b === "listUnordered" ? !r.containerState.marker || c === r.containerState.marker : kt(c)) {
2075
- if (r.containerState.type || (r.containerState.type = b, e.enter(b, {
2076
- _container: !0
2077
- })), b === "listUnordered")
2078
- return e.enter("listItemPrefix"), c === 42 || c === 45 ? e.check(We, n, s)(c) : s(c);
2079
- if (!r.interrupt || c === 49)
2080
- return e.enter("listItemPrefix"), e.enter("listItemValue"), u(c);
2081
- }
2082
- return n(c);
2083
- }
2084
- function u(c) {
2085
- return kt(c) && ++l < 10 ? (e.consume(c), u) : (!r.interrupt || l < 2) && (r.containerState.marker ? c === r.containerState.marker : c === 41 || c === 46) ? (e.exit("listItemValue"), s(c)) : n(c);
2086
- }
2087
- function s(c) {
2088
- return e.enter("listItemMarker"), e.consume(c), e.exit("listItemMarker"), r.containerState.marker = r.containerState.marker || c, e.check(
2089
- Je,
2090
- // Can’t be empty when interrupting.
2091
- r.interrupt ? n : d,
2092
- e.attempt(ci, g, p)
2093
- );
2094
- }
2095
- function d(c) {
2096
- return r.containerState.initialBlankLine = !0, a++, g(c);
2097
- }
2098
- function p(c) {
2099
- return R(c) ? (e.enter("listItemPrefixWhitespace"), e.consume(c), e.exit("listItemPrefixWhitespace"), g) : n(c);
2100
- }
2101
- function g(c) {
2102
- return r.containerState.size = a + r.sliceSerialize(e.exit("listItemPrefix"), !0).length, t(c);
2103
- }
2104
- }
2105
- function di(e, t, n) {
2106
- const r = this;
2107
- return r.containerState._closeFlow = void 0, e.check(Je, i, a);
2108
- function i(o) {
2109
- return r.containerState.furtherBlankLines = r.containerState.furtherBlankLines || r.containerState.initialBlankLine, q(e, t, "listItemIndent", r.containerState.size + 1)(o);
2110
- }
2111
- function a(o) {
2112
- return r.containerState.furtherBlankLines || !R(o) ? (r.containerState.furtherBlankLines = void 0, r.containerState.initialBlankLine = void 0, l(o)) : (r.containerState.furtherBlankLines = void 0, r.containerState.initialBlankLine = void 0, e.attempt(hi, t, l)(o));
2113
- }
2114
- function l(o) {
2115
- return r.containerState._closeFlow = !0, r.interrupt = void 0, q(e, e.attempt(Z, t, n), "linePrefix", r.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(o);
2116
- }
2117
- }
2118
- function pi(e, t, n) {
2119
- const r = this;
2120
- return q(e, i, "listItemIndent", r.containerState.size + 1);
2121
- function i(a) {
2122
- const l = r.events[r.events.length - 1];
2123
- return l && l[1].type === "listItemIndent" && l[2].sliceSerialize(l[1], !0).length === r.containerState.size ? t(a) : n(a);
2124
- }
2125
- }
2126
- function gi(e) {
2127
- e.exit(this.containerState.type);
2128
- }
2129
- function mi(e, t, n) {
2130
- const r = this;
2131
- return q(e, i, "listItemPrefixWhitespace", r.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 5);
2132
- function i(a) {
2133
- const l = r.events[r.events.length - 1];
2134
- return !R(a) && l && l[1].type === "listItemPrefixWhitespace" ? t(a) : n(a);
2135
- }
2136
- }
2137
- const Vt = {
2138
- name: "setextUnderline",
2139
- resolveTo: ki,
2140
- tokenize: xi
2141
- };
2142
- function ki(e, t) {
2143
- let n = e.length, r, i, a;
2144
- for (; n--; )
2145
- if (e[n][0] === "enter") {
2146
- if (e[n][1].type === "content") {
2147
- r = n;
2148
- break;
2149
- }
2150
- e[n][1].type === "paragraph" && (i = n);
2151
- } else
2152
- e[n][1].type === "content" && e.splice(n, 1), !a && e[n][1].type === "definition" && (a = n);
2153
- const l = {
2154
- type: "setextHeading",
2155
- start: {
2156
- ...e[r][1].start
2157
- },
2158
- end: {
2159
- ...e[e.length - 1][1].end
2160
- }
2161
- };
2162
- return e[i][1].type = "setextHeadingText", a ? (e.splice(i, 0, ["enter", l, t]), e.splice(a + 1, 0, ["exit", e[r][1], t]), e[r][1].end = {
2163
- ...e[a][1].end
2164
- }) : e[r][1] = l, e.push(["exit", l, t]), e;
2165
- }
2166
- function xi(e, t, n) {
2167
- const r = this;
2168
- let i;
2169
- return a;
2170
- function a(s) {
2171
- let d = r.events.length, p;
2172
- for (; d--; )
2173
- if (r.events[d][1].type !== "lineEnding" && r.events[d][1].type !== "linePrefix" && r.events[d][1].type !== "content") {
2174
- p = r.events[d][1].type === "paragraph";
2175
- break;
2176
- }
2177
- return !r.parser.lazy[r.now().line] && (r.interrupt || p) ? (e.enter("setextHeadingLine"), i = s, l(s)) : n(s);
2178
- }
2179
- function l(s) {
2180
- return e.enter("setextHeadingLineSequence"), o(s);
2181
- }
2182
- function o(s) {
2183
- return s === i ? (e.consume(s), o) : (e.exit("setextHeadingLineSequence"), R(s) ? q(e, u, "lineSuffix")(s) : u(s));
2184
- }
2185
- function u(s) {
2186
- return s === null || I(s) ? (e.exit("setextHeadingLine"), t(s)) : n(s);
2187
- }
2188
- }
2189
- const bi = {
2190
- tokenize: yi
2191
- };
2192
- function yi(e) {
2193
- const t = this, n = e.attempt(
2194
- // Try to parse a blank line.
2195
- Je,
2196
- r,
2197
- // Try to parse initial flow (essentially, only code).
2198
- e.attempt(this.parser.constructs.flowInitial, i, q(e, e.attempt(this.parser.constructs.flow, i, e.attempt(vr, i)), "linePrefix"))
2199
- );
2200
- return n;
2201
- function r(a) {
2202
- if (a === null) {
2203
- e.consume(a);
2204
- return;
2205
- }
2206
- return e.enter("lineEndingBlank"), e.consume(a), e.exit("lineEndingBlank"), t.currentConstruct = void 0, n;
2207
- }
2208
- function i(a) {
2209
- if (a === null) {
2210
- e.consume(a);
2211
- return;
2212
- }
2213
- return e.enter("lineEnding"), e.consume(a), e.exit("lineEnding"), t.currentConstruct = void 0, n;
2214
- }
2215
- }
2216
- const Si = {
2217
- resolveAll: hn()
2218
- }, wi = cn("string"), Ci = cn("text");
2219
- function cn(e) {
2220
- return {
2221
- resolveAll: hn(e === "text" ? _i : void 0),
2222
- tokenize: t
2223
- };
2224
- function t(n) {
2225
- const r = this, i = this.parser.constructs[e], a = n.attempt(i, l, o);
2226
- return l;
2227
- function l(d) {
2228
- return s(d) ? a(d) : o(d);
2229
- }
2230
- function o(d) {
2231
- if (d === null) {
2232
- n.consume(d);
2233
- return;
2234
- }
2235
- return n.enter("data"), n.consume(d), u;
2236
- }
2237
- function u(d) {
2238
- return s(d) ? (n.exit("data"), a(d)) : (n.consume(d), u);
2239
- }
2240
- function s(d) {
2241
- if (d === null)
2242
- return !0;
2243
- const p = i[d];
2244
- let g = -1;
2245
- if (p)
2246
- for (; ++g < p.length; ) {
2247
- const c = p[g];
2248
- if (!c.previous || c.previous.call(r, r.previous))
2249
- return !0;
2250
- }
2251
- return !1;
2252
- }
2253
- }
2254
- }
2255
- function hn(e) {
2256
- return t;
2257
- function t(n, r) {
2258
- let i = -1, a;
2259
- for (; ++i <= n.length; )
2260
- a === void 0 ? n[i] && n[i][1].type === "data" && (a = i, i++) : (!n[i] || n[i][1].type !== "data") && (i !== a + 2 && (n[a][1].end = n[i - 1][1].end, n.splice(a + 2, i - a - 2), i = a + 2), a = void 0);
2261
- return e ? e(n, r) : n;
2262
- }
2263
- }
2264
- function _i(e, t) {
2265
- let n = 0;
2266
- for (; ++n <= e.length; )
2267
- if ((n === e.length || e[n][1].type === "lineEnding") && e[n - 1][1].type === "data") {
2268
- const r = e[n - 1][1], i = t.sliceStream(r);
2269
- let a = i.length, l = -1, o = 0, u;
2270
- for (; a--; ) {
2271
- const s = i[a];
2272
- if (typeof s == "string") {
2273
- for (l = s.length; s.charCodeAt(l - 1) === 32; )
2274
- o++, l--;
2275
- if (l) break;
2276
- l = -1;
2277
- } else if (s === -2)
2278
- u = !0, o++;
2279
- else if (s !== -1) {
2280
- a++;
2281
- break;
2282
- }
2283
- }
2284
- if (t._contentTypeTextTrailing && n === e.length && (o = 0), o) {
2285
- const s = {
2286
- type: n === e.length || u || o < 2 ? "lineSuffix" : "hardBreakTrailing",
2287
- start: {
2288
- _bufferIndex: a ? l : r.start._bufferIndex + l,
2289
- _index: r.start._index + a,
2290
- line: r.end.line,
2291
- column: r.end.column - o,
2292
- offset: r.end.offset - o
2293
- },
2294
- end: {
2295
- ...r.end
2296
- }
2297
- };
2298
- r.end = {
2299
- ...s.start
2300
- }, r.start.offset === r.end.offset ? Object.assign(r, s) : (e.splice(n, 0, ["enter", s, t], ["exit", s, t]), n += 2);
2301
- }
2302
- n++;
2303
- }
2304
- return e;
2305
- }
2306
- const vi = {
2307
- 42: Z,
2308
- 43: Z,
2309
- 45: Z,
2310
- 48: Z,
2311
- 49: Z,
2312
- 50: Z,
2313
- 51: Z,
2314
- 52: Z,
2315
- 53: Z,
2316
- 54: Z,
2317
- 55: Z,
2318
- 56: Z,
2319
- 57: Z,
2320
- 62: nn
2321
- }, Ei = {
2322
- 91: zr
2323
- }, Ti = {
2324
- [-2]: st,
2325
- [-1]: st,
2326
- 32: st
2327
- }, Ii = {
2328
- 35: Nr,
2329
- 42: We,
2330
- 45: [Vt, We],
2331
- 60: Hr,
2332
- 61: Vt,
2333
- 95: We,
2334
- 96: Ht,
2335
- 126: Ht
2336
- }, Li = {
2337
- 38: an,
2338
- 92: rn
2339
- }, zi = {
2340
- [-5]: ct,
2341
- [-4]: ct,
2342
- [-3]: ct,
2343
- 33: ii,
2344
- 38: an,
2345
- 42: xt,
2346
- 60: [lr, Qr],
2347
- 91: li,
2348
- 92: [Mr, rn],
2349
- 93: Ct,
2350
- 95: xt,
2351
- 96: br
2352
- }, Bi = {
2353
- null: [xt, Si]
2354
- }, Ai = {
2355
- null: [42, 95]
2356
- }, Fi = {
2357
- null: []
2358
- }, Mi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2359
- __proto__: null,
2360
- attentionMarkers: Ai,
2361
- contentInitial: Ei,
2362
- disable: Fi,
2363
- document: vi,
2364
- flow: Ii,
2365
- flowInitial: Ti,
2366
- insideSpan: Bi,
2367
- string: Li,
2368
- text: zi
2369
- }, Symbol.toStringTag, { value: "Module" }));
2370
- function Ri(e, t, n) {
2371
- let r = {
2372
- _bufferIndex: -1,
2373
- _index: 0,
2374
- line: n && n.line || 1,
2375
- column: n && n.column || 1,
2376
- offset: n && n.offset || 0
2377
- };
2378
- const i = {}, a = [];
2379
- let l = [], o = [];
2380
- const u = {
2381
- attempt: M(B),
2382
- check: M(k),
2383
- consume: w,
2384
- enter: C,
2385
- exit: O,
2386
- interrupt: M(k, {
2387
- interrupt: !0
2388
- })
2389
- }, s = {
2390
- code: null,
2391
- containerState: {},
2392
- defineSkip: _,
2393
- events: [],
2394
- now: b,
2395
- parser: e,
2396
- previous: null,
2397
- sliceSerialize: g,
2398
- sliceStream: c,
2399
- write: p
2400
- };
2401
- let d = t.tokenize.call(s, u);
2402
- return t.resolveAll && a.push(t), s;
2403
- function p(T) {
2404
- return l = Y(l, T), z(), l[l.length - 1] !== null ? [] : ($(t, 0), s.events = Ze(a, s.events, s), s.events);
2405
- }
2406
- function g(T, E) {
2407
- return Oi(c(T), E);
2408
- }
2409
- function c(T) {
2410
- return Ni(l, T);
2411
- }
2412
- function b() {
2413
- const {
2414
- _bufferIndex: T,
2415
- _index: E,
2416
- line: H,
2417
- column: V,
2418
- offset: F
2419
- } = r;
2420
- return {
2421
- _bufferIndex: T,
2422
- _index: E,
2423
- line: H,
2424
- column: V,
2425
- offset: F
2426
- };
2427
- }
2428
- function _(T) {
2429
- i[T.line] = T.column, D();
2430
- }
2431
- function z() {
2432
- let T;
2433
- for (; r._index < l.length; ) {
2434
- const E = l[r._index];
2435
- if (typeof E == "string")
2436
- for (T = r._index, r._bufferIndex < 0 && (r._bufferIndex = 0); r._index === T && r._bufferIndex < E.length; )
2437
- x(E.charCodeAt(r._bufferIndex));
2438
- else
2439
- x(E);
2440
- }
2441
- }
2442
- function x(T) {
2443
- d = d(T);
2444
- }
2445
- function w(T) {
2446
- I(T) ? (r.line++, r.column = 1, r.offset += T === -3 ? 2 : 1, D()) : T !== -1 && (r.column++, r.offset++), r._bufferIndex < 0 ? r._index++ : (r._bufferIndex++, r._bufferIndex === // Points w/ non-negative `_bufferIndex` reference
2447
- // strings.
2448
- /** @type {string} */
2449
- l[r._index].length && (r._bufferIndex = -1, r._index++)), s.previous = T;
2450
- }
2451
- function C(T, E) {
2452
- const H = E || {};
2453
- return H.type = T, H.start = b(), s.events.push(["enter", H, s]), o.push(H), H;
2454
- }
2455
- function O(T) {
2456
- const E = o.pop();
2457
- return E.end = b(), s.events.push(["exit", E, s]), E;
2458
- }
2459
- function B(T, E) {
2460
- $(T, E.from);
2461
- }
2462
- function k(T, E) {
2463
- E.restore();
2464
- }
2465
- function M(T, E) {
2466
- return H;
2467
- function H(V, F, W) {
2468
- let U, ne, ce, h;
2469
- return Array.isArray(V) ? (
2470
- /* c8 ignore next 1 */
2471
- he(V)
2472
- ) : "tokenize" in V ? (
2473
- // Looks like a construct.
2474
- he([
2475
- /** @type {Construct} */
2476
- V
2477
- ])
2478
- ) : re(V);
2479
- function re(j) {
2480
- return Be;
2481
- function Be(me) {
2482
- const _e = me !== null && j[me], ve = me !== null && j.null, Me = [
2483
- // To do: add more extension tests.
2484
- /* c8 ignore next 2 */
2485
- ...Array.isArray(_e) ? _e : _e ? [_e] : [],
2486
- ...Array.isArray(ve) ? ve : ve ? [ve] : []
2487
- ];
2488
- return he(Me)(me);
2489
- }
2490
- }
2491
- function he(j) {
2492
- return U = j, ne = 0, j.length === 0 ? W : f(j[ne]);
2493
- }
2494
- function f(j) {
2495
- return Be;
2496
- function Be(me) {
2497
- return h = P(), ce = j, j.partial || (s.currentConstruct = j), j.name && s.parser.constructs.disable.null.includes(j.name) ? we() : j.tokenize.call(
2498
- // If we do have fields, create an object w/ `context` as its
2499
- // prototype.
2500
- // This allows a “live binding”, which is needed for `interrupt`.
2501
- E ? Object.assign(Object.create(s), E) : s,
2502
- u,
2503
- ie,
2504
- we
2505
- )(me);
2506
- }
2507
- }
2508
- function ie(j) {
2509
- return T(ce, h), F;
2510
- }
2511
- function we(j) {
2512
- return h.restore(), ++ne < U.length ? f(U[ne]) : W;
2513
- }
2514
- }
2515
- }
2516
- function $(T, E) {
2517
- T.resolveAll && !a.includes(T) && a.push(T), T.resolve && oe(s.events, E, s.events.length - E, T.resolve(s.events.slice(E), s)), T.resolveTo && (s.events = T.resolveTo(s.events, s));
2518
- }
2519
- function P() {
2520
- const T = b(), E = s.previous, H = s.currentConstruct, V = s.events.length, F = Array.from(o);
2521
- return {
2522
- from: V,
2523
- restore: W
2524
- };
2525
- function W() {
2526
- r = T, s.previous = E, s.currentConstruct = H, s.events.length = V, o = F, D();
2527
- }
2528
- }
2529
- function D() {
2530
- r.line in i && r.column < 2 && (r.column = i[r.line], r.offset += i[r.line] - 1);
2531
- }
2532
- }
2533
- function Ni(e, t) {
2534
- const n = t.start._index, r = t.start._bufferIndex, i = t.end._index, a = t.end._bufferIndex;
2535
- let l;
2536
- if (n === i)
2537
- l = [e[n].slice(r, a)];
2538
- else {
2539
- if (l = e.slice(n, i), r > -1) {
2540
- const o = l[0];
2541
- typeof o == "string" ? l[0] = o.slice(r) : l.shift();
2542
- }
2543
- a > 0 && l.push(e[i].slice(0, a));
2544
- }
2545
- return l;
2546
- }
2547
- function Oi(e, t) {
2548
- let n = -1;
2549
- const r = [];
2550
- let i;
2551
- for (; ++n < e.length; ) {
2552
- const a = e[n];
2553
- let l;
2554
- if (typeof a == "string")
2555
- l = a;
2556
- else switch (a) {
2557
- case -5: {
2558
- l = "\r";
2559
- break;
2560
- }
2561
- case -4: {
2562
- l = `
2563
- `;
2564
- break;
2565
- }
2566
- case -3: {
2567
- l = `\r
2568
- `;
2569
- break;
2570
- }
2571
- case -2: {
2572
- l = t ? " " : " ";
2573
- break;
2574
- }
2575
- case -1: {
2576
- if (!t && i) continue;
2577
- l = " ";
2578
- break;
2579
- }
2580
- default:
2581
- l = String.fromCharCode(a);
2582
- }
2583
- i = a === -2, r.push(l);
2584
- }
2585
- return r.join("");
2586
- }
2587
- function fn(e) {
2588
- const r = {
2589
- constructs: (
2590
- /** @type {FullNormalizedExtension} */
2591
- Dn([Mi, ...(e || {}).extensions || []])
2592
- ),
2593
- content: i(Jn),
2594
- defined: [],
2595
- document: i(tr),
2596
- flow: i(bi),
2597
- lazy: {},
2598
- string: i(wi),
2599
- text: i(Ci)
2600
- };
2601
- return r;
2602
- function i(a) {
2603
- return l;
2604
- function l(o) {
2605
- return Ri(r, a, o);
2606
- }
2607
- }
2608
- }
2609
- function dn(e) {
2610
- for (; !ln(e); )
2611
- ;
2612
- return e;
2613
- }
2614
- const $t = /[\0\t\n\r]/g;
2615
- function pn() {
2616
- let e = 1, t = "", n = !0, r;
2617
- return i;
2618
- function i(a, l, o) {
2619
- const u = [];
2620
- let s, d, p, g, c;
2621
- for (a = t + (typeof a == "string" ? a.toString() : new TextDecoder(l || void 0).decode(a)), p = 0, t = "", n && (a.charCodeAt(0) === 65279 && p++, n = void 0); p < a.length; ) {
2622
- if ($t.lastIndex = p, s = $t.exec(a), g = s && s.index !== void 0 ? s.index : a.length, c = a.charCodeAt(g), !s) {
2623
- t = a.slice(p);
2624
- break;
2625
- }
2626
- if (c === 10 && p === g && r)
2627
- u.push(-3), r = void 0;
2628
- else
2629
- switch (r && (u.push(-5), r = void 0), p < g && (u.push(a.slice(p, g)), e += g - p), c) {
2630
- case 0: {
2631
- u.push(65533), e++;
2632
- break;
2633
- }
2634
- case 9: {
2635
- for (d = Math.ceil(e / 4) * 4, u.push(-2); e++ < d; ) u.push(-1);
2636
- break;
2637
- }
2638
- case 10: {
2639
- u.push(-4), e = 1;
2640
- break;
2641
- }
2642
- default:
2643
- r = !0, e = 1;
2644
- }
2645
- p = g + 1;
2646
- }
2647
- return o && (r && u.push(-5), t && u.push(t), u.push(null)), u;
2648
- }
2649
- }
2650
- function Pi(e, t, n) {
2651
- return typeof t != "string" && (n = t, t = void 0), Zn(n)(dn(fn(n).document().write(pn()(e, t, !0))));
2652
- }
2653
- function gn(e) {
2654
- let n = {}.singleTilde;
2655
- const r = {
2656
- name: "strikethrough",
2657
- tokenize: a,
2658
- resolveAll: i
2659
- };
2660
- return n == null && (n = !0), {
2661
- text: {
2662
- 126: r
2663
- },
2664
- insideSpan: {
2665
- null: [r]
2666
- },
2667
- attentionMarkers: {
2668
- null: [126]
2669
- }
2670
- };
2671
- function i(l, o) {
2672
- let u = -1;
2673
- for (; ++u < l.length; )
2674
- if (l[u][0] === "enter" && l[u][1].type === "strikethroughSequenceTemporary" && l[u][1]._close) {
2675
- let s = u;
2676
- for (; s--; )
2677
- if (l[s][0] === "exit" && l[s][1].type === "strikethroughSequenceTemporary" && l[s][1]._open && // If the sizes are the same:
2678
- l[u][1].end.offset - l[u][1].start.offset === l[s][1].end.offset - l[s][1].start.offset) {
2679
- l[u][1].type = "strikethroughSequence", l[s][1].type = "strikethroughSequence";
2680
- const d = {
2681
- type: "strikethrough",
2682
- start: Object.assign({}, l[s][1].start),
2683
- end: Object.assign({}, l[u][1].end)
2684
- }, p = {
2685
- type: "strikethroughText",
2686
- start: Object.assign({}, l[s][1].end),
2687
- end: Object.assign({}, l[u][1].start)
2688
- }, g = [["enter", d, o], ["enter", l[s][1], o], ["exit", l[s][1], o], ["enter", p, o]], c = o.parser.constructs.insideSpan.null;
2689
- c && oe(g, g.length, 0, Ze(c, l.slice(s + 1, u), o)), oe(g, g.length, 0, [["exit", p, o], ["enter", l[u][1], o], ["exit", l[u][1], o], ["exit", d, o]]), oe(l, s - 1, u - s + 3, g), u = s + g.length - 2;
2690
- break;
2691
- }
2692
- }
2693
- for (u = -1; ++u < l.length; )
2694
- l[u][1].type === "strikethroughSequenceTemporary" && (l[u][1].type = "data");
2695
- return l;
2696
- }
2697
- function a(l, o, u) {
2698
- const s = this.previous, d = this.events;
2699
- let p = 0;
2700
- return g;
2701
- function g(b) {
2702
- return s === 126 && d[d.length - 1][1].type !== "characterEscape" ? u(b) : (l.enter("strikethroughSequenceTemporary"), c(b));
2703
- }
2704
- function c(b) {
2705
- const _ = Ke(s);
2706
- if (b === 126)
2707
- return p > 1 ? u(b) : (l.consume(b), p++, c);
2708
- if (p < 2 && !n) return u(b);
2709
- const z = l.exit("strikethroughSequenceTemporary"), x = Ke(b);
2710
- return z._open = !x || x === 2 && !!_, z._close = !_ || _ === 2 && !!x, o(b);
2711
- }
2712
- }
2713
- }
2714
- function Di(e) {
2715
- for (var t = 1; t < arguments.length; t++) {
2716
- var n = arguments[t];
2717
- for (var r in n)
2718
- Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
2719
- }
2720
- return e;
2721
- }
2722
- function bt(e, t) {
2723
- return Array(t + 1).join(e);
2724
- }
2725
- function mn(e) {
2726
- return e.replace(/^\n*/, "");
2727
- }
2728
- function kn(e) {
2729
- for (var t = e.length; t > 0 && e[t - 1] === `
2730
- `; ) t--;
2731
- return e.substring(0, t);
2732
- }
2733
- function xn(e) {
2734
- return kn(mn(e));
2735
- }
2736
- var Hi = ["ADDRESS", "ARTICLE", "ASIDE", "AUDIO", "BLOCKQUOTE", "BODY", "CANVAS", "CENTER", "DD", "DIR", "DIV", "DL", "DT", "FIELDSET", "FIGCAPTION", "FIGURE", "FOOTER", "FORM", "FRAMESET", "H1", "H2", "H3", "H4", "H5", "H6", "HEADER", "HGROUP", "HR", "HTML", "ISINDEX", "LI", "MAIN", "MENU", "NAV", "NOFRAMES", "NOSCRIPT", "OL", "OUTPUT", "P", "PRE", "SECTION", "TABLE", "TBODY", "TD", "TFOOT", "TH", "THEAD", "TR", "UL"];
2737
- function _t(e) {
2738
- return vt(e, Hi);
2739
- }
2740
- var bn = ["AREA", "BASE", "BR", "COL", "COMMAND", "EMBED", "HR", "IMG", "INPUT", "KEYGEN", "LINK", "META", "PARAM", "SOURCE", "TRACK", "WBR"];
2741
- function yn(e) {
2742
- return vt(e, bn);
2743
- }
2744
- function qi(e) {
2745
- return wn(e, bn);
2746
- }
2747
- var Sn = ["A", "TABLE", "THEAD", "TBODY", "TFOOT", "TH", "TD", "IFRAME", "SCRIPT", "AUDIO", "VIDEO"];
2748
- function Vi(e) {
2749
- return vt(e, Sn);
2750
- }
2751
- function $i(e) {
2752
- return wn(e, Sn);
2753
- }
2754
- function vt(e, t) {
2755
- return t.indexOf(e.nodeName) >= 0;
2756
- }
2757
- function wn(e, t) {
2758
- return e.getElementsByTagName && t.some(function(n) {
2759
- return e.getElementsByTagName(n).length;
2760
- });
2761
- }
2762
- var Ui = [[/\\/g, "\\\\"], [/\*/g, "\\*"], [/^-/g, "\\-"], [/^\+ /g, "\\+ "], [/^(=+)/g, "\\$1"], [/^(#{1,6}) /g, "\\$1 "], [/`/g, "\\`"], [/^~~~/g, "\\~~~"], [/\[/g, "\\["], [/\]/g, "\\]"], [/^>/g, "\\>"], [/_/g, "\\_"], [/^(\d+)\. /g, "$1\\. "]];
2763
- function Cn(e) {
2764
- return Ui.reduce(function(t, n) {
2765
- return t.replace(n[0], n[1]);
2766
- }, e);
2767
- }
2768
- var G = {};
2769
- G.paragraph = {
2770
- filter: "p",
2771
- replacement: function(e) {
2772
- return `
2773
-
2774
- ` + e + `
2775
-
2776
- `;
2777
- }
2778
- };
2779
- G.lineBreak = {
2780
- filter: "br",
2781
- replacement: function(e, t, n) {
2782
- return n.br + `
2783
- `;
2784
- }
2785
- };
2786
- G.heading = {
2787
- filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
2788
- replacement: function(e, t, n) {
2789
- var r = Number(t.nodeName.charAt(1));
2790
- if (n.headingStyle === "setext" && r < 3) {
2791
- var i = bt(r === 1 ? "=" : "-", e.length);
2792
- return `
2793
-
2794
- ` + e + `
2795
- ` + i + `
2796
-
2797
- `;
2798
- } else
2799
- return `
2800
-
2801
- ` + bt("#", r) + " " + e + `
2802
-
2803
- `;
2804
- }
2805
- };
2806
- G.blockquote = {
2807
- filter: "blockquote",
2808
- replacement: function(e) {
2809
- return e = xn(e).replace(/^/gm, "> "), `
2810
-
2811
- ` + e + `
2812
-
2813
- `;
2814
- }
2815
- };
2816
- G.list = {
2817
- filter: ["ul", "ol"],
2818
- replacement: function(e, t) {
2819
- var n = t.parentNode;
2820
- return n.nodeName === "LI" && n.lastElementChild === t ? `
2821
- ` + e : `
2822
-
2823
- ` + e + `
2824
-
2825
- `;
2826
- }
2827
- };
2828
- G.listItem = {
2829
- filter: "li",
2830
- replacement: function(e, t, n) {
2831
- var r = n.bulletListMarker + " ", i = t.parentNode;
2832
- if (i.nodeName === "OL") {
2833
- var a = i.getAttribute("start"), l = Array.prototype.indexOf.call(i.children, t);
2834
- r = (a ? Number(a) + l : l + 1) + ". ";
2835
- }
2836
- var o = /\n$/.test(e);
2837
- return e = xn(e) + (o ? `
2838
- ` : ""), e = e.replace(/\n/gm, `
2839
- ` + " ".repeat(r.length)), r + e + (t.nextSibling ? `
2840
- ` : "");
2841
- }
2842
- };
2843
- G.indentedCodeBlock = {
2844
- filter: function(e, t) {
2845
- return t.codeBlockStyle === "indented" && e.nodeName === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE";
2846
- },
2847
- replacement: function(e, t, n) {
2848
- return `
2849
-
2850
- ` + t.firstChild.textContent.replace(/\n/g, `
2851
- `) + `
2852
-
2853
- `;
2854
- }
2855
- };
2856
- G.fencedCodeBlock = {
2857
- filter: function(e, t) {
2858
- return t.codeBlockStyle === "fenced" && e.nodeName === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE";
2859
- },
2860
- replacement: function(e, t, n) {
2861
- for (var r = t.firstChild.getAttribute("class") || "", i = (r.match(/language-(\S+)/) || [null, ""])[1], a = t.firstChild.textContent, l = n.fence.charAt(0), o = 3, u = new RegExp("^" + l + "{3,}", "gm"), s; s = u.exec(a); )
2862
- s[0].length >= o && (o = s[0].length + 1);
2863
- var d = bt(l, o);
2864
- return `
2865
-
2866
- ` + d + i + `
2867
- ` + a.replace(/\n$/, "") + `
2868
- ` + d + `
2869
-
2870
- `;
2871
- }
2872
- };
2873
- G.horizontalRule = {
2874
- filter: "hr",
2875
- replacement: function(e, t, n) {
2876
- return `
2877
-
2878
- ` + n.hr + `
2879
-
2880
- `;
2881
- }
2882
- };
2883
- G.inlineLink = {
2884
- filter: function(e, t) {
2885
- return t.linkStyle === "inlined" && e.nodeName === "A" && e.getAttribute("href");
2886
- },
2887
- replacement: function(e, t) {
2888
- var n = Et(t.getAttribute("href")), r = Tt(Ye(t.getAttribute("title"))), i = r ? ' "' + r + '"' : "";
2889
- return "[" + e + "](" + n + i + ")";
2890
- }
2891
- };
2892
- G.referenceLink = {
2893
- filter: function(e, t) {
2894
- return t.linkStyle === "referenced" && e.nodeName === "A" && e.getAttribute("href");
2895
- },
2896
- replacement: function(e, t, n) {
2897
- var r = Et(t.getAttribute("href")), i = Ye(t.getAttribute("title"));
2898
- i && (i = ' "' + Tt(i) + '"');
2899
- var a, l;
2900
- switch (n.linkReferenceStyle) {
2901
- case "collapsed":
2902
- a = "[" + e + "][]", l = "[" + e + "]: " + r + i;
2903
- break;
2904
- case "shortcut":
2905
- a = "[" + e + "]", l = "[" + e + "]: " + r + i;
2906
- break;
2907
- default:
2908
- var o = this.references.length + 1;
2909
- a = "[" + e + "][" + o + "]", l = "[" + o + "]: " + r + i;
2910
- }
2911
- return this.references.push(l), a;
2912
- },
2913
- references: [],
2914
- append: function(e) {
2915
- var t = "";
2916
- return this.references.length && (t = `
2917
-
2918
- ` + this.references.join(`
2919
- `) + `
2920
-
2921
- `, this.references = []), t;
2922
- }
2923
- };
2924
- G.emphasis = {
2925
- filter: ["em", "i"],
2926
- replacement: function(e, t, n) {
2927
- return e.trim() ? n.emDelimiter + e + n.emDelimiter : "";
2928
- }
2929
- };
2930
- G.strong = {
2931
- filter: ["strong", "b"],
2932
- replacement: function(e, t, n) {
2933
- return e.trim() ? n.strongDelimiter + e + n.strongDelimiter : "";
2934
- }
2935
- };
2936
- G.code = {
2937
- filter: function(e) {
2938
- var t = e.previousSibling || e.nextSibling, n = e.parentNode.nodeName === "PRE" && !t;
2939
- return e.nodeName === "CODE" && !n;
2940
- },
2941
- replacement: function(e) {
2942
- if (!e) return "";
2943
- e = e.replace(/\r?\n|\r/g, " ");
2944
- for (var t = /^`|^ .*?[^ ].* $|`$/.test(e) ? " " : "", n = "`", r = e.match(/`+/gm) || []; r.indexOf(n) !== -1; ) n = n + "`";
2945
- return n + t + e + t + n;
2946
- }
2947
- };
2948
- G.image = {
2949
- filter: "img",
2950
- replacement: function(e, t) {
2951
- var n = Cn(Ye(t.getAttribute("alt"))), r = Et(t.getAttribute("src") || ""), i = Ye(t.getAttribute("title")), a = i ? ' "' + Tt(i) + '"' : "";
2952
- return r ? "![" + n + "](" + r + a + ")" : "";
2953
- }
2954
- };
2955
- function Ye(e) {
2956
- return e ? e.replace(/(\n+\s*)+/g, `
2957
- `) : "";
2958
- }
2959
- function Et(e) {
2960
- var t = e.replace(/([<>()])/g, "\\$1");
2961
- return t.indexOf(" ") >= 0 ? "<" + t + ">" : t;
2962
- }
2963
- function Tt(e) {
2964
- return e.replace(/"/g, '\\"');
2965
- }
2966
- function _n(e) {
2967
- this.options = e, this._keep = [], this._remove = [], this.blankRule = {
2968
- replacement: e.blankReplacement
2969
- }, this.keepReplacement = e.keepReplacement, this.defaultRule = {
2970
- replacement: e.defaultReplacement
2971
- }, this.array = [];
2972
- for (var t in e.rules) this.array.push(e.rules[t]);
2973
- }
2974
- _n.prototype = {
2975
- add: function(e, t) {
2976
- this.array.unshift(t);
2977
- },
2978
- keep: function(e) {
2979
- this._keep.unshift({
2980
- filter: e,
2981
- replacement: this.keepReplacement
2982
- });
2983
- },
2984
- remove: function(e) {
2985
- this._remove.unshift({
2986
- filter: e,
2987
- replacement: function() {
2988
- return "";
2989
- }
2990
- });
2991
- },
2992
- forNode: function(e) {
2993
- if (e.isBlank) return this.blankRule;
2994
- var t;
2995
- return (t = ht(this.array, e, this.options)) || (t = ht(this._keep, e, this.options)) || (t = ht(this._remove, e, this.options)) ? t : this.defaultRule;
2996
- },
2997
- forEach: function(e) {
2998
- for (var t = 0; t < this.array.length; t++) e(this.array[t], t);
2999
- }
3000
- };
3001
- function ht(e, t, n) {
3002
- for (var r = 0; r < e.length; r++) {
3003
- var i = e[r];
3004
- if (ji(i, t, n)) return i;
3005
- }
3006
- }
3007
- function ji(e, t, n) {
3008
- var r = e.filter;
3009
- if (typeof r == "string") {
3010
- if (r === t.nodeName.toLowerCase()) return !0;
3011
- } else if (Array.isArray(r)) {
3012
- if (r.indexOf(t.nodeName.toLowerCase()) > -1) return !0;
3013
- } else if (typeof r == "function") {
3014
- if (r.call(e, t, n)) return !0;
3015
- } else
3016
- throw new TypeError("`filter` needs to be a string, array, or function");
3017
- }
3018
- function Wi(e) {
3019
- var t = e.element, n = e.isBlock, r = e.isVoid, i = e.isPre || function(p) {
3020
- return p.nodeName === "PRE";
3021
- };
3022
- if (!(!t.firstChild || i(t))) {
3023
- for (var a = null, l = !1, o = null, u = Ut(o, t, i); u !== t; ) {
3024
- if (u.nodeType === 3 || u.nodeType === 4) {
3025
- var s = u.data.replace(/[ \r\n\t]+/g, " ");
3026
- if ((!a || / $/.test(a.data)) && !l && s[0] === " " && (s = s.substr(1)), !s) {
3027
- u = ft(u);
3028
- continue;
3029
- }
3030
- u.data = s, a = u;
3031
- } else if (u.nodeType === 1)
3032
- n(u) || u.nodeName === "BR" ? (a && (a.data = a.data.replace(/ $/, "")), a = null, l = !1) : r(u) || i(u) ? (a = null, l = !0) : a && (l = !1);
3033
- else {
3034
- u = ft(u);
3035
- continue;
3036
- }
3037
- var d = Ut(o, u, i);
3038
- o = u, u = d;
3039
- }
3040
- a && (a.data = a.data.replace(/ $/, ""), a.data || ft(a));
3041
- }
3042
- }
3043
- function ft(e) {
3044
- var t = e.nextSibling || e.parentNode;
3045
- return e.parentNode.removeChild(e), t;
3046
- }
3047
- function Ut(e, t, n) {
3048
- return e && e.parentNode === t || n(t) ? t.nextSibling || t.parentNode : t.firstChild || t.nextSibling || t.parentNode;
3049
- }
3050
- var It = typeof window < "u" ? window : {};
3051
- function Qi() {
3052
- var e = It.DOMParser, t = !1;
3053
- try {
3054
- new e().parseFromString("", "text/html") && (t = !0);
3055
- } catch {
3056
- }
3057
- return t;
3058
- }
3059
- function Ki() {
3060
- var e = function() {
3061
- };
3062
- return Yi() ? e.prototype.parseFromString = function(t) {
3063
- var n = new window.ActiveXObject("htmlfile");
3064
- return n.designMode = "on", n.open(), n.write(t), n.close(), n;
3065
- } : e.prototype.parseFromString = function(t) {
3066
- var n = document.implementation.createHTMLDocument("");
3067
- return n.open(), n.write(t), n.close(), n;
3068
- }, e;
3069
- }
3070
- function Yi() {
3071
- var e = !1;
3072
- try {
3073
- document.implementation.createHTMLDocument("").open();
3074
- } catch {
3075
- It.ActiveXObject && (e = !0);
3076
- }
3077
- return e;
3078
- }
3079
- var Gi = Qi() ? It.DOMParser : Ki();
3080
- function Xi(e, t) {
3081
- var n;
3082
- if (typeof e == "string") {
3083
- var r = Zi().parseFromString(
3084
- // DOM parsers arrange elements in the <head> and <body>.
3085
- // Wrapping in a custom element ensures elements are reliably arranged in
3086
- // a single element.
3087
- '<x-turndown id="turndown-root">' + e + "</x-turndown>",
3088
- "text/html"
3089
- );
3090
- n = r.getElementById("turndown-root");
3091
- } else
3092
- n = e.cloneNode(!0);
3093
- return Wi({
3094
- element: n,
3095
- isBlock: _t,
3096
- isVoid: yn,
3097
- isPre: t.preformattedCode ? Ji : null
3098
- }), n;
3099
- }
3100
- var dt;
3101
- function Zi() {
3102
- return dt = dt || new Gi(), dt;
3103
- }
3104
- function Ji(e) {
3105
- return e.nodeName === "PRE" || e.nodeName === "CODE";
3106
- }
3107
- function ea(e, t) {
3108
- return e.isBlock = _t(e), e.isCode = e.nodeName === "CODE" || e.parentNode.isCode, e.isBlank = ta(e), e.flankingWhitespace = na(e, t), e;
3109
- }
3110
- function ta(e) {
3111
- return !yn(e) && !Vi(e) && /^\s*$/i.test(e.textContent) && !qi(e) && !$i(e);
3112
- }
3113
- function na(e, t) {
3114
- if (e.isBlock || t.preformattedCode && e.isCode)
3115
- return {
3116
- leading: "",
3117
- trailing: ""
3118
- };
3119
- var n = ra(e.textContent);
3120
- return n.leadingAscii && jt("left", e, t) && (n.leading = n.leadingNonAscii), n.trailingAscii && jt("right", e, t) && (n.trailing = n.trailingNonAscii), {
3121
- leading: n.leading,
3122
- trailing: n.trailing
3123
- };
3124
- }
3125
- function ra(e) {
3126
- var t = e.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);
3127
- return {
3128
- leading: t[1],
3129
- // whole string for whitespace-only strings
3130
- leadingAscii: t[2],
3131
- leadingNonAscii: t[3],
3132
- trailing: t[4],
3133
- // empty for whitespace-only strings
3134
- trailingNonAscii: t[5],
3135
- trailingAscii: t[6]
3136
- };
3137
- }
3138
- function jt(e, t, n) {
3139
- var r, i, a;
3140
- return e === "left" ? (r = t.previousSibling, i = / $/) : (r = t.nextSibling, i = /^ /), r && (r.nodeType === 3 ? a = i.test(r.nodeValue) : n.preformattedCode && r.nodeName === "CODE" ? a = !1 : r.nodeType === 1 && !_t(r) && (a = i.test(r.textContent))), a;
3141
- }
3142
- var ia = Array.prototype.reduce;
3143
- function Ge(e) {
3144
- if (!(this instanceof Ge)) return new Ge(e);
3145
- var t = {
3146
- rules: G,
3147
- headingStyle: "setext",
3148
- hr: "* * *",
3149
- bulletListMarker: "*",
3150
- codeBlockStyle: "indented",
3151
- fence: "```",
3152
- emDelimiter: "_",
3153
- strongDelimiter: "**",
3154
- linkStyle: "inlined",
3155
- linkReferenceStyle: "full",
3156
- br: " ",
3157
- preformattedCode: !1,
3158
- blankReplacement: function(n, r) {
3159
- return r.isBlock ? `
3160
-
3161
- ` : "";
3162
- },
3163
- keepReplacement: function(n, r) {
3164
- return r.isBlock ? `
3165
-
3166
- ` + r.outerHTML + `
3167
-
3168
- ` : r.outerHTML;
3169
- },
3170
- defaultReplacement: function(n, r) {
3171
- return r.isBlock ? `
3172
-
3173
- ` + n + `
3174
-
3175
- ` : n;
3176
- }
3177
- };
3178
- this.options = Di({}, t, e), this.rules = new _n(this.options);
3179
- }
3180
- Ge.prototype = {
3181
- /**
3182
- * The entry point for converting a string or DOM node to Markdown
3183
- * @public
3184
- * @param {String|HTMLElement} input The string or DOM node to convert
3185
- * @returns A Markdown representation of the input
3186
- * @type String
3187
- */
3188
- turndown: function(e) {
3189
- if (!oa(e))
3190
- throw new TypeError(e + " is not a string, or an element/document/fragment node.");
3191
- if (e === "") return "";
3192
- var t = vn.call(this, new Xi(e, this.options));
3193
- return aa.call(this, t);
3194
- },
3195
- /**
3196
- * Add one or more plugins
3197
- * @public
3198
- * @param {Function|Array} plugin The plugin or array of plugins to add
3199
- * @returns The Turndown instance for chaining
3200
- * @type Object
3201
- */
3202
- use: function(e) {
3203
- if (Array.isArray(e))
3204
- for (var t = 0; t < e.length; t++) this.use(e[t]);
3205
- else if (typeof e == "function")
3206
- e(this);
3207
- else
3208
- throw new TypeError("plugin must be a Function or an Array of Functions");
3209
- return this;
3210
- },
3211
- /**
3212
- * Adds a rule
3213
- * @public
3214
- * @param {String} key The unique key of the rule
3215
- * @param {Object} rule The rule
3216
- * @returns The Turndown instance for chaining
3217
- * @type Object
3218
- */
3219
- addRule: function(e, t) {
3220
- return this.rules.add(e, t), this;
3221
- },
3222
- /**
3223
- * Keep a node (as HTML) that matches the filter
3224
- * @public
3225
- * @param {String|Array|Function} filter The unique key of the rule
3226
- * @returns The Turndown instance for chaining
3227
- * @type Object
3228
- */
3229
- keep: function(e) {
3230
- return this.rules.keep(e), this;
3231
- },
3232
- /**
3233
- * Remove a node that matches the filter
3234
- * @public
3235
- * @param {String|Array|Function} filter The unique key of the rule
3236
- * @returns The Turndown instance for chaining
3237
- * @type Object
3238
- */
3239
- remove: function(e) {
3240
- return this.rules.remove(e), this;
3241
- },
3242
- /**
3243
- * Escapes Markdown syntax
3244
- * @public
3245
- * @param {String} string The string to escape
3246
- * @returns A string with Markdown syntax escaped
3247
- * @type String
3248
- */
3249
- escape: function(e) {
3250
- return Cn(e);
3251
- }
3252
- };
3253
- function vn(e) {
3254
- var t = this;
3255
- return ia.call(e.childNodes, function(n, r) {
3256
- r = new ea(r, t.options);
3257
- var i = "";
3258
- return r.nodeType === 3 ? i = r.isCode ? r.nodeValue : t.escape(r.nodeValue) : r.nodeType === 1 && (i = la.call(t, r)), En(n, i);
3259
- }, "");
3260
- }
3261
- function aa(e) {
3262
- var t = this;
3263
- return this.rules.forEach(function(n) {
3264
- typeof n.append == "function" && (e = En(e, n.append(t.options)));
3265
- }), e.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
3266
- }
3267
- function la(e) {
3268
- var t = this.rules.forNode(e), n = vn.call(this, e), r = e.flankingWhitespace;
3269
- return (r.leading || r.trailing) && (n = n.trim()), r.leading + t.replacement(n, e, this.options) + r.trailing;
3270
- }
3271
- function En(e, t) {
3272
- var n = kn(e), r = mn(t), i = Math.max(e.length - n.length, t.length - r.length), a = `
3273
-
3274
- `.substring(0, i);
3275
- return n + a + r;
3276
- }
3277
- function oa(e) {
3278
- return e != null && (typeof e == "string" || e.nodeType && (e.nodeType === 1 || e.nodeType === 9 || e.nodeType === 11));
3279
- }
3280
- const ua = {};
3281
- function sa(e, t) {
3282
- const n = ua, r = typeof n.includeImageAlt == "boolean" ? n.includeImageAlt : !0, i = typeof n.includeHtml == "boolean" ? n.includeHtml : !0;
3283
- return Tn(e, r, i);
3284
- }
3285
- function Tn(e, t, n) {
3286
- if (ca(e)) {
3287
- if ("value" in e)
3288
- return e.type === "html" && !n ? "" : e.value;
3289
- if (t && "alt" in e && e.alt)
3290
- return e.alt;
3291
- if ("children" in e)
3292
- return Wt(e.children, t, n);
3293
- }
3294
- return Array.isArray(e) ? Wt(e, t, n) : "";
3295
- }
3296
- function Wt(e, t, n) {
3297
- const r = [];
3298
- let i = -1;
3299
- for (; ++i < e.length; )
3300
- r[i] = Tn(e[i], t, n);
3301
- return r.join("");
3302
- }
3303
- function ca(e) {
3304
- return !!(e && typeof e == "object");
3305
- }
3306
- const ha = /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;
3307
- function fa(e) {
3308
- return e.replace(ha, da);
3309
- }
3310
- function da(e, t, n) {
3311
- if (t)
3312
- return t;
3313
- if (n.charCodeAt(0) === 35) {
3314
- const i = n.charCodeAt(1), a = i === 120 || i === 88;
3315
- return wt(n.slice(a ? 2 : 1), a ? 16 : 10);
3316
- }
3317
- return Xe(n) || e;
3318
- }
3319
- function Qe(e) {
3320
- return !e || typeof e != "object" ? "" : "position" in e || "type" in e ? Qt(e.position) : "start" in e || "end" in e ? Qt(e) : "line" in e || "column" in e ? yt(e) : "";
3321
- }
3322
- function yt(e) {
3323
- return Kt(e && e.line) + ":" + Kt(e && e.column);
3324
- }
3325
- function Qt(e) {
3326
- return yt(e && e.start) + "-" + yt(e && e.end);
3327
- }
3328
- function Kt(e) {
3329
- return e && typeof e == "number" ? e : 1;
3330
- }
3331
- const In = {}.hasOwnProperty;
3332
- function Yt(e, t, n) {
3333
- return t && typeof t == "object" && (n = t, t = void 0), pa(n)(dn(fn(n).document().write(pn()(e, t, !0))));
3334
- }
3335
- function pa(e) {
3336
- const t = {
3337
- transforms: [],
3338
- canContainEols: ["emphasis", "fragment", "heading", "paragraph", "strong"],
3339
- enter: {
3340
- autolink: a($e),
3341
- autolinkProtocol: P,
3342
- autolinkEmail: P,
3343
- atxHeading: a(He),
3344
- blockQuote: a(ve),
3345
- characterEscape: P,
3346
- characterReference: P,
3347
- codeFenced: a(Me),
3348
- codeFencedFenceInfo: l,
3349
- codeFencedFenceMeta: l,
3350
- codeIndented: a(Me, l),
3351
- codeText: a(tt, l),
3352
- codeTextData: P,
3353
- data: P,
3354
- codeFlowValue: P,
3355
- definition: a(De),
3356
- definitionDestinationString: l,
3357
- definitionLabelString: l,
3358
- definitionTitleString: l,
3359
- emphasis: a(nt),
3360
- hardBreakEscape: a(qe),
3361
- hardBreakTrailing: a(qe),
3362
- htmlFlow: a(Ve, l),
3363
- htmlFlowData: P,
3364
- htmlText: a(Ve, l),
3365
- htmlTextData: P,
3366
- image: a(rt),
3367
- label: l,
3368
- link: a($e),
3369
- listItem: a(it),
3370
- listItemValue: g,
3371
- listOrdered: a(Ue, p),
3372
- listUnordered: a(Ue),
3373
- paragraph: a(at),
3374
- reference: f,
3375
- referenceString: l,
3376
- resourceDestinationString: l,
3377
- resourceTitleString: l,
3378
- setextHeading: a(He),
3379
- strong: a(lt),
3380
- thematicBreak: a(ut)
3381
- },
3382
- exit: {
3383
- atxHeading: u(),
3384
- atxHeadingSequence: B,
3385
- autolink: u(),
3386
- autolinkEmail: _e,
3387
- autolinkProtocol: me,
3388
- blockQuote: u(),
3389
- characterEscapeValue: D,
3390
- characterReferenceMarkerHexadecimal: we,
3391
- characterReferenceMarkerNumeric: we,
3392
- characterReferenceValue: j,
3393
- characterReference: Be,
3394
- codeFenced: u(z),
3395
- codeFencedFence: _,
3396
- codeFencedFenceInfo: c,
3397
- codeFencedFenceMeta: b,
3398
- codeFlowValue: D,
3399
- codeIndented: u(x),
3400
- codeText: u(F),
3401
- codeTextData: D,
3402
- data: D,
3403
- definition: u(),
3404
- definitionDestinationString: O,
3405
- definitionLabelString: w,
3406
- definitionTitleString: C,
3407
- emphasis: u(),
3408
- hardBreakEscape: u(E),
3409
- hardBreakTrailing: u(E),
3410
- htmlFlow: u(H),
3411
- htmlFlowData: D,
3412
- htmlText: u(V),
3413
- htmlTextData: D,
3414
- image: u(U),
3415
- label: ce,
3416
- labelText: ne,
3417
- lineEnding: T,
3418
- link: u(W),
3419
- listItem: u(),
3420
- listOrdered: u(),
3421
- listUnordered: u(),
3422
- paragraph: u(),
3423
- referenceString: ie,
3424
- resourceDestinationString: h,
3425
- resourceTitleString: re,
3426
- resource: he,
3427
- setextHeading: u($),
3428
- setextHeadingLineSequence: M,
3429
- setextHeadingText: k,
3430
- strong: u(),
3431
- thematicBreak: u()
3432
- }
3433
- };
3434
- Ln(t, (e || {}).mdastExtensions || []);
3435
- const n = {};
3436
- return r;
3437
- function r(m) {
3438
- let y = {
3439
- type: "root",
3440
- children: []
3441
- };
3442
- const L = {
3443
- stack: [y],
3444
- tokenStack: [],
3445
- config: t,
3446
- enter: o,
3447
- exit: s,
3448
- buffer: l,
3449
- resume: d,
3450
- data: n
3451
- }, A = [];
3452
- let N = -1;
3453
- for (; ++N < m.length; )
3454
- if (m[N][1].type === "listOrdered" || m[N][1].type === "listUnordered")
3455
- if (m[N][0] === "enter")
3456
- A.push(N);
3457
- else {
3458
- const ae = A.pop();
3459
- N = i(m, ae, N);
3460
- }
3461
- for (N = -1; ++N < m.length; ) {
3462
- const ae = t[m[N][0]];
3463
- In.call(ae, m[N][1].type) && ae[m[N][1].type].call(Object.assign({
3464
- sliceSerialize: m[N][2].sliceSerialize
3465
- }, L), m[N][1]);
3466
- }
3467
- if (L.tokenStack.length > 0) {
3468
- const ae = L.tokenStack[L.tokenStack.length - 1];
3469
- (ae[1] || Gt).call(L, void 0, ae[0]);
3470
- }
3471
- for (y.position = {
3472
- start: Te(m.length > 0 ? m[0][1].start : {
3473
- line: 1,
3474
- column: 1,
3475
- offset: 0
3476
- }),
3477
- end: Te(m.length > 0 ? m[m.length - 2][1].end : {
3478
- line: 1,
3479
- column: 1,
3480
- offset: 0
3481
- })
3482
- }, N = -1; ++N < t.transforms.length; )
3483
- y = t.transforms[N](y) || y;
3484
- return y;
3485
- }
3486
- function i(m, y, L) {
3487
- let A = y - 1, N = -1, ae = !1, ke, ue, Ae, Fe;
3488
- for (; ++A <= L; ) {
3489
- const X = m[A];
3490
- switch (X[1].type) {
3491
- case "listUnordered":
3492
- case "listOrdered":
3493
- case "blockQuote": {
3494
- X[0] === "enter" ? N++ : N--, Fe = void 0;
3495
- break;
3496
- }
3497
- case "lineEndingBlank": {
3498
- X[0] === "enter" && (ke && !Fe && !N && !Ae && (Ae = A), Fe = void 0);
3499
- break;
3500
- }
3501
- case "linePrefix":
3502
- case "listItemValue":
3503
- case "listItemMarker":
3504
- case "listItemPrefix":
3505
- case "listItemPrefixWhitespace":
3506
- break;
3507
- default:
3508
- Fe = void 0;
3509
- }
3510
- if (!N && X[0] === "enter" && X[1].type === "listItemPrefix" || N === -1 && X[0] === "exit" && (X[1].type === "listUnordered" || X[1].type === "listOrdered")) {
3511
- if (ke) {
3512
- let Ee = A;
3513
- for (ue = void 0; Ee--; ) {
3514
- const fe = m[Ee];
3515
- if (fe[1].type === "lineEnding" || fe[1].type === "lineEndingBlank") {
3516
- if (fe[0] === "exit") continue;
3517
- ue && (m[ue][1].type = "lineEndingBlank", ae = !0), fe[1].type = "lineEnding", ue = Ee;
3518
- } else if (!(fe[1].type === "linePrefix" || fe[1].type === "blockQuotePrefix" || fe[1].type === "blockQuotePrefixWhitespace" || fe[1].type === "blockQuoteMarker" || fe[1].type === "listItemIndent")) break;
3519
- }
3520
- Ae && (!ue || Ae < ue) && (ke._spread = !0), ke.end = Object.assign({}, ue ? m[ue][1].start : X[1].end), m.splice(ue || A, 0, ["exit", ke, X[2]]), A++, L++;
3521
- }
3522
- if (X[1].type === "listItemPrefix") {
3523
- const Ee = {
3524
- type: "listItem",
3525
- _spread: !1,
3526
- start: Object.assign({}, X[1].start),
3527
- // @ts-expect-error: we’ll add `end` in a second.
3528
- end: void 0
3529
- };
3530
- ke = Ee, m.splice(A, 0, ["enter", Ee, X[2]]), A++, L++, Ae = void 0, Fe = !0;
3531
- }
3532
- }
3533
- }
3534
- return m[y][1]._spread = ae, L;
3535
- }
3536
- function a(m, y) {
3537
- return L;
3538
- function L(A) {
3539
- o.call(this, m(A), A), y && y.call(this, A);
3540
- }
3541
- }
3542
- function l() {
3543
- this.stack.push({
3544
- type: "fragment",
3545
- children: []
3546
- });
3547
- }
3548
- function o(m, y, L) {
3549
- this.stack[this.stack.length - 1].children.push(m), this.stack.push(m), this.tokenStack.push([y, L || void 0]), m.position = {
3550
- start: Te(y.start),
3551
- // @ts-expect-error: `end` will be patched later.
3552
- end: void 0
3553
- };
3554
- }
3555
- function u(m) {
3556
- return y;
3557
- function y(L) {
3558
- m && m.call(this, L), s.call(this, L);
3559
- }
3560
- }
3561
- function s(m, y) {
3562
- const L = this.stack.pop(), A = this.tokenStack.pop();
3563
- if (A)
3564
- A[0].type !== m.type && (y ? y.call(this, m, A[0]) : (A[1] || Gt).call(this, m, A[0]));
3565
- else throw new Error("Cannot close `" + m.type + "` (" + Qe({
3566
- start: m.start,
3567
- end: m.end
3568
- }) + "): it’s not open");
3569
- L.position.end = Te(m.end);
3570
- }
3571
- function d() {
3572
- return sa(this.stack.pop());
3573
- }
3574
- function p() {
3575
- this.data.expectingFirstListItemValue = !0;
3576
- }
3577
- function g(m) {
3578
- if (this.data.expectingFirstListItemValue) {
3579
- const y = this.stack[this.stack.length - 2];
3580
- y.start = Number.parseInt(this.sliceSerialize(m), 10), this.data.expectingFirstListItemValue = void 0;
3581
- }
3582
- }
3583
- function c() {
3584
- const m = this.resume(), y = this.stack[this.stack.length - 1];
3585
- y.lang = m;
3586
- }
3587
- function b() {
3588
- const m = this.resume(), y = this.stack[this.stack.length - 1];
3589
- y.meta = m;
3590
- }
3591
- function _() {
3592
- this.data.flowCodeInside || (this.buffer(), this.data.flowCodeInside = !0);
3593
- }
3594
- function z() {
3595
- const m = this.resume(), y = this.stack[this.stack.length - 1];
3596
- y.value = m.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, ""), this.data.flowCodeInside = void 0;
3597
- }
3598
- function x() {
3599
- const m = this.resume(), y = this.stack[this.stack.length - 1];
3600
- y.value = m.replace(/(\r?\n|\r)$/g, "");
3601
- }
3602
- function w(m) {
3603
- const y = this.resume(), L = this.stack[this.stack.length - 1];
3604
- L.label = y, L.identifier = Ie(this.sliceSerialize(m)).toLowerCase();
3605
- }
3606
- function C() {
3607
- const m = this.resume(), y = this.stack[this.stack.length - 1];
3608
- y.title = m;
3609
- }
3610
- function O() {
3611
- const m = this.resume(), y = this.stack[this.stack.length - 1];
3612
- y.url = m;
3613
- }
3614
- function B(m) {
3615
- const y = this.stack[this.stack.length - 1];
3616
- if (!y.depth) {
3617
- const L = this.sliceSerialize(m).length;
3618
- y.depth = L;
3619
- }
3620
- }
3621
- function k() {
3622
- this.data.setextHeadingSlurpLineEnding = !0;
3623
- }
3624
- function M(m) {
3625
- const y = this.stack[this.stack.length - 1];
3626
- y.depth = this.sliceSerialize(m).codePointAt(0) === 61 ? 1 : 2;
3627
- }
3628
- function $() {
3629
- this.data.setextHeadingSlurpLineEnding = void 0;
3630
- }
3631
- function P(m) {
3632
- const L = this.stack[this.stack.length - 1].children;
3633
- let A = L[L.length - 1];
3634
- (!A || A.type !== "text") && (A = ot(), A.position = {
3635
- start: Te(m.start),
3636
- // @ts-expect-error: we’ll add `end` later.
3637
- end: void 0
3638
- }, L.push(A)), this.stack.push(A);
3639
- }
3640
- function D(m) {
3641
- const y = this.stack.pop();
3642
- y.value += this.sliceSerialize(m), y.position.end = Te(m.end);
3643
- }
3644
- function T(m) {
3645
- const y = this.stack[this.stack.length - 1];
3646
- if (this.data.atHardBreak) {
3647
- const L = y.children[y.children.length - 1];
3648
- L.position.end = Te(m.end), this.data.atHardBreak = void 0;
3649
- return;
3650
- }
3651
- !this.data.setextHeadingSlurpLineEnding && t.canContainEols.includes(y.type) && (P.call(this, m), D.call(this, m));
3652
- }
3653
- function E() {
3654
- this.data.atHardBreak = !0;
3655
- }
3656
- function H() {
3657
- const m = this.resume(), y = this.stack[this.stack.length - 1];
3658
- y.value = m;
3659
- }
3660
- function V() {
3661
- const m = this.resume(), y = this.stack[this.stack.length - 1];
3662
- y.value = m;
3663
- }
3664
- function F() {
3665
- const m = this.resume(), y = this.stack[this.stack.length - 1];
3666
- y.value = m;
3667
- }
3668
- function W() {
3669
- const m = this.stack[this.stack.length - 1];
3670
- if (this.data.inReference) {
3671
- const y = this.data.referenceType || "shortcut";
3672
- m.type += "Reference", m.referenceType = y, delete m.url, delete m.title;
3673
- } else
3674
- delete m.identifier, delete m.label;
3675
- this.data.referenceType = void 0;
3676
- }
3677
- function U() {
3678
- const m = this.stack[this.stack.length - 1];
3679
- if (this.data.inReference) {
3680
- const y = this.data.referenceType || "shortcut";
3681
- m.type += "Reference", m.referenceType = y, delete m.url, delete m.title;
3682
- } else
3683
- delete m.identifier, delete m.label;
3684
- this.data.referenceType = void 0;
3685
- }
3686
- function ne(m) {
3687
- const y = this.sliceSerialize(m), L = this.stack[this.stack.length - 2];
3688
- L.label = fa(y), L.identifier = Ie(y).toLowerCase();
3689
- }
3690
- function ce() {
3691
- const m = this.stack[this.stack.length - 1], y = this.resume(), L = this.stack[this.stack.length - 1];
3692
- if (this.data.inReference = !0, L.type === "link") {
3693
- const A = m.children;
3694
- L.children = A;
3695
- } else
3696
- L.alt = y;
3697
- }
3698
- function h() {
3699
- const m = this.resume(), y = this.stack[this.stack.length - 1];
3700
- y.url = m;
3701
- }
3702
- function re() {
3703
- const m = this.resume(), y = this.stack[this.stack.length - 1];
3704
- y.title = m;
3705
- }
3706
- function he() {
3707
- this.data.inReference = void 0;
3708
- }
3709
- function f() {
3710
- this.data.referenceType = "collapsed";
3711
- }
3712
- function ie(m) {
3713
- const y = this.resume(), L = this.stack[this.stack.length - 1];
3714
- L.label = y, L.identifier = Ie(this.sliceSerialize(m)).toLowerCase(), this.data.referenceType = "full";
3715
- }
3716
- function we(m) {
3717
- this.data.characterReferenceType = m.type;
3718
- }
3719
- function j(m) {
3720
- const y = this.sliceSerialize(m), L = this.data.characterReferenceType;
3721
- let A;
3722
- L ? (A = wt(y, L === "characterReferenceMarkerNumeric" ? 10 : 16), this.data.characterReferenceType = void 0) : A = Xe(y);
3723
- const N = this.stack[this.stack.length - 1];
3724
- N.value += A;
3725
- }
3726
- function Be(m) {
3727
- const y = this.stack.pop();
3728
- y.position.end = Te(m.end);
3729
- }
3730
- function me(m) {
3731
- D.call(this, m);
3732
- const y = this.stack[this.stack.length - 1];
3733
- y.url = this.sliceSerialize(m);
3734
- }
3735
- function _e(m) {
3736
- D.call(this, m);
3737
- const y = this.stack[this.stack.length - 1];
3738
- y.url = "mailto:" + this.sliceSerialize(m);
3739
- }
3740
- function ve() {
3741
- return {
3742
- type: "blockquote",
3743
- children: []
3744
- };
3745
- }
3746
- function Me() {
3747
- return {
3748
- type: "code",
3749
- lang: null,
3750
- meta: null,
3751
- value: ""
3752
- };
3753
- }
3754
- function tt() {
3755
- return {
3756
- type: "inlineCode",
3757
- value: ""
3758
- };
3759
- }
3760
- function De() {
3761
- return {
3762
- type: "definition",
3763
- identifier: "",
3764
- label: null,
3765
- title: null,
3766
- url: ""
3767
- };
3768
- }
3769
- function nt() {
3770
- return {
3771
- type: "emphasis",
3772
- children: []
3773
- };
3774
- }
3775
- function He() {
3776
- return {
3777
- type: "heading",
3778
- // @ts-expect-error `depth` will be set later.
3779
- depth: 0,
3780
- children: []
3781
- };
3782
- }
3783
- function qe() {
3784
- return {
3785
- type: "break"
3786
- };
3787
- }
3788
- function Ve() {
3789
- return {
3790
- type: "html",
3791
- value: ""
3792
- };
3793
- }
3794
- function rt() {
3795
- return {
3796
- type: "image",
3797
- title: null,
3798
- url: "",
3799
- alt: null
3800
- };
3801
- }
3802
- function $e() {
3803
- return {
3804
- type: "link",
3805
- title: null,
3806
- url: "",
3807
- children: []
3808
- };
3809
- }
3810
- function Ue(m) {
3811
- return {
3812
- type: "list",
3813
- ordered: m.type === "listOrdered",
3814
- start: null,
3815
- spread: m._spread,
3816
- children: []
3817
- };
3818
- }
3819
- function it(m) {
3820
- return {
3821
- type: "listItem",
3822
- spread: m._spread,
3823
- checked: null,
3824
- children: []
3825
- };
3826
- }
3827
- function at() {
3828
- return {
3829
- type: "paragraph",
3830
- children: []
3831
- };
3832
- }
3833
- function lt() {
3834
- return {
3835
- type: "strong",
3836
- children: []
3837
- };
3838
- }
3839
- function ot() {
3840
- return {
3841
- type: "text",
3842
- value: ""
3843
- };
3844
- }
3845
- function ut() {
3846
- return {
3847
- type: "thematicBreak"
3848
- };
3849
- }
3850
- }
3851
- function Te(e) {
3852
- return {
3853
- line: e.line,
3854
- column: e.column,
3855
- offset: e.offset
3856
- };
3857
- }
3858
- function Ln(e, t) {
3859
- let n = -1;
3860
- for (; ++n < t.length; ) {
3861
- const r = t[n];
3862
- Array.isArray(r) ? Ln(e, r) : ga(e, r);
3863
- }
3864
- }
3865
- function ga(e, t) {
3866
- let n;
3867
- for (n in t)
3868
- if (In.call(t, n))
3869
- switch (n) {
3870
- case "canContainEols": {
3871
- const r = t[n];
3872
- r && e[n].push(...r);
3873
- break;
3874
- }
3875
- case "transforms": {
3876
- const r = t[n];
3877
- r && e[n].push(...r);
3878
- break;
3879
- }
3880
- case "enter":
3881
- case "exit": {
3882
- const r = t[n];
3883
- r && Object.assign(e[n], r);
3884
- break;
3885
- }
3886
- }
3887
- }
3888
- function Gt(e, t) {
3889
- throw e ? new Error("Cannot close `" + e.type + "` (" + Qe({
3890
- start: e.start,
3891
- end: e.end
3892
- }) + "): a different token (`" + t.type + "`, " + Qe({
3893
- start: t.start,
3894
- end: t.end
3895
- }) + ") is open") : new Error("Cannot close document, a token (`" + t.type + "`, " + Qe({
3896
- start: t.start,
3897
- end: t.end
3898
- }) + ") is still open");
3899
- }
3900
- function ma() {
3901
- return {
3902
- canContainEols: ["delete"],
3903
- enter: { strikethrough: ka },
3904
- exit: { strikethrough: xa }
3905
- };
3906
- }
3907
- function ka(e) {
3908
- this.enter({ type: "delete", children: [] }, e);
3909
- }
3910
- function xa(e) {
3911
- this.exit(e);
3912
- }
3913
- const zn = (
3914
- // Note: overloads in JSDoc can’t yet use different `@template`s.
3915
- /**
3916
- * @type {(
3917
- * (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &
3918
- * (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &
3919
- * (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &
3920
- * ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &
3921
- * ((test?: Test) => Check)
3922
- * )}
3923
- */
3924
- /**
3925
- * @param {Test} [test]
3926
- * @returns {Check}
3927
- */
3928
- (function(e) {
3929
- if (e == null)
3930
- return wa;
3931
- if (typeof e == "function")
3932
- return et(e);
3933
- if (typeof e == "object")
3934
- return Array.isArray(e) ? ba(e) : (
3935
- // Cast because `ReadonlyArray` goes into the above but `isArray`
3936
- // narrows to `Array`.
3937
- ya(
3938
- /** @type {Props} */
3939
- e
3940
- )
3941
- );
3942
- if (typeof e == "string")
3943
- return Sa(e);
3944
- throw new Error("Expected function, string, or object as test");
3945
- })
3946
- );
3947
- function ba(e) {
3948
- const t = [];
3949
- let n = -1;
3950
- for (; ++n < e.length; )
3951
- t[n] = zn(e[n]);
3952
- return et(r);
3953
- function r(...i) {
3954
- let a = -1;
3955
- for (; ++a < t.length; )
3956
- if (t[a].apply(this, i)) return !0;
3957
- return !1;
3958
- }
3959
- }
3960
- function ya(e) {
3961
- const t = (
3962
- /** @type {Record<string, unknown>} */
3963
- e
3964
- );
3965
- return et(n);
3966
- function n(r) {
3967
- const i = (
3968
- /** @type {Record<string, unknown>} */
3969
- /** @type {unknown} */
3970
- r
3971
- );
3972
- let a;
3973
- for (a in e)
3974
- if (i[a] !== t[a]) return !1;
3975
- return !0;
3976
- }
3977
- }
3978
- function Sa(e) {
3979
- return et(t);
3980
- function t(n) {
3981
- return n && n.type === e;
3982
- }
3983
- }
3984
- function et(e) {
3985
- return t;
3986
- function t(n, r, i) {
3987
- return !!(Ca(n) && e.call(
3988
- this,
3989
- n,
3990
- typeof r == "number" ? r : void 0,
3991
- i || void 0
3992
- ));
3993
- }
3994
- }
3995
- function wa() {
3996
- return !0;
3997
- }
3998
- function Ca(e) {
3999
- return e !== null && typeof e == "object" && "type" in e;
4000
- }
4001
- const Bn = [], _a = !0, Xt = !1, va = "skip";
4002
- function Ea(e, t, n, r) {
4003
- let i;
4004
- typeof t == "function" && typeof n != "function" ? (r = n, n = t) : i = t;
4005
- const a = zn(i), l = r ? -1 : 1;
4006
- o(e, void 0, [])();
4007
- function o(u, s, d) {
4008
- const p = (
4009
- /** @type {Record<string, unknown>} */
4010
- u && typeof u == "object" ? u : {}
4011
- );
4012
- if (typeof p.type == "string") {
4013
- const c = (
4014
- // `hast`
4015
- typeof p.tagName == "string" ? p.tagName : (
4016
- // `xast`
4017
- typeof p.name == "string" ? p.name : void 0
4018
- )
4019
- );
4020
- Object.defineProperty(g, "name", {
4021
- value: "node (" + (u.type + (c ? "<" + c + ">" : "")) + ")"
4022
- });
4023
- }
4024
- return g;
4025
- function g() {
4026
- let c = Bn, b, _, z;
4027
- if ((!t || a(u, s, d[d.length - 1] || void 0)) && (c = Ta(n(u, d)), c[0] === Xt))
4028
- return c;
4029
- if ("children" in u && u.children) {
4030
- const x = (
4031
- /** @type {UnistParent} */
4032
- u
4033
- );
4034
- if (x.children && c[0] !== va)
4035
- for (_ = (r ? x.children.length : -1) + l, z = d.concat(x); _ > -1 && _ < x.children.length; ) {
4036
- const w = x.children[_];
4037
- if (b = o(w, _, z)(), b[0] === Xt)
4038
- return b;
4039
- _ = typeof b[1] == "number" ? b[1] : _ + l;
4040
- }
4041
- }
4042
- return c;
4043
- }
4044
- }
4045
- }
4046
- function Ta(e) {
4047
- return Array.isArray(e) ? e : typeof e == "number" ? [_a, e] : e == null ? Bn : [e];
4048
- }
4049
- function pt(e, t, n, r) {
4050
- let i, a, l;
4051
- typeof t == "function" && typeof n != "function" ? (a = void 0, l = t, i = n) : (a = t, l = n, i = r), Ea(e, a, o, i);
4052
- function o(u, s) {
4053
- const d = s[s.length - 1], p = d ? d.children.indexOf(u) : void 0;
4054
- return l(u, p, d);
4055
- }
4056
- }
4057
- const Ia = On`
4058
- :host {
4059
- display: flex;
4060
- flex-direction: column;
4061
- box-sizing: border-box;
4062
- }
4063
-
4064
- #rich-view {
4065
- flex: 1 1 auto;
4066
- min-height: 0;
4067
- overflow-y: auto;
4068
- box-sizing: border-box;
4069
- outline: none;
4070
- /* Consumer themes via CSS custom properties */
4071
- font-family: var(--rme-font-family, inherit);
4072
- font-size: var(--rme-font-size, inherit);
4073
- line-height: var(--rme-line-height, 1.6);
4074
- padding: var(--rme-padding, 0.75em 1em);
4075
- background: var(--rme-background, Canvas);
4076
- color: var(--rme-color, CanvasText);
4077
- border: var(--rme-border, 1px solid ButtonBorder);
4078
- border-top: none;
4079
- border-radius: var(--rme-border-radius, 0 0 4px 4px);
4080
- }
4081
-
4082
- #rich-view:focus {
4083
- outline: var(--rme-focus-outline, 2px solid Highlight);
4084
- outline-offset: -2px;
4085
- }
4086
-
4087
- #rich-view[hidden] { display: none; }
4088
-
4089
- /* Block-level spacing within the rich view */
4090
- #rich-view > :first-child { margin-top: 0; }
4091
- #rich-view > :last-child { margin-bottom: 0; }
4092
-
4093
- /* Source mode wrapper */
4094
- #source-wrapper {
4095
- flex: 1 1 auto;
4096
- min-height: 0;
4097
- display: flex;
4098
- flex-direction: column;
4099
- }
4100
-
4101
- #source-wrapper[hidden] { display: none; }
4102
-
4103
- #source-editor {
4104
- flex: 1 1 auto;
4105
- display: block;
4106
- --rc-textarea-border-radius: 0 0 4px 4px;
4107
- --rc-textarea-border-top: none;
4108
- }
4109
-
4110
- /* ── Toolbar ─────────────────────────────────────────────────────────────── */
4111
-
4112
- rc-editor-toolbar [role='toolbar'] {
4113
- display: flex;
4114
- flex-wrap: wrap;
4115
- align-items: center;
4116
- gap: var(--rme-toolbar-gap, 1px);
4117
- padding: 4px;
4118
- border: 1px solid ButtonBorder;
4119
- border-radius: 4px 4px 0 0;
4120
- background: Canvas;
4121
- }
4122
-
4123
- rc-editor-toolbar button {
4124
- appearance: none;
4125
- display: inline-flex;
4126
- align-items: center;
4127
- justify-content: center;
4128
- min-inline-size: var(--rme-toolbar-button-size, 2rem);
4129
- min-block-size: var(--rme-toolbar-button-size, 2rem);
4130
- padding: 0.3em;
4131
- border: 1px solid transparent;
4132
- border-radius: 3px;
4133
- background: transparent;
4134
- color: ButtonText;
4135
- font: inherit;
4136
- font-size: 0.875em;
4137
- cursor: pointer;
4138
- line-height: 1;
4139
- }
4140
-
4141
- rc-editor-toolbar button svg {
4142
- inline-size: 1.15em;
4143
- block-size: 1.15em;
4144
- flex-shrink: 0;
4145
- }
4146
-
4147
- rc-editor-toolbar button:hover {
4148
- background: ButtonFace;
4149
- border-color: ButtonBorder;
4150
- }
4151
-
4152
- rc-editor-toolbar button:focus-visible {
4153
- outline: 2px solid Highlight;
4154
- outline-offset: 1px;
4155
- }
4156
-
4157
- rc-editor-toolbar button[aria-pressed='true'] {
4158
- background: Highlight;
4159
- color: HighlightText;
4160
- border-color: Highlight;
4161
- }
4162
-
4163
- /* Heading select */
4164
- rc-editor-toolbar select {
4165
- appearance: auto;
4166
- padding: 0.25em 0.35em;
4167
- border: 1px solid ButtonBorder;
4168
- border-radius: 3px;
4169
- background: ButtonFace;
4170
- color: ButtonText;
4171
- font: inherit;
4172
- font-size: 0.8125em;
4173
- cursor: pointer;
4174
- }
4175
-
4176
- rc-editor-toolbar select:focus-visible {
4177
- outline: 2px solid Highlight;
4178
- outline-offset: 1px;
4179
- }
4180
-
4181
- rc-editor-toolbar select.toolbar-active {
4182
- background: Highlight;
4183
- color: HighlightText;
4184
- border-color: Highlight;
4185
- }
4186
-
4187
- /* Code block language input */
4188
- rc-editor-toolbar .lang-input {
4189
- padding: 0.25em 0.5em;
4190
- border: 1px solid ButtonBorder;
4191
- border-radius: 3px;
4192
- background: Field;
4193
- color: FieldText;
4194
- font: inherit;
4195
- font-size: 0.8125em;
4196
- width: 8em;
4197
- }
4198
-
4199
- rc-editor-toolbar .lang-input:focus {
4200
- outline: 2px solid Highlight;
4201
- outline-offset: 1px;
4202
- }
4203
-
4204
- rc-editor-toolbar .lang-input::placeholder {
4205
- color: GrayText;
4206
- }
4207
-
4208
- /* ── Source mode decoration classes ─────────────────────────────────────── */
4209
-
4210
- .rme-blockquote { color: GrayText; }
4211
- .rme-list-bullet,
4212
- .rme-list-ordered { color: GrayText; }
4213
- .rme-code-block { color: GrayText; font-style: italic; }
4214
- .rme-strikethrough { text-decoration: line-through; }
4215
- .rme-underline { text-decoration: underline; }
4216
-
4217
- /* ── Rich view block element spacing ─────────────────────────────────────── */
4218
-
4219
- #rich-view blockquote {
4220
- margin: 0.5em 0;
4221
- padding-left: 1em;
4222
- border-left: 3px solid ButtonBorder;
4223
- color: GrayText;
4224
- }
4225
-
4226
- #rich-view pre {
4227
- margin: 0.5em 0;
4228
- padding: 0.65em 0.85em;
4229
- background: Field;
4230
- border: 1px solid ButtonBorder;
4231
- border-radius: 4px;
4232
- overflow-x: auto;
4233
- }
4234
-
4235
- #rich-view pre code {
4236
- font-family: 'Cascadia Code', 'Fira Code', ui-monospace, monospace;
4237
- font-size: 0.875em;
4238
- }
4239
-
4240
- #rich-view ul, #rich-view ol {
4241
- margin: 0.5em 0;
4242
- padding-left: 1.75em;
4243
- }
4244
-
4245
- #rich-view li { margin: 0.2em 0; }
4246
-
4247
- /* ── Hide the slotted native textarea ────────────────────────────────────── */
4248
- ::slotted(textarea) {
4249
- display: none !important;
4250
- }
4251
-
4252
- ::slotted(label) {
4253
- display: block;
4254
- margin-bottom: 0.25em;
4255
- font-size: 0.875em;
4256
- }
4257
- `;
4258
- function La(e, t, n) {
4259
- const r = e.filter(
4260
- (l) => l.type === "mark" && l.from <= t && l.to >= n
4261
- ), a = r.find((l) => l.className?.startsWith("rme-heading-"))?.className?.replace("rme-heading-", "");
4262
- return {
4263
- bold: r.some((l) => l.bold),
4264
- italic: r.some((l) => l.italic),
4265
- underline: r.some((l) => l.className === "rme-underline"),
4266
- strikethrough: r.some((l) => l.className === "rme-strikethrough"),
4267
- code: r.some((l) => l.className === "rme-code"),
4268
- link: r.some((l) => l.className === "rme-link"),
4269
- heading: a ?? null,
4270
- blockquote: r.some((l) => l.className === "rme-blockquote"),
4271
- bulletList: r.some((l) => l.className === "rme-list-bullet"),
4272
- orderedList: r.some((l) => l.className === "rme-list-ordered"),
4273
- codeBlock: r.some((l) => l.className === "rme-code-block")
4274
- };
4275
- }
4276
- var za = Object.defineProperty, Ba = Object.getOwnPropertyDescriptor, ze = (e, t, n, r) => {
4277
- for (var i = r > 1 ? void 0 : r ? Ba(t, n) : t, a = e.length - 1, l; a >= 0; a--)
4278
- (l = e[a]) && (i = (r ? l(t, n, i) : l(i)) || i);
4279
- return r && i && za(t, n, i), i;
4280
- };
4281
- const Aa = {
4282
- allowDangerousHtml: !0,
4283
- // preserves <u> underline passthrough
4284
- extensions: [gn()]
4285
- // renders ~~text~~ as <del>
4286
- }, Zt = {
4287
- extensions: [gn()],
4288
- mdastExtensions: [ma()]
4289
- }, Pe = new Ge({
4290
- headingStyle: "atx",
4291
- bulletListMarker: "-",
4292
- codeBlockStyle: "fenced",
4293
- fence: "```",
4294
- emDelimiter: "*",
4295
- strongDelimiter: "**"
4296
- });
4297
- Pe.addRule("inlineCode", {
4298
- filter: (e) => e.nodeName === "CODE" && e.parentElement?.nodeName !== "PRE",
4299
- replacement: (e) => "`" + e + "`"
4300
- });
4301
- Pe.addRule("underline", {
4302
- filter: ["u"],
4303
- replacement: (e) => "<u>" + e + "</u>"
4304
- });
4305
- Pe.addRule("strikethrough", {
4306
- filter: (e) => ["S", "DEL", "STRIKE"].includes(e.nodeName),
4307
- replacement: (e) => "~~" + e + "~~"
4308
- });
4309
- Pe.addRule("codeBlockWithLang", {
4310
- filter: (e) => e.nodeName === "PRE" && !!e.querySelector("code"),
4311
- replacement: (e, t) => {
4312
- const n = t, r = n.querySelector("code");
4313
- return "\n\n```" + (n.dataset.lang ?? "") + `
4314
- ` + (r?.textContent ?? "") + "\n```\n\n";
4315
- }
4316
- });
4317
- const Fa = {
4318
- heading: { bold: !0 },
4319
- // className set per depth below
4320
- emphasis: { italic: !0 },
4321
- strong: { bold: !0 },
4322
- inlineCode: { className: "rme-code" },
4323
- link: { underline: "solid", className: "rme-link" },
4324
- blockquote: { className: "rme-blockquote" },
4325
- code: { className: "rme-code-block" },
4326
- // fenced code block
4327
- delete: { className: "rme-strikethrough" }
4328
- // GFM ~~text~~
4329
- // list and html (underline) are handled dynamically below
4330
- }, Lt = class Lt extends Jt {
4331
- constructor() {
4332
- super(...arguments), this._defaultValue = "", this._valueInitialized = !1, this._defaultSourceMode = !1, this._sourceModeInitialized = !1, this.toolbar = !0, this.readOnly = !1, this._observer = null, this._savedRichRange = null, this._activeFormats = {}, this._syncTimer = null, this._pluginApi = null, this._ignoreRichMutations = !1, this._richViewRendered = !1, this._skipNextModeSwitch = !1, this._cachedTree = null, this._onSourceChange = (t) => {
4333
- const n = this._sourceEditor?.value ?? "";
4334
- n !== this.value && (this._value = n, this._syncNativeTextarea(), this._dispatchChange(n));
4335
- }, this._onToolbarAction = (t) => {
4336
- const { action: n, headingLevel: r, codeLanguage: i } = t.detail;
4337
- if (n === "source") {
4338
- this.sourceMode = !this.sourceMode;
4339
- return;
4340
- }
4341
- if (n === "code-block-language") {
4342
- this.sourceMode ? this._setSourceCodeBlockLanguage(i ?? "") : this._setRichCodeBlockLanguage(i ?? "");
4343
- return;
4344
- }
4345
- if (n === "heading" && r !== void 0) {
4346
- this.sourceMode ? this._setSourceHeadingLevel(r) : document.execCommand("formatBlock", !1, r ?? "p");
4347
- return;
4348
- }
4349
- this.sourceMode ? this._applySourceFormat(n) : this._applyRichFormat(n);
4350
- }, this._onKeyDown = (t) => {
4351
- if (!t.ctrlKey && !t.metaKey) return;
4352
- if (t.shiftKey && t.key === "S") {
4353
- t.preventDefault(), this.sourceMode = !this.sourceMode;
4354
- return;
4355
- }
4356
- if (t.shiftKey) return;
4357
- let n = null;
4358
- switch (t.key) {
4359
- case "b":
4360
- n = "bold";
4361
- break;
4362
- case "i":
4363
- n = "italic";
4364
- break;
4365
- case "u":
4366
- n = "underline";
4367
- break;
4368
- case "`":
4369
- n = "code";
4370
- break;
4371
- case "k":
4372
- n = "link";
4373
- break;
4374
- }
4375
- n && (t.preventDefault(), this.sourceMode ? this._applySourceFormat(n) : this._applyRichFormat(n));
4376
- }, this._onSelectionChange = () => {
4377
- const t = this.shadowRoot.getSelection?.() ?? window.getSelection();
4378
- if (!t || t.rangeCount === 0) return;
4379
- const n = t.getRangeAt(0), r = n.commonAncestorContainer, i = r.nodeType === Node.TEXT_NODE ? r.parentElement : r;
4380
- if (!this._richView?.contains(i) || (this._savedRichRange = n.cloneRange(), this.sourceMode)) return;
4381
- const a = i?.closest("pre");
4382
- this._activeFormats = {
4383
- bold: !!i?.closest("strong, b"),
4384
- italic: !!i?.closest("em, i"),
4385
- underline: !!i?.closest("u"),
4386
- strikethrough: !!i?.closest("s, del, strike"),
4387
- code: !a && !!i?.closest("code"),
4388
- link: !!i?.closest("a"),
4389
- heading: i?.closest("h1,h2,h3,h4,h5,h6")?.tagName.toLowerCase() ?? null,
4390
- blockquote: !!i?.closest("blockquote"),
4391
- bulletList: !!i?.closest("ul"),
4392
- orderedList: !!i?.closest("ol"),
4393
- codeBlock: !!a,
4394
- codeLanguage: a ? a.dataset.lang ?? "" : null
4395
- }, this._pushToolbarState();
4396
- };
4397
- }
4398
- get defaultValue() {
4399
- return this._defaultValue;
4400
- }
4401
- set defaultValue(t) {
4402
- this._defaultValue = t, this._valueInitialized || this.requestUpdate("defaultValue");
4403
- }
4404
- get value() {
4405
- return this._value ?? this._defaultValue;
4406
- }
4407
- set value(t) {
4408
- const n = this._value;
4409
- this._value = t, this._valueInitialized = !0, n !== t && (this._syncNativeTextarea(), this.requestUpdate("value", n));
4410
- }
4411
- get defaultSourceMode() {
4412
- return this._defaultSourceMode;
4413
- }
4414
- set defaultSourceMode(t) {
4415
- const n = this._defaultSourceMode;
4416
- this._defaultSourceMode = t, !this._sourceModeInitialized && this._sourceMode === void 0 && this.requestUpdate("defaultSourceMode", n);
4417
- }
4418
- get sourceMode() {
4419
- return this._sourceMode ?? this._defaultSourceMode;
4420
- }
4421
- set sourceMode(t) {
4422
- const n = this._sourceMode;
4423
- this._sourceMode = t, this._sourceModeInitialized = !0, this.requestUpdate("sourceMode", n), n !== t && this._dispatchModeChange(t ? "source" : "rich");
4424
- }
4425
- // ── Lifecycle ─────────────────────────────────────────────────────────────
4426
- connectedCallback() {
4427
- super.connectedCallback(), document.addEventListener("selectionchange", this._onSelectionChange), this.addEventListener("keydown", this._onKeyDown);
4428
- }
4429
- disconnectedCallback() {
4430
- super.disconnectedCallback(), document.removeEventListener("selectionchange", this._onSelectionChange), this.removeEventListener("keydown", this._onKeyDown), this._observer?.disconnect(), this._syncTimer !== null && clearTimeout(this._syncTimer);
4431
- }
4432
- firstUpdated() {
4433
- if (!this._valueInitialized) {
4434
- const t = this.querySelector("textarea");
4435
- t?.value && (this._defaultValue = t.value);
4436
- }
4437
- this._observer = new MutationObserver(() => {
4438
- this._ignoreRichMutations || this._scheduleMarkdownSync();
4439
- }), this._observer.observe(this._richView, {
4440
- childList: !0,
4441
- subtree: !0,
4442
- characterData: !0
4443
- }), this._setupSourcePlugin(), this.sourceMode ? (this._sourceEditor.value = this.value, this._skipNextModeSwitch = !0) : (this._setRichViewContent(this.value), this._skipNextModeSwitch = !0), this._syncNativeTextarea(), this._connectLabel();
4444
- }
4445
- updated(t) {
4446
- (t.has("sourceMode") || t.has("defaultSourceMode")) && (this._skipNextModeSwitch ? this._skipNextModeSwitch = !1 : this.sourceMode ? this._switchToSource() : this._switchToRich(), this._pushToolbarState()), t.has("value") && !this.sourceMode && this._richViewRendered && this._setRichViewContent(this.value);
4447
- }
4448
- // ── Rendering ─────────────────────────────────────────────────────────────
4449
- render() {
4450
- return Ne`
4451
- <slot></slot>
4452
-
4453
- ${this.toolbar ? Ne`<rc-editor-toolbar
4454
- part="toolbar"
4455
- @rc-toolbar-action=${this._onToolbarAction}
4456
- ></rc-editor-toolbar>` : en}
4457
-
4458
- <div
4459
- id="rich-view"
4460
- part="rich-view"
4461
- contenteditable=${this.readOnly ? "false" : "true"}
4462
- role="textbox"
4463
- aria-multiline="true"
4464
- spellcheck="true"
4465
- ?hidden=${this.sourceMode}
4466
- ></div>
4467
-
4468
- <div id="source-wrapper" ?hidden=${!this.sourceMode}>
4469
- <rc-textarea
4470
- id="source-editor"
4471
- word-wrap
4472
- @rc-change=${this._onSourceChange}
4473
- ></rc-textarea>
4474
- </div>
4475
- `;
4476
- }
4477
- // ── Rich view ─────────────────────────────────────────────────────────────
4478
- _setRichViewContent(t) {
4479
- this._richView && (this._ignoreRichMutations = !0, this._richView.innerHTML = this._renderMarkdown(t), this._ignoreRichMutations = !1, this._richViewRendered = !0);
4480
- }
4481
- _renderMarkdown(t) {
4482
- const n = Pi(t, Aa), r = Yt(t, Zt), i = [];
4483
- if (pt(r, "code", (o) => {
4484
- i.push(o.lang ?? null);
4485
- }), i.length === 0) return n;
4486
- const a = new DOMParser().parseFromString(n, "text/html"), l = a.querySelectorAll("pre");
4487
- return i.forEach((o, u) => {
4488
- l[u] && o && (l[u].dataset.lang = o);
4489
- }), a.body.innerHTML;
4490
- }
4491
- _scheduleMarkdownSync() {
4492
- this.sourceMode || (this._syncTimer !== null && clearTimeout(this._syncTimer), this._syncTimer = setTimeout(() => {
4493
- this._syncMarkdownFromRichView(), this._syncTimer = null;
4494
- }, 150));
4495
- }
4496
- _syncMarkdownFromRichView() {
4497
- if (!this._richView || this.sourceMode) return;
4498
- const t = Pe.turndown(this._richView.innerHTML);
4499
- t !== this.value && (this._value = t, this._syncNativeTextarea(), this._dispatchChange(t));
4500
- }
4501
- // ── Mode switching ────────────────────────────────────────────────────────
4502
- _switchToSource() {
4503
- !this._richView || !this._sourceEditor || (this._syncTimer !== null && (clearTimeout(this._syncTimer), this._syncTimer = null, this._syncMarkdownFromRichView()), this._sourceEditor.value = this.value, this._sourceEditor.clearHistory());
4504
- }
4505
- _switchToRich() {
4506
- if (!this._richView) return;
4507
- const t = this._sourceEditor?.value ?? this.value;
4508
- this._value = t, this._setRichViewContent(t), this._syncNativeTextarea();
4509
- }
4510
- _setupSourcePlugin() {
4511
- this._sourceEditor.usePlugin({
4512
- mount: (t) => {
4513
- this._pluginApi = t, t.onCursorMove((n, r) => {
4514
- if (!this.sourceMode) return;
4515
- const i = La(t.getDecorations(), n, r), a = i.codeBlock && this._cachedTree ? this._getCodeBlockLanguage(this._cachedTree, n) : null;
4516
- this._activeFormats = { ...i, codeLanguage: a }, this._pushToolbarState();
4517
- });
4518
- },
4519
- destroy: () => {
4520
- this._pluginApi = null, this._cachedTree = null;
4521
- },
4522
- update: (t, n) => {
4523
- const r = Yt(t, Zt);
4524
- this._cachedTree = r;
4525
- const i = [];
4526
- pt(
4527
- r,
4528
- (a) => {
4529
- const l = a.position?.start.offset, o = a.position?.end.offset;
4530
- if (l === void 0 || o === void 0) return;
4531
- if (a.type === "list") {
4532
- i.push({
4533
- type: "mark",
4534
- from: l,
4535
- to: o,
4536
- className: a.ordered ? "rme-list-ordered" : "rme-list-bullet"
4537
- });
4538
- return;
4539
- }
4540
- const u = Fa[a.type];
4541
- if (!u) return;
4542
- const s = { type: "mark", from: l, to: o, ...u };
4543
- a.type === "heading" && a.depth && (s.className = `rme-heading-h${a.depth}`), i.push(s);
4544
- }
4545
- ), n.setDecorations(i);
4546
- }
4547
- });
4548
- }
4549
- _getCodeBlockLanguage(t, n) {
4550
- let r = null;
4551
- return pt(
4552
- t,
4553
- "code",
4554
- (i) => {
4555
- const a = i.position?.start.offset, l = i.position?.end.offset;
4556
- a !== void 0 && l !== void 0 && a <= n && l >= n && (r = i.lang ?? "");
4557
- }
4558
- ), r;
4559
- }
4560
- _applyRichFormat(t) {
4561
- if (!(this.readOnly || !this._richView)) {
4562
- if (this._richView.focus(), this._savedRichRange) {
4563
- const n = window.getSelection();
4564
- n && (n.removeAllRanges(), n.addRange(this._savedRichRange.cloneRange()));
4565
- }
4566
- switch (t) {
4567
- case "bold":
4568
- document.execCommand("bold");
4569
- break;
4570
- case "italic":
4571
- document.execCommand("italic");
4572
- break;
4573
- case "underline":
4574
- document.execCommand("underline");
4575
- break;
4576
- case "strikethrough":
4577
- this._wrapRichSelection("s");
4578
- break;
4579
- case "code":
4580
- this._wrapRichSelection("code");
4581
- break;
4582
- case "blockquote": {
4583
- const n = this._activeFormats.blockquote ? "p" : "blockquote";
4584
- document.execCommand("formatBlock", !1, n);
4585
- break;
4586
- }
4587
- case "bullet-list":
4588
- document.execCommand("insertUnorderedList");
4589
- break;
4590
- case "ordered-list":
4591
- document.execCommand("insertOrderedList");
4592
- break;
4593
- case "code-block":
4594
- this._toggleRichCodeBlock();
4595
- break;
4596
- case "link": {
4597
- const n = prompt("Enter URL:");
4598
- n && document.execCommand("createLink", !1, n);
4599
- break;
4600
- }
4601
- }
4602
- }
4603
- }
4604
- _applySourceFormat(t) {
4605
- const n = this._sourceEditor;
4606
- if (n)
4607
- switch (t) {
4608
- case "bold":
4609
- n.wrapSelection("**", "**");
4610
- break;
4611
- case "italic":
4612
- n.wrapSelection("*", "*");
4613
- break;
4614
- case "underline":
4615
- n.wrapSelection("<u>", "</u>");
4616
- break;
4617
- case "strikethrough":
4618
- n.wrapSelection("~~", "~~");
4619
- break;
4620
- case "code":
4621
- n.wrapSelection("`", "`");
4622
- break;
4623
- case "link":
4624
- n.replaceSelection("[](url)");
4625
- break;
4626
- case "blockquote":
4627
- this._toggleLinePrefix("> ");
4628
- break;
4629
- case "bullet-list":
4630
- this._toggleLinePrefix("- ");
4631
- break;
4632
- case "ordered-list":
4633
- this._toggleLinePrefix("1. ");
4634
- break;
4635
- case "code-block":
4636
- this._toggleSourceCodeFence();
4637
- break;
4638
- }
4639
- }
4640
- /** Sets the heading level on the cursor's line in source mode. null = paragraph. */
4641
- _setSourceHeadingLevel(t) {
4642
- const n = this._pluginApi, r = this._sourceEditor;
4643
- if (!n || !r) return;
4644
- const { value: i, selectionStart: a } = n, l = i.lastIndexOf(`
4645
- `, a - 1) + 1, o = i.slice(l).replace(/^#{1,6} /, ""), u = t ? "#".repeat(parseInt(t[1])) + " " : "";
4646
- r.value = i.slice(0, l) + u + o + i.slice(
4647
- l + (i.slice(l).length - o.length)
4648
- );
4649
- }
4650
- /** Updates the language of the code block at the cursor in source mode. */
4651
- _setSourceCodeBlockLanguage(t) {
4652
- const n = this._pluginApi, r = this._sourceEditor;
4653
- if (!n || !r) return;
4654
- const { value: i, selectionStart: a } = n, o = i.slice(0, a).match(/```\w*\n(?![\s\S]*```)/);
4655
- if (!o?.index === void 0) return;
4656
- const u = o?.index ?? 0, s = u + (o?.[0].indexOf(`
4657
- `) ?? 3) + 1;
4658
- r.value = i.slice(0, u) + "```" + t + `
4659
- ` + i.slice(s);
4660
- }
4661
- /** Updates the data-lang attribute on the <pre> at the cursor in rich mode. */
4662
- _setRichCodeBlockLanguage(t) {
4663
- const n = window.getSelection();
4664
- if (!n || n.rangeCount === 0) return;
4665
- const r = n.getRangeAt(0).commonAncestorContainer, a = (r.nodeType === Node.TEXT_NODE ? r.parentElement : r)?.closest("pre");
4666
- a && (t ? a.dataset.lang = t : delete a.dataset.lang);
4667
- }
4668
- /** Toggles a line prefix (e.g. `'# '`, `'> '`, `'- '`) on the cursor's line. */
4669
- _toggleLinePrefix(t) {
4670
- const n = this._pluginApi, r = this._sourceEditor;
4671
- if (!n || !r) return;
4672
- const { value: i, selectionStart: a } = n, l = i.lastIndexOf(`
4673
- `, a - 1) + 1;
4674
- i.startsWith(t, l) ? r.value = i.slice(0, l) + i.slice(l + t.length) : r.value = i.slice(0, l) + t + i.slice(l);
4675
- }
4676
- /** Wraps the current selection (or cursor line) with a fenced code block. */
4677
- _toggleSourceCodeFence() {
4678
- const t = this._pluginApi, n = this._sourceEditor;
4679
- if (!t || !n) return;
4680
- const { value: r, selectionStart: i, selectionEnd: a } = t, l = "```", o = r.lastIndexOf(`
4681
- `, i - 1) + 1, u = r.indexOf(`
4682
- `, a), s = u === -1 ? r.length : u, d = r.lastIndexOf(`
4683
- `, o - 2), p = d === -1 ? "" : r.slice(d + 1, o - 1), g = s + 1, c = r.indexOf(`
4684
- `, g), b = r.slice(g, c === -1 ? void 0 : c);
4685
- if (p.trim() === l && b.trim() === l) {
4686
- const z = d === -1 ? 0 : d + 1, x = c === -1 ? r.length : c + 1, w = r.slice(o, s);
4687
- n.value = r.slice(0, z) + w + `
4688
- ` + r.slice(x);
4689
- return;
4690
- }
4691
- const _ = r.slice(o, s);
4692
- n.value = r.slice(0, o) + l + `
4693
- ` + _ + `
4694
- ` + l + r.slice(s);
4695
- }
4696
- _wrapRichSelection(t) {
4697
- const n = window.getSelection();
4698
- if (!n || n.rangeCount === 0) return;
4699
- const r = n.getRangeAt(0);
4700
- if (r.collapsed) return;
4701
- const i = document.createElement(t);
4702
- try {
4703
- r.surroundContents(i);
4704
- } catch {
4705
- const a = r.extractContents();
4706
- i.appendChild(a), r.insertNode(i);
4707
- }
4708
- n.removeAllRanges(), n.addRange(r);
4709
- }
4710
- _toggleRichCodeBlock() {
4711
- const t = window.getSelection();
4712
- if (!t || t.rangeCount === 0) return;
4713
- const n = t.getRangeAt(0), r = n.commonAncestorContainer, i = r.nodeType === Node.TEXT_NODE ? r.parentElement : r, a = i?.closest("pre");
4714
- if (a) {
4715
- const u = document.createElement("p");
4716
- u.textContent = a.textContent ?? "", a.replaceWith(u);
4717
- return;
4718
- }
4719
- const l = document.createElement("pre"), o = document.createElement("code");
4720
- l.appendChild(o);
4721
- try {
4722
- const u = n.extractContents();
4723
- o.appendChild(u), n.insertNode(l);
4724
- } catch {
4725
- i && i !== this._richView && (o.textContent = i.textContent ?? "", i.replaceWith(l));
4726
- }
4727
- }
4728
- // ── Toolbar state sync ────────────────────────────────────────────────────
4729
- _pushToolbarState() {
4730
- const t = this._toolbarEl;
4731
- t && (t.activeBold = !!this._activeFormats.bold, t.activeItalic = !!this._activeFormats.italic, t.activeUnderline = !!this._activeFormats.underline, t.activeStrikethrough = !!this._activeFormats.strikethrough, t.activeCode = !!this._activeFormats.code, t.activeHeading = this._activeFormats.heading ?? null, t.activeBlockquote = !!this._activeFormats.blockquote, t.activeBulletList = !!this._activeFormats.bulletList, t.activeOrderedList = !!this._activeFormats.orderedList, t.activeCodeBlock = !!this._activeFormats.codeBlock, t.codeLanguage = this._activeFormats.codeLanguage ?? null, t.sourceMode = this.sourceMode), this.dispatchEvent(new CustomEvent("rc-formatting-change", {
4732
- bubbles: !0,
4733
- composed: !0,
4734
- detail: { ...this._activeFormats }
4735
- }));
4736
- }
4737
- // ── Form integration ──────────────────────────────────────────────────────
4738
- _syncNativeTextarea() {
4739
- const t = this.querySelector("textarea");
4740
- t && (t.value = this.value);
4741
- }
4742
- _connectLabel() {
4743
- const t = this.querySelector("textarea");
4744
- if (!t) return;
4745
- const n = t.id ? this.querySelector(`label[for="${CSS.escape(t.id)}"]`) : null;
4746
- n && this._richView && this._richView.setAttribute("aria-label", n.textContent?.trim() ?? ""), n?.addEventListener("click", () => {
4747
- this.sourceMode || this._richView?.focus();
4748
- });
4749
- }
4750
- // ── Events ────────────────────────────────────────────────────────────────
4751
- _dispatchChange(t) {
4752
- this.dispatchEvent(new CustomEvent("rc-change", {
4753
- bubbles: !0,
4754
- composed: !0,
4755
- detail: { value: t }
4756
- }));
4757
- }
4758
- _dispatchModeChange(t) {
4759
- this.dispatchEvent(new CustomEvent("rc-mode-change", {
4760
- bubbles: !0,
4761
- composed: !0,
4762
- detail: { mode: t }
4763
- }));
4764
- }
4765
- };
4766
- Lt.styles = Ia;
4767
- let Se = Lt;
4768
- ze([
4769
- Q({ type: String, attribute: "default-value" })
4770
- ], Se.prototype, "defaultValue", 1);
4771
- ze([
4772
- Q({ type: Boolean, attribute: "default-source-mode" })
4773
- ], Se.prototype, "defaultSourceMode", 1);
4774
- ze([
4775
- Q({ type: Boolean, reflect: !0, attribute: "source-mode" })
4776
- ], Se.prototype, "sourceMode", 1);
4777
- ze([
4778
- Q({ type: Boolean, reflect: !0 })
4779
- ], Se.prototype, "toolbar", 2);
4780
- ze([
4781
- Q({ type: Boolean, reflect: !0, attribute: "read-only" })
4782
- ], Se.prototype, "readOnly", 2);
4783
- ze([
4784
- St("#rich-view")
4785
- ], Se.prototype, "_richView", 2);
4786
- ze([
4787
- St("#source-editor")
4788
- ], Se.prototype, "_sourceEditor", 2);
4789
- ze([
4790
- St("rc-editor-toolbar")
4791
- ], Se.prototype, "_toolbarEl", 2);
4792
- const pe = (e) => se`
4793
- <svg
4794
- viewBox="0 0 16 16"
4795
- width="1em"
4796
- height="1em"
4797
- aria-hidden="true"
4798
- focusable="false"
4799
- >${e}</svg>
4800
- `, ge = {
4801
- bold: pe(se`
4802
- <path fill="currentColor" d="M8.21 13c2.106 0 3.412-1.087 3.412-2.823c0-1.306-.984-2.283-2.324-2.386v-.055a2.176 2.176 0 0 0 1.852-2.14c0-1.51-1.162-2.46-3.014-2.46H3.843V13zM5.908 4.674h1.696c.963 0 1.517.451 1.517 1.244c0 .834-.629 1.32-1.73 1.32H5.908V4.673zm0 6.788V8.598h1.73c1.217 0 1.88.492 1.88 1.415c0 .943-.643 1.449-1.832 1.449H5.907z"/>
4803
- `),
4804
- italic: pe(se`
4805
- <path fill="currentColor" d="M7.991 11.674L9.53 4.455c.123-.595.246-.71 1.347-.807l.11-.52H7.211l-.11.52c1.06.096 1.128.212 1.005.807L6.57 11.674c-.123.595-.246.71-1.346.806l-.11.52h3.774l.11-.52c-1.06-.095-1.129-.211-1.006-.806z"/>
4806
- `),
4807
- underline: pe(se`
4808
- <path fill="currentColor" d="M5.313 3.136h-1.23V9.54c0 2.105 1.47 3.623 3.917 3.623s3.917-1.518 3.917-3.623V3.136h-1.23v6.323c0 1.49-.978 2.57-2.687 2.57s-2.687-1.08-2.687-2.57zM12.5 15h-9v-1h9z"/>
4809
- `),
4810
- strikethrough: pe(se`
4811
- <path fill="currentColor" d="M6.333 5.686c0 .31.083.581.27.814H5.166a2.8 2.8 0 0 1-.099-.76c0-1.627 1.436-2.768 3.48-2.768c1.969 0 3.39 1.175 3.445 2.85h-1.23c-.11-1.08-.964-1.743-2.25-1.743c-1.23 0-2.18.602-2.18 1.607zm2.194 7.478c-2.153 0-3.589-1.107-3.705-2.81h1.23c.144 1.06 1.129 1.703 2.544 1.703c1.34 0 2.31-.705 2.31-1.675c0-.827-.547-1.374-1.914-1.675L8.046 8.5H1v-1h14v1h-3.504c.468.437.675.994.675 1.697c0 1.826-1.436 2.967-3.644 2.967"/>
4812
- `),
4813
- code: pe(se`
4814
- <path fill="currentColor" d="M5.854 4.854a.5.5 0 1 0-.708-.708l-3.5 3.5a.5.5 0 0 0 0 .708l3.5 3.5a.5.5 0 0 0 .708-.708L2.707 8zm4.292 0a.5.5 0 0 1 .708-.708l3.5 3.5a.5.5 0 0 1 0 .708l-3.5 3.5a.5.5 0 0 1-.708-.708L13.293 8z"/>
4815
- `),
4816
- link: pe(se`
4817
- <g fill="currentColor">
4818
- <path d="M4.715 6.542L3.343 7.914a3 3 0 1 0 4.243 4.243l1.828-1.829A3 3 0 0 0 8.586 5.5L8 6.086a1 1 0 0 0-.154.199a2 2 0 0 1 .861 3.337L6.88 11.45a2 2 0 1 1-2.83-2.83l.793-.792a4 4 0 0 1-.128-1.287z"/>
4819
- <path d="M6.586 4.672A3 3 0 0 0 7.414 9.5l.775-.776a2 2 0 0 1-.896-3.346L9.12 3.55a2 2 0 1 1 2.83 2.83l-.793.792c.112.42.155.855.128 1.287l1.372-1.372a3 3 0 1 0-4.243-4.243z"/>
4820
- </g>
4821
- `),
4822
- blockquote: pe(se`
4823
- <path fill="currentColor" d="M2.5 3a.5.5 0 0 0 0 1h11a.5.5 0 0 0 0-1zm5 3a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm0 3a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm-5 3a.5.5 0 0 0 0 1h11a.5.5 0 0 0 0-1zm.79-5.373q.168-.117.444-.275L3.524 6q-.183.111-.452.287q-.27.176-.51.428a2.4 2.4 0 0 0-.398.562Q2 7.587 2 7.969q0 .54.217.873q.217.328.72.328q.322 0 .504-.211a.7.7 0 0 0 .188-.463q0-.345-.211-.521q-.205-.182-.568-.182h-.282q.036-.305.123-.498a1.4 1.4 0 0 1 .252-.37a2 2 0 0 1 .346-.298zm2.167 0q.17-.117.445-.275L5.692 6q-.183.111-.452.287q-.27.176-.51.428a2.4 2.4 0 0 0-.398.562q-.165.31-.164.692q0 .54.217.873q.217.328.72.328q.322 0 .504-.211a.7.7 0 0 0 .188-.463q0-.345-.211-.521q-.205-.182-.568-.182h-.282a1.8 1.8 0 0 1 .118-.492q.087-.194.257-.375a2 2 0 0 1 .346-.3z"/>
4824
- `),
4825
- bulletList: pe(se`
4826
- <path fill="currentColor" fill-rule="evenodd" d="M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m-3 1a1 1 0 1 0 0-2a1 1 0 0 0 0 2m0 4a1 1 0 1 0 0-2a1 1 0 0 0 0 2m0 4a1 1 0 1 0 0-2a1 1 0 0 0 0 2"/>
4827
- `),
4828
- orderedList: pe(se`
4829
- <g fill="currentColor">
4830
- <path fill-rule="evenodd" d="M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5"/>
4831
- <path d="M1.713 11.865v-.474H2c.217 0 .363-.137.363-.317c0-.185-.158-.31-.361-.31c-.223 0-.367.152-.373.31h-.59c.016-.467.373-.787.986-.787c.588-.002.954.291.957.703a.595.595 0 0 1-.492.594v.033a.615.615 0 0 1 .569.631c.003.533-.502.8-1.051.8c-.656 0-1-.37-1.008-.794h.582c.008.178.186.306.422.309c.254 0 .424-.145.422-.35c-.002-.195-.155-.348-.414-.348h-.3zm-.004-4.699h-.604v-.035c0-.408.295-.844.958-.844c.583 0 .96.326.96.756c0 .389-.257.617-.476.848l-.537.572v.03h1.054V9H1.143v-.395l.957-.99c.138-.142.293-.304.293-.508c0-.18-.147-.32-.342-.32a.33.33 0 0 0-.342.338zM2.564 5h-.635V2.924h-.031l-.598.42v-.567l.629-.443h.635z"/>
4832
- </g>
4833
- `),
4834
- codeBlock: pe(se`
4835
- <path fill="currentColor" d="M2.114 8.063V7.9c1.005-.102 1.497-.615 1.497-1.6V4.503c0-1.094.39-1.538 1.354-1.538h.273V2h-.376C3.25 2 2.49 2.759 2.49 4.352v1.524c0 1.094-.376 1.456-1.49 1.456v1.299c1.114 0 1.49.362 1.49 1.456v1.524c0 1.593.759 2.352 2.372 2.352h.376v-.964h-.273c-.964 0-1.354-.444-1.354-1.538V9.663c0-.984-.492-1.497-1.497-1.6M13.886 7.9v.163c-1.005.103-1.497.616-1.497 1.6v1.798c0 1.094-.39 1.538-1.354 1.538h-.273v.964h.376c1.613 0 2.372-.759 2.372-2.352v-1.524c0-1.094.376-1.456 1.49-1.456V7.332c-1.114 0-1.49-.362-1.49-1.456V4.352C13.51 2.759 12.75 2 11.138 2h-.376v.964h.273c.964 0 1.354.444 1.354 1.538V6.3c0 .984.492 1.497 1.497 1.6"/>
4836
- `),
4837
- source: pe(se`
4838
- <g fill="currentColor">
4839
- <path d="M14 3a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM2 2a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2z"/>
4840
- <path fill-rule="evenodd" d="M9.146 8.146a.5.5 0 0 1 .708 0L11.5 9.793l1.646-1.647a.5.5 0 0 1 .708.708l-2 2a.5.5 0 0 1-.708 0l-2-2a.5.5 0 0 1 0-.708"/>
4841
- <path fill-rule="evenodd" d="M11.5 5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0v-4a.5.5 0 0 1 .5-.5"/>
4842
- <path d="M3.56 11V7.01h.056l1.428 3.239h.774l1.42-3.24h.056V11h1.073V5.001h-1.2l-1.71 3.894h-.039l-1.71-3.894H2.5V11z"/>
4843
- </g>
4844
- `)
4845
- };
4846
- var Ma = Object.defineProperty, ee = (e, t, n, r) => {
4847
- for (var i = void 0, a = e.length - 1, l; a >= 0; a--)
4848
- (l = e[a]) && (i = l(t, n, i) || i);
4849
- return i && Ma(t, n, i), i;
4850
- };
4851
- const Ra = [
4852
- { value: "", label: "Paragraph" },
4853
- { value: "h1", label: "Heading 1" },
4854
- { value: "h2", label: "Heading 2" },
4855
- { value: "h3", label: "Heading 3" },
4856
- { value: "h4", label: "Heading 4" },
4857
- { value: "h5", label: "Heading 5" },
4858
- { value: "h6", label: "Heading 6" }
4859
- ];
4860
- class te extends Jt {
4861
- constructor() {
4862
- super(...arguments), this.label = "Formatting", this.activeBold = !1, this.activeItalic = !1, this.activeUnderline = !1, this.activeStrikethrough = !1, this.activeCode = !1, this.activeHeading = null, this.activeBlockquote = !1, this.activeBulletList = !1, this.activeOrderedList = !1, this.activeCodeBlock = !1, this.codeLanguage = null, this.sourceMode = !1, this._langInputValue = "", this._onClick = (t) => {
4863
- const n = t.target.closest("button[data-action]");
4864
- n && this._dispatch(n.dataset.action);
4865
- }, this._onHeadingChange = (t) => {
4866
- const n = t.target.value;
4867
- this._dispatch("heading", { headingLevel: n || null });
4868
- }, this._onLangInput = (t) => {
4869
- this._langInputValue = t.target.value;
4870
- }, this._onLangCommit = () => {
4871
- this._dispatch("code-block-language", { codeLanguage: this._langInputValue.trim() });
4872
- }, this._onLangKeyDown = (t) => {
4873
- t.key === "Enter" && (t.preventDefault(), this._onLangCommit());
4874
- };
4875
- }
4876
- createRenderRoot() {
4877
- return this;
4878
- }
4879
- updated(t) {
4880
- t.has("codeLanguage") && this.codeLanguage !== null && (this._langInputValue = this.codeLanguage);
4881
- }
4882
- // ── Event helpers ─────────────────────────────────────────────────────────
4883
- _dispatch(t, n) {
4884
- this.dispatchEvent(
4885
- new CustomEvent("rc-toolbar-action", {
4886
- bubbles: !0,
4887
- composed: !0,
4888
- detail: { action: t, ...n }
4889
- })
4890
- );
4891
- }
4892
- // ── Rendering ─────────────────────────────────────────────────────────────
4893
- render() {
4894
- const t = (r) => String(r), n = this.activeHeading ?? "";
4895
- return Ne`
4896
- <div role="toolbar" aria-label=${this.label} @click=${this._onClick}>
4897
-
4898
- <button type="button" data-action="bold"
4899
- title="Bold (Ctrl+B)" aria-label="Bold" aria-pressed=${t(this.activeBold)}
4900
- >${ge.bold}</button>
4901
-
4902
- <button type="button" data-action="italic"
4903
- title="Italic (Ctrl+I)" aria-label="Italic" aria-pressed=${t(this.activeItalic)}
4904
- >${ge.italic}</button>
4905
-
4906
- <button type="button" data-action="underline"
4907
- title="Underline (Ctrl+U)" aria-label="Underline" aria-pressed=${t(this.activeUnderline)}
4908
- >${ge.underline}</button>
4909
-
4910
- <button type="button" data-action="strikethrough"
4911
- title="Strikethrough" aria-label="Strikethrough" aria-pressed=${t(this.activeStrikethrough)}
4912
- >${ge.strikethrough}</button>
4913
-
4914
- <button type="button" data-action="code"
4915
- title="Inline Code (Ctrl+\`)" aria-label="Inline Code" aria-pressed=${t(this.activeCode)}
4916
- >${ge.code}</button>
4917
-
4918
- <button type="button" data-action="link"
4919
- title="Link (Ctrl+K)" aria-label="Link"
4920
- >${ge.link}</button>
4921
-
4922
- <select
4923
- aria-label="Heading level"
4924
- title="Heading level"
4925
- class=${this.activeHeading ? "toolbar-active" : ""}
4926
- @change=${this._onHeadingChange}
4927
- .value=${n}
4928
- >
4929
- ${Ra.map(({ value: r, label: i }) => Ne`
4930
- <option value=${r} ?selected=${n === r}>${i}</option>
4931
- `)}
4932
- </select>
4933
-
4934
- <button type="button" data-action="blockquote"
4935
- title="Blockquote" aria-label="Blockquote" aria-pressed=${t(this.activeBlockquote)}
4936
- >${ge.blockquote}</button>
4937
-
4938
- <button type="button" data-action="bullet-list"
4939
- title="Bullet List" aria-label="Bullet List" aria-pressed=${t(this.activeBulletList)}
4940
- >${ge.bulletList}</button>
4941
-
4942
- <button type="button" data-action="ordered-list"
4943
- title="Ordered List" aria-label="Ordered List" aria-pressed=${t(this.activeOrderedList)}
4944
- >${ge.orderedList}</button>
4945
-
4946
- <button type="button" data-action="code-block"
4947
- title="Code Block" aria-label="Code Block" aria-pressed=${t(this.activeCodeBlock)}
4948
- >${ge.codeBlock}</button>
4949
-
4950
- ${this.activeCodeBlock && this.codeLanguage !== null ? Ne`
4951
- <input
4952
- type="text"
4953
- class="lang-input"
4954
- aria-label="Code block language"
4955
- placeholder="Language"
4956
- title="Syntax language (e.g. TypeScript, Rust)"
4957
- .value=${this._langInputValue}
4958
- @input=${this._onLangInput}
4959
- @blur=${this._onLangCommit}
4960
- @keydown=${this._onLangKeyDown}
4961
- @click=${(r) => r.stopPropagation()}
4962
- />
4963
- ` : en}
4964
-
4965
- <button type="button" data-action="source"
4966
- title="Toggle Markdown Source (Ctrl+Shift+S)" aria-label="Source Mode"
4967
- aria-pressed=${t(this.sourceMode)}
4968
- >${ge.source}</button>
4969
-
4970
- </div>
4971
- `;
4972
- }
4973
- }
4974
- ee([
4975
- Q({ type: String })
4976
- ], te.prototype, "label");
4977
- ee([
4978
- Q({ type: Boolean, reflect: !0, attribute: "active-bold" })
4979
- ], te.prototype, "activeBold");
4980
- ee([
4981
- Q({ type: Boolean, reflect: !0, attribute: "active-italic" })
4982
- ], te.prototype, "activeItalic");
4983
- ee([
4984
- Q({ type: Boolean, reflect: !0, attribute: "active-underline" })
4985
- ], te.prototype, "activeUnderline");
4986
- ee([
4987
- Q({ type: Boolean, reflect: !0, attribute: "active-strikethrough" })
4988
- ], te.prototype, "activeStrikethrough");
4989
- ee([
4990
- Q({ type: Boolean, reflect: !0, attribute: "active-code" })
4991
- ], te.prototype, "activeCode");
4992
- ee([
4993
- Q({ attribute: "active-heading" })
4994
- ], te.prototype, "activeHeading");
4995
- ee([
4996
- Q({ type: Boolean, reflect: !0, attribute: "active-blockquote" })
4997
- ], te.prototype, "activeBlockquote");
4998
- ee([
4999
- Q({ type: Boolean, reflect: !0, attribute: "active-bullet-list" })
5000
- ], te.prototype, "activeBulletList");
5001
- ee([
5002
- Q({ type: Boolean, reflect: !0, attribute: "active-ordered-list" })
5003
- ], te.prototype, "activeOrderedList");
5004
- ee([
5005
- Q({ type: Boolean, reflect: !0, attribute: "active-code-block" })
5006
- ], te.prototype, "activeCodeBlock");
5007
- ee([
5008
- Q({ attribute: "code-language" })
5009
- ], te.prototype, "codeLanguage");
5010
- ee([
5011
- Q({ type: Boolean, reflect: !0, attribute: "source-mode" })
5012
- ], te.prototype, "sourceMode");
5013
- ee([
5014
- Pn()
5015
- ], te.prototype, "_langInputValue");
5016
- export {
5017
- te as R,
5018
- Se as a
5019
- };
5020
- //# sourceMappingURL=rc-editor-toolbar-B74gMsna.js.map