@chaibuilder/sdk 3.0.8 → 3.0.9

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
@@ -4,7 +4,7 @@ var $ = (o, n, r) => U(o, typeof n != "symbol" ? n + "" : n, r);
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
6
6
  import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, sortBy, round } from "lodash-es";
7
- import { SquareIcon, ChevronRightIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, ExclamationTriangleIcon, Cross1Icon, Pencil2Icon, ChevronLeftIcon, LoopIcon, IdCardIcon, LetterCaseCapitalizeIcon, ValueIcon, LinkBreak1Icon, EnterFullScreenIcon, PlusCircledIcon, ChevronDownIcon, InfoCircledIcon, FileIcon, DotsVerticalIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, BoxIcon, MinusIcon, CrossCircledIcon, MobileIcon, LaptopIcon, DesktopIcon, ReloadIcon, MagicWandIcon, CircleIcon, MagnifyingGlassIcon, CaretRightIcon, FrameIcon, CheckIcon, LinkBreak2Icon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, DoubleArrowDownIcon, DoubleArrowUpIcon, ResetIcon, UploadIcon, TextIcon, CornerTopRightIcon, MixerHorizontalIcon, SunIcon, MoonIcon, ChatBubbleIcon, FaceIcon, ShuffleIcon, ImageIcon, PaperPlaneIcon, EraserIcon, LightningBoltIcon, ZoomInIcon, StackIcon } from "@radix-ui/react-icons";
7
+ import { SquareIcon, ChevronRightIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, ExclamationTriangleIcon, Cross1Icon, Pencil2Icon, ChevronLeftIcon, LoopIcon, IdCardIcon, LetterCaseCapitalizeIcon, ValueIcon, LinkBreak1Icon, EnterFullScreenIcon, PlusCircledIcon, ChevronDownIcon, InfoCircledIcon, FileIcon, DotsVerticalIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, BoxIcon, MinusIcon, CrossCircledIcon, MobileIcon, LaptopIcon, DesktopIcon, ReloadIcon, MagicWandIcon, CircleIcon, MagnifyingGlassIcon, CaretRightIcon, FrameIcon, CheckIcon, LinkBreak2Icon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, DoubleArrowDownIcon, DoubleArrowUpIcon, ResetIcon, UploadIcon, TextIcon, CornerTopRightIcon, MixerHorizontalIcon, SunIcon, MoonIcon, FaceIcon, ShuffleIcon, ChatBubbleIcon, ImageIcon, PaperPlaneIcon, EraserIcon, LightningBoltIcon, ZoomInIcon, StackIcon } from "@radix-ui/react-icons";
8
8
  import * as React from "react";
9
9
  import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, lazy, useReducer, useDebugValue } from "react";
10
10
  import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
@@ -23,6 +23,8 @@ import { useTranslation, initReactI18next } from "react-i18next";
23
23
  import { useTranslation as $e } from "react-i18next";
24
24
  import Fuse from "fuse.js";
25
25
  import UndoManager from "undo-manager";
26
+ import i18n, { t } from "i18next";
27
+ import { default as Ve } from "i18next";
26
28
  import Link from "@tiptap/extension-link";
27
29
  import TextAlign from "@tiptap/extension-text-align";
28
30
  import Underline from "@tiptap/extension-underline";
@@ -34,8 +36,6 @@ import validator from "@rjsf/validator-ajv8";
34
36
  import Autosuggest from "react-autosuggest";
35
37
  import { useFeature } from "flagged";
36
38
  import { Tree } from "react-arborist";
37
- import i18n from "i18next";
38
- import { default as Ve } from "i18next";
39
39
  import "himalaya";
40
40
  import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
41
41
  import tailwindForms from "@tailwindcss/forms";
@@ -341,16 +341,16 @@ function insertBlocksAtPosition(o, n, r, a) {
341
341
  _type: "Text",
342
342
  content: u.content
343
343
  };
344
- Object.keys(u).forEach((f) => {
345
- f.startsWith("content-") && (h[f] = u[f]);
346
- }), l.unshift(h), i = i.map((f) => {
347
- if (f._id === r) {
348
- const x = { ...f, content: "" };
349
- return Object.keys(x).forEach((y) => {
350
- y.startsWith("content-") && (x[y] = "");
351
- }), x;
344
+ Object.keys(u).forEach((x) => {
345
+ x.startsWith("content-") && (h[x] = u[x]);
346
+ }), l.unshift(h), i = i.map((x) => {
347
+ if (x._id === r) {
348
+ const f = { ...x, content: "" };
349
+ return Object.keys(f).forEach((y) => {
350
+ y.startsWith("content-") && (f[y] = "");
351
+ }), f;
352
352
  }
353
- return f;
353
+ return x;
354
354
  });
355
355
  }
356
356
  }
@@ -478,15 +478,15 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
478
478
  if (g.length === 2) {
479
479
  const m = g.find((h) => h._id !== d);
480
480
  if (m && m._type === "Text") {
481
- const h = r.find((f) => f._id === u);
482
- h && "content" in h && (r = r.map((f) => {
483
- if (f._id === u) {
484
- const x = { ...f, content: m.content };
481
+ const h = r.find((x) => x._id === u);
482
+ h && "content" in h && (r = r.map((x) => {
483
+ if (x._id === u) {
484
+ const f = { ...x, content: m.content };
485
485
  return Object.keys(m).forEach((y) => {
486
- y.startsWith("content-") && (x[y] = m[y]);
487
- }), x;
486
+ y.startsWith("content-") && (f[y] = m[y]);
487
+ }), f;
488
488
  }
489
- return f;
489
+ return x;
490
490
  }), a.push(m._id));
491
491
  }
492
492
  }
@@ -569,32 +569,32 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
569
569
  status: "idle",
570
570
  props: {},
571
571
  error: void 0
572
- }), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), m = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
572
+ }), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (x) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), m = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
573
573
  return useEffect(() => {
574
574
  if (n === "mock") {
575
575
  if (isFunction(a)) {
576
- i((x) => ({ ...x, status: "loading", props: {} }));
577
- const f = a({ block: o });
578
- if (!isObject(f))
576
+ i((f) => ({ ...f, status: "loading", props: {} }));
577
+ const x = a({ block: o });
578
+ if (!isObject(x))
579
579
  throw new Error("mockDataProvider should return an object");
580
- i((x) => ({ ...x, status: "loaded", props: f }));
580
+ i((f) => ({ ...f, status: "loaded", props: x }));
581
581
  }
582
582
  return;
583
583
  }
584
- n === "live" && (!g && !m || (i((f) => ({ ...f, status: "loading", props: {} })), d({ block: o }).then((f = {}) => {
585
- g ? (p((x) => ({
586
- ...x,
584
+ n === "live" && (!g && !m || (i((x) => ({ ...x, status: "loading", props: {} })), d({ block: o }).then((x = {}) => {
585
+ g ? (p((f) => ({
586
+ ...f,
587
587
  [o._id]: {
588
588
  status: "loaded",
589
- props: get(f, "items", []),
589
+ props: get(x, "items", []),
590
590
  repeaterItems: o.repeaterItems
591
591
  }
592
- })), 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 : {} }));
593
- }).catch((f) => {
594
- g ? (p((x) => ({
595
- ...x,
596
- [o._id]: { status: "error", error: f, props: [] }
597
- })), i((x) => ({ ...x, status: "error", error: f, props: {} }))) : i((x) => ({ ...x, status: "error", error: f, props: {} }));
592
+ })), 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 : {} }));
593
+ }).catch((x) => {
594
+ g ? (p((f) => ({
595
+ ...f,
596
+ [o._id]: { status: "error", error: x, props: [] }
597
+ })), i((f) => ({ ...f, status: "error", error: x, props: {} }))) : i((f) => ({ ...f, status: "error", error: x, props: {} }));
598
598
  })));
599
599
  }, [o == null ? void 0 : o._id, u, g, m, a, n]), {
600
600
  $loading: get(l, "status") === "loading",
@@ -749,20 +749,20 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
749
749
  return console.warn(`Failed to get block definition for type: ${r._type}`, a), !1;
750
750
  }
751
751
  }) : !1, useSavePage = () => {
752
- const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (f) => {
752
+ const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (x) => {
753
753
  }), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), [u] = useIsPageLoaded(), g = () => {
754
- const f = l();
755
- return !d || d === p ? !1 : checkMissingTranslations(f.blocks || [], d);
754
+ const x = l();
755
+ return !d || d === p ? !1 : checkMissingTranslations(x.blocks || [], d);
756
756
  };
757
757
  return { savePage: useThrottledCallback(
758
- async (f = !1) => {
758
+ async (x = !1) => {
759
759
  if (!c("save_page") || !u)
760
760
  return;
761
761
  n("SAVING"), a("SAVING");
762
- const x = l();
762
+ const f = l();
763
763
  return await r({
764
- autoSave: f,
765
- blocks: x.blocks,
764
+ autoSave: x,
765
+ blocks: f.blocks,
766
766
  theme: i,
767
767
  needTranslations: g()
768
768
  }), setTimeout(() => {
@@ -776,10 +776,10 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
776
776
  if (!c("save_page") || !u)
777
777
  return;
778
778
  n("SAVING"), a("SAVING");
779
- const f = l();
779
+ const x = l();
780
780
  return await r({
781
781
  autoSave: !0,
782
- blocks: f.blocks,
782
+ blocks: x.blocks,
783
783
  theme: i,
784
784
  needTranslations: g()
785
785
  }), setTimeout(() => {
@@ -837,65 +837,65 @@ const undoRedoStateAtom = atom({
837
837
  updateBlocksProps: c
838
838
  } = useBlocksStoreManager();
839
839
  return {
840
- moveBlocks: (x, y, b) => {
841
- const C = map(x, (j) => {
842
- const A = n.find((E) => E._id === j)._parent || null, w = n.filter((E) => A ? E._parent === A : !E._parent).map((E) => E._id).indexOf(j);
843
- return { _id: j, oldParent: A, oldPosition: w };
844
- }), B = C.find(({ _id: j }) => j === x[0]);
845
- B && B.oldParent === y && B.oldPosition === b || (i(x, y, b), o({
846
- undo: () => each(C, ({ _id: j, oldParent: _, oldPosition: A }) => {
847
- i([j], _, A);
840
+ moveBlocks: (f, y, b) => {
841
+ const C = map(f, (j) => {
842
+ const w = n.find((E) => E._id === j)._parent || null, A = n.filter((E) => w ? E._parent === w : !E._parent).map((E) => E._id).indexOf(j);
843
+ return { _id: j, oldParent: w, oldPosition: A };
844
+ }), B = C.find(({ _id: j }) => j === f[0]);
845
+ B && B.oldParent === y && B.oldPosition === b || (i(f, y, b), o({
846
+ undo: () => each(C, ({ _id: j, oldParent: _, oldPosition: w }) => {
847
+ i([j], _, w);
848
848
  }),
849
- redo: () => i(x, y, b)
849
+ redo: () => i(f, y, b)
850
850
  }));
851
851
  },
852
- addBlocks: (x, y, b) => {
853
- a(x, y, b), o({
854
- undo: () => l(map(x, "_id")),
855
- redo: () => a(x, y, b)
852
+ addBlocks: (f, y, b) => {
853
+ a(f, y, b), o({
854
+ undo: () => l(map(f, "_id")),
855
+ redo: () => a(f, y, b)
856
856
  });
857
857
  },
858
- removeBlocks: (x) => {
858
+ removeBlocks: (f) => {
859
859
  var B;
860
- const y = (B = first(x)) == null ? void 0 : B._parent, C = n.filter((j) => y ? j._parent === y : !j._parent).indexOf(first(x));
861
- l(map(x, "_id")), o({
862
- undo: () => a(x, y, C),
863
- redo: () => l(map(x, "_id"))
860
+ const y = (B = first(f)) == null ? void 0 : B._parent, C = n.filter((j) => y ? j._parent === y : !j._parent).indexOf(first(f));
861
+ l(map(f, "_id")), o({
862
+ undo: () => a(f, y, C),
863
+ redo: () => l(map(f, "_id"))
864
864
  });
865
865
  },
866
- updateBlocks: (x, y, b) => {
866
+ updateBlocks: (f, y, b) => {
867
867
  let C = [];
868
868
  if (b)
869
- C = map(x, (B) => ({ _id: B, ...b }));
869
+ C = map(f, (B) => ({ _id: B, ...b }));
870
870
  else {
871
871
  const B = keys(y);
872
- C = map(x, (j) => {
873
- const _ = n.find((k) => k._id === j), A = { _id: j };
874
- return each(B, (k) => A[k] = _[k]), A;
872
+ C = map(f, (j) => {
873
+ const _ = n.find((k) => k._id === j), w = { _id: j };
874
+ return each(B, (k) => w[k] = _[k]), w;
875
875
  });
876
876
  }
877
- c(map(x, (B) => ({ _id: B, ...y }))), o({
877
+ c(map(f, (B) => ({ _id: B, ...y }))), o({
878
878
  undo: () => c(C),
879
- redo: () => c(map(x, (B) => ({ _id: B, ...y })))
879
+ redo: () => c(map(f, (B) => ({ _id: B, ...y })))
880
880
  });
881
881
  },
882
- updateBlocksRuntime: (x, y) => {
883
- c(map(x, (b) => ({ _id: b, ...y })));
882
+ updateBlocksRuntime: (f, y) => {
883
+ c(map(f, (b) => ({ _id: b, ...y })));
884
884
  },
885
- setNewBlocks: (x) => {
886
- r(x), o({
885
+ setNewBlocks: (f) => {
886
+ r(f), o({
887
887
  undo: () => r(n),
888
- redo: () => r(x)
888
+ redo: () => r(f)
889
889
  });
890
890
  },
891
- updateMultipleBlocksProps: (x) => {
891
+ updateMultipleBlocksProps: (f) => {
892
892
  let y = [];
893
- y = map(x, (b) => {
893
+ y = map(f, (b) => {
894
894
  const C = keys(b), B = n.find((_) => _._id === b._id), j = {};
895
895
  return each(C, (_) => j[_] = B[_]), j;
896
- }), c(x), o({
896
+ }), c(f), o({
897
897
  undo: () => c(y),
898
- redo: () => c(x)
898
+ redo: () => c(f)
899
899
  });
900
900
  }
901
901
  };
@@ -903,12 +903,12 @@ const undoRedoStateAtom = atom({
903
903
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
904
904
  (i, c, d) => {
905
905
  var h;
906
- for (let f = 0; f < i.length; f++) {
907
- const { _id: x } = i[f];
908
- i[f]._id = generateUUID();
909
- const y = filter(i, { _parent: x });
906
+ for (let x = 0; x < i.length; x++) {
907
+ const { _id: f } = i[x];
908
+ i[x]._id = generateUUID();
909
+ const y = filter(i, { _parent: f });
910
910
  for (let b = 0; b < y.length; b++)
911
- y[b]._parent = i[f]._id;
911
+ y[b]._parent = i[x]._id;
912
912
  }
913
913
  const p = first(i);
914
914
  let u, g;
@@ -2361,36 +2361,36 @@ const getBlockWithChildren = (o, n) => {
2361
2361
  return isEmpty(d) ? !1 : (has(i, "_parent") && isEmpty(i._parent) && delete i._parent, { ...i, ...d });
2362
2362
  })
2363
2363
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2364
- const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (h, f) => {
2365
- const x = cloneDeep(f.find((y) => y._id === h));
2366
- for (const y in x) {
2367
- const b = x[y];
2364
+ const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (h, x) => {
2365
+ const f = cloneDeep(x.find((y) => y._id === h));
2366
+ for (const y in f) {
2367
+ const b = f[y];
2368
2368
  if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
2369
2369
  const { baseClasses: C, classes: B } = getSplitChaiClasses(b);
2370
- x[y] = compact(flattenDeep([C, B])).join(" ");
2370
+ f[y] = compact(flattenDeep([C, B])).join(" ");
2371
2371
  } else
2372
- y !== "_id" && delete x[y];
2372
+ y !== "_id" && delete f[y];
2373
2373
  }
2374
- return x;
2374
+ return f;
2375
2375
  };
2376
2376
  return {
2377
2377
  askAi: useCallback(
2378
- async (h, f, x, y) => {
2378
+ async (h, x, f, y) => {
2379
2379
  if (l) {
2380
2380
  n(!0), a(null);
2381
2381
  try {
2382
2382
  const b = p === u ? "" : p;
2383
- console.log("prompt", x);
2384
- const C = x.toLowerCase().includes("translate the content"), B = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p, C) : [m(f, d)], j = await l(h, addLangToPrompt(x, g, h), B, b), { blocks: _, error: A } = j;
2385
- if (A) {
2386
- a(A);
2383
+ console.log("prompt", f);
2384
+ const C = f.toLowerCase().includes("translate the content"), B = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p, C) : [m(x, d)], j = await l(h, addLangToPrompt(f, g, h), B, b), { blocks: _, error: w } = j;
2385
+ if (w) {
2386
+ a(w);
2387
2387
  return;
2388
2388
  }
2389
2389
  if (h === "styles") {
2390
- const k = _.map((w) => {
2391
- for (const E in w)
2392
- E !== "_id" && (w[E] = `${STYLES_KEY},${w[E]}`);
2393
- return w;
2390
+ const k = _.map((A) => {
2391
+ for (const E in A)
2392
+ E !== "_id" && (A[E] = `${STYLES_KEY},${A[E]}`);
2393
+ return A;
2394
2394
  });
2395
2395
  c(k);
2396
2396
  } else
@@ -2493,12 +2493,12 @@ const getBlockWithChildren = (o, n) => {
2493
2493
  if (!p)
2494
2494
  return m;
2495
2495
  let h = [];
2496
- for (const f of m)
2497
- if (f._type === "PartialBlock" || f._type === "GlobalBlock") {
2498
- let x = l(f.partialBlockId);
2499
- f._parent && (x == null ? void 0 : x.length) > 0 && (x = x.map((y) => (isEmpty(y._parent) && set(y, "_parent", f._parent), y))), h = [...h, ...x];
2496
+ for (const x of m)
2497
+ if (x._type === "PartialBlock" || x._type === "GlobalBlock") {
2498
+ let f = l(x.partialBlockId);
2499
+ x._parent && (f == null ? void 0 : f.length) > 0 && (f = f.map((y) => (isEmpty(y._parent) && set(y, "_parent", x._parent), y))), h = [...h, ...f];
2500
2500
  } else
2501
- h.push(f);
2501
+ h.push(x);
2502
2502
  return h;
2503
2503
  })
2504
2504
  };
@@ -2673,13 +2673,13 @@ const getBlockWithChildren = (o, n) => {
2673
2673
  const d = o(c), p = a;
2674
2674
  let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
2675
2675
  return each(p, (m) => {
2676
- const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2677
- u = u.replace(f, " ").replace(/\s+/g, " ").trim();
2678
- const x = first(m.split(":"));
2679
- includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
2676
+ const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2677
+ u = u.replace(x, " ").replace(/\s+/g, " ").trim();
2678
+ const f = first(m.split(":"));
2679
+ includes(["2xl", "xl", "lg", "md", "sm"], f) && p.push(m.split(":").pop().trim());
2680
2680
  }), each(p, (m) => {
2681
- const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2682
- g = g.replace(f, " ").replace(/\s+/g, " ").trim();
2681
+ const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2682
+ g = g.replace(x, " ").replace(/\s+/g, " ").trim();
2683
2683
  }), {
2684
2684
  ids: [d._id],
2685
2685
  props: {
@@ -2828,21 +2828,21 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2828
2828
  return "VERTICAL";
2829
2829
  }
2830
2830
  }, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
2831
- const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), f = useCallback(
2832
- (x) => {
2833
- isDisabledControl(g, m, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
2831
+ const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (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, m = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), x = useCallback(
2832
+ (f) => {
2833
+ isDisabledControl(g, m, f) || p || (f === "UP" || f === "LEFT" ? l([i], c || null, u - 1) : (f === "DOWN" || f === "RIGHT") && l([i], c || null, u + 2), n());
2834
2834
  },
2835
2835
  [g, m, p, u, i, c, n]
2836
2836
  );
2837
2837
  return useHotkeys(
2838
2838
  "shift+up, shift+down, shift+left, shift+right",
2839
- ({ key: x }) => {
2839
+ ({ key: f }) => {
2840
2840
  var y;
2841
- f((y = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : y.toUpperCase());
2841
+ x((y = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : y.toUpperCase());
2842
2842
  },
2843
2843
  { document: a == null ? void 0 : a.contentDocument },
2844
- [f]
2845
- ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation: h };
2844
+ [x]
2845
+ ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: x, orientation: h };
2846
2846
  }, BlockController = ({ block: o, updateFloatingBar: n }) => {
2847
2847
  const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
2848
2848
  o,
@@ -3010,7 +3010,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
3010
3010
  elements: { reference: n }
3011
3011
  });
3012
3012
  useResizeObserver(n, () => h(), n !== null), useResizeObserver(u == null ? void 0 : u.body, () => h(), (u == null ? void 0 : u.body) !== null);
3013
- const f = get(o, "_parent", null), x = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
3013
+ const x = get(o, "_parent", null), f = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
3014
3014
  return useEffect(() => {
3015
3015
  if (n) {
3016
3016
  const y = setTimeout(() => h(), 500);
@@ -3033,16 +3033,16 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
3033
3033
  onKeyDown: (y) => y.stopPropagation(),
3034
3034
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3035
3035
  children: [
3036
- f && /* @__PURE__ */ jsx(
3036
+ x && /* @__PURE__ */ jsx(
3037
3037
  ArrowUpIcon,
3038
3038
  {
3039
3039
  className: "hover:scale-105",
3040
3040
  onClick: () => {
3041
- c([]), l([f]);
3041
+ c([]), l([x]);
3042
3042
  }
3043
3043
  }
3044
3044
  ),
3045
- /* @__PURE__ */ jsx(BlockActionLabel, { label: x, block: o }),
3045
+ /* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: o }),
3046
3046
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
3047
3047
  /* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
3048
3048
  canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([o == null ? void 0 : o._id]) }) : null,
@@ -3200,8 +3200,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3200
3200
  i
3201
3201
  ]), useHotkeys(
3202
3202
  "del, backspace",
3203
- (f) => {
3204
- f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
3203
+ (x) => {
3204
+ x.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
3205
3205
  },
3206
3206
  h,
3207
3207
  [n, l]
@@ -3503,8 +3503,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3503
3503
  ],
3504
3504
  onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
3505
3505
  onBlur: ({ editor: u, event: g }) => {
3506
- const m = g.relatedTarget, h = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = h == null ? void 0 : h.contains(m), y = f == null ? void 0 : f.contains(m);
3507
- if (!x && !y) {
3506
+ const m = g.relatedTarget, h = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = h == null ? void 0 : h.contains(m), y = x == null ? void 0 : x.contains(m);
3507
+ if (!f && !y) {
3508
3508
  const b = (u == null ? void 0 : u.getHTML()) || "";
3509
3509
  r(b);
3510
3510
  }
@@ -3559,14 +3559,14 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3559
3559
  useEffect(() => {
3560
3560
  if (a.current) {
3561
3561
  a.current.innerText = n, a.current.focus();
3562
- const h = c.createRange(), f = d.getSelection();
3563
- h.selectNodeContents(a.current), h.collapse(!1), f == null || f.removeAllRanges(), f == null || f.addRange(h), a.current.focus();
3562
+ const h = c.createRange(), x = d.getSelection();
3563
+ h.selectNodeContents(a.current), h.collapse(!1), x == null || x.removeAllRanges(), x == null || x.addRange(h), a.current.focus();
3564
3564
  } else
3565
3565
  r();
3566
3566
  }, [c, d]);
3567
3567
  const p = useMemo(() => {
3568
- var f;
3569
- const h = ((f = o == null ? void 0 : o.tagName) == null ? void 0 : f.toLowerCase()) || "div";
3568
+ var x;
3569
+ const h = ((x = o == null ? void 0 : o.tagName) == null ? void 0 : x.toLowerCase()) || "div";
3570
3570
  return h === "button" ? "div" : h;
3571
3571
  }, [o]), u = useCallback(
3572
3572
  (h) => {
@@ -3582,12 +3582,12 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3582
3582
  contentEditable: !0,
3583
3583
  className: `${((h = o == null ? void 0 : o.className) == null ? void 0 : h.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]`,
3584
3584
  style: cloneDeep(o == null ? void 0 : o.style) || {},
3585
- onInput: (f) => {
3586
- const x = f.target;
3587
- 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));
3585
+ onInput: (x) => {
3586
+ const f = x.target;
3587
+ 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));
3588
3588
  },
3589
- onClick: (f) => {
3590
- f.stopPropagation(), f.preventDefault();
3589
+ onClick: (x) => {
3590
+ x.stopPropagation(), x.preventDefault();
3591
3591
  }
3592
3592
  };
3593
3593
  }, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
@@ -3600,38 +3600,38 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3600
3600
  }
3601
3601
  ), WithBlockTextEditor = memo(
3602
3602
  ({ block: o, children: n }) => {
3603
- const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: f } = useLanguages(), [, x] = useSelectedBlockIds(), y = useRef(null), b = l, { blockContent: C, blockType: B } = useMemo(() => {
3603
+ const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: x } = useLanguages(), [, f] = useSelectedBlockIds(), y = useRef(null), b = l, { blockContent: C, blockType: B } = useMemo(() => {
3604
3604
  var I;
3605
- const w = o._type;
3605
+ const A = o._type;
3606
3606
  let E = o[r];
3607
3607
  const S = getRegisteredChaiBlock(o._type);
3608
- return f && ((I = S == null ? void 0 : S.i18nProps) == null ? void 0 : I.includes(r)) && has(o, `${r}-${f}`) && (E = get(o, `${r}-${f}`)), { blockContent: E, blockType: w };
3609
- }, [o, f]), j = useCallback(
3610
- (w) => {
3608
+ return x && ((I = S == null ? void 0 : S.i18nProps) == null ? void 0 : I.includes(r)) && has(o, `${r}-${x}`) && (E = get(o, `${r}-${x}`)), { blockContent: E, blockType: A };
3609
+ }, [o, x]), j = useCallback(
3610
+ (A) => {
3611
3611
  var S;
3612
- const E = w || ((S = g.current) == null ? void 0 : S.innerText);
3613
- h([b], { [r]: E }), u(null), c(null), d(-1), x(b ? [b] : []);
3612
+ const E = A || ((S = g.current) == null ? void 0 : S.innerText);
3613
+ h([b], { [r]: E }), u(null), c(null), d(-1), f(b ? [b] : []);
3614
3614
  },
3615
- [b, h, c, x, f]
3615
+ [b, h, c, f, x]
3616
3616
  ), _ = useDebouncedCallback(
3617
- (w) => {
3618
- h([b], { [r]: w });
3617
+ (A) => {
3618
+ h([b], { [r]: A });
3619
3619
  },
3620
- [b, o, h, f],
3620
+ [b, o, h, x],
3621
3621
  1e3
3622
- ), A = useCallback(
3623
- (w) => {
3624
- w.preventDefault(), b && (y.current = b), j(), setTimeout(() => {
3622
+ ), w = useCallback(
3623
+ (A) => {
3624
+ A.preventDefault(), b && (y.current = b), j(), setTimeout(() => {
3625
3625
  const E = y.current;
3626
- y.current = null, x([E]);
3626
+ y.current = null, f([E]);
3627
3627
  }, 100);
3628
3628
  },
3629
- [x, b, f]
3629
+ [f, b, x]
3630
3630
  );
3631
3631
  useEffect(() => {
3632
3632
  var v;
3633
3633
  if (!b) return;
3634
- const w = `[data-block-id="${b}"]`, E = i >= 0 ? `[data-block-index="${i}"]` : "", S = a.querySelector(`${w}${E}`);
3634
+ const A = `[data-block-id="${b}"]`, E = i >= 0 ? `[data-block-index="${i}"]` : "", S = a.querySelector(`${A}${E}`);
3635
3635
  S && ((v = S == null ? void 0 : S.classList) == null || v.add("sr-only"), u(S));
3636
3636
  }, [b, B, a, i]);
3637
3637
  const k = useMemo(() => p ? (m(), B === "RichText" ? /* @__PURE__ */ jsx(
@@ -3641,7 +3641,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3641
3641
  editingElement: p,
3642
3642
  onChange: _,
3643
3643
  onClose: j,
3644
- onEscape: A
3644
+ onEscape: w
3645
3645
  }
3646
3646
  ) : /* @__PURE__ */ jsx(
3647
3647
  MemoizedEditor,
@@ -3651,9 +3651,9 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3651
3651
  editingElement: p,
3652
3652
  onClose: j,
3653
3653
  onChange: _,
3654
- onEscape: A
3654
+ onEscape: w
3655
3655
  }
3656
- )) : null, [p, b, B, C, j, f]);
3656
+ )) : null, [p, b, B, C, j, x]);
3657
3657
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3658
3658
  k,
3659
3659
  n
@@ -3688,18 +3688,18 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3688
3688
  blockAtom: n,
3689
3689
  children: r
3690
3690
  }) => {
3691
- const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useAtom$1(dataBindingActiveAtom), h = get(c, "component", null), { index: f, key: x } = useContext(RepeaterContext), y = useMemo(
3691
+ const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useAtom$1(dataBindingActiveAtom), h = get(c, "component", null), { index: x, key: f } = useContext(RepeaterContext), y = useMemo(
3692
3692
  () => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
3693
- index: f,
3694
- key: x
3693
+ index: x,
3694
+ key: f
3695
3695
  }) : applyLanguage(i, d, c),
3696
- [i, d, c, g, m, f, x]
3696
+ [i, d, c, g, m, x, f]
3697
3697
  ), b = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), C = useMemo(
3698
3698
  () => u(i._id, getBlockRuntimeProps(i._type)),
3699
3699
  [i._id, i._type, u, getBlockRuntimeProps]
3700
3700
  ), B = useMemo(
3701
3701
  () => ({
3702
- blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": f },
3702
+ blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": x },
3703
3703
  inBuilder: !0,
3704
3704
  lang: d || p,
3705
3705
  ...y,
@@ -3719,7 +3719,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3719
3719
  ]
3720
3720
  ), j = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]), _ = useMemo(() => get(i, "_show", !0), [i]);
3721
3721
  if (isNull(h) || !_) return null;
3722
- let A = /* @__PURE__ */ jsx(Suspense, { children: createElement(h, {
3722
+ let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(h, {
3723
3723
  ...B,
3724
3724
  children: r({
3725
3725
  _id: i._id,
@@ -3732,7 +3732,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3732
3732
  ...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
3733
3733
  })
3734
3734
  }) });
3735
- const k = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: A }) : A;
3735
+ const k = a === i._id && (l === x || x < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: w }) : w;
3736
3736
  return j ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: k }) : k;
3737
3737
  }, PartialWrapper$1 = ({ children: o, partialBlockId: n }) => {
3738
3738
  const r = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
@@ -3773,7 +3773,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3773
3773
  );
3774
3774
  return map(l, (c) => {
3775
3775
  const d = a(c._id);
3776
- return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: m, repeaterItems: h, $repeaterItemsKey: f }) => g === "Repeater" ? isArray(h) && h.map((x, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: f }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) }, `${u}-${y}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: m }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3776
+ return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: m, repeaterItems: h, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(h) && h.map((f, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) }, `${u}-${y}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: m }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3777
3777
  });
3778
3778
  }, PageBlocksRenderer = () => {
3779
3779
  const [o] = useBlocksStore();
@@ -3841,14 +3841,14 @@ const CanvasEventsWatcher = () => {
3841
3841
  }, StaticCanvas = () => {
3842
3842
  const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useAtom$1(canvasIframeAtom), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), g = useCallback(
3843
3843
  (h) => {
3844
- i((f) => ({ ...f, width: h }));
3844
+ i((x) => ({ ...x, width: h }));
3845
3845
  },
3846
3846
  [i]
3847
3847
  );
3848
3848
  useEffect(() => {
3849
3849
  if (!a.current) return;
3850
- const { clientWidth: h, clientHeight: f } = a.current;
3851
- i({ width: h, height: f });
3850
+ const { clientWidth: h, clientHeight: x } = a.current;
3851
+ i({ width: h, height: x });
3852
3852
  }, [a, o]);
3853
3853
  const m = useMemo(() => {
3854
3854
  let h = IframeInitialContent;
@@ -3895,10 +3895,13 @@ const CanvasEventsWatcher = () => {
3895
3895
  )
3896
3896
  }
3897
3897
  ) });
3898
- }, FallbackError = () => /* @__PURE__ */ jsx("div", { className: "h-full w-full rounded-md bg-red-200 p-4 text-red-500", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center", children: [
3899
- /* @__PURE__ */ jsx("p", { className: "font-semibold", children: "Oops! Something went wrong." }),
3900
- /* @__PURE__ */ jsx("p", { children: "Please try again." })
3901
- ] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-GydqqBXp.js")), CanvasArea = () => {
3898
+ }, FallbackError = () => {
3899
+ const { t: o } = useTranslation();
3900
+ return /* @__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: [
3901
+ /* @__PURE__ */ jsx("p", { className: "font-semibold", children: o("Oops! Something went wrong.") }),
3902
+ /* @__PURE__ */ jsx("p", { children: o("Please try again.") })
3903
+ ] }) });
3904
+ }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-GydqqBXp.js")), CanvasArea = () => {
3902
3905
  const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
3903
3906
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40", children: [
3904
3907
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -3963,8 +3966,8 @@ const CanvasEventsWatcher = () => {
3963
3966
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
3964
3967
  ] });
3965
3968
  }, DefaultMediaManager = ({ close: o, onSelect: n, mode: r = "image" }) => {
3966
- const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), m = async (f) => {
3967
- if (!f.trim()) {
3969
+ const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), m = async (x) => {
3970
+ if (!x.trim()) {
3968
3971
  p(!1), g("Please enter a URL");
3969
3972
  return;
3970
3973
  }
@@ -3988,7 +3991,7 @@ const CanvasEventsWatcher = () => {
3988
3991
  {
3989
3992
  placeholder: h(`Enter ${r} URL`),
3990
3993
  value: a,
3991
- onChange: (f) => l(f.target.value),
3994
+ onChange: (x) => l(x.target.value),
3992
3995
  onKeyUp: () => m(a)
3993
3996
  }
3994
3997
  ),
@@ -4028,7 +4031,7 @@ const CanvasEventsWatcher = () => {
4028
4031
  };
4029
4032
  MediaManagerModal.displayName = "MediaManagerModal";
4030
4033
  const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==", ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
4031
- const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = r.split(".").pop() || "", u = i ? `_${p}Id-${i}` : `_${p}Id`, g = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), m = get(c, u, g ? c == null ? void 0 : c.assetId : ""), h = !!m, f = (y) => {
4034
+ const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = r.split(".").pop() || "", u = i ? `_${p}Id-${i}` : `_${p}Id`, g = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), m = get(c, u, g ? c == null ? void 0 : c.assetId : ""), h = !!m, x = (y) => {
4032
4035
  const b = isArray(y) ? first(y) : y;
4033
4036
  if (b) {
4034
4037
  n(b == null ? void 0 : b.url);
@@ -4043,7 +4046,7 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4043
4046
  d([c._id], j);
4044
4047
  }
4045
4048
  }
4046
- }, x = useCallback(() => {
4049
+ }, f = useCallback(() => {
4047
4050
  n(PLACEHOLDER_IMAGE), c != null && c._id && d([c._id], { assetId: "" });
4048
4051
  }, [n, c == null ? void 0 : c._id, d]);
4049
4052
  return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-center gap-x-3", children: [
@@ -4060,12 +4063,12 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4060
4063
  "button",
4061
4064
  {
4062
4065
  type: "button",
4063
- onClick: x,
4066
+ onClick: f,
4064
4067
  className: "absolute -right-2 -top-2 z-20 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",
4065
4068
  children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" })
4066
4069
  }
4067
4070
  ),
4068
- m && m !== "" && /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: f, assetId: m, children: /* @__PURE__ */ jsx(
4071
+ m && m !== "" && /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: x, assetId: m, children: /* @__PURE__ */ jsx(
4069
4072
  "button",
4070
4073
  {
4071
4074
  type: "button",
@@ -4073,10 +4076,10 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4073
4076
  children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-4 w-4 text-white" })
4074
4077
  }
4075
4078
  ) })
4076
- ] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: f, mode: "image", assetId: m, children: /* @__PURE__ */ jsx("div", { className: "h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
4079
+ ] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: x, mode: "image", assetId: m, children: /* @__PURE__ */ jsx("div", { className: "h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
4077
4080
  /* @__PURE__ */ jsxs("div", { className: "flex w-3/5 flex-col", children: [
4078
4081
  /* @__PURE__ */ jsxs(Fragment, { children: [
4079
- /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: f, assetId: "", children: /* @__PURE__ */ jsx("small", { className: "h-6 cursor-pointer rounded-md bg-secondary px-2 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: o || !isEmpty(o) ? l("Replace image") : l("Choose image") }) }),
4082
+ /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: x, assetId: "", children: /* @__PURE__ */ jsx("small", { className: "h-6 cursor-pointer rounded-md bg-secondary px-2 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: o || !isEmpty(o) ? l("Replace image") : l("Choose image") }) }),
4080
4083
  /* @__PURE__ */ jsx("small", { className: "-pl-4 pt-2 text-center text-xs text-secondary-foreground", children: "OR" })
4081
4084
  ] }),
4082
4085
  /* @__PURE__ */ jsx(
@@ -4099,24 +4102,24 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4099
4102
  }, PathDropdown = ({ data: o, onSelect: n, dataType: r }) => {
4100
4103
  const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (m) => Array.isArray(m) ? "array" : typeof m == "object" && m !== null ? "object" : "value", p = React__default.useCallback(
4101
4104
  (m) => {
4102
- const h = (f) => r === "value" ? f === "value" || f === "object" : r === "array" ? f === "array" : f === r;
4103
- m.type === "object" ? (l((f) => [...f, m.key]), c(m.value)) : h(m.type) && n([...a, m.key].join("."), r);
4105
+ const h = (x) => r === "value" ? x === "value" || x === "object" : r === "array" ? x === "array" : x === r;
4106
+ m.type === "object" ? (l((x) => [...x, m.key]), c(m.value)) : h(m.type) && n([...a, m.key].join("."), r);
4104
4107
  },
4105
4108
  [a, n, r]
4106
4109
  ), u = React__default.useCallback(() => {
4107
4110
  if (a.length > 0) {
4108
4111
  const m = a.slice(0, -1);
4109
- l(m), c(m.reduce((h, f) => h[f], o));
4112
+ l(m), c(m.reduce((h, x) => h[x], o));
4110
4113
  }
4111
4114
  }, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([m, h]) => ({ key: m, value: h, type: d(h) })).filter((m) => !startsWith(m.key, REPEATER_PREFIX) && m.key.includes("/") ? !1 : r === "value" ? m.type === "value" || m.type === "object" : r === "array" ? m.type === "array" || m.type === "object" : r === "object" ? m.type === "object" : !0) : [], [i, r]);
4112
4115
  return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
4113
4116
  /* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
4114
4117
  /* @__PURE__ */ jsxs(CommandList, { children: [
4115
- /* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
4118
+ /* @__PURE__ */ jsx(CommandEmpty, { children: t("No option found.") }),
4116
4119
  /* @__PURE__ */ jsxs(CommandGroup, { children: [
4117
4120
  a.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: u, className: "flex items-center text-sm", children: [
4118
4121
  /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "mr-2 h-4 w-4" }),
4119
- "Back"
4122
+ t("Back")
4120
4123
  ] }),
4121
4124
  g.map((m) => /* @__PURE__ */ jsxs(
4122
4125
  CommandItem,
@@ -4128,7 +4131,7 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4128
4131
  children: [
4129
4132
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-2", children: [
4130
4133
  startsWith(m.key, REPEATER_PREFIX) ? /* @__PURE__ */ jsx(LoopIcon, {}) : startsWith(m.key, COLLECTION_PREFIX) ? /* @__PURE__ */ jsx(IdCardIcon, {}) : null,
4131
- startsWith(m.key, REPEATER_PREFIX) ? "Repeater Data" : startsWith(m.key, COLLECTION_PREFIX) ? m.key.replace(COLLECTION_PREFIX, "") : m.key
4134
+ startsWith(m.key, REPEATER_PREFIX) ? t("Repeater Data") : startsWith(m.key, COLLECTION_PREFIX) ? m.key.replace(COLLECTION_PREFIX, "") : m.key
4132
4135
  ] }),
4133
4136
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
4134
4137
  r === "object" && m.type === "object" && /* @__PURE__ */ jsx(
@@ -4140,7 +4143,7 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4140
4143
  onClick: (h) => {
4141
4144
  h.stopPropagation(), n([...a, m.key].join("."), r);
4142
4145
  },
4143
- children: "Select"
4146
+ children: t("Select")
4144
4147
  }
4145
4148
  ),
4146
4149
  m.type === "object" && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 opacity-50" }) })
@@ -4177,7 +4180,7 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4177
4180
  ) })
4178
4181
  }
4179
4182
  ) }) }),
4180
- /* @__PURE__ */ jsx(TooltipContent, { children: "Add field" })
4183
+ /* @__PURE__ */ jsx(TooltipContent, { children: t("Add field") })
4181
4184
  ] }),
4182
4185
  /* @__PURE__ */ jsx(PopoverContent, { className: "z-[1000]! relative mr-3 w-[300px] p-0", children: /* @__PURE__ */ jsx(
4183
4186
  PathDropdown,
@@ -4199,7 +4202,7 @@ const DataBindingSelector = ({
4199
4202
  }) => {
4200
4203
  const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
4201
4204
  if (i.length === 1) return "";
4202
- const g = i.find((f) => f._type === "Repeater"), h = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
4205
+ const g = i.find((x) => x._type === "Repeater"), h = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
4203
4206
  return `${REPEATER_PREFIX}${startsWith(h, COLLECTION_PREFIX) ? `${h}/${g._id}` : h}`;
4204
4207
  }, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
4205
4208
  (g, m) => {
@@ -4207,16 +4210,16 @@ const DataBindingSelector = ({
4207
4210
  n(`{{${g}}}`, {}, r);
4208
4211
  return;
4209
4212
  }
4210
- const h = (b) => /[.,!?;:]/.test(b), f = (b, C, B) => {
4213
+ const h = (b) => /[.,!?;:]/.test(b), x = (b, C, B) => {
4211
4214
  let j = "", _ = "";
4212
- const A = C > 0 ? b[C - 1] : "", k = C < b.length ? b[C] : "";
4213
- return C > 0 && (A === "." || !h(A) && A !== " ") && (j = " "), C < b.length && !h(k) && k !== " " && (_ = " "), {
4215
+ const w = C > 0 ? b[C - 1] : "", k = C < b.length ? b[C] : "";
4216
+ return C > 0 && (w === "." || !h(w) && w !== " ") && (j = " "), C < b.length && !h(k) && k !== " " && (_ = " "), {
4214
4217
  text: j + B + _,
4215
4218
  prefixLength: j.length,
4216
4219
  suffixLength: _.length
4217
4220
  };
4218
- }, x = document.getElementById(r);
4219
- if (!x) return;
4221
+ }, f = document.getElementById(r);
4222
+ if (!f) return;
4220
4223
  const y = document.getElementById(`chai-rte-${r}`) || document.getElementById(`chai-rte-modal-${r}`);
4221
4224
  if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
4222
4225
  const b = y.__chaiRTE;
@@ -4227,9 +4230,9 @@ const DataBindingSelector = ({
4227
4230
  if (B !== j)
4228
4231
  b.chain().deleteSelection().insertContent(C).run();
4229
4232
  else {
4230
- const { state: A } = b, k = A.selection.from, w = A.doc.textBetween(Math.max(0, k - 1), k), E = A.doc.textBetween(k, Math.min(k + 1, A.doc.content.size));
4233
+ const { state: w } = b, k = w.selection.from, A = w.doc.textBetween(Math.max(0, k - 1), k), E = w.doc.textBetween(k, Math.min(k + 1, w.doc.content.size));
4231
4234
  let S = "";
4232
- k > 0 && w !== " " && !h(w) && (S = " ");
4235
+ k > 0 && A !== " " && !h(A) && (S = " ");
4233
4236
  let v = "";
4234
4237
  E && E !== " " && !h(E) && (v = " "), b.chain().insertContent(S + C + v).run();
4235
4238
  }
@@ -4237,14 +4240,14 @@ const DataBindingSelector = ({
4237
4240
  return;
4238
4241
  }
4239
4242
  } else {
4240
- const b = x, C = b.selectionStart || 0, B = b.value || "", j = b.selectionEnd || C;
4243
+ const b = f, C = b.selectionStart || 0, B = b.value || "", j = b.selectionEnd || C;
4241
4244
  if (j > C) {
4242
- const E = `{{${g}}}`, { text: S } = f(B, C, E), v = B.slice(0, C) + S + B.slice(j);
4245
+ const E = `{{${g}}}`, { text: S } = x(B, C, E), v = B.slice(0, C) + S + B.slice(j);
4243
4246
  n(v, {}, r);
4244
4247
  return;
4245
4248
  }
4246
- const A = `{{${g}}}`, { text: k } = f(B, C, A), w = B.slice(0, C) + k + B.slice(C);
4247
- n(w, {}, r);
4249
+ const w = `{{${g}}}`, { text: k } = x(B, C, w), A = B.slice(0, C) + k + B.slice(C);
4250
+ n(A, {}, r);
4248
4251
  }
4249
4252
  },
4250
4253
  [r, n, a, c == null ? void 0 : c._id, d]
@@ -4266,9 +4269,9 @@ const DataBindingSelector = ({
4266
4269
  onChange: r
4267
4270
  }) => {
4268
4271
  var E;
4269
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (S, v) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [y, b] = useState(-1), C = useRef(null), B = (E = n == null ? void 0 : n.find((S) => S.key === u)) == null ? void 0 : E.name;
4272
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (S, v) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [x, f] = useState([]), [y, b] = useState(-1), C = useRef(null), B = (E = n == null ? void 0 : n.find((S) => S.key === u)) == null ? void 0 : E.name;
4270
4273
  useEffect(() => {
4271
- if (h(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4274
+ if (h(""), f([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4272
4275
  const S = split(o, ":"), v = get(S, 1, "page") || "page";
4273
4276
  g(v), (async () => {
4274
4277
  const I = await l(v, [get(S, 2, "page")]);
@@ -4278,10 +4281,10 @@ const DataBindingSelector = ({
4278
4281
  const j = useDebouncedCallback(
4279
4282
  async (S) => {
4280
4283
  if (isEmpty(S))
4281
- x([]);
4284
+ f([]);
4282
4285
  else {
4283
4286
  const v = await l(u, S);
4284
- x(v);
4287
+ f(v);
4285
4288
  }
4286
4289
  c(!1), b(-1);
4287
4290
  },
@@ -4289,18 +4292,18 @@ const DataBindingSelector = ({
4289
4292
  300
4290
4293
  ), _ = (S) => {
4291
4294
  const v = ["pageType", u, S.id];
4292
- v[1] && (r(v.join(":")), h(S.name), p(!1), x([]), b(-1));
4293
- }, A = (S) => {
4295
+ v[1] && (r(v.join(":")), h(S.name), p(!1), f([]), b(-1));
4296
+ }, w = (S) => {
4294
4297
  switch (S.key) {
4295
4298
  case "ArrowDown":
4296
- S.preventDefault(), b((v) => v < f.length - 1 ? v + 1 : v);
4299
+ S.preventDefault(), b((v) => v < x.length - 1 ? v + 1 : v);
4297
4300
  break;
4298
4301
  case "ArrowUp":
4299
4302
  S.preventDefault(), b((v) => v > 0 ? v - 1 : v);
4300
4303
  break;
4301
4304
  case "Enter":
4302
- if (S.preventDefault(), f.length === 0) return;
4303
- y >= 0 && _(f[y]);
4305
+ if (S.preventDefault(), x.length === 0) return;
4306
+ y >= 0 && _(x[y]);
4304
4307
  break;
4305
4308
  case "Escape":
4306
4309
  S.preventDefault(), k();
@@ -4314,8 +4317,8 @@ const DataBindingSelector = ({
4314
4317
  }
4315
4318
  }, [y]);
4316
4319
  const k = () => {
4317
- h(""), x([]), b(-1), p(!1), r("");
4318
- }, w = (S) => {
4320
+ h(""), f([]), b(-1), p(!1), r("");
4321
+ }, A = (S) => {
4319
4322
  h(S), p(!isEmpty(S)), c(!0), j(S);
4320
4323
  };
4321
4324
  return /* @__PURE__ */ jsxs("div", { children: [
@@ -4326,23 +4329,23 @@ const DataBindingSelector = ({
4326
4329
  {
4327
4330
  type: "text",
4328
4331
  value: m,
4329
- onChange: (S) => w(S.target.value),
4330
- onKeyDown: A,
4332
+ onChange: (S) => A(S.target.value),
4333
+ onKeyDown: w,
4331
4334
  placeholder: a(`Search ${B ?? ""}`),
4332
4335
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4333
4336
  }
4334
4337
  ),
4335
4338
  /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: k, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" }) }) })
4336
4339
  ] }),
4337
- (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: [
4340
+ (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: [
4338
4341
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
4339
4342
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
4340
- ] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4343
+ ] }) : d && isEmpty(x) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4341
4344
  a("No results found for"),
4342
4345
  ' "',
4343
4346
  m,
4344
4347
  '"'
4345
- ] }) : /* @__PURE__ */ jsx("ul", { ref: C, children: map(f == null ? void 0 : f.slice(0, 20), (S, v) => /* @__PURE__ */ jsxs(
4348
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: C, children: map(x == null ? void 0 : x.slice(0, 20), (S, v) => /* @__PURE__ */ jsxs(
4346
4349
  "li",
4347
4350
  {
4348
4351
  onClick: () => _(S),
@@ -4657,15 +4660,15 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4657
4660
  if (!u) return;
4658
4661
  const h = `{{${m}}}`;
4659
4662
  u.commands.focus();
4660
- const { from: f, to: x } = u.state.selection;
4661
- if (f !== x)
4663
+ const { from: x, to: f } = u.state.selection;
4664
+ if (x !== f)
4662
4665
  u.chain().deleteSelection().insertContent(h).run();
4663
4666
  else {
4664
4667
  const { state: b } = u, C = b.selection.from, B = b.doc.textBetween(Math.max(0, C - 1), C), j = b.doc.textBetween(C, Math.min(C + 1, b.doc.content.size));
4665
4668
  let _ = "";
4666
4669
  C > 0 && B !== " " && !/[.,!?;:]/.test(B) && (_ = " ");
4667
- let A = "";
4668
- j && j !== " " && !/[.,!?;:]/.test(j) && (A = " "), u.chain().insertContent(_ + h + A).run();
4670
+ let w = "";
4671
+ j && j !== " " && !/[.,!?;:]/.test(j) && (w = " "), u.chain().insertContent(_ + h + w).run();
4669
4672
  }
4670
4673
  };
4671
4674
  return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (m) => !m && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
@@ -4704,13 +4707,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4704
4707
  })
4705
4708
  ],
4706
4709
  content: r || "",
4707
- onUpdate: ({ editor: f }) => {
4708
- const x = f.getHTML();
4709
- a(x), c || u(x);
4710
+ onUpdate: ({ editor: x }) => {
4711
+ const f = x.getHTML();
4712
+ a(f), c || u(f);
4710
4713
  },
4711
- onBlur: ({ editor: f }) => {
4712
- const x = f.getHTML();
4713
- l(o, x);
4714
+ onBlur: ({ editor: x }) => {
4715
+ const f = x.getHTML();
4716
+ l(o, f);
4714
4717
  },
4715
4718
  editorProps: {
4716
4719
  attributes: {
@@ -4723,8 +4726,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4723
4726
  }, [g]), useEffect(() => {
4724
4727
  u(r || "");
4725
4728
  }, [r]);
4726
- const m = (f) => {
4727
- a(f);
4729
+ const m = (x) => {
4730
+ a(x);
4728
4731
  }, h = () => {
4729
4732
  d(!1), g && g.commands.setContent(p);
4730
4733
  };
@@ -4757,24 +4760,24 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4757
4760
  u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
4758
4761
  }, [o, u]);
4759
4762
  const m = () => {
4760
- const x = findIndex(u, { _id: g });
4761
- if (x > -1) {
4762
- const y = (x + 1) % u.length, b = get(u, [y, "_id"]);
4763
+ const f = findIndex(u, { _id: g });
4764
+ if (f > -1) {
4765
+ const y = (f + 1) % u.length, b = get(u, [y, "_id"]);
4763
4766
  if (!b) return;
4764
4767
  n({ ...o, currentSlide: b }), c([b]);
4765
4768
  }
4766
4769
  }, h = () => {
4767
- const x = findIndex(u, { _id: g });
4768
- if (x > -1) {
4769
- const y = (x - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
4770
+ const f = findIndex(u, { _id: g });
4771
+ if (f > -1) {
4772
+ const y = (f - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
4770
4773
  if (!b) return;
4771
4774
  n({ ...o, currentSlide: b }), c([b]);
4772
4775
  }
4773
- }, f = () => {
4774
- const x = i(
4776
+ }, x = () => {
4777
+ const f = i(
4775
4778
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4776
4779
  p == null ? void 0 : p._id
4777
- ), y = x == null ? void 0 : x._id;
4780
+ ), y = f == null ? void 0 : f._id;
4778
4781
  y && (n({ ...o, currentSlide: y }), c([y]));
4779
4782
  };
4780
4783
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
@@ -4792,7 +4795,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4792
4795
  /* @__PURE__ */ jsxs(
4793
4796
  "button",
4794
4797
  {
4795
- onClick: f,
4798
+ onClick: x,
4796
4799
  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",
4797
4800
  children: [
4798
4801
  /* @__PURE__ */ jsx(PlusCircledIcon, { className: "h-3 w-3" }),
@@ -4853,8 +4856,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4853
4856
  value: o == null ? void 0 : o.autoplayInterval,
4854
4857
  className: "text-xs",
4855
4858
  pattern: "[0-9]*",
4856
- onChange: (x) => {
4857
- let y = x.target.value;
4859
+ onChange: (f) => {
4860
+ let y = f.target.value;
4858
4861
  y.length && (y = y.replace("-", "")), n({ ...o, autoplayInterval: y });
4859
4862
  }
4860
4863
  }
@@ -4962,17 +4965,17 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4962
4965
  formData: u,
4963
4966
  onChange: g
4964
4967
  }) => {
4965
- const { selectedLang: m, fallbackLang: h, languages: f } = useLanguages(), x = useMemo(
4966
- () => isEmpty(f) ? "" : isEmpty(m) ? h : m,
4967
- [f, m, h]
4968
- ), y = useMemo(() => get(LANGUAGES, x, x), [x]), b = usePageExternalData(), C = useSelectedBlock(), B = useRegisteredChaiBlocks(), j = useMemo(
4968
+ const { selectedLang: m, fallbackLang: h, languages: x } = useLanguages(), f = useMemo(
4969
+ () => isEmpty(x) ? "" : isEmpty(m) ? h : m,
4970
+ [x, m, h]
4971
+ ), y = useMemo(() => get(LANGUAGES, f, f), [f]), b = usePageExternalData(), C = useSelectedBlock(), B = useRegisteredChaiBlocks(), j = useMemo(
4969
4972
  () => get(B, [C == null ? void 0 : C._type, "i18nProps"], []),
4970
4973
  [B, C == null ? void 0 : C._type]
4971
- ), [_, A] = useState(null);
4974
+ ), [_, w] = useState(null);
4972
4975
  if (c)
4973
4976
  return null;
4974
4977
  if (p.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
4975
- const w = j == null ? void 0 : j.includes(o.replace("root.", ""));
4978
+ const A = j == null ? void 0 : j.includes(o.replace("root.", ""));
4976
4979
  if (p.type === "array") {
4977
4980
  const E = _ === o;
4978
4981
  return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
@@ -4980,7 +4983,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4980
4983
  "label",
4981
4984
  {
4982
4985
  htmlFor: o,
4983
- onClick: () => A(E ? null : o),
4986
+ onClick: () => w(E ? null : o),
4984
4987
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
4985
4988
  children: [
4986
4989
  E ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }),
@@ -5015,7 +5018,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5015
5018
  /* @__PURE__ */ jsxs("label", { htmlFor: o, className: p.type === "object" ? "pb-2" : "", children: [
5016
5019
  r,
5017
5020
  " ",
5018
- w && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5021
+ A && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5019
5022
  " ",
5020
5023
  y
5021
5024
  ] }),
@@ -5137,43 +5140,43 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5137
5140
  }), a;
5138
5141
  };
5139
5142
  function BlockSettings() {
5140
- const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), f = ({ formData: A }, k, w) => {
5141
- k && (c == null ? void 0 : c._id) === n._id && a([n._id], { [k]: get(A, k) }, w);
5142
- }, x = useCallback(
5143
- debounce(({ formData: A }, k, w) => {
5144
- f({ formData: A }, k, w), d(A);
5143
+ const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), x = ({ formData: w }, k, A) => {
5144
+ k && (c == null ? void 0 : c._id) === n._id && a([n._id], { [k]: get(w, k) }, A);
5145
+ }, f = useCallback(
5146
+ debounce(({ formData: w }, k, A) => {
5147
+ x({ formData: w }, k, A), d(w);
5145
5148
  }, 1500),
5146
5149
  [n == null ? void 0 : n._id, o]
5147
- ), y = ({ formData: A }, k) => {
5148
- k && (r([n._id], { [k]: get(A, k) }), x({ formData: A }, k, { [k]: get(c, k) }));
5149
- }, b = ({ formData: A }, k) => {
5150
- k && (r([g._id], { [k]: get(A, k) }), x({ formData: A }, k, { [k]: get(c, k) }));
5150
+ ), y = ({ formData: w }, k) => {
5151
+ k && (r([n._id], { [k]: get(w, k) }), f({ formData: w }, k, { [k]: get(c, k) }));
5152
+ }, b = ({ formData: w }, k) => {
5153
+ k && (r([g._id], { [k]: get(w, k) }), f({ formData: w }, k, { [k]: get(c, k) }));
5151
5154
  }, { schema: C, uiSchema: B } = useMemo(() => {
5152
- const A = n == null ? void 0 : n._type;
5153
- if (!A)
5155
+ const w = n == null ? void 0 : n._type;
5156
+ if (!w)
5154
5157
  return { schema: {}, uiSchema: {} };
5155
5158
  try {
5156
- const { schema: k, uiSchema: w } = getBlockFormSchemas(A);
5157
- if (A === "Repeater") {
5159
+ const { schema: k, uiSchema: A } = getBlockFormSchemas(w);
5160
+ if (w === "Repeater") {
5158
5161
  const E = get(n, "repeaterItems", "");
5159
- startsWith(E, `{{${COLLECTION_PREFIX}`) ? (set(w, "filter", { "ui:widget": "collectionSelect" }), set(w, "sort", { "ui:widget": "collectionSelect" })) : (set(w, "filter", { "ui:widget": "hidden" }), set(w, "sort", { "ui:widget": "hidden" }));
5162
+ startsWith(E, `{{${COLLECTION_PREFIX}`) ? (set(A, "filter", { "ui:widget": "collectionSelect" }), set(A, "sort", { "ui:widget": "collectionSelect" })) : (set(A, "filter", { "ui:widget": "hidden" }), set(A, "sort", { "ui:widget": "hidden" }));
5160
5163
  }
5161
- return { schema: k, uiSchema: w };
5164
+ return { schema: k, uiSchema: A };
5162
5165
  } catch {
5163
5166
  return { schema: {}, uiSchema: {} };
5164
5167
  }
5165
5168
  }, [n]), { wrapperSchema: j, wrapperUiSchema: _ } = useMemo(() => {
5166
5169
  if (!g || !(g != null && g._type))
5167
5170
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5168
- const A = g == null ? void 0 : g._type, { schema: k = {}, uiSchema: w = {} } = getBlockFormSchemas(A);
5169
- return { wrapperSchema: k, wrapperUiSchema: w };
5171
+ const w = g == null ? void 0 : g._type, { schema: k = {}, uiSchema: A = {} } = getBlockFormSchemas(w);
5172
+ return { wrapperSchema: k, wrapperUiSchema: A };
5170
5173
  }, [g]);
5171
5174
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5172
5175
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
5173
5176
  /* @__PURE__ */ jsxs(
5174
5177
  "div",
5175
5178
  {
5176
- onClick: () => u((A) => !A),
5179
+ onClick: () => u((w) => !w),
5177
5180
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5178
5181
  children: [
5179
5182
  p ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-4 w-4 text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 text-slate-400" }),
@@ -5212,27 +5215,27 @@ function BlockSettings() {
5212
5215
  ] });
5213
5216
  }
5214
5217
  const BlockStylingProps = () => {
5215
- var f;
5218
+ var x;
5216
5219
  const o = useSelectedBlock(), [n, r] = useSelectedStylingBlocks(), a = useRemoveClassesFromBlocks(), [l] = useSelectedBlockIds(), { t: i } = useTranslation();
5217
5220
  if (!o) return null;
5218
5221
  const c = Object.keys(o).filter(
5219
- (x) => typeof o[x] == "string" && o[x].startsWith("#styles:")
5220
- ), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (f = n[0]) == null ? void 0 : f.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, m = g ? g.split(" ").filter((x) => !isEmpty(x)) : [], h = (x) => find(n, (y) => y.prop === x);
5222
+ (f) => typeof o[f] == "string" && o[f].startsWith("#styles:")
5223
+ ), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (x = n[0]) == null ? void 0 : x.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, m = g ? g.split(" ").filter((f) => !isEmpty(f)) : [], h = (f) => find(n, (y) => y.prop === f);
5221
5224
  return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
5222
5225
  /* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
5223
5226
  i("Style element"),
5224
5227
  ":"
5225
5228
  ] }),
5226
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (x) => /* @__PURE__ */ jsxs(
5229
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (f) => /* @__PURE__ */ jsxs(
5227
5230
  Badge,
5228
5231
  {
5229
5232
  className: "flex cursor-pointer items-center gap-1 pr-1",
5230
- variant: h(x) ? "default" : "secondary",
5233
+ variant: h(f) ? "default" : "secondary",
5231
5234
  onClick: () => {
5232
- r([{ id: `${x}-${o._id}`, blockId: o._id, prop: x }]);
5235
+ r([{ id: `${f}-${o._id}`, blockId: o._id, prop: f }]);
5233
5236
  },
5234
5237
  children: [
5235
- startCase(x),
5238
+ startCase(f),
5236
5239
  /* @__PURE__ */ jsxs(DropdownMenu, { children: [
5237
5240
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5238
5241
  "button",
@@ -5249,7 +5252,7 @@ const BlockStylingProps = () => {
5249
5252
  {
5250
5253
  className: "text-xs",
5251
5254
  onClick: () => {
5252
- d(x);
5255
+ d(f);
5253
5256
  },
5254
5257
  children: i("Reset style")
5255
5258
  }
@@ -5268,7 +5271,7 @@ const BlockStylingProps = () => {
5268
5271
  ] })
5269
5272
  ]
5270
5273
  },
5271
- x
5274
+ f
5272
5275
  )) }),
5273
5276
  /* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
5274
5277
  ] }) });
@@ -5417,7 +5420,7 @@ const BlockStylingProps = () => {
5417
5420
  },
5418
5421
  a
5419
5422
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5420
- const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [y, b] = useState(""), [C, B] = useState(!1), [j, _] = useState(!1);
5423
+ const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [y, b] = useState(""), [C, B] = useState(!1), [j, _] = useState(!1);
5421
5424
  useEffect(() => {
5422
5425
  const { value: S, unit: v } = getClassValueAndUnit(i);
5423
5426
  if (v === "") {
@@ -5426,41 +5429,41 @@ const BlockStylingProps = () => {
5426
5429
  }
5427
5430
  h(v), l(v === "class" || isEmpty(S) ? "" : S);
5428
5431
  }, [i, p, u]);
5429
- const A = useThrottledCallback((S) => c(S), [c], THROTTLE_TIME), k = useThrottledCallback((S) => c(S, !1), [c], THROTTLE_TIME), w = useCallback(
5432
+ const w = useThrottledCallback((S) => c(S), [c], THROTTLE_TIME), k = useThrottledCallback((S) => c(S, !1), [c], THROTTLE_TIME), A = useCallback(
5430
5433
  (S = !1) => {
5431
5434
  const v = getUserInputValues(`${a}`, u);
5432
5435
  if (get(v, "error", !1)) {
5433
- x(!0);
5436
+ f(!0);
5434
5437
  return;
5435
5438
  }
5436
5439
  const I = get(v, "unit") !== "" ? get(v, "unit") : m;
5437
5440
  if (I === "auto" || I === "none") {
5438
- A(`${d}${I}`);
5441
+ w(`${d}${I}`);
5439
5442
  return;
5440
5443
  }
5441
5444
  if (get(v, "value") === "")
5442
5445
  return;
5443
5446
  const T = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${I === "-" ? "" : I}]`;
5444
- S ? k(T) : A(T);
5447
+ S ? k(T) : w(T);
5445
5448
  },
5446
- [A, k, a, m, d, u]
5449
+ [w, k, a, m, d, u]
5447
5450
  ), E = useCallback(
5448
5451
  (S) => {
5449
5452
  const v = getUserInputValues(`${a}`, u);
5450
5453
  if (get(v, "error", !1)) {
5451
- x(!0);
5454
+ f(!0);
5452
5455
  return;
5453
5456
  }
5454
5457
  if (S === "auto" || S === "none") {
5455
- A(`${d}${S}`);
5458
+ w(`${d}${S}`);
5456
5459
  return;
5457
5460
  }
5458
5461
  if (get(v, "value") === "")
5459
5462
  return;
5460
5463
  const I = get(v, "unit") !== "" ? get(v, "unit") : S, T = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${I === "-" ? "" : I}]`;
5461
- A(T);
5464
+ w(T);
5462
5465
  },
5463
- [A, a, d, u]
5466
+ [w, a, d, u]
5464
5467
  );
5465
5468
  return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5466
5469
  /* @__PURE__ */ jsx(
@@ -5482,7 +5485,7 @@ const BlockStylingProps = () => {
5482
5485
  {
5483
5486
  readOnly: m === "class",
5484
5487
  onKeyPress: (S) => {
5485
- S.key === "Enter" && w();
5488
+ S.key === "Enter" && A();
5486
5489
  },
5487
5490
  onKeyDown: (S) => {
5488
5491
  if (S.keyCode !== 38 && S.keyCode !== 40)
@@ -5497,9 +5500,9 @@ const BlockStylingProps = () => {
5497
5500
  onKeyUp: (S) => {
5498
5501
  j && (S.preventDefault(), _(!1));
5499
5502
  },
5500
- onBlur: () => w(),
5503
+ onBlur: () => A(),
5501
5504
  onChange: (S) => {
5502
- x(!1), l(S.target.value);
5505
+ f(!1), l(S.target.value);
5503
5506
  },
5504
5507
  onClick: (S) => {
5505
5508
  var v;
@@ -5508,7 +5511,7 @@ const BlockStylingProps = () => {
5508
5511
  value: C ? y : a,
5509
5512
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
5510
5513
  " ",
5511
- f ? "border-red-500 text-red-500" : "border-foreground/20"
5514
+ x ? "border-red-500 text-red-500" : "border-foreground/20"
5512
5515
  )
5513
5516
  }
5514
5517
  ),
@@ -5545,7 +5548,7 @@ const BlockStylingProps = () => {
5545
5548
  if (b(() => ""), B(!1), isEmpty(S))
5546
5549
  return;
5547
5550
  const v = `${S}`, L = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${m === "-" ? "" : m}]`;
5548
- A(L);
5551
+ w(L);
5549
5552
  },
5550
5553
  onDrag: (S) => {
5551
5554
  if (isEmpty(S))
@@ -5627,7 +5630,7 @@ const COLOR_PROP = {
5627
5630
  return c([]);
5628
5631
  c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
5629
5632
  }, [g]);
5630
- const f = useCallback(
5633
+ const x = useCallback(
5631
5634
  // eslint-disable-next-line no-shadow
5632
5635
  (y) => {
5633
5636
  p({ color: g, shade: y });
@@ -5637,11 +5640,11 @@ const COLOR_PROP = {
5637
5640
  useEffect(() => {
5638
5641
  p({ color: "", shade: "" });
5639
5642
  }, [r]);
5640
- const { match: x } = useTailwindClassList();
5643
+ const { match: f } = useTailwindClassList();
5641
5644
  return useEffect(() => {
5642
5645
  const b = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
5643
- x(o, b) && n(b, o);
5644
- }, [x, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
5646
+ f(o, b) && n(b, o);
5647
+ }, [f, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
5645
5648
  /* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
5646
5649
  DropDown,
5647
5650
  {
@@ -5681,7 +5684,7 @@ const COLOR_PROP = {
5681
5684
  ]
5682
5685
  }
5683
5686
  ) }),
5684
- /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: f, options: i }) })
5687
+ /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: x, options: i }) })
5685
5688
  ] });
5686
5689
  }, EDITOR_ICONS = {
5687
5690
  "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" }) }),
@@ -6015,17 +6018,17 @@ const COLOR_PROP = {
6015
6018
  "2xl": "1536px"
6016
6019
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6017
6020
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
6018
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(m, "fullCls", ""), [m]), b = useCallback(
6019
- (k, w = !0) => {
6021
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), y = useMemo(() => get(m, "fullCls", ""), [m]), b = useCallback(
6022
+ (k, A = !0) => {
6020
6023
  const E = { dark: p, mq: g, mod: u, cls: k, property: l, fullCls: "" };
6021
6024
  (p || u !== "") && (E.mq = "xs");
6022
6025
  const S = generateFullClsName(E);
6023
- h(x, [S], w);
6026
+ h(f, [S], A);
6024
6027
  },
6025
- [x, p, g, u, l, h]
6028
+ [f, p, g, u, l, h]
6026
6029
  ), C = useCallback(() => {
6027
- f(x, [y], !0);
6028
- }, [x, y, f]), B = useMemo(() => canChangeClass(m, g), [m, g]);
6030
+ x(f, [y], !0);
6031
+ }, [f, y, x]), B = useMemo(() => canChangeClass(m, g), [m, g]);
6029
6032
  useEffect(() => {
6030
6033
  i(B, m);
6031
6034
  }, [B, i, m]);
@@ -6041,9 +6044,9 @@ const COLOR_PROP = {
6041
6044
  }[k]);
6042
6045
  },
6043
6046
  [j]
6044
- ), A = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6045
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: m && A, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6046
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !A ? "text-foreground" : ""}`, children: n(a) }) }),
6047
+ ), w = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6048
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: m && w, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6049
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !w ? "text-foreground" : ""}`, children: n(a) }) }),
6047
6050
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6048
6051
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
6049
6052
  r === "arbitrary" ? /* @__PURE__ */ jsx(
@@ -6062,7 +6065,7 @@ const COLOR_PROP = {
6062
6065
  r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
6063
6066
  r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
6064
6067
  ] }),
6065
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: A ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => C(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6068
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: w ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => C(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6066
6069
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6067
6070
  "button",
6068
6071
  {
@@ -6111,23 +6114,23 @@ const COLOR_PROP = {
6111
6114
  children: [
6112
6115
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
6113
6116
  o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
6114
- /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: h, key: f }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6117
+ /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: h, key: x }, f) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6115
6118
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6116
6119
  "button",
6117
6120
  {
6118
6121
  type: "button",
6119
- onClick: () => u(f),
6120
- className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6122
+ onClick: () => u(x),
6123
+ className: `relative cursor-pointer rounded-full p-1 text-[8px] ${x === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6121
6124
  children: [
6122
6125
  React__default.createElement("div", {
6123
- className: m(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6126
+ className: m(x) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6124
6127
  }),
6125
- React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
6128
+ React__default.createElement(get(EDITOR_ICONS, x, BoxIcon), { className: "text-inherit w-3 h-3" })
6126
6129
  ]
6127
6130
  }
6128
6131
  ) }),
6129
6132
  /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(h)) })
6130
- ] }) }, `option-${x}`)) })
6133
+ ] }) }, `option-${f}`)) })
6131
6134
  ] }),
6132
6135
  /* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
6133
6136
  BlockStyle,
@@ -6282,9 +6285,9 @@ const COLOR_PROP = {
6282
6285
  canvas: n = !1,
6283
6286
  tooltip: r = !0
6284
6287
  }) => {
6285
- const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (b) => {
6288
+ const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), x = (b) => {
6286
6289
  u.includes(b) ? u.length > 2 && g(u.filter((C) => C !== b)) : g((C) => [...C, b]);
6287
- }, x = (b) => {
6290
+ }, f = (b) => {
6288
6291
  n || l(b), c(b);
6289
6292
  }, y = getBreakpointValue(n ? i : a).toLowerCase();
6290
6293
  return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (b) => /* @__PURE__ */ createElement(
@@ -6292,7 +6295,7 @@ const COLOR_PROP = {
6292
6295
  {
6293
6296
  canvas: n,
6294
6297
  ...b,
6295
- onClick: x,
6298
+ onClick: f,
6296
6299
  key: b.breakpoint,
6297
6300
  currentBreakpoint: y
6298
6301
  }
@@ -6306,7 +6309,7 @@ const COLOR_PROP = {
6306
6309
  openDelay: o,
6307
6310
  tooltip: r,
6308
6311
  ...b,
6309
- onClick: x,
6312
+ onClick: f,
6310
6313
  key: b.breakpoint,
6311
6314
  currentBreakpoint: y
6312
6315
  }
@@ -6321,7 +6324,7 @@ const COLOR_PROP = {
6321
6324
  DropdownMenuCheckboxItem,
6322
6325
  {
6323
6326
  disabled: b.breakpoint === "xs",
6324
- onCheckedChange: () => f(toUpper(b.breakpoint)),
6327
+ onCheckedChange: () => x(toUpper(b.breakpoint)),
6325
6328
  checked: includes(u, toUpper(b.breakpoint)),
6326
6329
  children: m(b.title)
6327
6330
  },
@@ -6406,8 +6409,8 @@ const AskAIStyles = ({ blockId: o }) => {
6406
6409
  (h = d.current) == null || h.focus();
6407
6410
  }, []);
6408
6411
  const m = (h) => {
6409
- const { usage: f } = h || {};
6410
- !l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
6412
+ const { usage: x } = h || {};
6413
+ !l && x && g(x), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
6411
6414
  };
6412
6415
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
6413
6416
  /* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("Ask AI") }),
@@ -6463,10 +6466,10 @@ const AskAIStyles = ({ blockId: o }) => {
6463
6466
  };
6464
6467
  function ManualClasses() {
6465
6468
  var L;
6466
- const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), y = (L = first(d)) == null ? void 0 : L.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), C = b.split(" ").filter((T) => !isEmpty(T)), B = () => {
6467
- const T = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6468
- u(m, T, !0), x("");
6469
- }, [j, _] = useState([]), A = ({ value: T }) => {
6469
+ const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [x, f] = useState(""), y = (L = first(d)) == null ? void 0 : L.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), C = b.split(" ").filter((T) => !isEmpty(T)), B = () => {
6470
+ const T = x.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6471
+ u(m, T, !0), f("");
6472
+ }, [j, _] = useState([]), w = ({ value: T }) => {
6470
6473
  const P = T.trim().toLowerCase(), R = P.match(/.+:/g);
6471
6474
  let N = [];
6472
6475
  if (R && R.length > 0) {
@@ -6480,7 +6483,7 @@ function ManualClasses() {
6480
6483
  return _(map(N, "item"));
6481
6484
  }, k = () => {
6482
6485
  _([]);
6483
- }, w = (T) => T.name, E = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), S = useMemo(
6486
+ }, A = (T) => T.name, E = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), S = useMemo(
6484
6487
  () => ({
6485
6488
  ref: o,
6486
6489
  autoComplete: "off",
@@ -6488,19 +6491,19 @@ function ManualClasses() {
6488
6491
  autoCapitalize: "off",
6489
6492
  spellCheck: !1,
6490
6493
  placeholder: c("Enter classes separated by space"),
6491
- value: f,
6494
+ value: x,
6492
6495
  onFocus: (T) => {
6493
6496
  setTimeout(() => {
6494
6497
  T.target && T.target.select();
6495
6498
  }, 0);
6496
6499
  },
6497
6500
  onKeyDown: (T) => {
6498
- T.key === "Enter" && f.trim() !== "" && B();
6501
+ T.key === "Enter" && x.trim() !== "" && B();
6499
6502
  },
6500
- onChange: (T, { newValue: P }) => x(P),
6503
+ onChange: (T, { newValue: P }) => f(P),
6501
6504
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
6502
6505
  }),
6503
- [f, c, o]
6506
+ [x, c, o]
6504
6507
  ), v = (T) => {
6505
6508
  debugger;
6506
6509
  const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
@@ -6534,9 +6537,9 @@ function ManualClasses() {
6534
6537
  Autosuggest,
6535
6538
  {
6536
6539
  suggestions: j,
6537
- onSuggestionsFetchRequested: A,
6540
+ onSuggestionsFetchRequested: w,
6538
6541
  onSuggestionsClearRequested: k,
6539
- getSuggestionValue: w,
6542
+ getSuggestionValue: A,
6540
6543
  renderSuggestion: E,
6541
6544
  inputProps: S,
6542
6545
  containerProps: {
@@ -6555,7 +6558,7 @@ function ManualClasses() {
6555
6558
  variant: "outline",
6556
6559
  className: "h-6 border-border",
6557
6560
  onClick: B,
6558
- disabled: f.trim() === "",
6561
+ disabled: x.trim() === "",
6559
6562
  size: "sm",
6560
6563
  children: /* @__PURE__ */ jsx(PlusIcon, {})
6561
6564
  }
@@ -6586,7 +6589,7 @@ function ManualClasses() {
6586
6589
  "button",
6587
6590
  {
6588
6591
  onDoubleClick: () => {
6589
- x(T), g(m, [T]), setTimeout(() => {
6592
+ f(T), g(m, [T]), setTimeout(() => {
6590
6593
  o.current && o.current.focus();
6591
6594
  }, 10);
6592
6595
  },
@@ -6742,9 +6745,9 @@ function BlockStyling() {
6742
6745
  const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
6743
6746
  let h = parseFloat(i.dragStartValue);
6744
6747
  h = isNaN(h) ? 0 : h;
6745
- let f = MAPPER[i.dragUnit];
6746
- (startsWith(m, "scale") || m === "opacity") && (f = 10);
6747
- let y = (i.dragStartY - u.pageY) / f + h;
6748
+ let x = MAPPER[i.dragUnit];
6749
+ (startsWith(m, "scale") || m === "opacity") && (x = 10);
6750
+ let y = (i.dragStartY - u.pageY) / x + h;
6748
6751
  g && y < 0 && (y = 0), m === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6749
6752
  },
6750
6753
  [i],
@@ -6793,7 +6796,7 @@ const CoreBlock = ({
6793
6796
  } else
6794
6797
  p(o, r || null, a);
6795
6798
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6796
- }, f = useFeature("dnd"), { t: x } = useTranslation();
6799
+ }, x = useFeature("dnd"), { t: f } = useTranslation();
6797
6800
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6798
6801
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6799
6802
  "button",
@@ -6806,15 +6809,15 @@ const CoreBlock = ({
6806
6809
  g([]), m();
6807
6810
  }, 200);
6808
6811
  },
6809
- draggable: f ? "true" : "false",
6812
+ draggable: x ? "true" : "false",
6810
6813
  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",
6811
6814
  children: [
6812
6815
  createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
6813
- /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
6816
+ /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(f(d || i)) })
6814
6817
  ]
6815
6818
  }
6816
6819
  ) }),
6817
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
6820
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: f(d || i) }) })
6818
6821
  ] }) });
6819
6822
  }, DefaultChaiBlocks = ({
6820
6823
  parentId: o,
@@ -6925,7 +6928,7 @@ const registerChaiLibrary = (o, n) => {
6925
6928
  parentId: r = void 0,
6926
6929
  position: a = -1
6927
6930
  }) => {
6928
- const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), y = (B) => {
6931
+ const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), y = (B) => {
6929
6932
  const j = has(B, "styles_attrs.data-page-section");
6930
6933
  return B._type === "Box" && j;
6931
6934
  }, b = useCallback(
@@ -6946,20 +6949,20 @@ const registerChaiLibrary = (o, n) => {
6946
6949
  {
6947
6950
  onClick: l ? () => {
6948
6951
  } : b,
6949
- draggable: f ? "true" : "false",
6952
+ draggable: x ? "true" : "false",
6950
6953
  onDragStart: async (B) => {
6951
6954
  const j = await c({ library: n, block: o });
6952
6955
  let _ = r;
6953
6956
  if (y(first(j)) && (_ = null), !isEmpty(j)) {
6954
- const A = { blocks: j, uiLibrary: !0, parent: _ };
6955
- if (B.dataTransfer.setData("text/plain", JSON.stringify(A)), o.preview) {
6957
+ const w = { blocks: j, uiLibrary: !0, parent: _ };
6958
+ if (B.dataTransfer.setData("text/plain", JSON.stringify(w)), o.preview) {
6956
6959
  const k = new Image();
6957
6960
  k.src = o.preview, k.onload = () => {
6958
6961
  B.dataTransfer.setDragImage(k, 0, 0);
6959
6962
  };
6960
6963
  } else
6961
6964
  B.dataTransfer.setDragImage(new Image(), 0, 0);
6962
- x(A), setTimeout(() => {
6965
+ f(w), setTimeout(() => {
6963
6966
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6964
6967
  }, 200);
6965
6968
  }
@@ -6985,22 +6988,22 @@ const registerChaiLibrary = (o, n) => {
6985
6988
  ] }) })
6986
6989
  ] });
6987
6990
  }, UILibrarySection = ({ parentId: o, position: n }) => {
6988
- const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((v) => v.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [m, h] = useState([]), f = useRef(null);
6991
+ const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((v) => v.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [m, h] = useState([]), x = useRef(null);
6989
6992
  useEffect(() => {
6990
- c && c.length > 0 && (f.current = new Fuse(c, {
6993
+ c && c.length > 0 && (x.current = new Fuse(c, {
6991
6994
  keys: ["name", "label", "description", "group"],
6992
6995
  threshold: 0.4,
6993
6996
  ignoreLocation: !0
6994
6997
  }));
6995
6998
  }, [c]), useEffect(() => {
6996
- if (!u.trim() || !f.current) {
6999
+ if (!u.trim() || !x.current) {
6997
7000
  h([]);
6998
7001
  return;
6999
7002
  }
7000
- const v = f.current.search(u).map((I) => I.item);
7003
+ const v = x.current.search(u).map((I) => I.item);
7001
7004
  h(v);
7002
7005
  }, [u]);
7003
- const x = u.trim() && !isEmpty(m) ? m : c, y = groupBy(x, "group"), [b, C] = useState(null);
7006
+ const f = u.trim() && !isEmpty(m) ? m : c, y = groupBy(f, "group"), [b, C] = useState(null);
7004
7007
  useEffect(() => {
7005
7008
  if (isEmpty(keys(y))) {
7006
7009
  C(null);
@@ -7011,13 +7014,13 @@ const registerChaiLibrary = (o, n) => {
7011
7014
  return;
7012
7015
  }
7013
7016
  }, [y, b]);
7014
- const B = get(y, b, []), j = useRef(null), { t: _ } = useTranslation(), A = (v) => {
7017
+ const B = get(y, b, []), j = useRef(null), { t: _ } = useTranslation(), w = (v) => {
7015
7018
  j.current && (clearTimeout(j.current), j.current = null), j.current = setTimeout(() => {
7016
7019
  j.current && C(v);
7017
7020
  }, 400);
7018
7021
  }, k = () => {
7019
7022
  i != null && i.id && p(i.id);
7020
- }, w = () => {
7023
+ }, A = () => {
7021
7024
  g("");
7022
7025
  };
7023
7026
  if (d)
@@ -7041,7 +7044,7 @@ const registerChaiLibrary = (o, n) => {
7041
7044
  u && /* @__PURE__ */ jsx(
7042
7045
  "button",
7043
7046
  {
7044
- onClick: w,
7047
+ onClick: A,
7045
7048
  className: "absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",
7046
7049
  children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" })
7047
7050
  }
@@ -7062,7 +7065,7 @@ const registerChaiLibrary = (o, n) => {
7062
7065
  ] }) }) : map(y, (v, I) => /* @__PURE__ */ jsxs(
7063
7066
  "div",
7064
7067
  {
7065
- onMouseEnter: () => A(I),
7068
+ onMouseEnter: () => w(I),
7066
7069
  onMouseLeave: () => clearTimeout(j.current),
7067
7070
  role: "button",
7068
7071
  onClick: () => C(I),
@@ -7140,25 +7143,25 @@ const registerChaiLibrary = (o, n) => {
7140
7143
  error: c
7141
7144
  }), g(!0);
7142
7145
  else if (!l && Object.keys(a || {}).length > 0) {
7143
- const h = Object.entries(a).map(([x, y]) => {
7146
+ const h = Object.entries(a).map(([f, y]) => {
7144
7147
  const b = y, C = b.type || "partial", B = formatReadableName(C);
7145
7148
  return {
7146
7149
  type: "PartialBlock",
7147
7150
  // Set the type to PartialBlock
7148
- label: formatReadableName(b.name || x),
7151
+ label: formatReadableName(b.name || f),
7149
7152
  description: b.description || "",
7150
7153
  icon: FrameIcon,
7151
7154
  group: B,
7152
7155
  // Use formatted type as group
7153
7156
  category: "partial",
7154
- partialBlockId: x,
7157
+ partialBlockId: f,
7155
7158
  // Store the original ID as partialBlockId
7156
7159
  _name: b.name
7157
7160
  };
7158
- }), f = uniq(map(h, "group"));
7161
+ }), x = uniq(map(h, "group"));
7159
7162
  p({
7160
7163
  blocks: h,
7161
- groups: f,
7164
+ groups: x,
7162
7165
  isLoading: !1,
7163
7166
  error: null
7164
7167
  }), g(!0);
@@ -7204,7 +7207,7 @@ const registerChaiLibrary = (o, n) => {
7204
7207
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...n });
7205
7208
  }, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
7206
7209
  var S;
7207
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (S = find(c, (v) => v._id === r)) == null ? void 0 : S._type, [h, f] = useState("all"), [x, y] = useState(null), b = useRef(null);
7210
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (S = find(c, (v) => v._id === r)) == null ? void 0 : S._type, [h, x] = useState("all"), [f, y] = useState(null), b = useRef(null);
7208
7211
  useEffect(() => {
7209
7212
  const v = setTimeout(() => {
7210
7213
  var I;
@@ -7212,9 +7215,9 @@ const registerChaiLibrary = (o, n) => {
7212
7215
  }, 0);
7213
7216
  return () => clearTimeout(v);
7214
7217
  }, [g]), useEffect(() => {
7215
- d && (f("all"), y(null));
7218
+ d && (x("all"), y(null));
7216
7219
  }, [d]), useEffect(() => (b.current = debounce((v) => {
7217
- f(v);
7220
+ x(v);
7218
7221
  }, 500), () => {
7219
7222
  b.current && b.current.cancel();
7220
7223
  }), []);
@@ -7223,7 +7226,7 @@ const registerChaiLibrary = (o, n) => {
7223
7226
  }, []), B = useCallback(() => {
7224
7227
  y(null), b.current && b.current.cancel();
7225
7228
  }, []), j = useCallback((v) => {
7226
- b.current && b.current.cancel(), f(v), y(null);
7229
+ b.current && b.current.cancel(), x(v), y(null);
7227
7230
  }, []), _ = useMemo(
7228
7231
  () => d ? values(n).filter(
7229
7232
  (v) => {
@@ -7232,15 +7235,15 @@ const registerChaiLibrary = (o, n) => {
7232
7235
  }
7233
7236
  ) : n,
7234
7237
  [n, d]
7235
- ), A = useMemo(
7238
+ ), w = useMemo(
7236
7239
  () => d ? o.filter(
7237
7240
  (v) => reject(filter(values(_), { group: v }), { hidden: !0 }).length > 0
7238
7241
  ) : o.filter((v) => reject(filter(values(n), { group: v }), { hidden: !0 }).length > 0),
7239
7242
  [n, _, o, d]
7240
7243
  ), k = useMemo(
7241
- () => sortBy(A, (v) => CORE_GROUPS.indexOf(v) === -1 ? 99 : CORE_GROUPS.indexOf(v)),
7242
- [A]
7243
- ), w = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), E = useMemo(() => h === "all" ? k : [h], [k, h]);
7244
+ () => sortBy(w, (v) => CORE_GROUPS.indexOf(v) === -1 ? 99 : CORE_GROUPS.indexOf(v)),
7245
+ [w]
7246
+ ), A = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), E = useMemo(() => h === "all" ? k : [h], [k, h]);
7244
7247
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7245
7248
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7246
7249
  Input$1,
@@ -7261,7 +7264,7 @@ const registerChaiLibrary = (o, n) => {
7261
7264
  onClick: () => j("all"),
7262
7265
  onMouseEnter: () => C("all"),
7263
7266
  onMouseLeave: B,
7264
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || x === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7267
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || f === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7265
7268
  children: i("All")
7266
7269
  },
7267
7270
  "sidebar-all"
@@ -7272,13 +7275,13 @@ const registerChaiLibrary = (o, n) => {
7272
7275
  onClick: () => j(v),
7273
7276
  onMouseEnter: () => C(v),
7274
7277
  onMouseLeave: B,
7275
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === v || x === v ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7278
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === v || f === v ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7276
7279
  children: capitalize(i(v.toLowerCase()))
7277
7280
  },
7278
7281
  `sidebar-${v}`
7279
7282
  ))
7280
7283
  ] }) }) }),
7281
- /* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: A.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
7284
+ /* @__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: [
7282
7285
  i("No blocks found matching"),
7283
7286
  ' "',
7284
7287
  d,
@@ -7286,7 +7289,7 @@ const registerChaiLibrary = (o, n) => {
7286
7289
  ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: E.map((v) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7287
7290
  /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(v.toLowerCase())) }),
7288
7291
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7289
- h === "all" ? filter(values(w), { group: v }) : values(w),
7292
+ h === "all" ? filter(values(A), { group: v }) : values(A),
7290
7293
  { hidden: !0 }
7291
7294
  ).map((I) => /* @__PURE__ */ jsx(
7292
7295
  CoreBlock,
@@ -7313,7 +7316,7 @@ const registerChaiLibrary = (o, n) => {
7313
7316
  }, [i, g, c]);
7314
7317
  const h = useCallback(() => {
7315
7318
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7316
- }, []), f = useChaiAddBlockTabs(), x = p && m(PERMISSIONS.IMPORT_HTML), b = useChaiLibraries().length > 0;
7319
+ }, []), x = useChaiAddBlockTabs(), f = p && m(PERMISSIONS.IMPORT_HTML), b = useChaiLibraries().length > 0;
7317
7320
  return useEffect(() => {
7318
7321
  i === "library" && !b && c("core");
7319
7322
  }, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$2("flex h-full w-full flex-col overflow-hidden", o), children: [
@@ -7334,14 +7337,14 @@ const registerChaiLibrary = (o, n) => {
7334
7337
  b && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
7335
7338
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
7336
7339
  g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7337
- x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7338
- map(f, (C) => /* @__PURE__ */ jsx(TabsTrigger, { value: C.id, children: React__default.createElement(C.tab) }, `tab-add-block-${C.id}`))
7340
+ f ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7341
+ map(x, (C) => /* @__PURE__ */ jsx(TabsTrigger, { value: C.id, children: React__default.createElement(C.tab) }, `tab-add-block-${C.id}`))
7339
7342
  ] }),
7340
7343
  /* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7341
7344
  b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
7342
7345
  g && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7343
- x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
7344
- map(f, (C) => /* @__PURE__ */ jsx(TabsContent, { value: C.id, children: React__default.createElement(C.tabContent, { close: h, parentId: r, position: a }) }, `panel-add-block-${C.id}`))
7346
+ f ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
7347
+ map(x, (C) => /* @__PURE__ */ jsx(TabsContent, { value: C.id, children: React__default.createElement(C.tabContent, { close: h, parentId: r, position: a }) }, `panel-add-block-${C.id}`))
7345
7348
  ]
7346
7349
  }
7347
7350
  )
@@ -7651,26 +7654,26 @@ const Input = ({ node: o }) => {
7651
7654
  var R;
7652
7655
  const { t: a } = useTranslation(), l = useUpdateBlocksProps(), [i] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
7653
7656
  let d = null;
7654
- const p = o.children.length > 0, { highlightBlock: u, clearHighlight: g } = useBlockHighlight(), { id: m, data: h, isSelected: f, willReceiveDrop: x, isDragging: y, isEditing: b, handleClick: C } = o, B = get(h, "_show", !0), j = (N) => {
7657
+ const p = o.children.length > 0, { highlightBlock: u, clearHighlight: g } = useBlockHighlight(), { id: m, data: h, isSelected: x, willReceiveDrop: f, isDragging: y, isEditing: b, handleClick: C } = o, B = get(h, "_show", !0), j = (N) => {
7655
7658
  N.stopPropagation(), B && o.toggle();
7656
7659
  }, _ = (N) => {
7657
7660
  N.isInternal && (d = N.isOpen, N.isOpen && N.close());
7658
- }, A = (N) => {
7661
+ }, w = (N) => {
7659
7662
  N.isInternal && d !== null && (d ? N.open() : N.close(), d = null);
7660
- }, [k, w] = useAtom$1(currentAddSelection), E = () => {
7663
+ }, [k, A] = useAtom$1(currentAddSelection), E = () => {
7661
7664
  var N;
7662
- S(), o.parent.isSelected || w((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7665
+ S(), o.parent.isSelected || A((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7663
7666
  }, S = () => {
7664
- w(null);
7667
+ A(null);
7665
7668
  }, v = (N) => {
7666
7669
  S(), N.stopPropagation(), !o.isOpen && B && o.toggle(), C(N);
7667
7670
  };
7668
7671
  useEffect(() => {
7669
7672
  const N = setTimeout(() => {
7670
- x && !o.isOpen && !y && B && o.toggle();
7673
+ f && !o.isOpen && !y && B && o.toggle();
7671
7674
  }, 500);
7672
7675
  return () => clearTimeout(N);
7673
- }, [x, o, y]);
7676
+ }, [f, o, y]);
7674
7677
  const I = (N, D) => {
7675
7678
  const F = i.contentDocument || i.contentWindow.document, O = F.querySelector(`[data-block-id=${N}]`);
7676
7679
  O && O.setAttribute("data-drop", D);
@@ -7710,7 +7713,7 @@ const Input = ({ node: o }) => {
7710
7713
  "data-node-id": m,
7711
7714
  ref: r,
7712
7715
  onDragStart: () => _(o),
7713
- onDragEnd: () => A(o),
7716
+ onDragEnd: () => w(o),
7714
7717
  onDragOver: (N) => {
7715
7718
  N.preventDefault(), I(m, "yes");
7716
7719
  },
@@ -7738,12 +7741,12 @@ const Input = ({ node: o }) => {
7738
7741
  {
7739
7742
  className: cn(
7740
7743
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 py-0 outline-none",
7741
- f ? "bg-primary/20" : "hover:bg-primary/10",
7742
- x && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7744
+ x ? "bg-primary/20" : "hover:bg-primary/10",
7745
+ f && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7743
7746
  (o == null ? void 0 : o.id) === k ? "bg-primary/10" : "",
7744
7747
  y && "opacity-20",
7745
7748
  B ? "" : "line-through opacity-50",
7746
- T && f && "bg-primary/20 text-primary"
7749
+ T && x && "bg-primary/20 text-primary"
7747
7750
  ),
7748
7751
  children: [
7749
7752
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -7760,9 +7763,9 @@ const Input = ({ node: o }) => {
7760
7763
  className: cn(
7761
7764
  "leading-1 flex items-center",
7762
7765
  T && "text-orange-600/90",
7763
- T && f && "text-orange-800",
7766
+ T && x && "text-orange-800",
7764
7767
  P && "text-purple-600/90",
7765
- P && f && "text-purple-800"
7768
+ P && x && "text-purple-800"
7766
7769
  ),
7767
7770
  children: [
7768
7771
  /* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
@@ -8225,16 +8228,16 @@ const Input = ({ node: o }) => {
8225
8228
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
8226
8229
  const [n, r] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions();
8227
8230
  if (d) {
8228
- const A = d.map((k) => Object.keys(k)[0]);
8231
+ const w = d.map((k) => Object.keys(k)[0]);
8229
8232
  DEFAULT_THEME_PRESET.forEach((k) => {
8230
- const w = Object.keys(k)[0];
8231
- A.includes(w) || d.push(k);
8233
+ const A = Object.keys(k)[0];
8234
+ w.includes(A) || d.push(k);
8232
8235
  });
8233
8236
  }
8234
- const [g, m] = useTheme(), h = useThemeOptions(), { t: f } = useTranslation(), x = React.useCallback(
8235
- (A) => {
8237
+ const [g, m] = useTheme(), h = useThemeOptions(), { t: x } = useTranslation(), f = React.useCallback(
8238
+ (w) => {
8236
8239
  const k = { ...g };
8237
- setPreviousTheme(k), m(A), toast.success("Theme updated", {
8240
+ setPreviousTheme(k), m(w), toast.success("Theme updated", {
8238
8241
  action: {
8239
8242
  label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
8240
8243
  /* @__PURE__ */ jsx(ResetIcon, { className: "h-4 w-4" }),
@@ -8250,56 +8253,56 @@ const Input = ({ node: o }) => {
8250
8253
  },
8251
8254
  [g, m]
8252
8255
  ), y = () => {
8253
- const A = d.find((k) => Object.keys(k)[0] === a);
8254
- if (A) {
8255
- const k = Object.values(A)[0];
8256
- k && typeof k == "object" && "fontFamily" in k && "borderRadius" in k && "colors" in k ? (x(k), l("")) : console.error("Invalid preset structure:", k);
8256
+ const w = d.find((k) => Object.keys(k)[0] === a);
8257
+ if (w) {
8258
+ const k = Object.values(w)[0];
8259
+ k && typeof k == "object" && "fontFamily" in k && "borderRadius" in k && "colors" in k ? (f(k), l("")) : console.error("Invalid preset structure:", k);
8257
8260
  } else
8258
8261
  console.error("Preset not found:", a);
8259
- }, b = (A) => {
8260
- x(A), l("");
8262
+ }, b = (w) => {
8263
+ f(w), l("");
8261
8264
  }, C = useDebouncedCallback(
8262
- (A, k) => {
8265
+ (w, k) => {
8263
8266
  m(() => ({
8264
8267
  ...g,
8265
8268
  fontFamily: {
8266
8269
  ...g.fontFamily,
8267
- [A.replace(/font-/g, "")]: k
8270
+ [w.replace(/font-/g, "")]: k
8268
8271
  }
8269
8272
  }));
8270
8273
  },
8271
8274
  [g],
8272
8275
  200
8273
8276
  ), B = React.useCallback(
8274
- (A) => {
8277
+ (w) => {
8275
8278
  m(() => ({
8276
8279
  ...g,
8277
- borderRadius: `${A}px`
8280
+ borderRadius: `${w}px`
8278
8281
  }));
8279
8282
  },
8280
8283
  [g]
8281
8284
  ), j = useDebouncedCallback(
8282
- (A, k) => {
8285
+ (w, k) => {
8283
8286
  m(() => {
8284
- const w = get(g, `colors.${A}`);
8285
- return n ? set(w, 1, k) : set(w, 0, k), {
8287
+ const A = get(g, `colors.${w}`);
8288
+ return n ? set(A, 1, k) : set(A, 0, k), {
8286
8289
  ...g,
8287
8290
  colors: {
8288
8291
  ...g.colors,
8289
- [A]: w
8292
+ [w]: A
8290
8293
  }
8291
8294
  };
8292
8295
  });
8293
8296
  },
8294
8297
  [g],
8295
8298
  200
8296
- ), _ = (A) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(A.items).map(([k]) => {
8297
- const w = get(g, `colors.${k}.${n ? 1 : 0}`);
8298
- return w ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8299
+ ), _ = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([k]) => {
8300
+ const A = get(g, `colors.${k}.${n ? 1 : 0}`);
8301
+ return A ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8299
8302
  /* @__PURE__ */ jsx(
8300
8303
  ColorPickerInput,
8301
8304
  {
8302
- value: w,
8305
+ value: A,
8303
8306
  onChange: (E) => j(k, E)
8304
8307
  }
8305
8308
  ),
@@ -8310,21 +8313,21 @@ const Input = ({ node: o }) => {
8310
8313
  /* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
8311
8314
  d.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mx-0 my-2 flex flex-col gap-1 py-2", children: [
8312
8315
  /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
8313
- /* @__PURE__ */ jsx(Label, { className: "text-sm", children: f("Presets") }),
8316
+ /* @__PURE__ */ jsx(Label, { className: "text-sm", children: x("Presets") }),
8314
8317
  /* @__PURE__ */ jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ jsxs(Button, { className: "px-1", variant: "link", size: "sm", onClick: () => c(!0), children: [
8315
8318
  /* @__PURE__ */ jsx(UploadIcon, { className: "h-4 w-4" }),
8316
- f("Import theme")
8319
+ x("Import theme")
8317
8320
  ] }) })
8318
8321
  ] }),
8319
8322
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
8320
8323
  /* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
8321
8324
  /* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
8322
- /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((A) => {
8323
- const k = Object.keys(A)[0], w = k.replaceAll("_", " ");
8324
- return /* @__PURE__ */ jsx(SelectItem, { value: k, children: capitalize(w) }, k);
8325
+ /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((w) => {
8326
+ const k = Object.keys(w)[0], A = k.replaceAll("_", " ");
8327
+ return /* @__PURE__ */ jsx(SelectItem, { value: k, children: capitalize(A) }, k);
8325
8328
  }) })
8326
8329
  ] }) }),
8327
- /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: y, children: f("Apply") }) })
8330
+ /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: y, children: x("Apply") }) })
8328
8331
  ] })
8329
8332
  ] }),
8330
8333
  /* @__PURE__ */ jsx(Separator, {}),
@@ -8333,14 +8336,14 @@ const Input = ({ node: o }) => {
8333
8336
  /* @__PURE__ */ jsx(TextIcon, { className: "h-3 w-3 text-gray-600" }),
8334
8337
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Typography" })
8335
8338
  ] }),
8336
- (h == null ? void 0 : h.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(h.fontFamily).map(([A, k]) => /* @__PURE__ */ jsx(
8339
+ (h == null ? void 0 : h.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(h.fontFamily).map(([w, k]) => /* @__PURE__ */ jsx(
8337
8340
  FontSelector,
8338
8341
  {
8339
- label: A,
8340
- value: g.fontFamily[A.replace(/font-/g, "")] || k[Object.keys(k)[0]],
8341
- onChange: (w) => C(A, w)
8342
+ label: w,
8343
+ value: g.fontFamily[w.replace(/font-/g, "")] || k[Object.keys(k)[0]],
8344
+ onChange: (A) => C(w, A)
8342
8345
  },
8343
- A
8346
+ w
8344
8347
  )) }),
8345
8348
  /* @__PURE__ */ jsx(Separator, {}),
8346
8349
  (h == null ? void 0 : h.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
@@ -8366,7 +8369,7 @@ const Input = ({ node: o }) => {
8366
8369
  Switch,
8367
8370
  {
8368
8371
  checked: n,
8369
- onCheckedChange: (A) => r(A),
8372
+ onCheckedChange: (w) => r(w),
8370
8373
  "aria-label": "Toggle dark mode",
8371
8374
  className: "mx-1"
8372
8375
  }
@@ -8374,7 +8377,7 @@ const Input = ({ node: o }) => {
8374
8377
  /* @__PURE__ */ jsx(MoonIcon, { className: "h-4 w-4" })
8375
8378
  ] }) })
8376
8379
  ] }),
8377
- /* @__PURE__ */ jsx("div", { className: "space-y-2", children: h.colors.map((A) => _(A)) })
8380
+ /* @__PURE__ */ jsx("div", { className: "space-y-2", children: h.colors.map((w) => _(w)) })
8378
8381
  ] }),
8379
8382
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: i && /* @__PURE__ */ jsx(
8380
8383
  LazyCssImportModal,
@@ -8795,106 +8798,103 @@ const CHAI_FEATURE_FLAGS = {}, registerChaiFeatureFlag = (o, n) => {
8795
8798
  registerChaiFeatureFlag("enable-ai-chat-left", {
8796
8799
  description: "Enable AI chat on the left side"
8797
8800
  });
8798
- }, QUICK_PROMPTS = [
8799
- {
8800
- name: "Improve writing",
8801
- icon: Pencil2Icon,
8802
- prompt: "Improving writing in all text elements. Replacing placeholder content with meaningful relevant content."
8803
- },
8804
- {
8805
- name: "Replace placeholder content",
8806
- icon: LoopIcon,
8807
- prompt: "Discard current placeholder content and replace with meaningful relevant content."
8808
- },
8809
- //TODO: Add tone options
8810
- // {
8811
- // name: "Change tone",
8812
- // icon: MegaphoneIcon,
8813
- // subMenus: ["joyful", "serious", "angry", "sad", "excited", "relaxed", "confident", "assertive", "polite"],
8814
- // prompt: "Change tone in all text elements. Rewrite all text elements in a more _TONE_ tone.",
8815
- // },
8816
- {
8817
- name: "Fix grammar",
8818
- icon: CheckIcon,
8819
- prompt: "Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors."
8820
- },
8821
- {
8822
- name: "Make longer",
8823
- icon: ArrowUpIcon,
8824
- prompt: "Make all text elements longer."
8825
- },
8826
- {
8827
- name: "Make shorter",
8828
- icon: ArrowDownIcon,
8829
- prompt: "Make all text elements shorter."
8830
- },
8831
- {
8832
- name: "Add emojis",
8833
- icon: FaceIcon,
8834
- prompt: "Add emojis to text elements if relevant."
8835
- },
8836
- {
8837
- name: "Randomize",
8838
- icon: ShuffleIcon,
8839
- prompt: "Randomize all text elements."
8840
- }
8841
- ];
8801
+ };
8842
8802
  function QuickPrompts({ onClick: o }) {
8843
- const { loading: n } = useAskAi(), { t: r } = useTranslation(), { selectedLang: a, fallbackLang: l } = useLanguages(), i = [...QUICK_PROMPTS];
8844
- return a && a !== l && i.splice(0, 0, {
8845
- name: `Translate to ${get(LANGUAGES, a, a)}`,
8803
+ const { loading: n } = useAskAi(), { t: r } = useTranslation(), { selectedLang: a, fallbackLang: l } = useLanguages(), c = [...[
8804
+ {
8805
+ name: r("Improve writing"),
8806
+ icon: Pencil2Icon,
8807
+ prompt: r(
8808
+ "Improving writing in all text elements. Replacing placeholder content with meaningful relevant content."
8809
+ )
8810
+ },
8811
+ {
8812
+ name: r("Replace placeholder content"),
8813
+ icon: LoopIcon,
8814
+ prompt: r("Discard current placeholder content and replace with meaningful relevant content.")
8815
+ },
8816
+ {
8817
+ name: r("Fix grammar"),
8818
+ icon: CheckIcon,
8819
+ prompt: r("Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors.")
8820
+ },
8821
+ {
8822
+ name: r("Make longer"),
8823
+ icon: ArrowUpIcon,
8824
+ prompt: r("Make all text elements longer.")
8825
+ },
8826
+ {
8827
+ name: r("Make shorter"),
8828
+ icon: ArrowDownIcon,
8829
+ prompt: r("Make all text elements shorter.")
8830
+ },
8831
+ {
8832
+ name: r("Add emojis"),
8833
+ icon: FaceIcon,
8834
+ prompt: r("Add emojis to text elements if relevant.")
8835
+ },
8836
+ {
8837
+ name: r("Randomize"),
8838
+ icon: ShuffleIcon,
8839
+ prompt: r("Randomize all text elements.")
8840
+ }
8841
+ ]];
8842
+ return a && a !== l && c.splice(0, 0, {
8843
+ name: r("Translate to %s", get(LANGUAGES, a, a)),
8846
8844
  icon: ChatBubbleIcon,
8847
- prompt: `Translate the content to ${get(LANGUAGES, a, a)}. Maintain same tone, style and length.`
8848
- }), /* @__PURE__ */ jsx("div", { className: n ? "pointer-events-none opacity-50" : "", children: /* @__PURE__ */ jsx("ul", { className: "space-y-2", children: i.map(
8849
- ({ name: c, icon: d, subMenus: p, prompt: u }) => p ? /* @__PURE__ */ jsxs(Popover, { children: [
8845
+ prompt: r(
8846
+ "Translate the content to %s. Maintain same tone, style and length.",
8847
+ get(LANGUAGES, a, a)
8848
+ )
8849
+ }), /* @__PURE__ */ jsx("div", { className: n ? "pointer-events-none opacity-50" : "", children: /* @__PURE__ */ jsx("ul", { className: "space-y-2", children: c.map(
8850
+ ({ name: d, icon: p, subMenus: u, prompt: g }) => u ? /* @__PURE__ */ jsxs(Popover, { children: [
8850
8851
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
8851
8852
  "li",
8852
8853
  {
8853
8854
  className: "flex cursor-pointer items-center space-x-2 rounded p-1 pl-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",
8854
8855
  children: [
8855
- /* @__PURE__ */ jsx(d, { className: "h-4 w-4" }),
8856
- /* @__PURE__ */ jsx("span", { children: c })
8856
+ /* @__PURE__ */ jsx(p, { className: "h-4 w-4" }),
8857
+ /* @__PURE__ */ jsx("span", { children: d })
8857
8858
  ]
8858
8859
  },
8859
- c
8860
+ d
8860
8861
  ) }),
8861
- /* @__PURE__ */ jsx(PopoverContent, { side: "right", children: /* @__PURE__ */ jsx("ul", { children: /* @__PURE__ */ jsx("li", { children: "Happy" }) }) })
8862
+ /* @__PURE__ */ jsx(PopoverContent, { side: "right", children: /* @__PURE__ */ jsx("ul", { children: /* @__PURE__ */ jsx("li", { children: r("Happy") }) }) })
8862
8863
  ] }) : /* @__PURE__ */ jsxs(
8863
8864
  "li",
8864
8865
  {
8865
- onClick: () => o(u),
8866
+ onClick: () => o(g),
8866
8867
  className: "flex cursor-pointer items-center space-x-2 rounded p-1 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",
8867
8868
  children: [
8868
- /* @__PURE__ */ jsx(d, { className: "h-4 w-4" }),
8869
- /* @__PURE__ */ jsx("span", { children: r(c) })
8869
+ /* @__PURE__ */ jsx(p, { className: "h-4 w-4" }),
8870
+ /* @__PURE__ */ jsx("span", { children: r(d) })
8870
8871
  ]
8871
8872
  },
8872
- c
8873
+ d
8873
8874
  )
8874
8875
  ) }) });
8875
8876
  }
8876
8877
  const AIUserPrompt = ({ blockId: o }) => {
8877
- const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(), u = useRef(null), g = useRef(null);
8878
+ const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null);
8878
8879
  useEffect(() => {
8879
- var h;
8880
- (h = u.current) == null || h.focus();
8880
+ var g;
8881
+ (g = d.current) == null || g.focus();
8881
8882
  }, []);
8882
- const m = (h) => {
8883
- const { usage: f } = h || {};
8884
- !l && f && p(f), g.current = setTimeout(() => p(void 0), 1e4), l || c("");
8883
+ const u = () => {
8884
+ l || c("");
8885
8885
  };
8886
8886
  return /* @__PURE__ */ jsx("div", { className: "", children: o ? /* @__PURE__ */ jsxs("div", { className: "mt-2", children: [
8887
8887
  /* @__PURE__ */ jsx(
8888
8888
  Textarea,
8889
8889
  {
8890
- ref: u,
8890
+ ref: d,
8891
8891
  value: i,
8892
- onChange: (h) => c(h.target.value),
8892
+ onChange: (g) => c(g.target.value),
8893
8893
  placeholder: n("Ask AI to edit content"),
8894
8894
  className: "w-full",
8895
8895
  rows: 3,
8896
- onKeyDown: (h) => {
8897
- h.key === "Enter" && (h.preventDefault(), g.current && clearTimeout(g.current), p(void 0), r("content", o, i, m));
8896
+ onKeyDown: (g) => {
8897
+ g.key === "Enter" && (g.preventDefault(), p.current && clearTimeout(p.current), r("content", o, i, u));
8898
8898
  }
8899
8899
  }
8900
8900
  ),
@@ -8904,7 +8904,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8904
8904
  {
8905
8905
  disabled: i.trim().length < 5 || a,
8906
8906
  onClick: () => {
8907
- g.current && clearTimeout(g.current), p(void 0), r("content", o, i, m);
8907
+ p.current && clearTimeout(p.current), r("content", o, i, u);
8908
8908
  },
8909
8909
  variant: "default",
8910
8910
  className: "w-fit",
@@ -8923,21 +8923,13 @@ const AIUserPrompt = ({ blockId: o }) => {
8923
8923
  /* @__PURE__ */ jsx(Button, { variant: "destructive", onClick: () => stop(), className: "hidden w-fit", size: "sm", children: n("Stop") })
8924
8924
  ] }) : null
8925
8925
  ] }),
8926
- d ? /* @__PURE__ */ jsx("div", { className: "max-w-full", children: /* @__PURE__ */ jsxs("p", { className: "mb-1 flex justify-between break-words rounded border border-blue-500 bg-blue-100 p-1 text-xs text-blue-500", children: [
8927
- /* @__PURE__ */ jsxs("span", { children: [
8928
- n("Total tokens used"),
8929
- ": ",
8930
- d.totalTokens
8931
- ] }),
8932
- /* @__PURE__ */ jsx(Countdown, {})
8933
- ] }) }) : null,
8934
8926
  /* @__PURE__ */ jsx("div", { className: "max-w-full", children: l && /* @__PURE__ */ jsx("p", { className: "break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500", children: l.message }) }),
8935
8927
  /* @__PURE__ */ jsx("br", {}),
8936
8928
  /* @__PURE__ */ jsx(
8937
8929
  QuickPrompts,
8938
8930
  {
8939
- onClick: (h) => {
8940
- g.current && clearTimeout(g.current), p(void 0), r("content", o, h, m);
8931
+ onClick: (g) => {
8932
+ p.current && clearTimeout(p.current), r("content", o, g, u);
8941
8933
  }
8942
8934
  }
8943
8935
  )
@@ -9008,17 +9000,17 @@ function AIChatPanel() {
9008
9000
  }, 1500);
9009
9001
  }, h = (b) => {
9010
9002
  b.key === "Enter" && !b.shiftKey && (b.preventDefault(), m());
9011
- }, f = (b) => {
9003
+ }, x = (b) => {
9012
9004
  var B;
9013
9005
  const C = (B = b.target.files) == null ? void 0 : B[0];
9014
9006
  if (C) {
9015
9007
  const j = new FileReader();
9016
9008
  j.onload = (_) => {
9017
- var A;
9018
- d((A = _.target) == null ? void 0 : A.result);
9009
+ var w;
9010
+ d((w = _.target) == null ? void 0 : w.result);
9019
9011
  }, j.readAsDataURL(C);
9020
9012
  }
9021
- }, x = () => {
9013
+ }, f = () => {
9022
9014
  var b;
9023
9015
  (b = p.current) == null || b.click();
9024
9016
  }, y = () => {
@@ -9085,14 +9077,14 @@ function AIChatPanel() {
9085
9077
  className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
9086
9078
  }
9087
9079
  ),
9088
- /* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: f, accept: "image/*", className: "hidden" }),
9080
+ /* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: x, accept: "image/*", className: "hidden" }),
9089
9081
  /* @__PURE__ */ jsx(
9090
9082
  Button,
9091
9083
  {
9092
9084
  size: "icon",
9093
9085
  variant: "ghost",
9094
9086
  className: "absolute bottom-2 right-2 h-6 w-6",
9095
- onClick: x,
9087
+ onClick: f,
9096
9088
  children: /* @__PURE__ */ jsx(ImageIcon, { className: "h-4 w-4 text-muted-foreground" })
9097
9089
  }
9098
9090
  )
@@ -9210,7 +9202,7 @@ const AiAssistant = () => {
9210
9202
  preloadedAttributes: n = [],
9211
9203
  onAttributesChange: r
9212
9204
  }) {
9213
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), f = useRef(null), x = useRef(null), y = usePageExternalData();
9205
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), x = useRef(null), f = useRef(null), y = usePageExternalData();
9214
9206
  useEffect(() => {
9215
9207
  l(n);
9216
9208
  }, [n]);
@@ -9224,8 +9216,8 @@ const AiAssistant = () => {
9224
9216
  r(k), l(a), c(""), p(""), h("");
9225
9217
  }
9226
9218
  }, C = (k) => {
9227
- const w = a.filter((E, S) => S !== k);
9228
- r(w), l(w);
9219
+ const A = a.filter((E, S) => S !== k);
9220
+ r(A), l(A);
9229
9221
  }, B = (k) => {
9230
9222
  g(k), c(a[k].key), p(a[k].value);
9231
9223
  }, j = () => {
@@ -9239,16 +9231,16 @@ const AiAssistant = () => {
9239
9231
  }
9240
9232
  }, _ = (k) => {
9241
9233
  k.key === "Enter" && !k.shiftKey && (k.preventDefault(), u !== null ? j() : b());
9242
- }, A = useCallback((k) => {
9243
- const w = (v) => /[.,!?;:]/.test(v), E = (v, I, L) => {
9234
+ }, w = useCallback((k) => {
9235
+ const A = (v) => /[.,!?;:]/.test(v), E = (v, I, L) => {
9244
9236
  let T = "", P = "";
9245
9237
  const R = I > 0 ? v[I - 1] : "", N = I < v.length ? v[I] : "";
9246
- return I > 0 && (R === "." || !w(R) && R !== " ") && (T = " "), I < v.length && !w(N) && N !== " " && (P = " "), {
9238
+ return I > 0 && (R === "." || !A(R) && R !== " ") && (T = " "), I < v.length && !A(N) && N !== " " && (P = " "), {
9247
9239
  text: T + L + P,
9248
9240
  prefixLength: T.length,
9249
9241
  suffixLength: P.length
9250
9242
  };
9251
- }, S = x.current;
9243
+ }, S = f.current;
9252
9244
  if (S) {
9253
9245
  const v = S.selectionStart || 0, I = S.value || "", L = S.selectionEnd || v;
9254
9246
  if (L > v) {
@@ -9279,7 +9271,7 @@ const AiAssistant = () => {
9279
9271
  autoCorrect: "off",
9280
9272
  spellCheck: "false",
9281
9273
  id: "attrKey",
9282
- ref: f,
9274
+ ref: x,
9283
9275
  value: i,
9284
9276
  onChange: (k) => c(k.target.value),
9285
9277
  placeholder: "Enter Key",
@@ -9290,7 +9282,7 @@ const AiAssistant = () => {
9290
9282
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9291
9283
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9292
9284
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9293
- !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: A })
9285
+ !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: w })
9294
9286
  ] }),
9295
9287
  /* @__PURE__ */ jsx(
9296
9288
  Textarea,
@@ -9300,7 +9292,7 @@ const AiAssistant = () => {
9300
9292
  spellCheck: "false",
9301
9293
  id: "attrValue",
9302
9294
  rows: 2,
9303
- ref: x,
9295
+ ref: f,
9304
9296
  value: d,
9305
9297
  onChange: (k) => p(k.target.value),
9306
9298
  onKeyDown: _,
@@ -9315,16 +9307,16 @@ const AiAssistant = () => {
9315
9307
  ]
9316
9308
  }
9317
9309
  ),
9318
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((k, w) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9310
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((k, A) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9319
9311
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9320
9312
  /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: k.key }),
9321
9313
  /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: k.value.toString() })
9322
9314
  ] }),
9323
9315
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9324
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(w), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
9325
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => C(w), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
9316
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(A), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
9317
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => C(A), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
9326
9318
  ] })
9327
- ] }, w)) })
9319
+ ] }, A)) })
9328
9320
  ] });
9329
9321
  }), BlockAttributesEditor = React.memo(() => {
9330
9322
  const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9494,40 +9486,40 @@ function useSidebarDefaultPanels() {
9494
9486
  }, [o, n, r]);
9495
9487
  }
9496
9488
  const RootLayout = () => {
9497
- const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), m = reverse([...g ?? []]), h = useCallback((w) => {
9498
- w.preventDefault();
9499
- }, []), f = useCallback(
9500
- (w) => {
9501
- console.log("handleMenuItemClick", w, n), r(n === w ? null : w);
9489
+ const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), m = reverse([...g ?? []]), h = useCallback((A) => {
9490
+ A.preventDefault();
9491
+ }, []), x = useCallback(
9492
+ (A) => {
9493
+ console.log("handleMenuItemClick", A, n), r(n === A ? null : A);
9502
9494
  },
9503
9495
  [n, r]
9504
- ), { t: x } = useTranslation(), y = useMemo(
9496
+ ), { t: f } = useTranslation(), y = useMemo(
9505
9497
  () => [...p, ...u, ...g],
9506
9498
  [p, u, g]
9507
9499
  ), b = useBuilderProp("htmlDir", "ltr"), C = find(y, { id: n }) ?? first(y), B = get(C, "width", DEFAULT_PANEL_WIDTH);
9508
9500
  useEffect(() => {
9509
9501
  if (n !== null) {
9510
- const w = find(y, { id: n });
9511
- w && get(w, "view", "standard") === "standard" && (a.current = n, i(get(w, "width", DEFAULT_PANEL_WIDTH)));
9502
+ const A = find(y, { id: n });
9503
+ A && get(A, "view", "standard") === "standard" && (a.current = n, i(get(A, "width", DEFAULT_PANEL_WIDTH)));
9512
9504
  }
9513
9505
  }, [n, y]);
9514
9506
  const j = useMemo(() => {
9515
9507
  if (n === null) return 0;
9516
- const w = find(y, { id: n });
9517
- return get(w, "view", "standard") === "standard" ? B : l;
9508
+ const A = find(y, { id: n });
9509
+ return get(A, "view", "standard") === "standard" ? B : l;
9518
9510
  }, [n, B, l, y]), _ = useCallback(() => {
9519
9511
  r(a.current);
9520
- }, [r, n]), A = useCallback(() => {
9512
+ }, [r, n]), w = useCallback(() => {
9521
9513
  r("outline");
9522
9514
  }, [r]);
9523
9515
  useEffect(() => {
9524
9516
  n !== null && !find(y, { id: n }) && r("outline");
9525
9517
  }, [n, y]);
9526
9518
  const k = useCallback(
9527
- (w) => {
9528
- f(w);
9519
+ (A) => {
9520
+ x(A);
9529
9521
  },
9530
- [f]
9522
+ [x]
9531
9523
  );
9532
9524
  return /* @__PURE__ */ jsx("div", { dir: b, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9533
9525
  /* @__PURE__ */ jsxs(
@@ -9539,24 +9531,24 @@ const RootLayout = () => {
9539
9531
  /* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
9540
9532
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9541
9533
  /* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9542
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((w, E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9543
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(w, "button", NoopComponent), {
9534
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((A, E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9535
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(A, "button", NoopComponent), {
9544
9536
  position: "top",
9545
- panelId: w.id,
9546
- isActive: n === w.id,
9547
- show: () => k(w.id)
9537
+ panelId: A.id,
9538
+ isActive: n === A.id,
9539
+ show: () => k(A.id)
9548
9540
  }) }),
9549
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(w.label) }) })
9541
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(A.label) }) })
9550
9542
  ] }, "button-top-" + E)) }),
9551
9543
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9552
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: m == null ? void 0 : m.map((w, E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9553
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(w, "button", NoopComponent), {
9544
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: m == null ? void 0 : m.map((A, E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9545
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(A, "button", NoopComponent), {
9554
9546
  position: "bottom",
9555
- panelId: w.id,
9556
- isActive: n === w.id,
9557
- show: () => k(w.id)
9547
+ panelId: A.id,
9548
+ isActive: n === A.id,
9549
+ show: () => k(A.id)
9558
9550
  }) }),
9559
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(w.label) }) })
9551
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(A.label) }) })
9560
9552
  ] }, "button-bottom-" + E)) })
9561
9553
  ] }),
9562
9554
  /* @__PURE__ */ jsx(
@@ -9572,7 +9564,7 @@ const RootLayout = () => {
9572
9564
  "div",
9573
9565
  {
9574
9566
  className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(C, "isInternal", !1) ? "" : "w-64"}`,
9575
- children: /* @__PURE__ */ jsx("span", { children: x(get(C, "label", "")) })
9567
+ children: /* @__PURE__ */ jsx("span", { children: f(get(C, "label", "")) })
9576
9568
  }
9577
9569
  ),
9578
9570
  /* @__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(C, "panel", NoopComponent), {}) }) })
@@ -9595,11 +9587,11 @@ const RootLayout = () => {
9595
9587
  /* @__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: [
9596
9588
  /* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
9597
9589
  " ",
9598
- x("AI Assistant")
9590
+ f("AI Assistant")
9599
9591
  ] }) }) : c === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
9600
9592
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
9601
9593
  /* @__PURE__ */ jsx(MixerHorizontalIcon, { className: "h-4 w-4 text-gray-600" }),
9602
- x("Theme Settings")
9594
+ f("Theme Settings")
9603
9595
  ] }),
9604
9596
  /* @__PURE__ */ jsx(
9605
9597
  Button,
@@ -9630,10 +9622,10 @@ const RootLayout = () => {
9630
9622
  children: [
9631
9623
  /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
9632
9624
  /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(C, "icon", null) }),
9633
- /* @__PURE__ */ jsx("span", { children: x(get(C, "label", "")) })
9625
+ /* @__PURE__ */ jsx("span", { children: f(get(C, "label", "")) })
9634
9626
  ] }) }),
9635
9627
  /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(C, "panel", NoopComponent), {
9636
- close: A
9628
+ close: w
9637
9629
  }) }) })
9638
9630
  ]
9639
9631
  }
@@ -9642,10 +9634,10 @@ const RootLayout = () => {
9642
9634
  n !== null && get(C, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${B}px` }, children: [
9643
9635
  /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
9644
9636
  /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(C, "icon", null) }),
9645
- /* @__PURE__ */ jsx("span", { children: x(get(C, "label", "")) })
9637
+ /* @__PURE__ */ jsx("span", { children: f(get(C, "label", "")) })
9646
9638
  ] }) }),
9647
9639
  /* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(C, "panel", NoopComponent), {
9648
- close: A
9640
+ close: w
9649
9641
  }) }) })
9650
9642
  ] }) }),
9651
9643
  n !== null && get(C, "view") === "overlay" && /* @__PURE__ */ jsx(
@@ -9668,12 +9660,12 @@ const RootLayout = () => {
9668
9660
  /* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
9669
9661
  /* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
9670
9662
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(C, "icon", null) }),
9671
- /* @__PURE__ */ jsx("span", { children: x(get(C, "label", "")) })
9663
+ /* @__PURE__ */ jsx("span", { children: f(get(C, "label", "")) })
9672
9664
  ] }),
9673
9665
  /* @__PURE__ */ jsx(Button, { onClick: () => _(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-5 w-5" }) })
9674
9666
  ] }),
9675
9667
  /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(C, "panel", NoopComponent), {
9676
- close: A
9668
+ close: w
9677
9669
  }) }) })
9678
9670
  ]
9679
9671
  }
@@ -9712,36 +9704,36 @@ const RootLayout = () => {
9712
9704
  }) => {
9713
9705
  const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
9714
9706
  if (!l.trim()) return a;
9715
- const x = l.toLowerCase();
9707
+ const f = l.toLowerCase();
9716
9708
  return Object.fromEntries(
9717
9709
  Object.entries(a).filter(([y, b]) => {
9718
9710
  var C;
9719
- return (y == null ? void 0 : y.toLowerCase().includes(x)) || ((C = b == null ? void 0 : b.description) == null ? void 0 : C.toLowerCase().includes(x));
9711
+ return (y == null ? void 0 : y.toLowerCase().includes(f)) || ((C = b == null ? void 0 : b.description) == null ? void 0 : C.toLowerCase().includes(f));
9720
9712
  })
9721
9713
  );
9722
- }, [a, l]), m = (x) => {
9714
+ }, [a, l]), m = (f) => {
9723
9715
  d(!0), u({
9724
- x: x.clientX - n.x,
9725
- y: x.clientY - n.y
9716
+ x: f.clientX - n.x,
9717
+ y: f.clientY - n.y
9726
9718
  });
9727
- }, h = (x) => {
9719
+ }, h = (f) => {
9728
9720
  if (!c) return;
9729
- const y = x.clientX - p.x, b = x.clientY - p.y, C = x.currentTarget, B = C.offsetWidth, j = C.offsetHeight, _ = window.innerWidth - B, A = window.innerHeight - j, k = Math.max(0, Math.min(y, _)), w = Math.max(0, Math.min(b, A));
9730
- r(k, w);
9731
- }, f = () => {
9721
+ const y = f.clientX - p.x, b = f.clientY - p.y, C = f.currentTarget, B = C.offsetWidth, j = C.offsetHeight, _ = window.innerWidth - B, w = window.innerHeight - j, k = Math.max(0, Math.min(y, _)), A = Math.max(0, Math.min(b, w));
9722
+ r(k, A);
9723
+ }, x = () => {
9732
9724
  d(!1);
9733
9725
  };
9734
9726
  return useEffect(() => {
9735
- const x = () => {
9727
+ const f = () => {
9736
9728
  c && d(!1);
9737
9729
  };
9738
- return window.addEventListener("mouseup", x), () => window.removeEventListener("mouseup", x);
9730
+ return window.addEventListener("mouseup", f), () => window.removeEventListener("mouseup", f);
9739
9731
  }, [c]), !n || n.x < 0 || n.y < 0 ? null : /* @__PURE__ */ jsxs(
9740
9732
  "div",
9741
9733
  {
9742
9734
  onMouseDown: m,
9743
9735
  onMouseMove: h,
9744
- onMouseUp: f,
9736
+ onMouseUp: x,
9745
9737
  className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
9746
9738
  style: {
9747
9739
  left: n.x,
@@ -9783,13 +9775,13 @@ const RootLayout = () => {
9783
9775
  placeholder: "Search features...",
9784
9776
  className: "w-full pl-8",
9785
9777
  value: l,
9786
- onChange: (x) => i(x.target.value),
9778
+ onChange: (f) => i(f.target.value),
9787
9779
  autoFocus: !0
9788
9780
  }
9789
9781
  )
9790
9782
  ] })
9791
9783
  ] }),
9792
- /* @__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, y]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: x, options: y }, x)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
9784
+ /* @__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: [
9793
9785
  'No features found matching "',
9794
9786
  l,
9795
9787
  '"'
@@ -9933,8 +9925,8 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
9933
9925
  c.f && u(c.f);
9934
9926
  const g = /* @__PURE__ */ new Set(), m = g.add.bind(g);
9935
9927
  a.forEach((h) => {
9936
- var f;
9937
- return (f = r.get(h)) == null ? void 0 : f.l.forEach(m);
9928
+ var x;
9929
+ return (x = r.get(h)) == null ? void 0 : x.l.forEach(m);
9938
9930
  }), a.clear(), i.forEach(m), i.clear(), l.forEach(m), l.clear(), g.forEach(u), a.size && d(o);
9939
9931
  } while (a.size || i.size || l.size);
9940
9932
  if (p.length)
@@ -9942,73 +9934,73 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
9942
9934
  }, recomputeInvalidatedAtoms = (o) => {
9943
9935
  const n = getBuildingBlocks(o), r = n[1], a = n[2], l = n[3], i = n[11], c = n[14], d = n[17], p = [], u = /* @__PURE__ */ new WeakSet(), g = /* @__PURE__ */ new WeakSet(), m = Array.from(l);
9944
9936
  for (; m.length; ) {
9945
- const h = m[m.length - 1], f = i(o, h);
9937
+ const h = m[m.length - 1], x = i(o, h);
9946
9938
  if (g.has(h)) {
9947
9939
  m.pop();
9948
9940
  continue;
9949
9941
  }
9950
9942
  if (u.has(h)) {
9951
- a.get(h) === f.n && p.push([h, f]), g.add(h), m.pop();
9943
+ a.get(h) === x.n && p.push([h, x]), g.add(h), m.pop();
9952
9944
  continue;
9953
9945
  }
9954
9946
  u.add(h);
9955
- for (const x of getMountedOrPendingDependents(h, f, r))
9956
- u.has(x) || m.push(x);
9947
+ for (const f of getMountedOrPendingDependents(h, x, r))
9948
+ u.has(f) || m.push(f);
9957
9949
  }
9958
9950
  for (let h = p.length - 1; h >= 0; --h) {
9959
- const [f, x] = p[h];
9951
+ const [x, f] = p[h];
9960
9952
  let y = !1;
9961
- for (const b of x.d.keys())
9962
- if (b !== f && l.has(b)) {
9953
+ for (const b of f.d.keys())
9954
+ if (b !== x && l.has(b)) {
9963
9955
  y = !0;
9964
9956
  break;
9965
9957
  }
9966
- y && (c(o, f), d(o, f)), a.delete(f);
9958
+ y && (c(o, x), d(o, x)), a.delete(x);
9967
9959
  }
9968
9960
  }, readAtomState = (o, n) => {
9969
9961
  var r;
9970
- const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], d = a[6], p = a[7], u = a[11], g = a[12], m = a[13], h = a[14], f = a[16], x = a[17], y = u(o, n);
9962
+ const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], d = a[6], p = a[7], u = a[11], g = a[12], m = a[13], h = a[14], x = a[16], f = a[17], y = u(o, n);
9971
9963
  if (isAtomStateInitialized(y) && (l.has(n) && i.get(n) !== y.n || Array.from(y.d).every(
9972
- ([w, E]) => (
9964
+ ([A, E]) => (
9973
9965
  // Recursively, read the atom state of the dependency, and
9974
9966
  // check if the atom epoch number is unchanged
9975
- h(o, w).n === E
9967
+ h(o, A).n === E
9976
9968
  )
9977
9969
  )))
9978
9970
  return y;
9979
9971
  y.d.clear();
9980
9972
  let b = !0;
9981
9973
  function C() {
9982
- l.has(n) && (x(o, n), m(o), g(o));
9974
+ l.has(n) && (f(o, n), m(o), g(o));
9983
9975
  }
9984
- function B(w) {
9976
+ function B(A) {
9985
9977
  var E;
9986
- if (isSelfAtom(n, w)) {
9987
- const v = u(o, w);
9978
+ if (isSelfAtom(n, A)) {
9979
+ const v = u(o, A);
9988
9980
  if (!isAtomStateInitialized(v))
9989
- if (hasInitialValue(w))
9990
- setAtomStateValueOrPromise(o, w, w.init);
9981
+ if (hasInitialValue(A))
9982
+ setAtomStateValueOrPromise(o, A, A.init);
9991
9983
  else
9992
9984
  throw new Error("no atom init");
9993
9985
  return returnAtomValue(v);
9994
9986
  }
9995
- const S = h(o, w);
9987
+ const S = h(o, A);
9996
9988
  try {
9997
9989
  return returnAtomValue(S);
9998
9990
  } finally {
9999
- y.d.set(w, S.n), isPendingPromise(y.v) && addPendingPromiseToDependency(n, y.v, S), (E = l.get(w)) == null || E.t.add(n), b || C();
9991
+ y.d.set(A, S.n), isPendingPromise(y.v) && addPendingPromiseToDependency(n, y.v, S), (E = l.get(A)) == null || E.t.add(n), b || C();
10000
9992
  }
10001
9993
  }
10002
9994
  let j, _;
10003
- const A = {
9995
+ const w = {
10004
9996
  get signal() {
10005
9997
  return j || (j = new AbortController()), j.signal;
10006
9998
  },
10007
9999
  get setSelf() {
10008
- return !_ && isActuallyWritableAtom(n) && (_ = (...w) => {
10000
+ return !_ && isActuallyWritableAtom(n) && (_ = (...A) => {
10009
10001
  if (!b)
10010
10002
  try {
10011
- return f(o, n, ...w);
10003
+ return x(o, n, ...A);
10012
10004
  } finally {
10013
10005
  m(o), g(o);
10014
10006
  }
@@ -10016,10 +10008,10 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10016
10008
  }
10017
10009
  }, k = y.n;
10018
10010
  try {
10019
- const w = p(o, n, B, A);
10020
- return setAtomStateValueOrPromise(o, n, w), isPromiseLike$1(w) && (registerAbortHandler(w, () => j == null ? void 0 : j.abort()), w.then(C, C)), y;
10021
- } catch (w) {
10022
- return delete y.v, y.e = w, ++y.n, y;
10011
+ const A = p(o, n, B, w);
10012
+ return setAtomStateValueOrPromise(o, n, A), isPromiseLike$1(A) && (registerAbortHandler(A, () => j == null ? void 0 : j.abort()), A.then(C, C)), y;
10013
+ } catch (A) {
10014
+ return delete y.v, y.e = A, ++y.n, y;
10023
10015
  } finally {
10024
10016
  b = !1, k !== y.n && i.get(n) === k && (i.set(n, y.n), c.add(n), (r = d.c) == null || r.call(d, n));
10025
10017
  }
@@ -10034,57 +10026,57 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10034
10026
  }
10035
10027
  }, writeAtomState = (o, n, ...r) => {
10036
10028
  const a = getBuildingBlocks(o), l = a[3], i = a[6], c = a[8], d = a[11], p = a[12], u = a[13], g = a[14], m = a[15], h = a[17];
10037
- let f = !0;
10038
- const x = (b) => returnAtomValue(g(o, b)), y = (b, ...C) => {
10029
+ let x = !0;
10030
+ const f = (b) => returnAtomValue(g(o, b)), y = (b, ...C) => {
10039
10031
  var B;
10040
10032
  const j = d(o, b);
10041
10033
  try {
10042
10034
  if (isSelfAtom(n, b)) {
10043
10035
  if (!hasInitialValue(b))
10044
10036
  throw new Error("atom not writable");
10045
- const _ = j.n, A = C[0];
10046
- setAtomStateValueOrPromise(o, b, A), h(o, b), _ !== j.n && (l.add(b), (B = i.c) == null || B.call(i, b), m(o, b));
10037
+ const _ = j.n, w = C[0];
10038
+ setAtomStateValueOrPromise(o, b, w), h(o, b), _ !== j.n && (l.add(b), (B = i.c) == null || B.call(i, b), m(o, b));
10047
10039
  return;
10048
10040
  } else
10049
10041
  return writeAtomState(o, b, ...C);
10050
10042
  } finally {
10051
- f || (u(o), p(o));
10043
+ x || (u(o), p(o));
10052
10044
  }
10053
10045
  };
10054
10046
  try {
10055
- return c(o, n, x, y, ...r);
10047
+ return c(o, n, f, y, ...r);
10056
10048
  } finally {
10057
- f = !1;
10049
+ x = !1;
10058
10050
  }
10059
10051
  }, mountDependencies = (o, n) => {
10060
10052
  var r;
10061
10053
  const a = getBuildingBlocks(o), l = a[1], i = a[3], c = a[6], d = a[11], p = a[15], u = a[18], g = a[19], m = d(o, n), h = l.get(n);
10062
10054
  if (h && !isPendingPromise(m.v)) {
10063
- for (const [f, x] of m.d)
10064
- if (!h.d.has(f)) {
10065
- const y = d(o, f);
10066
- u(o, f).t.add(n), h.d.add(f), x !== y.n && (i.add(f), (r = c.c) == null || r.call(c, f), p(o, f));
10055
+ for (const [x, f] of m.d)
10056
+ if (!h.d.has(x)) {
10057
+ const y = d(o, x);
10058
+ u(o, x).t.add(n), h.d.add(x), f !== y.n && (i.add(x), (r = c.c) == null || r.call(c, x), p(o, x));
10067
10059
  }
10068
- for (const f of h.d || [])
10069
- if (!m.d.has(f)) {
10070
- h.d.delete(f);
10071
- const x = g(o, f);
10072
- x == null || x.t.delete(n);
10060
+ for (const x of h.d || [])
10061
+ if (!m.d.has(x)) {
10062
+ h.d.delete(x);
10063
+ const f = g(o, x);
10064
+ f == null || f.t.delete(n);
10073
10065
  }
10074
10066
  }
10075
10067
  }, mountAtom = (o, n) => {
10076
10068
  var r;
10077
- const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], d = a[10], p = a[11], u = a[12], g = a[13], m = a[14], h = a[16], f = p(o, n);
10078
- let x = l.get(n);
10079
- if (!x) {
10069
+ const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], d = a[10], p = a[11], u = a[12], g = a[13], m = a[14], h = a[16], x = p(o, n);
10070
+ let f = l.get(n);
10071
+ if (!f) {
10080
10072
  m(o, n);
10081
- for (const y of f.d.keys())
10073
+ for (const y of x.d.keys())
10082
10074
  mountAtom(o, y).t.add(n);
10083
- if (x = {
10075
+ if (f = {
10084
10076
  l: /* @__PURE__ */ new Set(),
10085
- d: new Set(f.d.keys()),
10077
+ d: new Set(x.d.keys()),
10086
10078
  t: /* @__PURE__ */ new Set()
10087
- }, l.set(n, x), (r = c.m) == null || r.call(c, n), isActuallyWritableAtom(n)) {
10079
+ }, l.set(n, f), (r = c.m) == null || r.call(c, n), isActuallyWritableAtom(n)) {
10088
10080
  const y = () => {
10089
10081
  let b = !0;
10090
10082
  const C = (...B) => {
@@ -10096,7 +10088,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10096
10088
  };
10097
10089
  try {
10098
10090
  const B = d(o, n, C);
10099
- B && (x.u = () => {
10091
+ B && (f.u = () => {
10100
10092
  b = !0;
10101
10093
  try {
10102
10094
  B();
@@ -10111,7 +10103,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10111
10103
  i.add(y);
10112
10104
  }
10113
10105
  }
10114
- return x;
10106
+ return f;
10115
10107
  }, unmountAtom = (o, n) => {
10116
10108
  var r;
10117
10109
  const a = getBuildingBlocks(o), l = a[1], i = a[5], c = a[6], d = a[11], p = a[19], u = d(o, n);