@bagelink/vue 1.20.87 → 1.20.89

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.
@@ -0,0 +1,2508 @@
1
+ import { Na as Lt, Yr as ut, ka as C, tn as wr } from "./src-BB_6NiiK.js";
2
+ import { $ as Bt, A as Er, B as Rr, C as Tr, D as g, E as Fr, F as Ir, G as me, H as W, I as Or, J as Pr, K as _e, L as qr, M as ht, N as Nr, O as $r, P as Vr, Q as Dt, R as D, T as He, U as ft, V as Wr, W as d, Y as _r, Z as ie, a as Hr, at as H, b as wt, ct as y, d as Ur, dt as Te, et as De, g as Et, h as Fe, it as Ue, j as Rt, n as Tt, nt as zr, ot as Gr, p as Jr, rt as Ft, t as jr, tt as Kr, v as Qr, w as ze, x as K, y as ge, z as Ge } from "./dist-IV7z-zur.js";
3
+ import { computed as G, createBlock as Ie, createCommentVNode as P, createElementBlock as T, createElementVNode as b, createVNode as B, defineComponent as It, getCurrentInstance as Yr, h as dt, normalizeClass as Zr, onBeforeUnmount as Xr, onMounted as en, openBlock as A, ref as w, render as mt, resolveDirective as Ot, shallowRef as tn, toDisplayString as $, unref as V, useId as rn, watch as le, withDirectives as M } from "vue";
4
+ var nn = (e) => {
5
+ let { state: t } = e, r = t.doc.lineAt(t.selection.main.from), n = je(e.state, r.from);
6
+ return n.line ? ln(e) : n.block ? on(e) : !1;
7
+ };
8
+ function Je(e, t) {
9
+ return ({ state: r, dispatch: n }) => {
10
+ if (r.readOnly) return !1;
11
+ let l = e(t, r);
12
+ return l ? (n(r.update(l)), !0) : !1;
13
+ };
14
+ }
15
+ var ln = /* @__PURE__ */ Je(un, 0), an = /* @__PURE__ */ Je(Pt, 0), on = /* @__PURE__ */ Je((e, t) => Pt(e, t, cn(t)), 0);
16
+ function je(e, t) {
17
+ let r = e.languageDataAt("commentTokens", t, 1);
18
+ return r.length ? r[0] : {};
19
+ }
20
+ var te = 50;
21
+ function sn(e, { open: t, close: r }, n, l) {
22
+ let a = e.sliceDoc(n - te, n), o = e.sliceDoc(l, l + te), i = /\s*$/.exec(a)[0].length, s = /^\s*/.exec(o)[0].length, c = a.length - i;
23
+ if (a.slice(c - t.length, c) == t && o.slice(s, s + r.length) == r) return {
24
+ open: {
25
+ pos: n - i,
26
+ margin: i && 1
27
+ },
28
+ close: {
29
+ pos: l + s,
30
+ margin: s && 1
31
+ }
32
+ };
33
+ let u, h;
34
+ l - n <= 2 * te ? u = h = e.sliceDoc(n, l) : (u = e.sliceDoc(n, n + te), h = e.sliceDoc(l - te, l));
35
+ let f = /^\s*/.exec(u)[0].length, v = /\s*$/.exec(h)[0].length, m = h.length - v - r.length;
36
+ return u.slice(f, f + t.length) == t && h.slice(m, m + r.length) == r ? {
37
+ open: {
38
+ pos: n + f + t.length,
39
+ margin: /\s/.test(u.charAt(f + t.length)) ? 1 : 0
40
+ },
41
+ close: {
42
+ pos: l - v - r.length,
43
+ margin: /\s/.test(h.charAt(m - 1)) ? 1 : 0
44
+ }
45
+ } : null;
46
+ }
47
+ function cn(e) {
48
+ let t = [];
49
+ for (let r of e.selection.ranges) {
50
+ let n = e.doc.lineAt(r.from), l = r.to <= n.to ? n : e.doc.lineAt(r.to);
51
+ l.from > n.from && l.from == r.to && (l = r.to == n.to + 1 ? n : e.doc.lineAt(r.to - 1));
52
+ let a = t.length - 1;
53
+ a >= 0 && t[a].to > n.from ? t[a].to = l.to : t.push({
54
+ from: n.from + /^\s*/.exec(n.text)[0].length,
55
+ to: l.to
56
+ });
57
+ }
58
+ return t;
59
+ }
60
+ function Pt(e, t, r = t.selection.ranges) {
61
+ let n = r.map((a) => je(t, a.from).block);
62
+ if (!n.every((a) => a)) return null;
63
+ let l = r.map((a, o) => sn(t, n[o], a.from, a.to));
64
+ if (e != 2 && !l.every((a) => a)) return { changes: t.changes(r.map((a, o) => l[o] ? [] : [{
65
+ from: a.from,
66
+ insert: n[o].open + " "
67
+ }, {
68
+ from: a.to,
69
+ insert: " " + n[o].close
70
+ }])) };
71
+ if (e != 1 && l.some((a) => a)) {
72
+ let a = [];
73
+ for (let o = 0, i; o < l.length; o++) if (i = l[o]) {
74
+ let s = n[o], { open: c, close: u } = i;
75
+ a.push({
76
+ from: c.pos - s.open.length,
77
+ to: c.pos + c.margin
78
+ }, {
79
+ from: u.pos - u.margin,
80
+ to: u.pos + s.close.length
81
+ });
82
+ }
83
+ return { changes: a };
84
+ }
85
+ return null;
86
+ }
87
+ function un(e, t, r = t.selection.ranges) {
88
+ let n = [], l = -1;
89
+ e: for (let { from: a, to: o } of r) {
90
+ let i = n.length, s = 1e9, c;
91
+ for (let u = a; u <= o; ) {
92
+ let h = t.doc.lineAt(u);
93
+ if (c == null && (c = je(t, h.from).line, !c))
94
+ continue e;
95
+ if (h.from > l && (a == o || o > h.from)) {
96
+ l = h.from;
97
+ let f = /^\s*/.exec(h.text)[0].length, v = f == h.length, m = h.text.slice(f, f + c.length) == c ? f : -1;
98
+ f < h.text.length && f < s && (s = f), n.push({
99
+ line: h,
100
+ comment: m,
101
+ token: c,
102
+ indent: f,
103
+ empty: v,
104
+ single: !1
105
+ });
106
+ }
107
+ u = h.to + 1;
108
+ }
109
+ if (s < 1e9)
110
+ for (let u = i; u < n.length; u++) n[u].indent < n[u].line.text.length && (n[u].indent = s);
111
+ n.length == i + 1 && (n[i].single = !0);
112
+ }
113
+ if (e != 2 && n.some((a) => a.comment < 0 && (!a.empty || a.single))) {
114
+ let a = [];
115
+ for (let { line: i, token: s, indent: c, empty: u, single: h } of n) (h || !u) && a.push({
116
+ from: i.from + c,
117
+ insert: s + " "
118
+ });
119
+ let o = t.changes(a);
120
+ return {
121
+ changes: o,
122
+ selection: t.selection.map(o, 1)
123
+ };
124
+ } else if (e != 1 && n.some((a) => a.comment >= 0)) {
125
+ let a = [];
126
+ for (let { line: o, comment: i, token: s } of n) if (i >= 0) {
127
+ let c = o.from + i, u = c + s.length;
128
+ o.text[u - o.from] == " " && u++, a.push({
129
+ from: c,
130
+ to: u
131
+ });
132
+ }
133
+ return { changes: a };
134
+ }
135
+ return null;
136
+ }
137
+ var Oe = /* @__PURE__ */ Ge.define(), hn = /* @__PURE__ */ Ge.define(), fn = /* @__PURE__ */ _e.define(), qt = /* @__PURE__ */ _e.define({ combine(e) {
138
+ return Ft(e, {
139
+ minDepth: 100,
140
+ newGroupDelay: 500,
141
+ joinToEvent: (t, r) => r
142
+ }, {
143
+ minDepth: Math.max,
144
+ newGroupDelay: Math.min,
145
+ joinToEvent: (t, r) => (n, l) => t(n, l) || r(n, l)
146
+ });
147
+ } }), Nt = /* @__PURE__ */ Dt.define({
148
+ create() {
149
+ return ae.empty;
150
+ },
151
+ update(e, t) {
152
+ let r = t.state.facet(qt), n = t.annotation(Oe);
153
+ if (n) {
154
+ let s = q.fromTransaction(t, n.selection), c = n.side, u = c == 0 ? e.undone : e.done;
155
+ return s ? u = ve(u, u.length, r.minDepth, s) : u = Wt(u, t.startState.selection), new ae(c == 0 ? n.rest : u, c == 0 ? u : n.rest);
156
+ }
157
+ let l = t.annotation(hn);
158
+ if ((l == "full" || l == "before") && (e = e.isolate()), t.annotation(De.addToHistory) === !1) return t.changes.empty ? e : e.addMapping(t.changes.desc);
159
+ let a = q.fromTransaction(t), o = t.annotation(De.time), i = t.annotation(De.userEvent);
160
+ return a ? e = e.addChanges(a, o, i, r, t) : t.selection && (e = e.addSelection(t.startState.selection, o, i, r.newGroupDelay)), (l == "full" || l == "after") && (e = e.isolate()), e;
161
+ },
162
+ toJSON(e) {
163
+ return {
164
+ done: e.done.map((t) => t.toJSON()),
165
+ undone: e.undone.map((t) => t.toJSON())
166
+ };
167
+ },
168
+ fromJSON(e) {
169
+ return new ae(e.done.map(q.fromJSON), e.undone.map(q.fromJSON));
170
+ }
171
+ });
172
+ function dn(e = {}) {
173
+ return [
174
+ Nt,
175
+ qt.of(e),
176
+ g.domEventHandlers({ beforeinput(t, r) {
177
+ let n = t.inputType == "historyUndo" ? $t : t.inputType == "historyRedo" ? Pe : null;
178
+ return n ? (t.preventDefault(), n(r)) : !1;
179
+ } })
180
+ ];
181
+ }
182
+ function Ce(e, t) {
183
+ return function({ state: r, dispatch: n }) {
184
+ if (!t && r.readOnly) return !1;
185
+ let l = r.field(Nt, !1);
186
+ if (!l) return !1;
187
+ let a = l.pop(e, r, t);
188
+ return a ? (n(a), !0) : !1;
189
+ };
190
+ }
191
+ var $t = /* @__PURE__ */ Ce(0, !1), Pe = /* @__PURE__ */ Ce(1, !1), mn = /* @__PURE__ */ Ce(0, !0), pn = /* @__PURE__ */ Ce(1, !0), q = class re {
192
+ constructor(t, r, n, l, a) {
193
+ this.changes = t, this.effects = r, this.mapped = n, this.startSelection = l, this.selectionsAfter = a;
194
+ }
195
+ setSelAfter(t) {
196
+ return new re(this.changes, this.effects, this.mapped, this.startSelection, t);
197
+ }
198
+ toJSON() {
199
+ var t, r, n;
200
+ return {
201
+ changes: (t = this.changes) === null || t === void 0 ? void 0 : t.toJSON(),
202
+ mapped: (r = this.mapped) === null || r === void 0 ? void 0 : r.toJSON(),
203
+ startSelection: (n = this.startSelection) === null || n === void 0 ? void 0 : n.toJSON(),
204
+ selectionsAfter: this.selectionsAfter.map((l) => l.toJSON())
205
+ };
206
+ }
207
+ static fromJSON(t) {
208
+ return new re(t.changes && Wr.fromJSON(t.changes), [], t.mapped && Rr.fromJSON(t.mapped), t.startSelection && d.fromJSON(t.startSelection), t.selectionsAfter.map(d.fromJSON));
209
+ }
210
+ static fromTransaction(t, r) {
211
+ let n = E;
212
+ for (let l of t.startState.facet(fn)) {
213
+ let a = l(t);
214
+ a.length && (n = n.concat(a));
215
+ }
216
+ return !n.length && t.changes.empty ? null : new re(t.changes.invert(t.startState.doc), n, void 0, r || t.startState.selection, E);
217
+ }
218
+ static selection(t) {
219
+ return new re(void 0, E, void 0, void 0, t);
220
+ }
221
+ };
222
+ function ve(e, t, r, n) {
223
+ let l = t + 1 > r + 20 ? t - r - 1 : 0, a = e.slice(l, t);
224
+ return a.push(n), a;
225
+ }
226
+ function gn(e, t) {
227
+ let r = [], n = !1;
228
+ return e.iterChangedRanges((l, a) => r.push(l, a)), t.iterChangedRanges((l, a, o, i) => {
229
+ for (let s = 0; s < r.length; ) {
230
+ let c = r[s++], u = r[s++];
231
+ i >= c && o <= u && (n = !0);
232
+ }
233
+ }), n;
234
+ }
235
+ function vn(e, t) {
236
+ return e.ranges.length == t.ranges.length && e.ranges.filter((r, n) => r.empty != t.ranges[n].empty).length === 0;
237
+ }
238
+ function Vt(e, t) {
239
+ return e.length ? t.length ? e.concat(t) : e : t;
240
+ }
241
+ var E = [], yn = 200;
242
+ function Wt(e, t) {
243
+ if (e.length) {
244
+ let r = e[e.length - 1], n = r.selectionsAfter.slice(Math.max(0, r.selectionsAfter.length - yn));
245
+ return n.length && n[n.length - 1].eq(t) ? e : (n.push(t), ve(e, e.length - 1, 1e9, r.setSelAfter(n)));
246
+ } else
247
+ return [q.selection([t])];
248
+ }
249
+ function xn(e) {
250
+ let t = e[e.length - 1], r = e.slice();
251
+ return r[e.length - 1] = t.setSelAfter(t.selectionsAfter.slice(0, t.selectionsAfter.length - 1)), r;
252
+ }
253
+ function we(e, t) {
254
+ if (!e.length) return e;
255
+ let r = e.length, n = E;
256
+ for (; r; ) {
257
+ let l = kn(e[r - 1], t, n);
258
+ if (l.changes && !l.changes.empty || l.effects.length) {
259
+ let a = e.slice(0, r);
260
+ return a[r - 1] = l, a;
261
+ } else
262
+ t = l.mapped, r--, n = l.selectionsAfter;
263
+ }
264
+ return n.length ? [q.selection(n)] : E;
265
+ }
266
+ function kn(e, t, r) {
267
+ let n = Vt(e.selectionsAfter.length ? e.selectionsAfter.map((i) => i.map(t)) : E, r);
268
+ if (!e.changes) return q.selection(n);
269
+ let l = e.changes.map(t), a = t.mapDesc(e.changes, !0), o = e.mapped ? e.mapped.composeDesc(a) : a;
270
+ return new q(l, ie.mapEffects(e.effects, t), o, e.startSelection.map(a), n);
271
+ }
272
+ var Sn = /^(input\.type|delete)($|\.)/, ae = class ne {
273
+ constructor(t, r, n = 0, l = void 0) {
274
+ this.done = t, this.undone = r, this.prevTime = n, this.prevUserEvent = l;
275
+ }
276
+ isolate() {
277
+ return this.prevTime ? new ne(this.done, this.undone) : this;
278
+ }
279
+ addChanges(t, r, n, l, a) {
280
+ let o = this.done, i = o[o.length - 1];
281
+ return i && i.changes && !i.changes.empty && t.changes && (!n || Sn.test(n)) && (!i.selectionsAfter.length && r - this.prevTime < l.newGroupDelay && l.joinToEvent(a, gn(i.changes, t.changes)) || n == "input.type.compose") ? o = ve(o, o.length - 1, l.minDepth, new q(t.changes.compose(i.changes), Vt(ie.mapEffects(t.effects, i.changes), i.effects), i.mapped, i.startSelection, E)) : o = ve(o, o.length, l.minDepth, t), new ne(o, E, r, n);
282
+ }
283
+ addSelection(t, r, n, l) {
284
+ let a = this.done.length ? this.done[this.done.length - 1].selectionsAfter : E;
285
+ return a.length > 0 && r - this.prevTime < l && n == this.prevUserEvent && n && /^select($|\.)/.test(n) && vn(a[a.length - 1], t) ? this : new ne(Wt(this.done, t), this.undone, r, n);
286
+ }
287
+ addMapping(t) {
288
+ return new ne(we(this.done, t), we(this.undone, t), this.prevTime, this.prevUserEvent);
289
+ }
290
+ pop(t, r, n) {
291
+ let l = t == 0 ? this.done : this.undone;
292
+ if (l.length == 0) return null;
293
+ let a = l[l.length - 1], o = a.selectionsAfter[0] || (a.startSelection ? a.startSelection.map(a.changes.invertedDesc, 1) : r.selection);
294
+ if (n && a.selectionsAfter.length) return r.update({
295
+ selection: a.selectionsAfter[a.selectionsAfter.length - 1],
296
+ annotations: Oe.of({
297
+ side: t,
298
+ rest: xn(l),
299
+ selection: o
300
+ }),
301
+ userEvent: t == 0 ? "select.undo" : "select.redo",
302
+ scrollIntoView: !0
303
+ });
304
+ if (a.changes) {
305
+ let i = l.length == 1 ? E : l.slice(0, l.length - 1);
306
+ return a.mapped && (i = we(i, a.mapped)), r.update({
307
+ changes: a.changes,
308
+ selection: a.startSelection,
309
+ effects: a.effects,
310
+ annotations: Oe.of({
311
+ side: t,
312
+ rest: i,
313
+ selection: o
314
+ }),
315
+ filter: !1,
316
+ userEvent: t == 0 ? "undo" : "redo",
317
+ scrollIntoView: !0
318
+ });
319
+ } else
320
+ return null;
321
+ }
322
+ };
323
+ ae.empty = /* @__PURE__ */ new ae(E, E);
324
+ var bn = [
325
+ {
326
+ key: "Mod-z",
327
+ run: $t,
328
+ preventDefault: !0
329
+ },
330
+ {
331
+ key: "Mod-y",
332
+ mac: "Mod-Shift-z",
333
+ run: Pe,
334
+ preventDefault: !0
335
+ },
336
+ {
337
+ linux: "Ctrl-Shift-z",
338
+ run: Pe,
339
+ preventDefault: !0
340
+ },
341
+ {
342
+ key: "Mod-u",
343
+ run: mn,
344
+ preventDefault: !0
345
+ },
346
+ {
347
+ key: "Alt-u",
348
+ mac: "Mod-Shift-u",
349
+ run: pn,
350
+ preventDefault: !0
351
+ }
352
+ ];
353
+ function X(e, t) {
354
+ return d.create(e.ranges.map(t), e.mainIndex);
355
+ }
356
+ function F(e, t) {
357
+ return e.update({
358
+ selection: t,
359
+ scrollIntoView: !0,
360
+ userEvent: "select"
361
+ });
362
+ }
363
+ function I({ state: e, dispatch: t }, r) {
364
+ let n = X(e.selection, r);
365
+ return n.eq(e.selection, !0) ? !1 : (t(F(e, n)), !0);
366
+ }
367
+ function Ae(e, t) {
368
+ return d.cursor(t ? e.to : e.from);
369
+ }
370
+ function _t(e, t) {
371
+ return I(e, (r) => r.empty ? e.moveByChar(r, t) : Ae(r, t));
372
+ }
373
+ function S(e) {
374
+ return e.textDirectionAt(e.state.selection.main.head) == Fr.LTR;
375
+ }
376
+ var Ht = (e) => _t(e, !S(e)), Ut = (e) => _t(e, S(e));
377
+ function zt(e, t) {
378
+ return I(e, (r) => r.empty ? e.moveByGroup(r, t) : Ae(r, t));
379
+ }
380
+ var Cn = (e) => zt(e, !S(e)), An = (e) => zt(e, S(e)), fa = typeof Intl < "u" && Intl.Segmenter ? /* @__PURE__ */ new Intl.Segmenter(void 0, { granularity: "word" }) : null;
381
+ function Mn(e, t, r) {
382
+ if (t.type.prop(r)) return !0;
383
+ let n = t.to - t.from;
384
+ return n && (n > 2 || /[^\s,.;:]/.test(e.sliceDoc(t.from, t.to))) || t.firstChild;
385
+ }
386
+ function Me(e, t, r) {
387
+ let n = ze(e).resolveInner(t.head), l = r ? Te.closedBy : Te.openedBy;
388
+ for (let s = t.head; ; ) {
389
+ let c = r ? n.childAfter(s) : n.childBefore(s);
390
+ if (!c) break;
391
+ Mn(e, c, l) ? n = c : s = r ? c.to : c.from;
392
+ }
393
+ let a = n.type.prop(l), o, i;
394
+ return a && (o = r ? K(e, n.from, 1) : K(e, n.to, -1)) && o.matched ? i = r ? o.end.to : o.end.from : i = r ? n.to : n.from, d.cursor(i, r ? -1 : 1);
395
+ }
396
+ var Ln = (e) => I(e, (t) => Me(e.state, t, !S(e))), Bn = (e) => I(e, (t) => Me(e.state, t, S(e)));
397
+ function Gt(e, t) {
398
+ return I(e, (r) => {
399
+ if (!r.empty) return Ae(r, t);
400
+ let n = e.moveVertically(r, t);
401
+ return n.head != r.head ? n : e.moveToLineBoundary(r, t);
402
+ });
403
+ }
404
+ var Jt = (e) => Gt(e, !1), jt = (e) => Gt(e, !0);
405
+ function Kt(e) {
406
+ let t = e.scrollDOM.clientHeight < e.scrollDOM.scrollHeight - 2, r = 0, n = 0, l;
407
+ if (t) {
408
+ for (let a of e.state.facet(g.scrollMargins)) {
409
+ let o = a(e);
410
+ o?.top && (r = Math.max(o?.top, r)), o?.bottom && (n = Math.max(o?.bottom, n));
411
+ }
412
+ l = e.scrollDOM.clientHeight - r - n;
413
+ } else l = (e.dom.ownerDocument.defaultView || window).innerHeight;
414
+ return {
415
+ marginTop: r,
416
+ marginBottom: n,
417
+ selfScroll: t,
418
+ height: Math.max(e.defaultLineHeight, l - 5)
419
+ };
420
+ }
421
+ function Qt(e, t) {
422
+ let r = Kt(e), { state: n } = e, l = X(n.selection, (o) => o.empty ? e.moveVertically(o, t, r.height) : Ae(o, t));
423
+ if (l.eq(n.selection)) return !1;
424
+ let a;
425
+ if (r.selfScroll) {
426
+ let o = e.coordsAtPos(n.selection.main.head), i = e.scrollDOM.getBoundingClientRect(), s = i.top + r.marginTop, c = i.bottom - r.marginBottom;
427
+ o && o.top > s && o.bottom < c && (a = g.scrollIntoView(l.main.head, {
428
+ y: "start",
429
+ yMargin: o.top - s
430
+ }));
431
+ }
432
+ return e.dispatch(F(n, l), { effects: a }), !0;
433
+ }
434
+ var pt = (e) => Qt(e, !1), qe = (e) => Qt(e, !0);
435
+ function _(e, t, r) {
436
+ let n = e.lineBlockAt(t.head), l = e.moveToLineBoundary(t, r);
437
+ if (l.head == t.head && l.head != (r ? n.to : n.from) && (l = e.moveToLineBoundary(t, r, !1)), !r && l.head == n.from && n.length) {
438
+ let a = /^\s*/.exec(e.state.sliceDoc(n.from, Math.min(n.from + 100, n.to)))[0].length;
439
+ a && t.head != n.from + a && (l = d.cursor(n.from + a));
440
+ }
441
+ return l;
442
+ }
443
+ var Dn = (e) => I(e, (t) => _(e, t, !0)), wn = (e) => I(e, (t) => _(e, t, !1)), En = (e) => I(e, (t) => _(e, t, !S(e))), Rn = (e) => I(e, (t) => _(e, t, S(e))), Tn = (e) => I(e, (t) => e.moveToLineBoundary(t, !1, !1)), Fn = (e) => I(e, (t) => e.moveToLineBoundary(t, !0, !1));
444
+ function In(e, t, r) {
445
+ let n = !1, l = X(e.selection, (a) => {
446
+ let o = K(e, a.head, -1) || K(e, a.head, 1) || a.head > 0 && K(e, a.head - 1, 1) || a.head < e.doc.length && K(e, a.head + 1, -1);
447
+ if (!o || !o.end) return a;
448
+ n = !0;
449
+ let i = o.start.from == a.head ? o.end.to : o.end.from;
450
+ return r ? d.range(a.anchor, i) : d.cursor(i);
451
+ });
452
+ return n ? (t(F(e, l)), !0) : !1;
453
+ }
454
+ var On = ({ state: e, dispatch: t }) => In(e, t, !1);
455
+ function R(e, t, r) {
456
+ let n = X(e.state.selection, (l) => {
457
+ l.undirectional && l.head >= l.anchor != t && (l = d.range(l.head, l.anchor));
458
+ let a = r(l);
459
+ return d.range(l.anchor, a.head, a.goalColumn, a.bidiLevel || void 0, a.assoc);
460
+ });
461
+ return n.eq(e.state.selection) ? !1 : (e.dispatch(F(e.state, n)), !0);
462
+ }
463
+ function Yt(e, t) {
464
+ return R(e, t, (r) => e.moveByChar(r, t));
465
+ }
466
+ var Zt = (e) => Yt(e, !S(e)), Xt = (e) => Yt(e, S(e));
467
+ function er(e, t) {
468
+ return R(e, t, (r) => e.moveByGroup(r, t));
469
+ }
470
+ var Pn = (e) => er(e, !S(e)), qn = (e) => er(e, S(e)), Nn = (e) => {
471
+ let t = !S(e);
472
+ return R(e, t, (r) => Me(e.state, r, t));
473
+ }, $n = (e) => {
474
+ let t = S(e);
475
+ return R(e, t, (r) => Me(e.state, r, t));
476
+ };
477
+ function tr(e, t) {
478
+ return R(e, t, (r) => e.moveVertically(r, t));
479
+ }
480
+ var rr = (e) => tr(e, !1), nr = (e) => tr(e, !0);
481
+ function lr(e, t) {
482
+ return R(e, t, (r) => e.moveVertically(r, t, Kt(e).height));
483
+ }
484
+ var gt = (e) => lr(e, !1), vt = (e) => lr(e, !0), Vn = (e) => R(e, !0, (t) => _(e, t, !0)), Wn = (e) => R(e, !1, (t) => _(e, t, !1)), _n = (e) => {
485
+ let t = !S(e);
486
+ return R(e, t, (r) => _(e, r, t));
487
+ }, Hn = (e) => {
488
+ let t = S(e);
489
+ return R(e, t, (r) => _(e, r, t));
490
+ }, Un = (e) => R(e, !1, (t) => d.cursor(e.lineBlockAt(t.head).from)), zn = (e) => R(e, !0, (t) => d.cursor(e.lineBlockAt(t.head).to)), yt = ({ state: e, dispatch: t }) => (t(F(e, { anchor: 0 })), !0), xt = ({ state: e, dispatch: t }) => (t(F(e, { anchor: e.doc.length })), !0), kt = ({ state: e, dispatch: t }) => (t(F(e, {
491
+ anchor: e.selection.main.anchor,
492
+ head: 0
493
+ })), !0), St = ({ state: e, dispatch: t }) => (t(F(e, {
494
+ anchor: e.selection.main.anchor,
495
+ head: e.doc.length
496
+ })), !0), Gn = ({ state: e, dispatch: t }) => (t(e.update({
497
+ selection: {
498
+ anchor: 0,
499
+ head: e.doc.length
500
+ },
501
+ userEvent: "select"
502
+ })), !0), Jn = ({ state: e, dispatch: t }) => {
503
+ let r = Le(e).map(({ from: n, to: l }) => d.undirectionalRange(n, Math.min(l + 1, e.doc.length)));
504
+ return t(e.update({
505
+ selection: d.create(r),
506
+ userEvent: "select"
507
+ })), !0;
508
+ }, jn = ({ state: e, dispatch: t }) => {
509
+ let r = X(e.selection, (n) => {
510
+ let l = ze(e), a = l.resolveStack(n.from, 1);
511
+ if (n.empty) {
512
+ let o = l.resolveStack(n.from, -1);
513
+ o.node.from >= a.node.from && o.node.to <= a.node.to && (a = o);
514
+ }
515
+ for (let o = a; o; o = o.next) {
516
+ let { node: i } = o;
517
+ if ((i.from < n.from && i.to >= n.to || i.to > n.to && i.from <= n.from) && o.next) return d.undirectionalRange(i.from, i.to);
518
+ }
519
+ return n;
520
+ });
521
+ return r.eq(e.selection) ? !1 : (t(F(e, r)), !0);
522
+ };
523
+ function ar(e, t) {
524
+ let { state: r } = e, n = r.selection, l = r.selection.ranges.slice();
525
+ for (let a of r.selection.ranges) {
526
+ let o = r.doc.lineAt(a.head);
527
+ if (t ? o.to < e.state.doc.length : o.from > 0) for (let i = a; ; ) {
528
+ let s = e.moveVertically(i, t);
529
+ if (s.head < o.from || s.head > o.to) {
530
+ l.some((c) => c.head == s.head) || l.push(s);
531
+ break;
532
+ } else {
533
+ if (s.head == i.head) break;
534
+ i = s;
535
+ }
536
+ }
537
+ }
538
+ return l.length == n.ranges.length ? !1 : (e.dispatch(F(r, d.create(l, l.length - 1))), !0);
539
+ }
540
+ var Kn = (e) => ar(e, !1), Qn = (e) => ar(e, !0), Yn = ({ state: e, dispatch: t }) => {
541
+ let r = e.selection, n = null;
542
+ return r.ranges.length > 1 ? n = d.create([r.main]) : r.main.empty || (n = d.create([d.cursor(r.main.head)])), n ? (t(F(e, n)), !0) : !1;
543
+ };
544
+ function se(e, t) {
545
+ if (e.state.readOnly) return !1;
546
+ let r = "delete.selection", { state: n } = e, l = n.changeByRange((a) => {
547
+ let { from: o, to: i } = a;
548
+ if (o == i) {
549
+ let s = t(a);
550
+ s < o ? (r = "delete.backward", s = he(e, s, !1)) : s > o && (r = "delete.forward", s = he(e, s, !0)), o = Math.min(o, s), i = Math.max(i, s);
551
+ } else
552
+ o = he(e, o, !1), i = he(e, i, !0);
553
+ return o == i ? { range: a } : {
554
+ changes: {
555
+ from: o,
556
+ to: i
557
+ },
558
+ range: d.cursor(o, o < a.head ? -1 : 1)
559
+ };
560
+ });
561
+ return l.changes.empty ? !1 : (e.dispatch(n.update(l, {
562
+ scrollIntoView: !0,
563
+ userEvent: r,
564
+ effects: r == "delete.selection" ? g.announce.of(n.phrase("Selection deleted")) : void 0
565
+ })), !0);
566
+ }
567
+ function he(e, t, r) {
568
+ if (e instanceof g) for (let n of e.state.facet(g.atomicRanges).map((l) => l(e))) n.between(t, t, (l, a) => {
569
+ l < t && a > t && (t = r ? a : l);
570
+ });
571
+ return t;
572
+ }
573
+ var or = (e, t, r) => se(e, (n) => {
574
+ let l = n.from, { state: a } = e, o = a.doc.lineAt(l), i, s;
575
+ if (r && !t && l > o.from && l < o.from + 200 && !/[^ \t]/.test(i = o.text.slice(0, l - o.from))) {
576
+ if (i[i.length - 1] == " ") return l - 1;
577
+ let c = Ue(i, a.tabSize) % Fe(a) || Fe(a);
578
+ for (let u = 0; u < c && i[i.length - 1 - u] == " "; u++) l--;
579
+ s = l;
580
+ } else
581
+ s = H(o.text, l - o.from, t, t) + o.from, s == l && o.number != (t ? a.doc.lines : 1) ? s += t ? 1 : -1 : !t && /[\ufe00-\ufe0f]/.test(o.text.slice(s - o.from, l - o.from)) && (s = H(o.text, s - o.from, !1, !1) + o.from);
582
+ return s;
583
+ }), Ne = (e) => or(e, !1, !0), ir = (e) => or(e, !0, !1), sr = (e, t) => se(e, (r) => {
584
+ let n = r.head, { state: l } = e, a = l.doc.lineAt(n), o = l.charCategorizer(n);
585
+ for (let i = null; ; ) {
586
+ if (n == (t ? a.to : a.from)) {
587
+ n == r.head && a.number != (t ? l.doc.lines : 1) && (n += t ? 1 : -1);
588
+ break;
589
+ }
590
+ let s = H(a.text, n - a.from, t) + a.from, c = a.text.slice(Math.min(n, s) - a.from, Math.max(n, s) - a.from), u = o(c);
591
+ if (i != null && u != i) break;
592
+ (c != " " || n != r.head) && (i = u), n = s;
593
+ }
594
+ return n;
595
+ }), cr = (e) => sr(e, !1), Zn = (e) => sr(e, !0), Xn = (e) => se(e, (t) => {
596
+ let r = e.lineBlockAt(t.head).to;
597
+ return t.head < r ? r : Math.min(e.state.doc.length, t.head + 1);
598
+ }), el = (e) => se(e, (t) => {
599
+ let r = e.moveToLineBoundary(t, !1).head;
600
+ return t.head > r ? r : Math.max(0, t.head - 1);
601
+ }), tl = (e) => se(e, (t) => {
602
+ let r = e.moveToLineBoundary(t, !0).head;
603
+ return t.head < r ? r : Math.min(e.state.doc.length, t.head + 1);
604
+ }), rl = ({ state: e, dispatch: t }) => {
605
+ if (e.readOnly) return !1;
606
+ let r = e.changeByRange((n) => ({
607
+ changes: {
608
+ from: n.from,
609
+ to: n.to,
610
+ insert: Bt.of(["", ""])
611
+ },
612
+ range: d.cursor(n.from)
613
+ }));
614
+ return t(e.update(r, {
615
+ scrollIntoView: !0,
616
+ userEvent: "input"
617
+ })), !0;
618
+ }, nl = ({ state: e, dispatch: t }) => {
619
+ if (e.readOnly) return !1;
620
+ let r = e.changeByRange((n) => {
621
+ if (!n.empty || n.from == 0 || n.from == e.doc.length) return { range: n };
622
+ let l = n.from, a = e.doc.lineAt(l), o = l == a.from ? l - 1 : H(a.text, l - a.from, !1) + a.from, i = l == a.to ? l + 1 : H(a.text, l - a.from, !0) + a.from;
623
+ return {
624
+ changes: {
625
+ from: o,
626
+ to: i,
627
+ insert: e.doc.slice(l, i).append(e.doc.slice(o, l))
628
+ },
629
+ range: d.cursor(i)
630
+ };
631
+ });
632
+ return r.changes.empty ? !1 : (t(e.update(r, {
633
+ scrollIntoView: !0,
634
+ userEvent: "move.character"
635
+ })), !0);
636
+ };
637
+ function Le(e) {
638
+ let t = [], r = -1;
639
+ for (let n of e.selection.ranges) {
640
+ let l = e.doc.lineAt(n.from), a = e.doc.lineAt(n.to);
641
+ if (!n.empty && n.to == a.from && (a = e.doc.lineAt(n.to - 1)), r >= l.number) {
642
+ let o = t[t.length - 1];
643
+ o.to = a.to, o.ranges.push(n);
644
+ } else t.push({
645
+ from: l.from,
646
+ to: a.to,
647
+ ranges: [n]
648
+ });
649
+ r = a.number + 1;
650
+ }
651
+ return t;
652
+ }
653
+ function ur(e, t, r) {
654
+ if (e.readOnly) return !1;
655
+ let n = [], l = [];
656
+ for (let a of Le(e)) {
657
+ if (r ? a.to == e.doc.length : a.from == 0) continue;
658
+ let o = e.doc.lineAt(r ? a.to + 1 : a.from - 1), i = o.length + 1;
659
+ if (r) {
660
+ n.push({
661
+ from: a.to,
662
+ to: o.to
663
+ }, {
664
+ from: a.from,
665
+ insert: o.text + e.lineBreak
666
+ });
667
+ for (let s of a.ranges) l.push(d.range(Math.min(e.doc.length, s.anchor + i), Math.min(e.doc.length, s.head + i)));
668
+ } else {
669
+ n.push({
670
+ from: o.from,
671
+ to: a.from
672
+ }, {
673
+ from: a.to,
674
+ insert: e.lineBreak + o.text
675
+ });
676
+ for (let s of a.ranges) l.push(d.range(s.anchor - i, s.head - i));
677
+ }
678
+ }
679
+ return n.length ? (t(e.update({
680
+ changes: n,
681
+ scrollIntoView: !0,
682
+ selection: d.create(l, e.selection.mainIndex),
683
+ userEvent: "move.line"
684
+ })), !0) : !1;
685
+ }
686
+ var ll = ({ state: e, dispatch: t }) => ur(e, t, !1), al = ({ state: e, dispatch: t }) => ur(e, t, !0);
687
+ function hr(e, t, r) {
688
+ if (e.readOnly) return !1;
689
+ let n = [];
690
+ for (let a of Le(e)) r ? n.push({
691
+ from: a.from,
692
+ insert: e.doc.slice(a.from, a.to) + e.lineBreak
693
+ }) : n.push({
694
+ from: a.to,
695
+ insert: e.lineBreak + e.doc.slice(a.from, a.to)
696
+ });
697
+ let l = e.changes(n);
698
+ return t(e.update({
699
+ changes: l,
700
+ selection: e.selection.map(l, r ? 1 : -1),
701
+ scrollIntoView: !0,
702
+ userEvent: "input.copyline"
703
+ })), !0;
704
+ }
705
+ var ol = ({ state: e, dispatch: t }) => hr(e, t, !1), il = ({ state: e, dispatch: t }) => hr(e, t, !0), sl = (e) => {
706
+ if (e.state.readOnly) return !1;
707
+ let { state: t } = e, r = t.changes(Le(t).map(({ from: l, to: a }) => (l > 0 ? l-- : a < t.doc.length && a++, {
708
+ from: l,
709
+ to: a
710
+ }))), n = X(t.selection, (l) => {
711
+ let a;
712
+ if (e.lineWrapping) {
713
+ let o = e.lineBlockAt(l.head), i = e.coordsAtPos(l.head, l.assoc || 1);
714
+ i && (a = o.bottom + e.documentTop - i.bottom + e.defaultLineHeight / 2);
715
+ }
716
+ return e.moveVertically(l, !0, a);
717
+ }).map(r);
718
+ return e.dispatch({
719
+ changes: r,
720
+ selection: n,
721
+ scrollIntoView: !0,
722
+ userEvent: "delete.line"
723
+ }), !0;
724
+ };
725
+ function cl(e, t) {
726
+ if (/\(\)|\[\]|\{\}/.test(e.sliceDoc(t - 1, t + 1))) return {
727
+ from: t,
728
+ to: t
729
+ };
730
+ let r = ze(e).resolveInner(t), n = r.childBefore(t), l = r.childAfter(t), a;
731
+ return n && l && n.to <= t && l.from >= t && (a = n.type.prop(Te.closedBy)) && a.indexOf(l.name) > -1 && e.doc.lineAt(n.to).from == e.doc.lineAt(l.from).from && !/\S/.test(e.sliceDoc(n.to, l.from)) ? {
732
+ from: n.to,
733
+ to: l.from
734
+ } : null;
735
+ }
736
+ var bt = /* @__PURE__ */ fr(!1), ul = /* @__PURE__ */ fr(!0);
737
+ function fr(e) {
738
+ return ({ state: t, dispatch: r }) => {
739
+ if (t.readOnly) return !1;
740
+ let n = t.changeByRange((l) => {
741
+ let { from: a, to: o } = l, i = t.doc.lineAt(a), s = !e && a == o && cl(t, a);
742
+ e && (a = o = (o <= i.to ? i : t.doc.lineAt(o)).to);
743
+ let c = new Tt(t, {
744
+ simulateBreak: a,
745
+ simulateDoubleBreak: !!s
746
+ }), u = Et(c, a);
747
+ for (u == null && (u = Ue(/^\s*/.exec(t.doc.lineAt(a).text)[0], t.tabSize)); o < i.to && /\s/.test(i.text[o - i.from]); ) o++;
748
+ s ? { from: a, to: o } = s : a > i.from && a < i.from + 100 && !/\S/.test(i.text.slice(0, a)) && (a = i.from);
749
+ let h = ["", ge(t, u)];
750
+ return s && h.push(ge(t, c.lineIndent(i.from, -1))), {
751
+ changes: {
752
+ from: a,
753
+ to: o,
754
+ insert: Bt.of(h)
755
+ },
756
+ range: d.cursor(a + 1 + h[1].length)
757
+ };
758
+ });
759
+ return r(t.update(n, {
760
+ scrollIntoView: !0,
761
+ userEvent: "input"
762
+ })), !0;
763
+ };
764
+ }
765
+ function Ke(e, t) {
766
+ let r = -1;
767
+ return e.changeByRange((n) => {
768
+ let l = [];
769
+ for (let o = n.from; o <= n.to; ) {
770
+ let i = e.doc.lineAt(o);
771
+ i.number > r && (n.empty || n.to > i.from) && (t(i, l, n), r = i.number), o = i.to + 1;
772
+ }
773
+ let a = e.changes(l);
774
+ return {
775
+ changes: l,
776
+ range: d.range(a.mapPos(n.anchor, 1), a.mapPos(n.head, 1))
777
+ };
778
+ });
779
+ }
780
+ var hl = ({ state: e, dispatch: t }) => {
781
+ if (e.readOnly) return !1;
782
+ let r = /* @__PURE__ */ Object.create(null), n = new Tt(e, { overrideIndentation: (a) => {
783
+ let o = r[a];
784
+ return o ?? -1;
785
+ } }), l = Ke(e, (a, o, i) => {
786
+ let s = Et(n, a.from);
787
+ if (s == null) return;
788
+ /\S/.test(a.text) || (s = 0);
789
+ let c = /^\s*/.exec(a.text)[0], u = ge(e, s);
790
+ (c != u || i.from < a.from + c.length) && (r[a.from] = s, o.push({
791
+ from: a.from,
792
+ to: a.from + c.length,
793
+ insert: u
794
+ }));
795
+ });
796
+ return l.changes.empty || t(e.update(l, { userEvent: "indent" })), !0;
797
+ }, dr = ({ state: e, dispatch: t }) => e.readOnly ? !1 : (t(e.update(Ke(e, (r, n) => {
798
+ n.push({
799
+ from: r.from,
800
+ insert: e.facet(wt)
801
+ });
802
+ }), { userEvent: "input.indent" })), !0), mr = ({ state: e, dispatch: t }) => e.readOnly ? !1 : (t(e.update(Ke(e, (r, n) => {
803
+ let l = /^\s*/.exec(r.text)[0];
804
+ if (!l) return;
805
+ let a = Ue(l, e.tabSize), o = 0, i = ge(e, Math.max(0, a - Fe(e)));
806
+ for (; o < l.length && o < i.length && l.charCodeAt(o) == i.charCodeAt(o); ) o++;
807
+ n.push({
808
+ from: r.from + o,
809
+ to: r.from + l.length,
810
+ insert: i.slice(o)
811
+ });
812
+ }), { userEvent: "delete.dedent" })), !0), fl = (e) => (e.setTabFocusMode(), !0), dl = [
813
+ {
814
+ key: "Ctrl-b",
815
+ run: Ht,
816
+ shift: Zt,
817
+ preventDefault: !0
818
+ },
819
+ {
820
+ key: "Ctrl-f",
821
+ run: Ut,
822
+ shift: Xt
823
+ },
824
+ {
825
+ key: "Ctrl-p",
826
+ run: Jt,
827
+ shift: rr
828
+ },
829
+ {
830
+ key: "Ctrl-n",
831
+ run: jt,
832
+ shift: nr
833
+ },
834
+ {
835
+ key: "Ctrl-a",
836
+ run: Tn,
837
+ shift: Un
838
+ },
839
+ {
840
+ key: "Ctrl-e",
841
+ run: Fn,
842
+ shift: zn
843
+ },
844
+ {
845
+ key: "Ctrl-d",
846
+ run: ir
847
+ },
848
+ {
849
+ key: "Ctrl-h",
850
+ run: Ne
851
+ },
852
+ {
853
+ key: "Ctrl-k",
854
+ run: Xn
855
+ },
856
+ {
857
+ key: "Ctrl-Alt-h",
858
+ run: cr
859
+ },
860
+ {
861
+ key: "Ctrl-o",
862
+ run: rl
863
+ },
864
+ {
865
+ key: "Ctrl-t",
866
+ run: nl
867
+ },
868
+ {
869
+ key: "Ctrl-v",
870
+ run: qe
871
+ }
872
+ ], ml = /* @__PURE__ */ [
873
+ {
874
+ key: "ArrowLeft",
875
+ run: Ht,
876
+ shift: Zt,
877
+ preventDefault: !0
878
+ },
879
+ {
880
+ key: "Mod-ArrowLeft",
881
+ mac: "Alt-ArrowLeft",
882
+ run: Cn,
883
+ shift: Pn,
884
+ preventDefault: !0
885
+ },
886
+ {
887
+ mac: "Cmd-ArrowLeft",
888
+ run: En,
889
+ shift: _n,
890
+ preventDefault: !0
891
+ },
892
+ {
893
+ key: "ArrowRight",
894
+ run: Ut,
895
+ shift: Xt,
896
+ preventDefault: !0
897
+ },
898
+ {
899
+ key: "Mod-ArrowRight",
900
+ mac: "Alt-ArrowRight",
901
+ run: An,
902
+ shift: qn,
903
+ preventDefault: !0
904
+ },
905
+ {
906
+ mac: "Cmd-ArrowRight",
907
+ run: Rn,
908
+ shift: Hn,
909
+ preventDefault: !0
910
+ },
911
+ {
912
+ key: "ArrowUp",
913
+ run: Jt,
914
+ shift: rr,
915
+ preventDefault: !0
916
+ },
917
+ {
918
+ mac: "Cmd-ArrowUp",
919
+ run: yt,
920
+ shift: kt
921
+ },
922
+ {
923
+ mac: "Ctrl-ArrowUp",
924
+ run: pt,
925
+ shift: gt
926
+ },
927
+ {
928
+ key: "ArrowDown",
929
+ run: jt,
930
+ shift: nr,
931
+ preventDefault: !0
932
+ },
933
+ {
934
+ mac: "Cmd-ArrowDown",
935
+ run: xt,
936
+ shift: St
937
+ },
938
+ {
939
+ mac: "Ctrl-ArrowDown",
940
+ run: qe,
941
+ shift: vt
942
+ },
943
+ {
944
+ key: "PageUp",
945
+ run: pt,
946
+ shift: gt
947
+ },
948
+ {
949
+ key: "PageDown",
950
+ run: qe,
951
+ shift: vt
952
+ },
953
+ {
954
+ key: "Home",
955
+ run: wn,
956
+ shift: Wn,
957
+ preventDefault: !0
958
+ },
959
+ {
960
+ key: "Mod-Home",
961
+ run: yt,
962
+ shift: kt
963
+ },
964
+ {
965
+ key: "End",
966
+ run: Dn,
967
+ shift: Vn,
968
+ preventDefault: !0
969
+ },
970
+ {
971
+ key: "Mod-End",
972
+ run: xt,
973
+ shift: St
974
+ },
975
+ {
976
+ key: "Enter",
977
+ run: bt,
978
+ shift: bt
979
+ },
980
+ {
981
+ key: "Mod-a",
982
+ run: Gn
983
+ },
984
+ {
985
+ key: "Backspace",
986
+ run: Ne,
987
+ shift: Ne,
988
+ preventDefault: !0
989
+ },
990
+ {
991
+ key: "Delete",
992
+ run: ir,
993
+ preventDefault: !0
994
+ },
995
+ {
996
+ key: "Mod-Backspace",
997
+ mac: "Alt-Backspace",
998
+ run: cr,
999
+ preventDefault: !0
1000
+ },
1001
+ {
1002
+ key: "Mod-Delete",
1003
+ mac: "Alt-Delete",
1004
+ run: Zn,
1005
+ preventDefault: !0
1006
+ },
1007
+ {
1008
+ mac: "Mod-Backspace",
1009
+ run: el,
1010
+ preventDefault: !0
1011
+ },
1012
+ {
1013
+ mac: "Mod-Delete",
1014
+ run: tl,
1015
+ preventDefault: !0
1016
+ }
1017
+ ].concat(/* @__PURE__ */ dl.map((e) => ({
1018
+ mac: e.key,
1019
+ run: e.run,
1020
+ shift: e.shift
1021
+ }))), pl = /* @__PURE__ */ [
1022
+ {
1023
+ key: "Alt-ArrowLeft",
1024
+ mac: "Ctrl-ArrowLeft",
1025
+ run: Ln,
1026
+ shift: Nn
1027
+ },
1028
+ {
1029
+ key: "Alt-ArrowRight",
1030
+ mac: "Ctrl-ArrowRight",
1031
+ run: Bn,
1032
+ shift: $n
1033
+ },
1034
+ {
1035
+ key: "Alt-ArrowUp",
1036
+ run: ll
1037
+ },
1038
+ {
1039
+ key: "Shift-Alt-ArrowUp",
1040
+ run: ol
1041
+ },
1042
+ {
1043
+ key: "Alt-ArrowDown",
1044
+ run: al
1045
+ },
1046
+ {
1047
+ key: "Shift-Alt-ArrowDown",
1048
+ run: il
1049
+ },
1050
+ {
1051
+ key: "Mod-Alt-ArrowUp",
1052
+ run: Kn
1053
+ },
1054
+ {
1055
+ key: "Mod-Alt-ArrowDown",
1056
+ run: Qn
1057
+ },
1058
+ {
1059
+ key: "Escape",
1060
+ run: Yn
1061
+ },
1062
+ {
1063
+ key: "Mod-Enter",
1064
+ run: ul
1065
+ },
1066
+ {
1067
+ key: "Alt-l",
1068
+ mac: "Ctrl-l",
1069
+ run: Jn
1070
+ },
1071
+ {
1072
+ key: "Mod-i",
1073
+ run: jn,
1074
+ preventDefault: !0
1075
+ },
1076
+ {
1077
+ key: "Mod-[",
1078
+ run: mr
1079
+ },
1080
+ {
1081
+ key: "Mod-]",
1082
+ run: dr
1083
+ },
1084
+ {
1085
+ key: "Mod-Alt-\\",
1086
+ run: hl
1087
+ },
1088
+ {
1089
+ key: "Shift-Mod-k",
1090
+ run: sl
1091
+ },
1092
+ {
1093
+ key: "Shift-Mod-\\",
1094
+ run: On
1095
+ },
1096
+ {
1097
+ key: "Mod-/",
1098
+ run: nn
1099
+ },
1100
+ {
1101
+ key: "Alt-A",
1102
+ mac: "Ctrl-A",
1103
+ run: an
1104
+ },
1105
+ {
1106
+ key: "Ctrl-m",
1107
+ mac: "Shift-Alt-m",
1108
+ run: fl
1109
+ }
1110
+ ].concat(ml), gl = {
1111
+ key: "Tab",
1112
+ run: dr,
1113
+ shift: mr
1114
+ };
1115
+ function $e() {
1116
+ return $e = Object.assign ? Object.assign.bind() : function(e) {
1117
+ for (var t = 1; t < arguments.length; t++) {
1118
+ var r = arguments[t];
1119
+ for (var n in r) ({}).hasOwnProperty.call(r, n) && (e[n] = r[n]);
1120
+ }
1121
+ return e;
1122
+ }, $e.apply(null, arguments);
1123
+ }
1124
+ var vl = (e) => {
1125
+ var t = e.theme, r = e.settings, n = r === void 0 ? {} : r, l = e.styles, a = l === void 0 ? [] : l, o = { ".cm-gutters": {} }, i = {};
1126
+ n.background && (i.backgroundColor = n.background), n.backgroundImage && (i.backgroundImage = n.backgroundImage), n.foreground && (i.color = n.foreground), n.fontSize && (i.fontSize = n.fontSize), (n.background || n.foreground) && (o["&"] = i), n.fontFamily && (o["&.cm-editor .cm-scroller"] = { fontFamily: n.fontFamily }), n.gutterBackground && (o[".cm-gutters"].backgroundColor = n.gutterBackground), n.gutterForeground && (o[".cm-gutters"].color = n.gutterForeground), n.gutterBorder && (o[".cm-gutters"].borderRightColor = n.gutterBorder), n.caret && (o[".cm-content"] = { caretColor: n.caret }, o[".cm-cursor, .cm-dropCursor"] = { borderLeftColor: n.caret });
1127
+ var s = {};
1128
+ return n.gutterActiveForeground && (s.color = n.gutterActiveForeground), n.lineHighlight && (o[".cm-activeLine"] = { backgroundColor: n.lineHighlight }, s.backgroundColor = n.lineHighlight), o[".cm-activeLineGutter"] = s, n.selection && (o["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"] = { background: n.selection + " !important" }), n.selectionMatch && (o["& .cm-selectionMatch"] = { backgroundColor: n.selectionMatch }), [g.theme(o, { dark: t === "dark" }), Tr(jr.define(a))];
1129
+ }, yl = {
1130
+ background: "#272C35",
1131
+ foreground: "#9d9b97",
1132
+ caret: "#797977",
1133
+ selection: "#3d4c64",
1134
+ selectionMatch: "#3d4c64",
1135
+ gutterBackground: "#272C35",
1136
+ gutterForeground: "#465063",
1137
+ gutterBorder: "transparent",
1138
+ lineHighlight: "#2e3f5940"
1139
+ }, xl = [
1140
+ {
1141
+ tag: [
1142
+ y.function(y.variableName),
1143
+ y.function(y.propertyName),
1144
+ y.url,
1145
+ y.processingInstruction
1146
+ ],
1147
+ color: "hsl(207, 82%, 66%)"
1148
+ },
1149
+ {
1150
+ tag: [y.tagName, y.heading],
1151
+ color: "#e06c75"
1152
+ },
1153
+ {
1154
+ tag: y.comment,
1155
+ color: "#54636D"
1156
+ },
1157
+ {
1158
+ tag: [y.propertyName],
1159
+ color: "hsl(220, 14%, 71%)"
1160
+ },
1161
+ {
1162
+ tag: [y.attributeName, y.number],
1163
+ color: "hsl( 29, 54%, 61%)"
1164
+ },
1165
+ {
1166
+ tag: y.className,
1167
+ color: "hsl( 39, 67%, 69%)"
1168
+ },
1169
+ {
1170
+ tag: y.keyword,
1171
+ color: "hsl(286, 60%, 67%)"
1172
+ },
1173
+ {
1174
+ tag: [
1175
+ y.string,
1176
+ y.regexp,
1177
+ y.special(y.propertyName)
1178
+ ],
1179
+ color: "#98c379"
1180
+ }
1181
+ ], pr = (e) => {
1182
+ var t = e || {}, r = t.theme, n = r === void 0 ? "dark" : r, l = t.settings, a = l === void 0 ? {} : l, o = t.styles, i = o === void 0 ? [] : o;
1183
+ return vl({
1184
+ theme: n,
1185
+ settings: $e({}, yl, a),
1186
+ styles: [...xl, ...i]
1187
+ });
1188
+ }, kl = pr(), Ct = typeof String.prototype.normalize == "function" ? (e) => e.normalize("NFKD") : (e) => e, oe = class {
1189
+ /**
1190
+ Create a text cursor. The query is the search string, `from` to
1191
+ `to` provides the region to search.
1192
+
1193
+ When `normalize` is given, it will be called, on both the query
1194
+ string and the content it is matched against, before comparing.
1195
+ You can, for example, create a case-insensitive search by
1196
+ passing `s => s.toLowerCase()`.
1197
+
1198
+ Text is always normalized with
1199
+ [`.normalize("NFKD")`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
1200
+ (when supported).
1201
+ */
1202
+ constructor(e, t, r = 0, n = e.length, l, a) {
1203
+ this.test = a, this.value = {
1204
+ from: 0,
1205
+ to: 0,
1206
+ precise: !1
1207
+ }, this.done = !1, this.matches = [], this.buffer = "", this.bufferPos = 0, this.iter = e.iterRange(r, n), this.bufferStart = r, this.normalize = l ? (o) => l(Ct(o)) : Ct, this.query = this.normalize(t);
1208
+ }
1209
+ peek() {
1210
+ if (this.bufferPos == this.buffer.length) {
1211
+ if (this.bufferStart += this.buffer.length, this.iter.next(), this.iter.done) return -1;
1212
+ this.bufferPos = 0, this.buffer = this.iter.value;
1213
+ }
1214
+ return Kr(this.buffer, this.bufferPos);
1215
+ }
1216
+ /**
1217
+ Look for the next match. Updates the iterator's
1218
+ [`value`](https://codemirror.net/6/docs/ref/#search.SearchCursor.value) and
1219
+ [`done`](https://codemirror.net/6/docs/ref/#search.SearchCursor.done) properties. Should be called
1220
+ at least once before using the cursor.
1221
+ */
1222
+ next() {
1223
+ for (; this.matches.length; ) this.matches.pop();
1224
+ return this.nextOverlapping();
1225
+ }
1226
+ /**
1227
+ The `next` method will ignore matches that partially overlap a
1228
+ previous match. This method behaves like `next`, but includes
1229
+ such matches.
1230
+ */
1231
+ nextOverlapping() {
1232
+ for (; ; ) {
1233
+ let e = this.peek();
1234
+ if (e < 0)
1235
+ return this.done = !0, this;
1236
+ let t = Gr(e), r = this.bufferStart + this.bufferPos;
1237
+ this.bufferPos += zr(e);
1238
+ let n = this.normalize(t);
1239
+ if (n.length) for (let l = 0, a = r, o = !0; ; l++) {
1240
+ let i = n.charCodeAt(l), s = this.match(i, a, o, this.bufferPos + this.bufferStart, l == n.length - 1);
1241
+ if (s)
1242
+ return this.value = s, this;
1243
+ if (l == n.length - 1) break;
1244
+ o && l < t.length && t.charCodeAt(l) == i ? a++ : o = !1;
1245
+ }
1246
+ }
1247
+ }
1248
+ match(e, t, r, n, l) {
1249
+ let a = null;
1250
+ for (let o = 0; o < this.matches.length; ) {
1251
+ let i = this.matches[o], s = !1;
1252
+ this.query.charCodeAt(i.index) == e && (i.index == this.query.length - 1 ? a = {
1253
+ from: i.from,
1254
+ to: n,
1255
+ precise: l && i.precise
1256
+ } : (i.index++, s = !0)), s ? o++ : this.matches.splice(o, 1);
1257
+ }
1258
+ return this.query.charCodeAt(0) == e && (this.query.length == 1 ? a = {
1259
+ from: t,
1260
+ to: n,
1261
+ precise: r && l
1262
+ } : this.matches.push({
1263
+ from: t,
1264
+ index: 1,
1265
+ precise: r
1266
+ })), a && this.test && !this.test(a.from, a.to, this.buffer, this.bufferStart) && (a = null), a;
1267
+ }
1268
+ };
1269
+ typeof Symbol < "u" && (oe.prototype[Symbol.iterator] = function() {
1270
+ return this;
1271
+ });
1272
+ var gr = {
1273
+ from: -1,
1274
+ to: -1,
1275
+ match: /* @__PURE__ */ /.*/.exec(""),
1276
+ precise: !0
1277
+ }, Qe = "gm" + (/x/.unicode == null ? "" : "u"), vr = class {
1278
+ /**
1279
+ Create a cursor that will search the given range in the given
1280
+ document. `query` should be the raw pattern (as you'd pass it to
1281
+ `new RegExp`).
1282
+ */
1283
+ constructor(e, t, r, n = 0, l = e.length) {
1284
+ if (this.text = e, this.to = l, this.curLine = "", this.done = !1, this.value = gr, /\\[sWDnr]|\n|\r|\[\^/.test(t)) return new yr(e, t, r, n, l);
1285
+ this.re = new RegExp(t, Qe + (r?.ignoreCase ? "i" : "")), this.test = r?.test, this.iter = e.iter(), this.curLineStart = e.lineAt(n).from, this.matchPos = ye(e, n), this.getLine(this.curLineStart);
1286
+ }
1287
+ getLine(e) {
1288
+ 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());
1289
+ }
1290
+ nextLine() {
1291
+ this.curLineStart = this.curLineStart + this.curLine.length + 1, this.curLineStart > this.to ? this.curLine = "" : this.getLine(0);
1292
+ }
1293
+ /**
1294
+ Move to the next match, if there is one.
1295
+ */
1296
+ next() {
1297
+ for (let e = this.matchPos - this.curLineStart; ; ) {
1298
+ this.re.lastIndex = e;
1299
+ let t = this.matchPos <= this.to && this.re.exec(this.curLine);
1300
+ if (t) {
1301
+ let r = this.curLineStart + t.index, n = r + t[0].length;
1302
+ if (this.matchPos = ye(this.text, n + (r == n ? 1 : 0)), r == this.curLineStart + this.curLine.length && this.nextLine(), (r < n || r > this.value.to) && (!this.test || this.test(r, n, t)))
1303
+ return this.value = {
1304
+ from: r,
1305
+ to: n,
1306
+ precise: !0,
1307
+ match: t
1308
+ }, this;
1309
+ e = this.matchPos - this.curLineStart;
1310
+ } else if (this.curLineStart + this.curLine.length < this.to)
1311
+ this.nextLine(), e = 0;
1312
+ else
1313
+ return this.done = !0, this;
1314
+ }
1315
+ }
1316
+ }, Ee = /* @__PURE__ */ new WeakMap(), At = class pe {
1317
+ constructor(t, r) {
1318
+ this.from = t, this.text = r;
1319
+ }
1320
+ get to() {
1321
+ return this.from + this.text.length;
1322
+ }
1323
+ static get(t, r, n) {
1324
+ let l = Ee.get(t);
1325
+ if (!l || l.from >= n || l.to <= r) {
1326
+ let i = new pe(r, t.sliceString(r, n));
1327
+ return Ee.set(t, i), i;
1328
+ }
1329
+ if (l.from == r && l.to == n) return l;
1330
+ let { text: a, from: o } = l;
1331
+ return o > r && (a = t.sliceString(r, o) + a, o = r), l.to < n && (a += t.sliceString(l.to, n)), Ee.set(t, new pe(o, a)), new pe(r, a.slice(r - o, n - o));
1332
+ }
1333
+ }, yr = class {
1334
+ constructor(e, t, r, n, l) {
1335
+ this.text = e, this.to = l, this.done = !1, this.value = gr, this.matchPos = ye(e, n), this.re = new RegExp(t, Qe + (r?.ignoreCase ? "i" : "")), this.test = r?.test, this.flat = At.get(e, n, this.chunkEnd(n + 5e3));
1336
+ }
1337
+ chunkEnd(e) {
1338
+ return e >= this.to ? this.to : this.text.lineAt(e).to;
1339
+ }
1340
+ next() {
1341
+ for (; ; ) {
1342
+ let e = this.re.lastIndex = this.matchPos - this.flat.from, t = this.re.exec(this.flat.text);
1343
+ if (t && !t[0] && t.index == e && (this.re.lastIndex = e + 1, t = this.re.exec(this.flat.text)), t) {
1344
+ let r = this.flat.from + t.index, n = r + t[0].length;
1345
+ if ((this.flat.to >= this.to || t.index + t[0].length <= this.flat.text.length - 10) && (!this.test || this.test(r, n, t)))
1346
+ return this.value = {
1347
+ from: r,
1348
+ to: n,
1349
+ precise: !0,
1350
+ match: t
1351
+ }, this.matchPos = ye(this.text, n + (r == n ? 1 : 0)), this;
1352
+ }
1353
+ if (this.flat.to == this.to)
1354
+ return this.done = !0, this;
1355
+ this.flat = At.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
1356
+ }
1357
+ }
1358
+ };
1359
+ typeof Symbol < "u" && (vr.prototype[Symbol.iterator] = yr.prototype[Symbol.iterator] = function() {
1360
+ return this;
1361
+ });
1362
+ function Sl(e) {
1363
+ try {
1364
+ return new RegExp(e, Qe), !0;
1365
+ } catch {
1366
+ return !1;
1367
+ }
1368
+ }
1369
+ function ye(e, t) {
1370
+ if (t >= e.length) return t;
1371
+ let r = e.lineAt(t), n;
1372
+ for (; t < r.to && (n = r.text.charCodeAt(t - r.from)) >= 56320 && n < 57344; ) t++;
1373
+ return t;
1374
+ }
1375
+ var bl = (e) => {
1376
+ let t = Er(e, "cm-goto-line");
1377
+ if (t) {
1378
+ let o = t.dom.querySelector("input[type=text]");
1379
+ return o && o.select(), !0;
1380
+ }
1381
+ let { state: r } = e, n = String(r.doc.lineAt(e.state.selection.main.head).number), { close: l, result: a } = Or(e, {
1382
+ class: "cm-goto-line",
1383
+ label: r.phrase("Go to line"),
1384
+ input: {
1385
+ type: "text",
1386
+ name: "line",
1387
+ value: n
1388
+ },
1389
+ focus: !0,
1390
+ submitLabel: r.phrase("go")
1391
+ });
1392
+ return a.then((o) => {
1393
+ let i = o && /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(o.elements.line.value);
1394
+ if (!i) {
1395
+ e.dispatch({ effects: l });
1396
+ return;
1397
+ }
1398
+ let s = r.doc.lineAt(r.selection.main.head), [, c, u, h, f] = i, v = h ? +h.slice(1) : 0, m = u ? +u : s.number;
1399
+ if (u && f) {
1400
+ let z = m / 100;
1401
+ c && (z = z * (c == "-" ? -1 : 1) + s.number / r.doc.lines), m = Math.round(r.doc.lines * z);
1402
+ } else u && c && (m = m * (c == "-" ? -1 : 1) + s.number);
1403
+ let ue = r.doc.line(Math.max(1, Math.min(r.doc.lines, m))), ee = d.cursor(ue.from + Math.max(0, Math.min(v, ue.length)));
1404
+ e.dispatch({
1405
+ effects: [l, g.scrollIntoView(ee.from, { y: "center" })],
1406
+ selection: ee
1407
+ });
1408
+ }), !0;
1409
+ }, Cl = ({ state: e, dispatch: t }) => {
1410
+ let { selection: r } = e, n = d.create(r.ranges.map((l) => e.wordAt(l.head) || d.cursor(l.head)), r.mainIndex);
1411
+ return n.eq(r) ? !1 : (t(e.update({ selection: n })), !0);
1412
+ };
1413
+ function Al(e, t) {
1414
+ let { main: r, ranges: n } = e.selection, l = e.wordAt(r.head), a = l && l.from == r.from && l.to == r.to;
1415
+ for (let o = !1, i = new oe(e.doc, t, n[n.length - 1].to); ; )
1416
+ if (i.next(), i.done) {
1417
+ if (o) return null;
1418
+ i = new oe(e.doc, t, 0, Math.max(0, n[n.length - 1].from - 1)), o = !0;
1419
+ } else {
1420
+ if (o && n.some((s) => s.from == i.value.from)) continue;
1421
+ if (a) {
1422
+ let s = e.wordAt(i.value.from);
1423
+ if (!s || s.from != i.value.from || s.to != i.value.to) continue;
1424
+ }
1425
+ return i.value;
1426
+ }
1427
+ }
1428
+ var Ml = ({ state: e, dispatch: t }) => {
1429
+ let { ranges: r } = e.selection;
1430
+ if (r.some((a) => a.from === a.to)) return Cl({
1431
+ state: e,
1432
+ dispatch: t
1433
+ });
1434
+ let n = e.sliceDoc(r[0].from, r[0].to);
1435
+ if (e.selection.ranges.some((a) => e.sliceDoc(a.from, a.to) != n)) return !1;
1436
+ let l = Al(e, n);
1437
+ return l ? (t(e.update({
1438
+ selection: e.selection.addRange(d.range(l.from, l.to), !1),
1439
+ effects: g.scrollIntoView(l.to)
1440
+ })), !0) : !1;
1441
+ }, U = /* @__PURE__ */ _e.define({ combine(e) {
1442
+ return Ft(e, {
1443
+ top: !1,
1444
+ caseSensitive: !1,
1445
+ literal: !1,
1446
+ regexp: !1,
1447
+ wholeWord: !1,
1448
+ createPanel: (t) => new Nl(t),
1449
+ scrollToMatch: (t) => g.scrollIntoView(t)
1450
+ });
1451
+ } });
1452
+ function Ll(e) {
1453
+ return e ? [U.of(e), We] : We;
1454
+ }
1455
+ var Ye = class {
1456
+ /**
1457
+ Create a query object.
1458
+ */
1459
+ constructor(e) {
1460
+ this.search = e.search, this.caseSensitive = !!e.caseSensitive, this.literal = !!e.literal, this.regexp = !!e.regexp, this.replace = e.replace || "", this.valid = !!this.search && (!this.regexp || Sl(this.search)), this.unquoted = this.unquote(this.search), this.wholeWord = !!e.wholeWord, this.test = e.test;
1461
+ }
1462
+ /**
1463
+ @internal
1464
+ */
1465
+ unquote(e) {
1466
+ return this.literal ? e : e.replace(/\\([nrt\\])/g, (t, r) => r == "n" ? `
1467
+ ` : r == "r" ? "\r" : r == "t" ? " " : "\\");
1468
+ }
1469
+ /**
1470
+ Compare this query to another query.
1471
+ */
1472
+ eq(e) {
1473
+ return this.search == e.search && this.replace == e.replace && this.caseSensitive == e.caseSensitive && this.regexp == e.regexp && this.wholeWord == e.wholeWord && this.test == e.test;
1474
+ }
1475
+ /**
1476
+ @internal
1477
+ */
1478
+ create() {
1479
+ return this.regexp ? new Tl(this) : new wl(this);
1480
+ }
1481
+ /**
1482
+ Get a search cursor for this query, searching through the given
1483
+ range in the given state.
1484
+ */
1485
+ getCursor(e, t = 0, r) {
1486
+ let n = e.doc ? e : me.create({ doc: e });
1487
+ return r == null && (r = n.doc.length), this.regexp ? j(this, n, t, r) : J(this, n, t, r);
1488
+ }
1489
+ }, xr = class {
1490
+ constructor(e) {
1491
+ this.spec = e;
1492
+ }
1493
+ };
1494
+ function Bl(e, t, r) {
1495
+ return (n, l, a, o) => r && !r(n, l, a, o) ? !1 : e(n >= o && l <= o + a.length ? a.slice(n - o, l - o) : t.doc.sliceString(n, l), t, n, l);
1496
+ }
1497
+ function J(e, t, r, n) {
1498
+ let l;
1499
+ return e.wholeWord && (l = Dl(t.doc, t.charCategorizer(t.selection.main.head))), e.test && (l = Bl(e.test, t, l)), new oe(t.doc, e.unquoted, r, n, e.caseSensitive ? void 0 : (a) => a.toLowerCase(), l);
1500
+ }
1501
+ function Dl(e, t) {
1502
+ return (r, n, l, a) => ((a > r || a + l.length < n) && (a = Math.max(0, r - 2), l = e.sliceString(a, Math.min(e.length, n + 2))), (t(xe(l, r - a)) != W.Word || t(ke(l, r - a)) != W.Word) && (t(ke(l, n - a)) != W.Word || t(xe(l, n - a)) != W.Word));
1503
+ }
1504
+ var wl = class extends xr {
1505
+ constructor(e) {
1506
+ super(e);
1507
+ }
1508
+ nextMatch(e, t, r) {
1509
+ let n = J(this.spec, e, r, e.doc.length).nextOverlapping();
1510
+ if (n.done) {
1511
+ let l = Math.min(e.doc.length, t + this.spec.unquoted.length);
1512
+ n = J(this.spec, e, 0, l).nextOverlapping();
1513
+ }
1514
+ return n.done || n.value.from == t && n.value.to == r ? null : n.value;
1515
+ }
1516
+ prevMatchInRange(e, t, r) {
1517
+ for (let n = r; ; ) {
1518
+ let l = Math.max(t, n - 1e4 - this.spec.unquoted.length), a = J(this.spec, e, l, n), o = null;
1519
+ for (; !a.nextOverlapping().done; ) o = a.value;
1520
+ if (o) return o;
1521
+ if (l == t) return null;
1522
+ n -= 1e4;
1523
+ }
1524
+ }
1525
+ prevMatch(e, t, r) {
1526
+ let n = this.prevMatchInRange(e, 0, t);
1527
+ return n || (n = this.prevMatchInRange(e, Math.max(0, r - this.spec.unquoted.length), e.doc.length)), n && (n.from != t || n.to != r) ? n : null;
1528
+ }
1529
+ getReplacement(e) {
1530
+ return this.spec.unquote(this.spec.replace);
1531
+ }
1532
+ matchAll(e, t) {
1533
+ let r = J(this.spec, e, 0, e.doc.length), n = [];
1534
+ for (; !r.next().done; ) {
1535
+ if (n.length >= t) return null;
1536
+ n.push(r.value);
1537
+ }
1538
+ return n;
1539
+ }
1540
+ highlight(e, t, r, n) {
1541
+ let l = J(this.spec, e, Math.max(0, t - this.spec.unquoted.length), Math.min(r + this.spec.unquoted.length, e.doc.length));
1542
+ for (; !l.next().done; ) n(l.value.from, l.value.to);
1543
+ }
1544
+ };
1545
+ function El(e, t, r) {
1546
+ return (n, l, a) => (!r || r(n, l, a)) && e(a[0], t, n, l);
1547
+ }
1548
+ function j(e, t, r, n) {
1549
+ let l;
1550
+ return e.wholeWord && (l = Rl(t.charCategorizer(t.selection.main.head))), e.test && (l = El(e.test, t, l)), new vr(t.doc, e.search, {
1551
+ ignoreCase: !e.caseSensitive,
1552
+ test: l
1553
+ }, r, n);
1554
+ }
1555
+ function xe(e, t) {
1556
+ return e.slice(H(e, t, !1), t);
1557
+ }
1558
+ function ke(e, t) {
1559
+ return e.slice(t, H(e, t));
1560
+ }
1561
+ function Rl(e) {
1562
+ return (t, r, n) => !n[0].length || (e(xe(n.input, n.index)) != W.Word || e(ke(n.input, n.index)) != W.Word) && (e(ke(n.input, n.index + n[0].length)) != W.Word || e(xe(n.input, n.index + n[0].length)) != W.Word);
1563
+ }
1564
+ var Tl = class extends xr {
1565
+ nextMatch(e, t, r) {
1566
+ let n = j(this.spec, e, r, e.doc.length).next();
1567
+ return n.done && (n = j(this.spec, e, 0, t).next()), n.done ? null : n.value;
1568
+ }
1569
+ prevMatchInRange(e, t, r) {
1570
+ for (let n = 1; ; n++) {
1571
+ let l = Math.max(t, r - n * 1e4), a = j(this.spec, e, l, r), o = null;
1572
+ for (; !a.next().done; ) o = a.value;
1573
+ if (o && (l == t || o.from > l + 10)) return o;
1574
+ if (l == t) return null;
1575
+ }
1576
+ }
1577
+ prevMatch(e, t, r) {
1578
+ return this.prevMatchInRange(e, 0, t) || this.prevMatchInRange(e, r, e.doc.length);
1579
+ }
1580
+ getReplacement(e) {
1581
+ return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g, (t, r) => {
1582
+ if (r == "&") return e.match[0];
1583
+ if (r == "$") return "$";
1584
+ for (let n = r.length; n > 0; n--) {
1585
+ let l = +r.slice(0, n);
1586
+ if (l > 0 && l < e.match.length) return e.match[l] + r.slice(n);
1587
+ }
1588
+ return t;
1589
+ });
1590
+ }
1591
+ matchAll(e, t) {
1592
+ let r = j(this.spec, e, 0, e.doc.length), n = [];
1593
+ for (; !r.next().done; ) {
1594
+ if (n.length >= t) return null;
1595
+ n.push(r.value);
1596
+ }
1597
+ return n;
1598
+ }
1599
+ highlight(e, t, r, n) {
1600
+ let l = j(this.spec, e, Math.max(0, t - 250), Math.min(r + 250, e.doc.length));
1601
+ for (; !l.next().done; ) n(l.value.from, l.value.to);
1602
+ }
1603
+ }, Q = /* @__PURE__ */ ie.define(), Ze = /* @__PURE__ */ ie.define(), N = /* @__PURE__ */ Dt.define({
1604
+ create(e) {
1605
+ return new Re(Se(e).create(), null);
1606
+ },
1607
+ update(e, t) {
1608
+ for (let r of t.effects) r.is(Q) ? e = new Re(r.value.create(), e.panel) : r.is(Ze) && (e = new Re(e.query, r.value ? Xe : null));
1609
+ return e;
1610
+ },
1611
+ provide: (e) => qr.from(e, (t) => t.panel)
1612
+ });
1613
+ function Mt(e) {
1614
+ let t = e.field(N, !1);
1615
+ return t ? t.query.spec : Se(e);
1616
+ }
1617
+ var Re = class {
1618
+ constructor(e, t) {
1619
+ this.query = e, this.panel = t;
1620
+ }
1621
+ }, Fl = /* @__PURE__ */ He.mark({ class: "cm-searchMatch" }), Il = /* @__PURE__ */ He.mark({ class: "cm-searchMatch cm-searchMatch-selected" }), Ol = /* @__PURE__ */ $r.fromClass(class {
1622
+ constructor(e) {
1623
+ this.view = e, this.decorations = this.highlight(e.state.field(N));
1624
+ }
1625
+ update(e) {
1626
+ let t = e.state.field(N);
1627
+ (t != e.startState.field(N) || e.docChanged || e.selectionSet || e.viewportChanged) && (this.decorations = this.highlight(t));
1628
+ }
1629
+ highlight({ query: e, panel: t }) {
1630
+ if (!t || !e.spec.valid) return He.none;
1631
+ let { view: r } = this, n = new _r();
1632
+ for (let l = 0, a = r.visibleRanges, o = a.length; l < o; l++) {
1633
+ let { from: i, to: s } = a[l];
1634
+ for (; l < o - 1 && s > a[l + 1].from - 500; ) s = a[++l].to;
1635
+ e.highlight(r.state, i, s, (c, u) => {
1636
+ let h = r.state.selection.ranges.some((f) => f.from == c && f.to == u);
1637
+ n.add(c, u, h ? Il : Fl);
1638
+ });
1639
+ }
1640
+ return n.finish();
1641
+ }
1642
+ }, { decorations: (e) => e.decorations });
1643
+ function ce(e) {
1644
+ return (t) => {
1645
+ let r = t.state.field(N, !1);
1646
+ return r && r.query.spec.valid ? e(t, r) : Ar(t);
1647
+ };
1648
+ }
1649
+ var Y = /* @__PURE__ */ ce((e, { query: t }) => {
1650
+ let { to: r } = e.state.selection.main, n = t.nextMatch(e.state, r, r);
1651
+ if (!n) return !1;
1652
+ let l = d.single(n.from, n.to), a = e.state.facet(U);
1653
+ return e.dispatch({
1654
+ selection: l,
1655
+ effects: [et(e, n), a.scrollToMatch(l.main, e)],
1656
+ userEvent: "select.search"
1657
+ }), Cr(e), !0;
1658
+ }), Z = /* @__PURE__ */ ce((e, { query: t }) => {
1659
+ let { state: r } = e, { from: n } = r.selection.main, l = t.prevMatch(r, n, n);
1660
+ if (!l) return !1;
1661
+ let a = d.single(l.from, l.to), o = e.state.facet(U);
1662
+ return e.dispatch({
1663
+ selection: a,
1664
+ effects: [et(e, l), o.scrollToMatch(a.main, e)],
1665
+ userEvent: "select.search"
1666
+ }), Cr(e), !0;
1667
+ }), kr = /* @__PURE__ */ ce((e, { query: t }) => {
1668
+ let r = t.matchAll(e.state, 1e3);
1669
+ return !r || !r.length ? !1 : (e.dispatch({
1670
+ selection: d.create(r.map((n) => d.range(n.from, n.to))),
1671
+ userEvent: "select.search.matches"
1672
+ }), !0);
1673
+ }), Pl = ({ state: e, dispatch: t }) => {
1674
+ let r = e.selection;
1675
+ if (r.ranges.length > 1 || r.main.empty) return !1;
1676
+ let { from: n, to: l } = r.main, a = [], o = 0;
1677
+ for (let i = new oe(e.doc, e.sliceDoc(n, l)); !i.next().done; ) {
1678
+ if (a.length > 1e3) return !1;
1679
+ i.value.from == n && (o = a.length), a.push(d.range(i.value.from, i.value.to));
1680
+ }
1681
+ return t(e.update({
1682
+ selection: d.create(a, o),
1683
+ userEvent: "select.search.matches"
1684
+ })), !0;
1685
+ }, Ve = /* @__PURE__ */ ce((e, { query: t }) => {
1686
+ let { state: r } = e, { from: n, to: l } = r.selection.main;
1687
+ if (r.readOnly) return !1;
1688
+ let a = t.nextMatch(r, n, n);
1689
+ if (!a) return !1;
1690
+ let o = a, i = [], s, c, u = [];
1691
+ o.precise ? o.from == n && o.to == l && (c = r.toText(t.getReplacement(o)), i.push({
1692
+ from: o.from,
1693
+ to: o.to,
1694
+ insert: c
1695
+ }), o = t.nextMatch(r, o.from, o.to), u.push(g.announce.of(r.phrase("replaced match on line $", r.doc.lineAt(n).number) + "."))) : o = t.nextMatch(r, o.from, o.to);
1696
+ let h = e.state.changes(i);
1697
+ return o && (s = d.single(o.from, o.to).map(h), u.push(et(e, o)), u.push(r.facet(U).scrollToMatch(s.main, e))), e.dispatch({
1698
+ changes: h,
1699
+ selection: s,
1700
+ effects: u,
1701
+ userEvent: "input.replace"
1702
+ }), !0;
1703
+ }), Sr = /* @__PURE__ */ ce((e, { query: t }) => {
1704
+ if (e.state.readOnly) return !1;
1705
+ let r = [];
1706
+ for (let l of t.matchAll(e.state, 1e9)) {
1707
+ let { from: a, to: o, precise: i } = l;
1708
+ i && r.push({
1709
+ from: a,
1710
+ to: o,
1711
+ insert: t.getReplacement(l)
1712
+ });
1713
+ }
1714
+ if (!r.length) return !1;
1715
+ let n = e.state.phrase("replaced $ matches", r.length) + ".";
1716
+ return e.dispatch({
1717
+ changes: r,
1718
+ effects: g.announce.of(n),
1719
+ userEvent: "input.replace.all"
1720
+ }), !0;
1721
+ });
1722
+ function Xe(e) {
1723
+ return e.state.facet(U).createPanel(e);
1724
+ }
1725
+ function Se(e, t) {
1726
+ var r, n, l, a, o;
1727
+ let i = e.selection.main, s = i.empty || i.to > i.from + 100 ? "" : e.sliceDoc(i.from, i.to);
1728
+ if (t && !s) return t;
1729
+ let c = e.facet(U);
1730
+ return new Ye({
1731
+ search: ((r = t?.literal) !== null && r !== void 0 ? r : c.literal) ? s : s.replace(/\n/g, "\\n"),
1732
+ caseSensitive: (n = t?.caseSensitive) !== null && n !== void 0 ? n : c.caseSensitive,
1733
+ literal: (l = t?.literal) !== null && l !== void 0 ? l : c.literal,
1734
+ regexp: (a = t?.regexp) !== null && a !== void 0 ? a : c.regexp,
1735
+ wholeWord: (o = t?.wholeWord) !== null && o !== void 0 ? o : c.wholeWord
1736
+ });
1737
+ }
1738
+ function br(e) {
1739
+ let t = Rt(e, Xe);
1740
+ return t && t.dom.querySelector("[main-field]");
1741
+ }
1742
+ function Cr(e) {
1743
+ let t = br(e);
1744
+ t && t == e.root.activeElement && t.select();
1745
+ }
1746
+ var Ar = (e) => {
1747
+ let t = e.state.field(N, !1);
1748
+ if (t && t.panel) {
1749
+ let r = br(e);
1750
+ if (r && r != e.root.activeElement) {
1751
+ let n = Se(e.state, t.query.spec);
1752
+ n.valid && e.dispatch({ effects: Q.of(n) }), r.focus(), r.select();
1753
+ }
1754
+ } else e.dispatch({ effects: [Ze.of(!0), t ? Q.of(Se(e.state, t.query.spec)) : ie.appendConfig.of(We)] });
1755
+ return !0;
1756
+ }, be = (e) => {
1757
+ let t = e.state.field(N, !1);
1758
+ if (!t || !t.panel) return !1;
1759
+ let r = Rt(e, Xe);
1760
+ return r && r.dom.contains(e.root.activeElement) && e.focus(), e.dispatch({ effects: Ze.of(!1) }), !0;
1761
+ }, ql = [
1762
+ {
1763
+ key: "Mod-f",
1764
+ run: Ar,
1765
+ scope: "editor search-panel"
1766
+ },
1767
+ {
1768
+ key: "F3",
1769
+ run: Y,
1770
+ shift: Z,
1771
+ scope: "editor search-panel",
1772
+ preventDefault: !0
1773
+ },
1774
+ {
1775
+ key: "Mod-g",
1776
+ run: Y,
1777
+ shift: Z,
1778
+ scope: "editor search-panel",
1779
+ preventDefault: !0
1780
+ },
1781
+ {
1782
+ key: "Escape",
1783
+ run: be,
1784
+ scope: "editor search-panel"
1785
+ },
1786
+ {
1787
+ key: "Mod-Shift-l",
1788
+ run: Pl
1789
+ },
1790
+ {
1791
+ key: "Mod-Alt-g",
1792
+ run: bl
1793
+ },
1794
+ {
1795
+ key: "Mod-d",
1796
+ run: Ml,
1797
+ preventDefault: !0
1798
+ }
1799
+ ], Nl = class {
1800
+ constructor(e) {
1801
+ this.view = e;
1802
+ let t = this.query = e.state.field(N).query.spec;
1803
+ this.commit = this.commit.bind(this), this.searchField = D("input", {
1804
+ value: t.search,
1805
+ placeholder: L(e, "Find"),
1806
+ "aria-label": L(e, "Find"),
1807
+ class: "cm-textfield",
1808
+ name: "search",
1809
+ form: "",
1810
+ "main-field": "true",
1811
+ onchange: this.commit,
1812
+ onkeyup: this.commit
1813
+ }), this.replaceField = D("input", {
1814
+ value: t.replace,
1815
+ placeholder: L(e, "Replace"),
1816
+ "aria-label": L(e, "Replace"),
1817
+ class: "cm-textfield",
1818
+ name: "replace",
1819
+ form: "",
1820
+ onchange: this.commit,
1821
+ onkeyup: this.commit
1822
+ }), this.caseField = D("input", {
1823
+ type: "checkbox",
1824
+ name: "case",
1825
+ form: "",
1826
+ checked: t.caseSensitive,
1827
+ onchange: this.commit
1828
+ }), this.reField = D("input", {
1829
+ type: "checkbox",
1830
+ name: "re",
1831
+ form: "",
1832
+ checked: t.regexp,
1833
+ onchange: this.commit
1834
+ }), this.wordField = D("input", {
1835
+ type: "checkbox",
1836
+ name: "word",
1837
+ form: "",
1838
+ checked: t.wholeWord,
1839
+ onchange: this.commit
1840
+ });
1841
+ function r(n, l, a) {
1842
+ return D("button", {
1843
+ class: "cm-button",
1844
+ name: n,
1845
+ onclick: l,
1846
+ type: "button"
1847
+ }, a);
1848
+ }
1849
+ this.dom = D("div", {
1850
+ onkeydown: (n) => this.keydown(n),
1851
+ class: "cm-search"
1852
+ }, [
1853
+ this.searchField,
1854
+ r("next", () => Y(e), [L(e, "next")]),
1855
+ r("prev", () => Z(e), [L(e, "previous")]),
1856
+ r("select", () => kr(e), [L(e, "all")]),
1857
+ D("label", null, [this.caseField, L(e, "match case")]),
1858
+ D("label", null, [this.reField, L(e, "regexp")]),
1859
+ D("label", null, [this.wordField, L(e, "by word")]),
1860
+ ...e.state.readOnly ? [] : [
1861
+ D("br"),
1862
+ this.replaceField,
1863
+ r("replace", () => Ve(e), [L(e, "replace")]),
1864
+ r("replaceAll", () => Sr(e), [L(e, "replace all")])
1865
+ ],
1866
+ D("button", {
1867
+ name: "close",
1868
+ onclick: () => be(e),
1869
+ "aria-label": L(e, "close"),
1870
+ type: "button"
1871
+ }, ["×"])
1872
+ ]);
1873
+ }
1874
+ commit() {
1875
+ let e = new Ye({
1876
+ search: this.searchField.value,
1877
+ caseSensitive: this.caseField.checked,
1878
+ regexp: this.reField.checked,
1879
+ wholeWord: this.wordField.checked,
1880
+ replace: this.replaceField.value
1881
+ });
1882
+ e.eq(this.query) || (this.query = e, this.view.dispatch({ effects: Q.of(e) }));
1883
+ }
1884
+ keydown(e) {
1885
+ Ir(this.view, e, "search-panel") ? e.preventDefault() : e.keyCode == 13 && e.target == this.searchField ? (e.preventDefault(), (e.shiftKey ? Z : Y)(this.view)) : e.keyCode == 13 && e.target == this.replaceField && (e.preventDefault(), Ve(this.view));
1886
+ }
1887
+ update(e) {
1888
+ for (let t of e.transactions) for (let r of t.effects) r.is(Q) && !r.value.eq(this.query) && this.setQuery(r.value);
1889
+ }
1890
+ setQuery(e) {
1891
+ this.query = e, this.searchField.value = e.search, this.replaceField.value = e.replace, this.caseField.checked = e.caseSensitive, this.reField.checked = e.regexp, this.wordField.checked = e.wholeWord;
1892
+ }
1893
+ mount() {
1894
+ this.searchField.select();
1895
+ }
1896
+ get pos() {
1897
+ return 80;
1898
+ }
1899
+ get top() {
1900
+ return this.view.state.facet(U).top;
1901
+ }
1902
+ };
1903
+ function L(e, t) {
1904
+ return e.state.phrase(t);
1905
+ }
1906
+ var fe = 30, de = /[\s\.,:;?!]/;
1907
+ function et(e, { from: t, to: r }) {
1908
+ let n = e.state.doc.lineAt(t), l = e.state.doc.lineAt(r).to, a = Math.max(n.from, t - fe), o = Math.min(l, r + fe), i = e.state.sliceDoc(a, o);
1909
+ if (a != n.from) {
1910
+ for (let s = 0; s < fe; s++) if (!de.test(i[s + 1]) && de.test(i[s])) {
1911
+ i = i.slice(s);
1912
+ break;
1913
+ }
1914
+ }
1915
+ if (o != l) {
1916
+ for (let s = i.length - 1; s > i.length - fe; s--) if (!de.test(i[s - 1]) && de.test(i[s])) {
1917
+ i = i.slice(0, s);
1918
+ break;
1919
+ }
1920
+ }
1921
+ return g.announce.of(`${e.state.phrase("current match")}. ${i} ${e.state.phrase("on line")} ${n.number}.`);
1922
+ }
1923
+ var $l = /* @__PURE__ */ g.baseTheme({
1924
+ ".cm-panel.cm-search": {
1925
+ padding: "2px 6px 4px",
1926
+ position: "relative",
1927
+ "& [name=close]": {
1928
+ position: "absolute",
1929
+ top: "0",
1930
+ right: "4px",
1931
+ backgroundColor: "inherit",
1932
+ border: "none",
1933
+ font: "inherit",
1934
+ padding: 0,
1935
+ margin: 0
1936
+ },
1937
+ "& input, & button, & label": { margin: ".2em .6em .2em 0" },
1938
+ "& input[type=checkbox]": { marginRight: ".2em" },
1939
+ "& label": {
1940
+ fontSize: "80%",
1941
+ whiteSpace: "pre"
1942
+ }
1943
+ },
1944
+ "&light .cm-searchMatch": { backgroundColor: "#ffff0054" },
1945
+ "&dark .cm-searchMatch": { backgroundColor: "#00ffff8a" },
1946
+ "&light .cm-searchMatch-selected": { backgroundColor: "#ff6a0054" },
1947
+ "&dark .cm-searchMatch-selected": { backgroundColor: "#ff00ff8a" }
1948
+ }), We = [
1949
+ N,
1950
+ /* @__PURE__ */ Pr.low(Ol),
1951
+ $l
1952
+ ], Vl = { class: "flex align-items-center gap-025" }, Wl = { class: "code-search-field flex-1 min-w-0" }, _l = { class: "code-search-options flex align-items-center" }, Hl = ["id"], Ul = {
1953
+ key: 1,
1954
+ class: "txt12 color-red",
1955
+ role: "alert"
1956
+ }, zl = /* @__PURE__ */ It({
1957
+ __name: "SearchPanel",
1958
+ props: {
1959
+ view: {},
1960
+ query: {},
1961
+ readonly: { type: Boolean }
1962
+ },
1963
+ setup(e) {
1964
+ const t = e, r = w(t.query.search), n = w(t.query.replace), l = w(t.query.caseSensitive), a = w(t.query.regexp), o = w(t.query.wholeWord), i = w(!1), s = rn();
1965
+ let c = !1;
1966
+ le(() => t.query, (h) => {
1967
+ c = !0, r.value = h.search, n.value = h.replace, l.value = h.caseSensitive, a.value = h.regexp, o.value = h.wholeWord, c = !1;
1968
+ }), le([
1969
+ r,
1970
+ n,
1971
+ l,
1972
+ a,
1973
+ o
1974
+ ], () => {
1975
+ if (c) return;
1976
+ const h = new Ye({
1977
+ search: r.value,
1978
+ replace: n.value,
1979
+ caseSensitive: l.value,
1980
+ regexp: a.value,
1981
+ wholeWord: o.value
1982
+ });
1983
+ h.eq(t.query) || t.view.dispatch({ effects: Q.of(h) });
1984
+ }, { flush: "sync" });
1985
+ function u(h) {
1986
+ h.key === "Escape" ? (h.preventDefault(), be(t.view), t.view.focus()) : h.key === "Enter" && (h.preventDefault(), h.shiftKey ? Z(t.view) : Y(t.view));
1987
+ }
1988
+ return (h, f) => {
1989
+ const v = Ot("tooltip");
1990
+ return A(), T("div", {
1991
+ class: "code-search-panel grid gap-025 p-05",
1992
+ style: {
1993
+ position: "absolute",
1994
+ right: "1rem",
1995
+ opacity: 0.9
1996
+ },
1997
+ role: "search",
1998
+ "aria-label": "Find and replace",
1999
+ onKeydown: u
2000
+ }, [
2001
+ b("div", Vl, [
2002
+ e.readonly ? P("", !0) : M((A(), Ie(C, {
2003
+ key: 0,
2004
+ thin: "",
2005
+ flat: "",
2006
+ icon: i.value ? "expand_more" : "chevron_right",
2007
+ "aria-label": "Toggle replace",
2008
+ "aria-expanded": i.value,
2009
+ "aria-controls": V(s),
2010
+ onClick: f[0] || (f[0] = (m) => i.value = !i.value)
2011
+ }, null, 8, [
2012
+ "icon",
2013
+ "aria-expanded",
2014
+ "aria-controls"
2015
+ ])), [[v, i.value ? "Hide replace" : "Show replace"]]),
2016
+ b("div", Wl, [B(ut, {
2017
+ modelValue: r.value,
2018
+ "onUpdate:modelValue": f[1] || (f[1] = (m) => r.value = m),
2019
+ small: "",
2020
+ placeholder: "Find",
2021
+ class: "min-w-0",
2022
+ "native-input-attrs": {
2023
+ "aria-label": "Find",
2024
+ "main-field": "true",
2025
+ name: "search"
2026
+ }
2027
+ }, null, 8, ["modelValue"]), b("div", _l, [
2028
+ M(B(C, {
2029
+ thin: "",
2030
+ flat: !l.value,
2031
+ soft: l.value,
2032
+ icon: "match_case",
2033
+ "aria-label": "Match case",
2034
+ "aria-pressed": l.value,
2035
+ onClick: f[2] || (f[2] = (m) => l.value = !l.value)
2036
+ }, null, 8, [
2037
+ "flat",
2038
+ "soft",
2039
+ "aria-pressed"
2040
+ ]), [[v, "Match case"]]),
2041
+ M(B(C, {
2042
+ thin: "",
2043
+ flat: !o.value,
2044
+ soft: o.value,
2045
+ icon: "match_word",
2046
+ "aria-label": "Match whole word",
2047
+ "aria-pressed": o.value,
2048
+ onClick: f[3] || (f[3] = (m) => o.value = !o.value)
2049
+ }, null, 8, [
2050
+ "flat",
2051
+ "soft",
2052
+ "aria-pressed"
2053
+ ]), [[v, "Match whole word"]]),
2054
+ M(B(C, {
2055
+ thin: "",
2056
+ flat: !a.value,
2057
+ soft: a.value,
2058
+ icon: "regular_expression",
2059
+ "aria-label": "Regular expression",
2060
+ "aria-pressed": a.value,
2061
+ onClick: f[4] || (f[4] = (m) => a.value = !a.value)
2062
+ }, null, 8, [
2063
+ "flat",
2064
+ "soft",
2065
+ "aria-pressed"
2066
+ ]), [[v, "Regular expression"]])
2067
+ ])]),
2068
+ M(B(C, {
2069
+ thin: "",
2070
+ flat: "",
2071
+ icon: "arrow_upward",
2072
+ "aria-label": "Previous match",
2073
+ onClick: f[5] || (f[5] = (m) => V(Z)(e.view))
2074
+ }, null, 512), [[v, "Previous match (Shift+Enter)"]]),
2075
+ M(B(C, {
2076
+ thin: "",
2077
+ flat: "",
2078
+ icon: "arrow_downward",
2079
+ "aria-label": "Next match",
2080
+ onClick: f[6] || (f[6] = (m) => V(Y)(e.view))
2081
+ }, null, 512), [[v, "Next match (Enter)"]]),
2082
+ M(B(C, {
2083
+ thin: "",
2084
+ flat: "",
2085
+ icon: "select_all",
2086
+ "aria-label": "Select all matches",
2087
+ onClick: f[7] || (f[7] = (m) => V(kr)(e.view))
2088
+ }, null, 512), [[v, "Select all matches"]]),
2089
+ M(B(C, {
2090
+ thin: "",
2091
+ flat: "",
2092
+ icon: "close",
2093
+ "aria-label": "Close search",
2094
+ onClick: f[8] || (f[8] = (m) => {
2095
+ V(be)(e.view), e.view.focus();
2096
+ })
2097
+ }, null, 512), [[v, "Close (Escape)"]])
2098
+ ]),
2099
+ !e.readonly && i.value ? (A(), T("div", {
2100
+ key: 0,
2101
+ id: V(s),
2102
+ class: "code-replace-row flex align-items-center gap-025"
2103
+ }, [
2104
+ B(ut, {
2105
+ modelValue: n.value,
2106
+ "onUpdate:modelValue": f[9] || (f[9] = (m) => n.value = m),
2107
+ small: "",
2108
+ dense: "",
2109
+ placeholder: "Replace",
2110
+ class: "flex-1 min-w-0",
2111
+ "native-input-attrs": {
2112
+ "aria-label": "Replace",
2113
+ name: "replace"
2114
+ }
2115
+ }, null, 8, ["modelValue"]),
2116
+ M(B(C, {
2117
+ thin: "",
2118
+ flat: "",
2119
+ icon: "find_replace",
2120
+ "aria-label": "Replace next",
2121
+ onClick: f[10] || (f[10] = (m) => V(Ve)(e.view))
2122
+ }, null, 512), [[v, "Replace next"]]),
2123
+ M(B(C, {
2124
+ thin: "",
2125
+ flat: "",
2126
+ icon: "published_with_changes",
2127
+ "aria-label": "Replace all",
2128
+ onClick: f[11] || (f[11] = (m) => V(Sr)(e.view))
2129
+ }, null, 512), [[v, "Replace all"]])
2130
+ ], 8, Hl)) : P("", !0),
2131
+ e.query.regexp && e.query.search.length > 0 && !e.query.valid ? (A(), T("span", Ul, "Invalid regular expression")) : P("", !0)
2132
+ ], 32);
2133
+ };
2134
+ }
2135
+ }), Gl = /* @__PURE__ */ Lt(zl, [["__scopeId", "data-v-c5ae435d"]]);
2136
+ function Jl(e) {
2137
+ return [
2138
+ "html",
2139
+ "xml",
2140
+ "javascript",
2141
+ "js",
2142
+ "typescript",
2143
+ "ts",
2144
+ "json",
2145
+ "css"
2146
+ ].includes(e);
2147
+ }
2148
+ async function jl(e, t) {
2149
+ const { format: r } = await import("./standalone-D-HcbQmf.js"), n = {
2150
+ tabWidth: 2,
2151
+ useTabs: !1
2152
+ };
2153
+ switch (t) {
2154
+ case "html":
2155
+ case "xml": {
2156
+ const l = await import("./html-B-hsQYII.js");
2157
+ return r(e, {
2158
+ ...n,
2159
+ parser: "html",
2160
+ plugins: [l],
2161
+ htmlWhitespaceSensitivity: "strict"
2162
+ });
2163
+ }
2164
+ case "css": {
2165
+ const l = await import("./postcss-Bk65KKdh.js");
2166
+ return r(e, {
2167
+ ...n,
2168
+ parser: "css",
2169
+ plugins: [l]
2170
+ });
2171
+ }
2172
+ case "json":
2173
+ case "javascript":
2174
+ case "js":
2175
+ case "typescript":
2176
+ case "ts": {
2177
+ const [l, a] = await Promise.all([import("./babel-BVvTH0ev.js"), import("./estree-CKgw47OZ.js")]), o = t === "json" ? "json" : ["typescript", "ts"].includes(t) ? "babel-ts" : "babel";
2178
+ return r(e, {
2179
+ ...n,
2180
+ parser: o,
2181
+ plugins: [l, a]
2182
+ });
2183
+ }
2184
+ default:
2185
+ return e;
2186
+ }
2187
+ }
2188
+ var Kl = {
2189
+ key: 0,
2190
+ class: "code-terminal-bar monospace flex flex-shrink-0 space-between gap-05 py-025 px-075 txt11 line-height-1 border-bottom"
2191
+ }, Ql = { class: "flex gap-05 min-w-0" }, Yl = {
2192
+ key: 0,
2193
+ class: "opacity-5 ellipsis-1"
2194
+ }, Zl = { class: "flex align-items-center gap-025 flex-shrink-0" }, Xl = {
2195
+ class: "opacity-5 px-05",
2196
+ "aria-label": "Code language"
2197
+ }, ea = {
2198
+ class: "hide",
2199
+ role: "status"
2200
+ }, ta = {
2201
+ key: 1,
2202
+ class: "code-toolbar flex flex-shrink-0 align-items-center space-between gap-05 py-025"
2203
+ }, ra = {
2204
+ key: 0,
2205
+ class: "label mb-0"
2206
+ }, na = {
2207
+ key: 1,
2208
+ class: "txt11 opacity-5",
2209
+ "aria-label": "Code language"
2210
+ }, la = { class: "flex align-items-center gap-025 ms-auto" }, aa = {
2211
+ key: 0,
2212
+ class: "txt11 opacity-5 px-05",
2213
+ "aria-label": "Code language"
2214
+ }, oa = {
2215
+ class: "hide",
2216
+ role: "status"
2217
+ }, ia = {
2218
+ key: 2,
2219
+ role: "alert",
2220
+ class: "code-alert txt12 color-red px-075"
2221
+ }, sa = /* @__PURE__ */ It({
2222
+ __name: "StructuredEditor",
2223
+ props: {
2224
+ modelValue: {},
2225
+ language: {},
2226
+ lineNumbers: { type: Boolean },
2227
+ folding: { type: Boolean },
2228
+ formatting: { type: Boolean },
2229
+ readonly: { type: Boolean },
2230
+ disabled: { type: Boolean },
2231
+ wrap: { type: Boolean },
2232
+ singleLine: { type: Boolean },
2233
+ placeholder: {},
2234
+ label: {},
2235
+ dark: { type: Boolean },
2236
+ terminal: { type: Boolean },
2237
+ title: {},
2238
+ toolbarMode: {}
2239
+ },
2240
+ emits: [
2241
+ "update:modelValue",
2242
+ "focus",
2243
+ "blur"
2244
+ ],
2245
+ setup(e, { emit: t }) {
2246
+ const r = e, n = t, l = w(), a = w(!1), o = w(""), i = w(!1), s = w("");
2247
+ let c;
2248
+ const u = {
2249
+ javascript: "JS",
2250
+ typescript: "TS"
2251
+ }, h = G(() => u[r.language] || r.language.toUpperCase()), f = G(() => r.formatting && !r.singleLine && Jl(r.language)), v = G(() => r.toolbarMode ?? "bar"), m = G(() => !r.terminal && v.value === "hover"), ue = G(() => a.value || i.value || !!(o.value || s.value)), ee = G(() => !r.singleLine), z = new ft(), tt = new ft(), rt = Ge.define();
2252
+ let k, nt = 0, Be = !1;
2253
+ async function lt() {
2254
+ s.value = "";
2255
+ try {
2256
+ await wr(k?.state.doc.toString() ?? r.modelValue), i.value = !0, clearTimeout(c), c = setTimeout(() => {
2257
+ i.value = !1;
2258
+ }, 2e3);
2259
+ } catch {
2260
+ s.value = "Could not copy. Check clipboard permissions and try again.";
2261
+ }
2262
+ }
2263
+ const Mr = Yr().appContext, Lr = pr({
2264
+ theme: "light",
2265
+ settings: {
2266
+ background: "#fafafa",
2267
+ foreground: "#383a42",
2268
+ caret: "#526fff",
2269
+ selection: "#d7d7d7",
2270
+ selectionMatch: "#e5e5e6",
2271
+ lineHighlight: "#f0f0f0",
2272
+ gutterBackground: "#fafafa",
2273
+ gutterForeground: "#9d9d9f"
2274
+ }
2275
+ });
2276
+ function Br(p) {
2277
+ const x = document.createElement("div"), O = tn(Mt(p.state)), st = w(p.state.readOnly), ct = dt({ setup: () => () => dt(Gl, {
2278
+ view: p,
2279
+ query: O.value,
2280
+ readonly: st.value
2281
+ }) });
2282
+ return ct.appContext = Mr, mt(ct, x), {
2283
+ dom: x,
2284
+ top: !0,
2285
+ update() {
2286
+ O.value = Mt(p.state), st.value = p.state.readOnly;
2287
+ },
2288
+ destroy() {
2289
+ mt(null, x);
2290
+ }
2291
+ };
2292
+ }
2293
+ function at() {
2294
+ const p = r.singleLine ? "0" : "0.75em 1ch 1.5em 2ch";
2295
+ return [
2296
+ r.dark ? kl : Lr,
2297
+ r.lineNumbers && !r.singleLine ? Nr() : [],
2298
+ r.folding && !r.singleLine ? [Ur(), ht.of(Jr)] : [],
2299
+ r.wrap ? g.lineWrapping : [],
2300
+ me.readOnly.of(r.readonly || r.disabled),
2301
+ g.editable.of(!r.readonly && !r.disabled),
2302
+ g.contentAttributes.of({
2303
+ "aria-label": r.label || "Code editor",
2304
+ "aria-disabled": String(r.disabled)
2305
+ }),
2306
+ Vr(r.placeholder),
2307
+ g.theme({
2308
+ "&": {
2309
+ height: "100%",
2310
+ ...r.terminal ? { backgroundColor: "transparent" } : {}
2311
+ },
2312
+ ".cm-scroller": {
2313
+ overflow: "auto",
2314
+ fontFamily: "inherit",
2315
+ lineHeight: "1.5",
2316
+ overscrollBehavior: "contain"
2317
+ },
2318
+ ".cm-content": {
2319
+ padding: p,
2320
+ fontVariantLigatures: "none",
2321
+ tabSize: 2,
2322
+ caretColor: r.dark ? "#fff" : "#1b1f23"
2323
+ },
2324
+ ".cm-gutters": r.terminal ? {
2325
+ backgroundColor: "transparent",
2326
+ border: "none"
2327
+ } : {},
2328
+ ".cm-activeLineGutter": r.terminal ? { backgroundColor: "transparent" } : {},
2329
+ "&.cm-focused": { outline: "none" },
2330
+ ".cm-selectionBackground, &.cm-focused .cm-selectionBackground": { backgroundColor: r.dark ? "rgba(36, 102, 188, 0.35)" : "rgba(36, 102, 188, 0.3)" }
2331
+ }, { dark: r.dark })
2332
+ ];
2333
+ }
2334
+ async function Dr() {
2335
+ const p = ++nt;
2336
+ let x = [];
2337
+ switch (r.language) {
2338
+ case "html":
2339
+ case "xml":
2340
+ x = (await import("./dist-D8OWrPLr.js")).html();
2341
+ break;
2342
+ case "javascript":
2343
+ case "js":
2344
+ case "typescript":
2345
+ case "ts":
2346
+ x = (await import("./dist-B0uc2InW.js")).javascript({ typescript: ["typescript", "ts"].includes(r.language) });
2347
+ break;
2348
+ case "json":
2349
+ x = (await import("./dist-BnLdfA7w.js")).json();
2350
+ break;
2351
+ case "css":
2352
+ x = (await import("./dist-jq7acmcZ.js")).css();
2353
+ break;
2354
+ }
2355
+ !Be && p === nt && k?.dispatch({ effects: tt.reconfigure(x) });
2356
+ }
2357
+ function ot() {
2358
+ Dr().catch(() => {
2359
+ Be || (o.value = "Could not load syntax support. Plain-text editing is still available.");
2360
+ });
2361
+ }
2362
+ async function it() {
2363
+ if (!k || !f.value || r.readonly || r.disabled || a.value) return;
2364
+ const p = k.state.doc, x = r.language;
2365
+ a.value = !0, o.value = "";
2366
+ try {
2367
+ const O = await jl(p.toString(), x);
2368
+ k && k.state.doc === p && r.language === x && !r.readonly && !r.disabled && (k.dispatch({
2369
+ changes: {
2370
+ from: 0,
2371
+ to: p.length,
2372
+ insert: O
2373
+ },
2374
+ userEvent: "input.format"
2375
+ }), k.focus());
2376
+ } catch {
2377
+ o.value = "Could not format this code. Check its syntax and try again.";
2378
+ } finally {
2379
+ a.value = !1;
2380
+ }
2381
+ }
2382
+ return en(() => {
2383
+ k = new g({
2384
+ parent: l.value,
2385
+ state: me.create({
2386
+ doc: r.modelValue,
2387
+ extensions: [
2388
+ z.of(at()),
2389
+ tt.of([]),
2390
+ dn(),
2391
+ wt.of(" "),
2392
+ Qr(),
2393
+ Hr(),
2394
+ Ll({ createPanel: Br }),
2395
+ ht.of([
2396
+ {
2397
+ key: "Enter",
2398
+ run: () => r.singleLine
2399
+ },
2400
+ ...pl,
2401
+ ...bn,
2402
+ ...ql,
2403
+ gl
2404
+ ]),
2405
+ me.transactionFilter.of((p) => r.singleLine && p.docChanged && p.newDoc.lines > 1 ? [] : p),
2406
+ g.updateListener.of((p) => {
2407
+ p.docChanged && !p.transactions.some((x) => x.annotation(rt)) && n("update:modelValue", p.state.doc.toString()), p.focusChanged && (p.view.hasFocus ? n("focus") : n("blur"));
2408
+ })
2409
+ ]
2410
+ })
2411
+ }), ot();
2412
+ }), le(() => r.modelValue, (p) => {
2413
+ k && p !== k.state.doc.toString() && k.dispatch({
2414
+ changes: {
2415
+ from: 0,
2416
+ to: k.state.doc.length,
2417
+ insert: p
2418
+ },
2419
+ annotations: rt.of(!0)
2420
+ });
2421
+ }), le(() => r.language, ot), le(() => [
2422
+ r.lineNumbers,
2423
+ r.folding,
2424
+ r.readonly,
2425
+ r.disabled,
2426
+ r.wrap,
2427
+ r.singleLine,
2428
+ r.placeholder,
2429
+ r.label,
2430
+ r.dark,
2431
+ r.terminal
2432
+ ], () => {
2433
+ k?.dispatch({ effects: z.reconfigure(at()) });
2434
+ }), Xr(() => {
2435
+ Be = !0, clearTimeout(c), k?.destroy(), k = void 0;
2436
+ }), (p, x) => {
2437
+ const O = Ot("tooltip");
2438
+ return A(), T("div", { class: Zr(["structured-editor", {
2439
+ terminal: e.terminal,
2440
+ "toolbar-hover": m.value,
2441
+ "toolbar-pinned": ue.value,
2442
+ "single-line": e.singleLine
2443
+ }]) }, [
2444
+ e.terminal && ee.value ? (A(), T("div", Kl, [b("div", Ql, [x[0] || (x[0] = b("span", {
2445
+ class: "inline-flex gap-025 flex-shrink-0",
2446
+ "aria-hidden": "true"
2447
+ }, [
2448
+ b("span", { class: "square-10 round bg-red" }),
2449
+ b("span", { class: "square-10 round bg-yellow" }),
2450
+ b("span", { class: "square-10 round bg-green" })
2451
+ ], -1)), e.title ? (A(), T("span", Yl, $(e.title), 1)) : P("", !0)]), b("div", Zl, [
2452
+ b("span", Xl, $(h.value), 1),
2453
+ f.value ? M((A(), Ie(C, {
2454
+ key: 0,
2455
+ thin: "",
2456
+ flat: "",
2457
+ "icon-size": "1",
2458
+ icon: "format_align_left",
2459
+ "aria-label": "Format code",
2460
+ "aria-busy": a.value,
2461
+ disabled: e.readonly || e.disabled || a.value,
2462
+ onClick: it
2463
+ }, null, 8, ["aria-busy", "disabled"])), [[O, a.value ? "Formatting…" : "Format code"]]) : P("", !0),
2464
+ M(B(C, {
2465
+ thin: "",
2466
+ flat: "",
2467
+ "icon-size": "1",
2468
+ icon: i.value ? "check" : "content_copy",
2469
+ "aria-label": i.value ? "Copied!" : "Copy code",
2470
+ onClick: lt
2471
+ }, null, 8, ["icon", "aria-label"]), [[O, i.value ? "Copied!" : "Copy code"]]),
2472
+ b("span", ea, $(i.value ? "Copied to clipboard" : ""), 1)
2473
+ ])])) : ee.value ? (A(), T("div", ta, [e.label && !m.value ? (A(), T("label", ra, $(e.label), 1)) : (A(), T("span", na, $(h.value), 1)), b("div", la, [
2474
+ e.label && !m.value ? (A(), T("span", aa, $(h.value), 1)) : P("", !0),
2475
+ f.value ? M((A(), Ie(C, {
2476
+ key: 1,
2477
+ thin: "",
2478
+ flat: "",
2479
+ "icon-size": "1",
2480
+ icon: "format_align_left",
2481
+ "aria-label": "Format code",
2482
+ "aria-busy": a.value,
2483
+ disabled: e.readonly || e.disabled || a.value,
2484
+ onClick: it
2485
+ }, null, 8, ["aria-busy", "disabled"])), [[O, a.value ? "Formatting…" : "Format code"]]) : P("", !0),
2486
+ M(B(C, {
2487
+ thin: "",
2488
+ flat: "",
2489
+ "icon-size": "1",
2490
+ icon: i.value ? "check" : "content_copy",
2491
+ "aria-label": i.value ? "Copied!" : "Copy code",
2492
+ onClick: lt
2493
+ }, null, 8, ["icon", "aria-label"]), [[O, i.value ? "Copied!" : "Copy code"]]),
2494
+ b("span", oa, $(i.value ? "Copied to clipboard" : ""), 1)
2495
+ ])])) : P("", !0),
2496
+ o.value || s.value ? (A(), T("span", ia, $(o.value || s.value), 1)) : P("", !0),
2497
+ b("div", {
2498
+ ref_key: "host",
2499
+ ref: l,
2500
+ class: "structured-editor-host"
2501
+ }, null, 512)
2502
+ ], 2);
2503
+ };
2504
+ }
2505
+ }), da = /* @__PURE__ */ Lt(sa, [["__scopeId", "data-v-7cd77e82"]]);
2506
+ export {
2507
+ da as default
2508
+ };