@clevertask/scribe 0.1.4 → 0.1.5

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 (85) hide show
  1. package/README.md +3 -0
  2. package/dist/BarMenu-V1uRL3bt.js +272 -0
  3. package/dist/assets/index.css +1 -1
  4. package/dist/components/Menu/BarMenu.d.ts.map +1 -1
  5. package/dist/components/Menu/BarMenu.js +2 -10
  6. package/dist/components/Menu/BubbleMenu.d.ts.map +1 -1
  7. package/dist/components/Menu/BubbleMenu.js +165 -1023
  8. package/dist/components/Menu/LinkBubbleMenu.d.ts +8 -0
  9. package/dist/components/Menu/LinkBubbleMenu.d.ts.map +1 -0
  10. package/dist/components/Menu/LinkBubbleMenu.js +78 -0
  11. package/dist/components/Menu/LinkEditor.d.ts +14 -0
  12. package/dist/components/Menu/LinkEditor.d.ts.map +1 -0
  13. package/dist/components/Menu/LinkEditor.js +140 -0
  14. package/dist/components/Menu/Mobile/ListOptionBar.d.ts.map +1 -1
  15. package/dist/components/Menu/Mobile/ListOptionBar.js +38 -44
  16. package/dist/components/Menu/linkBubbleMenuPlugin.d.ts +5 -0
  17. package/dist/components/Menu/linkBubbleMenuPlugin.d.ts.map +1 -0
  18. package/dist/components/Menu/linkBubbleMenuPlugin.js +7 -0
  19. package/dist/components/Menu/linkUrl.d.ts +2 -0
  20. package/dist/components/Menu/linkUrl.d.ts.map +1 -0
  21. package/dist/components/Menu/linkUrl.js +21 -0
  22. package/dist/components/Scribe/extension/emoji/EmojiList.js +58 -45
  23. package/dist/components/Scribe/extension/emoji/suggest.d.ts +2 -2
  24. package/dist/components/Scribe/extension/emoji/suggest.d.ts.map +1 -1
  25. package/dist/components/Scribe/extension/emoji/suggest.js +39 -43
  26. package/dist/components/Scribe/extension/extension-link.d.ts.map +1 -1
  27. package/dist/components/Scribe/extension/extension-link.js +2 -4
  28. package/dist/components/Scribe/extension/extension-markdown-paste.d.ts.map +1 -1
  29. package/dist/components/Scribe/extension/extension-markdown-paste.js +50 -45
  30. package/dist/components/Scribe/extension/extension-selectedText.d.ts.map +1 -1
  31. package/dist/components/Scribe/extension/extension-selectedText.js +10 -12
  32. package/dist/components/Scribe/extension/getPopupMountTarget.d.ts.map +1 -1
  33. package/dist/components/Scribe/extension/getPopupMountTarget.js +12 -15
  34. package/dist/components/Scribe/extension/index.d.ts +4 -4
  35. package/dist/components/Scribe/extension/index.d.ts.map +1 -1
  36. package/dist/components/Scribe/extension/index.js +2 -39521
  37. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +3369 -3731
  38. package/dist/components/Scribe/extension/slashCommand/index.js +2 -6
  39. package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -1
  40. package/dist/components/Scribe/extension/slashCommand/items.js +177 -176
  41. package/dist/components/Scribe/extension/slashCommand/renderItems.d.ts.map +1 -1
  42. package/dist/components/Scribe/extension/slashCommand/renderItems.js +35 -41
  43. package/dist/components/Scribe/extension/tableOfContents.js +153 -180
  44. package/dist/components/Scribe/index.d.ts.map +1 -1
  45. package/dist/components/Scribe/index.js +113 -153
  46. package/dist/dist-BQjH-i-q.js +7016 -0
  47. package/dist/dist-CnXCIcnl.js +3506 -0
  48. package/dist/dist-RuuEA1GJ.js +686 -0
  49. package/dist/extension-CZOsheCI.js +56236 -0
  50. package/dist/extension-link-DZID_SYl.js +908 -0
  51. package/dist/floating-ui.dom-rih69525.js +928 -0
  52. package/dist/html-to-markdown-CrNOkSye.js +497 -0
  53. package/dist/icons/ToolbarIcons.d.ts.map +1 -1
  54. package/dist/icons/ToolbarIcons.js +76 -135
  55. package/dist/main.css +10 -0
  56. package/dist/main.js +7 -15
  57. package/dist/markdown-to-html-DEczPfuq.js +1458 -0
  58. package/dist/menus-CzX7kyXn.js +633 -0
  59. package/dist/purify.es-DF9CW1cl.js +767 -0
  60. package/dist/rolldown-runtime-B8UxIWdF.js +7 -0
  61. package/dist/slashCommand-B7CRIaKG.js +429 -0
  62. package/dist/tables-CjOC70rm.js +1345 -0
  63. package/dist/tippy.esm-D9LL2xiE.js +1713 -0
  64. package/dist/utils/convert-legacy-math-delimiters.d.ts.map +1 -1
  65. package/dist/utils/convert-legacy-math-delimiters.js +7 -13
  66. package/dist/utils/create-scribe-editor.js +2 -31
  67. package/dist/utils/html-to-markdown.d.ts.map +1 -1
  68. package/dist/utils/html-to-markdown.js +2 -600
  69. package/dist/utils/index.js +24 -12
  70. package/dist/utils/is-in-viewport.d.ts.map +1 -1
  71. package/dist/utils/is-in-viewport.js +6 -6
  72. package/dist/utils/markdown-to-html.d.ts.map +1 -1
  73. package/dist/utils/markdown-to-html.js +2 -5
  74. package/dist/vite-env.d.js +0 -1
  75. package/package.json +36 -34
  76. package/dist/BarMenu-BNk2I0zi.js +0 -327
  77. package/dist/extension-link-P1rro4zO.js +0 -1059
  78. package/dist/floating-ui.dom-ZRy7FSVk.js +0 -1246
  79. package/dist/index-BMISMQrG.js +0 -855
  80. package/dist/index-ByyiiYsp.js +0 -1410
  81. package/dist/index-CnKS-BY2.js +0 -13834
  82. package/dist/index-CnQHDObA.js +0 -539
  83. package/dist/markdown-to-html-Bw9L43K6.js +0 -1135
  84. package/dist/purify.es-DC1iJOxX.js +0 -864
  85. package/dist/tippy.esm-DLHdsnfG.js +0 -1711
@@ -0,0 +1,3506 @@
1
+ //#region node_modules/.pnpm/orderedmap@2.1.1/node_modules/orderedmap/dist/index.js
2
+ function e(e) {
3
+ this.content = e;
4
+ }
5
+ e.prototype = {
6
+ constructor: e,
7
+ find: function(e) {
8
+ for (var t = 0; t < this.content.length; t += 2) if (this.content[t] === e) return t;
9
+ return -1;
10
+ },
11
+ get: function(e) {
12
+ var t = this.find(e);
13
+ return t == -1 ? void 0 : this.content[t + 1];
14
+ },
15
+ update: function(t, n, r) {
16
+ var i = r && r != t ? this.remove(r) : this, a = i.find(t), o = i.content.slice();
17
+ return a == -1 ? o.push(r || t, n) : (o[a + 1] = n, r && (o[a] = r)), new e(o);
18
+ },
19
+ remove: function(t) {
20
+ var n = this.find(t);
21
+ if (n == -1) return this;
22
+ var r = this.content.slice();
23
+ return r.splice(n, 2), new e(r);
24
+ },
25
+ addToStart: function(t, n) {
26
+ return new e([t, n].concat(this.remove(t).content));
27
+ },
28
+ addToEnd: function(t, n) {
29
+ var r = this.remove(t).content.slice();
30
+ return r.push(t, n), new e(r);
31
+ },
32
+ addBefore: function(t, n, r) {
33
+ var i = this.remove(n), a = i.content.slice(), o = i.find(t);
34
+ return a.splice(o == -1 ? a.length : o, 0, n, r), new e(a);
35
+ },
36
+ forEach: function(e) {
37
+ for (var t = 0; t < this.content.length; t += 2) e(this.content[t], this.content[t + 1]);
38
+ },
39
+ prepend: function(t) {
40
+ return t = e.from(t), t.size ? new e(t.content.concat(this.subtract(t).content)) : this;
41
+ },
42
+ append: function(t) {
43
+ return t = e.from(t), t.size ? new e(this.subtract(t).content.concat(t.content)) : this;
44
+ },
45
+ subtract: function(t) {
46
+ var n = this;
47
+ t = e.from(t);
48
+ for (var r = 0; r < t.content.length; r += 2) n = n.remove(t.content[r]);
49
+ return n;
50
+ },
51
+ toObject: function() {
52
+ var e = {};
53
+ return this.forEach(function(t, n) {
54
+ e[t] = n;
55
+ }), e;
56
+ },
57
+ get size() {
58
+ return this.content.length >> 1;
59
+ }
60
+ }, e.from = function(t) {
61
+ if (t instanceof e) return t;
62
+ var n = [];
63
+ if (t) for (var r in t) n.push(r, t[r]);
64
+ return new e(n);
65
+ };
66
+ //#endregion
67
+ //#region node_modules/.pnpm/prosemirror-model@1.25.11/node_modules/prosemirror-model/dist/index.js
68
+ function t(e, n, a) {
69
+ for (let o = 0;; o++) {
70
+ if (o == e.childCount || o == n.childCount) return e.childCount == n.childCount ? null : a;
71
+ let s = e.child(o), c = n.child(o);
72
+ if (s == c) {
73
+ a += s.nodeSize;
74
+ continue;
75
+ }
76
+ if (!s.sameMarkup(c)) return a;
77
+ if (s.isText && s.text != c.text) {
78
+ let e = s.text, t = c.text, n = 0;
79
+ for (; e[n] == t[n]; n++) a++;
80
+ return n && n < e.length && n < t.length && i(e.charCodeAt(n - 1)) && r(e.charCodeAt(n)) && a--, a;
81
+ }
82
+ if (s.content.size || c.content.size) {
83
+ let e = t(s.content, c.content, a + 1);
84
+ if (e != null) return e;
85
+ }
86
+ a += s.nodeSize;
87
+ }
88
+ }
89
+ function n(e, t, a, o) {
90
+ for (let s = e.childCount, c = t.childCount;;) {
91
+ if (s == 0 || c == 0) return s == c ? null : {
92
+ a,
93
+ b: o
94
+ };
95
+ let l = e.child(--s), u = t.child(--c), d = l.nodeSize;
96
+ if (l == u) {
97
+ a -= d, o -= d;
98
+ continue;
99
+ }
100
+ if (!l.sameMarkup(u)) return {
101
+ a,
102
+ b: o
103
+ };
104
+ if (l.isText && l.text != u.text) {
105
+ let e = l.text, t = u.text, n = e.length, s = t.length;
106
+ for (; n > 0 && s > 0 && e[n - 1] == t[s - 1];) n--, s--, a--, o--;
107
+ return n && s && n < e.length && i(e.charCodeAt(n - 1)) && r(e.charCodeAt(n)) && (a++, o++), {
108
+ a,
109
+ b: o
110
+ };
111
+ }
112
+ if (l.content.size || u.content.size) {
113
+ let e = n(l.content, u.content, a - 1, o - 1);
114
+ if (e) return e;
115
+ }
116
+ a -= d, o -= d;
117
+ }
118
+ }
119
+ function r(e) {
120
+ return e >= 56320 && e < 57344;
121
+ }
122
+ function i(e) {
123
+ return e >= 55296 && e < 56320;
124
+ }
125
+ var a = class e {
126
+ constructor(e, t) {
127
+ if (this.content = e, this.size = t || 0, t == null) for (let t = 0; t < e.length; t++) this.size += e[t].nodeSize;
128
+ }
129
+ nodesBetween(e, t, n, r = 0, i) {
130
+ for (let a = 0, o = 0; o < t; a++) {
131
+ let s = this.content[a], c = o + s.nodeSize;
132
+ if (c > e && n(s, r + o, i || null, a) !== !1 && s.content.size) {
133
+ let i = o + 1;
134
+ s.nodesBetween(Math.max(0, e - i), Math.min(s.content.size, t - i), n, r + i);
135
+ }
136
+ o = c;
137
+ }
138
+ }
139
+ descendants(e) {
140
+ this.nodesBetween(0, this.size, e);
141
+ }
142
+ textBetween(e, t, n, r) {
143
+ let i = "", a = !0;
144
+ return this.nodesBetween(e, t, (o, s) => {
145
+ let c = o.isText ? o.text.slice(Math.max(e, s) - s, t - s) : o.isLeaf ? r ? typeof r == "function" ? r(o) : r : o.type.spec.leafText ? o.type.spec.leafText(o) : "" : "";
146
+ o.isBlock && (o.isLeaf && c || o.isTextblock) && n && (a ? a = !1 : i += n), i += c;
147
+ }, 0), i;
148
+ }
149
+ append(t) {
150
+ if (!t.size) return this;
151
+ if (!this.size) return t;
152
+ let n = this.lastChild, r = t.firstChild, i = this.content.slice(), a = 0;
153
+ for (n.isText && n.sameMarkup(r) && (i[i.length - 1] = n.withText(n.text + r.text), a = 1); a < t.content.length; a++) i.push(t.content[a]);
154
+ return new e(i, this.size + t.size);
155
+ }
156
+ cut(t, n = this.size) {
157
+ if (t == 0 && n == this.size) return this;
158
+ let r = [], i = 0;
159
+ if (n > t) for (let e = 0, a = 0; a < n; e++) {
160
+ let o = this.content[e], s = a + o.nodeSize;
161
+ s > t && ((a < t || s > n) && (o = o.isText ? o.cut(Math.max(0, t - a), Math.min(o.text.length, n - a)) : o.cut(Math.max(0, t - a - 1), Math.min(o.content.size, n - a - 1))), r.push(o), i += o.nodeSize), a = s;
162
+ }
163
+ return new e(r, i);
164
+ }
165
+ cutByIndex(t, n) {
166
+ return t == n ? e.empty : t == 0 && n == this.content.length ? this : new e(this.content.slice(t, n));
167
+ }
168
+ replaceChild(t, n) {
169
+ let r = this.content[t];
170
+ if (r == n) return this;
171
+ let i = this.content.slice(), a = this.size + n.nodeSize - r.nodeSize;
172
+ return i[t] = n, new e(i, a);
173
+ }
174
+ addToStart(t) {
175
+ return new e([t].concat(this.content), this.size + t.nodeSize);
176
+ }
177
+ addToEnd(t) {
178
+ return new e(this.content.concat(t), this.size + t.nodeSize);
179
+ }
180
+ eq(e) {
181
+ if (this.content.length != e.content.length) return !1;
182
+ for (let t = 0; t < this.content.length; t++) if (!this.content[t].eq(e.content[t])) return !1;
183
+ return !0;
184
+ }
185
+ get firstChild() {
186
+ return this.content.length ? this.content[0] : null;
187
+ }
188
+ get lastChild() {
189
+ return this.content.length ? this.content[this.content.length - 1] : null;
190
+ }
191
+ get childCount() {
192
+ return this.content.length;
193
+ }
194
+ child(e) {
195
+ let t = this.content[e];
196
+ if (!t) throw RangeError("Index " + e + " out of range for " + this);
197
+ return t;
198
+ }
199
+ maybeChild(e) {
200
+ return this.content[e] || null;
201
+ }
202
+ forEach(e) {
203
+ for (let t = 0, n = 0; t < this.content.length; t++) {
204
+ let r = this.content[t];
205
+ e(r, n, t), n += r.nodeSize;
206
+ }
207
+ }
208
+ findDiffStart(e, n = 0) {
209
+ return t(this, e, n);
210
+ }
211
+ findDiffEnd(e, t = this.size, r = e.size) {
212
+ return n(this, e, t, r);
213
+ }
214
+ findIndex(e) {
215
+ if (e == 0) return s(0, e);
216
+ if (e == this.size) return s(this.content.length, e);
217
+ if (e > this.size || e < 0) throw RangeError(`Position ${e} outside of fragment (${this})`);
218
+ for (let t = 0, n = 0;; t++) {
219
+ let r = this.child(t), i = n + r.nodeSize;
220
+ if (i >= e) return i == e ? s(t + 1, i) : s(t, n);
221
+ n = i;
222
+ }
223
+ }
224
+ toString() {
225
+ return "<" + this.toStringInner() + ">";
226
+ }
227
+ toStringInner() {
228
+ return this.content.join(", ");
229
+ }
230
+ toJSON() {
231
+ return this.content.length ? this.content.map((e) => e.toJSON()) : null;
232
+ }
233
+ static fromJSON(t, n) {
234
+ if (!n) return e.empty;
235
+ if (!Array.isArray(n)) throw RangeError("Invalid input for Fragment.fromJSON");
236
+ return e.fromArray(n.map(t.nodeFromJSON));
237
+ }
238
+ static fromArray(t) {
239
+ if (!t.length) return e.empty;
240
+ let n, r = 0;
241
+ for (let e = 0; e < t.length; e++) {
242
+ let i = t[e];
243
+ r += i.nodeSize, e && i.isText && t[e - 1].sameMarkup(i) ? (n ||= t.slice(0, e), n[n.length - 1] = i.withText(n[n.length - 1].text + i.text)) : n && n.push(i);
244
+ }
245
+ return new e(n || t, r);
246
+ }
247
+ static from(t) {
248
+ if (!t) return e.empty;
249
+ if (t instanceof e) return t;
250
+ if (Array.isArray(t)) return this.fromArray(t);
251
+ if (t.attrs) return new e([t], t.nodeSize);
252
+ throw RangeError("Can not convert " + t + " to a Fragment" + (t.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
253
+ }
254
+ };
255
+ a.empty = new a([], 0);
256
+ var o = {
257
+ index: 0,
258
+ offset: 0
259
+ };
260
+ function s(e, t) {
261
+ return o.index = e, o.offset = t, o;
262
+ }
263
+ function c(e, t) {
264
+ if (e === t) return !0;
265
+ if (!(e && typeof e == "object") || !(t && typeof t == "object")) return !1;
266
+ let n = Array.isArray(e);
267
+ if (Array.isArray(t) != n) return !1;
268
+ if (n) {
269
+ if (e.length != t.length) return !1;
270
+ for (let n = 0; n < e.length; n++) if (!c(e[n], t[n])) return !1;
271
+ } else {
272
+ for (let n in e) if (!(n in t) || !c(e[n], t[n])) return !1;
273
+ for (let n in t) if (!(n in e)) return !1;
274
+ }
275
+ return !0;
276
+ }
277
+ var l = class e {
278
+ constructor(e, t) {
279
+ this.type = e, this.attrs = t;
280
+ }
281
+ addToSet(e) {
282
+ let t, n = !1;
283
+ for (let r = 0; r < e.length; r++) {
284
+ let i = e[r];
285
+ if (this.eq(i)) return e;
286
+ if (this.type.excludes(i.type)) t ||= e.slice(0, r);
287
+ else if (i.type.excludes(this.type)) return e;
288
+ else !n && i.type.rank > this.type.rank && (t ||= e.slice(0, r), t.push(this), n = !0), t && t.push(i);
289
+ }
290
+ return t ||= e.slice(), n || t.push(this), t;
291
+ }
292
+ removeFromSet(e) {
293
+ for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return e.slice(0, t).concat(e.slice(t + 1));
294
+ return e;
295
+ }
296
+ isInSet(e) {
297
+ for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return !0;
298
+ return !1;
299
+ }
300
+ eq(e) {
301
+ return this == e || this.type == e.type && c(this.attrs, e.attrs);
302
+ }
303
+ toJSON() {
304
+ let e = { type: this.type.name };
305
+ for (let t in this.attrs) {
306
+ e.attrs = this.attrs;
307
+ break;
308
+ }
309
+ return e;
310
+ }
311
+ static fromJSON(e, t) {
312
+ if (!t) throw RangeError("Invalid input for Mark.fromJSON");
313
+ let n = e.marks[t.type];
314
+ if (!n) throw RangeError(`There is no mark type ${t.type} in this schema`);
315
+ let r = n.create(t.attrs);
316
+ return n.checkAttrs(r.attrs), r;
317
+ }
318
+ static sameSet(e, t) {
319
+ if (e == t) return !0;
320
+ if (e.length != t.length) return !1;
321
+ for (let n = 0; n < e.length; n++) if (!e[n].eq(t[n])) return !1;
322
+ return !0;
323
+ }
324
+ static setFrom(t) {
325
+ if (!t || Array.isArray(t) && t.length == 0) return e.none;
326
+ if (t instanceof e) return [t];
327
+ let n = t.slice();
328
+ return n.sort((e, t) => e.type.rank - t.type.rank), n;
329
+ }
330
+ };
331
+ l.none = [];
332
+ var u = class extends Error {}, d = class e {
333
+ constructor(e, t, n) {
334
+ this.content = e, this.openStart = t, this.openEnd = n;
335
+ }
336
+ get size() {
337
+ return this.content.size - this.openStart - this.openEnd;
338
+ }
339
+ insertAt(t, n) {
340
+ let r = p(this.content, t + this.openStart, n, this.openStart + 1, this.openEnd + 1);
341
+ return r && new e(r, this.openStart, this.openEnd);
342
+ }
343
+ removeBetween(t, n) {
344
+ return new e(f(this.content, t + this.openStart, n + this.openStart), this.openStart, this.openEnd);
345
+ }
346
+ eq(e) {
347
+ return this.content.eq(e.content) && this.openStart == e.openStart && this.openEnd == e.openEnd;
348
+ }
349
+ toString() {
350
+ return this.content + "(" + this.openStart + "," + this.openEnd + ")";
351
+ }
352
+ toJSON() {
353
+ if (!this.content.size) return null;
354
+ let e = { content: this.content.toJSON() };
355
+ return this.openStart > 0 && (e.openStart = this.openStart), this.openEnd > 0 && (e.openEnd = this.openEnd), e;
356
+ }
357
+ static fromJSON(t, n) {
358
+ if (!n) return e.empty;
359
+ let r = n.openStart || 0, i = n.openEnd || 0;
360
+ if (typeof r != "number" || typeof i != "number") throw RangeError("Invalid input for Slice.fromJSON");
361
+ return new e(a.fromJSON(t, n.content), r, i);
362
+ }
363
+ static maxOpen(t, n = !0) {
364
+ let r = 0, i = 0;
365
+ for (let e = t.firstChild; e && !e.isLeaf && (n || !e.type.spec.isolating); e = e.firstChild) r++;
366
+ for (let e = t.lastChild; e && !e.isLeaf && (n || !e.type.spec.isolating); e = e.lastChild) i++;
367
+ return new e(t, r, i);
368
+ }
369
+ };
370
+ d.empty = new d(a.empty, 0, 0);
371
+ function f(e, t, n) {
372
+ let { index: r, offset: i } = e.findIndex(t), a = e.maybeChild(r), { index: o, offset: s } = e.findIndex(n);
373
+ if (i == t || a.isText) {
374
+ if (s != n && !e.child(o).isText) throw RangeError("Removing non-flat range");
375
+ return e.cut(0, t).append(e.cut(n));
376
+ }
377
+ if (r != o) throw RangeError("Removing non-flat range");
378
+ return e.replaceChild(r, a.copy(f(a.content, t - i - 1, n - i - 1)));
379
+ }
380
+ function p(e, t, n, r, i, a) {
381
+ let { index: o, offset: s } = e.findIndex(t), c = e.maybeChild(o);
382
+ if (s == t || c.isText) return a && r <= 0 && i <= 0 && !a.canReplace(o, o, n) ? null : e.cut(0, t).append(n).append(e.cut(t));
383
+ let l = p(c.content, t - s - 1, n, o == 0 ? r - 1 : 0, o == e.childCount - 1 ? i - 1 : 0, c);
384
+ return l && e.replaceChild(o, c.copy(l));
385
+ }
386
+ function m(e, t, n) {
387
+ if (n.openStart > e.depth) throw new u("Inserted content deeper than insertion position");
388
+ if (e.depth - n.openStart != t.depth - n.openEnd) throw new u("Inconsistent open depths");
389
+ return h(e, t, n, 0);
390
+ }
391
+ function h(e, t, n, r) {
392
+ let i = e.index(r), a = e.node(r);
393
+ if (i == t.index(r) && r < e.depth - n.openStart) {
394
+ let o = h(e, t, n, r + 1);
395
+ return a.copy(a.content.replaceChild(i, o));
396
+ } else if (!n.content.size) return y(a, b(e, t, r));
397
+ else if (!n.openStart && !n.openEnd && e.depth == r && t.depth == r) {
398
+ let r = e.parent, i = r.content;
399
+ return y(r, i.cut(0, e.parentOffset).append(n.content).append(i.cut(t.parentOffset)));
400
+ } else {
401
+ let { start: i, end: o } = ne(n, e);
402
+ return y(a, te(e, i, o, t, r));
403
+ }
404
+ }
405
+ function ee(e, t) {
406
+ if (!t.type.compatibleContent(e.type)) throw new u("Cannot join " + t.type.name + " onto " + e.type.name);
407
+ }
408
+ function g(e, t, n) {
409
+ let r = e.node(n);
410
+ return ee(r, t.node(n)), r;
411
+ }
412
+ function _(e, t) {
413
+ let n = t.length - 1;
414
+ n >= 0 && e.isText && e.sameMarkup(t[n]) ? t[n] = e.withText(t[n].text + e.text) : t.push(e);
415
+ }
416
+ function v(e, t, n, r) {
417
+ let i = (t || e).node(n), a = 0, o = t ? t.index(n) : i.childCount;
418
+ e && (a = e.index(n), e.depth > n ? a++ : e.textOffset && (_(e.nodeAfter, r), a++));
419
+ for (let e = a; e < o; e++) _(i.child(e), r);
420
+ t && t.depth == n && t.textOffset && _(t.nodeBefore, r);
421
+ }
422
+ function y(e, t) {
423
+ if (!e.type.validContent(t)) throw new u("Invalid content for node " + e.type.name);
424
+ return e.copy(t);
425
+ }
426
+ function te(e, t, n, r, i) {
427
+ let o = e.depth > i && g(e, t, i + 1), s = r.depth > i && g(n, r, i + 1), c = [];
428
+ return v(null, e, i, c), o && s && t.index(i) == n.index(i) ? (ee(o, s), _(y(o, te(e, t, n, r, i + 1)), c)) : (o && _(y(o, b(e, t, i + 1)), c), v(t, n, i, c), s && _(y(s, b(n, r, i + 1)), c)), v(r, null, i, c), new a(c);
429
+ }
430
+ function b(e, t, n) {
431
+ let r = [];
432
+ return v(null, e, n, r), e.depth > n && _(y(g(e, t, n + 1), b(e, t, n + 1)), r), v(t, null, n, r), new a(r);
433
+ }
434
+ function ne(e, t) {
435
+ let n = t.depth - e.openStart, r = t.node(n).copy(e.content);
436
+ for (let e = n - 1; e >= 0; e--) r = t.node(e).copy(a.from(r));
437
+ return {
438
+ start: r.resolveNoCache(e.openStart + n),
439
+ end: r.resolveNoCache(r.content.size - e.openEnd - n)
440
+ };
441
+ }
442
+ var re = class e {
443
+ constructor(e, t, n) {
444
+ this.pos = e, this.path = t, this.parentOffset = n, this.depth = t.length / 3 - 1;
445
+ }
446
+ resolveDepth(e) {
447
+ return e == null ? this.depth : e < 0 ? this.depth + e : e;
448
+ }
449
+ get parent() {
450
+ return this.node(this.depth);
451
+ }
452
+ get doc() {
453
+ return this.node(0);
454
+ }
455
+ node(e) {
456
+ return this.path[this.resolveDepth(e) * 3];
457
+ }
458
+ index(e) {
459
+ return this.path[this.resolveDepth(e) * 3 + 1];
460
+ }
461
+ indexAfter(e) {
462
+ return e = this.resolveDepth(e), this.index(e) + (e == this.depth && !this.textOffset ? 0 : 1);
463
+ }
464
+ start(e) {
465
+ return e = this.resolveDepth(e), e == 0 ? 0 : this.path[e * 3 - 1] + 1;
466
+ }
467
+ end(e) {
468
+ return e = this.resolveDepth(e), this.start(e) + this.node(e).content.size;
469
+ }
470
+ before(e) {
471
+ if (e = this.resolveDepth(e), !e) throw RangeError("There is no position before the top-level node");
472
+ return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1];
473
+ }
474
+ after(e) {
475
+ if (e = this.resolveDepth(e), !e) throw RangeError("There is no position after the top-level node");
476
+ return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1] + this.path[e * 3].nodeSize;
477
+ }
478
+ get textOffset() {
479
+ return this.pos - this.path[this.path.length - 1];
480
+ }
481
+ get nodeAfter() {
482
+ let e = this.parent, t = this.index(this.depth);
483
+ if (t == e.childCount) return null;
484
+ let n = this.pos - this.path[this.path.length - 1], r = e.child(t);
485
+ return n ? e.child(t).cut(n) : r;
486
+ }
487
+ get nodeBefore() {
488
+ let e = this.index(this.depth), t = this.pos - this.path[this.path.length - 1];
489
+ return t ? this.parent.child(e).cut(0, t) : e == 0 ? null : this.parent.child(e - 1);
490
+ }
491
+ posAtIndex(e, t) {
492
+ t = this.resolveDepth(t);
493
+ let n = this.path[t * 3], r = t == 0 ? 0 : this.path[t * 3 - 1] + 1;
494
+ for (let t = 0; t < e; t++) r += n.child(t).nodeSize;
495
+ return r;
496
+ }
497
+ marks() {
498
+ let e = this.parent, t = this.index();
499
+ if (e.content.size == 0) return l.none;
500
+ if (this.textOffset) return e.child(t).marks;
501
+ let n = e.maybeChild(t - 1), r = e.maybeChild(t);
502
+ if (!n) {
503
+ let e = n;
504
+ n = r, r = e;
505
+ }
506
+ let i = n.marks;
507
+ for (var a = 0; a < i.length; a++) i[a].type.spec.inclusive === !1 && (!r || !i[a].isInSet(r.marks)) && (i = i[a--].removeFromSet(i));
508
+ return i;
509
+ }
510
+ marksAcross(e) {
511
+ let t = this.parent.maybeChild(this.index());
512
+ if (!t || !t.isInline) return null;
513
+ let n = t.marks, r = e.parent.maybeChild(e.index());
514
+ for (var i = 0; i < n.length; i++) n[i].type.spec.inclusive === !1 && (!r || !n[i].isInSet(r.marks)) && (n = n[i--].removeFromSet(n));
515
+ return n;
516
+ }
517
+ sharedDepth(e) {
518
+ for (let t = this.depth; t > 0; t--) if (this.start(t) <= e && this.end(t) >= e) return t;
519
+ return 0;
520
+ }
521
+ blockRange(e = this, t) {
522
+ if (e.pos < this.pos) return e.blockRange(this);
523
+ for (let n = this.depth - (this.parent.inlineContent || this.pos == e.pos ? 1 : 0); n >= 0; n--) if (e.pos <= this.end(n) && (!t || t(this.node(n)))) return new se(this, e, n);
524
+ return null;
525
+ }
526
+ sameParent(e) {
527
+ return this.pos - this.parentOffset == e.pos - e.parentOffset;
528
+ }
529
+ max(e) {
530
+ return e.pos > this.pos ? e : this;
531
+ }
532
+ min(e) {
533
+ return e.pos < this.pos ? e : this;
534
+ }
535
+ toString() {
536
+ let e = "";
537
+ for (let t = 1; t <= this.depth; t++) e += (e ? "/" : "") + this.node(t).type.name + "_" + this.index(t - 1);
538
+ return e + ":" + this.parentOffset;
539
+ }
540
+ static resolve(t, n) {
541
+ if (!(n >= 0 && n <= t.content.size)) throw RangeError("Position " + n + " out of range");
542
+ let r = [], i = 0, a = n;
543
+ for (let e = t;;) {
544
+ let { index: t, offset: n } = e.content.findIndex(a), o = a - n;
545
+ if (r.push(e, t, i + n), !o || (e = e.child(t), e.isText)) break;
546
+ a = o - 1, i += n + 1;
547
+ }
548
+ return new e(n, r, a);
549
+ }
550
+ static resolveCached(t, n) {
551
+ let r = oe.get(t);
552
+ if (r) for (let e = 0; e < r.elts.length; e++) {
553
+ let t = r.elts[e];
554
+ if (t.pos == n) return t;
555
+ }
556
+ else oe.set(t, r = new ie());
557
+ let i = r.elts[r.i] = e.resolve(t, n);
558
+ return r.i = (r.i + 1) % ae, i;
559
+ }
560
+ }, ie = class {
561
+ constructor() {
562
+ this.elts = [], this.i = 0;
563
+ }
564
+ }, ae = 12, oe = /* @__PURE__ */ new WeakMap(), se = class {
565
+ constructor(e, t, n) {
566
+ this.$from = e, this.$to = t, this.depth = n;
567
+ }
568
+ get start() {
569
+ return this.$from.before(this.depth + 1);
570
+ }
571
+ get end() {
572
+ return this.$to.after(this.depth + 1);
573
+ }
574
+ get parent() {
575
+ return this.$from.node(this.depth);
576
+ }
577
+ get startIndex() {
578
+ return this.$from.index(this.depth);
579
+ }
580
+ get endIndex() {
581
+ return this.$to.indexAfter(this.depth);
582
+ }
583
+ }, ce = Object.create(null), x = class e {
584
+ constructor(e, t, n, r = l.none) {
585
+ this.type = e, this.attrs = t, this.marks = r, this.content = n || a.empty;
586
+ }
587
+ get children() {
588
+ return this.content.content;
589
+ }
590
+ get nodeSize() {
591
+ return this.isLeaf ? 1 : 2 + this.content.size;
592
+ }
593
+ get childCount() {
594
+ return this.content.childCount;
595
+ }
596
+ child(e) {
597
+ return this.content.child(e);
598
+ }
599
+ maybeChild(e) {
600
+ return this.content.maybeChild(e);
601
+ }
602
+ forEach(e) {
603
+ this.content.forEach(e);
604
+ }
605
+ nodesBetween(e, t, n, r = 0) {
606
+ this.content.nodesBetween(e, t, n, r, this);
607
+ }
608
+ descendants(e) {
609
+ this.nodesBetween(0, this.content.size, e);
610
+ }
611
+ get textContent() {
612
+ return this.isLeaf && this.type.spec.leafText ? this.type.spec.leafText(this) : this.textBetween(0, this.content.size, "");
613
+ }
614
+ textBetween(e, t, n, r) {
615
+ return this.content.textBetween(e, t, n, r);
616
+ }
617
+ get firstChild() {
618
+ return this.content.firstChild;
619
+ }
620
+ get lastChild() {
621
+ return this.content.lastChild;
622
+ }
623
+ eq(e) {
624
+ return this == e || this.sameMarkup(e) && this.content.eq(e.content);
625
+ }
626
+ sameMarkup(e) {
627
+ return this.hasMarkup(e.type, e.attrs, e.marks);
628
+ }
629
+ hasMarkup(e, t, n) {
630
+ return this.type == e && c(this.attrs, t || e.defaultAttrs || ce) && l.sameSet(this.marks, n || l.none);
631
+ }
632
+ copy(t = null) {
633
+ return t == this.content ? this : new e(this.type, this.attrs, t, this.marks);
634
+ }
635
+ mark(t) {
636
+ return t == this.marks ? this : new e(this.type, this.attrs, this.content, t);
637
+ }
638
+ cut(e, t = this.content.size) {
639
+ return e == 0 && t == this.content.size ? this : this.copy(this.content.cut(e, t));
640
+ }
641
+ slice(e, t = this.content.size, n = !1) {
642
+ if (e == t) return d.empty;
643
+ let r = this.resolve(e), i = this.resolve(t), a = n ? 0 : r.sharedDepth(t), o = r.start(a);
644
+ return new d(r.node(a).content.cut(r.pos - o, i.pos - o), r.depth - a, i.depth - a);
645
+ }
646
+ replace(e, t, n) {
647
+ return m(this.resolve(e), this.resolve(t), n);
648
+ }
649
+ nodeAt(e) {
650
+ for (let t = this;;) {
651
+ let { index: n, offset: r } = t.content.findIndex(e);
652
+ if (t = t.maybeChild(n), !t) return null;
653
+ if (r == e || t.isText) return t;
654
+ e -= r + 1;
655
+ }
656
+ }
657
+ childAfter(e) {
658
+ let { index: t, offset: n } = this.content.findIndex(e);
659
+ return {
660
+ node: this.content.maybeChild(t),
661
+ index: t,
662
+ offset: n
663
+ };
664
+ }
665
+ childBefore(e) {
666
+ if (e == 0) return {
667
+ node: null,
668
+ index: 0,
669
+ offset: 0
670
+ };
671
+ let { index: t, offset: n } = this.content.findIndex(e);
672
+ if (n < e) return {
673
+ node: this.content.child(t),
674
+ index: t,
675
+ offset: n
676
+ };
677
+ let r = this.content.child(t - 1);
678
+ return {
679
+ node: r,
680
+ index: t - 1,
681
+ offset: n - r.nodeSize
682
+ };
683
+ }
684
+ resolve(e) {
685
+ return re.resolveCached(this, e);
686
+ }
687
+ resolveNoCache(e) {
688
+ return re.resolve(this, e);
689
+ }
690
+ rangeHasMark(e, t, n) {
691
+ let r = !1;
692
+ return t > e && this.nodesBetween(e, t, (e) => (n.isInSet(e.marks) && (r = !0), !r)), r;
693
+ }
694
+ get isBlock() {
695
+ return this.type.isBlock;
696
+ }
697
+ get isTextblock() {
698
+ return this.type.isTextblock;
699
+ }
700
+ get inlineContent() {
701
+ return this.type.inlineContent;
702
+ }
703
+ get isInline() {
704
+ return this.type.isInline;
705
+ }
706
+ get isText() {
707
+ return this.type.isText;
708
+ }
709
+ get isLeaf() {
710
+ return this.type.isLeaf;
711
+ }
712
+ get isAtom() {
713
+ return this.type.isAtom;
714
+ }
715
+ toString() {
716
+ if (this.type.spec.toDebugString) return this.type.spec.toDebugString(this);
717
+ let e = this.type.name;
718
+ return this.content.size && (e += "(" + this.content.toStringInner() + ")"), ue(this.marks, e);
719
+ }
720
+ contentMatchAt(e) {
721
+ let t = this.type.contentMatch.matchFragment(this.content, 0, e);
722
+ if (!t) throw Error("Called contentMatchAt on a node with invalid content");
723
+ return t;
724
+ }
725
+ canReplace(e, t, n = a.empty, r = 0, i = n.childCount) {
726
+ let o = this.contentMatchAt(e).matchFragment(n, r, i), s = o && o.matchFragment(this.content, t);
727
+ if (!s || !s.validEnd) return !1;
728
+ for (let e = r; e < i; e++) if (!this.type.allowsMarks(n.child(e).marks)) return !1;
729
+ return !0;
730
+ }
731
+ canReplaceWith(e, t, n, r) {
732
+ if (r && !this.type.allowsMarks(r)) return !1;
733
+ let i = this.contentMatchAt(e).matchType(n), a = i && i.matchFragment(this.content, t);
734
+ return a ? a.validEnd : !1;
735
+ }
736
+ canAppend(e) {
737
+ return e.content.size ? this.canReplace(this.childCount, this.childCount, e.content) : this.type.compatibleContent(e.type);
738
+ }
739
+ check() {
740
+ this.type.checkContent(this.content), this.type.checkAttrs(this.attrs);
741
+ let e = l.none;
742
+ for (let t = 0; t < this.marks.length; t++) {
743
+ let n = this.marks[t];
744
+ n.type.checkAttrs(n.attrs), e = n.addToSet(e);
745
+ }
746
+ if (!l.sameSet(e, this.marks)) throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e) => e.type.name)}`);
747
+ this.content.forEach((e) => e.check());
748
+ }
749
+ toJSON() {
750
+ let e = { type: this.type.name };
751
+ for (let t in this.attrs) {
752
+ e.attrs = this.attrs;
753
+ break;
754
+ }
755
+ return this.content.size && (e.content = this.content.toJSON()), this.marks.length && (e.marks = this.marks.map((e) => e.toJSON())), e;
756
+ }
757
+ static fromJSON(e, t) {
758
+ if (!t) throw RangeError("Invalid input for Node.fromJSON");
759
+ let n;
760
+ if (t.marks) {
761
+ if (!Array.isArray(t.marks)) throw RangeError("Invalid mark data for Node.fromJSON");
762
+ n = t.marks.map(e.markFromJSON);
763
+ }
764
+ if (t.type == "text") {
765
+ if (typeof t.text != "string") throw RangeError("Invalid text node in JSON");
766
+ return e.text(t.text, n);
767
+ }
768
+ let r = a.fromJSON(e, t.content), i = e.nodeType(t.type).create(t.attrs, r, n);
769
+ return i.type.checkAttrs(i.attrs), i;
770
+ }
771
+ };
772
+ x.prototype.text = void 0;
773
+ var le = class e extends x {
774
+ constructor(e, t, n, r) {
775
+ if (super(e, t, null, r), !n) throw RangeError("Empty text nodes are not allowed");
776
+ this.text = n;
777
+ }
778
+ toString() {
779
+ return this.type.spec.toDebugString ? this.type.spec.toDebugString(this) : ue(this.marks, JSON.stringify(this.text));
780
+ }
781
+ get textContent() {
782
+ return this.text;
783
+ }
784
+ textBetween(e, t) {
785
+ return this.text.slice(e, t);
786
+ }
787
+ get nodeSize() {
788
+ return this.text.length;
789
+ }
790
+ mark(t) {
791
+ return t == this.marks ? this : new e(this.type, this.attrs, this.text, t);
792
+ }
793
+ withText(t) {
794
+ return t == this.text ? this : new e(this.type, this.attrs, t, this.marks);
795
+ }
796
+ cut(e = 0, t = this.text.length) {
797
+ return e == 0 && t == this.text.length ? this : this.withText(this.text.slice(e, t));
798
+ }
799
+ eq(e) {
800
+ return this.sameMarkup(e) && this.text == e.text;
801
+ }
802
+ toJSON() {
803
+ let e = super.toJSON();
804
+ return e.text = this.text, e;
805
+ }
806
+ };
807
+ function ue(e, t) {
808
+ for (let n = e.length - 1; n >= 0; n--) t = e[n].type.name + "(" + t + ")";
809
+ return t;
810
+ }
811
+ var S = class e {
812
+ constructor(e) {
813
+ this.validEnd = e, this.next = [], this.wrapCache = [];
814
+ }
815
+ static parse(t, n) {
816
+ let r = new de(t, n);
817
+ if (r.next == null) return e.empty;
818
+ let i = fe(r);
819
+ r.next && r.err("Unexpected trailing text");
820
+ let a = Se(ye(i));
821
+ return Ce(a, r), a;
822
+ }
823
+ matchType(e) {
824
+ for (let t = 0; t < this.next.length; t++) if (this.next[t].type == e) return this.next[t].next;
825
+ return null;
826
+ }
827
+ matchFragment(e, t = 0, n = e.childCount) {
828
+ let r = this;
829
+ for (let i = t; r && i < n; i++) r = r.matchType(e.child(i).type);
830
+ return r;
831
+ }
832
+ get inlineContent() {
833
+ return this.next.length != 0 && this.next[0].type.isInline;
834
+ }
835
+ get defaultType() {
836
+ for (let e = 0; e < this.next.length; e++) {
837
+ let { type: t } = this.next[e];
838
+ if (!(t.isText || t.hasRequiredAttrs())) return t;
839
+ }
840
+ return null;
841
+ }
842
+ compatible(e) {
843
+ for (let t = 0; t < this.next.length; t++) for (let n = 0; n < e.next.length; n++) if (this.next[t].type == e.next[n].type) return !0;
844
+ return !1;
845
+ }
846
+ fillBefore(e, t = !1, n = 0) {
847
+ let r = [this];
848
+ function i(o, s) {
849
+ let c = o.matchFragment(e, n);
850
+ if (c && (!t || c.validEnd)) return a.from(s.map((e) => e.createAndFill()));
851
+ for (let e = 0; e < o.next.length; e++) {
852
+ let { type: t, next: n } = o.next[e];
853
+ if (!(t.isText || t.hasRequiredAttrs()) && r.indexOf(n) == -1) {
854
+ r.push(n);
855
+ let e = i(n, s.concat(t));
856
+ if (e) return e;
857
+ }
858
+ }
859
+ return null;
860
+ }
861
+ return i(this, []);
862
+ }
863
+ findWrapping(e) {
864
+ for (let t = 0; t < this.wrapCache.length; t += 2) if (this.wrapCache[t] == e) return this.wrapCache[t + 1];
865
+ let t = this.computeWrapping(e);
866
+ return this.wrapCache.push(e, t), t;
867
+ }
868
+ computeWrapping(e) {
869
+ let t = Object.create(null), n = [{
870
+ match: this,
871
+ type: null,
872
+ via: null
873
+ }];
874
+ for (; n.length;) {
875
+ let r = n.shift(), i = r.match;
876
+ if (i.matchType(e)) {
877
+ let e = [];
878
+ for (let t = r; t.type; t = t.via) e.push(t.type);
879
+ return e.reverse();
880
+ }
881
+ for (let e = 0; e < i.next.length; e++) {
882
+ let { type: a, next: o } = i.next[e];
883
+ !a.isLeaf && !a.hasRequiredAttrs() && !(a.name in t) && (!r.type || o.validEnd) && (n.push({
884
+ match: a.contentMatch,
885
+ type: a,
886
+ via: r
887
+ }), t[a.name] = !0);
888
+ }
889
+ }
890
+ return null;
891
+ }
892
+ get edgeCount() {
893
+ return this.next.length;
894
+ }
895
+ edge(e) {
896
+ if (e >= this.next.length) throw RangeError(`There's no ${e}th edge in this content match`);
897
+ return this.next[e];
898
+ }
899
+ toString() {
900
+ let e = [];
901
+ function t(n) {
902
+ e.push(n);
903
+ for (let r = 0; r < n.next.length; r++) e.indexOf(n.next[r].next) == -1 && t(n.next[r].next);
904
+ }
905
+ return t(this), e.map((t, n) => {
906
+ let r = n + (t.validEnd ? "*" : " ") + " ";
907
+ for (let n = 0; n < t.next.length; n++) r += (n ? ", " : "") + t.next[n].type.name + "->" + e.indexOf(t.next[n].next);
908
+ return r;
909
+ }).join("\n");
910
+ }
911
+ };
912
+ S.empty = new S(!0);
913
+ var de = class {
914
+ constructor(e, t) {
915
+ this.string = e, this.nodeTypes = t, this.inline = null, this.pos = 0, this.tokens = e.split(/\s*(?=\b|\W|$)/), this.tokens[this.tokens.length - 1] == "" && this.tokens.pop(), this.tokens[0] == "" && this.tokens.shift();
916
+ }
917
+ get next() {
918
+ return this.tokens[this.pos];
919
+ }
920
+ eat(e) {
921
+ return this.next == e && (this.pos++ || !0);
922
+ }
923
+ err(e) {
924
+ throw SyntaxError(e + " (in content expression '" + this.string + "')");
925
+ }
926
+ };
927
+ function fe(e) {
928
+ let t = [];
929
+ do
930
+ t.push(pe(e));
931
+ while (e.eat("|"));
932
+ return t.length == 1 ? t[0] : {
933
+ type: "choice",
934
+ exprs: t
935
+ };
936
+ }
937
+ function pe(e) {
938
+ let t = [];
939
+ do
940
+ t.push(me(e));
941
+ while (e.next && e.next != ")" && e.next != "|");
942
+ return t.length == 1 ? t[0] : {
943
+ type: "seq",
944
+ exprs: t
945
+ };
946
+ }
947
+ function me(e) {
948
+ let t = ve(e);
949
+ for (;;) if (e.eat("+")) t = {
950
+ type: "plus",
951
+ expr: t
952
+ };
953
+ else if (e.eat("*")) t = {
954
+ type: "star",
955
+ expr: t
956
+ };
957
+ else if (e.eat("?")) t = {
958
+ type: "opt",
959
+ expr: t
960
+ };
961
+ else if (e.eat("{")) t = ge(e, t);
962
+ else break;
963
+ return t;
964
+ }
965
+ function he(e) {
966
+ /\D/.test(e.next) && e.err("Expected number, got '" + e.next + "'");
967
+ let t = Number(e.next);
968
+ return e.pos++, t;
969
+ }
970
+ function ge(e, t) {
971
+ let n = he(e), r = n;
972
+ return e.eat(",") && (r = e.next == "}" ? -1 : he(e)), e.eat("}") || e.err("Unclosed braced range"), {
973
+ type: "range",
974
+ min: n,
975
+ max: r,
976
+ expr: t
977
+ };
978
+ }
979
+ function _e(e, t) {
980
+ let n = e.nodeTypes, r = n[t];
981
+ if (r) return [r];
982
+ let i = [];
983
+ for (let e in n) {
984
+ let r = n[e];
985
+ r.isInGroup(t) && i.push(r);
986
+ }
987
+ return i.length == 0 && e.err("No node type or group '" + t + "' found"), i;
988
+ }
989
+ function ve(e) {
990
+ if (e.eat("(")) {
991
+ let t = fe(e);
992
+ return e.eat(")") || e.err("Missing closing paren"), t;
993
+ } else if (/\W/.test(e.next)) e.err("Unexpected token '" + e.next + "'");
994
+ else {
995
+ let t = _e(e, e.next).map((t) => (e.inline == null ? e.inline = t.isInline : e.inline != t.isInline && e.err("Mixing inline and block content"), {
996
+ type: "name",
997
+ value: t
998
+ }));
999
+ return e.pos++, t.length == 1 ? t[0] : {
1000
+ type: "choice",
1001
+ exprs: t
1002
+ };
1003
+ }
1004
+ }
1005
+ function ye(e) {
1006
+ let t = [[]];
1007
+ return i(a(e, 0), n()), t;
1008
+ function n() {
1009
+ return t.push([]) - 1;
1010
+ }
1011
+ function r(e, n, r) {
1012
+ let i = {
1013
+ term: r,
1014
+ to: n
1015
+ };
1016
+ return t[e].push(i), i;
1017
+ }
1018
+ function i(e, t) {
1019
+ e.forEach((e) => e.to = t);
1020
+ }
1021
+ function a(e, t) {
1022
+ if (e.type == "choice") return e.exprs.reduce((e, n) => e.concat(a(n, t)), []);
1023
+ if (e.type == "seq") for (let r = 0;; r++) {
1024
+ let o = a(e.exprs[r], t);
1025
+ if (r == e.exprs.length - 1) return o;
1026
+ i(o, t = n());
1027
+ }
1028
+ else if (e.type == "star") {
1029
+ let o = n();
1030
+ return r(t, o), i(a(e.expr, o), o), [r(o)];
1031
+ } else if (e.type == "plus") {
1032
+ let o = n();
1033
+ return i(a(e.expr, t), o), i(a(e.expr, o), o), [r(o)];
1034
+ } else if (e.type == "opt") return [r(t)].concat(a(e.expr, t));
1035
+ else if (e.type == "range") {
1036
+ let o = t;
1037
+ for (let t = 0; t < e.min; t++) {
1038
+ let t = n();
1039
+ i(a(e.expr, o), t), o = t;
1040
+ }
1041
+ if (e.max == -1) i(a(e.expr, o), o);
1042
+ else for (let t = e.min; t < e.max; t++) {
1043
+ let t = n();
1044
+ r(o, t), i(a(e.expr, o), t), o = t;
1045
+ }
1046
+ return [r(o)];
1047
+ } else if (e.type == "name") return [r(t, void 0, e.value)];
1048
+ else throw Error("Unknown expr type");
1049
+ }
1050
+ }
1051
+ function be(e, t) {
1052
+ return t - e;
1053
+ }
1054
+ function xe(e, t) {
1055
+ let n = [];
1056
+ return r(t), n.sort(be);
1057
+ function r(t) {
1058
+ let i = e[t];
1059
+ if (i.length == 1 && !i[0].term) return r(i[0].to);
1060
+ n.push(t);
1061
+ for (let e = 0; e < i.length; e++) {
1062
+ let { term: t, to: a } = i[e];
1063
+ !t && n.indexOf(a) == -1 && r(a);
1064
+ }
1065
+ }
1066
+ }
1067
+ function Se(e) {
1068
+ let t = Object.create(null);
1069
+ return n(xe(e, 0));
1070
+ function n(r) {
1071
+ let i = [];
1072
+ r.forEach((t) => {
1073
+ e[t].forEach(({ term: t, to: n }) => {
1074
+ if (!t) return;
1075
+ let r;
1076
+ for (let e = 0; e < i.length; e++) i[e][0] == t && (r = i[e][1]);
1077
+ xe(e, n).forEach((e) => {
1078
+ r || i.push([t, r = []]), r.indexOf(e) == -1 && r.push(e);
1079
+ });
1080
+ });
1081
+ });
1082
+ let a = t[r.join(",")] = new S(r.indexOf(e.length - 1) > -1);
1083
+ for (let e = 0; e < i.length; e++) {
1084
+ let r = i[e][1].sort(be);
1085
+ a.next.push({
1086
+ type: i[e][0],
1087
+ next: t[r.join(",")] || n(r)
1088
+ });
1089
+ }
1090
+ return a;
1091
+ }
1092
+ }
1093
+ function Ce(e, t) {
1094
+ for (let n = 0, r = [e]; n < r.length; n++) {
1095
+ let e = r[n], i = !e.validEnd, a = [];
1096
+ for (let t = 0; t < e.next.length; t++) {
1097
+ let { type: n, next: o } = e.next[t];
1098
+ a.push(n.name), i && !(n.isText || n.hasRequiredAttrs()) && (i = !1), r.indexOf(o) == -1 && r.push(o);
1099
+ }
1100
+ i && t.err("Only non-generatable nodes (" + a.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)");
1101
+ }
1102
+ }
1103
+ function we(e) {
1104
+ let t = Object.create(null);
1105
+ for (let n in e) {
1106
+ let r = e[n];
1107
+ if (!r.hasDefault) return null;
1108
+ t[n] = r.default;
1109
+ }
1110
+ return t;
1111
+ }
1112
+ function Te(e, t) {
1113
+ let n = Object.create(null);
1114
+ for (let r in e) {
1115
+ let i = t && t[r];
1116
+ if (i === void 0) {
1117
+ let t = e[r];
1118
+ if (t.hasDefault) i = t.default;
1119
+ else throw RangeError("No value supplied for attribute " + r);
1120
+ }
1121
+ n[r] = i;
1122
+ }
1123
+ return n;
1124
+ }
1125
+ function Ee(e, t, n, r) {
1126
+ for (let i in t) if (!(i in e)) throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);
1127
+ for (let n in e) e[n].validate && e[n].validate(t[n]);
1128
+ }
1129
+ function De(e, t) {
1130
+ let n = Object.create(null);
1131
+ if (t) for (let r in t) n[r] = new Ae(e, r, t[r]);
1132
+ return n;
1133
+ }
1134
+ var Oe = class e {
1135
+ constructor(e, t, n) {
1136
+ this.name = e, this.schema = t, this.spec = n, this.markSet = null, this.groups = n.group ? n.group.split(" ") : [], this.attrs = De(e, n.attrs), this.defaultAttrs = we(this.attrs), this.contentMatch = null, this.inlineContent = null, this.isBlock = !(n.inline || e == "text"), this.isText = e == "text";
1137
+ }
1138
+ get isInline() {
1139
+ return !this.isBlock;
1140
+ }
1141
+ get isTextblock() {
1142
+ return this.isBlock && this.inlineContent;
1143
+ }
1144
+ get isLeaf() {
1145
+ return this.contentMatch == S.empty;
1146
+ }
1147
+ get isAtom() {
1148
+ return this.isLeaf || !!this.spec.atom;
1149
+ }
1150
+ isInGroup(e) {
1151
+ return this.groups.indexOf(e) > -1;
1152
+ }
1153
+ get whitespace() {
1154
+ return this.spec.whitespace || (this.spec.code ? "pre" : "normal");
1155
+ }
1156
+ hasRequiredAttrs() {
1157
+ for (let e in this.attrs) if (this.attrs[e].isRequired) return !0;
1158
+ return !1;
1159
+ }
1160
+ compatibleContent(e) {
1161
+ return this == e || this.contentMatch.compatible(e.contentMatch);
1162
+ }
1163
+ computeAttrs(e) {
1164
+ return !e && this.defaultAttrs ? this.defaultAttrs : Te(this.attrs, e);
1165
+ }
1166
+ create(e = null, t, n) {
1167
+ if (this.isText) throw Error("NodeType.create can't construct text nodes");
1168
+ return new x(this, this.computeAttrs(e), a.from(t), l.setFrom(n));
1169
+ }
1170
+ createChecked(e = null, t, n) {
1171
+ return t = a.from(t), this.checkContent(t), new x(this, this.computeAttrs(e), t, l.setFrom(n));
1172
+ }
1173
+ createAndFill(e = null, t, n) {
1174
+ if (e = this.computeAttrs(e), t = a.from(t), t.size) {
1175
+ let e = this.contentMatch.fillBefore(t);
1176
+ if (!e) return null;
1177
+ t = e.append(t);
1178
+ }
1179
+ let r = this.contentMatch.matchFragment(t), i = r && r.fillBefore(a.empty, !0);
1180
+ return i ? new x(this, e, t.append(i), l.setFrom(n)) : null;
1181
+ }
1182
+ validContent(e) {
1183
+ let t = this.contentMatch.matchFragment(e);
1184
+ if (!t || !t.validEnd) return !1;
1185
+ for (let t = 0; t < e.childCount; t++) if (!this.allowsMarks(e.child(t).marks)) return !1;
1186
+ return !0;
1187
+ }
1188
+ checkContent(e) {
1189
+ if (!this.validContent(e)) throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0, 50)}`);
1190
+ }
1191
+ checkAttrs(e) {
1192
+ Ee(this.attrs, e, "node", this.name);
1193
+ }
1194
+ allowsMarkType(e) {
1195
+ return this.markSet == null || this.markSet.indexOf(e) > -1;
1196
+ }
1197
+ allowsMarks(e) {
1198
+ if (this.markSet == null) return !0;
1199
+ for (let t = 0; t < e.length; t++) if (!this.allowsMarkType(e[t].type)) return !1;
1200
+ return !0;
1201
+ }
1202
+ allowedMarks(e) {
1203
+ if (this.markSet == null) return e;
1204
+ let t;
1205
+ for (let n = 0; n < e.length; n++) this.allowsMarkType(e[n].type) ? t && t.push(e[n]) : t ||= e.slice(0, n);
1206
+ return t ? t.length ? t : l.none : e;
1207
+ }
1208
+ static compile(t, n) {
1209
+ let r = Object.create(null);
1210
+ t.forEach((t, i) => r[t] = new e(t, n, i));
1211
+ let i = n.spec.topNode || "doc";
1212
+ if (!r[i]) throw RangeError("Schema is missing its top node type ('" + i + "')");
1213
+ if (!r.text) throw RangeError("Every schema needs a 'text' type");
1214
+ for (let e in r.text.attrs) throw RangeError("The text node type should not have attributes");
1215
+ return r;
1216
+ }
1217
+ };
1218
+ function ke(e, t, n) {
1219
+ let r = n.split("|");
1220
+ return (n) => {
1221
+ let i = n === null ? "null" : typeof n;
1222
+ if (r.indexOf(i) < 0) throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`);
1223
+ };
1224
+ }
1225
+ var Ae = class {
1226
+ constructor(e, t, n) {
1227
+ this.hasDefault = Object.prototype.hasOwnProperty.call(n, "default"), this.default = n.default, this.validate = typeof n.validate == "string" ? ke(e, t, n.validate) : n.validate;
1228
+ }
1229
+ get isRequired() {
1230
+ return !this.hasDefault;
1231
+ }
1232
+ }, je = class e {
1233
+ constructor(e, t, n, r) {
1234
+ this.name = e, this.rank = t, this.schema = n, this.spec = r, this.attrs = De(e, r.attrs), this.excluded = null;
1235
+ let i = we(this.attrs);
1236
+ this.instance = i ? new l(this, i) : null;
1237
+ }
1238
+ create(e = null) {
1239
+ return !e && this.instance ? this.instance : new l(this, Te(this.attrs, e));
1240
+ }
1241
+ static compile(t, n) {
1242
+ let r = Object.create(null), i = 0;
1243
+ return t.forEach((t, a) => r[t] = new e(t, i++, n, a)), r;
1244
+ }
1245
+ removeFromSet(e) {
1246
+ for (var t = 0; t < e.length; t++) e[t].type == this && (e = e.slice(0, t).concat(e.slice(t + 1)), t--);
1247
+ return e;
1248
+ }
1249
+ isInSet(e) {
1250
+ for (let t = 0; t < e.length; t++) if (e[t].type == this) return e[t];
1251
+ }
1252
+ checkAttrs(e) {
1253
+ Ee(this.attrs, e, "mark", this.name);
1254
+ }
1255
+ excludes(e) {
1256
+ return this.excluded.indexOf(e) > -1;
1257
+ }
1258
+ }, Me = class {
1259
+ constructor(t) {
1260
+ this.linebreakReplacement = null, this.cached = Object.create(null);
1261
+ let n = this.spec = {};
1262
+ for (let e in t) n[e] = t[e];
1263
+ n.nodes = e.from(t.nodes), n.marks = e.from(t.marks || {}), this.nodes = Oe.compile(this.spec.nodes, this), this.marks = je.compile(this.spec.marks, this);
1264
+ let r = Object.create(null);
1265
+ for (let e in this.nodes) {
1266
+ if (e in this.marks) throw RangeError(e + " can not be both a node and a mark");
1267
+ let t = this.nodes[e], n = t.spec.content || "", i = t.spec.marks;
1268
+ if (t.contentMatch = r[n] || (r[n] = S.parse(n, this.nodes)), t.inlineContent = t.contentMatch.inlineContent, t.spec.linebreakReplacement) {
1269
+ if (this.linebreakReplacement) throw RangeError("Multiple linebreak nodes defined");
1270
+ if (!t.isInline || !t.isLeaf) throw RangeError("Linebreak replacement nodes must be inline leaf nodes");
1271
+ this.linebreakReplacement = t;
1272
+ }
1273
+ t.markSet = i == "_" ? null : i ? Ne(this, i.split(" ")) : i == "" || !t.inlineContent ? [] : null;
1274
+ }
1275
+ for (let e in this.marks) {
1276
+ let t = this.marks[e], n = t.spec.excludes;
1277
+ t.excluded = n == null ? [t] : n == "" ? [] : Ne(this, n.split(" "));
1278
+ }
1279
+ this.nodeFromJSON = (e) => x.fromJSON(this, e), this.markFromJSON = (e) => l.fromJSON(this, e), this.topNodeType = this.nodes[this.spec.topNode || "doc"], this.cached.wrappings = Object.create(null);
1280
+ }
1281
+ node(e, t = null, n, r) {
1282
+ if (typeof e == "string") e = this.nodeType(e);
1283
+ else if (!(e instanceof Oe)) throw RangeError("Invalid node type: " + e);
1284
+ else if (e.schema != this) throw RangeError("Node type from different schema used (" + e.name + ")");
1285
+ return e.createChecked(t, n, r);
1286
+ }
1287
+ text(e, t) {
1288
+ let n = this.nodes.text;
1289
+ return new le(n, n.defaultAttrs, e, l.setFrom(t));
1290
+ }
1291
+ mark(e, t) {
1292
+ return typeof e == "string" && (e = this.marks[e]), e.create(t);
1293
+ }
1294
+ nodeType(e) {
1295
+ let t = this.nodes[e];
1296
+ if (!t) throw RangeError("Unknown node type: " + e);
1297
+ return t;
1298
+ }
1299
+ };
1300
+ function Ne(e, t) {
1301
+ let n = [];
1302
+ for (let r = 0; r < t.length; r++) {
1303
+ let i = t[r], a = e.marks[i], o = a;
1304
+ if (a) n.push(a);
1305
+ else for (let t in e.marks) {
1306
+ let r = e.marks[t];
1307
+ (i == "_" || r.spec.group && r.spec.group.split(" ").indexOf(i) > -1) && n.push(o = r);
1308
+ }
1309
+ if (!o) throw SyntaxError("Unknown mark type: '" + t[r] + "'");
1310
+ }
1311
+ return n;
1312
+ }
1313
+ function Pe(e) {
1314
+ return e.tag != null;
1315
+ }
1316
+ function Fe(e) {
1317
+ return e.style != null;
1318
+ }
1319
+ var Ie = class e {
1320
+ constructor(e, t) {
1321
+ this.schema = e, this.rules = t, this.tags = [], this.styles = [];
1322
+ let n = this.matchedStyles = [];
1323
+ t.forEach((e) => {
1324
+ if (Pe(e)) this.tags.push(e);
1325
+ else if (Fe(e)) {
1326
+ let t = /[^=]*/.exec(e.style)[0];
1327
+ n.indexOf(t) < 0 && n.push(t), this.styles.push(e);
1328
+ }
1329
+ }), this.normalizeLists = !this.tags.some((t) => {
1330
+ if (!/^(ul|ol)\b/.test(t.tag) || !t.node) return !1;
1331
+ let n = e.nodes[t.node];
1332
+ return n.contentMatch.matchType(n);
1333
+ });
1334
+ }
1335
+ parse(e, t = {}) {
1336
+ let n = new He(this, t, !1);
1337
+ return n.addAll(e, l.none, t.from, t.to), n.finish();
1338
+ }
1339
+ parseSlice(e, t = {}) {
1340
+ let n = new He(this, t, !0);
1341
+ return n.addAll(e, l.none, t.from, t.to), d.maxOpen(n.finish());
1342
+ }
1343
+ matchTag(e, t, n) {
1344
+ for (let r = n ? this.tags.indexOf(n) + 1 : 0; r < this.tags.length; r++) {
1345
+ let n = this.tags[r];
1346
+ if (We(e, n.tag) && (n.namespace === void 0 || e.namespaceURI == n.namespace) && (!n.context || t.matchesContext(n.context))) {
1347
+ if (n.getAttrs) {
1348
+ let t = n.getAttrs(e);
1349
+ if (t === !1) continue;
1350
+ n.attrs = t || void 0;
1351
+ }
1352
+ return n;
1353
+ }
1354
+ }
1355
+ }
1356
+ matchStyle(e, t, n, r) {
1357
+ for (let i = r ? this.styles.indexOf(r) + 1 : 0; i < this.styles.length; i++) {
1358
+ let r = this.styles[i], a = r.style;
1359
+ if (!(a.indexOf(e) != 0 || r.context && !n.matchesContext(r.context) || a.length > e.length && (a.charCodeAt(e.length) != 61 || a.slice(e.length + 1) != t))) {
1360
+ if (r.getAttrs) {
1361
+ let e = r.getAttrs(t);
1362
+ if (e === !1) continue;
1363
+ r.attrs = e || void 0;
1364
+ }
1365
+ return r;
1366
+ }
1367
+ }
1368
+ }
1369
+ static schemaRules(e) {
1370
+ let t = [];
1371
+ function n(e) {
1372
+ let n = e.priority == null ? 50 : e.priority, r = 0;
1373
+ for (; r < t.length; r++) {
1374
+ let e = t[r];
1375
+ if ((e.priority == null ? 50 : e.priority) < n) break;
1376
+ }
1377
+ t.splice(r, 0, e);
1378
+ }
1379
+ for (let t in e.marks) {
1380
+ let r = e.marks[t].spec.parseDOM;
1381
+ r && r.forEach((e) => {
1382
+ n(e = Ge(e)), e.mark || e.ignore || e.clearMark || (e.mark = t);
1383
+ });
1384
+ }
1385
+ for (let t in e.nodes) {
1386
+ let r = e.nodes[t].spec.parseDOM;
1387
+ r && r.forEach((e) => {
1388
+ n(e = Ge(e)), e.node || e.ignore || e.mark || (e.node = t);
1389
+ });
1390
+ }
1391
+ return t;
1392
+ }
1393
+ static fromSchema(t) {
1394
+ return t.cached.domParser || (t.cached.domParser = new e(t, e.schemaRules(t)));
1395
+ }
1396
+ }, Le = {
1397
+ address: !0,
1398
+ article: !0,
1399
+ aside: !0,
1400
+ blockquote: !0,
1401
+ body: !0,
1402
+ canvas: !0,
1403
+ dd: !0,
1404
+ div: !0,
1405
+ dl: !0,
1406
+ fieldset: !0,
1407
+ figcaption: !0,
1408
+ figure: !0,
1409
+ footer: !0,
1410
+ form: !0,
1411
+ h1: !0,
1412
+ h2: !0,
1413
+ h3: !0,
1414
+ h4: !0,
1415
+ h5: !0,
1416
+ h6: !0,
1417
+ header: !0,
1418
+ hgroup: !0,
1419
+ hr: !0,
1420
+ li: !0,
1421
+ noscript: !0,
1422
+ ol: !0,
1423
+ output: !0,
1424
+ p: !0,
1425
+ pre: !0,
1426
+ section: !0,
1427
+ table: !0,
1428
+ tfoot: !0,
1429
+ ul: !0
1430
+ }, Re = {
1431
+ head: !0,
1432
+ noscript: !0,
1433
+ object: !0,
1434
+ script: !0,
1435
+ style: !0,
1436
+ title: !0
1437
+ }, ze = {
1438
+ ol: !0,
1439
+ ul: !0
1440
+ }, C = 1, Be = 2, w = 4;
1441
+ function Ve(e, t, n) {
1442
+ return t == null ? e && e.whitespace == "pre" ? 3 : n & -5 : (t ? C : 0) | (t === "full" ? Be : 0);
1443
+ }
1444
+ var T = class {
1445
+ constructor(e, t, n, r, i, a) {
1446
+ this.type = e, this.attrs = t, this.marks = n, this.solid = r, this.options = a, this.content = [], this.activeMarks = l.none, this.match = i || (a & w ? null : e.contentMatch);
1447
+ }
1448
+ findWrapping(e) {
1449
+ if (!this.match) {
1450
+ if (!this.type) return [];
1451
+ let t = this.type.contentMatch.fillBefore(a.from(e));
1452
+ if (t) this.match = this.type.contentMatch.matchFragment(t);
1453
+ else {
1454
+ let t = this.type.contentMatch, n;
1455
+ return (n = t.findWrapping(e.type)) ? (this.match = t, n) : null;
1456
+ }
1457
+ }
1458
+ return this.match.findWrapping(e.type);
1459
+ }
1460
+ finish(e) {
1461
+ if (!(this.options & C)) {
1462
+ let e = this.content[this.content.length - 1], t;
1463
+ if (e && e.isText && (t = /[ \t\r\n\u000c]+$/.exec(e.text))) {
1464
+ let n = e;
1465
+ e.text.length == t[0].length ? this.content.pop() : this.content[this.content.length - 1] = n.withText(n.text.slice(0, n.text.length - t[0].length));
1466
+ }
1467
+ }
1468
+ let t = a.from(this.content);
1469
+ return !e && this.match && (t = t.append(this.match.fillBefore(a.empty, !0))), this.type ? this.type.create(this.attrs, t, this.marks) : t;
1470
+ }
1471
+ inlineContext(e) {
1472
+ return this.type ? this.type.inlineContent : this.content.length ? this.content[0].isInline : e.parentNode && !Le.hasOwnProperty(e.parentNode.nodeName.toLowerCase());
1473
+ }
1474
+ }, He = class {
1475
+ constructor(e, t, n) {
1476
+ this.parser = e, this.options = t, this.isOpen = n, this.open = 0, this.localPreserveWS = !1;
1477
+ let r = t.topNode, i, a = Ve(null, t.preserveWhitespace, 0) | (n ? w : 0);
1478
+ i = r ? new T(r.type, r.attrs, l.none, !0, t.topMatch || r.type.contentMatch, a) : n ? new T(null, null, l.none, !0, null, a) : new T(e.schema.topNodeType, null, l.none, !0, null, a), this.nodes = [i], this.find = t.findPositions, this.needsBlock = !1;
1479
+ }
1480
+ get top() {
1481
+ return this.nodes[this.open];
1482
+ }
1483
+ addDOM(e, t) {
1484
+ e.nodeType == 3 ? this.addTextNode(e, t) : e.nodeType == 1 && this.addElement(e, t);
1485
+ }
1486
+ addTextNode(e, t) {
1487
+ let n = e.nodeValue, r = this.top, i = r.options & Be ? "full" : this.localPreserveWS || (r.options & C) > 0, { schema: a } = this.parser;
1488
+ if (i === "full" || r.inlineContext(e) || /[^ \t\r\n\u000c]/.test(n)) {
1489
+ if (!i) {
1490
+ if (n = n.replace(/[ \t\r\n\u000c]+/g, " "), /^[ \t\r\n\u000c]/.test(n) && this.open == this.nodes.length - 1) {
1491
+ let t = r.content[r.content.length - 1], i = e.previousSibling;
1492
+ (!t || i && i.nodeName == "BR" || t.isText && /[ \t\r\n\u000c]$/.test(t.text)) && (n = n.slice(1));
1493
+ }
1494
+ } else if (i === "full") n = n.replace(/\r\n?/g, "\n");
1495
+ else if (a.linebreakReplacement && /[\r\n]/.test(n) && this.top.findWrapping(a.linebreakReplacement.create())) {
1496
+ let e = n.split(/\r?\n|\r/);
1497
+ for (let n = 0; n < e.length; n++) n && this.insertNode(a.linebreakReplacement.create(), t, !0), e[n] && this.insertNode(a.text(e[n]), t, !/\S/.test(e[n]));
1498
+ n = "";
1499
+ } else n = n.replace(/\r?\n|\r/g, " ");
1500
+ n && this.insertNode(a.text(n), t, !/\S/.test(n)), this.findInText(e);
1501
+ } else this.findInside(e);
1502
+ }
1503
+ addElement(e, t, n) {
1504
+ let r = this.localPreserveWS, i = this.top;
1505
+ (e.tagName == "PRE" || /pre/.test(e.style && e.style.whiteSpace)) && (this.localPreserveWS = !0);
1506
+ let a = e.nodeName.toLowerCase(), o;
1507
+ ze.hasOwnProperty(a) && this.parser.normalizeLists && Ue(e);
1508
+ let s = this.options.ruleFromNode && this.options.ruleFromNode(e) || (o = this.parser.matchTag(e, this, n));
1509
+ out: if (s ? s.ignore : Re.hasOwnProperty(a)) this.findInside(e), this.ignoreFallback(e, t);
1510
+ else if (!s || s.skip || s.closeParent) {
1511
+ s && s.closeParent ? this.open = Math.max(0, this.open - 1) : s && s.skip.nodeType && (e = s.skip);
1512
+ let n, r = this.needsBlock;
1513
+ if (Le.hasOwnProperty(a)) i.content.length && i.content[0].isInline && this.open && (this.open--, i = this.top), n = !0, i.type || (this.needsBlock = !0);
1514
+ else if (!e.firstChild) {
1515
+ this.leafFallback(e, t);
1516
+ break out;
1517
+ }
1518
+ let o = s && s.skip ? t : this.readStyles(e, t);
1519
+ o && this.addAll(e, o), n && this.sync(i), this.needsBlock = r;
1520
+ } else {
1521
+ let n = this.readStyles(e, t);
1522
+ n && this.addElementByRule(e, s, n, s.consuming === !1 ? o : void 0);
1523
+ }
1524
+ this.localPreserveWS = r;
1525
+ }
1526
+ leafFallback(e, t) {
1527
+ e.nodeName == "BR" && this.top.type && this.top.type.inlineContent && this.addTextNode(e.ownerDocument.createTextNode("\n"), t);
1528
+ }
1529
+ ignoreFallback(e, t) {
1530
+ e.nodeName == "BR" && (!this.top.type || !this.top.type.inlineContent) && this.findPlace(this.parser.schema.text("-"), t, !0);
1531
+ }
1532
+ readStyles(e, t) {
1533
+ let n = e.style;
1534
+ if (n && n.length) for (let e = 0; e < this.parser.matchedStyles.length; e++) {
1535
+ let r = this.parser.matchedStyles[e], i = n.getPropertyValue(r);
1536
+ if (i) for (let e;;) {
1537
+ let n = this.parser.matchStyle(r, i, this, e);
1538
+ if (!n) break;
1539
+ if (n.ignore) return null;
1540
+ if (t = n.clearMark ? t.filter((e) => !n.clearMark(e)) : t.concat(this.parser.schema.marks[n.mark].create(n.attrs)), n.consuming === !1) e = n;
1541
+ else break;
1542
+ }
1543
+ }
1544
+ return t;
1545
+ }
1546
+ addElementByRule(e, t, n, r) {
1547
+ let i, a;
1548
+ if (t.node) if (a = this.parser.schema.nodes[t.node], a.isLeaf) this.insertNode(a.create(t.attrs), n, e.nodeName == "BR") || this.leafFallback(e, n);
1549
+ else {
1550
+ let e = this.enter(a, t.attrs || null, n, t.preserveWhitespace);
1551
+ e && (i = !0, n = e);
1552
+ }
1553
+ else {
1554
+ let e = this.parser.schema.marks[t.mark];
1555
+ n = n.concat(e.create(t.attrs));
1556
+ }
1557
+ let o = this.top;
1558
+ if (a && a.isLeaf) this.findInside(e);
1559
+ else if (r) this.addElement(e, n, r);
1560
+ else if (t.getContent) this.findInside(e), t.getContent(e, this.parser.schema).forEach((e) => this.insertNode(e, n, !1));
1561
+ else {
1562
+ let r = e;
1563
+ typeof t.contentElement == "string" ? r = e.querySelector(t.contentElement) : typeof t.contentElement == "function" ? r = t.contentElement(e) : t.contentElement && (r = t.contentElement), this.findAround(e, r, !0), this.addAll(r, n), this.findAround(e, r, !1);
1564
+ }
1565
+ i && this.sync(o) && this.open--;
1566
+ }
1567
+ addAll(e, t, n, r) {
1568
+ let i = n || 0;
1569
+ for (let a = n ? e.childNodes[n] : e.firstChild, o = r == null ? null : e.childNodes[r]; a != o; a = a.nextSibling, ++i) this.findAtPoint(e, i), this.addDOM(a, t);
1570
+ this.findAtPoint(e, i);
1571
+ }
1572
+ findPlace(e, t, n) {
1573
+ let r, i;
1574
+ for (let t = this.open, a = 0; t >= 0; t--) {
1575
+ let o = this.nodes[t], s = o.findWrapping(e);
1576
+ if (s && (!r || r.length > s.length + a) && (r = s, i = o, !s.length)) break;
1577
+ if (o.solid) {
1578
+ if (n) break;
1579
+ a += 2;
1580
+ }
1581
+ }
1582
+ if (!r) return null;
1583
+ this.sync(i);
1584
+ for (let e = 0; e < r.length; e++) t = this.enterInner(r[e], null, t, !1);
1585
+ return t;
1586
+ }
1587
+ insertNode(e, t, n) {
1588
+ if (e.isInline && this.needsBlock && !this.top.type) {
1589
+ let e = this.textblockFromContext();
1590
+ e && (t = this.enterInner(e, null, t));
1591
+ }
1592
+ let r = this.findPlace(e, t, n);
1593
+ if (r) {
1594
+ this.closeExtra();
1595
+ let t = this.top;
1596
+ t.match &&= t.match.matchType(e.type);
1597
+ let n = l.none;
1598
+ for (let i of r.concat(e.marks)) (t.type ? t.type.allowsMarkType(i.type) : Ke(i.type, e.type)) && (n = i.addToSet(n));
1599
+ return t.content.push(e.mark(n)), !0;
1600
+ }
1601
+ return !1;
1602
+ }
1603
+ enter(e, t, n, r) {
1604
+ let i = this.findPlace(e.create(t), n, !1);
1605
+ return i &&= this.enterInner(e, t, n, !0, r), i;
1606
+ }
1607
+ enterInner(e, t, n, r = !1, i) {
1608
+ this.closeExtra();
1609
+ let a = this.top;
1610
+ a.match = a.match && a.match.matchType(e);
1611
+ let o = Ve(e, i, a.options);
1612
+ a.options & w && a.content.length == 0 && (o |= w);
1613
+ let s = l.none;
1614
+ return n = n.filter((t) => (a.type ? a.type.allowsMarkType(t.type) : Ke(t.type, e)) ? (s = t.addToSet(s), !1) : !0), this.nodes.push(new T(e, t, s, r, null, o)), this.open++, n;
1615
+ }
1616
+ closeExtra(e = !1) {
1617
+ let t = this.nodes.length - 1;
1618
+ if (t > this.open) {
1619
+ for (; t > this.open; t--) this.nodes[t - 1].content.push(this.nodes[t].finish(e));
1620
+ this.nodes.length = this.open + 1;
1621
+ }
1622
+ }
1623
+ finish() {
1624
+ return this.open = 0, this.closeExtra(this.isOpen), this.nodes[0].finish(!!(this.isOpen || this.options.topOpen));
1625
+ }
1626
+ sync(e) {
1627
+ for (let t = this.open; t >= 0; t--) if (this.nodes[t] == e) return this.open = t, !0;
1628
+ else this.localPreserveWS && (this.nodes[t].options |= C);
1629
+ return !1;
1630
+ }
1631
+ get currentPos() {
1632
+ this.closeExtra();
1633
+ let e = 0;
1634
+ for (let t = this.open; t >= 0; t--) {
1635
+ let n = this.nodes[t].content;
1636
+ for (let t = n.length - 1; t >= 0; t--) e += n[t].nodeSize;
1637
+ t && e++;
1638
+ }
1639
+ return e;
1640
+ }
1641
+ findAtPoint(e, t) {
1642
+ if (this.find) for (let n = 0; n < this.find.length; n++) this.find[n].node == e && this.find[n].offset == t && (this.find[n].pos = this.currentPos);
1643
+ }
1644
+ findInside(e) {
1645
+ if (this.find) for (let t = 0; t < this.find.length; t++) this.find[t].pos == null && e.nodeType == 1 && e.contains(this.find[t].node) && (this.find[t].pos = this.currentPos);
1646
+ }
1647
+ findAround(e, t, n) {
1648
+ if (e != t && this.find) for (let r = 0; r < this.find.length; r++) this.find[r].pos == null && e.nodeType == 1 && e.contains(this.find[r].node) && t.compareDocumentPosition(this.find[r].node) & (n ? 2 : 4) && (this.find[r].pos = this.currentPos);
1649
+ }
1650
+ findInText(e) {
1651
+ if (this.find) for (let t = 0; t < this.find.length; t++) this.find[t].node == e && (this.find[t].pos = this.currentPos - (e.nodeValue.length - this.find[t].offset));
1652
+ }
1653
+ matchesContext(e) {
1654
+ if (e.indexOf("|") > -1) return e.split(/\s*\|\s*/).some(this.matchesContext, this);
1655
+ let t = e.split("/"), n = this.options.context, r = !this.isOpen && (!n || n.parent.type == this.nodes[0].type), i = -(n ? n.depth + 1 : 0) + +!r, a = (e, o) => {
1656
+ for (; e >= 0; e--) {
1657
+ let s = t[e];
1658
+ if (s == "") {
1659
+ if (e == t.length - 1 || e == 0) continue;
1660
+ for (; o >= i; o--) if (a(e - 1, o)) return !0;
1661
+ return !1;
1662
+ } else {
1663
+ let e = o > 0 || o == 0 && r ? this.nodes[o].type : n && o >= i ? n.node(o - i).type : null;
1664
+ if (!e || e.name != s && !e.isInGroup(s)) return !1;
1665
+ o--;
1666
+ }
1667
+ }
1668
+ return !0;
1669
+ };
1670
+ return a(t.length - 1, this.open);
1671
+ }
1672
+ textblockFromContext() {
1673
+ let e = this.options.context;
1674
+ if (e) for (let t = e.depth; t >= 0; t--) {
1675
+ let n = e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;
1676
+ if (n && n.isTextblock && n.defaultAttrs) return n;
1677
+ }
1678
+ for (let e in this.parser.schema.nodes) {
1679
+ let t = this.parser.schema.nodes[e];
1680
+ if (t.isTextblock && t.defaultAttrs) return t;
1681
+ }
1682
+ }
1683
+ };
1684
+ function Ue(e) {
1685
+ for (let t = e.firstChild, n = null; t; t = t.nextSibling) {
1686
+ let e = t.nodeType == 1 ? t.nodeName.toLowerCase() : null;
1687
+ e && ze.hasOwnProperty(e) && n ? (n.appendChild(t), t = n) : e == "li" ? n = t : e && (n = null);
1688
+ }
1689
+ }
1690
+ function We(e, t) {
1691
+ return (e.matches || e.msMatchesSelector || e.webkitMatchesSelector || e.mozMatchesSelector).call(e, t);
1692
+ }
1693
+ function Ge(e) {
1694
+ let t = {};
1695
+ for (let n in e) t[n] = e[n];
1696
+ return t;
1697
+ }
1698
+ function Ke(e, t) {
1699
+ let n = t.schema.nodes;
1700
+ for (let r in n) {
1701
+ let i = n[r];
1702
+ if (!i.allowsMarkType(e)) continue;
1703
+ let a = [], o = (e) => {
1704
+ a.push(e);
1705
+ for (let n = 0; n < e.edgeCount; n++) {
1706
+ let { type: r, next: i } = e.edge(n);
1707
+ if (r == t || a.indexOf(i) < 0 && o(i)) return !0;
1708
+ }
1709
+ };
1710
+ if (o(i.contentMatch)) return !0;
1711
+ }
1712
+ }
1713
+ var qe = class e {
1714
+ constructor(e, t) {
1715
+ this.nodes = e, this.marks = t;
1716
+ }
1717
+ serializeFragment(e, t = {}, n) {
1718
+ n ||= E(t).createDocumentFragment();
1719
+ let r = n, i = [];
1720
+ return e.forEach((e) => {
1721
+ if (i.length || e.marks.length) {
1722
+ let n = 0, a = 0;
1723
+ for (; n < i.length && a < e.marks.length;) {
1724
+ let t = e.marks[a];
1725
+ if (!this.marks[t.type.name]) {
1726
+ a++;
1727
+ continue;
1728
+ }
1729
+ if (!t.eq(i[n][0]) || t.type.spec.spanning === !1) break;
1730
+ n++, a++;
1731
+ }
1732
+ for (; n < i.length;) r = i.pop()[1];
1733
+ for (; a < e.marks.length;) {
1734
+ let n = e.marks[a++], o = this.serializeMark(n, e.isInline, t);
1735
+ o && (i.push([n, r]), r.appendChild(o.dom), r = o.contentDOM || o.dom);
1736
+ }
1737
+ }
1738
+ r.appendChild(this.serializeNodeInner(e, t));
1739
+ }), n;
1740
+ }
1741
+ serializeNodeInner(e, t) {
1742
+ if (e.isText) return E(t).createTextNode(e.text);
1743
+ let { dom: n, contentDOM: r } = D(E(t), this.nodes[e.type.name](e), null, e.attrs);
1744
+ if (r) {
1745
+ if (e.isLeaf) throw RangeError("Content hole not allowed in a leaf node spec");
1746
+ this.serializeFragment(e.content, t, r);
1747
+ }
1748
+ return n;
1749
+ }
1750
+ serializeNode(e, t = {}) {
1751
+ let n = this.serializeNodeInner(e, t);
1752
+ for (let r = e.marks.length - 1; r >= 0; r--) {
1753
+ let i = this.serializeMark(e.marks[r], e.isInline, t);
1754
+ i && ((i.contentDOM || i.dom).appendChild(n), n = i.dom);
1755
+ }
1756
+ return n;
1757
+ }
1758
+ serializeMark(e, t, n = {}) {
1759
+ let r = this.marks[e.type.name];
1760
+ return r && D(E(n), r(e, t), null, e.attrs);
1761
+ }
1762
+ static renderSpec(e, t, n = null, r) {
1763
+ return typeof t == "string" ? { dom: e.createTextNode(t) } : D(e, t, n, r);
1764
+ }
1765
+ static fromSchema(t) {
1766
+ return t.cached.domSerializer || (t.cached.domSerializer = new e(this.nodesFromSchema(t), this.marksFromSchema(t)));
1767
+ }
1768
+ static nodesFromSchema(e) {
1769
+ let t = Je(e.nodes);
1770
+ return t.text ||= (e) => e.text, t;
1771
+ }
1772
+ static marksFromSchema(e) {
1773
+ return Je(e.marks);
1774
+ }
1775
+ };
1776
+ function Je(e) {
1777
+ let t = {};
1778
+ for (let n in e) {
1779
+ let r = e[n].spec.toDOM;
1780
+ r && (t[n] = r);
1781
+ }
1782
+ return t;
1783
+ }
1784
+ function E(e) {
1785
+ return e.document || window.document;
1786
+ }
1787
+ var Ye = /* @__PURE__ */ new WeakMap();
1788
+ function Xe(e) {
1789
+ let t = Ye.get(e);
1790
+ return t === void 0 && Ye.set(e, t = Ze(e)), t;
1791
+ }
1792
+ function Ze(e) {
1793
+ let t = null;
1794
+ function n(e) {
1795
+ if (e && typeof e == "object") if (Array.isArray(e)) if (typeof e[0] == "string") t ||= [], t.push(e);
1796
+ else for (let t = 0; t < e.length; t++) n(e[t]);
1797
+ else for (let t in e) n(e[t]);
1798
+ }
1799
+ return n(e), t;
1800
+ }
1801
+ function D(e, t, n, r) {
1802
+ if (t.nodeType == 1) return { dom: t };
1803
+ if (t.dom && t.dom.nodeType == 1) return t;
1804
+ let i = t[0], a;
1805
+ if (typeof i != "string") throw RangeError("Invalid array passed to renderSpec");
1806
+ if (r && (a = Xe(r)) && a.indexOf(t) > -1) throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");
1807
+ let o = i.indexOf(" ");
1808
+ o > 0 && (n = i.slice(0, o), i = i.slice(o + 1));
1809
+ let s, c = n ? e.createElementNS(n, i) : e.createElement(i), l = t[1], u = 1;
1810
+ if (l && typeof l == "object" && l.nodeType == null && !Array.isArray(l)) {
1811
+ u = 2;
1812
+ for (let e in l) if (l[e] != null) {
1813
+ let t = e.indexOf(" ");
1814
+ t > 0 ? c.setAttributeNS(e.slice(0, t), e.slice(t + 1), l[e]) : e == "style" && c.style ? c.style.cssText = l[e] : c.setAttribute(e, l[e]);
1815
+ }
1816
+ }
1817
+ for (let i = u; i < t.length; i++) {
1818
+ let a = t[i];
1819
+ if (a === 0) {
1820
+ if (i < t.length - 1 || i > u) throw RangeError("Content hole must be the only child of its parent node");
1821
+ return {
1822
+ dom: c,
1823
+ contentDOM: c
1824
+ };
1825
+ } else if (typeof a == "string") c.appendChild(e.createTextNode(a));
1826
+ else {
1827
+ let { dom: t, contentDOM: i } = D(e, a, n, r);
1828
+ if (c.appendChild(t), i) {
1829
+ if (s) throw RangeError("Multiple content holes");
1830
+ s = i;
1831
+ }
1832
+ }
1833
+ }
1834
+ return {
1835
+ dom: c,
1836
+ contentDOM: s
1837
+ };
1838
+ }
1839
+ //#endregion
1840
+ //#region node_modules/.pnpm/prosemirror-transform@1.12.0/node_modules/prosemirror-transform/dist/index.js
1841
+ var Qe = 65535, $e = 2 ** 16;
1842
+ function et(e, t) {
1843
+ return e + t * $e;
1844
+ }
1845
+ function tt(e) {
1846
+ return e & Qe;
1847
+ }
1848
+ function nt(e) {
1849
+ return (e - (e & Qe)) / $e;
1850
+ }
1851
+ var rt = 1, it = 2, at = 4, ot = 8, O = class {
1852
+ constructor(e, t, n) {
1853
+ this.pos = e, this.delInfo = t, this.recover = n;
1854
+ }
1855
+ get deleted() {
1856
+ return (this.delInfo & ot) > 0;
1857
+ }
1858
+ get deletedBefore() {
1859
+ return (this.delInfo & 5) > 0;
1860
+ }
1861
+ get deletedAfter() {
1862
+ return (this.delInfo & 6) > 0;
1863
+ }
1864
+ get deletedAcross() {
1865
+ return (this.delInfo & at) > 0;
1866
+ }
1867
+ }, k = class e {
1868
+ constructor(t, n = !1) {
1869
+ if (this.ranges = t, this.inverted = n, !t.length && e.empty) return e.empty;
1870
+ }
1871
+ recover(e) {
1872
+ let t = 0, n = tt(e);
1873
+ if (!this.inverted) for (let e = 0; e < n; e++) t += this.ranges[e * 3 + 2] - this.ranges[e * 3 + 1];
1874
+ return this.ranges[n * 3] + t + nt(e);
1875
+ }
1876
+ mapResult(e, t = 1) {
1877
+ return this._map(e, t, !1);
1878
+ }
1879
+ map(e, t = 1) {
1880
+ return this._map(e, t, !0);
1881
+ }
1882
+ _map(e, t, n) {
1883
+ let r = 0, i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2;
1884
+ for (let o = 0; o < this.ranges.length; o += 3) {
1885
+ let s = this.ranges[o] - (this.inverted ? r : 0);
1886
+ if (s > e) break;
1887
+ let c = this.ranges[o + i], l = this.ranges[o + a], u = s + c;
1888
+ if (e <= u) {
1889
+ let i = c ? e == s ? -1 : e == u ? 1 : t : t, a = s + r + (i < 0 ? 0 : l);
1890
+ if (n) return a;
1891
+ let d = e == (t < 0 ? s : u) ? null : et(o / 3, e - s), f = e == s ? it : e == u ? rt : at;
1892
+ return (t < 0 ? e != s : e != u) && (f |= ot), new O(a, f, d);
1893
+ }
1894
+ r += l - c;
1895
+ }
1896
+ return n ? e + r : new O(e + r, 0, null);
1897
+ }
1898
+ touches(e, t) {
1899
+ let n = 0, r = tt(t), i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2;
1900
+ for (let t = 0; t < this.ranges.length; t += 3) {
1901
+ let o = this.ranges[t] - (this.inverted ? n : 0);
1902
+ if (o > e) break;
1903
+ let s = this.ranges[t + i];
1904
+ if (e <= o + s && t == r * 3) return !0;
1905
+ n += this.ranges[t + a] - s;
1906
+ }
1907
+ return !1;
1908
+ }
1909
+ forEach(e) {
1910
+ let t = this.inverted ? 2 : 1, n = this.inverted ? 1 : 2;
1911
+ for (let r = 0, i = 0; r < this.ranges.length; r += 3) {
1912
+ let a = this.ranges[r], o = a - (this.inverted ? i : 0), s = a + (this.inverted ? 0 : i), c = this.ranges[r + t], l = this.ranges[r + n];
1913
+ e(o, o + c, s, s + l), i += l - c;
1914
+ }
1915
+ }
1916
+ invert() {
1917
+ return new e(this.ranges, !this.inverted);
1918
+ }
1919
+ toString() {
1920
+ return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
1921
+ }
1922
+ static offset(t) {
1923
+ return t == 0 ? e.empty : new e(t < 0 ? [
1924
+ 0,
1925
+ -t,
1926
+ 0
1927
+ ] : [
1928
+ 0,
1929
+ 0,
1930
+ t
1931
+ ]);
1932
+ }
1933
+ };
1934
+ k.empty = new k([]);
1935
+ var st = class e {
1936
+ constructor(e, t, n = 0, r = e ? e.length : 0) {
1937
+ this.mirror = t, this.from = n, this.to = r, this._maps = e || [], this.ownData = !(e || t);
1938
+ }
1939
+ get maps() {
1940
+ return this._maps;
1941
+ }
1942
+ slice(t = 0, n = this.maps.length) {
1943
+ return new e(this._maps, this.mirror, t, n);
1944
+ }
1945
+ appendMap(e, t) {
1946
+ this.ownData ||= (this._maps = this._maps.slice(), this.mirror = this.mirror && this.mirror.slice(), !0), this.to = this._maps.push(e), t != null && this.setMirror(this._maps.length - 1, t);
1947
+ }
1948
+ appendMapping(e) {
1949
+ for (let t = 0, n = this._maps.length; t < e._maps.length; t++) {
1950
+ let r = e.getMirror(t);
1951
+ this.appendMap(e._maps[t], r != null && r < t ? n + r : void 0);
1952
+ }
1953
+ }
1954
+ getMirror(e) {
1955
+ if (this.mirror) {
1956
+ for (let t = 0; t < this.mirror.length; t++) if (this.mirror[t] == e) return this.mirror[t + (t % 2 ? -1 : 1)];
1957
+ }
1958
+ }
1959
+ setMirror(e, t) {
1960
+ this.mirror ||= [], this.mirror.push(e, t);
1961
+ }
1962
+ appendMappingInverted(e) {
1963
+ for (let t = e.maps.length - 1, n = this._maps.length + e._maps.length; t >= 0; t--) {
1964
+ let r = e.getMirror(t);
1965
+ this.appendMap(e._maps[t].invert(), r != null && r > t ? n - r - 1 : void 0);
1966
+ }
1967
+ }
1968
+ invert() {
1969
+ let t = new e();
1970
+ return t.appendMappingInverted(this), t;
1971
+ }
1972
+ map(e, t = 1) {
1973
+ if (this.mirror) return this._map(e, t, !0);
1974
+ for (let n = this.from; n < this.to; n++) e = this._maps[n].map(e, t);
1975
+ return e;
1976
+ }
1977
+ mapResult(e, t = 1) {
1978
+ return this._map(e, t, !1);
1979
+ }
1980
+ _map(e, t, n) {
1981
+ let r = 0;
1982
+ for (let n = this.from; n < this.to; n++) {
1983
+ let i = this._maps[n].mapResult(e, t);
1984
+ if (i.recover != null) {
1985
+ let t = this.getMirror(n);
1986
+ if (t != null && t > n && t < this.to) {
1987
+ n = t, e = this._maps[t].recover(i.recover);
1988
+ continue;
1989
+ }
1990
+ }
1991
+ r |= i.delInfo, e = i.pos;
1992
+ }
1993
+ return n ? e : new O(e, r, null);
1994
+ }
1995
+ }, A = Object.create(null), j = class {
1996
+ getMap() {
1997
+ return k.empty;
1998
+ }
1999
+ merge(e) {
2000
+ return null;
2001
+ }
2002
+ static fromJSON(e, t) {
2003
+ if (!t || !t.stepType) throw RangeError("Invalid input for Step.fromJSON");
2004
+ let n = A[t.stepType];
2005
+ if (!n) throw RangeError(`No step type ${t.stepType} defined`);
2006
+ return n.fromJSON(e, t);
2007
+ }
2008
+ static jsonID(e, t) {
2009
+ if (e in A) throw RangeError("Duplicate use of step JSON ID " + e);
2010
+ return A[e] = t, t.prototype.jsonID = e, t;
2011
+ }
2012
+ }, M = class e {
2013
+ constructor(e, t) {
2014
+ this.doc = e, this.failed = t;
2015
+ }
2016
+ static ok(t) {
2017
+ return new e(t, null);
2018
+ }
2019
+ static fail(t) {
2020
+ return new e(null, t);
2021
+ }
2022
+ static fromReplace(t, n, r, i) {
2023
+ try {
2024
+ return e.ok(t.replace(n, r, i));
2025
+ } catch (t) {
2026
+ if (t instanceof u) return e.fail(t.message);
2027
+ throw t;
2028
+ }
2029
+ }
2030
+ };
2031
+ function N(e, t, n) {
2032
+ let r = [];
2033
+ for (let i = 0; i < e.childCount; i++) {
2034
+ let a = e.child(i);
2035
+ a.content.size && (a = a.copy(N(a.content, t, a))), a.isInline && (a = t(a, n, i)), r.push(a);
2036
+ }
2037
+ return a.fromArray(r);
2038
+ }
2039
+ var P = class e extends j {
2040
+ constructor(e, t, n) {
2041
+ super(), this.from = e, this.to = t, this.mark = n;
2042
+ }
2043
+ apply(e) {
2044
+ let t = e.slice(this.from, this.to), n = e.resolve(this.from), r = n.node(n.sharedDepth(this.to)), i = new d(N(t.content, (e, t) => !e.isAtom || !t.type.allowsMarkType(this.mark.type) ? e : e.mark(this.mark.addToSet(e.marks)), r), t.openStart, t.openEnd);
2045
+ return M.fromReplace(e, this.from, this.to, i);
2046
+ }
2047
+ invert() {
2048
+ return new F(this.from, this.to, this.mark);
2049
+ }
2050
+ map(t) {
2051
+ let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
2052
+ return n.deleted && r.deleted || n.pos >= r.pos ? null : new e(n.pos, r.pos, this.mark);
2053
+ }
2054
+ merge(t) {
2055
+ return t instanceof e && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new e(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null;
2056
+ }
2057
+ toJSON() {
2058
+ return {
2059
+ stepType: "addMark",
2060
+ mark: this.mark.toJSON(),
2061
+ from: this.from,
2062
+ to: this.to
2063
+ };
2064
+ }
2065
+ static fromJSON(t, n) {
2066
+ if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for AddMarkStep.fromJSON");
2067
+ return new e(n.from, n.to, t.markFromJSON(n.mark));
2068
+ }
2069
+ };
2070
+ j.jsonID("addMark", P);
2071
+ var F = class e extends j {
2072
+ constructor(e, t, n) {
2073
+ super(), this.from = e, this.to = t, this.mark = n;
2074
+ }
2075
+ apply(e) {
2076
+ let t = e.slice(this.from, this.to), n = new d(N(t.content, (e) => e.mark(this.mark.removeFromSet(e.marks)), e), t.openStart, t.openEnd);
2077
+ return M.fromReplace(e, this.from, this.to, n);
2078
+ }
2079
+ invert() {
2080
+ return new P(this.from, this.to, this.mark);
2081
+ }
2082
+ map(t) {
2083
+ let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
2084
+ return n.deleted && r.deleted || n.pos >= r.pos ? null : new e(n.pos, r.pos, this.mark);
2085
+ }
2086
+ merge(t) {
2087
+ return t instanceof e && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new e(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null;
2088
+ }
2089
+ toJSON() {
2090
+ return {
2091
+ stepType: "removeMark",
2092
+ mark: this.mark.toJSON(),
2093
+ from: this.from,
2094
+ to: this.to
2095
+ };
2096
+ }
2097
+ static fromJSON(t, n) {
2098
+ if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for RemoveMarkStep.fromJSON");
2099
+ return new e(n.from, n.to, t.markFromJSON(n.mark));
2100
+ }
2101
+ };
2102
+ j.jsonID("removeMark", F);
2103
+ var I = class e extends j {
2104
+ constructor(e, t) {
2105
+ super(), this.pos = e, this.mark = t;
2106
+ }
2107
+ apply(e) {
2108
+ let t = e.nodeAt(this.pos);
2109
+ if (!t) return M.fail("No node at mark step's position");
2110
+ let n = t.type.create(t.attrs, null, this.mark.addToSet(t.marks));
2111
+ return M.fromReplace(e, this.pos, this.pos + 1, new d(a.from(n), 0, +!t.isLeaf));
2112
+ }
2113
+ invert(t) {
2114
+ let n = t.nodeAt(this.pos);
2115
+ if (n) {
2116
+ let t = this.mark.addToSet(n.marks);
2117
+ if (t.length == n.marks.length) {
2118
+ for (let r = 0; r < n.marks.length; r++) if (!n.marks[r].isInSet(t)) return new e(this.pos, n.marks[r]);
2119
+ return new e(this.pos, this.mark);
2120
+ }
2121
+ }
2122
+ return new L(this.pos, this.mark);
2123
+ }
2124
+ map(t) {
2125
+ let n = t.mapResult(this.pos, 1);
2126
+ return n.deletedAfter ? null : new e(n.pos, this.mark);
2127
+ }
2128
+ toJSON() {
2129
+ return {
2130
+ stepType: "addNodeMark",
2131
+ pos: this.pos,
2132
+ mark: this.mark.toJSON()
2133
+ };
2134
+ }
2135
+ static fromJSON(t, n) {
2136
+ if (typeof n.pos != "number") throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");
2137
+ return new e(n.pos, t.markFromJSON(n.mark));
2138
+ }
2139
+ };
2140
+ j.jsonID("addNodeMark", I);
2141
+ var L = class e extends j {
2142
+ constructor(e, t) {
2143
+ super(), this.pos = e, this.mark = t;
2144
+ }
2145
+ apply(e) {
2146
+ let t = e.nodeAt(this.pos);
2147
+ if (!t) return M.fail("No node at mark step's position");
2148
+ let n = t.type.create(t.attrs, null, this.mark.removeFromSet(t.marks));
2149
+ return M.fromReplace(e, this.pos, this.pos + 1, new d(a.from(n), 0, +!t.isLeaf));
2150
+ }
2151
+ invert(e) {
2152
+ let t = e.nodeAt(this.pos);
2153
+ return !t || !this.mark.isInSet(t.marks) ? this : new I(this.pos, this.mark);
2154
+ }
2155
+ map(t) {
2156
+ let n = t.mapResult(this.pos, 1);
2157
+ return n.deletedAfter ? null : new e(n.pos, this.mark);
2158
+ }
2159
+ toJSON() {
2160
+ return {
2161
+ stepType: "removeNodeMark",
2162
+ pos: this.pos,
2163
+ mark: this.mark.toJSON()
2164
+ };
2165
+ }
2166
+ static fromJSON(t, n) {
2167
+ if (typeof n.pos != "number") throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
2168
+ return new e(n.pos, t.markFromJSON(n.mark));
2169
+ }
2170
+ };
2171
+ j.jsonID("removeNodeMark", L);
2172
+ var R = class e extends j {
2173
+ constructor(e, t, n, r = !1) {
2174
+ super(), this.from = e, this.to = t, this.slice = n, this.structure = r;
2175
+ }
2176
+ apply(e) {
2177
+ return this.structure && B(e, this.from, this.to) ? M.fail("Structure replace would overwrite content") : M.fromReplace(e, this.from, this.to, this.slice);
2178
+ }
2179
+ getMap() {
2180
+ return new k([
2181
+ this.from,
2182
+ this.to - this.from,
2183
+ this.slice.size
2184
+ ]);
2185
+ }
2186
+ invert(t) {
2187
+ return new e(this.from, this.from + this.slice.size, t.slice(this.from, this.to));
2188
+ }
2189
+ map(t) {
2190
+ let n = t.mapResult(this.to, -1), r = this.from == this.to && e.MAP_BIAS < 0 ? n : t.mapResult(this.from, 1);
2191
+ return r.deletedAcross && n.deletedAcross ? null : new e(r.pos, Math.max(r.pos, n.pos), this.slice, this.structure);
2192
+ }
2193
+ merge(t) {
2194
+ if (!(t instanceof e) || t.structure || this.structure) return null;
2195
+ if (this.from + this.slice.size == t.from && !this.slice.openEnd && !t.slice.openStart) {
2196
+ let n = this.slice.size + t.slice.size == 0 ? d.empty : new d(this.slice.content.append(t.slice.content), this.slice.openStart, t.slice.openEnd);
2197
+ return new e(this.from, this.to + (t.to - t.from), n, this.structure);
2198
+ } else if (t.to == this.from && !this.slice.openStart && !t.slice.openEnd) {
2199
+ let n = this.slice.size + t.slice.size == 0 ? d.empty : new d(t.slice.content.append(this.slice.content), t.slice.openStart, this.slice.openEnd);
2200
+ return new e(t.from, this.to, n, this.structure);
2201
+ } else return null;
2202
+ }
2203
+ toJSON() {
2204
+ let e = {
2205
+ stepType: "replace",
2206
+ from: this.from,
2207
+ to: this.to
2208
+ };
2209
+ return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
2210
+ }
2211
+ static fromJSON(t, n) {
2212
+ if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for ReplaceStep.fromJSON");
2213
+ return new e(n.from, n.to, d.fromJSON(t, n.slice), !!n.structure);
2214
+ }
2215
+ };
2216
+ R.MAP_BIAS = 1, j.jsonID("replace", R);
2217
+ var z = class e extends j {
2218
+ constructor(e, t, n, r, i, a, o = !1) {
2219
+ super(), this.from = e, this.to = t, this.gapFrom = n, this.gapTo = r, this.slice = i, this.insert = a, this.structure = o;
2220
+ }
2221
+ apply(e) {
2222
+ if (this.structure && (B(e, this.from, this.gapFrom) || B(e, this.gapTo, this.to))) return M.fail("Structure gap-replace would overwrite content");
2223
+ let t = e.slice(this.gapFrom, this.gapTo);
2224
+ if (t.openStart || t.openEnd) return M.fail("Gap is not a flat range");
2225
+ let n = this.slice.insertAt(this.insert, t.content);
2226
+ return n ? M.fromReplace(e, this.from, this.to, n) : M.fail("Content does not fit in gap");
2227
+ }
2228
+ getMap() {
2229
+ return new k([
2230
+ this.from,
2231
+ this.gapFrom - this.from,
2232
+ this.insert,
2233
+ this.gapTo,
2234
+ this.to - this.gapTo,
2235
+ this.slice.size - this.insert
2236
+ ]);
2237
+ }
2238
+ invert(t) {
2239
+ let n = this.gapTo - this.gapFrom;
2240
+ return new e(this.from, this.from + this.slice.size + n, this.from + this.insert, this.from + this.insert + n, t.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
2241
+ }
2242
+ map(t) {
2243
+ let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1), i = this.from == this.gapFrom ? n.pos : t.map(this.gapFrom, -1), a = this.to == this.gapTo ? r.pos : t.map(this.gapTo, 1);
2244
+ return n.deletedAcross && r.deletedAcross || i < n.pos || a > r.pos ? null : new e(n.pos, r.pos, i, a, this.slice, this.insert, this.structure);
2245
+ }
2246
+ toJSON() {
2247
+ let e = {
2248
+ stepType: "replaceAround",
2249
+ from: this.from,
2250
+ to: this.to,
2251
+ gapFrom: this.gapFrom,
2252
+ gapTo: this.gapTo,
2253
+ insert: this.insert
2254
+ };
2255
+ return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
2256
+ }
2257
+ static fromJSON(t, n) {
2258
+ if (typeof n.from != "number" || typeof n.to != "number" || typeof n.gapFrom != "number" || typeof n.gapTo != "number" || typeof n.insert != "number") throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");
2259
+ return new e(n.from, n.to, n.gapFrom, n.gapTo, d.fromJSON(t, n.slice), n.insert, !!n.structure);
2260
+ }
2261
+ };
2262
+ j.jsonID("replaceAround", z);
2263
+ function B(e, t, n) {
2264
+ let r = e.resolve(t), i = n - t, a = r.depth;
2265
+ for (; i > 0 && a > 0 && r.indexAfter(a) == r.node(a).childCount;) a--, i--;
2266
+ if (i > 0) {
2267
+ let e = r.node(a).maybeChild(r.indexAfter(a));
2268
+ for (; i > 0;) {
2269
+ if (!e || e.isLeaf) return !0;
2270
+ e = e.firstChild, i--;
2271
+ }
2272
+ }
2273
+ return !1;
2274
+ }
2275
+ function ct(e, t, n, r) {
2276
+ let i = [], a = [], o, s;
2277
+ e.doc.nodesBetween(t, n, (e, c, l) => {
2278
+ if (!e.isInline) return;
2279
+ let u = e.marks;
2280
+ if (!r.isInSet(u) && l.type.allowsMarkType(r.type)) {
2281
+ let l = Math.max(c, t), d = Math.min(c + e.nodeSize, n), f = r.addToSet(u);
2282
+ for (let e = 0; e < u.length; e++) u[e].isInSet(f) || (o && o.to == l && o.mark.eq(u[e]) ? o.to = d : i.push(o = new F(l, d, u[e])));
2283
+ s && s.to == l ? s.to = d : a.push(s = new P(l, d, r));
2284
+ }
2285
+ }), i.forEach((t) => e.step(t)), a.forEach((t) => e.step(t));
2286
+ }
2287
+ function lt(e, t, n, r) {
2288
+ let i = [], a = 0;
2289
+ e.doc.nodesBetween(t, n, (e, o) => {
2290
+ if (!e.isInline) return;
2291
+ a++;
2292
+ let s = null;
2293
+ if (r instanceof je) {
2294
+ let t = e.marks, n;
2295
+ for (; n = r.isInSet(t);) (s ||= []).push(n), t = n.removeFromSet(t);
2296
+ } else r ? r.isInSet(e.marks) && (s = [r]) : s = e.marks;
2297
+ if (s && s.length) {
2298
+ let r = Math.min(o + e.nodeSize, n);
2299
+ for (let e = 0; e < s.length; e++) {
2300
+ let n = s[e], c;
2301
+ for (let e = 0; e < i.length; e++) {
2302
+ let t = i[e];
2303
+ t.step == a - 1 && n.eq(i[e].style) && (c = t);
2304
+ }
2305
+ c ? (c.to = r, c.step = a) : i.push({
2306
+ style: n,
2307
+ from: Math.max(o, t),
2308
+ to: r,
2309
+ step: a
2310
+ });
2311
+ }
2312
+ }
2313
+ }), i.forEach((t) => e.step(new F(t.from, t.to, t.style)));
2314
+ }
2315
+ function V(e, t, n, r = n.contentMatch, i = !0) {
2316
+ let o = e.doc.nodeAt(t), s = [], c = t + 1;
2317
+ for (let t = 0; t < o.childCount; t++) {
2318
+ let l = o.child(t), u = c + l.nodeSize, f = r.matchType(l.type);
2319
+ if (!f) s.push(new R(c, u, d.empty));
2320
+ else {
2321
+ r = f;
2322
+ for (let t = 0; t < l.marks.length; t++) n.allowsMarkType(l.marks[t].type) || e.step(new F(c, u, l.marks[t]));
2323
+ if (i && l.isText && n.whitespace != "pre") {
2324
+ let e, t = /\r?\n|\r/g, r;
2325
+ for (; e = t.exec(l.text);) r ||= new d(a.from(n.schema.text(" ", n.allowedMarks(l.marks))), 0, 0), s.push(new R(c + e.index, c + e.index + e[0].length, r));
2326
+ }
2327
+ }
2328
+ c = u;
2329
+ }
2330
+ if (!r.validEnd) {
2331
+ let t = r.fillBefore(a.empty, !0);
2332
+ e.replace(c, c, new d(t, 0, 0));
2333
+ }
2334
+ for (let t = s.length - 1; t >= 0; t--) e.step(s[t]);
2335
+ }
2336
+ function ut(e, t, n) {
2337
+ return (t == 0 || e.canReplace(t, e.childCount)) && (n == e.childCount || e.canReplace(0, n));
2338
+ }
2339
+ function dt(e) {
2340
+ let t = e.parent.content.cutByIndex(e.startIndex, e.endIndex);
2341
+ for (let n = e.depth, r = 0, i = 0;; --n) {
2342
+ let a = e.$from.node(n), o = e.$from.index(n) + r, s = e.$to.indexAfter(n) - i;
2343
+ if (n < e.depth && a.canReplace(o, s, t)) return n;
2344
+ if (n == 0 || a.type.spec.isolating || !ut(a, o, s)) break;
2345
+ o && (r = 1), s < a.childCount && (i = 1);
2346
+ }
2347
+ return null;
2348
+ }
2349
+ function ft(e, t, n) {
2350
+ let { $from: r, $to: i, depth: o } = t, s = r.before(o + 1), c = i.after(o + 1), l = s, u = c, f = a.empty, p = 0;
2351
+ for (let e = o, t = !1; e > n; e--) t || r.index(e) > 0 ? (t = !0, f = a.from(r.node(e).copy(f)), p++) : l--;
2352
+ let m = a.empty, h = 0;
2353
+ for (let e = o, t = !1; e > n; e--) t || i.after(e + 1) < i.end(e) ? (t = !0, m = a.from(i.node(e).copy(m)), h++) : u++;
2354
+ e.step(new z(l, u, s, c, new d(f.append(m), p, h), f.size - p, !0));
2355
+ }
2356
+ function pt(e, t, n = null, r = e) {
2357
+ let i = ht(e, t), a = i && gt(r, t);
2358
+ return a ? i.map(mt).concat({
2359
+ type: t,
2360
+ attrs: n
2361
+ }).concat(a.map(mt)) : null;
2362
+ }
2363
+ function mt(e) {
2364
+ return {
2365
+ type: e,
2366
+ attrs: null
2367
+ };
2368
+ }
2369
+ function ht(e, t) {
2370
+ let { parent: n, startIndex: r, endIndex: i } = e, a = n.contentMatchAt(r).findWrapping(t);
2371
+ if (!a) return null;
2372
+ let o = a.length ? a[0] : t;
2373
+ return n.canReplaceWith(r, i, o) ? a : null;
2374
+ }
2375
+ function gt(e, t) {
2376
+ let { parent: n, startIndex: r, endIndex: i } = e, a = n.child(r), o = t.contentMatch.findWrapping(a.type);
2377
+ if (!o) return null;
2378
+ let s = (o.length ? o[o.length - 1] : t).contentMatch;
2379
+ for (let e = r; s && e < i; e++) s = s.matchType(n.child(e).type);
2380
+ return !s || !s.validEnd ? null : o;
2381
+ }
2382
+ function _t(e, t, n) {
2383
+ let r = a.empty;
2384
+ for (let e = n.length - 1; e >= 0; e--) {
2385
+ if (r.size) {
2386
+ let t = n[e].type.contentMatch.matchFragment(r);
2387
+ if (!t || !t.validEnd) throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper");
2388
+ }
2389
+ r = a.from(n[e].type.create(n[e].attrs, r));
2390
+ }
2391
+ let i = t.start, o = t.end;
2392
+ e.step(new z(i, o, i, o, new d(r, 0, 0), n.length, !0));
2393
+ }
2394
+ function vt(e, t, n, r, i) {
2395
+ if (!r.isTextblock) throw RangeError("Type given to setBlockType should be a textblock");
2396
+ let o = e.steps.length;
2397
+ e.doc.nodesBetween(t, n, (t, n) => {
2398
+ let s = typeof i == "function" ? i(t) : i;
2399
+ if (t.isTextblock && !t.hasMarkup(r, s) && xt(e.doc, e.mapping.slice(o).map(n), r)) {
2400
+ let i = null;
2401
+ if (r.schema.linebreakReplacement) {
2402
+ let e = r.whitespace == "pre", t = !!r.contentMatch.matchType(r.schema.linebreakReplacement);
2403
+ e && !t ? i = !1 : !e && t && (i = !0);
2404
+ }
2405
+ i === !1 && bt(e, t, n, o), V(e, e.mapping.slice(o).map(n, 1), r, void 0, i === null);
2406
+ let c = e.mapping.slice(o), l = c.map(n, 1), u = c.map(n + t.nodeSize, 1);
2407
+ return e.step(new z(l, u, l + 1, u - 1, new d(a.from(r.create(s, null, t.marks)), 0, 0), 1, !0)), i === !0 && yt(e, t, n, o), !1;
2408
+ }
2409
+ });
2410
+ }
2411
+ function yt(e, t, n, r) {
2412
+ t.forEach((i, a) => {
2413
+ if (i.isText) {
2414
+ let o, s = /\r?\n|\r/g;
2415
+ for (; o = s.exec(i.text);) {
2416
+ let i = e.mapping.slice(r).map(n + 1 + a + o.index);
2417
+ e.replaceWith(i, i + 1, t.type.schema.linebreakReplacement.create());
2418
+ }
2419
+ }
2420
+ });
2421
+ }
2422
+ function bt(e, t, n, r) {
2423
+ t.forEach((i, a) => {
2424
+ if (i.type == i.type.schema.linebreakReplacement) {
2425
+ let i = e.mapping.slice(r).map(n + 1 + a);
2426
+ e.replaceWith(i, i + 1, t.type.schema.text("\n"));
2427
+ }
2428
+ });
2429
+ }
2430
+ function xt(e, t, n) {
2431
+ let r = e.resolve(t), i = r.index();
2432
+ return r.parent.canReplaceWith(i, i + 1, n);
2433
+ }
2434
+ function St(e, t, n, r, i) {
2435
+ let o = e.doc.nodeAt(t);
2436
+ if (!o) throw RangeError("No node at given position");
2437
+ n ||= o.type;
2438
+ let s = n.create(r, null, i || o.marks);
2439
+ if (o.isLeaf) return e.replaceWith(t, t + o.nodeSize, s);
2440
+ if (!n.validContent(o.content)) throw RangeError("Invalid content for node type " + n.name);
2441
+ e.step(new z(t, t + o.nodeSize, t + 1, t + o.nodeSize - 1, new d(a.from(s), 0, 0), 1, !0));
2442
+ }
2443
+ function Ct(e, t, n = 1, r) {
2444
+ let i = e.resolve(t), a = i.depth - n, o = r && r[r.length - 1] || i.parent;
2445
+ if (a < 0 || i.parent.type.spec.isolating || !i.parent.canReplace(i.index(), i.parent.childCount) || !o.type.validContent(i.parent.content.cutByIndex(i.index(), i.parent.childCount))) return !1;
2446
+ for (let e = i.depth - 1, t = n - 2; e > a; e--, t--) {
2447
+ let n = i.node(e), a = i.index(e);
2448
+ if (n.type.spec.isolating) return !1;
2449
+ let o = n.content.cutByIndex(a, n.childCount), s = r && r[t + 1];
2450
+ s && (o = o.replaceChild(0, s.type.create(s.attrs)));
2451
+ let c = r && r[t] || n;
2452
+ if (!n.canReplace(a + 1, n.childCount) || !c.type.validContent(o)) return !1;
2453
+ }
2454
+ let s = i.indexAfter(a), c = r && r[0];
2455
+ return i.node(a).canReplaceWith(s, s, c ? c.type : i.node(a + 1).type);
2456
+ }
2457
+ function wt(e, t, n = 1, r) {
2458
+ let i = e.doc.resolve(t), o = a.empty, s = a.empty;
2459
+ for (let e = i.depth, t = i.depth - n, c = n - 1; e > t; e--, c--) {
2460
+ o = a.from(i.node(e).copy(o));
2461
+ let t = r && r[c];
2462
+ s = a.from(t ? t.type.create(t.attrs, s) : i.node(e).copy(s));
2463
+ }
2464
+ e.step(new R(t, t, new d(o.append(s), n, n), !0));
2465
+ }
2466
+ function Tt(e, t) {
2467
+ let n = e.resolve(t), r = n.index();
2468
+ return Dt(n.nodeBefore, n.nodeAfter) && n.parent.canReplace(r, r + 1);
2469
+ }
2470
+ function Et(e, t) {
2471
+ t.content.size || e.type.compatibleContent(t.type);
2472
+ let n = e.contentMatchAt(e.childCount), { linebreakReplacement: r } = e.type.schema;
2473
+ for (let i = 0; i < t.childCount; i++) {
2474
+ let a = t.child(i), o = a.type == r ? e.type.schema.nodes.text : a.type;
2475
+ if (n = n.matchType(o), !n || !e.type.allowsMarks(a.marks)) return !1;
2476
+ }
2477
+ return n.validEnd;
2478
+ }
2479
+ function Dt(e, t) {
2480
+ return !!(e && t && !e.isLeaf && Et(e, t));
2481
+ }
2482
+ function Ot(e, t, n = -1) {
2483
+ let r = e.resolve(t);
2484
+ for (let e = r.depth;; e--) {
2485
+ let i, a, o = r.index(e);
2486
+ if (e == r.depth ? (i = r.nodeBefore, a = r.nodeAfter) : n > 0 ? (i = r.node(e + 1), o++, a = r.node(e).maybeChild(o)) : (i = r.node(e).maybeChild(o - 1), a = r.node(e + 1)), i && !i.isTextblock && Dt(i, a) && r.node(e).canReplace(o, o + 1)) return t;
2487
+ if (e == 0) break;
2488
+ t = n < 0 ? r.before(e) : r.after(e);
2489
+ }
2490
+ }
2491
+ function kt(e, t, n) {
2492
+ let r = null, { linebreakReplacement: i } = e.doc.type.schema, a = e.doc.resolve(t - n), o = a.node().type;
2493
+ if (i && o.inlineContent) {
2494
+ let e = o.whitespace == "pre", t = !!o.contentMatch.matchType(i);
2495
+ e && !t ? r = !1 : !e && t && (r = !0);
2496
+ }
2497
+ let s = e.steps.length;
2498
+ if (r === !1) {
2499
+ let r = e.doc.resolve(t + n);
2500
+ bt(e, r.node(), r.before(), s);
2501
+ }
2502
+ o.inlineContent && V(e, t + n - 1, o, a.node().contentMatchAt(a.index()), r == null);
2503
+ let c = e.mapping.slice(s), l = c.map(t - n);
2504
+ if (e.step(new R(l, c.map(t + n, -1), d.empty, !0)), r === !0) {
2505
+ let t = e.doc.resolve(l);
2506
+ yt(e, t.node(), t.before(), e.steps.length);
2507
+ }
2508
+ return e;
2509
+ }
2510
+ function At(e, t, n) {
2511
+ let r = e.resolve(t);
2512
+ if (r.parent.canReplaceWith(r.index(), r.index(), n)) return t;
2513
+ if (r.parentOffset == 0) for (let e = r.depth - 1; e >= 0; e--) {
2514
+ let t = r.index(e);
2515
+ if (r.node(e).canReplaceWith(t, t, n)) return r.before(e + 1);
2516
+ if (t > 0) return null;
2517
+ }
2518
+ if (r.parentOffset == r.parent.content.size) for (let e = r.depth - 1; e >= 0; e--) {
2519
+ let t = r.indexAfter(e);
2520
+ if (r.node(e).canReplaceWith(t, t, n)) return r.after(e + 1);
2521
+ if (t < r.node(e).childCount) return null;
2522
+ }
2523
+ return null;
2524
+ }
2525
+ function jt(e, t, n) {
2526
+ let r = e.resolve(t);
2527
+ if (!n.content.size) return t;
2528
+ let i = n.content;
2529
+ for (let e = 0; e < n.openStart; e++) i = i.firstChild.content;
2530
+ for (let e = 1; e <= (n.openStart == 0 && n.size ? 2 : 1); e++) for (let t = r.depth; t >= 0; t--) {
2531
+ let n = t == r.depth ? 0 : r.pos <= (r.start(t + 1) + r.end(t + 1)) / 2 ? -1 : 1, a = r.index(t) + +(n > 0), o = r.node(t), s = !1;
2532
+ if (e == 1) s = o.canReplace(a, a, i);
2533
+ else {
2534
+ let e = o.contentMatchAt(a).findWrapping(i.firstChild.type);
2535
+ s = e && o.canReplaceWith(a, a, e[0]);
2536
+ }
2537
+ if (s) return n == 0 ? r.pos : n < 0 ? r.before(t + 1) : r.after(t + 1);
2538
+ }
2539
+ return null;
2540
+ }
2541
+ function Mt(e, t, n = t, r = d.empty) {
2542
+ if (t == n && !r.size) return null;
2543
+ let i = e.resolve(t), a = e.resolve(n);
2544
+ return Nt(i, a, r) ? new R(t, n, r) : new Pt(i, a, r).fit();
2545
+ }
2546
+ function Nt(e, t, n) {
2547
+ return !n.openStart && !n.openEnd && e.start() == t.start() && e.parent.canReplace(e.index(), t.index(), n.content);
2548
+ }
2549
+ var Pt = class {
2550
+ constructor(e, t, n) {
2551
+ this.$from = e, this.$to = t, this.unplaced = n, this.frontier = [], this.placed = a.empty;
2552
+ for (let t = 0; t <= e.depth; t++) {
2553
+ let n = e.node(t);
2554
+ this.frontier.push({
2555
+ type: n.type,
2556
+ match: n.contentMatchAt(e.indexAfter(t))
2557
+ });
2558
+ }
2559
+ for (let t = e.depth; t > 0; t--) this.placed = a.from(e.node(t).copy(this.placed));
2560
+ }
2561
+ get depth() {
2562
+ return this.frontier.length - 1;
2563
+ }
2564
+ fit() {
2565
+ for (; this.unplaced.size;) {
2566
+ let e = this.findFittable();
2567
+ e ? this.placeNodes(e) : this.openMore() || this.dropNode();
2568
+ }
2569
+ let e = this.mustMoveInline(), t = this.placed.size - this.depth - this.$from.depth, n = this.$from, r = this.close(e < 0 ? this.$to : n.doc.resolve(e));
2570
+ if (!r) return null;
2571
+ let i = this.placed, a = n.depth, o = r.depth;
2572
+ for (; a && o && i.childCount == 1;) i = i.firstChild.content, a--, o--;
2573
+ let s = new d(i, a, o);
2574
+ return e > -1 ? new z(n.pos, e, this.$to.pos, this.$to.end(), s, t) : s.size || n.pos != this.$to.pos ? new R(n.pos, r.pos, s) : null;
2575
+ }
2576
+ findFittable() {
2577
+ let e = this.unplaced.openStart;
2578
+ for (let t = this.unplaced.content, n = 0, r = this.unplaced.openEnd; n < e; n++) {
2579
+ let i = t.firstChild;
2580
+ if (t.childCount > 1 && (r = 0), i.type.spec.isolating && r <= n) {
2581
+ e = n;
2582
+ break;
2583
+ }
2584
+ t = i.content;
2585
+ }
2586
+ for (let t = 1; t <= 2; t++) for (let n = t == 1 ? e : this.unplaced.openStart; n >= 0; n--) {
2587
+ let e, r = null;
2588
+ n ? (r = W(this.unplaced.content, n - 1).firstChild, e = r.content) : e = this.unplaced.content;
2589
+ let i = e.firstChild;
2590
+ for (let e = this.depth; e >= 0; e--) {
2591
+ let { type: o, match: s } = this.frontier[e], c, l = null;
2592
+ if (t == 1 && (i ? s.matchType(i.type) || (l = s.fillBefore(a.from(i), !1)) : r && o.compatibleContent(r.type))) return {
2593
+ sliceDepth: n,
2594
+ frontierDepth: e,
2595
+ parent: r,
2596
+ inject: l
2597
+ };
2598
+ if (t == 2 && i && (c = s.findWrapping(i.type))) return {
2599
+ sliceDepth: n,
2600
+ frontierDepth: e,
2601
+ parent: r,
2602
+ wrap: c
2603
+ };
2604
+ if (r && s.matchType(r.type)) break;
2605
+ }
2606
+ }
2607
+ }
2608
+ openMore() {
2609
+ let { content: e, openStart: t, openEnd: n } = this.unplaced, r = W(e, t);
2610
+ return !r.childCount || r.firstChild.isLeaf ? !1 : (this.unplaced = new d(e, t + 1, Math.max(n, r.size + t >= e.size - n ? t + 1 : 0)), !0);
2611
+ }
2612
+ dropNode() {
2613
+ let { content: e, openStart: t, openEnd: n } = this.unplaced, r = W(e, t);
2614
+ if (r.childCount <= 1 && t > 0) {
2615
+ let i = e.size - t <= t + r.size;
2616
+ this.unplaced = new d(H(e, t - 1, 1), t - 1, i ? t - 1 : n);
2617
+ } else this.unplaced = new d(H(e, t, 1), t, n);
2618
+ }
2619
+ placeNodes({ sliceDepth: e, frontierDepth: t, parent: n, inject: r, wrap: i }) {
2620
+ for (; this.depth > t;) this.closeFrontierNode();
2621
+ if (i) for (let e = 0; e < i.length; e++) this.openFrontierNode(i[e]);
2622
+ let o = this.unplaced, s = n ? n.content : o.content, c = o.openStart - e, l = 0, u = [], { match: f, type: p } = this.frontier[t];
2623
+ if (r) {
2624
+ for (let e = 0; e < r.childCount; e++) u.push(r.child(e));
2625
+ f = f.matchFragment(r);
2626
+ }
2627
+ let m = s.size + e - (o.content.size - o.openEnd);
2628
+ for (; l < s.childCount;) {
2629
+ let e = s.child(l), t = f.matchType(e.type);
2630
+ if (!t) break;
2631
+ l++, (l > 1 || c == 0 || e.content.size) && (f = t, u.push(Ft(e.mark(p.allowedMarks(e.marks)), l == 1 ? c : 0, l == s.childCount ? m : -1)));
2632
+ }
2633
+ let h = l == s.childCount;
2634
+ h || (m = -1), this.placed = U(this.placed, t, a.from(u)), this.frontier[t].match = f, h && m < 0 && n && n.type == this.frontier[this.depth].type && this.frontier.length > 1 && this.closeFrontierNode();
2635
+ for (let e = 0, t = s; e < m; e++) {
2636
+ let e = t.lastChild;
2637
+ this.frontier.push({
2638
+ type: e.type,
2639
+ match: e.contentMatchAt(e.childCount)
2640
+ }), t = e.content;
2641
+ }
2642
+ this.unplaced = h ? e == 0 ? d.empty : new d(H(o.content, e - 1, 1), e - 1, m < 0 ? o.openEnd : e - 1) : new d(H(o.content, e, l), o.openStart, o.openEnd);
2643
+ }
2644
+ mustMoveInline() {
2645
+ if (!this.$to.parent.isTextblock) return -1;
2646
+ let e = this.frontier[this.depth], t;
2647
+ if (!e.type.isTextblock || !G(this.$to, this.$to.depth, e.type, e.match, !1) || this.$to.depth == this.depth && (t = this.findCloseLevel(this.$to)) && t.depth == this.depth) return -1;
2648
+ let { depth: n } = this.$to, r = this.$to.after(n);
2649
+ for (; n > 1 && r == this.$to.end(--n);) ++r;
2650
+ return r;
2651
+ }
2652
+ findCloseLevel(e) {
2653
+ scan: for (let t = Math.min(this.depth, e.depth); t >= 0; t--) {
2654
+ let { match: n, type: r } = this.frontier[t], i = t < e.depth && e.end(t + 1) == e.pos + (e.depth - (t + 1)), a = G(e, t, r, n, i);
2655
+ if (a) {
2656
+ for (let n = t - 1; n >= 0; n--) {
2657
+ let { match: t, type: r } = this.frontier[n], i = G(e, n, r, t, !0);
2658
+ if (!i || i.childCount) continue scan;
2659
+ }
2660
+ return {
2661
+ depth: t,
2662
+ fit: a,
2663
+ move: i ? e.doc.resolve(e.after(t + 1)) : e
2664
+ };
2665
+ }
2666
+ }
2667
+ }
2668
+ close(e) {
2669
+ let t = this.findCloseLevel(e);
2670
+ if (!t) return null;
2671
+ for (; this.depth > t.depth;) this.closeFrontierNode();
2672
+ t.fit.childCount && (this.placed = U(this.placed, t.depth, t.fit)), e = t.move;
2673
+ for (let n = t.depth + 1; n <= e.depth; n++) {
2674
+ let t = e.node(n), r = t.type.contentMatch.fillBefore(t.content, !0, e.index(n));
2675
+ this.openFrontierNode(t.type, t.attrs, r);
2676
+ }
2677
+ return e;
2678
+ }
2679
+ openFrontierNode(e, t = null, n) {
2680
+ let r = this.frontier[this.depth];
2681
+ r.match = r.match.matchType(e), this.placed = U(this.placed, this.depth, a.from(e.create(t, n))), this.frontier.push({
2682
+ type: e,
2683
+ match: e.contentMatch
2684
+ });
2685
+ }
2686
+ closeFrontierNode() {
2687
+ let e = this.frontier.pop().match.fillBefore(a.empty, !0);
2688
+ e.childCount && (this.placed = U(this.placed, this.frontier.length, e));
2689
+ }
2690
+ };
2691
+ function H(e, t, n) {
2692
+ return t == 0 ? e.cutByIndex(n, e.childCount) : e.replaceChild(0, e.firstChild.copy(H(e.firstChild.content, t - 1, n)));
2693
+ }
2694
+ function U(e, t, n) {
2695
+ return t == 0 ? e.append(n) : e.replaceChild(e.childCount - 1, e.lastChild.copy(U(e.lastChild.content, t - 1, n)));
2696
+ }
2697
+ function W(e, t) {
2698
+ for (let n = 0; n < t; n++) e = e.firstChild.content;
2699
+ return e;
2700
+ }
2701
+ function Ft(e, t, n) {
2702
+ if (t <= 0) return e;
2703
+ let r = e.content;
2704
+ return t > 1 && (r = r.replaceChild(0, Ft(r.firstChild, t - 1, r.childCount == 1 ? n - 1 : 0))), t > 0 && (r = e.type.contentMatch.fillBefore(r).append(r), n <= 0 && (r = r.append(e.type.contentMatch.matchFragment(r).fillBefore(a.empty, !0)))), e.copy(r);
2705
+ }
2706
+ function G(e, t, n, r, i) {
2707
+ let a = e.node(t), o = i ? e.indexAfter(t) : e.index(t);
2708
+ if (o == a.childCount && !n.compatibleContent(a.type)) return null;
2709
+ let s = r.fillBefore(a.content, !0, o);
2710
+ return s && !It(n, a.content, o) ? s : null;
2711
+ }
2712
+ function It(e, t, n) {
2713
+ for (let r = n; r < t.childCount; r++) if (!e.allowsMarks(t.child(r).marks)) return !0;
2714
+ return !1;
2715
+ }
2716
+ function Lt(e) {
2717
+ return e.spec.defining || e.spec.definingForContent;
2718
+ }
2719
+ function Rt(e, t, n, r) {
2720
+ if (!r.size) return e.deleteRange(t, n);
2721
+ let i = e.doc.resolve(t), a = e.doc.resolve(n);
2722
+ if (Nt(i, a, r)) return e.step(new R(t, n, r));
2723
+ let o = Ht(i, a);
2724
+ o[o.length - 1] == 0 && o.pop();
2725
+ let s = -(i.depth + 1);
2726
+ o.unshift(s);
2727
+ for (let e = i.depth, t = i.pos - 1; e > 0; e--, t--) {
2728
+ let n = i.node(e).type.spec;
2729
+ if (n.defining || n.definingAsContext || n.isolating) break;
2730
+ o.indexOf(e) > -1 ? s = e : i.before(e) == t && o.splice(1, 0, -e);
2731
+ }
2732
+ let c = o.indexOf(s), l = [], u = r.openStart;
2733
+ for (let e = r.content, t = 0;; t++) {
2734
+ let n = e.firstChild;
2735
+ if (l.push(n), t == r.openStart) break;
2736
+ e = n.content;
2737
+ }
2738
+ for (let e = u - 1; e >= 0; e--) {
2739
+ let t = l[e], n = Lt(t.type);
2740
+ if (n && !t.sameMarkup(i.node(Math.abs(s) - 1))) u = e;
2741
+ else if (n || !t.type.isTextblock) break;
2742
+ }
2743
+ for (let t = r.openStart; t >= 0; t--) {
2744
+ let s = (t + u + 1) % (r.openStart + 1), f = l[s];
2745
+ if (f) for (let t = 0; t < o.length; t++) {
2746
+ let l = o[(t + c) % o.length], u = !0;
2747
+ l < 0 && (u = !1, l = -l);
2748
+ let p = i.node(l - 1), m = i.index(l - 1);
2749
+ if (p.canReplaceWith(m, m, f.type, f.marks)) return e.replace(i.before(l), u ? a.after(l) : n, new d(zt(r.content, 0, r.openStart, s), s, r.openEnd));
2750
+ }
2751
+ }
2752
+ let f = e.steps.length;
2753
+ for (let s = o.length - 1; s >= 0 && (e.replace(t, n, r), !(e.steps.length > f)); s--) {
2754
+ let e = o[s];
2755
+ e < 0 || (t = i.before(e), n = a.after(e));
2756
+ }
2757
+ }
2758
+ function zt(e, t, n, r, i) {
2759
+ if (t < n) {
2760
+ let i = e.firstChild;
2761
+ e = e.replaceChild(0, i.copy(zt(i.content, t + 1, n, r, i)));
2762
+ }
2763
+ if (t > r) {
2764
+ let t = i.contentMatchAt(0), n = t.fillBefore(e).append(e);
2765
+ e = n.append(t.matchFragment(n).fillBefore(a.empty, !0));
2766
+ }
2767
+ return e;
2768
+ }
2769
+ function Bt(e, t, n, r) {
2770
+ if (!r.isInline && t == n && e.doc.resolve(t).parent.content.size) {
2771
+ let i = At(e.doc, t, r.type);
2772
+ i != null && (t = n = i);
2773
+ }
2774
+ e.replaceRange(t, n, new d(a.from(r), 0, 0));
2775
+ }
2776
+ function Vt(e, t, n) {
2777
+ let r = e.doc.resolve(t), i = e.doc.resolve(n);
2778
+ if (r.parent.isTextblock && i.parent.isTextblock && r.start() != i.start() && r.parentOffset == 0 && i.parentOffset == 0) {
2779
+ let a = r.sharedDepth(n), o = !1;
2780
+ for (let e = r.depth; e > a; e--) r.node(e).type.spec.isolating && (o = !0);
2781
+ for (let e = i.depth; e > a; e--) i.node(e).type.spec.isolating && (o = !0);
2782
+ if (!o) {
2783
+ for (let e = r.depth; e > 0 && t == r.start(e); e--) t = r.before(e);
2784
+ for (let e = i.depth; e > 0 && n == i.start(e); e--) n = i.before(e);
2785
+ r = e.doc.resolve(t), i = e.doc.resolve(n);
2786
+ }
2787
+ }
2788
+ let a = Ht(r, i);
2789
+ for (let t = 0; t < a.length; t++) {
2790
+ let n = a[t], o = t == a.length - 1;
2791
+ if (o && n == 0 || r.node(n).type.contentMatch.validEnd) return e.delete(r.start(n), i.end(n));
2792
+ if (n > 0 && (o || r.node(n - 1).canReplace(r.index(n - 1), i.indexAfter(n - 1)))) return e.delete(r.before(n), i.after(n));
2793
+ }
2794
+ for (let a = 1; a <= r.depth && a <= i.depth; a++) if (t - r.start(a) == r.depth - a && n > r.end(a) && i.end(a) - n != i.depth - a && r.start(a - 1) == i.start(a - 1) && r.node(a - 1).canReplace(r.index(a - 1), i.index(a - 1))) return e.delete(r.before(a), n);
2795
+ e.delete(t, n);
2796
+ }
2797
+ function Ht(e, t) {
2798
+ let n = [], r = Math.min(e.depth, t.depth);
2799
+ for (let i = r; i >= 0; i--) {
2800
+ let r = e.start(i);
2801
+ if (r < e.pos - (e.depth - i) || t.end(i) > t.pos + (t.depth - i) || e.node(i).type.spec.isolating || t.node(i).type.spec.isolating) break;
2802
+ (r == t.start(i) || i == e.depth && i == t.depth && e.parent.inlineContent && t.parent.inlineContent && i && t.start(i - 1) == r - 1) && n.push(i);
2803
+ }
2804
+ return n;
2805
+ }
2806
+ var Ut = class e extends j {
2807
+ constructor(e, t, n) {
2808
+ super(), this.pos = e, this.attr = t, this.value = n;
2809
+ }
2810
+ apply(e) {
2811
+ let t = e.nodeAt(this.pos);
2812
+ if (!t) return M.fail("No node at attribute step's position");
2813
+ let n = Object.create(null);
2814
+ for (let e in t.attrs) n[e] = t.attrs[e];
2815
+ n[this.attr] = this.value;
2816
+ let r = t.type.create(n, null, t.marks);
2817
+ return M.fromReplace(e, this.pos, this.pos + 1, new d(a.from(r), 0, +!t.isLeaf));
2818
+ }
2819
+ getMap() {
2820
+ return k.empty;
2821
+ }
2822
+ invert(t) {
2823
+ return new e(this.pos, this.attr, t.nodeAt(this.pos).attrs[this.attr]);
2824
+ }
2825
+ map(t) {
2826
+ let n = t.mapResult(this.pos, 1);
2827
+ return n.deletedAfter ? null : new e(n.pos, this.attr, this.value);
2828
+ }
2829
+ toJSON() {
2830
+ return {
2831
+ stepType: "attr",
2832
+ pos: this.pos,
2833
+ attr: this.attr,
2834
+ value: this.value
2835
+ };
2836
+ }
2837
+ static fromJSON(t, n) {
2838
+ if (typeof n.pos != "number" || typeof n.attr != "string") throw RangeError("Invalid input for AttrStep.fromJSON");
2839
+ return new e(n.pos, n.attr, n.value);
2840
+ }
2841
+ };
2842
+ j.jsonID("attr", Ut);
2843
+ var Wt = class e extends j {
2844
+ constructor(e, t) {
2845
+ super(), this.attr = e, this.value = t;
2846
+ }
2847
+ apply(e) {
2848
+ let t = Object.create(null);
2849
+ for (let n in e.attrs) t[n] = e.attrs[n];
2850
+ t[this.attr] = this.value;
2851
+ let n = e.type.create(t, e.content, e.marks);
2852
+ return M.ok(n);
2853
+ }
2854
+ getMap() {
2855
+ return k.empty;
2856
+ }
2857
+ invert(t) {
2858
+ return new e(this.attr, t.attrs[this.attr]);
2859
+ }
2860
+ map(e) {
2861
+ return this;
2862
+ }
2863
+ toJSON() {
2864
+ return {
2865
+ stepType: "docAttr",
2866
+ attr: this.attr,
2867
+ value: this.value
2868
+ };
2869
+ }
2870
+ static fromJSON(t, n) {
2871
+ if (typeof n.attr != "string") throw RangeError("Invalid input for DocAttrStep.fromJSON");
2872
+ return new e(n.attr, n.value);
2873
+ }
2874
+ };
2875
+ j.jsonID("docAttr", Wt);
2876
+ var K = class extends Error {};
2877
+ K = function e(t) {
2878
+ let n = Error.call(this, t);
2879
+ return n.__proto__ = e.prototype, n;
2880
+ }, K.prototype = Object.create(Error.prototype), K.prototype.constructor = K, K.prototype.name = "TransformError";
2881
+ var Gt = class {
2882
+ constructor(e) {
2883
+ this.doc = e, this.steps = [], this.docs = [], this.mapping = new st();
2884
+ }
2885
+ get before() {
2886
+ return this.docs.length ? this.docs[0] : this.doc;
2887
+ }
2888
+ step(e) {
2889
+ let t = this.maybeStep(e);
2890
+ if (t.failed) throw new K(t.failed);
2891
+ return this;
2892
+ }
2893
+ maybeStep(e) {
2894
+ let t = e.apply(this.doc);
2895
+ return t.failed || this.addStep(e, t.doc), t;
2896
+ }
2897
+ get docChanged() {
2898
+ return this.steps.length > 0;
2899
+ }
2900
+ changedRange() {
2901
+ let e = 1e9, t = -1e9;
2902
+ for (let n = 0; n < this.mapping.maps.length; n++) {
2903
+ let r = this.mapping.maps[n];
2904
+ n && (e = r.map(e, 1), t = r.map(t, -1)), r.forEach((n, r, i, a) => {
2905
+ e = Math.min(e, i), t = Math.max(t, a);
2906
+ });
2907
+ }
2908
+ return e == 1e9 ? null : {
2909
+ from: e,
2910
+ to: t
2911
+ };
2912
+ }
2913
+ addStep(e, t) {
2914
+ this.docs.push(this.doc), this.steps.push(e), this.mapping.appendMap(e.getMap()), this.doc = t;
2915
+ }
2916
+ replace(e, t = e, n = d.empty) {
2917
+ let r = Mt(this.doc, e, t, n);
2918
+ return r && this.step(r), this;
2919
+ }
2920
+ replaceWith(e, t, n) {
2921
+ return this.replace(e, t, new d(a.from(n), 0, 0));
2922
+ }
2923
+ delete(e, t) {
2924
+ return this.replace(e, t, d.empty);
2925
+ }
2926
+ insert(e, t) {
2927
+ return this.replaceWith(e, e, t);
2928
+ }
2929
+ replaceRange(e, t, n) {
2930
+ return Rt(this, e, t, n), this;
2931
+ }
2932
+ replaceRangeWith(e, t, n) {
2933
+ return Bt(this, e, t, n), this;
2934
+ }
2935
+ deleteRange(e, t) {
2936
+ return Vt(this, e, t), this;
2937
+ }
2938
+ lift(e, t) {
2939
+ return ft(this, e, t), this;
2940
+ }
2941
+ join(e, t = 1) {
2942
+ return kt(this, e, t), this;
2943
+ }
2944
+ wrap(e, t) {
2945
+ return _t(this, e, t), this;
2946
+ }
2947
+ setBlockType(e, t = e, n, r = null) {
2948
+ return vt(this, e, t, n, r), this;
2949
+ }
2950
+ setNodeMarkup(e, t, n = null, r) {
2951
+ return St(this, e, t, n, r), this;
2952
+ }
2953
+ setNodeAttribute(e, t, n) {
2954
+ return this.step(new Ut(e, t, n)), this;
2955
+ }
2956
+ setDocAttribute(e, t) {
2957
+ return this.step(new Wt(e, t)), this;
2958
+ }
2959
+ addNodeMark(e, t) {
2960
+ return this.step(new I(e, t)), this;
2961
+ }
2962
+ removeNodeMark(e, t) {
2963
+ let n = this.doc.nodeAt(e);
2964
+ if (!n) throw RangeError("No node at position " + e);
2965
+ if (t instanceof l) t.isInSet(n.marks) && this.step(new L(e, t));
2966
+ else {
2967
+ let r = n.marks, i, a = [];
2968
+ for (; i = t.isInSet(r);) a.push(new L(e, i)), r = i.removeFromSet(r);
2969
+ for (let e = a.length - 1; e >= 0; e--) this.step(a[e]);
2970
+ }
2971
+ return this;
2972
+ }
2973
+ split(e, t = 1, n) {
2974
+ return wt(this, e, t, n), this;
2975
+ }
2976
+ addMark(e, t, n) {
2977
+ return ct(this, e, t, n), this;
2978
+ }
2979
+ removeMark(e, t, n) {
2980
+ return lt(this, e, t, n), this;
2981
+ }
2982
+ clearIncompatible(e, t, n) {
2983
+ return V(this, e, t, n), this;
2984
+ }
2985
+ }, Kt = Object.create(null), q = class {
2986
+ constructor(e, t, n) {
2987
+ this.$anchor = e, this.$head = t, this.ranges = n || [new qt(e.min(t), e.max(t))];
2988
+ }
2989
+ get anchor() {
2990
+ return this.$anchor.pos;
2991
+ }
2992
+ get head() {
2993
+ return this.$head.pos;
2994
+ }
2995
+ get from() {
2996
+ return this.$from.pos;
2997
+ }
2998
+ get to() {
2999
+ return this.$to.pos;
3000
+ }
3001
+ get $from() {
3002
+ return this.ranges[0].$from;
3003
+ }
3004
+ get $to() {
3005
+ return this.ranges[0].$to;
3006
+ }
3007
+ get empty() {
3008
+ let e = this.ranges;
3009
+ for (let t = 0; t < e.length; t++) if (e[t].$from.pos != e[t].$to.pos) return !1;
3010
+ return !0;
3011
+ }
3012
+ content() {
3013
+ return this.$from.doc.slice(this.from, this.to, !0);
3014
+ }
3015
+ replace(e, t = d.empty) {
3016
+ let n = t.content.lastChild, r = null;
3017
+ for (let e = 0; e < t.openEnd; e++) r = n, n = n.lastChild;
3018
+ let i = e.steps.length, a = this.ranges;
3019
+ for (let o = 0; o < a.length; o++) {
3020
+ let { $from: s, $to: c } = a[o], l = e.mapping.slice(i);
3021
+ e.replaceRange(l.map(s.pos), l.map(c.pos), o ? d.empty : t), o == 0 && $t(e, i, (n ? n.isInline : r && r.isTextblock) ? -1 : 1);
3022
+ }
3023
+ }
3024
+ replaceWith(e, t) {
3025
+ let n = e.steps.length, r = this.ranges;
3026
+ for (let i = 0; i < r.length; i++) {
3027
+ let { $from: a, $to: o } = r[i], s = e.mapping.slice(n), c = s.map(a.pos), l = s.map(o.pos);
3028
+ i ? e.deleteRange(c, l) : (e.replaceRangeWith(c, l, t), $t(e, n, t.isInline ? -1 : 1));
3029
+ }
3030
+ }
3031
+ static findFrom(e, t, n = !1) {
3032
+ let r = e.parent.inlineContent ? new J(e) : Z(e.node(0), e.parent, e.pos, e.index(), t, n);
3033
+ if (r) return r;
3034
+ for (let r = e.depth - 1; r >= 0; r--) {
3035
+ let i = t < 0 ? Z(e.node(0), e.node(r), e.before(r + 1), e.index(r), t, n) : Z(e.node(0), e.node(r), e.after(r + 1), e.index(r) + 1, t, n);
3036
+ if (i) return i;
3037
+ }
3038
+ return null;
3039
+ }
3040
+ static near(e, t = 1) {
3041
+ return this.findFrom(e, t) || this.findFrom(e, -t) || new X(e.node(0));
3042
+ }
3043
+ static atStart(e) {
3044
+ return Z(e, e, 0, 0, 1) || new X(e);
3045
+ }
3046
+ static atEnd(e) {
3047
+ return Z(e, e, e.content.size, e.childCount, -1) || new X(e);
3048
+ }
3049
+ static fromJSON(e, t) {
3050
+ if (!t || !t.type) throw RangeError("Invalid input for Selection.fromJSON");
3051
+ let n = Kt[t.type];
3052
+ if (!n) throw RangeError(`No selection type ${t.type} defined`);
3053
+ return n.fromJSON(e, t);
3054
+ }
3055
+ static jsonID(e, t) {
3056
+ if (e in Kt) throw RangeError("Duplicate use of selection JSON ID " + e);
3057
+ return Kt[e] = t, t.prototype.jsonID = e, t;
3058
+ }
3059
+ getBookmark() {
3060
+ return J.between(this.$anchor, this.$head).getBookmark();
3061
+ }
3062
+ };
3063
+ q.prototype.visible = !0;
3064
+ var qt = class {
3065
+ constructor(e, t) {
3066
+ this.$from = e, this.$to = t;
3067
+ }
3068
+ }, Jt = !1;
3069
+ function Yt(e) {
3070
+ !Jt && !e.parent.inlineContent && (Jt = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + e.parent.type.name + ")"));
3071
+ }
3072
+ var J = class e extends q {
3073
+ constructor(e, t = e) {
3074
+ Yt(e), Yt(t), super(e, t);
3075
+ }
3076
+ get $cursor() {
3077
+ return this.$anchor.pos == this.$head.pos ? this.$head : null;
3078
+ }
3079
+ map(t, n) {
3080
+ let r = t.resolve(n.map(this.head));
3081
+ if (!r.parent.inlineContent) return q.near(r);
3082
+ let i = t.resolve(n.map(this.anchor));
3083
+ return new e(i.parent.inlineContent ? i : r, r);
3084
+ }
3085
+ replace(e, t = d.empty) {
3086
+ if (super.replace(e, t), t == d.empty) {
3087
+ let t = this.$from.marksAcross(this.$to);
3088
+ t && e.ensureMarks(t);
3089
+ }
3090
+ }
3091
+ eq(t) {
3092
+ return t instanceof e && t.anchor == this.anchor && t.head == this.head;
3093
+ }
3094
+ getBookmark() {
3095
+ return new Xt(this.anchor, this.head);
3096
+ }
3097
+ toJSON() {
3098
+ return {
3099
+ type: "text",
3100
+ anchor: this.anchor,
3101
+ head: this.head
3102
+ };
3103
+ }
3104
+ static fromJSON(t, n) {
3105
+ if (typeof n.anchor != "number" || typeof n.head != "number") throw RangeError("Invalid input for TextSelection.fromJSON");
3106
+ return new e(t.resolve(n.anchor), t.resolve(n.head));
3107
+ }
3108
+ static create(e, t, n = t) {
3109
+ let r = e.resolve(t);
3110
+ return new this(r, n == t ? r : e.resolve(n));
3111
+ }
3112
+ static between(t, n, r) {
3113
+ let i = t.pos - n.pos;
3114
+ if ((!r || i) && (r = i >= 0 ? 1 : -1), !n.parent.inlineContent) {
3115
+ let e = q.findFrom(n, r, !0) || q.findFrom(n, -r, !0);
3116
+ if (e) n = e.$head;
3117
+ else return q.near(n, r);
3118
+ }
3119
+ return t.parent.inlineContent || (i == 0 ? t = n : (t = (q.findFrom(t, -r, !0) || q.findFrom(t, r, !0)).$anchor, t.pos < n.pos != i < 0 && (t = n))), new e(t, n);
3120
+ }
3121
+ };
3122
+ q.jsonID("text", J);
3123
+ var Xt = class e {
3124
+ constructor(e, t) {
3125
+ this.anchor = e, this.head = t;
3126
+ }
3127
+ map(t) {
3128
+ return new e(t.map(this.anchor), t.map(this.head));
3129
+ }
3130
+ resolve(e) {
3131
+ return J.between(e.resolve(this.anchor), e.resolve(this.head));
3132
+ }
3133
+ }, Y = class e extends q {
3134
+ constructor(e) {
3135
+ let t = e.nodeAfter, n = e.node(0).resolve(e.pos + t.nodeSize);
3136
+ super(e, n), this.node = t;
3137
+ }
3138
+ map(t, n) {
3139
+ let { deleted: r, pos: i } = n.mapResult(this.anchor), a = t.resolve(i);
3140
+ return r ? q.near(a) : new e(a);
3141
+ }
3142
+ content() {
3143
+ return new d(a.from(this.node), 0, 0);
3144
+ }
3145
+ eq(t) {
3146
+ return t instanceof e && t.anchor == this.anchor;
3147
+ }
3148
+ toJSON() {
3149
+ return {
3150
+ type: "node",
3151
+ anchor: this.anchor
3152
+ };
3153
+ }
3154
+ getBookmark() {
3155
+ return new Zt(this.anchor);
3156
+ }
3157
+ static fromJSON(t, n) {
3158
+ if (typeof n.anchor != "number") throw RangeError("Invalid input for NodeSelection.fromJSON");
3159
+ return new e(t.resolve(n.anchor));
3160
+ }
3161
+ static create(t, n) {
3162
+ return new e(t.resolve(n));
3163
+ }
3164
+ static isSelectable(e) {
3165
+ return !e.isText && e.type.spec.selectable !== !1;
3166
+ }
3167
+ };
3168
+ Y.prototype.visible = !1, q.jsonID("node", Y);
3169
+ var Zt = class e {
3170
+ constructor(e) {
3171
+ this.anchor = e;
3172
+ }
3173
+ map(t) {
3174
+ let { deleted: n, pos: r } = t.mapResult(this.anchor);
3175
+ return n ? new Xt(r, r) : new e(r);
3176
+ }
3177
+ resolve(e) {
3178
+ let t = e.resolve(this.anchor), n = t.nodeAfter;
3179
+ return n && Y.isSelectable(n) ? new Y(t) : q.near(t);
3180
+ }
3181
+ }, X = class e extends q {
3182
+ constructor(e) {
3183
+ super(e.resolve(0), e.resolve(e.content.size));
3184
+ }
3185
+ replace(e, t = d.empty) {
3186
+ if (t == d.empty) {
3187
+ e.delete(0, e.doc.content.size);
3188
+ let t = q.atStart(e.doc);
3189
+ t.eq(e.selection) || e.setSelection(t);
3190
+ } else super.replace(e, t);
3191
+ }
3192
+ toJSON() {
3193
+ return { type: "all" };
3194
+ }
3195
+ static fromJSON(t) {
3196
+ return new e(t);
3197
+ }
3198
+ map(t) {
3199
+ return new e(t);
3200
+ }
3201
+ eq(t) {
3202
+ return t instanceof e;
3203
+ }
3204
+ getBookmark() {
3205
+ return Qt;
3206
+ }
3207
+ };
3208
+ q.jsonID("all", X);
3209
+ var Qt = {
3210
+ map() {
3211
+ return this;
3212
+ },
3213
+ resolve(e) {
3214
+ return new X(e);
3215
+ }
3216
+ };
3217
+ function Z(e, t, n, r, i, a = !1) {
3218
+ if (t.inlineContent) return J.create(e, n);
3219
+ for (let o = r - (i > 0 ? 0 : 1); i > 0 ? o < t.childCount : o >= 0; o += i) {
3220
+ let r = t.child(o);
3221
+ if (!r.isAtom) {
3222
+ let t = Z(e, r, n + i, i < 0 ? r.childCount : 0, i, a);
3223
+ if (t) return t;
3224
+ } else if (!a && Y.isSelectable(r)) return Y.create(e, n - (i < 0 ? r.nodeSize : 0));
3225
+ n += r.nodeSize * i;
3226
+ }
3227
+ return null;
3228
+ }
3229
+ function $t(e, t, n) {
3230
+ let r = e.steps.length - 1;
3231
+ if (r < t) return;
3232
+ let i = e.steps[r];
3233
+ if (!(i instanceof R || i instanceof z)) return;
3234
+ let a = e.mapping.maps[r], o;
3235
+ a.forEach((e, t, n, r) => {
3236
+ o ??= r;
3237
+ }), e.setSelection(q.near(e.doc.resolve(o), n));
3238
+ }
3239
+ var en = 1, tn = 2, nn = 4, rn = class extends Gt {
3240
+ constructor(e) {
3241
+ super(e.doc), this.curSelectionFor = 0, this.updated = 0, this.meta = Object.create(null), this.time = Date.now(), this.curSelection = e.selection, this.storedMarks = e.storedMarks;
3242
+ }
3243
+ get selection() {
3244
+ return this.curSelectionFor < this.steps.length && (this.curSelection = this.curSelection.map(this.doc, this.mapping.slice(this.curSelectionFor)), this.curSelectionFor = this.steps.length), this.curSelection;
3245
+ }
3246
+ setSelection(e) {
3247
+ if (e.$from.doc != this.doc) throw RangeError("Selection passed to setSelection must point at the current document");
3248
+ return this.curSelection = e, this.curSelectionFor = this.steps.length, this.updated = (this.updated | en) & -3, this.storedMarks = null, this;
3249
+ }
3250
+ get selectionSet() {
3251
+ return (this.updated & en) > 0;
3252
+ }
3253
+ setStoredMarks(e) {
3254
+ return this.storedMarks = e, this.updated |= tn, this;
3255
+ }
3256
+ ensureMarks(e) {
3257
+ return l.sameSet(this.storedMarks || this.selection.$from.marks(), e) || this.setStoredMarks(e), this;
3258
+ }
3259
+ addStoredMark(e) {
3260
+ return this.ensureMarks(e.addToSet(this.storedMarks || this.selection.$head.marks()));
3261
+ }
3262
+ removeStoredMark(e) {
3263
+ return this.ensureMarks(e.removeFromSet(this.storedMarks || this.selection.$head.marks()));
3264
+ }
3265
+ get storedMarksSet() {
3266
+ return (this.updated & tn) > 0;
3267
+ }
3268
+ addStep(e, t) {
3269
+ super.addStep(e, t), this.updated &= -3, this.storedMarks = null;
3270
+ }
3271
+ setTime(e) {
3272
+ return this.time = e, this;
3273
+ }
3274
+ replaceSelection(e) {
3275
+ return this.selection.replace(this, e), this;
3276
+ }
3277
+ replaceSelectionWith(e, t = !0) {
3278
+ let n = this.selection;
3279
+ return t && (e = e.mark(this.storedMarks || (n.empty ? n.$from.marks() : n.$from.marksAcross(n.$to) || l.none))), n.replaceWith(this, e), this;
3280
+ }
3281
+ deleteSelection() {
3282
+ return this.selection.replace(this), this;
3283
+ }
3284
+ insertText(e, t, n) {
3285
+ let r = this.doc.type.schema;
3286
+ if (t == null) return e ? this.replaceSelectionWith(r.text(e), !0) : this.deleteSelection();
3287
+ {
3288
+ if (n ??= t, !e) return this.deleteRange(t, n);
3289
+ let i = this.storedMarks;
3290
+ if (!i) {
3291
+ let e = this.doc.resolve(t);
3292
+ i = n == t ? e.marks() : e.marksAcross(this.doc.resolve(n));
3293
+ }
3294
+ return this.replaceRangeWith(t, n, r.text(e, i)), !this.selection.empty && this.selection.to == t + e.length && this.setSelection(q.near(this.selection.$to)), this;
3295
+ }
3296
+ }
3297
+ setMeta(e, t) {
3298
+ return this.meta[typeof e == "string" ? e : e.key] = t, this;
3299
+ }
3300
+ getMeta(e) {
3301
+ return this.meta[typeof e == "string" ? e : e.key];
3302
+ }
3303
+ get isGeneric() {
3304
+ for (let e in this.meta) return !1;
3305
+ return !0;
3306
+ }
3307
+ scrollIntoView() {
3308
+ return this.updated |= nn, this;
3309
+ }
3310
+ get scrolledIntoView() {
3311
+ return (this.updated & nn) > 0;
3312
+ }
3313
+ };
3314
+ function an(e, t) {
3315
+ return !t || !e ? e : e.bind(t);
3316
+ }
3317
+ var Q = class {
3318
+ constructor(e, t, n) {
3319
+ this.name = e, this.init = an(t.init, n), this.apply = an(t.apply, n);
3320
+ }
3321
+ }, on = [
3322
+ new Q("doc", {
3323
+ init(e) {
3324
+ return e.doc || e.schema.topNodeType.createAndFill();
3325
+ },
3326
+ apply(e) {
3327
+ return e.doc;
3328
+ }
3329
+ }),
3330
+ new Q("selection", {
3331
+ init(e, t) {
3332
+ return e.selection || q.atStart(t.doc);
3333
+ },
3334
+ apply(e) {
3335
+ return e.selection;
3336
+ }
3337
+ }),
3338
+ new Q("storedMarks", {
3339
+ init(e) {
3340
+ return e.storedMarks || null;
3341
+ },
3342
+ apply(e, t, n, r) {
3343
+ return r.selection.$cursor ? e.storedMarks : null;
3344
+ }
3345
+ }),
3346
+ new Q("scrollToSelection", {
3347
+ init() {
3348
+ return 0;
3349
+ },
3350
+ apply(e, t) {
3351
+ return e.scrolledIntoView ? t + 1 : t;
3352
+ }
3353
+ })
3354
+ ], sn = class {
3355
+ constructor(e, t) {
3356
+ this.schema = e, this.plugins = [], this.pluginsByKey = Object.create(null), this.fields = on.slice(), t && t.forEach((e) => {
3357
+ if (this.pluginsByKey[e.key]) throw RangeError("Adding different instances of a keyed plugin (" + e.key + ")");
3358
+ this.plugins.push(e), this.pluginsByKey[e.key] = e, e.spec.state && this.fields.push(new Q(e.key, e.spec.state, e));
3359
+ });
3360
+ }
3361
+ }, cn = class e {
3362
+ constructor(e) {
3363
+ this.config = e;
3364
+ }
3365
+ get schema() {
3366
+ return this.config.schema;
3367
+ }
3368
+ get plugins() {
3369
+ return this.config.plugins;
3370
+ }
3371
+ apply(e) {
3372
+ return this.applyTransaction(e).state;
3373
+ }
3374
+ filterTransaction(e, t = -1) {
3375
+ for (let n = 0; n < this.config.plugins.length; n++) if (n != t) {
3376
+ let t = this.config.plugins[n];
3377
+ if (t.spec.filterTransaction && !t.spec.filterTransaction.call(t, e, this)) return !1;
3378
+ }
3379
+ return !0;
3380
+ }
3381
+ applyTransaction(e) {
3382
+ if (!this.filterTransaction(e)) return {
3383
+ state: this,
3384
+ transactions: []
3385
+ };
3386
+ let t = [e], n = this.applyInner(e), r = null;
3387
+ for (;;) {
3388
+ let i = !1;
3389
+ for (let a = 0; a < this.config.plugins.length; a++) {
3390
+ let o = this.config.plugins[a];
3391
+ if (o.spec.appendTransaction) {
3392
+ let s = r ? r[a].n : 0, c = r ? r[a].state : this, l = s < t.length && o.spec.appendTransaction.call(o, s ? t.slice(s) : t, c, n);
3393
+ if (l && n.filterTransaction(l, a)) {
3394
+ if (l.setMeta("appendedTransaction", e), !r) {
3395
+ r = [];
3396
+ for (let e = 0; e < this.config.plugins.length; e++) r.push(e < a ? {
3397
+ state: n,
3398
+ n: t.length
3399
+ } : {
3400
+ state: this,
3401
+ n: 0
3402
+ });
3403
+ }
3404
+ t.push(l), n = n.applyInner(l), i = !0;
3405
+ }
3406
+ r && (r[a] = {
3407
+ state: n,
3408
+ n: t.length
3409
+ });
3410
+ }
3411
+ }
3412
+ if (!i) return {
3413
+ state: n,
3414
+ transactions: t
3415
+ };
3416
+ }
3417
+ }
3418
+ applyInner(t) {
3419
+ if (!t.before.eq(this.doc)) throw RangeError("Applying a mismatched transaction");
3420
+ let n = new e(this.config), r = this.config.fields;
3421
+ for (let e = 0; e < r.length; e++) {
3422
+ let i = r[e];
3423
+ n[i.name] = i.apply(t, this[i.name], this, n);
3424
+ }
3425
+ return n;
3426
+ }
3427
+ get tr() {
3428
+ return new rn(this);
3429
+ }
3430
+ static create(t) {
3431
+ let n = new sn(t.doc ? t.doc.type.schema : t.schema, t.plugins), r = new e(n);
3432
+ for (let e = 0; e < n.fields.length; e++) r[n.fields[e].name] = n.fields[e].init(t, r);
3433
+ return r;
3434
+ }
3435
+ reconfigure(t) {
3436
+ let n = new sn(this.schema, t.plugins), r = n.fields, i = new e(n);
3437
+ for (let e = 0; e < r.length; e++) {
3438
+ let n = r[e].name;
3439
+ i[n] = this.hasOwnProperty(n) ? this[n] : r[e].init(t, i);
3440
+ }
3441
+ return i;
3442
+ }
3443
+ toJSON(e) {
3444
+ let t = {
3445
+ doc: this.doc.toJSON(),
3446
+ selection: this.selection.toJSON()
3447
+ };
3448
+ if (this.storedMarks && (t.storedMarks = this.storedMarks.map((e) => e.toJSON())), e && typeof e == "object") for (let n in e) {
3449
+ if (n == "doc" || n == "selection") throw RangeError("The JSON fields `doc` and `selection` are reserved");
3450
+ let r = e[n], i = r.spec.state;
3451
+ i && i.toJSON && (t[n] = i.toJSON.call(r, this[r.key]));
3452
+ }
3453
+ return t;
3454
+ }
3455
+ static fromJSON(t, n, r) {
3456
+ if (!n) throw RangeError("Invalid input for EditorState.fromJSON");
3457
+ if (!t.schema) throw RangeError("Required config field 'schema' missing");
3458
+ let i = new sn(t.schema, t.plugins), a = new e(i);
3459
+ return i.fields.forEach((e) => {
3460
+ if (e.name == "doc") a.doc = x.fromJSON(t.schema, n.doc);
3461
+ else if (e.name == "selection") a.selection = q.fromJSON(a.doc, n.selection);
3462
+ else if (e.name == "storedMarks") n.storedMarks && (a.storedMarks = n.storedMarks.map(t.schema.markFromJSON));
3463
+ else {
3464
+ if (r) for (let i in r) {
3465
+ let o = r[i], s = o.spec.state;
3466
+ if (o.key == e.name && s && s.fromJSON && Object.prototype.hasOwnProperty.call(n, i)) {
3467
+ a[e.name] = s.fromJSON.call(o, t, n[i], a);
3468
+ return;
3469
+ }
3470
+ }
3471
+ a[e.name] = e.init(t, a);
3472
+ }
3473
+ }), a;
3474
+ }
3475
+ };
3476
+ function ln(e, t, n) {
3477
+ for (let r in e) {
3478
+ let i = e[r];
3479
+ i instanceof Function ? i = i.bind(t) : r == "handleDOMEvents" && (i = ln(i, t, {})), n[r] = i;
3480
+ }
3481
+ return n;
3482
+ }
3483
+ var un = class {
3484
+ constructor(e) {
3485
+ this.spec = e, this.props = {}, e.props && ln(e.props, this, this.props), this.key = e.key ? e.key.key : dn("plugin");
3486
+ }
3487
+ getState(e) {
3488
+ return e[this.key];
3489
+ }
3490
+ }, $ = Object.create(null);
3491
+ function dn(e) {
3492
+ return e in $ ? e + "$" + ++$[e] : ($[e] = 0, e + "$");
3493
+ }
3494
+ var fn = class {
3495
+ constructor(e = "key") {
3496
+ this.key = dn(e);
3497
+ }
3498
+ get(e) {
3499
+ return e.config.pluginsByKey[this.key];
3500
+ }
3501
+ getState(e) {
3502
+ return e[this.key];
3503
+ }
3504
+ };
3505
+ //#endregion
3506
+ export { a as C, Me as D, se as E, d as O, qe as S, x as T, pt as _, fn as a, Mt as b, J as c, z as d, R as f, jt as g, Ct as h, un as i, st as l, Tt as m, cn as n, q as o, Gt as p, Y as r, qt as s, X as t, F as u, Ot as v, l as w, Ie as x, dt as y };