@pi-outpost/embed 0.35.2 → 0.37.0

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 (59) hide show
  1. package/dist/CodeEditor-2Vx8PHAy.js +2790 -0
  2. package/dist/CodeEditor-Cb6i9oIs.cjs +6 -0
  3. package/dist/clike-8rZWBES0.cjs +1 -0
  4. package/dist/clike-D-dOQnrm.js +587 -0
  5. package/dist/{conversationExport-DU5Xp2g-.js → conversationExport-BXEb1n8C.js} +2 -2
  6. package/dist/{conversationExport-DwLc0HDC.cjs → conversationExport-DEKaUq-d.cjs} +1 -1
  7. package/dist/{conversationHistory-DTP8xNqg.cjs → conversationHistory-BCj7z0AY.cjs} +5 -5
  8. package/dist/{conversationHistory-DHEPfViO.js → conversationHistory-BsL2Q-mL.js} +4759 -4747
  9. package/dist/dist-B0lO3k1f.js +410 -0
  10. package/dist/dist-B7I27gkN.cjs +1 -0
  11. package/dist/dist-B8gmxwh-.cjs +23 -0
  12. package/dist/dist-BBUKMRrs.js +69 -0
  13. package/dist/dist-BWlGU9XM.js +395 -0
  14. package/dist/dist-BZcglaBe.cjs +1 -0
  15. package/dist/dist-BZjcsPqi.cjs +13 -0
  16. package/dist/dist-BfQGuM1r.js +1340 -0
  17. package/dist/dist-BhNvvg0I.js +471 -0
  18. package/dist/dist-BhXQJ0x3.js +10805 -0
  19. package/dist/dist-BlD6NhiG.js +296 -0
  20. package/dist/dist-Bppoi_v9.js +357 -0
  21. package/dist/dist-BvsCdwbL.cjs +1 -0
  22. package/dist/dist-C0_uLrCb.cjs +6 -0
  23. package/dist/dist-C8jjSrIs.cjs +11 -0
  24. package/dist/dist-C9dtxVRR.cjs +1 -0
  25. package/dist/dist-CA6ERWRG.js +380 -0
  26. package/dist/dist-CHKg1Qb9.js +1583 -0
  27. package/dist/dist-CyFPTQ2l.cjs +1 -0
  28. package/dist/dist-D8I4FQ-Q.cjs +1 -0
  29. package/dist/dist-DEl2Ze0j.cjs +2 -0
  30. package/dist/dist-DJbgM591.cjs +1 -0
  31. package/dist/dist-DPXHxuWb.js +855 -0
  32. package/dist/dist-DZrtSp8H.js +607 -0
  33. package/dist/dist-Dja2VlN5.cjs +1 -0
  34. package/dist/dist-DqbI0un6.cjs +1 -0
  35. package/dist/dist-Dr4zY56l.js +440 -0
  36. package/dist/dist-Dvqp7T4I.cjs +1 -0
  37. package/dist/dist-FSzij9Rn.js +271 -0
  38. package/dist/dist-Xjm88mbq.js +756 -0
  39. package/dist/dist-qNFo_ASR.cjs +9 -0
  40. package/dist/dist-qq9a_ch2.js +431 -0
  41. package/dist/dockerfile-4x0UkDoN.js +291 -0
  42. package/dist/dockerfile-C67wRfne.cjs +1 -0
  43. package/dist/docxExport-BKC_hi5D.js +67 -0
  44. package/dist/docxExport-V7joLrkm.cjs +3 -0
  45. package/dist/{docxExport-BWwEuboU.js → loadReferencedImage-FGse7G4p.js} +538 -306
  46. package/dist/{docxExport-PjDC4XKL.cjs → loadReferencedImage-QespeGh9.cjs} +7 -9
  47. package/dist/pi-outpost-embed.cjs +51 -24
  48. package/dist/pi-outpost-embed.js +3026 -2743
  49. package/dist/properties-C85NeSsH.js +20 -0
  50. package/dist/properties-XjDvZYDm.cjs +1 -0
  51. package/dist/ruby-Bx72aP7E.cjs +1 -0
  52. package/dist/ruby-CjYBP7RB.js +166 -0
  53. package/dist/shell-CD1ADQh5.cjs +1 -0
  54. package/dist/shell-CevoiH_y.js +109 -0
  55. package/dist/toml-CPJF62TK.js +28 -0
  56. package/dist/toml-OuUxin0A.cjs +1 -0
  57. package/package.json +1 -1
  58. package/dist/loadReferencedImage-C8Hn2ejN.js +0 -268
  59. package/dist/loadReferencedImage-q-G47ESL.cjs +0 -1
@@ -0,0 +1,2790 @@
1
+ import { n as e } from "./rolldown-runtime-DArdT4gl.js";
2
+ import { $ as t, A as n, B as r, C as i, E as a, F as o, G as s, H as c, I as l, J as u, K as d, L as f, M as p, N as m, O as ee, P as h, Q as g, R as _, S as te, U as ne, V as re, W as ie, X as v, Y as ae, Z as oe, at as y, b as se, c as ce, ct as le, dt as ue, et as b, ft as de, g as fe, gt as pe, it as me, j as he, k as x, lt as S, m as ge, mt as _e, nt as ve, ot as C, pt as w, q as ye, rt as be, s as xe, st as Se, t as Ce, tt as we, ut as T, w as E, xt as Te, y as Ee, z as De } from "./dist-BhXQJ0x3.js";
3
+ import { useEffect as Oe, useImperativeHandle as ke, useRef as Ae } from "react";
4
+ import { jsx as je } from "react/jsx-runtime";
5
+ //#region ../node_modules/@codemirror/autocomplete/dist/index.js
6
+ var Me = class {
7
+ constructor(e, t, n, r) {
8
+ this.state = e, this.pos = t, this.explicit = n, this.view = r, this.abortListeners = [], this.abortOnDocChange = !1;
9
+ }
10
+ tokenBefore(e) {
11
+ let t = x(this.state).resolveInner(this.pos, -1);
12
+ for (; t && e.indexOf(t.name) < 0;) t = t.parent;
13
+ return t ? {
14
+ from: t.from,
15
+ to: this.pos,
16
+ text: this.state.sliceDoc(t.from, this.pos),
17
+ type: t.type
18
+ } : null;
19
+ }
20
+ matchBefore(e) {
21
+ let t = this.state.doc.lineAt(this.pos), n = Math.max(t.from, this.pos - 250), r = t.text.slice(n - t.from, this.pos - t.from), i = r.search(Re(e, !1));
22
+ return i < 0 ? null : {
23
+ from: n + i,
24
+ to: this.pos,
25
+ text: r.slice(i)
26
+ };
27
+ }
28
+ get aborted() {
29
+ return this.abortListeners == null;
30
+ }
31
+ addEventListener(e, t, n) {
32
+ e == "abort" && this.abortListeners && (this.abortListeners.push(t), n && n.onDocChange && (this.abortOnDocChange = !0));
33
+ }
34
+ };
35
+ function Ne(e) {
36
+ let t = Object.keys(e).join(""), n = /\w/.test(t);
37
+ return n && (t = t.replace(/\w/g, "")), `[${n ? "\\w" : ""}${t.replace(/[^\w\s]/g, "\\$&")}]`;
38
+ }
39
+ function Pe(e) {
40
+ let t = Object.create(null), n = Object.create(null);
41
+ for (let { label: r } of e) {
42
+ t[r[0]] = !0;
43
+ for (let e = 1; e < r.length; e++) n[r[e]] = !0;
44
+ }
45
+ let r = Ne(t) + Ne(n) + "*$";
46
+ return [RegExp("^" + r), new RegExp(r)];
47
+ }
48
+ function Fe(e) {
49
+ let t = e.map((e) => typeof e == "string" ? { label: e } : e), [n, r] = t.every((e) => /^\w+$/.test(e.label)) ? [/\w*$/, /\w+$/] : Pe(t);
50
+ return (e) => {
51
+ let i = e.matchBefore(r);
52
+ return i || e.explicit ? {
53
+ from: i ? i.from : e.pos,
54
+ options: t,
55
+ validFor: n
56
+ } : null;
57
+ };
58
+ }
59
+ function Ie(e, t) {
60
+ return (n) => {
61
+ for (let t = x(n.state).resolveInner(n.pos, -1); t; t = t.parent) {
62
+ if (e.indexOf(t.name) > -1) return null;
63
+ if (t.type.isTop) break;
64
+ }
65
+ return t(n);
66
+ };
67
+ }
68
+ var Le = class {
69
+ constructor(e, t, n, r) {
70
+ this.completion = e, this.source = t, this.match = n, this.score = r;
71
+ }
72
+ };
73
+ function D(e) {
74
+ return e.selection.main.from;
75
+ }
76
+ function Re(e, t) {
77
+ let { source: n } = e, r = t && n[0] != "^", i = n[n.length - 1] != "$";
78
+ return !r && !i ? e : RegExp(`${r ? "^" : ""}(?:${n})${i ? "$" : ""}`, e.flags ?? (e.ignoreCase ? "i" : ""));
79
+ }
80
+ var ze = /*@__PURE__*/ ye.define();
81
+ function Be(e, t, n, r) {
82
+ let { main: i } = e.selection, a = n - i.from, o = r - i.from;
83
+ return {
84
+ ...e.changeByRange((s) => {
85
+ if (s != i && n != r && e.sliceDoc(s.from + a, s.from + o) != e.sliceDoc(n, r)) return { range: s };
86
+ let c = e.toText(t);
87
+ return {
88
+ changes: {
89
+ from: s.from + a,
90
+ to: r == i.from ? s.to : s.from + o,
91
+ insert: c
92
+ },
93
+ range: g.cursor(s.from + a + c.length)
94
+ };
95
+ }),
96
+ scrollIntoView: !0,
97
+ userEvent: "input.complete"
98
+ };
99
+ }
100
+ var Ve = /*@__PURE__*/ new WeakMap();
101
+ function He(e) {
102
+ if (!Array.isArray(e)) return e;
103
+ let t = Ve.get(e);
104
+ return t || Ve.set(e, t = Fe(e)), t;
105
+ }
106
+ var Ue = /*@__PURE__*/ y.define(), O = /*@__PURE__*/ y.define(), We = class {
107
+ constructor(e) {
108
+ this.pattern = e, this.chars = [], this.folded = [], this.any = [], this.precise = [], this.byWord = [], this.score = 0, this.matched = [];
109
+ for (let t = 0; t < e.length;) {
110
+ let n = S(e, t), r = T(n);
111
+ this.chars.push(n);
112
+ let i = e.slice(t, t + r), a = i.toUpperCase();
113
+ this.folded.push(S(a == i ? i.toLowerCase() : a, 0)), t += r;
114
+ }
115
+ this.astral = e.length != this.chars.length;
116
+ }
117
+ ret(e, t) {
118
+ return this.score = e, this.matched = t, this;
119
+ }
120
+ match(e) {
121
+ if (this.pattern.length == 0) return this.ret(-100, []);
122
+ if (e.length < this.pattern.length) return null;
123
+ let { chars: t, folded: n, any: r, precise: i, byWord: a } = this;
124
+ if (t.length == 1) {
125
+ let r = S(e, 0), i = T(r), a = i == e.length ? 0 : -100;
126
+ if (r != t[0]) {
127
+ if (r == n[0]) a += -200;
128
+ else return null;
129
+ }
130
+ return this.ret(a, [0, i]);
131
+ }
132
+ let o = e.indexOf(this.pattern);
133
+ if (o == 0) return this.ret(e.length == this.pattern.length ? 0 : -100, [0, this.pattern.length]);
134
+ let s = t.length, c = 0;
135
+ if (o < 0) {
136
+ for (let i = 0, a = Math.min(e.length, 200); i < a && c < s;) {
137
+ let a = S(e, i);
138
+ (a == t[c] || a == n[c]) && (r[c++] = i), i += T(a);
139
+ }
140
+ if (c < s) return null;
141
+ }
142
+ let l = 0, u = 0, d = !1, f = 0, p = -1, m = -1, ee = /[a-z]/.test(e), h = !0;
143
+ for (let r = 0, c = Math.min(e.length, 200), g = 0; r < c && u < s;) {
144
+ let c = S(e, r);
145
+ o < 0 && (l < s && c == t[l] && (i[l++] = r), f < s && (c == t[f] || c == n[f] ? (f == 0 && (p = r), m = r + 1, f++) : f = 0));
146
+ let _, te = c < 255 ? c >= 48 && c <= 57 || c >= 97 && c <= 122 ? 2 : +(c >= 65 && c <= 90) : (_ = _e(c)) == _.toLowerCase() ? _ == _.toUpperCase() ? 0 : 2 : 1;
147
+ (!r || te == 1 && ee || g == 0 && te != 0) && (t[u] == c || n[u] == c && (d = !0) ? a[u++] = r : a.length && (h = !1)), g = te, r += T(c);
148
+ }
149
+ return u == s && a[0] == 0 && h ? this.result(-100 + (d ? -200 : 0), a, e) : f == s && p == 0 ? this.ret(-200 - e.length + (m == e.length ? 0 : -100), [0, m]) : o > -1 ? this.ret(-700 - e.length, [o, o + this.pattern.length]) : f == s ? this.ret(-900 - e.length, [p, m]) : u == s ? this.result(-100 + (d ? -200 : 0) + -700 + (h ? 0 : -1100), a, e) : t.length == 2 ? null : this.result((r[0] ? -700 : 0) + -200 + -1100, r, e);
150
+ }
151
+ result(e, t, n) {
152
+ let r = [], i = 0;
153
+ for (let e of t) {
154
+ let t = e + (this.astral ? T(S(n, e)) : 1);
155
+ i && r[i - 1] == e ? r[i - 1] = t : (r[i++] = e, r[i++] = t);
156
+ }
157
+ return this.ret(e - n.length, r);
158
+ }
159
+ }, Ge = class {
160
+ constructor(e) {
161
+ this.pattern = e, this.matched = [], this.score = 0, this.folded = e.toLowerCase();
162
+ }
163
+ match(e) {
164
+ if (e.length < this.pattern.length) return null;
165
+ let t = e.slice(0, this.pattern.length), n = t == this.pattern ? 0 : t.toLowerCase() == this.folded ? -200 : null;
166
+ return n == null ? null : (this.matched = [0, t.length], this.score = n + (e.length == this.pattern.length ? 0 : -100), this);
167
+ }
168
+ }, k = /*@__PURE__*/ b.define({ combine(e) {
169
+ return ue(e, {
170
+ activateOnTyping: !0,
171
+ activateOnCompletion: () => !1,
172
+ activateOnTypingDelay: 100,
173
+ selectOnOpen: !0,
174
+ override: null,
175
+ closeOnBlur: !0,
176
+ maxRenderedOptions: 100,
177
+ defaultKeymap: !0,
178
+ tooltipClass: () => "",
179
+ optionClass: () => "",
180
+ aboveCursor: !1,
181
+ icons: !0,
182
+ addToOptions: [],
183
+ positionInfo: qe,
184
+ filterStrict: !1,
185
+ compareCompletions: (e, t) => (e.sortText || e.label).localeCompare(t.sortText || t.label),
186
+ interactionDelay: 75,
187
+ updateSyncTime: 100
188
+ }, {
189
+ defaultKeymap: (e, t) => e && t,
190
+ closeOnBlur: (e, t) => e && t,
191
+ icons: (e, t) => e && t,
192
+ tooltipClass: (e, t) => (n) => Ke(e(n), t(n)),
193
+ optionClass: (e, t) => (n) => Ke(e(n), t(n)),
194
+ addToOptions: (e, t) => e.concat(t),
195
+ filterStrict: (e, t) => e || t
196
+ });
197
+ } });
198
+ function Ke(e, t) {
199
+ return e ? t ? e + " " + t : e : t;
200
+ }
201
+ function qe(e, t, n, r, i, a) {
202
+ let o = e.textDirection == he.RTL, s = o, c = !1, l = "top", u, d, f = t.left - i.left, p = i.right - t.right, m = r.right - r.left, ee = r.bottom - r.top;
203
+ if (s && f < Math.min(m, p) ? s = !1 : !s && p < Math.min(m, f) && (s = !0), m <= (s ? f : p)) u = Math.max(i.top, Math.min(n.top, i.bottom - ee)) - t.top, d = Math.min(400, s ? f : p);
204
+ else {
205
+ c = !0, d = Math.min(400, (o ? t.right : i.right - t.left) - 30);
206
+ let e = i.bottom - t.bottom;
207
+ e >= ee || e > t.top ? u = n.bottom - t.top : (l = "bottom", u = t.bottom - n.top);
208
+ }
209
+ let h = (t.bottom - t.top) / a.offsetHeight, g = (t.right - t.left) / a.offsetWidth;
210
+ return {
211
+ style: `${l}: ${u / h}px; max-width: ${d / g}px`,
212
+ class: "cm-completionInfo-" + (c ? o ? "left-narrow" : "right-narrow" : s ? "left" : "right")
213
+ };
214
+ }
215
+ var Je = /*@__PURE__*/ y.define();
216
+ function Ye(e) {
217
+ let t = e.addToOptions.slice();
218
+ return e.icons && t.push({
219
+ render(e) {
220
+ let t = document.createElement("div");
221
+ return t.classList.add("cm-completionIcon"), e.type && t.classList.add(...e.type.split(/\s+/g).map((e) => "cm-completionIcon-" + e)), t.setAttribute("aria-hidden", "true"), t;
222
+ },
223
+ position: 20
224
+ }), t.push({
225
+ render(e, t, n, r) {
226
+ let i = document.createElement("span");
227
+ i.className = "cm-completionLabel";
228
+ let a = e.displayLabel || e.label, o = 0;
229
+ for (let e = 0; e < r.length;) {
230
+ let t = r[e++], n = r[e++];
231
+ t > o && i.appendChild(document.createTextNode(a.slice(o, t)));
232
+ let s = i.appendChild(document.createElement("span"));
233
+ s.appendChild(document.createTextNode(a.slice(t, n))), s.className = "cm-completionMatchedText", o = n;
234
+ }
235
+ return o < a.length && i.appendChild(document.createTextNode(a.slice(o))), i;
236
+ },
237
+ position: 50
238
+ }, {
239
+ render(e) {
240
+ if (!e.detail) return null;
241
+ let t = document.createElement("span");
242
+ return t.className = "cm-completionDetail", t.textContent = e.detail, t;
243
+ },
244
+ position: 80
245
+ }), t.sort((e, t) => e.position - t.position).map((e) => e.render);
246
+ }
247
+ function Xe(e, t, n) {
248
+ if (e <= n) return {
249
+ from: 0,
250
+ to: e
251
+ };
252
+ if (t < 0 && (t = 0), t <= e >> 1) {
253
+ let e = Math.floor(t / n);
254
+ return {
255
+ from: e * n,
256
+ to: (e + 1) * n
257
+ };
258
+ }
259
+ let r = Math.ceil((e - t) / n);
260
+ return {
261
+ from: e - r * n,
262
+ to: e - (r - 1) * n
263
+ };
264
+ }
265
+ var Ze = class {
266
+ constructor(e, t, n) {
267
+ this.view = e, this.stateField = t, this.applyCompletion = n, this.info = null, this.infoDestroy = null, this.placeInfoReq = {
268
+ read: () => this.measureInfo(),
269
+ write: (e) => this.placeInfo(e),
270
+ key: this
271
+ }, this.space = null, this.currentClass = "";
272
+ let r = e.state.field(t), { options: i, selected: a } = r.open, o = e.state.facet(k);
273
+ this.optionContent = Ye(o), this.optionClass = o.optionClass, this.tooltipClass = o.tooltipClass, this.range = Xe(i.length, a, o.maxRenderedOptions), this.dom = document.createElement("div"), this.dom.className = "cm-tooltip-autocomplete", this.updateTooltipClass(e.state), this.dom.addEventListener("mousedown", (n) => {
274
+ let { options: r } = e.state.field(t).open;
275
+ for (let t = n.target, i; t && t != this.dom; t = t.parentNode) if (t.nodeName == "LI" && (i = /-(\d+)$/.exec(t.id)) && +i[1] < r.length) {
276
+ this.applyCompletion(e, r[+i[1]]), n.preventDefault();
277
+ return;
278
+ }
279
+ if (n.target == this.list) {
280
+ let t = this.list.classList.contains("cm-completionListIncompleteTop") && n.clientY < this.list.firstChild.getBoundingClientRect().top ? this.range.from - 1 : this.list.classList.contains("cm-completionListIncompleteBottom") && n.clientY > this.list.lastChild.getBoundingClientRect().bottom ? this.range.to : null;
281
+ t != null && (e.dispatch({ effects: Je.of(t) }), n.preventDefault());
282
+ }
283
+ }), this.dom.addEventListener("focusout", (t) => {
284
+ let n = e.state.field(this.stateField, !1);
285
+ n && n.tooltip && e.state.facet(k).closeOnBlur && t.relatedTarget != e.contentDOM && e.dispatch({ effects: O.of(null) });
286
+ }), this.showOptions(i, r.id);
287
+ }
288
+ mount() {
289
+ this.updateSel();
290
+ }
291
+ showOptions(e, t) {
292
+ this.list && this.list.remove(), this.list = this.dom.appendChild(this.createListBox(e, t, this.range)), this.list.addEventListener("scroll", () => {
293
+ this.info && this.view.requestMeasure(this.placeInfoReq);
294
+ });
295
+ }
296
+ update(e) {
297
+ let t = e.state.field(this.stateField), n = e.startState.field(this.stateField);
298
+ if (this.updateTooltipClass(e.state), t != n) {
299
+ let { options: r, selected: i, disabled: a } = t.open;
300
+ (!n.open || n.open.options != r) && (this.range = Xe(r.length, i, e.state.facet(k).maxRenderedOptions), this.showOptions(r, t.id)), this.updateSel(), a != n.open?.disabled && this.dom.classList.toggle("cm-tooltip-autocomplete-disabled", !!a);
301
+ }
302
+ }
303
+ updateTooltipClass(e) {
304
+ let t = this.tooltipClass(e);
305
+ if (t != this.currentClass) {
306
+ for (let e of this.currentClass.split(" ")) e && this.dom.classList.remove(e);
307
+ for (let e of t.split(" ")) e && this.dom.classList.add(e);
308
+ this.currentClass = t;
309
+ }
310
+ }
311
+ positioned(e) {
312
+ this.space = e, this.info && this.view.requestMeasure(this.placeInfoReq);
313
+ }
314
+ updateSel() {
315
+ let e = this.view.state.field(this.stateField), t = e.open;
316
+ (t.selected > -1 && t.selected < this.range.from || t.selected >= this.range.to) && (this.range = Xe(t.options.length, t.selected, this.view.state.facet(k).maxRenderedOptions), this.showOptions(t.options, e.id));
317
+ let n = this.updateSelectedOption(t.selected);
318
+ if (n) {
319
+ this.destroyInfo();
320
+ let { completion: r } = t.options[t.selected], { info: i } = r;
321
+ if (!i) return;
322
+ let a = typeof i == "string" ? document.createTextNode(i) : i(r);
323
+ if (!a) return;
324
+ "then" in a ? a.then((t) => {
325
+ t && this.view.state.field(this.stateField, !1) == e && this.addInfoPane(t, r);
326
+ }).catch((e) => ie(this.view.state, e, "completion info")) : (this.addInfoPane(a, r), n.setAttribute("aria-describedby", this.info.id));
327
+ }
328
+ }
329
+ addInfoPane(e, t) {
330
+ this.destroyInfo();
331
+ let n = this.info = document.createElement("div");
332
+ if (n.className = "cm-tooltip cm-completionInfo", n.id = "cm-completionInfo-" + Math.floor(Math.random() * 65535).toString(16), e.nodeType != null) n.appendChild(e), this.infoDestroy = null;
333
+ else {
334
+ let { dom: t, destroy: r } = e;
335
+ n.appendChild(t), this.infoDestroy = r || null;
336
+ }
337
+ this.dom.appendChild(n), this.view.requestMeasure(this.placeInfoReq);
338
+ }
339
+ updateSelectedOption(e) {
340
+ let t = null;
341
+ for (let n = this.list.firstChild, r = this.range.from; n; n = n.nextSibling, r++) n.nodeName != "LI" || !n.id ? r-- : r == e ? n.hasAttribute("aria-selected") || (n.setAttribute("aria-selected", "true"), t = n) : n.hasAttribute("aria-selected") && (n.removeAttribute("aria-selected"), n.removeAttribute("aria-describedby"));
342
+ return t && $e(this.list, t), t;
343
+ }
344
+ measureInfo() {
345
+ let e = this.dom.querySelector("[aria-selected]");
346
+ if (!e || !this.info) return null;
347
+ let t = this.dom.getBoundingClientRect(), n = this.info.getBoundingClientRect(), r = e.getBoundingClientRect(), i = this.space;
348
+ if (!i) {
349
+ let e = this.dom.ownerDocument.documentElement;
350
+ i = {
351
+ left: 0,
352
+ top: 0,
353
+ right: e.clientWidth,
354
+ bottom: e.clientHeight
355
+ };
356
+ }
357
+ return r.top > Math.min(i.bottom, t.bottom) - 10 || r.bottom < Math.max(i.top, t.top) + 10 ? null : this.view.state.facet(k).positionInfo(this.view, t, r, n, i, this.dom);
358
+ }
359
+ placeInfo(e) {
360
+ this.info && (e ? (e.style && (this.info.style.cssText = e.style), this.info.className = "cm-tooltip cm-completionInfo " + (e.class || "")) : this.info.style.cssText = "top: -1e6px");
361
+ }
362
+ createListBox(e, t, n) {
363
+ let r = document.createElement("ul");
364
+ r.id = t, r.setAttribute("role", "listbox"), r.setAttribute("aria-expanded", "true"), r.setAttribute("aria-label", this.view.state.phrase("Completions")), r.addEventListener("mousedown", (e) => {
365
+ e.target == r && e.preventDefault();
366
+ });
367
+ let i = null;
368
+ for (let a = n.from; a < n.to; a++) {
369
+ let { completion: o, match: s } = e[a], { section: c } = o;
370
+ if (c) {
371
+ let e = typeof c == "string" ? c : c.name;
372
+ if (e != i && (a > n.from || n.from == 0)) {
373
+ if (i = e, typeof c != "string" && c.header) r.appendChild(c.header(c));
374
+ else {
375
+ let t = r.appendChild(document.createElement("completion-section"));
376
+ t.textContent = e;
377
+ }
378
+ }
379
+ }
380
+ let l = r.appendChild(document.createElement("li"));
381
+ l.id = t + "-" + a, l.setAttribute("role", "option");
382
+ let u = this.optionClass(o);
383
+ u && (l.className = u);
384
+ for (let e of this.optionContent) {
385
+ let t = e(o, this.view.state, this.view, s);
386
+ t && l.appendChild(t);
387
+ }
388
+ }
389
+ return n.from && r.classList.add("cm-completionListIncompleteTop"), n.to < e.length && r.classList.add("cm-completionListIncompleteBottom"), r;
390
+ }
391
+ destroyInfo() {
392
+ this.info &&= (this.infoDestroy && this.infoDestroy(), this.info.remove(), null);
393
+ }
394
+ destroy() {
395
+ this.destroyInfo();
396
+ }
397
+ };
398
+ function Qe(e, t) {
399
+ return (n) => new Ze(n, e, t);
400
+ }
401
+ function $e(e, t) {
402
+ let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = n.height / e.offsetHeight;
403
+ r.top < n.top ? e.scrollTop -= (n.top - r.top) / i : r.bottom > n.bottom && (e.scrollTop += (r.bottom - n.bottom) / i);
404
+ }
405
+ function et(e) {
406
+ return (e.boost || 0) * 100 + (e.apply ? 10 : 0) + (e.info ? 5 : 0) + +!!e.type;
407
+ }
408
+ function tt(e, t) {
409
+ let n = [], r = null, i = null, a = (e) => {
410
+ n.push(e);
411
+ let { section: t } = e.completion;
412
+ if (t) {
413
+ r ||= [];
414
+ let e = typeof t == "string" ? t : t.name;
415
+ r.some((t) => t.name == e) || r.push(typeof t == "string" ? { name: e } : t);
416
+ }
417
+ }, o = t.facet(k);
418
+ for (let r of e) if (r.hasResult()) {
419
+ let e = r.result.getMatch;
420
+ if (r.result.filter === !1) for (let t of r.result.options) a(new Le(t, r.source, e ? e(t) : [], 1e9 - n.length));
421
+ else {
422
+ let n = t.sliceDoc(r.from, r.to), s, c = o.filterStrict ? new Ge(n) : new We(n);
423
+ for (let t of r.result.options) if (s = c.match(t.label)) {
424
+ let n = t.displayLabel ? e ? e(t, s.matched) : [] : s.matched, o = s.score + (t.boost || 0);
425
+ if (a(new Le(t, r.source, n, o)), typeof t.section == "object" && t.section.rank === "dynamic") {
426
+ let { name: e } = t.section;
427
+ i ||= Object.create(null), i[e] = Math.max(o, i[e] || -1e9);
428
+ }
429
+ }
430
+ }
431
+ }
432
+ if (r) {
433
+ let e = Object.create(null), t = 0, a = (e, t) => (e.rank === "dynamic" && t.rank === "dynamic" ? i[t.name] - i[e.name] : 0) || (typeof e.rank == "number" ? e.rank : 1e9) - (typeof t.rank == "number" ? t.rank : 1e9) || (e.name < t.name ? -1 : 1);
434
+ for (let n of r.sort(a)) t -= 1e5, e[n.name] = t;
435
+ for (let t of n) {
436
+ let { section: n } = t.completion;
437
+ n && (t.score += e[typeof n == "string" ? n : n.name]);
438
+ }
439
+ }
440
+ let s = [], c = null, l = o.compareCompletions;
441
+ for (let e of n.sort((e, t) => t.score - e.score || l(e.completion, t.completion))) {
442
+ let t = e.completion;
443
+ !c || c.label != t.label || c.detail != t.detail || c.type != null && t.type != null && c.type != t.type || c.apply != t.apply || c.boost != t.boost ? s.push(e) : et(e.completion) > et(c) && (s[s.length - 1] = e), c = e.completion;
444
+ }
445
+ return s;
446
+ }
447
+ var nt = class e {
448
+ constructor(e, t, n, r, i, a) {
449
+ this.options = e, this.attrs = t, this.tooltip = n, this.timestamp = r, this.selected = i, this.disabled = a;
450
+ }
451
+ setSelected(t, n) {
452
+ return t == this.selected || t >= this.options.length ? this : new e(this.options, st(n, t), this.tooltip, this.timestamp, t, this.disabled);
453
+ }
454
+ static build(t, n, r, i, a, o) {
455
+ if (i && !o && t.some((e) => e.isPending)) return i.setDisabled();
456
+ let s = tt(t, n);
457
+ if (!s.length) return i && t.some((e) => e.isPending) ? i.setDisabled() : null;
458
+ let c = n.facet(k).selectOnOpen ? 0 : -1;
459
+ if (i && i.selected != c && i.selected != -1) {
460
+ let e = i.options[i.selected].completion;
461
+ for (let t = 0; t < s.length; t++) if (s[t].completion == e) {
462
+ c = t;
463
+ break;
464
+ }
465
+ }
466
+ return new e(s, st(r, c), {
467
+ pos: t.reduce((e, t) => t.hasResult() ? Math.min(e, t.from) : e, 1e8),
468
+ create: mt,
469
+ above: a.aboveCursor
470
+ }, i ? i.timestamp : Date.now(), c, !1);
471
+ }
472
+ map(t) {
473
+ return new e(this.options, this.attrs, {
474
+ ...this.tooltip,
475
+ pos: t.mapPos(this.tooltip.pos)
476
+ }, this.timestamp, this.selected, this.disabled);
477
+ }
478
+ setDisabled() {
479
+ return new e(this.options, this.attrs, this.tooltip, this.timestamp, this.selected, !0);
480
+ }
481
+ }, rt = class e {
482
+ constructor(e, t, n) {
483
+ this.active = e, this.id = t, this.open = n;
484
+ }
485
+ static start() {
486
+ return new e(ct, "cm-ac-" + Math.floor(Math.random() * 2e6).toString(36), null);
487
+ }
488
+ update(t) {
489
+ let { state: n } = t, r = n.facet(k), i = (r.override || n.languageDataAt("autocomplete", D(n)).map(He)).map((e) => (this.active.find((t) => t.source == e) || new A(e, +!!this.active.some((e) => e.state != 0))).update(t, r));
490
+ i.length == this.active.length && i.every((e, t) => e == this.active[t]) && (i = this.active);
491
+ let a = this.open, o = t.effects.some((e) => e.is(ft));
492
+ a && t.docChanged && (a = a.map(t.changes)), t.selection || i.some((e) => e.hasResult() && t.changes.touchesRange(e.from, e.to)) || !it(i, this.active) || o ? a = nt.build(i, n, this.id, a, r, o) : a && a.disabled && !i.some((e) => e.isPending) && (a = null), !a && i.every((e) => !e.isPending) && i.some((e) => e.hasResult()) && (i = i.map((e) => e.hasResult() ? new A(e.source, 0) : e));
493
+ for (let e of t.effects) e.is(Je) && (a &&= a.setSelected(e.value, this.id));
494
+ return i == this.active && a == this.open ? this : new e(i, this.id, a);
495
+ }
496
+ get tooltip() {
497
+ return this.open ? this.open.tooltip : null;
498
+ }
499
+ get attrs() {
500
+ return this.open ? this.open.attrs : this.active.length ? at : ot;
501
+ }
502
+ };
503
+ function it(e, t) {
504
+ if (e == t) return !0;
505
+ for (let n = 0, r = 0;;) {
506
+ for (; n < e.length && !e[n].hasResult();) n++;
507
+ for (; r < t.length && !t[r].hasResult();) r++;
508
+ let i = n == e.length, a = r == t.length;
509
+ if (i || a) return i == a;
510
+ if (e[n++].result != t[r++].result) return !1;
511
+ }
512
+ }
513
+ var at = { "aria-autocomplete": "list" }, ot = {};
514
+ function st(e, t) {
515
+ let n = {
516
+ "aria-autocomplete": "list",
517
+ "aria-haspopup": "listbox",
518
+ "aria-controls": e
519
+ };
520
+ return t > -1 && (n["aria-activedescendant"] = e + "-" + t), n;
521
+ }
522
+ var ct = [];
523
+ function lt(e, t) {
524
+ if (e.isUserEvent("input.complete")) {
525
+ let n = e.annotation(ze);
526
+ if (n && t.activateOnCompletion(n)) return 12;
527
+ }
528
+ let n = e.isUserEvent("input.type");
529
+ return n && t.activateOnTyping ? 5 : n ? 1 : e.isUserEvent("delete.backward") ? 2 : e.selection ? 8 : e.docChanged ? 16 : 0;
530
+ }
531
+ var A = class e {
532
+ constructor(e, t, n = !1) {
533
+ this.source = e, this.state = t, this.explicit = n;
534
+ }
535
+ hasResult() {
536
+ return !1;
537
+ }
538
+ get isPending() {
539
+ return this.state == 1;
540
+ }
541
+ update(t, n) {
542
+ let r = lt(t, n), i = this;
543
+ (r & 8 || r & 16 && this.touches(t)) && (i = new e(i.source, 0)), r & 4 && i.state == 0 && (i = new e(this.source, 1)), i = i.updateFor(t, r);
544
+ for (let n of t.effects) if (n.is(Ue)) i = new e(i.source, 1, n.value);
545
+ else if (n.is(O)) i = new e(i.source, 0);
546
+ else if (n.is(ft)) for (let e of n.value) e.source == i.source && (i = e);
547
+ return i;
548
+ }
549
+ updateFor(e, t) {
550
+ return this.map(e.changes);
551
+ }
552
+ map(e) {
553
+ return this;
554
+ }
555
+ touches(e) {
556
+ return e.changes.touchesRange(D(e.state));
557
+ }
558
+ }, ut = class e extends A {
559
+ constructor(e, t, n, r, i, a) {
560
+ super(e, 3, t), this.limit = n, this.result = r, this.from = i, this.to = a;
561
+ }
562
+ hasResult() {
563
+ return !0;
564
+ }
565
+ updateFor(t, n) {
566
+ if (!(n & 3)) return this.map(t.changes);
567
+ let r = this.result;
568
+ r.map && !t.changes.empty && (r = r.map(r, t.changes));
569
+ let i = t.changes.mapPos(this.from), a = t.changes.mapPos(this.to, 1), o = D(t.state);
570
+ if (o > a || !r || n & 2 && (D(t.startState) == this.from || o < this.limit)) return new A(this.source, n & 4 ? 1 : 0);
571
+ let s = t.changes.mapPos(this.limit);
572
+ return dt(r.validFor, t.state, i, a) ? new e(this.source, this.explicit, s, r, i, a) : r.update && (r = r.update(r, i, a, new Me(t.state, o, !1))) ? new e(this.source, this.explicit, s, r, r.from, r.to ?? D(t.state)) : new A(this.source, 1, this.explicit);
573
+ }
574
+ map(t) {
575
+ if (t.empty) return this;
576
+ let n = this.result.map ? this.result.map(this.result, t) : this.result;
577
+ return n ? new e(this.source, this.explicit, t.mapPos(this.limit), n, t.mapPos(this.from), t.mapPos(this.to, 1)) : new A(this.source, 0);
578
+ }
579
+ touches(e) {
580
+ return e.changes.touchesRange(this.from, this.to);
581
+ }
582
+ };
583
+ function dt(e, t, n, r) {
584
+ if (!e) return !1;
585
+ let i = t.sliceDoc(n, r);
586
+ return typeof e == "function" ? e(i, n, r, t) : Re(e, !0).test(i);
587
+ }
588
+ var ft = /*@__PURE__*/ y.define({ map(e, t) {
589
+ return e.map((e) => e.map(t));
590
+ } }), j = /*@__PURE__*/ C.define({
591
+ create() {
592
+ return rt.start();
593
+ },
594
+ update(e, t) {
595
+ return e.update(t);
596
+ },
597
+ provide: (e) => [d.from(e, (e) => e.tooltip), p.contentAttributes.from(e, (e) => e.attrs)]
598
+ });
599
+ function pt(e, t) {
600
+ let n = t.completion.apply || t.completion.label, r = e.state.field(j).active.find((e) => e.source == t.source);
601
+ return r instanceof ut && (typeof n == "string" ? e.dispatch({
602
+ ...Be(e.state, n, r.from, r.to),
603
+ annotations: ze.of(t.completion)
604
+ }) : n(e, t.completion, r.from, r.to), !0);
605
+ }
606
+ var mt = /*@__PURE__*/ Qe(j, pt);
607
+ function ht(e, t = "option") {
608
+ return (n) => {
609
+ let r = n.state.field(j, !1);
610
+ if (!r || !r.open || r.open.disabled || Date.now() - r.open.timestamp < n.state.facet(k).interactionDelay) return !1;
611
+ let i = 1, a;
612
+ t == "page" && (a = _(n, r.open.tooltip)) && (i = Math.max(2, Math.floor(a.dom.offsetHeight / a.dom.querySelector("li").offsetHeight) - 1));
613
+ let { length: o } = r.open.options, s = r.open.selected > -1 ? r.open.selected + i * (e ? 1 : -1) : e ? 0 : o - 1;
614
+ return s < 0 ? s = t == "page" ? 0 : o - 1 : s >= o && (s = t == "page" ? o - 1 : 0), n.dispatch({ effects: Je.of(s) }), !0;
615
+ };
616
+ }
617
+ var gt = (e) => {
618
+ let t = e.state.field(j, !1);
619
+ return e.state.readOnly || !t || !t.open || t.open.selected < 0 || t.open.disabled || Date.now() - t.open.timestamp < e.state.facet(k).interactionDelay ? !1 : pt(e, t.open.options[t.open.selected]);
620
+ }, _t = (e) => e.state.field(j, !1) ? (e.dispatch({ effects: Ue.of(!0) }), !0) : !1, vt = (e) => {
621
+ let t = e.state.field(j, !1);
622
+ return !t || !t.active.some((e) => e.state != 0) ? !1 : (e.dispatch({ effects: O.of(null) }), !0);
623
+ }, yt = class {
624
+ constructor(e, t) {
625
+ this.active = e, this.context = t, this.time = Date.now(), this.updates = [], this.done = void 0;
626
+ }
627
+ }, bt = 50, xt = 1e3, St = /*@__PURE__*/ m.fromClass(class {
628
+ constructor(e) {
629
+ this.view = e, this.debounceUpdate = -1, this.running = [], this.debounceAccept = -1, this.pendingStart = !1, this.composing = 0;
630
+ for (let t of e.state.field(j).active) t.isPending && this.startQuery(t);
631
+ }
632
+ update(e) {
633
+ let t = e.state.field(j), n = e.state.facet(k);
634
+ if (!e.selectionSet && !e.docChanged && e.startState.field(j) == t) return;
635
+ let r = e.transactions.some((e) => {
636
+ let t = lt(e, n);
637
+ return t & 8 || (e.selection || e.docChanged) && !(t & 3);
638
+ });
639
+ for (let t = 0; t < this.running.length; t++) {
640
+ let n = this.running[t];
641
+ if (r || n.context.abortOnDocChange && e.docChanged || n.updates.length + e.transactions.length > bt && Date.now() - n.time > xt) {
642
+ for (let e of n.context.abortListeners) try {
643
+ e();
644
+ } catch (e) {
645
+ ie(this.view.state, e);
646
+ }
647
+ n.context.abortListeners = null, this.running.splice(t--, 1);
648
+ } else n.updates.push(...e.transactions);
649
+ }
650
+ this.debounceUpdate > -1 && clearTimeout(this.debounceUpdate), e.transactions.some((e) => e.effects.some((e) => e.is(Ue))) && (this.pendingStart = !0);
651
+ let i = this.pendingStart ? 50 : n.activateOnTypingDelay;
652
+ if (this.debounceUpdate = t.active.some((e) => e.isPending && !this.running.some((t) => t.active.source == e.source)) ? setTimeout(() => this.startUpdate(), i) : -1, this.composing != 0) for (let t of e.transactions) t.isUserEvent("input.type") ? this.composing = 2 : this.composing == 2 && t.selection && (this.composing = 3);
653
+ }
654
+ startUpdate() {
655
+ this.debounceUpdate = -1, this.pendingStart = !1;
656
+ let { state: e } = this.view, t = e.field(j);
657
+ for (let e of t.active) e.isPending && !this.running.some((t) => t.active.source == e.source) && this.startQuery(e);
658
+ this.running.length && t.open && t.open.disabled && (this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(k).updateSyncTime));
659
+ }
660
+ startQuery(e) {
661
+ let { state: t } = this.view, n = new Me(t, D(t), e.explicit, this.view), r = new yt(e, n);
662
+ this.running.push(r), Promise.resolve(e.source(n)).then((e) => {
663
+ r.context.aborted || (r.done = e || null, this.scheduleAccept());
664
+ }, (e) => {
665
+ this.view.dispatch({ effects: O.of(null) }), ie(this.view.state, e);
666
+ });
667
+ }
668
+ scheduleAccept() {
669
+ this.running.every((e) => e.done !== void 0) ? this.accept() : this.debounceAccept < 0 && (this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(k).updateSyncTime));
670
+ }
671
+ accept() {
672
+ this.debounceAccept > -1 && clearTimeout(this.debounceAccept), this.debounceAccept = -1;
673
+ let e = [], t = this.view.state.facet(k), n = this.view.state.field(j);
674
+ for (let r = 0; r < this.running.length; r++) {
675
+ let i = this.running[r];
676
+ if (i.done === void 0) continue;
677
+ if (this.running.splice(r--, 1), i.done) {
678
+ let n = D(i.updates.length ? i.updates[0].startState : this.view.state), r = Math.min(n, i.done.from + +!i.active.explicit), a = new ut(i.active.source, i.active.explicit, r, i.done, i.done.from, i.done.to ?? n);
679
+ for (let e of i.updates) a = a.update(e, t);
680
+ if (a.hasResult()) {
681
+ e.push(a);
682
+ continue;
683
+ }
684
+ }
685
+ let a = n.active.find((e) => e.source == i.active.source);
686
+ if (a && a.isPending) {
687
+ if (i.done == null) {
688
+ let n = new A(i.active.source, 0);
689
+ for (let e of i.updates) n = n.update(e, t);
690
+ n.isPending || e.push(n);
691
+ } else this.startQuery(a);
692
+ }
693
+ }
694
+ (e.length || n.open && n.open.disabled) && this.view.dispatch({ effects: ft.of(e) });
695
+ }
696
+ }, { eventHandlers: {
697
+ blur(e) {
698
+ let t = this.view.state.field(j, !1);
699
+ if (t && t.tooltip && this.view.state.facet(k).closeOnBlur) {
700
+ let n = t.open && _(this.view, t.open.tooltip);
701
+ (!n || !n.dom.contains(e.relatedTarget)) && setTimeout(() => this.view.dispatch({ effects: O.of(null) }), 10);
702
+ }
703
+ },
704
+ compositionstart() {
705
+ this.composing = 1;
706
+ },
707
+ compositionend() {
708
+ this.composing == 3 && setTimeout(() => this.view.dispatch({ effects: Ue.of(!1) }), 20), this.composing = 0;
709
+ }
710
+ } }), Ct = typeof navigator == "object" && /*@__PURE__*/ /Win/.test(navigator.platform), wt = /*@__PURE__*/ ve.highest(/*@__PURE__*/ p.domEventHandlers({ keydown(e, t) {
711
+ let n = t.state.field(j, !1);
712
+ if (!n || !n.open || n.open.disabled || n.open.selected < 0 || e.key.length > 1 || e.ctrlKey && !(Ct && e.altKey) || e.metaKey) return !1;
713
+ let r = n.open.options[n.open.selected], i = n.active.find((e) => e.source == r.source), a = r.completion.commitCharacters || i.result.commitCharacters;
714
+ return a && a.indexOf(e.key) > -1 && pt(t, r), !1;
715
+ } })), Tt = /*@__PURE__*/ p.baseTheme({
716
+ ".cm-tooltip.cm-tooltip-autocomplete": { "& > ul": {
717
+ fontFamily: "monospace",
718
+ whiteSpace: "nowrap",
719
+ overflow: "hidden auto",
720
+ maxWidth_fallback: "700px",
721
+ maxWidth: "min(700px, 95vw)",
722
+ minWidth: "250px",
723
+ maxHeight: "10em",
724
+ height: "100%",
725
+ listStyle: "none",
726
+ margin: 0,
727
+ padding: 0,
728
+ "& > li, & > completion-section": {
729
+ padding: "1px 3px",
730
+ lineHeight: 1.2
731
+ },
732
+ "& > li": {
733
+ overflowX: "hidden",
734
+ textOverflow: "ellipsis",
735
+ cursor: "pointer"
736
+ },
737
+ "& > completion-section": {
738
+ display: "list-item",
739
+ borderBottom: "1px solid silver",
740
+ paddingLeft: "0.5em",
741
+ opacity: .7
742
+ }
743
+ } },
744
+ "&light .cm-tooltip-autocomplete ul li[aria-selected]": {
745
+ background: "#17c",
746
+ color: "white"
747
+ },
748
+ "&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]": { background: "#777" },
749
+ "&dark .cm-tooltip-autocomplete ul li[aria-selected]": {
750
+ background: "#347",
751
+ color: "white"
752
+ },
753
+ "&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]": { background: "#444" },
754
+ ".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after": {
755
+ content: "\"···\"",
756
+ opacity: .5,
757
+ display: "block",
758
+ textAlign: "center",
759
+ cursor: "pointer"
760
+ },
761
+ ".cm-tooltip.cm-completionInfo": {
762
+ position: "absolute",
763
+ padding: "3px 9px",
764
+ width: "max-content",
765
+ maxWidth: "400px",
766
+ boxSizing: "border-box",
767
+ whiteSpace: "pre-line"
768
+ },
769
+ ".cm-completionInfo.cm-completionInfo-left": { right: "100%" },
770
+ ".cm-completionInfo.cm-completionInfo-right": { left: "100%" },
771
+ ".cm-completionInfo.cm-completionInfo-left-narrow": { right: "30px" },
772
+ ".cm-completionInfo.cm-completionInfo-right-narrow": { left: "30px" },
773
+ "&light .cm-snippetField": { backgroundColor: "#00000022" },
774
+ "&dark .cm-snippetField": { backgroundColor: "#ffffff22" },
775
+ ".cm-snippetFieldPosition": {
776
+ verticalAlign: "text-top",
777
+ width: 0,
778
+ height: "1.15em",
779
+ display: "inline-block",
780
+ margin: "0 -0.7px -.7em",
781
+ borderLeft: "1.4px dotted #888"
782
+ },
783
+ ".cm-completionMatchedText": { textDecoration: "underline" },
784
+ ".cm-completionDetail": {
785
+ marginLeft: "0.5em",
786
+ fontStyle: "italic"
787
+ },
788
+ ".cm-completionIcon": {
789
+ fontSize: "90%",
790
+ width: ".8em",
791
+ display: "inline-block",
792
+ textAlign: "center",
793
+ paddingRight: ".6em",
794
+ opacity: "0.6",
795
+ boxSizing: "content-box"
796
+ },
797
+ ".cm-completionIcon-function, .cm-completionIcon-method": { "&:after": { content: "'ƒ'" } },
798
+ ".cm-completionIcon-class": { "&:after": { content: "'○'" } },
799
+ ".cm-completionIcon-interface": { "&:after": { content: "'◌'" } },
800
+ ".cm-completionIcon-variable": { "&:after": { content: "'𝑥'" } },
801
+ ".cm-completionIcon-constant": { "&:after": { content: "'𝐶'" } },
802
+ ".cm-completionIcon-type": { "&:after": { content: "'𝑡'" } },
803
+ ".cm-completionIcon-enum": { "&:after": { content: "'∪'" } },
804
+ ".cm-completionIcon-property": { "&:after": { content: "'□'" } },
805
+ ".cm-completionIcon-keyword": { "&:after": { content: "'🔑︎'" } },
806
+ ".cm-completionIcon-namespace": { "&:after": { content: "'▢'" } },
807
+ ".cm-completionIcon-text": { "&:after": {
808
+ content: "'abc'",
809
+ fontSize: "50%",
810
+ verticalAlign: "middle"
811
+ } }
812
+ }), Et = class {
813
+ constructor(e, t, n, r) {
814
+ this.field = e, this.line = t, this.from = n, this.to = r;
815
+ }
816
+ }, Dt = class e {
817
+ constructor(e, t, n) {
818
+ this.field = e, this.from = t, this.to = n;
819
+ }
820
+ map(t) {
821
+ let n = t.mapPos(this.from, -1, we.TrackDel), r = t.mapPos(this.to, 1, we.TrackDel);
822
+ return n == null || r == null ? null : new e(this.field, n, r);
823
+ }
824
+ }, Ot = class e {
825
+ constructor(e, t) {
826
+ this.lines = e, this.fieldPositions = t;
827
+ }
828
+ instantiate(e, t) {
829
+ let n = [], r = [t], i = e.doc.lineAt(t), a = /^\s*/.exec(i.text)[0];
830
+ for (let i of this.lines) {
831
+ if (n.length) {
832
+ let n = a, o = /^\t*/.exec(i)[0].length;
833
+ for (let t = 0; t < o; t++) n += e.facet(E);
834
+ r.push(t + n.length - o), i = n + i.slice(o);
835
+ }
836
+ n.push(i), t += i.length + 1;
837
+ }
838
+ return {
839
+ text: n,
840
+ ranges: this.fieldPositions.map((e) => new Dt(e.field, r[e.line] + e.from, r[e.line] + e.to))
841
+ };
842
+ }
843
+ static parse(t) {
844
+ let n = [], r = [], i = [], a;
845
+ for (let e of t.split(/\r\n?|\n/)) {
846
+ for (; a = /[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);) {
847
+ let t = a[1] ? +a[1] : null, o = a[2] || a[3] || "", s = -1;
848
+ t === 0 && (t = 1e9);
849
+ let c = o.replace(/\\[{}]/g, (e) => e[1]);
850
+ for (let e = 0; e < n.length; e++) (t == null ? c && n[e].name == c : n[e].seq == t) && (s = e);
851
+ if (s < 0) {
852
+ let e = 0;
853
+ for (; e < n.length && (t == null || n[e].seq != null && n[e].seq < t);) e++;
854
+ n.splice(e, 0, {
855
+ seq: t,
856
+ name: c
857
+ }), s = e;
858
+ for (let e of i) e.field >= s && e.field++;
859
+ }
860
+ for (let e of i) if (e.line == r.length && e.from > a.index) {
861
+ let t = a[2] ? 3 + (a[1] || "").length : 2;
862
+ e.from -= t, e.to -= t;
863
+ }
864
+ i.push(new Et(s, r.length, a.index, a.index + c.length)), e = e.slice(0, a.index) + o + e.slice(a.index + a[0].length);
865
+ }
866
+ e = e.replace(/\\([{}])/g, (e, t, n) => {
867
+ for (let e of i) e.line == r.length && e.from > n && (e.from--, e.to--);
868
+ return t;
869
+ }), r.push(e);
870
+ }
871
+ return new e(r, i);
872
+ }
873
+ }, kt = /*@__PURE__*/ n.widget({ widget: /*@__PURE__*/ new class extends h {
874
+ toDOM() {
875
+ let e = document.createElement("span");
876
+ return e.className = "cm-snippetFieldPosition", e;
877
+ }
878
+ ignoreEvent() {
879
+ return !1;
880
+ }
881
+ }() }), At = /*@__PURE__*/ n.mark({ class: "cm-snippetField" }), jt = class e {
882
+ constructor(e, t) {
883
+ this.ranges = e, this.active = t, this.deco = n.set(e.map((e) => (e.from == e.to ? kt : At).range(e.from, e.to)), !0);
884
+ }
885
+ map(t) {
886
+ let n = [];
887
+ for (let e of this.ranges) {
888
+ let r = e.map(t);
889
+ if (!r) return null;
890
+ n.push(r);
891
+ }
892
+ return new e(n, this.active);
893
+ }
894
+ selectionInsideField(e) {
895
+ return e.ranges.every((e) => this.ranges.some((t) => t.field == this.active && t.from <= e.from && t.to >= e.to));
896
+ }
897
+ }, M = /*@__PURE__*/ y.define({ map(e, t) {
898
+ return e && e.map(t);
899
+ } }), Mt = /*@__PURE__*/ y.define(), N = /*@__PURE__*/ C.define({
900
+ create() {
901
+ return null;
902
+ },
903
+ update(e, t) {
904
+ for (let n of t.effects) {
905
+ if (n.is(M)) return n.value;
906
+ if (n.is(Mt) && e) return new jt(e.ranges, n.value);
907
+ }
908
+ return e && t.docChanged && (e = e.map(t.changes)), e && t.selection && !e.selectionInsideField(t.selection) && (e = null), e;
909
+ },
910
+ provide: (e) => p.decorations.from(e, (e) => e ? e.deco : n.none)
911
+ });
912
+ function Nt(e, t) {
913
+ return g.create(e.filter((e) => e.field == t).map((e) => g.range(e.from, e.to)));
914
+ }
915
+ function Pt(e) {
916
+ let t = Ot.parse(e);
917
+ return (e, n, r, i) => {
918
+ let { text: a, ranges: o } = t.instantiate(e.state, r), { main: s } = e.state.selection, c = {
919
+ changes: {
920
+ from: r,
921
+ to: i == s.from ? s.to : i,
922
+ insert: Se.of(a)
923
+ },
924
+ scrollIntoView: !0,
925
+ annotations: n ? [ze.of(n), le.userEvent.of("input.complete")] : void 0
926
+ };
927
+ if (o.length && (c.selection = Nt(o, 0)), o.some((e) => e.field > 0)) {
928
+ let t = new jt(o, 0), n = c.effects = [M.of(t)];
929
+ e.state.field(N, !1) === void 0 && n.push(y.appendConfig.of([
930
+ N,
931
+ Rt,
932
+ Bt,
933
+ Tt
934
+ ]));
935
+ }
936
+ e.dispatch(e.state.update(c));
937
+ };
938
+ }
939
+ function Ft(e) {
940
+ return ({ state: t, dispatch: n }) => {
941
+ let r = t.field(N, !1);
942
+ if (!r || e < 0 && r.active == 0) return !1;
943
+ let i = r.active + e, a = e > 0 && !r.ranges.some((t) => t.field == i + e);
944
+ return n(t.update({
945
+ selection: Nt(r.ranges, i),
946
+ effects: M.of(a ? null : new jt(r.ranges, i)),
947
+ scrollIntoView: !0
948
+ })), !0;
949
+ };
950
+ }
951
+ var It = [{
952
+ key: "Tab",
953
+ run: /* @__PURE__ */ Ft(1),
954
+ shift: /* @__PURE__ */ Ft(-1)
955
+ }, {
956
+ key: "Escape",
957
+ run: ({ state: e, dispatch: t }) => e.field(N, !1) ? (t(e.update({ effects: M.of(null) })), !0) : !1
958
+ }], Lt = /*@__PURE__*/ b.define({ combine(e) {
959
+ return e.length ? e[0] : It;
960
+ } }), Rt = /*@__PURE__*/ ve.highest(/*@__PURE__*/ c.compute([Lt], (e) => e.facet(Lt)));
961
+ function zt(e, t) {
962
+ return {
963
+ ...t,
964
+ apply: Pt(e)
965
+ };
966
+ }
967
+ var Bt = /*@__PURE__*/ p.domEventHandlers({ mousedown(e, t) {
968
+ let n = t.state.field(N, !1), r;
969
+ if (!n || (r = t.posAtCoords({
970
+ x: e.clientX,
971
+ y: e.clientY
972
+ })) == null) return !1;
973
+ let i = n.ranges.find((e) => e.from <= r && e.to >= r);
974
+ return !i || i.field == n.active ? !1 : (t.dispatch({
975
+ selection: Nt(n.ranges, i.field),
976
+ effects: M.of(n.ranges.some((e) => e.field > i.field) ? new jt(n.ranges, i.field) : null),
977
+ scrollIntoView: !0
978
+ }), !0);
979
+ } }), P = {
980
+ brackets: [
981
+ "(",
982
+ "[",
983
+ "{",
984
+ "'",
985
+ "\""
986
+ ],
987
+ before: ")]}:;>",
988
+ stringPrefixes: []
989
+ }, F = /*@__PURE__*/ y.define({ map(e, t) {
990
+ return t.mapPos(e, -1, we.TrackAfter) ?? void 0;
991
+ } }), Vt = /*@__PURE__*/ new class extends me {}();
992
+ Vt.startSide = 1, Vt.endSide = -1;
993
+ var Ht = /*@__PURE__*/ C.define({
994
+ create() {
995
+ return be.empty;
996
+ },
997
+ update(e, t) {
998
+ if (e = e.map(t.changes), t.selection) {
999
+ let n = t.state.doc.lineAt(t.selection.main.head);
1000
+ e = e.update({ filter: (e) => e >= n.from && e <= n.to });
1001
+ }
1002
+ for (let n of t.effects) n.is(F) && (e = e.update({ add: [Vt.range(n.value, n.value + 1)] }));
1003
+ return e;
1004
+ }
1005
+ });
1006
+ function Ut() {
1007
+ return [Jt, Ht];
1008
+ }
1009
+ var Wt = "()[]{}<>«»»«[]{}";
1010
+ function Gt(e) {
1011
+ for (let t = 0; t < 16; t += 2) if (Wt.charCodeAt(t) == e) return Wt.charAt(t + 1);
1012
+ return _e(e < 128 ? e : e + 1);
1013
+ }
1014
+ function Kt(e, t) {
1015
+ return e.languageDataAt("closeBrackets", t)[0] || P;
1016
+ }
1017
+ var qt = typeof navigator == "object" && /*@__PURE__*/ /Android\b/.test(navigator.userAgent), Jt = /*@__PURE__*/ p.inputHandler.of((e, t, n, r) => {
1018
+ if ((qt ? e.composing : e.compositionStarted) || e.state.readOnly) return !1;
1019
+ let i = e.state.selection.main;
1020
+ if (r.length > 2 || r.length == 2 && T(S(r, 0)) == 1 || t != i.from || n != i.to) return !1;
1021
+ let a = Xt(e.state, r);
1022
+ return a ? (e.dispatch(a), !0) : !1;
1023
+ }), Yt = [{
1024
+ key: "Backspace",
1025
+ run: ({ state: e, dispatch: t }) => {
1026
+ if (e.readOnly) return !1;
1027
+ let n = Kt(e, e.selection.main.head).brackets || P.brackets, r = null, i = e.changeByRange((t) => {
1028
+ if (t.empty) {
1029
+ let r = Qt(e.doc, t.head);
1030
+ for (let i of n) if (i == r && I(e.doc, t.head) == Gt(S(i, 0))) return {
1031
+ changes: {
1032
+ from: t.head - i.length,
1033
+ to: t.head + i.length
1034
+ },
1035
+ range: g.cursor(t.head - i.length)
1036
+ };
1037
+ }
1038
+ return { range: r = t };
1039
+ });
1040
+ return r || t(e.update(i, {
1041
+ scrollIntoView: !0,
1042
+ userEvent: "delete.backward"
1043
+ })), !r;
1044
+ }
1045
+ }];
1046
+ function Xt(e, t) {
1047
+ let n = Kt(e, e.selection.main.head), r = n.brackets || P.brackets;
1048
+ for (let i of r) {
1049
+ let a = Gt(S(i, 0));
1050
+ if (t == i) return a == i ? tn(e, i, r.indexOf(i + i + i) > -1, n) : $t(e, i, a, n.before || P.before);
1051
+ if (t == a && Zt(e, e.selection.main.from)) return en(e, i, a);
1052
+ }
1053
+ return null;
1054
+ }
1055
+ function Zt(e, t) {
1056
+ let n = !1;
1057
+ return e.field(Ht).between(0, e.doc.length, (e) => {
1058
+ e == t && (n = !0);
1059
+ }), n;
1060
+ }
1061
+ function I(e, t) {
1062
+ let n = e.sliceString(t, t + 2);
1063
+ return n.slice(0, T(S(n, 0)));
1064
+ }
1065
+ function Qt(e, t) {
1066
+ let n = e.sliceString(t - 2, t);
1067
+ return T(S(n, 0)) == n.length ? n : n.slice(1);
1068
+ }
1069
+ function $t(e, t, n, r) {
1070
+ let i = null, a = e.changeByRange((a) => {
1071
+ if (!a.empty) return {
1072
+ changes: [{
1073
+ insert: t,
1074
+ from: a.from
1075
+ }, {
1076
+ insert: n,
1077
+ from: a.to
1078
+ }],
1079
+ effects: F.of(a.to + t.length),
1080
+ range: g.range(a.anchor + t.length, a.head + t.length)
1081
+ };
1082
+ let o = I(e.doc, a.head);
1083
+ return !o || /\s/.test(o) || r.indexOf(o) > -1 ? {
1084
+ changes: {
1085
+ insert: t + n,
1086
+ from: a.head
1087
+ },
1088
+ effects: F.of(a.head + t.length),
1089
+ range: g.cursor(a.head + t.length)
1090
+ } : { range: i = a };
1091
+ });
1092
+ return i ? null : e.update(a, {
1093
+ scrollIntoView: !0,
1094
+ userEvent: "input.type"
1095
+ });
1096
+ }
1097
+ function en(e, t, n) {
1098
+ let r = null, i = e.changeByRange((t) => t.empty && I(e.doc, t.head) == n ? {
1099
+ changes: {
1100
+ from: t.head,
1101
+ to: t.head + n.length,
1102
+ insert: n
1103
+ },
1104
+ range: g.cursor(t.head + n.length)
1105
+ } : r = { range: t });
1106
+ return r ? null : e.update(i, {
1107
+ scrollIntoView: !0,
1108
+ userEvent: "input.type"
1109
+ });
1110
+ }
1111
+ function tn(e, t, n, r) {
1112
+ let i = r.stringPrefixes || P.stringPrefixes, a = null, o = e.changeByRange((r) => {
1113
+ if (!r.empty) return {
1114
+ changes: [{
1115
+ insert: t,
1116
+ from: r.from
1117
+ }, {
1118
+ insert: t,
1119
+ from: r.to
1120
+ }],
1121
+ effects: F.of(r.to + t.length),
1122
+ range: g.range(r.anchor + t.length, r.head + t.length)
1123
+ };
1124
+ let o = r.head, s = I(e.doc, o), c;
1125
+ if (s == t) {
1126
+ if (nn(e, o)) return {
1127
+ changes: {
1128
+ insert: t + t,
1129
+ from: o
1130
+ },
1131
+ effects: F.of(o + t.length),
1132
+ range: g.cursor(o + t.length)
1133
+ };
1134
+ if (Zt(e, o)) {
1135
+ let r = n && e.sliceDoc(o, o + t.length * 3) == t + t + t ? t + t + t : t;
1136
+ return {
1137
+ changes: {
1138
+ from: o,
1139
+ to: o + r.length,
1140
+ insert: r
1141
+ },
1142
+ range: g.cursor(o + r.length)
1143
+ };
1144
+ }
1145
+ } else if (n && e.sliceDoc(o - 2 * t.length, o) == t + t && (c = an(e, o - 2 * t.length, i)) > -1 && nn(e, c)) return {
1146
+ changes: {
1147
+ insert: t + t + t + t,
1148
+ from: o
1149
+ },
1150
+ effects: F.of(o + t.length),
1151
+ range: g.cursor(o + t.length)
1152
+ };
1153
+ else if (e.charCategorizer(o)(s) != v.Word && an(e, o, i) > -1 && !rn(e, o, t, i)) return {
1154
+ changes: {
1155
+ insert: t + t,
1156
+ from: o
1157
+ },
1158
+ effects: F.of(o + t.length),
1159
+ range: g.cursor(o + t.length)
1160
+ };
1161
+ return { range: a = r };
1162
+ });
1163
+ return a ? null : e.update(o, {
1164
+ scrollIntoView: !0,
1165
+ userEvent: "input.type"
1166
+ });
1167
+ }
1168
+ function nn(e, t) {
1169
+ let n = x(e).resolveInner(t + 1);
1170
+ return n.parent && n.from == t;
1171
+ }
1172
+ function rn(e, t, n, r) {
1173
+ let i = x(e).resolveInner(t, -1), a = r.reduce((e, t) => Math.max(e, t.length), 0);
1174
+ for (let o = 0; o < 5; o++) {
1175
+ let o = e.sliceDoc(i.from, Math.min(i.to, i.from + n.length + a)), s = o.indexOf(n);
1176
+ if (!s || s > -1 && r.indexOf(o.slice(0, s)) > -1) {
1177
+ let t = i.firstChild;
1178
+ for (; t && t.from == i.from && t.to - t.from > n.length + s;) {
1179
+ if (e.sliceDoc(t.to - n.length, t.to) == n) return !1;
1180
+ t = t.firstChild;
1181
+ }
1182
+ return !0;
1183
+ }
1184
+ let c = i.to == t && i.parent;
1185
+ if (!c) break;
1186
+ i = c;
1187
+ }
1188
+ return !1;
1189
+ }
1190
+ function an(e, t, n) {
1191
+ let r = e.charCategorizer(t);
1192
+ if (r(e.sliceDoc(t - 1, t)) != v.Word) return t;
1193
+ for (let i of n) {
1194
+ let n = t - i.length;
1195
+ if (e.sliceDoc(n, t) == i && r(e.sliceDoc(n - 1, n)) != v.Word) return n;
1196
+ }
1197
+ return -1;
1198
+ }
1199
+ function on(e = {}) {
1200
+ return [
1201
+ wt,
1202
+ j,
1203
+ k.of(e),
1204
+ St,
1205
+ cn,
1206
+ Tt
1207
+ ];
1208
+ }
1209
+ var sn = [
1210
+ {
1211
+ key: "Ctrl-Space",
1212
+ run: _t
1213
+ },
1214
+ {
1215
+ mac: "Alt-`",
1216
+ run: _t
1217
+ },
1218
+ {
1219
+ mac: "Alt-i",
1220
+ run: _t
1221
+ },
1222
+ {
1223
+ key: "Escape",
1224
+ run: vt
1225
+ },
1226
+ {
1227
+ key: "ArrowDown",
1228
+ run: /*@__PURE__*/ ht(!0)
1229
+ },
1230
+ {
1231
+ key: "ArrowUp",
1232
+ run: /*@__PURE__*/ ht(!1)
1233
+ },
1234
+ {
1235
+ key: "PageDown",
1236
+ run: /*@__PURE__*/ ht(!0, "page")
1237
+ },
1238
+ {
1239
+ key: "PageUp",
1240
+ run: /*@__PURE__*/ ht(!1, "page")
1241
+ },
1242
+ {
1243
+ key: "Enter",
1244
+ run: gt
1245
+ }
1246
+ ], cn = /*@__PURE__*/ ve.highest(/*@__PURE__*/ c.computeN([k], (e) => e.facet(k).defaultKeymap ? [sn] : [])), ln = (e) => {
1247
+ let { state: t } = e, n = t.doc.lineAt(t.selection.main.from), r = mn(e.state, n.from);
1248
+ return r.line ? dn(e) : r.block ? pn(e) : !1;
1249
+ };
1250
+ function un(e, t) {
1251
+ return ({ state: n, dispatch: r }) => {
1252
+ if (n.readOnly) return !1;
1253
+ let i = e(t, n);
1254
+ return i ? (r(n.update(i)), !0) : !1;
1255
+ };
1256
+ }
1257
+ var dn = /*@__PURE__*/ un(vn, 0), fn = /*@__PURE__*/ un(_n, 0), pn = /*@__PURE__*/ un((e, t) => _n(e, t, gn(t)), 0);
1258
+ function mn(e, t) {
1259
+ let n = e.languageDataAt("commentTokens", t, 1);
1260
+ return n.length ? n[0] : {};
1261
+ }
1262
+ var L = 50;
1263
+ function hn(e, { open: t, close: n }, r, i) {
1264
+ let a = e.sliceDoc(r - L, r), o = e.sliceDoc(i, i + L), s = /\s*$/.exec(a)[0].length, c = /^\s*/.exec(o)[0].length, l = a.length - s;
1265
+ if (a.slice(l - t.length, l) == t && o.slice(c, c + n.length) == n) return {
1266
+ open: {
1267
+ pos: r - s,
1268
+ margin: s && 1
1269
+ },
1270
+ close: {
1271
+ pos: i + c,
1272
+ margin: c && 1
1273
+ }
1274
+ };
1275
+ let u, d;
1276
+ i - r <= 100 ? u = d = e.sliceDoc(r, i) : (u = e.sliceDoc(r, r + L), d = e.sliceDoc(i - L, i));
1277
+ let f = /^\s*/.exec(u)[0].length, p = /\s*$/.exec(d)[0].length, m = d.length - p - n.length;
1278
+ return u.slice(f, f + t.length) == t && d.slice(m, m + n.length) == n ? {
1279
+ open: {
1280
+ pos: r + f + t.length,
1281
+ margin: +!!/\s/.test(u.charAt(f + t.length))
1282
+ },
1283
+ close: {
1284
+ pos: i - p - n.length,
1285
+ margin: +!!/\s/.test(d.charAt(m - 1))
1286
+ }
1287
+ } : null;
1288
+ }
1289
+ function gn(e) {
1290
+ let t = [];
1291
+ for (let n of e.selection.ranges) {
1292
+ let r = e.doc.lineAt(n.from), i = n.to <= r.to ? r : e.doc.lineAt(n.to);
1293
+ i.from > r.from && i.from == n.to && (i = n.to == r.to + 1 ? r : e.doc.lineAt(n.to - 1));
1294
+ let a = t.length - 1;
1295
+ a >= 0 && t[a].to > r.from ? t[a].to = i.to : t.push({
1296
+ from: r.from + /^\s*/.exec(r.text)[0].length,
1297
+ to: i.to
1298
+ });
1299
+ }
1300
+ return t;
1301
+ }
1302
+ function _n(e, t, n = t.selection.ranges) {
1303
+ let r = n.map((e) => mn(t, e.from).block);
1304
+ if (!r.every((e) => e)) return null;
1305
+ let i = n.map((e, n) => hn(t, r[n], e.from, e.to));
1306
+ if (e != 2 && !i.every((e) => e)) return { changes: t.changes(n.map((e, t) => i[t] ? [] : [{
1307
+ from: e.from,
1308
+ insert: r[t].open + " "
1309
+ }, {
1310
+ from: e.to,
1311
+ insert: " " + r[t].close
1312
+ }])) };
1313
+ if (e != 1 && i.some((e) => e)) {
1314
+ let e = [];
1315
+ for (let t = 0, n; t < i.length; t++) if (n = i[t]) {
1316
+ let i = r[t], { open: a, close: o } = n;
1317
+ e.push({
1318
+ from: a.pos - i.open.length,
1319
+ to: a.pos + a.margin
1320
+ }, {
1321
+ from: o.pos - o.margin,
1322
+ to: o.pos + i.close.length
1323
+ });
1324
+ }
1325
+ return { changes: e };
1326
+ }
1327
+ return null;
1328
+ }
1329
+ function vn(e, t, n = t.selection.ranges) {
1330
+ let r = [], i = -1;
1331
+ ranges: for (let { from: e, to: a } of n) {
1332
+ let n = r.length, o = 1e9, s;
1333
+ for (let n = e; n <= a;) {
1334
+ let c = t.doc.lineAt(n);
1335
+ if (s == null && (s = mn(t, c.from).line, !s)) continue ranges;
1336
+ if (c.from > i && (e == a || a > c.from)) {
1337
+ i = c.from;
1338
+ let e = /^\s*/.exec(c.text)[0].length, t = e == c.length, n = c.text.slice(e, e + s.length) == s ? e : -1;
1339
+ e < c.text.length && e < o && (o = e), r.push({
1340
+ line: c,
1341
+ comment: n,
1342
+ token: s,
1343
+ indent: e,
1344
+ empty: t,
1345
+ single: !1
1346
+ });
1347
+ }
1348
+ n = c.to + 1;
1349
+ }
1350
+ if (o < 1e9) for (let e = n; e < r.length; e++) r[e].indent < r[e].line.text.length && (r[e].indent = o);
1351
+ r.length == n + 1 && (r[n].single = !0);
1352
+ }
1353
+ if (e != 2 && r.some((e) => e.comment < 0 && (!e.empty || e.single))) {
1354
+ let e = [];
1355
+ for (let { line: t, token: n, indent: i, empty: a, single: o } of r) (o || !a) && e.push({
1356
+ from: t.from + i,
1357
+ insert: n + " "
1358
+ });
1359
+ let n = t.changes(e);
1360
+ return {
1361
+ changes: n,
1362
+ selection: t.selection.map(n, 1)
1363
+ };
1364
+ }
1365
+ if (e != 1 && r.some((e) => e.comment >= 0)) {
1366
+ let e = [];
1367
+ for (let { line: t, comment: n, token: i } of r) if (n >= 0) {
1368
+ let r = t.from + n, a = r + i.length;
1369
+ t.text[a - t.from] == " " && a++, e.push({
1370
+ from: r,
1371
+ to: a
1372
+ });
1373
+ }
1374
+ return { changes: e };
1375
+ }
1376
+ return null;
1377
+ }
1378
+ var yn = /*@__PURE__*/ ye.define(), bn = /*@__PURE__*/ ye.define(), xn = /*@__PURE__*/ b.define(), Sn = /*@__PURE__*/ b.define({ combine(e) {
1379
+ return ue(e, {
1380
+ minDepth: 100,
1381
+ newGroupDelay: 500,
1382
+ joinToEvent: (e, t) => t
1383
+ }, {
1384
+ minDepth: Math.max,
1385
+ newGroupDelay: Math.min,
1386
+ joinToEvent: (e, t) => (n, r) => e(n, r) || t(n, r)
1387
+ });
1388
+ } }), Cn = /*@__PURE__*/ C.define({
1389
+ create() {
1390
+ return H.empty;
1391
+ },
1392
+ update(e, t) {
1393
+ let n = t.state.facet(Sn), r = t.annotation(yn);
1394
+ if (r) {
1395
+ let i = z.fromTransaction(t, r.selection), a = r.side, o = a == 0 ? e.undone : e.done;
1396
+ return o = i ? B(o, o.length, n.minDepth, i) : Nn(o, t.startState.selection), new H(a == 0 ? r.rest : o, a == 0 ? o : r.rest);
1397
+ }
1398
+ let i = t.annotation(bn);
1399
+ if ((i == "full" || i == "before") && (e = e.isolate()), t.annotation(le.addToHistory) === !1) return t.changes.empty ? e : e.addMapping(t.changes.desc);
1400
+ let a = z.fromTransaction(t), o = t.annotation(le.time), s = t.annotation(le.userEvent);
1401
+ return a ? e = e.addChanges(a, o, s, n, t) : t.selection && (e = e.addSelection(t.startState.selection, o, s, n.newGroupDelay)), (i == "full" || i == "after") && (e = e.isolate()), e;
1402
+ },
1403
+ toJSON(e) {
1404
+ return {
1405
+ done: e.done.map((e) => e.toJSON()),
1406
+ undone: e.undone.map((e) => e.toJSON())
1407
+ };
1408
+ },
1409
+ fromJSON(e) {
1410
+ return new H(e.done.map(z.fromJSON), e.undone.map(z.fromJSON));
1411
+ }
1412
+ });
1413
+ function wn(e = {}) {
1414
+ return [
1415
+ Cn,
1416
+ Sn.of(e),
1417
+ p.domEventHandlers({ beforeinput(e, t) {
1418
+ let n = e.inputType == "historyUndo" ? Tn : e.inputType == "historyRedo" ? En : null;
1419
+ return n ? (e.preventDefault(), n(t)) : !1;
1420
+ } })
1421
+ ];
1422
+ }
1423
+ function R(e, t) {
1424
+ return function({ state: n, dispatch: r }) {
1425
+ if (!t && n.readOnly) return !1;
1426
+ let i = n.field(Cn, !1);
1427
+ if (!i) return !1;
1428
+ let a = i.pop(e, n, t);
1429
+ return a ? (r(a), !0) : !1;
1430
+ };
1431
+ }
1432
+ var Tn = /*@__PURE__*/ R(0, !1), En = /*@__PURE__*/ R(1, !1), Dn = /*@__PURE__*/ R(0, !0), On = /*@__PURE__*/ R(1, !0), z = class e {
1433
+ constructor(e, t, n, r, i) {
1434
+ this.changes = e, this.effects = t, this.mapped = n, this.startSelection = r, this.selectionsAfter = i;
1435
+ }
1436
+ setSelAfter(t) {
1437
+ return new e(this.changes, this.effects, this.mapped, this.startSelection, t);
1438
+ }
1439
+ toJSON() {
1440
+ return {
1441
+ changes: this.changes?.toJSON(),
1442
+ mapped: this.mapped?.toJSON(),
1443
+ startSelection: this.startSelection?.toJSON(),
1444
+ selectionsAfter: this.selectionsAfter.map((e) => e.toJSON())
1445
+ };
1446
+ }
1447
+ static fromJSON(t) {
1448
+ return new e(t.changes && ae.fromJSON(t.changes), [], t.mapped && u.fromJSON(t.mapped), t.startSelection && g.fromJSON(t.startSelection), t.selectionsAfter.map(g.fromJSON));
1449
+ }
1450
+ static fromTransaction(t, n) {
1451
+ let r = V;
1452
+ for (let e of t.startState.facet(xn)) {
1453
+ let n = e(t);
1454
+ n.length && (r = r.concat(n));
1455
+ }
1456
+ return !r.length && t.changes.empty ? null : new e(t.changes.invert(t.startState.doc), r, void 0, n || t.startState.selection, V);
1457
+ }
1458
+ static selection(t) {
1459
+ return new e(void 0, V, void 0, void 0, t);
1460
+ }
1461
+ };
1462
+ function B(e, t, n, r) {
1463
+ let i = t + 1 > n + 20 ? t - n - 1 : 0, a = e.slice(i, t);
1464
+ return a.push(r), a;
1465
+ }
1466
+ function kn(e, t) {
1467
+ let n = [], r = !1;
1468
+ return e.iterChangedRanges((e, t) => n.push(e, t)), t.iterChangedRanges((e, t, i, a) => {
1469
+ for (let e = 0; e < n.length;) {
1470
+ let t = n[e++], o = n[e++];
1471
+ a >= t && i <= o && (r = !0);
1472
+ }
1473
+ }), r;
1474
+ }
1475
+ function An(e, t) {
1476
+ return e.ranges.length == t.ranges.length && e.ranges.filter((e, n) => e.empty != t.ranges[n].empty).length === 0;
1477
+ }
1478
+ function jn(e, t) {
1479
+ return e.length ? t.length ? e.concat(t) : e : t;
1480
+ }
1481
+ var V = [], Mn = 200;
1482
+ function Nn(e, t) {
1483
+ if (e.length) {
1484
+ let n = e[e.length - 1], r = n.selectionsAfter.slice(Math.max(0, n.selectionsAfter.length - Mn));
1485
+ return r.length && r[r.length - 1].eq(t) ? e : (r.push(t), B(e, e.length - 1, 1e9, n.setSelAfter(r)));
1486
+ }
1487
+ return [z.selection([t])];
1488
+ }
1489
+ function Pn(e) {
1490
+ let t = e[e.length - 1], n = e.slice();
1491
+ return n[e.length - 1] = t.setSelAfter(t.selectionsAfter.slice(0, t.selectionsAfter.length - 1)), n;
1492
+ }
1493
+ function Fn(e, t) {
1494
+ if (!e.length) return e;
1495
+ let n = e.length, r = V;
1496
+ for (; n;) {
1497
+ let i = In(e[n - 1], t, r);
1498
+ if (i.changes && !i.changes.empty || i.effects.length) {
1499
+ let t = e.slice(0, n);
1500
+ return t[n - 1] = i, t;
1501
+ }
1502
+ t = i.mapped, n--, r = i.selectionsAfter;
1503
+ }
1504
+ return r.length ? [z.selection(r)] : V;
1505
+ }
1506
+ function In(e, t, n) {
1507
+ let r = jn(e.selectionsAfter.length ? e.selectionsAfter.map((e) => e.map(t)) : V, n);
1508
+ if (!e.changes) return z.selection(r);
1509
+ let i = e.changes.map(t), a = t.mapDesc(e.changes, !0), o = e.mapped ? e.mapped.composeDesc(a) : a;
1510
+ return new z(i, y.mapEffects(e.effects, t), o, e.startSelection.map(a), r);
1511
+ }
1512
+ var Ln = /^(input\.type|delete)($|\.)/, H = class e {
1513
+ constructor(e, t, n = 0, r = void 0) {
1514
+ this.done = e, this.undone = t, this.prevTime = n, this.prevUserEvent = r;
1515
+ }
1516
+ isolate() {
1517
+ return this.prevTime ? new e(this.done, this.undone) : this;
1518
+ }
1519
+ addChanges(t, n, r, i, a) {
1520
+ let o = this.done, s = o[o.length - 1];
1521
+ return o = s && s.changes && !s.changes.empty && t.changes && (!r || Ln.test(r)) && (!s.selectionsAfter.length && n - this.prevTime < i.newGroupDelay && i.joinToEvent(a, kn(s.changes, t.changes)) || r == "input.type.compose") ? B(o, o.length - 1, i.minDepth, new z(t.changes.compose(s.changes), jn(y.mapEffects(t.effects, s.changes), s.effects), s.mapped, s.startSelection, V)) : B(o, o.length, i.minDepth, t), new e(o, V, n, r);
1522
+ }
1523
+ addSelection(t, n, r, i) {
1524
+ let a = this.done.length ? this.done[this.done.length - 1].selectionsAfter : V;
1525
+ return a.length > 0 && n - this.prevTime < i && r == this.prevUserEvent && r && /^select($|\.)/.test(r) && An(a[a.length - 1], t) ? this : new e(Nn(this.done, t), this.undone, n, r);
1526
+ }
1527
+ addMapping(t) {
1528
+ return new e(Fn(this.done, t), Fn(this.undone, t), this.prevTime, this.prevUserEvent);
1529
+ }
1530
+ pop(e, t, n) {
1531
+ let r = e == 0 ? this.done : this.undone;
1532
+ if (r.length == 0) return null;
1533
+ let i = r[r.length - 1], a = i.selectionsAfter[0] || (i.startSelection ? i.startSelection.map(i.changes.invertedDesc, 1) : t.selection);
1534
+ if (n && i.selectionsAfter.length) return t.update({
1535
+ selection: i.selectionsAfter[i.selectionsAfter.length - 1],
1536
+ annotations: yn.of({
1537
+ side: e,
1538
+ rest: Pn(r),
1539
+ selection: a
1540
+ }),
1541
+ userEvent: e == 0 ? "select.undo" : "select.redo",
1542
+ scrollIntoView: !0
1543
+ });
1544
+ if (i.changes) {
1545
+ let n = r.length == 1 ? V : r.slice(0, r.length - 1);
1546
+ return i.mapped && (n = Fn(n, i.mapped)), t.update({
1547
+ changes: i.changes,
1548
+ selection: i.startSelection,
1549
+ effects: i.effects,
1550
+ annotations: yn.of({
1551
+ side: e,
1552
+ rest: n,
1553
+ selection: a
1554
+ }),
1555
+ filter: !1,
1556
+ userEvent: e == 0 ? "undo" : "redo",
1557
+ scrollIntoView: !0
1558
+ });
1559
+ }
1560
+ return null;
1561
+ }
1562
+ };
1563
+ H.empty = /*@__PURE__*/ new H(V, V);
1564
+ var Rn = [
1565
+ {
1566
+ key: "Mod-z",
1567
+ run: Tn,
1568
+ preventDefault: !0
1569
+ },
1570
+ {
1571
+ key: "Mod-y",
1572
+ mac: "Mod-Shift-z",
1573
+ run: En,
1574
+ preventDefault: !0
1575
+ },
1576
+ {
1577
+ linux: "Ctrl-Shift-z",
1578
+ run: En,
1579
+ preventDefault: !0
1580
+ },
1581
+ {
1582
+ key: "Mod-u",
1583
+ run: Dn,
1584
+ preventDefault: !0
1585
+ },
1586
+ {
1587
+ key: "Alt-u",
1588
+ mac: "Mod-Shift-u",
1589
+ run: On,
1590
+ preventDefault: !0
1591
+ }
1592
+ ];
1593
+ function U(e, t) {
1594
+ return g.create(e.ranges.map(t), e.mainIndex);
1595
+ }
1596
+ function W(e, t) {
1597
+ return e.update({
1598
+ selection: t,
1599
+ scrollIntoView: !0,
1600
+ userEvent: "select"
1601
+ });
1602
+ }
1603
+ function G({ state: e, dispatch: t }, n) {
1604
+ let r = U(e.selection, n);
1605
+ return !r.eq(e.selection, !0) && (t(W(e, r)), !0);
1606
+ }
1607
+ function zn(e, t) {
1608
+ return g.cursor(t ? e.to : e.from);
1609
+ }
1610
+ function Bn(e, t) {
1611
+ return G(e, (n) => n.empty ? e.moveByChar(n, t) : zn(n, t));
1612
+ }
1613
+ function K(e) {
1614
+ return e.textDirectionAt(e.state.selection.main.head) == he.LTR;
1615
+ }
1616
+ var Vn = (e) => Bn(e, !K(e)), Hn = (e) => Bn(e, K(e));
1617
+ function Un(e, t) {
1618
+ return G(e, (n) => n.empty ? e.moveByGroup(n, t) : zn(n, t));
1619
+ }
1620
+ var Wn = (e) => Un(e, !K(e)), Gn = (e) => Un(e, K(e));
1621
+ typeof Intl < "u" && Intl.Segmenter;
1622
+ function Kn(e, t, n) {
1623
+ if (t.type.prop(n)) return !0;
1624
+ let r = t.to - t.from;
1625
+ return r && (r > 2 || /[^\s,.;:]/.test(e.sliceDoc(t.from, t.to))) || t.firstChild;
1626
+ }
1627
+ function qn(e, t, n) {
1628
+ let r = x(e).resolveInner(t.head), i = n ? Te.closedBy : Te.openedBy;
1629
+ for (let a = t.head;;) {
1630
+ let t = n ? r.childAfter(a) : r.childBefore(a);
1631
+ if (!t) break;
1632
+ Kn(e, t, i) ? r = t : a = n ? t.to : t.from;
1633
+ }
1634
+ let o = r.type.prop(i), s, c;
1635
+ return c = o && (s = n ? a(e, r.from, 1) : a(e, r.to, -1)) && s.matched ? n ? s.end.to : s.end.from : n ? r.to : r.from, g.cursor(c, n ? -1 : 1);
1636
+ }
1637
+ var Jn = (e) => G(e, (t) => qn(e.state, t, !K(e))), Yn = (e) => G(e, (t) => qn(e.state, t, K(e)));
1638
+ function Xn(e, t) {
1639
+ return G(e, (n) => {
1640
+ if (!n.empty) return zn(n, t);
1641
+ let r = e.moveVertically(n, t);
1642
+ return r.head == n.head ? e.moveToLineBoundary(n, t) : r;
1643
+ });
1644
+ }
1645
+ var Zn = (e) => Xn(e, !1), Qn = (e) => Xn(e, !0);
1646
+ function $n(e) {
1647
+ let t = e.scrollDOM.clientHeight < e.scrollDOM.scrollHeight - 2, n = 0, r = 0, i;
1648
+ if (t) {
1649
+ for (let t of e.state.facet(p.scrollMargins)) {
1650
+ let i = t(e);
1651
+ i?.top && (n = Math.max(i?.top, n)), i?.bottom && (r = Math.max(i?.bottom, r));
1652
+ }
1653
+ i = e.scrollDOM.clientHeight - n - r;
1654
+ } else i = (e.dom.ownerDocument.defaultView || window).innerHeight;
1655
+ return {
1656
+ marginTop: n,
1657
+ marginBottom: r,
1658
+ selfScroll: t,
1659
+ height: Math.max(e.defaultLineHeight, i - 5)
1660
+ };
1661
+ }
1662
+ function er(e, t) {
1663
+ let n = $n(e), { state: r } = e, i = U(r.selection, (r) => r.empty ? e.moveVertically(r, t, n.height) : zn(r, t));
1664
+ if (i.eq(r.selection)) return !1;
1665
+ let a;
1666
+ if (n.selfScroll) {
1667
+ let t = e.coordsAtPos(r.selection.main.head), o = e.scrollDOM.getBoundingClientRect(), s = o.top + n.marginTop, c = o.bottom - n.marginBottom;
1668
+ t && t.top > s && t.bottom < c && (a = p.scrollIntoView(i.main.head, {
1669
+ y: "start",
1670
+ yMargin: t.top - s
1671
+ }));
1672
+ }
1673
+ return e.dispatch(W(r, i), { effects: a }), !0;
1674
+ }
1675
+ var tr = (e) => er(e, !1), nr = (e) => er(e, !0);
1676
+ function q(e, t, n) {
1677
+ let r = e.lineBlockAt(t.head), i = e.moveToLineBoundary(t, n);
1678
+ if (i.head == t.head && i.head != (n ? r.to : r.from) && (i = e.moveToLineBoundary(t, n, !1)), !n && i.head == r.from && r.length) {
1679
+ let n = /^\s*/.exec(e.state.sliceDoc(r.from, Math.min(r.from + 100, r.to)))[0].length;
1680
+ n && t.head != r.from + n && (i = g.cursor(r.from + n));
1681
+ }
1682
+ return i;
1683
+ }
1684
+ var rr = (e) => G(e, (t) => q(e, t, !0)), ir = (e) => G(e, (t) => q(e, t, !1)), ar = (e) => G(e, (t) => q(e, t, !K(e))), or = (e) => G(e, (t) => q(e, t, K(e))), sr = (e) => G(e, (t) => e.moveToLineBoundary(t, !1, !1)), cr = (e) => G(e, (t) => e.moveToLineBoundary(t, !0, !1));
1685
+ function lr(e, t, n) {
1686
+ let r = !1, i = U(e.selection, (t) => {
1687
+ let i = a(e, t.head, -1) || a(e, t.head, 1) || t.head > 0 && a(e, t.head - 1, 1) || t.head < e.doc.length && a(e, t.head + 1, -1);
1688
+ if (!i || !i.end) return t;
1689
+ r = !0;
1690
+ let o = i.start.from == t.head ? i.end.to : i.end.from;
1691
+ return n ? g.range(t.anchor, o) : g.cursor(o);
1692
+ });
1693
+ return r ? (t(W(e, i)), !0) : !1;
1694
+ }
1695
+ var ur = ({ state: e, dispatch: t }) => lr(e, t, !1);
1696
+ function J(e, t, n) {
1697
+ let r = U(e.state.selection, (e) => {
1698
+ e.undirectional && e.head >= e.anchor != t && (e = g.range(e.head, e.anchor));
1699
+ let r = n(e);
1700
+ return g.range(e.anchor, r.head, r.goalColumn, r.bidiLevel || void 0, r.assoc);
1701
+ });
1702
+ return !r.eq(e.state.selection) && (e.dispatch(W(e.state, r)), !0);
1703
+ }
1704
+ function dr(e, t) {
1705
+ return J(e, t, (n) => e.moveByChar(n, t));
1706
+ }
1707
+ var fr = (e) => dr(e, !K(e)), pr = (e) => dr(e, K(e));
1708
+ function mr(e, t) {
1709
+ return J(e, t, (n) => e.moveByGroup(n, t));
1710
+ }
1711
+ var hr = (e) => mr(e, !K(e)), gr = (e) => mr(e, K(e)), _r = (e) => {
1712
+ let t = !K(e);
1713
+ return J(e, t, (n) => qn(e.state, n, t));
1714
+ }, vr = (e) => {
1715
+ let t = K(e);
1716
+ return J(e, t, (n) => qn(e.state, n, t));
1717
+ };
1718
+ function yr(e, t) {
1719
+ return J(e, t, (n) => e.moveVertically(n, t));
1720
+ }
1721
+ var br = (e) => yr(e, !1), xr = (e) => yr(e, !0);
1722
+ function Sr(e, t) {
1723
+ return J(e, t, (n) => e.moveVertically(n, t, $n(e).height));
1724
+ }
1725
+ var Cr = (e) => Sr(e, !1), wr = (e) => Sr(e, !0), Tr = (e) => J(e, !0, (t) => q(e, t, !0)), Er = (e) => J(e, !1, (t) => q(e, t, !1)), Dr = (e) => {
1726
+ let t = !K(e);
1727
+ return J(e, t, (n) => q(e, n, t));
1728
+ }, Or = (e) => {
1729
+ let t = K(e);
1730
+ return J(e, t, (n) => q(e, n, t));
1731
+ }, kr = (e) => J(e, !1, (t) => g.cursor(e.lineBlockAt(t.head).from)), Ar = (e) => J(e, !0, (t) => g.cursor(e.lineBlockAt(t.head).to)), jr = ({ state: e, dispatch: t }) => (t(W(e, { anchor: 0 })), !0), Mr = ({ state: e, dispatch: t }) => (t(W(e, { anchor: e.doc.length })), !0), Nr = ({ state: e, dispatch: t }) => (t(W(e, {
1732
+ anchor: e.selection.main.anchor,
1733
+ head: 0
1734
+ })), !0), Pr = ({ state: e, dispatch: t }) => (t(W(e, {
1735
+ anchor: e.selection.main.anchor,
1736
+ head: e.doc.length
1737
+ })), !0), Fr = ({ state: e, dispatch: t }) => (t(e.update({
1738
+ selection: {
1739
+ anchor: 0,
1740
+ head: e.doc.length
1741
+ },
1742
+ userEvent: "select"
1743
+ })), !0), Ir = ({ state: e, dispatch: t }) => {
1744
+ let n = ei(e).map(({ from: t, to: n }) => g.undirectionalRange(t, Math.min(n + 1, e.doc.length)));
1745
+ return t(e.update({
1746
+ selection: g.create(n),
1747
+ userEvent: "select"
1748
+ })), !0;
1749
+ }, Lr = ({ state: e, dispatch: t }) => {
1750
+ let n = U(e.selection, (t) => {
1751
+ let n = x(e), r = n.resolveStack(t.from, 1);
1752
+ if (t.empty) {
1753
+ let e = n.resolveStack(t.from, -1);
1754
+ e.node.from >= r.node.from && e.node.to <= r.node.to && (r = e);
1755
+ }
1756
+ for (let e = r; e; e = e.next) {
1757
+ let { node: n } = e;
1758
+ if ((n.from < t.from && n.to >= t.to || n.to > t.to && n.from <= t.from) && e.next) return g.undirectionalRange(n.from, n.to);
1759
+ }
1760
+ return t;
1761
+ });
1762
+ return !n.eq(e.selection) && (t(W(e, n)), !0);
1763
+ };
1764
+ function Rr(e, t) {
1765
+ let { state: n } = e, r = n.selection, i = n.selection.ranges.slice();
1766
+ for (let r of n.selection.ranges) {
1767
+ let a = n.doc.lineAt(r.head);
1768
+ if (t ? a.to < e.state.doc.length : a.from > 0) for (let n = r;;) {
1769
+ let r = e.moveVertically(n, t);
1770
+ if (r.head < a.from || r.head > a.to) {
1771
+ i.some((e) => e.head == r.head) || i.push(r);
1772
+ break;
1773
+ }
1774
+ if (r.head == n.head) break;
1775
+ n = r;
1776
+ }
1777
+ }
1778
+ return i.length != r.ranges.length && (e.dispatch(W(n, g.create(i, i.length - 1))), !0);
1779
+ }
1780
+ var zr = (e) => Rr(e, !1), Br = (e) => Rr(e, !0), Vr = ({ state: e, dispatch: t }) => {
1781
+ let n = e.selection, r = null;
1782
+ return n.ranges.length > 1 ? r = g.create([n.main]) : n.main.empty || (r = g.create([g.cursor(n.main.head)])), r ? (t(W(e, r)), !0) : !1;
1783
+ };
1784
+ function Y(e, t) {
1785
+ if (e.state.readOnly) return !1;
1786
+ let n = "delete.selection", { state: r } = e, i = r.changeByRange((r) => {
1787
+ let { from: i, to: a } = r;
1788
+ if (i == a) {
1789
+ let o = t(r);
1790
+ o < i ? (n = "delete.backward", o = Hr(e, o, !1)) : o > i && (n = "delete.forward", o = Hr(e, o, !0)), i = Math.min(i, o), a = Math.max(a, o);
1791
+ } else i = Hr(e, i, !1), a = Hr(e, a, !0);
1792
+ return i == a ? { range: r } : {
1793
+ changes: {
1794
+ from: i,
1795
+ to: a
1796
+ },
1797
+ range: g.cursor(i, i < r.head ? -1 : 1)
1798
+ };
1799
+ });
1800
+ return !i.changes.empty && (e.dispatch(r.update(i, {
1801
+ scrollIntoView: !0,
1802
+ userEvent: n,
1803
+ effects: n == "delete.selection" ? p.announce.of(r.phrase("Selection deleted")) : void 0
1804
+ })), !0);
1805
+ }
1806
+ function Hr(e, t, n) {
1807
+ if (e instanceof p) for (let r of e.state.facet(p.atomicRanges).map((t) => t(e))) r.between(t, t, (e, r) => {
1808
+ e < t && r > t && (t = n ? r : e);
1809
+ });
1810
+ return t;
1811
+ }
1812
+ var Ur = (e, t, n) => Y(e, (r) => {
1813
+ let i = r.from, { state: a } = e, o = a.doc.lineAt(i), s, c;
1814
+ if (n && !t && i > o.from && i < o.from + 200 && !/[^ \t]/.test(s = o.text.slice(0, i - o.from))) {
1815
+ if (s[s.length - 1] == " ") return i - 1;
1816
+ let e = de(s, a.tabSize) % Ee(a) || Ee(a);
1817
+ for (let t = 0; t < e && s[s.length - 1 - t] == " "; t++) i--;
1818
+ c = i;
1819
+ } else c = w(o.text, i - o.from, t, t) + o.from, c == i && o.number != (t ? a.doc.lines : 1) ? c += t ? 1 : -1 : !t && /[\ufe00-\ufe0f]/.test(o.text.slice(c - o.from, i - o.from)) && (c = w(o.text, c - o.from, !1, !1) + o.from);
1820
+ return c;
1821
+ }), Wr = (e) => Ur(e, !1, !0), Gr = (e) => Ur(e, !0, !1), Kr = (e, t) => Y(e, (n) => {
1822
+ let r = n.head, { state: i } = e, a = i.doc.lineAt(r), o = i.charCategorizer(r);
1823
+ for (let e = null;;) {
1824
+ if (r == (t ? a.to : a.from)) {
1825
+ r == n.head && a.number != (t ? i.doc.lines : 1) && (r += t ? 1 : -1);
1826
+ break;
1827
+ }
1828
+ let s = w(a.text, r - a.from, t) + a.from, c = a.text.slice(Math.min(r, s) - a.from, Math.max(r, s) - a.from), l = o(c);
1829
+ if (e != null && l != e) break;
1830
+ (c != " " || r != n.head) && (e = l), r = s;
1831
+ }
1832
+ return r;
1833
+ }), qr = (e) => Kr(e, !1), Jr = (e) => Kr(e, !0), Yr = (e) => Y(e, (t) => {
1834
+ let n = e.lineBlockAt(t.head).to;
1835
+ return t.head < n ? n : Math.min(e.state.doc.length, t.head + 1);
1836
+ }), Xr = (e) => Y(e, (t) => {
1837
+ let n = e.moveToLineBoundary(t, !1).head;
1838
+ return t.head > n ? n : Math.max(0, t.head - 1);
1839
+ }), Zr = (e) => Y(e, (t) => {
1840
+ let n = e.moveToLineBoundary(t, !0).head;
1841
+ return t.head < n ? n : Math.min(e.state.doc.length, t.head + 1);
1842
+ }), Qr = ({ state: e, dispatch: t }) => {
1843
+ if (e.readOnly) return !1;
1844
+ let n = e.changeByRange((e) => ({
1845
+ changes: {
1846
+ from: e.from,
1847
+ to: e.to,
1848
+ insert: Se.of(["", ""])
1849
+ },
1850
+ range: g.cursor(e.from)
1851
+ }));
1852
+ return t(e.update(n, {
1853
+ scrollIntoView: !0,
1854
+ userEvent: "input"
1855
+ })), !0;
1856
+ }, $r = ({ state: e, dispatch: t }) => {
1857
+ if (e.readOnly) return !1;
1858
+ let n = e.changeByRange((t) => {
1859
+ if (!t.empty || t.from == 0 || t.from == e.doc.length) return { range: t };
1860
+ let n = t.from, r = e.doc.lineAt(n), i = n == r.from ? n - 1 : w(r.text, n - r.from, !1) + r.from, a = n == r.to ? n + 1 : w(r.text, n - r.from, !0) + r.from;
1861
+ return {
1862
+ changes: {
1863
+ from: i,
1864
+ to: a,
1865
+ insert: e.doc.slice(n, a).append(e.doc.slice(i, n))
1866
+ },
1867
+ range: g.cursor(a)
1868
+ };
1869
+ });
1870
+ return !n.changes.empty && (t(e.update(n, {
1871
+ scrollIntoView: !0,
1872
+ userEvent: "move.character"
1873
+ })), !0);
1874
+ };
1875
+ function ei(e) {
1876
+ let t = [], n = -1;
1877
+ for (let r of e.selection.ranges) {
1878
+ let i = e.doc.lineAt(r.from), a = e.doc.lineAt(r.to);
1879
+ if (!r.empty && r.to == a.from && (a = e.doc.lineAt(r.to - 1)), n >= i.number) {
1880
+ let e = t[t.length - 1];
1881
+ e.to = a.to, e.ranges.push(r);
1882
+ } else t.push({
1883
+ from: i.from,
1884
+ to: a.to,
1885
+ ranges: [r]
1886
+ });
1887
+ n = a.number + 1;
1888
+ }
1889
+ return t;
1890
+ }
1891
+ function ti(e, t, n) {
1892
+ if (e.readOnly) return !1;
1893
+ let r = [], i = [];
1894
+ for (let t of ei(e)) {
1895
+ if (n ? t.to == e.doc.length : t.from == 0) continue;
1896
+ let a = e.doc.lineAt(n ? t.to + 1 : t.from - 1), o = a.length + 1;
1897
+ if (n) {
1898
+ r.push({
1899
+ from: t.to,
1900
+ to: a.to
1901
+ }, {
1902
+ from: t.from,
1903
+ insert: a.text + e.lineBreak
1904
+ });
1905
+ for (let n of t.ranges) i.push(g.range(Math.min(e.doc.length, n.anchor + o), Math.min(e.doc.length, n.head + o)));
1906
+ } else {
1907
+ r.push({
1908
+ from: a.from,
1909
+ to: t.from
1910
+ }, {
1911
+ from: t.to,
1912
+ insert: e.lineBreak + a.text
1913
+ });
1914
+ for (let e of t.ranges) i.push(g.range(e.anchor - o, e.head - o));
1915
+ }
1916
+ }
1917
+ return r.length ? (t(e.update({
1918
+ changes: r,
1919
+ scrollIntoView: !0,
1920
+ selection: g.create(i, e.selection.mainIndex),
1921
+ userEvent: "move.line"
1922
+ })), !0) : !1;
1923
+ }
1924
+ var ni = ({ state: e, dispatch: t }) => ti(e, t, !1), ri = ({ state: e, dispatch: t }) => ti(e, t, !0);
1925
+ function ii(e, t, n) {
1926
+ if (e.readOnly) return !1;
1927
+ let r = [];
1928
+ for (let t of ei(e)) n ? r.push({
1929
+ from: t.from,
1930
+ insert: e.doc.slice(t.from, t.to) + e.lineBreak
1931
+ }) : r.push({
1932
+ from: t.to,
1933
+ insert: e.lineBreak + e.doc.slice(t.from, t.to)
1934
+ });
1935
+ let i = e.changes(r);
1936
+ return t(e.update({
1937
+ changes: i,
1938
+ selection: e.selection.map(i, n ? 1 : -1),
1939
+ scrollIntoView: !0,
1940
+ userEvent: "input.copyline"
1941
+ })), !0;
1942
+ }
1943
+ var ai = ({ state: e, dispatch: t }) => ii(e, t, !1), oi = ({ state: e, dispatch: t }) => ii(e, t, !0), si = (e) => {
1944
+ if (e.state.readOnly) return !1;
1945
+ let { state: t } = e, n = t.changes(ei(t).map(({ from: e, to: n }) => (e > 0 ? e-- : n < t.doc.length && n++, {
1946
+ from: e,
1947
+ to: n
1948
+ }))), r = U(t.selection, (t) => {
1949
+ let n;
1950
+ if (e.lineWrapping) {
1951
+ let r = e.lineBlockAt(t.head), i = e.coordsAtPos(t.head, t.assoc || 1);
1952
+ i && (n = r.bottom + e.documentTop - i.bottom + e.defaultLineHeight / 2);
1953
+ }
1954
+ return e.moveVertically(t, !0, n);
1955
+ }).map(n);
1956
+ return e.dispatch({
1957
+ changes: n,
1958
+ selection: r,
1959
+ scrollIntoView: !0,
1960
+ userEvent: "delete.line"
1961
+ }), !0;
1962
+ };
1963
+ function ci(e, t) {
1964
+ if (/\(\)|\[\]|\{\}/.test(e.sliceDoc(t - 1, t + 1))) return {
1965
+ from: t,
1966
+ to: t
1967
+ };
1968
+ let n = x(e).resolveInner(t), r = n.childBefore(t), i = n.childAfter(t), a;
1969
+ return r && i && r.to <= t && i.from >= t && (a = r.type.prop(Te.closedBy)) && a.indexOf(i.name) > -1 && e.doc.lineAt(r.to).from == e.doc.lineAt(i.from).from && !/\S/.test(e.sliceDoc(r.to, i.from)) ? {
1970
+ from: r.to,
1971
+ to: i.from
1972
+ } : null;
1973
+ }
1974
+ var li = /*@__PURE__*/ di(!1), ui = /*@__PURE__*/ di(!0);
1975
+ function di(e) {
1976
+ return ({ state: t, dispatch: n }) => {
1977
+ if (t.readOnly) return !1;
1978
+ let r = t.changeByRange((n) => {
1979
+ let { from: r, to: a } = n, o = t.doc.lineAt(r), s = !e && r == a && ci(t, r);
1980
+ e && (r = a = (a <= o.to ? o : t.doc.lineAt(a)).to);
1981
+ let c = new Ce(t, {
1982
+ simulateBreak: r,
1983
+ simulateDoubleBreak: !!s
1984
+ }), l = se(c, r);
1985
+ for (l ??= de(/^\s*/.exec(t.doc.lineAt(r).text)[0], t.tabSize); a < o.to && /\s/.test(o.text[a - o.from]);) a++;
1986
+ s ? {from: r, to: a} = s : r > o.from && r < o.from + 100 && !/\S/.test(o.text.slice(0, r)) && (r = o.from);
1987
+ let u = ["", i(t, l)];
1988
+ return s && u.push(i(t, c.lineIndent(o.from, -1))), {
1989
+ changes: {
1990
+ from: r,
1991
+ to: a,
1992
+ insert: Se.of(u)
1993
+ },
1994
+ range: g.cursor(r + 1 + u[1].length)
1995
+ };
1996
+ });
1997
+ return n(t.update(r, {
1998
+ scrollIntoView: !0,
1999
+ userEvent: "input"
2000
+ })), !0;
2001
+ };
2002
+ }
2003
+ function fi(e, t) {
2004
+ let n = -1;
2005
+ return e.changeByRange((r) => {
2006
+ let i = [];
2007
+ for (let a = r.from; a <= r.to;) {
2008
+ let o = e.doc.lineAt(a);
2009
+ o.number > n && (r.empty || r.to > o.from) && (t(o, i, r), n = o.number), a = o.to + 1;
2010
+ }
2011
+ let a = e.changes(i);
2012
+ return {
2013
+ changes: i,
2014
+ range: g.range(a.mapPos(r.anchor, 1), a.mapPos(r.head, 1))
2015
+ };
2016
+ });
2017
+ }
2018
+ var pi = ({ state: e, dispatch: t }) => {
2019
+ if (e.readOnly) return !1;
2020
+ let n = Object.create(null), r = new Ce(e, { overrideIndentation: (e) => n[e] ?? -1 }), a = fi(e, (t, a, o) => {
2021
+ let s = se(r, t.from);
2022
+ if (s == null) return;
2023
+ /\S/.test(t.text) || (s = 0);
2024
+ let c = /^\s*/.exec(t.text)[0], l = i(e, s);
2025
+ (c != l || o.from < t.from + c.length) && (n[t.from] = s, a.push({
2026
+ from: t.from,
2027
+ to: t.from + c.length,
2028
+ insert: l
2029
+ }));
2030
+ });
2031
+ return a.changes.empty || t(e.update(a, { userEvent: "indent" })), !0;
2032
+ }, mi = ({ state: e, dispatch: t }) => !e.readOnly && (t(e.update(fi(e, (t, n) => {
2033
+ n.push({
2034
+ from: t.from,
2035
+ insert: e.facet(E)
2036
+ });
2037
+ }), { userEvent: "input.indent" })), !0), hi = ({ state: e, dispatch: t }) => !e.readOnly && (t(e.update(fi(e, (t, n) => {
2038
+ let r = /^\s*/.exec(t.text)[0];
2039
+ if (!r) return;
2040
+ let a = de(r, e.tabSize), o = 0, s = i(e, Math.max(0, a - Ee(e)));
2041
+ for (; o < r.length && o < s.length && r.charCodeAt(o) == s.charCodeAt(o);) o++;
2042
+ n.push({
2043
+ from: t.from + o,
2044
+ to: t.from + r.length,
2045
+ insert: s.slice(o)
2046
+ });
2047
+ }), { userEvent: "delete.dedent" })), !0), gi = (e) => (e.setTabFocusMode(), !0), _i = [
2048
+ {
2049
+ key: "Ctrl-b",
2050
+ run: Vn,
2051
+ shift: fr,
2052
+ preventDefault: !0
2053
+ },
2054
+ {
2055
+ key: "Ctrl-f",
2056
+ run: Hn,
2057
+ shift: pr
2058
+ },
2059
+ {
2060
+ key: "Ctrl-p",
2061
+ run: Zn,
2062
+ shift: br
2063
+ },
2064
+ {
2065
+ key: "Ctrl-n",
2066
+ run: Qn,
2067
+ shift: xr
2068
+ },
2069
+ {
2070
+ key: "Ctrl-a",
2071
+ run: sr,
2072
+ shift: kr
2073
+ },
2074
+ {
2075
+ key: "Ctrl-e",
2076
+ run: cr,
2077
+ shift: Ar
2078
+ },
2079
+ {
2080
+ key: "Ctrl-d",
2081
+ run: Gr
2082
+ },
2083
+ {
2084
+ key: "Ctrl-h",
2085
+ run: Wr
2086
+ },
2087
+ {
2088
+ key: "Ctrl-k",
2089
+ run: Yr
2090
+ },
2091
+ {
2092
+ key: "Ctrl-Alt-h",
2093
+ run: qr
2094
+ },
2095
+ {
2096
+ key: "Ctrl-o",
2097
+ run: Qr
2098
+ },
2099
+ {
2100
+ key: "Ctrl-t",
2101
+ run: $r
2102
+ },
2103
+ {
2104
+ key: "Ctrl-v",
2105
+ run: nr
2106
+ }
2107
+ ], vi = /*@__PURE__*/ [
2108
+ {
2109
+ key: "ArrowLeft",
2110
+ run: Vn,
2111
+ shift: fr,
2112
+ preventDefault: !0
2113
+ },
2114
+ {
2115
+ key: "Mod-ArrowLeft",
2116
+ mac: "Alt-ArrowLeft",
2117
+ run: Wn,
2118
+ shift: hr,
2119
+ preventDefault: !0
2120
+ },
2121
+ {
2122
+ mac: "Cmd-ArrowLeft",
2123
+ run: ar,
2124
+ shift: Dr,
2125
+ preventDefault: !0
2126
+ },
2127
+ {
2128
+ key: "ArrowRight",
2129
+ run: Hn,
2130
+ shift: pr,
2131
+ preventDefault: !0
2132
+ },
2133
+ {
2134
+ key: "Mod-ArrowRight",
2135
+ mac: "Alt-ArrowRight",
2136
+ run: Gn,
2137
+ shift: gr,
2138
+ preventDefault: !0
2139
+ },
2140
+ {
2141
+ mac: "Cmd-ArrowRight",
2142
+ run: or,
2143
+ shift: Or,
2144
+ preventDefault: !0
2145
+ },
2146
+ {
2147
+ key: "ArrowUp",
2148
+ run: Zn,
2149
+ shift: br,
2150
+ preventDefault: !0
2151
+ },
2152
+ {
2153
+ mac: "Cmd-ArrowUp",
2154
+ run: jr,
2155
+ shift: Nr
2156
+ },
2157
+ {
2158
+ mac: "Ctrl-ArrowUp",
2159
+ run: tr,
2160
+ shift: Cr
2161
+ },
2162
+ {
2163
+ key: "ArrowDown",
2164
+ run: Qn,
2165
+ shift: xr,
2166
+ preventDefault: !0
2167
+ },
2168
+ {
2169
+ mac: "Cmd-ArrowDown",
2170
+ run: Mr,
2171
+ shift: Pr
2172
+ },
2173
+ {
2174
+ mac: "Ctrl-ArrowDown",
2175
+ run: nr,
2176
+ shift: wr
2177
+ },
2178
+ {
2179
+ key: "PageUp",
2180
+ run: tr,
2181
+ shift: Cr
2182
+ },
2183
+ {
2184
+ key: "PageDown",
2185
+ run: nr,
2186
+ shift: wr
2187
+ },
2188
+ {
2189
+ key: "Home",
2190
+ run: ir,
2191
+ shift: Er,
2192
+ preventDefault: !0
2193
+ },
2194
+ {
2195
+ key: "Mod-Home",
2196
+ run: jr,
2197
+ shift: Nr
2198
+ },
2199
+ {
2200
+ key: "End",
2201
+ run: rr,
2202
+ shift: Tr,
2203
+ preventDefault: !0
2204
+ },
2205
+ {
2206
+ key: "Mod-End",
2207
+ run: Mr,
2208
+ shift: Pr
2209
+ },
2210
+ {
2211
+ key: "Enter",
2212
+ run: li,
2213
+ shift: li
2214
+ },
2215
+ {
2216
+ key: "Mod-a",
2217
+ run: Fr
2218
+ },
2219
+ {
2220
+ key: "Backspace",
2221
+ run: Wr,
2222
+ shift: Wr,
2223
+ preventDefault: !0
2224
+ },
2225
+ {
2226
+ key: "Delete",
2227
+ run: Gr,
2228
+ preventDefault: !0
2229
+ },
2230
+ {
2231
+ key: "Mod-Backspace",
2232
+ mac: "Alt-Backspace",
2233
+ run: qr,
2234
+ preventDefault: !0
2235
+ },
2236
+ {
2237
+ key: "Mod-Delete",
2238
+ mac: "Alt-Delete",
2239
+ run: Jr,
2240
+ preventDefault: !0
2241
+ },
2242
+ {
2243
+ mac: "Mod-Backspace",
2244
+ run: Xr,
2245
+ preventDefault: !0
2246
+ },
2247
+ {
2248
+ mac: "Mod-Delete",
2249
+ run: Zr,
2250
+ preventDefault: !0
2251
+ }
2252
+ ].concat(/*@__PURE__*/ _i.map((e) => ({
2253
+ mac: e.key,
2254
+ run: e.run,
2255
+ shift: e.shift
2256
+ }))), yi = /*@__PURE__*/ [
2257
+ {
2258
+ key: "Alt-ArrowLeft",
2259
+ mac: "Ctrl-ArrowLeft",
2260
+ run: Jn,
2261
+ shift: _r
2262
+ },
2263
+ {
2264
+ key: "Alt-ArrowRight",
2265
+ mac: "Ctrl-ArrowRight",
2266
+ run: Yn,
2267
+ shift: vr
2268
+ },
2269
+ {
2270
+ key: "Alt-ArrowUp",
2271
+ run: ni
2272
+ },
2273
+ {
2274
+ key: "Shift-Alt-ArrowUp",
2275
+ run: ai
2276
+ },
2277
+ {
2278
+ key: "Alt-ArrowDown",
2279
+ run: ri
2280
+ },
2281
+ {
2282
+ key: "Shift-Alt-ArrowDown",
2283
+ run: oi
2284
+ },
2285
+ {
2286
+ key: "Mod-Alt-ArrowUp",
2287
+ run: zr
2288
+ },
2289
+ {
2290
+ key: "Mod-Alt-ArrowDown",
2291
+ run: Br
2292
+ },
2293
+ {
2294
+ key: "Escape",
2295
+ run: Vr
2296
+ },
2297
+ {
2298
+ key: "Mod-Enter",
2299
+ run: ui
2300
+ },
2301
+ {
2302
+ key: "Alt-l",
2303
+ mac: "Ctrl-l",
2304
+ run: Ir
2305
+ },
2306
+ {
2307
+ key: "Mod-i",
2308
+ run: Lr,
2309
+ preventDefault: !0
2310
+ },
2311
+ {
2312
+ key: "Mod-[",
2313
+ run: hi
2314
+ },
2315
+ {
2316
+ key: "Mod-]",
2317
+ run: mi
2318
+ },
2319
+ {
2320
+ key: "Mod-Alt-\\",
2321
+ run: pi
2322
+ },
2323
+ {
2324
+ key: "Shift-Mod-k",
2325
+ run: si
2326
+ },
2327
+ {
2328
+ key: "Shift-Mod-\\",
2329
+ run: ur
2330
+ },
2331
+ {
2332
+ key: "Mod-/",
2333
+ run: ln
2334
+ },
2335
+ {
2336
+ key: "Alt-A",
2337
+ mac: "Ctrl-A",
2338
+ run: fn
2339
+ },
2340
+ {
2341
+ key: "Ctrl-m",
2342
+ mac: "Shift-Alt-m",
2343
+ run: gi
2344
+ }
2345
+ ].concat(vi), bi = typeof String.prototype.normalize == "function" ? (e) => e.normalize("NFKD") : (e) => e, xi = class {
2346
+ constructor(e, t, n = 0, r = e.length, i, a) {
2347
+ this.test = a, this.value = {
2348
+ from: 0,
2349
+ to: 0,
2350
+ precise: !1
2351
+ }, this.done = !1, this.matches = [], this.buffer = "", this.bufferPos = 0, this.iter = e.iterRange(n, r), this.bufferStart = n, this.normalize = i ? (e) => i(bi(e)) : bi, this.query = this.normalize(t);
2352
+ }
2353
+ peek() {
2354
+ if (this.bufferPos == this.buffer.length) {
2355
+ if (this.bufferStart += this.buffer.length, this.iter.next(), this.iter.done) return -1;
2356
+ this.bufferPos = 0, this.buffer = this.iter.value;
2357
+ }
2358
+ return S(this.buffer, this.bufferPos);
2359
+ }
2360
+ next() {
2361
+ for (; this.matches.length;) this.matches.pop();
2362
+ return this.nextOverlapping();
2363
+ }
2364
+ nextOverlapping() {
2365
+ for (;;) {
2366
+ let e = this.peek();
2367
+ if (e < 0) return this.done = !0, this;
2368
+ let t = _e(e), n = this.bufferStart + this.bufferPos;
2369
+ this.bufferPos += T(e);
2370
+ let r = this.normalize(t);
2371
+ if (r.length) for (let e = 0, i = n, a = !0;; e++) {
2372
+ let n = r.charCodeAt(e), o = this.match(n, i, a, this.bufferPos + this.bufferStart, e == r.length - 1);
2373
+ if (o) return this.value = o, this;
2374
+ if (e == r.length - 1) break;
2375
+ a && e < t.length && t.charCodeAt(e) == n ? i++ : a = !1;
2376
+ }
2377
+ }
2378
+ }
2379
+ match(e, t, n, r, i) {
2380
+ let a = null;
2381
+ for (let t = 0; t < this.matches.length;) {
2382
+ let n = this.matches[t], o = !1;
2383
+ this.query.charCodeAt(n.index) == e && (n.index == this.query.length - 1 ? a = {
2384
+ from: n.from,
2385
+ to: r,
2386
+ precise: i && n.precise
2387
+ } : (n.index++, o = !0)), o ? t++ : this.matches.splice(t, 1);
2388
+ }
2389
+ return this.query.charCodeAt(0) == e && (this.query.length == 1 ? a = {
2390
+ from: t,
2391
+ to: r,
2392
+ precise: n && i
2393
+ } : this.matches.push({
2394
+ from: t,
2395
+ index: 1,
2396
+ precise: n
2397
+ })), a && this.test && !this.test(a.from, a.to, this.buffer, this.bufferStart) && (a = null), a;
2398
+ }
2399
+ };
2400
+ typeof Symbol < "u" && (xi.prototype[Symbol.iterator] = function() {
2401
+ return this;
2402
+ });
2403
+ var Si = {
2404
+ from: -1,
2405
+ to: -1,
2406
+ match: /*@__PURE__*/ /.*/.exec(""),
2407
+ precise: !0
2408
+ }, Ci = "gm" + (/x/.unicode == null ? "" : "u"), wi = class {
2409
+ constructor(e, t, n, r = 0, i = e.length) {
2410
+ if (this.text = e, this.to = i, this.curLine = "", this.done = !1, this.value = Si, /\\[sWDnr]|\n|\r|\[\^/.test(t)) return new Di(e, t, n, r, i);
2411
+ this.re = new RegExp(t, Ci + (n?.ignoreCase ? "i" : "")), this.test = n?.test, this.iter = e.iter();
2412
+ let a = e.lineAt(r);
2413
+ this.curLineStart = a.from, this.matchPos = Oi(e, r), this.getLine(this.curLineStart);
2414
+ }
2415
+ getLine(e) {
2416
+ 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());
2417
+ }
2418
+ nextLine() {
2419
+ this.curLineStart = this.curLineStart + this.curLine.length + 1, this.curLineStart > this.to ? this.curLine = "" : this.getLine(0);
2420
+ }
2421
+ next() {
2422
+ for (let e = this.matchPos - this.curLineStart;;) {
2423
+ this.re.lastIndex = e;
2424
+ let t = this.matchPos <= this.to && this.re.exec(this.curLine);
2425
+ if (t) {
2426
+ let n = this.curLineStart + t.index, r = n + t[0].length;
2427
+ if (this.matchPos = Oi(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 = {
2428
+ from: n,
2429
+ to: r,
2430
+ precise: !0,
2431
+ match: t
2432
+ }, this;
2433
+ e = this.matchPos - this.curLineStart;
2434
+ } else if (this.curLineStart + this.curLine.length < this.to) this.nextLine(), e = 0;
2435
+ else return this.done = !0, this;
2436
+ }
2437
+ }
2438
+ }, Ti = /*@__PURE__*/ new WeakMap(), Ei = class e {
2439
+ constructor(e, t) {
2440
+ this.from = e, this.text = t;
2441
+ }
2442
+ get to() {
2443
+ return this.from + this.text.length;
2444
+ }
2445
+ static get(t, n, r) {
2446
+ let i = Ti.get(t);
2447
+ if (!i || i.from >= r || i.to <= n) {
2448
+ let i = new e(n, t.sliceString(n, r));
2449
+ return Ti.set(t, i), i;
2450
+ }
2451
+ if (i.from == n && i.to == r) return i;
2452
+ let { text: a, from: o } = i;
2453
+ return o > n && (a = t.sliceString(n, o) + a, o = n), i.to < r && (a += t.sliceString(i.to, r)), Ti.set(t, new e(o, a)), new e(n, a.slice(n - o, r - o));
2454
+ }
2455
+ }, Di = class {
2456
+ constructor(e, t, n, r, i) {
2457
+ this.text = e, this.to = i, this.done = !1, this.value = Si, this.matchPos = Oi(e, r), this.re = new RegExp(t, Ci + (n?.ignoreCase ? "i" : "")), this.test = n?.test, this.flat = Ei.get(e, r, this.chunkEnd(r + 5e3));
2458
+ }
2459
+ chunkEnd(e) {
2460
+ return e >= this.to ? this.to : this.text.lineAt(e).to;
2461
+ }
2462
+ next() {
2463
+ for (;;) {
2464
+ let e = this.re.lastIndex = this.matchPos - this.flat.from, t = this.re.exec(this.flat.text);
2465
+ if (t && !t[0] && t.index == e && (this.re.lastIndex = e + 1, t = this.re.exec(this.flat.text)), t) {
2466
+ let e = this.flat.from + t.index, n = e + t[0].length;
2467
+ 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 = {
2468
+ from: e,
2469
+ to: n,
2470
+ precise: !0,
2471
+ match: t
2472
+ }, this.matchPos = Oi(this.text, n + +(e == n)), this;
2473
+ }
2474
+ if (this.flat.to == this.to) return this.done = !0, this;
2475
+ this.flat = Ei.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
2476
+ }
2477
+ }
2478
+ };
2479
+ typeof Symbol < "u" && (wi.prototype[Symbol.iterator] = Di.prototype[Symbol.iterator] = function() {
2480
+ return this;
2481
+ });
2482
+ function Oi(e, t) {
2483
+ if (t >= e.length) return t;
2484
+ let n = e.lineAt(t), r;
2485
+ for (; t < n.to && (r = n.text.charCodeAt(t - n.from)) >= 56320 && r < 57344;) t++;
2486
+ return t;
2487
+ }
2488
+ var ki = {
2489
+ highlightWordAroundCursor: !1,
2490
+ minSelectionLength: 1,
2491
+ maxMatches: 100,
2492
+ wholeWords: !1
2493
+ }, Ai = /*@__PURE__*/ b.define({ combine(e) {
2494
+ return ue(e, ki, {
2495
+ highlightWordAroundCursor: (e, t) => e || t,
2496
+ minSelectionLength: Math.min,
2497
+ maxMatches: Math.min
2498
+ });
2499
+ } });
2500
+ function ji(e) {
2501
+ let t = [Li, Ii];
2502
+ return e && t.push(Ai.of(e)), t;
2503
+ }
2504
+ var Mi = /*@__PURE__*/ n.mark({ class: "cm-selectionMatch" }), Ni = /*@__PURE__*/ n.mark({ class: "cm-selectionMatch cm-selectionMatch-main" });
2505
+ function Pi(e, t, n, r) {
2506
+ return (n == 0 || e(t.sliceDoc(n - 1, n)) != v.Word) && (r == t.doc.length || e(t.sliceDoc(r, r + 1)) != v.Word);
2507
+ }
2508
+ function Fi(e, t, n, r) {
2509
+ return e(t.sliceDoc(n, n + 1)) == v.Word && e(t.sliceDoc(r - 1, r)) == v.Word;
2510
+ }
2511
+ var Ii = /*@__PURE__*/ m.fromClass(class {
2512
+ constructor(e) {
2513
+ this.decorations = this.getDeco(e);
2514
+ }
2515
+ update(e) {
2516
+ (e.selectionSet || e.docChanged || e.viewportChanged) && (this.decorations = this.getDeco(e.view));
2517
+ }
2518
+ getDeco(e) {
2519
+ let t = e.state.facet(Ai), { state: r } = e, i = r.selection;
2520
+ if (i.ranges.length > 1) return n.none;
2521
+ let a = i.main, o, s = null;
2522
+ if (a.empty) {
2523
+ if (!t.highlightWordAroundCursor) return n.none;
2524
+ let e = r.wordAt(a.head);
2525
+ if (!e) return n.none;
2526
+ s = r.charCategorizer(a.head), o = r.sliceDoc(e.from, e.to);
2527
+ } else {
2528
+ let e = a.to - a.from;
2529
+ if (e < t.minSelectionLength || e > 200) return n.none;
2530
+ if (t.wholeWords) {
2531
+ if (o = r.sliceDoc(a.from, a.to), s = r.charCategorizer(a.head), !(Pi(s, r, a.from, a.to) && Fi(s, r, a.from, a.to))) return n.none;
2532
+ } else if (o = r.sliceDoc(a.from, a.to), !o) return n.none;
2533
+ }
2534
+ let c = [];
2535
+ for (let i of e.visibleRanges) {
2536
+ let e = new xi(r.doc, o, i.from, i.to);
2537
+ for (; !e.next().done;) {
2538
+ let { from: i, to: o } = e.value;
2539
+ if ((!s || Pi(s, r, i, o)) && (a.empty && i <= a.from && o >= a.to ? c.push(Ni.range(i, o)) : (i >= a.to || o <= a.from) && c.push(Mi.range(i, o)), c.length > t.maxMatches)) return n.none;
2540
+ }
2541
+ }
2542
+ return n.set(c);
2543
+ }
2544
+ }, { decorations: (e) => e.decorations }), Li = /*@__PURE__*/ p.baseTheme({
2545
+ ".cm-selectionMatch": { backgroundColor: "#99ff7780" },
2546
+ ".cm-searchMatch .cm-selectionMatch": { backgroundColor: "transparent" }
2547
+ }), Ri = ({ state: e, dispatch: t }) => {
2548
+ let { selection: n } = e, r = g.create(n.ranges.map((t) => e.wordAt(t.head) || g.cursor(t.head)), n.mainIndex);
2549
+ return !r.eq(n) && (t(e.update({ selection: r })), !0);
2550
+ };
2551
+ function zi(e, t) {
2552
+ let { main: n, ranges: r } = e.selection, i = e.wordAt(n.head), a = i && i.from == n.from && i.to == n.to;
2553
+ for (let n = !1, i = new xi(e.doc, t, r[r.length - 1].to);;) if (i.next(), i.done) {
2554
+ if (n) return null;
2555
+ i = new xi(e.doc, t, 0, Math.max(0, r[r.length - 1].from - 1)), n = !0;
2556
+ } else {
2557
+ if (n && r.some((e) => e.from == i.value.from)) continue;
2558
+ if (a) {
2559
+ let t = e.wordAt(i.value.from);
2560
+ if (!t || t.from != i.value.from || t.to != i.value.to) continue;
2561
+ }
2562
+ return i.value;
2563
+ }
2564
+ }
2565
+ var Bi = ({ state: e, dispatch: t }) => {
2566
+ let { ranges: n } = e.selection;
2567
+ if (n.some((e) => e.from === e.to)) return Ri({
2568
+ state: e,
2569
+ dispatch: t
2570
+ });
2571
+ let r = e.sliceDoc(n[0].from, n[0].to);
2572
+ if (e.selection.ranges.some((t) => e.sliceDoc(t.from, t.to) != r)) return !1;
2573
+ let i = zi(e, r);
2574
+ return i ? (t(e.update({
2575
+ selection: e.selection.addRange(g.range(i.from, i.to), !1),
2576
+ effects: p.scrollIntoView(i.to)
2577
+ })), !0) : !1;
2578
+ };
2579
+ //#endregion
2580
+ //#region ../ui/src/components/codeEditorLanguages.ts
2581
+ async function X(e) {
2582
+ return xe.define(await e());
2583
+ }
2584
+ var Vi = async () => (await import("./dist-Xjm88mbq.js").then((e) => e.t)).javascript({ typescript: !0 }), Hi = async () => (await import("./dist-Xjm88mbq.js").then((e) => e.t)).javascript({
2585
+ typescript: !0,
2586
+ jsx: !0
2587
+ }), Ui = async () => (await import("./dist-Xjm88mbq.js").then((e) => e.t)).javascript({ jsx: !0 }), Wi = async () => (await import("./dist-BBUKMRrs.js")).json(), Gi = async () => (await import("./dist-BWlGU9XM.js").then((e) => e.r)).css(), Ki = async () => (await import("./dist-BfQGuM1r.js")).html(), qi = async () => (await import("./dist-CA6ERWRG.js")).xml(), Ji = async () => (await import("./dist-CHKg1Qb9.js")).markdown(), Yi = async () => (await import("./dist-DZrtSp8H.js")).python(), Xi = async () => (await import("./dist-B0lO3k1f.js")).go(), Zi = async () => (await import("./dist-Bppoi_v9.js")).rust(), Qi = async () => (await import("./dist-FSzij9Rn.js")).java(), Z = async () => (await import("./dist-Dr4zY56l.js")).cpp(), $i = async () => (await import("./dist-qq9a_ch2.js")).php(), ea = async () => (await import("./dist-BhNvvg0I.js")).sql(), ta = async () => (await import("./dist-BlD6NhiG.js")).yaml(), na = () => X(async () => (await import("./shell-CevoiH_y.js")).shell), ra = () => X(async () => (await import("./dockerfile-4x0UkDoN.js")).dockerFile), ia = () => X(async () => (await import("./toml-CPJF62TK.js")).toml), Q = () => X(async () => (await import("./properties-C85NeSsH.js")).properties), aa = {
2588
+ ts: Vi,
2589
+ mts: Vi,
2590
+ cts: Vi,
2591
+ tsx: Hi,
2592
+ js: Ui,
2593
+ jsx: Ui,
2594
+ mjs: Ui,
2595
+ cjs: Ui,
2596
+ json: Wi,
2597
+ jsonc: Wi,
2598
+ css: Gi,
2599
+ scss: Gi,
2600
+ less: Gi,
2601
+ html: Ki,
2602
+ htm: Ki,
2603
+ xml: qi,
2604
+ svg: qi,
2605
+ md: Ji,
2606
+ markdown: Ji,
2607
+ py: Yi,
2608
+ go: Xi,
2609
+ rs: Zi,
2610
+ java: Qi,
2611
+ c: Z,
2612
+ h: Z,
2613
+ cpp: Z,
2614
+ cc: Z,
2615
+ cxx: Z,
2616
+ hpp: Z,
2617
+ php: $i,
2618
+ sql: ea,
2619
+ yaml: ta,
2620
+ yml: ta,
2621
+ sh: na,
2622
+ bash: na,
2623
+ zsh: na,
2624
+ toml: ia,
2625
+ ini: Q,
2626
+ cfg: Q,
2627
+ properties: Q,
2628
+ env: Q,
2629
+ rb: () => X(async () => (await import("./ruby-CjYBP7RB.js")).ruby),
2630
+ cs: () => X(async () => (await import("./clike-D-dOQnrm.js")).csharp)
2631
+ };
2632
+ function oa(e) {
2633
+ let t = e.split("/").pop() ?? e;
2634
+ if (/^dockerfile$/i.test(t)) return ra();
2635
+ if (/^\.env(\..+)?$/.test(t)) return Q();
2636
+ let n = t.lastIndexOf("."), r = n < 0 ? void 0 : aa[t.slice(n + 1).toLowerCase()];
2637
+ return r === void 0 ? Promise.resolve(null) : r();
2638
+ }
2639
+ //#endregion
2640
+ //#region ../ui/src/components/CodeEditor.tsx
2641
+ var sa = /* @__PURE__ */ e({
2642
+ CodeEditor: () => pa,
2643
+ detectIndentUnit: () => ua,
2644
+ documentPosition: () => $
2645
+ }), ca = y.define(), la = C.define({
2646
+ create: () => n.none,
2647
+ update(e, t) {
2648
+ for (let e of t.effects) if (e.is(ca)) return n.set(e.value.map(({ from: e, to: t, current: r }) => n.mark({ class: r ? "find-match-current" : "find-match" }).range(e, t)), !0);
2649
+ return e.map(t.changes);
2650
+ },
2651
+ provide: (e) => p.decorations.from(e)
2652
+ });
2653
+ function ua(e) {
2654
+ if (/^\t/m.test(e)) return " ";
2655
+ let t = [...e.matchAll(/^( +)\S/gm)].map((e) => e[1].length).filter((e) => e >= 2 && e <= 8);
2656
+ return " ".repeat(t.length === 0 ? 2 : Math.min(...t));
2657
+ }
2658
+ function $(e, t) {
2659
+ let n = 0;
2660
+ for (let r = e.indexOf("\r\n"); r !== -1 && r < t - 1; r = e.indexOf("\r\n", r + 2)) n++;
2661
+ return t - n;
2662
+ }
2663
+ var da = ({ state: e, dispatch: t }) => e.selection.ranges.some((e) => !e.empty) ? mi({
2664
+ state: e,
2665
+ dispatch: t
2666
+ }) : (t(e.update(e.replaceSelection(e.facet(E)), {
2667
+ scrollIntoView: !0,
2668
+ userEvent: "input"
2669
+ })), !0);
2670
+ function fa(e) {
2671
+ return [
2672
+ r(),
2673
+ wn(),
2674
+ f(),
2675
+ t.allowMultipleSelections.of(!0),
2676
+ te(),
2677
+ Ut(),
2678
+ on({ activateOnTyping: !1 }),
2679
+ s(),
2680
+ o(),
2681
+ De(),
2682
+ c.of([
2683
+ ...["Ctrl-s", "Meta-s"].map((t) => ({
2684
+ key: t,
2685
+ preventDefault: !0,
2686
+ run: () => (e.current.onSave?.(), !0)
2687
+ })),
2688
+ {
2689
+ key: "Mod-d",
2690
+ run: Bi,
2691
+ preventDefault: !0
2692
+ },
2693
+ ...Yt,
2694
+ ...yi,
2695
+ ...Rn,
2696
+ ...fe,
2697
+ ...sn,
2698
+ {
2699
+ key: "Tab",
2700
+ run: da,
2701
+ shift: hi,
2702
+ preventDefault: !0
2703
+ }
2704
+ ]),
2705
+ p.updateListener.of((t) => {
2706
+ t.docChanged && e.current.onChange?.(t.state.sliceDoc());
2707
+ })
2708
+ ];
2709
+ }
2710
+ function pa({ value: e, path: n, onChange: r, onSave: i, handle: a, readOnly: o = !1, label: s = o ? "File source" : "File editor" }) {
2711
+ let u = Ae(null), d = Ae(null), f = Ae({
2712
+ onChange: r,
2713
+ onSave: i
2714
+ });
2715
+ return f.current = {
2716
+ onChange: r,
2717
+ onSave: i
2718
+ }, ke(a, () => ({
2719
+ focus: () => d.current?.focus(),
2720
+ select(e, t) {
2721
+ let n = d.current;
2722
+ if (n === null) return;
2723
+ let r = n.state.sliceDoc(), i = n.state.doc.length, a = Math.min($(r, e), i), o = Math.min($(r, t), i);
2724
+ n.dispatch({
2725
+ selection: g.single(a, o),
2726
+ effects: p.scrollIntoView(a, { y: "center" })
2727
+ });
2728
+ },
2729
+ markMatches(e, t) {
2730
+ let n = d.current;
2731
+ if (n === null) return;
2732
+ let r = n.state.sliceDoc(), i = n.state.doc.length, a = e.map(({ start: e, end: n }, a) => ({
2733
+ from: Math.min($(r, e), i),
2734
+ to: Math.min($(r, n), i),
2735
+ current: a === t
2736
+ })).filter(({ from: e, to: t }) => e < t);
2737
+ n.dispatch({ effects: ca.of(a) });
2738
+ }
2739
+ })), Oe(() => {
2740
+ let r = new oe(), i = new p({
2741
+ parent: u.current,
2742
+ state: t.create({
2743
+ doc: e,
2744
+ extensions: [
2745
+ t.lineSeparator.of(e.includes("\r\n") ? "\r\n" : "\n"),
2746
+ E.of(ua(e)),
2747
+ ne(),
2748
+ re(),
2749
+ ge(),
2750
+ l(),
2751
+ ee(pe),
2752
+ ce(),
2753
+ ji(),
2754
+ la,
2755
+ p.lineWrapping,
2756
+ p.contentAttributes.of({
2757
+ "aria-label": s,
2758
+ spellcheck: "false"
2759
+ }),
2760
+ ...o ? [
2761
+ t.readOnly.of(!0),
2762
+ p.editable.of(!1),
2763
+ c.of(fe)
2764
+ ] : fa(f),
2765
+ r.of([])
2766
+ ]
2767
+ })
2768
+ });
2769
+ d.current = i, o || i.focus();
2770
+ let a = !0;
2771
+ return oa(n).then((e) => {
2772
+ a && e !== null && i.dispatch({ effects: r.reconfigure(e) });
2773
+ }, () => {}), () => {
2774
+ a = !1, i.destroy(), d.current = null;
2775
+ };
2776
+ }, []), Oe(() => {
2777
+ let t = d.current;
2778
+ t !== null && t.state.sliceDoc() !== e && t.dispatch({ changes: {
2779
+ from: 0,
2780
+ to: t.state.doc.length,
2781
+ insert: e
2782
+ } });
2783
+ }, [e]), /* @__PURE__ */ je("div", {
2784
+ ref: u,
2785
+ className: "code-editor h-full w-full",
2786
+ "data-testid": o ? "file-source" : "file-editor"
2787
+ });
2788
+ }
2789
+ //#endregion
2790
+ export { pa as CodeEditor, zt as a, ua as detectIndentUnit, $ as documentPosition, Ie as i, Me as n, Fe as r, sa as t };