@cascivo/editor 0.2.4 → 0.2.5

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.
package/dist/index.js CHANGED
@@ -1,24 +1,24 @@
1
1
  "use client";
2
- import { cn as e, useControllableSignal as t, useSignal as n, useSignalEffect as r, useSignals as i } from "@cascivo/core";
3
- import { builtin as a, t as o } from "@cascivo/i18n";
4
- import { forwardRef as s, useImperativeHandle as c, useRef as l } from "react";
5
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
2
+ import { cn as e, useAnchorPosition as t, useControllableSignal as n, useId as r, useSignal as i, useSignalEffect as a, useSignals as o } from "@cascivo/core";
3
+ import { builtin as s, t as c } from "@cascivo/i18n";
4
+ import { forwardRef as l, useImperativeHandle as ee, useRef as u } from "react";
5
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
6
6
  //#region src/engine/tokenize.ts
7
- var f = /* @__PURE__ */ new Map(), p = "\0", ee = 0;
8
- function m(e, t, n) {
9
- let r = `${e.name}${p}${n}${p}${t}`, i = f.get(r);
7
+ var p = /* @__PURE__ */ new Map(), m = "\0", h = 0;
8
+ function g(e, t, n) {
9
+ let r = `${e.name}${m}${n}${m}${t}`, i = p.get(r);
10
10
  if (i) return i;
11
- ee++;
11
+ h++;
12
12
  let { tokens: a, state: o } = e.tokenizeLine(t, n), s = {
13
13
  tokens: a,
14
14
  endState: o
15
15
  };
16
- return f.set(r, s), s;
16
+ return p.set(r, s), s;
17
17
  }
18
- function h(e, t) {
18
+ function _(e, t) {
19
19
  let n = t.split("\n"), r = [], i = e.initialState;
20
20
  for (let t of n) {
21
- let n = m(e, t, i);
21
+ let n = g(e, t, i);
22
22
  r.push(n.tokens), i = n.endState;
23
23
  }
24
24
  return r;
@@ -26,7 +26,7 @@ function h(e, t) {
26
26
  function te(e, t, n, r, i) {
27
27
  let a = Math.max(0, Math.min(n, t.length)), o = Math.max(a, Math.min(r, t.length)), s = i.startStateOf(t, a), c = [];
28
28
  for (let n = a; n < o; n++) {
29
- let r = m(e, t[n], s);
29
+ let r = g(e, t[n], s);
30
30
  c.push(r.tokens), i.setEndState(n, r.endState), s = r.endState;
31
31
  }
32
32
  return c;
@@ -39,7 +39,7 @@ function ne(e) {
39
39
  if (a > i) return;
40
40
  let o = a === 0 ? e.initialState : t[a - 1];
41
41
  for (; a <= i; a++) {
42
- let r = m(e, n[a], o);
42
+ let r = g(e, n[a], o);
43
43
  t[a] = r.endState, o = r.endState;
44
44
  }
45
45
  };
@@ -61,7 +61,7 @@ function ne(e) {
61
61
  }
62
62
  //#endregion
63
63
  //#region src/engine/registry.ts
64
- var g = /* @__PURE__ */ new Map(), _ = {
64
+ var v = /* @__PURE__ */ new Map(), y = {
65
65
  name: "plaintext",
66
66
  initialState: "default",
67
67
  tokenizeLine: (e) => ({
@@ -72,23 +72,23 @@ var g = /* @__PURE__ */ new Map(), _ = {
72
72
  state: "default"
73
73
  })
74
74
  };
75
- g.set(_.name, _);
76
- function v(e) {
77
- g.set(e.name, e);
75
+ v.set(y.name, y);
76
+ function b(e) {
77
+ v.set(e.name, e);
78
78
  }
79
79
  function re(e) {
80
80
  if (e !== void 0) {
81
- let t = g.get(e);
81
+ let t = v.get(e);
82
82
  if (t) return t;
83
83
  }
84
- return g.get("plaintext");
84
+ return v.get("plaintext");
85
85
  }
86
- function y() {
87
- return [...g.keys()];
86
+ function x() {
87
+ return [...v.keys()];
88
88
  }
89
89
  //#endregion
90
90
  //#region src/grammars/rules.ts
91
- function b(e) {
91
+ function S(e) {
92
92
  let t = {};
93
93
  for (let [n, r] of Object.entries(e.states)) t[n] = r.map((e) => {
94
94
  let t = `${e.match.flags.replace(/[gy]/g, "")}y`, n = {
@@ -131,7 +131,7 @@ function b(e) {
131
131
  }
132
132
  //#endregion
133
133
  //#region src/grammars/plaintext.ts
134
- var x = {
134
+ var ie = {
135
135
  name: "plaintext",
136
136
  initialState: "default",
137
137
  tokenizeLine: (e) => ({
@@ -142,10 +142,10 @@ var x = {
142
142
  state: "default"
143
143
  })
144
144
  };
145
- v(x);
145
+ b(ie);
146
146
  //#endregion
147
147
  //#region src/grammars/json.ts
148
- var S = b({
148
+ var ae = S({
149
149
  name: "json",
150
150
  states: { default: [
151
151
  {
@@ -174,14 +174,14 @@ var S = b({
174
174
  }
175
175
  ] }
176
176
  });
177
- v(S);
177
+ b(ae);
178
178
  //#endregion
179
179
  //#region src/grammars/clike.ts
180
- var C = /* @__PURE__ */ "async.await.break.case.catch.class.const.continue.debugger.default.delete.do.else.export.extends.finally.for.function.if.import.in.instanceof.let.new.of.return.static.super.switch.this.throw.try.typeof.var.void.while.with.yield.as.from.get.set".split(".");
181
- function w(e) {
180
+ var oe = /* @__PURE__ */ "async.await.break.case.catch.class.const.continue.debugger.default.delete.do.else.export.extends.finally.for.function.if.import.in.instanceof.let.new.of.return.static.super.switch.this.throw.try.typeof.var.void.while.with.yield.as.from.get.set".split(".");
181
+ function se(e) {
182
182
  return RegExp(`(?:${e.join("|")})\\b`);
183
183
  }
184
- function T(e, t, n = []) {
184
+ function C(e, t, n = []) {
185
185
  let r = [
186
186
  {
187
187
  match: /\/\/.*/,
@@ -215,10 +215,10 @@ function T(e, t, n = []) {
215
215
  }
216
216
  ];
217
217
  return n.length > 0 && r.push({
218
- match: w(n),
218
+ match: se(n),
219
219
  kind: "type"
220
220
  }), r.push({
221
- match: w(t),
221
+ match: se(t),
222
222
  kind: "keyword"
223
223
  }, {
224
224
  match: /[A-Za-z_$][\w$]*(?=\s*\()/,
@@ -235,7 +235,7 @@ function T(e, t, n = []) {
235
235
  }, {
236
236
  match: /[{}()[\];,.:]/,
237
237
  kind: "punctuation"
238
- }), b({
238
+ }), S({
239
239
  name: e,
240
240
  states: {
241
241
  default: r,
@@ -282,9 +282,9 @@ function T(e, t, n = []) {
282
282
  }
283
283
  //#endregion
284
284
  //#region src/grammars/javascript.ts
285
- var ie = T("javascript", C);
286
- v(ie);
287
- var ae = T("typescript", C, [
285
+ var ce = C("javascript", oe);
286
+ b(ce);
287
+ var le = C("typescript", oe, [
288
288
  "interface",
289
289
  "type",
290
290
  "enum",
@@ -310,10 +310,10 @@ var ae = T("typescript", C, [
310
310
  "never",
311
311
  "object"
312
312
  ]);
313
- v(ae);
313
+ b(le);
314
314
  //#endregion
315
315
  //#region src/grammars/css.ts
316
- var oe = b({
316
+ var w = S({
317
317
  name: "css",
318
318
  states: {
319
319
  default: [
@@ -380,10 +380,10 @@ var oe = b({
380
380
  ]
381
381
  }
382
382
  });
383
- v(oe);
383
+ b(w);
384
384
  //#endregion
385
385
  //#region src/grammars/html.ts
386
- var se = b({
386
+ var ue = S({
387
387
  name: "html",
388
388
  states: {
389
389
  default: [
@@ -442,10 +442,10 @@ var se = b({
442
442
  ]
443
443
  }
444
444
  });
445
- v(se);
445
+ b(ue);
446
446
  //#endregion
447
447
  //#region src/grammars/markdown.ts
448
- var ce = b({
448
+ var de = S({
449
449
  name: "markdown",
450
450
  states: {
451
451
  default: [
@@ -518,10 +518,10 @@ var ce = b({
518
518
  }]
519
519
  }
520
520
  });
521
- v(ce);
521
+ b(de);
522
522
  //#endregion
523
523
  //#region src/grammars/bash.ts
524
- var le = b({
524
+ var fe = S({
525
525
  name: "bash",
526
526
  states: { default: [
527
527
  {
@@ -558,8 +558,8 @@ var le = b({
558
558
  }
559
559
  ] }
560
560
  });
561
- v(le);
562
- var E = {
561
+ b(fe);
562
+ var T = {
563
563
  root: "_root_1m6ns_2",
564
564
  gutter: "_gutter_1m6ns_17",
565
565
  gutterLine: "_gutterLine_1m6ns_28",
@@ -588,77 +588,77 @@ var E = {
588
588
  };
589
589
  //#endregion
590
590
  //#region src/editor/view.tsx
591
- function ue(e, t) {
591
+ function pe(e, t) {
592
592
  let n = "";
593
593
  for (let r of t) e >= r.start && e < r.end && (n = n ? `${n} ${r.className}` : r.className);
594
594
  return n;
595
595
  }
596
- function de(t, n, r, i) {
596
+ function me(t, n, r, i) {
597
597
  let a = n + t.value.length, o = new Set([n, a]);
598
598
  for (let e of r) e.start > n && e.start < a && o.add(e.start), e.end > n && e.end < a && o.add(e.end);
599
599
  if (o.size === 2) {
600
- let a = ue(n, r);
601
- return /* @__PURE__ */ u("span", {
602
- className: a ? e(E[t.kind], a) : E[t.kind],
600
+ let a = pe(n, r);
601
+ return /* @__PURE__ */ d("span", {
602
+ className: a ? e(T[t.kind], a) : T[t.kind],
603
603
  children: t.value
604
604
  }, i);
605
605
  }
606
606
  let s = [...o].sort((e, t) => e - t), c = [];
607
607
  for (let i = 0; i < s.length - 1; i++) {
608
- let a = s[i], o = s[i + 1], l = ue(a, r);
609
- c.push(/* @__PURE__ */ u("span", {
610
- className: l ? e(E[t.kind], l) : E[t.kind],
608
+ let a = s[i], o = s[i + 1], l = pe(a, r);
609
+ c.push(/* @__PURE__ */ d("span", {
610
+ className: l ? e(T[t.kind], l) : T[t.kind],
611
611
  children: t.value.slice(a - n, o - n)
612
612
  }, a));
613
613
  }
614
- return /* @__PURE__ */ u("span", { children: c }, i);
614
+ return /* @__PURE__ */ d("span", { children: c }, i);
615
615
  }
616
- function fe(e, t = 0, n = t + e.length, r) {
616
+ function he(e, t = 0, n = t + e.length, r) {
617
617
  let i = [];
618
618
  for (let a = t; a < n; a++) {
619
619
  let n = e[a - t], o = r?.filter((e) => e.line === a);
620
- i.push(/* @__PURE__ */ u("span", {
621
- className: E.line,
620
+ i.push(/* @__PURE__ */ d("span", {
621
+ className: T.line,
622
622
  children: n.length === 0 ? "​" : o && o.length > 0 ? (() => {
623
623
  let e = 0;
624
624
  return n.map((t, n) => {
625
- let r = de(t, e, o, n);
625
+ let r = me(t, e, o, n);
626
626
  return e += t.value.length, r;
627
627
  });
628
- })() : n.map((e, t) => /* @__PURE__ */ u("span", {
629
- className: E[e.kind],
628
+ })() : n.map((e, t) => /* @__PURE__ */ d("span", {
629
+ className: T[e.kind],
630
630
  children: e.value
631
631
  }, t))
632
632
  }, a));
633
633
  }
634
634
  return i;
635
635
  }
636
- function pe({ count: e, className: t, gutterRef: n, start: r = 0, end: i = e, topPad: a = 0, bottomPad: o = 0, activeLine: s = !1 }) {
636
+ function ge({ count: e, className: t, gutterRef: n, start: r = 0, end: i = e, topPad: a = 0, bottomPad: o = 0, activeLine: s = !1 }) {
637
637
  let c = [];
638
- for (let e = r + 1; e <= i; e++) c.push(/* @__PURE__ */ u("span", {
639
- className: E.gutterLine,
638
+ for (let e = r + 1; e <= i; e++) c.push(/* @__PURE__ */ d("span", {
639
+ className: T.gutterLine,
640
640
  children: e
641
641
  }, e));
642
- return /* @__PURE__ */ d("div", {
642
+ return /* @__PURE__ */ f("div", {
643
643
  ref: n,
644
644
  className: t,
645
645
  "aria-hidden": "true",
646
646
  children: [
647
- s && /* @__PURE__ */ u("div", { className: E.gutterActive }),
648
- a > 0 && /* @__PURE__ */ u("div", { style: { blockSize: a } }),
647
+ s && /* @__PURE__ */ d("div", { className: T.gutterActive }),
648
+ a > 0 && /* @__PURE__ */ d("div", { style: { blockSize: a } }),
649
649
  c,
650
- o > 0 && /* @__PURE__ */ u("div", { style: { blockSize: o } })
650
+ o > 0 && /* @__PURE__ */ d("div", { style: { blockSize: o } })
651
651
  ]
652
652
  });
653
653
  }
654
- var D = {
654
+ var E = {
655
655
  root: "_root_18xci_2",
656
656
  textarea: "_textarea_18xci_18",
657
657
  gutter: "_gutter_18xci_23",
658
658
  codeArea: "_codeArea_18xci_36",
659
659
  pre: "_pre_18xci_43",
660
660
  currentLine: "_currentLine_18xci_58"
661
- }, O = {
661
+ }, D = {
662
662
  panel: "_panel_hawkv_2",
663
663
  row: "_row_hawkv_20",
664
664
  input: "_input_hawkv_26",
@@ -669,32 +669,32 @@ var D = {
669
669
  };
670
670
  //#endregion
671
671
  //#region src/editor/code-editor/find-panel.tsx
672
- function me(t) {
673
- i();
674
- let n = t.matchCount === 0 ? o(a.editor.noMatches) : o(a.editor.findCount, {
672
+ function _e(t) {
673
+ o();
674
+ let n = t.matchCount === 0 ? c(s.editor.noMatches) : c(s.editor.findCount, {
675
675
  current: t.currentIndex + 1,
676
676
  total: t.matchCount
677
677
  });
678
- return /* @__PURE__ */ d("div", {
679
- className: O.panel,
678
+ return /* @__PURE__ */ f("div", {
679
+ className: D.panel,
680
680
  role: "search",
681
- "aria-label": o(a.editor.find),
682
- children: [/* @__PURE__ */ d("div", {
683
- className: O.row,
681
+ "aria-label": c(s.editor.find),
682
+ children: [/* @__PURE__ */ f("div", {
683
+ className: D.row,
684
684
  children: [
685
- /* @__PURE__ */ u("button", {
685
+ /* @__PURE__ */ d("button", {
686
686
  type: "button",
687
- className: O.toggle,
688
- "aria-label": o(a.editor.toggleReplace),
687
+ className: D.toggle,
688
+ "aria-label": c(s.editor.toggleReplace),
689
689
  "aria-expanded": t.replaceMode,
690
690
  onClick: t.onToggleReplace,
691
691
  children: t.replaceMode ? "▾" : "▸"
692
692
  }),
693
- /* @__PURE__ */ u("input", {
694
- className: O.input,
693
+ /* @__PURE__ */ d("input", {
694
+ className: D.input,
695
695
  value: t.query,
696
- placeholder: o(a.editor.findPlaceholder),
697
- "aria-label": o(a.editor.find),
696
+ placeholder: c(s.editor.findPlaceholder),
697
+ "aria-label": c(s.editor.find),
698
698
  autoFocus: !0,
699
699
  autoComplete: "off",
700
700
  spellCheck: !1,
@@ -703,49 +703,49 @@ function me(t) {
703
703
  e.key === "Enter" ? (e.preventDefault(), e.shiftKey ? t.onPrev() : t.onNext()) : e.key === "Escape" && (e.preventDefault(), t.onClose());
704
704
  }
705
705
  }),
706
- /* @__PURE__ */ u("span", {
707
- className: O.count,
706
+ /* @__PURE__ */ d("span", {
707
+ className: D.count,
708
708
  "aria-live": "polite",
709
709
  children: n
710
710
  }),
711
- /* @__PURE__ */ u("button", {
711
+ /* @__PURE__ */ d("button", {
712
712
  type: "button",
713
- className: O.button,
714
- "aria-label": o(a.editor.previous),
713
+ className: D.button,
714
+ "aria-label": c(s.editor.previous),
715
715
  onClick: t.onPrev,
716
716
  children: "‹"
717
717
  }),
718
- /* @__PURE__ */ u("button", {
718
+ /* @__PURE__ */ d("button", {
719
719
  type: "button",
720
- className: O.button,
721
- "aria-label": o(a.editor.next),
720
+ className: D.button,
721
+ "aria-label": c(s.editor.next),
722
722
  onClick: t.onNext,
723
723
  children: "›"
724
724
  }),
725
- /* @__PURE__ */ u("button", {
725
+ /* @__PURE__ */ d("button", {
726
726
  type: "button",
727
- className: e(O.button, t.caseSensitive && O.active),
727
+ className: e(D.button, t.caseSensitive && D.active),
728
728
  "aria-pressed": t.caseSensitive,
729
- "aria-label": o(a.editor.matchCase),
729
+ "aria-label": c(s.editor.matchCase),
730
730
  onClick: t.onToggleCase,
731
731
  children: "Aa"
732
732
  }),
733
- /* @__PURE__ */ u("button", {
733
+ /* @__PURE__ */ d("button", {
734
734
  type: "button",
735
- className: O.button,
736
- "aria-label": o(a.editor.close),
735
+ className: D.button,
736
+ "aria-label": c(s.editor.close),
737
737
  onClick: t.onClose,
738
738
  children: "×"
739
739
  })
740
740
  ]
741
- }), t.replaceMode && /* @__PURE__ */ d("div", {
742
- className: O.row,
741
+ }), t.replaceMode && /* @__PURE__ */ f("div", {
742
+ className: D.row,
743
743
  children: [
744
- /* @__PURE__ */ u("input", {
745
- className: O.input,
744
+ /* @__PURE__ */ d("input", {
745
+ className: D.input,
746
746
  value: t.replaceQuery,
747
- placeholder: o(a.editor.replacePlaceholder),
748
- "aria-label": o(a.editor.replace),
747
+ placeholder: c(s.editor.replacePlaceholder),
748
+ "aria-label": c(s.editor.replace),
749
749
  autoComplete: "off",
750
750
  spellCheck: !1,
751
751
  onChange: (e) => t.onReplaceChange(e.currentTarget.value),
@@ -753,17 +753,17 @@ function me(t) {
753
753
  e.key === "Escape" ? (e.preventDefault(), t.onClose()) : e.key === "Enter" && (e.preventDefault(), t.onReplace());
754
754
  }
755
755
  }),
756
- /* @__PURE__ */ u("button", {
756
+ /* @__PURE__ */ d("button", {
757
757
  type: "button",
758
- className: O.button,
758
+ className: D.button,
759
759
  onClick: t.onReplace,
760
- children: o(a.editor.replaceOne)
760
+ children: c(s.editor.replaceOne)
761
761
  }),
762
- /* @__PURE__ */ u("button", {
762
+ /* @__PURE__ */ d("button", {
763
763
  type: "button",
764
- className: O.button,
764
+ className: D.button,
765
765
  onClick: t.onReplaceAll,
766
- children: o(a.editor.replaceAll)
766
+ children: c(s.editor.replaceAll)
767
767
  })
768
768
  ]
769
769
  })]
@@ -771,25 +771,25 @@ function me(t) {
771
771
  }
772
772
  //#endregion
773
773
  //#region src/editor/code-editor/find.ts
774
- var he = /\w/;
775
- function k(e) {
776
- return e !== void 0 && he.test(e);
774
+ var O = /\w/;
775
+ function ve(e) {
776
+ return e !== void 0 && O.test(e);
777
777
  }
778
- function ge(e, t, n = {}) {
778
+ function ye(e, t, n = {}) {
779
779
  if (t.length === 0) return [];
780
780
  let r = n.caseSensitive ? e : e.toLowerCase(), i = n.caseSensitive ? t : t.toLowerCase(), a = [], o = 0;
781
781
  for (;;) {
782
782
  let t = r.indexOf(i, o);
783
783
  if (t === -1) break;
784
784
  let s = t + i.length;
785
- (!n.wholeWord || !k(e[t - 1]) && !k(e[s])) && a.push({
785
+ (!n.wholeWord || !ve(e[t - 1]) && !ve(e[s])) && a.push({
786
786
  start: t,
787
787
  end: s
788
788
  }), o = s > t ? s : t + 1;
789
789
  }
790
790
  return a;
791
791
  }
792
- function _e(e, t) {
792
+ function be(e, t) {
793
793
  let n = 0, r = 0;
794
794
  for (let i = 0; i < t && i < e.length; i++) e[i] === "\n" && (n++, r = i + 1);
795
795
  return {
@@ -797,9 +797,9 @@ function _e(e, t) {
797
797
  col: t - r
798
798
  };
799
799
  }
800
- function ve(e, t, n, r) {
800
+ function xe(e, t, n, r) {
801
801
  return t.map((t, i) => {
802
- let { line: a, col: o } = _e(e, t.start);
802
+ let { line: a, col: o } = be(e, t.start);
803
803
  return {
804
804
  line: a,
805
805
  start: o,
@@ -808,7 +808,7 @@ function ve(e, t, n, r) {
808
808
  };
809
809
  });
810
810
  }
811
- function ye(e, t, n) {
811
+ function Se(e, t, n) {
812
812
  let r = e;
813
813
  for (let e = t.length - 1; e >= 0; e--) {
814
814
  let i = t[e];
@@ -818,16 +818,16 @@ function ye(e, t, n) {
818
818
  }
819
819
  //#endregion
820
820
  //#region src/editor/code-editor/brackets.ts
821
- var A = {
821
+ var k = {
822
822
  "(": ")",
823
823
  "[": "]",
824
824
  "{": "}"
825
- }, j = {
825
+ }, A = {
826
826
  ")": "(",
827
827
  "]": "[",
828
828
  "}": "}"
829
829
  };
830
- function M(e, t, n, r) {
830
+ function j(e, t, n, r) {
831
831
  let i = 0;
832
832
  for (let a = t; a < e.length; a++) {
833
833
  let t = e[a];
@@ -836,7 +836,7 @@ function M(e, t, n, r) {
836
836
  }
837
837
  return -1;
838
838
  }
839
- function N(e, t, n, r) {
839
+ function M(e, t, n, r) {
840
840
  let i = 0;
841
841
  for (let a = t; a >= 0; a--) {
842
842
  let t = e[a];
@@ -845,41 +845,41 @@ function N(e, t, n, r) {
845
845
  }
846
846
  return -1;
847
847
  }
848
- function be(e, t) {
848
+ function Ce(e, t) {
849
849
  let n = e[t];
850
- if (n && n in A) {
851
- let r = M(e, t, n, A[n]);
850
+ if (n && n in k) {
851
+ let r = j(e, t, n, k[n]);
852
852
  if (r !== -1) return {
853
853
  open: t,
854
854
  close: r
855
855
  };
856
856
  }
857
857
  let r = e[t - 1];
858
- if (r && r in j) {
859
- let n = N(e, t - 1, j[r], r);
858
+ if (r && r in A) {
859
+ let n = M(e, t - 1, A[r], r);
860
860
  if (n !== -1) return {
861
861
  open: n,
862
862
  close: t - 1
863
863
  };
864
864
  }
865
- if (r && r in A) {
866
- let n = M(e, t - 1, r, A[r]);
865
+ if (r && r in k) {
866
+ let n = j(e, t - 1, r, k[r]);
867
867
  if (n !== -1) return {
868
868
  open: t - 1,
869
869
  close: n
870
870
  };
871
871
  }
872
- if (n && n in j) {
873
- let r = N(e, t, j[n], n);
872
+ if (n && n in A) {
873
+ let r = M(e, t, A[n], n);
874
874
  if (r !== -1) return {
875
875
  open: r,
876
876
  close: t
877
877
  };
878
878
  }
879
879
  }
880
- function xe(e, t, n) {
880
+ function we(e, t, n) {
881
881
  return [t.open, t.close].map((t) => {
882
- let { line: r, col: i } = _e(e, t);
882
+ let { line: r, col: i } = be(e, t);
883
883
  return {
884
884
  line: r,
885
885
  start: i,
@@ -890,7 +890,7 @@ function xe(e, t, n) {
890
890
  }
891
891
  //#endregion
892
892
  //#region src/editor/code-editor/history.ts
893
- function Se(e = 200) {
893
+ function Te(e = 200) {
894
894
  let t = [], n = -1, r = !1;
895
895
  return {
896
896
  record(i, a) {
@@ -916,23 +916,23 @@ function Se(e = 200) {
916
916
  }
917
917
  //#endregion
918
918
  //#region src/editor/code-editor/keymap.ts
919
- var P = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || "");
920
- function F(e) {
919
+ var N = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || "");
920
+ function P(e) {
921
921
  let t = [];
922
- (P ? e.metaKey : e.ctrlKey) && t.push("Mod"), e.altKey && t.push("Alt"), e.shiftKey && t.push("Shift");
922
+ (N ? e.metaKey : e.ctrlKey) && t.push("Mod"), e.altKey && t.push("Alt"), e.shiftKey && t.push("Shift");
923
923
  let n = e.key;
924
924
  return n.length === 1 && (n = n.toLowerCase()), t.push(n), t.join("-");
925
925
  }
926
- function Ce(e, t) {
926
+ function Ee(e, t) {
927
927
  let n = new Map(Object.entries(e));
928
928
  if (t) for (let [e, r] of Object.entries(t)) n.set(e, r);
929
929
  return n;
930
930
  }
931
- function we(e, t) {
932
- let n = e.get(F(t.event));
931
+ function De(e, t) {
932
+ let n = e.get(P(t.event));
933
933
  return n ? n(t) : !1;
934
934
  }
935
- function Te(e) {
935
+ function Oe(e) {
936
936
  let t = () => e.insertSpaces ? " ".repeat(e.tabSize) : " ";
937
937
  return {
938
938
  indent: ({ textarea: e, setText: n }) => {
@@ -952,7 +952,7 @@ function Te(e) {
952
952
  }
953
953
  //#endregion
954
954
  //#region src/editor/code-editor/sync.ts
955
- function Ee(e, t) {
955
+ function ke(e, t) {
956
956
  if (e === t) return {
957
957
  from: e.length,
958
958
  to: e.length,
@@ -968,30 +968,124 @@ function Ee(e, t) {
968
968
  insert: t.slice(r, a)
969
969
  };
970
970
  }
971
- function I(e, t) {
971
+ function F(e, t) {
972
972
  return e <= t.from ? e : e >= t.to ? e + (t.insert.length - (t.to - t.from)) : t.from + t.insert.length;
973
973
  }
974
- function De(e, t, n) {
974
+ function Ae(e, t, n) {
975
975
  return {
976
- start: I(e, n),
977
- end: I(t, n)
976
+ start: F(e, n),
977
+ end: F(t, n)
978
978
  };
979
979
  }
980
- var L = s(function({ value: s, defaultValue: f, onValueChange: p, language: ee = "plaintext", lineNumbers: m = !0, tabSize: h = 2, insertSpaces: g = !0, wrap: _ = !1, virtualize: v, readOnly: y = !1, disabled: b = !1, spellCheck: x = !1, label: S, onSave: C, keymap: w, decorations: T, theme: ie, bracketMatching: ae = !1, className: oe, style: se, onKeyDown: ce, ...le }, ue) {
981
- i();
982
- let de = l(C);
983
- de.current = C;
984
- let [O, he] = t({
985
- value: s,
986
- defaultValue: f ?? "",
987
- onChange: p
988
- }), k = l(null), A = l(null), j = l(null), M = l(null), N = l(null);
989
- N.current === null && (N.current = Se(), N.current.reset({
980
+ //#endregion
981
+ //#region src/editor/code-editor/caret.ts
982
+ function I(e, t) {
983
+ let n = 0;
984
+ for (let r of e) r === " " ? n += t - n % t : n += 1;
985
+ return n;
986
+ }
987
+ function je(e, t, n) {
988
+ let { line: r, col: i } = be(e, t), a = I(e.slice(t - i, t), n.tabSize);
989
+ return {
990
+ top: r * n.lineHeight - n.scrollTop + n.padTop,
991
+ left: a * n.charWidth - n.scrollLeft + n.padLeft
992
+ };
993
+ }
994
+ function Me(e, t) {
995
+ if (typeof document > "u") return null;
996
+ let n = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0, i = n.nextNode();
997
+ for (; i;) {
998
+ let e = i.textContent?.length ?? 0;
999
+ if (t <= r + e) {
1000
+ let e = document.createRange();
1001
+ e.setStart(i, Math.max(0, t - r)), e.collapse(!0);
1002
+ let n = e.getClientRects();
1003
+ return n.length > 0 ? n[0] : e.getBoundingClientRect();
1004
+ }
1005
+ r += e, i = n.nextNode();
1006
+ }
1007
+ return null;
1008
+ }
1009
+ function Ne(e) {
1010
+ if (typeof document > "u") return 0;
1011
+ let t = getComputedStyle(e), n = document.createElement("span");
1012
+ n.style.position = "absolute", n.style.visibility = "hidden", n.style.whiteSpace = "pre", n.style.font = t.font, n.style.letterSpacing = t.letterSpacing, n.style.tabSize = t.tabSize, n.textContent = "0".repeat(10), document.body.appendChild(n);
1013
+ let r = n.getBoundingClientRect().width / 10;
1014
+ return n.remove(), r;
1015
+ }
1016
+ //#endregion
1017
+ //#region src/editor/code-editor/slash-trigger.ts
1018
+ function Pe(e, t) {
1019
+ for (let n = t - 1; n >= 0; n--) {
1020
+ let r = e[n];
1021
+ if (r === "/") {
1022
+ let r = e[n - 1];
1023
+ return r === void 0 || /\s/.test(r) ? {
1024
+ start: n,
1025
+ query: e.slice(n + 1, t)
1026
+ } : null;
1027
+ }
1028
+ if (r === void 0 || /\s/.test(r)) return null;
1029
+ }
1030
+ return null;
1031
+ }
1032
+ function Fe(e, t) {
1033
+ if (t === "") return [...e];
1034
+ let n = t.toLowerCase();
1035
+ return e.filter((e) => e.label.toLowerCase().includes(n) || (e.keywords?.some((e) => e.toLowerCase().includes(n)) ?? !1));
1036
+ }
1037
+ var L = {
1038
+ menu: "_menu_zkolh_2",
1039
+ option: "_option_zkolh_24",
1040
+ active: "_active_zkolh_35",
1041
+ label: "_label_zkolh_39",
1042
+ hint: "_hint_zkolh_44",
1043
+ empty: "_empty_zkolh_50"
1044
+ }, Ie = l(function({ id: t, items: n, activeIndex: r, onSelect: i, onHover: a, style: l }, ee) {
1045
+ return o(), /* @__PURE__ */ d("ul", {
1046
+ ref: ee,
1047
+ id: t,
1048
+ className: L.menu,
1049
+ role: "listbox",
1050
+ "aria-label": c(s.editor.commandMenu),
1051
+ style: l,
1052
+ children: n.length === 0 ? /* @__PURE__ */ d("li", {
1053
+ className: L.empty,
1054
+ role: "presentation",
1055
+ children: c(s.editor.commandMenuEmpty)
1056
+ }) : n.map((n, o) => /* @__PURE__ */ f("li", {
1057
+ id: `${t}-opt-${o}`,
1058
+ role: "option",
1059
+ "aria-selected": o === r,
1060
+ className: e(L.option, o === r && L.active),
1061
+ onMouseEnter: () => a(o),
1062
+ onMouseDown: (e) => {
1063
+ e.preventDefault(), i(o);
1064
+ },
1065
+ children: [/* @__PURE__ */ d("span", {
1066
+ className: L.label,
1067
+ children: n.label
1068
+ }), n.hint !== void 0 && /* @__PURE__ */ d("span", {
1069
+ className: L.hint,
1070
+ children: n.hint
1071
+ })]
1072
+ }, n.id))
1073
+ });
1074
+ }), R = l(function({ value: l, defaultValue: p, onValueChange: m, language: h = "plaintext", lineNumbers: g = !0, tabSize: _ = 2, insertSpaces: v = !0, wrap: y = !1, virtualize: b, readOnly: x = !1, disabled: S = !1, spellCheck: ie = !1, label: ae, onSave: oe, keymap: se, decorations: C, theme: ce, bracketMatching: le = !1, commands: w, className: ue, style: de, onKeyDown: fe, ...pe }, me) {
1075
+ o();
1076
+ let D = u(oe);
1077
+ D.current = oe;
1078
+ let [O, ve] = n({
1079
+ value: l,
1080
+ defaultValue: p ?? "",
1081
+ onChange: m
1082
+ }), k = u(null), A = u(null), j = u(null), M = u(null), N = u(null);
1083
+ N.current === null && (N.current = Te(), N.current.reset({
990
1084
  text: O.value,
991
1085
  selectionStart: 0,
992
1086
  selectionEnd: 0
993
1087
  }));
994
- let P = N.current, F = l(null), I = l(void 0), L = l(O.value), R = l(void 0), z = l(!1), B = l({
1088
+ let P = N.current, F = u(null), I = u(void 0), L = u(O.value), R = u(void 0), z = u(!1), B = u({
995
1089
  start: 0,
996
1090
  end: 0
997
1091
  }), V = (e, t, n) => {
@@ -999,30 +1093,30 @@ var L = s(function({ value: s, defaultValue: f, onValueChange: p, language: ee =
999
1093
  text: e,
1000
1094
  selectionStart: t.start,
1001
1095
  selectionEnd: t.end
1002
- }, { coalesce: n }), he(e);
1003
- }, Oe = (e) => {
1096
+ }, { coalesce: n }), ve(e);
1097
+ }, Le = (e) => {
1004
1098
  let t = M.current;
1005
1099
  V(e, t ? {
1006
1100
  start: t.selectionStart,
1007
1101
  end: t.selectionEnd
1008
1102
  } : B.current, !1);
1009
- }, ke = (e) => {
1103
+ }, Re = (e) => {
1010
1104
  let t = M.current;
1011
1105
  if (!t) return;
1012
- z.current = !0, t.value = e.text, t.setSelectionRange(e.selectionStart, e.selectionEnd), he(e.text), R.current = e.text, L.current = e.text, B.current = {
1106
+ z.current = !0, t.value = e.text, t.setSelectionRange(e.selectionStart, e.selectionEnd), ve(e.text), R.current = e.text, L.current = e.text, B.current = {
1013
1107
  start: e.selectionStart,
1014
1108
  end: e.selectionEnd
1015
- }, Ie.value = e.selectionStart;
1109
+ }, G.value = e.selectionStart;
1016
1110
  let n = e.text.slice(0, e.selectionStart).split("\n").length - 1;
1017
1111
  k.current?.style.setProperty("--cascivo-editor-caret-line", String(n)), z.current = !1;
1018
- }, Ae = () => {
1112
+ }, ze = () => {
1019
1113
  let e = P.undo();
1020
- e && ke(e);
1021
- }, je = () => {
1114
+ e && Re(e);
1115
+ }, Be = () => {
1022
1116
  let e = P.redo();
1023
- e && ke(e);
1024
- }, H = n(O.value), Me = n(0), Ne = n(0), Pe = n(0), U = n(!1), Fe = n(""), W = n(""), G = n(!1), K = n(!1), q = n(0), Ie = n(0);
1025
- r(() => {
1117
+ e && Re(e);
1118
+ }, H = i(O.value), Ve = i(0), He = i(0), Ue = i(0), U = i(!1), We = i(""), Ge = i(""), Ke = i(!1), qe = i(!1), W = i(0), G = i(0), K = i(!1), Je = i(0), Ye = i(""), q = i(0), Xe = i(-1), Ze = i(0), Qe = u(null), $e = u(null), et = r("slash-menu");
1119
+ a(() => {
1026
1120
  let e = O.value;
1027
1121
  if (typeof requestAnimationFrame != "function") {
1028
1122
  H.value = e;
@@ -1032,102 +1126,149 @@ var L = s(function({ value: s, defaultValue: f, onValueChange: p, language: ee =
1032
1126
  H.value = e;
1033
1127
  });
1034
1128
  return () => cancelAnimationFrame(t);
1035
- }), r(() => {
1129
+ }), a(() => {
1036
1130
  let e = O.value;
1037
1131
  if (z.current || e === L.current) return;
1038
1132
  if (e === R.current) {
1039
1133
  L.current = e;
1040
1134
  return;
1041
1135
  }
1042
- let t = M.current, n = Ee(L.current, e), r = De(B.current.start, B.current.end, n);
1136
+ let t = M.current, n = ke(L.current, e), r = Ae(B.current.start, B.current.end, n);
1043
1137
  t && (z.current = !0, t.value !== e && (t.value = e), t.setSelectionRange(r.start, r.end), z.current = !1), B.current = r, P.reset({
1044
1138
  text: e,
1045
1139
  selectionStart: r.start,
1046
1140
  selectionEnd: r.end
1047
1141
  }), L.current = e;
1048
- }), r(() => {
1142
+ }), a(() => {
1049
1143
  let e = M.current;
1050
1144
  if (!e) return;
1051
1145
  let t = () => {
1052
1146
  let t = Number.parseFloat(getComputedStyle(e).lineHeight);
1053
- Pe.value = Number.isFinite(t) && t > 0 ? t : 0, Ne.value = e.clientHeight;
1147
+ Ue.value = Number.isFinite(t) && t > 0 ? t : 0, He.value = e.clientHeight, Ze.value === 0 && (Ze.value = Ne(e));
1054
1148
  }, n = () => {
1055
- Me.value = e.scrollTop, Ne.value = e.clientHeight, A.current && (A.current.scrollTop = e.scrollTop, A.current.scrollLeft = e.scrollLeft), j.current && (j.current.scrollTop = e.scrollTop);
1149
+ Ve.value = e.scrollTop, He.value = e.clientHeight, A.current && (A.current.scrollTop = e.scrollTop, A.current.scrollLeft = e.scrollLeft), j.current && (j.current.scrollTop = e.scrollTop);
1056
1150
  }, r = () => {
1057
1151
  let t = e.value.slice(0, e.selectionStart).split("\n").length - 1;
1058
1152
  k.current?.style.setProperty("--cascivo-editor-caret-line", String(t)), B.current = {
1059
1153
  start: e.selectionStart,
1060
1154
  end: e.selectionEnd
1061
- }, Ie.value = e.selectionStart;
1155
+ }, G.value = e.selectionStart;
1062
1156
  }, i = () => {
1063
1157
  document.activeElement === e && r();
1064
1158
  };
1065
1159
  return t(), r(), e.addEventListener("scroll", n), e.addEventListener("keyup", r), e.addEventListener("click", r), e.addEventListener("input", r), document.addEventListener("selectionchange", i), () => {
1066
1160
  e.removeEventListener("scroll", n), e.removeEventListener("keyup", r), e.removeEventListener("click", r), e.removeEventListener("input", r), document.removeEventListener("selectionchange", i);
1067
1161
  };
1162
+ }), a(() => {
1163
+ let e = G.value, t = O.value;
1164
+ if (!w || w.length === 0 || x || S) {
1165
+ K.value &&= !1;
1166
+ return;
1167
+ }
1168
+ let n = Pe(t, e);
1169
+ if (!n) {
1170
+ Xe.value = -1, K.value &&= !1;
1171
+ return;
1172
+ }
1173
+ if (n.start === Xe.value) {
1174
+ K.value &&= !1;
1175
+ return;
1176
+ }
1177
+ K.value || (q.value = 0), K.value = !0, Je.value = n.start, Ye.value = n.query;
1178
+ }), a(() => {
1179
+ if (!K.value) return;
1180
+ let e = Qe.current, t = M.current;
1181
+ if (!e || !t) return;
1182
+ let n = Je.value, r = e.offsetParent, i, a, o = A.current, s = (y || O.value.includes(" ")) && o ? Me(o, n) : null;
1183
+ if (s && r) {
1184
+ let e = r.getBoundingClientRect();
1185
+ i = s.bottom - e.top, a = s.left - e.left;
1186
+ } else {
1187
+ let e = getComputedStyle(t), r = je(O.value, n, {
1188
+ charWidth: Ze.value,
1189
+ lineHeight: Ue.value,
1190
+ scrollTop: t.scrollTop,
1191
+ scrollLeft: t.scrollLeft,
1192
+ padTop: Number.parseFloat(e.paddingTop) || 0,
1193
+ padLeft: Number.parseFloat(e.paddingLeft) || 0,
1194
+ tabSize: _
1195
+ });
1196
+ i = r.top + Ue.value, a = r.left;
1197
+ }
1198
+ e.style.top = `${i}px`, e.style.left = `${a}px`;
1068
1199
  });
1069
- let Le = re(ee);
1070
- (F.current === null || F.current.grammar !== Le) && (F.current = ne(Le), I.current = void 0);
1071
- let Re = F.current, ze = H.value.split("\n"), J = ze.length, Be = H.value, Y = I.current;
1072
- if (Be !== Y) {
1073
- let e = Y === void 0 ? 0 : (() => {
1074
- let e = Ee(Y, Be);
1075
- return Y.slice(0, e.from).split("\n").length - 1;
1200
+ let tt = re(h);
1201
+ (F.current === null || F.current.grammar !== tt) && (F.current = ne(tt), I.current = void 0);
1202
+ let nt = F.current, rt = H.value.split("\n"), J = rt.length, it = H.value, at = I.current;
1203
+ if (it !== at) {
1204
+ let e = at === void 0 ? 0 : (() => {
1205
+ let e = ke(at, it);
1206
+ return at.slice(0, e.from).split("\n").length - 1;
1076
1207
  })();
1077
- Re.invalidateFrom(e), I.current = Be;
1208
+ nt.invalidateFrom(e), I.current = it;
1078
1209
  }
1079
- let X = Pe.value, Ve = (v ?? J > 1e3) && !_ && X > 0, Z = 0, Q = J;
1080
- if (Ve) {
1081
- Z = Math.max(0, Math.floor(Me.value / X) - 12);
1082
- let e = Math.ceil(Ne.value / X);
1083
- Q = Math.min(J, Z + e + 24);
1210
+ let Y = Ue.value, ot = (b ?? J > 1e3) && !y && Y > 0, X = 0, Z = J;
1211
+ if (ot) {
1212
+ X = Math.max(0, Math.floor(Ve.value / Y) - 12);
1213
+ let e = Math.ceil(He.value / Y);
1214
+ Z = Math.min(J, X + e + 24);
1084
1215
  }
1085
- let He = te(Le, ze, Z, Q, Re), Ue = Z * X, We = (J - Q) * X, $ = U.value ? ge(H.value, Fe.value, { caseSensitive: G.value }) : [];
1086
- q.value >= $.length && (q.value = Math.max(0, $.length - 1));
1087
- let Ge = $.length > 0 ? ve(H.value, $, q.value, {
1088
- match: E.match,
1089
- current: E.matchCurrent
1090
- }) : [], Ke = typeof T == "function" ? T(H.value) : T ?? [], qe = [];
1091
- if (ae) {
1092
- let e = be(H.value, Ie.value);
1093
- e && (qe = xe(H.value, e, E.bracketMatch));
1216
+ let st = te(tt, rt, X, Z, nt), ct = X * Y, lt = (J - Z) * Y, Q = U.value ? ye(H.value, We.value, { caseSensitive: Ke.value }) : [];
1217
+ W.value >= Q.length && (W.value = Math.max(0, Q.length - 1));
1218
+ let ut = Q.length > 0 ? xe(H.value, Q, W.value, {
1219
+ match: T.match,
1220
+ current: T.matchCurrent
1221
+ }) : [], dt = typeof C == "function" ? C(H.value) : C ?? [], ft = [];
1222
+ if (le) {
1223
+ let e = Ce(H.value, G.value);
1224
+ e && (ft = we(H.value, e, T.bracketMatch));
1094
1225
  }
1095
- let Je = [
1096
- ...Ke,
1097
- ...qe,
1098
- ...Ge
1099
- ], Ye = Je.length > 0 ? Je : void 0, Xe = (e) => {
1100
- let t = $[e], n = M.current;
1226
+ let pt = [
1227
+ ...dt,
1228
+ ...ft,
1229
+ ...ut
1230
+ ], mt = pt.length > 0 ? pt : void 0, ht = (e) => {
1231
+ let t = Q[e], n = M.current;
1101
1232
  if (!(!t || !n) && (n.focus(), n.setSelectionRange(t.start, t.end), B.current = {
1102
1233
  start: t.start,
1103
1234
  end: t.end
1104
- }, X > 0)) {
1105
- let { line: e } = _e(n.value, t.start), r = e * X;
1106
- (r < n.scrollTop || r > n.scrollTop + n.clientHeight - X) && (n.scrollTop = Math.max(0, r - n.clientHeight / 2));
1235
+ }, Y > 0)) {
1236
+ let { line: e } = be(n.value, t.start), r = e * Y;
1237
+ (r < n.scrollTop || r > n.scrollTop + n.clientHeight - Y) && (n.scrollTop = Math.max(0, r - n.clientHeight / 2));
1107
1238
  }
1108
- }, Ze = () => {
1109
- $.length !== 0 && (q.value = (q.value + 1) % $.length, Xe(q.value));
1110
- }, Qe = () => {
1111
- $.length !== 0 && (q.value = (q.value - 1 + $.length) % $.length, Xe(q.value));
1112
- }, $e = () => {
1113
- let e = $[q.value], t = M.current;
1114
- !e || !t || y || b || (t.setRangeText(W.value, e.start, e.end, "end"), V(t.value, {
1239
+ }, gt = () => {
1240
+ Q.length !== 0 && (W.value = (W.value + 1) % Q.length, ht(W.value));
1241
+ }, _t = () => {
1242
+ Q.length !== 0 && (W.value = (W.value - 1 + Q.length) % Q.length, ht(W.value));
1243
+ }, vt = () => {
1244
+ let e = Q[W.value], t = M.current;
1245
+ !e || !t || x || S || (t.setRangeText(Ge.value, e.start, e.end, "end"), V(t.value, {
1115
1246
  start: t.selectionStart,
1116
1247
  end: t.selectionEnd
1117
1248
  }, !1));
1118
- }, et = () => {
1119
- if ($.length === 0 || y || b) return;
1120
- let e = ye(H.value, $, W.value), t = M.current;
1249
+ }, yt = () => {
1250
+ if (Q.length === 0 || x || S) return;
1251
+ let e = Se(H.value, Q, Ge.value), t = M.current;
1121
1252
  t && (t.value = e), V(e, {
1122
1253
  start: t?.selectionStart ?? 0,
1123
1254
  end: t?.selectionEnd ?? 0
1124
1255
  }, !1);
1125
- }, tt = (e) => {
1126
- K.value = e, U.value = !0;
1127
- }, nt = () => {
1256
+ }, bt = (e) => {
1257
+ qe.value = e, U.value = !0;
1258
+ }, xt = () => {
1128
1259
  U.value = !1, M.current?.focus();
1129
- };
1130
- c(ue, () => ({
1260
+ }, $ = K.value ? Fe(w ?? [], Ye.value) : [];
1261
+ q.value >= $.length && (q.value = Math.max(0, $.length - 1));
1262
+ let St = $.map((e) => ({
1263
+ id: e.id,
1264
+ label: e.label,
1265
+ ...e.hint !== void 0 && { hint: e.hint }
1266
+ })), { anchorStyle: Ct, floatingStyle: wt } = t({
1267
+ anchorRef: Qe,
1268
+ floatingRef: $e,
1269
+ placement: "bottom-start",
1270
+ enabled: K
1271
+ }), Tt = {
1131
1272
  applyEdit: ({ from: e, to: t }, n) => {
1132
1273
  let r = M.current;
1133
1274
  r && (r.setRangeText(n, e, t, "end"), V(r.value, {
@@ -1143,66 +1284,97 @@ var L = s(function({ value: s, defaultValue: f, onValueChange: p, language: ee =
1143
1284
  } : { ...B.current };
1144
1285
  },
1145
1286
  focus: () => M.current?.focus(),
1146
- undo: Ae,
1147
- redo: je,
1148
- openFind: () => tt(!1)
1149
- }));
1150
- let rt = (e) => {
1151
- let t = e.currentTarget, n = !y && !b, r = {};
1287
+ undo: ze,
1288
+ redo: Be,
1289
+ openFind: () => bt(!1),
1290
+ openCommandMenu: () => {
1291
+ let e = M.current;
1292
+ !e || !w || w.length === 0 || x || S || (e.focus(), e.setRangeText("/", e.selectionStart, e.selectionEnd, "end"), V(e.value, {
1293
+ start: e.selectionStart,
1294
+ end: e.selectionEnd
1295
+ }, !1), G.value = e.selectionStart, B.current = {
1296
+ start: e.selectionStart,
1297
+ end: e.selectionEnd
1298
+ });
1299
+ }
1300
+ };
1301
+ ee(me, () => Tt);
1302
+ let Et = (e) => {
1303
+ let t = $[e], n = M.current;
1304
+ if (!t || !n || x || S) return;
1305
+ let r = Je.value, i = n.selectionStart;
1306
+ n.setRangeText(t.insert ?? "", r, i, "end"), V(n.value, {
1307
+ start: n.selectionStart,
1308
+ end: n.selectionEnd
1309
+ }, !1), G.value = n.selectionStart, B.current = {
1310
+ start: n.selectionStart,
1311
+ end: n.selectionEnd
1312
+ }, K.value = !1, q.value = 0, n.focus(), t.run?.(Tt);
1313
+ }, Dt = (e) => {
1314
+ let t = e.currentTarget, n = !x && !S, r = {};
1152
1315
  if (n) {
1153
- let { indent: e, dedent: t } = Te({
1154
- tabSize: h,
1155
- insertSpaces: g
1316
+ let { indent: e, dedent: t } = Oe({
1317
+ tabSize: _,
1318
+ insertSpaces: v
1156
1319
  });
1157
- r.Tab = e, r["Shift-Tab"] = t, r["Mod-z"] = () => (Ae(), !0);
1158
- let n = () => (je(), !0);
1320
+ r.Tab = e, r["Shift-Tab"] = t, r["Mod-z"] = () => (ze(), !0);
1321
+ let n = () => (Be(), !0);
1159
1322
  r["Mod-Shift-z"] = n, r["Mod-y"] = n;
1160
1323
  }
1161
- r["Mod-f"] = () => (tt(!1), !0), r["Mod-Alt-f"] = () => (tt(!0), !0), r["Mod-s"] = () => {
1162
- let e = de.current;
1324
+ if (r["Mod-f"] = () => (bt(!1), !0), r["Mod-Alt-f"] = () => (bt(!0), !0), r["Mod-s"] = () => {
1325
+ let e = D.current;
1163
1326
  return e ? (e(O.value), !0) : !1;
1164
- }, U.value && (r.Escape = () => (nt(), !0)), we(Ce(r, w), {
1327
+ }, U.value && (r.Escape = () => (xt(), !0)), K.value) {
1328
+ let e = (e) => () => {
1329
+ let t = $.length;
1330
+ return t > 0 && (q.value = (q.value + e + t) % t), !0;
1331
+ };
1332
+ r.ArrowDown = e(1), r.ArrowUp = e(-1);
1333
+ let t = () => ($.length > 0 && Et(q.value), !0);
1334
+ r.Enter = t, r.Tab = t, r.Escape = () => (Xe.value = Je.value, K.value = !1, !0);
1335
+ }
1336
+ De(Ee(r, se), {
1165
1337
  textarea: t,
1166
1338
  event: e,
1167
- setText: Oe
1168
- }) && e.preventDefault(), ce?.(e);
1169
- }, it = {
1170
- "--cascivo-editor-tab-size": h,
1171
- ...ie,
1172
- ...se
1339
+ setText: Le
1340
+ }) && e.preventDefault(), fe?.(e);
1341
+ }, Ot = {
1342
+ "--cascivo-editor-tab-size": _,
1343
+ ...ce,
1344
+ ...de
1173
1345
  };
1174
- return /* @__PURE__ */ d("div", {
1346
+ return /* @__PURE__ */ f("div", {
1175
1347
  ref: k,
1176
- className: e(D.root, oe),
1177
- "data-wrap": _,
1178
- "data-line-numbers": m,
1179
- style: it,
1180
- children: [m && /* @__PURE__ */ u(pe, {
1348
+ className: e(E.root, ue),
1349
+ "data-wrap": y,
1350
+ "data-line-numbers": g,
1351
+ style: Ot,
1352
+ children: [g && /* @__PURE__ */ d(ge, {
1181
1353
  count: J,
1182
- className: D.gutter,
1354
+ className: E.gutter,
1183
1355
  gutterRef: j,
1184
- start: Z,
1185
- end: Q,
1186
- topPad: Ue,
1187
- bottomPad: We,
1356
+ start: X,
1357
+ end: Z,
1358
+ topPad: ct,
1359
+ bottomPad: lt,
1188
1360
  activeLine: !0
1189
- }), /* @__PURE__ */ d("div", {
1190
- className: D.codeArea,
1361
+ }), /* @__PURE__ */ f("div", {
1362
+ className: E.codeArea,
1191
1363
  children: [
1192
- /* @__PURE__ */ d("pre", {
1364
+ /* @__PURE__ */ f("pre", {
1193
1365
  ref: A,
1194
- className: D.pre,
1366
+ className: E.pre,
1195
1367
  "aria-hidden": "true",
1196
1368
  children: [
1197
- /* @__PURE__ */ u("div", { className: D.currentLine }),
1198
- Ue > 0 && /* @__PURE__ */ u("div", { style: { blockSize: Ue } }),
1199
- /* @__PURE__ */ u("code", { children: fe(He, Z, Q, Ye) }),
1200
- We > 0 && /* @__PURE__ */ u("div", { style: { blockSize: We } })
1369
+ /* @__PURE__ */ d("div", { className: E.currentLine }),
1370
+ ct > 0 && /* @__PURE__ */ d("div", { style: { blockSize: ct } }),
1371
+ /* @__PURE__ */ d("code", { children: he(st, X, Z, mt) }),
1372
+ lt > 0 && /* @__PURE__ */ d("div", { style: { blockSize: lt } })
1201
1373
  ]
1202
1374
  }),
1203
- /* @__PURE__ */ u("textarea", {
1375
+ /* @__PURE__ */ d("textarea", {
1204
1376
  ref: M,
1205
- className: D.textarea,
1377
+ className: E.textarea,
1206
1378
  value: O.value,
1207
1379
  onChange: (e) => {
1208
1380
  let t = e.currentTarget, n = t.value, r = Math.abs(n.length - L.current.length) === 1;
@@ -1211,35 +1383,57 @@ var L = s(function({ value: s, defaultValue: f, onValueChange: p, language: ee =
1211
1383
  end: t.selectionEnd
1212
1384
  }, r);
1213
1385
  },
1214
- onKeyDown: rt,
1215
- readOnly: y,
1216
- disabled: b,
1217
- spellCheck: x,
1218
- "aria-label": S ?? o(a.editor.label),
1386
+ onKeyDown: Dt,
1387
+ readOnly: x,
1388
+ disabled: S,
1389
+ spellCheck: ie,
1390
+ "aria-label": ae ?? c(s.editor.label),
1391
+ "aria-expanded": K.value,
1392
+ "aria-controls": K.value ? et : void 0,
1393
+ "aria-activedescendant": K.value ? `${et}-opt-${q.value}` : void 0,
1219
1394
  autoCapitalize: "off",
1220
1395
  autoCorrect: "off",
1221
1396
  autoComplete: "off",
1222
- wrap: _ ? "soft" : "off",
1223
- ...le
1397
+ wrap: y ? "soft" : "off",
1398
+ ...pe
1399
+ }),
1400
+ /* @__PURE__ */ d("div", {
1401
+ ref: Qe,
1402
+ "aria-hidden": "true",
1403
+ style: {
1404
+ position: "absolute",
1405
+ inlineSize: 0,
1406
+ blockSize: 0,
1407
+ ...Ct
1408
+ }
1224
1409
  }),
1225
- U.value && /* @__PURE__ */ u(me, {
1226
- query: Fe.value,
1227
- replaceQuery: W.value,
1228
- replaceMode: K.value,
1229
- caseSensitive: G.value,
1230
- matchCount: $.length,
1231
- currentIndex: $.length > 0 ? q.value : -1,
1410
+ K.value && /* @__PURE__ */ d(Ie, {
1411
+ ref: $e,
1412
+ id: et,
1413
+ items: St,
1414
+ activeIndex: q.value,
1415
+ onSelect: Et,
1416
+ onHover: (e) => q.value = e,
1417
+ style: wt
1418
+ }),
1419
+ U.value && /* @__PURE__ */ d(_e, {
1420
+ query: We.value,
1421
+ replaceQuery: Ge.value,
1422
+ replaceMode: qe.value,
1423
+ caseSensitive: Ke.value,
1424
+ matchCount: Q.length,
1425
+ currentIndex: Q.length > 0 ? W.value : -1,
1232
1426
  onQueryChange: (e) => {
1233
- Fe.value = e, q.value = 0;
1427
+ We.value = e, W.value = 0;
1234
1428
  },
1235
- onReplaceChange: (e) => W.value = e,
1236
- onNext: Ze,
1237
- onPrev: Qe,
1238
- onReplace: $e,
1239
- onReplaceAll: et,
1240
- onToggleCase: () => G.value = !G.value,
1241
- onToggleReplace: () => K.value = !K.value,
1242
- onClose: nt
1429
+ onReplaceChange: (e) => Ge.value = e,
1430
+ onNext: gt,
1431
+ onPrev: _t,
1432
+ onReplace: vt,
1433
+ onReplaceAll: yt,
1434
+ onToggleCase: () => Ke.value = !Ke.value,
1435
+ onToggleReplace: () => qe.value = !qe.value,
1436
+ onClose: xt
1243
1437
  })
1244
1438
  ]
1245
1439
  })]
@@ -1247,32 +1441,32 @@ var L = s(function({ value: s, defaultValue: f, onValueChange: p, language: ee =
1247
1441
  });
1248
1442
  //#endregion
1249
1443
  //#region src/editor/highlight/highlight.tsx
1250
- function R({ value: t, language: n = "plaintext", lineNumbers: r = !1, wrap: a = !1, tabSize: o = 2, label: s, className: c, preRef: l, gutterRef: f, style: p, ...ee }) {
1251
- i();
1444
+ function z({ value: t, language: n = "plaintext", lineNumbers: r = !1, wrap: i = !1, tabSize: a = 2, label: s, className: c, preRef: l, gutterRef: ee, style: u, ...p }) {
1445
+ o();
1252
1446
  let m = re(n), h = t.split("\n"), g = te(m, h, 0, h.length, ne(m)), _ = {
1253
- "--cascivo-editor-tab-size": o,
1254
- ...p
1447
+ "--cascivo-editor-tab-size": a,
1448
+ ...u
1255
1449
  };
1256
- return /* @__PURE__ */ d("div", {
1257
- className: e(E.root, c),
1258
- "data-wrap": a,
1450
+ return /* @__PURE__ */ f("div", {
1451
+ className: e(T.root, c),
1452
+ "data-wrap": i,
1259
1453
  "data-line-numbers": r,
1260
1454
  style: _,
1261
1455
  "aria-label": s,
1262
- ...ee,
1263
- children: [r && /* @__PURE__ */ u(pe, {
1456
+ ...p,
1457
+ children: [r && /* @__PURE__ */ d(ge, {
1264
1458
  count: g.length,
1265
- className: E.gutter,
1266
- gutterRef: f
1267
- }), /* @__PURE__ */ u("pre", {
1459
+ className: T.gutter,
1460
+ gutterRef: ee
1461
+ }), /* @__PURE__ */ d("pre", {
1268
1462
  ref: l,
1269
- className: E.pre,
1270
- children: /* @__PURE__ */ u("code", {
1271
- className: E.code,
1272
- children: fe(g)
1463
+ className: T.pre,
1464
+ children: /* @__PURE__ */ d("code", {
1465
+ className: T.code,
1466
+ children: he(g)
1273
1467
  })
1274
1468
  })]
1275
1469
  });
1276
1470
  }
1277
1471
  //#endregion
1278
- export { L as CodeEditor, R as Highlight, le as bash, ne as createLineStateIndex, b as createRuleGrammar, oe as css, re as getGrammar, se as html, ie as javascript, S as json, y as listGrammars, ce as markdown, x as plaintext, v as registerGrammar, m as tokenize, h as tokenizeDocument, te as tokenizeRange, ae as typescript };
1472
+ export { R as CodeEditor, z as Highlight, fe as bash, ne as createLineStateIndex, S as createRuleGrammar, w as css, re as getGrammar, ue as html, ce as javascript, ae as json, x as listGrammars, de as markdown, ie as plaintext, b as registerGrammar, g as tokenize, _ as tokenizeDocument, te as tokenizeRange, le as typescript };