@notmrabhi/flowforge 0.1.21 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/GatewayBranchEdge-9YF32wwN.js +1 -0
  2. package/dist/GatewayBranchEdge-Dxoy5B1A.js +1264 -0
  3. package/dist/SchemaBuilderDrawer-157p-2Vj.js +1136 -0
  4. package/dist/SchemaBuilderDrawer-Wje7pVrn.js +1 -0
  5. package/dist/bpmn-CcuE2X_Q.js +2 -0
  6. package/dist/bpmn-CtfWDaOY.js +33 -0
  7. package/dist/canvas.cjs +1 -0
  8. package/dist/canvas.d.ts +809 -0
  9. package/dist/canvas.js +28 -0
  10. package/dist/canvasTokens-CAD6G24b.js +32 -0
  11. package/dist/canvasTokens-gKNYrPl4.js +1 -0
  12. package/dist/core.cjs +1 -0
  13. package/dist/core.d.ts +374 -0
  14. package/dist/core.js +24 -0
  15. package/dist/defaultUi.cjs +1 -0
  16. package/dist/defaultUi.d.ts +83 -0
  17. package/dist/defaultUi.js +18 -0
  18. package/dist/form.cjs +1 -0
  19. package/dist/form.d.ts +857 -0
  20. package/dist/form.js +44 -0
  21. package/dist/index-B31-Y5uO.js +11 -0
  22. package/dist/index-B3aHpb84.js +13 -0
  23. package/dist/index-BU09HbVh.js +10176 -0
  24. package/dist/index-BnzttJ4w.js +13758 -0
  25. package/dist/index-BysKSEtZ.js +1 -0
  26. package/dist/index-CQ0cVcHp.js +2 -0
  27. package/dist/index-CkjEllpd.js +1 -0
  28. package/dist/index-Codx5QwP.js +41 -0
  29. package/dist/index-Cw9DC-tf.js +76 -0
  30. package/dist/index-CzPi8KQC.js +1310 -0
  31. package/dist/index-D14V8rKX.js +1 -0
  32. package/dist/index-Da5NHCS2.js +8132 -0
  33. package/dist/index-a1IOaYsW.js +9 -0
  34. package/dist/index-a3QMaedZ.js +2553 -0
  35. package/dist/index-gtgq_241.js +3 -0
  36. package/dist/index-l6kvDx-m.js +1360 -0
  37. package/dist/index-lcviy90e.js +613 -0
  38. package/dist/index-wOnYb3DO.js +567 -0
  39. package/dist/index.cjs +1 -0
  40. package/dist/index.d.ts +1409 -0
  41. package/dist/index.js +107 -0
  42. package/dist/messages-CO299wPN.js +22 -0
  43. package/dist/messages-O9Tw_XXR.js +1 -0
  44. package/dist/nodeRegistry.cjs +1 -0
  45. package/dist/nodeRegistry.d.ts +334 -0
  46. package/dist/nodeRegistry.js +555 -0
  47. package/dist/style.css +6 -0
  48. package/dist/templateRegistry.cjs +1 -0
  49. package/dist/templateRegistry.d.ts +83 -0
  50. package/dist/templateRegistry.js +43 -0
  51. package/dist/templateSkeletons-D2ecxpVH.js +2954 -0
  52. package/dist/templateSkeletons-D5dYuslG.js +1 -0
  53. package/package.json +1 -1
@@ -0,0 +1,2553 @@
1
+ import { _ as Nn, G as qn } from "./index-BU09HbVh.js";
2
+ import { useState as ae, useLayoutEffect as Vn, useEffect as ce, forwardRef as Hn, useRef as Un, useImperativeHandle as zn, useCallback as Gn } from "react";
3
+ import { E as m, b as x, Q as Pt, U as Ft, X as Ae, S as et, T as Ve, F as ge, e as Re, Y as tt, j as Nt, i as nt, Z as te, _, d as F, $ as Kn, a0 as $n, A as rt, r as $e, n as Jn, a1 as Je, m as qt, a2 as it, a3 as _n, a4 as Vt, P as Qn, c as jn, a as Yn, V as Ht, D as v, a5 as ue, a6 as Ut, f as Zn, C as T, a7 as b, a8 as Xn, a9 as er, W as tr, aa as nr, ab as rr, ac as ir, ad as or, ae as sr, af as lr, ag as ar, ah as cr, ai as zt, aj as hr, ak as ur, al as fr, am as dr, k as Gt, an as mr, ao as gr, v as f, ap as pr } from "./index-BnzttJ4w.js";
4
+ import { aq as Xo, ar as es, as as ts, at as ns, au as rs, av as is, aw as os, ax as ss, M as ls, ay as as, az as cs, R as hs, h as us, aA as fs, aB as ds, aC as ms, aD as gs, aE as ps, g as ys, aF as ks, aG as xs, aH as Ss, aI as bs, aJ as Cs, aK as vs, aL as Ms, l as As, s as Ls } from "./index-BnzttJ4w.js";
5
+ import { a as yr, b as kr, d as xr, e as Sr } from "./index-l6kvDx-m.js";
6
+ import { jsx as br } from "react/jsx-runtime";
7
+ const Cr = (t) => {
8
+ let { state: e } = t, r = e.doc.lineAt(e.selection.main.from), n = st(t.state, r.from);
9
+ return n.line ? vr(t) : n.block ? Ar(t) : !1;
10
+ };
11
+ function ot(t, e) {
12
+ return ({ state: r, dispatch: n }) => {
13
+ if (r.readOnly)
14
+ return !1;
15
+ let i = t(e, r);
16
+ return i ? (n(r.update(i)), !0) : !1;
17
+ };
18
+ }
19
+ const vr = /* @__PURE__ */ ot(
20
+ Dr,
21
+ 0
22
+ /* CommentOption.Toggle */
23
+ ), Mr = /* @__PURE__ */ ot(
24
+ Kt,
25
+ 0
26
+ /* CommentOption.Toggle */
27
+ ), Ar = /* @__PURE__ */ ot(
28
+ (t, e) => Kt(t, e, Br(e)),
29
+ 0
30
+ /* CommentOption.Toggle */
31
+ );
32
+ function st(t, e) {
33
+ let r = t.languageDataAt("commentTokens", e, 1);
34
+ return r.length ? r[0] : {};
35
+ }
36
+ const he = 50;
37
+ function Lr(t, { open: e, close: r }, n, i) {
38
+ let o = t.sliceDoc(n - he, n), s = t.sliceDoc(i, i + he), l = /\s*$/.exec(o)[0].length, a = /^\s*/.exec(s)[0].length, c = o.length - l;
39
+ if (o.slice(c - e.length, c) == e && s.slice(a, a + r.length) == r)
40
+ return {
41
+ open: { pos: n - l, margin: l && 1 },
42
+ close: { pos: i + a, margin: a && 1 }
43
+ };
44
+ let h, u;
45
+ i - n <= 2 * he ? h = u = t.sliceDoc(n, i) : (h = t.sliceDoc(n, n + he), u = t.sliceDoc(i - he, i));
46
+ let d = /^\s*/.exec(h)[0].length, g = /\s*$/.exec(u)[0].length, p = u.length - g - r.length;
47
+ return h.slice(d, d + e.length) == e && u.slice(p, p + r.length) == r ? {
48
+ open: {
49
+ pos: n + d + e.length,
50
+ margin: /\s/.test(h.charAt(d + e.length)) ? 1 : 0
51
+ },
52
+ close: {
53
+ pos: i - g - r.length,
54
+ margin: /\s/.test(u.charAt(p - 1)) ? 1 : 0
55
+ }
56
+ } : null;
57
+ }
58
+ function Br(t) {
59
+ let e = [];
60
+ for (let r of t.selection.ranges) {
61
+ let n = t.doc.lineAt(r.from), i = r.to <= n.to ? n : t.doc.lineAt(r.to);
62
+ i.from > n.from && i.from == r.to && (i = r.to == n.to + 1 ? n : t.doc.lineAt(r.to - 1));
63
+ let o = e.length - 1;
64
+ o >= 0 && e[o].to > n.from ? e[o].to = i.to : e.push({ from: n.from + /^\s*/.exec(n.text)[0].length, to: i.to });
65
+ }
66
+ return e;
67
+ }
68
+ function Kt(t, e, r = e.selection.ranges) {
69
+ let n = r.map((o) => st(e, o.from).block);
70
+ if (!n.every((o) => o))
71
+ return null;
72
+ let i = r.map((o, s) => Lr(e, n[s], o.from, o.to));
73
+ if (t != 2 && !i.every((o) => o))
74
+ return { changes: e.changes(r.map((o, s) => i[s] ? [] : [{ from: o.from, insert: n[s].open + " " }, { from: o.to, insert: " " + n[s].close }])) };
75
+ if (t != 1 && i.some((o) => o)) {
76
+ let o = [];
77
+ for (let s = 0, l; s < i.length; s++)
78
+ if (l = i[s]) {
79
+ let a = n[s], { open: c, close: h } = l;
80
+ o.push({ from: c.pos - a.open.length, to: c.pos + c.margin }, { from: h.pos - h.margin, to: h.pos + a.close.length });
81
+ }
82
+ return { changes: o };
83
+ }
84
+ return null;
85
+ }
86
+ function Dr(t, e, r = e.selection.ranges) {
87
+ let n = [], i = -1;
88
+ e: for (let { from: o, to: s } of r) {
89
+ let l = n.length, a = 1e9, c;
90
+ for (let h = o; h <= s; ) {
91
+ let u = e.doc.lineAt(h);
92
+ if (c == null && (c = st(e, u.from).line, !c))
93
+ continue e;
94
+ if (u.from > i && (o == s || s > u.from)) {
95
+ i = u.from;
96
+ let d = /^\s*/.exec(u.text)[0].length, g = d == u.length, p = u.text.slice(d, d + c.length) == c ? d : -1;
97
+ d < u.text.length && d < a && (a = d), n.push({ line: u, comment: p, token: c, indent: d, empty: g, single: !1 });
98
+ }
99
+ h = u.to + 1;
100
+ }
101
+ if (a < 1e9)
102
+ for (let h = l; h < n.length; h++)
103
+ n[h].indent < n[h].line.text.length && (n[h].indent = a);
104
+ n.length == l + 1 && (n[l].single = !0);
105
+ }
106
+ if (t != 2 && n.some((o) => o.comment < 0 && (!o.empty || o.single))) {
107
+ let o = [];
108
+ for (let { line: l, token: a, indent: c, empty: h, single: u } of n)
109
+ (u || !h) && o.push({ from: l.from + c, insert: a + " " });
110
+ let s = e.changes(o);
111
+ return { changes: s, selection: e.selection.map(s, 1) };
112
+ } else if (t != 1 && n.some((o) => o.comment >= 0)) {
113
+ let o = [];
114
+ for (let { line: s, comment: l, token: a } of n)
115
+ if (l >= 0) {
116
+ let c = s.from + l, h = c + a.length;
117
+ s.text[h - s.from] == " " && h++, o.push({ from: c, to: h });
118
+ }
119
+ return { changes: o };
120
+ }
121
+ return null;
122
+ }
123
+ const _e = /* @__PURE__ */ rt.define(), Er = /* @__PURE__ */ rt.define(), Tr = /* @__PURE__ */ ge.define(), $t = /* @__PURE__ */ ge.define({
124
+ combine(t) {
125
+ return Re(t, {
126
+ minDepth: 100,
127
+ newGroupDelay: 500,
128
+ joinToEvent: (e, r) => r
129
+ }, {
130
+ minDepth: Math.max,
131
+ newGroupDelay: Math.min,
132
+ joinToEvent: (e, r) => (n, i) => e(n, i) || r(n, i)
133
+ });
134
+ }
135
+ }), Jt = /* @__PURE__ */ et.define({
136
+ create() {
137
+ return P.empty;
138
+ },
139
+ update(t, e) {
140
+ let r = e.state.facet($t), n = e.annotation(_e);
141
+ if (n) {
142
+ let a = L.fromTransaction(e, n.selection), c = n.side, h = c == 0 ? t.undone : t.done;
143
+ return a ? h = Le(h, h.length, r.minDepth, a) : h = jt(h, e.startState.selection), new P(c == 0 ? n.rest : h, c == 0 ? h : n.rest);
144
+ }
145
+ let i = e.annotation(Er);
146
+ if ((i == "full" || i == "before") && (t = t.isolate()), e.annotation(Ve.addToHistory) === !1)
147
+ return e.changes.empty ? t : t.addMapping(e.changes.desc);
148
+ let o = L.fromTransaction(e), s = e.annotation(Ve.time), l = e.annotation(Ve.userEvent);
149
+ return o ? t = t.addChanges(o, s, l, r, e) : e.selection && (t = t.addSelection(e.startState.selection, s, l, r.newGroupDelay)), (i == "full" || i == "after") && (t = t.isolate()), t;
150
+ },
151
+ toJSON(t) {
152
+ return { done: t.done.map((e) => e.toJSON()), undone: t.undone.map((e) => e.toJSON()) };
153
+ },
154
+ fromJSON(t) {
155
+ return new P(t.done.map(L.fromJSON), t.undone.map(L.fromJSON));
156
+ }
157
+ });
158
+ function wr(t = {}) {
159
+ return [
160
+ Jt,
161
+ $t.of(t),
162
+ x.domEventHandlers({
163
+ beforeinput(e, r) {
164
+ let n = e.inputType == "historyUndo" ? _t : e.inputType == "historyRedo" ? Qe : null;
165
+ return n ? (e.preventDefault(), n(r)) : !1;
166
+ }
167
+ })
168
+ ];
169
+ }
170
+ function Ie(t, e) {
171
+ return function({ state: r, dispatch: n }) {
172
+ if (!e && r.readOnly)
173
+ return !1;
174
+ let i = r.field(Jt, !1);
175
+ if (!i)
176
+ return !1;
177
+ let o = i.pop(t, r, e);
178
+ return o ? (n(o), !0) : !1;
179
+ };
180
+ }
181
+ const _t = /* @__PURE__ */ Ie(0, !1), Qe = /* @__PURE__ */ Ie(1, !1), Rr = /* @__PURE__ */ Ie(0, !0), Ir = /* @__PURE__ */ Ie(1, !0);
182
+ class L {
183
+ constructor(e, r, n, i, o) {
184
+ this.changes = e, this.effects = r, this.mapped = n, this.startSelection = i, this.selectionsAfter = o;
185
+ }
186
+ setSelAfter(e) {
187
+ return new L(this.changes, this.effects, this.mapped, this.startSelection, e);
188
+ }
189
+ toJSON() {
190
+ var e, r, n;
191
+ return {
192
+ changes: (e = this.changes) === null || e === void 0 ? void 0 : e.toJSON(),
193
+ mapped: (r = this.mapped) === null || r === void 0 ? void 0 : r.toJSON(),
194
+ startSelection: (n = this.startSelection) === null || n === void 0 ? void 0 : n.toJSON(),
195
+ selectionsAfter: this.selectionsAfter.map((i) => i.toJSON())
196
+ };
197
+ }
198
+ static fromJSON(e) {
199
+ return new L(e.changes && Kn.fromJSON(e.changes), [], e.mapped && $n.fromJSON(e.mapped), e.startSelection && m.fromJSON(e.startSelection), e.selectionsAfter.map(m.fromJSON));
200
+ }
201
+ // This does not check `addToHistory` and such, it assumes the
202
+ // transaction needs to be converted to an item. Returns null when
203
+ // there are no changes or effects in the transaction.
204
+ static fromTransaction(e, r) {
205
+ let n = w;
206
+ for (let i of e.startState.facet(Tr)) {
207
+ let o = i(e);
208
+ o.length && (n = n.concat(o));
209
+ }
210
+ return !n.length && e.changes.empty ? null : new L(e.changes.invert(e.startState.doc), n, void 0, r || e.startState.selection, w);
211
+ }
212
+ static selection(e) {
213
+ return new L(void 0, w, void 0, void 0, e);
214
+ }
215
+ }
216
+ function Le(t, e, r, n) {
217
+ let i = e + 1 > r + 20 ? e - r - 1 : 0, o = t.slice(i, e);
218
+ return o.push(n), o;
219
+ }
220
+ function Or(t, e) {
221
+ let r = [], n = !1;
222
+ return t.iterChangedRanges((i, o) => r.push(i, o)), e.iterChangedRanges((i, o, s, l) => {
223
+ for (let a = 0; a < r.length; ) {
224
+ let c = r[a++], h = r[a++];
225
+ l >= c && s <= h && (n = !0);
226
+ }
227
+ }), n;
228
+ }
229
+ function Wr(t, e) {
230
+ return t.ranges.length == e.ranges.length && t.ranges.filter((r, n) => r.empty != e.ranges[n].empty).length === 0;
231
+ }
232
+ function Qt(t, e) {
233
+ return t.length ? e.length ? t.concat(e) : t : e;
234
+ }
235
+ const w = [], Pr = 200;
236
+ function jt(t, e) {
237
+ if (t.length) {
238
+ let r = t[t.length - 1], n = r.selectionsAfter.slice(Math.max(0, r.selectionsAfter.length - Pr));
239
+ return n.length && n[n.length - 1].eq(e) ? t : (n.push(e), Le(t, t.length - 1, 1e9, r.setSelAfter(n)));
240
+ } else
241
+ return [L.selection([e])];
242
+ }
243
+ function Fr(t) {
244
+ let e = t[t.length - 1], r = t.slice();
245
+ return r[t.length - 1] = e.setSelAfter(e.selectionsAfter.slice(0, e.selectionsAfter.length - 1)), r;
246
+ }
247
+ function He(t, e) {
248
+ if (!t.length)
249
+ return t;
250
+ let r = t.length, n = w;
251
+ for (; r; ) {
252
+ let i = Nr(t[r - 1], e, n);
253
+ if (i.changes && !i.changes.empty || i.effects.length) {
254
+ let o = t.slice(0, r);
255
+ return o[r - 1] = i, o;
256
+ } else
257
+ e = i.mapped, r--, n = i.selectionsAfter;
258
+ }
259
+ return n.length ? [L.selection(n)] : w;
260
+ }
261
+ function Nr(t, e, r) {
262
+ let n = Qt(t.selectionsAfter.length ? t.selectionsAfter.map((l) => l.map(e)) : w, r);
263
+ if (!t.changes)
264
+ return L.selection(n);
265
+ let i = t.changes.map(e), o = e.mapDesc(t.changes, !0), s = t.mapped ? t.mapped.composeDesc(o) : o;
266
+ return new L(i, F.mapEffects(t.effects, e), s, t.startSelection.map(o), n);
267
+ }
268
+ const qr = /^(input\.type|delete)($|\.)/;
269
+ class P {
270
+ constructor(e, r, n = 0, i = void 0) {
271
+ this.done = e, this.undone = r, this.prevTime = n, this.prevUserEvent = i;
272
+ }
273
+ isolate() {
274
+ return this.prevTime ? new P(this.done, this.undone) : this;
275
+ }
276
+ addChanges(e, r, n, i, o) {
277
+ let s = this.done, l = s[s.length - 1];
278
+ return l && l.changes && !l.changes.empty && e.changes && (!n || qr.test(n)) && (!l.selectionsAfter.length && r - this.prevTime < i.newGroupDelay && i.joinToEvent(o, Or(l.changes, e.changes)) || // For compose (but not compose.start) events, always join with previous event
279
+ n == "input.type.compose") ? s = Le(s, s.length - 1, i.minDepth, new L(e.changes.compose(l.changes), Qt(F.mapEffects(e.effects, l.changes), l.effects), l.mapped, l.startSelection, w)) : s = Le(s, s.length, i.minDepth, e), new P(s, w, r, n);
280
+ }
281
+ addSelection(e, r, n, i) {
282
+ let o = this.done.length ? this.done[this.done.length - 1].selectionsAfter : w;
283
+ return o.length > 0 && r - this.prevTime < i && n == this.prevUserEvent && n && /^select($|\.)/.test(n) && Wr(o[o.length - 1], e) ? this : new P(jt(this.done, e), this.undone, r, n);
284
+ }
285
+ addMapping(e) {
286
+ return new P(He(this.done, e), He(this.undone, e), this.prevTime, this.prevUserEvent);
287
+ }
288
+ pop(e, r, n) {
289
+ let i = e == 0 ? this.done : this.undone;
290
+ if (i.length == 0)
291
+ return null;
292
+ let o = i[i.length - 1], s = o.selectionsAfter[0] || (o.startSelection ? o.startSelection.map(o.changes.invertedDesc, 1) : r.selection);
293
+ if (n && o.selectionsAfter.length)
294
+ return r.update({
295
+ selection: o.selectionsAfter[o.selectionsAfter.length - 1],
296
+ annotations: _e.of({ side: e, rest: Fr(i), selection: s }),
297
+ userEvent: e == 0 ? "select.undo" : "select.redo",
298
+ scrollIntoView: !0
299
+ });
300
+ if (o.changes) {
301
+ let l = i.length == 1 ? w : i.slice(0, i.length - 1);
302
+ return o.mapped && (l = He(l, o.mapped)), r.update({
303
+ changes: o.changes,
304
+ selection: o.startSelection,
305
+ effects: o.effects,
306
+ annotations: _e.of({ side: e, rest: l, selection: s }),
307
+ filter: !1,
308
+ userEvent: e == 0 ? "undo" : "redo",
309
+ scrollIntoView: !0
310
+ });
311
+ } else
312
+ return null;
313
+ }
314
+ }
315
+ P.empty = /* @__PURE__ */ new P(w, w);
316
+ const Vr = [
317
+ { key: "Mod-z", run: _t, preventDefault: !0 },
318
+ { key: "Mod-y", mac: "Mod-Shift-z", run: Qe, preventDefault: !0 },
319
+ { linux: "Ctrl-Shift-z", run: Qe, preventDefault: !0 },
320
+ { key: "Mod-u", run: Rr, preventDefault: !0 },
321
+ { key: "Alt-u", mac: "Mod-Shift-u", run: Ir, preventDefault: !0 }
322
+ ];
323
+ function ie(t, e) {
324
+ return m.create(t.ranges.map(e), t.mainIndex);
325
+ }
326
+ function I(t, e) {
327
+ return t.update({ selection: e, scrollIntoView: !0, userEvent: "select" });
328
+ }
329
+ function O({ state: t, dispatch: e }, r) {
330
+ let n = ie(t.selection, r);
331
+ return n.eq(t.selection, !0) ? !1 : (e(I(t, n)), !0);
332
+ }
333
+ function Oe(t, e) {
334
+ return m.cursor(e ? t.to : t.from);
335
+ }
336
+ function Yt(t, e) {
337
+ return O(t, (r) => r.empty ? t.moveByChar(r, e) : Oe(r, e));
338
+ }
339
+ function M(t) {
340
+ return t.textDirectionAt(t.state.selection.main.head) == Jn.LTR;
341
+ }
342
+ const Zt = (t) => Yt(t, !M(t)), Xt = (t) => Yt(t, M(t));
343
+ function en(t, e) {
344
+ return O(t, (r) => r.empty ? t.moveByGroup(r, e) : Oe(r, e));
345
+ }
346
+ const Hr = (t) => en(t, !M(t)), Ur = (t) => en(t, M(t));
347
+ function zr(t, e, r) {
348
+ if (e.type.prop(r))
349
+ return !0;
350
+ let n = e.to - e.from;
351
+ return n && (n > 2 || /[^\s,.;:]/.test(t.sliceDoc(e.from, e.to))) || e.firstChild;
352
+ }
353
+ function We(t, e, r) {
354
+ let n = nt(t).resolveInner(e.head), i = r ? $e.closedBy : $e.openedBy;
355
+ for (let a = e.head; ; ) {
356
+ let c = r ? n.childAfter(a) : n.childBefore(a);
357
+ if (!c)
358
+ break;
359
+ zr(t, c, i) ? n = c : a = r ? c.to : c.from;
360
+ }
361
+ let o = n.type.prop(i), s, l;
362
+ return o && (s = r ? te(t, n.from, 1) : te(t, n.to, -1)) && s.matched ? l = r ? s.end.to : s.end.from : l = r ? n.to : n.from, m.cursor(l, r ? -1 : 1);
363
+ }
364
+ const Gr = (t) => O(t, (e) => We(t.state, e, !M(t))), Kr = (t) => O(t, (e) => We(t.state, e, M(t)));
365
+ function tn(t, e) {
366
+ return O(t, (r) => {
367
+ if (!r.empty)
368
+ return Oe(r, e);
369
+ let n = t.moveVertically(r, e);
370
+ return n.head != r.head ? n : t.moveToLineBoundary(r, e);
371
+ });
372
+ }
373
+ const nn = (t) => tn(t, !1), rn = (t) => tn(t, !0);
374
+ function on(t) {
375
+ let e = t.scrollDOM.clientHeight < t.scrollDOM.scrollHeight - 2, r = 0, n = 0, i;
376
+ if (e) {
377
+ for (let o of t.state.facet(x.scrollMargins)) {
378
+ let s = o(t);
379
+ s != null && s.top && (r = Math.max(s == null ? void 0 : s.top, r)), s != null && s.bottom && (n = Math.max(s == null ? void 0 : s.bottom, n));
380
+ }
381
+ i = t.scrollDOM.clientHeight - r - n;
382
+ } else
383
+ i = (t.dom.ownerDocument.defaultView || window).innerHeight;
384
+ return {
385
+ marginTop: r,
386
+ marginBottom: n,
387
+ selfScroll: e,
388
+ height: Math.max(t.defaultLineHeight, i - 5)
389
+ };
390
+ }
391
+ function sn(t, e) {
392
+ let r = on(t), { state: n } = t, i = ie(n.selection, (s) => s.empty ? t.moveVertically(s, e, r.height) : Oe(s, e));
393
+ if (i.eq(n.selection))
394
+ return !1;
395
+ let o;
396
+ if (r.selfScroll) {
397
+ let s = t.coordsAtPos(n.selection.main.head), l = t.scrollDOM.getBoundingClientRect(), a = l.top + r.marginTop, c = l.bottom - r.marginBottom;
398
+ s && s.top > a && s.bottom < c && (o = x.scrollIntoView(i.main.head, { y: "start", yMargin: s.top - a }));
399
+ }
400
+ return t.dispatch(I(n, i), { effects: o }), !0;
401
+ }
402
+ const dt = (t) => sn(t, !1), je = (t) => sn(t, !0);
403
+ function U(t, e, r) {
404
+ let n = t.lineBlockAt(e.head), i = t.moveToLineBoundary(e, r);
405
+ if (i.head == e.head && i.head != (r ? n.to : n.from) && (i = t.moveToLineBoundary(e, r, !1)), !r && i.head == n.from && n.length) {
406
+ let o = /^\s*/.exec(t.state.sliceDoc(n.from, Math.min(n.from + 100, n.to)))[0].length;
407
+ o && e.head != n.from + o && (i = m.cursor(n.from + o));
408
+ }
409
+ return i;
410
+ }
411
+ const $r = (t) => O(t, (e) => U(t, e, !0)), Jr = (t) => O(t, (e) => U(t, e, !1)), _r = (t) => O(t, (e) => U(t, e, !M(t))), Qr = (t) => O(t, (e) => U(t, e, M(t))), jr = (t) => O(t, (e) => m.cursor(t.lineBlockAt(e.head).from, 1)), Yr = (t) => O(t, (e) => m.cursor(t.lineBlockAt(e.head).to, -1));
412
+ function Zr(t, e, r) {
413
+ let n = !1, i = ie(t.selection, (o) => {
414
+ let s = te(t, o.head, -1) || te(t, o.head, 1) || o.head > 0 && te(t, o.head - 1, 1) || o.head < t.doc.length && te(t, o.head + 1, -1);
415
+ if (!s || !s.end)
416
+ return o;
417
+ n = !0;
418
+ let l = s.start.from == o.head ? s.end.to : s.end.from;
419
+ return m.cursor(l);
420
+ });
421
+ return n ? (e(I(t, i)), !0) : !1;
422
+ }
423
+ const Xr = ({ state: t, dispatch: e }) => Zr(t, e);
424
+ function R(t, e) {
425
+ let r = ie(t.state.selection, (n) => {
426
+ let i = e(n);
427
+ return m.range(n.anchor, i.head, i.goalColumn, i.bidiLevel || void 0, i.assoc);
428
+ });
429
+ return r.eq(t.state.selection) ? !1 : (t.dispatch(I(t.state, r)), !0);
430
+ }
431
+ function ln(t, e) {
432
+ return R(t, (r) => t.moveByChar(r, e));
433
+ }
434
+ const an = (t) => ln(t, !M(t)), cn = (t) => ln(t, M(t));
435
+ function hn(t, e) {
436
+ return R(t, (r) => t.moveByGroup(r, e));
437
+ }
438
+ const ei = (t) => hn(t, !M(t)), ti = (t) => hn(t, M(t)), ni = (t) => R(t, (e) => We(t.state, e, !M(t))), ri = (t) => R(t, (e) => We(t.state, e, M(t)));
439
+ function un(t, e) {
440
+ return R(t, (r) => t.moveVertically(r, e));
441
+ }
442
+ const fn = (t) => un(t, !1), dn = (t) => un(t, !0);
443
+ function mn(t, e) {
444
+ return R(t, (r) => t.moveVertically(r, e, on(t).height));
445
+ }
446
+ const mt = (t) => mn(t, !1), gt = (t) => mn(t, !0), ii = (t) => R(t, (e) => U(t, e, !0)), oi = (t) => R(t, (e) => U(t, e, !1)), si = (t) => R(t, (e) => U(t, e, !M(t))), li = (t) => R(t, (e) => U(t, e, M(t))), ai = (t) => R(t, (e) => m.cursor(t.lineBlockAt(e.head).from)), ci = (t) => R(t, (e) => m.cursor(t.lineBlockAt(e.head).to)), pt = ({ state: t, dispatch: e }) => (e(I(t, { anchor: 0 })), !0), yt = ({ state: t, dispatch: e }) => (e(I(t, { anchor: t.doc.length })), !0), kt = ({ state: t, dispatch: e }) => (e(I(t, { anchor: t.selection.main.anchor, head: 0 })), !0), xt = ({ state: t, dispatch: e }) => (e(I(t, { anchor: t.selection.main.anchor, head: t.doc.length })), !0), hi = ({ state: t, dispatch: e }) => (e(t.update({ selection: { anchor: 0, head: t.doc.length }, userEvent: "select" })), !0), ui = ({ state: t, dispatch: e }) => {
447
+ let r = Pe(t).map(({ from: n, to: i }) => m.range(n, Math.min(i + 1, t.doc.length)));
448
+ return e(t.update({ selection: m.create(r), userEvent: "select" })), !0;
449
+ }, fi = ({ state: t, dispatch: e }) => {
450
+ let r = ie(t.selection, (n) => {
451
+ let i = nt(t), o = i.resolveStack(n.from, 1);
452
+ if (n.empty) {
453
+ let s = i.resolveStack(n.from, -1);
454
+ s.node.from >= o.node.from && s.node.to <= o.node.to && (o = s);
455
+ }
456
+ for (let s = o; s; s = s.next) {
457
+ let { node: l } = s;
458
+ if ((l.from < n.from && l.to >= n.to || l.to > n.to && l.from <= n.from) && s.next)
459
+ return m.range(l.to, l.from);
460
+ }
461
+ return n;
462
+ });
463
+ return r.eq(t.selection) ? !1 : (e(I(t, r)), !0);
464
+ };
465
+ function gn(t, e) {
466
+ let { state: r } = t, n = r.selection, i = r.selection.ranges.slice();
467
+ for (let o of r.selection.ranges) {
468
+ let s = r.doc.lineAt(o.head);
469
+ if (e ? s.to < t.state.doc.length : s.from > 0)
470
+ for (let l = o; ; ) {
471
+ let a = t.moveVertically(l, e);
472
+ if (a.head < s.from || a.head > s.to) {
473
+ i.some((c) => c.head == a.head) || i.push(a);
474
+ break;
475
+ } else {
476
+ if (a.head == l.head)
477
+ break;
478
+ l = a;
479
+ }
480
+ }
481
+ }
482
+ return i.length == n.ranges.length ? !1 : (t.dispatch(I(r, m.create(i, i.length - 1))), !0);
483
+ }
484
+ const di = (t) => gn(t, !1), mi = (t) => gn(t, !0), gi = ({ state: t, dispatch: e }) => {
485
+ let r = t.selection, n = null;
486
+ return r.ranges.length > 1 ? n = m.create([r.main]) : r.main.empty || (n = m.create([m.cursor(r.main.head)])), n ? (e(I(t, n)), !0) : !1;
487
+ };
488
+ function pe(t, e) {
489
+ if (t.state.readOnly)
490
+ return !1;
491
+ let r = "delete.selection", { state: n } = t, i = n.changeByRange((o) => {
492
+ let { from: s, to: l } = o;
493
+ if (s == l) {
494
+ let a = e(o);
495
+ a < s ? (r = "delete.backward", a = Se(t, a, !1)) : a > s && (r = "delete.forward", a = Se(t, a, !0)), s = Math.min(s, a), l = Math.max(l, a);
496
+ } else
497
+ s = Se(t, s, !1), l = Se(t, l, !0);
498
+ return s == l ? { range: o } : { changes: { from: s, to: l }, range: m.cursor(s, s < o.head ? -1 : 1) };
499
+ });
500
+ return i.changes.empty ? !1 : (t.dispatch(n.update(i, {
501
+ scrollIntoView: !0,
502
+ userEvent: r,
503
+ effects: r == "delete.selection" ? x.announce.of(n.phrase("Selection deleted")) : void 0
504
+ })), !0);
505
+ }
506
+ function Se(t, e, r) {
507
+ if (t instanceof x)
508
+ for (let n of t.state.facet(x.atomicRanges).map((i) => i(t)))
509
+ n.between(e, e, (i, o) => {
510
+ i < e && o > e && (e = r ? o : i);
511
+ });
512
+ return e;
513
+ }
514
+ const pn = (t, e, r) => pe(t, (n) => {
515
+ let i = n.from, { state: o } = t, s = o.doc.lineAt(i), l, a;
516
+ if (r && !e && i > s.from && i < s.from + 200 && !/[^ \t]/.test(l = s.text.slice(0, i - s.from))) {
517
+ if (l[l.length - 1] == " ")
518
+ return i - 1;
519
+ let c = tt(l, o.tabSize), h = c % Je(o) || Je(o);
520
+ for (let u = 0; u < h && l[l.length - 1 - u] == " "; u++)
521
+ i--;
522
+ a = i;
523
+ } else
524
+ a = _(s.text, i - s.from, e, e) + s.from, a == i && s.number != (e ? o.doc.lines : 1) ? a += e ? 1 : -1 : !e && /[\ufe00-\ufe0f]/.test(s.text.slice(a - s.from, i - s.from)) && (a = _(s.text, a - s.from, !1, !1) + s.from);
525
+ return a;
526
+ }), Ye = (t) => pn(t, !1, !0), yn = (t) => pn(t, !0, !1), kn = (t, e) => pe(t, (r) => {
527
+ let n = r.head, { state: i } = t, o = i.doc.lineAt(n), s = i.charCategorizer(n);
528
+ for (let l = null; ; ) {
529
+ if (n == (e ? o.to : o.from)) {
530
+ n == r.head && o.number != (e ? i.doc.lines : 1) && (n += e ? 1 : -1);
531
+ break;
532
+ }
533
+ let a = _(o.text, n - o.from, e) + o.from, c = o.text.slice(Math.min(n, a) - o.from, Math.max(n, a) - o.from), h = s(c);
534
+ if (l != null && h != l)
535
+ break;
536
+ (c != " " || n != r.head) && (l = h), n = a;
537
+ }
538
+ return n;
539
+ }), xn = (t) => kn(t, !1), pi = (t) => kn(t, !0), yi = (t) => pe(t, (e) => {
540
+ let r = t.lineBlockAt(e.head).to;
541
+ return e.head < r ? r : Math.min(t.state.doc.length, e.head + 1);
542
+ }), ki = (t) => pe(t, (e) => {
543
+ let r = t.moveToLineBoundary(e, !1).head;
544
+ return e.head > r ? r : Math.max(0, e.head - 1);
545
+ }), xi = (t) => pe(t, (e) => {
546
+ let r = t.moveToLineBoundary(e, !0).head;
547
+ return e.head < r ? r : Math.min(t.state.doc.length, e.head + 1);
548
+ }), Si = ({ state: t, dispatch: e }) => {
549
+ if (t.readOnly)
550
+ return !1;
551
+ let r = t.changeByRange((n) => ({
552
+ changes: { from: n.from, to: n.to, insert: Nt.of(["", ""]) },
553
+ range: m.cursor(n.from)
554
+ }));
555
+ return e(t.update(r, { scrollIntoView: !0, userEvent: "input" })), !0;
556
+ }, bi = ({ state: t, dispatch: e }) => {
557
+ if (t.readOnly)
558
+ return !1;
559
+ let r = t.changeByRange((n) => {
560
+ if (!n.empty || n.from == 0 || n.from == t.doc.length)
561
+ return { range: n };
562
+ let i = n.from, o = t.doc.lineAt(i), s = i == o.from ? i - 1 : _(o.text, i - o.from, !1) + o.from, l = i == o.to ? i + 1 : _(o.text, i - o.from, !0) + o.from;
563
+ return {
564
+ changes: { from: s, to: l, insert: t.doc.slice(i, l).append(t.doc.slice(s, i)) },
565
+ range: m.cursor(l)
566
+ };
567
+ });
568
+ return r.changes.empty ? !1 : (e(t.update(r, { scrollIntoView: !0, userEvent: "move.character" })), !0);
569
+ };
570
+ function Pe(t) {
571
+ let e = [], r = -1;
572
+ for (let n of t.selection.ranges) {
573
+ let i = t.doc.lineAt(n.from), o = t.doc.lineAt(n.to);
574
+ if (!n.empty && n.to == o.from && (o = t.doc.lineAt(n.to - 1)), r >= i.number) {
575
+ let s = e[e.length - 1];
576
+ s.to = o.to, s.ranges.push(n);
577
+ } else
578
+ e.push({ from: i.from, to: o.to, ranges: [n] });
579
+ r = o.number + 1;
580
+ }
581
+ return e;
582
+ }
583
+ function Sn(t, e, r) {
584
+ if (t.readOnly)
585
+ return !1;
586
+ let n = [], i = [];
587
+ for (let o of Pe(t)) {
588
+ if (r ? o.to == t.doc.length : o.from == 0)
589
+ continue;
590
+ let s = t.doc.lineAt(r ? o.to + 1 : o.from - 1), l = s.length + 1;
591
+ if (r) {
592
+ n.push({ from: o.to, to: s.to }, { from: o.from, insert: s.text + t.lineBreak });
593
+ for (let a of o.ranges)
594
+ i.push(m.range(Math.min(t.doc.length, a.anchor + l), Math.min(t.doc.length, a.head + l)));
595
+ } else {
596
+ n.push({ from: s.from, to: o.from }, { from: o.to, insert: t.lineBreak + s.text });
597
+ for (let a of o.ranges)
598
+ i.push(m.range(a.anchor - l, a.head - l));
599
+ }
600
+ }
601
+ return n.length ? (e(t.update({
602
+ changes: n,
603
+ scrollIntoView: !0,
604
+ selection: m.create(i, t.selection.mainIndex),
605
+ userEvent: "move.line"
606
+ })), !0) : !1;
607
+ }
608
+ const Ci = ({ state: t, dispatch: e }) => Sn(t, e, !1), vi = ({ state: t, dispatch: e }) => Sn(t, e, !0);
609
+ function bn(t, e, r) {
610
+ if (t.readOnly)
611
+ return !1;
612
+ let n = [];
613
+ for (let o of Pe(t))
614
+ r ? n.push({ from: o.from, insert: t.doc.slice(o.from, o.to) + t.lineBreak }) : n.push({ from: o.to, insert: t.lineBreak + t.doc.slice(o.from, o.to) });
615
+ let i = t.changes(n);
616
+ return e(t.update({
617
+ changes: i,
618
+ selection: t.selection.map(i, r ? 1 : -1),
619
+ scrollIntoView: !0,
620
+ userEvent: "input.copyline"
621
+ })), !0;
622
+ }
623
+ const Mi = ({ state: t, dispatch: e }) => bn(t, e, !1), Ai = ({ state: t, dispatch: e }) => bn(t, e, !0), Li = (t) => {
624
+ if (t.state.readOnly)
625
+ return !1;
626
+ let { state: e } = t, r = e.changes(Pe(e).map(({ from: i, to: o }) => (i > 0 ? i-- : o < e.doc.length && o++, { from: i, to: o }))), n = ie(e.selection, (i) => {
627
+ let o;
628
+ if (t.lineWrapping) {
629
+ let s = t.lineBlockAt(i.head), l = t.coordsAtPos(i.head, i.assoc || 1);
630
+ l && (o = s.bottom + t.documentTop - l.bottom + t.defaultLineHeight / 2);
631
+ }
632
+ return t.moveVertically(i, !0, o);
633
+ }).map(r);
634
+ return t.dispatch({ changes: r, selection: n, scrollIntoView: !0, userEvent: "delete.line" }), !0;
635
+ };
636
+ function Bi(t, e) {
637
+ if (/\(\)|\[\]|\{\}/.test(t.sliceDoc(e - 1, e + 1)))
638
+ return { from: e, to: e };
639
+ let r = nt(t).resolveInner(e), n = r.childBefore(e), i = r.childAfter(e), o;
640
+ return n && i && n.to <= e && i.from >= e && (o = n.type.prop($e.closedBy)) && o.indexOf(i.name) > -1 && t.doc.lineAt(n.to).from == t.doc.lineAt(i.from).from && !/\S/.test(t.sliceDoc(n.to, i.from)) ? { from: n.to, to: i.from } : null;
641
+ }
642
+ const St = /* @__PURE__ */ Cn(!1), Di = /* @__PURE__ */ Cn(!0);
643
+ function Cn(t) {
644
+ return ({ state: e, dispatch: r }) => {
645
+ if (e.readOnly)
646
+ return !1;
647
+ let n = e.changeByRange((i) => {
648
+ let { from: o, to: s } = i, l = e.doc.lineAt(o), a = !t && o == s && Bi(e, o);
649
+ t && (o = s = (s <= l.to ? l : e.doc.lineAt(s)).to);
650
+ let c = new Pt(e, { simulateBreak: o, simulateDoubleBreak: !!a }), h = Ft(c, o);
651
+ for (h == null && (h = tt(/^\s*/.exec(e.doc.lineAt(o).text)[0], e.tabSize)); s < l.to && /\s/.test(l.text[s - l.from]); )
652
+ s++;
653
+ a ? { from: o, to: s } = a : o > l.from && o < l.from + 100 && !/\S/.test(l.text.slice(0, o)) && (o = l.from);
654
+ let u = ["", Ae(e, h)];
655
+ return a && u.push(Ae(e, c.lineIndent(l.from, -1))), {
656
+ changes: { from: o, to: s, insert: Nt.of(u) },
657
+ range: m.cursor(o + 1 + u[1].length)
658
+ };
659
+ });
660
+ return r(e.update(n, { scrollIntoView: !0, userEvent: "input" })), !0;
661
+ };
662
+ }
663
+ function lt(t, e) {
664
+ let r = -1;
665
+ return t.changeByRange((n) => {
666
+ let i = [];
667
+ for (let s = n.from; s <= n.to; ) {
668
+ let l = t.doc.lineAt(s);
669
+ l.number > r && (n.empty || n.to > l.from) && (e(l, i, n), r = l.number), s = l.to + 1;
670
+ }
671
+ let o = t.changes(i);
672
+ return {
673
+ changes: i,
674
+ range: m.range(o.mapPos(n.anchor, 1), o.mapPos(n.head, 1))
675
+ };
676
+ });
677
+ }
678
+ const Ei = ({ state: t, dispatch: e }) => {
679
+ if (t.readOnly)
680
+ return !1;
681
+ let r = /* @__PURE__ */ Object.create(null), n = new Pt(t, { overrideIndentation: (o) => {
682
+ let s = r[o];
683
+ return s ?? -1;
684
+ } }), i = lt(t, (o, s, l) => {
685
+ let a = Ft(n, o.from);
686
+ if (a == null)
687
+ return;
688
+ /\S/.test(o.text) || (a = 0);
689
+ let c = /^\s*/.exec(o.text)[0], h = Ae(t, a);
690
+ (c != h || l.from < o.from + c.length) && (r[o.from] = a, s.push({ from: o.from, to: o.from + c.length, insert: h }));
691
+ });
692
+ return i.changes.empty || e(t.update(i, { userEvent: "indent" })), !0;
693
+ }, vn = ({ state: t, dispatch: e }) => t.readOnly ? !1 : (e(t.update(lt(t, (r, n) => {
694
+ n.push({ from: r.from, insert: t.facet(qt) });
695
+ }), { userEvent: "input.indent" })), !0), Mn = ({ state: t, dispatch: e }) => t.readOnly ? !1 : (e(t.update(lt(t, (r, n) => {
696
+ let i = /^\s*/.exec(r.text)[0];
697
+ if (!i)
698
+ return;
699
+ let o = tt(i, t.tabSize), s = 0, l = Ae(t, Math.max(0, o - Je(t)));
700
+ for (; s < i.length && s < l.length && i.charCodeAt(s) == l.charCodeAt(s); )
701
+ s++;
702
+ n.push({ from: r.from + s, to: r.from + i.length, insert: l.slice(s) });
703
+ }), { userEvent: "delete.dedent" })), !0), Ti = (t) => (t.setTabFocusMode(), !0), wi = [
704
+ { key: "Ctrl-b", run: Zt, shift: an, preventDefault: !0 },
705
+ { key: "Ctrl-f", run: Xt, shift: cn },
706
+ { key: "Ctrl-p", run: nn, shift: fn },
707
+ { key: "Ctrl-n", run: rn, shift: dn },
708
+ { key: "Ctrl-a", run: jr, shift: ai },
709
+ { key: "Ctrl-e", run: Yr, shift: ci },
710
+ { key: "Ctrl-d", run: yn },
711
+ { key: "Ctrl-h", run: Ye },
712
+ { key: "Ctrl-k", run: yi },
713
+ { key: "Ctrl-Alt-h", run: xn },
714
+ { key: "Ctrl-o", run: Si },
715
+ { key: "Ctrl-t", run: bi },
716
+ { key: "Ctrl-v", run: je }
717
+ ], Ri = /* @__PURE__ */ [
718
+ { key: "ArrowLeft", run: Zt, shift: an, preventDefault: !0 },
719
+ { key: "Mod-ArrowLeft", mac: "Alt-ArrowLeft", run: Hr, shift: ei, preventDefault: !0 },
720
+ { mac: "Cmd-ArrowLeft", run: _r, shift: si, preventDefault: !0 },
721
+ { key: "ArrowRight", run: Xt, shift: cn, preventDefault: !0 },
722
+ { key: "Mod-ArrowRight", mac: "Alt-ArrowRight", run: Ur, shift: ti, preventDefault: !0 },
723
+ { mac: "Cmd-ArrowRight", run: Qr, shift: li, preventDefault: !0 },
724
+ { key: "ArrowUp", run: nn, shift: fn, preventDefault: !0 },
725
+ { mac: "Cmd-ArrowUp", run: pt, shift: kt },
726
+ { mac: "Ctrl-ArrowUp", run: dt, shift: mt },
727
+ { key: "ArrowDown", run: rn, shift: dn, preventDefault: !0 },
728
+ { mac: "Cmd-ArrowDown", run: yt, shift: xt },
729
+ { mac: "Ctrl-ArrowDown", run: je, shift: gt },
730
+ { key: "PageUp", run: dt, shift: mt },
731
+ { key: "PageDown", run: je, shift: gt },
732
+ { key: "Home", run: Jr, shift: oi, preventDefault: !0 },
733
+ { key: "Mod-Home", run: pt, shift: kt },
734
+ { key: "End", run: $r, shift: ii, preventDefault: !0 },
735
+ { key: "Mod-End", run: yt, shift: xt },
736
+ { key: "Enter", run: St, shift: St },
737
+ { key: "Mod-a", run: hi },
738
+ { key: "Backspace", run: Ye, shift: Ye, preventDefault: !0 },
739
+ { key: "Delete", run: yn, preventDefault: !0 },
740
+ { key: "Mod-Backspace", mac: "Alt-Backspace", run: xn, preventDefault: !0 },
741
+ { key: "Mod-Delete", mac: "Alt-Delete", run: pi, preventDefault: !0 },
742
+ { mac: "Mod-Backspace", run: ki, preventDefault: !0 },
743
+ { mac: "Mod-Delete", run: xi, preventDefault: !0 }
744
+ ].concat(/* @__PURE__ */ wi.map((t) => ({ mac: t.key, run: t.run, shift: t.shift }))), Ii = /* @__PURE__ */ [
745
+ { key: "Alt-ArrowLeft", mac: "Ctrl-ArrowLeft", run: Gr, shift: ni },
746
+ { key: "Alt-ArrowRight", mac: "Ctrl-ArrowRight", run: Kr, shift: ri },
747
+ { key: "Alt-ArrowUp", run: Ci },
748
+ { key: "Shift-Alt-ArrowUp", run: Mi },
749
+ { key: "Alt-ArrowDown", run: vi },
750
+ { key: "Shift-Alt-ArrowDown", run: Ai },
751
+ { key: "Mod-Alt-ArrowUp", run: di },
752
+ { key: "Mod-Alt-ArrowDown", run: mi },
753
+ { key: "Escape", run: gi },
754
+ { key: "Mod-Enter", run: Di },
755
+ { key: "Alt-l", mac: "Ctrl-l", run: ui },
756
+ { key: "Mod-i", run: fi, preventDefault: !0 },
757
+ { key: "Mod-[", run: Mn },
758
+ { key: "Mod-]", run: vn },
759
+ { key: "Mod-Alt-\\", run: Ei },
760
+ { key: "Shift-Mod-k", run: Li },
761
+ { key: "Shift-Mod-\\", run: Xr },
762
+ { key: "Mod-/", run: Cr },
763
+ { key: "Alt-A", run: Mr },
764
+ { key: "Ctrl-m", mac: "Shift-Alt-m", run: Ti }
765
+ ].concat(Ri), Oi = { key: "Tab", run: vn, shift: Mn }, bt = typeof String.prototype.normalize == "function" ? (t) => t.normalize("NFKD") : (t) => t;
766
+ class re {
767
+ /**
768
+ Create a text cursor. The query is the search string, `from` to
769
+ `to` provides the region to search.
770
+
771
+ When `normalize` is given, it will be called, on both the query
772
+ string and the content it is matched against, before comparing.
773
+ You can, for example, create a case-insensitive search by
774
+ passing `s => s.toLowerCase()`.
775
+
776
+ Text is always normalized with
777
+ [`.normalize("NFKD")`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
778
+ (when supported).
779
+ */
780
+ constructor(e, r, n = 0, i = e.length, o, s) {
781
+ this.test = s, this.value = { from: 0, to: 0, precise: !1 }, this.done = !1, this.matches = [], this.buffer = "", this.bufferPos = 0, this.iter = e.iterRange(n, i), this.bufferStart = n, this.normalize = o ? (l) => o(bt(l)) : bt, this.query = this.normalize(r);
782
+ }
783
+ peek() {
784
+ if (this.bufferPos == this.buffer.length) {
785
+ if (this.bufferStart += this.buffer.length, this.iter.next(), this.iter.done)
786
+ return -1;
787
+ this.bufferPos = 0, this.buffer = this.iter.value;
788
+ }
789
+ return jn(this.buffer, this.bufferPos);
790
+ }
791
+ /**
792
+ Look for the next match. Updates the iterator's
793
+ [`value`](https://codemirror.net/6/docs/ref/#search.SearchCursor.value) and
794
+ [`done`](https://codemirror.net/6/docs/ref/#search.SearchCursor.done) properties. Should be called
795
+ at least once before using the cursor.
796
+ */
797
+ next() {
798
+ for (; this.matches.length; )
799
+ this.matches.pop();
800
+ return this.nextOverlapping();
801
+ }
802
+ /**
803
+ The `next` method will ignore matches that partially overlap a
804
+ previous match. This method behaves like `next`, but includes
805
+ such matches.
806
+ */
807
+ nextOverlapping() {
808
+ for (; ; ) {
809
+ let e = this.peek();
810
+ if (e < 0)
811
+ return this.done = !0, this;
812
+ let r = Zn(e), n = this.bufferStart + this.bufferPos;
813
+ this.bufferPos += Yn(e);
814
+ let i = this.normalize(r);
815
+ if (i.length)
816
+ for (let o = 0, s = n, l = !0; ; o++) {
817
+ let a = i.charCodeAt(o), c = this.match(a, s, l, this.bufferPos + this.bufferStart, o == i.length - 1);
818
+ if (c)
819
+ return this.value = c, this;
820
+ if (o == i.length - 1)
821
+ break;
822
+ l && o < r.length && r.charCodeAt(o) == a ? s++ : l = !1;
823
+ }
824
+ }
825
+ }
826
+ match(e, r, n, i, o) {
827
+ let s = null;
828
+ for (let l = 0; l < this.matches.length; ) {
829
+ let a = this.matches[l], c = !1;
830
+ this.query.charCodeAt(a.index) == e && (a.index == this.query.length - 1 ? s = { from: a.from, to: i, precise: o && a.precise } : (a.index++, c = !0)), c ? l++ : this.matches.splice(l, 1);
831
+ }
832
+ return this.query.charCodeAt(0) == e && (this.query.length == 1 ? s = { from: r, to: i, precise: n && o } : this.matches.push({ from: r, index: 1, precise: n })), s && this.test && !this.test(s.from, s.to, this.buffer, this.bufferStart) && (s = null), s;
833
+ }
834
+ }
835
+ typeof Symbol < "u" && (re.prototype[Symbol.iterator] = function() {
836
+ return this;
837
+ });
838
+ const An = { from: -1, to: -1, match: /* @__PURE__ */ /.*/.exec(""), precise: !0 }, at = "gm" + (/x/.unicode == null ? "" : "u");
839
+ class Ln {
840
+ /**
841
+ Create a cursor that will search the given range in the given
842
+ document. `query` should be the raw pattern (as you'd pass it to
843
+ `new RegExp`).
844
+ */
845
+ constructor(e, r, n, i = 0, o = e.length) {
846
+ if (this.text = e, this.to = o, this.curLine = "", this.done = !1, this.value = An, /\\[sWDnr]|\n|\r|\[\^/.test(r))
847
+ return new Bn(e, r, n, i, o);
848
+ this.re = new RegExp(r, at + (n != null && n.ignoreCase ? "i" : "")), this.test = n == null ? void 0 : n.test, this.iter = e.iter();
849
+ let s = e.lineAt(i);
850
+ this.curLineStart = s.from, this.matchPos = Be(e, i), this.getLine(this.curLineStart);
851
+ }
852
+ getLine(e) {
853
+ this.iter.next(e), this.iter.lineBreak ? this.curLine = "" : (this.curLine = this.iter.value, this.curLineStart + this.curLine.length > this.to && (this.curLine = this.curLine.slice(0, this.to - this.curLineStart)), this.iter.next());
854
+ }
855
+ nextLine() {
856
+ this.curLineStart = this.curLineStart + this.curLine.length + 1, this.curLineStart > this.to ? this.curLine = "" : this.getLine(0);
857
+ }
858
+ /**
859
+ Move to the next match, if there is one.
860
+ */
861
+ next() {
862
+ for (let e = this.matchPos - this.curLineStart; ; ) {
863
+ this.re.lastIndex = e;
864
+ let r = this.matchPos <= this.to && this.re.exec(this.curLine);
865
+ if (r) {
866
+ let n = this.curLineStart + r.index, i = n + r[0].length;
867
+ if (this.matchPos = Be(this.text, i + (n == i ? 1 : 0)), n == this.curLineStart + this.curLine.length && this.nextLine(), (n < i || n > this.value.to) && (!this.test || this.test(n, i, r)))
868
+ return this.value = { from: n, to: i, precise: !0, match: r }, this;
869
+ e = this.matchPos - this.curLineStart;
870
+ } else if (this.curLineStart + this.curLine.length < this.to)
871
+ this.nextLine(), e = 0;
872
+ else
873
+ return this.done = !0, this;
874
+ }
875
+ }
876
+ }
877
+ const Ue = /* @__PURE__ */ new WeakMap();
878
+ class ne {
879
+ constructor(e, r) {
880
+ this.from = e, this.text = r;
881
+ }
882
+ get to() {
883
+ return this.from + this.text.length;
884
+ }
885
+ static get(e, r, n) {
886
+ let i = Ue.get(e);
887
+ if (!i || i.from >= n || i.to <= r) {
888
+ let l = new ne(r, e.sliceString(r, n));
889
+ return Ue.set(e, l), l;
890
+ }
891
+ if (i.from == r && i.to == n)
892
+ return i;
893
+ let { text: o, from: s } = i;
894
+ return s > r && (o = e.sliceString(r, s) + o, s = r), i.to < n && (o += e.sliceString(i.to, n)), Ue.set(e, new ne(s, o)), new ne(r, o.slice(r - s, n - s));
895
+ }
896
+ }
897
+ class Bn {
898
+ constructor(e, r, n, i, o) {
899
+ this.text = e, this.to = o, this.done = !1, this.value = An, this.matchPos = Be(e, i), this.re = new RegExp(r, at + (n != null && n.ignoreCase ? "i" : "")), this.test = n == null ? void 0 : n.test, this.flat = ne.get(e, i, this.chunkEnd(
900
+ i + 5e3
901
+ /* Chunk.Base */
902
+ ));
903
+ }
904
+ chunkEnd(e) {
905
+ return e >= this.to ? this.to : this.text.lineAt(e).to;
906
+ }
907
+ next() {
908
+ for (; ; ) {
909
+ let e = this.re.lastIndex = this.matchPos - this.flat.from, r = this.re.exec(this.flat.text);
910
+ if (r && !r[0] && r.index == e && (this.re.lastIndex = e + 1, r = this.re.exec(this.flat.text)), r) {
911
+ let n = this.flat.from + r.index, i = n + r[0].length;
912
+ if ((this.flat.to >= this.to || r.index + r[0].length <= this.flat.text.length - 10) && (!this.test || this.test(n, i, r)))
913
+ return this.value = { from: n, to: i, precise: !0, match: r }, this.matchPos = Be(this.text, i + (n == i ? 1 : 0)), this;
914
+ }
915
+ if (this.flat.to == this.to)
916
+ return this.done = !0, this;
917
+ this.flat = ne.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
918
+ }
919
+ }
920
+ }
921
+ typeof Symbol < "u" && (Ln.prototype[Symbol.iterator] = Bn.prototype[Symbol.iterator] = function() {
922
+ return this;
923
+ });
924
+ function Wi(t) {
925
+ try {
926
+ return new RegExp(t, at), !0;
927
+ } catch {
928
+ return !1;
929
+ }
930
+ }
931
+ function Be(t, e) {
932
+ if (e >= t.length)
933
+ return e;
934
+ let r = t.lineAt(e), n;
935
+ for (; e < r.to && (n = r.text.charCodeAt(e - r.from)) >= 56320 && n < 57344; )
936
+ e++;
937
+ return e;
938
+ }
939
+ const Pi = (t) => {
940
+ let { state: e } = t, r = String(e.doc.lineAt(t.state.selection.main.head).number), { close: n, result: i } = _n(t, {
941
+ label: e.phrase("Go to line"),
942
+ input: { type: "text", name: "line", value: r },
943
+ focus: !0,
944
+ submitLabel: e.phrase("go")
945
+ });
946
+ return i.then((o) => {
947
+ let s = o && /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(o.elements.line.value);
948
+ if (!s) {
949
+ t.dispatch({ effects: n });
950
+ return;
951
+ }
952
+ let l = e.doc.lineAt(e.selection.main.head), [, a, c, h, u] = s, d = h ? +h.slice(1) : 0, g = c ? +c : l.number;
953
+ if (c && u) {
954
+ let k = g / 100;
955
+ a && (k = k * (a == "-" ? -1 : 1) + l.number / e.doc.lines), g = Math.round(e.doc.lines * k);
956
+ } else c && a && (g = g * (a == "-" ? -1 : 1) + l.number);
957
+ let p = e.doc.line(Math.max(1, Math.min(e.doc.lines, g))), S = m.cursor(p.from + Math.max(0, Math.min(d, p.length)));
958
+ t.dispatch({
959
+ effects: [n, x.scrollIntoView(S.from, { y: "center" })],
960
+ selection: S
961
+ });
962
+ }), !0;
963
+ }, Fi = {
964
+ highlightWordAroundCursor: !1,
965
+ minSelectionLength: 1,
966
+ maxMatches: 100,
967
+ wholeWords: !1
968
+ }, Ni = /* @__PURE__ */ ge.define({
969
+ combine(t) {
970
+ return Re(t, Fi, {
971
+ highlightWordAroundCursor: (e, r) => e || r,
972
+ minSelectionLength: Math.min,
973
+ maxMatches: Math.min
974
+ });
975
+ }
976
+ });
977
+ function qi(t) {
978
+ return [Gi, zi];
979
+ }
980
+ const Vi = /* @__PURE__ */ v.mark({ class: "cm-selectionMatch" }), Hi = /* @__PURE__ */ v.mark({ class: "cm-selectionMatch cm-selectionMatch-main" });
981
+ function Ct(t, e, r, n) {
982
+ return (r == 0 || t(e.sliceDoc(r - 1, r)) != T.Word) && (n == e.doc.length || t(e.sliceDoc(n, n + 1)) != T.Word);
983
+ }
984
+ function Ui(t, e, r, n) {
985
+ return t(e.sliceDoc(r, r + 1)) == T.Word && t(e.sliceDoc(n - 1, n)) == T.Word;
986
+ }
987
+ const zi = /* @__PURE__ */ Ht.fromClass(class {
988
+ constructor(t) {
989
+ this.decorations = this.getDeco(t);
990
+ }
991
+ update(t) {
992
+ (t.selectionSet || t.docChanged || t.viewportChanged) && (this.decorations = this.getDeco(t.view));
993
+ }
994
+ getDeco(t) {
995
+ let e = t.state.facet(Ni), { state: r } = t, n = r.selection;
996
+ if (n.ranges.length > 1)
997
+ return v.none;
998
+ let i = n.main, o, s = null;
999
+ if (i.empty) {
1000
+ if (!e.highlightWordAroundCursor)
1001
+ return v.none;
1002
+ let a = r.wordAt(i.head);
1003
+ if (!a)
1004
+ return v.none;
1005
+ s = r.charCategorizer(i.head), o = r.sliceDoc(a.from, a.to);
1006
+ } else {
1007
+ let a = i.to - i.from;
1008
+ if (a < e.minSelectionLength || a > 200)
1009
+ return v.none;
1010
+ if (e.wholeWords) {
1011
+ if (o = r.sliceDoc(i.from, i.to), s = r.charCategorizer(i.head), !(Ct(s, r, i.from, i.to) && Ui(s, r, i.from, i.to)))
1012
+ return v.none;
1013
+ } else if (o = r.sliceDoc(i.from, i.to), !o)
1014
+ return v.none;
1015
+ }
1016
+ let l = [];
1017
+ for (let a of t.visibleRanges) {
1018
+ let c = new re(r.doc, o, a.from, a.to);
1019
+ for (; !c.next().done; ) {
1020
+ let { from: h, to: u } = c.value;
1021
+ if ((!s || Ct(s, r, h, u)) && (i.empty && h <= i.from && u >= i.to ? l.push(Hi.range(h, u)) : (h >= i.to || u <= i.from) && l.push(Vi.range(h, u)), l.length > e.maxMatches))
1022
+ return v.none;
1023
+ }
1024
+ }
1025
+ return v.set(l);
1026
+ }
1027
+ }, {
1028
+ decorations: (t) => t.decorations
1029
+ }), Gi = /* @__PURE__ */ x.baseTheme({
1030
+ ".cm-selectionMatch": { backgroundColor: "#99ff7780" },
1031
+ ".cm-searchMatch .cm-selectionMatch": { backgroundColor: "transparent" }
1032
+ }), Ki = ({ state: t, dispatch: e }) => {
1033
+ let { selection: r } = t, n = m.create(r.ranges.map((i) => t.wordAt(i.head) || m.cursor(i.head)), r.mainIndex);
1034
+ return n.eq(r) ? !1 : (e(t.update({ selection: n })), !0);
1035
+ };
1036
+ function $i(t, e) {
1037
+ let { main: r, ranges: n } = t.selection, i = t.wordAt(r.head), o = i && i.from == r.from && i.to == r.to;
1038
+ for (let s = !1, l = new re(t.doc, e, n[n.length - 1].to); ; )
1039
+ if (l.next(), l.done) {
1040
+ if (s)
1041
+ return null;
1042
+ l = new re(t.doc, e, 0, Math.max(0, n[n.length - 1].from - 1)), s = !0;
1043
+ } else {
1044
+ if (s && n.some((a) => a.from == l.value.from))
1045
+ continue;
1046
+ if (o) {
1047
+ let a = t.wordAt(l.value.from);
1048
+ if (!a || a.from != l.value.from || a.to != l.value.to)
1049
+ continue;
1050
+ }
1051
+ return l.value;
1052
+ }
1053
+ }
1054
+ const Ji = ({ state: t, dispatch: e }) => {
1055
+ let { ranges: r } = t.selection;
1056
+ if (r.some((o) => o.from === o.to))
1057
+ return Ki({ state: t, dispatch: e });
1058
+ let n = t.sliceDoc(r[0].from, r[0].to);
1059
+ if (t.selection.ranges.some((o) => t.sliceDoc(o.from, o.to) != n))
1060
+ return !1;
1061
+ let i = $i(t, n);
1062
+ return i ? (e(t.update({
1063
+ selection: t.selection.addRange(m.range(i.from, i.to), !1),
1064
+ effects: x.scrollIntoView(i.to)
1065
+ })), !0) : !1;
1066
+ }, oe = /* @__PURE__ */ ge.define({
1067
+ combine(t) {
1068
+ return Re(t, {
1069
+ top: !1,
1070
+ caseSensitive: !1,
1071
+ literal: !1,
1072
+ regexp: !1,
1073
+ wholeWord: !1,
1074
+ createPanel: (e) => new lo(e),
1075
+ scrollToMatch: (e) => x.scrollIntoView(e)
1076
+ });
1077
+ }
1078
+ });
1079
+ class Dn {
1080
+ /**
1081
+ Create a query object.
1082
+ */
1083
+ constructor(e) {
1084
+ this.search = e.search, this.caseSensitive = !!e.caseSensitive, this.literal = !!e.literal, this.regexp = !!e.regexp, this.replace = e.replace || "", this.valid = !!this.search && (!this.regexp || Wi(this.search)), this.unquoted = this.unquote(this.search), this.wholeWord = !!e.wholeWord, this.test = e.test;
1085
+ }
1086
+ /**
1087
+ @internal
1088
+ */
1089
+ unquote(e) {
1090
+ return this.literal ? e : e.replace(/\\([nrt\\])/g, (r, n) => n == "n" ? `
1091
+ ` : n == "r" ? "\r" : n == "t" ? " " : "\\");
1092
+ }
1093
+ /**
1094
+ Compare this query to another query.
1095
+ */
1096
+ eq(e) {
1097
+ return this.search == e.search && this.replace == e.replace && this.caseSensitive == e.caseSensitive && this.regexp == e.regexp && this.wholeWord == e.wholeWord && this.test == e.test;
1098
+ }
1099
+ /**
1100
+ @internal
1101
+ */
1102
+ create() {
1103
+ return this.regexp ? new Xi(this) : new ji(this);
1104
+ }
1105
+ /**
1106
+ Get a search cursor for this query, searching through the given
1107
+ range in the given state.
1108
+ */
1109
+ getCursor(e, r = 0, n) {
1110
+ let i = e.doc ? e : ue.create({ doc: e });
1111
+ return n == null && (n = i.doc.length), this.regexp ? ee(this, i, r, n) : X(this, i, r, n);
1112
+ }
1113
+ }
1114
+ class En {
1115
+ constructor(e) {
1116
+ this.spec = e;
1117
+ }
1118
+ }
1119
+ function _i(t, e, r) {
1120
+ return (n, i, o, s) => {
1121
+ if (r && !r(n, i, o, s))
1122
+ return !1;
1123
+ let l = n >= s && i <= s + o.length ? o.slice(n - s, i - s) : e.doc.sliceString(n, i);
1124
+ return t(l, e, n, i);
1125
+ };
1126
+ }
1127
+ function X(t, e, r, n) {
1128
+ let i;
1129
+ return t.wholeWord && (i = Qi(e.doc, e.charCategorizer(e.selection.main.head))), t.test && (i = _i(t.test, e, i)), new re(e.doc, t.unquoted, r, n, t.caseSensitive ? void 0 : (o) => o.toLowerCase(), i);
1130
+ }
1131
+ function Qi(t, e) {
1132
+ return (r, n, i, o) => ((o > r || o + i.length < n) && (o = Math.max(0, r - 2), i = t.sliceString(o, Math.min(t.length, n + 2))), (e(De(i, r - o)) != T.Word || e(Ee(i, r - o)) != T.Word) && (e(Ee(i, n - o)) != T.Word || e(De(i, n - o)) != T.Word));
1133
+ }
1134
+ class ji extends En {
1135
+ constructor(e) {
1136
+ super(e);
1137
+ }
1138
+ nextMatch(e, r, n) {
1139
+ let i = X(this.spec, e, n, e.doc.length).nextOverlapping();
1140
+ if (i.done) {
1141
+ let o = Math.min(e.doc.length, r + this.spec.unquoted.length);
1142
+ i = X(this.spec, e, 0, o).nextOverlapping();
1143
+ }
1144
+ return i.done || i.value.from == r && i.value.to == n ? null : i.value;
1145
+ }
1146
+ // Searching in reverse is, rather than implementing an inverted search
1147
+ // cursor, done by scanning chunk after chunk forward.
1148
+ prevMatchInRange(e, r, n) {
1149
+ for (let i = n; ; ) {
1150
+ let o = Math.max(r, i - 1e4 - this.spec.unquoted.length), s = X(this.spec, e, o, i), l = null;
1151
+ for (; !s.nextOverlapping().done; )
1152
+ l = s.value;
1153
+ if (l)
1154
+ return l;
1155
+ if (o == r)
1156
+ return null;
1157
+ i -= 1e4;
1158
+ }
1159
+ }
1160
+ prevMatch(e, r, n) {
1161
+ let i = this.prevMatchInRange(e, 0, r);
1162
+ return i || (i = this.prevMatchInRange(e, Math.max(0, n - this.spec.unquoted.length), e.doc.length)), i && (i.from != r || i.to != n) ? i : null;
1163
+ }
1164
+ getReplacement(e) {
1165
+ return this.spec.unquote(this.spec.replace);
1166
+ }
1167
+ matchAll(e, r) {
1168
+ let n = X(this.spec, e, 0, e.doc.length), i = [];
1169
+ for (; !n.next().done; ) {
1170
+ if (i.length >= r)
1171
+ return null;
1172
+ i.push(n.value);
1173
+ }
1174
+ return i;
1175
+ }
1176
+ highlight(e, r, n, i) {
1177
+ let o = X(this.spec, e, Math.max(0, r - this.spec.unquoted.length), Math.min(n + this.spec.unquoted.length, e.doc.length));
1178
+ for (; !o.next().done; )
1179
+ i(o.value.from, o.value.to);
1180
+ }
1181
+ }
1182
+ function Yi(t, e, r) {
1183
+ return (n, i, o) => (!r || r(n, i, o)) && t(o[0], e, n, i);
1184
+ }
1185
+ function ee(t, e, r, n) {
1186
+ let i;
1187
+ return t.wholeWord && (i = Zi(e.charCategorizer(e.selection.main.head))), t.test && (i = Yi(t.test, e, i)), new Ln(e.doc, t.search, { ignoreCase: !t.caseSensitive, test: i }, r, n);
1188
+ }
1189
+ function De(t, e) {
1190
+ return t.slice(_(t, e, !1), e);
1191
+ }
1192
+ function Ee(t, e) {
1193
+ return t.slice(e, _(t, e));
1194
+ }
1195
+ function Zi(t) {
1196
+ return (e, r, n) => !n[0].length || (t(De(n.input, n.index)) != T.Word || t(Ee(n.input, n.index)) != T.Word) && (t(Ee(n.input, n.index + n[0].length)) != T.Word || t(De(n.input, n.index + n[0].length)) != T.Word);
1197
+ }
1198
+ class Xi extends En {
1199
+ nextMatch(e, r, n) {
1200
+ let i = ee(this.spec, e, n, e.doc.length).next();
1201
+ return i.done && (i = ee(this.spec, e, 0, r).next()), i.done ? null : i.value;
1202
+ }
1203
+ prevMatchInRange(e, r, n) {
1204
+ for (let i = 1; ; i++) {
1205
+ let o = Math.max(
1206
+ r,
1207
+ n - i * 1e4
1208
+ /* FindPrev.ChunkSize */
1209
+ ), s = ee(this.spec, e, o, n), l = null;
1210
+ for (; !s.next().done; )
1211
+ l = s.value;
1212
+ if (l && (o == r || l.from > o + 10))
1213
+ return l;
1214
+ if (o == r)
1215
+ return null;
1216
+ }
1217
+ }
1218
+ prevMatch(e, r, n) {
1219
+ return this.prevMatchInRange(e, 0, r) || this.prevMatchInRange(e, n, e.doc.length);
1220
+ }
1221
+ getReplacement(e) {
1222
+ return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g, (r, n) => {
1223
+ if (n == "&")
1224
+ return e.match[0];
1225
+ if (n == "$")
1226
+ return "$";
1227
+ for (let i = n.length; i > 0; i--) {
1228
+ let o = +n.slice(0, i);
1229
+ if (o > 0 && o < e.match.length)
1230
+ return e.match[o] + n.slice(i);
1231
+ }
1232
+ return r;
1233
+ });
1234
+ }
1235
+ matchAll(e, r) {
1236
+ let n = ee(this.spec, e, 0, e.doc.length), i = [];
1237
+ for (; !n.next().done; ) {
1238
+ if (i.length >= r)
1239
+ return null;
1240
+ i.push(n.value);
1241
+ }
1242
+ return i;
1243
+ }
1244
+ highlight(e, r, n, i) {
1245
+ let o = ee(this.spec, e, Math.max(
1246
+ 0,
1247
+ r - 250
1248
+ /* RegExp.HighlightMargin */
1249
+ ), Math.min(n + 250, e.doc.length));
1250
+ for (; !o.next().done; )
1251
+ i(o.value.from, o.value.to);
1252
+ }
1253
+ }
1254
+ const fe = /* @__PURE__ */ F.define(), ct = /* @__PURE__ */ F.define(), V = /* @__PURE__ */ et.define({
1255
+ create(t) {
1256
+ return new ze(Ze(t).create(), null);
1257
+ },
1258
+ update(t, e) {
1259
+ for (let r of e.effects)
1260
+ r.is(fe) ? t = new ze(r.value.create(), t.panel) : r.is(ct) && (t = new ze(t.query, r.value ? ht : null));
1261
+ return t;
1262
+ },
1263
+ provide: (t) => Vt.from(t, (e) => e.panel)
1264
+ });
1265
+ class ze {
1266
+ constructor(e, r) {
1267
+ this.query = e, this.panel = r;
1268
+ }
1269
+ }
1270
+ const eo = /* @__PURE__ */ v.mark({ class: "cm-searchMatch" }), to = /* @__PURE__ */ v.mark({ class: "cm-searchMatch cm-searchMatch-selected" }), no = /* @__PURE__ */ Ht.fromClass(class {
1271
+ constructor(t) {
1272
+ this.view = t, this.decorations = this.highlight(t.state.field(V));
1273
+ }
1274
+ update(t) {
1275
+ let e = t.state.field(V);
1276
+ (e != t.startState.field(V) || t.docChanged || t.selectionSet || t.viewportChanged) && (this.decorations = this.highlight(e));
1277
+ }
1278
+ highlight({ query: t, panel: e }) {
1279
+ if (!e || !t.spec.valid)
1280
+ return v.none;
1281
+ let { view: r } = this, n = new Ut();
1282
+ for (let i = 0, o = r.visibleRanges, s = o.length; i < s; i++) {
1283
+ let { from: l, to: a } = o[i];
1284
+ for (; i < s - 1 && a > o[i + 1].from - 2 * 250; )
1285
+ a = o[++i].to;
1286
+ t.highlight(r.state, l, a, (c, h) => {
1287
+ let u = r.state.selection.ranges.some((d) => d.from == c && d.to == h);
1288
+ n.add(c, h, u ? to : eo);
1289
+ });
1290
+ }
1291
+ return n.finish();
1292
+ }
1293
+ }, {
1294
+ decorations: (t) => t.decorations
1295
+ });
1296
+ function ye(t) {
1297
+ return (e) => {
1298
+ let r = e.state.field(V, !1);
1299
+ return r && r.query.spec.valid ? t(e, r) : Rn(e);
1300
+ };
1301
+ }
1302
+ const Te = /* @__PURE__ */ ye((t, { query: e }) => {
1303
+ let { to: r } = t.state.selection.main, n = e.nextMatch(t.state, r, r);
1304
+ if (!n)
1305
+ return !1;
1306
+ let i = m.single(n.from, n.to), o = t.state.facet(oe);
1307
+ return t.dispatch({
1308
+ selection: i,
1309
+ effects: [ut(t, n), o.scrollToMatch(i.main, t)],
1310
+ userEvent: "select.search"
1311
+ }), wn(t), !0;
1312
+ }), we = /* @__PURE__ */ ye((t, { query: e }) => {
1313
+ let { state: r } = t, { from: n } = r.selection.main, i = e.prevMatch(r, n, n);
1314
+ if (!i)
1315
+ return !1;
1316
+ let o = m.single(i.from, i.to), s = t.state.facet(oe);
1317
+ return t.dispatch({
1318
+ selection: o,
1319
+ effects: [ut(t, i), s.scrollToMatch(o.main, t)],
1320
+ userEvent: "select.search"
1321
+ }), wn(t), !0;
1322
+ }), ro = /* @__PURE__ */ ye((t, { query: e }) => {
1323
+ let r = e.matchAll(t.state, 1e3);
1324
+ return !r || !r.length ? !1 : (t.dispatch({
1325
+ selection: m.create(r.map((n) => m.range(n.from, n.to))),
1326
+ userEvent: "select.search.matches"
1327
+ }), !0);
1328
+ }), io = ({ state: t, dispatch: e }) => {
1329
+ let r = t.selection;
1330
+ if (r.ranges.length > 1 || r.main.empty)
1331
+ return !1;
1332
+ let { from: n, to: i } = r.main, o = [], s = 0;
1333
+ for (let l = new re(t.doc, t.sliceDoc(n, i)); !l.next().done; ) {
1334
+ if (o.length > 1e3)
1335
+ return !1;
1336
+ l.value.from == n && (s = o.length), o.push(m.range(l.value.from, l.value.to));
1337
+ }
1338
+ return e(t.update({
1339
+ selection: m.create(o, s),
1340
+ userEvent: "select.search.matches"
1341
+ })), !0;
1342
+ }, vt = /* @__PURE__ */ ye((t, { query: e }) => {
1343
+ let { state: r } = t, { from: n, to: i } = r.selection.main;
1344
+ if (r.readOnly)
1345
+ return !1;
1346
+ let o = e.nextMatch(r, n, n);
1347
+ if (!o)
1348
+ return !1;
1349
+ let s = o, l = [], a, c, h = [];
1350
+ s.precise ? s.from == n && s.to == i && (c = r.toText(e.getReplacement(s)), l.push({ from: s.from, to: s.to, insert: c }), h.push(x.announce.of(r.phrase("replaced match on line $", r.doc.lineAt(n).number) + "."))) : s = e.nextMatch(r, s.from, s.to);
1351
+ let u = t.state.changes(l);
1352
+ return s && (a = m.single(s.from, s.to).map(u), h.push(ut(t, s)), h.push(r.facet(oe).scrollToMatch(a.main, t))), t.dispatch({
1353
+ changes: u,
1354
+ selection: a,
1355
+ effects: h,
1356
+ userEvent: "input.replace"
1357
+ }), !0;
1358
+ }), oo = /* @__PURE__ */ ye((t, { query: e }) => {
1359
+ if (t.state.readOnly)
1360
+ return !1;
1361
+ let r = [];
1362
+ for (let i of e.matchAll(t.state, 1e9)) {
1363
+ let { from: o, to: s, precise: l } = i;
1364
+ l && r.push({ from: o, to: s, insert: e.getReplacement(i) });
1365
+ }
1366
+ if (!r.length)
1367
+ return !1;
1368
+ let n = t.state.phrase("replaced $ matches", r.length) + ".";
1369
+ return t.dispatch({
1370
+ changes: r,
1371
+ effects: x.announce.of(n),
1372
+ userEvent: "input.replace.all"
1373
+ }), !0;
1374
+ });
1375
+ function ht(t) {
1376
+ return t.state.facet(oe).createPanel(t);
1377
+ }
1378
+ function Ze(t, e) {
1379
+ var r, n, i, o, s;
1380
+ let l = t.selection.main, a = l.empty || l.to > l.from + 100 ? "" : t.sliceDoc(l.from, l.to);
1381
+ if (e && !a)
1382
+ return e;
1383
+ let c = t.facet(oe);
1384
+ return new Dn({
1385
+ search: ((r = e == null ? void 0 : e.literal) !== null && r !== void 0 ? r : c.literal) ? a : a.replace(/\n/g, "\\n"),
1386
+ caseSensitive: (n = e == null ? void 0 : e.caseSensitive) !== null && n !== void 0 ? n : c.caseSensitive,
1387
+ literal: (i = e == null ? void 0 : e.literal) !== null && i !== void 0 ? i : c.literal,
1388
+ regexp: (o = e == null ? void 0 : e.regexp) !== null && o !== void 0 ? o : c.regexp,
1389
+ wholeWord: (s = e == null ? void 0 : e.wholeWord) !== null && s !== void 0 ? s : c.wholeWord
1390
+ });
1391
+ }
1392
+ function Tn(t) {
1393
+ let e = it(t, ht);
1394
+ return e && e.dom.querySelector("[main-field]");
1395
+ }
1396
+ function wn(t) {
1397
+ let e = Tn(t);
1398
+ e && e == t.root.activeElement && e.select();
1399
+ }
1400
+ const Rn = (t) => {
1401
+ let e = t.state.field(V, !1);
1402
+ if (e && e.panel) {
1403
+ let r = Tn(t);
1404
+ if (r && r != t.root.activeElement) {
1405
+ let n = Ze(t.state, e.query.spec);
1406
+ n.valid && t.dispatch({ effects: fe.of(n) }), r.focus(), r.select();
1407
+ }
1408
+ } else
1409
+ t.dispatch({ effects: [
1410
+ ct.of(!0),
1411
+ e ? fe.of(Ze(t.state, e.query.spec)) : F.appendConfig.of(co)
1412
+ ] });
1413
+ return !0;
1414
+ }, In = (t) => {
1415
+ let e = t.state.field(V, !1);
1416
+ if (!e || !e.panel)
1417
+ return !1;
1418
+ let r = it(t, ht);
1419
+ return r && r.dom.contains(t.root.activeElement) && t.focus(), t.dispatch({ effects: ct.of(!1) }), !0;
1420
+ }, so = [
1421
+ { key: "Mod-f", run: Rn, scope: "editor search-panel" },
1422
+ { key: "F3", run: Te, shift: we, scope: "editor search-panel", preventDefault: !0 },
1423
+ { key: "Mod-g", run: Te, shift: we, scope: "editor search-panel", preventDefault: !0 },
1424
+ { key: "Escape", run: In, scope: "editor search-panel" },
1425
+ { key: "Mod-Shift-l", run: io },
1426
+ { key: "Mod-Alt-g", run: Pi },
1427
+ { key: "Mod-d", run: Ji, preventDefault: !0 }
1428
+ ];
1429
+ class lo {
1430
+ constructor(e) {
1431
+ this.view = e;
1432
+ let r = this.query = e.state.field(V).query.spec;
1433
+ this.commit = this.commit.bind(this), this.searchField = b("input", {
1434
+ value: r.search,
1435
+ placeholder: B(e, "Find"),
1436
+ "aria-label": B(e, "Find"),
1437
+ class: "cm-textfield",
1438
+ name: "search",
1439
+ form: "",
1440
+ "main-field": "true",
1441
+ onchange: this.commit,
1442
+ onkeyup: this.commit
1443
+ }), this.replaceField = b("input", {
1444
+ value: r.replace,
1445
+ placeholder: B(e, "Replace"),
1446
+ "aria-label": B(e, "Replace"),
1447
+ class: "cm-textfield",
1448
+ name: "replace",
1449
+ form: "",
1450
+ onchange: this.commit,
1451
+ onkeyup: this.commit
1452
+ }), this.caseField = b("input", {
1453
+ type: "checkbox",
1454
+ name: "case",
1455
+ form: "",
1456
+ checked: r.caseSensitive,
1457
+ onchange: this.commit
1458
+ }), this.reField = b("input", {
1459
+ type: "checkbox",
1460
+ name: "re",
1461
+ form: "",
1462
+ checked: r.regexp,
1463
+ onchange: this.commit
1464
+ }), this.wordField = b("input", {
1465
+ type: "checkbox",
1466
+ name: "word",
1467
+ form: "",
1468
+ checked: r.wholeWord,
1469
+ onchange: this.commit
1470
+ });
1471
+ function n(i, o, s) {
1472
+ return b("button", { class: "cm-button", name: i, onclick: o, type: "button" }, s);
1473
+ }
1474
+ this.dom = b("div", { onkeydown: (i) => this.keydown(i), class: "cm-search" }, [
1475
+ this.searchField,
1476
+ n("next", () => Te(e), [B(e, "next")]),
1477
+ n("prev", () => we(e), [B(e, "previous")]),
1478
+ n("select", () => ro(e), [B(e, "all")]),
1479
+ b("label", null, [this.caseField, B(e, "match case")]),
1480
+ b("label", null, [this.reField, B(e, "regexp")]),
1481
+ b("label", null, [this.wordField, B(e, "by word")]),
1482
+ ...e.state.readOnly ? [] : [
1483
+ b("br"),
1484
+ this.replaceField,
1485
+ n("replace", () => vt(e), [B(e, "replace")]),
1486
+ n("replaceAll", () => oo(e), [B(e, "replace all")])
1487
+ ],
1488
+ b("button", {
1489
+ name: "close",
1490
+ onclick: () => In(e),
1491
+ "aria-label": B(e, "close"),
1492
+ type: "button"
1493
+ }, ["×"])
1494
+ ]);
1495
+ }
1496
+ commit() {
1497
+ let e = new Dn({
1498
+ search: this.searchField.value,
1499
+ caseSensitive: this.caseField.checked,
1500
+ regexp: this.reField.checked,
1501
+ wholeWord: this.wordField.checked,
1502
+ replace: this.replaceField.value
1503
+ });
1504
+ e.eq(this.query) || (this.query = e, this.view.dispatch({ effects: fe.of(e) }));
1505
+ }
1506
+ keydown(e) {
1507
+ Xn(this.view, e, "search-panel") ? e.preventDefault() : e.keyCode == 13 && e.target == this.searchField ? (e.preventDefault(), (e.shiftKey ? we : Te)(this.view)) : e.keyCode == 13 && e.target == this.replaceField && (e.preventDefault(), vt(this.view));
1508
+ }
1509
+ update(e) {
1510
+ for (let r of e.transactions)
1511
+ for (let n of r.effects)
1512
+ n.is(fe) && !n.value.eq(this.query) && this.setQuery(n.value);
1513
+ }
1514
+ setQuery(e) {
1515
+ this.query = e, this.searchField.value = e.search, this.replaceField.value = e.replace, this.caseField.checked = e.caseSensitive, this.reField.checked = e.regexp, this.wordField.checked = e.wholeWord;
1516
+ }
1517
+ mount() {
1518
+ this.searchField.select();
1519
+ }
1520
+ get pos() {
1521
+ return 80;
1522
+ }
1523
+ get top() {
1524
+ return this.view.state.facet(oe).top;
1525
+ }
1526
+ }
1527
+ function B(t, e) {
1528
+ return t.state.phrase(e);
1529
+ }
1530
+ const be = 30, Ce = /[\s\.,:;?!]/;
1531
+ function ut(t, { from: e, to: r }) {
1532
+ let n = t.state.doc.lineAt(e), i = t.state.doc.lineAt(r).to, o = Math.max(n.from, e - be), s = Math.min(i, r + be), l = t.state.sliceDoc(o, s);
1533
+ if (o != n.from) {
1534
+ for (let a = 0; a < be; a++)
1535
+ if (!Ce.test(l[a + 1]) && Ce.test(l[a])) {
1536
+ l = l.slice(a);
1537
+ break;
1538
+ }
1539
+ }
1540
+ if (s != i) {
1541
+ for (let a = l.length - 1; a > l.length - be; a--)
1542
+ if (!Ce.test(l[a - 1]) && Ce.test(l[a])) {
1543
+ l = l.slice(0, a);
1544
+ break;
1545
+ }
1546
+ }
1547
+ return x.announce.of(`${t.state.phrase("current match")}. ${l} ${t.state.phrase("on line")} ${n.number}.`);
1548
+ }
1549
+ const ao = /* @__PURE__ */ x.baseTheme({
1550
+ ".cm-panel.cm-search": {
1551
+ padding: "2px 6px 4px",
1552
+ position: "relative",
1553
+ "& [name=close]": {
1554
+ position: "absolute",
1555
+ top: "0",
1556
+ right: "4px",
1557
+ backgroundColor: "inherit",
1558
+ border: "none",
1559
+ font: "inherit",
1560
+ padding: 0,
1561
+ margin: 0
1562
+ },
1563
+ "& input, & button, & label": {
1564
+ margin: ".2em .6em .2em 0"
1565
+ },
1566
+ "& input[type=checkbox]": {
1567
+ marginRight: ".2em"
1568
+ },
1569
+ "& label": {
1570
+ fontSize: "80%",
1571
+ whiteSpace: "pre"
1572
+ }
1573
+ },
1574
+ "&light .cm-searchMatch": { backgroundColor: "#ffff0054" },
1575
+ "&dark .cm-searchMatch": { backgroundColor: "#00ffff8a" },
1576
+ "&light .cm-searchMatch-selected": { backgroundColor: "#ff6a0054" },
1577
+ "&dark .cm-searchMatch-selected": { backgroundColor: "#ff00ff8a" }
1578
+ }), co = [
1579
+ V,
1580
+ /* @__PURE__ */ Qn.low(no),
1581
+ ao
1582
+ ];
1583
+ class Mt {
1584
+ constructor(e, r, n) {
1585
+ this.from = e, this.to = r, this.diagnostic = n;
1586
+ }
1587
+ }
1588
+ class J {
1589
+ constructor(e, r, n) {
1590
+ this.diagnostics = e, this.panel = r, this.selected = n;
1591
+ }
1592
+ static init(e, r, n) {
1593
+ let i = n.facet(de).markerFilter;
1594
+ i && (e = i(e, n));
1595
+ let o = e.slice().sort((g, p) => g.from - p.from || g.to - p.to), s = new Ut(), l = [], a = 0, c = n.doc.iter(), h = 0, u = n.doc.length;
1596
+ for (let g = 0; ; ) {
1597
+ let p = g == o.length ? null : o[g];
1598
+ if (!p && !l.length)
1599
+ break;
1600
+ let S, k;
1601
+ if (l.length)
1602
+ S = a, k = l.reduce((y, A) => Math.min(y, A.to), p && p.from > S ? p.from : 1e8);
1603
+ else {
1604
+ if (S = p.from, S > u)
1605
+ break;
1606
+ k = p.to, l.push(p), g++;
1607
+ }
1608
+ for (; g < o.length; ) {
1609
+ let y = o[g];
1610
+ if (y.from == S && (y.to > y.from || y.to == S))
1611
+ l.push(y), g++, k = Math.min(y.to, k);
1612
+ else {
1613
+ k = Math.min(y.from, k);
1614
+ break;
1615
+ }
1616
+ }
1617
+ k = Math.min(k, u);
1618
+ let N = !1;
1619
+ if (l.some((y) => y.from == S && (y.to == k || k == u)) && (N = S == k, !N && k - S < 10)) {
1620
+ let y = S - (h + c.value.length);
1621
+ y > 0 && (c.next(y), h = S);
1622
+ for (let A = S; ; ) {
1623
+ if (A >= k) {
1624
+ N = !0;
1625
+ break;
1626
+ }
1627
+ if (!c.lineBreak && h + c.value.length > A)
1628
+ break;
1629
+ A = h + c.value.length, h += c.value.length, c.next();
1630
+ }
1631
+ }
1632
+ let z = vo(l);
1633
+ if (N)
1634
+ s.add(S, S, v.widget({
1635
+ widget: new xo(z),
1636
+ diagnostics: l.slice()
1637
+ }));
1638
+ else {
1639
+ let y = l.reduce((A, Q) => Q.markClass ? A + " " + Q.markClass : A, "");
1640
+ s.add(S, k, v.mark({
1641
+ class: "cm-lintRange cm-lintRange-" + z + y,
1642
+ diagnostics: l.slice(),
1643
+ inclusiveEnd: l.some((A) => A.to > k)
1644
+ }));
1645
+ }
1646
+ if (a = k, a == u)
1647
+ break;
1648
+ for (let y = 0; y < l.length; y++)
1649
+ l[y].to <= a && l.splice(y--, 1);
1650
+ }
1651
+ let d = s.finish();
1652
+ return new J(d, r, H(d));
1653
+ }
1654
+ }
1655
+ function H(t, e = null, r = 0) {
1656
+ let n = null;
1657
+ return t.between(r, 1e9, (i, o, { spec: s }) => {
1658
+ if (!(e && s.diagnostics.indexOf(e) < 0))
1659
+ if (!n)
1660
+ n = new Mt(i, o, e || s.diagnostics[0]);
1661
+ else {
1662
+ if (s.diagnostics.indexOf(n.diagnostic) < 0)
1663
+ return !1;
1664
+ n = new Mt(n.from, o, n.diagnostic);
1665
+ }
1666
+ }), n;
1667
+ }
1668
+ function ho(t, e) {
1669
+ let r = e.pos, n = e.end || r, i = t.state.facet(de).hideOn(t, r, n);
1670
+ if (i != null)
1671
+ return i;
1672
+ let o = t.startState.doc.lineAt(e.pos);
1673
+ return !!(t.effects.some((s) => s.is(On)) || t.changes.touchesRange(o.from, Math.max(o.to, n)));
1674
+ }
1675
+ function uo(t, e) {
1676
+ return t.field(D, !1) ? e : e.concat(F.appendConfig.of(Mo));
1677
+ }
1678
+ const On = /* @__PURE__ */ F.define(), ft = /* @__PURE__ */ F.define(), Wn = /* @__PURE__ */ F.define(), D = /* @__PURE__ */ et.define({
1679
+ create() {
1680
+ return new J(v.none, null, null);
1681
+ },
1682
+ update(t, e) {
1683
+ if (e.docChanged && t.diagnostics.size) {
1684
+ let r = t.diagnostics.map(e.changes), n = null, i = t.panel;
1685
+ if (t.selected) {
1686
+ let o = e.changes.mapPos(t.selected.from, 1);
1687
+ n = H(r, t.selected.diagnostic, o) || H(r, null, o);
1688
+ }
1689
+ !r.size && i && e.state.facet(de).autoPanel && (i = null), t = new J(r, i, n);
1690
+ }
1691
+ for (let r of e.effects)
1692
+ if (r.is(On)) {
1693
+ let n = e.state.facet(de).autoPanel ? r.value.length ? me.open : null : t.panel;
1694
+ t = J.init(r.value, n, e.state);
1695
+ } else r.is(ft) ? t = new J(t.diagnostics, r.value ? me.open : null, t.selected) : r.is(Wn) && (t = new J(t.diagnostics, t.panel, r.value));
1696
+ return t;
1697
+ },
1698
+ provide: (t) => [
1699
+ Vt.from(t, (e) => e.panel),
1700
+ x.decorations.from(t, (e) => e.diagnostics)
1701
+ ]
1702
+ }), fo = /* @__PURE__ */ v.mark({ class: "cm-lintRange cm-lintRange-active" });
1703
+ function mo(t, e, r) {
1704
+ let { diagnostics: n } = t.state.field(D), i, o = -1, s = -1;
1705
+ n.between(e - (r < 0 ? 1 : 0), e + (r > 0 ? 1 : 0), (a, c, { spec: h }) => {
1706
+ if (e >= a && e <= c && (a == c || (e > a || r > 0) && (e < c || r < 0)))
1707
+ return i = h.diagnostics, o = a, s = c, !1;
1708
+ });
1709
+ let l = t.state.facet(de).tooltipFilter;
1710
+ return i && l && (i = l(i, t.state)), i ? {
1711
+ pos: o,
1712
+ end: s,
1713
+ above: t.state.doc.lineAt(o).to < s,
1714
+ create() {
1715
+ return { dom: go(t, i) };
1716
+ }
1717
+ } : null;
1718
+ }
1719
+ function go(t, e) {
1720
+ return b("ul", { class: "cm-tooltip-lint" }, e.map((r) => Fn(t, r, !1)));
1721
+ }
1722
+ const po = (t) => {
1723
+ let e = t.state.field(D, !1);
1724
+ (!e || !e.panel) && t.dispatch({ effects: uo(t.state, [ft.of(!0)]) });
1725
+ let r = it(t, me.open);
1726
+ return r && r.dom.querySelector(".cm-panel-lint ul").focus(), !0;
1727
+ }, At = (t) => {
1728
+ let e = t.state.field(D, !1);
1729
+ return !e || !e.panel ? !1 : (t.dispatch({ effects: ft.of(!1) }), !0);
1730
+ }, yo = (t) => {
1731
+ let e = t.state.field(D, !1);
1732
+ if (!e)
1733
+ return !1;
1734
+ let r = t.state.selection.main, n = H(e.diagnostics, null, r.to + 1);
1735
+ return !n && (n = H(e.diagnostics, null, 0), !n || n.from == r.from && n.to == r.to) ? !1 : (t.dispatch({ selection: { anchor: n.from, head: n.to }, scrollIntoView: !0 }), !0);
1736
+ }, ko = [
1737
+ { key: "Mod-Shift-m", run: po, preventDefault: !0 },
1738
+ { key: "F8", run: yo }
1739
+ ], de = /* @__PURE__ */ ge.define({
1740
+ combine(t) {
1741
+ return {
1742
+ sources: t.map((e) => e.source).filter((e) => e != null),
1743
+ ...Re(t.map((e) => e.config), {
1744
+ delay: 750,
1745
+ markerFilter: null,
1746
+ tooltipFilter: null,
1747
+ needsRefresh: null,
1748
+ hideOn: () => null
1749
+ }, {
1750
+ delay: Math.max,
1751
+ markerFilter: Lt,
1752
+ tooltipFilter: Lt,
1753
+ needsRefresh: (e, r) => e ? r ? (n) => e(n) || r(n) : e : r,
1754
+ hideOn: (e, r) => e ? r ? (n, i, o) => e(n, i, o) || r(n, i, o) : e : r,
1755
+ autoPanel: (e, r) => e || r
1756
+ })
1757
+ };
1758
+ }
1759
+ });
1760
+ function Lt(t, e) {
1761
+ return t ? e ? (r, n) => e(t(r, n), n) : t : e;
1762
+ }
1763
+ function Pn(t) {
1764
+ let e = [];
1765
+ if (t)
1766
+ e: for (let { name: r } of t) {
1767
+ for (let n = 0; n < r.length; n++) {
1768
+ let i = r[n];
1769
+ if (/[a-zA-Z]/.test(i) && !e.some((o) => o.toLowerCase() == i.toLowerCase())) {
1770
+ e.push(i);
1771
+ continue e;
1772
+ }
1773
+ }
1774
+ e.push("");
1775
+ }
1776
+ return e;
1777
+ }
1778
+ function Fn(t, e, r) {
1779
+ var n;
1780
+ let i = r ? Pn(e.actions) : [];
1781
+ return b("li", { class: "cm-diagnostic cm-diagnostic-" + e.severity }, b("span", { class: "cm-diagnosticText" }, e.renderMessage ? e.renderMessage(t) : e.message), (n = e.actions) === null || n === void 0 ? void 0 : n.map((o, s) => {
1782
+ let l = !1, a = (g) => {
1783
+ if (g.preventDefault(), l)
1784
+ return;
1785
+ l = !0;
1786
+ let p = H(t.state.field(D).diagnostics, e);
1787
+ p && o.apply(t, p.from, p.to);
1788
+ }, { name: c } = o, h = i[s] ? c.indexOf(i[s]) : -1, u = h < 0 ? c : [
1789
+ c.slice(0, h),
1790
+ b("u", c.slice(h, h + 1)),
1791
+ c.slice(h + 1)
1792
+ ], d = o.markClass ? " " + o.markClass : "";
1793
+ return b("button", {
1794
+ type: "button",
1795
+ class: "cm-diagnosticAction" + d,
1796
+ onclick: a,
1797
+ onmousedown: a,
1798
+ "aria-label": ` Action: ${c}${h < 0 ? "" : ` (access key "${i[s]})"`}.`
1799
+ }, u);
1800
+ }), e.source && b("div", { class: "cm-diagnosticSource" }, e.source));
1801
+ }
1802
+ class xo extends tr {
1803
+ constructor(e) {
1804
+ super(), this.sev = e;
1805
+ }
1806
+ eq(e) {
1807
+ return e.sev == this.sev;
1808
+ }
1809
+ toDOM() {
1810
+ return b("span", { class: "cm-lintPoint cm-lintPoint-" + this.sev });
1811
+ }
1812
+ }
1813
+ class Bt {
1814
+ constructor(e, r) {
1815
+ this.diagnostic = r, this.id = "item_" + Math.floor(Math.random() * 4294967295).toString(16), this.dom = Fn(e, r, !0), this.dom.id = this.id, this.dom.setAttribute("role", "option");
1816
+ }
1817
+ }
1818
+ class me {
1819
+ constructor(e) {
1820
+ this.view = e, this.items = [];
1821
+ let r = (i) => {
1822
+ if (!(i.ctrlKey || i.altKey || i.metaKey)) {
1823
+ if (i.keyCode == 27)
1824
+ At(this.view), this.view.focus();
1825
+ else if (i.keyCode == 38 || i.keyCode == 33)
1826
+ this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
1827
+ else if (i.keyCode == 40 || i.keyCode == 34)
1828
+ this.moveSelection((this.selectedIndex + 1) % this.items.length);
1829
+ else if (i.keyCode == 36)
1830
+ this.moveSelection(0);
1831
+ else if (i.keyCode == 35)
1832
+ this.moveSelection(this.items.length - 1);
1833
+ else if (i.keyCode == 13)
1834
+ this.view.focus();
1835
+ else if (i.keyCode >= 65 && i.keyCode <= 90 && this.selectedIndex >= 0) {
1836
+ let { diagnostic: o } = this.items[this.selectedIndex], s = Pn(o.actions);
1837
+ for (let l = 0; l < s.length; l++)
1838
+ if (s[l].toUpperCase().charCodeAt(0) == i.keyCode) {
1839
+ let a = H(this.view.state.field(D).diagnostics, o);
1840
+ a && o.actions[l].apply(e, a.from, a.to);
1841
+ }
1842
+ } else
1843
+ return;
1844
+ i.preventDefault();
1845
+ }
1846
+ }, n = (i) => {
1847
+ for (let o = 0; o < this.items.length; o++)
1848
+ this.items[o].dom.contains(i.target) && this.moveSelection(o);
1849
+ };
1850
+ this.list = b("ul", {
1851
+ tabIndex: 0,
1852
+ role: "listbox",
1853
+ "aria-label": this.view.state.phrase("Diagnostics"),
1854
+ onkeydown: r,
1855
+ onclick: n
1856
+ }), this.dom = b("div", { class: "cm-panel-lint" }, this.list, b("button", {
1857
+ type: "button",
1858
+ name: "close",
1859
+ "aria-label": this.view.state.phrase("close"),
1860
+ onclick: () => At(this.view)
1861
+ }, "×")), this.update();
1862
+ }
1863
+ get selectedIndex() {
1864
+ let e = this.view.state.field(D).selected;
1865
+ if (!e)
1866
+ return -1;
1867
+ for (let r = 0; r < this.items.length; r++)
1868
+ if (this.items[r].diagnostic == e.diagnostic)
1869
+ return r;
1870
+ return -1;
1871
+ }
1872
+ update() {
1873
+ let { diagnostics: e, selected: r } = this.view.state.field(D), n = 0, i = !1, o = null, s = /* @__PURE__ */ new Set();
1874
+ for (e.between(0, this.view.state.doc.length, (l, a, { spec: c }) => {
1875
+ for (let h of c.diagnostics) {
1876
+ if (s.has(h))
1877
+ continue;
1878
+ s.add(h);
1879
+ let u = -1, d;
1880
+ for (let g = n; g < this.items.length; g++)
1881
+ if (this.items[g].diagnostic == h) {
1882
+ u = g;
1883
+ break;
1884
+ }
1885
+ u < 0 ? (d = new Bt(this.view, h), this.items.splice(n, 0, d), i = !0) : (d = this.items[u], u > n && (this.items.splice(n, u - n), i = !0)), r && d.diagnostic == r.diagnostic ? d.dom.hasAttribute("aria-selected") || (d.dom.setAttribute("aria-selected", "true"), o = d) : d.dom.hasAttribute("aria-selected") && d.dom.removeAttribute("aria-selected"), n++;
1886
+ }
1887
+ }); n < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0); )
1888
+ i = !0, this.items.pop();
1889
+ this.items.length == 0 && (this.items.push(new Bt(this.view, {
1890
+ from: -1,
1891
+ to: -1,
1892
+ severity: "info",
1893
+ message: this.view.state.phrase("No diagnostics")
1894
+ })), i = !0), o ? (this.list.setAttribute("aria-activedescendant", o.id), this.view.requestMeasure({
1895
+ key: this,
1896
+ read: () => ({ sel: o.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }),
1897
+ write: ({ sel: l, panel: a }) => {
1898
+ let c = a.height / this.list.offsetHeight;
1899
+ l.top < a.top ? this.list.scrollTop -= (a.top - l.top) / c : l.bottom > a.bottom && (this.list.scrollTop += (l.bottom - a.bottom) / c);
1900
+ }
1901
+ })) : this.selectedIndex < 0 && this.list.removeAttribute("aria-activedescendant"), i && this.sync();
1902
+ }
1903
+ sync() {
1904
+ let e = this.list.firstChild;
1905
+ function r() {
1906
+ let n = e;
1907
+ e = n.nextSibling, n.remove();
1908
+ }
1909
+ for (let n of this.items)
1910
+ if (n.dom.parentNode == this.list) {
1911
+ for (; e != n.dom; )
1912
+ r();
1913
+ e = n.dom.nextSibling;
1914
+ } else
1915
+ this.list.insertBefore(n.dom, e);
1916
+ for (; e; )
1917
+ r();
1918
+ }
1919
+ moveSelection(e) {
1920
+ if (this.selectedIndex < 0)
1921
+ return;
1922
+ let r = this.view.state.field(D), n = H(r.diagnostics, this.items[e].diagnostic);
1923
+ n && this.view.dispatch({
1924
+ selection: { anchor: n.from, head: n.to },
1925
+ scrollIntoView: !0,
1926
+ effects: Wn.of(n)
1927
+ });
1928
+ }
1929
+ static open(e) {
1930
+ return new me(e);
1931
+ }
1932
+ }
1933
+ function So(t, e = 'viewBox="0 0 40 40"') {
1934
+ return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`;
1935
+ }
1936
+ function ve(t) {
1937
+ return So(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`, 'width="6" height="3"');
1938
+ }
1939
+ const bo = /* @__PURE__ */ x.baseTheme({
1940
+ ".cm-diagnostic": {
1941
+ padding: "3px 6px 3px 8px",
1942
+ marginLeft: "-1px",
1943
+ display: "block",
1944
+ whiteSpace: "pre-wrap"
1945
+ },
1946
+ ".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
1947
+ ".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
1948
+ ".cm-diagnostic-info": { borderLeft: "5px solid #999" },
1949
+ ".cm-diagnostic-hint": { borderLeft: "5px solid #66d" },
1950
+ ".cm-diagnosticAction": {
1951
+ font: "inherit",
1952
+ border: "none",
1953
+ padding: "2px 4px",
1954
+ backgroundColor: "#444",
1955
+ color: "white",
1956
+ borderRadius: "3px",
1957
+ marginLeft: "8px",
1958
+ cursor: "pointer"
1959
+ },
1960
+ ".cm-diagnosticSource": {
1961
+ fontSize: "70%",
1962
+ opacity: 0.7
1963
+ },
1964
+ ".cm-lintRange": {
1965
+ backgroundPosition: "left bottom",
1966
+ backgroundRepeat: "repeat-x",
1967
+ paddingBottom: "0.7px"
1968
+ },
1969
+ ".cm-lintRange-error": { backgroundImage: /* @__PURE__ */ ve("#d11") },
1970
+ ".cm-lintRange-warning": { backgroundImage: /* @__PURE__ */ ve("orange") },
1971
+ ".cm-lintRange-info": { backgroundImage: /* @__PURE__ */ ve("#999") },
1972
+ ".cm-lintRange-hint": { backgroundImage: /* @__PURE__ */ ve("#66d") },
1973
+ ".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
1974
+ ".cm-tooltip-lint": {
1975
+ padding: 0,
1976
+ margin: 0
1977
+ },
1978
+ ".cm-lintPoint": {
1979
+ position: "relative",
1980
+ "&:after": {
1981
+ content: '""',
1982
+ position: "absolute",
1983
+ bottom: 0,
1984
+ left: "-2px",
1985
+ borderLeft: "3px solid transparent",
1986
+ borderRight: "3px solid transparent",
1987
+ borderBottom: "4px solid #d11"
1988
+ }
1989
+ },
1990
+ ".cm-lintPoint-warning": {
1991
+ "&:after": { borderBottomColor: "orange" }
1992
+ },
1993
+ ".cm-lintPoint-info": {
1994
+ "&:after": { borderBottomColor: "#999" }
1995
+ },
1996
+ ".cm-lintPoint-hint": {
1997
+ "&:after": { borderBottomColor: "#66d" }
1998
+ },
1999
+ ".cm-panel.cm-panel-lint": {
2000
+ position: "relative",
2001
+ "& ul": {
2002
+ maxHeight: "100px",
2003
+ overflowY: "auto",
2004
+ "& [aria-selected]": {
2005
+ backgroundColor: "#ddd",
2006
+ "& u": { textDecoration: "underline" }
2007
+ },
2008
+ "&:focus [aria-selected]": {
2009
+ background_fallback: "#bdf",
2010
+ backgroundColor: "Highlight",
2011
+ color_fallback: "white",
2012
+ color: "HighlightText"
2013
+ },
2014
+ "& u": { textDecoration: "none" },
2015
+ padding: 0,
2016
+ margin: 0
2017
+ },
2018
+ "& [name=close]": {
2019
+ position: "absolute",
2020
+ top: "0",
2021
+ right: "2px",
2022
+ background: "inherit",
2023
+ border: "none",
2024
+ font: "inherit",
2025
+ padding: 0,
2026
+ margin: 0
2027
+ }
2028
+ },
2029
+ "&dark .cm-lintRange-active": { backgroundColor: "#86714a80" },
2030
+ "&dark .cm-panel.cm-panel-lint ul": {
2031
+ "& [aria-selected]": {
2032
+ backgroundColor: "#2e343e"
2033
+ }
2034
+ }
2035
+ });
2036
+ function Co(t) {
2037
+ return t == "error" ? 4 : t == "warning" ? 3 : t == "info" ? 2 : 1;
2038
+ }
2039
+ function vo(t) {
2040
+ let e = "hint", r = 1;
2041
+ for (let n of t) {
2042
+ let i = Co(n.severity);
2043
+ i > r && (r = i, e = n.severity);
2044
+ }
2045
+ return e;
2046
+ }
2047
+ const Mo = [
2048
+ D,
2049
+ /* @__PURE__ */ x.decorations.compute([D], (t) => {
2050
+ let { selected: e, panel: r } = t.field(D);
2051
+ return !e || !r || e.from == e.to ? v.none : v.set([
2052
+ fo.range(e.from, e.to)
2053
+ ]);
2054
+ }),
2055
+ /* @__PURE__ */ er(mo, { hideOn: ho }),
2056
+ bo
2057
+ ];
2058
+ var Dt = function(e) {
2059
+ e === void 0 && (e = {});
2060
+ var {
2061
+ crosshairCursor: r = !1
2062
+ } = e, n = [];
2063
+ e.closeBracketsKeymap !== !1 && (n = n.concat(yr)), e.defaultKeymap !== !1 && (n = n.concat(Ii)), e.searchKeymap !== !1 && (n = n.concat(so)), e.historyKeymap !== !1 && (n = n.concat(Vr)), e.foldKeymap !== !1 && (n = n.concat(nr)), e.completionKeymap !== !1 && (n = n.concat(kr)), e.lintKeymap !== !1 && (n = n.concat(ko));
2064
+ var i = [];
2065
+ return e.lineNumbers !== !1 && i.push(rr()), e.highlightActiveLineGutter !== !1 && i.push(ir()), e.highlightSpecialChars !== !1 && i.push(or()), e.history !== !1 && i.push(wr()), e.foldGutter !== !1 && i.push(sr()), e.drawSelection !== !1 && i.push(lr()), e.dropCursor !== !1 && i.push(ar()), e.allowMultipleSelections !== !1 && i.push(ue.allowMultipleSelections.of(!0)), e.indentOnInput !== !1 && i.push(cr()), e.syntaxHighlighting !== !1 && i.push(zt(mr, {
2066
+ fallback: !0
2067
+ })), e.bracketMatching !== !1 && i.push(hr()), e.closeBrackets !== !1 && i.push(xr()), e.autocompletion !== !1 && i.push(Sr()), e.rectangularSelection !== !1 && i.push(ur()), r !== !1 && i.push(fr()), e.highlightActiveLine !== !1 && i.push(dr()), e.highlightSelectionMatches !== !1 && i.push(qi()), e.tabSize && typeof e.tabSize == "number" && i.push(qt.of(" ".repeat(e.tabSize))), i.concat([Gt.of(n.flat())]).filter(Boolean);
2068
+ };
2069
+ const Ao = "#e5c07b", Et = "#e06c75", Lo = "#56b6c2", Bo = "#ffffff", Me = "#abb2bf", Xe = "#7d8799", Do = "#61afef", Eo = "#98c379", Tt = "#d19a66", To = "#c678dd", wo = "#21252b", wt = "#2c313a", Rt = "#282c34", Ge = "#353a42", Ro = "#3E4451", It = "#528bff", Io = /* @__PURE__ */ x.theme({
2070
+ "&": {
2071
+ color: Me,
2072
+ backgroundColor: Rt
2073
+ },
2074
+ ".cm-content": {
2075
+ caretColor: It
2076
+ },
2077
+ ".cm-cursor, .cm-dropCursor": { borderLeftColor: It },
2078
+ "&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: Ro },
2079
+ ".cm-panels": { backgroundColor: wo, color: Me },
2080
+ ".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
2081
+ ".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
2082
+ ".cm-searchMatch": {
2083
+ backgroundColor: "#72a1ff59",
2084
+ outline: "1px solid #457dff"
2085
+ },
2086
+ ".cm-searchMatch.cm-searchMatch-selected": {
2087
+ backgroundColor: "#6199ff2f"
2088
+ },
2089
+ ".cm-activeLine": { backgroundColor: "#6699ff0b" },
2090
+ ".cm-selectionMatch": { backgroundColor: "#aafe661a" },
2091
+ "&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket": {
2092
+ backgroundColor: "#bad0f847"
2093
+ },
2094
+ ".cm-gutters": {
2095
+ backgroundColor: Rt,
2096
+ color: Xe,
2097
+ border: "none"
2098
+ },
2099
+ ".cm-activeLineGutter": {
2100
+ backgroundColor: wt
2101
+ },
2102
+ ".cm-foldPlaceholder": {
2103
+ backgroundColor: "transparent",
2104
+ border: "none",
2105
+ color: "#ddd"
2106
+ },
2107
+ ".cm-tooltip": {
2108
+ border: "none",
2109
+ backgroundColor: Ge
2110
+ },
2111
+ ".cm-tooltip .cm-tooltip-arrow:before": {
2112
+ borderTopColor: "transparent",
2113
+ borderBottomColor: "transparent"
2114
+ },
2115
+ ".cm-tooltip .cm-tooltip-arrow:after": {
2116
+ borderTopColor: Ge,
2117
+ borderBottomColor: Ge
2118
+ },
2119
+ ".cm-tooltip-autocomplete": {
2120
+ "& > ul > li[aria-selected]": {
2121
+ backgroundColor: wt,
2122
+ color: Me
2123
+ }
2124
+ }
2125
+ }, { dark: !0 }), Oo = /* @__PURE__ */ gr.define([
2126
+ {
2127
+ tag: f.keyword,
2128
+ color: To
2129
+ },
2130
+ {
2131
+ tag: [f.name, f.deleted, f.character, f.propertyName, f.macroName],
2132
+ color: Et
2133
+ },
2134
+ {
2135
+ tag: [/* @__PURE__ */ f.function(f.variableName), f.labelName],
2136
+ color: Do
2137
+ },
2138
+ {
2139
+ tag: [f.color, /* @__PURE__ */ f.constant(f.name), /* @__PURE__ */ f.standard(f.name)],
2140
+ color: Tt
2141
+ },
2142
+ {
2143
+ tag: [/* @__PURE__ */ f.definition(f.name), f.separator],
2144
+ color: Me
2145
+ },
2146
+ {
2147
+ tag: [f.typeName, f.className, f.number, f.changed, f.annotation, f.modifier, f.self, f.namespace],
2148
+ color: Ao
2149
+ },
2150
+ {
2151
+ tag: [f.operator, f.operatorKeyword, f.url, f.escape, f.regexp, f.link, /* @__PURE__ */ f.special(f.string)],
2152
+ color: Lo
2153
+ },
2154
+ {
2155
+ tag: [f.meta, f.comment],
2156
+ color: Xe
2157
+ },
2158
+ {
2159
+ tag: f.strong,
2160
+ fontWeight: "bold"
2161
+ },
2162
+ {
2163
+ tag: f.emphasis,
2164
+ fontStyle: "italic"
2165
+ },
2166
+ {
2167
+ tag: f.strikethrough,
2168
+ textDecoration: "line-through"
2169
+ },
2170
+ {
2171
+ tag: f.link,
2172
+ color: Xe,
2173
+ textDecoration: "underline"
2174
+ },
2175
+ {
2176
+ tag: f.heading,
2177
+ fontWeight: "bold",
2178
+ color: Et
2179
+ },
2180
+ {
2181
+ tag: [f.atom, f.bool, /* @__PURE__ */ f.special(f.variableName)],
2182
+ color: Tt
2183
+ },
2184
+ {
2185
+ tag: [f.processingInstruction, f.string, f.inserted],
2186
+ color: Eo
2187
+ },
2188
+ {
2189
+ tag: f.invalid,
2190
+ color: Bo
2191
+ }
2192
+ ]), Wo = [Io, /* @__PURE__ */ zt(Oo)];
2193
+ var Po = x.theme({
2194
+ "&": {
2195
+ backgroundColor: "#fff"
2196
+ }
2197
+ }, {
2198
+ dark: !1
2199
+ }), Fo = function(e) {
2200
+ e === void 0 && (e = {});
2201
+ var {
2202
+ indentWithTab: r = !0,
2203
+ editable: n = !0,
2204
+ readOnly: i = !1,
2205
+ theme: o = "light",
2206
+ placeholder: s = "",
2207
+ basicSetup: l = !0
2208
+ } = e, a = [];
2209
+ switch (r && a.unshift(Gt.of([Oi])), l && (typeof l == "boolean" ? a.unshift(Dt()) : a.unshift(Dt(l))), s && a.unshift(pr(s)), o) {
2210
+ case "light":
2211
+ a.push(Po);
2212
+ break;
2213
+ case "dark":
2214
+ a.push(Wo);
2215
+ break;
2216
+ case "none":
2217
+ break;
2218
+ default:
2219
+ a.push(o);
2220
+ break;
2221
+ }
2222
+ return n === !1 && a.push(x.editable.of(!1)), i && a.push(ue.readOnly.of(!0)), [...a];
2223
+ }, No = (t) => ({
2224
+ line: t.state.doc.lineAt(t.state.selection.main.from),
2225
+ lineCount: t.state.doc.lines,
2226
+ lineBreak: t.state.lineBreak,
2227
+ length: t.state.doc.length,
2228
+ readOnly: t.state.readOnly,
2229
+ tabSize: t.state.tabSize,
2230
+ selection: t.state.selection,
2231
+ selectionAsSingle: t.state.selection.asSingle().main,
2232
+ ranges: t.state.selection.ranges,
2233
+ selectionCode: t.state.sliceDoc(t.state.selection.main.from, t.state.selection.main.to),
2234
+ selections: t.state.selection.ranges.map((e) => t.state.sliceDoc(e.from, e.to)),
2235
+ selectedText: t.state.selection.ranges.some((e) => !e.empty)
2236
+ });
2237
+ class qo {
2238
+ constructor(e, r) {
2239
+ this.timeLeftMS = void 0, this.timeoutMS = void 0, this.isCancelled = !1, this.isTimeExhausted = !1, this.callbacks = [], this.timeLeftMS = r, this.timeoutMS = r, this.callbacks.push(e);
2240
+ }
2241
+ tick() {
2242
+ if (!this.isCancelled && !this.isTimeExhausted && (this.timeLeftMS--, this.timeLeftMS <= 0)) {
2243
+ this.isTimeExhausted = !0;
2244
+ var e = this.callbacks.slice();
2245
+ this.callbacks.length = 0, e.forEach((r) => {
2246
+ try {
2247
+ r();
2248
+ } catch (n) {
2249
+ console.error("TimeoutLatch callback error:", n);
2250
+ }
2251
+ });
2252
+ }
2253
+ }
2254
+ cancel() {
2255
+ this.isCancelled = !0, this.callbacks.length = 0;
2256
+ }
2257
+ reset() {
2258
+ this.timeLeftMS = this.timeoutMS, this.isCancelled = !1, this.isTimeExhausted = !1;
2259
+ }
2260
+ get isDone() {
2261
+ return this.isCancelled || this.isTimeExhausted;
2262
+ }
2263
+ }
2264
+ class Ot {
2265
+ constructor() {
2266
+ this.interval = null, this.latches = /* @__PURE__ */ new Set();
2267
+ }
2268
+ add(e) {
2269
+ this.latches.add(e), this.start();
2270
+ }
2271
+ remove(e) {
2272
+ this.latches.delete(e), this.latches.size === 0 && this.stop();
2273
+ }
2274
+ start() {
2275
+ this.interval === null && (this.interval = setInterval(() => {
2276
+ this.latches.forEach((e) => {
2277
+ e.tick(), e.isDone && this.remove(e);
2278
+ });
2279
+ }, 1));
2280
+ }
2281
+ stop() {
2282
+ this.interval !== null && (clearInterval(this.interval), this.interval = null);
2283
+ }
2284
+ }
2285
+ var Ke = null, Vo = () => typeof window > "u" ? new Ot() : (Ke || (Ke = new Ot()), Ke), Wt = rt.define(), Ho = 200, Uo = [];
2286
+ function zo(t) {
2287
+ var {
2288
+ value: e,
2289
+ selection: r,
2290
+ onChange: n,
2291
+ onStatistics: i,
2292
+ onCreateEditor: o,
2293
+ onUpdate: s,
2294
+ extensions: l = Uo,
2295
+ autoFocus: a,
2296
+ theme: c = "light",
2297
+ height: h = null,
2298
+ minHeight: u = null,
2299
+ maxHeight: d = null,
2300
+ width: g = null,
2301
+ minWidth: p = null,
2302
+ maxWidth: S = null,
2303
+ placeholder: k = "",
2304
+ editable: N = !0,
2305
+ readOnly: z = !1,
2306
+ indentWithTab: y = !0,
2307
+ basicSetup: A = !0,
2308
+ root: Q,
2309
+ initialState: se
2310
+ } = t, [j, ke] = ae(), [C, q] = ae(), [Y, Z] = ae(), E = ae(() => ({
2311
+ current: null
2312
+ }))[0], G = ae(() => ({
2313
+ current: null
2314
+ }))[0], Fe = x.theme({
2315
+ "&": {
2316
+ height: h,
2317
+ minHeight: u,
2318
+ maxHeight: d,
2319
+ width: g,
2320
+ minWidth: p,
2321
+ maxWidth: S
2322
+ },
2323
+ "& .cm-scroller": {
2324
+ height: "100% !important"
2325
+ }
2326
+ }), Ne = x.updateListener.of((W) => {
2327
+ if (W.docChanged && typeof n == "function" && // Fix echoing of the remote changes:
2328
+ // If transaction is market as remote we don't have to call `onChange` handler again
2329
+ !W.transactions.some((qe) => qe.annotation(Wt))) {
2330
+ E.current ? E.current.reset() : (E.current = new qo(() => {
2331
+ if (G.current) {
2332
+ var qe = G.current;
2333
+ G.current = null, qe();
2334
+ }
2335
+ E.current = null;
2336
+ }, Ho), Vo().add(E.current));
2337
+ var K = W.state.doc, $ = K.toString();
2338
+ n($, W);
2339
+ }
2340
+ i && i(No(W));
2341
+ }), xe = Fo({
2342
+ theme: c,
2343
+ editable: N,
2344
+ readOnly: z,
2345
+ placeholder: k,
2346
+ indentWithTab: y,
2347
+ basicSetup: A
2348
+ }), le = [Ne, Fe, ...xe];
2349
+ return s && typeof s == "function" && le.push(x.updateListener.of(s)), le = le.concat(l), Vn(() => {
2350
+ if (j && !Y) {
2351
+ var W = {
2352
+ doc: e,
2353
+ selection: r,
2354
+ extensions: le
2355
+ }, K = se ? ue.fromJSON(se.json, W, se.fields) : ue.create(W);
2356
+ if (Z(K), !C) {
2357
+ var $ = new x({
2358
+ state: K,
2359
+ parent: j,
2360
+ root: Q
2361
+ });
2362
+ q($), o && o($, K);
2363
+ }
2364
+ }
2365
+ return () => {
2366
+ C && (Z(void 0), q(void 0));
2367
+ };
2368
+ }, [j, Y]), ce(() => {
2369
+ t.container && ke(t.container);
2370
+ }, [t.container]), ce(() => () => {
2371
+ C && (C.destroy(), q(void 0)), E.current && (E.current.cancel(), E.current = null);
2372
+ }, [C]), ce(() => {
2373
+ a && C && C.focus();
2374
+ }, [a, C]), ce(() => {
2375
+ C && C.dispatch({
2376
+ effects: F.reconfigure.of(le)
2377
+ });
2378
+ }, [c, l, h, u, d, g, p, S, k, N, z, y, A, n, s]), ce(() => {
2379
+ if (e !== void 0) {
2380
+ var W = C ? C.state.doc.toString() : "";
2381
+ if (C && e !== W) {
2382
+ var K = E.current && !E.current.isDone, $ = () => {
2383
+ C && e !== C.state.doc.toString() && C.dispatch({
2384
+ changes: {
2385
+ from: 0,
2386
+ to: C.state.doc.toString().length,
2387
+ insert: e || ""
2388
+ },
2389
+ annotations: [Wt.of(!0)]
2390
+ });
2391
+ };
2392
+ K ? G.current = $ : $();
2393
+ }
2394
+ }
2395
+ }, [e, C]), {
2396
+ state: Y,
2397
+ setState: Z,
2398
+ view: C,
2399
+ setView: q,
2400
+ container: j,
2401
+ setContainer: ke
2402
+ };
2403
+ }
2404
+ var Go = ["className", "value", "selection", "extensions", "onChange", "onStatistics", "onCreateEditor", "onUpdate", "autoFocus", "theme", "height", "minHeight", "maxHeight", "width", "minWidth", "maxWidth", "basicSetup", "placeholder", "indentWithTab", "editable", "readOnly", "root", "initialState"], Ko = /* @__PURE__ */ Hn((t, e) => {
2405
+ var {
2406
+ className: r,
2407
+ value: n = "",
2408
+ selection: i,
2409
+ extensions: o = [],
2410
+ onChange: s,
2411
+ onStatistics: l,
2412
+ onCreateEditor: a,
2413
+ onUpdate: c,
2414
+ autoFocus: h,
2415
+ theme: u = "light",
2416
+ height: d,
2417
+ minHeight: g,
2418
+ maxHeight: p,
2419
+ width: S,
2420
+ minWidth: k,
2421
+ maxWidth: N,
2422
+ basicSetup: z,
2423
+ placeholder: y,
2424
+ indentWithTab: A,
2425
+ editable: Q,
2426
+ readOnly: se,
2427
+ root: j,
2428
+ initialState: ke
2429
+ } = t, C = Nn(t, Go), q = Un(null), {
2430
+ state: Y,
2431
+ view: Z,
2432
+ container: E,
2433
+ setContainer: G
2434
+ } = zo({
2435
+ root: j,
2436
+ value: n,
2437
+ autoFocus: h,
2438
+ theme: u,
2439
+ height: d,
2440
+ minHeight: g,
2441
+ maxHeight: p,
2442
+ width: S,
2443
+ minWidth: k,
2444
+ maxWidth: N,
2445
+ basicSetup: z,
2446
+ placeholder: y,
2447
+ indentWithTab: A,
2448
+ editable: Q,
2449
+ readOnly: se,
2450
+ selection: i,
2451
+ onChange: s,
2452
+ onStatistics: l,
2453
+ onCreateEditor: a,
2454
+ onUpdate: c,
2455
+ extensions: o,
2456
+ initialState: ke
2457
+ });
2458
+ zn(e, () => ({
2459
+ editor: q.current,
2460
+ state: Y,
2461
+ view: Z
2462
+ }), [q, E, Y, Z]);
2463
+ var Fe = Gn((xe) => {
2464
+ q.current = xe, G(xe);
2465
+ }, [G]);
2466
+ if (typeof n != "string")
2467
+ throw new Error("value must be typeof string but got " + typeof n);
2468
+ var Ne = typeof u == "string" ? "cm-theme-" + u : "cm-theme";
2469
+ return /* @__PURE__ */ br("div", qn({
2470
+ ref: Fe,
2471
+ className: "" + Ne + (r ? " " + r : "")
2472
+ }, C));
2473
+ });
2474
+ Ko.displayName = "CodeMirror";
2475
+ export {
2476
+ rt as Annotation,
2477
+ Xo as AnnotationType,
2478
+ es as BidiSpan,
2479
+ ts as BlockInfo,
2480
+ ns as BlockType,
2481
+ rs as BlockWrapper,
2482
+ $n as ChangeDesc,
2483
+ Kn as ChangeSet,
2484
+ T as CharCategory,
2485
+ is as Compartment,
2486
+ v as Decoration,
2487
+ Jn as Direction,
2488
+ m as EditorSelection,
2489
+ ue as EditorState,
2490
+ x as EditorView,
2491
+ Wt as ExternalChange,
2492
+ ge as Facet,
2493
+ os as GutterMarker,
2494
+ ss as Line,
2495
+ ls as MapMode,
2496
+ as as MatchDecorator,
2497
+ Qn as Prec,
2498
+ cs as Range,
2499
+ hs as RangeSet,
2500
+ Ut as RangeSetBuilder,
2501
+ us as RangeValue,
2502
+ fs as RectangleMarker,
2503
+ ds as SelectionRange,
2504
+ F as StateEffect,
2505
+ ms as StateEffectType,
2506
+ et as StateField,
2507
+ Nt as Text,
2508
+ Ve as Transaction,
2509
+ Ht as ViewPlugin,
2510
+ gs as ViewUpdate,
2511
+ tr as WidgetType,
2512
+ Dt as basicSetup,
2513
+ jn as codePointAt,
2514
+ Yn as codePointSize,
2515
+ Re as combineConfig,
2516
+ tt as countColumn,
2517
+ fr as crosshairCursor,
2518
+ Ko as default,
2519
+ Po as defaultLightThemeOption,
2520
+ lr as drawSelection,
2521
+ ar as dropCursor,
2522
+ _ as findClusterBreak,
2523
+ ps as findColumn,
2524
+ Zn as fromCodePoint,
2525
+ Fo as getDefaultExtensions,
2526
+ it as getPanel,
2527
+ No as getStatistics,
2528
+ ys as getTooltip,
2529
+ ks as gutter,
2530
+ xs as gutterLineClass,
2531
+ Ss as gutterWidgetClass,
2532
+ bs as gutters,
2533
+ dr as highlightActiveLine,
2534
+ ir as highlightActiveLineGutter,
2535
+ or as highlightSpecialChars,
2536
+ er as hoverTooltip,
2537
+ Gt as keymap,
2538
+ Cs as layer,
2539
+ vs as lineNumberMarkers,
2540
+ Ms as lineNumberWidgetMarker,
2541
+ rr as lineNumbers,
2542
+ As as logException,
2543
+ Wo as oneDark,
2544
+ Oo as oneDarkHighlightStyle,
2545
+ Io as oneDarkTheme,
2546
+ pr as placeholder,
2547
+ ur as rectangularSelection,
2548
+ Xn as runScopeHandlers,
2549
+ _n as showDialog,
2550
+ Vt as showPanel,
2551
+ Ls as showTooltip,
2552
+ zo as useCodeMirror
2553
+ };