@chaibuilder/sdk 3.0.28 → 3.0.29

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.
@@ -4,13 +4,13 @@ var F = (o, n, r) => W(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 { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, uniq, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, sortBy, round } from "lodash-es";
7
- import { SquareIcon, ChevronRightIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, CaretDownIcon, Cross1Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, ListBulletIcon, ValueIcon, TextAlignCenterIcon, TextAlignRightIcon, TextAlignLeftIcon, Link2Icon, LinkBreak2Icon, EnterFullScreenIcon, ExclamationTriangleIcon, Pencil2Icon, ChevronLeftIcon, LoopIcon, IdCardIcon, PlusCircledIcon, ChevronDownIcon, InfoCircledIcon, FileIcon, DotsVerticalIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, BoxIcon, MinusIcon, CrossCircledIcon, MobileIcon, LaptopIcon, DesktopIcon, ReloadIcon, CircleIcon, MagnifyingGlassIcon, CaretRightIcon, FrameIcon, CheckIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, DoubleArrowDownIcon, DoubleArrowUpIcon, ResetIcon, UploadIcon, TextIcon, CornerTopRightIcon, MixerHorizontalIcon, SunIcon, MoonIcon, FaceIcon, ShuffleIcon, ChatBubbleIcon, StopIcon, ImageIcon, PaperPlaneIcon, EraserIcon, LightningBoltIcon, ZoomInIcon, StackIcon } from "@radix-ui/react-icons";
7
+ import { SquareIcon, ChevronRightIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, CaretDownIcon, Cross1Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, ListBulletIcon, ValueIcon, TextAlignCenterIcon, TextAlignRightIcon, TextAlignLeftIcon, Link2Icon, LinkBreak2Icon, EnterFullScreenIcon, ExclamationTriangleIcon, Pencil2Icon, ChevronLeftIcon, LoopIcon, IdCardIcon, PlusCircledIcon, ChevronDownIcon, InfoCircledIcon, FileIcon, DotsVerticalIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, BoxIcon, MinusIcon, CrossCircledIcon, MobileIcon, LaptopIcon, DesktopIcon, ReloadIcon, CircleIcon, MagnifyingGlassIcon, CaretRightIcon, FrameIcon, CheckIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, DoubleArrowDownIcon, DoubleArrowUpIcon, ResetIcon, UploadIcon, TextIcon, CornerTopRightIcon, MixerHorizontalIcon, SunIcon, MoonIcon, FaceIcon, ShuffleIcon, ChatBubbleIcon, StopIcon, EraserIcon, LightningBoltIcon, ZoomInIcon, StackIcon } from "@radix-ui/react-icons";
8
8
  import * as React from "react";
9
9
  import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, lazy, useReducer, useDebugValue } from "react";
10
10
  import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
11
11
  import { atomWithStorage, splitAtom, useAtomCallback } from "jotai/utils";
12
12
  import { g as generateUUID, a as getBreakpointValue, c as cn$1 } from "./common-functions-BGzDsf1z.js";
13
- import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, at as Input$1, aW as Skeleton, d as Alert, e as AlertDescription, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, a9 as DialogTitle, av as Popover, b4 as Tooltip, b7 as TooltipTrigger, ay as PopoverTrigger, b5 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, B as Badge, b6 as TooltipProvider, 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, b1 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, aZ as Tabs, a$ as TabsList, b0 as TabsTrigger, a_ as TabsContent, a6 as DialogHeader, aX as Slider, aB as Select$1, aJ as SelectTrigger, aK as SelectValue, aC as SelectContent, aE as SelectItem, aL as Separator, aY as Switch, b8 as cn$2, r as Avatar, 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, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle } from "./tooltip-Bz2MxMHf.js";
13
+ import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, at as Input$1, aW as Skeleton, d as Alert, e as AlertDescription, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, a9 as DialogTitle, av as Popover, b4 as Tooltip, b7 as TooltipTrigger, ay as PopoverTrigger, b5 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, B as Badge, b6 as TooltipProvider, 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, b1 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, aZ as Tabs, a$ as TabsList, b0 as TabsTrigger, a_ as TabsContent, a6 as DialogHeader, aX as Slider, aB as Select$1, aJ as SelectTrigger, aK as SelectValue, aC as SelectContent, aE as SelectItem, aL as Separator, aY as Switch, 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, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle } from "./tooltip-4-b9QGDK.js";
14
14
  import clsx$1, { clsx } from "clsx";
15
15
  import { twMerge } from "tailwind-merge";
16
16
  import TreeModel from "tree-model";
@@ -45,9 +45,9 @@ import tailwindTypography from "@tailwindcss/typography";
45
45
  import "tailwindcss-animate";
46
46
  import "@mhsdesign/jit-browser-tailwindcss";
47
47
  import twContainer from "@tailwindcss/container-queries";
48
+ import { useHotkeys } from "react-hotkeys-hook";
48
49
  import { ErrorBoundary } from "react-error-boundary";
49
50
  import { motion } from "framer-motion";
50
- import { useHotkeys } from "react-hotkeys-hook";
51
51
  import { limitShift, flip, size } from "@floating-ui/dom";
52
52
  import { useFloating, shift } from "@floating-ui/react-dom";
53
53
  import { Provider as Provider$1 } from "react-wrap-balancer";
@@ -295,20 +295,20 @@ class PubSub {
295
295
  }
296
296
  }
297
297
  const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
298
- const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (m) => c ? get(m, "_parent") === c : !get(m, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (m) => {
299
- if (m === "CHILD")
298
+ const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (g) => c ? get(g, "_parent") === c : !get(g, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), m = (g) => {
299
+ if (g === "CHILD")
300
300
  pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
301
301
  else {
302
302
  const h = { _id: c || "", position: d == null ? void 0 : d.length };
303
- m === "BEFORE" ? h.position = Math.max(u, 0) : m === "AFTER" && (h.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, h);
303
+ g === "BEFORE" ? h.position = Math.max(u, 0) : g === "AFTER" && (h.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, h);
304
304
  }
305
305
  };
306
306
  return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
307
307
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { children: n }),
308
308
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-500 bg-primary text-white shadow-2xl", children: [
309
- p && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("CHILD"), children: r("Add inside") }),
310
- /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("BEFORE"), children: r("Add before") }),
311
- /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("AFTER"), children: r("Add after") })
309
+ p && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => m("CHILD"), children: r("Add inside") }),
310
+ /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => m("BEFORE"), children: r("Add before") }),
311
+ /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => m("AFTER"), children: r("Add after") })
312
312
  ] })
313
313
  ] }) : null;
314
314
  }, draggedBlockAtom = atom(null);
@@ -334,8 +334,8 @@ function insertBlocksAtPosition(o, n, r, a) {
334
334
  const l = [...n];
335
335
  let i = [...o];
336
336
  if (r) {
337
- const u = o.find((g) => g._id === r);
338
- if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
337
+ const u = o.find((m) => m._id === r);
338
+ if (u && u.content !== void 0 && u.content !== "" && !o.some((g) => g._parent === r)) {
339
339
  const h = {
340
340
  _id: generateUUID(),
341
341
  _parent: r,
@@ -359,13 +359,13 @@ function insertBlocksAtPosition(o, n, r, a) {
359
359
  r && (c = i.filter((u) => u._parent === r));
360
360
  const d = !isNaN(a) || a > -1 ? Math.min(a, c.length) : c.length;
361
361
  let p = i.length;
362
- for (let u = 0, g = 0; u < i.length; u++)
362
+ for (let u = 0, m = 0; u < i.length; u++)
363
363
  if (r !== void 0 ? i[u]._parent === r : !i[u]._parent) {
364
- if (g === d) {
364
+ if (m === d) {
365
365
  p = u;
366
366
  break;
367
367
  }
368
- g++;
368
+ m++;
369
369
  }
370
370
  return !r && a !== void 0 && a >= c.length && (p = i.length), [...i.slice(0, p), ...l, ...i.slice(p)];
371
371
  }
@@ -380,17 +380,17 @@ function findNodeById(o, n) {
380
380
  return o.first((r) => r.model._id === n) || null;
381
381
  }
382
382
  function moveNode(o, n, r, a) {
383
- var u, g;
383
+ var u, m;
384
384
  const l = findNodeById(o, n), i = findNodeById(o, r);
385
385
  if (!l || !i) return !1;
386
386
  i.children || (i.model.children = []);
387
- let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((m) => m.model._id === n);
387
+ let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((g) => g.model._id === n);
388
388
  l.drop(), c = Math.max(c, 0);
389
- const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === r && c <= a ? a - 1 : a;
389
+ const p = (((m = l == null ? void 0 : l.model) == null ? void 0 : m._parent) || "root") === r && c <= a ? a - 1 : a;
390
390
  try {
391
391
  i.addChildAtIndex(l, p);
392
- } catch (m) {
393
- return console.error("Error adding child to parent:", m), !1;
392
+ } catch (g) {
393
+ return console.error("Error adding child to parent:", g), !1;
394
394
  }
395
395
  return !0;
396
396
  }
@@ -430,10 +430,10 @@ function handleNewParentTextBlock(o, n, r) {
430
430
  });
431
431
  const d = o.map((u) => {
432
432
  if (u._id === r) {
433
- const g = { ...u, content: "" };
434
- return Object.keys(g).forEach((m) => {
435
- m.startsWith("content-") && (g[m] = "");
436
- }), g;
433
+ const m = { ...u, content: "" };
434
+ return Object.keys(m).forEach((g) => {
435
+ g.startsWith("content-") && (m[g] = "");
436
+ }), m;
437
437
  }
438
438
  return u;
439
439
  }), p = d.findIndex((u) => u._id === n._id);
@@ -449,8 +449,8 @@ function moveBlocksWithChildren(o, n, r, a) {
449
449
  const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
450
450
  if (moveNode(p, n, c, a)) {
451
451
  let u = flattenTree(p);
452
- const g = u.find((m) => m._id === n);
453
- return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
452
+ const m = u.find((g) => g._id === n);
453
+ return m && (m._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
454
454
  }
455
455
  return i;
456
456
  }
@@ -473,22 +473,22 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
473
473
  }, removeNestedBlocks = (o, n) => {
474
474
  let r = [...o], a = [];
475
475
  n.forEach((d) => {
476
- const p = r.find((m) => m._id === d);
476
+ const p = r.find((g) => g._id === d);
477
477
  if (!p || !p._parent) return;
478
- const u = p._parent, g = r.filter((m) => m._parent === u);
479
- if (g.length === 2) {
480
- const m = g.find((h) => h._id !== d);
481
- if (m && m._type === "Text") {
478
+ const u = p._parent, m = r.filter((g) => g._parent === u);
479
+ if (m.length === 2) {
480
+ const g = m.find((h) => h._id !== d);
481
+ if (g && g._type === "Text") {
482
482
  const h = r.find((f) => f._id === u);
483
483
  h && "content" in h && (r = r.map((f) => {
484
484
  if (f._id === u) {
485
- const x = { ...f, content: m.content };
486
- return Object.keys(m).forEach((b) => {
487
- b.startsWith("content-") && (x[b] = m[b]);
485
+ const x = { ...f, content: g.content };
486
+ return Object.keys(g).forEach((b) => {
487
+ b.startsWith("content-") && (x[b] = g[b]);
488
488
  }), x;
489
489
  }
490
490
  return f;
491
- }), a.push(m._id));
491
+ }), a.push(g._id));
492
492
  }
493
493
  }
494
494
  });
@@ -551,7 +551,7 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
551
551
  for (let p = 0; p < a.length; p++)
552
552
  d = moveBlocksWithChildren(d, a[p], l, i);
553
553
  return each(a, (p) => {
554
- const u = find(d, (g) => g._id === p);
554
+ const u = find(d, (m) => m._id === p);
555
555
  u && r({ id: p, props: { _parent: u._parent || null } });
556
556
  }), n({ type: "blocks-updated", blocks: d }), d;
557
557
  });
@@ -570,7 +570,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
570
570
  status: "idle",
571
571
  props: {},
572
572
  error: void 0
573
- }), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), m = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
573
+ }), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), m = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), g = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
574
574
  return useEffect(() => {
575
575
  if (n === "mock") {
576
576
  if (isFunction(a)) {
@@ -582,8 +582,8 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
582
582
  }
583
583
  return;
584
584
  }
585
- n === "live" && (!g && !m || (i((f) => ({ ...f, status: "loading", props: {} })), d({ block: o }).then((f = {}) => {
586
- g ? (p((x) => ({
585
+ n === "live" && (!m && !g || (i((f) => ({ ...f, status: "loading", props: {} })), d({ block: o }).then((f = {}) => {
586
+ m ? (p((x) => ({
587
587
  ...x,
588
588
  [o._id]: {
589
589
  status: "loaded",
@@ -592,12 +592,12 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
592
592
  }
593
593
  })), i((x) => ({ ...x, status: "loaded", props: { totalItems: get(f, "totalItems") } })), c([o._id], { totalItems: get(f, "totalItems") })) : i((x) => ({ ...x, status: "loaded", props: isObject(f) ? f : {} }));
594
594
  }).catch((f) => {
595
- g ? (p((x) => ({
595
+ m ? (p((x) => ({
596
596
  ...x,
597
597
  [o._id]: { status: "error", error: f, props: [] }
598
598
  })), i((x) => ({ ...x, status: "error", error: f, props: {} }))) : i((x) => ({ ...x, status: "error", error: f, props: {} }));
599
599
  })));
600
- }, [o == null ? void 0 : o._id, u, g, m, a, n]), {
600
+ }, [o == null ? void 0 : o._id, u, m, g, a, n]), {
601
601
  $loading: get(l, "status") === "loading",
602
602
  ...o ? get(l, "props", {}) : {}
603
603
  };
@@ -751,7 +751,7 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
751
751
  }
752
752
  }) : !1, useSavePage = () => {
753
753
  const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (f) => {
754
- }), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), [u] = useIsPageLoaded(), g = () => {
754
+ }), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), [u] = useIsPageLoaded(), m = () => {
755
755
  const f = l();
756
756
  return !d || d === p ? !1 : checkMissingTranslations(f.blocks || [], d);
757
757
  };
@@ -765,7 +765,7 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
765
765
  autoSave: f,
766
766
  blocks: x.blocks,
767
767
  theme: i,
768
- needTranslations: g()
768
+ needTranslations: m()
769
769
  }), setTimeout(() => {
770
770
  n("SAVED"), a("SAVED");
771
771
  }, 100), !0;
@@ -782,11 +782,11 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
782
782
  autoSave: !0,
783
783
  blocks: f.blocks,
784
784
  theme: i,
785
- needTranslations: g()
785
+ needTranslations: m()
786
786
  }), setTimeout(() => {
787
787
  n("SAVED"), a("SAVED");
788
788
  }, 100), !0;
789
- }, saveState: o, setSaveState: n, needTranslations: g };
789
+ }, saveState: o, setSaveState: n, needTranslations: m };
790
790
  }, undoManager = new UndoManager();
791
791
  undoManager.setLimit(50);
792
792
  const undoRedoStateAtom = atom({
@@ -840,12 +840,12 @@ const undoRedoStateAtom = atom({
840
840
  return {
841
841
  moveBlocks: (x, b, y) => {
842
842
  const S = map(x, (B) => {
843
- const w = n.find((I) => I._id === B)._parent || null, k = n.filter((I) => w ? I._parent === w : !I._parent).map((I) => I._id).indexOf(B);
844
- return { _id: B, oldParent: w, oldPosition: k };
845
- }), C = S.find(({ _id: B }) => B === x[0]);
846
- C && C.oldParent === b && C.oldPosition === y || (i(x, b, y), o({
847
- undo: () => each(S, ({ _id: B, oldParent: _, oldPosition: w }) => {
848
- i([B], _, w);
843
+ const j = n.find((I) => I._id === B)._parent || null, k = n.filter((I) => j ? I._parent === j : !I._parent).map((I) => I._id).indexOf(B);
844
+ return { _id: B, oldParent: j, oldPosition: k };
845
+ }), v = S.find(({ _id: B }) => B === x[0]);
846
+ v && v.oldParent === b && v.oldPosition === y || (i(x, b, y), o({
847
+ undo: () => each(S, ({ _id: B, oldParent: _, oldPosition: j }) => {
848
+ i([B], _, j);
849
849
  }),
850
850
  redo: () => i(x, b, y)
851
851
  }));
@@ -857,8 +857,8 @@ const undoRedoStateAtom = atom({
857
857
  });
858
858
  },
859
859
  removeBlocks: (x) => {
860
- var C;
861
- const b = (C = first(x)) == null ? void 0 : C._parent, S = n.filter((B) => b ? B._parent === b : !B._parent).indexOf(first(x));
860
+ var v;
861
+ const b = (v = first(x)) == null ? void 0 : v._parent, S = n.filter((B) => b ? B._parent === b : !B._parent).indexOf(first(x));
862
862
  l(map(x, "_id")), o({
863
863
  undo: () => a(x, b, S),
864
864
  redo: () => l(map(x, "_id"))
@@ -867,17 +867,17 @@ const undoRedoStateAtom = atom({
867
867
  updateBlocks: (x, b, y) => {
868
868
  let S = [];
869
869
  if (y)
870
- S = map(x, (C) => ({ _id: C, ...y }));
870
+ S = map(x, (v) => ({ _id: v, ...y }));
871
871
  else {
872
- const C = keys(b);
872
+ const v = keys(b);
873
873
  S = map(x, (B) => {
874
- const _ = n.find((v) => v._id === B), w = { _id: B };
875
- return each(C, (v) => w[v] = _[v]), w;
874
+ const _ = n.find((C) => C._id === B), j = { _id: B };
875
+ return each(v, (C) => j[C] = _[C]), j;
876
876
  });
877
877
  }
878
- c(map(x, (C) => ({ _id: C, ...b }))), o({
878
+ c(map(x, (v) => ({ _id: v, ...b }))), o({
879
879
  undo: () => c(S),
880
- redo: () => c(map(x, (C) => ({ _id: C, ...b })))
880
+ redo: () => c(map(x, (v) => ({ _id: v, ...b })))
881
881
  });
882
882
  },
883
883
  updateBlocksRuntime: (x, b) => {
@@ -892,8 +892,8 @@ const undoRedoStateAtom = atom({
892
892
  updateMultipleBlocksProps: (x) => {
893
893
  let b = [];
894
894
  b = map(x, (y) => {
895
- const S = keys(y), C = n.find((_) => _._id === y._id), B = {};
896
- return each(S, (_) => B[_] = C[_]), B;
895
+ const S = keys(y), v = n.find((_) => _._id === y._id), B = {};
896
+ return each(S, (_) => B[_] = v[_]), B;
897
897
  }), c(x), o({
898
898
  undo: () => c(b),
899
899
  redo: () => c(x)
@@ -912,8 +912,8 @@ const undoRedoStateAtom = atom({
912
912
  b[y]._parent = i[f]._id;
913
913
  }
914
914
  const p = first(i);
915
- let u, g;
916
- return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(h = first(i)) == null ? void 0 : h._id]), first(i);
915
+ let u, m;
916
+ return c && (u = find(o, { _id: c }), i[0]._parent = c, m = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, m = u._parent), r(i, m, d), n([(h = first(i)) == null ? void 0 : h._id]), first(i);
917
917
  },
918
918
  [r, o, n]
919
919
  );
@@ -923,15 +923,15 @@ const undoRedoStateAtom = atom({
923
923
  const b = i.blocks;
924
924
  return a(b, c, d);
925
925
  }
926
- const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
926
+ const p = generateUUID(), u = getDefaultBlockProps(i.type), m = {
927
927
  _type: i.type,
928
928
  _id: p,
929
929
  ...u,
930
930
  ...has(i, "_name") && { _name: i._name },
931
931
  ...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
932
932
  };
933
- let m, h;
934
- return c && (m = find(o, { _id: c }), g._parent = c, h = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, h = m._parent), r([g], h, d), n([g._id]), g;
933
+ let g, h;
934
+ return c && (g = find(o, { _id: c }), m._parent = c, h = c), !canAcceptChildBlock(g == null ? void 0 : g._type, m._type) && g && (m._parent = g._parent, h = g._parent), r([m], h, d), n([m._id]), m;
935
935
  },
936
936
  [r, a, o, n]
937
937
  ), addPredefinedBlock: a };
@@ -2042,7 +2042,7 @@ function removeDuplicateClasses(o) {
2042
2042
  for (const l of r) {
2043
2043
  const i = l.property, c = n.indexOf(l.mq);
2044
2044
  for (let d = c + 1; d < n.length; d++) {
2045
- const p = n[d], u = r.find((g) => g.property === i && g.mq === p);
2045
+ const p = n[d], u = r.find((m) => m.property === i && m.mq === p);
2046
2046
  if (u && u.cls === l.cls)
2047
2047
  a = a.replace(u.fullCls, "");
2048
2048
  else if (u && u.cls !== l.cls)
@@ -2315,7 +2315,7 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), add
2315
2315
  let p = "";
2316
2316
  o([n], { [i]: "" });
2317
2317
  for (let u = 0; u < d.length; u++)
2318
- p += d[u].join(""), o([n], { [i]: p }), await new Promise((g) => setTimeout(g, a));
2318
+ p += d[u].join(""), o([n], { [i]: p }), await new Promise((m) => setTimeout(m, a));
2319
2319
  }
2320
2320
  }
2321
2321
  },
@@ -2356,19 +2356,19 @@ const getBlockWithChildren = (o, n) => {
2356
2356
  const l = ["_id", "_type", "_parent"], i = pick(a, l), c = getRegisteredChaiBlock(a._type), d = {}, p = get(c, "aiProps", []);
2357
2357
  for (const u in a)
2358
2358
  if (!l.includes(u) && p.includes(u)) {
2359
- const g = get(a, `${u}-${n}`, ""), m = get(a, u, "");
2360
- d[u] = isString(g) && g.trim() || m, r && (d[u] = m);
2359
+ const m = get(a, `${u}-${n}`, ""), g = get(a, u, "");
2360
+ d[u] = isString(m) && m.trim() || g, r && (d[u] = g);
2361
2361
  }
2362
2362
  return isEmpty(d) ? !1 : (has(i, "_parent") && isEmpty(i._parent) && delete i._parent, { ...i, ...d });
2363
2363
  })
2364
2364
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2365
- 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, f) => {
2365
+ 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(), m = p.length ? p : u, g = (h, f) => {
2366
2366
  const x = cloneDeep(f.find((b) => b._id === h));
2367
2367
  for (const b in x) {
2368
2368
  const y = x[b];
2369
2369
  if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
2370
- const { baseClasses: S, classes: C } = getSplitChaiClasses(y);
2371
- x[b] = compact(flattenDeep([S, C])).join(" ");
2370
+ const { baseClasses: S, classes: v } = getSplitChaiClasses(y);
2371
+ x[b] = compact(flattenDeep([S, v])).join(" ");
2372
2372
  } else
2373
2373
  b !== "_id" && delete x[b];
2374
2374
  }
@@ -2380,18 +2380,18 @@ const getBlockWithChildren = (o, n) => {
2380
2380
  if (l) {
2381
2381
  n(!0), a(null);
2382
2382
  try {
2383
- const y = p === u ? "" : p, S = x.toLowerCase().includes("translate the content"), C = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p, S) : [m(f, d)], B = await l(h, addLangToPrompt(x, g, h), C, y), { blocks: _, error: w } = B;
2384
- if (w) {
2385
- a(w);
2383
+ const y = p === u ? "" : p, S = x.toLowerCase().includes("translate the content"), v = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p, S) : [g(f, d)], B = await l(h, addLangToPrompt(x, m, h), v, y), { blocks: _, error: j } = B;
2384
+ if (j) {
2385
+ a(j);
2386
2386
  return;
2387
2387
  }
2388
2388
  if (h === "styles") {
2389
- const v = _.map((k) => {
2389
+ const C = _.map((k) => {
2390
2390
  for (const I in k)
2391
2391
  I !== "_id" && (k[I] = `${STYLES_KEY},${k[I]}`);
2392
2392
  return k;
2393
2393
  });
2394
- c(v);
2394
+ c(C);
2395
2395
  } else
2396
2396
  i(_);
2397
2397
  b && b(B);
@@ -2408,7 +2408,7 @@ const getBlockWithChildren = (o, n) => {
2408
2408
  p,
2409
2409
  u,
2410
2410
  d,
2411
- g,
2411
+ m,
2412
2412
  c,
2413
2413
  i
2414
2414
  ]
@@ -2471,7 +2471,7 @@ const getBlockWithChildren = (o, n) => {
2471
2471
  return [o, a];
2472
2472
  }, copiedBlockIdsAtom = atom([]), useCopyBlocks = () => {
2473
2473
  const [o] = useBlocksStore(), [n, r] = useAtom$1(copiedBlockIdsAtom), a = useSetAtom$1(cutBlockIdsAtom), { getPartailBlocks: l } = usePartialBlocksStore(), i = useCallback(
2474
- (d) => d.some((p) => getDuplicatedBlocks(o, p, null).some((g) => g._type === "PartialBlock" || g._type === "GlobalBlock")),
2474
+ (d) => d.some((p) => getDuplicatedBlocks(o, p, null).some((m) => m._type === "PartialBlock" || m._type === "GlobalBlock")),
2475
2475
  [o]
2476
2476
  ), c = useCallback(
2477
2477
  async (d, p = !1) => {
@@ -2479,12 +2479,12 @@ const getBlockWithChildren = (o, n) => {
2479
2479
  if (isEmpty(d)) return;
2480
2480
  r(d), a([]);
2481
2481
  const u = {
2482
- _chai_copied_blocks: d.flatMap((g) => {
2483
- const m = getDuplicatedBlocks(o, g, null);
2482
+ _chai_copied_blocks: d.flatMap((m) => {
2483
+ const g = getDuplicatedBlocks(o, m, null);
2484
2484
  if (!p)
2485
- return m;
2485
+ return g;
2486
2486
  let h = [];
2487
- for (const f of m)
2487
+ for (const f of g)
2488
2488
  if (f._type === "PartialBlock" || f._type === "GlobalBlock") {
2489
2489
  let x = l(f.partialBlockId);
2490
2490
  f._parent && (x == null ? void 0 : x.length) > 0 && (x = x.map((b) => (isEmpty(b._parent) && set(b, "_parent", f._parent), b))), h = [...h, ...x];
@@ -2530,11 +2530,11 @@ const getBlockWithChildren = (o, n) => {
2530
2530
  each(a, (c) => {
2531
2531
  const d = o.find((h) => h._id === c);
2532
2532
  l ? l === "root" && (l = null) : l = d._parent;
2533
- const g = filter(
2533
+ const m = filter(
2534
2534
  o,
2535
2535
  (h) => isString(l) ? h._parent === l : !h._parent
2536
- ).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
2537
- r(m, l, g), i.push(get(m, "0._id", ""));
2536
+ ).indexOf(d) + 1, g = getDuplicatedBlocks(o, c, l);
2537
+ r(g, l, m), i.push(get(g, "0._id", ""));
2538
2538
  }), n(i);
2539
2539
  },
2540
2540
  [o, n]
@@ -2662,19 +2662,19 @@ const getBlockWithChildren = (o, n) => {
2662
2662
  );
2663
2663
  return map(i, (c) => {
2664
2664
  const d = o(c), p = a;
2665
- let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
2666
- return each(p, (m) => {
2667
- const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2665
+ let { classes: u, baseClasses: m } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
2666
+ return each(p, (g) => {
2667
+ const h = g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2668
2668
  u = u.replace(f, " ").replace(/\s+/g, " ").trim();
2669
- const x = first(m.split(":"));
2670
- includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
2671
- }), each(p, (m) => {
2672
- const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2673
- g = g.replace(f, " ").replace(/\s+/g, " ").trim();
2669
+ const x = first(g.split(":"));
2670
+ includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(g.split(":").pop().trim());
2671
+ }), each(p, (g) => {
2672
+ const h = g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2673
+ m = m.replace(f, " ").replace(/\s+/g, " ").trim();
2674
2674
  }), {
2675
2675
  ids: [d._id],
2676
2676
  props: {
2677
- [l.prop]: `${STYLES_KEY}${g},${u}`
2677
+ [l.prop]: `${STYLES_KEY}${m},${u}`
2678
2678
  }
2679
2679
  };
2680
2680
  });
@@ -2799,14 +2799,18 @@ const useInlineEditing = () => {
2799
2799
  setEditingBlockId: n,
2800
2800
  setEditingItemIndex: a
2801
2801
  };
2802
+ }, getAllDescendantIds = (o, n) => {
2803
+ const r = o.filter((i) => i._parent === n), a = r.map((i) => i._id), l = r.flatMap((i) => getAllDescendantIds(o, i._id));
2804
+ return [...a, ...l];
2802
2805
  }, replaceBlock = (o, n, r) => {
2803
2806
  const a = find(o, { _id: n });
2804
2807
  if (!a) return o;
2805
- const l = a._parent, i = r.map((d) => ({
2806
- ...d,
2807
- _parent: l
2808
- }));
2809
- return [...filter(o, (d) => d._id !== n && d._parent !== n), ...i];
2808
+ const l = o.findIndex((g) => g._id === n), i = getAllDescendantIds(o, n), c = /* @__PURE__ */ new Set([n, ...i]), d = o.filter((g) => !c.has(g._id)), p = new Set(r.map((g) => g._id)), u = r.map((g) => !g._parent || !p.has(g._parent) ? { ...g, _parent: a._parent } : g);
2809
+ return [
2810
+ ...d.slice(0, l),
2811
+ ...u,
2812
+ ...d.slice(l)
2813
+ ];
2810
2814
  }, useReplaceBlock = () => {
2811
2815
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { setNewBlocks: r } = useBlocksStoreUndoableActions(), { hasPermission: a } = usePermissions();
2812
2816
  return useCallback(
@@ -2837,11 +2841,11 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2837
2841
  return "VERTICAL";
2838
2842
  }
2839
2843
  }, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
2840
- const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), f = useCallback(
2844
+ const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), m = u <= 0, g = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), f = useCallback(
2841
2845
  (x) => {
2842
- isDisabledControl(g, m, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
2846
+ isDisabledControl(m, g, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
2843
2847
  },
2844
- [g, m, p, u, i, c, n]
2848
+ [m, g, p, u, i, c, n]
2845
2849
  );
2846
2850
  return useHotkeys(
2847
2851
  "shift+up, shift+down, shift+left, shift+right",
@@ -2851,7 +2855,7 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2851
2855
  },
2852
2856
  { document: a == null ? void 0 : a.contentDocument },
2853
2857
  [f]
2854
- ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation: h };
2858
+ ), { isOnlyChild: p, isFirstBlock: m, isLastBlock: g, moveBlock: f, orientation: h };
2855
2859
  }, BlockController = ({ block: o, updateFloatingBar: n }) => {
2856
2860
  const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
2857
2861
  o,
@@ -2859,12 +2863,12 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2859
2863
  );
2860
2864
  return r ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => {
2861
2865
  if (c !== p) return null;
2862
- const g = isDisabledControl(a, l, u);
2863
- return g ? null : /* @__PURE__ */ jsx(
2866
+ const m = isDisabledControl(a, l, u);
2867
+ return m ? null : /* @__PURE__ */ jsx(
2864
2868
  d,
2865
2869
  {
2866
2870
  onClick: () => i(u),
2867
- className: `${g ? "pointer-events-none cursor-not-allowed opacity-50" : "duration-300 hover:scale-95 hover:opacity-80"}`
2871
+ className: `${m ? "pointer-events-none cursor-not-allowed opacity-50" : "duration-300 hover:scale-95 hover:opacity-80"}`
2868
2872
  },
2869
2873
  u
2870
2874
  );
@@ -2991,7 +2995,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
2991
2995
  i([null]);
2992
2996
  }, [r, n]), /* @__PURE__ */ jsx(BlockFloatingSelector, { block: o, selectedBlockElement: a[0] });
2993
2997
  }, BlockFloatingSelector = ({ block: o, selectedBlockElement: n }) => {
2994
- const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: u } = useFrame(), { floatingStyles: g, refs: m, update: h } = useFloating({
2998
+ const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: u } = useFrame(), { floatingStyles: m, refs: g, update: h } = useFloating({
2995
2999
  placement: "top-start",
2996
3000
  middleware: [
2997
3001
  shift({
@@ -3031,8 +3035,8 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3031
3035
  {
3032
3036
  role: "button",
3033
3037
  tabIndex: 0,
3034
- ref: m.setFloating,
3035
- style: g,
3038
+ ref: g.setFloating,
3039
+ style: m,
3036
3040
  onClick: (b) => {
3037
3041
  b.stopPropagation(), b.preventDefault();
3038
3042
  },
@@ -3258,7 +3262,7 @@ F(Frame, "defaultProps", {
3258
3262
  initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
3259
3263
  });
3260
3264
  const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: n })), useKeyEventWatcher = (o) => {
3261
- const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), h = o ? { document: o } : {};
3265
+ const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: m, pasteBlocks: g } = usePasteBlocks(), h = o ? { document: o } : {};
3262
3266
  useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys(
3263
3267
  "ctrl+c,command+c",
3264
3268
  () => u(n),
@@ -3267,10 +3271,10 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3267
3271
  ), useHotkeys(
3268
3272
  "ctrl+v,command+v",
3269
3273
  () => {
3270
- g(n[0]) && m(n);
3274
+ m(n[0]) && g(n);
3271
3275
  },
3272
3276
  { ...h, enabled: !isEmpty(n), preventDefault: !0 },
3273
- [n, g, m]
3277
+ [n, m, g]
3274
3278
  ), useHotkeys("esc", () => r([]), h, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...h, enabled: !isEmpty(n), preventDefault: !0 }, [
3275
3279
  n,
3276
3280
  i
@@ -3478,28 +3482,28 @@ const RteDropdownMenu = ({
3478
3482
  from: a,
3479
3483
  menuRef: l
3480
3484
  }) => {
3481
- const { document: i } = useFrame(), [c, d] = useState({ left: void 0, right: void 0, top: void 0, bottom: void 0 }), [p, u] = useState(!1), g = useRef(null);
3485
+ const { document: i } = useFrame(), [c, d] = useState({ left: void 0, right: void 0, top: void 0, bottom: void 0 }), [p, u] = useState(!1), m = useRef(null);
3482
3486
  if (useEffect(() => {
3483
- var S, C;
3487
+ var S, v;
3484
3488
  if (!p) {
3485
3489
  d({ left: void 0, right: void 0, top: void 0, bottom: void 0 });
3486
3490
  return;
3487
3491
  }
3488
- const m = (S = g.current) == null ? void 0 : S.getBoundingClientRect(), h = (C = l.current) == null ? void 0 : C.getBoundingClientRect();
3489
- let f = m == null ? void 0 : m.left, x = (m == null ? void 0 : m.bottom) + 4, b, y;
3490
- (h == null ? void 0 : h.left) + (h == null ? void 0 : h.width) + 50 >= i.body.offsetWidth && (f = void 0, b = i.body.offsetWidth - (m == null ? void 0 : m.right)), x + 202 >= i.body.clientHeight && (x = null, y = i.body.clientHeight - (m == null ? void 0 : m.bottom) + (h == null ? void 0 : h.height)), d({ left: f, top: x, right: b, bottom: y });
3492
+ const g = (S = m.current) == null ? void 0 : S.getBoundingClientRect(), h = (v = l.current) == null ? void 0 : v.getBoundingClientRect();
3493
+ let f = g == null ? void 0 : g.left, x = (g == null ? void 0 : g.bottom) + 4, b, y;
3494
+ (h == null ? void 0 : h.left) + (h == null ? void 0 : h.width) + 50 >= i.body.offsetWidth && (f = void 0, b = i.body.offsetWidth - (g == null ? void 0 : g.right)), x + 202 >= i.body.clientHeight && (x = null, y = i.body.clientHeight - (g == null ? void 0 : g.bottom) + (h == null ? void 0 : h.height)), d({ left: f, top: x, right: b, bottom: y });
3491
3495
  }, [p]), a === "canvas") {
3492
- const m = () => {
3496
+ const g = () => {
3493
3497
  u(!1), o && (o == null || o.view.focus(), o == null || o.chain().focus().run());
3494
3498
  };
3495
3499
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3496
- /* @__PURE__ */ jsx("div", { ref: g, onClick: () => u((h) => !h), className: "cursor-pointer", children: n }),
3500
+ /* @__PURE__ */ jsx("div", { ref: m, onClick: () => u((h) => !h), className: "cursor-pointer", children: n }),
3497
3501
  p && (c.left !== void 0 || c.top !== void 0 || c.right !== void 0 || c.bottom !== void 0) && createPortal(
3498
3502
  /* @__PURE__ */ jsx(
3499
3503
  "div",
3500
3504
  {
3501
3505
  id: "chaibuilder-rte-dropdown-menu-content",
3502
- onClick: m,
3506
+ onClick: g,
3503
3507
  className: "fixed inset-0 left-0 top-0 z-[10001] h-full w-screen",
3504
3508
  children: /* @__PURE__ */ jsx(
3505
3509
  "div",
@@ -3510,7 +3514,7 @@ const RteDropdownMenu = ({
3510
3514
  {},
3511
3515
  { left: c.left, top: c.top, right: c.right, bottom: c.bottom }
3512
3516
  ),
3513
- children: typeof r == "function" ? r(m) : r
3517
+ children: typeof r == "function" ? r(g) : r
3514
3518
  }
3515
3519
  )
3516
3520
  }
@@ -3594,13 +3598,13 @@ const getActiveClasses$1 = (o, n, r) => {
3594
3598
  onRemoveHighlightColor: i,
3595
3599
  onClose: c
3596
3600
  }) => {
3597
- const [d] = useDarkMode(), [p] = useAtom$1(lsThemeAtom), u = (p == null ? void 0 : p.colors) || {}, g = Object.values(u).map((f) => get(f, d ? "1" : "0")), [m, h] = useState("TEXT");
3601
+ const [d] = useDarkMode(), [p] = useAtom$1(lsThemeAtom), u = (p == null ? void 0 : p.colors) || {}, m = Object.values(u).map((f) => get(f, d ? "1" : "0")), [g, h] = useState("TEXT");
3598
3602
  return /* @__PURE__ */ jsxs("div", { id: "rte-widget-color-picker", className: "px-1", children: [
3599
3603
  /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center justify-between rounded-md border bg-muted", children: [
3600
3604
  /* @__PURE__ */ jsx(
3601
3605
  "div",
3602
3606
  {
3603
- className: `w-full cursor-pointer rounded p-0.5 text-center ${m === "TEXT" ? "bg-blue-500 text-white" : "hover:bg-blue-100 hover:text-blue-500"}`,
3607
+ className: `w-full cursor-pointer rounded p-0.5 text-center ${g === "TEXT" ? "bg-blue-500 text-white" : "hover:bg-blue-100 hover:text-blue-500"}`,
3604
3608
  onClick: () => h("TEXT"),
3605
3609
  children: "Text Color"
3606
3610
  }
@@ -3608,16 +3612,16 @@ const getActiveClasses$1 = (o, n, r) => {
3608
3612
  /* @__PURE__ */ jsx(
3609
3613
  "div",
3610
3614
  {
3611
- className: `w-full cursor-pointer rounded p-0.5 text-center ${m === "HIGHLIGHT" ? "bg-blue-500 text-white" : "hover:bg-blue-100 hover:text-blue-500"}`,
3615
+ className: `w-full cursor-pointer rounded p-0.5 text-center ${g === "HIGHLIGHT" ? "bg-blue-500 text-white" : "hover:bg-blue-100 hover:text-blue-500"}`,
3612
3616
  onClick: () => h("HIGHLIGHT"),
3613
3617
  children: "Highlight Color"
3614
3618
  }
3615
3619
  )
3616
3620
  ] }),
3617
- m === "TEXT" ? /* @__PURE__ */ jsx(
3621
+ g === "TEXT" ? /* @__PURE__ */ jsx(
3618
3622
  Commons,
3619
3623
  {
3620
- themeColors: g,
3624
+ themeColors: m,
3621
3625
  onClose: c,
3622
3626
  onChange: r,
3623
3627
  color: o,
@@ -3626,7 +3630,7 @@ const getActiveClasses$1 = (o, n, r) => {
3626
3630
  ) : /* @__PURE__ */ jsx(
3627
3631
  Commons,
3628
3632
  {
3629
- themeColors: g,
3633
+ themeColors: m,
3630
3634
  onClose: c,
3631
3635
  onChange: a,
3632
3636
  color: n,
@@ -3635,11 +3639,11 @@ const getActiveClasses$1 = (o, n, r) => {
3635
3639
  )
3636
3640
  ] });
3637
3641
  }, RteColorPicker = ({ editor: o, from: n, menuRef: r }) => {
3638
- var C, B;
3639
- const a = (C = o == null ? void 0 : o.getAttributes("textStyle")) == null ? void 0 : C.color, l = (B = o == null ? void 0 : o.getAttributes("highlight")) == null ? void 0 : B.color, [i, c] = useState(a || "#000000F2"), [d, p] = useState(l || "#00000057"), [u, g] = useDebouncedState(i, 150), [m, h] = useDebouncedState(d, 150), f = (_, w) => {
3640
- w ? (c(_), g(_)) : (o == null || o.chain().setColor(_).run(), c(_));
3641
- }, x = (_, w) => {
3642
- w ? (p(_), h(_)) : (o == null || o.chain().setHighlight({ color: _ }).run(), p(_));
3642
+ var v, B;
3643
+ const a = (v = o == null ? void 0 : o.getAttributes("textStyle")) == null ? void 0 : v.color, l = (B = o == null ? void 0 : o.getAttributes("highlight")) == null ? void 0 : B.color, [i, c] = useState(a || "#000000F2"), [d, p] = useState(l || "#00000057"), [u, m] = useDebouncedState(i, 150), [g, h] = useDebouncedState(d, 150), f = (_, j) => {
3644
+ j ? (c(_), m(_)) : (o == null || o.chain().setColor(_).run(), c(_));
3645
+ }, x = (_, j) => {
3646
+ j ? (p(_), h(_)) : (o == null || o.chain().setHighlight({ color: _ }).run(), p(_));
3643
3647
  }, b = () => {
3644
3648
  o == null || o.chain().unsetColor().run(), c("#000000F2");
3645
3649
  }, y = () => {
@@ -3648,8 +3652,8 @@ const getActiveClasses$1 = (o, n, r) => {
3648
3652
  return useEffect(() => {
3649
3653
  l && p(l);
3650
3654
  }, [l]), useEffect(() => {
3651
- m != null && m.includes("#") && (m == null ? void 0 : m.length) >= 3 && (o == null || o.chain().setHighlight({ color: m }).run());
3652
- }, [m]), useEffect(() => {
3655
+ g != null && g.includes("#") && (g == null ? void 0 : g.length) >= 3 && (o == null || o.chain().setHighlight({ color: g }).run());
3656
+ }, [g]), useEffect(() => {
3653
3657
  u != null && u.includes("#") && (u == null ? void 0 : u.length) >= 3 && (o == null || o.chain().setColor(u).run());
3654
3658
  }, [u]), /* @__PURE__ */ jsx(
3655
3659
  RteDropdownMenu,
@@ -3946,9 +3950,9 @@ const RichTextEditor = memo(
3946
3950
  blockId: "active-inline-editing-element",
3947
3951
  placeholder: "Enter text here",
3948
3952
  onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
3949
- onBlur: ({ editor: u, event: g }) => {
3950
- const m = g == null ? void 0 : g.relatedTarget, h = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = i.querySelector("#chai-rich-text-menu-bar"), b = h == null ? void 0 : h.contains(m), y = f == null ? void 0 : f.contains(m), S = x == null ? void 0 : x.contains(m), C = window.document.getElementById("rte-widget-color-picker");
3951
- if (!b && !y && !S && !C) {
3953
+ onBlur: ({ editor: u, event: m }) => {
3954
+ const g = m == null ? void 0 : m.relatedTarget, h = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = i.querySelector("#chai-rich-text-menu-bar"), b = h == null ? void 0 : h.contains(g), y = f == null ? void 0 : f.contains(g), S = x == null ? void 0 : x.contains(g), v = window.document.getElementById("rte-widget-color-picker");
3955
+ if (!b && !y && !S && !v) {
3952
3956
  const B = (u == null ? void 0 : u.getHTML()) || "";
3953
3957
  r(B);
3954
3958
  }
@@ -3956,20 +3960,20 @@ const RichTextEditor = memo(
3956
3960
  from: "canvas"
3957
3961
  });
3958
3962
  useEffect(() => {
3959
- var g, m;
3963
+ var m, g;
3960
3964
  const u = getInitialTextAlign(n);
3961
- u && ((g = c == null ? void 0 : c.commands) == null || g.setTextAlign(u)), (m = c == null ? void 0 : c.commands) == null || m.focus(), c == null || c.emit("focus", {
3965
+ u && ((m = c == null ? void 0 : c.commands) == null || m.setTextAlign(u)), (g = c == null ? void 0 : c.commands) == null || g.focus(), c == null || c.emit("focus", {
3962
3966
  editor: c,
3963
3967
  event: new FocusEvent("focus"),
3964
3968
  transaction: []
3965
3969
  });
3966
3970
  }, [c]);
3967
3971
  const d = useMemo(() => {
3968
- var m;
3972
+ var g;
3969
3973
  const u = "max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";
3970
3974
  if (!n) return u;
3971
- const g = ((m = n == null ? void 0 : n.className) == null ? void 0 : m.replace("sr-only", "")) || "";
3972
- return `${u} ${g}`;
3975
+ const m = ((g = n == null ? void 0 : n.className) == null ? void 0 : g.replace("sr-only", "")) || "";
3976
+ return `${u} ${m}`;
3973
3977
  }, [n]), p = (u) => {
3974
3978
  u.key === "Escape" && l(u);
3975
3979
  };
@@ -4014,9 +4018,9 @@ const RichTextEditor = memo(
4014
4018
  (h.key === "Enter" || h.key === "Escape") && i(h);
4015
4019
  },
4016
4020
  [i]
4017
- ), g = useCallback(() => {
4021
+ ), m = useCallback(() => {
4018
4022
  r();
4019
- }, [r]), m = useMemo(() => {
4023
+ }, [r]), g = useMemo(() => {
4020
4024
  var h;
4021
4025
  return {
4022
4026
  id: "active-inline-editing-element",
@@ -4034,14 +4038,14 @@ const RichTextEditor = memo(
4034
4038
  }, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
4035
4039
  return /* @__PURE__ */ jsx(Fragment, { children: createElement(p, {
4036
4040
  ref: a,
4037
- onBlur: g,
4041
+ onBlur: m,
4038
4042
  onKeyDown: u,
4039
- ...m
4043
+ ...g
4040
4044
  }) });
4041
4045
  }
4042
4046
  ), WithBlockTextEditor = memo(
4043
4047
  ({ block: o, children: n }) => {
4044
- 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: f } = useLanguages(), [, x] = useSelectedBlockIds(), b = useRef(null), y = l, { blockContent: S, blockType: C } = useMemo(() => {
4048
+ const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), m = useRef(null), { clearHighlight: g } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: f } = useLanguages(), [, x] = useSelectedBlockIds(), b = useRef(null), y = l, { blockContent: S, blockType: v } = useMemo(() => {
4045
4049
  var E;
4046
4050
  const k = o._type;
4047
4051
  let I = o[r];
@@ -4050,7 +4054,7 @@ const RichTextEditor = memo(
4050
4054
  }, [o, f]), B = useCallback(
4051
4055
  (k) => {
4052
4056
  var A;
4053
- const I = k || ((A = g.current) == null ? void 0 : A.innerText);
4057
+ const I = k || ((A = m.current) == null ? void 0 : A.innerText);
4054
4058
  h([y], { [r]: I }), u(null), c(null), d(-1), x([]), y && setTimeout(() => x([y]), 100);
4055
4059
  },
4056
4060
  [y, h, c, x, f]
@@ -4060,7 +4064,7 @@ const RichTextEditor = memo(
4060
4064
  },
4061
4065
  [y, o, h, f],
4062
4066
  1e3
4063
- ), w = useCallback(
4067
+ ), j = useCallback(
4064
4068
  (k) => {
4065
4069
  k.preventDefault(), y && (b.current = y), B(), setTimeout(() => {
4066
4070
  const I = b.current;
@@ -4070,33 +4074,33 @@ const RichTextEditor = memo(
4070
4074
  [x, y, f]
4071
4075
  );
4072
4076
  useEffect(() => {
4073
- var j;
4077
+ var w;
4074
4078
  if (!y) return;
4075
4079
  const k = `[data-block-id="${y}"]`, I = i >= 0 ? `[data-block-index="${i}"]` : "", A = a.querySelector(`${k}${I}`);
4076
- A && ((j = A == null ? void 0 : A.classList) == null || j.add("sr-only"), u(A));
4077
- }, [y, C, a, i]);
4078
- const v = useMemo(() => p ? (m(), ["RichText", "Paragraph"].includes(C) ? /* @__PURE__ */ jsx(
4080
+ A && ((w = A == null ? void 0 : A.classList) == null || w.add("sr-only"), u(A));
4081
+ }, [y, v, a, i]);
4082
+ const C = useMemo(() => p ? (g(), ["RichText", "Paragraph"].includes(v) ? /* @__PURE__ */ jsx(
4079
4083
  RichTextEditor,
4080
4084
  {
4081
4085
  blockContent: S,
4082
4086
  editingElement: p,
4083
4087
  onChange: _,
4084
4088
  onClose: B,
4085
- onEscape: w
4089
+ onEscape: j
4086
4090
  }
4087
4091
  ) : /* @__PURE__ */ jsx(
4088
4092
  MemoizedEditor,
4089
4093
  {
4090
- editorRef: g,
4094
+ editorRef: m,
4091
4095
  blockContent: S,
4092
4096
  editingElement: p,
4093
4097
  onClose: B,
4094
4098
  onChange: _,
4095
- onEscape: w
4099
+ onEscape: j
4096
4100
  }
4097
- )) : null, [p, y, C, S, B, f]);
4101
+ )) : null, [p, y, v, S, B, f]);
4098
4102
  return /* @__PURE__ */ jsxs(Fragment, { children: [
4099
- v,
4103
+ C,
4100
4104
  n
4101
4105
  ] });
4102
4106
  },
@@ -4129,16 +4133,16 @@ const RichTextEditor = memo(
4129
4133
  blockAtom: n,
4130
4134
  children: r
4131
4135
  }) => {
4132
- 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] = useAtom$1(dataBindingActiveAtom), h = get(c, "component", null), { index: f, key: x } = useContext(RepeaterContext), b = useMemo(
4133
- () => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
4136
+ const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), m = usePageExternalData(), [g] = useAtom$1(dataBindingActiveAtom), h = get(c, "component", null), { index: f, key: x } = useContext(RepeaterContext), b = useMemo(
4137
+ () => g ? applyBindingToBlockProps(applyLanguage(i, d, c), m, {
4134
4138
  index: f,
4135
4139
  key: x
4136
4140
  }) : applyLanguage(i, d, c),
4137
- [i, d, c, g, m, f, x]
4141
+ [i, d, c, m, g, f, x]
4138
4142
  ), y = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), S = useMemo(
4139
4143
  () => u(i._id, getBlockRuntimeProps(i._type)),
4140
4144
  [i._id, i._type, u, getBlockRuntimeProps]
4141
- ), C = useMemo(
4145
+ ), v = useMemo(
4142
4146
  () => ({
4143
4147
  blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": f },
4144
4148
  inBuilder: !0,
@@ -4160,8 +4164,8 @@ const RichTextEditor = memo(
4160
4164
  ]
4161
4165
  ), B = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]), _ = useMemo(() => get(i, "_show", !0), [i]);
4162
4166
  if (isNull(h) || !_) return null;
4163
- let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(h, {
4164
- ...C,
4167
+ let j = /* @__PURE__ */ jsx(Suspense, { children: createElement(h, {
4168
+ ...v,
4165
4169
  children: r({
4166
4170
  _id: i._id,
4167
4171
  _type: i._type,
@@ -4173,8 +4177,8 @@ const RichTextEditor = memo(
4173
4177
  ...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
4174
4178
  })
4175
4179
  }) });
4176
- const v = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: w }) : w;
4177
- return B ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: v }) : v;
4180
+ const C = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: j }) : j;
4181
+ return B ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: C }) : C;
4178
4182
  }, PartialWrapper$1 = ({ children: o, partialBlockId: n }) => {
4179
4183
  const r = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
4180
4184
  (d) => {
@@ -4217,7 +4221,7 @@ const RichTextEditor = memo(
4217
4221
  );
4218
4222
  return c && (a === "Heading" || a === "Paragraph" || a === "Link") && (i = adjustSpacingInContentBlocks(i)), map(i, (d) => {
4219
4223
  const p = l(d._id);
4220
- return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: d, children: (u) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: p, asyncProps: u, children: ({ _id: g, _type: m, partialBlockId: h, repeaterItems: f, $repeaterItemsKey: x }) => m === "Repeater" ? isArray(f) && f.map((b, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) }, `${g}-${y}`)) : m === "GlobalBlock" || m === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : c(g) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) : null }) }, d._id) : null;
4224
+ return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: d, children: (u) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: p, asyncProps: u, children: ({ _id: m, _type: g, partialBlockId: h, repeaterItems: f, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(f) && f.map((b, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: g }) }, `${m}-${y}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : c(m) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: g }) : null }) }, d._id) : null;
4221
4225
  });
4222
4226
  }, PageBlocksRenderer = () => {
4223
4227
  const [o] = useBlocksStore();
@@ -4230,18 +4234,18 @@ const RichTextEditor = memo(
4230
4234
  const { width: d, height: p } = o;
4231
4235
  if (d < n) {
4232
4236
  const u = parseFloat((d / n).toFixed(2).toString());
4233
- let g = {};
4234
- const m = p * u, h = d * u;
4235
- p && (g = {
4237
+ let m = {};
4238
+ const g = p * u, h = d * u;
4239
+ p && (m = {
4236
4240
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
4237
- height: 100 + (p - m) / m * 100 + "%",
4241
+ height: 100 + (p - g) / g * 100 + "%",
4238
4242
  width: 100 + (d - h) / h * 100 + "%"
4239
4243
  }), i({
4240
4244
  position: "relative",
4241
4245
  top: 0,
4242
4246
  transform: `scale(${u})`,
4243
4247
  transformOrigin: a === "rtl" ? "top right" : "top left",
4244
- ...g,
4248
+ ...m,
4245
4249
  maxWidth: "none"
4246
4250
  // TODO: Add max-width to the wrapper
4247
4251
  }), r(u * 100);
@@ -4268,8 +4272,8 @@ const CanvasEventsWatcher = () => {
4268
4272
  if (d) {
4269
4273
  const p = d.getAttribute("data-style-prop");
4270
4274
  if (p) {
4271
- const u = d.getAttribute("data-style-id"), g = d.getAttribute("data-block-parent");
4272
- r([{ id: u, prop: p, blockId: g }]);
4275
+ const u = d.getAttribute("data-style-id"), m = d.getAttribute("data-block-parent");
4276
+ r([{ id: u, prop: p, blockId: m }]);
4273
4277
  }
4274
4278
  }
4275
4279
  }, 100);
@@ -4277,13 +4281,13 @@ const CanvasEventsWatcher = () => {
4277
4281
  d && (!isEmpty(d) && !includes(i, first(d)) && (c == null || c.closeAll()), o(d));
4278
4282
  }), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, (d) => {
4279
4283
  if (!d) return;
4280
- const { blockId: p, styleId: u, styleProp: g } = d;
4281
- p && (includes(i, p) || c == null || c.closeAll(), r([{ id: u, prop: g, blockId: p }]), o([p]));
4284
+ const { blockId: p, styleId: u, styleProp: m } = d;
4285
+ p && (includes(i, p) || c == null || c.closeAll(), r([{ id: u, prop: m, blockId: p }]), o([p]));
4282
4286
  }), usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION, () => {
4283
4287
  l(), o([]), r([]);
4284
4288
  }), null;
4285
4289
  }, StaticCanvas = () => {
4286
- const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useAtom$1(canvasIframeAtom), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), g = useCallback(
4290
+ const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useAtom$1(canvasIframeAtom), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), m = useCallback(
4287
4291
  (h) => {
4288
4292
  i((f) => ({ ...f, width: h }));
4289
4293
  },
@@ -4294,11 +4298,11 @@ const CanvasEventsWatcher = () => {
4294
4298
  const { clientWidth: h, clientHeight: f } = a.current;
4295
4299
  i({ width: h, height: f });
4296
4300
  }, [a, o]);
4297
- const m = useMemo(() => {
4301
+ const g = useMemo(() => {
4298
4302
  let h = IframeInitialContent;
4299
4303
  return h = h.replace("__HTML_DIR__", u), h;
4300
4304
  }, [u]);
4301
- return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: g, onResize: g, children: /* @__PURE__ */ jsx(
4305
+ return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: m, onResize: m, children: /* @__PURE__ */ jsx(
4302
4306
  "div",
4303
4307
  {
4304
4308
  onMouseLeave: () => setTimeout(() => n(""), 300),
@@ -4312,7 +4316,7 @@ const CanvasEventsWatcher = () => {
4312
4316
  id: "canvas-iframe",
4313
4317
  style: { ...c, ...isEmpty(c) ? { width: `${o}px` } : {} },
4314
4318
  className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
4315
- initialContent: m,
4319
+ initialContent: g,
4316
4320
  children: [
4317
4321
  /* @__PURE__ */ jsx(KeyboardHandler, {}),
4318
4322
  /* @__PURE__ */ jsx(BlockSelectionHighlighter, {}),
@@ -4345,7 +4349,7 @@ const CanvasEventsWatcher = () => {
4345
4349
  /* @__PURE__ */ jsx("p", { className: "font-semibold", children: o("Oops! Something went wrong.") }),
4346
4350
  /* @__PURE__ */ jsx("p", { children: o("Please try again.") })
4347
4351
  ] }) });
4348
- }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-DmN41-qr.js")), CanvasArea = () => {
4352
+ }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-DlWYye4v.js")), CanvasArea = () => {
4349
4353
  const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
4350
4354
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40", children: [
4351
4355
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -4373,7 +4377,7 @@ const CanvasEventsWatcher = () => {
4373
4377
  }, useBlockSettingComponents = (o) => Object.values(RJSF_EXTENSIONS).filter((n) => n.type === o).reduce(
4374
4378
  (n, r) => (n[r.id] = r.component, n),
4375
4379
  {}
4376
- ), IconPicker = lazy(() => import("./IconPicker-CluS-5Mv.js").then((o) => ({ default: o.IconPicker }))), sanitizeSvg = (o) => {
4380
+ ), IconPicker = lazy(() => import("./IconPicker-DB-dcym6.js").then((o) => ({ default: o.IconPicker }))), sanitizeSvg = (o) => {
4377
4381
  try {
4378
4382
  let n = o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi, "<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi, "<svg$1$2>");
4379
4383
  return n = n.replace(/>\s+</g, "><"), n = n.replace(/\n/g, "").replace(/\s{2,}/g, " "), n = n.replace(/\s+=/g, "=").replace(/=\s+/g, "="), n = n.replace(/<!--[\s\S]*?-->/g, ""), n.trim();
@@ -4414,15 +4418,15 @@ const CanvasEventsWatcher = () => {
4414
4418
  ] })
4415
4419
  ] });
4416
4420
  }, DefaultMediaManager = ({ close: o, onSelect: n, mode: r = "image" }) => {
4417
- const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), m = async (f) => {
4421
+ const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, m] = useState(null), g = async (f) => {
4418
4422
  if (!f.trim()) {
4419
- p(!1), g("Please enter a URL");
4423
+ p(!1), m("Please enter a URL");
4420
4424
  return;
4421
4425
  }
4422
4426
  try {
4423
- c(!0), g(null), p(!0), g(null);
4427
+ c(!0), m(null), p(!0), m(null);
4424
4428
  } catch {
4425
- p(!1), g("Error validating URL");
4429
+ p(!1), m("Error validating URL");
4426
4430
  } finally {
4427
4431
  c(!1);
4428
4432
  }
@@ -4440,7 +4444,7 @@ const CanvasEventsWatcher = () => {
4440
4444
  placeholder: h(`Enter ${r} URL`),
4441
4445
  value: a,
4442
4446
  onChange: (f) => l(f.target.value),
4443
- onKeyUp: () => m(a)
4447
+ onKeyUp: () => g(a)
4444
4448
  }
4445
4449
  ),
4446
4450
  /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
@@ -4484,31 +4488,31 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4484
4488
  const n = ((l = o.split("/").pop()) == null ? void 0 : l.split("?")[0]) || "";
4485
4489
  return [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".bmp", ".ico", ".avif"].some((i) => n.toLowerCase().endsWith(i)) ? n : "";
4486
4490
  }, ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
4487
- const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = usePageExternalData(), u = r.split(".").pop() || "", g = i ? `_${u}Id-${i}` : `_${u}Id`, m = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, g, m ? c == null ? void 0 : c.assetId : ""), f = useMemo(() => {
4491
+ const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = usePageExternalData(), u = r.split(".").pop() || "", m = i ? `_${u}Id-${i}` : `_${u}Id`, g = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, m, g ? c == null ? void 0 : c.assetId : ""), f = useMemo(() => {
4488
4492
  if (!o || !c || !/\{\{.*?\}\}/.test(o)) return o;
4489
4493
  const B = { ...c, [u]: o }, _ = applyBindingToBlockProps(B, p, { index: -1, key: "" });
4490
4494
  return get(_, u, o);
4491
- }, [o, c, p, u]), x = !!h || f !== PLACEHOLDER_IMAGE, b = (C) => {
4492
- const B = isArray(C) ? first(C) : C;
4495
+ }, [o, c, p, u]), x = !!h || f !== PLACEHOLDER_IMAGE, b = (v) => {
4496
+ const B = isArray(v) ? first(v) : v;
4493
4497
  if (B) {
4494
4498
  n(B == null ? void 0 : B.url);
4495
- const _ = B == null ? void 0 : B.width, w = B == null ? void 0 : B.height, v = g.includes("mobile");
4499
+ const _ = B == null ? void 0 : B.width, j = B == null ? void 0 : B.height, C = m.includes("mobile");
4496
4500
  if (c != null && c._id) {
4497
4501
  const k = {
4498
- ..._ && { [v ? "mobileWidth" : "width"]: _ },
4499
- ...w && { [v ? "mobileHeight" : "height"]: w },
4502
+ ..._ && { [C ? "mobileWidth" : "width"]: _ },
4503
+ ...j && { [C ? "mobileHeight" : "height"]: j },
4500
4504
  ...B.description && { alt: B.description }
4501
4505
  };
4502
- if (set(k, g, B.id), isEmpty(k)) return;
4506
+ if (set(k, m, B.id), isEmpty(k)) return;
4503
4507
  d([c._id], k);
4504
4508
  }
4505
4509
  }
4506
4510
  }, y = useCallback(() => {
4507
4511
  if (n(PLACEHOLDER_IMAGE), c != null && c._id) {
4508
- const C = {}, B = g.includes("mobile");
4509
- set(C, g, ""), set(C, B ? "mobileWidth" : "width", ""), set(C, B ? "mobileHeight" : "height", ""), d([c._id], C);
4512
+ const v = {}, B = m.includes("mobile");
4513
+ set(v, m, ""), set(v, B ? "mobileWidth" : "width", ""), set(v, B ? "mobileHeight" : "height", ""), d([c._id], v);
4510
4514
  }
4511
- }, [n, c == null ? void 0 : c._id, d, g]), S = getFileName(f);
4515
+ }, [n, c == null ? void 0 : c._id, d, m]), S = getFileName(f);
4512
4516
  return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-start gap-x-3", children: [
4513
4517
  f ? /* @__PURE__ */ jsxs("div", { className: "group relative", children: [
4514
4518
  /* @__PURE__ */ jsx(
@@ -4554,25 +4558,25 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4554
4558
  className: "h-6 text-xs",
4555
4559
  placeholder: l("Enter image URL"),
4556
4560
  value: o === PLACEHOLDER_IMAGE ? "" : o,
4557
- onBlur: ({ target: { value: C } }) => a(r, C),
4558
- onChange: (C) => n(C.target.value)
4561
+ onBlur: ({ target: { value: v } }) => a(r, v),
4562
+ onChange: (v) => n(v.target.value)
4559
4563
  }
4560
4564
  )
4561
4565
  ] })
4562
4566
  ] });
4563
4567
  }, PathDropdown = ({ data: o, onSelect: n, dataType: r }) => {
4564
- const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (m) => Array.isArray(m) ? "array" : typeof m == "object" && m !== null ? "object" : "value", p = React__default.useCallback(
4565
- (m) => {
4568
+ const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (g) => Array.isArray(g) ? "array" : typeof g == "object" && g !== null ? "object" : "value", p = React__default.useCallback(
4569
+ (g) => {
4566
4570
  const h = (f) => r === "value" ? f === "value" || f === "object" : r === "array" ? f === "array" : f === r;
4567
- m.type === "object" ? (l((f) => [...f, m.key]), c(m.value)) : h(m.type) && n([...a, m.key].join("."), r);
4571
+ g.type === "object" ? (l((f) => [...f, g.key]), c(g.value)) : h(g.type) && n([...a, g.key].join("."), r);
4568
4572
  },
4569
4573
  [a, n, r]
4570
4574
  ), u = React__default.useCallback(() => {
4571
4575
  if (a.length > 0) {
4572
- const m = a.slice(0, -1);
4573
- l(m), c(m.reduce((h, f) => h[f], o));
4576
+ const g = a.slice(0, -1);
4577
+ l(g), c(g.reduce((h, f) => h[f], o));
4574
4578
  }
4575
- }, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([m, h]) => ({ key: m, value: h, type: d(h) })).filter((m) => !startsWith(m.key, REPEATER_PREFIX) && m.key.includes("/") ? !1 : r === "value" ? m.type === "value" || m.type === "object" : r === "array" ? m.type === "array" || m.type === "object" : r === "object" ? m.type === "object" : !0) : [], [i, r]);
4579
+ }, [a, o]), m = React__default.useMemo(() => i ? Object.entries(i).map(([g, h]) => ({ key: g, value: h, type: d(h) })).filter((g) => !startsWith(g.key, REPEATER_PREFIX) && g.key.includes("/") ? !1 : r === "value" ? g.type === "value" || g.type === "object" : r === "array" ? g.type === "array" || g.type === "object" : r === "object" ? g.type === "object" : !0) : [], [i, r]);
4576
4580
  return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
4577
4581
  /* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
4578
4582
  /* @__PURE__ */ jsxs(CommandList, { children: [
@@ -4582,36 +4586,36 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4582
4586
  /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "mr-2 h-4 w-4" }),
4583
4587
  t("Back")
4584
4588
  ] }),
4585
- g.map((m) => /* @__PURE__ */ jsxs(
4589
+ m.map((g) => /* @__PURE__ */ jsxs(
4586
4590
  CommandItem,
4587
4591
  {
4588
- value: m.key,
4592
+ value: g.key,
4589
4593
  disabled: !1,
4590
- onSelect: () => p(m),
4594
+ onSelect: () => p(g),
4591
4595
  className: "flex items-center justify-between",
4592
4596
  children: [
4593
4597
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-2", children: [
4594
- startsWith(m.key, REPEATER_PREFIX) ? /* @__PURE__ */ jsx(LoopIcon, {}) : startsWith(m.key, COLLECTION_PREFIX) ? /* @__PURE__ */ jsx(IdCardIcon, {}) : null,
4595
- startsWith(m.key, REPEATER_PREFIX) ? t("Repeater Data") : startsWith(m.key, COLLECTION_PREFIX) ? m.key.replace(COLLECTION_PREFIX, "") : m.key
4598
+ startsWith(g.key, REPEATER_PREFIX) ? /* @__PURE__ */ jsx(LoopIcon, {}) : startsWith(g.key, COLLECTION_PREFIX) ? /* @__PURE__ */ jsx(IdCardIcon, {}) : null,
4599
+ startsWith(g.key, REPEATER_PREFIX) ? t("Repeater Data") : startsWith(g.key, COLLECTION_PREFIX) ? g.key.replace(COLLECTION_PREFIX, "") : g.key
4596
4600
  ] }),
4597
4601
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
4598
- r === "object" && m.type === "object" && /* @__PURE__ */ jsx(
4602
+ r === "object" && g.type === "object" && /* @__PURE__ */ jsx(
4599
4603
  Button,
4600
4604
  {
4601
4605
  size: "sm",
4602
4606
  variant: "ghost",
4603
4607
  className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
4604
4608
  onClick: (h) => {
4605
- h.stopPropagation(), n([...a, m.key].join("."), r);
4609
+ h.stopPropagation(), n([...a, g.key].join("."), r);
4606
4610
  },
4607
4611
  children: t("Select")
4608
4612
  }
4609
4613
  ),
4610
- m.type === "object" && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 opacity-50" }) })
4614
+ g.type === "object" && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 opacity-50" }) })
4611
4615
  ] })
4612
4616
  ]
4613
4617
  },
4614
- m.key
4618
+ g.key
4615
4619
  ))
4616
4620
  ] })
4617
4621
  ] })
@@ -4663,19 +4667,19 @@ const DataBindingSelector = ({
4663
4667
  }) => {
4664
4668
  const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
4665
4669
  if (i.length === 1) return "";
4666
- const g = i.find((f) => f._type === "Repeater"), h = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
4667
- return `${REPEATER_PREFIX}${startsWith(h, COLLECTION_PREFIX) ? `${h}/${g._id}` : h}`;
4670
+ const m = i.find((f) => f._type === "Repeater"), h = get(m, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
4671
+ return `${REPEATER_PREFIX}${startsWith(h, COLLECTION_PREFIX) ? `${h}/${m._id}` : h}`;
4668
4672
  }, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
4669
- (g, m) => {
4670
- if (g = isEmpty(d) ? g : g.replace(`${d}`, "$index"), m === "array" || m === "object") {
4671
- n(`{{${g}}}`, {}, r);
4673
+ (m, g) => {
4674
+ if (m = isEmpty(d) ? m : m.replace(`${d}`, "$index"), g === "array" || g === "object") {
4675
+ n(`{{${m}}}`, {}, r);
4672
4676
  return;
4673
4677
  }
4674
- const h = (y) => /[.,!?;:]/.test(y), f = (y, S, C) => {
4678
+ const h = (y) => /[.,!?;:]/.test(y), f = (y, S, v) => {
4675
4679
  let B = "", _ = "";
4676
- const w = S > 0 ? y[S - 1] : "", v = S < y.length ? y[S] : "";
4677
- return S > 0 && (w === "." || !h(w) && w !== " ") && (B = " "), S < y.length && !h(v) && v !== " " && (_ = " "), {
4678
- text: B + C + _,
4680
+ const j = S > 0 ? y[S - 1] : "", C = S < y.length ? y[S] : "";
4681
+ return S > 0 && (j === "." || !h(j) && j !== " ") && (B = " "), S < y.length && !h(C) && C !== " " && (_ = " "), {
4682
+ text: B + v + _,
4679
4683
  prefixLength: B.length,
4680
4684
  suffixLength: _.length
4681
4685
  };
@@ -4685,29 +4689,29 @@ const DataBindingSelector = ({
4685
4689
  if (b && (b.querySelector(".ProseMirror") || b.__chaiRTE)) {
4686
4690
  const y = b.__chaiRTE;
4687
4691
  if (y) {
4688
- const S = `{{${g}}}`;
4692
+ const S = `{{${m}}}`;
4689
4693
  y.commands.focus();
4690
- const { from: C, to: B } = y.state.selection;
4691
- if (C !== B)
4694
+ const { from: v, to: B } = y.state.selection;
4695
+ if (v !== B)
4692
4696
  y.chain().deleteSelection().insertContent(S).run();
4693
4697
  else {
4694
- const { state: w } = y, v = w.selection.from, k = w.doc.textBetween(Math.max(0, v - 1), v), I = w.doc.textBetween(v, Math.min(v + 1, w.doc.content.size));
4698
+ const { state: j } = y, C = j.selection.from, k = j.doc.textBetween(Math.max(0, C - 1), C), I = j.doc.textBetween(C, Math.min(C + 1, j.doc.content.size));
4695
4699
  let A = "";
4696
- v > 0 && k !== " " && !h(k) && (A = " ");
4697
- let j = "";
4698
- I && I !== " " && !h(I) && (j = " "), y.chain().insertContent(A + S + j).run();
4700
+ C > 0 && k !== " " && !h(k) && (A = " ");
4701
+ let w = "";
4702
+ I && I !== " " && !h(I) && (w = " "), y.chain().insertContent(A + S + w).run();
4699
4703
  }
4700
4704
  setTimeout(() => n(y.getHTML(), {}, r), 100);
4701
4705
  return;
4702
4706
  }
4703
4707
  } else {
4704
- const y = x, S = y.selectionStart || 0, C = y.value || "", B = y.selectionEnd || S;
4708
+ const y = x, S = y.selectionStart || 0, v = y.value || "", B = y.selectionEnd || S;
4705
4709
  if (B > S) {
4706
- const I = `{{${g}}}`, { text: A } = f(C, S, I), j = C.slice(0, S) + A + C.slice(B);
4707
- n(j, {}, r);
4710
+ const I = `{{${m}}}`, { text: A } = f(v, S, I), w = v.slice(0, S) + A + v.slice(B);
4711
+ n(w, {}, r);
4708
4712
  return;
4709
4713
  }
4710
- const w = `{{${g}}}`, { text: v } = f(C, S, w), k = C.slice(0, S) + v + C.slice(S);
4714
+ const j = `{{${m}}}`, { text: C } = f(v, S, j), k = v.slice(0, S) + C + v.slice(S);
4711
4715
  n(k, {}, r);
4712
4716
  }
4713
4717
  },
@@ -4730,12 +4734,12 @@ const DataBindingSelector = ({
4730
4734
  onChange: r
4731
4735
  }) => {
4732
4736
  var I;
4733
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (A, j) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), S = useRef(null), C = (I = n == null ? void 0 : n.find((A) => A.key === u)) == null ? void 0 : I.name;
4737
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (A, w) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, m] = useState("page"), [g, h] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), S = useRef(null), v = (I = n == null ? void 0 : n.find((A) => A.key === u)) == null ? void 0 : I.name;
4734
4738
  useEffect(() => {
4735
4739
  if (h(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4736
- const A = split(o, ":"), j = get(A, 1, "page") || "page";
4737
- g(j), (async () => {
4738
- const E = await l(j, [get(A, 2, "page")]);
4740
+ const A = split(o, ":"), w = get(A, 1, "page") || "page";
4741
+ m(w), (async () => {
4742
+ const E = await l(w, [get(A, 2, "page")]);
4739
4743
  E && Array.isArray(E) && h(get(E, [0, "name"], ""));
4740
4744
  })();
4741
4745
  }, [o]);
@@ -4744,30 +4748,30 @@ const DataBindingSelector = ({
4744
4748
  if (isEmpty(A))
4745
4749
  x([]);
4746
4750
  else {
4747
- const j = await l(u, A);
4748
- x(j);
4751
+ const w = await l(u, A);
4752
+ x(w);
4749
4753
  }
4750
4754
  c(!1), y(-1);
4751
4755
  },
4752
4756
  [u],
4753
4757
  300
4754
4758
  ), _ = (A) => {
4755
- const j = ["pageType", u, A.id];
4756
- j[1] && (r(j.join(":")), h(A.name), p(!1), x([]), y(-1));
4757
- }, w = (A) => {
4759
+ const w = ["pageType", u, A.id];
4760
+ w[1] && (r(w.join(":")), h(A.name), p(!1), x([]), y(-1));
4761
+ }, j = (A) => {
4758
4762
  switch (A.key) {
4759
4763
  case "ArrowDown":
4760
- A.preventDefault(), y((j) => j < f.length - 1 ? j + 1 : j);
4764
+ A.preventDefault(), y((w) => w < f.length - 1 ? w + 1 : w);
4761
4765
  break;
4762
4766
  case "ArrowUp":
4763
- A.preventDefault(), y((j) => j > 0 ? j - 1 : j);
4767
+ A.preventDefault(), y((w) => w > 0 ? w - 1 : w);
4764
4768
  break;
4765
4769
  case "Enter":
4766
4770
  if (A.preventDefault(), f.length === 0) return;
4767
4771
  b >= 0 && _(f[b]);
4768
4772
  break;
4769
4773
  case "Escape":
4770
- A.preventDefault(), v();
4774
+ A.preventDefault(), C();
4771
4775
  break;
4772
4776
  }
4773
4777
  };
@@ -4777,26 +4781,26 @@ const DataBindingSelector = ({
4777
4781
  A == null || A.scrollIntoView({ block: "nearest" });
4778
4782
  }
4779
4783
  }, [b]);
4780
- const v = () => {
4784
+ const C = () => {
4781
4785
  h(""), x([]), y(-1), p(!1), r("");
4782
4786
  }, k = (A) => {
4783
4787
  h(A), p(!isEmpty(A)), c(!0), B(A);
4784
4788
  };
4785
4789
  return /* @__PURE__ */ jsxs("div", { children: [
4786
- /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (A) => g(A.target.value), children: map(n, (A) => /* @__PURE__ */ jsx("option", { value: A.key, children: A.name }, A.key)) }),
4790
+ /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (A) => m(A.target.value), children: map(n, (A) => /* @__PURE__ */ jsx("option", { value: A.key, children: A.name }, A.key)) }),
4787
4791
  u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
4788
4792
  /* @__PURE__ */ jsx(
4789
4793
  "input",
4790
4794
  {
4791
4795
  type: "text",
4792
- value: m,
4796
+ value: g,
4793
4797
  onChange: (A) => k(A.target.value),
4794
- onKeyDown: w,
4795
- placeholder: a(`Search ${C ?? ""}`),
4798
+ onKeyDown: j,
4799
+ placeholder: a(`Search ${v ?? ""}`),
4796
4800
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4797
4801
  }
4798
4802
  ),
4799
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: v, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" }) }) })
4803
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: g && /* @__PURE__ */ jsx("button", { onClick: C, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" }) }) })
4800
4804
  ] }),
4801
4805
  (i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
4802
4806
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -4804,13 +4808,13 @@ const DataBindingSelector = ({
4804
4808
  ] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4805
4809
  a("No results found for"),
4806
4810
  ' "',
4807
- m,
4811
+ g,
4808
4812
  '"'
4809
- ] }) : /* @__PURE__ */ jsx("ul", { ref: S, children: map(f == null ? void 0 : f.slice(0, 20), (A, j) => /* @__PURE__ */ jsxs(
4813
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: S, children: map(f == null ? void 0 : f.slice(0, 20), (A, w) => /* @__PURE__ */ jsxs(
4810
4814
  "li",
4811
4815
  {
4812
4816
  onClick: () => _(A),
4813
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(A.id) ? "bg-blue-200" : j === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
4817
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(A.id) ? "bg-blue-200" : w === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
4814
4818
  children: [
4815
4819
  A.name,
4816
4820
  " ",
@@ -4825,9 +4829,9 @@ const DataBindingSelector = ({
4825
4829
  )) }) })
4826
4830
  ] });
4827
4831
  }, LinkField = ({ schema: o, formData: n, onChange: r, name: a }) => {
4828
- const { t: l } = useTranslation(), { type: i = "pageType", href: c = "", target: d = "self" } = n ?? {}, p = useBuilderProp("pageTypes", []), { selectedLang: u, fallbackLang: g, languages: m } = useLanguages(), h = useMemo(
4829
- () => isEmpty(m) ? "" : isEmpty(u) ? g : u,
4830
- [m, u, g]
4832
+ const { t: l } = useTranslation(), { type: i = "pageType", href: c = "", target: d = "self" } = n ?? {}, p = useBuilderProp("pageTypes", []), { selectedLang: u, fallbackLang: m, languages: g } = useLanguages(), h = useMemo(
4833
+ () => isEmpty(g) ? "" : isEmpty(u) ? m : u,
4834
+ [g, u, m]
4831
4835
  ), f = useMemo(() => get(LANGUAGES, h, h), [h]), x = i === "pageType" && isEmpty(p) ? "url" : i;
4832
4836
  return /* @__PURE__ */ jsxs("div", { children: [
4833
4837
  /* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between gap-x-2 text-xs font-medium", children: [
@@ -4915,7 +4919,7 @@ const DataBindingSelector = ({
4915
4919
  ]
4916
4920
  }
4917
4921
  ) });
4918
- }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-jYxk5Q4W.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
4922
+ }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-CqBZ4WKt.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
4919
4923
  const c = useRef(null), [d, p] = useState(!1), u = useRTEditor({
4920
4924
  blockId: o,
4921
4925
  value: a,
@@ -4932,9 +4936,9 @@ const DataBindingSelector = ({
4932
4936
  useEffect(() => {
4933
4937
  c.current && u && (c.current.__chaiRTE = u);
4934
4938
  }, [o, u]);
4935
- const g = () => {
4939
+ const m = () => {
4936
4940
  p(!1);
4937
- }, m = /* @__PURE__ */ jsxs("div", { id: `chai-rte-${n}`, ref: c, className: "mt-1 rounded-md border border-input", children: [
4941
+ }, g = /* @__PURE__ */ jsxs("div", { id: `chai-rte-${n}`, ref: c, className: "mt-1 rounded-md border border-input", children: [
4938
4942
  /* @__PURE__ */ jsx(RteMenubar, { editor: u, onExpand: () => p(!0) }),
4939
4943
  /* @__PURE__ */ jsx(
4940
4944
  EditorContent,
@@ -4948,8 +4952,8 @@ const DataBindingSelector = ({
4948
4952
  )
4949
4953
  ] });
4950
4954
  return /* @__PURE__ */ jsxs(Fragment, { children: [
4951
- d && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(RTEModal, { isOpen: d, onClose: g, editor: u, rteElement: m }) }),
4952
- d ? /* @__PURE__ */ jsx("div", { children: "Open in modal" }) : /* @__PURE__ */ jsx("div", { className: "relative", children: m })
4955
+ d && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(RTEModal, { isOpen: d, onClose: m, editor: u, rteElement: g }) }),
4956
+ d ? /* @__PURE__ */ jsx("div", { children: "Open in modal" }) : /* @__PURE__ */ jsx("div", { className: "relative", children: g })
4953
4957
  ] });
4954
4958
  }, RichTextEditorField = (o) => {
4955
4959
  const { editingBlockId: n } = useInlineEditing(), [r, a] = useState(null), l = useSelectedBlock(), i = l == null ? void 0 : l._id;
@@ -4961,21 +4965,21 @@ const DataBindingSelector = ({
4961
4965
  if (!a && !l) return null;
4962
4966
  const d = (a == null ? void 0 : a._type) === "Slider" ? a : l, p = find(r, { _parent: d == null ? void 0 : d._id, _type: "Slides" });
4963
4967
  if (!p) return null;
4964
- const u = filter(r, { _parent: p == null ? void 0 : p._id, _type: "Slide" }), g = (o == null ? void 0 : o.currentSlide) || get(u, "0._id");
4968
+ const u = filter(r, { _parent: p == null ? void 0 : p._id, _type: "Slide" }), m = (o == null ? void 0 : o.currentSlide) || get(u, "0._id");
4965
4969
  useEffect(() => {
4966
4970
  (a == null ? void 0 : a._type) === "Slide" && (o == null ? void 0 : o.currentSlide) !== (a == null ? void 0 : a._id) && n({ ...o, currentSlide: a == null ? void 0 : a._id });
4967
4971
  }, [a]), useEffect(() => {
4968
4972
  u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
4969
4973
  }, [o, u]);
4970
- const m = () => {
4971
- const x = findIndex(u, { _id: g });
4974
+ const g = () => {
4975
+ const x = findIndex(u, { _id: m });
4972
4976
  if (x > -1) {
4973
4977
  const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
4974
4978
  if (!y) return;
4975
4979
  n({ ...o, currentSlide: y }), c([y]);
4976
4980
  }
4977
4981
  }, h = () => {
4978
- const x = findIndex(u, { _id: g });
4982
+ const x = findIndex(u, { _id: m });
4979
4983
  if (x > -1) {
4980
4984
  const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
4981
4985
  if (!y) return;
@@ -4991,15 +4995,15 @@ const DataBindingSelector = ({
4991
4995
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4992
4996
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
4993
4997
  /* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "h-3 w-3" }) }),
4994
- /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
4998
+ /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: m ? /* @__PURE__ */ jsxs("span", { className: "", children: [
4995
4999
  /* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
4996
5000
  " ",
4997
- findIndex(u, { _id: g }) + 1
5001
+ findIndex(u, { _id: m }) + 1
4998
5002
  ] }),
4999
5003
  "/",
5000
5004
  u.length
5001
5005
  ] }) : "-" }),
5002
- /* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) }),
5006
+ /* @__PURE__ */ jsx("button", { onClick: g, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) }),
5003
5007
  /* @__PURE__ */ jsxs(
5004
5008
  "button",
5005
5009
  {
@@ -5077,7 +5081,7 @@ const DataBindingSelector = ({
5077
5081
  const r = get(o, "srcsets", []) || [], a = (c, d) => {
5078
5082
  const p = c.target.name, u = c.target.value;
5079
5083
  n({
5080
- srcsets: map(r, (g, m) => m === d ? { ...g, [p]: u } : g)
5084
+ srcsets: map(r, (m, g) => g === d ? { ...m, [p]: u } : m)
5081
5085
  });
5082
5086
  }, l = () => {
5083
5087
  n({ srcsets: [...r, {}] });
@@ -5156,37 +5160,37 @@ const DataBindingSelector = ({
5156
5160
  ] });
5157
5161
  }, CollectionFilterSortField = ({ id: o, value: n, onChange: r, onBlur: a }) => {
5158
5162
  const l = useBuilderProp("collections", []), i = useSelectedBlock(), c = get(i, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1").replace(COLLECTION_PREFIX, ""), d = find(l, { id: c }), u = get(d, o === "root.filter" ? "filters" : "sorts", []);
5159
- return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("select", { value: n, onChange: (g) => r(g.target.value), onBlur: (g) => a(o, g.target.value), children: [
5163
+ return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("select", { value: n, onChange: (m) => r(m.target.value), onBlur: (m) => a(o, m.target.value), children: [
5160
5164
  /* @__PURE__ */ jsx("option", { value: "", children: "Select" }),
5161
- u.map((g) => /* @__PURE__ */ jsx("option", { value: g.id, children: g.name }, g.id))
5165
+ u.map((m) => /* @__PURE__ */ jsx("option", { value: m.id, children: m.name }, m.id))
5162
5166
  ] }) });
5163
5167
  }, JSONFormFieldTemplate = (o) => {
5164
- const { id: n, classNames: r, label: a, children: l, errors: i, help: c, hidden: d, required: p, schema: u, formData: g, onChange: m } = o, { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = useMemo(
5168
+ const { id: n, classNames: r, label: a, children: l, errors: i, help: c, hidden: d, required: p, schema: u, formData: m, onChange: g } = o, { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = useMemo(
5165
5169
  () => isEmpty(x) ? "" : isEmpty(h) ? f : h,
5166
5170
  [x, h, f]
5167
- ), y = useMemo(() => get(LANGUAGES, b, b), [b]), S = usePageExternalData(), C = useSelectedBlock(), B = useRegisteredChaiBlocks(), _ = useMemo(
5168
- () => get(B, [C == null ? void 0 : C._type, "i18nProps"], []),
5169
- [B, C == null ? void 0 : C._type]
5170
- ), [w, v] = useState(null);
5171
+ ), y = useMemo(() => get(LANGUAGES, b, b), [b]), S = usePageExternalData(), v = useSelectedBlock(), B = useRegisteredChaiBlocks(), _ = useMemo(
5172
+ () => get(B, [v == null ? void 0 : v._type, "i18nProps"], []),
5173
+ [B, v == null ? void 0 : v._type]
5174
+ ), [j, C] = useState(null);
5171
5175
  if (d)
5172
5176
  return null;
5173
5177
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: l });
5174
5178
  const I = _ == null ? void 0 : _.includes(n.replace("root.", ""));
5175
5179
  if (u.type === "array") {
5176
- const E = w === n;
5180
+ const E = j === n;
5177
5181
  return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
5178
5182
  u.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
5179
5183
  "label",
5180
5184
  {
5181
5185
  htmlFor: n,
5182
- onClick: () => v(E ? null : n),
5186
+ onClick: () => C(E ? null : n),
5183
5187
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
5184
5188
  children: [
5185
5189
  E ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }),
5186
5190
  /* @__PURE__ */ jsx(ListBulletIcon, { className: "h-3 w-3" }),
5187
5191
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: a }),
5188
5192
  " ",
5189
- /* @__PURE__ */ jsx(Badge, { className: "m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-slate-600", children: g == null ? void 0 : g.length }) }),
5193
+ /* @__PURE__ */ jsx(Badge, { className: "m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-slate-600", children: m == null ? void 0 : m.length }) }),
5190
5194
  u.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5191
5195
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5192
5196
  InfoCircledIcon,
@@ -5201,14 +5205,14 @@ const DataBindingSelector = ({
5201
5205
  ]
5202
5206
  }
5203
5207
  ) }),
5204
- (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: l }) : /* @__PURE__ */ jsxs("div", { className: `${E ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
5208
+ (m == null ? void 0 : m.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: l }) : /* @__PURE__ */ jsxs("div", { className: `${E ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
5205
5209
  l,
5206
5210
  i,
5207
5211
  c
5208
5212
  ] })
5209
5213
  ] });
5210
5214
  }
5211
- const A = n.replace("root.", ""), j = _.includes(A) && !isEmpty(h) && isEmpty(g);
5215
+ const A = n.replace("root.", ""), w = _.includes(A) && !isEmpty(h) && isEmpty(m);
5212
5216
  return /* @__PURE__ */ jsxs("div", { className: r, children: [
5213
5217
  u.title && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
5214
5218
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
@@ -5227,7 +5231,7 @@ const DataBindingSelector = ({
5227
5231
  ] }) })
5228
5232
  ] }),
5229
5233
  !u.enum && !u.oneOf && S && /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-1", children: [
5230
- j ? /* @__PURE__ */ jsxs(Tooltip, { children: [
5234
+ w ? /* @__PURE__ */ jsxs(Tooltip, { children: [
5231
5235
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
5232
5236
  "svg",
5233
5237
  {
@@ -5259,10 +5263,10 @@ const DataBindingSelector = ({
5259
5263
  {
5260
5264
  schema: u,
5261
5265
  onChange: (E) => {
5262
- m(E, g, n);
5266
+ g(E, m, n);
5263
5267
  },
5264
5268
  id: n,
5265
- formData: g
5269
+ formData: m
5266
5270
  }
5267
5271
  )
5268
5272
  ] })
@@ -5309,8 +5313,8 @@ const DataBindingSelector = ({
5309
5313
  /* @__PURE__ */ jsx("span", { children: "Add" })
5310
5314
  ] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
5311
5315
  const { selectedLang: i } = useLanguages(), c = useBlockSettingComponents("widget"), d = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
5312
- async ({ formData: g }, m) => {
5313
- get(g, m) === void 0 && set(g, m, ""), l({ formData: g }, m);
5316
+ async ({ formData: m }, g) => {
5317
+ get(m, g) === void 0 && set(m, g, ""), l({ formData: m }, g);
5314
5318
  },
5315
5319
  [l, i],
5316
5320
  400
@@ -5351,10 +5355,10 @@ const DataBindingSelector = ({
5351
5355
  uiSchema: r,
5352
5356
  schema: n,
5353
5357
  formData: a,
5354
- onChange: ({ formData: g }, m) => {
5355
- if (!m || o !== (g == null ? void 0 : g._id)) return;
5356
- const h = take(m.split("."), 2).join(".").replace("root.", "");
5357
- u({ formData: g }, h);
5358
+ onChange: ({ formData: m }, g) => {
5359
+ if (!g || o !== (m == null ? void 0 : m._id)) return;
5360
+ const h = take(g.split("."), 2).join(".").replace("root.", "");
5361
+ u({ formData: m }, h);
5358
5362
  }
5359
5363
  },
5360
5364
  i
@@ -5366,52 +5370,52 @@ const DataBindingSelector = ({
5366
5370
  }), a;
5367
5371
  };
5368
5372
  function BlockSettings() {
5369
- 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), f = ({ formData: w }, v, k) => {
5370
- v && (c == null ? void 0 : c._id) === n._id && a([n._id], { [v]: get(w, v) }, k);
5373
+ 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), m = useWrapperBlock(), g = getRegisteredChaiBlock(m == null ? void 0 : m._type), h = formDataWithSelectedLang(m, o, g), f = ({ formData: j }, C, k) => {
5374
+ C && (c == null ? void 0 : c._id) === n._id && a([n._id], { [C]: get(j, C) }, k);
5371
5375
  }, x = useCallback(
5372
- debounce(({ formData: w }, v, k) => {
5373
- f({ formData: w }, v, k), d(w);
5376
+ debounce(({ formData: j }, C, k) => {
5377
+ f({ formData: j }, C, k), d(j);
5374
5378
  }, 1500),
5375
5379
  [n == null ? void 0 : n._id, o]
5376
- ), b = ({ formData: w }, v) => {
5377
- v && (r([n._id], { [v]: get(w, v) }), x({ formData: w }, v, { [v]: get(c, v) }));
5378
- }, y = ({ formData: w }, v) => {
5379
- v && (r([g._id], { [v]: get(w, v) }), x({ formData: w }, v, { [v]: get(c, v) }));
5380
- }, { schema: S, uiSchema: C } = useMemo(() => {
5381
- const w = n == null ? void 0 : n._type;
5382
- if (!w)
5380
+ ), b = ({ formData: j }, C) => {
5381
+ C && (r([n._id], { [C]: get(j, C) }), x({ formData: j }, C, { [C]: get(c, C) }));
5382
+ }, y = ({ formData: j }, C) => {
5383
+ C && (r([m._id], { [C]: get(j, C) }), x({ formData: j }, C, { [C]: get(c, C) }));
5384
+ }, { schema: S, uiSchema: v } = useMemo(() => {
5385
+ const j = n == null ? void 0 : n._type;
5386
+ if (!j)
5383
5387
  return { schema: {}, uiSchema: {} };
5384
5388
  try {
5385
- const { schema: v, uiSchema: k } = getBlockFormSchemas(w);
5386
- if (w === "Repeater") {
5389
+ const { schema: C, uiSchema: k } = getBlockFormSchemas(j);
5390
+ if (j === "Repeater") {
5387
5391
  const I = get(n, "repeaterItems", "");
5388
5392
  startsWith(I, `{{${COLLECTION_PREFIX}`) ? (set(k, "filter", { "ui:widget": "collectionSelect" }), set(k, "sort", { "ui:widget": "collectionSelect" })) : (set(k, "filter", { "ui:widget": "hidden" }), set(k, "sort", { "ui:widget": "hidden" }));
5389
5393
  }
5390
- return { schema: v, uiSchema: k };
5394
+ return { schema: C, uiSchema: k };
5391
5395
  } catch {
5392
5396
  return { schema: {}, uiSchema: {} };
5393
5397
  }
5394
5398
  }, [n]), { wrapperSchema: B, wrapperUiSchema: _ } = useMemo(() => {
5395
- if (!g || !(g != null && g._type))
5399
+ if (!m || !(m != null && m._type))
5396
5400
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5397
- const w = g == null ? void 0 : g._type, { schema: v = {}, uiSchema: k = {} } = getBlockFormSchemas(w);
5398
- return { wrapperSchema: v, wrapperUiSchema: k };
5399
- }, [g]);
5401
+ const j = m == null ? void 0 : m._type, { schema: C = {}, uiSchema: k = {} } = getBlockFormSchemas(j);
5402
+ return { wrapperSchema: C, wrapperUiSchema: k };
5403
+ }, [m]);
5400
5404
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5401
- !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
5405
+ !isEmpty(m) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
5402
5406
  /* @__PURE__ */ jsxs(
5403
5407
  "div",
5404
5408
  {
5405
- onClick: () => u((w) => !w),
5409
+ onClick: () => u((j) => !j),
5406
5410
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5407
5411
  children: [
5408
5412
  p ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-4 w-4 text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 text-slate-400" }),
5409
- startCase(g._type),
5413
+ startCase(m._type),
5410
5414
  " settings",
5411
5415
  " ",
5412
- g._name && /* @__PURE__ */ jsxs("span", { className: "text-[11px] font-light text-slate-400", children: [
5416
+ m._name && /* @__PURE__ */ jsxs("span", { className: "text-[11px] font-light text-slate-400", children: [
5413
5417
  "(",
5414
- g._name,
5418
+ m._name,
5415
5419
  ")"
5416
5420
  ] })
5417
5421
  ]
@@ -5420,7 +5424,7 @@ function BlockSettings() {
5420
5424
  /* @__PURE__ */ jsx("div", { className: p ? "h-auto" : "invisible h-0", children: /* @__PURE__ */ jsx(
5421
5425
  JSONForm,
5422
5426
  {
5423
- blockId: g == null ? void 0 : g._id,
5427
+ blockId: m == null ? void 0 : m._id,
5424
5428
  onChange: y,
5425
5429
  formData: h,
5426
5430
  schema: B,
@@ -5435,7 +5439,7 @@ function BlockSettings() {
5435
5439
  onChange: b,
5436
5440
  formData: i,
5437
5441
  schema: S,
5438
- uiSchema: C
5442
+ uiSchema: v
5439
5443
  }
5440
5444
  )
5441
5445
  ] });
@@ -5446,7 +5450,7 @@ const BlockStylingProps = () => {
5446
5450
  if (!o) return null;
5447
5451
  const c = Object.keys(o).filter(
5448
5452
  (x) => typeof o[x] == "string" && o[x].startsWith("#styles:")
5449
- ), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (f = n[0]) == null ? void 0 : f.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, m = g ? g.split(" ").filter((x) => !isEmpty(x)) : [], h = (x) => find(n, (b) => b.prop === x);
5453
+ ), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (f = n[0]) == null ? void 0 : f.prop, ""), { classes: m = "" } = getSplitChaiClasses(u) || {}, g = m ? m.split(" ").filter((x) => !isEmpty(x)) : [], h = (x) => find(n, (b) => b.prop === x);
5450
5454
  return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
5451
5455
  /* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
5452
5456
  i("Style element"),
@@ -5488,7 +5492,7 @@ const BlockStylingProps = () => {
5488
5492
  {
5489
5493
  className: "text-xs",
5490
5494
  onClick: () => {
5491
- a(l, m, !0);
5495
+ a(l, g, !0);
5492
5496
  },
5493
5497
  children: i("Clear styles")
5494
5498
  }
@@ -5646,52 +5650,52 @@ const BlockStylingProps = () => {
5646
5650
  },
5647
5651
  a
5648
5652
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5649
- 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]), [f, x] = useState(!1), [b, y] = useState(""), [S, C] = useState(!1), [B, _] = useState(!1);
5653
+ const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: m } = o, [g, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [b, y] = useState(""), [S, v] = useState(!1), [B, _] = useState(!1);
5650
5654
  useEffect(() => {
5651
- const { value: A, unit: j } = getClassValueAndUnit(i);
5652
- if (j === "") {
5655
+ const { value: A, unit: w } = getClassValueAndUnit(i);
5656
+ if (w === "") {
5653
5657
  l(A), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5654
5658
  return;
5655
5659
  }
5656
- h(j), l(j === "class" || isEmpty(A) ? "" : A);
5660
+ h(w), l(w === "class" || isEmpty(A) ? "" : A);
5657
5661
  }, [i, p, u]);
5658
- const w = useThrottledCallback((A) => c(A), [c], THROTTLE_TIME), v = useThrottledCallback((A) => c(A, !1), [c], THROTTLE_TIME), k = useCallback(
5662
+ const j = useThrottledCallback((A) => c(A), [c], THROTTLE_TIME), C = useThrottledCallback((A) => c(A, !1), [c], THROTTLE_TIME), k = useCallback(
5659
5663
  (A = !1) => {
5660
- const j = getUserInputValues(`${a}`, u);
5661
- if (get(j, "error", !1)) {
5664
+ const w = getUserInputValues(`${a}`, u);
5665
+ if (get(w, "error", !1)) {
5662
5666
  x(!0);
5663
5667
  return;
5664
5668
  }
5665
- const E = get(j, "unit") !== "" ? get(j, "unit") : m;
5669
+ const E = get(w, "unit") !== "" ? get(w, "unit") : g;
5666
5670
  if (E === "auto" || E === "none") {
5667
- w(`${d}${E}`);
5671
+ j(`${d}${E}`);
5668
5672
  return;
5669
5673
  }
5670
- if (get(j, "value") === "")
5674
+ if (get(w, "value") === "")
5671
5675
  return;
5672
- const T = `${get(j, "value", "").startsWith("-") ? "-" : ""}${d}[${get(j, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
5673
- A ? v(T) : w(T);
5676
+ const T = `${get(w, "value", "").startsWith("-") ? "-" : ""}${d}[${get(w, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
5677
+ A ? C(T) : j(T);
5674
5678
  },
5675
- [w, v, a, m, d, u]
5679
+ [j, C, a, g, d, u]
5676
5680
  ), I = useCallback(
5677
5681
  (A) => {
5678
- const j = getUserInputValues(`${a}`, u);
5679
- if (get(j, "error", !1)) {
5682
+ const w = getUserInputValues(`${a}`, u);
5683
+ if (get(w, "error", !1)) {
5680
5684
  x(!0);
5681
5685
  return;
5682
5686
  }
5683
5687
  if (A === "auto" || A === "none") {
5684
- w(`${d}${A}`);
5688
+ j(`${d}${A}`);
5685
5689
  return;
5686
5690
  }
5687
- if (get(j, "value") === "")
5691
+ if (get(w, "value") === "")
5688
5692
  return;
5689
- const E = get(j, "unit") !== "" ? get(j, "unit") : A, T = `${get(j, "value", "").startsWith("-") ? "-" : ""}${d}[${get(j, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
5690
- w(T);
5693
+ const E = get(w, "unit") !== "" ? get(w, "unit") : A, T = `${get(w, "value", "").startsWith("-") ? "-" : ""}${d}[${get(w, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
5694
+ j(T);
5691
5695
  },
5692
- [w, a, d, u]
5696
+ [j, a, d, u]
5693
5697
  );
5694
- return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5698
+ return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: g === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5695
5699
  /* @__PURE__ */ jsx(
5696
5700
  "input",
5697
5701
  {
@@ -5706,10 +5710,10 @@ const BlockStylingProps = () => {
5706
5710
  ] })
5707
5711
  ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${S ? "z-auto" : ""}`, children: [
5708
5712
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
5709
- ["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
5713
+ ["none", "auto"].indexOf(g) !== -1 ? null : /* @__PURE__ */ jsx(
5710
5714
  "input",
5711
5715
  {
5712
- readOnly: m === "class",
5716
+ readOnly: g === "class",
5713
5717
  onKeyPress: (A) => {
5714
5718
  A.key === "Enter" && k();
5715
5719
  },
@@ -5717,11 +5721,11 @@ const BlockStylingProps = () => {
5717
5721
  if (A.keyCode !== 38 && A.keyCode !== 40)
5718
5722
  return;
5719
5723
  A.preventDefault(), _(!0);
5720
- const j = parseInt$1(A.target.value);
5721
- let E = isNaN$1(j) ? 0 : j;
5724
+ const w = parseInt$1(A.target.value);
5725
+ let E = isNaN$1(w) ? 0 : w;
5722
5726
  A.keyCode === 38 && (E += 1), A.keyCode === 40 && (E -= 1);
5723
- const L = `${E}`, P = `${L.startsWith("-") ? "-" : ""}${d}[${L.replace("-", "")}${m === "-" ? "" : m}]`;
5724
- v(P);
5727
+ const L = `${E}`, P = `${L.startsWith("-") ? "-" : ""}${d}[${L.replace("-", "")}${g === "-" ? "" : g}]`;
5728
+ C(P);
5725
5729
  },
5726
5730
  onKeyUp: (A) => {
5727
5731
  B && (A.preventDefault(), _(!1));
@@ -5731,8 +5735,8 @@ const BlockStylingProps = () => {
5731
5735
  x(!1), l(A.target.value);
5732
5736
  },
5733
5737
  onClick: (A) => {
5734
- var j;
5735
- (j = A == null ? void 0 : A.target) == null || j.select(), r(!1);
5738
+ var w;
5739
+ (w = A == null ? void 0 : A.target) == null || w.select(), r(!1);
5736
5740
  },
5737
5741
  value: S ? b : a,
5738
5742
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
@@ -5749,7 +5753,7 @@ const BlockStylingProps = () => {
5749
5753
  onClick: () => r(!n),
5750
5754
  className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
5751
5755
  children: [
5752
- /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
5756
+ /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: g }),
5753
5757
  u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
5754
5758
  ]
5755
5759
  }
@@ -5758,7 +5762,7 @@ const BlockStylingProps = () => {
5758
5762
  UnitSelection,
5759
5763
  {
5760
5764
  units: u,
5761
- current: m,
5765
+ current: g,
5762
5766
  onSelect: (A) => {
5763
5767
  r(!1), h(A), I(A);
5764
5768
  }
@@ -5766,26 +5770,26 @@ const BlockStylingProps = () => {
5766
5770
  ) })
5767
5771
  ] })
5768
5772
  ] }),
5769
- ["none", "auto"].indexOf(m) !== -1 || S ? null : /* @__PURE__ */ jsx(
5773
+ ["none", "auto"].indexOf(g) !== -1 || S ? null : /* @__PURE__ */ jsx(
5770
5774
  DragStyleButton,
5771
5775
  {
5772
- onDragStart: () => C(!0),
5776
+ onDragStart: () => v(!0),
5773
5777
  onDragEnd: (A) => {
5774
- if (y(() => ""), C(!1), isEmpty(A))
5778
+ if (y(() => ""), v(!1), isEmpty(A))
5775
5779
  return;
5776
- const j = `${A}`, L = `${j.startsWith("-") ? "-" : ""}${d}[${j.replace("-", "")}${m === "-" ? "" : m}]`;
5777
- w(L);
5780
+ const w = `${A}`, L = `${w.startsWith("-") ? "-" : ""}${d}[${w.replace("-", "")}${g === "-" ? "" : g}]`;
5781
+ j(L);
5778
5782
  },
5779
5783
  onDrag: (A) => {
5780
5784
  if (isEmpty(A))
5781
5785
  return;
5782
5786
  y(A);
5783
- const j = `${A}`, L = `${j.startsWith("-") ? "-" : ""}${d}[${j.replace("-", "")}${m === "-" ? "" : m}]`;
5784
- v(L);
5787
+ const w = `${A}`, L = `${w.startsWith("-") ? "-" : ""}${d}[${w.replace("-", "")}${g === "-" ? "" : g}]`;
5788
+ C(L);
5785
5789
  },
5786
5790
  currentValue: a,
5787
- unit: m,
5788
- negative: g,
5791
+ unit: g,
5792
+ negative: m,
5789
5793
  cssProperty: p
5790
5794
  }
5791
5795
  )
@@ -5844,7 +5848,7 @@ const COLOR_PROP = {
5844
5848
  ringColor: "ring",
5845
5849
  ringOffsetColor: "ring-offset"
5846
5850
  }, ColorChoice = ({ property: o, onChange: n }) => {
5847
- 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(
5851
+ 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("-"), m = get(u, "1", ""), g = get(u, "2", ""), h = useCallback(
5848
5852
  // eslint-disable-next-line no-shadow
5849
5853
  (b) => {
5850
5854
  ["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: b, shade: y.shade ? y.shade : "500" })));
@@ -5852,16 +5856,16 @@ const COLOR_PROP = {
5852
5856
  [c, p]
5853
5857
  );
5854
5858
  useEffect(() => {
5855
- if (["current", "inherit", "transparent", "black", "white"].includes(g))
5859
+ if (["current", "inherit", "transparent", "black", "white"].includes(m))
5856
5860
  return c([]);
5857
5861
  c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
5858
- }, [g]);
5862
+ }, [m]);
5859
5863
  const f = useCallback(
5860
5864
  // eslint-disable-next-line no-shadow
5861
5865
  (b) => {
5862
- p({ color: g, shade: b });
5866
+ p({ color: m, shade: b });
5863
5867
  },
5864
- [g]
5868
+ [m]
5865
5869
  );
5866
5870
  useEffect(() => {
5867
5871
  p({ color: "", shade: "" });
@@ -5876,7 +5880,7 @@ const COLOR_PROP = {
5876
5880
  {
5877
5881
  disabled: !l,
5878
5882
  rounded: !0,
5879
- selected: g,
5883
+ selected: m,
5880
5884
  onChange: h,
5881
5885
  options: [
5882
5886
  "current",
@@ -5910,7 +5914,7 @@ const COLOR_PROP = {
5910
5914
  ]
5911
5915
  }
5912
5916
  ) }),
5913
- /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: f, options: i }) })
5917
+ /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: g, disabled: !m || !l, onChange: f, options: i }) })
5914
5918
  ] });
5915
5919
  }, EDITOR_ICONS = {
5916
5920
  "not-italic": () => /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z", fill: "white" }) }),
@@ -6244,22 +6248,22 @@ const COLOR_PROP = {
6244
6248
  "2xl": "1536px"
6245
6249
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6246
6250
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
6247
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
6248
- (v, k = !0) => {
6249
- const I = { dark: p, mq: g, mod: u, cls: v, property: l, fullCls: "" };
6251
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, m] = useScreenSizeWidth(), g = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(g, "fullCls", ""), [g]), y = useCallback(
6252
+ (C, k = !0) => {
6253
+ const I = { dark: p, mq: m, mod: u, cls: C, property: l, fullCls: "" };
6250
6254
  (p || u !== "") && (I.mq = "xs");
6251
6255
  const A = generateFullClsName(I);
6252
6256
  h(x, [A], k);
6253
6257
  },
6254
- [x, p, g, u, l, h]
6258
+ [x, p, m, u, l, h]
6255
6259
  ), S = useCallback(() => {
6256
6260
  f(x, [b], !0);
6257
- }, [x, b, f]), C = useMemo(() => canChangeClass(m, g), [m, g]);
6261
+ }, [x, b, f]), v = useMemo(() => canChangeClass(g, m), [g, m]);
6258
6262
  useEffect(() => {
6259
- i(C, m);
6260
- }, [C, i, m]);
6263
+ i(v, g);
6264
+ }, [v, i, g]);
6261
6265
  const [, , B] = useScreenSizeWidth(), _ = useCallback(
6262
- (v) => {
6266
+ (C) => {
6263
6267
  B({
6264
6268
  xs: 400,
6265
6269
  sm: 640,
@@ -6267,18 +6271,18 @@ const COLOR_PROP = {
6267
6271
  lg: 1024,
6268
6272
  xl: 1420,
6269
6273
  "2xl": 1920
6270
- }[v]);
6274
+ }[C]);
6271
6275
  },
6272
6276
  [B]
6273
- ), w = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6274
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: C, canReset: m && w, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6275
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !w ? "text-foreground" : ""}`, children: n(a) }) }),
6277
+ ), j = get(g, "dark", null) === p && get(g, "mod", null) === u && get(g, "mq", null) === m;
6278
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: v, canReset: g && j, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6279
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${g && !j ? "text-foreground" : ""}`, children: n(a) }) }),
6276
6280
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6277
6281
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
6278
6282
  r === "arbitrary" ? /* @__PURE__ */ jsx(
6279
6283
  AdvanceChoices,
6280
6284
  {
6281
- currentClass: get(m, "cls", ""),
6285
+ currentClass: get(g, "cls", ""),
6282
6286
  classPrefix: get(CLASS_PREFIXES, l, ""),
6283
6287
  units: c || [],
6284
6288
  onChange: y,
@@ -6291,7 +6295,7 @@ const COLOR_PROP = {
6291
6295
  r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
6292
6296
  r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
6293
6297
  ] }),
6294
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: w ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => S(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : C && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6298
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: j ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => S(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : v && g ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6295
6299
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6296
6300
  "button",
6297
6301
  {
@@ -6303,19 +6307,19 @@ const COLOR_PROP = {
6303
6307
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
6304
6308
  "Current style is set at  ",
6305
6309
  /* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
6306
- getBreakpoint(get(m, "mq")),
6307
- p && !m.dark ? "(Light mode)" : ""
6310
+ getBreakpoint(get(g, "mq")),
6311
+ p && !g.dark ? "(Light mode)" : ""
6308
6312
  ] }),
6309
6313
  /* @__PURE__ */ jsx("br", {}),
6310
6314
  /* @__PURE__ */ jsxs(
6311
6315
  "button",
6312
6316
  {
6313
6317
  type: "button",
6314
- onClick: () => _(get(m, "mq")),
6318
+ onClick: () => _(get(g, "mq")),
6315
6319
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
6316
6320
  children: [
6317
6321
  "Switch to ",
6318
- get(m, "mq").toUpperCase()
6322
+ get(g, "mq").toUpperCase()
6319
6323
  ]
6320
6324
  }
6321
6325
  )
@@ -6332,7 +6336,7 @@ const COLOR_PROP = {
6332
6336
  units: i = basicUnits,
6333
6337
  negative: c = !1
6334
6338
  }) => {
6335
- const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((h) => map(g, "property").includes(h), [g]);
6339
+ const { t: d } = useTranslation(), [p, u] = useState(n[0].key), m = useSelectedBlockCurrentClasses(), g = useCallback((h) => map(m, "property").includes(h), [m]);
6336
6340
  return /* @__PURE__ */ jsxs(
6337
6341
  "div",
6338
6342
  {
@@ -6349,7 +6353,7 @@ const COLOR_PROP = {
6349
6353
  className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6350
6354
  children: [
6351
6355
  React__default.createElement("div", {
6352
- className: m(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6356
+ className: g(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6353
6357
  }),
6354
6358
  React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
6355
6359
  ]
@@ -6480,7 +6484,7 @@ const COLOR_PROP = {
6480
6484
  icon: p,
6481
6485
  onClick: u
6482
6486
  }) => {
6483
- const { t: g } = useTranslation();
6487
+ const { t: m } = useTranslation();
6484
6488
  return r ? /* @__PURE__ */ jsxs(HoverCard, { openDelay: n, children: [
6485
6489
  /* @__PURE__ */ jsx(HoverCardTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6486
6490
  Button,
@@ -6493,8 +6497,8 @@ const COLOR_PROP = {
6493
6497
  }
6494
6498
  ) }),
6495
6499
  /* @__PURE__ */ jsx(HoverCardContent, { className: "w-fit max-w-52 border-border", children: /* @__PURE__ */ jsx("div", { className: "flex justify-between space-x-4", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
6496
- /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: g(a) }),
6497
- o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: g(l) })
6500
+ /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: m(a) }),
6501
+ o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: m(l) })
6498
6502
  ] }) }) })
6499
6503
  ] }) : /* @__PURE__ */ jsx(
6500
6504
  Button,
@@ -6511,8 +6515,8 @@ const COLOR_PROP = {
6511
6515
  canvas: n = !1,
6512
6516
  tooltip: r = !0
6513
6517
  }) => {
6514
- const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (y) => {
6515
- u.includes(y) ? u.length > 2 && g(u.filter((S) => S !== y)) : g((S) => [...S, y]);
6518
+ const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, m = p, { t: g } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (y) => {
6519
+ u.includes(y) ? u.length > 2 && m(u.filter((S) => S !== y)) : m((S) => [...S, y]);
6516
6520
  }, x = (y) => {
6517
6521
  n || l(y), c(y);
6518
6522
  }, b = getBreakpointValue(n ? i : a).toLowerCase();
@@ -6544,7 +6548,7 @@ const COLOR_PROP = {
6544
6548
  /* @__PURE__ */ jsxs(DropdownMenu, { children: [
6545
6549
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer px-2.5 hover:opacity-80", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "scale-90 transform" }) }) }),
6546
6550
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
6547
- /* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
6551
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: g("Screen sizes") }),
6548
6552
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
6549
6553
  map(h, (y) => /* @__PURE__ */ jsx(
6550
6554
  DropdownMenuCheckboxItem,
@@ -6552,7 +6556,7 @@ const COLOR_PROP = {
6552
6556
  disabled: y.breakpoint === "xs",
6553
6557
  onCheckedChange: () => f(toUpper(y.breakpoint)),
6554
6558
  checked: includes(u, toUpper(y.breakpoint)),
6555
- children: m(y.title)
6559
+ children: g(y.title)
6556
6560
  },
6557
6561
  y.breakpoint
6558
6562
  ))
@@ -6629,14 +6633,14 @@ function Countdown() {
6629
6633
  ] });
6630
6634
  }
6631
6635
  const AskAIStyles = ({ blockId: o }) => {
6632
- const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
6636
+ const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, m] = useState();
6633
6637
  useEffect(() => {
6634
6638
  var h;
6635
6639
  (h = d.current) == null || h.focus();
6636
6640
  }, []);
6637
- const m = (h) => {
6641
+ const g = (h) => {
6638
6642
  const { usage: f } = h || {};
6639
- !l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
6643
+ !l && f && m(f), p.current = setTimeout(() => m(void 0), 1e4), l || c("");
6640
6644
  };
6641
6645
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
6642
6646
  /* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("Ask AI") }),
@@ -6650,7 +6654,7 @@ const AskAIStyles = ({ blockId: o }) => {
6650
6654
  className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
6651
6655
  rows: 4,
6652
6656
  onKeyDown: (h) => {
6653
- h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
6657
+ h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current), m(void 0), r("styles", o, i, g));
6654
6658
  }
6655
6659
  }
6656
6660
  ),
@@ -6660,7 +6664,7 @@ const AskAIStyles = ({ blockId: o }) => {
6660
6664
  {
6661
6665
  disabled: i.trim().length < 5 || a,
6662
6666
  onClick: () => {
6663
- p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m);
6667
+ p.current && clearTimeout(p.current), m(void 0), r("styles", o, i, g);
6664
6668
  },
6665
6669
  variant: "default",
6666
6670
  className: "w-fit",
@@ -6692,10 +6696,10 @@ const AskAIStyles = ({ blockId: o }) => {
6692
6696
  }, AiIcon = ({ className: o = "h-full w-full" }) => /* @__PURE__ */ jsx("svg", { className: o, viewBox: "0 0 256 256", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "m198.39 128.986-52.16-19.216-19.216-52.16a16 16 0 0 0-30.028 0L77.77 109.77l-52.16 19.216a16 16 0 0 0 0 30.028l52.16 19.216 19.216 52.16a16 16 0 0 0 30.028 0l19.216-52.16 52.16-19.216a16 16 0 0 0 0-30.028m-57.69 34.23a15.97 15.97 0 0 0-9.483 9.483l-19.22 52.152-19.214-52.15a15.97 15.97 0 0 0-9.482-9.484l-52.152-19.22 52.15-19.214a15.97 15.97 0 0 0 9.484-9.482l19.22-52.152 19.214 52.15a15.97 15.97 0 0 0 9.482 9.484l52.152 19.22ZM144 40a8 8 0 0 1 8-8h16V16a8 8 0 0 1 16 0v16h16a8 8 0 0 1 0 16h-16v16a8 8 0 0 1-16 0V48h-16a8 8 0 0 1-8-8m104 48a8 8 0 0 1-8 8h-8v8a8 8 0 0 1-16 0v-8h-8a8 8 0 0 1 0-16h8v-8a8 8 0 0 1 16 0v8h8a8 8 0 0 1 8 8" }) });
6693
6697
  function ManualClasses() {
6694
6698
  var L;
6695
- 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), [f, x] = useState(""), b = (L = first(d)) == null ? void 0 : L.prop, { classes: y } = getSplitChaiClasses(get(p, b, "")), S = y.split(" ").filter((T) => !isEmpty(T)), C = () => {
6699
+ const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), m = useRemoveClassesFromBlocks(), [g] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), b = (L = first(d)) == null ? void 0 : L.prop, { classes: y } = getSplitChaiClasses(get(p, b, "")), S = y.split(" ").filter((T) => !isEmpty(T)), v = () => {
6696
6700
  const T = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6697
- u(m, T, !0), x("");
6698
- }, [B, _] = useState([]), w = ({ value: T }) => {
6701
+ u(g, T, !0), x("");
6702
+ }, [B, _] = useState([]), j = ({ value: T }) => {
6699
6703
  const P = T.trim().toLowerCase(), R = P.match(/.+:/g);
6700
6704
  let D = [];
6701
6705
  if (R && R.length > 0) {
@@ -6707,7 +6711,7 @@ function ManualClasses() {
6707
6711
  } else
6708
6712
  D = i.search(P);
6709
6713
  return _(map(D, "item"));
6710
- }, v = () => {
6714
+ }, C = () => {
6711
6715
  _([]);
6712
6716
  }, k = (T) => T.name, I = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), A = useMemo(
6713
6717
  () => ({
@@ -6724,16 +6728,16 @@ function ManualClasses() {
6724
6728
  }, 0);
6725
6729
  },
6726
6730
  onKeyDown: (T) => {
6727
- T.key === "Enter" && f.trim() !== "" && C();
6731
+ T.key === "Enter" && f.trim() !== "" && v();
6728
6732
  },
6729
6733
  onChange: (T, { newValue: P }) => x(P),
6730
6734
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
6731
6735
  }),
6732
6736
  [f, c, o]
6733
- ), j = (T) => {
6737
+ ), w = (T) => {
6734
6738
  debugger;
6735
6739
  const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6736
- g(m, [T]), u(m, P, !0), r(""), l(-1);
6740
+ m(g, [T]), u(g, P, !0), r(""), l(-1);
6737
6741
  }, E = () => {
6738
6742
  if (navigator.clipboard === void 0) {
6739
6743
  toast.error(c("Clipboard not supported"));
@@ -6763,8 +6767,8 @@ function ManualClasses() {
6763
6767
  Autosuggest,
6764
6768
  {
6765
6769
  suggestions: B,
6766
- onSuggestionsFetchRequested: w,
6767
- onSuggestionsClearRequested: v,
6770
+ onSuggestionsFetchRequested: j,
6771
+ onSuggestionsClearRequested: C,
6768
6772
  getSuggestionValue: k,
6769
6773
  renderSuggestion: I,
6770
6774
  inputProps: A,
@@ -6783,7 +6787,7 @@ function ManualClasses() {
6783
6787
  {
6784
6788
  variant: "outline",
6785
6789
  className: "h-6 border-border",
6786
- onClick: C,
6790
+ onClick: v,
6787
6791
  disabled: f.trim() === "",
6788
6792
  size: "sm",
6789
6793
  children: /* @__PURE__ */ jsx(PlusIcon, {})
@@ -6798,10 +6802,10 @@ function ManualClasses() {
6798
6802
  value: n,
6799
6803
  onChange: (R) => r(R.target.value),
6800
6804
  onBlur: () => {
6801
- j(T);
6805
+ w(T);
6802
6806
  },
6803
6807
  onKeyDown: (R) => {
6804
- R.key === "Enter" && j(T);
6808
+ R.key === "Enter" && w(T);
6805
6809
  },
6806
6810
  onFocus: (R) => {
6807
6811
  setTimeout(() => {
@@ -6815,7 +6819,7 @@ function ManualClasses() {
6815
6819
  "button",
6816
6820
  {
6817
6821
  onDoubleClick: () => {
6818
- x(T), g(m, [T]), setTimeout(() => {
6822
+ x(T), m(g, [T]), setTimeout(() => {
6819
6823
  o.current && o.current.focus();
6820
6824
  }, 10);
6821
6825
  },
@@ -6825,7 +6829,7 @@ function ManualClasses() {
6825
6829
  /* @__PURE__ */ jsx(
6826
6830
  Cross2Icon,
6827
6831
  {
6828
- onClick: () => g(m, [T], !0),
6832
+ onClick: () => m(g, [T], !0),
6829
6833
  className: "hidden h-max w-3.5 cursor-pointer rounded bg-gray-100 p-0.5 text-red-500 hover:bg-gray-50 group-hover:block"
6830
6834
  }
6831
6835
  ),
@@ -6968,13 +6972,13 @@ function BlockStyling() {
6968
6972
  cssProperty: ""
6969
6973
  }), d = useThrottledCallback(
6970
6974
  (u) => {
6971
- const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
6975
+ const m = !get(i, "negative", !1), g = get(i, "cssProperty", "");
6972
6976
  let h = parseFloat(i.dragStartValue);
6973
6977
  h = isNaN(h) ? 0 : h;
6974
6978
  let f = MAPPER[i.dragUnit];
6975
- (startsWith(m, "scale") || m === "opacity") && (f = 10);
6979
+ (startsWith(g, "scale") || g === "opacity") && (f = 10);
6976
6980
  let b = (i.dragStartY - u.pageY) / f + h;
6977
- g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
6981
+ m && b < 0 && (b = 0), g === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
6978
6982
  },
6979
6983
  [i],
6980
6984
  50
@@ -7015,7 +7019,7 @@ const CoreBlock = ({
7015
7019
  parentId: r,
7016
7020
  position: a
7017
7021
  }) => {
7018
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
7022
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, m] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = () => {
7019
7023
  if (has(o, "blocks")) {
7020
7024
  const b = isFunction(o.blocks) ? o.blocks() : o.blocks;
7021
7025
  u(syncBlocksWithDefaults(b), r || null, a);
@@ -7032,7 +7036,7 @@ const CoreBlock = ({
7032
7036
  type: "button",
7033
7037
  onDragStart: (b) => {
7034
7038
  b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
7035
- g([]), m();
7039
+ m([]), g();
7036
7040
  }, 200);
7037
7041
  },
7038
7042
  draggable: f ? "true" : "false",
@@ -7068,8 +7072,8 @@ const registerChaiPreImportHTMLHook = (o) => {
7068
7072
  }, getPreImportHTML = async (o) => await PRE_IMPORT_HTML_HOOK(o), ImportHTML = ({ parentId: o, position: n }) => {
7069
7073
  const { t: r } = useTranslation(), [a, l] = useState(""), { addPredefinedBlock: i } = useAddBlock(), [c, d] = useState(!1), p = async () => {
7070
7074
  d(!0);
7071
- const u = await getPreImportHTML(a), g = getBlocksFromHTML(u);
7072
- i([...g], o, n), l(""), d(!1), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7075
+ const u = await getPreImportHTML(a), m = getBlocksFromHTML(u);
7076
+ i([...m], o, n), l(""), d(!1), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7073
7077
  };
7074
7078
  return /* @__PURE__ */ jsxs(Card, { className: "border-border/0 p-0 shadow-none", children: [
7075
7079
  /* @__PURE__ */ jsx(CardHeader, { className: "p-3", children: /* @__PURE__ */ jsx(CardDescription, { children: r("Use HTML snippets from Tailwind CSS component libraries") }) }),
@@ -7104,8 +7108,8 @@ const registerChaiPreImportHTMLHook = (o) => {
7104
7108
  height: i = ""
7105
7109
  }) => {
7106
7110
  const [c, d] = useState(o), p = (u) => {
7107
- const g = u.target.value;
7108
- d(g), n(g);
7111
+ const m = u.target.value;
7112
+ d(m), n(m);
7109
7113
  };
7110
7114
  return /* @__PURE__ */ jsx("div", { className: cn$1("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
7111
7115
  "select",
@@ -7154,12 +7158,12 @@ const registerChaiLibrary = (o, n) => {
7154
7158
  parentId: r = void 0,
7155
7159
  position: a = -1
7156
7160
  }) => {
7157
- 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", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), b = (C) => {
7158
- const B = has(C, "styles_attrs.data-page-section");
7159
- return C._type === "Box" && B;
7161
+ const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), g = get(o, "name", get(o, "label")), h = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), b = (v) => {
7162
+ const B = has(v, "styles_attrs.data-page-section");
7163
+ return v._type === "Box" && B;
7160
7164
  }, y = useCallback(
7161
- async (C) => {
7162
- if (C.stopPropagation(), has(o, "component")) {
7165
+ async (v) => {
7166
+ if (v.stopPropagation(), has(o, "component")) {
7163
7167
  d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7164
7168
  return;
7165
7169
  }
@@ -7176,20 +7180,20 @@ const registerChaiLibrary = (o, n) => {
7176
7180
  onClick: l ? () => {
7177
7181
  } : y,
7178
7182
  draggable: f ? "true" : "false",
7179
- onDragStart: async (C) => {
7183
+ onDragStart: async (v) => {
7180
7184
  const B = await c({ library: n, block: o });
7181
7185
  let _ = r;
7182
7186
  if (b(first(B)) && (_ = null), !isEmpty(B)) {
7183
- const w = { blocks: B, uiLibrary: !0, parent: _ };
7184
- if (C.dataTransfer.setData("text/plain", JSON.stringify(w)), o.preview) {
7185
- const v = new Image();
7186
- v.src = o.preview, v.onload = () => {
7187
- C.dataTransfer.setDragImage(v, 0, 0);
7187
+ const j = { blocks: B, uiLibrary: !0, parent: _ };
7188
+ if (v.dataTransfer.setData("text/plain", JSON.stringify(j)), o.preview) {
7189
+ const C = new Image();
7190
+ C.src = o.preview, C.onload = () => {
7191
+ v.dataTransfer.setDragImage(C, 0, 0);
7188
7192
  };
7189
7193
  } else
7190
- C.dataTransfer.setDragImage(new Image(), 0, 0);
7191
- x(w), setTimeout(() => {
7192
- u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7194
+ v.dataTransfer.setDragImage(new Image(), 0, 0);
7195
+ x(j), setTimeout(() => {
7196
+ u([]), m(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7193
7197
  }, 200);
7194
7198
  }
7195
7199
  },
@@ -7201,17 +7205,17 @@ const registerChaiLibrary = (o, n) => {
7201
7205
  /* @__PURE__ */ jsx(ReloadIcon, { className: "animate-spin h-4 w-4 text-white" }),
7202
7206
  /* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
7203
7207
  ] }),
7204
- o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: m }) : /* @__PURE__ */ jsxs("div", { className: "flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center", children: [
7205
- /* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: m }),
7208
+ o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: g }) : /* @__PURE__ */ jsxs("div", { className: "flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center", children: [
7209
+ /* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: g }),
7206
7210
  h && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600", children: h })
7207
7211
  ] })
7208
7212
  ]
7209
7213
  }
7210
7214
  ) }),
7211
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "max-w-xs", children: /* @__PURE__ */ jsx("p", { className: "font-medium", children: m }) }) })
7215
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "max-w-xs", children: /* @__PURE__ */ jsx("p", { className: "font-medium", children: g }) }) })
7212
7216
  ] });
7213
7217
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7214
- const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((j) => j.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [m, h] = useState([]), f = useRef(null);
7218
+ const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((w) => w.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, m] = useState(""), [g, h] = useState([]), f = useRef(null);
7215
7219
  useEffect(() => {
7216
7220
  c && c.length > 0 && (f.current = new Fuse(c, {
7217
7221
  keys: ["name", "label", "description", "group"],
@@ -7223,10 +7227,10 @@ const registerChaiLibrary = (o, n) => {
7223
7227
  h([]);
7224
7228
  return;
7225
7229
  }
7226
- const j = f.current.search(u).map((E) => E.item);
7227
- h(j);
7230
+ const w = f.current.search(u).map((E) => E.item);
7231
+ h(w);
7228
7232
  }, [u]);
7229
- const x = u.trim() && !isEmpty(m) ? m : c, b = groupBy(x, "group"), [y, S] = useState(null);
7233
+ const x = u.trim() && !isEmpty(g) ? g : c, b = groupBy(x, "group"), [y, S] = useState(null);
7230
7234
  useEffect(() => {
7231
7235
  if (isEmpty(keys(b))) {
7232
7236
  S(null);
@@ -7237,21 +7241,21 @@ const registerChaiLibrary = (o, n) => {
7237
7241
  return;
7238
7242
  }
7239
7243
  }, [b, y]);
7240
- const C = get(b, y, []), B = useRef(null), { t: _ } = useTranslation(), w = (j) => {
7244
+ const v = get(b, y, []), B = useRef(null), { t: _ } = useTranslation(), j = (w) => {
7241
7245
  B.current && (clearTimeout(B.current), B.current = null), B.current = setTimeout(() => {
7242
- B.current && S(j);
7246
+ B.current && S(w);
7243
7247
  }, 400);
7244
- }, v = () => {
7248
+ }, C = () => {
7245
7249
  i != null && i.id && p(i.id);
7246
7250
  }, k = () => {
7247
- g("");
7251
+ m("");
7248
7252
  };
7249
7253
  if (d)
7250
7254
  return /* @__PURE__ */ jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
7251
7255
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7252
7256
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7253
7257
  ] });
7254
- const I = filter(C, (j, E) => E % 2 === 0), A = filter(C, (j, E) => E % 2 === 1);
7258
+ const I = filter(v, (w, E) => E % 2 === 0), A = filter(v, (w, E) => E % 2 === 1);
7255
7259
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
7256
7260
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7257
7261
  /* @__PURE__ */ jsx(MagnifyingGlassIcon, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
@@ -7260,7 +7264,7 @@ const registerChaiLibrary = (o, n) => {
7260
7264
  {
7261
7265
  placeholder: _("Search blocks..."),
7262
7266
  value: u,
7263
- onChange: (j) => g(j.target.value),
7267
+ onChange: (w) => m(w.target.value),
7264
7268
  className: "w-full pl-8 pr-8"
7265
7269
  }
7266
7270
  ),
@@ -7281,14 +7285,14 @@ const registerChaiLibrary = (o, n) => {
7281
7285
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7282
7286
  /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(b) ? /* @__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: [
7283
7287
  /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("Failed to load the UI library. Try again") }),
7284
- /* @__PURE__ */ jsxs(Button, { onClick: v, variant: "outline", size: "sm", className: "gap-2", children: [
7288
+ /* @__PURE__ */ jsxs(Button, { onClick: C, variant: "outline", size: "sm", className: "gap-2", children: [
7285
7289
  /* @__PURE__ */ jsx(ReloadIcon, { className: "h-4 w-4" }),
7286
7290
  _("Retry")
7287
7291
  ] })
7288
- ] }) }) : map(b, (j, E) => /* @__PURE__ */ jsxs(
7292
+ ] }) }) : map(b, (w, E) => /* @__PURE__ */ jsxs(
7289
7293
  "div",
7290
7294
  {
7291
- onMouseEnter: () => w(E),
7295
+ onMouseEnter: () => j(E),
7292
7296
  onMouseLeave: () => clearTimeout(B.current),
7293
7297
  role: "button",
7294
7298
  onClick: () => S(E),
@@ -7311,23 +7315,23 @@ const registerChaiLibrary = (o, n) => {
7311
7315
  onMouseEnter: () => B.current ? clearTimeout(B.current) : null,
7312
7316
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
7313
7317
  children: [
7314
- isEmpty(C) && !isEmpty(b) ? /* @__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: [
7315
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: I.map((j, E) => /* @__PURE__ */ jsx(
7318
+ isEmpty(v) && !isEmpty(b) ? /* @__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: [
7319
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: I.map((w, E) => /* @__PURE__ */ jsx(
7316
7320
  BlockCard,
7317
7321
  {
7318
7322
  parentId: o,
7319
7323
  position: n,
7320
- block: j,
7324
+ block: w,
7321
7325
  library: i
7322
7326
  },
7323
7327
  `block-${E}`
7324
7328
  )) }),
7325
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: A.map((j, E) => /* @__PURE__ */ jsx(
7329
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: A.map((w, E) => /* @__PURE__ */ jsx(
7326
7330
  BlockCard,
7327
7331
  {
7328
7332
  parentId: o,
7329
7333
  position: n,
7330
- block: j,
7334
+ block: w,
7331
7335
  library: i
7332
7336
  },
7333
7337
  `block-second-${E}`
@@ -7355,7 +7359,7 @@ const registerChaiLibrary = (o, n) => {
7355
7359
  position: n,
7356
7360
  gridCols: r = "grid-cols-2"
7357
7361
  }) => {
7358
- const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u, g] = useAtom$1(hasInitializedPartialBlocksAtom);
7362
+ const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u, m] = useAtom$1(hasInitializedPartialBlocksAtom);
7359
7363
  useEffect(() => {
7360
7364
  if (!u || Object.keys(d.blocks).length === 0)
7361
7365
  if (c)
@@ -7364,17 +7368,17 @@ const registerChaiLibrary = (o, n) => {
7364
7368
  groups: [],
7365
7369
  isLoading: !1,
7366
7370
  error: c
7367
- }), g(!0);
7371
+ }), m(!0);
7368
7372
  else if (!l && Object.keys(a || {}).length > 0) {
7369
7373
  const h = Object.entries(a).map(([x, b]) => {
7370
- const y = b, S = y.type || "partial", C = formatReadableName(S);
7374
+ const y = b, S = y.type || "partial", v = formatReadableName(S);
7371
7375
  return {
7372
7376
  type: "PartialBlock",
7373
7377
  // Set the type to PartialBlock
7374
7378
  label: formatReadableName(y.name || x),
7375
7379
  description: y.description || "",
7376
7380
  icon: FrameIcon,
7377
- group: C,
7381
+ group: v,
7378
7382
  // Use formatted type as group
7379
7383
  category: "partial",
7380
7384
  partialBlockId: x,
@@ -7387,31 +7391,31 @@ const registerChaiLibrary = (o, n) => {
7387
7391
  groups: f,
7388
7392
  isLoading: !1,
7389
7393
  error: null
7390
- }), g(!0);
7394
+ }), m(!0);
7391
7395
  } else l ? p((h) => ({ ...h, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
7392
7396
  blocks: [],
7393
7397
  groups: [],
7394
7398
  isLoading: !1,
7395
7399
  error: "No partial blocks available"
7396
- }), g(!0));
7400
+ }), m(!0));
7397
7401
  }, [
7398
7402
  l,
7399
7403
  a,
7400
7404
  u,
7401
- g,
7405
+ m,
7402
7406
  p,
7403
7407
  d.blocks,
7404
7408
  c
7405
7409
  ]);
7406
- const m = () => {
7407
- p((h) => ({ ...h, isLoading: !0, error: null })), g(!1), i();
7410
+ const g = () => {
7411
+ p((h) => ({ ...h, isLoading: !0, error: null })), m(!1), i();
7408
7412
  };
7409
7413
  return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
7410
7414
  /* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
7411
7415
  /* @__PURE__ */ jsx(
7412
7416
  "button",
7413
7417
  {
7414
- onClick: m,
7418
+ onClick: g,
7415
7419
  className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
7416
7420
  children: "Refresh"
7417
7421
  }
@@ -7430,43 +7434,43 @@ const registerChaiLibrary = (o, n) => {
7430
7434
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...n });
7431
7435
  }, 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" }) => {
7432
7436
  var A;
7433
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (A = find(c, (j) => j._id === r)) == null ? void 0 : A._type, [h, f] = useState("all"), [x, b] = useState(null), y = useRef(null);
7437
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [m] = useAtom$1(addBlockTabAtom), g = (A = find(c, (w) => w._id === r)) == null ? void 0 : A._type, [h, f] = useState("all"), [x, b] = useState(null), y = useRef(null);
7434
7438
  useEffect(() => {
7435
- const j = setTimeout(() => {
7439
+ const w = setTimeout(() => {
7436
7440
  var E;
7437
7441
  (E = u.current) == null || E.focus();
7438
7442
  }, 0);
7439
- return () => clearTimeout(j);
7440
- }, [g]), useEffect(() => {
7443
+ return () => clearTimeout(w);
7444
+ }, [m]), useEffect(() => {
7441
7445
  d && (f("all"), b(null));
7442
- }, [d]), useEffect(() => (y.current = debounce((j) => {
7443
- f(j);
7446
+ }, [d]), useEffect(() => (y.current = debounce((w) => {
7447
+ f(w);
7444
7448
  }, 500), () => {
7445
7449
  y.current && y.current.cancel();
7446
7450
  }), []);
7447
- const S = useCallback((j) => {
7448
- b(j), y.current && y.current(j);
7449
- }, []), C = useCallback(() => {
7451
+ const S = useCallback((w) => {
7452
+ b(w), y.current && y.current(w);
7453
+ }, []), v = useCallback(() => {
7450
7454
  b(null), y.current && y.current.cancel();
7451
- }, []), B = useCallback((j) => {
7452
- y.current && y.current.cancel(), f(j), b(null);
7455
+ }, []), B = useCallback((w) => {
7456
+ y.current && y.current.cancel(), f(w), b(null);
7453
7457
  }, []), _ = useMemo(
7454
7458
  () => d ? values(n).filter(
7455
- (j) => {
7459
+ (w) => {
7456
7460
  var E, L;
7457
- return (((E = j.label) == null ? void 0 : E.toLowerCase()) + " " + ((L = j.type) == null ? void 0 : L.toLowerCase())).includes(d.toLowerCase());
7461
+ return (((E = w.label) == null ? void 0 : E.toLowerCase()) + " " + ((L = w.type) == null ? void 0 : L.toLowerCase())).includes(d.toLowerCase());
7458
7462
  }
7459
7463
  ) : n,
7460
7464
  [n, d]
7461
- ), w = useMemo(
7465
+ ), j = useMemo(
7462
7466
  () => d ? o.filter(
7463
- (j) => reject(filter(values(_), { group: j }), { hidden: !0 }).length > 0
7464
- ) : o.filter((j) => reject(filter(values(n), { group: j }), { hidden: !0 }).length > 0),
7467
+ (w) => reject(filter(values(_), { group: w }), { hidden: !0 }).length > 0
7468
+ ) : o.filter((w) => reject(filter(values(n), { group: w }), { hidden: !0 }).length > 0),
7465
7469
  [n, _, o, d]
7466
- ), v = useMemo(
7467
- () => sortBy(w, (j) => CORE_GROUPS.indexOf(j) === -1 ? 99 : CORE_GROUPS.indexOf(j)),
7468
- [w]
7469
- ), k = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), I = useMemo(() => h === "all" ? v : [h], [v, h]);
7470
+ ), C = useMemo(
7471
+ () => sortBy(j, (w) => CORE_GROUPS.indexOf(w) === -1 ? 99 : CORE_GROUPS.indexOf(w)),
7472
+ [j]
7473
+ ), k = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), I = useMemo(() => h === "all" ? C : [h], [C, h]);
7470
7474
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7471
7475
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7472
7476
  Input$1,
@@ -7476,43 +7480,43 @@ const registerChaiLibrary = (o, n) => {
7476
7480
  placeholder: i("Search blocks..."),
7477
7481
  value: d,
7478
7482
  className: "-ml-2",
7479
- onChange: (j) => p(j.target.value)
7483
+ onChange: (w) => p(w.target.value)
7480
7484
  }
7481
7485
  ) }),
7482
7486
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
7483
- v.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: [
7487
+ 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: [
7484
7488
  /* @__PURE__ */ jsx(
7485
7489
  "button",
7486
7490
  {
7487
7491
  onClick: () => B("all"),
7488
7492
  onMouseEnter: () => S("all"),
7489
- onMouseLeave: C,
7493
+ onMouseLeave: v,
7490
7494
  className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || x === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7491
7495
  children: i("All")
7492
7496
  },
7493
7497
  "sidebar-all"
7494
7498
  ),
7495
- v.map((j) => /* @__PURE__ */ jsx(
7499
+ C.map((w) => /* @__PURE__ */ jsx(
7496
7500
  "button",
7497
7501
  {
7498
- onClick: () => B(j),
7499
- onMouseEnter: () => S(j),
7500
- onMouseLeave: C,
7501
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === j || x === j ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7502
- children: capitalize(i(j.toLowerCase()))
7502
+ onClick: () => B(w),
7503
+ onMouseEnter: () => S(w),
7504
+ onMouseLeave: v,
7505
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === w || x === w ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7506
+ children: capitalize(i(w.toLowerCase()))
7503
7507
  },
7504
- `sidebar-${j}`
7508
+ `sidebar-${w}`
7505
7509
  ))
7506
7510
  ] }) }) }),
7507
- /* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: w.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
7511
+ /* @__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: j.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: [
7508
7512
  i("No blocks found matching"),
7509
7513
  ' "',
7510
7514
  d,
7511
7515
  '"'
7512
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: I.map((j) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7513
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(j.toLowerCase())) }),
7516
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: I.map((w) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7517
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(w.toLowerCase())) }),
7514
7518
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7515
- h === "all" ? filter(values(k), { group: j }) : values(k),
7519
+ h === "all" ? filter(values(k), { group: w }) : values(k),
7516
7520
  { hidden: !0 }
7517
7521
  ).map((E) => /* @__PURE__ */ jsx(
7518
7522
  CoreBlock,
@@ -7520,11 +7524,11 @@ const registerChaiLibrary = (o, n) => {
7520
7524
  parentId: r,
7521
7525
  position: a,
7522
7526
  block: E,
7523
- disabled: !canAcceptChildBlock(m, E.type) || !canBeNestedInside(m, E.type)
7527
+ disabled: !canAcceptChildBlock(g, E.type) || !canBeNestedInside(g, E.type)
7524
7528
  },
7525
7529
  E.type
7526
7530
  )) })
7527
- ] }, j)) }) }) })
7531
+ ] }, w)) }) }) })
7528
7532
  ] })
7529
7533
  ] });
7530
7534
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -7533,13 +7537,13 @@ const registerChaiLibrary = (o, n) => {
7533
7537
  parentId: r = void 0,
7534
7538
  position: a = -1
7535
7539
  }) => {
7536
- const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission: m } = usePermissions();
7540
+ const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), m = Object.keys(u || {}).length > 0, { hasPermission: g } = usePermissions();
7537
7541
  useEffect(() => {
7538
- i === "partials" && !g && c("library");
7539
- }, [i, g, c]);
7542
+ i === "partials" && !m && c("library");
7543
+ }, [i, m, c]);
7540
7544
  const h = useCallback(() => {
7541
7545
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7542
- }, []), f = useChaiAddBlockTabs(), x = p && m(PERMISSIONS.IMPORT_HTML), y = useChaiLibraries().length > 0;
7546
+ }, []), f = useChaiAddBlockTabs(), x = p && g(PERMISSIONS.IMPORT_HTML), y = useChaiLibraries().length > 0;
7543
7547
  return useEffect(() => {
7544
7548
  i === "library" && !y && c("core");
7545
7549
  }, [i, y, c]), /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
@@ -7559,13 +7563,13 @@ const registerChaiLibrary = (o, n) => {
7559
7563
  /* @__PURE__ */ jsxs(TabsList, { className: "flex w-full items-center", children: [
7560
7564
  y && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
7561
7565
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
7562
- g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7566
+ m && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7563
7567
  x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7564
7568
  map(f, (S) => /* @__PURE__ */ jsx(TabsTrigger, { value: S.id, children: React__default.createElement(S.tab) }, `tab-add-block-${S.id}`))
7565
7569
  ] }),
7566
7570
  /* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7567
7571
  y && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
7568
- g && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7572
+ m && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7569
7573
  x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
7570
7574
  map(f, (S) => /* @__PURE__ */ jsx(TabsContent, { value: S.id, children: React__default.createElement(S.tabContent, { close: h, parentId: r, position: a }) }, `panel-add-block-${S.id}`))
7571
7575
  ]
@@ -7689,10 +7693,10 @@ const registerChaiSaveToLibrary = (o) => {
7689
7693
  }, CANNOT_COPY_BLOCKS = !navigator.clipboard, CopyPasteBlocks = () => {
7690
7694
  const [o] = useBlocksStore(), [n] = useSelectedBlockIds(), { pasteBlocks: r } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(), d = useCallback(() => {
7691
7695
  const p = n.map((u) => {
7692
- const g = o.find((m) => m._id === u);
7696
+ const m = o.find((g) => g._id === u);
7693
7697
  return {
7694
7698
  id: u,
7695
- data: g
7699
+ data: m
7696
7700
  };
7697
7701
  });
7698
7702
  l(p.map((u) => u.id)) ? toast.warning("Partial blocks detected. Clone partial blocks?", {
@@ -7877,23 +7881,23 @@ const Input = ({ node: o }) => {
7877
7881
  var D;
7878
7882
  const { t: a } = useTranslation(), l = useUpdateBlocksProps(), [i] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
7879
7883
  let d = null;
7880
- const p = o.children.length > 0, { highlightBlock: u, clearHighlight: g } = useBlockHighlight(), { id: m, data: h, isSelected: f, willReceiveDrop: x, isDragging: b, isEditing: y, handleClick: S } = o, C = get(h, "_show", !0), B = (N) => {
7881
- N.stopPropagation(), C && o.toggle();
7884
+ const p = o.children.length > 0, { highlightBlock: u, clearHighlight: m } = useBlockHighlight(), { id: g, data: h, isSelected: f, willReceiveDrop: x, isDragging: b, isEditing: y, handleClick: S } = o, v = get(h, "_show", !0), B = (N) => {
7885
+ N.stopPropagation(), v && o.toggle();
7882
7886
  }, _ = (N) => {
7883
7887
  N.isInternal && (d = N.isOpen, N.isOpen && N.close());
7884
- }, w = (N) => {
7888
+ }, j = (N) => {
7885
7889
  N.isInternal && d !== null && (d ? N.open() : N.close(), d = null);
7886
- }, [v, k] = useAtom$1(currentAddSelection), I = () => {
7890
+ }, [C, k] = useAtom$1(currentAddSelection), I = () => {
7887
7891
  var N;
7888
7892
  A(), o.parent.isSelected || k((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7889
7893
  }, A = () => {
7890
7894
  k(null);
7891
- }, j = (N) => {
7892
- A(), N.stopPropagation(), !o.isOpen && C && o.toggle(), S(N);
7895
+ }, w = (N) => {
7896
+ A(), N.stopPropagation(), !o.isOpen && v && o.toggle(), S(N);
7893
7897
  };
7894
7898
  useEffect(() => {
7895
7899
  const N = setTimeout(() => {
7896
- x && !o.isOpen && !b && C && o.toggle();
7900
+ x && !o.isOpen && !b && v && o.toggle();
7897
7901
  }, 500);
7898
7902
  return () => clearTimeout(N);
7899
7903
  }, [x, o, b]);
@@ -7907,7 +7911,7 @@ const Input = ({ node: o }) => {
7907
7911
  const O = get(o, "parent.id");
7908
7912
  O !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: O, position: N }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: N });
7909
7913
  };
7910
- if (m === ROOT_TEMP_KEY)
7914
+ if (g === ROOT_TEMP_KEY)
7911
7915
  return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7912
7916
  /* @__PURE__ */ jsx("br", {}),
7913
7917
  c(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
@@ -7929,22 +7933,22 @@ const Input = ({ node: o }) => {
7929
7933
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7930
7934
  "div",
7931
7935
  {
7932
- onMouseEnter: () => u(m),
7933
- onMouseLeave: () => g(),
7934
- onClick: j,
7936
+ onMouseEnter: () => u(g),
7937
+ onMouseLeave: () => m(),
7938
+ onClick: w,
7935
7939
  style: n,
7936
- "data-node-id": m,
7940
+ "data-node-id": g,
7937
7941
  ref: r,
7938
7942
  onDragStart: () => _(o),
7939
- onDragEnd: () => w(o),
7943
+ onDragEnd: () => j(o),
7940
7944
  onDragOver: (N) => {
7941
- N.preventDefault(), E(m, "yes");
7945
+ N.preventDefault(), E(g, "yes");
7942
7946
  },
7943
7947
  onDragLeave: (N) => {
7944
- N.preventDefault(), E(m, "no");
7948
+ N.preventDefault(), E(g, "no");
7945
7949
  },
7946
7950
  onDrop: (N) => {
7947
- N.preventDefault(), E(m, "no");
7951
+ N.preventDefault(), E(g, "no");
7948
7952
  },
7949
7953
  children: [
7950
7954
  c(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((D = o == null ? void 0 : o.parent) == null ? void 0 : D.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
@@ -7966,9 +7970,9 @@ const Input = ({ node: o }) => {
7966
7970
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 py-0 outline-none",
7967
7971
  f ? "bg-primary/20" : "hover:bg-primary/10",
7968
7972
  x && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7969
- (o == null ? void 0 : o.id) === v ? "bg-primary/10" : "",
7973
+ (o == null ? void 0 : o.id) === C ? "bg-primary/10" : "",
7970
7974
  b && "opacity-20",
7971
- C ? "" : "line-through opacity-50",
7975
+ v ? "" : "line-through opacity-50",
7972
7976
  P && f && "bg-primary/20 text-primary"
7973
7977
  ),
7974
7978
  children: [
@@ -8007,11 +8011,11 @@ const Input = ({ node: o }) => {
8007
8011
  )
8008
8012
  ] }),
8009
8013
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-px group-hover:visible", children: [
8010
- canAddChildBlock(h == null ? void 0 : h._type) && C && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8014
+ canAddChildBlock(h == null ? void 0 : h._type) && v && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8011
8015
  /* @__PURE__ */ jsx(
8012
8016
  TooltipTrigger,
8013
8017
  {
8014
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: m }),
8018
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: g }),
8015
8019
  className: "cursor-pointer rounded bg-transparent p-px hover:bg-primary/10",
8016
8020
  asChild: !0,
8017
8021
  children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-4 w-4" })
@@ -8024,16 +8028,16 @@ const Input = ({ node: o }) => {
8024
8028
  TooltipTrigger,
8025
8029
  {
8026
8030
  onClick: (N) => {
8027
- N.stopPropagation(), l([m], { _show: !C }), o.isOpen && o.toggle();
8031
+ N.stopPropagation(), l([g], { _show: !v }), o.isOpen && o.toggle();
8028
8032
  },
8029
8033
  className: "cursor-pointer rounded bg-transparent p-0.5 hover:bg-primary/10",
8030
8034
  asChild: !0,
8031
- children: C ? /* @__PURE__ */ jsx(EyeClosedIcon, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(EyeOpenIcon, { className: "h-4 w-4" })
8035
+ children: v ? /* @__PURE__ */ jsx(EyeClosedIcon, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(EyeOpenIcon, { className: "h-4 w-4" })
8032
8036
  }
8033
8037
  ),
8034
- /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999] text-xs", side: "bottom", children: a(C ? "Hide the block from page" : "Show the block on page") })
8038
+ /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999] text-xs", side: "bottom", children: a(v ? "Hide the block from page" : "Show the block on page") })
8035
8039
  ] }),
8036
- /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: m, children: /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded bg-transparent p-px hover:bg-primary/10", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "h-3 w-3" }) }) })
8040
+ /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: g, children: /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded bg-transparent p-px hover:bg-primary/10", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "h-3 w-3" }) }) })
8037
8041
  ] })
8038
8042
  ]
8039
8043
  }
@@ -8427,7 +8431,7 @@ const Input = ({ node: o }) => {
8427
8431
  "popover-foreground": ["#3d3436", "#f2e9e4"]
8428
8432
  }
8429
8433
  }, LazyCssImportModal = lazy(
8430
- () => import("./css-import-modal-DaH4zyxk.js").then((o) => ({ default: o.CssImportModal }))
8434
+ () => import("./css-import-modal-DK2j6oGY.js").then((o) => ({ default: o.CssImportModal }))
8431
8435
  ), PREV_THEME_KEY = "chai-builder-previous-theme", DEFAULT_THEME_PRESET = [
8432
8436
  { shadcn_default: defaultShadcnPreset },
8433
8437
  { twitter_theme: twitter },
@@ -8451,86 +8455,86 @@ const Input = ({ node: o }) => {
8451
8455
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
8452
8456
  const [n, r] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions();
8453
8457
  if (d) {
8454
- const w = d.map((v) => Object.keys(v)[0]);
8455
- DEFAULT_THEME_PRESET.forEach((v) => {
8456
- const k = Object.keys(v)[0];
8457
- w.includes(k) || d.push(v);
8458
+ const j = d.map((C) => Object.keys(C)[0]);
8459
+ DEFAULT_THEME_PRESET.forEach((C) => {
8460
+ const k = Object.keys(C)[0];
8461
+ j.includes(k) || d.push(C);
8458
8462
  });
8459
8463
  }
8460
- const [g, m] = useTheme(), h = useThemeOptions(), { t: f } = useTranslation(), x = React.useCallback(
8461
- (w) => {
8462
- const v = { ...g };
8463
- setPreviousTheme(v), m(w), toast.success("Theme updated", {
8464
+ const [m, g] = useTheme(), h = useThemeOptions(), { t: f } = useTranslation(), x = React.useCallback(
8465
+ (j) => {
8466
+ const C = { ...m };
8467
+ setPreviousTheme(C), g(j), toast.success("Theme updated", {
8464
8468
  action: {
8465
8469
  label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
8466
8470
  /* @__PURE__ */ jsx(ResetIcon, { className: "h-4 w-4" }),
8467
8471
  " Undo"
8468
8472
  ] }),
8469
8473
  onClick: () => {
8470
- m(v), clearPreviousTheme(), toast.dismiss();
8474
+ g(C), clearPreviousTheme(), toast.dismiss();
8471
8475
  }
8472
8476
  },
8473
8477
  closeButton: !0,
8474
8478
  duration: 15e3
8475
8479
  });
8476
8480
  },
8477
- [g, m]
8481
+ [m, g]
8478
8482
  ), b = () => {
8479
- const w = d.find((v) => Object.keys(v)[0] === a);
8480
- if (w) {
8481
- const v = Object.values(w)[0];
8482
- v && typeof v == "object" && "fontFamily" in v && "borderRadius" in v && "colors" in v ? (x(v), l("")) : console.error("Invalid preset structure:", v);
8483
+ const j = d.find((C) => Object.keys(C)[0] === a);
8484
+ if (j) {
8485
+ const C = Object.values(j)[0];
8486
+ C && typeof C == "object" && "fontFamily" in C && "borderRadius" in C && "colors" in C ? (x(C), l("")) : console.error("Invalid preset structure:", C);
8483
8487
  } else
8484
8488
  console.error("Preset not found:", a);
8485
- }, y = (w) => {
8486
- x(w), l("");
8489
+ }, y = (j) => {
8490
+ x(j), l("");
8487
8491
  }, S = useDebouncedCallback(
8488
- (w, v) => {
8489
- m(() => ({
8490
- ...g,
8492
+ (j, C) => {
8493
+ g(() => ({
8494
+ ...m,
8491
8495
  fontFamily: {
8492
- ...g.fontFamily,
8493
- [w.replace(/font-/g, "")]: v
8496
+ ...m.fontFamily,
8497
+ [j.replace(/font-/g, "")]: C
8494
8498
  }
8495
8499
  }));
8496
8500
  },
8497
- [g],
8501
+ [m],
8498
8502
  200
8499
- ), C = React.useCallback(
8500
- (w) => {
8501
- m(() => ({
8502
- ...g,
8503
- borderRadius: `${w}px`
8503
+ ), v = React.useCallback(
8504
+ (j) => {
8505
+ g(() => ({
8506
+ ...m,
8507
+ borderRadius: `${j}px`
8504
8508
  }));
8505
8509
  },
8506
- [g]
8510
+ [m]
8507
8511
  ), B = useDebouncedCallback(
8508
- (w, v) => {
8509
- m(() => {
8510
- const k = get(g, `colors.${w}`);
8511
- return n ? set(k, 1, v) : set(k, 0, v), {
8512
- ...g,
8512
+ (j, C) => {
8513
+ g(() => {
8514
+ const k = get(m, `colors.${j}`);
8515
+ return n ? set(k, 1, C) : set(k, 0, C), {
8516
+ ...m,
8513
8517
  colors: {
8514
- ...g.colors,
8515
- [w]: k
8518
+ ...m.colors,
8519
+ [j]: k
8516
8520
  }
8517
8521
  };
8518
8522
  });
8519
8523
  },
8520
- [g],
8524
+ [m],
8521
8525
  200
8522
- ), _ = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([v]) => {
8523
- const k = get(g, `colors.${v}.${n ? 1 : 0}`);
8526
+ ), _ = (j) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(j.items).map(([C]) => {
8527
+ const k = get(m, `colors.${C}.${n ? 1 : 0}`);
8524
8528
  return k ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8525
8529
  /* @__PURE__ */ jsx(
8526
8530
  ColorPickerInput,
8527
8531
  {
8528
8532
  value: k,
8529
- onChange: (I) => B(v, I)
8533
+ onChange: (I) => B(C, I)
8530
8534
  }
8531
8535
  ),
8532
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: v.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((I) => I.charAt(0).toUpperCase() + I.slice(1)).join(" ") + (!v.toLowerCase().includes("foreground") && !v.toLowerCase().includes("border") && !v.toLowerCase().includes("input") && !v.toLowerCase().includes("ring") && !v.toLowerCase().includes("background") ? " Background" : "") })
8533
- ] }, v) : null;
8536
+ /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: C.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((I) => I.charAt(0).toUpperCase() + I.slice(1)).join(" ") + (!C.toLowerCase().includes("foreground") && !C.toLowerCase().includes("border") && !C.toLowerCase().includes("input") && !C.toLowerCase().includes("ring") && !C.toLowerCase().includes("background") ? " Background" : "") })
8537
+ ] }, C) : null;
8534
8538
  }) });
8535
8539
  return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
8536
8540
  /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
@@ -8545,9 +8549,9 @@ const Input = ({ node: o }) => {
8545
8549
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
8546
8550
  /* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
8547
8551
  /* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
8548
- /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((w) => {
8549
- const v = Object.keys(w)[0], k = v.replaceAll("_", " ");
8550
- return /* @__PURE__ */ jsx(SelectItem, { value: v, children: capitalize(k) }, v);
8552
+ /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((j) => {
8553
+ const C = Object.keys(j)[0], k = C.replaceAll("_", " ");
8554
+ return /* @__PURE__ */ jsx(SelectItem, { value: C, children: capitalize(k) }, C);
8551
8555
  }) })
8552
8556
  ] }) }),
8553
8557
  /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: b, children: f("Apply") }) })
@@ -8559,14 +8563,14 @@ const Input = ({ node: o }) => {
8559
8563
  /* @__PURE__ */ jsx(TextIcon, { className: "h-3 w-3 text-gray-600" }),
8560
8564
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Typography" })
8561
8565
  ] }),
8562
- (h == null ? void 0 : h.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(h.fontFamily).map(([w, v]) => /* @__PURE__ */ jsx(
8566
+ (h == null ? void 0 : h.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(h.fontFamily).map(([j, C]) => /* @__PURE__ */ jsx(
8563
8567
  FontSelector,
8564
8568
  {
8565
- label: w,
8566
- value: g.fontFamily[w.replace(/font-/g, "")] || v[Object.keys(v)[0]],
8567
- onChange: (k) => S(w, k)
8569
+ label: j,
8570
+ value: m.fontFamily[j.replace(/font-/g, "")] || C[Object.keys(C)[0]],
8571
+ onChange: (k) => S(j, k)
8568
8572
  },
8569
- w
8573
+ j
8570
8574
  )) }),
8571
8575
  /* @__PURE__ */ jsx(Separator, {}),
8572
8576
  (h == null ? void 0 : h.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
@@ -8575,9 +8579,9 @@ const Input = ({ node: o }) => {
8575
8579
  /* @__PURE__ */ jsx(CornerTopRightIcon, { className: "h-3 w-3 text-gray-600" }),
8576
8580
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Border Radius" })
8577
8581
  ] }),
8578
- /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: g.borderRadius })
8582
+ /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: m.borderRadius })
8579
8583
  ] }),
8580
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: g.borderRadius, onChange: C }) })
8584
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: m.borderRadius, onChange: v }) })
8581
8585
  ] }),
8582
8586
  /* @__PURE__ */ jsx(Separator, {}),
8583
8587
  (h == null ? void 0 : h.colors) && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
@@ -8592,7 +8596,7 @@ const Input = ({ node: o }) => {
8592
8596
  Switch,
8593
8597
  {
8594
8598
  checked: n,
8595
- onCheckedChange: (w) => r(w),
8599
+ onCheckedChange: (j) => r(j),
8596
8600
  "aria-label": "Toggle dark mode",
8597
8601
  className: "mx-1"
8598
8602
  }
@@ -8600,7 +8604,7 @@ const Input = ({ node: o }) => {
8600
8604
  /* @__PURE__ */ jsx(MoonIcon, { className: "h-4 w-4" })
8601
8605
  ] }) })
8602
8606
  ] }),
8603
- /* @__PURE__ */ jsx("div", { className: "space-y-2", children: h.colors.map((w) => _(w)) })
8607
+ /* @__PURE__ */ jsx("div", { className: "space-y-2", children: h.colors.map((j) => _(j)) })
8604
8608
  ] }),
8605
8609
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: i && /* @__PURE__ */ jsx(
8606
8610
  LazyCssImportModal,
@@ -9114,7 +9118,7 @@ function QuickPrompts({ onClick: o }) {
9114
9118
  lang: get(LANGUAGES, a, a)
9115
9119
  })
9116
9120
  }), /* @__PURE__ */ jsx("div", { className: n ? "pointer-events-none opacity-50" : "", children: /* @__PURE__ */ jsx("ul", { className: "space-y-1", children: c.map(
9117
- ({ name: d, icon: p, subMenus: u, prompt: g }) => u ? /* @__PURE__ */ jsxs(Popover, { children: [
9121
+ ({ name: d, icon: p, subMenus: u, prompt: m }) => u ? /* @__PURE__ */ jsxs(Popover, { children: [
9118
9122
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
9119
9123
  "li",
9120
9124
  {
@@ -9130,7 +9134,7 @@ function QuickPrompts({ onClick: o }) {
9130
9134
  ] }) : /* @__PURE__ */ jsxs(
9131
9135
  "li",
9132
9136
  {
9133
- onClick: () => o(g),
9137
+ onClick: () => o(m),
9134
9138
  className: "flex cursor-pointer items-center space-x-2 rounded p-1 text-xs hover:bg-primary/10 hover:text-primary dark:hover:bg-gray-800",
9135
9139
  children: [
9136
9140
  /* @__PURE__ */ jsx(p, { className: "h-3.5 w-3.5" }),
@@ -9144,10 +9148,10 @@ function QuickPrompts({ onClick: o }) {
9144
9148
  const AIUserPrompt = ({ blockId: o }) => {
9145
9149
  const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), u = useSelectedBlock();
9146
9150
  useEffect(() => {
9147
- var m;
9148
- (m = d.current) == null || m.focus();
9151
+ var g;
9152
+ (g = d.current) == null || g.focus();
9149
9153
  }, []);
9150
- const g = () => {
9154
+ const m = () => {
9151
9155
  l || c("");
9152
9156
  };
9153
9157
  return /* @__PURE__ */ jsx("div", { className: "", children: o ? /* @__PURE__ */ jsxs("div", { className: "", children: [
@@ -9162,8 +9166,8 @@ const AIUserPrompt = ({ blockId: o }) => {
9162
9166
  /* @__PURE__ */ jsx("div", { className: "rounded border p-2 text-sm", children: /* @__PURE__ */ jsx(
9163
9167
  QuickPrompts,
9164
9168
  {
9165
- onClick: (m) => {
9166
- p.current && clearTimeout(p.current), r("content", o, m, g);
9169
+ onClick: (g) => {
9170
+ p.current && clearTimeout(p.current), r("content", o, g, m);
9167
9171
  }
9168
9172
  }
9169
9173
  ) }),
@@ -9175,12 +9179,12 @@ const AIUserPrompt = ({ blockId: o }) => {
9175
9179
  {
9176
9180
  ref: d,
9177
9181
  value: i,
9178
- onChange: (m) => c(m.target.value),
9182
+ onChange: (g) => c(g.target.value),
9179
9183
  placeholder: n("Ask AI to edit content"),
9180
9184
  className: "w-full resize-none border-none p-0 text-xs shadow-none outline-none",
9181
9185
  rows: 3,
9182
- onKeyDown: (m) => {
9183
- m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), r("content", o, i, g));
9186
+ onKeyDown: (g) => {
9187
+ g.key === "Enter" && (g.preventDefault(), p.current && clearTimeout(p.current), r("content", o, i, m));
9184
9188
  }
9185
9189
  }
9186
9190
  ),
@@ -9190,7 +9194,7 @@ const AIUserPrompt = ({ blockId: o }) => {
9190
9194
  Button,
9191
9195
  {
9192
9196
  onClick: () => {
9193
- p.current && clearTimeout(p.current), r("content", o, i, g);
9197
+ p.current && clearTimeout(p.current), r("content", o, i, m);
9194
9198
  },
9195
9199
  variant: "default",
9196
9200
  className: "h-7 w-7",
@@ -9241,140 +9245,7 @@ const UndoRedo = () => {
9241
9245
  /* @__PURE__ */ jsx(Button, { disabled: !o(), size: "sm", onClick: r, className: "rounded-full", variant: "ghost", children: /* @__PURE__ */ jsx(ResetIcon, {}) }),
9242
9246
  /* @__PURE__ */ jsx(Button, { disabled: !n(), onClick: a, size: "sm", className: "rounded-full", variant: "ghost", children: /* @__PURE__ */ jsx(ResetIcon, { className: "rotate-180 scale-y-[-1] transform" }) })
9243
9247
  ] });
9244
- };
9245
- function AIChatPanel() {
9246
- const [o, n] = useState([]), [r, a] = useState(""), [l, i] = useState(!1), [c, d] = useState(null), p = useRef(null), u = useRef(null), g = useRef(null);
9247
- useEffect(() => {
9248
- var y;
9249
- (y = u.current) == null || y.scrollIntoView({ behavior: "smooth" });
9250
- }, [o]), useEffect(() => {
9251
- g.current && (g.current.style.height = "auto", g.current.style.height = `${Math.min(g.current.scrollHeight, 120)}px`);
9252
- }, [r]);
9253
- const m = async () => {
9254
- if (!r.trim() && !c) return;
9255
- const y = {
9256
- id: Date.now().toString(),
9257
- role: "user",
9258
- content: r,
9259
- timestamp: /* @__PURE__ */ new Date()
9260
- };
9261
- n((S) => [...S, y]), a(""), i(!0), setTimeout(() => {
9262
- const S = {
9263
- id: (Date.now() + 1).toString(),
9264
- role: "assistant",
9265
- content: "This is a sample response from the AI assistant. In a real implementation, this would be replaced with an actual response from the AI model.",
9266
- timestamp: /* @__PURE__ */ new Date()
9267
- };
9268
- n((C) => [...C, S]), i(!1), d(null);
9269
- }, 1500);
9270
- }, h = (y) => {
9271
- y.key === "Enter" && !y.shiftKey && (y.preventDefault(), m());
9272
- }, f = (y) => {
9273
- var C;
9274
- const S = (C = y.target.files) == null ? void 0 : C[0];
9275
- if (S) {
9276
- const B = new FileReader();
9277
- B.onload = (_) => {
9278
- var w;
9279
- d((w = _.target) == null ? void 0 : w.result);
9280
- }, B.readAsDataURL(S);
9281
- }
9282
- }, x = () => {
9283
- var y;
9284
- (y = p.current) == null || y.click();
9285
- }, b = () => {
9286
- d(null), p.current && (p.current.value = "");
9287
- };
9288
- return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
9289
- /* @__PURE__ */ jsx(ScrollArea, { className: "flex-1 p-3", children: o.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "mt-10 flex h-full flex-col items-center justify-center p-4 text-center text-muted-foreground", children: [
9290
- /* @__PURE__ */ jsx(AiIcon, { className: "mb-2 h-8 w-8 text-primary/50" }),
9291
- /* @__PURE__ */ jsx("p", { className: "text-sm", children: "Ask me anything to get started" })
9292
- ] }) : /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
9293
- o.map((y) => /* @__PURE__ */ jsxs(
9294
- "div",
9295
- {
9296
- className: cn$2(
9297
- "flex max-w-full gap-2",
9298
- y.role === "assistant" ? "items-start" : "items-start justify-end"
9299
- ),
9300
- children: [
9301
- y.role === "assistant" && /* @__PURE__ */ jsx(Avatar, { className: "h-6 w-6 bg-primary/10", children: /* @__PURE__ */ jsx(AiIcon, { className: "h-3 w-3 text-primary" }) }),
9302
- /* @__PURE__ */ jsx(
9303
- "div",
9304
- {
9305
- className: cn$2(
9306
- "rounded-lg px-3 py-2 text-sm",
9307
- y.role === "assistant" ? "bg-muted text-foreground" : "bg-primary text-primary-foreground"
9308
- ),
9309
- children: y.content
9310
- }
9311
- ),
9312
- y.role === "user" && /* @__PURE__ */ jsx(Avatar, { className: "h-6 w-6 bg-primary", children: /* @__PURE__ */ jsx("span", { className: "text-xs text-primary-foreground", children: "You" }) })
9313
- ]
9314
- },
9315
- y.id
9316
- )),
9317
- l && /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
9318
- /* @__PURE__ */ jsx(Avatar, { className: "h-6 w-6 bg-primary/10", children: /* @__PURE__ */ jsx(AiIcon, { className: "h-3 w-3 text-primary" }) }),
9319
- /* @__PURE__ */ jsx("div", { className: "rounded-lg bg-muted px-3 py-2", children: /* @__PURE__ */ jsx(ReloadIcon, { className: "h-4 w-4 animate-spin text-muted-foreground" }) })
9320
- ] }),
9321
- /* @__PURE__ */ jsx("div", { ref: u })
9322
- ] }) }),
9323
- c && /* @__PURE__ */ jsx("div", { className: "px-3 pt-2", children: /* @__PURE__ */ jsxs("div", { className: "relative h-20 w-20 overflow-hidden rounded-md", children: [
9324
- /* @__PURE__ */ jsx("img", { src: c || "/placeholder.svg", alt: "Attachment", className: "h-full w-full object-cover" }),
9325
- /* @__PURE__ */ jsx(
9326
- Button,
9327
- {
9328
- size: "icon",
9329
- variant: "destructive",
9330
- className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
9331
- onClick: b,
9332
- children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" })
9333
- }
9334
- )
9335
- ] }) }),
9336
- /* @__PURE__ */ jsx("div", { className: "mt-auto p-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
9337
- /* @__PURE__ */ jsxs("div", { className: "relative flex-1", children: [
9338
- /* @__PURE__ */ jsx(
9339
- Textarea,
9340
- {
9341
- ref: g,
9342
- value: r,
9343
- onChange: (y) => a(y.target.value),
9344
- onKeyDown: h,
9345
- placeholder: "Ask something...",
9346
- className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
9347
- }
9348
- ),
9349
- /* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: f, accept: "image/*", className: "hidden" }),
9350
- /* @__PURE__ */ jsx(
9351
- Button,
9352
- {
9353
- size: "icon",
9354
- variant: "ghost",
9355
- className: "absolute bottom-2 right-2 h-6 w-6",
9356
- onClick: x,
9357
- children: /* @__PURE__ */ jsx(ImageIcon, { className: "h-4 w-4 text-muted-foreground" })
9358
- }
9359
- )
9360
- ] }),
9361
- /* @__PURE__ */ jsxs(
9362
- Button,
9363
- {
9364
- size: "sm",
9365
- className: "h-10 px-3",
9366
- onClick: m,
9367
- disabled: l || !r.trim() && !c,
9368
- children: [
9369
- /* @__PURE__ */ jsx(PaperPlaneIcon, { className: "mr-1 h-4 w-4" }),
9370
- "Send"
9371
- ]
9372
- }
9373
- )
9374
- ] }) })
9375
- ] });
9376
- }
9377
- const ClearCanvas = () => {
9248
+ }, ClearCanvas = () => {
9378
9249
  const { t: o } = useTranslation(), { setNewBlocks: n } = useBlocksStoreUndoableActions(), [, r] = useSelectedBlockIds(), [, a] = useSelectedStylingBlocks(), l = useCallback(() => {
9379
9250
  n([]), r([]), a([]);
9380
9251
  }, [n]);
@@ -9449,7 +9320,7 @@ const ClearCanvas = () => {
9449
9320
  preloadedAttributes: n = [],
9450
9321
  onAttributesChange: r
9451
9322
  }) {
9452
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), f = useRef(null), x = useRef(null), b = usePageExternalData(), { t: y } = useTranslation();
9323
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, m] = useState(null), [g, h] = useState(""), f = useRef(null), x = useRef(null), b = usePageExternalData(), { t: y } = useTranslation();
9453
9324
  useEffect(() => {
9454
9325
  l(n);
9455
9326
  }, [n]);
@@ -9462,11 +9333,11 @@ const ClearCanvas = () => {
9462
9333
  const k = [...a, { key: i, value: d }];
9463
9334
  r(k), l(a), c(""), p(""), h("");
9464
9335
  }
9465
- }, C = (k) => {
9466
- const I = a.filter((A, j) => j !== k);
9336
+ }, v = (k) => {
9337
+ const I = a.filter((A, w) => w !== k);
9467
9338
  r(I), l(I);
9468
9339
  }, B = (k) => {
9469
- g(k), c(a[k].key), p(a[k].value);
9340
+ m(k), c(a[k].key), p(a[k].value);
9470
9341
  }, _ = () => {
9471
9342
  if (i.startsWith("@")) {
9472
9343
  h("Attribute keys cannot start with '@'");
@@ -9474,11 +9345,11 @@ const ClearCanvas = () => {
9474
9345
  }
9475
9346
  if (u !== null && i) {
9476
9347
  const k = [...a];
9477
- k[u] = { key: i, value: d }, r(k), l(k), g(null), c(""), p(""), h("");
9348
+ k[u] = { key: i, value: d }, r(k), l(k), m(null), c(""), p(""), h("");
9478
9349
  }
9479
- }, w = (k) => {
9350
+ }, j = (k) => {
9480
9351
  k.key === "Enter" && !k.shiftKey && (k.preventDefault(), u !== null ? _() : S());
9481
- }, v = useCallback((k) => {
9352
+ }, C = useCallback((k) => {
9482
9353
  const I = (E) => /[.,!?;:]/.test(E), A = (E, L, T) => {
9483
9354
  let P = "", R = "";
9484
9355
  const D = L > 0 ? E[L - 1] : "", N = L < E.length ? E[L] : "";
@@ -9487,9 +9358,9 @@ const ClearCanvas = () => {
9487
9358
  prefixLength: P.length,
9488
9359
  suffixLength: R.length
9489
9360
  };
9490
- }, j = x.current;
9491
- if (j) {
9492
- const E = j.selectionStart || 0, L = j.value || "", T = j.selectionEnd || E;
9361
+ }, w = x.current;
9362
+ if (w) {
9363
+ const E = w.selectionStart || 0, L = w.value || "", T = w.selectionEnd || E;
9493
9364
  if (T > E) {
9494
9365
  const O = `{{${k}}}`, { text: $ } = A(L, E, O), M = L.slice(0, E) + $ + L.slice(T);
9495
9366
  p(M);
@@ -9529,7 +9400,7 @@ const ClearCanvas = () => {
9529
9400
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9530
9401
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9531
9402
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9532
- !isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: v })
9403
+ !isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: C })
9533
9404
  ] }),
9534
9405
  /* @__PURE__ */ jsx(
9535
9406
  Textarea,
@@ -9542,7 +9413,7 @@ const ClearCanvas = () => {
9542
9413
  ref: x,
9543
9414
  value: d,
9544
9415
  onChange: (k) => p(k.target.value),
9545
- onKeyDown: w,
9416
+ onKeyDown: j,
9546
9417
  placeholder: "Enter Value",
9547
9418
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
9548
9419
  }
@@ -9550,7 +9421,7 @@ const ClearCanvas = () => {
9550
9421
  ] })
9551
9422
  ] }),
9552
9423
  /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !i.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: u !== null ? "Save" : "Add" }) }),
9553
- m && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: m })
9424
+ g && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: g })
9554
9425
  ]
9555
9426
  }
9556
9427
  ),
@@ -9561,7 +9432,7 @@ const ClearCanvas = () => {
9561
9432
  ] }),
9562
9433
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9563
9434
  /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(I), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
9564
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => C(I), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
9435
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(I), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
9565
9436
  ] })
9566
9437
  ] }, I)) })
9567
9438
  ] });
@@ -9703,47 +9574,35 @@ const PartialWrapper = ({ partialBlockId: o }) => {
9703
9574
  component: DefaultTopBar
9704
9575
  }, registerChaiTopBar = (o) => {
9705
9576
  TOP_BAR.component = o;
9706
- }, useTopBarComponent = () => useMemo(() => TOP_BAR.component, []), DEFAULT_PANEL_WIDTH = 280, OutlineButton = ({ isActive: o, show: n }) => /* @__PURE__ */ jsx(Button, { variant: o ? "default" : "ghost", size: "icon", onClick: n, children: /* @__PURE__ */ jsx(StackIcon, { className: "h-5 w-5" }) }), AiButton = ({ isActive: o, show: n }) => /* @__PURE__ */ jsx(Button, { variant: o ? "default" : "ghost", size: "icon", onClick: n, children: /* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }) }), AskAiButton = ({ isActive: o, show: n }) => /* @__PURE__ */ jsx(Button, { variant: o ? "default" : "ghost", size: "icon", onClick: n, children: /* @__PURE__ */ jsx(AiIcon, {}) });
9707
- function useSidebarDefaultPanels() {
9708
- const o = useBuilderProp("askAiCallBack", null), n = useFeature("aiChat");
9709
- return useMemo(() => {
9710
- const r = [];
9711
- return r.push({
9712
- id: "ask-ai",
9713
- button: AskAiButton,
9714
- label: "Ask AI",
9715
- isInternal: !0,
9716
- width: DEFAULT_PANEL_WIDTH,
9717
- panel: () => /* @__PURE__ */ jsx("div", { className: "", children: /* @__PURE__ */ jsx(AskAI, {}) })
9718
- }), r.push({
9719
- id: "outline",
9720
- label: "Outline",
9721
- isInternal: !0,
9722
- width: DEFAULT_PANEL_WIDTH,
9723
- button: OutlineButton,
9724
- panel: () => /* @__PURE__ */ jsx("div", { className: "-mt-8", children: /* @__PURE__ */ jsx(ListTree, {}) })
9725
- }), o && n && r.unshift({
9726
- id: "ai",
9727
- button: AiButton,
9728
- label: "AI Assistant",
9729
- isInternal: !0,
9730
- width: 450,
9731
- panel: () => /* @__PURE__ */ jsx("div", { className: "-mt-8 h-full max-h-full", children: /* @__PURE__ */ jsx(AIChatPanel, {}) })
9732
- }), compact(r);
9733
- }, [o, n]);
9734
- }
9577
+ }, useTopBarComponent = () => useMemo(() => TOP_BAR.component, []), DEFAULT_PANEL_WIDTH = 280, OutlineButton = ({ isActive: o, show: n }) => /* @__PURE__ */ jsx(Button, { variant: o ? "default" : "ghost", size: "icon", onClick: n, children: /* @__PURE__ */ jsx(StackIcon, { className: "h-5 w-5" }) }), AskAiButton = ({ isActive: o, show: n }) => /* @__PURE__ */ jsx(Button, { variant: o ? "default" : "ghost", size: "icon", onClick: n, children: /* @__PURE__ */ jsx(AiIcon, {}) });
9578
+ registerChaiSidebarPanel("chai-chat-panel", {
9579
+ button: AskAiButton,
9580
+ label: "Ask AI",
9581
+ position: "top",
9582
+ isInternal: !0,
9583
+ width: DEFAULT_PANEL_WIDTH,
9584
+ panel: () => /* @__PURE__ */ jsx("div", { className: "", children: /* @__PURE__ */ jsx(AskAI, {}) })
9585
+ });
9586
+ registerChaiSidebarPanel("outline", {
9587
+ button: OutlineButton,
9588
+ label: "Outline",
9589
+ position: "top",
9590
+ isInternal: !0,
9591
+ width: DEFAULT_PANEL_WIDTH,
9592
+ panel: () => /* @__PURE__ */ jsx("div", { className: "", children: /* @__PURE__ */ jsx(ListTree, {}) })
9593
+ });
9735
9594
  const RootLayout = () => {
9736
- const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), m = reverse([...g ?? []]), h = useCallback((k) => {
9595
+ const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), m = reverse([...u ?? []]), g = useCallback((k) => {
9737
9596
  k.preventDefault();
9738
- }, []), f = useCallback(
9597
+ }, []), h = useMemo(() => {
9598
+ const k = [p].flat(), I = k.find((w) => w.id === "chai-chat-panel"), A = k.filter((w) => w.id !== "chai-chat-panel");
9599
+ return I ? [I, ...A] : k;
9600
+ }, [p]), f = useCallback(
9739
9601
  (k) => {
9740
9602
  console.log("handleMenuItemClick", k, n), r(n === k ? null : k);
9741
9603
  },
9742
9604
  [n, r]
9743
- ), { t: x } = useTranslation(), b = useMemo(
9744
- () => [...p, ...u, ...g],
9745
- [p, u, g]
9746
- ), y = useBuilderProp("htmlDir", "ltr"), S = find(b, { id: n }) ?? first(b), C = get(S, "width", DEFAULT_PANEL_WIDTH);
9605
+ ), { t: x } = useTranslation(), b = useMemo(() => [...p, ...u], [p, u]), y = useBuilderProp("htmlDir", "ltr"), S = find(b, { id: n }) ?? first(b), v = get(S, "width", DEFAULT_PANEL_WIDTH);
9747
9606
  useEffect(() => {
9748
9607
  if (n !== null) {
9749
9608
  const k = find(b, { id: n });
@@ -9753,16 +9612,16 @@ const RootLayout = () => {
9753
9612
  const B = useMemo(() => {
9754
9613
  if (n === null) return 0;
9755
9614
  const k = find(b, { id: n });
9756
- return get(k, "view", "standard") === "standard" ? C : l;
9757
- }, [n, C, l, b]), _ = useCallback(() => {
9615
+ return get(k, "view", "standard") === "standard" ? v : l;
9616
+ }, [n, v, l, b]), _ = useCallback(() => {
9758
9617
  r(a.current);
9759
- }, [r, n]), w = useCallback(() => {
9618
+ }, [r, n]), j = useCallback(() => {
9760
9619
  r("outline");
9761
9620
  }, [r]);
9762
9621
  useEffect(() => {
9763
9622
  n !== null && !find(b, { id: n }) && r("outline");
9764
9623
  }, [n, b]);
9765
- const v = useCallback(
9624
+ const C = useCallback(
9766
9625
  (k) => {
9767
9626
  f(k);
9768
9627
  },
@@ -9772,18 +9631,18 @@ const RootLayout = () => {
9772
9631
  /* @__PURE__ */ jsxs(
9773
9632
  "div",
9774
9633
  {
9775
- onContextMenu: h,
9634
+ onContextMenu: g,
9776
9635
  className: "flex h-full max-h-full flex-col bg-background text-foreground",
9777
9636
  children: [
9778
9637
  /* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
9779
9638
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9780
9639
  /* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9781
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((k, I) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9640
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: h.map((k, I) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9782
9641
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(k, "button", NoopComponent), {
9783
9642
  position: "top",
9784
9643
  panelId: k.id,
9785
9644
  isActive: n === k.id,
9786
- show: () => v(k.id)
9645
+ show: () => C(k.id)
9787
9646
  }) }),
9788
9647
  /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(k.label) }) })
9789
9648
  ] }, "button-top-" + I)) }),
@@ -9793,7 +9652,7 @@ const RootLayout = () => {
9793
9652
  position: "bottom",
9794
9653
  panelId: k.id,
9795
9654
  isActive: n === k.id,
9796
- show: () => v(k.id)
9655
+ show: () => C(k.id)
9797
9656
  }) }),
9798
9657
  /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(k.label) }) })
9799
9658
  ] }, "button-bottom-" + I)) })
@@ -9865,26 +9724,26 @@ const RootLayout = () => {
9865
9724
  {
9866
9725
  side: "left",
9867
9726
  className: "flex flex-col gap-0 p-0 sm:max-w-full",
9868
- style: { width: `${C}px` },
9727
+ style: { width: `${v}px` },
9869
9728
  children: [
9870
9729
  /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
9871
9730
  /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(S, "icon", null) }),
9872
9731
  /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
9873
9732
  ] }) }),
9874
9733
  /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {
9875
- close: w
9734
+ close: j
9876
9735
  }) }) })
9877
9736
  ]
9878
9737
  }
9879
9738
  ) }),
9880
9739
  " ",
9881
- n !== null && get(S, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${C}px` }, children: [
9740
+ n !== null && get(S, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${v}px` }, children: [
9882
9741
  /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
9883
9742
  /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(S, "icon", null) }),
9884
9743
  /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
9885
9744
  ] }) }),
9886
9745
  /* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {
9887
- close: w
9746
+ close: j
9888
9747
  }) }) })
9889
9748
  ] }) }),
9890
9749
  n !== null && get(S, "view") === "overlay" && /* @__PURE__ */ jsx(
@@ -9912,7 +9771,7 @@ const RootLayout = () => {
9912
9771
  /* @__PURE__ */ jsx(Button, { onClick: () => _(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-5 w-5" }) })
9913
9772
  ] }),
9914
9773
  /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {
9915
- close: w
9774
+ close: j
9916
9775
  }) }) })
9917
9776
  ]
9918
9777
  }
@@ -9967,7 +9826,7 @@ const RootLayout = () => {
9967
9826
  position: n,
9968
9827
  updatePosition: r
9969
9828
  }) => {
9970
- const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
9829
+ const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), m = useMemo(() => {
9971
9830
  if (!l.trim()) return a;
9972
9831
  const x = l.toLowerCase();
9973
9832
  return Object.fromEntries(
@@ -9976,15 +9835,15 @@ const RootLayout = () => {
9976
9835
  return (b == null ? void 0 : b.toLowerCase().includes(x)) || ((S = y == null ? void 0 : y.description) == null ? void 0 : S.toLowerCase().includes(x));
9977
9836
  })
9978
9837
  );
9979
- }, [a, l]), m = (x) => {
9838
+ }, [a, l]), g = (x) => {
9980
9839
  d(!0), u({
9981
9840
  x: x.clientX - n.x,
9982
9841
  y: x.clientY - n.y
9983
9842
  });
9984
9843
  }, h = (x) => {
9985
9844
  if (!c) return;
9986
- const b = x.clientX - p.x, y = x.clientY - p.y, S = x.currentTarget, C = S.offsetWidth, B = S.offsetHeight, _ = window.innerWidth - C, w = window.innerHeight - B, v = Math.max(0, Math.min(b, _)), k = Math.max(0, Math.min(y, w));
9987
- r(v, k);
9845
+ const b = x.clientX - p.x, y = x.clientY - p.y, S = x.currentTarget, v = S.offsetWidth, B = S.offsetHeight, _ = window.innerWidth - v, j = window.innerHeight - B, C = Math.max(0, Math.min(b, _)), k = Math.max(0, Math.min(y, j));
9846
+ r(C, k);
9988
9847
  }, f = () => {
9989
9848
  d(!1);
9990
9849
  };
@@ -9996,7 +9855,7 @@ const RootLayout = () => {
9996
9855
  }, [c]), !n || n.x < 0 || n.y < 0 ? null : /* @__PURE__ */ jsxs(
9997
9856
  "div",
9998
9857
  {
9999
- onMouseDown: m,
9858
+ onMouseDown: g,
10000
9859
  onMouseMove: h,
10001
9860
  onMouseUp: f,
10002
9861
  className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
@@ -10046,7 +9905,7 @@ const RootLayout = () => {
10046
9905
  )
10047
9906
  ] })
10048
9907
  ] }),
10049
- /* @__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(([x, b]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: x, options: b }, x)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
9908
+ /* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(m).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(m).map(([x, b]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: x, options: b }, x)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
10050
9909
  'No features found matching "',
10051
9910
  l,
10052
9911
  '"'
@@ -10179,38 +10038,38 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10179
10038
  let i = a.get(n);
10180
10039
  return i || (i = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, a.set(n, i), l == null || l(o, n)), i;
10181
10040
  }, flushCallbacks = (o) => {
10182
- const n = getBuildingBlocks(o), r = n[1], a = n[3], l = n[4], i = n[5], c = n[6], d = n[13], p = [], u = (g) => {
10041
+ const n = getBuildingBlocks(o), r = n[1], a = n[3], l = n[4], i = n[5], c = n[6], d = n[13], p = [], u = (m) => {
10183
10042
  try {
10184
- g();
10185
- } catch (m) {
10186
- p.push(m);
10043
+ m();
10044
+ } catch (g) {
10045
+ p.push(g);
10187
10046
  }
10188
10047
  };
10189
10048
  do {
10190
10049
  c.f && u(c.f);
10191
- const g = /* @__PURE__ */ new Set(), m = g.add.bind(g);
10050
+ const m = /* @__PURE__ */ new Set(), g = m.add.bind(m);
10192
10051
  a.forEach((h) => {
10193
10052
  var f;
10194
- return (f = r.get(h)) == null ? void 0 : f.l.forEach(m);
10195
- }), a.clear(), i.forEach(m), i.clear(), l.forEach(m), l.clear(), g.forEach(u), a.size && d(o);
10053
+ return (f = r.get(h)) == null ? void 0 : f.l.forEach(g);
10054
+ }), a.clear(), i.forEach(g), i.clear(), l.forEach(g), l.clear(), m.forEach(u), a.size && d(o);
10196
10055
  } while (a.size || i.size || l.size);
10197
10056
  if (p.length)
10198
10057
  throw new AggregateError(p);
10199
10058
  }, recomputeInvalidatedAtoms = (o) => {
10200
- const n = getBuildingBlocks(o), r = n[1], a = n[2], l = n[3], i = n[11], c = n[14], d = n[17], p = [], u = /* @__PURE__ */ new WeakSet(), g = /* @__PURE__ */ new WeakSet(), m = Array.from(l);
10201
- for (; m.length; ) {
10202
- const h = m[m.length - 1], f = i(o, h);
10203
- if (g.has(h)) {
10204
- m.pop();
10059
+ const n = getBuildingBlocks(o), r = n[1], a = n[2], l = n[3], i = n[11], c = n[14], d = n[17], p = [], u = /* @__PURE__ */ new WeakSet(), m = /* @__PURE__ */ new WeakSet(), g = Array.from(l);
10060
+ for (; g.length; ) {
10061
+ const h = g[g.length - 1], f = i(o, h);
10062
+ if (m.has(h)) {
10063
+ g.pop();
10205
10064
  continue;
10206
10065
  }
10207
10066
  if (u.has(h)) {
10208
- a.get(h) === f.n && p.push([h, f]), g.add(h), m.pop();
10067
+ a.get(h) === f.n && p.push([h, f]), m.add(h), g.pop();
10209
10068
  continue;
10210
10069
  }
10211
10070
  u.add(h);
10212
10071
  for (const x of getMountedOrPendingDependents(h, f, r))
10213
- u.has(x) || m.push(x);
10072
+ u.has(x) || g.push(x);
10214
10073
  }
10215
10074
  for (let h = p.length - 1; h >= 0; --h) {
10216
10075
  const [f, x] = p[h];
@@ -10224,7 +10083,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10224
10083
  }
10225
10084
  }, readAtomState = (o, n) => {
10226
10085
  var r;
10227
- const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], d = a[6], p = a[7], u = a[11], g = a[12], m = a[13], h = a[14], f = a[16], x = a[17], b = u(o, n);
10086
+ const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], d = a[6], p = a[7], u = a[11], m = a[12], g = a[13], h = a[14], f = a[16], x = a[17], b = u(o, n);
10228
10087
  if (isAtomStateInitialized(b) && (l.has(n) && i.get(n) !== b.n || Array.from(b.d).every(
10229
10088
  ([k, I]) => (
10230
10089
  // Recursively, read the atom state of the dependency, and
@@ -10236,18 +10095,18 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10236
10095
  b.d.clear();
10237
10096
  let y = !0;
10238
10097
  function S() {
10239
- l.has(n) && (x(o, n), m(o), g(o));
10098
+ l.has(n) && (x(o, n), g(o), m(o));
10240
10099
  }
10241
- function C(k) {
10100
+ function v(k) {
10242
10101
  var I;
10243
10102
  if (isSelfAtom(n, k)) {
10244
- const j = u(o, k);
10245
- if (!isAtomStateInitialized(j))
10103
+ const w = u(o, k);
10104
+ if (!isAtomStateInitialized(w))
10246
10105
  if (hasInitialValue(k))
10247
10106
  setAtomStateValueOrPromise(o, k, k.init);
10248
10107
  else
10249
10108
  throw new Error("no atom init");
10250
- return returnAtomValue(j);
10109
+ return returnAtomValue(w);
10251
10110
  }
10252
10111
  const A = h(o, k);
10253
10112
  try {
@@ -10257,7 +10116,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10257
10116
  }
10258
10117
  }
10259
10118
  let B, _;
10260
- const w = {
10119
+ const j = {
10261
10120
  get signal() {
10262
10121
  return B || (B = new AbortController()), B.signal;
10263
10122
  },
@@ -10267,40 +10126,40 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10267
10126
  try {
10268
10127
  return f(o, n, ...k);
10269
10128
  } finally {
10270
- m(o), g(o);
10129
+ g(o), m(o);
10271
10130
  }
10272
10131
  }), _;
10273
10132
  }
10274
- }, v = b.n;
10133
+ }, C = b.n;
10275
10134
  try {
10276
- const k = p(o, n, C, w);
10135
+ const k = p(o, n, v, j);
10277
10136
  return setAtomStateValueOrPromise(o, n, k), isPromiseLike$1(k) && (registerAbortHandler(k, () => B == null ? void 0 : B.abort()), k.then(S, S)), b;
10278
10137
  } catch (k) {
10279
10138
  return delete b.v, b.e = k, ++b.n, b;
10280
10139
  } finally {
10281
- y = !1, v !== b.n && i.get(n) === v && (i.set(n, b.n), c.add(n), (r = d.c) == null || r.call(d, n));
10140
+ y = !1, C !== b.n && i.get(n) === C && (i.set(n, b.n), c.add(n), (r = d.c) == null || r.call(d, n));
10282
10141
  }
10283
10142
  }, invalidateDependents = (o, n) => {
10284
10143
  const r = getBuildingBlocks(o), a = r[1], l = r[2], i = r[11], c = [n];
10285
10144
  for (; c.length; ) {
10286
10145
  const d = c.pop(), p = i(o, d);
10287
10146
  for (const u of getMountedOrPendingDependents(d, p, a)) {
10288
- const g = i(o, u);
10289
- l.set(u, g.n), c.push(u);
10147
+ const m = i(o, u);
10148
+ l.set(u, m.n), c.push(u);
10290
10149
  }
10291
10150
  }
10292
10151
  }, writeAtomState = (o, n, ...r) => {
10293
- const a = getBuildingBlocks(o), l = a[3], i = a[6], c = a[8], d = a[11], p = a[12], u = a[13], g = a[14], m = a[15], h = a[17];
10152
+ const a = getBuildingBlocks(o), l = a[3], i = a[6], c = a[8], d = a[11], p = a[12], u = a[13], m = a[14], g = a[15], h = a[17];
10294
10153
  let f = !0;
10295
- const x = (y) => returnAtomValue(g(o, y)), b = (y, ...S) => {
10296
- var C;
10154
+ const x = (y) => returnAtomValue(m(o, y)), b = (y, ...S) => {
10155
+ var v;
10297
10156
  const B = d(o, y);
10298
10157
  try {
10299
10158
  if (isSelfAtom(n, y)) {
10300
10159
  if (!hasInitialValue(y))
10301
10160
  throw new Error("atom not writable");
10302
- const _ = B.n, w = S[0];
10303
- setAtomStateValueOrPromise(o, y, w), h(o, y), _ !== B.n && (l.add(y), (C = i.c) == null || C.call(i, y), m(o, y));
10161
+ const _ = B.n, j = S[0];
10162
+ setAtomStateValueOrPromise(o, y, j), h(o, y), _ !== B.n && (l.add(y), (v = i.c) == null || v.call(i, y), g(o, y));
10304
10163
  return;
10305
10164
  } else
10306
10165
  return writeAtomState(o, y, ...S);
@@ -10315,26 +10174,26 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10315
10174
  }
10316
10175
  }, mountDependencies = (o, n) => {
10317
10176
  var r;
10318
- const a = getBuildingBlocks(o), l = a[1], i = a[3], c = a[6], d = a[11], p = a[15], u = a[18], g = a[19], m = d(o, n), h = l.get(n);
10319
- if (h && !isPendingPromise(m.v)) {
10320
- for (const [f, x] of m.d)
10177
+ const a = getBuildingBlocks(o), l = a[1], i = a[3], c = a[6], d = a[11], p = a[15], u = a[18], m = a[19], g = d(o, n), h = l.get(n);
10178
+ if (h && !isPendingPromise(g.v)) {
10179
+ for (const [f, x] of g.d)
10321
10180
  if (!h.d.has(f)) {
10322
10181
  const b = d(o, f);
10323
10182
  u(o, f).t.add(n), h.d.add(f), x !== b.n && (i.add(f), (r = c.c) == null || r.call(c, f), p(o, f));
10324
10183
  }
10325
10184
  for (const f of h.d || [])
10326
- if (!m.d.has(f)) {
10185
+ if (!g.d.has(f)) {
10327
10186
  h.d.delete(f);
10328
- const x = g(o, f);
10187
+ const x = m(o, f);
10329
10188
  x == null || x.t.delete(n);
10330
10189
  }
10331
10190
  }
10332
10191
  }, mountAtom = (o, n) => {
10333
10192
  var r;
10334
- const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], d = a[10], p = a[11], u = a[12], g = a[13], m = a[14], h = a[16], f = p(o, n);
10193
+ const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], d = a[10], p = a[11], u = a[12], m = a[13], g = a[14], h = a[16], f = p(o, n);
10335
10194
  let x = l.get(n);
10336
10195
  if (!x) {
10337
- m(o, n);
10196
+ g(o, n);
10338
10197
  for (const b of f.d.keys())
10339
10198
  mountAtom(o, b).t.add(n);
10340
10199
  if (x = {
@@ -10344,19 +10203,19 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10344
10203
  }, l.set(n, x), (r = c.m) == null || r.call(c, n), isActuallyWritableAtom(n)) {
10345
10204
  const b = () => {
10346
10205
  let y = !0;
10347
- const S = (...C) => {
10206
+ const S = (...v) => {
10348
10207
  try {
10349
- return h(o, n, ...C);
10208
+ return h(o, n, ...v);
10350
10209
  } finally {
10351
- y || (g(o), u(o));
10210
+ y || (m(o), u(o));
10352
10211
  }
10353
10212
  };
10354
10213
  try {
10355
- const C = d(o, n, S);
10356
- C && (x.u = () => {
10214
+ const v = d(o, n, S);
10215
+ v && (x.u = () => {
10357
10216
  y = !0;
10358
10217
  try {
10359
- C();
10218
+ v();
10360
10219
  } finally {
10361
10220
  y = !1;
10362
10221
  }
@@ -10372,19 +10231,19 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10372
10231
  }, unmountAtom = (o, n) => {
10373
10232
  var r;
10374
10233
  const a = getBuildingBlocks(o), l = a[1], i = a[5], c = a[6], d = a[11], p = a[19], u = d(o, n);
10375
- let g = l.get(n);
10376
- if (g && !g.l.size && !Array.from(g.t).some((m) => {
10234
+ let m = l.get(n);
10235
+ if (m && !m.l.size && !Array.from(m.t).some((g) => {
10377
10236
  var h;
10378
- return (h = l.get(m)) == null ? void 0 : h.d.has(n);
10237
+ return (h = l.get(g)) == null ? void 0 : h.d.has(n);
10379
10238
  })) {
10380
- g.u && i.add(g.u), g = void 0, l.delete(n), (r = c.u) == null || r.call(c, n);
10381
- for (const m of u.d.keys()) {
10382
- const h = p(o, m);
10239
+ m.u && i.add(m.u), m = void 0, l.delete(n), (r = c.u) == null || r.call(c, n);
10240
+ for (const g of u.d.keys()) {
10241
+ const h = p(o, g);
10383
10242
  h == null || h.t.delete(n);
10384
10243
  }
10385
10244
  return;
10386
10245
  }
10387
- return g;
10246
+ return m;
10388
10247
  }, setAtomStateValueOrPromise = (o, n, r) => {
10389
10248
  const a = getBuildingBlocks(o)[11], l = a(o, n), i = "v" in l, c = l.v;
10390
10249
  if (isPromiseLike$1(r))
@@ -10499,10 +10358,10 @@ const isPromiseLike = (o) => typeof (o == null ? void 0 : o.then) == "function",
10499
10358
  let r = continuablePromiseMap.get(o);
10500
10359
  return r || (r = new Promise((a, l) => {
10501
10360
  let i = o;
10502
- const c = (u) => (g) => {
10503
- i === u && a(g);
10504
- }, d = (u) => (g) => {
10505
- i === u && l(g);
10361
+ const c = (u) => (m) => {
10362
+ i === u && a(m);
10363
+ }, d = (u) => (m) => {
10364
+ i === u && l(m);
10506
10365
  }, p = () => {
10507
10366
  try {
10508
10367
  const u = n();
@@ -10516,21 +10375,21 @@ const isPromiseLike = (o) => typeof (o == null ? void 0 : o.then) == "function",
10516
10375
  };
10517
10376
  function useAtomValue(o, n) {
10518
10377
  const { delay: r, unstable_promiseStatus: a = !React__default.use } = {}, l = useStore(), [[i, c, d], p] = useReducer(
10519
- (g) => {
10520
- const m = l.get(o);
10521
- return Object.is(g[0], m) && g[1] === l && g[2] === o ? g : [m, l, o];
10378
+ (m) => {
10379
+ const g = l.get(o);
10380
+ return Object.is(m[0], g) && m[1] === l && m[2] === o ? m : [g, l, o];
10522
10381
  },
10523
10382
  void 0,
10524
10383
  () => [l.get(o), l, o]
10525
10384
  );
10526
10385
  let u = i;
10527
10386
  if ((c !== l || d !== o) && (p(), u = l.get(o)), useEffect(() => {
10528
- const g = l.sub(o, () => {
10387
+ const m = l.sub(o, () => {
10529
10388
  if (a)
10530
10389
  try {
10531
- const m = l.get(o);
10532
- isPromiseLike(m) && attachPromiseStatus(
10533
- createContinuablePromise(m, () => l.get(o))
10390
+ const g = l.get(o);
10391
+ isPromiseLike(g) && attachPromiseStatus(
10392
+ createContinuablePromise(g, () => l.get(o))
10534
10393
  );
10535
10394
  } catch {
10536
10395
  }
@@ -10540,10 +10399,10 @@ function useAtomValue(o, n) {
10540
10399
  }
10541
10400
  p();
10542
10401
  });
10543
- return p(), g;
10402
+ return p(), m;
10544
10403
  }, [l, o, r, a]), useDebugValue(u), isPromiseLike(u)) {
10545
- const g = createContinuablePromise(u, () => l.get(o));
10546
- return a && attachPromiseStatus(g), use(g);
10404
+ const m = createContinuablePromise(u, () => l.get(o));
10405
+ return a && attachPromiseStatus(m), use(m);
10547
10406
  }
10548
10407
  return u;
10549
10408
  }