@chaibuilder/sdk 2.2.2 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,24 +1,26 @@
1
1
  var G = Object.defineProperty;
2
2
  var K = (o, r, n) => r in o ? G(o, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[r] = n;
3
- var V = (o, r, n) => K(o, typeof r != "symbol" ? r + "" : r, n);
4
- import { jsx, Fragment, jsxs } from "react/jsx-runtime";
3
+ var U = (o, r, n) => K(o, typeof r != "symbol" ? r + "" : r, n);
4
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
+ import { find, filter, flatten, map, omit, isString, has, includes, without, get, compact, isEmpty, each, isObject, memoize, noop, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, reverse, findIndex, throttle, isFunction, split, reject, take, debounce, startCase, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, capitalize, groupBy, uniq, flatMapDeep, some, sortBy, round } from "lodash-es";
6
+ import { Resizable } from "re-resizable";
5
7
  import * as React from "react";
6
- import React__default, { Component, Children, useEffect, useCallback, useMemo, useRef, useState, Suspense, createElement, memo, createContext, useContext, useReducer, useDebugValue } from "react";
7
- import { U as DropdownMenu, V as DropdownMenuTrigger, W as DropdownMenuContent, X as DropdownMenuItem, aq as Skeleton, B as Button, e as Alert, g as AlertDescription, aa as Input$1, N as Dialog, O as DialogTrigger, P as DialogContent, ac as Popover, ay as Tooltip, az as TooltipTrigger, ad as PopoverTrigger, aA as TooltipContent, ae as PopoverContent, E as Command, G as CommandInput, H as CommandList, I as CommandEmpty, J as CommandGroup, K as CommandItem, Q as DialogHeader, S as DialogTitle, t as Badge, _ as DropdownMenuLabel, $ as DropdownMenuSeparator, Y as DropdownMenuCheckboxItem, a7 as HoverCard, a8 as HoverCardTrigger, a9 as HoverCardContent, ax as Textarea, aC as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, A as Accordion, C as Card, w as CardHeader, z as CardDescription, D as CardContent, ab as Label, x as CardFooter, af as ScrollArea, at as Tabs, au as TabsList, av as TabsTrigger, aw as TabsContent, h as AlertDialog, i as AlertDialogTrigger, j as AlertDialogContent, k as AlertDialogHeader, m as AlertDialogTitle, n as AlertDialogDescription, l as AlertDialogFooter, p as AlertDialogCancel, o as AlertDialogAction, as as Switch, q as Avatar, ah as Separator, aB as TooltipProvider, ai as Sheet, al as SheetContent, am as SheetHeader, ao as SheetTitle, ar as Toaster } from "./tooltip-DGVZAvLU.js";
8
- import { atom, useAtomValue as useAtomValue$1, useAtom as useAtom$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
9
- import { find, filter, flatten, map, omit, isString, has, includes, without, get, compact, isEmpty, each, isObject, memoize, noop, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, findIndex, throttle, isFunction, reverse, split, reject, take, debounce, startCase, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, capitalize, groupBy, uniq, flatMapDeep, some, sortBy, round } from "lodash-es";
10
- import { Provider as Provider$1 } from "react-wrap-balancer";
11
- import { atomWithStorage, splitAtom, useAtomCallback } from "jotai/utils";
8
+ import React__default, { useEffect, useCallback, useMemo, useRef, useState, Component, Children, Suspense, createElement, memo, createContext, useContext, useReducer, useDebugValue } from "react";
9
+ import { ErrorBoundary } from "react-error-boundary";
10
+ import { B as Button, U as DropdownMenu, V as DropdownMenuTrigger, W as DropdownMenuContent, X as DropdownMenuItem, aq as Skeleton, e as Alert, g as AlertDescription, aa as Input$1, N as Dialog, O as DialogTrigger, P as DialogContent, ac as Popover, ay as Tooltip, az as TooltipTrigger, ad as PopoverTrigger, aA as TooltipContent, ae as PopoverContent, E as Command, G as CommandInput, H as CommandList, I as CommandEmpty, J as CommandGroup, K as CommandItem, Q as DialogHeader, S as DialogTitle, t as Badge, _ as DropdownMenuLabel, $ as DropdownMenuSeparator, Y as DropdownMenuCheckboxItem, a7 as HoverCard, a8 as HoverCardTrigger, a9 as HoverCardContent, ax as Textarea, aC as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, A as Accordion, C as Card, w as CardHeader, z as CardDescription, D as CardContent, ab as Label, x as CardFooter, af as ScrollArea, at as Tabs, au as TabsList, av as TabsTrigger, aw as TabsContent, h as AlertDialog, i as AlertDialogTrigger, j as AlertDialogContent, k as AlertDialogHeader, m as AlertDialogTitle, n as AlertDialogDescription, l as AlertDialogFooter, p as AlertDialogCancel, o as AlertDialogAction, as as Switch, q as Avatar, ah as Separator, aB as TooltipProvider, ai as Sheet, al as SheetContent, am as SheetHeader, ao as SheetTitle, ar as Toaster } from "./tooltip-DGVZAvLU.js";
12
11
  import { useTranslation, initReactI18next } from "react-i18next";
13
- import { useTranslation as Ue } from "react-i18next";
12
+ import { useTranslation as Ve } from "react-i18next";
13
+ import { atom, useAtomValue as useAtomValue$1, useAtom as useAtom$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
14
+ import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, DatabaseIcon, ChevronLeft, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, X, Plus, PlusCircle, ChevronDown, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, MoreVertical, Eye, ChevronsDown, ChevronsUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
15
+ import { splitAtom, atomWithStorage, useAtomCallback } from "jotai/utils";
14
16
  import { g as generateUUID, a as getBreakpointValue, c as cn$1 } from "./Functions-BGzDsf1z.js";
17
+ import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredChaiBlocks, useRegisteredFonts, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
18
+ import { BoxModelIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, Cross2Icon, InfoCircledIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon, BoxIcon, MinusIcon, TriangleDownIcon, RowSpacingIcon, CrossCircledIcon, CaretRightIcon, CardStackIcon, CardStackPlusIcon, ScissorsIcon, CheckIcon, SunIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
19
+ import { Provider as Provider$1 } from "react-wrap-balancer";
15
20
  import { flip } from "@floating-ui/dom";
16
21
  import { useFloating, shift } from "@floating-ui/react-dom";
17
- import { PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxModelIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, Cross2Icon, InfoCircledIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon, BoxIcon, MinusIcon, TriangleDownIcon, RowSpacingIcon, CrossCircledIcon, CaretRightIcon, CardStackIcon, CardStackPlusIcon, ScissorsIcon, CheckIcon, SunIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
18
22
  import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
19
23
  import { useFeature, FlagsProvider } from "flagged";
20
- import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, useRegisteredChaiBlocks, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
21
- import { PlusIcon as PlusIcon$1, ChevronRight, AlertCircle, DatabaseIcon, ChevronLeft, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, X, Plus, PlusCircle, ChevronDown, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, PencilIcon, EyeOffIcon, MoreVertical, Eye, ChevronsDown, ChevronsUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
22
24
  import RjForm from "@rjsf/core";
23
25
  import validator from "@rjsf/validator-ajv8";
24
26
  import Link from "@tiptap/extension-link";
@@ -31,14 +33,13 @@ import { twMerge } from "tailwind-merge";
31
33
  import Autosuggest from "react-autosuggest";
32
34
  import { toast } from "sonner";
33
35
  import Fuse from "fuse.js";
34
- import { d as defaultThemeOptions, h as hexToHSL, a as getChaiThemeCssVariables, g as getChaiThemeOptions, p as plugin, c as getThemeFontsLinkMarkup, e as getThemeCustomFontFace } from "./chai-theme-helpers-FO9vdd-R.js";
36
+ import { d as defaultThemeOptions, e as defaultThemeValues, a as getChaiThemeCssVariables, g as getChaiThemeOptions, p as plugin, c as getThemeFontsLinkMarkup, f as getThemeCustomFontFace } from "./chai-theme-helpers-CfZwxV6S.js";
35
37
  import { S as STYLES_KEY, g as getSplitChaiClasses, R as ROOT_TEMP_KEY } from "./getSplitClasses-DphwgQiE.js";
36
38
  import UndoManager from "undo-manager";
37
39
  import { parse, stringify } from "himalaya";
38
40
  import { Tree } from "react-arborist";
39
41
  import i18n from "i18next";
40
42
  import { default as ze } from "i18next";
41
- import { ErrorBoundary } from "react-error-boundary";
42
43
  import { useHotkeys } from "react-hotkeys-hook";
43
44
  import { motion } from "framer-motion";
44
45
  import TreeModel from "tree-model";
@@ -47,130 +48,15 @@ import twContainer from "@tailwindcss/container-queries";
47
48
  import tailwindForms from "@tailwindcss/forms";
48
49
  import tailwindTypography from "@tailwindcss/typography";
49
50
  import ReactDOM from "react-dom";
50
- import { Resizable } from "re-resizable";
51
- const readOnlyModeAtom = atom(!1);
52
- readOnlyModeAtom.debugLabel = "readOnlyModeAtom";
53
- const networkModeAtom = atom("online");
54
- networkModeAtom.debugLabel = "networkModeAtom";
55
- atom("");
56
- const editLayerNameAtom = atom(!1);
57
- editLayerNameAtom.debugLabel = "editLayerNameAtom";
58
- const activeLanguageAtom = atom("");
59
- activeLanguageAtom.debugLabel = "activeLanguageAtom";
60
- const primaryLanguageAtom = atom("");
61
- primaryLanguageAtom.debugLabel = "primaryLanguageAtom";
62
- const canvasIframeAtom = atom(null);
63
- canvasIframeAtom.debugLabel = "canvasIframeAtom";
64
- const activePanelAtom = atom("outline");
65
- activePanelAtom.debugLabel = "activePanelAtom";
66
- const showPredefinedBlockCategoryAtom = atom("");
67
- showPredefinedBlockCategoryAtom.debugLabel = "showPredefinedBlockCategoryAtom";
68
- const inlineEditingActiveAtom = atom("");
69
- inlineEditingActiveAtom.debugLabel = "inlineEditingActiveAtom";
70
- const draggingFlagAtom = atom(!1);
71
- draggingFlagAtom.debugLabel = "draggingFlagAtom";
72
- const treeRefAtom = atom(null);
73
- treeRefAtom.debugLabel = "treeRefAtom";
74
- const canvasSettingsAtom = atom({});
75
- canvasSettingsAtom.debugLabel = "canvasSettingsAtom";
76
- const aiAssistantActiveAtom = atom(!1);
77
- aiAssistantActiveAtom.debugLabel = "aiAssistantActiveAtom";
78
- const codeEditorOpenAtom = atom(!1);
79
- codeEditorOpenAtom.debugLabel = "codeEditorOpenAtom";
80
- const codeEditorHeightAtom = atomWithStorage("codeEditorHeight", 500);
81
- codeEditorHeightAtom.debugLabel = "codeEditorHeightAtom";
82
- const xShowBlocksAtom = atom([]);
83
- xShowBlocksAtom.debugLabel = "xShowBlocksAtom";
84
- const selectedLibraryAtom = atomWithStorage("_selectedLibrary", null);
85
- selectedLibraryAtom.debugLabel = "selectedLibraryAtom";
86
- const dataBindingActiveAtom = atom(!0);
87
- dataBindingActiveAtom.debugLabel = "dataBindingActiveAtom";
88
- class Content extends Component {
89
- componentDidMount() {
90
- this.props.contentDidMount();
91
- }
92
- componentDidUpdate() {
93
- this.props.contentDidUpdate();
94
- }
95
- render() {
96
- return Children.only(this.props.children);
97
- }
98
- }
99
- let doc, win;
100
- typeof document < "u" && (doc = document);
101
- typeof window < "u" && (win = window);
102
- const FrameContext = React__default.createContext({ document: doc, window: win }), useFrame = () => React__default.useContext(FrameContext), { Provider: FrameContextProvider, Consumer: FrameContextConsumer } = FrameContext;
103
- class Frame extends Component {
104
- constructor(n, a) {
105
- super(n, a);
106
- V(this, "setRef", (n) => {
107
- this.nodeRef.current = n;
108
- const { forwardedRef: a } = this.props;
109
- typeof a == "function" ? a(n) : a && (a.current = n);
110
- });
111
- V(this, "handleLoad", () => {
112
- clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
113
- });
114
- // In certain situations on a cold cache DOMContentLoaded never gets called
115
- // fallback to an interval to check if that's the case
116
- V(this, "loadCheck", () => setInterval(() => {
117
- this.handleLoad();
118
- }, 500));
119
- this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
120
- }
121
- componentDidMount() {
122
- this._isMounted = !0, this.getDoc() && this.nodeRef.current.contentWindow.addEventListener("DOMContentLoaded", this.handleLoad);
123
- }
124
- componentWillUnmount() {
125
- this._isMounted = !1, this.nodeRef.current.removeEventListener("DOMContentLoaded", this.handleLoad);
126
- }
127
- getDoc() {
128
- return this.nodeRef.current ? this.nodeRef.current.contentDocument : null;
129
- }
130
- getMountTarget() {
131
- const n = this.getDoc();
132
- return this.props.mountTarget ? n.querySelector(this.props.mountTarget) : n.body.children[0];
133
- }
134
- renderFrameContents() {
135
- if (!this._isMounted)
136
- return null;
137
- const n = this.getDoc();
138
- if (!n)
139
- return null;
140
- const a = this.props.contentDidMount, l = this.props.contentDidUpdate, i = n.defaultView || n.parentView, c = /* @__PURE__ */ jsx(Content, { contentDidMount: a, contentDidUpdate: l, children: /* @__PURE__ */ jsx(FrameContextProvider, { value: { document: n, window: i }, children: /* @__PURE__ */ jsx("div", { className: "frame-content", children: this.props.children }) }) }), d = this.getMountTarget();
141
- return [ReactDOM.createPortal(this.props.head, this.getDoc().head), ReactDOM.createPortal(c, d)];
142
- }
143
- render() {
144
- const n = {
145
- ...this.props,
146
- srcDoc: this.props.initialContent,
147
- children: void 0
148
- // The iframe isn't ready so we drop children from props here. #12, #17
149
- };
150
- return delete n.head, delete n.initialContent, delete n.mountTarget, delete n.contentDidMount, delete n.contentDidUpdate, delete n.forwardedRef, /* @__PURE__ */ jsx("iframe", { ...n, ref: this.setRef, onLoad: this.handleLoad, children: this.state.iframeLoaded && this.renderFrameContents() });
151
- }
152
- }
153
- V(Frame, "defaultProps", {
154
- style: {},
155
- head: null,
156
- children: void 0,
157
- mountTarget: void 0,
158
- contentDidMount: () => {
159
- },
160
- contentDidUpdate: () => {
161
- },
162
- initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
163
- });
164
- const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: r }));
165
51
  function duplicateBlocks(o, r, n) {
166
52
  const a = filter(o, (i) => i._parent === r), l = [];
167
53
  for (let i = 0; i < a.length; i++) {
168
- const c = getSlots(a[i]);
169
- if (Object.keys(c).length > 0 && Object.keys(c).forEach((d) => {
170
- a[i][d] = `slot:${generateUUID()}`;
54
+ const d = getSlots(a[i]);
55
+ if (Object.keys(d).length > 0 && Object.keys(d).forEach((c) => {
56
+ a[i][c] = `slot:${generateUUID()}`;
171
57
  }), filter(o, { _parent: a[i]._id }).length > 0) {
172
- const d = generateUUID();
173
- l.push({ ...a[i], oldId: a[i]._id, _id: d, _parent: n }), l.push(flatten(duplicateBlocks(o, a[i]._id, d)));
58
+ const c = generateUUID();
59
+ l.push({ ...a[i], oldId: a[i]._id, _id: c, _parent: n }), l.push(flatten(duplicateBlocks(o, a[i]._id, c)));
174
60
  } else
175
61
  l.push({
176
62
  ...a[i],
@@ -206,12 +92,12 @@ const getSlots = (o) => {
206
92
  const l = [a];
207
93
  filter(o, { _parent: r }).length > 0 && l.push(flatten(duplicateBlocks(o, r, a._id)));
208
94
  const i = flatten(l);
209
- return map(i, (c) => {
210
- const d = c, p = getSlots(d);
95
+ return map(i, (d) => {
96
+ const c = d, p = getSlots(c);
211
97
  return Object.keys(p).length > 0 && Object.keys(p).forEach((u) => {
212
98
  const g = find(i, { oldId: p[u].replace("slot:", "") });
213
- d[u] = `slot:${g._id}`;
214
- }), omit(d, ["global", "oldId"]);
99
+ c[u] = `slot:${g._id}`;
100
+ }), omit(c, ["global", "oldId"]);
215
101
  });
216
102
  }, presentBlocksAtom = atom([]);
217
103
  presentBlocksAtom.debugLabel = "presentBlocksAtom";
@@ -288,7 +174,7 @@ const useSelectedBlocksDisplayChild = () => ({
288
174
  let a = r;
289
175
  const l = [r];
290
176
  do {
291
- const i = n.find(({ _id: c }) => c === (a == null ? void 0 : a._parent));
177
+ const i = n.find(({ _id: d }) => d === (a == null ? void 0 : a._parent));
292
178
  a = i, i && l.push(i);
293
179
  } while (a != null && a._parent);
294
180
  return l;
@@ -302,12 +188,12 @@ const useSelectedBlocksDisplayChild = () => ({
302
188
  return [o, r, n];
303
189
  }, removeNestedBlocks = (o, r) => {
304
190
  let n = [...o], a = [];
305
- r.forEach((d) => {
306
- const p = n.find((f) => f._id === d);
191
+ r.forEach((c) => {
192
+ const p = n.find((f) => f._id === c);
307
193
  if (!p || !p._parent) return;
308
194
  const u = p._parent, g = n.filter((f) => f._parent === u);
309
195
  if (g.length === 2) {
310
- const f = g.find((m) => m._id !== d);
196
+ const f = g.find((m) => m._id !== c);
311
197
  if (f && f._type === "Text") {
312
198
  const m = n.find((h) => h._id === u);
313
199
  m && "content" in m && (n = n.map((h) => {
@@ -322,16 +208,16 @@ const useSelectedBlocksDisplayChild = () => ({
322
208
  }
323
209
  }
324
210
  });
325
- const l = [...r, ...a], i = [], c = filter(n, (d) => includes(l, d._id) || includes(l, d._parent) ? (i.push(d._id), !1) : !0);
326
- return isEmpty(i) ? c : removeNestedBlocks(c, i);
211
+ const l = [...r, ...a], i = [], d = filter(n, (c) => includes(l, c._id) || includes(l, c._parent) ? (i.push(c._id), !1) : !0);
212
+ return isEmpty(i) ? d : removeNestedBlocks(d, i);
327
213
  }, useRemoveBlocks = () => {
328
214
  const [o] = useBlocksStore(), [r, n] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions(), { hasPermission: l } = usePermissions();
329
215
  return useCallback(
330
216
  (i) => {
331
- var d;
217
+ var c;
332
218
  if (!l(PERMISSIONS.DELETE_BLOCK)) return;
333
- const c = ((d = find(o, { _id: i[0] })) == null ? void 0 : d._parent) || null;
334
- a(removeNestedBlocks(o, i)), setTimeout(() => n(c ? [c] : []), 200);
219
+ const d = ((c = find(o, { _id: i[0] })) == null ? void 0 : c._parent) || null;
220
+ a(removeNestedBlocks(o, i)), setTimeout(() => n(d ? [d] : []), 200);
335
221
  },
336
222
  [o, n, r, l]
337
223
  );
@@ -339,7 +225,7 @@ const useSelectedBlocksDisplayChild = () => ({
339
225
  null,
340
226
  // it's a convention to pass `null` for the first argument
341
227
  (o, r, { id: n, props: a }) => {
342
- const l = o(pageBlocksAtomsAtom), i = find(l, (c) => o(c)._id === n);
228
+ const l = o(pageBlocksAtomsAtom), i = find(l, (d) => o(d)._id === n);
343
229
  if (!i)
344
230
  throw new Error(`Block with id ${n} not found`);
345
231
  return r(i, { ...o(i), ...a });
@@ -352,7 +238,7 @@ const useSelectedBlocksDisplayChild = () => ({
352
238
  throw new Error("No blocks available");
353
239
  const i = find(
354
240
  l,
355
- (c) => r(c)._id === (isString(a) ? a : r(a)._id)
241
+ (d) => r(d)._id === (isString(a) ? a : r(a)._id)
356
242
  );
357
243
  if (!i)
358
244
  throw new Error(`Block with id ${a} not found`);
@@ -369,7 +255,7 @@ const useSelectedBlocksDisplayChild = () => ({
369
255
  return console.warn("No blocks available in splitAtoms"), null;
370
256
  const i = find(
371
257
  l,
372
- (c) => r(c)._id === (isString(a) ? a : r(a)._id)
258
+ (d) => r(d)._id === (isString(a) ? a : r(a)._id)
373
259
  );
374
260
  return i || (console.warn(`Block with id ${a} not found`), null);
375
261
  },
@@ -402,19 +288,19 @@ function insertBlocksAtPosition(o, r, n, a) {
402
288
  });
403
289
  }
404
290
  }
405
- let c = i.filter((u) => !u._parent);
406
- n && (c = i.filter((u) => u._parent === n));
407
- const d = !isNaN(a) || a > -1 ? Math.min(a, c.length) : c.length;
291
+ let d = i.filter((u) => !u._parent);
292
+ n && (d = i.filter((u) => u._parent === n));
293
+ const c = !isNaN(a) || a > -1 ? Math.min(a, d.length) : d.length;
408
294
  let p = i.length;
409
295
  for (let u = 0, g = 0; u < i.length; u++)
410
296
  if (n !== void 0 ? i[u]._parent === n : !i[u]._parent) {
411
- if (g === d) {
297
+ if (g === c) {
412
298
  p = u;
413
299
  break;
414
300
  }
415
301
  g++;
416
302
  }
417
- return !n && a !== void 0 && a >= c.length && (p = i.length), [...i.slice(0, p), ...l, ...i.slice(p)];
303
+ return !n && a !== void 0 && a >= d.length && (p = i.length), [...i.slice(0, p), ...l, ...i.slice(p)];
418
304
  }
419
305
  function getBlocksTree(o) {
420
306
  return convertToBlocksTree(o);
@@ -431,9 +317,9 @@ function moveNode(o, r, n, a) {
431
317
  const l = findNodeById(o, r), i = findNodeById(o, n);
432
318
  if (!l || !i) return !1;
433
319
  i.children || (i.model.children = []);
434
- let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((f) => f.model._id === r);
435
- l.drop(), c = Math.max(c, 0);
436
- const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === n && c <= a ? a - 1 : a;
320
+ let d = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((f) => f.model._id === r);
321
+ l.drop(), d = Math.max(d, 0);
322
+ const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === n && d <= a ? a - 1 : a;
437
323
  try {
438
324
  i.addChildAtIndex(l, p);
439
325
  } catch (f) {
@@ -447,17 +333,17 @@ function handleOldParentTextBlock(o, r) {
447
333
  if (!a) return o;
448
334
  const l = o.filter((i) => i._parent === n);
449
335
  if (l.length === 2) {
450
- const i = l.find((c) => c._id !== r._id);
336
+ const i = l.find((d) => d._id !== r._id);
451
337
  if (i && i._type === "Text" && "content" in a)
452
- return o.map((d) => {
453
- if (d._id === n) {
454
- const p = { ...d, content: i.content };
338
+ return o.map((c) => {
339
+ if (c._id === n) {
340
+ const p = { ...c, content: i.content };
455
341
  return Object.keys(i).forEach((u) => {
456
342
  u.startsWith("content-") && (p[u] = i[u]);
457
343
  }), p;
458
344
  }
459
- return d;
460
- }).filter((d) => d._id !== i._id);
345
+ return c;
346
+ }).filter((c) => c._id !== i._id);
461
347
  }
462
348
  return o;
463
349
  }
@@ -466,16 +352,16 @@ function handleNewParentTextBlock(o, r, n) {
466
352
  const a = o.find((l) => l._id === n);
467
353
  if (!a) return o;
468
354
  if (a.content !== void 0 && a.content !== "" && !o.some((i) => i._parent === n && i._id !== r._id)) {
469
- const c = {
355
+ const d = {
470
356
  _id: generateUUID(),
471
357
  _parent: n,
472
358
  _type: "Text",
473
359
  content: a.content
474
360
  };
475
361
  Object.keys(a).forEach((u) => {
476
- u.startsWith("content-") && (c[u] = a[u]);
362
+ u.startsWith("content-") && (d[u] = a[u]);
477
363
  });
478
- const d = o.map((u) => {
364
+ const c = o.map((u) => {
479
365
  if (u._id === n) {
480
366
  const g = { ...u, content: "" };
481
367
  return Object.keys(g).forEach((f) => {
@@ -483,8 +369,8 @@ function handleNewParentTextBlock(o, r, n) {
483
369
  }), g;
484
370
  }
485
371
  return u;
486
- }), p = d.findIndex((u) => u._id === r._id);
487
- return p !== -1 ? [...d.slice(0, p), c, ...d.slice(p)] : [c, ...d];
372
+ }), p = c.findIndex((u) => u._id === r._id);
373
+ return p !== -1 ? [...c.slice(0, p), d, ...c.slice(p)] : [d, ...c];
488
374
  }
489
375
  return o;
490
376
  }
@@ -493,11 +379,11 @@ function moveBlocksWithChildren(o, r, n, a) {
493
379
  const l = o.find((u) => u._id === r);
494
380
  if (!l) return o;
495
381
  let i = handleOldParentTextBlock(o, l);
496
- const c = n || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
497
- if (moveNode(p, r, c, a)) {
382
+ const d = n || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
383
+ if (moveNode(p, r, d, a)) {
498
384
  let u = flattenTree(p);
499
385
  const g = u.find((f) => f._id === r);
500
- return g && (g._parent = c === "root" ? null : c), u.shift(), n && (u = handleNewParentTextBlock(u, l, n)), u;
386
+ return g && (g._parent = d === "root" ? null : d), u.shift(), n && (u = handleNewParentTextBlock(u, l, n)), u;
501
387
  }
502
388
  return i;
503
389
  }
@@ -508,9 +394,9 @@ const useBlocksStoreManager = () => {
508
394
  o(a), r({ type: "blocks-updated", blocks: a });
509
395
  },
510
396
  addBlocks: (a, l, i) => {
511
- o((c) => {
512
- const d = insertBlocksAtPosition(c, a, l, i);
513
- return r({ type: "blocks-updated", blocks: d }), d;
397
+ o((d) => {
398
+ const c = insertBlocksAtPosition(d, a, l, i);
399
+ return r({ type: "blocks-updated", blocks: c }), c;
514
400
  });
515
401
  },
516
402
  removeBlocks: (a) => {
@@ -520,14 +406,14 @@ const useBlocksStoreManager = () => {
520
406
  });
521
407
  },
522
408
  moveBlocks: (a, l, i) => {
523
- o((c) => {
524
- let d = [...c];
409
+ o((d) => {
410
+ let c = [...d];
525
411
  for (let p = 0; p < a.length; p++)
526
- d = moveBlocksWithChildren(d, a[p], l, i);
412
+ c = moveBlocksWithChildren(c, a[p], l, i);
527
413
  return each(a, (p) => {
528
- const u = find(d, (g) => g._id === p);
414
+ const u = find(c, (g) => g._id === p);
529
415
  u && n({ id: p, props: { _parent: u._parent || null } });
530
- }), r({ type: "blocks-updated", blocks: d }), d;
416
+ }), r({ type: "blocks-updated", blocks: c }), c;
531
417
  });
532
418
  },
533
419
  updateBlocksProps: (a) => {
@@ -632,19 +518,16 @@ const useBrandingOptions = () => {
632
518
  [o]
633
519
  ) };
634
520
  }, getDefaultThemeValues = (o = defaultThemeOptions) => {
635
- const r = {};
521
+ const r = defaultThemeValues;
636
522
  return o.fontFamily && (r.fontFamily = Object.entries(o.fontFamily).reduce(
637
523
  (n, [a, l]) => ({
638
524
  ...n,
639
525
  [a.replace("font-", "")]: l
640
526
  }),
641
- {}
642
- )), r.borderRadius = o.borderRadius, o.colors && (r.colors = o.colors.reduce(
643
- (n, a) => (Object.entries(a.items).forEach(([l, i]) => {
644
- n[l] = i;
645
- }), n),
646
- {}
647
- )), r;
527
+ r.fontFamily
528
+ )), r.borderRadius = o.borderRadius, o.colors && (r.colors = o.colors.reduce((n, a) => (Object.entries(a.items).forEach(([l, i]) => {
529
+ n[l] = i;
530
+ }), n), r.colors)), r;
648
531
  }, chaiThemeValuesAtom = atom({}), useTheme = () => {
649
532
  const o = useThemeOptions(), r = useMemo(() => getDefaultThemeValues(o), [o]), n = useBuilderProp("theme", {}), [a, l] = useAtom$1(chaiThemeValuesAtom);
650
533
  return [useMemo(
@@ -658,10 +541,10 @@ const useBrandingOptions = () => {
658
541
  builderSaveStateAtom.debugLabel = "builderSaveStateAtom";
659
542
  const useSavePage = () => {
660
543
  const [o, r] = useAtom$1(builderSaveStateAtom), n = useBuilderProp("onSave", async (p) => {
661
- }), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions();
544
+ }), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: d } = usePermissions();
662
545
  return { savePage: useThrottledCallback(
663
546
  async (p = !1) => {
664
- if (!c("save_page"))
547
+ if (!d("save_page"))
665
548
  return;
666
549
  r("SAVING"), a("SAVING");
667
550
  const u = l();
@@ -699,12 +582,12 @@ const useUndoManager = () => {
699
582
  addBlocks: a,
700
583
  removeBlocks: l,
701
584
  moveBlocks: i,
702
- updateBlocksProps: c
585
+ updateBlocksProps: d
703
586
  } = useBlocksStoreManager();
704
587
  return {
705
588
  moveBlocks: (x, k, b) => {
706
589
  const S = map(x, (A) => {
707
- const C = r.find((L) => L._id === A)._parent || null, _ = r.filter((L) => C ? L._parent === C : !L._parent).map((L) => L._id).indexOf(A);
590
+ const C = r.find((I) => I._id === A)._parent || null, _ = r.filter((I) => C ? I._parent === C : !I._parent).map((I) => I._id).indexOf(A);
708
591
  return { _id: A, oldParent: C, oldPosition: _ };
709
592
  }), w = S.find(({ _id: A }) => A === x[0]);
710
593
  w && w.oldParent === k && w.oldPosition === b || (i(x, k, b), o({
@@ -739,13 +622,13 @@ const useUndoManager = () => {
739
622
  return each(w, (B) => C[B] = E[B]), C;
740
623
  });
741
624
  }
742
- c(map(x, (w) => ({ _id: w, ...k }))), o({
743
- undo: () => c(S),
744
- redo: () => c(map(x, (w) => ({ _id: w, ...k })))
625
+ d(map(x, (w) => ({ _id: w, ...k }))), o({
626
+ undo: () => d(S),
627
+ redo: () => d(map(x, (w) => ({ _id: w, ...k })))
745
628
  });
746
629
  },
747
630
  updateBlocksRuntime: (x, k) => {
748
- c(map(x, (b) => ({ _id: b, ...k })));
631
+ d(map(x, (b) => ({ _id: b, ...k })));
749
632
  },
750
633
  setNewBlocks: (x) => {
751
634
  n(x), o({
@@ -758,36 +641,36 @@ const useUndoManager = () => {
758
641
  k = map(x, (b) => {
759
642
  const S = keys(b), w = r.find((E) => E._id === b._id), A = {};
760
643
  return each(S, (E) => A[E] = w[E]), A;
761
- }), c(x), o({
762
- undo: () => c(k),
763
- redo: () => c(x)
644
+ }), d(x), o({
645
+ undo: () => d(k),
646
+ redo: () => d(x)
764
647
  });
765
648
  }
766
649
  };
767
650
  }, libraryBlocksAtom = atom(
768
651
  {}
769
652
  ), useLibraryBlocks = (o) => {
770
- const [r, n] = useAtom$1(libraryBlocksAtom), a = useBuilderProp("getUILibraryBlocks", noop), l = get(r, `${o == null ? void 0 : o.id}.blocks`, null), i = get(r, `${o == null ? void 0 : o.id}.loading`, "idle"), c = useRef("idle");
653
+ const [r, n] = useAtom$1(libraryBlocksAtom), a = useBuilderProp("getUILibraryBlocks", noop), l = get(r, `${o == null ? void 0 : o.id}.blocks`, null), i = get(r, `${o == null ? void 0 : o.id}.loading`, "idle"), d = useRef("idle");
771
654
  useEffect(() => {
772
655
  (async () => {
773
- if (!(i === "complete" || c.current === "loading")) {
774
- c.current = "loading", n((p) => ({ ...p, [o == null ? void 0 : o.id]: { loading: "loading", blocks: [] } }));
656
+ if (!(i === "complete" || d.current === "loading")) {
657
+ d.current = "loading", n((p) => ({ ...p, [o == null ? void 0 : o.id]: { loading: "loading", blocks: [] } }));
775
658
  try {
776
659
  const p = await a(o);
777
- c.current = "idle", n((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: p || [] } }));
660
+ d.current = "idle", n((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: p || [] } }));
778
661
  } catch {
779
- c.current = "idle", n((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: [] } }));
662
+ d.current = "idle", n((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: [] } }));
780
663
  }
781
664
  }
782
665
  })();
783
- }, [o, l, i, c, n, a]);
784
- const d = useCallback(
666
+ }, [o, l, i, d, n, a]);
667
+ const c = useCallback(
785
668
  (p) => {
786
669
  n((u) => ({ ...u, [p]: { loading: "idle", blocks: [] } }));
787
670
  },
788
671
  [n]
789
672
  );
790
- return { data: l || [], isLoading: i === "loading", resetLibrary: d };
673
+ return { data: l || [], isLoading: i === "loading", resetLibrary: c };
791
674
  }, canAcceptChildBlock = (o, r) => {
792
675
  if (!o) return !0;
793
676
  const n = getRegisteredChaiBlock(o);
@@ -819,7 +702,7 @@ import.meta.vitest && describe("canDropBlock Function", () => {
819
702
  });
820
703
  const useAddBlock = () => {
821
704
  const [o] = useBlocksStore(), [, r] = useSelectedBlockIds(), { addBlocks: n } = useBlocksStoreUndoableActions(), a = useCallback(
822
- (i, c, d) => {
705
+ (i, d, c) => {
823
706
  var m;
824
707
  for (let h = 0; h < i.length; h++) {
825
708
  const { _id: x } = i[h];
@@ -830,15 +713,15 @@ const useAddBlock = () => {
830
713
  }
831
714
  const p = first(i);
832
715
  let u, g;
833
- return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), n(i, g, d), r([(m = first(i)) == null ? void 0 : m._id]), first(i);
716
+ return d && (u = find(o, { _id: d }), i[0]._parent = d, g = d), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), n(i, g, c), r([(m = first(i)) == null ? void 0 : m._id]), first(i);
834
717
  },
835
718
  [n, o, r]
836
719
  );
837
720
  return { addCoreBlock: useCallback(
838
- (i, c, d) => {
721
+ (i, d, c) => {
839
722
  if (has(i, "blocks")) {
840
723
  const k = i.blocks;
841
- return a(k, c, d);
724
+ return a(k, d, c);
842
725
  }
843
726
  const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
844
727
  _type: i.type,
@@ -848,7 +731,7 @@ const useAddBlock = () => {
848
731
  ...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
849
732
  };
850
733
  let f, m;
851
- return c && (f = find(o, { _id: c }), g._parent = c, m = c), !canAcceptChildBlock(f == null ? void 0 : f._type, g._type) && f && (g._parent = f._parent, m = f._parent), n([g], m, d), r([g._id]), g;
734
+ return d && (f = find(o, { _id: d }), g._parent = d, m = d), !canAcceptChildBlock(f == null ? void 0 : f._type, g._type) && f && (g._parent = f._parent, m = f._parent), n([g], m, c), r([g._id]), g;
852
735
  },
853
736
  [n, a, o, r]
854
737
  ), addPredefinedBlock: a };
@@ -1889,15 +1772,15 @@ const useAddBlock = () => {
1889
1772
  const o = useThemeOptions(), r = useMemo(() => {
1890
1773
  if (o.colors) {
1891
1774
  const l = flattenDeep(map(o.colors, ({ items: i }) => keys(i)));
1892
- each(CLASSES_LIST, (i, c) => {
1893
- set(CLASSES_LIST, `${c}.regExp`, i.regExp.replace("__THEME_COLORS_REGEXP__", l.join("|")));
1775
+ each(CLASSES_LIST, (i, d) => {
1776
+ set(CLASSES_LIST, `${d}.regExp`, i.regExp.replace("__THEME_COLORS_REGEXP__", l.join("|")));
1894
1777
  });
1895
1778
  }
1896
1779
  return CLASSES_LIST;
1897
1780
  }, [o]), n = useCallback(
1898
1781
  (l, i) => {
1899
- const c = get(r, `${l}.regExp`, "");
1900
- return i.match(new RegExp(c));
1782
+ const d = get(r, `${l}.regExp`, "");
1783
+ return i.match(new RegExp(d));
1901
1784
  },
1902
1785
  [r]
1903
1786
  ), a = useCallback(
@@ -1963,9 +1846,9 @@ function removeDuplicateClasses(o) {
1963
1846
  let a = o;
1964
1847
  if (n.length === 1) return n[0].fullCls;
1965
1848
  for (const l of n) {
1966
- const i = l.property, c = r.indexOf(l.mq);
1967
- for (let d = c + 1; d < r.length; d++) {
1968
- const p = r[d], u = n.find((g) => g.property === i && g.mq === p);
1849
+ const i = l.property, d = r.indexOf(l.mq);
1850
+ for (let c = d + 1; c < r.length; c++) {
1851
+ const p = r[c], u = n.find((g) => g.property === i && g.mq === p);
1969
1852
  if (u && u.cls === l.cls)
1970
1853
  a = a.replace(u.fullCls, "");
1971
1854
  else if (u && u.cls !== l.cls)
@@ -1982,15 +1865,15 @@ selectedStylingBlocksAtom.debugLabel = "selectedStylingBlocksAtom";
1982
1865
  const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), addClassesToBlocksAtom = atom(null, (o, r, { blockIds: n, newClasses: a }) => {
1983
1866
  const l = filter(
1984
1867
  o(pageBlocksAtomsAtom),
1985
- (c) => (
1868
+ (d) => (
1986
1869
  // @ts-ignore
1987
- n.includes(o(c)._id)
1870
+ n.includes(o(d)._id)
1988
1871
  )
1989
1872
  ), i = first(o(selectedStylingBlocksAtom));
1990
- return map(l, (c) => {
1991
- const d = o(c), p = get(d, i.prop, `${STYLES_KEY},`), { classes: u } = getSplitChaiClasses(p);
1873
+ return map(l, (d) => {
1874
+ const c = o(d), p = get(c, i.prop, `${STYLES_KEY},`), { classes: u } = getSplitChaiClasses(p);
1992
1875
  return {
1993
- ids: [d._id],
1876
+ ids: [c._id],
1994
1877
  props: {
1995
1878
  [i.prop]: `${STYLES_KEY},${orderClassesByBreakpoint(
1996
1879
  removeDuplicateClasses(twMerge(u, a))
@@ -2002,12 +1885,12 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), add
2002
1885
  const o = useSetAtom$1(addClassesToBlocksAtom), { updateBlocks: r, updateBlocksRuntime: n } = useBlocksStoreUndoableActions();
2003
1886
  return useCallback(
2004
1887
  (a, l, i = !1) => {
2005
- const c = o({ blockIds: a, newClasses: l });
1888
+ const d = o({ blockIds: a, newClasses: l });
2006
1889
  if (!i) {
2007
- n(a, c[0].props);
1890
+ n(a, d[0].props);
2008
1891
  return;
2009
1892
  }
2010
- r(a, c[0].props);
1893
+ r(a, d[0].props);
2011
1894
  },
2012
1895
  [o, r, n]
2013
1896
  );
@@ -2217,16 +2100,16 @@ const useLanguages = () => {
2217
2100
  const l = { ...o };
2218
2101
  return forEach(keys(o), (i) => {
2219
2102
  if (includes(get(a, "i18nProps", []), i) && !isEmpty(r)) {
2220
- const c = `${i}-${r}`;
2221
- set(l, c, o[i]), unset(l, i);
2103
+ const d = `${i}-${r}`;
2104
+ set(l, d, o[i]), unset(l, i);
2222
2105
  }
2223
2106
  }), l;
2224
2107
  }, useUpdateBlocksProps = () => {
2225
2108
  const { updateBlocks: o } = useBlocksStoreUndoableActions(), { selectedLang: r } = useLanguages(), n = useSelectedBlock();
2226
2109
  return useCallback(
2227
2110
  (a, l, i) => {
2228
- const c = updatePropsForLanguage(l, r, n);
2229
- o(a, c, i);
2111
+ const d = updatePropsForLanguage(l, r, n);
2112
+ o(a, d, i);
2230
2113
  },
2231
2114
  [r, n, o]
2232
2115
  );
@@ -2244,13 +2127,13 @@ const useLanguages = () => {
2244
2127
  async (r, n, a = 30) => {
2245
2128
  const l = keys(omit(n, ["_id"]));
2246
2129
  for (const i of l) {
2247
- const c = n[i];
2248
- if (isString(c)) {
2249
- const d = chunk(c.split(""), 12);
2130
+ const d = n[i];
2131
+ if (isString(d)) {
2132
+ const c = chunk(d.split(""), 12);
2250
2133
  let p = "";
2251
2134
  o([r], { [i]: "" });
2252
- for (let u = 0; u < d.length; u++)
2253
- p += d[u].join(""), o([r], { [i]: p }), await new Promise((g) => setTimeout(g, a));
2135
+ for (let u = 0; u < c.length; u++)
2136
+ p += c[u].join(""), o([r], { [i]: p }), await new Promise((g) => setTimeout(g, a));
2254
2137
  }
2255
2138
  }
2256
2139
  },
@@ -2288,13 +2171,13 @@ const getBlockWithChildren = (o, r) => {
2288
2171
  return n = flattenDeep([...n, ...getChildBlocks(r, o, n)]), n;
2289
2172
  }, pickOnlyAIProps = (o, r) => compact(
2290
2173
  o.map((n) => {
2291
- const a = ["_id", "_type", "_parent"], l = pick(n, a), i = getRegisteredChaiBlock(n._type), c = {}, d = get(i, "aiProps", []);
2174
+ const a = ["_id", "_type", "_parent"], l = pick(n, a), i = getRegisteredChaiBlock(n._type), d = {}, c = get(i, "aiProps", []);
2292
2175
  for (const p in n)
2293
- a.includes(p) || d.includes(p) && (c[p] = get(n, `${p}-${r}`, n[p]));
2294
- return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
2176
+ a.includes(p) || c.includes(p) && (d[p] = get(n, `${p}-${r}`, n[p]));
2177
+ return isEmpty(d) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...d });
2295
2178
  })
2296
2179
  ), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2297
- const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, f = (m, h) => {
2180
+ const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), d = useUpdateMultipleBlocksProps(), [c] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, f = (m, h) => {
2298
2181
  const x = cloneDeep(h.find((k) => k._id === m));
2299
2182
  for (const k in x) {
2300
2183
  const b = x[k];
@@ -2312,7 +2195,7 @@ const getBlockWithChildren = (o, r) => {
2312
2195
  if (l) {
2313
2196
  r(!0), a(null);
2314
2197
  try {
2315
- const b = p === u ? "" : p, S = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, d)), p) : [f(h, d)], w = await l(m, addLangToPrompt(x, g, m), S, b), { blocks: A, error: E } = w;
2198
+ const b = p === u ? "" : p, S = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, c)), p) : [f(h, c)], w = await l(m, addLangToPrompt(x, g, m), S, b), { blocks: A, error: E } = w;
2316
2199
  if (E) {
2317
2200
  a(E);
2318
2201
  return;
@@ -2323,7 +2206,7 @@ const getBlockWithChildren = (o, r) => {
2323
2206
  _ !== "_id" && (B[_] = `${STYLES_KEY},${B[_]}`);
2324
2207
  return B;
2325
2208
  });
2326
- c(C);
2209
+ d(C);
2327
2210
  } else
2328
2211
  i(A);
2329
2212
  k && k(w);
@@ -2339,9 +2222,9 @@ const getBlockWithChildren = (o, r) => {
2339
2222
  r,
2340
2223
  p,
2341
2224
  u,
2342
- d,
2343
- g,
2344
2225
  c,
2226
+ g,
2227
+ d,
2345
2228
  i
2346
2229
  ]
2347
2230
  ),
@@ -2356,7 +2239,43 @@ const getBlockWithChildren = (o, r) => {
2356
2239
  },
2357
2240
  [o]
2358
2241
  );
2359
- };
2242
+ }, readOnlyModeAtom = atom(!1);
2243
+ readOnlyModeAtom.debugLabel = "readOnlyModeAtom";
2244
+ const networkModeAtom = atom("online");
2245
+ networkModeAtom.debugLabel = "networkModeAtom";
2246
+ atom("");
2247
+ const editLayerNameAtom = atom(!1);
2248
+ editLayerNameAtom.debugLabel = "editLayerNameAtom";
2249
+ const activeLanguageAtom = atom("");
2250
+ activeLanguageAtom.debugLabel = "activeLanguageAtom";
2251
+ const primaryLanguageAtom = atom("");
2252
+ primaryLanguageAtom.debugLabel = "primaryLanguageAtom";
2253
+ const canvasIframeAtom = atom(null);
2254
+ canvasIframeAtom.debugLabel = "canvasIframeAtom";
2255
+ const activePanelAtom = atom("outline");
2256
+ activePanelAtom.debugLabel = "activePanelAtom";
2257
+ const showPredefinedBlockCategoryAtom = atom("");
2258
+ showPredefinedBlockCategoryAtom.debugLabel = "showPredefinedBlockCategoryAtom";
2259
+ const inlineEditingActiveAtom = atom("");
2260
+ inlineEditingActiveAtom.debugLabel = "inlineEditingActiveAtom";
2261
+ const draggingFlagAtom = atom(!1);
2262
+ draggingFlagAtom.debugLabel = "draggingFlagAtom";
2263
+ const treeRefAtom = atom(null);
2264
+ treeRefAtom.debugLabel = "treeRefAtom";
2265
+ const canvasSettingsAtom = atom({});
2266
+ canvasSettingsAtom.debugLabel = "canvasSettingsAtom";
2267
+ const aiAssistantActiveAtom = atom(!1);
2268
+ aiAssistantActiveAtom.debugLabel = "aiAssistantActiveAtom";
2269
+ const codeEditorOpenAtom = atom(!1);
2270
+ codeEditorOpenAtom.debugLabel = "codeEditorOpenAtom";
2271
+ const codeEditorHeightAtom = atomWithStorage("codeEditorHeight", 500);
2272
+ codeEditorHeightAtom.debugLabel = "codeEditorHeightAtom";
2273
+ const xShowBlocksAtom = atom([]);
2274
+ xShowBlocksAtom.debugLabel = "xShowBlocksAtom";
2275
+ const selectedLibraryAtom = atomWithStorage("_selectedLibrary", null);
2276
+ selectedLibraryAtom.debugLabel = "selectedLibraryAtom";
2277
+ const dataBindingActiveAtom = atom(!0);
2278
+ dataBindingActiveAtom.debugLabel = "dataBindingActiveAtom";
2360
2279
  let lastHighlighted = null;
2361
2280
  const useBlockHighlight = () => {
2362
2281
  const [o] = useAtom$1(canvasIframeAtom), r = useMemo(() => {
@@ -2382,18 +2301,18 @@ const useBlockHighlight = () => {
2382
2301
  const [o, r] = useAtom$1(partialBlocksStoreAtom), n = useCallback((l) => get(o, l, []), [o]), a = useCallback(() => r({}), [r]);
2383
2302
  return { getPartailBlocks: n, reset: a };
2384
2303
  }, useWatchPartailBlocks = () => {
2385
- const [o] = useBlocksStore(), [r, n] = useAtom$1(partialBlocksStoreAtom), [a, l] = useAtom$1(partialBlocksLoadingStateAtom), i = useBuilderProp("getPartialBlockBlocks", async (d) => []), c = useMemo(() => o.filter((d) => d._type === "PartialBlock" || d._type === "GlobalBlock").map((d) => get(d, "partialBlockId", get(d, "globalBlock", ""))), [o]);
2304
+ const [o] = useBlocksStore(), [r, n] = useAtom$1(partialBlocksStoreAtom), [a, l] = useAtom$1(partialBlocksLoadingStateAtom), i = useBuilderProp("getPartialBlockBlocks", async (c) => []), d = useMemo(() => o.filter((c) => c._type === "PartialBlock" || c._type === "GlobalBlock").map((c) => get(c, "partialBlockId", get(c, "globalBlock", ""))), [o]);
2386
2305
  useEffect(() => {
2387
- forEach(c, (d) => {
2388
- has(r, d) || get(a, `${d}.loading`, !1) || (l((p) => ({ ...p, [d]: { loading: !0, error: null } })), i(d).then((p) => {
2389
- n((u) => ({ ...u, [d]: p })), l((u) => ({
2306
+ forEach(d, (c) => {
2307
+ has(r, c) || get(a, `${c}.loading`, !1) || (l((p) => ({ ...p, [c]: { loading: !0, error: null } })), i(c).then((p) => {
2308
+ n((u) => ({ ...u, [c]: p })), l((u) => ({
2390
2309
  ...u,
2391
- [d]: { loading: !1, error: null }
2310
+ [c]: { loading: !1, error: null }
2392
2311
  }));
2393
2312
  }).catch((p) => {
2394
2313
  l((u) => ({
2395
2314
  ...u,
2396
- [d]: { loading: !1, error: p.message }
2315
+ [c]: { loading: !1, error: p.message }
2397
2316
  }));
2398
2317
  }));
2399
2318
  });
@@ -2403,25 +2322,25 @@ const useBlockHighlight = () => {
2403
2322
  a,
2404
2323
  n,
2405
2324
  l,
2406
- c
2325
+ d
2407
2326
  ]);
2408
2327
  }, partialBlocksListAtom = atom({}), usePartialBlocksList = () => {
2409
- const [o, r] = useState(!1), [n, a] = useState(null), [l, i] = useAtom$1(partialBlocksListAtom), c = useBuilderProp("getPartialBlocks", async () => []), d = useCallback(async () => {
2328
+ const [o, r] = useState(!1), [n, a] = useState(null), [l, i] = useAtom$1(partialBlocksListAtom), d = useBuilderProp("getPartialBlocks", async () => []), c = useCallback(async () => {
2410
2329
  r(!0), a(null);
2411
2330
  try {
2412
- const p = await c();
2331
+ const p = await d();
2413
2332
  i(p), r(!1);
2414
2333
  } catch (p) {
2415
2334
  a(p instanceof Error ? p.message : "Failed to fetch partial blocks"), r(!1);
2416
2335
  }
2417
- }, [c, i]);
2336
+ }, [d, i]);
2418
2337
  return useEffect(() => {
2419
- d();
2420
- }, []), { data: l, isLoading: o, refetch: d, error: n };
2338
+ c();
2339
+ }, []), { data: l, isLoading: o, refetch: c, error: n };
2421
2340
  }, useBuilderReset = () => {
2422
- const { clear: o } = useUndoManager(), [, r] = useSelectedBlockIds(), { clearHighlight: n } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom$1(aiAssistantActiveAtom), { reset: i } = usePartailBlocksStore(), { setSaveState: c } = useSavePage();
2341
+ const { clear: o } = useUndoManager(), [, r] = useSelectedBlockIds(), { clearHighlight: n } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom$1(aiAssistantActiveAtom), { reset: i } = usePartailBlocksStore(), { setSaveState: d } = useSavePage();
2423
2342
  return () => {
2424
- r([]), a([]), n(), o(), l(!1), i(), c("SAVED");
2343
+ r([]), a([]), n(), o(), l(!1), i(), d("SAVED");
2425
2344
  };
2426
2345
  }, canvasZoomAtom = atomWithStorage("canvasZoom", 100), useCanvasZoom = () => useAtom$1(canvasZoomAtom), codeEditorAtom = atom(null), useCodeEditor = () => useAtom$1(codeEditorAtom), cutBlockIdsAtom = atom([]), useCutBlockIds = () => {
2427
2346
  const [o, r] = useAtom$1(cutBlockIdsAtom), n = useSetAtom$1(copiedBlockIdsAtom), a = useCallback(
@@ -2436,12 +2355,12 @@ const useBlockHighlight = () => {
2436
2355
  async (i) => {
2437
2356
  try {
2438
2357
  n(i), a([]);
2439
- const c = {
2440
- _chai_copied_blocks: i.flatMap((d) => getDuplicatedBlocks(o, d, null))
2358
+ const d = {
2359
+ _chai_copied_blocks: i.flatMap((c) => getDuplicatedBlocks(o, c, null))
2441
2360
  };
2442
- await navigator.clipboard.writeText(JSON.stringify(c));
2443
- } catch (c) {
2444
- console.error("Failed to copy blocks to clipboard:", c);
2361
+ await navigator.clipboard.writeText(JSON.stringify(d));
2362
+ } catch (d) {
2363
+ console.error("Failed to copy blocks to clipboard:", d);
2445
2364
  }
2446
2365
  },
2447
2366
  [n, a, o]
@@ -2466,13 +2385,13 @@ const useBlockHighlight = () => {
2466
2385
  return useCallback(
2467
2386
  (a, l = null) => {
2468
2387
  const i = [];
2469
- each(a, (c) => {
2470
- const d = o.find((m) => m._id === c);
2471
- l ? l === "root" && (l = null) : l = d._parent;
2388
+ each(a, (d) => {
2389
+ const c = o.find((m) => m._id === d);
2390
+ l ? l === "root" && (l = null) : l = c._parent;
2472
2391
  const g = filter(
2473
2392
  o,
2474
2393
  (m) => isString(l) ? m._parent === l : !m._parent
2475
- ).indexOf(d) + 1, f = getDuplicatedBlocks(o, c, l);
2394
+ ).indexOf(c) + 1, f = getDuplicatedBlocks(o, d, l);
2476
2395
  n(f, l, g), i.push(get(f, "0._id", ""));
2477
2396
  }), r(i);
2478
2397
  },
@@ -2490,9 +2409,9 @@ const useBlockHighlight = () => {
2490
2409
  const [o] = useBlocksStore();
2491
2410
  return (r, n) => {
2492
2411
  var i;
2493
- const a = ((i = find(o, { _id: n })) == null ? void 0 : i._type) || null, l = first(r.map((c) => {
2494
- var d;
2495
- return (d = find(o, { _id: c })) == null ? void 0 : d._type;
2412
+ const a = ((i = find(o, { _id: n })) == null ? void 0 : i._type) || null, l = first(r.map((d) => {
2413
+ var c;
2414
+ return (c = find(o, { _id: d })) == null ? void 0 : c._type;
2496
2415
  }));
2497
2416
  return canAcceptChildBlock(a, l);
2498
2417
  };
@@ -2502,10 +2421,10 @@ const useBlockHighlight = () => {
2502
2421
  (n, a) => {
2503
2422
  const l = Array.isArray(a) ? a[0] : a;
2504
2423
  if (a === "root") {
2505
- const i = o == null ? void 0 : o.filter((c) => !c._parent);
2424
+ const i = o == null ? void 0 : o.filter((d) => !d._parent);
2506
2425
  r(n, null, (i == null ? void 0 : i.length) || 0);
2507
2426
  } else {
2508
- const i = o == null ? void 0 : o.filter((c) => c._parent === l);
2427
+ const i = o == null ? void 0 : o.filter((d) => d._parent === l);
2509
2428
  r(n, l, (i == null ? void 0 : i.length) || 0);
2510
2429
  }
2511
2430
  },
@@ -2515,13 +2434,13 @@ const useBlockHighlight = () => {
2515
2434
  const [o, r] = useCutBlockIds(), n = useMoveCutBlocks(), a = useCanPaste(), { addPredefinedBlock: l } = useAddBlock();
2516
2435
  return {
2517
2436
  canPaste: useCallback(
2518
- async (c) => {
2437
+ async (d) => {
2519
2438
  if (o.length > 0)
2520
- return a(o, c);
2439
+ return a(o, d);
2521
2440
  try {
2522
- const d = await navigator.clipboard.readText();
2523
- if (d) {
2524
- const p = JSON.parse(d);
2441
+ const c = await navigator.clipboard.readText();
2442
+ if (c) {
2443
+ const p = JSON.parse(c);
2525
2444
  return has(p, "_chai_copied_blocks");
2526
2445
  }
2527
2446
  } catch {
@@ -2532,17 +2451,17 @@ const useBlockHighlight = () => {
2532
2451
  [a, o]
2533
2452
  ),
2534
2453
  pasteBlocks: useCallback(
2535
- async (c) => {
2536
- const d = Array.isArray(c) ? c[0] : c;
2454
+ async (d) => {
2455
+ const c = Array.isArray(d) ? d[0] : d;
2537
2456
  if (!isEmpty(o)) {
2538
- n(o, c), r([]), await navigator.clipboard.writeText("");
2457
+ n(o, d), r([]), await navigator.clipboard.writeText("");
2539
2458
  return;
2540
2459
  }
2541
2460
  try {
2542
2461
  const p = await navigator.clipboard.readText();
2543
2462
  if (p) {
2544
2463
  const u = JSON.parse(p);
2545
- has(u, "_chai_copied_blocks") ? l(u._chai_copied_blocks, d === "root" ? null : d) : toast.error("Nothing to paste");
2464
+ has(u, "_chai_copied_blocks") ? l(u._chai_copied_blocks, c === "root" ? null : c) : toast.error("Nothing to paste");
2546
2465
  } else
2547
2466
  toast.error("Nothing to paste");
2548
2467
  } catch {
@@ -2558,14 +2477,14 @@ const useBlockHighlight = () => {
2558
2477
  }, removeClassFromBlocksAtom = atom(null, (o, r, { blockIds: n, fullClasses: a }) => {
2559
2478
  const l = first(o(selectedStylingBlocksAtom)), i = filter(
2560
2479
  o(pageBlocksAtomsAtom),
2561
- (c) => (
2480
+ (d) => (
2562
2481
  // @ts-ignore
2563
- n.includes(o(c)._id)
2482
+ n.includes(o(d)._id)
2564
2483
  )
2565
2484
  );
2566
- return map(i, (c) => {
2567
- const d = o(c), p = a;
2568
- let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
2485
+ return map(i, (d) => {
2486
+ const c = o(d), p = a;
2487
+ let { classes: u, baseClasses: g } = getSplitChaiClasses(get(c, l.prop, `${STYLES_KEY},`));
2569
2488
  return each(p, (f) => {
2570
2489
  const m = f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
2571
2490
  u = u.replace(h, " ").replace(/\s+/g, " ").trim();
@@ -2575,7 +2494,7 @@ const useBlockHighlight = () => {
2575
2494
  const m = f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
2576
2495
  g = g.replace(h, " ").replace(/\s+/g, " ").trim();
2577
2496
  }), {
2578
- ids: [d._id],
2497
+ ids: [c._id],
2579
2498
  props: {
2580
2499
  [l.prop]: `${STYLES_KEY}${g},${u}`
2581
2500
  }
@@ -2585,8 +2504,8 @@ const useBlockHighlight = () => {
2585
2504
  const { updateBlocks: o, updateBlocksRuntime: r } = useBlocksStoreUndoableActions(), n = useSetAtom$1(removeClassFromBlocksAtom);
2586
2505
  return useCallback(
2587
2506
  (a, l, i = !1) => {
2588
- const c = n({ blockIds: a, fullClasses: l });
2589
- i ? o(a, c[0].props) : r(a, c[0].props);
2507
+ const d = n({ blockIds: a, fullClasses: l });
2508
+ i ? o(a, d[0].props) : r(a, d[0].props);
2590
2509
  },
2591
2510
  [n]
2592
2511
  );
@@ -2609,7 +2528,7 @@ const useBlockHighlight = () => {
2609
2528
  }), useSelectedBlockAllClasses = () => useAtomValue$1(selectedBlockAllClassesAtom), MQ = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4, "2xl": 5 }, selectedBlockCurrentClassesAtom = atom((o) => {
2610
2529
  const r = o(canvasBreakpointAtom), n = o(styleStateAtom), a = o(darkModeAtom), l = getQueries(r);
2611
2530
  let i = filter(o(selectedBlockAllClassesAtom), { mod: n });
2612
- return startsWith(n, "_") || (i = filter(i, (c) => l.includes(c.mq))), i = i.sort((c, d) => MQ[c.mq] - MQ[d.mq]), a || (i = filter(i, { dark: !1 })), i;
2531
+ return startsWith(n, "_") || (i = filter(i, (d) => l.includes(d.mq))), i = i.sort((d, c) => MQ[d.mq] - MQ[c.mq]), a || (i = filter(i, { dark: !1 })), i;
2613
2532
  }), getQueries = (o) => {
2614
2533
  let r = [];
2615
2534
  switch (o) {
@@ -2640,34 +2559,143 @@ const useBlockHighlight = () => {
2640
2559
  const [o, r] = useAtom$1(selectedBreakpointsAtom);
2641
2560
  return [o, r];
2642
2561
  }, useStylingState = () => useAtom$1(styleStateAtom), useUILibraryBlocks = () => ({ data: useBuilderProp("uiLibraries", []), isLoading: !1 }), wrapperBlockAtom = atom((o) => {
2643
- var c;
2562
+ var d;
2644
2563
  const r = o(presentBlocksAtom), n = o(selectedBlockIdsAtom), a = n.length === 1 ? n[0] : null;
2645
2564
  if (!a) return null;
2646
2565
  const l = find(r, { _id: a });
2647
2566
  if (!l) return null;
2648
2567
  let i = l._parent;
2649
2568
  for (; i; ) {
2650
- const d = find(r, { _id: i });
2651
- if (!d) return null;
2652
- if ((c = getRegisteredChaiBlock(d._type)) != null && c.wrapper)
2653
- return d;
2654
- i = d._parent;
2569
+ const c = find(r, { _id: i });
2570
+ if (!c) return null;
2571
+ if ((d = getRegisteredChaiBlock(c._type)) != null && d.wrapper)
2572
+ return c;
2573
+ i = c._parent;
2655
2574
  }
2656
2575
  return null;
2657
2576
  });
2658
2577
  wrapperBlockAtom.debugLabel = "wrapperBlockAtom";
2659
2578
  const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useSelectedLibrary = () => useAtom$1(selectedLibraryAtom), sidebarActivePanelAtom = atom("outline");
2660
2579
  sidebarActivePanelAtom.debugLabel = "sidebarActivePanelAtom";
2661
- const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom);
2580
+ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), 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: [
2581
+ /* @__PURE__ */ jsx("p", { className: "font-semibold", children: "Oops! Something went wrong." }),
2582
+ /* @__PURE__ */ jsx("p", { children: "Please try again." })
2583
+ ] }) }), ICON_CLASS = "h-3 w-3 stroke-[2]", TypeIcon = (o) => {
2584
+ const r = useRegisteredChaiBlocks(), n = get(r, [o == null ? void 0 : o.type, "icon"]);
2585
+ return n ? React__default.createElement(n, { className: ICON_CLASS }) : /* @__PURE__ */ jsx(BoxModelIcon, { className: ICON_CLASS });
2586
+ }, Breadcrumb = () => {
2587
+ const o = useSelectedBlockHierarchy(), [, r] = useSelectedBlockIds(), { highlightBlock: n } = useBlockHighlight();
2588
+ return /* @__PURE__ */ jsx("div", { className: "-mx-2 border-t border-border bg-background px-2 py-1 text-xs text-muted-foreground", children: /* @__PURE__ */ jsxs("ol", { className: "flex items-center whitespace-nowrap", children: [
2589
+ /* @__PURE__ */ jsxs("li", { className: "inline-flex items-center", children: [
2590
+ /* @__PURE__ */ jsx(Button, { onClick: () => r([]), variant: "ghost", className: "h-fit p-1 text-xs font-normal", children: "Body" }),
2591
+ /* @__PURE__ */ jsx(ChevronRight, { className: "rtl:rotate-180", size: 16 })
2592
+ ] }),
2593
+ reverse(o).map((a, l) => /* @__PURE__ */ jsxs("li", { className: "inline-flex items-center", children: [
2594
+ /* @__PURE__ */ jsxs(
2595
+ Button,
2596
+ {
2597
+ onMouseEnter: () => {
2598
+ n(a == null ? void 0 : a._id);
2599
+ },
2600
+ onClick: () => r([a == null ? void 0 : a._id]),
2601
+ variant: "ghost",
2602
+ className: "h-fit gap-x-1 p-1 text-xs font-normal",
2603
+ children: [
2604
+ /* @__PURE__ */ jsx(TypeIcon, { type: a == null ? void 0 : a._type }),
2605
+ a._name || a._type
2606
+ ]
2607
+ }
2608
+ ),
2609
+ l !== o.length - 1 && /* @__PURE__ */ jsx(ChevronRight, { className: "rtl:rotate-180", size: 16 })
2610
+ ] }, l))
2611
+ ] }) });
2612
+ };
2613
+ class Content extends Component {
2614
+ componentDidMount() {
2615
+ this.props.contentDidMount();
2616
+ }
2617
+ componentDidUpdate() {
2618
+ this.props.contentDidUpdate();
2619
+ }
2620
+ render() {
2621
+ return Children.only(this.props.children);
2622
+ }
2623
+ }
2624
+ let doc, win;
2625
+ typeof document < "u" && (doc = document);
2626
+ typeof window < "u" && (win = window);
2627
+ const FrameContext = React__default.createContext({ document: doc, window: win }), useFrame = () => React__default.useContext(FrameContext), { Provider: FrameContextProvider, Consumer: FrameContextConsumer } = FrameContext;
2628
+ class Frame extends Component {
2629
+ constructor(n, a) {
2630
+ super(n, a);
2631
+ U(this, "setRef", (n) => {
2632
+ this.nodeRef.current = n;
2633
+ const { forwardedRef: a } = this.props;
2634
+ typeof a == "function" ? a(n) : a && (a.current = n);
2635
+ });
2636
+ U(this, "handleLoad", () => {
2637
+ clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
2638
+ });
2639
+ // In certain situations on a cold cache DOMContentLoaded never gets called
2640
+ // fallback to an interval to check if that's the case
2641
+ U(this, "loadCheck", () => setInterval(() => {
2642
+ this.handleLoad();
2643
+ }, 500));
2644
+ this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
2645
+ }
2646
+ componentDidMount() {
2647
+ this._isMounted = !0, this.getDoc() && this.nodeRef.current.contentWindow.addEventListener("DOMContentLoaded", this.handleLoad);
2648
+ }
2649
+ componentWillUnmount() {
2650
+ this._isMounted = !1, this.nodeRef.current.removeEventListener("DOMContentLoaded", this.handleLoad);
2651
+ }
2652
+ getDoc() {
2653
+ return this.nodeRef.current ? this.nodeRef.current.contentDocument : null;
2654
+ }
2655
+ getMountTarget() {
2656
+ const n = this.getDoc();
2657
+ return this.props.mountTarget ? n.querySelector(this.props.mountTarget) : n.body.children[0];
2658
+ }
2659
+ renderFrameContents() {
2660
+ if (!this._isMounted)
2661
+ return null;
2662
+ const n = this.getDoc();
2663
+ if (!n)
2664
+ return null;
2665
+ const a = this.props.contentDidMount, l = this.props.contentDidUpdate, i = n.defaultView || n.parentView, d = /* @__PURE__ */ jsx(Content, { contentDidMount: a, contentDidUpdate: l, children: /* @__PURE__ */ jsx(FrameContextProvider, { value: { document: n, window: i }, children: /* @__PURE__ */ jsx("div", { className: "frame-content", children: this.props.children }) }) }), c = this.getMountTarget();
2666
+ return [ReactDOM.createPortal(this.props.head, this.getDoc().head), ReactDOM.createPortal(d, c)];
2667
+ }
2668
+ render() {
2669
+ const n = {
2670
+ ...this.props,
2671
+ srcDoc: this.props.initialContent,
2672
+ children: void 0
2673
+ // The iframe isn't ready so we drop children from props here. #12, #17
2674
+ };
2675
+ return delete n.head, delete n.initialContent, delete n.mountTarget, delete n.contentDidMount, delete n.contentDidUpdate, delete n.forwardedRef, /* @__PURE__ */ jsx("iframe", { ...n, ref: this.setRef, onLoad: this.handleLoad, children: this.state.iframeLoaded && this.renderFrameContents() });
2676
+ }
2677
+ }
2678
+ U(Frame, "defaultProps", {
2679
+ style: {},
2680
+ head: null,
2681
+ children: void 0,
2682
+ mountTarget: void 0,
2683
+ contentDidMount: () => {
2684
+ },
2685
+ contentDidUpdate: () => {
2686
+ },
2687
+ initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
2688
+ });
2689
+ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: r }));
2662
2690
  function getOrientation(o, r = null) {
2663
2691
  const n = window.getComputedStyle(o), a = r ? window.getComputedStyle(r) : null, l = n.display, i = a ? a.display : null;
2664
2692
  if (l === "flex" || l === "inline-flex") {
2665
- const c = n.flexDirection;
2666
- return c === "column" || c === "column-reverse" ? "vertical" : "horizontal";
2693
+ const d = n.flexDirection;
2694
+ return d === "column" || d === "column-reverse" ? "vertical" : "horizontal";
2667
2695
  } else if (l === "grid") {
2668
- const c = n.gridAutoFlow, d = n.gridTemplateColumns;
2669
- return c.includes("column") || d && d !== "none" && d !== "" && !d.includes("calc") && // Handle calc expressions
2670
- d.split(" ").length <= 1 ? "vertical" : "horizontal";
2696
+ const d = n.gridAutoFlow, c = n.gridTemplateColumns;
2697
+ return d.includes("column") || c && c !== "none" && c !== "" && !c.includes("calc") && // Handle calc expressions
2698
+ c.split(" ").length <= 1 ? "vertical" : "horizontal";
2671
2699
  } else if (i === "inline-block" || i === "inline")
2672
2700
  return "horizontal";
2673
2701
  return "vertical";
@@ -2690,11 +2718,11 @@ const CONTROLS = [
2690
2718
  return "VERTICAL";
2691
2719
  }
2692
2720
  }, isDisabledControl = (o, r, n) => !!(o && (n === "UP" || n === "LEFT") || r && (n === "DOWN" || n === "RIGHT")), useBlockController = (o, r) => {
2693
- const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(n, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, f = u + 1 === (d == null ? void 0 : d.length), m = getParentBlockOrientation(c, i, a), h = useCallback(
2721
+ const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), d = get(o, "_parent"), c = filter(n, (x) => d ? get(x, "_parent") === d : !get(x, "_parent")), p = (c == null ? void 0 : c.length) <= 1, u = findIndex(c, { _id: i }), g = u <= 0, f = u + 1 === (c == null ? void 0 : c.length), m = getParentBlockOrientation(d, i, a), h = useCallback(
2694
2722
  (x) => {
2695
- isDisabledControl(g, f, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), r());
2723
+ isDisabledControl(g, f, x) || p || (x === "UP" || x === "LEFT" ? l([i], d || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], d || null, u + 2), r());
2696
2724
  },
2697
- [g, f, p, u, i, c, r]
2725
+ [g, f, p, u, i, d, r]
2698
2726
  );
2699
2727
  return useHotkeys(
2700
2728
  "shift+up, shift+down, shift+left, shift+right",
@@ -2706,15 +2734,15 @@ const CONTROLS = [
2706
2734
  [h]
2707
2735
  ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: f, moveBlock: h, orientation: m };
2708
2736
  }, BlockController = ({ block: o, updateFloatingBar: r }) => {
2709
- const { isOnlyChild: n, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
2737
+ const { isOnlyChild: n, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: d } = useBlockController(
2710
2738
  o,
2711
2739
  r
2712
2740
  );
2713
- return n ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => {
2714
- if (c !== p) return null;
2741
+ return n ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: c, dir: p, key: u }) => {
2742
+ if (d !== p) return null;
2715
2743
  const g = isDisabledControl(a, l, u);
2716
2744
  return g ? null : /* @__PURE__ */ jsx(
2717
- d,
2745
+ c,
2718
2746
  {
2719
2747
  onClick: () => i(u),
2720
2748
  className: `${g ? "pointer-events-none cursor-not-allowed opacity-50" : "duration-300 hover:scale-95 hover:opacity-80"}`
@@ -2729,7 +2757,7 @@ const CONTROLS = [
2729
2757
  };
2730
2758
  class PubSub {
2731
2759
  constructor() {
2732
- V(this, "subscribers", /* @__PURE__ */ new Map());
2760
+ U(this, "subscribers", /* @__PURE__ */ new Map());
2733
2761
  }
2734
2762
  subscribe(r, n) {
2735
2763
  return this.subscribers.has(r) || this.subscribers.set(r, /* @__PURE__ */ new Set()), this.subscribers.get(r).add(n), () => {
@@ -2743,11 +2771,11 @@ class PubSub {
2743
2771
  }
2744
2772
  }
2745
2773
  const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: r }) => {
2746
- const { t: n } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (f) => c ? get(f, "_parent") === c : !get(f, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (f) => {
2774
+ const { t: n } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), d = get(o, "_parent"), c = filter(a, (f) => d ? get(f, "_parent") === d : !get(f, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(c, { _id: i }), g = (f) => {
2747
2775
  if (f === "CHILD")
2748
2776
  pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
2749
2777
  else {
2750
- const m = { _id: c || "", position: d == null ? void 0 : d.length };
2778
+ const m = { _id: d || "", position: c == null ? void 0 : c.length };
2751
2779
  f === "BEFORE" ? m.position = Math.max(u, 0) : f === "AFTER" && (m.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, m);
2752
2780
  }
2753
2781
  };
@@ -2766,8 +2794,8 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: r }) => {
2766
2794
  {
2767
2795
  className: "mr-10 flex cursor-default items-center space-x-1 px-1",
2768
2796
  draggable: i ? "true" : "false",
2769
- onDragStart: (c) => {
2770
- c.dataTransfer.setData("text/plain", JSON.stringify(pick(o, ["_id", "_type", "_name"]))), l(o), setTimeout(() => {
2797
+ onDragStart: (d) => {
2798
+ d.dataTransfer.setData("text/plain", JSON.stringify(pick(o, ["_id", "_type", "_name"]))), l(o), setTimeout(() => {
2771
2799
  n([]), a(null);
2772
2800
  }, 200);
2773
2801
  },
@@ -2778,7 +2806,7 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: r }) => {
2778
2806
  }
2779
2807
  );
2780
2808
  }, BlockFloatingSelector = ({ selectedBlockElement: o, block: r }) => {
2781
- const n = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: f, update: m } = useFloating({
2809
+ const n = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, d] = useSelectedStylingBlocks(), { hasPermission: c } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: f, update: m } = useFloating({
2782
2810
  placement: "top-start",
2783
2811
  middleware: [shift(), flip()],
2784
2812
  elements: {
@@ -2801,23 +2829,23 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: r }) => {
2801
2829
  k.stopPropagation(), i(null);
2802
2830
  },
2803
2831
  onKeyDown: (k) => k.stopPropagation(),
2804
- className: "isolate z-[999] flex h-6 items-center bg-primary py-2 text-xs text-white",
2832
+ className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
2805
2833
  children: [
2806
2834
  h && /* @__PURE__ */ jsx(
2807
2835
  ArrowUpIcon,
2808
2836
  {
2809
2837
  className: "hover:scale-105",
2810
2838
  onClick: () => {
2811
- c([]), l([h]);
2839
+ d([]), l([h]);
2812
2840
  }
2813
2841
  }
2814
2842
  ),
2815
2843
  /* @__PURE__ */ jsx(BlockActionLabel, { label: x, block: r }),
2816
2844
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
2817
2845
  /* @__PURE__ */ jsx(AddBlockDropdown, { block: r, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
2818
- canDuplicateBlock(get(r, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([r == null ? void 0 : r._id]) }) : null,
2819
- canDeleteBlock(get(r, "_type", "")) && d(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => n([r == null ? void 0 : r._id]) }) : null,
2820
- d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: r, updateFloatingBar: m })
2846
+ canDuplicateBlock(get(r, "_type", "")) && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([r == null ? void 0 : r._id]) }) : null,
2847
+ canDeleteBlock(get(r, "_type", "")) && c(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => n([r == null ? void 0 : r._id]) }) : null,
2848
+ c(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: r, updateFloatingBar: m })
2821
2849
  ] })
2822
2850
  ]
2823
2851
  }
@@ -2878,8 +2906,8 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: r }) => {
2878
2906
  <div class="frame-root h-full"></div>
2879
2907
  </body>
2880
2908
  </html>`, useKeyEventWatcher = (o) => {
2881
- const [r, n] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: f } = usePasteBlocks(), m = o ? { document: o } : {};
2882
- useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(r), {}, [r, p]), useHotkeys("ctrl+c,command+c", () => u(r), {}, [r, u]), useHotkeys(
2909
+ const [r, n] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: d, redo: c } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: f } = usePasteBlocks(), m = o ? { document: o } : {};
2910
+ useHotkeys("ctrl+z,command+z", () => d(), {}, [d]), useHotkeys("ctrl+y,command+y", () => c(), {}, [c]), useHotkeys("ctrl+x,command+x", () => p(r), {}, [r, p]), useHotkeys("ctrl+c,command+c", () => u(r), {}, [r, u]), useHotkeys(
2883
2911
  "ctrl+v,command+v",
2884
2912
  () => {
2885
2913
  g(r[0]) && f(r);
@@ -2926,26 +2954,26 @@ const positionPlaceholder = (o, r, n) => {
2926
2954
  const a = iframeDocument == null ? void 0 : iframeDocument.getElementById("placeholder"), l = possiblePositions.map(([p]) => p), i = l.reduce(
2927
2955
  (p, u) => Math.abs(u - n) < Math.abs(p - n) ? u : p,
2928
2956
  0
2929
- ), c = l.indexOf(i);
2930
- if (!possiblePositions[c]) return;
2931
- const d = possiblePositions[c];
2932
- a.style.width = r === "vertical" ? d[2] + "px" : "2px", a.style.height = r === "vertical" ? "2px" : d[2] + "px", a.style.display = "block", r === "vertical" ? (a.style.top = d[0] + "px", a.style.left = d[1] + "px") : (a.style.top = d[1] + "px", a.style.left = d[0] + "px");
2957
+ ), d = l.indexOf(i);
2958
+ if (!possiblePositions[d]) return;
2959
+ const c = possiblePositions[d];
2960
+ a.style.width = r === "vertical" ? c[2] + "px" : "2px", a.style.height = r === "vertical" ? "2px" : c[2] + "px", a.style.display = "block", r === "vertical" ? (a.style.top = c[0] + "px", a.style.left = c[1] + "px") : (a.style.top = c[1] + "px", a.style.left = c[0] + "px");
2933
2961
  };
2934
2962
  function calculateDropIndex(o, r) {
2935
2963
  let n = 0, a = 1 / 0;
2936
2964
  return r.forEach((l, i) => {
2937
- const c = Math.abs(l[0] - o);
2938
- c < a && (a = c, n = i);
2965
+ const d = Math.abs(l[0] - o);
2966
+ d < a && (a = d, n = i);
2939
2967
  }), n;
2940
2968
  }
2941
2969
  const calculatePossiblePositions = (o) => {
2942
2970
  const n = getOrientation(o) === "horizontal";
2943
2971
  possiblePositions = [], Array.from(o.children).forEach((a, l) => {
2944
2972
  if (a.classList.contains("pointer-events-none")) return;
2945
- const i = n ? a.offsetLeft : a.offsetTop, c = n ? [a.offsetTop, a.clientHeight] : [a.offsetLeft, a.clientWidth];
2946
- if (possiblePositions.push([i, c[0], c[1]]), l === o.children.length - 1) {
2947
- const d = n ? a.offsetLeft + a.clientWidth : a.offsetTop + a.clientHeight;
2948
- possiblePositions.push([d, c[0], c[1]]);
2973
+ const i = n ? a.offsetLeft : a.offsetTop, d = n ? [a.offsetTop, a.clientHeight] : [a.offsetLeft, a.clientWidth];
2974
+ if (possiblePositions.push([i, d[0], d[1]]), l === o.children.length - 1) {
2975
+ const c = n ? a.offsetLeft + a.clientWidth : a.offsetTop + a.clientHeight;
2976
+ possiblePositions.push([c, d[0], d[1]]);
2949
2977
  }
2950
2978
  });
2951
2979
  }, throttledDragOver = throttle((o) => {
@@ -2967,7 +2995,7 @@ function removeDataDrop() {
2967
2995
  o && o.removeAttribute("data-drop");
2968
2996
  }
2969
2997
  const useDnd = () => {
2970
- const { document: o } = useFrame(), [r, n] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: c } = useBlocksStoreUndoableActions(), [d, p] = useAtom$1(draggedBlockAtom), [, u] = useAtom$1(dropTargetBlockIdAtom);
2998
+ const { document: o } = useFrame(), [r, n] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: d } = useBlocksStoreUndoableActions(), [c, p] = useAtom$1(draggedBlockAtom), [, u] = useAtom$1(dropTargetBlockIdAtom);
2971
2999
  if (!useFeature("dnd")) return {};
2972
3000
  const f = () => {
2973
3001
  removePlaceholder(), n(!1), p(null), u(null), possiblePositions = [];
@@ -2981,7 +3009,7 @@ const useDnd = () => {
2981
3009
  var E;
2982
3010
  const h = dropTarget, k = getOrientation(h) === "vertical" ? m.clientY + ((E = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : E.scrollY) : m.clientX;
2983
3011
  dropIndex = calculateDropIndex(k, possiblePositions);
2984
- const b = d, S = h.getAttribute("data-block-id"), w = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3012
+ const b = c, S = h.getAttribute("data-block-id"), w = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
2985
3013
  if ((b == null ? void 0 : b._id) === S || !w) {
2986
3014
  f();
2987
3015
  return;
@@ -2991,7 +3019,7 @@ const useDnd = () => {
2991
3019
  return;
2992
3020
  }
2993
3021
  let A = h.getAttribute("data-block-id");
2994
- A === null && (A = m.target.parentElement.getAttribute("data-block-id")), c([b._id], A === "canvas" ? null : A, dropIndex), f(), setTimeout(removePlaceholder, 300);
3022
+ A === null && (A = m.target.parentElement.getAttribute("data-block-id")), d([b._id], A === "canvas" ? null : A, dropIndex), f(), setTimeout(removePlaceholder, 300);
2995
3023
  },
2996
3024
  onDragEnter: (m) => {
2997
3025
  const h = m, x = h.target;
@@ -3013,7 +3041,7 @@ function getTargetedBlock(o) {
3013
3041
  return (r == null ? void 0 : r.getAttribute("data-block-id")) === "canvas" ? null : r;
3014
3042
  }
3015
3043
  const useHandleCanvasDblClick = (o, r) => {
3016
- const n = [], a = useUpdateBlocksProps(), [l, i] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: c } = useBlockHighlight(), d = useGetBlockAtomValue(pageBlocksAtomsAtom);
3044
+ const n = [], a = useUpdateBlocksProps(), [l, i] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: d } = useBlockHighlight(), c = useGetBlockAtomValue(pageBlocksAtomsAtom);
3017
3045
  return useCallback(
3018
3046
  (p) => {
3019
3047
  if (l) return;
@@ -3031,26 +3059,26 @@ const useHandleCanvasDblClick = (o, r) => {
3031
3059
  const h = o.getHTML();
3032
3060
  a([f], { content: h }), r.style.display = "none", u.style.visibility = "visible";
3033
3061
  }), i(f);
3034
- const m = d(f).content;
3062
+ const m = c(f).content;
3035
3063
  o.commands.setContent(m), r.style.display = "block", u.style.visibility = "hidden", r.style.position = "absolute", r.style.top = `${u.offsetTop}px`, r.style.left = `${u.offsetLeft}px`, r.style.width = `${u.offsetWidth}px`, r.style.height = `${u.offsetHeight}px`, r.classList.add(...u.classList);
3036
3064
  },
3037
- [l, c, d, i, a, o, r]
3065
+ [l, d, c, i, a, o, r]
3038
3066
  );
3039
3067
  }, useHandleCanvasClick = () => {
3040
3068
  const [, o] = useSelectedStylingBlocks(), [r, n] = useSelectedBlockIds(), [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(treeRefAtom), { clearHighlight: i } = useBlockHighlight();
3041
- return (c) => {
3069
+ return (d) => {
3042
3070
  if (a) return;
3043
- c.stopPropagation();
3044
- const d = getTargetedBlock(c.target);
3045
- if (d != null && d.getAttribute("data-block-id") && (d == null ? void 0 : d.getAttribute("data-block-id")) === "container") {
3071
+ d.stopPropagation();
3072
+ const c = getTargetedBlock(d.target);
3073
+ if (c != null && c.getAttribute("data-block-id") && (c == null ? void 0 : c.getAttribute("data-block-id")) === "container") {
3046
3074
  n([]), o([]), i();
3047
3075
  return;
3048
3076
  }
3049
- if (d != null && d.getAttribute("data-block-parent")) {
3050
- const p = d.getAttribute("data-style-prop"), u = d.getAttribute("data-style-id"), g = d.getAttribute("data-block-parent");
3077
+ if (c != null && c.getAttribute("data-block-parent")) {
3078
+ const p = c.getAttribute("data-style-prop"), u = c.getAttribute("data-style-id"), g = c.getAttribute("data-block-parent");
3051
3079
  r.includes(g) || l == null || l.closeAll(), o([{ id: u, prop: p, blockId: g }]), n([g]);
3052
- } else if (d != null && d.getAttribute("data-block-id")) {
3053
- const p = d.getAttribute("data-block-id");
3080
+ } else if (c != null && c.getAttribute("data-block-id")) {
3081
+ const p = c.getAttribute("data-block-id");
3054
3082
  r.includes(p) || l == null || l.closeAll(), o([]), n(p === "canvas" ? [] : [p]);
3055
3083
  }
3056
3084
  i();
@@ -3081,9 +3109,9 @@ const useHandleCanvasDblClick = (o, r) => {
3081
3109
  }
3082
3110
  }, 100);
3083
3111
  }, [r, n, l, a]);
3084
- const c = useEditor({
3112
+ const d = useEditor({
3085
3113
  extensions: [StarterKit]
3086
- }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), f = useHandleMouseLeave(), m = useDnd();
3114
+ }), c = useRef(null), p = useHandleCanvasDblClick(d, c.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), f = useHandleMouseLeave(), m = useDnd();
3087
3115
  return /* @__PURE__ */ jsx(
3088
3116
  "div",
3089
3117
  {
@@ -3098,31 +3126,20 @@ const useHandleCanvasDblClick = (o, r) => {
3098
3126
  children: o
3099
3127
  }
3100
3128
  );
3101
- }, getElementByDataBlockId = (o, r) => o.querySelector(`[data-block-id="${r}"]`), CssThemeVariables = () => {
3102
- const [o] = useTheme(), r = useMemo(() => getChaiThemeCssVariables(o), [o]);
3129
+ }, getElementByDataBlockId = (o, r) => o.querySelector(`[data-block-id="${r}"]`), CssThemeVariables = ({ theme: o }) => {
3130
+ const r = useMemo(() => getChaiThemeCssVariables(o), [o]);
3103
3131
  return /* @__PURE__ */ jsx("style", { id: "chai-theme", children: r });
3104
- }, PrimaryColorCSSVariable = () => {
3105
- const [o] = useTheme(), r = get(o, "colors.primary", ["#2563EB", "#3B82F6"]), n = get(o, "colors.primary-foreground", ["#ffffff", "#ffffff"]);
3106
- return /* @__PURE__ */ jsx("style", { id: "chai-theme", children: `:root {
3107
- --primary: ${hexToHSL(r[0])};
3108
- --primary-foreground: ${hexToHSL(n[0])};
3109
-
3110
- .dark {
3111
- --primary: ${hexToHSL(r[1])};
3112
- --primary-foreground: ${hexToHSL(n[1])};
3113
- }
3114
- }` });
3115
3132
  }, HeadTags = () => {
3116
- const [o] = useTheme(), r = useThemeOptions(), [n] = useSelectedBlockIds(), [a] = useDarkMode(), [l] = useSelectedStylingBlocks(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), { document: d, window: p } = useFrame(), [u] = useState(d == null ? void 0 : d.getElementById("highlighted-block")), [g] = useState(
3117
- d == null ? void 0 : d.getElementById("selected-block")
3133
+ const [o] = useTheme(), r = useThemeOptions(), [n] = useSelectedBlockIds(), [a] = useDarkMode(), [l] = useSelectedStylingBlocks(), [i] = useAtom$1(draggedBlockAtom), [d] = useAtom$1(dropTargetBlockIdAtom), { document: c, window: p } = useFrame(), [u] = useState(c == null ? void 0 : c.getElementById("highlighted-block")), [g] = useState(
3134
+ c == null ? void 0 : c.getElementById("selected-block")
3118
3135
  ), [f] = useState(
3119
- d == null ? void 0 : d.getElementById("selected-styling-block")
3136
+ c == null ? void 0 : c.getElementById("selected-styling-block")
3120
3137
  ), [m] = useState(
3121
- d == null ? void 0 : d.getElementById("dragged-block")
3138
+ c == null ? void 0 : c.getElementById("dragged-block")
3122
3139
  );
3123
3140
  useEffect(() => {
3124
- a ? d == null || d.documentElement.classList.add("dark") : d == null || d.documentElement.classList.remove("dark");
3125
- }, [a, d]);
3141
+ a ? c == null || c.documentElement.classList.add("dark") : c == null || c.documentElement.classList.remove("dark");
3142
+ }, [a, c]);
3126
3143
  const h = useRegisteredFonts();
3127
3144
  useEffect(() => {
3128
3145
  !p || !p.tailwind || (p.tailwind.config = {
@@ -3171,8 +3188,8 @@ const useHandleCanvasDblClick = (o, r) => {
3171
3188
  outline: 1px solid orange !important; outline-offset: -1px;
3172
3189
  }`);
3173
3190
  }, [l, f]), useEffect(() => {
3174
- d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
3175
- }, [c, d]);
3191
+ c.querySelector("#drop-target-block").innerHTML = d ? `[data-block-id="${d}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
3192
+ }, [d, c]);
3176
3193
  const x = useMemo(() => {
3177
3194
  const { heading: S, body: w } = {
3178
3195
  heading: get(o, "fontFamily.heading"),
@@ -3184,12 +3201,12 @@ const useHandleCanvasDblClick = (o, r) => {
3184
3201
  [x]
3185
3202
  );
3186
3203
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3187
- /* @__PURE__ */ jsx(CssThemeVariables, {}),
3204
+ /* @__PURE__ */ jsx(CssThemeVariables, { theme: o }),
3188
3205
  /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: k } }),
3189
3206
  /* @__PURE__ */ jsx("style", { id: "chai-custom-fonts", dangerouslySetInnerHTML: { __html: b } })
3190
3207
  ] });
3191
3208
  }, ResizableCanvasWrapper = ({ children: o, onMount: r, onResize: n }) => {
3192
- const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
3209
+ const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), d = useDebouncedCallback(
3193
3210
  () => {
3194
3211
  const { clientWidth: p } = i.current;
3195
3212
  n(p);
@@ -3197,7 +3214,7 @@ const useHandleCanvasDblClick = (o, r) => {
3197
3214
  [i.current],
3198
3215
  100
3199
3216
  );
3200
- return useResizeObserver(i.current, c, i.current !== null), useEffect(() => {
3217
+ return useResizeObserver(i.current, d, i.current !== null), useEffect(() => {
3201
3218
  const { clientWidth: p } = i.current;
3202
3219
  r(p);
3203
3220
  }, []), /* @__PURE__ */ jsx("div", { id: "main-content", onClick: () => {
@@ -3217,10 +3234,10 @@ const applyBinding = (o, r) => {
3217
3234
  return forEach(keys(n), (a) => {
3218
3235
  if (isString(n[a]) && !startsWith(a, "_")) {
3219
3236
  let l = n[a];
3220
- const i = /\{\{(.*?)\}\}/g, c = l.match(i);
3221
- c && c.forEach((d) => {
3222
- const p = d.slice(2, -2), u = get(r, p, d);
3223
- l = l.replace(d, u);
3237
+ const i = /\{\{(.*?)\}\}/g, d = l.match(i);
3238
+ d && d.forEach((c) => {
3239
+ const p = c.slice(2, -2), u = get(r, p, c);
3240
+ l = l.replace(c, u);
3224
3241
  }), n[a] = l;
3225
3242
  }
3226
3243
  }), n;
@@ -3253,22 +3270,22 @@ const getBlockRuntimeProps = memoize((o) => {
3253
3270
  const [o] = useBlocksStore();
3254
3271
  return useCallback(
3255
3272
  (r, n) => isEmpty(n) ? {} : Object.entries(n).reduce((a, [l, i]) => {
3256
- const c = [];
3257
- let d = find(o, { _id: r });
3258
- for (; d; )
3259
- c.push(d), d = find(o, { _id: d._parent });
3260
- const p = find(c, { _type: i.block });
3273
+ const d = [];
3274
+ let c = find(o, { _id: r });
3275
+ for (; c; )
3276
+ d.push(c), c = find(o, { _id: c._parent });
3277
+ const p = find(d, { _type: i.block });
3261
3278
  return p && (a[l] = get(p, get(i, "prop"), null)), a;
3262
3279
  }, {}),
3263
3280
  [o]
3264
3281
  );
3265
3282
  }, BlockRenderer = ({ blockAtom: o, children: r }) => {
3266
- const [n] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(n._type), [n._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), f = useMemo(
3267
- () => u ? applyBinding(applyLanguage(n, l, a), d) : applyLanguage(n, l, a),
3268
- [n, l, a, d, u]
3283
+ const [n] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(n._type), [n._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), d = useBlockRuntimeProps(), c = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), f = useMemo(
3284
+ () => u ? applyBinding(applyLanguage(n, l, a), c) : applyLanguage(n, l, a),
3285
+ [n, l, a, c, u]
3269
3286
  ), m = useMemo(() => getBlockTagAttributes(n), [n, getBlockTagAttributes]), h = useMemo(
3270
- () => c(n._id, getBlockRuntimeProps(n._type)),
3271
- [n._id, n._type, c, getBlockRuntimeProps]
3287
+ () => d(n._id, getBlockRuntimeProps(n._type)),
3288
+ [n._id, n._type, d, getBlockRuntimeProps]
3272
3289
  ), x = useMemo(() => !has(a, "dataProvider") || !isFunction(a.dataProvider) ? {} : a.dataProvider(n, l), [n, l, a]), k = useMemo(
3273
3290
  () => ({
3274
3291
  blockProps: {
@@ -3303,12 +3320,12 @@ const getBlockRuntimeProps = memoize((o) => {
3303
3320
  splitAtoms: n = void 0
3304
3321
  }) => {
3305
3322
  const a = useGetBlockAtom(n), l = useMemo(
3306
- () => filter(o, (c) => has(c, "_id") && (isEmpty(r) ? !c._parent : c._parent === r)),
3323
+ () => filter(o, (d) => has(d, "_id") && (isEmpty(r) ? !d._parent : d._parent === r)),
3307
3324
  [o, r]
3308
- ), i = useCallback((c) => filter(o, (d) => d._parent === c._id).length > 0, [o]);
3309
- return map(l, (c) => {
3310
- const d = a(c._id);
3311
- return d ? /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, children: c._type === "GlobalBlock" || c._type === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: get(c, "partialBlockId", get(c, "globalBlock", "")) }) }) : i(c) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) : null }, c._id) : null;
3325
+ ), i = useCallback((d) => filter(o, (c) => c._parent === d._id).length > 0, [o]);
3326
+ return map(l, (d) => {
3327
+ const c = a(d._id);
3328
+ return c ? /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: c, children: d._type === "GlobalBlock" || d._type === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: get(d, "partialBlockId", get(d, "globalBlock", "")) }) }) : i(d) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: d._id }) : null }, d._id) : null;
3312
3329
  });
3313
3330
  }, PageBlocksRenderer = () => {
3314
3331
  const [o] = useBlocksStore();
@@ -3317,16 +3334,16 @@ const getBlockRuntimeProps = memoize((o) => {
3317
3334
  const [o] = useBlocksStore(), r = isEmpty(o) ? null : /* @__PURE__ */ jsx(PageBlocksRenderer, {});
3318
3335
  return /* @__PURE__ */ jsx(Fragment, { children: r });
3319
3336
  }, useCanvasScale = (o) => {
3320
- const [r] = useCanvasDisplayWidth(), [, n] = useCanvasZoom(), a = useBuilderProp("htmlDir", "ltr"), [l, i] = useState({}), c = useCallback(() => {
3321
- const { width: d, height: p } = o;
3322
- if (d < r) {
3323
- const u = parseFloat((d / r).toFixed(2).toString());
3337
+ const [r] = useCanvasDisplayWidth(), [, n] = useCanvasZoom(), a = useBuilderProp("htmlDir", "ltr"), [l, i] = useState({}), d = useCallback(() => {
3338
+ const { width: c, height: p } = o;
3339
+ if (c < r) {
3340
+ const u = parseFloat((c / r).toFixed(2).toString());
3324
3341
  let g = {};
3325
- const f = p * u, m = d * u;
3342
+ const f = p * u, m = c * u;
3326
3343
  p && (g = {
3327
3344
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
3328
3345
  height: 100 + (p - f) / f * 100 + "%",
3329
- width: 100 + (d - m) / m * 100 + "%"
3346
+ width: 100 + (c - m) / m * 100 + "%"
3330
3347
  }), i({
3331
3348
  position: "relative",
3332
3349
  top: 0,
@@ -3340,17 +3357,17 @@ const getBlockRuntimeProps = memoize((o) => {
3340
3357
  i({}), n(100);
3341
3358
  }, [r, o, a, n]);
3342
3359
  return useEffect(() => {
3343
- c();
3344
- }, [r, o, n, c]), l;
3360
+ d();
3361
+ }, [r, o, n, d]), l;
3345
3362
  }, getElementByStyleId = (o, r) => o.querySelector(`[data-style-id="${r}"]`), StaticCanvas = () => {
3346
- const [o] = useAtom$1(networkModeAtom), [r] = useCanvasDisplayWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, f] = useState([]), [, m] = useState([]), [, h] = useAtom$1(canvasIframeAtom), [x, k] = useSelectedStylingBlocks(), b = useBuilderProp("loading", !1), S = useBuilderProp("htmlDir", "ltr"), w = (C) => {
3363
+ const [o] = useAtom$1(networkModeAtom), [r] = useCanvasDisplayWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), d = useRef(null), [c, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(c), [g, f] = useState([]), [, m] = useState([]), [, h] = useAtom$1(canvasIframeAtom), [x, k] = useSelectedStylingBlocks(), b = useBuilderProp("loading", !1), S = useBuilderProp("htmlDir", "ltr"), w = (C) => {
3347
3364
  p((B) => ({ ...B, width: C }));
3348
3365
  };
3349
3366
  useEffect(() => {
3350
- if (!c.current) return;
3351
- const { clientWidth: C, clientHeight: B } = c.current;
3367
+ if (!d.current) return;
3368
+ const { clientWidth: C, clientHeight: B } = d.current;
3352
3369
  p({ width: C, height: B });
3353
- }, [c, r]);
3370
+ }, [d, r]);
3354
3371
  const A = (C, B = 0) => {
3355
3372
  const { top: _ } = C.getBoundingClientRect();
3356
3373
  return _ + B >= 0 && _ - B <= window.innerHeight;
@@ -3383,7 +3400,7 @@ const getBlockRuntimeProps = memoize((o) => {
3383
3400
  },
3384
3401
  onMouseLeave: () => setTimeout(() => l(""), 300),
3385
3402
  className: "relative mx-auto h-full w-full overflow-hidden",
3386
- ref: c,
3403
+ ref: d,
3387
3404
  children: /* @__PURE__ */ jsxs(
3388
3405
  ChaiFrame,
3389
3406
  {
@@ -3422,38 +3439,6 @@ const getBlockRuntimeProps = memoize((o) => {
3422
3439
  )
3423
3440
  }
3424
3441
  ) });
3425
- }, 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: [
3426
- /* @__PURE__ */ jsx("p", { className: "font-semibold", children: "Oops! Something went wrong." }),
3427
- /* @__PURE__ */ jsx("p", { children: "Please try again." })
3428
- ] }) }), ICON_CLASS = "h-3 w-3 stroke-[2]", TypeIcon = (o) => {
3429
- const r = useRegisteredChaiBlocks(), n = get(r, [o == null ? void 0 : o.type, "icon"]);
3430
- return n ? React__default.createElement(n, { className: ICON_CLASS }) : /* @__PURE__ */ jsx(BoxModelIcon, { className: ICON_CLASS });
3431
- }, Breadcrumb = () => {
3432
- const o = useSelectedBlockHierarchy(), [, r] = useSelectedBlockIds(), { highlightBlock: n } = useBlockHighlight();
3433
- return /* @__PURE__ */ jsx("div", { className: "-mx-2 border-t border-border bg-background px-2 py-1 text-xs text-muted-foreground", children: /* @__PURE__ */ jsxs("ol", { className: "flex items-center whitespace-nowrap", children: [
3434
- /* @__PURE__ */ jsxs("li", { className: "inline-flex items-center", children: [
3435
- /* @__PURE__ */ jsx(Button, { onClick: () => r([]), variant: "ghost", className: "h-fit p-1 text-xs font-normal", children: "Body" }),
3436
- /* @__PURE__ */ jsx(ChevronRight, { className: "rtl:rotate-180", size: 16 })
3437
- ] }),
3438
- reverse(o).map((a, l) => /* @__PURE__ */ jsxs("li", { className: "inline-flex items-center", children: [
3439
- /* @__PURE__ */ jsxs(
3440
- Button,
3441
- {
3442
- onMouseEnter: () => {
3443
- n(a == null ? void 0 : a._id);
3444
- },
3445
- onClick: () => r([a == null ? void 0 : a._id]),
3446
- variant: "ghost",
3447
- className: "h-fit gap-x-1 p-1 text-xs font-normal",
3448
- children: [
3449
- /* @__PURE__ */ jsx(TypeIcon, { type: a == null ? void 0 : a._type }),
3450
- a._name || a._type
3451
- ]
3452
- }
3453
- ),
3454
- l !== o.length - 1 && /* @__PURE__ */ jsx(ChevronRight, { className: "rtl:rotate-180", size: 16 })
3455
- ] }, l))
3456
- ] }) });
3457
3442
  }, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-CuhsobXe.js")), CanvasArea = () => {
3458
3443
  const [o] = useCodeEditor(), r = useBuilderProp("onError", noop);
3459
3444
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2", children: [
@@ -3493,9 +3478,9 @@ const getBlockRuntimeProps = memoize((o) => {
3493
3478
  useEffect(() => {
3494
3479
  i(o || "");
3495
3480
  }, [o]);
3496
- const c = (d) => {
3497
- i(d);
3498
- const p = removeSizeAttributes(d);
3481
+ const d = (c) => {
3482
+ i(c);
3483
+ const p = removeSizeAttributes(c);
3499
3484
  r(p);
3500
3485
  };
3501
3486
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex flex-col gap-2", id: "icon-picker-field", children: [
@@ -3509,7 +3494,7 @@ const getBlockRuntimeProps = memoize((o) => {
3509
3494
  autoCorrect: "off",
3510
3495
  spellCheck: "false",
3511
3496
  value: l,
3512
- onChange: (d) => c(d.target.value),
3497
+ onChange: (c) => d(c.target.value),
3513
3498
  placeholder: a("Enter SVG code here"),
3514
3499
  rows: 2,
3515
3500
  className: "no-scrollbar w-full rounded-md border border-border bg-background px-3 py-1.5 text-xs shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
@@ -3519,13 +3504,13 @@ const getBlockRuntimeProps = memoize((o) => {
3519
3504
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
3520
3505
  ] });
3521
3506
  }, DefaultMediaManager = ({ close: o, onSelect: r, mode: n = "image" }) => {
3522
- const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), f = async (h) => {
3507
+ const [a, l] = useState(""), [i, d] = useState(!1), [c, p] = useState(!1), [u, g] = useState(null), f = async (h) => {
3523
3508
  if (!h.trim()) {
3524
3509
  p(!1), g("Please enter a URL");
3525
3510
  return;
3526
3511
  }
3527
3512
  try {
3528
- c(!0), g(null);
3513
+ d(!0), g(null);
3529
3514
  const x = await fetch(h, { method: "HEAD" });
3530
3515
  if (!x.ok) {
3531
3516
  p(!1), g("Invalid asset URL");
@@ -3536,7 +3521,7 @@ const getBlockRuntimeProps = memoize((o) => {
3536
3521
  } catch {
3537
3522
  p(!1), g("Error validating URL");
3538
3523
  } finally {
3539
- c(!1);
3524
+ d(!1);
3540
3525
  }
3541
3526
  }, { t: m } = useTranslation();
3542
3527
  return /* @__PURE__ */ jsxs("div", { className: "flex w-96 flex-col gap-4 p-4", children: [
@@ -3557,7 +3542,7 @@ const getBlockRuntimeProps = memoize((o) => {
3557
3542
  ),
3558
3543
  /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
3559
3544
  /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: o, children: m("Cancel") }),
3560
- /* @__PURE__ */ jsx(Button, { onClick: () => r([a]), disabled: !d || i, children: m("Insert") })
3545
+ /* @__PURE__ */ jsx(Button, { onClick: () => r([a]), disabled: !c || i, children: m("Insert") })
3561
3546
  ] })
3562
3547
  ] })
3563
3548
  ] });
@@ -3571,10 +3556,10 @@ const getBlockRuntimeProps = memoize((o) => {
3571
3556
  mode: n = "image"
3572
3557
  }) => {
3573
3558
  const [a, l] = useState(!1), i = useMediaManagerComponent();
3574
- return /* @__PURE__ */ jsxs(Dialog, { open: a, onOpenChange: (d) => l(d), children: [
3559
+ return /* @__PURE__ */ jsxs(Dialog, { open: a, onOpenChange: (c) => l(c), children: [
3575
3560
  /* @__PURE__ */ jsx(DialogTrigger, { asChild: !0, children: o }),
3576
- /* @__PURE__ */ jsx(DialogContent, { className: "flex max-h-[90vh] max-w-7xl border-border md:w-fit", children: /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: i ? /* @__PURE__ */ jsx(i, { close: () => l(!1), onSelect: (...d) => {
3577
- r.call(void 0, ...d), l(!1);
3561
+ /* @__PURE__ */ jsx(DialogContent, { className: "flex max-h-[90vh] max-w-7xl border-border md:w-fit", children: /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: i ? /* @__PURE__ */ jsx(i, { close: () => l(!1), onSelect: (...c) => {
3562
+ r.call(void 0, ...c), l(!1);
3578
3563
  }, mode: n }) : null }) })
3579
3564
  ] });
3580
3565
  };
@@ -3607,26 +3592,26 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
3607
3592
  ] });
3608
3593
  };
3609
3594
  function NestedPathSelector({ data: o, onSelect: r, dataType: n = "value" }) {
3610
- const [a, l] = React.useState(!1), [i, c] = React.useState([]), [d, p] = React.useState(o);
3595
+ const [a, l] = React.useState(!1), [i, d] = React.useState([]), [c, p] = React.useState(o);
3611
3596
  useEffect(() => {
3612
- a || c([]), p(o);
3597
+ a || d([]), p(o);
3613
3598
  }, [a, o]);
3614
3599
  const u = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", g = React.useCallback(
3615
3600
  (h) => {
3616
3601
  const x = (k) => n === "value" ? k === "value" || k === "object" : n === "array" ? k === "array" : k === n;
3617
- h.type === "object" ? (c((k) => [...k, h.key]), p(h.value)) : x(h.type) && (r([...i, h.key].join(".")), l(!1));
3602
+ h.type === "object" ? (d((k) => [...k, h.key]), p(h.value)) : x(h.type) && (r([...i, h.key].join(".")), l(!1));
3618
3603
  },
3619
3604
  [i, r, n]
3620
3605
  ), f = React.useCallback(() => {
3621
3606
  if (i.length > 0) {
3622
3607
  const h = i.slice(0, -1);
3623
- c(h), p(h.reduce((x, k) => x[k], o));
3608
+ d(h), p(h.reduce((x, k) => x[k], o));
3624
3609
  }
3625
- }, [i, o]), m = React.useMemo(() => Object.entries(d).map(([h, x]) => ({
3610
+ }, [i, o]), m = React.useMemo(() => Object.entries(c).map(([h, x]) => ({
3626
3611
  key: h,
3627
3612
  value: x,
3628
3613
  type: u(x)
3629
- })).filter((h) => n === "value" ? h.type === "value" || h.type === "object" : n === "array" ? h.type === "array" || h.type === "object" : n === "object" ? h.type === "object" : !0), [d, n]);
3614
+ })).filter((h) => n === "value" ? h.type === "value" || h.type === "object" : n === "array" ? h.type === "array" || h.type === "object" : n === "object" ? h.type === "object" : !0), [c, n]);
3630
3615
  return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
3631
3616
  /* @__PURE__ */ jsxs(Tooltip, { children: [
3632
3617
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
@@ -3833,7 +3818,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
3833
3818
  onChange: l,
3834
3819
  onBlur: i
3835
3820
  }) => {
3836
- const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
3821
+ const d = useRef(null), c = useRef(a || ""), p = usePageExternalData();
3837
3822
  useEffect(() => {
3838
3823
  if (o) {
3839
3824
  const f = document.createElement("style");
@@ -3881,11 +3866,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
3881
3866
  }
3882
3867
  });
3883
3868
  useEffect(() => {
3884
- o && u && (d.current !== a && (d.current = a || "", u.commands.setContent(a || "")), setTimeout(() => {
3869
+ o && u && (c.current !== a && (c.current = a || "", u.commands.setContent(a || "")), setTimeout(() => {
3885
3870
  u.commands.focus();
3886
3871
  }, 100));
3887
3872
  }, [o, u]), useEffect(() => {
3888
- c.current && u && (c.current.__chaiRTE = u);
3873
+ d.current && u && (d.current.__chaiRTE = u);
3889
3874
  }, [u, o]);
3890
3875
  const g = (f) => {
3891
3876
  if (!u) return;
@@ -3910,14 +3895,14 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
3910
3895
  /* @__PURE__ */ jsx("div", { className: "rte-path-selector", children: /* @__PURE__ */ jsx(NestedPathSelector, { data: p, onSelect: g }) })
3911
3896
  ] })
3912
3897
  ] }) }),
3913
- /* @__PURE__ */ jsxs("div", { id: `chai-rte-modal-${n}`, ref: c, className: "rounded-md border border-input", children: [
3898
+ /* @__PURE__ */ jsxs("div", { id: `chai-rte-modal-${n}`, ref: d, className: "rounded-md border border-input", children: [
3914
3899
  /* @__PURE__ */ jsx(MenuBar, { editor: u }),
3915
3900
  /* @__PURE__ */ jsx(EditorContent, { editor: u, id: `modal-${n}`, className: "p-2" })
3916
3901
  ] }),
3917
3902
  /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-end", children: /* @__PURE__ */ jsx(Button, { onClick: r, children: "Done" }) })
3918
3903
  ] }) });
3919
3904
  }, RichTextEditorField = ({ id: o, placeholder: r, value: n, onChange: a, onBlur: l }) => {
3920
- const i = useRef(null), [c, d] = useState(!1), [p, u] = useState(""), g = useEditor({
3905
+ const i = useRef(null), [d, c] = useState(!1), [p, u] = useState(""), g = useEditor({
3921
3906
  extensions: [
3922
3907
  StarterKit,
3923
3908
  Link.configure({
@@ -3936,7 +3921,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
3936
3921
  content: n || "",
3937
3922
  onUpdate: ({ editor: h }) => {
3938
3923
  const x = h.getHTML();
3939
- a(x), c || u(x);
3924
+ a(x), d || u(x);
3940
3925
  },
3941
3926
  onBlur: ({ editor: h }) => {
3942
3927
  const x = h.getHTML();
@@ -3956,17 +3941,17 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
3956
3941
  const f = (h) => {
3957
3942
  a(h);
3958
3943
  }, m = () => {
3959
- d(!1), g && g.commands.setContent(p);
3944
+ c(!1), g && g.commands.setContent(p);
3960
3945
  };
3961
3946
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3962
3947
  /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsxs("div", { id: `chai-rte-${o}`, ref: i, className: "mt-1 rounded-md border border-input", children: [
3963
- /* @__PURE__ */ jsx(MenuBar, { editor: g, onExpand: () => d(!0) }),
3948
+ /* @__PURE__ */ jsx(MenuBar, { editor: g, onExpand: () => c(!0) }),
3964
3949
  /* @__PURE__ */ jsx(EditorContent, { editor: g, id: o, placeholder: r })
3965
3950
  ] }) }),
3966
- c && /* @__PURE__ */ jsx(
3951
+ d && /* @__PURE__ */ jsx(
3967
3952
  RTEModal,
3968
3953
  {
3969
- isOpen: c,
3954
+ isOpen: d,
3970
3955
  onClose: m,
3971
3956
  id: o,
3972
3957
  value: p,
@@ -3980,8 +3965,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
3980
3965
  pageTypes: r,
3981
3966
  onChange: n
3982
3967
  }) => {
3983
- var L;
3984
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [f, m] = useState(""), [h, x] = useState([]), [k, b] = useState(-1), S = useRef(null), w = (L = r == null ? void 0 : r.find((v) => v.key === u)) == null ? void 0 : L.name;
3968
+ var I;
3969
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, y) => []), [i, d] = useState(!1), [c, p] = useState(!1), [u, g] = useState("page"), [f, m] = useState(""), [h, x] = useState([]), [k, b] = useState(-1), S = useRef(null), w = (I = r == null ? void 0 : r.find((v) => v.key === u)) == null ? void 0 : I.name;
3985
3970
  useEffect(() => {
3986
3971
  if (m(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
3987
3972
  const v = split(o, ":"), y = get(v, 1, "page") || "page";
@@ -3998,7 +3983,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
3998
3983
  const y = await l(u, v);
3999
3984
  x(y);
4000
3985
  }
4001
- c(!1), b(-1);
3986
+ d(!1), b(-1);
4002
3987
  },
4003
3988
  [u],
4004
3989
  300
@@ -4031,7 +4016,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4031
4016
  const B = () => {
4032
4017
  m(""), x([]), b(-1), p(!1), n("");
4033
4018
  }, _ = (v) => {
4034
- m(v), p(!isEmpty(v)), c(!0), A(v);
4019
+ m(v), p(!isEmpty(v)), d(!0), A(v);
4035
4020
  };
4036
4021
  return /* @__PURE__ */ jsxs("div", { children: [
4037
4022
  /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (v) => g(v.target.value), children: map(r, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
@@ -4049,10 +4034,10 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4049
4034
  ),
4050
4035
  /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: f && /* @__PURE__ */ jsx("button", { onClick: B, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4051
4036
  ] }),
4052
- (i || !isEmpty(h) || d && isEmpty(h)) && /* @__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: [
4037
+ (i || !isEmpty(h) || c && isEmpty(h)) && /* @__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: [
4053
4038
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
4054
4039
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
4055
- ] }) : d && isEmpty(h) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4040
+ ] }) : c && isEmpty(h) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4056
4041
  a("No results found for"),
4057
4042
  ' "',
4058
4043
  f,
@@ -4076,13 +4061,13 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4076
4061
  )) }) })
4077
4062
  ] });
4078
4063
  }, LinkField = ({ schema: o, formData: r, onChange: n }) => {
4079
- const { t: a } = useTranslation(), { type: l = "pageType", href: i = "", target: c = "self" } = r, d = useBuilderProp("pageTypes", []), p = l === "pageType" && isEmpty(d) ? "url" : l;
4064
+ const { t: a } = useTranslation(), { type: l = "pageType", href: i = "", target: d = "self" } = r, c = useBuilderProp("pageTypes", []), p = l === "pageType" && isEmpty(c) ? "url" : l;
4080
4065
  return /* @__PURE__ */ jsxs("div", { children: [
4081
4066
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium", children: (o == null ? void 0 : o.title) ?? "Link" }),
4082
4067
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-1.5", children: [
4083
4068
  /* @__PURE__ */ jsx("select", { name: "type", value: l, onChange: (u) => n({ ...r, type: u.target.value }), children: map(
4084
4069
  [
4085
- ...isEmpty(d) ? [] : [{ const: "pageType", title: a("Goto Page") }],
4070
+ ...isEmpty(c) ? [] : [{ const: "pageType", title: a("Goto Page") }],
4086
4071
  { const: "url", title: a("Open URL") },
4087
4072
  { const: "email", title: a("Compose Email") },
4088
4073
  { const: "telephone", title: a("Call Phone") },
@@ -4090,11 +4075,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4090
4075
  ],
4091
4076
  (u) => /* @__PURE__ */ jsx("option", { value: u.const, children: u.title }, u.const)
4092
4077
  ) }),
4093
- p === "pageType" && !isEmpty(d) ? /* @__PURE__ */ jsx(
4078
+ p === "pageType" && !isEmpty(c) ? /* @__PURE__ */ jsx(
4094
4079
  PageTypeField,
4095
4080
  {
4096
4081
  href: i,
4097
- pageTypes: d,
4082
+ pageTypes: c,
4098
4083
  onChange: (u) => n({ ...r, href: u })
4099
4084
  }
4100
4085
  ) : /* @__PURE__ */ jsx(
@@ -4118,9 +4103,9 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4118
4103
  autoCorrect: "off",
4119
4104
  spellCheck: "false",
4120
4105
  type: "checkbox",
4121
- defaultChecked: c === "_blank",
4106
+ defaultChecked: d === "_blank",
4122
4107
  className: "!w-fit cursor-pointer rounded-md border border-border",
4123
- onChange: () => n({ ...r, target: c === "_blank" ? "_self" : "_blank" })
4108
+ onChange: () => n({ ...r, target: d === "_blank" ? "_self" : "_blank" })
4124
4109
  }
4125
4110
  ),
4126
4111
  /* @__PURE__ */ jsx("span", { className: "pt-1 text-xs", children: a("Open in new tab") })
@@ -4144,9 +4129,9 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4144
4129
  }
4145
4130
  ) });
4146
4131
  }, SliderField = ({ formData: o, onChange: r }) => {
4147
- const [n] = useBlocksStore(), a = useSelectedBlock(), l = useWrapperBlock(), { addCoreBlock: i } = useAddBlock(), [, c] = useSelectedBlockIds();
4132
+ const [n] = useBlocksStore(), a = useSelectedBlock(), l = useWrapperBlock(), { addCoreBlock: i } = useAddBlock(), [, d] = useSelectedBlockIds();
4148
4133
  if (!a && !l) return null;
4149
- const d = (a == null ? void 0 : a._type) === "Slider" ? a : l, p = find(n, { _parent: d == null ? void 0 : d._id, _type: "Slides" });
4134
+ const c = (a == null ? void 0 : a._type) === "Slider" ? a : l, p = find(n, { _parent: c == null ? void 0 : c._id, _type: "Slides" });
4150
4135
  if (!p) return null;
4151
4136
  const u = filter(n, { _parent: p == null ? void 0 : p._id, _type: "Slide" }), g = (o == null ? void 0 : o.currentSlide) || get(u, "0._id");
4152
4137
  useEffect(() => {
@@ -4159,21 +4144,21 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4159
4144
  if (x > -1) {
4160
4145
  const k = (x + 1) % u.length, b = get(u, [k, "_id"]);
4161
4146
  if (!b) return;
4162
- r({ ...o, currentSlide: b }), c([b]);
4147
+ r({ ...o, currentSlide: b }), d([b]);
4163
4148
  }
4164
4149
  }, m = () => {
4165
4150
  const x = findIndex(u, { _id: g });
4166
4151
  if (x > -1) {
4167
4152
  const k = (x - 1 + u.length) % u.length, b = get(u, [k, "_id"]);
4168
4153
  if (!b) return;
4169
- r({ ...o, currentSlide: b }), c([b]);
4154
+ r({ ...o, currentSlide: b }), d([b]);
4170
4155
  }
4171
4156
  }, h = () => {
4172
4157
  const x = i(
4173
4158
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4174
4159
  p == null ? void 0 : p._id
4175
4160
  ), k = x == null ? void 0 : x._id;
4176
- k && (r({ ...o, currentSlide: k }), c([k]));
4161
+ k && (r({ ...o, currentSlide: k }), d([k]));
4177
4162
  };
4178
4163
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4179
4164
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
@@ -4261,15 +4246,15 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4261
4246
  ] }) })
4262
4247
  ] });
4263
4248
  }, SourcesField = ({ formData: o, onChange: r }) => {
4264
- const n = get(o, "srcsets", []) || [], a = (c, d) => {
4265
- const p = c.target.name, u = c.target.value;
4249
+ const n = get(o, "srcsets", []) || [], a = (d, c) => {
4250
+ const p = d.target.name, u = d.target.value;
4266
4251
  r({
4267
- srcsets: map(n, (g, f) => f === d ? { ...g, [p]: u } : g)
4252
+ srcsets: map(n, (g, f) => f === c ? { ...g, [p]: u } : g)
4268
4253
  });
4269
4254
  }, l = () => {
4270
4255
  r({ srcsets: [...n, {}] });
4271
- }, i = (c) => {
4272
- r({ srcsets: reject(n, (d, p) => p === c) });
4256
+ }, i = (d) => {
4257
+ r({ srcsets: reject(n, (c, p) => p === d) });
4273
4258
  };
4274
4259
  return /* @__PURE__ */ jsxs("div", { children: [
4275
4260
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pb-2", children: [
@@ -4284,12 +4269,12 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4284
4269
  }
4285
4270
  )
4286
4271
  ] }),
4287
- /* @__PURE__ */ jsx("div", { className: "space-y-2", children: n.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded border border-dashed border-gray-200 p-2 text-xs italic text-gray-500", children: "Add additional sources to create responsive videos" }) : map(n, (c, d) => /* @__PURE__ */ jsxs("div", { className: "group relative space-y-1.5 rounded border border-gray-200 px-2 pb-1.5", children: [
4272
+ /* @__PURE__ */ jsx("div", { className: "space-y-2", children: n.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded border border-dashed border-gray-200 p-2 text-xs italic text-gray-500", children: "Add additional sources to create responsive videos" }) : map(n, (d, c) => /* @__PURE__ */ jsxs("div", { className: "group relative space-y-1.5 rounded border border-gray-200 px-2 pb-1.5", children: [
4288
4273
  /* @__PURE__ */ jsx(
4289
4274
  "button",
4290
4275
  {
4291
4276
  type: "button",
4292
- onClick: () => i(d),
4277
+ onClick: () => i(c),
4293
4278
  className: "absolute -right-px -top-0 -translate-y-1/2 rounded-full bg-red-100 p-1 opacity-0 hover:bg-red-200 group-hover:opacity-100",
4294
4279
  children: /* @__PURE__ */ jsx(X, { size: 10, className: "text-red-500" })
4295
4280
  }
@@ -4302,8 +4287,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4302
4287
  name: "width",
4303
4288
  placeholder: "Enter width (in px)",
4304
4289
  type: "number",
4305
- value: get(c, "width"),
4306
- onChange: (p) => a(p, d),
4290
+ value: get(d, "width"),
4291
+ onChange: (p) => a(p, c),
4307
4292
  className: "!placeholder:text-gray-100 !mt-0 !rounded-none !border-0 !p-0 !text-xs"
4308
4293
  }
4309
4294
  )
@@ -4316,30 +4301,30 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4316
4301
  name: "url",
4317
4302
  placeholder: "Enter url",
4318
4303
  className: "!mt-0 !rounded-none !border-0 !p-0 !text-xs !shadow-none",
4319
- value: get(c, "url", ""),
4320
- onChange: (p) => a(p, d)
4304
+ value: get(d, "url", ""),
4305
+ onChange: (p) => a(p, c)
4321
4306
  }
4322
4307
  )
4323
4308
  ] })
4324
- ] }, d)) })
4309
+ ] }, c)) })
4325
4310
  ] });
4326
4311
  }, BindingWidget = () => /* @__PURE__ */ jsx("div", { className: "text-xs border rounded-sm p-1 mt-1 border-orange-500 text-orange-500 bg-orange-100", children: "Data binding is set for this field" }), CodeEditor = ({ id: o, placeholder: r }) => {
4327
4312
  const { t: n } = useTranslation(), [, a] = useCodeEditor(), l = useSelectedBlock();
4328
4313
  if (typeof window > "u") return null;
4329
- const i = o.replace("root.", ""), c = get(l, i, ""), d = () => {
4314
+ const i = o.replace("root.", ""), d = get(l, i, ""), c = () => {
4330
4315
  const p = l == null ? void 0 : l._id;
4331
- a({ blockId: p, blockProp: i, placeholder: r, initialCode: get(l, i, c) });
4316
+ a({ blockId: p, blockProp: i, placeholder: r, initialCode: get(l, i, d) });
4332
4317
  };
4333
4318
  return /* @__PURE__ */ jsxs("div", { className: "mt-2 flex flex-col gap-y-1", children: [
4334
4319
  /* @__PURE__ */ jsx(
4335
4320
  "button",
4336
4321
  {
4337
- onClick: d,
4322
+ onClick: c,
4338
4323
  className: "w-[90%] max-w-full cursor-default truncate text-pretty rounded border border-border bg-background p-2 text-left text-[10px]",
4339
- children: c.trim().length > 0 ? c.substring(0, 46) : r || "Eg: <script>console.log('Hello, world!');<\/script>"
4324
+ children: d.trim().length > 0 ? d.substring(0, 46) : r || "Eg: <script>console.log('Hello, world!');<\/script>"
4340
4325
  }
4341
4326
  ),
4342
- /* @__PURE__ */ jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: n("Open code editor") })
4327
+ /* @__PURE__ */ jsx(Button, { onClick: c, size: "sm", variant: "outline", className: "w-fit", children: n("Open code editor") })
4343
4328
  ] });
4344
4329
  }, JSONFormFieldTemplate = ({
4345
4330
  id: o,
@@ -4348,8 +4333,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4348
4333
  children: a,
4349
4334
  errors: l,
4350
4335
  help: i,
4351
- description: c,
4352
- hidden: d,
4336
+ description: d,
4337
+ hidden: c,
4353
4338
  required: p,
4354
4339
  schema: u,
4355
4340
  formData: g,
@@ -4365,8 +4350,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4365
4350
  prefixLength: R.length,
4366
4351
  suffixLength: $.length
4367
4352
  };
4368
- }, I = document.getElementById(o);
4369
- if (!I) return;
4353
+ }, L = document.getElementById(o);
4354
+ if (!L) return;
4370
4355
  const P = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
4371
4356
  if (P && (P.querySelector(".ProseMirror") || P.__chaiRTE)) {
4372
4357
  const N = P.__chaiRTE;
@@ -4377,19 +4362,19 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4377
4362
  if (O !== R)
4378
4363
  N.chain().deleteSelection().insertContent(D).run();
4379
4364
  else {
4380
- const { state: M } = N, H = M.selection.from, F = M.doc.textBetween(Math.max(0, H - 1), H), U = M.doc.textBetween(H, Math.min(H + 1, M.doc.content.size));
4365
+ const { state: M } = N, H = M.selection.from, F = M.doc.textBetween(Math.max(0, H - 1), H), V = M.doc.textBetween(H, Math.min(H + 1, M.doc.content.size));
4381
4366
  let z = "";
4382
4367
  H > 0 && F !== " " && !j(F) && (z = " ");
4383
4368
  let W = "";
4384
- U && U !== " " && !j(U) && (W = " "), N.chain().insertContent(z + D + W).run();
4369
+ V && V !== " " && !j(V) && (W = " "), N.chain().insertContent(z + D + W).run();
4385
4370
  }
4386
4371
  setTimeout(() => f(N.getHTML(), {}, o), 100);
4387
4372
  return;
4388
4373
  }
4389
4374
  } else {
4390
- const N = I, D = N.selectionStart || 0, O = N.value || "", R = N.selectionEnd || D;
4375
+ const N = L, D = N.selectionStart || 0, O = N.value || "", R = N.selectionEnd || D;
4391
4376
  if (R > D) {
4392
- const U = `{{${y}}}`, { text: z } = T(O, D, U), W = O.slice(0, D) + z + O.slice(R);
4377
+ const V = `{{${y}}}`, { text: z } = T(O, D, V), W = O.slice(0, D) + z + O.slice(R);
4393
4378
  f(W, {}, o);
4394
4379
  return;
4395
4380
  }
@@ -4399,7 +4384,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4399
4384
  },
4400
4385
  [o, f, g, w == null ? void 0 : w._id]
4401
4386
  );
4402
- if (d)
4387
+ if (c)
4403
4388
  return null;
4404
4389
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: a });
4405
4390
  const v = E == null ? void 0 : E.includes(o.replace("root.", ""));
@@ -4422,7 +4407,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4422
4407
  }
4423
4408
  ),
4424
4409
  (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${y ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
4425
- c,
4410
+ d,
4426
4411
  a,
4427
4412
  l,
4428
4413
  i
@@ -4442,7 +4427,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4442
4427
  ] }),
4443
4428
  u.type === "string" && !u.enum && !u.oneOf && S && /* @__PURE__ */ jsx(NestedPathSelector, { data: S, onSelect: _, dataType: "value" })
4444
4429
  ] }),
4445
- c,
4430
+ d,
4446
4431
  a,
4447
4432
  l,
4448
4433
  i
@@ -4452,7 +4437,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4452
4437
  " ",
4453
4438
  /* @__PURE__ */ jsx("span", { children: "Add" })
4454
4439
  ] }) }), JSONForm = memo(({ blockId: o, schema: r, uiSchema: n, formData: a, onChange: l }) => {
4455
- const { selectedLang: i } = useLanguages(), c = useBlockSettingComponents("widget"), d = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
4440
+ const { selectedLang: i } = useLanguages(), d = useBlockSettingComponents("widget"), c = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
4456
4441
  async ({ formData: g }, f) => {
4457
4442
  l({ formData: g }, f);
4458
4443
  },
@@ -4470,13 +4455,13 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4470
4455
  image: ImagePickerField,
4471
4456
  code: CodeEditor,
4472
4457
  colCount: RowColField,
4473
- ...c
4458
+ ...d
4474
4459
  },
4475
4460
  fields: {
4476
4461
  link: LinkField,
4477
4462
  slider: SliderField,
4478
4463
  sources: SourcesField,
4479
- ...d
4464
+ ...c
4480
4465
  },
4481
4466
  templates: {
4482
4467
  FieldTemplate: JSONFormFieldTemplate,
@@ -4509,17 +4494,17 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4509
4494
  }), a;
4510
4495
  };
4511
4496
  function BlockSettings() {
4512
- const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), f = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, f), h = ({ formData: C }, B, _) => {
4513
- B && (c == null ? void 0 : c._id) === r._id && a([r._id], { [B]: get(C, B) }, _);
4497
+ const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [d, c] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), f = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, f), h = ({ formData: C }, B, _) => {
4498
+ B && (d == null ? void 0 : d._id) === r._id && a([r._id], { [B]: get(C, B) }, _);
4514
4499
  }, x = useCallback(
4515
4500
  debounce(({ formData: C }, B, _) => {
4516
- h({ formData: C }, B, _), d(C);
4501
+ h({ formData: C }, B, _), c(C);
4517
4502
  }, 1500),
4518
4503
  [r == null ? void 0 : r._id, o]
4519
4504
  ), k = ({ formData: C }, B) => {
4520
- B && (n([r._id], { [B]: get(C, B) }), x({ formData: C }, B, { [B]: get(c, B) }));
4505
+ B && (n([r._id], { [B]: get(C, B) }), x({ formData: C }, B, { [B]: get(d, B) }));
4521
4506
  }, b = ({ formData: C }, B) => {
4522
- B && (n([g._id], { [B]: get(C, B) }), x({ formData: C }, B, { [B]: get(c, B) }));
4507
+ B && (n([g._id], { [B]: get(C, B) }), x({ formData: C }, B, { [B]: get(d, B) }));
4523
4508
  }, { schema: S, uiSchema: w } = useMemo(() => {
4524
4509
  const C = r == null ? void 0 : r._type;
4525
4510
  if (!C)
@@ -4641,8 +4626,8 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
4641
4626
  title: a,
4642
4627
  content: l,
4643
4628
  currentBreakpoint: i,
4644
- breakpoint: c,
4645
- width: d,
4629
+ breakpoint: d,
4630
+ width: c,
4646
4631
  icon: p,
4647
4632
  onClick: u
4648
4633
  }) => {
@@ -4651,10 +4636,10 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
4651
4636
  /* @__PURE__ */ jsx(HoverCardTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
4652
4637
  Button,
4653
4638
  {
4654
- onClick: () => u(d),
4639
+ onClick: () => u(c),
4655
4640
  size: "sm",
4656
4641
  className: "h-7 w-7 rounded-md p-1",
4657
- variant: c === i ? "outline" : "ghost",
4642
+ variant: d === i ? "outline" : "ghost",
4658
4643
  children: p
4659
4644
  }
4660
4645
  ) }),
@@ -4665,10 +4650,10 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
4665
4650
  ] }) : /* @__PURE__ */ jsx(
4666
4651
  Button,
4667
4652
  {
4668
- onClick: () => u(d),
4653
+ onClick: () => u(c),
4669
4654
  size: "sm",
4670
4655
  className: "h-7 w-7 rounded-md p-1",
4671
- variant: c === i ? "outline" : "ghost",
4656
+ variant: d === i ? "outline" : "ghost",
4672
4657
  children: p
4673
4658
  }
4674
4659
  );
@@ -4677,10 +4662,10 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
4677
4662
  canvas: r = !1,
4678
4663
  tooltip: n = !0
4679
4664
  }) => {
4680
- const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: f } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), h = (b) => {
4665
+ const [a, , l] = useScreenSizeWidth(), [i, d] = useCanvasDisplayWidth(), [c, p] = useSelectedBreakpoints(), u = c, g = p, { t: f } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), h = (b) => {
4681
4666
  u.includes(b) ? u.length > 2 && g(u.filter((S) => S !== b)) : g((S) => [...S, b]);
4682
4667
  }, x = (b) => {
4683
- r || l(b), c(b);
4668
+ r || l(b), d(b);
4684
4669
  }, k = getBreakpointValue(r ? i : a).toLowerCase();
4685
4670
  return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
4686
4671
  BreakpointCard,
@@ -4760,7 +4745,7 @@ function Countdown() {
4760
4745
  useEffect(() => {
4761
4746
  o === SECONDS && l();
4762
4747
  }, [o]);
4763
- const i = 18, c = 2 * Math.PI * i, d = c * (1 - (SECONDS - o) / SECONDS);
4748
+ const i = 18, d = 2 * Math.PI * i, c = d * (1 - (SECONDS - o) / SECONDS);
4764
4749
  return /* @__PURE__ */ jsxs("div", { className: "relative h-4 w-4", children: [
4765
4750
  /* @__PURE__ */ jsxs("svg", { className: "h-full w-full", viewBox: "0 0 40 40", children: [
4766
4751
  /* @__PURE__ */ jsx(
@@ -4780,8 +4765,8 @@ function Countdown() {
4780
4765
  {
4781
4766
  className: "text-blue-600",
4782
4767
  strokeWidth: "4",
4783
- strokeDasharray: c,
4784
- strokeDashoffset: d,
4768
+ strokeDasharray: d,
4769
+ strokeDashoffset: c,
4785
4770
  strokeLinecap: "round",
4786
4771
  stroke: "currentColor",
4787
4772
  fill: "transparent",
@@ -4795,23 +4780,23 @@ function Countdown() {
4795
4780
  ] });
4796
4781
  }
4797
4782
  const AskAIStyles = ({ blockId: o }) => {
4798
- const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
4783
+ const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, d] = useState(""), c = useRef(null), p = useRef(null), [u, g] = useState();
4799
4784
  useEffect(() => {
4800
4785
  var m;
4801
- (m = d.current) == null || m.focus();
4786
+ (m = c.current) == null || m.focus();
4802
4787
  }, []);
4803
4788
  const f = (m) => {
4804
4789
  const { usage: h } = m || {};
4805
- !l && h && g(h), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
4790
+ !l && h && g(h), p.current = setTimeout(() => g(void 0), 1e4), l || d("");
4806
4791
  };
4807
4792
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
4808
4793
  /* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: r("Ask AI") }),
4809
4794
  /* @__PURE__ */ jsx(
4810
4795
  Textarea,
4811
4796
  {
4812
- ref: d,
4797
+ ref: c,
4813
4798
  value: i,
4814
- onChange: (m) => c(m.target.value),
4799
+ onChange: (m) => d(m.target.value),
4815
4800
  placeholder: r("Ask AI to edit styles"),
4816
4801
  className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
4817
4802
  rows: 4,
@@ -4858,11 +4843,11 @@ const AskAIStyles = ({ blockId: o }) => {
4858
4843
  };
4859
4844
  function ManualClasses() {
4860
4845
  var T;
4861
- const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [h, x] = useState(""), k = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), S = b.split(" ").filter((I) => !isEmpty(I)), w = () => {
4862
- const I = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
4863
- u(f, I, !0), x("");
4864
- }, [A, E] = useState([]), C = ({ value: I }) => {
4865
- const P = I.trim().toLowerCase(), N = P.match(/.+:/g);
4846
+ const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: d } = useTranslation(), [c] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [h, x] = useState(""), k = (T = first(c)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), S = b.split(" ").filter((L) => !isEmpty(L)), w = () => {
4847
+ const L = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
4848
+ u(f, L, !0), x("");
4849
+ }, [A, E] = useState([]), C = ({ value: L }) => {
4850
+ const P = L.trim().toLowerCase(), N = P.match(/.+:/g);
4866
4851
  let D = [];
4867
4852
  if (N && N.length > 0) {
4868
4853
  const [O] = N, R = P.replace(O, "");
@@ -4875,46 +4860,46 @@ function ManualClasses() {
4875
4860
  return E(map(D, "item"));
4876
4861
  }, B = () => {
4877
4862
  E([]);
4878
- }, _ = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), v = useMemo(
4863
+ }, _ = (L) => L.name, I = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), v = useMemo(
4879
4864
  () => ({
4880
4865
  ref: o,
4881
4866
  autoComplete: "off",
4882
4867
  autoCorrect: "off",
4883
4868
  autoCapitalize: "off",
4884
4869
  spellCheck: !1,
4885
- placeholder: c("Enter classes separated by space"),
4870
+ placeholder: d("Enter classes separated by space"),
4886
4871
  value: h,
4887
- onKeyDown: (I) => {
4888
- I.key === "Enter" && h.trim() !== "" && w();
4872
+ onKeyDown: (L) => {
4873
+ L.key === "Enter" && h.trim() !== "" && w();
4889
4874
  },
4890
- onChange: (I, { newValue: P }) => x(P),
4875
+ onChange: (L, { newValue: P }) => x(P),
4891
4876
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
4892
4877
  }),
4893
- [h, c, o]
4894
- ), y = (I) => {
4878
+ [h, d, o]
4879
+ ), y = (L) => {
4895
4880
  debugger;
4896
4881
  const P = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
4897
- g(f, [I]), u(f, P, !0), n(""), l(-1);
4882
+ g(f, [L]), u(f, P, !0), n(""), l(-1);
4898
4883
  }, j = () => {
4899
4884
  if (navigator.clipboard === void 0) {
4900
- toast.error(c("Clipboard not supported"));
4885
+ toast.error(d("Clipboard not supported"));
4901
4886
  return;
4902
4887
  }
4903
- navigator.clipboard.writeText(S.join(" ")), toast.success(c("Classes copied to clipboard"));
4888
+ navigator.clipboard.writeText(S.join(" ")), toast.success(d("Classes copied to clipboard"));
4904
4889
  };
4905
4890
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
4906
4891
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
4907
4892
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
4908
- /* @__PURE__ */ jsx("span", { children: c("Classes") }),
4893
+ /* @__PURE__ */ jsx("span", { children: d("Classes") }),
4909
4894
  /* @__PURE__ */ jsxs(Tooltip, { children: [
4910
4895
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: j, className: "cursor-pointer" }) }),
4911
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
4896
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: d("Copy classes to clipboard") }) })
4912
4897
  ] })
4913
4898
  ] }),
4914
4899
  m ? /* @__PURE__ */ jsxs(Popover, { children: [
4915
4900
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
4916
4901
  /* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
4917
- /* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
4902
+ /* @__PURE__ */ jsx("span", { className: "ml-2", children: d("Ask AI") })
4918
4903
  ] }) }),
4919
4904
  /* @__PURE__ */ jsx(PopoverContent, { side: "left", className: "p-2", children: /* @__PURE__ */ jsx(AskAIStyles, { blockId: p == null ? void 0 : p._id }) })
4920
4905
  ] }) : null
@@ -4927,7 +4912,7 @@ function ManualClasses() {
4927
4912
  onSuggestionsFetchRequested: C,
4928
4913
  onSuggestionsClearRequested: B,
4929
4914
  getSuggestionValue: _,
4930
- renderSuggestion: L,
4915
+ renderSuggestion: I,
4931
4916
  inputProps: v,
4932
4917
  containerProps: {
4933
4918
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
@@ -4952,37 +4937,37 @@ function ManualClasses() {
4952
4937
  )
4953
4938
  ] }),
4954
4939
  /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: S.map(
4955
- (I, P) => a === P ? /* @__PURE__ */ jsx(
4940
+ (L, P) => a === P ? /* @__PURE__ */ jsx(
4956
4941
  "input",
4957
4942
  {
4958
4943
  ref: o,
4959
4944
  value: r,
4960
4945
  onChange: (N) => n(N.target.value),
4961
4946
  onBlur: () => {
4962
- y(I);
4947
+ y(L);
4963
4948
  },
4964
4949
  onKeyDown: (N) => {
4965
- N.key === "Enter" && y(I);
4950
+ N.key === "Enter" && y(L);
4966
4951
  },
4967
4952
  className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
4968
4953
  },
4969
- I
4954
+ L
4970
4955
  ) : /* @__PURE__ */ jsxs(
4971
4956
  "button",
4972
4957
  {
4973
4958
  className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",
4974
4959
  children: [
4975
- I,
4976
- r !== I && /* @__PURE__ */ jsx(
4960
+ L,
4961
+ r !== L && /* @__PURE__ */ jsx(
4977
4962
  Cross2Icon,
4978
4963
  {
4979
- onClick: () => g(f, [I], !0),
4964
+ onClick: () => g(f, [L], !0),
4980
4965
  className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
4981
4966
  }
4982
4967
  )
4983
4968
  ]
4984
4969
  },
4985
- I
4970
+ L
4986
4971
  )
4987
4972
  ) })
4988
4973
  ] });
@@ -5076,26 +5061,26 @@ const BlockStylingProps = () => {
5076
5061
  const o = useSelectedBlock(), [r, n] = useSelectedStylingBlocks(), { t: a } = useTranslation();
5077
5062
  if (!o) return null;
5078
5063
  const l = Object.keys(o).filter(
5079
- (c) => typeof o[c] == "string" && o[c].startsWith("#styles:")
5064
+ (d) => typeof o[d] == "string" && o[d].startsWith("#styles:")
5080
5065
  );
5081
5066
  if (isEmpty(l) || l.length <= 1) return null;
5082
- const i = (c) => find(r, (d) => d.prop === c);
5067
+ const i = (d) => find(r, (c) => c.prop === d);
5083
5068
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
5084
5069
  /* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
5085
5070
  a("Style element"),
5086
5071
  ":"
5087
5072
  ] }),
5088
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(l, (c) => /* @__PURE__ */ jsx(
5073
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(l, (d) => /* @__PURE__ */ jsx(
5089
5074
  Badge,
5090
5075
  {
5091
5076
  className: "cursor-pointer",
5092
5077
  onClick: () => {
5093
- n([{ id: `${c}-${o._id}`, blockId: o._id, prop: c }]);
5078
+ n([{ id: `${d}-${o._id}`, blockId: o._id, prop: d }]);
5094
5079
  },
5095
- variant: i(c) ? "default" : "secondary",
5096
- children: startCase(c)
5080
+ variant: i(d) ? "default" : "secondary",
5081
+ children: startCase(d)
5097
5082
  },
5098
- c
5083
+ d
5099
5084
  )) }),
5100
5085
  /* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
5101
5086
  ] });
@@ -5103,9 +5088,9 @@ const BlockStylingProps = () => {
5103
5088
  // eslint-disable-next-line react/jsx-no-constructed-context-values
5104
5089
  /* @__PURE__ */ jsx(StyleContext.Provider, { value: { canReset: r, canChange: n }, children: o })
5105
5090
  ), DropDownChoices = ({ label: o, property: r, onChange: n }) => {
5106
- const { getClasses: a } = useTailwindClassList(), l = a(r), i = useCurrentClassByProperty(r), c = useMemo(() => get(i, "cls", ""), [i]), { canChange: d } = useContext(StyleContext), p = /\[.*\]/g.test(c);
5091
+ const { getClasses: a } = useTailwindClassList(), l = a(r), i = useCurrentClassByProperty(r), d = useMemo(() => get(i, "cls", ""), [i]), { canChange: c } = useContext(StyleContext), p = /\[.*\]/g.test(d);
5107
5092
  return /* @__PURE__ */ jsx("div", { className: o ? "w-full rounded" : "grow", children: p ? /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
5108
- /* @__PURE__ */ jsx(Input$1, { className: "w-[70%] rounded py-1", readOnly: !0, value: c }),
5093
+ /* @__PURE__ */ jsx(Input$1, { className: "w-[70%] rounded py-1", readOnly: !0, value: d }),
5109
5094
  /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5110
5095
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsx(InfoCircledIcon, {}) }) }),
5111
5096
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind arbitrary value." })
@@ -5115,14 +5100,14 @@ const BlockStylingProps = () => {
5115
5100
  {
5116
5101
  rounded: o,
5117
5102
  onChange: (u) => n(u, r),
5118
- selected: c,
5103
+ selected: d,
5119
5104
  options: l,
5120
- disabled: !d
5105
+ disabled: !c
5121
5106
  }
5122
5107
  ) });
5123
5108
  };
5124
5109
  function DropDown({ selected: o, onChange: r, rounded: n = !1, options: a, disabled: l = !1 }) {
5125
- const i = o.replace(/.*:/g, "").trim(), { undo: c, redo: d } = useUndoManager();
5110
+ const i = o.replace(/.*:/g, "").trim(), { undo: d, redo: c } = useUndoManager();
5126
5111
  return /* @__PURE__ */ jsxs(
5127
5112
  "select",
5128
5113
  {
@@ -5130,7 +5115,7 @@ function DropDown({ selected: o, onChange: r, rounded: n = !1, options: a, disab
5130
5115
  className: `${n ? "rounded-md border border-border" : "border-0"} disable:bg-gray-500 h-full w-full truncate rounded bg-background px-2 py-1 text-xs outline-none disabled:cursor-not-allowed`,
5131
5116
  onChange: (p) => r(p.target.value),
5132
5117
  onKeyDown: (p) => {
5133
- p.ctrlKey && (p.key === "z" && c(), p.key === "y" && d());
5118
+ p.ctrlKey && (p.key === "z" && d(), p.key === "y" && c());
5134
5119
  },
5135
5120
  value: i,
5136
5121
  children: [
@@ -5153,17 +5138,17 @@ const COLOR_PROP = {
5153
5138
  ringColor: "ring",
5154
5139
  ringOffsetColor: "ring-offset"
5155
5140
  }, ColorChoice = ({ property: o, onChange: r }) => {
5156
- const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), f = get(u, "2", ""), m = useCallback(
5141
+ const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, d] = useState([]), [c, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), f = get(u, "2", ""), m = useCallback(
5157
5142
  // eslint-disable-next-line no-shadow
5158
5143
  (k) => {
5159
- ["current", "inherit", "transparent", "black", "white"].includes(k) ? (c([]), p({ color: k })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: k, shade: b.shade ? b.shade : "500" })));
5144
+ ["current", "inherit", "transparent", "black", "white"].includes(k) ? (d([]), p({ color: k })) : (d(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: k, shade: b.shade ? b.shade : "500" })));
5160
5145
  },
5161
- [c, p]
5146
+ [d, p]
5162
5147
  );
5163
5148
  useEffect(() => {
5164
5149
  if (["current", "inherit", "transparent", "black", "white"].includes(g))
5165
- return c([]);
5166
- c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
5150
+ return d([]);
5151
+ d(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
5167
5152
  }, [g]);
5168
5153
  const h = useCallback(
5169
5154
  // eslint-disable-next-line no-shadow
@@ -5177,9 +5162,9 @@ const COLOR_PROP = {
5177
5162
  }, [n]);
5178
5163
  const { match: x } = useTailwindClassList();
5179
5164
  return useEffect(() => {
5180
- const b = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
5165
+ const b = `${get(COLOR_PROP, o, "")}-${c.color}${c.shade ? `-${c.shade}` : ""}`;
5181
5166
  x(o, b) && r(b, o);
5182
- }, [x, d, r, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
5167
+ }, [x, c, r, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
5183
5168
  /* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
5184
5169
  DropDown,
5185
5170
  {
@@ -5416,22 +5401,22 @@ const COLOR_PROP = {
5416
5401
  ] }),
5417
5402
  static: Cross1Icon
5418
5403
  }, IconChoices = ({ property: o, onChange: r }) => {
5419
- const { getClasses: n } = useTailwindClassList(), a = n(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
5420
- return /* @__PURE__ */ jsx("div", { className: "flex grow flex-wrap gap-1", children: map(a, (d) => /* @__PURE__ */ jsxs(Tooltip, { children: [
5404
+ const { getClasses: n } = useTailwindClassList(), a = n(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), d = useMemo(() => get(i, "cls", ""), [i]);
5405
+ return /* @__PURE__ */ jsx("div", { className: "flex grow flex-wrap gap-1", children: map(a, (c) => /* @__PURE__ */ jsxs(Tooltip, { children: [
5421
5406
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5422
5407
  "button",
5423
5408
  {
5424
5409
  type: "button",
5425
5410
  disabled: !l,
5426
- onClick: () => r(d, o),
5427
- className: `cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${c === d ? "bg-primary text-white" : "disabled:bg-gray-600 disabled:text-gray-400"}`,
5428
- children: React__default.createElement(get(EDITOR_ICONS, d, BoxIcon))
5411
+ onClick: () => r(c, o),
5412
+ className: `cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${d === c ? "bg-primary text-white" : "disabled:bg-gray-600 disabled:text-gray-400"}`,
5413
+ children: React__default.createElement(get(EDITOR_ICONS, c, BoxIcon))
5429
5414
  }
5430
5415
  ) }),
5431
- /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(d)) })
5416
+ /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(c)) })
5432
5417
  ] })) });
5433
5418
  }, RangeChoices = ({ property: o, onChange: r }) => {
5434
- const { canReset: n, canChange: a } = useContext(StyleContext), l = useCurrentClassByProperty(o), i = useMemo(() => get(l, "cls", ""), [l]), { getClasses: c } = useTailwindClassList(), d = c(o, [""]), p = d.indexOf(i) > -1 ? d.indexOf(i) : 0, u = /\[.*\]/g.test(i);
5419
+ const { canReset: n, canChange: a } = useContext(StyleContext), l = useCurrentClassByProperty(o), i = useMemo(() => get(l, "cls", ""), [l]), { getClasses: d } = useTailwindClassList(), c = d(o, [""]), p = c.indexOf(i) > -1 ? c.indexOf(i) : 0, u = /\[.*\]/g.test(i);
5435
5420
  return /* @__PURE__ */ jsx("div", { className: "flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs", children: u ? /* @__PURE__ */ jsx("div", { className: "px-2 py-[5px]", children: i }) : /* @__PURE__ */ jsxs(Fragment, { children: [
5436
5421
  /* @__PURE__ */ jsx(
5437
5422
  "button",
@@ -5439,7 +5424,7 @@ const COLOR_PROP = {
5439
5424
  type: "button",
5440
5425
  className: "hover:bg-bg-gray-700 box-border w-2/12 rounded-bl rounded-tl bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",
5441
5426
  disabled: !a && (!n || p - 1 < 0),
5442
- onClick: () => r(nth(d, p - 1), o),
5427
+ onClick: () => r(nth(c, p - 1), o),
5443
5428
  children: /* @__PURE__ */ jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
5444
5429
  MinusIcon,
5445
5430
  {
@@ -5454,12 +5439,12 @@ const COLOR_PROP = {
5454
5439
  {
5455
5440
  type: "button",
5456
5441
  className: "hover:bg-bg-gray-700 w-2/12 rounded-br rounded-tr bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",
5457
- disabled: !a && (!n || p + 1 >= d.length),
5458
- onClick: () => r(nth(d, p + 1), o),
5442
+ disabled: !a && (!n || p + 1 >= c.length),
5443
+ onClick: () => r(nth(c, p + 1), o),
5459
5444
  children: /* @__PURE__ */ jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
5460
5445
  PlusIcon,
5461
5446
  {
5462
- className: !a && (!n || p + 1 >= d.length) ? "text-gray-500" : "text-black/60 dark:text-white/60"
5447
+ className: !a && (!n || p + 1 >= c.length) ? "text-gray-500" : "text-black/60 dark:text-white/60"
5463
5448
  }
5464
5449
  ) })
5465
5450
  }
@@ -5472,8 +5457,8 @@ const COLOR_PROP = {
5472
5457
  return { value: "", unit: n };
5473
5458
  const a = r.length ? new RegExp(r.join("|"), "g") : /XXXXXX/g;
5474
5459
  n = n.replace(a, "");
5475
- const l = o.match(a), i = l && l.length > 1, c = !isEmpty(n) && Number.isNaN(Number(n));
5476
- return i || c ? { error: "Invalid value" } : l && (l[0] === "auto" || l[0] === "none") ? { value: l[0], unit: "" } : { value: n, unit: l ? l[0] : "" };
5460
+ const l = o.match(a), i = l && l.length > 1, d = !isEmpty(n) && Number.isNaN(Number(n));
5461
+ return i || d ? { error: "Invalid value" } : l && (l[0] === "auto" || l[0] === "none") ? { value: l[0], unit: "" } : { value: n, unit: l ? l[0] : "" };
5477
5462
  }, getTwClassValue = (o) => {
5478
5463
  const r = o.startsWith("-") ? "-" : "", n = o.split("-").pop();
5479
5464
  if (["auto", "none"].includes(n))
@@ -5572,9 +5557,9 @@ const COLOR_PROP = {
5572
5557
  onDragEnd: a,
5573
5558
  onDragStart: l,
5574
5559
  negative: i,
5575
- cssProperty: c
5560
+ cssProperty: d
5576
5561
  }) => {
5577
- const { setDragData: d } = useContext(BlockSettingsContext);
5562
+ const { setDragData: c } = useContext(BlockSettingsContext);
5578
5563
  return /* @__PURE__ */ jsx(
5579
5564
  "button",
5580
5565
  {
@@ -5588,9 +5573,9 @@ const COLOR_PROP = {
5588
5573
  dragStartValue: `${r}`,
5589
5574
  dragUnit: o,
5590
5575
  negative: i,
5591
- cssProperty: c
5576
+ cssProperty: d
5592
5577
  };
5593
- l(u), d(u);
5578
+ l(u), c(u);
5594
5579
  },
5595
5580
  color: void 0,
5596
5581
  className: "relative z-50 ml-1 hidden h-6 cursor-row-resize rounded bg-background/70 px-2 group-hover:inline",
@@ -5610,7 +5595,7 @@ const COLOR_PROP = {
5610
5595
  },
5611
5596
  a
5612
5597
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5613
- const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [f, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [h, x] = useState(!1), [k, b] = useState(""), [S, w] = useState(!1), [A, E] = useState(!1);
5598
+ const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: d, classPrefix: c, cssProperty: p, units: u, negative: g } = o, [f, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [h, x] = useState(!1), [k, b] = useState(""), [S, w] = useState(!1), [A, E] = useState(!1);
5614
5599
  useEffect(() => {
5615
5600
  const { value: v, unit: y } = getClassValueAndUnit(i);
5616
5601
  if (y === "") {
@@ -5619,7 +5604,7 @@ const COLOR_PROP = {
5619
5604
  }
5620
5605
  m(y), l(y === "class" || isEmpty(v) ? "" : v);
5621
5606
  }, [i, p, u]);
5622
- const C = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), B = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), _ = useCallback(
5607
+ const C = useThrottledCallback((v) => d(v), [d], THROTTLE_TIME), B = useThrottledCallback((v) => d(v, !1), [d], THROTTLE_TIME), _ = useCallback(
5623
5608
  (v = !1) => {
5624
5609
  const y = getUserInputValues(`${a}`, u);
5625
5610
  if (get(y, "error", !1)) {
@@ -5628,16 +5613,16 @@ const COLOR_PROP = {
5628
5613
  }
5629
5614
  const j = get(y, "unit") !== "" ? get(y, "unit") : f;
5630
5615
  if (j === "auto" || j === "none") {
5631
- C(`${d}${j}`);
5616
+ C(`${c}${j}`);
5632
5617
  return;
5633
5618
  }
5634
5619
  if (get(y, "value") === "")
5635
5620
  return;
5636
- const I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5637
- v ? B(I) : C(I);
5621
+ const L = `${get(y, "value", "").startsWith("-") ? "-" : ""}${c}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5622
+ v ? B(L) : C(L);
5638
5623
  },
5639
- [C, B, a, f, d, u]
5640
- ), L = useCallback(
5624
+ [C, B, a, f, c, u]
5625
+ ), I = useCallback(
5641
5626
  (v) => {
5642
5627
  const y = getUserInputValues(`${a}`, u);
5643
5628
  if (get(y, "error", !1)) {
@@ -5645,15 +5630,15 @@ const COLOR_PROP = {
5645
5630
  return;
5646
5631
  }
5647
5632
  if (v === "auto" || v === "none") {
5648
- C(`${d}${v}`);
5633
+ C(`${c}${v}`);
5649
5634
  return;
5650
5635
  }
5651
5636
  if (get(y, "value") === "")
5652
5637
  return;
5653
- const j = get(y, "unit") !== "" ? get(y, "unit") : v, I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5654
- C(I);
5638
+ const j = get(y, "unit") !== "" ? get(y, "unit") : v, L = `${get(y, "value", "").startsWith("-") ? "-" : ""}${c}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5639
+ C(L);
5655
5640
  },
5656
- [C, a, d, u]
5641
+ [C, a, c, u]
5657
5642
  );
5658
5643
  return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: f === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5659
5644
  /* @__PURE__ */ jsx(
@@ -5684,7 +5669,7 @@ const COLOR_PROP = {
5684
5669
  const y = parseInt$1(v.target.value);
5685
5670
  let j = isNaN$1(y) ? 0 : y;
5686
5671
  v.keyCode === 38 && (j += 1), v.keyCode === 40 && (j -= 1);
5687
- const T = `${j}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${f === "-" ? "" : f}]`;
5672
+ const T = `${j}`, P = `${T.startsWith("-") ? "-" : ""}${c}[${T.replace("-", "")}${f === "-" ? "" : f}]`;
5688
5673
  B(P);
5689
5674
  },
5690
5675
  onKeyUp: (v) => {
@@ -5724,7 +5709,7 @@ const COLOR_PROP = {
5724
5709
  units: u,
5725
5710
  current: f,
5726
5711
  onSelect: (v) => {
5727
- n(!1), m(v), L(v);
5712
+ n(!1), m(v), I(v);
5728
5713
  }
5729
5714
  }
5730
5715
  ) }) })
@@ -5737,14 +5722,14 @@ const COLOR_PROP = {
5737
5722
  onDragEnd: (v) => {
5738
5723
  if (b(() => ""), w(!1), isEmpty(v))
5739
5724
  return;
5740
- const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${f === "-" ? "" : f}]`;
5725
+ const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${c}[${y.replace("-", "")}${f === "-" ? "" : f}]`;
5741
5726
  C(T);
5742
5727
  },
5743
5728
  onDrag: (v) => {
5744
5729
  if (isEmpty(v))
5745
5730
  return;
5746
5731
  b(v);
5747
- const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${f === "-" ? "" : f}]`;
5732
+ const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${c}[${y.replace("-", "")}${f === "-" ? "" : f}]`;
5748
5733
  B(T);
5749
5734
  },
5750
5735
  currentValue: a,
@@ -5842,11 +5827,11 @@ const COLOR_PROP = {
5842
5827
  "2xl": "1536px"
5843
5828
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
5844
5829
  const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
5845
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), f = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), k = useMemo(() => get(f, "fullCls", ""), [f]), b = useCallback(
5830
+ }, units: d, negative: c = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), f = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), k = useMemo(() => get(f, "fullCls", ""), [f]), b = useCallback(
5846
5831
  (B, _ = !0) => {
5847
- const L = { dark: p, mq: g, mod: u, cls: B, property: l, fullCls: "" };
5848
- (p || u !== "") && (L.mq = "xs");
5849
- const v = generateFullClsName(L);
5832
+ const I = { dark: p, mq: g, mod: u, cls: B, property: l, fullCls: "" };
5833
+ (p || u !== "") && (I.mq = "xs");
5834
+ const v = generateFullClsName(I);
5850
5835
  m(x, [v], _);
5851
5836
  },
5852
5837
  [x, p, g, u, l, m]
@@ -5878,9 +5863,9 @@ const COLOR_PROP = {
5878
5863
  {
5879
5864
  currentClass: get(f, "cls", ""),
5880
5865
  classPrefix: get(CLASS_PREFIXES, l, ""),
5881
- units: c || [],
5866
+ units: d || [],
5882
5867
  onChange: b,
5883
- negative: d,
5868
+ negative: c,
5884
5869
  cssProperty: l
5885
5870
  }
5886
5871
  ) : null,
@@ -5928,16 +5913,16 @@ const COLOR_PROP = {
5928
5913
  borderT: a = !1,
5929
5914
  type: l = "arbitrary",
5930
5915
  units: i = basicUnits,
5931
- negative: c = !1
5916
+ negative: d = !1
5932
5917
  }) => {
5933
- const { t: d } = useTranslation(), [p, u] = useState(r[0].key), g = useSelectedBlockCurrentClasses(), f = useCallback((m) => map(g, "property").includes(m), [g]);
5918
+ const { t: c } = useTranslation(), [p, u] = useState(r[0].key), g = useSelectedBlockCurrentClasses(), f = useCallback((m) => map(g, "property").includes(m), [g]);
5934
5919
  return /* @__PURE__ */ jsxs(
5935
5920
  "div",
5936
5921
  {
5937
5922
  className: `mb-2 border-border py-2 first:pt-0 last:pb-0 ${n ? "border-b" : ""} ${a ? "border-t" : ""}`,
5938
5923
  children: [
5939
5924
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
5940
- o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
5925
+ o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: c(o) }),
5941
5926
  /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: m, key: h }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5942
5927
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
5943
5928
  "button",
@@ -5963,7 +5948,7 @@ const COLOR_PROP = {
5963
5948
  units: [...i],
5964
5949
  label: "",
5965
5950
  property: p,
5966
- negative: c
5951
+ negative: d
5967
5952
  }
5968
5953
  ) })
5969
5954
  ]
@@ -5973,10 +5958,10 @@ const COLOR_PROP = {
5973
5958
  const { t: n } = useTranslation(), a = useSelectedBlockCurrentClasses(), l = useMemo(() => {
5974
5959
  const i = (p) => flatten(
5975
5960
  p.map((u) => u.styleType === "multiple" ? map(u.options, "key") : u.property)
5976
- ), c = flatten(
5961
+ ), d = flatten(
5977
5962
  r.map((p) => p.styleType === "accordion" ? i(p.items) : p.styleType === "multiple" ? map(p.options, "key") : p.property)
5978
- ), d = map(a, "property");
5979
- return intersection(c, d).length > 0;
5963
+ ), c = map(a, "property");
5964
+ return intersection(d, c).length > 0;
5980
5965
  }, [a, r]);
5981
5966
  return /* @__PURE__ */ jsxs("details", { children: [
5982
5967
  /* @__PURE__ */ jsx("summary", { className: "my-px cursor-default rounded-md bg-gray-50 p-px px-2 text-[11px] text-foreground dark:bg-gray-800", children: /* @__PURE__ */ jsxs("div", { className: "inline", children: [
@@ -5992,13 +5977,13 @@ const COLOR_PROP = {
5992
5977
  ] });
5993
5978
  }, SectionContext = createContext({}), StylingGroup = ({ section: o, showAccordian: r }) => {
5994
5979
  const { t: n } = useTranslation(), a = useSelectedBlockCurrentClasses(), l = useCallback(
5995
- (c = []) => {
5996
- const d = {};
5980
+ (d = []) => {
5981
+ const c = {};
5997
5982
  for (let u = 0; u < a.length; u++)
5998
- d[a[u].property] = a[u].cls;
5983
+ c[a[u].property] = a[u].cls;
5999
5984
  let p = !0;
6000
- for (const u in c)
6001
- if (!has(d, u) || d[u] !== c[u]) {
5985
+ for (const u in d)
5986
+ if (!has(c, u) || c[u] !== d[u]) {
6002
5987
  p = !1;
6003
5988
  break;
6004
5989
  }
@@ -6008,8 +5993,8 @@ const COLOR_PROP = {
6008
5993
  ), i = useMemo(() => ({}), []);
6009
5994
  return /* @__PURE__ */ jsx(SectionContext.Provider, { value: i, children: r ? /* @__PURE__ */ jsxs(AccordionItem, { value: o.heading, className: "border-none", children: [
6010
5995
  /* @__PURE__ */ jsx(AccordionTrigger, { className: "border-slate-150 border-t py-2 text-xs", children: /* @__PURE__ */ jsx("div", { className: "flex items-center py-2", children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-x-2 text-xs font-medium", children: startCase(n(o.heading)) }) }) }),
6011
- /* @__PURE__ */ jsx(AccordionContent, { className: "py-2", children: o.items.map((c) => has(c, "component") ? React__default.createElement(c.component, { key: c.label }) : has(c, "styleType") ? c.styleType === "multiple" ? /* @__PURE__ */ jsx(MultipleChoices, { ...c }, c.label + "multiple-choices") : c.styleType === "accordion" && l(c == null ? void 0 : c.conditions) ? /* @__PURE__ */ jsx(NestedOptions, { ...c }, c.label + "nested-options") : null : /* @__PURE__ */ jsx(BlockStyle, { ...c }, c.label + "block-style")) })
6012
- ] }) : /* @__PURE__ */ jsx("div", { className: "py-2", children: o.items.map((c, d) => has(c, "component") ? React__default.createElement(c.component, { key: c.label }) : has(c, "styleType") ? c.styleType === "multiple" ? /* @__PURE__ */ jsx(MultipleChoices, { ...c }, c.label + "multiple-choices" + d) : c.styleType === "accordion" && l(c == null ? void 0 : c.conditions) ? /* @__PURE__ */ jsx(NestedOptions, { ...c }, c.label + "nested-options" + d) : null : /* @__PURE__ */ jsx(BlockStyle, { ...c }, c.label + "block-style" + d)) }) });
5996
+ /* @__PURE__ */ jsx(AccordionContent, { className: "py-2", children: o.items.map((d) => has(d, "component") ? React__default.createElement(d.component, { key: d.label }) : has(d, "styleType") ? d.styleType === "multiple" ? /* @__PURE__ */ jsx(MultipleChoices, { ...d }, d.label + "multiple-choices") : d.styleType === "accordion" && l(d == null ? void 0 : d.conditions) ? /* @__PURE__ */ jsx(NestedOptions, { ...d }, d.label + "nested-options") : null : /* @__PURE__ */ jsx(BlockStyle, { ...d }, d.label + "block-style")) })
5997
+ ] }) : /* @__PURE__ */ jsx("div", { className: "py-2", children: o.items.map((d, c) => has(d, "component") ? React__default.createElement(d.component, { key: d.label }) : has(d, "styleType") ? d.styleType === "multiple" ? /* @__PURE__ */ jsx(MultipleChoices, { ...d }, d.label + "multiple-choices" + c) : d.styleType === "accordion" && l(d == null ? void 0 : d.conditions) ? /* @__PURE__ */ jsx(NestedOptions, { ...d }, d.label + "nested-options" + c) : null : /* @__PURE__ */ jsx(BlockStyle, { ...d }, d.label + "block-style" + c)) }) });
6013
5998
  }, MAPPER = {
6014
5999
  px: 1,
6015
6000
  "%": 1,
@@ -6023,7 +6008,7 @@ const COLOR_PROP = {
6023
6008
  ms: 0.1
6024
6009
  };
6025
6010
  function BlockStyling() {
6026
- const { flexChild: o, gridChild: r } = useSelectedBlocksDisplayChild(), [n] = useSelectedStylingBlocks(), [a, l] = React__default.useState(""), [i, c] = React__default.useState({
6011
+ const { flexChild: o, gridChild: r } = useSelectedBlocksDisplayChild(), [n] = useSelectedStylingBlocks(), [a, l] = React__default.useState(""), [i, d] = React__default.useState({
6027
6012
  onDrag: (u) => u,
6028
6013
  onDragEnd: (u) => u,
6029
6014
  dragStartY: 0,
@@ -6032,7 +6017,7 @@ function BlockStyling() {
6032
6017
  dragUnit: "",
6033
6018
  negative: !1,
6034
6019
  cssProperty: ""
6035
- }), d = useThrottledCallback(
6020
+ }), c = useThrottledCallback(
6036
6021
  (u) => {
6037
6022
  const g = !get(i, "negative", !1), f = get(i, "cssProperty", "");
6038
6023
  let m = parseFloat(i.dragStartValue);
@@ -6045,7 +6030,7 @@ function BlockStyling() {
6045
6030
  [i],
6046
6031
  50
6047
6032
  ), p = useCallback(() => {
6048
- setTimeout(() => i.onDragEnd(`${a}`), 100), c({
6033
+ setTimeout(() => i.onDragEnd(`${a}`), 100), d({
6049
6034
  onDrag: (u) => u,
6050
6035
  onDragEnd: (u) => u,
6051
6036
  dragStartY: 0,
@@ -6055,12 +6040,12 @@ function BlockStyling() {
6055
6040
  negative: !1,
6056
6041
  cssProperty: ""
6057
6042
  });
6058
- }, [i, a, c]);
6059
- return isEmpty(n) ? null : /* @__PURE__ */ jsxs(BlockSettingsContext.Provider, { value: { setDragData: c }, children: [
6043
+ }, [i, a, d]);
6044
+ return isEmpty(n) ? null : /* @__PURE__ */ jsxs(BlockSettingsContext.Provider, { value: { setDragData: d }, children: [
6060
6045
  i.dragging ? /* @__PURE__ */ jsx(
6061
6046
  "div",
6062
6047
  {
6063
- onMouseMove: d,
6048
+ onMouseMove: c,
6064
6049
  onMouseUp: () => p(),
6065
6050
  className: "absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"
6066
6051
  }
@@ -6083,7 +6068,7 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6083
6068
  parentId: n,
6084
6069
  position: a
6085
6070
  }) => {
6086
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: f } = useBlockHighlight(), m = () => {
6071
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: d, label: c } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: f } = useBlockHighlight(), m = () => {
6087
6072
  if (console.log("addBlockToPage", o), has(o, "blocks")) {
6088
6073
  const k = isFunction(o.blocks) ? o.blocks() : o.blocks;
6089
6074
  u(syncBlocksWithDefaults(k), n || null, a);
@@ -6106,12 +6091,12 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6106
6091
  draggable: h ? "true" : "false",
6107
6092
  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",
6108
6093
  children: [
6109
- createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
6110
- /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
6094
+ createElement(d || BoxIcon, { className: "w-4 h-4 mx-auto" }),
6095
+ /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(c || i)) })
6111
6096
  ]
6112
6097
  }
6113
6098
  ) }),
6114
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
6099
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(c || i) }) })
6115
6100
  ] }) });
6116
6101
  }, DefaultChaiBlocks = ({
6117
6102
  parentId: o,
@@ -6134,8 +6119,8 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6134
6119
  return r.test(o) || n.test(o);
6135
6120
  }, getVideoURLFromHTML = (o) => {
6136
6121
  if (isEmpty(o)) return o;
6137
- const r = /<video[^>]+src=['"]([^'">]+)['"]/, n = /<iframe[^>]+src=['"]([^'">]+)['"]/, a = o.match(r), l = o.match(n), i = a ? a[1] : l ? l[1] : null, c = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, d = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
6138
- return i && (c.test(i) || d.test(i)) ? i : o;
6122
+ const r = /<video[^>]+src=['"]([^'">]+)['"]/, n = /<iframe[^>]+src=['"]([^'">]+)['"]/, a = o.match(r), l = o.match(n), i = a ? a[1] : l ? l[1] : null, d = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, c = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
6123
+ return i && (d.test(i) || c.test(i)) ? i : o;
6139
6124
  }, NAME_ATTRIBUTES = ["chai-name", "data-chai-name"], ATTRIBUTE_MAP = {
6140
6125
  img: { alt: "alt", width: "width", height: "height", src: "image" },
6141
6126
  video: {
@@ -6182,8 +6167,8 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6182
6167
  if (!includes(NAME_ATTRIBUTES, l))
6183
6168
  if (n[l]) {
6184
6169
  if (o.tagName === "img" && l === "src" && !i.startsWith("http")) {
6185
- const c = find(o.attributes, { key: "width" }), d = find(o.attributes, { key: "height" });
6186
- c && d ? i = `https://via.placeholder.com/${c == null ? void 0 : c.value}x${d == null ? void 0 : d.value}` : i = "https://via.placeholder.com/150x150";
6170
+ const d = find(o.attributes, { key: "width" }), c = find(o.attributes, { key: "height" });
6171
+ d && c ? i = `https://via.placeholder.com/${d == null ? void 0 : d.value}x${c == null ? void 0 : c.value}` : i = "https://via.placeholder.com/150x150";
6187
6172
  }
6188
6173
  set(r, n[l], getSanitizedValue(i));
6189
6174
  } else includes(["style", "class", "srcset"], l) || (has(r, "styles_attrs") || (r.styles_attrs = {}), startsWith(l, "@") && (l = l.replace("@", "x-on:")), r.styles_attrs[`${l}`] = getSanitizedValue(i));
@@ -6197,16 +6182,16 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6197
6182
  }
6198
6183
  return { [r]: `${STYLES_KEY},` };
6199
6184
  }, getBlockProps = (o) => {
6200
- const r = get(o, "attributes", []), n = r.find((d) => d.key === "data-chai-richtext" || d.key === "chai-richtext"), a = r.find((d) => d.key === "data-chai-lightbox" || d.key === "chai-lightbox"), l = r.find((d) => d.key === "data-chai-dropdown" || d.key === "chai-dropdown"), i = r.find(
6201
- (d) => d.key === "data-chai-dropdown-button" || d.key === "chai-dropdown-button"
6202
- ), c = r.find(
6203
- (d) => d.key === "data-chai-dropdown-content" || d.key === "chai-dropdown-content"
6185
+ const r = get(o, "attributes", []), n = r.find((c) => c.key === "data-chai-richtext" || c.key === "chai-richtext"), a = r.find((c) => c.key === "data-chai-lightbox" || c.key === "chai-lightbox"), l = r.find((c) => c.key === "data-chai-dropdown" || c.key === "chai-dropdown"), i = r.find(
6186
+ (c) => c.key === "data-chai-dropdown-button" || c.key === "chai-dropdown-button"
6187
+ ), d = r.find(
6188
+ (c) => c.key === "data-chai-dropdown-content" || c.key === "chai-dropdown-content"
6204
6189
  );
6205
6190
  if (l)
6206
6191
  return { _type: "Dropdown" };
6207
6192
  if (i)
6208
6193
  return { _type: "DropdownButton" };
6209
- if (c)
6194
+ if (d)
6210
6195
  return { _type: "DropdownContent" };
6211
6196
  if (n)
6212
6197
  return { _type: "RichText" };
@@ -6290,11 +6275,11 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6290
6275
  case "tfoot":
6291
6276
  return { _type: "TableFooter" };
6292
6277
  default: {
6293
- const d = get(o, "children", []).length > 0 ? "Box" : "EmptyBox";
6278
+ const c = get(o, "children", []).length > 0 ? "Box" : "EmptyBox";
6294
6279
  return {
6295
- _type: d,
6280
+ _type: c,
6296
6281
  tag: o.tagName,
6297
- _name: d == "EmptyBox" || o.tagName === "div" ? d : capitalize(o.tagName)
6282
+ _name: c == "EmptyBox" || o.tagName === "div" ? c : capitalize(o.tagName)
6298
6283
  };
6299
6284
  }
6300
6285
  }
@@ -6307,9 +6292,9 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6307
6292
  return isEmpty(get(n, "content", "")) ? [] : r && shouldAddText(r.node, r.block) ? (set(r, "block.content", get(n, "content", "")), []) : { ...a, _type: "Text", content: get(n, "content", "") };
6308
6293
  const l = get(n, "attributes", []), i = l.find(
6309
6294
  (A) => A.key === "data-chai-richtext" || A.key === "chai-richtext"
6310
- ), c = l.find(
6311
- (A) => A.key === "data-chai-lightbox" || A.key === "chai-lightbox"
6312
6295
  ), d = l.find(
6296
+ (A) => A.key === "data-chai-lightbox" || A.key === "chai-lightbox"
6297
+ ), c = l.find(
6313
6298
  (A) => A.key === "data-chai-dropdown" || A.key === "chai-dropdown"
6314
6299
  ), p = l.find(
6315
6300
  (A) => A.key === "data-chai-dropdown-button" || A.key === "chai-dropdown-button"
@@ -6327,7 +6312,7 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6327
6312
  }
6328
6313
  if (i)
6329
6314
  return a.content = stringify(n.children), has(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], has(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
6330
- if (c) {
6315
+ if (d) {
6331
6316
  const A = [
6332
6317
  "data-chai-lightbox",
6333
6318
  "chai-lightbox",
@@ -6350,7 +6335,7 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6350
6335
  has(a, `styles_attrs.${E}`) && delete a.styles_attrs[E];
6351
6336
  });
6352
6337
  }
6353
- if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
6338
+ if (c && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
6354
6339
  delete a.styles_attrs;
6355
6340
  const A = filter(n.children || [], (C) => (C == null ? void 0 : C.tagName) !== "span");
6356
6341
  a.content = getTextContent(A);
@@ -6376,7 +6361,7 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6376
6361
  return hasVideoEmbed(A) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(A)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = A, [a];
6377
6362
  } else if (n.tagName === "svg") {
6378
6363
  const A = find(n.attributes, { key: "height" }), E = find(n.attributes, { key: "width" }), C = get(A, "value") ? `[${get(A, "value")}px]` : "24px", B = get(E, "value") ? `[${get(E, "value")}px]` : "24px", _ = get(find(n.attributes, { key: "class" }), "value", "w-full h-full");
6379
- return a.styles = `${STYLES_KEY}, ${cn$1(`w-${B} h-${C}`, _)}`.trim(), n.attributes = filter(n.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([n]), [a];
6364
+ return a.styles = `${STYLES_KEY}, ${cn$1(`w-${B} h-${C}`, _)}`.trim(), n.attributes = filter(n.attributes, (I) => !includes(["style", "width", "height", "class"], I.key)), a.icon = stringify([n]), [a];
6380
6365
  } else if (n.tagName == "option" && r && ((w = r.block) == null ? void 0 : w._type) === "Select")
6381
6366
  return r.block.options.push({
6382
6367
  label: getTextContent(n.children),
@@ -6392,8 +6377,8 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6392
6377
  };
6393
6378
  }, getSanitizedHTML = (o) => {
6394
6379
  o = o.replace(/(\w+)=\\?"(.*?)\\?"/g, (a, l, i) => {
6395
- let c = i.replace(/\\"/g, '"');
6396
- return c = c.replace(/{([^}]+)}/g, (d) => d.replace(/"/g, '\\"')), `${l}="${c.replace(/\\"/g, '"')}"`;
6380
+ let d = i.replace(/\\"/g, '"');
6381
+ return d = d.replace(/{([^}]+)}/g, (c) => c.replace(/"/g, '\\"')), `${l}="${d.replace(/\\"/g, '"')}"`;
6397
6382
  }), o = o.replace(/\\n/g, "").replace(/\\\\/g, "").replace(/\\([/<>])/g, "$1").replace(/\\./g, "").replace(/[\n\r\t\f\v]/g, ""), o = o.replace(/\$name="[^"]*"/g, "");
6398
6383
  const r = o.match(/<body[^>]*>[\s\S]*?<\/body>/);
6399
6384
  return (r && r.length > 0 ? r[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : o).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
@@ -6401,9 +6386,9 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6401
6386
  const r = parse(getSanitizedHTML(o));
6402
6387
  return isEmpty(o) ? [] : flatten(traverseNodes(r));
6403
6388
  }, ImportHTML = ({ parentId: o, position: r }) => {
6404
- const { t: n } = useTranslation(), [a, l] = useState(""), { addPredefinedBlock: i } = useAddBlock(), c = () => {
6405
- const d = getBlocksFromHTML(a);
6406
- i([...d], o, r), l(""), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6389
+ const { t: n } = useTranslation(), [a, l] = useState(""), { addPredefinedBlock: i } = useAddBlock(), d = () => {
6390
+ const c = getBlocksFromHTML(a);
6391
+ i([...c], o, r), l(""), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6407
6392
  };
6408
6393
  return /* @__PURE__ */ jsxs(Card, { className: "border-border/0 p-0 shadow-none", children: [
6409
6394
  /* @__PURE__ */ jsx(CardHeader, { className: "p-3", children: /* @__PURE__ */ jsx(CardDescription, { children: n("Use HTML snippets from Tailwind CSS component libraries") }) }),
@@ -6414,8 +6399,8 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6414
6399
  {
6415
6400
  autoFocus: !0,
6416
6401
  tabIndex: 1,
6417
- ref: (d) => d && d.focus(),
6418
- onChange: (d) => l(d.target.value),
6402
+ ref: (c) => c && c.focus(),
6403
+ onChange: (c) => l(c.target.value),
6419
6404
  rows: 12,
6420
6405
  value: a,
6421
6406
  placeholder: n("Enter your code snippet here"),
@@ -6423,7 +6408,7 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6423
6408
  }
6424
6409
  )
6425
6410
  ] }) }),
6426
- /* @__PURE__ */ jsx(CardFooter, { className: "flex flex-col justify-end p-3", children: /* @__PURE__ */ jsx(Button, { disabled: a.trim() === "", onClick: () => c(), size: "sm", className: "w-fit", children: n("Import HTML") }) })
6411
+ /* @__PURE__ */ jsx(CardFooter, { className: "flex flex-col justify-end p-3", children: /* @__PURE__ */ jsx(Button, { disabled: a.trim() === "", onClick: () => d(), size: "sm", className: "w-fit", children: n("Import HTML") }) })
6427
6412
  ] });
6428
6413
  }, ChaiSelect = ({
6429
6414
  defaultValue: o = "",
@@ -6433,9 +6418,9 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6433
6418
  className: l = "",
6434
6419
  height: i = ""
6435
6420
  }) => {
6436
- const [c, d] = useState(o), p = (u) => {
6421
+ const [d, c] = useState(o), p = (u) => {
6437
6422
  const g = u.target.value;
6438
- d(g), r(g);
6423
+ c(g), r(g);
6439
6424
  };
6440
6425
  return /* @__PURE__ */ jsx("div", { className: cn$1("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
6441
6426
  "select",
@@ -6444,7 +6429,7 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6444
6429
  "mt-1 flex w-full rounded-md border border-border bg-background px-3 py-1 text-sm text-foreground shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
6445
6430
  i
6446
6431
  ),
6447
- value: c,
6432
+ value: d,
6448
6433
  onChange: p,
6449
6434
  children: [
6450
6435
  /* @__PURE__ */ jsx("option", { value: "", disabled: !0, children: a }),
@@ -6481,20 +6466,20 @@ const BlockCard = ({
6481
6466
  parentId: n = void 0,
6482
6467
  position: a = -1
6483
6468
  }) => {
6484
- const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), f = get(o, "name", get(o, "label")), m = get(o, "description", ""), h = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), k = (w) => {
6469
+ const [l, i] = useState(!1), d = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: c, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), f = get(o, "name", get(o, "label")), m = get(o, "description", ""), h = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), k = (w) => {
6485
6470
  const A = has(w, "styles_attrs.data-page-section");
6486
6471
  return w._type === "Box" && A;
6487
6472
  }, b = useCallback(
6488
6473
  async (w) => {
6489
6474
  if (w.stopPropagation(), has(o, "component")) {
6490
- d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6475
+ c(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6491
6476
  return;
6492
6477
  }
6493
6478
  i(!0);
6494
- const A = await c(r, o);
6479
+ const A = await d(r, o);
6495
6480
  isEmpty(A) || p(syncBlocksWithDefaults(A), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6496
6481
  },
6497
- [d, p, o, c, r, n, a]
6482
+ [c, p, o, d, r, n, a]
6498
6483
  );
6499
6484
  return /* @__PURE__ */ jsxs(Tooltip, { children: [
6500
6485
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
@@ -6504,7 +6489,7 @@ const BlockCard = ({
6504
6489
  } : b,
6505
6490
  draggable: h ? "true" : "false",
6506
6491
  onDragStart: async (w) => {
6507
- const A = await c(r, o);
6492
+ const A = await d(r, o);
6508
6493
  let E = n;
6509
6494
  if (k(first(A)) && (E = null), !isEmpty(A)) {
6510
6495
  const C = { blocks: A, uiLibrary: !0, parent: E };
@@ -6541,14 +6526,14 @@ const BlockCard = ({
6541
6526
  ] }) })
6542
6527
  ] });
6543
6528
  }, UILibrarySection = ({ parentId: o, position: r }) => {
6544
- const [n, a] = useSelectedLibrary(), l = useBuilderProp("uiLibraries", []), i = l.find((y) => y.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [f, m] = useState([]), h = useRef(null);
6529
+ const [n, a] = useSelectedLibrary(), l = useBuilderProp("uiLibraries", []), i = l.find((y) => y.id === n) || first(l), { data: d, isLoading: c, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [f, m] = useState([]), h = useRef(null);
6545
6530
  useEffect(() => {
6546
- c && c.length > 0 && (h.current = new Fuse(c, {
6531
+ d && d.length > 0 && (h.current = new Fuse(d, {
6547
6532
  keys: ["name", "label", "description", "group"],
6548
6533
  threshold: 0.4,
6549
6534
  ignoreLocation: !0
6550
6535
  }));
6551
- }, [c]), useEffect(() => {
6536
+ }, [d]), useEffect(() => {
6552
6537
  if (!u.trim() || !h.current) {
6553
6538
  m([]);
6554
6539
  return;
@@ -6556,7 +6541,7 @@ const BlockCard = ({
6556
6541
  const y = h.current.search(u).map((j) => j.item);
6557
6542
  m(y);
6558
6543
  }, [u]);
6559
- const x = u.trim() && !isEmpty(f) ? f : c, k = groupBy(x, "group"), [b, S] = useState(null);
6544
+ const x = u.trim() && !isEmpty(f) ? f : d, k = groupBy(x, "group"), [b, S] = useState(null);
6560
6545
  useEffect(() => {
6561
6546
  if (isEmpty(keys(k))) {
6562
6547
  S(null);
@@ -6576,12 +6561,12 @@ const BlockCard = ({
6576
6561
  }, _ = () => {
6577
6562
  g("");
6578
6563
  };
6579
- if (d)
6564
+ if (c)
6580
6565
  return /* @__PURE__ */ jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
6581
6566
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
6582
6567
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
6583
6568
  ] });
6584
- const L = filter(w, (y, j) => j % 2 === 0), v = filter(w, (y, j) => j % 2 === 1);
6569
+ const I = filter(w, (y, j) => j % 2 === 0), v = filter(w, (y, j) => j % 2 === 1);
6585
6570
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
6586
6571
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
6587
6572
  /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
@@ -6642,7 +6627,7 @@ const BlockCard = ({
6642
6627
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
6643
6628
  children: [
6644
6629
  isEmpty(w) && !isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: E("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
6645
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: L.map((y, j) => /* @__PURE__ */ jsx(
6630
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: I.map((y, j) => /* @__PURE__ */ jsx(
6646
6631
  BlockCard,
6647
6632
  {
6648
6633
  parentId: o,
@@ -6685,15 +6670,15 @@ const BlockCard = ({
6685
6670
  position: r,
6686
6671
  gridCols: n = "grid-cols-2"
6687
6672
  }) => {
6688
- const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u, g] = useAtom$1(hasInitializedPartialBlocksAtom);
6673
+ const { data: a, isLoading: l, refetch: i, error: d } = usePartialBlocksList(), [c, p] = useAtom$1(partialBlocksDataAtom), [u, g] = useAtom$1(hasInitializedPartialBlocksAtom);
6689
6674
  useEffect(() => {
6690
- if (!u || Object.keys(d.blocks).length === 0)
6691
- if (c)
6675
+ if (!u || Object.keys(c.blocks).length === 0)
6676
+ if (d)
6692
6677
  p({
6693
6678
  blocks: [],
6694
6679
  groups: [],
6695
6680
  isLoading: !1,
6696
- error: c
6681
+ error: d
6697
6682
  }), g(!0);
6698
6683
  else if (!l && Object.keys(a || {}).length > 0) {
6699
6684
  const m = Object.entries(a).map(([x, k]) => {
@@ -6730,14 +6715,14 @@ const BlockCard = ({
6730
6715
  u,
6731
6716
  g,
6732
6717
  p,
6733
- d.blocks,
6734
- c
6718
+ c.blocks,
6719
+ d
6735
6720
  ]);
6736
6721
  const f = () => {
6737
6722
  p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
6738
6723
  };
6739
- return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
6740
- /* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
6724
+ return c.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : c.error || c.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
6725
+ /* @__PURE__ */ jsx("p", { children: c.error || "No partial blocks available" }),
6741
6726
  /* @__PURE__ */ jsx(
6742
6727
  "button",
6743
6728
  {
@@ -6752,13 +6737,13 @@ const BlockCard = ({
6752
6737
  gridCols: n,
6753
6738
  parentId: o,
6754
6739
  position: r,
6755
- groups: d.groups,
6756
- blocks: d.blocks
6740
+ groups: c.groups,
6741
+ blocks: c.blocks
6757
6742
  }
6758
6743
  );
6759
6744
  }, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: r, parentId: n, position: a, gridCols: l = "grid-cols-4" }) => {
6760
6745
  var v;
6761
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), f = (v = find(c, (y) => y._id === n)) == null ? void 0 : v._type, [m, h] = useState("all"), [x, k] = useState(null), b = useRef(null);
6746
+ const { t: i } = useTranslation(), [d] = useBlocksStore(), [c, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), f = (v = find(d, (y) => y._id === n)) == null ? void 0 : v._type, [m, h] = useState("all"), [x, k] = useState(null), b = useRef(null);
6762
6747
  useEffect(() => {
6763
6748
  const y = setTimeout(() => {
6764
6749
  var j;
@@ -6766,8 +6751,8 @@ const BlockCard = ({
6766
6751
  }, 0);
6767
6752
  return () => clearTimeout(y);
6768
6753
  }, [g]), useEffect(() => {
6769
- d && (h("all"), k(null));
6770
- }, [d]), useEffect(() => (b.current = debounce((y) => {
6754
+ c && (h("all"), k(null));
6755
+ }, [c]), useEffect(() => (b.current = debounce((y) => {
6771
6756
  h(y);
6772
6757
  }, 500), () => {
6773
6758
  b.current && b.current.cancel();
@@ -6779,22 +6764,22 @@ const BlockCard = ({
6779
6764
  }, []), A = useCallback((y) => {
6780
6765
  b.current && b.current.cancel(), h(y), k(null);
6781
6766
  }, []), E = useMemo(
6782
- () => d ? values(r).filter(
6767
+ () => c ? values(r).filter(
6783
6768
  (y) => {
6784
6769
  var j, T;
6785
- return (((j = y.label) == null ? void 0 : j.toLowerCase()) + " " + ((T = y.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
6770
+ return (((j = y.label) == null ? void 0 : j.toLowerCase()) + " " + ((T = y.type) == null ? void 0 : T.toLowerCase())).includes(c.toLowerCase());
6786
6771
  }
6787
6772
  ) : r,
6788
- [r, d]
6773
+ [r, c]
6789
6774
  ), C = useMemo(
6790
- () => d ? o.filter(
6775
+ () => c ? o.filter(
6791
6776
  (y) => reject(filter(values(E), { group: y }), { hidden: !0 }).length > 0
6792
6777
  ) : o.filter((y) => reject(filter(values(r), { group: y }), { hidden: !0 }).length > 0),
6793
- [r, E, o, d]
6778
+ [r, E, o, c]
6794
6779
  ), B = useMemo(
6795
6780
  () => sortBy(C, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
6796
6781
  [C]
6797
- ), _ = useMemo(() => m === "all" ? E : filter(values(E), { group: m }), [E, m]), L = useMemo(() => m === "all" ? B : [m], [B, m]);
6782
+ ), _ = useMemo(() => m === "all" ? E : filter(values(E), { group: m }), [E, m]), I = useMemo(() => m === "all" ? B : [m], [B, m]);
6798
6783
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
6799
6784
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
6800
6785
  Input$1,
@@ -6802,7 +6787,7 @@ const BlockCard = ({
6802
6787
  ref: u,
6803
6788
  type: "search",
6804
6789
  placeholder: i("Search blocks..."),
6805
- value: d,
6790
+ value: c,
6806
6791
  className: "-ml-2",
6807
6792
  onChange: (y) => p(y.target.value)
6808
6793
  }
@@ -6832,12 +6817,12 @@ const BlockCard = ({
6832
6817
  `sidebar-${y}`
6833
6818
  ))
6834
6819
  ] }) }) }),
6835
- /* @__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: C.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: [
6820
+ /* @__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: C.length === 0 && c ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
6836
6821
  i("No blocks found matching"),
6837
6822
  ' "',
6838
- d,
6823
+ c,
6839
6824
  '"'
6840
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((y) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
6825
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: I.map((y) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
6841
6826
  /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(y.toLowerCase())) }),
6842
6827
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
6843
6828
  m === "all" ? filter(values(_), { group: y }) : values(_),
@@ -6861,16 +6846,16 @@ const BlockCard = ({
6861
6846
  parentId: n = void 0,
6862
6847
  position: a = -1
6863
6848
  }) => {
6864
- const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission: f } = usePermissions();
6849
+ const { t: l } = useTranslation(), [i, d] = useAtom$1(addBlockTabAtom), [, c] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission: f } = usePermissions();
6865
6850
  useEffect(() => {
6866
- i === "partials" && !g && c("library");
6867
- }, [i, g, c]);
6851
+ i === "partials" && !g && d("library");
6852
+ }, [i, g, d]);
6868
6853
  const m = useCallback(() => {
6869
6854
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6870
6855
  }, []), h = useChaiAddBlockTabs(), x = p && f(PERMISSIONS.IMPORT_HTML), b = useBuilderProp("uiLibraries", []).length > 0;
6871
6856
  return useEffect(() => {
6872
- i === "library" && !b && c("core");
6873
- }, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
6857
+ i === "library" && !b && d("core");
6858
+ }, [i, b, d]), /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
6874
6859
  r ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
6875
6860
  /* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: l("Add block") }),
6876
6861
  /* @__PURE__ */ jsx("span", { className: "p-0 text-xs font-light leading-3 opacity-80 xl:pl-1", children: l(i === "html" ? "Enter or paste TailwindCSS HTML snippet" : "Click to add block to page") })
@@ -6879,7 +6864,7 @@ const BlockCard = ({
6879
6864
  Tabs,
6880
6865
  {
6881
6866
  onValueChange: (S) => {
6882
- d(""), c(S);
6867
+ c(""), d(S);
6883
6868
  },
6884
6869
  value: i,
6885
6870
  className: "flex h-full max-h-full flex-col overflow-hidden",
@@ -6930,14 +6915,14 @@ const registerChaiSaveToLibrary = (o) => {
6930
6915
  a.push(...getBlocks(o, l == null ? void 0 : l._id));
6931
6916
  }), a;
6932
6917
  }, SaveToLibraryModal = () => {
6933
- const [o, r] = useAtom$1(saveToLibraryModalAtom), { t: n } = useTranslation(), [a] = useBlocksStore(), l = () => r({ isOpen: !1, blockId: null }), i = useSaveToLibraryComponent(), c = useMemo(() => {
6918
+ const [o, r] = useAtom$1(saveToLibraryModalAtom), { t: n } = useTranslation(), [a] = useBlocksStore(), l = () => r({ isOpen: !1, blockId: null }), i = useSaveToLibraryComponent(), d = useMemo(() => {
6934
6919
  if (!o.blockId) return [];
6935
- const d = find(a, { _id: o.blockId });
6936
- return d == null || delete d._parent, [d, ...getBlocks(a, d == null ? void 0 : d._id)];
6920
+ const c = find(a, { _id: o.blockId });
6921
+ return c == null || delete c._parent, [c, ...getBlocks(a, c == null ? void 0 : c._id)];
6937
6922
  }, [o.blockId, a]);
6938
- return /* @__PURE__ */ jsx(Dialog, { open: o.isOpen, onOpenChange: (d) => !d && l(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "p-4 sm:max-w-[450px]", children: [
6923
+ return /* @__PURE__ */ jsx(Dialog, { open: o.isOpen, onOpenChange: (c) => !c && l(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "p-4 sm:max-w-[450px]", children: [
6939
6924
  /* @__PURE__ */ jsx(DialogHeader, { className: "pb-2", children: /* @__PURE__ */ jsx(DialogTitle, { children: n("Save to Library") }) }),
6940
- i && !isEmpty(o.blockId) && /* @__PURE__ */ jsx(i, { blockId: o.blockId, blocks: c, close: l })
6925
+ i && !isEmpty(o.blockId) && /* @__PURE__ */ jsx(i, { blockId: o.blockId, blocks: d, close: l })
6941
6926
  ] }) });
6942
6927
  }, SaveToLibrary = () => {
6943
6928
  const o = useSelectedBlock(), { t: r } = useTranslation(), [, n] = useAtom$1(saveToLibraryModalAtom), a = useSaveToLibraryComponent(), l = () => {
@@ -6951,6 +6936,17 @@ const registerChaiSaveToLibrary = (o) => {
6951
6936
  " ",
6952
6937
  r(o != null && o._libBlockId ? "Update library block" : "Save to library")
6953
6938
  ] }) : null;
6939
+ }, UnlinkLibraryBlock = () => {
6940
+ const { t: o } = useTranslation(), r = useSelectedBlock(), n = useUpdateBlocksProps();
6941
+ return /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: () => {
6942
+ n([r._id], {
6943
+ _libBlockId: null
6944
+ });
6945
+ }, className: "flex items-center gap-x-4 text-xs", children: [
6946
+ /* @__PURE__ */ jsx(UnlinkIcon, { className: "h-4 w-4" }),
6947
+ " ",
6948
+ o("Unlink from library")
6949
+ ] });
6954
6950
  }, PasteAtRootContextMenu = ({ parentContext: o, setParentContext: r }) => {
6955
6951
  const { t: n } = useTranslation(), { canPaste: a, pasteBlocks: l } = usePasteBlocks();
6956
6952
  return useEffect(() => {
@@ -6973,22 +6969,22 @@ const registerChaiSaveToLibrary = (o) => {
6973
6969
  ) })
6974
6970
  ] }) });
6975
6971
  }, CopyPasteBlocks = () => {
6976
- const [o] = useBlocksStore(), [r] = useSelectedBlockIds(), { pasteBlocks: n } = usePasteBlocks(), [, a] = useCopyBlockIds(), { t: l } = useTranslation(), i = useSelectedBlock(), c = useCallback(() => {
6977
- const d = r.map((p) => {
6972
+ const [o] = useBlocksStore(), [r] = useSelectedBlockIds(), { pasteBlocks: n } = usePasteBlocks(), [, a] = useCopyBlockIds(), { t: l } = useTranslation(), i = useSelectedBlock(), d = useCallback(() => {
6973
+ const c = r.map((p) => {
6978
6974
  const u = o.find((g) => g._id === p);
6979
6975
  return {
6980
6976
  id: p,
6981
6977
  data: u
6982
6978
  };
6983
6979
  });
6984
- a(d.map((p) => p.id));
6980
+ a(c.map((p) => p.id));
6985
6981
  }, [r, o, a]);
6986
6982
  return /* @__PURE__ */ jsxs(Fragment, { children: [
6987
6983
  /* @__PURE__ */ jsxs(
6988
6984
  DropdownMenuItem,
6989
6985
  {
6990
6986
  disabled: !canDuplicateBlock(i == null ? void 0 : i._type),
6991
- onClick: c,
6987
+ onClick: d,
6992
6988
  className: "flex items-center gap-x-4 text-xs",
6993
6989
  children: [
6994
6990
  /* @__PURE__ */ jsx(CopyIcon, {}),
@@ -7051,9 +7047,9 @@ const registerChaiSaveToLibrary = (o) => {
7051
7047
  }
7052
7048
  );
7053
7049
  }, BlockContextMenuContent = ({ node: o }) => {
7054
- const { t: r } = useTranslation(), [n] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), { hasPermission: i } = usePermissions(), c = useCallback(() => {
7050
+ const { t: r } = useTranslation(), [n] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), { hasPermission: i } = usePermissions(), d = useCallback(() => {
7055
7051
  a(n);
7056
- }, [n, a]);
7052
+ }, [n, a]), c = useMemo(() => has(l, "_libBlockId") && !isEmpty(l._libBlockId), [l == null ? void 0 : l._libBlockId]);
7057
7053
  return /* @__PURE__ */ jsxs(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: [
7058
7054
  i(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsxs(Fragment, { children: [
7059
7055
  /* @__PURE__ */ jsxs(
@@ -7074,7 +7070,7 @@ const registerChaiSaveToLibrary = (o) => {
7074
7070
  {
7075
7071
  disabled: !canDuplicateBlock(l == null ? void 0 : l._type),
7076
7072
  className: "flex items-center gap-x-4 text-xs",
7077
- onClick: c,
7073
+ onClick: d,
7078
7074
  children: [
7079
7075
  /* @__PURE__ */ jsx(CardStackPlusIcon, {}),
7080
7076
  " ",
@@ -7086,6 +7082,7 @@ const registerChaiSaveToLibrary = (o) => {
7086
7082
  /* @__PURE__ */ jsx(RenameBlock, { node: o }),
7087
7083
  i(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(CutBlocks, {}),
7088
7084
  i(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(CopyPasteBlocks, {}),
7085
+ c && /* @__PURE__ */ jsx(UnlinkLibraryBlock, {}),
7089
7086
  i(PERMISSIONS.CREATE_LIBRARY_BLOCK) && /* @__PURE__ */ jsx(SaveToLibrary, {}),
7090
7087
  i(PERMISSIONS.DELETE_BLOCK) && /* @__PURE__ */ jsx(RemoveBlocks, {})
7091
7088
  ] });
@@ -7119,7 +7116,7 @@ const registerChaiSaveToLibrary = (o) => {
7119
7116
  }), Overlay = memo(function({ children: r, isDragging: n }) {
7120
7117
  return n ? /* @__PURE__ */ jsx("div", { className: "pointer-events-none fixed left-0 top-0 z-[100] h-full w-full", children: r }) : null;
7121
7118
  }), DefaultDragPreview = memo(({ id: o, isDragging: r, mouse: n }) => {
7122
- const [a] = useBlocksStore(), l = useMemo(() => a.find((c) => c._id === o), [a, o]), i = useMemo(
7119
+ const [a] = useBlocksStore(), l = useMemo(() => a.find((d) => d._id === o), [a, o]), i = useMemo(
7123
7120
  () => ({
7124
7121
  transform: `translate(${(n == null ? void 0 : n.x) - 10}px, ${(n == null ? void 0 : n.y) - 10}px)`
7125
7122
  }),
@@ -7191,7 +7188,7 @@ const selectParent = (o, r) => {
7191
7188
  );
7192
7189
  }, currentAddSelection = atom(null), Node = memo(({ node: o, style: r, dragHandle: n }) => {
7193
7190
  var P;
7194
- const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7191
+ const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
7195
7192
  let p = null;
7196
7193
  const u = o.children.length > 0, { highlightBlock: g, clearHighlight: f } = useBlockHighlight(), { id: m, data: h, isSelected: x, willReceiveDrop: k, isDragging: b, isEditing: S, handleClick: w } = o, A = (N) => {
7197
7194
  N.stopPropagation(), !l.includes(m) && o.toggle();
@@ -7199,7 +7196,7 @@ const selectParent = (o, r) => {
7199
7196
  N.isInternal && (p = N.isOpen, N.isOpen && N.close());
7200
7197
  }, C = (N) => {
7201
7198
  N.isInternal && p !== null && (p ? N.open() : N.close(), p = null);
7202
- }, [B, _] = useAtom$1(currentAddSelection), L = () => {
7199
+ }, [B, _] = useAtom$1(currentAddSelection), I = () => {
7203
7200
  var N;
7204
7201
  v(), o.parent.isSelected || _((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7205
7202
  }, v = () => {
@@ -7214,9 +7211,9 @@ const selectParent = (o, r) => {
7214
7211
  return () => clearTimeout(N);
7215
7212
  }, [k, o, b]);
7216
7213
  const j = (N, D) => {
7217
- const O = c.contentDocument || c.contentWindow.document, R = O.querySelector(`[data-block-id=${N}]`);
7214
+ const O = d.contentDocument || d.contentWindow.document, R = O.querySelector(`[data-block-id=${N}]`);
7218
7215
  R && R.setAttribute("data-drop", D);
7219
- const $ = R.getBoundingClientRect(), M = c.getBoundingClientRect();
7216
+ const $ = R.getBoundingClientRect(), M = d.getBoundingClientRect();
7220
7217
  $.top >= M.top && $.left >= M.left && $.bottom <= M.bottom && $.right <= M.right || (O.documentElement.scrollTop = R.offsetTop - M.top);
7221
7218
  }, T = (N) => {
7222
7219
  v();
@@ -7226,7 +7223,7 @@ const selectParent = (o, r) => {
7226
7223
  if (m === ROOT_TEMP_KEY)
7227
7224
  return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7228
7225
  /* @__PURE__ */ jsx("br", {}),
7229
- d(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
7226
+ c(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
7230
7227
  "div",
7231
7228
  {
7232
7229
  role: "button",
@@ -7241,7 +7238,7 @@ const selectParent = (o, r) => {
7241
7238
  ),
7242
7239
  /* @__PURE__ */ jsx("br", {})
7243
7240
  ] });
7244
- const I = useMemo(() => has(h, "_libBlockId") && !isEmpty(h._libBlockId) && (d(PERMISSIONS.CREATE_LIBRARY_BLOCK) || d(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [h, d]);
7241
+ const L = useMemo(() => has(h, "_libBlockId") && !isEmpty(h._libBlockId) && (c(PERMISSIONS.CREATE_LIBRARY_BLOCK) || c(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [h, c]);
7245
7242
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7246
7243
  "div",
7247
7244
  {
@@ -7263,13 +7260,13 @@ const selectParent = (o, r) => {
7263
7260
  N.preventDefault(), j(m, "no");
7264
7261
  },
7265
7262
  children: [
7266
- d(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
7263
+ c(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
7267
7264
  "div",
7268
7265
  {
7269
7266
  onClick: (N) => {
7270
7267
  N.stopPropagation(), T(o.childIndex);
7271
7268
  },
7272
- onMouseEnter: L,
7269
+ onMouseEnter: I,
7273
7270
  onMouseLeave: v,
7274
7271
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
7275
7272
  children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary p-1 outline outline-2 outline-white hover:bg-primary", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3 stroke-[4] text-white" }) })
@@ -7285,7 +7282,7 @@ const selectParent = (o, r) => {
7285
7282
  (o == null ? void 0 : o.id) === B ? "bg-primary/10" : "",
7286
7283
  b && "opacity-20",
7287
7284
  l.includes(m) ? "opacity-50" : "",
7288
- I && x && "bg-primary/20 text-primary"
7285
+ L && x && "bg-primary/20 text-primary"
7289
7286
  ),
7290
7287
  children: [
7291
7288
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -7293,7 +7290,7 @@ const selectParent = (o, r) => {
7293
7290
  "div",
7294
7291
  {
7295
7292
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
7296
- children: u && /* @__PURE__ */ jsx("button", { onClick: A, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${x ? "text-primary" : "text-slate-400"}` }) })
7293
+ children: u && /* @__PURE__ */ jsx("button", { onClick: A, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${x ? "text-white" : "text-slate-400"}` }) })
7297
7294
  }
7298
7295
  ),
7299
7296
  /* @__PURE__ */ jsxs(
@@ -7301,8 +7298,8 @@ const selectParent = (o, r) => {
7301
7298
  {
7302
7299
  className: cn(
7303
7300
  "leading-1 flex items-center",
7304
- I && "text-primary/60",
7305
- I && x && "text-primary/80"
7301
+ L && "text-primary/60",
7302
+ L && x && "text-primary/80"
7306
7303
  ),
7307
7304
  children: [
7308
7305
  /* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
@@ -7321,7 +7318,7 @@ const selectParent = (o, r) => {
7321
7318
  )
7322
7319
  ] }),
7323
7320
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
7324
- canAddChildBlock(h == null ? void 0 : h._type) && !l.includes(m) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7321
+ canAddChildBlock(h == null ? void 0 : h._type) && !l.includes(m) && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7325
7322
  /* @__PURE__ */ jsx(
7326
7323
  TooltipTrigger,
7327
7324
  {
@@ -7359,9 +7356,9 @@ const selectParent = (o, r) => {
7359
7356
  const [o] = useBlocksStore();
7360
7357
  return (r, n) => {
7361
7358
  var i;
7362
- const a = (i = find(o, { _id: n })) == null ? void 0 : i._type, l = first(r.map((c) => {
7363
- var d;
7364
- return (d = find(o, { _id: c })) == null ? void 0 : d._type;
7359
+ const a = (i = find(o, { _id: n })) == null ? void 0 : i._type, l = first(r.map((d) => {
7360
+ var c;
7361
+ return (c = find(o, { _id: d })) == null ? void 0 : c._type;
7365
7362
  }));
7366
7363
  return canAcceptChildBlock(a, l);
7367
7364
  };
@@ -7584,7 +7581,7 @@ const selectParent = (o, r) => {
7584
7581
  )
7585
7582
  ] });
7586
7583
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
7587
- const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), f = (S) => {
7584
+ const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: d } = usePermissions(), [c, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), f = (S) => {
7588
7585
  a(S);
7589
7586
  }, m = () => {
7590
7587
  const S = l.find((w) => Object.keys(w)[0] === n);
@@ -7596,41 +7593,41 @@ const selectParent = (o, r) => {
7596
7593
  }, h = useDebouncedCallback(
7597
7594
  (S, w) => {
7598
7595
  p(() => ({
7599
- ...d,
7596
+ ...c,
7600
7597
  fontFamily: {
7601
- ...d.fontFamily,
7598
+ ...c.fontFamily,
7602
7599
  [S.replace(/font-/g, "")]: w
7603
7600
  }
7604
7601
  }));
7605
7602
  },
7606
- [d],
7603
+ [c],
7607
7604
  200
7608
7605
  ), x = useDebouncedCallback(
7609
7606
  (S) => {
7610
7607
  p(() => ({
7611
- ...d,
7608
+ ...c,
7612
7609
  borderRadius: `${S}px`
7613
7610
  }));
7614
7611
  },
7615
- [d],
7612
+ [c],
7616
7613
  200
7617
7614
  ), k = useDebouncedCallback(
7618
7615
  (S, w) => {
7619
7616
  p(() => {
7620
- const A = get(d, `colors.${S}`);
7617
+ const A = get(c, `colors.${S}`);
7621
7618
  return r ? set(A, 1, w) : set(A, 0, w), {
7622
- ...d,
7619
+ ...c,
7623
7620
  colors: {
7624
- ...d.colors,
7621
+ ...c.colors,
7625
7622
  [S]: A
7626
7623
  }
7627
7624
  };
7628
7625
  });
7629
7626
  },
7630
- [d],
7627
+ [c],
7631
7628
  200
7632
7629
  ), b = (S) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(S.items).map(([w]) => {
7633
- const A = get(d, `colors.${w}.${r ? 1 : 0}`);
7630
+ const A = get(c, `colors.${w}.${r ? 1 : 0}`);
7634
7631
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
7635
7632
  /* @__PURE__ */ jsx(
7636
7633
  ColorPickerInput,
@@ -7642,7 +7639,7 @@ const selectParent = (o, r) => {
7642
7639
  /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: w.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!w.toLowerCase().includes("foreground") && !w.toLowerCase().includes("border") && !w.toLowerCase().includes("input") && !w.toLowerCase().includes("ring") && !w.toLowerCase().includes("background") ? " Background" : "") })
7643
7640
  ] }, w);
7644
7641
  }) });
7645
- return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7642
+ return d("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7646
7643
  /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
7647
7644
  l.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 py-2", children: [
7648
7645
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
@@ -7676,7 +7673,7 @@ const selectParent = (o, r) => {
7676
7673
  FontSelector,
7677
7674
  {
7678
7675
  label: S,
7679
- value: d.fontFamily[S.replace(/font-/g, "")] || w[Object.keys(w)[0]],
7676
+ value: c.fontFamily[S.replace(/font-/g, "")] || w[Object.keys(w)[0]],
7680
7677
  onChange: (A) => h(S, A)
7681
7678
  },
7682
7679
  S
@@ -7684,8 +7681,8 @@ const selectParent = (o, r) => {
7684
7681
  (u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
7685
7682
  /* @__PURE__ */ jsx(Label, { className: "text-sm", children: g("Border Radius") }),
7686
7683
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
7687
- /* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange: x }),
7688
- /* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: d.borderRadius })
7684
+ /* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange: x }),
7685
+ /* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: c.borderRadius })
7689
7686
  ] })
7690
7687
  ] }),
7691
7688
  (u == null ? void 0 : u.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
@@ -8132,17 +8129,17 @@ function QuickPrompts({ onClick: o }) {
8132
8129
  icon: Languages,
8133
8130
  prompt: `Translate the content to ${get(LANGUAGES, a, a)}. Maintain same tone, style and length.`
8134
8131
  }), /* @__PURE__ */ jsx("div", { className: r ? "pointer-events-none opacity-50" : "", children: /* @__PURE__ */ jsx("ul", { className: "space-y-2", children: i.map(
8135
- ({ name: c, icon: d, subMenus: p, prompt: u }) => p ? /* @__PURE__ */ jsxs(Popover, { children: [
8132
+ ({ name: d, icon: c, subMenus: p, prompt: u }) => p ? /* @__PURE__ */ jsxs(Popover, { children: [
8136
8133
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
8137
8134
  "li",
8138
8135
  {
8139
8136
  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",
8140
8137
  children: [
8141
- /* @__PURE__ */ jsx(d, { className: "h-4 w-4" }),
8142
- /* @__PURE__ */ jsx("span", { children: c })
8138
+ /* @__PURE__ */ jsx(c, { className: "h-4 w-4" }),
8139
+ /* @__PURE__ */ jsx("span", { children: d })
8143
8140
  ]
8144
8141
  },
8145
- c
8142
+ d
8146
8143
  ) }),
8147
8144
  /* @__PURE__ */ jsx(PopoverContent, { side: "right", children: /* @__PURE__ */ jsx("ul", { children: /* @__PURE__ */ jsx("li", { children: "Happy" }) }) })
8148
8145
  ] }) : /* @__PURE__ */ jsxs(
@@ -8151,43 +8148,43 @@ function QuickPrompts({ onClick: o }) {
8151
8148
  onClick: () => o(u),
8152
8149
  className: "flex cursor-pointer items-center space-x-2 rounded p-1 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",
8153
8150
  children: [
8154
- /* @__PURE__ */ jsx(d, { className: "h-4 w-4" }),
8155
- /* @__PURE__ */ jsx("span", { children: n(c) })
8151
+ /* @__PURE__ */ jsx(c, { className: "h-4 w-4" }),
8152
+ /* @__PURE__ */ jsx("span", { children: n(d) })
8156
8153
  ]
8157
8154
  },
8158
- c
8155
+ d
8159
8156
  )
8160
8157
  ) }) });
8161
8158
  }
8162
8159
  const AIUserPrompt = ({ blockId: o }) => {
8163
- const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), f = useRef(null), m = useRef(null);
8160
+ const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, d] = useState(""), [c, p] = useState(!0), [u, g] = useState(), f = useRef(null), m = useRef(null);
8164
8161
  useEffect(() => {
8165
8162
  var x;
8166
8163
  (x = f.current) == null || x.focus();
8167
8164
  }, []);
8168
8165
  const h = (x) => {
8169
8166
  const { usage: k } = x || {};
8170
- !l && k && g(k), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8167
+ !l && k && g(k), m.current = setTimeout(() => g(void 0), 1e4), l || d("");
8171
8168
  };
8172
8169
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8173
8170
  /* @__PURE__ */ jsxs(
8174
8171
  "div",
8175
8172
  {
8176
- onClick: () => p(!d),
8173
+ onClick: () => p(!c),
8177
8174
  className: "flex cursor-pointer items-center justify-between border-t border-border py-2 text-sm font-medium hover:underline",
8178
8175
  children: [
8179
8176
  /* @__PURE__ */ jsx("span", { children: r("Ask AI") }),
8180
- /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 text-gray-500 " + (d ? "rotate-180" : "") }) })
8177
+ /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 text-gray-500 " + (c ? "rotate-180" : "") }) })
8181
8178
  ]
8182
8179
  }
8183
8180
  ),
8184
- d && o ? /* @__PURE__ */ jsxs("div", { className: "mt-2", children: [
8181
+ c && o ? /* @__PURE__ */ jsxs("div", { className: "mt-2", children: [
8185
8182
  /* @__PURE__ */ jsx(
8186
8183
  Textarea,
8187
8184
  {
8188
8185
  ref: f,
8189
8186
  value: i,
8190
- onChange: (x) => c(x.target.value),
8187
+ onChange: (x) => d(x.target.value),
8191
8188
  placeholder: r("Ask AI to edit content"),
8192
8189
  className: "w-full",
8193
8190
  rows: 3,
@@ -8239,23 +8236,23 @@ const AIUserPrompt = ({ blockId: o }) => {
8239
8236
  }
8240
8237
  }
8241
8238
  )
8242
- ] }) : d ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
8239
+ ] }) : c ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
8243
8240
  /* @__PURE__ */ jsx(SparklesIcon, { className: "mx-auto text-3xl text-muted-foreground" }),
8244
8241
  /* @__PURE__ */ jsx("h1", { children: r("Please select a block to Ask AI") })
8245
8242
  ] }) }) : null
8246
8243
  ] });
8247
8244
  }, AISetContext = () => {
8248
- const { t: o } = useTranslation(), r = useBuilderProp("aiContext", ""), [n, a] = useState(r), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), f = useRef(null);
8245
+ const { t: o } = useTranslation(), r = useBuilderProp("aiContext", ""), [n, a] = useState(r), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [d, c] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), f = useRef(null);
8249
8246
  useEffect(() => {
8250
8247
  r && a(r);
8251
8248
  }, [r]);
8252
8249
  const m = async () => {
8253
8250
  try {
8254
- d(!0), u(null), await i(n), toast.success(o("Updated AI Context")), f.current.click();
8251
+ c(!0), u(null), await i(n), toast.success(o("Updated AI Context")), f.current.click();
8255
8252
  } catch (h) {
8256
8253
  u(h);
8257
8254
  } finally {
8258
- d(!1);
8255
+ c(!1);
8259
8256
  }
8260
8257
  };
8261
8258
  return /* @__PURE__ */ jsx(
@@ -8295,14 +8292,14 @@ const AIUserPrompt = ({ blockId: o }) => {
8295
8292
  variant: "default",
8296
8293
  className: "w-fit",
8297
8294
  size: "sm",
8298
- children: c ? /* @__PURE__ */ jsxs(Fragment, { children: [
8295
+ children: d ? /* @__PURE__ */ jsxs(Fragment, { children: [
8299
8296
  /* @__PURE__ */ jsx(Loader, { className: "h-5 w-5 animate-spin" }),
8300
8297
  o("Saving... Please wait...")
8301
8298
  ] }) : o("Save")
8302
8299
  }
8303
8300
  ),
8304
8301
  r.trim().length > 0 ? /* @__PURE__ */ jsxs(AlertDialog, { children: [
8305
- /* @__PURE__ */ jsx(AlertDialogTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { disabled: r.trim().length === 0, variant: "ghost", className: "w-fit", size: "sm", children: c ? /* @__PURE__ */ jsxs(Fragment, { children: [
8302
+ /* @__PURE__ */ jsx(AlertDialogTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { disabled: r.trim().length === 0, variant: "ghost", className: "w-fit", size: "sm", children: d ? /* @__PURE__ */ jsxs(Fragment, { children: [
8306
8303
  /* @__PURE__ */ jsx(Loader, { className: "h-5 w-5 animate-spin" }),
8307
8304
  o("Deleting... Please wait...")
8308
8305
  ] }) : o("Delete") }) }),
@@ -8403,13 +8400,13 @@ const UndoRedo = () => {
8403
8400
  }
8404
8401
  ));
8405
8402
  }, setAtomStateValueOrPromise = (o, r, n) => {
8406
- const a = n(o), l = "v" in a, i = a.v, c = isPendingPromise(a.v) ? a.v : null;
8403
+ const a = n(o), l = "v" in a, i = a.v, d = isPendingPromise(a.v) ? a.v : null;
8407
8404
  if (isPromiseLike$1(r)) {
8408
8405
  patchPromiseForCancelability(r);
8409
- for (const d of a.d.keys())
8410
- addPendingPromiseToDependency(o, r, n(d));
8406
+ for (const c of a.d.keys())
8407
+ addPendingPromiseToDependency(o, r, n(c));
8411
8408
  }
8412
- a.v = r, delete a.e, (!l || !Object.is(i, a.v)) && (++a.n, c && cancelPromise(c, r));
8409
+ a.v = r, delete a.e, (!l || !Object.is(i, a.v)) && (++a.n, d && cancelPromise(d, r));
8413
8410
  }, getMountedOrPendingDependents = (o, r, n) => {
8414
8411
  var a;
8415
8412
  const l = /* @__PURE__ */ new Set();
@@ -8418,7 +8415,7 @@ const UndoRedo = () => {
8418
8415
  for (const i of r.p)
8419
8416
  l.add(i);
8420
8417
  return l;
8421
- }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...h) => m.read(...h), p = (m, ...h) => m.write(...h), u = (m, h) => {
8418
+ }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), d = {}, c = (m, ...h) => m.read(...h), p = (m, ...h) => m.write(...h), u = (m, h) => {
8422
8419
  var x;
8423
8420
  return (x = m.unstable_onInit) == null ? void 0 : x.call(m, h);
8424
8421
  }, g = (m, h) => {
@@ -8426,47 +8423,47 @@ const UndoRedo = () => {
8426
8423
  return (x = m.onMount) == null ? void 0 : x.call(m, h);
8427
8424
  }, ...f) => {
8428
8425
  const m = f[0] || ((_) => {
8429
- let L = o.get(_);
8430
- return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(_, L), u == null || u(_, B)), L;
8426
+ let I = o.get(_);
8427
+ return I || (I = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(_, I), u == null || u(_, B)), I;
8431
8428
  }), h = f[1] || (() => {
8432
- let _, L;
8429
+ let _, I;
8433
8430
  const v = (y) => {
8434
8431
  try {
8435
8432
  y();
8436
8433
  } catch (j) {
8437
- _ || (_ = !0, L = j);
8434
+ _ || (_ = !0, I = j);
8438
8435
  }
8439
8436
  };
8440
8437
  do {
8441
- c.f && v(c.f);
8438
+ d.f && v(d.f);
8442
8439
  const y = /* @__PURE__ */ new Set(), j = y.add.bind(y);
8443
8440
  a.forEach((T) => {
8444
- var I;
8445
- return (I = r.get(T)) == null ? void 0 : I.l.forEach(j);
8441
+ var L;
8442
+ return (L = r.get(T)) == null ? void 0 : L.l.forEach(j);
8446
8443
  }), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), y.forEach(v), a.size && x();
8447
8444
  } while (a.size || i.size || l.size);
8448
8445
  if (_)
8449
- throw L;
8446
+ throw I;
8450
8447
  }), x = f[2] || (() => {
8451
- const _ = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
8448
+ const _ = [], I = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
8452
8449
  for (; y.length; ) {
8453
8450
  const j = y[y.length - 1], T = m(j);
8454
8451
  if (v.has(j)) {
8455
8452
  y.pop();
8456
8453
  continue;
8457
8454
  }
8458
- if (L.has(j)) {
8455
+ if (I.has(j)) {
8459
8456
  n.get(j) === T.n && _.push([j, T]), v.add(j), y.pop();
8460
8457
  continue;
8461
8458
  }
8462
- L.add(j);
8463
- for (const I of getMountedOrPendingDependents(j, T, r))
8464
- L.has(I) || y.push(I);
8459
+ I.add(j);
8460
+ for (const L of getMountedOrPendingDependents(j, T, r))
8461
+ I.has(L) || y.push(L);
8465
8462
  }
8466
8463
  for (let j = _.length - 1; j >= 0; --j) {
8467
- const [T, I] = _[j];
8464
+ const [T, L] = _[j];
8468
8465
  let P = !1;
8469
- for (const N of I.d.keys())
8466
+ for (const N of L.d.keys())
8470
8467
  if (N !== T && a.has(N)) {
8471
8468
  P = !0;
8472
8469
  break;
@@ -8474,7 +8471,7 @@ const UndoRedo = () => {
8474
8471
  P && (k(T), w(T)), n.delete(T);
8475
8472
  }
8476
8473
  }), k = f[3] || ((_) => {
8477
- var L, v;
8474
+ var I, v;
8478
8475
  const y = m(_);
8479
8476
  if (isAtomStateInitialized(y) && (r.has(_) && n.get(_) !== y.n || Array.from(y.d).every(
8480
8477
  ([R, $]) => (
@@ -8488,7 +8485,7 @@ const UndoRedo = () => {
8488
8485
  let j = !0;
8489
8486
  const T = () => {
8490
8487
  r.has(_) && (w(_), x(), h());
8491
- }, I = (R) => {
8488
+ }, L = (R) => {
8492
8489
  var $;
8493
8490
  if (isSelfAtom(_, R)) {
8494
8491
  const H = m(R);
@@ -8523,56 +8520,56 @@ const UndoRedo = () => {
8523
8520
  }
8524
8521
  }, O = y.n;
8525
8522
  try {
8526
- const R = d(_, I, D);
8527
- return setAtomStateValueOrPromise(_, R, m), isPromiseLike$1(R) && ((L = R.onCancel) == null || L.call(R, () => P == null ? void 0 : P.abort()), R.then(
8523
+ const R = c(_, L, D);
8524
+ return setAtomStateValueOrPromise(_, R, m), isPromiseLike$1(R) && ((I = R.onCancel) == null || I.call(R, () => P == null ? void 0 : P.abort()), R.then(
8528
8525
  T,
8529
8526
  T
8530
8527
  )), y;
8531
8528
  } catch (R) {
8532
8529
  return delete y.v, y.e = R, ++y.n, y;
8533
8530
  } finally {
8534
- j = !1, O !== y.n && n.get(_) === O && (n.set(_, y.n), a.add(_), (v = c.c) == null || v.call(c, _));
8531
+ j = !1, O !== y.n && n.get(_) === O && (n.set(_, y.n), a.add(_), (v = d.c) == null || v.call(d, _));
8535
8532
  }
8536
8533
  }), b = f[4] || ((_) => {
8537
- const L = [_];
8538
- for (; L.length; ) {
8539
- const v = L.pop(), y = m(v);
8534
+ const I = [_];
8535
+ for (; I.length; ) {
8536
+ const v = I.pop(), y = m(v);
8540
8537
  for (const j of getMountedOrPendingDependents(v, y, r)) {
8541
8538
  const T = m(j);
8542
- n.set(j, T.n), L.push(j);
8539
+ n.set(j, T.n), I.push(j);
8543
8540
  }
8544
8541
  }
8545
- }), S = f[5] || ((_, ...L) => {
8542
+ }), S = f[5] || ((_, ...I) => {
8546
8543
  let v = !0;
8547
- const y = (T) => returnAtomValue(k(T)), j = (T, ...I) => {
8544
+ const y = (T) => returnAtomValue(k(T)), j = (T, ...L) => {
8548
8545
  var P;
8549
8546
  const N = m(T);
8550
8547
  try {
8551
8548
  if (isSelfAtom(_, T)) {
8552
8549
  if (!hasInitialValue(T))
8553
8550
  throw new Error("atom not writable");
8554
- const D = N.n, O = I[0];
8555
- setAtomStateValueOrPromise(T, O, m), w(T), D !== N.n && (a.add(T), (P = c.c) == null || P.call(c, T), b(T));
8551
+ const D = N.n, O = L[0];
8552
+ setAtomStateValueOrPromise(T, O, m), w(T), D !== N.n && (a.add(T), (P = d.c) == null || P.call(d, T), b(T));
8556
8553
  return;
8557
8554
  } else
8558
- return S(T, ...I);
8555
+ return S(T, ...L);
8559
8556
  } finally {
8560
8557
  v || (x(), h());
8561
8558
  }
8562
8559
  };
8563
8560
  try {
8564
- return p(_, y, j, ...L);
8561
+ return p(_, y, j, ...I);
8565
8562
  } finally {
8566
8563
  v = !1;
8567
8564
  }
8568
8565
  }), w = f[6] || ((_) => {
8569
- var L;
8566
+ var I;
8570
8567
  const v = m(_), y = r.get(_);
8571
8568
  if (y && !isPendingPromise(v.v)) {
8572
8569
  for (const [j, T] of v.d)
8573
8570
  if (!y.d.has(j)) {
8574
- const I = m(j);
8575
- A(j).t.add(_), y.d.add(j), T !== I.n && (a.add(j), (L = c.c) == null || L.call(c, j), b(j));
8571
+ const L = m(j);
8572
+ A(j).t.add(_), y.d.add(j), T !== L.n && (a.add(j), (I = d.c) == null || I.call(d, j), b(j));
8576
8573
  }
8577
8574
  for (const j of y.d || [])
8578
8575
  if (!v.d.has(j)) {
@@ -8582,7 +8579,7 @@ const UndoRedo = () => {
8582
8579
  }
8583
8580
  }
8584
8581
  }), A = f[7] || ((_) => {
8585
- var L;
8582
+ var I;
8586
8583
  const v = m(_);
8587
8584
  let y = r.get(_);
8588
8585
  if (!y) {
@@ -8593,10 +8590,10 @@ const UndoRedo = () => {
8593
8590
  l: /* @__PURE__ */ new Set(),
8594
8591
  d: new Set(v.d.keys()),
8595
8592
  t: /* @__PURE__ */ new Set()
8596
- }, r.set(_, y), (L = c.m) == null || L.call(c, _), isActuallyWritableAtom(_)) {
8593
+ }, r.set(_, y), (I = d.m) == null || I.call(d, _), isActuallyWritableAtom(_)) {
8597
8594
  const j = () => {
8598
8595
  let T = !0;
8599
- const I = (...P) => {
8596
+ const L = (...P) => {
8600
8597
  try {
8601
8598
  return S(_, ...P);
8602
8599
  } finally {
@@ -8604,7 +8601,7 @@ const UndoRedo = () => {
8604
8601
  }
8605
8602
  };
8606
8603
  try {
8607
- const P = g(_, I);
8604
+ const P = g(_, L);
8608
8605
  P && (y.u = () => {
8609
8606
  T = !0;
8610
8607
  try {
@@ -8622,14 +8619,14 @@ const UndoRedo = () => {
8622
8619
  }
8623
8620
  return y;
8624
8621
  }), E = f[8] || ((_) => {
8625
- var L;
8622
+ var I;
8626
8623
  const v = m(_);
8627
8624
  let y = r.get(_);
8628
8625
  if (y && !y.l.size && !Array.from(y.t).some((j) => {
8629
8626
  var T;
8630
8627
  return (T = r.get(j)) == null ? void 0 : T.d.has(_);
8631
8628
  })) {
8632
- y.u && i.add(y.u), y = void 0, r.delete(_), (L = c.u) == null || L.call(c, _);
8629
+ y.u && i.add(y.u), y = void 0, r.delete(_), (I = d.u) == null || I.call(d, _);
8633
8630
  for (const j of v.d.keys()) {
8634
8631
  const T = E(j);
8635
8632
  T == null || T.t.delete(_);
@@ -8645,9 +8642,9 @@ const UndoRedo = () => {
8645
8642
  a,
8646
8643
  l,
8647
8644
  i,
8648
- c,
8649
- // atom intercepters
8650
8645
  d,
8646
+ // atom intercepters
8647
+ c,
8651
8648
  p,
8652
8649
  u,
8653
8650
  g,
@@ -8663,17 +8660,17 @@ const UndoRedo = () => {
8663
8660
  E
8664
8661
  ], B = {
8665
8662
  get: (_) => returnAtomValue(k(_)),
8666
- set: (_, ...L) => {
8663
+ set: (_, ...I) => {
8667
8664
  try {
8668
- return S(_, ...L);
8665
+ return S(_, ...I);
8669
8666
  } finally {
8670
8667
  x(), h();
8671
8668
  }
8672
8669
  },
8673
- sub: (_, L) => {
8670
+ sub: (_, I) => {
8674
8671
  const y = A(_).l;
8675
- return y.add(L), h(), () => {
8676
- y.delete(L), E(_), h();
8672
+ return y.add(I), h(), () => {
8673
+ y.delete(I), E(_), h();
8677
8674
  };
8678
8675
  }
8679
8676
  };
@@ -8703,18 +8700,18 @@ const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), d
8703
8700
  let l = o;
8704
8701
  const i = (p) => (u) => {
8705
8702
  l === p && n(u);
8706
- }, c = (p) => (u) => {
8703
+ }, d = (p) => (u) => {
8707
8704
  l === p && a(u);
8708
- }, d = (p) => {
8705
+ }, c = (p) => {
8709
8706
  "onCancel" in p && typeof p.onCancel == "function" && p.onCancel((u) => {
8710
- isPromiseLike(u) ? (continuablePromiseMap.set(u, r), l = u, u.then(i(u), c(u)), d(u)) : n(u);
8707
+ isPromiseLike(u) ? (continuablePromiseMap.set(u, r), l = u, u.then(i(u), d(u)), c(u)) : n(u);
8711
8708
  });
8712
8709
  };
8713
- o.then(i(o), c(o)), d(o);
8710
+ o.then(i(o), d(o)), c(o);
8714
8711
  }), continuablePromiseMap.set(o, r)), r;
8715
8712
  };
8716
8713
  function useAtomValue(o, r) {
8717
- const n = useStore(), [[a, l, i], c] = useReducer(
8714
+ const n = useStore(), [[a, l, i], d] = useReducer(
8718
8715
  (u) => {
8719
8716
  const g = n.get(o);
8720
8717
  return Object.is(u[0], g) && u[1] === n && u[2] === o ? u : [g, n, o];
@@ -8722,17 +8719,17 @@ function useAtomValue(o, r) {
8722
8719
  void 0,
8723
8720
  () => [n.get(o), n, o]
8724
8721
  );
8725
- let d = a;
8726
- if ((l !== n || i !== o) && (c(), d = n.get(o)), useEffect(() => {
8722
+ let c = a;
8723
+ if ((l !== n || i !== o) && (d(), c = n.get(o)), useEffect(() => {
8727
8724
  const u = n.sub(o, () => {
8728
- c();
8725
+ d();
8729
8726
  });
8730
- return c(), u;
8731
- }, [n, o, void 0]), useDebugValue(d), isPromiseLike(d)) {
8732
- const u = createContinuablePromise(d);
8727
+ return d(), u;
8728
+ }, [n, o, void 0]), useDebugValue(c), isPromiseLike(c)) {
8729
+ const u = createContinuablePromise(c);
8733
8730
  return use(u);
8734
8731
  }
8735
- return d;
8732
+ return c;
8736
8733
  }
8737
8734
  function useSetAtom(o, r) {
8738
8735
  const n = useStore();
@@ -8786,7 +8783,7 @@ function usePubSub(o, r) {
8786
8783
  }, [o, r]);
8787
8784
  }
8788
8785
  function AIChatPanel() {
8789
- const [o, r] = useState([]), [n, a] = useState(""), [l, i] = useState(!1), [c, d] = useState(null), p = useRef(null), u = useRef(null), g = useRef(null);
8786
+ const [o, r] = useState([]), [n, a] = useState(""), [l, i] = useState(!1), [d, c] = useState(null), p = useRef(null), u = useRef(null), g = useRef(null);
8790
8787
  useEffect(() => {
8791
8788
  var b;
8792
8789
  (b = u.current) == null || b.scrollIntoView({ behavior: "smooth" });
@@ -8794,7 +8791,7 @@ function AIChatPanel() {
8794
8791
  g.current && (g.current.style.height = "auto", g.current.style.height = `${Math.min(g.current.scrollHeight, 120)}px`);
8795
8792
  }, [n]);
8796
8793
  const f = async () => {
8797
- if (!n.trim() && !c) return;
8794
+ if (!n.trim() && !d) return;
8798
8795
  const b = {
8799
8796
  id: Date.now().toString(),
8800
8797
  role: "user",
@@ -8808,7 +8805,7 @@ function AIChatPanel() {
8808
8805
  content: "This is a sample response from the AI assistant. In a real implementation, this would be replaced with an actual response from the AI model.",
8809
8806
  timestamp: /* @__PURE__ */ new Date()
8810
8807
  };
8811
- r((w) => [...w, S]), i(!1), d(null);
8808
+ r((w) => [...w, S]), i(!1), c(null);
8812
8809
  }, 1500);
8813
8810
  }, m = (b) => {
8814
8811
  b.key === "Enter" && !b.shiftKey && (b.preventDefault(), f());
@@ -8819,14 +8816,14 @@ function AIChatPanel() {
8819
8816
  const A = new FileReader();
8820
8817
  A.onload = (E) => {
8821
8818
  var C;
8822
- d((C = E.target) == null ? void 0 : C.result);
8819
+ c((C = E.target) == null ? void 0 : C.result);
8823
8820
  }, A.readAsDataURL(S);
8824
8821
  }
8825
8822
  }, x = () => {
8826
8823
  var b;
8827
8824
  (b = p.current) == null || b.click();
8828
8825
  }, k = () => {
8829
- d(null), p.current && (p.current.value = "");
8826
+ c(null), p.current && (p.current.value = "");
8830
8827
  };
8831
8828
  return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
8832
8829
  /* @__PURE__ */ jsx(ScrollArea, { className: "flex-1 p-3", children: o.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "mt-10 flex h-full flex-col items-center justify-center p-4 text-center text-muted-foreground", children: [
@@ -8863,8 +8860,8 @@ function AIChatPanel() {
8863
8860
  ] }),
8864
8861
  /* @__PURE__ */ jsx("div", { ref: u })
8865
8862
  ] }) }),
8866
- c && /* @__PURE__ */ jsx("div", { className: "px-3 pt-2", children: /* @__PURE__ */ jsxs("div", { className: "relative h-20 w-20 overflow-hidden rounded-md", children: [
8867
- /* @__PURE__ */ jsx("img", { src: c || "/placeholder.svg", alt: "Attachment", className: "h-full w-full object-cover" }),
8863
+ d && /* @__PURE__ */ jsx("div", { className: "px-3 pt-2", children: /* @__PURE__ */ jsxs("div", { className: "relative h-20 w-20 overflow-hidden rounded-md", children: [
8864
+ /* @__PURE__ */ jsx("img", { src: d || "/placeholder.svg", alt: "Attachment", className: "h-full w-full object-cover" }),
8868
8865
  /* @__PURE__ */ jsx(
8869
8866
  Button,
8870
8867
  {
@@ -8907,7 +8904,7 @@ function AIChatPanel() {
8907
8904
  size: "sm",
8908
8905
  className: "h-10 px-3",
8909
8906
  onClick: f,
8910
- disabled: l || !n.trim() && !c,
8907
+ disabled: l || !n.trim() && !d,
8911
8908
  children: [
8912
8909
  /* @__PURE__ */ jsx(Send, { className: "mr-1 h-4 w-4" }),
8913
8910
  "Send"
@@ -8991,18 +8988,18 @@ const AiAssistant = () => {
8991
8988
  ] })
8992
8989
  ] });
8993
8990
  }, AddBlocksDialog = () => {
8994
- const { t: o } = useTranslation(), [r, n] = useState(""), [a, l] = useState(-1), [i, c] = useState(!1);
8995
- return usePubSub(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, (d) => {
8996
- n(d ? d._id : null), l(isNaN(d == null ? void 0 : d.position) ? -1 : d == null ? void 0 : d.position), c(!0);
8991
+ const { t: o } = useTranslation(), [r, n] = useState(""), [a, l] = useState(-1), [i, d] = useState(!1);
8992
+ return usePubSub(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, (c) => {
8993
+ n(c ? c._id : null), l(isNaN(c == null ? void 0 : c.position) ? -1 : c == null ? void 0 : c.position), d(!0);
8997
8994
  }), usePubSub(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK, () => {
8998
- n(""), l(-1), c(!1);
8999
- }), /* @__PURE__ */ jsx(AlertDialog, { open: i, onOpenChange: () => i ? c(!1) : "", children: /* @__PURE__ */ jsxs(AlertDialogContent, { className: "max-w-5xl overflow-hidden border-border", children: [
8995
+ n(""), l(-1), d(!1);
8996
+ }), /* @__PURE__ */ jsx(AlertDialog, { open: i, onOpenChange: () => i ? d(!1) : "", children: /* @__PURE__ */ jsxs(AlertDialogContent, { className: "max-w-5xl overflow-hidden border-border", children: [
9000
8997
  /* @__PURE__ */ jsxs(AlertDialogHeader, { className: "flex flex-row items-center justify-between", children: [
9001
8998
  /* @__PURE__ */ jsx(AlertDialogTitle, { className: "text-foreground", children: o("Add blocks") }),
9002
8999
  /* @__PURE__ */ jsx(
9003
9000
  "button",
9004
9001
  {
9005
- onClick: () => c(!1),
9002
+ onClick: () => d(!1),
9006
9003
  className: "text-gray-500 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-300",
9007
9004
  children: /* @__PURE__ */ jsx(Cross2Icon, { className: "h-6 w-6" })
9008
9005
  }
@@ -9014,7 +9011,7 @@ const AiAssistant = () => {
9014
9011
  preloadedAttributes: r = [],
9015
9012
  onAttributesChange: n
9016
9013
  }) {
9017
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [f, m] = useState(""), h = useRef(null), x = useRef(null), k = usePageExternalData();
9014
+ const [a, l] = useState([]), [i, d] = useState(""), [c, p] = useState(""), [u, g] = useState(null), [f, m] = useState(""), h = useRef(null), x = useRef(null), k = usePageExternalData();
9018
9015
  useEffect(() => {
9019
9016
  l(r);
9020
9017
  }, [r]);
@@ -9024,14 +9021,14 @@ const AiAssistant = () => {
9024
9021
  return;
9025
9022
  }
9026
9023
  if (i) {
9027
- const B = [...a, { key: i, value: d }];
9028
- n(B), l(a), c(""), p(""), m("");
9024
+ const B = [...a, { key: i, value: c }];
9025
+ n(B), l(a), d(""), p(""), m("");
9029
9026
  }
9030
9027
  }, S = (B) => {
9031
- const _ = a.filter((L, v) => v !== B);
9028
+ const _ = a.filter((I, v) => v !== B);
9032
9029
  n(_), l(_);
9033
9030
  }, w = (B) => {
9034
- g(B), c(a[B].key), p(a[B].value);
9031
+ g(B), d(a[B].key), p(a[B].value);
9035
9032
  }, A = () => {
9036
9033
  if (i.startsWith("@")) {
9037
9034
  m("Attribute keys cannot start with '@'");
@@ -9039,28 +9036,28 @@ const AiAssistant = () => {
9039
9036
  }
9040
9037
  if (u !== null && i) {
9041
9038
  const B = [...a];
9042
- B[u] = { key: i, value: d }, n(B), l(B), g(null), c(""), p(""), m("");
9039
+ B[u] = { key: i, value: c }, n(B), l(B), g(null), d(""), p(""), m("");
9043
9040
  }
9044
9041
  }, E = (B) => {
9045
9042
  B.key === "Enter" && !B.shiftKey && (B.preventDefault(), u !== null ? A() : b());
9046
9043
  }, C = useCallback((B) => {
9047
- const _ = (y) => /[.,!?;:]/.test(y), L = (y, j, T) => {
9048
- let I = "", P = "";
9044
+ const _ = (y) => /[.,!?;:]/.test(y), I = (y, j, T) => {
9045
+ let L = "", P = "";
9049
9046
  const N = j > 0 ? y[j - 1] : "", D = j < y.length ? y[j] : "";
9050
- return j > 0 && (N === "." || !_(N) && N !== " ") && (I = " "), j < y.length && !_(D) && D !== " " && (P = " "), {
9051
- text: I + T + P,
9052
- prefixLength: I.length,
9047
+ return j > 0 && (N === "." || !_(N) && N !== " ") && (L = " "), j < y.length && !_(D) && D !== " " && (P = " "), {
9048
+ text: L + T + P,
9049
+ prefixLength: L.length,
9053
9050
  suffixLength: P.length
9054
9051
  };
9055
9052
  }, v = x.current;
9056
9053
  if (v) {
9057
9054
  const y = v.selectionStart || 0, j = v.value || "", T = v.selectionEnd || y;
9058
9055
  if (T > y) {
9059
- const O = `{{${B}}}`, { text: R } = L(j, y, O), $ = j.slice(0, y) + R + j.slice(T);
9056
+ const O = `{{${B}}}`, { text: R } = I(j, y, O), $ = j.slice(0, y) + R + j.slice(T);
9060
9057
  p($);
9061
9058
  return;
9062
9059
  }
9063
- const P = `{{${B}}}`, { text: N } = L(j, y, P), D = j.slice(0, y) + N + j.slice(y);
9060
+ const P = `{{${B}}}`, { text: N } = I(j, y, P), D = j.slice(0, y) + N + j.slice(y);
9064
9061
  p(D);
9065
9062
  }
9066
9063
  }, []);
@@ -9085,7 +9082,7 @@ const AiAssistant = () => {
9085
9082
  id: "attrKey",
9086
9083
  ref: h,
9087
9084
  value: i,
9088
- onChange: (B) => c(B.target.value),
9085
+ onChange: (B) => d(B.target.value),
9089
9086
  placeholder: "Enter Key",
9090
9087
  className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
9091
9088
  }
@@ -9105,7 +9102,7 @@ const AiAssistant = () => {
9105
9102
  id: "attrValue",
9106
9103
  rows: 2,
9107
9104
  ref: x,
9108
- value: d,
9105
+ value: c,
9109
9106
  onChange: (B) => p(B.target.value),
9110
9107
  onKeyDown: E,
9111
9108
  placeholder: "Enter Value",
@@ -9133,19 +9130,19 @@ const AiAssistant = () => {
9133
9130
  }), BlockAttributesEditor = React.memo(() => {
9134
9131
  const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
9135
9132
  React.useEffect(() => {
9136
- const d = map(get(o, i), (p, u) => ({ key: u, value: p }));
9137
- isEmpty(d) ? n([]) : n(d);
9133
+ const c = map(get(o, i), (p, u) => ({ key: u, value: p }));
9134
+ isEmpty(c) ? n([]) : n(c);
9138
9135
  }, [get(o, i)]);
9139
- const c = React.useCallback(
9140
- (d = []) => {
9136
+ const d = React.useCallback(
9137
+ (c = []) => {
9141
9138
  const p = {};
9142
- forEach(d, (u) => {
9139
+ forEach(c, (u) => {
9143
9140
  isEmpty(u.key) || set(p, u.key, u.value);
9144
9141
  }), l([get(o, "_id")], { [i]: p });
9145
9142
  },
9146
9143
  [o, l, i]
9147
9144
  );
9148
- return /* @__PURE__ */ jsx("div", { className: "flex-col gap-y-2", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(AttrsEditor, { preloadedAttributes: r, onAttributesChange: c }) }) }) });
9145
+ return /* @__PURE__ */ jsx("div", { className: "flex-col gap-y-2", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(AttrsEditor, { preloadedAttributes: r, onAttributesChange: d }) }) }) });
9149
9146
  }), NoopComponent = () => null;
9150
9147
  function BlockAttributesToggle() {
9151
9148
  const { t: o } = useTranslation(), [r, n] = useState(!0), [a] = useSelectedStylingBlocks();
@@ -9233,7 +9230,7 @@ function useSidebarMenuItems() {
9233
9230
  }, [o, r]);
9234
9231
  }
9235
9232
  const RootLayout = () => {
9236
- const o = useTopBarComponent(), [r, n] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel();
9233
+ const o = useTopBarComponent(), [r, n] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [d, c] = useRightPanel();
9237
9234
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9238
9235
  n("outline");
9239
9236
  });
@@ -9327,11 +9324,11 @@ const RootLayout = () => {
9327
9324
  animate: { width: r === "ai" ? 0 : DEFAULT_PANEL_WIDTH },
9328
9325
  transition: { duration: 0.3, ease: "easeInOut" },
9329
9326
  children: /* @__PURE__ */ jsx("div", { className: "no-scrollbar overflow h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col overflow-hidden p-3", children: [
9330
- /* @__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: [
9327
+ /* @__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: d === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9331
9328
  /* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
9332
9329
  " ",
9333
9330
  h("AI Assistant")
9334
- ] }) }) : c === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
9331
+ ] }) }) : d === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
9335
9332
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
9336
9333
  /* @__PURE__ */ jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
9337
9334
  h("Theme Settings")
@@ -9339,7 +9336,7 @@ const RootLayout = () => {
9339
9336
  /* @__PURE__ */ jsx(
9340
9337
  Button,
9341
9338
  {
9342
- onClick: () => d("block"),
9339
+ onClick: () => c("block"),
9343
9340
  variant: "ghost",
9344
9341
  size: "icon",
9345
9342
  className: "text-xs",
@@ -9347,7 +9344,7 @@ const RootLayout = () => {
9347
9344
  }
9348
9345
  )
9349
9346
  ] }) : null }) }) }),
9350
- /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: c === "ai" ? /* @__PURE__ */ jsx(AskAI, {}) : c === "theme" ? /* @__PURE__ */ jsx(ThemeConfigPanel, {}) : /* @__PURE__ */ jsx(SettingsPanel, {}) }) })
9347
+ /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: d === "ai" ? /* @__PURE__ */ jsx(AskAI, {}) : d === "theme" ? /* @__PURE__ */ jsx(ThemeConfigPanel, {}) : /* @__PURE__ */ jsx(SettingsPanel, {}) }) })
9351
9348
  ] }) })
9352
9349
  }
9353
9350
  ),
@@ -9429,9 +9426,9 @@ const RootLayout = () => {
9429
9426
  r && o(!0);
9430
9427
  }, n * 1e3);
9431
9428
  }, ChaiBuilderComponent = (o) => {
9432
- const [, r] = useBlocksStore(), n = useBuilderReset(), [a] = useAtom(builderSaveStateAtom), l = useMemo(() => o.layout || RootLayout, [o.layout]);
9429
+ const [, r] = useBlocksStore(), n = useBuilderProp("builderTheme", defaultThemeValues), a = useBuilderReset(), [l] = useAtom(builderSaveStateAtom), i = useMemo(() => o.layout || RootLayout, [o.layout]);
9433
9430
  useAtom(selectedLibraryAtom), useKeyEventWatcher(), useExpandTree(), useAutoSave(), useWatchPartailBlocks(), useUnmountBroadcastChannel();
9434
- const { postMessage: i } = useBroadcastChannel();
9431
+ const { postMessage: d } = useBroadcastChannel();
9435
9432
  return useEffect(() => {
9436
9433
  builderStore.set(
9437
9434
  // @ts-ignore
@@ -9443,21 +9440,21 @@ const RootLayout = () => {
9443
9440
  }, [o.pageExternalData]), useEffect(() => {
9444
9441
  setTimeout(() => {
9445
9442
  const c = syncBlocksWithDefaults(o.blocks || []);
9446
- r(c), c && c.length > 0 && i({ type: "blocks-updated", blocks: c }), n();
9443
+ r(c), c && c.length > 0 && d({ type: "blocks-updated", blocks: c }), a();
9447
9444
  }, 400);
9448
9445
  }, [o.blocks]), useEffect(() => {
9449
9446
  i18n.changeLanguage(o.locale || "en");
9450
9447
  }, [o.locale]), useEffect(() => {
9451
9448
  setDebugLogs(o.debugLogs);
9452
9449
  }, [o.debugLogs]), useEffect(() => {
9453
- o.translations && each(o.translations, (c, d) => {
9454
- i18n.addResourceBundle(d, "translation", c, !0, !0);
9450
+ o.translations && each(o.translations, (c, p) => {
9451
+ i18n.addResourceBundle(p, "translation", c, !0, !0);
9455
9452
  });
9456
- }, [o.translations]), useEffect(() => (a !== "SAVED" ? window.onbeforeunload = () => "" : window.onbeforeunload = null, () => {
9453
+ }, [o.translations]), useEffect(() => (l !== "SAVED" ? window.onbeforeunload = () => "" : window.onbeforeunload = null, () => {
9457
9454
  window.onbeforeunload = null;
9458
- }), [a]), /* @__PURE__ */ jsxs(Fragment, { children: [
9459
- /* @__PURE__ */ jsx(PrimaryColorCSSVariable, {}),
9460
- /* @__PURE__ */ jsx(l, {})
9455
+ }), [l]), /* @__PURE__ */ jsxs(Fragment, { children: [
9456
+ /* @__PURE__ */ jsx(CssThemeVariables, { theme: n }),
9457
+ /* @__PURE__ */ jsx(i, {})
9461
9458
  ] });
9462
9459
  }, ChaiBuilderEditor = (o) => {
9463
9460
  const r = o.onError || noop;
@@ -9548,7 +9545,7 @@ export {
9548
9545
  useStylingState,
9549
9546
  useTheme,
9550
9547
  useThemeOptions,
9551
- Ue as useTranslation,
9548
+ Ve as useTranslation,
9552
9549
  useUILibraryBlocks,
9553
9550
  useUndoManager,
9554
9551
  useUpdateBlocksProps,