@oomol-lab/open-flow 0.1.0-beta.3 → 0.1.0-beta.30

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