@chaibuilder/sdk 2.4.3 → 2.4.4

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,17 +1,17 @@
1
- var H = Object.defineProperty;
2
- var U = (o, r, n) => r in o ? H(o, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[r] = n;
3
- var F = (o, r, n) => U(o, typeof r != "symbol" ? r + "" : r, n);
1
+ var U = Object.defineProperty;
2
+ var V = (o, r, n) => r in o ? U(o, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[r] = n;
3
+ var F = (o, r, n) => V(o, typeof r != "symbol" ? r + "" : r, n);
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
6
6
  import { BoxModelIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, LoopIcon, InfoCircledIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, Cross1Icon, BoxIcon, MinusIcon, CrossCircledIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, CaretRightIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, CheckIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
7
- import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, flatMapDeep, some, sortBy, round } from "lodash-es";
7
+ import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, flatMapDeep, some, trim, sortBy, round } from "lodash-es";
8
8
  import * as React from "react";
9
- import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, useReducer, useDebugValue } from "react";
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, 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, a9 as DialogTitle, 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, a4 as DialogDescription, a5 as DialogFooter, 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, aY as Switch, r as Avatar, aL as Separator, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle } from "./toggle-BKtuoy5e.js";
14
- import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, Info, File, Database, MoreVertical, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, Eye, ChevronsUpDown, ChevronsDownUp, ImportIcon, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
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, 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, a9 as DialogTitle, 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, 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, aY as Switch, r as Avatar, aL as Separator, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle } from "./toggle-BKtuoy5e.js";
14
+ import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, Info, File, Database, MoreVertical, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, Eye, ChevronsUpDown, ChevronsDownUp, Undo as Undo$1, ImportIcon, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
15
15
  import clsx$1, { clsx } from "clsx";
16
16
  import { twMerge } from "tailwind-merge";
17
17
  import TreeModel from "tree-model";
@@ -21,7 +21,7 @@ import { isObject } from "@rjsf/utils";
21
21
  import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
22
22
  import { toast, Toaster } from "sonner";
23
23
  import { useTranslation, initReactI18next } from "react-i18next";
24
- import { useTranslation as He } from "react-i18next";
24
+ import { useTranslation as Ue } from "react-i18next";
25
25
  import Fuse from "fuse.js";
26
26
  import UndoManager from "undo-manager";
27
27
  import Link from "@tiptap/extension-link";
@@ -47,7 +47,7 @@ import twContainer from "@tailwindcss/container-queries";
47
47
  import { ErrorBoundary } from "react-error-boundary";
48
48
  import { motion } from "framer-motion";
49
49
  import { useHotkeys } from "react-hotkeys-hook";
50
- import { flip } from "@floating-ui/dom";
50
+ import { limitShift, flip, size } from "@floating-ui/dom";
51
51
  import { useFloating, shift } from "@floating-ui/react-dom";
52
52
  import ReactDOM from "react-dom";
53
53
  import { Provider as Provider$1 } from "react-wrap-balancer";
@@ -343,16 +343,16 @@ function insertBlocksAtPosition(o, r, n, a) {
343
343
  _type: "Text",
344
344
  content: u.content
345
345
  };
346
- Object.keys(u).forEach((x) => {
347
- x.startsWith("content-") && (m[x] = u[x]);
348
- }), l.unshift(m), i = i.map((x) => {
349
- if (x._id === n) {
350
- const f = { ...x, content: "" };
351
- return Object.keys(f).forEach((y) => {
352
- y.startsWith("content-") && (f[y] = "");
353
- }), f;
346
+ Object.keys(u).forEach((f) => {
347
+ f.startsWith("content-") && (m[f] = u[f]);
348
+ }), l.unshift(m), i = i.map((f) => {
349
+ if (f._id === n) {
350
+ const x = { ...f, content: "" };
351
+ return Object.keys(x).forEach((k) => {
352
+ k.startsWith("content-") && (x[k] = "");
353
+ }), x;
354
354
  }
355
- return x;
355
+ return f;
356
356
  });
357
357
  }
358
358
  }
@@ -480,15 +480,15 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
480
480
  if (g.length === 2) {
481
481
  const h = g.find((m) => m._id !== d);
482
482
  if (h && h._type === "Text") {
483
- const m = n.find((x) => x._id === u);
484
- m && "content" in m && (n = n.map((x) => {
485
- if (x._id === u) {
486
- const f = { ...x, content: h.content };
487
- return Object.keys(h).forEach((y) => {
488
- y.startsWith("content-") && (f[y] = h[y]);
489
- }), f;
483
+ const m = n.find((f) => f._id === u);
484
+ m && "content" in m && (n = n.map((f) => {
485
+ if (f._id === u) {
486
+ const x = { ...f, content: h.content };
487
+ return Object.keys(h).forEach((k) => {
488
+ k.startsWith("content-") && (x[k] = h[k]);
489
+ }), x;
490
490
  }
491
- return x;
491
+ return f;
492
492
  }), a.push(h._id));
493
493
  }
494
494
  }
@@ -571,32 +571,32 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
571
571
  status: "idle",
572
572
  props: {},
573
573
  error: void 0
574
- }), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (x) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, n ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), h = (o == null ? void 0 : o._type) !== "Repeater" && r === "live";
574
+ }), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, n ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), h = (o == null ? void 0 : o._type) !== "Repeater" && r === "live";
575
575
  return useEffect(() => {
576
576
  if (r === "mock") {
577
577
  if (isFunction(a)) {
578
- i((f) => ({ ...f, status: "loading", props: {} }));
579
- const x = a({ block: o });
580
- if (!isObject(x))
578
+ i((x) => ({ ...x, status: "loading", props: {} }));
579
+ const f = a({ block: o });
580
+ if (!isObject(f))
581
581
  throw new Error("mockDataProvider should return an object");
582
- i((f) => ({ ...f, status: "loaded", props: x }));
582
+ i((x) => ({ ...x, status: "loaded", props: f }));
583
583
  }
584
584
  return;
585
585
  }
586
- r === "live" && (!g && !h || (i((x) => ({ ...x, status: "loading", props: {} })), d({ block: o }).then((x = {}) => {
587
- g ? (p((f) => ({
588
- ...f,
586
+ r === "live" && (!g && !h || (i((f) => ({ ...f, status: "loading", props: {} })), d({ block: o }).then((f = {}) => {
587
+ g ? (p((x) => ({
588
+ ...x,
589
589
  [o._id]: {
590
590
  status: "loaded",
591
- props: get(x, "items", []),
591
+ props: get(f, "items", []),
592
592
  repeaterItems: o.repeaterItems
593
593
  }
594
- })), i((f) => ({ ...f, status: "loaded", props: { totalItems: get(x, "totalItems") } })), c([o._id], { totalItems: get(x, "totalItems") })) : i((f) => ({ ...f, status: "loaded", props: isObject(x) ? x : {} }));
595
- }).catch((x) => {
596
- g ? (p((f) => ({
597
- ...f,
598
- [o._id]: { status: "error", error: x, props: [] }
599
- })), i((f) => ({ ...f, status: "error", error: x, props: {} }))) : i((f) => ({ ...f, status: "error", error: x, props: {} }));
594
+ })), 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 : {} }));
595
+ }).catch((f) => {
596
+ g ? (p((x) => ({
597
+ ...x,
598
+ [o._id]: { status: "error", error: f, props: [] }
599
+ })), i((x) => ({ ...x, status: "error", error: f, props: {} }))) : i((x) => ({ ...x, status: "error", error: f, props: {} }));
600
600
  })));
601
601
  }, [o == null ? void 0 : o._id, u, g, h, a, r]), {
602
602
  $loading: get(l, "status") === "loading",
@@ -761,10 +761,10 @@ const checkMissingTranslations = (o, r) => r ? o.some((n) => {
761
761
  if (!c("save_page"))
762
762
  return;
763
763
  r("SAVING"), a("SAVING");
764
- const x = l();
764
+ const f = l();
765
765
  return await n({
766
766
  autoSave: m,
767
- blocks: x.blocks,
767
+ blocks: f.blocks,
768
768
  theme: i,
769
769
  needTranslations: u()
770
770
  }), setTimeout(() => {
@@ -839,65 +839,65 @@ const undoRedoStateAtom = atom({
839
839
  updateBlocksProps: c
840
840
  } = useBlocksStoreManager();
841
841
  return {
842
- moveBlocks: (f, y, b) => {
843
- const B = map(f, (A) => {
844
- const w = r.find((N) => N._id === A)._parent || null, v = r.filter((N) => w ? N._parent === w : !N._parent).map((N) => N._id).indexOf(A);
845
- return { _id: A, oldParent: w, oldPosition: v };
846
- }), E = B.find(({ _id: A }) => A === f[0]);
847
- E && E.oldParent === y && E.oldPosition === b || (i(f, y, b), o({
848
- undo: () => each(B, ({ _id: A, oldParent: j, oldPosition: w }) => {
849
- i([A], j, w);
842
+ moveBlocks: (x, k, b) => {
843
+ const A = map(x, (_) => {
844
+ const w = r.find((E) => E._id === _)._parent || null, S = r.filter((E) => w ? E._parent === w : !E._parent).map((E) => E._id).indexOf(_);
845
+ return { _id: _, oldParent: w, oldPosition: S };
846
+ }), B = A.find(({ _id: _ }) => _ === x[0]);
847
+ B && B.oldParent === k && B.oldPosition === b || (i(x, k, b), o({
848
+ undo: () => each(A, ({ _id: _, oldParent: N, oldPosition: w }) => {
849
+ i([_], N, w);
850
850
  }),
851
- redo: () => i(f, y, b)
851
+ redo: () => i(x, k, b)
852
852
  }));
853
853
  },
854
- addBlocks: (f, y, b) => {
855
- a(f, y, b), o({
856
- undo: () => l(map(f, "_id")),
857
- redo: () => a(f, y, b)
854
+ addBlocks: (x, k, b) => {
855
+ a(x, k, b), o({
856
+ undo: () => l(map(x, "_id")),
857
+ redo: () => a(x, k, b)
858
858
  });
859
859
  },
860
- removeBlocks: (f) => {
861
- var E;
862
- const y = (E = first(f)) == null ? void 0 : E._parent, B = r.filter((A) => y ? A._parent === y : !A._parent).indexOf(first(f));
863
- l(map(f, "_id")), o({
864
- undo: () => a(f, y, B),
865
- redo: () => l(map(f, "_id"))
860
+ removeBlocks: (x) => {
861
+ var B;
862
+ const k = (B = first(x)) == null ? void 0 : B._parent, A = r.filter((_) => k ? _._parent === k : !_._parent).indexOf(first(x));
863
+ l(map(x, "_id")), o({
864
+ undo: () => a(x, k, A),
865
+ redo: () => l(map(x, "_id"))
866
866
  });
867
867
  },
868
- updateBlocks: (f, y, b) => {
869
- let B = [];
868
+ updateBlocks: (x, k, b) => {
869
+ let A = [];
870
870
  if (b)
871
- B = map(f, (E) => ({ _id: E, ...b }));
871
+ A = map(x, (B) => ({ _id: B, ...b }));
872
872
  else {
873
- const E = keys(y);
874
- B = map(f, (A) => {
875
- const j = r.find((C) => C._id === A), w = { _id: A };
876
- return each(E, (C) => w[C] = j[C]), w;
873
+ const B = keys(k);
874
+ A = map(x, (_) => {
875
+ const N = r.find((y) => y._id === _), w = { _id: _ };
876
+ return each(B, (y) => w[y] = N[y]), w;
877
877
  });
878
878
  }
879
- c(map(f, (E) => ({ _id: E, ...y }))), o({
880
- undo: () => c(B),
881
- redo: () => c(map(f, (E) => ({ _id: E, ...y })))
879
+ c(map(x, (B) => ({ _id: B, ...k }))), o({
880
+ undo: () => c(A),
881
+ redo: () => c(map(x, (B) => ({ _id: B, ...k })))
882
882
  });
883
883
  },
884
- updateBlocksRuntime: (f, y) => {
885
- c(map(f, (b) => ({ _id: b, ...y })));
884
+ updateBlocksRuntime: (x, k) => {
885
+ c(map(x, (b) => ({ _id: b, ...k })));
886
886
  },
887
- setNewBlocks: (f) => {
888
- n(f), o({
887
+ setNewBlocks: (x) => {
888
+ n(x), o({
889
889
  undo: () => n(r),
890
- redo: () => n(f)
890
+ redo: () => n(x)
891
891
  });
892
892
  },
893
- updateMultipleBlocksProps: (f) => {
894
- let y = [];
895
- y = map(f, (b) => {
896
- const B = keys(b), E = r.find((j) => j._id === b._id), A = {};
897
- return each(B, (j) => A[j] = E[j]), A;
898
- }), c(f), o({
899
- undo: () => c(y),
900
- redo: () => c(f)
893
+ updateMultipleBlocksProps: (x) => {
894
+ let k = [];
895
+ k = map(x, (b) => {
896
+ const A = keys(b), B = r.find((N) => N._id === b._id), _ = {};
897
+ return each(A, (N) => _[N] = B[N]), _;
898
+ }), c(x), o({
899
+ undo: () => c(k),
900
+ redo: () => c(x)
901
901
  });
902
902
  }
903
903
  };
@@ -905,12 +905,12 @@ const undoRedoStateAtom = atom({
905
905
  const [o] = useBlocksStore(), [, r] = useSelectedBlockIds(), { addBlocks: n } = useBlocksStoreUndoableActions(), a = useCallback(
906
906
  (i, c, d) => {
907
907
  var m;
908
- for (let x = 0; x < i.length; x++) {
909
- const { _id: f } = i[x];
910
- i[x]._id = generateUUID();
911
- const y = filter(i, { _parent: f });
912
- for (let b = 0; b < y.length; b++)
913
- y[b]._parent = i[x]._id;
908
+ for (let f = 0; f < i.length; f++) {
909
+ const { _id: x } = i[f];
910
+ i[f]._id = generateUUID();
911
+ const k = filter(i, { _parent: x });
912
+ for (let b = 0; b < k.length; b++)
913
+ k[b]._parent = i[f]._id;
914
914
  }
915
915
  const p = first(i);
916
916
  let u, g;
@@ -921,8 +921,8 @@ const undoRedoStateAtom = atom({
921
921
  return { addCoreBlock: useCallback(
922
922
  (i, c, d) => {
923
923
  if (has(i, "blocks")) {
924
- const y = i.blocks;
925
- return a(y, c, d);
924
+ const k = i.blocks;
925
+ return a(k, c, d);
926
926
  }
927
927
  const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
928
928
  _type: i.type,
@@ -1821,8 +1821,8 @@ const undoRedoStateAtom = atom({
1821
1821
  regExp: "delay-(\\d+|\\[.*\\])"
1822
1822
  },
1823
1823
  animation: {
1824
- classes: ["animation-none", "animation-spin", "animation-ping"],
1825
- regExp: "animation-(none|spin|ping)"
1824
+ classes: ["animate-none", "animate-spin", "animate-ping"],
1825
+ regExp: "animate-(none|spin|ping)"
1826
1826
  },
1827
1827
  scaleX: {
1828
1828
  classes: map(CLASS_VALUES.scale, (o) => `scale-x-${o}`),
@@ -2360,43 +2360,43 @@ const getBlockWithChildren = (o, r) => {
2360
2360
  return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
2361
2361
  })
2362
2362
  ), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2363
- const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m, x) => {
2364
- const f = cloneDeep(x.find((y) => y._id === m));
2365
- for (const y in f) {
2366
- const b = f[y];
2363
+ const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m, f) => {
2364
+ const x = cloneDeep(f.find((k) => k._id === m));
2365
+ for (const k in x) {
2366
+ const b = x[k];
2367
2367
  if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
2368
- const { baseClasses: B, classes: E } = getSplitChaiClasses(b);
2369
- f[y] = compact(flattenDeep([B, E])).join(" ");
2368
+ const { baseClasses: A, classes: B } = getSplitChaiClasses(b);
2369
+ x[k] = compact(flattenDeep([A, B])).join(" ");
2370
2370
  } else
2371
- y !== "_id" && delete f[y];
2371
+ k !== "_id" && delete x[k];
2372
2372
  }
2373
- return f;
2373
+ return x;
2374
2374
  };
2375
2375
  return {
2376
2376
  askAi: useCallback(
2377
- async (m, x, f, y) => {
2377
+ async (m, f, x, k) => {
2378
2378
  if (l) {
2379
2379
  r(!0), a(null);
2380
2380
  try {
2381
- const b = p === u ? "" : p, B = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p) : [h(x, d)], E = await l(m, addLangToPrompt(f, g, m), B, b), { blocks: A, error: j } = E;
2382
- if (j) {
2383
- a(j);
2381
+ const b = p === u ? "" : p, A = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [h(f, d)], B = await l(m, addLangToPrompt(x, g, m), A, b), { blocks: _, error: N } = B;
2382
+ if (N) {
2383
+ a(N);
2384
2384
  return;
2385
2385
  }
2386
2386
  if (m === "styles") {
2387
- const w = A.map((C) => {
2388
- for (const v in C)
2389
- v !== "_id" && (C[v] = `${STYLES_KEY},${C[v]}`);
2390
- return C;
2387
+ const w = _.map((y) => {
2388
+ for (const S in y)
2389
+ S !== "_id" && (y[S] = `${STYLES_KEY},${y[S]}`);
2390
+ return y;
2391
2391
  });
2392
2392
  c(w);
2393
2393
  } else
2394
- i(A);
2395
- y && y(E);
2394
+ i(_);
2395
+ k && k(B);
2396
2396
  } catch (b) {
2397
2397
  a(b);
2398
2398
  } finally {
2399
- r(!1), y && y();
2399
+ r(!1), k && k();
2400
2400
  }
2401
2401
  }
2402
2402
  },
@@ -2490,12 +2490,12 @@ const getBlockWithChildren = (o, r) => {
2490
2490
  if (!p)
2491
2491
  return h;
2492
2492
  let m = [];
2493
- for (const x of h)
2494
- if (x._type === "PartialBlock" || x._type === "GlobalBlock") {
2495
- let f = l(x.partialBlockId);
2496
- x._parent && (f == null ? void 0 : f.length) > 0 && (f = f.map((y) => (isEmpty(y._parent) && set(y, "_parent", x._parent), y))), m = [...m, ...f];
2493
+ for (const f of h)
2494
+ if (f._type === "PartialBlock" || f._type === "GlobalBlock") {
2495
+ let x = l(f.partialBlockId);
2496
+ f._parent && (x == null ? void 0 : x.length) > 0 && (x = x.map((k) => (isEmpty(k._parent) && set(k, "_parent", f._parent), k))), m = [...m, ...x];
2497
2497
  } else
2498
- m.push(x);
2498
+ m.push(f);
2499
2499
  return m;
2500
2500
  })
2501
2501
  };
@@ -2678,13 +2678,13 @@ const getBlockWithChildren = (o, r) => {
2678
2678
  const d = o(c), p = a;
2679
2679
  let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
2680
2680
  return each(p, (h) => {
2681
- const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
2682
- u = u.replace(x, " ").replace(/\s+/g, " ").trim();
2683
- const f = first(h.split(":"));
2684
- includes(["2xl", "xl", "lg", "md", "sm"], f) && p.push(h.split(":").pop().trim());
2681
+ const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
2682
+ u = u.replace(f, " ").replace(/\s+/g, " ").trim();
2683
+ const x = first(h.split(":"));
2684
+ includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(h.split(":").pop().trim());
2685
2685
  }), each(p, (h) => {
2686
- const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
2687
- g = g.replace(x, " ").replace(/\s+/g, " ").trim();
2686
+ const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
2687
+ g = g.replace(f, " ").replace(/\s+/g, " ").trim();
2688
2688
  }), {
2689
2689
  ids: [d._id],
2690
2690
  props: {
@@ -2833,21 +2833,21 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2833
2833
  return "VERTICAL";
2834
2834
  }
2835
2835
  }, isDisabledControl = (o, r, n) => !!(o && (n === "UP" || n === "LEFT") || r && (n === "DOWN" || n === "RIGHT")), useBlockController = (o, r) => {
2836
- const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(n, (f) => c ? get(f, "_parent") === c : !get(f, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, h = u + 1 === (d == null ? void 0 : d.length), m = getParentBlockOrientation(c, i, a), x = useCallback(
2837
- (f) => {
2838
- isDisabledControl(g, h, f) || p || (f === "UP" || f === "LEFT" ? l([i], c || null, u - 1) : (f === "DOWN" || f === "RIGHT") && l([i], c || null, u + 2), r());
2836
+ const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(n, (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, h = u + 1 === (d == null ? void 0 : d.length), m = getParentBlockOrientation(c, i, a), f = useCallback(
2837
+ (x) => {
2838
+ isDisabledControl(g, h, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), r());
2839
2839
  },
2840
2840
  [g, h, p, u, i, c, r]
2841
2841
  );
2842
2842
  return useHotkeys(
2843
2843
  "shift+up, shift+down, shift+left, shift+right",
2844
- ({ key: f }) => {
2845
- var y;
2846
- x((y = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : y.toUpperCase());
2844
+ ({ key: x }) => {
2845
+ var k;
2846
+ f((k = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : k.toUpperCase());
2847
2847
  },
2848
2848
  { document: a == null ? void 0 : a.contentDocument },
2849
- [x]
2850
- ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: x, orientation: m };
2849
+ [f]
2850
+ ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: f, orientation: m };
2851
2851
  }, BlockController = ({ block: o, updateFloatingBar: r }) => {
2852
2852
  const { isOnlyChild: n, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
2853
2853
  o,
@@ -2989,37 +2989,65 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
2989
2989
  }, BlockFloatingSelector = ({ block: o, selectedBlockElement: r }) => {
2990
2990
  const n = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: u } = useFrame(), { floatingStyles: g, refs: h, update: m } = useFloating({
2991
2991
  placement: "top-start",
2992
- middleware: [shift(), flip()],
2992
+ middleware: [
2993
+ shift({
2994
+ boundary: u == null ? void 0 : u.body,
2995
+ limiter: limitShift({
2996
+ offset: 8,
2997
+ mainAxis: !0,
2998
+ crossAxis: !0
2999
+ })
3000
+ }),
3001
+ flip({
3002
+ boundary: u == null ? void 0 : u.body,
3003
+ fallbackPlacements: ["bottom-start", "top-end", "bottom-end", "inside"]
3004
+ }),
3005
+ size({
3006
+ boundary: u == null ? void 0 : u.body,
3007
+ apply({ availableWidth: k, availableHeight: b, elements: A }) {
3008
+ Object.assign(A.floating.style, {
3009
+ maxWidth: `${Math.max(200, k)}px`,
3010
+ maxHeight: `${Math.max(100, b)}px`
3011
+ });
3012
+ }
3013
+ })
3014
+ ],
2993
3015
  elements: { reference: r }
2994
3016
  });
2995
3017
  useResizeObserver(r, () => m(), r !== null), useResizeObserver(u == null ? void 0 : u.body, () => m(), (u == null ? void 0 : u.body) !== null);
2996
- const x = get(o, "_parent", null), f = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
2997
- return !r || !o || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
3018
+ const f = get(o, "_parent", null), x = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
3019
+ return useEffect(() => {
3020
+ if (r) {
3021
+ const k = setTimeout(() => m(), 500);
3022
+ return () => clearTimeout(k);
3023
+ } else
3024
+ m();
3025
+ }, [r]), !r || !o || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
2998
3026
  "div",
2999
3027
  {
3000
3028
  role: "button",
3001
3029
  tabIndex: 0,
3002
3030
  ref: h.setFloating,
3003
3031
  style: g,
3004
- onClick: (y) => {
3005
- y.stopPropagation(), y.preventDefault();
3032
+ onClick: (k) => {
3033
+ k.stopPropagation(), k.preventDefault();
3006
3034
  },
3007
- onMouseEnter: (y) => {
3008
- y.stopPropagation(), i(null);
3035
+ onMouseEnter: (k) => {
3036
+ k.stopPropagation(), i(null);
3009
3037
  },
3010
- onKeyDown: (y) => y.stopPropagation(),
3038
+ onKeyDown: (k) => k.stopPropagation(),
3011
3039
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3012
3040
  children: [
3013
- x && /* @__PURE__ */ jsx(
3041
+ f && /* @__PURE__ */ jsx(
3014
3042
  ArrowUpIcon,
3015
3043
  {
3016
3044
  className: "hover:scale-105",
3017
3045
  onClick: () => {
3018
- c([]), l([x]);
3046
+ c([]), l([f]);
3019
3047
  }
3020
3048
  }
3021
3049
  ),
3022
- /* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: o }),
3050
+ /* @__PURE__ */ jsx(BlockActionLabel, { label: x, block: o }),
3023
3051
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
3024
3052
  /* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
3025
3053
  canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([o == null ? void 0 : o._id]) }) : null,
@@ -3177,8 +3205,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3177
3205
  i
3178
3206
  ]), useHotkeys(
3179
3207
  "del, backspace",
3180
- (x) => {
3181
- x.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
3208
+ (f) => {
3209
+ f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
3182
3210
  },
3183
3211
  m,
3184
3212
  [r, l]
@@ -3471,8 +3499,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3471
3499
  ],
3472
3500
  onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
3473
3501
  onBlur: ({ editor: u, event: g }) => {
3474
- const h = g.relatedTarget, m = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = m == null ? void 0 : m.contains(h), y = x == null ? void 0 : x.contains(h);
3475
- if (!f && !y) {
3502
+ const h = g.relatedTarget, m = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = m == null ? void 0 : m.contains(h), k = f == null ? void 0 : f.contains(h);
3503
+ if (!x && !k) {
3476
3504
  const b = (u == null ? void 0 : u.getHTML()) || "";
3477
3505
  n(b);
3478
3506
  }
@@ -3527,14 +3555,14 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3527
3555
  useEffect(() => {
3528
3556
  if (a.current) {
3529
3557
  a.current.innerText = r, a.current.focus();
3530
- const m = c.createRange(), x = d.getSelection();
3531
- m.selectNodeContents(a.current), m.collapse(!1), x == null || x.removeAllRanges(), x == null || x.addRange(m), a.current.focus();
3558
+ const m = c.createRange(), f = d.getSelection();
3559
+ m.selectNodeContents(a.current), m.collapse(!1), f == null || f.removeAllRanges(), f == null || f.addRange(m), a.current.focus();
3532
3560
  } else
3533
3561
  n();
3534
3562
  }, [c, d]);
3535
3563
  const p = useMemo(() => {
3536
- var x;
3537
- const m = ((x = o == null ? void 0 : o.tagName) == null ? void 0 : x.toLowerCase()) || "div";
3564
+ var f;
3565
+ const m = ((f = o == null ? void 0 : o.tagName) == null ? void 0 : f.toLowerCase()) || "div";
3538
3566
  return m === "button" ? "div" : m;
3539
3567
  }, [o]), u = useCallback(
3540
3568
  (m) => {
@@ -3550,12 +3578,12 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3550
3578
  contentEditable: !0,
3551
3579
  className: `${((m = o == null ? void 0 : o.className) == null ? void 0 : m.replace("sr-only", "")) || ""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,
3552
3580
  style: cloneDeep(o == null ? void 0 : o.style) || {},
3553
- onInput: (x) => {
3554
- const f = x.target;
3555
- f && (f.innerText.trim() === "" ? (f.setAttribute("data-placeholder", "Enter text here"), f.children.length > 0 && f.children[0].remove()) : x.target.removeAttribute("data-placeholder"), l(x.target.innerText));
3581
+ onInput: (f) => {
3582
+ const x = f.target;
3583
+ x && (x.innerText.trim() === "" ? (x.setAttribute("data-placeholder", "Enter text here"), x.children.length > 0 && x.children[0].remove()) : f.target.removeAttribute("data-placeholder"), l(f.target.innerText));
3556
3584
  },
3557
- onClick: (x) => {
3558
- x.stopPropagation(), x.preventDefault();
3585
+ onClick: (f) => {
3586
+ f.stopPropagation(), f.preventDefault();
3559
3587
  }
3560
3588
  };
3561
3589
  }, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
@@ -3568,62 +3596,62 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3568
3596
  }
3569
3597
  ), WithBlockTextEditor = memo(
3570
3598
  ({ block: o, children: r }) => {
3571
- const n = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: x } = useLanguages(), [, f] = useSelectedBlockIds(), y = useRef(null), b = l, { blockContent: B, blockType: E } = useMemo(() => {
3572
- var _;
3573
- const v = o._type;
3574
- let N = o[n];
3575
- const S = getRegisteredChaiBlock(o._type);
3576
- return x && ((_ = S == null ? void 0 : S.i18nProps) == null ? void 0 : _.includes(n)) && has(o, `${n}-${x}`) && (N = get(o, `${n}-${x}`)), { blockContent: N, blockType: v };
3577
- }, [o, x]), A = useCallback(
3578
- (v) => {
3579
- var S;
3580
- const N = v || ((S = g.current) == null ? void 0 : S.innerText);
3581
- m([b], { [n]: N }), u(null), c(null), d(-1), f([]);
3599
+ const n = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: f } = useLanguages(), [, x] = useSelectedBlockIds(), k = useRef(null), b = l, { blockContent: A, blockType: B } = useMemo(() => {
3600
+ var j;
3601
+ const S = o._type;
3602
+ let E = o[n];
3603
+ const v = getRegisteredChaiBlock(o._type);
3604
+ return f && ((j = v == null ? void 0 : v.i18nProps) == null ? void 0 : j.includes(n)) && has(o, `${n}-${f}`) && (E = get(o, `${n}-${f}`)), { blockContent: E, blockType: S };
3605
+ }, [o, f]), _ = useCallback(
3606
+ (S) => {
3607
+ var v;
3608
+ const E = S || ((v = g.current) == null ? void 0 : v.innerText);
3609
+ m([b], { [n]: E }), u(null), c(null), d(-1), x([]);
3582
3610
  },
3583
- [b, m, c, f, x]
3584
- ), j = useDebouncedCallback(
3585
- (v) => {
3586
- m([b], { [n]: v });
3611
+ [b, m, c, x, f]
3612
+ ), N = useDebouncedCallback(
3613
+ (S) => {
3614
+ m([b], { [n]: S });
3587
3615
  },
3588
- [b, o, m, x],
3616
+ [b, o, m, f],
3589
3617
  1e3
3590
3618
  ), w = useCallback(
3591
- (v) => {
3592
- v.preventDefault(), b && (y.current = b), A(), setTimeout(() => {
3593
- const N = y.current;
3594
- y.current = null, f([N]);
3619
+ (S) => {
3620
+ S.preventDefault(), b && (k.current = b), _(), setTimeout(() => {
3621
+ const E = k.current;
3622
+ k.current = null, x([E]);
3595
3623
  }, 100);
3596
3624
  },
3597
- [f, b, x]
3625
+ [x, b, f]
3598
3626
  );
3599
3627
  useEffect(() => {
3600
- var k;
3628
+ var C;
3601
3629
  if (!b) return;
3602
- const v = `[data-block-id="${b}"]`, N = i >= 0 ? `[data-block-index="${i}"]` : "", S = a.querySelector(`${v}${N}`);
3603
- S && ((k = S == null ? void 0 : S.classList) == null || k.add("sr-only"), u(S));
3604
- }, [b, E, a, i]);
3605
- const C = useMemo(() => p ? (h(), E === "RichText" ? /* @__PURE__ */ jsx(
3630
+ const S = `[data-block-id="${b}"]`, E = i >= 0 ? `[data-block-index="${i}"]` : "", v = a.querySelector(`${S}${E}`);
3631
+ v && ((C = v == null ? void 0 : v.classList) == null || C.add("sr-only"), u(v));
3632
+ }, [b, B, a, i]);
3633
+ const y = useMemo(() => p ? (h(), B === "RichText" ? /* @__PURE__ */ jsx(
3606
3634
  RichTextEditor,
3607
3635
  {
3608
- blockContent: B,
3636
+ blockContent: A,
3609
3637
  editingElement: p,
3610
- onChange: j,
3611
- onClose: A,
3638
+ onChange: N,
3639
+ onClose: _,
3612
3640
  onEscape: w
3613
3641
  }
3614
3642
  ) : /* @__PURE__ */ jsx(
3615
3643
  MemoizedEditor,
3616
3644
  {
3617
3645
  editorRef: g,
3618
- blockContent: B,
3646
+ blockContent: A,
3619
3647
  editingElement: p,
3620
- onClose: A,
3621
- onChange: j,
3648
+ onClose: _,
3649
+ onChange: N,
3622
3650
  onEscape: w
3623
3651
  }
3624
- )) : null, [p, b, E, B, A, x]);
3652
+ )) : null, [p, b, B, A, _, f]);
3625
3653
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3626
- C,
3654
+ y,
3627
3655
  r
3628
3656
  ] });
3629
3657
  },
@@ -3656,23 +3684,23 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3656
3684
  blockAtom: r,
3657
3685
  children: n
3658
3686
  }) => {
3659
- const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(r), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom), x = get(c, "component", null), { index: f, key: y } = useContext(RepeaterContext), b = useMemo(
3687
+ const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(r), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom), f = get(c, "component", null), { index: x, key: k } = useContext(RepeaterContext), b = useMemo(
3660
3688
  () => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
3661
- index: f,
3662
- key: y
3689
+ index: x,
3690
+ key: k
3663
3691
  }) : applyLanguage(i, d, c),
3664
- [i, d, c, g, m, f, y]
3665
- ), B = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), E = useMemo(
3692
+ [i, d, c, g, m, x, k]
3693
+ ), A = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), B = useMemo(
3666
3694
  () => u(i._id, getBlockRuntimeProps(i._type)),
3667
3695
  [i._id, i._type, u, getBlockRuntimeProps]
3668
- ), A = useMemo(
3696
+ ), _ = useMemo(
3669
3697
  () => ({
3670
- blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": f },
3698
+ blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": x },
3671
3699
  inBuilder: !0,
3672
3700
  lang: d || p,
3673
3701
  ...b,
3702
+ ...A,
3674
3703
  ...B,
3675
- ...E,
3676
3704
  ...o
3677
3705
  }),
3678
3706
  [
@@ -3681,14 +3709,14 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3681
3709
  d,
3682
3710
  p,
3683
3711
  b,
3712
+ A,
3684
3713
  B,
3685
- E,
3686
3714
  o
3687
3715
  ]
3688
- ), j = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]);
3689
- if (isNull(x) || h.includes(i._id)) return null;
3690
- let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(x, {
3691
- ...A,
3716
+ ), N = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]);
3717
+ if (isNull(f) || h.includes(i._id)) return null;
3718
+ let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(f, {
3719
+ ..._,
3692
3720
  children: n({
3693
3721
  _id: i._id,
3694
3722
  _type: i._type,
@@ -3700,8 +3728,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3700
3728
  ...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
3701
3729
  })
3702
3730
  }) });
3703
- const C = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: w }) : w;
3704
- return j ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: C }) : C;
3731
+ const y = a === i._id && (l === x || x < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: w }) : w;
3732
+ return N ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: y }) : y;
3705
3733
  }, PartialWrapper = ({ children: o, partialBlockId: r }) => {
3706
3734
  const n = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
3707
3735
  (d) => {
@@ -3741,7 +3769,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3741
3769
  );
3742
3770
  return map(l, (c) => {
3743
3771
  const d = a(c._id);
3744
- return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: h, repeaterItems: m, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(m) && m.map((f, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) }, `${u}-${y}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3772
+ return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: h, repeaterItems: m, $repeaterItemsKey: f }) => g === "Repeater" ? isArray(m) && m.map((x, k) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: k, key: f }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) }, `${u}-${k}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3745
3773
  });
3746
3774
  }, PageBlocksRenderer = () => {
3747
3775
  const [o] = useBlocksStore();
@@ -3809,14 +3837,14 @@ const CanvasEventsWatcher = () => {
3809
3837
  }, StaticCanvas = () => {
3810
3838
  const [o] = useCanvasDisplayWidth(), [, r] = useHighlightBlockId(), n = 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(
3811
3839
  (m) => {
3812
- i((x) => ({ ...x, width: m }));
3840
+ i((f) => ({ ...f, width: m }));
3813
3841
  },
3814
3842
  [i]
3815
3843
  );
3816
3844
  useEffect(() => {
3817
3845
  if (!a.current) return;
3818
- const { clientWidth: m, clientHeight: x } = a.current;
3819
- i({ width: m, height: x });
3846
+ const { clientWidth: m, clientHeight: f } = a.current;
3847
+ i({ width: m, height: f });
3820
3848
  }, [a, o]);
3821
3849
  const h = useMemo(() => {
3822
3850
  let m = IframeInitialContent;
@@ -3931,8 +3959,8 @@ const CanvasEventsWatcher = () => {
3931
3959
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
3932
3960
  ] });
3933
3961
  }, DefaultMediaManager = ({ close: o, onSelect: r, mode: n = "image" }) => {
3934
- const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (x) => {
3935
- if (!x.trim()) {
3962
+ const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (f) => {
3963
+ if (!f.trim()) {
3936
3964
  p(!1), g("Please enter a URL");
3937
3965
  return;
3938
3966
  }
@@ -3956,7 +3984,7 @@ const CanvasEventsWatcher = () => {
3956
3984
  {
3957
3985
  placeholder: m(`Enter ${n} URL`),
3958
3986
  value: a,
3959
- onChange: (x) => l(x.target.value),
3987
+ onChange: (f) => l(f.target.value),
3960
3988
  onKeyUp: () => h(a)
3961
3989
  }
3962
3990
  ),
@@ -3997,16 +4025,16 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
3997
4025
  const h = isArray(g) ? first(g) : g;
3998
4026
  if (h) {
3999
4027
  r(h == null ? void 0 : h.url);
4000
- const m = h == null ? void 0 : h.width, x = h == null ? void 0 : h.height;
4028
+ const m = h == null ? void 0 : h.width, f = h == null ? void 0 : h.height;
4001
4029
  if (i != null && i._id) {
4002
- const f = {
4030
+ const x = {
4003
4031
  ...m && { width: m },
4004
- ...x && { height: x },
4032
+ ...f && { height: f },
4005
4033
  ...h.description && { alt: h.description },
4006
4034
  ...h.id && { assetId: h.id }
4007
4035
  };
4008
- if (isEmpty(f)) return;
4009
- c([i._id], f);
4036
+ if (isEmpty(x)) return;
4037
+ c([i._id], x);
4010
4038
  }
4011
4039
  }
4012
4040
  }, p = useCallback(() => {
@@ -4050,14 +4078,14 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
4050
4078
  }, PathDropdown = ({ data: o, onSelect: r, dataType: n }) => {
4051
4079
  const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", p = React__default.useCallback(
4052
4080
  (h) => {
4053
- const m = (x) => n === "value" ? x === "value" || x === "object" : n === "array" ? x === "array" : x === n;
4054
- h.type === "object" ? (l((x) => [...x, h.key]), c(h.value)) : m(h.type) && r([...a, h.key].join("."), n);
4081
+ const m = (f) => n === "value" ? f === "value" || f === "object" : n === "array" ? f === "array" : f === n;
4082
+ h.type === "object" ? (l((f) => [...f, h.key]), c(h.value)) : m(h.type) && r([...a, h.key].join("."), n);
4055
4083
  },
4056
4084
  [a, r, n]
4057
4085
  ), u = React__default.useCallback(() => {
4058
4086
  if (a.length > 0) {
4059
4087
  const h = a.slice(0, -1);
4060
- l(h), c(h.reduce((m, x) => m[x], o));
4088
+ l(h), c(h.reduce((m, f) => m[f], o));
4061
4089
  }
4062
4090
  }, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([h, m]) => ({ key: h, value: m, type: d(m) })).filter((h) => !startsWith(h.key, REPEATER_PREFIX) && h.key.includes("/") ? !1 : n === "value" ? h.type === "value" || h.type === "object" : n === "array" ? h.type === "array" || h.type === "object" : n === "object" ? h.type === "object" : !0) : [], [i, n]);
4063
4091
  return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
@@ -4150,7 +4178,7 @@ const DataBindingSelector = ({
4150
4178
  }) => {
4151
4179
  const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
4152
4180
  if (i.length === 1) return "";
4153
- const g = i.find((x) => x._type === "Repeater"), m = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
4181
+ const g = i.find((f) => f._type === "Repeater"), m = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
4154
4182
  return `${REPEATER_PREFIX}${startsWith(m, COLLECTION_PREFIX) ? `${m}/${g._id}` : m}`;
4155
4183
  }, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
4156
4184
  (g, h) => {
@@ -4158,44 +4186,44 @@ const DataBindingSelector = ({
4158
4186
  r(`{{${g}}}`, {}, n);
4159
4187
  return;
4160
4188
  }
4161
- const m = (b) => /[.,!?;:]/.test(b), x = (b, B, E) => {
4162
- let A = "", j = "";
4163
- const w = B > 0 ? b[B - 1] : "", C = B < b.length ? b[B] : "";
4164
- return B > 0 && (w === "." || !m(w) && w !== " ") && (A = " "), B < b.length && !m(C) && C !== " " && (j = " "), {
4165
- text: A + E + j,
4166
- prefixLength: A.length,
4167
- suffixLength: j.length
4189
+ const m = (b) => /[.,!?;:]/.test(b), f = (b, A, B) => {
4190
+ let _ = "", N = "";
4191
+ const w = A > 0 ? b[A - 1] : "", y = A < b.length ? b[A] : "";
4192
+ return A > 0 && (w === "." || !m(w) && w !== " ") && (_ = " "), A < b.length && !m(y) && y !== " " && (N = " "), {
4193
+ text: _ + B + N,
4194
+ prefixLength: _.length,
4195
+ suffixLength: N.length
4168
4196
  };
4169
- }, f = document.getElementById(n);
4170
- if (!f) return;
4171
- const y = document.getElementById(`chai-rte-${n}`) || document.getElementById(`chai-rte-modal-${n}`);
4172
- if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
4173
- const b = y.__chaiRTE;
4197
+ }, x = document.getElementById(n);
4198
+ if (!x) return;
4199
+ const k = document.getElementById(`chai-rte-${n}`) || document.getElementById(`chai-rte-modal-${n}`);
4200
+ if (k && (k.querySelector(".ProseMirror") || k.__chaiRTE)) {
4201
+ const b = k.__chaiRTE;
4174
4202
  if (b) {
4175
- const B = `{{${g}}}`;
4203
+ const A = `{{${g}}}`;
4176
4204
  b.commands.focus();
4177
- const { from: E, to: A } = b.state.selection;
4178
- if (E !== A)
4179
- b.chain().deleteSelection().insertContent(B).run();
4205
+ const { from: B, to: _ } = b.state.selection;
4206
+ if (B !== _)
4207
+ b.chain().deleteSelection().insertContent(A).run();
4180
4208
  else {
4181
- const { state: w } = b, C = w.selection.from, v = w.doc.textBetween(Math.max(0, C - 1), C), N = w.doc.textBetween(C, Math.min(C + 1, w.doc.content.size));
4182
- let S = "";
4183
- C > 0 && v !== " " && !m(v) && (S = " ");
4184
- let k = "";
4185
- N && N !== " " && !m(N) && (k = " "), b.chain().insertContent(S + B + k).run();
4209
+ const { state: w } = b, y = w.selection.from, S = w.doc.textBetween(Math.max(0, y - 1), y), E = w.doc.textBetween(y, Math.min(y + 1, w.doc.content.size));
4210
+ let v = "";
4211
+ y > 0 && S !== " " && !m(S) && (v = " ");
4212
+ let C = "";
4213
+ E && E !== " " && !m(E) && (C = " "), b.chain().insertContent(v + A + C).run();
4186
4214
  }
4187
4215
  setTimeout(() => r(b.getHTML(), {}, n), 100);
4188
4216
  return;
4189
4217
  }
4190
4218
  } else {
4191
- const b = f, B = b.selectionStart || 0, E = b.value || "", A = b.selectionEnd || B;
4192
- if (A > B) {
4193
- const N = `{{${g}}}`, { text: S } = x(E, B, N), k = E.slice(0, B) + S + E.slice(A);
4194
- r(k, {}, n);
4219
+ const b = x, A = b.selectionStart || 0, B = b.value || "", _ = b.selectionEnd || A;
4220
+ if (_ > A) {
4221
+ const E = `{{${g}}}`, { text: v } = f(B, A, E), C = B.slice(0, A) + v + B.slice(_);
4222
+ r(C, {}, n);
4195
4223
  return;
4196
4224
  }
4197
- const w = `{{${g}}}`, { text: C } = x(E, B, w), v = E.slice(0, B) + C + E.slice(B);
4198
- r(v, {}, n);
4225
+ const w = `{{${g}}}`, { text: y } = f(B, A, w), S = B.slice(0, A) + y + B.slice(A);
4226
+ r(S, {}, n);
4199
4227
  }
4200
4228
  },
4201
4229
  [n, r, a, c == null ? void 0 : c._id, d]
@@ -4216,99 +4244,99 @@ const DataBindingSelector = ({
4216
4244
  pageTypes: r,
4217
4245
  onChange: n
4218
4246
  }) => {
4219
- var N;
4220
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (S, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [x, f] = useState([]), [y, b] = useState(-1), B = useRef(null), E = (N = r == null ? void 0 : r.find((S) => S.key === u)) == null ? void 0 : N.name;
4247
+ var E;
4248
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, C) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [f, x] = useState([]), [k, b] = useState(-1), A = useRef(null), B = (E = r == null ? void 0 : r.find((v) => v.key === u)) == null ? void 0 : E.name;
4221
4249
  useEffect(() => {
4222
- if (m(""), f([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4223
- const S = split(o, ":"), k = get(S, 1, "page") || "page";
4224
- g(k), (async () => {
4225
- const _ = await l(k, [get(S, 2, "page")]);
4226
- _ && Array.isArray(_) && m(get(_, [0, "name"], ""));
4250
+ if (m(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4251
+ const v = split(o, ":"), C = get(v, 1, "page") || "page";
4252
+ g(C), (async () => {
4253
+ const j = await l(C, [get(v, 2, "page")]);
4254
+ j && Array.isArray(j) && m(get(j, [0, "name"], ""));
4227
4255
  })();
4228
4256
  }, [o]);
4229
- const A = useDebouncedCallback(
4230
- async (S) => {
4231
- if (isEmpty(S))
4232
- f([]);
4257
+ const _ = useDebouncedCallback(
4258
+ async (v) => {
4259
+ if (isEmpty(v))
4260
+ x([]);
4233
4261
  else {
4234
- const k = await l(u, S);
4235
- f(k);
4262
+ const C = await l(u, v);
4263
+ x(C);
4236
4264
  }
4237
4265
  c(!1), b(-1);
4238
4266
  },
4239
4267
  [u],
4240
4268
  300
4241
- ), j = (S) => {
4242
- const k = ["pageType", u, S.id];
4243
- k[1] && (n(k.join(":")), m(S.name), p(!1), f([]), b(-1));
4244
- }, w = (S) => {
4245
- switch (S.key) {
4269
+ ), N = (v) => {
4270
+ const C = ["pageType", u, v.id];
4271
+ C[1] && (n(C.join(":")), m(v.name), p(!1), x([]), b(-1));
4272
+ }, w = (v) => {
4273
+ switch (v.key) {
4246
4274
  case "ArrowDown":
4247
- S.preventDefault(), b((k) => k < x.length - 1 ? k + 1 : k);
4275
+ v.preventDefault(), b((C) => C < f.length - 1 ? C + 1 : C);
4248
4276
  break;
4249
4277
  case "ArrowUp":
4250
- S.preventDefault(), b((k) => k > 0 ? k - 1 : k);
4278
+ v.preventDefault(), b((C) => C > 0 ? C - 1 : C);
4251
4279
  break;
4252
4280
  case "Enter":
4253
- if (S.preventDefault(), x.length === 0) return;
4254
- y >= 0 && j(x[y]);
4281
+ if (v.preventDefault(), f.length === 0) return;
4282
+ k >= 0 && N(f[k]);
4255
4283
  break;
4256
4284
  case "Escape":
4257
- S.preventDefault(), C();
4285
+ v.preventDefault(), y();
4258
4286
  break;
4259
4287
  }
4260
4288
  };
4261
4289
  useEffect(() => {
4262
- if (y >= 0 && B.current) {
4263
- const S = B.current.children[y];
4264
- S == null || S.scrollIntoView({ block: "nearest" });
4290
+ if (k >= 0 && A.current) {
4291
+ const v = A.current.children[k];
4292
+ v == null || v.scrollIntoView({ block: "nearest" });
4265
4293
  }
4266
- }, [y]);
4267
- const C = () => {
4268
- m(""), f([]), b(-1), p(!1), n("");
4269
- }, v = (S) => {
4270
- m(S), p(!isEmpty(S)), c(!0), A(S);
4294
+ }, [k]);
4295
+ const y = () => {
4296
+ m(""), x([]), b(-1), p(!1), n("");
4297
+ }, S = (v) => {
4298
+ m(v), p(!isEmpty(v)), c(!0), _(v);
4271
4299
  };
4272
4300
  return /* @__PURE__ */ jsxs("div", { children: [
4273
- /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (S) => g(S.target.value), children: map(r, (S) => /* @__PURE__ */ jsx("option", { value: S.key, children: S.name }, S.key)) }),
4301
+ /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (v) => g(v.target.value), children: map(r, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
4274
4302
  u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
4275
4303
  /* @__PURE__ */ jsx(
4276
4304
  "input",
4277
4305
  {
4278
4306
  type: "text",
4279
4307
  value: h,
4280
- onChange: (S) => v(S.target.value),
4308
+ onChange: (v) => S(v.target.value),
4281
4309
  onKeyDown: w,
4282
- placeholder: a(`Search ${E ?? ""}`),
4310
+ placeholder: a(`Search ${B ?? ""}`),
4283
4311
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4284
4312
  }
4285
4313
  ),
4286
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: C, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4314
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: y, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4287
4315
  ] }),
4288
- (i || !isEmpty(x) || d && isEmpty(x)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
4316
+ (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: [
4289
4317
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
4290
4318
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
4291
- ] }) : d && isEmpty(x) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4319
+ ] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4292
4320
  a("No results found for"),
4293
4321
  ' "',
4294
4322
  h,
4295
4323
  '"'
4296
- ] }) : /* @__PURE__ */ jsx("ul", { ref: B, children: map(x == null ? void 0 : x.slice(0, 20), (S, k) => /* @__PURE__ */ jsxs(
4324
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(f == null ? void 0 : f.slice(0, 20), (v, C) => /* @__PURE__ */ jsxs(
4297
4325
  "li",
4298
4326
  {
4299
- onClick: () => j(S),
4300
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(S.id) ? "bg-blue-200" : k === y ? "bg-gray-100" : "hover:bg-gray-100"}`,
4327
+ onClick: () => N(v),
4328
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : C === k ? "bg-gray-100" : "hover:bg-gray-100"}`,
4301
4329
  children: [
4302
- S.name,
4330
+ v.name,
4303
4331
  " ",
4304
- S.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4332
+ v.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4305
4333
  "( ",
4306
- S.slug,
4334
+ v.slug,
4307
4335
  " )"
4308
4336
  ] })
4309
4337
  ]
4310
4338
  },
4311
- S.id
4339
+ v.id
4312
4340
  )) }) })
4313
4341
  ] });
4314
4342
  }, LinkField = ({ schema: o, formData: r, onChange: n, name: a }) => {
@@ -4608,15 +4636,15 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4608
4636
  if (!u) return;
4609
4637
  const m = `{{${h}}}`;
4610
4638
  u.commands.focus();
4611
- const { from: x, to: f } = u.state.selection;
4612
- if (x !== f)
4639
+ const { from: f, to: x } = u.state.selection;
4640
+ if (f !== x)
4613
4641
  u.chain().deleteSelection().insertContent(m).run();
4614
4642
  else {
4615
- const { state: b } = u, B = b.selection.from, E = b.doc.textBetween(Math.max(0, B - 1), B), A = b.doc.textBetween(B, Math.min(B + 1, b.doc.content.size));
4616
- let j = "";
4617
- B > 0 && E !== " " && !/[.,!?;:]/.test(E) && (j = " ");
4643
+ const { state: b } = u, A = b.selection.from, B = b.doc.textBetween(Math.max(0, A - 1), A), _ = b.doc.textBetween(A, Math.min(A + 1, b.doc.content.size));
4644
+ let N = "";
4645
+ A > 0 && B !== " " && !/[.,!?;:]/.test(B) && (N = " ");
4618
4646
  let w = "";
4619
- A && A !== " " && !/[.,!?;:]/.test(A) && (w = " "), u.chain().insertContent(j + m + w).run();
4647
+ _ && _ !== " " && !/[.,!?;:]/.test(_) && (w = " "), u.chain().insertContent(N + m + w).run();
4620
4648
  }
4621
4649
  };
4622
4650
  return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (h) => !h && r(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
@@ -4655,13 +4683,13 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4655
4683
  })
4656
4684
  ],
4657
4685
  content: n || "",
4658
- onUpdate: ({ editor: x }) => {
4659
- const f = x.getHTML();
4660
- a(f), c || u(f);
4686
+ onUpdate: ({ editor: f }) => {
4687
+ const x = f.getHTML();
4688
+ a(x), c || u(x);
4661
4689
  },
4662
- onBlur: ({ editor: x }) => {
4663
- const f = x.getHTML();
4664
- l(o, f);
4690
+ onBlur: ({ editor: f }) => {
4691
+ const x = f.getHTML();
4692
+ l(o, x);
4665
4693
  },
4666
4694
  editorProps: {
4667
4695
  attributes: {
@@ -4674,8 +4702,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4674
4702
  }, [g]), useEffect(() => {
4675
4703
  u(n || "");
4676
4704
  }, [n]);
4677
- const h = (x) => {
4678
- a(x);
4705
+ const h = (f) => {
4706
+ a(f);
4679
4707
  }, m = () => {
4680
4708
  d(!1), g && g.commands.setContent(p);
4681
4709
  };
@@ -4708,25 +4736,25 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4708
4736
  u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && r({ ...o, currentSlide: get(u, "0._id") });
4709
4737
  }, [o, u]);
4710
4738
  const h = () => {
4711
- const f = findIndex(u, { _id: g });
4712
- if (f > -1) {
4713
- const y = (f + 1) % u.length, b = get(u, [y, "_id"]);
4739
+ const x = findIndex(u, { _id: g });
4740
+ if (x > -1) {
4741
+ const k = (x + 1) % u.length, b = get(u, [k, "_id"]);
4714
4742
  if (!b) return;
4715
4743
  r({ ...o, currentSlide: b }), c([b]);
4716
4744
  }
4717
4745
  }, m = () => {
4718
- const f = findIndex(u, { _id: g });
4719
- if (f > -1) {
4720
- const y = (f - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
4746
+ const x = findIndex(u, { _id: g });
4747
+ if (x > -1) {
4748
+ const k = (x - 1 + u.length) % u.length, b = get(u, [k, "_id"]);
4721
4749
  if (!b) return;
4722
4750
  r({ ...o, currentSlide: b }), c([b]);
4723
4751
  }
4724
- }, x = () => {
4725
- const f = i(
4752
+ }, f = () => {
4753
+ const x = i(
4726
4754
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4727
4755
  p == null ? void 0 : p._id
4728
- ), y = f == null ? void 0 : f._id;
4729
- y && (r({ ...o, currentSlide: y }), c([y]));
4756
+ ), k = x == null ? void 0 : x._id;
4757
+ k && (r({ ...o, currentSlide: k }), c([k]));
4730
4758
  };
4731
4759
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4732
4760
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
@@ -4743,7 +4771,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4743
4771
  /* @__PURE__ */ jsxs(
4744
4772
  "button",
4745
4773
  {
4746
- onClick: x,
4774
+ onClick: f,
4747
4775
  className: "flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",
4748
4776
  children: [
4749
4777
  /* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
@@ -4804,9 +4832,9 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4804
4832
  value: o == null ? void 0 : o.autoplayInterval,
4805
4833
  className: "text-xs",
4806
4834
  pattern: "[0-9]*",
4807
- onChange: (f) => {
4808
- let y = f.target.value;
4809
- y.length && (y = y.replace("-", "")), r({ ...o, autoplayInterval: y });
4835
+ onChange: (x) => {
4836
+ let k = x.target.value;
4837
+ k.length && (k = k.replace("-", "")), r({ ...o, autoplayInterval: k });
4810
4838
  }
4811
4839
  }
4812
4840
  )
@@ -4914,28 +4942,28 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4914
4942
  formData: g,
4915
4943
  onChange: h
4916
4944
  }) => {
4917
- const { selectedLang: m, fallbackLang: x, languages: f } = useLanguages(), y = useMemo(
4918
- () => isEmpty(f) ? "" : isEmpty(m) ? x : m,
4919
- [f, m, x]
4920
- ), b = useMemo(() => get(LANGUAGES, y, y), [y]), B = usePageExternalData(), E = useSelectedBlock(), A = useRegisteredChaiBlocks(), j = useMemo(
4921
- () => get(A, [E == null ? void 0 : E._type, "i18nProps"], []),
4922
- [A, E == null ? void 0 : E._type]
4923
- ), [w, C] = useState(null);
4945
+ const { selectedLang: m, fallbackLang: f, languages: x } = useLanguages(), k = useMemo(
4946
+ () => isEmpty(x) ? "" : isEmpty(m) ? f : m,
4947
+ [x, m, f]
4948
+ ), b = useMemo(() => get(LANGUAGES, k, k), [k]), A = usePageExternalData(), B = useSelectedBlock(), _ = useRegisteredChaiBlocks(), N = useMemo(
4949
+ () => get(_, [B == null ? void 0 : B._type, "i18nProps"], []),
4950
+ [_, B == null ? void 0 : B._type]
4951
+ ), [w, y] = useState(null);
4924
4952
  if (d)
4925
4953
  return null;
4926
4954
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: a });
4927
- const N = j == null ? void 0 : j.includes(o.replace("root.", ""));
4955
+ const E = N == null ? void 0 : N.includes(o.replace("root.", ""));
4928
4956
  if (u.type === "array") {
4929
- const S = w === o;
4957
+ const v = w === o;
4930
4958
  return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
4931
4959
  u.title && /* @__PURE__ */ jsxs(
4932
4960
  "label",
4933
4961
  {
4934
4962
  htmlFor: o,
4935
- onClick: () => C(S ? null : o),
4963
+ onClick: () => y(v ? null : o),
4936
4964
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
4937
4965
  children: [
4938
- S ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
4966
+ v ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
4939
4967
  /* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
4940
4968
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: n }),
4941
4969
  " ",
@@ -4943,7 +4971,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4943
4971
  ]
4944
4972
  }
4945
4973
  ),
4946
- (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${S ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
4974
+ (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${v ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
4947
4975
  c,
4948
4976
  a,
4949
4977
  l,
@@ -4957,7 +4985,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4957
4985
  /* @__PURE__ */ jsxs("label", { htmlFor: o, className: u.type === "object" ? "pb-2" : "", children: [
4958
4986
  n,
4959
4987
  " ",
4960
- N && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
4988
+ E && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
4961
4989
  " ",
4962
4990
  b
4963
4991
  ] }),
@@ -4968,12 +4996,12 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4968
4996
  /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: u.description })
4969
4997
  ] }) })
4970
4998
  ] }),
4971
- !u.enum && !u.oneOf && B && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
4999
+ !u.enum && !u.oneOf && A && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
4972
5000
  DataBindingSelector,
4973
5001
  {
4974
5002
  schema: u,
4975
- onChange: (S) => {
4976
- h(S, g, o);
5003
+ onChange: (v) => {
5004
+ h(v, g, o);
4977
5005
  },
4978
5006
  id: o,
4979
5007
  formData: g
@@ -5080,36 +5108,36 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
5080
5108
  }), a;
5081
5109
  };
5082
5110
  function BlockSettings() {
5083
- const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), x = ({ formData: w }, C, v) => {
5084
- C && (c == null ? void 0 : c._id) === r._id && a([r._id], { [C]: get(w, C) }, v);
5085
- }, f = useCallback(
5086
- debounce(({ formData: w }, C, v) => {
5087
- x({ formData: w }, C, v), d(w);
5111
+ const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), f = ({ formData: w }, y, S) => {
5112
+ y && (c == null ? void 0 : c._id) === r._id && a([r._id], { [y]: get(w, y) }, S);
5113
+ }, x = useCallback(
5114
+ debounce(({ formData: w }, y, S) => {
5115
+ f({ formData: w }, y, S), d(w);
5088
5116
  }, 1500),
5089
5117
  [r == null ? void 0 : r._id, o]
5090
- ), y = ({ formData: w }, C) => {
5091
- C && (n([r._id], { [C]: get(w, C) }), f({ formData: w }, C, { [C]: get(c, C) }));
5092
- }, b = ({ formData: w }, C) => {
5093
- C && (n([g._id], { [C]: get(w, C) }), f({ formData: w }, C, { [C]: get(c, C) }));
5094
- }, { schema: B, uiSchema: E } = useMemo(() => {
5118
+ ), k = ({ formData: w }, y) => {
5119
+ y && (n([r._id], { [y]: get(w, y) }), x({ formData: w }, y, { [y]: get(c, y) }));
5120
+ }, b = ({ formData: w }, y) => {
5121
+ y && (n([g._id], { [y]: get(w, y) }), x({ formData: w }, y, { [y]: get(c, y) }));
5122
+ }, { schema: A, uiSchema: B } = useMemo(() => {
5095
5123
  const w = r == null ? void 0 : r._type;
5096
5124
  if (!w)
5097
5125
  return { schema: {}, uiSchema: {} };
5098
5126
  try {
5099
- const { schema: C, uiSchema: v } = getBlockFormSchemas(w);
5127
+ const { schema: y, uiSchema: S } = getBlockFormSchemas(w);
5100
5128
  if (w === "Repeater") {
5101
- const N = get(r, "repeaterItems", "");
5102
- startsWith(N, `{{${COLLECTION_PREFIX}`) ? (set(v, "filter", { "ui:widget": "collectionSelect" }), set(v, "sort", { "ui:widget": "collectionSelect" })) : (set(v, "filter", { "ui:widget": "hidden" }), set(v, "sort", { "ui:widget": "hidden" }));
5129
+ const E = get(r, "repeaterItems", "");
5130
+ startsWith(E, `{{${COLLECTION_PREFIX}`) ? (set(S, "filter", { "ui:widget": "collectionSelect" }), set(S, "sort", { "ui:widget": "collectionSelect" })) : (set(S, "filter", { "ui:widget": "hidden" }), set(S, "sort", { "ui:widget": "hidden" }));
5103
5131
  }
5104
- return { schema: C, uiSchema: v };
5132
+ return { schema: y, uiSchema: S };
5105
5133
  } catch {
5106
5134
  return { schema: {}, uiSchema: {} };
5107
5135
  }
5108
- }, [r]), { wrapperSchema: A, wrapperUiSchema: j } = useMemo(() => {
5136
+ }, [r]), { wrapperSchema: _, wrapperUiSchema: N } = useMemo(() => {
5109
5137
  if (!g || !(g != null && g._type))
5110
5138
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5111
- const w = g == null ? void 0 : g._type, { schema: C = {}, uiSchema: v = {} } = getBlockFormSchemas(w);
5112
- return { wrapperSchema: C, wrapperUiSchema: v };
5139
+ const w = g == null ? void 0 : g._type, { schema: y = {}, uiSchema: S = {} } = getBlockFormSchemas(w);
5140
+ return { wrapperSchema: y, wrapperUiSchema: S };
5113
5141
  }, [g]);
5114
5142
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5115
5143
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
@@ -5137,52 +5165,52 @@ function BlockSettings() {
5137
5165
  blockId: g == null ? void 0 : g._id,
5138
5166
  onChange: b,
5139
5167
  formData: m,
5140
- schema: A,
5141
- uiSchema: j
5168
+ schema: _,
5169
+ uiSchema: N
5142
5170
  }
5143
5171
  ) })
5144
5172
  ] }),
5145
- isEmpty(B) ? null : /* @__PURE__ */ jsx(
5173
+ isEmpty(A) ? null : /* @__PURE__ */ jsx(
5146
5174
  JSONForm,
5147
5175
  {
5148
5176
  blockId: r == null ? void 0 : r._id,
5149
- onChange: y,
5177
+ onChange: k,
5150
5178
  formData: i,
5151
- schema: B,
5152
- uiSchema: E
5179
+ schema: A,
5180
+ uiSchema: B
5153
5181
  }
5154
5182
  )
5155
5183
  ] });
5156
5184
  }
5157
5185
  const BlockStylingProps = () => {
5158
- var x;
5186
+ var f;
5159
5187
  const o = useSelectedBlock(), [r, n] = useSelectedStylingBlocks(), a = useRemoveClassesFromBlocks(), [l] = useSelectedBlockIds(), { t: i } = useTranslation();
5160
5188
  if (!o) return null;
5161
5189
  const c = Object.keys(o).filter(
5162
- (f) => typeof o[f] == "string" && o[f].startsWith("#styles:")
5163
- ), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (x = r[0]) == null ? void 0 : x.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, h = g ? g.split(" ").filter((f) => !isEmpty(f)) : [], m = (f) => find(r, (y) => y.prop === f);
5190
+ (x) => typeof o[x] == "string" && o[x].startsWith("#styles:")
5191
+ ), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (f = r[0]) == null ? void 0 : f.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, h = g ? g.split(" ").filter((x) => !isEmpty(x)) : [], m = (x) => find(r, (k) => k.prop === x);
5164
5192
  return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
5165
5193
  /* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
5166
5194
  i("Style element"),
5167
5195
  ":"
5168
5196
  ] }),
5169
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (f) => /* @__PURE__ */ jsxs(
5197
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (x) => /* @__PURE__ */ jsxs(
5170
5198
  Badge,
5171
5199
  {
5172
5200
  className: "flex cursor-pointer items-center gap-1 pr-1",
5173
- variant: m(f) ? "default" : "secondary",
5201
+ variant: m(x) ? "default" : "secondary",
5174
5202
  onClick: () => {
5175
- n([{ id: `${f}-${o._id}`, blockId: o._id, prop: f }]);
5203
+ n([{ id: `${x}-${o._id}`, blockId: o._id, prop: x }]);
5176
5204
  },
5177
5205
  children: [
5178
- startCase(f),
5206
+ startCase(x),
5179
5207
  /* @__PURE__ */ jsxs(DropdownMenu, { children: [
5180
5208
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5181
5209
  "button",
5182
5210
  {
5183
5211
  type: "button",
5184
5212
  className: "ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",
5185
- onClick: (y) => y.stopPropagation(),
5213
+ onClick: (k) => k.stopPropagation(),
5186
5214
  children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-3 w-3" })
5187
5215
  }
5188
5216
  ) }),
@@ -5192,7 +5220,7 @@ const BlockStylingProps = () => {
5192
5220
  {
5193
5221
  className: "text-xs",
5194
5222
  onClick: () => {
5195
- d(f);
5223
+ d(x);
5196
5224
  },
5197
5225
  children: i("Reset style")
5198
5226
  }
@@ -5211,7 +5239,7 @@ const BlockStylingProps = () => {
5211
5239
  ] })
5212
5240
  ]
5213
5241
  },
5214
- f
5242
+ x
5215
5243
  )) }),
5216
5244
  /* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
5217
5245
  ] }) });
@@ -5360,47 +5388,47 @@ const BlockStylingProps = () => {
5360
5388
  },
5361
5389
  a
5362
5390
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5363
- const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [y, b] = useState(""), [B, E] = useState(!1), [A, j] = useState(!1);
5391
+ const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [k, b] = useState(""), [A, B] = useState(!1), [_, N] = useState(!1);
5364
5392
  useEffect(() => {
5365
- const { value: S, unit: k } = getClassValueAndUnit(i);
5366
- if (k === "") {
5367
- l(S), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5393
+ const { value: v, unit: C } = getClassValueAndUnit(i);
5394
+ if (C === "") {
5395
+ l(v), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5368
5396
  return;
5369
5397
  }
5370
- m(k), l(k === "class" || isEmpty(S) ? "" : S);
5398
+ m(C), l(C === "class" || isEmpty(v) ? "" : v);
5371
5399
  }, [i, p, u]);
5372
- const w = useThrottledCallback((S) => c(S), [c], THROTTLE_TIME), C = useThrottledCallback((S) => c(S, !1), [c], THROTTLE_TIME), v = useCallback(
5373
- (S = !1) => {
5374
- const k = getUserInputValues(`${a}`, u);
5375
- if (get(k, "error", !1)) {
5376
- f(!0);
5400
+ const w = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), y = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), S = useCallback(
5401
+ (v = !1) => {
5402
+ const C = getUserInputValues(`${a}`, u);
5403
+ if (get(C, "error", !1)) {
5404
+ x(!0);
5377
5405
  return;
5378
5406
  }
5379
- const _ = get(k, "unit") !== "" ? get(k, "unit") : h;
5380
- if (_ === "auto" || _ === "none") {
5381
- w(`${d}${_}`);
5407
+ const j = get(C, "unit") !== "" ? get(C, "unit") : h;
5408
+ if (j === "auto" || j === "none") {
5409
+ w(`${d}${j}`);
5382
5410
  return;
5383
5411
  }
5384
- if (get(k, "value") === "")
5412
+ if (get(C, "value") === "")
5385
5413
  return;
5386
- const L = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
5387
- S ? C(L) : w(L);
5414
+ const L = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5415
+ v ? y(L) : w(L);
5388
5416
  },
5389
- [w, C, a, h, d, u]
5390
- ), N = useCallback(
5391
- (S) => {
5392
- const k = getUserInputValues(`${a}`, u);
5393
- if (get(k, "error", !1)) {
5394
- f(!0);
5417
+ [w, y, a, h, d, u]
5418
+ ), E = useCallback(
5419
+ (v) => {
5420
+ const C = getUserInputValues(`${a}`, u);
5421
+ if (get(C, "error", !1)) {
5422
+ x(!0);
5395
5423
  return;
5396
5424
  }
5397
- if (S === "auto" || S === "none") {
5398
- w(`${d}${S}`);
5425
+ if (v === "auto" || v === "none") {
5426
+ w(`${d}${v}`);
5399
5427
  return;
5400
5428
  }
5401
- if (get(k, "value") === "")
5429
+ if (get(C, "value") === "")
5402
5430
  return;
5403
- const _ = get(k, "unit") !== "" ? get(k, "unit") : S, L = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
5431
+ const j = get(C, "unit") !== "" ? get(C, "unit") : v, L = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5404
5432
  w(L);
5405
5433
  },
5406
5434
  [w, a, d, u]
@@ -5418,40 +5446,40 @@ const BlockStylingProps = () => {
5418
5446
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsx(InfoCircledIcon, {}) }) }),
5419
5447
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
5420
5448
  ] })
5421
- ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${B ? "z-auto" : ""}`, children: [
5449
+ ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
5422
5450
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
5423
5451
  ["none", "auto"].indexOf(h) !== -1 ? null : /* @__PURE__ */ jsx(
5424
5452
  "input",
5425
5453
  {
5426
5454
  readOnly: h === "class",
5427
- onKeyPress: (S) => {
5428
- S.key === "Enter" && v();
5455
+ onKeyPress: (v) => {
5456
+ v.key === "Enter" && S();
5429
5457
  },
5430
- onKeyDown: (S) => {
5431
- if (S.keyCode !== 38 && S.keyCode !== 40)
5458
+ onKeyDown: (v) => {
5459
+ if (v.keyCode !== 38 && v.keyCode !== 40)
5432
5460
  return;
5433
- S.preventDefault(), j(!0);
5434
- const k = parseInt$1(S.target.value);
5435
- let _ = isNaN$1(k) ? 0 : k;
5436
- S.keyCode === 38 && (_ += 1), S.keyCode === 40 && (_ -= 1);
5437
- const I = `${_}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
5438
- C(R);
5461
+ v.preventDefault(), N(!0);
5462
+ const C = parseInt$1(v.target.value);
5463
+ let j = isNaN$1(C) ? 0 : C;
5464
+ v.keyCode === 38 && (j += 1), v.keyCode === 40 && (j -= 1);
5465
+ const I = `${j}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
5466
+ y(R);
5439
5467
  },
5440
- onKeyUp: (S) => {
5441
- A && (S.preventDefault(), j(!1));
5468
+ onKeyUp: (v) => {
5469
+ _ && (v.preventDefault(), N(!1));
5442
5470
  },
5443
- onBlur: () => v(),
5444
- onChange: (S) => {
5445
- f(!1), l(S.target.value);
5471
+ onBlur: () => S(),
5472
+ onChange: (v) => {
5473
+ x(!1), l(v.target.value);
5446
5474
  },
5447
- onClick: (S) => {
5448
- var k;
5449
- (k = S == null ? void 0 : S.target) == null || k.select(), n(!1);
5475
+ onClick: (v) => {
5476
+ var C;
5477
+ (C = v == null ? void 0 : v.target) == null || C.select(), n(!1);
5450
5478
  },
5451
- value: B ? y : a,
5479
+ value: A ? k : a,
5452
5480
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
5453
5481
  " ",
5454
- x ? "border-red-500 text-red-500" : "border-foreground/20"
5482
+ f ? "border-red-500 text-red-500" : "border-foreground/20"
5455
5483
  )
5456
5484
  }
5457
5485
  ),
@@ -5473,29 +5501,29 @@ const BlockStylingProps = () => {
5473
5501
  {
5474
5502
  units: u,
5475
5503
  current: h,
5476
- onSelect: (S) => {
5477
- n(!1), m(S), N(S);
5504
+ onSelect: (v) => {
5505
+ n(!1), m(v), E(v);
5478
5506
  }
5479
5507
  }
5480
5508
  ) })
5481
5509
  ] })
5482
5510
  ] }),
5483
- ["none", "auto"].indexOf(h) !== -1 || B ? null : /* @__PURE__ */ jsx(
5511
+ ["none", "auto"].indexOf(h) !== -1 || A ? null : /* @__PURE__ */ jsx(
5484
5512
  DragStyleButton,
5485
5513
  {
5486
- onDragStart: () => E(!0),
5487
- onDragEnd: (S) => {
5488
- if (b(() => ""), E(!1), isEmpty(S))
5514
+ onDragStart: () => B(!0),
5515
+ onDragEnd: (v) => {
5516
+ if (b(() => ""), B(!1), isEmpty(v))
5489
5517
  return;
5490
- const k = `${S}`, I = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
5518
+ const C = `${v}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
5491
5519
  w(I);
5492
5520
  },
5493
- onDrag: (S) => {
5494
- if (isEmpty(S))
5521
+ onDrag: (v) => {
5522
+ if (isEmpty(v))
5495
5523
  return;
5496
- b(S);
5497
- const k = `${S}`, I = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
5498
- C(I);
5524
+ b(v);
5525
+ const C = `${v}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
5526
+ y(I);
5499
5527
  },
5500
5528
  currentValue: a,
5501
5529
  unit: h,
@@ -5560,8 +5588,8 @@ const COLOR_PROP = {
5560
5588
  }, ColorChoice = ({ property: o, onChange: r }) => {
5561
5589
  const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), h = get(u, "2", ""), m = useCallback(
5562
5590
  // eslint-disable-next-line no-shadow
5563
- (y) => {
5564
- ["current", "inherit", "transparent", "black", "white"].includes(y) ? (c([]), p({ color: y })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: y, shade: b.shade ? b.shade : "500" })));
5591
+ (k) => {
5592
+ ["current", "inherit", "transparent", "black", "white"].includes(k) ? (c([]), p({ color: k })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: k, shade: b.shade ? b.shade : "500" })));
5565
5593
  },
5566
5594
  [c, p]
5567
5595
  );
@@ -5570,21 +5598,21 @@ const COLOR_PROP = {
5570
5598
  return c([]);
5571
5599
  c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
5572
5600
  }, [g]);
5573
- const x = useCallback(
5601
+ const f = useCallback(
5574
5602
  // eslint-disable-next-line no-shadow
5575
- (y) => {
5576
- p({ color: g, shade: y });
5603
+ (k) => {
5604
+ p({ color: g, shade: k });
5577
5605
  },
5578
5606
  [g]
5579
5607
  );
5580
5608
  useEffect(() => {
5581
5609
  p({ color: "", shade: "" });
5582
5610
  }, [n]);
5583
- const { match: f } = useTailwindClassList();
5611
+ const { match: x } = useTailwindClassList();
5584
5612
  return useEffect(() => {
5585
5613
  const b = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
5586
- f(o, b) && r(b, o);
5587
- }, [f, d, r, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
5614
+ x(o, b) && r(b, o);
5615
+ }, [x, d, r, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
5588
5616
  /* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
5589
5617
  DropDown,
5590
5618
  {
@@ -5624,7 +5652,7 @@ const COLOR_PROP = {
5624
5652
  ]
5625
5653
  }
5626
5654
  ) }),
5627
- /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: x, options: i }) })
5655
+ /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: f, options: i }) })
5628
5656
  ] });
5629
5657
  }, EDITOR_ICONS = {
5630
5658
  "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" }) }),
@@ -5958,34 +5986,34 @@ const COLOR_PROP = {
5958
5986
  "2xl": "1536px"
5959
5987
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
5960
5988
  const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
5961
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), y = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
5962
- (C, v = !0) => {
5963
- const N = { dark: p, mq: g, mod: u, cls: C, property: l, fullCls: "" };
5964
- (p || u !== "") && (N.mq = "xs");
5965
- const S = generateFullClsName(N);
5966
- m(f, [S], v);
5989
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), k = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
5990
+ (y, S = !0) => {
5991
+ const E = { dark: p, mq: g, mod: u, cls: y, property: l, fullCls: "" };
5992
+ (p || u !== "") && (E.mq = "xs");
5993
+ const v = generateFullClsName(E);
5994
+ m(x, [v], S);
5967
5995
  },
5968
- [f, p, g, u, l, m]
5969
- ), B = useCallback(() => {
5970
- x(f, [y], !0);
5971
- }, [f, y, x]), E = useMemo(() => canChangeClass(h, g), [h, g]);
5996
+ [x, p, g, u, l, m]
5997
+ ), A = useCallback(() => {
5998
+ f(x, [k], !0);
5999
+ }, [x, k, f]), B = useMemo(() => canChangeClass(h, g), [h, g]);
5972
6000
  useEffect(() => {
5973
- i(E, h);
5974
- }, [E, i, h]);
5975
- const [, , A] = useScreenSizeWidth(), j = useCallback(
5976
- (C) => {
5977
- A({
6001
+ i(B, h);
6002
+ }, [B, i, h]);
6003
+ const [, , _] = useScreenSizeWidth(), N = useCallback(
6004
+ (y) => {
6005
+ _({
5978
6006
  xs: 400,
5979
6007
  sm: 640,
5980
6008
  md: 800,
5981
6009
  lg: 1024,
5982
6010
  xl: 1420,
5983
6011
  "2xl": 1920
5984
- }[C]);
6012
+ }[y]);
5985
6013
  },
5986
- [A]
6014
+ [_]
5987
6015
  ), w = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
5988
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: E, canReset: h && w, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6016
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: h && w, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
5989
6017
  /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !w ? "text-foreground" : ""}`, children: r(a) }) }),
5990
6018
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
5991
6019
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
@@ -6005,7 +6033,7 @@ const COLOR_PROP = {
6005
6033
  n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
6006
6034
  n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
6007
6035
  ] }),
6008
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: w ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => B(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : E && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6036
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${k ? "visible" : "invisible"}`, children: w ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6009
6037
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6010
6038
  "button",
6011
6039
  {
@@ -6025,7 +6053,7 @@ const COLOR_PROP = {
6025
6053
  "button",
6026
6054
  {
6027
6055
  type: "button",
6028
- onClick: () => j(get(h, "mq")),
6056
+ onClick: () => N(get(h, "mq")),
6029
6057
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
6030
6058
  children: [
6031
6059
  "Switch to ",
@@ -6054,23 +6082,23 @@ const COLOR_PROP = {
6054
6082
  children: [
6055
6083
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
6056
6084
  o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
6057
- /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: m, key: x }, f) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6085
+ /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: m, key: f }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6058
6086
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6059
6087
  "button",
6060
6088
  {
6061
6089
  type: "button",
6062
- onClick: () => u(x),
6063
- className: `relative cursor-pointer rounded-full p-1 text-[8px] ${x === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6090
+ onClick: () => u(f),
6091
+ className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6064
6092
  children: [
6065
6093
  React__default.createElement("div", {
6066
- className: h(x) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6094
+ className: h(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6067
6095
  }),
6068
- React__default.createElement(get(EDITOR_ICONS, x, BoxIcon), { className: "text-inherit w-3 h-3" })
6096
+ React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
6069
6097
  ]
6070
6098
  }
6071
6099
  ) }),
6072
6100
  /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(m)) })
6073
- ] }) }, `option-${f}`)) })
6101
+ ] }) }, `option-${x}`)) })
6074
6102
  ] }),
6075
6103
  /* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
6076
6104
  BlockStyle,
@@ -6225,19 +6253,19 @@ const COLOR_PROP = {
6225
6253
  canvas: r = !1,
6226
6254
  tooltip: n = !0
6227
6255
  }) => {
6228
- const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), x = (b) => {
6229
- u.includes(b) ? u.length > 2 && g(u.filter((B) => B !== b)) : g((B) => [...B, b]);
6230
- }, f = (b) => {
6256
+ const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (b) => {
6257
+ u.includes(b) ? u.length > 2 && g(u.filter((A) => A !== b)) : g((A) => [...A, b]);
6258
+ }, x = (b) => {
6231
6259
  r || l(b), c(b);
6232
- }, y = getBreakpointValue(r ? i : a).toLowerCase();
6260
+ }, k = getBreakpointValue(r ? i : a).toLowerCase();
6233
6261
  return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
6234
6262
  BreakpointCard,
6235
6263
  {
6236
6264
  canvas: r,
6237
6265
  ...b,
6238
- onClick: f,
6266
+ onClick: x,
6239
6267
  key: b.breakpoint,
6240
- currentBreakpoint: y
6268
+ currentBreakpoint: k
6241
6269
  }
6242
6270
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
6243
6271
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
@@ -6249,9 +6277,9 @@ const COLOR_PROP = {
6249
6277
  openDelay: o,
6250
6278
  tooltip: n,
6251
6279
  ...b,
6252
- onClick: f,
6280
+ onClick: x,
6253
6281
  key: b.breakpoint,
6254
- currentBreakpoint: y
6282
+ currentBreakpoint: k
6255
6283
  }
6256
6284
  )
6257
6285
  ) }),
@@ -6264,7 +6292,7 @@ const COLOR_PROP = {
6264
6292
  DropdownMenuCheckboxItem,
6265
6293
  {
6266
6294
  disabled: b.breakpoint === "xs",
6267
- onCheckedChange: () => x(toUpper(b.breakpoint)),
6295
+ onCheckedChange: () => f(toUpper(b.breakpoint)),
6268
6296
  checked: includes(u, toUpper(b.breakpoint)),
6269
6297
  children: h(b.title)
6270
6298
  },
@@ -6349,8 +6377,8 @@ const AskAIStyles = ({ blockId: o }) => {
6349
6377
  (m = d.current) == null || m.focus();
6350
6378
  }, []);
6351
6379
  const h = (m) => {
6352
- const { usage: x } = m || {};
6353
- !l && x && g(x), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
6380
+ const { usage: f } = m || {};
6381
+ !l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
6354
6382
  };
6355
6383
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
6356
6384
  /* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: r("Ask AI") }),
@@ -6406,10 +6434,10 @@ const AskAIStyles = ({ blockId: o }) => {
6406
6434
  };
6407
6435
  function ManualClasses() {
6408
6436
  var I;
6409
- const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [x, f] = useState(""), y = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), B = b.split(" ").filter((L) => !isEmpty(L)), E = () => {
6410
- const L = x.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6411
- u(h, L, !0), f("");
6412
- }, [A, j] = useState([]), w = ({ value: L }) => {
6437
+ const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), k = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), A = b.split(" ").filter((L) => !isEmpty(L)), B = () => {
6438
+ const L = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6439
+ u(h, L, !0), x("");
6440
+ }, [_, N] = useState([]), w = ({ value: L }) => {
6413
6441
  const R = L.trim().toLowerCase(), T = R.match(/.+:/g);
6414
6442
  let D = [];
6415
6443
  if (T && T.length > 0) {
@@ -6420,10 +6448,10 @@ function ManualClasses() {
6420
6448
  }));
6421
6449
  } else
6422
6450
  D = i.search(R);
6423
- return j(map(D, "item"));
6424
- }, C = () => {
6425
- j([]);
6426
- }, v = (L) => L.name, N = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), S = useMemo(
6451
+ return N(map(D, "item"));
6452
+ }, y = () => {
6453
+ N([]);
6454
+ }, S = (L) => L.name, E = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), v = useMemo(
6427
6455
  () => ({
6428
6456
  ref: o,
6429
6457
  autoComplete: "off",
@@ -6431,36 +6459,36 @@ function ManualClasses() {
6431
6459
  autoCapitalize: "off",
6432
6460
  spellCheck: !1,
6433
6461
  placeholder: c("Enter classes separated by space"),
6434
- value: x,
6462
+ value: f,
6435
6463
  onFocus: (L) => {
6436
6464
  setTimeout(() => {
6437
6465
  L.target && L.target.select();
6438
6466
  }, 0);
6439
6467
  },
6440
6468
  onKeyDown: (L) => {
6441
- L.key === "Enter" && x.trim() !== "" && E();
6469
+ L.key === "Enter" && f.trim() !== "" && B();
6442
6470
  },
6443
- onChange: (L, { newValue: R }) => f(R),
6471
+ onChange: (L, { newValue: R }) => x(R),
6444
6472
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
6445
6473
  }),
6446
- [x, c, o]
6447
- ), k = (L) => {
6474
+ [f, c, o]
6475
+ ), C = (L) => {
6448
6476
  debugger;
6449
6477
  const R = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6450
6478
  g(h, [L]), u(h, R, !0), n(""), l(-1);
6451
- }, _ = () => {
6479
+ }, j = () => {
6452
6480
  if (navigator.clipboard === void 0) {
6453
6481
  toast.error(c("Clipboard not supported"));
6454
6482
  return;
6455
6483
  }
6456
- navigator.clipboard.writeText(B.join(" ")), toast.success(c("Classes copied to clipboard"));
6484
+ navigator.clipboard.writeText(A.join(" ")), toast.success(c("Classes copied to clipboard"));
6457
6485
  };
6458
6486
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
6459
6487
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
6460
6488
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
6461
6489
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
6462
6490
  /* @__PURE__ */ jsxs(Tooltip, { children: [
6463
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: _, className: "cursor-pointer" }) }),
6491
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: j, className: "cursor-pointer" }) }),
6464
6492
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
6465
6493
  ] })
6466
6494
  ] }),
@@ -6476,12 +6504,12 @@ function ManualClasses() {
6476
6504
  /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
6477
6505
  Autosuggest,
6478
6506
  {
6479
- suggestions: A,
6507
+ suggestions: _,
6480
6508
  onSuggestionsFetchRequested: w,
6481
- onSuggestionsClearRequested: C,
6482
- getSuggestionValue: v,
6483
- renderSuggestion: N,
6484
- inputProps: S,
6509
+ onSuggestionsClearRequested: y,
6510
+ getSuggestionValue: S,
6511
+ renderSuggestion: E,
6512
+ inputProps: v,
6485
6513
  containerProps: {
6486
6514
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
6487
6515
  },
@@ -6497,14 +6525,14 @@ function ManualClasses() {
6497
6525
  {
6498
6526
  variant: "outline",
6499
6527
  className: "h-6 border-border",
6500
- onClick: E,
6501
- disabled: x.trim() === "",
6528
+ onClick: B,
6529
+ disabled: f.trim() === "",
6502
6530
  size: "sm",
6503
6531
  children: /* @__PURE__ */ jsx(PlusIcon, {})
6504
6532
  }
6505
6533
  )
6506
6534
  ] }),
6507
- /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: B.map(
6535
+ /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: A.map(
6508
6536
  (L, R) => a === R ? /* @__PURE__ */ jsx(
6509
6537
  "input",
6510
6538
  {
@@ -6512,10 +6540,10 @@ function ManualClasses() {
6512
6540
  value: r,
6513
6541
  onChange: (T) => n(T.target.value),
6514
6542
  onBlur: () => {
6515
- k(L);
6543
+ C(L);
6516
6544
  },
6517
6545
  onKeyDown: (T) => {
6518
- T.key === "Enter" && k(L);
6546
+ T.key === "Enter" && C(L);
6519
6547
  },
6520
6548
  onFocus: (T) => {
6521
6549
  setTimeout(() => {
@@ -6529,7 +6557,7 @@ function ManualClasses() {
6529
6557
  "button",
6530
6558
  {
6531
6559
  onDoubleClick: () => {
6532
- f(L), g(h, [L]), setTimeout(() => {
6560
+ x(L), g(h, [L]), setTimeout(() => {
6533
6561
  o.current && o.current.focus();
6534
6562
  }, 10);
6535
6563
  },
@@ -6683,10 +6711,10 @@ function BlockStyling() {
6683
6711
  const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
6684
6712
  let m = parseFloat(i.dragStartValue);
6685
6713
  m = isNaN(m) ? 0 : m;
6686
- let x = MAPPER[i.dragUnit];
6687
- (startsWith(h, "scale") || h === "opacity") && (x = 10);
6688
- let y = (i.dragStartY - u.pageY) / x + m;
6689
- g && y < 0 && (y = 0), h === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6714
+ let f = MAPPER[i.dragUnit];
6715
+ (startsWith(h, "scale") || h === "opacity") && (f = 10);
6716
+ let k = (i.dragStartY - u.pageY) / f + m;
6717
+ g && k < 0 && (k = 0), h === "opacity" && k > 1 && (k = 1), i.onDrag(`${k}`), l(`${k}`);
6690
6718
  },
6691
6719
  [i],
6692
6720
  50
@@ -6729,12 +6757,12 @@ const CoreBlock = ({
6729
6757
  }) => {
6730
6758
  const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
6731
6759
  if (has(o, "blocks")) {
6732
- const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
6733
- u(syncBlocksWithDefaults(y), n || null, a);
6760
+ const k = isFunction(o.blocks) ? o.blocks() : o.blocks;
6761
+ u(syncBlocksWithDefaults(k), n || null, a);
6734
6762
  } else
6735
6763
  p(o, n || null, a);
6736
6764
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6737
- }, x = useFeature("dnd"), { t: f } = useTranslation();
6765
+ }, f = useFeature("dnd"), { t: x } = useTranslation();
6738
6766
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6739
6767
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6740
6768
  "button",
@@ -6742,20 +6770,20 @@ const CoreBlock = ({
6742
6770
  disabled: r,
6743
6771
  onClick: m,
6744
6772
  type: "button",
6745
- onDragStart: (y) => {
6746
- y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6773
+ onDragStart: (k) => {
6774
+ k.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), k.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6747
6775
  g([]), h();
6748
6776
  }, 200);
6749
6777
  },
6750
- draggable: x ? "true" : "false",
6778
+ draggable: f ? "true" : "false",
6751
6779
  className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
6752
6780
  children: [
6753
6781
  createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
6754
- /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(f(d || i)) })
6782
+ /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
6755
6783
  ]
6756
6784
  }
6757
6785
  ) }),
6758
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: f(d || i) }) })
6786
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
6759
6787
  ] }) });
6760
6788
  }, DefaultChaiBlocks = ({
6761
6789
  parentId: o,
@@ -6819,7 +6847,22 @@ const CoreBlock = ({
6819
6847
  }, shouldAddText = (o, r) => o.children.length === 1 && includes(
6820
6848
  ["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
6821
6849
  r._type
6822
- ), getTextContent = (o) => o.map((r) => r.type === "text" ? get(r, "content", "") : isEmpty(r.children) ? "" : getTextContent(r.children)).join(""), getSanitizedValue = (o) => o === null ? "" : o, getAttrs = (o) => {
6850
+ ), getTextContent = (o) => o.map((r) => r.type === "text" ? get(r, "content", "") : isEmpty(r.children) ? "" : getTextContent(r.children)).join(""), getSanitizedValue = (o) => o === null ? "" : o, getHeightAndWidthFromClass = (o) => {
6851
+ const r = compact(map(o.split(/\s+/), trim)), n = find(r, (d) => /^w-/.test(d)), a = find(r, (d) => /^h-/.test(d));
6852
+ if (!a || !n) return { height: "", width: "" };
6853
+ const l = (d) => {
6854
+ if (!d) return;
6855
+ const p = d.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
6856
+ if (!p) return;
6857
+ if (p[1]) return p[1];
6858
+ const u = p[2];
6859
+ return /^\d+(\.\d+)?$/.test(u) ? `${Number(u) * 4}px` : u === "auto" || includes(u, "%") ? u : "16px";
6860
+ }, i = l(n), c = l(a);
6861
+ return {
6862
+ width: includes(i, "px") ? i : "16px",
6863
+ height: includes(c, "px") ? c : "16px"
6864
+ };
6865
+ }, getAttrs = (o) => {
6823
6866
  if (o.tagName === "svg") return {};
6824
6867
  const r = {}, n = ATTRIBUTE_MAP[o.tagName] || {}, a = o.attributes;
6825
6868
  return forEach(a, ({ key: l, value: i }) => {
@@ -6943,21 +6986,21 @@ const CoreBlock = ({
6943
6986
  }
6944
6987
  }
6945
6988
  }, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
6946
- var h, m, x, f, y, b, B, E;
6989
+ var h, m, f, x, k, b, A, B, _, N;
6947
6990
  if (n.type === "comment") return [];
6948
6991
  let a = { _id: generateUUID() };
6949
6992
  if (r && (a._parent = r.block._id), n.type === "text")
6950
6993
  return isEmpty(get(n, "content", "")) ? [] : r && shouldAddText(r.node, r.block) ? (set(r, "block.content", get(n, "content", "")), []) : { ...a, _type: "Text", content: get(n, "content", "") };
6951
6994
  const l = get(n, "attributes", []), i = l.find(
6952
- (A) => A.key === "data-chai-richtext" || A.key === "chai-richtext"
6995
+ (w) => w.key === "data-chai-richtext" || w.key === "chai-richtext"
6953
6996
  ), c = l.find(
6954
- (A) => A.key === "data-chai-lightbox" || A.key === "chai-lightbox"
6997
+ (w) => w.key === "data-chai-lightbox" || w.key === "chai-lightbox"
6955
6998
  ), d = l.find(
6956
- (A) => A.key === "data-chai-dropdown" || A.key === "chai-dropdown"
6999
+ (w) => w.key === "data-chai-dropdown" || w.key === "chai-dropdown"
6957
7000
  ), p = l.find(
6958
- (A) => A.key === "data-chai-dropdown-button" || A.key === "chai-dropdown-button"
7001
+ (w) => w.key === "data-chai-dropdown-button" || w.key === "chai-dropdown-button"
6959
7002
  ), u = l.find(
6960
- (A) => A.key === "data-chai-dropdown-content" || A.key === "chai-dropdown-content"
7003
+ (w) => w.key === "data-chai-dropdown-content" || w.key === "chai-dropdown-content"
6961
7004
  );
6962
7005
  if (a = {
6963
7006
  ...a,
@@ -6965,13 +7008,13 @@ const CoreBlock = ({
6965
7008
  ...getAttrs(n),
6966
7009
  ...getStyles(n)
6967
7010
  }, n.attributes) {
6968
- const A = n.attributes.find((j) => includes(NAME_ATTRIBUTES, j.key));
6969
- A && (a._name = A.value);
7011
+ const w = n.attributes.find((y) => includes(NAME_ATTRIBUTES, y.key));
7012
+ w && (a._name = w.value);
6970
7013
  }
6971
7014
  if (i)
6972
7015
  return a.content = stringify(n.children), has(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], has(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
6973
7016
  if (c) {
6974
- const A = [
7017
+ const w = [
6975
7018
  "data-chai-lightbox",
6976
7019
  "chai-lightbox",
6977
7020
  "data-vbtype",
@@ -6983,44 +7026,50 @@ const CoreBlock = ({
6983
7026
  ];
6984
7027
  a = {
6985
7028
  ...a,
6986
- href: ((h = l.find((j) => j.key === "href")) == null ? void 0 : h.value) || "",
6987
- hrefType: ((m = l.find((j) => j.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
6988
- autoplay: ((x = l.find((j) => j.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
6989
- maxWidth: ((y = (f = l.find((j) => j.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : y.replace("px", "")) || "",
6990
- backdropColor: ((b = l.find((j) => j.key === "data-overlay")) == null ? void 0 : b.value) || "",
6991
- galleryName: ((B = l.find((j) => j.key === "data-gall")) == null ? void 0 : B.value) || ""
6992
- }, forEach(A, (j) => {
6993
- has(a, `styles_attrs.${j}`) && delete a.styles_attrs[j];
7029
+ href: ((h = l.find((y) => y.key === "href")) == null ? void 0 : h.value) || "",
7030
+ hrefType: ((m = l.find((y) => y.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
7031
+ autoplay: ((f = l.find((y) => y.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
7032
+ maxWidth: ((k = (x = l.find((y) => y.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : k.replace("px", "")) || "",
7033
+ backdropColor: ((b = l.find((y) => y.key === "data-overlay")) == null ? void 0 : b.value) || "",
7034
+ galleryName: ((A = l.find((y) => y.key === "data-gall")) == null ? void 0 : A.value) || ""
7035
+ }, forEach(w, (y) => {
7036
+ has(a, `styles_attrs.${y}`) && delete a.styles_attrs[y];
6994
7037
  });
6995
7038
  }
6996
7039
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
6997
7040
  delete a.styles_attrs;
6998
- const A = filter(n.children || [], (w) => (w == null ? void 0 : w.tagName) !== "span");
6999
- a.content = getTextContent(A);
7000
- const j = find(
7041
+ const w = filter(n.children || [], (S) => (S == null ? void 0 : S.tagName) !== "span");
7042
+ a.content = getTextContent(w);
7043
+ const y = find(
7001
7044
  n.children || [],
7002
- (w) => (w == null ? void 0 : w.tagName) === "span" && some(w.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg")
7045
+ (S) => (S == null ? void 0 : S.tagName) === "span" && some(S.children || [], (E) => (E == null ? void 0 : E.tagName) === "svg")
7003
7046
  );
7004
- if (j) {
7005
- const w = find(j.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg");
7006
- if (w) {
7007
- a.icon = stringify([w]);
7008
- const { height: C, width: v } = getSvgDimensions(w, "16px", "16px");
7009
- a.iconHeight = C, a.iconWidth = v;
7047
+ if (y) {
7048
+ const S = find(y.children || [], (E) => (E == null ? void 0 : E.tagName) === "svg");
7049
+ if (S) {
7050
+ a.icon = stringify([S]);
7051
+ const { height: E, width: v } = getSvgDimensions(S, "16px", "16px");
7052
+ a.iconHeight = E, a.iconWidth = v;
7010
7053
  }
7011
7054
  }
7012
7055
  return [a];
7013
7056
  }
7014
7057
  if (a._type === "Input") {
7015
- const A = a.inputType || "text";
7016
- A === "checkbox" ? set(a, "_type", "Checkbox") : A === "radio" && set(a, "_type", "Radio");
7058
+ const w = a.inputType || "text";
7059
+ w === "checkbox" ? set(a, "_type", "Checkbox") : w === "radio" && set(a, "_type", "Radio");
7017
7060
  } else if (n.tagName === "video" || n.tagName === "iframe") {
7018
- const A = stringify([n]);
7019
- return hasVideoEmbed(A) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(A)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = A, [a];
7061
+ const w = stringify([n]);
7062
+ return hasVideoEmbed(w) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(w)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = w, [a];
7020
7063
  } else if (n.tagName === "svg") {
7021
- const A = find(n.attributes, { key: "height" }), j = find(n.attributes, { key: "width" }), w = get(A, "value") ? `[${get(A, "value")}px]` : "24px", C = get(j, "value") ? `[${get(j, "value")}px]` : "24px", v = get(find(n.attributes, { key: "class" }), "value", "w-full h-full");
7022
- return a.styles = `${STYLES_KEY}, ${cn$2(`w-${C} h-${w}`, v)}`.trim(), n.attributes = filter(n.attributes, (N) => !includes(["style", "width", "height", "class"], N.key)), a.icon = stringify([n]), [a];
7023
- } else if (n.tagName == "option" && r && ((E = r.block) == null ? void 0 : E._type) === "Select")
7064
+ const w = get(find(n.attributes, { key: "class" }), "value", ""), { height: y, width: S } = getHeightAndWidthFromClass(w);
7065
+ if (y && S)
7066
+ a.styles = `${STYLES_KEY}, ${cn$2(`w-${S} h-${y}`, w)}`.trim(), a.height = y == null ? void 0 : y.replace("px", ""), a.width = S == null ? void 0 : S.replace("px", "");
7067
+ else {
7068
+ const E = (B = find(n.attributes, { key: "height" })) == null ? void 0 : B.value, v = (_ = find(n.attributes, { key: "width" })) == null ? void 0 : _.value;
7069
+ E && v ? (a.styles = `${STYLES_KEY}, ${cn$2(`w-[${v}px] h-[${E}px]`, w)}`.trim(), a.height = E, a.width = v) : a.styles = `${STYLES_KEY}, ${cn$2("w-full h-full", w)}`.trim();
7070
+ }
7071
+ return n.attributes = filter(n.attributes, (E) => !includes(["style", "width", "height", "class"], E.key)), a.icon = stringify([n]), [a];
7072
+ } else if (n.tagName == "option" && r && ((N = r.block) == null ? void 0 : N._type) === "Select")
7024
7073
  return r.block.options.push({
7025
7074
  label: getTextContent(n.children),
7026
7075
  ...getAttrs(n)
@@ -7028,10 +7077,19 @@ const CoreBlock = ({
7028
7077
  const g = traverseNodes(n.children, { block: a, node: n });
7029
7078
  return [a, ...g];
7030
7079
  }), getSvgDimensions = (o, r, n) => {
7031
- const a = get(o, "attributes", []), l = find(a, { key: "height" }), i = find(a, { key: "width" });
7080
+ var p, u;
7081
+ const a = get(o, "attributes", []), { height: l, width: i } = getHeightAndWidthFromClass(
7082
+ get(find(a, { key: "class" }), "value", "")
7083
+ );
7084
+ if (l && i)
7085
+ return {
7086
+ height: `[${l}px]`,
7087
+ width: `[${i}px]`
7088
+ };
7089
+ const c = (p = find(a, { key: "height" })) == null ? void 0 : p.value, d = (u = find(a, { key: "width" })) == null ? void 0 : u.value;
7032
7090
  return {
7033
- height: get(l, "value") ? `[${get(l, "value")}px]` : n,
7034
- width: get(i, "value") ? `[${get(i, "value")}px]` : r
7091
+ height: c ? `[${c}px]` : n,
7092
+ width: d ? `[${d}px]` : r
7035
7093
  };
7036
7094
  }, getSanitizedHTML = (o) => {
7037
7095
  o = o.replace(/(\w+)=\\?"(.*?)\\?"/g, (a, l, i) => {
@@ -7127,18 +7185,18 @@ const registerChaiLibrary = (o, r) => {
7127
7185
  parentId: n = void 0,
7128
7186
  position: a = -1
7129
7187
  }) => {
7130
- const [l, i] = useState(!1), c = useMemo(() => (r == null ? void 0 : r.getBlock) || (() => []), [r]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), y = (E) => {
7131
- const A = has(E, "styles_attrs.data-page-section");
7132
- return E._type === "Box" && A;
7188
+ const [l, i] = useState(!1), c = useMemo(() => (r == null ? void 0 : r.getBlock) || (() => []), [r]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), k = (B) => {
7189
+ const _ = has(B, "styles_attrs.data-page-section");
7190
+ return B._type === "Box" && _;
7133
7191
  }, b = useCallback(
7134
- async (E) => {
7135
- if (E.stopPropagation(), has(o, "component")) {
7192
+ async (B) => {
7193
+ if (B.stopPropagation(), has(o, "component")) {
7136
7194
  d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7137
7195
  return;
7138
7196
  }
7139
7197
  i(!0);
7140
- let A = await c({ library: r, block: o });
7141
- typeof A == "string" && (A = getBlocksFromHTML(A)), isEmpty(A) || p(syncBlocksWithDefaults(A), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7198
+ let _ = await c({ library: r, block: o });
7199
+ typeof _ == "string" && (_ = getBlocksFromHTML(_)), isEmpty(_) || p(syncBlocksWithDefaults(_), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7142
7200
  },
7143
7201
  [d, p, o, c, r, n, a]
7144
7202
  );
@@ -7148,20 +7206,20 @@ const registerChaiLibrary = (o, r) => {
7148
7206
  {
7149
7207
  onClick: l ? () => {
7150
7208
  } : b,
7151
- draggable: x ? "true" : "false",
7152
- onDragStart: async (E) => {
7153
- const A = await c({ library: r, block: o });
7154
- let j = n;
7155
- if (y(first(A)) && (j = null), !isEmpty(A)) {
7156
- const w = { blocks: A, uiLibrary: !0, parent: j };
7157
- if (E.dataTransfer.setData("text/plain", JSON.stringify(w)), o.preview) {
7158
- const C = new Image();
7159
- C.src = o.preview, C.onload = () => {
7160
- E.dataTransfer.setDragImage(C, 0, 0);
7209
+ draggable: f ? "true" : "false",
7210
+ onDragStart: async (B) => {
7211
+ const _ = await c({ library: r, block: o });
7212
+ let N = n;
7213
+ if (k(first(_)) && (N = null), !isEmpty(_)) {
7214
+ const w = { blocks: _, uiLibrary: !0, parent: N };
7215
+ if (B.dataTransfer.setData("text/plain", JSON.stringify(w)), o.preview) {
7216
+ const y = new Image();
7217
+ y.src = o.preview, y.onload = () => {
7218
+ B.dataTransfer.setDragImage(y, 0, 0);
7161
7219
  };
7162
7220
  } else
7163
- E.dataTransfer.setDragImage(new Image(), 0, 0);
7164
- f(w), setTimeout(() => {
7221
+ B.dataTransfer.setDragImage(new Image(), 0, 0);
7222
+ x(w), setTimeout(() => {
7165
7223
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7166
7224
  }, 200);
7167
7225
  }
@@ -7187,39 +7245,39 @@ const registerChaiLibrary = (o, r) => {
7187
7245
  ] }) })
7188
7246
  ] });
7189
7247
  }, UILibrarySection = ({ parentId: o, position: r }) => {
7190
- const [n, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((k) => k.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), x = useRef(null);
7248
+ const [n, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((C) => C.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), f = useRef(null);
7191
7249
  useEffect(() => {
7192
- c && c.length > 0 && (x.current = new Fuse(c, {
7250
+ c && c.length > 0 && (f.current = new Fuse(c, {
7193
7251
  keys: ["name", "label", "description", "group"],
7194
7252
  threshold: 0.4,
7195
7253
  ignoreLocation: !0
7196
7254
  }));
7197
7255
  }, [c]), useEffect(() => {
7198
- if (!u.trim() || !x.current) {
7256
+ if (!u.trim() || !f.current) {
7199
7257
  m([]);
7200
7258
  return;
7201
7259
  }
7202
- const k = x.current.search(u).map((_) => _.item);
7203
- m(k);
7260
+ const C = f.current.search(u).map((j) => j.item);
7261
+ m(C);
7204
7262
  }, [u]);
7205
- const f = u.trim() && !isEmpty(h) ? h : c, y = groupBy(f, "group"), [b, B] = useState(null);
7263
+ const x = u.trim() && !isEmpty(h) ? h : c, k = groupBy(x, "group"), [b, A] = useState(null);
7206
7264
  useEffect(() => {
7207
- if (isEmpty(keys(y))) {
7208
- B(null);
7265
+ if (isEmpty(keys(k))) {
7266
+ A(null);
7209
7267
  return;
7210
7268
  }
7211
- if (!b || !y[b]) {
7212
- B(first(keys(y)));
7269
+ if (!b || !k[b]) {
7270
+ A(first(keys(k)));
7213
7271
  return;
7214
7272
  }
7215
- }, [y, b]);
7216
- const E = get(y, b, []), A = useRef(null), { t: j } = useTranslation(), w = (k) => {
7217
- A.current && (clearTimeout(A.current), A.current = null), A.current = setTimeout(() => {
7218
- A.current && B(k);
7273
+ }, [k, b]);
7274
+ const B = get(k, b, []), _ = useRef(null), { t: N } = useTranslation(), w = (C) => {
7275
+ _.current && (clearTimeout(_.current), _.current = null), _.current = setTimeout(() => {
7276
+ _.current && A(C);
7219
7277
  }, 400);
7220
- }, C = () => {
7278
+ }, y = () => {
7221
7279
  i != null && i.id && p(i.id);
7222
- }, v = () => {
7280
+ }, S = () => {
7223
7281
  g("");
7224
7282
  };
7225
7283
  if (d)
@@ -7227,23 +7285,23 @@ const registerChaiLibrary = (o, r) => {
7227
7285
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7228
7286
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7229
7287
  ] });
7230
- const N = filter(E, (k, _) => _ % 2 === 0), S = filter(E, (k, _) => _ % 2 === 1);
7288
+ const E = filter(B, (C, j) => j % 2 === 0), v = filter(B, (C, j) => j % 2 === 1);
7231
7289
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
7232
7290
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7233
7291
  /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
7234
7292
  /* @__PURE__ */ jsx(
7235
7293
  Input$1,
7236
7294
  {
7237
- placeholder: j("Search blocks..."),
7295
+ placeholder: N("Search blocks..."),
7238
7296
  value: u,
7239
- onChange: (k) => g(k.target.value),
7297
+ onChange: (C) => g(C.target.value),
7240
7298
  className: "w-full pl-8 pr-8"
7241
7299
  }
7242
7300
  ),
7243
7301
  u && /* @__PURE__ */ jsx(
7244
7302
  "button",
7245
7303
  {
7246
- onClick: v,
7304
+ onClick: S,
7247
7305
  className: "absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",
7248
7306
  children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
7249
7307
  }
@@ -7253,60 +7311,60 @@ const registerChaiLibrary = (o, r) => {
7253
7311
  /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 min-w-60 max-w-60 flex-col gap-1 px-1 pr-2", children: [
7254
7312
  /* @__PURE__ */ jsx(UILibrariesSelect, { library: i == null ? void 0 : i.id, setLibrary: a, uiLibraries: l }),
7255
7313
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7256
- /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: j("Groups") }),
7314
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: N("Groups") }),
7257
7315
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7258
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(y) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: j("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7259
- /* @__PURE__ */ jsx("p", { className: "text-sm", children: j("Failed to load the UI library. Try again") }),
7260
- /* @__PURE__ */ jsxs(Button, { onClick: C, variant: "outline", size: "sm", className: "gap-2", children: [
7316
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7317
+ /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("Failed to load the UI library. Try again") }),
7318
+ /* @__PURE__ */ jsxs(Button, { onClick: y, variant: "outline", size: "sm", className: "gap-2", children: [
7261
7319
  /* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
7262
- j("Retry")
7320
+ N("Retry")
7263
7321
  ] })
7264
- ] }) }) : map(y, (k, _) => /* @__PURE__ */ jsxs(
7322
+ ] }) }) : map(k, (C, j) => /* @__PURE__ */ jsxs(
7265
7323
  "div",
7266
7324
  {
7267
- onMouseEnter: () => w(_),
7268
- onMouseLeave: () => clearTimeout(A.current),
7325
+ onMouseEnter: () => w(j),
7326
+ onMouseLeave: () => clearTimeout(_.current),
7269
7327
  role: "button",
7270
- onClick: () => B(_),
7328
+ onClick: () => A(j),
7271
7329
  className: cn$2(
7272
7330
  "flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
7273
- _ === b ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
7331
+ j === b ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
7274
7332
  ),
7275
7333
  children: [
7276
- /* @__PURE__ */ jsx("span", { children: capitalize(j(_.toLowerCase())) }),
7334
+ /* @__PURE__ */ jsx("span", { children: capitalize(N(j.toLowerCase())) }),
7277
7335
  /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
7278
7336
  ]
7279
7337
  },
7280
- _
7338
+ j
7281
7339
  )) })
7282
7340
  ] })
7283
7341
  ] }),
7284
7342
  /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-col border-l border-border", children: /* @__PURE__ */ jsxs(
7285
7343
  ScrollArea,
7286
7344
  {
7287
- onMouseEnter: () => A.current ? clearTimeout(A.current) : null,
7345
+ onMouseEnter: () => _.current ? clearTimeout(_.current) : null,
7288
7346
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
7289
7347
  children: [
7290
- isEmpty(E) && !isEmpty(y) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: j("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7291
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: N.map((k, _) => /* @__PURE__ */ jsx(
7348
+ isEmpty(B) && !isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7349
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: E.map((C, j) => /* @__PURE__ */ jsx(
7292
7350
  BlockCard,
7293
7351
  {
7294
7352
  parentId: o,
7295
7353
  position: r,
7296
- block: k,
7354
+ block: C,
7297
7355
  library: i
7298
7356
  },
7299
- `block-${_}`
7357
+ `block-${j}`
7300
7358
  )) }),
7301
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: S.map((k, _) => /* @__PURE__ */ jsx(
7359
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: v.map((C, j) => /* @__PURE__ */ jsx(
7302
7360
  BlockCard,
7303
7361
  {
7304
7362
  parentId: o,
7305
7363
  position: r,
7306
- block: k,
7364
+ block: C,
7307
7365
  library: i
7308
7366
  },
7309
- `block-second-${_}`
7367
+ `block-second-${j}`
7310
7368
  )) })
7311
7369
  ] }),
7312
7370
  /* @__PURE__ */ jsx("br", {}),
@@ -7342,25 +7400,25 @@ const registerChaiLibrary = (o, r) => {
7342
7400
  error: c
7343
7401
  }), g(!0);
7344
7402
  else if (!l && Object.keys(a || {}).length > 0) {
7345
- const m = Object.entries(a).map(([f, y]) => {
7346
- const b = y, B = b.type || "partial", E = formatReadableName(B);
7403
+ const m = Object.entries(a).map(([x, k]) => {
7404
+ const b = k, A = b.type || "partial", B = formatReadableName(A);
7347
7405
  return {
7348
7406
  type: "PartialBlock",
7349
7407
  // Set the type to PartialBlock
7350
- label: formatReadableName(b.name || f),
7408
+ label: formatReadableName(b.name || x),
7351
7409
  description: b.description || "",
7352
7410
  icon: Globe,
7353
- group: E,
7411
+ group: B,
7354
7412
  // Use formatted type as group
7355
7413
  category: "partial",
7356
- partialBlockId: f,
7414
+ partialBlockId: x,
7357
7415
  // Store the original ID as partialBlockId
7358
7416
  _name: b.name
7359
7417
  };
7360
- }), x = uniq(map(m, "group"));
7418
+ }), f = uniq(map(m, "group"));
7361
7419
  p({
7362
7420
  blocks: m,
7363
- groups: x,
7421
+ groups: f,
7364
7422
  isLoading: !1,
7365
7423
  error: null
7366
7424
  }), g(!0);
@@ -7405,44 +7463,44 @@ const registerChaiLibrary = (o, r) => {
7405
7463
  }, ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
7406
7464
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
7407
7465
  }, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: r, parentId: n, position: a, gridCols: l = "grid-cols-4" }) => {
7408
- var S;
7409
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (S = find(c, (k) => k._id === n)) == null ? void 0 : S._type, [m, x] = useState("all"), [f, y] = useState(null), b = useRef(null);
7466
+ var v;
7467
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (v = find(c, (C) => C._id === n)) == null ? void 0 : v._type, [m, f] = useState("all"), [x, k] = useState(null), b = useRef(null);
7410
7468
  useEffect(() => {
7411
- const k = setTimeout(() => {
7412
- var _;
7413
- (_ = u.current) == null || _.focus();
7469
+ const C = setTimeout(() => {
7470
+ var j;
7471
+ (j = u.current) == null || j.focus();
7414
7472
  }, 0);
7415
- return () => clearTimeout(k);
7473
+ return () => clearTimeout(C);
7416
7474
  }, [g]), useEffect(() => {
7417
- d && (x("all"), y(null));
7418
- }, [d]), useEffect(() => (b.current = debounce((k) => {
7419
- x(k);
7475
+ d && (f("all"), k(null));
7476
+ }, [d]), useEffect(() => (b.current = debounce((C) => {
7477
+ f(C);
7420
7478
  }, 500), () => {
7421
7479
  b.current && b.current.cancel();
7422
7480
  }), []);
7423
- const B = useCallback((k) => {
7424
- y(k), b.current && b.current(k);
7425
- }, []), E = useCallback(() => {
7426
- y(null), b.current && b.current.cancel();
7427
- }, []), A = useCallback((k) => {
7428
- b.current && b.current.cancel(), x(k), y(null);
7429
- }, []), j = useMemo(
7481
+ const A = useCallback((C) => {
7482
+ k(C), b.current && b.current(C);
7483
+ }, []), B = useCallback(() => {
7484
+ k(null), b.current && b.current.cancel();
7485
+ }, []), _ = useCallback((C) => {
7486
+ b.current && b.current.cancel(), f(C), k(null);
7487
+ }, []), N = useMemo(
7430
7488
  () => d ? values(r).filter(
7431
- (k) => {
7432
- var _, I;
7433
- return (((_ = k.label) == null ? void 0 : _.toLowerCase()) + " " + ((I = k.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
7489
+ (C) => {
7490
+ var j, I;
7491
+ return (((j = C.label) == null ? void 0 : j.toLowerCase()) + " " + ((I = C.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
7434
7492
  }
7435
7493
  ) : r,
7436
7494
  [r, d]
7437
7495
  ), w = useMemo(
7438
7496
  () => d ? o.filter(
7439
- (k) => reject(filter(values(j), { group: k }), { hidden: !0 }).length > 0
7440
- ) : o.filter((k) => reject(filter(values(r), { group: k }), { hidden: !0 }).length > 0),
7441
- [r, j, o, d]
7442
- ), C = useMemo(
7443
- () => sortBy(w, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7497
+ (C) => reject(filter(values(N), { group: C }), { hidden: !0 }).length > 0
7498
+ ) : o.filter((C) => reject(filter(values(r), { group: C }), { hidden: !0 }).length > 0),
7499
+ [r, N, o, d]
7500
+ ), y = useMemo(
7501
+ () => sortBy(w, (C) => CORE_GROUPS.indexOf(C) === -1 ? 99 : CORE_GROUPS.indexOf(C)),
7444
7502
  [w]
7445
- ), v = useMemo(() => m === "all" ? j : filter(values(j), { group: m }), [j, m]), N = useMemo(() => m === "all" ? C : [m], [C, m]);
7503
+ ), S = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), E = useMemo(() => m === "all" ? y : [m], [y, m]);
7446
7504
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7447
7505
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7448
7506
  Input$1,
@@ -7452,32 +7510,32 @@ const registerChaiLibrary = (o, r) => {
7452
7510
  placeholder: i("Search blocks..."),
7453
7511
  value: d,
7454
7512
  className: "-ml-2",
7455
- onChange: (k) => p(k.target.value)
7513
+ onChange: (C) => p(C.target.value)
7456
7514
  }
7457
7515
  ) }),
7458
7516
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
7459
- 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: [
7517
+ y.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
7460
7518
  /* @__PURE__ */ jsx(
7461
7519
  "button",
7462
7520
  {
7463
- onClick: () => A("all"),
7464
- onMouseEnter: () => B("all"),
7465
- onMouseLeave: E,
7466
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || f === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7521
+ onClick: () => _("all"),
7522
+ onMouseEnter: () => A("all"),
7523
+ onMouseLeave: B,
7524
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || x === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7467
7525
  children: i("All")
7468
7526
  },
7469
7527
  "sidebar-all"
7470
7528
  ),
7471
- C.map((k) => /* @__PURE__ */ jsx(
7529
+ y.map((C) => /* @__PURE__ */ jsx(
7472
7530
  "button",
7473
7531
  {
7474
- onClick: () => A(k),
7475
- onMouseEnter: () => B(k),
7476
- onMouseLeave: E,
7477
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === k || f === k ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7478
- children: capitalize(i(k.toLowerCase()))
7532
+ onClick: () => _(C),
7533
+ onMouseEnter: () => A(C),
7534
+ onMouseLeave: B,
7535
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === C || x === C ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7536
+ children: capitalize(i(C.toLowerCase()))
7479
7537
  },
7480
- `sidebar-${k}`
7538
+ `sidebar-${C}`
7481
7539
  ))
7482
7540
  ] }) }) }),
7483
7541
  /* @__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: [
@@ -7485,22 +7543,22 @@ const registerChaiLibrary = (o, r) => {
7485
7543
  ' "',
7486
7544
  d,
7487
7545
  '"'
7488
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7489
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
7546
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: E.map((C) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7547
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(C.toLowerCase())) }),
7490
7548
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7491
- m === "all" ? filter(values(v), { group: k }) : values(v),
7549
+ m === "all" ? filter(values(S), { group: C }) : values(S),
7492
7550
  { hidden: !0 }
7493
- ).map((_) => /* @__PURE__ */ jsx(
7551
+ ).map((j) => /* @__PURE__ */ jsx(
7494
7552
  CoreBlock,
7495
7553
  {
7496
7554
  parentId: n,
7497
7555
  position: a,
7498
- block: _,
7499
- disabled: !canAcceptChildBlock(h, _.type) || !canBeNestedInside(h, _.type)
7556
+ block: j,
7557
+ disabled: !canAcceptChildBlock(h, j.type) || !canBeNestedInside(h, j.type)
7500
7558
  },
7501
- _.type
7559
+ j.type
7502
7560
  )) })
7503
- ] }, k)) }) }) })
7561
+ ] }, C)) }) }) })
7504
7562
  ] })
7505
7563
  ] });
7506
7564
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -7515,7 +7573,7 @@ const registerChaiLibrary = (o, r) => {
7515
7573
  }, [i, g, c]);
7516
7574
  const m = useCallback(() => {
7517
7575
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7518
- }, []), x = useChaiAddBlockTabs(), f = p && h(PERMISSIONS.IMPORT_HTML), b = useChaiLibraries().length > 0;
7576
+ }, []), f = useChaiAddBlockTabs(), x = p && h(PERMISSIONS.IMPORT_HTML), b = useChaiLibraries().length > 0;
7519
7577
  return useEffect(() => {
7520
7578
  i === "library" && !b && c("core");
7521
7579
  }, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$2("flex h-full w-full flex-col overflow-hidden", o), children: [
@@ -7526,8 +7584,8 @@ const registerChaiLibrary = (o, r) => {
7526
7584
  /* @__PURE__ */ jsxs(
7527
7585
  Tabs,
7528
7586
  {
7529
- onValueChange: (B) => {
7530
- d(""), c(B);
7587
+ onValueChange: (A) => {
7588
+ d(""), c(A);
7531
7589
  },
7532
7590
  value: i,
7533
7591
  className: "flex h-full max-h-full flex-col overflow-hidden",
@@ -7536,14 +7594,14 @@ const registerChaiLibrary = (o, r) => {
7536
7594
  b && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
7537
7595
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
7538
7596
  g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7539
- f ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7540
- map(x, (B) => /* @__PURE__ */ jsx(TabsTrigger, { value: B.id, children: React__default.createElement(B.tab) }, `tab-add-block-${B.id}`))
7597
+ x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7598
+ map(f, (A) => /* @__PURE__ */ jsx(TabsTrigger, { value: A.id, children: React__default.createElement(A.tab) }, `tab-add-block-${A.id}`))
7541
7599
  ] }),
7542
7600
  /* @__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: n, position: a }) }) }) }),
7543
7601
  b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: n, position: a }) }),
7544
7602
  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: n, position: a }) }) }) }),
7545
- f ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: n, position: a }) }) : null,
7546
- map(x, (B) => /* @__PURE__ */ jsx(TabsContent, { value: B.id, children: React__default.createElement(B.tabContent, { close: m, parentId: n, position: a }) }, `panel-add-block-${B.id}`))
7603
+ x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: n, position: a }) }) : null,
7604
+ map(f, (A) => /* @__PURE__ */ jsx(TabsContent, { value: A.id, children: React__default.createElement(A.tabContent, { close: m, parentId: n, position: a }) }, `panel-add-block-${A.id}`))
7547
7605
  ]
7548
7606
  }
7549
7607
  )
@@ -7853,33 +7911,33 @@ const Input = ({ node: o }) => {
7853
7911
  var R;
7854
7912
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7855
7913
  let p = null;
7856
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: x, isSelected: f, willReceiveDrop: y, isDragging: b, isEditing: B, handleClick: E } = o, A = (T) => {
7914
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: f, isSelected: x, willReceiveDrop: k, isDragging: b, isEditing: A, handleClick: B } = o, _ = (T) => {
7857
7915
  T.stopPropagation(), !l.includes(m) && o.toggle();
7858
- }, j = (T) => {
7916
+ }, N = (T) => {
7859
7917
  T.isInternal && (p = T.isOpen, T.isOpen && T.close());
7860
7918
  }, w = (T) => {
7861
7919
  T.isInternal && p !== null && (p ? T.open() : T.close(), p = null);
7862
- }, [C, v] = useAtom$1(currentAddSelection), N = () => {
7920
+ }, [y, S] = useAtom$1(currentAddSelection), E = () => {
7863
7921
  var T;
7864
- S(), o.parent.isSelected || v((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
7865
- }, S = () => {
7866
- v(null);
7867
- }, k = (T) => {
7868
- S(), T.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), E(T);
7922
+ v(), o.parent.isSelected || S((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
7923
+ }, v = () => {
7924
+ S(null);
7925
+ }, C = (T) => {
7926
+ v(), T.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), B(T);
7869
7927
  };
7870
7928
  useEffect(() => {
7871
7929
  const T = setTimeout(() => {
7872
- y && !o.isOpen && !b && !l.includes(m) && o.toggle();
7930
+ k && !o.isOpen && !b && !l.includes(m) && o.toggle();
7873
7931
  }, 500);
7874
7932
  return () => clearTimeout(T);
7875
- }, [y, o, b]);
7876
- const _ = (T, D) => {
7933
+ }, [k, o, b]);
7934
+ const j = (T, D) => {
7877
7935
  const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${T}]`);
7878
7936
  P && P.setAttribute("data-drop", D);
7879
7937
  const $ = P.getBoundingClientRect(), M = c.getBoundingClientRect();
7880
7938
  $.top >= M.top && $.left >= M.left && $.bottom <= M.bottom && $.right <= M.right || (O.documentElement.scrollTop = P.offsetTop - M.top);
7881
7939
  }, I = (T) => {
7882
- S();
7940
+ v();
7883
7941
  const D = get(o, "parent.id");
7884
7942
  D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: T }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: T });
7885
7943
  };
@@ -7901,26 +7959,26 @@ const Input = ({ node: o }) => {
7901
7959
  ),
7902
7960
  /* @__PURE__ */ jsx("br", {})
7903
7961
  ] });
7904
- const L = useMemo(() => has(x, "_libBlockId") && !isEmpty(x._libBlockId) && (d(PERMISSIONS.CREATE_LIBRARY_BLOCK) || d(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [x, d]);
7962
+ const L = useMemo(() => has(f, "_libBlockId") && !isEmpty(f._libBlockId) && (d(PERMISSIONS.CREATE_LIBRARY_BLOCK) || d(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [f, d]);
7905
7963
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7906
7964
  "div",
7907
7965
  {
7908
7966
  onMouseEnter: () => g(m),
7909
7967
  onMouseLeave: () => h(),
7910
- onClick: k,
7968
+ onClick: C,
7911
7969
  style: r,
7912
7970
  "data-node-id": m,
7913
7971
  ref: l.includes(m) ? null : n,
7914
- onDragStart: () => j(o),
7972
+ onDragStart: () => N(o),
7915
7973
  onDragEnd: () => w(o),
7916
7974
  onDragOver: (T) => {
7917
- T.preventDefault(), _(m, "yes");
7975
+ T.preventDefault(), j(m, "yes");
7918
7976
  },
7919
7977
  onDragLeave: (T) => {
7920
- T.preventDefault(), _(m, "no");
7978
+ T.preventDefault(), j(m, "no");
7921
7979
  },
7922
7980
  onDrop: (T) => {
7923
- T.preventDefault(), _(m, "no");
7981
+ T.preventDefault(), j(m, "no");
7924
7982
  },
7925
7983
  children: [
7926
7984
  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(
@@ -7929,8 +7987,8 @@ const Input = ({ node: o }) => {
7929
7987
  onClick: (T) => {
7930
7988
  T.stopPropagation(), I(o.childIndex);
7931
7989
  },
7932
- onMouseEnter: N,
7933
- onMouseLeave: S,
7990
+ onMouseEnter: E,
7991
+ onMouseLeave: v,
7934
7992
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
7935
7993
  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" }) })
7936
7994
  }
@@ -7940,12 +7998,12 @@ const Input = ({ node: o }) => {
7940
7998
  {
7941
7999
  className: cn(
7942
8000
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
7943
- f ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
7944
- y && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
7945
- (o == null ? void 0 : o.id) === C ? "bg-primary/10" : "",
8001
+ x ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
8002
+ k && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
8003
+ (o == null ? void 0 : o.id) === y ? "bg-primary/10" : "",
7946
8004
  b && "opacity-20",
7947
8005
  l.includes(m) ? "opacity-50" : "",
7948
- L && f && "bg-primary/20 text-primary"
8006
+ L && x && "bg-primary/20 text-primary"
7949
8007
  ),
7950
8008
  children: [
7951
8009
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -7953,7 +8011,7 @@ const Input = ({ node: o }) => {
7953
8011
  "div",
7954
8012
  {
7955
8013
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
7956
- children: u && /* @__PURE__ */ jsx("button", { onClick: A, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${f ? "text-white" : "text-slate-400"}` }) })
8014
+ children: u && /* @__PURE__ */ jsx("button", { onClick: _, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${x ? "text-white" : "text-slate-400"}` }) })
7957
8015
  }
7958
8016
  ),
7959
8017
  /* @__PURE__ */ jsxs(
@@ -7962,18 +8020,18 @@ const Input = ({ node: o }) => {
7962
8020
  className: cn(
7963
8021
  "leading-1 flex items-center",
7964
8022
  L && "text-primary/60",
7965
- L && f && "text-primary/80"
8023
+ L && x && "text-primary/80"
7966
8024
  ),
7967
8025
  children: [
7968
- /* @__PURE__ */ jsx(TypeIcon, { type: x == null ? void 0 : x._type }),
7969
- B ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
8026
+ /* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
8027
+ A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
7970
8028
  "div",
7971
8029
  {
7972
8030
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
7973
8031
  onDoubleClick: (T) => {
7974
8032
  T.stopPropagation(), o.edit(), o.deselect();
7975
8033
  },
7976
- children: /* @__PURE__ */ jsx("span", { children: getBlockDisplayName(x) })
8034
+ children: /* @__PURE__ */ jsx("span", { children: getBlockDisplayName(f) })
7977
8035
  }
7978
8036
  )
7979
8037
  ]
@@ -7981,7 +8039,7 @@ const Input = ({ node: o }) => {
7981
8039
  )
7982
8040
  ] }),
7983
8041
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
7984
- canAddChildBlock(x == null ? void 0 : x._type) && !l.includes(m) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8042
+ canAddChildBlock(f == null ? void 0 : f._type) && !l.includes(m) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7985
8043
  /* @__PURE__ */ jsx(
7986
8044
  TooltipTrigger,
7987
8045
  {
@@ -8271,281 +8329,121 @@ const Input = ({ node: o }) => {
8271
8329
  }
8272
8330
  )
8273
8331
  ] });
8274
- }, parseToChaiThemeValues = (o) => {
8275
- const r = {
8276
- fontFamily: {
8277
- heading: "",
8278
- body: ""
8279
- },
8280
- borderRadius: "",
8281
- colors: {}
8282
- };
8283
- try {
8284
- const n = extractCssBlockContent(o, ":root"), a = extractCssBlockContent(o, ".dark"), l = extractVariableValue(n, "--font-sans") || extractVariableValue(n, "--font-family") || extractVariableValue(n, "--font-heading") || extractVariableValue(n, "--font-body");
8285
- r.fontFamily = {
8286
- heading: l || "ui-sans-serif, system-ui, sans-serif",
8287
- body: l || "ui-sans-serif, system-ui, sans-serif"
8288
- }, r.borderRadius = extractVariableValue(n, "--radius") || extractVariableValue(n, "--border-radius") || "0.5rem", [
8289
- "background",
8290
- "foreground",
8291
- "primary",
8292
- "primary-foreground",
8293
- "secondary",
8294
- "secondary-foreground",
8295
- "muted",
8296
- "muted-foreground",
8297
- "accent",
8298
- "accent-foreground",
8299
- "destructive",
8300
- "destructive-foreground",
8301
- "border",
8302
- "input",
8303
- "ring",
8304
- "card",
8305
- "card-foreground",
8306
- "popover",
8307
- "popover-foreground"
8308
- ].forEach((c) => {
8309
- const d = extractVariableValue(n, `--${c}`), p = extractVariableValue(a, `--${c}`);
8310
- if (d || p) {
8311
- const u = d ? processAndFormatColor(d) : "#000000", g = p ? processAndFormatColor(p) : u;
8312
- r.colors[c] = [u, g];
8313
- }
8314
- });
8315
- } catch (n) {
8316
- console.error("Error parsing CSS to ChaiThemeValues:", n);
8317
- }
8318
- return r;
8319
- }, extractCssBlockContent = (o, r) => {
8320
- var a, l;
8321
- const n = new RegExp(`${escapeRegExp(r)}\\s*{([^}]+)}`);
8322
- return ((l = (a = o.match(n)) == null ? void 0 : a[1]) == null ? void 0 : l.trim()) || null;
8323
- }, extractVariableValue = (o, r) => {
8324
- var l;
8325
- if (!o) return null;
8326
- const n = new RegExp(`${escapeRegExp(r)}\\s*:\\s*([^;]+)`), a = o.match(n);
8327
- return ((l = a == null ? void 0 : a[1]) == null ? void 0 : l.trim()) || null;
8328
- }, processAndFormatColor = (o) => {
8329
- try {
8330
- let r = o.replace(/var\([^)]+\)/g, "").trim();
8331
- return /^\d/.test(r) && !r.startsWith("#") && !r.startsWith("rgb") && !r.startsWith("hsl") && (r = `hsl(${r})`), r.startsWith("#") && /^#[0-9A-F]{6}$/i.test(r) ? r : r.startsWith("hsl(") ? hslToHex(r) : r.startsWith("rgb(") ? rgbToHex(r) : /^[0-9A-F]{6}$/i.test(r) ? `#${r}` : "#000000";
8332
- } catch (r) {
8333
- return console.error("Error processing color value:", o, r), o.startsWith("#") ? o : "#000000";
8334
- }
8335
- }, hslToHex = (o) => {
8336
- const r = o.match(/hsla?\((\d+)(?:deg)?,?\s*(\d+)%?,?\s*(\d+)%?(?:,?\s*[\d.]+)?\)/);
8337
- if (!r) return "#000000";
8338
- const n = parseInt(r[1]) / 360, a = parseInt(r[2]) / 100, l = parseInt(r[3]) / 100, i = (g, h, m) => (m < 0 && (m += 1), m > 1 && (m -= 1), m < 1 / 6 ? g + (h - g) * 6 * m : m < 1 / 2 ? h : m < 2 / 3 ? g + (h - g) * (2 / 3 - m) * 6 : g);
8339
- let c, d, p;
8340
- if (a === 0)
8341
- c = d = p = l;
8342
- else {
8343
- const g = l < 0.5 ? l * (1 + a) : l + a - l * a, h = 2 * l - g;
8344
- c = i(h, g, n + 1 / 3), d = i(h, g, n), p = i(h, g, n - 1 / 3);
8345
- }
8346
- const u = (g) => {
8347
- const h = Math.round(g * 255).toString(16);
8348
- return h.length === 1 ? "0" + h : h;
8349
- };
8350
- return `#${u(c)}${u(d)}${u(p)}`;
8351
- }, rgbToHex = (o) => {
8352
- const r = o.match(/rgba?\((\d+)(?:\.\d+)?,?\s*(\d+)(?:\.\d+)?,?\s*(\d+)(?:\.\d+)?(?:,?\s*[\d.]+)?\)/);
8353
- if (!r) return "#000000";
8354
- const n = parseInt(r[1]), a = parseInt(r[2]), l = parseInt(r[3]), i = (c) => {
8355
- const d = c.toString(16);
8356
- return d.length === 1 ? "0" + d : d;
8357
- };
8358
- return `#${i(n)}${i(a)}${i(l)}`;
8359
- }, escapeRegExp = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), validateChaiThemeValues = (o) => [
8360
- "background",
8361
- "foreground",
8362
- "primary",
8363
- "primary-foreground"
8364
- ].every(
8365
- (a) => o.colors[a] && Array.isArray(o.colors[a]) && o.colors[a].length >= 2
8366
- ) && !!o.fontFamily.heading && !!o.fontFamily.body && !!o.borderRadius, validateCssInput = (o) => {
8367
- if (!o.trim())
8368
- return { isValid: !1, error: "Please enter CSS content" };
8369
- try {
8370
- return !o.includes("--") || !o.includes(":") ? {
8371
- isValid: !1,
8372
- error: "Invalid CSS format. CSS should contain variable definitions like --primary: #color"
8373
- } : !o.includes("{") || !o.includes("}") ? {
8374
- isValid: !1,
8375
- error: "Invalid CSS format. CSS should contain proper block structure with { }"
8376
- } : { isValid: !0 };
8377
- } catch {
8378
- return { isValid: !1, error: "Failed to parse CSS. Please check your syntax." };
8379
- }
8380
- }, CSS_PLACEHOLDER = `:root {
8381
- --background: 0 0% 100%;
8382
- --foreground: oklch(0.52 0.13 144.17);
8383
- --primary: #3e2723;
8384
- --primary-foreground: #ffffff;
8385
- }
8386
-
8387
- .dark {
8388
- --background: 222.2 84% 4.9%;
8389
- --foreground: hsl(37.50 36.36% 95.69%);
8390
- --primary: rgb(46, 125, 50);
8391
- --primary-foreground: #ffffff;
8392
- }`, CssImportModal = ({
8393
- open: o,
8394
- onOpenChange: r,
8395
- onImport: n
8396
- }) => {
8397
- const [a, l] = React.useState(""), [i, c] = React.useState(null), [d, p] = React.useState(!1), { t: u } = useTranslation(), g = async () => {
8398
- p(!0), c(null);
8332
+ }, LazyCssImportModal = lazy(
8333
+ () => import("./CssImportModal-DXUM3oRB.js").then((o) => ({ default: o.CssImportModal }))
8334
+ ), PREV_THEME_KEY = "chai-builder-previous-theme", setPreviousTheme = (o) => {
8335
+ if (!(typeof window > "u"))
8399
8336
  try {
8400
- const m = validateCssInput(a);
8401
- if (!m.isValid) {
8402
- c(m.error || "Invalid CSS format"), setTimeout(() => {
8403
- c(null);
8404
- }, 5e3), p(!1);
8405
- return;
8406
- }
8407
- const x = parseToChaiThemeValues(a);
8408
- if (!validateChaiThemeValues(x)) {
8409
- c("The CSS doesn't contain enough theme information. Please ensure it includes at least background, foreground, primary, and primary-foreground colors."), setTimeout(() => {
8410
- c(null);
8411
- }, 5e3), p(!1);
8412
- return;
8413
- }
8414
- n(x), l(""), c(null), r(!1);
8415
- } catch (m) {
8416
- console.error("Error importing CSS:", m), c("Failed to parse CSS. Please check your syntax and try again."), setTimeout(() => {
8417
- c(null);
8418
- }, 5e3);
8419
- } finally {
8420
- p(!1);
8337
+ localStorage.setItem(PREV_THEME_KEY, JSON.stringify(o));
8338
+ } catch (r) {
8339
+ console.warn("Failed to save previous theme to localStorage:", r);
8340
+ }
8341
+ }, clearPreviousTheme = () => {
8342
+ if (!(typeof window > "u"))
8343
+ try {
8344
+ localStorage.removeItem(PREV_THEME_KEY);
8345
+ } catch (o) {
8346
+ console.warn("Failed to clear previous theme from localStorage:", o);
8421
8347
  }
8422
- }, h = () => {
8423
- l(""), c(null), r(!1);
8424
- };
8425
- return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: r, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-2xl max-h-[80vh] flex flex-col", children: [
8426
- /* @__PURE__ */ jsxs(DialogHeader, { children: [
8427
- /* @__PURE__ */ jsx(DialogTitle, { children: u("Import CSS Theme") }),
8428
- /* @__PURE__ */ jsx(DialogDescription, { children: u("Paste your CSS variables to import a custom theme. The CSS should contain :root and .dark blocks with CSS custom properties.") })
8429
- ] }),
8430
- /* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-4 overflow-hidden", children: [
8431
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
8432
- /* @__PURE__ */ jsx(Label, { htmlFor: "css-input", children: u("CSS Variables") }),
8433
- /* @__PURE__ */ jsx(
8434
- Textarea,
8435
- {
8436
- id: "css-input",
8437
- placeholder: CSS_PLACEHOLDER,
8438
- value: a,
8439
- onChange: (m) => l(m.target.value),
8440
- className: "min-h-[300px] font-mono text-sm resize-none",
8441
- disabled: d
8442
- }
8443
- )
8444
- ] }),
8445
- i && /* @__PURE__ */ jsx("div", { className: "rounded-md border border-red-200 bg-red-50 p-3", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-red-600", children: i }) })
8446
- ] }),
8447
- /* @__PURE__ */ jsxs(DialogFooter, { className: "gap-2", children: [
8448
- /* @__PURE__ */ jsx(
8449
- Button,
8450
- {
8451
- variant: "outline",
8452
- onClick: h,
8453
- disabled: d,
8454
- children: u("Cancel")
8455
- }
8456
- ),
8457
- /* @__PURE__ */ jsx(
8458
- Button,
8459
- {
8460
- onClick: g,
8461
- disabled: !a.trim() || d,
8462
- children: u(d ? "Importing..." : "Import Theme")
8463
- }
8464
- )
8465
- ] })
8466
- ] }) });
8467
8348
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
8468
- const [r] = useDarkMode(), [n, a] = React.useState(""), [l, i] = React.useState(!1), c = useBuilderProp("themePresets", []), d = useBuilderProp("themePanelComponent", null), { hasPermission: p } = usePermissions(), [u, g] = useTheme(), h = useThemeOptions(), { t: m } = useTranslation(), x = (j) => {
8469
- a(j);
8470
- }, f = () => {
8471
- const j = c.find((w) => Object.keys(w)[0] === n);
8472
- if (j) {
8473
- const w = Object.values(j)[0];
8474
- w && typeof w == "object" && "fontFamily" in w && "borderRadius" in w && "colors" in w ? g(w) : console.error("Invalid preset structure:", w);
8349
+ const [r] = useDarkMode(), [n, a] = React.useState(""), [l, i] = React.useState(!1), c = useBuilderProp("themePresets", []), d = useBuilderProp("themePanelComponent", null), { hasPermission: p } = usePermissions(), [u, g] = useTheme(), h = useThemeOptions(), { t: m } = useTranslation(), f = React.useCallback(
8350
+ (w) => {
8351
+ const y = { ...u };
8352
+ setPreviousTheme(y), g(w), toast.success("Theme updated", {
8353
+ action: {
8354
+ label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
8355
+ /* @__PURE__ */ jsx(Undo$1, { className: "h-4 w-4" }),
8356
+ " Undo"
8357
+ ] }),
8358
+ onClick: () => {
8359
+ g(y), clearPreviousTheme(), toast.dismiss();
8360
+ }
8361
+ },
8362
+ closeButton: !0,
8363
+ duration: 15e3
8364
+ });
8365
+ },
8366
+ [u, g]
8367
+ ), x = (w) => {
8368
+ a(w);
8369
+ }, k = () => {
8370
+ const w = c.find((y) => Object.keys(y)[0] === n);
8371
+ if (w) {
8372
+ const y = Object.values(w)[0];
8373
+ y && typeof y == "object" && "fontFamily" in y && "borderRadius" in y && "colors" in y ? f(y) : console.error("Invalid preset structure:", y);
8475
8374
  } else
8476
8375
  console.error("Preset not found:", n);
8477
- }, y = (j) => {
8478
- g(j), a("");
8479
- }, b = useDebouncedCallback(
8480
- (j, w) => {
8376
+ }, b = (w) => {
8377
+ f(w), a("");
8378
+ }, A = useDebouncedCallback(
8379
+ (w, y) => {
8481
8380
  g(() => ({
8482
8381
  ...u,
8483
8382
  fontFamily: {
8484
8383
  ...u.fontFamily,
8485
- [j.replace(/font-/g, "")]: w
8384
+ [w.replace(/font-/g, "")]: y
8486
8385
  }
8487
8386
  }));
8488
8387
  },
8489
8388
  [u],
8490
8389
  200
8491
8390
  ), B = useDebouncedCallback(
8492
- (j) => {
8391
+ (w) => {
8493
8392
  g(() => ({
8494
8393
  ...u,
8495
- borderRadius: `${j}px`
8394
+ borderRadius: `${w}px`
8496
8395
  }));
8497
8396
  },
8498
8397
  [u],
8499
8398
  200
8500
- ), E = useDebouncedCallback(
8501
- (j, w) => {
8399
+ ), _ = useDebouncedCallback(
8400
+ (w, y) => {
8502
8401
  g(() => {
8503
- const C = get(u, `colors.${j}`);
8504
- return r ? set(C, 1, w) : set(C, 0, w), {
8402
+ const S = get(u, `colors.${w}`);
8403
+ return r ? set(S, 1, y) : set(S, 0, y), {
8505
8404
  ...u,
8506
8405
  colors: {
8507
8406
  ...u.colors,
8508
- [j]: C
8407
+ [w]: S
8509
8408
  }
8510
8409
  };
8511
8410
  });
8512
8411
  },
8513
8412
  [u],
8514
8413
  200
8515
- ), A = (j) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(j.items).map(([w]) => {
8516
- const C = get(u, `colors.${w}.${r ? 1 : 0}`);
8517
- return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8414
+ ), N = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([y]) => {
8415
+ const S = get(u, `colors.${y}.${r ? 1 : 0}`);
8416
+ return S ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8518
8417
  /* @__PURE__ */ jsx(
8519
8418
  ColorPickerInput,
8520
8419
  {
8521
- value: C,
8522
- onChange: (v) => E(w, v)
8420
+ value: S,
8421
+ onChange: (E) => _(y, E)
8523
8422
  }
8524
8423
  ),
8525
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: w.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((v) => v.charAt(0).toUpperCase() + v.slice(1)).join(" ") + (!w.toLowerCase().includes("foreground") && !w.toLowerCase().includes("border") && !w.toLowerCase().includes("input") && !w.toLowerCase().includes("ring") && !w.toLowerCase().includes("background") ? " Background" : "") })
8526
- ] }, w);
8424
+ /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: y.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!y.toLowerCase().includes("foreground") && !y.toLowerCase().includes("border") && !y.toLowerCase().includes("input") && !y.toLowerCase().includes("ring") && !y.toLowerCase().includes("background") ? " Background" : "") })
8425
+ ] }, y) : null;
8527
8426
  }) });
8528
8427
  return p("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
8529
8428
  /* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
8530
- c.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 py-2", children: [
8429
+ c.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 py-2", children: [
8531
8430
  /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
8532
8431
  /* @__PURE__ */ jsx(Label, { className: "text-sm", children: m("Presets") }),
8533
- /* @__PURE__ */ jsxs(Button, { variant: "link", size: "sm", onClick: () => i(!0), children: [
8534
- /* @__PURE__ */ jsx(ImportIcon, { className: "h-3 w-3" }),
8535
- " ",
8432
+ /* @__PURE__ */ jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ jsxs(Button, { className: "px-1", variant: "link", size: "sm", onClick: () => i(!0), children: [
8433
+ /* @__PURE__ */ jsx(ImportIcon, { className: "h-4 w-4" }),
8536
8434
  m("Import theme")
8537
- ] })
8435
+ ] }) })
8538
8436
  ] }),
8539
8437
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
8540
8438
  /* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(
8541
8439
  "select",
8542
8440
  {
8543
8441
  value: n,
8544
- onChange: (j) => x(j.target.value),
8442
+ onChange: (w) => x(w.target.value),
8545
8443
  className: "w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
8546
8444
  children: [
8547
8445
  /* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
8548
- Array.isArray(c) && c.map((j) => /* @__PURE__ */ jsx("option", { value: Object.keys(j)[0], children: capitalize(Object.keys(j)[0].replaceAll("_", " ")) }, Object.keys(j)[0]))
8446
+ Array.isArray(c) && c.map((w) => /* @__PURE__ */ jsx("option", { value: Object.keys(w)[0], children: capitalize(Object.keys(w)[0].replaceAll("_", " ")) }, Object.keys(w)[0]))
8549
8447
  ]
8550
8448
  }
8551
8449
  ) }),
@@ -8555,21 +8453,21 @@ const Input = ({ node: o }) => {
8555
8453
  className: "w-full text-sm",
8556
8454
  disabled: n === "",
8557
8455
  variant: "default",
8558
- onClick: f,
8456
+ onClick: k,
8559
8457
  children: m("Apply")
8560
8458
  }
8561
8459
  ) })
8562
8460
  ] })
8563
8461
  ] }),
8564
8462
  /* @__PURE__ */ jsxs("div", { className: cn$2("space-y-2", o), children: [
8565
- (h == null ? void 0 : h.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(h.fontFamily).map(([j, w]) => /* @__PURE__ */ jsx(
8463
+ (h == null ? void 0 : h.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(h.fontFamily).map(([w, y]) => /* @__PURE__ */ jsx(
8566
8464
  FontSelector,
8567
8465
  {
8568
- label: j,
8569
- value: u.fontFamily[j.replace(/font-/g, "")] || w[Object.keys(w)[0]],
8570
- onChange: (C) => b(j, C)
8466
+ label: w,
8467
+ value: u.fontFamily[w.replace(/font-/g, "")] || y[Object.keys(y)[0]],
8468
+ onChange: (S) => A(w, S)
8571
8469
  },
8572
- j
8470
+ w
8573
8471
  )) }),
8574
8472
  (h == null ? void 0 : h.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
8575
8473
  /* @__PURE__ */ jsx(Label, { className: "text-sm", children: m("Border Radius") }),
@@ -8580,7 +8478,7 @@ const Input = ({ node: o }) => {
8580
8478
  ] }),
8581
8479
  (h == null ? void 0 : h.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
8582
8480
  /* @__PURE__ */ jsx(Label, { className: "text-sm", children: m("Colors") }),
8583
- /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: h.colors.map((j) => A(j)) }, r ? "dark" : "light")
8481
+ /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: h.colors.map((w) => N(w)) }, r ? "dark" : "light")
8584
8482
  ] })
8585
8483
  ] }),
8586
8484
  /* @__PURE__ */ jsx("br", {}),
@@ -8589,7 +8487,7 @@ const Input = ({ node: o }) => {
8589
8487
  /* @__PURE__ */ jsx("br", {})
8590
8488
  ] }),
8591
8489
  d && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(d) }),
8592
- /* @__PURE__ */ jsx(CssImportModal, { open: l, onOpenChange: i, onImport: y })
8490
+ /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: l && /* @__PURE__ */ jsx(LazyCssImportModal, { open: l, onOpenChange: i, onImport: b }) })
8593
8491
  ] }) : /* @__PURE__ */ jsx("div", { className: "relative w-full", children: /* @__PURE__ */ jsx("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto text-center", o), children: /* @__PURE__ */ jsx("div", { className: "mt-10 h-full items-center justify-center gap-2 text-muted-foreground", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: "You don't have permission to edit the theme. Please contact your administrator to get access." }) }) }) });
8594
8492
  }), Core = "Core", Import = "Import", Breakpoints = "Breakpoints", Clear = "Clear", Cancel = "Cancel", Yes = "Yes", Preview = "Preview", Settings = "Settings", Styling = "Styling", Remove = "Remove", Choose = "Choose", Cut = "Cut", Copy = "Copy", Paste = "Paste", Delete = "Delete", classes = "classes", Theme = "Theme", Outline = "Outline", Copied = "Copied", Stop = "Stop", Edit = "Edit", Tag = "Tag", Value = "Value", Images = "Images", Library = "Library", Blocks = "Blocks", Basic = "Basic", Media = "Media", Advanced = "Advanced", Form = "Form", Groups = "Groups", Accordions = "Accordions", Buttons = "Buttons", Layouts = "Layouts", FAQ = "FAQ", Hero = "Hero", Features = "Features", Footer = "Footer", Navbar = "Navbar", Icons = "Icons", Testimonials = "Testimonials", Blog = "Blog", Saved = "Saved", Unsaved = "Unsaved", Randomize = "Randomize", theme_config = { heading_font: "Heading Font", body_font: "Body Font", rounded_corner: "Rounded Corners", primary: "Primary", secondary: "Secondary", background: "Background", text_color: "Text Color", background_dark_mode: "Background (Dark Mode)", text_color_dark_mode: "Text Color (Dark Mode)" }, web_blocks = { box: "box", tag: "Tag", div: "div", level: "Level", header: "header", footer: "footer", section: "section", article: "article", aside: "aside", main: "main", nav: "navigation", figure: "figure", details: "details", summary: "summary", dialog: "dialog", strike: "strike", caption: "caption", legend: "legend", figcaption: "figure caption", mark: "mark", background_image: "Background Image", label: "Label", default: "default", icon_size: "Icon Size", icon_position: "Icon Position", start: "Start", end: "End", button: "Button", custom_html: "Custom HTML", html_code: "HTML Code", default_snippet: "The HTML snippet goes here...", placeholder: "Enter custom HTML code here", custom_script: "Custom Script", dark_mode: "Dark Mode", divider: "Divider", empty_box: "Empty Box", heading: "Heading", image: "Image", alt: "Alt", width: "Width", height: "Height", video: "Video", span: "Span", content: "Content", icon: "Icon", richtext: "Rich Text", list: "List", list_type: "List Type", listitem: "List Item", link: "Link", list_item: "List Item", none: "None", disc: "Disc", number: "Number", paragraph: "Paragraph", lightbox_link: "Lightbox Link", href: "Link", type: "Type", iframe: "iframe", inline: "inline", ajax: "ajax", autoplay: "Video autoplay", max_width: "Max Width", backdrop_color: "Background Color", gallery_name: "Gallery Name", slot: "Slot", empty_slot: "Empty Slot", text: "Text", video_url: "Video URL", controls: "Show Controls", loop: "Loop", muted: "Muted", checkbox: "Checkbox", required: "Required", checked: "Checked", submit_button: "Submit Button", form: "Form", submit_url: "Submit URL", error_message: "Error Message", success_message: "Success Message", input: "Input", value: "Value", show_label: "Show Label", field_name: "Field Name", radio: "Radio", multiple: "Multiple", options: "Options", select: "Select", multiple_choice: "Multiple Choice", textarea: "Textarea", rows: "Rows" }, Undo = "Undo", Redo = "Redo", Duplicate = "Duplicate", Close = "Close", Selected = "Selected", Select = "Select", Attributes = "Attributes", apply = "apply", presets = "presets", Orientation = "Orientation", Color = "Color", Upload = "Upload", lngEn = {
8595
8493
  "Add block": "Add Block",
@@ -9075,12 +8973,12 @@ function QuickPrompts({ onClick: o }) {
9075
8973
  const AIUserPrompt = ({ blockId: o }) => {
9076
8974
  const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), h = useRef(null), m = useRef(null);
9077
8975
  useEffect(() => {
9078
- var f;
9079
- (f = h.current) == null || f.focus();
8976
+ var x;
8977
+ (x = h.current) == null || x.focus();
9080
8978
  }, []);
9081
- const x = (f) => {
9082
- const { usage: y } = f || {};
9083
- !l && y && g(y), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8979
+ const f = (x) => {
8980
+ const { usage: k } = x || {};
8981
+ !l && k && g(k), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
9084
8982
  };
9085
8983
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
9086
8984
  /* @__PURE__ */ jsxs(
@@ -9100,12 +8998,12 @@ const AIUserPrompt = ({ blockId: o }) => {
9100
8998
  {
9101
8999
  ref: h,
9102
9000
  value: i,
9103
- onChange: (f) => c(f.target.value),
9001
+ onChange: (x) => c(x.target.value),
9104
9002
  placeholder: r("Ask AI to edit content"),
9105
9003
  className: "w-full",
9106
9004
  rows: 3,
9107
- onKeyDown: (f) => {
9108
- f.key === "Enter" && (f.preventDefault(), m.current && clearTimeout(m.current), g(void 0), n("content", o, i, x));
9005
+ onKeyDown: (x) => {
9006
+ x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f));
9109
9007
  }
9110
9008
  }
9111
9009
  ),
@@ -9115,7 +9013,7 @@ const AIUserPrompt = ({ blockId: o }) => {
9115
9013
  {
9116
9014
  disabled: i.trim().length < 5 || a,
9117
9015
  onClick: () => {
9118
- m.current && clearTimeout(m.current), g(void 0), n("content", o, i, x);
9016
+ m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f);
9119
9017
  },
9120
9018
  variant: "default",
9121
9019
  className: "w-fit",
@@ -9147,8 +9045,8 @@ const AIUserPrompt = ({ blockId: o }) => {
9147
9045
  /* @__PURE__ */ jsx(
9148
9046
  QuickPrompts,
9149
9047
  {
9150
- onClick: (f) => {
9151
- m.current && clearTimeout(m.current), g(void 0), n("content", o, f, x);
9048
+ onClick: (x) => {
9049
+ m.current && clearTimeout(m.current), g(void 0), n("content", o, x, f);
9152
9050
  }
9153
9051
  }
9154
9052
  )
@@ -9165,8 +9063,8 @@ const AIUserPrompt = ({ blockId: o }) => {
9165
9063
  const m = async () => {
9166
9064
  try {
9167
9065
  d(!0), u(null), await i(n), toast.success(o("Updated AI Context")), h.current.click();
9168
- } catch (x) {
9169
- u(x);
9066
+ } catch (f) {
9067
+ u(f);
9170
9068
  } finally {
9171
9069
  d(!1);
9172
9070
  }
@@ -9174,8 +9072,8 @@ const AIUserPrompt = ({ blockId: o }) => {
9174
9072
  return /* @__PURE__ */ jsx(
9175
9073
  Accordion,
9176
9074
  {
9177
- onValueChange: (x) => {
9178
- g(x !== "");
9075
+ onValueChange: (f) => {
9076
+ g(f !== "");
9179
9077
  },
9180
9078
  type: "single",
9181
9079
  collapsible: !0,
@@ -9187,12 +9085,12 @@ const AIUserPrompt = ({ blockId: o }) => {
9187
9085
  {
9188
9086
  ref: l,
9189
9087
  value: n,
9190
- onChange: (x) => a(x.target.value),
9088
+ onChange: (f) => a(f.target.value),
9191
9089
  placeholder: o("Tell about this page eg this page is about"),
9192
9090
  className: "mt-1 w-full",
9193
9091
  rows: 10,
9194
- onKeyDown: (x) => {
9195
- x.key === "Enter" && (x.preventDefault(), m());
9092
+ onKeyDown: (f) => {
9093
+ f.key === "Enter" && (f.preventDefault(), m());
9196
9094
  }
9197
9095
  }
9198
9096
  ),
@@ -9302,31 +9200,31 @@ function AIChatPanel() {
9302
9200
  content: n,
9303
9201
  timestamp: /* @__PURE__ */ new Date()
9304
9202
  };
9305
- r((B) => [...B, b]), a(""), i(!0), setTimeout(() => {
9306
- const B = {
9203
+ r((A) => [...A, b]), a(""), i(!0), setTimeout(() => {
9204
+ const A = {
9307
9205
  id: (Date.now() + 1).toString(),
9308
9206
  role: "assistant",
9309
9207
  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.",
9310
9208
  timestamp: /* @__PURE__ */ new Date()
9311
9209
  };
9312
- r((E) => [...E, B]), i(!1), d(null);
9210
+ r((B) => [...B, A]), i(!1), d(null);
9313
9211
  }, 1500);
9314
9212
  }, m = (b) => {
9315
9213
  b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
9316
- }, x = (b) => {
9317
- var E;
9318
- const B = (E = b.target.files) == null ? void 0 : E[0];
9319
- if (B) {
9320
- const A = new FileReader();
9321
- A.onload = (j) => {
9214
+ }, f = (b) => {
9215
+ var B;
9216
+ const A = (B = b.target.files) == null ? void 0 : B[0];
9217
+ if (A) {
9218
+ const _ = new FileReader();
9219
+ _.onload = (N) => {
9322
9220
  var w;
9323
- d((w = j.target) == null ? void 0 : w.result);
9324
- }, A.readAsDataURL(B);
9221
+ d((w = N.target) == null ? void 0 : w.result);
9222
+ }, _.readAsDataURL(A);
9325
9223
  }
9326
- }, f = () => {
9224
+ }, x = () => {
9327
9225
  var b;
9328
9226
  (b = p.current) == null || b.click();
9329
- }, y = () => {
9227
+ }, k = () => {
9330
9228
  d(null), p.current && (p.current.value = "");
9331
9229
  };
9332
9230
  return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
@@ -9372,7 +9270,7 @@ function AIChatPanel() {
9372
9270
  size: "icon",
9373
9271
  variant: "destructive",
9374
9272
  className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
9375
- onClick: y,
9273
+ onClick: k,
9376
9274
  children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
9377
9275
  }
9378
9276
  )
@@ -9390,14 +9288,14 @@ function AIChatPanel() {
9390
9288
  className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
9391
9289
  }
9392
9290
  ),
9393
- /* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: x, accept: "image/*", className: "hidden" }),
9291
+ /* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: f, accept: "image/*", className: "hidden" }),
9394
9292
  /* @__PURE__ */ jsx(
9395
9293
  Button,
9396
9294
  {
9397
9295
  size: "icon",
9398
9296
  variant: "ghost",
9399
9297
  className: "absolute bottom-2 right-2 h-6 w-6",
9400
- onClick: f,
9298
+ onClick: x,
9401
9299
  children: /* @__PURE__ */ jsx(Image$1, { className: "h-4 w-4 text-muted-foreground" })
9402
9300
  }
9403
9301
  )
@@ -9515,7 +9413,7 @@ const AiAssistant = () => {
9515
9413
  preloadedAttributes: r = [],
9516
9414
  onAttributesChange: n
9517
9415
  }) {
9518
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), x = useRef(null), f = useRef(null), y = usePageExternalData();
9416
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), f = useRef(null), x = useRef(null), k = usePageExternalData();
9519
9417
  useEffect(() => {
9520
9418
  l(r);
9521
9419
  }, [r]);
@@ -9525,43 +9423,43 @@ const AiAssistant = () => {
9525
9423
  return;
9526
9424
  }
9527
9425
  if (i) {
9528
- const C = [...a, { key: i, value: d }];
9529
- n(C), l(a), c(""), p(""), m("");
9426
+ const y = [...a, { key: i, value: d }];
9427
+ n(y), l(a), c(""), p(""), m("");
9530
9428
  }
9531
- }, B = (C) => {
9532
- const v = a.filter((N, S) => S !== C);
9533
- n(v), l(v);
9534
- }, E = (C) => {
9535
- g(C), c(a[C].key), p(a[C].value);
9536
- }, A = () => {
9429
+ }, A = (y) => {
9430
+ const S = a.filter((E, v) => v !== y);
9431
+ n(S), l(S);
9432
+ }, B = (y) => {
9433
+ g(y), c(a[y].key), p(a[y].value);
9434
+ }, _ = () => {
9537
9435
  if (i.startsWith("@")) {
9538
9436
  m("Attribute keys cannot start with '@'");
9539
9437
  return;
9540
9438
  }
9541
9439
  if (u !== null && i) {
9542
- const C = [...a];
9543
- C[u] = { key: i, value: d }, n(C), l(C), g(null), c(""), p(""), m("");
9440
+ const y = [...a];
9441
+ y[u] = { key: i, value: d }, n(y), l(y), g(null), c(""), p(""), m("");
9544
9442
  }
9545
- }, j = (C) => {
9546
- C.key === "Enter" && !C.shiftKey && (C.preventDefault(), u !== null ? A() : b());
9547
- }, w = useCallback((C) => {
9548
- const v = (k) => /[.,!?;:]/.test(k), N = (k, _, I) => {
9443
+ }, N = (y) => {
9444
+ y.key === "Enter" && !y.shiftKey && (y.preventDefault(), u !== null ? _() : b());
9445
+ }, w = useCallback((y) => {
9446
+ const S = (C) => /[.,!?;:]/.test(C), E = (C, j, I) => {
9549
9447
  let L = "", R = "";
9550
- const T = _ > 0 ? k[_ - 1] : "", D = _ < k.length ? k[_] : "";
9551
- return _ > 0 && (T === "." || !v(T) && T !== " ") && (L = " "), _ < k.length && !v(D) && D !== " " && (R = " "), {
9448
+ const T = j > 0 ? C[j - 1] : "", D = j < C.length ? C[j] : "";
9449
+ return j > 0 && (T === "." || !S(T) && T !== " ") && (L = " "), j < C.length && !S(D) && D !== " " && (R = " "), {
9552
9450
  text: L + I + R,
9553
9451
  prefixLength: L.length,
9554
9452
  suffixLength: R.length
9555
9453
  };
9556
- }, S = f.current;
9557
- if (S) {
9558
- const k = S.selectionStart || 0, _ = S.value || "", I = S.selectionEnd || k;
9559
- if (I > k) {
9560
- const O = `{{${C}}}`, { text: P } = N(_, k, O), $ = _.slice(0, k) + P + _.slice(I);
9454
+ }, v = x.current;
9455
+ if (v) {
9456
+ const C = v.selectionStart || 0, j = v.value || "", I = v.selectionEnd || C;
9457
+ if (I > C) {
9458
+ const O = `{{${y}}}`, { text: P } = E(j, C, O), $ = j.slice(0, C) + P + j.slice(I);
9561
9459
  p($);
9562
9460
  return;
9563
9461
  }
9564
- const R = `{{${C}}}`, { text: T } = N(_, k, R), D = _.slice(0, k) + T + _.slice(k);
9462
+ const R = `{{${y}}}`, { text: T } = E(j, C, R), D = j.slice(0, C) + T + j.slice(C);
9565
9463
  p(D);
9566
9464
  }
9567
9465
  }, []);
@@ -9569,8 +9467,8 @@ const AiAssistant = () => {
9569
9467
  /* @__PURE__ */ jsxs(
9570
9468
  "form",
9571
9469
  {
9572
- onSubmit: (C) => {
9573
- C.preventDefault(), u !== null ? A() : b();
9470
+ onSubmit: (y) => {
9471
+ y.preventDefault(), u !== null ? _() : b();
9574
9472
  },
9575
9473
  className: "space-y-3",
9576
9474
  children: [
@@ -9584,9 +9482,9 @@ const AiAssistant = () => {
9584
9482
  autoCorrect: "off",
9585
9483
  spellCheck: "false",
9586
9484
  id: "attrKey",
9587
- ref: x,
9485
+ ref: f,
9588
9486
  value: i,
9589
- onChange: (C) => c(C.target.value),
9487
+ onChange: (y) => c(y.target.value),
9590
9488
  placeholder: "Enter Key",
9591
9489
  className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
9592
9490
  }
@@ -9595,7 +9493,7 @@ const AiAssistant = () => {
9595
9493
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9596
9494
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9597
9495
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9598
- !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: w })
9496
+ !isEmpty(k) && /* @__PURE__ */ jsx(NestedPathSelector, { data: k, onSelect: w })
9599
9497
  ] }),
9600
9498
  /* @__PURE__ */ jsx(
9601
9499
  Textarea,
@@ -9605,10 +9503,10 @@ const AiAssistant = () => {
9605
9503
  spellCheck: "false",
9606
9504
  id: "attrValue",
9607
9505
  rows: 2,
9608
- ref: f,
9506
+ ref: x,
9609
9507
  value: d,
9610
- onChange: (C) => p(C.target.value),
9611
- onKeyDown: j,
9508
+ onChange: (y) => p(y.target.value),
9509
+ onKeyDown: N,
9612
9510
  placeholder: "Enter Value",
9613
9511
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
9614
9512
  }
@@ -9620,16 +9518,16 @@ const AiAssistant = () => {
9620
9518
  ]
9621
9519
  }
9622
9520
  ),
9623
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((C, v) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9521
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((y, S) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9624
9522
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9625
- /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: C.key }),
9626
- /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: C.value.toString() })
9523
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: y.key }),
9524
+ /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: y.value.toString() })
9627
9525
  ] }),
9628
9526
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9629
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => E(v), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9630
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(v), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9527
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(S), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9528
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(S), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9631
9529
  ] })
9632
- ] }, v)) })
9530
+ ] }, S)) })
9633
9531
  ] });
9634
9532
  }), BlockAttributesEditor = React.memo(() => {
9635
9533
  const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9791,42 +9689,42 @@ const RootLayout = () => {
9791
9689
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9792
9690
  n("outline");
9793
9691
  });
9794
- const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((C) => {
9795
- C.preventDefault();
9692
+ const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((y) => {
9693
+ y.preventDefault();
9796
9694
  }, []), m = useCallback(
9797
- (C) => {
9798
- n(r === C ? null : C);
9695
+ (y) => {
9696
+ n(r === y ? null : y);
9799
9697
  },
9800
9698
  [r]
9801
- ), { t: x } = useTranslation(), f = useMemo(
9699
+ ), { t: f } = useTranslation(), x = useMemo(
9802
9700
  () => [...p, ...u, ...g],
9803
9701
  [p, u, g]
9804
- ), y = useBuilderProp("htmlDir", "ltr"), b = find(f, { id: r }) ?? first(f), B = get(b, "width", DEFAULT_PANEL_WIDTH);
9702
+ ), k = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: r }) ?? first(x), A = get(b, "width", DEFAULT_PANEL_WIDTH);
9805
9703
  useEffect(() => {
9806
9704
  if (r !== null) {
9807
- const C = find(f, { id: r });
9808
- C && get(C, "view", "standard") === "standard" && (a.current = r, i(get(C, "width", DEFAULT_PANEL_WIDTH)));
9705
+ const y = find(x, { id: r });
9706
+ y && get(y, "view", "standard") === "standard" && (a.current = r, i(get(y, "width", DEFAULT_PANEL_WIDTH)));
9809
9707
  }
9810
- }, [r, f]);
9811
- const E = useMemo(() => {
9708
+ }, [r, x]);
9709
+ const B = useMemo(() => {
9812
9710
  if (r === null) return 0;
9813
- const C = find(f, { id: r });
9814
- return get(C, "view", "standard") === "standard" ? B : l;
9815
- }, [r, B, l, f]), A = useCallback(() => {
9711
+ const y = find(x, { id: r });
9712
+ return get(y, "view", "standard") === "standard" ? A : l;
9713
+ }, [r, A, l, x]), _ = useCallback(() => {
9816
9714
  n(a.current);
9817
- }, [n]), j = useCallback(() => {
9715
+ }, [n]), N = useCallback(() => {
9818
9716
  n("outline");
9819
9717
  }, [n]);
9820
9718
  useEffect(() => {
9821
- find(f, { id: r }) || n("outline");
9822
- }, [r, f]);
9719
+ find(x, { id: r }) || n("outline");
9720
+ }, [r, x]);
9823
9721
  const w = useCallback(
9824
- (C) => {
9825
- m(C);
9722
+ (y) => {
9723
+ m(y);
9826
9724
  },
9827
9725
  [m]
9828
9726
  );
9829
- return /* @__PURE__ */ jsx("div", { dir: y, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9727
+ return /* @__PURE__ */ jsx("div", { dir: k, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9830
9728
  /* @__PURE__ */ jsxs(
9831
9729
  "div",
9832
9730
  {
@@ -9836,40 +9734,40 @@ const RootLayout = () => {
9836
9734
  /* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
9837
9735
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9838
9736
  /* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9839
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((C, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9840
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(C, "button", NoopComponent), {
9737
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((y, S) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9738
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
9841
9739
  position: "top",
9842
- panelId: C.id,
9843
- isActive: r === C.id,
9844
- show: () => w(C.id)
9740
+ panelId: y.id,
9741
+ isActive: r === y.id,
9742
+ show: () => w(y.id)
9845
9743
  }) }),
9846
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(C.label) }) })
9847
- ] }, "button-top-" + v)) }),
9744
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(y.label) }) })
9745
+ ] }, "button-top-" + S)) }),
9848
9746
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9849
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((C, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9850
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(C, "button", NoopComponent), {
9747
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((y, S) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9748
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
9851
9749
  position: "bottom",
9852
- panelId: C.id,
9853
- isActive: r === C.id,
9854
- show: () => w(C.id)
9750
+ panelId: y.id,
9751
+ isActive: r === y.id,
9752
+ show: () => w(y.id)
9855
9753
  }) }),
9856
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(C.label) }) })
9857
- ] }, "button-bottom-" + v)) })
9754
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(y.label) }) })
9755
+ ] }, "button-bottom-" + S)) })
9858
9756
  ] }),
9859
9757
  /* @__PURE__ */ jsx(
9860
9758
  motion.div,
9861
9759
  {
9862
9760
  id: "left-panel",
9863
9761
  className: "h-full max-h-full border-r border-border",
9864
- initial: { width: E },
9865
- animate: { width: E },
9762
+ initial: { width: B },
9763
+ animate: { width: B },
9866
9764
  transition: { duration: 0.3, ease: "easeInOut" },
9867
9765
  children: r !== null && get(b, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
9868
9766
  /* @__PURE__ */ jsx(
9869
9767
  "div",
9870
9768
  {
9871
9769
  className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(b, "isInternal", !1) ? "" : "w-64"}`,
9872
- children: /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
9770
+ children: /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9873
9771
  }
9874
9772
  ),
9875
9773
  /* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {}) }) })
@@ -9892,11 +9790,11 @@ const RootLayout = () => {
9892
9790
  /* @__PURE__ */ jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between gap-2", children: c === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9893
9791
  /* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
9894
9792
  " ",
9895
- x("AI Assistant")
9793
+ f("AI Assistant")
9896
9794
  ] }) }) : c === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
9897
9795
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
9898
9796
  /* @__PURE__ */ jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
9899
- x("Theme Settings")
9797
+ f("Theme Settings")
9900
9798
  ] }),
9901
9799
  /* @__PURE__ */ jsx(
9902
9800
  Button,
@@ -9918,31 +9816,31 @@ const RootLayout = () => {
9918
9816
  }
9919
9817
  ),
9920
9818
  /* @__PURE__ */ jsx(AddBlocksDialog, {}),
9921
- r !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => A(), children: /* @__PURE__ */ jsxs(
9819
+ r !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(
9922
9820
  SheetContent,
9923
9821
  {
9924
9822
  side: "left",
9925
9823
  className: "flex flex-col gap-0 p-0 sm:max-w-full",
9926
- style: { width: `${B}px` },
9824
+ style: { width: `${A}px` },
9927
9825
  children: [
9928
9826
  /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
9929
9827
  /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
9930
- /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
9828
+ /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9931
9829
  ] }) }),
9932
9830
  /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
9933
- close: j
9831
+ close: N
9934
9832
  }) }) })
9935
9833
  ]
9936
9834
  }
9937
9835
  ) }),
9938
9836
  " ",
9939
- r !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => A(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${B}px` }, children: [
9837
+ r !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${A}px` }, children: [
9940
9838
  /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
9941
9839
  /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
9942
- /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
9840
+ /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9943
9841
  ] }) }),
9944
9842
  /* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
9945
- close: j
9843
+ close: N
9946
9844
  }) }) })
9947
9845
  ] }) }),
9948
9846
  r !== null && get(b, "view") === "overlay" && /* @__PURE__ */ jsx(
@@ -9965,12 +9863,12 @@ const RootLayout = () => {
9965
9863
  /* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
9966
9864
  /* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
9967
9865
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9968
- /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
9866
+ /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9969
9867
  ] }),
9970
- /* @__PURE__ */ jsx(Button, { onClick: () => A(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
9868
+ /* @__PURE__ */ jsx(Button, { onClick: () => _(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
9971
9869
  ] }),
9972
9870
  /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
9973
- close: j
9871
+ close: N
9974
9872
  }) }) })
9975
9873
  ]
9976
9874
  }
@@ -10009,36 +9907,36 @@ const RootLayout = () => {
10009
9907
  }) => {
10010
9908
  const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
10011
9909
  if (!l.trim()) return a;
10012
- const f = l.toLowerCase();
9910
+ const x = l.toLowerCase();
10013
9911
  return Object.fromEntries(
10014
- Object.entries(a).filter(([y, b]) => {
10015
- var B;
10016
- return (y == null ? void 0 : y.toLowerCase().includes(f)) || ((B = b == null ? void 0 : b.description) == null ? void 0 : B.toLowerCase().includes(f));
9912
+ Object.entries(a).filter(([k, b]) => {
9913
+ var A;
9914
+ return (k == null ? void 0 : k.toLowerCase().includes(x)) || ((A = b == null ? void 0 : b.description) == null ? void 0 : A.toLowerCase().includes(x));
10017
9915
  })
10018
9916
  );
10019
- }, [a, l]), h = (f) => {
9917
+ }, [a, l]), h = (x) => {
10020
9918
  d(!0), u({
10021
- x: f.clientX - r.x,
10022
- y: f.clientY - r.y
9919
+ x: x.clientX - r.x,
9920
+ y: x.clientY - r.y
10023
9921
  });
10024
- }, m = (f) => {
9922
+ }, m = (x) => {
10025
9923
  if (!c) return;
10026
- const y = f.clientX - p.x, b = f.clientY - p.y, B = f.currentTarget, E = B.offsetWidth, A = B.offsetHeight, j = window.innerWidth - E, w = window.innerHeight - A, C = Math.max(0, Math.min(y, j)), v = Math.max(0, Math.min(b, w));
10027
- n(C, v);
10028
- }, x = () => {
9924
+ const k = x.clientX - p.x, b = x.clientY - p.y, A = x.currentTarget, B = A.offsetWidth, _ = A.offsetHeight, N = window.innerWidth - B, w = window.innerHeight - _, y = Math.max(0, Math.min(k, N)), S = Math.max(0, Math.min(b, w));
9925
+ n(y, S);
9926
+ }, f = () => {
10029
9927
  d(!1);
10030
9928
  };
10031
9929
  return useEffect(() => {
10032
- const f = () => {
9930
+ const x = () => {
10033
9931
  c && d(!1);
10034
9932
  };
10035
- return window.addEventListener("mouseup", f), () => window.removeEventListener("mouseup", f);
9933
+ return window.addEventListener("mouseup", x), () => window.removeEventListener("mouseup", x);
10036
9934
  }, [c]), !r || r.x < 0 || r.y < 0 ? null : /* @__PURE__ */ jsxs(
10037
9935
  "div",
10038
9936
  {
10039
9937
  onMouseDown: h,
10040
9938
  onMouseMove: m,
10041
- onMouseUp: x,
9939
+ onMouseUp: f,
10042
9940
  className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
10043
9941
  style: {
10044
9942
  left: r.x,
@@ -10080,13 +9978,13 @@ const RootLayout = () => {
10080
9978
  placeholder: "Search features...",
10081
9979
  className: "w-full pl-8",
10082
9980
  value: l,
10083
- onChange: (f) => i(f.target.value),
9981
+ onChange: (x) => i(x.target.value),
10084
9982
  autoFocus: !0
10085
9983
  }
10086
9984
  )
10087
9985
  ] })
10088
9986
  ] }),
10089
- /* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(g).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(g).map(([f, y]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: f, options: y }, f)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
9987
+ /* @__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, k]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: x, options: k }, x)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
10090
9988
  'No features found matching "',
10091
9989
  l,
10092
9990
  '"'
@@ -10197,92 +10095,92 @@ const RootLayout = () => {
10197
10095
  for (const i of r.p)
10198
10096
  l.add(i);
10199
10097
  return l;
10200
- }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...x) => m.read(...x), p = (m, ...x) => m.write(...x), u = (m, x) => {
10201
- var f;
10202
- return (f = m.unstable_onInit) == null ? void 0 : f.call(m, x);
10203
- }, g = (m, x) => {
10204
- var f;
10205
- return (f = m.onMount) == null ? void 0 : f.call(m, x);
10098
+ }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...f) => m.read(...f), p = (m, ...f) => m.write(...f), u = (m, f) => {
10099
+ var x;
10100
+ return (x = m.unstable_onInit) == null ? void 0 : x.call(m, f);
10101
+ }, g = (m, f) => {
10102
+ var x;
10103
+ return (x = m.onMount) == null ? void 0 : x.call(m, f);
10206
10104
  }, ...h) => {
10207
- const m = h[0] || ((v) => {
10208
- let N = o.get(v);
10209
- return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(v, N), u == null || u(v, C)), N;
10210
- }), x = h[1] || (() => {
10211
- let v, N;
10212
- const S = (k) => {
10105
+ const m = h[0] || ((S) => {
10106
+ let E = o.get(S);
10107
+ return E || (E = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(S, E), u == null || u(S, y)), E;
10108
+ }), f = h[1] || (() => {
10109
+ let S, E;
10110
+ const v = (C) => {
10213
10111
  try {
10214
- k();
10215
- } catch (_) {
10216
- v || (v = !0, N = _);
10112
+ C();
10113
+ } catch (j) {
10114
+ S || (S = !0, E = j);
10217
10115
  }
10218
10116
  };
10219
10117
  do {
10220
- c.f && S(c.f);
10221
- const k = /* @__PURE__ */ new Set(), _ = k.add.bind(k);
10118
+ c.f && v(c.f);
10119
+ const C = /* @__PURE__ */ new Set(), j = C.add.bind(C);
10222
10120
  a.forEach((I) => {
10223
10121
  var L;
10224
- return (L = r.get(I)) == null ? void 0 : L.l.forEach(_);
10225
- }), a.clear(), i.forEach(_), i.clear(), l.forEach(_), l.clear(), k.forEach(S), a.size && f();
10122
+ return (L = r.get(I)) == null ? void 0 : L.l.forEach(j);
10123
+ }), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), C.forEach(v), a.size && x();
10226
10124
  } while (a.size || i.size || l.size);
10227
- if (v)
10228
- throw N;
10229
- }), f = h[2] || (() => {
10230
- const v = [], N = /* @__PURE__ */ new WeakSet(), S = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
10231
- for (; k.length; ) {
10232
- const _ = k[k.length - 1], I = m(_);
10233
- if (S.has(_)) {
10234
- k.pop();
10125
+ if (S)
10126
+ throw E;
10127
+ }), x = h[2] || (() => {
10128
+ const S = [], E = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), C = Array.from(a);
10129
+ for (; C.length; ) {
10130
+ const j = C[C.length - 1], I = m(j);
10131
+ if (v.has(j)) {
10132
+ C.pop();
10235
10133
  continue;
10236
10134
  }
10237
- if (N.has(_)) {
10238
- n.get(_) === I.n && v.push([_, I]), S.add(_), k.pop();
10135
+ if (E.has(j)) {
10136
+ n.get(j) === I.n && S.push([j, I]), v.add(j), C.pop();
10239
10137
  continue;
10240
10138
  }
10241
- N.add(_);
10242
- for (const L of getMountedOrPendingDependents(_, I, r))
10243
- N.has(L) || k.push(L);
10139
+ E.add(j);
10140
+ for (const L of getMountedOrPendingDependents(j, I, r))
10141
+ E.has(L) || C.push(L);
10244
10142
  }
10245
- for (let _ = v.length - 1; _ >= 0; --_) {
10246
- const [I, L] = v[_];
10143
+ for (let j = S.length - 1; j >= 0; --j) {
10144
+ const [I, L] = S[j];
10247
10145
  let R = !1;
10248
10146
  for (const T of L.d.keys())
10249
10147
  if (T !== I && a.has(T)) {
10250
10148
  R = !0;
10251
10149
  break;
10252
10150
  }
10253
- R && (y(I), E(I)), n.delete(I);
10151
+ R && (k(I), B(I)), n.delete(I);
10254
10152
  }
10255
- }), y = h[3] || ((v) => {
10256
- var N, S;
10257
- const k = m(v);
10258
- if (isAtomStateInitialized(k) && (r.has(v) && n.get(v) !== k.n || Array.from(k.d).every(
10153
+ }), k = h[3] || ((S) => {
10154
+ var E, v;
10155
+ const C = m(S);
10156
+ if (isAtomStateInitialized(C) && (r.has(S) && n.get(S) !== C.n || Array.from(C.d).every(
10259
10157
  ([P, $]) => (
10260
10158
  // Recursively, read the atom state of the dependency, and
10261
10159
  // check if the atom epoch number is unchanged
10262
- y(P).n === $
10160
+ k(P).n === $
10263
10161
  )
10264
10162
  )))
10265
- return k;
10266
- k.d.clear();
10267
- let _ = !0;
10163
+ return C;
10164
+ C.d.clear();
10165
+ let j = !0;
10268
10166
  const I = () => {
10269
- r.has(v) && (E(v), f(), x());
10167
+ r.has(S) && (B(S), x(), f());
10270
10168
  }, L = (P) => {
10271
10169
  var $;
10272
- if (isSelfAtom(v, P)) {
10273
- const V = m(P);
10274
- if (!isAtomStateInitialized(V))
10170
+ if (isSelfAtom(S, P)) {
10171
+ const H = m(P);
10172
+ if (!isAtomStateInitialized(H))
10275
10173
  if (hasInitialValue(P))
10276
10174
  setAtomStateValueOrPromise(P, P.init, m);
10277
10175
  else
10278
10176
  throw new Error("no atom init");
10279
- return returnAtomValue(V);
10177
+ return returnAtomValue(H);
10280
10178
  }
10281
- const M = y(P);
10179
+ const M = k(P);
10282
10180
  try {
10283
10181
  return returnAtomValue(M);
10284
10182
  } finally {
10285
- k.d.set(P, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(v, k.v, M), ($ = r.get(P)) == null || $.t.add(v), _ || I();
10183
+ C.d.set(P, M.n), isPendingPromise(C.v) && addPendingPromiseToDependency(S, C.v, M), ($ = r.get(P)) == null || $.t.add(S), j || I();
10286
10184
  }
10287
10185
  };
10288
10186
  let R, T;
@@ -10291,100 +10189,100 @@ const RootLayout = () => {
10291
10189
  return R || (R = new AbortController()), R.signal;
10292
10190
  },
10293
10191
  get setSelf() {
10294
- return !T && isActuallyWritableAtom(v) && (T = (...P) => {
10295
- if (!_)
10192
+ return !T && isActuallyWritableAtom(S) && (T = (...P) => {
10193
+ if (!j)
10296
10194
  try {
10297
- return B(v, ...P);
10195
+ return A(S, ...P);
10298
10196
  } finally {
10299
- f(), x();
10197
+ x(), f();
10300
10198
  }
10301
10199
  }), T;
10302
10200
  }
10303
- }, O = k.n;
10201
+ }, O = C.n;
10304
10202
  try {
10305
- const P = d(v, L, D);
10306
- return setAtomStateValueOrPromise(v, P, m), isPromiseLike$1(P) && ((N = P.onCancel) == null || N.call(P, () => R == null ? void 0 : R.abort()), P.then(
10203
+ const P = d(S, L, D);
10204
+ return setAtomStateValueOrPromise(S, P, m), isPromiseLike$1(P) && ((E = P.onCancel) == null || E.call(P, () => R == null ? void 0 : R.abort()), P.then(
10307
10205
  I,
10308
10206
  I
10309
- )), k;
10207
+ )), C;
10310
10208
  } catch (P) {
10311
- return delete k.v, k.e = P, ++k.n, k;
10209
+ return delete C.v, C.e = P, ++C.n, C;
10312
10210
  } finally {
10313
- _ = !1, O !== k.n && n.get(v) === O && (n.set(v, k.n), a.add(v), (S = c.c) == null || S.call(c, v));
10211
+ j = !1, O !== C.n && n.get(S) === O && (n.set(S, C.n), a.add(S), (v = c.c) == null || v.call(c, S));
10314
10212
  }
10315
- }), b = h[4] || ((v) => {
10316
- const N = [v];
10317
- for (; N.length; ) {
10318
- const S = N.pop(), k = m(S);
10319
- for (const _ of getMountedOrPendingDependents(S, k, r)) {
10320
- const I = m(_);
10321
- n.set(_, I.n), N.push(_);
10213
+ }), b = h[4] || ((S) => {
10214
+ const E = [S];
10215
+ for (; E.length; ) {
10216
+ const v = E.pop(), C = m(v);
10217
+ for (const j of getMountedOrPendingDependents(v, C, r)) {
10218
+ const I = m(j);
10219
+ n.set(j, I.n), E.push(j);
10322
10220
  }
10323
10221
  }
10324
- }), B = h[5] || ((v, ...N) => {
10325
- let S = !0;
10326
- const k = (I) => returnAtomValue(y(I)), _ = (I, ...L) => {
10222
+ }), A = h[5] || ((S, ...E) => {
10223
+ let v = !0;
10224
+ const C = (I) => returnAtomValue(k(I)), j = (I, ...L) => {
10327
10225
  var R;
10328
10226
  const T = m(I);
10329
10227
  try {
10330
- if (isSelfAtom(v, I)) {
10228
+ if (isSelfAtom(S, I)) {
10331
10229
  if (!hasInitialValue(I))
10332
10230
  throw new Error("atom not writable");
10333
10231
  const D = T.n, O = L[0];
10334
- setAtomStateValueOrPromise(I, O, m), E(I), D !== T.n && (a.add(I), (R = c.c) == null || R.call(c, I), b(I));
10232
+ setAtomStateValueOrPromise(I, O, m), B(I), D !== T.n && (a.add(I), (R = c.c) == null || R.call(c, I), b(I));
10335
10233
  return;
10336
10234
  } else
10337
- return B(I, ...L);
10235
+ return A(I, ...L);
10338
10236
  } finally {
10339
- S || (f(), x());
10237
+ v || (x(), f());
10340
10238
  }
10341
10239
  };
10342
10240
  try {
10343
- return p(v, k, _, ...N);
10241
+ return p(S, C, j, ...E);
10344
10242
  } finally {
10345
- S = !1;
10243
+ v = !1;
10346
10244
  }
10347
- }), E = h[6] || ((v) => {
10348
- var N;
10349
- const S = m(v), k = r.get(v);
10350
- if (k && !isPendingPromise(S.v)) {
10351
- for (const [_, I] of S.d)
10352
- if (!k.d.has(_)) {
10353
- const L = m(_);
10354
- A(_).t.add(v), k.d.add(_), I !== L.n && (a.add(_), (N = c.c) == null || N.call(c, _), b(_));
10245
+ }), B = h[6] || ((S) => {
10246
+ var E;
10247
+ const v = m(S), C = r.get(S);
10248
+ if (C && !isPendingPromise(v.v)) {
10249
+ for (const [j, I] of v.d)
10250
+ if (!C.d.has(j)) {
10251
+ const L = m(j);
10252
+ _(j).t.add(S), C.d.add(j), I !== L.n && (a.add(j), (E = c.c) == null || E.call(c, j), b(j));
10355
10253
  }
10356
- for (const _ of k.d || [])
10357
- if (!S.d.has(_)) {
10358
- k.d.delete(_);
10359
- const I = j(_);
10360
- I == null || I.t.delete(v);
10254
+ for (const j of C.d || [])
10255
+ if (!v.d.has(j)) {
10256
+ C.d.delete(j);
10257
+ const I = N(j);
10258
+ I == null || I.t.delete(S);
10361
10259
  }
10362
10260
  }
10363
- }), A = h[7] || ((v) => {
10364
- var N;
10365
- const S = m(v);
10366
- let k = r.get(v);
10367
- if (!k) {
10368
- y(v);
10369
- for (const _ of S.d.keys())
10370
- A(_).t.add(v);
10371
- if (k = {
10261
+ }), _ = h[7] || ((S) => {
10262
+ var E;
10263
+ const v = m(S);
10264
+ let C = r.get(S);
10265
+ if (!C) {
10266
+ k(S);
10267
+ for (const j of v.d.keys())
10268
+ _(j).t.add(S);
10269
+ if (C = {
10372
10270
  l: /* @__PURE__ */ new Set(),
10373
- d: new Set(S.d.keys()),
10271
+ d: new Set(v.d.keys()),
10374
10272
  t: /* @__PURE__ */ new Set()
10375
- }, r.set(v, k), (N = c.m) == null || N.call(c, v), isActuallyWritableAtom(v)) {
10376
- const _ = () => {
10273
+ }, r.set(S, C), (E = c.m) == null || E.call(c, S), isActuallyWritableAtom(S)) {
10274
+ const j = () => {
10377
10275
  let I = !0;
10378
10276
  const L = (...R) => {
10379
10277
  try {
10380
- return B(v, ...R);
10278
+ return A(S, ...R);
10381
10279
  } finally {
10382
- I || (f(), x());
10280
+ I || (x(), f());
10383
10281
  }
10384
10282
  };
10385
10283
  try {
10386
- const R = g(v, L);
10387
- R && (k.u = () => {
10284
+ const R = g(S, L);
10285
+ R && (C.u = () => {
10388
10286
  I = !0;
10389
10287
  try {
10390
10288
  R();
@@ -10396,26 +10294,26 @@ const RootLayout = () => {
10396
10294
  I = !1;
10397
10295
  }
10398
10296
  };
10399
- l.add(_);
10297
+ l.add(j);
10400
10298
  }
10401
10299
  }
10402
- return k;
10403
- }), j = h[8] || ((v) => {
10404
- var N;
10405
- const S = m(v);
10406
- let k = r.get(v);
10407
- if (k && !k.l.size && !Array.from(k.t).some((_) => {
10300
+ return C;
10301
+ }), N = h[8] || ((S) => {
10302
+ var E;
10303
+ const v = m(S);
10304
+ let C = r.get(S);
10305
+ if (C && !C.l.size && !Array.from(C.t).some((j) => {
10408
10306
  var I;
10409
- return (I = r.get(_)) == null ? void 0 : I.d.has(v);
10307
+ return (I = r.get(j)) == null ? void 0 : I.d.has(S);
10410
10308
  })) {
10411
- k.u && i.add(k.u), k = void 0, r.delete(v), (N = c.u) == null || N.call(c, v);
10412
- for (const _ of S.d.keys()) {
10413
- const I = j(_);
10414
- I == null || I.t.delete(v);
10309
+ C.u && i.add(C.u), C = void 0, r.delete(S), (E = c.u) == null || E.call(c, S);
10310
+ for (const j of v.d.keys()) {
10311
+ const I = N(j);
10312
+ I == null || I.t.delete(S);
10415
10313
  }
10416
10314
  return;
10417
10315
  }
10418
- return k;
10316
+ return C;
10419
10317
  }), w = [
10420
10318
  // store state
10421
10319
  o,
@@ -10432,31 +10330,31 @@ const RootLayout = () => {
10432
10330
  g,
10433
10331
  // building-block functions
10434
10332
  m,
10435
- x,
10436
10333
  f,
10437
- y,
10334
+ x,
10335
+ k,
10438
10336
  b,
10439
- B,
10440
- E,
10441
10337
  A,
10442
- j
10443
- ], C = {
10444
- get: (v) => returnAtomValue(y(v)),
10445
- set: (v, ...N) => {
10338
+ B,
10339
+ _,
10340
+ N
10341
+ ], y = {
10342
+ get: (S) => returnAtomValue(k(S)),
10343
+ set: (S, ...E) => {
10446
10344
  try {
10447
- return B(v, ...N);
10345
+ return A(S, ...E);
10448
10346
  } finally {
10449
- f(), x();
10347
+ x(), f();
10450
10348
  }
10451
10349
  },
10452
- sub: (v, N) => {
10453
- const k = A(v).l;
10454
- return k.add(N), x(), () => {
10455
- k.delete(N), j(v), x();
10350
+ sub: (S, E) => {
10351
+ const C = _(S).l;
10352
+ return C.add(E), f(), () => {
10353
+ C.delete(E), N(S), f();
10456
10354
  };
10457
10355
  }
10458
10356
  };
10459
- return Object.defineProperty(C, BUILDING_BLOCKS, { value: w }), C;
10357
+ return Object.defineProperty(y, BUILDING_BLOCKS, { value: w }), y;
10460
10358
  }, INTERNAL_buildStoreRev1 = buildStore, createStore = () => INTERNAL_buildStoreRev1();
10461
10359
  let defaultStore;
10462
10360
  const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), defaultStore), StoreContext = createContext(
@@ -10668,7 +10566,7 @@ export {
10668
10566
  useTheme,
10669
10567
  useThemeOptions,
10670
10568
  useToggleChaiFeatureFlag,
10671
- He as useTranslation,
10569
+ Ue as useTranslation,
10672
10570
  useUndoManager,
10673
10571
  useUpdateBlocksProps,
10674
10572
  useUpdateBlocksPropsRealtime,