@vizel/core 0.0.1-alpha.2 → 0.0.1-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/index.d.ts +13 -13
  2. package/dist/index10.js +1 -1
  3. package/dist/index11.js +2 -2
  4. package/dist/index14.js +1 -1
  5. package/dist/index20.js +2 -2
  6. package/dist/index21.js +2 -2
  7. package/dist/index22.js +3 -3
  8. package/dist/index26.js +1 -1
  9. package/dist/index3.js +1 -1
  10. package/dist/index31.js +2 -2
  11. package/dist/index34.js +63 -16
  12. package/dist/index35.js +4 -58
  13. package/dist/index36.js +123 -15
  14. package/dist/index37.js +316 -37
  15. package/dist/index38.js +481 -58
  16. package/dist/index39.js +48 -4
  17. package/dist/index4.js +1 -1
  18. package/dist/index40.js +664 -108
  19. package/dist/index41.js +4 -327
  20. package/dist/index42.js +4 -487
  21. package/dist/index43.js +206 -647
  22. package/dist/index44.js +82 -4
  23. package/dist/index45.js +17 -4
  24. package/dist/index46.js +57 -237
  25. package/dist/index47.js +15 -82
  26. package/dist/index48.js +4 -4
  27. package/dist/index49.js +3 -3
  28. package/dist/index5.js +1 -1
  29. package/dist/index50.js +1408 -1467
  30. package/dist/index51.js +5 -1502
  31. package/dist/index52.js +1533 -695
  32. package/dist/index53.js +723 -5
  33. package/dist/index54.js +84 -21
  34. package/dist/index55.js +246 -10
  35. package/dist/index56.js +3 -7
  36. package/dist/index57.js +1231 -7
  37. package/dist/index58.js +731 -11
  38. package/dist/index59.js +21 -19
  39. package/dist/index6.js +1 -1
  40. package/dist/index60.js +10 -25
  41. package/dist/index61.js +6 -83
  42. package/dist/index62.js +7 -245
  43. package/dist/index63.js +11 -1229
  44. package/dist/index64.js +17 -732
  45. package/dist/index65.js +25 -3
  46. package/dist/index66.js +1 -1
  47. package/dist/index68.js +91 -98
  48. package/dist/index69.js +3 -90
  49. package/dist/index70.js +98 -4
  50. package/dist/index8.js +1 -1
  51. package/dist/index9.js +1 -1
  52. package/package.json +27 -15
  53. package/LICENSE +0 -21
package/dist/index50.js CHANGED
@@ -1,1563 +1,1504 @@
1
- function O() {
2
- return {
3
- async: !1,
4
- breaks: !1,
5
- extensions: null,
6
- gfm: !0,
7
- hooks: null,
8
- pedantic: !1,
9
- renderer: null,
10
- silent: !1,
11
- tokenizer: null,
12
- walkTokens: null
13
- };
14
- }
15
- var S = O();
16
- function ie(n) {
17
- S = n;
18
- }
19
- var z = { exec: () => null };
20
- function u(n, e = "") {
21
- let t = typeof n == "string" ? n : n.source;
22
- const s = {
23
- replace: (r, i) => {
24
- let l = typeof i == "string" ? i : i.source;
25
- return l = l.replace(x.caret, "$1"), t = t.replace(r, l), s;
26
- },
27
- getRegex: () => new RegExp(t, e)
28
- };
29
- return s;
30
- }
31
- var x = {
32
- codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
33
- outputLinkReplace: /\\([\[\]])/g,
34
- indentCodeCompensation: /^(\s+)(?:```)/,
35
- beginningSpace: /^\s+/,
36
- endingHash: /#$/,
37
- startingSpaceChar: /^ /,
38
- endingSpaceChar: / $/,
39
- nonSpaceChar: /[^ ]/,
40
- newLineCharGlobal: /\n/g,
41
- tabCharGlobal: /\t/g,
42
- multipleSpaceGlobal: /\s+/g,
43
- blankLine: /^[ \t]*$/,
44
- doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
45
- blockquoteStart: /^ {0,3}>/,
46
- blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
47
- blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
48
- listReplaceTabs: /^\t+/,
49
- listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
50
- listIsTask: /^\[[ xX]\] /,
51
- listReplaceTask: /^\[[ xX]\] +/,
52
- anyLine: /\n.*\n/,
53
- hrefBrackets: /^<(.*)>$/,
54
- tableDelimiter: /[:|]/,
55
- tableAlignChars: /^\||\| *$/g,
56
- tableRowBlankLine: /\n[ \t]*$/,
57
- tableAlignRight: /^ *-+: *$/,
58
- tableAlignCenter: /^ *:-+: *$/,
59
- tableAlignLeft: /^ *:-+ *$/,
60
- startATag: /^<a /i,
61
- endATag: /^<\/a>/i,
62
- startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
63
- endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
64
- startAngleBracket: /^</,
65
- endAngleBracket: />$/,
66
- pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
67
- unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
68
- escapeTest: /[&<>"']/,
69
- escapeReplace: /[&<>"']/g,
70
- escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
71
- escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
72
- unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
73
- caret: /(^|[^\[])\^/g,
74
- percentDecode: /%25/g,
75
- findPipe: /\|/g,
76
- splitPipe: / \|/,
77
- slashPipe: /\\\|/g,
78
- carriageReturn: /\r\n|\r/g,
79
- spaceLine: /^ +$/gm,
80
- notSpaceStart: /^\S*/,
81
- endingNewline: /\n$/,
82
- listItemRegex: (n) => new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),
83
- nextBulletRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
84
- hrRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
85
- fencesBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:\`\`\`|~~~)`),
86
- headingBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}#`),
87
- htmlBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}<(?:[a-z].*>|!--)`, "i")
88
- }, xe = /^(?:[ \t]*(?:\n|$))+/, be = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, me = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, _ = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, we = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, N = /(?:[*+-]|\d{1,9}[.)])/, le = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, ae = u(le).replace(/bull/g, N).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(), ye = u(le).replace(/bull/g, N).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), j = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Re = /^[^\n]+/, H = /(?!\s*\])(?:\\.|[^\[\]\\])+/, Se = u(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", H).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), $e = u(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, N).getRegex(), B = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", Q = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Te = u(
89
- "^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))",
90
- "i"
91
- ).replace("comment", Q).replace("tag", B).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), oe = u(j).replace("hr", _).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", B).getRegex(), ve = u(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", oe).getRegex(), F = {
92
- blockquote: ve,
93
- code: be,
94
- def: Se,
95
- fences: me,
96
- heading: we,
97
- hr: _,
98
- html: Te,
99
- lheading: ae,
100
- list: $e,
101
- newline: xe,
102
- paragraph: oe,
103
- table: z,
104
- text: Re
105
- }, ee = u(
106
- "^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
107
- ).replace("hr", _).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", B).getRegex(), ze = {
108
- ...F,
109
- lheading: ye,
110
- table: ee,
111
- paragraph: u(j).replace("hr", _).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", ee).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", B).getRegex()
112
- }, _e = {
113
- ...F,
114
- html: u(
115
- `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
116
- ).replace("comment", Q).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
117
- def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
118
- heading: /^(#{1,6})(.*)(?:\n+|$)/,
119
- fences: z,
120
- // fences not supported
121
- lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
122
- paragraph: u(j).replace("hr", _).replace("heading", ` *#{1,6} *[^
123
- ]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
124
- }, Ae = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Le = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, ce = /^( {2,}|\\)\n(?!\s*$)/, Pe = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, E = /[\p{P}\p{S}]/u, U = /[\s\p{P}\p{S}]/u, he = /[^\s\p{P}\p{S}]/u, Ce = u(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, U).getRegex(), pe = /(?!~)[\p{P}\p{S}]/u, Ie = /(?!~)[\s\p{P}\p{S}]/u, Be = /(?:[^\s\p{P}\p{S}]|~)/u, Ee = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g, ue = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, qe = u(ue, "u").replace(/punct/g, E).getRegex(), Ze = u(ue, "u").replace(/punct/g, pe).getRegex(), ge = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", De = u(ge, "gu").replace(/notPunctSpace/g, he).replace(/punctSpace/g, U).replace(/punct/g, E).getRegex(), Me = u(ge, "gu").replace(/notPunctSpace/g, Be).replace(/punctSpace/g, Ie).replace(/punct/g, pe).getRegex(), Ge = u(
125
- "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
126
- "gu"
127
- ).replace(/notPunctSpace/g, he).replace(/punctSpace/g, U).replace(/punct/g, E).getRegex(), Oe = u(/\\(punct)/, "gu").replace(/punct/g, E).getRegex(), Ne = u(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), je = u(Q).replace("(?:-->|$)", "-->").getRegex(), He = u(
128
- "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
129
- ).replace("comment", je).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), P = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, Qe = u(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", P).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), fe = u(/^!?\[(label)\]\[(ref)\]/).replace("label", P).replace("ref", H).getRegex(), ke = u(/^!?\[(ref)\](?:\[\])?/).replace("ref", H).getRegex(), Fe = u("reflink|nolink(?!\\()", "g").replace("reflink", fe).replace("nolink", ke).getRegex(), X = {
130
- _backpedal: z,
131
- // only used for GFM url
132
- anyPunctuation: Oe,
133
- autolink: Ne,
134
- blockSkip: Ee,
135
- br: ce,
136
- code: Le,
137
- del: z,
138
- emStrongLDelim: qe,
139
- emStrongRDelimAst: De,
140
- emStrongRDelimUnd: Ge,
141
- escape: Ae,
142
- link: Qe,
143
- nolink: ke,
144
- punctuation: Ce,
145
- reflink: fe,
146
- reflinkSearch: Fe,
147
- tag: He,
148
- text: Pe,
149
- url: z
150
- }, Ue = {
151
- ...X,
152
- link: u(/^!?\[(label)\]\((.*?)\)/).replace("label", P).getRegex(),
153
- reflink: u(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", P).getRegex()
154
- }, D = {
155
- ...X,
156
- emStrongRDelimAst: Me,
157
- emStrongLDelim: Ze,
158
- url: u(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
159
- _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
160
- del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
161
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
162
- }, Xe = {
163
- ...D,
164
- br: u(ce).replace("{2,}", "*").getRegex(),
165
- text: u(D.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
166
- }, A = {
167
- normal: F,
168
- gfm: ze,
169
- pedantic: _e
170
- }, T = {
171
- normal: X,
172
- gfm: D,
173
- breaks: Xe,
174
- pedantic: Ue
175
- }, We = {
176
- "&": "&amp;",
177
- "<": "&lt;",
178
- ">": "&gt;",
179
- '"': "&quot;",
180
- "'": "&#39;"
181
- }, te = (n) => We[n];
182
- function m(n, e) {
183
- if (e) {
184
- if (x.escapeTest.test(n))
185
- return n.replace(x.escapeReplace, te);
186
- } else if (x.escapeTestNoEncode.test(n))
187
- return n.replace(x.escapeReplaceNoEncode, te);
188
- return n;
189
- }
190
- function ne(n) {
191
- try {
192
- n = encodeURI(n).replace(x.percentDecode, "%");
193
- } catch {
194
- return null;
1
+ import { TextSelection as D, NodeSelection as h, Selection as J, AllSelection as st } from "./index38.js";
2
+ import { Slice as K, DOMSerializer as Ve, Fragment as z, DOMParser as it } from "./index57.js";
3
+ import { dropPoint as at } from "./index58.js";
4
+ const L = function(e) {
5
+ for (var n = 0; ; n++)
6
+ if (e = e.previousSibling, !e)
7
+ return n;
8
+ }, Ke = function(e, n, t, r) {
9
+ return t && (Se(e, n, t, r, -1) || Se(e, n, t, r, 1));
10
+ }, ct = /^(img|br|input|textarea|hr)$/i;
11
+ function Se(e, n, t, r, o) {
12
+ for (var l; ; ) {
13
+ if (e == t && n == r)
14
+ return !0;
15
+ if (n == (o < 0 ? 0 : G(e))) {
16
+ let s = e.parentNode;
17
+ if (!s || s.nodeType != 1 || fe(e) || ct.test(e.nodeName) || e.contentEditable == "false")
18
+ return !1;
19
+ n = L(e) + (o < 0 ? 0 : 1), e = s;
20
+ } else if (e.nodeType == 1) {
21
+ let s = e.childNodes[n + (o < 0 ? -1 : 0)];
22
+ if (s.nodeType == 1 && s.contentEditable == "false")
23
+ if (!((l = s.pmViewDesc) === null || l === void 0) && l.ignoreForSelection)
24
+ n += o;
25
+ else
26
+ return !1;
27
+ else
28
+ e = s, n = o < 0 ? G(e) : 0;
29
+ } else
30
+ return !1;
195
31
  }
196
- return n;
197
32
  }
198
- function re(n, e) {
199
- const t = n.replace(x.findPipe, (i, l, a) => {
200
- let c = !1, o = l;
201
- for (; --o >= 0 && a[o] === "\\"; ) c = !c;
202
- return c ? "|" : " |";
203
- }), s = t.split(x.splitPipe);
204
- let r = 0;
205
- if (s[0].trim() || s.shift(), s.length > 0 && !s.at(-1)?.trim() && s.pop(), e)
206
- if (s.length > e)
207
- s.splice(e);
208
- else
209
- for (; s.length < e; ) s.push("");
210
- for (; r < s.length; r++)
211
- s[r] = s[r].trim().replace(x.slashPipe, "|");
212
- return s;
213
- }
214
- function v(n, e, t) {
215
- const s = n.length;
216
- if (s === 0)
217
- return "";
218
- let r = 0;
219
- for (; r < s && n.charAt(s - r - 1) === e; )
220
- r++;
221
- return n.slice(0, s - r);
222
- }
223
- function Je(n, e) {
224
- if (n.indexOf(e[1]) === -1)
225
- return -1;
226
- let t = 0;
227
- for (let s = 0; s < n.length; s++)
228
- if (n[s] === "\\")
229
- s++;
230
- else if (n[s] === e[0])
231
- t++;
232
- else if (n[s] === e[1] && (t--, t < 0))
233
- return s;
234
- return t > 0 ? -2 : -1;
235
- }
236
- function se(n, e, t, s, r) {
237
- const i = e.href, l = e.title || null, a = n[1].replace(r.other.outputLinkReplace, "$1");
238
- s.state.inLink = !0;
239
- const c = {
240
- type: n[0].charAt(0) === "!" ? "image" : "link",
241
- raw: t,
242
- href: i,
243
- title: l,
244
- text: a,
245
- tokens: s.inlineTokens(a)
246
- };
247
- return s.state.inLink = !1, c;
248
- }
249
- function Ke(n, e, t) {
250
- const s = n.match(t.other.indentCodeCompensation);
251
- if (s === null)
252
- return e;
253
- const r = s[1];
254
- return e.split(`
255
- `).map((i) => {
256
- const l = i.match(t.other.beginningSpace);
257
- if (l === null)
258
- return i;
259
- const [a] = l;
260
- return a.length >= r.length ? i.slice(r.length) : i;
261
- }).join(`
262
- `);
33
+ function G(e) {
34
+ return e.nodeType == 3 ? e.nodeValue.length : e.childNodes.length;
263
35
  }
264
- var C = class {
265
- options;
266
- rules;
267
- // set by the lexer
268
- lexer;
269
- // set by the lexer
270
- constructor(n) {
271
- this.options = n || S;
272
- }
273
- space(n) {
274
- const e = this.rules.block.newline.exec(n);
275
- if (e && e[0].length > 0)
276
- return {
277
- type: "space",
278
- raw: e[0]
279
- };
280
- }
281
- code(n) {
282
- const e = this.rules.block.code.exec(n);
283
- if (e) {
284
- const t = e[0].replace(this.rules.other.codeRemoveIndent, "");
285
- return {
286
- type: "code",
287
- raw: e[0],
288
- codeBlockStyle: "indented",
289
- text: this.options.pedantic ? t : v(t, `
290
- `)
291
- };
292
- }
36
+ function ft(e, n, t) {
37
+ for (let r = n == 0, o = n == G(e); r || o; ) {
38
+ if (e == t)
39
+ return !0;
40
+ let l = L(e);
41
+ if (e = e.parentNode, !e)
42
+ return !1;
43
+ r = r && l == 0, o = o && l == G(e);
293
44
  }
294
- fences(n) {
295
- const e = this.rules.block.fences.exec(n);
296
- if (e) {
297
- const t = e[0], s = Ke(t, e[3] || "", this.rules);
298
- return {
299
- type: "code",
300
- raw: t,
301
- lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2],
302
- text: s
303
- };
45
+ }
46
+ function fe(e) {
47
+ let n;
48
+ for (let t = e; t && !(n = t.pmViewDesc); t = t.parentNode)
49
+ ;
50
+ return n && n.node && n.node.isBlock && (n.dom == e || n.contentDOM == e);
51
+ }
52
+ const ze = function(e) {
53
+ return e.focusNode && Ke(e.focusNode, e.focusOffset, e.anchorNode, e.anchorOffset);
54
+ };
55
+ function Le(e, n) {
56
+ let t = document.createEvent("Event");
57
+ return t.initEvent("keydown", !0, !0), t.keyCode = e, t.key = t.code = n, t;
58
+ }
59
+ const k = typeof navigator < "u" ? navigator : null, De = typeof document < "u" ? document : null, $ = k && k.userAgent || "", re = /Edge\/(\d+)/.exec($), Fe = /MSIE \d/.exec($), oe = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec($), X = !!(Fe || oe || re), Be = Fe ? document.documentMode : oe ? +oe[1] : re ? +re[1] : 0, v = !X && /gecko\/(\d+)/i.test($);
60
+ v && +(/Firefox\/(\d+)/.exec($) || [0, 0])[1];
61
+ const le = !X && /Chrome\/(\d+)/.exec($), O = !!le, qe = le ? +le[1] : 0, F = !X && !!k && /Apple Computer/.test(k.vendor), ue = F && (/Mobile\/\w+/.test($) || !!k && k.maxTouchPoints > 2), S = ue || (k ? /Mac/.test(k.platform) : !1), He = k ? /Win/.test(k.platform) : !1, Y = /Android \d/.test($), de = !!De && "webkitFontSmoothing" in De.documentElement.style, ut = de ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0;
62
+ function dt(e, n = null) {
63
+ let t = e.domSelectionRange(), r = e.state.doc;
64
+ if (!t.focusNode)
65
+ return null;
66
+ let o = e.docView.nearestDesc(t.focusNode), l = o && o.size == 0, s = e.docView.posFromDOM(t.focusNode, t.focusOffset, 1);
67
+ if (s < 0)
68
+ return null;
69
+ let i = r.resolve(s), a, f;
70
+ if (ze(t)) {
71
+ for (a = s; o && !o.node; )
72
+ o = o.parent;
73
+ let c = o.node;
74
+ if (o && c.isAtom && h.isSelectable(c) && o.parent && !(c.isInline && ft(t.focusNode, t.focusOffset, o.dom))) {
75
+ let d = o.posBefore;
76
+ f = new h(s == d ? i : r.resolve(d));
304
77
  }
305
- }
306
- heading(n) {
307
- const e = this.rules.block.heading.exec(n);
308
- if (e) {
309
- let t = e[2].trim();
310
- if (this.rules.other.endingHash.test(t)) {
311
- const s = v(t, "#");
312
- (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (t = s.trim());
78
+ } else {
79
+ if (t instanceof e.dom.ownerDocument.defaultView.Selection && t.rangeCount > 1) {
80
+ let c = s, d = s;
81
+ for (let p = 0; p < t.rangeCount; p++) {
82
+ let b = t.getRangeAt(p);
83
+ c = Math.min(c, e.docView.posFromDOM(b.startContainer, b.startOffset, 1)), d = Math.max(d, e.docView.posFromDOM(b.endContainer, b.endOffset, -1));
84
+ }
85
+ if (c < 0)
86
+ return null;
87
+ [a, s] = d == e.state.selection.anchor ? [d, c] : [c, d], i = r.resolve(s);
88
+ } else
89
+ a = e.docView.posFromDOM(t.anchorNode, t.anchorOffset, 1);
90
+ if (a < 0)
91
+ return null;
92
+ }
93
+ let u = r.resolve(a);
94
+ if (!f) {
95
+ let c = n == "pointer" || e.state.selection.head < i.pos && !l ? 1 : -1;
96
+ f = je(e, u, i, c);
97
+ }
98
+ return f;
99
+ }
100
+ function We(e) {
101
+ return e.editable ? e.hasFocus() : gt(e) && document.activeElement && document.activeElement.contains(e.dom);
102
+ }
103
+ function pe(e, n = !1) {
104
+ let t = e.state.selection;
105
+ if (mt(e, t), !!We(e)) {
106
+ if (!n && e.input.mouseDown && e.input.mouseDown.allowDefault && O) {
107
+ let r = e.domSelectionRange(), o = e.domObserver.currentSelection;
108
+ if (r.anchorNode && o.anchorNode && Ke(r.anchorNode, r.anchorOffset, o.anchorNode, o.anchorOffset)) {
109
+ e.input.mouseDown.delayedSelectionSync = !0, e.domObserver.setCurSelection();
110
+ return;
313
111
  }
314
- return {
315
- type: "heading",
316
- raw: e[0],
317
- depth: e[1].length,
318
- text: t,
319
- tokens: this.lexer.inline(t)
320
- };
321
112
  }
113
+ if (e.domObserver.disconnectSelection(), e.cursorWrapper)
114
+ ht(e);
115
+ else {
116
+ let { anchor: r, head: o } = t, l, s;
117
+ Ne && !(t instanceof D) && (t.$from.parent.inlineContent || (l = Te(e, t.from)), !t.empty && !t.$from.parent.inlineContent && (s = Te(e, t.to))), e.docView.setSelection(r, o, e, n), Ne && (l && ke(l), s && ke(s)), t.visible ? e.dom.classList.remove("ProseMirror-hideselection") : (e.dom.classList.add("ProseMirror-hideselection"), "onselectionchange" in document && pt(e));
118
+ }
119
+ e.domObserver.setCurSelection(), e.domObserver.connectSelection();
322
120
  }
323
- hr(n) {
324
- const e = this.rules.block.hr.exec(n);
325
- if (e)
326
- return {
327
- type: "hr",
328
- raw: v(e[0], `
329
- `)
330
- };
331
- }
332
- blockquote(n) {
333
- const e = this.rules.block.blockquote.exec(n);
334
- if (e) {
335
- let t = v(e[0], `
336
- `).split(`
337
- `), s = "", r = "";
338
- const i = [];
339
- for (; t.length > 0; ) {
340
- let l = !1;
341
- const a = [];
342
- let c;
343
- for (c = 0; c < t.length; c++)
344
- if (this.rules.other.blockquoteStart.test(t[c]))
345
- a.push(t[c]), l = !0;
346
- else if (!l)
347
- a.push(t[c]);
348
- else
349
- break;
350
- t = t.slice(c);
351
- const o = a.join(`
352
- `), h = o.replace(this.rules.other.blockquoteSetextReplace, `
353
- $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
354
- s = s ? `${s}
355
- ${o}` : o, r = r ? `${r}
356
- ${h}` : h;
357
- const k = this.lexer.state.top;
358
- if (this.lexer.state.top = !0, this.lexer.blockTokens(h, i, !0), this.lexer.state.top = k, t.length === 0)
359
- break;
360
- const p = i.at(-1);
361
- if (p?.type === "code")
362
- break;
363
- if (p?.type === "blockquote") {
364
- const d = p, f = d.raw + `
365
- ` + t.join(`
366
- `), b = this.blockquote(f);
367
- i[i.length - 1] = b, s = s.substring(0, s.length - d.raw.length) + b.raw, r = r.substring(0, r.length - d.text.length) + b.text;
368
- break;
369
- } else if (p?.type === "list") {
370
- const d = p, f = d.raw + `
371
- ` + t.join(`
372
- `), b = this.list(f);
373
- i[i.length - 1] = b, s = s.substring(0, s.length - p.raw.length) + b.raw, r = r.substring(0, r.length - d.raw.length) + b.raw, t = f.substring(i.at(-1).raw.length).split(`
374
- `);
375
- continue;
376
- }
121
+ }
122
+ const Ne = F || O && qe < 63;
123
+ function Te(e, n) {
124
+ let { node: t, offset: r } = e.docView.domFromPos(n, 0), o = r < t.childNodes.length ? t.childNodes[r] : null, l = r ? t.childNodes[r - 1] : null;
125
+ if (F && o && o.contentEditable == "false")
126
+ return te(o);
127
+ if ((!o || o.contentEditable == "false") && (!l || l.contentEditable == "false")) {
128
+ if (o)
129
+ return te(o);
130
+ if (l)
131
+ return te(l);
132
+ }
133
+ }
134
+ function te(e) {
135
+ return e.contentEditable = "true", F && e.draggable && (e.draggable = !1, e.wasDraggable = !0), e;
136
+ }
137
+ function ke(e) {
138
+ e.contentEditable = "false", e.wasDraggable && (e.draggable = !0, e.wasDraggable = null);
139
+ }
140
+ function pt(e) {
141
+ let n = e.dom.ownerDocument;
142
+ n.removeEventListener("selectionchange", e.input.hideSelectionGuard);
143
+ let t = e.domSelectionRange(), r = t.anchorNode, o = t.anchorOffset;
144
+ n.addEventListener("selectionchange", e.input.hideSelectionGuard = () => {
145
+ (t.anchorNode != r || t.anchorOffset != o) && (n.removeEventListener("selectionchange", e.input.hideSelectionGuard), setTimeout(() => {
146
+ (!We(e) || e.state.selection.visible) && e.dom.classList.remove("ProseMirror-hideselection");
147
+ }, 20));
148
+ });
149
+ }
150
+ function ht(e) {
151
+ let n = e.domSelection();
152
+ if (!n)
153
+ return;
154
+ let t = e.cursorWrapper.dom, r = t.nodeName == "IMG";
155
+ r ? n.collapse(t.parentNode, L(t) + 1) : n.collapse(t, 0), !r && !e.state.selection.visible && X && Be <= 11 && (t.disabled = !0, t.disabled = !1);
156
+ }
157
+ function mt(e, n) {
158
+ if (n instanceof h) {
159
+ let t = e.docView.descAt(n.from);
160
+ t != e.lastSelectedViewDesc && (xe(e), t && t.selectNode(), e.lastSelectedViewDesc = t);
161
+ } else
162
+ xe(e);
163
+ }
164
+ function xe(e) {
165
+ e.lastSelectedViewDesc && (e.lastSelectedViewDesc.parent && e.lastSelectedViewDesc.deselectNode(), e.lastSelectedViewDesc = void 0);
166
+ }
167
+ function je(e, n, t, r) {
168
+ return e.someProp("createSelectionBetween", (o) => o(e, n, t)) || D.between(n, t, r);
169
+ }
170
+ function gt(e) {
171
+ let n = e.domSelectionRange();
172
+ if (!n.anchorNode)
173
+ return !1;
174
+ try {
175
+ return e.dom.contains(n.anchorNode.nodeType == 3 ? n.anchorNode.parentNode : n.anchorNode) && (e.editable || e.dom.contains(n.focusNode.nodeType == 3 ? n.focusNode.parentNode : n.focusNode));
176
+ } catch {
177
+ return !1;
178
+ }
179
+ }
180
+ function se(e, n) {
181
+ let { $anchor: t, $head: r } = e.selection, o = n > 0 ? t.max(r) : t.min(r), l = o.parent.inlineContent ? o.depth ? e.doc.resolve(n > 0 ? o.after() : o.before()) : null : o;
182
+ return l && J.findFrom(l, n);
183
+ }
184
+ function M(e, n) {
185
+ return e.dispatch(e.state.tr.setSelection(n).scrollIntoView()), !0;
186
+ }
187
+ function Oe(e, n, t) {
188
+ let r = e.state.selection;
189
+ if (r instanceof D)
190
+ if (t.indexOf("s") > -1) {
191
+ let { $head: o } = r, l = o.textOffset ? null : n < 0 ? o.nodeBefore : o.nodeAfter;
192
+ if (!l || l.isText || !l.isLeaf)
193
+ return !1;
194
+ let s = e.state.doc.resolve(o.pos + l.nodeSize * (n < 0 ? -1 : 1));
195
+ return M(e, new D(r.$anchor, s));
196
+ } else if (r.empty) {
197
+ if (e.endOfTextblock(n > 0 ? "forward" : "backward")) {
198
+ let o = se(e.state, n);
199
+ return o && o instanceof h ? M(e, o) : !1;
200
+ } else if (!(S && t.indexOf("m") > -1)) {
201
+ let o = r.$head, l = o.textOffset ? null : n < 0 ? o.nodeBefore : o.nodeAfter, s;
202
+ if (!l || l.isText)
203
+ return !1;
204
+ let i = n < 0 ? o.pos - l.nodeSize : o.pos;
205
+ return l.isAtom || (s = e.docView.descAt(i)) && !s.contentDOM ? h.isSelectable(l) ? M(e, new h(n < 0 ? e.state.doc.resolve(o.pos - l.nodeSize) : o)) : de ? M(e, new D(e.state.doc.resolve(n < 0 ? i : i + l.nodeSize))) : !1 : !1;
377
206
  }
378
- return {
379
- type: "blockquote",
380
- raw: s,
381
- tokens: i,
382
- text: r
383
- };
207
+ } else return !1;
208
+ else {
209
+ if (r instanceof h && r.node.isInline)
210
+ return M(e, new D(n > 0 ? r.$to : r.$from));
211
+ {
212
+ let o = se(e.state, n);
213
+ return o ? M(e, o) : !1;
384
214
  }
385
215
  }
386
- list(n) {
387
- let e = this.rules.block.list.exec(n);
388
- if (e) {
389
- let t = e[1].trim();
390
- const s = t.length > 1, r = {
391
- type: "list",
392
- raw: "",
393
- ordered: s,
394
- start: s ? +t.slice(0, -1) : "",
395
- loose: !1,
396
- items: []
397
- };
398
- t = s ? `\\d{1,9}\\${t.slice(-1)}` : `\\${t}`, this.options.pedantic && (t = s ? t : "[*+-]");
399
- const i = this.rules.other.listItemRegex(t);
400
- let l = !1;
401
- for (; n; ) {
402
- let c = !1, o = "", h = "";
403
- if (!(e = i.exec(n)) || this.rules.block.hr.test(n))
216
+ }
217
+ function Q(e) {
218
+ return e.nodeType == 3 ? e.nodeValue.length : e.childNodes.length;
219
+ }
220
+ function W(e, n) {
221
+ let t = e.pmViewDesc;
222
+ return t && t.size == 0 && (n < 0 || e.nextSibling || e.nodeName != "BR");
223
+ }
224
+ function B(e, n) {
225
+ return n < 0 ? bt(e) : yt(e);
226
+ }
227
+ function bt(e) {
228
+ let n = e.domSelectionRange(), t = n.focusNode, r = n.focusOffset;
229
+ if (!t)
230
+ return;
231
+ let o, l, s = !1;
232
+ for (v && t.nodeType == 1 && r < Q(t) && W(t.childNodes[r], -1) && (s = !0); ; )
233
+ if (r > 0) {
234
+ if (t.nodeType != 1)
235
+ break;
236
+ {
237
+ let i = t.childNodes[r - 1];
238
+ if (W(i, -1))
239
+ o = t, l = --r;
240
+ else if (i.nodeType == 3)
241
+ t = i, r = t.nodeValue.length;
242
+ else
404
243
  break;
405
- o = e[0], n = n.substring(o.length);
406
- let k = e[2].split(`
407
- `, 1)[0].replace(this.rules.other.listReplaceTabs, (q) => " ".repeat(3 * q.length)), p = n.split(`
408
- `, 1)[0], d = !k.trim(), f = 0;
409
- if (this.options.pedantic ? (f = 2, h = k.trimStart()) : d ? f = e[1].length + 1 : (f = e[2].search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, h = k.slice(f), f += e[1].length), d && this.rules.other.blankLine.test(p) && (o += p + `
410
- `, n = n.substring(p.length + 1), c = !0), !c) {
411
- const q = this.rules.other.nextBulletRegex(f), K = this.rules.other.hrRegex(f), V = this.rules.other.fencesBeginRegex(f), Y = this.rules.other.headingBeginRegex(f), de = this.rules.other.htmlBeginRegex(f);
412
- for (; n; ) {
413
- const Z = n.split(`
414
- `, 1)[0];
415
- let $;
416
- if (p = Z, this.options.pedantic ? (p = p.replace(this.rules.other.listReplaceNesting, " "), $ = p) : $ = p.replace(this.rules.other.tabCharGlobal, " "), V.test(p) || Y.test(p) || de.test(p) || q.test(p) || K.test(p))
417
- break;
418
- if ($.search(this.rules.other.nonSpaceChar) >= f || !p.trim())
419
- h += `
420
- ` + $.slice(f);
421
- else {
422
- if (d || k.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || V.test(k) || Y.test(k) || K.test(k))
423
- break;
424
- h += `
425
- ` + p;
426
- }
427
- !d && !p.trim() && (d = !0), o += Z + `
428
- `, n = n.substring(Z.length + 1), k = $.slice(f);
429
- }
244
+ }
245
+ } else {
246
+ if (Ue(t))
247
+ break;
248
+ {
249
+ let i = t.previousSibling;
250
+ for (; i && W(i, -1); )
251
+ o = t.parentNode, l = L(i), i = i.previousSibling;
252
+ if (i)
253
+ t = i, r = Q(t);
254
+ else {
255
+ if (t = t.parentNode, t == e.dom)
256
+ break;
257
+ r = 0;
430
258
  }
431
- r.loose || (l ? r.loose = !0 : this.rules.other.doubleBlankLine.test(o) && (l = !0));
432
- let b = null, J;
433
- this.options.gfm && (b = this.rules.other.listIsTask.exec(h), b && (J = b[0] !== "[ ] ", h = h.replace(this.rules.other.listReplaceTask, ""))), r.items.push({
434
- type: "list_item",
435
- raw: o,
436
- task: !!b,
437
- checked: J,
438
- loose: !1,
439
- text: h,
440
- tokens: []
441
- }), r.raw += o;
442
259
  }
443
- const a = r.items.at(-1);
444
- if (a)
445
- a.raw = a.raw.trimEnd(), a.text = a.text.trimEnd();
260
+ }
261
+ s ? ie(e, t, r) : o && ie(e, o, l);
262
+ }
263
+ function yt(e) {
264
+ let n = e.domSelectionRange(), t = n.focusNode, r = n.focusOffset;
265
+ if (!t)
266
+ return;
267
+ let o = Q(t), l, s;
268
+ for (; ; )
269
+ if (r < o) {
270
+ if (t.nodeType != 1)
271
+ break;
272
+ let i = t.childNodes[r];
273
+ if (W(i, 1))
274
+ l = t, s = ++r;
446
275
  else
447
- return;
448
- r.raw = r.raw.trimEnd();
449
- for (let c = 0; c < r.items.length; c++)
450
- if (this.lexer.state.top = !1, r.items[c].tokens = this.lexer.blockTokens(r.items[c].text, []), !r.loose) {
451
- const o = r.items[c].tokens.filter((k) => k.type === "space"), h = o.length > 0 && o.some((k) => this.rules.other.anyLine.test(k.raw));
452
- r.loose = h;
276
+ break;
277
+ } else {
278
+ if (Ue(t))
279
+ break;
280
+ {
281
+ let i = t.nextSibling;
282
+ for (; i && W(i, 1); )
283
+ l = i.parentNode, s = L(i) + 1, i = i.nextSibling;
284
+ if (i)
285
+ t = i, r = 0, o = Q(t);
286
+ else {
287
+ if (t = t.parentNode, t == e.dom)
288
+ break;
289
+ r = o = 0;
453
290
  }
454
- if (r.loose)
455
- for (let c = 0; c < r.items.length; c++)
456
- r.items[c].loose = !0;
457
- return r;
458
- }
459
- }
460
- html(n) {
461
- const e = this.rules.block.html.exec(n);
462
- if (e)
463
- return {
464
- type: "html",
465
- block: !0,
466
- raw: e[0],
467
- pre: e[1] === "pre" || e[1] === "script" || e[1] === "style",
468
- text: e[0]
469
- };
470
- }
471
- def(n) {
472
- const e = this.rules.block.def.exec(n);
473
- if (e) {
474
- const t = e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = e[2] ? e[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
475
- return {
476
- type: "def",
477
- tag: t,
478
- raw: e[0],
479
- href: s,
480
- title: r
481
- };
291
+ }
482
292
  }
293
+ l && ie(e, l, s);
294
+ }
295
+ function Ue(e) {
296
+ let n = e.pmViewDesc;
297
+ return n && n.node && n.node.isBlock;
298
+ }
299
+ function Ct(e, n) {
300
+ for (; e && n == e.childNodes.length && !fe(e); )
301
+ n = L(e) + 1, e = e.parentNode;
302
+ for (; e && n < e.childNodes.length; ) {
303
+ let t = e.childNodes[n];
304
+ if (t.nodeType == 3)
305
+ return t;
306
+ if (t.nodeType == 1 && t.contentEditable == "false")
307
+ break;
308
+ e = t, n = 0;
483
309
  }
484
- table(n) {
485
- const e = this.rules.block.table.exec(n);
486
- if (!e || !this.rules.other.tableDelimiter.test(e[2]))
487
- return;
488
- const t = re(e[1]), s = e[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = e[3]?.trim() ? e[3].replace(this.rules.other.tableRowBlankLine, "").split(`
489
- `) : [], i = {
490
- type: "table",
491
- raw: e[0],
492
- header: [],
493
- align: [],
494
- rows: []
495
- };
496
- if (t.length === s.length) {
497
- for (const l of s)
498
- this.rules.other.tableAlignRight.test(l) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(l) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(l) ? i.align.push("left") : i.align.push(null);
499
- for (let l = 0; l < t.length; l++)
500
- i.header.push({
501
- text: t[l],
502
- tokens: this.lexer.inline(t[l]),
503
- header: !0,
504
- align: i.align[l]
505
- });
506
- for (const l of r)
507
- i.rows.push(re(l, i.header.length).map((a, c) => ({
508
- text: a,
509
- tokens: this.lexer.inline(a),
510
- header: !1,
511
- align: i.align[c]
512
- })));
513
- return i;
514
- }
310
+ }
311
+ function St(e, n) {
312
+ for (; e && !n && !fe(e); )
313
+ n = L(e), e = e.parentNode;
314
+ for (; e && n; ) {
315
+ let t = e.childNodes[n - 1];
316
+ if (t.nodeType == 3)
317
+ return t;
318
+ if (t.nodeType == 1 && t.contentEditable == "false")
319
+ break;
320
+ e = t, n = e.childNodes.length;
515
321
  }
516
- lheading(n) {
517
- const e = this.rules.block.lheading.exec(n);
518
- if (e)
519
- return {
520
- type: "heading",
521
- raw: e[0],
522
- depth: e[2].charAt(0) === "=" ? 1 : 2,
523
- text: e[1],
524
- tokens: this.lexer.inline(e[1])
525
- };
526
- }
527
- paragraph(n) {
528
- const e = this.rules.block.paragraph.exec(n);
529
- if (e) {
530
- const t = e[1].charAt(e[1].length - 1) === `
531
- ` ? e[1].slice(0, -1) : e[1];
532
- return {
533
- type: "paragraph",
534
- raw: e[0],
535
- text: t,
536
- tokens: this.lexer.inline(t)
537
- };
322
+ }
323
+ function ie(e, n, t) {
324
+ if (n.nodeType != 3) {
325
+ let l, s;
326
+ (s = Ct(n, t)) ? (n = s, t = 0) : (l = St(n, t)) && (n = l, t = l.nodeValue.length);
327
+ }
328
+ let r = e.domSelection();
329
+ if (!r)
330
+ return;
331
+ if (ze(r)) {
332
+ let l = document.createRange();
333
+ l.setEnd(n, t), l.setStart(n, t), r.removeAllRanges(), r.addRange(l);
334
+ } else r.extend && r.extend(n, t);
335
+ e.domObserver.setCurSelection();
336
+ let { state: o } = e;
337
+ setTimeout(() => {
338
+ e.state == o && pe(e);
339
+ }, 50);
340
+ }
341
+ function Ee(e, n) {
342
+ let t = e.state.doc.resolve(n);
343
+ if (!(O || He) && t.parent.inlineContent) {
344
+ let o = e.coordsAtPos(n);
345
+ if (n > t.start()) {
346
+ let l = e.coordsAtPos(n - 1), s = (l.top + l.bottom) / 2;
347
+ if (s > o.top && s < o.bottom && Math.abs(l.left - o.left) > 1)
348
+ return l.left < o.left ? "ltr" : "rtl";
538
349
  }
539
- }
540
- text(n) {
541
- const e = this.rules.block.text.exec(n);
542
- if (e)
543
- return {
544
- type: "text",
545
- raw: e[0],
546
- text: e[0],
547
- tokens: this.lexer.inline(e[0])
548
- };
549
- }
550
- escape(n) {
551
- const e = this.rules.inline.escape.exec(n);
552
- if (e)
553
- return {
554
- type: "escape",
555
- raw: e[0],
556
- text: e[1]
557
- };
558
- }
559
- tag(n) {
560
- const e = this.rules.inline.tag.exec(n);
561
- if (e)
562
- return !this.lexer.state.inLink && this.rules.other.startATag.test(e[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(e[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(e[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(e[0]) && (this.lexer.state.inRawBlock = !1), {
563
- type: "html",
564
- raw: e[0],
565
- inLink: this.lexer.state.inLink,
566
- inRawBlock: this.lexer.state.inRawBlock,
567
- block: !1,
568
- text: e[0]
569
- };
570
- }
571
- link(n) {
572
- const e = this.rules.inline.link.exec(n);
573
- if (e) {
574
- const t = e[2].trim();
575
- if (!this.options.pedantic && this.rules.other.startAngleBracket.test(t)) {
576
- if (!this.rules.other.endAngleBracket.test(t))
577
- return;
578
- const i = v(t.slice(0, -1), "\\");
579
- if ((t.length - i.length) % 2 === 0)
580
- return;
581
- } else {
582
- const i = Je(e[2], "()");
583
- if (i === -2)
584
- return;
585
- if (i > -1) {
586
- const a = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + i;
587
- e[2] = e[2].substring(0, i), e[0] = e[0].substring(0, a).trim(), e[3] = "";
588
- }
589
- }
590
- let s = e[2], r = "";
591
- if (this.options.pedantic) {
592
- const i = this.rules.other.pedanticHrefTitle.exec(s);
593
- i && (s = i[1], r = i[3]);
594
- } else
595
- r = e[3] ? e[3].slice(1, -1) : "";
596
- return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(t) ? s = s.slice(1) : s = s.slice(1, -1)), se(e, {
597
- href: s && s.replace(this.rules.inline.anyPunctuation, "$1"),
598
- title: r && r.replace(this.rules.inline.anyPunctuation, "$1")
599
- }, e[0], this.lexer, this.rules);
350
+ if (n < t.end()) {
351
+ let l = e.coordsAtPos(n + 1), s = (l.top + l.bottom) / 2;
352
+ if (s > o.top && s < o.bottom && Math.abs(l.left - o.left) > 1)
353
+ return l.left > o.left ? "ltr" : "rtl";
600
354
  }
601
355
  }
602
- reflink(n, e) {
603
- let t;
604
- if ((t = this.rules.inline.reflink.exec(n)) || (t = this.rules.inline.nolink.exec(n))) {
605
- const s = (t[2] || t[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = e[s.toLowerCase()];
606
- if (!r) {
607
- const i = t[0].charAt(0);
608
- return {
609
- type: "text",
610
- raw: i,
611
- text: i
612
- };
613
- }
614
- return se(t, r, t[0], this.lexer, this.rules);
356
+ return getComputedStyle(e.dom).direction == "rtl" ? "rtl" : "ltr";
357
+ }
358
+ function Me(e, n, t) {
359
+ let r = e.state.selection;
360
+ if (r instanceof D && !r.empty || t.indexOf("s") > -1 || S && t.indexOf("m") > -1)
361
+ return !1;
362
+ let { $from: o, $to: l } = r;
363
+ if (!o.parent.inlineContent || e.endOfTextblock(n < 0 ? "up" : "down")) {
364
+ let s = se(e.state, n);
365
+ if (s && s instanceof h)
366
+ return M(e, s);
367
+ }
368
+ if (!o.parent.inlineContent) {
369
+ let s = n < 0 ? o : l, i = r instanceof st ? J.near(s, n) : J.findFrom(s, n);
370
+ return i ? M(e, i) : !1;
371
+ }
372
+ return !1;
373
+ }
374
+ function Ae(e, n) {
375
+ if (!(e.state.selection instanceof D))
376
+ return !0;
377
+ let { $head: t, $anchor: r, empty: o } = e.state.selection;
378
+ if (!t.sameParent(r))
379
+ return !0;
380
+ if (!o)
381
+ return !1;
382
+ if (e.endOfTextblock(n > 0 ? "forward" : "backward"))
383
+ return !0;
384
+ let l = !t.textOffset && (n < 0 ? t.nodeBefore : t.nodeAfter);
385
+ if (l && !l.isText) {
386
+ let s = e.state.tr;
387
+ return n < 0 ? s.delete(t.pos - l.nodeSize, t.pos) : s.delete(t.pos, t.pos + l.nodeSize), e.dispatch(s), !0;
388
+ }
389
+ return !1;
390
+ }
391
+ function Pe(e, n, t) {
392
+ e.domObserver.stop(), n.contentEditable = t, e.domObserver.start();
393
+ }
394
+ function Dt(e) {
395
+ if (!F || e.state.selection.$head.parentOffset > 0)
396
+ return !1;
397
+ let { focusNode: n, focusOffset: t } = e.domSelectionRange();
398
+ if (n && n.nodeType == 1 && t == 0 && n.firstChild && n.firstChild.contentEditable == "false") {
399
+ let r = n.firstChild;
400
+ Pe(e, r, "true"), setTimeout(() => Pe(e, r, "false"), 20);
401
+ }
402
+ return !1;
403
+ }
404
+ function Nt(e) {
405
+ let n = "";
406
+ return e.ctrlKey && (n += "c"), e.metaKey && (n += "m"), e.altKey && (n += "a"), e.shiftKey && (n += "s"), n;
407
+ }
408
+ function Tt(e, n) {
409
+ let t = n.keyCode, r = Nt(n);
410
+ if (t == 8 || S && t == 72 && r == "c")
411
+ return Ae(e, -1) || B(e, -1);
412
+ if (t == 46 && !n.shiftKey || S && t == 68 && r == "c")
413
+ return Ae(e, 1) || B(e, 1);
414
+ if (t == 13 || t == 27)
415
+ return !0;
416
+ if (t == 37 || S && t == 66 && r == "c") {
417
+ let o = t == 37 ? Ee(e, e.state.selection.from) == "ltr" ? -1 : 1 : -1;
418
+ return Oe(e, o, r) || B(e, o);
419
+ } else if (t == 39 || S && t == 70 && r == "c") {
420
+ let o = t == 39 ? Ee(e, e.state.selection.from) == "ltr" ? 1 : -1 : 1;
421
+ return Oe(e, o, r) || B(e, o);
422
+ } else {
423
+ if (t == 38 || S && t == 80 && r == "c")
424
+ return Me(e, -1, r) || B(e, -1);
425
+ if (t == 40 || S && t == 78 && r == "c")
426
+ return Dt(e) || Me(e, 1, r) || B(e, 1);
427
+ if (r == (S ? "m" : "c") && (t == 66 || t == 73 || t == 89 || t == 90))
428
+ return !0;
429
+ }
430
+ return !1;
431
+ }
432
+ function Xe(e, n) {
433
+ e.someProp("transformCopied", (p) => {
434
+ n = p(n, e);
435
+ });
436
+ let t = [], { content: r, openStart: o, openEnd: l } = n;
437
+ for (; o > 1 && l > 1 && r.childCount == 1 && r.firstChild.childCount == 1; ) {
438
+ o--, l--;
439
+ let p = r.firstChild;
440
+ t.push(p.type.name, p.attrs != p.type.defaultAttrs ? p.attrs : null), r = p.content;
441
+ }
442
+ let s = e.someProp("clipboardSerializer") || Ve.fromSchema(e.state.schema), i = _e(), a = i.createElement("div");
443
+ a.appendChild(s.serializeFragment(r, { document: i }));
444
+ let f = a.firstChild, u, c = 0;
445
+ for (; f && f.nodeType == 1 && (u = Ze[f.nodeName.toLowerCase()]); ) {
446
+ for (let p = u.length - 1; p >= 0; p--) {
447
+ let b = i.createElement(u[p]);
448
+ for (; a.firstChild; )
449
+ b.appendChild(a.firstChild);
450
+ a.appendChild(b), c++;
615
451
  }
452
+ f = a.firstChild;
616
453
  }
617
- emStrong(n, e, t = "") {
618
- let s = this.rules.inline.emStrongLDelim.exec(n);
619
- if (!s || s[3] && t.match(this.rules.other.unicodeAlphaNumeric)) return;
620
- if (!(s[1] || s[2] || "") || !t || this.rules.inline.punctuation.exec(t)) {
621
- const i = [...s[0]].length - 1;
622
- let l, a, c = i, o = 0;
623
- const h = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
624
- for (h.lastIndex = 0, e = e.slice(-1 * n.length + i); (s = h.exec(e)) != null; ) {
625
- if (l = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !l) continue;
626
- if (a = [...l].length, s[3] || s[4]) {
627
- c += a;
628
- continue;
629
- } else if ((s[5] || s[6]) && i % 3 && !((i + a) % 3)) {
630
- o += a;
631
- continue;
632
- }
633
- if (c -= a, c > 0) continue;
634
- a = Math.min(a, a + c + o);
635
- const k = [...s[0]][0].length, p = n.slice(0, i + s.index + k + a);
636
- if (Math.min(i, a) % 2) {
637
- const f = p.slice(1, -1);
638
- return {
639
- type: "em",
640
- raw: p,
641
- text: f,
642
- tokens: this.lexer.inlineTokens(f)
643
- };
644
- }
645
- const d = p.slice(2, -2);
646
- return {
647
- type: "strong",
648
- raw: p,
649
- text: d,
650
- tokens: this.lexer.inlineTokens(d)
651
- };
652
- }
454
+ f && f.nodeType == 1 && f.setAttribute("data-pm-slice", `${o} ${l}${c ? ` -${c}` : ""} ${JSON.stringify(t)}`);
455
+ let d = e.someProp("clipboardTextSerializer", (p) => p(n, e)) || n.content.textBetween(0, n.content.size, `
456
+
457
+ `);
458
+ return { dom: a, text: d, slice: n };
459
+ }
460
+ function Ye(e, n, t, r, o) {
461
+ let l = o.parent.type.spec.code, s, i;
462
+ if (!t && !n)
463
+ return null;
464
+ let a = !!n && (r || l || !t);
465
+ if (a) {
466
+ if (e.someProp("transformPastedText", (d) => {
467
+ n = d(n, l || r, e);
468
+ }), l)
469
+ return i = new K(z.from(e.state.schema.text(n.replace(/\r\n?/g, `
470
+ `))), 0, 0), e.someProp("transformPasted", (d) => {
471
+ i = d(i, e, !0);
472
+ }), i;
473
+ let c = e.someProp("clipboardTextParser", (d) => d(n, o, r, e));
474
+ if (c)
475
+ i = c;
476
+ else {
477
+ let d = o.marks(), { schema: p } = e.state, b = Ve.fromSchema(p);
478
+ s = document.createElement("div"), n.split(/(?:\r\n?|\n)+/).forEach((E) => {
479
+ let N = s.appendChild(document.createElement("p"));
480
+ E && N.appendChild(b.serializeNode(p.text(E, d)));
481
+ });
653
482
  }
654
- }
655
- codespan(n) {
656
- const e = this.rules.inline.code.exec(n);
657
- if (e) {
658
- let t = e[2].replace(this.rules.other.newLineCharGlobal, " ");
659
- const s = this.rules.other.nonSpaceChar.test(t), r = this.rules.other.startingSpaceChar.test(t) && this.rules.other.endingSpaceChar.test(t);
660
- return s && r && (t = t.substring(1, t.length - 1)), {
661
- type: "codespan",
662
- raw: e[0],
663
- text: t
664
- };
483
+ } else
484
+ e.someProp("transformPastedHTML", (c) => {
485
+ t = c(t, e);
486
+ }), s = Et(t), de && Mt(s);
487
+ let f = s && s.querySelector("[data-pm-slice]"), u = f && /^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice") || "");
488
+ if (u && u[3])
489
+ for (let c = +u[3]; c > 0; c--) {
490
+ let d = s.firstChild;
491
+ for (; d && d.nodeType != 1; )
492
+ d = d.nextSibling;
493
+ if (!d)
494
+ break;
495
+ s = d;
665
496
  }
666
- }
667
- br(n) {
668
- const e = this.rules.inline.br.exec(n);
669
- if (e)
670
- return {
671
- type: "br",
672
- raw: e[0]
673
- };
674
- }
675
- del(n) {
676
- const e = this.rules.inline.del.exec(n);
677
- if (e)
678
- return {
679
- type: "del",
680
- raw: e[0],
681
- text: e[2],
682
- tokens: this.lexer.inlineTokens(e[2])
683
- };
684
- }
685
- autolink(n) {
686
- const e = this.rules.inline.autolink.exec(n);
687
- if (e) {
688
- let t, s;
689
- return e[2] === "@" ? (t = e[1], s = "mailto:" + t) : (t = e[1], s = t), {
690
- type: "link",
691
- raw: e[0],
692
- text: t,
693
- href: s,
694
- tokens: [
695
- {
696
- type: "text",
697
- raw: t,
698
- text: t
699
- }
700
- ]
701
- };
497
+ if (i || (i = (e.someProp("clipboardParser") || e.someProp("domParser") || it.fromSchema(e.state.schema)).parseSlice(s, {
498
+ preserveWhitespace: !!(a || u),
499
+ context: o,
500
+ ruleFromNode(d) {
501
+ return d.nodeName == "BR" && !d.nextSibling && d.parentNode && !kt.test(d.parentNode.nodeName) ? { ignore: !0 } : null;
702
502
  }
703
- }
704
- url(n) {
705
- let e;
706
- if (e = this.rules.inline.url.exec(n)) {
707
- let t, s;
708
- if (e[2] === "@")
709
- t = e[0], s = "mailto:" + t;
503
+ })), u)
504
+ i = At($e(i, +u[1], +u[2]), u[4]);
505
+ else if (i = K.maxOpen(xt(i.content, o), !0), i.openStart || i.openEnd) {
506
+ let c = 0, d = 0;
507
+ for (let p = i.content.firstChild; c < i.openStart && !p.type.spec.isolating; c++, p = p.firstChild)
508
+ ;
509
+ for (let p = i.content.lastChild; d < i.openEnd && !p.type.spec.isolating; d++, p = p.lastChild)
510
+ ;
511
+ i = $e(i, c, d);
512
+ }
513
+ return e.someProp("transformPasted", (c) => {
514
+ i = c(i, e, a);
515
+ }), i;
516
+ }
517
+ const kt = /^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;
518
+ function xt(e, n) {
519
+ if (e.childCount < 2)
520
+ return e;
521
+ for (let t = n.depth; t >= 0; t--) {
522
+ let o = n.node(t).contentMatchAt(n.index(t)), l, s = [];
523
+ if (e.forEach((i) => {
524
+ if (!s)
525
+ return;
526
+ let a = o.findWrapping(i.type), f;
527
+ if (!a)
528
+ return s = null;
529
+ if (f = s.length && l.length && Ge(a, l, i, s[s.length - 1], 0))
530
+ s[s.length - 1] = f;
710
531
  else {
711
- let r;
712
- do
713
- r = e[0], e[0] = this.rules.inline._backpedal.exec(e[0])?.[0] ?? "";
714
- while (r !== e[0]);
715
- t = e[0], e[1] === "www." ? s = "http://" + e[0] : s = e[0];
532
+ s.length && (s[s.length - 1] = Qe(s[s.length - 1], l.length));
533
+ let u = Je(i, a);
534
+ s.push(u), o = o.matchType(u.type), l = a;
716
535
  }
717
- return {
718
- type: "link",
719
- raw: e[0],
720
- text: t,
721
- href: s,
722
- tokens: [
723
- {
724
- type: "text",
725
- raw: t,
726
- text: t
727
- }
728
- ]
729
- };
730
- }
536
+ }), s)
537
+ return z.from(s);
731
538
  }
732
- inlineText(n) {
733
- const e = this.rules.inline.text.exec(n);
734
- if (e) {
735
- const t = this.lexer.state.inRawBlock;
736
- return {
737
- type: "text",
738
- raw: e[0],
739
- text: e[0],
740
- escaped: t
741
- };
742
- }
539
+ return e;
540
+ }
541
+ function Je(e, n, t = 0) {
542
+ for (let r = n.length - 1; r >= t; r--)
543
+ e = n[r].create(null, z.from(e));
544
+ return e;
545
+ }
546
+ function Ge(e, n, t, r, o) {
547
+ if (o < e.length && o < n.length && e[o] == n[o]) {
548
+ let l = Ge(e, n, t, r.lastChild, o + 1);
549
+ if (l)
550
+ return r.copy(r.content.replaceChild(r.childCount - 1, l));
551
+ if (r.contentMatchAt(r.childCount).matchType(o == e.length - 1 ? t.type : e[o + 1]))
552
+ return r.copy(r.content.append(z.from(Je(t, e, o + 1))));
743
553
  }
744
- }, w = class M {
745
- tokens;
746
- options;
747
- state;
748
- tokenizer;
749
- inlineQueue;
750
- constructor(e) {
751
- this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || S, this.options.tokenizer = this.options.tokenizer || new C(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
752
- inLink: !1,
753
- inRawBlock: !1,
754
- top: !0
755
- };
756
- const t = {
757
- other: x,
758
- block: A.normal,
759
- inline: T.normal
760
- };
761
- this.options.pedantic ? (t.block = A.pedantic, t.inline = T.pedantic) : this.options.gfm && (t.block = A.gfm, this.options.breaks ? t.inline = T.breaks : t.inline = T.gfm), this.tokenizer.rules = t;
554
+ }
555
+ function Qe(e, n) {
556
+ if (n == 0)
557
+ return e;
558
+ let t = e.content.replaceChild(e.childCount - 1, Qe(e.lastChild, n - 1)), r = e.contentMatchAt(e.childCount).fillBefore(z.empty, !0);
559
+ return e.copy(t.append(r));
560
+ }
561
+ function ae(e, n, t, r, o, l) {
562
+ let s = n < 0 ? e.firstChild : e.lastChild, i = s.content;
563
+ return e.childCount > 1 && (l = 0), o < r - 1 && (i = ae(i, n, t, r, o + 1, l)), o >= t && (i = n < 0 ? s.contentMatchAt(0).fillBefore(i, l <= o).append(i) : i.append(s.contentMatchAt(s.childCount).fillBefore(z.empty, !0))), e.replaceChild(n < 0 ? 0 : e.childCount - 1, s.copy(i));
564
+ }
565
+ function $e(e, n, t) {
566
+ return n < e.openStart && (e = new K(ae(e.content, -1, n, e.openStart, 0, e.openEnd), n, e.openEnd)), t < e.openEnd && (e = new K(ae(e.content, 1, t, e.openEnd, 0, 0), e.openStart, t)), e;
567
+ }
568
+ const Ze = {
569
+ thead: ["table"],
570
+ tbody: ["table"],
571
+ tfoot: ["table"],
572
+ caption: ["table"],
573
+ colgroup: ["table"],
574
+ col: ["table", "colgroup"],
575
+ tr: ["table", "tbody"],
576
+ td: ["table", "tbody", "tr"],
577
+ th: ["table", "tbody", "tr"]
578
+ };
579
+ let Ie = null;
580
+ function _e() {
581
+ return Ie || (Ie = document.implementation.createHTMLDocument("title"));
582
+ }
583
+ let ne = null;
584
+ function Ot(e) {
585
+ let n = window.trustedTypes;
586
+ return n ? (ne || (ne = n.defaultPolicy || n.createPolicy("ProseMirrorClipboard", { createHTML: (t) => t })), ne.createHTML(e)) : e;
587
+ }
588
+ function Et(e) {
589
+ let n = /^(\s*<meta [^>]*>)*/.exec(e);
590
+ n && (e = e.slice(n[0].length));
591
+ let t = _e().createElement("div"), r = /<([a-z][^>\s]+)/i.exec(e), o;
592
+ if ((o = r && Ze[r[1].toLowerCase()]) && (e = o.map((l) => "<" + l + ">").join("") + e + o.map((l) => "</" + l + ">").reverse().join("")), t.innerHTML = Ot(e), o)
593
+ for (let l = 0; l < o.length; l++)
594
+ t = t.querySelector(o[l]) || t;
595
+ return t;
596
+ }
597
+ function Mt(e) {
598
+ let n = e.querySelectorAll(O ? "span:not([class]):not([style])" : "span.Apple-converted-space");
599
+ for (let t = 0; t < n.length; t++) {
600
+ let r = n[t];
601
+ r.childNodes.length == 1 && r.textContent == " " && r.parentNode && r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "), r);
762
602
  }
763
- /**
764
- * Expose Rules
765
- */
766
- static get rules() {
767
- return {
768
- block: A,
769
- inline: T
770
- };
603
+ }
604
+ function At(e, n) {
605
+ if (!e.size)
606
+ return e;
607
+ let t = e.content.firstChild.type.schema, r;
608
+ try {
609
+ r = JSON.parse(n);
610
+ } catch {
611
+ return e;
771
612
  }
772
- /**
773
- * Static Lex Method
774
- */
775
- static lex(e, t) {
776
- return new M(t).lex(e);
613
+ let { content: o, openStart: l, openEnd: s } = e;
614
+ for (let i = r.length - 2; i >= 0; i -= 2) {
615
+ let a = t.nodes[r[i]];
616
+ if (!a || a.hasRequiredAttrs())
617
+ break;
618
+ o = z.from(a.create(r[i + 1], o)), l++, s++;
777
619
  }
778
- /**
779
- * Static Lex Inline Method
780
- */
781
- static lexInline(e, t) {
782
- return new M(t).inlineTokens(e);
620
+ return new K(o, l, s);
621
+ }
622
+ const T = {}, y = {};
623
+ function A(e, n) {
624
+ e.input.lastSelectionOrigin = n, e.input.lastSelectionTime = Date.now();
625
+ }
626
+ y.keydown = (e, n) => {
627
+ let t = n;
628
+ if (e.input.shiftKey = t.keyCode == 16 || t.shiftKey, !ve(e, t) && (e.input.lastKeyCode = t.keyCode, e.input.lastKeyCodeTime = Date.now(), !(Y && O && t.keyCode == 13)))
629
+ if (t.keyCode != 229 && e.domObserver.forceFlush(), ue && t.keyCode == 13 && !t.ctrlKey && !t.altKey && !t.metaKey) {
630
+ let r = Date.now();
631
+ e.input.lastIOSEnter = r, e.input.lastIOSEnterFallbackTimeout = setTimeout(() => {
632
+ e.input.lastIOSEnter == r && (e.someProp("handleKeyDown", (o) => o(e, Le(13, "Enter"))), e.input.lastIOSEnter = 0);
633
+ }, 200);
634
+ } else e.someProp("handleKeyDown", (r) => r(e, t)) || Tt(e, t) ? t.preventDefault() : A(e, "key");
635
+ };
636
+ y.keyup = (e, n) => {
637
+ n.keyCode == 16 && (e.input.shiftKey = !1);
638
+ };
639
+ y.keypress = (e, n) => {
640
+ let t = n;
641
+ if (ve(e, t) || !t.charCode || t.ctrlKey && !t.altKey || S && t.metaKey)
642
+ return;
643
+ if (e.someProp("handleKeyPress", (o) => o(e, t))) {
644
+ t.preventDefault();
645
+ return;
646
+ }
647
+ let r = e.state.selection;
648
+ if (!(r instanceof D) || !r.$from.sameParent(r.$to)) {
649
+ let o = String.fromCharCode(t.charCode), l = () => e.state.tr.insertText(o).scrollIntoView();
650
+ !/[\r\n]/.test(o) && !e.someProp("handleTextInput", (s) => s(e, r.$from.pos, r.$to.pos, o, l)) && e.dispatch(l()), t.preventDefault();
783
651
  }
784
- /**
785
- * Preprocessing
786
- */
787
- lex(e) {
788
- e = e.replace(x.carriageReturn, `
789
- `), this.blockTokens(e, this.tokens);
790
- for (let t = 0; t < this.inlineQueue.length; t++) {
791
- const s = this.inlineQueue[t];
792
- this.inlineTokens(s.src, s.tokens);
652
+ };
653
+ function ee(e) {
654
+ return { left: e.clientX, top: e.clientY };
655
+ }
656
+ function Pt(e, n) {
657
+ let t = n.x - e.clientX, r = n.y - e.clientY;
658
+ return t * t + r * r < 100;
659
+ }
660
+ function he(e, n, t, r, o) {
661
+ if (r == -1)
662
+ return !1;
663
+ let l = e.state.doc.resolve(r);
664
+ for (let s = l.depth + 1; s > 0; s--)
665
+ if (e.someProp(n, (i) => s > l.depth ? i(e, t, l.nodeAfter, l.before(s), o, !0) : i(e, t, l.node(s), l.before(s), o, !1)))
666
+ return !0;
667
+ return !1;
668
+ }
669
+ function H(e, n, t) {
670
+ if (e.focused || e.focus(), e.state.selection.eq(n))
671
+ return;
672
+ let r = e.state.tr.setSelection(n);
673
+ r.setMeta("pointer", !0), e.dispatch(r);
674
+ }
675
+ function $t(e, n) {
676
+ if (n == -1)
677
+ return !1;
678
+ let t = e.state.doc.resolve(n), r = t.nodeAfter;
679
+ return r && r.isAtom && h.isSelectable(r) ? (H(e, new h(t)), !0) : !1;
680
+ }
681
+ function It(e, n) {
682
+ if (n == -1)
683
+ return !1;
684
+ let t = e.state.selection, r, o;
685
+ t instanceof h && (r = t.node);
686
+ let l = e.state.doc.resolve(n);
687
+ for (let s = l.depth + 1; s > 0; s--) {
688
+ let i = s > l.depth ? l.nodeAfter : l.node(s);
689
+ if (h.isSelectable(i)) {
690
+ r && t.$from.depth > 0 && s >= t.$from.depth && l.before(t.$from.depth + 1) == t.$from.pos ? o = l.before(t.$from.depth) : o = l.before(s);
691
+ break;
793
692
  }
794
- return this.inlineQueue = [], this.tokens;
795
693
  }
796
- blockTokens(e, t = [], s = !1) {
797
- for (this.options.pedantic && (e = e.replace(x.tabCharGlobal, " ").replace(x.spaceLine, "")); e; ) {
798
- let r;
799
- if (this.options.extensions?.block?.some((l) => (r = l.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), !0) : !1))
800
- continue;
801
- if (r = this.tokenizer.space(e)) {
802
- e = e.substring(r.raw.length);
803
- const l = t.at(-1);
804
- r.raw.length === 1 && l !== void 0 ? l.raw += `
805
- ` : t.push(r);
806
- continue;
807
- }
808
- if (r = this.tokenizer.code(e)) {
809
- e = e.substring(r.raw.length);
810
- const l = t.at(-1);
811
- l?.type === "paragraph" || l?.type === "text" ? (l.raw += `
812
- ` + r.raw, l.text += `
813
- ` + r.text, this.inlineQueue.at(-1).src = l.text) : t.push(r);
814
- continue;
815
- }
816
- if (r = this.tokenizer.fences(e)) {
817
- e = e.substring(r.raw.length), t.push(r);
818
- continue;
819
- }
820
- if (r = this.tokenizer.heading(e)) {
821
- e = e.substring(r.raw.length), t.push(r);
822
- continue;
823
- }
824
- if (r = this.tokenizer.hr(e)) {
825
- e = e.substring(r.raw.length), t.push(r);
826
- continue;
827
- }
828
- if (r = this.tokenizer.blockquote(e)) {
829
- e = e.substring(r.raw.length), t.push(r);
830
- continue;
831
- }
832
- if (r = this.tokenizer.list(e)) {
833
- e = e.substring(r.raw.length), t.push(r);
834
- continue;
835
- }
836
- if (r = this.tokenizer.html(e)) {
837
- e = e.substring(r.raw.length), t.push(r);
838
- continue;
839
- }
840
- if (r = this.tokenizer.def(e)) {
841
- e = e.substring(r.raw.length);
842
- const l = t.at(-1);
843
- l?.type === "paragraph" || l?.type === "text" ? (l.raw += `
844
- ` + r.raw, l.text += `
845
- ` + r.raw, this.inlineQueue.at(-1).src = l.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = {
846
- href: r.href,
847
- title: r.title
848
- });
849
- continue;
850
- }
851
- if (r = this.tokenizer.table(e)) {
852
- e = e.substring(r.raw.length), t.push(r);
853
- continue;
854
- }
855
- if (r = this.tokenizer.lheading(e)) {
856
- e = e.substring(r.raw.length), t.push(r);
857
- continue;
858
- }
859
- let i = e;
860
- if (this.options.extensions?.startBlock) {
861
- let l = 1 / 0;
862
- const a = e.slice(1);
863
- let c;
864
- this.options.extensions.startBlock.forEach((o) => {
865
- c = o.call({ lexer: this }, a), typeof c == "number" && c >= 0 && (l = Math.min(l, c));
866
- }), l < 1 / 0 && l >= 0 && (i = e.substring(0, l + 1));
867
- }
868
- if (this.state.top && (r = this.tokenizer.paragraph(i))) {
869
- const l = t.at(-1);
870
- s && l?.type === "paragraph" ? (l.raw += `
871
- ` + r.raw, l.text += `
872
- ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = l.text) : t.push(r), s = i.length !== e.length, e = e.substring(r.raw.length);
873
- continue;
874
- }
875
- if (r = this.tokenizer.text(e)) {
876
- e = e.substring(r.raw.length);
877
- const l = t.at(-1);
878
- l?.type === "text" ? (l.raw += `
879
- ` + r.raw, l.text += `
880
- ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = l.text) : t.push(r);
881
- continue;
882
- }
883
- if (e) {
884
- const l = "Infinite loop on byte: " + e.charCodeAt(0);
885
- if (this.options.silent) {
886
- console.error(l);
694
+ return o != null ? (H(e, h.create(e.state.doc, o)), !0) : !1;
695
+ }
696
+ function Rt(e, n, t, r, o) {
697
+ return he(e, "handleClickOn", n, t, r) || e.someProp("handleClick", (l) => l(e, n, r)) || (o ? It(e, t) : $t(e, t));
698
+ }
699
+ function Vt(e, n, t, r) {
700
+ return he(e, "handleDoubleClickOn", n, t, r) || e.someProp("handleDoubleClick", (o) => o(e, n, r));
701
+ }
702
+ function Kt(e, n, t, r) {
703
+ return he(e, "handleTripleClickOn", n, t, r) || e.someProp("handleTripleClick", (o) => o(e, n, r)) || zt(e, t, r);
704
+ }
705
+ function zt(e, n, t) {
706
+ if (t.button != 0)
707
+ return !1;
708
+ let r = e.state.doc;
709
+ if (n == -1)
710
+ return r.inlineContent ? (H(e, D.create(r, 0, r.content.size)), !0) : !1;
711
+ let o = r.resolve(n);
712
+ for (let l = o.depth + 1; l > 0; l--) {
713
+ let s = l > o.depth ? o.nodeAfter : o.node(l), i = o.before(l);
714
+ if (s.inlineContent)
715
+ H(e, D.create(r, i + 1, i + 1 + s.content.size));
716
+ else if (h.isSelectable(s))
717
+ H(e, h.create(r, i));
718
+ else
719
+ continue;
720
+ return !0;
721
+ }
722
+ }
723
+ function me(e) {
724
+ return Z(e);
725
+ }
726
+ const we = S ? "metaKey" : "ctrlKey";
727
+ T.mousedown = (e, n) => {
728
+ let t = n;
729
+ e.input.shiftKey = t.shiftKey;
730
+ let r = me(e), o = Date.now(), l = "singleClick";
731
+ o - e.input.lastClick.time < 500 && Pt(t, e.input.lastClick) && !t[we] && e.input.lastClick.button == t.button && (e.input.lastClick.type == "singleClick" ? l = "doubleClick" : e.input.lastClick.type == "doubleClick" && (l = "tripleClick")), e.input.lastClick = { time: o, x: t.clientX, y: t.clientY, type: l, button: t.button };
732
+ let s = e.posAtCoords(ee(t));
733
+ s && (l == "singleClick" ? (e.input.mouseDown && e.input.mouseDown.done(), e.input.mouseDown = new Lt(e, s, t, !!r)) : (l == "doubleClick" ? Vt : Kt)(e, s.pos, s.inside, t) ? t.preventDefault() : A(e, "pointer"));
734
+ };
735
+ class Lt {
736
+ constructor(n, t, r, o) {
737
+ this.view = n, this.pos = t, this.event = r, this.flushed = o, this.delayedSelectionSync = !1, this.mightDrag = null, this.startDoc = n.state.doc, this.selectNode = !!r[we], this.allowDefault = r.shiftKey;
738
+ let l, s;
739
+ if (t.inside > -1)
740
+ l = n.state.doc.nodeAt(t.inside), s = t.inside;
741
+ else {
742
+ let u = n.state.doc.resolve(t.pos);
743
+ l = u.parent, s = u.depth ? u.before() : 0;
744
+ }
745
+ const i = o ? null : r.target, a = i ? n.docView.nearestDesc(i, !0) : null;
746
+ this.target = a && a.nodeDOM.nodeType == 1 ? a.nodeDOM : null;
747
+ let { selection: f } = n.state;
748
+ (r.button == 0 && l.type.spec.draggable && l.type.spec.selectable !== !1 || f instanceof h && f.from <= s && f.to > s) && (this.mightDrag = {
749
+ node: l,
750
+ pos: s,
751
+ addAttr: !!(this.target && !this.target.draggable),
752
+ setUneditable: !!(this.target && v && !this.target.hasAttribute("contentEditable"))
753
+ }), this.target && this.mightDrag && (this.mightDrag.addAttr || this.mightDrag.setUneditable) && (this.view.domObserver.stop(), this.mightDrag.addAttr && (this.target.draggable = !0), this.mightDrag.setUneditable && setTimeout(() => {
754
+ this.view.input.mouseDown == this && this.target.setAttribute("contentEditable", "false");
755
+ }, 20), this.view.domObserver.start()), n.root.addEventListener("mouseup", this.up = this.up.bind(this)), n.root.addEventListener("mousemove", this.move = this.move.bind(this)), A(n, "pointer");
756
+ }
757
+ done() {
758
+ this.view.root.removeEventListener("mouseup", this.up), this.view.root.removeEventListener("mousemove", this.move), this.mightDrag && this.target && (this.view.domObserver.stop(), this.mightDrag.addAttr && this.target.removeAttribute("draggable"), this.mightDrag.setUneditable && this.target.removeAttribute("contentEditable"), this.view.domObserver.start()), this.delayedSelectionSync && setTimeout(() => pe(this.view)), this.view.input.mouseDown = null;
759
+ }
760
+ up(n) {
761
+ if (this.done(), !this.view.dom.contains(n.target))
762
+ return;
763
+ let t = this.pos;
764
+ this.view.state.doc != this.startDoc && (t = this.view.posAtCoords(ee(n))), this.updateAllowDefault(n), this.allowDefault || !t ? A(this.view, "pointer") : Rt(this.view, t.pos, t.inside, n, this.selectNode) ? n.preventDefault() : n.button == 0 && (this.flushed || // Safari ignores clicks on draggable elements
765
+ F && this.mightDrag && !this.mightDrag.node.isAtom || // Chrome will sometimes treat a node selection as a
766
+ // cursor, but still report that the node is selected
767
+ // when asked through getSelection. You'll then get a
768
+ // situation where clicking at the point where that
769
+ // (hidden) cursor is doesn't change the selection, and
770
+ // thus doesn't get a reaction from ProseMirror. This
771
+ // works around that.
772
+ O && !this.view.state.selection.visible && Math.min(Math.abs(t.pos - this.view.state.selection.from), Math.abs(t.pos - this.view.state.selection.to)) <= 2) ? (H(this.view, J.near(this.view.state.doc.resolve(t.pos))), n.preventDefault()) : A(this.view, "pointer");
773
+ }
774
+ move(n) {
775
+ this.updateAllowDefault(n), A(this.view, "pointer"), n.buttons == 0 && this.done();
776
+ }
777
+ updateAllowDefault(n) {
778
+ !this.allowDefault && (Math.abs(this.event.x - n.clientX) > 4 || Math.abs(this.event.y - n.clientY) > 4) && (this.allowDefault = !0);
779
+ }
780
+ }
781
+ T.touchstart = (e) => {
782
+ e.input.lastTouch = Date.now(), me(e), A(e, "pointer");
783
+ };
784
+ T.touchmove = (e) => {
785
+ e.input.lastTouch = Date.now(), A(e, "pointer");
786
+ };
787
+ T.contextmenu = (e) => me(e);
788
+ function ve(e, n) {
789
+ return e.composing ? !0 : F && Math.abs(n.timeStamp - e.input.compositionEndedAt) < 500 ? (e.input.compositionEndedAt = -2e8, !0) : !1;
790
+ }
791
+ const Ft = Y ? 5e3 : -1;
792
+ y.compositionstart = y.compositionupdate = (e) => {
793
+ if (!e.composing) {
794
+ e.domObserver.flush();
795
+ let { state: n } = e, t = n.selection.$to;
796
+ if (n.selection instanceof D && (n.storedMarks || !t.textOffset && t.parentOffset && t.nodeBefore.marks.some((r) => r.type.spec.inclusive === !1) || O && He && Bt(e)))
797
+ e.markCursor = e.state.storedMarks || t.marks(), Z(e, !0), e.markCursor = null;
798
+ else if (Z(e, !n.selection.empty), v && n.selection.empty && t.parentOffset && !t.textOffset && t.nodeBefore.marks.length) {
799
+ let r = e.domSelectionRange();
800
+ for (let o = r.focusNode, l = r.focusOffset; o && o.nodeType == 1 && l != 0; ) {
801
+ let s = l < 0 ? o.lastChild : o.childNodes[l - 1];
802
+ if (!s)
803
+ break;
804
+ if (s.nodeType == 3) {
805
+ let i = e.domSelection();
806
+ i && i.collapse(s, s.nodeValue.length);
887
807
  break;
888
808
  } else
889
- throw new Error(l);
809
+ o = s, l = -1;
890
810
  }
891
811
  }
892
- return this.state.top = !0, t;
812
+ e.input.composing = !0;
893
813
  }
894
- inline(e, t = []) {
895
- return this.inlineQueue.push({ src: e, tokens: t }), t;
896
- }
897
- /**
898
- * Lexing/Compiling
899
- */
900
- inlineTokens(e, t = []) {
901
- let s = e, r = null;
902
- if (this.tokens.links) {
903
- const a = Object.keys(this.tokens.links);
904
- if (a.length > 0)
905
- for (; (r = this.tokenizer.rules.inline.reflinkSearch.exec(s)) != null; )
906
- a.includes(r[0].slice(r[0].lastIndexOf("[") + 1, -1)) && (s = s.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
814
+ et(e, Ft);
815
+ };
816
+ function Bt(e) {
817
+ let { focusNode: n, focusOffset: t } = e.domSelectionRange();
818
+ if (!n || n.nodeType != 1 || t >= n.childNodes.length)
819
+ return !1;
820
+ let r = n.childNodes[t];
821
+ return r.nodeType == 1 && r.contentEditable == "false";
822
+ }
823
+ y.compositionend = (e, n) => {
824
+ e.composing && (e.input.composing = !1, e.input.compositionEndedAt = n.timeStamp, e.input.compositionPendingChanges = e.domObserver.pendingRecords().length ? e.input.compositionID : 0, e.input.compositionNode = null, e.input.badSafariComposition ? e.domObserver.forceFlush() : e.input.compositionPendingChanges && Promise.resolve().then(() => e.domObserver.flush()), e.input.compositionID++, et(e, 20));
825
+ };
826
+ function et(e, n) {
827
+ clearTimeout(e.input.composingTimeout), n > -1 && (e.input.composingTimeout = setTimeout(() => Z(e), n));
828
+ }
829
+ function qt(e) {
830
+ for (e.composing && (e.input.composing = !1, e.input.compositionEndedAt = Ht()); e.input.compositionNodes.length > 0; )
831
+ e.input.compositionNodes.pop().markParentsDirty();
832
+ }
833
+ function Ht() {
834
+ let e = document.createEvent("Event");
835
+ return e.initEvent("event", !0, !0), e.timeStamp;
836
+ }
837
+ function Z(e, n = !1) {
838
+ if (!(Y && e.domObserver.flushingSoon >= 0)) {
839
+ if (e.domObserver.forceFlush(), qt(e), n || e.docView && e.docView.dirty) {
840
+ let t = dt(e), r = e.state.selection;
841
+ return t && !t.eq(r) ? e.dispatch(e.state.tr.setSelection(t)) : (e.markCursor || n) && !r.$from.node(r.$from.sharedDepth(r.to)).inlineContent ? e.dispatch(e.state.tr.deleteSelection()) : e.updateState(e.state), !0;
907
842
  }
908
- for (; (r = this.tokenizer.rules.inline.anyPunctuation.exec(s)) != null; )
909
- s = s.slice(0, r.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
910
- for (; (r = this.tokenizer.rules.inline.blockSkip.exec(s)) != null; )
911
- s = s.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
912
- let i = !1, l = "";
913
- for (; e; ) {
914
- i || (l = ""), i = !1;
915
- let a;
916
- if (this.options.extensions?.inline?.some((o) => (a = o.call({ lexer: this }, e, t)) ? (e = e.substring(a.raw.length), t.push(a), !0) : !1))
917
- continue;
918
- if (a = this.tokenizer.escape(e)) {
919
- e = e.substring(a.raw.length), t.push(a);
920
- continue;
921
- }
922
- if (a = this.tokenizer.tag(e)) {
923
- e = e.substring(a.raw.length), t.push(a);
924
- continue;
925
- }
926
- if (a = this.tokenizer.link(e)) {
927
- e = e.substring(a.raw.length), t.push(a);
928
- continue;
929
- }
930
- if (a = this.tokenizer.reflink(e, this.tokens.links)) {
931
- e = e.substring(a.raw.length);
932
- const o = t.at(-1);
933
- a.type === "text" && o?.type === "text" ? (o.raw += a.raw, o.text += a.text) : t.push(a);
934
- continue;
935
- }
936
- if (a = this.tokenizer.emStrong(e, s, l)) {
937
- e = e.substring(a.raw.length), t.push(a);
938
- continue;
939
- }
940
- if (a = this.tokenizer.codespan(e)) {
941
- e = e.substring(a.raw.length), t.push(a);
942
- continue;
943
- }
944
- if (a = this.tokenizer.br(e)) {
945
- e = e.substring(a.raw.length), t.push(a);
946
- continue;
947
- }
948
- if (a = this.tokenizer.del(e)) {
949
- e = e.substring(a.raw.length), t.push(a);
950
- continue;
951
- }
952
- if (a = this.tokenizer.autolink(e)) {
953
- e = e.substring(a.raw.length), t.push(a);
954
- continue;
955
- }
956
- if (!this.state.inLink && (a = this.tokenizer.url(e))) {
957
- e = e.substring(a.raw.length), t.push(a);
958
- continue;
959
- }
960
- let c = e;
961
- if (this.options.extensions?.startInline) {
962
- let o = 1 / 0;
963
- const h = e.slice(1);
964
- let k;
965
- this.options.extensions.startInline.forEach((p) => {
966
- k = p.call({ lexer: this }, h), typeof k == "number" && k >= 0 && (o = Math.min(o, k));
967
- }), o < 1 / 0 && o >= 0 && (c = e.substring(0, o + 1));
968
- }
969
- if (a = this.tokenizer.inlineText(c)) {
970
- e = e.substring(a.raw.length), a.raw.slice(-1) !== "_" && (l = a.raw.slice(-1)), i = !0;
971
- const o = t.at(-1);
972
- o?.type === "text" ? (o.raw += a.raw, o.text += a.text) : t.push(a);
973
- continue;
974
- }
975
- if (e) {
976
- const o = "Infinite loop on byte: " + e.charCodeAt(0);
977
- if (this.options.silent) {
978
- console.error(o);
979
- break;
980
- } else
981
- throw new Error(o);
982
- }
843
+ return !1;
844
+ }
845
+ }
846
+ function Wt(e, n) {
847
+ if (!e.dom.parentNode)
848
+ return;
849
+ let t = e.dom.parentNode.appendChild(document.createElement("div"));
850
+ t.appendChild(n), t.style.cssText = "position: fixed; left: -10000px; top: 10px";
851
+ let r = getSelection(), o = document.createRange();
852
+ o.selectNodeContents(n), e.dom.blur(), r.removeAllRanges(), r.addRange(o), setTimeout(() => {
853
+ t.parentNode && t.parentNode.removeChild(t), e.focus();
854
+ }, 50);
855
+ }
856
+ const j = X && Be < 15 || ue && ut < 604;
857
+ T.copy = y.cut = (e, n) => {
858
+ let t = n, r = e.state.selection, o = t.type == "cut";
859
+ if (r.empty)
860
+ return;
861
+ let l = j ? null : t.clipboardData, s = r.content(), { dom: i, text: a } = Xe(e, s);
862
+ l ? (t.preventDefault(), l.clearData(), l.setData("text/html", i.innerHTML), l.setData("text/plain", a)) : Wt(e, i), o && e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent", "cut"));
863
+ };
864
+ function jt(e) {
865
+ return e.openStart == 0 && e.openEnd == 0 && e.content.childCount == 1 ? e.content.firstChild : null;
866
+ }
867
+ function Ut(e, n) {
868
+ if (!e.dom.parentNode)
869
+ return;
870
+ let t = e.input.shiftKey || e.state.selection.$from.parent.type.spec.code, r = e.dom.parentNode.appendChild(document.createElement(t ? "textarea" : "div"));
871
+ t || (r.contentEditable = "true"), r.style.cssText = "position: fixed; left: -10000px; top: 10px", r.focus();
872
+ let o = e.input.shiftKey && e.input.lastKeyCode != 45;
873
+ setTimeout(() => {
874
+ e.focus(), r.parentNode && r.parentNode.removeChild(r), t ? ce(e, r.value, null, o, n) : ce(e, r.textContent, r.innerHTML, o, n);
875
+ }, 50);
876
+ }
877
+ function ce(e, n, t, r, o) {
878
+ let l = Ye(e, n, t, r, e.state.selection.$from);
879
+ if (e.someProp("handlePaste", (a) => a(e, o, l || K.empty)))
880
+ return !0;
881
+ if (!l)
882
+ return !1;
883
+ let s = jt(l), i = s ? e.state.tr.replaceSelectionWith(s, r) : e.state.tr.replaceSelection(l);
884
+ return e.dispatch(i.scrollIntoView().setMeta("paste", !0).setMeta("uiEvent", "paste")), !0;
885
+ }
886
+ function tt(e) {
887
+ let n = e.getData("text/plain") || e.getData("Text");
888
+ if (n)
889
+ return n;
890
+ let t = e.getData("text/uri-list");
891
+ return t ? t.replace(/\r?\n/g, " ") : "";
892
+ }
893
+ y.paste = (e, n) => {
894
+ let t = n;
895
+ if (e.composing && !Y)
896
+ return;
897
+ let r = j ? null : t.clipboardData, o = e.input.shiftKey && e.input.lastKeyCode != 45;
898
+ r && ce(e, tt(r), r.getData("text/html"), o, t) ? t.preventDefault() : Ut(e, t);
899
+ };
900
+ class Xt {
901
+ constructor(n, t, r) {
902
+ this.slice = n, this.move = t, this.node = r;
903
+ }
904
+ }
905
+ const Yt = S ? "altKey" : "ctrlKey";
906
+ function nt(e, n) {
907
+ let t = e.someProp("dragCopies", (r) => !r(n));
908
+ return t ?? !n[Yt];
909
+ }
910
+ T.dragstart = (e, n) => {
911
+ let t = n, r = e.input.mouseDown;
912
+ if (r && r.done(), !t.dataTransfer)
913
+ return;
914
+ let o = e.state.selection, l = o.empty ? null : e.posAtCoords(ee(t)), s;
915
+ if (!(l && l.pos >= o.from && l.pos <= (o instanceof h ? o.to - 1 : o.to))) {
916
+ if (r && r.mightDrag)
917
+ s = h.create(e.state.doc, r.mightDrag.pos);
918
+ else if (t.target && t.target.nodeType == 1) {
919
+ let c = e.docView.nearestDesc(t.target, !0);
920
+ c && c.node.type.spec.draggable && c != e.docView && (s = h.create(e.state.doc, c.posBefore));
983
921
  }
984
- return t;
985
922
  }
986
- }, I = class {
987
- options;
988
- parser;
989
- // set by the parser
990
- constructor(n) {
991
- this.options = n || S;
923
+ let i = (s || e.state.selection).content(), { dom: a, text: f, slice: u } = Xe(e, i);
924
+ (!t.dataTransfer.files.length || !O || qe > 120) && t.dataTransfer.clearData(), t.dataTransfer.setData(j ? "Text" : "text/html", a.innerHTML), t.dataTransfer.effectAllowed = "copyMove", j || t.dataTransfer.setData("text/plain", f), e.dragging = new Xt(u, nt(e, t), s);
925
+ };
926
+ T.dragend = (e) => {
927
+ let n = e.dragging;
928
+ window.setTimeout(() => {
929
+ e.dragging == n && (e.dragging = null);
930
+ }, 50);
931
+ };
932
+ y.dragover = y.dragenter = (e, n) => n.preventDefault();
933
+ y.drop = (e, n) => {
934
+ try {
935
+ Jt(e, n, e.dragging);
936
+ } finally {
937
+ e.dragging = null;
992
938
  }
993
- space(n) {
994
- return "";
939
+ };
940
+ function Jt(e, n, t) {
941
+ if (!n.dataTransfer)
942
+ return;
943
+ let r = e.posAtCoords(ee(n));
944
+ if (!r)
945
+ return;
946
+ let o = e.state.doc.resolve(r.pos), l = t && t.slice;
947
+ l ? e.someProp("transformPasted", (p) => {
948
+ l = p(l, e, !1);
949
+ }) : l = Ye(e, tt(n.dataTransfer), j ? null : n.dataTransfer.getData("text/html"), !1, o);
950
+ let s = !!(t && nt(e, n));
951
+ if (e.someProp("handleDrop", (p) => p(e, n, l || K.empty, s))) {
952
+ n.preventDefault();
953
+ return;
954
+ }
955
+ if (!l)
956
+ return;
957
+ n.preventDefault();
958
+ let i = l ? at(e.state.doc, o.pos, l) : o.pos;
959
+ i == null && (i = o.pos);
960
+ let a = e.state.tr;
961
+ if (s) {
962
+ let { node: p } = t;
963
+ p ? p.replace(a) : a.deleteSelection();
964
+ }
965
+ let f = a.mapping.map(i), u = l.openStart == 0 && l.openEnd == 0 && l.content.childCount == 1, c = a.doc;
966
+ if (u ? a.replaceRangeWith(f, f, l.content.firstChild) : a.replaceRange(f, f, l), a.doc.eq(c))
967
+ return;
968
+ let d = a.doc.resolve(f);
969
+ if (u && h.isSelectable(l.content.firstChild) && d.nodeAfter && d.nodeAfter.sameMarkup(l.content.firstChild))
970
+ a.setSelection(new h(d));
971
+ else {
972
+ let p = a.mapping.map(i);
973
+ a.mapping.maps[a.mapping.maps.length - 1].forEach((b, E, N, C) => p = C), a.setSelection(je(e, d, a.doc.resolve(p)));
974
+ }
975
+ e.focus(), e.dispatch(a.setMeta("uiEvent", "drop"));
976
+ }
977
+ T.focus = (e) => {
978
+ e.input.lastFocus = Date.now(), e.focused || (e.domObserver.stop(), e.dom.classList.add("ProseMirror-focused"), e.domObserver.start(), e.focused = !0, setTimeout(() => {
979
+ e.docView && e.hasFocus() && !e.domObserver.currentSelection.eq(e.domSelectionRange()) && pe(e);
980
+ }, 20));
981
+ };
982
+ T.blur = (e, n) => {
983
+ let t = n;
984
+ e.focused && (e.domObserver.stop(), e.dom.classList.remove("ProseMirror-focused"), e.domObserver.start(), t.relatedTarget && e.dom.contains(t.relatedTarget) && e.domObserver.currentSelection.clear(), e.focused = !1);
985
+ };
986
+ T.beforeinput = (e, n) => {
987
+ if (O && Y && n.inputType == "deleteContentBackward") {
988
+ e.domObserver.flushSoon();
989
+ let { domChangeCount: r } = e.input;
990
+ setTimeout(() => {
991
+ if (e.input.domChangeCount != r || (e.dom.blur(), e.focus(), e.someProp("handleKeyDown", (l) => l(e, Le(8, "Backspace")))))
992
+ return;
993
+ let { $cursor: o } = e.state.selection;
994
+ o && o.pos > 0 && e.dispatch(e.state.tr.delete(o.pos - 1, o.pos).scrollIntoView());
995
+ }, 50);
995
996
  }
996
- code({ text: n, lang: e, escaped: t }) {
997
- const s = (e || "").match(x.notSpaceStart)?.[0], r = n.replace(x.endingNewline, "") + `
998
- `;
999
- return s ? '<pre><code class="language-' + m(s) + '">' + (t ? r : m(r, !0)) + `</code></pre>
1000
- ` : "<pre><code>" + (t ? r : m(r, !0)) + `</code></pre>
1001
- `;
997
+ };
998
+ for (let e in y)
999
+ T[e] = y[e];
1000
+ function U(e, n) {
1001
+ if (e == n)
1002
+ return !0;
1003
+ for (let t in e)
1004
+ if (e[t] !== n[t])
1005
+ return !1;
1006
+ for (let t in n)
1007
+ if (!(t in e))
1008
+ return !1;
1009
+ return !0;
1010
+ }
1011
+ class _ {
1012
+ constructor(n, t) {
1013
+ this.toDOM = n, this.spec = t || R, this.side = this.spec.side || 0;
1002
1014
  }
1003
- blockquote({ tokens: n }) {
1004
- return `<blockquote>
1005
- ${this.parser.parse(n)}</blockquote>
1006
- `;
1015
+ map(n, t, r, o) {
1016
+ let { pos: l, deleted: s } = n.mapResult(t.from + o, this.side < 0 ? -1 : 1);
1017
+ return s ? null : new x(l - r, l - r, this);
1007
1018
  }
1008
- html({ text: n }) {
1009
- return n;
1019
+ valid() {
1020
+ return !0;
1010
1021
  }
1011
- heading({ tokens: n, depth: e }) {
1012
- return `<h${e}>${this.parser.parseInline(n)}</h${e}>
1013
- `;
1022
+ eq(n) {
1023
+ return this == n || n instanceof _ && (this.spec.key && this.spec.key == n.spec.key || this.toDOM == n.toDOM && U(this.spec, n.spec));
1014
1024
  }
1015
- hr(n) {
1016
- return `<hr>
1017
- `;
1025
+ destroy(n) {
1026
+ this.spec.destroy && this.spec.destroy(n);
1018
1027
  }
1019
- list(n) {
1020
- const e = n.ordered, t = n.start;
1021
- let s = "";
1022
- for (let l = 0; l < n.items.length; l++) {
1023
- const a = n.items[l];
1024
- s += this.listitem(a);
1025
- }
1026
- const r = e ? "ol" : "ul", i = e && t !== 1 ? ' start="' + t + '"' : "";
1027
- return "<" + r + i + `>
1028
- ` + s + "</" + r + `>
1029
- `;
1030
- }
1031
- listitem(n) {
1032
- let e = "";
1033
- if (n.task) {
1034
- const t = this.checkbox({ checked: !!n.checked });
1035
- n.loose ? n.tokens[0]?.type === "paragraph" ? (n.tokens[0].text = t + " " + n.tokens[0].text, n.tokens[0].tokens && n.tokens[0].tokens.length > 0 && n.tokens[0].tokens[0].type === "text" && (n.tokens[0].tokens[0].text = t + " " + m(n.tokens[0].tokens[0].text), n.tokens[0].tokens[0].escaped = !0)) : n.tokens.unshift({
1036
- type: "text",
1037
- raw: t + " ",
1038
- text: t + " ",
1039
- escaped: !0
1040
- }) : e += t + " ";
1041
- }
1042
- return e += this.parser.parse(n.tokens, !!n.loose), `<li>${e}</li>
1043
- `;
1044
- }
1045
- checkbox({ checked: n }) {
1046
- return "<input " + (n ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
1047
- }
1048
- paragraph({ tokens: n }) {
1049
- return `<p>${this.parser.parseInline(n)}</p>
1050
- `;
1051
- }
1052
- table(n) {
1053
- let e = "", t = "";
1054
- for (let r = 0; r < n.header.length; r++)
1055
- t += this.tablecell(n.header[r]);
1056
- e += this.tablerow({ text: t });
1057
- let s = "";
1058
- for (let r = 0; r < n.rows.length; r++) {
1059
- const i = n.rows[r];
1060
- t = "";
1061
- for (let l = 0; l < i.length; l++)
1062
- t += this.tablecell(i[l]);
1063
- s += this.tablerow({ text: t });
1064
- }
1065
- return s && (s = `<tbody>${s}</tbody>`), `<table>
1066
- <thead>
1067
- ` + e + `</thead>
1068
- ` + s + `</table>
1069
- `;
1070
- }
1071
- tablerow({ text: n }) {
1072
- return `<tr>
1073
- ${n}</tr>
1074
- `;
1075
- }
1076
- tablecell(n) {
1077
- const e = this.parser.parseInline(n.tokens), t = n.header ? "th" : "td";
1078
- return (n.align ? `<${t} align="${n.align}">` : `<${t}>`) + e + `</${t}>
1079
- `;
1028
+ }
1029
+ class P {
1030
+ constructor(n, t) {
1031
+ this.attrs = n, this.spec = t || R;
1080
1032
  }
1081
- /**
1082
- * span level renderer
1083
- */
1084
- strong({ tokens: n }) {
1085
- return `<strong>${this.parser.parseInline(n)}</strong>`;
1086
- }
1087
- em({ tokens: n }) {
1088
- return `<em>${this.parser.parseInline(n)}</em>`;
1089
- }
1090
- codespan({ text: n }) {
1091
- return `<code>${m(n, !0)}</code>`;
1092
- }
1093
- br(n) {
1094
- return "<br>";
1095
- }
1096
- del({ tokens: n }) {
1097
- return `<del>${this.parser.parseInline(n)}</del>`;
1098
- }
1099
- link({ href: n, title: e, tokens: t }) {
1100
- const s = this.parser.parseInline(t), r = ne(n);
1101
- if (r === null)
1102
- return s;
1103
- n = r;
1104
- let i = '<a href="' + n + '"';
1105
- return e && (i += ' title="' + m(e) + '"'), i += ">" + s + "</a>", i;
1106
- }
1107
- image({ href: n, title: e, text: t, tokens: s }) {
1108
- s && (t = this.parser.parseInline(s, this.parser.textRenderer));
1109
- const r = ne(n);
1110
- if (r === null)
1111
- return m(t);
1112
- n = r;
1113
- let i = `<img src="${n}" alt="${t}"`;
1114
- return e && (i += ` title="${m(e)}"`), i += ">", i;
1115
- }
1116
- text(n) {
1117
- return "tokens" in n && n.tokens ? this.parser.parseInline(n.tokens) : "escaped" in n && n.escaped ? n.text : m(n.text);
1118
- }
1119
- }, W = class {
1120
- // no need for block level renderers
1121
- strong({ text: n }) {
1122
- return n;
1033
+ map(n, t, r, o) {
1034
+ let l = n.map(t.from + o, this.spec.inclusiveStart ? -1 : 1) - r, s = n.map(t.to + o, this.spec.inclusiveEnd ? 1 : -1) - r;
1035
+ return l >= s ? null : new x(l, s, this);
1123
1036
  }
1124
- em({ text: n }) {
1125
- return n;
1037
+ valid(n, t) {
1038
+ return t.from < t.to;
1126
1039
  }
1127
- codespan({ text: n }) {
1128
- return n;
1040
+ eq(n) {
1041
+ return this == n || n instanceof P && U(this.attrs, n.attrs) && U(this.spec, n.spec);
1129
1042
  }
1130
- del({ text: n }) {
1131
- return n;
1043
+ static is(n) {
1044
+ return n.type instanceof P;
1132
1045
  }
1133
- html({ text: n }) {
1134
- return n;
1046
+ destroy() {
1135
1047
  }
1136
- text({ text: n }) {
1137
- return n;
1048
+ }
1049
+ class ge {
1050
+ constructor(n, t) {
1051
+ this.attrs = n, this.spec = t || R;
1138
1052
  }
1139
- link({ text: n }) {
1140
- return "" + n;
1053
+ map(n, t, r, o) {
1054
+ let l = n.mapResult(t.from + o, 1);
1055
+ if (l.deleted)
1056
+ return null;
1057
+ let s = n.mapResult(t.to + o, -1);
1058
+ return s.deleted || s.pos <= l.pos ? null : new x(l.pos - r, s.pos - r, this);
1141
1059
  }
1142
- image({ text: n }) {
1143
- return "" + n;
1060
+ valid(n, t) {
1061
+ let { index: r, offset: o } = n.content.findIndex(t.from), l;
1062
+ return o == t.from && !(l = n.child(r)).isText && o + l.nodeSize == t.to;
1144
1063
  }
1145
- br() {
1146
- return "";
1064
+ eq(n) {
1065
+ return this == n || n instanceof ge && U(this.attrs, n.attrs) && U(this.spec, n.spec);
1147
1066
  }
1148
- }, y = class G {
1149
- options;
1150
- renderer;
1151
- textRenderer;
1152
- constructor(e) {
1153
- this.options = e || S, this.options.renderer = this.options.renderer || new I(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new W();
1067
+ destroy() {
1154
1068
  }
1069
+ }
1070
+ class x {
1155
1071
  /**
1156
- * Static Parse Method
1157
- */
1158
- static parse(e, t) {
1159
- return new G(t).parse(e);
1072
+ @internal
1073
+ */
1074
+ constructor(n, t, r) {
1075
+ this.from = n, this.to = t, this.type = r;
1160
1076
  }
1161
1077
  /**
1162
- * Static Parse Inline Method
1163
- */
1164
- static parseInline(e, t) {
1165
- return new G(t).parseInline(e);
1078
+ @internal
1079
+ */
1080
+ copy(n, t) {
1081
+ return new x(n, t, this.type);
1166
1082
  }
1167
1083
  /**
1168
- * Parse Loop
1169
- */
1170
- parse(e, t = !0) {
1171
- let s = "";
1172
- for (let r = 0; r < e.length; r++) {
1173
- const i = e[r];
1174
- if (this.options.extensions?.renderers?.[i.type]) {
1175
- const a = i, c = this.options.extensions.renderers[a.type].call({ parser: this }, a);
1176
- if (c !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(a.type)) {
1177
- s += c || "";
1178
- continue;
1179
- }
1180
- }
1181
- const l = i;
1182
- switch (l.type) {
1183
- case "space": {
1184
- s += this.renderer.space(l);
1185
- continue;
1186
- }
1187
- case "hr": {
1188
- s += this.renderer.hr(l);
1189
- continue;
1190
- }
1191
- case "heading": {
1192
- s += this.renderer.heading(l);
1193
- continue;
1194
- }
1195
- case "code": {
1196
- s += this.renderer.code(l);
1197
- continue;
1198
- }
1199
- case "table": {
1200
- s += this.renderer.table(l);
1201
- continue;
1202
- }
1203
- case "blockquote": {
1204
- s += this.renderer.blockquote(l);
1205
- continue;
1206
- }
1207
- case "list": {
1208
- s += this.renderer.list(l);
1209
- continue;
1210
- }
1211
- case "html": {
1212
- s += this.renderer.html(l);
1213
- continue;
1214
- }
1215
- case "paragraph": {
1216
- s += this.renderer.paragraph(l);
1217
- continue;
1218
- }
1219
- case "text": {
1220
- let a = l, c = this.renderer.text(a);
1221
- for (; r + 1 < e.length && e[r + 1].type === "text"; )
1222
- a = e[++r], c += `
1223
- ` + this.renderer.text(a);
1224
- t ? s += this.renderer.paragraph({
1225
- type: "paragraph",
1226
- raw: c,
1227
- text: c,
1228
- tokens: [{ type: "text", raw: c, text: c, escaped: !0 }]
1229
- }) : s += c;
1230
- continue;
1231
- }
1232
- default: {
1233
- const a = 'Token with "' + l.type + '" type was not found.';
1234
- if (this.options.silent)
1235
- return console.error(a), "";
1236
- throw new Error(a);
1237
- }
1238
- }
1239
- }
1240
- return s;
1084
+ @internal
1085
+ */
1086
+ eq(n, t = 0) {
1087
+ return this.type.eq(n.type) && this.from + t == n.from && this.to + t == n.to;
1241
1088
  }
1242
1089
  /**
1243
- * Parse Inline Tokens
1244
- */
1245
- parseInline(e, t = this.renderer) {
1246
- let s = "";
1247
- for (let r = 0; r < e.length; r++) {
1248
- const i = e[r];
1249
- if (this.options.extensions?.renderers?.[i.type]) {
1250
- const a = this.options.extensions.renderers[i.type].call({ parser: this }, i);
1251
- if (a !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) {
1252
- s += a || "";
1253
- continue;
1254
- }
1255
- }
1256
- const l = i;
1257
- switch (l.type) {
1258
- case "escape": {
1259
- s += t.text(l);
1260
- break;
1261
- }
1262
- case "html": {
1263
- s += t.html(l);
1264
- break;
1265
- }
1266
- case "link": {
1267
- s += t.link(l);
1268
- break;
1269
- }
1270
- case "image": {
1271
- s += t.image(l);
1272
- break;
1273
- }
1274
- case "strong": {
1275
- s += t.strong(l);
1276
- break;
1277
- }
1278
- case "em": {
1279
- s += t.em(l);
1280
- break;
1281
- }
1282
- case "codespan": {
1283
- s += t.codespan(l);
1284
- break;
1285
- }
1286
- case "br": {
1287
- s += t.br(l);
1288
- break;
1289
- }
1290
- case "del": {
1291
- s += t.del(l);
1292
- break;
1293
- }
1294
- case "text": {
1295
- s += t.text(l);
1296
- break;
1297
- }
1298
- default: {
1299
- const a = 'Token with "' + l.type + '" type was not found.';
1300
- if (this.options.silent)
1301
- return console.error(a), "";
1302
- throw new Error(a);
1303
- }
1304
- }
1305
- }
1306
- return s;
1090
+ @internal
1091
+ */
1092
+ map(n, t, r) {
1093
+ return this.type.map(n, this, t, r);
1307
1094
  }
1308
- }, L = class {
1309
- options;
1310
- block;
1311
- constructor(n) {
1312
- this.options = n || S;
1095
+ /**
1096
+ Creates a widget decoration, which is a DOM node that's shown in
1097
+ the document at the given position. It is recommended that you
1098
+ delay rendering the widget by passing a function that will be
1099
+ called when the widget is actually drawn in a view, but you can
1100
+ also directly pass a DOM node. `getPos` can be used to find the
1101
+ widget's current document position.
1102
+ */
1103
+ static widget(n, t, r) {
1104
+ return new x(n, n, new _(t, r));
1313
1105
  }
1314
- static passThroughHooks = /* @__PURE__ */ new Set([
1315
- "preprocess",
1316
- "postprocess",
1317
- "processAllTokens"
1318
- ]);
1319
1106
  /**
1320
- * Process markdown before marked
1321
- */
1322
- preprocess(n) {
1323
- return n;
1107
+ Creates an inline decoration, which adds the given attributes to
1108
+ each inline node between `from` and `to`.
1109
+ */
1110
+ static inline(n, t, r, o) {
1111
+ return new x(n, t, new P(r, o));
1324
1112
  }
1325
1113
  /**
1326
- * Process HTML after marked is finished
1327
- */
1328
- postprocess(n) {
1329
- return n;
1114
+ Creates a node decoration. `from` and `to` should point precisely
1115
+ before and after a node in the document. That node, and only that
1116
+ node, will receive the given attributes.
1117
+ */
1118
+ static node(n, t, r, o) {
1119
+ return new x(n, t, new ge(r, o));
1330
1120
  }
1331
1121
  /**
1332
- * Process all tokens before walk tokens
1333
- */
1334
- processAllTokens(n) {
1335
- return n;
1122
+ The spec provided when creating this decoration. Can be useful
1123
+ if you've stored extra information in that object.
1124
+ */
1125
+ get spec() {
1126
+ return this.type.spec;
1336
1127
  }
1337
1128
  /**
1338
- * Provide function to tokenize markdown
1339
- */
1340
- provideLexer() {
1341
- return this.block ? w.lex : w.lexInline;
1129
+ @internal
1130
+ */
1131
+ get inline() {
1132
+ return this.type instanceof P;
1342
1133
  }
1343
1134
  /**
1344
- * Provide function to parse tokens
1345
- */
1346
- provideParser() {
1347
- return this.block ? y.parse : y.parseInline;
1348
- }
1349
- }, Ve = class {
1350
- defaults = O();
1351
- options = this.setOptions;
1352
- parse = this.parseMarkdown(!0);
1353
- parseInline = this.parseMarkdown(!1);
1354
- Parser = y;
1355
- Renderer = I;
1356
- TextRenderer = W;
1357
- Lexer = w;
1358
- Tokenizer = C;
1359
- Hooks = L;
1360
- constructor(...n) {
1361
- this.use(...n);
1135
+ @internal
1136
+ */
1137
+ get widget() {
1138
+ return this.type instanceof _;
1362
1139
  }
1140
+ }
1141
+ const q = [], R = {};
1142
+ class m {
1363
1143
  /**
1364
- * Run callback for every token
1365
- */
1366
- walkTokens(n, e) {
1367
- let t = [];
1368
- for (const s of n)
1369
- switch (t = t.concat(e.call(this, s)), s.type) {
1370
- case "table": {
1371
- const r = s;
1372
- for (const i of r.header)
1373
- t = t.concat(this.walkTokens(i.tokens, e));
1374
- for (const i of r.rows)
1375
- for (const l of i)
1376
- t = t.concat(this.walkTokens(l.tokens, e));
1377
- break;
1378
- }
1379
- case "list": {
1380
- const r = s;
1381
- t = t.concat(this.walkTokens(r.items, e));
1382
- break;
1383
- }
1384
- default: {
1385
- const r = s;
1386
- this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((i) => {
1387
- const l = r[i].flat(1 / 0);
1388
- t = t.concat(this.walkTokens(l, e));
1389
- }) : r.tokens && (t = t.concat(this.walkTokens(r.tokens, e)));
1390
- }
1144
+ @internal
1145
+ */
1146
+ constructor(n, t) {
1147
+ this.local = n.length ? n : q, this.children = t.length ? t : q;
1148
+ }
1149
+ /**
1150
+ Create a set of decorations, using the structure of the given
1151
+ document. This will consume (modify) the `decorations` array, so
1152
+ you must make a copy if you want need to preserve that.
1153
+ */
1154
+ static create(n, t) {
1155
+ return t.length ? w(t, n, 0, R) : g;
1156
+ }
1157
+ /**
1158
+ Find all decorations in this set which touch the given range
1159
+ (including decorations that start or end directly at the
1160
+ boundaries) and match the given predicate on their spec. When
1161
+ `start` and `end` are omitted, all decorations in the set are
1162
+ considered. When `predicate` isn't given, all decorations are
1163
+ assumed to match.
1164
+ */
1165
+ find(n, t, r) {
1166
+ let o = [];
1167
+ return this.findInner(n ?? 0, t ?? 1e9, o, 0, r), o;
1168
+ }
1169
+ findInner(n, t, r, o, l) {
1170
+ for (let s = 0; s < this.local.length; s++) {
1171
+ let i = this.local[s];
1172
+ i.from <= t && i.to >= n && (!l || l(i.spec)) && r.push(i.copy(i.from + o, i.to + o));
1173
+ }
1174
+ for (let s = 0; s < this.children.length; s += 3)
1175
+ if (this.children[s] < t && this.children[s + 1] > n) {
1176
+ let i = this.children[s] + 1;
1177
+ this.children[s + 2].findInner(n - i, t - i, r, o + i, l);
1391
1178
  }
1392
- return t;
1393
1179
  }
1394
- use(...n) {
1395
- const e = this.defaults.extensions || { renderers: {}, childTokens: {} };
1396
- return n.forEach((t) => {
1397
- const s = { ...t };
1398
- if (s.async = this.defaults.async || s.async || !1, t.extensions && (t.extensions.forEach((r) => {
1399
- if (!r.name)
1400
- throw new Error("extension name required");
1401
- if ("renderer" in r) {
1402
- const i = e.renderers[r.name];
1403
- i ? e.renderers[r.name] = function(...l) {
1404
- let a = r.renderer.apply(this, l);
1405
- return a === !1 && (a = i.apply(this, l)), a;
1406
- } : e.renderers[r.name] = r.renderer;
1407
- }
1408
- if ("tokenizer" in r) {
1409
- if (!r.level || r.level !== "block" && r.level !== "inline")
1410
- throw new Error("extension level must be 'block' or 'inline'");
1411
- const i = e[r.level];
1412
- i ? i.unshift(r.tokenizer) : e[r.level] = [r.tokenizer], r.start && (r.level === "block" ? e.startBlock ? e.startBlock.push(r.start) : e.startBlock = [r.start] : r.level === "inline" && (e.startInline ? e.startInline.push(r.start) : e.startInline = [r.start]));
1413
- }
1414
- "childTokens" in r && r.childTokens && (e.childTokens[r.name] = r.childTokens);
1415
- }), s.extensions = e), t.renderer) {
1416
- const r = this.defaults.renderer || new I(this.defaults);
1417
- for (const i in t.renderer) {
1418
- if (!(i in r))
1419
- throw new Error(`renderer '${i}' does not exist`);
1420
- if (["options", "parser"].includes(i))
1421
- continue;
1422
- const l = i, a = t.renderer[l], c = r[l];
1423
- r[l] = (...o) => {
1424
- let h = a.apply(r, o);
1425
- return h === !1 && (h = c.apply(r, o)), h || "";
1426
- };
1427
- }
1428
- s.renderer = r;
1180
+ /**
1181
+ Map the set of decorations in response to a change in the
1182
+ document.
1183
+ */
1184
+ map(n, t, r) {
1185
+ return this == g || n.maps.length == 0 ? this : this.mapInner(n, t, 0, 0, r || R);
1186
+ }
1187
+ /**
1188
+ @internal
1189
+ */
1190
+ mapInner(n, t, r, o, l) {
1191
+ let s;
1192
+ for (let i = 0; i < this.local.length; i++) {
1193
+ let a = this.local[i].map(n, r, o);
1194
+ a && a.type.valid(t, a) ? (s || (s = [])).push(a) : l.onRemove && l.onRemove(this.local[i].spec);
1195
+ }
1196
+ return this.children.length ? Gt(this.children, s || [], n, t, r, o, l) : s ? new m(s.sort(V), q) : g;
1197
+ }
1198
+ /**
1199
+ Add the given array of decorations to the ones in the set,
1200
+ producing a new set. Consumes the `decorations` array. Needs
1201
+ access to the current document to create the appropriate tree
1202
+ structure.
1203
+ */
1204
+ add(n, t) {
1205
+ return t.length ? this == g ? m.create(n, t) : this.addInner(n, t, 0) : this;
1206
+ }
1207
+ addInner(n, t, r) {
1208
+ let o, l = 0;
1209
+ n.forEach((i, a) => {
1210
+ let f = a + r, u;
1211
+ if (u = ot(t, i, f)) {
1212
+ for (o || (o = this.children.slice()); l < o.length && o[l] < a; )
1213
+ l += 3;
1214
+ o[l] == a ? o[l + 2] = o[l + 2].addInner(i, u, f + 1) : o.splice(l, 0, a, a + i.nodeSize, w(u, i, f + 1, R)), l += 3;
1429
1215
  }
1430
- if (t.tokenizer) {
1431
- const r = this.defaults.tokenizer || new C(this.defaults);
1432
- for (const i in t.tokenizer) {
1433
- if (!(i in r))
1434
- throw new Error(`tokenizer '${i}' does not exist`);
1435
- if (["options", "rules", "lexer"].includes(i))
1436
- continue;
1437
- const l = i, a = t.tokenizer[l], c = r[l];
1438
- r[l] = (...o) => {
1439
- let h = a.apply(r, o);
1440
- return h === !1 && (h = c.apply(r, o)), h;
1441
- };
1442
- }
1443
- s.tokenizer = r;
1216
+ });
1217
+ let s = rt(l ? lt(t) : t, -r);
1218
+ for (let i = 0; i < s.length; i++)
1219
+ s[i].type.valid(n, s[i]) || s.splice(i--, 1);
1220
+ return new m(s.length ? this.local.concat(s).sort(V) : this.local, o || this.children);
1221
+ }
1222
+ /**
1223
+ Create a new set that contains the decorations in this set, minus
1224
+ the ones in the given array.
1225
+ */
1226
+ remove(n) {
1227
+ return n.length == 0 || this == g ? this : this.removeInner(n, 0);
1228
+ }
1229
+ removeInner(n, t) {
1230
+ let r = this.children, o = this.local;
1231
+ for (let l = 0; l < r.length; l += 3) {
1232
+ let s, i = r[l] + t, a = r[l + 1] + t;
1233
+ for (let u = 0, c; u < n.length; u++)
1234
+ (c = n[u]) && c.from > i && c.to < a && (n[u] = null, (s || (s = [])).push(c));
1235
+ if (!s)
1236
+ continue;
1237
+ r == this.children && (r = this.children.slice());
1238
+ let f = r[l + 2].removeInner(s, i + 1);
1239
+ f != g ? r[l + 2] = f : (r.splice(l, 3), l -= 3);
1240
+ }
1241
+ if (o.length) {
1242
+ for (let l = 0, s; l < n.length; l++)
1243
+ if (s = n[l])
1244
+ for (let i = 0; i < o.length; i++)
1245
+ o[i].eq(s, t) && (o == this.local && (o = this.local.slice()), o.splice(i--, 1));
1246
+ }
1247
+ return r == this.children && o == this.local ? this : o.length || r.length ? new m(o, r) : g;
1248
+ }
1249
+ forChild(n, t) {
1250
+ if (this == g)
1251
+ return this;
1252
+ if (t.isLeaf)
1253
+ return m.empty;
1254
+ let r, o;
1255
+ for (let i = 0; i < this.children.length; i += 3)
1256
+ if (this.children[i] >= n) {
1257
+ this.children[i] == n && (r = this.children[i + 2]);
1258
+ break;
1259
+ }
1260
+ let l = n + 1, s = l + t.content.size;
1261
+ for (let i = 0; i < this.local.length; i++) {
1262
+ let a = this.local[i];
1263
+ if (a.from < s && a.to > l && a.type instanceof P) {
1264
+ let f = Math.max(l, a.from) - l, u = Math.min(s, a.to) - l;
1265
+ f < u && (o || (o = [])).push(a.copy(f, u));
1444
1266
  }
1445
- if (t.hooks) {
1446
- const r = this.defaults.hooks || new L();
1447
- for (const i in t.hooks) {
1448
- if (!(i in r))
1449
- throw new Error(`hook '${i}' does not exist`);
1450
- if (["options", "block"].includes(i))
1451
- continue;
1452
- const l = i, a = t.hooks[l], c = r[l];
1453
- L.passThroughHooks.has(i) ? r[l] = (o) => {
1454
- if (this.defaults.async)
1455
- return Promise.resolve(a.call(r, o)).then((k) => c.call(r, k));
1456
- const h = a.call(r, o);
1457
- return c.call(r, h);
1458
- } : r[l] = (...o) => {
1459
- let h = a.apply(r, o);
1460
- return h === !1 && (h = c.apply(r, o)), h;
1461
- };
1267
+ }
1268
+ if (o) {
1269
+ let i = new m(o.sort(V), q);
1270
+ return r ? new I([i, r]) : i;
1271
+ }
1272
+ return r || g;
1273
+ }
1274
+ /**
1275
+ @internal
1276
+ */
1277
+ eq(n) {
1278
+ if (this == n)
1279
+ return !0;
1280
+ if (!(n instanceof m) || this.local.length != n.local.length || this.children.length != n.children.length)
1281
+ return !1;
1282
+ for (let t = 0; t < this.local.length; t++)
1283
+ if (!this.local[t].eq(n.local[t]))
1284
+ return !1;
1285
+ for (let t = 0; t < this.children.length; t += 3)
1286
+ if (this.children[t] != n.children[t] || this.children[t + 1] != n.children[t + 1] || !this.children[t + 2].eq(n.children[t + 2]))
1287
+ return !1;
1288
+ return !0;
1289
+ }
1290
+ /**
1291
+ @internal
1292
+ */
1293
+ locals(n) {
1294
+ return be(this.localsInner(n));
1295
+ }
1296
+ /**
1297
+ @internal
1298
+ */
1299
+ localsInner(n) {
1300
+ if (this == g)
1301
+ return q;
1302
+ if (n.inlineContent || !this.local.some(P.is))
1303
+ return this.local;
1304
+ let t = [];
1305
+ for (let r = 0; r < this.local.length; r++)
1306
+ this.local[r].type instanceof P || t.push(this.local[r]);
1307
+ return t;
1308
+ }
1309
+ forEachSet(n) {
1310
+ n(this);
1311
+ }
1312
+ }
1313
+ m.empty = new m([], []);
1314
+ m.removeOverlap = be;
1315
+ const g = m.empty;
1316
+ class I {
1317
+ constructor(n) {
1318
+ this.members = n;
1319
+ }
1320
+ map(n, t) {
1321
+ const r = this.members.map((o) => o.map(n, t, R));
1322
+ return I.from(r);
1323
+ }
1324
+ forChild(n, t) {
1325
+ if (t.isLeaf)
1326
+ return m.empty;
1327
+ let r = [];
1328
+ for (let o = 0; o < this.members.length; o++) {
1329
+ let l = this.members[o].forChild(n, t);
1330
+ l != g && (l instanceof I ? r = r.concat(l.members) : r.push(l));
1331
+ }
1332
+ return I.from(r);
1333
+ }
1334
+ eq(n) {
1335
+ if (!(n instanceof I) || n.members.length != this.members.length)
1336
+ return !1;
1337
+ for (let t = 0; t < this.members.length; t++)
1338
+ if (!this.members[t].eq(n.members[t]))
1339
+ return !1;
1340
+ return !0;
1341
+ }
1342
+ locals(n) {
1343
+ let t, r = !0;
1344
+ for (let o = 0; o < this.members.length; o++) {
1345
+ let l = this.members[o].localsInner(n);
1346
+ if (l.length)
1347
+ if (!t)
1348
+ t = l;
1349
+ else {
1350
+ r && (t = t.slice(), r = !1);
1351
+ for (let s = 0; s < l.length; s++)
1352
+ t.push(l[s]);
1462
1353
  }
1463
- s.hooks = r;
1354
+ }
1355
+ return t ? be(r ? t : t.sort(V)) : q;
1356
+ }
1357
+ // Create a group for the given array of decoration sets, or return
1358
+ // a single set when possible.
1359
+ static from(n) {
1360
+ switch (n.length) {
1361
+ case 0:
1362
+ return g;
1363
+ case 1:
1364
+ return n[0];
1365
+ default:
1366
+ return new I(n.every((t) => t instanceof m) ? n : n.reduce((t, r) => t.concat(r instanceof m ? r : r.members), []));
1367
+ }
1368
+ }
1369
+ forEachSet(n) {
1370
+ for (let t = 0; t < this.members.length; t++)
1371
+ this.members[t].forEachSet(n);
1372
+ }
1373
+ }
1374
+ function Gt(e, n, t, r, o, l, s) {
1375
+ let i = e.slice();
1376
+ for (let f = 0, u = l; f < t.maps.length; f++) {
1377
+ let c = 0;
1378
+ t.maps[f].forEach((d, p, b, E) => {
1379
+ let N = E - b - (p - d);
1380
+ for (let C = 0; C < i.length; C += 3) {
1381
+ let ye = i[C + 1];
1382
+ if (ye < 0 || d > ye + u - c)
1383
+ continue;
1384
+ let Ce = i[C] + u - c;
1385
+ p >= Ce ? i[C + 1] = d <= Ce ? -2 : -1 : d >= u && N && (i[C] += N, i[C + 1] += N);
1464
1386
  }
1465
- if (t.walkTokens) {
1466
- const r = this.defaults.walkTokens, i = t.walkTokens;
1467
- s.walkTokens = function(l) {
1468
- let a = [];
1469
- return a.push(i.call(this, l)), r && (a = a.concat(r.call(this, l))), a;
1470
- };
1387
+ c += N;
1388
+ }), u = t.maps[f].map(u, -1);
1389
+ }
1390
+ let a = !1;
1391
+ for (let f = 0; f < i.length; f += 3)
1392
+ if (i[f + 1] < 0) {
1393
+ if (i[f + 1] == -2) {
1394
+ a = !0, i[f + 1] = -1;
1395
+ continue;
1471
1396
  }
1472
- this.defaults = { ...this.defaults, ...s };
1473
- }), this;
1474
- }
1475
- setOptions(n) {
1476
- return this.defaults = { ...this.defaults, ...n }, this;
1477
- }
1478
- lexer(n, e) {
1479
- return w.lex(n, e ?? this.defaults);
1480
- }
1481
- parser(n, e) {
1482
- return y.parse(n, e ?? this.defaults);
1483
- }
1484
- parseMarkdown(n) {
1485
- return (t, s) => {
1486
- const r = { ...s }, i = { ...this.defaults, ...r }, l = this.onError(!!i.silent, !!i.async);
1487
- if (this.defaults.async === !0 && r.async === !1)
1488
- return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
1489
- if (typeof t > "u" || t === null)
1490
- return l(new Error("marked(): input parameter is undefined or null"));
1491
- if (typeof t != "string")
1492
- return l(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(t) + ", string expected"));
1493
- i.hooks && (i.hooks.options = i, i.hooks.block = n);
1494
- const a = i.hooks ? i.hooks.provideLexer() : n ? w.lex : w.lexInline, c = i.hooks ? i.hooks.provideParser() : n ? y.parse : y.parseInline;
1495
- if (i.async)
1496
- return Promise.resolve(i.hooks ? i.hooks.preprocess(t) : t).then((o) => a(o, i)).then((o) => i.hooks ? i.hooks.processAllTokens(o) : o).then((o) => i.walkTokens ? Promise.all(this.walkTokens(o, i.walkTokens)).then(() => o) : o).then((o) => c(o, i)).then((o) => i.hooks ? i.hooks.postprocess(o) : o).catch(l);
1497
- try {
1498
- i.hooks && (t = i.hooks.preprocess(t));
1499
- let o = a(t, i);
1500
- i.hooks && (o = i.hooks.processAllTokens(o)), i.walkTokens && this.walkTokens(o, i.walkTokens);
1501
- let h = c(o, i);
1502
- return i.hooks && (h = i.hooks.postprocess(h)), h;
1503
- } catch (o) {
1504
- return l(o);
1397
+ let u = t.map(e[f] + l), c = u - o;
1398
+ if (c < 0 || c >= r.content.size) {
1399
+ a = !0;
1400
+ continue;
1505
1401
  }
1506
- };
1507
- }
1508
- onError(n, e) {
1509
- return (t) => {
1510
- if (t.message += `
1511
- Please report this to https://github.com/markedjs/marked.`, n) {
1512
- const s = "<p>An error occurred:</p><pre>" + m(t.message + "", !0) + "</pre>";
1513
- return e ? Promise.resolve(s) : s;
1402
+ let d = t.map(e[f + 1] + l, -1), p = d - o, { index: b, offset: E } = r.content.findIndex(c), N = r.maybeChild(b);
1403
+ if (N && E == c && E + N.nodeSize == p) {
1404
+ let C = i[f + 2].mapInner(t, N, u + 1, e[f] + l + 1, s);
1405
+ C != g ? (i[f] = c, i[f + 1] = p, i[f + 2] = C) : (i[f + 1] = -2, a = !0);
1406
+ } else
1407
+ a = !0;
1408
+ }
1409
+ if (a) {
1410
+ let f = Qt(i, e, n, t, o, l, s), u = w(f, r, 0, s);
1411
+ n = u.local;
1412
+ for (let c = 0; c < i.length; c += 3)
1413
+ i[c + 1] < 0 && (i.splice(c, 3), c -= 3);
1414
+ for (let c = 0, d = 0; c < u.children.length; c += 3) {
1415
+ let p = u.children[c];
1416
+ for (; d < i.length && i[d] < p; )
1417
+ d += 3;
1418
+ i.splice(d, 0, u.children[c], u.children[c + 1], u.children[c + 2]);
1419
+ }
1420
+ }
1421
+ return new m(n.sort(V), i);
1422
+ }
1423
+ function rt(e, n) {
1424
+ if (!n || !e.length)
1425
+ return e;
1426
+ let t = [];
1427
+ for (let r = 0; r < e.length; r++) {
1428
+ let o = e[r];
1429
+ t.push(new x(o.from + n, o.to + n, o.type));
1430
+ }
1431
+ return t;
1432
+ }
1433
+ function Qt(e, n, t, r, o, l, s) {
1434
+ function i(a, f) {
1435
+ for (let u = 0; u < a.local.length; u++) {
1436
+ let c = a.local[u].map(r, o, f);
1437
+ c ? t.push(c) : s.onRemove && s.onRemove(a.local[u].spec);
1438
+ }
1439
+ for (let u = 0; u < a.children.length; u += 3)
1440
+ i(a.children[u + 2], a.children[u] + f + 1);
1441
+ }
1442
+ for (let a = 0; a < e.length; a += 3)
1443
+ e[a + 1] == -1 && i(e[a + 2], n[a] + l + 1);
1444
+ return t;
1445
+ }
1446
+ function ot(e, n, t) {
1447
+ if (n.isLeaf)
1448
+ return null;
1449
+ let r = t + n.nodeSize, o = null;
1450
+ for (let l = 0, s; l < e.length; l++)
1451
+ (s = e[l]) && s.from > t && s.to < r && ((o || (o = [])).push(s), e[l] = null);
1452
+ return o;
1453
+ }
1454
+ function lt(e) {
1455
+ let n = [];
1456
+ for (let t = 0; t < e.length; t++)
1457
+ e[t] != null && n.push(e[t]);
1458
+ return n;
1459
+ }
1460
+ function w(e, n, t, r) {
1461
+ let o = [], l = !1;
1462
+ n.forEach((i, a) => {
1463
+ let f = ot(e, i, a + t);
1464
+ if (f) {
1465
+ l = !0;
1466
+ let u = w(f, i, t + a + 1, r);
1467
+ u != g && o.push(a, a + i.nodeSize, u);
1468
+ }
1469
+ });
1470
+ let s = rt(l ? lt(e) : e, -t).sort(V);
1471
+ for (let i = 0; i < s.length; i++)
1472
+ s[i].type.valid(n, s[i]) || (r.onRemove && r.onRemove(s[i].spec), s.splice(i--, 1));
1473
+ return s.length || o.length ? new m(s, o) : g;
1474
+ }
1475
+ function V(e, n) {
1476
+ return e.from - n.from || e.to - n.to;
1477
+ }
1478
+ function be(e) {
1479
+ let n = e;
1480
+ for (let t = 0; t < n.length - 1; t++) {
1481
+ let r = n[t];
1482
+ if (r.from != r.to)
1483
+ for (let o = t + 1; o < n.length; o++) {
1484
+ let l = n[o];
1485
+ if (l.from == r.from) {
1486
+ l.to != r.to && (n == e && (n = e.slice()), n[o] = l.copy(l.from, r.to), Re(n, o + 1, l.copy(r.to, l.to)));
1487
+ continue;
1488
+ } else {
1489
+ l.from < r.to && (n == e && (n = e.slice()), n[t] = r.copy(r.from, l.from), Re(n, o, r.copy(l.from, r.to)));
1490
+ break;
1491
+ }
1514
1492
  }
1515
- if (e)
1516
- return Promise.reject(t);
1517
- throw t;
1518
- };
1519
1493
  }
1520
- }, R = new Ve();
1521
- function g(n, e) {
1522
- return R.parse(n, e);
1494
+ return n;
1495
+ }
1496
+ function Re(e, n, t) {
1497
+ for (; n < e.length && V(t, e[n]) > 0; )
1498
+ n++;
1499
+ e.splice(n, 0, t);
1523
1500
  }
1524
- g.options = g.setOptions = function(n) {
1525
- return R.setOptions(n), g.defaults = R.defaults, ie(g.defaults), g;
1526
- };
1527
- g.getDefaults = O;
1528
- g.defaults = S;
1529
- g.use = function(...n) {
1530
- return R.use(...n), g.defaults = R.defaults, ie(g.defaults), g;
1531
- };
1532
- g.walkTokens = function(n, e) {
1533
- return R.walkTokens(n, e);
1534
- };
1535
- g.parseInline = R.parseInline;
1536
- g.Parser = y;
1537
- g.parser = y.parse;
1538
- g.Renderer = I;
1539
- g.TextRenderer = W;
1540
- g.Lexer = w;
1541
- g.lexer = w.lex;
1542
- g.Tokenizer = C;
1543
- g.Hooks = L;
1544
- g.parse = g;
1545
- g.options;
1546
- g.setOptions;
1547
- g.use;
1548
- g.walkTokens;
1549
- g.parseInline;
1550
- y.parse;
1551
- w.lex;
1552
1501
  export {
1553
- L as Hooks,
1554
- w as Lexer,
1555
- Ve as Marked,
1556
- y as Parser,
1557
- I as Renderer,
1558
- W as TextRenderer,
1559
- C as Tokenizer,
1560
- S as defaults,
1561
- O as getDefaults,
1562
- g as marked
1502
+ x as Decoration,
1503
+ m as DecorationSet
1563
1504
  };