@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
@@ -1,2328 +0,0 @@
1
- import { l as e } from "./dist-CVtP-E2c.js";
2
- import { S as t, _ as n, a as r, b as i, d as a, g as o, h as s, i as c, l, m as u, n as d, o as f, p, r as m, s as h, t as ee, v as te, w as ne, y as g } from "./dist-Mecbzdl2.js";
3
- import { C as re, D as _, S as ie, T as ae, _ as oe, a as se, b as ce, c as le, d as ue, f as de, g as fe, h as pe, n as me, o as he, r as v, s as ge, t as y, u as _e, v as ve, w as ye, y as be } from "./dist-n9WmBm5w.js";
4
- import { A as xe, E as Se, O as b, S as Ce, T as x, c as we, d as Te, g as Ee, j as De, n as Oe, v as ke, w as Ae, x as je } from "./dist-CUkceEvN.js";
5
- import { i as Me, n as Ne, o as Pe, r as Fe } from "./dist-DXgEYMFx.js";
6
- //#region ../../node_modules/.bun/@codemirror+commands@6.11.0/node_modules/@codemirror/commands/dist/index.js
7
- var Ie = (e) => {
8
- let { state: t } = e, n = t.doc.lineAt(t.selection.main.from), r = Ve(e.state, n.from);
9
- return r.line ? Re(e) : r.block ? Be(e) : !1;
10
- };
11
- function Le(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 Re = /*@__PURE__*/ Le(Ke, 0), ze = /*@__PURE__*/ Le(Ge, 0), Be = /*@__PURE__*/ Le((e, t) => Ge(e, t, We(t)), 0);
19
- function Ve(e, t) {
20
- let n = e.languageDataAt("commentTokens", t, 1);
21
- return n.length ? n[0] : {};
22
- }
23
- var He = 50;
24
- function Ue(e, { open: t, close: n }, r, i) {
25
- let a = e.sliceDoc(r - He, r), o = e.sliceDoc(i, i + He), 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 + He), d = e.sliceDoc(i - He, 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 We(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 Ge(e, t, n = t.selection.ranges) {
64
- let r = n.map((e) => Ve(t, e.from).block);
65
- if (!r.every((e) => e)) return null;
66
- let i = n.map((e, n) => Ue(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 Ke(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 = Ve(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 qe = /*@__PURE__*/ ee.define(), Je = /*@__PURE__*/ ee.define(), Ye = /*@__PURE__*/ h.define(), Xe = /*@__PURE__*/ h.define({ combine(e) {
140
- return g(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
- } }), Ze = /*@__PURE__*/ u.define({
150
- create() {
151
- return T.empty;
152
- },
153
- update(e, t) {
154
- let n = t.state.facet(Xe), r = t.annotation(qe);
155
- if (r) {
156
- let i = C.fromTransaction(t, r.selection), a = r.side, o = a == 0 ? e.undone : e.done;
157
- return o = i ? rt(o, o.length, n.minDepth, i) : ct(o, t.startState.selection), new T(a == 0 ? r.rest : o, a == 0 ? o : r.rest);
158
- }
159
- let i = t.annotation(Je);
160
- if ((i == "full" || i == "before") && (e = e.isolate()), t.annotation(o.addToHistory) === !1) return t.changes.empty ? e : e.addMapping(t.changes.desc);
161
- let a = C.fromTransaction(t), s = t.annotation(o.time), c = t.annotation(o.userEvent);
162
- return a ? e = e.addChanges(a, s, c, n, t) : t.selection && (e = e.addSelection(t.startState.selection, s, c, 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 T(e.done.map(C.fromJSON), e.undone.map(C.fromJSON));
172
- }
173
- });
174
- function Qe(e = {}) {
175
- return [
176
- Ze,
177
- Xe.of(e),
178
- v.domEventHandlers({ beforeinput(e, t) {
179
- let n = e.inputType == "historyUndo" ? $e : e.inputType == "historyRedo" ? et : null;
180
- return n ? (e.preventDefault(), n(t)) : !1;
181
- } })
182
- ];
183
- }
184
- function S(e, t) {
185
- return function({ state: n, dispatch: r }) {
186
- if (!t && n.readOnly) return !1;
187
- let i = n.field(Ze, !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 $e = /*@__PURE__*/ S(0, !1), et = /*@__PURE__*/ S(1, !1), tt = /*@__PURE__*/ S(0, !0), nt = /*@__PURE__*/ S(1, !0), C = 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 && m.fromJSON(t.changes), [], t.mapped && d.fromJSON(t.mapped), t.startSelection && r.fromJSON(t.startSelection), t.selectionsAfter.map(r.fromJSON));
210
- }
211
- static fromTransaction(t, n) {
212
- let r = w;
213
- for (let e of t.startState.facet(Ye)) {
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, w);
218
- }
219
- static selection(t) {
220
- return new e(void 0, w, void 0, void 0, t);
221
- }
222
- };
223
- function rt(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 it(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 at(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 ot(e, t) {
240
- return e.length ? t.length ? e.concat(t) : e : t;
241
- }
242
- var w = [], st = 200;
243
- function ct(e, t) {
244
- if (e.length) {
245
- let n = e[e.length - 1], r = n.selectionsAfter.slice(Math.max(0, n.selectionsAfter.length - st));
246
- return r.length && r[r.length - 1].eq(t) ? e : (r.push(t), rt(e, e.length - 1, 1e9, n.setSelAfter(r)));
247
- }
248
- return [C.selection([t])];
249
- }
250
- function lt(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 ut(e, t) {
255
- if (!e.length) return e;
256
- let n = e.length, r = w;
257
- for (; n;) {
258
- let i = dt(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 ? [C.selection(r)] : w;
266
- }
267
- function dt(e, t, n) {
268
- let r = ot(e.selectionsAfter.length ? e.selectionsAfter.map((e) => e.map(t)) : w, n);
269
- if (!e.changes) return C.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 C(i, p.mapEffects(e.effects, t), o, e.startSelection.map(a), r);
272
- }
273
- var ft = /^(input\.type|delete)($|\.)/, T = 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 || ft.test(r)) && (!s.selectionsAfter.length && n - this.prevTime < i.newGroupDelay && i.joinToEvent(a, it(s.changes, t.changes)) || r == "input.type.compose") ? rt(o, o.length - 1, i.minDepth, new C(t.changes.compose(s.changes), ot(p.mapEffects(t.effects, s.changes), s.effects), s.mapped, s.startSelection, w)) : rt(o, o.length, i.minDepth, t), new e(o, w, n, r);
283
- }
284
- addSelection(t, n, r, i) {
285
- let a = this.done.length ? this.done[this.done.length - 1].selectionsAfter : w;
286
- return a.length > 0 && n - this.prevTime < i && r == this.prevUserEvent && r && /^select($|\.)/.test(r) && at(a[a.length - 1], t) ? this : new e(ct(this.done, t), this.undone, n, r);
287
- }
288
- addMapping(t) {
289
- return new e(ut(this.done, t), ut(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: qe.of({
298
- side: e,
299
- rest: lt(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 ? w : r.slice(0, r.length - 1);
307
- return i.mapped && (n = ut(n, i.mapped)), t.update({
308
- changes: i.changes,
309
- selection: i.startSelection,
310
- effects: i.effects,
311
- annotations: qe.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
- T.empty = /*@__PURE__*/ new T(w, w);
325
- var pt = [
326
- {
327
- key: "Mod-z",
328
- run: $e,
329
- preventDefault: !0
330
- },
331
- {
332
- key: "Mod-y",
333
- mac: "Mod-Shift-z",
334
- run: et,
335
- preventDefault: !0
336
- },
337
- {
338
- linux: "Ctrl-Shift-z",
339
- run: et,
340
- preventDefault: !0
341
- },
342
- {
343
- key: "Mod-u",
344
- run: tt,
345
- preventDefault: !0
346
- },
347
- {
348
- key: "Alt-u",
349
- mac: "Mod-Shift-u",
350
- run: nt,
351
- preventDefault: !0
352
- }
353
- ];
354
- function E(e, t) {
355
- return r.create(e.ranges.map(t), e.mainIndex);
356
- }
357
- function D(e, t) {
358
- return e.update({
359
- selection: t,
360
- scrollIntoView: !0,
361
- userEvent: "select"
362
- });
363
- }
364
- function O({ state: e, dispatch: t }, n) {
365
- let r = E(e.selection, n);
366
- return !r.eq(e.selection, !0) && (t(D(e, r)), !0);
367
- }
368
- function mt(e, t) {
369
- return r.cursor(t ? e.to : e.from);
370
- }
371
- function ht(e, t) {
372
- return O(e, (n) => n.empty ? e.moveByChar(n, t) : mt(n, t));
373
- }
374
- function k(e) {
375
- return e.textDirectionAt(e.state.selection.main.head) == me.LTR;
376
- }
377
- var gt = (e) => ht(e, !k(e)), _t = (e) => ht(e, k(e));
378
- function vt(e, t) {
379
- return O(e, (n) => n.empty ? e.moveByGroup(n, t) : mt(n, t));
380
- }
381
- var yt = (e) => vt(e, !k(e)), bt = (e) => vt(e, k(e));
382
- typeof Intl < "u" && Intl.Segmenter;
383
- function xt(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 A(t, n, i) {
389
- let a = De(t).resolveInner(n.head), o = i ? e.closedBy : e.openedBy;
390
- for (let e = n.head;;) {
391
- let n = i ? a.childAfter(e) : a.childBefore(e);
392
- if (!n) break;
393
- xt(t, n, o) ? a = n : e = i ? n.to : n.from;
394
- }
395
- let s = a.type.prop(o), c, l;
396
- return l = s && (c = i ? b(t, a.from, 1) : b(t, a.to, -1)) && c.matched ? i ? c.end.to : c.end.from : i ? a.to : a.from, r.cursor(l, i ? -1 : 1);
397
- }
398
- var St = (e) => O(e, (t) => A(e.state, t, !k(e))), Ct = (e) => O(e, (t) => A(e.state, t, k(e)));
399
- function wt(e, t) {
400
- return O(e, (n) => {
401
- if (!n.empty) return mt(n, t);
402
- let r = e.moveVertically(n, t);
403
- return r.head == n.head ? e.moveToLineBoundary(n, t) : r;
404
- });
405
- }
406
- var Tt = (e) => wt(e, !1), Et = (e) => wt(e, !0);
407
- function Dt(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(v.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 Ot(e, t) {
424
- let n = Dt(e), { state: r } = e, i = E(r.selection, (r) => r.empty ? e.moveVertically(r, t, n.height) : mt(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 = v.scrollIntoView(i.main.head, {
430
- y: "start",
431
- yMargin: t.top - s
432
- }));
433
- }
434
- return e.dispatch(D(r, i), { effects: a }), !0;
435
- }
436
- var kt = (e) => Ot(e, !1), At = (e) => Ot(e, !0);
437
- function j(e, t, n) {
438
- let i = e.lineBlockAt(t.head), a = e.moveToLineBoundary(t, n);
439
- if (a.head == t.head && a.head != (n ? i.to : i.from) && (a = e.moveToLineBoundary(t, n, !1)), !n && a.head == i.from && i.length) {
440
- let n = /^\s*/.exec(e.state.sliceDoc(i.from, Math.min(i.from + 100, i.to)))[0].length;
441
- n && t.head != i.from + n && (a = r.cursor(i.from + n));
442
- }
443
- return a;
444
- }
445
- var jt = (e) => O(e, (t) => j(e, t, !0)), Mt = (e) => O(e, (t) => j(e, t, !1)), Nt = (e) => O(e, (t) => j(e, t, !k(e))), Pt = (e) => O(e, (t) => j(e, t, k(e))), Ft = (e) => O(e, (t) => r.cursor(e.lineBlockAt(t.head).from, 1)), It = (e) => O(e, (t) => r.cursor(e.lineBlockAt(t.head).to, -1));
446
- function Lt(e, t, n) {
447
- let i = !1, a = E(e.selection, (t) => {
448
- let a = b(e, t.head, -1) || b(e, t.head, 1) || t.head > 0 && b(e, t.head - 1, 1) || t.head < e.doc.length && b(e, t.head + 1, -1);
449
- if (!a || !a.end) return t;
450
- i = !0;
451
- let o = a.start.from == t.head ? a.end.to : a.end.from;
452
- return n ? r.range(t.anchor, o) : r.cursor(o);
453
- });
454
- return i ? (t(D(e, a)), !0) : !1;
455
- }
456
- var Rt = ({ state: e, dispatch: t }) => Lt(e, t, !1);
457
- function M(e, t, n) {
458
- let i = E(e.state.selection, (e) => {
459
- e.undirectional && e.head >= e.anchor != t && (e = r.range(e.head, e.anchor));
460
- let i = n(e);
461
- return r.range(e.anchor, i.head, i.goalColumn, i.bidiLevel || void 0, i.assoc);
462
- });
463
- return !i.eq(e.state.selection) && (e.dispatch(D(e.state, i)), !0);
464
- }
465
- function zt(e, t) {
466
- return M(e, t, (n) => e.moveByChar(n, t));
467
- }
468
- var Bt = (e) => zt(e, !k(e)), Vt = (e) => zt(e, k(e));
469
- function Ht(e, t) {
470
- return M(e, t, (n) => e.moveByGroup(n, t));
471
- }
472
- var Ut = (e) => Ht(e, !k(e)), Wt = (e) => Ht(e, k(e)), Gt = (e) => {
473
- let t = !k(e);
474
- return M(e, t, (n) => A(e.state, n, t));
475
- }, Kt = (e) => {
476
- let t = k(e);
477
- return M(e, t, (n) => A(e.state, n, t));
478
- };
479
- function qt(e, t) {
480
- return M(e, t, (n) => e.moveVertically(n, t));
481
- }
482
- var Jt = (e) => qt(e, !1), Yt = (e) => qt(e, !0);
483
- function Xt(e, t) {
484
- return M(e, t, (n) => e.moveVertically(n, t, Dt(e).height));
485
- }
486
- var Zt = (e) => Xt(e, !1), Qt = (e) => Xt(e, !0), $t = (e) => M(e, !0, (t) => j(e, t, !0)), en = (e) => M(e, !1, (t) => j(e, t, !1)), tn = (e) => {
487
- let t = !k(e);
488
- return M(e, t, (n) => j(e, n, t));
489
- }, nn = (e) => {
490
- let t = k(e);
491
- return M(e, t, (n) => j(e, n, t));
492
- }, rn = (e) => M(e, !1, (t) => r.cursor(e.lineBlockAt(t.head).from)), an = (e) => M(e, !0, (t) => r.cursor(e.lineBlockAt(t.head).to)), on = ({ state: e, dispatch: t }) => (t(D(e, { anchor: 0 })), !0), sn = ({ state: e, dispatch: t }) => (t(D(e, { anchor: e.doc.length })), !0), cn = ({ state: e, dispatch: t }) => (t(D(e, {
493
- anchor: e.selection.main.anchor,
494
- head: 0
495
- })), !0), ln = ({ state: e, dispatch: t }) => (t(D(e, {
496
- anchor: e.selection.main.anchor,
497
- head: e.doc.length
498
- })), !0), un = ({ state: e, dispatch: t }) => (t(e.update({
499
- selection: {
500
- anchor: 0,
501
- head: e.doc.length
502
- },
503
- userEvent: "select"
504
- })), !0), dn = ({ state: e, dispatch: t }) => {
505
- let n = F(e).map(({ from: t, to: n }) => r.undirectionalRange(t, Math.min(n + 1, e.doc.length)));
506
- return t(e.update({
507
- selection: r.create(n),
508
- userEvent: "select"
509
- })), !0;
510
- }, fn = ({ state: e, dispatch: t }) => {
511
- let n = E(e.selection, (t) => {
512
- let n = De(e), i = n.resolveStack(t.from, 1);
513
- if (t.empty) {
514
- let e = n.resolveStack(t.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: n } = e;
519
- if ((n.from < t.from && n.to >= t.to || n.to > t.to && n.from <= t.from) && e.next) return r.undirectionalRange(n.from, n.to);
520
- }
521
- return t;
522
- });
523
- return !n.eq(e.selection) && (t(D(e, n)), !0);
524
- };
525
- function pn(e, t) {
526
- let { state: n } = e, i = n.selection, a = n.selection.ranges.slice();
527
- for (let r of n.selection.ranges) {
528
- let i = n.doc.lineAt(r.head);
529
- if (t ? i.to < e.state.doc.length : i.from > 0) for (let n = r;;) {
530
- let r = e.moveVertically(n, t);
531
- if (r.head < i.from || r.head > i.to) {
532
- a.some((e) => e.head == r.head) || a.push(r);
533
- break;
534
- }
535
- if (r.head == n.head) break;
536
- n = r;
537
- }
538
- }
539
- return a.length != i.ranges.length && (e.dispatch(D(n, r.create(a, a.length - 1))), !0);
540
- }
541
- var mn = (e) => pn(e, !1), hn = (e) => pn(e, !0), gn = ({ state: e, dispatch: t }) => {
542
- let n = e.selection, i = null;
543
- return n.ranges.length > 1 ? i = r.create([n.main]) : n.main.empty || (i = r.create([r.cursor(n.main.head)])), i ? (t(D(e, i)), !0) : !1;
544
- };
545
- function N(e, t) {
546
- if (e.state.readOnly) return !1;
547
- let n = "delete.selection", { state: i } = e, a = i.changeByRange((i) => {
548
- let { from: a, to: o } = i;
549
- if (a == o) {
550
- let r = t(i);
551
- r < a ? (n = "delete.backward", r = P(e, r, !1)) : r > a && (n = "delete.forward", r = P(e, r, !0)), a = Math.min(a, r), o = Math.max(o, r);
552
- } else a = P(e, a, !1), o = P(e, o, !0);
553
- return a == o ? { range: i } : {
554
- changes: {
555
- from: a,
556
- to: o
557
- },
558
- range: r.cursor(a, a < i.head ? -1 : 1)
559
- };
560
- });
561
- return !a.changes.empty && (e.dispatch(i.update(a, {
562
- scrollIntoView: !0,
563
- userEvent: n,
564
- effects: n == "delete.selection" ? v.announce.of(i.phrase("Selection deleted")) : void 0
565
- })), !0);
566
- }
567
- function P(e, t, n) {
568
- if (e instanceof v) for (let r of e.state.facet(v.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 _n = (e, n, r) => N(e, (a) => {
574
- let o = a.from, { state: s } = e, c = s.doc.lineAt(o), l, u;
575
- if (r && !n && o > c.from && o < c.from + 200 && !/[^ \t]/.test(l = c.text.slice(0, o - c.from))) {
576
- if (l[l.length - 1] == " ") return o - 1;
577
- let e = i(l, s.tabSize) % je(s) || je(s);
578
- for (let t = 0; t < e && l[l.length - 1 - t] == " "; t++) o--;
579
- u = o;
580
- } else u = t(c.text, o - c.from, n, n) + c.from, u == o && c.number != (n ? s.doc.lines : 1) ? u += n ? 1 : -1 : !n && /[\ufe00-\ufe0f]/.test(c.text.slice(u - c.from, o - c.from)) && (u = t(c.text, u - c.from, !1, !1) + c.from);
581
- return u;
582
- }), vn = (e) => _n(e, !1, !0), yn = (e) => _n(e, !0, !1), bn = (e, n) => N(e, (r) => {
583
- let i = r.head, { state: a } = e, o = a.doc.lineAt(i), s = a.charCategorizer(i);
584
- for (let e = null;;) {
585
- if (i == (n ? o.to : o.from)) {
586
- i == r.head && o.number != (n ? a.doc.lines : 1) && (i += n ? 1 : -1);
587
- break;
588
- }
589
- let c = t(o.text, i - o.from, n) + o.from, l = o.text.slice(Math.min(i, c) - o.from, Math.max(i, c) - o.from), u = s(l);
590
- if (e != null && u != e) break;
591
- (l != " " || i != r.head) && (e = u), i = c;
592
- }
593
- return i;
594
- }), xn = (e) => bn(e, !1), Sn = (e) => bn(e, !0), Cn = (e) => N(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
- }), wn = (e) => N(e, (t) => {
598
- let n = e.moveToLineBoundary(t, !1).head;
599
- return t.head > n ? n : Math.max(0, t.head - 1);
600
- }), Tn = (e) => N(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
- }), En = ({ 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: s.of(["", ""])
610
- },
611
- range: r.cursor(e.from)
612
- }));
613
- return t(e.update(n, {
614
- scrollIntoView: !0,
615
- userEvent: "input"
616
- })), !0;
617
- }, Dn = ({ state: e, dispatch: n }) => {
618
- if (e.readOnly) return !1;
619
- let i = e.changeByRange((n) => {
620
- if (!n.empty || n.from == 0 || n.from == e.doc.length) return { range: n };
621
- let i = n.from, a = e.doc.lineAt(i), o = i == a.from ? i - 1 : t(a.text, i - a.from, !1) + a.from, s = i == a.to ? i + 1 : t(a.text, i - a.from, !0) + a.from;
622
- return {
623
- changes: {
624
- from: o,
625
- to: s,
626
- insert: e.doc.slice(i, s).append(e.doc.slice(o, i))
627
- },
628
- range: r.cursor(s)
629
- };
630
- });
631
- return !i.changes.empty && (n(e.update(i, {
632
- scrollIntoView: !0,
633
- userEvent: "move.character"
634
- })), !0);
635
- };
636
- function F(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 On(e, t, n) {
653
- if (e.readOnly) return !1;
654
- let i = [], a = [];
655
- for (let t of F(e)) {
656
- if (n ? t.to == e.doc.length : t.from == 0) continue;
657
- let o = e.doc.lineAt(n ? t.to + 1 : t.from - 1), s = o.length + 1;
658
- if (n) {
659
- i.push({
660
- from: t.to,
661
- to: o.to
662
- }, {
663
- from: t.from,
664
- insert: o.text + e.lineBreak
665
- });
666
- for (let n of t.ranges) a.push(r.range(Math.min(e.doc.length, n.anchor + s), Math.min(e.doc.length, n.head + s)));
667
- } else {
668
- i.push({
669
- from: o.from,
670
- to: t.from
671
- }, {
672
- from: t.to,
673
- insert: e.lineBreak + o.text
674
- });
675
- for (let e of t.ranges) a.push(r.range(e.anchor - s, e.head - s));
676
- }
677
- }
678
- return i.length ? (t(e.update({
679
- changes: i,
680
- scrollIntoView: !0,
681
- selection: r.create(a, e.selection.mainIndex),
682
- userEvent: "move.line"
683
- })), !0) : !1;
684
- }
685
- var kn = ({ state: e, dispatch: t }) => On(e, t, !1), An = ({ state: e, dispatch: t }) => On(e, t, !0);
686
- function jn(e, t, n) {
687
- if (e.readOnly) return !1;
688
- let r = [];
689
- for (let t of F(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 Mn = ({ state: e, dispatch: t }) => jn(e, t, !1), Nn = ({ state: e, dispatch: t }) => jn(e, t, !0), Pn = (e) => {
705
- if (e.state.readOnly) return !1;
706
- let { state: t } = e, n = t.changes(F(t).map(({ from: e, to: n }) => (e > 0 ? e-- : n < t.doc.length && n++, {
707
- from: e,
708
- to: n
709
- }))), r = E(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 Fn(t, n) {
725
- if (/\(\)|\[\]|\{\}/.test(t.sliceDoc(n - 1, n + 1))) return {
726
- from: n,
727
- to: n
728
- };
729
- let r = De(t).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(e.closedBy)) && o.indexOf(a.name) > -1 && t.doc.lineAt(i.to).from == t.doc.lineAt(a.from).from && !/\S/.test(t.sliceDoc(i.to, a.from)) ? {
731
- from: i.to,
732
- to: a.from
733
- } : null;
734
- }
735
- var In = /*@__PURE__*/ Rn(!1), Ln = /*@__PURE__*/ Rn(!0);
736
- function Rn(e) {
737
- return ({ state: t, dispatch: n }) => {
738
- if (t.readOnly) return !1;
739
- let a = t.changeByRange((n) => {
740
- let { from: a, to: o } = n, c = t.doc.lineAt(a), l = !e && a == o && Fn(t, a);
741
- e && (a = o = (o <= c.to ? c : t.doc.lineAt(o)).to);
742
- let u = new Oe(t, {
743
- simulateBreak: a,
744
- simulateDoubleBreak: !!l
745
- }), d = Ce(u, a);
746
- for (d ??= i(/^\s*/.exec(t.doc.lineAt(a).text)[0], t.tabSize); o < c.to && /\s/.test(c.text[o - c.from]);) o++;
747
- l ? {from: a, to: o} = l : a > c.from && a < c.from + 100 && !/\S/.test(c.text.slice(0, a)) && (a = c.from);
748
- let f = ["", x(t, d)];
749
- return l && f.push(x(t, u.lineIndent(c.from, -1))), {
750
- changes: {
751
- from: a,
752
- to: o,
753
- insert: s.of(f)
754
- },
755
- range: r.cursor(a + 1 + f[1].length)
756
- };
757
- });
758
- return n(t.update(a, {
759
- scrollIntoView: !0,
760
- userEvent: "input"
761
- })), !0;
762
- };
763
- }
764
- function zn(e, t) {
765
- let n = -1;
766
- return e.changeByRange((i) => {
767
- let a = [];
768
- for (let r = i.from; r <= i.to;) {
769
- let o = e.doc.lineAt(r);
770
- o.number > n && (i.empty || i.to > o.from) && (t(o, a, i), n = o.number), r = o.to + 1;
771
- }
772
- let o = e.changes(a);
773
- return {
774
- changes: a,
775
- range: r.range(o.mapPos(i.anchor, 1), o.mapPos(i.head, 1))
776
- };
777
- });
778
- }
779
- var Bn = ({ state: e, dispatch: t }) => {
780
- if (e.readOnly) return !1;
781
- let n = Object.create(null), r = new Oe(e, { overrideIndentation: (e) => n[e] ?? -1 }), i = zn(e, (t, i, a) => {
782
- let o = Ce(r, t.from);
783
- if (o == null) return;
784
- /\S/.test(t.text) || (o = 0);
785
- let s = /^\s*/.exec(t.text)[0], c = x(e, o);
786
- (s != c || a.from < t.from + s.length) && (n[t.from] = o, i.push({
787
- from: t.from,
788
- to: t.from + s.length,
789
- insert: c
790
- }));
791
- });
792
- return i.changes.empty || t(e.update(i, { userEvent: "indent" })), !0;
793
- }, Vn = ({ state: e, dispatch: t }) => !e.readOnly && (t(e.update(zn(e, (t, n) => {
794
- n.push({
795
- from: t.from,
796
- insert: e.facet(Se)
797
- });
798
- }), { userEvent: "input.indent" })), !0), Hn = ({ state: e, dispatch: t }) => !e.readOnly && (t(e.update(zn(e, (t, n) => {
799
- let r = /^\s*/.exec(t.text)[0];
800
- if (!r) return;
801
- let a = i(r, e.tabSize), o = 0, s = x(e, Math.max(0, a - je(e)));
802
- for (; o < r.length && o < s.length && r.charCodeAt(o) == s.charCodeAt(o);) o++;
803
- n.push({
804
- from: t.from + o,
805
- to: t.from + r.length,
806
- insert: s.slice(o)
807
- });
808
- }), { userEvent: "delete.dedent" })), !0), Un = (e) => (e.setTabFocusMode(), !0), Wn = [
809
- {
810
- key: "Ctrl-b",
811
- run: gt,
812
- shift: Bt,
813
- preventDefault: !0
814
- },
815
- {
816
- key: "Ctrl-f",
817
- run: _t,
818
- shift: Vt
819
- },
820
- {
821
- key: "Ctrl-p",
822
- run: Tt,
823
- shift: Jt
824
- },
825
- {
826
- key: "Ctrl-n",
827
- run: Et,
828
- shift: Yt
829
- },
830
- {
831
- key: "Ctrl-a",
832
- run: Ft,
833
- shift: rn
834
- },
835
- {
836
- key: "Ctrl-e",
837
- run: It,
838
- shift: an
839
- },
840
- {
841
- key: "Ctrl-d",
842
- run: yn
843
- },
844
- {
845
- key: "Ctrl-h",
846
- run: vn
847
- },
848
- {
849
- key: "Ctrl-k",
850
- run: Cn
851
- },
852
- {
853
- key: "Ctrl-Alt-h",
854
- run: xn
855
- },
856
- {
857
- key: "Ctrl-o",
858
- run: En
859
- },
860
- {
861
- key: "Ctrl-t",
862
- run: Dn
863
- },
864
- {
865
- key: "Ctrl-v",
866
- run: At
867
- }
868
- ], Gn = /*@__PURE__*/ [
869
- {
870
- key: "ArrowLeft",
871
- run: gt,
872
- shift: Bt,
873
- preventDefault: !0
874
- },
875
- {
876
- key: "Mod-ArrowLeft",
877
- mac: "Alt-ArrowLeft",
878
- run: yt,
879
- shift: Ut,
880
- preventDefault: !0
881
- },
882
- {
883
- mac: "Cmd-ArrowLeft",
884
- run: Nt,
885
- shift: tn,
886
- preventDefault: !0
887
- },
888
- {
889
- key: "ArrowRight",
890
- run: _t,
891
- shift: Vt,
892
- preventDefault: !0
893
- },
894
- {
895
- key: "Mod-ArrowRight",
896
- mac: "Alt-ArrowRight",
897
- run: bt,
898
- shift: Wt,
899
- preventDefault: !0
900
- },
901
- {
902
- mac: "Cmd-ArrowRight",
903
- run: Pt,
904
- shift: nn,
905
- preventDefault: !0
906
- },
907
- {
908
- key: "ArrowUp",
909
- run: Tt,
910
- shift: Jt,
911
- preventDefault: !0
912
- },
913
- {
914
- mac: "Cmd-ArrowUp",
915
- run: on,
916
- shift: cn
917
- },
918
- {
919
- mac: "Ctrl-ArrowUp",
920
- run: kt,
921
- shift: Zt
922
- },
923
- {
924
- key: "ArrowDown",
925
- run: Et,
926
- shift: Yt,
927
- preventDefault: !0
928
- },
929
- {
930
- mac: "Cmd-ArrowDown",
931
- run: sn,
932
- shift: ln
933
- },
934
- {
935
- mac: "Ctrl-ArrowDown",
936
- run: At,
937
- shift: Qt
938
- },
939
- {
940
- key: "PageUp",
941
- run: kt,
942
- shift: Zt
943
- },
944
- {
945
- key: "PageDown",
946
- run: At,
947
- shift: Qt
948
- },
949
- {
950
- key: "Home",
951
- run: Mt,
952
- shift: en,
953
- preventDefault: !0
954
- },
955
- {
956
- key: "Mod-Home",
957
- run: on,
958
- shift: cn
959
- },
960
- {
961
- key: "End",
962
- run: jt,
963
- shift: $t,
964
- preventDefault: !0
965
- },
966
- {
967
- key: "Mod-End",
968
- run: sn,
969
- shift: ln
970
- },
971
- {
972
- key: "Enter",
973
- run: In,
974
- shift: In
975
- },
976
- {
977
- key: "Mod-a",
978
- run: un
979
- },
980
- {
981
- key: "Backspace",
982
- run: vn,
983
- shift: vn,
984
- preventDefault: !0
985
- },
986
- {
987
- key: "Delete",
988
- run: yn,
989
- preventDefault: !0
990
- },
991
- {
992
- key: "Mod-Backspace",
993
- mac: "Alt-Backspace",
994
- run: xn,
995
- preventDefault: !0
996
- },
997
- {
998
- key: "Mod-Delete",
999
- mac: "Alt-Delete",
1000
- run: Sn,
1001
- preventDefault: !0
1002
- },
1003
- {
1004
- mac: "Mod-Backspace",
1005
- run: wn,
1006
- preventDefault: !0
1007
- },
1008
- {
1009
- mac: "Mod-Delete",
1010
- run: Tn,
1011
- preventDefault: !0
1012
- }
1013
- ].concat(/*@__PURE__*/ Wn.map((e) => ({
1014
- mac: e.key,
1015
- run: e.run,
1016
- shift: e.shift
1017
- }))), Kn = /*@__PURE__*/ [
1018
- {
1019
- key: "Alt-ArrowLeft",
1020
- mac: "Ctrl-ArrowLeft",
1021
- run: St,
1022
- shift: Gt
1023
- },
1024
- {
1025
- key: "Alt-ArrowRight",
1026
- mac: "Ctrl-ArrowRight",
1027
- run: Ct,
1028
- shift: Kt
1029
- },
1030
- {
1031
- key: "Alt-ArrowUp",
1032
- run: kn
1033
- },
1034
- {
1035
- key: "Shift-Alt-ArrowUp",
1036
- run: Mn
1037
- },
1038
- {
1039
- key: "Alt-ArrowDown",
1040
- run: An
1041
- },
1042
- {
1043
- key: "Shift-Alt-ArrowDown",
1044
- run: Nn
1045
- },
1046
- {
1047
- key: "Mod-Alt-ArrowUp",
1048
- run: mn
1049
- },
1050
- {
1051
- key: "Mod-Alt-ArrowDown",
1052
- run: hn
1053
- },
1054
- {
1055
- key: "Escape",
1056
- run: gn
1057
- },
1058
- {
1059
- key: "Mod-Enter",
1060
- run: Ln
1061
- },
1062
- {
1063
- key: "Alt-l",
1064
- mac: "Ctrl-l",
1065
- run: dn
1066
- },
1067
- {
1068
- key: "Mod-i",
1069
- run: fn,
1070
- preventDefault: !0
1071
- },
1072
- {
1073
- key: "Mod-[",
1074
- run: Hn
1075
- },
1076
- {
1077
- key: "Mod-]",
1078
- run: Vn
1079
- },
1080
- {
1081
- key: "Mod-Alt-\\",
1082
- run: Bn
1083
- },
1084
- {
1085
- key: "Shift-Mod-k",
1086
- run: Pn
1087
- },
1088
- {
1089
- key: "Shift-Mod-\\",
1090
- run: Rt
1091
- },
1092
- {
1093
- key: "Mod-/",
1094
- run: Ie
1095
- },
1096
- {
1097
- key: "Alt-A",
1098
- mac: "Ctrl-A",
1099
- run: ze
1100
- },
1101
- {
1102
- key: "Ctrl-m",
1103
- mac: "Shift-Alt-m",
1104
- run: Un
1105
- }
1106
- ].concat(Gn), qn = typeof String.prototype.normalize == "function" ? (e) => e.normalize("NFKD") : (e) => e, I = 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(qn(e)) : qn, 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 n(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 = ne(e), n = this.bufferStart + this.bufferPos;
1130
- this.bufferPos += te(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" && (I.prototype[Symbol.iterator] = function() {
1162
- return this;
1163
- });
1164
- var Jn = {
1165
- from: -1,
1166
- to: -1,
1167
- match: /*@__PURE__*/ /.*/.exec(""),
1168
- precise: !0
1169
- }, Yn = "gm" + (/x/.unicode == null ? "" : "u"), Xn = 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 = Jn, /\\[sWDnr]|\n|\r|\[\^/.test(t)) return new $n(e, t, n, r, i);
1172
- this.re = new RegExp(t, Yn + (n?.ignoreCase ? "i" : "")), this.test = n?.test, this.iter = e.iter();
1173
- let a = e.lineAt(r);
1174
- this.curLineStart = a.from, this.matchPos = L(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 = L(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
- }, Zn = /*@__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 = Zn.get(t);
1208
- if (!i || i.from >= r || i.to <= n) {
1209
- let i = new e(n, t.sliceString(n, r));
1210
- return Zn.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)), Zn.set(t, new e(o, a)), new e(n, a.slice(n - o, r - o));
1215
- }
1216
- }, $n = class {
1217
- constructor(e, t, n, r, i) {
1218
- this.text = e, this.to = i, this.done = !1, this.value = Jn, this.matchPos = L(e, r), this.re = new RegExp(t, Yn + (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 = L(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" && (Xn.prototype[Symbol.iterator] = $n.prototype[Symbol.iterator] = function() {
1241
- return this;
1242
- });
1243
- function er(e) {
1244
- try {
1245
- return new RegExp(e, Yn), !0;
1246
- } catch {
1247
- return !1;
1248
- }
1249
- }
1250
- function L(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 tr = (e) => {
1257
- let { state: t } = e, n = String(t.doc.lineAt(e.state.selection.main.head).number), { close: i, result: a } = ye(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 a.then((n) => {
1268
- let a = n && /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);
1269
- if (!a) {
1270
- e.dispatch({ effects: i });
1271
- return;
1272
- }
1273
- let o = t.doc.lineAt(t.selection.main.head), [, s, c, l, u] = a, d = l ? +l.slice(1) : 0, f = c ? +c : o.number;
1274
- if (c && u) {
1275
- let e = f / 100;
1276
- s && (e = e * (s == "-" ? -1 : 1) + o.number / t.doc.lines), f = Math.round(t.doc.lines * e);
1277
- } else c && s && (f = f * (s == "-" ? -1 : 1) + o.number);
1278
- let p = t.doc.line(Math.max(1, Math.min(t.doc.lines, f))), m = r.cursor(p.from + Math.max(0, Math.min(d, p.length)));
1279
- e.dispatch({
1280
- effects: [i, v.scrollIntoView(m.from, { y: "center" })],
1281
- selection: m
1282
- });
1283
- }), !0;
1284
- }, nr = {
1285
- highlightWordAroundCursor: !1,
1286
- minSelectionLength: 1,
1287
- maxMatches: 100,
1288
- wholeWords: !1
1289
- }, rr = /*@__PURE__*/ h.define({ combine(e) {
1290
- return g(e, nr, {
1291
- highlightWordAroundCursor: (e, t) => e || t,
1292
- minSelectionLength: Math.min,
1293
- maxMatches: Math.min
1294
- });
1295
- } });
1296
- function ir(e) {
1297
- let t = [ur, lr];
1298
- return e && t.push(rr.of(e)), t;
1299
- }
1300
- var ar = /*@__PURE__*/ y.mark({ class: "cm-selectionMatch" }), or = /*@__PURE__*/ y.mark({ class: "cm-selectionMatch cm-selectionMatch-main" });
1301
- function sr(e, t, n, r) {
1302
- return (n == 0 || e(t.sliceDoc(n - 1, n)) != c.Word) && (r == t.doc.length || e(t.sliceDoc(r, r + 1)) != c.Word);
1303
- }
1304
- function cr(e, t, n, r) {
1305
- return e(t.sliceDoc(n, n + 1)) == c.Word && e(t.sliceDoc(r - 1, r)) == c.Word;
1306
- }
1307
- var lr = /*@__PURE__*/ se.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(rr), { state: n } = e, r = n.selection;
1316
- if (r.ranges.length > 1) return y.none;
1317
- let i = r.main, a, o = null;
1318
- if (i.empty) {
1319
- if (!t.highlightWordAroundCursor) return y.none;
1320
- let e = n.wordAt(i.head);
1321
- if (!e) return y.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 y.none;
1326
- if (t.wholeWords) {
1327
- if (a = n.sliceDoc(i.from, i.to), o = n.charCategorizer(i.head), !(sr(o, n, i.from, i.to) && cr(o, n, i.from, i.to))) return y.none;
1328
- } else if (a = n.sliceDoc(i.from, i.to), !a) return y.none;
1329
- }
1330
- let s = [];
1331
- for (let r of e.visibleRanges) {
1332
- let e = new I(n.doc, a, r.from, r.to);
1333
- for (; !e.next().done;) {
1334
- let { from: r, to: a } = e.value;
1335
- if ((!o || sr(o, n, r, a)) && (i.empty && r <= i.from && a >= i.to ? s.push(or.range(r, a)) : (r >= i.to || a <= i.from) && s.push(ar.range(r, a)), s.length > t.maxMatches)) return y.none;
1336
- }
1337
- }
1338
- return y.set(s);
1339
- }
1340
- }, { decorations: (e) => e.decorations }), ur = /*@__PURE__*/ v.baseTheme({
1341
- ".cm-selectionMatch": { backgroundColor: "#99ff7780" },
1342
- ".cm-searchMatch .cm-selectionMatch": { backgroundColor: "transparent" }
1343
- }), dr = ({ state: e, dispatch: t }) => {
1344
- let { selection: n } = e, i = r.create(n.ranges.map((t) => e.wordAt(t.head) || r.cursor(t.head)), n.mainIndex);
1345
- return !i.eq(n) && (t(e.update({ selection: i })), !0);
1346
- };
1347
- function fr(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 I(e.doc, t, r[r.length - 1].to);;) if (i.next(), i.done) {
1350
- if (n) return null;
1351
- i = new I(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 pr = ({ state: e, dispatch: t }) => {
1362
- let { ranges: n } = e.selection;
1363
- if (n.some((e) => e.from === e.to)) return dr({
1364
- state: e,
1365
- dispatch: t
1366
- });
1367
- let i = e.sliceDoc(n[0].from, n[0].to);
1368
- if (e.selection.ranges.some((t) => e.sliceDoc(t.from, t.to) != i)) return !1;
1369
- let a = fr(e, i);
1370
- return a ? (t(e.update({
1371
- selection: e.selection.addRange(r.range(a.from, a.to), !1),
1372
- effects: v.scrollIntoView(a.to)
1373
- })), !0) : !1;
1374
- }, R = /*@__PURE__*/ h.define({ combine(e) {
1375
- return g(e, {
1376
- top: !1,
1377
- caseSensitive: !1,
1378
- literal: !1,
1379
- regexp: !1,
1380
- wholeWord: !1,
1381
- createPanel: (e) => new Rr(e),
1382
- scrollToMatch: (e) => v.scrollIntoView(e)
1383
- });
1384
- } }), mr = 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 || er(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 xr(this) : new vr(this);
1396
- }
1397
- getCursor(e, t = 0, n) {
1398
- let r = e.doc ? e : f.create({ doc: e });
1399
- return n ??= r.doc.length, this.regexp ? B(this, r, t, n) : z(this, r, t, n);
1400
- }
1401
- }, hr = class {
1402
- constructor(e) {
1403
- this.spec = e;
1404
- }
1405
- };
1406
- function gr(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 z(e, t, n, r) {
1410
- let i;
1411
- return e.wholeWord && (i = _r(t.doc, t.charCategorizer(t.selection.main.head))), e.test && (i = gr(e.test, t, i)), new I(t.doc, e.unquoted, n, r, e.caseSensitive ? void 0 : (e) => e.toLowerCase(), i);
1412
- }
1413
- function _r(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(V(i, n - a)) != c.Word || t(H(i, n - a)) != c.Word) && (t(H(i, r - a)) != c.Word || t(V(i, r - a)) != c.Word));
1415
- }
1416
- var vr = class extends hr {
1417
- constructor(e) {
1418
- super(e);
1419
- }
1420
- nextMatch(e, t, n) {
1421
- let r = z(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 = z(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 = z(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 = z(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 = z(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 yr(e, t, n) {
1458
- return (r, i, a) => (!n || n(r, i, a)) && e(a[0], t, r, i);
1459
- }
1460
- function B(e, t, n, r) {
1461
- let i;
1462
- return e.wholeWord && (i = br(t.charCategorizer(t.selection.main.head))), e.test && (i = yr(e.test, t, i)), new Xn(t.doc, e.search, {
1463
- ignoreCase: !e.caseSensitive,
1464
- test: i
1465
- }, n, r);
1466
- }
1467
- function V(e, n) {
1468
- return e.slice(t(e, n, !1), n);
1469
- }
1470
- function H(e, n) {
1471
- return e.slice(n, t(e, n));
1472
- }
1473
- function br(e) {
1474
- return (t, n, r) => !r[0].length || (e(V(r.input, r.index)) != c.Word || e(H(r.input, r.index)) != c.Word) && (e(H(r.input, r.index + r[0].length)) != c.Word || e(V(r.input, r.index + r[0].length)) != c.Word);
1475
- }
1476
- var xr = class extends hr {
1477
- nextMatch(e, t, n) {
1478
- let r = B(this.spec, e, n, e.doc.length).next();
1479
- return r.done && (r = B(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 = B(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 = B(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 = B(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
- }, U = /*@__PURE__*/ p.define(), Sr = /*@__PURE__*/ p.define(), W = /*@__PURE__*/ u.define({
1516
- create(e) {
1517
- return new Cr(Mr(e).create(), null);
1518
- },
1519
- update(e, t) {
1520
- for (let n of t.effects) n.is(U) ? e = new Cr(n.value.create(), e.panel) : n.is(Sr) && (e = new Cr(e.query, n.value ? jr : null));
1521
- return e;
1522
- },
1523
- provide: (e) => ae.from(e, (e) => e.panel)
1524
- }), Cr = class {
1525
- constructor(e, t) {
1526
- this.query = e, this.panel = t;
1527
- }
1528
- }, wr = /*@__PURE__*/ y.mark({ class: "cm-searchMatch" }), Tr = /*@__PURE__*/ y.mark({ class: "cm-searchMatch cm-searchMatch-selected" }), Er = /*@__PURE__*/ se.fromClass(class {
1529
- constructor(e) {
1530
- this.view = e, this.decorations = this.highlight(e.state.field(W));
1531
- }
1532
- update(e) {
1533
- let t = e.state.field(W);
1534
- (t != e.startState.field(W) || 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 y.none;
1538
- let { view: n } = this, r = new a();
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 ? Tr : wr);
1545
- });
1546
- }
1547
- return r.finish();
1548
- }
1549
- }, { decorations: (e) => e.decorations });
1550
- function G(e) {
1551
- return (t) => {
1552
- let n = t.state.field(W, !1);
1553
- return n && n.query.spec.valid ? e(t, n) : Fr(t);
1554
- };
1555
- }
1556
- var K = /*@__PURE__*/ G((e, { query: t }) => {
1557
- let { to: n } = e.state.selection.main, i = t.nextMatch(e.state, n, n);
1558
- if (!i) return !1;
1559
- let a = r.single(i.from, i.to), o = e.state.facet(R);
1560
- return e.dispatch({
1561
- selection: a,
1562
- effects: [Br(e, i), o.scrollToMatch(a.main, e)],
1563
- userEvent: "select.search"
1564
- }), Pr(e), !0;
1565
- }), q = /*@__PURE__*/ G((e, { query: t }) => {
1566
- let { state: n } = e, { from: i } = n.selection.main, a = t.prevMatch(n, i, i);
1567
- if (!a) return !1;
1568
- let o = r.single(a.from, a.to), s = e.state.facet(R);
1569
- return e.dispatch({
1570
- selection: o,
1571
- effects: [Br(e, a), s.scrollToMatch(o.main, e)],
1572
- userEvent: "select.search"
1573
- }), Pr(e), !0;
1574
- }), Dr = /*@__PURE__*/ G((e, { query: t }) => {
1575
- let n = t.matchAll(e.state, 1e3);
1576
- return !n || !n.length ? !1 : (e.dispatch({
1577
- selection: r.create(n.map((e) => r.range(e.from, e.to))),
1578
- userEvent: "select.search.matches"
1579
- }), !0);
1580
- }), Or = ({ state: e, dispatch: t }) => {
1581
- let n = e.selection;
1582
- if (n.ranges.length > 1 || n.main.empty) return !1;
1583
- let { from: i, to: a } = n.main, o = [], s = 0;
1584
- for (let t = new I(e.doc, e.sliceDoc(i, a)); !t.next().done;) {
1585
- if (o.length > 1e3) return !1;
1586
- t.value.from == i && (s = o.length), o.push(r.range(t.value.from, t.value.to));
1587
- }
1588
- return t(e.update({
1589
- selection: r.create(o, s),
1590
- userEvent: "select.search.matches"
1591
- })), !0;
1592
- }, kr = /*@__PURE__*/ G((e, { query: t }) => {
1593
- let { state: n } = e, { from: i, to: a } = n.selection.main;
1594
- if (n.readOnly) return !1;
1595
- let o = t.nextMatch(n, i, i);
1596
- if (!o) return !1;
1597
- let s = o, c = [], l, u, d = [];
1598
- s.precise ? s.from == i && s.to == a && (u = n.toText(t.getReplacement(s)), c.push({
1599
- from: s.from,
1600
- to: s.to,
1601
- insert: u
1602
- }), s = t.nextMatch(n, s.from, s.to), d.push(v.announce.of(n.phrase("replaced match on line $", n.doc.lineAt(i).number) + "."))) : s = t.nextMatch(n, s.from, s.to);
1603
- let f = e.state.changes(c);
1604
- return s && (l = r.single(s.from, s.to).map(f), d.push(Br(e, s)), d.push(n.facet(R).scrollToMatch(l.main, e))), e.dispatch({
1605
- changes: f,
1606
- selection: l,
1607
- effects: d,
1608
- userEvent: "input.replace"
1609
- }), !0;
1610
- }), Ar = /*@__PURE__*/ G((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: v.announce.of(r),
1626
- userEvent: "input.replace.all"
1627
- }), !0;
1628
- });
1629
- function jr(e) {
1630
- return e.state.facet(R).createPanel(e);
1631
- }
1632
- function Mr(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(R);
1636
- return new mr({
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 Nr(e) {
1645
- let t = de(e, jr);
1646
- return t && t.dom.querySelector("[main-field]");
1647
- }
1648
- function Pr(e) {
1649
- let t = Nr(e);
1650
- t && t == e.root.activeElement && t.select();
1651
- }
1652
- var Fr = (e) => {
1653
- let t = e.state.field(W, !1);
1654
- if (t && t.panel) {
1655
- let n = Nr(e);
1656
- if (n && n != e.root.activeElement) {
1657
- let r = Mr(e.state, t.query.spec);
1658
- r.valid && e.dispatch({ effects: U.of(r) }), n.focus(), n.select();
1659
- }
1660
- } else e.dispatch({ effects: [Sr.of(!0), t ? U.of(Mr(e.state, t.query.spec)) : p.appendConfig.of(Hr)] });
1661
- return !0;
1662
- }, Ir = (e) => {
1663
- let t = e.state.field(W, !1);
1664
- if (!t || !t.panel) return !1;
1665
- let n = de(e, jr);
1666
- return n && n.dom.contains(e.root.activeElement) && e.focus(), e.dispatch({ effects: Sr.of(!1) }), !0;
1667
- }, Lr = [
1668
- {
1669
- key: "Mod-f",
1670
- run: Fr,
1671
- scope: "editor search-panel"
1672
- },
1673
- {
1674
- key: "F3",
1675
- run: K,
1676
- shift: q,
1677
- scope: "editor search-panel",
1678
- preventDefault: !0
1679
- },
1680
- {
1681
- key: "Mod-g",
1682
- run: K,
1683
- shift: q,
1684
- scope: "editor search-panel",
1685
- preventDefault: !0
1686
- },
1687
- {
1688
- key: "Escape",
1689
- run: Ir,
1690
- scope: "editor search-panel"
1691
- },
1692
- {
1693
- key: "Mod-Shift-l",
1694
- run: Or
1695
- },
1696
- {
1697
- key: "Mod-Alt-g",
1698
- run: tr
1699
- },
1700
- {
1701
- key: "Mod-d",
1702
- run: pr,
1703
- preventDefault: !0
1704
- }
1705
- ], Rr = class {
1706
- constructor(e) {
1707
- this.view = e;
1708
- let t = this.query = e.state.field(W).query.spec;
1709
- this.commit = this.commit.bind(this), this.searchField = _("input", {
1710
- value: t.search,
1711
- placeholder: J(e, "Find"),
1712
- "aria-label": J(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 = _("input", {
1720
- value: t.replace,
1721
- placeholder: J(e, "Replace"),
1722
- "aria-label": J(e, "Replace"),
1723
- class: "cm-textfield",
1724
- name: "replace",
1725
- form: "",
1726
- onchange: this.commit,
1727
- onkeyup: this.commit
1728
- }), this.caseField = _("input", {
1729
- type: "checkbox",
1730
- name: "case",
1731
- form: "",
1732
- checked: t.caseSensitive,
1733
- onchange: this.commit
1734
- }), this.reField = _("input", {
1735
- type: "checkbox",
1736
- name: "re",
1737
- form: "",
1738
- checked: t.regexp,
1739
- onchange: this.commit
1740
- }), this.wordField = _("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 _("button", {
1749
- class: "cm-button",
1750
- name: e,
1751
- onclick: t,
1752
- type: "button"
1753
- }, n);
1754
- }
1755
- this.dom = _("div", {
1756
- onkeydown: (e) => this.keydown(e),
1757
- class: "cm-search"
1758
- }, [
1759
- this.searchField,
1760
- n("next", () => K(e), [J(e, "next")]),
1761
- n("prev", () => q(e), [J(e, "previous")]),
1762
- n("select", () => Dr(e), [J(e, "all")]),
1763
- _("label", null, [this.caseField, J(e, "match case")]),
1764
- _("label", null, [this.reField, J(e, "regexp")]),
1765
- _("label", null, [this.wordField, J(e, "by word")]),
1766
- ...e.state.readOnly ? [] : [
1767
- _("br"),
1768
- this.replaceField,
1769
- n("replace", () => kr(e), [J(e, "replace")]),
1770
- n("replaceAll", () => Ar(e), [J(e, "replace all")])
1771
- ],
1772
- _("button", {
1773
- name: "close",
1774
- onclick: () => Ir(e),
1775
- "aria-label": J(e, "close"),
1776
- type: "button"
1777
- }, ["×"])
1778
- ]);
1779
- }
1780
- commit() {
1781
- let e = new mr({
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: U.of(e) }));
1789
- }
1790
- keydown(e) {
1791
- re(this.view, e, "search-panel") ? e.preventDefault() : e.keyCode == 13 && e.target == this.searchField ? (e.preventDefault(), (e.shiftKey ? q : K)(this.view)) : e.keyCode == 13 && e.target == this.replaceField && (e.preventDefault(), kr(this.view));
1792
- }
1793
- update(e) {
1794
- for (let t of e.transactions) for (let e of t.effects) e.is(U) && !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(R).top;
1807
- }
1808
- };
1809
- function J(e, t) {
1810
- return e.state.phrase(t);
1811
- }
1812
- var Y = 30, zr = /[\s\.,:;?!]/;
1813
- function Br(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 - Y), o = Math.min(i, n + Y), s = e.state.sliceDoc(a, o);
1815
- if (a != r.from) {
1816
- for (let e = 0; e < Y; e++) if (!zr.test(s[e + 1]) && zr.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 - Y; e--) if (!zr.test(s[e - 1]) && zr.test(s[e])) {
1823
- s = s.slice(0, e);
1824
- break;
1825
- }
1826
- }
1827
- return v.announce.of(`${e.state.phrase("current match")}. ${s} ${e.state.phrase("on line")} ${r.number}.`);
1828
- }
1829
- var Vr = /*@__PURE__*/ v.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
- }), Hr = [
1855
- W,
1856
- /*@__PURE__*/ l.low(Er),
1857
- Vr
1858
- ], Ur = class {
1859
- constructor(e, t, n) {
1860
- this.from = e, this.to = t, this.diagnostic = n;
1861
- }
1862
- }, X = class e {
1863
- constructor(e, t, n) {
1864
- this.diagnostics = e, this.panel = t, this.selected = n;
1865
- }
1866
- static init(t, n, r) {
1867
- let i = r.facet($).markerFilter;
1868
- i && (t = i(t, r));
1869
- let o = t.slice().sort((e, t) => e.from - t.from || e.to - t.to), s = new a(), c = [], l = 0, u = r.doc.iter(), d = 0, f = r.doc.length;
1870
- for (let e = 0;;) {
1871
- let t = e == o.length ? null : o[e];
1872
- if (!t && !c.length) break;
1873
- let n, r;
1874
- if (c.length) n = l, r = c.reduce((e, t) => Math.min(e, t.to), t && t.from > n ? t.from : 1e8);
1875
- else {
1876
- if (n = t.from, n > f) break;
1877
- r = t.to, c.push(t), e++;
1878
- }
1879
- for (; e < o.length;) {
1880
- let t = o[e];
1881
- if (t.from == n && (t.to > t.from || t.to == n)) c.push(t), e++, r = Math.min(t.to, r);
1882
- else {
1883
- r = Math.min(t.from, r);
1884
- break;
1885
- }
1886
- }
1887
- r = Math.min(r, f);
1888
- let i = !1;
1889
- if (c.some((e) => e.from == n && (e.to == r || r == f)) && (i = n == r, !i && r - n < 10)) {
1890
- let e = n - (d + u.value.length);
1891
- e > 0 && (u.next(e), d = n);
1892
- for (let e = n;;) {
1893
- if (e >= r) {
1894
- i = !0;
1895
- break;
1896
- }
1897
- if (!u.lineBreak && d + u.value.length > e) break;
1898
- e = d + u.value.length, d += u.value.length, u.next();
1899
- }
1900
- }
1901
- let a = di(c);
1902
- if (i) s.add(n, n, y.widget({
1903
- widget: new ii(a),
1904
- diagnostics: c.slice()
1905
- }));
1906
- else {
1907
- let e = c.reduce((e, t) => t.markClass ? e + " " + t.markClass : e, "");
1908
- s.add(n, r, y.mark({
1909
- class: "cm-lintRange cm-lintRange-" + a + e,
1910
- diagnostics: c.slice(),
1911
- inclusiveEnd: c.some((e) => e.to > r)
1912
- }));
1913
- }
1914
- if (l = r, l == f) break;
1915
- for (let e = 0; e < c.length; e++) c[e].to <= l && c.splice(e--, 1);
1916
- }
1917
- let p = s.finish();
1918
- return new e(p, n, Z(p));
1919
- }
1920
- };
1921
- function Z(e, t = null, n = 0) {
1922
- let r = null;
1923
- return e.between(n, 1e9, (e, n, { spec: i }) => {
1924
- if (!(t && i.diagnostics.indexOf(t) < 0)) {
1925
- if (!r) r = new Ur(e, n, t || i.diagnostics[0]);
1926
- else if (i.diagnostics.indexOf(r.diagnostic) < 0) return !1;
1927
- else r = new Ur(r.from, n, r.diagnostic);
1928
- }
1929
- }), r;
1930
- }
1931
- function Wr(e, t) {
1932
- let n = t.pos, r = t.end || n, i = e.state.facet($).hideOn(e, n, r);
1933
- if (i != null) return i;
1934
- let a = e.startState.doc.lineAt(t.pos);
1935
- return !!(e.effects.some((e) => e.is(Kr)) || e.changes.touchesRange(a.from, Math.max(a.to, r)));
1936
- }
1937
- function Gr(e, t) {
1938
- return e.field(Q, !1) ? t : t.concat(p.appendConfig.of(pi));
1939
- }
1940
- var Kr = /*@__PURE__*/ p.define(), qr = /*@__PURE__*/ p.define(), Jr = /*@__PURE__*/ p.define(), Q = /*@__PURE__*/ u.define({
1941
- create() {
1942
- return new X(y.none, null, null);
1943
- },
1944
- update(e, t) {
1945
- if (t.docChanged && e.diagnostics.size) {
1946
- let n = e.diagnostics.map(t.changes), r = null, i = e.panel;
1947
- if (e.selected) {
1948
- let i = t.changes.mapPos(e.selected.from, 1);
1949
- r = Z(n, e.selected.diagnostic, i) || Z(n, null, i);
1950
- }
1951
- !n.size && i && t.state.facet($).autoPanel && (i = null), e = new X(n, i, r);
1952
- }
1953
- for (let n of t.effects) if (n.is(Kr)) {
1954
- let r = t.state.facet($).autoPanel ? n.value.length ? oi.open : null : e.panel;
1955
- e = X.init(n.value, r, t.state);
1956
- } else n.is(qr) ? e = new X(e.diagnostics, n.value ? oi.open : null, e.selected) : n.is(Jr) && (e = new X(e.diagnostics, e.panel, n.value));
1957
- return e;
1958
- },
1959
- provide: (e) => [ae.from(e, (e) => e.panel), v.decorations.from(e, (e) => e.diagnostics)]
1960
- }), Yr = /*@__PURE__*/ y.mark({ class: "cm-lintRange cm-lintRange-active" });
1961
- function Xr(e, t, n) {
1962
- let { diagnostics: r } = e.state.field(Q), i, a = -1, o = -1;
1963
- r.between(t - +(n < 0), t + +(n > 0), (e, r, { spec: s }) => {
1964
- if (t >= e && t <= r && (e == r || (t > e || n > 0) && (t < r || n < 0))) return i = s.diagnostics, a = e, o = r, !1;
1965
- });
1966
- let s = e.state.facet($).tooltipFilter;
1967
- return i && s && (i = s(i, e.state)), i ? {
1968
- pos: a,
1969
- end: o,
1970
- above: !0,
1971
- create() {
1972
- return { dom: Zr(e, i) };
1973
- }
1974
- } : null;
1975
- }
1976
- function Zr(e, t) {
1977
- return _("ul", { class: "cm-tooltip-lint" }, t.map((t) => ri(e, t, !1)));
1978
- }
1979
- var Qr = (e) => {
1980
- let t = e.state.field(Q, !1);
1981
- (!t || !t.panel) && e.dispatch({ effects: Gr(e.state, [qr.of(!0)]) });
1982
- let n = de(e, oi.open);
1983
- return n && n.dom.querySelector(".cm-panel-lint ul").focus(), !0;
1984
- }, $r = (e) => {
1985
- let t = e.state.field(Q, !1);
1986
- return !t || !t.panel ? !1 : (e.dispatch({ effects: qr.of(!1) }), !0);
1987
- }, ei = [{
1988
- key: "Mod-Shift-m",
1989
- run: Qr,
1990
- preventDefault: !0
1991
- }, {
1992
- key: "F8",
1993
- run: (e) => {
1994
- let t = e.state.field(Q, !1);
1995
- if (!t) return !1;
1996
- let n = e.state.selection.main, r = Z(t.diagnostics, null, n.to + 1);
1997
- return !r && (r = Z(t.diagnostics, null, 0), !r || r.from == n.from && r.to == n.to) ? !1 : (e.dispatch({
1998
- selection: {
1999
- anchor: r.from,
2000
- head: r.to
2001
- },
2002
- scrollIntoView: !0
2003
- }), ge(e, r.from, 1, {
2004
- tooltip: fi,
2005
- until: (e) => e.docChanged || e.newSelection.main.head < r.from || e.newSelection.main.head > r.to
2006
- }), !0);
2007
- }
2008
- }], $ = /*@__PURE__*/ h.define({ combine(e) {
2009
- return {
2010
- sources: e.map((e) => e.source).filter((e) => e != null),
2011
- ...g(e.map((e) => e.config), {
2012
- delay: 750,
2013
- markerFilter: null,
2014
- tooltipFilter: null,
2015
- needsRefresh: null,
2016
- hideOn: () => null
2017
- }, {
2018
- delay: Math.max,
2019
- markerFilter: ti,
2020
- tooltipFilter: ti,
2021
- needsRefresh: (e, t) => e ? t ? (n) => e(n) || t(n) : e : t,
2022
- hideOn: (e, t) => e ? t ? (n, r, i) => e(n, r, i) || t(n, r, i) : e : t,
2023
- autoPanel: (e, t) => e || t
2024
- })
2025
- };
2026
- } });
2027
- function ti(e, t) {
2028
- return e ? t ? (n, r) => t(e(n, r), r) : e : t;
2029
- }
2030
- function ni(e) {
2031
- let t = [];
2032
- if (e) actions: for (let { name: n } of e) {
2033
- for (let e = 0; e < n.length; e++) {
2034
- let r = n[e];
2035
- if (/[a-zA-Z]/.test(r) && !t.some((e) => e.toLowerCase() == r.toLowerCase())) {
2036
- t.push(r);
2037
- continue actions;
2038
- }
2039
- }
2040
- t.push("");
2041
- }
2042
- return t;
2043
- }
2044
- function ri(e, t, n) {
2045
- let r = n ? ni(t.actions) : [];
2046
- return _("li", { class: "cm-diagnostic cm-diagnostic-" + t.severity }, _("span", { class: "cm-diagnosticText" }, t.renderMessage ? t.renderMessage(e) : t.message), t.actions?.map((n, i) => {
2047
- let a = !1, o = (r) => {
2048
- if (r.preventDefault(), a) return;
2049
- a = !0;
2050
- let i = Z(e.state.field(Q).diagnostics, t);
2051
- i && n.apply(e, i.from, i.to);
2052
- }, { name: s } = n, c = r[i] ? s.indexOf(r[i]) : -1, l = c < 0 ? s : [
2053
- s.slice(0, c),
2054
- _("u", s.slice(c, c + 1)),
2055
- s.slice(c + 1)
2056
- ], u = n.markClass ? " " + n.markClass : "";
2057
- return _("button", {
2058
- type: "button",
2059
- class: "cm-diagnosticAction" + u,
2060
- onclick: o,
2061
- onmousedown: o,
2062
- "aria-label": ` Action: ${s}${c < 0 ? "" : ` (access key "${r[i]})"`}.`
2063
- }, l);
2064
- }), t.source && _("div", { class: "cm-diagnosticSource" }, t.source));
2065
- }
2066
- var ii = class extends he {
2067
- constructor(e) {
2068
- super(), this.sev = e;
2069
- }
2070
- eq(e) {
2071
- return e.sev == this.sev;
2072
- }
2073
- toDOM() {
2074
- return _("span", { class: "cm-lintPoint cm-lintPoint-" + this.sev });
2075
- }
2076
- }, ai = class {
2077
- constructor(e, t) {
2078
- this.diagnostic = t, this.id = "item_" + Math.floor(Math.random() * 4294967295).toString(16), this.dom = ri(e, t, !0), this.dom.id = this.id, this.dom.setAttribute("role", "option");
2079
- }
2080
- }, oi = class e {
2081
- constructor(e) {
2082
- this.view = e, this.items = [];
2083
- let t = (t) => {
2084
- if (!(t.ctrlKey || t.altKey || t.metaKey)) {
2085
- if (t.keyCode == 27) $r(this.view), this.view.focus();
2086
- else if (t.keyCode == 38 || t.keyCode == 33) this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
2087
- else if (t.keyCode == 40 || t.keyCode == 34) this.moveSelection((this.selectedIndex + 1) % this.items.length);
2088
- else if (t.keyCode == 36) this.moveSelection(0);
2089
- else if (t.keyCode == 35) this.moveSelection(this.items.length - 1);
2090
- else if (t.keyCode == 13) this.view.focus();
2091
- else if (t.keyCode >= 65 && t.keyCode <= 90 && this.selectedIndex >= 0) {
2092
- let { diagnostic: n } = this.items[this.selectedIndex], r = ni(n.actions);
2093
- for (let i = 0; i < r.length; i++) if (r[i].toUpperCase().charCodeAt(0) == t.keyCode) {
2094
- let t = Z(this.view.state.field(Q).diagnostics, n);
2095
- t && n.actions[i].apply(e, t.from, t.to);
2096
- }
2097
- } else return;
2098
- t.preventDefault();
2099
- }
2100
- }, n = (e) => {
2101
- for (let t = 0; t < this.items.length; t++) this.items[t].dom.contains(e.target) && this.moveSelection(t);
2102
- };
2103
- this.list = _("ul", {
2104
- tabIndex: 0,
2105
- role: "listbox",
2106
- "aria-label": this.view.state.phrase("Diagnostics"),
2107
- onkeydown: t,
2108
- onclick: n
2109
- }), this.dom = _("div", { class: "cm-panel-lint" }, this.list, _("button", {
2110
- type: "button",
2111
- name: "close",
2112
- "aria-label": this.view.state.phrase("close"),
2113
- onclick: () => $r(this.view)
2114
- }, "×")), this.update();
2115
- }
2116
- get selectedIndex() {
2117
- let e = this.view.state.field(Q).selected;
2118
- if (!e) return -1;
2119
- for (let t = 0; t < this.items.length; t++) if (this.items[t].diagnostic == e.diagnostic) return t;
2120
- return -1;
2121
- }
2122
- update() {
2123
- let { diagnostics: e, selected: t } = this.view.state.field(Q), n = 0, r = !1, i = null, a = /* @__PURE__ */ new Set();
2124
- for (e.between(0, this.view.state.doc.length, (e, o, { spec: s }) => {
2125
- for (let e of s.diagnostics) {
2126
- if (a.has(e)) continue;
2127
- a.add(e);
2128
- let o = -1, s;
2129
- for (let t = n; t < this.items.length; t++) if (this.items[t].diagnostic == e) {
2130
- o = t;
2131
- break;
2132
- }
2133
- o < 0 ? (s = new ai(this.view, e), this.items.splice(n, 0, s), r = !0) : (s = this.items[o], o > n && (this.items.splice(n, o - n), r = !0)), t && s.diagnostic == t.diagnostic ? s.dom.hasAttribute("aria-selected") || (s.dom.setAttribute("aria-selected", "true"), i = s) : s.dom.hasAttribute("aria-selected") && s.dom.removeAttribute("aria-selected"), n++;
2134
- }
2135
- }); n < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0);) r = !0, this.items.pop();
2136
- this.items.length == 0 && (this.items.push(new ai(this.view, {
2137
- from: -1,
2138
- to: -1,
2139
- severity: "info",
2140
- message: this.view.state.phrase("No diagnostics")
2141
- })), r = !0), i ? (this.list.setAttribute("aria-activedescendant", i.id), this.view.requestMeasure({
2142
- key: this,
2143
- read: () => ({
2144
- sel: i.dom.getBoundingClientRect(),
2145
- panel: this.list.getBoundingClientRect()
2146
- }),
2147
- write: ({ sel: e, panel: t }) => {
2148
- let n = t.height / this.list.offsetHeight;
2149
- e.top < t.top ? this.list.scrollTop -= (t.top - e.top) / n : e.bottom > t.bottom && (this.list.scrollTop += (e.bottom - t.bottom) / n);
2150
- }
2151
- })) : this.selectedIndex < 0 && this.list.removeAttribute("aria-activedescendant"), r && this.sync();
2152
- }
2153
- sync() {
2154
- let e = this.list.firstChild;
2155
- function t() {
2156
- let t = e;
2157
- e = t.nextSibling, t.remove();
2158
- }
2159
- for (let n of this.items) if (n.dom.parentNode == this.list) {
2160
- for (; e != n.dom;) t();
2161
- e = n.dom.nextSibling;
2162
- } else this.list.insertBefore(n.dom, e);
2163
- for (; e;) t();
2164
- }
2165
- moveSelection(e) {
2166
- if (this.selectedIndex < 0) return;
2167
- let t = Z(this.view.state.field(Q).diagnostics, this.items[e].diagnostic);
2168
- t && this.view.dispatch({
2169
- selection: {
2170
- anchor: t.from,
2171
- head: t.to
2172
- },
2173
- scrollIntoView: !0,
2174
- effects: Jr.of(t)
2175
- });
2176
- }
2177
- static open(t) {
2178
- return new e(t);
2179
- }
2180
- };
2181
- function si(e, t = "viewBox=\"0 0 40 40\"") {
2182
- return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`;
2183
- }
2184
- function ci(e) {
2185
- return si(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`, "width=\"6\" height=\"3\"");
2186
- }
2187
- var li = /*@__PURE__*/ v.baseTheme({
2188
- ".cm-diagnostic": {
2189
- padding: "3px 6px 3px 8px",
2190
- marginLeft: "-1px",
2191
- display: "block",
2192
- whiteSpace: "pre-wrap"
2193
- },
2194
- ".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
2195
- ".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
2196
- ".cm-diagnostic-info": { borderLeft: "5px solid #999" },
2197
- ".cm-diagnostic-hint": { borderLeft: "5px solid #66d" },
2198
- ".cm-diagnosticAction": {
2199
- font: "inherit",
2200
- border: "none",
2201
- padding: "2px 4px",
2202
- backgroundColor: "#444",
2203
- color: "white",
2204
- borderRadius: "3px",
2205
- marginLeft: "8px",
2206
- cursor: "pointer"
2207
- },
2208
- ".cm-diagnosticSource": {
2209
- fontSize: "70%",
2210
- opacity: .7
2211
- },
2212
- ".cm-lintRange": {
2213
- backgroundPosition: "left bottom",
2214
- backgroundRepeat: "repeat-x",
2215
- paddingBottom: "0.7px"
2216
- },
2217
- ".cm-lintRange-error": { backgroundImage: /*@__PURE__*/ ci("#f11") },
2218
- ".cm-lintRange-warning": { backgroundImage: /*@__PURE__*/ ci("orange") },
2219
- ".cm-lintRange-info": { backgroundImage: /*@__PURE__*/ ci("#999") },
2220
- ".cm-lintRange-hint": { backgroundImage: /*@__PURE__*/ ci("#66d") },
2221
- ".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
2222
- ".cm-tooltip-lint": {
2223
- padding: 0,
2224
- margin: 0
2225
- },
2226
- ".cm-lintPoint": {
2227
- position: "relative",
2228
- "&:after": {
2229
- content: "\"\"",
2230
- position: "absolute",
2231
- bottom: 0,
2232
- left: "-2px",
2233
- borderLeft: "3px solid transparent",
2234
- borderRight: "3px solid transparent",
2235
- borderBottom: "4px solid #d11"
2236
- }
2237
- },
2238
- ".cm-lintPoint-warning": { "&:after": { borderBottomColor: "orange" } },
2239
- ".cm-lintPoint-info": { "&:after": { borderBottomColor: "#999" } },
2240
- ".cm-lintPoint-hint": { "&:after": { borderBottomColor: "#66d" } },
2241
- ".cm-panel.cm-panel-lint": {
2242
- position: "relative",
2243
- "& ul": {
2244
- maxHeight: "100px",
2245
- overflowY: "auto",
2246
- "& [aria-selected]": {
2247
- backgroundColor: "#ddd",
2248
- "& u": { textDecoration: "underline" }
2249
- },
2250
- "&:focus [aria-selected]": {
2251
- background_fallback: "#bdf",
2252
- backgroundColor: "Highlight",
2253
- color_fallback: "white",
2254
- color: "HighlightText"
2255
- },
2256
- "& u": { textDecoration: "none" },
2257
- padding: 0,
2258
- margin: 0
2259
- },
2260
- "& [name=close]": {
2261
- position: "absolute",
2262
- top: "0",
2263
- right: "2px",
2264
- background: "inherit",
2265
- border: "none",
2266
- font: "inherit",
2267
- padding: 0,
2268
- margin: 0
2269
- }
2270
- },
2271
- "&dark .cm-lintRange-active": { backgroundColor: "#86714a80" },
2272
- "&dark .cm-panel.cm-panel-lint ul": { "& [aria-selected]": { backgroundColor: "#2e343e" } }
2273
- });
2274
- function ui(e) {
2275
- return e == "error" ? 4 : e == "warning" ? 3 : e == "info" ? 2 : 1;
2276
- }
2277
- function di(e) {
2278
- let t = "hint", n = 1;
2279
- for (let r of e) {
2280
- let e = ui(r.severity);
2281
- e > n && (n = e, t = r.severity);
2282
- }
2283
- return t;
2284
- }
2285
- var fi = /*@__PURE__*/ ve(Xr, { hideOn: Wr }), pi = [
2286
- Q,
2287
- /*@__PURE__*/ v.decorations.compute([Q], (e) => {
2288
- let { selected: t, panel: n } = e.field(Q);
2289
- return !t || !n || t.from == t.to ? y.none : y.set([Yr.range(t.from, t.to)]);
2290
- }),
2291
- fi,
2292
- li
2293
- ], mi = [
2294
- ce(),
2295
- fe(),
2296
- oe(),
2297
- Qe(),
2298
- Ee(),
2299
- _e(),
2300
- ue(),
2301
- f.allowMultipleSelections.of(!0),
2302
- Ae(),
2303
- xe(Te, { fallback: !0 }),
2304
- we(),
2305
- Fe(),
2306
- Ne(),
2307
- ie(),
2308
- le(),
2309
- pe(),
2310
- ir(),
2311
- be.of([
2312
- ...Me,
2313
- ...Kn,
2314
- ...Lr,
2315
- ...pt,
2316
- ...ke,
2317
- ...Pe,
2318
- ...ei
2319
- ])
2320
- ], hi = [
2321
- oe(),
2322
- Qe(),
2323
- _e(),
2324
- xe(Te, { fallback: !0 }),
2325
- be.of([...Kn, ...pt])
2326
- ];
2327
- //#endregion
2328
- export { v as EditorView, mi as basicSetup, hi as minimalSetup };