@chaibuilder/sdk 2.2.28 → 2.2.30

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
@@ -4,7 +4,7 @@ var H = (o, n, r) => F(o, typeof n != "symbol" ? n + "" : n, r);
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
6
6
  import { BoxModelIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, LoopIcon, InfoCircledIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, Cross1Icon, BoxIcon, MinusIcon, CrossCircledIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, CaretRightIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, CheckIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
7
- import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isArray, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, flatMapDeep, some, sortBy, round } from "lodash-es";
7
+ import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, flatMapDeep, some, sortBy, round } from "lodash-es";
8
8
  import * as React from "react";
9
9
  import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, useReducer, useDebugValue } from "react";
10
10
  import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
@@ -73,8 +73,6 @@ const activePanelAtom = atom("outline");
73
73
  activePanelAtom.debugLabel = "activePanelAtom";
74
74
  const showPredefinedBlockCategoryAtom = atom("");
75
75
  showPredefinedBlockCategoryAtom.debugLabel = "showPredefinedBlockCategoryAtom";
76
- const inlineEditingActiveAtom = atom("");
77
- inlineEditingActiveAtom.debugLabel = "inlineEditingActiveAtom";
78
76
  const draggingFlagAtom = atom(!1);
79
77
  draggingFlagAtom.debugLabel = "draggingFlagAtom";
80
78
  const treeRefAtom = atom(null);
@@ -351,8 +349,8 @@ function insertBlocksAtPosition(o, n, r, a) {
351
349
  }), l.unshift(m), i = i.map((f) => {
352
350
  if (f._id === r) {
353
351
  const x = { ...f, content: "" };
354
- return Object.keys(x).forEach((y) => {
355
- y.startsWith("content-") && (x[y] = "");
352
+ return Object.keys(x).forEach((k) => {
353
+ k.startsWith("content-") && (x[k] = "");
356
354
  }), x;
357
355
  }
358
356
  return f;
@@ -487,8 +485,8 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
487
485
  m && "content" in m && (r = r.map((f) => {
488
486
  if (f._id === u) {
489
487
  const x = { ...f, content: h.content };
490
- return Object.keys(h).forEach((y) => {
491
- y.startsWith("content-") && (x[y] = h[y]);
488
+ return Object.keys(h).forEach((k) => {
489
+ k.startsWith("content-") && (x[k] = h[k]);
492
490
  }), x;
493
491
  }
494
492
  return f;
@@ -574,30 +572,34 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
574
572
  status: "idle",
575
573
  props: {},
576
574
  error: void 0
577
- }), c = useBuilderProp("getBlockAsyncProps", async (m) => ({})), d = useSetAtom$1(blockRepeaterDataAtom), p = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), u = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), g = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
575
+ }), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), h = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
578
576
  return useEffect(() => {
579
577
  if (n === "mock") {
580
578
  if (isFunction(a)) {
581
- i((f) => ({ ...f, status: "loading", props: {} }));
582
- const m = a({ block: o });
583
- if (!isObject(m))
579
+ i((x) => ({ ...x, status: "loading", props: {} }));
580
+ const f = a({ block: o });
581
+ if (!isObject(f))
584
582
  throw new Error("mockDataProvider should return an object");
585
- i((f) => ({ ...f, status: "loaded", props: m }));
583
+ i((x) => ({ ...x, status: "loaded", props: f }));
586
584
  }
587
585
  return;
588
586
  }
589
- n === "live" && (!u && !g || (i((m) => ({ ...m, status: "loading", props: {} })), c({ block: o }).then((m = {}) => {
590
- u ? (d((f) => ({
591
- ...f,
592
- [o._id]: { status: "loaded", props: isArray(m) ? m : [], repeaterItems: o.repeaterItems }
593
- })), i((f) => ({ ...f, status: "loaded" }))) : i((f) => ({ ...f, status: "loaded", props: isObject(m) ? m : {} }));
594
- }).catch((m) => {
595
- u ? (d((f) => ({
596
- ...f,
597
- [o._id]: { status: "error", error: m, props: [] }
598
- })), i((f) => ({ ...f, status: "error", error: m }))) : i((f) => ({ ...f, status: "error", error: m, props: {} }));
587
+ n === "live" && (!g && !h || (i((f) => ({ ...f, status: "loading", props: {} })), d({ block: o }).then((f = {}) => {
588
+ g ? (p((x) => ({
589
+ ...x,
590
+ [o._id]: {
591
+ status: "loaded",
592
+ props: get(f, "items", []),
593
+ repeaterItems: o.repeaterItems
594
+ }
595
+ })), i((x) => ({ ...x, status: "loaded", props: { totalItems: get(f, "totalItems") } })), c([o._id], { totalItems: get(f, "totalItems") })) : i((x) => ({ ...x, status: "loaded", props: isObject(f) ? f : {} }));
596
+ }).catch((f) => {
597
+ g ? (p((x) => ({
598
+ ...x,
599
+ [o._id]: { status: "error", error: f, props: [] }
600
+ })), i((x) => ({ ...x, status: "error", error: f, props: {} }))) : i((x) => ({ ...x, status: "error", error: f, props: {} }));
599
601
  })));
600
- }, [o == null ? void 0 : o._id, p, u, g, a, n]), {
602
+ }, [o == null ? void 0 : o._id, u, g, h, a, n]), {
601
603
  $loading: get(l, "status") === "loading",
602
604
  ...o ? get(l, "props", {}) : {}
603
605
  };
@@ -797,50 +799,50 @@ const undoRedoStateAtom = atom({
797
799
  updateBlocksProps: c
798
800
  } = useBlocksStoreManager();
799
801
  return {
800
- moveBlocks: (x, y, b) => {
802
+ moveBlocks: (x, k, b) => {
801
803
  const v = map(x, (w) => {
802
- const _ = n.find((N) => N._id === w)._parent || null, A = n.filter((N) => _ ? N._parent === _ : !N._parent).map((N) => N._id).indexOf(w);
803
- return { _id: w, oldParent: _, oldPosition: A };
804
+ const E = n.find((N) => N._id === w)._parent || null, A = n.filter((N) => E ? N._parent === E : !N._parent).map((N) => N._id).indexOf(w);
805
+ return { _id: w, oldParent: E, oldPosition: A };
804
806
  }), B = v.find(({ _id: w }) => w === x[0]);
805
- B && B.oldParent === y && B.oldPosition === b || (i(x, y, b), o({
806
- undo: () => each(v, ({ _id: w, oldParent: E, oldPosition: _ }) => {
807
- i([w], E, _);
807
+ B && B.oldParent === k && B.oldPosition === b || (i(x, k, b), o({
808
+ undo: () => each(v, ({ _id: w, oldParent: _, oldPosition: E }) => {
809
+ i([w], _, E);
808
810
  }),
809
- redo: () => i(x, y, b)
811
+ redo: () => i(x, k, b)
810
812
  }));
811
813
  },
812
- addBlocks: (x, y, b) => {
813
- a(x, y, b), o({
814
+ addBlocks: (x, k, b) => {
815
+ a(x, k, b), o({
814
816
  undo: () => l(map(x, "_id")),
815
- redo: () => a(x, y, b)
817
+ redo: () => a(x, k, b)
816
818
  });
817
819
  },
818
820
  removeBlocks: (x) => {
819
821
  var B;
820
- const y = (B = first(x)) == null ? void 0 : B._parent, v = n.filter((w) => y ? w._parent === y : !w._parent).indexOf(first(x));
822
+ const k = (B = first(x)) == null ? void 0 : B._parent, v = n.filter((w) => k ? w._parent === k : !w._parent).indexOf(first(x));
821
823
  l(map(x, "_id")), o({
822
- undo: () => a(x, y, v),
824
+ undo: () => a(x, k, v),
823
825
  redo: () => l(map(x, "_id"))
824
826
  });
825
827
  },
826
- updateBlocks: (x, y, b) => {
828
+ updateBlocks: (x, k, b) => {
827
829
  let v = [];
828
830
  if (b)
829
831
  v = map(x, (B) => ({ _id: B, ...b }));
830
832
  else {
831
- const B = keys(y);
833
+ const B = keys(k);
832
834
  v = map(x, (w) => {
833
- const E = n.find((S) => S._id === w), _ = { _id: w };
834
- return each(B, (S) => _[S] = E[S]), _;
835
+ const _ = n.find((C) => C._id === w), E = { _id: w };
836
+ return each(B, (C) => E[C] = _[C]), E;
835
837
  });
836
838
  }
837
- c(map(x, (B) => ({ _id: B, ...y }))), o({
839
+ c(map(x, (B) => ({ _id: B, ...k }))), o({
838
840
  undo: () => c(v),
839
- redo: () => c(map(x, (B) => ({ _id: B, ...y })))
841
+ redo: () => c(map(x, (B) => ({ _id: B, ...k })))
840
842
  });
841
843
  },
842
- updateBlocksRuntime: (x, y) => {
843
- c(map(x, (b) => ({ _id: b, ...y })));
844
+ updateBlocksRuntime: (x, k) => {
845
+ c(map(x, (b) => ({ _id: b, ...k })));
844
846
  },
845
847
  setNewBlocks: (x) => {
846
848
  r(x), o({
@@ -849,12 +851,12 @@ const undoRedoStateAtom = atom({
849
851
  });
850
852
  },
851
853
  updateMultipleBlocksProps: (x) => {
852
- let y = [];
853
- y = map(x, (b) => {
854
- const v = keys(b), B = n.find((E) => E._id === b._id), w = {};
855
- return each(v, (E) => w[E] = B[E]), w;
854
+ let k = [];
855
+ k = map(x, (b) => {
856
+ const v = keys(b), B = n.find((_) => _._id === b._id), w = {};
857
+ return each(v, (_) => w[_] = B[_]), w;
856
858
  }), c(x), o({
857
- undo: () => c(y),
859
+ undo: () => c(k),
858
860
  redo: () => c(x)
859
861
  });
860
862
  }
@@ -866,9 +868,9 @@ const undoRedoStateAtom = atom({
866
868
  for (let f = 0; f < i.length; f++) {
867
869
  const { _id: x } = i[f];
868
870
  i[f]._id = generateUUID();
869
- const y = filter(i, { _parent: x });
870
- for (let b = 0; b < y.length; b++)
871
- y[b]._parent = i[f]._id;
871
+ const k = filter(i, { _parent: x });
872
+ for (let b = 0; b < k.length; b++)
873
+ k[b]._parent = i[f]._id;
872
874
  }
873
875
  const p = first(i);
874
876
  let u, g;
@@ -879,8 +881,8 @@ const undoRedoStateAtom = atom({
879
881
  return { addCoreBlock: useCallback(
880
882
  (i, c, d) => {
881
883
  if (has(i, "blocks")) {
882
- const y = i.blocks;
883
- return a(y, c, d);
884
+ const k = i.blocks;
885
+ return a(k, c, d);
884
886
  }
885
887
  const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
886
888
  _type: i.type,
@@ -2331,42 +2333,42 @@ const getBlockWithChildren = (o, n) => {
2331
2333
  })
2332
2334
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2333
2335
  const [o, n] = useAtom$1(askAiProcessingAtom), [r, 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, f) => {
2334
- const x = cloneDeep(f.find((y) => y._id === m));
2335
- for (const y in x) {
2336
- const b = x[y];
2336
+ const x = cloneDeep(f.find((k) => k._id === m));
2337
+ for (const k in x) {
2338
+ const b = x[k];
2337
2339
  if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
2338
2340
  const { baseClasses: v, classes: B } = getSplitChaiClasses(b);
2339
- x[y] = compact(flattenDeep([v, B])).join(" ");
2341
+ x[k] = compact(flattenDeep([v, B])).join(" ");
2340
2342
  } else
2341
- y !== "_id" && delete x[y];
2343
+ k !== "_id" && delete x[k];
2342
2344
  }
2343
2345
  return x;
2344
2346
  };
2345
2347
  return {
2346
2348
  askAi: useCallback(
2347
- async (m, f, x, y) => {
2349
+ async (m, f, x, k) => {
2348
2350
  if (l) {
2349
2351
  n(!0), a(null);
2350
2352
  try {
2351
- const b = p === u ? "" : p, v = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [h(f, d)], B = await l(m, addLangToPrompt(x, g, m), v, b), { blocks: w, error: E } = B;
2352
- if (E) {
2353
- a(E);
2353
+ const b = p === u ? "" : p, v = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [h(f, d)], B = await l(m, addLangToPrompt(x, g, m), v, b), { blocks: w, error: _ } = B;
2354
+ if (_) {
2355
+ a(_);
2354
2356
  return;
2355
2357
  }
2356
2358
  if (m === "styles") {
2357
- const _ = w.map((S) => {
2358
- for (const A in S)
2359
- A !== "_id" && (S[A] = `${STYLES_KEY},${S[A]}`);
2360
- return S;
2359
+ const E = w.map((C) => {
2360
+ for (const A in C)
2361
+ A !== "_id" && (C[A] = `${STYLES_KEY},${C[A]}`);
2362
+ return C;
2361
2363
  });
2362
- c(_);
2364
+ c(E);
2363
2365
  } else
2364
2366
  i(w);
2365
- y && y(B);
2367
+ k && k(B);
2366
2368
  } catch (b) {
2367
2369
  a(b);
2368
2370
  } finally {
2369
- n(!1), y && y();
2371
+ n(!1), k && k();
2370
2372
  }
2371
2373
  }
2372
2374
  },
@@ -2462,7 +2464,7 @@ const getBlockWithChildren = (o, n) => {
2462
2464
  for (const f of h)
2463
2465
  if (f._type === "PartialBlock" || f._type === "GlobalBlock") {
2464
2466
  let x = l(f.partialBlockId);
2465
- f._parent && (x == null ? void 0 : x.length) > 0 && (x = x.map((y) => (isEmpty(y._parent) && set(y, "_parent", f._parent), y))), m = [...m, ...x];
2467
+ f._parent && (x == null ? void 0 : x.length) > 0 && (x = x.map((k) => (isEmpty(k._parent) && set(k, "_parent", f._parent), k))), m = [...m, ...x];
2466
2468
  } else
2467
2469
  m.push(f);
2468
2470
  return m;
@@ -2736,7 +2738,19 @@ const getBlockWithChildren = (o, n) => {
2736
2738
  return null;
2737
2739
  });
2738
2740
  wrapperBlockAtom.debugLabel = "wrapperBlockAtom";
2739
- const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useSelectedLibrary = () => useAtom$1(selectedLibraryAtom), sidebarActivePanelAtom = atom("outline");
2741
+ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), inlineEditingActiveAtom = atom("");
2742
+ inlineEditingActiveAtom.debugLabel = "inlineEditingActiveAtom";
2743
+ const inlineEditingItemIndexAtom = atom(0);
2744
+ inlineEditingItemIndexAtom.debugLabel = "inlineEditingItemIndexAtom";
2745
+ const useInlineEditing = () => {
2746
+ const [o, n] = useAtom$1(inlineEditingActiveAtom), [r, a] = useAtom$1(inlineEditingItemIndexAtom);
2747
+ return {
2748
+ editingBlockId: o,
2749
+ editingItemIndex: r,
2750
+ setEditingBlockId: n,
2751
+ setEditingItemIndex: a
2752
+ };
2753
+ }, useSelectedLibrary = () => useAtom$1(selectedLibraryAtom), sidebarActivePanelAtom = atom("outline");
2740
2754
  sidebarActivePanelAtom.debugLabel = "sidebarActivePanelAtom";
2741
2755
  const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS = [
2742
2756
  { ControlIcon: PinTopIcon, dir: "VERTICAL", key: "UP" },
@@ -2765,8 +2779,8 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2765
2779
  return useHotkeys(
2766
2780
  "shift+up, shift+down, shift+left, shift+right",
2767
2781
  ({ key: x }) => {
2768
- var y;
2769
- f((y = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : y.toUpperCase());
2782
+ var k;
2783
+ f((k = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : k.toUpperCase());
2770
2784
  },
2771
2785
  { document: a == null ? void 0 : a.contentDocument },
2772
2786
  [f]
@@ -2806,19 +2820,24 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
2806
2820
  const r = o == null ? void 0 : o.getAttribute("data-block-type");
2807
2821
  return !r || o && o.children.length > 0 || r === "Button" ? !1 : INLINE_EDITABLE_BLOCKS.includes(r);
2808
2822
  }, useHandleCanvasDblClick = () => {
2809
- const [o, n] = useAtom$1(inlineEditingActiveAtom);
2823
+ const { editingBlockId: o, setEditingBlockId: n, setEditingItemIndex: r } = useInlineEditing();
2810
2824
  return useCallback(
2811
- (r) => {
2812
- if (r == null || r.preventDefault(), r == null || r.stopPropagation(), o) return;
2813
- const a = getTargetedBlock(r.target);
2814
- if (!isInlineEditable(a)) return;
2815
- const l = a.getAttribute("data-block-id");
2816
- l && n(l);
2825
+ (a) => {
2826
+ var d;
2827
+ if (a == null || a.preventDefault(), a == null || a.stopPropagation(), o) return;
2828
+ const l = getTargetedBlock(a.target);
2829
+ if (!isInlineEditable(l)) return;
2830
+ const i = l.getAttribute("data-block-id");
2831
+ if (!i || !l) return;
2832
+ const c = l.closest('[data-block-type="Repeater"]');
2833
+ c ? (d = c == null ? void 0 : c.childNodes) == null || d.forEach((p, u) => {
2834
+ p.contains(l) && r(u);
2835
+ }) : r(-1), n(i);
2817
2836
  },
2818
- [o, n]
2837
+ [o, n, r]
2819
2838
  );
2820
2839
  }, useHandleCanvasClick = () => {
2821
- const [o] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: n } = useBlockHighlight(), r = useRef(0);
2840
+ const { editingBlockId: o } = useInlineEditing(), { clearHighlight: n } = useBlockHighlight(), r = useRef(0);
2822
2841
  return useCallback(
2823
2842
  (a) => {
2824
2843
  const l = (/* @__PURE__ */ new Date()).getTime();
@@ -2840,7 +2859,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
2840
2859
  [o]
2841
2860
  );
2842
2861
  }, useHandleMouseMove = () => {
2843
- const [o] = useAtom$1(inlineEditingActiveAtom), { highlightBlock: n } = useBlockHighlight();
2862
+ const { editingBlockId: o } = useInlineEditing(), { highlightBlock: n } = useBlockHighlight();
2844
2863
  return useThrottledCallback(
2845
2864
  (r) => {
2846
2865
  if (o) return;
@@ -2905,7 +2924,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
2905
2924
  i([null]);
2906
2925
  }, [r, n]), /* @__PURE__ */ jsx(BlockFloatingSelector, { block: o, selectedBlockElement: a[0] });
2907
2926
  }, BlockFloatingSelector = ({ block: o, selectedBlockElement: n }) => {
2908
- const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: h, update: m } = useFloating({
2927
+ const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: u } = useFrame(), { floatingStyles: g, refs: h, update: m } = useFloating({
2909
2928
  placement: "top-start",
2910
2929
  middleware: [shift(), flip()],
2911
2930
  elements: { reference: n }
@@ -2919,13 +2938,13 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
2919
2938
  tabIndex: 0,
2920
2939
  ref: h.setFloating,
2921
2940
  style: g,
2922
- onClick: (y) => {
2923
- y.stopPropagation(), y.preventDefault();
2941
+ onClick: (k) => {
2942
+ k.stopPropagation(), k.preventDefault();
2924
2943
  },
2925
- onMouseEnter: (y) => {
2926
- y.stopPropagation(), i(null);
2944
+ onMouseEnter: (k) => {
2945
+ k.stopPropagation(), i(null);
2927
2946
  },
2928
- onKeyDown: (y) => y.stopPropagation(),
2947
+ onKeyDown: (k) => k.stopPropagation(),
2929
2948
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
2930
2949
  children: [
2931
2950
  f && /* @__PURE__ */ jsx(
@@ -3382,8 +3401,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3382
3401
  ],
3383
3402
  onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
3384
3403
  onBlur: ({ editor: u, event: g }) => {
3385
- const h = g.relatedTarget, m = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = m == null ? void 0 : m.contains(h), y = f == null ? void 0 : f.contains(h);
3386
- if (!x && !y) {
3404
+ const h = g.relatedTarget, m = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = m == null ? void 0 : m.contains(h), k = f == null ? void 0 : f.contains(h);
3405
+ if (!x && !k) {
3387
3406
  const b = (u == null ? void 0 : u.getHTML()) || "";
3388
3407
  r(b);
3389
3408
  }
@@ -3479,62 +3498,62 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3479
3498
  }
3480
3499
  ), WithBlockTextEditor = memo(
3481
3500
  ({ block: o, children: n }) => {
3482
- const r = "content", { document: a } = useFrame(), [l, i] = useAtom$1(inlineEditingActiveAtom), [c, d] = useState(null), p = useRef(null), { clearHighlight: u } = useBlockHighlight(), g = useUpdateBlocksProps(), { selectedLang: h } = useLanguages(), [, m] = useSelectedBlockIds(), f = useRef(null), x = l, { blockContent: y, blockType: b } = useMemo(() => {
3483
- var C;
3484
- const _ = o._type;
3485
- let S = o[r];
3486
- const A = getRegisteredChaiBlock(o._type);
3487
- return h && ((C = A == null ? void 0 : A.i18nProps) == null ? void 0 : C.includes(r)) && has(o, `${r}-${h}`) && (S = get(o, `${r}-${h}`)), { blockContent: S, blockType: _ };
3488
- }, [o, h]), v = useCallback(
3489
- (_) => {
3490
- var A;
3491
- const S = _ || ((A = p.current) == null ? void 0 : A.innerText);
3492
- g([x], { [r]: S }), d(null), i(null), m([]);
3501
+ const r = "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: f } = useLanguages(), [, x] = useSelectedBlockIds(), k = useRef(null), b = l, { blockContent: v, blockType: B } = useMemo(() => {
3502
+ var j;
3503
+ const A = o._type;
3504
+ let N = o[r];
3505
+ const S = getRegisteredChaiBlock(o._type);
3506
+ return f && ((j = S == null ? void 0 : S.i18nProps) == null ? void 0 : j.includes(r)) && has(o, `${r}-${f}`) && (N = get(o, `${r}-${f}`)), { blockContent: N, blockType: A };
3507
+ }, [o, f]), w = useCallback(
3508
+ (A) => {
3509
+ var S;
3510
+ const N = A || ((S = g.current) == null ? void 0 : S.innerText);
3511
+ m([b], { [r]: N }), u(null), c(null), d(-1), x([]);
3493
3512
  },
3494
- [x, g, i, m, h]
3495
- ), B = useDebouncedCallback(
3496
- (_) => {
3497
- g([x], { [r]: _ });
3513
+ [b, m, c, x, f]
3514
+ ), _ = useDebouncedCallback(
3515
+ (A) => {
3516
+ m([b], { [r]: A });
3498
3517
  },
3499
- [x, o, g, h],
3518
+ [b, o, m, f],
3500
3519
  1e3
3501
- ), w = useCallback(
3502
- (_) => {
3503
- _.preventDefault(), x && (f.current = x), v(), setTimeout(() => {
3504
- const S = f.current;
3505
- f.current = null, m([S]);
3520
+ ), E = useCallback(
3521
+ (A) => {
3522
+ A.preventDefault(), b && (k.current = b), w(), setTimeout(() => {
3523
+ const N = k.current;
3524
+ k.current = null, x([N]);
3506
3525
  }, 100);
3507
3526
  },
3508
- [m, x, h]
3527
+ [x, b, f]
3509
3528
  );
3510
3529
  useEffect(() => {
3511
- var S;
3512
- if (!x) return;
3513
- const _ = getElementByDataBlockId(a, x);
3514
- (S = _ == null ? void 0 : _.classList) == null || S.add("sr-only"), d(_);
3515
- }, [x, b, a]);
3516
- const E = useMemo(() => c ? (u(), b === "RichText" ? /* @__PURE__ */ jsx(
3530
+ var y;
3531
+ if (!b) return;
3532
+ const A = `[data-block-id="${b}"]`, N = i >= 0 ? `[data-block-index="${i}"]` : "", S = a.querySelector(`${A}${N}`);
3533
+ S && ((y = S == null ? void 0 : S.classList) == null || y.add("sr-only"), u(S));
3534
+ }, [b, B, a, i]);
3535
+ const C = useMemo(() => p ? (h(), B === "RichText" ? /* @__PURE__ */ jsx(
3517
3536
  RichTextEditor,
3518
3537
  {
3519
- blockContent: y,
3520
- editingElement: c,
3521
- onChange: B,
3522
- onClose: v,
3523
- onEscape: w
3538
+ blockContent: v,
3539
+ editingElement: p,
3540
+ onChange: _,
3541
+ onClose: w,
3542
+ onEscape: E
3524
3543
  }
3525
3544
  ) : /* @__PURE__ */ jsx(
3526
3545
  MemoizedEditor,
3527
3546
  {
3528
- editorRef: p,
3529
- blockContent: y,
3530
- editingElement: c,
3531
- onClose: v,
3532
- onChange: B,
3533
- onEscape: w
3547
+ editorRef: g,
3548
+ blockContent: v,
3549
+ editingElement: p,
3550
+ onClose: w,
3551
+ onChange: _,
3552
+ onEscape: E
3534
3553
  }
3535
- )) : null, [c, x, b, y, v, h]);
3554
+ )) : null, [p, b, B, v, w, f]);
3536
3555
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3537
- E,
3556
+ C,
3538
3557
  n
3539
3558
  ] });
3540
3559
  },
@@ -3567,52 +3586,52 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3567
3586
  blockAtom: n,
3568
3587
  children: r
3569
3588
  }) => {
3570
- const [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(n), i = useMemo(() => getRegisteredChaiBlock(l._type), [l._type]), { selectedLang: c, fallbackLang: d } = useLanguages(), p = useBlockRuntimeProps(), u = usePageExternalData(), [g] = useHiddenBlockIds(), [h] = useAtom$1(dataBindingActiveAtom), m = get(i, "component", null), { index: f, key: x } = useContext(RepeaterContext), y = useMemo(
3571
- () => h ? applyBindingToBlockProps(applyLanguage(l, c, i), u, {
3572
- index: f,
3573
- key: x
3574
- }) : applyLanguage(l, c, i),
3575
- [l, c, i, u, h, f, x]
3576
- ), b = useMemo(() => getBlockTagAttributes(l), [l, getBlockTagAttributes]), v = useMemo(
3577
- () => p(l._id, getBlockRuntimeProps(l._type)),
3578
- [l._id, l._type, p, getBlockRuntimeProps]
3579
- ), B = useMemo(
3589
+ const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom), f = get(c, "component", null), { index: x, key: k } = useContext(RepeaterContext), b = useMemo(
3590
+ () => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
3591
+ index: x,
3592
+ key: k
3593
+ }) : applyLanguage(i, d, c),
3594
+ [i, d, c, g, m, x, k]
3595
+ ), v = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), B = useMemo(
3596
+ () => u(i._id, getBlockRuntimeProps(i._type)),
3597
+ [i._id, i._type, u, getBlockRuntimeProps]
3598
+ ), w = useMemo(
3580
3599
  () => ({
3581
- blockProps: { "data-block-id": l._id, "data-block-type": l._type },
3600
+ blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": x },
3582
3601
  inBuilder: !0,
3583
- lang: c || d,
3584
- ...y,
3602
+ lang: d || p,
3585
3603
  ...b,
3586
3604
  ...v,
3605
+ ...B,
3587
3606
  ...o
3588
3607
  }),
3589
3608
  [
3590
- l._id,
3591
- l._type,
3592
- c,
3609
+ i._id,
3610
+ i._type,
3593
3611
  d,
3594
- y,
3612
+ p,
3595
3613
  b,
3596
3614
  v,
3615
+ B,
3597
3616
  o
3598
3617
  ]
3599
- ), w = useMemo(() => !CORE_BLOCKS.includes(l._type), [l._type]);
3600
- if (isNull(m) || g.includes(l._id)) return null;
3601
- let E = /* @__PURE__ */ jsx(Suspense, { children: createElement(m, {
3602
- ...B,
3618
+ ), _ = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]);
3619
+ if (isNull(f) || h.includes(i._id)) return null;
3620
+ let E = /* @__PURE__ */ jsx(Suspense, { children: createElement(f, {
3621
+ ...w,
3603
3622
  children: r({
3604
- _id: l._id,
3605
- _type: l._type,
3606
- ...isArray(y.repeaterItems) ? {
3607
- repeaterItems: applyLimit(y.repeaterItems, l),
3608
- $repeaterItemsKey: y.$repeaterItemsKey
3623
+ _id: i._id,
3624
+ _type: i._type,
3625
+ ...isArray(b.repeaterItems) ? {
3626
+ repeaterItems: applyLimit(b.repeaterItems, i),
3627
+ $repeaterItemsKey: b.$repeaterItemsKey
3609
3628
  } : {},
3610
- ...l.partialBlockId ? { partialBlockId: l.partialBlockId } : "",
3611
- ...l.globalBlock ? { partialBlockId: l.globalBlock } : ""
3629
+ ...i.partialBlockId ? { partialBlockId: i.partialBlockId } : "",
3630
+ ...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
3612
3631
  })
3613
3632
  }) });
3614
- const _ = a === l._id ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: l, children: E }) : E;
3615
- return w ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: _ }) : _;
3633
+ const C = a === i._id && (l === x || x < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: E }) : E;
3634
+ return _ ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: C }) : C;
3616
3635
  }, PartialBlocksRenderer = ({ partialBlockId: o }) => {
3617
3636
  const { getPartailBlocks: n } = usePartialBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom(r)), [r]);
3618
3637
  return isEmpty(r) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r });
@@ -3630,7 +3649,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3630
3649
  );
3631
3650
  return map(l, (c) => {
3632
3651
  const d = a(c._id);
3633
- 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: f }) => g === "Repeater" ? isArray(m) && m.map((x, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: f }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, 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: r, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3652
+ 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: f }) => g === "Repeater" ? isArray(m) && m.map((x, k) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: k, key: f }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, 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: r, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3634
3653
  });
3635
3654
  }, PageBlocksRenderer = () => {
3636
3655
  const [o] = useBlocksStore();
@@ -4048,18 +4067,18 @@ const DataBindingSelector = ({
4048
4067
  return;
4049
4068
  }
4050
4069
  const m = (b) => /[.,!?;:]/.test(b), f = (b, v, B) => {
4051
- let w = "", E = "";
4052
- const _ = v > 0 ? b[v - 1] : "", S = v < b.length ? b[v] : "";
4053
- return v > 0 && (_ === "." || !m(_) && _ !== " ") && (w = " "), v < b.length && !m(S) && S !== " " && (E = " "), {
4054
- text: w + B + E,
4070
+ let w = "", _ = "";
4071
+ const E = v > 0 ? b[v - 1] : "", C = v < b.length ? b[v] : "";
4072
+ return v > 0 && (E === "." || !m(E) && E !== " ") && (w = " "), v < b.length && !m(C) && C !== " " && (_ = " "), {
4073
+ text: w + B + _,
4055
4074
  prefixLength: w.length,
4056
- suffixLength: E.length
4075
+ suffixLength: _.length
4057
4076
  };
4058
4077
  }, x = document.getElementById(r);
4059
4078
  if (!x) return;
4060
- const y = document.getElementById(`chai-rte-${r}`) || document.getElementById(`chai-rte-modal-${r}`);
4061
- if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
4062
- const b = y.__chaiRTE;
4079
+ const k = document.getElementById(`chai-rte-${r}`) || document.getElementById(`chai-rte-modal-${r}`);
4080
+ if (k && (k.querySelector(".ProseMirror") || k.__chaiRTE)) {
4081
+ const b = k.__chaiRTE;
4063
4082
  if (b) {
4064
4083
  const v = `{{${g}}}`;
4065
4084
  b.commands.focus();
@@ -4067,11 +4086,11 @@ const DataBindingSelector = ({
4067
4086
  if (B !== w)
4068
4087
  b.chain().deleteSelection().insertContent(v).run();
4069
4088
  else {
4070
- const { state: _ } = b, S = _.selection.from, A = _.doc.textBetween(Math.max(0, S - 1), S), N = _.doc.textBetween(S, Math.min(S + 1, _.doc.content.size));
4071
- let C = "";
4072
- S > 0 && A !== " " && !m(A) && (C = " ");
4073
- let k = "";
4074
- N && N !== " " && !m(N) && (k = " "), b.chain().insertContent(C + v + k).run();
4089
+ const { state: E } = b, C = E.selection.from, A = E.doc.textBetween(Math.max(0, C - 1), C), N = E.doc.textBetween(C, Math.min(C + 1, E.doc.content.size));
4090
+ let S = "";
4091
+ C > 0 && A !== " " && !m(A) && (S = " ");
4092
+ let y = "";
4093
+ N && N !== " " && !m(N) && (y = " "), b.chain().insertContent(S + v + y).run();
4075
4094
  }
4076
4095
  setTimeout(() => n(b.getHTML(), {}, r), 100);
4077
4096
  return;
@@ -4079,11 +4098,11 @@ const DataBindingSelector = ({
4079
4098
  } else {
4080
4099
  const b = x, v = b.selectionStart || 0, B = b.value || "", w = b.selectionEnd || v;
4081
4100
  if (w > v) {
4082
- const N = `{{${g}}}`, { text: C } = f(B, v, N), k = B.slice(0, v) + C + B.slice(w);
4083
- n(k, {}, r);
4101
+ const N = `{{${g}}}`, { text: S } = f(B, v, N), y = B.slice(0, v) + S + B.slice(w);
4102
+ n(y, {}, r);
4084
4103
  return;
4085
4104
  }
4086
- const _ = `{{${g}}}`, { text: S } = f(B, v, _), A = B.slice(0, v) + S + B.slice(v);
4105
+ const E = `{{${g}}}`, { text: C } = f(B, v, E), A = B.slice(0, v) + C + B.slice(v);
4087
4106
  n(A, {}, r);
4088
4107
  }
4089
4108
  },
@@ -4106,73 +4125,73 @@ const DataBindingSelector = ({
4106
4125
  onChange: r
4107
4126
  }) => {
4108
4127
  var N;
4109
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [f, x] = useState([]), [y, b] = useState(-1), v = useRef(null), B = (N = n == null ? void 0 : n.find((C) => C.key === u)) == null ? void 0 : N.name;
4128
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (S, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [f, x] = useState([]), [k, b] = useState(-1), v = useRef(null), B = (N = n == null ? void 0 : n.find((S) => S.key === u)) == null ? void 0 : N.name;
4110
4129
  useEffect(() => {
4111
4130
  if (m(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4112
- const C = split(o, ":"), k = get(C, 1, "page") || "page";
4113
- g(k), (async () => {
4114
- const j = await l(k, [get(C, 2, "page")]);
4131
+ const S = split(o, ":"), y = get(S, 1, "page") || "page";
4132
+ g(y), (async () => {
4133
+ const j = await l(y, [get(S, 2, "page")]);
4115
4134
  j && Array.isArray(j) && m(get(j, [0, "name"], ""));
4116
4135
  })();
4117
4136
  }, [o]);
4118
4137
  const w = useDebouncedCallback(
4119
- async (C) => {
4120
- if (isEmpty(C))
4138
+ async (S) => {
4139
+ if (isEmpty(S))
4121
4140
  x([]);
4122
4141
  else {
4123
- const k = await l(u, C);
4124
- x(k);
4142
+ const y = await l(u, S);
4143
+ x(y);
4125
4144
  }
4126
4145
  c(!1), b(-1);
4127
4146
  },
4128
4147
  [u],
4129
4148
  300
4130
- ), E = (C) => {
4131
- const k = ["pageType", u, C.id];
4132
- k[1] && (r(k.join(":")), m(C.name), p(!1), x([]), b(-1));
4133
- }, _ = (C) => {
4134
- switch (C.key) {
4149
+ ), _ = (S) => {
4150
+ const y = ["pageType", u, S.id];
4151
+ y[1] && (r(y.join(":")), m(S.name), p(!1), x([]), b(-1));
4152
+ }, E = (S) => {
4153
+ switch (S.key) {
4135
4154
  case "ArrowDown":
4136
- C.preventDefault(), b((k) => k < f.length - 1 ? k + 1 : k);
4155
+ S.preventDefault(), b((y) => y < f.length - 1 ? y + 1 : y);
4137
4156
  break;
4138
4157
  case "ArrowUp":
4139
- C.preventDefault(), b((k) => k > 0 ? k - 1 : k);
4158
+ S.preventDefault(), b((y) => y > 0 ? y - 1 : y);
4140
4159
  break;
4141
4160
  case "Enter":
4142
- if (C.preventDefault(), f.length === 0) return;
4143
- y >= 0 && E(f[y]);
4161
+ if (S.preventDefault(), f.length === 0) return;
4162
+ k >= 0 && _(f[k]);
4144
4163
  break;
4145
4164
  case "Escape":
4146
- C.preventDefault(), S();
4165
+ S.preventDefault(), C();
4147
4166
  break;
4148
4167
  }
4149
4168
  };
4150
4169
  useEffect(() => {
4151
- if (y >= 0 && v.current) {
4152
- const C = v.current.children[y];
4153
- C == null || C.scrollIntoView({ block: "nearest" });
4170
+ if (k >= 0 && v.current) {
4171
+ const S = v.current.children[k];
4172
+ S == null || S.scrollIntoView({ block: "nearest" });
4154
4173
  }
4155
- }, [y]);
4156
- const S = () => {
4174
+ }, [k]);
4175
+ const C = () => {
4157
4176
  m(""), x([]), b(-1), p(!1), r("");
4158
- }, A = (C) => {
4159
- m(C), p(!isEmpty(C)), c(!0), w(C);
4177
+ }, A = (S) => {
4178
+ m(S), p(!isEmpty(S)), c(!0), w(S);
4160
4179
  };
4161
4180
  return /* @__PURE__ */ jsxs("div", { children: [
4162
- /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (C) => g(C.target.value), children: map(n, (C) => /* @__PURE__ */ jsx("option", { value: C.key, children: C.name }, C.key)) }),
4181
+ /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (S) => g(S.target.value), children: map(n, (S) => /* @__PURE__ */ jsx("option", { value: S.key, children: S.name }, S.key)) }),
4163
4182
  u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
4164
4183
  /* @__PURE__ */ jsx(
4165
4184
  "input",
4166
4185
  {
4167
4186
  type: "text",
4168
4187
  value: h,
4169
- onChange: (C) => A(C.target.value),
4170
- onKeyDown: _,
4188
+ onChange: (S) => A(S.target.value),
4189
+ onKeyDown: E,
4171
4190
  placeholder: a(`Search ${B ?? ""}`),
4172
4191
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4173
4192
  }
4174
4193
  ),
4175
- /* @__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" }) }) })
4194
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: C, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4176
4195
  ] }),
4177
4196
  (i || !isEmpty(f) || d && isEmpty(f)) && /* @__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: [
4178
4197
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -4182,22 +4201,22 @@ const DataBindingSelector = ({
4182
4201
  ' "',
4183
4202
  h,
4184
4203
  '"'
4185
- ] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(f == null ? void 0 : f.slice(0, 20), (C, k) => /* @__PURE__ */ jsxs(
4204
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(f == null ? void 0 : f.slice(0, 20), (S, y) => /* @__PURE__ */ jsxs(
4186
4205
  "li",
4187
4206
  {
4188
- onClick: () => E(C),
4189
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(C.id) ? "bg-blue-200" : k === y ? "bg-gray-100" : "hover:bg-gray-100"}`,
4207
+ onClick: () => _(S),
4208
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(S.id) ? "bg-blue-200" : y === k ? "bg-gray-100" : "hover:bg-gray-100"}`,
4190
4209
  children: [
4191
- C.name,
4210
+ S.name,
4192
4211
  " ",
4193
- C.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4212
+ S.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4194
4213
  "( ",
4195
- C.slug,
4214
+ S.slug,
4196
4215
  " )"
4197
4216
  ] })
4198
4217
  ]
4199
4218
  },
4200
- C.id
4219
+ S.id
4201
4220
  )) }) })
4202
4221
  ] });
4203
4222
  }, LinkField = ({ schema: o, formData: n, onChange: r, name: a }) => {
@@ -4502,10 +4521,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4502
4521
  u.chain().deleteSelection().insertContent(m).run();
4503
4522
  else {
4504
4523
  const { state: b } = u, v = b.selection.from, B = b.doc.textBetween(Math.max(0, v - 1), v), w = b.doc.textBetween(v, Math.min(v + 1, b.doc.content.size));
4505
- let E = "";
4506
- v > 0 && B !== " " && !/[.,!?;:]/.test(B) && (E = " ");
4507
4524
  let _ = "";
4508
- w && w !== " " && !/[.,!?;:]/.test(w) && (_ = " "), u.chain().insertContent(E + m + _).run();
4525
+ v > 0 && B !== " " && !/[.,!?;:]/.test(B) && (_ = " ");
4526
+ let E = "";
4527
+ w && w !== " " && !/[.,!?;:]/.test(w) && (E = " "), u.chain().insertContent(_ + m + E).run();
4509
4528
  }
4510
4529
  };
4511
4530
  return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (h) => !h && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
@@ -4599,14 +4618,14 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4599
4618
  const h = () => {
4600
4619
  const x = findIndex(u, { _id: g });
4601
4620
  if (x > -1) {
4602
- const y = (x + 1) % u.length, b = get(u, [y, "_id"]);
4621
+ const k = (x + 1) % u.length, b = get(u, [k, "_id"]);
4603
4622
  if (!b) return;
4604
4623
  n({ ...o, currentSlide: b }), c([b]);
4605
4624
  }
4606
4625
  }, m = () => {
4607
4626
  const x = findIndex(u, { _id: g });
4608
4627
  if (x > -1) {
4609
- const y = (x - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
4628
+ const k = (x - 1 + u.length) % u.length, b = get(u, [k, "_id"]);
4610
4629
  if (!b) return;
4611
4630
  n({ ...o, currentSlide: b }), c([b]);
4612
4631
  }
@@ -4614,8 +4633,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4614
4633
  const x = i(
4615
4634
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4616
4635
  p == null ? void 0 : p._id
4617
- ), y = x == null ? void 0 : x._id;
4618
- y && (n({ ...o, currentSlide: y }), c([y]));
4636
+ ), k = x == null ? void 0 : x._id;
4637
+ k && (n({ ...o, currentSlide: k }), c([k]));
4619
4638
  };
4620
4639
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4621
4640
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
@@ -4694,8 +4713,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4694
4713
  className: "text-xs",
4695
4714
  pattern: "[0-9]*",
4696
4715
  onChange: (x) => {
4697
- let y = x.target.value;
4698
- y.length && (y = y.replace("-", "")), n({ ...o, autoplayInterval: y });
4716
+ let k = x.target.value;
4717
+ k.length && (k = k.replace("-", "")), n({ ...o, autoplayInterval: k });
4699
4718
  }
4700
4719
  }
4701
4720
  )
@@ -4803,28 +4822,28 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4803
4822
  formData: g,
4804
4823
  onChange: h
4805
4824
  }) => {
4806
- const { selectedLang: m, fallbackLang: f, languages: x } = useLanguages(), y = useMemo(
4825
+ const { selectedLang: m, fallbackLang: f, languages: x } = useLanguages(), k = useMemo(
4807
4826
  () => isEmpty(x) ? "" : isEmpty(m) ? f : m,
4808
4827
  [x, m, f]
4809
- ), b = useMemo(() => get(LANGUAGES, y, y), [y]), v = usePageExternalData(), B = useSelectedBlock(), w = useRegisteredChaiBlocks(), E = useMemo(
4828
+ ), b = useMemo(() => get(LANGUAGES, k, k), [k]), v = usePageExternalData(), B = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = useMemo(
4810
4829
  () => get(w, [B == null ? void 0 : B._type, "i18nProps"], []),
4811
4830
  [w, B == null ? void 0 : B._type]
4812
- ), [_, S] = useState(null);
4831
+ ), [E, C] = useState(null);
4813
4832
  if (d)
4814
4833
  return null;
4815
4834
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
4816
- const N = E == null ? void 0 : E.includes(o.replace("root.", ""));
4835
+ const N = _ == null ? void 0 : _.includes(o.replace("root.", ""));
4817
4836
  if (u.type === "array") {
4818
- const C = _ === o;
4837
+ const S = E === o;
4819
4838
  return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
4820
4839
  u.title && /* @__PURE__ */ jsxs(
4821
4840
  "label",
4822
4841
  {
4823
4842
  htmlFor: o,
4824
- onClick: () => S(C ? null : o),
4843
+ onClick: () => C(S ? null : o),
4825
4844
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
4826
4845
  children: [
4827
- C ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
4846
+ S ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
4828
4847
  /* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
4829
4848
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: r }),
4830
4849
  " ",
@@ -4832,7 +4851,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4832
4851
  ]
4833
4852
  }
4834
4853
  ),
4835
- (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${C ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
4854
+ (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${S ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
4836
4855
  c,
4837
4856
  a,
4838
4857
  l,
@@ -4855,8 +4874,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4855
4874
  DataBindingSelector,
4856
4875
  {
4857
4876
  schema: u,
4858
- onChange: (C) => {
4859
- h(C, g, o);
4877
+ onChange: (S) => {
4878
+ h(S, g, o);
4860
4879
  },
4861
4880
  id: o,
4862
4881
  formData: g
@@ -4960,43 +4979,43 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4960
4979
  }), a;
4961
4980
  };
4962
4981
  function BlockSettings() {
4963
- const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, 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), f = ({ formData: _ }, S, A) => {
4964
- S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(_, S) }, A);
4982
+ const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, 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), f = ({ formData: E }, C, A) => {
4983
+ C && (c == null ? void 0 : c._id) === n._id && a([n._id], { [C]: get(E, C) }, A);
4965
4984
  }, x = useCallback(
4966
- debounce(({ formData: _ }, S, A) => {
4967
- f({ formData: _ }, S, A), d(_);
4985
+ debounce(({ formData: E }, C, A) => {
4986
+ f({ formData: E }, C, A), d(E);
4968
4987
  }, 1500),
4969
4988
  [n == null ? void 0 : n._id, o]
4970
- ), y = ({ formData: _ }, S) => {
4971
- S && (r([n._id], { [S]: get(_, S) }), x({ formData: _ }, S, { [S]: get(c, S) }));
4972
- }, b = ({ formData: _ }, S) => {
4973
- S && (r([g._id], { [S]: get(_, S) }), x({ formData: _ }, S, { [S]: get(c, S) }));
4989
+ ), k = ({ formData: E }, C) => {
4990
+ C && (r([n._id], { [C]: get(E, C) }), x({ formData: E }, C, { [C]: get(c, C) }));
4991
+ }, b = ({ formData: E }, C) => {
4992
+ C && (r([g._id], { [C]: get(E, C) }), x({ formData: E }, C, { [C]: get(c, C) }));
4974
4993
  }, { schema: v, uiSchema: B } = useMemo(() => {
4975
- const _ = n == null ? void 0 : n._type;
4976
- if (!_)
4994
+ const E = n == null ? void 0 : n._type;
4995
+ if (!E)
4977
4996
  return { schema: {}, uiSchema: {} };
4978
4997
  try {
4979
- const { schema: S, uiSchema: A } = getBlockFormSchemas(_);
4980
- if (_ === "Repeater") {
4998
+ const { schema: C, uiSchema: A } = getBlockFormSchemas(E);
4999
+ if (E === "Repeater") {
4981
5000
  const N = get(n, "repeaterItems", "");
4982
5001
  startsWith(N, `{{${COLLECTION_PREFIX}`) ? (set(A, "filter", { "ui:widget": "collectionSelect" }), set(A, "sort", { "ui:widget": "collectionSelect" })) : (set(A, "filter", { "ui:widget": "hidden" }), set(A, "sort", { "ui:widget": "hidden" }));
4983
5002
  }
4984
- return { schema: S, uiSchema: A };
5003
+ return { schema: C, uiSchema: A };
4985
5004
  } catch {
4986
5005
  return { schema: {}, uiSchema: {} };
4987
5006
  }
4988
- }, [n]), { wrapperSchema: w, wrapperUiSchema: E } = useMemo(() => {
5007
+ }, [n]), { wrapperSchema: w, wrapperUiSchema: _ } = useMemo(() => {
4989
5008
  if (!g || !(g != null && g._type))
4990
5009
  return { wrapperSchema: {}, wrapperUiSchema: {} };
4991
- const _ = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: A = {} } = getBlockFormSchemas(_);
4992
- return { wrapperSchema: S, wrapperUiSchema: A };
5010
+ const E = g == null ? void 0 : g._type, { schema: C = {}, uiSchema: A = {} } = getBlockFormSchemas(E);
5011
+ return { wrapperSchema: C, wrapperUiSchema: A };
4993
5012
  }, [g]);
4994
5013
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
4995
5014
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
4996
5015
  /* @__PURE__ */ jsxs(
4997
5016
  "div",
4998
5017
  {
4999
- onClick: () => u((_) => !_),
5018
+ onClick: () => u((E) => !E),
5000
5019
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5001
5020
  children: [
5002
5021
  p ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
@@ -5018,7 +5037,7 @@ function BlockSettings() {
5018
5037
  onChange: b,
5019
5038
  formData: m,
5020
5039
  schema: w,
5021
- uiSchema: E
5040
+ uiSchema: _
5022
5041
  }
5023
5042
  ) })
5024
5043
  ] }),
@@ -5026,7 +5045,7 @@ function BlockSettings() {
5026
5045
  JSONForm,
5027
5046
  {
5028
5047
  blockId: n == null ? void 0 : n._id,
5029
- onChange: y,
5048
+ onChange: k,
5030
5049
  formData: i,
5031
5050
  schema: v,
5032
5051
  uiSchema: B
@@ -5206,50 +5225,50 @@ const BlockStylingProps = () => {
5206
5225
  },
5207
5226
  a
5208
5227
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5209
- const [n, r] = 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]), [f, x] = useState(!1), [y, b] = useState(""), [v, B] = useState(!1), [w, E] = useState(!1);
5228
+ const [n, r] = 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]), [f, x] = useState(!1), [k, b] = useState(""), [v, B] = useState(!1), [w, _] = useState(!1);
5210
5229
  useEffect(() => {
5211
- const { value: C, unit: k } = getClassValueAndUnit(i);
5212
- if (k === "") {
5213
- l(C), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5230
+ const { value: S, unit: y } = getClassValueAndUnit(i);
5231
+ if (y === "") {
5232
+ l(S), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5214
5233
  return;
5215
5234
  }
5216
- m(k), l(k === "class" || isEmpty(C) ? "" : C);
5235
+ m(y), l(y === "class" || isEmpty(S) ? "" : S);
5217
5236
  }, [i, p, u]);
5218
- const _ = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), S = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), A = useCallback(
5219
- (C = !1) => {
5220
- const k = getUserInputValues(`${a}`, u);
5221
- if (get(k, "error", !1)) {
5237
+ const E = useThrottledCallback((S) => c(S), [c], THROTTLE_TIME), C = useThrottledCallback((S) => c(S, !1), [c], THROTTLE_TIME), A = useCallback(
5238
+ (S = !1) => {
5239
+ const y = getUserInputValues(`${a}`, u);
5240
+ if (get(y, "error", !1)) {
5222
5241
  x(!0);
5223
5242
  return;
5224
5243
  }
5225
- const j = get(k, "unit") !== "" ? get(k, "unit") : h;
5244
+ const j = get(y, "unit") !== "" ? get(y, "unit") : h;
5226
5245
  if (j === "auto" || j === "none") {
5227
- _(`${d}${j}`);
5246
+ E(`${d}${j}`);
5228
5247
  return;
5229
5248
  }
5230
- if (get(k, "value") === "")
5249
+ if (get(y, "value") === "")
5231
5250
  return;
5232
- const L = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5233
- C ? S(L) : _(L);
5251
+ const L = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5252
+ S ? C(L) : E(L);
5234
5253
  },
5235
- [_, S, a, h, d, u]
5254
+ [E, C, a, h, d, u]
5236
5255
  ), N = useCallback(
5237
- (C) => {
5238
- const k = getUserInputValues(`${a}`, u);
5239
- if (get(k, "error", !1)) {
5256
+ (S) => {
5257
+ const y = getUserInputValues(`${a}`, u);
5258
+ if (get(y, "error", !1)) {
5240
5259
  x(!0);
5241
5260
  return;
5242
5261
  }
5243
- if (C === "auto" || C === "none") {
5244
- _(`${d}${C}`);
5262
+ if (S === "auto" || S === "none") {
5263
+ E(`${d}${S}`);
5245
5264
  return;
5246
5265
  }
5247
- if (get(k, "value") === "")
5266
+ if (get(y, "value") === "")
5248
5267
  return;
5249
- const j = get(k, "unit") !== "" ? get(k, "unit") : C, L = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5250
- _(L);
5268
+ const j = get(y, "unit") !== "" ? get(y, "unit") : S, L = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5269
+ E(L);
5251
5270
  },
5252
- [_, a, d, u]
5271
+ [E, a, d, u]
5253
5272
  );
5254
5273
  return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: h === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5255
5274
  /* @__PURE__ */ jsx(
@@ -5270,31 +5289,31 @@ const BlockStylingProps = () => {
5270
5289
  "input",
5271
5290
  {
5272
5291
  readOnly: h === "class",
5273
- onKeyPress: (C) => {
5274
- C.key === "Enter" && A();
5292
+ onKeyPress: (S) => {
5293
+ S.key === "Enter" && A();
5275
5294
  },
5276
- onKeyDown: (C) => {
5277
- if (C.keyCode !== 38 && C.keyCode !== 40)
5295
+ onKeyDown: (S) => {
5296
+ if (S.keyCode !== 38 && S.keyCode !== 40)
5278
5297
  return;
5279
- C.preventDefault(), E(!0);
5280
- const k = parseInt$1(C.target.value);
5281
- let j = isNaN$1(k) ? 0 : k;
5282
- C.keyCode === 38 && (j += 1), C.keyCode === 40 && (j -= 1);
5283
- const T = `${j}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${h === "-" ? "" : h}]`;
5284
- S(R);
5298
+ S.preventDefault(), _(!0);
5299
+ const y = parseInt$1(S.target.value);
5300
+ let j = isNaN$1(y) ? 0 : y;
5301
+ S.keyCode === 38 && (j += 1), S.keyCode === 40 && (j -= 1);
5302
+ const I = `${j}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
5303
+ C(R);
5285
5304
  },
5286
- onKeyUp: (C) => {
5287
- w && (C.preventDefault(), E(!1));
5305
+ onKeyUp: (S) => {
5306
+ w && (S.preventDefault(), _(!1));
5288
5307
  },
5289
5308
  onBlur: () => A(),
5290
- onChange: (C) => {
5291
- x(!1), l(C.target.value);
5309
+ onChange: (S) => {
5310
+ x(!1), l(S.target.value);
5292
5311
  },
5293
- onClick: (C) => {
5294
- var k;
5295
- (k = C == null ? void 0 : C.target) == null || k.select(), r(!1);
5312
+ onClick: (S) => {
5313
+ var y;
5314
+ (y = S == null ? void 0 : S.target) == null || y.select(), r(!1);
5296
5315
  },
5297
- value: v ? y : a,
5316
+ value: v ? k : a,
5298
5317
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
5299
5318
  " ",
5300
5319
  f ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -5319,8 +5338,8 @@ const BlockStylingProps = () => {
5319
5338
  {
5320
5339
  units: u,
5321
5340
  current: h,
5322
- onSelect: (C) => {
5323
- r(!1), m(C), N(C);
5341
+ onSelect: (S) => {
5342
+ r(!1), m(S), N(S);
5324
5343
  }
5325
5344
  }
5326
5345
  ) })
@@ -5330,18 +5349,18 @@ const BlockStylingProps = () => {
5330
5349
  DragStyleButton,
5331
5350
  {
5332
5351
  onDragStart: () => B(!0),
5333
- onDragEnd: (C) => {
5334
- if (b(() => ""), B(!1), isEmpty(C))
5352
+ onDragEnd: (S) => {
5353
+ if (b(() => ""), B(!1), isEmpty(S))
5335
5354
  return;
5336
- const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
5337
- _(T);
5355
+ const y = `${S}`, I = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${h === "-" ? "" : h}]`;
5356
+ E(I);
5338
5357
  },
5339
- onDrag: (C) => {
5340
- if (isEmpty(C))
5358
+ onDrag: (S) => {
5359
+ if (isEmpty(S))
5341
5360
  return;
5342
- b(C);
5343
- const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
5344
- S(T);
5361
+ b(S);
5362
+ const y = `${S}`, I = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${h === "-" ? "" : h}]`;
5363
+ C(I);
5345
5364
  },
5346
5365
  currentValue: a,
5347
5366
  unit: h,
@@ -5406,8 +5425,8 @@ const COLOR_PROP = {
5406
5425
  }, ColorChoice = ({ property: o, onChange: n }) => {
5407
5426
  const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { 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(
5408
5427
  // eslint-disable-next-line no-shadow
5409
- (y) => {
5410
- ["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" })));
5428
+ (k) => {
5429
+ ["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" })));
5411
5430
  },
5412
5431
  [c, p]
5413
5432
  );
@@ -5418,8 +5437,8 @@ const COLOR_PROP = {
5418
5437
  }, [g]);
5419
5438
  const f = useCallback(
5420
5439
  // eslint-disable-next-line no-shadow
5421
- (y) => {
5422
- p({ color: g, shade: y });
5440
+ (k) => {
5441
+ p({ color: g, shade: k });
5423
5442
  },
5424
5443
  [g]
5425
5444
  );
@@ -5804,22 +5823,22 @@ const COLOR_PROP = {
5804
5823
  "2xl": "1536px"
5805
5824
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
5806
5825
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
5807
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
5808
- (S, A = !0) => {
5809
- const N = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
5826
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), k = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
5827
+ (C, A = !0) => {
5828
+ const N = { dark: p, mq: g, mod: u, cls: C, property: l, fullCls: "" };
5810
5829
  (p || u !== "") && (N.mq = "xs");
5811
- const C = generateFullClsName(N);
5812
- m(x, [C], A);
5830
+ const S = generateFullClsName(N);
5831
+ m(x, [S], A);
5813
5832
  },
5814
5833
  [x, p, g, u, l, m]
5815
5834
  ), v = useCallback(() => {
5816
- f(x, [y], !0);
5817
- }, [x, y, f]), B = useMemo(() => canChangeClass(h, g), [h, g]);
5835
+ f(x, [k], !0);
5836
+ }, [x, k, f]), B = useMemo(() => canChangeClass(h, g), [h, g]);
5818
5837
  useEffect(() => {
5819
5838
  i(B, h);
5820
5839
  }, [B, i, h]);
5821
- const [, , w] = useScreenSizeWidth(), E = useCallback(
5822
- (S) => {
5840
+ const [, , w] = useScreenSizeWidth(), _ = useCallback(
5841
+ (C) => {
5823
5842
  w({
5824
5843
  xs: 400,
5825
5844
  sm: 640,
@@ -5827,12 +5846,12 @@ const COLOR_PROP = {
5827
5846
  lg: 1024,
5828
5847
  xl: 1420,
5829
5848
  "2xl": 1920
5830
- }[S]);
5849
+ }[C]);
5831
5850
  },
5832
5851
  [w]
5833
- ), _ = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
5834
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: h && _, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
5835
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !_ ? "text-foreground" : ""}`, children: n(a) }) }),
5852
+ ), E = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
5853
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: h && E, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
5854
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !E ? "text-foreground" : ""}`, children: n(a) }) }),
5836
5855
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
5837
5856
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
5838
5857
  r === "arbitrary" ? /* @__PURE__ */ jsx(
@@ -5851,7 +5870,7 @@ const COLOR_PROP = {
5851
5870
  r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
5852
5871
  r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
5853
5872
  ] }),
5854
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: _ ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5873
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${k ? "visible" : "invisible"}`, children: E ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5855
5874
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5856
5875
  "button",
5857
5876
  {
@@ -5871,7 +5890,7 @@ const COLOR_PROP = {
5871
5890
  "button",
5872
5891
  {
5873
5892
  type: "button",
5874
- onClick: () => E(get(h, "mq")),
5893
+ onClick: () => _(get(h, "mq")),
5875
5894
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
5876
5895
  children: [
5877
5896
  "Switch to ",
@@ -6075,7 +6094,7 @@ const COLOR_PROP = {
6075
6094
  u.includes(b) ? u.length > 2 && g(u.filter((v) => v !== b)) : g((v) => [...v, b]);
6076
6095
  }, x = (b) => {
6077
6096
  n || l(b), c(b);
6078
- }, y = getBreakpointValue(n ? i : a).toLowerCase();
6097
+ }, k = getBreakpointValue(n ? i : a).toLowerCase();
6079
6098
  return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
6080
6099
  BreakpointCard,
6081
6100
  {
@@ -6083,7 +6102,7 @@ const COLOR_PROP = {
6083
6102
  ...b,
6084
6103
  onClick: x,
6085
6104
  key: b.breakpoint,
6086
- currentBreakpoint: y
6105
+ currentBreakpoint: k
6087
6106
  }
6088
6107
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
6089
6108
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
@@ -6097,7 +6116,7 @@ const COLOR_PROP = {
6097
6116
  ...b,
6098
6117
  onClick: x,
6099
6118
  key: b.breakpoint,
6100
- currentBreakpoint: y
6119
+ currentBreakpoint: k
6101
6120
  }
6102
6121
  )
6103
6122
  ) }),
@@ -6251,25 +6270,25 @@ const AskAIStyles = ({ blockId: o }) => {
6251
6270
  ] });
6252
6271
  };
6253
6272
  function ManualClasses() {
6254
- var T;
6255
- const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), y = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), v = b.split(" ").filter((L) => !isEmpty(L)), B = () => {
6273
+ var I;
6274
+ const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), k = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), v = b.split(" ").filter((L) => !isEmpty(L)), B = () => {
6256
6275
  const L = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6257
6276
  u(h, L, !0), x("");
6258
- }, [w, E] = useState([]), _ = ({ value: L }) => {
6259
- const R = L.trim().toLowerCase(), I = R.match(/.+:/g);
6277
+ }, [w, _] = useState([]), E = ({ value: L }) => {
6278
+ const R = L.trim().toLowerCase(), T = R.match(/.+:/g);
6260
6279
  let D = [];
6261
- if (I && I.length > 0) {
6262
- const [O] = I, P = R.replace(O, "");
6280
+ if (T && T.length > 0) {
6281
+ const [O] = T, P = R.replace(O, "");
6263
6282
  D = i.search(P).map((M) => ({
6264
6283
  ...M,
6265
6284
  item: { ...M.item, name: O + M.item.name }
6266
6285
  }));
6267
6286
  } else
6268
6287
  D = i.search(R);
6269
- return E(map(D, "item"));
6270
- }, S = () => {
6271
- E([]);
6272
- }, A = (L) => L.name, N = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), C = useMemo(
6288
+ return _(map(D, "item"));
6289
+ }, C = () => {
6290
+ _([]);
6291
+ }, A = (L) => L.name, N = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), S = useMemo(
6273
6292
  () => ({
6274
6293
  ref: o,
6275
6294
  autoComplete: "off",
@@ -6290,7 +6309,7 @@ function ManualClasses() {
6290
6309
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
6291
6310
  }),
6292
6311
  [f, c, o]
6293
- ), k = (L) => {
6312
+ ), y = (L) => {
6294
6313
  debugger;
6295
6314
  const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6296
6315
  g(h, [L]), u(h, R, !0), r(""), l(-1);
@@ -6323,11 +6342,11 @@ function ManualClasses() {
6323
6342
  Autosuggest,
6324
6343
  {
6325
6344
  suggestions: w,
6326
- onSuggestionsFetchRequested: _,
6327
- onSuggestionsClearRequested: S,
6345
+ onSuggestionsFetchRequested: E,
6346
+ onSuggestionsClearRequested: C,
6328
6347
  getSuggestionValue: A,
6329
6348
  renderSuggestion: N,
6330
- inputProps: C,
6349
+ inputProps: S,
6331
6350
  containerProps: {
6332
6351
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
6333
6352
  },
@@ -6356,16 +6375,16 @@ function ManualClasses() {
6356
6375
  {
6357
6376
  ref: o,
6358
6377
  value: n,
6359
- onChange: (I) => r(I.target.value),
6378
+ onChange: (T) => r(T.target.value),
6360
6379
  onBlur: () => {
6361
- k(L);
6380
+ y(L);
6362
6381
  },
6363
- onKeyDown: (I) => {
6364
- I.key === "Enter" && k(L);
6382
+ onKeyDown: (T) => {
6383
+ T.key === "Enter" && y(L);
6365
6384
  },
6366
- onFocus: (I) => {
6385
+ onFocus: (T) => {
6367
6386
  setTimeout(() => {
6368
- I.target.select();
6387
+ T.target.select();
6369
6388
  }, 0);
6370
6389
  },
6371
6390
  className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
@@ -6510,8 +6529,8 @@ function BlockStyling() {
6510
6529
  m = isNaN(m) ? 0 : m;
6511
6530
  let f = MAPPER[i.dragUnit];
6512
6531
  (startsWith(h, "scale") || h === "opacity") && (f = 10);
6513
- let y = (i.dragStartY - u.pageY) / f + m;
6514
- g && y < 0 && (y = 0), h === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6532
+ let k = (i.dragStartY - u.pageY) / f + m;
6533
+ g && k < 0 && (k = 0), h === "opacity" && k > 1 && (k = 1), i.onDrag(`${k}`), l(`${k}`);
6515
6534
  },
6516
6535
  [i],
6517
6536
  50
@@ -6554,8 +6573,8 @@ const CoreBlock = ({
6554
6573
  }) => {
6555
6574
  const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
6556
6575
  if (has(o, "blocks")) {
6557
- const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
6558
- u(syncBlocksWithDefaults(y), r || null, a);
6576
+ const k = isFunction(o.blocks) ? o.blocks() : o.blocks;
6577
+ u(syncBlocksWithDefaults(k), r || null, a);
6559
6578
  } else
6560
6579
  p(o, r || null, a);
6561
6580
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
@@ -6567,8 +6586,8 @@ const CoreBlock = ({
6567
6586
  disabled: n,
6568
6587
  onClick: m,
6569
6588
  type: "button",
6570
- onDragStart: (y) => {
6571
- y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6589
+ onDragStart: (k) => {
6590
+ k.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), k.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6572
6591
  g([]), h();
6573
6592
  }, 200);
6574
6593
  },
@@ -6768,7 +6787,7 @@ const CoreBlock = ({
6768
6787
  }
6769
6788
  }
6770
6789
  }, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
6771
- var h, m, f, x, y, b, v, B;
6790
+ var h, m, f, x, k, b, v, B;
6772
6791
  if (r.type === "comment") return [];
6773
6792
  let a = { _id: generateUUID() };
6774
6793
  if (n && (a._parent = n.block._id), r.type === "text")
@@ -6790,7 +6809,7 @@ const CoreBlock = ({
6790
6809
  ...getAttrs(r),
6791
6810
  ...getStyles(r)
6792
6811
  }, r.attributes) {
6793
- const w = r.attributes.find((E) => includes(NAME_ATTRIBUTES, E.key));
6812
+ const w = r.attributes.find((_) => includes(NAME_ATTRIBUTES, _.key));
6794
6813
  w && (a._name = w.value);
6795
6814
  }
6796
6815
  if (i)
@@ -6808,30 +6827,30 @@ const CoreBlock = ({
6808
6827
  ];
6809
6828
  a = {
6810
6829
  ...a,
6811
- href: ((h = l.find((E) => E.key === "href")) == null ? void 0 : h.value) || "",
6812
- hrefType: ((m = l.find((E) => E.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
6813
- autoplay: ((f = l.find((E) => E.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
6814
- maxWidth: ((y = (x = l.find((E) => E.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : y.replace("px", "")) || "",
6815
- backdropColor: ((b = l.find((E) => E.key === "data-overlay")) == null ? void 0 : b.value) || "",
6816
- galleryName: ((v = l.find((E) => E.key === "data-gall")) == null ? void 0 : v.value) || ""
6817
- }, forEach(w, (E) => {
6818
- has(a, `styles_attrs.${E}`) && delete a.styles_attrs[E];
6830
+ href: ((h = l.find((_) => _.key === "href")) == null ? void 0 : h.value) || "",
6831
+ hrefType: ((m = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
6832
+ autoplay: ((f = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
6833
+ maxWidth: ((k = (x = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : k.replace("px", "")) || "",
6834
+ backdropColor: ((b = l.find((_) => _.key === "data-overlay")) == null ? void 0 : b.value) || "",
6835
+ galleryName: ((v = l.find((_) => _.key === "data-gall")) == null ? void 0 : v.value) || ""
6836
+ }, forEach(w, (_) => {
6837
+ has(a, `styles_attrs.${_}`) && delete a.styles_attrs[_];
6819
6838
  });
6820
6839
  }
6821
6840
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
6822
6841
  delete a.styles_attrs;
6823
- const w = filter(r.children || [], (_) => (_ == null ? void 0 : _.tagName) !== "span");
6842
+ const w = filter(r.children || [], (E) => (E == null ? void 0 : E.tagName) !== "span");
6824
6843
  a.content = getTextContent(w);
6825
- const E = find(
6844
+ const _ = find(
6826
6845
  r.children || [],
6827
- (_) => (_ == null ? void 0 : _.tagName) === "span" && some(_.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg")
6846
+ (E) => (E == null ? void 0 : E.tagName) === "span" && some(E.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg")
6828
6847
  );
6829
- if (E) {
6830
- const _ = find(E.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg");
6831
- if (_) {
6832
- a.icon = stringify([_]);
6833
- const { height: S, width: A } = getSvgDimensions(_, "16px", "16px");
6834
- a.iconHeight = S, a.iconWidth = A;
6848
+ if (_) {
6849
+ const E = find(_.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg");
6850
+ if (E) {
6851
+ a.icon = stringify([E]);
6852
+ const { height: C, width: A } = getSvgDimensions(E, "16px", "16px");
6853
+ a.iconHeight = C, a.iconWidth = A;
6835
6854
  }
6836
6855
  }
6837
6856
  return [a];
@@ -6843,8 +6862,8 @@ const CoreBlock = ({
6843
6862
  const w = stringify([r]);
6844
6863
  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];
6845
6864
  } else if (r.tagName === "svg") {
6846
- const w = find(r.attributes, { key: "height" }), E = find(r.attributes, { key: "width" }), _ = get(w, "value") ? `[${get(w, "value")}px]` : "24px", S = get(E, "value") ? `[${get(E, "value")}px]` : "24px", A = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
6847
- return a.styles = `${STYLES_KEY}, ${cn$2(`w-${S} h-${_}`, A)}`.trim(), r.attributes = filter(r.attributes, (N) => !includes(["style", "width", "height", "class"], N.key)), a.icon = stringify([r]), [a];
6865
+ const w = find(r.attributes, { key: "height" }), _ = find(r.attributes, { key: "width" }), E = get(w, "value") ? `[${get(w, "value")}px]` : "24px", C = get(_, "value") ? `[${get(_, "value")}px]` : "24px", A = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
6866
+ return a.styles = `${STYLES_KEY}, ${cn$2(`w-${C} h-${E}`, A)}`.trim(), r.attributes = filter(r.attributes, (N) => !includes(["style", "width", "height", "class"], N.key)), a.icon = stringify([r]), [a];
6848
6867
  } else if (r.tagName == "option" && n && ((B = n.block) == null ? void 0 : B._type) === "Select")
6849
6868
  return n.block.options.push({
6850
6869
  label: getTextContent(r.children),
@@ -6952,7 +6971,7 @@ const registerChaiLibrary = (o, n) => {
6952
6971
  parentId: r = void 0,
6953
6972
  position: a = -1
6954
6973
  }) => {
6955
- const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), y = (B) => {
6974
+ const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), k = (B) => {
6956
6975
  const w = has(B, "styles_attrs.data-page-section");
6957
6976
  return B._type === "Box" && w;
6958
6977
  }, b = useCallback(
@@ -6976,17 +6995,17 @@ const registerChaiLibrary = (o, n) => {
6976
6995
  draggable: f ? "true" : "false",
6977
6996
  onDragStart: async (B) => {
6978
6997
  const w = await c({ library: n, block: o });
6979
- let E = r;
6980
- if (y(first(w)) && (E = null), !isEmpty(w)) {
6981
- const _ = { blocks: w, uiLibrary: !0, parent: E };
6982
- if (B.dataTransfer.setData("text/plain", JSON.stringify(_)), o.preview) {
6983
- const S = new Image();
6984
- S.src = o.preview, S.onload = () => {
6985
- B.dataTransfer.setDragImage(S, 0, 0);
6998
+ let _ = r;
6999
+ if (k(first(w)) && (_ = null), !isEmpty(w)) {
7000
+ const E = { blocks: w, uiLibrary: !0, parent: _ };
7001
+ if (B.dataTransfer.setData("text/plain", JSON.stringify(E)), o.preview) {
7002
+ const C = new Image();
7003
+ C.src = o.preview, C.onload = () => {
7004
+ B.dataTransfer.setDragImage(C, 0, 0);
6986
7005
  };
6987
7006
  } else
6988
7007
  B.dataTransfer.setDragImage(new Image(), 0, 0);
6989
- x(_), setTimeout(() => {
7008
+ x(E), setTimeout(() => {
6990
7009
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6991
7010
  }, 200);
6992
7011
  }
@@ -7012,7 +7031,7 @@ const registerChaiLibrary = (o, n) => {
7012
7031
  ] }) })
7013
7032
  ] });
7014
7033
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7015
- const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((k) => k.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), f = useRef(null);
7034
+ const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((y) => y.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), f = useRef(null);
7016
7035
  useEffect(() => {
7017
7036
  c && c.length > 0 && (f.current = new Fuse(c, {
7018
7037
  keys: ["name", "label", "description", "group"],
@@ -7024,25 +7043,25 @@ const registerChaiLibrary = (o, n) => {
7024
7043
  m([]);
7025
7044
  return;
7026
7045
  }
7027
- const k = f.current.search(u).map((j) => j.item);
7028
- m(k);
7046
+ const y = f.current.search(u).map((j) => j.item);
7047
+ m(y);
7029
7048
  }, [u]);
7030
- const x = u.trim() && !isEmpty(h) ? h : c, y = groupBy(x, "group"), [b, v] = useState(null);
7049
+ const x = u.trim() && !isEmpty(h) ? h : c, k = groupBy(x, "group"), [b, v] = useState(null);
7031
7050
  useEffect(() => {
7032
- if (isEmpty(keys(y))) {
7051
+ if (isEmpty(keys(k))) {
7033
7052
  v(null);
7034
7053
  return;
7035
7054
  }
7036
- if (!b || !y[b]) {
7037
- v(first(keys(y)));
7055
+ if (!b || !k[b]) {
7056
+ v(first(keys(k)));
7038
7057
  return;
7039
7058
  }
7040
- }, [y, b]);
7041
- const B = get(y, b, []), w = useRef(null), { t: E } = useTranslation(), _ = (k) => {
7059
+ }, [k, b]);
7060
+ const B = get(k, b, []), w = useRef(null), { t: _ } = useTranslation(), E = (y) => {
7042
7061
  w.current && (clearTimeout(w.current), w.current = null), w.current = setTimeout(() => {
7043
- w.current && v(k);
7062
+ w.current && v(y);
7044
7063
  }, 400);
7045
- }, S = () => {
7064
+ }, C = () => {
7046
7065
  i != null && i.id && p(i.id);
7047
7066
  }, A = () => {
7048
7067
  g("");
@@ -7052,16 +7071,16 @@ const registerChaiLibrary = (o, n) => {
7052
7071
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7053
7072
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7054
7073
  ] });
7055
- const N = filter(B, (k, j) => j % 2 === 0), C = filter(B, (k, j) => j % 2 === 1);
7074
+ const N = filter(B, (y, j) => j % 2 === 0), S = filter(B, (y, j) => j % 2 === 1);
7056
7075
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
7057
7076
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7058
7077
  /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
7059
7078
  /* @__PURE__ */ jsx(
7060
7079
  Input$1,
7061
7080
  {
7062
- placeholder: E("Search blocks..."),
7081
+ placeholder: _("Search blocks..."),
7063
7082
  value: u,
7064
- onChange: (k) => g(k.target.value),
7083
+ onChange: (y) => g(y.target.value),
7065
7084
  className: "w-full pl-8 pr-8"
7066
7085
  }
7067
7086
  ),
@@ -7078,18 +7097,18 @@ const registerChaiLibrary = (o, n) => {
7078
7097
  /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 min-w-60 max-w-60 flex-col gap-1 px-1 pr-2", children: [
7079
7098
  /* @__PURE__ */ jsx(UILibrariesSelect, { library: i == null ? void 0 : i.id, setLibrary: a, uiLibraries: l }),
7080
7099
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7081
- /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: E("Groups") }),
7100
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: _("Groups") }),
7082
7101
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7083
- /* @__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: E("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7084
- /* @__PURE__ */ jsx("p", { className: "text-sm", children: E("Failed to load the UI library. Try again") }),
7085
- /* @__PURE__ */ jsxs(Button, { onClick: S, variant: "outline", size: "sm", className: "gap-2", children: [
7102
+ /* @__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: _("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7103
+ /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("Failed to load the UI library. Try again") }),
7104
+ /* @__PURE__ */ jsxs(Button, { onClick: C, variant: "outline", size: "sm", className: "gap-2", children: [
7086
7105
  /* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
7087
- E("Retry")
7106
+ _("Retry")
7088
7107
  ] })
7089
- ] }) }) : map(y, (k, j) => /* @__PURE__ */ jsxs(
7108
+ ] }) }) : map(k, (y, j) => /* @__PURE__ */ jsxs(
7090
7109
  "div",
7091
7110
  {
7092
- onMouseEnter: () => _(j),
7111
+ onMouseEnter: () => E(j),
7093
7112
  onMouseLeave: () => clearTimeout(w.current),
7094
7113
  role: "button",
7095
7114
  onClick: () => v(j),
@@ -7098,7 +7117,7 @@ const registerChaiLibrary = (o, n) => {
7098
7117
  j === b ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
7099
7118
  ),
7100
7119
  children: [
7101
- /* @__PURE__ */ jsx("span", { children: capitalize(E(j.toLowerCase())) }),
7120
+ /* @__PURE__ */ jsx("span", { children: capitalize(_(j.toLowerCase())) }),
7102
7121
  /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
7103
7122
  ]
7104
7123
  },
@@ -7112,23 +7131,23 @@ const registerChaiLibrary = (o, n) => {
7112
7131
  onMouseEnter: () => w.current ? clearTimeout(w.current) : null,
7113
7132
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
7114
7133
  children: [
7115
- isEmpty(B) && !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: E("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7116
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: N.map((k, j) => /* @__PURE__ */ jsx(
7134
+ isEmpty(B) && !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: _("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7135
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: N.map((y, j) => /* @__PURE__ */ jsx(
7117
7136
  BlockCard,
7118
7137
  {
7119
7138
  parentId: o,
7120
7139
  position: n,
7121
- block: k,
7140
+ block: y,
7122
7141
  library: i
7123
7142
  },
7124
7143
  `block-${j}`
7125
7144
  )) }),
7126
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: C.map((k, j) => /* @__PURE__ */ jsx(
7145
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: S.map((y, j) => /* @__PURE__ */ jsx(
7127
7146
  BlockCard,
7128
7147
  {
7129
7148
  parentId: o,
7130
7149
  position: n,
7131
- block: k,
7150
+ block: y,
7132
7151
  library: i
7133
7152
  },
7134
7153
  `block-second-${j}`
@@ -7167,8 +7186,8 @@ const registerChaiLibrary = (o, n) => {
7167
7186
  error: c
7168
7187
  }), g(!0);
7169
7188
  else if (!l && Object.keys(a || {}).length > 0) {
7170
- const m = Object.entries(a).map(([x, y]) => {
7171
- const b = y, v = b.type || "partial", B = formatReadableName(v);
7189
+ const m = Object.entries(a).map(([x, k]) => {
7190
+ const b = k, v = b.type || "partial", B = formatReadableName(v);
7172
7191
  return {
7173
7192
  type: "PartialBlock",
7174
7193
  // Set the type to PartialBlock
@@ -7230,44 +7249,44 @@ const registerChaiLibrary = (o, n) => {
7230
7249
  }, ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, n) => {
7231
7250
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...n });
7232
7251
  }, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
7233
- var C;
7234
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (C = find(c, (k) => k._id === r)) == null ? void 0 : C._type, [m, f] = useState("all"), [x, y] = useState(null), b = useRef(null);
7252
+ var S;
7253
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (S = find(c, (y) => y._id === r)) == null ? void 0 : S._type, [m, f] = useState("all"), [x, k] = useState(null), b = useRef(null);
7235
7254
  useEffect(() => {
7236
- const k = setTimeout(() => {
7255
+ const y = setTimeout(() => {
7237
7256
  var j;
7238
7257
  (j = u.current) == null || j.focus();
7239
7258
  }, 0);
7240
- return () => clearTimeout(k);
7259
+ return () => clearTimeout(y);
7241
7260
  }, [g]), useEffect(() => {
7242
- d && (f("all"), y(null));
7243
- }, [d]), useEffect(() => (b.current = debounce((k) => {
7244
- f(k);
7261
+ d && (f("all"), k(null));
7262
+ }, [d]), useEffect(() => (b.current = debounce((y) => {
7263
+ f(y);
7245
7264
  }, 500), () => {
7246
7265
  b.current && b.current.cancel();
7247
7266
  }), []);
7248
- const v = useCallback((k) => {
7249
- y(k), b.current && b.current(k);
7267
+ const v = useCallback((y) => {
7268
+ k(y), b.current && b.current(y);
7250
7269
  }, []), B = useCallback(() => {
7251
- y(null), b.current && b.current.cancel();
7252
- }, []), w = useCallback((k) => {
7253
- b.current && b.current.cancel(), f(k), y(null);
7254
- }, []), E = useMemo(
7270
+ k(null), b.current && b.current.cancel();
7271
+ }, []), w = useCallback((y) => {
7272
+ b.current && b.current.cancel(), f(y), k(null);
7273
+ }, []), _ = useMemo(
7255
7274
  () => d ? values(n).filter(
7256
- (k) => {
7257
- var j, T;
7258
- return (((j = k.label) == null ? void 0 : j.toLowerCase()) + " " + ((T = k.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
7275
+ (y) => {
7276
+ var j, I;
7277
+ return (((j = y.label) == null ? void 0 : j.toLowerCase()) + " " + ((I = y.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
7259
7278
  }
7260
7279
  ) : n,
7261
7280
  [n, d]
7262
- ), _ = useMemo(
7281
+ ), E = useMemo(
7263
7282
  () => d ? o.filter(
7264
- (k) => reject(filter(values(E), { group: k }), { hidden: !0 }).length > 0
7265
- ) : o.filter((k) => reject(filter(values(n), { group: k }), { hidden: !0 }).length > 0),
7266
- [n, E, o, d]
7267
- ), S = useMemo(
7268
- () => sortBy(_, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7269
- [_]
7270
- ), A = useMemo(() => m === "all" ? E : filter(values(E), { group: m }), [E, m]), N = useMemo(() => m === "all" ? S : [m], [S, m]);
7283
+ (y) => reject(filter(values(_), { group: y }), { hidden: !0 }).length > 0
7284
+ ) : o.filter((y) => reject(filter(values(n), { group: y }), { hidden: !0 }).length > 0),
7285
+ [n, _, o, d]
7286
+ ), C = useMemo(
7287
+ () => sortBy(E, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
7288
+ [E]
7289
+ ), A = useMemo(() => m === "all" ? _ : filter(values(_), { group: m }), [_, m]), N = useMemo(() => m === "all" ? C : [m], [C, m]);
7271
7290
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7272
7291
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7273
7292
  Input$1,
@@ -7277,11 +7296,11 @@ const registerChaiLibrary = (o, n) => {
7277
7296
  placeholder: i("Search blocks..."),
7278
7297
  value: d,
7279
7298
  className: "-ml-2",
7280
- onChange: (k) => p(k.target.value)
7299
+ onChange: (y) => p(y.target.value)
7281
7300
  }
7282
7301
  ) }),
7283
7302
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
7284
- 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: [
7303
+ C.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: [
7285
7304
  /* @__PURE__ */ jsx(
7286
7305
  "button",
7287
7306
  {
@@ -7293,27 +7312,27 @@ const registerChaiLibrary = (o, n) => {
7293
7312
  },
7294
7313
  "sidebar-all"
7295
7314
  ),
7296
- S.map((k) => /* @__PURE__ */ jsx(
7315
+ C.map((y) => /* @__PURE__ */ jsx(
7297
7316
  "button",
7298
7317
  {
7299
- onClick: () => w(k),
7300
- onMouseEnter: () => v(k),
7318
+ onClick: () => w(y),
7319
+ onMouseEnter: () => v(y),
7301
7320
  onMouseLeave: B,
7302
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === k || x === k ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7303
- children: capitalize(i(k.toLowerCase()))
7321
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === y || x === y ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7322
+ children: capitalize(i(y.toLowerCase()))
7304
7323
  },
7305
- `sidebar-${k}`
7324
+ `sidebar-${y}`
7306
7325
  ))
7307
7326
  ] }) }) }),
7308
- /* @__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: _.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: [
7327
+ /* @__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: E.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: [
7309
7328
  i("No blocks found matching"),
7310
7329
  ' "',
7311
7330
  d,
7312
7331
  '"'
7313
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7314
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
7332
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((y) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7333
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(y.toLowerCase())) }),
7315
7334
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7316
- m === "all" ? filter(values(A), { group: k }) : values(A),
7335
+ m === "all" ? filter(values(A), { group: y }) : values(A),
7317
7336
  { hidden: !0 }
7318
7337
  ).map((j) => /* @__PURE__ */ jsx(
7319
7338
  CoreBlock,
@@ -7325,7 +7344,7 @@ const registerChaiLibrary = (o, n) => {
7325
7344
  },
7326
7345
  j.type
7327
7346
  )) })
7328
- ] }, k)) }) }) })
7347
+ ] }, y)) }) }) })
7329
7348
  ] })
7330
7349
  ] });
7331
7350
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -7675,35 +7694,35 @@ const Input = ({ node: o }) => {
7675
7694
  var R;
7676
7695
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7677
7696
  let p = null;
7678
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: f, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: v, handleClick: B } = o, w = (I) => {
7679
- I.stopPropagation(), !l.includes(m) && o.toggle();
7680
- }, E = (I) => {
7681
- I.isInternal && (p = I.isOpen, I.isOpen && I.close());
7682
- }, _ = (I) => {
7683
- I.isInternal && p !== null && (p ? I.open() : I.close(), p = null);
7684
- }, [S, A] = useAtom$1(currentAddSelection), N = () => {
7685
- var I;
7686
- C(), o.parent.isSelected || A((I = o == null ? void 0 : o.parent) == null ? void 0 : I.id);
7687
- }, C = () => {
7697
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: f, isSelected: x, willReceiveDrop: k, isDragging: b, isEditing: v, handleClick: B } = o, w = (T) => {
7698
+ T.stopPropagation(), !l.includes(m) && o.toggle();
7699
+ }, _ = (T) => {
7700
+ T.isInternal && (p = T.isOpen, T.isOpen && T.close());
7701
+ }, E = (T) => {
7702
+ T.isInternal && p !== null && (p ? T.open() : T.close(), p = null);
7703
+ }, [C, A] = useAtom$1(currentAddSelection), N = () => {
7704
+ var T;
7705
+ S(), o.parent.isSelected || A((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
7706
+ }, S = () => {
7688
7707
  A(null);
7689
- }, k = (I) => {
7690
- C(), I.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), B(I);
7708
+ }, y = (T) => {
7709
+ S(), T.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), B(T);
7691
7710
  };
7692
7711
  useEffect(() => {
7693
- const I = setTimeout(() => {
7694
- y && !o.isOpen && !b && !l.includes(m) && o.toggle();
7712
+ const T = setTimeout(() => {
7713
+ k && !o.isOpen && !b && !l.includes(m) && o.toggle();
7695
7714
  }, 500);
7696
- return () => clearTimeout(I);
7697
- }, [y, o, b]);
7698
- const j = (I, D) => {
7699
- const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${I}]`);
7715
+ return () => clearTimeout(T);
7716
+ }, [k, o, b]);
7717
+ const j = (T, D) => {
7718
+ const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${T}]`);
7700
7719
  P && P.setAttribute("data-drop", D);
7701
7720
  const $ = P.getBoundingClientRect(), M = c.getBoundingClientRect();
7702
7721
  $.top >= M.top && $.left >= M.left && $.bottom <= M.bottom && $.right <= M.right || (O.documentElement.scrollTop = P.offsetTop - M.top);
7703
- }, T = (I) => {
7704
- C();
7722
+ }, I = (T) => {
7723
+ S();
7705
7724
  const D = get(o, "parent.id");
7706
- D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: I }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: I });
7725
+ D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: T }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: T });
7707
7726
  };
7708
7727
  if (m === ROOT_TEMP_KEY)
7709
7728
  return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
@@ -7712,7 +7731,7 @@ const Input = ({ node: o }) => {
7712
7731
  "div",
7713
7732
  {
7714
7733
  role: "button",
7715
- onClick: () => T(-1),
7734
+ onClick: () => I(-1),
7716
7735
  className: "h-1 rounded bg-primary opacity-0 duration-200 group-hover:opacity-100",
7717
7736
  children: /* @__PURE__ */ jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-primary px-3 py-1 text-[9px] leading-tight text-white hover:bg-primary", children: [
7718
7737
  /* @__PURE__ */ jsx(PlusIcon, { className: "h-2 w-2 stroke-[3]" }),
@@ -7729,30 +7748,30 @@ const Input = ({ node: o }) => {
7729
7748
  {
7730
7749
  onMouseEnter: () => g(m),
7731
7750
  onMouseLeave: () => h(),
7732
- onClick: k,
7751
+ onClick: y,
7733
7752
  style: n,
7734
7753
  "data-node-id": m,
7735
7754
  ref: l.includes(m) ? null : r,
7736
- onDragStart: () => E(o),
7737
- onDragEnd: () => _(o),
7738
- onDragOver: (I) => {
7739
- I.preventDefault(), j(m, "yes");
7755
+ onDragStart: () => _(o),
7756
+ onDragEnd: () => E(o),
7757
+ onDragOver: (T) => {
7758
+ T.preventDefault(), j(m, "yes");
7740
7759
  },
7741
- onDragLeave: (I) => {
7742
- I.preventDefault(), j(m, "no");
7760
+ onDragLeave: (T) => {
7761
+ T.preventDefault(), j(m, "no");
7743
7762
  },
7744
- onDrop: (I) => {
7745
- I.preventDefault(), j(m, "no");
7763
+ onDrop: (T) => {
7764
+ T.preventDefault(), j(m, "no");
7746
7765
  },
7747
7766
  children: [
7748
7767
  d(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((R = o == null ? void 0 : o.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
7749
7768
  "div",
7750
7769
  {
7751
- onClick: (I) => {
7752
- I.stopPropagation(), T(o.childIndex);
7770
+ onClick: (T) => {
7771
+ T.stopPropagation(), I(o.childIndex);
7753
7772
  },
7754
7773
  onMouseEnter: N,
7755
- onMouseLeave: C,
7774
+ onMouseLeave: S,
7756
7775
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
7757
7776
  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" }) })
7758
7777
  }
@@ -7763,8 +7782,8 @@ const Input = ({ node: o }) => {
7763
7782
  className: cn(
7764
7783
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
7765
7784
  x ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
7766
- y && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
7767
- (o == null ? void 0 : o.id) === S ? "bg-primary/10" : "",
7785
+ k && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
7786
+ (o == null ? void 0 : o.id) === C ? "bg-primary/10" : "",
7768
7787
  b && "opacity-20",
7769
7788
  l.includes(m) ? "opacity-50" : "",
7770
7789
  L && x && "bg-primary/20 text-primary"
@@ -7792,8 +7811,8 @@ const Input = ({ node: o }) => {
7792
7811
  "div",
7793
7812
  {
7794
7813
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
7795
- onDoubleClick: (I) => {
7796
- I.stopPropagation(), o.edit(), o.deselect();
7814
+ onDoubleClick: (T) => {
7815
+ T.stopPropagation(), o.edit(), o.deselect();
7797
7816
  },
7798
7817
  children: /* @__PURE__ */ jsx("span", { children: (f == null ? void 0 : f._name) || (f == null ? void 0 : f._type.split("/").pop()) })
7799
7818
  }
@@ -7819,8 +7838,8 @@ const Input = ({ node: o }) => {
7819
7838
  /* @__PURE__ */ jsx(
7820
7839
  TooltipTrigger,
7821
7840
  {
7822
- onClick: (I) => {
7823
- I.stopPropagation(), i(m), o.isOpen && o.toggle();
7841
+ onClick: (T) => {
7842
+ T.stopPropagation(), i(m), o.isOpen && o.toggle();
7824
7843
  },
7825
7844
  className: "cursor-pointer rounded bg-transparent",
7826
7845
  asChild: !0,
@@ -8124,7 +8143,7 @@ const Input = ({ node: o }) => {
8124
8143
  },
8125
8144
  [d],
8126
8145
  200
8127
- ), y = useDebouncedCallback(
8146
+ ), k = useDebouncedCallback(
8128
8147
  (v, B) => {
8129
8148
  p(() => {
8130
8149
  const w = get(d, `colors.${v}`);
@@ -8146,10 +8165,10 @@ const Input = ({ node: o }) => {
8146
8165
  ColorPickerInput,
8147
8166
  {
8148
8167
  value: w,
8149
- onChange: (E) => y(B, E)
8168
+ onChange: (_) => k(B, _)
8150
8169
  }
8151
8170
  ),
8152
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
8171
+ /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((_) => _.charAt(0).toUpperCase() + _.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
8153
8172
  ] }, B);
8154
8173
  }) });
8155
8174
  return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
@@ -8676,8 +8695,8 @@ const AIUserPrompt = ({ blockId: o }) => {
8676
8695
  (x = h.current) == null || x.focus();
8677
8696
  }, []);
8678
8697
  const f = (x) => {
8679
- const { usage: y } = x || {};
8680
- !l && y && g(y), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8698
+ const { usage: k } = x || {};
8699
+ !l && k && g(k), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8681
8700
  };
8682
8701
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8683
8702
  /* @__PURE__ */ jsxs(
@@ -8915,15 +8934,15 @@ function AIChatPanel() {
8915
8934
  const v = (B = b.target.files) == null ? void 0 : B[0];
8916
8935
  if (v) {
8917
8936
  const w = new FileReader();
8918
- w.onload = (E) => {
8919
- var _;
8920
- d((_ = E.target) == null ? void 0 : _.result);
8937
+ w.onload = (_) => {
8938
+ var E;
8939
+ d((E = _.target) == null ? void 0 : E.result);
8921
8940
  }, w.readAsDataURL(v);
8922
8941
  }
8923
8942
  }, x = () => {
8924
8943
  var b;
8925
8944
  (b = p.current) == null || b.click();
8926
- }, y = () => {
8945
+ }, k = () => {
8927
8946
  d(null), p.current && (p.current.value = "");
8928
8947
  };
8929
8948
  return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
@@ -8969,7 +8988,7 @@ function AIChatPanel() {
8969
8988
  size: "icon",
8970
8989
  variant: "destructive",
8971
8990
  className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
8972
- onClick: y,
8991
+ onClick: k,
8973
8992
  children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
8974
8993
  }
8975
8994
  )
@@ -9112,7 +9131,7 @@ const AiAssistant = () => {
9112
9131
  preloadedAttributes: n = [],
9113
9132
  onAttributesChange: r
9114
9133
  }) {
9115
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), f = useRef(null), x = useRef(null), y = usePageExternalData();
9134
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), f = useRef(null), x = useRef(null), k = usePageExternalData();
9116
9135
  useEffect(() => {
9117
9136
  l(n);
9118
9137
  }, [n]);
@@ -9122,43 +9141,43 @@ const AiAssistant = () => {
9122
9141
  return;
9123
9142
  }
9124
9143
  if (i) {
9125
- const S = [...a, { key: i, value: d }];
9126
- r(S), l(a), c(""), p(""), m("");
9144
+ const C = [...a, { key: i, value: d }];
9145
+ r(C), l(a), c(""), p(""), m("");
9127
9146
  }
9128
- }, v = (S) => {
9129
- const A = a.filter((N, C) => C !== S);
9147
+ }, v = (C) => {
9148
+ const A = a.filter((N, S) => S !== C);
9130
9149
  r(A), l(A);
9131
- }, B = (S) => {
9132
- g(S), c(a[S].key), p(a[S].value);
9150
+ }, B = (C) => {
9151
+ g(C), c(a[C].key), p(a[C].value);
9133
9152
  }, w = () => {
9134
9153
  if (i.startsWith("@")) {
9135
9154
  m("Attribute keys cannot start with '@'");
9136
9155
  return;
9137
9156
  }
9138
9157
  if (u !== null && i) {
9139
- const S = [...a];
9140
- S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), m("");
9158
+ const C = [...a];
9159
+ C[u] = { key: i, value: d }, r(C), l(C), g(null), c(""), p(""), m("");
9141
9160
  }
9142
- }, E = (S) => {
9143
- S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : b());
9144
- }, _ = useCallback((S) => {
9145
- const A = (k) => /[.,!?;:]/.test(k), N = (k, j, T) => {
9161
+ }, _ = (C) => {
9162
+ C.key === "Enter" && !C.shiftKey && (C.preventDefault(), u !== null ? w() : b());
9163
+ }, E = useCallback((C) => {
9164
+ const A = (y) => /[.,!?;:]/.test(y), N = (y, j, I) => {
9146
9165
  let L = "", R = "";
9147
- const I = j > 0 ? k[j - 1] : "", D = j < k.length ? k[j] : "";
9148
- return j > 0 && (I === "." || !A(I) && I !== " ") && (L = " "), j < k.length && !A(D) && D !== " " && (R = " "), {
9149
- text: L + T + R,
9166
+ const T = j > 0 ? y[j - 1] : "", D = j < y.length ? y[j] : "";
9167
+ return j > 0 && (T === "." || !A(T) && T !== " ") && (L = " "), j < y.length && !A(D) && D !== " " && (R = " "), {
9168
+ text: L + I + R,
9150
9169
  prefixLength: L.length,
9151
9170
  suffixLength: R.length
9152
9171
  };
9153
- }, C = x.current;
9154
- if (C) {
9155
- const k = C.selectionStart || 0, j = C.value || "", T = C.selectionEnd || k;
9156
- if (T > k) {
9157
- const O = `{{${S}}}`, { text: P } = N(j, k, O), $ = j.slice(0, k) + P + j.slice(T);
9172
+ }, S = x.current;
9173
+ if (S) {
9174
+ const y = S.selectionStart || 0, j = S.value || "", I = S.selectionEnd || y;
9175
+ if (I > y) {
9176
+ const O = `{{${C}}}`, { text: P } = N(j, y, O), $ = j.slice(0, y) + P + j.slice(I);
9158
9177
  p($);
9159
9178
  return;
9160
9179
  }
9161
- const R = `{{${S}}}`, { text: I } = N(j, k, R), D = j.slice(0, k) + I + j.slice(k);
9180
+ const R = `{{${C}}}`, { text: T } = N(j, y, R), D = j.slice(0, y) + T + j.slice(y);
9162
9181
  p(D);
9163
9182
  }
9164
9183
  }, []);
@@ -9166,8 +9185,8 @@ const AiAssistant = () => {
9166
9185
  /* @__PURE__ */ jsxs(
9167
9186
  "form",
9168
9187
  {
9169
- onSubmit: (S) => {
9170
- S.preventDefault(), u !== null ? w() : b();
9188
+ onSubmit: (C) => {
9189
+ C.preventDefault(), u !== null ? w() : b();
9171
9190
  },
9172
9191
  className: "space-y-3",
9173
9192
  children: [
@@ -9183,7 +9202,7 @@ const AiAssistant = () => {
9183
9202
  id: "attrKey",
9184
9203
  ref: f,
9185
9204
  value: i,
9186
- onChange: (S) => c(S.target.value),
9205
+ onChange: (C) => c(C.target.value),
9187
9206
  placeholder: "Enter Key",
9188
9207
  className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
9189
9208
  }
@@ -9192,7 +9211,7 @@ const AiAssistant = () => {
9192
9211
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9193
9212
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9194
9213
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9195
- !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: _ })
9214
+ !isEmpty(k) && /* @__PURE__ */ jsx(NestedPathSelector, { data: k, onSelect: E })
9196
9215
  ] }),
9197
9216
  /* @__PURE__ */ jsx(
9198
9217
  Textarea,
@@ -9204,8 +9223,8 @@ const AiAssistant = () => {
9204
9223
  rows: 2,
9205
9224
  ref: x,
9206
9225
  value: d,
9207
- onChange: (S) => p(S.target.value),
9208
- onKeyDown: E,
9226
+ onChange: (C) => p(C.target.value),
9227
+ onKeyDown: _,
9209
9228
  placeholder: "Enter Value",
9210
9229
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
9211
9230
  }
@@ -9217,10 +9236,10 @@ const AiAssistant = () => {
9217
9236
  ]
9218
9237
  }
9219
9238
  ),
9220
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, A) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9239
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((C, A) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9221
9240
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9222
- /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
9223
- /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: S.value.toString() })
9241
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: C.key }),
9242
+ /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: C.value.toString() })
9224
9243
  ] }),
9225
9244
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9226
9245
  /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(A), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
@@ -9344,42 +9363,42 @@ const RootLayout = () => {
9344
9363
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9345
9364
  r("outline");
9346
9365
  });
9347
- const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((S) => {
9348
- S.preventDefault();
9366
+ const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((C) => {
9367
+ C.preventDefault();
9349
9368
  }, []), m = useCallback(
9350
- (S) => {
9351
- r(n === S ? null : S);
9369
+ (C) => {
9370
+ r(n === C ? null : C);
9352
9371
  },
9353
9372
  [n]
9354
9373
  ), { t: f } = useTranslation(), x = useMemo(
9355
9374
  () => [...p, ...u, ...g],
9356
9375
  [p, u, g]
9357
- ), y = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: n }) ?? first(x), v = get(b, "width", DEFAULT_PANEL_WIDTH);
9376
+ ), k = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: n }) ?? first(x), v = get(b, "width", DEFAULT_PANEL_WIDTH);
9358
9377
  useEffect(() => {
9359
9378
  if (n !== null) {
9360
- const S = find(x, { id: n });
9361
- S && get(S, "view", "standard") === "standard" && (a.current = n, i(get(S, "width", DEFAULT_PANEL_WIDTH)));
9379
+ const C = find(x, { id: n });
9380
+ C && get(C, "view", "standard") === "standard" && (a.current = n, i(get(C, "width", DEFAULT_PANEL_WIDTH)));
9362
9381
  }
9363
9382
  }, [n, x]);
9364
9383
  const B = useMemo(() => {
9365
9384
  if (n === null) return 0;
9366
- const S = find(x, { id: n });
9367
- return get(S, "view", "standard") === "standard" ? v : l;
9385
+ const C = find(x, { id: n });
9386
+ return get(C, "view", "standard") === "standard" ? v : l;
9368
9387
  }, [n, v, l, x]), w = useCallback(() => {
9369
9388
  r(a.current);
9370
- }, [r]), E = useCallback(() => {
9389
+ }, [r]), _ = useCallback(() => {
9371
9390
  r("outline");
9372
9391
  }, [r]);
9373
9392
  useEffect(() => {
9374
9393
  find(x, { id: n }) || r("outline");
9375
9394
  }, [n, x]);
9376
- const _ = useCallback(
9377
- (S) => {
9378
- m(S);
9395
+ const E = useCallback(
9396
+ (C) => {
9397
+ m(C);
9379
9398
  },
9380
9399
  [m]
9381
9400
  );
9382
- return /* @__PURE__ */ jsx("div", { dir: y, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9401
+ 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: [
9383
9402
  /* @__PURE__ */ jsxs(
9384
9403
  "div",
9385
9404
  {
@@ -9389,24 +9408,24 @@ const RootLayout = () => {
9389
9408
  /* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
9390
9409
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9391
9410
  /* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9392
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((S, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9393
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(S, "button", NoopComponent), {
9411
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((C, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9412
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(C, "button", NoopComponent), {
9394
9413
  position: "top",
9395
- panelId: S.id,
9396
- isActive: n === S.id,
9397
- show: () => _(S.id)
9414
+ panelId: C.id,
9415
+ isActive: n === C.id,
9416
+ show: () => E(C.id)
9398
9417
  }) }),
9399
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(S.label) }) })
9418
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(C.label) }) })
9400
9419
  ] }, "button-top-" + A)) }),
9401
9420
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9402
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((S, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9403
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(S, "button", NoopComponent), {
9421
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((C, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9422
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(C, "button", NoopComponent), {
9404
9423
  position: "bottom",
9405
- panelId: S.id,
9406
- isActive: n === S.id,
9407
- show: () => _(S.id)
9424
+ panelId: C.id,
9425
+ isActive: n === C.id,
9426
+ show: () => E(C.id)
9408
9427
  }) }),
9409
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(S.label) }) })
9428
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(C.label) }) })
9410
9429
  ] }, "button-bottom-" + A)) })
9411
9430
  ] }),
9412
9431
  /* @__PURE__ */ jsx(
@@ -9471,23 +9490,31 @@ const RootLayout = () => {
9471
9490
  }
9472
9491
  ),
9473
9492
  /* @__PURE__ */ jsx(AddBlocksDialog, {}),
9474
- n !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => w(), children: /* @__PURE__ */ jsxs(SheetContent, { side: "left", className: "p-0 sm:max-w-full", style: { width: `${v}px` }, children: [
9475
- /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border p-4 pb-2", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
9476
- /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9477
- /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9478
- ] }) }),
9479
- /* @__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), {
9480
- close: E
9481
- }) }) })
9482
- ] }) }),
9493
+ n !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => w(), children: /* @__PURE__ */ jsxs(
9494
+ SheetContent,
9495
+ {
9496
+ side: "left",
9497
+ className: "flex flex-col gap-0 p-0 sm:max-w-full",
9498
+ style: { width: `${v}px` },
9499
+ children: [
9500
+ /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
9501
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
9502
+ /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9503
+ ] }) }),
9504
+ /* @__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), {
9505
+ close: _
9506
+ }) }) })
9507
+ ]
9508
+ }
9509
+ ) }),
9483
9510
  " ",
9484
- n !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => w(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "p-0", style: { maxWidth: `${v}px` }, children: [
9485
- /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border p-4 pb-2", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
9486
- /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9511
+ n !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => w(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${v}px` }, children: [
9512
+ /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
9513
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
9487
9514
  /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9488
9515
  ] }) }),
9489
9516
  /* @__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), {
9490
- close: E
9517
+ close: _
9491
9518
  }) }) })
9492
9519
  ] }) }),
9493
9520
  n !== null && get(b, "view") === "overlay" && /* @__PURE__ */ jsx(
@@ -9515,7 +9542,7 @@ const RootLayout = () => {
9515
9542
  /* @__PURE__ */ jsx(Button, { onClick: () => w(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
9516
9543
  ] }),
9517
9544
  /* @__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), {
9518
- close: E
9545
+ close: _
9519
9546
  }) }) })
9520
9547
  ]
9521
9548
  }
@@ -9546,18 +9573,35 @@ const RootLayout = () => {
9546
9573
  const l = first(o);
9547
9574
  isString(l) && (a = [l, ...getParentNodeIds(n, l)]), r(a);
9548
9575
  }, [o, n, r]);
9549
- }, ScreenTooSmall = () => /* @__PURE__ */ jsx("section", { className: "h-screen w-screen bg-gray-900 py-12 sm:py-16 lg:py-20 xl:hidden", children: /* @__PURE__ */ jsx("div", { className: "mx-auto max-w-7xl px-4 sm:px-6 lg:px-8", children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-md text-center", children: [
9576
+ }, ScreenTooSmall = () => /* @__PURE__ */ jsx("section", { className: "fixed inset-0 z-50 flex h-screen w-screen items-center justify-center bg-white bg-[linear-gradient(to_right,#f3f4f6_1px,transparent_1px),linear-gradient(to_bottom,#f3f4f6_1px,transparent_1px)] bg-[size:10px_10px] py-12 sm:py-16 lg:py-20 xl:hidden", children: /* @__PURE__ */ jsx("div", { className: "mx-auto max-w-7xl px-4 sm:px-6 lg:px-8", children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-md space-y-6 text-center", children: [
9550
9577
  /* @__PURE__ */ jsx(
9551
9578
  "img",
9552
9579
  {
9553
- src: "https://fldwljgzcktqnysdkxnn.supabase.co/storage/v1/object/public/chaibuilder-blob-storage/175ac8d8-37fe-4707-bb4a-3c0cd6a6db75/gVH7O-Ir_400x400.png",
9580
+ src: "https://ucarecdn.com/fbfc3b05-cb73-4e99-92a2-3a367b7c36cd/",
9554
9581
  alt: "Chai Builder",
9555
- className: "mx-auto w-14 rounded-full"
9582
+ className: "mx-auto h-20 w-20 rounded-full shadow-lg transition-transform duration-300 hover:scale-105"
9556
9583
  }
9557
9584
  ),
9558
- /* @__PURE__ */ jsx("br", {}),
9559
- /* @__PURE__ */ jsx("h2", { className: "text-4xl font-bold", children: "Screen too small" }),
9560
- /* @__PURE__ */ jsx("p", { className: "mt-6 text-sm font-medium leading-6 text-white text-opacity-70", children: "Please view this page on greater than 1280px screen width." })
9585
+ /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
9586
+ /* @__PURE__ */ jsx("h2", { className: "text-5xl font-bold tracking-tight text-gray-900", children: "Screen too small" }),
9587
+ /* @__PURE__ */ jsxs("p", { className: "mx-auto max-w-sm text-sm leading-7 text-gray-600", children: [
9588
+ "Please view this page on greater than ",
9589
+ /* @__PURE__ */ jsx("strong", { className: "font-medium", children: "1280px" }),
9590
+ " screen width for the best experience."
9591
+ ] })
9592
+ ] }),
9593
+ /* @__PURE__ */ jsx("div", { className: "pt-4", children: /* @__PURE__ */ jsxs("div", { className: "inline-flex items-center rounded-full bg-gray-100 px-4 py-2 text-sm text-gray-700", children: [
9594
+ /* @__PURE__ */ jsx("svg", { className: "mr-2 h-5 w-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx(
9595
+ "path",
9596
+ {
9597
+ strokeLinecap: "round",
9598
+ strokeLinejoin: "round",
9599
+ strokeWidth: "2",
9600
+ d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
9601
+ }
9602
+ ) }),
9603
+ "Minimum width: 1280px"
9604
+ ] }) })
9561
9605
  ] }) }) });
9562
9606
  function getFromQueryParams(o) {
9563
9607
  var r;
@@ -9621,66 +9665,66 @@ const FEATURE_TOGGLES = {
9621
9665
  }, ...h) => {
9622
9666
  const m = h[0] || ((A) => {
9623
9667
  let N = o.get(A);
9624
- return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, N), u == null || u(A, S)), N;
9668
+ return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, N), u == null || u(A, C)), N;
9625
9669
  }), f = h[1] || (() => {
9626
9670
  let A, N;
9627
- const C = (k) => {
9671
+ const S = (y) => {
9628
9672
  try {
9629
- k();
9673
+ y();
9630
9674
  } catch (j) {
9631
9675
  A || (A = !0, N = j);
9632
9676
  }
9633
9677
  };
9634
9678
  do {
9635
- c.f && C(c.f);
9636
- const k = /* @__PURE__ */ new Set(), j = k.add.bind(k);
9637
- a.forEach((T) => {
9679
+ c.f && S(c.f);
9680
+ const y = /* @__PURE__ */ new Set(), j = y.add.bind(y);
9681
+ a.forEach((I) => {
9638
9682
  var L;
9639
- return (L = n.get(T)) == null ? void 0 : L.l.forEach(j);
9640
- }), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), k.forEach(C), a.size && x();
9683
+ return (L = n.get(I)) == null ? void 0 : L.l.forEach(j);
9684
+ }), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), y.forEach(S), a.size && x();
9641
9685
  } while (a.size || i.size || l.size);
9642
9686
  if (A)
9643
9687
  throw N;
9644
9688
  }), x = h[2] || (() => {
9645
- const A = [], N = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
9646
- for (; k.length; ) {
9647
- const j = k[k.length - 1], T = m(j);
9648
- if (C.has(j)) {
9649
- k.pop();
9689
+ const A = [], N = /* @__PURE__ */ new WeakSet(), S = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
9690
+ for (; y.length; ) {
9691
+ const j = y[y.length - 1], I = m(j);
9692
+ if (S.has(j)) {
9693
+ y.pop();
9650
9694
  continue;
9651
9695
  }
9652
9696
  if (N.has(j)) {
9653
- r.get(j) === T.n && A.push([j, T]), C.add(j), k.pop();
9697
+ r.get(j) === I.n && A.push([j, I]), S.add(j), y.pop();
9654
9698
  continue;
9655
9699
  }
9656
9700
  N.add(j);
9657
- for (const L of getMountedOrPendingDependents(j, T, n))
9658
- N.has(L) || k.push(L);
9701
+ for (const L of getMountedOrPendingDependents(j, I, n))
9702
+ N.has(L) || y.push(L);
9659
9703
  }
9660
9704
  for (let j = A.length - 1; j >= 0; --j) {
9661
- const [T, L] = A[j];
9705
+ const [I, L] = A[j];
9662
9706
  let R = !1;
9663
- for (const I of L.d.keys())
9664
- if (I !== T && a.has(I)) {
9707
+ for (const T of L.d.keys())
9708
+ if (T !== I && a.has(T)) {
9665
9709
  R = !0;
9666
9710
  break;
9667
9711
  }
9668
- R && (y(T), B(T)), r.delete(T);
9712
+ R && (k(I), B(I)), r.delete(I);
9669
9713
  }
9670
- }), y = h[3] || ((A) => {
9671
- var N, C;
9672
- const k = m(A);
9673
- if (isAtomStateInitialized(k) && (n.has(A) && r.get(A) !== k.n || Array.from(k.d).every(
9714
+ }), k = h[3] || ((A) => {
9715
+ var N, S;
9716
+ const y = m(A);
9717
+ if (isAtomStateInitialized(y) && (n.has(A) && r.get(A) !== y.n || Array.from(y.d).every(
9674
9718
  ([P, $]) => (
9675
9719
  // Recursively, read the atom state of the dependency, and
9676
9720
  // check if the atom epoch number is unchanged
9677
- y(P).n === $
9721
+ k(P).n === $
9678
9722
  )
9679
9723
  )))
9680
- return k;
9681
- k.d.clear();
9724
+ return y;
9725
+ y.d.clear();
9682
9726
  let j = !0;
9683
- const T = () => {
9727
+ const I = () => {
9684
9728
  n.has(A) && (B(A), x(), f());
9685
9729
  }, L = (P) => {
9686
9730
  var $;
@@ -9693,145 +9737,145 @@ const FEATURE_TOGGLES = {
9693
9737
  throw new Error("no atom init");
9694
9738
  return returnAtomValue(U);
9695
9739
  }
9696
- const M = y(P);
9740
+ const M = k(P);
9697
9741
  try {
9698
9742
  return returnAtomValue(M);
9699
9743
  } finally {
9700
- k.d.set(P, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(A, k.v, M), ($ = n.get(P)) == null || $.t.add(A), j || T();
9744
+ y.d.set(P, M.n), isPendingPromise(y.v) && addPendingPromiseToDependency(A, y.v, M), ($ = n.get(P)) == null || $.t.add(A), j || I();
9701
9745
  }
9702
9746
  };
9703
- let R, I;
9747
+ let R, T;
9704
9748
  const D = {
9705
9749
  get signal() {
9706
9750
  return R || (R = new AbortController()), R.signal;
9707
9751
  },
9708
9752
  get setSelf() {
9709
- return !I && isActuallyWritableAtom(A) && (I = (...P) => {
9753
+ return !T && isActuallyWritableAtom(A) && (T = (...P) => {
9710
9754
  if (!j)
9711
9755
  try {
9712
9756
  return v(A, ...P);
9713
9757
  } finally {
9714
9758
  x(), f();
9715
9759
  }
9716
- }), I;
9760
+ }), T;
9717
9761
  }
9718
- }, O = k.n;
9762
+ }, O = y.n;
9719
9763
  try {
9720
9764
  const P = d(A, L, D);
9721
9765
  return setAtomStateValueOrPromise(A, P, m), isPromiseLike$1(P) && ((N = P.onCancel) == null || N.call(P, () => R == null ? void 0 : R.abort()), P.then(
9722
- T,
9723
- T
9724
- )), k;
9766
+ I,
9767
+ I
9768
+ )), y;
9725
9769
  } catch (P) {
9726
- return delete k.v, k.e = P, ++k.n, k;
9770
+ return delete y.v, y.e = P, ++y.n, y;
9727
9771
  } finally {
9728
- j = !1, O !== k.n && r.get(A) === O && (r.set(A, k.n), a.add(A), (C = c.c) == null || C.call(c, A));
9772
+ j = !1, O !== y.n && r.get(A) === O && (r.set(A, y.n), a.add(A), (S = c.c) == null || S.call(c, A));
9729
9773
  }
9730
9774
  }), b = h[4] || ((A) => {
9731
9775
  const N = [A];
9732
9776
  for (; N.length; ) {
9733
- const C = N.pop(), k = m(C);
9734
- for (const j of getMountedOrPendingDependents(C, k, n)) {
9735
- const T = m(j);
9736
- r.set(j, T.n), N.push(j);
9777
+ const S = N.pop(), y = m(S);
9778
+ for (const j of getMountedOrPendingDependents(S, y, n)) {
9779
+ const I = m(j);
9780
+ r.set(j, I.n), N.push(j);
9737
9781
  }
9738
9782
  }
9739
9783
  }), v = h[5] || ((A, ...N) => {
9740
- let C = !0;
9741
- const k = (T) => returnAtomValue(y(T)), j = (T, ...L) => {
9784
+ let S = !0;
9785
+ const y = (I) => returnAtomValue(k(I)), j = (I, ...L) => {
9742
9786
  var R;
9743
- const I = m(T);
9787
+ const T = m(I);
9744
9788
  try {
9745
- if (isSelfAtom(A, T)) {
9746
- if (!hasInitialValue(T))
9789
+ if (isSelfAtom(A, I)) {
9790
+ if (!hasInitialValue(I))
9747
9791
  throw new Error("atom not writable");
9748
- const D = I.n, O = L[0];
9749
- setAtomStateValueOrPromise(T, O, m), B(T), D !== I.n && (a.add(T), (R = c.c) == null || R.call(c, T), b(T));
9792
+ const D = T.n, O = L[0];
9793
+ setAtomStateValueOrPromise(I, O, m), B(I), D !== T.n && (a.add(I), (R = c.c) == null || R.call(c, I), b(I));
9750
9794
  return;
9751
9795
  } else
9752
- return v(T, ...L);
9796
+ return v(I, ...L);
9753
9797
  } finally {
9754
- C || (x(), f());
9798
+ S || (x(), f());
9755
9799
  }
9756
9800
  };
9757
9801
  try {
9758
- return p(A, k, j, ...N);
9802
+ return p(A, y, j, ...N);
9759
9803
  } finally {
9760
- C = !1;
9804
+ S = !1;
9761
9805
  }
9762
9806
  }), B = h[6] || ((A) => {
9763
9807
  var N;
9764
- const C = m(A), k = n.get(A);
9765
- if (k && !isPendingPromise(C.v)) {
9766
- for (const [j, T] of C.d)
9767
- if (!k.d.has(j)) {
9808
+ const S = m(A), y = n.get(A);
9809
+ if (y && !isPendingPromise(S.v)) {
9810
+ for (const [j, I] of S.d)
9811
+ if (!y.d.has(j)) {
9768
9812
  const L = m(j);
9769
- w(j).t.add(A), k.d.add(j), T !== L.n && (a.add(j), (N = c.c) == null || N.call(c, j), b(j));
9813
+ w(j).t.add(A), y.d.add(j), I !== L.n && (a.add(j), (N = c.c) == null || N.call(c, j), b(j));
9770
9814
  }
9771
- for (const j of k.d || [])
9772
- if (!C.d.has(j)) {
9773
- k.d.delete(j);
9774
- const T = E(j);
9775
- T == null || T.t.delete(A);
9815
+ for (const j of y.d || [])
9816
+ if (!S.d.has(j)) {
9817
+ y.d.delete(j);
9818
+ const I = _(j);
9819
+ I == null || I.t.delete(A);
9776
9820
  }
9777
9821
  }
9778
9822
  }), w = h[7] || ((A) => {
9779
9823
  var N;
9780
- const C = m(A);
9781
- let k = n.get(A);
9782
- if (!k) {
9783
- y(A);
9784
- for (const j of C.d.keys())
9824
+ const S = m(A);
9825
+ let y = n.get(A);
9826
+ if (!y) {
9827
+ k(A);
9828
+ for (const j of S.d.keys())
9785
9829
  w(j).t.add(A);
9786
- if (k = {
9830
+ if (y = {
9787
9831
  l: /* @__PURE__ */ new Set(),
9788
- d: new Set(C.d.keys()),
9832
+ d: new Set(S.d.keys()),
9789
9833
  t: /* @__PURE__ */ new Set()
9790
- }, n.set(A, k), (N = c.m) == null || N.call(c, A), isActuallyWritableAtom(A)) {
9834
+ }, n.set(A, y), (N = c.m) == null || N.call(c, A), isActuallyWritableAtom(A)) {
9791
9835
  const j = () => {
9792
- let T = !0;
9836
+ let I = !0;
9793
9837
  const L = (...R) => {
9794
9838
  try {
9795
9839
  return v(A, ...R);
9796
9840
  } finally {
9797
- T || (x(), f());
9841
+ I || (x(), f());
9798
9842
  }
9799
9843
  };
9800
9844
  try {
9801
9845
  const R = g(A, L);
9802
- R && (k.u = () => {
9803
- T = !0;
9846
+ R && (y.u = () => {
9847
+ I = !0;
9804
9848
  try {
9805
9849
  R();
9806
9850
  } finally {
9807
- T = !1;
9851
+ I = !1;
9808
9852
  }
9809
9853
  });
9810
9854
  } finally {
9811
- T = !1;
9855
+ I = !1;
9812
9856
  }
9813
9857
  };
9814
9858
  l.add(j);
9815
9859
  }
9816
9860
  }
9817
- return k;
9818
- }), E = h[8] || ((A) => {
9861
+ return y;
9862
+ }), _ = h[8] || ((A) => {
9819
9863
  var N;
9820
- const C = m(A);
9821
- let k = n.get(A);
9822
- if (k && !k.l.size && !Array.from(k.t).some((j) => {
9823
- var T;
9824
- return (T = n.get(j)) == null ? void 0 : T.d.has(A);
9864
+ const S = m(A);
9865
+ let y = n.get(A);
9866
+ if (y && !y.l.size && !Array.from(y.t).some((j) => {
9867
+ var I;
9868
+ return (I = n.get(j)) == null ? void 0 : I.d.has(A);
9825
9869
  })) {
9826
- k.u && i.add(k.u), k = void 0, n.delete(A), (N = c.u) == null || N.call(c, A);
9827
- for (const j of C.d.keys()) {
9828
- const T = E(j);
9829
- T == null || T.t.delete(A);
9870
+ y.u && i.add(y.u), y = void 0, n.delete(A), (N = c.u) == null || N.call(c, A);
9871
+ for (const j of S.d.keys()) {
9872
+ const I = _(j);
9873
+ I == null || I.t.delete(A);
9830
9874
  }
9831
9875
  return;
9832
9876
  }
9833
- return k;
9834
- }), _ = [
9877
+ return y;
9878
+ }), E = [
9835
9879
  // store state
9836
9880
  o,
9837
9881
  n,
@@ -9849,14 +9893,14 @@ const FEATURE_TOGGLES = {
9849
9893
  m,
9850
9894
  f,
9851
9895
  x,
9852
- y,
9896
+ k,
9853
9897
  b,
9854
9898
  v,
9855
9899
  B,
9856
9900
  w,
9857
- E
9858
- ], S = {
9859
- get: (A) => returnAtomValue(y(A)),
9901
+ _
9902
+ ], C = {
9903
+ get: (A) => returnAtomValue(k(A)),
9860
9904
  set: (A, ...N) => {
9861
9905
  try {
9862
9906
  return v(A, ...N);
@@ -9865,13 +9909,13 @@ const FEATURE_TOGGLES = {
9865
9909
  }
9866
9910
  },
9867
9911
  sub: (A, N) => {
9868
- const k = w(A).l;
9869
- return k.add(N), f(), () => {
9870
- k.delete(N), E(A), f();
9912
+ const y = w(A).l;
9913
+ return y.add(N), f(), () => {
9914
+ y.delete(N), _(A), f();
9871
9915
  };
9872
9916
  }
9873
9917
  };
9874
- return Object.defineProperty(S, BUILDING_BLOCKS, { value: _ }), S;
9918
+ return Object.defineProperty(C, BUILDING_BLOCKS, { value: E }), C;
9875
9919
  }, INTERNAL_buildStoreRev1 = buildStore, createStore = () => INTERNAL_buildStoreRev1();
9876
9920
  let defaultStore;
9877
9921
  const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), defaultStore), StoreContext = createContext(
@@ -10046,6 +10090,7 @@ export {
10046
10090
  useDuplicateBlocks,
10047
10091
  useHiddenBlockIds,
10048
10092
  useHighlightBlockId,
10093
+ useInlineEditing,
10049
10094
  useLanguages,
10050
10095
  useLibraryBlocks,
10051
10096
  useMediaManagerComponent,