@vizel/core 0.0.1-alpha.1

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