@chaibuilder/sdk 2.6.0 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -21,7 +21,7 @@ import { isObject } from "@rjsf/utils";
21
21
  import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
22
22
  import { toast, Toaster } from "sonner";
23
23
  import { useTranslation, initReactI18next } from "react-i18next";
24
- import { useTranslation as Ve } from "react-i18next";
24
+ import { useTranslation as He } from "react-i18next";
25
25
  import Fuse from "fuse.js";
26
26
  import UndoManager from "undo-manager";
27
27
  import Link from "@tiptap/extension-link";
@@ -37,7 +37,7 @@ import { useFeature } from "flagged";
37
37
  import { parse, stringify } from "himalaya";
38
38
  import { Tree } from "react-arborist";
39
39
  import i18n from "i18next";
40
- import { default as We } from "i18next";
40
+ import { default as Ue } from "i18next";
41
41
  import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
42
42
  import tailwindForms from "@tailwindcss/forms";
43
43
  import tailwindTypography from "@tailwindcss/typography";
@@ -51,7 +51,6 @@ import { limitShift, flip, size } from "@floating-ui/dom";
51
51
  import { useFloating, shift } from "@floating-ui/react-dom";
52
52
  import ReactDOM from "react-dom";
53
53
  import { Provider as Provider$1 } from "react-wrap-balancer";
54
- import { Resizable } from "re-resizable";
55
54
  const ICON_CLASS = "h-3 w-3 stroke-[2]", TypeIcon = (o) => {
56
55
  const r = useRegisteredChaiBlocks(), n = get(r, [o == null ? void 0 : o.type, "icon"]);
57
56
  return n ? React__default.createElement(n, { className: ICON_CLASS }) : /* @__PURE__ */ jsx(BoxModelIcon, { className: ICON_CLASS });
@@ -348,8 +347,8 @@ function insertBlocksAtPosition(o, r, n, a) {
348
347
  }), l.unshift(m), i = i.map((x) => {
349
348
  if (x._id === n) {
350
349
  const f = { ...x, content: "" };
351
- return Object.keys(f).forEach((k) => {
352
- k.startsWith("content-") && (f[k] = "");
350
+ return Object.keys(f).forEach((y) => {
351
+ y.startsWith("content-") && (f[y] = "");
353
352
  }), f;
354
353
  }
355
354
  return x;
@@ -484,8 +483,8 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
484
483
  m && "content" in m && (n = n.map((x) => {
485
484
  if (x._id === u) {
486
485
  const f = { ...x, content: h.content };
487
- return Object.keys(h).forEach((k) => {
488
- k.startsWith("content-") && (f[k] = h[k]);
486
+ return Object.keys(h).forEach((y) => {
487
+ y.startsWith("content-") && (f[y] = h[y]);
489
488
  }), f;
490
489
  }
491
490
  return x;
@@ -839,50 +838,50 @@ const undoRedoStateAtom = atom({
839
838
  updateBlocksProps: c
840
839
  } = useBlocksStoreManager();
841
840
  return {
842
- moveBlocks: (f, k, b) => {
843
- const A = map(f, (_) => {
844
- const w = r.find((B) => B._id === _)._parent || null, v = r.filter((B) => w ? B._parent === w : !B._parent).map((B) => B._id).indexOf(_);
845
- return { _id: _, oldParent: w, oldPosition: v };
846
- }), E = A.find(({ _id: _ }) => _ === f[0]);
847
- E && E.oldParent === k && E.oldPosition === b || (i(f, k, b), o({
848
- undo: () => each(A, ({ _id: _, oldParent: N, oldPosition: w }) => {
849
- i([_], N, w);
841
+ moveBlocks: (f, y, b) => {
842
+ const A = map(f, (E) => {
843
+ const w = r.find((j) => j._id === E)._parent || null, k = r.filter((j) => w ? j._parent === w : !j._parent).map((j) => j._id).indexOf(E);
844
+ return { _id: E, oldParent: w, oldPosition: k };
845
+ }), _ = A.find(({ _id: E }) => E === f[0]);
846
+ _ && _.oldParent === y && _.oldPosition === b || (i(f, y, b), o({
847
+ undo: () => each(A, ({ _id: E, oldParent: N, oldPosition: w }) => {
848
+ i([E], N, w);
850
849
  }),
851
- redo: () => i(f, k, b)
850
+ redo: () => i(f, y, b)
852
851
  }));
853
852
  },
854
- addBlocks: (f, k, b) => {
855
- a(f, k, b), o({
853
+ addBlocks: (f, y, b) => {
854
+ a(f, y, b), o({
856
855
  undo: () => l(map(f, "_id")),
857
- redo: () => a(f, k, b)
856
+ redo: () => a(f, y, b)
858
857
  });
859
858
  },
860
859
  removeBlocks: (f) => {
861
- var E;
862
- const k = (E = first(f)) == null ? void 0 : E._parent, A = r.filter((_) => k ? _._parent === k : !_._parent).indexOf(first(f));
860
+ var _;
861
+ const y = (_ = first(f)) == null ? void 0 : _._parent, A = r.filter((E) => y ? E._parent === y : !E._parent).indexOf(first(f));
863
862
  l(map(f, "_id")), o({
864
- undo: () => a(f, k, A),
863
+ undo: () => a(f, y, A),
865
864
  redo: () => l(map(f, "_id"))
866
865
  });
867
866
  },
868
- updateBlocks: (f, k, b) => {
867
+ updateBlocks: (f, y, b) => {
869
868
  let A = [];
870
869
  if (b)
871
- A = map(f, (E) => ({ _id: E, ...b }));
870
+ A = map(f, (_) => ({ _id: _, ...b }));
872
871
  else {
873
- const E = keys(k);
874
- A = map(f, (_) => {
875
- const N = r.find((y) => y._id === _), w = { _id: _ };
876
- return each(E, (y) => w[y] = N[y]), w;
872
+ const _ = keys(y);
873
+ A = map(f, (E) => {
874
+ const N = r.find((S) => S._id === E), w = { _id: E };
875
+ return each(_, (S) => w[S] = N[S]), w;
877
876
  });
878
877
  }
879
- c(map(f, (E) => ({ _id: E, ...k }))), o({
878
+ c(map(f, (_) => ({ _id: _, ...y }))), o({
880
879
  undo: () => c(A),
881
- redo: () => c(map(f, (E) => ({ _id: E, ...k })))
880
+ redo: () => c(map(f, (_) => ({ _id: _, ...y })))
882
881
  });
883
882
  },
884
- updateBlocksRuntime: (f, k) => {
885
- c(map(f, (b) => ({ _id: b, ...k })));
883
+ updateBlocksRuntime: (f, y) => {
884
+ c(map(f, (b) => ({ _id: b, ...y })));
886
885
  },
887
886
  setNewBlocks: (f) => {
888
887
  n(f), o({
@@ -891,12 +890,12 @@ const undoRedoStateAtom = atom({
891
890
  });
892
891
  },
893
892
  updateMultipleBlocksProps: (f) => {
894
- let k = [];
895
- k = map(f, (b) => {
896
- const A = keys(b), E = r.find((N) => N._id === b._id), _ = {};
897
- return each(A, (N) => _[N] = E[N]), _;
893
+ let y = [];
894
+ y = map(f, (b) => {
895
+ const A = keys(b), _ = r.find((N) => N._id === b._id), E = {};
896
+ return each(A, (N) => E[N] = _[N]), E;
898
897
  }), c(f), o({
899
- undo: () => c(k),
898
+ undo: () => c(y),
900
899
  redo: () => c(f)
901
900
  });
902
901
  }
@@ -908,9 +907,9 @@ const undoRedoStateAtom = atom({
908
907
  for (let x = 0; x < i.length; x++) {
909
908
  const { _id: f } = i[x];
910
909
  i[x]._id = generateUUID();
911
- const k = filter(i, { _parent: f });
912
- for (let b = 0; b < k.length; b++)
913
- k[b]._parent = i[x]._id;
910
+ const y = filter(i, { _parent: f });
911
+ for (let b = 0; b < y.length; b++)
912
+ y[b]._parent = i[x]._id;
914
913
  }
915
914
  const p = first(i);
916
915
  let u, g;
@@ -921,8 +920,8 @@ const undoRedoStateAtom = atom({
921
920
  return { addCoreBlock: useCallback(
922
921
  (i, c, d) => {
923
922
  if (has(i, "blocks")) {
924
- const k = i.blocks;
925
- return a(k, c, d);
923
+ const y = i.blocks;
924
+ return a(y, c, d);
926
925
  }
927
926
  const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
928
927
  _type: i.type,
@@ -2364,44 +2363,44 @@ const getBlockWithChildren = (o, r) => {
2364
2363
  })
2365
2364
  ), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2366
2365
  const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m, x) => {
2367
- const f = cloneDeep(x.find((k) => k._id === m));
2368
- for (const k in f) {
2369
- const b = f[k];
2366
+ const f = cloneDeep(x.find((y) => y._id === m));
2367
+ for (const y in f) {
2368
+ const b = f[y];
2370
2369
  if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
2371
- const { baseClasses: A, classes: E } = getSplitChaiClasses(b);
2372
- f[k] = compact(flattenDeep([A, E])).join(" ");
2370
+ const { baseClasses: A, classes: _ } = getSplitChaiClasses(b);
2371
+ f[y] = compact(flattenDeep([A, _])).join(" ");
2373
2372
  } else
2374
- k !== "_id" && delete f[k];
2373
+ y !== "_id" && delete f[y];
2375
2374
  }
2376
2375
  return f;
2377
2376
  };
2378
2377
  return {
2379
2378
  askAi: useCallback(
2380
- async (m, x, f, k) => {
2379
+ async (m, x, f, y) => {
2381
2380
  if (l) {
2382
2381
  r(!0), a(null);
2383
2382
  try {
2384
2383
  const b = p === u ? "" : p;
2385
2384
  console.log("prompt", f);
2386
- const A = f.toLowerCase().includes("translate the content"), E = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p, A) : [h(x, d)], _ = await l(m, addLangToPrompt(f, g, m), E, b), { blocks: N, error: w } = _;
2385
+ const A = f.toLowerCase().includes("translate the content"), _ = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p, A) : [h(x, d)], E = await l(m, addLangToPrompt(f, g, m), _, b), { blocks: N, error: w } = E;
2387
2386
  if (w) {
2388
2387
  a(w);
2389
2388
  return;
2390
2389
  }
2391
2390
  if (m === "styles") {
2392
- const y = N.map((v) => {
2393
- for (const B in v)
2394
- B !== "_id" && (v[B] = `${STYLES_KEY},${v[B]}`);
2395
- return v;
2391
+ const S = N.map((k) => {
2392
+ for (const j in k)
2393
+ j !== "_id" && (k[j] = `${STYLES_KEY},${k[j]}`);
2394
+ return k;
2396
2395
  });
2397
- c(y);
2396
+ c(S);
2398
2397
  } else
2399
2398
  i(N);
2400
- k && k(_);
2399
+ y && y(E);
2401
2400
  } catch (b) {
2402
2401
  a(b);
2403
2402
  } finally {
2404
- r(!1), k && k();
2403
+ r(!1), y && y();
2405
2404
  }
2406
2405
  }
2407
2406
  },
@@ -2498,7 +2497,7 @@ const getBlockWithChildren = (o, r) => {
2498
2497
  for (const x of h)
2499
2498
  if (x._type === "PartialBlock" || x._type === "GlobalBlock") {
2500
2499
  let f = l(x.partialBlockId);
2501
- x._parent && (f == null ? void 0 : f.length) > 0 && (f = f.map((k) => (isEmpty(k._parent) && set(k, "_parent", x._parent), k))), m = [...m, ...f];
2500
+ x._parent && (f == null ? void 0 : f.length) > 0 && (f = f.map((y) => (isEmpty(y._parent) && set(y, "_parent", x._parent), y))), m = [...m, ...f];
2502
2501
  } else
2503
2502
  m.push(x);
2504
2503
  return m;
@@ -2847,8 +2846,8 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2847
2846
  return useHotkeys(
2848
2847
  "shift+up, shift+down, shift+left, shift+right",
2849
2848
  ({ key: f }) => {
2850
- var k;
2851
- x((k = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : k.toUpperCase());
2849
+ var y;
2850
+ x((y = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : y.toUpperCase());
2852
2851
  },
2853
2852
  { document: a == null ? void 0 : a.contentDocument },
2854
2853
  [x]
@@ -3009,9 +3008,9 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
3009
3008
  }),
3010
3009
  size({
3011
3010
  boundary: u == null ? void 0 : u.body,
3012
- apply({ availableWidth: k, availableHeight: b, elements: A }) {
3011
+ apply({ availableWidth: y, availableHeight: b, elements: A }) {
3013
3012
  Object.assign(A.floating.style, {
3014
- maxWidth: `${Math.max(200, k)}px`,
3013
+ maxWidth: `${Math.max(200, y)}px`,
3015
3014
  maxHeight: `${Math.max(100, b)}px`
3016
3015
  });
3017
3016
  }
@@ -3023,8 +3022,8 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
3023
3022
  const x = get(o, "_parent", null), f = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
3024
3023
  return useEffect(() => {
3025
3024
  if (r) {
3026
- const k = setTimeout(() => m(), 500);
3027
- return () => clearTimeout(k);
3025
+ const y = setTimeout(() => m(), 500);
3026
+ return () => clearTimeout(y);
3028
3027
  } else
3029
3028
  m();
3030
3029
  }, [r]), !r || !o || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
@@ -3034,13 +3033,13 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
3034
3033
  tabIndex: 0,
3035
3034
  ref: h.setFloating,
3036
3035
  style: g,
3037
- onClick: (k) => {
3038
- k.stopPropagation(), k.preventDefault();
3036
+ onClick: (y) => {
3037
+ y.stopPropagation(), y.preventDefault();
3039
3038
  },
3040
- onMouseEnter: (k) => {
3041
- k.stopPropagation(), i(null);
3039
+ onMouseEnter: (y) => {
3040
+ y.stopPropagation(), i(null);
3042
3041
  },
3043
- onKeyDown: (k) => k.stopPropagation(),
3042
+ onKeyDown: (y) => y.stopPropagation(),
3044
3043
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3045
3044
  children: [
3046
3045
  x && /* @__PURE__ */ jsx(
@@ -3504,8 +3503,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3504
3503
  ],
3505
3504
  onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
3506
3505
  onBlur: ({ editor: u, event: g }) => {
3507
- const h = g.relatedTarget, m = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = m == null ? void 0 : m.contains(h), k = x == null ? void 0 : x.contains(h);
3508
- if (!f && !k) {
3506
+ const h = g.relatedTarget, m = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = m == null ? void 0 : m.contains(h), y = x == null ? void 0 : x.contains(h);
3507
+ if (!f && !y) {
3509
3508
  const b = (u == null ? void 0 : u.getHTML()) || "";
3510
3509
  n(b);
3511
3510
  }
@@ -3601,47 +3600,47 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3601
3600
  }
3602
3601
  ), WithBlockTextEditor = memo(
3603
3602
  ({ block: o, children: r }) => {
3604
- const n = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: x } = useLanguages(), [, f] = useSelectedBlockIds(), k = useRef(null), b = l, { blockContent: A, blockType: E } = useMemo(() => {
3605
- var j;
3606
- const v = o._type;
3607
- let B = o[n];
3608
- const S = getRegisteredChaiBlock(o._type);
3609
- return x && ((j = S == null ? void 0 : S.i18nProps) == null ? void 0 : j.includes(n)) && has(o, `${n}-${x}`) && (B = get(o, `${n}-${x}`)), { blockContent: B, blockType: v };
3610
- }, [o, x]), _ = useCallback(
3611
- (v) => {
3612
- var S;
3613
- const B = v || ((S = g.current) == null ? void 0 : S.innerText);
3614
- m([b], { [n]: B }), u(null), c(null), d(-1), f(b ? [b] : []);
3603
+ const n = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: x } = useLanguages(), [, f] = useSelectedBlockIds(), y = useRef(null), b = l, { blockContent: A, blockType: _ } = useMemo(() => {
3604
+ var B;
3605
+ const k = o._type;
3606
+ let j = o[n];
3607
+ const C = getRegisteredChaiBlock(o._type);
3608
+ return x && ((B = C == null ? void 0 : C.i18nProps) == null ? void 0 : B.includes(n)) && has(o, `${n}-${x}`) && (j = get(o, `${n}-${x}`)), { blockContent: j, blockType: k };
3609
+ }, [o, x]), E = useCallback(
3610
+ (k) => {
3611
+ var C;
3612
+ const j = k || ((C = g.current) == null ? void 0 : C.innerText);
3613
+ m([b], { [n]: j }), u(null), c(null), d(-1), f(b ? [b] : []);
3615
3614
  },
3616
3615
  [b, m, c, f, x]
3617
3616
  ), N = useDebouncedCallback(
3618
- (v) => {
3619
- m([b], { [n]: v });
3617
+ (k) => {
3618
+ m([b], { [n]: k });
3620
3619
  },
3621
3620
  [b, o, m, x],
3622
3621
  1e3
3623
3622
  ), w = useCallback(
3624
- (v) => {
3625
- v.preventDefault(), b && (k.current = b), _(), setTimeout(() => {
3626
- const B = k.current;
3627
- k.current = null, f([B]);
3623
+ (k) => {
3624
+ k.preventDefault(), b && (y.current = b), E(), setTimeout(() => {
3625
+ const j = y.current;
3626
+ y.current = null, f([j]);
3628
3627
  }, 100);
3629
3628
  },
3630
3629
  [f, b, x]
3631
3630
  );
3632
3631
  useEffect(() => {
3633
- var C;
3632
+ var v;
3634
3633
  if (!b) return;
3635
- const v = `[data-block-id="${b}"]`, B = i >= 0 ? `[data-block-index="${i}"]` : "", S = a.querySelector(`${v}${B}`);
3636
- S && ((C = S == null ? void 0 : S.classList) == null || C.add("sr-only"), u(S));
3637
- }, [b, E, a, i]);
3638
- const y = useMemo(() => p ? (h(), E === "RichText" ? /* @__PURE__ */ jsx(
3634
+ const k = `[data-block-id="${b}"]`, j = i >= 0 ? `[data-block-index="${i}"]` : "", C = a.querySelector(`${k}${j}`);
3635
+ C && ((v = C == null ? void 0 : C.classList) == null || v.add("sr-only"), u(C));
3636
+ }, [b, _, a, i]);
3637
+ const S = useMemo(() => p ? (h(), _ === "RichText" ? /* @__PURE__ */ jsx(
3639
3638
  RichTextEditor,
3640
3639
  {
3641
3640
  blockContent: A,
3642
3641
  editingElement: p,
3643
3642
  onChange: N,
3644
- onClose: _,
3643
+ onClose: E,
3645
3644
  onEscape: w
3646
3645
  }
3647
3646
  ) : /* @__PURE__ */ jsx(
@@ -3650,13 +3649,13 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3650
3649
  editorRef: g,
3651
3650
  blockContent: A,
3652
3651
  editingElement: p,
3653
- onClose: _,
3652
+ onClose: E,
3654
3653
  onChange: N,
3655
3654
  onEscape: w
3656
3655
  }
3657
- )) : null, [p, b, E, A, _, x]);
3656
+ )) : null, [p, b, _, A, E, x]);
3658
3657
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3659
- y,
3658
+ S,
3660
3659
  r
3661
3660
  ] });
3662
3661
  },
@@ -3689,23 +3688,23 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3689
3688
  blockAtom: r,
3690
3689
  children: n
3691
3690
  }) => {
3692
- const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(r), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom), x = get(c, "component", null), { index: f, key: k } = useContext(RepeaterContext), b = useMemo(
3691
+ const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(r), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom), x = get(c, "component", null), { index: f, key: y } = useContext(RepeaterContext), b = useMemo(
3693
3692
  () => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
3694
3693
  index: f,
3695
- key: k
3694
+ key: y
3696
3695
  }) : applyLanguage(i, d, c),
3697
- [i, d, c, g, m, f, k]
3698
- ), A = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), E = useMemo(
3696
+ [i, d, c, g, m, f, y]
3697
+ ), A = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), _ = useMemo(
3699
3698
  () => u(i._id, getBlockRuntimeProps(i._type)),
3700
3699
  [i._id, i._type, u, getBlockRuntimeProps]
3701
- ), _ = useMemo(
3700
+ ), E = useMemo(
3702
3701
  () => ({
3703
3702
  blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": f },
3704
3703
  inBuilder: !0,
3705
3704
  lang: d || p,
3706
3705
  ...b,
3707
3706
  ...A,
3708
- ...E,
3707
+ ..._,
3709
3708
  ...o
3710
3709
  }),
3711
3710
  [
@@ -3715,13 +3714,13 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3715
3714
  p,
3716
3715
  b,
3717
3716
  A,
3718
- E,
3717
+ _,
3719
3718
  o
3720
3719
  ]
3721
3720
  ), N = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]);
3722
3721
  if (isNull(x) || h.includes(i._id)) return null;
3723
3722
  let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(x, {
3724
- ..._,
3723
+ ...E,
3725
3724
  children: n({
3726
3725
  _id: i._id,
3727
3726
  _type: i._type,
@@ -3733,8 +3732,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3733
3732
  ...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
3734
3733
  })
3735
3734
  }) });
3736
- const y = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: w }) : w;
3737
- return N ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: y }) : y;
3735
+ const S = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: w }) : w;
3736
+ return N ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: S }) : S;
3738
3737
  }, PartialWrapper = ({ children: o, partialBlockId: r }) => {
3739
3738
  const n = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
3740
3739
  (d) => {
@@ -3774,7 +3773,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3774
3773
  );
3775
3774
  return map(l, (c) => {
3776
3775
  const d = a(c._id);
3777
- return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: h, repeaterItems: m, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(m) && m.map((f, k) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: k, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) }, `${u}-${k}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3776
+ return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: h, repeaterItems: m, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(m) && m.map((f, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) }, `${u}-${y}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3778
3777
  });
3779
3778
  }, PageBlocksRenderer = () => {
3780
3779
  const [o] = useBlocksStore();
@@ -3899,11 +3898,11 @@ const CanvasEventsWatcher = () => {
3899
3898
  }, FallbackError = () => /* @__PURE__ */ jsx("div", { className: "h-full w-full rounded-md bg-red-200 p-4 text-red-500", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center", children: [
3900
3899
  /* @__PURE__ */ jsx("p", { className: "font-semibold", children: "Oops! Something went wrong." }),
3901
3900
  /* @__PURE__ */ jsx("p", { children: "Please try again." })
3902
- ] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-CAnkmeVK.js")), CanvasArea = () => {
3901
+ ] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-RwOkFe_0.js")), CanvasArea = () => {
3903
3902
  const [o] = useCodeEditor(), r = useBuilderProp("onError", noop);
3904
3903
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2", children: [
3905
3904
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
3906
- o ? /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(Resizable, { enable: { top: !0, bottom: !1 }, className: "max-h-[400px] min-h-[200px]", children: /* @__PURE__ */ jsx(CodeEditor$1, {}) }) }) : null,
3905
+ o ? /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(CodeEditor$1, {}) }) : null,
3907
3906
  /* @__PURE__ */ jsx(Breadcrumb, {})
3908
3907
  ] }) });
3909
3908
  }, RJSF_EXTENSIONS = {}, registerBlockSettingWidget = (o, r) => {
@@ -4029,19 +4028,19 @@ const CanvasEventsWatcher = () => {
4029
4028
  };
4030
4029
  MediaManagerModal.displayName = "MediaManagerModal";
4031
4030
  const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==", ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
4032
- const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = n.split(".").pop() || "", u = i ? `_${p}Id-${i}` : `_${p}Id`, g = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, u, g ? c == null ? void 0 : c.assetId : ""), m = !!h, x = (k) => {
4033
- const b = isArray(k) ? first(k) : k;
4031
+ const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = n.split(".").pop() || "", u = i ? `_${p}Id-${i}` : `_${p}Id`, g = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, u, g ? c == null ? void 0 : c.assetId : ""), m = !!h, x = (y) => {
4032
+ const b = isArray(y) ? first(y) : y;
4034
4033
  if (b) {
4035
4034
  r(b == null ? void 0 : b.url);
4036
- const A = b == null ? void 0 : b.width, E = b == null ? void 0 : b.height;
4035
+ const A = b == null ? void 0 : b.width, _ = b == null ? void 0 : b.height;
4037
4036
  if (c != null && c._id) {
4038
- const _ = {
4037
+ const E = {
4039
4038
  ...A && { width: A },
4040
- ...E && { height: E },
4039
+ ..._ && { height: _ },
4041
4040
  ...b.description && { alt: b.description }
4042
4041
  };
4043
- if (set(_, u, b.id), isEmpty(_)) return;
4044
- d([c._id], _);
4042
+ if (set(E, u, b.id), isEmpty(E)) return;
4043
+ d([c._id], E);
4045
4044
  }
4046
4045
  }
4047
4046
  }, f = useCallback(() => {
@@ -4091,8 +4090,8 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4091
4090
  className: "text-xs",
4092
4091
  placeholder: l("Enter image URL"),
4093
4092
  value: o,
4094
- onBlur: ({ target: { value: k } }) => a(n, k),
4095
- onChange: (k) => r(k.target.value)
4093
+ onBlur: ({ target: { value: y } }) => a(n, y),
4094
+ onChange: (y) => r(y.target.value)
4096
4095
  }
4097
4096
  )
4098
4097
  ] })
@@ -4208,44 +4207,44 @@ const DataBindingSelector = ({
4208
4207
  r(`{{${g}}}`, {}, n);
4209
4208
  return;
4210
4209
  }
4211
- const m = (b) => /[.,!?;:]/.test(b), x = (b, A, E) => {
4212
- let _ = "", N = "";
4213
- const w = A > 0 ? b[A - 1] : "", y = A < b.length ? b[A] : "";
4214
- return A > 0 && (w === "." || !m(w) && w !== " ") && (_ = " "), A < b.length && !m(y) && y !== " " && (N = " "), {
4215
- text: _ + E + N,
4216
- prefixLength: _.length,
4210
+ const m = (b) => /[.,!?;:]/.test(b), x = (b, A, _) => {
4211
+ let E = "", N = "";
4212
+ const w = A > 0 ? b[A - 1] : "", S = A < b.length ? b[A] : "";
4213
+ return A > 0 && (w === "." || !m(w) && w !== " ") && (E = " "), A < b.length && !m(S) && S !== " " && (N = " "), {
4214
+ text: E + _ + N,
4215
+ prefixLength: E.length,
4217
4216
  suffixLength: N.length
4218
4217
  };
4219
4218
  }, f = document.getElementById(n);
4220
4219
  if (!f) return;
4221
- const k = document.getElementById(`chai-rte-${n}`) || document.getElementById(`chai-rte-modal-${n}`);
4222
- if (k && (k.querySelector(".ProseMirror") || k.__chaiRTE)) {
4223
- const b = k.__chaiRTE;
4220
+ const y = document.getElementById(`chai-rte-${n}`) || document.getElementById(`chai-rte-modal-${n}`);
4221
+ if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
4222
+ const b = y.__chaiRTE;
4224
4223
  if (b) {
4225
4224
  const A = `{{${g}}}`;
4226
4225
  b.commands.focus();
4227
- const { from: E, to: _ } = b.state.selection;
4228
- if (E !== _)
4226
+ const { from: _, to: E } = b.state.selection;
4227
+ if (_ !== E)
4229
4228
  b.chain().deleteSelection().insertContent(A).run();
4230
4229
  else {
4231
- const { state: w } = b, y = w.selection.from, v = w.doc.textBetween(Math.max(0, y - 1), y), B = w.doc.textBetween(y, Math.min(y + 1, w.doc.content.size));
4232
- let S = "";
4233
- y > 0 && v !== " " && !m(v) && (S = " ");
4230
+ const { state: w } = b, S = w.selection.from, k = w.doc.textBetween(Math.max(0, S - 1), S), j = w.doc.textBetween(S, Math.min(S + 1, w.doc.content.size));
4234
4231
  let C = "";
4235
- B && B !== " " && !m(B) && (C = " "), b.chain().insertContent(S + A + C).run();
4232
+ S > 0 && k !== " " && !m(k) && (C = " ");
4233
+ let v = "";
4234
+ j && j !== " " && !m(j) && (v = " "), b.chain().insertContent(C + A + v).run();
4236
4235
  }
4237
4236
  setTimeout(() => r(b.getHTML(), {}, n), 100);
4238
4237
  return;
4239
4238
  }
4240
4239
  } else {
4241
- const b = f, A = b.selectionStart || 0, E = b.value || "", _ = b.selectionEnd || A;
4242
- if (_ > A) {
4243
- const B = `{{${g}}}`, { text: S } = x(E, A, B), C = E.slice(0, A) + S + E.slice(_);
4244
- r(C, {}, n);
4240
+ const b = f, A = b.selectionStart || 0, _ = b.value || "", E = b.selectionEnd || A;
4241
+ if (E > A) {
4242
+ const j = `{{${g}}}`, { text: C } = x(_, A, j), v = _.slice(0, A) + C + _.slice(E);
4243
+ r(v, {}, n);
4245
4244
  return;
4246
4245
  }
4247
- const w = `{{${g}}}`, { text: y } = x(E, A, w), v = E.slice(0, A) + y + E.slice(A);
4248
- r(v, {}, n);
4246
+ const w = `{{${g}}}`, { text: S } = x(_, A, w), k = _.slice(0, A) + S + _.slice(A);
4247
+ r(k, {}, n);
4249
4248
  }
4250
4249
  },
4251
4250
  [n, r, a, c == null ? void 0 : c._id, d]
@@ -4266,74 +4265,74 @@ const DataBindingSelector = ({
4266
4265
  pageTypes: r,
4267
4266
  onChange: n
4268
4267
  }) => {
4269
- var B;
4270
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (S, C) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [x, f] = useState([]), [k, b] = useState(-1), A = useRef(null), E = (B = r == null ? void 0 : r.find((S) => S.key === u)) == null ? void 0 : B.name;
4268
+ var j;
4269
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, v) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [x, f] = useState([]), [y, b] = useState(-1), A = useRef(null), _ = (j = r == null ? void 0 : r.find((C) => C.key === u)) == null ? void 0 : j.name;
4271
4270
  useEffect(() => {
4272
4271
  if (m(""), f([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4273
- const S = split(o, ":"), C = get(S, 1, "page") || "page";
4274
- g(C), (async () => {
4275
- const j = await l(C, [get(S, 2, "page")]);
4276
- j && Array.isArray(j) && m(get(j, [0, "name"], ""));
4272
+ const C = split(o, ":"), v = get(C, 1, "page") || "page";
4273
+ g(v), (async () => {
4274
+ const B = await l(v, [get(C, 2, "page")]);
4275
+ B && Array.isArray(B) && m(get(B, [0, "name"], ""));
4277
4276
  })();
4278
4277
  }, [o]);
4279
- const _ = useDebouncedCallback(
4280
- async (S) => {
4281
- if (isEmpty(S))
4278
+ const E = useDebouncedCallback(
4279
+ async (C) => {
4280
+ if (isEmpty(C))
4282
4281
  f([]);
4283
4282
  else {
4284
- const C = await l(u, S);
4285
- f(C);
4283
+ const v = await l(u, C);
4284
+ f(v);
4286
4285
  }
4287
4286
  c(!1), b(-1);
4288
4287
  },
4289
4288
  [u],
4290
4289
  300
4291
- ), N = (S) => {
4292
- const C = ["pageType", u, S.id];
4293
- C[1] && (n(C.join(":")), m(S.name), p(!1), f([]), b(-1));
4294
- }, w = (S) => {
4295
- switch (S.key) {
4290
+ ), N = (C) => {
4291
+ const v = ["pageType", u, C.id];
4292
+ v[1] && (n(v.join(":")), m(C.name), p(!1), f([]), b(-1));
4293
+ }, w = (C) => {
4294
+ switch (C.key) {
4296
4295
  case "ArrowDown":
4297
- S.preventDefault(), b((C) => C < x.length - 1 ? C + 1 : C);
4296
+ C.preventDefault(), b((v) => v < x.length - 1 ? v + 1 : v);
4298
4297
  break;
4299
4298
  case "ArrowUp":
4300
- S.preventDefault(), b((C) => C > 0 ? C - 1 : C);
4299
+ C.preventDefault(), b((v) => v > 0 ? v - 1 : v);
4301
4300
  break;
4302
4301
  case "Enter":
4303
- if (S.preventDefault(), x.length === 0) return;
4304
- k >= 0 && N(x[k]);
4302
+ if (C.preventDefault(), x.length === 0) return;
4303
+ y >= 0 && N(x[y]);
4305
4304
  break;
4306
4305
  case "Escape":
4307
- S.preventDefault(), y();
4306
+ C.preventDefault(), S();
4308
4307
  break;
4309
4308
  }
4310
4309
  };
4311
4310
  useEffect(() => {
4312
- if (k >= 0 && A.current) {
4313
- const S = A.current.children[k];
4314
- S == null || S.scrollIntoView({ block: "nearest" });
4311
+ if (y >= 0 && A.current) {
4312
+ const C = A.current.children[y];
4313
+ C == null || C.scrollIntoView({ block: "nearest" });
4315
4314
  }
4316
- }, [k]);
4317
- const y = () => {
4315
+ }, [y]);
4316
+ const S = () => {
4318
4317
  m(""), f([]), b(-1), p(!1), n("");
4319
- }, v = (S) => {
4320
- m(S), p(!isEmpty(S)), c(!0), _(S);
4318
+ }, k = (C) => {
4319
+ m(C), p(!isEmpty(C)), c(!0), E(C);
4321
4320
  };
4322
4321
  return /* @__PURE__ */ jsxs("div", { children: [
4323
- /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (S) => g(S.target.value), children: map(r, (S) => /* @__PURE__ */ jsx("option", { value: S.key, children: S.name }, S.key)) }),
4322
+ /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (C) => g(C.target.value), children: map(r, (C) => /* @__PURE__ */ jsx("option", { value: C.key, children: C.name }, C.key)) }),
4324
4323
  u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
4325
4324
  /* @__PURE__ */ jsx(
4326
4325
  "input",
4327
4326
  {
4328
4327
  type: "text",
4329
4328
  value: h,
4330
- onChange: (S) => v(S.target.value),
4329
+ onChange: (C) => k(C.target.value),
4331
4330
  onKeyDown: w,
4332
- placeholder: a(`Search ${E ?? ""}`),
4331
+ placeholder: a(`Search ${_ ?? ""}`),
4333
4332
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4334
4333
  }
4335
4334
  ),
4336
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: y, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4335
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4337
4336
  ] }),
4338
4337
  (i || !isEmpty(x) || d && isEmpty(x)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
4339
4338
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -4343,22 +4342,22 @@ const DataBindingSelector = ({
4343
4342
  ' "',
4344
4343
  h,
4345
4344
  '"'
4346
- ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(x == null ? void 0 : x.slice(0, 20), (S, C) => /* @__PURE__ */ jsxs(
4345
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(x == null ? void 0 : x.slice(0, 20), (C, v) => /* @__PURE__ */ jsxs(
4347
4346
  "li",
4348
4347
  {
4349
- onClick: () => N(S),
4350
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(S.id) ? "bg-blue-200" : C === k ? "bg-gray-100" : "hover:bg-gray-100"}`,
4348
+ onClick: () => N(C),
4349
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(C.id) ? "bg-blue-200" : v === y ? "bg-gray-100" : "hover:bg-gray-100"}`,
4351
4350
  children: [
4352
- S.name,
4351
+ C.name,
4353
4352
  " ",
4354
- S.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4353
+ C.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4355
4354
  "( ",
4356
- S.slug,
4355
+ C.slug,
4357
4356
  " )"
4358
4357
  ] })
4359
4358
  ]
4360
4359
  },
4361
- S.id
4360
+ C.id
4362
4361
  )) }) })
4363
4362
  ] });
4364
4363
  }, LinkField = ({ schema: o, formData: r, onChange: n, name: a }) => {
@@ -4662,11 +4661,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4662
4661
  if (x !== f)
4663
4662
  u.chain().deleteSelection().insertContent(m).run();
4664
4663
  else {
4665
- const { state: b } = u, A = b.selection.from, E = b.doc.textBetween(Math.max(0, A - 1), A), _ = b.doc.textBetween(A, Math.min(A + 1, b.doc.content.size));
4664
+ const { state: b } = u, A = b.selection.from, _ = b.doc.textBetween(Math.max(0, A - 1), A), E = b.doc.textBetween(A, Math.min(A + 1, b.doc.content.size));
4666
4665
  let N = "";
4667
- A > 0 && E !== " " && !/[.,!?;:]/.test(E) && (N = " ");
4666
+ A > 0 && _ !== " " && !/[.,!?;:]/.test(_) && (N = " ");
4668
4667
  let w = "";
4669
- _ && _ !== " " && !/[.,!?;:]/.test(_) && (w = " "), u.chain().insertContent(N + m + w).run();
4668
+ E && E !== " " && !/[.,!?;:]/.test(E) && (w = " "), u.chain().insertContent(N + m + w).run();
4670
4669
  }
4671
4670
  };
4672
4671
  return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (h) => !h && r(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
@@ -4760,14 +4759,14 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4760
4759
  const h = () => {
4761
4760
  const f = findIndex(u, { _id: g });
4762
4761
  if (f > -1) {
4763
- const k = (f + 1) % u.length, b = get(u, [k, "_id"]);
4762
+ const y = (f + 1) % u.length, b = get(u, [y, "_id"]);
4764
4763
  if (!b) return;
4765
4764
  r({ ...o, currentSlide: b }), c([b]);
4766
4765
  }
4767
4766
  }, m = () => {
4768
4767
  const f = findIndex(u, { _id: g });
4769
4768
  if (f > -1) {
4770
- const k = (f - 1 + u.length) % u.length, b = get(u, [k, "_id"]);
4769
+ const y = (f - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
4771
4770
  if (!b) return;
4772
4771
  r({ ...o, currentSlide: b }), c([b]);
4773
4772
  }
@@ -4775,8 +4774,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4775
4774
  const f = i(
4776
4775
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4777
4776
  p == null ? void 0 : p._id
4778
- ), k = f == null ? void 0 : f._id;
4779
- k && (r({ ...o, currentSlide: k }), c([k]));
4777
+ ), y = f == null ? void 0 : f._id;
4778
+ y && (r({ ...o, currentSlide: y }), c([y]));
4780
4779
  };
4781
4780
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4782
4781
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
@@ -4855,8 +4854,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4855
4854
  className: "text-xs",
4856
4855
  pattern: "[0-9]*",
4857
4856
  onChange: (f) => {
4858
- let k = f.target.value;
4859
- k.length && (k = k.replace("-", "")), r({ ...o, autoplayInterval: k });
4857
+ let y = f.target.value;
4858
+ y.length && (y = y.replace("-", "")), r({ ...o, autoplayInterval: y });
4860
4859
  }
4861
4860
  }
4862
4861
  )
@@ -4966,25 +4965,25 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4966
4965
  const { selectedLang: h, fallbackLang: m, languages: x } = useLanguages(), f = useMemo(
4967
4966
  () => isEmpty(x) ? "" : isEmpty(h) ? m : h,
4968
4967
  [x, h, m]
4969
- ), k = useMemo(() => get(LANGUAGES, f, f), [f]), b = usePageExternalData(), A = useSelectedBlock(), E = useRegisteredChaiBlocks(), _ = useMemo(
4970
- () => get(E, [A == null ? void 0 : A._type, "i18nProps"], []),
4971
- [E, A == null ? void 0 : A._type]
4968
+ ), y = useMemo(() => get(LANGUAGES, f, f), [f]), b = usePageExternalData(), A = useSelectedBlock(), _ = useRegisteredChaiBlocks(), E = useMemo(
4969
+ () => get(_, [A == null ? void 0 : A._type, "i18nProps"], []),
4970
+ [_, A == null ? void 0 : A._type]
4972
4971
  ), [N, w] = useState(null);
4973
4972
  if (c)
4974
4973
  return null;
4975
4974
  if (p.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: a });
4976
- const v = _ == null ? void 0 : _.includes(o.replace("root.", ""));
4975
+ const k = E == null ? void 0 : E.includes(o.replace("root.", ""));
4977
4976
  if (p.type === "array") {
4978
- const B = N === o;
4977
+ const j = N === o;
4979
4978
  return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
4980
4979
  p.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
4981
4980
  "label",
4982
4981
  {
4983
4982
  htmlFor: o,
4984
- onClick: () => w(B ? null : o),
4983
+ onClick: () => w(j ? null : o),
4985
4984
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
4986
4985
  children: [
4987
- B ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
4986
+ j ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
4988
4987
  /* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
4989
4988
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: n }),
4990
4989
  " ",
@@ -4994,8 +4993,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4994
4993
  Info,
4995
4994
  {
4996
4995
  className: "h-3 w-3 text-muted-foreground/70",
4997
- onClick: (S) => S.stopPropagation(),
4998
- onMouseDown: (S) => S.stopPropagation()
4996
+ onClick: (C) => C.stopPropagation(),
4997
+ onMouseDown: (C) => C.stopPropagation()
4999
4998
  }
5000
4999
  ) }),
5001
5000
  /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: p.description })
@@ -5003,7 +5002,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
5003
5002
  ]
5004
5003
  }
5005
5004
  ) }),
5006
- (u == null ? void 0 : u.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${B ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
5005
+ (u == null ? void 0 : u.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${j ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
5007
5006
  a,
5008
5007
  l,
5009
5008
  i
@@ -5016,9 +5015,9 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
5016
5015
  /* @__PURE__ */ jsxs("label", { htmlFor: o, className: p.type === "object" ? "pb-2" : "", children: [
5017
5016
  n,
5018
5017
  " ",
5019
- v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5018
+ k && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5020
5019
  " ",
5021
- k
5020
+ y
5022
5021
  ] }),
5023
5022
  d && p.type !== "object" ? " *" : null
5024
5023
  ] }),
@@ -5031,8 +5030,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
5031
5030
  DataBindingSelector,
5032
5031
  {
5033
5032
  schema: p,
5034
- onChange: (B) => {
5035
- g(B, u, o);
5033
+ onChange: (j) => {
5034
+ g(j, u, o);
5036
5035
  },
5037
5036
  id: o,
5038
5037
  formData: u
@@ -5138,36 +5137,36 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
5138
5137
  }), a;
5139
5138
  };
5140
5139
  function BlockSettings() {
5141
- const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), x = ({ formData: w }, y, v) => {
5142
- y && (c == null ? void 0 : c._id) === r._id && a([r._id], { [y]: get(w, y) }, v);
5140
+ const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), x = ({ formData: w }, S, k) => {
5141
+ S && (c == null ? void 0 : c._id) === r._id && a([r._id], { [S]: get(w, S) }, k);
5143
5142
  }, f = useCallback(
5144
- debounce(({ formData: w }, y, v) => {
5145
- x({ formData: w }, y, v), d(w);
5143
+ debounce(({ formData: w }, S, k) => {
5144
+ x({ formData: w }, S, k), d(w);
5146
5145
  }, 1500),
5147
5146
  [r == null ? void 0 : r._id, o]
5148
- ), k = ({ formData: w }, y) => {
5149
- y && (n([r._id], { [y]: get(w, y) }), f({ formData: w }, y, { [y]: get(c, y) }));
5150
- }, b = ({ formData: w }, y) => {
5151
- y && (n([g._id], { [y]: get(w, y) }), f({ formData: w }, y, { [y]: get(c, y) }));
5152
- }, { schema: A, uiSchema: E } = useMemo(() => {
5147
+ ), y = ({ formData: w }, S) => {
5148
+ S && (n([r._id], { [S]: get(w, S) }), f({ formData: w }, S, { [S]: get(c, S) }));
5149
+ }, b = ({ formData: w }, S) => {
5150
+ S && (n([g._id], { [S]: get(w, S) }), f({ formData: w }, S, { [S]: get(c, S) }));
5151
+ }, { schema: A, uiSchema: _ } = useMemo(() => {
5153
5152
  const w = r == null ? void 0 : r._type;
5154
5153
  if (!w)
5155
5154
  return { schema: {}, uiSchema: {} };
5156
5155
  try {
5157
- const { schema: y, uiSchema: v } = getBlockFormSchemas(w);
5156
+ const { schema: S, uiSchema: k } = getBlockFormSchemas(w);
5158
5157
  if (w === "Repeater") {
5159
- const B = get(r, "repeaterItems", "");
5160
- startsWith(B, `{{${COLLECTION_PREFIX}`) ? (set(v, "filter", { "ui:widget": "collectionSelect" }), set(v, "sort", { "ui:widget": "collectionSelect" })) : (set(v, "filter", { "ui:widget": "hidden" }), set(v, "sort", { "ui:widget": "hidden" }));
5158
+ const j = get(r, "repeaterItems", "");
5159
+ startsWith(j, `{{${COLLECTION_PREFIX}`) ? (set(k, "filter", { "ui:widget": "collectionSelect" }), set(k, "sort", { "ui:widget": "collectionSelect" })) : (set(k, "filter", { "ui:widget": "hidden" }), set(k, "sort", { "ui:widget": "hidden" }));
5161
5160
  }
5162
- return { schema: y, uiSchema: v };
5161
+ return { schema: S, uiSchema: k };
5163
5162
  } catch {
5164
5163
  return { schema: {}, uiSchema: {} };
5165
5164
  }
5166
- }, [r]), { wrapperSchema: _, wrapperUiSchema: N } = useMemo(() => {
5165
+ }, [r]), { wrapperSchema: E, wrapperUiSchema: N } = useMemo(() => {
5167
5166
  if (!g || !(g != null && g._type))
5168
5167
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5169
- const w = g == null ? void 0 : g._type, { schema: y = {}, uiSchema: v = {} } = getBlockFormSchemas(w);
5170
- return { wrapperSchema: y, wrapperUiSchema: v };
5168
+ const w = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: k = {} } = getBlockFormSchemas(w);
5169
+ return { wrapperSchema: S, wrapperUiSchema: k };
5171
5170
  }, [g]);
5172
5171
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5173
5172
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
@@ -5195,7 +5194,7 @@ function BlockSettings() {
5195
5194
  blockId: g == null ? void 0 : g._id,
5196
5195
  onChange: b,
5197
5196
  formData: m,
5198
- schema: _,
5197
+ schema: E,
5199
5198
  uiSchema: N
5200
5199
  }
5201
5200
  ) })
@@ -5204,10 +5203,10 @@ function BlockSettings() {
5204
5203
  JSONForm,
5205
5204
  {
5206
5205
  blockId: r == null ? void 0 : r._id,
5207
- onChange: k,
5206
+ onChange: y,
5208
5207
  formData: i,
5209
5208
  schema: A,
5210
- uiSchema: E
5209
+ uiSchema: _
5211
5210
  }
5212
5211
  )
5213
5212
  ] });
@@ -5218,7 +5217,7 @@ const BlockStylingProps = () => {
5218
5217
  if (!o) return null;
5219
5218
  const c = Object.keys(o).filter(
5220
5219
  (f) => typeof o[f] == "string" && o[f].startsWith("#styles:")
5221
- ), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (x = r[0]) == null ? void 0 : x.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, h = g ? g.split(" ").filter((f) => !isEmpty(f)) : [], m = (f) => find(r, (k) => k.prop === f);
5220
+ ), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (x = r[0]) == null ? void 0 : x.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, h = g ? g.split(" ").filter((f) => !isEmpty(f)) : [], m = (f) => find(r, (y) => y.prop === f);
5222
5221
  return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
5223
5222
  /* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
5224
5223
  i("Style element"),
@@ -5240,7 +5239,7 @@ const BlockStylingProps = () => {
5240
5239
  {
5241
5240
  type: "button",
5242
5241
  className: "ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",
5243
- onClick: (k) => k.stopPropagation(),
5242
+ onClick: (y) => y.stopPropagation(),
5244
5243
  children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-3 w-3" })
5245
5244
  }
5246
5245
  ) }),
@@ -5418,47 +5417,47 @@ const BlockStylingProps = () => {
5418
5417
  },
5419
5418
  a
5420
5419
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5421
- const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [k, b] = useState(""), [A, E] = useState(!1), [_, N] = useState(!1);
5420
+ const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [y, b] = useState(""), [A, _] = useState(!1), [E, N] = useState(!1);
5422
5421
  useEffect(() => {
5423
- const { value: S, unit: C } = getClassValueAndUnit(i);
5424
- if (C === "") {
5425
- l(S), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5422
+ const { value: C, unit: v } = getClassValueAndUnit(i);
5423
+ if (v === "") {
5424
+ l(C), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5426
5425
  return;
5427
5426
  }
5428
- m(C), l(C === "class" || isEmpty(S) ? "" : S);
5427
+ m(v), l(v === "class" || isEmpty(C) ? "" : C);
5429
5428
  }, [i, p, u]);
5430
- const w = useThrottledCallback((S) => c(S), [c], THROTTLE_TIME), y = useThrottledCallback((S) => c(S, !1), [c], THROTTLE_TIME), v = useCallback(
5431
- (S = !1) => {
5432
- const C = getUserInputValues(`${a}`, u);
5433
- if (get(C, "error", !1)) {
5429
+ const w = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), S = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), k = useCallback(
5430
+ (C = !1) => {
5431
+ const v = getUserInputValues(`${a}`, u);
5432
+ if (get(v, "error", !1)) {
5434
5433
  f(!0);
5435
5434
  return;
5436
5435
  }
5437
- const j = get(C, "unit") !== "" ? get(C, "unit") : h;
5438
- if (j === "auto" || j === "none") {
5439
- w(`${d}${j}`);
5436
+ const B = get(v, "unit") !== "" ? get(v, "unit") : h;
5437
+ if (B === "auto" || B === "none") {
5438
+ w(`${d}${B}`);
5440
5439
  return;
5441
5440
  }
5442
- if (get(C, "value") === "")
5441
+ if (get(v, "value") === "")
5443
5442
  return;
5444
- const T = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5445
- S ? y(T) : w(T);
5443
+ const T = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
5444
+ C ? S(T) : w(T);
5446
5445
  },
5447
- [w, y, a, h, d, u]
5448
- ), B = useCallback(
5449
- (S) => {
5450
- const C = getUserInputValues(`${a}`, u);
5451
- if (get(C, "error", !1)) {
5446
+ [w, S, a, h, d, u]
5447
+ ), j = useCallback(
5448
+ (C) => {
5449
+ const v = getUserInputValues(`${a}`, u);
5450
+ if (get(v, "error", !1)) {
5452
5451
  f(!0);
5453
5452
  return;
5454
5453
  }
5455
- if (S === "auto" || S === "none") {
5456
- w(`${d}${S}`);
5454
+ if (C === "auto" || C === "none") {
5455
+ w(`${d}${C}`);
5457
5456
  return;
5458
5457
  }
5459
- if (get(C, "value") === "")
5458
+ if (get(v, "value") === "")
5460
5459
  return;
5461
- const j = get(C, "unit") !== "" ? get(C, "unit") : S, T = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5460
+ const B = get(v, "unit") !== "" ? get(v, "unit") : C, T = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
5462
5461
  w(T);
5463
5462
  },
5464
5463
  [w, a, d, u]
@@ -5482,31 +5481,31 @@ const BlockStylingProps = () => {
5482
5481
  "input",
5483
5482
  {
5484
5483
  readOnly: h === "class",
5485
- onKeyPress: (S) => {
5486
- S.key === "Enter" && v();
5484
+ onKeyPress: (C) => {
5485
+ C.key === "Enter" && k();
5487
5486
  },
5488
- onKeyDown: (S) => {
5489
- if (S.keyCode !== 38 && S.keyCode !== 40)
5487
+ onKeyDown: (C) => {
5488
+ if (C.keyCode !== 38 && C.keyCode !== 40)
5490
5489
  return;
5491
- S.preventDefault(), N(!0);
5492
- const C = parseInt$1(S.target.value);
5493
- let j = isNaN$1(C) ? 0 : C;
5494
- S.keyCode === 38 && (j += 1), S.keyCode === 40 && (j -= 1);
5495
- const I = `${j}`, P = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
5496
- y(P);
5490
+ C.preventDefault(), N(!0);
5491
+ const v = parseInt$1(C.target.value);
5492
+ let B = isNaN$1(v) ? 0 : v;
5493
+ C.keyCode === 38 && (B += 1), C.keyCode === 40 && (B -= 1);
5494
+ const I = `${B}`, P = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
5495
+ S(P);
5497
5496
  },
5498
- onKeyUp: (S) => {
5499
- _ && (S.preventDefault(), N(!1));
5497
+ onKeyUp: (C) => {
5498
+ E && (C.preventDefault(), N(!1));
5500
5499
  },
5501
- onBlur: () => v(),
5502
- onChange: (S) => {
5503
- f(!1), l(S.target.value);
5500
+ onBlur: () => k(),
5501
+ onChange: (C) => {
5502
+ f(!1), l(C.target.value);
5504
5503
  },
5505
- onClick: (S) => {
5506
- var C;
5507
- (C = S == null ? void 0 : S.target) == null || C.select(), n(!1);
5504
+ onClick: (C) => {
5505
+ var v;
5506
+ (v = C == null ? void 0 : C.target) == null || v.select(), n(!1);
5508
5507
  },
5509
- value: A ? k : a,
5508
+ value: A ? y : a,
5510
5509
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
5511
5510
  " ",
5512
5511
  x ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -5531,8 +5530,8 @@ const BlockStylingProps = () => {
5531
5530
  {
5532
5531
  units: u,
5533
5532
  current: h,
5534
- onSelect: (S) => {
5535
- n(!1), m(S), B(S);
5533
+ onSelect: (C) => {
5534
+ n(!1), m(C), j(C);
5536
5535
  }
5537
5536
  }
5538
5537
  ) })
@@ -5541,19 +5540,19 @@ const BlockStylingProps = () => {
5541
5540
  ["none", "auto"].indexOf(h) !== -1 || A ? null : /* @__PURE__ */ jsx(
5542
5541
  DragStyleButton,
5543
5542
  {
5544
- onDragStart: () => E(!0),
5545
- onDragEnd: (S) => {
5546
- if (b(() => ""), E(!1), isEmpty(S))
5543
+ onDragStart: () => _(!0),
5544
+ onDragEnd: (C) => {
5545
+ if (b(() => ""), _(!1), isEmpty(C))
5547
5546
  return;
5548
- const C = `${S}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
5547
+ const v = `${C}`, I = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${h === "-" ? "" : h}]`;
5549
5548
  w(I);
5550
5549
  },
5551
- onDrag: (S) => {
5552
- if (isEmpty(S))
5550
+ onDrag: (C) => {
5551
+ if (isEmpty(C))
5553
5552
  return;
5554
- b(S);
5555
- const C = `${S}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
5556
- y(I);
5553
+ b(C);
5554
+ const v = `${C}`, I = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${h === "-" ? "" : h}]`;
5555
+ S(I);
5557
5556
  },
5558
5557
  currentValue: a,
5559
5558
  unit: h,
@@ -5618,8 +5617,8 @@ const COLOR_PROP = {
5618
5617
  }, ColorChoice = ({ property: o, onChange: r }) => {
5619
5618
  const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), h = get(u, "2", ""), m = useCallback(
5620
5619
  // eslint-disable-next-line no-shadow
5621
- (k) => {
5622
- ["current", "inherit", "transparent", "black", "white"].includes(k) ? (c([]), p({ color: k })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: k, shade: b.shade ? b.shade : "500" })));
5620
+ (y) => {
5621
+ ["current", "inherit", "transparent", "black", "white"].includes(y) ? (c([]), p({ color: y })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: y, shade: b.shade ? b.shade : "500" })));
5623
5622
  },
5624
5623
  [c, p]
5625
5624
  );
@@ -5630,8 +5629,8 @@ const COLOR_PROP = {
5630
5629
  }, [g]);
5631
5630
  const x = useCallback(
5632
5631
  // eslint-disable-next-line no-shadow
5633
- (k) => {
5634
- p({ color: g, shade: k });
5632
+ (y) => {
5633
+ p({ color: g, shade: y });
5635
5634
  },
5636
5635
  [g]
5637
5636
  );
@@ -6016,34 +6015,34 @@ const COLOR_PROP = {
6016
6015
  "2xl": "1536px"
6017
6016
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6018
6017
  const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
6019
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), k = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
6020
- (y, v = !0) => {
6021
- const B = { dark: p, mq: g, mod: u, cls: y, property: l, fullCls: "" };
6022
- (p || u !== "") && (B.mq = "xs");
6023
- const S = generateFullClsName(B);
6024
- m(f, [S], v);
6018
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), y = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
6019
+ (S, k = !0) => {
6020
+ const j = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
6021
+ (p || u !== "") && (j.mq = "xs");
6022
+ const C = generateFullClsName(j);
6023
+ m(f, [C], k);
6025
6024
  },
6026
6025
  [f, p, g, u, l, m]
6027
6026
  ), A = useCallback(() => {
6028
- x(f, [k], !0);
6029
- }, [f, k, x]), E = useMemo(() => canChangeClass(h, g), [h, g]);
6027
+ x(f, [y], !0);
6028
+ }, [f, y, x]), _ = useMemo(() => canChangeClass(h, g), [h, g]);
6030
6029
  useEffect(() => {
6031
- i(E, h);
6032
- }, [E, i, h]);
6033
- const [, , _] = useScreenSizeWidth(), N = useCallback(
6034
- (y) => {
6035
- _({
6030
+ i(_, h);
6031
+ }, [_, i, h]);
6032
+ const [, , E] = useScreenSizeWidth(), N = useCallback(
6033
+ (S) => {
6034
+ E({
6036
6035
  xs: 400,
6037
6036
  sm: 640,
6038
6037
  md: 800,
6039
6038
  lg: 1024,
6040
6039
  xl: 1420,
6041
6040
  "2xl": 1920
6042
- }[y]);
6041
+ }[S]);
6043
6042
  },
6044
- [_]
6043
+ [E]
6045
6044
  ), w = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
6046
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: E, canReset: h && w, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6045
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: _, canReset: h && w, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6047
6046
  /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !w ? "text-foreground" : ""}`, children: r(a) }) }),
6048
6047
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6049
6048
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
@@ -6063,7 +6062,7 @@ const COLOR_PROP = {
6063
6062
  n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
6064
6063
  n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
6065
6064
  ] }),
6066
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${k ? "visible" : "invisible"}`, children: w ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : E && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6065
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: w ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : _ && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6067
6066
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6068
6067
  "button",
6069
6068
  {
@@ -6287,7 +6286,7 @@ const COLOR_PROP = {
6287
6286
  u.includes(b) ? u.length > 2 && g(u.filter((A) => A !== b)) : g((A) => [...A, b]);
6288
6287
  }, f = (b) => {
6289
6288
  r || l(b), c(b);
6290
- }, k = getBreakpointValue(r ? i : a).toLowerCase();
6289
+ }, y = getBreakpointValue(r ? i : a).toLowerCase();
6291
6290
  return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
6292
6291
  BreakpointCard,
6293
6292
  {
@@ -6295,7 +6294,7 @@ const COLOR_PROP = {
6295
6294
  ...b,
6296
6295
  onClick: f,
6297
6296
  key: b.breakpoint,
6298
- currentBreakpoint: k
6297
+ currentBreakpoint: y
6299
6298
  }
6300
6299
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
6301
6300
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
@@ -6309,7 +6308,7 @@ const COLOR_PROP = {
6309
6308
  ...b,
6310
6309
  onClick: f,
6311
6310
  key: b.breakpoint,
6312
- currentBreakpoint: k
6311
+ currentBreakpoint: y
6313
6312
  }
6314
6313
  )
6315
6314
  ) }),
@@ -6464,10 +6463,10 @@ const AskAIStyles = ({ blockId: o }) => {
6464
6463
  };
6465
6464
  function ManualClasses() {
6466
6465
  var I;
6467
- const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [x, f] = useState(""), k = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), A = b.split(" ").filter((T) => !isEmpty(T)), E = () => {
6466
+ const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [x, f] = useState(""), y = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), A = b.split(" ").filter((T) => !isEmpty(T)), _ = () => {
6468
6467
  const T = x.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6469
6468
  u(h, T, !0), f("");
6470
- }, [_, N] = useState([]), w = ({ value: T }) => {
6469
+ }, [E, N] = useState([]), w = ({ value: T }) => {
6471
6470
  const P = T.trim().toLowerCase(), L = P.match(/.+:/g);
6472
6471
  let D = [];
6473
6472
  if (L && L.length > 0) {
@@ -6479,9 +6478,9 @@ function ManualClasses() {
6479
6478
  } else
6480
6479
  D = i.search(P);
6481
6480
  return N(map(D, "item"));
6482
- }, y = () => {
6481
+ }, S = () => {
6483
6482
  N([]);
6484
- }, v = (T) => T.name, B = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), S = useMemo(
6483
+ }, k = (T) => T.name, j = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), C = useMemo(
6485
6484
  () => ({
6486
6485
  ref: o,
6487
6486
  autoComplete: "off",
@@ -6496,17 +6495,17 @@ function ManualClasses() {
6496
6495
  }, 0);
6497
6496
  },
6498
6497
  onKeyDown: (T) => {
6499
- T.key === "Enter" && x.trim() !== "" && E();
6498
+ T.key === "Enter" && x.trim() !== "" && _();
6500
6499
  },
6501
6500
  onChange: (T, { newValue: P }) => f(P),
6502
6501
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
6503
6502
  }),
6504
6503
  [x, c, o]
6505
- ), C = (T) => {
6504
+ ), v = (T) => {
6506
6505
  debugger;
6507
6506
  const P = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6508
6507
  g(h, [T]), u(h, P, !0), n(""), l(-1);
6509
- }, j = () => {
6508
+ }, B = () => {
6510
6509
  if (navigator.clipboard === void 0) {
6511
6510
  toast.error(c("Clipboard not supported"));
6512
6511
  return;
@@ -6518,7 +6517,7 @@ function ManualClasses() {
6518
6517
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
6519
6518
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
6520
6519
  /* @__PURE__ */ jsxs(Tooltip, { children: [
6521
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: j, className: "cursor-pointer" }) }),
6520
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: B, className: "cursor-pointer" }) }),
6522
6521
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
6523
6522
  ] })
6524
6523
  ] }),
@@ -6534,12 +6533,12 @@ function ManualClasses() {
6534
6533
  /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
6535
6534
  Autosuggest,
6536
6535
  {
6537
- suggestions: _,
6536
+ suggestions: E,
6538
6537
  onSuggestionsFetchRequested: w,
6539
- onSuggestionsClearRequested: y,
6540
- getSuggestionValue: v,
6541
- renderSuggestion: B,
6542
- inputProps: S,
6538
+ onSuggestionsClearRequested: S,
6539
+ getSuggestionValue: k,
6540
+ renderSuggestion: j,
6541
+ inputProps: C,
6543
6542
  containerProps: {
6544
6543
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
6545
6544
  },
@@ -6555,7 +6554,7 @@ function ManualClasses() {
6555
6554
  {
6556
6555
  variant: "outline",
6557
6556
  className: "h-6 border-border",
6558
- onClick: E,
6557
+ onClick: _,
6559
6558
  disabled: x.trim() === "",
6560
6559
  size: "sm",
6561
6560
  children: /* @__PURE__ */ jsx(PlusIcon, {})
@@ -6570,10 +6569,10 @@ function ManualClasses() {
6570
6569
  value: r,
6571
6570
  onChange: (L) => n(L.target.value),
6572
6571
  onBlur: () => {
6573
- C(T);
6572
+ v(T);
6574
6573
  },
6575
6574
  onKeyDown: (L) => {
6576
- L.key === "Enter" && C(T);
6575
+ L.key === "Enter" && v(T);
6577
6576
  },
6578
6577
  onFocus: (L) => {
6579
6578
  setTimeout(() => {
@@ -6745,8 +6744,8 @@ function BlockStyling() {
6745
6744
  m = isNaN(m) ? 0 : m;
6746
6745
  let x = MAPPER[i.dragUnit];
6747
6746
  (startsWith(h, "scale") || h === "opacity") && (x = 10);
6748
- let k = (i.dragStartY - u.pageY) / x + m;
6749
- g && k < 0 && (k = 0), h === "opacity" && k > 1 && (k = 1), i.onDrag(`${k}`), l(`${k}`);
6747
+ let y = (i.dragStartY - u.pageY) / x + m;
6748
+ g && y < 0 && (y = 0), h === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6750
6749
  },
6751
6750
  [i],
6752
6751
  50
@@ -6789,8 +6788,8 @@ const CoreBlock = ({
6789
6788
  }) => {
6790
6789
  const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
6791
6790
  if (has(o, "blocks")) {
6792
- const k = isFunction(o.blocks) ? o.blocks() : o.blocks;
6793
- u(syncBlocksWithDefaults(k), n || null, a);
6791
+ const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
6792
+ u(syncBlocksWithDefaults(y), n || null, a);
6794
6793
  } else
6795
6794
  p(o, n || null, a);
6796
6795
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
@@ -6802,8 +6801,8 @@ const CoreBlock = ({
6802
6801
  disabled: r,
6803
6802
  onClick: m,
6804
6803
  type: "button",
6805
- onDragStart: (k) => {
6806
- k.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), k.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6804
+ onDragStart: (y) => {
6805
+ y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6807
6806
  g([]), h();
6808
6807
  }, 200);
6809
6808
  },
@@ -7018,7 +7017,7 @@ const CoreBlock = ({
7018
7017
  }
7019
7018
  }
7020
7019
  }, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
7021
- var h, m, x, f, k, b, A, E, _, N;
7020
+ var h, m, x, f, y, b, A, _, E, N;
7022
7021
  if (n.type === "comment") return [];
7023
7022
  let a = { _id: generateUUID() };
7024
7023
  if (r && (a._parent = r.block._id), n.type === "text")
@@ -7040,7 +7039,7 @@ const CoreBlock = ({
7040
7039
  ...getAttrs(n),
7041
7040
  ...getStyles(n)
7042
7041
  }, n.attributes) {
7043
- const w = n.attributes.find((y) => includes(NAME_ATTRIBUTES, y.key));
7042
+ const w = n.attributes.find((S) => includes(NAME_ATTRIBUTES, S.key));
7044
7043
  w && (a._name = w.value);
7045
7044
  }
7046
7045
  if (i)
@@ -7058,30 +7057,30 @@ const CoreBlock = ({
7058
7057
  ];
7059
7058
  a = {
7060
7059
  ...a,
7061
- href: ((h = l.find((y) => y.key === "href")) == null ? void 0 : h.value) || "",
7062
- hrefType: ((m = l.find((y) => y.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
7063
- autoplay: ((x = l.find((y) => y.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
7064
- maxWidth: ((k = (f = l.find((y) => y.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : k.replace("px", "")) || "",
7065
- backdropColor: ((b = l.find((y) => y.key === "data-overlay")) == null ? void 0 : b.value) || "",
7066
- galleryName: ((A = l.find((y) => y.key === "data-gall")) == null ? void 0 : A.value) || ""
7067
- }, forEach(w, (y) => {
7068
- has(a, `styles_attrs.${y}`) && delete a.styles_attrs[y];
7060
+ href: ((h = l.find((S) => S.key === "href")) == null ? void 0 : h.value) || "",
7061
+ hrefType: ((m = l.find((S) => S.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
7062
+ autoplay: ((x = l.find((S) => S.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
7063
+ maxWidth: ((y = (f = l.find((S) => S.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : y.replace("px", "")) || "",
7064
+ backdropColor: ((b = l.find((S) => S.key === "data-overlay")) == null ? void 0 : b.value) || "",
7065
+ galleryName: ((A = l.find((S) => S.key === "data-gall")) == null ? void 0 : A.value) || ""
7066
+ }, forEach(w, (S) => {
7067
+ has(a, `styles_attrs.${S}`) && delete a.styles_attrs[S];
7069
7068
  });
7070
7069
  }
7071
7070
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
7072
7071
  delete a.styles_attrs;
7073
- const w = filter(n.children || [], (v) => (v == null ? void 0 : v.tagName) !== "span");
7072
+ const w = filter(n.children || [], (k) => (k == null ? void 0 : k.tagName) !== "span");
7074
7073
  a.content = getTextContent(w);
7075
- const y = find(
7074
+ const S = find(
7076
7075
  n.children || [],
7077
- (v) => (v == null ? void 0 : v.tagName) === "span" && some(v.children || [], (B) => (B == null ? void 0 : B.tagName) === "svg")
7076
+ (k) => (k == null ? void 0 : k.tagName) === "span" && some(k.children || [], (j) => (j == null ? void 0 : j.tagName) === "svg")
7078
7077
  );
7079
- if (y) {
7080
- const v = find(y.children || [], (B) => (B == null ? void 0 : B.tagName) === "svg");
7081
- if (v) {
7082
- a.icon = stringify([v]);
7083
- const { height: B, width: S } = getSvgDimensions(v, "16px", "16px");
7084
- a.iconHeight = B, a.iconWidth = S;
7078
+ if (S) {
7079
+ const k = find(S.children || [], (j) => (j == null ? void 0 : j.tagName) === "svg");
7080
+ if (k) {
7081
+ a.icon = stringify([k]);
7082
+ const { height: j, width: C } = getSvgDimensions(k, "16px", "16px");
7083
+ a.iconHeight = j, a.iconWidth = C;
7085
7084
  }
7086
7085
  }
7087
7086
  return [a];
@@ -7093,14 +7092,14 @@ const CoreBlock = ({
7093
7092
  const w = stringify([n]);
7094
7093
  return hasVideoEmbed(w) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(w)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = w, [a];
7095
7094
  } else if (n.tagName === "svg") {
7096
- const w = get(find(n.attributes, { key: "class" }), "value", ""), { height: y, width: v } = getHeightAndWidthFromClass(w);
7097
- if (y && v)
7098
- a.styles = `${STYLES_KEY}, ${cn$2(`w-${v} h-${y}`, w)}`.trim(), a.height = y == null ? void 0 : y.replace("px", ""), a.width = v == null ? void 0 : v.replace("px", "");
7095
+ const w = get(find(n.attributes, { key: "class" }), "value", ""), { height: S, width: k } = getHeightAndWidthFromClass(w);
7096
+ if (S && k)
7097
+ a.styles = `${STYLES_KEY}, ${cn$2(`w-${k} h-${S}`, w)}`.trim(), a.height = S == null ? void 0 : S.replace("px", ""), a.width = k == null ? void 0 : k.replace("px", "");
7099
7098
  else {
7100
- const B = (E = find(n.attributes, { key: "height" })) == null ? void 0 : E.value, S = (_ = find(n.attributes, { key: "width" })) == null ? void 0 : _.value;
7101
- B && S ? (a.styles = `${STYLES_KEY}, ${cn$2(`w-[${S}px] h-[${B}px]`, w)}`.trim(), a.height = B, a.width = S) : a.styles = `${STYLES_KEY}, ${cn$2("w-full h-full", w)}`.trim();
7099
+ const j = (_ = find(n.attributes, { key: "height" })) == null ? void 0 : _.value, C = (E = find(n.attributes, { key: "width" })) == null ? void 0 : E.value;
7100
+ j && C ? (a.styles = `${STYLES_KEY}, ${cn$2(`w-[${C}px] h-[${j}px]`, w)}`.trim(), a.height = j, a.width = C) : a.styles = `${STYLES_KEY}, ${cn$2("w-full h-full", w)}`.trim();
7102
7101
  }
7103
- return n.attributes = filter(n.attributes, (B) => !includes(["style", "width", "height", "class"], B.key)), a.icon = stringify([n]), [a];
7102
+ return n.attributes = filter(n.attributes, (j) => !includes(["style", "width", "height", "class"], j.key)), a.icon = stringify([n]), [a];
7104
7103
  } else if (n.tagName == "option" && r && ((N = r.block) == null ? void 0 : N._type) === "Select")
7105
7104
  return r.block.options.push({
7106
7105
  label: getTextContent(n.children),
@@ -7217,18 +7216,18 @@ const registerChaiLibrary = (o, r) => {
7217
7216
  parentId: n = void 0,
7218
7217
  position: a = -1
7219
7218
  }) => {
7220
- const [l, i] = useState(!1), c = useMemo(() => (r == null ? void 0 : r.getBlock) || (() => []), [r]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), k = (E) => {
7221
- const _ = has(E, "styles_attrs.data-page-section");
7222
- return E._type === "Box" && _;
7219
+ const [l, i] = useState(!1), c = useMemo(() => (r == null ? void 0 : r.getBlock) || (() => []), [r]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), y = (_) => {
7220
+ const E = has(_, "styles_attrs.data-page-section");
7221
+ return _._type === "Box" && E;
7223
7222
  }, b = useCallback(
7224
- async (E) => {
7225
- if (E.stopPropagation(), has(o, "component")) {
7223
+ async (_) => {
7224
+ if (_.stopPropagation(), has(o, "component")) {
7226
7225
  d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7227
7226
  return;
7228
7227
  }
7229
7228
  i(!0);
7230
- let _ = await c({ library: r, block: o });
7231
- typeof _ == "string" && (_ = getBlocksFromHTML(_)), isEmpty(_) || p(syncBlocksWithDefaults(_), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7229
+ let E = await c({ library: r, block: o });
7230
+ typeof E == "string" && (E = getBlocksFromHTML(E)), isEmpty(E) || p(syncBlocksWithDefaults(E), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7232
7231
  },
7233
7232
  [d, p, o, c, r, n, a]
7234
7233
  );
@@ -7239,18 +7238,18 @@ const registerChaiLibrary = (o, r) => {
7239
7238
  onClick: l ? () => {
7240
7239
  } : b,
7241
7240
  draggable: x ? "true" : "false",
7242
- onDragStart: async (E) => {
7243
- const _ = await c({ library: r, block: o });
7241
+ onDragStart: async (_) => {
7242
+ const E = await c({ library: r, block: o });
7244
7243
  let N = n;
7245
- if (k(first(_)) && (N = null), !isEmpty(_)) {
7246
- const w = { blocks: _, uiLibrary: !0, parent: N };
7247
- if (E.dataTransfer.setData("text/plain", JSON.stringify(w)), o.preview) {
7248
- const y = new Image();
7249
- y.src = o.preview, y.onload = () => {
7250
- E.dataTransfer.setDragImage(y, 0, 0);
7244
+ if (y(first(E)) && (N = null), !isEmpty(E)) {
7245
+ const w = { blocks: E, uiLibrary: !0, parent: N };
7246
+ if (_.dataTransfer.setData("text/plain", JSON.stringify(w)), o.preview) {
7247
+ const S = new Image();
7248
+ S.src = o.preview, S.onload = () => {
7249
+ _.dataTransfer.setDragImage(S, 0, 0);
7251
7250
  };
7252
7251
  } else
7253
- E.dataTransfer.setDragImage(new Image(), 0, 0);
7252
+ _.dataTransfer.setDragImage(new Image(), 0, 0);
7254
7253
  f(w), setTimeout(() => {
7255
7254
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7256
7255
  }, 200);
@@ -7277,7 +7276,7 @@ const registerChaiLibrary = (o, r) => {
7277
7276
  ] }) })
7278
7277
  ] });
7279
7278
  }, UILibrarySection = ({ parentId: o, position: r }) => {
7280
- const [n, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((C) => C.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), x = useRef(null);
7279
+ const [n, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((v) => v.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), x = useRef(null);
7281
7280
  useEffect(() => {
7282
7281
  c && c.length > 0 && (x.current = new Fuse(c, {
7283
7282
  keys: ["name", "label", "description", "group"],
@@ -7289,27 +7288,27 @@ const registerChaiLibrary = (o, r) => {
7289
7288
  m([]);
7290
7289
  return;
7291
7290
  }
7292
- const C = x.current.search(u).map((j) => j.item);
7293
- m(C);
7291
+ const v = x.current.search(u).map((B) => B.item);
7292
+ m(v);
7294
7293
  }, [u]);
7295
- const f = u.trim() && !isEmpty(h) ? h : c, k = groupBy(f, "group"), [b, A] = useState(null);
7294
+ const f = u.trim() && !isEmpty(h) ? h : c, y = groupBy(f, "group"), [b, A] = useState(null);
7296
7295
  useEffect(() => {
7297
- if (isEmpty(keys(k))) {
7296
+ if (isEmpty(keys(y))) {
7298
7297
  A(null);
7299
7298
  return;
7300
7299
  }
7301
- if (!b || !k[b]) {
7302
- A(first(keys(k)));
7300
+ if (!b || !y[b]) {
7301
+ A(first(keys(y)));
7303
7302
  return;
7304
7303
  }
7305
- }, [k, b]);
7306
- const E = get(k, b, []), _ = useRef(null), { t: N } = useTranslation(), w = (C) => {
7307
- _.current && (clearTimeout(_.current), _.current = null), _.current = setTimeout(() => {
7308
- _.current && A(C);
7304
+ }, [y, b]);
7305
+ const _ = get(y, b, []), E = useRef(null), { t: N } = useTranslation(), w = (v) => {
7306
+ E.current && (clearTimeout(E.current), E.current = null), E.current = setTimeout(() => {
7307
+ E.current && A(v);
7309
7308
  }, 400);
7310
- }, y = () => {
7309
+ }, S = () => {
7311
7310
  i != null && i.id && p(i.id);
7312
- }, v = () => {
7311
+ }, k = () => {
7313
7312
  g("");
7314
7313
  };
7315
7314
  if (d)
@@ -7317,7 +7316,7 @@ const registerChaiLibrary = (o, r) => {
7317
7316
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7318
7317
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7319
7318
  ] });
7320
- const B = filter(E, (C, j) => j % 2 === 0), S = filter(E, (C, j) => j % 2 === 1);
7319
+ const j = filter(_, (v, B) => B % 2 === 0), C = filter(_, (v, B) => B % 2 === 1);
7321
7320
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
7322
7321
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7323
7322
  /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
@@ -7326,14 +7325,14 @@ const registerChaiLibrary = (o, r) => {
7326
7325
  {
7327
7326
  placeholder: N("Search blocks..."),
7328
7327
  value: u,
7329
- onChange: (C) => g(C.target.value),
7328
+ onChange: (v) => g(v.target.value),
7330
7329
  className: "w-full pl-8 pr-8"
7331
7330
  }
7332
7331
  ),
7333
7332
  u && /* @__PURE__ */ jsx(
7334
7333
  "button",
7335
7334
  {
7336
- onClick: v,
7335
+ onClick: k,
7337
7336
  className: "absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",
7338
7337
  children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
7339
7338
  }
@@ -7345,58 +7344,58 @@ const registerChaiLibrary = (o, r) => {
7345
7344
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7346
7345
  /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: N("Groups") }),
7347
7346
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7348
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7347
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(y) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7349
7348
  /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("Failed to load the UI library. Try again") }),
7350
- /* @__PURE__ */ jsxs(Button, { onClick: y, variant: "outline", size: "sm", className: "gap-2", children: [
7349
+ /* @__PURE__ */ jsxs(Button, { onClick: S, variant: "outline", size: "sm", className: "gap-2", children: [
7351
7350
  /* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
7352
7351
  N("Retry")
7353
7352
  ] })
7354
- ] }) }) : map(k, (C, j) => /* @__PURE__ */ jsxs(
7353
+ ] }) }) : map(y, (v, B) => /* @__PURE__ */ jsxs(
7355
7354
  "div",
7356
7355
  {
7357
- onMouseEnter: () => w(j),
7358
- onMouseLeave: () => clearTimeout(_.current),
7356
+ onMouseEnter: () => w(B),
7357
+ onMouseLeave: () => clearTimeout(E.current),
7359
7358
  role: "button",
7360
- onClick: () => A(j),
7359
+ onClick: () => A(B),
7361
7360
  className: cn$2(
7362
7361
  "flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
7363
- j === b ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
7362
+ B === b ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
7364
7363
  ),
7365
7364
  children: [
7366
- /* @__PURE__ */ jsx("span", { children: capitalize(N(j.toLowerCase())) }),
7365
+ /* @__PURE__ */ jsx("span", { children: capitalize(N(B.toLowerCase())) }),
7367
7366
  /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
7368
7367
  ]
7369
7368
  },
7370
- j
7369
+ B
7371
7370
  )) })
7372
7371
  ] })
7373
7372
  ] }),
7374
7373
  /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-col border-l border-border", children: /* @__PURE__ */ jsxs(
7375
7374
  ScrollArea,
7376
7375
  {
7377
- onMouseEnter: () => _.current ? clearTimeout(_.current) : null,
7376
+ onMouseEnter: () => E.current ? clearTimeout(E.current) : null,
7378
7377
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
7379
7378
  children: [
7380
- isEmpty(E) && !isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7381
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: B.map((C, j) => /* @__PURE__ */ jsx(
7379
+ isEmpty(_) && !isEmpty(y) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7380
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: j.map((v, B) => /* @__PURE__ */ jsx(
7382
7381
  BlockCard,
7383
7382
  {
7384
7383
  parentId: o,
7385
7384
  position: r,
7386
- block: C,
7385
+ block: v,
7387
7386
  library: i
7388
7387
  },
7389
- `block-${j}`
7388
+ `block-${B}`
7390
7389
  )) }),
7391
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: S.map((C, j) => /* @__PURE__ */ jsx(
7390
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: C.map((v, B) => /* @__PURE__ */ jsx(
7392
7391
  BlockCard,
7393
7392
  {
7394
7393
  parentId: o,
7395
7394
  position: r,
7396
- block: C,
7395
+ block: v,
7397
7396
  library: i
7398
7397
  },
7399
- `block-second-${j}`
7398
+ `block-second-${B}`
7400
7399
  )) })
7401
7400
  ] }),
7402
7401
  /* @__PURE__ */ jsx("br", {}),
@@ -7432,15 +7431,15 @@ const registerChaiLibrary = (o, r) => {
7432
7431
  error: c
7433
7432
  }), g(!0);
7434
7433
  else if (!l && Object.keys(a || {}).length > 0) {
7435
- const m = Object.entries(a).map(([f, k]) => {
7436
- const b = k, A = b.type || "partial", E = formatReadableName(A);
7434
+ const m = Object.entries(a).map(([f, y]) => {
7435
+ const b = y, A = b.type || "partial", _ = formatReadableName(A);
7437
7436
  return {
7438
7437
  type: "PartialBlock",
7439
7438
  // Set the type to PartialBlock
7440
7439
  label: formatReadableName(b.name || f),
7441
7440
  description: b.description || "",
7442
7441
  icon: Globe,
7443
- group: E,
7442
+ group: _,
7444
7443
  // Use formatted type as group
7445
7444
  category: "partial",
7446
7445
  partialBlockId: f,
@@ -7495,44 +7494,44 @@ const registerChaiLibrary = (o, r) => {
7495
7494
  }, ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
7496
7495
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
7497
7496
  }, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: r, parentId: n, position: a, gridCols: l = "grid-cols-4" }) => {
7498
- var S;
7499
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (S = find(c, (C) => C._id === n)) == null ? void 0 : S._type, [m, x] = useState("all"), [f, k] = useState(null), b = useRef(null);
7497
+ var C;
7498
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (C = find(c, (v) => v._id === n)) == null ? void 0 : C._type, [m, x] = useState("all"), [f, y] = useState(null), b = useRef(null);
7500
7499
  useEffect(() => {
7501
- const C = setTimeout(() => {
7502
- var j;
7503
- (j = u.current) == null || j.focus();
7500
+ const v = setTimeout(() => {
7501
+ var B;
7502
+ (B = u.current) == null || B.focus();
7504
7503
  }, 0);
7505
- return () => clearTimeout(C);
7504
+ return () => clearTimeout(v);
7506
7505
  }, [g]), useEffect(() => {
7507
- d && (x("all"), k(null));
7508
- }, [d]), useEffect(() => (b.current = debounce((C) => {
7509
- x(C);
7506
+ d && (x("all"), y(null));
7507
+ }, [d]), useEffect(() => (b.current = debounce((v) => {
7508
+ x(v);
7510
7509
  }, 500), () => {
7511
7510
  b.current && b.current.cancel();
7512
7511
  }), []);
7513
- const A = useCallback((C) => {
7514
- k(C), b.current && b.current(C);
7515
- }, []), E = useCallback(() => {
7516
- k(null), b.current && b.current.cancel();
7517
- }, []), _ = useCallback((C) => {
7518
- b.current && b.current.cancel(), x(C), k(null);
7512
+ const A = useCallback((v) => {
7513
+ y(v), b.current && b.current(v);
7514
+ }, []), _ = useCallback(() => {
7515
+ y(null), b.current && b.current.cancel();
7516
+ }, []), E = useCallback((v) => {
7517
+ b.current && b.current.cancel(), x(v), y(null);
7519
7518
  }, []), N = useMemo(
7520
7519
  () => d ? values(r).filter(
7521
- (C) => {
7522
- var j, I;
7523
- return (((j = C.label) == null ? void 0 : j.toLowerCase()) + " " + ((I = C.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
7520
+ (v) => {
7521
+ var B, I;
7522
+ return (((B = v.label) == null ? void 0 : B.toLowerCase()) + " " + ((I = v.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
7524
7523
  }
7525
7524
  ) : r,
7526
7525
  [r, d]
7527
7526
  ), w = useMemo(
7528
7527
  () => d ? o.filter(
7529
- (C) => reject(filter(values(N), { group: C }), { hidden: !0 }).length > 0
7530
- ) : o.filter((C) => reject(filter(values(r), { group: C }), { hidden: !0 }).length > 0),
7528
+ (v) => reject(filter(values(N), { group: v }), { hidden: !0 }).length > 0
7529
+ ) : o.filter((v) => reject(filter(values(r), { group: v }), { hidden: !0 }).length > 0),
7531
7530
  [r, N, o, d]
7532
- ), y = useMemo(
7533
- () => sortBy(w, (C) => CORE_GROUPS.indexOf(C) === -1 ? 99 : CORE_GROUPS.indexOf(C)),
7531
+ ), S = useMemo(
7532
+ () => sortBy(w, (v) => CORE_GROUPS.indexOf(v) === -1 ? 99 : CORE_GROUPS.indexOf(v)),
7534
7533
  [w]
7535
- ), v = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), B = useMemo(() => m === "all" ? y : [m], [y, m]);
7534
+ ), k = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), j = useMemo(() => m === "all" ? S : [m], [S, m]);
7536
7535
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7537
7536
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7538
7537
  Input$1,
@@ -7542,32 +7541,32 @@ const registerChaiLibrary = (o, r) => {
7542
7541
  placeholder: i("Search blocks..."),
7543
7542
  value: d,
7544
7543
  className: "-ml-2",
7545
- onChange: (C) => p(C.target.value)
7544
+ onChange: (v) => p(v.target.value)
7546
7545
  }
7547
7546
  ) }),
7548
7547
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
7549
- y.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
7548
+ S.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
7550
7549
  /* @__PURE__ */ jsx(
7551
7550
  "button",
7552
7551
  {
7553
- onClick: () => _("all"),
7552
+ onClick: () => E("all"),
7554
7553
  onMouseEnter: () => A("all"),
7555
- onMouseLeave: E,
7554
+ onMouseLeave: _,
7556
7555
  className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || f === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7557
7556
  children: i("All")
7558
7557
  },
7559
7558
  "sidebar-all"
7560
7559
  ),
7561
- y.map((C) => /* @__PURE__ */ jsx(
7560
+ S.map((v) => /* @__PURE__ */ jsx(
7562
7561
  "button",
7563
7562
  {
7564
- onClick: () => _(C),
7565
- onMouseEnter: () => A(C),
7566
- onMouseLeave: E,
7567
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === C || f === C ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7568
- children: capitalize(i(C.toLowerCase()))
7563
+ onClick: () => E(v),
7564
+ onMouseEnter: () => A(v),
7565
+ onMouseLeave: _,
7566
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === v || f === v ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7567
+ children: capitalize(i(v.toLowerCase()))
7569
7568
  },
7570
- `sidebar-${C}`
7569
+ `sidebar-${v}`
7571
7570
  ))
7572
7571
  ] }) }) }),
7573
7572
  /* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: w.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
@@ -7575,22 +7574,22 @@ const registerChaiLibrary = (o, r) => {
7575
7574
  ' "',
7576
7575
  d,
7577
7576
  '"'
7578
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: B.map((C) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7579
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(C.toLowerCase())) }),
7577
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: j.map((v) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7578
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(v.toLowerCase())) }),
7580
7579
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7581
- m === "all" ? filter(values(v), { group: C }) : values(v),
7580
+ m === "all" ? filter(values(k), { group: v }) : values(k),
7582
7581
  { hidden: !0 }
7583
- ).map((j) => /* @__PURE__ */ jsx(
7582
+ ).map((B) => /* @__PURE__ */ jsx(
7584
7583
  CoreBlock,
7585
7584
  {
7586
7585
  parentId: n,
7587
7586
  position: a,
7588
- block: j,
7589
- disabled: !canAcceptChildBlock(h, j.type) || !canBeNestedInside(h, j.type)
7587
+ block: B,
7588
+ disabled: !canAcceptChildBlock(h, B.type) || !canBeNestedInside(h, B.type)
7590
7589
  },
7591
- j.type
7590
+ B.type
7592
7591
  )) })
7593
- ] }, C)) }) }) })
7592
+ ] }, v)) }) }) })
7594
7593
  ] })
7595
7594
  ] });
7596
7595
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -7943,33 +7942,33 @@ const Input = ({ node: o }) => {
7943
7942
  var P;
7944
7943
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7945
7944
  let p = null;
7946
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: x, isSelected: f, willReceiveDrop: k, isDragging: b, isEditing: A, handleClick: E } = o, _ = (L) => {
7945
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: x, isSelected: f, willReceiveDrop: y, isDragging: b, isEditing: A, handleClick: _ } = o, E = (L) => {
7947
7946
  L.stopPropagation(), !l.includes(m) && o.toggle();
7948
7947
  }, N = (L) => {
7949
7948
  L.isInternal && (p = L.isOpen, L.isOpen && L.close());
7950
7949
  }, w = (L) => {
7951
7950
  L.isInternal && p !== null && (p ? L.open() : L.close(), p = null);
7952
- }, [y, v] = useAtom$1(currentAddSelection), B = () => {
7951
+ }, [S, k] = useAtom$1(currentAddSelection), j = () => {
7953
7952
  var L;
7954
- S(), o.parent.isSelected || v((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
7955
- }, S = () => {
7956
- v(null);
7957
- }, C = (L) => {
7958
- S(), L.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), E(L);
7953
+ C(), o.parent.isSelected || k((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
7954
+ }, C = () => {
7955
+ k(null);
7956
+ }, v = (L) => {
7957
+ C(), L.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), _(L);
7959
7958
  };
7960
7959
  useEffect(() => {
7961
7960
  const L = setTimeout(() => {
7962
- k && !o.isOpen && !b && !l.includes(m) && o.toggle();
7961
+ y && !o.isOpen && !b && !l.includes(m) && o.toggle();
7963
7962
  }, 500);
7964
7963
  return () => clearTimeout(L);
7965
- }, [k, o, b]);
7966
- const j = (L, D) => {
7964
+ }, [y, o, b]);
7965
+ const B = (L, D) => {
7967
7966
  const R = c.contentDocument || c.contentWindow.document, M = R.querySelector(`[data-block-id=${L}]`);
7968
7967
  M && M.setAttribute("data-drop", D);
7969
7968
  const $ = M.getBoundingClientRect(), O = c.getBoundingClientRect();
7970
7969
  $.top >= O.top && $.left >= O.left && $.bottom <= O.bottom && $.right <= O.right || (R.documentElement.scrollTop = M.offsetTop - O.top);
7971
7970
  }, I = (L) => {
7972
- S();
7971
+ C();
7973
7972
  const D = get(o, "parent.id");
7974
7973
  D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: L }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: L });
7975
7974
  };
@@ -7997,20 +7996,20 @@ const Input = ({ node: o }) => {
7997
7996
  {
7998
7997
  onMouseEnter: () => g(m),
7999
7998
  onMouseLeave: () => h(),
8000
- onClick: C,
7999
+ onClick: v,
8001
8000
  style: r,
8002
8001
  "data-node-id": m,
8003
8002
  ref: l.includes(m) ? null : n,
8004
8003
  onDragStart: () => N(o),
8005
8004
  onDragEnd: () => w(o),
8006
8005
  onDragOver: (L) => {
8007
- L.preventDefault(), j(m, "yes");
8006
+ L.preventDefault(), B(m, "yes");
8008
8007
  },
8009
8008
  onDragLeave: (L) => {
8010
- L.preventDefault(), j(m, "no");
8009
+ L.preventDefault(), B(m, "no");
8011
8010
  },
8012
8011
  onDrop: (L) => {
8013
- L.preventDefault(), j(m, "no");
8012
+ L.preventDefault(), B(m, "no");
8014
8013
  },
8015
8014
  children: [
8016
8015
  d(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
@@ -8019,8 +8018,8 @@ const Input = ({ node: o }) => {
8019
8018
  onClick: (L) => {
8020
8019
  L.stopPropagation(), I(o.childIndex);
8021
8020
  },
8022
- onMouseEnter: B,
8023
- onMouseLeave: S,
8021
+ onMouseEnter: j,
8022
+ onMouseLeave: C,
8024
8023
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
8025
8024
  children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary p-1 outline outline-2 outline-white hover:bg-primary", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3 stroke-[4] text-white" }) })
8026
8025
  }
@@ -8031,8 +8030,8 @@ const Input = ({ node: o }) => {
8031
8030
  className: cn(
8032
8031
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
8033
8032
  f ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
8034
- k && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
8035
- (o == null ? void 0 : o.id) === y ? "bg-primary/10" : "",
8033
+ y && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
8034
+ (o == null ? void 0 : o.id) === S ? "bg-primary/10" : "",
8036
8035
  b && "opacity-20",
8037
8036
  l.includes(m) ? "opacity-50" : "",
8038
8037
  T && f && "bg-primary/20 text-primary"
@@ -8043,7 +8042,7 @@ const Input = ({ node: o }) => {
8043
8042
  "div",
8044
8043
  {
8045
8044
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
8046
- children: u && /* @__PURE__ */ jsx("button", { onClick: _, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${f ? "text-white" : "text-slate-400"}` }) })
8045
+ children: u && /* @__PURE__ */ jsx("button", { onClick: E, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${f ? "text-white" : "text-slate-400"}` }) })
8047
8046
  }
8048
8047
  ),
8049
8048
  /* @__PURE__ */ jsxs(
@@ -8527,23 +8526,23 @@ const Input = ({ node: o }) => {
8527
8526
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
8528
8527
  const [r, n] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions();
8529
8528
  if (d) {
8530
- const w = d.map((y) => Object.keys(y)[0]);
8531
- DEFAULT_THEME_PRESET.forEach((y) => {
8532
- const v = Object.keys(y)[0];
8533
- w.includes(v) || d.push(y);
8529
+ const w = d.map((S) => Object.keys(S)[0]);
8530
+ DEFAULT_THEME_PRESET.forEach((S) => {
8531
+ const k = Object.keys(S)[0];
8532
+ w.includes(k) || d.push(S);
8534
8533
  });
8535
8534
  }
8536
8535
  const [g, h] = useTheme(), m = useThemeOptions(), { t: x } = useTranslation(), f = React.useCallback(
8537
8536
  (w) => {
8538
- const y = { ...g };
8539
- setPreviousTheme(y), h(w), toast.success("Theme updated", {
8537
+ const S = { ...g };
8538
+ setPreviousTheme(S), h(w), toast.success("Theme updated", {
8540
8539
  action: {
8541
8540
  label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
8542
8541
  /* @__PURE__ */ jsx(Undo$1, { className: "h-4 w-4" }),
8543
8542
  " Undo"
8544
8543
  ] }),
8545
8544
  onClick: () => {
8546
- h(y), clearPreviousTheme(), toast.dismiss();
8545
+ h(S), clearPreviousTheme(), toast.dismiss();
8547
8546
  }
8548
8547
  },
8549
8548
  closeButton: !0,
@@ -8551,28 +8550,28 @@ const Input = ({ node: o }) => {
8551
8550
  });
8552
8551
  },
8553
8552
  [g, h]
8554
- ), k = () => {
8555
- const w = d.find((y) => Object.keys(y)[0] === a);
8553
+ ), y = () => {
8554
+ const w = d.find((S) => Object.keys(S)[0] === a);
8556
8555
  if (w) {
8557
- const y = Object.values(w)[0];
8558
- y && typeof y == "object" && "fontFamily" in y && "borderRadius" in y && "colors" in y ? (f(y), l("")) : console.error("Invalid preset structure:", y);
8556
+ const S = Object.values(w)[0];
8557
+ S && typeof S == "object" && "fontFamily" in S && "borderRadius" in S && "colors" in S ? (f(S), l("")) : console.error("Invalid preset structure:", S);
8559
8558
  } else
8560
8559
  console.error("Preset not found:", a);
8561
8560
  }, b = (w) => {
8562
8561
  f(w), l("");
8563
8562
  }, A = useDebouncedCallback(
8564
- (w, y) => {
8563
+ (w, S) => {
8565
8564
  h(() => ({
8566
8565
  ...g,
8567
8566
  fontFamily: {
8568
8567
  ...g.fontFamily,
8569
- [w.replace(/font-/g, "")]: y
8568
+ [w.replace(/font-/g, "")]: S
8570
8569
  }
8571
8570
  }));
8572
8571
  },
8573
8572
  [g],
8574
8573
  200
8575
- ), E = React.useCallback(
8574
+ ), _ = React.useCallback(
8576
8575
  (w) => {
8577
8576
  h(() => ({
8578
8577
  ...g,
@@ -8580,33 +8579,33 @@ const Input = ({ node: o }) => {
8580
8579
  }));
8581
8580
  },
8582
8581
  [g]
8583
- ), _ = useDebouncedCallback(
8584
- (w, y) => {
8582
+ ), E = useDebouncedCallback(
8583
+ (w, S) => {
8585
8584
  h(() => {
8586
- const v = get(g, `colors.${w}`);
8587
- return r ? set(v, 1, y) : set(v, 0, y), {
8585
+ const k = get(g, `colors.${w}`);
8586
+ return r ? set(k, 1, S) : set(k, 0, S), {
8588
8587
  ...g,
8589
8588
  colors: {
8590
8589
  ...g.colors,
8591
- [w]: v
8590
+ [w]: k
8592
8591
  }
8593
8592
  };
8594
8593
  });
8595
8594
  },
8596
8595
  [g],
8597
8596
  200
8598
- ), N = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([y]) => {
8599
- const v = get(g, `colors.${y}.${r ? 1 : 0}`);
8600
- return v ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8597
+ ), N = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([S]) => {
8598
+ const k = get(g, `colors.${S}.${r ? 1 : 0}`);
8599
+ return k ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8601
8600
  /* @__PURE__ */ jsx(
8602
8601
  ColorPickerInput,
8603
8602
  {
8604
- value: v,
8605
- onChange: (B) => _(y, B)
8603
+ value: k,
8604
+ onChange: (j) => E(S, j)
8606
8605
  }
8607
8606
  ),
8608
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: y.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((B) => B.charAt(0).toUpperCase() + B.slice(1)).join(" ") + (!y.toLowerCase().includes("foreground") && !y.toLowerCase().includes("border") && !y.toLowerCase().includes("input") && !y.toLowerCase().includes("ring") && !y.toLowerCase().includes("background") ? " Background" : "") })
8609
- ] }, y) : null;
8607
+ /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: S.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((j) => j.charAt(0).toUpperCase() + j.slice(1)).join(" ") + (!S.toLowerCase().includes("foreground") && !S.toLowerCase().includes("border") && !S.toLowerCase().includes("input") && !S.toLowerCase().includes("ring") && !S.toLowerCase().includes("background") ? " Background" : "") })
8608
+ ] }, S) : null;
8610
8609
  }) });
8611
8610
  return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
8612
8611
  /* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
@@ -8622,11 +8621,11 @@ const Input = ({ node: o }) => {
8622
8621
  /* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
8623
8622
  /* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
8624
8623
  /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((w) => {
8625
- const y = Object.keys(w)[0], v = y.replaceAll("_", " ");
8626
- return /* @__PURE__ */ jsx(SelectItem, { value: y, children: capitalize(v) }, y);
8624
+ const S = Object.keys(w)[0], k = S.replaceAll("_", " ");
8625
+ return /* @__PURE__ */ jsx(SelectItem, { value: S, children: capitalize(k) }, S);
8627
8626
  }) })
8628
8627
  ] }) }),
8629
- /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: k, children: x("Apply") }) })
8628
+ /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: y, children: x("Apply") }) })
8630
8629
  ] })
8631
8630
  ] }),
8632
8631
  /* @__PURE__ */ jsx(Separator, {}),
@@ -8635,12 +8634,12 @@ const Input = ({ node: o }) => {
8635
8634
  /* @__PURE__ */ jsx(Type, { className: "h-3 w-3 text-gray-600" }),
8636
8635
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Typography" })
8637
8636
  ] }),
8638
- (m == null ? void 0 : m.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(m.fontFamily).map(([w, y]) => /* @__PURE__ */ jsx(
8637
+ (m == null ? void 0 : m.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(m.fontFamily).map(([w, S]) => /* @__PURE__ */ jsx(
8639
8638
  FontSelector,
8640
8639
  {
8641
8640
  label: w,
8642
- value: g.fontFamily[w.replace(/font-/g, "")] || y[Object.keys(y)[0]],
8643
- onChange: (v) => A(w, v)
8641
+ value: g.fontFamily[w.replace(/font-/g, "")] || S[Object.keys(S)[0]],
8642
+ onChange: (k) => A(w, k)
8644
8643
  },
8645
8644
  w
8646
8645
  )) }),
@@ -8653,7 +8652,7 @@ const Input = ({ node: o }) => {
8653
8652
  ] }),
8654
8653
  /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: g.borderRadius })
8655
8654
  ] }),
8656
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: g.borderRadius, onChange: E }) })
8655
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: g.borderRadius, onChange: _ }) })
8657
8656
  ] }),
8658
8657
  /* @__PURE__ */ jsx(Separator, {}),
8659
8658
  (m == null ? void 0 : m.colors) && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
@@ -9306,24 +9305,24 @@ function AIChatPanel() {
9306
9305
  content: "This is a sample response from the AI assistant. In a real implementation, this would be replaced with an actual response from the AI model.",
9307
9306
  timestamp: /* @__PURE__ */ new Date()
9308
9307
  };
9309
- r((E) => [...E, A]), i(!1), d(null);
9308
+ r((_) => [..._, A]), i(!1), d(null);
9310
9309
  }, 1500);
9311
9310
  }, m = (b) => {
9312
9311
  b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
9313
9312
  }, x = (b) => {
9314
- var E;
9315
- const A = (E = b.target.files) == null ? void 0 : E[0];
9313
+ var _;
9314
+ const A = (_ = b.target.files) == null ? void 0 : _[0];
9316
9315
  if (A) {
9317
- const _ = new FileReader();
9318
- _.onload = (N) => {
9316
+ const E = new FileReader();
9317
+ E.onload = (N) => {
9319
9318
  var w;
9320
9319
  d((w = N.target) == null ? void 0 : w.result);
9321
- }, _.readAsDataURL(A);
9320
+ }, E.readAsDataURL(A);
9322
9321
  }
9323
9322
  }, f = () => {
9324
9323
  var b;
9325
9324
  (b = p.current) == null || b.click();
9326
- }, k = () => {
9325
+ }, y = () => {
9327
9326
  d(null), p.current && (p.current.value = "");
9328
9327
  };
9329
9328
  return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
@@ -9369,7 +9368,7 @@ function AIChatPanel() {
9369
9368
  size: "icon",
9370
9369
  variant: "destructive",
9371
9370
  className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
9372
- onClick: k,
9371
+ onClick: y,
9373
9372
  children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
9374
9373
  }
9375
9374
  )
@@ -9512,7 +9511,7 @@ const AiAssistant = () => {
9512
9511
  preloadedAttributes: r = [],
9513
9512
  onAttributesChange: n
9514
9513
  }) {
9515
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), x = useRef(null), f = useRef(null), k = usePageExternalData();
9514
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), x = useRef(null), f = useRef(null), y = usePageExternalData();
9516
9515
  useEffect(() => {
9517
9516
  l(r);
9518
9517
  }, [r]);
@@ -9522,43 +9521,43 @@ const AiAssistant = () => {
9522
9521
  return;
9523
9522
  }
9524
9523
  if (i) {
9525
- const y = [...a, { key: i, value: d }];
9526
- n(y), l(a), c(""), p(""), m("");
9524
+ const S = [...a, { key: i, value: d }];
9525
+ n(S), l(a), c(""), p(""), m("");
9527
9526
  }
9528
- }, A = (y) => {
9529
- const v = a.filter((B, S) => S !== y);
9530
- n(v), l(v);
9531
- }, E = (y) => {
9532
- g(y), c(a[y].key), p(a[y].value);
9533
- }, _ = () => {
9527
+ }, A = (S) => {
9528
+ const k = a.filter((j, C) => C !== S);
9529
+ n(k), l(k);
9530
+ }, _ = (S) => {
9531
+ g(S), c(a[S].key), p(a[S].value);
9532
+ }, E = () => {
9534
9533
  if (i.startsWith("@")) {
9535
9534
  m("Attribute keys cannot start with '@'");
9536
9535
  return;
9537
9536
  }
9538
9537
  if (u !== null && i) {
9539
- const y = [...a];
9540
- y[u] = { key: i, value: d }, n(y), l(y), g(null), c(""), p(""), m("");
9538
+ const S = [...a];
9539
+ S[u] = { key: i, value: d }, n(S), l(S), g(null), c(""), p(""), m("");
9541
9540
  }
9542
- }, N = (y) => {
9543
- y.key === "Enter" && !y.shiftKey && (y.preventDefault(), u !== null ? _() : b());
9544
- }, w = useCallback((y) => {
9545
- const v = (C) => /[.,!?;:]/.test(C), B = (C, j, I) => {
9541
+ }, N = (S) => {
9542
+ S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? E() : b());
9543
+ }, w = useCallback((S) => {
9544
+ const k = (v) => /[.,!?;:]/.test(v), j = (v, B, I) => {
9546
9545
  let T = "", P = "";
9547
- const L = j > 0 ? C[j - 1] : "", D = j < C.length ? C[j] : "";
9548
- return j > 0 && (L === "." || !v(L) && L !== " ") && (T = " "), j < C.length && !v(D) && D !== " " && (P = " "), {
9546
+ const L = B > 0 ? v[B - 1] : "", D = B < v.length ? v[B] : "";
9547
+ return B > 0 && (L === "." || !k(L) && L !== " ") && (T = " "), B < v.length && !k(D) && D !== " " && (P = " "), {
9549
9548
  text: T + I + P,
9550
9549
  prefixLength: T.length,
9551
9550
  suffixLength: P.length
9552
9551
  };
9553
- }, S = f.current;
9554
- if (S) {
9555
- const C = S.selectionStart || 0, j = S.value || "", I = S.selectionEnd || C;
9556
- if (I > C) {
9557
- const R = `{{${y}}}`, { text: M } = B(j, C, R), $ = j.slice(0, C) + M + j.slice(I);
9552
+ }, C = f.current;
9553
+ if (C) {
9554
+ const v = C.selectionStart || 0, B = C.value || "", I = C.selectionEnd || v;
9555
+ if (I > v) {
9556
+ const R = `{{${S}}}`, { text: M } = j(B, v, R), $ = B.slice(0, v) + M + B.slice(I);
9558
9557
  p($);
9559
9558
  return;
9560
9559
  }
9561
- const P = `{{${y}}}`, { text: L } = B(j, C, P), D = j.slice(0, C) + L + j.slice(C);
9560
+ const P = `{{${S}}}`, { text: L } = j(B, v, P), D = B.slice(0, v) + L + B.slice(v);
9562
9561
  p(D);
9563
9562
  }
9564
9563
  }, []);
@@ -9566,8 +9565,8 @@ const AiAssistant = () => {
9566
9565
  /* @__PURE__ */ jsxs(
9567
9566
  "form",
9568
9567
  {
9569
- onSubmit: (y) => {
9570
- y.preventDefault(), u !== null ? _() : b();
9568
+ onSubmit: (S) => {
9569
+ S.preventDefault(), u !== null ? E() : b();
9571
9570
  },
9572
9571
  className: "space-y-3",
9573
9572
  children: [
@@ -9583,7 +9582,7 @@ const AiAssistant = () => {
9583
9582
  id: "attrKey",
9584
9583
  ref: x,
9585
9584
  value: i,
9586
- onChange: (y) => c(y.target.value),
9585
+ onChange: (S) => c(S.target.value),
9587
9586
  placeholder: "Enter Key",
9588
9587
  className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
9589
9588
  }
@@ -9592,7 +9591,7 @@ const AiAssistant = () => {
9592
9591
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9593
9592
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9594
9593
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9595
- !isEmpty(k) && /* @__PURE__ */ jsx(NestedPathSelector, { data: k, onSelect: w })
9594
+ !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: w })
9596
9595
  ] }),
9597
9596
  /* @__PURE__ */ jsx(
9598
9597
  Textarea,
@@ -9604,7 +9603,7 @@ const AiAssistant = () => {
9604
9603
  rows: 2,
9605
9604
  ref: f,
9606
9605
  value: d,
9607
- onChange: (y) => p(y.target.value),
9606
+ onChange: (S) => p(S.target.value),
9608
9607
  onKeyDown: N,
9609
9608
  placeholder: "Enter Value",
9610
9609
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
@@ -9617,16 +9616,16 @@ const AiAssistant = () => {
9617
9616
  ]
9618
9617
  }
9619
9618
  ),
9620
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((y, v) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9619
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, k) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9621
9620
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9622
- /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: y.key }),
9623
- /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: y.value.toString() })
9621
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
9622
+ /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: S.value.toString() })
9624
9623
  ] }),
9625
9624
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9626
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => E(v), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9627
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(v), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9625
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => _(k), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9626
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(k), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9628
9627
  ] })
9629
- ] }, v)) })
9628
+ ] }, k)) })
9630
9629
  ] });
9631
9630
  }), BlockAttributesEditor = React.memo(() => {
9632
9631
  const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9788,70 +9787,70 @@ const RootLayout = () => {
9788
9787
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9789
9788
  n("outline");
9790
9789
  });
9791
- const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((y) => {
9792
- y.preventDefault();
9793
- }, []), m = useCallback(
9794
- (y) => {
9795
- n(r === y ? null : y);
9790
+ const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = reverse([...g ?? []]), m = useCallback((k) => {
9791
+ k.preventDefault();
9792
+ }, []), x = useCallback(
9793
+ (k) => {
9794
+ n(r === k ? null : k);
9796
9795
  },
9797
9796
  [r]
9798
- ), { t: x } = useTranslation(), f = useMemo(
9797
+ ), { t: f } = useTranslation(), y = useMemo(
9799
9798
  () => [...p, ...u, ...g],
9800
9799
  [p, u, g]
9801
- ), k = useBuilderProp("htmlDir", "ltr"), b = find(f, { id: r }) ?? first(f), A = get(b, "width", DEFAULT_PANEL_WIDTH);
9800
+ ), b = useBuilderProp("htmlDir", "ltr"), A = find(y, { id: r }) ?? first(y), _ = get(A, "width", DEFAULT_PANEL_WIDTH);
9802
9801
  useEffect(() => {
9803
9802
  if (r !== null) {
9804
- const y = find(f, { id: r });
9805
- y && get(y, "view", "standard") === "standard" && (a.current = r, i(get(y, "width", DEFAULT_PANEL_WIDTH)));
9803
+ const k = find(y, { id: r });
9804
+ k && get(k, "view", "standard") === "standard" && (a.current = r, i(get(k, "width", DEFAULT_PANEL_WIDTH)));
9806
9805
  }
9807
- }, [r, f]);
9806
+ }, [r, y]);
9808
9807
  const E = useMemo(() => {
9809
9808
  if (r === null) return 0;
9810
- const y = find(f, { id: r });
9811
- return get(y, "view", "standard") === "standard" ? A : l;
9812
- }, [r, A, l, f]), _ = useCallback(() => {
9809
+ const k = find(y, { id: r });
9810
+ return get(k, "view", "standard") === "standard" ? _ : l;
9811
+ }, [r, _, l, y]), N = useCallback(() => {
9813
9812
  n(a.current);
9814
- }, [n]), N = useCallback(() => {
9813
+ }, [n]), w = useCallback(() => {
9815
9814
  n("outline");
9816
9815
  }, [n]);
9817
9816
  useEffect(() => {
9818
- find(f, { id: r }) || n("outline");
9819
- }, [r, f]);
9820
- const w = useCallback(
9821
- (y) => {
9822
- m(y);
9817
+ find(y, { id: r }) || n("outline");
9818
+ }, [r, y]);
9819
+ const S = useCallback(
9820
+ (k) => {
9821
+ x(k);
9823
9822
  },
9824
- [m]
9823
+ [x]
9825
9824
  );
9826
- return /* @__PURE__ */ jsx("div", { dir: k, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9825
+ return /* @__PURE__ */ jsx("div", { dir: b, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9827
9826
  /* @__PURE__ */ jsxs(
9828
9827
  "div",
9829
9828
  {
9830
- onContextMenu: h,
9829
+ onContextMenu: m,
9831
9830
  className: "flex h-screen max-h-full flex-col bg-background text-foreground",
9832
9831
  children: [
9833
9832
  /* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
9834
9833
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9835
9834
  /* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9836
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((y, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9837
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
9835
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((k, j) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9836
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(k, "button", NoopComponent), {
9838
9837
  position: "top",
9839
- panelId: y.id,
9840
- isActive: r === y.id,
9841
- show: () => w(y.id)
9838
+ panelId: k.id,
9839
+ isActive: r === k.id,
9840
+ show: () => S(k.id)
9842
9841
  }) }),
9843
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(y.label) }) })
9844
- ] }, "button-top-" + v)) }),
9842
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(k.label) }) })
9843
+ ] }, "button-top-" + j)) }),
9845
9844
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9846
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((y, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9847
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
9845
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: h == null ? void 0 : h.map((k, j) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9846
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(k, "button", NoopComponent), {
9848
9847
  position: "bottom",
9849
- panelId: y.id,
9850
- isActive: r === y.id,
9851
- show: () => w(y.id)
9848
+ panelId: k.id,
9849
+ isActive: r === k.id,
9850
+ show: () => S(k.id)
9852
9851
  }) }),
9853
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(y.label) }) })
9854
- ] }, "button-bottom-" + v)) })
9852
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(k.label) }) })
9853
+ ] }, "button-bottom-" + j)) })
9855
9854
  ] }),
9856
9855
  /* @__PURE__ */ jsx(
9857
9856
  motion.div,
@@ -9861,15 +9860,15 @@ const RootLayout = () => {
9861
9860
  initial: { width: E },
9862
9861
  animate: { width: E },
9863
9862
  transition: { duration: 0.3, ease: "easeInOut" },
9864
- children: r !== null && get(b, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
9863
+ children: r !== null && get(A, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
9865
9864
  /* @__PURE__ */ jsx(
9866
9865
  "div",
9867
9866
  {
9868
- className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(b, "isInternal", !1) ? "" : "w-64"}`,
9869
- children: /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
9867
+ className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(A, "isInternal", !1) ? "" : "w-64"}`,
9868
+ children: /* @__PURE__ */ jsx("span", { children: f(get(A, "label", "")) })
9870
9869
  }
9871
9870
  ),
9872
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {}) }) })
9871
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(A, "panel", NoopComponent), {}) }) })
9873
9872
  ] })
9874
9873
  }
9875
9874
  ),
@@ -9889,11 +9888,11 @@ const RootLayout = () => {
9889
9888
  /* @__PURE__ */ jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between gap-2", children: c === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9890
9889
  /* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
9891
9890
  " ",
9892
- x("AI Assistant")
9891
+ f("AI Assistant")
9893
9892
  ] }) }) : c === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
9894
9893
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
9895
- /* @__PURE__ */ jsx(Palette, { className: "w-4 h-4 text-gray-600" }),
9896
- x("Theme Settings")
9894
+ /* @__PURE__ */ jsx(Palette, { className: "h-4 w-4 text-gray-600" }),
9895
+ f("Theme Settings")
9897
9896
  ] }),
9898
9897
  /* @__PURE__ */ jsx(
9899
9898
  Button,
@@ -9915,34 +9914,34 @@ const RootLayout = () => {
9915
9914
  }
9916
9915
  ),
9917
9916
  /* @__PURE__ */ jsx(AddBlocksDialog, {}),
9918
- r !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(
9917
+ r !== null && get(A, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => N(), children: /* @__PURE__ */ jsxs(
9919
9918
  SheetContent,
9920
9919
  {
9921
9920
  side: "left",
9922
9921
  className: "flex flex-col gap-0 p-0 sm:max-w-full",
9923
- style: { width: `${A}px` },
9922
+ style: { width: `${_}px` },
9924
9923
  children: [
9925
9924
  /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
9926
- /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
9927
- /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
9925
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(A, "icon", null) }),
9926
+ /* @__PURE__ */ jsx("span", { children: f(get(A, "label", "")) })
9928
9927
  ] }) }),
9929
- /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
9930
- close: N
9928
+ /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(A, "panel", NoopComponent), {
9929
+ close: w
9931
9930
  }) }) })
9932
9931
  ]
9933
9932
  }
9934
9933
  ) }),
9935
9934
  " ",
9936
- r !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${A}px` }, children: [
9935
+ r !== null && get(A, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => N(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${_}px` }, children: [
9937
9936
  /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
9938
- /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
9939
- /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
9937
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(A, "icon", null) }),
9938
+ /* @__PURE__ */ jsx("span", { children: f(get(A, "label", "")) })
9940
9939
  ] }) }),
9941
- /* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
9942
- close: N
9940
+ /* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(A, "panel", NoopComponent), {
9941
+ close: w
9943
9942
  }) }) })
9944
9943
  ] }) }),
9945
- r !== null && get(b, "view") === "overlay" && /* @__PURE__ */ jsx(
9944
+ r !== null && get(A, "view") === "overlay" && /* @__PURE__ */ jsx(
9946
9945
  motion.div,
9947
9946
  {
9948
9947
  className: "absolute bottom-0 left-12 right-0 top-0 z-50",
@@ -9961,13 +9960,13 @@ const RootLayout = () => {
9961
9960
  children: [
9962
9961
  /* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
9963
9962
  /* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
9964
- /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9965
- /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
9963
+ /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(A, "icon", null) }),
9964
+ /* @__PURE__ */ jsx("span", { children: f(get(A, "label", "")) })
9966
9965
  ] }),
9967
- /* @__PURE__ */ jsx(Button, { onClick: () => _(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
9966
+ /* @__PURE__ */ jsx(Button, { onClick: () => N(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
9968
9967
  ] }),
9969
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
9970
- close: N
9968
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(A, "panel", NoopComponent), {
9969
+ close: w
9971
9970
  }) }) })
9972
9971
  ]
9973
9972
  }
@@ -10008,9 +10007,9 @@ const RootLayout = () => {
10008
10007
  if (!l.trim()) return a;
10009
10008
  const f = l.toLowerCase();
10010
10009
  return Object.fromEntries(
10011
- Object.entries(a).filter(([k, b]) => {
10010
+ Object.entries(a).filter(([y, b]) => {
10012
10011
  var A;
10013
- return (k == null ? void 0 : k.toLowerCase().includes(f)) || ((A = b == null ? void 0 : b.description) == null ? void 0 : A.toLowerCase().includes(f));
10012
+ return (y == null ? void 0 : y.toLowerCase().includes(f)) || ((A = b == null ? void 0 : b.description) == null ? void 0 : A.toLowerCase().includes(f));
10014
10013
  })
10015
10014
  );
10016
10015
  }, [a, l]), h = (f) => {
@@ -10020,8 +10019,8 @@ const RootLayout = () => {
10020
10019
  });
10021
10020
  }, m = (f) => {
10022
10021
  if (!c) return;
10023
- const k = f.clientX - p.x, b = f.clientY - p.y, A = f.currentTarget, E = A.offsetWidth, _ = A.offsetHeight, N = window.innerWidth - E, w = window.innerHeight - _, y = Math.max(0, Math.min(k, N)), v = Math.max(0, Math.min(b, w));
10024
- n(y, v);
10022
+ const y = f.clientX - p.x, b = f.clientY - p.y, A = f.currentTarget, _ = A.offsetWidth, E = A.offsetHeight, N = window.innerWidth - _, w = window.innerHeight - E, S = Math.max(0, Math.min(y, N)), k = Math.max(0, Math.min(b, w));
10023
+ n(S, k);
10025
10024
  }, x = () => {
10026
10025
  d(!1);
10027
10026
  };
@@ -10083,7 +10082,7 @@ const RootLayout = () => {
10083
10082
  )
10084
10083
  ] })
10085
10084
  ] }),
10086
- /* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(g).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(g).map(([f, k]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: f, options: k }, f)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
10085
+ /* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(g).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(g).map(([f, y]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: f, options: y }, f)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
10087
10086
  'No features found matching "',
10088
10087
  l,
10089
10088
  '"'
@@ -10198,71 +10197,71 @@ const RootLayout = () => {
10198
10197
  var f;
10199
10198
  return (f = m.onMount) == null ? void 0 : f.call(m, x);
10200
10199
  }, ...h) => {
10201
- const m = h[0] || ((v) => {
10202
- let B = o.get(v);
10203
- return B || (B = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(v, B), u == null || u(v, y)), B;
10200
+ const m = h[0] || ((k) => {
10201
+ let j = o.get(k);
10202
+ return j || (j = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(k, j), u == null || u(k, S)), j;
10204
10203
  }), x = h[1] || (() => {
10205
- const v = [], B = (S) => {
10204
+ const k = [], j = (C) => {
10206
10205
  try {
10207
- S();
10208
- } catch (C) {
10209
- v.push(C);
10206
+ C();
10207
+ } catch (v) {
10208
+ k.push(v);
10210
10209
  }
10211
10210
  };
10212
10211
  do {
10213
- c.f && B(c.f);
10214
- const S = /* @__PURE__ */ new Set(), C = S.add.bind(S);
10215
- a.forEach((j) => {
10212
+ c.f && j(c.f);
10213
+ const C = /* @__PURE__ */ new Set(), v = C.add.bind(C);
10214
+ a.forEach((B) => {
10216
10215
  var I;
10217
- return (I = r.get(j)) == null ? void 0 : I.l.forEach(C);
10218
- }), a.clear(), i.forEach(C), i.clear(), l.forEach(C), l.clear(), S.forEach(B), a.size && f();
10216
+ return (I = r.get(B)) == null ? void 0 : I.l.forEach(v);
10217
+ }), a.clear(), i.forEach(v), i.clear(), l.forEach(v), l.clear(), C.forEach(j), a.size && f();
10219
10218
  } while (a.size || i.size || l.size);
10220
- if (v.length)
10221
- throw new AggregateError(v);
10219
+ if (k.length)
10220
+ throw new AggregateError(k);
10222
10221
  }), f = h[2] || (() => {
10223
- const v = [], B = /* @__PURE__ */ new WeakSet(), S = /* @__PURE__ */ new WeakSet(), C = Array.from(a);
10224
- for (; C.length; ) {
10225
- const j = C[C.length - 1], I = m(j);
10226
- if (S.has(j)) {
10227
- C.pop();
10222
+ const k = [], j = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), v = Array.from(a);
10223
+ for (; v.length; ) {
10224
+ const B = v[v.length - 1], I = m(B);
10225
+ if (C.has(B)) {
10226
+ v.pop();
10228
10227
  continue;
10229
10228
  }
10230
- if (B.has(j)) {
10231
- n.get(j) === I.n && v.push([j, I]), S.add(j), C.pop();
10229
+ if (j.has(B)) {
10230
+ n.get(B) === I.n && k.push([B, I]), C.add(B), v.pop();
10232
10231
  continue;
10233
10232
  }
10234
- B.add(j);
10235
- for (const T of getMountedOrPendingDependents(j, I, r))
10236
- B.has(T) || C.push(T);
10233
+ j.add(B);
10234
+ for (const T of getMountedOrPendingDependents(B, I, r))
10235
+ j.has(T) || v.push(T);
10237
10236
  }
10238
- for (let j = v.length - 1; j >= 0; --j) {
10239
- const [I, T] = v[j];
10237
+ for (let B = k.length - 1; B >= 0; --B) {
10238
+ const [I, T] = k[B];
10240
10239
  let P = !1;
10241
10240
  for (const L of T.d.keys())
10242
10241
  if (L !== I && a.has(L)) {
10243
10242
  P = !0;
10244
10243
  break;
10245
10244
  }
10246
- P && (k(I), E(I)), n.delete(I);
10245
+ P && (y(I), _(I)), n.delete(I);
10247
10246
  }
10248
- }), k = h[3] || ((v) => {
10249
- var B;
10250
- const S = m(v);
10251
- if (isAtomStateInitialized(S) && (r.has(v) && n.get(v) !== S.n || Array.from(S.d).every(
10247
+ }), y = h[3] || ((k) => {
10248
+ var j;
10249
+ const C = m(k);
10250
+ if (isAtomStateInitialized(C) && (r.has(k) && n.get(k) !== C.n || Array.from(C.d).every(
10252
10251
  ([R, M]) => (
10253
10252
  // Recursively, read the atom state of the dependency, and
10254
10253
  // check if the atom epoch number is unchanged
10255
- k(R).n === M
10254
+ y(R).n === M
10256
10255
  )
10257
10256
  )))
10258
- return S;
10259
- S.d.clear();
10260
- let C = !0;
10261
- const j = () => {
10262
- r.has(v) && (E(v), f(), x());
10257
+ return C;
10258
+ C.d.clear();
10259
+ let v = !0;
10260
+ const B = () => {
10261
+ r.has(k) && (_(k), f(), x());
10263
10262
  }, I = (R) => {
10264
10263
  var M;
10265
- if (isSelfAtom(v, R)) {
10264
+ if (isSelfAtom(k, R)) {
10266
10265
  const O = m(R);
10267
10266
  if (!isAtomStateInitialized(O))
10268
10267
  if (hasInitialValue(R))
@@ -10271,11 +10270,11 @@ const RootLayout = () => {
10271
10270
  throw new Error("no atom init");
10272
10271
  return returnAtomValue(O);
10273
10272
  }
10274
- const $ = k(R);
10273
+ const $ = y(R);
10275
10274
  try {
10276
10275
  return returnAtomValue($);
10277
10276
  } finally {
10278
- S.d.set(R, $.n), isPendingPromise(S.v) && addPendingPromiseToDependency(v, S.v, $), (M = r.get(R)) == null || M.t.add(v), C || j();
10277
+ C.d.set(R, $.n), isPendingPromise(C.v) && addPendingPromiseToDependency(k, C.v, $), (M = r.get(R)) == null || M.t.add(k), v || B();
10279
10278
  }
10280
10279
  };
10281
10280
  let T, P;
@@ -10284,100 +10283,100 @@ const RootLayout = () => {
10284
10283
  return T || (T = new AbortController()), T.signal;
10285
10284
  },
10286
10285
  get setSelf() {
10287
- return !P && isActuallyWritableAtom(v) && (P = (...R) => {
10288
- if (!C)
10286
+ return !P && isActuallyWritableAtom(k) && (P = (...R) => {
10287
+ if (!v)
10289
10288
  try {
10290
- return A(v, ...R);
10289
+ return A(k, ...R);
10291
10290
  } finally {
10292
10291
  f(), x();
10293
10292
  }
10294
10293
  }), P;
10295
10294
  }
10296
- }, D = S.n;
10295
+ }, D = C.n;
10297
10296
  try {
10298
- const R = d(v, I, L);
10299
- return setAtomStateValueOrPromise(v, R, m), isPromiseLike$1(R) && (registerAbortHandler(R, () => T == null ? void 0 : T.abort()), R.then(
10300
- j,
10301
- j
10302
- )), S;
10297
+ const R = d(k, I, L);
10298
+ return setAtomStateValueOrPromise(k, R, m), isPromiseLike$1(R) && (registerAbortHandler(R, () => T == null ? void 0 : T.abort()), R.then(
10299
+ B,
10300
+ B
10301
+ )), C;
10303
10302
  } catch (R) {
10304
- return delete S.v, S.e = R, ++S.n, S;
10303
+ return delete C.v, C.e = R, ++C.n, C;
10305
10304
  } finally {
10306
- C = !1, D !== S.n && n.get(v) === D && (n.set(v, S.n), a.add(v), (B = c.c) == null || B.call(c, v));
10305
+ v = !1, D !== C.n && n.get(k) === D && (n.set(k, C.n), a.add(k), (j = c.c) == null || j.call(c, k));
10307
10306
  }
10308
- }), b = h[4] || ((v) => {
10309
- const B = [v];
10310
- for (; B.length; ) {
10311
- const S = B.pop(), C = m(S);
10312
- for (const j of getMountedOrPendingDependents(S, C, r)) {
10313
- const I = m(j);
10314
- n.set(j, I.n), B.push(j);
10307
+ }), b = h[4] || ((k) => {
10308
+ const j = [k];
10309
+ for (; j.length; ) {
10310
+ const C = j.pop(), v = m(C);
10311
+ for (const B of getMountedOrPendingDependents(C, v, r)) {
10312
+ const I = m(B);
10313
+ n.set(B, I.n), j.push(B);
10315
10314
  }
10316
10315
  }
10317
- }), A = h[5] || ((v, ...B) => {
10318
- let S = !0;
10319
- const C = (I) => returnAtomValue(k(I)), j = (I, ...T) => {
10316
+ }), A = h[5] || ((k, ...j) => {
10317
+ let C = !0;
10318
+ const v = (I) => returnAtomValue(y(I)), B = (I, ...T) => {
10320
10319
  var P;
10321
10320
  const L = m(I);
10322
10321
  try {
10323
- if (isSelfAtom(v, I)) {
10322
+ if (isSelfAtom(k, I)) {
10324
10323
  if (!hasInitialValue(I))
10325
10324
  throw new Error("atom not writable");
10326
10325
  const D = L.n, R = T[0];
10327
- setAtomStateValueOrPromise(I, R, m), E(I), D !== L.n && (a.add(I), (P = c.c) == null || P.call(c, I), b(I));
10326
+ setAtomStateValueOrPromise(I, R, m), _(I), D !== L.n && (a.add(I), (P = c.c) == null || P.call(c, I), b(I));
10328
10327
  return;
10329
10328
  } else
10330
10329
  return A(I, ...T);
10331
10330
  } finally {
10332
- S || (f(), x());
10331
+ C || (f(), x());
10333
10332
  }
10334
10333
  };
10335
10334
  try {
10336
- return p(v, C, j, ...B);
10335
+ return p(k, v, B, ...j);
10337
10336
  } finally {
10338
- S = !1;
10337
+ C = !1;
10339
10338
  }
10340
- }), E = h[6] || ((v) => {
10341
- var B;
10342
- const S = m(v), C = r.get(v);
10343
- if (C && !isPendingPromise(S.v)) {
10344
- for (const [j, I] of S.d)
10345
- if (!C.d.has(j)) {
10346
- const T = m(j);
10347
- _(j).t.add(v), C.d.add(j), I !== T.n && (a.add(j), (B = c.c) == null || B.call(c, j), b(j));
10339
+ }), _ = h[6] || ((k) => {
10340
+ var j;
10341
+ const C = m(k), v = r.get(k);
10342
+ if (v && !isPendingPromise(C.v)) {
10343
+ for (const [B, I] of C.d)
10344
+ if (!v.d.has(B)) {
10345
+ const T = m(B);
10346
+ E(B).t.add(k), v.d.add(B), I !== T.n && (a.add(B), (j = c.c) == null || j.call(c, B), b(B));
10348
10347
  }
10349
- for (const j of C.d || [])
10350
- if (!S.d.has(j)) {
10351
- C.d.delete(j);
10352
- const I = N(j);
10353
- I == null || I.t.delete(v);
10348
+ for (const B of v.d || [])
10349
+ if (!C.d.has(B)) {
10350
+ v.d.delete(B);
10351
+ const I = N(B);
10352
+ I == null || I.t.delete(k);
10354
10353
  }
10355
10354
  }
10356
- }), _ = h[7] || ((v) => {
10357
- var B;
10358
- const S = m(v);
10359
- let C = r.get(v);
10360
- if (!C) {
10361
- k(v);
10362
- for (const j of S.d.keys())
10363
- _(j).t.add(v);
10364
- if (C = {
10355
+ }), E = h[7] || ((k) => {
10356
+ var j;
10357
+ const C = m(k);
10358
+ let v = r.get(k);
10359
+ if (!v) {
10360
+ y(k);
10361
+ for (const B of C.d.keys())
10362
+ E(B).t.add(k);
10363
+ if (v = {
10365
10364
  l: /* @__PURE__ */ new Set(),
10366
- d: new Set(S.d.keys()),
10365
+ d: new Set(C.d.keys()),
10367
10366
  t: /* @__PURE__ */ new Set()
10368
- }, r.set(v, C), (B = c.m) == null || B.call(c, v), isActuallyWritableAtom(v)) {
10369
- const j = () => {
10367
+ }, r.set(k, v), (j = c.m) == null || j.call(c, k), isActuallyWritableAtom(k)) {
10368
+ const B = () => {
10370
10369
  let I = !0;
10371
10370
  const T = (...P) => {
10372
10371
  try {
10373
- return A(v, ...P);
10372
+ return A(k, ...P);
10374
10373
  } finally {
10375
10374
  I || (f(), x());
10376
10375
  }
10377
10376
  };
10378
10377
  try {
10379
- const P = g(v, T);
10380
- P && (C.u = () => {
10378
+ const P = g(k, T);
10379
+ P && (v.u = () => {
10381
10380
  I = !0;
10382
10381
  try {
10383
10382
  P();
@@ -10389,26 +10388,26 @@ const RootLayout = () => {
10389
10388
  I = !1;
10390
10389
  }
10391
10390
  };
10392
- l.add(j);
10391
+ l.add(B);
10393
10392
  }
10394
10393
  }
10395
- return C;
10396
- }), N = h[8] || ((v) => {
10397
- var B;
10398
- const S = m(v);
10399
- let C = r.get(v);
10400
- if (C && !C.l.size && !Array.from(C.t).some((j) => {
10394
+ return v;
10395
+ }), N = h[8] || ((k) => {
10396
+ var j;
10397
+ const C = m(k);
10398
+ let v = r.get(k);
10399
+ if (v && !v.l.size && !Array.from(v.t).some((B) => {
10401
10400
  var I;
10402
- return (I = r.get(j)) == null ? void 0 : I.d.has(v);
10401
+ return (I = r.get(B)) == null ? void 0 : I.d.has(k);
10403
10402
  })) {
10404
- C.u && i.add(C.u), C = void 0, r.delete(v), (B = c.u) == null || B.call(c, v);
10405
- for (const j of S.d.keys()) {
10406
- const I = N(j);
10407
- I == null || I.t.delete(v);
10403
+ v.u && i.add(v.u), v = void 0, r.delete(k), (j = c.u) == null || j.call(c, k);
10404
+ for (const B of C.d.keys()) {
10405
+ const I = N(B);
10406
+ I == null || I.t.delete(k);
10408
10407
  }
10409
10408
  return;
10410
10409
  }
10411
- return C;
10410
+ return v;
10412
10411
  }), w = [
10413
10412
  // store state
10414
10413
  o,
@@ -10427,29 +10426,29 @@ const RootLayout = () => {
10427
10426
  m,
10428
10427
  x,
10429
10428
  f,
10430
- k,
10429
+ y,
10431
10430
  b,
10432
10431
  A,
10433
- E,
10434
10432
  _,
10433
+ E,
10435
10434
  N
10436
- ], y = {
10437
- get: (v) => returnAtomValue(k(v)),
10438
- set: (v, ...B) => {
10435
+ ], S = {
10436
+ get: (k) => returnAtomValue(y(k)),
10437
+ set: (k, ...j) => {
10439
10438
  try {
10440
- return A(v, ...B);
10439
+ return A(k, ...j);
10441
10440
  } finally {
10442
10441
  f(), x();
10443
10442
  }
10444
10443
  },
10445
- sub: (v, B) => {
10446
- const C = _(v).l;
10447
- return C.add(B), x(), () => {
10448
- C.delete(B), N(v), x();
10444
+ sub: (k, j) => {
10445
+ const v = E(k).l;
10446
+ return v.add(j), x(), () => {
10447
+ v.delete(j), N(k), x();
10449
10448
  };
10450
10449
  }
10451
10450
  };
10452
- return Object.defineProperty(y, BUILDING_BLOCKS, { value: w }), y;
10451
+ return Object.defineProperty(S, BUILDING_BLOCKS, { value: w }), S;
10453
10452
  }, INTERNAL_buildStoreRev1 = buildStore, INTERNAL_registerAbortHandler = registerAbortHandler;
10454
10453
  function createStore() {
10455
10454
  return INTERNAL_buildStoreRev1();
@@ -10621,7 +10620,7 @@ export {
10621
10620
  getBlocksFromHTML as convertHTMLToChaiBlocks,
10622
10621
  generateUUID as generateBlockId,
10623
10622
  getBlocksFromHTML,
10624
- We as i18n,
10623
+ Ue as i18n,
10625
10624
  cn$2 as mergeClasses,
10626
10625
  registerBlockSettingField,
10627
10626
  registerBlockSettingTemplate,
@@ -10687,7 +10686,7 @@ export {
10687
10686
  useTheme,
10688
10687
  useThemeOptions,
10689
10688
  useToggleChaiFeatureFlag,
10690
- Ve as useTranslation,
10689
+ He as useTranslation,
10691
10690
  useUndoManager,
10692
10691
  useUpdateBlocksProps,
10693
10692
  useUpdateBlocksPropsRealtime,