@chaibuilder/sdk 2.4.4 → 2.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -10,8 +10,8 @@ import React__default, { useMemo, useCallback, useEffect, useState, useRef, Comp
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, 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";
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, aX as Slider, aB as Select$1, aJ as SelectTrigger, aK as SelectValue, aC as SelectContent, aE as SelectItem, aL as Separator, aY as Switch, g as AlertDialog, q as AlertDialogTrigger, j as AlertDialogContent, m as AlertDialogHeader, p as AlertDialogTitle, k as AlertDialogDescription, l as AlertDialogFooter, i as AlertDialogCancel, h as AlertDialogAction, r as Avatar, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle } from "./toggle-CyXEVUOu.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, Type, CornerUpRight, Palette, Sun, Moon, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, 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";
@@ -841,8 +841,8 @@ const undoRedoStateAtom = atom({
841
841
  return {
842
842
  moveBlocks: (x, k, b) => {
843
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 };
844
+ const w = r.find((E) => E._id === _)._parent || null, C = r.filter((E) => w ? E._parent === w : !E._parent).map((E) => E._id).indexOf(_);
845
+ return { _id: _, oldParent: w, oldPosition: C };
846
846
  }), B = A.find(({ _id: _ }) => _ === x[0]);
847
847
  B && B.oldParent === k && B.oldPosition === b || (i(x, k, b), o({
848
848
  undo: () => each(A, ({ _id: _, oldParent: N, oldPosition: w }) => {
@@ -2385,8 +2385,8 @@ const getBlockWithChildren = (o, r) => {
2385
2385
  }
2386
2386
  if (m === "styles") {
2387
2387
  const w = _.map((y) => {
2388
- for (const S in y)
2389
- S !== "_id" && (y[S] = `${STYLES_KEY},${y[S]}`);
2388
+ for (const C in y)
2389
+ C !== "_id" && (y[C] = `${STYLES_KEY},${y[C]}`);
2390
2390
  return y;
2391
2391
  });
2392
2392
  c(w);
@@ -3598,26 +3598,26 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3598
3598
  ({ block: o, children: r }) => {
3599
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
3600
  var j;
3601
- const S = o._type;
3601
+ const C = o._type;
3602
3602
  let E = o[n];
3603
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 };
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: C };
3605
3605
  }, [o, f]), _ = useCallback(
3606
- (S) => {
3606
+ (C) => {
3607
3607
  var v;
3608
- const E = S || ((v = g.current) == null ? void 0 : v.innerText);
3608
+ const E = C || ((v = g.current) == null ? void 0 : v.innerText);
3609
3609
  m([b], { [n]: E }), u(null), c(null), d(-1), x([]);
3610
3610
  },
3611
3611
  [b, m, c, x, f]
3612
3612
  ), N = useDebouncedCallback(
3613
- (S) => {
3614
- m([b], { [n]: S });
3613
+ (C) => {
3614
+ m([b], { [n]: C });
3615
3615
  },
3616
3616
  [b, o, m, f],
3617
3617
  1e3
3618
3618
  ), w = useCallback(
3619
- (S) => {
3620
- S.preventDefault(), b && (k.current = b), _(), setTimeout(() => {
3619
+ (C) => {
3620
+ C.preventDefault(), b && (k.current = b), _(), setTimeout(() => {
3621
3621
  const E = k.current;
3622
3622
  k.current = null, x([E]);
3623
3623
  }, 100);
@@ -3625,10 +3625,10 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3625
3625
  [x, b, f]
3626
3626
  );
3627
3627
  useEffect(() => {
3628
- var C;
3628
+ var S;
3629
3629
  if (!b) return;
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));
3630
+ const C = `[data-block-id="${b}"]`, E = i >= 0 ? `[data-block-index="${i}"]` : "", v = a.querySelector(`${C}${E}`);
3631
+ v && ((S = v == null ? void 0 : v.classList) == null || S.add("sr-only"), u(v));
3632
3632
  }, [b, B, a, i]);
3633
3633
  const y = useMemo(() => p ? (h(), B === "RichText" ? /* @__PURE__ */ jsx(
3634
3634
  RichTextEditor,
@@ -3894,7 +3894,7 @@ const CanvasEventsWatcher = () => {
3894
3894
  }, FallbackError = () => /* @__PURE__ */ jsx("div", { className: "h-full w-full rounded-md bg-red-200 p-4 text-red-500", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center", children: [
3895
3895
  /* @__PURE__ */ jsx("p", { className: "font-semibold", children: "Oops! Something went wrong." }),
3896
3896
  /* @__PURE__ */ jsx("p", { children: "Please try again." })
3897
- ] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-CJfScsxg.js")), CanvasArea = () => {
3897
+ ] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-0HrsuGAE.js")), CanvasArea = () => {
3898
3898
  const [o] = useCodeEditor(), r = useBuilderProp("onError", noop);
3899
3899
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2", children: [
3900
3900
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -4206,11 +4206,11 @@ const DataBindingSelector = ({
4206
4206
  if (B !== _)
4207
4207
  b.chain().deleteSelection().insertContent(A).run();
4208
4208
  else {
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));
4209
+ const { state: w } = b, y = w.selection.from, C = w.doc.textBetween(Math.max(0, y - 1), y), E = w.doc.textBetween(y, Math.min(y + 1, w.doc.content.size));
4210
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();
4211
+ y > 0 && C !== " " && !m(C) && (v = " ");
4212
+ let S = "";
4213
+ E && E !== " " && !m(E) && (S = " "), b.chain().insertContent(v + A + S).run();
4214
4214
  }
4215
4215
  setTimeout(() => r(b.getHTML(), {}, n), 100);
4216
4216
  return;
@@ -4218,12 +4218,12 @@ const DataBindingSelector = ({
4218
4218
  } else {
4219
4219
  const b = x, A = b.selectionStart || 0, B = b.value || "", _ = b.selectionEnd || A;
4220
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);
4221
+ const E = `{{${g}}}`, { text: v } = f(B, A, E), S = B.slice(0, A) + v + B.slice(_);
4222
+ r(S, {}, n);
4223
4223
  return;
4224
4224
  }
4225
- const w = `{{${g}}}`, { text: y } = f(B, A, w), S = B.slice(0, A) + y + B.slice(A);
4226
- r(S, {}, n);
4225
+ const w = `{{${g}}}`, { text: y } = f(B, A, w), C = B.slice(0, A) + y + B.slice(A);
4226
+ r(C, {}, n);
4227
4227
  }
4228
4228
  },
4229
4229
  [n, r, a, c == null ? void 0 : c._id, d]
@@ -4245,12 +4245,12 @@ const DataBindingSelector = ({
4245
4245
  onChange: n
4246
4246
  }) => {
4247
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;
4248
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, S) => []), [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;
4249
4249
  useEffect(() => {
4250
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")]);
4251
+ const v = split(o, ":"), S = get(v, 1, "page") || "page";
4252
+ g(S), (async () => {
4253
+ const j = await l(S, [get(v, 2, "page")]);
4254
4254
  j && Array.isArray(j) && m(get(j, [0, "name"], ""));
4255
4255
  })();
4256
4256
  }, [o]);
@@ -4259,23 +4259,23 @@ const DataBindingSelector = ({
4259
4259
  if (isEmpty(v))
4260
4260
  x([]);
4261
4261
  else {
4262
- const C = await l(u, v);
4263
- x(C);
4262
+ const S = await l(u, v);
4263
+ x(S);
4264
4264
  }
4265
4265
  c(!1), b(-1);
4266
4266
  },
4267
4267
  [u],
4268
4268
  300
4269
4269
  ), N = (v) => {
4270
- const C = ["pageType", u, v.id];
4271
- C[1] && (n(C.join(":")), m(v.name), p(!1), x([]), b(-1));
4270
+ const S = ["pageType", u, v.id];
4271
+ S[1] && (n(S.join(":")), m(v.name), p(!1), x([]), b(-1));
4272
4272
  }, w = (v) => {
4273
4273
  switch (v.key) {
4274
4274
  case "ArrowDown":
4275
- v.preventDefault(), b((C) => C < f.length - 1 ? C + 1 : C);
4275
+ v.preventDefault(), b((S) => S < f.length - 1 ? S + 1 : S);
4276
4276
  break;
4277
4277
  case "ArrowUp":
4278
- v.preventDefault(), b((C) => C > 0 ? C - 1 : C);
4278
+ v.preventDefault(), b((S) => S > 0 ? S - 1 : S);
4279
4279
  break;
4280
4280
  case "Enter":
4281
4281
  if (v.preventDefault(), f.length === 0) return;
@@ -4294,7 +4294,7 @@ const DataBindingSelector = ({
4294
4294
  }, [k]);
4295
4295
  const y = () => {
4296
4296
  m(""), x([]), b(-1), p(!1), n("");
4297
- }, S = (v) => {
4297
+ }, C = (v) => {
4298
4298
  m(v), p(!isEmpty(v)), c(!0), _(v);
4299
4299
  };
4300
4300
  return /* @__PURE__ */ jsxs("div", { children: [
@@ -4305,7 +4305,7 @@ const DataBindingSelector = ({
4305
4305
  {
4306
4306
  type: "text",
4307
4307
  value: h,
4308
- onChange: (v) => S(v.target.value),
4308
+ onChange: (v) => C(v.target.value),
4309
4309
  onKeyDown: w,
4310
4310
  placeholder: a(`Search ${B ?? ""}`),
4311
4311
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
@@ -4321,11 +4321,11 @@ const DataBindingSelector = ({
4321
4321
  ' "',
4322
4322
  h,
4323
4323
  '"'
4324
- ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(f == null ? void 0 : f.slice(0, 20), (v, C) => /* @__PURE__ */ jsxs(
4324
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(f == null ? void 0 : f.slice(0, 20), (v, S) => /* @__PURE__ */ jsxs(
4325
4325
  "li",
4326
4326
  {
4327
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"}`,
4328
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : S === k ? "bg-gray-100" : "hover:bg-gray-100"}`,
4329
4329
  children: [
4330
4330
  v.name,
4331
4331
  " ",
@@ -5108,11 +5108,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
5108
5108
  }), a;
5109
5109
  };
5110
5110
  function BlockSettings() {
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);
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, C) => {
5112
+ y && (c == null ? void 0 : c._id) === r._id && a([r._id], { [y]: get(w, y) }, C);
5113
5113
  }, x = useCallback(
5114
- debounce(({ formData: w }, y, S) => {
5115
- f({ formData: w }, y, S), d(w);
5114
+ debounce(({ formData: w }, y, C) => {
5115
+ f({ formData: w }, y, C), d(w);
5116
5116
  }, 1500),
5117
5117
  [r == null ? void 0 : r._id, o]
5118
5118
  ), k = ({ formData: w }, y) => {
@@ -5124,20 +5124,20 @@ function BlockSettings() {
5124
5124
  if (!w)
5125
5125
  return { schema: {}, uiSchema: {} };
5126
5126
  try {
5127
- const { schema: y, uiSchema: S } = getBlockFormSchemas(w);
5127
+ const { schema: y, uiSchema: C } = getBlockFormSchemas(w);
5128
5128
  if (w === "Repeater") {
5129
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" }));
5130
+ startsWith(E, `{{${COLLECTION_PREFIX}`) ? (set(C, "filter", { "ui:widget": "collectionSelect" }), set(C, "sort", { "ui:widget": "collectionSelect" })) : (set(C, "filter", { "ui:widget": "hidden" }), set(C, "sort", { "ui:widget": "hidden" }));
5131
5131
  }
5132
- return { schema: y, uiSchema: S };
5132
+ return { schema: y, uiSchema: C };
5133
5133
  } catch {
5134
5134
  return { schema: {}, uiSchema: {} };
5135
5135
  }
5136
5136
  }, [r]), { wrapperSchema: _, wrapperUiSchema: N } = useMemo(() => {
5137
5137
  if (!g || !(g != null && g._type))
5138
5138
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5139
- const w = g == null ? void 0 : g._type, { schema: y = {}, uiSchema: S = {} } = getBlockFormSchemas(w);
5140
- return { wrapperSchema: y, wrapperUiSchema: S };
5139
+ const w = g == null ? void 0 : g._type, { schema: y = {}, uiSchema: C = {} } = getBlockFormSchemas(w);
5140
+ return { wrapperSchema: y, wrapperUiSchema: C };
5141
5141
  }, [g]);
5142
5142
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5143
5143
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
@@ -5390,35 +5390,35 @@ const BlockStylingProps = () => {
5390
5390
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5391
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);
5392
5392
  useEffect(() => {
5393
- const { value: v, unit: C } = getClassValueAndUnit(i);
5394
- if (C === "") {
5393
+ const { value: v, unit: S } = getClassValueAndUnit(i);
5394
+ if (S === "") {
5395
5395
  l(v), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5396
5396
  return;
5397
5397
  }
5398
- m(C), l(C === "class" || isEmpty(v) ? "" : v);
5398
+ m(S), l(S === "class" || isEmpty(v) ? "" : v);
5399
5399
  }, [i, p, u]);
5400
- const w = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), y = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), S = useCallback(
5400
+ const w = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), y = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), C = useCallback(
5401
5401
  (v = !1) => {
5402
- const C = getUserInputValues(`${a}`, u);
5403
- if (get(C, "error", !1)) {
5402
+ const S = getUserInputValues(`${a}`, u);
5403
+ if (get(S, "error", !1)) {
5404
5404
  x(!0);
5405
5405
  return;
5406
5406
  }
5407
- const j = get(C, "unit") !== "" ? get(C, "unit") : h;
5407
+ const j = get(S, "unit") !== "" ? get(S, "unit") : h;
5408
5408
  if (j === "auto" || j === "none") {
5409
5409
  w(`${d}${j}`);
5410
5410
  return;
5411
5411
  }
5412
- if (get(C, "value") === "")
5412
+ if (get(S, "value") === "")
5413
5413
  return;
5414
- const L = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5414
+ const L = `${get(S, "value", "").startsWith("-") ? "-" : ""}${d}[${get(S, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5415
5415
  v ? y(L) : w(L);
5416
5416
  },
5417
5417
  [w, y, a, h, d, u]
5418
5418
  ), E = useCallback(
5419
5419
  (v) => {
5420
- const C = getUserInputValues(`${a}`, u);
5421
- if (get(C, "error", !1)) {
5420
+ const S = getUserInputValues(`${a}`, u);
5421
+ if (get(S, "error", !1)) {
5422
5422
  x(!0);
5423
5423
  return;
5424
5424
  }
@@ -5426,9 +5426,9 @@ const BlockStylingProps = () => {
5426
5426
  w(`${d}${v}`);
5427
5427
  return;
5428
5428
  }
5429
- if (get(C, "value") === "")
5429
+ if (get(S, "value") === "")
5430
5430
  return;
5431
- const j = get(C, "unit") !== "" ? get(C, "unit") : v, L = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5431
+ const j = get(S, "unit") !== "" ? get(S, "unit") : v, L = `${get(S, "value", "").startsWith("-") ? "-" : ""}${d}[${get(S, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5432
5432
  w(L);
5433
5433
  },
5434
5434
  [w, a, d, u]
@@ -5453,28 +5453,28 @@ const BlockStylingProps = () => {
5453
5453
  {
5454
5454
  readOnly: h === "class",
5455
5455
  onKeyPress: (v) => {
5456
- v.key === "Enter" && S();
5456
+ v.key === "Enter" && C();
5457
5457
  },
5458
5458
  onKeyDown: (v) => {
5459
5459
  if (v.keyCode !== 38 && v.keyCode !== 40)
5460
5460
  return;
5461
5461
  v.preventDefault(), N(!0);
5462
- const C = parseInt$1(v.target.value);
5463
- let j = isNaN$1(C) ? 0 : C;
5462
+ const S = parseInt$1(v.target.value);
5463
+ let j = isNaN$1(S) ? 0 : S;
5464
5464
  v.keyCode === 38 && (j += 1), v.keyCode === 40 && (j -= 1);
5465
- const I = `${j}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
5465
+ const T = `${j}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${h === "-" ? "" : h}]`;
5466
5466
  y(R);
5467
5467
  },
5468
5468
  onKeyUp: (v) => {
5469
5469
  _ && (v.preventDefault(), N(!1));
5470
5470
  },
5471
- onBlur: () => S(),
5471
+ onBlur: () => C(),
5472
5472
  onChange: (v) => {
5473
5473
  x(!1), l(v.target.value);
5474
5474
  },
5475
5475
  onClick: (v) => {
5476
- var C;
5477
- (C = v == null ? void 0 : v.target) == null || C.select(), n(!1);
5476
+ var S;
5477
+ (S = v == null ? void 0 : v.target) == null || S.select(), n(!1);
5478
5478
  },
5479
5479
  value: A ? k : a,
5480
5480
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
@@ -5515,15 +5515,15 @@ const BlockStylingProps = () => {
5515
5515
  onDragEnd: (v) => {
5516
5516
  if (b(() => ""), B(!1), isEmpty(v))
5517
5517
  return;
5518
- const C = `${v}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
5519
- w(I);
5518
+ const S = `${v}`, T = `${S.startsWith("-") ? "-" : ""}${d}[${S.replace("-", "")}${h === "-" ? "" : h}]`;
5519
+ w(T);
5520
5520
  },
5521
5521
  onDrag: (v) => {
5522
5522
  if (isEmpty(v))
5523
5523
  return;
5524
5524
  b(v);
5525
- const C = `${v}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
5526
- y(I);
5525
+ const S = `${v}`, T = `${S.startsWith("-") ? "-" : ""}${d}[${S.replace("-", "")}${h === "-" ? "" : h}]`;
5526
+ y(T);
5527
5527
  },
5528
5528
  currentValue: a,
5529
5529
  unit: h,
@@ -5987,11 +5987,11 @@ const COLOR_PROP = {
5987
5987
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
5988
5988
  const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
5989
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) => {
5990
+ (y, C = !0) => {
5991
5991
  const E = { dark: p, mq: g, mod: u, cls: y, property: l, fullCls: "" };
5992
5992
  (p || u !== "") && (E.mq = "xs");
5993
5993
  const v = generateFullClsName(E);
5994
- m(x, [v], S);
5994
+ m(x, [v], C);
5995
5995
  },
5996
5996
  [x, p, g, u, l, m]
5997
5997
  ), A = useCallback(() => {
@@ -6433,15 +6433,15 @@ const AskAIStyles = ({ blockId: o }) => {
6433
6433
  ] });
6434
6434
  };
6435
6435
  function ManualClasses() {
6436
- var I;
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 = () => {
6436
+ var T;
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 = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), A = b.split(" ").filter((L) => !isEmpty(L)), B = () => {
6438
6438
  const L = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6439
6439
  u(h, L, !0), x("");
6440
6440
  }, [_, N] = useState([]), w = ({ value: L }) => {
6441
- const R = L.trim().toLowerCase(), T = R.match(/.+:/g);
6441
+ const R = L.trim().toLowerCase(), I = R.match(/.+:/g);
6442
6442
  let D = [];
6443
- if (T && T.length > 0) {
6444
- const [O] = T, P = R.replace(O, "");
6443
+ if (I && I.length > 0) {
6444
+ const [O] = I, P = R.replace(O, "");
6445
6445
  D = i.search(P).map((M) => ({
6446
6446
  ...M,
6447
6447
  item: { ...M.item, name: O + M.item.name }
@@ -6451,7 +6451,7 @@ function ManualClasses() {
6451
6451
  return N(map(D, "item"));
6452
6452
  }, y = () => {
6453
6453
  N([]);
6454
- }, S = (L) => L.name, E = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), v = useMemo(
6454
+ }, C = (L) => L.name, E = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), v = useMemo(
6455
6455
  () => ({
6456
6456
  ref: o,
6457
6457
  autoComplete: "off",
@@ -6472,7 +6472,7 @@ function ManualClasses() {
6472
6472
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
6473
6473
  }),
6474
6474
  [f, c, o]
6475
- ), C = (L) => {
6475
+ ), S = (L) => {
6476
6476
  debugger;
6477
6477
  const R = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6478
6478
  g(h, [L]), u(h, R, !0), n(""), l(-1);
@@ -6507,7 +6507,7 @@ function ManualClasses() {
6507
6507
  suggestions: _,
6508
6508
  onSuggestionsFetchRequested: w,
6509
6509
  onSuggestionsClearRequested: y,
6510
- getSuggestionValue: S,
6510
+ getSuggestionValue: C,
6511
6511
  renderSuggestion: E,
6512
6512
  inputProps: v,
6513
6513
  containerProps: {
@@ -6538,16 +6538,16 @@ function ManualClasses() {
6538
6538
  {
6539
6539
  ref: o,
6540
6540
  value: r,
6541
- onChange: (T) => n(T.target.value),
6541
+ onChange: (I) => n(I.target.value),
6542
6542
  onBlur: () => {
6543
- C(L);
6543
+ S(L);
6544
6544
  },
6545
- onKeyDown: (T) => {
6546
- T.key === "Enter" && C(L);
6545
+ onKeyDown: (I) => {
6546
+ I.key === "Enter" && S(L);
6547
6547
  },
6548
- onFocus: (T) => {
6548
+ onFocus: (I) => {
6549
6549
  setTimeout(() => {
6550
- T.target.select();
6550
+ I.target.select();
6551
6551
  }, 0);
6552
6552
  },
6553
6553
  className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
@@ -7038,17 +7038,17 @@ const CoreBlock = ({
7038
7038
  }
7039
7039
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
7040
7040
  delete a.styles_attrs;
7041
- const w = filter(n.children || [], (S) => (S == null ? void 0 : S.tagName) !== "span");
7041
+ const w = filter(n.children || [], (C) => (C == null ? void 0 : C.tagName) !== "span");
7042
7042
  a.content = getTextContent(w);
7043
7043
  const y = find(
7044
7044
  n.children || [],
7045
- (S) => (S == null ? void 0 : S.tagName) === "span" && some(S.children || [], (E) => (E == null ? void 0 : E.tagName) === "svg")
7045
+ (C) => (C == null ? void 0 : C.tagName) === "span" && some(C.children || [], (E) => (E == null ? void 0 : E.tagName) === "svg")
7046
7046
  );
7047
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");
7048
+ const C = find(y.children || [], (E) => (E == null ? void 0 : E.tagName) === "svg");
7049
+ if (C) {
7050
+ a.icon = stringify([C]);
7051
+ const { height: E, width: v } = getSvgDimensions(C, "16px", "16px");
7052
7052
  a.iconHeight = E, a.iconWidth = v;
7053
7053
  }
7054
7054
  }
@@ -7061,9 +7061,9 @@ const CoreBlock = ({
7061
7061
  const w = stringify([n]);
7062
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];
7063
7063
  } else if (n.tagName === "svg") {
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", "");
7064
+ const w = get(find(n.attributes, { key: "class" }), "value", ""), { height: y, width: C } = getHeightAndWidthFromClass(w);
7065
+ if (y && C)
7066
+ a.styles = `${STYLES_KEY}, ${cn$2(`w-${C} h-${y}`, w)}`.trim(), a.height = y == null ? void 0 : y.replace("px", ""), a.width = C == null ? void 0 : C.replace("px", "");
7067
7067
  else {
7068
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
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();
@@ -7245,7 +7245,7 @@ const registerChaiLibrary = (o, r) => {
7245
7245
  ] }) })
7246
7246
  ] });
7247
7247
  }, UILibrarySection = ({ parentId: o, position: r }) => {
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);
7248
+ const [n, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((S) => S.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), f = useRef(null);
7249
7249
  useEffect(() => {
7250
7250
  c && c.length > 0 && (f.current = new Fuse(c, {
7251
7251
  keys: ["name", "label", "description", "group"],
@@ -7257,8 +7257,8 @@ const registerChaiLibrary = (o, r) => {
7257
7257
  m([]);
7258
7258
  return;
7259
7259
  }
7260
- const C = f.current.search(u).map((j) => j.item);
7261
- m(C);
7260
+ const S = f.current.search(u).map((j) => j.item);
7261
+ m(S);
7262
7262
  }, [u]);
7263
7263
  const x = u.trim() && !isEmpty(h) ? h : c, k = groupBy(x, "group"), [b, A] = useState(null);
7264
7264
  useEffect(() => {
@@ -7271,13 +7271,13 @@ const registerChaiLibrary = (o, r) => {
7271
7271
  return;
7272
7272
  }
7273
7273
  }, [k, b]);
7274
- const B = get(k, b, []), _ = useRef(null), { t: N } = useTranslation(), w = (C) => {
7274
+ const B = get(k, b, []), _ = useRef(null), { t: N } = useTranslation(), w = (S) => {
7275
7275
  _.current && (clearTimeout(_.current), _.current = null), _.current = setTimeout(() => {
7276
- _.current && A(C);
7276
+ _.current && A(S);
7277
7277
  }, 400);
7278
7278
  }, y = () => {
7279
7279
  i != null && i.id && p(i.id);
7280
- }, S = () => {
7280
+ }, C = () => {
7281
7281
  g("");
7282
7282
  };
7283
7283
  if (d)
@@ -7285,7 +7285,7 @@ const registerChaiLibrary = (o, r) => {
7285
7285
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7286
7286
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7287
7287
  ] });
7288
- const E = filter(B, (C, j) => j % 2 === 0), v = filter(B, (C, j) => j % 2 === 1);
7288
+ const E = filter(B, (S, j) => j % 2 === 0), v = filter(B, (S, j) => j % 2 === 1);
7289
7289
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
7290
7290
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7291
7291
  /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
@@ -7294,14 +7294,14 @@ const registerChaiLibrary = (o, r) => {
7294
7294
  {
7295
7295
  placeholder: N("Search blocks..."),
7296
7296
  value: u,
7297
- onChange: (C) => g(C.target.value),
7297
+ onChange: (S) => g(S.target.value),
7298
7298
  className: "w-full pl-8 pr-8"
7299
7299
  }
7300
7300
  ),
7301
7301
  u && /* @__PURE__ */ jsx(
7302
7302
  "button",
7303
7303
  {
7304
- onClick: S,
7304
+ onClick: C,
7305
7305
  className: "absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",
7306
7306
  children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
7307
7307
  }
@@ -7319,7 +7319,7 @@ const registerChaiLibrary = (o, r) => {
7319
7319
  /* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
7320
7320
  N("Retry")
7321
7321
  ] })
7322
- ] }) }) : map(k, (C, j) => /* @__PURE__ */ jsxs(
7322
+ ] }) }) : map(k, (S, j) => /* @__PURE__ */ jsxs(
7323
7323
  "div",
7324
7324
  {
7325
7325
  onMouseEnter: () => w(j),
@@ -7346,22 +7346,22 @@ const registerChaiLibrary = (o, r) => {
7346
7346
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
7347
7347
  children: [
7348
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(
7349
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: E.map((S, j) => /* @__PURE__ */ jsx(
7350
7350
  BlockCard,
7351
7351
  {
7352
7352
  parentId: o,
7353
7353
  position: r,
7354
- block: C,
7354
+ block: S,
7355
7355
  library: i
7356
7356
  },
7357
7357
  `block-${j}`
7358
7358
  )) }),
7359
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: v.map((C, j) => /* @__PURE__ */ jsx(
7359
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: v.map((S, j) => /* @__PURE__ */ jsx(
7360
7360
  BlockCard,
7361
7361
  {
7362
7362
  parentId: o,
7363
7363
  position: r,
7364
- block: C,
7364
+ block: S,
7365
7365
  library: i
7366
7366
  },
7367
7367
  `block-second-${j}`
@@ -7464,43 +7464,43 @@ const registerChaiLibrary = (o, r) => {
7464
7464
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
7465
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" }) => {
7466
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);
7467
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (v = find(c, (S) => S._id === n)) == null ? void 0 : v._type, [m, f] = useState("all"), [x, k] = useState(null), b = useRef(null);
7468
7468
  useEffect(() => {
7469
- const C = setTimeout(() => {
7469
+ const S = setTimeout(() => {
7470
7470
  var j;
7471
7471
  (j = u.current) == null || j.focus();
7472
7472
  }, 0);
7473
- return () => clearTimeout(C);
7473
+ return () => clearTimeout(S);
7474
7474
  }, [g]), useEffect(() => {
7475
7475
  d && (f("all"), k(null));
7476
- }, [d]), useEffect(() => (b.current = debounce((C) => {
7477
- f(C);
7476
+ }, [d]), useEffect(() => (b.current = debounce((S) => {
7477
+ f(S);
7478
7478
  }, 500), () => {
7479
7479
  b.current && b.current.cancel();
7480
7480
  }), []);
7481
- const A = useCallback((C) => {
7482
- k(C), b.current && b.current(C);
7481
+ const A = useCallback((S) => {
7482
+ k(S), b.current && b.current(S);
7483
7483
  }, []), B = useCallback(() => {
7484
7484
  k(null), b.current && b.current.cancel();
7485
- }, []), _ = useCallback((C) => {
7486
- b.current && b.current.cancel(), f(C), k(null);
7485
+ }, []), _ = useCallback((S) => {
7486
+ b.current && b.current.cancel(), f(S), k(null);
7487
7487
  }, []), N = useMemo(
7488
7488
  () => d ? values(r).filter(
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());
7489
+ (S) => {
7490
+ var j, T;
7491
+ return (((j = S.label) == null ? void 0 : j.toLowerCase()) + " " + ((T = S.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
7492
7492
  }
7493
7493
  ) : r,
7494
7494
  [r, d]
7495
7495
  ), w = useMemo(
7496
7496
  () => d ? o.filter(
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),
7497
+ (S) => reject(filter(values(N), { group: S }), { hidden: !0 }).length > 0
7498
+ ) : o.filter((S) => reject(filter(values(r), { group: S }), { hidden: !0 }).length > 0),
7499
7499
  [r, N, o, d]
7500
7500
  ), y = useMemo(
7501
- () => sortBy(w, (C) => CORE_GROUPS.indexOf(C) === -1 ? 99 : CORE_GROUPS.indexOf(C)),
7501
+ () => sortBy(w, (S) => CORE_GROUPS.indexOf(S) === -1 ? 99 : CORE_GROUPS.indexOf(S)),
7502
7502
  [w]
7503
- ), S = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), E = useMemo(() => m === "all" ? y : [m], [y, m]);
7503
+ ), C = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), E = useMemo(() => m === "all" ? y : [m], [y, m]);
7504
7504
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7505
7505
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7506
7506
  Input$1,
@@ -7510,7 +7510,7 @@ const registerChaiLibrary = (o, r) => {
7510
7510
  placeholder: i("Search blocks..."),
7511
7511
  value: d,
7512
7512
  className: "-ml-2",
7513
- onChange: (C) => p(C.target.value)
7513
+ onChange: (S) => p(S.target.value)
7514
7514
  }
7515
7515
  ) }),
7516
7516
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
@@ -7526,16 +7526,16 @@ const registerChaiLibrary = (o, r) => {
7526
7526
  },
7527
7527
  "sidebar-all"
7528
7528
  ),
7529
- y.map((C) => /* @__PURE__ */ jsx(
7529
+ y.map((S) => /* @__PURE__ */ jsx(
7530
7530
  "button",
7531
7531
  {
7532
- onClick: () => _(C),
7533
- onMouseEnter: () => A(C),
7532
+ onClick: () => _(S),
7533
+ onMouseEnter: () => A(S),
7534
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()))
7535
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === S || x === S ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7536
+ children: capitalize(i(S.toLowerCase()))
7537
7537
  },
7538
- `sidebar-${C}`
7538
+ `sidebar-${S}`
7539
7539
  ))
7540
7540
  ] }) }) }),
7541
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: [
@@ -7543,10 +7543,10 @@ const registerChaiLibrary = (o, r) => {
7543
7543
  ' "',
7544
7544
  d,
7545
7545
  '"'
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())) }),
7546
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: E.map((S) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7547
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(S.toLowerCase())) }),
7548
7548
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7549
- m === "all" ? filter(values(S), { group: C }) : values(S),
7549
+ m === "all" ? filter(values(C), { group: S }) : values(C),
7550
7550
  { hidden: !0 }
7551
7551
  ).map((j) => /* @__PURE__ */ jsx(
7552
7552
  CoreBlock,
@@ -7558,7 +7558,7 @@ const registerChaiLibrary = (o, r) => {
7558
7558
  },
7559
7559
  j.type
7560
7560
  )) })
7561
- ] }, C)) }) }) })
7561
+ ] }, S)) }) }) })
7562
7562
  ] })
7563
7563
  ] });
7564
7564
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -7911,35 +7911,35 @@ const Input = ({ node: o }) => {
7911
7911
  var R;
7912
7912
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7913
7913
  let p = null;
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) => {
7915
- T.stopPropagation(), !l.includes(m) && o.toggle();
7916
- }, N = (T) => {
7917
- T.isInternal && (p = T.isOpen, T.isOpen && T.close());
7918
- }, w = (T) => {
7919
- T.isInternal && p !== null && (p ? T.open() : T.close(), p = null);
7920
- }, [y, S] = useAtom$1(currentAddSelection), E = () => {
7921
- var T;
7922
- v(), o.parent.isSelected || S((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
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, _ = (I) => {
7915
+ I.stopPropagation(), !l.includes(m) && o.toggle();
7916
+ }, N = (I) => {
7917
+ I.isInternal && (p = I.isOpen, I.isOpen && I.close());
7918
+ }, w = (I) => {
7919
+ I.isInternal && p !== null && (p ? I.open() : I.close(), p = null);
7920
+ }, [y, C] = useAtom$1(currentAddSelection), E = () => {
7921
+ var I;
7922
+ v(), o.parent.isSelected || C((I = o == null ? void 0 : o.parent) == null ? void 0 : I.id);
7923
7923
  }, v = () => {
7924
- S(null);
7925
- }, C = (T) => {
7926
- v(), T.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), B(T);
7924
+ C(null);
7925
+ }, S = (I) => {
7926
+ v(), I.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), B(I);
7927
7927
  };
7928
7928
  useEffect(() => {
7929
- const T = setTimeout(() => {
7929
+ const I = setTimeout(() => {
7930
7930
  k && !o.isOpen && !b && !l.includes(m) && o.toggle();
7931
7931
  }, 500);
7932
- return () => clearTimeout(T);
7932
+ return () => clearTimeout(I);
7933
7933
  }, [k, o, b]);
7934
- const j = (T, D) => {
7935
- const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${T}]`);
7934
+ const j = (I, D) => {
7935
+ const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${I}]`);
7936
7936
  P && P.setAttribute("data-drop", D);
7937
7937
  const $ = P.getBoundingClientRect(), M = c.getBoundingClientRect();
7938
7938
  $.top >= M.top && $.left >= M.left && $.bottom <= M.bottom && $.right <= M.right || (O.documentElement.scrollTop = P.offsetTop - M.top);
7939
- }, I = (T) => {
7939
+ }, T = (I) => {
7940
7940
  v();
7941
7941
  const D = get(o, "parent.id");
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 });
7942
+ D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: I }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: I });
7943
7943
  };
7944
7944
  if (m === ROOT_TEMP_KEY)
7945
7945
  return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
@@ -7948,7 +7948,7 @@ const Input = ({ node: o }) => {
7948
7948
  "div",
7949
7949
  {
7950
7950
  role: "button",
7951
- onClick: () => I(-1),
7951
+ onClick: () => T(-1),
7952
7952
  className: "h-1 rounded bg-primary opacity-0 duration-200 group-hover:opacity-100",
7953
7953
  children: /* @__PURE__ */ jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-primary px-3 py-1 text-[9px] leading-tight text-white hover:bg-primary", children: [
7954
7954
  /* @__PURE__ */ jsx(PlusIcon, { className: "h-2 w-2 stroke-[3]" }),
@@ -7965,27 +7965,27 @@ const Input = ({ node: o }) => {
7965
7965
  {
7966
7966
  onMouseEnter: () => g(m),
7967
7967
  onMouseLeave: () => h(),
7968
- onClick: C,
7968
+ onClick: S,
7969
7969
  style: r,
7970
7970
  "data-node-id": m,
7971
7971
  ref: l.includes(m) ? null : n,
7972
7972
  onDragStart: () => N(o),
7973
7973
  onDragEnd: () => w(o),
7974
- onDragOver: (T) => {
7975
- T.preventDefault(), j(m, "yes");
7974
+ onDragOver: (I) => {
7975
+ I.preventDefault(), j(m, "yes");
7976
7976
  },
7977
- onDragLeave: (T) => {
7978
- T.preventDefault(), j(m, "no");
7977
+ onDragLeave: (I) => {
7978
+ I.preventDefault(), j(m, "no");
7979
7979
  },
7980
- onDrop: (T) => {
7981
- T.preventDefault(), j(m, "no");
7980
+ onDrop: (I) => {
7981
+ I.preventDefault(), j(m, "no");
7982
7982
  },
7983
7983
  children: [
7984
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(
7985
7985
  "div",
7986
7986
  {
7987
- onClick: (T) => {
7988
- T.stopPropagation(), I(o.childIndex);
7987
+ onClick: (I) => {
7988
+ I.stopPropagation(), T(o.childIndex);
7989
7989
  },
7990
7990
  onMouseEnter: E,
7991
7991
  onMouseLeave: v,
@@ -8028,8 +8028,8 @@ const Input = ({ node: o }) => {
8028
8028
  "div",
8029
8029
  {
8030
8030
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
8031
- onDoubleClick: (T) => {
8032
- T.stopPropagation(), o.edit(), o.deselect();
8031
+ onDoubleClick: (I) => {
8032
+ I.stopPropagation(), o.edit(), o.deselect();
8033
8033
  },
8034
8034
  children: /* @__PURE__ */ jsx("span", { children: getBlockDisplayName(f) })
8035
8035
  }
@@ -8055,8 +8055,8 @@ const Input = ({ node: o }) => {
8055
8055
  /* @__PURE__ */ jsx(
8056
8056
  TooltipTrigger,
8057
8057
  {
8058
- onClick: (T) => {
8059
- T.stopPropagation(), i(m), o.isOpen && o.toggle();
8058
+ onClick: (I) => {
8059
+ I.stopPropagation(), i(m), o.isOpen && o.toggle();
8060
8060
  },
8061
8061
  className: "cursor-pointer rounded bg-transparent",
8062
8062
  asChild: !0,
@@ -8276,17 +8276,18 @@ const Input = ({ node: o }) => {
8276
8276
  /* @__PURE__ */ jsx(PasteAtRootContextMenu, { parentContext, setParentContext })
8277
8277
  ] });
8278
8278
  }, BorderRadiusInput = ({ value: o, onChange: r, disabled: n }) => {
8279
- const a = debounce((l) => r(l), 200);
8279
+ const [a, l] = useState(o), i = useThrottledCallback(r, [o], 200, !0);
8280
8280
  return /* @__PURE__ */ jsx(
8281
- "input",
8281
+ Slider,
8282
8282
  {
8283
- type: "range",
8284
- min: "0",
8285
- step: "1",
8286
- max: "30",
8283
+ min: 0,
8284
+ step: 1,
8285
+ max: 50,
8287
8286
  disabled: n,
8288
- defaultValue: o.replace("px", ""),
8289
- onChange: (l) => a(l.target.value),
8287
+ value: [Number(a.replace("px", ""))],
8288
+ onValueChange: (c) => {
8289
+ l(c[0].toString() + "px"), i(c[0].toString());
8290
+ },
8290
8291
  className: "flex-1 cursor-pointer"
8291
8292
  }
8292
8293
  );
@@ -8317,20 +8318,17 @@ const Input = ({ node: o }) => {
8317
8318
  onChange: n
8318
8319
  }) => {
8319
8320
  const a = useRegisteredFonts();
8320
- return /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
8321
- /* @__PURE__ */ jsx(Label, { className: "text-sm", children: startCase(o) }),
8322
- /* @__PURE__ */ jsx(
8323
- "select",
8324
- {
8325
- className: "mt-1 w-full cursor-pointer rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-border focus:ring-offset-2",
8326
- value: r,
8327
- onChange: (l) => n(l.target.value),
8328
- children: a.map((l) => /* @__PURE__ */ jsx("option", { value: l.family, children: l.family }, l.family))
8329
- }
8330
- )
8321
+ return useEffect(() => {
8322
+ a.some((l) => l.family === r) || n(a[0].family);
8323
+ }, [r, n]), /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
8324
+ /* @__PURE__ */ jsx(Label, { className: "mb-1 block text-xs text-gray-600", children: startCase(o) }),
8325
+ /* @__PURE__ */ jsxs(Select$1, { value: r, onValueChange: n, children: [
8326
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 w-full text-xs text-black", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select font" }) }),
8327
+ /* @__PURE__ */ jsx(SelectContent, { children: a.map((l) => /* @__PURE__ */ jsx(SelectItem, { value: l.family, children: l.family }, l.family)) })
8328
+ ] })
8331
8329
  ] });
8332
8330
  }, LazyCssImportModal = lazy(
8333
- () => import("./CssImportModal-DXUM3oRB.js").then((o) => ({ default: o.CssImportModal }))
8331
+ () => import("./css-import-modal-CcUf6F6T.js").then((o) => ({ default: o.CssImportModal }))
8334
8332
  ), PREV_THEME_KEY = "chai-builder-previous-theme", setPreviousTheme = (o) => {
8335
8333
  if (!(typeof window > "u"))
8336
8334
  try {
@@ -8346,148 +8344,166 @@ const Input = ({ node: o }) => {
8346
8344
  console.warn("Failed to clear previous theme from localStorage:", o);
8347
8345
  }
8348
8346
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
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(
8347
+ const [r, n] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions(), [g, h] = useTheme(), m = useThemeOptions(), { t: f } = useTranslation(), x = React.useCallback(
8350
8348
  (w) => {
8351
- const y = { ...u };
8352
- setPreviousTheme(y), g(w), toast.success("Theme updated", {
8349
+ const y = { ...g };
8350
+ setPreviousTheme(y), h(w), toast.success("Theme updated", {
8353
8351
  action: {
8354
8352
  label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
8355
8353
  /* @__PURE__ */ jsx(Undo$1, { className: "h-4 w-4" }),
8356
8354
  " Undo"
8357
8355
  ] }),
8358
8356
  onClick: () => {
8359
- g(y), clearPreviousTheme(), toast.dismiss();
8357
+ h(y), clearPreviousTheme(), toast.dismiss();
8360
8358
  }
8361
8359
  },
8362
8360
  closeButton: !0,
8363
8361
  duration: 15e3
8364
8362
  });
8365
8363
  },
8366
- [u, g]
8367
- ), x = (w) => {
8368
- a(w);
8369
- }, k = () => {
8370
- const w = c.find((y) => Object.keys(y)[0] === n);
8364
+ [g, h]
8365
+ ), k = () => {
8366
+ const w = d.find((y) => Object.keys(y)[0] === a);
8371
8367
  if (w) {
8372
8368
  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);
8369
+ y && typeof y == "object" && "fontFamily" in y && "borderRadius" in y && "colors" in y ? (x(y), l("")) : console.error("Invalid preset structure:", y);
8374
8370
  } else
8375
- console.error("Preset not found:", n);
8371
+ console.error("Preset not found:", a);
8376
8372
  }, b = (w) => {
8377
- f(w), a("");
8373
+ x(w), l("");
8378
8374
  }, A = useDebouncedCallback(
8379
8375
  (w, y) => {
8380
- g(() => ({
8381
- ...u,
8376
+ h(() => ({
8377
+ ...g,
8382
8378
  fontFamily: {
8383
- ...u.fontFamily,
8379
+ ...g.fontFamily,
8384
8380
  [w.replace(/font-/g, "")]: y
8385
8381
  }
8386
8382
  }));
8387
8383
  },
8388
- [u],
8384
+ [g],
8389
8385
  200
8390
- ), B = useDebouncedCallback(
8386
+ ), B = React.useCallback(
8391
8387
  (w) => {
8392
- g(() => ({
8393
- ...u,
8388
+ h(() => ({
8389
+ ...g,
8394
8390
  borderRadius: `${w}px`
8395
8391
  }));
8396
8392
  },
8397
- [u],
8398
- 200
8393
+ [g]
8399
8394
  ), _ = useDebouncedCallback(
8400
8395
  (w, y) => {
8401
- g(() => {
8402
- const S = get(u, `colors.${w}`);
8403
- return r ? set(S, 1, y) : set(S, 0, y), {
8404
- ...u,
8396
+ h(() => {
8397
+ const C = get(g, `colors.${w}`);
8398
+ return r ? set(C, 1, y) : set(C, 0, y), {
8399
+ ...g,
8405
8400
  colors: {
8406
- ...u.colors,
8407
- [w]: S
8401
+ ...g.colors,
8402
+ [w]: C
8408
8403
  }
8409
8404
  };
8410
8405
  });
8411
8406
  },
8412
- [u],
8407
+ [g],
8413
8408
  200
8414
8409
  ), 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: [
8410
+ const C = get(g, `colors.${y}.${r ? 1 : 0}`);
8411
+ return C ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8417
8412
  /* @__PURE__ */ jsx(
8418
8413
  ColorPickerInput,
8419
8414
  {
8420
- value: S,
8415
+ value: C,
8421
8416
  onChange: (E) => _(y, E)
8422
8417
  }
8423
8418
  ),
8424
8419
  /* @__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
8420
  ] }, y) : null;
8426
8421
  }) });
8427
- return p("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
8422
+ return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
8428
8423
  /* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
8429
- c.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 py-2", children: [
8424
+ d.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mx-0 my-2 flex flex-col gap-1 py-2", children: [
8430
8425
  /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
8431
- /* @__PURE__ */ jsx(Label, { className: "text-sm", children: m("Presets") }),
8432
- /* @__PURE__ */ jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ jsxs(Button, { className: "px-1", variant: "link", size: "sm", onClick: () => i(!0), children: [
8426
+ /* @__PURE__ */ jsx(Label, { className: "text-sm", children: f("Presets") }),
8427
+ /* @__PURE__ */ jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ jsxs(Button, { className: "px-1", variant: "link", size: "sm", onClick: () => c(!0), children: [
8433
8428
  /* @__PURE__ */ jsx(ImportIcon, { className: "h-4 w-4" }),
8434
- m("Import theme")
8429
+ f("Import theme")
8435
8430
  ] }) })
8436
8431
  ] }),
8437
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
8438
- /* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(
8439
- "select",
8440
- {
8441
- value: n,
8442
- onChange: (w) => x(w.target.value),
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",
8444
- children: [
8445
- /* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
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]))
8447
- ]
8448
- }
8449
- ) }),
8450
- /* @__PURE__ */ jsx("div", { className: "flex w-[30%] items-end", children: /* @__PURE__ */ jsx(
8451
- Button,
8452
- {
8453
- className: "w-full text-sm",
8454
- disabled: n === "",
8455
- variant: "default",
8456
- onClick: k,
8457
- children: m("Apply")
8458
- }
8459
- ) })
8432
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
8433
+ /* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
8434
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
8435
+ /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((w) => {
8436
+ const y = Object.keys(w)[0], C = y.replaceAll("_", " ");
8437
+ return /* @__PURE__ */ jsx(SelectItem, { value: y, children: capitalize(C) }, y);
8438
+ }) })
8439
+ ] }) }),
8440
+ /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: k, children: f("Apply") }) })
8460
8441
  ] })
8461
8442
  ] }),
8462
- /* @__PURE__ */ jsxs("div", { className: cn$2("space-y-2", o), children: [
8463
- (h == null ? void 0 : h.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(h.fontFamily).map(([w, y]) => /* @__PURE__ */ jsx(
8443
+ /* @__PURE__ */ jsx(Separator, {}),
8444
+ /* @__PURE__ */ jsxs("div", { className: cn$2("my-2 space-y-3", o), children: [
8445
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
8446
+ /* @__PURE__ */ jsx(Type, { className: "h-3 w-3 text-gray-600" }),
8447
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Typography" })
8448
+ ] }),
8449
+ (m == null ? void 0 : m.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(m.fontFamily).map(([w, y]) => /* @__PURE__ */ jsx(
8464
8450
  FontSelector,
8465
8451
  {
8466
8452
  label: w,
8467
- value: u.fontFamily[w.replace(/font-/g, "")] || y[Object.keys(y)[0]],
8468
- onChange: (S) => A(w, S)
8453
+ value: g.fontFamily[w.replace(/font-/g, "")] || y[Object.keys(y)[0]],
8454
+ onChange: (C) => A(w, C)
8469
8455
  },
8470
8456
  w
8471
8457
  )) }),
8472
- (h == null ? void 0 : h.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
8473
- /* @__PURE__ */ jsx(Label, { className: "text-sm", children: m("Border Radius") }),
8474
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
8475
- /* @__PURE__ */ jsx(BorderRadiusInput, { value: u.borderRadius, onChange: B }),
8476
- /* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: u.borderRadius })
8477
- ] })
8458
+ /* @__PURE__ */ jsx(Separator, {}),
8459
+ (m == null ? void 0 : m.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
8460
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
8461
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
8462
+ /* @__PURE__ */ jsx(CornerUpRight, { className: "h-3 w-3 text-gray-600" }),
8463
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Border Radius" })
8464
+ ] }),
8465
+ /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: g.borderRadius })
8466
+ ] }),
8467
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: g.borderRadius, onChange: B }) })
8478
8468
  ] }),
8479
- (h == null ? void 0 : h.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
8480
- /* @__PURE__ */ jsx(Label, { className: "text-sm", children: m("Colors") }),
8481
- /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: h.colors.map((w) => N(w)) }, r ? "dark" : "light")
8482
- ] })
8469
+ /* @__PURE__ */ jsx(Separator, {}),
8470
+ (m == null ? void 0 : m.colors) && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
8471
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
8472
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
8473
+ /* @__PURE__ */ jsx(Palette, { className: "h-3 w-3 text-gray-600" }),
8474
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Colors" })
8475
+ ] }),
8476
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
8477
+ /* @__PURE__ */ jsx(Sun, { className: "h-4 w-4" }),
8478
+ /* @__PURE__ */ jsx(
8479
+ Switch,
8480
+ {
8481
+ checked: r,
8482
+ onCheckedChange: (w) => n(w),
8483
+ "aria-label": "Toggle dark mode",
8484
+ className: "mx-1"
8485
+ }
8486
+ ),
8487
+ /* @__PURE__ */ jsx(Moon, { className: "h-4 w-4" })
8488
+ ] }) })
8489
+ ] }),
8490
+ /* @__PURE__ */ jsx("div", { className: "space-y-2", children: m.colors.map((w) => N(w)) })
8491
+ ] }),
8492
+ /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: i && /* @__PURE__ */ jsx(
8493
+ LazyCssImportModal,
8494
+ {
8495
+ open: i,
8496
+ onOpenChange: c,
8497
+ onImport: b
8498
+ }
8499
+ ) })
8483
8500
  ] }),
8484
8501
  /* @__PURE__ */ jsx("br", {}),
8485
8502
  /* @__PURE__ */ jsx("br", {}),
8486
8503
  /* @__PURE__ */ jsx("br", {}),
8487
8504
  /* @__PURE__ */ jsx("br", {})
8488
8505
  ] }),
8489
- d && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(d) }),
8490
- /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: l && /* @__PURE__ */ jsx(LazyCssImportModal, { open: l, onOpenChange: i, onImport: b }) })
8506
+ p && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(p) })
8491
8507
  ] }) : /* @__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." }) }) }) });
8492
8508
  }), 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 = {
8493
8509
  "Add block": "Add Block",
@@ -9427,8 +9443,8 @@ const AiAssistant = () => {
9427
9443
  n(y), l(a), c(""), p(""), m("");
9428
9444
  }
9429
9445
  }, A = (y) => {
9430
- const S = a.filter((E, v) => v !== y);
9431
- n(S), l(S);
9446
+ const C = a.filter((E, v) => v !== y);
9447
+ n(C), l(C);
9432
9448
  }, B = (y) => {
9433
9449
  g(y), c(a[y].key), p(a[y].value);
9434
9450
  }, _ = () => {
@@ -9443,23 +9459,23 @@ const AiAssistant = () => {
9443
9459
  }, N = (y) => {
9444
9460
  y.key === "Enter" && !y.shiftKey && (y.preventDefault(), u !== null ? _() : b());
9445
9461
  }, w = useCallback((y) => {
9446
- const S = (C) => /[.,!?;:]/.test(C), E = (C, j, I) => {
9462
+ const C = (S) => /[.,!?;:]/.test(S), E = (S, j, T) => {
9447
9463
  let L = "", 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 = " "), {
9450
- text: L + I + R,
9464
+ const I = j > 0 ? S[j - 1] : "", D = j < S.length ? S[j] : "";
9465
+ return j > 0 && (I === "." || !C(I) && I !== " ") && (L = " "), j < S.length && !C(D) && D !== " " && (R = " "), {
9466
+ text: L + T + R,
9451
9467
  prefixLength: L.length,
9452
9468
  suffixLength: R.length
9453
9469
  };
9454
9470
  }, v = x.current;
9455
9471
  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);
9472
+ const S = v.selectionStart || 0, j = v.value || "", T = v.selectionEnd || S;
9473
+ if (T > S) {
9474
+ const O = `{{${y}}}`, { text: P } = E(j, S, O), $ = j.slice(0, S) + P + j.slice(T);
9459
9475
  p($);
9460
9476
  return;
9461
9477
  }
9462
- const R = `{{${y}}}`, { text: T } = E(j, C, R), D = j.slice(0, C) + T + j.slice(C);
9478
+ const R = `{{${y}}}`, { text: I } = E(j, S, R), D = j.slice(0, S) + I + j.slice(S);
9463
9479
  p(D);
9464
9480
  }
9465
9481
  }, []);
@@ -9518,16 +9534,16 @@ const AiAssistant = () => {
9518
9534
  ]
9519
9535
  }
9520
9536
  ),
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: [
9537
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((y, C) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9522
9538
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9523
9539
  /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: y.key }),
9524
9540
  /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: y.value.toString() })
9525
9541
  ] }),
9526
9542
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
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" }) })
9543
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(C), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9544
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(C), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9529
9545
  ] })
9530
- ] }, S)) })
9546
+ ] }, C)) })
9531
9547
  ] });
9532
9548
  }), BlockAttributesEditor = React.memo(() => {
9533
9549
  const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9734,7 +9750,7 @@ const RootLayout = () => {
9734
9750
  /* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
9735
9751
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9736
9752
  /* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9737
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((y, S) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9753
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((y, C) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9738
9754
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
9739
9755
  position: "top",
9740
9756
  panelId: y.id,
@@ -9742,9 +9758,9 @@ const RootLayout = () => {
9742
9758
  show: () => w(y.id)
9743
9759
  }) }),
9744
9760
  /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(y.label) }) })
9745
- ] }, "button-top-" + S)) }),
9761
+ ] }, "button-top-" + C)) }),
9746
9762
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9747
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((y, S) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9763
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((y, C) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9748
9764
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
9749
9765
  position: "bottom",
9750
9766
  panelId: y.id,
@@ -9752,7 +9768,7 @@ const RootLayout = () => {
9752
9768
  show: () => w(y.id)
9753
9769
  }) }),
9754
9770
  /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(y.label) }) })
9755
- ] }, "button-bottom-" + S)) })
9771
+ ] }, "button-bottom-" + C)) })
9756
9772
  ] }),
9757
9773
  /* @__PURE__ */ jsx(
9758
9774
  motion.div,
@@ -9793,7 +9809,7 @@ const RootLayout = () => {
9793
9809
  f("AI Assistant")
9794
9810
  ] }) }) : c === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
9795
9811
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
9796
- /* @__PURE__ */ jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
9812
+ /* @__PURE__ */ jsx(Palette, { className: "w-4 h-4 text-gray-600" }),
9797
9813
  f("Theme Settings")
9798
9814
  ] }),
9799
9815
  /* @__PURE__ */ jsx(
@@ -9921,8 +9937,8 @@ const RootLayout = () => {
9921
9937
  });
9922
9938
  }, m = (x) => {
9923
9939
  if (!c) return;
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);
9940
+ 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)), C = Math.max(0, Math.min(b, w));
9941
+ n(y, C);
9926
9942
  }, f = () => {
9927
9943
  d(!1);
9928
9944
  };
@@ -10102,72 +10118,72 @@ const RootLayout = () => {
10102
10118
  var x;
10103
10119
  return (x = m.onMount) == null ? void 0 : x.call(m, f);
10104
10120
  }, ...h) => {
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;
10121
+ const m = h[0] || ((C) => {
10122
+ let E = o.get(C);
10123
+ return E || (E = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(C, E), u == null || u(C, y)), E;
10108
10124
  }), f = h[1] || (() => {
10109
- let S, E;
10110
- const v = (C) => {
10125
+ let C, E;
10126
+ const v = (S) => {
10111
10127
  try {
10112
- C();
10128
+ S();
10113
10129
  } catch (j) {
10114
- S || (S = !0, E = j);
10130
+ C || (C = !0, E = j);
10115
10131
  }
10116
10132
  };
10117
10133
  do {
10118
10134
  c.f && v(c.f);
10119
- const C = /* @__PURE__ */ new Set(), j = C.add.bind(C);
10120
- a.forEach((I) => {
10135
+ const S = /* @__PURE__ */ new Set(), j = S.add.bind(S);
10136
+ a.forEach((T) => {
10121
10137
  var L;
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();
10138
+ return (L = r.get(T)) == null ? void 0 : L.l.forEach(j);
10139
+ }), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), S.forEach(v), a.size && x();
10124
10140
  } while (a.size || i.size || l.size);
10125
- if (S)
10141
+ if (C)
10126
10142
  throw E;
10127
10143
  }), 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);
10144
+ const C = [], E = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), S = Array.from(a);
10145
+ for (; S.length; ) {
10146
+ const j = S[S.length - 1], T = m(j);
10131
10147
  if (v.has(j)) {
10132
- C.pop();
10148
+ S.pop();
10133
10149
  continue;
10134
10150
  }
10135
10151
  if (E.has(j)) {
10136
- n.get(j) === I.n && S.push([j, I]), v.add(j), C.pop();
10152
+ n.get(j) === T.n && C.push([j, T]), v.add(j), S.pop();
10137
10153
  continue;
10138
10154
  }
10139
10155
  E.add(j);
10140
- for (const L of getMountedOrPendingDependents(j, I, r))
10141
- E.has(L) || C.push(L);
10156
+ for (const L of getMountedOrPendingDependents(j, T, r))
10157
+ E.has(L) || S.push(L);
10142
10158
  }
10143
- for (let j = S.length - 1; j >= 0; --j) {
10144
- const [I, L] = S[j];
10159
+ for (let j = C.length - 1; j >= 0; --j) {
10160
+ const [T, L] = C[j];
10145
10161
  let R = !1;
10146
- for (const T of L.d.keys())
10147
- if (T !== I && a.has(T)) {
10162
+ for (const I of L.d.keys())
10163
+ if (I !== T && a.has(I)) {
10148
10164
  R = !0;
10149
10165
  break;
10150
10166
  }
10151
- R && (k(I), B(I)), n.delete(I);
10167
+ R && (k(T), B(T)), n.delete(T);
10152
10168
  }
10153
- }), k = h[3] || ((S) => {
10169
+ }), k = h[3] || ((C) => {
10154
10170
  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(
10171
+ const S = m(C);
10172
+ if (isAtomStateInitialized(S) && (r.has(C) && n.get(C) !== S.n || Array.from(S.d).every(
10157
10173
  ([P, $]) => (
10158
10174
  // Recursively, read the atom state of the dependency, and
10159
10175
  // check if the atom epoch number is unchanged
10160
10176
  k(P).n === $
10161
10177
  )
10162
10178
  )))
10163
- return C;
10164
- C.d.clear();
10179
+ return S;
10180
+ S.d.clear();
10165
10181
  let j = !0;
10166
- const I = () => {
10167
- r.has(S) && (B(S), x(), f());
10182
+ const T = () => {
10183
+ r.has(C) && (B(C), x(), f());
10168
10184
  }, L = (P) => {
10169
10185
  var $;
10170
- if (isSelfAtom(S, P)) {
10186
+ if (isSelfAtom(C, P)) {
10171
10187
  const H = m(P);
10172
10188
  if (!isAtomStateInitialized(H))
10173
10189
  if (hasInitialValue(P))
@@ -10180,140 +10196,140 @@ const RootLayout = () => {
10180
10196
  try {
10181
10197
  return returnAtomValue(M);
10182
10198
  } finally {
10183
- C.d.set(P, M.n), isPendingPromise(C.v) && addPendingPromiseToDependency(S, C.v, M), ($ = r.get(P)) == null || $.t.add(S), j || I();
10199
+ S.d.set(P, M.n), isPendingPromise(S.v) && addPendingPromiseToDependency(C, S.v, M), ($ = r.get(P)) == null || $.t.add(C), j || T();
10184
10200
  }
10185
10201
  };
10186
- let R, T;
10202
+ let R, I;
10187
10203
  const D = {
10188
10204
  get signal() {
10189
10205
  return R || (R = new AbortController()), R.signal;
10190
10206
  },
10191
10207
  get setSelf() {
10192
- return !T && isActuallyWritableAtom(S) && (T = (...P) => {
10208
+ return !I && isActuallyWritableAtom(C) && (I = (...P) => {
10193
10209
  if (!j)
10194
10210
  try {
10195
- return A(S, ...P);
10211
+ return A(C, ...P);
10196
10212
  } finally {
10197
10213
  x(), f();
10198
10214
  }
10199
- }), T;
10215
+ }), I;
10200
10216
  }
10201
- }, O = C.n;
10217
+ }, O = S.n;
10202
10218
  try {
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(
10205
- I,
10206
- I
10207
- )), C;
10219
+ const P = d(C, L, D);
10220
+ return setAtomStateValueOrPromise(C, P, m), isPromiseLike$1(P) && ((E = P.onCancel) == null || E.call(P, () => R == null ? void 0 : R.abort()), P.then(
10221
+ T,
10222
+ T
10223
+ )), S;
10208
10224
  } catch (P) {
10209
- return delete C.v, C.e = P, ++C.n, C;
10225
+ return delete S.v, S.e = P, ++S.n, S;
10210
10226
  } finally {
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));
10227
+ j = !1, O !== S.n && n.get(C) === O && (n.set(C, S.n), a.add(C), (v = c.c) == null || v.call(c, C));
10212
10228
  }
10213
- }), b = h[4] || ((S) => {
10214
- const E = [S];
10229
+ }), b = h[4] || ((C) => {
10230
+ const E = [C];
10215
10231
  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);
10232
+ const v = E.pop(), S = m(v);
10233
+ for (const j of getMountedOrPendingDependents(v, S, r)) {
10234
+ const T = m(j);
10235
+ n.set(j, T.n), E.push(j);
10220
10236
  }
10221
10237
  }
10222
- }), A = h[5] || ((S, ...E) => {
10238
+ }), A = h[5] || ((C, ...E) => {
10223
10239
  let v = !0;
10224
- const C = (I) => returnAtomValue(k(I)), j = (I, ...L) => {
10240
+ const S = (T) => returnAtomValue(k(T)), j = (T, ...L) => {
10225
10241
  var R;
10226
- const T = m(I);
10242
+ const I = m(T);
10227
10243
  try {
10228
- if (isSelfAtom(S, I)) {
10229
- if (!hasInitialValue(I))
10244
+ if (isSelfAtom(C, T)) {
10245
+ if (!hasInitialValue(T))
10230
10246
  throw new Error("atom not writable");
10231
- const D = T.n, O = L[0];
10232
- setAtomStateValueOrPromise(I, O, m), B(I), D !== T.n && (a.add(I), (R = c.c) == null || R.call(c, I), b(I));
10247
+ const D = I.n, O = L[0];
10248
+ setAtomStateValueOrPromise(T, O, m), B(T), D !== I.n && (a.add(T), (R = c.c) == null || R.call(c, T), b(T));
10233
10249
  return;
10234
10250
  } else
10235
- return A(I, ...L);
10251
+ return A(T, ...L);
10236
10252
  } finally {
10237
10253
  v || (x(), f());
10238
10254
  }
10239
10255
  };
10240
10256
  try {
10241
- return p(S, C, j, ...E);
10257
+ return p(C, S, j, ...E);
10242
10258
  } finally {
10243
10259
  v = !1;
10244
10260
  }
10245
- }), B = h[6] || ((S) => {
10261
+ }), B = h[6] || ((C) => {
10246
10262
  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)) {
10263
+ const v = m(C), S = r.get(C);
10264
+ if (S && !isPendingPromise(v.v)) {
10265
+ for (const [j, T] of v.d)
10266
+ if (!S.d.has(j)) {
10251
10267
  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));
10268
+ _(j).t.add(C), S.d.add(j), T !== L.n && (a.add(j), (E = c.c) == null || E.call(c, j), b(j));
10253
10269
  }
10254
- for (const j of C.d || [])
10270
+ for (const j of S.d || [])
10255
10271
  if (!v.d.has(j)) {
10256
- C.d.delete(j);
10257
- const I = N(j);
10258
- I == null || I.t.delete(S);
10272
+ S.d.delete(j);
10273
+ const T = N(j);
10274
+ T == null || T.t.delete(C);
10259
10275
  }
10260
10276
  }
10261
- }), _ = h[7] || ((S) => {
10277
+ }), _ = h[7] || ((C) => {
10262
10278
  var E;
10263
- const v = m(S);
10264
- let C = r.get(S);
10265
- if (!C) {
10266
- k(S);
10279
+ const v = m(C);
10280
+ let S = r.get(C);
10281
+ if (!S) {
10282
+ k(C);
10267
10283
  for (const j of v.d.keys())
10268
- _(j).t.add(S);
10269
- if (C = {
10284
+ _(j).t.add(C);
10285
+ if (S = {
10270
10286
  l: /* @__PURE__ */ new Set(),
10271
10287
  d: new Set(v.d.keys()),
10272
10288
  t: /* @__PURE__ */ new Set()
10273
- }, r.set(S, C), (E = c.m) == null || E.call(c, S), isActuallyWritableAtom(S)) {
10289
+ }, r.set(C, S), (E = c.m) == null || E.call(c, C), isActuallyWritableAtom(C)) {
10274
10290
  const j = () => {
10275
- let I = !0;
10291
+ let T = !0;
10276
10292
  const L = (...R) => {
10277
10293
  try {
10278
- return A(S, ...R);
10294
+ return A(C, ...R);
10279
10295
  } finally {
10280
- I || (x(), f());
10296
+ T || (x(), f());
10281
10297
  }
10282
10298
  };
10283
10299
  try {
10284
- const R = g(S, L);
10285
- R && (C.u = () => {
10286
- I = !0;
10300
+ const R = g(C, L);
10301
+ R && (S.u = () => {
10302
+ T = !0;
10287
10303
  try {
10288
10304
  R();
10289
10305
  } finally {
10290
- I = !1;
10306
+ T = !1;
10291
10307
  }
10292
10308
  });
10293
10309
  } finally {
10294
- I = !1;
10310
+ T = !1;
10295
10311
  }
10296
10312
  };
10297
10313
  l.add(j);
10298
10314
  }
10299
10315
  }
10300
- return C;
10301
- }), N = h[8] || ((S) => {
10316
+ return S;
10317
+ }), N = h[8] || ((C) => {
10302
10318
  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) => {
10306
- var I;
10307
- return (I = r.get(j)) == null ? void 0 : I.d.has(S);
10319
+ const v = m(C);
10320
+ let S = r.get(C);
10321
+ if (S && !S.l.size && !Array.from(S.t).some((j) => {
10322
+ var T;
10323
+ return (T = r.get(j)) == null ? void 0 : T.d.has(C);
10308
10324
  })) {
10309
- C.u && i.add(C.u), C = void 0, r.delete(S), (E = c.u) == null || E.call(c, S);
10325
+ S.u && i.add(S.u), S = void 0, r.delete(C), (E = c.u) == null || E.call(c, C);
10310
10326
  for (const j of v.d.keys()) {
10311
- const I = N(j);
10312
- I == null || I.t.delete(S);
10327
+ const T = N(j);
10328
+ T == null || T.t.delete(C);
10313
10329
  }
10314
10330
  return;
10315
10331
  }
10316
- return C;
10332
+ return S;
10317
10333
  }), w = [
10318
10334
  // store state
10319
10335
  o,
@@ -10339,18 +10355,18 @@ const RootLayout = () => {
10339
10355
  _,
10340
10356
  N
10341
10357
  ], y = {
10342
- get: (S) => returnAtomValue(k(S)),
10343
- set: (S, ...E) => {
10358
+ get: (C) => returnAtomValue(k(C)),
10359
+ set: (C, ...E) => {
10344
10360
  try {
10345
- return A(S, ...E);
10361
+ return A(C, ...E);
10346
10362
  } finally {
10347
10363
  x(), f();
10348
10364
  }
10349
10365
  },
10350
- sub: (S, E) => {
10351
- const C = _(S).l;
10352
- return C.add(E), f(), () => {
10353
- C.delete(E), N(S), f();
10366
+ sub: (C, E) => {
10367
+ const S = _(C).l;
10368
+ return S.add(E), f(), () => {
10369
+ S.delete(E), N(C), f();
10354
10370
  };
10355
10371
  }
10356
10372
  };