@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.
@@ -1,2431 +0,0 @@
1
- import { Na as xt, Yr as rt, ka as M, tn as Mr } from "./src-CgzOmRZD.js";
2
- import { $ as kt, A as Lr, B as Br, C as Dr, D as v, E as Er, F as wr, G as he, H as O, I as Rr, J as Tr, K as $e, L as Fr, M as nt, N as Ir, O as Or, P as Pr, Q as St, R as C, T as Ve, U as lt, V as qr, W as d, Y as Nr, Z as oe, a as $r, at as V, b as bt, ct as x, d as Vr, dt as we, et as Me, g as Ct, h as Re, it as We, j as At, n as Mt, nt as Wr, ot as _r, p as Hr, rt as Lt, t as Ur, tt as Gr, v as Jr, w as _e, x as G, y as de, z as He } from "./dist-IV7z-zur.js";
3
- import { computed as ot, createBlock as Bt, createCommentVNode as J, createElementBlock as z, createElementVNode as $, createVNode as A, defineComponent as Dt, getCurrentInstance as zr, h as at, onBeforeUnmount as jr, onMounted as Kr, openBlock as P, ref as B, render as it, resolveDirective as Et, shallowRef as Qr, toDisplayString as Le, unref as I, useId as Yr, watch as re, withDirectives as L } from "vue";
4
- var Zr = (e) => {
5
- let { state: t } = e, r = t.doc.lineAt(t.selection.main.from), n = Ge(e.state, r.from);
6
- return n.line ? Xr(e) : n.block ? tn(e) : !1;
7
- };
8
- function Ue(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 Xr = /* @__PURE__ */ Ue(ln, 0), en = /* @__PURE__ */ Ue(wt, 0), tn = /* @__PURE__ */ Ue((e, t) => wt(e, t, nn(t)), 0);
16
- function Ge(e, t) {
17
- let r = e.languageDataAt("commentTokens", t, 1);
18
- return r.length ? r[0] : {};
19
- }
20
- var X = 50;
21
- function rn(e, { open: t, close: r }, n, l) {
22
- let o = e.sliceDoc(n - X, n), a = e.sliceDoc(l, l + X), i = /\s*$/.exec(o)[0].length, s = /^\s*/.exec(a)[0].length, c = o.length - i;
23
- if (o.slice(c - t.length, c) == t && a.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 * X ? u = h = e.sliceDoc(n, l) : (u = e.sliceDoc(n, n + X), h = e.sliceDoc(l - X, l));
35
- let f = /^\s*/.exec(u)[0].length, g = /\s*$/.exec(h)[0].length, m = h.length - g - 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 - g - r.length,
43
- margin: /\s/.test(h.charAt(m - 1)) ? 1 : 0
44
- }
45
- } : null;
46
- }
47
- function nn(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 o = t.length - 1;
53
- o >= 0 && t[o].to > n.from ? t[o].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 wt(e, t, r = t.selection.ranges) {
61
- let n = r.map((o) => Ge(t, o.from).block);
62
- if (!n.every((o) => o)) return null;
63
- let l = r.map((o, a) => rn(t, n[a], o.from, o.to));
64
- if (e != 2 && !l.every((o) => o)) return { changes: t.changes(r.map((o, a) => l[a] ? [] : [{
65
- from: o.from,
66
- insert: n[a].open + " "
67
- }, {
68
- from: o.to,
69
- insert: " " + n[a].close
70
- }])) };
71
- if (e != 1 && l.some((o) => o)) {
72
- let o = [];
73
- for (let a = 0, i; a < l.length; a++) if (i = l[a]) {
74
- let s = n[a], { open: c, close: u } = i;
75
- o.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: o };
84
- }
85
- return null;
86
- }
87
- function ln(e, t, r = t.selection.ranges) {
88
- let n = [], l = -1;
89
- e: for (let { from: o, to: a } of r) {
90
- let i = n.length, s = 1e9, c;
91
- for (let u = o; u <= a; ) {
92
- let h = t.doc.lineAt(u);
93
- if (c == null && (c = Ge(t, h.from).line, !c))
94
- continue e;
95
- if (h.from > l && (o == a || a > h.from)) {
96
- l = h.from;
97
- let f = /^\s*/.exec(h.text)[0].length, g = 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: g,
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((o) => o.comment < 0 && (!o.empty || o.single))) {
114
- let o = [];
115
- for (let { line: i, token: s, indent: c, empty: u, single: h } of n) (h || !u) && o.push({
116
- from: i.from + c,
117
- insert: s + " "
118
- });
119
- let a = t.changes(o);
120
- return {
121
- changes: a,
122
- selection: t.selection.map(a, 1)
123
- };
124
- } else if (e != 1 && n.some((o) => o.comment >= 0)) {
125
- let o = [];
126
- for (let { line: a, comment: i, token: s } of n) if (i >= 0) {
127
- let c = a.from + i, u = c + s.length;
128
- a.text[u - a.from] == " " && u++, o.push({
129
- from: c,
130
- to: u
131
- });
132
- }
133
- return { changes: o };
134
- }
135
- return null;
136
- }
137
- var Te = /* @__PURE__ */ He.define(), on = /* @__PURE__ */ He.define(), an = /* @__PURE__ */ $e.define(), Rt = /* @__PURE__ */ $e.define({ combine(e) {
138
- return Lt(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
- } }), Tt = /* @__PURE__ */ St.define({
148
- create() {
149
- return ne.empty;
150
- },
151
- update(e, t) {
152
- let r = t.state.facet(Rt), n = t.annotation(Te);
153
- if (n) {
154
- let s = T.fromTransaction(t, n.selection), c = n.side, u = c == 0 ? e.undone : e.done;
155
- return s ? u = me(u, u.length, r.minDepth, s) : u = Ot(u, t.startState.selection), new ne(c == 0 ? n.rest : u, c == 0 ? u : n.rest);
156
- }
157
- let l = t.annotation(on);
158
- if ((l == "full" || l == "before") && (e = e.isolate()), t.annotation(Me.addToHistory) === !1) return t.changes.empty ? e : e.addMapping(t.changes.desc);
159
- let o = T.fromTransaction(t), a = t.annotation(Me.time), i = t.annotation(Me.userEvent);
160
- return o ? e = e.addChanges(o, a, i, r, t) : t.selection && (e = e.addSelection(t.startState.selection, a, 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 ne(e.done.map(T.fromJSON), e.undone.map(T.fromJSON));
170
- }
171
- });
172
- function sn(e = {}) {
173
- return [
174
- Tt,
175
- Rt.of(e),
176
- v.domEventHandlers({ beforeinput(t, r) {
177
- let n = t.inputType == "historyUndo" ? Ft : t.inputType == "historyRedo" ? Fe : null;
178
- return n ? (t.preventDefault(), n(r)) : !1;
179
- } })
180
- ];
181
- }
182
- function ke(e, t) {
183
- return function({ state: r, dispatch: n }) {
184
- if (!t && r.readOnly) return !1;
185
- let l = r.field(Tt, !1);
186
- if (!l) return !1;
187
- let o = l.pop(e, r, t);
188
- return o ? (n(o), !0) : !1;
189
- };
190
- }
191
- var Ft = /* @__PURE__ */ ke(0, !1), Fe = /* @__PURE__ */ ke(1, !1), cn = /* @__PURE__ */ ke(0, !0), un = /* @__PURE__ */ ke(1, !0), T = class ee {
192
- constructor(t, r, n, l, o) {
193
- this.changes = t, this.effects = r, this.mapped = n, this.startSelection = l, this.selectionsAfter = o;
194
- }
195
- setSelAfter(t) {
196
- return new ee(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 ee(t.changes && qr.fromJSON(t.changes), [], t.mapped && Br.fromJSON(t.mapped), t.startSelection && d.fromJSON(t.startSelection), t.selectionsAfter.map(d.fromJSON));
209
- }
210
- static fromTransaction(t, r) {
211
- let n = D;
212
- for (let l of t.startState.facet(an)) {
213
- let o = l(t);
214
- o.length && (n = n.concat(o));
215
- }
216
- return !n.length && t.changes.empty ? null : new ee(t.changes.invert(t.startState.doc), n, void 0, r || t.startState.selection, D);
217
- }
218
- static selection(t) {
219
- return new ee(void 0, D, void 0, void 0, t);
220
- }
221
- };
222
- function me(e, t, r, n) {
223
- let l = t + 1 > r + 20 ? t - r - 1 : 0, o = e.slice(l, t);
224
- return o.push(n), o;
225
- }
226
- function hn(e, t) {
227
- let r = [], n = !1;
228
- return e.iterChangedRanges((l, o) => r.push(l, o)), t.iterChangedRanges((l, o, a, i) => {
229
- for (let s = 0; s < r.length; ) {
230
- let c = r[s++], u = r[s++];
231
- i >= c && a <= u && (n = !0);
232
- }
233
- }), n;
234
- }
235
- function fn(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 It(e, t) {
239
- return e.length ? t.length ? e.concat(t) : e : t;
240
- }
241
- var D = [], dn = 200;
242
- function Ot(e, t) {
243
- if (e.length) {
244
- let r = e[e.length - 1], n = r.selectionsAfter.slice(Math.max(0, r.selectionsAfter.length - dn));
245
- return n.length && n[n.length - 1].eq(t) ? e : (n.push(t), me(e, e.length - 1, 1e9, r.setSelAfter(n)));
246
- } else
247
- return [T.selection([t])];
248
- }
249
- function mn(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 Be(e, t) {
254
- if (!e.length) return e;
255
- let r = e.length, n = D;
256
- for (; r; ) {
257
- let l = pn(e[r - 1], t, n);
258
- if (l.changes && !l.changes.empty || l.effects.length) {
259
- let o = e.slice(0, r);
260
- return o[r - 1] = l, o;
261
- } else
262
- t = l.mapped, r--, n = l.selectionsAfter;
263
- }
264
- return n.length ? [T.selection(n)] : D;
265
- }
266
- function pn(e, t, r) {
267
- let n = It(e.selectionsAfter.length ? e.selectionsAfter.map((i) => i.map(t)) : D, r);
268
- if (!e.changes) return T.selection(n);
269
- let l = e.changes.map(t), o = t.mapDesc(e.changes, !0), a = e.mapped ? e.mapped.composeDesc(o) : o;
270
- return new T(l, oe.mapEffects(e.effects, t), a, e.startSelection.map(o), n);
271
- }
272
- var gn = /^(input\.type|delete)($|\.)/, ne = class te {
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 te(this.done, this.undone) : this;
278
- }
279
- addChanges(t, r, n, l, o) {
280
- let a = this.done, i = a[a.length - 1];
281
- return i && i.changes && !i.changes.empty && t.changes && (!n || gn.test(n)) && (!i.selectionsAfter.length && r - this.prevTime < l.newGroupDelay && l.joinToEvent(o, hn(i.changes, t.changes)) || n == "input.type.compose") ? a = me(a, a.length - 1, l.minDepth, new T(t.changes.compose(i.changes), It(oe.mapEffects(t.effects, i.changes), i.effects), i.mapped, i.startSelection, D)) : a = me(a, a.length, l.minDepth, t), new te(a, D, r, n);
282
- }
283
- addSelection(t, r, n, l) {
284
- let o = this.done.length ? this.done[this.done.length - 1].selectionsAfter : D;
285
- return o.length > 0 && r - this.prevTime < l && n == this.prevUserEvent && n && /^select($|\.)/.test(n) && fn(o[o.length - 1], t) ? this : new te(Ot(this.done, t), this.undone, r, n);
286
- }
287
- addMapping(t) {
288
- return new te(Be(this.done, t), Be(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 o = l[l.length - 1], a = o.selectionsAfter[0] || (o.startSelection ? o.startSelection.map(o.changes.invertedDesc, 1) : r.selection);
294
- if (n && o.selectionsAfter.length) return r.update({
295
- selection: o.selectionsAfter[o.selectionsAfter.length - 1],
296
- annotations: Te.of({
297
- side: t,
298
- rest: mn(l),
299
- selection: a
300
- }),
301
- userEvent: t == 0 ? "select.undo" : "select.redo",
302
- scrollIntoView: !0
303
- });
304
- if (o.changes) {
305
- let i = l.length == 1 ? D : l.slice(0, l.length - 1);
306
- return o.mapped && (i = Be(i, o.mapped)), r.update({
307
- changes: o.changes,
308
- selection: o.startSelection,
309
- effects: o.effects,
310
- annotations: Te.of({
311
- side: t,
312
- rest: i,
313
- selection: a
314
- }),
315
- filter: !1,
316
- userEvent: t == 0 ? "undo" : "redo",
317
- scrollIntoView: !0
318
- });
319
- } else
320
- return null;
321
- }
322
- };
323
- ne.empty = /* @__PURE__ */ new ne(D, D);
324
- var vn = [
325
- {
326
- key: "Mod-z",
327
- run: Ft,
328
- preventDefault: !0
329
- },
330
- {
331
- key: "Mod-y",
332
- mac: "Mod-Shift-z",
333
- run: Fe,
334
- preventDefault: !0
335
- },
336
- {
337
- linux: "Ctrl-Shift-z",
338
- run: Fe,
339
- preventDefault: !0
340
- },
341
- {
342
- key: "Mod-u",
343
- run: cn,
344
- preventDefault: !0
345
- },
346
- {
347
- key: "Alt-u",
348
- mac: "Mod-Shift-u",
349
- run: un,
350
- preventDefault: !0
351
- }
352
- ];
353
- function Y(e, t) {
354
- return d.create(e.ranges.map(t), e.mainIndex);
355
- }
356
- function w(e, t) {
357
- return e.update({
358
- selection: t,
359
- scrollIntoView: !0,
360
- userEvent: "select"
361
- });
362
- }
363
- function R({ state: e, dispatch: t }, r) {
364
- let n = Y(e.selection, r);
365
- return n.eq(e.selection, !0) ? !1 : (t(w(e, n)), !0);
366
- }
367
- function Se(e, t) {
368
- return d.cursor(t ? e.to : e.from);
369
- }
370
- function Pt(e, t) {
371
- return R(e, (r) => r.empty ? e.moveByChar(r, t) : Se(r, t));
372
- }
373
- function k(e) {
374
- return e.textDirectionAt(e.state.selection.main.head) == Er.LTR;
375
- }
376
- var qt = (e) => Pt(e, !k(e)), Nt = (e) => Pt(e, k(e));
377
- function $t(e, t) {
378
- return R(e, (r) => r.empty ? e.moveByGroup(r, t) : Se(r, t));
379
- }
380
- var yn = (e) => $t(e, !k(e)), xn = (e) => $t(e, k(e)), eo = typeof Intl < "u" && Intl.Segmenter ? /* @__PURE__ */ new Intl.Segmenter(void 0, { granularity: "word" }) : null;
381
- function kn(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 be(e, t, r) {
387
- let n = _e(e).resolveInner(t.head), l = r ? we.closedBy : we.openedBy;
388
- for (let s = t.head; ; ) {
389
- let c = r ? n.childAfter(s) : n.childBefore(s);
390
- if (!c) break;
391
- kn(e, c, l) ? n = c : s = r ? c.to : c.from;
392
- }
393
- let o = n.type.prop(l), a, i;
394
- return o && (a = r ? G(e, n.from, 1) : G(e, n.to, -1)) && a.matched ? i = r ? a.end.to : a.end.from : i = r ? n.to : n.from, d.cursor(i, r ? -1 : 1);
395
- }
396
- var Sn = (e) => R(e, (t) => be(e.state, t, !k(e))), bn = (e) => R(e, (t) => be(e.state, t, k(e)));
397
- function Vt(e, t) {
398
- return R(e, (r) => {
399
- if (!r.empty) return Se(r, t);
400
- let n = e.moveVertically(r, t);
401
- return n.head != r.head ? n : e.moveToLineBoundary(r, t);
402
- });
403
- }
404
- var Wt = (e) => Vt(e, !1), _t = (e) => Vt(e, !0);
405
- function Ht(e) {
406
- let t = e.scrollDOM.clientHeight < e.scrollDOM.scrollHeight - 2, r = 0, n = 0, l;
407
- if (t) {
408
- for (let o of e.state.facet(v.scrollMargins)) {
409
- let a = o(e);
410
- a?.top && (r = Math.max(a?.top, r)), a?.bottom && (n = Math.max(a?.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 Ut(e, t) {
422
- let r = Ht(e), { state: n } = e, l = Y(n.selection, (a) => a.empty ? e.moveVertically(a, t, r.height) : Se(a, t));
423
- if (l.eq(n.selection)) return !1;
424
- let o;
425
- if (r.selfScroll) {
426
- let a = e.coordsAtPos(n.selection.main.head), i = e.scrollDOM.getBoundingClientRect(), s = i.top + r.marginTop, c = i.bottom - r.marginBottom;
427
- a && a.top > s && a.bottom < c && (o = v.scrollIntoView(l.main.head, {
428
- y: "start",
429
- yMargin: a.top - s
430
- }));
431
- }
432
- return e.dispatch(w(n, l), { effects: o }), !0;
433
- }
434
- var st = (e) => Ut(e, !1), Ie = (e) => Ut(e, !0);
435
- function q(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 o = /^\s*/.exec(e.state.sliceDoc(n.from, Math.min(n.from + 100, n.to)))[0].length;
439
- o && t.head != n.from + o && (l = d.cursor(n.from + o));
440
- }
441
- return l;
442
- }
443
- var Cn = (e) => R(e, (t) => q(e, t, !0)), An = (e) => R(e, (t) => q(e, t, !1)), Mn = (e) => R(e, (t) => q(e, t, !k(e))), Ln = (e) => R(e, (t) => q(e, t, k(e))), Bn = (e) => R(e, (t) => e.moveToLineBoundary(t, !1, !1)), Dn = (e) => R(e, (t) => e.moveToLineBoundary(t, !0, !1));
444
- function En(e, t, r) {
445
- let n = !1, l = Y(e.selection, (o) => {
446
- let a = G(e, o.head, -1) || G(e, o.head, 1) || o.head > 0 && G(e, o.head - 1, 1) || o.head < e.doc.length && G(e, o.head + 1, -1);
447
- if (!a || !a.end) return o;
448
- n = !0;
449
- let i = a.start.from == o.head ? a.end.to : a.end.from;
450
- return r ? d.range(o.anchor, i) : d.cursor(i);
451
- });
452
- return n ? (t(w(e, l)), !0) : !1;
453
- }
454
- var wn = ({ state: e, dispatch: t }) => En(e, t, !1);
455
- function E(e, t, r) {
456
- let n = Y(e.state.selection, (l) => {
457
- l.undirectional && l.head >= l.anchor != t && (l = d.range(l.head, l.anchor));
458
- let o = r(l);
459
- return d.range(l.anchor, o.head, o.goalColumn, o.bidiLevel || void 0, o.assoc);
460
- });
461
- return n.eq(e.state.selection) ? !1 : (e.dispatch(w(e.state, n)), !0);
462
- }
463
- function Gt(e, t) {
464
- return E(e, t, (r) => e.moveByChar(r, t));
465
- }
466
- var Jt = (e) => Gt(e, !k(e)), zt = (e) => Gt(e, k(e));
467
- function jt(e, t) {
468
- return E(e, t, (r) => e.moveByGroup(r, t));
469
- }
470
- var Rn = (e) => jt(e, !k(e)), Tn = (e) => jt(e, k(e)), Fn = (e) => {
471
- let t = !k(e);
472
- return E(e, t, (r) => be(e.state, r, t));
473
- }, In = (e) => {
474
- let t = k(e);
475
- return E(e, t, (r) => be(e.state, r, t));
476
- };
477
- function Kt(e, t) {
478
- return E(e, t, (r) => e.moveVertically(r, t));
479
- }
480
- var Qt = (e) => Kt(e, !1), Yt = (e) => Kt(e, !0);
481
- function Zt(e, t) {
482
- return E(e, t, (r) => e.moveVertically(r, t, Ht(e).height));
483
- }
484
- var ct = (e) => Zt(e, !1), ut = (e) => Zt(e, !0), On = (e) => E(e, !0, (t) => q(e, t, !0)), Pn = (e) => E(e, !1, (t) => q(e, t, !1)), qn = (e) => {
485
- let t = !k(e);
486
- return E(e, t, (r) => q(e, r, t));
487
- }, Nn = (e) => {
488
- let t = k(e);
489
- return E(e, t, (r) => q(e, r, t));
490
- }, $n = (e) => E(e, !1, (t) => d.cursor(e.lineBlockAt(t.head).from)), Vn = (e) => E(e, !0, (t) => d.cursor(e.lineBlockAt(t.head).to)), ht = ({ state: e, dispatch: t }) => (t(w(e, { anchor: 0 })), !0), ft = ({ state: e, dispatch: t }) => (t(w(e, { anchor: e.doc.length })), !0), dt = ({ state: e, dispatch: t }) => (t(w(e, {
491
- anchor: e.selection.main.anchor,
492
- head: 0
493
- })), !0), mt = ({ state: e, dispatch: t }) => (t(w(e, {
494
- anchor: e.selection.main.anchor,
495
- head: e.doc.length
496
- })), !0), Wn = ({ state: e, dispatch: t }) => (t(e.update({
497
- selection: {
498
- anchor: 0,
499
- head: e.doc.length
500
- },
501
- userEvent: "select"
502
- })), !0), _n = ({ state: e, dispatch: t }) => {
503
- let r = Ce(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
- }, Hn = ({ state: e, dispatch: t }) => {
509
- let r = Y(e.selection, (n) => {
510
- let l = _e(e), o = l.resolveStack(n.from, 1);
511
- if (n.empty) {
512
- let a = l.resolveStack(n.from, -1);
513
- a.node.from >= o.node.from && a.node.to <= o.node.to && (o = a);
514
- }
515
- for (let a = o; a; a = a.next) {
516
- let { node: i } = a;
517
- if ((i.from < n.from && i.to >= n.to || i.to > n.to && i.from <= n.from) && a.next) return d.undirectionalRange(i.from, i.to);
518
- }
519
- return n;
520
- });
521
- return r.eq(e.selection) ? !1 : (t(w(e, r)), !0);
522
- };
523
- function Xt(e, t) {
524
- let { state: r } = e, n = r.selection, l = r.selection.ranges.slice();
525
- for (let o of r.selection.ranges) {
526
- let a = r.doc.lineAt(o.head);
527
- if (t ? a.to < e.state.doc.length : a.from > 0) for (let i = o; ; ) {
528
- let s = e.moveVertically(i, t);
529
- if (s.head < a.from || s.head > a.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(w(r, d.create(l, l.length - 1))), !0);
539
- }
540
- var Un = (e) => Xt(e, !1), Gn = (e) => Xt(e, !0), Jn = ({ 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(w(e, n)), !0) : !1;
543
- };
544
- function ae(e, t) {
545
- if (e.state.readOnly) return !1;
546
- let r = "delete.selection", { state: n } = e, l = n.changeByRange((o) => {
547
- let { from: a, to: i } = o;
548
- if (a == i) {
549
- let s = t(o);
550
- s < a ? (r = "delete.backward", s = se(e, s, !1)) : s > a && (r = "delete.forward", s = se(e, s, !0)), a = Math.min(a, s), i = Math.max(i, s);
551
- } else
552
- a = se(e, a, !1), i = se(e, i, !0);
553
- return a == i ? { range: o } : {
554
- changes: {
555
- from: a,
556
- to: i
557
- },
558
- range: d.cursor(a, a < o.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" ? v.announce.of(n.phrase("Selection deleted")) : void 0
565
- })), !0);
566
- }
567
- function se(e, t, r) {
568
- if (e instanceof v) for (let n of e.state.facet(v.atomicRanges).map((l) => l(e))) n.between(t, t, (l, o) => {
569
- l < t && o > t && (t = r ? o : l);
570
- });
571
- return t;
572
- }
573
- var er = (e, t, r) => ae(e, (n) => {
574
- let l = n.from, { state: o } = e, a = o.doc.lineAt(l), i, s;
575
- if (r && !t && l > a.from && l < a.from + 200 && !/[^ \t]/.test(i = a.text.slice(0, l - a.from))) {
576
- if (i[i.length - 1] == " ") return l - 1;
577
- let c = We(i, o.tabSize) % Re(o) || Re(o);
578
- for (let u = 0; u < c && i[i.length - 1 - u] == " "; u++) l--;
579
- s = l;
580
- } else
581
- s = V(a.text, l - a.from, t, t) + a.from, s == l && a.number != (t ? o.doc.lines : 1) ? s += t ? 1 : -1 : !t && /[\ufe00-\ufe0f]/.test(a.text.slice(s - a.from, l - a.from)) && (s = V(a.text, s - a.from, !1, !1) + a.from);
582
- return s;
583
- }), Oe = (e) => er(e, !1, !0), tr = (e) => er(e, !0, !1), rr = (e, t) => ae(e, (r) => {
584
- let n = r.head, { state: l } = e, o = l.doc.lineAt(n), a = l.charCategorizer(n);
585
- for (let i = null; ; ) {
586
- if (n == (t ? o.to : o.from)) {
587
- n == r.head && o.number != (t ? l.doc.lines : 1) && (n += t ? 1 : -1);
588
- break;
589
- }
590
- let s = V(o.text, n - o.from, t) + o.from, c = o.text.slice(Math.min(n, s) - o.from, Math.max(n, s) - o.from), u = a(c);
591
- if (i != null && u != i) break;
592
- (c != " " || n != r.head) && (i = u), n = s;
593
- }
594
- return n;
595
- }), nr = (e) => rr(e, !1), zn = (e) => rr(e, !0), jn = (e) => ae(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
- }), Kn = (e) => ae(e, (t) => {
599
- let r = e.moveToLineBoundary(t, !1).head;
600
- return t.head > r ? r : Math.max(0, t.head - 1);
601
- }), Qn = (e) => ae(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
- }), Yn = ({ 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: kt.of(["", ""])
611
- },
612
- range: d.cursor(n.from)
613
- }));
614
- return t(e.update(r, {
615
- scrollIntoView: !0,
616
- userEvent: "input"
617
- })), !0;
618
- }, Zn = ({ 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, o = e.doc.lineAt(l), a = l == o.from ? l - 1 : V(o.text, l - o.from, !1) + o.from, i = l == o.to ? l + 1 : V(o.text, l - o.from, !0) + o.from;
623
- return {
624
- changes: {
625
- from: a,
626
- to: i,
627
- insert: e.doc.slice(l, i).append(e.doc.slice(a, 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 Ce(e) {
638
- let t = [], r = -1;
639
- for (let n of e.selection.ranges) {
640
- let l = e.doc.lineAt(n.from), o = e.doc.lineAt(n.to);
641
- if (!n.empty && n.to == o.from && (o = e.doc.lineAt(n.to - 1)), r >= l.number) {
642
- let a = t[t.length - 1];
643
- a.to = o.to, a.ranges.push(n);
644
- } else t.push({
645
- from: l.from,
646
- to: o.to,
647
- ranges: [n]
648
- });
649
- r = o.number + 1;
650
- }
651
- return t;
652
- }
653
- function lr(e, t, r) {
654
- if (e.readOnly) return !1;
655
- let n = [], l = [];
656
- for (let o of Ce(e)) {
657
- if (r ? o.to == e.doc.length : o.from == 0) continue;
658
- let a = e.doc.lineAt(r ? o.to + 1 : o.from - 1), i = a.length + 1;
659
- if (r) {
660
- n.push({
661
- from: o.to,
662
- to: a.to
663
- }, {
664
- from: o.from,
665
- insert: a.text + e.lineBreak
666
- });
667
- for (let s of o.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: a.from,
671
- to: o.from
672
- }, {
673
- from: o.to,
674
- insert: e.lineBreak + a.text
675
- });
676
- for (let s of o.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 Xn = ({ state: e, dispatch: t }) => lr(e, t, !1), el = ({ state: e, dispatch: t }) => lr(e, t, !0);
687
- function or(e, t, r) {
688
- if (e.readOnly) return !1;
689
- let n = [];
690
- for (let o of Ce(e)) r ? n.push({
691
- from: o.from,
692
- insert: e.doc.slice(o.from, o.to) + e.lineBreak
693
- }) : n.push({
694
- from: o.to,
695
- insert: e.lineBreak + e.doc.slice(o.from, o.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 tl = ({ state: e, dispatch: t }) => or(e, t, !1), rl = ({ state: e, dispatch: t }) => or(e, t, !0), nl = (e) => {
706
- if (e.state.readOnly) return !1;
707
- let { state: t } = e, r = t.changes(Ce(t).map(({ from: l, to: o }) => (l > 0 ? l-- : o < t.doc.length && o++, {
708
- from: l,
709
- to: o
710
- }))), n = Y(t.selection, (l) => {
711
- let o;
712
- if (e.lineWrapping) {
713
- let a = e.lineBlockAt(l.head), i = e.coordsAtPos(l.head, l.assoc || 1);
714
- i && (o = a.bottom + e.documentTop - i.bottom + e.defaultLineHeight / 2);
715
- }
716
- return e.moveVertically(l, !0, o);
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 ll(e, t) {
726
- if (/\(\)|\[\]|\{\}/.test(e.sliceDoc(t - 1, t + 1))) return {
727
- from: t,
728
- to: t
729
- };
730
- let r = _e(e).resolveInner(t), n = r.childBefore(t), l = r.childAfter(t), o;
731
- return n && l && n.to <= t && l.from >= t && (o = n.type.prop(we.closedBy)) && o.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 pt = /* @__PURE__ */ ar(!1), ol = /* @__PURE__ */ ar(!0);
737
- function ar(e) {
738
- return ({ state: t, dispatch: r }) => {
739
- if (t.readOnly) return !1;
740
- let n = t.changeByRange((l) => {
741
- let { from: o, to: a } = l, i = t.doc.lineAt(o), s = !e && o == a && ll(t, o);
742
- e && (o = a = (a <= i.to ? i : t.doc.lineAt(a)).to);
743
- let c = new Mt(t, {
744
- simulateBreak: o,
745
- simulateDoubleBreak: !!s
746
- }), u = Ct(c, o);
747
- for (u == null && (u = We(/^\s*/.exec(t.doc.lineAt(o).text)[0], t.tabSize)); a < i.to && /\s/.test(i.text[a - i.from]); ) a++;
748
- s ? { from: o, to: a } = s : o > i.from && o < i.from + 100 && !/\S/.test(i.text.slice(0, o)) && (o = i.from);
749
- let h = ["", de(t, u)];
750
- return s && h.push(de(t, c.lineIndent(i.from, -1))), {
751
- changes: {
752
- from: o,
753
- to: a,
754
- insert: kt.of(h)
755
- },
756
- range: d.cursor(o + 1 + h[1].length)
757
- };
758
- });
759
- return r(t.update(n, {
760
- scrollIntoView: !0,
761
- userEvent: "input"
762
- })), !0;
763
- };
764
- }
765
- function Je(e, t) {
766
- let r = -1;
767
- return e.changeByRange((n) => {
768
- let l = [];
769
- for (let a = n.from; a <= n.to; ) {
770
- let i = e.doc.lineAt(a);
771
- i.number > r && (n.empty || n.to > i.from) && (t(i, l, n), r = i.number), a = i.to + 1;
772
- }
773
- let o = e.changes(l);
774
- return {
775
- changes: l,
776
- range: d.range(o.mapPos(n.anchor, 1), o.mapPos(n.head, 1))
777
- };
778
- });
779
- }
780
- var al = ({ state: e, dispatch: t }) => {
781
- if (e.readOnly) return !1;
782
- let r = /* @__PURE__ */ Object.create(null), n = new Mt(e, { overrideIndentation: (o) => {
783
- let a = r[o];
784
- return a ?? -1;
785
- } }), l = Je(e, (o, a, i) => {
786
- let s = Ct(n, o.from);
787
- if (s == null) return;
788
- /\S/.test(o.text) || (s = 0);
789
- let c = /^\s*/.exec(o.text)[0], u = de(e, s);
790
- (c != u || i.from < o.from + c.length) && (r[o.from] = s, a.push({
791
- from: o.from,
792
- to: o.from + c.length,
793
- insert: u
794
- }));
795
- });
796
- return l.changes.empty || t(e.update(l, { userEvent: "indent" })), !0;
797
- }, ir = ({ state: e, dispatch: t }) => e.readOnly ? !1 : (t(e.update(Je(e, (r, n) => {
798
- n.push({
799
- from: r.from,
800
- insert: e.facet(bt)
801
- });
802
- }), { userEvent: "input.indent" })), !0), sr = ({ state: e, dispatch: t }) => e.readOnly ? !1 : (t(e.update(Je(e, (r, n) => {
803
- let l = /^\s*/.exec(r.text)[0];
804
- if (!l) return;
805
- let o = We(l, e.tabSize), a = 0, i = de(e, Math.max(0, o - Re(e)));
806
- for (; a < l.length && a < i.length && l.charCodeAt(a) == i.charCodeAt(a); ) a++;
807
- n.push({
808
- from: r.from + a,
809
- to: r.from + l.length,
810
- insert: i.slice(a)
811
- });
812
- }), { userEvent: "delete.dedent" })), !0), il = (e) => (e.setTabFocusMode(), !0), sl = [
813
- {
814
- key: "Ctrl-b",
815
- run: qt,
816
- shift: Jt,
817
- preventDefault: !0
818
- },
819
- {
820
- key: "Ctrl-f",
821
- run: Nt,
822
- shift: zt
823
- },
824
- {
825
- key: "Ctrl-p",
826
- run: Wt,
827
- shift: Qt
828
- },
829
- {
830
- key: "Ctrl-n",
831
- run: _t,
832
- shift: Yt
833
- },
834
- {
835
- key: "Ctrl-a",
836
- run: Bn,
837
- shift: $n
838
- },
839
- {
840
- key: "Ctrl-e",
841
- run: Dn,
842
- shift: Vn
843
- },
844
- {
845
- key: "Ctrl-d",
846
- run: tr
847
- },
848
- {
849
- key: "Ctrl-h",
850
- run: Oe
851
- },
852
- {
853
- key: "Ctrl-k",
854
- run: jn
855
- },
856
- {
857
- key: "Ctrl-Alt-h",
858
- run: nr
859
- },
860
- {
861
- key: "Ctrl-o",
862
- run: Yn
863
- },
864
- {
865
- key: "Ctrl-t",
866
- run: Zn
867
- },
868
- {
869
- key: "Ctrl-v",
870
- run: Ie
871
- }
872
- ], cl = /* @__PURE__ */ [
873
- {
874
- key: "ArrowLeft",
875
- run: qt,
876
- shift: Jt,
877
- preventDefault: !0
878
- },
879
- {
880
- key: "Mod-ArrowLeft",
881
- mac: "Alt-ArrowLeft",
882
- run: yn,
883
- shift: Rn,
884
- preventDefault: !0
885
- },
886
- {
887
- mac: "Cmd-ArrowLeft",
888
- run: Mn,
889
- shift: qn,
890
- preventDefault: !0
891
- },
892
- {
893
- key: "ArrowRight",
894
- run: Nt,
895
- shift: zt,
896
- preventDefault: !0
897
- },
898
- {
899
- key: "Mod-ArrowRight",
900
- mac: "Alt-ArrowRight",
901
- run: xn,
902
- shift: Tn,
903
- preventDefault: !0
904
- },
905
- {
906
- mac: "Cmd-ArrowRight",
907
- run: Ln,
908
- shift: Nn,
909
- preventDefault: !0
910
- },
911
- {
912
- key: "ArrowUp",
913
- run: Wt,
914
- shift: Qt,
915
- preventDefault: !0
916
- },
917
- {
918
- mac: "Cmd-ArrowUp",
919
- run: ht,
920
- shift: dt
921
- },
922
- {
923
- mac: "Ctrl-ArrowUp",
924
- run: st,
925
- shift: ct
926
- },
927
- {
928
- key: "ArrowDown",
929
- run: _t,
930
- shift: Yt,
931
- preventDefault: !0
932
- },
933
- {
934
- mac: "Cmd-ArrowDown",
935
- run: ft,
936
- shift: mt
937
- },
938
- {
939
- mac: "Ctrl-ArrowDown",
940
- run: Ie,
941
- shift: ut
942
- },
943
- {
944
- key: "PageUp",
945
- run: st,
946
- shift: ct
947
- },
948
- {
949
- key: "PageDown",
950
- run: Ie,
951
- shift: ut
952
- },
953
- {
954
- key: "Home",
955
- run: An,
956
- shift: Pn,
957
- preventDefault: !0
958
- },
959
- {
960
- key: "Mod-Home",
961
- run: ht,
962
- shift: dt
963
- },
964
- {
965
- key: "End",
966
- run: Cn,
967
- shift: On,
968
- preventDefault: !0
969
- },
970
- {
971
- key: "Mod-End",
972
- run: ft,
973
- shift: mt
974
- },
975
- {
976
- key: "Enter",
977
- run: pt,
978
- shift: pt
979
- },
980
- {
981
- key: "Mod-a",
982
- run: Wn
983
- },
984
- {
985
- key: "Backspace",
986
- run: Oe,
987
- shift: Oe,
988
- preventDefault: !0
989
- },
990
- {
991
- key: "Delete",
992
- run: tr,
993
- preventDefault: !0
994
- },
995
- {
996
- key: "Mod-Backspace",
997
- mac: "Alt-Backspace",
998
- run: nr,
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: Kn,
1010
- preventDefault: !0
1011
- },
1012
- {
1013
- mac: "Mod-Delete",
1014
- run: Qn,
1015
- preventDefault: !0
1016
- }
1017
- ].concat(/* @__PURE__ */ sl.map((e) => ({
1018
- mac: e.key,
1019
- run: e.run,
1020
- shift: e.shift
1021
- }))), ul = /* @__PURE__ */ [
1022
- {
1023
- key: "Alt-ArrowLeft",
1024
- mac: "Ctrl-ArrowLeft",
1025
- run: Sn,
1026
- shift: Fn
1027
- },
1028
- {
1029
- key: "Alt-ArrowRight",
1030
- mac: "Ctrl-ArrowRight",
1031
- run: bn,
1032
- shift: In
1033
- },
1034
- {
1035
- key: "Alt-ArrowUp",
1036
- run: Xn
1037
- },
1038
- {
1039
- key: "Shift-Alt-ArrowUp",
1040
- run: tl
1041
- },
1042
- {
1043
- key: "Alt-ArrowDown",
1044
- run: el
1045
- },
1046
- {
1047
- key: "Shift-Alt-ArrowDown",
1048
- run: rl
1049
- },
1050
- {
1051
- key: "Mod-Alt-ArrowUp",
1052
- run: Un
1053
- },
1054
- {
1055
- key: "Mod-Alt-ArrowDown",
1056
- run: Gn
1057
- },
1058
- {
1059
- key: "Escape",
1060
- run: Jn
1061
- },
1062
- {
1063
- key: "Mod-Enter",
1064
- run: ol
1065
- },
1066
- {
1067
- key: "Alt-l",
1068
- mac: "Ctrl-l",
1069
- run: _n
1070
- },
1071
- {
1072
- key: "Mod-i",
1073
- run: Hn,
1074
- preventDefault: !0
1075
- },
1076
- {
1077
- key: "Mod-[",
1078
- run: sr
1079
- },
1080
- {
1081
- key: "Mod-]",
1082
- run: ir
1083
- },
1084
- {
1085
- key: "Mod-Alt-\\",
1086
- run: al
1087
- },
1088
- {
1089
- key: "Shift-Mod-k",
1090
- run: nl
1091
- },
1092
- {
1093
- key: "Shift-Mod-\\",
1094
- run: wn
1095
- },
1096
- {
1097
- key: "Mod-/",
1098
- run: Zr
1099
- },
1100
- {
1101
- key: "Alt-A",
1102
- mac: "Ctrl-A",
1103
- run: en
1104
- },
1105
- {
1106
- key: "Ctrl-m",
1107
- mac: "Shift-Alt-m",
1108
- run: il
1109
- }
1110
- ].concat(cl), hl = {
1111
- key: "Tab",
1112
- run: ir,
1113
- shift: sr
1114
- };
1115
- function Pe() {
1116
- return Pe = 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
- }, Pe.apply(null, arguments);
1123
- }
1124
- var fl = (e) => {
1125
- var t = e.theme, r = e.settings, n = r === void 0 ? {} : r, l = e.styles, o = l === void 0 ? [] : l, a = { ".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) && (a["&"] = i), n.fontFamily && (a["&.cm-editor .cm-scroller"] = { fontFamily: n.fontFamily }), n.gutterBackground && (a[".cm-gutters"].backgroundColor = n.gutterBackground), n.gutterForeground && (a[".cm-gutters"].color = n.gutterForeground), n.gutterBorder && (a[".cm-gutters"].borderRightColor = n.gutterBorder), n.caret && (a[".cm-content"] = { caretColor: n.caret }, a[".cm-cursor, .cm-dropCursor"] = { borderLeftColor: n.caret });
1127
- var s = {};
1128
- return n.gutterActiveForeground && (s.color = n.gutterActiveForeground), n.lineHighlight && (a[".cm-activeLine"] = { backgroundColor: n.lineHighlight }, s.backgroundColor = n.lineHighlight), a[".cm-activeLineGutter"] = s, n.selection && (a["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"] = { background: n.selection + " !important" }), n.selectionMatch && (a["& .cm-selectionMatch"] = { backgroundColor: n.selectionMatch }), [v.theme(a, { dark: t === "dark" }), Dr(Ur.define(o))];
1129
- }, dl = {
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
- }, ml = [
1140
- {
1141
- tag: [
1142
- x.function(x.variableName),
1143
- x.function(x.propertyName),
1144
- x.url,
1145
- x.processingInstruction
1146
- ],
1147
- color: "hsl(207, 82%, 66%)"
1148
- },
1149
- {
1150
- tag: [x.tagName, x.heading],
1151
- color: "#e06c75"
1152
- },
1153
- {
1154
- tag: x.comment,
1155
- color: "#54636D"
1156
- },
1157
- {
1158
- tag: [x.propertyName],
1159
- color: "hsl(220, 14%, 71%)"
1160
- },
1161
- {
1162
- tag: [x.attributeName, x.number],
1163
- color: "hsl( 29, 54%, 61%)"
1164
- },
1165
- {
1166
- tag: x.className,
1167
- color: "hsl( 39, 67%, 69%)"
1168
- },
1169
- {
1170
- tag: x.keyword,
1171
- color: "hsl(286, 60%, 67%)"
1172
- },
1173
- {
1174
- tag: [
1175
- x.string,
1176
- x.regexp,
1177
- x.special(x.propertyName)
1178
- ],
1179
- color: "#98c379"
1180
- }
1181
- ], cr = (e) => {
1182
- var t = e || {}, r = t.theme, n = r === void 0 ? "dark" : r, l = t.settings, o = l === void 0 ? {} : l, a = t.styles, i = a === void 0 ? [] : a;
1183
- return fl({
1184
- theme: n,
1185
- settings: Pe({}, dl, o),
1186
- styles: [...ml, ...i]
1187
- });
1188
- }, pl = cr(), gt = typeof String.prototype.normalize == "function" ? (e) => e.normalize("NFKD") : (e) => e, le = 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, o) {
1203
- this.test = o, 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 ? (a) => l(gt(a)) : gt, 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 Gr(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 = _r(e), r = this.bufferStart + this.bufferPos;
1237
- this.bufferPos += Wr(e);
1238
- let n = this.normalize(t);
1239
- if (n.length) for (let l = 0, o = r, a = !0; ; l++) {
1240
- let i = n.charCodeAt(l), s = this.match(i, o, a, 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
- a && l < t.length && t.charCodeAt(l) == i ? o++ : a = !1;
1245
- }
1246
- }
1247
- }
1248
- match(e, t, r, n, l) {
1249
- let o = null;
1250
- for (let a = 0; a < this.matches.length; ) {
1251
- let i = this.matches[a], s = !1;
1252
- this.query.charCodeAt(i.index) == e && (i.index == this.query.length - 1 ? o = {
1253
- from: i.from,
1254
- to: n,
1255
- precise: l && i.precise
1256
- } : (i.index++, s = !0)), s ? a++ : this.matches.splice(a, 1);
1257
- }
1258
- return this.query.charCodeAt(0) == e && (this.query.length == 1 ? o = {
1259
- from: t,
1260
- to: n,
1261
- precise: r && l
1262
- } : this.matches.push({
1263
- from: t,
1264
- index: 1,
1265
- precise: r
1266
- })), o && this.test && !this.test(o.from, o.to, this.buffer, this.bufferStart) && (o = null), o;
1267
- }
1268
- };
1269
- typeof Symbol < "u" && (le.prototype[Symbol.iterator] = function() {
1270
- return this;
1271
- });
1272
- var ur = {
1273
- from: -1,
1274
- to: -1,
1275
- match: /* @__PURE__ */ /.*/.exec(""),
1276
- precise: !0
1277
- }, ze = "gm" + (/x/.unicode == null ? "" : "u"), hr = 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 = ur, /\\[sWDnr]|\n|\r|\[\^/.test(t)) return new fr(e, t, r, n, l);
1285
- this.re = new RegExp(t, ze + (r?.ignoreCase ? "i" : "")), this.test = r?.test, this.iter = e.iter(), this.curLineStart = e.lineAt(n).from, this.matchPos = pe(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 = pe(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
- }, De = /* @__PURE__ */ new WeakMap(), vt = class fe {
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 = De.get(t);
1325
- if (!l || l.from >= n || l.to <= r) {
1326
- let i = new fe(r, t.sliceString(r, n));
1327
- return De.set(t, i), i;
1328
- }
1329
- if (l.from == r && l.to == n) return l;
1330
- let { text: o, from: a } = l;
1331
- return a > r && (o = t.sliceString(r, a) + o, a = r), l.to < n && (o += t.sliceString(l.to, n)), De.set(t, new fe(a, o)), new fe(r, o.slice(r - a, n - a));
1332
- }
1333
- }, fr = class {
1334
- constructor(e, t, r, n, l) {
1335
- this.text = e, this.to = l, this.done = !1, this.value = ur, this.matchPos = pe(e, n), this.re = new RegExp(t, ze + (r?.ignoreCase ? "i" : "")), this.test = r?.test, this.flat = vt.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 = pe(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 = vt.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
1356
- }
1357
- }
1358
- };
1359
- typeof Symbol < "u" && (hr.prototype[Symbol.iterator] = fr.prototype[Symbol.iterator] = function() {
1360
- return this;
1361
- });
1362
- function gl(e) {
1363
- try {
1364
- return new RegExp(e, ze), !0;
1365
- } catch {
1366
- return !1;
1367
- }
1368
- }
1369
- function pe(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 vl = (e) => {
1376
- let t = Lr(e, "cm-goto-line");
1377
- if (t) {
1378
- let a = t.dom.querySelector("input[type=text]");
1379
- return a && a.select(), !0;
1380
- }
1381
- let { state: r } = e, n = String(r.doc.lineAt(e.state.selection.main.head).number), { close: l, result: o } = Rr(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 o.then((a) => {
1393
- let i = a && /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(a.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, g = h ? +h.slice(1) : 0, m = u ? +u : s.number;
1399
- if (u && f) {
1400
- let _ = m / 100;
1401
- c && (_ = _ * (c == "-" ? -1 : 1) + s.number / r.doc.lines), m = Math.round(r.doc.lines * _);
1402
- } else u && c && (m = m * (c == "-" ? -1 : 1) + s.number);
1403
- let Z = r.doc.line(Math.max(1, Math.min(r.doc.lines, m))), y = d.cursor(Z.from + Math.max(0, Math.min(g, Z.length)));
1404
- e.dispatch({
1405
- effects: [l, v.scrollIntoView(y.from, { y: "center" })],
1406
- selection: y
1407
- });
1408
- }), !0;
1409
- }, yl = ({ 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 xl(e, t) {
1414
- let { main: r, ranges: n } = e.selection, l = e.wordAt(r.head), o = l && l.from == r.from && l.to == r.to;
1415
- for (let a = !1, i = new le(e.doc, t, n[n.length - 1].to); ; )
1416
- if (i.next(), i.done) {
1417
- if (a) return null;
1418
- i = new le(e.doc, t, 0, Math.max(0, n[n.length - 1].from - 1)), a = !0;
1419
- } else {
1420
- if (a && n.some((s) => s.from == i.value.from)) continue;
1421
- if (o) {
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 kl = ({ state: e, dispatch: t }) => {
1429
- let { ranges: r } = e.selection;
1430
- if (r.some((o) => o.from === o.to)) return yl({
1431
- state: e,
1432
- dispatch: t
1433
- });
1434
- let n = e.sliceDoc(r[0].from, r[0].to);
1435
- if (e.selection.ranges.some((o) => e.sliceDoc(o.from, o.to) != n)) return !1;
1436
- let l = xl(e, n);
1437
- return l ? (t(e.update({
1438
- selection: e.selection.addRange(d.range(l.from, l.to), !1),
1439
- effects: v.scrollIntoView(l.to)
1440
- })), !0) : !1;
1441
- }, W = /* @__PURE__ */ $e.define({ combine(e) {
1442
- return Lt(e, {
1443
- top: !1,
1444
- caseSensitive: !1,
1445
- literal: !1,
1446
- regexp: !1,
1447
- wholeWord: !1,
1448
- createPanel: (t) => new Fl(t),
1449
- scrollToMatch: (t) => v.scrollIntoView(t)
1450
- });
1451
- } });
1452
- function Sl(e) {
1453
- return e ? [W.of(e), Ne] : Ne;
1454
- }
1455
- var je = 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 || gl(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 Bl(this) : new Al(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 : he.create({ doc: e });
1487
- return r == null && (r = n.doc.length), this.regexp ? U(this, n, t, r) : H(this, n, t, r);
1488
- }
1489
- }, dr = class {
1490
- constructor(e) {
1491
- this.spec = e;
1492
- }
1493
- };
1494
- function bl(e, t, r) {
1495
- return (n, l, o, a) => r && !r(n, l, o, a) ? !1 : e(n >= a && l <= a + o.length ? o.slice(n - a, l - a) : t.doc.sliceString(n, l), t, n, l);
1496
- }
1497
- function H(e, t, r, n) {
1498
- let l;
1499
- return e.wholeWord && (l = Cl(t.doc, t.charCategorizer(t.selection.main.head))), e.test && (l = bl(e.test, t, l)), new le(t.doc, e.unquoted, r, n, e.caseSensitive ? void 0 : (o) => o.toLowerCase(), l);
1500
- }
1501
- function Cl(e, t) {
1502
- return (r, n, l, o) => ((o > r || o + l.length < n) && (o = Math.max(0, r - 2), l = e.sliceString(o, Math.min(e.length, n + 2))), (t(ge(l, r - o)) != O.Word || t(ve(l, r - o)) != O.Word) && (t(ve(l, n - o)) != O.Word || t(ge(l, n - o)) != O.Word));
1503
- }
1504
- var Al = class extends dr {
1505
- constructor(e) {
1506
- super(e);
1507
- }
1508
- nextMatch(e, t, r) {
1509
- let n = H(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 = H(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), o = H(this.spec, e, l, n), a = null;
1519
- for (; !o.nextOverlapping().done; ) a = o.value;
1520
- if (a) return a;
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 = H(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 = H(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 Ml(e, t, r) {
1546
- return (n, l, o) => (!r || r(n, l, o)) && e(o[0], t, n, l);
1547
- }
1548
- function U(e, t, r, n) {
1549
- let l;
1550
- return e.wholeWord && (l = Ll(t.charCategorizer(t.selection.main.head))), e.test && (l = Ml(e.test, t, l)), new hr(t.doc, e.search, {
1551
- ignoreCase: !e.caseSensitive,
1552
- test: l
1553
- }, r, n);
1554
- }
1555
- function ge(e, t) {
1556
- return e.slice(V(e, t, !1), t);
1557
- }
1558
- function ve(e, t) {
1559
- return e.slice(t, V(e, t));
1560
- }
1561
- function Ll(e) {
1562
- return (t, r, n) => !n[0].length || (e(ge(n.input, n.index)) != O.Word || e(ve(n.input, n.index)) != O.Word) && (e(ve(n.input, n.index + n[0].length)) != O.Word || e(ge(n.input, n.index + n[0].length)) != O.Word);
1563
- }
1564
- var Bl = class extends dr {
1565
- nextMatch(e, t, r) {
1566
- let n = U(this.spec, e, r, e.doc.length).next();
1567
- return n.done && (n = U(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), o = U(this.spec, e, l, r), a = null;
1572
- for (; !o.next().done; ) a = o.value;
1573
- if (a && (l == t || a.from > l + 10)) return a;
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 = U(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 = U(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
- }, j = /* @__PURE__ */ oe.define(), Ke = /* @__PURE__ */ oe.define(), F = /* @__PURE__ */ St.define({
1604
- create(e) {
1605
- return new Ee(ye(e).create(), null);
1606
- },
1607
- update(e, t) {
1608
- for (let r of t.effects) r.is(j) ? e = new Ee(r.value.create(), e.panel) : r.is(Ke) && (e = new Ee(e.query, r.value ? Qe : null));
1609
- return e;
1610
- },
1611
- provide: (e) => Fr.from(e, (t) => t.panel)
1612
- });
1613
- function yt(e) {
1614
- let t = e.field(F, !1);
1615
- return t ? t.query.spec : ye(e);
1616
- }
1617
- var Ee = class {
1618
- constructor(e, t) {
1619
- this.query = e, this.panel = t;
1620
- }
1621
- }, Dl = /* @__PURE__ */ Ve.mark({ class: "cm-searchMatch" }), El = /* @__PURE__ */ Ve.mark({ class: "cm-searchMatch cm-searchMatch-selected" }), wl = /* @__PURE__ */ Or.fromClass(class {
1622
- constructor(e) {
1623
- this.view = e, this.decorations = this.highlight(e.state.field(F));
1624
- }
1625
- update(e) {
1626
- let t = e.state.field(F);
1627
- (t != e.startState.field(F) || 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 Ve.none;
1631
- let { view: r } = this, n = new Nr();
1632
- for (let l = 0, o = r.visibleRanges, a = o.length; l < a; l++) {
1633
- let { from: i, to: s } = o[l];
1634
- for (; l < a - 1 && s > o[l + 1].from - 500; ) s = o[++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 ? El : Dl);
1638
- });
1639
- }
1640
- return n.finish();
1641
- }
1642
- }, { decorations: (e) => e.decorations });
1643
- function ie(e) {
1644
- return (t) => {
1645
- let r = t.state.field(F, !1);
1646
- return r && r.query.spec.valid ? e(t, r) : yr(t);
1647
- };
1648
- }
1649
- var K = /* @__PURE__ */ ie((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), o = e.state.facet(W);
1653
- return e.dispatch({
1654
- selection: l,
1655
- effects: [Ye(e, n), o.scrollToMatch(l.main, e)],
1656
- userEvent: "select.search"
1657
- }), vr(e), !0;
1658
- }), Q = /* @__PURE__ */ ie((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 o = d.single(l.from, l.to), a = e.state.facet(W);
1662
- return e.dispatch({
1663
- selection: o,
1664
- effects: [Ye(e, l), a.scrollToMatch(o.main, e)],
1665
- userEvent: "select.search"
1666
- }), vr(e), !0;
1667
- }), mr = /* @__PURE__ */ ie((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
- }), Rl = ({ 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, o = [], a = 0;
1677
- for (let i = new le(e.doc, e.sliceDoc(n, l)); !i.next().done; ) {
1678
- if (o.length > 1e3) return !1;
1679
- i.value.from == n && (a = o.length), o.push(d.range(i.value.from, i.value.to));
1680
- }
1681
- return t(e.update({
1682
- selection: d.create(o, a),
1683
- userEvent: "select.search.matches"
1684
- })), !0;
1685
- }, qe = /* @__PURE__ */ ie((e, { query: t }) => {
1686
- let { state: r } = e, { from: n, to: l } = r.selection.main;
1687
- if (r.readOnly) return !1;
1688
- let o = t.nextMatch(r, n, n);
1689
- if (!o) return !1;
1690
- let a = o, i = [], s, c, u = [];
1691
- a.precise ? a.from == n && a.to == l && (c = r.toText(t.getReplacement(a)), i.push({
1692
- from: a.from,
1693
- to: a.to,
1694
- insert: c
1695
- }), a = t.nextMatch(r, a.from, a.to), u.push(v.announce.of(r.phrase("replaced match on line $", r.doc.lineAt(n).number) + "."))) : a = t.nextMatch(r, a.from, a.to);
1696
- let h = e.state.changes(i);
1697
- return a && (s = d.single(a.from, a.to).map(h), u.push(Ye(e, a)), u.push(r.facet(W).scrollToMatch(s.main, e))), e.dispatch({
1698
- changes: h,
1699
- selection: s,
1700
- effects: u,
1701
- userEvent: "input.replace"
1702
- }), !0;
1703
- }), pr = /* @__PURE__ */ ie((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: o, to: a, precise: i } = l;
1708
- i && r.push({
1709
- from: o,
1710
- to: a,
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: v.announce.of(n),
1719
- userEvent: "input.replace.all"
1720
- }), !0;
1721
- });
1722
- function Qe(e) {
1723
- return e.state.facet(W).createPanel(e);
1724
- }
1725
- function ye(e, t) {
1726
- var r, n, l, o, a;
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(W);
1730
- return new je({
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: (o = t?.regexp) !== null && o !== void 0 ? o : c.regexp,
1735
- wholeWord: (a = t?.wholeWord) !== null && a !== void 0 ? a : c.wholeWord
1736
- });
1737
- }
1738
- function gr(e) {
1739
- let t = At(e, Qe);
1740
- return t && t.dom.querySelector("[main-field]");
1741
- }
1742
- function vr(e) {
1743
- let t = gr(e);
1744
- t && t == e.root.activeElement && t.select();
1745
- }
1746
- var yr = (e) => {
1747
- let t = e.state.field(F, !1);
1748
- if (t && t.panel) {
1749
- let r = gr(e);
1750
- if (r && r != e.root.activeElement) {
1751
- let n = ye(e.state, t.query.spec);
1752
- n.valid && e.dispatch({ effects: j.of(n) }), r.focus(), r.select();
1753
- }
1754
- } else e.dispatch({ effects: [Ke.of(!0), t ? j.of(ye(e.state, t.query.spec)) : oe.appendConfig.of(Ne)] });
1755
- return !0;
1756
- }, xe = (e) => {
1757
- let t = e.state.field(F, !1);
1758
- if (!t || !t.panel) return !1;
1759
- let r = At(e, Qe);
1760
- return r && r.dom.contains(e.root.activeElement) && e.focus(), e.dispatch({ effects: Ke.of(!1) }), !0;
1761
- }, Tl = [
1762
- {
1763
- key: "Mod-f",
1764
- run: yr,
1765
- scope: "editor search-panel"
1766
- },
1767
- {
1768
- key: "F3",
1769
- run: K,
1770
- shift: Q,
1771
- scope: "editor search-panel",
1772
- preventDefault: !0
1773
- },
1774
- {
1775
- key: "Mod-g",
1776
- run: K,
1777
- shift: Q,
1778
- scope: "editor search-panel",
1779
- preventDefault: !0
1780
- },
1781
- {
1782
- key: "Escape",
1783
- run: xe,
1784
- scope: "editor search-panel"
1785
- },
1786
- {
1787
- key: "Mod-Shift-l",
1788
- run: Rl
1789
- },
1790
- {
1791
- key: "Mod-Alt-g",
1792
- run: vl
1793
- },
1794
- {
1795
- key: "Mod-d",
1796
- run: kl,
1797
- preventDefault: !0
1798
- }
1799
- ], Fl = class {
1800
- constructor(e) {
1801
- this.view = e;
1802
- let t = this.query = e.state.field(F).query.spec;
1803
- this.commit = this.commit.bind(this), this.searchField = C("input", {
1804
- value: t.search,
1805
- placeholder: b(e, "Find"),
1806
- "aria-label": b(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 = C("input", {
1814
- value: t.replace,
1815
- placeholder: b(e, "Replace"),
1816
- "aria-label": b(e, "Replace"),
1817
- class: "cm-textfield",
1818
- name: "replace",
1819
- form: "",
1820
- onchange: this.commit,
1821
- onkeyup: this.commit
1822
- }), this.caseField = C("input", {
1823
- type: "checkbox",
1824
- name: "case",
1825
- form: "",
1826
- checked: t.caseSensitive,
1827
- onchange: this.commit
1828
- }), this.reField = C("input", {
1829
- type: "checkbox",
1830
- name: "re",
1831
- form: "",
1832
- checked: t.regexp,
1833
- onchange: this.commit
1834
- }), this.wordField = C("input", {
1835
- type: "checkbox",
1836
- name: "word",
1837
- form: "",
1838
- checked: t.wholeWord,
1839
- onchange: this.commit
1840
- });
1841
- function r(n, l, o) {
1842
- return C("button", {
1843
- class: "cm-button",
1844
- name: n,
1845
- onclick: l,
1846
- type: "button"
1847
- }, o);
1848
- }
1849
- this.dom = C("div", {
1850
- onkeydown: (n) => this.keydown(n),
1851
- class: "cm-search"
1852
- }, [
1853
- this.searchField,
1854
- r("next", () => K(e), [b(e, "next")]),
1855
- r("prev", () => Q(e), [b(e, "previous")]),
1856
- r("select", () => mr(e), [b(e, "all")]),
1857
- C("label", null, [this.caseField, b(e, "match case")]),
1858
- C("label", null, [this.reField, b(e, "regexp")]),
1859
- C("label", null, [this.wordField, b(e, "by word")]),
1860
- ...e.state.readOnly ? [] : [
1861
- C("br"),
1862
- this.replaceField,
1863
- r("replace", () => qe(e), [b(e, "replace")]),
1864
- r("replaceAll", () => pr(e), [b(e, "replace all")])
1865
- ],
1866
- C("button", {
1867
- name: "close",
1868
- onclick: () => xe(e),
1869
- "aria-label": b(e, "close"),
1870
- type: "button"
1871
- }, ["×"])
1872
- ]);
1873
- }
1874
- commit() {
1875
- let e = new je({
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: j.of(e) }));
1883
- }
1884
- keydown(e) {
1885
- wr(this.view, e, "search-panel") ? e.preventDefault() : e.keyCode == 13 && e.target == this.searchField ? (e.preventDefault(), (e.shiftKey ? Q : K)(this.view)) : e.keyCode == 13 && e.target == this.replaceField && (e.preventDefault(), qe(this.view));
1886
- }
1887
- update(e) {
1888
- for (let t of e.transactions) for (let r of t.effects) r.is(j) && !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(W).top;
1901
- }
1902
- };
1903
- function b(e, t) {
1904
- return e.state.phrase(t);
1905
- }
1906
- var ce = 30, ue = /[\s\.,:;?!]/;
1907
- function Ye(e, { from: t, to: r }) {
1908
- let n = e.state.doc.lineAt(t), l = e.state.doc.lineAt(r).to, o = Math.max(n.from, t - ce), a = Math.min(l, r + ce), i = e.state.sliceDoc(o, a);
1909
- if (o != n.from) {
1910
- for (let s = 0; s < ce; s++) if (!ue.test(i[s + 1]) && ue.test(i[s])) {
1911
- i = i.slice(s);
1912
- break;
1913
- }
1914
- }
1915
- if (a != l) {
1916
- for (let s = i.length - 1; s > i.length - ce; s--) if (!ue.test(i[s - 1]) && ue.test(i[s])) {
1917
- i = i.slice(0, s);
1918
- break;
1919
- }
1920
- }
1921
- return v.announce.of(`${e.state.phrase("current match")}. ${i} ${e.state.phrase("on line")} ${n.number}.`);
1922
- }
1923
- var Il = /* @__PURE__ */ v.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
- }), Ne = [
1949
- F,
1950
- /* @__PURE__ */ Tr.low(wl),
1951
- Il
1952
- ], Ol = { class: "flex align-items-center gap-025" }, Pl = { class: "code-search-field flex-1 min-w-0" }, ql = { class: "code-search-options flex align-items-center" }, Nl = ["id"], $l = {
1953
- key: 1,
1954
- class: "txt12 color-red",
1955
- role: "alert"
1956
- }, Vl = /* @__PURE__ */ Dt({
1957
- __name: "SearchPanel",
1958
- props: {
1959
- view: {},
1960
- query: {},
1961
- readonly: { type: Boolean }
1962
- },
1963
- setup(e) {
1964
- const t = e, r = B(t.query.search), n = B(t.query.replace), l = B(t.query.caseSensitive), o = B(t.query.regexp), a = B(t.query.wholeWord), i = B(!1), s = Yr();
1965
- let c = !1;
1966
- re(() => t.query, (h) => {
1967
- c = !0, r.value = h.search, n.value = h.replace, l.value = h.caseSensitive, o.value = h.regexp, a.value = h.wholeWord, c = !1;
1968
- }), re([
1969
- r,
1970
- n,
1971
- l,
1972
- o,
1973
- a
1974
- ], () => {
1975
- if (c) return;
1976
- const h = new je({
1977
- search: r.value,
1978
- replace: n.value,
1979
- caseSensitive: l.value,
1980
- regexp: o.value,
1981
- wholeWord: a.value
1982
- });
1983
- h.eq(t.query) || t.view.dispatch({ effects: j.of(h) });
1984
- }, { flush: "sync" });
1985
- function u(h) {
1986
- h.key === "Escape" ? (h.preventDefault(), xe(t.view), t.view.focus()) : h.key === "Enter" && (h.preventDefault(), h.shiftKey ? Q(t.view) : K(t.view));
1987
- }
1988
- return (h, f) => {
1989
- const g = Et("tooltip");
1990
- return P(), z("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
- $("div", Ol, [
2002
- e.readonly ? J("", !0) : L((P(), Bt(M, {
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": I(s),
2010
- onClick: f[0] || (f[0] = (m) => i.value = !i.value)
2011
- }, null, 8, [
2012
- "icon",
2013
- "aria-expanded",
2014
- "aria-controls"
2015
- ])), [[g, i.value ? "Hide replace" : "Show replace"]]),
2016
- $("div", Pl, [A(rt, {
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"]), $("div", ql, [
2028
- L(A(M, {
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
- ]), [[g, "Match case"]]),
2041
- L(A(M, {
2042
- thin: "",
2043
- flat: !a.value,
2044
- soft: a.value,
2045
- icon: "match_word",
2046
- "aria-label": "Match whole word",
2047
- "aria-pressed": a.value,
2048
- onClick: f[3] || (f[3] = (m) => a.value = !a.value)
2049
- }, null, 8, [
2050
- "flat",
2051
- "soft",
2052
- "aria-pressed"
2053
- ]), [[g, "Match whole word"]]),
2054
- L(A(M, {
2055
- thin: "",
2056
- flat: !o.value,
2057
- soft: o.value,
2058
- icon: "regular_expression",
2059
- "aria-label": "Regular expression",
2060
- "aria-pressed": o.value,
2061
- onClick: f[4] || (f[4] = (m) => o.value = !o.value)
2062
- }, null, 8, [
2063
- "flat",
2064
- "soft",
2065
- "aria-pressed"
2066
- ]), [[g, "Regular expression"]])
2067
- ])]),
2068
- L(A(M, {
2069
- thin: "",
2070
- flat: "",
2071
- icon: "arrow_upward",
2072
- "aria-label": "Previous match",
2073
- onClick: f[5] || (f[5] = (m) => I(Q)(e.view))
2074
- }, null, 512), [[g, "Previous match (Shift+Enter)"]]),
2075
- L(A(M, {
2076
- thin: "",
2077
- flat: "",
2078
- icon: "arrow_downward",
2079
- "aria-label": "Next match",
2080
- onClick: f[6] || (f[6] = (m) => I(K)(e.view))
2081
- }, null, 512), [[g, "Next match (Enter)"]]),
2082
- L(A(M, {
2083
- thin: "",
2084
- flat: "",
2085
- icon: "select_all",
2086
- "aria-label": "Select all matches",
2087
- onClick: f[7] || (f[7] = (m) => I(mr)(e.view))
2088
- }, null, 512), [[g, "Select all matches"]]),
2089
- L(A(M, {
2090
- thin: "",
2091
- flat: "",
2092
- icon: "close",
2093
- "aria-label": "Close search",
2094
- onClick: f[8] || (f[8] = (m) => {
2095
- I(xe)(e.view), e.view.focus();
2096
- })
2097
- }, null, 512), [[g, "Close (Escape)"]])
2098
- ]),
2099
- !e.readonly && i.value ? (P(), z("div", {
2100
- key: 0,
2101
- id: I(s),
2102
- class: "code-replace-row flex align-items-center gap-025"
2103
- }, [
2104
- A(rt, {
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
- L(A(M, {
2117
- thin: "",
2118
- flat: "",
2119
- icon: "find_replace",
2120
- "aria-label": "Replace next",
2121
- onClick: f[10] || (f[10] = (m) => I(qe)(e.view))
2122
- }, null, 512), [[g, "Replace next"]]),
2123
- L(A(M, {
2124
- thin: "",
2125
- flat: "",
2126
- icon: "published_with_changes",
2127
- "aria-label": "Replace all",
2128
- onClick: f[11] || (f[11] = (m) => I(pr)(e.view))
2129
- }, null, 512), [[g, "Replace all"]])
2130
- ], 8, Nl)) : J("", !0),
2131
- e.query.regexp && e.query.search.length > 0 && !e.query.valid ? (P(), z("span", $l, "Invalid regular expression")) : J("", !0)
2132
- ], 32);
2133
- };
2134
- }
2135
- }), Wl = /* @__PURE__ */ xt(Vl, [["__scopeId", "data-v-c5ae435d"]]);
2136
- function _l(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 Hl(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, o] = await Promise.all([import("./babel-BVvTH0ev.js"), import("./estree-CKgw47OZ.js")]), a = t === "json" ? "json" : ["typescript", "ts"].includes(t) ? "babel-ts" : "babel";
2178
- return r(e, {
2179
- ...n,
2180
- parser: a,
2181
- plugins: [l, o]
2182
- });
2183
- }
2184
- default:
2185
- return e;
2186
- }
2187
- }
2188
- var Ul = { class: "structured-editor monospace" }, Gl = {
2189
- key: 0,
2190
- class: "flex flex-shrink-0 align-items-center space-between gap-05 px-075 py-025"
2191
- }, Jl = {
2192
- class: "txt11 opacity-5",
2193
- "aria-label": "Code language"
2194
- }, zl = { class: "flex align-items-center gap-025" }, jl = {
2195
- class: "hide",
2196
- role: "status"
2197
- }, Kl = {
2198
- key: 1,
2199
- role: "alert",
2200
- class: "txt12 color-red px-075"
2201
- }, Ql = /* @__PURE__ */ Dt({
2202
- __name: "StructuredEditor",
2203
- props: {
2204
- modelValue: {},
2205
- language: {},
2206
- lineNumbers: { type: Boolean },
2207
- folding: { type: Boolean },
2208
- formatting: { type: Boolean },
2209
- readonly: { type: Boolean },
2210
- disabled: { type: Boolean },
2211
- wrap: { type: Boolean },
2212
- singleLine: { type: Boolean },
2213
- placeholder: {},
2214
- label: {},
2215
- dark: { type: Boolean }
2216
- },
2217
- emits: [
2218
- "update:modelValue",
2219
- "focus",
2220
- "blur"
2221
- ],
2222
- setup(e, { emit: t }) {
2223
- const r = e, n = t, l = B(), o = B(!1), a = B(""), i = B(!1), s = B("");
2224
- let c;
2225
- const u = {
2226
- javascript: "JS",
2227
- typescript: "TS"
2228
- }, h = ot(() => u[r.language] || r.language.toUpperCase()), f = ot(() => r.formatting && !r.singleLine && _l(r.language)), g = new lt(), m = new lt(), Z = He.define();
2229
- let y, _ = 0, Ae = !1;
2230
- async function xr() {
2231
- s.value = "";
2232
- try {
2233
- await Mr(y?.state.doc.toString() ?? r.modelValue), i.value = !0, clearTimeout(c), c = setTimeout(() => {
2234
- i.value = !1;
2235
- }, 2e3);
2236
- } catch {
2237
- s.value = "Could not copy. Check clipboard permissions and try again.";
2238
- }
2239
- }
2240
- const kr = zr().appContext, Sr = cr({
2241
- theme: "light",
2242
- settings: {
2243
- background: "#fafafa",
2244
- foreground: "#383a42",
2245
- caret: "#526fff",
2246
- selection: "#d7d7d7",
2247
- selectionMatch: "#e5e5e6",
2248
- lineHighlight: "#f0f0f0",
2249
- gutterBackground: "#fafafa",
2250
- gutterForeground: "#9d9d9f"
2251
- }
2252
- });
2253
- function br(p) {
2254
- const S = document.createElement("div"), N = Qr(yt(p.state)), et = B(p.state.readOnly), tt = at({ setup: () => () => at(Wl, {
2255
- view: p,
2256
- query: N.value,
2257
- readonly: et.value
2258
- }) });
2259
- return tt.appContext = kr, it(tt, S), {
2260
- dom: S,
2261
- top: !0,
2262
- update() {
2263
- N.value = yt(p.state), et.value = p.state.readOnly;
2264
- },
2265
- destroy() {
2266
- it(null, S);
2267
- }
2268
- };
2269
- }
2270
- function Ze() {
2271
- return [
2272
- r.dark ? pl : Sr,
2273
- r.lineNumbers && !r.singleLine ? Ir() : [],
2274
- r.folding && !r.singleLine ? [Vr(), nt.of(Hr)] : [],
2275
- r.wrap ? v.lineWrapping : [],
2276
- he.readOnly.of(r.readonly || r.disabled),
2277
- v.editable.of(!r.readonly && !r.disabled),
2278
- v.contentAttributes.of({
2279
- "aria-label": r.label || "Code editor",
2280
- "aria-disabled": String(r.disabled)
2281
- }),
2282
- Pr(r.placeholder),
2283
- v.theme({
2284
- "&": { height: "100%" },
2285
- ".cm-scroller": {
2286
- overflow: "auto",
2287
- fontFamily: "inherit",
2288
- lineHeight: "1.5"
2289
- },
2290
- ".cm-content": { padding: "8px 0" },
2291
- "&.cm-focused": { outline: "none" }
2292
- }, { dark: r.dark })
2293
- ];
2294
- }
2295
- async function Cr() {
2296
- const p = ++_;
2297
- let S = [];
2298
- switch (r.language) {
2299
- case "html":
2300
- case "xml":
2301
- S = (await import("./dist-D8OWrPLr.js")).html();
2302
- break;
2303
- case "javascript":
2304
- case "js":
2305
- case "typescript":
2306
- case "ts":
2307
- S = (await import("./dist-B0uc2InW.js")).javascript({ typescript: ["typescript", "ts"].includes(r.language) });
2308
- break;
2309
- case "json":
2310
- S = (await import("./dist-BnLdfA7w.js")).json();
2311
- break;
2312
- case "css":
2313
- S = (await import("./dist-jq7acmcZ.js")).css();
2314
- break;
2315
- }
2316
- !Ae && p === _ && y?.dispatch({ effects: m.reconfigure(S) });
2317
- }
2318
- function Xe() {
2319
- Cr().catch(() => {
2320
- Ae || (a.value = "Could not load syntax support. Plain-text editing is still available.");
2321
- });
2322
- }
2323
- async function Ar() {
2324
- if (!y || !f.value || r.readonly || r.disabled || o.value) return;
2325
- const p = y.state.doc, S = r.language;
2326
- o.value = !0, a.value = "";
2327
- try {
2328
- const N = await Hl(p.toString(), S);
2329
- y && y.state.doc === p && r.language === S && !r.readonly && !r.disabled && (y.dispatch({
2330
- changes: {
2331
- from: 0,
2332
- to: p.length,
2333
- insert: N
2334
- },
2335
- userEvent: "input.format"
2336
- }), y.focus());
2337
- } catch {
2338
- a.value = "Could not format this code. Check its syntax and try again.";
2339
- } finally {
2340
- o.value = !1;
2341
- }
2342
- }
2343
- return Kr(() => {
2344
- y = new v({
2345
- parent: l.value,
2346
- state: he.create({
2347
- doc: r.modelValue,
2348
- extensions: [
2349
- g.of(Ze()),
2350
- m.of([]),
2351
- sn(),
2352
- bt.of(" "),
2353
- Jr(),
2354
- $r(),
2355
- Sl({ createPanel: br }),
2356
- nt.of([
2357
- {
2358
- key: "Enter",
2359
- run: () => r.singleLine
2360
- },
2361
- ...ul,
2362
- ...vn,
2363
- ...Tl,
2364
- hl
2365
- ]),
2366
- he.transactionFilter.of((p) => r.singleLine && p.docChanged && p.newDoc.lines > 1 ? [] : p),
2367
- v.updateListener.of((p) => {
2368
- p.docChanged && !p.transactions.some((S) => S.annotation(Z)) && n("update:modelValue", p.state.doc.toString()), p.focusChanged && (p.view.hasFocus ? n("focus") : n("blur"));
2369
- })
2370
- ]
2371
- })
2372
- }), Xe();
2373
- }), re(() => r.modelValue, (p) => {
2374
- y && p !== y.state.doc.toString() && y.dispatch({
2375
- changes: {
2376
- from: 0,
2377
- to: y.state.doc.length,
2378
- insert: p
2379
- },
2380
- annotations: Z.of(!0)
2381
- });
2382
- }), re(() => r.language, Xe), re(() => [
2383
- r.lineNumbers,
2384
- r.folding,
2385
- r.readonly,
2386
- r.disabled,
2387
- r.wrap,
2388
- r.singleLine,
2389
- r.placeholder,
2390
- r.label,
2391
- r.dark
2392
- ], () => {
2393
- y?.dispatch({ effects: g.reconfigure(Ze()) });
2394
- }), jr(() => {
2395
- Ae = !0, clearTimeout(c), y?.destroy(), y = void 0;
2396
- }), (p, S) => {
2397
- const N = Et("tooltip");
2398
- return P(), z("div", Ul, [
2399
- e.singleLine ? J("", !0) : (P(), z("div", Gl, [$("span", Jl, Le(h.value), 1), $("div", zl, [
2400
- f.value ? L((P(), Bt(M, {
2401
- key: 0,
2402
- thin: "",
2403
- flat: "",
2404
- icon: "format_align_left",
2405
- "aria-label": "Format code",
2406
- "aria-busy": o.value,
2407
- disabled: e.readonly || e.disabled || o.value,
2408
- onClick: Ar
2409
- }, null, 8, ["aria-busy", "disabled"])), [[N, o.value ? "Formatting…" : "Format code"]]) : J("", !0),
2410
- L(A(M, {
2411
- thin: "",
2412
- flat: "",
2413
- icon: i.value ? "check" : "content_copy",
2414
- "aria-label": i.value ? "Copied!" : "Copy code",
2415
- onClick: xr
2416
- }, null, 8, ["icon", "aria-label"]), [[N, i.value ? "Copied!" : "Copy code"]]),
2417
- $("span", jl, Le(i.value ? "Copied to clipboard" : ""), 1)
2418
- ])])),
2419
- a.value || s.value ? (P(), z("span", Kl, Le(a.value || s.value), 1)) : J("", !0),
2420
- $("div", {
2421
- ref_key: "host",
2422
- ref: l,
2423
- class: "structured-editor-host"
2424
- }, null, 512)
2425
- ]);
2426
- };
2427
- }
2428
- }), to = /* @__PURE__ */ xt(Ql, [["__scopeId", "data-v-b553967e"]]);
2429
- export {
2430
- to as default
2431
- };