@chaibuilder/sdk 2.2.37 → 2.3.1

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
@@ -1,6 +1,6 @@
1
1
  var U = Object.defineProperty;
2
2
  var V = (o, n, r) => n in o ? U(o, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[n] = r;
3
- var H = (o, n, r) => V(o, typeof n != "symbol" ? n + "" : n, r);
3
+ var F = (o, n, r) => V(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, ResetIcon, 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, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
@@ -11,7 +11,7 @@ import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultS
11
11
  import { atomWithStorage, splitAtom, useAtomCallback } from "jotai/utils";
12
12
  import { g as generateUUID, a as getBreakpointValue, c as cn$2 } from "./common-functions-BGzDsf1z.js";
13
13
  import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, b9 as cn$1, aW as Skeleton, d as Alert, e as AlertDescription, at as Input$1, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, av as Popover, b5 as Tooltip, b8 as TooltipTrigger, ay as PopoverTrigger, b6 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, a6 as DialogHeader, a9 as DialogTitle, B as Badge, a as AccordionItem, b as AccordionTrigger, c as AccordionContent, ag as DropdownMenuLabel, ak as DropdownMenuSeparator, ac as DropdownMenuCheckboxItem, aq as HoverCard, as as HoverCardTrigger, ar as HoverCardContent, b2 as Textarea, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, au as Label, z as CardFooter, az as ScrollArea, a_ as Tabs, b0 as TabsList, b1 as TabsTrigger, a$ as TabsContent, g as AlertDialog, q as AlertDialogTrigger, j as AlertDialogContent, m as AlertDialogHeader, p as AlertDialogTitle, k as AlertDialogDescription, l as AlertDialogFooter, i as AlertDialogCancel, h as AlertDialogAction, aZ as Switch, r as Avatar, aL as Separator, b7 as TooltipProvider, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle, aY as Toaster } from "./toggle-BFR6fqvM.js";
14
- import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, File, Database, MoreVertical, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, Eye, ChevronsUpDown, ChevronsDownUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers, Settings as Settings$1 } from "lucide-react";
14
+ import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, File, Database, MoreVertical, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, Eye, ChevronsUpDown, ChevronsDownUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
15
15
  import clsx$1, { clsx } from "clsx";
16
16
  import { twMerge } from "tailwind-merge";
17
17
  import TreeModel from "tree-model";
@@ -38,7 +38,7 @@ import { useFeature } from "flagged";
38
38
  import { parse, stringify } from "himalaya";
39
39
  import { Tree } from "react-arborist";
40
40
  import i18n from "i18next";
41
- import { default as We } from "i18next";
41
+ import { default as ze } from "i18next";
42
42
  import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
43
43
  import tailwindForms from "@tailwindcss/forms";
44
44
  import tailwindTypography from "@tailwindcss/typography";
@@ -283,7 +283,7 @@ import.meta.vitest && describe("canDropBlock Function", () => {
283
283
  });
284
284
  class PubSub {
285
285
  constructor() {
286
- H(this, "subscribers", /* @__PURE__ */ new Map());
286
+ F(this, "subscribers", /* @__PURE__ */ new Map());
287
287
  }
288
288
  subscribe(n, r) {
289
289
  return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
@@ -349,8 +349,8 @@ function insertBlocksAtPosition(o, n, r, a) {
349
349
  }), l.unshift(h), i = i.map((x) => {
350
350
  if (x._id === r) {
351
351
  const f = { ...x, content: "" };
352
- return Object.keys(f).forEach((k) => {
353
- k.startsWith("content-") && (f[k] = "");
352
+ return Object.keys(f).forEach((y) => {
353
+ y.startsWith("content-") && (f[y] = "");
354
354
  }), f;
355
355
  }
356
356
  return x;
@@ -485,8 +485,8 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
485
485
  h && "content" in h && (r = r.map((x) => {
486
486
  if (x._id === u) {
487
487
  const f = { ...x, content: m.content };
488
- return Object.keys(m).forEach((k) => {
489
- k.startsWith("content-") && (f[k] = m[k]);
488
+ return Object.keys(m).forEach((y) => {
489
+ y.startsWith("content-") && (f[y] = m[y]);
490
490
  }), f;
491
491
  }
492
492
  return x;
@@ -799,50 +799,50 @@ const undoRedoStateAtom = atom({
799
799
  updateBlocksProps: c
800
800
  } = useBlocksStoreManager();
801
801
  return {
802
- moveBlocks: (f, k, b) => {
802
+ moveBlocks: (f, y, b) => {
803
803
  const v = map(f, (w) => {
804
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
805
  return { _id: w, oldParent: E, oldPosition: A };
806
806
  }), B = v.find(({ _id: w }) => w === f[0]);
807
- B && B.oldParent === k && B.oldPosition === b || (i(f, k, b), o({
807
+ B && B.oldParent === y && B.oldPosition === b || (i(f, y, b), o({
808
808
  undo: () => each(v, ({ _id: w, oldParent: _, oldPosition: E }) => {
809
809
  i([w], _, E);
810
810
  }),
811
- redo: () => i(f, k, b)
811
+ redo: () => i(f, y, b)
812
812
  }));
813
813
  },
814
- addBlocks: (f, k, b) => {
815
- a(f, k, b), o({
814
+ addBlocks: (f, y, b) => {
815
+ a(f, y, b), o({
816
816
  undo: () => l(map(f, "_id")),
817
- redo: () => a(f, k, b)
817
+ redo: () => a(f, y, b)
818
818
  });
819
819
  },
820
820
  removeBlocks: (f) => {
821
821
  var B;
822
- const k = (B = first(f)) == null ? void 0 : B._parent, v = n.filter((w) => k ? w._parent === k : !w._parent).indexOf(first(f));
822
+ const y = (B = first(f)) == null ? void 0 : B._parent, v = n.filter((w) => y ? w._parent === y : !w._parent).indexOf(first(f));
823
823
  l(map(f, "_id")), o({
824
- undo: () => a(f, k, v),
824
+ undo: () => a(f, y, v),
825
825
  redo: () => l(map(f, "_id"))
826
826
  });
827
827
  },
828
- updateBlocks: (f, k, b) => {
828
+ updateBlocks: (f, y, b) => {
829
829
  let v = [];
830
830
  if (b)
831
831
  v = map(f, (B) => ({ _id: B, ...b }));
832
832
  else {
833
- const B = keys(k);
833
+ const B = keys(y);
834
834
  v = map(f, (w) => {
835
- const _ = n.find((C) => C._id === w), E = { _id: w };
836
- return each(B, (C) => E[C] = _[C]), E;
835
+ const _ = n.find((S) => S._id === w), E = { _id: w };
836
+ return each(B, (S) => E[S] = _[S]), E;
837
837
  });
838
838
  }
839
- c(map(f, (B) => ({ _id: B, ...k }))), o({
839
+ c(map(f, (B) => ({ _id: B, ...y }))), o({
840
840
  undo: () => c(v),
841
- redo: () => c(map(f, (B) => ({ _id: B, ...k })))
841
+ redo: () => c(map(f, (B) => ({ _id: B, ...y })))
842
842
  });
843
843
  },
844
- updateBlocksRuntime: (f, k) => {
845
- c(map(f, (b) => ({ _id: b, ...k })));
844
+ updateBlocksRuntime: (f, y) => {
845
+ c(map(f, (b) => ({ _id: b, ...y })));
846
846
  },
847
847
  setNewBlocks: (f) => {
848
848
  r(f), o({
@@ -851,12 +851,12 @@ const undoRedoStateAtom = atom({
851
851
  });
852
852
  },
853
853
  updateMultipleBlocksProps: (f) => {
854
- let k = [];
855
- k = map(f, (b) => {
854
+ let y = [];
855
+ y = map(f, (b) => {
856
856
  const v = keys(b), B = n.find((_) => _._id === b._id), w = {};
857
857
  return each(v, (_) => w[_] = B[_]), w;
858
858
  }), c(f), o({
859
- undo: () => c(k),
859
+ undo: () => c(y),
860
860
  redo: () => c(f)
861
861
  });
862
862
  }
@@ -868,9 +868,9 @@ const undoRedoStateAtom = atom({
868
868
  for (let x = 0; x < i.length; x++) {
869
869
  const { _id: f } = i[x];
870
870
  i[x]._id = generateUUID();
871
- const k = filter(i, { _parent: f });
872
- for (let b = 0; b < k.length; b++)
873
- k[b]._parent = i[x]._id;
871
+ const y = filter(i, { _parent: f });
872
+ for (let b = 0; b < y.length; b++)
873
+ y[b]._parent = i[x]._id;
874
874
  }
875
875
  const p = first(i);
876
876
  let u, g;
@@ -881,8 +881,8 @@ const undoRedoStateAtom = atom({
881
881
  return { addCoreBlock: useCallback(
882
882
  (i, c, d) => {
883
883
  if (has(i, "blocks")) {
884
- const k = i.blocks;
885
- return a(k, c, d);
884
+ const y = i.blocks;
885
+ return a(y, c, d);
886
886
  }
887
887
  const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
888
888
  _type: i.type,
@@ -2333,20 +2333,20 @@ const getBlockWithChildren = (o, n) => {
2333
2333
  })
2334
2334
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2335
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, m = (h, x) => {
2336
- const f = cloneDeep(x.find((k) => k._id === h));
2337
- for (const k in f) {
2338
- const b = f[k];
2336
+ const f = cloneDeep(x.find((y) => y._id === h));
2337
+ for (const y in f) {
2338
+ const b = f[y];
2339
2339
  if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
2340
2340
  const { baseClasses: v, classes: B } = getSplitChaiClasses(b);
2341
- f[k] = compact(flattenDeep([v, B])).join(" ");
2341
+ f[y] = compact(flattenDeep([v, B])).join(" ");
2342
2342
  } else
2343
- k !== "_id" && delete f[k];
2343
+ y !== "_id" && delete f[y];
2344
2344
  }
2345
2345
  return f;
2346
2346
  };
2347
2347
  return {
2348
2348
  askAi: useCallback(
2349
- async (h, x, f, k) => {
2349
+ async (h, x, f, y) => {
2350
2350
  if (l) {
2351
2351
  n(!0), a(null);
2352
2352
  try {
@@ -2356,19 +2356,19 @@ const getBlockWithChildren = (o, n) => {
2356
2356
  return;
2357
2357
  }
2358
2358
  if (h === "styles") {
2359
- const E = w.map((C) => {
2360
- for (const A in C)
2361
- A !== "_id" && (C[A] = `${STYLES_KEY},${C[A]}`);
2362
- return C;
2359
+ const E = w.map((S) => {
2360
+ for (const A in S)
2361
+ A !== "_id" && (S[A] = `${STYLES_KEY},${S[A]}`);
2362
+ return S;
2363
2363
  });
2364
2364
  c(E);
2365
2365
  } else
2366
2366
  i(w);
2367
- k && k(B);
2367
+ y && y(B);
2368
2368
  } catch (b) {
2369
2369
  a(b);
2370
2370
  } finally {
2371
- n(!1), k && k();
2371
+ n(!1), y && y();
2372
2372
  }
2373
2373
  }
2374
2374
  },
@@ -2465,7 +2465,7 @@ const getBlockWithChildren = (o, n) => {
2465
2465
  for (const x of m)
2466
2466
  if (x._type === "PartialBlock" || x._type === "GlobalBlock") {
2467
2467
  let f = l(x.partialBlockId);
2468
- x._parent && (f == null ? void 0 : f.length) > 0 && (f = f.map((k) => (isEmpty(k._parent) && set(k, "_parent", x._parent), k))), h = [...h, ...f];
2468
+ x._parent && (f == null ? void 0 : f.length) > 0 && (f = f.map((y) => (isEmpty(y._parent) && set(y, "_parent", x._parent), y))), h = [...h, ...f];
2469
2469
  } else
2470
2470
  h.push(x);
2471
2471
  return h;
@@ -2798,8 +2798,8 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2798
2798
  return useHotkeys(
2799
2799
  "shift+up, shift+down, shift+left, shift+right",
2800
2800
  ({ key: f }) => {
2801
- var k;
2802
- x((k = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : k.toUpperCase());
2801
+ var y;
2802
+ x((y = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : y.toUpperCase());
2803
2803
  },
2804
2804
  { document: a == null ? void 0 : a.contentDocument },
2805
2805
  [x]
@@ -2957,13 +2957,13 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
2957
2957
  tabIndex: 0,
2958
2958
  ref: m.setFloating,
2959
2959
  style: g,
2960
- onClick: (k) => {
2961
- k.stopPropagation(), k.preventDefault();
2960
+ onClick: (y) => {
2961
+ y.stopPropagation(), y.preventDefault();
2962
2962
  },
2963
- onMouseEnter: (k) => {
2964
- k.stopPropagation(), i(null);
2963
+ onMouseEnter: (y) => {
2964
+ y.stopPropagation(), i(null);
2965
2965
  },
2966
- onKeyDown: (k) => k.stopPropagation(),
2966
+ onKeyDown: (y) => y.stopPropagation(),
2967
2967
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
2968
2968
  children: [
2969
2969
  x && /* @__PURE__ */ jsx(
@@ -3056,17 +3056,17 @@ class Content extends Component {
3056
3056
  class Frame extends Component {
3057
3057
  constructor(r, a) {
3058
3058
  super(r, a);
3059
- H(this, "setRef", (r) => {
3059
+ F(this, "setRef", (r) => {
3060
3060
  this.nodeRef.current = r;
3061
3061
  const { forwardedRef: a } = this.props;
3062
3062
  typeof a == "function" ? a(r) : a && (a.current = r);
3063
3063
  });
3064
- H(this, "handleLoad", () => {
3064
+ F(this, "handleLoad", () => {
3065
3065
  clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
3066
3066
  });
3067
3067
  // In certain situations on a cold cache DOMContentLoaded never gets called
3068
3068
  // fallback to an interval to check if that's the case
3069
- H(this, "loadCheck", () => setInterval(() => {
3069
+ F(this, "loadCheck", () => setInterval(() => {
3070
3070
  this.handleLoad();
3071
3071
  }, 500));
3072
3072
  this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
@@ -3103,7 +3103,7 @@ class Frame extends Component {
3103
3103
  return delete r.head, delete r.initialContent, delete r.mountTarget, delete r.contentDidMount, delete r.contentDidUpdate, delete r.forwardedRef, /* @__PURE__ */ jsx("iframe", { ...r, ref: this.setRef, onLoad: this.handleLoad, children: this.state.iframeLoaded && this.renderFrameContents() });
3104
3104
  }
3105
3105
  }
3106
- H(Frame, "defaultProps", {
3106
+ F(Frame, "defaultProps", {
3107
3107
  style: {},
3108
3108
  head: null,
3109
3109
  children: void 0,
@@ -3427,8 +3427,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3427
3427
  ],
3428
3428
  onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
3429
3429
  onBlur: ({ editor: u, event: g }) => {
3430
- const m = g.relatedTarget, h = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = h == null ? void 0 : h.contains(m), k = x == null ? void 0 : x.contains(m);
3431
- if (!f && !k) {
3430
+ const m = g.relatedTarget, h = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = h == null ? void 0 : h.contains(m), y = x == null ? void 0 : x.contains(m);
3431
+ if (!f && !y) {
3432
3432
  const b = (u == null ? void 0 : u.getHTML()) || "";
3433
3433
  r(b);
3434
3434
  }
@@ -3524,16 +3524,16 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3524
3524
  }
3525
3525
  ), WithBlockTextEditor = memo(
3526
3526
  ({ block: o, children: n }) => {
3527
- const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: x } = useLanguages(), [, f] = useSelectedBlockIds(), k = useRef(null), b = l, { blockContent: v, blockType: B } = useMemo(() => {
3527
+ const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: x } = useLanguages(), [, f] = useSelectedBlockIds(), y = useRef(null), b = l, { blockContent: v, blockType: B } = useMemo(() => {
3528
3528
  var j;
3529
3529
  const A = o._type;
3530
3530
  let N = o[r];
3531
- const S = getRegisteredChaiBlock(o._type);
3532
- return x && ((j = S == null ? void 0 : S.i18nProps) == null ? void 0 : j.includes(r)) && has(o, `${r}-${x}`) && (N = get(o, `${r}-${x}`)), { blockContent: N, blockType: A };
3531
+ const C = getRegisteredChaiBlock(o._type);
3532
+ return x && ((j = C == null ? void 0 : C.i18nProps) == null ? void 0 : j.includes(r)) && has(o, `${r}-${x}`) && (N = get(o, `${r}-${x}`)), { blockContent: N, blockType: A };
3533
3533
  }, [o, x]), w = useCallback(
3534
3534
  (A) => {
3535
- var S;
3536
- const N = A || ((S = g.current) == null ? void 0 : S.innerText);
3535
+ var C;
3536
+ const N = A || ((C = g.current) == null ? void 0 : C.innerText);
3537
3537
  h([b], { [r]: N }), u(null), c(null), d(-1), f([]);
3538
3538
  },
3539
3539
  [b, h, c, f, x]
@@ -3545,20 +3545,20 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3545
3545
  1e3
3546
3546
  ), E = useCallback(
3547
3547
  (A) => {
3548
- A.preventDefault(), b && (k.current = b), w(), setTimeout(() => {
3549
- const N = k.current;
3550
- k.current = null, f([N]);
3548
+ A.preventDefault(), b && (y.current = b), w(), setTimeout(() => {
3549
+ const N = y.current;
3550
+ y.current = null, f([N]);
3551
3551
  }, 100);
3552
3552
  },
3553
3553
  [f, b, x]
3554
3554
  );
3555
3555
  useEffect(() => {
3556
- var y;
3556
+ var k;
3557
3557
  if (!b) return;
3558
- const A = `[data-block-id="${b}"]`, N = i >= 0 ? `[data-block-index="${i}"]` : "", S = a.querySelector(`${A}${N}`);
3559
- S && ((y = S == null ? void 0 : S.classList) == null || y.add("sr-only"), u(S));
3558
+ const A = `[data-block-id="${b}"]`, N = i >= 0 ? `[data-block-index="${i}"]` : "", C = a.querySelector(`${A}${N}`);
3559
+ C && ((k = C == null ? void 0 : C.classList) == null || k.add("sr-only"), u(C));
3560
3560
  }, [b, B, a, i]);
3561
- const C = useMemo(() => p ? (m(), B === "RichText" ? /* @__PURE__ */ jsx(
3561
+ const S = useMemo(() => p ? (m(), B === "RichText" ? /* @__PURE__ */ jsx(
3562
3562
  RichTextEditor,
3563
3563
  {
3564
3564
  blockContent: v,
@@ -3579,7 +3579,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3579
3579
  }
3580
3580
  )) : null, [p, b, B, v, w, x]);
3581
3581
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3582
- C,
3582
+ S,
3583
3583
  n
3584
3584
  ] });
3585
3585
  },
@@ -3612,12 +3612,12 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3612
3612
  blockAtom: n,
3613
3613
  children: r
3614
3614
  }) => {
3615
- 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(), [m] = useHiddenBlockIds(), [h] = useAtom$1(dataBindingActiveAtom), x = get(c, "component", null), { index: f, key: k } = useContext(RepeaterContext), b = useMemo(
3615
+ 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(), [m] = useHiddenBlockIds(), [h] = useAtom$1(dataBindingActiveAtom), x = get(c, "component", null), { index: f, key: y } = useContext(RepeaterContext), b = useMemo(
3616
3616
  () => h ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
3617
3617
  index: f,
3618
- key: k
3618
+ key: y
3619
3619
  }) : applyLanguage(i, d, c),
3620
- [i, d, c, g, h, f, k]
3620
+ [i, d, c, g, h, f, y]
3621
3621
  ), v = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), B = useMemo(
3622
3622
  () => u(i._id, getBlockRuntimeProps(i._type)),
3623
3623
  [i._id, i._type, u, getBlockRuntimeProps]
@@ -3656,8 +3656,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3656
3656
  ...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
3657
3657
  })
3658
3658
  }) });
3659
- const C = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: E }) : E;
3660
- return _ ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: C }) : C;
3659
+ const S = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: E }) : E;
3660
+ return _ ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: S }) : S;
3661
3661
  }, PartialWrapper = ({ children: o, partialBlockId: n }) => {
3662
3662
  const r = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
3663
3663
  (d) => {
@@ -3697,7 +3697,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3697
3697
  );
3698
3698
  return map(l, (c) => {
3699
3699
  const d = a(c._id);
3700
- return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: m, repeaterItems: h, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(h) && h.map((f, k) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: k, key: x }, 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: m }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3700
+ return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: m, repeaterItems: h, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(h) && h.map((f, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, 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: m }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3701
3701
  });
3702
3702
  }, PageBlocksRenderer = () => {
3703
3703
  const [o] = useBlocksStore();
@@ -4116,17 +4116,17 @@ const DataBindingSelector = ({
4116
4116
  }
4117
4117
  const h = (b) => /[.,!?;:]/.test(b), x = (b, v, B) => {
4118
4118
  let w = "", _ = "";
4119
- const E = v > 0 ? b[v - 1] : "", C = v < b.length ? b[v] : "";
4120
- return v > 0 && (E === "." || !h(E) && E !== " ") && (w = " "), v < b.length && !h(C) && C !== " " && (_ = " "), {
4119
+ const E = v > 0 ? b[v - 1] : "", S = v < b.length ? b[v] : "";
4120
+ return v > 0 && (E === "." || !h(E) && E !== " ") && (w = " "), v < b.length && !h(S) && S !== " " && (_ = " "), {
4121
4121
  text: w + B + _,
4122
4122
  prefixLength: w.length,
4123
4123
  suffixLength: _.length
4124
4124
  };
4125
4125
  }, f = document.getElementById(r);
4126
4126
  if (!f) return;
4127
- const k = document.getElementById(`chai-rte-${r}`) || document.getElementById(`chai-rte-modal-${r}`);
4128
- if (k && (k.querySelector(".ProseMirror") || k.__chaiRTE)) {
4129
- const b = k.__chaiRTE;
4127
+ const y = document.getElementById(`chai-rte-${r}`) || document.getElementById(`chai-rte-modal-${r}`);
4128
+ if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
4129
+ const b = y.__chaiRTE;
4130
4130
  if (b) {
4131
4131
  const v = `{{${g}}}`;
4132
4132
  b.commands.focus();
@@ -4134,11 +4134,11 @@ const DataBindingSelector = ({
4134
4134
  if (B !== w)
4135
4135
  b.chain().deleteSelection().insertContent(v).run();
4136
4136
  else {
4137
- 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));
4138
- let S = "";
4139
- C > 0 && A !== " " && !h(A) && (S = " ");
4140
- let y = "";
4141
- N && N !== " " && !h(N) && (y = " "), b.chain().insertContent(S + v + y).run();
4137
+ const { state: E } = b, S = E.selection.from, A = E.doc.textBetween(Math.max(0, S - 1), S), N = E.doc.textBetween(S, Math.min(S + 1, E.doc.content.size));
4138
+ let C = "";
4139
+ S > 0 && A !== " " && !h(A) && (C = " ");
4140
+ let k = "";
4141
+ N && N !== " " && !h(N) && (k = " "), b.chain().insertContent(C + v + k).run();
4142
4142
  }
4143
4143
  setTimeout(() => n(b.getHTML(), {}, r), 100);
4144
4144
  return;
@@ -4146,11 +4146,11 @@ const DataBindingSelector = ({
4146
4146
  } else {
4147
4147
  const b = f, v = b.selectionStart || 0, B = b.value || "", w = b.selectionEnd || v;
4148
4148
  if (w > v) {
4149
- const N = `{{${g}}}`, { text: S } = x(B, v, N), y = B.slice(0, v) + S + B.slice(w);
4150
- n(y, {}, r);
4149
+ const N = `{{${g}}}`, { text: C } = x(B, v, N), k = B.slice(0, v) + C + B.slice(w);
4150
+ n(k, {}, r);
4151
4151
  return;
4152
4152
  }
4153
- const E = `{{${g}}}`, { text: C } = x(B, v, E), A = B.slice(0, v) + C + B.slice(v);
4153
+ const E = `{{${g}}}`, { text: S } = x(B, v, E), A = B.slice(0, v) + S + B.slice(v);
4154
4154
  n(A, {}, r);
4155
4155
  }
4156
4156
  },
@@ -4173,73 +4173,73 @@ const DataBindingSelector = ({
4173
4173
  onChange: r
4174
4174
  }) => {
4175
4175
  var N;
4176
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (S, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [x, f] = 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;
4176
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [x, f] = 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;
4177
4177
  useEffect(() => {
4178
4178
  if (h(""), f([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4179
- const S = split(o, ":"), y = get(S, 1, "page") || "page";
4180
- g(y), (async () => {
4181
- const j = await l(y, [get(S, 2, "page")]);
4179
+ const C = split(o, ":"), k = get(C, 1, "page") || "page";
4180
+ g(k), (async () => {
4181
+ const j = await l(k, [get(C, 2, "page")]);
4182
4182
  j && Array.isArray(j) && h(get(j, [0, "name"], ""));
4183
4183
  })();
4184
4184
  }, [o]);
4185
4185
  const w = useDebouncedCallback(
4186
- async (S) => {
4187
- if (isEmpty(S))
4186
+ async (C) => {
4187
+ if (isEmpty(C))
4188
4188
  f([]);
4189
4189
  else {
4190
- const y = await l(u, S);
4191
- f(y);
4190
+ const k = await l(u, C);
4191
+ f(k);
4192
4192
  }
4193
4193
  c(!1), b(-1);
4194
4194
  },
4195
4195
  [u],
4196
4196
  300
4197
- ), _ = (S) => {
4198
- const y = ["pageType", u, S.id];
4199
- y[1] && (r(y.join(":")), h(S.name), p(!1), f([]), b(-1));
4200
- }, E = (S) => {
4201
- switch (S.key) {
4197
+ ), _ = (C) => {
4198
+ const k = ["pageType", u, C.id];
4199
+ k[1] && (r(k.join(":")), h(C.name), p(!1), f([]), b(-1));
4200
+ }, E = (C) => {
4201
+ switch (C.key) {
4202
4202
  case "ArrowDown":
4203
- S.preventDefault(), b((y) => y < x.length - 1 ? y + 1 : y);
4203
+ C.preventDefault(), b((k) => k < x.length - 1 ? k + 1 : k);
4204
4204
  break;
4205
4205
  case "ArrowUp":
4206
- S.preventDefault(), b((y) => y > 0 ? y - 1 : y);
4206
+ C.preventDefault(), b((k) => k > 0 ? k - 1 : k);
4207
4207
  break;
4208
4208
  case "Enter":
4209
- if (S.preventDefault(), x.length === 0) return;
4210
- k >= 0 && _(x[k]);
4209
+ if (C.preventDefault(), x.length === 0) return;
4210
+ y >= 0 && _(x[y]);
4211
4211
  break;
4212
4212
  case "Escape":
4213
- S.preventDefault(), C();
4213
+ C.preventDefault(), S();
4214
4214
  break;
4215
4215
  }
4216
4216
  };
4217
4217
  useEffect(() => {
4218
- if (k >= 0 && v.current) {
4219
- const S = v.current.children[k];
4220
- S == null || S.scrollIntoView({ block: "nearest" });
4218
+ if (y >= 0 && v.current) {
4219
+ const C = v.current.children[y];
4220
+ C == null || C.scrollIntoView({ block: "nearest" });
4221
4221
  }
4222
- }, [k]);
4223
- const C = () => {
4222
+ }, [y]);
4223
+ const S = () => {
4224
4224
  h(""), f([]), b(-1), p(!1), r("");
4225
- }, A = (S) => {
4226
- h(S), p(!isEmpty(S)), c(!0), w(S);
4225
+ }, A = (C) => {
4226
+ h(C), p(!isEmpty(C)), c(!0), w(C);
4227
4227
  };
4228
4228
  return /* @__PURE__ */ jsxs("div", { children: [
4229
- /* @__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)) }),
4229
+ /* @__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)) }),
4230
4230
  u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
4231
4231
  /* @__PURE__ */ jsx(
4232
4232
  "input",
4233
4233
  {
4234
4234
  type: "text",
4235
4235
  value: m,
4236
- onChange: (S) => A(S.target.value),
4236
+ onChange: (C) => A(C.target.value),
4237
4237
  onKeyDown: E,
4238
4238
  placeholder: a(`Search ${B ?? ""}`),
4239
4239
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4240
4240
  }
4241
4241
  ),
4242
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__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" }) }) })
4242
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__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" }) }) })
4243
4243
  ] }),
4244
4244
  (i || !isEmpty(x) || d && isEmpty(x)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
4245
4245
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -4249,22 +4249,22 @@ const DataBindingSelector = ({
4249
4249
  ' "',
4250
4250
  m,
4251
4251
  '"'
4252
- ] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(x == null ? void 0 : x.slice(0, 20), (S, y) => /* @__PURE__ */ jsxs(
4252
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(x == null ? void 0 : x.slice(0, 20), (C, k) => /* @__PURE__ */ jsxs(
4253
4253
  "li",
4254
4254
  {
4255
- onClick: () => _(S),
4256
- 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"}`,
4255
+ onClick: () => _(C),
4256
+ 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"}`,
4257
4257
  children: [
4258
- S.name,
4258
+ C.name,
4259
4259
  " ",
4260
- S.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4260
+ C.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4261
4261
  "( ",
4262
- S.slug,
4262
+ C.slug,
4263
4263
  " )"
4264
4264
  ] })
4265
4265
  ]
4266
4266
  },
4267
- S.id
4267
+ C.id
4268
4268
  )) }) })
4269
4269
  ] });
4270
4270
  }, LinkField = ({ schema: o, formData: n, onChange: r, name: a }) => {
@@ -4666,14 +4666,14 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4666
4666
  const m = () => {
4667
4667
  const f = findIndex(u, { _id: g });
4668
4668
  if (f > -1) {
4669
- const k = (f + 1) % u.length, b = get(u, [k, "_id"]);
4669
+ const y = (f + 1) % u.length, b = get(u, [y, "_id"]);
4670
4670
  if (!b) return;
4671
4671
  n({ ...o, currentSlide: b }), c([b]);
4672
4672
  }
4673
4673
  }, h = () => {
4674
4674
  const f = findIndex(u, { _id: g });
4675
4675
  if (f > -1) {
4676
- const k = (f - 1 + u.length) % u.length, b = get(u, [k, "_id"]);
4676
+ const y = (f - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
4677
4677
  if (!b) return;
4678
4678
  n({ ...o, currentSlide: b }), c([b]);
4679
4679
  }
@@ -4681,8 +4681,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4681
4681
  const f = i(
4682
4682
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4683
4683
  p == null ? void 0 : p._id
4684
- ), k = f == null ? void 0 : f._id;
4685
- k && (n({ ...o, currentSlide: k }), c([k]));
4684
+ ), y = f == null ? void 0 : f._id;
4685
+ y && (n({ ...o, currentSlide: y }), c([y]));
4686
4686
  };
4687
4687
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4688
4688
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
@@ -4761,8 +4761,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4761
4761
  className: "text-xs",
4762
4762
  pattern: "[0-9]*",
4763
4763
  onChange: (f) => {
4764
- let k = f.target.value;
4765
- k.length && (k = k.replace("-", "")), n({ ...o, autoplayInterval: k });
4764
+ let y = f.target.value;
4765
+ y.length && (y = y.replace("-", "")), n({ ...o, autoplayInterval: y });
4766
4766
  }
4767
4767
  }
4768
4768
  )
@@ -4870,28 +4870,28 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4870
4870
  formData: g,
4871
4871
  onChange: m
4872
4872
  }) => {
4873
- const { selectedLang: h, fallbackLang: x, languages: f } = useLanguages(), k = useMemo(
4873
+ const { selectedLang: h, fallbackLang: x, languages: f } = useLanguages(), y = useMemo(
4874
4874
  () => isEmpty(f) ? "" : isEmpty(h) ? x : h,
4875
4875
  [f, h, x]
4876
- ), b = useMemo(() => get(LANGUAGES, k, k), [k]), v = usePageExternalData(), B = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = useMemo(
4876
+ ), b = useMemo(() => get(LANGUAGES, y, y), [y]), v = usePageExternalData(), B = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = useMemo(
4877
4877
  () => get(w, [B == null ? void 0 : B._type, "i18nProps"], []),
4878
4878
  [w, B == null ? void 0 : B._type]
4879
- ), [E, C] = useState(null);
4879
+ ), [E, S] = useState(null);
4880
4880
  if (d)
4881
4881
  return null;
4882
4882
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
4883
4883
  const N = _ == null ? void 0 : _.includes(o.replace("root.", ""));
4884
4884
  if (u.type === "array") {
4885
- const S = E === o;
4885
+ const C = E === o;
4886
4886
  return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
4887
4887
  u.title && /* @__PURE__ */ jsxs(
4888
4888
  "label",
4889
4889
  {
4890
4890
  htmlFor: o,
4891
- onClick: () => C(S ? null : o),
4891
+ onClick: () => S(C ? null : o),
4892
4892
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
4893
4893
  children: [
4894
- S ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
4894
+ C ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
4895
4895
  /* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
4896
4896
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: r }),
4897
4897
  " ",
@@ -4899,7 +4899,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4899
4899
  ]
4900
4900
  }
4901
4901
  ),
4902
- (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: [
4902
+ (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: [
4903
4903
  c,
4904
4904
  a,
4905
4905
  l,
@@ -4922,8 +4922,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4922
4922
  DataBindingSelector,
4923
4923
  {
4924
4924
  schema: u,
4925
- onChange: (S) => {
4926
- m(S, g, o);
4925
+ onChange: (C) => {
4926
+ m(C, g, o);
4927
4927
  },
4928
4928
  id: o,
4929
4929
  formData: g
@@ -5027,36 +5027,36 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5027
5027
  }), a;
5028
5028
  };
5029
5029
  function BlockSettings() {
5030
- 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(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), x = ({ formData: E }, C, A) => {
5031
- C && (c == null ? void 0 : c._id) === n._id && a([n._id], { [C]: get(E, C) }, A);
5030
+ 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(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), x = ({ formData: E }, S, A) => {
5031
+ S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(E, S) }, A);
5032
5032
  }, f = useCallback(
5033
- debounce(({ formData: E }, C, A) => {
5034
- x({ formData: E }, C, A), d(E);
5033
+ debounce(({ formData: E }, S, A) => {
5034
+ x({ formData: E }, S, A), d(E);
5035
5035
  }, 1500),
5036
5036
  [n == null ? void 0 : n._id, o]
5037
- ), k = ({ formData: E }, C) => {
5038
- C && (r([n._id], { [C]: get(E, C) }), f({ formData: E }, C, { [C]: get(c, C) }));
5039
- }, b = ({ formData: E }, C) => {
5040
- C && (r([g._id], { [C]: get(E, C) }), f({ formData: E }, C, { [C]: get(c, C) }));
5037
+ ), y = ({ formData: E }, S) => {
5038
+ S && (r([n._id], { [S]: get(E, S) }), f({ formData: E }, S, { [S]: get(c, S) }));
5039
+ }, b = ({ formData: E }, S) => {
5040
+ S && (r([g._id], { [S]: get(E, S) }), f({ formData: E }, S, { [S]: get(c, S) }));
5041
5041
  }, { schema: v, uiSchema: B } = useMemo(() => {
5042
5042
  const E = n == null ? void 0 : n._type;
5043
5043
  if (!E)
5044
5044
  return { schema: {}, uiSchema: {} };
5045
5045
  try {
5046
- const { schema: C, uiSchema: A } = getBlockFormSchemas(E);
5046
+ const { schema: S, uiSchema: A } = getBlockFormSchemas(E);
5047
5047
  if (E === "Repeater") {
5048
5048
  const N = get(n, "repeaterItems", "");
5049
5049
  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" }));
5050
5050
  }
5051
- return { schema: C, uiSchema: A };
5051
+ return { schema: S, uiSchema: A };
5052
5052
  } catch {
5053
5053
  return { schema: {}, uiSchema: {} };
5054
5054
  }
5055
5055
  }, [n]), { wrapperSchema: w, wrapperUiSchema: _ } = useMemo(() => {
5056
5056
  if (!g || !(g != null && g._type))
5057
5057
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5058
- const E = g == null ? void 0 : g._type, { schema: C = {}, uiSchema: A = {} } = getBlockFormSchemas(E);
5059
- return { wrapperSchema: C, wrapperUiSchema: A };
5058
+ const E = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: A = {} } = getBlockFormSchemas(E);
5059
+ return { wrapperSchema: S, wrapperUiSchema: A };
5060
5060
  }, [g]);
5061
5061
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5062
5062
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
@@ -5093,7 +5093,7 @@ function BlockSettings() {
5093
5093
  JSONForm,
5094
5094
  {
5095
5095
  blockId: n == null ? void 0 : n._id,
5096
- onChange: k,
5096
+ onChange: y,
5097
5097
  formData: i,
5098
5098
  schema: v,
5099
5099
  uiSchema: B
@@ -5300,47 +5300,47 @@ const BlockStylingProps = () => {
5300
5300
  },
5301
5301
  a
5302
5302
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5303
- const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [k, b] = useState(""), [v, B] = useState(!1), [w, _] = useState(!1);
5303
+ const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [y, b] = useState(""), [v, B] = useState(!1), [w, _] = useState(!1);
5304
5304
  useEffect(() => {
5305
- const { value: S, unit: y } = getClassValueAndUnit(i);
5306
- if (y === "") {
5307
- l(S), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5305
+ const { value: C, unit: k } = getClassValueAndUnit(i);
5306
+ if (k === "") {
5307
+ l(C), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5308
5308
  return;
5309
5309
  }
5310
- h(y), l(y === "class" || isEmpty(S) ? "" : S);
5310
+ h(k), l(k === "class" || isEmpty(C) ? "" : C);
5311
5311
  }, [i, p, u]);
5312
- const E = useThrottledCallback((S) => c(S), [c], THROTTLE_TIME), C = useThrottledCallback((S) => c(S, !1), [c], THROTTLE_TIME), A = useCallback(
5313
- (S = !1) => {
5314
- const y = getUserInputValues(`${a}`, u);
5315
- if (get(y, "error", !1)) {
5312
+ const E = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), S = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), A = useCallback(
5313
+ (C = !1) => {
5314
+ const k = getUserInputValues(`${a}`, u);
5315
+ if (get(k, "error", !1)) {
5316
5316
  f(!0);
5317
5317
  return;
5318
5318
  }
5319
- const j = get(y, "unit") !== "" ? get(y, "unit") : m;
5319
+ const j = get(k, "unit") !== "" ? get(k, "unit") : m;
5320
5320
  if (j === "auto" || j === "none") {
5321
5321
  E(`${d}${j}`);
5322
5322
  return;
5323
5323
  }
5324
- if (get(y, "value") === "")
5324
+ if (get(k, "value") === "")
5325
5325
  return;
5326
- const L = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5327
- S ? C(L) : E(L);
5326
+ const L = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5327
+ C ? S(L) : E(L);
5328
5328
  },
5329
- [E, C, a, m, d, u]
5329
+ [E, S, a, m, d, u]
5330
5330
  ), N = useCallback(
5331
- (S) => {
5332
- const y = getUserInputValues(`${a}`, u);
5333
- if (get(y, "error", !1)) {
5331
+ (C) => {
5332
+ const k = getUserInputValues(`${a}`, u);
5333
+ if (get(k, "error", !1)) {
5334
5334
  f(!0);
5335
5335
  return;
5336
5336
  }
5337
- if (S === "auto" || S === "none") {
5338
- E(`${d}${S}`);
5337
+ if (C === "auto" || C === "none") {
5338
+ E(`${d}${C}`);
5339
5339
  return;
5340
5340
  }
5341
- if (get(y, "value") === "")
5341
+ if (get(k, "value") === "")
5342
5342
  return;
5343
- const j = get(y, "unit") !== "" ? get(y, "unit") : S, L = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5343
+ const j = get(k, "unit") !== "" ? get(k, "unit") : C, L = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5344
5344
  E(L);
5345
5345
  },
5346
5346
  [E, a, d, u]
@@ -5364,31 +5364,31 @@ const BlockStylingProps = () => {
5364
5364
  "input",
5365
5365
  {
5366
5366
  readOnly: m === "class",
5367
- onKeyPress: (S) => {
5368
- S.key === "Enter" && A();
5367
+ onKeyPress: (C) => {
5368
+ C.key === "Enter" && A();
5369
5369
  },
5370
- onKeyDown: (S) => {
5371
- if (S.keyCode !== 38 && S.keyCode !== 40)
5370
+ onKeyDown: (C) => {
5371
+ if (C.keyCode !== 38 && C.keyCode !== 40)
5372
5372
  return;
5373
- S.preventDefault(), _(!0);
5374
- const y = parseInt$1(S.target.value);
5375
- let j = isNaN$1(y) ? 0 : y;
5376
- S.keyCode === 38 && (j += 1), S.keyCode === 40 && (j -= 1);
5373
+ C.preventDefault(), _(!0);
5374
+ const k = parseInt$1(C.target.value);
5375
+ let j = isNaN$1(k) ? 0 : k;
5376
+ C.keyCode === 38 && (j += 1), C.keyCode === 40 && (j -= 1);
5377
5377
  const I = `${j}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${m === "-" ? "" : m}]`;
5378
- C(R);
5378
+ S(R);
5379
5379
  },
5380
- onKeyUp: (S) => {
5381
- w && (S.preventDefault(), _(!1));
5380
+ onKeyUp: (C) => {
5381
+ w && (C.preventDefault(), _(!1));
5382
5382
  },
5383
5383
  onBlur: () => A(),
5384
- onChange: (S) => {
5385
- f(!1), l(S.target.value);
5384
+ onChange: (C) => {
5385
+ f(!1), l(C.target.value);
5386
5386
  },
5387
- onClick: (S) => {
5388
- var y;
5389
- (y = S == null ? void 0 : S.target) == null || y.select(), r(!1);
5387
+ onClick: (C) => {
5388
+ var k;
5389
+ (k = C == null ? void 0 : C.target) == null || k.select(), r(!1);
5390
5390
  },
5391
- value: v ? k : a,
5391
+ value: v ? y : a,
5392
5392
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
5393
5393
  " ",
5394
5394
  x ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -5413,8 +5413,8 @@ const BlockStylingProps = () => {
5413
5413
  {
5414
5414
  units: u,
5415
5415
  current: m,
5416
- onSelect: (S) => {
5417
- r(!1), h(S), N(S);
5416
+ onSelect: (C) => {
5417
+ r(!1), h(C), N(C);
5418
5418
  }
5419
5419
  }
5420
5420
  ) })
@@ -5424,18 +5424,18 @@ const BlockStylingProps = () => {
5424
5424
  DragStyleButton,
5425
5425
  {
5426
5426
  onDragStart: () => B(!0),
5427
- onDragEnd: (S) => {
5428
- if (b(() => ""), B(!1), isEmpty(S))
5427
+ onDragEnd: (C) => {
5428
+ if (b(() => ""), B(!1), isEmpty(C))
5429
5429
  return;
5430
- const y = `${S}`, I = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
5430
+ const k = `${C}`, I = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
5431
5431
  E(I);
5432
5432
  },
5433
- onDrag: (S) => {
5434
- if (isEmpty(S))
5433
+ onDrag: (C) => {
5434
+ if (isEmpty(C))
5435
5435
  return;
5436
- b(S);
5437
- const y = `${S}`, I = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
5438
- C(I);
5436
+ b(C);
5437
+ const k = `${C}`, I = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
5438
+ S(I);
5439
5439
  },
5440
5440
  currentValue: a,
5441
5441
  unit: m,
@@ -5500,8 +5500,8 @@ const COLOR_PROP = {
5500
5500
  }, ColorChoice = ({ property: o, onChange: n }) => {
5501
5501
  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", ""), m = get(u, "2", ""), h = useCallback(
5502
5502
  // eslint-disable-next-line no-shadow
5503
- (k) => {
5504
- ["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" })));
5503
+ (y) => {
5504
+ ["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" })));
5505
5505
  },
5506
5506
  [c, p]
5507
5507
  );
@@ -5512,8 +5512,8 @@ const COLOR_PROP = {
5512
5512
  }, [g]);
5513
5513
  const x = useCallback(
5514
5514
  // eslint-disable-next-line no-shadow
5515
- (k) => {
5516
- p({ color: g, shade: k });
5515
+ (y) => {
5516
+ p({ color: g, shade: y });
5517
5517
  },
5518
5518
  [g]
5519
5519
  );
@@ -5898,22 +5898,22 @@ const COLOR_PROP = {
5898
5898
  "2xl": "1536px"
5899
5899
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
5900
5900
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
5901
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), k = useMemo(() => get(m, "fullCls", ""), [m]), b = useCallback(
5902
- (C, A = !0) => {
5903
- const N = { dark: p, mq: g, mod: u, cls: C, property: l, fullCls: "" };
5901
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), y = useMemo(() => get(m, "fullCls", ""), [m]), b = useCallback(
5902
+ (S, A = !0) => {
5903
+ const N = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
5904
5904
  (p || u !== "") && (N.mq = "xs");
5905
- const S = generateFullClsName(N);
5906
- h(f, [S], A);
5905
+ const C = generateFullClsName(N);
5906
+ h(f, [C], A);
5907
5907
  },
5908
5908
  [f, p, g, u, l, h]
5909
5909
  ), v = useCallback(() => {
5910
- x(f, [k], !0);
5911
- }, [f, k, x]), B = useMemo(() => canChangeClass(m, g), [m, g]);
5910
+ x(f, [y], !0);
5911
+ }, [f, y, x]), B = useMemo(() => canChangeClass(m, g), [m, g]);
5912
5912
  useEffect(() => {
5913
5913
  i(B, m);
5914
5914
  }, [B, i, m]);
5915
5915
  const [, , w] = useScreenSizeWidth(), _ = useCallback(
5916
- (C) => {
5916
+ (S) => {
5917
5917
  w({
5918
5918
  xs: 400,
5919
5919
  sm: 640,
@@ -5921,7 +5921,7 @@ const COLOR_PROP = {
5921
5921
  lg: 1024,
5922
5922
  xl: 1420,
5923
5923
  "2xl": 1920
5924
- }[C]);
5924
+ }[S]);
5925
5925
  },
5926
5926
  [w]
5927
5927
  ), E = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
@@ -5945,7 +5945,7 @@ const COLOR_PROP = {
5945
5945
  r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
5946
5946
  r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
5947
5947
  ] }),
5948
- /* @__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 && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5948
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "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 && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5949
5949
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5950
5950
  "button",
5951
5951
  {
@@ -6169,7 +6169,7 @@ const COLOR_PROP = {
6169
6169
  u.includes(b) ? u.length > 2 && g(u.filter((v) => v !== b)) : g((v) => [...v, b]);
6170
6170
  }, f = (b) => {
6171
6171
  n || l(b), c(b);
6172
- }, k = getBreakpointValue(n ? i : a).toLowerCase();
6172
+ }, y = getBreakpointValue(n ? i : a).toLowerCase();
6173
6173
  return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (b) => /* @__PURE__ */ createElement(
6174
6174
  BreakpointCard,
6175
6175
  {
@@ -6177,7 +6177,7 @@ const COLOR_PROP = {
6177
6177
  ...b,
6178
6178
  onClick: f,
6179
6179
  key: b.breakpoint,
6180
- currentBreakpoint: k
6180
+ currentBreakpoint: y
6181
6181
  }
6182
6182
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
6183
6183
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
@@ -6191,7 +6191,7 @@ const COLOR_PROP = {
6191
6191
  ...b,
6192
6192
  onClick: f,
6193
6193
  key: b.breakpoint,
6194
- currentBreakpoint: k
6194
+ currentBreakpoint: y
6195
6195
  }
6196
6196
  )
6197
6197
  ) }),
@@ -6346,7 +6346,7 @@ const AskAIStyles = ({ blockId: o }) => {
6346
6346
  };
6347
6347
  function ManualClasses() {
6348
6348
  var I;
6349
- const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [x, f] = useState(""), k = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), v = b.split(" ").filter((L) => !isEmpty(L)), B = () => {
6349
+ const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [x, f] = useState(""), y = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), v = b.split(" ").filter((L) => !isEmpty(L)), B = () => {
6350
6350
  const L = x.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6351
6351
  u(m, L, !0), f("");
6352
6352
  }, [w, _] = useState([]), E = ({ value: L }) => {
@@ -6361,9 +6361,9 @@ function ManualClasses() {
6361
6361
  } else
6362
6362
  D = i.search(R);
6363
6363
  return _(map(D, "item"));
6364
- }, C = () => {
6364
+ }, S = () => {
6365
6365
  _([]);
6366
- }, A = (L) => L.name, N = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), S = useMemo(
6366
+ }, A = (L) => L.name, N = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), C = useMemo(
6367
6367
  () => ({
6368
6368
  ref: o,
6369
6369
  autoComplete: "off",
@@ -6384,7 +6384,7 @@ function ManualClasses() {
6384
6384
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
6385
6385
  }),
6386
6386
  [x, c, o]
6387
- ), y = (L) => {
6387
+ ), k = (L) => {
6388
6388
  debugger;
6389
6389
  const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6390
6390
  g(m, [L]), u(m, R, !0), r(""), l(-1);
@@ -6418,10 +6418,10 @@ function ManualClasses() {
6418
6418
  {
6419
6419
  suggestions: w,
6420
6420
  onSuggestionsFetchRequested: E,
6421
- onSuggestionsClearRequested: C,
6421
+ onSuggestionsClearRequested: S,
6422
6422
  getSuggestionValue: A,
6423
6423
  renderSuggestion: N,
6424
- inputProps: S,
6424
+ inputProps: C,
6425
6425
  containerProps: {
6426
6426
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
6427
6427
  },
@@ -6452,10 +6452,10 @@ function ManualClasses() {
6452
6452
  value: n,
6453
6453
  onChange: (T) => r(T.target.value),
6454
6454
  onBlur: () => {
6455
- y(L);
6455
+ k(L);
6456
6456
  },
6457
6457
  onKeyDown: (T) => {
6458
- T.key === "Enter" && y(L);
6458
+ T.key === "Enter" && k(L);
6459
6459
  },
6460
6460
  onFocus: (T) => {
6461
6461
  setTimeout(() => {
@@ -6604,8 +6604,8 @@ function BlockStyling() {
6604
6604
  h = isNaN(h) ? 0 : h;
6605
6605
  let x = MAPPER[i.dragUnit];
6606
6606
  (startsWith(m, "scale") || m === "opacity") && (x = 10);
6607
- let k = (i.dragStartY - u.pageY) / x + h;
6608
- g && k < 0 && (k = 0), m === "opacity" && k > 1 && (k = 1), i.onDrag(`${k}`), l(`${k}`);
6607
+ let y = (i.dragStartY - u.pageY) / x + h;
6608
+ g && y < 0 && (y = 0), m === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6609
6609
  },
6610
6610
  [i],
6611
6611
  50
@@ -6648,8 +6648,8 @@ const CoreBlock = ({
6648
6648
  }) => {
6649
6649
  const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
6650
6650
  if (has(o, "blocks")) {
6651
- const k = isFunction(o.blocks) ? o.blocks() : o.blocks;
6652
- u(syncBlocksWithDefaults(k), r || null, a);
6651
+ const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
6652
+ u(syncBlocksWithDefaults(y), r || null, a);
6653
6653
  } else
6654
6654
  p(o, r || null, a);
6655
6655
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
@@ -6661,8 +6661,8 @@ const CoreBlock = ({
6661
6661
  disabled: n,
6662
6662
  onClick: h,
6663
6663
  type: "button",
6664
- onDragStart: (k) => {
6665
- k.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), k.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6664
+ onDragStart: (y) => {
6665
+ y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6666
6666
  g([]), m();
6667
6667
  }, 200);
6668
6668
  },
@@ -6862,7 +6862,7 @@ const CoreBlock = ({
6862
6862
  }
6863
6863
  }
6864
6864
  }, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
6865
- var m, h, x, f, k, b, v, B;
6865
+ var m, h, x, f, y, b, v, B;
6866
6866
  if (r.type === "comment") return [];
6867
6867
  let a = { _id: generateUUID() };
6868
6868
  if (n && (a._parent = n.block._id), r.type === "text")
@@ -6905,7 +6905,7 @@ const CoreBlock = ({
6905
6905
  href: ((m = l.find((_) => _.key === "href")) == null ? void 0 : m.value) || "",
6906
6906
  hrefType: ((h = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
6907
6907
  autoplay: ((x = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
6908
- maxWidth: ((k = (f = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : k.replace("px", "")) || "",
6908
+ maxWidth: ((y = (f = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : y.replace("px", "")) || "",
6909
6909
  backdropColor: ((b = l.find((_) => _.key === "data-overlay")) == null ? void 0 : b.value) || "",
6910
6910
  galleryName: ((v = l.find((_) => _.key === "data-gall")) == null ? void 0 : v.value) || ""
6911
6911
  }, forEach(w, (_) => {
@@ -6918,14 +6918,14 @@ const CoreBlock = ({
6918
6918
  a.content = getTextContent(w);
6919
6919
  const _ = find(
6920
6920
  r.children || [],
6921
- (E) => (E == null ? void 0 : E.tagName) === "span" && some(E.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg")
6921
+ (E) => (E == null ? void 0 : E.tagName) === "span" && some(E.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg")
6922
6922
  );
6923
6923
  if (_) {
6924
- const E = find(_.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg");
6924
+ const E = find(_.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg");
6925
6925
  if (E) {
6926
6926
  a.icon = stringify([E]);
6927
- const { height: C, width: A } = getSvgDimensions(E, "16px", "16px");
6928
- a.iconHeight = C, a.iconWidth = A;
6927
+ const { height: S, width: A } = getSvgDimensions(E, "16px", "16px");
6928
+ a.iconHeight = S, a.iconWidth = A;
6929
6929
  }
6930
6930
  }
6931
6931
  return [a];
@@ -6937,8 +6937,8 @@ const CoreBlock = ({
6937
6937
  const w = stringify([r]);
6938
6938
  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];
6939
6939
  } else if (r.tagName === "svg") {
6940
- 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");
6941
- 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];
6940
+ const w = find(r.attributes, { key: "height" }), _ = find(r.attributes, { key: "width" }), E = get(w, "value") ? `[${get(w, "value")}px]` : "24px", S = get(_, "value") ? `[${get(_, "value")}px]` : "24px", A = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
6941
+ return a.styles = `${STYLES_KEY}, ${cn$2(`w-${S} h-${E}`, A)}`.trim(), r.attributes = filter(r.attributes, (N) => !includes(["style", "width", "height", "class"], N.key)), a.icon = stringify([r]), [a];
6942
6942
  } else if (r.tagName == "option" && n && ((B = n.block) == null ? void 0 : B._type) === "Select")
6943
6943
  return n.block.options.push({
6944
6944
  label: getTextContent(r.children),
@@ -7046,7 +7046,7 @@ const registerChaiLibrary = (o, n) => {
7046
7046
  parentId: r = void 0,
7047
7047
  position: a = -1
7048
7048
  }) => {
7049
- const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), k = (B) => {
7049
+ const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), y = (B) => {
7050
7050
  const w = has(B, "styles_attrs.data-page-section");
7051
7051
  return B._type === "Box" && w;
7052
7052
  }, b = useCallback(
@@ -7071,12 +7071,12 @@ const registerChaiLibrary = (o, n) => {
7071
7071
  onDragStart: async (B) => {
7072
7072
  const w = await c({ library: n, block: o });
7073
7073
  let _ = r;
7074
- if (k(first(w)) && (_ = null), !isEmpty(w)) {
7074
+ if (y(first(w)) && (_ = null), !isEmpty(w)) {
7075
7075
  const E = { blocks: w, uiLibrary: !0, parent: _ };
7076
7076
  if (B.dataTransfer.setData("text/plain", JSON.stringify(E)), o.preview) {
7077
- const C = new Image();
7078
- C.src = o.preview, C.onload = () => {
7079
- B.dataTransfer.setDragImage(C, 0, 0);
7077
+ const S = new Image();
7078
+ S.src = o.preview, S.onload = () => {
7079
+ B.dataTransfer.setDragImage(S, 0, 0);
7080
7080
  };
7081
7081
  } else
7082
7082
  B.dataTransfer.setDragImage(new Image(), 0, 0);
@@ -7106,7 +7106,7 @@ const registerChaiLibrary = (o, n) => {
7106
7106
  ] }) })
7107
7107
  ] });
7108
7108
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7109
- 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(""), [m, h] = useState([]), x = useRef(null);
7109
+ 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(""), [m, h] = useState([]), x = useRef(null);
7110
7110
  useEffect(() => {
7111
7111
  c && c.length > 0 && (x.current = new Fuse(c, {
7112
7112
  keys: ["name", "label", "description", "group"],
@@ -7118,25 +7118,25 @@ const registerChaiLibrary = (o, n) => {
7118
7118
  h([]);
7119
7119
  return;
7120
7120
  }
7121
- const y = x.current.search(u).map((j) => j.item);
7122
- h(y);
7121
+ const k = x.current.search(u).map((j) => j.item);
7122
+ h(k);
7123
7123
  }, [u]);
7124
- const f = u.trim() && !isEmpty(m) ? m : c, k = groupBy(f, "group"), [b, v] = useState(null);
7124
+ const f = u.trim() && !isEmpty(m) ? m : c, y = groupBy(f, "group"), [b, v] = useState(null);
7125
7125
  useEffect(() => {
7126
- if (isEmpty(keys(k))) {
7126
+ if (isEmpty(keys(y))) {
7127
7127
  v(null);
7128
7128
  return;
7129
7129
  }
7130
- if (!b || !k[b]) {
7131
- v(first(keys(k)));
7130
+ if (!b || !y[b]) {
7131
+ v(first(keys(y)));
7132
7132
  return;
7133
7133
  }
7134
- }, [k, b]);
7135
- const B = get(k, b, []), w = useRef(null), { t: _ } = useTranslation(), E = (y) => {
7134
+ }, [y, b]);
7135
+ const B = get(y, b, []), w = useRef(null), { t: _ } = useTranslation(), E = (k) => {
7136
7136
  w.current && (clearTimeout(w.current), w.current = null), w.current = setTimeout(() => {
7137
- w.current && v(y);
7137
+ w.current && v(k);
7138
7138
  }, 400);
7139
- }, C = () => {
7139
+ }, S = () => {
7140
7140
  i != null && i.id && p(i.id);
7141
7141
  }, A = () => {
7142
7142
  g("");
@@ -7146,7 +7146,7 @@ const registerChaiLibrary = (o, n) => {
7146
7146
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7147
7147
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7148
7148
  ] });
7149
- const N = filter(B, (y, j) => j % 2 === 0), S = filter(B, (y, j) => j % 2 === 1);
7149
+ const N = filter(B, (k, j) => j % 2 === 0), C = filter(B, (k, j) => j % 2 === 1);
7150
7150
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
7151
7151
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7152
7152
  /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
@@ -7155,7 +7155,7 @@ const registerChaiLibrary = (o, n) => {
7155
7155
  {
7156
7156
  placeholder: _("Search blocks..."),
7157
7157
  value: u,
7158
- onChange: (y) => g(y.target.value),
7158
+ onChange: (k) => g(k.target.value),
7159
7159
  className: "w-full pl-8 pr-8"
7160
7160
  }
7161
7161
  ),
@@ -7174,13 +7174,13 @@ const registerChaiLibrary = (o, n) => {
7174
7174
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7175
7175
  /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: _("Groups") }),
7176
7176
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7177
- /* @__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: [
7177
+ /* @__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: _("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7178
7178
  /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("Failed to load the UI library. Try again") }),
7179
- /* @__PURE__ */ jsxs(Button, { onClick: C, variant: "outline", size: "sm", className: "gap-2", children: [
7179
+ /* @__PURE__ */ jsxs(Button, { onClick: S, variant: "outline", size: "sm", className: "gap-2", children: [
7180
7180
  /* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
7181
7181
  _("Retry")
7182
7182
  ] })
7183
- ] }) }) : map(k, (y, j) => /* @__PURE__ */ jsxs(
7183
+ ] }) }) : map(y, (k, j) => /* @__PURE__ */ jsxs(
7184
7184
  "div",
7185
7185
  {
7186
7186
  onMouseEnter: () => E(j),
@@ -7206,23 +7206,23 @@ const registerChaiLibrary = (o, n) => {
7206
7206
  onMouseEnter: () => w.current ? clearTimeout(w.current) : null,
7207
7207
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
7208
7208
  children: [
7209
- 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: [
7210
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: N.map((y, j) => /* @__PURE__ */ jsx(
7209
+ 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: _("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7210
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: N.map((k, j) => /* @__PURE__ */ jsx(
7211
7211
  BlockCard,
7212
7212
  {
7213
7213
  parentId: o,
7214
7214
  position: n,
7215
- block: y,
7215
+ block: k,
7216
7216
  library: i
7217
7217
  },
7218
7218
  `block-${j}`
7219
7219
  )) }),
7220
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: S.map((y, j) => /* @__PURE__ */ jsx(
7220
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: C.map((k, j) => /* @__PURE__ */ jsx(
7221
7221
  BlockCard,
7222
7222
  {
7223
7223
  parentId: o,
7224
7224
  position: n,
7225
- block: y,
7225
+ block: k,
7226
7226
  library: i
7227
7227
  },
7228
7228
  `block-second-${j}`
@@ -7261,8 +7261,8 @@ const registerChaiLibrary = (o, n) => {
7261
7261
  error: c
7262
7262
  }), g(!0);
7263
7263
  else if (!l && Object.keys(a || {}).length > 0) {
7264
- const h = Object.entries(a).map(([f, k]) => {
7265
- const b = k, v = b.type || "partial", B = formatReadableName(v);
7264
+ const h = Object.entries(a).map(([f, y]) => {
7265
+ const b = y, v = b.type || "partial", B = formatReadableName(v);
7266
7266
  return {
7267
7267
  type: "PartialBlock",
7268
7268
  // Set the type to PartialBlock
@@ -7324,44 +7324,44 @@ const registerChaiLibrary = (o, n) => {
7324
7324
  }, ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, n) => {
7325
7325
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...n });
7326
7326
  }, 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" }) => {
7327
- var S;
7328
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (S = find(c, (y) => y._id === r)) == null ? void 0 : S._type, [h, x] = useState("all"), [f, k] = useState(null), b = useRef(null);
7327
+ var C;
7328
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (C = find(c, (k) => k._id === r)) == null ? void 0 : C._type, [h, x] = useState("all"), [f, y] = useState(null), b = useRef(null);
7329
7329
  useEffect(() => {
7330
- const y = setTimeout(() => {
7330
+ const k = setTimeout(() => {
7331
7331
  var j;
7332
7332
  (j = u.current) == null || j.focus();
7333
7333
  }, 0);
7334
- return () => clearTimeout(y);
7334
+ return () => clearTimeout(k);
7335
7335
  }, [g]), useEffect(() => {
7336
- d && (x("all"), k(null));
7337
- }, [d]), useEffect(() => (b.current = debounce((y) => {
7338
- x(y);
7336
+ d && (x("all"), y(null));
7337
+ }, [d]), useEffect(() => (b.current = debounce((k) => {
7338
+ x(k);
7339
7339
  }, 500), () => {
7340
7340
  b.current && b.current.cancel();
7341
7341
  }), []);
7342
- const v = useCallback((y) => {
7343
- k(y), b.current && b.current(y);
7342
+ const v = useCallback((k) => {
7343
+ y(k), b.current && b.current(k);
7344
7344
  }, []), B = useCallback(() => {
7345
- k(null), b.current && b.current.cancel();
7346
- }, []), w = useCallback((y) => {
7347
- b.current && b.current.cancel(), x(y), k(null);
7345
+ y(null), b.current && b.current.cancel();
7346
+ }, []), w = useCallback((k) => {
7347
+ b.current && b.current.cancel(), x(k), y(null);
7348
7348
  }, []), _ = useMemo(
7349
7349
  () => d ? values(n).filter(
7350
- (y) => {
7350
+ (k) => {
7351
7351
  var j, I;
7352
- return (((j = y.label) == null ? void 0 : j.toLowerCase()) + " " + ((I = y.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
7352
+ return (((j = k.label) == null ? void 0 : j.toLowerCase()) + " " + ((I = k.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
7353
7353
  }
7354
7354
  ) : n,
7355
7355
  [n, d]
7356
7356
  ), E = useMemo(
7357
7357
  () => d ? o.filter(
7358
- (y) => reject(filter(values(_), { group: y }), { hidden: !0 }).length > 0
7359
- ) : o.filter((y) => reject(filter(values(n), { group: y }), { hidden: !0 }).length > 0),
7358
+ (k) => reject(filter(values(_), { group: k }), { hidden: !0 }).length > 0
7359
+ ) : o.filter((k) => reject(filter(values(n), { group: k }), { hidden: !0 }).length > 0),
7360
7360
  [n, _, o, d]
7361
- ), C = useMemo(
7362
- () => sortBy(E, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
7361
+ ), S = useMemo(
7362
+ () => sortBy(E, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7363
7363
  [E]
7364
- ), A = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), N = useMemo(() => h === "all" ? C : [h], [C, h]);
7364
+ ), A = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), N = useMemo(() => h === "all" ? S : [h], [S, h]);
7365
7365
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7366
7366
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7367
7367
  Input$1,
@@ -7371,11 +7371,11 @@ const registerChaiLibrary = (o, n) => {
7371
7371
  placeholder: i("Search blocks..."),
7372
7372
  value: d,
7373
7373
  className: "-ml-2",
7374
- onChange: (y) => p(y.target.value)
7374
+ onChange: (k) => p(k.target.value)
7375
7375
  }
7376
7376
  ) }),
7377
7377
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
7378
- 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: [
7378
+ 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: [
7379
7379
  /* @__PURE__ */ jsx(
7380
7380
  "button",
7381
7381
  {
@@ -7387,16 +7387,16 @@ const registerChaiLibrary = (o, n) => {
7387
7387
  },
7388
7388
  "sidebar-all"
7389
7389
  ),
7390
- C.map((y) => /* @__PURE__ */ jsx(
7390
+ S.map((k) => /* @__PURE__ */ jsx(
7391
7391
  "button",
7392
7392
  {
7393
- onClick: () => w(y),
7394
- onMouseEnter: () => v(y),
7393
+ onClick: () => w(k),
7394
+ onMouseEnter: () => v(k),
7395
7395
  onMouseLeave: B,
7396
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === y || f === y ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7397
- children: capitalize(i(y.toLowerCase()))
7396
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === k || f === k ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7397
+ children: capitalize(i(k.toLowerCase()))
7398
7398
  },
7399
- `sidebar-${y}`
7399
+ `sidebar-${k}`
7400
7400
  ))
7401
7401
  ] }) }) }),
7402
7402
  /* @__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: [
@@ -7404,10 +7404,10 @@ const registerChaiLibrary = (o, n) => {
7404
7404
  ' "',
7405
7405
  d,
7406
7406
  '"'
7407
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((y) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7408
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(y.toLowerCase())) }),
7407
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7408
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
7409
7409
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7410
- h === "all" ? filter(values(A), { group: y }) : values(A),
7410
+ h === "all" ? filter(values(A), { group: k }) : values(A),
7411
7411
  { hidden: !0 }
7412
7412
  ).map((j) => /* @__PURE__ */ jsx(
7413
7413
  CoreBlock,
@@ -7419,7 +7419,7 @@ const registerChaiLibrary = (o, n) => {
7419
7419
  },
7420
7420
  j.type
7421
7421
  )) })
7422
- ] }, y)) }) }) })
7422
+ ] }, k)) }) }) })
7423
7423
  ] })
7424
7424
  ] });
7425
7425
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -7769,33 +7769,33 @@ const Input = ({ node: o }) => {
7769
7769
  var R;
7770
7770
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7771
7771
  let p = null;
7772
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: h, data: x, isSelected: f, willReceiveDrop: k, isDragging: b, isEditing: v, handleClick: B } = o, w = (T) => {
7772
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: h, data: x, isSelected: f, willReceiveDrop: y, isDragging: b, isEditing: v, handleClick: B } = o, w = (T) => {
7773
7773
  T.stopPropagation(), !l.includes(h) && o.toggle();
7774
7774
  }, _ = (T) => {
7775
7775
  T.isInternal && (p = T.isOpen, T.isOpen && T.close());
7776
7776
  }, E = (T) => {
7777
7777
  T.isInternal && p !== null && (p ? T.open() : T.close(), p = null);
7778
- }, [C, A] = useAtom$1(currentAddSelection), N = () => {
7778
+ }, [S, A] = useAtom$1(currentAddSelection), N = () => {
7779
7779
  var T;
7780
- S(), o.parent.isSelected || A((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
7781
- }, S = () => {
7780
+ C(), o.parent.isSelected || A((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
7781
+ }, C = () => {
7782
7782
  A(null);
7783
- }, y = (T) => {
7784
- S(), T.stopPropagation(), !o.isOpen && !l.includes(h) && o.toggle(), B(T);
7783
+ }, k = (T) => {
7784
+ C(), T.stopPropagation(), !o.isOpen && !l.includes(h) && o.toggle(), B(T);
7785
7785
  };
7786
7786
  useEffect(() => {
7787
7787
  const T = setTimeout(() => {
7788
- k && !o.isOpen && !b && !l.includes(h) && o.toggle();
7788
+ y && !o.isOpen && !b && !l.includes(h) && o.toggle();
7789
7789
  }, 500);
7790
7790
  return () => clearTimeout(T);
7791
- }, [k, o, b]);
7791
+ }, [y, o, b]);
7792
7792
  const j = (T, D) => {
7793
7793
  const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${T}]`);
7794
7794
  P && P.setAttribute("data-drop", D);
7795
7795
  const $ = P.getBoundingClientRect(), M = c.getBoundingClientRect();
7796
7796
  $.top >= M.top && $.left >= M.left && $.bottom <= M.bottom && $.right <= M.right || (O.documentElement.scrollTop = P.offsetTop - M.top);
7797
7797
  }, I = (T) => {
7798
- S();
7798
+ C();
7799
7799
  const D = get(o, "parent.id");
7800
7800
  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 });
7801
7801
  };
@@ -7823,7 +7823,7 @@ const Input = ({ node: o }) => {
7823
7823
  {
7824
7824
  onMouseEnter: () => g(h),
7825
7825
  onMouseLeave: () => m(),
7826
- onClick: y,
7826
+ onClick: k,
7827
7827
  style: n,
7828
7828
  "data-node-id": h,
7829
7829
  ref: l.includes(h) ? null : r,
@@ -7846,7 +7846,7 @@ const Input = ({ node: o }) => {
7846
7846
  T.stopPropagation(), I(o.childIndex);
7847
7847
  },
7848
7848
  onMouseEnter: N,
7849
- onMouseLeave: S,
7849
+ onMouseLeave: C,
7850
7850
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
7851
7851
  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" }) })
7852
7852
  }
@@ -7857,8 +7857,8 @@ const Input = ({ node: o }) => {
7857
7857
  className: cn(
7858
7858
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
7859
7859
  f ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
7860
- k && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
7861
- (o == null ? void 0 : o.id) === C ? "bg-primary/10" : "",
7860
+ y && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
7861
+ (o == null ? void 0 : o.id) === S ? "bg-primary/10" : "",
7862
7862
  b && "opacity-20",
7863
7863
  l.includes(h) ? "opacity-50" : "",
7864
7864
  L && f && "bg-primary/20 text-primary"
@@ -8218,7 +8218,7 @@ const Input = ({ node: o }) => {
8218
8218
  },
8219
8219
  [d],
8220
8220
  200
8221
- ), k = useDebouncedCallback(
8221
+ ), y = useDebouncedCallback(
8222
8222
  (v, B) => {
8223
8223
  p(() => {
8224
8224
  const w = get(d, `colors.${v}`);
@@ -8240,7 +8240,7 @@ const Input = ({ node: o }) => {
8240
8240
  ColorPickerInput,
8241
8241
  {
8242
8242
  value: w,
8243
- onChange: (_) => k(B, _)
8243
+ onChange: (_) => y(B, _)
8244
8244
  }
8245
8245
  ),
8246
8246
  /* @__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" : "") })
@@ -8770,8 +8770,8 @@ const AIUserPrompt = ({ blockId: o }) => {
8770
8770
  (f = m.current) == null || f.focus();
8771
8771
  }, []);
8772
8772
  const x = (f) => {
8773
- const { usage: k } = f || {};
8774
- !l && k && g(k), h.current = setTimeout(() => g(void 0), 1e4), l || c("");
8773
+ const { usage: y } = f || {};
8774
+ !l && y && g(y), h.current = setTimeout(() => g(void 0), 1e4), l || c("");
8775
8775
  };
8776
8776
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8777
8777
  /* @__PURE__ */ jsxs(
@@ -9017,7 +9017,7 @@ function AIChatPanel() {
9017
9017
  }, f = () => {
9018
9018
  var b;
9019
9019
  (b = p.current) == null || b.click();
9020
- }, k = () => {
9020
+ }, y = () => {
9021
9021
  d(null), p.current && (p.current.value = "");
9022
9022
  };
9023
9023
  return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
@@ -9063,7 +9063,7 @@ function AIChatPanel() {
9063
9063
  size: "icon",
9064
9064
  variant: "destructive",
9065
9065
  className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
9066
- onClick: k,
9066
+ onClick: y,
9067
9067
  children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
9068
9068
  }
9069
9069
  )
@@ -9206,7 +9206,7 @@ const AiAssistant = () => {
9206
9206
  preloadedAttributes: n = [],
9207
9207
  onAttributesChange: r
9208
9208
  }) {
9209
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), x = useRef(null), f = useRef(null), k = usePageExternalData();
9209
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), x = useRef(null), f = useRef(null), y = usePageExternalData();
9210
9210
  useEffect(() => {
9211
9211
  l(n);
9212
9212
  }, [n]);
@@ -9216,43 +9216,43 @@ const AiAssistant = () => {
9216
9216
  return;
9217
9217
  }
9218
9218
  if (i) {
9219
- const C = [...a, { key: i, value: d }];
9220
- r(C), l(a), c(""), p(""), h("");
9219
+ const S = [...a, { key: i, value: d }];
9220
+ r(S), l(a), c(""), p(""), h("");
9221
9221
  }
9222
- }, v = (C) => {
9223
- const A = a.filter((N, S) => S !== C);
9222
+ }, v = (S) => {
9223
+ const A = a.filter((N, C) => C !== S);
9224
9224
  r(A), l(A);
9225
- }, B = (C) => {
9226
- g(C), c(a[C].key), p(a[C].value);
9225
+ }, B = (S) => {
9226
+ g(S), c(a[S].key), p(a[S].value);
9227
9227
  }, w = () => {
9228
9228
  if (i.startsWith("@")) {
9229
9229
  h("Attribute keys cannot start with '@'");
9230
9230
  return;
9231
9231
  }
9232
9232
  if (u !== null && i) {
9233
- const C = [...a];
9234
- C[u] = { key: i, value: d }, r(C), l(C), g(null), c(""), p(""), h("");
9233
+ const S = [...a];
9234
+ S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), h("");
9235
9235
  }
9236
- }, _ = (C) => {
9237
- C.key === "Enter" && !C.shiftKey && (C.preventDefault(), u !== null ? w() : b());
9238
- }, E = useCallback((C) => {
9239
- const A = (y) => /[.,!?;:]/.test(y), N = (y, j, I) => {
9236
+ }, _ = (S) => {
9237
+ S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : b());
9238
+ }, E = useCallback((S) => {
9239
+ const A = (k) => /[.,!?;:]/.test(k), N = (k, j, I) => {
9240
9240
  let L = "", R = "";
9241
- const T = j > 0 ? y[j - 1] : "", D = j < y.length ? y[j] : "";
9242
- return j > 0 && (T === "." || !A(T) && T !== " ") && (L = " "), j < y.length && !A(D) && D !== " " && (R = " "), {
9241
+ const T = j > 0 ? k[j - 1] : "", D = j < k.length ? k[j] : "";
9242
+ return j > 0 && (T === "." || !A(T) && T !== " ") && (L = " "), j < k.length && !A(D) && D !== " " && (R = " "), {
9243
9243
  text: L + I + R,
9244
9244
  prefixLength: L.length,
9245
9245
  suffixLength: R.length
9246
9246
  };
9247
- }, S = f.current;
9248
- if (S) {
9249
- const y = S.selectionStart || 0, j = S.value || "", I = S.selectionEnd || y;
9250
- if (I > y) {
9251
- const O = `{{${C}}}`, { text: P } = N(j, y, O), $ = j.slice(0, y) + P + j.slice(I);
9247
+ }, C = f.current;
9248
+ if (C) {
9249
+ const k = C.selectionStart || 0, j = C.value || "", I = C.selectionEnd || k;
9250
+ if (I > k) {
9251
+ const O = `{{${S}}}`, { text: P } = N(j, k, O), $ = j.slice(0, k) + P + j.slice(I);
9252
9252
  p($);
9253
9253
  return;
9254
9254
  }
9255
- const R = `{{${C}}}`, { text: T } = N(j, y, R), D = j.slice(0, y) + T + j.slice(y);
9255
+ const R = `{{${S}}}`, { text: T } = N(j, k, R), D = j.slice(0, k) + T + j.slice(k);
9256
9256
  p(D);
9257
9257
  }
9258
9258
  }, []);
@@ -9260,8 +9260,8 @@ const AiAssistant = () => {
9260
9260
  /* @__PURE__ */ jsxs(
9261
9261
  "form",
9262
9262
  {
9263
- onSubmit: (C) => {
9264
- C.preventDefault(), u !== null ? w() : b();
9263
+ onSubmit: (S) => {
9264
+ S.preventDefault(), u !== null ? w() : b();
9265
9265
  },
9266
9266
  className: "space-y-3",
9267
9267
  children: [
@@ -9277,7 +9277,7 @@ const AiAssistant = () => {
9277
9277
  id: "attrKey",
9278
9278
  ref: x,
9279
9279
  value: i,
9280
- onChange: (C) => c(C.target.value),
9280
+ onChange: (S) => c(S.target.value),
9281
9281
  placeholder: "Enter Key",
9282
9282
  className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
9283
9283
  }
@@ -9286,7 +9286,7 @@ const AiAssistant = () => {
9286
9286
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9287
9287
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9288
9288
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9289
- !isEmpty(k) && /* @__PURE__ */ jsx(NestedPathSelector, { data: k, onSelect: E })
9289
+ !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: E })
9290
9290
  ] }),
9291
9291
  /* @__PURE__ */ jsx(
9292
9292
  Textarea,
@@ -9298,7 +9298,7 @@ const AiAssistant = () => {
9298
9298
  rows: 2,
9299
9299
  ref: f,
9300
9300
  value: d,
9301
- onChange: (C) => p(C.target.value),
9301
+ onChange: (S) => p(S.target.value),
9302
9302
  onKeyDown: _,
9303
9303
  placeholder: "Enter Value",
9304
9304
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
@@ -9311,10 +9311,10 @@ const AiAssistant = () => {
9311
9311
  ]
9312
9312
  }
9313
9313
  ),
9314
- /* @__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: [
9314
+ /* @__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: [
9315
9315
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9316
- /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: C.key }),
9317
- /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: C.value.toString() })
9316
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
9317
+ /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: S.value.toString() })
9318
9318
  ] }),
9319
9319
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9320
9320
  /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(A), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
@@ -9438,27 +9438,27 @@ const RootLayout = () => {
9438
9438
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9439
9439
  r("outline");
9440
9440
  });
9441
- const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), m = useCallback((C) => {
9442
- C.preventDefault();
9441
+ const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), m = useCallback((S) => {
9442
+ S.preventDefault();
9443
9443
  }, []), h = useCallback(
9444
- (C) => {
9445
- r(n === C ? null : C);
9444
+ (S) => {
9445
+ r(n === S ? null : S);
9446
9446
  },
9447
9447
  [n]
9448
9448
  ), { t: x } = useTranslation(), f = useMemo(
9449
9449
  () => [...p, ...u, ...g],
9450
9450
  [p, u, g]
9451
- ), k = useBuilderProp("htmlDir", "ltr"), b = find(f, { id: n }) ?? first(f), v = get(b, "width", DEFAULT_PANEL_WIDTH);
9451
+ ), y = useBuilderProp("htmlDir", "ltr"), b = find(f, { id: n }) ?? first(f), v = get(b, "width", DEFAULT_PANEL_WIDTH);
9452
9452
  useEffect(() => {
9453
9453
  if (n !== null) {
9454
- const C = find(f, { id: n });
9455
- C && get(C, "view", "standard") === "standard" && (a.current = n, i(get(C, "width", DEFAULT_PANEL_WIDTH)));
9454
+ const S = find(f, { id: n });
9455
+ S && get(S, "view", "standard") === "standard" && (a.current = n, i(get(S, "width", DEFAULT_PANEL_WIDTH)));
9456
9456
  }
9457
9457
  }, [n, f]);
9458
9458
  const B = useMemo(() => {
9459
9459
  if (n === null) return 0;
9460
- const C = find(f, { id: n });
9461
- return get(C, "view", "standard") === "standard" ? v : l;
9460
+ const S = find(f, { id: n });
9461
+ return get(S, "view", "standard") === "standard" ? v : l;
9462
9462
  }, [n, v, l, f]), w = useCallback(() => {
9463
9463
  r(a.current);
9464
9464
  }, [r]), _ = useCallback(() => {
@@ -9468,12 +9468,12 @@ const RootLayout = () => {
9468
9468
  find(f, { id: n }) || r("outline");
9469
9469
  }, [n, f]);
9470
9470
  const E = useCallback(
9471
- (C) => {
9472
- h(C);
9471
+ (S) => {
9472
+ h(S);
9473
9473
  },
9474
9474
  [h]
9475
9475
  );
9476
- 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: [
9476
+ 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: [
9477
9477
  /* @__PURE__ */ jsxs(
9478
9478
  "div",
9479
9479
  {
@@ -9483,24 +9483,24 @@ const RootLayout = () => {
9483
9483
  /* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
9484
9484
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9485
9485
  /* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9486
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((C, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9487
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(C, "button", NoopComponent), {
9486
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((S, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9487
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(S, "button", NoopComponent), {
9488
9488
  position: "top",
9489
- panelId: C.id,
9490
- isActive: n === C.id,
9491
- show: () => E(C.id)
9489
+ panelId: S.id,
9490
+ isActive: n === S.id,
9491
+ show: () => E(S.id)
9492
9492
  }) }),
9493
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(C.label) }) })
9493
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(S.label) }) })
9494
9494
  ] }, "button-top-" + A)) }),
9495
9495
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9496
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((C, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9497
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(C, "button", NoopComponent), {
9496
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((S, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9497
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(S, "button", NoopComponent), {
9498
9498
  position: "bottom",
9499
- panelId: C.id,
9500
- isActive: n === C.id,
9501
- show: () => E(C.id)
9499
+ panelId: S.id,
9500
+ isActive: n === S.id,
9501
+ show: () => E(S.id)
9502
9502
  }) }),
9503
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(C.label) }) })
9503
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(S.label) }) })
9504
9504
  ] }, "button-bottom-" + A)) })
9505
9505
  ] }),
9506
9506
  /* @__PURE__ */ jsx(
@@ -9634,7 +9634,17 @@ const RootLayout = () => {
9634
9634
  ] }),
9635
9635
  /* @__PURE__ */ jsx("div", { children: a ? /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-96 w-full" }), children: React__default.createElement(a) }) : null })
9636
9636
  ] }) : null;
9637
- }, CHAI_FEATURE_FLAGS = {}, useChaiFeatureFlags = () => CHAI_FEATURE_FLAGS, featureFlagsAtom = atomWithStorage("chai-feature-flags", []), useChaiFeatureFlag = (o) => {
9637
+ }, CHAI_FEATURE_FLAGS = {}, registerChaiFeatureFlag = (o, n) => {
9638
+ if (CHAI_FEATURE_FLAGS[o])
9639
+ throw new Error(`Flag ${o} already exists`);
9640
+ CHAI_FEATURE_FLAGS[o] = { key: o, value: !1, ...n };
9641
+ }, registerChaiFeatureFlags = (o) => {
9642
+ Object.entries(o).forEach(([n, r]) => {
9643
+ if (CHAI_FEATURE_FLAGS[n])
9644
+ throw new Error(`Flag ${n} already exists`);
9645
+ registerChaiFeatureFlag(n, r);
9646
+ });
9647
+ }, useChaiFeatureFlags = () => CHAI_FEATURE_FLAGS, featureFlagsAtom = atomWithStorage("chai-feature-flags", []), useChaiFeatureFlag = (o) => {
9638
9648
  const [n] = useAtom$1(featureFlagsAtom);
9639
9649
  return n.includes(o);
9640
9650
  }, useToggleChaiFeatureFlag = (o) => {
@@ -9642,30 +9652,127 @@ const RootLayout = () => {
9642
9652
  return () => {
9643
9653
  n.includes(o) ? r(n.filter((l) => l !== o)) : r([...n, o]);
9644
9654
  };
9645
- }, FeatureToggle = ({
9655
+ }, IfChaiFeatureFlag = ({ flagKey: o, children: n }) => useChaiFeatureFlag(o) ? n : null, FeatureToggle = ({
9646
9656
  featureKey: o,
9647
9657
  options: n
9648
9658
  }) => {
9649
9659
  const r = useToggleChaiFeatureFlag(o), a = useChaiFeatureFlag(o);
9650
- return /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
9660
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-3 rounded-md p-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800", children: [
9651
9661
  /* @__PURE__ */ jsx(Switch, { checked: a, onCheckedChange: r }),
9652
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
9653
- /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: n.key }),
9654
- /* @__PURE__ */ jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: n.description })
9662
+ /* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
9663
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: n.key }),
9664
+ n.description && /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400", children: n.description })
9655
9665
  ] })
9656
9666
  ] });
9657
- }, showFeatureFlagAtom = atomWithStorage("show-feature-flag", !1), ChaiFeatureFlagsWidget = () => {
9658
- const o = useChaiFeatureFlags(), [n, r] = useAtom$1(showFeatureFlagAtom);
9659
- return useHotkeys("ctrl+shift+1,command+shift+1", () => r(!n)), n ? /* @__PURE__ */ jsxs(Popover, { open: !0, children: [
9660
- /* @__PURE__ */ jsx(PopoverTrigger, { children: /* @__PURE__ */ jsx(Settings$1, {}) }),
9661
- /* @__PURE__ */ jsx(PopoverContent, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-1", children: [
9662
- /* @__PURE__ */ jsxs("div", { className: "mb-2 px-1", children: [
9663
- /* @__PURE__ */ jsx("h3", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Feature Flags" }),
9664
- /* @__PURE__ */ jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: "Enable or disable experimental features" })
9665
- ] }),
9666
- /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-3 pt-2", children: Object.entries(o).map(([a, l]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: a, options: l }, a)) })
9667
- ] }) })
9668
- ] }) : null;
9667
+ }, showFeatureFlagAtom = atomWithStorage(
9668
+ "show-feature-flag",
9669
+ null
9670
+ ), ChaiFeatureFlagsWidgetComponent = ({
9671
+ close: o,
9672
+ position: n,
9673
+ updatePosition: r
9674
+ }) => {
9675
+ const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
9676
+ if (!l.trim()) return a;
9677
+ const f = l.toLowerCase();
9678
+ return Object.fromEntries(
9679
+ Object.entries(a).filter(([y, b]) => {
9680
+ var v;
9681
+ return (y == null ? void 0 : y.toLowerCase().includes(f)) || ((v = b == null ? void 0 : b.description) == null ? void 0 : v.toLowerCase().includes(f));
9682
+ })
9683
+ );
9684
+ }, [a, l]), m = (f) => {
9685
+ d(!0), u({
9686
+ x: f.clientX - n.x,
9687
+ y: f.clientY - n.y
9688
+ });
9689
+ }, h = (f) => {
9690
+ if (!c) return;
9691
+ const y = f.clientX - p.x, b = f.clientY - p.y, v = f.currentTarget, B = v.offsetWidth, w = v.offsetHeight, _ = window.innerWidth - B, E = window.innerHeight - w, S = Math.max(0, Math.min(y, _)), A = Math.max(0, Math.min(b, E));
9692
+ r(S, A);
9693
+ }, x = () => {
9694
+ d(!1);
9695
+ };
9696
+ return useEffect(() => {
9697
+ const f = () => {
9698
+ c && d(!1);
9699
+ };
9700
+ return window.addEventListener("mouseup", f), () => window.removeEventListener("mouseup", f);
9701
+ }, [c]), !n || n.x < 0 || n.y < 0 ? null : /* @__PURE__ */ jsxs(
9702
+ "div",
9703
+ {
9704
+ onMouseDown: m,
9705
+ onMouseMove: h,
9706
+ onMouseUp: x,
9707
+ className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
9708
+ style: {
9709
+ left: n.x,
9710
+ top: n.y,
9711
+ cursor: c ? "grabbing" : "grab",
9712
+ userSelect: "none"
9713
+ },
9714
+ children: [
9715
+ /* @__PURE__ */ jsxs("div", { className: "relative sticky top-0 rounded-t-lg bg-white", children: [
9716
+ /* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center justify-between", children: [
9717
+ /* @__PURE__ */ jsxs("div", { children: [
9718
+ /* @__PURE__ */ jsxs("h3", { className: "flex items-center gap-x-2 text-base font-semibold text-gray-900 dark:text-gray-100", children: [
9719
+ /* @__PURE__ */ jsx(DragHandleDots2Icon, {}),
9720
+ " Feature Flags"
9721
+ ] }),
9722
+ /* @__PURE__ */ jsxs("p", { className: "text-xs text-gray-400 dark:text-gray-400", children: [
9723
+ "Toggle experimental features (",
9724
+ /* @__PURE__ */ jsx("span", { className: "font-mono", children: "Ctrl+Shift+1" }),
9725
+ " to toggle)"
9726
+ ] })
9727
+ ] }),
9728
+ /* @__PURE__ */ jsx(
9729
+ Button,
9730
+ {
9731
+ variant: "ghost",
9732
+ size: "sm",
9733
+ onClick: o,
9734
+ className: "absolute -right-2 -top-2 p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",
9735
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
9736
+ }
9737
+ )
9738
+ ] }),
9739
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
9740
+ /* @__PURE__ */ jsx(Search, { className: "absolute left-2.5 top-2.5 h-4 w-4 text-gray-400" }),
9741
+ /* @__PURE__ */ jsx(
9742
+ Input$1,
9743
+ {
9744
+ type: "search",
9745
+ placeholder: "Search features...",
9746
+ className: "w-full pl-8",
9747
+ value: l,
9748
+ onChange: (f) => i(f.target.value),
9749
+ autoFocus: !0
9750
+ }
9751
+ )
9752
+ ] })
9753
+ ] }),
9754
+ /* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(g).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(g).map(([f, y]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: f, options: y }, f)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
9755
+ 'No features found matching "',
9756
+ l,
9757
+ '"'
9758
+ ] }) }) })
9759
+ ]
9760
+ }
9761
+ );
9762
+ }, ChaiFeatureFlagsWidget = () => {
9763
+ const [o, n] = useAtom$1(showFeatureFlagAtom);
9764
+ return useHotkeys(
9765
+ "ctrl+shift+1,command+shift+1",
9766
+ () => n((r) => r ? { ...r, show: !r.show } : { x: 0, y: 0, show: !0 }),
9767
+ { enableOnFormTags: !0 }
9768
+ ), o != null && o.show ? /* @__PURE__ */ jsx(
9769
+ ChaiFeatureFlagsWidgetComponent,
9770
+ {
9771
+ position: o,
9772
+ close: () => n((r) => ({ ...r, show: !1 })),
9773
+ updatePosition: (r, a) => n((l) => ({ ...l, x: r, y: a }))
9774
+ }
9775
+ ) : null;
9669
9776
  }, setDebugLogs = (o) => {
9670
9777
  }, getParentNodeIds = (o, n) => {
9671
9778
  const r = [];
@@ -9764,41 +9871,41 @@ const RootLayout = () => {
9764
9871
  }, ...m) => {
9765
9872
  const h = m[0] || ((A) => {
9766
9873
  let N = o.get(A);
9767
- return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, N), u == null || u(A, C)), N;
9874
+ return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, N), u == null || u(A, S)), N;
9768
9875
  }), x = m[1] || (() => {
9769
9876
  let A, N;
9770
- const S = (y) => {
9877
+ const C = (k) => {
9771
9878
  try {
9772
- y();
9879
+ k();
9773
9880
  } catch (j) {
9774
9881
  A || (A = !0, N = j);
9775
9882
  }
9776
9883
  };
9777
9884
  do {
9778
- c.f && S(c.f);
9779
- const y = /* @__PURE__ */ new Set(), j = y.add.bind(y);
9885
+ c.f && C(c.f);
9886
+ const k = /* @__PURE__ */ new Set(), j = k.add.bind(k);
9780
9887
  a.forEach((I) => {
9781
9888
  var L;
9782
9889
  return (L = n.get(I)) == null ? void 0 : L.l.forEach(j);
9783
- }), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), y.forEach(S), a.size && f();
9890
+ }), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), k.forEach(C), a.size && f();
9784
9891
  } while (a.size || i.size || l.size);
9785
9892
  if (A)
9786
9893
  throw N;
9787
9894
  }), f = m[2] || (() => {
9788
- const A = [], N = /* @__PURE__ */ new WeakSet(), S = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
9789
- for (; y.length; ) {
9790
- const j = y[y.length - 1], I = h(j);
9791
- if (S.has(j)) {
9792
- y.pop();
9895
+ const A = [], N = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
9896
+ for (; k.length; ) {
9897
+ const j = k[k.length - 1], I = h(j);
9898
+ if (C.has(j)) {
9899
+ k.pop();
9793
9900
  continue;
9794
9901
  }
9795
9902
  if (N.has(j)) {
9796
- r.get(j) === I.n && A.push([j, I]), S.add(j), y.pop();
9903
+ r.get(j) === I.n && A.push([j, I]), C.add(j), k.pop();
9797
9904
  continue;
9798
9905
  }
9799
9906
  N.add(j);
9800
9907
  for (const L of getMountedOrPendingDependents(j, I, n))
9801
- N.has(L) || y.push(L);
9908
+ N.has(L) || k.push(L);
9802
9909
  }
9803
9910
  for (let j = A.length - 1; j >= 0; --j) {
9804
9911
  const [I, L] = A[j];
@@ -9808,39 +9915,39 @@ const RootLayout = () => {
9808
9915
  R = !0;
9809
9916
  break;
9810
9917
  }
9811
- R && (k(I), B(I)), r.delete(I);
9918
+ R && (y(I), B(I)), r.delete(I);
9812
9919
  }
9813
- }), k = m[3] || ((A) => {
9814
- var N, S;
9815
- const y = h(A);
9816
- if (isAtomStateInitialized(y) && (n.has(A) && r.get(A) !== y.n || Array.from(y.d).every(
9920
+ }), y = m[3] || ((A) => {
9921
+ var N, C;
9922
+ const k = h(A);
9923
+ if (isAtomStateInitialized(k) && (n.has(A) && r.get(A) !== k.n || Array.from(k.d).every(
9817
9924
  ([P, $]) => (
9818
9925
  // Recursively, read the atom state of the dependency, and
9819
9926
  // check if the atom epoch number is unchanged
9820
- k(P).n === $
9927
+ y(P).n === $
9821
9928
  )
9822
9929
  )))
9823
- return y;
9824
- y.d.clear();
9930
+ return k;
9931
+ k.d.clear();
9825
9932
  let j = !0;
9826
9933
  const I = () => {
9827
9934
  n.has(A) && (B(A), f(), x());
9828
9935
  }, L = (P) => {
9829
9936
  var $;
9830
9937
  if (isSelfAtom(A, P)) {
9831
- const F = h(P);
9832
- if (!isAtomStateInitialized(F))
9938
+ const H = h(P);
9939
+ if (!isAtomStateInitialized(H))
9833
9940
  if (hasInitialValue(P))
9834
9941
  setAtomStateValueOrPromise(P, P.init, h);
9835
9942
  else
9836
9943
  throw new Error("no atom init");
9837
- return returnAtomValue(F);
9944
+ return returnAtomValue(H);
9838
9945
  }
9839
- const M = k(P);
9946
+ const M = y(P);
9840
9947
  try {
9841
9948
  return returnAtomValue(M);
9842
9949
  } finally {
9843
- y.d.set(P, M.n), isPendingPromise(y.v) && addPendingPromiseToDependency(A, y.v, M), ($ = n.get(P)) == null || $.t.add(A), j || I();
9950
+ k.d.set(P, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(A, k.v, M), ($ = n.get(P)) == null || $.t.add(A), j || I();
9844
9951
  }
9845
9952
  };
9846
9953
  let R, T;
@@ -9858,30 +9965,30 @@ const RootLayout = () => {
9858
9965
  }
9859
9966
  }), T;
9860
9967
  }
9861
- }, O = y.n;
9968
+ }, O = k.n;
9862
9969
  try {
9863
9970
  const P = d(A, L, D);
9864
9971
  return setAtomStateValueOrPromise(A, P, h), isPromiseLike$1(P) && ((N = P.onCancel) == null || N.call(P, () => R == null ? void 0 : R.abort()), P.then(
9865
9972
  I,
9866
9973
  I
9867
- )), y;
9974
+ )), k;
9868
9975
  } catch (P) {
9869
- return delete y.v, y.e = P, ++y.n, y;
9976
+ return delete k.v, k.e = P, ++k.n, k;
9870
9977
  } finally {
9871
- 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));
9978
+ 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));
9872
9979
  }
9873
9980
  }), b = m[4] || ((A) => {
9874
9981
  const N = [A];
9875
9982
  for (; N.length; ) {
9876
- const S = N.pop(), y = h(S);
9877
- for (const j of getMountedOrPendingDependents(S, y, n)) {
9983
+ const C = N.pop(), k = h(C);
9984
+ for (const j of getMountedOrPendingDependents(C, k, n)) {
9878
9985
  const I = h(j);
9879
9986
  r.set(j, I.n), N.push(j);
9880
9987
  }
9881
9988
  }
9882
9989
  }), v = m[5] || ((A, ...N) => {
9883
- let S = !0;
9884
- const y = (I) => returnAtomValue(k(I)), j = (I, ...L) => {
9990
+ let C = !0;
9991
+ const k = (I) => returnAtomValue(y(I)), j = (I, ...L) => {
9885
9992
  var R;
9886
9993
  const T = h(I);
9887
9994
  try {
@@ -9894,43 +10001,43 @@ const RootLayout = () => {
9894
10001
  } else
9895
10002
  return v(I, ...L);
9896
10003
  } finally {
9897
- S || (f(), x());
10004
+ C || (f(), x());
9898
10005
  }
9899
10006
  };
9900
10007
  try {
9901
- return p(A, y, j, ...N);
10008
+ return p(A, k, j, ...N);
9902
10009
  } finally {
9903
- S = !1;
10010
+ C = !1;
9904
10011
  }
9905
10012
  }), B = m[6] || ((A) => {
9906
10013
  var N;
9907
- const S = h(A), y = n.get(A);
9908
- if (y && !isPendingPromise(S.v)) {
9909
- for (const [j, I] of S.d)
9910
- if (!y.d.has(j)) {
10014
+ const C = h(A), k = n.get(A);
10015
+ if (k && !isPendingPromise(C.v)) {
10016
+ for (const [j, I] of C.d)
10017
+ if (!k.d.has(j)) {
9911
10018
  const L = h(j);
9912
- 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));
10019
+ w(j).t.add(A), k.d.add(j), I !== L.n && (a.add(j), (N = c.c) == null || N.call(c, j), b(j));
9913
10020
  }
9914
- for (const j of y.d || [])
9915
- if (!S.d.has(j)) {
9916
- y.d.delete(j);
10021
+ for (const j of k.d || [])
10022
+ if (!C.d.has(j)) {
10023
+ k.d.delete(j);
9917
10024
  const I = _(j);
9918
10025
  I == null || I.t.delete(A);
9919
10026
  }
9920
10027
  }
9921
10028
  }), w = m[7] || ((A) => {
9922
10029
  var N;
9923
- const S = h(A);
9924
- let y = n.get(A);
9925
- if (!y) {
9926
- k(A);
9927
- for (const j of S.d.keys())
10030
+ const C = h(A);
10031
+ let k = n.get(A);
10032
+ if (!k) {
10033
+ y(A);
10034
+ for (const j of C.d.keys())
9928
10035
  w(j).t.add(A);
9929
- if (y = {
10036
+ if (k = {
9930
10037
  l: /* @__PURE__ */ new Set(),
9931
- d: new Set(S.d.keys()),
10038
+ d: new Set(C.d.keys()),
9932
10039
  t: /* @__PURE__ */ new Set()
9933
- }, n.set(A, y), (N = c.m) == null || N.call(c, A), isActuallyWritableAtom(A)) {
10040
+ }, n.set(A, k), (N = c.m) == null || N.call(c, A), isActuallyWritableAtom(A)) {
9934
10041
  const j = () => {
9935
10042
  let I = !0;
9936
10043
  const L = (...R) => {
@@ -9942,7 +10049,7 @@ const RootLayout = () => {
9942
10049
  };
9943
10050
  try {
9944
10051
  const R = g(A, L);
9945
- R && (y.u = () => {
10052
+ R && (k.u = () => {
9946
10053
  I = !0;
9947
10054
  try {
9948
10055
  R();
@@ -9957,23 +10064,23 @@ const RootLayout = () => {
9957
10064
  l.add(j);
9958
10065
  }
9959
10066
  }
9960
- return y;
10067
+ return k;
9961
10068
  }), _ = m[8] || ((A) => {
9962
10069
  var N;
9963
- const S = h(A);
9964
- let y = n.get(A);
9965
- if (y && !y.l.size && !Array.from(y.t).some((j) => {
10070
+ const C = h(A);
10071
+ let k = n.get(A);
10072
+ if (k && !k.l.size && !Array.from(k.t).some((j) => {
9966
10073
  var I;
9967
10074
  return (I = n.get(j)) == null ? void 0 : I.d.has(A);
9968
10075
  })) {
9969
- y.u && i.add(y.u), y = void 0, n.delete(A), (N = c.u) == null || N.call(c, A);
9970
- for (const j of S.d.keys()) {
10076
+ k.u && i.add(k.u), k = void 0, n.delete(A), (N = c.u) == null || N.call(c, A);
10077
+ for (const j of C.d.keys()) {
9971
10078
  const I = _(j);
9972
10079
  I == null || I.t.delete(A);
9973
10080
  }
9974
10081
  return;
9975
10082
  }
9976
- return y;
10083
+ return k;
9977
10084
  }), E = [
9978
10085
  // store state
9979
10086
  o,
@@ -9992,14 +10099,14 @@ const RootLayout = () => {
9992
10099
  h,
9993
10100
  x,
9994
10101
  f,
9995
- k,
10102
+ y,
9996
10103
  b,
9997
10104
  v,
9998
10105
  B,
9999
10106
  w,
10000
10107
  _
10001
- ], C = {
10002
- get: (A) => returnAtomValue(k(A)),
10108
+ ], S = {
10109
+ get: (A) => returnAtomValue(y(A)),
10003
10110
  set: (A, ...N) => {
10004
10111
  try {
10005
10112
  return v(A, ...N);
@@ -10008,13 +10115,13 @@ const RootLayout = () => {
10008
10115
  }
10009
10116
  },
10010
10117
  sub: (A, N) => {
10011
- const y = w(A).l;
10012
- return y.add(N), x(), () => {
10013
- y.delete(N), _(A), x();
10118
+ const k = w(A).l;
10119
+ return k.add(N), x(), () => {
10120
+ k.delete(N), _(A), x();
10014
10121
  };
10015
10122
  }
10016
10123
  };
10017
- return Object.defineProperty(C, BUILDING_BLOCKS, { value: E }), C;
10124
+ return Object.defineProperty(S, BUILDING_BLOCKS, { value: E }), S;
10018
10125
  }, INTERNAL_buildStoreRev1 = buildStore, createStore = () => INTERNAL_buildStoreRev1();
10019
10126
  let defaultStore;
10020
10127
  const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), defaultStore), StoreContext = createContext(
@@ -10132,7 +10239,7 @@ const useAutoSave = () => {
10132
10239
  /* @__PURE__ */ jsx(ChaiWatchers, { ...o }),
10133
10240
  /* @__PURE__ */ jsx(PreviewScreen, {}),
10134
10241
  /* @__PURE__ */ jsx(Toaster, { richColors: !0 }),
10135
- /* @__PURE__ */ jsx("div", { className: "fixed bottom-4 left-4 z-50", children: /* @__PURE__ */ jsx(ChaiFeatureFlagsWidget, {}) })
10242
+ /* @__PURE__ */ jsx(ChaiFeatureFlagsWidget, {})
10136
10243
  ] }) });
10137
10244
  };
10138
10245
  if (typeof window > "u")
@@ -10155,16 +10262,19 @@ export {
10155
10262
  ThemeConfigPanel as ChaiThemeConfigPanel,
10156
10263
  UILibrariesPanel as ChaiUILibrariesPanel,
10157
10264
  UndoRedo as ChaiUndoRedo,
10265
+ IfChaiFeatureFlag,
10158
10266
  PERMISSIONS,
10159
10267
  getBlocksFromHTML as convertHTMLToChaiBlocks,
10160
10268
  generateUUID as generateBlockId,
10161
10269
  getBlocksFromHTML,
10162
- We as i18n,
10270
+ ze as i18n,
10163
10271
  cn$2 as mergeClasses,
10164
10272
  registerBlockSettingField,
10165
10273
  registerBlockSettingTemplate,
10166
10274
  registerBlockSettingWidget,
10167
10275
  registerChaiAddBlockTab,
10276
+ registerChaiFeatureFlag,
10277
+ registerChaiFeatureFlags,
10168
10278
  registerChaiLibrary,
10169
10279
  registerChaiMediaManager,
10170
10280
  registerChaiSaveToLibrary,
@@ -10181,6 +10291,8 @@ export {
10181
10291
  useBuilderReset,
10182
10292
  useCanvasDisplayWidth,
10183
10293
  useCanvasZoom,
10294
+ useChaiFeatureFlag,
10295
+ useChaiFeatureFlags,
10184
10296
  useCodeEditor,
10185
10297
  useCopyBlocks as useCopyBlockIds,
10186
10298
  useCopyToClipboard,
@@ -10218,6 +10330,7 @@ export {
10218
10330
  useStylingState,
10219
10331
  useTheme,
10220
10332
  useThemeOptions,
10333
+ useToggleChaiFeatureFlag,
10221
10334
  Ve as useTranslation,
10222
10335
  useUndoManager,
10223
10336
  useUpdateBlocksProps,