@chaibuilder/sdk 3.0.4 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,16 +1,16 @@
1
1
  var V = Object.defineProperty;
2
2
  var U = (o, n, r) => n in o ? V(o, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[n] = r;
3
- var F = (o, n, r) => U(o, typeof n != "symbol" ? n + "" : n, r);
3
+ var $ = (o, n, r) => U(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, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, sortBy, round } from "lodash-es";
7
- import { SquareIcon, ChevronRightIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, ExclamationTriangleIcon, Cross1Icon, Pencil2Icon, ChevronLeftIcon, LoopIcon, IdCardIcon, LetterCaseCapitalizeIcon, ValueIcon, LinkBreak1Icon, EnterFullScreenIcon, 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, MagicWandIcon, MagnifyingGlassIcon, CaretRightIcon, GlobeIcon, CheckIcon, LinkBreak2Icon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, EyeNoneIcon, DoubleArrowDownIcon, DoubleArrowUpIcon, ResetIcon, UploadIcon, TextIcon, CornerTopRightIcon, MixerHorizontalIcon, SunIcon, MoonIcon, ChatBubbleIcon, FaceIcon, ShuffleIcon, ImageIcon, PaperPlaneIcon, EraserIcon, LightningBoltIcon, ZoomInIcon, StackIcon } from "@radix-ui/react-icons";
7
+ import { SquareIcon, ChevronRightIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, ExclamationTriangleIcon, Cross1Icon, Pencil2Icon, ChevronLeftIcon, LoopIcon, IdCardIcon, LetterCaseCapitalizeIcon, ValueIcon, LinkBreak1Icon, EnterFullScreenIcon, 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, MagicWandIcon, MagnifyingGlassIcon, CaretRightIcon, FrameIcon, CheckIcon, LinkBreak2Icon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, DoubleArrowDownIcon, DoubleArrowUpIcon, ResetIcon, UploadIcon, TextIcon, CornerTopRightIcon, MixerHorizontalIcon, SunIcon, MoonIcon, ChatBubbleIcon, FaceIcon, ShuffleIcon, ImageIcon, PaperPlaneIcon, 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$2 } from "./common-functions-BGzDsf1z.js";
13
- import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, b8 as cn$1, aW as Skeleton, d as Alert, e as AlertDescription, at as Input$1, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, 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, a6 as DialogHeader, 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, 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, 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 "./toggle-C6VUu_7m.js";
13
+ import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, b8 as cn$1, aW as Skeleton, d as Alert, e as AlertDescription, at as Input$1, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, 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, a6 as DialogHeader, B as Badge, b6 as TooltipProvider, aY as Switch, 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, aX as Slider, aB as Select$1, aJ as SelectTrigger, aK as SelectValue, aC as SelectContent, aE as SelectItem, aL as Separator, 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 "./toggle-Cud7csHn.js";
14
14
  import clsx$1, { clsx } from "clsx";
15
15
  import { twMerge } from "tailwind-merge";
16
16
  import TreeModel from "tree-model";
@@ -20,7 +20,7 @@ import { isObject } from "@rjsf/utils";
20
20
  import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
21
21
  import { toast, Toaster } from "sonner";
22
22
  import { useTranslation, initReactI18next } from "react-i18next";
23
- import { useTranslation as Fe } from "react-i18next";
23
+ import { useTranslation as $e } from "react-i18next";
24
24
  import Fuse from "fuse.js";
25
25
  import UndoManager from "undo-manager";
26
26
  import Link from "@tiptap/extension-link";
@@ -280,7 +280,7 @@ import.meta.vitest && describe("canDropBlock Function", () => {
280
280
  });
281
281
  class PubSub {
282
282
  constructor() {
283
- F(this, "subscribers", /* @__PURE__ */ new Map());
283
+ $(this, "subscribers", /* @__PURE__ */ new Map());
284
284
  }
285
285
  subscribe(n, r) {
286
286
  return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
@@ -839,12 +839,12 @@ const undoRedoStateAtom = atom({
839
839
  return {
840
840
  moveBlocks: (x, y, b) => {
841
841
  const C = map(x, (j) => {
842
- const w = n.find((E) => E._id === j)._parent || null, A = n.filter((E) => w ? E._parent === w : !E._parent).map((E) => E._id).indexOf(j);
843
- return { _id: j, oldParent: w, oldPosition: A };
842
+ const A = n.find((E) => E._id === j)._parent || null, w = n.filter((E) => A ? E._parent === A : !E._parent).map((E) => E._id).indexOf(j);
843
+ return { _id: j, oldParent: A, oldPosition: w };
844
844
  }), B = C.find(({ _id: j }) => j === x[0]);
845
845
  B && B.oldParent === y && B.oldPosition === b || (i(x, y, b), o({
846
- undo: () => each(C, ({ _id: j, oldParent: _, oldPosition: w }) => {
847
- i([j], _, w);
846
+ undo: () => each(C, ({ _id: j, oldParent: _, oldPosition: A }) => {
847
+ i([j], _, A);
848
848
  }),
849
849
  redo: () => i(x, y, b)
850
850
  }));
@@ -870,8 +870,8 @@ const undoRedoStateAtom = atom({
870
870
  else {
871
871
  const B = keys(y);
872
872
  C = map(x, (j) => {
873
- const _ = n.find((k) => k._id === j), w = { _id: j };
874
- return each(B, (k) => w[k] = _[k]), w;
873
+ const _ = n.find((k) => k._id === j), A = { _id: j };
874
+ return each(B, (k) => A[k] = _[k]), A;
875
875
  });
876
876
  }
877
877
  c(map(x, (B) => ({ _id: B, ...y }))), o({
@@ -2381,16 +2381,16 @@ const getBlockWithChildren = (o, n) => {
2381
2381
  try {
2382
2382
  const b = p === u ? "" : p;
2383
2383
  console.log("prompt", x);
2384
- const C = x.toLowerCase().includes("translate the content"), B = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p, C) : [m(f, d)], j = await l(h, addLangToPrompt(x, g, h), B, b), { blocks: _, error: w } = j;
2385
- if (w) {
2386
- a(w);
2384
+ const C = x.toLowerCase().includes("translate the content"), B = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p, C) : [m(f, d)], j = await l(h, addLangToPrompt(x, g, h), B, b), { blocks: _, error: A } = j;
2385
+ if (A) {
2386
+ a(A);
2387
2387
  return;
2388
2388
  }
2389
2389
  if (h === "styles") {
2390
- const k = _.map((A) => {
2391
- for (const E in A)
2392
- E !== "_id" && (A[E] = `${STYLES_KEY},${A[E]}`);
2393
- return A;
2390
+ const k = _.map((w) => {
2391
+ for (const E in w)
2392
+ E !== "_id" && (w[E] = `${STYLES_KEY},${w[E]}`);
2393
+ return w;
2394
2394
  });
2395
2395
  c(k);
2396
2396
  } else
@@ -2548,14 +2548,6 @@ const getBlockWithChildren = (o, n) => {
2548
2548
  },
2549
2549
  [o, n]
2550
2550
  );
2551
- }, hiddenBlockIdsAtom = atom([]), useHiddenBlockIds = () => {
2552
- const [o, n] = useAtom$1(hiddenBlockIdsAtom), r = useCallback(
2553
- (a) => {
2554
- n((l) => includes(l, a) ? without(l, a) : [...l, a]);
2555
- },
2556
- [n]
2557
- );
2558
- return [o, n, r];
2559
2551
  }, highlightBlockIdAtom = atom(""), useHighlightBlockId = () => useAtom$1(highlightBlockIdAtom), libraryBlocksAtom = atom(
2560
2552
  {}
2561
2553
  ), useLibraryBlocks = (o) => {
@@ -3131,17 +3123,17 @@ class Content extends Component {
3131
3123
  class Frame extends Component {
3132
3124
  constructor(r, a) {
3133
3125
  super(r, a);
3134
- F(this, "setRef", (r) => {
3126
+ $(this, "setRef", (r) => {
3135
3127
  this.nodeRef.current = r;
3136
3128
  const { forwardedRef: a } = this.props;
3137
3129
  typeof a == "function" ? a(r) : a && (a.current = r);
3138
3130
  });
3139
- F(this, "handleLoad", () => {
3131
+ $(this, "handleLoad", () => {
3140
3132
  clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
3141
3133
  });
3142
3134
  // In certain situations on a cold cache DOMContentLoaded never gets called
3143
3135
  // fallback to an interval to check if that's the case
3144
- F(this, "loadCheck", () => setInterval(() => {
3136
+ $(this, "loadCheck", () => setInterval(() => {
3145
3137
  this.handleLoad();
3146
3138
  }, 500));
3147
3139
  this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
@@ -3178,7 +3170,7 @@ class Frame extends Component {
3178
3170
  return delete r.head, delete r.initialContent, delete r.mountTarget, delete r.contentDidMount, delete r.contentDidUpdate, delete r.forwardedRef, /* @__PURE__ */ jsx("iframe", { ...r, ref: this.setRef, onLoad: this.handleLoad, children: this.state.iframeLoaded && this.renderFrameContents() });
3179
3171
  }
3180
3172
  }
3181
- F(Frame, "defaultProps", {
3173
+ $(Frame, "defaultProps", {
3182
3174
  style: {},
3183
3175
  head: null,
3184
3176
  children: void 0,
@@ -3610,26 +3602,26 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3610
3602
  ({ block: o, children: n }) => {
3611
3603
  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(), y = useRef(null), b = l, { blockContent: C, blockType: B } = useMemo(() => {
3612
3604
  var I;
3613
- const A = o._type;
3605
+ const w = o._type;
3614
3606
  let E = o[r];
3615
3607
  const S = getRegisteredChaiBlock(o._type);
3616
- return f && ((I = S == null ? void 0 : S.i18nProps) == null ? void 0 : I.includes(r)) && has(o, `${r}-${f}`) && (E = get(o, `${r}-${f}`)), { blockContent: E, blockType: A };
3608
+ return f && ((I = S == null ? void 0 : S.i18nProps) == null ? void 0 : I.includes(r)) && has(o, `${r}-${f}`) && (E = get(o, `${r}-${f}`)), { blockContent: E, blockType: w };
3617
3609
  }, [o, f]), j = useCallback(
3618
- (A) => {
3610
+ (w) => {
3619
3611
  var S;
3620
- const E = A || ((S = g.current) == null ? void 0 : S.innerText);
3612
+ const E = w || ((S = g.current) == null ? void 0 : S.innerText);
3621
3613
  h([b], { [r]: E }), u(null), c(null), d(-1), x(b ? [b] : []);
3622
3614
  },
3623
3615
  [b, h, c, x, f]
3624
3616
  ), _ = useDebouncedCallback(
3625
- (A) => {
3626
- h([b], { [r]: A });
3617
+ (w) => {
3618
+ h([b], { [r]: w });
3627
3619
  },
3628
3620
  [b, o, h, f],
3629
3621
  1e3
3630
- ), w = useCallback(
3631
- (A) => {
3632
- A.preventDefault(), b && (y.current = b), j(), setTimeout(() => {
3622
+ ), A = useCallback(
3623
+ (w) => {
3624
+ w.preventDefault(), b && (y.current = b), j(), setTimeout(() => {
3633
3625
  const E = y.current;
3634
3626
  y.current = null, x([E]);
3635
3627
  }, 100);
@@ -3639,7 +3631,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3639
3631
  useEffect(() => {
3640
3632
  var v;
3641
3633
  if (!b) return;
3642
- const A = `[data-block-id="${b}"]`, E = i >= 0 ? `[data-block-index="${i}"]` : "", S = a.querySelector(`${A}${E}`);
3634
+ const w = `[data-block-id="${b}"]`, E = i >= 0 ? `[data-block-index="${i}"]` : "", S = a.querySelector(`${w}${E}`);
3643
3635
  S && ((v = S == null ? void 0 : S.classList) == null || v.add("sr-only"), u(S));
3644
3636
  }, [b, B, a, i]);
3645
3637
  const k = useMemo(() => p ? (m(), B === "RichText" ? /* @__PURE__ */ jsx(
@@ -3649,7 +3641,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3649
3641
  editingElement: p,
3650
3642
  onChange: _,
3651
3643
  onClose: j,
3652
- onEscape: w
3644
+ onEscape: A
3653
3645
  }
3654
3646
  ) : /* @__PURE__ */ jsx(
3655
3647
  MemoizedEditor,
@@ -3659,7 +3651,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3659
3651
  editingElement: p,
3660
3652
  onClose: j,
3661
3653
  onChange: _,
3662
- onEscape: w
3654
+ onEscape: A
3663
3655
  }
3664
3656
  )) : null, [p, b, B, C, j, f]);
3665
3657
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -3696,23 +3688,23 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3696
3688
  blockAtom: n,
3697
3689
  children: r
3698
3690
  }) => {
3699
- const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useHiddenBlockIds(), [h] = useAtom$1(dataBindingActiveAtom), f = get(c, "component", null), { index: x, key: y } = useContext(RepeaterContext), b = useMemo(
3700
- () => h ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
3701
- index: x,
3702
- key: y
3691
+ 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), y = useMemo(
3692
+ () => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
3693
+ index: f,
3694
+ key: x
3703
3695
  }) : applyLanguage(i, d, c),
3704
- [i, d, c, g, h, x, y]
3705
- ), C = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), B = useMemo(
3696
+ [i, d, c, g, m, f, x]
3697
+ ), b = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), C = useMemo(
3706
3698
  () => u(i._id, getBlockRuntimeProps(i._type)),
3707
3699
  [i._id, i._type, u, getBlockRuntimeProps]
3708
- ), j = useMemo(
3700
+ ), B = useMemo(
3709
3701
  () => ({
3710
- blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": x },
3702
+ blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": f },
3711
3703
  inBuilder: !0,
3712
3704
  lang: d || p,
3705
+ ...y,
3713
3706
  ...b,
3714
3707
  ...C,
3715
- ...B,
3716
3708
  ...o
3717
3709
  }),
3718
3710
  [
@@ -3720,29 +3712,29 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3720
3712
  i._type,
3721
3713
  d,
3722
3714
  p,
3715
+ y,
3723
3716
  b,
3724
3717
  C,
3725
- B,
3726
3718
  o
3727
3719
  ]
3728
- ), _ = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]);
3729
- if (isNull(f) || m.includes(i._id)) return null;
3730
- let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(f, {
3731
- ...j,
3720
+ ), j = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]), _ = useMemo(() => get(i, "_show", !0), [i]);
3721
+ if (isNull(h) || !_) return null;
3722
+ let A = /* @__PURE__ */ jsx(Suspense, { children: createElement(h, {
3723
+ ...B,
3732
3724
  children: r({
3733
3725
  _id: i._id,
3734
3726
  _type: i._type,
3735
- ...isArray(b.repeaterItems) ? {
3736
- repeaterItems: applyLimit(b.repeaterItems, i),
3737
- $repeaterItemsKey: b.$repeaterItemsKey
3727
+ ...isArray(y.repeaterItems) ? {
3728
+ repeaterItems: applyLimit(y.repeaterItems, i),
3729
+ $repeaterItemsKey: y.$repeaterItemsKey
3738
3730
  } : {},
3739
3731
  ...i.partialBlockId ? { partialBlockId: i.partialBlockId } : "",
3740
3732
  ...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
3741
3733
  })
3742
3734
  }) });
3743
- const k = a === i._id && (l === x || x < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: w }) : w;
3744
- return _ ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: k }) : k;
3745
- }, PartialWrapper = ({ children: o, partialBlockId: n }) => {
3735
+ const k = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: A }) : A;
3736
+ return j ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: k }) : k;
3737
+ }, PartialWrapper$1 = ({ children: o, partialBlockId: n }) => {
3746
3738
  const r = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
3747
3739
  (d) => {
3748
3740
  if (d.stopPropagation(), a !== "SAVED") {
@@ -3766,7 +3758,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3766
3758
  ] });
3767
3759
  }, PartialBlocksRenderer = ({ partialBlockId: o }) => {
3768
3760
  const { getPartailBlocks: n } = usePartialBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom(r)), [r]);
3769
- return isEmpty(r) ? null : /* @__PURE__ */ jsx(PartialWrapper, { partialBlockId: o, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r }) });
3761
+ return isEmpty(r) ? null : /* @__PURE__ */ jsx(PartialWrapper$1, { partialBlockId: o, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r }) });
3770
3762
  }, BlocksRenderer = ({
3771
3763
  blocks: o,
3772
3764
  parent: n = null,
@@ -3906,7 +3898,7 @@ const CanvasEventsWatcher = () => {
3906
3898
  }, FallbackError = () => /* @__PURE__ */ jsx("div", { className: "h-full w-full rounded-md bg-red-200 p-4 text-red-500", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center", children: [
3907
3899
  /* @__PURE__ */ jsx("p", { className: "font-semibold", children: "Oops! Something went wrong." }),
3908
3900
  /* @__PURE__ */ jsx("p", { children: "Please try again." })
3909
- ] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-tDa4T69w.js")), CanvasArea = () => {
3901
+ ] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-CbG2Orke.js")), CanvasArea = () => {
3910
3902
  const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
3911
3903
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40", children: [
3912
3904
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -4217,8 +4209,8 @@ const DataBindingSelector = ({
4217
4209
  }
4218
4210
  const h = (b) => /[.,!?;:]/.test(b), f = (b, C, B) => {
4219
4211
  let j = "", _ = "";
4220
- const w = C > 0 ? b[C - 1] : "", k = C < b.length ? b[C] : "";
4221
- return C > 0 && (w === "." || !h(w) && w !== " ") && (j = " "), C < b.length && !h(k) && k !== " " && (_ = " "), {
4212
+ const A = C > 0 ? b[C - 1] : "", k = C < b.length ? b[C] : "";
4213
+ return C > 0 && (A === "." || !h(A) && A !== " ") && (j = " "), C < b.length && !h(k) && k !== " " && (_ = " "), {
4222
4214
  text: j + B + _,
4223
4215
  prefixLength: j.length,
4224
4216
  suffixLength: _.length
@@ -4235,9 +4227,9 @@ const DataBindingSelector = ({
4235
4227
  if (B !== j)
4236
4228
  b.chain().deleteSelection().insertContent(C).run();
4237
4229
  else {
4238
- const { state: w } = b, k = w.selection.from, A = w.doc.textBetween(Math.max(0, k - 1), k), E = w.doc.textBetween(k, Math.min(k + 1, w.doc.content.size));
4230
+ const { state: A } = b, k = A.selection.from, w = A.doc.textBetween(Math.max(0, k - 1), k), E = A.doc.textBetween(k, Math.min(k + 1, A.doc.content.size));
4239
4231
  let S = "";
4240
- k > 0 && A !== " " && !h(A) && (S = " ");
4232
+ k > 0 && w !== " " && !h(w) && (S = " ");
4241
4233
  let v = "";
4242
4234
  E && E !== " " && !h(E) && (v = " "), b.chain().insertContent(S + C + v).run();
4243
4235
  }
@@ -4251,8 +4243,8 @@ const DataBindingSelector = ({
4251
4243
  n(v, {}, r);
4252
4244
  return;
4253
4245
  }
4254
- const w = `{{${g}}}`, { text: k } = f(B, C, w), A = B.slice(0, C) + k + B.slice(C);
4255
- n(A, {}, r);
4246
+ const A = `{{${g}}}`, { text: k } = f(B, C, A), w = B.slice(0, C) + k + B.slice(C);
4247
+ n(w, {}, r);
4256
4248
  }
4257
4249
  },
4258
4250
  [r, n, a, c == null ? void 0 : c._id, d]
@@ -4298,7 +4290,7 @@ const DataBindingSelector = ({
4298
4290
  ), _ = (S) => {
4299
4291
  const v = ["pageType", u, S.id];
4300
4292
  v[1] && (r(v.join(":")), h(S.name), p(!1), x([]), b(-1));
4301
- }, w = (S) => {
4293
+ }, A = (S) => {
4302
4294
  switch (S.key) {
4303
4295
  case "ArrowDown":
4304
4296
  S.preventDefault(), b((v) => v < f.length - 1 ? v + 1 : v);
@@ -4323,7 +4315,7 @@ const DataBindingSelector = ({
4323
4315
  }, [y]);
4324
4316
  const k = () => {
4325
4317
  h(""), x([]), b(-1), p(!1), r("");
4326
- }, A = (S) => {
4318
+ }, w = (S) => {
4327
4319
  h(S), p(!isEmpty(S)), c(!0), j(S);
4328
4320
  };
4329
4321
  return /* @__PURE__ */ jsxs("div", { children: [
@@ -4334,8 +4326,8 @@ const DataBindingSelector = ({
4334
4326
  {
4335
4327
  type: "text",
4336
4328
  value: m,
4337
- onChange: (S) => A(S.target.value),
4338
- onKeyDown: w,
4329
+ onChange: (S) => w(S.target.value),
4330
+ onKeyDown: A,
4339
4331
  placeholder: a(`Search ${B ?? ""}`),
4340
4332
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4341
4333
  }
@@ -4672,8 +4664,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4672
4664
  const { state: b } = u, C = b.selection.from, B = b.doc.textBetween(Math.max(0, C - 1), C), j = b.doc.textBetween(C, Math.min(C + 1, b.doc.content.size));
4673
4665
  let _ = "";
4674
4666
  C > 0 && B !== " " && !/[.,!?;:]/.test(B) && (_ = " ");
4675
- let w = "";
4676
- j && j !== " " && !/[.,!?;:]/.test(j) && (w = " "), u.chain().insertContent(_ + h + w).run();
4667
+ let A = "";
4668
+ j && j !== " " && !/[.,!?;:]/.test(j) && (A = " "), u.chain().insertContent(_ + h + A).run();
4677
4669
  }
4678
4670
  };
4679
4671
  return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (m) => !m && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
@@ -4976,11 +4968,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4976
4968
  ), y = useMemo(() => get(LANGUAGES, x, x), [x]), b = usePageExternalData(), C = useSelectedBlock(), B = useRegisteredChaiBlocks(), j = useMemo(
4977
4969
  () => get(B, [C == null ? void 0 : C._type, "i18nProps"], []),
4978
4970
  [B, C == null ? void 0 : C._type]
4979
- ), [_, w] = useState(null);
4971
+ ), [_, A] = useState(null);
4980
4972
  if (c)
4981
4973
  return null;
4982
4974
  if (p.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
4983
- const A = j == null ? void 0 : j.includes(o.replace("root.", ""));
4975
+ const w = j == null ? void 0 : j.includes(o.replace("root.", ""));
4984
4976
  if (p.type === "array") {
4985
4977
  const E = _ === o;
4986
4978
  return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
@@ -4988,7 +4980,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4988
4980
  "label",
4989
4981
  {
4990
4982
  htmlFor: o,
4991
- onClick: () => w(E ? null : o),
4983
+ onClick: () => A(E ? null : o),
4992
4984
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
4993
4985
  children: [
4994
4986
  E ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }),
@@ -5023,7 +5015,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5023
5015
  /* @__PURE__ */ jsxs("label", { htmlFor: o, className: p.type === "object" ? "pb-2" : "", children: [
5024
5016
  r,
5025
5017
  " ",
5026
- A && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5018
+ w && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5027
5019
  " ",
5028
5020
  y
5029
5021
  ] }),
@@ -5138,50 +5130,101 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5138
5130
  },
5139
5131
  i
5140
5132
  );
5141
- }), formDataWithSelectedLang = (o, n, r) => {
5133
+ }), CommonSettings = ({ block: o, updateBlockProps: n, updateBlockPropsRealtime: r }) => {
5134
+ const [a, l] = useState(o._name), [i, c] = useState(o._show ?? !0);
5135
+ useEffect(() => {
5136
+ o && (l(o._name), c(o._show ?? !0));
5137
+ }, [o]);
5138
+ const d = useCallback(
5139
+ debounce((g) => {
5140
+ n([o._id], { _name: g });
5141
+ }, 500),
5142
+ [o._id, n]
5143
+ );
5144
+ return /* @__PURE__ */ jsx("div", { className: "", children: /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
5145
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 items-center", children: [
5146
+ /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-gray-500", children: "Name" }),
5147
+ /* @__PURE__ */ jsx(
5148
+ "input",
5149
+ {
5150
+ type: "text",
5151
+ className: "col-span-2 rounded-md border border-gray-300 px-2 py-1 text-xs",
5152
+ value: a,
5153
+ onChange: (g) => {
5154
+ const m = g.target.value;
5155
+ l(m), r([o._id], { _name: m }), d(m);
5156
+ }
5157
+ }
5158
+ )
5159
+ ] }),
5160
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 items-center", children: [
5161
+ /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-gray-500", children: "Show" }),
5162
+ /* @__PURE__ */ jsx(
5163
+ Switch,
5164
+ {
5165
+ className: "!col-span-2 !h-4 !w-7",
5166
+ thumbClassName: "!h-3 !w-3",
5167
+ checked: i,
5168
+ onCheckedChange: (g) => {
5169
+ c(g), n([o._id], { _show: g });
5170
+ }
5171
+ }
5172
+ )
5173
+ ] })
5174
+ ] }) });
5175
+ }, formDataWithSelectedLang = (o, n, r) => {
5142
5176
  const a = cloneDeep(o);
5143
5177
  return forEach(keys(o), (l) => {
5144
5178
  includes(get(r, "i18nProps", []), l) && !isEmpty(n) && (a[l] = get(o, `${l}-${n}`));
5145
5179
  }), a;
5146
5180
  };
5147
5181
  function BlockSettings() {
5148
- 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 }, k, A) => {
5149
- k && (c == null ? void 0 : c._id) === n._id && a([n._id], { [k]: get(w, k) }, A);
5182
+ 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: A }, k, w) => {
5183
+ k && (c == null ? void 0 : c._id) === n._id && a([n._id], { [k]: get(A, k) }, w);
5150
5184
  }, x = useCallback(
5151
- debounce(({ formData: w }, k, A) => {
5152
- f({ formData: w }, k, A), d(w);
5185
+ debounce(({ formData: A }, k, w) => {
5186
+ f({ formData: A }, k, w), d(A);
5153
5187
  }, 1500),
5154
5188
  [n == null ? void 0 : n._id, o]
5155
- ), y = ({ formData: w }, k) => {
5156
- k && (r([n._id], { [k]: get(w, k) }), x({ formData: w }, k, { [k]: get(c, k) }));
5157
- }, b = ({ formData: w }, k) => {
5158
- k && (r([g._id], { [k]: get(w, k) }), x({ formData: w }, k, { [k]: get(c, k) }));
5189
+ ), y = ({ formData: A }, k) => {
5190
+ k && (r([n._id], { [k]: get(A, k) }), x({ formData: A }, k, { [k]: get(c, k) }));
5191
+ }, b = ({ formData: A }, k) => {
5192
+ k && (r([g._id], { [k]: get(A, k) }), x({ formData: A }, k, { [k]: get(c, k) }));
5159
5193
  }, { schema: C, uiSchema: B } = useMemo(() => {
5160
- const w = n == null ? void 0 : n._type;
5161
- if (!w)
5194
+ const A = n == null ? void 0 : n._type;
5195
+ if (!A)
5162
5196
  return { schema: {}, uiSchema: {} };
5163
5197
  try {
5164
- const { schema: k, uiSchema: A } = getBlockFormSchemas(w);
5165
- if (w === "Repeater") {
5198
+ const { schema: k, uiSchema: w } = getBlockFormSchemas(A);
5199
+ if (A === "Repeater") {
5166
5200
  const E = get(n, "repeaterItems", "");
5167
- startsWith(E, `{{${COLLECTION_PREFIX}`) ? (set(A, "filter", { "ui:widget": "collectionSelect" }), set(A, "sort", { "ui:widget": "collectionSelect" })) : (set(A, "filter", { "ui:widget": "hidden" }), set(A, "sort", { "ui:widget": "hidden" }));
5201
+ startsWith(E, `{{${COLLECTION_PREFIX}`) ? (set(w, "filter", { "ui:widget": "collectionSelect" }), set(w, "sort", { "ui:widget": "collectionSelect" })) : (set(w, "filter", { "ui:widget": "hidden" }), set(w, "sort", { "ui:widget": "hidden" }));
5168
5202
  }
5169
- return { schema: k, uiSchema: A };
5203
+ return { schema: k, uiSchema: w };
5170
5204
  } catch {
5171
5205
  return { schema: {}, uiSchema: {} };
5172
5206
  }
5173
5207
  }, [n]), { wrapperSchema: j, wrapperUiSchema: _ } = useMemo(() => {
5174
5208
  if (!g || !(g != null && g._type))
5175
5209
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5176
- const w = g == null ? void 0 : g._type, { schema: k = {}, uiSchema: A = {} } = getBlockFormSchemas(w);
5177
- return { wrapperSchema: k, wrapperUiSchema: A };
5210
+ const A = g == null ? void 0 : g._type, { schema: k = {}, uiSchema: w = {} } = getBlockFormSchemas(A);
5211
+ return { wrapperSchema: k, wrapperUiSchema: w };
5178
5212
  }, [g]);
5179
5213
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5214
+ /* @__PURE__ */ jsx(
5215
+ CommonSettings,
5216
+ {
5217
+ block: n,
5218
+ updateBlockProps: a,
5219
+ updateBlockPropsRealtime: r
5220
+ }
5221
+ ),
5222
+ /* @__PURE__ */ jsx("br", {}),
5180
5223
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
5181
5224
  /* @__PURE__ */ jsxs(
5182
5225
  "div",
5183
5226
  {
5184
- onClick: () => u((w) => !w),
5227
+ onClick: () => u((A) => !A),
5185
5228
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5186
5229
  children: [
5187
5230
  p ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-4 w-4 text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 text-slate-400" }),
@@ -5434,7 +5477,7 @@ const BlockStylingProps = () => {
5434
5477
  }
5435
5478
  h(v), l(v === "class" || isEmpty(S) ? "" : S);
5436
5479
  }, [i, p, u]);
5437
- const w = useThrottledCallback((S) => c(S), [c], THROTTLE_TIME), k = useThrottledCallback((S) => c(S, !1), [c], THROTTLE_TIME), A = useCallback(
5480
+ const A = useThrottledCallback((S) => c(S), [c], THROTTLE_TIME), k = useThrottledCallback((S) => c(S, !1), [c], THROTTLE_TIME), w = useCallback(
5438
5481
  (S = !1) => {
5439
5482
  const v = getUserInputValues(`${a}`, u);
5440
5483
  if (get(v, "error", !1)) {
@@ -5443,15 +5486,15 @@ const BlockStylingProps = () => {
5443
5486
  }
5444
5487
  const I = get(v, "unit") !== "" ? get(v, "unit") : m;
5445
5488
  if (I === "auto" || I === "none") {
5446
- w(`${d}${I}`);
5489
+ A(`${d}${I}`);
5447
5490
  return;
5448
5491
  }
5449
5492
  if (get(v, "value") === "")
5450
5493
  return;
5451
5494
  const T = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${I === "-" ? "" : I}]`;
5452
- S ? k(T) : w(T);
5495
+ S ? k(T) : A(T);
5453
5496
  },
5454
- [w, k, a, m, d, u]
5497
+ [A, k, a, m, d, u]
5455
5498
  ), E = useCallback(
5456
5499
  (S) => {
5457
5500
  const v = getUserInputValues(`${a}`, u);
@@ -5460,15 +5503,15 @@ const BlockStylingProps = () => {
5460
5503
  return;
5461
5504
  }
5462
5505
  if (S === "auto" || S === "none") {
5463
- w(`${d}${S}`);
5506
+ A(`${d}${S}`);
5464
5507
  return;
5465
5508
  }
5466
5509
  if (get(v, "value") === "")
5467
5510
  return;
5468
5511
  const I = get(v, "unit") !== "" ? get(v, "unit") : S, T = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${I === "-" ? "" : I}]`;
5469
- w(T);
5512
+ A(T);
5470
5513
  },
5471
- [w, a, d, u]
5514
+ [A, a, d, u]
5472
5515
  );
5473
5516
  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: [
5474
5517
  /* @__PURE__ */ jsx(
@@ -5490,7 +5533,7 @@ const BlockStylingProps = () => {
5490
5533
  {
5491
5534
  readOnly: m === "class",
5492
5535
  onKeyPress: (S) => {
5493
- S.key === "Enter" && A();
5536
+ S.key === "Enter" && w();
5494
5537
  },
5495
5538
  onKeyDown: (S) => {
5496
5539
  if (S.keyCode !== 38 && S.keyCode !== 40)
@@ -5505,7 +5548,7 @@ const BlockStylingProps = () => {
5505
5548
  onKeyUp: (S) => {
5506
5549
  j && (S.preventDefault(), _(!1));
5507
5550
  },
5508
- onBlur: () => A(),
5551
+ onBlur: () => w(),
5509
5552
  onChange: (S) => {
5510
5553
  x(!1), l(S.target.value);
5511
5554
  },
@@ -5553,7 +5596,7 @@ const BlockStylingProps = () => {
5553
5596
  if (b(() => ""), B(!1), isEmpty(S))
5554
5597
  return;
5555
5598
  const v = `${S}`, L = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${m === "-" ? "" : m}]`;
5556
- w(L);
5599
+ A(L);
5557
5600
  },
5558
5601
  onDrag: (S) => {
5559
5602
  if (isEmpty(S))
@@ -6024,11 +6067,11 @@ const COLOR_PROP = {
6024
6067
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6025
6068
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
6026
6069
  }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(m, "fullCls", ""), [m]), b = useCallback(
6027
- (k, A = !0) => {
6070
+ (k, w = !0) => {
6028
6071
  const E = { dark: p, mq: g, mod: u, cls: k, property: l, fullCls: "" };
6029
6072
  (p || u !== "") && (E.mq = "xs");
6030
6073
  const S = generateFullClsName(E);
6031
- h(x, [S], A);
6074
+ h(x, [S], w);
6032
6075
  },
6033
6076
  [x, p, g, u, l, h]
6034
6077
  ), C = useCallback(() => {
@@ -6049,9 +6092,9 @@ const COLOR_PROP = {
6049
6092
  }[k]);
6050
6093
  },
6051
6094
  [j]
6052
- ), w = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6053
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: m && w, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6054
- /* @__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) }) }),
6095
+ ), A = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6096
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: m && A, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6097
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !A ? "text-foreground" : ""}`, children: n(a) }) }),
6055
6098
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6056
6099
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
6057
6100
  r === "arbitrary" ? /* @__PURE__ */ jsx(
@@ -6070,7 +6113,7 @@ const COLOR_PROP = {
6070
6113
  r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
6071
6114
  r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
6072
6115
  ] }),
6073
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: w ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => C(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6116
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: A ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => C(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6074
6117
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6075
6118
  "button",
6076
6119
  {
@@ -6474,12 +6517,12 @@ function ManualClasses() {
6474
6517
  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(""), y = (L = first(d)) == null ? void 0 : L.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), C = b.split(" ").filter((T) => !isEmpty(T)), B = () => {
6475
6518
  const T = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6476
6519
  u(m, T, !0), x("");
6477
- }, [j, _] = useState([]), w = ({ value: T }) => {
6520
+ }, [j, _] = useState([]), A = ({ value: T }) => {
6478
6521
  const P = T.trim().toLowerCase(), R = P.match(/.+:/g);
6479
6522
  let N = [];
6480
6523
  if (R && R.length > 0) {
6481
- const [D] = R, $ = P.replace(D, "");
6482
- N = i.search($).map((M) => ({
6524
+ const [D] = R, F = P.replace(D, "");
6525
+ N = i.search(F).map((M) => ({
6483
6526
  ...M,
6484
6527
  item: { ...M.item, name: D + M.item.name }
6485
6528
  }));
@@ -6488,7 +6531,7 @@ function ManualClasses() {
6488
6531
  return _(map(N, "item"));
6489
6532
  }, k = () => {
6490
6533
  _([]);
6491
- }, A = (T) => T.name, E = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), S = useMemo(
6534
+ }, w = (T) => T.name, E = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), S = useMemo(
6492
6535
  () => ({
6493
6536
  ref: o,
6494
6537
  autoComplete: "off",
@@ -6542,9 +6585,9 @@ function ManualClasses() {
6542
6585
  Autosuggest,
6543
6586
  {
6544
6587
  suggestions: j,
6545
- onSuggestionsFetchRequested: w,
6588
+ onSuggestionsFetchRequested: A,
6546
6589
  onSuggestionsClearRequested: k,
6547
- getSuggestionValue: A,
6590
+ getSuggestionValue: w,
6548
6591
  renderSuggestion: E,
6549
6592
  inputProps: S,
6550
6593
  containerProps: {
@@ -6950,15 +6993,15 @@ const registerChaiLibrary = (o, n) => {
6950
6993
  const j = await c({ library: n, block: o });
6951
6994
  let _ = r;
6952
6995
  if (y(first(j)) && (_ = null), !isEmpty(j)) {
6953
- const w = { blocks: j, uiLibrary: !0, parent: _ };
6954
- if (B.dataTransfer.setData("text/plain", JSON.stringify(w)), o.preview) {
6996
+ const A = { blocks: j, uiLibrary: !0, parent: _ };
6997
+ if (B.dataTransfer.setData("text/plain", JSON.stringify(A)), o.preview) {
6955
6998
  const k = new Image();
6956
6999
  k.src = o.preview, k.onload = () => {
6957
7000
  B.dataTransfer.setDragImage(k, 0, 0);
6958
7001
  };
6959
7002
  } else
6960
7003
  B.dataTransfer.setDragImage(new Image(), 0, 0);
6961
- x(w), setTimeout(() => {
7004
+ x(A), setTimeout(() => {
6962
7005
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6963
7006
  }, 200);
6964
7007
  }
@@ -7010,13 +7053,13 @@ const registerChaiLibrary = (o, n) => {
7010
7053
  return;
7011
7054
  }
7012
7055
  }, [y, b]);
7013
- const B = get(y, b, []), j = useRef(null), { t: _ } = useTranslation(), w = (v) => {
7056
+ const B = get(y, b, []), j = useRef(null), { t: _ } = useTranslation(), A = (v) => {
7014
7057
  j.current && (clearTimeout(j.current), j.current = null), j.current = setTimeout(() => {
7015
7058
  j.current && C(v);
7016
7059
  }, 400);
7017
7060
  }, k = () => {
7018
7061
  i != null && i.id && p(i.id);
7019
- }, A = () => {
7062
+ }, w = () => {
7020
7063
  g("");
7021
7064
  };
7022
7065
  if (d)
@@ -7040,7 +7083,7 @@ const registerChaiLibrary = (o, n) => {
7040
7083
  u && /* @__PURE__ */ jsx(
7041
7084
  "button",
7042
7085
  {
7043
- onClick: A,
7086
+ onClick: w,
7044
7087
  className: "absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",
7045
7088
  children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" })
7046
7089
  }
@@ -7061,7 +7104,7 @@ const registerChaiLibrary = (o, n) => {
7061
7104
  ] }) }) : map(y, (v, I) => /* @__PURE__ */ jsxs(
7062
7105
  "div",
7063
7106
  {
7064
- onMouseEnter: () => w(I),
7107
+ onMouseEnter: () => A(I),
7065
7108
  onMouseLeave: () => clearTimeout(j.current),
7066
7109
  role: "button",
7067
7110
  onClick: () => C(I),
@@ -7146,7 +7189,7 @@ const registerChaiLibrary = (o, n) => {
7146
7189
  // Set the type to PartialBlock
7147
7190
  label: formatReadableName(b.name || x),
7148
7191
  description: b.description || "",
7149
- icon: GlobeIcon,
7192
+ icon: FrameIcon,
7150
7193
  group: B,
7151
7194
  // Use formatted type as group
7152
7195
  category: "partial",
@@ -7231,15 +7274,15 @@ const registerChaiLibrary = (o, n) => {
7231
7274
  }
7232
7275
  ) : n,
7233
7276
  [n, d]
7234
- ), w = useMemo(
7277
+ ), A = useMemo(
7235
7278
  () => d ? o.filter(
7236
7279
  (v) => reject(filter(values(_), { group: v }), { hidden: !0 }).length > 0
7237
7280
  ) : o.filter((v) => reject(filter(values(n), { group: v }), { hidden: !0 }).length > 0),
7238
7281
  [n, _, o, d]
7239
7282
  ), k = useMemo(
7240
- () => sortBy(w, (v) => CORE_GROUPS.indexOf(v) === -1 ? 99 : CORE_GROUPS.indexOf(v)),
7241
- [w]
7242
- ), A = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), E = useMemo(() => h === "all" ? k : [h], [k, h]);
7283
+ () => sortBy(A, (v) => CORE_GROUPS.indexOf(v) === -1 ? 99 : CORE_GROUPS.indexOf(v)),
7284
+ [A]
7285
+ ), w = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), E = useMemo(() => h === "all" ? k : [h], [k, h]);
7243
7286
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7244
7287
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7245
7288
  Input$1,
@@ -7277,7 +7320,7 @@ const registerChaiLibrary = (o, n) => {
7277
7320
  `sidebar-${v}`
7278
7321
  ))
7279
7322
  ] }) }) }),
7280
- /* @__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: [
7323
+ /* @__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: A.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: [
7281
7324
  i("No blocks found matching"),
7282
7325
  ' "',
7283
7326
  d,
@@ -7285,7 +7328,7 @@ const registerChaiLibrary = (o, n) => {
7285
7328
  ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: E.map((v) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7286
7329
  /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(v.toLowerCase())) }),
7287
7330
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7288
- h === "all" ? filter(values(A), { group: v }) : values(A),
7331
+ h === "all" ? filter(values(w), { group: v }) : values(w),
7289
7332
  { hidden: !0 }
7290
7333
  ).map((I) => /* @__PURE__ */ jsx(
7291
7334
  CoreBlock,
@@ -7646,44 +7689,44 @@ const Input = ({ node: o }) => {
7646
7689
  }, currentAddSelection = atom(null), getBlockDisplayName = (o) => {
7647
7690
  var n;
7648
7691
  return o != null && o._name ? o._name : (o == null ? void 0 : o._type) === "Box" && (o != null && o.tag) && (o == null ? void 0 : o.tag) !== "div" ? startCase(o.tag) : ((n = o == null ? void 0 : o._type) == null ? void 0 : n.split("/").pop()) || "";
7649
- }, Node = memo(({ node: o, style: n, dragHandle: r }) => {
7692
+ }, truncateText = (o, n) => o.length > n ? o.substring(0, n) + "..." : o, Node = memo(({ node: o, style: n, dragHandle: r }) => {
7650
7693
  var R;
7651
- const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7652
- let p = null;
7653
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: h, data: f, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: C, handleClick: B } = o, j = (N) => {
7654
- N.stopPropagation(), !l.includes(h) && o.toggle();
7694
+ const { t: a } = useTranslation(), l = useUpdateBlocksProps(), [i] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
7695
+ let d = null;
7696
+ const p = o.children.length > 0, { highlightBlock: u, clearHighlight: g } = useBlockHighlight(), { id: m, data: h, isSelected: f, willReceiveDrop: x, isDragging: y, isEditing: b, handleClick: C } = o, B = get(h, "_show", !0), j = (N) => {
7697
+ N.stopPropagation(), B && o.toggle();
7655
7698
  }, _ = (N) => {
7656
- N.isInternal && (p = N.isOpen, N.isOpen && N.close());
7657
- }, w = (N) => {
7658
- N.isInternal && p !== null && (p ? N.open() : N.close(), p = null);
7659
- }, [k, A] = useAtom$1(currentAddSelection), E = () => {
7699
+ N.isInternal && (d = N.isOpen, N.isOpen && N.close());
7700
+ }, A = (N) => {
7701
+ N.isInternal && d !== null && (d ? N.open() : N.close(), d = null);
7702
+ }, [k, w] = useAtom$1(currentAddSelection), E = () => {
7660
7703
  var N;
7661
- S(), o.parent.isSelected || A((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7704
+ S(), o.parent.isSelected || w((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7662
7705
  }, S = () => {
7663
- A(null);
7706
+ w(null);
7664
7707
  }, v = (N) => {
7665
- S(), N.stopPropagation(), !o.isOpen && !l.includes(h) && o.toggle(), B(N);
7708
+ S(), N.stopPropagation(), !o.isOpen && B && o.toggle(), C(N);
7666
7709
  };
7667
7710
  useEffect(() => {
7668
7711
  const N = setTimeout(() => {
7669
- y && !o.isOpen && !b && !l.includes(h) && o.toggle();
7712
+ x && !o.isOpen && !y && B && o.toggle();
7670
7713
  }, 500);
7671
7714
  return () => clearTimeout(N);
7672
- }, [y, o, b]);
7715
+ }, [x, o, y]);
7673
7716
  const I = (N, D) => {
7674
- const $ = c.contentDocument || c.contentWindow.document, O = $.querySelector(`[data-block-id=${N}]`);
7717
+ const F = i.contentDocument || i.contentWindow.document, O = F.querySelector(`[data-block-id=${N}]`);
7675
7718
  O && O.setAttribute("data-drop", D);
7676
- const M = O.getBoundingClientRect(), H = c.getBoundingClientRect();
7677
- M.top >= H.top && M.left >= H.left && M.bottom <= H.bottom && M.right <= H.right || ($.documentElement.scrollTop = O.offsetTop - H.top);
7719
+ const M = O.getBoundingClientRect(), H = i.getBoundingClientRect();
7720
+ M.top >= H.top && M.left >= H.left && M.bottom <= H.bottom && M.right <= H.right || (F.documentElement.scrollTop = O.offsetTop - H.top);
7678
7721
  }, L = (N) => {
7679
7722
  S();
7680
7723
  const D = get(o, "parent.id");
7681
7724
  D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: N }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: N });
7682
7725
  };
7683
- if (h === ROOT_TEMP_KEY)
7726
+ if (m === ROOT_TEMP_KEY)
7684
7727
  return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7685
7728
  /* @__PURE__ */ jsx("br", {}),
7686
- d(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
7729
+ c(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
7687
7730
  "div",
7688
7731
  {
7689
7732
  role: "button",
@@ -7698,29 +7741,29 @@ const Input = ({ node: o }) => {
7698
7741
  ),
7699
7742
  /* @__PURE__ */ jsx("br", {})
7700
7743
  ] });
7701
- const T = useMemo(() => has(f, "_libBlockId") && !isEmpty(f._libBlockId) && (d(PERMISSIONS.CREATE_LIBRARY_BLOCK) || d(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [f, d]), P = useMemo(() => (f == null ? void 0 : f._type) === "PartialBlock" || (f == null ? void 0 : f._type) === "GlobalBlock", [f]);
7744
+ const T = useMemo(() => has(h, "_libBlockId") && !isEmpty(h._libBlockId) && (c(PERMISSIONS.CREATE_LIBRARY_BLOCK) || c(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [h, c]), P = useMemo(() => (h == null ? void 0 : h._type) === "PartialBlock" || (h == null ? void 0 : h._type) === "GlobalBlock", [h]);
7702
7745
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7703
7746
  "div",
7704
7747
  {
7705
- onMouseEnter: () => g(h),
7706
- onMouseLeave: () => m(),
7748
+ onMouseEnter: () => u(m),
7749
+ onMouseLeave: () => g(),
7707
7750
  onClick: v,
7708
7751
  style: n,
7709
- "data-node-id": h,
7710
- ref: l.includes(h) ? null : r,
7752
+ "data-node-id": m,
7753
+ ref: r,
7711
7754
  onDragStart: () => _(o),
7712
- onDragEnd: () => w(o),
7755
+ onDragEnd: () => A(o),
7713
7756
  onDragOver: (N) => {
7714
- N.preventDefault(), I(h, "yes");
7757
+ N.preventDefault(), I(m, "yes");
7715
7758
  },
7716
7759
  onDragLeave: (N) => {
7717
- N.preventDefault(), I(h, "no");
7760
+ N.preventDefault(), I(m, "no");
7718
7761
  },
7719
7762
  onDrop: (N) => {
7720
- N.preventDefault(), I(h, "no");
7763
+ N.preventDefault(), I(m, "no");
7721
7764
  },
7722
7765
  children: [
7723
- d(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((R = o == null ? void 0 : o.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
7766
+ c(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((R = o == null ? void 0 : o.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
7724
7767
  "div",
7725
7768
  {
7726
7769
  onClick: (N) => {
@@ -7728,21 +7771,21 @@ const Input = ({ node: o }) => {
7728
7771
  },
7729
7772
  onMouseEnter: E,
7730
7773
  onMouseLeave: S,
7731
- className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
7732
- children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary p-1 outline outline-2 outline-white hover:bg-primary", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3 stroke-[4] text-white" }) })
7774
+ className: "absolute -top-0.5 h-0.5 w-[90%] rounded bg-primary/80 opacity-0 delay-200 duration-200 group-hover:opacity-100",
7775
+ children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary/80 p-1 outline outline-2 outline-white hover:bg-primary/80", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-2 w-2 stroke-[2] text-white" }) })
7733
7776
  }
7734
7777
  ) }),
7735
7778
  /* @__PURE__ */ jsxs(
7736
7779
  "div",
7737
7780
  {
7738
7781
  className: cn(
7739
- "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
7740
- x ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
7741
- y && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
7782
+ "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 py-0 outline-none",
7783
+ f ? "bg-primary/20" : "hover:bg-primary/10",
7784
+ x && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7742
7785
  (o == null ? void 0 : o.id) === k ? "bg-primary/10" : "",
7743
- b && "opacity-20",
7744
- l.includes(h) ? "opacity-50" : "",
7745
- T && x && "bg-primary/20 text-primary"
7786
+ y && "opacity-20",
7787
+ B ? "" : "line-through opacity-50",
7788
+ T && f && "bg-primary/20 text-primary"
7746
7789
  ),
7747
7790
  children: [
7748
7791
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -7750,7 +7793,7 @@ const Input = ({ node: o }) => {
7750
7793
  "div",
7751
7794
  {
7752
7795
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
7753
- children: u && /* @__PURE__ */ jsx("button", { onClick: j, type: "button", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: `h-3 w-3 ${x ? "text-white" : "text-slate-400"}` }) })
7796
+ children: p && /* @__PURE__ */ jsx("button", { onClick: j, type: "button", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) })
7754
7797
  }
7755
7798
  ),
7756
7799
  /* @__PURE__ */ jsxs(
@@ -7759,20 +7802,20 @@ const Input = ({ node: o }) => {
7759
7802
  className: cn(
7760
7803
  "leading-1 flex items-center",
7761
7804
  T && "text-orange-600/90",
7762
- T && x && "text-orange-600",
7805
+ T && f && "text-orange-800",
7763
7806
  P && "text-purple-600/90",
7764
- P && x && "text-purple-100"
7807
+ P && f && "text-purple-800"
7765
7808
  ),
7766
7809
  children: [
7767
- /* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
7768
- C ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
7810
+ /* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
7811
+ b ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
7769
7812
  "div",
7770
7813
  {
7771
7814
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
7772
7815
  onDoubleClick: (N) => {
7773
7816
  N.stopPropagation(), o.edit(), o.deselect();
7774
7817
  },
7775
- children: /* @__PURE__ */ jsx("span", { children: getBlockDisplayName(f) })
7818
+ children: /* @__PURE__ */ jsx("span", { title: getBlockDisplayName(h).length > 17 ? getBlockDisplayName(h) : "", children: truncateText(getBlockDisplayName(h), 17) })
7776
7819
  }
7777
7820
  )
7778
7821
  ]
@@ -7780,11 +7823,11 @@ const Input = ({ node: o }) => {
7780
7823
  )
7781
7824
  ] }),
7782
7825
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-px group-hover:visible", children: [
7783
- canAddChildBlock(f == null ? void 0 : f._type) && !l.includes(h) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7826
+ canAddChildBlock(h == null ? void 0 : h._type) && B && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7784
7827
  /* @__PURE__ */ jsx(
7785
7828
  TooltipTrigger,
7786
7829
  {
7787
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: h }),
7830
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: m }),
7788
7831
  className: "cursor-pointer rounded bg-transparent p-px hover:bg-primary/10",
7789
7832
  asChild: !0,
7790
7833
  children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-4 w-4" })
@@ -7797,16 +7840,16 @@ const Input = ({ node: o }) => {
7797
7840
  TooltipTrigger,
7798
7841
  {
7799
7842
  onClick: (N) => {
7800
- N.stopPropagation(), i(h), o.isOpen && o.toggle();
7843
+ N.stopPropagation(), l([m], { _show: !B }), o.isOpen && o.toggle();
7801
7844
  },
7802
7845
  className: "cursor-pointer rounded bg-transparent p-0.5 hover:bg-primary/10",
7803
7846
  asChild: !0,
7804
- children: /* @__PURE__ */ jsx(EyeNoneIcon, { className: "h-4 w-4" })
7847
+ children: B ? /* @__PURE__ */ jsx(EyeClosedIcon, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(EyeOpenIcon, { className: "h-4 w-4" })
7805
7848
  }
7806
7849
  ),
7807
- /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999]", side: "bottom", children: a("Hide block") })
7850
+ /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999] text-xs", side: "bottom", children: a(B ? "Hide the block from page" : "Show the block on page") })
7808
7851
  ] }),
7809
- /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: h, 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" }) }) })
7852
+ /* @__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" }) }) })
7810
7853
  ] })
7811
7854
  ]
7812
7855
  }
@@ -7853,7 +7896,7 @@ const Input = ({ node: o }) => {
7853
7896
  return canAcceptChildBlock(a, l);
7854
7897
  };
7855
7898
  }, ListTree = () => {
7856
- const [treeData] = useAtom$1(treeDSBlocks), [ids, setIds] = useSelectedBlockIds(), [cutBlocksIds] = useCutBlockIds(), [, setHiddenBlocks] = useHiddenBlockIds(), updateBlockProps = useUpdateBlocksProps(), [, setStyleBlocks] = useSelectedStylingBlocks(), { moveBlocks } = useBlocksStoreUndoableActions(), canMove = useCanMove(), treeRef = useRef(null), [, setTreeRef] = useAtom$1(treeRefAtom), { t } = useTranslation(), [parentContext, setParentContext] = useState(null), clearSelection = () => {
7899
+ const [treeData] = useAtom$1(treeDSBlocks), [ids, setIds] = useSelectedBlockIds(), [cutBlocksIds] = useCutBlockIds(), updateBlockProps = useUpdateBlocksProps(), [, setStyleBlocks] = useSelectedStylingBlocks(), { moveBlocks } = useBlocksStoreUndoableActions(), canMove = useCanMove(), treeRef = useRef(null), [, setTreeRef] = useAtom$1(treeRefAtom), { t } = useTranslation(), [parentContext, setParentContext] = useState(null), clearSelection = () => {
7857
7900
  setIds([]), setStyleBlocks([]);
7858
7901
  }, filteredTreeData = useMemo(() => {
7859
7902
  const o = (r, a) => r.filter((l) => !a.includes(l._id)).map((l) => ({
@@ -7931,6 +7974,7 @@ const Input = ({ node: o }) => {
7931
7974
  disabled: !hasPermission(PERMISSIONS.ADD_BLOCK),
7932
7975
  onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),
7933
7976
  variant: "default",
7977
+ className: "bg-primary/80",
7934
7978
  size: "sm",
7935
7979
  children: [
7936
7980
  "+ ",
@@ -7949,19 +7993,6 @@ const Input = ({ node: o }) => {
7949
7993
  },
7950
7994
  children: [
7951
7995
  /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center justify-end gap-x-1 pb-2 text-sm text-muted-foreground", children: [
7952
- /* @__PURE__ */ jsxs(Tooltip, { children: [
7953
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
7954
- Button,
7955
- {
7956
- onClick: () => setHiddenBlocks([]),
7957
- variant: "ghost",
7958
- className: "h-fit p-1 disabled:cursor-not-allowed disabled:opacity-50",
7959
- size: "sm",
7960
- children: /* @__PURE__ */ jsx(EyeOpenIcon, { className: "h-2 w-2" })
7961
- }
7962
- ) }),
7963
- /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999]", children: t("Show hidden blocks") })
7964
- ] }),
7965
7996
  /* @__PURE__ */ jsxs(Tooltip, { children: [
7966
7997
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { className: "h-fit p-1", onClick: () => {
7967
7998
  var o;
@@ -8001,7 +8032,7 @@ const Input = ({ node: o }) => {
8001
8032
  onSelect,
8002
8033
  childrenAccessor: (o) => o.children,
8003
8034
  width: "100%",
8004
- rowHeight: 28,
8035
+ rowHeight: 25,
8005
8036
  renderDragPreview: DefaultDragPreview,
8006
8037
  indent: 10,
8007
8038
  onContextMenu,
@@ -8212,7 +8243,7 @@ const Input = ({ node: o }) => {
8212
8243
  "popover-foreground": ["#3d3436", "#f2e9e4"]
8213
8244
  }
8214
8245
  }, LazyCssImportModal = lazy(
8215
- () => import("./css-import-modal-CgSqJi_w.js").then((o) => ({ default: o.CssImportModal }))
8246
+ () => import("./css-import-modal-CgQoE9jh.js").then((o) => ({ default: o.CssImportModal }))
8216
8247
  ), PREV_THEME_KEY = "chai-builder-previous-theme", DEFAULT_THEME_PRESET = [
8217
8248
  { shadcn_default: defaultShadcnPreset },
8218
8249
  { twitter_theme: twitter },
@@ -8236,16 +8267,16 @@ const Input = ({ node: o }) => {
8236
8267
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
8237
8268
  const [n, r] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions();
8238
8269
  if (d) {
8239
- const w = d.map((k) => Object.keys(k)[0]);
8270
+ const A = d.map((k) => Object.keys(k)[0]);
8240
8271
  DEFAULT_THEME_PRESET.forEach((k) => {
8241
- const A = Object.keys(k)[0];
8242
- w.includes(A) || d.push(k);
8272
+ const w = Object.keys(k)[0];
8273
+ A.includes(w) || d.push(k);
8243
8274
  });
8244
8275
  }
8245
8276
  const [g, m] = useTheme(), h = useThemeOptions(), { t: f } = useTranslation(), x = React.useCallback(
8246
- (w) => {
8277
+ (A) => {
8247
8278
  const k = { ...g };
8248
- setPreviousTheme(k), m(w), toast.success("Theme updated", {
8279
+ setPreviousTheme(k), m(A), toast.success("Theme updated", {
8249
8280
  action: {
8250
8281
  label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
8251
8282
  /* @__PURE__ */ jsx(ResetIcon, { className: "h-4 w-4" }),
@@ -8261,56 +8292,56 @@ const Input = ({ node: o }) => {
8261
8292
  },
8262
8293
  [g, m]
8263
8294
  ), y = () => {
8264
- const w = d.find((k) => Object.keys(k)[0] === a);
8265
- if (w) {
8266
- const k = Object.values(w)[0];
8295
+ const A = d.find((k) => Object.keys(k)[0] === a);
8296
+ if (A) {
8297
+ const k = Object.values(A)[0];
8267
8298
  k && typeof k == "object" && "fontFamily" in k && "borderRadius" in k && "colors" in k ? (x(k), l("")) : console.error("Invalid preset structure:", k);
8268
8299
  } else
8269
8300
  console.error("Preset not found:", a);
8270
- }, b = (w) => {
8271
- x(w), l("");
8301
+ }, b = (A) => {
8302
+ x(A), l("");
8272
8303
  }, C = useDebouncedCallback(
8273
- (w, k) => {
8304
+ (A, k) => {
8274
8305
  m(() => ({
8275
8306
  ...g,
8276
8307
  fontFamily: {
8277
8308
  ...g.fontFamily,
8278
- [w.replace(/font-/g, "")]: k
8309
+ [A.replace(/font-/g, "")]: k
8279
8310
  }
8280
8311
  }));
8281
8312
  },
8282
8313
  [g],
8283
8314
  200
8284
8315
  ), B = React.useCallback(
8285
- (w) => {
8316
+ (A) => {
8286
8317
  m(() => ({
8287
8318
  ...g,
8288
- borderRadius: `${w}px`
8319
+ borderRadius: `${A}px`
8289
8320
  }));
8290
8321
  },
8291
8322
  [g]
8292
8323
  ), j = useDebouncedCallback(
8293
- (w, k) => {
8324
+ (A, k) => {
8294
8325
  m(() => {
8295
- const A = get(g, `colors.${w}`);
8296
- return n ? set(A, 1, k) : set(A, 0, k), {
8326
+ const w = get(g, `colors.${A}`);
8327
+ return n ? set(w, 1, k) : set(w, 0, k), {
8297
8328
  ...g,
8298
8329
  colors: {
8299
8330
  ...g.colors,
8300
- [w]: A
8331
+ [A]: w
8301
8332
  }
8302
8333
  };
8303
8334
  });
8304
8335
  },
8305
8336
  [g],
8306
8337
  200
8307
- ), _ = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([k]) => {
8308
- const A = get(g, `colors.${k}.${n ? 1 : 0}`);
8309
- return A ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8338
+ ), _ = (A) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(A.items).map(([k]) => {
8339
+ const w = get(g, `colors.${k}.${n ? 1 : 0}`);
8340
+ return w ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8310
8341
  /* @__PURE__ */ jsx(
8311
8342
  ColorPickerInput,
8312
8343
  {
8313
- value: A,
8344
+ value: w,
8314
8345
  onChange: (E) => j(k, E)
8315
8346
  }
8316
8347
  ),
@@ -8330,9 +8361,9 @@ const Input = ({ node: o }) => {
8330
8361
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
8331
8362
  /* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
8332
8363
  /* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
8333
- /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((w) => {
8334
- const k = Object.keys(w)[0], A = k.replaceAll("_", " ");
8335
- return /* @__PURE__ */ jsx(SelectItem, { value: k, children: capitalize(A) }, k);
8364
+ /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((A) => {
8365
+ const k = Object.keys(A)[0], w = k.replaceAll("_", " ");
8366
+ return /* @__PURE__ */ jsx(SelectItem, { value: k, children: capitalize(w) }, k);
8336
8367
  }) })
8337
8368
  ] }) }),
8338
8369
  /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: y, children: f("Apply") }) })
@@ -8344,14 +8375,14 @@ const Input = ({ node: o }) => {
8344
8375
  /* @__PURE__ */ jsx(TextIcon, { className: "h-3 w-3 text-gray-600" }),
8345
8376
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Typography" })
8346
8377
  ] }),
8347
- (h == null ? void 0 : h.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(h.fontFamily).map(([w, k]) => /* @__PURE__ */ jsx(
8378
+ (h == null ? void 0 : h.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(h.fontFamily).map(([A, k]) => /* @__PURE__ */ jsx(
8348
8379
  FontSelector,
8349
8380
  {
8350
- label: w,
8351
- value: g.fontFamily[w.replace(/font-/g, "")] || k[Object.keys(k)[0]],
8352
- onChange: (A) => C(w, A)
8381
+ label: A,
8382
+ value: g.fontFamily[A.replace(/font-/g, "")] || k[Object.keys(k)[0]],
8383
+ onChange: (w) => C(A, w)
8353
8384
  },
8354
- w
8385
+ A
8355
8386
  )) }),
8356
8387
  /* @__PURE__ */ jsx(Separator, {}),
8357
8388
  (h == null ? void 0 : h.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
@@ -8377,7 +8408,7 @@ const Input = ({ node: o }) => {
8377
8408
  Switch,
8378
8409
  {
8379
8410
  checked: n,
8380
- onCheckedChange: (w) => r(w),
8411
+ onCheckedChange: (A) => r(A),
8381
8412
  "aria-label": "Toggle dark mode",
8382
8413
  className: "mx-1"
8383
8414
  }
@@ -8385,7 +8416,7 @@ const Input = ({ node: o }) => {
8385
8416
  /* @__PURE__ */ jsx(MoonIcon, { className: "h-4 w-4" })
8386
8417
  ] }) })
8387
8418
  ] }),
8388
- /* @__PURE__ */ jsx("div", { className: "space-y-2", children: h.colors.map((w) => _(w)) })
8419
+ /* @__PURE__ */ jsx("div", { className: "space-y-2", children: h.colors.map((A) => _(A)) })
8389
8420
  ] }),
8390
8421
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: i && /* @__PURE__ */ jsx(
8391
8422
  LazyCssImportModal,
@@ -9025,8 +9056,8 @@ function AIChatPanel() {
9025
9056
  if (C) {
9026
9057
  const j = new FileReader();
9027
9058
  j.onload = (_) => {
9028
- var w;
9029
- d((w = _.target) == null ? void 0 : w.result);
9059
+ var A;
9060
+ d((A = _.target) == null ? void 0 : A.result);
9030
9061
  }, j.readAsDataURL(C);
9031
9062
  }
9032
9063
  }, x = () => {
@@ -9235,8 +9266,8 @@ const AiAssistant = () => {
9235
9266
  r(k), l(a), c(""), p(""), h("");
9236
9267
  }
9237
9268
  }, C = (k) => {
9238
- const A = a.filter((E, S) => S !== k);
9239
- r(A), l(A);
9269
+ const w = a.filter((E, S) => S !== k);
9270
+ r(w), l(w);
9240
9271
  }, B = (k) => {
9241
9272
  g(k), c(a[k].key), p(a[k].value);
9242
9273
  }, j = () => {
@@ -9250,11 +9281,11 @@ const AiAssistant = () => {
9250
9281
  }
9251
9282
  }, _ = (k) => {
9252
9283
  k.key === "Enter" && !k.shiftKey && (k.preventDefault(), u !== null ? j() : b());
9253
- }, w = useCallback((k) => {
9254
- const A = (v) => /[.,!?;:]/.test(v), E = (v, I, L) => {
9284
+ }, A = useCallback((k) => {
9285
+ const w = (v) => /[.,!?;:]/.test(v), E = (v, I, L) => {
9255
9286
  let T = "", P = "";
9256
9287
  const R = I > 0 ? v[I - 1] : "", N = I < v.length ? v[I] : "";
9257
- return I > 0 && (R === "." || !A(R) && R !== " ") && (T = " "), I < v.length && !A(N) && N !== " " && (P = " "), {
9288
+ return I > 0 && (R === "." || !w(R) && R !== " ") && (T = " "), I < v.length && !w(N) && N !== " " && (P = " "), {
9258
9289
  text: T + L + P,
9259
9290
  prefixLength: T.length,
9260
9291
  suffixLength: P.length
@@ -9263,7 +9294,7 @@ const AiAssistant = () => {
9263
9294
  if (S) {
9264
9295
  const v = S.selectionStart || 0, I = S.value || "", L = S.selectionEnd || v;
9265
9296
  if (L > v) {
9266
- const D = `{{${k}}}`, { text: $ } = E(I, v, D), O = I.slice(0, v) + $ + I.slice(L);
9297
+ const D = `{{${k}}}`, { text: F } = E(I, v, D), O = I.slice(0, v) + F + I.slice(L);
9267
9298
  p(O);
9268
9299
  return;
9269
9300
  }
@@ -9301,7 +9332,7 @@ const AiAssistant = () => {
9301
9332
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9302
9333
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9303
9334
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9304
- !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: w })
9335
+ !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: A })
9305
9336
  ] }),
9306
9337
  /* @__PURE__ */ jsx(
9307
9338
  Textarea,
@@ -9326,16 +9357,16 @@ const AiAssistant = () => {
9326
9357
  ]
9327
9358
  }
9328
9359
  ),
9329
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((k, A) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9360
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((k, w) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9330
9361
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9331
9362
  /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: k.key }),
9332
9363
  /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: k.value.toString() })
9333
9364
  ] }),
9334
9365
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9335
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(A), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
9336
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => C(A), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
9366
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(w), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
9367
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => C(w), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
9337
9368
  ] })
9338
- ] }, A)) })
9369
+ ] }, w)) })
9339
9370
  ] });
9340
9371
  }), BlockAttributesEditor = React.memo(() => {
9341
9372
  const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9404,11 +9435,23 @@ function BlockAttributesToggle() {
9404
9435
  n && /* @__PURE__ */ jsx(BlockAttributesEditor, {})
9405
9436
  ] });
9406
9437
  }
9407
- const SettingsPanel = () => {
9438
+ const PartialWrapper = ({ partialBlockId: o }) => {
9439
+ const n = useBuilderProp("gotoPage", noop), { saveState: r } = useSavePage(), { selectedLang: a, fallbackLang: l } = useLanguages(), i = useCallback(
9440
+ (c) => {
9441
+ if (c.stopPropagation(), r !== "SAVED") {
9442
+ toast.error("You have unsaved changes. Please save the page first.");
9443
+ return;
9444
+ }
9445
+ n({ pageId: o, lang: a || l });
9446
+ },
9447
+ [r, n, o, a, l]
9448
+ );
9449
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "hidden", children: /* @__PURE__ */ jsx("div", { onDoubleClick: i, className: "h-full w-full items-center justify-center", children: /* @__PURE__ */ jsx("p", { className: "rounded-md bg-white px-2 py-1 text-xs", children: "Partial block. Double click to edit." }) }) }) });
9450
+ }, SettingsPanel = () => {
9408
9451
  const o = useSelectedBlock(), { t: n } = useTranslation(), r = useBuilderProp("onError", noop), { hasPermission: a } = usePermissions();
9409
9452
  let l = !a(PERMISSIONS.EDIT_BLOCK);
9410
9453
  const i = !a(PERMISSIONS.EDIT_STYLES);
9411
- return isNull(o) ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
9454
+ return o && o._type === "PartialBlock" ? /* @__PURE__ */ jsx(PartialWrapper, { partialBlockId: o.partialBlockId }) : isNull(o) ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
9412
9455
  /* @__PURE__ */ jsx(MixerHorizontalIcon, { className: "mx-auto text-3xl" }),
9413
9456
  /* @__PURE__ */ jsx("h1", { children: n("Please select a block to edit settings or styles") })
9414
9457
  ] }) }) : l && i ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
@@ -9493,11 +9536,11 @@ function useSidebarDefaultPanels() {
9493
9536
  }, [o, n, r]);
9494
9537
  }
9495
9538
  const RootLayout = () => {
9496
- 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((A) => {
9497
- A.preventDefault();
9539
+ 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((w) => {
9540
+ w.preventDefault();
9498
9541
  }, []), f = useCallback(
9499
- (A) => {
9500
- console.log("handleMenuItemClick", A, n), r(n === A ? null : A);
9542
+ (w) => {
9543
+ console.log("handleMenuItemClick", w, n), r(n === w ? null : w);
9501
9544
  },
9502
9545
  [n, r]
9503
9546
  ), { t: x } = useTranslation(), y = useMemo(
@@ -9506,25 +9549,25 @@ const RootLayout = () => {
9506
9549
  ), b = useBuilderProp("htmlDir", "ltr"), C = find(y, { id: n }) ?? first(y), B = get(C, "width", DEFAULT_PANEL_WIDTH);
9507
9550
  useEffect(() => {
9508
9551
  if (n !== null) {
9509
- const A = find(y, { id: n });
9510
- A && get(A, "view", "standard") === "standard" && (a.current = n, i(get(A, "width", DEFAULT_PANEL_WIDTH)));
9552
+ const w = find(y, { id: n });
9553
+ w && get(w, "view", "standard") === "standard" && (a.current = n, i(get(w, "width", DEFAULT_PANEL_WIDTH)));
9511
9554
  }
9512
9555
  }, [n, y]);
9513
9556
  const j = useMemo(() => {
9514
9557
  if (n === null) return 0;
9515
- const A = find(y, { id: n });
9516
- return get(A, "view", "standard") === "standard" ? B : l;
9558
+ const w = find(y, { id: n });
9559
+ return get(w, "view", "standard") === "standard" ? B : l;
9517
9560
  }, [n, B, l, y]), _ = useCallback(() => {
9518
9561
  r(a.current);
9519
- }, [r, n]), w = useCallback(() => {
9562
+ }, [r, n]), A = useCallback(() => {
9520
9563
  r("outline");
9521
9564
  }, [r]);
9522
9565
  useEffect(() => {
9523
9566
  n !== null && !find(y, { id: n }) && r("outline");
9524
9567
  }, [n, y]);
9525
9568
  const k = useCallback(
9526
- (A) => {
9527
- f(A);
9569
+ (w) => {
9570
+ f(w);
9528
9571
  },
9529
9572
  [f]
9530
9573
  );
@@ -9538,24 +9581,24 @@ const RootLayout = () => {
9538
9581
  /* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
9539
9582
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9540
9583
  /* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9541
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((A, E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9542
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(A, "button", NoopComponent), {
9584
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((w, E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9585
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(w, "button", NoopComponent), {
9543
9586
  position: "top",
9544
- panelId: A.id,
9545
- isActive: n === A.id,
9546
- show: () => k(A.id)
9587
+ panelId: w.id,
9588
+ isActive: n === w.id,
9589
+ show: () => k(w.id)
9547
9590
  }) }),
9548
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(A.label) }) })
9591
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(w.label) }) })
9549
9592
  ] }, "button-top-" + E)) }),
9550
9593
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9551
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: m == null ? void 0 : m.map((A, E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9552
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(A, "button", NoopComponent), {
9594
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: m == null ? void 0 : m.map((w, E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9595
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(w, "button", NoopComponent), {
9553
9596
  position: "bottom",
9554
- panelId: A.id,
9555
- isActive: n === A.id,
9556
- show: () => k(A.id)
9597
+ panelId: w.id,
9598
+ isActive: n === w.id,
9599
+ show: () => k(w.id)
9557
9600
  }) }),
9558
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(A.label) }) })
9601
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(w.label) }) })
9559
9602
  ] }, "button-bottom-" + E)) })
9560
9603
  ] }),
9561
9604
  /* @__PURE__ */ jsx(
@@ -9632,7 +9675,7 @@ const RootLayout = () => {
9632
9675
  /* @__PURE__ */ jsx("span", { children: x(get(C, "label", "")) })
9633
9676
  ] }) }),
9634
9677
  /* @__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(C, "panel", NoopComponent), {
9635
- close: w
9678
+ close: A
9636
9679
  }) }) })
9637
9680
  ]
9638
9681
  }
@@ -9644,7 +9687,7 @@ const RootLayout = () => {
9644
9687
  /* @__PURE__ */ jsx("span", { children: x(get(C, "label", "")) })
9645
9688
  ] }) }),
9646
9689
  /* @__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(C, "panel", NoopComponent), {
9647
- close: w
9690
+ close: A
9648
9691
  }) }) })
9649
9692
  ] }) }),
9650
9693
  n !== null && get(C, "view") === "overlay" && /* @__PURE__ */ jsx(
@@ -9672,7 +9715,7 @@ const RootLayout = () => {
9672
9715
  /* @__PURE__ */ jsx(Button, { onClick: () => _(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-5 w-5" }) })
9673
9716
  ] }),
9674
9717
  /* @__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(C, "panel", NoopComponent), {
9675
- close: w
9718
+ close: A
9676
9719
  }) }) })
9677
9720
  ]
9678
9721
  }
@@ -9725,8 +9768,8 @@ const RootLayout = () => {
9725
9768
  });
9726
9769
  }, h = (x) => {
9727
9770
  if (!c) return;
9728
- const y = x.clientX - p.x, b = x.clientY - p.y, C = x.currentTarget, B = C.offsetWidth, j = C.offsetHeight, _ = window.innerWidth - B, w = window.innerHeight - j, k = Math.max(0, Math.min(y, _)), A = Math.max(0, Math.min(b, w));
9729
- r(k, A);
9771
+ const y = x.clientX - p.x, b = x.clientY - p.y, C = x.currentTarget, B = C.offsetWidth, j = C.offsetHeight, _ = window.innerWidth - B, A = window.innerHeight - j, k = Math.max(0, Math.min(y, _)), w = Math.max(0, Math.min(b, A));
9772
+ r(k, w);
9730
9773
  }, f = () => {
9731
9774
  d(!1);
9732
9775
  };
@@ -9968,10 +10011,10 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
9968
10011
  var r;
9969
10012
  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], y = u(o, n);
9970
10013
  if (isAtomStateInitialized(y) && (l.has(n) && i.get(n) !== y.n || Array.from(y.d).every(
9971
- ([A, E]) => (
10014
+ ([w, E]) => (
9972
10015
  // Recursively, read the atom state of the dependency, and
9973
10016
  // check if the atom epoch number is unchanged
9974
- h(o, A).n === E
10017
+ h(o, w).n === E
9975
10018
  )
9976
10019
  )))
9977
10020
  return y;
@@ -9980,34 +10023,34 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
9980
10023
  function C() {
9981
10024
  l.has(n) && (x(o, n), m(o), g(o));
9982
10025
  }
9983
- function B(A) {
10026
+ function B(w) {
9984
10027
  var E;
9985
- if (isSelfAtom(n, A)) {
9986
- const v = u(o, A);
10028
+ if (isSelfAtom(n, w)) {
10029
+ const v = u(o, w);
9987
10030
  if (!isAtomStateInitialized(v))
9988
- if (hasInitialValue(A))
9989
- setAtomStateValueOrPromise(o, A, A.init);
10031
+ if (hasInitialValue(w))
10032
+ setAtomStateValueOrPromise(o, w, w.init);
9990
10033
  else
9991
10034
  throw new Error("no atom init");
9992
10035
  return returnAtomValue(v);
9993
10036
  }
9994
- const S = h(o, A);
10037
+ const S = h(o, w);
9995
10038
  try {
9996
10039
  return returnAtomValue(S);
9997
10040
  } finally {
9998
- y.d.set(A, S.n), isPendingPromise(y.v) && addPendingPromiseToDependency(n, y.v, S), (E = l.get(A)) == null || E.t.add(n), b || C();
10041
+ y.d.set(w, S.n), isPendingPromise(y.v) && addPendingPromiseToDependency(n, y.v, S), (E = l.get(w)) == null || E.t.add(n), b || C();
9999
10042
  }
10000
10043
  }
10001
10044
  let j, _;
10002
- const w = {
10045
+ const A = {
10003
10046
  get signal() {
10004
10047
  return j || (j = new AbortController()), j.signal;
10005
10048
  },
10006
10049
  get setSelf() {
10007
- return !_ && isActuallyWritableAtom(n) && (_ = (...A) => {
10050
+ return !_ && isActuallyWritableAtom(n) && (_ = (...w) => {
10008
10051
  if (!b)
10009
10052
  try {
10010
- return f(o, n, ...A);
10053
+ return f(o, n, ...w);
10011
10054
  } finally {
10012
10055
  m(o), g(o);
10013
10056
  }
@@ -10015,10 +10058,10 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10015
10058
  }
10016
10059
  }, k = y.n;
10017
10060
  try {
10018
- const A = p(o, n, B, w);
10019
- return setAtomStateValueOrPromise(o, n, A), isPromiseLike$1(A) && (registerAbortHandler(A, () => j == null ? void 0 : j.abort()), A.then(C, C)), y;
10020
- } catch (A) {
10021
- return delete y.v, y.e = A, ++y.n, y;
10061
+ const w = p(o, n, B, A);
10062
+ return setAtomStateValueOrPromise(o, n, w), isPromiseLike$1(w) && (registerAbortHandler(w, () => j == null ? void 0 : j.abort()), w.then(C, C)), y;
10063
+ } catch (w) {
10064
+ return delete y.v, y.e = w, ++y.n, y;
10022
10065
  } finally {
10023
10066
  b = !1, k !== y.n && i.get(n) === k && (i.set(n, y.n), c.add(n), (r = d.c) == null || r.call(d, n));
10024
10067
  }
@@ -10041,8 +10084,8 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10041
10084
  if (isSelfAtom(n, b)) {
10042
10085
  if (!hasInitialValue(b))
10043
10086
  throw new Error("atom not writable");
10044
- const _ = j.n, w = C[0];
10045
- setAtomStateValueOrPromise(o, b, w), h(o, b), _ !== j.n && (l.add(b), (B = i.c) == null || B.call(i, b), m(o, b));
10087
+ const _ = j.n, A = C[0];
10088
+ setAtomStateValueOrPromise(o, b, A), h(o, b), _ !== j.n && (l.add(b), (B = i.c) == null || B.call(i, b), m(o, b));
10046
10089
  return;
10047
10090
  } else
10048
10091
  return writeAtomState(o, b, ...C);
@@ -10414,7 +10457,6 @@ export {
10414
10457
  useCutBlockIds,
10415
10458
  useDarkMode,
10416
10459
  useDuplicateBlocks,
10417
- useHiddenBlockIds,
10418
10460
  useHighlightBlockId,
10419
10461
  useInlineEditing,
10420
10462
  useIsPageLoaded,
@@ -10447,7 +10489,7 @@ export {
10447
10489
  useTheme,
10448
10490
  useThemeOptions,
10449
10491
  useToggleChaiFeatureFlag,
10450
- Fe as useTranslation,
10492
+ $e as useTranslation,
10451
10493
  useUndoManager,
10452
10494
  useUpdateBlocksProps,
10453
10495
  useUpdateBlocksPropsRealtime,