@oomol-lab/open-flow 0.1.0-alpha.9 → 0.1.0-beta.10

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 (74) hide show
  1. package/README.md +5 -1
  2. package/dist/browser/DesignerIcon-DjgOMYI5.js +2065 -0
  3. package/dist/browser/createResourceDialog-DNBueSYZ.js +505 -0
  4. package/dist/browser/{dist-n9WmBm5w.js → dist-BKuSVKCC.js} +1 -1
  5. package/dist/browser/dist-BMRLCebL.js +1893 -0
  6. package/dist/browser/{dist-DWzdGVm9.js → dist-By46o5UV.js} +74 -74
  7. package/dist/browser/dist-CP0883sY.js +4 -0
  8. package/dist/browser/{dist-B0Q2Mn0n.js → dist-Cc0y2Pli.js} +809 -810
  9. package/dist/browser/dist-CeSZ2xSM.js +444 -0
  10. package/dist/browser/{dist-Bc9TvHYl.js → dist-Dg_VXC8f.js} +134 -135
  11. package/dist/browser/{dist-DhsGR_K3.js → dist-DmuE3M0R.js} +47 -48
  12. package/dist/browser/{dist-D5mdziGP.js → dist-DpDLsYtO.js} +18 -19
  13. package/dist/browser/dist-DxahK_I8.js +2688 -0
  14. package/dist/browser/{dist-DXgEYMFx.js → dist-meg_oHVR.js} +230 -230
  15. package/dist/browser/{esm-YIGXG-Js.js → esm-yhVU_KbQ.js} +14 -15
  16. package/dist/browser/flow-authoring-module.d.ts +2 -2
  17. package/dist/browser/flow-authoring-node.d.ts +9 -4
  18. package/dist/browser/flow-authoring.d.ts +2 -1
  19. package/dist/browser/flow-authoring.js +752 -162
  20. package/dist/browser/flow-change.d.ts +122 -13
  21. package/dist/browser/flow-change.js +326 -96
  22. package/dist/browser/flow-notifications.d.ts +5 -0
  23. package/dist/browser/flowChanges-B2ttnaj9.js +12265 -0
  24. package/dist/browser/{flowRunInputEditorStore-DXOyyY7o.js → flowRunInputEditorStore-DDidwd8h.js} +1528 -783
  25. package/dist/browser/{flowWorkspace-D7-rBA1-.js → flowWorkspace-Dr8-Hut9.js} +42428 -42499
  26. package/dist/browser/getPseudoElementBounds-5LArT6Xc.js +7147 -0
  27. package/dist/browser/icons-KIOgjHpD.js +730 -0
  28. package/dist/browser/languages-DgJehE1g.js +62 -0
  29. package/dist/browser/lib-C5Ipyfps.js +7856 -0
  30. package/dist/browser/licenses.md +119 -1
  31. package/dist/browser/main-DmjVyuWr.js +76 -0
  32. package/dist/browser/{markdownContent-ColGUxHy.js → markdownContent-DUfLdnUt.js} +4811 -4795
  33. package/dist/browser/theme.css +63 -0
  34. package/dist/browser/theme.css.d.ts +1 -0
  35. package/dist/browser/typeScriptSession-_TgJ_7Oq.js +2578 -0
  36. package/dist/browser/waitNotificationInputs-BPulOxYt.js +26 -0
  37. package/dist/browser/workbench-contract.d.ts +2 -1
  38. package/dist/browser/workbench.css +1 -1
  39. package/dist/browser/workbench.d.ts +47 -1
  40. package/dist/browser/workbench.js +1524 -1768
  41. package/dist/browser/workbenchSelect-CbXrdwxW.js +1375 -0
  42. package/dist/common/connector-action.d.ts +6 -0
  43. package/dist/common/connector-action.js +37 -29
  44. package/dist/common/control-api-conformance.d.ts +1 -0
  45. package/dist/common/control-api-conformance.js +171 -51
  46. package/dist/common/control-api-errors.d.ts +28 -0
  47. package/dist/common/control-api.d.ts +80 -21
  48. package/dist/common/control-api.js +311 -131
  49. package/dist/common/flow-encoding.d.ts +2 -2
  50. package/dist/common/flow-encoding.js +28 -9
  51. package/dist/common/flow-notifications.d.ts +5 -0
  52. package/dist/common/flow-semantics.d.ts +4 -0
  53. package/dist/common/flow-semantics.js +3544 -1098
  54. package/dist/common/integration-trigger.d.ts +1 -0
  55. package/dist/common/licenses.md +1 -25
  56. package/dist/common/localization.d.ts +21 -0
  57. package/dist/common/localization.js +62 -0
  58. package/dist/common/provider-triggers.js +4 -1
  59. package/dist/common/run-events.js +2 -1
  60. package/dist/common/run-lifecycle.d.ts +17 -2
  61. package/dist/common/run-lifecycle.js +53 -2
  62. package/dist/common/runtime-contract.d.ts +1 -1
  63. package/dist/common/runtime-contract.js +27 -0
  64. package/dist/common/scheduler.d.ts +68 -7
  65. package/dist/common/scheduler.js +528 -240
  66. package/dist/index.d.ts +2 -1
  67. package/package.json +10 -1
  68. package/dist/browser/addNodeOptions-DRndy4EK.js +0 -6910
  69. package/dist/browser/createLucideIcon-CqjqCezK.js +0 -5537
  70. package/dist/browser/createResourceDialog-A64dDFCG.js +0 -467
  71. package/dist/browser/dist-CUkceEvN.js +0 -1620
  72. package/dist/browser/dist-CVtP-E2c.js +0 -1543
  73. package/dist/browser/dist-DQVavPcf.js +0 -2328
  74. package/dist/browser/field-CKGQHCIi.js +0 -312
@@ -0,0 +1,1893 @@
1
+ import { E as e, M as t, T as n, _ as r, b as i, c as a, d as o, h as s, j as c, k as l, n as u, w as d, x as f, z as p } from "./dist-DxahK_I8.js";
2
+ import { S as m, _ as ee, a as h, b as te, d as ne, g as re, h as ie, i as g, l as ae, m as oe, n as se, o as ce, p as _, r as le, s as v, t as ue, v as de, w as fe, y as pe } from "./dist-Mecbzdl2.js";
3
+ import { C as me, E as he, O as y, T as ge, _ as _e, a as ve, b as ye, c as be, d as xe, g as Se, n as Ce, p as we, r as b, t as x, u as Te, v as Ee, w as De, x as Oe } from "./dist-BKuSVKCC.js";
4
+ import { i as ke, n as Ae, o as je, r as Me } from "./dist-meg_oHVR.js";
5
+ import { t as Ne } from "./dist-CeSZ2xSM.js";
6
+ //#region ../../node_modules/.bun/@codemirror+commands@6.11.0/node_modules/@codemirror/commands/dist/index.js
7
+ var Pe = (e) => {
8
+ let { state: t } = e, n = t.doc.lineAt(t.selection.main.from), r = ze(e.state, n.from);
9
+ return r.line ? Ie(e) : r.block ? Re(e) : !1;
10
+ };
11
+ function Fe(e, t) {
12
+ return ({ state: n, dispatch: r }) => {
13
+ if (n.readOnly) return !1;
14
+ let i = e(t, n);
15
+ return i ? (r(n.update(i)), !0) : !1;
16
+ };
17
+ }
18
+ var Ie = /*@__PURE__*/ Fe(Ue, 0), Le = /*@__PURE__*/ Fe(He, 0), Re = /*@__PURE__*/ Fe((e, t) => He(e, t, Ve(t)), 0);
19
+ function ze(e, t) {
20
+ let n = e.languageDataAt("commentTokens", t, 1);
21
+ return n.length ? n[0] : {};
22
+ }
23
+ var S = 50;
24
+ function Be(e, { open: t, close: n }, r, i) {
25
+ let a = e.sliceDoc(r - S, r), o = e.sliceDoc(i, i + S), s = /\s*$/.exec(a)[0].length, c = /^\s*/.exec(o)[0].length, l = a.length - s;
26
+ if (a.slice(l - t.length, l) == t && o.slice(c, c + n.length) == n) return {
27
+ open: {
28
+ pos: r - s,
29
+ margin: s && 1
30
+ },
31
+ close: {
32
+ pos: i + c,
33
+ margin: c && 1
34
+ }
35
+ };
36
+ let u, d;
37
+ i - r <= 100 ? u = d = e.sliceDoc(r, i) : (u = e.sliceDoc(r, r + S), d = e.sliceDoc(i - S, i));
38
+ let f = /^\s*/.exec(u)[0].length, p = /\s*$/.exec(d)[0].length, m = d.length - p - n.length;
39
+ return u.slice(f, f + t.length) == t && d.slice(m, m + n.length) == n ? {
40
+ open: {
41
+ pos: r + f + t.length,
42
+ margin: +!!/\s/.test(u.charAt(f + t.length))
43
+ },
44
+ close: {
45
+ pos: i - p - n.length,
46
+ margin: +!!/\s/.test(d.charAt(m - 1))
47
+ }
48
+ } : null;
49
+ }
50
+ function Ve(e) {
51
+ let t = [];
52
+ for (let n of e.selection.ranges) {
53
+ let r = e.doc.lineAt(n.from), i = n.to <= r.to ? r : e.doc.lineAt(n.to);
54
+ i.from > r.from && i.from == n.to && (i = n.to == r.to + 1 ? r : e.doc.lineAt(n.to - 1));
55
+ let a = t.length - 1;
56
+ a >= 0 && t[a].to > r.from ? t[a].to = i.to : t.push({
57
+ from: r.from + /^\s*/.exec(r.text)[0].length,
58
+ to: i.to
59
+ });
60
+ }
61
+ return t;
62
+ }
63
+ function He(e, t, n = t.selection.ranges) {
64
+ let r = n.map((e) => ze(t, e.from).block);
65
+ if (!r.every((e) => e)) return null;
66
+ let i = n.map((e, n) => Be(t, r[n], e.from, e.to));
67
+ if (e != 2 && !i.every((e) => e)) return { changes: t.changes(n.map((e, t) => i[t] ? [] : [{
68
+ from: e.from,
69
+ insert: r[t].open + " "
70
+ }, {
71
+ from: e.to,
72
+ insert: " " + r[t].close
73
+ }])) };
74
+ if (e != 1 && i.some((e) => e)) {
75
+ let e = [];
76
+ for (let t = 0, n; t < i.length; t++) if (n = i[t]) {
77
+ let i = r[t], { open: a, close: o } = n;
78
+ e.push({
79
+ from: a.pos - i.open.length,
80
+ to: a.pos + a.margin
81
+ }, {
82
+ from: o.pos - o.margin,
83
+ to: o.pos + i.close.length
84
+ });
85
+ }
86
+ return { changes: e };
87
+ }
88
+ return null;
89
+ }
90
+ function Ue(e, t, n = t.selection.ranges) {
91
+ let r = [], i = -1;
92
+ ranges: for (let { from: e, to: a } of n) {
93
+ let n = r.length, o = 1e9, s;
94
+ for (let n = e; n <= a;) {
95
+ let c = t.doc.lineAt(n);
96
+ if (s == null && (s = ze(t, c.from).line, !s)) continue ranges;
97
+ if (c.from > i && (e == a || a > c.from)) {
98
+ i = c.from;
99
+ let e = /^\s*/.exec(c.text)[0].length, t = e == c.length, n = c.text.slice(e, e + s.length) == s ? e : -1;
100
+ e < c.text.length && e < o && (o = e), r.push({
101
+ line: c,
102
+ comment: n,
103
+ token: s,
104
+ indent: e,
105
+ empty: t,
106
+ single: !1
107
+ });
108
+ }
109
+ n = c.to + 1;
110
+ }
111
+ if (o < 1e9) for (let e = n; e < r.length; e++) r[e].indent < r[e].line.text.length && (r[e].indent = o);
112
+ r.length == n + 1 && (r[n].single = !0);
113
+ }
114
+ if (e != 2 && r.some((e) => e.comment < 0 && (!e.empty || e.single))) {
115
+ let e = [];
116
+ for (let { line: t, token: n, indent: i, empty: a, single: o } of r) (o || !a) && e.push({
117
+ from: t.from + i,
118
+ insert: n + " "
119
+ });
120
+ let n = t.changes(e);
121
+ return {
122
+ changes: n,
123
+ selection: t.selection.map(n, 1)
124
+ };
125
+ }
126
+ if (e != 1 && r.some((e) => e.comment >= 0)) {
127
+ let e = [];
128
+ for (let { line: t, comment: n, token: i } of r) if (n >= 0) {
129
+ let r = t.from + n, a = r + i.length;
130
+ t.text[a - t.from] == " " && a++, e.push({
131
+ from: r,
132
+ to: a
133
+ });
134
+ }
135
+ return { changes: e };
136
+ }
137
+ return null;
138
+ }
139
+ var We = /*@__PURE__*/ ue.define(), Ge = /*@__PURE__*/ ue.define(), Ke = /*@__PURE__*/ v.define(), qe = /*@__PURE__*/ v.define({ combine(e) {
140
+ return pe(e, {
141
+ minDepth: 100,
142
+ newGroupDelay: 500,
143
+ joinToEvent: (e, t) => t
144
+ }, {
145
+ minDepth: Math.max,
146
+ newGroupDelay: Math.min,
147
+ joinToEvent: (e, t) => (n, r) => e(n, r) || t(n, r)
148
+ });
149
+ } }), Je = /*@__PURE__*/ oe.define({
150
+ create() {
151
+ return D.empty;
152
+ },
153
+ update(e, t) {
154
+ let n = t.state.facet(qe), r = t.annotation(We);
155
+ if (r) {
156
+ let i = w.fromTransaction(t, r.selection), a = r.side, o = a == 0 ? e.undone : e.done;
157
+ return o = i ? T(o, o.length, n.minDepth, i) : it(o, t.startState.selection), new D(a == 0 ? r.rest : o, a == 0 ? o : r.rest);
158
+ }
159
+ let i = t.annotation(Ge);
160
+ if ((i == "full" || i == "before") && (e = e.isolate()), t.annotation(re.addToHistory) === !1) return t.changes.empty ? e : e.addMapping(t.changes.desc);
161
+ let a = w.fromTransaction(t), o = t.annotation(re.time), s = t.annotation(re.userEvent);
162
+ return a ? e = e.addChanges(a, o, s, n, t) : t.selection && (e = e.addSelection(t.startState.selection, o, s, n.newGroupDelay)), (i == "full" || i == "after") && (e = e.isolate()), e;
163
+ },
164
+ toJSON(e) {
165
+ return {
166
+ done: e.done.map((e) => e.toJSON()),
167
+ undone: e.undone.map((e) => e.toJSON())
168
+ };
169
+ },
170
+ fromJSON(e) {
171
+ return new D(e.done.map(w.fromJSON), e.undone.map(w.fromJSON));
172
+ }
173
+ });
174
+ function Ye(e = {}) {
175
+ return [
176
+ Je,
177
+ qe.of(e),
178
+ b.domEventHandlers({ beforeinput(e, t) {
179
+ let n = e.inputType == "historyUndo" ? Xe : e.inputType == "historyRedo" ? Ze : null;
180
+ return n ? (e.preventDefault(), n(t)) : !1;
181
+ } })
182
+ ];
183
+ }
184
+ function C(e, t) {
185
+ return function({ state: n, dispatch: r }) {
186
+ if (!t && n.readOnly) return !1;
187
+ let i = n.field(Je, !1);
188
+ if (!i) return !1;
189
+ let a = i.pop(e, n, t);
190
+ return a ? (r(a), !0) : !1;
191
+ };
192
+ }
193
+ var Xe = /*@__PURE__*/ C(0, !1), Ze = /*@__PURE__*/ C(1, !1), Qe = /*@__PURE__*/ C(0, !0), $e = /*@__PURE__*/ C(1, !0), w = class e {
194
+ constructor(e, t, n, r, i) {
195
+ this.changes = e, this.effects = t, this.mapped = n, this.startSelection = r, this.selectionsAfter = i;
196
+ }
197
+ setSelAfter(t) {
198
+ return new e(this.changes, this.effects, this.mapped, this.startSelection, t);
199
+ }
200
+ toJSON() {
201
+ return {
202
+ changes: this.changes?.toJSON(),
203
+ mapped: this.mapped?.toJSON(),
204
+ startSelection: this.startSelection?.toJSON(),
205
+ selectionsAfter: this.selectionsAfter.map((e) => e.toJSON())
206
+ };
207
+ }
208
+ static fromJSON(t) {
209
+ return new e(t.changes && le.fromJSON(t.changes), [], t.mapped && se.fromJSON(t.mapped), t.startSelection && h.fromJSON(t.startSelection), t.selectionsAfter.map(h.fromJSON));
210
+ }
211
+ static fromTransaction(t, n) {
212
+ let r = E;
213
+ for (let e of t.startState.facet(Ke)) {
214
+ let n = e(t);
215
+ n.length && (r = r.concat(n));
216
+ }
217
+ return !r.length && t.changes.empty ? null : new e(t.changes.invert(t.startState.doc), r, void 0, n || t.startState.selection, E);
218
+ }
219
+ static selection(t) {
220
+ return new e(void 0, E, void 0, void 0, t);
221
+ }
222
+ };
223
+ function T(e, t, n, r) {
224
+ let i = t + 1 > n + 20 ? t - n - 1 : 0, a = e.slice(i, t);
225
+ return a.push(r), a;
226
+ }
227
+ function et(e, t) {
228
+ let n = [], r = !1;
229
+ return e.iterChangedRanges((e, t) => n.push(e, t)), t.iterChangedRanges((e, t, i, a) => {
230
+ for (let e = 0; e < n.length;) {
231
+ let t = n[e++], o = n[e++];
232
+ a >= t && i <= o && (r = !0);
233
+ }
234
+ }), r;
235
+ }
236
+ function tt(e, t) {
237
+ return e.ranges.length == t.ranges.length && e.ranges.filter((e, n) => e.empty != t.ranges[n].empty).length === 0;
238
+ }
239
+ function nt(e, t) {
240
+ return e.length ? t.length ? e.concat(t) : e : t;
241
+ }
242
+ var E = [], rt = 200;
243
+ function it(e, t) {
244
+ if (e.length) {
245
+ let n = e[e.length - 1], r = n.selectionsAfter.slice(Math.max(0, n.selectionsAfter.length - rt));
246
+ return r.length && r[r.length - 1].eq(t) ? e : (r.push(t), T(e, e.length - 1, 1e9, n.setSelAfter(r)));
247
+ }
248
+ return [w.selection([t])];
249
+ }
250
+ function at(e) {
251
+ let t = e[e.length - 1], n = e.slice();
252
+ return n[e.length - 1] = t.setSelAfter(t.selectionsAfter.slice(0, t.selectionsAfter.length - 1)), n;
253
+ }
254
+ function ot(e, t) {
255
+ if (!e.length) return e;
256
+ let n = e.length, r = E;
257
+ for (; n;) {
258
+ let i = st(e[n - 1], t, r);
259
+ if (i.changes && !i.changes.empty || i.effects.length) {
260
+ let t = e.slice(0, n);
261
+ return t[n - 1] = i, t;
262
+ }
263
+ t = i.mapped, n--, r = i.selectionsAfter;
264
+ }
265
+ return r.length ? [w.selection(r)] : E;
266
+ }
267
+ function st(e, t, n) {
268
+ let r = nt(e.selectionsAfter.length ? e.selectionsAfter.map((e) => e.map(t)) : E, n);
269
+ if (!e.changes) return w.selection(r);
270
+ let i = e.changes.map(t), a = t.mapDesc(e.changes, !0), o = e.mapped ? e.mapped.composeDesc(a) : a;
271
+ return new w(i, _.mapEffects(e.effects, t), o, e.startSelection.map(a), r);
272
+ }
273
+ var ct = /^(input\.type|delete)($|\.)/, D = class e {
274
+ constructor(e, t, n = 0, r = void 0) {
275
+ this.done = e, this.undone = t, this.prevTime = n, this.prevUserEvent = r;
276
+ }
277
+ isolate() {
278
+ return this.prevTime ? new e(this.done, this.undone) : this;
279
+ }
280
+ addChanges(t, n, r, i, a) {
281
+ let o = this.done, s = o[o.length - 1];
282
+ return o = s && s.changes && !s.changes.empty && t.changes && (!r || ct.test(r)) && (!s.selectionsAfter.length && n - this.prevTime < i.newGroupDelay && i.joinToEvent(a, et(s.changes, t.changes)) || r == "input.type.compose") ? T(o, o.length - 1, i.minDepth, new w(t.changes.compose(s.changes), nt(_.mapEffects(t.effects, s.changes), s.effects), s.mapped, s.startSelection, E)) : T(o, o.length, i.minDepth, t), new e(o, E, n, r);
283
+ }
284
+ addSelection(t, n, r, i) {
285
+ let a = this.done.length ? this.done[this.done.length - 1].selectionsAfter : E;
286
+ return a.length > 0 && n - this.prevTime < i && r == this.prevUserEvent && r && /^select($|\.)/.test(r) && tt(a[a.length - 1], t) ? this : new e(it(this.done, t), this.undone, n, r);
287
+ }
288
+ addMapping(t) {
289
+ return new e(ot(this.done, t), ot(this.undone, t), this.prevTime, this.prevUserEvent);
290
+ }
291
+ pop(e, t, n) {
292
+ let r = e == 0 ? this.done : this.undone;
293
+ if (r.length == 0) return null;
294
+ let i = r[r.length - 1], a = i.selectionsAfter[0] || (i.startSelection ? i.startSelection.map(i.changes.invertedDesc, 1) : t.selection);
295
+ if (n && i.selectionsAfter.length) return t.update({
296
+ selection: i.selectionsAfter[i.selectionsAfter.length - 1],
297
+ annotations: We.of({
298
+ side: e,
299
+ rest: at(r),
300
+ selection: a
301
+ }),
302
+ userEvent: e == 0 ? "select.undo" : "select.redo",
303
+ scrollIntoView: !0
304
+ });
305
+ if (i.changes) {
306
+ let n = r.length == 1 ? E : r.slice(0, r.length - 1);
307
+ return i.mapped && (n = ot(n, i.mapped)), t.update({
308
+ changes: i.changes,
309
+ selection: i.startSelection,
310
+ effects: i.effects,
311
+ annotations: We.of({
312
+ side: e,
313
+ rest: n,
314
+ selection: a
315
+ }),
316
+ filter: !1,
317
+ userEvent: e == 0 ? "undo" : "redo",
318
+ scrollIntoView: !0
319
+ });
320
+ }
321
+ return null;
322
+ }
323
+ };
324
+ D.empty = /*@__PURE__*/ new D(E, E);
325
+ var lt = [
326
+ {
327
+ key: "Mod-z",
328
+ run: Xe,
329
+ preventDefault: !0
330
+ },
331
+ {
332
+ key: "Mod-y",
333
+ mac: "Mod-Shift-z",
334
+ run: Ze,
335
+ preventDefault: !0
336
+ },
337
+ {
338
+ linux: "Ctrl-Shift-z",
339
+ run: Ze,
340
+ preventDefault: !0
341
+ },
342
+ {
343
+ key: "Mod-u",
344
+ run: Qe,
345
+ preventDefault: !0
346
+ },
347
+ {
348
+ key: "Alt-u",
349
+ mac: "Mod-Shift-u",
350
+ run: $e,
351
+ preventDefault: !0
352
+ }
353
+ ];
354
+ function O(e, t) {
355
+ return h.create(e.ranges.map(t), e.mainIndex);
356
+ }
357
+ function k(e, t) {
358
+ return e.update({
359
+ selection: t,
360
+ scrollIntoView: !0,
361
+ userEvent: "select"
362
+ });
363
+ }
364
+ function A({ state: e, dispatch: t }, n) {
365
+ let r = O(e.selection, n);
366
+ return !r.eq(e.selection, !0) && (t(k(e, r)), !0);
367
+ }
368
+ function j(e, t) {
369
+ return h.cursor(t ? e.to : e.from);
370
+ }
371
+ function ut(e, t) {
372
+ return A(e, (n) => n.empty ? e.moveByChar(n, t) : j(n, t));
373
+ }
374
+ function M(e) {
375
+ return e.textDirectionAt(e.state.selection.main.head) == Ce.LTR;
376
+ }
377
+ var dt = (e) => ut(e, !M(e)), ft = (e) => ut(e, M(e));
378
+ function pt(e, t) {
379
+ return A(e, (n) => n.empty ? e.moveByGroup(n, t) : j(n, t));
380
+ }
381
+ var mt = (e) => pt(e, !M(e)), ht = (e) => pt(e, M(e));
382
+ typeof Intl < "u" && Intl.Segmenter;
383
+ function gt(e, t, n) {
384
+ if (t.type.prop(n)) return !0;
385
+ let r = t.to - t.from;
386
+ return r && (r > 2 || /[^\s,.;:]/.test(e.sliceDoc(t.from, t.to))) || t.firstChild;
387
+ }
388
+ function N(e, n, r) {
389
+ let i = t(e).resolveInner(n.head), a = r ? p.closedBy : p.openedBy;
390
+ for (let t = n.head;;) {
391
+ let n = r ? i.childAfter(t) : i.childBefore(t);
392
+ if (!n) break;
393
+ gt(e, n, a) ? i = n : t = r ? n.to : n.from;
394
+ }
395
+ let o = i.type.prop(a), s, c;
396
+ return c = o && (s = r ? l(e, i.from, 1) : l(e, i.to, -1)) && s.matched ? r ? s.end.to : s.end.from : r ? i.to : i.from, h.cursor(c, r ? -1 : 1);
397
+ }
398
+ var _t = (e) => A(e, (t) => N(e.state, t, !M(e))), vt = (e) => A(e, (t) => N(e.state, t, M(e)));
399
+ function yt(e, t) {
400
+ return A(e, (n) => {
401
+ if (!n.empty) return j(n, t);
402
+ let r = e.moveVertically(n, t);
403
+ return r.head == n.head ? e.moveToLineBoundary(n, t) : r;
404
+ });
405
+ }
406
+ var bt = (e) => yt(e, !1), xt = (e) => yt(e, !0);
407
+ function St(e) {
408
+ let t = e.scrollDOM.clientHeight < e.scrollDOM.scrollHeight - 2, n = 0, r = 0, i;
409
+ if (t) {
410
+ for (let t of e.state.facet(b.scrollMargins)) {
411
+ let i = t(e);
412
+ i?.top && (n = Math.max(i?.top, n)), i?.bottom && (r = Math.max(i?.bottom, r));
413
+ }
414
+ i = e.scrollDOM.clientHeight - n - r;
415
+ } else i = (e.dom.ownerDocument.defaultView || window).innerHeight;
416
+ return {
417
+ marginTop: n,
418
+ marginBottom: r,
419
+ selfScroll: t,
420
+ height: Math.max(e.defaultLineHeight, i - 5)
421
+ };
422
+ }
423
+ function Ct(e, t) {
424
+ let n = St(e), { state: r } = e, i = O(r.selection, (r) => r.empty ? e.moveVertically(r, t, n.height) : j(r, t));
425
+ if (i.eq(r.selection)) return !1;
426
+ let a;
427
+ if (n.selfScroll) {
428
+ let t = e.coordsAtPos(r.selection.main.head), o = e.scrollDOM.getBoundingClientRect(), s = o.top + n.marginTop, c = o.bottom - n.marginBottom;
429
+ t && t.top > s && t.bottom < c && (a = b.scrollIntoView(i.main.head, {
430
+ y: "start",
431
+ yMargin: t.top - s
432
+ }));
433
+ }
434
+ return e.dispatch(k(r, i), { effects: a }), !0;
435
+ }
436
+ var wt = (e) => Ct(e, !1), Tt = (e) => Ct(e, !0);
437
+ function P(e, t, n) {
438
+ let r = e.lineBlockAt(t.head), i = e.moveToLineBoundary(t, n);
439
+ if (i.head == t.head && i.head != (n ? r.to : r.from) && (i = e.moveToLineBoundary(t, n, !1)), !n && i.head == r.from && r.length) {
440
+ let n = /^\s*/.exec(e.state.sliceDoc(r.from, Math.min(r.from + 100, r.to)))[0].length;
441
+ n && t.head != r.from + n && (i = h.cursor(r.from + n));
442
+ }
443
+ return i;
444
+ }
445
+ var Et = (e) => A(e, (t) => P(e, t, !0)), Dt = (e) => A(e, (t) => P(e, t, !1)), Ot = (e) => A(e, (t) => P(e, t, !M(e))), kt = (e) => A(e, (t) => P(e, t, M(e))), At = (e) => A(e, (t) => h.cursor(e.lineBlockAt(t.head).from, 1)), jt = (e) => A(e, (t) => h.cursor(e.lineBlockAt(t.head).to, -1));
446
+ function Mt(e, t, n) {
447
+ let r = !1, i = O(e.selection, (t) => {
448
+ let i = l(e, t.head, -1) || l(e, t.head, 1) || t.head > 0 && l(e, t.head - 1, 1) || t.head < e.doc.length && l(e, t.head + 1, -1);
449
+ if (!i || !i.end) return t;
450
+ r = !0;
451
+ let a = i.start.from == t.head ? i.end.to : i.end.from;
452
+ return n ? h.range(t.anchor, a) : h.cursor(a);
453
+ });
454
+ return r ? (t(k(e, i)), !0) : !1;
455
+ }
456
+ var Nt = ({ state: e, dispatch: t }) => Mt(e, t, !1);
457
+ function F(e, t, n) {
458
+ let r = O(e.state.selection, (e) => {
459
+ e.undirectional && e.head >= e.anchor != t && (e = h.range(e.head, e.anchor));
460
+ let r = n(e);
461
+ return h.range(e.anchor, r.head, r.goalColumn, r.bidiLevel || void 0, r.assoc);
462
+ });
463
+ return !r.eq(e.state.selection) && (e.dispatch(k(e.state, r)), !0);
464
+ }
465
+ function Pt(e, t) {
466
+ return F(e, t, (n) => e.moveByChar(n, t));
467
+ }
468
+ var Ft = (e) => Pt(e, !M(e)), It = (e) => Pt(e, M(e));
469
+ function Lt(e, t) {
470
+ return F(e, t, (n) => e.moveByGroup(n, t));
471
+ }
472
+ var Rt = (e) => Lt(e, !M(e)), zt = (e) => Lt(e, M(e)), Bt = (e) => {
473
+ let t = !M(e);
474
+ return F(e, t, (n) => N(e.state, n, t));
475
+ }, Vt = (e) => {
476
+ let t = M(e);
477
+ return F(e, t, (n) => N(e.state, n, t));
478
+ };
479
+ function Ht(e, t) {
480
+ return F(e, t, (n) => e.moveVertically(n, t));
481
+ }
482
+ var Ut = (e) => Ht(e, !1), Wt = (e) => Ht(e, !0);
483
+ function Gt(e, t) {
484
+ return F(e, t, (n) => e.moveVertically(n, t, St(e).height));
485
+ }
486
+ var Kt = (e) => Gt(e, !1), qt = (e) => Gt(e, !0), Jt = (e) => F(e, !0, (t) => P(e, t, !0)), Yt = (e) => F(e, !1, (t) => P(e, t, !1)), Xt = (e) => {
487
+ let t = !M(e);
488
+ return F(e, t, (n) => P(e, n, t));
489
+ }, Zt = (e) => {
490
+ let t = M(e);
491
+ return F(e, t, (n) => P(e, n, t));
492
+ }, Qt = (e) => F(e, !1, (t) => h.cursor(e.lineBlockAt(t.head).from)), $t = (e) => F(e, !0, (t) => h.cursor(e.lineBlockAt(t.head).to)), en = ({ state: e, dispatch: t }) => (t(k(e, { anchor: 0 })), !0), tn = ({ state: e, dispatch: t }) => (t(k(e, { anchor: e.doc.length })), !0), nn = ({ state: e, dispatch: t }) => (t(k(e, {
493
+ anchor: e.selection.main.anchor,
494
+ head: 0
495
+ })), !0), rn = ({ state: e, dispatch: t }) => (t(k(e, {
496
+ anchor: e.selection.main.anchor,
497
+ head: e.doc.length
498
+ })), !0), an = ({ state: e, dispatch: t }) => (t(e.update({
499
+ selection: {
500
+ anchor: 0,
501
+ head: e.doc.length
502
+ },
503
+ userEvent: "select"
504
+ })), !0), on = ({ state: e, dispatch: t }) => {
505
+ let n = R(e).map(({ from: t, to: n }) => h.undirectionalRange(t, Math.min(n + 1, e.doc.length)));
506
+ return t(e.update({
507
+ selection: h.create(n),
508
+ userEvent: "select"
509
+ })), !0;
510
+ }, sn = ({ state: e, dispatch: n }) => {
511
+ let r = O(e.selection, (n) => {
512
+ let r = t(e), i = r.resolveStack(n.from, 1);
513
+ if (n.empty) {
514
+ let e = r.resolveStack(n.from, -1);
515
+ e.node.from >= i.node.from && e.node.to <= i.node.to && (i = e);
516
+ }
517
+ for (let e = i; e; e = e.next) {
518
+ let { node: t } = e;
519
+ if ((t.from < n.from && t.to >= n.to || t.to > n.to && t.from <= n.from) && e.next) return h.undirectionalRange(t.from, t.to);
520
+ }
521
+ return n;
522
+ });
523
+ return !r.eq(e.selection) && (n(k(e, r)), !0);
524
+ };
525
+ function cn(e, t) {
526
+ let { state: n } = e, r = n.selection, i = n.selection.ranges.slice();
527
+ for (let r of n.selection.ranges) {
528
+ let a = n.doc.lineAt(r.head);
529
+ if (t ? a.to < e.state.doc.length : a.from > 0) for (let n = r;;) {
530
+ let r = e.moveVertically(n, t);
531
+ if (r.head < a.from || r.head > a.to) {
532
+ i.some((e) => e.head == r.head) || i.push(r);
533
+ break;
534
+ }
535
+ if (r.head == n.head) break;
536
+ n = r;
537
+ }
538
+ }
539
+ return i.length != r.ranges.length && (e.dispatch(k(n, h.create(i, i.length - 1))), !0);
540
+ }
541
+ var ln = (e) => cn(e, !1), un = (e) => cn(e, !0), dn = ({ state: e, dispatch: t }) => {
542
+ let n = e.selection, r = null;
543
+ return n.ranges.length > 1 ? r = h.create([n.main]) : n.main.empty || (r = h.create([h.cursor(n.main.head)])), r ? (t(k(e, r)), !0) : !1;
544
+ };
545
+ function I(e, t) {
546
+ if (e.state.readOnly) return !1;
547
+ let n = "delete.selection", { state: r } = e, i = r.changeByRange((r) => {
548
+ let { from: i, to: a } = r;
549
+ if (i == a) {
550
+ let o = t(r);
551
+ o < i ? (n = "delete.backward", o = L(e, o, !1)) : o > i && (n = "delete.forward", o = L(e, o, !0)), i = Math.min(i, o), a = Math.max(a, o);
552
+ } else i = L(e, i, !1), a = L(e, a, !0);
553
+ return i == a ? { range: r } : {
554
+ changes: {
555
+ from: i,
556
+ to: a
557
+ },
558
+ range: h.cursor(i, i < r.head ? -1 : 1)
559
+ };
560
+ });
561
+ return !i.changes.empty && (e.dispatch(r.update(i, {
562
+ scrollIntoView: !0,
563
+ userEvent: n,
564
+ effects: n == "delete.selection" ? b.announce.of(r.phrase("Selection deleted")) : void 0
565
+ })), !0);
566
+ }
567
+ function L(e, t, n) {
568
+ if (e instanceof b) for (let r of e.state.facet(b.atomicRanges).map((t) => t(e))) r.between(t, t, (e, r) => {
569
+ e < t && r > t && (t = n ? r : e);
570
+ });
571
+ return t;
572
+ }
573
+ var fn = (e, t, n) => I(e, (r) => {
574
+ let a = r.from, { state: o } = e, s = o.doc.lineAt(a), c, l;
575
+ if (n && !t && a > s.from && a < s.from + 200 && !/[^ \t]/.test(c = s.text.slice(0, a - s.from))) {
576
+ if (c[c.length - 1] == " ") return a - 1;
577
+ let e = te(c, o.tabSize) % i(o) || i(o);
578
+ for (let t = 0; t < e && c[c.length - 1 - t] == " "; t++) a--;
579
+ l = a;
580
+ } else l = m(s.text, a - s.from, t, t) + s.from, l == a && s.number != (t ? o.doc.lines : 1) ? l += t ? 1 : -1 : !t && /[\ufe00-\ufe0f]/.test(s.text.slice(l - s.from, a - s.from)) && (l = m(s.text, l - s.from, !1, !1) + s.from);
581
+ return l;
582
+ }), pn = (e) => fn(e, !1, !0), mn = (e) => fn(e, !0, !1), hn = (e, t) => I(e, (n) => {
583
+ let r = n.head, { state: i } = e, a = i.doc.lineAt(r), o = i.charCategorizer(r);
584
+ for (let e = null;;) {
585
+ if (r == (t ? a.to : a.from)) {
586
+ r == n.head && a.number != (t ? i.doc.lines : 1) && (r += t ? 1 : -1);
587
+ break;
588
+ }
589
+ let s = m(a.text, r - a.from, t) + a.from, c = a.text.slice(Math.min(r, s) - a.from, Math.max(r, s) - a.from), l = o(c);
590
+ if (e != null && l != e) break;
591
+ (c != " " || r != n.head) && (e = l), r = s;
592
+ }
593
+ return r;
594
+ }), gn = (e) => hn(e, !1), _n = (e) => hn(e, !0), vn = (e) => I(e, (t) => {
595
+ let n = e.lineBlockAt(t.head).to;
596
+ return t.head < n ? n : Math.min(e.state.doc.length, t.head + 1);
597
+ }), yn = (e) => I(e, (t) => {
598
+ let n = e.moveToLineBoundary(t, !1).head;
599
+ return t.head > n ? n : Math.max(0, t.head - 1);
600
+ }), bn = (e) => I(e, (t) => {
601
+ let n = e.moveToLineBoundary(t, !0).head;
602
+ return t.head < n ? n : Math.min(e.state.doc.length, t.head + 1);
603
+ }), xn = ({ state: e, dispatch: t }) => {
604
+ if (e.readOnly) return !1;
605
+ let n = e.changeByRange((e) => ({
606
+ changes: {
607
+ from: e.from,
608
+ to: e.to,
609
+ insert: ie.of(["", ""])
610
+ },
611
+ range: h.cursor(e.from)
612
+ }));
613
+ return t(e.update(n, {
614
+ scrollIntoView: !0,
615
+ userEvent: "input"
616
+ })), !0;
617
+ }, Sn = ({ state: e, dispatch: t }) => {
618
+ if (e.readOnly) return !1;
619
+ let n = e.changeByRange((t) => {
620
+ if (!t.empty || t.from == 0 || t.from == e.doc.length) return { range: t };
621
+ let n = t.from, r = e.doc.lineAt(n), i = n == r.from ? n - 1 : m(r.text, n - r.from, !1) + r.from, a = n == r.to ? n + 1 : m(r.text, n - r.from, !0) + r.from;
622
+ return {
623
+ changes: {
624
+ from: i,
625
+ to: a,
626
+ insert: e.doc.slice(n, a).append(e.doc.slice(i, n))
627
+ },
628
+ range: h.cursor(a)
629
+ };
630
+ });
631
+ return !n.changes.empty && (t(e.update(n, {
632
+ scrollIntoView: !0,
633
+ userEvent: "move.character"
634
+ })), !0);
635
+ };
636
+ function R(e) {
637
+ let t = [], n = -1;
638
+ for (let r of e.selection.ranges) {
639
+ let i = e.doc.lineAt(r.from), a = e.doc.lineAt(r.to);
640
+ if (!r.empty && r.to == a.from && (a = e.doc.lineAt(r.to - 1)), n >= i.number) {
641
+ let e = t[t.length - 1];
642
+ e.to = a.to, e.ranges.push(r);
643
+ } else t.push({
644
+ from: i.from,
645
+ to: a.to,
646
+ ranges: [r]
647
+ });
648
+ n = a.number + 1;
649
+ }
650
+ return t;
651
+ }
652
+ function Cn(e, t, n) {
653
+ if (e.readOnly) return !1;
654
+ let r = [], i = [];
655
+ for (let t of R(e)) {
656
+ if (n ? t.to == e.doc.length : t.from == 0) continue;
657
+ let a = e.doc.lineAt(n ? t.to + 1 : t.from - 1), o = a.length + 1;
658
+ if (n) {
659
+ r.push({
660
+ from: t.to,
661
+ to: a.to
662
+ }, {
663
+ from: t.from,
664
+ insert: a.text + e.lineBreak
665
+ });
666
+ for (let n of t.ranges) i.push(h.range(Math.min(e.doc.length, n.anchor + o), Math.min(e.doc.length, n.head + o)));
667
+ } else {
668
+ r.push({
669
+ from: a.from,
670
+ to: t.from
671
+ }, {
672
+ from: t.to,
673
+ insert: e.lineBreak + a.text
674
+ });
675
+ for (let e of t.ranges) i.push(h.range(e.anchor - o, e.head - o));
676
+ }
677
+ }
678
+ return r.length ? (t(e.update({
679
+ changes: r,
680
+ scrollIntoView: !0,
681
+ selection: h.create(i, e.selection.mainIndex),
682
+ userEvent: "move.line"
683
+ })), !0) : !1;
684
+ }
685
+ var wn = ({ state: e, dispatch: t }) => Cn(e, t, !1), Tn = ({ state: e, dispatch: t }) => Cn(e, t, !0);
686
+ function En(e, t, n) {
687
+ if (e.readOnly) return !1;
688
+ let r = [];
689
+ for (let t of R(e)) n ? r.push({
690
+ from: t.from,
691
+ insert: e.doc.slice(t.from, t.to) + e.lineBreak
692
+ }) : r.push({
693
+ from: t.to,
694
+ insert: e.lineBreak + e.doc.slice(t.from, t.to)
695
+ });
696
+ let i = e.changes(r);
697
+ return t(e.update({
698
+ changes: i,
699
+ selection: e.selection.map(i, n ? 1 : -1),
700
+ scrollIntoView: !0,
701
+ userEvent: "input.copyline"
702
+ })), !0;
703
+ }
704
+ var Dn = ({ state: e, dispatch: t }) => En(e, t, !1), On = ({ state: e, dispatch: t }) => En(e, t, !0), kn = (e) => {
705
+ if (e.state.readOnly) return !1;
706
+ let { state: t } = e, n = t.changes(R(t).map(({ from: e, to: n }) => (e > 0 ? e-- : n < t.doc.length && n++, {
707
+ from: e,
708
+ to: n
709
+ }))), r = O(t.selection, (t) => {
710
+ let n;
711
+ if (e.lineWrapping) {
712
+ let r = e.lineBlockAt(t.head), i = e.coordsAtPos(t.head, t.assoc || 1);
713
+ i && (n = r.bottom + e.documentTop - i.bottom + e.defaultLineHeight / 2);
714
+ }
715
+ return e.moveVertically(t, !0, n);
716
+ }).map(n);
717
+ return e.dispatch({
718
+ changes: n,
719
+ selection: r,
720
+ scrollIntoView: !0,
721
+ userEvent: "delete.line"
722
+ }), !0;
723
+ };
724
+ function An(e, n) {
725
+ if (/\(\)|\[\]|\{\}/.test(e.sliceDoc(n - 1, n + 1))) return {
726
+ from: n,
727
+ to: n
728
+ };
729
+ let r = t(e).resolveInner(n), i = r.childBefore(n), a = r.childAfter(n), o;
730
+ return i && a && i.to <= n && a.from >= n && (o = i.type.prop(p.closedBy)) && o.indexOf(a.name) > -1 && e.doc.lineAt(i.to).from == e.doc.lineAt(a.from).from && !/\S/.test(e.sliceDoc(i.to, a.from)) ? {
731
+ from: i.to,
732
+ to: a.from
733
+ } : null;
734
+ }
735
+ var jn = /*@__PURE__*/ Nn(!1), Mn = /*@__PURE__*/ Nn(!0);
736
+ function Nn(e) {
737
+ return ({ state: t, dispatch: r }) => {
738
+ if (t.readOnly) return !1;
739
+ let i = t.changeByRange((r) => {
740
+ let { from: i, to: a } = r, o = t.doc.lineAt(i), s = !e && i == a && An(t, i);
741
+ e && (i = a = (a <= o.to ? o : t.doc.lineAt(a)).to);
742
+ let c = new u(t, {
743
+ simulateBreak: i,
744
+ simulateDoubleBreak: !!s
745
+ }), l = f(c, i);
746
+ for (l ??= te(/^\s*/.exec(t.doc.lineAt(i).text)[0], t.tabSize); a < o.to && /\s/.test(o.text[a - o.from]);) a++;
747
+ s ? {from: i, to: a} = s : i > o.from && i < o.from + 100 && !/\S/.test(o.text.slice(0, i)) && (i = o.from);
748
+ let d = ["", n(t, l)];
749
+ return s && d.push(n(t, c.lineIndent(o.from, -1))), {
750
+ changes: {
751
+ from: i,
752
+ to: a,
753
+ insert: ie.of(d)
754
+ },
755
+ range: h.cursor(i + 1 + d[1].length)
756
+ };
757
+ });
758
+ return r(t.update(i, {
759
+ scrollIntoView: !0,
760
+ userEvent: "input"
761
+ })), !0;
762
+ };
763
+ }
764
+ function Pn(e, t) {
765
+ let n = -1;
766
+ return e.changeByRange((r) => {
767
+ let i = [];
768
+ for (let a = r.from; a <= r.to;) {
769
+ let o = e.doc.lineAt(a);
770
+ o.number > n && (r.empty || r.to > o.from) && (t(o, i, r), n = o.number), a = o.to + 1;
771
+ }
772
+ let a = e.changes(i);
773
+ return {
774
+ changes: i,
775
+ range: h.range(a.mapPos(r.anchor, 1), a.mapPos(r.head, 1))
776
+ };
777
+ });
778
+ }
779
+ var Fn = ({ state: e, dispatch: t }) => {
780
+ if (e.readOnly) return !1;
781
+ let r = Object.create(null), i = new u(e, { overrideIndentation: (e) => r[e] ?? -1 }), a = Pn(e, (t, a, o) => {
782
+ let s = f(i, t.from);
783
+ if (s == null) return;
784
+ /\S/.test(t.text) || (s = 0);
785
+ let c = /^\s*/.exec(t.text)[0], l = n(e, s);
786
+ (c != l || o.from < t.from + c.length) && (r[t.from] = s, a.push({
787
+ from: t.from,
788
+ to: t.from + c.length,
789
+ insert: l
790
+ }));
791
+ });
792
+ return a.changes.empty || t(e.update(a, { userEvent: "indent" })), !0;
793
+ }, In = ({ state: t, dispatch: n }) => !t.readOnly && (n(t.update(Pn(t, (n, r) => {
794
+ r.push({
795
+ from: n.from,
796
+ insert: t.facet(e)
797
+ });
798
+ }), { userEvent: "input.indent" })), !0), Ln = ({ state: e, dispatch: t }) => !e.readOnly && (t(e.update(Pn(e, (t, r) => {
799
+ let a = /^\s*/.exec(t.text)[0];
800
+ if (!a) return;
801
+ let o = te(a, e.tabSize), s = 0, c = n(e, Math.max(0, o - i(e)));
802
+ for (; s < a.length && s < c.length && a.charCodeAt(s) == c.charCodeAt(s);) s++;
803
+ r.push({
804
+ from: t.from + s,
805
+ to: t.from + a.length,
806
+ insert: c.slice(s)
807
+ });
808
+ }), { userEvent: "delete.dedent" })), !0), Rn = (e) => (e.setTabFocusMode(), !0), zn = [
809
+ {
810
+ key: "Ctrl-b",
811
+ run: dt,
812
+ shift: Ft,
813
+ preventDefault: !0
814
+ },
815
+ {
816
+ key: "Ctrl-f",
817
+ run: ft,
818
+ shift: It
819
+ },
820
+ {
821
+ key: "Ctrl-p",
822
+ run: bt,
823
+ shift: Ut
824
+ },
825
+ {
826
+ key: "Ctrl-n",
827
+ run: xt,
828
+ shift: Wt
829
+ },
830
+ {
831
+ key: "Ctrl-a",
832
+ run: At,
833
+ shift: Qt
834
+ },
835
+ {
836
+ key: "Ctrl-e",
837
+ run: jt,
838
+ shift: $t
839
+ },
840
+ {
841
+ key: "Ctrl-d",
842
+ run: mn
843
+ },
844
+ {
845
+ key: "Ctrl-h",
846
+ run: pn
847
+ },
848
+ {
849
+ key: "Ctrl-k",
850
+ run: vn
851
+ },
852
+ {
853
+ key: "Ctrl-Alt-h",
854
+ run: gn
855
+ },
856
+ {
857
+ key: "Ctrl-o",
858
+ run: xn
859
+ },
860
+ {
861
+ key: "Ctrl-t",
862
+ run: Sn
863
+ },
864
+ {
865
+ key: "Ctrl-v",
866
+ run: Tt
867
+ }
868
+ ], Bn = /*@__PURE__*/ [
869
+ {
870
+ key: "ArrowLeft",
871
+ run: dt,
872
+ shift: Ft,
873
+ preventDefault: !0
874
+ },
875
+ {
876
+ key: "Mod-ArrowLeft",
877
+ mac: "Alt-ArrowLeft",
878
+ run: mt,
879
+ shift: Rt,
880
+ preventDefault: !0
881
+ },
882
+ {
883
+ mac: "Cmd-ArrowLeft",
884
+ run: Ot,
885
+ shift: Xt,
886
+ preventDefault: !0
887
+ },
888
+ {
889
+ key: "ArrowRight",
890
+ run: ft,
891
+ shift: It,
892
+ preventDefault: !0
893
+ },
894
+ {
895
+ key: "Mod-ArrowRight",
896
+ mac: "Alt-ArrowRight",
897
+ run: ht,
898
+ shift: zt,
899
+ preventDefault: !0
900
+ },
901
+ {
902
+ mac: "Cmd-ArrowRight",
903
+ run: kt,
904
+ shift: Zt,
905
+ preventDefault: !0
906
+ },
907
+ {
908
+ key: "ArrowUp",
909
+ run: bt,
910
+ shift: Ut,
911
+ preventDefault: !0
912
+ },
913
+ {
914
+ mac: "Cmd-ArrowUp",
915
+ run: en,
916
+ shift: nn
917
+ },
918
+ {
919
+ mac: "Ctrl-ArrowUp",
920
+ run: wt,
921
+ shift: Kt
922
+ },
923
+ {
924
+ key: "ArrowDown",
925
+ run: xt,
926
+ shift: Wt,
927
+ preventDefault: !0
928
+ },
929
+ {
930
+ mac: "Cmd-ArrowDown",
931
+ run: tn,
932
+ shift: rn
933
+ },
934
+ {
935
+ mac: "Ctrl-ArrowDown",
936
+ run: Tt,
937
+ shift: qt
938
+ },
939
+ {
940
+ key: "PageUp",
941
+ run: wt,
942
+ shift: Kt
943
+ },
944
+ {
945
+ key: "PageDown",
946
+ run: Tt,
947
+ shift: qt
948
+ },
949
+ {
950
+ key: "Home",
951
+ run: Dt,
952
+ shift: Yt,
953
+ preventDefault: !0
954
+ },
955
+ {
956
+ key: "Mod-Home",
957
+ run: en,
958
+ shift: nn
959
+ },
960
+ {
961
+ key: "End",
962
+ run: Et,
963
+ shift: Jt,
964
+ preventDefault: !0
965
+ },
966
+ {
967
+ key: "Mod-End",
968
+ run: tn,
969
+ shift: rn
970
+ },
971
+ {
972
+ key: "Enter",
973
+ run: jn,
974
+ shift: jn
975
+ },
976
+ {
977
+ key: "Mod-a",
978
+ run: an
979
+ },
980
+ {
981
+ key: "Backspace",
982
+ run: pn,
983
+ shift: pn,
984
+ preventDefault: !0
985
+ },
986
+ {
987
+ key: "Delete",
988
+ run: mn,
989
+ preventDefault: !0
990
+ },
991
+ {
992
+ key: "Mod-Backspace",
993
+ mac: "Alt-Backspace",
994
+ run: gn,
995
+ preventDefault: !0
996
+ },
997
+ {
998
+ key: "Mod-Delete",
999
+ mac: "Alt-Delete",
1000
+ run: _n,
1001
+ preventDefault: !0
1002
+ },
1003
+ {
1004
+ mac: "Mod-Backspace",
1005
+ run: yn,
1006
+ preventDefault: !0
1007
+ },
1008
+ {
1009
+ mac: "Mod-Delete",
1010
+ run: bn,
1011
+ preventDefault: !0
1012
+ }
1013
+ ].concat(/*@__PURE__*/ zn.map((e) => ({
1014
+ mac: e.key,
1015
+ run: e.run,
1016
+ shift: e.shift
1017
+ }))), Vn = /*@__PURE__*/ [
1018
+ {
1019
+ key: "Alt-ArrowLeft",
1020
+ mac: "Ctrl-ArrowLeft",
1021
+ run: _t,
1022
+ shift: Bt
1023
+ },
1024
+ {
1025
+ key: "Alt-ArrowRight",
1026
+ mac: "Ctrl-ArrowRight",
1027
+ run: vt,
1028
+ shift: Vt
1029
+ },
1030
+ {
1031
+ key: "Alt-ArrowUp",
1032
+ run: wn
1033
+ },
1034
+ {
1035
+ key: "Shift-Alt-ArrowUp",
1036
+ run: Dn
1037
+ },
1038
+ {
1039
+ key: "Alt-ArrowDown",
1040
+ run: Tn
1041
+ },
1042
+ {
1043
+ key: "Shift-Alt-ArrowDown",
1044
+ run: On
1045
+ },
1046
+ {
1047
+ key: "Mod-Alt-ArrowUp",
1048
+ run: ln
1049
+ },
1050
+ {
1051
+ key: "Mod-Alt-ArrowDown",
1052
+ run: un
1053
+ },
1054
+ {
1055
+ key: "Escape",
1056
+ run: dn
1057
+ },
1058
+ {
1059
+ key: "Mod-Enter",
1060
+ run: Mn
1061
+ },
1062
+ {
1063
+ key: "Alt-l",
1064
+ mac: "Ctrl-l",
1065
+ run: on
1066
+ },
1067
+ {
1068
+ key: "Mod-i",
1069
+ run: sn,
1070
+ preventDefault: !0
1071
+ },
1072
+ {
1073
+ key: "Mod-[",
1074
+ run: Ln
1075
+ },
1076
+ {
1077
+ key: "Mod-]",
1078
+ run: In
1079
+ },
1080
+ {
1081
+ key: "Mod-Alt-\\",
1082
+ run: Fn
1083
+ },
1084
+ {
1085
+ key: "Shift-Mod-k",
1086
+ run: kn
1087
+ },
1088
+ {
1089
+ key: "Shift-Mod-\\",
1090
+ run: Nt
1091
+ },
1092
+ {
1093
+ key: "Mod-/",
1094
+ run: Pe
1095
+ },
1096
+ {
1097
+ key: "Alt-A",
1098
+ mac: "Ctrl-A",
1099
+ run: Le
1100
+ },
1101
+ {
1102
+ key: "Ctrl-m",
1103
+ mac: "Shift-Alt-m",
1104
+ run: Rn
1105
+ }
1106
+ ].concat(Bn), Hn = typeof String.prototype.normalize == "function" ? (e) => e.normalize("NFKD") : (e) => e, z = class {
1107
+ constructor(e, t, n = 0, r = e.length, i, a) {
1108
+ this.test = a, this.value = {
1109
+ from: 0,
1110
+ to: 0,
1111
+ precise: !1
1112
+ }, this.done = !1, this.matches = [], this.buffer = "", this.bufferPos = 0, this.iter = e.iterRange(n, r), this.bufferStart = n, this.normalize = i ? (e) => i(Hn(e)) : Hn, this.query = this.normalize(t);
1113
+ }
1114
+ peek() {
1115
+ if (this.bufferPos == this.buffer.length) {
1116
+ if (this.bufferStart += this.buffer.length, this.iter.next(), this.iter.done) return -1;
1117
+ this.bufferPos = 0, this.buffer = this.iter.value;
1118
+ }
1119
+ return ee(this.buffer, this.bufferPos);
1120
+ }
1121
+ next() {
1122
+ for (; this.matches.length;) this.matches.pop();
1123
+ return this.nextOverlapping();
1124
+ }
1125
+ nextOverlapping() {
1126
+ for (;;) {
1127
+ let e = this.peek();
1128
+ if (e < 0) return this.done = !0, this;
1129
+ let t = fe(e), n = this.bufferStart + this.bufferPos;
1130
+ this.bufferPos += de(e);
1131
+ let r = this.normalize(t);
1132
+ if (r.length) for (let e = 0, i = n, a = !0;; e++) {
1133
+ let n = r.charCodeAt(e), o = this.match(n, i, a, this.bufferPos + this.bufferStart, e == r.length - 1);
1134
+ if (o) return this.value = o, this;
1135
+ if (e == r.length - 1) break;
1136
+ a && e < t.length && t.charCodeAt(e) == n ? i++ : a = !1;
1137
+ }
1138
+ }
1139
+ }
1140
+ match(e, t, n, r, i) {
1141
+ let a = null;
1142
+ for (let t = 0; t < this.matches.length;) {
1143
+ let n = this.matches[t], o = !1;
1144
+ this.query.charCodeAt(n.index) == e && (n.index == this.query.length - 1 ? a = {
1145
+ from: n.from,
1146
+ to: r,
1147
+ precise: i && n.precise
1148
+ } : (n.index++, o = !0)), o ? t++ : this.matches.splice(t, 1);
1149
+ }
1150
+ return this.query.charCodeAt(0) == e && (this.query.length == 1 ? a = {
1151
+ from: t,
1152
+ to: r,
1153
+ precise: n && i
1154
+ } : this.matches.push({
1155
+ from: t,
1156
+ index: 1,
1157
+ precise: n
1158
+ })), a && this.test && !this.test(a.from, a.to, this.buffer, this.bufferStart) && (a = null), a;
1159
+ }
1160
+ };
1161
+ typeof Symbol < "u" && (z.prototype[Symbol.iterator] = function() {
1162
+ return this;
1163
+ });
1164
+ var Un = {
1165
+ from: -1,
1166
+ to: -1,
1167
+ match: /*@__PURE__*/ /.*/.exec(""),
1168
+ precise: !0
1169
+ }, Wn = "gm" + (/x/.unicode == null ? "" : "u"), Gn = class {
1170
+ constructor(e, t, n, r = 0, i = e.length) {
1171
+ if (this.text = e, this.to = i, this.curLine = "", this.done = !1, this.value = Un, /\\[sWDnr]|\n|\r|\[\^/.test(t)) return new Jn(e, t, n, r, i);
1172
+ this.re = new RegExp(t, Wn + (n?.ignoreCase ? "i" : "")), this.test = n?.test, this.iter = e.iter();
1173
+ let a = e.lineAt(r);
1174
+ this.curLineStart = a.from, this.matchPos = B(e, r), this.getLine(this.curLineStart);
1175
+ }
1176
+ getLine(e) {
1177
+ 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());
1178
+ }
1179
+ nextLine() {
1180
+ this.curLineStart = this.curLineStart + this.curLine.length + 1, this.curLineStart > this.to ? this.curLine = "" : this.getLine(0);
1181
+ }
1182
+ next() {
1183
+ for (let e = this.matchPos - this.curLineStart;;) {
1184
+ this.re.lastIndex = e;
1185
+ let t = this.matchPos <= this.to && this.re.exec(this.curLine);
1186
+ if (t) {
1187
+ let n = this.curLineStart + t.index, r = n + t[0].length;
1188
+ if (this.matchPos = B(this.text, r + +(n == r)), n == this.curLineStart + this.curLine.length && this.nextLine(), (n < r || n > this.value.to) && (!this.test || this.test(n, r, t))) return this.value = {
1189
+ from: n,
1190
+ to: r,
1191
+ precise: !0,
1192
+ match: t
1193
+ }, this;
1194
+ e = this.matchPos - this.curLineStart;
1195
+ } else if (this.curLineStart + this.curLine.length < this.to) this.nextLine(), e = 0;
1196
+ else return this.done = !0, this;
1197
+ }
1198
+ }
1199
+ }, Kn = /*@__PURE__*/ new WeakMap(), qn = class e {
1200
+ constructor(e, t) {
1201
+ this.from = e, this.text = t;
1202
+ }
1203
+ get to() {
1204
+ return this.from + this.text.length;
1205
+ }
1206
+ static get(t, n, r) {
1207
+ let i = Kn.get(t);
1208
+ if (!i || i.from >= r || i.to <= n) {
1209
+ let i = new e(n, t.sliceString(n, r));
1210
+ return Kn.set(t, i), i;
1211
+ }
1212
+ if (i.from == n && i.to == r) return i;
1213
+ let { text: a, from: o } = i;
1214
+ return o > n && (a = t.sliceString(n, o) + a, o = n), i.to < r && (a += t.sliceString(i.to, r)), Kn.set(t, new e(o, a)), new e(n, a.slice(n - o, r - o));
1215
+ }
1216
+ }, Jn = class {
1217
+ constructor(e, t, n, r, i) {
1218
+ this.text = e, this.to = i, this.done = !1, this.value = Un, this.matchPos = B(e, r), this.re = new RegExp(t, Wn + (n?.ignoreCase ? "i" : "")), this.test = n?.test, this.flat = qn.get(e, r, this.chunkEnd(r + 5e3));
1219
+ }
1220
+ chunkEnd(e) {
1221
+ return e >= this.to ? this.to : this.text.lineAt(e).to;
1222
+ }
1223
+ next() {
1224
+ for (;;) {
1225
+ let e = this.re.lastIndex = this.matchPos - this.flat.from, t = this.re.exec(this.flat.text);
1226
+ if (t && !t[0] && t.index == e && (this.re.lastIndex = e + 1, t = this.re.exec(this.flat.text)), t) {
1227
+ let e = this.flat.from + t.index, n = e + t[0].length;
1228
+ if ((this.flat.to >= this.to || t.index + t[0].length <= this.flat.text.length - 10) && (!this.test || this.test(e, n, t))) return this.value = {
1229
+ from: e,
1230
+ to: n,
1231
+ precise: !0,
1232
+ match: t
1233
+ }, this.matchPos = B(this.text, n + +(e == n)), this;
1234
+ }
1235
+ if (this.flat.to == this.to) return this.done = !0, this;
1236
+ this.flat = qn.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
1237
+ }
1238
+ }
1239
+ };
1240
+ typeof Symbol < "u" && (Gn.prototype[Symbol.iterator] = Jn.prototype[Symbol.iterator] = function() {
1241
+ return this;
1242
+ });
1243
+ function Yn(e) {
1244
+ try {
1245
+ return new RegExp(e, Wn), !0;
1246
+ } catch {
1247
+ return !1;
1248
+ }
1249
+ }
1250
+ function B(e, t) {
1251
+ if (t >= e.length) return t;
1252
+ let n = e.lineAt(t), r;
1253
+ for (; t < n.to && (r = n.text.charCodeAt(t - n.from)) >= 56320 && r < 57344;) t++;
1254
+ return t;
1255
+ }
1256
+ var Xn = (e) => {
1257
+ let { state: t } = e, n = String(t.doc.lineAt(e.state.selection.main.head).number), { close: r, result: i } = ge(e, {
1258
+ label: t.phrase("Go to line"),
1259
+ input: {
1260
+ type: "text",
1261
+ name: "line",
1262
+ value: n
1263
+ },
1264
+ focus: !0,
1265
+ submitLabel: t.phrase("go")
1266
+ });
1267
+ return i.then((n) => {
1268
+ let i = n && /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);
1269
+ if (!i) {
1270
+ e.dispatch({ effects: r });
1271
+ return;
1272
+ }
1273
+ let a = t.doc.lineAt(t.selection.main.head), [, o, s, c, l] = i, u = c ? +c.slice(1) : 0, d = s ? +s : a.number;
1274
+ if (s && l) {
1275
+ let e = d / 100;
1276
+ o && (e = e * (o == "-" ? -1 : 1) + a.number / t.doc.lines), d = Math.round(t.doc.lines * e);
1277
+ } else s && o && (d = d * (o == "-" ? -1 : 1) + a.number);
1278
+ let f = t.doc.line(Math.max(1, Math.min(t.doc.lines, d))), p = h.cursor(f.from + Math.max(0, Math.min(u, f.length)));
1279
+ e.dispatch({
1280
+ effects: [r, b.scrollIntoView(p.from, { y: "center" })],
1281
+ selection: p
1282
+ });
1283
+ }), !0;
1284
+ }, Zn = {
1285
+ highlightWordAroundCursor: !1,
1286
+ minSelectionLength: 1,
1287
+ maxMatches: 100,
1288
+ wholeWords: !1
1289
+ }, Qn = /*@__PURE__*/ v.define({ combine(e) {
1290
+ return pe(e, Zn, {
1291
+ highlightWordAroundCursor: (e, t) => e || t,
1292
+ minSelectionLength: Math.min,
1293
+ maxMatches: Math.min
1294
+ });
1295
+ } });
1296
+ function $n(e) {
1297
+ let t = [ar, ir];
1298
+ return e && t.push(Qn.of(e)), t;
1299
+ }
1300
+ var er = /*@__PURE__*/ x.mark({ class: "cm-selectionMatch" }), tr = /*@__PURE__*/ x.mark({ class: "cm-selectionMatch cm-selectionMatch-main" });
1301
+ function nr(e, t, n, r) {
1302
+ return (n == 0 || e(t.sliceDoc(n - 1, n)) != g.Word) && (r == t.doc.length || e(t.sliceDoc(r, r + 1)) != g.Word);
1303
+ }
1304
+ function rr(e, t, n, r) {
1305
+ return e(t.sliceDoc(n, n + 1)) == g.Word && e(t.sliceDoc(r - 1, r)) == g.Word;
1306
+ }
1307
+ var ir = /*@__PURE__*/ ve.fromClass(class {
1308
+ constructor(e) {
1309
+ this.decorations = this.getDeco(e);
1310
+ }
1311
+ update(e) {
1312
+ (e.selectionSet || e.docChanged || e.viewportChanged) && (this.decorations = this.getDeco(e.view));
1313
+ }
1314
+ getDeco(e) {
1315
+ let t = e.state.facet(Qn), { state: n } = e, r = n.selection;
1316
+ if (r.ranges.length > 1) return x.none;
1317
+ let i = r.main, a, o = null;
1318
+ if (i.empty) {
1319
+ if (!t.highlightWordAroundCursor) return x.none;
1320
+ let e = n.wordAt(i.head);
1321
+ if (!e) return x.none;
1322
+ o = n.charCategorizer(i.head), a = n.sliceDoc(e.from, e.to);
1323
+ } else {
1324
+ let e = i.to - i.from;
1325
+ if (e < t.minSelectionLength || e > 200) return x.none;
1326
+ if (t.wholeWords) {
1327
+ if (a = n.sliceDoc(i.from, i.to), o = n.charCategorizer(i.head), !(nr(o, n, i.from, i.to) && rr(o, n, i.from, i.to))) return x.none;
1328
+ } else if (a = n.sliceDoc(i.from, i.to), !a) return x.none;
1329
+ }
1330
+ let s = [];
1331
+ for (let r of e.visibleRanges) {
1332
+ let e = new z(n.doc, a, r.from, r.to);
1333
+ for (; !e.next().done;) {
1334
+ let { from: r, to: a } = e.value;
1335
+ if ((!o || nr(o, n, r, a)) && (i.empty && r <= i.from && a >= i.to ? s.push(tr.range(r, a)) : (r >= i.to || a <= i.from) && s.push(er.range(r, a)), s.length > t.maxMatches)) return x.none;
1336
+ }
1337
+ }
1338
+ return x.set(s);
1339
+ }
1340
+ }, { decorations: (e) => e.decorations }), ar = /*@__PURE__*/ b.baseTheme({
1341
+ ".cm-selectionMatch": { backgroundColor: "#99ff7780" },
1342
+ ".cm-searchMatch .cm-selectionMatch": { backgroundColor: "transparent" }
1343
+ }), or = ({ state: e, dispatch: t }) => {
1344
+ let { selection: n } = e, r = h.create(n.ranges.map((t) => e.wordAt(t.head) || h.cursor(t.head)), n.mainIndex);
1345
+ return !r.eq(n) && (t(e.update({ selection: r })), !0);
1346
+ };
1347
+ function sr(e, t) {
1348
+ let { main: n, ranges: r } = e.selection, i = e.wordAt(n.head), a = i && i.from == n.from && i.to == n.to;
1349
+ for (let n = !1, i = new z(e.doc, t, r[r.length - 1].to);;) if (i.next(), i.done) {
1350
+ if (n) return null;
1351
+ i = new z(e.doc, t, 0, Math.max(0, r[r.length - 1].from - 1)), n = !0;
1352
+ } else {
1353
+ if (n && r.some((e) => e.from == i.value.from)) continue;
1354
+ if (a) {
1355
+ let t = e.wordAt(i.value.from);
1356
+ if (!t || t.from != i.value.from || t.to != i.value.to) continue;
1357
+ }
1358
+ return i.value;
1359
+ }
1360
+ }
1361
+ var cr = ({ state: e, dispatch: t }) => {
1362
+ let { ranges: n } = e.selection;
1363
+ if (n.some((e) => e.from === e.to)) return or({
1364
+ state: e,
1365
+ dispatch: t
1366
+ });
1367
+ let r = e.sliceDoc(n[0].from, n[0].to);
1368
+ if (e.selection.ranges.some((t) => e.sliceDoc(t.from, t.to) != r)) return !1;
1369
+ let i = sr(e, r);
1370
+ return i ? (t(e.update({
1371
+ selection: e.selection.addRange(h.range(i.from, i.to), !1),
1372
+ effects: b.scrollIntoView(i.to)
1373
+ })), !0) : !1;
1374
+ }, V = /*@__PURE__*/ v.define({ combine(e) {
1375
+ return pe(e, {
1376
+ top: !1,
1377
+ caseSensitive: !1,
1378
+ literal: !1,
1379
+ regexp: !1,
1380
+ wholeWord: !1,
1381
+ createPanel: (e) => new Nr(e),
1382
+ scrollToMatch: (e) => b.scrollIntoView(e)
1383
+ });
1384
+ } }), lr = class {
1385
+ constructor(e) {
1386
+ 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 || Yn(this.search)), this.unquoted = this.unquote(this.search), this.wholeWord = !!e.wholeWord, this.test = e.test;
1387
+ }
1388
+ unquote(e) {
1389
+ return this.literal ? e : e.replace(/\\([nrt\\])/g, (e, t) => t == "n" ? "\n" : t == "r" ? "\r" : t == "t" ? " " : "\\");
1390
+ }
1391
+ eq(e) {
1392
+ 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;
1393
+ }
1394
+ create() {
1395
+ return this.regexp ? new gr(this) : new pr(this);
1396
+ }
1397
+ getCursor(e, t = 0, n) {
1398
+ let r = e.doc ? e : ce.create({ doc: e });
1399
+ return n ??= r.doc.length, this.regexp ? U(this, r, t, n) : H(this, r, t, n);
1400
+ }
1401
+ }, ur = class {
1402
+ constructor(e) {
1403
+ this.spec = e;
1404
+ }
1405
+ };
1406
+ function dr(e, t, n) {
1407
+ return (r, i, a, o) => n && !n(r, i, a, o) ? !1 : e(r >= o && i <= o + a.length ? a.slice(r - o, i - o) : t.doc.sliceString(r, i), t, r, i);
1408
+ }
1409
+ function H(e, t, n, r) {
1410
+ let i;
1411
+ return e.wholeWord && (i = fr(t.doc, t.charCategorizer(t.selection.main.head))), e.test && (i = dr(e.test, t, i)), new z(t.doc, e.unquoted, n, r, e.caseSensitive ? void 0 : (e) => e.toLowerCase(), i);
1412
+ }
1413
+ function fr(e, t) {
1414
+ return (n, r, i, a) => ((a > n || a + i.length < r) && (a = Math.max(0, n - 2), i = e.sliceString(a, Math.min(e.length, r + 2))), (t(W(i, n - a)) != g.Word || t(G(i, n - a)) != g.Word) && (t(G(i, r - a)) != g.Word || t(W(i, r - a)) != g.Word));
1415
+ }
1416
+ var pr = class extends ur {
1417
+ constructor(e) {
1418
+ super(e);
1419
+ }
1420
+ nextMatch(e, t, n) {
1421
+ let r = H(this.spec, e, n, e.doc.length).nextOverlapping();
1422
+ if (r.done) {
1423
+ let n = Math.min(e.doc.length, t + this.spec.unquoted.length);
1424
+ r = H(this.spec, e, 0, n).nextOverlapping();
1425
+ }
1426
+ return r.done || r.value.from == t && r.value.to == n ? null : r.value;
1427
+ }
1428
+ prevMatchInRange(e, t, n) {
1429
+ for (let r = n;;) {
1430
+ let n = Math.max(t, r - 1e4 - this.spec.unquoted.length), i = H(this.spec, e, n, r), a = null;
1431
+ for (; !i.nextOverlapping().done;) a = i.value;
1432
+ if (a) return a;
1433
+ if (n == t) return null;
1434
+ r -= 1e4;
1435
+ }
1436
+ }
1437
+ prevMatch(e, t, n) {
1438
+ let r = this.prevMatchInRange(e, 0, t);
1439
+ return r ||= this.prevMatchInRange(e, Math.max(0, n - this.spec.unquoted.length), e.doc.length), r && (r.from != t || r.to != n) ? r : null;
1440
+ }
1441
+ getReplacement(e) {
1442
+ return this.spec.unquote(this.spec.replace);
1443
+ }
1444
+ matchAll(e, t) {
1445
+ let n = H(this.spec, e, 0, e.doc.length), r = [];
1446
+ for (; !n.next().done;) {
1447
+ if (r.length >= t) return null;
1448
+ r.push(n.value);
1449
+ }
1450
+ return r;
1451
+ }
1452
+ highlight(e, t, n, r) {
1453
+ let i = H(this.spec, e, Math.max(0, t - this.spec.unquoted.length), Math.min(n + this.spec.unquoted.length, e.doc.length));
1454
+ for (; !i.next().done;) r(i.value.from, i.value.to);
1455
+ }
1456
+ };
1457
+ function mr(e, t, n) {
1458
+ return (r, i, a) => (!n || n(r, i, a)) && e(a[0], t, r, i);
1459
+ }
1460
+ function U(e, t, n, r) {
1461
+ let i;
1462
+ return e.wholeWord && (i = hr(t.charCategorizer(t.selection.main.head))), e.test && (i = mr(e.test, t, i)), new Gn(t.doc, e.search, {
1463
+ ignoreCase: !e.caseSensitive,
1464
+ test: i
1465
+ }, n, r);
1466
+ }
1467
+ function W(e, t) {
1468
+ return e.slice(m(e, t, !1), t);
1469
+ }
1470
+ function G(e, t) {
1471
+ return e.slice(t, m(e, t));
1472
+ }
1473
+ function hr(e) {
1474
+ return (t, n, r) => !r[0].length || (e(W(r.input, r.index)) != g.Word || e(G(r.input, r.index)) != g.Word) && (e(G(r.input, r.index + r[0].length)) != g.Word || e(W(r.input, r.index + r[0].length)) != g.Word);
1475
+ }
1476
+ var gr = class extends ur {
1477
+ nextMatch(e, t, n) {
1478
+ let r = U(this.spec, e, n, e.doc.length).next();
1479
+ return r.done && (r = U(this.spec, e, 0, t).next()), r.done ? null : r.value;
1480
+ }
1481
+ prevMatchInRange(e, t, n) {
1482
+ for (let r = 1;; r++) {
1483
+ let i = Math.max(t, n - r * 1e4), a = U(this.spec, e, i, n), o = null;
1484
+ for (; !a.next().done;) o = a.value;
1485
+ if (o && (i == t || o.from > i + 10)) return o;
1486
+ if (i == t) return null;
1487
+ }
1488
+ }
1489
+ prevMatch(e, t, n) {
1490
+ return this.prevMatchInRange(e, 0, t) || this.prevMatchInRange(e, n, e.doc.length);
1491
+ }
1492
+ getReplacement(e) {
1493
+ return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g, (t, n) => {
1494
+ if (n == "&") return e.match[0];
1495
+ if (n == "$") return "$";
1496
+ for (let t = n.length; t > 0; t--) {
1497
+ let r = +n.slice(0, t);
1498
+ if (r > 0 && r < e.match.length) return e.match[r] + n.slice(t);
1499
+ }
1500
+ return t;
1501
+ });
1502
+ }
1503
+ matchAll(e, t) {
1504
+ let n = U(this.spec, e, 0, e.doc.length), r = [];
1505
+ for (; !n.next().done;) {
1506
+ if (r.length >= t) return null;
1507
+ r.push(n.value);
1508
+ }
1509
+ return r;
1510
+ }
1511
+ highlight(e, t, n, r) {
1512
+ let i = U(this.spec, e, Math.max(0, t - 250), Math.min(n + 250, e.doc.length));
1513
+ for (; !i.next().done;) r(i.value.from, i.value.to);
1514
+ }
1515
+ }, K = /*@__PURE__*/ _.define(), _r = /*@__PURE__*/ _.define(), q = /*@__PURE__*/ oe.define({
1516
+ create(e) {
1517
+ return new vr(Dr(e).create(), null);
1518
+ },
1519
+ update(e, t) {
1520
+ for (let n of t.effects) n.is(K) ? e = new vr(n.value.create(), e.panel) : n.is(_r) && (e = new vr(e.query, n.value ? Er : null));
1521
+ return e;
1522
+ },
1523
+ provide: (e) => he.from(e, (e) => e.panel)
1524
+ }), vr = class {
1525
+ constructor(e, t) {
1526
+ this.query = e, this.panel = t;
1527
+ }
1528
+ }, yr = /*@__PURE__*/ x.mark({ class: "cm-searchMatch" }), br = /*@__PURE__*/ x.mark({ class: "cm-searchMatch cm-searchMatch-selected" }), xr = /*@__PURE__*/ ve.fromClass(class {
1529
+ constructor(e) {
1530
+ this.view = e, this.decorations = this.highlight(e.state.field(q));
1531
+ }
1532
+ update(e) {
1533
+ let t = e.state.field(q);
1534
+ (t != e.startState.field(q) || e.docChanged || e.selectionSet || e.viewportChanged) && (this.decorations = this.highlight(t));
1535
+ }
1536
+ highlight({ query: e, panel: t }) {
1537
+ if (!t || !e.spec.valid) return x.none;
1538
+ let { view: n } = this, r = new ne();
1539
+ for (let t = 0, i = n.visibleRanges, a = i.length; t < a; t++) {
1540
+ let { from: o, to: s } = i[t];
1541
+ for (; t < a - 1 && s > i[t + 1].from - 500;) s = i[++t].to;
1542
+ e.highlight(n.state, o, s, (e, t) => {
1543
+ let i = n.state.selection.ranges.some((n) => n.from == e && n.to == t);
1544
+ r.add(e, t, i ? br : yr);
1545
+ });
1546
+ }
1547
+ return r.finish();
1548
+ }
1549
+ }, { decorations: (e) => e.decorations });
1550
+ function J(e) {
1551
+ return (t) => {
1552
+ let n = t.state.field(q, !1);
1553
+ return n && n.query.spec.valid ? e(t, n) : Ar(t);
1554
+ };
1555
+ }
1556
+ var Y = /*@__PURE__*/ J((e, { query: t }) => {
1557
+ let { to: n } = e.state.selection.main, r = t.nextMatch(e.state, n, n);
1558
+ if (!r) return !1;
1559
+ let i = h.single(r.from, r.to), a = e.state.facet(V);
1560
+ return e.dispatch({
1561
+ selection: i,
1562
+ effects: [Pr(e, r), a.scrollToMatch(i.main, e)],
1563
+ userEvent: "select.search"
1564
+ }), kr(e), !0;
1565
+ }), X = /*@__PURE__*/ J((e, { query: t }) => {
1566
+ let { state: n } = e, { from: r } = n.selection.main, i = t.prevMatch(n, r, r);
1567
+ if (!i) return !1;
1568
+ let a = h.single(i.from, i.to), o = e.state.facet(V);
1569
+ return e.dispatch({
1570
+ selection: a,
1571
+ effects: [Pr(e, i), o.scrollToMatch(a.main, e)],
1572
+ userEvent: "select.search"
1573
+ }), kr(e), !0;
1574
+ }), Sr = /*@__PURE__*/ J((e, { query: t }) => {
1575
+ let n = t.matchAll(e.state, 1e3);
1576
+ return !n || !n.length ? !1 : (e.dispatch({
1577
+ selection: h.create(n.map((e) => h.range(e.from, e.to))),
1578
+ userEvent: "select.search.matches"
1579
+ }), !0);
1580
+ }), Cr = ({ state: e, dispatch: t }) => {
1581
+ let n = e.selection;
1582
+ if (n.ranges.length > 1 || n.main.empty) return !1;
1583
+ let { from: r, to: i } = n.main, a = [], o = 0;
1584
+ for (let t = new z(e.doc, e.sliceDoc(r, i)); !t.next().done;) {
1585
+ if (a.length > 1e3) return !1;
1586
+ t.value.from == r && (o = a.length), a.push(h.range(t.value.from, t.value.to));
1587
+ }
1588
+ return t(e.update({
1589
+ selection: h.create(a, o),
1590
+ userEvent: "select.search.matches"
1591
+ })), !0;
1592
+ }, wr = /*@__PURE__*/ J((e, { query: t }) => {
1593
+ let { state: n } = e, { from: r, to: i } = n.selection.main;
1594
+ if (n.readOnly) return !1;
1595
+ let a = t.nextMatch(n, r, r);
1596
+ if (!a) return !1;
1597
+ let o = a, s = [], c, l, u = [];
1598
+ o.precise ? o.from == r && o.to == i && (l = n.toText(t.getReplacement(o)), s.push({
1599
+ from: o.from,
1600
+ to: o.to,
1601
+ insert: l
1602
+ }), o = t.nextMatch(n, o.from, o.to), u.push(b.announce.of(n.phrase("replaced match on line $", n.doc.lineAt(r).number) + "."))) : o = t.nextMatch(n, o.from, o.to);
1603
+ let d = e.state.changes(s);
1604
+ return o && (c = h.single(o.from, o.to).map(d), u.push(Pr(e, o)), u.push(n.facet(V).scrollToMatch(c.main, e))), e.dispatch({
1605
+ changes: d,
1606
+ selection: c,
1607
+ effects: u,
1608
+ userEvent: "input.replace"
1609
+ }), !0;
1610
+ }), Tr = /*@__PURE__*/ J((e, { query: t }) => {
1611
+ if (e.state.readOnly) return !1;
1612
+ let n = [];
1613
+ for (let r of t.matchAll(e.state, 1e9)) {
1614
+ let { from: e, to: i, precise: a } = r;
1615
+ a && n.push({
1616
+ from: e,
1617
+ to: i,
1618
+ insert: t.getReplacement(r)
1619
+ });
1620
+ }
1621
+ if (!n.length) return !1;
1622
+ let r = e.state.phrase("replaced $ matches", n.length) + ".";
1623
+ return e.dispatch({
1624
+ changes: n,
1625
+ effects: b.announce.of(r),
1626
+ userEvent: "input.replace.all"
1627
+ }), !0;
1628
+ });
1629
+ function Er(e) {
1630
+ return e.state.facet(V).createPanel(e);
1631
+ }
1632
+ function Dr(e, t) {
1633
+ let n = e.selection.main, r = n.empty || n.to > n.from + 100 ? "" : e.sliceDoc(n.from, n.to);
1634
+ if (t && !r) return t;
1635
+ let i = e.facet(V);
1636
+ return new lr({
1637
+ search: t?.literal ?? i.literal ? r : r.replace(/\n/g, "\\n"),
1638
+ caseSensitive: t?.caseSensitive ?? i.caseSensitive,
1639
+ literal: t?.literal ?? i.literal,
1640
+ regexp: t?.regexp ?? i.regexp,
1641
+ wholeWord: t?.wholeWord ?? i.wholeWord
1642
+ });
1643
+ }
1644
+ function Or(e) {
1645
+ let t = we(e, Er);
1646
+ return t && t.dom.querySelector("[main-field]");
1647
+ }
1648
+ function kr(e) {
1649
+ let t = Or(e);
1650
+ t && t == e.root.activeElement && t.select();
1651
+ }
1652
+ var Ar = (e) => {
1653
+ let t = e.state.field(q, !1);
1654
+ if (t && t.panel) {
1655
+ let n = Or(e);
1656
+ if (n && n != e.root.activeElement) {
1657
+ let r = Dr(e.state, t.query.spec);
1658
+ r.valid && e.dispatch({ effects: K.of(r) }), n.focus(), n.select();
1659
+ }
1660
+ } else e.dispatch({ effects: [_r.of(!0), t ? K.of(Dr(e.state, t.query.spec)) : _.appendConfig.of(Ir)] });
1661
+ return !0;
1662
+ }, jr = (e) => {
1663
+ let t = e.state.field(q, !1);
1664
+ if (!t || !t.panel) return !1;
1665
+ let n = we(e, Er);
1666
+ return n && n.dom.contains(e.root.activeElement) && e.focus(), e.dispatch({ effects: _r.of(!1) }), !0;
1667
+ }, Mr = [
1668
+ {
1669
+ key: "Mod-f",
1670
+ run: Ar,
1671
+ scope: "editor search-panel"
1672
+ },
1673
+ {
1674
+ key: "F3",
1675
+ run: Y,
1676
+ shift: X,
1677
+ scope: "editor search-panel",
1678
+ preventDefault: !0
1679
+ },
1680
+ {
1681
+ key: "Mod-g",
1682
+ run: Y,
1683
+ shift: X,
1684
+ scope: "editor search-panel",
1685
+ preventDefault: !0
1686
+ },
1687
+ {
1688
+ key: "Escape",
1689
+ run: jr,
1690
+ scope: "editor search-panel"
1691
+ },
1692
+ {
1693
+ key: "Mod-Shift-l",
1694
+ run: Cr
1695
+ },
1696
+ {
1697
+ key: "Mod-Alt-g",
1698
+ run: Xn
1699
+ },
1700
+ {
1701
+ key: "Mod-d",
1702
+ run: cr,
1703
+ preventDefault: !0
1704
+ }
1705
+ ], Nr = class {
1706
+ constructor(e) {
1707
+ this.view = e;
1708
+ let t = this.query = e.state.field(q).query.spec;
1709
+ this.commit = this.commit.bind(this), this.searchField = y("input", {
1710
+ value: t.search,
1711
+ placeholder: Z(e, "Find"),
1712
+ "aria-label": Z(e, "Find"),
1713
+ class: "cm-textfield",
1714
+ name: "search",
1715
+ form: "",
1716
+ "main-field": "true",
1717
+ onchange: this.commit,
1718
+ onkeyup: this.commit
1719
+ }), this.replaceField = y("input", {
1720
+ value: t.replace,
1721
+ placeholder: Z(e, "Replace"),
1722
+ "aria-label": Z(e, "Replace"),
1723
+ class: "cm-textfield",
1724
+ name: "replace",
1725
+ form: "",
1726
+ onchange: this.commit,
1727
+ onkeyup: this.commit
1728
+ }), this.caseField = y("input", {
1729
+ type: "checkbox",
1730
+ name: "case",
1731
+ form: "",
1732
+ checked: t.caseSensitive,
1733
+ onchange: this.commit
1734
+ }), this.reField = y("input", {
1735
+ type: "checkbox",
1736
+ name: "re",
1737
+ form: "",
1738
+ checked: t.regexp,
1739
+ onchange: this.commit
1740
+ }), this.wordField = y("input", {
1741
+ type: "checkbox",
1742
+ name: "word",
1743
+ form: "",
1744
+ checked: t.wholeWord,
1745
+ onchange: this.commit
1746
+ });
1747
+ function n(e, t, n) {
1748
+ return y("button", {
1749
+ class: "cm-button",
1750
+ name: e,
1751
+ onclick: t,
1752
+ type: "button"
1753
+ }, n);
1754
+ }
1755
+ this.dom = y("div", {
1756
+ onkeydown: (e) => this.keydown(e),
1757
+ class: "cm-search"
1758
+ }, [
1759
+ this.searchField,
1760
+ n("next", () => Y(e), [Z(e, "next")]),
1761
+ n("prev", () => X(e), [Z(e, "previous")]),
1762
+ n("select", () => Sr(e), [Z(e, "all")]),
1763
+ y("label", null, [this.caseField, Z(e, "match case")]),
1764
+ y("label", null, [this.reField, Z(e, "regexp")]),
1765
+ y("label", null, [this.wordField, Z(e, "by word")]),
1766
+ ...e.state.readOnly ? [] : [
1767
+ y("br"),
1768
+ this.replaceField,
1769
+ n("replace", () => wr(e), [Z(e, "replace")]),
1770
+ n("replaceAll", () => Tr(e), [Z(e, "replace all")])
1771
+ ],
1772
+ y("button", {
1773
+ name: "close",
1774
+ onclick: () => jr(e),
1775
+ "aria-label": Z(e, "close"),
1776
+ type: "button"
1777
+ }, ["×"])
1778
+ ]);
1779
+ }
1780
+ commit() {
1781
+ let e = new lr({
1782
+ search: this.searchField.value,
1783
+ caseSensitive: this.caseField.checked,
1784
+ regexp: this.reField.checked,
1785
+ wholeWord: this.wordField.checked,
1786
+ replace: this.replaceField.value
1787
+ });
1788
+ e.eq(this.query) || (this.query = e, this.view.dispatch({ effects: K.of(e) }));
1789
+ }
1790
+ keydown(e) {
1791
+ De(this.view, e, "search-panel") ? e.preventDefault() : e.keyCode == 13 && e.target == this.searchField ? (e.preventDefault(), (e.shiftKey ? X : Y)(this.view)) : e.keyCode == 13 && e.target == this.replaceField && (e.preventDefault(), wr(this.view));
1792
+ }
1793
+ update(e) {
1794
+ for (let t of e.transactions) for (let e of t.effects) e.is(K) && !e.value.eq(this.query) && this.setQuery(e.value);
1795
+ }
1796
+ setQuery(e) {
1797
+ 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;
1798
+ }
1799
+ mount() {
1800
+ this.searchField.select();
1801
+ }
1802
+ get pos() {
1803
+ return 80;
1804
+ }
1805
+ get top() {
1806
+ return this.view.state.facet(V).top;
1807
+ }
1808
+ };
1809
+ function Z(e, t) {
1810
+ return e.state.phrase(t);
1811
+ }
1812
+ var Q = 30, $ = /[\s\.,:;?!]/;
1813
+ function Pr(e, { from: t, to: n }) {
1814
+ let r = e.state.doc.lineAt(t), i = e.state.doc.lineAt(n).to, a = Math.max(r.from, t - Q), o = Math.min(i, n + Q), s = e.state.sliceDoc(a, o);
1815
+ if (a != r.from) {
1816
+ for (let e = 0; e < Q; e++) if (!$.test(s[e + 1]) && $.test(s[e])) {
1817
+ s = s.slice(e);
1818
+ break;
1819
+ }
1820
+ }
1821
+ if (o != i) {
1822
+ for (let e = s.length - 1; e > s.length - Q; e--) if (!$.test(s[e - 1]) && $.test(s[e])) {
1823
+ s = s.slice(0, e);
1824
+ break;
1825
+ }
1826
+ }
1827
+ return b.announce.of(`${e.state.phrase("current match")}. ${s} ${e.state.phrase("on line")} ${r.number}.`);
1828
+ }
1829
+ var Fr = /*@__PURE__*/ b.baseTheme({
1830
+ ".cm-panel.cm-search": {
1831
+ padding: "2px 6px 4px",
1832
+ position: "relative",
1833
+ "& [name=close]": {
1834
+ position: "absolute",
1835
+ top: "0",
1836
+ right: "4px",
1837
+ backgroundColor: "inherit",
1838
+ border: "none",
1839
+ font: "inherit",
1840
+ padding: 0,
1841
+ margin: 0
1842
+ },
1843
+ "& input, & button, & label": { margin: ".2em .6em .2em 0" },
1844
+ "& input[type=checkbox]": { marginRight: ".2em" },
1845
+ "& label": {
1846
+ fontSize: "80%",
1847
+ whiteSpace: "pre"
1848
+ }
1849
+ },
1850
+ "&light .cm-searchMatch": { backgroundColor: "#ffff0054" },
1851
+ "&dark .cm-searchMatch": { backgroundColor: "#00ffff8a" },
1852
+ "&light .cm-searchMatch-selected": { backgroundColor: "#ff6a0054" },
1853
+ "&dark .cm-searchMatch-selected": { backgroundColor: "#ff00ff8a" }
1854
+ }), Ir = [
1855
+ q,
1856
+ /*@__PURE__*/ ae.low(xr),
1857
+ Fr
1858
+ ], Lr = [
1859
+ Oe(),
1860
+ _e(),
1861
+ Ee(),
1862
+ Ye(),
1863
+ s(),
1864
+ Te(),
1865
+ xe(),
1866
+ ce.allowMultipleSelections.of(!0),
1867
+ d(),
1868
+ c(o, { fallback: !0 }),
1869
+ a(),
1870
+ Me(),
1871
+ Ae(),
1872
+ me(),
1873
+ be(),
1874
+ Se(),
1875
+ $n(),
1876
+ ye.of([
1877
+ ...ke,
1878
+ ...Vn,
1879
+ ...Mr,
1880
+ ...lt,
1881
+ ...r,
1882
+ ...je,
1883
+ ...Ne
1884
+ ])
1885
+ ], Rr = [
1886
+ Ee(),
1887
+ Ye(),
1888
+ Te(),
1889
+ c(o, { fallback: !0 }),
1890
+ ye.of([...Vn, ...lt])
1891
+ ];
1892
+ //#endregion
1893
+ export { b as EditorView, Lr as basicSetup, Rr as minimalSetup };