@markput/react 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.css +1 -1
  2. package/index.js +474 -471
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./index.css";
2
2
  import { createContext as e, memo as t, useCallback as n, useContext as r, useEffect as i, useImperativeHandle as a, useLayoutEffect as o, useMemo as s, useRef as c, useState as l, useSyncExternalStore as u } from "react";
3
3
  import { jsx as d, jsxs as f } from "react/jsx-runtime";
4
- //#region ../../common/core/src/shared/utils/shallow.ts
4
+ //#region ../../core/src/shared/utils/shallow.ts
5
5
  function p(e, t) {
6
6
  if (Object.is(e, t)) return !0;
7
7
  if (typeof e != "object" || !e || typeof t != "object" || !t) return !1;
@@ -11,28 +11,28 @@ function p(e, t) {
11
11
  return !0;
12
12
  }
13
13
  //#endregion
14
- //#region ../../common/core/src/shared/utils/cx.ts
14
+ //#region ../../core/src/shared/utils/cx.ts
15
15
  function m(...e) {
16
16
  return e.filter(Boolean).join(" ") || void 0;
17
17
  }
18
18
  //#endregion
19
- //#region ../../common/core/src/shared/utils/merge.ts
19
+ //#region ../../core/src/shared/utils/merge.ts
20
20
  function h(...e) {
21
21
  let t = Object.assign({}, ...e.filter(Boolean));
22
22
  return Object.keys(t).length > 0 ? t : void 0;
23
23
  }
24
24
  //#endregion
25
- //#region ../../common/core/src/shared/utils/resolveOptionSlot.ts
25
+ //#region ../../core/src/shared/utils/resolveOptionSlot.ts
26
26
  function g(e, t) {
27
27
  return e === void 0 ? t : typeof e == "function" ? e(t) : e;
28
28
  }
29
29
  //#endregion
30
- //#region ../../common/core/src/shared/utils/dataAttributes.ts
30
+ //#region ../../core/src/shared/utils/dataAttributes.ts
31
31
  function ee(e) {
32
32
  return e ? Object.fromEntries(Object.entries(e).map(([e, t]) => e.startsWith("data") && e.length > 4 && e[4] === e[4].toUpperCase() ? [`data-${e.slice(4).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase()}`, t] : [e, t])) : {};
33
33
  }
34
34
  //#endregion
35
- //#region ../../common/core/src/shared/utils/resolveSlot.ts
35
+ //#region ../../core/src/shared/utils/resolveSlot.ts
36
36
  var te = {
37
37
  container: "div",
38
38
  block: "div",
@@ -60,7 +60,7 @@ function re(e, t, n, r, i) {
60
60
  return [c, s];
61
61
  }
62
62
  //#endregion
63
- //#region ../../common/core/src/shared/constants.ts
63
+ //#region ../../core/src/shared/constants.ts
64
64
  var y = {
65
65
  UP: "ArrowUp",
66
66
  DOWN: "ArrowDown",
@@ -93,7 +93,7 @@ var y = {
93
93
  Slot: "slot"
94
94
  };
95
95
  //#endregion
96
- //#region ../../common/core/src/features/parsing/parser/core/MarkupDescriptor.ts
96
+ //#region ../../core/src/features/parsing/parser/core/MarkupDescriptor.ts
97
97
  function ae(e, t) {
98
98
  let { segments: n, gapTypes: r, counts: i, valueGapIndices: a } = se(e);
99
99
  ce(i, e);
@@ -196,7 +196,7 @@ function ue(e, t, n) {
196
196
  ];
197
197
  }
198
198
  //#endregion
199
- //#region ../../common/core/src/features/parsing/parser/core/MarkupRegistry.ts
199
+ //#region ../../core/src/features/parsing/parser/core/MarkupRegistry.ts
200
200
  function de(e, t) {
201
201
  let n = e.get(t);
202
202
  return n || (n = [], e.set(t, n)), n;
@@ -243,7 +243,7 @@ var fe = class {
243
243
  }
244
244
  };
245
245
  //#endregion
246
- //#region ../../common/core/src/features/parsing/parser/utils/getSegmentIndex.ts
246
+ //#region ../../core/src/features/parsing/parser/utils/getSegmentIndex.ts
247
247
  function pe(e, t) {
248
248
  if (!t) return e;
249
249
  let n = 5381;
@@ -251,7 +251,7 @@ function pe(e, t) {
251
251
  return n >>>= 0, e * 1e6 + (n & 1048575);
252
252
  }
253
253
  //#endregion
254
- //#region ../../common/core/src/features/parsing/parser/core/Match.ts
254
+ //#region ../../core/src/features/parsing/parser/core/Match.ts
255
255
  var me = class {
256
256
  gaps = {};
257
257
  captured;
@@ -313,7 +313,7 @@ var me = class {
313
313
  }
314
314
  };
315
315
  //#endregion
316
- //#region ../../common/core/src/features/parsing/parser/core/PatternMatcher.ts
316
+ //#region ../../core/src/features/parsing/parser/core/PatternMatcher.ts
317
317
  function he(e, t) {
318
318
  let n = e.get(t);
319
319
  return n || (n = [], e.set(t, n)), n;
@@ -392,7 +392,7 @@ var ge = class {
392
392
  }
393
393
  }, S = (e) => e.replace(/[.*+?^${}()|[\]\\\\]/g, "\\$&");
394
394
  //#endregion
395
- //#region ../../common/core/src/features/parsing/parser/core/SegmentMatcher.ts
395
+ //#region ../../core/src/features/parsing/parser/core/SegmentMatcher.ts
396
396
  function _e(e, t, n) {
397
397
  let r = S(e), i = S(t);
398
398
  return `${r}([^${S(t + n)}]+?)${i}`;
@@ -476,14 +476,14 @@ var ve = class {
476
476
  for (let e of t) n.some((t) => e.start < t.end && e.end > t.start) || r.push(e);
477
477
  return r.sort((e, t) => e.start - t.start), r;
478
478
  }
479
- }, ye = (e, t = 0, n = e.length) => ({
479
+ }, C = (e, t = 0, n = e.length) => ({
480
480
  type: "text",
481
481
  content: e.substring(t, n),
482
482
  position: {
483
483
  start: t,
484
484
  end: n
485
485
  }
486
- }), be = class {
486
+ }), ye = class {
487
487
  input;
488
488
  options;
489
489
  constructor(e) {
@@ -561,7 +561,7 @@ var ve = class {
561
561
  return e !== void 0 && t !== void 0 ? this.input.substring(e, t) : "";
562
562
  }
563
563
  createTextToken(e, t) {
564
- return ye(this.input, e, t);
564
+ return C(this.input, e, t);
565
565
  }
566
566
  createSlotSourceInfo(e, t) {
567
567
  if (!(!t || e.gaps.slot === void 0)) return {
@@ -576,12 +576,12 @@ var ve = class {
576
576
  }
577
577
  };
578
578
  //#endregion
579
- //#region ../../common/core/src/features/parsing/parser/utils/processTokens.ts
580
- function C(e, t) {
579
+ //#region ../../core/src/features/parsing/parser/utils/processTokens.ts
580
+ function w(e, t) {
581
581
  let n = "";
582
582
  for (let r of e) if (r.type === "text") n += r.content;
583
583
  else if (r.children.length > 0) {
584
- let e = C(r.children, t), i = {
584
+ let e = w(r.children, t), i = {
585
585
  ...r,
586
586
  value: e
587
587
  };
@@ -590,22 +590,22 @@ function C(e, t) {
590
590
  return n;
591
591
  }
592
592
  //#endregion
593
- //#region ../../common/core/src/features/parsing/parser/utils/annotate.ts
594
- function w(e, t) {
593
+ //#region ../../core/src/features/parsing/parser/utils/annotate.ts
594
+ function T(e, t) {
595
595
  let n = e;
596
596
  return t.value !== void 0 && (n = n.replaceAll(b.Value, t.value)), t.meta !== void 0 && (n = n.replaceAll(b.Meta, t.meta)), t.slot !== void 0 && (n = n.replaceAll(b.Slot, t.slot)), n;
597
597
  }
598
598
  //#endregion
599
- //#region ../../common/core/src/features/parsing/parser/utils/toString.ts
600
- function T(e) {
599
+ //#region ../../core/src/features/parsing/parser/utils/toString.ts
600
+ function E(e) {
601
601
  let t = "";
602
602
  for (let n of e) {
603
603
  if (n.type === "text") {
604
604
  t += n.content;
605
605
  continue;
606
606
  }
607
- let { markup: e, hasSlot: r } = n.descriptor, i = r ? n.children.length > 0 ? T(n.children) : n.slot?.content : void 0;
608
- t += w(e, {
607
+ let { markup: e, hasSlot: r } = n.descriptor, i = r ? n.children.length > 0 ? E(n.children) : n.slot?.content : void 0;
608
+ t += T(e, {
609
609
  value: n.value,
610
610
  meta: n.meta,
611
611
  slot: i
@@ -614,34 +614,34 @@ function T(e) {
614
614
  return t;
615
615
  }
616
616
  //#endregion
617
- //#region ../../common/core/src/features/parsing/parser/Parser.ts
618
- var xe = class e {
617
+ //#region ../../core/src/features/parsing/parser/Parser.ts
618
+ var be = class e {
619
619
  registry;
620
620
  segmentMatcher;
621
621
  patternMatcher;
622
622
  treeBuilder;
623
623
  parseOptions;
624
624
  constructor(e, t) {
625
- this.registry = new fe(e), this.segmentMatcher = new ve(this.registry.segments), this.patternMatcher = new ge(this.registry), this.parseOptions = t ?? {}, this.treeBuilder = new be(this.parseOptions);
625
+ this.registry = new fe(e), this.segmentMatcher = new ve(this.registry.segments), this.patternMatcher = new ge(this.registry), this.parseOptions = t ?? {}, this.treeBuilder = new ye(this.parseOptions);
626
626
  }
627
627
  static parse(t, n) {
628
628
  let r = n?.markup;
629
- if (!r || r.length === 0) return [ye(t)];
629
+ if (!r || r.length === 0) return [C(t)];
630
630
  let { markup: i, ...a } = n;
631
631
  return new e(r, a).parse(t);
632
632
  }
633
633
  static stringify(e) {
634
- return T(e);
634
+ return E(e);
635
635
  }
636
636
  parse(e) {
637
637
  let t = this.segmentMatcher.search(e), n = this.patternMatcher.process(t);
638
638
  return this.treeBuilder.build(n, e);
639
639
  }
640
640
  stringify(e) {
641
- return T(e);
641
+ return E(e);
642
642
  }
643
643
  transform(e, t) {
644
- return C(this.parse(e), t);
644
+ return w(this.parse(e), t);
645
645
  }
646
646
  escape(e) {
647
647
  return this.registry.segments.filter((e) => typeof e == "string").toSorted((e, t) => t.length - e.length).reduce((e, t) => e.replaceAll(t, t.replace(/(.)/g, "\\$1")), e);
@@ -651,27 +651,27 @@ var xe = class e {
651
651
  }
652
652
  };
653
653
  //#endregion
654
- //#region ../../common/core/src/features/parsing/parser/utils/denote.ts
655
- function Se(e, t, n) {
656
- return n.length ? C(new xe(n).parse(e), t) : e;
654
+ //#region ../../core/src/features/parsing/parser/utils/denote.ts
655
+ function xe(e, t, n) {
656
+ return n.length ? w(new be(n).parse(e), t) : e;
657
657
  }
658
658
  //#endregion
659
- //#region ../../common/core/src/features/parsing/utils/findToken.ts
660
- function E(e, t, n = 0, r) {
659
+ //#region ../../core/src/features/parsing/utils/findToken.ts
660
+ function D(e, t, n = 0, r) {
661
661
  for (let i of e) {
662
662
  if (i === t) return {
663
663
  depth: n,
664
664
  parent: r
665
665
  };
666
666
  if (i.type === "mark") {
667
- let e = E(i.children, t, n + 1, i);
667
+ let e = D(i.children, t, n + 1, i);
668
668
  if (e) return e;
669
669
  }
670
670
  }
671
671
  }
672
672
  //#endregion
673
- //#region ../../common/core/src/features/parsing/preparsing/utils/findGap.ts
674
- function Ce(e = "", t = "") {
673
+ //#region ../../core/src/features/parsing/preparsing/utils/findGap.ts
674
+ function Se(e = "", t = "") {
675
675
  if (e === t) return {};
676
676
  let n;
677
677
  for (let r = 0; r < e.length; r++) if (e[r] !== t[r]) {
@@ -689,8 +689,8 @@ function Ce(e = "", t = "") {
689
689
  };
690
690
  }
691
691
  //#endregion
692
- //#region ../../common/core/src/features/parsing/preparsing/utils/getClosestIndexes.ts
693
- function we(e, t) {
692
+ //#region ../../core/src/features/parsing/preparsing/utils/getClosestIndexes.ts
693
+ function Ce(e, t) {
694
694
  let n = -1, r = e.length;
695
695
  for (; r - n > 1;) {
696
696
  let i = Math.round((n + r) / 2);
@@ -699,48 +699,48 @@ function we(e, t) {
699
699
  return e[n] == t && (r = n), [n, r].filter((t) => e[t] !== void 0);
700
700
  }
701
701
  //#endregion
702
- //#region ../../common/core/src/features/parsing/utils/valueParser.ts
703
- function Te(e) {
702
+ //#region ../../core/src/features/parsing/utils/valueParser.ts
703
+ function we(e) {
704
704
  let { focus: t } = e.nodes, n = e.state.parser.get(), r = e.state.tokens.get();
705
705
  if (!n) return r;
706
706
  let i = n.parse(t.content);
707
707
  return i.length === 1 ? r : r.toSpliced(t.index, 1, ...i);
708
708
  }
709
- function Ee(e) {
710
- let t = e.state.value.get(), n = De(e), r = Ce(e.state.previousValue.get(), t);
709
+ function Te(e) {
710
+ let t = e.state.value.get(), n = Ee(e), r = Se(e.state.previousValue.get(), t);
711
711
  if (!r.left && !r.right) return e.state.previousValue.set(t), e.state.tokens.get();
712
712
  e.state.previousValue.set(t);
713
713
  let i = e.state.tokens.get();
714
714
  if (r.left !== void 0 && n.includes(r.left) && r.right !== void 0 && Math.abs(r.left - r.right) > 1) {
715
- let t = n.indexOf(r.left), a = D(e, t - 1, t);
715
+ let t = n.indexOf(r.left), a = O(e, t - 1, t);
716
716
  return i.toSpliced(t - 1, 2, ...a);
717
717
  }
718
718
  if (r.left !== void 0) {
719
- let [t] = we(n, r.left), a = D(e, t);
719
+ let [t] = Ce(n, r.left), a = O(e, t);
720
720
  return a.length === 1 ? i : i.toSpliced(t, 1, ...a);
721
721
  }
722
722
  if (r.right !== void 0) {
723
- let [t] = we(n, r.right), a = D(e, t);
723
+ let [t] = Ce(n, r.right), a = O(e, t);
724
724
  return a.length === 1 ? i : i.toSpliced(t, 1, ...a);
725
725
  }
726
- return O(e, t ?? "");
726
+ return k(e, t ?? "");
727
727
  }
728
- function D(e, ...t) {
728
+ function O(e, ...t) {
729
729
  let n = "", r = e.state.tokens.get();
730
730
  for (let e of t) {
731
731
  let t = r[e];
732
732
  n += t.content;
733
733
  }
734
- return O(e, n);
734
+ return k(e, n);
735
735
  }
736
- function De(e) {
736
+ function Ee(e) {
737
737
  let t = 0;
738
738
  return e.state.tokens.get().map((e) => {
739
739
  let n = e.content.length;
740
740
  return t += n, t - n;
741
741
  });
742
742
  }
743
- function O(e, t) {
743
+ function k(e, t) {
744
744
  let n = e.state.parser.get();
745
745
  return n ? n.parse(t) : [{
746
746
  type: "text",
@@ -752,13 +752,13 @@ function O(e, t) {
752
752
  }];
753
753
  }
754
754
  //#endregion
755
- //#region ../../common/core/src/shared/classes/Reactive.ts
756
- var Oe = (e, t) => e === t, k = class e {
755
+ //#region ../../core/src/shared/classes/Reactive.ts
756
+ var De = (e, t) => e === t, A = class e {
757
757
  #e;
758
758
  #t = /* @__PURE__ */ new Set();
759
759
  #n;
760
760
  constructor(e, t) {
761
- this.#e = e, this.#n = t?.equals ?? Oe;
761
+ this.#e = e, this.#n = t?.equals ?? De;
762
762
  }
763
763
  static event() {
764
764
  return new e(void 0, { equals: !1 });
@@ -789,16 +789,16 @@ var Oe = (e, t) => e === t, k = class e {
789
789
  }
790
790
  };
791
791
  //#endregion
792
- //#region ../../common/core/src/shared/classes/defineState.ts
793
- function ke(e, t) {
792
+ //#region ../../core/src/shared/classes/defineState.ts
793
+ function Oe(e, t) {
794
794
  let n = {};
795
795
  return n.get = () => e.get(), n.set = (t) => e.set(t), n.on = (t) => e.on(t), n.use = t(n), n;
796
796
  }
797
- function Ae(e, t, n) {
797
+ function ke(e, t, n) {
798
798
  let r = /* @__PURE__ */ new Map();
799
799
  for (let t in e) {
800
800
  let i = n?.equals?.[t];
801
- r.set(t, new k(e[t], i == null ? void 0 : { equals: i }));
801
+ r.set(t, new A(e[t], i == null ? void 0 : { equals: i }));
802
802
  }
803
803
  return new Proxy(e, { get(e, n) {
804
804
  if (n === "set") return (e) => {
@@ -810,47 +810,47 @@ function Ae(e, t, n) {
810
810
  for (let e of t) e.notify();
811
811
  };
812
812
  let i = r.get(n);
813
- if (i) return ke(i, t);
813
+ if (i) return Oe(i, t);
814
814
  } });
815
815
  }
816
816
  //#endregion
817
- //#region ../../common/core/src/shared/classes/defineEvents.ts
818
- function je(e) {
817
+ //#region ../../core/src/shared/classes/defineEvents.ts
818
+ function Ae(e) {
819
819
  return Object.assign((t) => {
820
820
  e.emit(t);
821
821
  }, { on: (t) => e.on(t) });
822
822
  }
823
- function Me(e) {
823
+ function je(e) {
824
824
  let t = e ? Object.keys(e) : [], n = /* @__PURE__ */ new Map();
825
- for (let e of t) n.set(e, k.event());
825
+ for (let e of t) n.set(e, A.event());
826
826
  return new Proxy({}, { get(e, t) {
827
827
  let r = n.get(t);
828
- return r || (r = k.event(), n.set(t, r)), je(r);
828
+ return r || (r = A.event(), n.set(t, r)), Ae(r);
829
829
  } });
830
830
  }
831
831
  //#endregion
832
- //#region ../../common/core/src/features/drag/eventHandlers.ts
833
- function Ne(e, t) {
832
+ //#region ../../core/src/features/drag/eventHandlers.ts
833
+ function Me(e, t) {
834
834
  return e < t.top + t.height / 2 ? "before" : "after";
835
835
  }
836
- function Pe(e) {
836
+ function Ne(e) {
837
837
  let t = parseInt(e.getData("text/plain"), 10);
838
838
  return isNaN(t) ? null : t;
839
839
  }
840
- function Fe(e, t) {
840
+ function Pe(e, t) {
841
841
  return t === "before" ? e : e + 1;
842
842
  }
843
843
  //#endregion
844
- //#region ../../common/core/src/shared/utils/menuUtils.ts
845
- function Ie(e, t) {
844
+ //#region ../../core/src/shared/utils/menuUtils.ts
845
+ function Fe(e, t) {
846
846
  return !!t && !t.contains(e instanceof Node ? e : null);
847
847
  }
848
- function Le(e) {
848
+ function Ie(e) {
849
849
  return e.key === "Escape";
850
850
  }
851
851
  //#endregion
852
- //#region ../../common/core/src/shared/classes/BlockStore.ts
853
- var Re = class {
852
+ //#region ../../core/src/shared/classes/BlockStore.ts
853
+ var Le = class {
854
854
  refs = { container: null };
855
855
  state;
856
856
  #e = 0;
@@ -859,7 +859,7 @@ var Re = class {
859
859
  #r;
860
860
  #i;
861
861
  constructor(e) {
862
- this.state = Ae({
862
+ this.state = ke({
863
863
  isHovered: !1,
864
864
  isDragging: !1,
865
865
  dropPosition: null,
@@ -873,16 +873,16 @@ var Re = class {
873
873
  attachContainer(e, t, n) {
874
874
  if (this.#e = t, this.#t = n, e === this.refs.container || (this.#n?.(), this.refs.container = e, !e)) return;
875
875
  let r = () => this.state.isHovered.set(!0), i = () => this.state.isHovered.set(!1), a = (t) => {
876
- t.dataTransfer && (t.preventDefault(), t.dataTransfer.dropEffect = "move", this.state.dropPosition.set(Ne(t.clientY, e.getBoundingClientRect())));
876
+ t.dataTransfer && (t.preventDefault(), t.dataTransfer.dropEffect = "move", this.state.dropPosition.set(Me(t.clientY, e.getBoundingClientRect())));
877
877
  }, o = (e) => {
878
878
  let t = e.currentTarget;
879
879
  t instanceof Node && t.contains(e.relatedTarget instanceof Node ? e.relatedTarget : null) || this.state.dropPosition.set(null);
880
880
  }, s = (e) => {
881
881
  if (!e.dataTransfer) return;
882
882
  e.preventDefault();
883
- let t = Pe(e.dataTransfer);
883
+ let t = Ne(e.dataTransfer);
884
884
  if (t === null) return;
885
- let r = Fe(this.#e, this.state.dropPosition.get() ?? "after");
885
+ let r = Pe(this.#e, this.state.dropPosition.get() ?? "after");
886
886
  this.state.dropPosition.set(null), n.reorder(t, r);
887
887
  };
888
888
  e.addEventListener("mouseenter", r), e.addEventListener("mouseleave", i), e.addEventListener("dragover", a), e.addEventListener("dragleave", o), e.addEventListener("drop", s), this.#n = () => {
@@ -910,9 +910,9 @@ var Re = class {
910
910
  attachMenu(e) {
911
911
  if (this.#i?.(), !e) return;
912
912
  let t = (t) => {
913
- Ie(t.target, e) && this.closeMenu();
913
+ Fe(t.target, e) && this.closeMenu();
914
914
  }, n = (e) => {
915
- Le(e) && this.closeMenu();
915
+ Ie(e) && this.closeMenu();
916
916
  };
917
917
  document.addEventListener("mousedown", t), document.addEventListener("keydown", n), this.#i = () => {
918
918
  document.removeEventListener("mousedown", t), document.removeEventListener("keydown", n);
@@ -928,7 +928,7 @@ var Re = class {
928
928
  duplicateBlock = () => {
929
929
  this.#t && (this.#t.duplicate(this.#e), this.closeMenu());
930
930
  };
931
- }, ze = class {
931
+ }, Re = class {
932
932
  #e = /* @__PURE__ */ new WeakMap();
933
933
  #t;
934
934
  constructor(e) {
@@ -936,9 +936,9 @@ var Re = class {
936
936
  }
937
937
  get(e) {
938
938
  let t = this.#e.get(e);
939
- return t || (t = new Re(this.#t), this.#e.set(e, t)), t;
939
+ return t || (t = new Le(this.#t), this.#e.set(e, t)), t;
940
940
  }
941
- }, Be = class {
941
+ }, ze = class {
942
942
  #e = 1;
943
943
  #t = /* @__PURE__ */ new WeakMap();
944
944
  get(e) {
@@ -946,39 +946,39 @@ var Re = class {
946
946
  }
947
947
  };
948
948
  //#endregion
949
- //#region ../../common/core/src/shared/checkers/domGuards.ts
950
- function A(e) {
949
+ //#region ../../core/src/shared/checkers/domGuards.ts
950
+ function j(e) {
951
951
  return typeof HTMLElement < "u" && e instanceof HTMLElement;
952
952
  }
953
- function j(e) {
953
+ function M(e) {
954
954
  return e instanceof Text;
955
955
  }
956
- function M(e, t) {
956
+ function N(e, t) {
957
957
  let n = e?.children[t];
958
958
  return n instanceof HTMLElement ? n : void 0;
959
959
  }
960
- function N(e) {
960
+ function P(e) {
961
961
  return e ? Array.from(e.children).filter((e) => e instanceof HTMLElement) : [];
962
962
  }
963
- function Ve(e) {
963
+ function Be(e) {
964
964
  let t = e?.firstElementChild;
965
965
  return t instanceof HTMLElement ? t : null;
966
966
  }
967
- function He(e) {
967
+ function Ve(e) {
968
968
  let t = e?.lastElementChild;
969
969
  return t instanceof HTMLElement ? t : null;
970
970
  }
971
- function Ue(e) {
971
+ function He(e) {
972
972
  let { target: t } = e;
973
973
  return t instanceof Node ? t : null;
974
974
  }
975
- function P(e) {
975
+ function F(e) {
976
976
  let t = e.nextNode();
977
977
  return t?.nodeType === 3 ? t : null;
978
978
  }
979
979
  //#endregion
980
- //#region ../../common/core/src/features/caret/Caret.ts
981
- var F = class {
980
+ //#region ../../core/src/features/caret/Caret.ts
981
+ var I = class {
982
982
  static get isSelectedPosition() {
983
983
  let e = window.getSelection();
984
984
  if (e) return e.isCollapsed;
@@ -1048,11 +1048,11 @@ var F = class {
1048
1048
  static setIndex(e, t) {
1049
1049
  let n = window.getSelection();
1050
1050
  if (!n) return;
1051
- let r = document.createTreeWalker(e, 4), i = P(r);
1051
+ let r = document.createTreeWalker(e, 4), i = F(r);
1052
1052
  if (!i) return;
1053
1053
  let a = isFinite(t) ? Math.max(0, t) : Infinity;
1054
1054
  for (;;) {
1055
- let e = P(r);
1055
+ let e = F(r);
1056
1056
  if (!e || a <= i.length) {
1057
1057
  let e = isFinite(a) ? Math.min(a, i.length) : i.length, t = document.createRange();
1058
1058
  t.setStart(i, e), t.collapse(!0), n.removeAllRanges(), n.addRange(t);
@@ -1083,16 +1083,16 @@ var F = class {
1083
1083
  let n = window.getSelection()?.getRangeAt(0);
1084
1084
  n?.setStart(n.endContainer, t), n?.setEnd(n.endContainer, t);
1085
1085
  }
1086
- }, We = /* @__PURE__ */ new RegExp(/^\w*/), Ge = class e {
1086
+ }, Ue = /* @__PURE__ */ new RegExp(/^\w*/), We = class e {
1087
1087
  span;
1088
1088
  node;
1089
1089
  dividedText;
1090
1090
  constructor() {
1091
- let e = F.getCurrentPosition();
1092
- this.node = F.getSelectedNode(), this.span = F.getFocusedSpan(), this.dividedText = this.getDividedTextBy(e);
1091
+ let e = I.getCurrentPosition();
1092
+ this.node = I.getSelectedNode(), this.span = I.getFocusedSpan(), this.dividedText = this.getDividedTextBy(e);
1093
1093
  }
1094
1094
  static find(t, n) {
1095
- if (t && F.isSelectedPosition) try {
1095
+ if (t && I.isSelectedPosition) try {
1096
1096
  return new e().find(t, n);
1097
1097
  } catch {
1098
1098
  return;
@@ -1129,7 +1129,7 @@ var F = class {
1129
1129
  }
1130
1130
  matchRightPart() {
1131
1131
  let { right: e } = this.dividedText;
1132
- return { word: e.match(We)?.[0] };
1132
+ return { word: e.match(Ue)?.[0] };
1133
1133
  }
1134
1134
  matchLeftPart(e) {
1135
1135
  let t = this.makeTriggerRegex(e), { left: n } = this.dividedText, r = n.match(t);
@@ -1145,14 +1145,14 @@ var F = class {
1145
1145
  let t = S(e) + "(\\w*)$";
1146
1146
  return new RegExp(t);
1147
1147
  }
1148
- }, Ke = class e {
1148
+ }, Ge = class e {
1149
1149
  #e;
1150
1150
  #t;
1151
1151
  get target() {
1152
1152
  return this.#e;
1153
1153
  }
1154
1154
  set target(e) {
1155
- this.#e = A(e) ? e : void 0;
1155
+ this.#e = j(e) ? e : void 0;
1156
1156
  }
1157
1157
  get next() {
1158
1158
  return new e(this.target?.nextSibling, this.#t);
@@ -1170,19 +1170,19 @@ var F = class {
1170
1170
  return this.target?.isContentEditable ?? !1;
1171
1171
  }
1172
1172
  get isCaretAtBeginning() {
1173
- if (this.target) return F.getCaretIndex(this.target) === 0;
1173
+ if (this.target) return I.getCaretIndex(this.target) === 0;
1174
1174
  }
1175
1175
  get isCaretAtEnd() {
1176
- if (this.target) return F.getCaretIndex(this.target) === this.target.textContent.length;
1176
+ if (this.target) return I.getCaretIndex(this.target) === this.target.textContent.length;
1177
1177
  }
1178
1178
  get index() {
1179
1179
  return this.target?.parentElement ? [...this.target.parentElement.children].indexOf(this.target) : -1;
1180
1180
  }
1181
1181
  get caret() {
1182
- return this.target ? F.getCaretIndex(this.target) : -1;
1182
+ return this.target ? I.getCaretIndex(this.target) : -1;
1183
1183
  }
1184
1184
  set caret(e) {
1185
- this.target && F.trySetIndex(this.target, e);
1185
+ this.target && I.trySetIndex(this.target, e);
1186
1186
  }
1187
1187
  get length() {
1188
1188
  return this.target?.textContent.length ?? -1;
@@ -1194,10 +1194,10 @@ var F = class {
1194
1194
  this.target && (this.target.textContent = e ?? "");
1195
1195
  }
1196
1196
  get head() {
1197
- return Ve(this.#t.refs.container ?? void 0);
1197
+ return Be(this.#t.refs.container ?? void 0);
1198
1198
  }
1199
1199
  get tail() {
1200
- return He(this.#t.refs.container ?? void 0);
1200
+ return Ve(this.#t.refs.container ?? void 0);
1201
1201
  }
1202
1202
  get isFocused() {
1203
1203
  return this.target === document.activeElement;
@@ -1206,7 +1206,7 @@ var F = class {
1206
1206
  this.target = e, this.#t = t;
1207
1207
  }
1208
1208
  setCaretToEnd() {
1209
- F.setCaretToEnd(this.target);
1209
+ I.setCaretToEnd(this.target);
1210
1210
  }
1211
1211
  focus() {
1212
1212
  this.target?.focus();
@@ -1216,49 +1216,49 @@ var F = class {
1216
1216
  }
1217
1217
  };
1218
1218
  //#endregion
1219
- //#region ../../common/core/src/features/drag/operations.ts
1220
- function qe(e, t, n) {
1219
+ //#region ../../core/src/features/drag/operations.ts
1220
+ function Ke(e, t, n) {
1221
1221
  return e.substring(t.position.end, n.position.start);
1222
1222
  }
1223
- function I(e) {
1223
+ function L(e) {
1224
1224
  return e.type === "mark" && e.descriptor.hasSlot && e.descriptor.segments.length === 1;
1225
1225
  }
1226
- function L(e, t) {
1227
- return !!(e.type === "text" && t.type === "text" && t.position.start > e.position.end || I(e) && I(t) && e.descriptor === t.descriptor);
1226
+ function R(e, t) {
1227
+ return !!(e.type === "text" && t.type === "text" && t.position.start > e.position.end || L(e) && L(t) && e.descriptor === t.descriptor);
1228
1228
  }
1229
- function Je(e, t, n, r) {
1229
+ function qe(e, t, n, r) {
1230
1230
  if (t.length === 0) return e + r;
1231
1231
  if (e === "" || t.length === 1 && t[0].type === "text" && t[0].content === "") return r + r;
1232
1232
  if (n >= t.length - 1) return e + r;
1233
1233
  let i = t[n + 1].position.start;
1234
1234
  return e.slice(0, i) + r + e.slice(i);
1235
1235
  }
1236
- function Ye(e, t, n) {
1236
+ function Je(e, t, n) {
1237
1237
  return t.length <= 1 ? "" : n >= t.length - 1 ? e.slice(0, t[n - 1].position.end) : e.slice(0, t[n].position.start) + e.slice(t[n + 1].position.start);
1238
1238
  }
1239
- function Xe(e, t, n) {
1239
+ function Ye(e, t, n) {
1240
1240
  let r = t[n], i = e.substring(r.position.start, r.position.end);
1241
1241
  if (n >= t.length - 1) return e + i;
1242
- let a = t[n + 1], o = qe(e, r, a);
1242
+ let a = t[n + 1], o = Ke(e, r, a);
1243
1243
  return e.slice(0, a.position.start) + i + o + e.slice(a.position.start);
1244
1244
  }
1245
- function R(e, t) {
1245
+ function z(e, t) {
1246
1246
  if (t <= 0 || t >= e.length) return 0;
1247
1247
  let n = e[t - 1];
1248
- return I(n) && n.slot ? n.slot.end : n.position.end;
1248
+ return L(n) && n.slot ? n.slot.end : n.position.end;
1249
1249
  }
1250
- function z(e, t, n) {
1250
+ function B(e, t, n) {
1251
1251
  if (n <= 0 || n >= t.length) return e;
1252
1252
  let r = t[n - 1], i = t[n];
1253
- if (I(r) && I(i)) {
1253
+ if (L(r) && L(i)) {
1254
1254
  let t = r.slot ? r.slot.end : r.position.end;
1255
1255
  return e.slice(0, t) + e.slice(i.position.start);
1256
1256
  }
1257
1257
  return e.slice(0, r.position.end) + e.slice(i.position.start);
1258
1258
  }
1259
- function Ze(e, t, n, r) {
1259
+ function Xe(e, t, n, r) {
1260
1260
  if (n === r || n === r - 1 || t.length < 2 || n < 0 || n >= t.length || r < 0 || r > t.length) return e;
1261
- let i = t.map((t) => e.substring(t.position.start, t.position.end)), a = t.slice(0, -1).map((n, r) => qe(e, n, t[r + 1])), [o] = i.splice(n, 1), s = n < a.length ? n : n - 1;
1261
+ let i = t.map((t) => e.substring(t.position.start, t.position.end)), a = t.slice(0, -1).map((n, r) => Ke(e, n, t[r + 1])), [o] = i.splice(n, 1), s = n < a.length ? n : n - 1;
1262
1262
  a.splice(s, 1);
1263
1263
  let c = r > n ? r - 1 : r;
1264
1264
  i.splice(c, 0, o), c < i.length - 1 && a.splice(c, 0, "");
@@ -1267,15 +1267,15 @@ function Ze(e, t, n, r) {
1267
1267
  return l.join("");
1268
1268
  }
1269
1269
  //#endregion
1270
- //#region ../../common/core/src/features/drag/tokens.ts
1271
- var Qe = {
1270
+ //#region ../../core/src/features/drag/tokens.ts
1271
+ var Ze = {
1272
1272
  type: "text",
1273
1273
  content: "",
1274
1274
  position: {
1275
1275
  start: 0,
1276
1276
  end: 0
1277
1277
  }
1278
- }, $e = class {
1278
+ }, Qe = class {
1279
1279
  constructor(e) {
1280
1280
  this.store = e;
1281
1281
  }
@@ -1284,33 +1284,33 @@ var Qe = {
1284
1284
  reorder(e, t) {
1285
1285
  let n = this.store.state.value.get();
1286
1286
  if (n == null || !this.store.state.onChange.get()) return;
1287
- let r = Ze(n, this.store.state.tokens.get(), e, t);
1287
+ let r = Xe(n, this.store.state.tokens.get(), e, t);
1288
1288
  r !== n && this.store.applyValue(r);
1289
1289
  }
1290
1290
  add(e) {
1291
1291
  let t = this.store.state.value.get();
1292
1292
  if (t == null || !this.store.state.onChange.get()) return;
1293
- let n = this.store.state.tokens.get(), r = n.length > 0 ? n : [Qe], i = this.#e();
1294
- this.store.applyValue(Je(t, r, e, i)), queueMicrotask(() => {
1293
+ let n = this.store.state.tokens.get(), r = n.length > 0 ? n : [Ze], i = this.#e();
1294
+ this.store.applyValue(qe(t, r, e, i)), queueMicrotask(() => {
1295
1295
  let t = this.store.refs.container;
1296
- t && M(t, e + 1)?.focus();
1296
+ t && N(t, e + 1)?.focus();
1297
1297
  });
1298
1298
  }
1299
1299
  delete(e) {
1300
1300
  let t = this.store.state.value.get();
1301
1301
  if (t == null || !this.store.state.onChange.get()) return;
1302
1302
  let n = this.store.state.tokens.get();
1303
- this.store.applyValue(Ye(t, n, e));
1303
+ this.store.applyValue(Je(t, n, e));
1304
1304
  }
1305
1305
  duplicate(e) {
1306
1306
  let t = this.store.state.value.get();
1307
1307
  if (t == null || !this.store.state.onChange.get()) return;
1308
1308
  let n = this.store.state.tokens.get();
1309
- this.store.applyValue(Xe(t, n, e));
1309
+ this.store.applyValue(Ye(t, n, e));
1310
1310
  }
1311
1311
  #e() {
1312
1312
  let e = this.store.state.options.get()?.[0];
1313
- return e?.markup ? w(e.markup, {
1313
+ return e?.markup ? T(e.markup, {
1314
1314
  value: "",
1315
1315
  slot: "",
1316
1316
  meta: ""
@@ -1318,25 +1318,28 @@ var Qe = {
1318
1318
  }
1319
1319
  };
1320
1320
  //#endregion
1321
- //#region ../../common/core/src/features/drag/config.ts
1322
- function et(e) {
1321
+ //#region ../../core/src/features/drag/config.ts
1322
+ function $e(e) {
1323
1323
  return typeof e == "object" && !!e.alwaysShowHandle;
1324
1324
  }
1325
1325
  //#endregion
1326
- //#region ../../common/core/src/features/editable/ContentEditableController.ts
1327
- function tt(e) {
1326
+ //#region ../../core/src/features/editable/ContentEditableController.ts
1327
+ function et(e) {
1328
1328
  return e.tagName === "SPAN" && (e.attributes.length === 0 || e.attributes.length === 1 && e.hasAttribute("contenteditable"));
1329
1329
  }
1330
- var nt = class {
1330
+ var tt = class {
1331
1331
  #e;
1332
+ #t;
1332
1333
  constructor(e) {
1333
1334
  this.store = e;
1334
1335
  }
1335
1336
  enable() {
1336
- this.#e || (this.#e = this.store.state.readOnly.on(() => this.sync()), this.sync());
1337
+ this.#e || (this.#e = this.store.state.readOnly.on(() => this.sync()), this.#t = this.store.state.selecting.on((e) => {
1338
+ e === void 0 && this.sync();
1339
+ }), this.sync());
1337
1340
  }
1338
1341
  disable() {
1339
- this.#e?.(), this.#e = void 0;
1342
+ this.#e?.(), this.#e = void 0, this.#t?.(), this.#t = void 0;
1340
1343
  }
1341
1344
  sync() {
1342
1345
  let e = this.store.refs.container;
@@ -1345,67 +1348,67 @@ var nt = class {
1345
1348
  if (i) {
1346
1349
  let i = this.store.state.tokens.get();
1347
1350
  for (let a = 0; a < i.length && a < r.length; a++) {
1348
- let r = M(e, a);
1351
+ let r = N(e, a);
1349
1352
  r && (i[a].type === "mark" ? t || (r.tabIndex = 0) : r.contentEditable = n);
1350
1353
  }
1351
1354
  } else for (let t = 0; t < r.length; t += 2) {
1352
- let r = M(e, t);
1355
+ let r = N(e, t);
1353
1356
  r && (r.contentEditable = n);
1354
1357
  }
1355
1358
  let a = this.store.state.tokens.get();
1356
- i ? this.#r(a, e, t) : this.#t(a, e);
1359
+ i ? this.#i(a, e, t) : this.#n(a, e);
1357
1360
  }
1358
- #t(e, t) {
1361
+ #n(e, t) {
1359
1362
  for (let n = 0; n < e.length; n++) {
1360
- let r = e[n], i = M(t, n);
1361
- i && (r.type === "text" ? i.textContent !== r.content && (i.textContent = r.content) : r.children.length > 0 && this.#n(r.children, i));
1363
+ let r = e[n], i = N(t, n);
1364
+ i && (r.type === "text" ? i.textContent !== r.content && (i.textContent = r.content) : r.children.length > 0 && this.#r(r.children, i));
1362
1365
  }
1363
1366
  }
1364
- #n(e, t, n) {
1367
+ #r(e, t, n) {
1365
1368
  let r = t.children, i = 0;
1366
1369
  for (let a of e) if (a.type === "text") {
1367
1370
  for (; i < r.length;) {
1368
- let e = M(t, i);
1369
- if (e && tt(e)) break;
1371
+ let e = N(t, i);
1372
+ if (e && et(e)) break;
1370
1373
  i++;
1371
1374
  }
1372
- let e = M(t, i);
1375
+ let e = N(t, i);
1373
1376
  e && (e.textContent !== a.content && (e.textContent = a.content), n !== void 0 && (e.contentEditable = n), i++);
1374
1377
  } else if (a.children.length > 0) {
1375
1378
  for (; i < r.length;) {
1376
- let e = M(t, i);
1377
- if (e && !tt(e)) break;
1379
+ let e = N(t, i);
1380
+ if (e && !et(e)) break;
1378
1381
  i++;
1379
1382
  }
1380
- let e = M(t, i);
1381
- e && (this.#n(a.children, e, n), i++);
1383
+ let e = N(t, i);
1384
+ e && (this.#r(a.children, e, n), i++);
1382
1385
  }
1383
1386
  }
1384
- #r(e, t, n) {
1387
+ #i(e, t, n) {
1385
1388
  let r = n ? "false" : "true";
1386
1389
  for (let i = 0; i < e.length; i++) {
1387
- let a = e[i], o = M(t, i);
1390
+ let a = e[i], o = N(t, i);
1388
1391
  if (!o) continue;
1389
1392
  if (a.type === "mark") {
1390
1393
  if (a.children.length > 0) {
1391
- let e = o.hasAttribute("data-testid") ? M(o, n ? 0 : 1) : o;
1392
- e && this.#n(a.children, e, r);
1394
+ let e = o.hasAttribute("data-testid") ? N(o, n ? 0 : 1) : o;
1395
+ e && this.#r(a.children, e, r);
1393
1396
  }
1394
1397
  continue;
1395
1398
  }
1396
- let s = M(o, n ? 0 : 1);
1399
+ let s = N(o, n ? 0 : 1);
1397
1400
  s && s.textContent !== a.content && (s.textContent = a.content);
1398
1401
  }
1399
1402
  }
1400
1403
  };
1401
1404
  //#endregion
1402
- //#region ../../common/core/src/features/editing/utils/createNewSpan.ts
1403
- function rt(e, t, n, r) {
1405
+ //#region ../../core/src/features/editing/utils/createNewSpan.ts
1406
+ function nt(e, t, n, r) {
1404
1407
  return e.slice(0, n) + t + e.slice(n + r.length);
1405
1408
  }
1406
1409
  //#endregion
1407
- //#region ../../common/core/src/features/editing/utils/deleteMark.ts
1408
- function B(e, t) {
1410
+ //#region ../../core/src/features/editing/utils/deleteMark.ts
1411
+ function V(e, t) {
1409
1412
  let n = {
1410
1413
  prev: 2,
1411
1414
  self: 1,
@@ -1425,11 +1428,11 @@ function B(e, t) {
1425
1428
  t.state.recovery.set({
1426
1429
  anchor: u.prev,
1427
1430
  caret: d
1428
- }), t.state.onChange.get()?.(T(t.state.tokens.get()));
1431
+ }), t.state.onChange.get()?.(E(t.state.tokens.get()));
1429
1432
  }
1430
1433
  //#endregion
1431
- //#region ../../common/core/src/features/events/SystemListenerController.ts
1432
- var it = class {
1434
+ //#region ../../core/src/features/events/SystemListenerController.ts
1435
+ var rt = class {
1433
1436
  #e;
1434
1437
  #t;
1435
1438
  #n;
@@ -1440,22 +1443,22 @@ var it = class {
1440
1443
  this.#e || (this.#e = this.store.events.change.on(() => {
1441
1444
  let e = this.store.state.onChange.get(), { focus: t } = this.store.nodes;
1442
1445
  if (!t.target || !t.target.isContentEditable) {
1443
- let t = this.store.state.tokens.get(), n = T(t);
1446
+ let t = this.store.state.tokens.get(), n = E(t);
1444
1447
  e?.(n), this.store.state.previousValue.set(n), this.store.state.tokens.set([...t]);
1445
1448
  return;
1446
1449
  }
1447
1450
  let n = this.store.state.tokens.get(), r = n[t.index];
1448
- r.type === "text" ? r.content = t.content : r.value = t.content, e?.(T(n)), this.store.events.parse();
1451
+ r.type === "text" ? r.content = t.content : r.value = t.content, e?.(E(n)), this.store.events.parse();
1449
1452
  }), this.#t = this.store.events.delete.on((e) => {
1450
1453
  let { token: t } = e, n = this.store.state.onChange.get(), r = this.store.state.tokens.get(), i = r.indexOf(t);
1451
- this.store.state.tokens.set(r.toSpliced(i, 1)), n?.(T(this.store.state.tokens.get()));
1454
+ this.store.state.tokens.set(r.toSpliced(i, 1)), n?.(E(this.store.state.tokens.get()));
1452
1455
  }), this.#n = this.store.events.select.on((e) => {
1453
1456
  let t = this.store.state.Mark.get(), n = this.store.state.onChange.get(), { mark: r, match: { option: i, span: a, index: o, source: s } } = e, c = i.markup;
1454
1457
  if (!c) return;
1455
- let l = r.type === "mark" ? w(c, {
1458
+ let l = r.type === "mark" ? T(c, {
1456
1459
  value: r.value,
1457
1460
  meta: r.meta
1458
- }) : w(c, { value: r.content }), u = rt(a, l, o, s);
1461
+ }) : T(c, { value: r.content }), u = nt(a, l, o, s);
1459
1462
  if (this.store.state.recovery.set(t ? {
1460
1463
  caret: 0,
1461
1464
  anchor: this.store.nodes.input.next,
@@ -1467,14 +1470,14 @@ var it = class {
1467
1470
  }), this.store.nodes.input.target) {
1468
1471
  this.store.nodes.input.content = u;
1469
1472
  let e = this.store.state.tokens.get(), t = e[this.store.nodes.input.index];
1470
- t.type === "text" && (t.content = u), this.store.nodes.focus.target = this.store.nodes.input.target, this.store.nodes.input.clear(), n?.(T(e)), this.store.events.parse();
1473
+ t.type === "text" && (t.content = u), this.store.nodes.focus.target = this.store.nodes.input.target, this.store.nodes.input.clear(), n?.(E(e)), this.store.events.parse();
1471
1474
  }
1472
1475
  }));
1473
1476
  }
1474
1477
  disable() {
1475
1478
  this.#e?.(), this.#t?.(), this.#n?.(), this.#e = void 0, this.#t = void 0, this.#n = void 0;
1476
1479
  }
1477
- }, at = class {
1480
+ }, it = class {
1478
1481
  #e;
1479
1482
  #t;
1480
1483
  #n;
@@ -1485,7 +1488,7 @@ var it = class {
1485
1488
  if (this.#e) return;
1486
1489
  let e = this.store.refs.container;
1487
1490
  e && (this.#e = (e) => {
1488
- let t = A(e.target) ? e.target : void 0;
1491
+ let t = j(e.target) ? e.target : void 0;
1489
1492
  this.store.nodes.focus.target = t;
1490
1493
  }, this.#t = () => {
1491
1494
  this.store.nodes.focus.target = void 0;
@@ -1493,7 +1496,7 @@ var it = class {
1493
1496
  let e = this.store.state.tokens.get();
1494
1497
  if (e.length === 1 && e[0].type === "text" && e[0].content === "") {
1495
1498
  let e = this.store.refs.container;
1496
- (e ? Ve(e) : null)?.focus();
1499
+ (e ? Be(e) : null)?.focus();
1497
1500
  }
1498
1501
  }, e.addEventListener("focusin", this.#e), e.addEventListener("focusout", this.#t), e.addEventListener("click", this.#n));
1499
1502
  }
@@ -1507,7 +1510,7 @@ var it = class {
1507
1510
  let { anchor: t, caret: n, isNext: r } = e, i = !t.target || !t.target.isConnected;
1508
1511
  switch (!0) {
1509
1512
  case r && i: {
1510
- let t = this.store.refs.container, n = e.childIndex == null ? void 0 : M(t, e.childIndex + 2);
1513
+ let t = this.store.refs.container, n = e.childIndex == null ? void 0 : N(t, e.childIndex + 2);
1511
1514
  n ? n.focus() : this.store.nodes.focus.tail?.focus();
1512
1515
  break;
1513
1516
  }
@@ -1523,28 +1526,28 @@ var it = class {
1523
1526
  }
1524
1527
  };
1525
1528
  //#endregion
1526
- //#region ../../common/core/src/features/navigation/navigation.ts
1527
- function ot(e, t) {
1529
+ //#region ../../core/src/features/navigation/navigation.ts
1530
+ function at(e, t) {
1528
1531
  let { focus: n } = e.nodes;
1529
1532
  if (n.isMark && !n.isEditable || n.isCaretAtBeginning) {
1530
1533
  let e = n.prev;
1531
1534
  for (; e.target && e.isMark && !e.isEditable;) e = e.prev;
1532
- return e.target ? (t.preventDefault(), e.target.focus(), F.setCaretToEnd(e.target), !0) : !1;
1535
+ return e.target ? (t.preventDefault(), e.target.focus(), I.setCaretToEnd(e.target), !0) : !1;
1533
1536
  }
1534
1537
  return !1;
1535
1538
  }
1536
- function st(e, t) {
1539
+ function ot(e, t) {
1537
1540
  let { focus: n } = e.nodes;
1538
1541
  if (n.isMark && !n.isEditable || n.isCaretAtEnd) {
1539
1542
  let e = n.next;
1540
1543
  for (; e.target && e.isMark && !e.isEditable;) e = e.next;
1541
- return e.target ? (t.preventDefault(), e.target.focus(), F.trySetIndex(e.target, 0), !0) : !1;
1544
+ return e.target ? (t.preventDefault(), e.target.focus(), I.trySetIndex(e.target, 0), !0) : !1;
1542
1545
  }
1543
1546
  return !1;
1544
1547
  }
1545
1548
  //#endregion
1546
- //#region ../../common/core/src/features/selection/selectionHelpers.ts
1547
- function ct(e) {
1549
+ //#region ../../core/src/features/selection/selectionHelpers.ts
1550
+ function st(e) {
1548
1551
  let t = window.getSelection(), n = e.refs.container;
1549
1552
  if (!t?.rangeCount || !n?.firstChild || !n.lastChild) return !1;
1550
1553
  try {
@@ -1554,7 +1557,7 @@ function ct(e) {
1554
1557
  return !1;
1555
1558
  }
1556
1559
  }
1557
- function lt(e, t) {
1560
+ function ct(e, t) {
1558
1561
  if ((t.ctrlKey || t.metaKey) && t.code === "KeyA") {
1559
1562
  if (e.state.drag.get()) return;
1560
1563
  t.preventDefault();
@@ -1564,45 +1567,51 @@ function lt(e, t) {
1564
1567
  }
1565
1568
  }
1566
1569
  //#endregion
1567
- //#region ../../common/core/src/features/selection/TextSelectionController.ts
1568
- var ut = class {
1570
+ //#region ../../core/src/features/selection/TextSelectionController.ts
1571
+ var lt = class {
1569
1572
  #e;
1570
1573
  #t;
1571
1574
  #n;
1572
1575
  #r;
1573
- #i = null;
1574
- #a = !1;
1576
+ #i;
1577
+ #a = null;
1578
+ #o = !1;
1575
1579
  constructor(e) {
1576
1580
  this.store = e;
1577
1581
  }
1578
1582
  enable() {
1579
1583
  this.#e || (this.#e = (e) => {
1580
- this.#i = Ue(e), this.#a = !0;
1584
+ this.#a = He(e), this.#o = !0;
1581
1585
  }, this.#t = (e) => {
1582
1586
  let t = this.store.refs.container;
1583
1587
  if (!t) return;
1584
- let n = this.#a, r = !t.contains(this.#i) || this.#i !== e.target, i = window.getSelection()?.containsNode(t, !0);
1585
- n && r && i && this.store.state.selecting.set("drag");
1588
+ let n = this.#o, r = !t.contains(this.#a) || this.#a !== e.target, i = window.getSelection()?.containsNode(t, !0);
1589
+ n && r && i && this.store.state.selecting.get() !== "drag" && this.store.state.selecting.set("drag");
1586
1590
  }, this.#n = () => {
1587
- this.#a = !1, this.#i = null, this.store.state.selecting.set(void 0);
1591
+ if (this.#o = !1, this.#a = null, this.store.state.selecting.get() === "drag") {
1592
+ let e = window.getSelection();
1593
+ (!e || e.isCollapsed) && this.store.state.selecting.set(void 0);
1594
+ }
1588
1595
  }, this.#r = () => {
1589
1596
  if (this.store.state.selecting.get() !== "drag") return;
1590
- let e = this.store.refs.container;
1591
- if (!e) return;
1592
- let t = N(e), n = t.map((e) => e.contentEditable);
1593
- t.forEach((e) => e.contentEditable = "false"), t.forEach((e, t) => e.contentEditable = n[t]);
1594
- }, document.addEventListener("mousedown", this.#e), document.addEventListener("mousemove", this.#t), document.addEventListener("mouseup", this.#n), document.addEventListener("selectionchange", this.#r));
1597
+ let e = window.getSelection();
1598
+ (!e || e.isCollapsed) && this.store.state.selecting.set(void 0);
1599
+ }, this.#i = this.store.state.selecting.on((e) => {
1600
+ if (e !== "drag") return;
1601
+ let t = this.store.refs.container;
1602
+ t && t.querySelectorAll("[contenteditable=\"true\"]").forEach((e) => e.contentEditable = "false");
1603
+ }), document.addEventListener("mousedown", this.#e), document.addEventListener("mousemove", this.#t), document.addEventListener("mouseup", this.#n), document.addEventListener("selectionchange", this.#r));
1595
1604
  }
1596
1605
  disable() {
1597
- this.#e && (document.removeEventListener("mousedown", this.#e), this.#t && document.removeEventListener("mousemove", this.#t), this.#n && document.removeEventListener("mouseup", this.#n), this.#r && document.removeEventListener("selectionchange", this.#r), this.#e = void 0, this.#t = void 0, this.#n = void 0, this.#r = void 0), this.#i = null, this.#a = !1;
1606
+ this.store.state.selecting.get() === "drag" && this.store.state.selecting.set(void 0), this.#i?.(), this.#i = void 0, this.#e && (document.removeEventListener("mousedown", this.#e), this.#t && document.removeEventListener("mousemove", this.#t), this.#n && document.removeEventListener("mouseup", this.#n), this.#r && document.removeEventListener("selectionchange", this.#r), this.#e = void 0, this.#t = void 0, this.#n = void 0, this.#r = void 0), this.#a = null, this.#o = !1;
1598
1607
  }
1599
1608
  };
1600
1609
  //#endregion
1601
- //#region ../../common/core/src/features/input/KeyDownController.ts
1602
- function dt(e) {
1610
+ //#region ../../core/src/features/input/KeyDownController.ts
1611
+ function ut(e) {
1603
1612
  return e.type === "text" ? !0 : e.descriptor.hasSlot && e.descriptor.segments.length === 1;
1604
1613
  }
1605
- var ft = class {
1614
+ var dt = class {
1606
1615
  #e;
1607
1616
  #t;
1608
1617
  #n;
@@ -1611,7 +1620,7 @@ var ft = class {
1611
1620
  }
1612
1621
  #r() {
1613
1622
  let e = this.store.state.options.get()?.[0];
1614
- return e?.markup ? w(e.markup, {
1623
+ return e?.markup ? T(e.markup, {
1615
1624
  value: "",
1616
1625
  slot: "",
1617
1626
  meta: ""
@@ -1621,11 +1630,11 @@ var ft = class {
1621
1630
  if (this.#e) return;
1622
1631
  let e = this.store.refs.container;
1623
1632
  e && (this.#e = (e) => {
1624
- e.key === y.LEFT ? this.#o(e, "left") || ot(this.store, e) : e.key === y.RIGHT ? this.#o(e, "right") || st(this.store, e) : (e.key === y.UP || e.key === y.DOWN) && this.#s(e), this.#i(e), this.#a(e), lt(this.store, e);
1633
+ e.key === y.LEFT ? this.#o(e, "left") || at(this.store, e) : e.key === y.RIGHT ? this.#o(e, "right") || ot(this.store, e) : (e.key === y.UP || e.key === y.DOWN) && this.#s(e), this.#i(e), this.#a(e), ct(this.store, e);
1625
1634
  }, this.#t = (e) => {
1626
- ht(this.store, e);
1635
+ mt(this.store, e);
1627
1636
  }, this.#n = (e) => {
1628
- pt(this.store, e);
1637
+ ft(this.store, e);
1629
1638
  }, e.addEventListener("keydown", this.#e), e.addEventListener("paste", this.#t), e.addEventListener("beforeinput", this.#n, !0));
1630
1639
  }
1631
1640
  disable() {
@@ -1637,101 +1646,101 @@ var ft = class {
1637
1646
  if (!n && (e.key === y.DELETE || e.key === y.BACKSPACE)) {
1638
1647
  if (t.isMark) {
1639
1648
  if (t.isEditable && (e.key === y.BACKSPACE && !t.isCaretAtBeginning || e.key === y.DELETE && !t.isCaretAtEnd)) return;
1640
- e.preventDefault(), B("self", this.store);
1649
+ e.preventDefault(), V("self", this.store);
1641
1650
  return;
1642
1651
  }
1643
1652
  if (e.key === y.BACKSPACE && t.isSpan && t.isCaretAtBeginning && t.prev.target) {
1644
- e.preventDefault(), B("prev", this.store);
1653
+ e.preventDefault(), V("prev", this.store);
1645
1654
  return;
1646
1655
  }
1647
1656
  if (e.key === y.DELETE && t.isSpan && t.isCaretAtEnd && t.next.target) {
1648
- e.preventDefault(), B("next", this.store);
1657
+ e.preventDefault(), V("next", this.store);
1649
1658
  return;
1650
1659
  }
1651
1660
  }
1652
1661
  if (!n) return;
1653
1662
  let r = this.store.refs.container;
1654
1663
  if (!r) return;
1655
- let i = N(r), a = i.findIndex((e) => e === document.activeElement || e.contains(document.activeElement));
1664
+ let i = P(r), a = i.findIndex((e) => e === document.activeElement || e.contains(document.activeElement));
1656
1665
  if (a === -1) return;
1657
1666
  let o = this.store.state.tokens.get();
1658
1667
  if (a >= o.length) return;
1659
1668
  let s = o[a], c = this.store.state.previousValue.get() ?? this.store.state.value.get() ?? "";
1660
1669
  if (this.store.state.onChange.get()) {
1661
1670
  if (e.key === y.BACKSPACE) {
1662
- let t = i[a], n = F.getCaretIndex(t) === 0;
1671
+ let t = i[a], n = I.getCaretIndex(t) === 0;
1663
1672
  if (("content" in s ? s.content : "") === "") {
1664
1673
  e.preventDefault();
1665
1674
  let t = o.length <= 1 ? "" : a >= o.length - 1 ? c.slice(0, o[a - 1].position.end) : c.slice(0, o[a].position.start) + c.slice(o[a + 1].position.start);
1666
1675
  this.store.applyValue(t), queueMicrotask(() => {
1667
- let e = M(r, Math.max(0, a - 1));
1668
- e && (e.focus(), F.setCaretToEnd(e));
1676
+ let e = N(r, Math.max(0, a - 1));
1677
+ e && (e.focus(), I.setCaretToEnd(e));
1669
1678
  });
1670
1679
  return;
1671
1680
  }
1672
1681
  if (n && a > 0) {
1673
1682
  let t = o[a - 1], n = o[a];
1674
- if (L(t, n)) {
1683
+ if (R(t, n)) {
1675
1684
  e.preventDefault();
1676
- let t = R(o, a), n = z(c, o, a);
1685
+ let t = z(o, a), n = B(c, o, a);
1677
1686
  this.store.applyValue(n), queueMicrotask(() => {
1678
- let e = M(r, a - 1);
1687
+ let e = N(r, a - 1);
1679
1688
  if (e) {
1680
1689
  e.focus();
1681
1690
  let n = this.store.state.tokens.get()[a - 1];
1682
- H(e, n, t);
1691
+ U(e, n, t);
1683
1692
  }
1684
1693
  });
1685
1694
  return;
1686
1695
  }
1687
1696
  e.preventDefault(), queueMicrotask(() => {
1688
1697
  let e = i[a - 1];
1689
- e.focus(), t.type !== "mark" && F.setCaretToEnd(e);
1698
+ e.focus(), t.type !== "mark" && I.setCaretToEnd(e);
1690
1699
  });
1691
1700
  return;
1692
1701
  }
1693
1702
  }
1694
1703
  if (e.key === y.DELETE) {
1695
- let t = i[a], n = F.getCaretIndex(t), s = n === t.textContent.length;
1704
+ let t = i[a], n = I.getCaretIndex(t), s = n === t.textContent.length;
1696
1705
  if (n === 0 && a > 0) {
1697
1706
  let t = o[a - 1], n = o[a];
1698
- if (L(t, n)) {
1707
+ if (R(t, n)) {
1699
1708
  e.preventDefault();
1700
- let t = R(o, a), n = z(c, o, a);
1709
+ let t = z(o, a), n = B(c, o, a);
1701
1710
  this.store.applyValue(n), queueMicrotask(() => {
1702
- let e = M(r, a - 1);
1711
+ let e = N(r, a - 1);
1703
1712
  if (e) {
1704
1713
  e.focus();
1705
1714
  let n = this.store.state.tokens.get()[a - 1];
1706
- H(e, n, t);
1715
+ U(e, n, t);
1707
1716
  }
1708
1717
  });
1709
1718
  return;
1710
1719
  }
1711
1720
  e.preventDefault(), queueMicrotask(() => {
1712
1721
  let e = i[a - 1];
1713
- e.focus(), t.type !== "mark" && F.setCaretToEnd(e);
1722
+ e.focus(), t.type !== "mark" && I.setCaretToEnd(e);
1714
1723
  });
1715
1724
  return;
1716
1725
  }
1717
1726
  if (s && a < o.length - 1) {
1718
1727
  let t = o[a], n = o[a + 1];
1719
- if (L(t, n)) {
1728
+ if (R(t, n)) {
1720
1729
  e.preventDefault();
1721
- let t = R(o, a + 1), n = z(c, o, a + 1);
1730
+ let t = z(o, a + 1), n = B(c, o, a + 1);
1722
1731
  this.store.applyValue(n), queueMicrotask(() => {
1723
- let e = M(r, a);
1732
+ let e = N(r, a);
1724
1733
  if (e) {
1725
1734
  e.focus();
1726
1735
  let n = this.store.state.tokens.get()[a];
1727
- H(e, n, t);
1736
+ U(e, n, t);
1728
1737
  }
1729
1738
  });
1730
1739
  return;
1731
1740
  }
1732
1741
  e.preventDefault(), queueMicrotask(() => {
1733
1742
  let e = i[a + 1];
1734
- e.focus(), F.trySetIndex(e, 0);
1743
+ e.focus(), I.trySetIndex(e, 0);
1735
1744
  });
1736
1745
  return;
1737
1746
  }
@@ -1743,9 +1752,9 @@ var ft = class {
1743
1752
  let t = this.store.refs.container;
1744
1753
  if (!t) return;
1745
1754
  let n = document.activeElement;
1746
- if (!A(n) || !t.contains(n)) return;
1755
+ if (!j(n) || !t.contains(n)) return;
1747
1756
  e.preventDefault();
1748
- let r = N(t), i = -1;
1757
+ let r = P(t), i = -1;
1749
1758
  for (let e = 0; e < r.length; e++) if (r[e] === n || r[e].contains(n)) {
1750
1759
  i = e;
1751
1760
  break;
@@ -1754,23 +1763,23 @@ var ft = class {
1754
1763
  let a = this.store.state.tokens.get(), o = a[i], s = r[i], c = this.store.state.previousValue.get() ?? this.store.state.value.get() ?? "";
1755
1764
  if (!this.store.state.onChange.get()) return;
1756
1765
  let l = this.#r();
1757
- if (!dt(o)) {
1758
- let e = Je(c, a, i, l);
1766
+ if (!ut(o)) {
1767
+ let e = qe(c, a, i, l);
1759
1768
  this.store.applyValue(e), queueMicrotask(() => {
1760
1769
  let e = i + 1;
1761
1770
  if (e < t.children.length) {
1762
- let n = M(t, e);
1763
- n && (n.focus(), F.trySetIndex(n, 0));
1771
+ let n = N(t, e);
1772
+ n && (n.focus(), I.trySetIndex(n, 0));
1764
1773
  }
1765
1774
  });
1766
1775
  return;
1767
1776
  }
1768
- let u = V(s, o), d = c.slice(0, u) + l + c.slice(u);
1777
+ let u = H(s, o), d = c.slice(0, u) + l + c.slice(u);
1769
1778
  this.store.applyValue(d), queueMicrotask(() => {
1770
1779
  let e = i + 1;
1771
1780
  if (e < t.children.length) {
1772
- let n = M(t, e);
1773
- n && (n.focus(), F.trySetIndex(n, 0));
1781
+ let n = N(t, e);
1782
+ n && (n.focus(), I.trySetIndex(n, 0));
1774
1783
  }
1775
1784
  });
1776
1785
  }
@@ -1779,73 +1788,73 @@ var ft = class {
1779
1788
  let n = this.store.refs.container;
1780
1789
  if (!n) return !1;
1781
1790
  let r = document.activeElement;
1782
- if (!A(r) || !n.contains(r)) return !1;
1783
- let i = N(n), a = i.findIndex((e) => e === r || e.contains(r));
1791
+ if (!j(r) || !n.contains(r)) return !1;
1792
+ let i = P(n), a = i.findIndex((e) => e === r || e.contains(r));
1784
1793
  if (a === -1) return !1;
1785
1794
  let o = i[a];
1786
1795
  if (t === "left") {
1787
- if (F.getCaretIndex(o) !== 0) return !1;
1796
+ if (I.getCaretIndex(o) !== 0) return !1;
1788
1797
  if (a === 0) return !0;
1789
1798
  e.preventDefault();
1790
1799
  let t = i[a - 1];
1791
- return t.focus(), F.setCaretToEnd(t), !0;
1800
+ return t.focus(), I.setCaretToEnd(t), !0;
1792
1801
  }
1793
- if (F.getCaretIndex(o) !== o.textContent.length) return !1;
1802
+ if (I.getCaretIndex(o) !== o.textContent.length) return !1;
1794
1803
  if (a >= i.length - 1) return !0;
1795
1804
  e.preventDefault();
1796
1805
  let s = i[a + 1];
1797
- return s.focus(), F.trySetIndex(s, 0), !0;
1806
+ return s.focus(), I.trySetIndex(s, 0), !0;
1798
1807
  }
1799
1808
  #s(e) {
1800
1809
  if (!this.store.state.drag.get()) return;
1801
1810
  let t = this.store.refs.container;
1802
1811
  if (!t) return;
1803
1812
  let n = document.activeElement;
1804
- if (!A(n) || !t.contains(n)) return;
1805
- let r = N(t), i = r.findIndex((e) => e === n || e.contains(n));
1813
+ if (!j(n) || !t.contains(n)) return;
1814
+ let r = P(t), i = r.findIndex((e) => e === n || e.contains(n));
1806
1815
  if (i === -1) return;
1807
1816
  let a = r[i];
1808
1817
  if (e.key === y.UP) {
1809
- if (!F.isCaretOnFirstLine(a) || i === 0) return;
1818
+ if (!I.isCaretOnFirstLine(a) || i === 0) return;
1810
1819
  e.preventDefault();
1811
- let t = F.getCaretRect()?.left ?? a.getBoundingClientRect().left, n = r[i - 1];
1820
+ let t = I.getCaretRect()?.left ?? a.getBoundingClientRect().left, n = r[i - 1];
1812
1821
  n.focus();
1813
1822
  let o = n.getBoundingClientRect();
1814
- F.setAtX(n, t, o.bottom - 4);
1823
+ I.setAtX(n, t, o.bottom - 4);
1815
1824
  } else if (e.key === y.DOWN) {
1816
- if (!F.isCaretOnLastLine(a) || i >= r.length - 1) return;
1825
+ if (!I.isCaretOnLastLine(a) || i >= r.length - 1) return;
1817
1826
  e.preventDefault();
1818
- let t = F.getCaretRect()?.left ?? a.getBoundingClientRect().left, n = r[i + 1];
1827
+ let t = I.getCaretRect()?.left ?? a.getBoundingClientRect().left, n = r[i + 1];
1819
1828
  n.focus();
1820
1829
  let o = n.getBoundingClientRect();
1821
- F.setAtX(n, t, o.top + 4);
1830
+ I.setAtX(n, t, o.top + 4);
1822
1831
  }
1823
1832
  }
1824
1833
  };
1825
- function V(e, t) {
1834
+ function H(e, t) {
1826
1835
  let n = window.getSelection();
1827
1836
  if (!n?.rangeCount) return t.position.end;
1828
1837
  let { focusNode: r, focusOffset: i } = n;
1829
- return r ? U(r, i, e, t) : t.position.end;
1838
+ return r ? W(r, i, e, t) : t.position.end;
1830
1839
  }
1831
- function pt(e, t) {
1840
+ function ft(e, t) {
1832
1841
  let n = e.state.selecting.get();
1833
- if (n === "all" && ct(e)) {
1842
+ if (n === "all" && st(e)) {
1834
1843
  if (t.inputType === "insertFromPaste") {
1835
1844
  t.preventDefault();
1836
1845
  return;
1837
1846
  }
1838
- t.preventDefault(), gt(e, t.inputType.startsWith("delete") ? "" : t.data ?? "");
1847
+ t.preventDefault(), ht(e, t.inputType.startsWith("delete") ? "" : t.data ?? "");
1839
1848
  return;
1840
1849
  }
1841
1850
  if (n === "all" && e.state.selecting.set(void 0), e.state.drag.get()) {
1842
- _t(e, t);
1851
+ gt(e, t);
1843
1852
  return;
1844
1853
  }
1845
1854
  let { focus: r } = e.nodes;
1846
- !r.target || !r.isEditable || mt(r, t) && e.events.change();
1855
+ !r.target || !r.isEditable || pt(r, t) && e.events.change();
1847
1856
  }
1848
- function mt(e, t) {
1857
+ function pt(e, t) {
1849
1858
  let n = e.caret, r = e.content, i, a;
1850
1859
  switch (t.inputType) {
1851
1860
  case "insertText": {
@@ -1877,15 +1886,15 @@ function mt(e, t) {
1877
1886
  }
1878
1887
  return e.content = i, e.caret = a, !0;
1879
1888
  }
1880
- function ht(e, t) {
1889
+ function mt(e, t) {
1881
1890
  let n = e.state.selecting.get();
1882
- if (n !== "all" || !ct(e)) {
1891
+ if (n !== "all" || !st(e)) {
1883
1892
  n === "all" && e.state.selecting.set(void 0);
1884
1893
  return;
1885
1894
  }
1886
- t.preventDefault(), gt(e, t.clipboardData?.getData("text/plain") ?? "");
1895
+ t.preventDefault(), ht(e, t.clipboardData?.getData("text/plain") ?? "");
1887
1896
  }
1888
- function gt(e, t) {
1897
+ function ht(e, t) {
1889
1898
  e.nodes.focus.target = null, e.state.selecting.set(void 0), e.state.onChange.get()?.(t), e.state.value.get() === void 0 && e.state.tokens.set(e.state.parser.get()?.parse(t) ?? [{
1890
1899
  type: "text",
1891
1900
  content: t,
@@ -1894,29 +1903,29 @@ function gt(e, t) {
1894
1903
  end: t.length
1895
1904
  }
1896
1905
  }]), queueMicrotask(() => {
1897
- let n = e.refs.container?.firstChild, r = A(n) ? n : null;
1906
+ let n = e.refs.container?.firstChild, r = j(n) ? n : null;
1898
1907
  r && (e.state.recovery.set({
1899
1908
  anchor: e.nodes.focus,
1900
1909
  caret: t.length
1901
1910
  }), r.focus());
1902
1911
  });
1903
1912
  }
1904
- function _t(e, t) {
1913
+ function gt(e, t) {
1905
1914
  let n = e.refs.container;
1906
1915
  if (!n) return;
1907
1916
  let r = document.activeElement;
1908
- if (!A(r) || !n.contains(r)) return;
1909
- let i = N(n), a = i.findIndex((e) => e === r || e.contains(r));
1917
+ if (!j(r) || !n.contains(r)) return;
1918
+ let i = P(n), a = i.findIndex((e) => e === r || e.contains(r));
1910
1919
  if (a === -1) return;
1911
1920
  let o = i[a], s = e.state.tokens.get();
1912
1921
  if (a >= s.length) return;
1913
1922
  let c = s[a], l = e.state.previousValue.get() ?? e.state.value.get() ?? "", u = (t) => {
1914
1923
  queueMicrotask(() => {
1915
- let r = M(n, a);
1924
+ let r = N(n, a);
1916
1925
  if (!r) return;
1917
1926
  r.focus();
1918
1927
  let i = e.state.tokens.get()[a];
1919
- H(r, i, t);
1928
+ U(r, i, t);
1920
1929
  });
1921
1930
  };
1922
1931
  switch (t.inputType) {
@@ -1924,9 +1933,9 @@ function _t(e, t) {
1924
1933
  t.preventDefault();
1925
1934
  let n = t.data ?? "", r = t.getTargetRanges(), i, a;
1926
1935
  if (r.length > 0) {
1927
- let e = U(r[0].startContainer, r[0].startOffset, o, c), t = U(r[0].endContainer, r[0].endOffset, o, c);
1936
+ let e = W(r[0].startContainer, r[0].startOffset, o, c), t = W(r[0].endContainer, r[0].endOffset, o, c);
1928
1937
  [i, a] = e <= t ? [e, t] : [t, e];
1929
- } else i = a = V(o, c);
1938
+ } else i = a = H(o, c);
1930
1939
  e.applyValue(l.slice(0, i) + n + l.slice(a)), u(i + n.length);
1931
1940
  break;
1932
1941
  }
@@ -1935,9 +1944,9 @@ function _t(e, t) {
1935
1944
  t.preventDefault();
1936
1945
  let n = t.dataTransfer?.getData("text/plain") ?? "", r = t.getTargetRanges(), i, a;
1937
1946
  if (r.length > 0) {
1938
- let e = U(r[0].startContainer, r[0].startOffset, o, c), t = U(r[0].endContainer, r[0].endOffset, o, c);
1947
+ let e = W(r[0].startContainer, r[0].startOffset, o, c), t = W(r[0].endContainer, r[0].endOffset, o, c);
1939
1948
  [i, a] = e <= t ? [e, t] : [t, e];
1940
- } else i = a = V(o, c);
1949
+ } else i = a = H(o, c);
1941
1950
  e.applyValue(l.slice(0, i) + n + l.slice(a)), u(i + n.length);
1942
1951
  break;
1943
1952
  }
@@ -1949,27 +1958,27 @@ function _t(e, t) {
1949
1958
  case "deleteSoftLineForward": {
1950
1959
  let n = t.getTargetRanges();
1951
1960
  if (!n.length) return;
1952
- let r = U(n[0].startContainer, n[0].startOffset, o, c), i = U(n[0].endContainer, n[0].endOffset, o, c), [a, s] = r <= i ? [r, i] : [i, r];
1961
+ let r = W(n[0].startContainer, n[0].startOffset, o, c), i = W(n[0].endContainer, n[0].endOffset, o, c), [a, s] = r <= i ? [r, i] : [i, r];
1953
1962
  if (a === s) return;
1954
1963
  t.preventDefault(), e.applyValue(l.slice(0, a) + l.slice(s)), u(a);
1955
1964
  break;
1956
1965
  }
1957
1966
  }
1958
1967
  }
1959
- function vt(e) {
1968
+ function _t(e) {
1960
1969
  return e.tagName === "SPAN" && (e.attributes.length === 0 || e.attributes.length === 1 && e.hasAttribute("contenteditable"));
1961
1970
  }
1962
- function yt(e, t, n) {
1971
+ function vt(e, t, n) {
1963
1972
  let r = window.getSelection();
1964
1973
  if (!r) return !1;
1965
1974
  let i = 0;
1966
1975
  for (let a of Array.from(e.childNodes)) {
1967
1976
  if (i >= t.children.length) break;
1968
1977
  let e = t.children[i];
1969
- if (A(a) && e.type === "text") {
1970
- if (!vt(a)) continue;
1978
+ if (j(a) && e.type === "text") {
1979
+ if (!_t(a)) continue;
1971
1980
  if (n >= e.position.start && n <= e.position.end) {
1972
- let t = a.firstChild, i = j(t) ? t : null, o = n - e.position.start;
1981
+ let t = a.firstChild, i = M(t) ? t : null, o = n - e.position.start;
1973
1982
  if (i) {
1974
1983
  let e = document.createRange();
1975
1984
  e.setStart(i, Math.min(o, i.length)), e.collapse(!0), r.removeAllRanges(), r.addRange(e);
@@ -1980,47 +1989,47 @@ function yt(e, t, n) {
1980
1989
  return !0;
1981
1990
  }
1982
1991
  i++;
1983
- } else if (j(a) && e.type === "text") {
1992
+ } else if (M(a) && e.type === "text") {
1984
1993
  if (n >= e.position.start && n <= e.position.end) {
1985
1994
  let t = Math.min(n - e.position.start, a.length), i = document.createRange();
1986
1995
  return i.setStart(a, t), i.collapse(!0), r.removeAllRanges(), r.addRange(i), !0;
1987
1996
  }
1988
1997
  i++;
1989
- } else if (A(a) && e.type === "mark") {
1998
+ } else if (j(a) && e.type === "mark") {
1990
1999
  let r = i + 1 < t.children.length ? t.children[i + 1] : null;
1991
- if (!(n === e.position.end && r?.position.start === n) && n >= e.position.start && n <= e.position.end) return yt(a, e, n);
2000
+ if (!(n === e.position.end && r?.position.start === n) && n >= e.position.start && n <= e.position.end) return vt(a, e, n);
1992
2001
  i++;
1993
2002
  }
1994
2003
  }
1995
2004
  return !1;
1996
2005
  }
1997
- function H(e, t, n) {
2006
+ function U(e, t, n) {
1998
2007
  let r = window.getSelection();
1999
2008
  if (!r) return;
2000
2009
  if (t.type === "mark") {
2001
- if (yt(e, t, n)) return;
2002
- F.setCaretToEnd(e);
2010
+ if (vt(e, t, n)) return;
2011
+ I.setCaretToEnd(e);
2003
2012
  return;
2004
2013
  }
2005
- let i = n - t.position.start, a = P(document.createTreeWalker(e, 4));
2014
+ let i = n - t.position.start, a = F(document.createTreeWalker(e, 4));
2006
2015
  if (a) {
2007
2016
  let e = Math.min(i, a.length), t = document.createRange();
2008
2017
  t.setStart(a, e), t.collapse(!0), r.removeAllRanges(), r.addRange(t);
2009
2018
  return;
2010
2019
  }
2011
- F.setCaretToEnd(e);
2020
+ I.setCaretToEnd(e);
2012
2021
  }
2013
- function U(e, t, n, r) {
2022
+ function W(e, t, n, r) {
2014
2023
  if (e === n) {
2015
2024
  let e = window.getSelection();
2016
- return e?.focusNode && e.focusNode !== n ? U(e.focusNode, e.focusOffset, n, r) : r.position.end;
2025
+ return e?.focusNode && e.focusNode !== n ? W(e.focusNode, e.focusOffset, n, r) : r.position.end;
2017
2026
  }
2018
- if (e.nodeType === Node.TEXT_NODE && e.parentElement === n) return r.type === "mark" ? W(e, t, n, r) : r.position.start + Math.min(t, r.content.length);
2027
+ if (e.nodeType === Node.TEXT_NODE && e.parentElement === n) return r.type === "mark" ? G(e, t, n, r) : r.position.start + Math.min(t, r.content.length);
2019
2028
  let i = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
2020
2029
  for (; i && i.parentElement !== n;) i = i.parentElement;
2021
- return i ? r.type === "mark" ? W(e, t, n, r) : r.position.start + Math.min(t, r.content.length) : r.position.end;
2030
+ return i ? r.type === "mark" ? G(e, t, n, r) : r.position.start + Math.min(t, r.content.length) : r.position.end;
2022
2031
  }
2023
- function W(e, t, n, r) {
2032
+ function G(e, t, n, r) {
2024
2033
  if (r.children.length === 0) {
2025
2034
  if (t === 0) return r.position.start;
2026
2035
  let e = r.slot?.content.length ?? r.value.length;
@@ -2030,27 +2039,27 @@ function W(e, t, n, r) {
2030
2039
  for (let a of Array.from(n.childNodes)) {
2031
2040
  if (i >= r.children.length) break;
2032
2041
  let n = r.children[i];
2033
- if (A(a) && n.type === "text") {
2034
- if (!vt(a)) continue;
2042
+ if (j(a) && n.type === "text") {
2043
+ if (!_t(a)) continue;
2035
2044
  if (e === a) {
2036
2045
  let e = t === 0 ? 0 : n.content.length;
2037
2046
  return n.position.start + Math.min(e, n.content.length);
2038
2047
  }
2039
2048
  if (a.contains(e)) return n.position.start + Math.min(t, n.content.length);
2040
2049
  i++;
2041
- } else if (j(a) && n.type === "text") {
2050
+ } else if (M(a) && n.type === "text") {
2042
2051
  if (e === a) return n.position.start + Math.min(t, n.content.length);
2043
2052
  i++;
2044
- } else if (A(a) && n.type === "mark") {
2045
- if (a === e || a.contains(e)) return W(e, t, a, n);
2053
+ } else if (j(a) && n.type === "mark") {
2054
+ if (a === e || a.contains(e)) return G(e, t, a, n);
2046
2055
  i++;
2047
2056
  }
2048
2057
  }
2049
2058
  return r.slot?.end ?? r.position.end;
2050
2059
  }
2051
2060
  //#endregion
2052
- //#region ../../common/core/src/features/feature-manager/FeatureManager.ts
2053
- var bt = class {
2061
+ //#region ../../core/src/features/feature-manager/FeatureManager.ts
2062
+ var yt = class {
2054
2063
  #e = [];
2055
2064
  #t = !1;
2056
2065
  register(e) {
@@ -2062,21 +2071,21 @@ var bt = class {
2062
2071
  disableAll() {
2063
2072
  this.#t && (this.#t = !1, this.#e.forEach((e) => e.disable()));
2064
2073
  }
2065
- }, G = (e, t) => ({
2074
+ }, K = (e, t) => ({
2066
2075
  name: e,
2067
2076
  enable: () => t.enable(),
2068
2077
  disable: () => t.disable()
2069
- }), xt = (e) => {
2070
- let t = new bt();
2071
- return t.register(G("keydown", e.controllers.keydown)).register(G("system", e.controllers.system)).register(G("focus", e.controllers.focus)).register(G("textSelection", e.controllers.textSelection)).register(G("contentEditable", e.controllers.contentEditable)), t;
2072
- }, St = class {
2078
+ }), bt = (e) => {
2079
+ let t = new yt();
2080
+ return t.register(K("keydown", e.controllers.keydown)).register(K("system", e.controllers.system)).register(K("focus", e.controllers.focus)).register(K("textSelection", e.controllers.textSelection)).register(K("contentEditable", e.controllers.contentEditable)), t;
2081
+ }, xt = class {
2073
2082
  #e = [];
2074
2083
  #t = !1;
2075
2084
  constructor(e) {
2076
2085
  this.store = e;
2077
2086
  }
2078
2087
  enable(e) {
2079
- let { store: t } = this, n = xt(t);
2088
+ let { store: t } = this, n = bt(t);
2080
2089
  n.enableAll(), this.#e.push(() => n.disableAll()), this.#n(), e?.getTrigger && this.#r(e.getTrigger);
2081
2090
  }
2082
2091
  disable() {
@@ -2087,14 +2096,14 @@ var bt = class {
2087
2096
  let { store: n } = this, r = t?.map((e) => e.markup);
2088
2097
  if (r?.some(Boolean)) {
2089
2098
  let e = n.state.drag.get() ? { skipEmptyText: !0 } : void 0;
2090
- n.state.parser.set(new xe(r, e));
2099
+ n.state.parser.set(new be(r, e));
2091
2100
  } else n.state.parser.set(void 0);
2092
2101
  if (this.#t) {
2093
2102
  n.state.recovery.get() || n.events.parse();
2094
2103
  return;
2095
2104
  }
2096
2105
  let i = e ?? n.state.defaultValue.get() ?? "";
2097
- n.state.tokens.set(O(n, i)), this.#t = !0;
2106
+ n.state.tokens.set(k(n, i)), this.#t = !0;
2098
2107
  }
2099
2108
  recoverFocus() {
2100
2109
  this.store.controllers.contentEditable.sync(), this.store.state.Mark.get() && this.store.controllers.focus.recover();
@@ -2103,11 +2112,11 @@ var bt = class {
2103
2112
  let { store: e } = this;
2104
2113
  this.#e.push(e.events.parse.on(() => {
2105
2114
  if (e.state.recovery.get()) {
2106
- let t = T(e.state.tokens.get());
2107
- e.state.tokens.set(O(e, t)), e.state.previousValue.set(t);
2115
+ let t = E(e.state.tokens.get());
2116
+ e.state.tokens.set(k(e, t)), e.state.previousValue.set(t);
2108
2117
  return;
2109
2118
  }
2110
- e.state.tokens.set(e.nodes.focus.target ? Te(e) : Ee(e));
2119
+ e.state.tokens.set(e.nodes.focus.target ? we(e) : Te(e));
2111
2120
  }));
2112
2121
  }
2113
2122
  #r(e) {
@@ -2118,14 +2127,14 @@ var bt = class {
2118
2127
  }
2119
2128
  };
2120
2129
  //#endregion
2121
- //#region ../../common/core/src/features/overlay/filterSuggestions.ts
2122
- function Ct(e, t) {
2130
+ //#region ../../core/src/features/overlay/filterSuggestions.ts
2131
+ function St(e, t) {
2123
2132
  let n = t.toLowerCase();
2124
2133
  return e.filter((e) => e.toLowerCase().includes(n));
2125
2134
  }
2126
2135
  //#endregion
2127
- //#region ../../common/core/src/features/overlay/createMarkFromOverlay.ts
2128
- function wt(e, t, n) {
2136
+ //#region ../../core/src/features/overlay/createMarkFromOverlay.ts
2137
+ function Ct(e, t, n) {
2129
2138
  let r = e.option.markup;
2130
2139
  if (!r) throw Error("createMarkFromOverlay: option.markup is required");
2131
2140
  return {
@@ -2151,8 +2160,8 @@ function wt(e, t, n) {
2151
2160
  };
2152
2161
  }
2153
2162
  //#endregion
2154
- //#region ../../common/core/src/features/overlay/OverlayController.ts
2155
- var Tt = class {
2163
+ //#region ../../core/src/features/overlay/OverlayController.ts
2164
+ var wt = class {
2156
2165
  #e;
2157
2166
  #t;
2158
2167
  #n;
@@ -2169,7 +2178,7 @@ var Tt = class {
2169
2178
  this.#e = this.store.events.clearOverlay.on(() => {
2170
2179
  t(void 0);
2171
2180
  }), this.#t = this.store.events.checkOverlay.on(() => {
2172
- t(Ge.find(this.store.state.options.get(), e));
2181
+ t(We.find(this.store.state.options.get(), e));
2173
2182
  }), this.#n = this.store.events.change.on(() => {
2174
2183
  let e = this.store.state.showOverlayOn.get();
2175
2184
  if (!e) return;
@@ -2207,8 +2216,8 @@ var Tt = class {
2207
2216
  }
2208
2217
  };
2209
2218
  //#endregion
2210
- //#region ../../common/core/src/features/overlay/suggestionNavigation.ts
2211
- function Et(e, t, n) {
2219
+ //#region ../../core/src/features/overlay/suggestionNavigation.ts
2220
+ function Tt(e, t, n) {
2212
2221
  if (n === 0) return {
2213
2222
  action: "none",
2214
2223
  index: t
@@ -2237,34 +2246,34 @@ function Et(e, t, n) {
2237
2246
  }
2238
2247
  }
2239
2248
  //#endregion
2240
- //#region ../../common/core/src/features/store/Store.ts
2241
- var Dt = class {
2242
- key = new Be();
2249
+ //#region ../../core/src/features/store/Store.ts
2250
+ var Et = class {
2251
+ key = new ze();
2243
2252
  blocks;
2244
2253
  nodes = {
2245
- focus: new Ke(void 0, this),
2246
- input: new Ke(void 0, this)
2254
+ focus: new Ge(void 0, this),
2255
+ input: new Ge(void 0, this)
2247
2256
  };
2248
2257
  state;
2249
2258
  slot;
2250
- events = Me();
2259
+ events = je();
2251
2260
  refs = {
2252
2261
  container: null,
2253
2262
  overlay: null
2254
2263
  };
2255
2264
  controllers = {
2256
- overlay: new Tt(this),
2257
- focus: new at(this),
2258
- keydown: new ft(this),
2259
- system: new it(this),
2260
- textSelection: new ut(this),
2261
- contentEditable: new nt(this),
2262
- drag: new $e(this)
2265
+ overlay: new wt(this),
2266
+ focus: new it(this),
2267
+ keydown: new dt(this),
2268
+ system: new rt(this),
2269
+ textSelection: new lt(this),
2270
+ contentEditable: new tt(this),
2271
+ drag: new Qe(this)
2263
2272
  };
2264
- lifecycle = new St(this);
2273
+ lifecycle = new xt(this);
2265
2274
  _defaultSpan;
2266
2275
  constructor(e) {
2267
- this._defaultSpan = e.defaultSpan, this.blocks = new ze(e.createUseHook), this.state = Ae({
2276
+ this._defaultSpan = e.defaultSpan, this.blocks = new Re(e.createUseHook), this.state = ke({
2268
2277
  tokens: [],
2269
2278
  parser: void 0,
2270
2279
  previousValue: void 0,
@@ -2311,7 +2320,7 @@ var Dt = class {
2311
2320
  applyValue(e) {
2312
2321
  let t = this.state.onChange.get();
2313
2322
  if (!t) return;
2314
- let n = O(this, e);
2323
+ let n = k(this, e);
2315
2324
  this.state.tokens.set(n), this.state.previousValue.set(e), t(e);
2316
2325
  }
2317
2326
  createHandler() {
@@ -2328,7 +2337,7 @@ var Dt = class {
2328
2337
  }
2329
2338
  };
2330
2339
  }
2331
- }, Ot = class {
2340
+ }, Dt = class {
2332
2341
  ref;
2333
2342
  #e;
2334
2343
  #t;
@@ -2364,13 +2373,13 @@ var Dt = class {
2364
2373
  return this.#t.slot?.content;
2365
2374
  }
2366
2375
  get depth() {
2367
- return E(this.#e.state.tokens.get(), this.#t)?.depth ?? 0;
2376
+ return D(this.#e.state.tokens.get(), this.#t)?.depth ?? 0;
2368
2377
  }
2369
2378
  get hasChildren() {
2370
2379
  return this.#t.children.some((e) => e.type === "mark");
2371
2380
  }
2372
2381
  get parent() {
2373
- return E(this.#e.state.tokens.get(), this.#t)?.parent;
2382
+ return D(this.#e.state.tokens.get(), this.#t)?.parent;
2374
2383
  }
2375
2384
  get tokens() {
2376
2385
  return this.#t.children;
@@ -2382,13 +2391,13 @@ var Dt = class {
2382
2391
  #r() {
2383
2392
  this.#e.events.change();
2384
2393
  }
2385
- }, kt = (e) => {
2394
+ }, Ot = (e) => {
2386
2395
  let t = (t) => e.on(t), n = () => e.get();
2387
2396
  return () => u(t, n, n);
2388
2397
  };
2389
2398
  //#endregion
2390
2399
  //#region src/lib/hooks/useCoreFeatures.ts
2391
- function At(e, t) {
2400
+ function kt(e, t) {
2392
2401
  a(t, () => e.createHandler(), [e]), i(() => (e.lifecycle.enable({ getTrigger: (e) => e.overlay?.trigger }), () => e.lifecycle.disable()), []);
2393
2402
  let n = e.state.value.use(), r = e.state.Mark.use(), s = e.state.options.use(), c = s?.some((e) => e.Mark != null), l = r || c ? s : void 0, u = e.state.tokens.use();
2394
2403
  i(() => {
@@ -2401,151 +2410,154 @@ function At(e, t) {
2401
2410
  }
2402
2411
  //#endregion
2403
2412
  //#region src/lib/providers/StoreContext.ts
2404
- var K = e(void 0);
2405
- K.displayName = "StoreContext";
2406
- function q() {
2407
- let e = r(K);
2413
+ var q = e(void 0);
2414
+ q.displayName = "StoreContext";
2415
+ function J() {
2416
+ let e = r(q);
2408
2417
  if (e === void 0) throw Error("Store not found. Make sure to wrap component in StoreContext.");
2409
2418
  return e;
2410
2419
  }
2411
- var J = {
2412
- Container: "_Container_5gsai_1",
2413
- Icon: "_Icon_5gsai_5",
2414
- IconGrip: "_IconGrip_5gsai_16",
2415
- IconAdd: "_IconAdd_5gsai_20",
2416
- IconDuplicate: "_IconDuplicate_5gsai_21",
2417
- IconTrash: "_IconTrash_5gsai_22",
2418
- Block: "_Block_5gsai_38",
2419
- SidePanel: "_SidePanel_5gsai_48",
2420
- SidePanelVisible: "_SidePanelVisible_5gsai_60",
2421
- SidePanelAlways: "_SidePanelAlways_5gsai_65",
2422
- GripButton: "_GripButton_5gsai_71",
2423
- GripButtonDragging: "_GripButtonDragging_5gsai_90",
2424
- BlockMenu: "_BlockMenu_5gsai_94",
2425
- BlockMenuItem: "_BlockMenuItem_5gsai_106",
2426
- BlockMenuItemDelete: "_BlockMenuItemDelete_5gsai_123",
2427
- BlockMenuSeparator: "_BlockMenuSeparator_5gsai_131",
2428
- DropIndicator: "_DropIndicator_5gsai_137",
2429
- Suggestions: "_Suggestions_5gsai_153",
2430
- suggestionActive: "_suggestionActive_5gsai_181"
2431
- }, Y = t(({ token: e }) => {
2432
- let t = q().blocks.get(e), n = t.state.menuOpen.use(), r = t.state.menuPosition.use();
2433
- return n ? /* @__PURE__ */ f("div", {
2420
+ var Y = {
2421
+ Container: "_Container_jix5i_1",
2422
+ Icon: "_Icon_jix5i_5",
2423
+ IconGrip: "_IconGrip_jix5i_16",
2424
+ IconAdd: "_IconAdd_jix5i_20",
2425
+ IconDuplicate: "_IconDuplicate_jix5i_21",
2426
+ IconTrash: "_IconTrash_jix5i_22",
2427
+ Popup: "_Popup_jix5i_38",
2428
+ PopupList: "_PopupList_jix5i_52",
2429
+ PopupItem: "_PopupItem_jix5i_60",
2430
+ PopupItemActive: "_PopupItemActive_jix5i_71",
2431
+ Block: "_Block_jix5i_76",
2432
+ SidePanel: "_SidePanel_jix5i_86",
2433
+ SidePanelVisible: "_SidePanelVisible_jix5i_98",
2434
+ SidePanelAlways: "_SidePanelAlways_jix5i_103",
2435
+ GripButton: "_GripButton_jix5i_109",
2436
+ GripButtonDragging: "_GripButtonDragging_jix5i_128",
2437
+ DropIndicator: "_DropIndicator_jix5i_132"
2438
+ }, At = ({ children: e }) => /* @__PURE__ */ d("ul", {
2439
+ className: Y.PopupList,
2440
+ children: e
2441
+ }), X = ({ onClick: e, onMouseDown: t, active: n, children: r }) => {
2442
+ let a = c(null);
2443
+ return i(() => {
2444
+ n && a.current?.scrollIntoView(!1);
2445
+ }, [n]), /* @__PURE__ */ d("li", {
2446
+ ref: a,
2447
+ className: m(Y.PopupItem, n && Y.PopupItemActive),
2448
+ onClick: e,
2449
+ onMouseDown: t,
2450
+ children: r
2451
+ });
2452
+ }, jt = ({ ref: e, style: t, children: n }) => /* @__PURE__ */ d("div", {
2453
+ ref: e,
2454
+ className: Y.Popup,
2455
+ style: t,
2456
+ children: n
2457
+ }), Mt = t(({ token: e }) => {
2458
+ let t = J().blocks.get(e), n = t.state.menuOpen.use(), r = t.state.menuPosition.use();
2459
+ return n ? /* @__PURE__ */ d(jt, {
2434
2460
  ref: (e) => t.attachMenu(e),
2435
- className: J.BlockMenu,
2436
2461
  style: {
2437
2462
  top: r.top,
2438
2463
  left: r.left
2439
2464
  },
2440
- children: [
2441
- /* @__PURE__ */ f("button", {
2442
- type: "button",
2443
- className: J.BlockMenuItem,
2444
- onMouseDown: (e) => {
2445
- e.preventDefault(), t.addBlock();
2446
- },
2447
- children: [/* @__PURE__ */ d("span", { className: m(J.Icon, J.IconAdd) }), /* @__PURE__ */ d("span", { children: "Add below" })]
2465
+ children: /* @__PURE__ */ f(At, { children: [
2466
+ /* @__PURE__ */ f(X, {
2467
+ onClick: () => t.addBlock(),
2468
+ children: [/* @__PURE__ */ d("span", { className: m(Y.Icon, Y.IconAdd) }), /* @__PURE__ */ d("span", { children: "Add below" })]
2448
2469
  }),
2449
- /* @__PURE__ */ f("button", {
2450
- type: "button",
2451
- className: J.BlockMenuItem,
2452
- onMouseDown: (e) => {
2453
- e.preventDefault(), t.duplicateBlock();
2454
- },
2455
- children: [/* @__PURE__ */ d("span", { className: m(J.Icon, J.IconDuplicate) }), /* @__PURE__ */ d("span", { children: "Duplicate" })]
2470
+ /* @__PURE__ */ f(X, {
2471
+ onClick: () => t.duplicateBlock(),
2472
+ children: [/* @__PURE__ */ d("span", { className: m(Y.Icon, Y.IconDuplicate) }), /* @__PURE__ */ d("span", { children: "Duplicate" })]
2456
2473
  }),
2457
- /* @__PURE__ */ d("div", { className: J.BlockMenuSeparator }),
2458
- /* @__PURE__ */ f("button", {
2459
- type: "button",
2460
- className: m(J.BlockMenuItem, J.BlockMenuItemDelete),
2461
- onMouseDown: (e) => {
2462
- e.preventDefault(), t.deleteBlock();
2463
- },
2464
- children: [/* @__PURE__ */ d("span", { className: m(J.Icon, J.IconTrash) }), /* @__PURE__ */ d("span", { children: "Delete" })]
2474
+ /* @__PURE__ */ f(X, {
2475
+ onClick: () => t.deleteBlock(),
2476
+ children: [/* @__PURE__ */ d("span", { className: m(Y.Icon, Y.IconTrash) }), /* @__PURE__ */ d("span", { children: "Delete" })]
2465
2477
  })
2466
- ]
2478
+ ] })
2467
2479
  }) : null;
2468
2480
  });
2469
- Y.displayName = "BlockMenu";
2481
+ Mt.displayName = "BlockMenu";
2470
2482
  //#endregion
2471
2483
  //#region src/components/DragHandle.tsx
2472
- var jt = `${J.Icon} ${J.IconGrip}`, Mt = t(({ token: e, blockIndex: t }) => {
2473
- let n = q(), r = n.state.readOnly.use(), i = n.state.drag.use(), a = n.blocks.get(e), o = a.state.isDragging.use(), c = a.state.isHovered.use(), l = s(() => et(i), [i]);
2484
+ var Nt = `${Y.Icon} ${Y.IconGrip}`, Pt = t(({ token: e, blockIndex: t }) => {
2485
+ let n = J(), r = n.state.readOnly.use(), i = n.state.drag.use(), a = n.blocks.get(e), o = a.state.isDragging.use(), c = a.state.isHovered.use(), l = s(() => $e(i), [i]);
2474
2486
  return r ? null : /* @__PURE__ */ d("div", {
2475
- className: m(J.SidePanel, l ? J.SidePanelAlways : c && !o && J.SidePanelVisible),
2487
+ className: m(Y.SidePanel, l ? Y.SidePanelAlways : c && !o && Y.SidePanelVisible),
2476
2488
  children: /* @__PURE__ */ d("button", {
2477
2489
  ref: (e) => a.attachGrip(e, t, n.controllers.drag),
2478
2490
  type: "button",
2479
2491
  draggable: !0,
2480
- className: m(J.GripButton, o && J.GripButtonDragging),
2492
+ className: m(Y.GripButton, o && Y.GripButtonDragging),
2481
2493
  "aria-label": "Drag to reorder or click for options",
2482
- children: /* @__PURE__ */ d("span", { className: jt })
2494
+ children: /* @__PURE__ */ d("span", { className: Nt })
2483
2495
  })
2484
2496
  });
2485
2497
  });
2486
- Mt.displayName = "DragHandle";
2498
+ Pt.displayName = "DragHandle";
2487
2499
  //#endregion
2488
2500
  //#region src/components/DropIndicator.tsx
2489
- var X = t(({ token: e, position: t }) => q().blocks.get(e).state.dropPosition.use() === t ? /* @__PURE__ */ d("div", {
2490
- className: J.DropIndicator,
2501
+ var Z = t(({ token: e, position: t }) => J().blocks.get(e).state.dropPosition.use() === t ? /* @__PURE__ */ d("div", {
2502
+ className: Y.DropIndicator,
2491
2503
  style: t === "before" ? { top: -1 } : { bottom: -1 }
2492
2504
  }) : null);
2493
- X.displayName = "DropIndicator";
2505
+ Z.displayName = "DropIndicator";
2494
2506
  //#endregion
2495
2507
  //#region src/lib/providers/TokenContext.ts
2496
- var Z = e(void 0);
2497
- Z.displayName = "TokenProvider";
2498
- function Nt() {
2499
- let e = r(Z);
2508
+ var Q = e(void 0);
2509
+ Q.displayName = "TokenProvider";
2510
+ function Ft() {
2511
+ let e = r(Q);
2500
2512
  if (e === void 0) throw Error("Token not found. Make sure to wrap component in TokenContext.Provider.");
2501
2513
  return e;
2502
2514
  }
2503
2515
  //#endregion
2504
2516
  //#region src/components/Token.tsx
2505
- var Q = t(({ mark: e }) => {
2506
- let t = q(), [n, r] = t.slot.mark.use(e);
2507
- return /* @__PURE__ */ d(Z, {
2517
+ var $ = t(({ mark: e }) => {
2518
+ let t = J(), [n, r] = t.slot.mark.use(e);
2519
+ return /* @__PURE__ */ d(Q, {
2508
2520
  value: e,
2509
2521
  children: /* @__PURE__ */ d(n, {
2510
- children: e.type === "mark" && e.children.length > 0 ? e.children.map((e) => /* @__PURE__ */ d(Q, { mark: e }, t.key.get(e))) : void 0,
2522
+ children: e.type === "mark" && e.children.length > 0 ? e.children.map((e) => /* @__PURE__ */ d($, { mark: e }, t.key.get(e))) : void 0,
2511
2523
  ...r
2512
2524
  })
2513
2525
  });
2514
2526
  });
2515
- Q.displayName = "Token";
2527
+ $.displayName = "Token";
2516
2528
  //#endregion
2517
2529
  //#region src/components/Block.tsx
2518
- var Pt = t(({ token: e, blockIndex: t }) => {
2519
- let n = q(), [r, i] = n.slot.block.use(), a = n.blocks.get(e), o = a.state.isDragging.use();
2530
+ var It = t(({ token: e, blockIndex: t }) => {
2531
+ let n = J(), [r, i] = n.slot.block.use(), a = n.blocks.get(e), o = a.state.isDragging.use();
2520
2532
  return /* @__PURE__ */ f(r, {
2521
2533
  ref: (e) => a.attachContainer(e, t, n.controllers.drag),
2522
2534
  "data-testid": "block",
2523
2535
  ...i,
2524
- className: J.Block,
2536
+ className: Y.Block,
2525
2537
  style: { opacity: o ? .4 : 1 },
2526
2538
  children: [
2527
- /* @__PURE__ */ d(X, {
2539
+ /* @__PURE__ */ d(Z, {
2528
2540
  token: e,
2529
2541
  position: "before"
2530
2542
  }),
2531
- /* @__PURE__ */ d(Mt, {
2543
+ /* @__PURE__ */ d(Pt, {
2532
2544
  token: e,
2533
2545
  blockIndex: t
2534
2546
  }),
2535
- /* @__PURE__ */ d(Q, { mark: e }),
2536
- /* @__PURE__ */ d(X, {
2547
+ /* @__PURE__ */ d($, { mark: e }),
2548
+ /* @__PURE__ */ d(Z, {
2537
2549
  token: e,
2538
2550
  position: "after"
2539
2551
  }),
2540
- /* @__PURE__ */ d(Y, { token: e })
2552
+ /* @__PURE__ */ d(Mt, { token: e })
2541
2553
  ]
2542
2554
  });
2543
2555
  });
2544
- Pt.displayName = "Block";
2556
+ It.displayName = "Block";
2545
2557
  //#endregion
2546
2558
  //#region src/components/Container.tsx
2547
- var Ft = t(() => {
2548
- let e = q(), t = e.state.drag.use(), n = e.state.tokens.use(), r = e.state.className.use(), i = e.state.style.use(), a = e.state.readOnly.use(), o = e.key, s = e.refs, [c, l] = e.slot.container.use();
2559
+ var Lt = t(() => {
2560
+ let e = J(), t = e.state.drag.use(), n = e.state.tokens.use(), r = e.state.className.use(), i = e.state.style.use(), a = e.state.readOnly.use(), o = e.key, s = e.refs, [c, l] = e.slot.container.use();
2549
2561
  return /* @__PURE__ */ d(c, {
2550
2562
  ref: (e) => s.container = e,
2551
2563
  ...l,
@@ -2554,24 +2566,24 @@ var Ft = t(() => {
2554
2566
  paddingLeft: 24,
2555
2567
  ...i
2556
2568
  } : i,
2557
- children: t ? n.map((e, t) => /* @__PURE__ */ d(Pt, {
2569
+ children: t ? n.map((e, t) => /* @__PURE__ */ d(It, {
2558
2570
  token: e,
2559
2571
  blockIndex: t
2560
- }, o.get(e))) : n.map((e) => /* @__PURE__ */ d(Q, { mark: e }, o.get(e)))
2572
+ }, o.get(e))) : n.map((e) => /* @__PURE__ */ d($, { mark: e }, o.get(e)))
2561
2573
  });
2562
2574
  });
2563
- Ft.displayName = "Container";
2575
+ Lt.displayName = "Container";
2564
2576
  //#endregion
2565
2577
  //#region src/lib/hooks/useOverlay.tsx
2566
- function It() {
2567
- let e = q(), t = e.state.overlayMatch.use();
2578
+ function Rt() {
2579
+ let e = J(), t = e.state.overlayMatch.use();
2568
2580
  if (!t) throw Error("useOverlay requires an active overlay match");
2569
- let r = s(() => F.getAbsolutePosition(), [t]), i = n(() => e.events.clearOverlay(), []);
2581
+ let r = s(() => I.getAbsolutePosition(), [t]), i = n(() => e.events.clearOverlay(), []);
2570
2582
  return {
2571
2583
  match: t,
2572
2584
  style: r,
2573
2585
  select: n((n) => {
2574
- let r = wt(t, n.value, n.meta);
2586
+ let r = Ct(t, n.value, n.meta);
2575
2587
  e.events.select({
2576
2588
  mark: r,
2577
2589
  match: t
@@ -2590,15 +2602,15 @@ function It() {
2590
2602
  }
2591
2603
  //#endregion
2592
2604
  //#region src/components/Suggestions/Suggestions.tsx
2593
- var Lt = () => {
2594
- let e = q(), { match: t, select: n, style: r, ref: a } = It(), [o, u] = l(NaN), f = t.option.overlay?.data ?? [], p = s(() => Ct(f, t.value), [t.value, f]), m = p.length, h = c(o);
2605
+ var zt = () => {
2606
+ let e = J(), { match: t, select: n, style: r, ref: a } = Rt(), [o, u] = l(NaN), f = t.option.overlay?.data ?? [], p = s(() => St(f, t.value), [t.value, f]), m = p.length, h = c(o);
2595
2607
  h.current = o;
2596
2608
  let g = c(p);
2597
2609
  return g.current = p, i(() => {
2598
2610
  let t = e.refs.container;
2599
2611
  if (!t) return;
2600
2612
  let r = (e) => {
2601
- let t = Et(e.key, h.current, m);
2613
+ let t = Tt(e.key, h.current, m);
2602
2614
  switch (t.action) {
2603
2615
  case "up":
2604
2616
  case "down":
@@ -2617,41 +2629,32 @@ var Lt = () => {
2617
2629
  }
2618
2630
  };
2619
2631
  return t.addEventListener("keydown", r), () => t.removeEventListener("keydown", r);
2620
- }, [m, n]), p.length ? /* @__PURE__ */ d("ul", {
2621
- ref: (e) => {
2622
- a.current = e;
2623
- },
2624
- className: J.Suggestions,
2632
+ }, [m, n]), p.length ? /* @__PURE__ */ d(jt, {
2633
+ ref: a,
2625
2634
  style: r,
2626
- children: p.map((e, t) => {
2627
- let r = t === o ? J.suggestionActive : void 0;
2628
- return /* @__PURE__ */ d("li", {
2629
- ref: (e) => {
2630
- r && e && e.scrollIntoView(!1);
2631
- },
2632
- className: r,
2633
- onClick: (r) => n({
2634
- value: e,
2635
- meta: t.toString()
2636
- }),
2637
- children: e
2638
- }, e);
2639
- })
2635
+ children: /* @__PURE__ */ d(At, { children: p.map((e, t) => /* @__PURE__ */ d(X, {
2636
+ active: t === o,
2637
+ onClick: () => n({
2638
+ value: e,
2639
+ meta: t.toString()
2640
+ }),
2641
+ children: e
2642
+ }, e)) })
2640
2643
  }) : null;
2641
- }, Rt = t(() => {
2642
- let e = q(), t = e.state.overlayMatch.use(), n = s(() => t ? e.key.get(t.option) : void 0, [t]), [r, i] = e.slot.overlay.use(t?.option, Lt);
2644
+ }, Bt = t(() => {
2645
+ let e = J(), t = e.state.overlayMatch.use(), n = s(() => t ? e.key.get(t.option) : void 0, [t]), [r, i] = e.slot.overlay.use(t?.option, zt);
2643
2646
  if (n) return /* @__PURE__ */ d(r, { ...i }, n);
2644
2647
  });
2645
- Rt.displayName = "OverlayRenderer";
2648
+ Bt.displayName = "OverlayRenderer";
2646
2649
  //#endregion
2647
2650
  //#region src/components/Span.tsx
2648
- var $ = (e) => /* @__PURE__ */ d("span", {});
2651
+ var Vt = (e) => /* @__PURE__ */ d("span", {});
2649
2652
  //#endregion
2650
2653
  //#region src/components/MarkedInput.tsx
2651
- function zt(e) {
2652
- let { ref: t } = e, n = m(J.Container, e.className, e.slotProps?.container?.className), r = h(e.style, e.slotProps?.container?.style), [i] = l(() => new Dt({
2653
- createUseHook: kt,
2654
- defaultSpan: $
2654
+ function Ht(e) {
2655
+ let { ref: t } = e, n = m(Y.Container, e.className, e.slotProps?.container?.className), r = h(e.style, e.slotProps?.container?.style), [i] = l(() => new Et({
2656
+ createUseHook: Ot,
2657
+ defaultSpan: Vt
2655
2658
  }));
2656
2659
  return i.state.set({
2657
2660
  value: e.value,
@@ -2668,31 +2671,31 @@ function zt(e) {
2668
2671
  style: r,
2669
2672
  slots: e.slots,
2670
2673
  slotProps: e.slotProps
2671
- }), At(i, t), /* @__PURE__ */ f(K, {
2674
+ }), kt(i, t), /* @__PURE__ */ f(q, {
2672
2675
  value: i,
2673
- children: [/* @__PURE__ */ d(Ft, {}), /* @__PURE__ */ d(Rt, {})]
2676
+ children: [/* @__PURE__ */ d(Lt, {}), /* @__PURE__ */ d(Bt, {})]
2674
2677
  });
2675
2678
  }
2676
2679
  //#endregion
2677
2680
  //#region src/lib/hooks/useMark.tsx
2678
- var Bt = (e = {}) => {
2679
- let t = q(), n = Nt();
2681
+ var Ut = (e = {}) => {
2682
+ let t = J(), n = Ft();
2680
2683
  if (n.type !== "mark") throw Error("useMark must be called within a mark token context");
2681
- let r = c(null), [a] = l(() => new Ot({
2684
+ let r = c(null), [a] = l(() => new Dt({
2682
2685
  ref: r,
2683
2686
  store: t,
2684
2687
  token: n
2685
2688
  }));
2686
- Vt(r, e, n);
2689
+ Wt(r, e, n);
2687
2690
  let o = t.state.readOnly.use();
2688
2691
  return i(() => {
2689
2692
  a.readOnly = o;
2690
2693
  }, [o]), a;
2691
2694
  };
2692
- function Vt(e, t, n) {
2695
+ function Wt(e, t, n) {
2693
2696
  i(() => {
2694
2697
  !t.controlled && e.current && (e.current.textContent = n.content);
2695
2698
  }, []);
2696
2699
  }
2697
2700
  //#endregion
2698
- export { Ot as MarkHandler, zt as MarkedInput, $ as Span, w as annotate, Se as denote, Bt as useMark, It as useOverlay };
2701
+ export { Dt as MarkHandler, Ht as MarkedInput, Vt as Span, T as annotate, xe as denote, Ut as useMark, Rt as useOverlay };