@chaibuilder/sdk 3.1.8 → 3.1.10

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.
@@ -3,7 +3,7 @@ var W = (o, n, r) => n in o ? U(o, n, { enumerable: !0, configurable: !0, writab
3
3
  var $ = (o, n, r) => W(o, typeof n != "symbol" ? n + "" : n, r);
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, syncBlocksWithDefaults, useRegisteredFonts, getBlockFormSchemas } from "@chaibuilder/runtime";
6
- import { get, find, filter, flatten, has, map, includes, without, compact, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, kebabCase, round, reverse, findIndex, uniq, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, sortBy } from "lodash-es";
6
+ import { get, find, filter, flatten, has, map, includes, without, compact, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, kebabCase, round, reverse, findIndex, uniq, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, sortBy, camelCase } from "lodash-es";
7
7
  import { SquareIcon, ZoomInIcon, ChevronRightIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, GearIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, CaretDownIcon, Cross1Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, ListBulletIcon, ValueIcon, TextAlignCenterIcon, TextAlignRightIcon, TextAlignLeftIcon, Link2Icon, LinkBreak2Icon, EnterFullScreenIcon, ExclamationTriangleIcon, Pencil2Icon, ChevronLeftIcon, LoopIcon, IdCardIcon, PlusCircledIcon, ChevronDownIcon, InfoCircledIcon, FileIcon, DotsVerticalIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, BoxIcon, MinusIcon, CrossCircledIcon, MobileIcon, LaptopIcon, DesktopIcon, CircleIcon, MagnifyingGlassIcon, ReloadIcon, CaretRightIcon, FrameIcon, EraserIcon, CheckIcon, DownloadIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, DoubleArrowDownIcon, DoubleArrowUpIcon, ResetIcon, UploadIcon, TextIcon, CornerTopRightIcon, MixerHorizontalIcon, SunIcon, MoonIcon, FaceIcon, ShuffleIcon, ChatBubbleIcon, StopIcon, DotsHorizontalIcon, LightningBoltIcon, StackIcon, DragHandleDots2Icon } from "@radix-ui/react-icons";
8
8
  import * as React from "react";
9
9
  import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, lazy, useReducer, useDebugValue } from "react";
@@ -14,7 +14,7 @@ import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as Dropd
14
14
  import clsx$1, { clsx } from "clsx";
15
15
  import { twMerge } from "tailwind-merge";
16
16
  import TreeModel from "tree-model";
17
- import { C as COLLECTION_PREFIX, S as STYLES_KEY, i as getSplitChaiClasses, h as getBlocksFromHTML, m as mergeBlocksWithExisting, e as adjustSpacingInContentBlocks, a as applyBindingToBlockProps, b as applyLanguage, g as getBlockTagAttributes, c as getBlockRuntimeProps, d as applyLimit, R as REPEATER_PREFIX, j as ROOT_TEMP_KEY } from "./apply-binding-w7OMcHcu.js";
17
+ import { C as COLLECTION_PREFIX, S as STYLES_KEY, i as getSplitChaiClasses, h as getBlocksFromHTML, m as mergeBlocksWithExisting, e as adjustSpacingInContentBlocks, a as applyBindingToBlockProps, b as applyLanguage, g as getBlockTagAttributes, c as getBlockRuntimeProps, d as applyLimit, R as REPEATER_PREFIX, j as ROOT_TEMP_KEY } from "./apply-binding-DXR0sMuX.js";
18
18
  import { d as defaultThemeOptions, f as defaultThemeValues, a as getChaiThemeCssVariables, g as getChaiThemeOptions, p as plugin, h as getThemeFontsUrls, i as getThemeCustomFontFace } from "./plugin-BOcGV_IY.js";
19
19
  import { isObject } from "@rjsf/utils";
20
20
  import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useDebouncedState, useIntervalEffect } from "@react-hookz/web";
@@ -36,7 +36,6 @@ import RjForm from "@rjsf/core";
36
36
  import validator from "@rjsf/validator-ajv8";
37
37
  import Autosuggest from "react-autosuggest";
38
38
  import { useFeature } from "flagged";
39
- import { compact as compact$1, pick as pick$1, each as each$1, get as get$1, noop as noop$1, kebabCase as kebabCase$1, camelCase } from "lodash";
40
39
  import { Tree } from "react-arborist";
41
40
  import { parse, stringify } from "himalaya";
42
41
  import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
@@ -223,16 +222,16 @@ function insertBlocksAtPosition(o, n, r, a) {
223
222
  const l = [...n];
224
223
  let i = [...o];
225
224
  if (r) {
226
- const d = o.find((g) => g._id === r);
227
- if (d && d.content !== void 0 && d.content !== "" && !o.some((m) => m._parent === r)) {
225
+ const u = o.find((g) => g._id === r);
226
+ if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
228
227
  const h = {
229
228
  _id: generateUUID(),
230
229
  _parent: r,
231
230
  _type: "Text",
232
- content: d.content
231
+ content: u.content
233
232
  };
234
- Object.keys(d).forEach((f) => {
235
- f.startsWith("content-") && (h[f] = d[f]);
233
+ Object.keys(u).forEach((f) => {
234
+ f.startsWith("content-") && (h[f] = u[f]);
236
235
  }), l.unshift(h), i = i.map((f) => {
237
236
  if (f._id === r) {
238
237
  const x = { ...f, content: "" };
@@ -244,14 +243,14 @@ function insertBlocksAtPosition(o, n, r, a) {
244
243
  });
245
244
  }
246
245
  }
247
- let c = i.filter((d) => !d._parent);
248
- r && (c = i.filter((d) => d._parent === r));
249
- const u = !isNaN(a) || a > -1 ? Math.min(a, c.length) : c.length;
246
+ let c = i.filter((u) => !u._parent);
247
+ r && (c = i.filter((u) => u._parent === r));
248
+ const d = !isNaN(a) || a > -1 ? Math.min(a, c.length) : c.length;
250
249
  let p = i.length;
251
- for (let d = 0, g = 0; d < i.length; d++)
252
- if (r !== void 0 ? i[d]._parent === r : !i[d]._parent) {
253
- if (g === u) {
254
- p = d;
250
+ for (let u = 0, g = 0; u < i.length; u++)
251
+ if (r !== void 0 ? i[u]._parent === r : !i[u]._parent) {
252
+ if (g === d) {
253
+ p = u;
255
254
  break;
256
255
  }
257
256
  g++;
@@ -269,11 +268,11 @@ function findNodeById(o, n) {
269
268
  return o.first((r) => r.model._id === n) || null;
270
269
  }
271
270
  function moveNode(o, n, r, a) {
272
- var d, g;
271
+ var u, g;
273
272
  const l = findNodeById(o, n), i = findNodeById(o, r);
274
273
  if (!l || !i) return !1;
275
274
  i.children || (i.model.children = []);
276
- let c = (d = i == null ? void 0 : i.children) == null ? void 0 : d.findIndex((m) => m.model._id === n);
275
+ let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((m) => m.model._id === n);
277
276
  l.drop(), c = Math.max(c, 0);
278
277
  const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === r && c <= a ? a - 1 : a;
279
278
  try {
@@ -291,15 +290,15 @@ function handleOldParentTextBlock(o, n) {
291
290
  if (l.length === 2) {
292
291
  const i = l.find((c) => c._id !== n._id);
293
292
  if (i && i._type === "Text" && "content" in a)
294
- return o.map((u) => {
295
- if (u._id === r) {
296
- const p = { ...u, content: i.content };
297
- return Object.keys(i).forEach((d) => {
298
- d.startsWith("content-") && (p[d] = i[d]);
293
+ return o.map((d) => {
294
+ if (d._id === r) {
295
+ const p = { ...d, content: i.content };
296
+ return Object.keys(i).forEach((u) => {
297
+ u.startsWith("content-") && (p[u] = i[u]);
299
298
  }), p;
300
299
  }
301
- return u;
302
- }).filter((u) => u._id !== i._id);
300
+ return d;
301
+ }).filter((d) => d._id !== i._id);
303
302
  }
304
303
  return o;
305
304
  }
@@ -314,32 +313,32 @@ function handleNewParentTextBlock(o, n, r) {
314
313
  _type: "Text",
315
314
  content: a.content
316
315
  };
317
- Object.keys(a).forEach((d) => {
318
- d.startsWith("content-") && (c[d] = a[d]);
316
+ Object.keys(a).forEach((u) => {
317
+ u.startsWith("content-") && (c[u] = a[u]);
319
318
  });
320
- const u = o.map((d) => {
321
- if (d._id === r) {
322
- const g = { ...d, content: "" };
319
+ const d = o.map((u) => {
320
+ if (u._id === r) {
321
+ const g = { ...u, content: "" };
323
322
  return Object.keys(g).forEach((m) => {
324
323
  m.startsWith("content-") && (g[m] = "");
325
324
  }), g;
326
325
  }
327
- return d;
328
- }), p = u.findIndex((d) => d._id === n._id);
329
- return p !== -1 ? [...u.slice(0, p), c, ...u.slice(p)] : [c, ...u];
326
+ return u;
327
+ }), p = d.findIndex((u) => u._id === n._id);
328
+ return p !== -1 ? [...d.slice(0, p), c, ...d.slice(p)] : [c, ...d];
330
329
  }
331
330
  return o;
332
331
  }
333
332
  function moveBlocksWithChildren(o, n, r, a) {
334
333
  if (!n) return o;
335
- const l = o.find((d) => d._id === n);
334
+ const l = o.find((u) => u._id === n);
336
335
  if (!l) return o;
337
336
  let i = handleOldParentTextBlock(o, l);
338
337
  const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
339
338
  if (moveNode(p, n, c, a)) {
340
- let d = flattenTree(p);
341
- const g = d.find((m) => m._id === n);
342
- return g && (g._parent = c === "root" ? null : c), d.shift(), r && (d = handleNewParentTextBlock(d, l, r)), d;
339
+ let u = flattenTree(p);
340
+ const g = u.find((m) => m._id === n);
341
+ return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
343
342
  }
344
343
  return i;
345
344
  }
@@ -361,16 +360,16 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
361
360
  }), [o, n]);
362
361
  }, removeNestedBlocks = (o, n) => {
363
362
  let r = [...o], a = [];
364
- n.forEach((u) => {
365
- const p = r.find((m) => m._id === u);
363
+ n.forEach((d) => {
364
+ const p = r.find((m) => m._id === d);
366
365
  if (!p || !p._parent) return;
367
- const d = p._parent, g = r.filter((m) => m._parent === d);
366
+ const u = p._parent, g = r.filter((m) => m._parent === u);
368
367
  if (g.length === 2) {
369
- const m = g.find((h) => h._id !== u);
368
+ const m = g.find((h) => h._id !== d);
370
369
  if (m && m._type === "Text") {
371
- const h = r.find((f) => f._id === d);
370
+ const h = r.find((f) => f._id === u);
372
371
  h && "content" in h && (r = r.map((f) => {
373
- if (f._id === d) {
372
+ if (f._id === u) {
374
373
  const x = { ...f, content: m.content };
375
374
  return Object.keys(m).forEach((b) => {
376
375
  b.startsWith("content-") && (x[b] = m[b]);
@@ -381,15 +380,15 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
381
380
  }
382
381
  }
383
382
  });
384
- const l = [...n, ...a], i = [], c = filter(r, (u) => includes(l, u._id) || includes(l, u._parent) ? (i.push(u._id), !1) : !0);
383
+ const l = [...n, ...a], i = [], c = filter(r, (d) => includes(l, d._id) || includes(l, d._parent) ? (i.push(d._id), !1) : !0);
385
384
  return isEmpty(i) ? c : removeNestedBlocks(c, i);
386
385
  }, useRemoveBlocks = () => {
387
386
  const [o] = useBlocksStore(), [n, r] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions(), { hasPermission: l } = usePermissions();
388
387
  return useCallback(
389
388
  (i) => {
390
- var u;
389
+ var d;
391
390
  if (!l(PERMISSIONS.DELETE_BLOCK)) return;
392
- const c = ((u = find(o, { _id: i[0] })) == null ? void 0 : u._parent) || null;
391
+ const c = ((d = find(o, { _id: i[0] })) == null ? void 0 : d._parent) || null;
393
392
  a(removeNestedBlocks(o, i)), setTimeout(() => r(c ? [c] : []), 200);
394
393
  },
395
394
  [o, r, n, l]
@@ -424,8 +423,8 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
424
423
  },
425
424
  addBlocks: (a, l, i) => {
426
425
  o((c) => {
427
- const u = insertBlocksAtPosition(c, a, l, i);
428
- return n({ type: "blocks-updated", blocks: u }), u;
426
+ const d = insertBlocksAtPosition(c, a, l, i);
427
+ return n({ type: "blocks-updated", blocks: d }), d;
429
428
  });
430
429
  },
431
430
  removeBlocks: (a) => {
@@ -436,13 +435,13 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
436
435
  },
437
436
  moveBlocks: (a, l, i) => {
438
437
  o((c) => {
439
- let u = [...c];
438
+ let d = [...c];
440
439
  for (let p = 0; p < a.length; p++)
441
- u = moveBlocksWithChildren(u, a[p], l, i);
440
+ d = moveBlocksWithChildren(d, a[p], l, i);
442
441
  return each(a, (p) => {
443
- const d = find(u, (g) => g._id === p);
444
- d && r({ id: p, props: { _parent: d._parent || null } });
445
- }), n({ type: "blocks-updated", blocks: u }), u;
442
+ const u = find(d, (g) => g._id === p);
443
+ u && r({ id: p, props: { _parent: u._parent || null } });
444
+ }), n({ type: "blocks-updated", blocks: d }), d;
446
445
  });
447
446
  },
448
447
  updateBlocksProps: (a) => {
@@ -459,7 +458,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
459
458
  status: "idle",
460
459
  props: {},
461
460
  error: void 0
462
- }), c = useUpdateBlocksPropsRealtime(), u = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), d = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), m = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
461
+ }), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), m = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
463
462
  return useEffect(() => {
464
463
  if (n === "mock") {
465
464
  if (isFunction(a)) {
@@ -471,7 +470,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
471
470
  }
472
471
  return;
473
472
  }
474
- n === "live" && (!g && !m || (i((f) => ({ ...f, status: "loading", props: {} })), u({ block: o }).then((f = {}) => {
473
+ n === "live" && (!g && !m || (i((f) => ({ ...f, status: "loading", props: {} })), d({ block: o }).then((f = {}) => {
475
474
  g ? (p((x) => ({
476
475
  ...x,
477
476
  [o._id]: {
@@ -486,7 +485,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
486
485
  [o._id]: { status: "error", error: f, props: [] }
487
486
  })), i((x) => ({ ...x, status: "error", error: f, props: {} }))) : i((x) => ({ ...x, status: "error", error: f, props: {} }));
488
487
  })));
489
- }, [o == null ? void 0 : o._id, d, g, m, a, n]), {
488
+ }, [o == null ? void 0 : o._id, u, g, m, a, n]), {
490
489
  $loading: get(l, "status") === "loading",
491
490
  ...o ? get(l, "props", {}) : {}
492
491
  };
@@ -640,13 +639,13 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
640
639
  }
641
640
  }) : !1, useSavePage = () => {
642
641
  const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (f) => {
643
- }), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: u, fallbackLang: p } = useLanguages(), [d] = useIsPageLoaded(), g = () => {
642
+ }), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), [u] = useIsPageLoaded(), g = () => {
644
643
  const f = l();
645
- return !u || u === p ? !1 : checkMissingTranslations(f.blocks || [], u);
644
+ return !d || d === p ? !1 : checkMissingTranslations(f.blocks || [], d);
646
645
  };
647
646
  return { savePage: useThrottledCallback(
648
647
  async (f = !1) => {
649
- if (!c("save_page") || !d)
648
+ if (!c("save_page") || !u)
650
649
  return;
651
650
  n("SAVING"), a("SAVING");
652
651
  const x = l();
@@ -659,11 +658,11 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
659
658
  n("SAVED"), a("SAVED");
660
659
  }, 100), !0;
661
660
  },
662
- [l, n, i, r, a, d],
661
+ [l, n, i, r, a, u],
663
662
  3e3
664
663
  // save only every 5 seconds
665
664
  ), savePageAsync: async () => {
666
- if (!c("save_page") || !d)
665
+ if (!c("save_page") || !u)
667
666
  return;
668
667
  n("SAVING"), a("SAVING");
669
668
  const f = l();
@@ -683,23 +682,23 @@ const undoRedoStateAtom = atom({
683
682
  canRedo: !1
684
683
  }), useUndoManager = () => {
685
684
  const [, o] = useAtom$1(builderSaveStateAtom), [n, r] = useAtom$1(undoRedoStateAtom), a = useBuilderProp("onSaveStateChange", noop), l = useCallback(() => {
686
- const d = {
685
+ const u = {
687
686
  canUndo: undoManager.hasUndo(),
688
687
  canRedo: undoManager.hasRedo()
689
688
  };
690
- r(d), o("UNSAVED"), a("UNSAVED");
689
+ r(u), o("UNSAVED"), a("UNSAVED");
691
690
  }, [r, o, a]);
692
691
  useEffect(() => (undoManager.setCallback(l), () => {
693
692
  undoManager.setCallback(noop);
694
693
  }), [l]);
695
694
  const i = useCallback(
696
- (d) => {
697
- undoManager.add(d), l();
695
+ (u) => {
696
+ undoManager.add(u), l();
698
697
  },
699
698
  [l]
700
699
  ), c = useCallback(() => {
701
700
  undoManager.undo(), l();
702
- }, [l]), u = useCallback(() => {
701
+ }, [l]), d = useCallback(() => {
703
702
  undoManager.redo(), l();
704
703
  }, [l]), p = useCallback(() => {
705
704
  undoManager.clear(), r({
@@ -711,12 +710,12 @@ const undoRedoStateAtom = atom({
711
710
  () => ({
712
711
  add: i,
713
712
  undo: c,
714
- redo: u,
713
+ redo: d,
715
714
  hasUndo: () => n.canUndo,
716
715
  hasRedo: () => n.canRedo,
717
716
  clear: p
718
717
  }),
719
- [i, c, u, n.canUndo, n.canRedo, p]
718
+ [i, c, d, n.canUndo, n.canRedo, p]
720
719
  );
721
720
  }, useBlocksStore = () => useAtom$1(presentBlocksAtom), useBlocksStoreUndoableActions = () => {
722
721
  const { add: o } = useUndoManager(), [n] = useBlocksStore(), {
@@ -728,13 +727,13 @@ const undoRedoStateAtom = atom({
728
727
  } = useBlocksStoreManager();
729
728
  return {
730
729
  moveBlocks: (x, b, y) => {
731
- const C = map(x, (w) => {
732
- const B = n.find((A) => A._id === w)._parent || null, k = n.filter((A) => B ? A._parent === B : !A._parent).map((A) => A._id).indexOf(w);
733
- return { _id: w, oldParent: B, oldPosition: k };
734
- }), S = C.find(({ _id: w }) => w === x[0]);
735
- S && S.oldParent === b && S.oldPosition === y || (i(x, b, y), o({
736
- undo: () => each(C, ({ _id: w, oldParent: _, oldPosition: B }) => {
737
- i([w], _, B);
730
+ const S = map(x, (v) => {
731
+ const B = n.find((A) => A._id === v)._parent || null, k = n.filter((A) => B ? A._parent === B : !A._parent).map((A) => A._id).indexOf(v);
732
+ return { _id: v, oldParent: B, oldPosition: k };
733
+ }), C = S.find(({ _id: v }) => v === x[0]);
734
+ C && C.oldParent === b && C.oldPosition === y || (i(x, b, y), o({
735
+ undo: () => each(S, ({ _id: v, oldParent: _, oldPosition: B }) => {
736
+ i([v], _, B);
738
737
  }),
739
738
  redo: () => i(x, b, y)
740
739
  }));
@@ -746,27 +745,27 @@ const undoRedoStateAtom = atom({
746
745
  });
747
746
  },
748
747
  removeBlocks: (x) => {
749
- var S;
750
- const b = (S = first(x)) == null ? void 0 : S._parent, C = n.filter((w) => b ? w._parent === b : !w._parent).indexOf(first(x));
748
+ var C;
749
+ const b = (C = first(x)) == null ? void 0 : C._parent, S = n.filter((v) => b ? v._parent === b : !v._parent).indexOf(first(x));
751
750
  l(map(x, "_id")), o({
752
- undo: () => a(x, b, C),
751
+ undo: () => a(x, b, S),
753
752
  redo: () => l(map(x, "_id"))
754
753
  });
755
754
  },
756
755
  updateBlocks: (x, b, y) => {
757
- let C = [];
756
+ let S = [];
758
757
  if (y)
759
- C = map(x, (S) => ({ _id: S, ...y }));
758
+ S = map(x, (C) => ({ _id: C, ...y }));
760
759
  else {
761
- const S = keys(b);
762
- C = map(x, (w) => {
763
- const _ = n.find((I) => I._id === w), B = { _id: w };
764
- return each(S, (I) => B[I] = _[I]), B;
760
+ const C = keys(b);
761
+ S = map(x, (v) => {
762
+ const _ = n.find((I) => I._id === v), B = { _id: v };
763
+ return each(C, (I) => B[I] = _[I]), B;
765
764
  });
766
765
  }
767
- c(map(x, (S) => ({ _id: S, ...b }))), o({
768
- undo: () => c(C),
769
- redo: () => c(map(x, (S) => ({ _id: S, ...b })))
766
+ c(map(x, (C) => ({ _id: C, ...b }))), o({
767
+ undo: () => c(S),
768
+ redo: () => c(map(x, (C) => ({ _id: C, ...b })))
770
769
  });
771
770
  },
772
771
  updateBlocksRuntime: (x, b) => {
@@ -781,8 +780,8 @@ const undoRedoStateAtom = atom({
781
780
  updateMultipleBlocksProps: (x) => {
782
781
  let b = [];
783
782
  b = map(x, (y) => {
784
- const C = keys(y), S = n.find((_) => _._id === y._id), w = {};
785
- return each(C, (_) => w[_] = S[_]), w;
783
+ const S = keys(y), C = n.find((_) => _._id === y._id), v = {};
784
+ return each(S, (_) => v[_] = C[_]), v;
786
785
  }), c(x), o({
787
786
  undo: () => c(b),
788
787
  redo: () => c(x)
@@ -820,7 +819,7 @@ import.meta.vitest && describe("canDropBlock Function", () => {
820
819
  });
821
820
  const useAddBlock = () => {
822
821
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
823
- (i, c, u) => {
822
+ (i, c, d) => {
824
823
  var h;
825
824
  for (let f = 0; f < i.length; f++) {
826
825
  const { _id: x } = i[f];
@@ -830,26 +829,26 @@ const useAddBlock = () => {
830
829
  b[y]._parent = i[f]._id;
831
830
  }
832
831
  const p = first(i);
833
- let d, g;
834
- return c && (d = find(o, { _id: c }), i[0]._parent = c, g = c), !(d ? canAcceptChildBlock(d == null ? void 0 : d._type, p._type) : !0) && d && (i[0]._parent = d._parent, g = d._parent), r(i, g, u), n([(h = first(i)) == null ? void 0 : h._id]), first(i);
832
+ 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), r(i, g, d), n([(h = first(i)) == null ? void 0 : h._id]), first(i);
835
834
  },
836
835
  [r, o, n]
837
836
  );
838
837
  return { addCoreBlock: useCallback(
839
- (i, c, u) => {
838
+ (i, c, d) => {
840
839
  if (has(i, "blocks")) {
841
840
  const b = i.blocks;
842
- return a(b, c, u);
841
+ return a(b, c, d);
843
842
  }
844
- const p = generateUUID(), d = getDefaultBlockProps(i.type), g = {
843
+ const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
845
844
  _type: i.type,
846
845
  _id: p,
847
- ...d,
846
+ ...u,
848
847
  ...has(i, "_name") && { _name: i._name },
849
848
  ...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
850
849
  };
851
850
  let m, h;
852
- return c && (m = find(o, { _id: c }), g._parent = c, h = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, h = m._parent), r([g], h, u), n([g._id]), g;
851
+ return c && (m = find(o, { _id: c }), g._parent = c, h = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, h = m._parent), r([g], h, d), n([g._id]), g;
853
852
  },
854
853
  [r, a, o, n]
855
854
  ), addPredefinedBlock: a };
@@ -1959,11 +1958,11 @@ function removeDuplicateClasses(o) {
1959
1958
  if (r.length === 1) return r[0].fullCls;
1960
1959
  for (const l of r) {
1961
1960
  const i = l.property, c = n.indexOf(l.mq);
1962
- for (let u = c + 1; u < n.length; u++) {
1963
- const p = n[u], d = r.find((g) => g.property === i && g.mq === p);
1964
- if (d && d.cls === l.cls)
1965
- a = a.replace(d.fullCls, "");
1966
- else if (d && d.cls !== l.cls)
1961
+ for (let d = c + 1; d < n.length; d++) {
1962
+ const p = n[d], u = r.find((g) => g.property === i && g.mq === p);
1963
+ if (u && u.cls === l.cls)
1964
+ a = a.replace(u.fullCls, "");
1965
+ else if (u && u.cls !== l.cls)
1967
1966
  break;
1968
1967
  }
1969
1968
  }
@@ -1983,12 +1982,12 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), add
1983
1982
  )
1984
1983
  ), i = first(o(selectedStylingBlocksAtom));
1985
1984
  return map(l, (c) => {
1986
- const u = o(c), p = get(u, i.prop, `${STYLES_KEY},`), { classes: d } = getSplitChaiClasses(p);
1985
+ const d = o(c), p = get(d, i.prop, `${STYLES_KEY},`), { classes: u } = getSplitChaiClasses(p);
1987
1986
  return {
1988
- ids: [u._id],
1987
+ ids: [d._id],
1989
1988
  props: {
1990
1989
  [i.prop]: `${STYLES_KEY},${orderClassesByBreakpoint(
1991
- removeDuplicateClasses(twMerge(d, a))
1990
+ removeDuplicateClasses(twMerge(u, a))
1992
1991
  )}`
1993
1992
  }
1994
1993
  };
@@ -2229,11 +2228,11 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), add
2229
2228
  for (const i of l) {
2230
2229
  const c = r[i];
2231
2230
  if (isString(c)) {
2232
- const u = chunk(c.split(""), 12);
2231
+ const d = chunk(c.split(""), 12);
2233
2232
  let p = "";
2234
2233
  o([n], { [i]: "" });
2235
- for (let d = 0; d < u.length; d++)
2236
- p += u[d].join(""), o([n], { [i]: p }), await new Promise((g) => setTimeout(g, a));
2234
+ for (let u = 0; u < d.length; u++)
2235
+ p += d[u].join(""), o([n], { [i]: p }), await new Promise((g) => setTimeout(g, a));
2237
2236
  }
2238
2237
  }
2239
2238
  },
@@ -2271,22 +2270,22 @@ const getBlockWithChildren = (o, n) => {
2271
2270
  return r = flattenDeep([...r, ...getChildBlocks(n, o, r)]), r;
2272
2271
  }, pickOnlyAIProps = (o, n, r) => compact(
2273
2272
  o.map((a) => {
2274
- const l = ["_id", "_type", "_parent"], i = pick(a, l), c = getRegisteredChaiBlock(a._type), u = {}, p = get(c, "aiProps", []);
2275
- for (const d in a)
2276
- if (!l.includes(d) && p.includes(d)) {
2277
- const g = get(a, `${d}-${n}`, ""), m = get(a, d, "");
2278
- u[d] = isString(g) && g.trim() || m, r && (u[d] = m);
2273
+ const l = ["_id", "_type", "_parent"], i = pick(a, l), c = getRegisteredChaiBlock(a._type), d = {}, p = get(c, "aiProps", []);
2274
+ for (const u in a)
2275
+ if (!l.includes(u) && p.includes(u)) {
2276
+ const g = get(a, `${u}-${n}`, ""), m = get(a, u, "");
2277
+ d[u] = isString(g) && g.trim() || m, r && (d[u] = m);
2279
2278
  }
2280
- return isEmpty(u) ? !1 : (has(i, "_parent") && isEmpty(i._parent) && delete i._parent, { ...i, ...u });
2279
+ return isEmpty(d) ? !1 : (has(i, "_parent") && isEmpty(i._parent) && delete i._parent, { ...i, ...d });
2281
2280
  })
2282
2281
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2283
- const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [u] = useBlocksStore(), { selectedLang: p, fallbackLang: d } = useLanguages(), g = p.length ? p : d, m = (h, f) => {
2282
+ const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (h, f) => {
2284
2283
  const x = cloneDeep(f.find((b) => b._id === h));
2285
2284
  for (const b in x) {
2286
2285
  const y = x[b];
2287
2286
  if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
2288
- const { baseClasses: C, classes: S } = getSplitChaiClasses(y);
2289
- x[b] = compact(flattenDeep([C, S])).join(" ");
2287
+ const { baseClasses: S, classes: C } = getSplitChaiClasses(y);
2288
+ x[b] = compact(flattenDeep([S, C])).join(" ");
2290
2289
  } else
2291
2290
  b !== "_id" && delete x[b];
2292
2291
  }
@@ -2298,7 +2297,7 @@ const getBlockWithChildren = (o, n) => {
2298
2297
  if (l) {
2299
2298
  n(!0), a(null);
2300
2299
  try {
2301
- const y = p === d ? "" : p, C = x.toLowerCase().includes("translate the content"), S = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, u)), p, C) : [m(f, u)], w = await l(h, addLangToPrompt(x, g, h), S, y), { blocks: _, error: B } = w;
2300
+ const y = p === u ? "" : p, S = x.toLowerCase().includes("translate the content"), C = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p, S) : [m(f, d)], v = await l(h, addLangToPrompt(x, g, h), C, y), { blocks: _, error: B } = v;
2302
2301
  if (B) {
2303
2302
  a(B);
2304
2303
  return;
@@ -2312,7 +2311,7 @@ const getBlockWithChildren = (o, n) => {
2312
2311
  c(I);
2313
2312
  } else
2314
2313
  i(_);
2315
- b && b(w);
2314
+ b && b(v);
2316
2315
  } catch (y) {
2317
2316
  a(y);
2318
2317
  } finally {
@@ -2324,8 +2323,8 @@ const getBlockWithChildren = (o, n) => {
2324
2323
  l,
2325
2324
  n,
2326
2325
  p,
2327
- d,
2328
2326
  u,
2327
+ d,
2329
2328
  g,
2330
2329
  c,
2331
2330
  i
@@ -2338,18 +2337,18 @@ const getBlockWithChildren = (o, n) => {
2338
2337
  const [o, n] = useAtom$1(partialBlocksStoreAtom), r = useCallback((l) => get(o, l, []), [o]), a = useCallback(() => n({}), [n]);
2339
2338
  return { getPartailBlocks: r, reset: a };
2340
2339
  }, useWatchPartailBlocks = () => {
2341
- const [o] = useBlocksStore(), [n, r] = useAtom$1(partialBlocksStoreAtom), [a, l] = useAtom$1(partialBlocksLoadingStateAtom), i = useBuilderProp("getPartialBlockBlocks", async (u) => []), c = useMemo(() => o.filter((u) => u._type === "PartialBlock" || u._type === "GlobalBlock").map((u) => get(u, "partialBlockId", get(u, "globalBlock", ""))), [o]);
2340
+ const [o] = useBlocksStore(), [n, r] = 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]);
2342
2341
  useEffect(() => {
2343
- forEach(c, (u) => {
2344
- has(n, u) || get(a, `${u}.loading`, !1) || (l((p) => ({ ...p, [u]: { loading: !0, error: null } })), i(u).then((p) => {
2345
- r((d) => ({ ...d, [u]: p })), l((d) => ({
2346
- ...d,
2347
- [u]: { loading: !1, error: null }
2342
+ forEach(c, (d) => {
2343
+ has(n, d) || get(a, `${d}.loading`, !1) || (l((p) => ({ ...p, [d]: { loading: !0, error: null } })), i(d).then((p) => {
2344
+ r((u) => ({ ...u, [d]: p })), l((u) => ({
2345
+ ...u,
2346
+ [d]: { loading: !1, error: null }
2348
2347
  }));
2349
2348
  }).catch((p) => {
2350
- l((d) => ({
2351
- ...d,
2352
- [u]: { loading: !1, error: p.message }
2349
+ l((u) => ({
2350
+ ...u,
2351
+ [d]: { loading: !1, error: p.message }
2353
2352
  }));
2354
2353
  }));
2355
2354
  });
@@ -2362,7 +2361,7 @@ const getBlockWithChildren = (o, n) => {
2362
2361
  c
2363
2362
  ]);
2364
2363
  }, partialBlocksListAtom = atom({}), usePartialBlocksList = () => {
2365
- const [o, n] = useState(!1), [r, a] = useState(null), [l, i] = useAtom$1(partialBlocksListAtom), c = useBuilderProp("getPartialBlocks", async () => []), u = useCallback(async () => {
2364
+ const [o, n] = useState(!1), [r, a] = useState(null), [l, i] = useAtom$1(partialBlocksListAtom), c = useBuilderProp("getPartialBlocks", async () => []), d = useCallback(async () => {
2366
2365
  n(!0), a(null);
2367
2366
  try {
2368
2367
  const p = await c();
@@ -2372,12 +2371,12 @@ const getBlockWithChildren = (o, n) => {
2372
2371
  }
2373
2372
  }, [c, i]);
2374
2373
  return useEffect(() => {
2375
- u();
2376
- }, []), { data: l, isLoading: o, refetch: u, error: r };
2374
+ d();
2375
+ }, []), { data: l, isLoading: o, refetch: d, error: r };
2377
2376
  }, useBuilderReset = () => {
2378
- const { clear: o } = useUndoManager(), [, n] = useSelectedBlockIds(), { clearHighlight: r } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom$1(aiAssistantActiveAtom), { reset: i } = usePartialBlocksStore(), { setSaveState: c } = useSavePage(), [, u] = useBlockRepeaterDataAtom();
2377
+ const { clear: o } = useUndoManager(), [, n] = useSelectedBlockIds(), { clearHighlight: r } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom$1(aiAssistantActiveAtom), { reset: i } = usePartialBlocksStore(), { setSaveState: c } = useSavePage(), [, d] = useBlockRepeaterDataAtom();
2379
2378
  return () => {
2380
- u({}), n([]), a([]), r(), o(), l(!1), i(), c("SAVED");
2379
+ d({}), n([]), a([]), r(), o(), l(!1), i(), c("SAVED");
2381
2380
  };
2382
2381
  }, canvasZoomAtom = atomWithStorage("canvasZoom", 100), useCanvasZoom = () => useAtom$1(canvasZoomAtom), codeEditorAtom = atom(null), useCodeEditor = () => useAtom$1(codeEditorAtom), cutBlockIdsAtom = atom([]), useCutBlockIds = () => {
2383
2382
  const [o, n] = useAtom$1(cutBlockIdsAtom), r = useSetAtom$1(copiedBlockIdsAtom), a = useCallback(
@@ -2389,17 +2388,17 @@ const getBlockWithChildren = (o, n) => {
2389
2388
  return [o, a];
2390
2389
  }, copiedBlockIdsAtom = atom([]), useCopyBlocks = () => {
2391
2390
  const [o] = useBlocksStore(), [n, r] = useAtom$1(copiedBlockIdsAtom), a = useSetAtom$1(cutBlockIdsAtom), { getPartailBlocks: l } = usePartialBlocksStore(), i = useBuilderProp("flags.copyPaste", !0), c = useCallback(
2392
- (p) => p.some((d) => getDuplicatedBlocks(o, d, null).some((m) => m._type === "PartialBlock" || m._type === "GlobalBlock")),
2391
+ (p) => p.some((u) => getDuplicatedBlocks(o, u, null).some((m) => m._type === "PartialBlock" || m._type === "GlobalBlock")),
2393
2392
  [o]
2394
- ), u = useCallback(
2395
- async (p, d = !1) => {
2393
+ ), d = useCallback(
2394
+ async (p, u = !1) => {
2396
2395
  try {
2397
2396
  if (isEmpty(p)) return;
2398
2397
  r(p), a([]);
2399
2398
  const g = {
2400
2399
  _chai_copied_blocks: p.flatMap((m) => {
2401
2400
  const h = getDuplicatedBlocks(o, m, null);
2402
- if (!d)
2401
+ if (!u)
2403
2402
  return h;
2404
2403
  let f = [];
2405
2404
  for (const x of h)
@@ -2427,7 +2426,7 @@ const getBlockWithChildren = (o, n) => {
2427
2426
  },
2428
2427
  [r, a, o]
2429
2428
  );
2430
- return [n, u, c];
2429
+ return [n, d, c];
2431
2430
  }, useCopyToClipboard = () => {
2432
2431
  const [o, n] = useState(null), r = useBuilderProp("flags.copyPaste", !0), a = useCallback(async (l) => {
2433
2432
  if (!r)
@@ -2450,12 +2449,12 @@ const getBlockWithChildren = (o, n) => {
2450
2449
  (a, l = null) => {
2451
2450
  const i = [];
2452
2451
  each(a, (c) => {
2453
- const u = o.find((h) => h._id === c);
2454
- l ? l === "root" && (l = null) : l = u._parent;
2452
+ const d = o.find((h) => h._id === c);
2453
+ l ? l === "root" && (l = null) : l = d._parent;
2455
2454
  const g = filter(
2456
2455
  o,
2457
2456
  (h) => isString(l) ? h._parent === l : !h._parent
2458
- ).indexOf(u) + 1, m = getDuplicatedBlocks(o, c, l);
2457
+ ).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
2459
2458
  r(m, l, g), i.push(get(m, "0._id", ""));
2460
2459
  }), n(i);
2461
2460
  },
@@ -2471,27 +2470,27 @@ const getBlockWithChildren = (o, n) => {
2471
2470
  c.current = "loading", r((p) => ({ ...p, [o == null ? void 0 : o.id]: { loading: "loading", blocks: [] } }));
2472
2471
  try {
2473
2472
  const p = await a(o);
2474
- c.current = "idle", r((d) => ({ ...d, [o == null ? void 0 : o.id]: { loading: "complete", blocks: p || [] } }));
2473
+ c.current = "idle", r((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: p || [] } }));
2475
2474
  } catch {
2476
- c.current = "idle", r((d) => ({ ...d, [o == null ? void 0 : o.id]: { loading: "complete", blocks: [] } }));
2475
+ c.current = "idle", r((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: [] } }));
2477
2476
  }
2478
2477
  }
2479
2478
  })();
2480
2479
  }, [o, l, i, c, r, a]);
2481
- const u = useCallback(
2480
+ const d = useCallback(
2482
2481
  (p) => {
2483
- r((d) => ({ ...d, [p]: { loading: "idle", blocks: [] } }));
2482
+ r((u) => ({ ...u, [p]: { loading: "idle", blocks: [] } }));
2484
2483
  },
2485
2484
  [r]
2486
2485
  );
2487
- return { data: l || [], isLoading: i === "loading", resetLibrary: u };
2486
+ return { data: l || [], isLoading: i === "loading", resetLibrary: d };
2488
2487
  }, useCanPaste = () => {
2489
2488
  const [o] = useBlocksStore();
2490
2489
  return (n, r) => {
2491
2490
  var i;
2492
2491
  const a = ((i = find(o, { _id: r })) == null ? void 0 : i._type) || null, l = first(n.map((c) => {
2493
- var u;
2494
- return (u = find(o, { _id: c })) == null ? void 0 : u._type;
2492
+ var d;
2493
+ return (d = find(o, { _id: c })) == null ? void 0 : d._type;
2495
2494
  }));
2496
2495
  return canAcceptChildBlock(a, l);
2497
2496
  };
@@ -2518,9 +2517,9 @@ const getBlockWithChildren = (o, n) => {
2518
2517
  if (o.length > 0)
2519
2518
  return l(o, c);
2520
2519
  try {
2521
- const u = await navigator.clipboard.readText();
2522
- if (u) {
2523
- const p = JSON.parse(u);
2520
+ const d = await navigator.clipboard.readText();
2521
+ if (d) {
2522
+ const p = JSON.parse(d);
2524
2523
  return has(p, "_chai_copied_blocks");
2525
2524
  }
2526
2525
  } catch {
@@ -2532,7 +2531,7 @@ const getBlockWithChildren = (o, n) => {
2532
2531
  ),
2533
2532
  pasteBlocks: useCallback(
2534
2533
  async (c) => {
2535
- const u = Array.isArray(c) ? c[0] : c;
2534
+ const d = Array.isArray(c) ? c[0] : c;
2536
2535
  if (!(navigator != null && navigator.permissions)) {
2537
2536
  toast.error("Cannot check clipboard permissions.");
2538
2537
  return;
@@ -2554,9 +2553,9 @@ const getBlockWithChildren = (o, n) => {
2554
2553
  async () => {
2555
2554
  const p = await navigator.clipboard.readText();
2556
2555
  if (p) {
2557
- const d = JSON.parse(p);
2558
- if (has(d, "_chai_copied_blocks"))
2559
- a(d._chai_copied_blocks, u === "root" ? null : u);
2556
+ const u = JSON.parse(p);
2557
+ if (has(u, "_chai_copied_blocks"))
2558
+ a(u._chai_copied_blocks, d === "root" ? null : d);
2560
2559
  else
2561
2560
  throw new Error("Nothing to paste");
2562
2561
  } else
@@ -2583,20 +2582,20 @@ const getBlockWithChildren = (o, n) => {
2583
2582
  )
2584
2583
  );
2585
2584
  return map(i, (c) => {
2586
- const u = o(c), p = a;
2587
- let { classes: d, baseClasses: g } = getSplitChaiClasses(get(u, l.prop, `${STYLES_KEY},`));
2585
+ const d = o(c), p = a;
2586
+ let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
2588
2587
  return each(p, (m) => {
2589
2588
  const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2590
- d = d.replace(f, " ").replace(/\s+/g, " ").trim();
2589
+ u = u.replace(f, " ").replace(/\s+/g, " ").trim();
2591
2590
  const x = first(m.split(":"));
2592
2591
  includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
2593
2592
  }), each(p, (m) => {
2594
2593
  const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2595
2594
  g = g.replace(f, " ").replace(/\s+/g, " ").trim();
2596
2595
  }), {
2597
- ids: [u._id],
2596
+ ids: [d._id],
2598
2597
  props: {
2599
- [l.prop]: `${STYLES_KEY}${g},${d}`
2598
+ [l.prop]: `${STYLES_KEY}${g},${u}`
2600
2599
  }
2601
2600
  };
2602
2601
  });
@@ -2627,7 +2626,7 @@ const getBlockWithChildren = (o, n) => {
2627
2626
  );
2628
2627
  }, useResetBlockStyles = () => {
2629
2628
  const o = useSelectedBlock(), n = useUpdateBlocksProps(), r = useCallback((c) => getDefaultBlockProps(c) || {}, []), a = useCallback((c) => Object.keys(c).filter(
2630
- (u) => typeof c[u] == "string" && c[u].startsWith("#styles:")
2629
+ (d) => typeof c[d] == "string" && c[d].startsWith("#styles:")
2631
2630
  ), []), l = useCallback(
2632
2631
  (c) => {
2633
2632
  if (!o) return;
@@ -2640,7 +2639,7 @@ const getBlockWithChildren = (o, n) => {
2640
2639
  if (!o) return;
2641
2640
  const c = a(o);
2642
2641
  if (c.length === 0) return;
2643
- const u = r(o._type), p = pick(u, c);
2642
+ const d = r(o._type), p = pick(d, c);
2644
2643
  n([o._id], p);
2645
2644
  }, [o, a, r, n]), reset: l };
2646
2645
  }, useStylingBreakpoint = () => useAtom$1(styleBreakpointAtom), canvasWidthAtom = atomWithStorage("canvasWidth", 800), canvasDisplayWidthAtom = atomWithStorage("canvasDisplayWidth", 800), canvasBreakpointAtom = atom((o) => {
@@ -2662,7 +2661,7 @@ const getBlockWithChildren = (o, n) => {
2662
2661
  }), useSelectedBlockAllClasses = () => useAtomValue$1(selectedBlockAllClassesAtom), MQ = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4, "2xl": 5 }, selectedBlockCurrentClassesAtom = atom((o) => {
2663
2662
  const n = o(canvasBreakpointAtom), r = o(styleStateAtom), a = o(darkModeAtom), l = getQueries(n);
2664
2663
  let i = filter(o(selectedBlockAllClassesAtom), { mod: r });
2665
- return startsWith(r, "_") || (i = filter(i, (c) => l.includes(c.mq))), i = i.sort((c, u) => MQ[c.mq] - MQ[u.mq]), a || (i = filter(i, { dark: !1 })), i;
2664
+ return startsWith(r, "_") || (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;
2666
2665
  }), getQueries = (o) => {
2667
2666
  let n = [];
2668
2667
  switch (o) {
@@ -2700,11 +2699,11 @@ const getBlockWithChildren = (o, n) => {
2700
2699
  if (!l) return null;
2701
2700
  let i = l._parent;
2702
2701
  for (; i; ) {
2703
- const u = find(n, { _id: i });
2704
- if (!u) return null;
2705
- if ((c = getRegisteredChaiBlock(u._type)) != null && c.wrapper)
2706
- return u;
2707
- i = u._parent;
2702
+ const d = find(n, { _id: i });
2703
+ if (!d) return null;
2704
+ if ((c = getRegisteredChaiBlock(d._type)) != null && c.wrapper)
2705
+ return d;
2706
+ i = d._parent;
2708
2707
  }
2709
2708
  return null;
2710
2709
  });
@@ -2737,18 +2736,18 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
2737
2736
  var i;
2738
2737
  if (o.type !== "element" || !o.attributes)
2739
2738
  return o;
2740
- o.tagName === "span" && o.attributes.find((u) => u.key === "role" && u.value === "link") && (o.tagName = "a", o.attributes = o.attributes.filter((u) => u.key !== "role"));
2739
+ o.tagName === "span" && o.attributes.find((d) => d.key === "role" && d.value === "link") && (o.tagName = "a", o.attributes = o.attributes.filter((d) => d.key !== "role"));
2741
2740
  const a = o.attributes.find((c) => c.key === "data-block-type"), l = o.attributes.find((c) => c.key === "data-block-id");
2742
2741
  if (a) {
2743
2742
  const c = a.value;
2744
2743
  if (CORE_BLOCKS$1.includes(c) || (i = r == null ? void 0 : r.EXTRA_CORE_BLOCKS) != null && i.includes(c))
2745
- o.attributes = o.attributes.filter((u) => u.key !== "data-block-type"), o.children && (o.children = o.children.map((u) => transformNode(u, n, r)));
2744
+ o.attributes = o.attributes.filter((d) => d.key !== "data-block-type"), o.children && (o.children = o.children.map((d) => transformNode(d, n, r)));
2746
2745
  else {
2747
- const u = `chai-${kebabCase(c)}`;
2748
- o.tagName = u, l ? o.attributes = [{ key: "id", value: l.value }] : o.attributes = [], o.attributes.push({ key: "chai-type", value: c });
2749
- const p = getRegisteredChaiBlock(c), d = n.find((g) => g._id === (l == null ? void 0 : l.value));
2750
- if (d && o.attributes.push(
2751
- ...Object.entries(d).filter(([g]) => !["_id", "_type", "_parent", "_index", "_name"].includes(g)).map(([g, m]) => ({
2746
+ const d = `chai-${kebabCase(c)}`;
2747
+ o.tagName = d, l ? o.attributes = [{ key: "id", value: l.value }] : o.attributes = [], o.attributes.push({ key: "chai-type", value: c });
2748
+ const p = getRegisteredChaiBlock(c), u = n.find((g) => g._id === (l == null ? void 0 : l.value));
2749
+ if (u && o.attributes.push(
2750
+ ...Object.entries(u).filter(([g]) => !["_id", "_type", "_parent", "_index", "_name"].includes(g)).map(([g, m]) => ({
2752
2751
  key: g,
2753
2752
  value: typeof m == "string" ? m : JSON.stringify(m)
2754
2753
  }))
@@ -2785,8 +2784,8 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
2785
2784
  const l = o != null && o._id ? `[data-block-id="${o._id}"]` : "#canvas", i = (m = (g = r.contentDocument) == null ? void 0 : g.querySelector(l)) == null ? void 0 : m[l === "#canvas" ? "innerHTML" : "outerHTML"];
2786
2785
  if (!i) return "";
2787
2786
  const p = parse(i).map(cleanNode).filter((h) => h !== null).map((h) => transformNode(h, n, a));
2788
- let d = stringify(p);
2789
- return d = d.replace(/#styles:,/g, "#styles:"), d.replace(/\s+/g, " ").trim();
2787
+ let u = stringify(p);
2788
+ return u = u.replace(/#styles:,/g, "#styles:"), u.replace(/\s+/g, " ").trim();
2790
2789
  },
2791
2790
  [o, r]
2792
2791
  );
@@ -2796,14 +2795,14 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
2796
2795
  const l = a.i18nProps;
2797
2796
  if (!l) return r;
2798
2797
  const i = filter(n, { _type: r._type }), c = pick(r, l);
2799
- return each(c, (u, p) => {
2800
- const d = find(i, (g) => {
2798
+ return each(c, (d, p) => {
2799
+ const u = find(i, (g) => {
2801
2800
  var f;
2802
- const m = typeof g[p] == "string" ? (f = g[p]) == null ? void 0 : f.trim().toLowerCase() : JSON.stringify(g[p]), h = typeof u == "string" ? u.trim().toLowerCase() : JSON.stringify(u);
2801
+ const m = typeof g[p] == "string" ? (f = g[p]) == null ? void 0 : f.trim().toLowerCase() : JSON.stringify(g[p]), h = typeof d == "string" ? d.trim().toLowerCase() : JSON.stringify(d);
2803
2802
  return m === h;
2804
2803
  });
2805
- if (d) {
2806
- const g = filter(Object.keys(d), (h) => startsWith(h, `${p}-`)), m = pick(d, g);
2804
+ if (u) {
2805
+ const g = filter(Object.keys(u), (h) => startsWith(h, `${p}-`)), m = pick(u, g);
2807
2806
  r = { ...r, ...m };
2808
2807
  }
2809
2808
  }), r;
@@ -2829,15 +2828,15 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
2829
2828
  return useCallback(
2830
2829
  (r = "") => {
2831
2830
  const a = o != null && o._id ? getBlockWithNestedChildren(o._id, n) : n;
2832
- return a ? compact$1(
2831
+ return a ? compact(
2833
2832
  a.map((l) => {
2834
2833
  const i = getRegisteredChaiBlock(l._type);
2835
2834
  if (!i) return null;
2836
2835
  const c = (i == null ? void 0 : i.i18nProps) ?? [];
2837
2836
  if (c.length === 0) return null;
2838
- const u = r === "ALL" ? Object.keys(l).filter((d) => c.find((g) => d.startsWith(g))) : c.map((d) => r ? `${d}-${r}` : d), p = pick$1(l, ["_id"]);
2839
- return each$1(u, (d) => {
2840
- p[d] = get$1(l, d, get$1(l, d.replace(`-${r}`, "")));
2837
+ const d = r === "ALL" ? Object.keys(l).filter((u) => c.find((g) => u.startsWith(g))) : c.map((u) => r ? `${u}-${r}` : u), p = pick(l, ["_id"]);
2838
+ return each(d, (u) => {
2839
+ p[u] = get(l, u, get(l, u.replace(`-${r}`, "")));
2841
2840
  }), p;
2842
2841
  })
2843
2842
  ) : [];
@@ -2885,11 +2884,11 @@ const getAllDescendantIds = (o, n) => {
2885
2884
  }, replaceBlock = (o, n, r) => {
2886
2885
  const a = find(o, { _id: n });
2887
2886
  if (!a) return o;
2888
- const l = o.findIndex((m) => m._id === n), i = getAllDescendantIds(o, n), c = /* @__PURE__ */ new Set([n, ...i]), u = o.filter((m) => !c.has(m._id)), p = new Set(r.map((m) => m._id)), d = r.map((m) => !m._parent || !p.has(m._parent) ? { ...m, _parent: a._parent } : m);
2887
+ const l = o.findIndex((m) => m._id === n), i = getAllDescendantIds(o, n), c = /* @__PURE__ */ new Set([n, ...i]), d = o.filter((m) => !c.has(m._id)), p = new Set(r.map((m) => m._id)), u = r.map((m) => !m._parent || !p.has(m._parent) ? { ...m, _parent: a._parent } : m);
2889
2888
  return [
2890
- ...u.slice(0, l),
2891
- ...d,
2892
- ...u.slice(l)
2889
+ ...d.slice(0, l),
2890
+ ...u,
2891
+ ...d.slice(l)
2893
2892
  ];
2894
2893
  }, useReplaceBlock = () => {
2895
2894
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { setNewBlocks: r } = useBlocksStoreUndoableActions(), { hasPermission: a } = usePermissions();
@@ -2979,12 +2978,12 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), ScalePerc
2979
2978
  // Export Code
2980
2979
  OPEN_EXPORT_CODE: "OPEN_EXPORT_CODE"
2981
2980
  }, AddBlockDropdown = ({ block: o, children: n }) => {
2982
- const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), u = filter(a, (m) => c ? get(m, "_parent") === c : !get(m, "_parent")), p = canAddChildBlock(get(o, "_type", "")), d = findIndex(u, { _id: i }), g = (m) => {
2981
+ const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (m) => c ? get(m, "_parent") === c : !get(m, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (m) => {
2983
2982
  if (m === "CHILD")
2984
2983
  pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
2985
2984
  else {
2986
- const h = { _id: c || "", position: u == null ? void 0 : u.length };
2987
- m === "BEFORE" ? h.position = Math.max(d, 0) : m === "AFTER" && (h.position = d + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, h);
2985
+ const h = { _id: c || "", position: d == null ? void 0 : d.length };
2986
+ m === "BEFORE" ? h.position = Math.max(u, 0) : m === "AFTER" && (h.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, h);
2988
2987
  }
2989
2988
  };
2990
2989
  return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
@@ -3003,9 +3002,9 @@ function getOrientation(o, n = null) {
3003
3002
  const c = r.flexDirection;
3004
3003
  return c === "column" || c === "column-reverse" ? "vertical" : "horizontal";
3005
3004
  } else if (l === "grid") {
3006
- const c = r.gridAutoFlow, u = r.gridTemplateColumns;
3007
- return c.includes("column") || u && u !== "none" && u !== "" && !u.includes("calc") && // Handle calc expressions
3008
- u.split(" ").length <= 1 ? "vertical" : "horizontal";
3005
+ const c = r.gridAutoFlow, d = r.gridTemplateColumns;
3006
+ return c.includes("column") || d && d !== "none" && d !== "" && !d.includes("calc") && // Handle calc expressions
3007
+ d.split(" ").length <= 1 ? "vertical" : "horizontal";
3009
3008
  } else if (i === "inline-block" || i === "inline")
3010
3009
  return "horizontal";
3011
3010
  return "vertical";
@@ -3031,11 +3030,11 @@ const FrameContext = React__default.createContext({ document: doc, window: win }
3031
3030
  return "VERTICAL";
3032
3031
  }
3033
3032
  }, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
3034
- const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), u = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (u == null ? void 0 : u.length) <= 1, d = findIndex(u, { _id: i }), g = d <= 0, m = d + 1 === (u == null ? void 0 : u.length), h = getParentBlockOrientation(c, i, a), f = useCallback(
3033
+ const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), f = useCallback(
3035
3034
  (x) => {
3036
- isDisabledControl(g, m, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, d - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, d + 2), n());
3035
+ isDisabledControl(g, m, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
3037
3036
  },
3038
- [g, m, p, d, i, c, n]
3037
+ [g, m, p, u, i, c, n]
3039
3038
  );
3040
3039
  return useHotkeys(
3041
3040
  "shift+up, shift+down, shift+left, shift+right",
@@ -3051,17 +3050,17 @@ const FrameContext = React__default.createContext({ document: doc, window: win }
3051
3050
  o,
3052
3051
  n
3053
3052
  );
3054
- return r ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: u, dir: p, key: d }) => c !== p || isDisabledControl(a, l, d) ? null : /* @__PURE__ */ jsx(
3055
- u,
3053
+ return r ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => c !== p || isDisabledControl(a, l, u) ? null : /* @__PURE__ */ jsx(
3054
+ d,
3056
3055
  {
3057
- onClick: () => i(d),
3056
+ onClick: () => i(u),
3058
3057
  className: "rounded p-px hover:bg-white hover:text-blue-500"
3059
3058
  },
3060
- d
3059
+ u
3061
3060
  )) });
3062
3061
  }, AiIcon = ({
3063
3062
  className: o = "h-full w-full",
3064
- onClick: n = noop$1
3063
+ onClick: n = noop
3065
3064
  }) => /* @__PURE__ */ jsx("svg", { className: o, viewBox: "0 0 256 256", fill: "currentColor", onClick: n, children: /* @__PURE__ */ jsx("path", { d: "m198.39 128.986-52.16-19.216-19.216-52.16a16 16 0 0 0-30.028 0L77.77 109.77l-52.16 19.216a16 16 0 0 0 0 30.028l52.16 19.216 19.216 52.16a16 16 0 0 0 30.028 0l19.216-52.16 52.16-19.216a16 16 0 0 0 0-30.028m-57.69 34.23a15.97 15.97 0 0 0-9.483 9.483l-19.22 52.152-19.214-52.15a15.97 15.97 0 0 0-9.482-9.484l-52.152-19.22 52.15-19.214a15.97 15.97 0 0 0 9.484-9.482l19.22-52.152 19.214 52.15a15.97 15.97 0 0 0 9.482 9.484l52.152 19.22ZM144 40a8 8 0 0 1 8-8h16V16a8 8 0 0 1 16 0v16h16a8 8 0 0 1 0 16h-16v16a8 8 0 0 1-16 0V48h-16a8 8 0 0 1-8-8m104 48a8 8 0 0 1-8 8h-8v8a8 8 0 0 1-16 0v-8h-8a8 8 0 0 1 0-16h8v-8a8 8 0 0 1 16 0v8h8a8 8 0 0 1 8 8" }) }), GotoSettingsIcon = ({ blockId: o, className: n }) => /* @__PURE__ */ jsx(GearIcon, { className: n, onClick: () => {
3066
3065
  o && pubsub.publish(CHAI_BUILDER_EVENTS.GOTO_BLOCK_SETTINGS, o);
3067
3066
  } });
@@ -3085,15 +3084,15 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3085
3084
  const { editingBlockId: o, setEditingBlockId: n, setEditingItemIndex: r } = useInlineEditing();
3086
3085
  return useCallback(
3087
3086
  (a) => {
3088
- var u;
3087
+ var d;
3089
3088
  if (a == null || a.preventDefault(), a == null || a.stopPropagation(), o) return;
3090
3089
  const l = getTargetedBlock(a.target);
3091
3090
  if (!isInlineEditable(l)) return;
3092
3091
  const i = l.getAttribute("data-block-id");
3093
3092
  if (!i || !l) return;
3094
3093
  const c = l.closest('[data-block-type="Repeater"]');
3095
- c ? (u = c == null ? void 0 : c.childNodes) == null || u.forEach((p, d) => {
3096
- p.contains(l) && r(d);
3094
+ c ? (d = c == null ? void 0 : c.childNodes) == null || d.forEach((p, u) => {
3095
+ p.contains(l) && r(u);
3097
3096
  }) : r(-1), n(i);
3098
3097
  },
3099
3098
  [o, n, r]
@@ -3110,11 +3109,11 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3110
3109
  return;
3111
3110
  }
3112
3111
  if (c != null && c.getAttribute("data-block-parent")) {
3113
- const u = c.getAttribute("data-style-prop"), p = c.getAttribute("data-style-id"), d = c.getAttribute("data-block-parent");
3114
- pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, { blockId: d, styleId: p, styleProp: u });
3112
+ const d = c.getAttribute("data-style-prop"), p = c.getAttribute("data-style-id"), u = c.getAttribute("data-block-parent");
3113
+ pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, { blockId: u, styleId: p, styleProp: d });
3115
3114
  } else if (c != null && c.getAttribute("data-block-id")) {
3116
- const u = c.getAttribute("data-block-id");
3117
- pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, u === "canvas" ? [] : [u]);
3115
+ const d = c.getAttribute("data-block-id");
3116
+ pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, d === "canvas" ? [] : [d]);
3118
3117
  }
3119
3118
  n(), r.current = (/* @__PURE__ */ new Date()).getTime();
3120
3119
  },
@@ -3165,29 +3164,29 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3165
3164
  }
3166
3165
  );
3167
3166
  }, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), BlockSelectionHighlighter = () => {
3168
- const o = useSelectedBlock(), { document: n } = useFrame(), [r] = useSelectedStylingBlocks(), [a, l] = useState([]), [, i] = useState([]), c = (u, p = 0) => {
3169
- const { top: d } = u.getBoundingClientRect();
3170
- return d + p >= 0 && d - p <= window.innerHeight;
3167
+ const o = useSelectedBlock(), { document: n } = useFrame(), [r] = useSelectedStylingBlocks(), [a, l] = useState([]), [, i] = useState([]), c = (d, p = 0) => {
3168
+ const { top: u } = d.getBoundingClientRect();
3169
+ return u + p >= 0 && u - p <= window.innerHeight;
3171
3170
  };
3172
3171
  return useEffect(() => {
3173
- var u;
3172
+ var d;
3174
3173
  if (o != null && o._id && o.type !== "Multiple" && n) {
3175
3174
  const p = getElementByDataBlockId(n, o._id);
3176
- p && (c(p) || (u = n.defaultView) == null || u.scrollTo({ top: p.offsetTop, behavior: "smooth" }), l([p]));
3175
+ p && (c(p) || (d = n.defaultView) == null || d.scrollTo({ top: p.offsetTop, behavior: "smooth" }), l([p]));
3177
3176
  }
3178
3177
  }, [o == null ? void 0 : o._id, o == null ? void 0 : o.type, n]), useEffect(() => {
3179
3178
  if (!isEmpty(r) && n) {
3180
- const u = getElementByStyleId(n, first(r).id);
3181
- i(u ? [u] : [null]);
3179
+ const d = getElementByStyleId(n, first(r).id);
3180
+ i(d ? [d] : [null]);
3182
3181
  } else
3183
3182
  i([null]);
3184
3183
  }, [r, n]), /* @__PURE__ */ jsx(BlockFloatingSelector, { block: o, selectedBlockElement: a[0] });
3185
3184
  }, BlockFloatingSelector = ({ block: o, selectedBlockElement: n }) => {
3186
- const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: u } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: d } = useFrame(), g = useBuilderProp("flags.gotoSettings", !1), { floatingStyles: m, refs: h, update: f } = useFloating({
3185
+ const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: u } = useFrame(), g = useBuilderProp("flags.gotoSettings", !1), { floatingStyles: m, refs: h, update: f } = useFloating({
3187
3186
  placement: "top-start",
3188
3187
  middleware: [
3189
3188
  shift({
3190
- boundary: d == null ? void 0 : d.body,
3189
+ boundary: u == null ? void 0 : u.body,
3191
3190
  limiter: limitShift({
3192
3191
  offset: 8,
3193
3192
  mainAxis: !0,
@@ -3195,27 +3194,27 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3195
3194
  })
3196
3195
  }),
3197
3196
  flip({
3198
- boundary: d == null ? void 0 : d.body,
3197
+ boundary: u == null ? void 0 : u.body,
3199
3198
  fallbackPlacements: ["bottom-start", "top-end", "bottom-end", "inside"]
3200
3199
  }),
3201
3200
  size({
3202
- boundary: d == null ? void 0 : d.body,
3203
- apply({ availableWidth: C, availableHeight: S, elements: w }) {
3204
- Object.assign(w.floating.style, {
3205
- maxWidth: `${Math.max(200, C)}px`,
3206
- maxHeight: `${Math.max(100, S)}px`
3201
+ boundary: u == null ? void 0 : u.body,
3202
+ apply({ availableWidth: S, availableHeight: C, elements: v }) {
3203
+ Object.assign(v.floating.style, {
3204
+ maxWidth: `${Math.max(200, S)}px`,
3205
+ maxHeight: `${Math.max(100, C)}px`
3207
3206
  });
3208
3207
  }
3209
3208
  })
3210
3209
  ],
3211
3210
  elements: { reference: n }
3212
3211
  });
3213
- useResizeObserver(n, () => f(), n !== null), useResizeObserver(d == null ? void 0 : d.body, () => f(), (d == null ? void 0 : d.body) !== null);
3212
+ useResizeObserver(n, () => f(), n !== null), useResizeObserver(u == null ? void 0 : u.body, () => f(), (u == null ? void 0 : u.body) !== null);
3214
3213
  const x = get(o, "_parent", null), b = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
3215
3214
  useEffect(() => {
3216
3215
  if (n) {
3217
- const C = setTimeout(() => f(), 500);
3218
- return () => clearTimeout(C);
3216
+ const S = setTimeout(() => f(), 500);
3217
+ return () => clearTimeout(S);
3219
3218
  } else
3220
3219
  f();
3221
3220
  }, [n]);
@@ -3227,13 +3226,13 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3227
3226
  tabIndex: 0,
3228
3227
  ref: h.setFloating,
3229
3228
  style: m,
3230
- onClick: (C) => {
3231
- C.stopPropagation(), C.preventDefault();
3229
+ onClick: (S) => {
3230
+ S.stopPropagation(), S.preventDefault();
3232
3231
  },
3233
- onMouseEnter: (C) => {
3234
- C.stopPropagation(), i(null);
3232
+ onMouseEnter: (S) => {
3233
+ S.stopPropagation(), i(null);
3235
3234
  },
3236
- onKeyDown: (C) => C.stopPropagation(),
3235
+ onKeyDown: (S) => S.stopPropagation(),
3237
3236
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3238
3237
  children: [
3239
3238
  x && /* @__PURE__ */ jsx(
@@ -3247,7 +3246,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3247
3246
  ),
3248
3247
  /* @__PURE__ */ jsx(BlockActionLabel, { label: b, block: o }),
3249
3248
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 pl-1 pr-1.5", children: [
3250
- u(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
3249
+ d(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
3251
3250
  AiIcon,
3252
3251
  {
3253
3252
  className: "h-4 w-4 rounded hover:bg-white hover:text-blue-500",
@@ -3262,21 +3261,21 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3262
3261
  }
3263
3262
  ),
3264
3263
  /* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500" }) }),
3265
- canDuplicateBlock(get(o, "_type", "")) && u(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(
3264
+ canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(
3266
3265
  CopyIcon,
3267
3266
  {
3268
3267
  className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500",
3269
3268
  onClick: () => a([o == null ? void 0 : o._id])
3270
3269
  }
3271
3270
  ) : null,
3272
- canDeleteBlock(get(o, "_type", "")) && u(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(
3271
+ canDeleteBlock(get(o, "_type", "")) && d(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(
3273
3272
  TrashIcon,
3274
3273
  {
3275
3274
  className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500",
3276
3275
  onClick: () => r([o == null ? void 0 : o._id])
3277
3276
  }
3278
3277
  ) : null,
3279
- u(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: o, updateFloatingBar: f })
3278
+ d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: o, updateFloatingBar: f })
3280
3279
  ] })
3281
3280
  ]
3282
3281
  }
@@ -3453,8 +3452,8 @@ class Frame extends Component {
3453
3452
  const r = this.getDoc();
3454
3453
  if (!r)
3455
3454
  return null;
3456
- const a = this.props.contentDidMount, l = this.props.contentDidUpdate, i = r.defaultView || r.parentView, c = /* @__PURE__ */ jsx(Content, { contentDidMount: a, contentDidUpdate: l, children: /* @__PURE__ */ jsx(FrameContextProvider, { value: { document: r, window: i }, children: /* @__PURE__ */ jsx("div", { className: "frame-content", children: this.props.children }) }) }), u = this.getMountTarget();
3457
- return [ReactDOM.createPortal(this.props.head, this.getDoc().head), ReactDOM.createPortal(c, u)];
3455
+ const a = this.props.contentDidMount, l = this.props.contentDidUpdate, i = r.defaultView || r.parentView, c = /* @__PURE__ */ jsx(Content, { contentDidMount: a, contentDidUpdate: l, children: /* @__PURE__ */ jsx(FrameContextProvider, { value: { document: r, window: i }, children: /* @__PURE__ */ jsx("div", { className: "frame-content", children: this.props.children }) }) }), d = this.getMountTarget();
3456
+ return [ReactDOM.createPortal(this.props.head, this.getDoc().head), ReactDOM.createPortal(c, d)];
3458
3457
  }
3459
3458
  render() {
3460
3459
  const r = {
@@ -3478,12 +3477,12 @@ $(Frame, "defaultProps", {
3478
3477
  initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
3479
3478
  });
3480
3479
  const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: n })), useKeyEventWatcher = (o) => {
3481
- const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: u } = useUndoManager(), [, p] = useCutBlockIds(), [, d] = useCopyBlocks(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), h = o ? { document: o } : {};
3482
- useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => u(), {}, [u]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys(
3480
+ const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), h = o ? { document: o } : {};
3481
+ useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys(
3483
3482
  "ctrl+c,command+c",
3484
- () => d(n),
3483
+ () => u(n),
3485
3484
  { ...h, enabled: !isEmpty(n), preventDefault: !0 },
3486
- [n, d]
3485
+ [n, u]
3487
3486
  ), useHotkeys(
3488
3487
  "ctrl+v,command+v",
3489
3488
  () => {
@@ -3590,7 +3589,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3590
3589
  heading: get(o, "fontFamily.heading"),
3591
3590
  body: get(o, "fontFamily.body")
3592
3591
  };
3593
- return n.filter((u) => u.family === i || u.family === c);
3592
+ return n.filter((d) => d.family === i || d.family === c);
3594
3593
  }, [o == null ? void 0 : o.fontFamily, n]), a = useMemo(() => getThemeFontsUrls(filter(r, (i) => has(i, "url"))), [r]), l = useMemo(
3595
3594
  () => getThemeCustomFontFace(filter(r, (i) => has(i, "src"))),
3596
3595
  [r]
@@ -3612,14 +3611,14 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3612
3611
  const { clientWidth: p } = i.current;
3613
3612
  n(p);
3614
3613
  }, []);
3615
- const u = useCallback(() => {
3614
+ const d = useCallback(() => {
3616
3615
  a([]), l([]);
3617
3616
  }, [a, l]);
3618
3617
  return /* @__PURE__ */ jsx(
3619
3618
  "div",
3620
3619
  {
3621
3620
  id: "main-content",
3622
- onClick: u,
3621
+ onClick: d,
3623
3622
  className: "h-full w-full border-l-4 border-r-4 pb-0",
3624
3623
  ref: i,
3625
3624
  children: o
@@ -3633,9 +3632,9 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3633
3632
  return useCallback(
3634
3633
  (n, r) => isEmpty(r) ? {} : Object.entries(r).reduce((a, [l, i]) => {
3635
3634
  const c = [];
3636
- let u = find(o, { _id: n });
3637
- for (; u; )
3638
- c.push(u), u = find(o, { _id: u._parent });
3635
+ let d = find(o, { _id: n });
3636
+ for (; d; )
3637
+ c.push(d), d = find(o, { _id: d._parent });
3639
3638
  const p = find(c, { _type: i.block });
3640
3639
  return p && (a[l] = get(p, get(i, "prop"), null)), a;
3641
3640
  }, {}),
@@ -3701,22 +3700,22 @@ const RteDropdownMenu = ({
3701
3700
  from: a,
3702
3701
  menuRef: l
3703
3702
  }) => {
3704
- const { document: i } = useFrame(), [c, u] = useState({ left: void 0, right: void 0, top: void 0, bottom: void 0 }), [p, d] = useState(!1), g = useRef(null);
3703
+ const { document: i } = useFrame(), [c, d] = useState({ left: void 0, right: void 0, top: void 0, bottom: void 0 }), [p, u] = useState(!1), g = useRef(null);
3705
3704
  if (useEffect(() => {
3706
- var C, S;
3705
+ var S, C;
3707
3706
  if (!p) {
3708
- u({ left: void 0, right: void 0, top: void 0, bottom: void 0 });
3707
+ d({ left: void 0, right: void 0, top: void 0, bottom: void 0 });
3709
3708
  return;
3710
3709
  }
3711
- const m = (C = g.current) == null ? void 0 : C.getBoundingClientRect(), h = (S = l.current) == null ? void 0 : S.getBoundingClientRect();
3710
+ const m = (S = g.current) == null ? void 0 : S.getBoundingClientRect(), h = (C = l.current) == null ? void 0 : C.getBoundingClientRect();
3712
3711
  let f = m == null ? void 0 : m.left, x = (m == null ? void 0 : m.bottom) + 4, b, y;
3713
- (h == null ? void 0 : h.left) + (h == null ? void 0 : h.width) + 50 >= i.body.offsetWidth && (f = void 0, b = i.body.offsetWidth - (m == null ? void 0 : m.right)), x + 202 >= i.body.clientHeight && (x = null, y = i.body.clientHeight - (m == null ? void 0 : m.bottom) + (h == null ? void 0 : h.height)), u({ left: f, top: x, right: b, bottom: y });
3712
+ (h == null ? void 0 : h.left) + (h == null ? void 0 : h.width) + 50 >= i.body.offsetWidth && (f = void 0, b = i.body.offsetWidth - (m == null ? void 0 : m.right)), x + 202 >= i.body.clientHeight && (x = null, y = i.body.clientHeight - (m == null ? void 0 : m.bottom) + (h == null ? void 0 : h.height)), d({ left: f, top: x, right: b, bottom: y });
3714
3713
  }, [p]), a === "canvas") {
3715
3714
  const m = () => {
3716
- d(!1), o && (o == null || o.view.focus(), o == null || o.chain().focus().run());
3715
+ u(!1), o && (o == null || o.view.focus(), o == null || o.chain().focus().run());
3717
3716
  };
3718
3717
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3719
- /* @__PURE__ */ jsx("div", { ref: g, onClick: () => d((h) => !h), className: "cursor-pointer", children: n }),
3718
+ /* @__PURE__ */ jsx("div", { ref: g, onClick: () => u((h) => !h), className: "cursor-pointer", children: n }),
3720
3719
  p && (c.left !== void 0 || c.top !== void 0 || c.right !== void 0 || c.bottom !== void 0) && createPortal(
3721
3720
  /* @__PURE__ */ jsx(
3722
3721
  "div",
@@ -3743,9 +3742,9 @@ const RteDropdownMenu = ({
3743
3742
  )
3744
3743
  ] });
3745
3744
  }
3746
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(DropdownMenu, { open: p, onOpenChange: d, children: [
3745
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(DropdownMenu, { open: p, onOpenChange: u, children: [
3747
3746
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { className: "relative outline-none", asChild: !0, children: n }),
3748
- /* @__PURE__ */ jsx(DropdownMenuContent, { className: "z-50 rounded-md border bg-white p-1 text-xs shadow-xl", children: p && (typeof r == "function" ? r(() => d(!1)) : r) })
3747
+ /* @__PURE__ */ jsx(DropdownMenuContent, { className: "z-50 rounded-md border bg-white p-1 text-xs shadow-xl", children: p && (typeof r == "function" ? r(() => u(!1)) : r) })
3749
3748
  ] }) });
3750
3749
  };
3751
3750
  atomWithStorage("chai-builder-blocks", []);
@@ -3817,7 +3816,7 @@ const getActiveClasses$1 = (o, n, r) => {
3817
3816
  onRemoveHighlightColor: i,
3818
3817
  onClose: c
3819
3818
  }) => {
3820
- const [u] = useDarkMode(), [p] = useAtom$1(lsThemeAtom), d = (p == null ? void 0 : p.colors) || {}, g = Object.values(d).map((f) => get(f, u ? "1" : "0")), [m, h] = useState("TEXT");
3819
+ const [d] = useDarkMode(), [p] = useAtom$1(lsThemeAtom), u = (p == null ? void 0 : p.colors) || {}, g = Object.values(u).map((f) => get(f, d ? "1" : "0")), [m, h] = useState("TEXT");
3821
3820
  return /* @__PURE__ */ jsxs("div", { id: "rte-widget-color-picker", className: "px-1", children: [
3822
3821
  /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center justify-between rounded-md border bg-muted", children: [
3823
3822
  /* @__PURE__ */ jsx(
@@ -3858,8 +3857,8 @@ const getActiveClasses$1 = (o, n, r) => {
3858
3857
  )
3859
3858
  ] });
3860
3859
  }, RteColorPicker = ({ editor: o, from: n, menuRef: r }) => {
3861
- var S, w;
3862
- const a = (S = o == null ? void 0 : o.getAttributes("textStyle")) == null ? void 0 : S.color, l = (w = o == null ? void 0 : o.getAttributes("highlight")) == null ? void 0 : w.color, [i, c] = useState(a || "#000000F2"), [u, p] = useState(l || "#00000057"), [d, g] = useDebouncedState(i, 150), [m, h] = useDebouncedState(u, 150), f = (_, B) => {
3860
+ var C, v;
3861
+ const a = (C = o == null ? void 0 : o.getAttributes("textStyle")) == null ? void 0 : C.color, l = (v = o == null ? void 0 : o.getAttributes("highlight")) == null ? void 0 : v.color, [i, c] = useState(a || "#000000F2"), [d, p] = useState(l || "#00000057"), [u, g] = useDebouncedState(i, 150), [m, h] = useDebouncedState(d, 150), f = (_, B) => {
3863
3862
  B ? (c(_), g(_)) : (o == null || o.chain().setColor(_).run(), c(_));
3864
3863
  }, x = (_, B) => {
3865
3864
  B ? (p(_), h(_)) : (o == null || o.chain().setHighlight({ color: _ }).run(), p(_));
@@ -3873,8 +3872,8 @@ const getActiveClasses$1 = (o, n, r) => {
3873
3872
  }, [l]), useEffect(() => {
3874
3873
  m != null && m.includes("#") && (m == null ? void 0 : m.length) >= 3 && (o == null || o.chain().setHighlight({ color: m }).run());
3875
3874
  }, [m]), useEffect(() => {
3876
- d != null && d.includes("#") && (d == null ? void 0 : d.length) >= 3 && (o == null || o.chain().setColor(d).run());
3877
- }, [d]), /* @__PURE__ */ jsx(
3875
+ u != null && u.includes("#") && (u == null ? void 0 : u.length) >= 3 && (o == null || o.chain().setColor(u).run());
3876
+ }, [u]), /* @__PURE__ */ jsx(
3878
3877
  RteDropdownMenu,
3879
3878
  {
3880
3879
  editor: o,
@@ -3896,7 +3895,7 @@ const getActiveClasses$1 = (o, n, r) => {
3896
3895
  ColorPickerContent,
3897
3896
  {
3898
3897
  textColor: i,
3899
- highlightColor: u,
3898
+ highlightColor: d,
3900
3899
  onChangeTextColor: f,
3901
3900
  onChangeHighlightColor: x,
3902
3901
  onRemoveTextColor: b,
@@ -4168,35 +4167,35 @@ const RichTextEditor = memo(
4168
4167
  value: o,
4169
4168
  blockId: "active-inline-editing-element",
4170
4169
  placeholder: "Enter text here",
4171
- onUpdate: ({ editor: d }) => a((d == null ? void 0 : d.getHTML()) || ""),
4172
- onBlur: ({ editor: d, event: g }) => {
4173
- const m = g == null ? void 0 : g.relatedTarget, h = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = i.querySelector("#chai-rich-text-menu-bar"), b = h == null ? void 0 : h.contains(m), y = f == null ? void 0 : f.contains(m), C = x == null ? void 0 : x.contains(m), S = window.document.getElementById("rte-widget-color-picker");
4174
- if (!b && !y && !C && !S) {
4175
- const w = (d == null ? void 0 : d.getHTML()) || "";
4176
- r(w);
4170
+ onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
4171
+ onBlur: ({ editor: u, event: g }) => {
4172
+ const m = g == null ? void 0 : g.relatedTarget, h = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = i.querySelector("#chai-rich-text-menu-bar"), b = h == null ? void 0 : h.contains(m), y = f == null ? void 0 : f.contains(m), S = x == null ? void 0 : x.contains(m), C = window.document.getElementById("rte-widget-color-picker");
4173
+ if (!b && !y && !S && !C) {
4174
+ const v = (u == null ? void 0 : u.getHTML()) || "";
4175
+ r(v);
4177
4176
  }
4178
4177
  },
4179
4178
  from: "canvas"
4180
4179
  });
4181
4180
  useEffect(() => {
4182
4181
  var g, m;
4183
- const d = getInitialTextAlign(n);
4184
- d && ((g = c == null ? void 0 : c.commands) == null || g.setTextAlign(d)), (m = c == null ? void 0 : c.commands) == null || m.focus(), c == null || c.emit("focus", {
4182
+ const u = getInitialTextAlign(n);
4183
+ u && ((g = c == null ? void 0 : c.commands) == null || g.setTextAlign(u)), (m = c == null ? void 0 : c.commands) == null || m.focus(), c == null || c.emit("focus", {
4185
4184
  editor: c,
4186
4185
  event: new FocusEvent("focus"),
4187
4186
  transaction: []
4188
4187
  });
4189
4188
  }, [c]);
4190
- const u = useMemo(() => {
4189
+ const d = useMemo(() => {
4191
4190
  var m;
4192
- const d = "max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";
4193
- if (!n) return d;
4191
+ const u = "max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";
4192
+ if (!n) return u;
4194
4193
  const g = ((m = n == null ? void 0 : n.className) == null ? void 0 : m.replace("sr-only", "")) || "";
4195
- return `${d} ${g}`;
4196
- }, [n]), p = (d) => {
4197
- d.key === "Escape" && l(d);
4194
+ return `${u} ${g}`;
4195
+ }, [n]), p = (u) => {
4196
+ u.key === "Escape" && l(u);
4198
4197
  };
4199
- return c && /* @__PURE__ */ jsxs("div", { onKeyDown: p, onClick: (d) => d.stopPropagation(), className: "relative", children: [
4198
+ return c && /* @__PURE__ */ jsxs("div", { onKeyDown: p, onClick: (u) => u.stopPropagation(), className: "relative", children: [
4200
4199
  /* @__PURE__ */ jsx(
4201
4200
  BubbleMenu,
4202
4201
  {
@@ -4207,7 +4206,7 @@ const RichTextEditor = memo(
4207
4206
  children: /* @__PURE__ */ jsx(RteMenubar, { editor: c, from: "canvas" })
4208
4207
  }
4209
4208
  ),
4210
- /* @__PURE__ */ jsx(EditorContent, { onKeyDown: p, value: o, editor: c, className: u })
4209
+ /* @__PURE__ */ jsx(EditorContent, { onKeyDown: p, value: o, editor: c, className: d })
4211
4210
  ] });
4212
4211
  }
4213
4212
  ), MemoizedEditor = memo(
@@ -4219,20 +4218,20 @@ const RichTextEditor = memo(
4219
4218
  onChange: l,
4220
4219
  onEscape: i
4221
4220
  }) => {
4222
- const { document: c, window: u } = useFrame();
4221
+ const { document: c, window: d } = useFrame();
4223
4222
  useEffect(() => {
4224
4223
  if (a.current) {
4225
4224
  a.current.innerHTML = n, a.current.focus();
4226
- const h = c.createRange(), f = u.getSelection();
4225
+ const h = c.createRange(), f = d.getSelection();
4227
4226
  h.selectNodeContents(a.current), h.collapse(!1), f == null || f.removeAllRanges(), f == null || f.addRange(h), a.current.focus();
4228
4227
  } else
4229
4228
  r();
4230
- }, [c, u]);
4229
+ }, [c, d]);
4231
4230
  const p = useMemo(() => {
4232
4231
  var f;
4233
4232
  const h = ((f = o == null ? void 0 : o.tagName) == null ? void 0 : f.toLowerCase()) || "div";
4234
4233
  return h === "button" ? "div" : h;
4235
- }, [o]), d = useCallback(
4234
+ }, [o]), u = useCallback(
4236
4235
  (h) => {
4237
4236
  (h.key === "Enter" || h.key === "Escape") && i(h);
4238
4237
  },
@@ -4258,23 +4257,23 @@ const RichTextEditor = memo(
4258
4257
  return /* @__PURE__ */ jsx(Fragment, { children: createElement(p, {
4259
4258
  ref: a,
4260
4259
  onBlur: g,
4261
- onKeyDown: d,
4260
+ onKeyDown: u,
4262
4261
  ...m
4263
4262
  }) });
4264
4263
  }
4265
4264
  ), WithBlockTextEditor = memo(
4266
4265
  ({ block: o, children: n }) => {
4267
- const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: u } = useInlineEditing(), [p, d] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: f } = useLanguages(), [, x] = useSelectedBlockIds(), b = useRef(null), y = l, { blockContent: C, blockType: S } = useMemo(() => {
4266
+ const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: f } = useLanguages(), [, x] = useSelectedBlockIds(), b = useRef(null), y = l, { blockContent: S, blockType: C } = useMemo(() => {
4268
4267
  var j;
4269
4268
  const k = o._type;
4270
4269
  let A = o[r];
4271
- const v = getRegisteredChaiBlock(o._type);
4272
- return f && ((j = v == null ? void 0 : v.i18nProps) == null ? void 0 : j.includes(r)) && has(o, `${r}-${f}`) && (A = get(o, `${r}-${f}`)), { blockContent: A, blockType: k };
4273
- }, [o, f]), w = useCallback(
4270
+ const w = getRegisteredChaiBlock(o._type);
4271
+ return f && ((j = w == null ? void 0 : w.i18nProps) == null ? void 0 : j.includes(r)) && has(o, `${r}-${f}`) && (A = get(o, `${r}-${f}`)), { blockContent: A, blockType: k };
4272
+ }, [o, f]), v = useCallback(
4274
4273
  (k) => {
4275
- var v;
4276
- const A = k || ((v = g.current) == null ? void 0 : v.innerText);
4277
- h([y], { [r]: A }), d(null), c(null), u(-1), x([]), y && setTimeout(() => x([y]), 100);
4274
+ var w;
4275
+ const A = k || ((w = g.current) == null ? void 0 : w.innerText);
4276
+ h([y], { [r]: A }), u(null), c(null), d(-1), x([]), y && setTimeout(() => x([y]), 100);
4278
4277
  },
4279
4278
  [y, h, c, x, f]
4280
4279
  ), _ = useDebouncedCallback(
@@ -4285,7 +4284,7 @@ const RichTextEditor = memo(
4285
4284
  1e3
4286
4285
  ), B = useCallback(
4287
4286
  (k) => {
4288
- k.preventDefault(), y && (b.current = y), w(), setTimeout(() => {
4287
+ k.preventDefault(), y && (b.current = y), v(), setTimeout(() => {
4289
4288
  const A = b.current;
4290
4289
  b.current = null, x([A]);
4291
4290
  }, 100);
@@ -4295,29 +4294,29 @@ const RichTextEditor = memo(
4295
4294
  useEffect(() => {
4296
4295
  var E;
4297
4296
  if (!y) return;
4298
- const k = `[data-block-id="${y}"]`, A = i >= 0 ? `[data-block-index="${i}"]` : "", v = a.querySelector(`${k}${A}`);
4299
- v && ((E = v == null ? void 0 : v.classList) == null || E.add("sr-only"), d(v));
4300
- }, [y, S, a, i]);
4301
- const I = useMemo(() => p ? (m(), ["RichText", "Paragraph"].includes(S) ? /* @__PURE__ */ jsx(
4297
+ const k = `[data-block-id="${y}"]`, A = i >= 0 ? `[data-block-index="${i}"]` : "", w = a.querySelector(`${k}${A}`);
4298
+ w && ((E = w == null ? void 0 : w.classList) == null || E.add("sr-only"), u(w));
4299
+ }, [y, C, a, i]);
4300
+ const I = useMemo(() => p ? (m(), ["RichText", "Paragraph"].includes(C) ? /* @__PURE__ */ jsx(
4302
4301
  RichTextEditor,
4303
4302
  {
4304
- blockContent: C,
4303
+ blockContent: S,
4305
4304
  editingElement: p,
4306
4305
  onChange: _,
4307
- onClose: w,
4306
+ onClose: v,
4308
4307
  onEscape: B
4309
4308
  }
4310
4309
  ) : /* @__PURE__ */ jsx(
4311
4310
  MemoizedEditor,
4312
4311
  {
4313
4312
  editorRef: g,
4314
- blockContent: C,
4313
+ blockContent: S,
4315
4314
  editingElement: p,
4316
- onClose: w,
4315
+ onClose: v,
4317
4316
  onChange: _,
4318
4317
  onEscape: B
4319
4318
  }
4320
- )) : null, [p, y, S, C, w, f]);
4319
+ )) : null, [p, y, C, S, v, f]);
4321
4320
  return /* @__PURE__ */ jsxs(Fragment, { children: [
4322
4321
  I,
4323
4322
  n
@@ -4355,40 +4354,40 @@ const RichTextEditor = memo(
4355
4354
  blockAtom: n,
4356
4355
  children: r
4357
4356
  }) => {
4358
- const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: u, fallbackLang: p } = useLanguages(), d = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useAtom$1(dataBindingActiveAtom), h = get(c, "component", null), { index: f, key: x } = useContext(RepeaterContext), { mode: b } = useEditorMode(), y = useMemo(
4359
- () => m ? applyBindingToBlockProps(applyLanguage(i, u, c), g, {
4357
+ const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useAtom$1(dataBindingActiveAtom), h = get(c, "component", null), { index: f, key: x } = useContext(RepeaterContext), { mode: b } = useEditorMode(), y = useMemo(
4358
+ () => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
4360
4359
  index: f,
4361
4360
  key: x
4362
- }) : applyLanguage(i, u, c),
4363
- [i, u, c, g, m, f, x]
4364
- ), C = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), S = useMemo(
4365
- () => d(i._id, getBlockRuntimeProps(i._type)),
4366
- [i._id, i._type, d, getBlockRuntimeProps]
4367
- ), w = useMemo(
4361
+ }) : applyLanguage(i, d, c),
4362
+ [i, d, c, g, m, f, x]
4363
+ ), S = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), C = useMemo(
4364
+ () => u(i._id, getBlockRuntimeProps(i._type)),
4365
+ [i._id, i._type, u, getBlockRuntimeProps]
4366
+ ), v = useMemo(
4368
4367
  () => ({
4369
4368
  blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": f },
4370
4369
  inBuilder: b === "edit",
4371
- lang: u || p,
4370
+ lang: d || p,
4372
4371
  ...y,
4373
- ...C,
4374
4372
  ...S,
4373
+ ...C,
4375
4374
  ...o
4376
4375
  }),
4377
4376
  [
4378
4377
  b,
4379
4378
  i._id,
4380
4379
  i._type,
4381
- u,
4380
+ d,
4382
4381
  p,
4383
4382
  y,
4384
- C,
4385
4383
  S,
4384
+ C,
4386
4385
  o
4387
4386
  ]
4388
4387
  ), _ = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]), B = useMemo(() => get(i, "_show", !0), [i]);
4389
4388
  if (isNull(h) || !B) return null;
4390
4389
  let I = /* @__PURE__ */ jsx(Suspense, { children: createElement(h, {
4391
- ...w,
4390
+ ...v,
4392
4391
  children: r({
4393
4392
  _id: i._id,
4394
4393
  _type: i._type,
@@ -4404,8 +4403,8 @@ const RichTextEditor = memo(
4404
4403
  return _ ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: k }) : k;
4405
4404
  }, PartialWrapper$1 = ({ children: o, partialBlockId: n }) => {
4406
4405
  const r = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
4407
- (u) => {
4408
- if (u.stopPropagation(), a !== "SAVED") {
4406
+ (d) => {
4407
+ if (d.stopPropagation(), a !== "SAVED") {
4409
4408
  toast.error("You have unsaved changes. Please save the page first.");
4410
4409
  return;
4411
4410
  }
@@ -4435,16 +4434,16 @@ const RichTextEditor = memo(
4435
4434
  }) => {
4436
4435
  const l = useGetBlockAtom(r);
4437
4436
  let i = useMemo(
4438
- () => filter(o, (u) => has(u, "_id") && (isEmpty(n) ? !u._parent : u._parent === n)),
4437
+ () => filter(o, (d) => has(d, "_id") && (isEmpty(n) ? !d._parent : d._parent === n)),
4439
4438
  [o, n]
4440
4439
  );
4441
4440
  const c = useCallback(
4442
- (u) => filter(o, (p) => p._parent === u).length > 0,
4441
+ (d) => filter(o, (p) => p._parent === d).length > 0,
4443
4442
  [o]
4444
4443
  );
4445
- return c && (a === "Heading" || a === "Paragraph" || a === "Link") && (i = adjustSpacingInContentBlocks(i)), map(i, (u) => {
4446
- const p = l(u._id);
4447
- return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: u, children: (d) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: p, asyncProps: d, children: ({ _id: g, _type: m, partialBlockId: h, repeaterItems: f, $repeaterItemsKey: x }) => m === "Repeater" ? isArray(f) && f.map((b, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: u._id, type: m }) }, `${g}-${y}`)) : m === "GlobalBlock" || m === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : c(g) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: u._id, type: m }) : null }) }, u._id) : null;
4444
+ return c && (a === "Heading" || a === "Paragraph" || a === "Link") && (i = adjustSpacingInContentBlocks(i)), map(i, (d) => {
4445
+ const p = l(d._id);
4446
+ return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: d, children: (u) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: p, asyncProps: u, children: ({ _id: g, _type: m, partialBlockId: h, repeaterItems: f, $repeaterItemsKey: x }) => m === "Repeater" ? isArray(f) && f.map((b, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) }, `${g}-${y}`)) : m === "GlobalBlock" || m === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : c(g) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) : null }) }, d._id) : null;
4448
4447
  });
4449
4448
  }, PageBlocksRenderer = () => {
4450
4449
  const [o] = useBlocksStore();
@@ -4454,24 +4453,24 @@ const RichTextEditor = memo(
4454
4453
  return /* @__PURE__ */ jsx(Fragment, { children: n });
4455
4454
  }, useCanvasScale = (o) => {
4456
4455
  const [n] = useCanvasDisplayWidth(), [, r] = useCanvasZoom(), a = useBuilderProp("htmlDir", "ltr"), [l, i] = useState({}), c = useCallback(() => {
4457
- const { width: u, height: p } = o;
4458
- if (u < n) {
4459
- const d = parseFloat((u / n).toFixed(2).toString());
4456
+ const { width: d, height: p } = o;
4457
+ if (d < n) {
4458
+ const u = parseFloat((d / n).toFixed(2).toString());
4460
4459
  let g = {};
4461
- const m = p * d, h = u * d;
4460
+ const m = p * u, h = d * u;
4462
4461
  p && (g = {
4463
4462
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
4464
4463
  height: 100 + (p - m) / m * 100 + "%",
4465
- width: 100 + (u - h) / h * 100 + "%"
4464
+ width: 100 + (d - h) / h * 100 + "%"
4466
4465
  }), i({
4467
4466
  position: "relative",
4468
4467
  top: 0,
4469
- transform: `scale(${d})`,
4468
+ transform: `scale(${u})`,
4470
4469
  transformOrigin: a === "rtl" ? "top right" : "top left",
4471
4470
  ...g,
4472
4471
  maxWidth: "none"
4473
4472
  // TODO: Add max-width to the wrapper
4474
- }), r(d * 100);
4473
+ }), r(u * 100);
4475
4474
  } else
4476
4475
  i({}), r(100);
4477
4476
  }, [n, o, a, r]);
@@ -4484,26 +4483,26 @@ const RichTextEditor = memo(
4484
4483
  setTimeout(() => {
4485
4484
  if (!isEmpty(n))
4486
4485
  return;
4487
- const u = getElementByDataBlockId(a, first(i));
4488
- if (u) {
4489
- const p = u.getAttribute("data-style-prop");
4486
+ const d = getElementByDataBlockId(a, first(i));
4487
+ if (d) {
4488
+ const p = d.getAttribute("data-style-prop");
4490
4489
  if (p) {
4491
- const d = u.getAttribute("data-style-id"), g = u.getAttribute("data-block-parent");
4492
- r([{ id: d, prop: p, blockId: g }]);
4490
+ const u = d.getAttribute("data-style-id"), g = d.getAttribute("data-block-parent");
4491
+ r([{ id: u, prop: p, blockId: g }]);
4493
4492
  }
4494
4493
  }
4495
4494
  }, 100);
4496
- }, [a, i, r, n]), useEffect(() => () => l(), [l]), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, (u) => {
4497
- u && (!isEmpty(u) && !includes(i, first(u)) && (c == null || c.closeAll()), o(u));
4498
- }), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, (u) => {
4499
- if (!u) return;
4500
- const { blockId: p, styleId: d, styleProp: g } = u;
4501
- p && (includes(i, p) || c == null || c.closeAll(), r([{ id: d, prop: g, blockId: p }]), o([p]));
4495
+ }, [a, i, r, n]), useEffect(() => () => l(), [l]), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, (d) => {
4496
+ d && (!isEmpty(d) && !includes(i, first(d)) && (c == null || c.closeAll()), o(d));
4497
+ }), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, (d) => {
4498
+ if (!d) return;
4499
+ const { blockId: p, styleId: u, styleProp: g } = d;
4500
+ p && (includes(i, p) || c == null || c.closeAll(), r([{ id: u, prop: g, blockId: p }]), o([p]));
4502
4501
  }), usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION, () => {
4503
4502
  l(), o([]), r([]);
4504
4503
  }), null;
4505
4504
  }, StaticCanvas = () => {
4506
- const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, u] = useCanvasIframe(), p = useBuilderProp("loading", !1), d = useBuilderProp("htmlDir", "ltr"), g = useCallback(
4505
+ const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useCanvasIframe(), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), g = useCallback(
4507
4506
  (h) => {
4508
4507
  i((f) => ({ ...f, width: h }));
4509
4508
  },
@@ -4516,8 +4515,8 @@ const RichTextEditor = memo(
4516
4515
  }, [a, o]);
4517
4516
  const m = useMemo(() => {
4518
4517
  let h = IframeInitialContent;
4519
- return h = h.replace("__HTML_DIR__", d), h;
4520
- }, [d]);
4518
+ return h = h.replace("__HTML_DIR__", u), h;
4519
+ }, [u]);
4521
4520
  return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: g, onResize: g, children: /* @__PURE__ */ jsx(
4522
4521
  "div",
4523
4522
  {
@@ -4527,7 +4526,7 @@ const RichTextEditor = memo(
4527
4526
  children: /* @__PURE__ */ jsxs(
4528
4527
  ChaiFrame,
4529
4528
  {
4530
- contentDidMount: () => u(r.current),
4529
+ contentDidMount: () => d(r.current),
4531
4530
  ref: r,
4532
4531
  id: "canvas-iframe",
4533
4532
  style: { ...c, ...isEmpty(c) ? { width: `${o}px` } : {} },
@@ -4562,7 +4561,7 @@ const RichTextEditor = memo(
4562
4561
  /* @__PURE__ */ jsx("p", { className: "font-semibold", children: o("Oops! Something went wrong.") }),
4563
4562
  /* @__PURE__ */ jsx("p", { children: o("Please try again.") })
4564
4563
  ] }) });
4565
- }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-CihZ_PJK.js")), CanvasArea = () => {
4564
+ }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-CfrDD-_Q.js")), CanvasArea = () => {
4566
4565
  const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
4567
4566
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40", children: [
4568
4567
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -4602,9 +4601,9 @@ const RichTextEditor = memo(
4602
4601
  useEffect(() => {
4603
4602
  i(o || "");
4604
4603
  }, [o]);
4605
- const c = (u) => {
4606
- i(u);
4607
- const p = sanitizeSvg(u);
4604
+ const c = (d) => {
4605
+ i(d);
4606
+ const p = sanitizeSvg(d);
4608
4607
  n(p);
4609
4608
  };
4610
4609
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex flex-col gap-2", id: "icon-picker-field", children: [
@@ -4618,7 +4617,7 @@ const RichTextEditor = memo(
4618
4617
  autoCorrect: "off",
4619
4618
  spellCheck: "false",
4620
4619
  value: l,
4621
- onChange: (u) => c(u.target.value),
4620
+ onChange: (d) => c(d.target.value),
4622
4621
  placeholder: a("SVG_code"),
4623
4622
  rows: 2,
4624
4623
  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"
@@ -4631,7 +4630,7 @@ const RichTextEditor = memo(
4631
4630
  ] })
4632
4631
  ] });
4633
4632
  }, DefaultMediaManager = ({ close: o, onSelect: n, mode: r = "image" }) => {
4634
- const [a, l] = useState(""), [i, c] = useState(!1), [u, p] = useState(!1), [d, g] = useState(null), m = async (f) => {
4633
+ const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), m = async (f) => {
4635
4634
  if (!f.trim()) {
4636
4635
  p(!1), g("Please enter a URL");
4637
4636
  return;
@@ -4646,9 +4645,9 @@ const RichTextEditor = memo(
4646
4645
  }, { t: h } = useTranslation();
4647
4646
  return /* @__PURE__ */ jsxs("div", { className: "flex w-96 flex-col gap-4 p-4", children: [
4648
4647
  /* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold", children: h(`${r.charAt(0).toUpperCase() + r.slice(1)} Manager`) }),
4649
- d && /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
4648
+ u && /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
4650
4649
  /* @__PURE__ */ jsx(ExclamationTriangleIcon, { className: "h-4 w-4" }),
4651
- /* @__PURE__ */ jsx(AlertDescription, { children: d })
4650
+ /* @__PURE__ */ jsx(AlertDescription, { children: u })
4652
4651
  ] }),
4653
4652
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
4654
4653
  /* @__PURE__ */ jsx(
@@ -4666,7 +4665,7 @@ const RichTextEditor = memo(
4666
4665
  Button,
4667
4666
  {
4668
4667
  onClick: () => n({ id: "dam-id", url: a, width: 600, height: 400, description: "This is image description" }),
4669
- disabled: !u || i,
4668
+ disabled: !d || i,
4670
4669
  children: h("Insert")
4671
4670
  }
4672
4671
  )
@@ -4701,31 +4700,31 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4701
4700
  const n = ((l = o.split("/").pop()) == null ? void 0 : l.split("?")[0]) || "";
4702
4701
  return [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".bmp", ".ico", ".avif"].some((i) => n.toLowerCase().endsWith(i)) ? n : "";
4703
4702
  }, ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
4704
- const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), u = useUpdateBlocksProps(), p = usePageExternalData(), d = r.split(".").pop() || "", g = i ? `_${d}Id-${i}` : `_${d}Id`, m = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, g, m ? c == null ? void 0 : c.assetId : ""), f = useMemo(() => {
4703
+ const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = usePageExternalData(), u = r.split(".").pop() || "", g = i ? `_${u}Id-${i}` : `_${u}Id`, m = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, g, m ? c == null ? void 0 : c.assetId : ""), f = useMemo(() => {
4705
4704
  if (!o || !c || !/\{\{.*?\}\}/.test(o)) return o;
4706
- const w = { ...c, [d]: o }, _ = applyBindingToBlockProps(w, p, { index: -1, key: "" });
4707
- return get(_, d, o);
4708
- }, [o, c, p, d]), x = !!h || f !== PLACEHOLDER_IMAGE, b = (S) => {
4709
- const w = isArray(S) ? first(S) : S;
4710
- if (w) {
4711
- n(w == null ? void 0 : w.url);
4712
- const _ = w == null ? void 0 : w.width, B = w == null ? void 0 : w.height, I = g.includes("mobile");
4705
+ const v = { ...c, [u]: o }, _ = applyBindingToBlockProps(v, p, { index: -1, key: "" });
4706
+ return get(_, u, o);
4707
+ }, [o, c, p, u]), x = !!h || f !== PLACEHOLDER_IMAGE, b = (C) => {
4708
+ const v = isArray(C) ? first(C) : C;
4709
+ if (v) {
4710
+ n(v == null ? void 0 : v.url);
4711
+ const _ = v == null ? void 0 : v.width, B = v == null ? void 0 : v.height, I = g.includes("mobile");
4713
4712
  if (c != null && c._id) {
4714
4713
  const k = {
4715
4714
  ..._ && { [I ? "mobileWidth" : "width"]: _ },
4716
4715
  ...B && { [I ? "mobileHeight" : "height"]: B },
4717
- ...w.description && { alt: w.description }
4716
+ ...v.description && { alt: v.description }
4718
4717
  };
4719
- if (set(k, g, w.id), isEmpty(k)) return;
4720
- u([c._id], k);
4718
+ if (set(k, g, v.id), isEmpty(k)) return;
4719
+ d([c._id], k);
4721
4720
  }
4722
4721
  }
4723
4722
  }, y = useCallback(() => {
4724
4723
  if (n(PLACEHOLDER_IMAGE), c != null && c._id) {
4725
- const S = {}, w = g.includes("mobile");
4726
- set(S, g, ""), set(S, w ? "mobileWidth" : "width", ""), set(S, w ? "mobileHeight" : "height", ""), u([c._id], S);
4724
+ const C = {}, v = g.includes("mobile");
4725
+ set(C, g, ""), set(C, v ? "mobileWidth" : "width", ""), set(C, v ? "mobileHeight" : "height", ""), d([c._id], C);
4727
4726
  }
4728
- }, [n, c == null ? void 0 : c._id, u, g]), C = getFileName(f);
4727
+ }, [n, c == null ? void 0 : c._id, d, g]), S = getFileName(f);
4729
4728
  return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-start gap-x-3", children: [
4730
4729
  f ? /* @__PURE__ */ jsxs("div", { className: "group relative", children: [
4731
4730
  /* @__PURE__ */ jsx(
@@ -4756,7 +4755,7 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4756
4755
  ] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: b, mode: "image", assetId: h, children: /* @__PURE__ */ jsx("div", { className: "h-14 w-14 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
4757
4756
  /* @__PURE__ */ jsxs("div", { className: "flex w-3/5 flex-col", children: [
4758
4757
  /* @__PURE__ */ jsxs(Fragment, { children: [
4759
- /* @__PURE__ */ jsx("p", { className: "max-w-[250px] truncate pr-2 text-xs text-gray-400", children: C }),
4758
+ /* @__PURE__ */ jsx("p", { className: "max-w-[250px] truncate pr-2 text-xs text-gray-400", children: S }),
4760
4759
  /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: b, assetId: "", children: /* @__PURE__ */ jsx("small", { className: "h-6 mb-1 w-full cursor-pointer rounded-md bg-secondary px-1 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: !isEmpty(f) && f !== PLACEHOLDER_IMAGE ? l("Replace image") : l("Choose image") }) }),
4761
4760
  /* @__PURE__ */ jsx("div", { className: "text-center text-xs text-gray-400", children: "OR" })
4762
4761
  ] }),
@@ -4771,31 +4770,31 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4771
4770
  className: "h-6 text-xs",
4772
4771
  placeholder: l("Enter image URL"),
4773
4772
  value: o === PLACEHOLDER_IMAGE ? "" : o,
4774
- onBlur: ({ target: { value: S } }) => a(r, S),
4775
- onChange: (S) => n(S.target.value)
4773
+ onBlur: ({ target: { value: C } }) => a(r, C),
4774
+ onChange: (C) => n(C.target.value)
4776
4775
  }
4777
4776
  )
4778
4777
  ] })
4779
4778
  ] });
4780
4779
  }, PathDropdown = ({ data: o, onSelect: n, dataType: r }) => {
4781
- const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), u = (m) => Array.isArray(m) ? "array" : typeof m == "object" && m !== null ? "object" : "value", p = React__default.useCallback(
4780
+ const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (m) => Array.isArray(m) ? "array" : typeof m == "object" && m !== null ? "object" : "value", p = React__default.useCallback(
4782
4781
  (m) => {
4783
4782
  const h = (f) => r === "value" ? f === "value" || f === "object" : r === "array" ? f === "array" : f === r;
4784
4783
  m.type === "object" ? (l((f) => [...f, m.key]), c(m.value)) : h(m.type) && n([...a, m.key].join("."), r);
4785
4784
  },
4786
4785
  [a, n, r]
4787
- ), d = React__default.useCallback(() => {
4786
+ ), u = React__default.useCallback(() => {
4788
4787
  if (a.length > 0) {
4789
4788
  const m = a.slice(0, -1);
4790
4789
  l(m), c(m.reduce((h, f) => h[f], o));
4791
4790
  }
4792
- }, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([m, h]) => ({ key: m, value: h, type: u(h) })).filter((m) => !startsWith(m.key, REPEATER_PREFIX) && m.key.includes("/") ? !1 : r === "value" ? m.type === "value" || m.type === "object" : r === "array" ? m.type === "array" || m.type === "object" : r === "object" ? m.type === "object" : !0) : [], [i, r]);
4791
+ }, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([m, h]) => ({ key: m, value: h, type: d(h) })).filter((m) => !startsWith(m.key, REPEATER_PREFIX) && m.key.includes("/") ? !1 : r === "value" ? m.type === "value" || m.type === "object" : r === "array" ? m.type === "array" || m.type === "object" : r === "object" ? m.type === "object" : !0) : [], [i, r]);
4793
4792
  return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
4794
4793
  /* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
4795
4794
  /* @__PURE__ */ jsxs(CommandList, { children: [
4796
4795
  /* @__PURE__ */ jsx(CommandEmpty, { children: t("No option found.") }),
4797
4796
  /* @__PURE__ */ jsxs(CommandGroup, { children: [
4798
- a.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: d, className: "flex items-center text-sm", children: [
4797
+ a.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: u, className: "flex items-center text-sm", children: [
4799
4798
  /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "mr-2 h-4 w-4" }),
4800
4799
  t("Back")
4801
4800
  ] }),
@@ -4835,7 +4834,7 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4835
4834
  ] });
4836
4835
  };
4837
4836
  function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4838
- const [a, l] = React__default.useState(!1), i = useBuilderProp("collections", []), c = React__default.useMemo(() => r === "array" ? { ...i.map((p) => p.id).reduce((p, d) => ({ ...p, [COLLECTION_PREFIX + d]: [] }), {}), ...o } : o, [o, i, r]);
4837
+ const [a, l] = React__default.useState(!1), i = useBuilderProp("collections", []), c = React__default.useMemo(() => r === "array" ? { ...i.map((p) => p.id).reduce((p, u) => ({ ...p, [COLLECTION_PREFIX + u]: [] }), {}), ...o } : o, [o, i, r]);
4839
4838
  return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
4840
4839
  /* @__PURE__ */ jsxs(Tooltip, { children: [
4841
4840
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
@@ -4864,8 +4863,8 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4864
4863
  PathDropdown,
4865
4864
  {
4866
4865
  data: c,
4867
- onSelect: (u, p) => {
4868
- n(u, p), l(!1);
4866
+ onSelect: (d, p) => {
4867
+ n(d, p), l(!1);
4869
4868
  },
4870
4869
  dataType: r
4871
4870
  }
@@ -4878,21 +4877,21 @@ const DataBindingSelector = ({
4878
4877
  id: r,
4879
4878
  formData: a
4880
4879
  }) => {
4881
- const l = usePageExternalData(), i = useBuilderProp("flags.dataBinding", !0), c = useSelectedBlockHierarchy(), u = useSelectedBlock(), p = useMemo(() => {
4880
+ const l = usePageExternalData(), i = useBuilderProp("flags.dataBinding", !0), c = useSelectedBlockHierarchy(), d = useSelectedBlock(), p = useMemo(() => {
4882
4881
  if (c.length === 1) return "";
4883
4882
  const m = c.find((x) => x._type === "Repeater"), f = get(m, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
4884
4883
  return `${REPEATER_PREFIX}${startsWith(f, COLLECTION_PREFIX) ? `${f}/${m._id}` : f}`;
4885
- }, [c]), d = useMemo(() => first(get(l, p.replace(REPEATER_PREFIX, ""), [])), [p, l]), g = useCallback(
4884
+ }, [c]), u = useMemo(() => first(get(l, p.replace(REPEATER_PREFIX, ""), [])), [p, l]), g = useCallback(
4886
4885
  (m, h) => {
4887
4886
  if (m = isEmpty(p) ? m : m.replace(`${p}`, "$index"), h === "array" || h === "object") {
4888
4887
  n(`{{${m}}}`, {}, r);
4889
4888
  return;
4890
4889
  }
4891
- const f = (C) => /[.,!?;:]/.test(C), x = (C, S, w) => {
4890
+ const f = (S) => /[.,!?;:]/.test(S), x = (S, C, v) => {
4892
4891
  let _ = "", B = "";
4893
- const I = S > 0 ? C[S - 1] : "", k = S < C.length ? C[S] : "";
4894
- return S > 0 && (I === "." || !f(I) && I !== " ") && (_ = " "), S < C.length && !f(k) && k !== " " && (B = " "), {
4895
- text: _ + w + B,
4892
+ const I = C > 0 ? S[C - 1] : "", k = C < S.length ? S[C] : "";
4893
+ return C > 0 && (I === "." || !f(I) && I !== " ") && (_ = " "), C < S.length && !f(k) && k !== " " && (B = " "), {
4894
+ text: _ + v + B,
4896
4895
  prefixLength: _.length,
4897
4896
  suffixLength: B.length
4898
4897
  };
@@ -4900,41 +4899,41 @@ const DataBindingSelector = ({
4900
4899
  if (!b) return;
4901
4900
  const y = document.getElementById(`chai-rte-${r}`) || document.getElementById(`chai-rte-modal-${r}`);
4902
4901
  if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
4903
- const C = y.__chaiRTE;
4904
- if (C) {
4905
- const S = `{{${m}}}`;
4906
- C.commands.focus();
4907
- const { from: w, to: _ } = C.state.selection;
4908
- if (w !== _)
4909
- C.chain().deleteSelection().insertContent(S).run();
4902
+ const S = y.__chaiRTE;
4903
+ if (S) {
4904
+ const C = `{{${m}}}`;
4905
+ S.commands.focus();
4906
+ const { from: v, to: _ } = S.state.selection;
4907
+ if (v !== _)
4908
+ S.chain().deleteSelection().insertContent(C).run();
4910
4909
  else {
4911
- const { state: I } = C, k = I.selection.from, A = I.doc.textBetween(Math.max(0, k - 1), k), v = I.doc.textBetween(k, Math.min(k + 1, I.doc.content.size));
4910
+ const { state: I } = S, k = I.selection.from, A = I.doc.textBetween(Math.max(0, k - 1), k), w = I.doc.textBetween(k, Math.min(k + 1, I.doc.content.size));
4912
4911
  let E = "";
4913
4912
  k > 0 && A !== " " && !f(A) && (E = " ");
4914
4913
  let j = "";
4915
- v && v !== " " && !f(v) && (j = " "), C.chain().insertContent(E + S + j).run();
4914
+ w && w !== " " && !f(w) && (j = " "), S.chain().insertContent(E + C + j).run();
4916
4915
  }
4917
- setTimeout(() => n(C.getHTML(), {}, r), 100);
4916
+ setTimeout(() => n(S.getHTML(), {}, r), 100);
4918
4917
  return;
4919
4918
  }
4920
4919
  } else {
4921
- const C = b, S = C.selectionStart || 0, w = C.value || "", _ = C.selectionEnd || S;
4922
- if (_ > S) {
4923
- const v = `{{${m}}}`, { text: E } = x(w, S, v), j = w.slice(0, S) + E + w.slice(_);
4920
+ const S = b, C = S.selectionStart || 0, v = S.value || "", _ = S.selectionEnd || C;
4921
+ if (_ > C) {
4922
+ const w = `{{${m}}}`, { text: E } = x(v, C, w), j = v.slice(0, C) + E + v.slice(_);
4924
4923
  n(j, {}, r);
4925
4924
  return;
4926
4925
  }
4927
- const I = `{{${m}}}`, { text: k } = x(w, S, I), A = w.slice(0, S) + k + w.slice(S);
4926
+ const I = `{{${m}}}`, { text: k } = x(v, C, I), A = v.slice(0, C) + k + v.slice(C);
4928
4927
  n(A, {}, r);
4929
4928
  }
4930
4929
  },
4931
- [r, n, a, u == null ? void 0 : u._id, p]
4930
+ [r, n, a, d == null ? void 0 : d._id, p]
4932
4931
  );
4933
4932
  return i ? /* @__PURE__ */ jsx(
4934
4933
  NestedPathSelector,
4935
4934
  {
4936
4935
  data: {
4937
- ...d && { [p]: d },
4936
+ ...u && { [p]: u },
4938
4937
  ...l
4939
4938
  },
4940
4939
  onSelect: g,
@@ -4947,104 +4946,104 @@ const DataBindingSelector = ({
4947
4946
  onChange: r
4948
4947
  }) => {
4949
4948
  var A;
4950
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, E) => []), [i, c] = useState(!1), [u, p] = useState(!1), [d, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), C = useRef(null), S = (A = n == null ? void 0 : n.find((v) => v.key === d)) == null ? void 0 : A.name;
4949
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (w, E) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), S = useRef(null), C = (A = n == null ? void 0 : n.find((w) => w.key === u)) == null ? void 0 : A.name;
4951
4950
  useEffect(() => {
4952
4951
  if (h(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4953
- const v = split(o, ":"), E = get(v, 1, "page") || "page";
4952
+ const w = split(o, ":"), E = get(w, 1, "page") || "page";
4954
4953
  g(E), (async () => {
4955
- const j = await l(E, [get(v, 2, "page")]);
4954
+ const j = await l(E, [get(w, 2, "page")]);
4956
4955
  j && Array.isArray(j) && h(get(j, [0, "name"], ""));
4957
4956
  })();
4958
4957
  }, [o]);
4959
- const w = useDebouncedCallback(
4960
- async (v) => {
4961
- if (isEmpty(v))
4958
+ const v = useDebouncedCallback(
4959
+ async (w) => {
4960
+ if (isEmpty(w))
4962
4961
  x([]);
4963
4962
  else {
4964
- const E = await l(d, v);
4963
+ const E = await l(u, w);
4965
4964
  x(E);
4966
4965
  }
4967
4966
  c(!1), y(-1);
4968
4967
  },
4969
- [d],
4968
+ [u],
4970
4969
  300
4971
- ), _ = (v) => {
4972
- const E = ["pageType", d, v.id];
4973
- E[1] && (r(E.join(":")), h(v.name), p(!1), x([]), y(-1));
4974
- }, B = (v) => {
4975
- switch (v.key) {
4970
+ ), _ = (w) => {
4971
+ const E = ["pageType", u, w.id];
4972
+ E[1] && (r(E.join(":")), h(w.name), p(!1), x([]), y(-1));
4973
+ }, B = (w) => {
4974
+ switch (w.key) {
4976
4975
  case "ArrowDown":
4977
- v.preventDefault(), y((E) => E < f.length - 1 ? E + 1 : E);
4976
+ w.preventDefault(), y((E) => E < f.length - 1 ? E + 1 : E);
4978
4977
  break;
4979
4978
  case "ArrowUp":
4980
- v.preventDefault(), y((E) => E > 0 ? E - 1 : E);
4979
+ w.preventDefault(), y((E) => E > 0 ? E - 1 : E);
4981
4980
  break;
4982
4981
  case "Enter":
4983
- if (v.preventDefault(), f.length === 0) return;
4982
+ if (w.preventDefault(), f.length === 0) return;
4984
4983
  b >= 0 && _(f[b]);
4985
4984
  break;
4986
4985
  case "Escape":
4987
- v.preventDefault(), I();
4986
+ w.preventDefault(), I();
4988
4987
  break;
4989
4988
  }
4990
4989
  };
4991
4990
  useEffect(() => {
4992
- if (b >= 0 && C.current) {
4993
- const v = C.current.children[b];
4994
- v == null || v.scrollIntoView({ block: "nearest" });
4991
+ if (b >= 0 && S.current) {
4992
+ const w = S.current.children[b];
4993
+ w == null || w.scrollIntoView({ block: "nearest" });
4995
4994
  }
4996
4995
  }, [b]);
4997
4996
  const I = () => {
4998
4997
  h(""), x([]), y(-1), p(!1), r("");
4999
- }, k = (v) => {
5000
- h(v), p(!isEmpty(v)), c(!0), w(v);
4998
+ }, k = (w) => {
4999
+ h(w), p(!isEmpty(w)), c(!0), v(w);
5001
5000
  };
5002
5001
  return /* @__PURE__ */ jsxs("div", { children: [
5003
- /* @__PURE__ */ jsx("select", { name: "pageType", value: d, onChange: (v) => g(v.target.value), children: map(n, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
5004
- d && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
5002
+ /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (w) => g(w.target.value), children: map(n, (w) => /* @__PURE__ */ jsx("option", { value: w.key, children: w.name }, w.key)) }),
5003
+ u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
5005
5004
  /* @__PURE__ */ jsx(
5006
5005
  "input",
5007
5006
  {
5008
5007
  type: "text",
5009
5008
  value: m,
5010
- onChange: (v) => k(v.target.value),
5009
+ onChange: (w) => k(w.target.value),
5011
5010
  onKeyDown: B,
5012
- placeholder: a(`Search ${S ?? ""}`),
5011
+ placeholder: a(`Search ${C ?? ""}`),
5013
5012
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
5014
5013
  }
5015
5014
  ),
5016
5015
  /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: I, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" }) }) })
5017
5016
  ] }),
5018
- (i || !isEmpty(f) || u && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
5017
+ (i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
5019
5018
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
5020
5019
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
5021
- ] }) : u && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
5020
+ ] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
5022
5021
  a("No results found for"),
5023
5022
  ' "',
5024
5023
  m,
5025
5024
  '"'
5026
- ] }) : /* @__PURE__ */ jsx("ul", { ref: C, children: map(f == null ? void 0 : f.slice(0, 20), (v, E) => /* @__PURE__ */ jsxs(
5025
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: S, children: map(f == null ? void 0 : f.slice(0, 20), (w, E) => /* @__PURE__ */ jsxs(
5027
5026
  "li",
5028
5027
  {
5029
- onClick: () => _(v),
5030
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : E === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
5028
+ onClick: () => _(w),
5029
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(w.id) ? "bg-blue-200" : E === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
5031
5030
  children: [
5032
- v.name,
5031
+ w.name,
5033
5032
  " ",
5034
- v.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
5033
+ w.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
5035
5034
  "( ",
5036
- v.slug,
5035
+ w.slug,
5037
5036
  " )"
5038
5037
  ] })
5039
5038
  ]
5040
5039
  },
5041
- v.id
5040
+ w.id
5042
5041
  )) }) })
5043
5042
  ] });
5044
5043
  }, LinkField = ({ schema: o, formData: n, onChange: r, name: a }) => {
5045
- const { t: l } = useTranslation(), { type: i = "pageType", href: c = "", target: u = "self" } = n ?? {}, p = useBuilderProp("pageTypes", []), { selectedLang: d, fallbackLang: g, languages: m } = useLanguages(), h = useMemo(
5046
- () => isEmpty(m) ? "" : isEmpty(d) ? g : d,
5047
- [m, d, g]
5044
+ const { t: l } = useTranslation(), { type: i = "pageType", href: c = "", target: d = "self" } = n ?? {}, p = useBuilderProp("pageTypes", []), { selectedLang: u, fallbackLang: g, languages: m } = useLanguages(), h = useMemo(
5045
+ () => isEmpty(m) ? "" : isEmpty(u) ? g : u,
5046
+ [m, u, g]
5048
5047
  ), f = useMemo(() => get(LANGUAGES, h, h), [h]), x = i === "pageType" && isEmpty(p) ? "url" : i;
5049
5048
  return /* @__PURE__ */ jsxs("div", { children: [
5050
5049
  /* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between gap-x-2 text-xs font-medium", children: [
@@ -5107,9 +5106,9 @@ const DataBindingSelector = ({
5107
5106
  autoCorrect: "off",
5108
5107
  spellCheck: "false",
5109
5108
  type: "checkbox",
5110
- defaultChecked: u === "_blank",
5109
+ defaultChecked: d === "_blank",
5111
5110
  className: "!w-fit cursor-pointer rounded-md border border-border",
5112
- onChange: () => r({ ...n, target: u === "_blank" ? "_self" : "_blank" })
5111
+ onChange: () => r({ ...n, target: d === "_blank" ? "_self" : "_blank" })
5113
5112
  }
5114
5113
  ),
5115
5114
  /* @__PURE__ */ jsx("span", { className: "pt-1 text-xs", children: l("Open in new tab") })
@@ -5132,8 +5131,8 @@ const DataBindingSelector = ({
5132
5131
  ]
5133
5132
  }
5134
5133
  ) });
5135
- }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-DpWQvFjm.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
5136
- const c = useRef(null), [u, p] = useState(!1), d = useRTEditor({
5134
+ }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-DG4qh6_A.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
5135
+ const c = useRef(null), [d, p] = useState(!1), u = useRTEditor({
5137
5136
  blockId: o,
5138
5137
  value: a,
5139
5138
  placeholder: r,
@@ -5147,26 +5146,26 @@ const DataBindingSelector = ({
5147
5146
  }
5148
5147
  });
5149
5148
  useEffect(() => {
5150
- c.current && d && (c.current.__chaiRTE = d);
5151
- }, [o, d]);
5149
+ c.current && u && (c.current.__chaiRTE = u);
5150
+ }, [o, u]);
5152
5151
  const g = () => {
5153
5152
  p(!1);
5154
5153
  }, m = /* @__PURE__ */ jsxs("div", { id: `chai-rte-${n}`, ref: c, className: "mt-1 rounded-md border border-input", children: [
5155
- /* @__PURE__ */ jsx(RteMenubar, { editor: d, onExpand: () => p(!0) }),
5154
+ /* @__PURE__ */ jsx(RteMenubar, { editor: u, onExpand: () => p(!0) }),
5156
5155
  /* @__PURE__ */ jsx(
5157
5156
  EditorContent,
5158
5157
  {
5159
- editor: d,
5158
+ editor: u,
5160
5159
  id: n,
5161
5160
  placeholder: r,
5162
- className: `overflow-auto ${u ? "max-h-[500px] min-h-[400px]" : "max-h-[200px] min-h-[100px]"}`
5161
+ className: `overflow-auto ${d ? "max-h-[500px] min-h-[400px]" : "max-h-[200px] min-h-[100px]"}`
5163
5162
  },
5164
5163
  n
5165
5164
  )
5166
5165
  ] });
5167
5166
  return /* @__PURE__ */ jsxs(Fragment, { children: [
5168
- u && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(RTEModal, { isOpen: u, onClose: g, editor: d, rteElement: m }) }),
5169
- u ? /* @__PURE__ */ jsx("div", { children: "Open in modal" }) : /* @__PURE__ */ jsx("div", { className: "relative", children: m })
5167
+ d && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(RTEModal, { isOpen: d, onClose: g, editor: u, rteElement: m }) }),
5168
+ d ? /* @__PURE__ */ jsx("div", { children: "Open in modal" }) : /* @__PURE__ */ jsx("div", { className: "relative", children: m })
5170
5169
  ] });
5171
5170
  }, RichTextEditorField = (o) => {
5172
5171
  const { editingBlockId: n } = useInlineEditing(), [r, a] = useState(null), l = useSelectedBlock(), i = l == null ? void 0 : l._id;
@@ -5176,25 +5175,25 @@ const DataBindingSelector = ({
5176
5175
  }, SliderField = ({ formData: o, onChange: n }) => {
5177
5176
  const [r] = useBlocksStore(), a = useSelectedBlock(), l = useWrapperBlock(), { addCoreBlock: i } = useAddBlock(), [, c] = useSelectedBlockIds();
5178
5177
  if (!a && !l) return null;
5179
- const u = (a == null ? void 0 : a._type) === "Slider" ? a : l, p = find(r, { _parent: u == null ? void 0 : u._id, _type: "Slides" });
5178
+ const d = (a == null ? void 0 : a._type) === "Slider" ? a : l, p = find(r, { _parent: d == null ? void 0 : d._id, _type: "Slides" });
5180
5179
  if (!p) return null;
5181
- const d = filter(r, { _parent: p == null ? void 0 : p._id, _type: "Slide" }), g = (o == null ? void 0 : o.currentSlide) || get(d, "0._id");
5180
+ const u = filter(r, { _parent: p == null ? void 0 : p._id, _type: "Slide" }), g = (o == null ? void 0 : o.currentSlide) || get(u, "0._id");
5182
5181
  useEffect(() => {
5183
5182
  (a == null ? void 0 : a._type) === "Slide" && (o == null ? void 0 : o.currentSlide) !== (a == null ? void 0 : a._id) && n({ ...o, currentSlide: a == null ? void 0 : a._id });
5184
5183
  }, [a]), useEffect(() => {
5185
- d != null && d.length && !find(d, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(d, "0._id") });
5186
- }, [o, d]);
5184
+ u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
5185
+ }, [o, u]);
5187
5186
  const m = () => {
5188
- const x = findIndex(d, { _id: g });
5187
+ const x = findIndex(u, { _id: g });
5189
5188
  if (x > -1) {
5190
- const b = (x + 1) % d.length, y = get(d, [b, "_id"]);
5189
+ const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
5191
5190
  if (!y) return;
5192
5191
  n({ ...o, currentSlide: y }), c([y]);
5193
5192
  }
5194
5193
  }, h = () => {
5195
- const x = findIndex(d, { _id: g });
5194
+ const x = findIndex(u, { _id: g });
5196
5195
  if (x > -1) {
5197
- const b = (x - 1 + d.length) % d.length, y = get(d, [b, "_id"]);
5196
+ const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
5198
5197
  if (!y) return;
5199
5198
  n({ ...o, currentSlide: y }), c([y]);
5200
5199
  }
@@ -5211,10 +5210,10 @@ const DataBindingSelector = ({
5211
5210
  /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
5212
5211
  /* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
5213
5212
  " ",
5214
- findIndex(d, { _id: g }) + 1
5213
+ findIndex(u, { _id: g }) + 1
5215
5214
  ] }),
5216
5215
  "/",
5217
- d.length
5216
+ u.length
5218
5217
  ] }) : "-" }),
5219
5218
  /* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) }),
5220
5219
  /* @__PURE__ */ jsxs(
@@ -5291,15 +5290,15 @@ const DataBindingSelector = ({
5291
5290
  ] }) })
5292
5291
  ] });
5293
5292
  }, SourcesField = ({ formData: o, onChange: n }) => {
5294
- const r = get(o, "srcsets", []) || [], a = (c, u) => {
5295
- const p = c.target.name, d = c.target.value;
5293
+ const r = get(o, "srcsets", []) || [], a = (c, d) => {
5294
+ const p = c.target.name, u = c.target.value;
5296
5295
  n({
5297
- srcsets: map(r, (g, m) => m === u ? { ...g, [p]: d } : g)
5296
+ srcsets: map(r, (g, m) => m === d ? { ...g, [p]: u } : g)
5298
5297
  });
5299
5298
  }, l = () => {
5300
5299
  n({ srcsets: [...r, {}] });
5301
5300
  }, i = (c) => {
5302
- n({ srcsets: reject(r, (u, p) => p === c) });
5301
+ n({ srcsets: reject(r, (d, p) => p === c) });
5303
5302
  };
5304
5303
  return /* @__PURE__ */ jsxs("div", { children: [
5305
5304
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pb-2", children: [
@@ -5314,12 +5313,12 @@ const DataBindingSelector = ({
5314
5313
  }
5315
5314
  )
5316
5315
  ] }),
5317
- /* @__PURE__ */ jsx("div", { className: "space-y-2", children: r.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(r, (c, u) => /* @__PURE__ */ jsxs("div", { className: "group relative space-y-1.5 rounded border border-gray-200 px-2 pb-1.5", children: [
5316
+ /* @__PURE__ */ jsx("div", { className: "space-y-2", children: r.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(r, (c, d) => /* @__PURE__ */ jsxs("div", { className: "group relative space-y-1.5 rounded border border-gray-200 px-2 pb-1.5", children: [
5318
5317
  /* @__PURE__ */ jsx(
5319
5318
  "button",
5320
5319
  {
5321
5320
  type: "button",
5322
- onClick: () => i(u),
5321
+ onClick: () => i(d),
5323
5322
  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",
5324
5323
  children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-2.5 w-2.5 text-red-500" })
5325
5324
  }
@@ -5333,7 +5332,7 @@ const DataBindingSelector = ({
5333
5332
  placeholder: "Enter width (in px)",
5334
5333
  type: "number",
5335
5334
  value: get(c, "width"),
5336
- onChange: (p) => a(p, u),
5335
+ onChange: (p) => a(p, d),
5337
5336
  className: "!placeholder:text-gray-100 !mt-0 !rounded-none !border-0 !p-0 !text-xs"
5338
5337
  }
5339
5338
  )
@@ -5347,16 +5346,16 @@ const DataBindingSelector = ({
5347
5346
  placeholder: "Enter url",
5348
5347
  className: "!mt-0 !rounded-none !border-0 !p-0 !text-xs !shadow-none",
5349
5348
  value: get(c, "url", ""),
5350
- onChange: (p) => a(p, u)
5349
+ onChange: (p) => a(p, d)
5351
5350
  }
5352
5351
  )
5353
5352
  ] })
5354
- ] }, u)) })
5353
+ ] }, d)) })
5355
5354
  ] });
5356
5355
  }, CodeEditor = ({ id: o, placeholder: n }) => {
5357
5356
  const { t: r } = useTranslation(), [, a] = useCodeEditor(), l = useSelectedBlock();
5358
5357
  if (typeof window > "u") return null;
5359
- const i = o.replace("root.", ""), c = get(l, i, ""), u = () => {
5358
+ const i = o.replace("root.", ""), c = get(l, i, ""), d = () => {
5360
5359
  const p = l == null ? void 0 : l._id;
5361
5360
  a({ blockId: p, blockProp: i, placeholder: n, initialCode: get(l, i, c) });
5362
5361
  };
@@ -5364,35 +5363,35 @@ const DataBindingSelector = ({
5364
5363
  /* @__PURE__ */ jsx(
5365
5364
  "button",
5366
5365
  {
5367
- onClick: u,
5366
+ onClick: d,
5368
5367
  className: "w-[90%] max-w-full cursor-default truncate text-pretty rounded border border-border bg-background p-2 text-left text-[10px]",
5369
5368
  children: c.trim().length > 0 ? c.substring(0, 46) : n || "Eg: <script>console.log('Hello, world!');<\/script>"
5370
5369
  }
5371
5370
  ),
5372
- /* @__PURE__ */ jsx(Button, { onClick: u, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
5371
+ /* @__PURE__ */ jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
5373
5372
  ] });
5374
5373
  }, CollectionFilterSortField = ({ id: o, value: n, onChange: r, onBlur: a }) => {
5375
- const l = useBuilderProp("collections", []), i = useSelectedBlock(), c = get(i, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1").replace(COLLECTION_PREFIX, ""), u = find(l, { id: c }), d = get(u, o === "root.filter" ? "filters" : "sorts", []);
5374
+ const l = useBuilderProp("collections", []), i = useSelectedBlock(), c = get(i, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1").replace(COLLECTION_PREFIX, ""), d = find(l, { id: c }), u = get(d, o === "root.filter" ? "filters" : "sorts", []);
5376
5375
  return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("select", { value: n, onChange: (g) => r(g.target.value), onBlur: (g) => a(o, g.target.value), children: [
5377
5376
  /* @__PURE__ */ jsx("option", { value: "", children: "Select" }),
5378
- d.map((g) => /* @__PURE__ */ jsx("option", { value: g.id, children: g.name }, g.id))
5377
+ u.map((g) => /* @__PURE__ */ jsx("option", { value: g.id, children: g.name }, g.id))
5379
5378
  ] }) });
5380
5379
  }, JSONFormFieldTemplate = (o) => {
5381
- const { id: n, classNames: r, label: a, children: l, errors: i, help: c, hidden: u, required: p, schema: d, formData: g, onChange: m } = o, { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = useMemo(
5380
+ const { id: n, classNames: r, label: a, children: l, errors: i, help: c, hidden: d, required: p, schema: u, formData: g, onChange: m } = o, { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = useMemo(
5382
5381
  () => isEmpty(x) ? "" : isEmpty(h) ? f : h,
5383
5382
  [x, h, f]
5384
- ), y = useMemo(() => get(LANGUAGES, b, b), [b]), C = usePageExternalData(), S = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = useMemo(
5385
- () => get(w, [S == null ? void 0 : S._type, "i18nProps"], []),
5386
- [w, S == null ? void 0 : S._type]
5383
+ ), y = useMemo(() => get(LANGUAGES, b, b), [b]), S = usePageExternalData(), C = useSelectedBlock(), v = useRegisteredChaiBlocks(), _ = useMemo(
5384
+ () => get(v, [C == null ? void 0 : C._type, "i18nProps"], []),
5385
+ [v, C == null ? void 0 : C._type]
5387
5386
  ), [B, I] = useState(null);
5388
- if (u)
5387
+ if (d)
5389
5388
  return null;
5390
- if (d.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: l });
5389
+ if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: l });
5391
5390
  const A = _ == null ? void 0 : _.includes(n.replace("root.", ""));
5392
- if (d.type === "array") {
5391
+ if (u.type === "array") {
5393
5392
  const j = B === n;
5394
5393
  return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
5395
- d.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
5394
+ u.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
5396
5395
  "label",
5397
5396
  {
5398
5397
  htmlFor: n,
@@ -5404,7 +5403,7 @@ const DataBindingSelector = ({
5404
5403
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: a }),
5405
5404
  " ",
5406
5405
  /* @__PURE__ */ jsx(Badge, { className: "m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-slate-600", children: g == null ? void 0 : g.length }) }),
5407
- d.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5406
+ u.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5408
5407
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5409
5408
  InfoCircledIcon,
5410
5409
  {
@@ -5413,7 +5412,7 @@ const DataBindingSelector = ({
5413
5412
  onMouseDown: (N) => N.stopPropagation()
5414
5413
  }
5415
5414
  ) }),
5416
- /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: d.description })
5415
+ /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: u.description })
5417
5416
  ] }) })
5418
5417
  ]
5419
5418
  }
@@ -5425,25 +5424,25 @@ const DataBindingSelector = ({
5425
5424
  ] })
5426
5425
  ] });
5427
5426
  }
5428
- const v = n.replace("root.", ""), E = _.includes(v) && !isEmpty(h) && isEmpty(g);
5427
+ const w = n.replace("root.", ""), E = _.includes(w) && !isEmpty(h) && isEmpty(g);
5429
5428
  return /* @__PURE__ */ jsxs("div", { className: r, children: [
5430
- d.title && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
5429
+ u.title && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
5431
5430
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
5432
- /* @__PURE__ */ jsxs("label", { htmlFor: n, className: d.type === "object" ? "pb-2" : "", children: [
5431
+ /* @__PURE__ */ jsxs("label", { htmlFor: n, className: u.type === "object" ? "pb-2" : "", children: [
5433
5432
  a,
5434
5433
  " ",
5435
5434
  A && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5436
5435
  " ",
5437
5436
  y
5438
5437
  ] }),
5439
- p && d.type !== "object" ? " *" : null
5438
+ p && u.type !== "object" ? " *" : null
5440
5439
  ] }),
5441
- d.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5440
+ u.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5442
5441
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(InfoCircledIcon, { className: "h-3 w-3 text-muted-foreground/70" }) }),
5443
- /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: d.description })
5442
+ /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: u.description })
5444
5443
  ] }) })
5445
5444
  ] }),
5446
- !d.enum && !d.oneOf && C && /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-1", children: [
5445
+ !u.enum && !u.oneOf && S && /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-1", children: [
5447
5446
  E ? /* @__PURE__ */ jsxs(Tooltip, { children: [
5448
5447
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
5449
5448
  "svg",
@@ -5474,7 +5473,7 @@ const DataBindingSelector = ({
5474
5473
  /* @__PURE__ */ jsx(
5475
5474
  DataBindingSelector,
5476
5475
  {
5477
- schema: d,
5476
+ schema: u,
5478
5477
  onChange: (j) => {
5479
5478
  m(j, g, n);
5480
5479
  },
@@ -5525,7 +5524,7 @@ const DataBindingSelector = ({
5525
5524
  " ",
5526
5525
  /* @__PURE__ */ jsx("span", { children: "Add" })
5527
5526
  ] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
5528
- const { selectedLang: i } = useLanguages(), c = useBlockSettingComponents("widget"), u = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), d = useThrottledCallback(
5527
+ const { selectedLang: i } = useLanguages(), c = useBlockSettingComponents("widget"), d = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
5529
5528
  async ({ formData: g }, m) => {
5530
5529
  get(g, m) === void 0 && set(g, m, ""), l({ formData: g }, m);
5531
5530
  },
@@ -5550,7 +5549,7 @@ const DataBindingSelector = ({
5550
5549
  link: LinkField,
5551
5550
  slider: SliderField,
5552
5551
  sources: SourcesField,
5553
- ...u
5552
+ ...d
5554
5553
  },
5555
5554
  templates: {
5556
5555
  FieldTemplate: JSONFormFieldTemplate,
@@ -5571,7 +5570,7 @@ const DataBindingSelector = ({
5571
5570
  onChange: ({ formData: g }, m) => {
5572
5571
  if (!m || o !== (g == null ? void 0 : g._id)) return;
5573
5572
  const h = take(m.split("."), 2).join(".").replace("root.", "");
5574
- d({ formData: g }, h);
5573
+ u({ formData: g }, h);
5575
5574
  }
5576
5575
  },
5577
5576
  i
@@ -5583,18 +5582,18 @@ const DataBindingSelector = ({
5583
5582
  }), a;
5584
5583
  };
5585
5584
  function BlockSettings() {
5586
- const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, u] = useState(i), [p, d] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), f = ({ formData: B }, I, k) => {
5585
+ const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), f = ({ formData: B }, I, k) => {
5587
5586
  I && (c == null ? void 0 : c._id) === n._id && a([n._id], { [I]: get(B, I) }, k);
5588
5587
  }, x = useCallback(
5589
5588
  debounce(({ formData: B }, I, k) => {
5590
- f({ formData: B }, I, k), u(B);
5589
+ f({ formData: B }, I, k), d(B);
5591
5590
  }, 1500),
5592
5591
  [n == null ? void 0 : n._id, o]
5593
5592
  ), b = ({ formData: B }, I) => {
5594
5593
  I && (r([n._id], { [I]: get(B, I) }), x({ formData: B }, I, { [I]: get(c, I) }));
5595
5594
  }, y = ({ formData: B }, I) => {
5596
5595
  I && (r([g._id], { [I]: get(B, I) }), x({ formData: B }, I, { [I]: get(c, I) }));
5597
- }, { schema: C, uiSchema: S } = useMemo(() => {
5596
+ }, { schema: S, uiSchema: C } = useMemo(() => {
5598
5597
  const B = n == null ? void 0 : n._type;
5599
5598
  if (!B)
5600
5599
  return { schema: {}, uiSchema: {} };
@@ -5608,7 +5607,7 @@ function BlockSettings() {
5608
5607
  } catch {
5609
5608
  return { schema: {}, uiSchema: {} };
5610
5609
  }
5611
- }, [n]), { wrapperSchema: w, wrapperUiSchema: _ } = useMemo(() => {
5610
+ }, [n]), { wrapperSchema: v, wrapperUiSchema: _ } = useMemo(() => {
5612
5611
  if (!g || !(g != null && g._type))
5613
5612
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5614
5613
  const B = g == null ? void 0 : g._type, { schema: I = {}, uiSchema: k = {} } = getBlockFormSchemas(B);
@@ -5619,7 +5618,7 @@ function BlockSettings() {
5619
5618
  /* @__PURE__ */ jsxs(
5620
5619
  "div",
5621
5620
  {
5622
- onClick: () => d((B) => !B),
5621
+ onClick: () => u((B) => !B),
5623
5622
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5624
5623
  children: [
5625
5624
  p ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-4 w-4 text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 text-slate-400" }),
@@ -5640,19 +5639,19 @@ function BlockSettings() {
5640
5639
  blockId: g == null ? void 0 : g._id,
5641
5640
  onChange: y,
5642
5641
  formData: h,
5643
- schema: w,
5642
+ schema: v,
5644
5643
  uiSchema: _
5645
5644
  }
5646
5645
  ) })
5647
5646
  ] }),
5648
- isEmpty(C) ? null : /* @__PURE__ */ jsx(
5647
+ isEmpty(S) ? null : /* @__PURE__ */ jsx(
5649
5648
  JSONForm,
5650
5649
  {
5651
5650
  blockId: n == null ? void 0 : n._id,
5652
5651
  onChange: b,
5653
5652
  formData: i,
5654
- schema: C,
5655
- uiSchema: S
5653
+ schema: S,
5654
+ uiSchema: C
5656
5655
  }
5657
5656
  )
5658
5657
  ] });
@@ -5663,7 +5662,7 @@ const BlockStylingProps = () => {
5663
5662
  if (!o) return null;
5664
5663
  const c = Object.keys(o).filter(
5665
5664
  (x) => typeof o[x] == "string" && o[x].startsWith("#styles:")
5666
- ), { reset: u } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, d = get(o, (f = n[0]) == null ? void 0 : f.prop, ""), { classes: g = "" } = getSplitChaiClasses(d) || {}, m = g ? g.split(" ").filter((x) => !isEmpty(x)) : [], h = (x) => find(n, (b) => b.prop === x);
5665
+ ), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (f = n[0]) == null ? void 0 : f.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, m = g ? g.split(" ").filter((x) => !isEmpty(x)) : [], h = (x) => find(n, (b) => b.prop === x);
5667
5666
  return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
5668
5667
  /* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
5669
5668
  i("Style element"),
@@ -5695,7 +5694,7 @@ const BlockStylingProps = () => {
5695
5694
  {
5696
5695
  className: "text-xs",
5697
5696
  onClick: () => {
5698
- u(x);
5697
+ d(x);
5699
5698
  },
5700
5699
  children: i("Reset style")
5701
5700
  }
@@ -5827,13 +5826,13 @@ const BlockStylingProps = () => {
5827
5826
  negative: i,
5828
5827
  cssProperty: c
5829
5828
  }) => {
5830
- const { setDragData: u } = useContext(BlockSettingsContext);
5829
+ const { setDragData: d } = useContext(BlockSettingsContext);
5831
5830
  return /* @__PURE__ */ jsx(
5832
5831
  "button",
5833
5832
  {
5834
5833
  type: "button",
5835
5834
  onMouseDown: (p) => {
5836
- const d = {
5835
+ const u = {
5837
5836
  onDrag: r,
5838
5837
  onDragEnd: a,
5839
5838
  dragging: !0,
@@ -5843,7 +5842,7 @@ const BlockStylingProps = () => {
5843
5842
  negative: i,
5844
5843
  cssProperty: c
5845
5844
  };
5846
- l(d), u(d);
5845
+ l(u), d(u);
5847
5846
  },
5848
5847
  color: void 0,
5849
5848
  className: "relative z-50 ml-1 hidden h-6 cursor-row-resize rounded bg-background/70 px-2 group-hover:inline",
@@ -5863,50 +5862,50 @@ const BlockStylingProps = () => {
5863
5862
  },
5864
5863
  a
5865
5864
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5866
- const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: u, cssProperty: p, units: d, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : d[0]), [f, x] = useState(!1), [b, y] = useState(""), [C, S] = useState(!1), [w, _] = useState(!1);
5865
+ const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [b, y] = useState(""), [S, C] = useState(!1), [v, _] = useState(!1);
5867
5866
  useEffect(() => {
5868
- const { value: v, unit: E } = getClassValueAndUnit(i);
5867
+ const { value: w, unit: E } = getClassValueAndUnit(i);
5869
5868
  if (E === "") {
5870
- l(v), h(p != null && p.toLowerCase().includes("width") ? "%" : first(d));
5869
+ l(w), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5871
5870
  return;
5872
5871
  }
5873
- h(E), l(E === "class" || isEmpty(v) ? "" : v);
5874
- }, [i, p, d]);
5875
- const B = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), I = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), k = useCallback(
5876
- (v = !1) => {
5877
- const E = getUserInputValues(`${a}`, d);
5872
+ h(E), l(E === "class" || isEmpty(w) ? "" : w);
5873
+ }, [i, p, u]);
5874
+ const B = useThrottledCallback((w) => c(w), [c], THROTTLE_TIME), I = useThrottledCallback((w) => c(w, !1), [c], THROTTLE_TIME), k = useCallback(
5875
+ (w = !1) => {
5876
+ const E = getUserInputValues(`${a}`, u);
5878
5877
  if (get(E, "error", !1)) {
5879
5878
  x(!0);
5880
5879
  return;
5881
5880
  }
5882
5881
  const j = get(E, "unit") !== "" ? get(E, "unit") : m;
5883
5882
  if (j === "auto" || j === "none") {
5884
- B(`${u}${j}`);
5883
+ B(`${d}${j}`);
5885
5884
  return;
5886
5885
  }
5887
5886
  if (get(E, "value") === "")
5888
5887
  return;
5889
- const T = `${get(E, "value", "").startsWith("-") ? "-" : ""}${u}[${get(E, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5890
- v ? I(T) : B(T);
5888
+ const T = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5889
+ w ? I(T) : B(T);
5891
5890
  },
5892
- [B, I, a, m, u, d]
5891
+ [B, I, a, m, d, u]
5893
5892
  ), A = useCallback(
5894
- (v) => {
5895
- const E = getUserInputValues(`${a}`, d);
5893
+ (w) => {
5894
+ const E = getUserInputValues(`${a}`, u);
5896
5895
  if (get(E, "error", !1)) {
5897
5896
  x(!0);
5898
5897
  return;
5899
5898
  }
5900
- if (v === "auto" || v === "none") {
5901
- B(`${u}${v}`);
5899
+ if (w === "auto" || w === "none") {
5900
+ B(`${d}${w}`);
5902
5901
  return;
5903
5902
  }
5904
5903
  if (get(E, "value") === "")
5905
5904
  return;
5906
- const j = get(E, "unit") !== "" ? get(E, "unit") : v, T = `${get(E, "value", "").startsWith("-") ? "-" : ""}${u}[${get(E, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5905
+ const j = get(E, "unit") !== "" ? get(E, "unit") : w, T = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5907
5906
  B(T);
5908
5907
  },
5909
- [B, a, u, d]
5908
+ [B, a, d, u]
5910
5909
  );
5911
5910
  return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5912
5911
  /* @__PURE__ */ jsx(
@@ -5921,37 +5920,37 @@ const BlockStylingProps = () => {
5921
5920
  /* @__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, {}) }) }),
5922
5921
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
5923
5922
  ] })
5924
- ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${C ? "z-auto" : ""}`, children: [
5923
+ ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${S ? "z-auto" : ""}`, children: [
5925
5924
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
5926
5925
  ["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
5927
5926
  "input",
5928
5927
  {
5929
5928
  readOnly: m === "class",
5930
- onKeyPress: (v) => {
5931
- v.key === "Enter" && k();
5929
+ onKeyPress: (w) => {
5930
+ w.key === "Enter" && k();
5932
5931
  },
5933
- onKeyDown: (v) => {
5934
- if (v.keyCode !== 38 && v.keyCode !== 40)
5932
+ onKeyDown: (w) => {
5933
+ if (w.keyCode !== 38 && w.keyCode !== 40)
5935
5934
  return;
5936
- v.preventDefault(), _(!0);
5937
- const E = parseInt$1(v.target.value);
5935
+ w.preventDefault(), _(!0);
5936
+ const E = parseInt$1(w.target.value);
5938
5937
  let j = isNaN$1(E) ? 0 : E;
5939
- v.keyCode === 38 && (j += 1), v.keyCode === 40 && (j -= 1);
5940
- const N = `${j}`, P = `${N.startsWith("-") ? "-" : ""}${u}[${N.replace("-", "")}${m === "-" ? "" : m}]`;
5938
+ w.keyCode === 38 && (j += 1), w.keyCode === 40 && (j -= 1);
5939
+ const N = `${j}`, P = `${N.startsWith("-") ? "-" : ""}${d}[${N.replace("-", "")}${m === "-" ? "" : m}]`;
5941
5940
  I(P);
5942
5941
  },
5943
- onKeyUp: (v) => {
5944
- w && (v.preventDefault(), _(!1));
5942
+ onKeyUp: (w) => {
5943
+ v && (w.preventDefault(), _(!1));
5945
5944
  },
5946
5945
  onBlur: () => k(),
5947
- onChange: (v) => {
5948
- x(!1), l(v.target.value);
5946
+ onChange: (w) => {
5947
+ x(!1), l(w.target.value);
5949
5948
  },
5950
- onClick: (v) => {
5949
+ onClick: (w) => {
5951
5950
  var E;
5952
- (E = v == null ? void 0 : v.target) == null || E.select(), r(!1);
5951
+ (E = w == null ? void 0 : w.target) == null || E.select(), r(!1);
5953
5952
  },
5954
- value: C ? b : a,
5953
+ value: S ? b : a,
5955
5954
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
5956
5955
  " ",
5957
5956
  f ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -5966,38 +5965,38 @@ const BlockStylingProps = () => {
5966
5965
  onClick: () => r(!n),
5967
5966
  className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
5968
5967
  children: [
5969
- /* @__PURE__ */ jsx("span", { className: `inline-block ${d.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
5970
- d.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
5968
+ /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
5969
+ u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
5971
5970
  ]
5972
5971
  }
5973
5972
  ) }),
5974
5973
  /* @__PURE__ */ jsx(TooltipContent, { className: "bg-background", children: /* @__PURE__ */ jsx(
5975
5974
  UnitSelection,
5976
5975
  {
5977
- units: d,
5976
+ units: u,
5978
5977
  current: m,
5979
- onSelect: (v) => {
5980
- r(!1), h(v), A(v);
5978
+ onSelect: (w) => {
5979
+ r(!1), h(w), A(w);
5981
5980
  }
5982
5981
  }
5983
5982
  ) })
5984
5983
  ] })
5985
5984
  ] }),
5986
- ["none", "auto"].indexOf(m) !== -1 || C ? null : /* @__PURE__ */ jsx(
5985
+ ["none", "auto"].indexOf(m) !== -1 || S ? null : /* @__PURE__ */ jsx(
5987
5986
  DragStyleButton,
5988
5987
  {
5989
- onDragStart: () => S(!0),
5990
- onDragEnd: (v) => {
5991
- if (y(() => ""), S(!1), isEmpty(v))
5988
+ onDragStart: () => C(!0),
5989
+ onDragEnd: (w) => {
5990
+ if (y(() => ""), C(!1), isEmpty(w))
5992
5991
  return;
5993
- const E = `${v}`, N = `${E.startsWith("-") ? "-" : ""}${u}[${E.replace("-", "")}${m === "-" ? "" : m}]`;
5992
+ const E = `${w}`, N = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${m === "-" ? "" : m}]`;
5994
5993
  B(N);
5995
5994
  },
5996
- onDrag: (v) => {
5997
- if (isEmpty(v))
5995
+ onDrag: (w) => {
5996
+ if (isEmpty(w))
5998
5997
  return;
5999
- y(v);
6000
- const E = `${v}`, N = `${E.startsWith("-") ? "-" : ""}${u}[${E.replace("-", "")}${m === "-" ? "" : m}]`;
5998
+ y(w);
5999
+ const E = `${w}`, N = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${m === "-" ? "" : m}]`;
6001
6000
  I(N);
6002
6001
  },
6003
6002
  currentValue: a,
@@ -6011,7 +6010,7 @@ const BlockStylingProps = () => {
6011
6010
  // eslint-disable-next-line react/jsx-no-constructed-context-values
6012
6011
  /* @__PURE__ */ jsx(StyleContext.Provider, { value: { canReset: n, canChange: r }, children: o })
6013
6012
  ), DropDownChoices = ({ label: o, property: n, onChange: r }) => {
6014
- const { getClasses: a } = useTailwindClassList(), l = a(n), i = useCurrentClassByProperty(n), c = useMemo(() => get(i, "cls", ""), [i]), { canChange: u } = useContext(StyleContext), p = /\[.*\]/g.test(c);
6013
+ const { getClasses: a } = useTailwindClassList(), l = a(n), i = useCurrentClassByProperty(n), c = useMemo(() => get(i, "cls", ""), [i]), { canChange: d } = useContext(StyleContext), p = /\[.*\]/g.test(c);
6015
6014
  return /* @__PURE__ */ jsx("div", { className: o ? "w-full rounded" : "grow", children: p ? /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
6016
6015
  /* @__PURE__ */ jsx(Input$1, { className: "w-[70%] rounded py-1", readOnly: !0, value: c }),
6017
6016
  /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
@@ -6022,15 +6021,15 @@ const BlockStylingProps = () => {
6022
6021
  DropDown,
6023
6022
  {
6024
6023
  rounded: o,
6025
- onChange: (d) => r(d, n),
6024
+ onChange: (u) => r(u, n),
6026
6025
  selected: c,
6027
6026
  options: l,
6028
- disabled: !u
6027
+ disabled: !d
6029
6028
  }
6030
6029
  ) });
6031
6030
  };
6032
6031
  function DropDown({ selected: o, onChange: n, rounded: r = !1, options: a, disabled: l = !1 }) {
6033
- const i = o.replace(/.*:/g, "").trim(), { undo: c, redo: u } = useUndoManager();
6032
+ const i = o.replace(/.*:/g, "").trim(), { undo: c, redo: d } = useUndoManager();
6034
6033
  return /* @__PURE__ */ jsxs(
6035
6034
  "select",
6036
6035
  {
@@ -6038,12 +6037,12 @@ function DropDown({ selected: o, onChange: n, rounded: r = !1, options: a, disab
6038
6037
  className: `${r ? "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`,
6039
6038
  onChange: (p) => n(p.target.value),
6040
6039
  onKeyDown: (p) => {
6041
- p.ctrlKey && (p.key === "z" && c(), p.key === "y" && u());
6040
+ p.ctrlKey && (p.key === "z" && c(), p.key === "y" && d());
6042
6041
  },
6043
6042
  value: i,
6044
6043
  children: [
6045
6044
  /* @__PURE__ */ jsx("option", { className: "bg-transparent", value: "" }),
6046
- a.map((p, d) => /* @__PURE__ */ jsx("option", { className: "bg-transparent", value: p, children: p }, `option-${d}`))
6045
+ a.map((p, u) => /* @__PURE__ */ jsx("option", { className: "bg-transparent", value: p, children: p }, `option-${u}`))
6047
6046
  ]
6048
6047
  }
6049
6048
  );
@@ -6061,7 +6060,7 @@ const COLOR_PROP = {
6061
6060
  ringColor: "ring",
6062
6061
  ringOffsetColor: "ring-offset"
6063
6062
  }, ColorChoice = ({ property: o, onChange: n }) => {
6064
- const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [u, p] = useState({ color: "", shade: "" }), d = a.split("-"), g = get(d, "1", ""), m = get(d, "2", ""), h = useCallback(
6063
+ const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""), h = useCallback(
6065
6064
  // eslint-disable-next-line no-shadow
6066
6065
  (b) => {
6067
6066
  ["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: b, shade: y.shade ? y.shade : "500" })));
@@ -6085,9 +6084,9 @@ const COLOR_PROP = {
6085
6084
  }, [r]);
6086
6085
  const { match: x } = useTailwindClassList();
6087
6086
  return useEffect(() => {
6088
- const y = `${get(COLOR_PROP, o, "")}-${u.color}${u.shade ? `-${u.shade}` : ""}`;
6087
+ const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6089
6088
  x(o, y) && n(y, o);
6090
- }, [x, u, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
6089
+ }, [x, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
6091
6090
  /* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
6092
6091
  DropDown,
6093
6092
  {
@@ -6325,29 +6324,29 @@ const COLOR_PROP = {
6325
6324
  static: Cross1Icon
6326
6325
  }, IconChoices = ({ property: o, onChange: n }) => {
6327
6326
  const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
6328
- return /* @__PURE__ */ jsx("div", { className: "flex grow flex-wrap gap-1", children: map(a, (u) => /* @__PURE__ */ jsxs(Tooltip, { children: [
6327
+ return /* @__PURE__ */ jsx("div", { className: "flex grow flex-wrap gap-1", children: map(a, (d) => /* @__PURE__ */ jsxs(Tooltip, { children: [
6329
6328
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6330
6329
  "button",
6331
6330
  {
6332
6331
  type: "button",
6333
6332
  disabled: !l,
6334
- onClick: () => n(u, o),
6335
- className: `cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${c === u ? "bg-primary text-white" : "disabled:bg-gray-600 disabled:text-gray-400"}`,
6336
- children: React__default.createElement(get(EDITOR_ICONS, u, BoxIcon))
6333
+ onClick: () => n(d, o),
6334
+ 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"}`,
6335
+ children: React__default.createElement(get(EDITOR_ICONS, d, BoxIcon))
6337
6336
  }
6338
6337
  ) }),
6339
- /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(u)) })
6338
+ /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(d)) })
6340
6339
  ] })) });
6341
6340
  }, RangeChoices = ({ property: o, onChange: n }) => {
6342
- const { canReset: r, canChange: a } = useContext(StyleContext), l = useCurrentClassByProperty(o), i = useMemo(() => get(l, "cls", ""), [l]), { getClasses: c } = useTailwindClassList(), u = c(o, [""]), p = u.indexOf(i) > -1 ? u.indexOf(i) : 0, d = /\[.*\]/g.test(i);
6343
- return /* @__PURE__ */ jsx("div", { className: "flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs", children: d ? /* @__PURE__ */ jsx("div", { className: "px-2 py-[5px]", children: i }) : /* @__PURE__ */ jsxs(Fragment, { children: [
6341
+ const { canReset: r, 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);
6342
+ 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: [
6344
6343
  /* @__PURE__ */ jsx(
6345
6344
  "button",
6346
6345
  {
6347
6346
  type: "button",
6348
6347
  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",
6349
6348
  disabled: !a && (!r || p - 1 < 0),
6350
- onClick: () => n(nth(u, p - 1), o),
6349
+ onClick: () => n(nth(d, p - 1), o),
6351
6350
  children: /* @__PURE__ */ jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
6352
6351
  MinusIcon,
6353
6352
  {
@@ -6362,12 +6361,12 @@ const COLOR_PROP = {
6362
6361
  {
6363
6362
  type: "button",
6364
6363
  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",
6365
- disabled: !a && (!r || p + 1 >= u.length),
6366
- onClick: () => n(nth(u, p + 1), o),
6364
+ disabled: !a && (!r || p + 1 >= d.length),
6365
+ onClick: () => n(nth(d, p + 1), o),
6367
6366
  children: /* @__PURE__ */ jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
6368
6367
  PlusIcon,
6369
6368
  {
6370
- className: !a && (!r || p + 1 >= u.length) ? "text-gray-500" : "text-black/60 dark:text-white/60"
6369
+ className: !a && (!r || p + 1 >= d.length) ? "text-gray-500" : "text-black/60 dark:text-white/60"
6371
6370
  }
6372
6371
  ) })
6373
6372
  }
@@ -6461,23 +6460,23 @@ const COLOR_PROP = {
6461
6460
  "2xl": "1536px"
6462
6461
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6463
6462
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
6464
- }, units: c, negative: u = !1 } = o, [p] = useDarkMode(), [d] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
6463
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
6465
6464
  (I, k = !0) => {
6466
- const A = { dark: p, mq: g, mod: d, cls: I, property: l, fullCls: "" };
6467
- (p || d !== "") && (A.mq = "xs");
6468
- const v = generateFullClsName(A);
6469
- h(x, [v], k);
6465
+ const A = { dark: p, mq: g, mod: u, cls: I, property: l, fullCls: "" };
6466
+ (p || u !== "") && (A.mq = "xs");
6467
+ const w = generateFullClsName(A);
6468
+ h(x, [w], k);
6470
6469
  },
6471
- [x, p, g, d, l, h]
6472
- ), C = useCallback(() => {
6470
+ [x, p, g, u, l, h]
6471
+ ), S = useCallback(() => {
6473
6472
  f(x, [b], !0);
6474
- }, [x, b, f]), S = useMemo(() => canChangeClass(m, g), [m, g]);
6473
+ }, [x, b, f]), C = useMemo(() => canChangeClass(m, g), [m, g]);
6475
6474
  useEffect(() => {
6476
- i(S, m);
6477
- }, [S, i, m]);
6478
- const [, , w] = useScreenSizeWidth(), _ = useCallback(
6475
+ i(C, m);
6476
+ }, [C, i, m]);
6477
+ const [, , v] = useScreenSizeWidth(), _ = useCallback(
6479
6478
  (I) => {
6480
- w({
6479
+ v({
6481
6480
  xs: 400,
6482
6481
  sm: 640,
6483
6482
  md: 800,
@@ -6486,9 +6485,9 @@ const COLOR_PROP = {
6486
6485
  "2xl": 1920
6487
6486
  }[I]);
6488
6487
  },
6489
- [w]
6490
- ), B = get(m, "dark", null) === p && get(m, "mod", null) === d && get(m, "mq", null) === g;
6491
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: S, canReset: m && B, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6488
+ [v]
6489
+ ), B = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6490
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: C, canReset: m && B, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6492
6491
  /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !B ? "text-foreground" : ""}`, children: n(a) }) }),
6493
6492
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6494
6493
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
@@ -6499,7 +6498,7 @@ const COLOR_PROP = {
6499
6498
  classPrefix: get(CLASS_PREFIXES, l, ""),
6500
6499
  units: c || [],
6501
6500
  onChange: y,
6502
- negative: u,
6501
+ negative: d,
6503
6502
  cssProperty: l
6504
6503
  }
6505
6504
  ) : null,
@@ -6508,7 +6507,7 @@ const COLOR_PROP = {
6508
6507
  r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
6509
6508
  r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
6510
6509
  ] }),
6511
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: B ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => C(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : S && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6510
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: B ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => S(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : C && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6512
6511
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6513
6512
  "button",
6514
6513
  {
@@ -6549,20 +6548,20 @@ const COLOR_PROP = {
6549
6548
  units: i = basicUnits,
6550
6549
  negative: c = !1
6551
6550
  }) => {
6552
- const { t: u } = useTranslation(), [p, d] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((h) => map(g, "property").includes(h), [g]);
6551
+ const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((h) => map(g, "property").includes(h), [g]);
6553
6552
  return /* @__PURE__ */ jsxs(
6554
6553
  "div",
6555
6554
  {
6556
6555
  className: `mb-2 border-border py-2 first:pt-0 last:pb-0 ${r ? "border-b" : ""} ${a ? "border-t" : ""}`,
6557
6556
  children: [
6558
6557
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
6559
- o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: u(o) }),
6558
+ o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
6560
6559
  /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: h, key: f }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6561
6560
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6562
6561
  "button",
6563
6562
  {
6564
6563
  type: "button",
6565
- onClick: () => d(f),
6564
+ onClick: () => u(f),
6566
6565
  className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6567
6566
  children: [
6568
6567
  React__default.createElement("div", {
@@ -6591,11 +6590,11 @@ const COLOR_PROP = {
6591
6590
  }, NestedOptions = ({ heading: o, items: n }) => {
6592
6591
  const { t: r } = useTranslation(), a = useSelectedBlockCurrentClasses(), l = useMemo(() => {
6593
6592
  const i = (p) => flatten(
6594
- p.map((d) => d.styleType === "multiple" ? map(d.options, "key") : d.property)
6593
+ p.map((u) => u.styleType === "multiple" ? map(u.options, "key") : u.property)
6595
6594
  ), c = flatten(
6596
6595
  n.map((p) => p.styleType === "accordion" ? i(p.items) : p.styleType === "multiple" ? map(p.options, "key") : p.property)
6597
- ), u = map(a, "property");
6598
- return intersection(c, u).length > 0;
6596
+ ), d = map(a, "property");
6597
+ return intersection(c, d).length > 0;
6599
6598
  }, [a, n]);
6600
6599
  return /* @__PURE__ */ jsxs("details", { children: [
6601
6600
  /* @__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: [
@@ -6612,12 +6611,12 @@ const COLOR_PROP = {
6612
6611
  }, SectionContext = createContext({}), StylingGroup = ({ section: o, showAccordian: n }) => {
6613
6612
  const { t: r } = useTranslation(), a = useSelectedBlockCurrentClasses(), l = useCallback(
6614
6613
  (c = []) => {
6615
- const u = {};
6616
- for (let d = 0; d < a.length; d++)
6617
- u[a[d].property] = a[d].cls;
6614
+ const d = {};
6615
+ for (let u = 0; u < a.length; u++)
6616
+ d[a[u].property] = a[u].cls;
6618
6617
  let p = !0;
6619
- for (const d in c)
6620
- if (!has(u, d) || u[d] !== c[d]) {
6618
+ for (const u in c)
6619
+ if (!has(d, u) || d[u] !== c[u]) {
6621
6620
  p = !1;
6622
6621
  break;
6623
6622
  }
@@ -6628,7 +6627,7 @@ const COLOR_PROP = {
6628
6627
  return /* @__PURE__ */ jsx(SectionContext.Provider, { value: i, children: n ? /* @__PURE__ */ jsxs(AccordionItem, { value: o.heading, className: "border-none", children: [
6629
6628
  /* @__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(r(o.heading)) }) }) }),
6630
6629
  /* @__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")) })
6631
- ] }) : /* @__PURE__ */ jsx("div", { className: "py-2", children: o.items.map((c, u) => 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" + u) : c.styleType === "accordion" && l(c == null ? void 0 : c.conditions) ? /* @__PURE__ */ jsx(NestedOptions, { ...c }, c.label + "nested-options" + u) : null : /* @__PURE__ */ jsx(BlockStyle, { ...c }, c.label + "block-style" + u)) }) });
6630
+ ] }) : /* @__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)) }) });
6632
6631
  }, TabletIcon = ({ landscape: o = !1, className: n = "" }) => /* @__PURE__ */ jsx(
6633
6632
  "svg",
6634
6633
  {
@@ -6691,30 +6690,32 @@ const COLOR_PROP = {
6691
6690
  content: l,
6692
6691
  currentBreakpoint: i,
6693
6692
  breakpoint: c,
6694
- width: u,
6693
+ width: d,
6695
6694
  icon: p,
6696
- onClick: d
6695
+ onClick: u,
6696
+ buttonClass: g = "",
6697
+ activeButtonClass: m = ""
6697
6698
  }) => {
6698
- const { t: g } = useTranslation();
6699
+ const { t: h } = useTranslation();
6699
6700
  return r ? /* @__PURE__ */ jsxs(HoverCard, { openDelay: n, children: [
6700
6701
  /* @__PURE__ */ jsx(HoverCardTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6701
6702
  Button,
6702
6703
  {
6703
- onClick: () => d(u),
6704
+ onClick: () => u(d),
6704
6705
  size: "sm",
6705
- className: "h-7 w-7 rounded-md p-1",
6706
+ className: cn$1("h-7 w-7 rounded-md p-1", c === i ? m : g),
6706
6707
  variant: c === i ? "outline" : "ghost",
6707
6708
  children: p
6708
6709
  }
6709
6710
  ) }),
6710
6711
  /* @__PURE__ */ jsx(HoverCardContent, { className: "w-fit max-w-52 border-border", children: /* @__PURE__ */ jsx("div", { className: "flex justify-between space-x-4", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
6711
- /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: g(a) }),
6712
- o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: g(l) })
6712
+ /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: h(a) }),
6713
+ o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: h(l) })
6713
6714
  ] }) }) })
6714
6715
  ] }) : /* @__PURE__ */ jsx(
6715
6716
  Button,
6716
6717
  {
6717
- onClick: () => d(u),
6718
+ onClick: () => u(d),
6718
6719
  size: "sm",
6719
6720
  className: "h-7 w-7 rounded-md p-1",
6720
6721
  variant: c === i ? "outline" : "ghost",
@@ -6724,53 +6725,57 @@ const COLOR_PROP = {
6724
6725
  }, Breakpoints$1 = ({
6725
6726
  openDelay: o = 400,
6726
6727
  canvas: n = !1,
6727
- tooltip: r = !0
6728
+ tooltip: r = !0,
6729
+ buttonClass: a = "",
6730
+ activeButtonClass: l = ""
6728
6731
  }) => {
6729
- const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [u, p] = useSelectedBreakpoints(), d = u, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (y) => {
6730
- d.includes(y) ? d.length > 2 && g(d.filter((C) => C !== y)) : g((C) => [...C, y]);
6731
- }, x = (y) => {
6732
- n || l(y), c(y);
6733
- }, b = getBreakpointValue(n ? i : a).toLowerCase();
6734
- return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (y) => /* @__PURE__ */ createElement(
6732
+ const [i, , c] = useScreenSizeWidth(), [d, p] = useCanvasDisplayWidth(), [u, g] = useSelectedBreakpoints(), m = u, h = g, { t: f } = useTranslation(), x = useBuilderProp("breakpoints", WEB_BREAKPOINTS), b = (C) => {
6733
+ m.includes(C) ? m.length > 2 && h(m.filter((v) => v !== C)) : h((v) => [...v, C]);
6734
+ }, y = (C) => {
6735
+ n || c(C), p(C);
6736
+ }, S = getBreakpointValue(n ? d : i).toLowerCase();
6737
+ return x.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(x, (C) => /* @__PURE__ */ createElement(
6735
6738
  BreakpointCard,
6736
6739
  {
6737
6740
  canvas: n,
6738
- ...y,
6739
- onClick: x,
6740
- key: y.breakpoint,
6741
- currentBreakpoint: b
6741
+ ...C,
6742
+ onClick: y,
6743
+ key: C.breakpoint,
6744
+ currentBreakpoint: S
6742
6745
  }
6743
6746
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
6744
6747
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
6745
- h.filter((y) => includes(d, toUpper(y.breakpoint))),
6746
- (y) => /* @__PURE__ */ createElement(
6748
+ x.filter((C) => includes(m, toUpper(C.breakpoint))),
6749
+ (C) => /* @__PURE__ */ createElement(
6747
6750
  BreakpointCard,
6748
6751
  {
6749
6752
  canvas: n,
6750
6753
  openDelay: o,
6751
6754
  tooltip: r,
6752
- ...y,
6753
- onClick: x,
6754
- key: y.breakpoint,
6755
- currentBreakpoint: b
6755
+ ...C,
6756
+ onClick: y,
6757
+ key: C.breakpoint,
6758
+ currentBreakpoint: S,
6759
+ buttonClass: a,
6760
+ activeButtonClass: l
6756
6761
  }
6757
6762
  )
6758
6763
  ) }),
6759
6764
  /* @__PURE__ */ jsxs(DropdownMenu, { children: [
6760
6765
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer rounded-md p-1 hover:bg-background", children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "scale-90 transform" }) }) }),
6761
6766
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
6762
- /* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
6767
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: f("Screen sizes") }),
6763
6768
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
6764
- map(h, (y) => /* @__PURE__ */ jsx(
6769
+ map(x, (C) => /* @__PURE__ */ jsx(
6765
6770
  DropdownMenuCheckboxItem,
6766
6771
  {
6767
- disabled: y.breakpoint === "xs",
6768
- onCheckedChange: () => f(toUpper(y.breakpoint)),
6769
- checked: includes(d, toUpper(y.breakpoint)),
6770
- onSelect: (C) => C.preventDefault(),
6771
- children: m(y.title)
6772
+ disabled: C.breakpoint === "xs",
6773
+ onCheckedChange: () => b(toUpper(C.breakpoint)),
6774
+ checked: includes(m, toUpper(C.breakpoint)),
6775
+ onSelect: (v) => v.preventDefault(),
6776
+ children: f(C.title)
6772
6777
  },
6773
- y.breakpoint
6778
+ C.breakpoint
6774
6779
  ))
6775
6780
  ] })
6776
6781
  ] })
@@ -6795,10 +6800,10 @@ function BreakpointSelector() {
6795
6800
  }
6796
6801
  function ManualClasses() {
6797
6802
  var N;
6798
- const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [u] = useSelectedStylingBlocks(), p = useSelectedBlock(), d = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), [h, f] = useState(""), x = (N = first(u)) == null ? void 0 : N.prop, { classes: b } = getSplitChaiClasses(get(p, x, "")), y = b.split(" ").filter((T) => !isEmpty(T)), C = useBuilderProp("flags.copyPaste", !0), S = () => {
6803
+ const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), [h, f] = useState(""), x = (N = first(d)) == null ? void 0 : N.prop, { classes: b } = getSplitChaiClasses(get(p, x, "")), y = b.split(" ").filter((T) => !isEmpty(T)), S = useBuilderProp("flags.copyPaste", !0), C = () => {
6799
6804
  const T = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6800
- d(m, T, !0), f("");
6801
- }, [w, _] = useState([]), B = ({ value: T }) => {
6805
+ u(m, T, !0), f("");
6806
+ }, [v, _] = useState([]), B = ({ value: T }) => {
6802
6807
  const P = T.trim().toLowerCase(), R = P.match(/.+:/g);
6803
6808
  let D = [];
6804
6809
  if (R && R.length > 0) {
@@ -6812,7 +6817,7 @@ function ManualClasses() {
6812
6817
  return _(map(D, "item"));
6813
6818
  }, I = () => {
6814
6819
  _([]);
6815
- }, k = (T) => T.name, A = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), v = useMemo(
6820
+ }, k = (T) => T.name, A = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), w = useMemo(
6816
6821
  () => ({
6817
6822
  ref: o,
6818
6823
  autoComplete: "off",
@@ -6827,7 +6832,7 @@ function ManualClasses() {
6827
6832
  }, 0);
6828
6833
  },
6829
6834
  onKeyDown: (T) => {
6830
- T.key === "Enter" && h.trim() !== "" && S();
6835
+ T.key === "Enter" && h.trim() !== "" && C();
6831
6836
  },
6832
6837
  onChange: (T, { newValue: P }) => f(P),
6833
6838
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
@@ -6836,7 +6841,7 @@ function ManualClasses() {
6836
6841
  ), E = (T) => {
6837
6842
  debugger;
6838
6843
  const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6839
- g(m, [T]), d(m, P, !0), r(""), l(-1);
6844
+ g(m, [T]), u(m, P, !0), r(""), l(-1);
6840
6845
  }, j = () => {
6841
6846
  if (navigator.clipboard === void 0) {
6842
6847
  toast.error(c("Clipboard not supported"));
@@ -6847,7 +6852,7 @@ function ManualClasses() {
6847
6852
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
6848
6853
  /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-x-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
6849
6854
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
6850
- C && /* @__PURE__ */ jsxs(Tooltip, { children: [
6855
+ S && /* @__PURE__ */ jsxs(Tooltip, { children: [
6851
6856
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: j, className: "cursor-pointer" }) }),
6852
6857
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
6853
6858
  ] })
@@ -6856,12 +6861,12 @@ function ManualClasses() {
6856
6861
  /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
6857
6862
  Autosuggest,
6858
6863
  {
6859
- suggestions: w,
6864
+ suggestions: v,
6860
6865
  onSuggestionsFetchRequested: B,
6861
6866
  onSuggestionsClearRequested: I,
6862
6867
  getSuggestionValue: k,
6863
6868
  renderSuggestion: A,
6864
- inputProps: v,
6869
+ inputProps: w,
6865
6870
  containerProps: {
6866
6871
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
6867
6872
  },
@@ -6877,7 +6882,7 @@ function ManualClasses() {
6877
6882
  {
6878
6883
  variant: "outline",
6879
6884
  className: "h-6 border-border",
6880
- onClick: S,
6885
+ onClick: C,
6881
6886
  disabled: h.trim() === "",
6882
6887
  size: "sm",
6883
6888
  children: /* @__PURE__ */ jsx(PlusIcon, {})
@@ -7052,30 +7057,30 @@ const MAPPER = {
7052
7057
  };
7053
7058
  function BlockStyling() {
7054
7059
  const { flexChild: o, gridChild: n } = useSelectedBlocksDisplayChild(), [r] = useSelectedStylingBlocks(), [a, l] = React__default.useState(""), [i, c] = React__default.useState({
7055
- onDrag: (d) => d,
7056
- onDragEnd: (d) => d,
7060
+ onDrag: (u) => u,
7061
+ onDragEnd: (u) => u,
7057
7062
  dragStartY: 0,
7058
7063
  dragging: !1,
7059
7064
  dragStartValue: 0,
7060
7065
  dragUnit: "",
7061
7066
  negative: !1,
7062
7067
  cssProperty: ""
7063
- }), u = useThrottledCallback(
7064
- (d) => {
7068
+ }), d = useThrottledCallback(
7069
+ (u) => {
7065
7070
  const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
7066
7071
  let h = parseFloat(i.dragStartValue);
7067
7072
  h = isNaN(h) ? 0 : h;
7068
7073
  let f = MAPPER[i.dragUnit];
7069
7074
  (startsWith(m, "scale") || m === "opacity") && (f = 10);
7070
- let b = (i.dragStartY - d.pageY) / f + h;
7075
+ let b = (i.dragStartY - u.pageY) / f + h;
7071
7076
  g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
7072
7077
  },
7073
7078
  [i],
7074
7079
  50
7075
7080
  ), p = useCallback(() => {
7076
7081
  setTimeout(() => i.onDragEnd(`${a}`), 100), c({
7077
- onDrag: (d) => d,
7078
- onDragEnd: (d) => d,
7082
+ onDrag: (u) => u,
7083
+ onDragEnd: (u) => u,
7079
7084
  dragStartY: 0,
7080
7085
  dragging: !1,
7081
7086
  dragStartValue: 0,
@@ -7088,7 +7093,7 @@ function BlockStyling() {
7088
7093
  i.dragging ? /* @__PURE__ */ jsx(
7089
7094
  "div",
7090
7095
  {
7091
- onMouseMove: u,
7096
+ onMouseMove: d,
7092
7097
  onMouseUp: () => p(),
7093
7098
  className: "absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"
7094
7099
  }
@@ -7098,7 +7103,7 @@ function BlockStyling() {
7098
7103
  /* @__PURE__ */ jsxs(Accordion, { defaultValue: ["Styles"], type: "multiple", className: "w-full", children: [
7099
7104
  o && /* @__PURE__ */ jsx(StylingGroup, { section: FLEX_CHILD_SECTION, showAccordian: o || n }),
7100
7105
  n && /* @__PURE__ */ jsx(StylingGroup, { section: GRID_CHILD_SECTION, showAccordian: o || n }),
7101
- SETTINGS_SECTIONS.map((d) => /* @__PURE__ */ jsx(StylingGroup, { section: d, showAccordian: o || n }, d.heading))
7106
+ SETTINGS_SECTIONS.map((u) => /* @__PURE__ */ jsx(StylingGroup, { section: u, showAccordian: o || n }, u.heading))
7102
7107
  ] })
7103
7108
  ] })
7104
7109
  ] });
@@ -7109,10 +7114,10 @@ const CoreBlock = ({
7109
7114
  parentId: r,
7110
7115
  position: a
7111
7116
  }) => {
7112
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: u } = o, { addCoreBlock: p, addPredefinedBlock: d } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
7117
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
7113
7118
  if (has(o, "blocks")) {
7114
7119
  const b = isFunction(o.blocks) ? o.blocks() : o.blocks;
7115
- d(syncBlocksWithDefaults(b), r || null, a);
7120
+ u(syncBlocksWithDefaults(b), r || null, a);
7116
7121
  } else
7117
7122
  p(o, r || null, a);
7118
7123
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
@@ -7130,14 +7135,14 @@ const CoreBlock = ({
7130
7135
  }, 200);
7131
7136
  },
7132
7137
  draggable: f ? "true" : "false",
7133
- className: `${kebabCase$1(`chai-block-${i}`)} 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 ${n ? "opacity-50" : ""}`,
7138
+ className: `${kebabCase(`chai-block-${i}`)} 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 ${n ? "opacity-50" : ""}`,
7134
7139
  children: [
7135
7140
  createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
7136
- /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(u || i)) })
7141
+ /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
7137
7142
  ]
7138
7143
  }
7139
7144
  ) }),
7140
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(u || i) }) })
7145
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
7141
7146
  ] }) });
7142
7147
  }, DefaultChaiBlocks = ({
7143
7148
  parentId: o,
@@ -7162,10 +7167,10 @@ let PRE_IMPORT_HTML_HOOK = async (o) => o;
7162
7167
  const registerChaiPreImportHTMLHook = (o) => {
7163
7168
  PRE_IMPORT_HTML_HOOK = o;
7164
7169
  }, getPreImportHTML = async (o) => await PRE_IMPORT_HTML_HOOK(o), ImportHTML = ({ parentId: o, position: n }) => {
7165
- const { t: r } = useTranslation(), [a, l] = useState(""), { addPredefinedBlock: i } = useAddBlock(), [c, u] = useState(!1), p = async () => {
7166
- u(!0);
7167
- const d = await getPreImportHTML(a), g = getBlocksFromHTML(d);
7168
- i([...g], o, n), l(""), u(!1), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7170
+ const { t: r } = useTranslation(), [a, l] = useState(""), { addPredefinedBlock: i } = useAddBlock(), [c, d] = useState(!1), p = async () => {
7171
+ d(!0);
7172
+ const u = await getPreImportHTML(a), g = getBlocksFromHTML(u);
7173
+ i([...g], o, n), l(""), d(!1), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7169
7174
  };
7170
7175
  return /* @__PURE__ */ jsxs(Card, { className: "border-border/0 p-0 shadow-none", children: [
7171
7176
  /* @__PURE__ */ jsx(CardHeader, { className: "p-3", children: /* @__PURE__ */ jsx(CardDescription, { children: r("Use HTML snippets from Tailwind CSS component libraries") }) }),
@@ -7176,8 +7181,8 @@ const registerChaiPreImportHTMLHook = (o) => {
7176
7181
  {
7177
7182
  autoFocus: !0,
7178
7183
  tabIndex: 1,
7179
- ref: (d) => d && d.focus(),
7180
- onChange: (d) => l(d.target.value),
7184
+ ref: (u) => u && u.focus(),
7185
+ onChange: (u) => l(u.target.value),
7181
7186
  rows: 12,
7182
7187
  value: a,
7183
7188
  placeholder: r("Enter your code snippet here"),
@@ -7199,9 +7204,9 @@ const registerChaiPreImportHTMLHook = (o) => {
7199
7204
  className: l = "",
7200
7205
  height: i = ""
7201
7206
  }) => {
7202
- const [c, u] = useState(o), p = (d) => {
7203
- const g = d.target.value;
7204
- u(g), n(g);
7207
+ const [c, d] = useState(o), p = (u) => {
7208
+ const g = u.target.value;
7209
+ d(g), n(g);
7205
7210
  };
7206
7211
  return /* @__PURE__ */ jsx("div", { className: cn$1("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
7207
7212
  "select",
@@ -7214,7 +7219,7 @@ const registerChaiPreImportHTMLHook = (o) => {
7214
7219
  onChange: p,
7215
7220
  children: [
7216
7221
  /* @__PURE__ */ jsx("option", { value: "", disabled: !0, children: a }),
7217
- r.map((d) => /* @__PURE__ */ jsx("option", { value: d.value, children: d.label }, d.value))
7222
+ r.map((u) => /* @__PURE__ */ jsx("option", { value: u.value, children: u.label }, u.value))
7218
7223
  ]
7219
7224
  }
7220
7225
  ) });
@@ -7250,20 +7255,20 @@ const registerChaiLibrary = (o, n) => {
7250
7255
  parentId: r = void 0,
7251
7256
  position: a = -1
7252
7257
  }) => {
7253
- const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: u, addPredefinedBlock: p } = useAddBlock(), [, d] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), b = (S) => {
7254
- const w = has(S, "styles_attrs.data-page-section");
7255
- return S._type === "Box" && w;
7258
+ const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), b = (C) => {
7259
+ const v = has(C, "styles_attrs.data-page-section");
7260
+ return C._type === "Box" && v;
7256
7261
  }, y = useCallback(
7257
- async (S) => {
7258
- if (S.stopPropagation(), has(o, "component")) {
7259
- u(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7262
+ async (C) => {
7263
+ if (C.stopPropagation(), has(o, "component")) {
7264
+ d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7260
7265
  return;
7261
7266
  }
7262
7267
  i(!0);
7263
- let w = await c({ library: n, block: o });
7264
- typeof w == "string" && (w = getBlocksFromHTML(w)), isEmpty(w) || p(syncBlocksWithDefaults(w), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7268
+ let v = await c({ library: n, block: o });
7269
+ typeof v == "string" && (v = getBlocksFromHTML(v)), isEmpty(v) || p(syncBlocksWithDefaults(v), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7265
7270
  },
7266
- [u, p, o, c, n, r, a]
7271
+ [d, p, o, c, n, r, a]
7267
7272
  );
7268
7273
  return /* @__PURE__ */ jsxs(Tooltip, { children: [
7269
7274
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
@@ -7272,20 +7277,20 @@ const registerChaiLibrary = (o, n) => {
7272
7277
  onClick: l ? () => {
7273
7278
  } : y,
7274
7279
  draggable: f ? "true" : "false",
7275
- onDragStart: async (S) => {
7276
- const w = await c({ library: n, block: o });
7280
+ onDragStart: async (C) => {
7281
+ const v = await c({ library: n, block: o });
7277
7282
  let _ = r;
7278
- if (b(first(w)) && (_ = null), !isEmpty(w)) {
7279
- const B = { blocks: w, uiLibrary: !0, parent: _ };
7280
- if (S.dataTransfer.setData("text/plain", JSON.stringify(B)), o.preview) {
7283
+ if (b(first(v)) && (_ = null), !isEmpty(v)) {
7284
+ const B = { blocks: v, uiLibrary: !0, parent: _ };
7285
+ if (C.dataTransfer.setData("text/plain", JSON.stringify(B)), o.preview) {
7281
7286
  const I = new Image();
7282
7287
  I.src = o.preview, I.onload = () => {
7283
- S.dataTransfer.setDragImage(I, 0, 0);
7288
+ C.dataTransfer.setDragImage(I, 0, 0);
7284
7289
  };
7285
7290
  } else
7286
- S.dataTransfer.setDragImage(new Image(), 0, 0);
7291
+ C.dataTransfer.setDragImage(new Image(), 0, 0);
7287
7292
  x(B), setTimeout(() => {
7288
- d([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7293
+ u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7289
7294
  }, 200);
7290
7295
  }
7291
7296
  },
@@ -7307,7 +7312,7 @@ const registerChaiLibrary = (o, n) => {
7307
7312
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "max-w-xs", children: /* @__PURE__ */ jsx("p", { className: "font-medium", children: m }) }) })
7308
7313
  ] });
7309
7314
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7310
- const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((E) => E.id === r) || first(l), { data: c, isLoading: u, resetLibrary: p } = useLibraryBlocks(i), [d, g] = useState(""), [m, h] = useState([]), f = useRef(null);
7315
+ const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((E) => E.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [m, h] = useState([]), f = useRef(null);
7311
7316
  useEffect(() => {
7312
7317
  c && c.length > 0 && (f.current = new Fuse(c, {
7313
7318
  keys: ["name", "label", "description", "group"],
@@ -7315,39 +7320,39 @@ const registerChaiLibrary = (o, n) => {
7315
7320
  ignoreLocation: !0
7316
7321
  }));
7317
7322
  }, [c]), useEffect(() => {
7318
- if (!d.trim() || !f.current) {
7323
+ if (!u.trim() || !f.current) {
7319
7324
  h([]);
7320
7325
  return;
7321
7326
  }
7322
- const E = f.current.search(d).map((j) => j.item);
7327
+ const E = f.current.search(u).map((j) => j.item);
7323
7328
  h(E);
7324
- }, [d]);
7325
- const x = d.trim() && !isEmpty(m) ? m : c, b = groupBy(x, "group"), [y, C] = useState(null);
7329
+ }, [u]);
7330
+ const x = u.trim() && !isEmpty(m) ? m : c, b = groupBy(x, "group"), [y, S] = useState(null);
7326
7331
  useEffect(() => {
7327
7332
  if (isEmpty(keys(b))) {
7328
- C(null);
7333
+ S(null);
7329
7334
  return;
7330
7335
  }
7331
7336
  if (!y || !b[y]) {
7332
- C(first(keys(b)));
7337
+ S(first(keys(b)));
7333
7338
  return;
7334
7339
  }
7335
7340
  }, [b, y]);
7336
- const S = get(b, y, []), w = useRef(null), { t: _ } = useTranslation(), B = (E) => {
7337
- w.current && (clearTimeout(w.current), w.current = null), w.current = setTimeout(() => {
7338
- w.current && C(E);
7341
+ const C = get(b, y, []), v = useRef(null), { t: _ } = useTranslation(), B = (E) => {
7342
+ v.current && (clearTimeout(v.current), v.current = null), v.current = setTimeout(() => {
7343
+ v.current && S(E);
7339
7344
  }, 400);
7340
7345
  }, I = () => {
7341
7346
  i != null && i.id && p(i.id);
7342
7347
  }, k = () => {
7343
7348
  g("");
7344
7349
  };
7345
- if (u)
7350
+ if (d)
7346
7351
  return /* @__PURE__ */ jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
7347
7352
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7348
7353
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7349
7354
  ] });
7350
- const A = filter(S, (E, j) => j % 2 === 0), v = filter(S, (E, j) => j % 2 === 1);
7355
+ const A = filter(C, (E, j) => j % 2 === 0), w = filter(C, (E, j) => j % 2 === 1);
7351
7356
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
7352
7357
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7353
7358
  /* @__PURE__ */ jsx(MagnifyingGlassIcon, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
@@ -7355,12 +7360,12 @@ const registerChaiLibrary = (o, n) => {
7355
7360
  Input$1,
7356
7361
  {
7357
7362
  placeholder: _("Search blocks..."),
7358
- value: d,
7363
+ value: u,
7359
7364
  onChange: (E) => g(E.target.value),
7360
7365
  className: "w-full pl-8 pr-8"
7361
7366
  }
7362
7367
  ),
7363
- d && /* @__PURE__ */ jsx(
7368
+ u && /* @__PURE__ */ jsx(
7364
7369
  "button",
7365
7370
  {
7366
7371
  onClick: k,
@@ -7375,7 +7380,7 @@ const registerChaiLibrary = (o, n) => {
7375
7380
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7376
7381
  /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: _("Groups") }),
7377
7382
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7378
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(b) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: d ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7383
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(b) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7379
7384
  /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("Failed to load the UI library. Try again") }),
7380
7385
  /* @__PURE__ */ jsxs(Button, { onClick: I, variant: "outline", size: "sm", className: "gap-2", children: [
7381
7386
  /* @__PURE__ */ jsx(ReloadIcon, { className: "h-4 w-4" }),
@@ -7385,9 +7390,9 @@ const registerChaiLibrary = (o, n) => {
7385
7390
  "div",
7386
7391
  {
7387
7392
  onMouseEnter: () => B(j),
7388
- onMouseLeave: () => clearTimeout(w.current),
7393
+ onMouseLeave: () => clearTimeout(v.current),
7389
7394
  role: "button",
7390
- onClick: () => C(j),
7395
+ onClick: () => S(j),
7391
7396
  className: cn$1(
7392
7397
  "flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
7393
7398
  j === y ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
@@ -7404,10 +7409,10 @@ const registerChaiLibrary = (o, n) => {
7404
7409
  /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-col border-l border-border", children: /* @__PURE__ */ jsxs(
7405
7410
  ScrollArea,
7406
7411
  {
7407
- onMouseEnter: () => w.current ? clearTimeout(w.current) : null,
7412
+ onMouseEnter: () => v.current ? clearTimeout(v.current) : null,
7408
7413
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
7409
7414
  children: [
7410
- isEmpty(S) && !isEmpty(b) ? /* @__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: _("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7415
+ isEmpty(C) && !isEmpty(b) ? /* @__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: _("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7411
7416
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: A.map((E, j) => /* @__PURE__ */ jsx(
7412
7417
  BlockCard,
7413
7418
  {
@@ -7418,7 +7423,7 @@ const registerChaiLibrary = (o, n) => {
7418
7423
  },
7419
7424
  `block-${j}`
7420
7425
  )) }),
7421
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: v.map((E, j) => /* @__PURE__ */ jsx(
7426
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: w.map((E, j) => /* @__PURE__ */ jsx(
7422
7427
  BlockCard,
7423
7428
  {
7424
7429
  parentId: o,
@@ -7451,9 +7456,9 @@ const registerChaiLibrary = (o, n) => {
7451
7456
  position: n,
7452
7457
  gridCols: r = "grid-cols-2"
7453
7458
  }) => {
7454
- const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [u, p] = useAtom$1(partialBlocksDataAtom), [d, g] = useAtom$1(hasInitializedPartialBlocksAtom);
7459
+ const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u, g] = useAtom$1(hasInitializedPartialBlocksAtom);
7455
7460
  useEffect(() => {
7456
- if (!d || Object.keys(u.blocks).length === 0)
7461
+ if (!u || Object.keys(d.blocks).length === 0)
7457
7462
  if (c)
7458
7463
  p({
7459
7464
  blocks: [],
@@ -7463,14 +7468,14 @@ const registerChaiLibrary = (o, n) => {
7463
7468
  }), g(!0);
7464
7469
  else if (!l && Object.keys(a || {}).length > 0) {
7465
7470
  const h = Object.entries(a).map(([x, b]) => {
7466
- const y = b, C = y.type || "partial", S = formatReadableName(C);
7471
+ const y = b, S = y.type || "partial", C = formatReadableName(S);
7467
7472
  return {
7468
7473
  type: "PartialBlock",
7469
7474
  // Set the type to PartialBlock
7470
7475
  label: formatReadableName(y.name || x),
7471
7476
  description: y.description || "",
7472
7477
  icon: FrameIcon,
7473
- group: S,
7478
+ group: C,
7474
7479
  // Use formatted type as group
7475
7480
  category: "partial",
7476
7481
  partialBlockId: x,
@@ -7493,17 +7498,17 @@ const registerChaiLibrary = (o, n) => {
7493
7498
  }, [
7494
7499
  l,
7495
7500
  a,
7496
- d,
7501
+ u,
7497
7502
  g,
7498
7503
  p,
7499
- u.blocks,
7504
+ d.blocks,
7500
7505
  c
7501
7506
  ]);
7502
7507
  const m = () => {
7503
7508
  p((h) => ({ ...h, isLoading: !0, error: null })), g(!1), i();
7504
7509
  };
7505
- return u.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : u.error || u.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
7506
- /* @__PURE__ */ jsx("p", { children: u.error || "No partial blocks available" }),
7510
+ 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: [
7511
+ /* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
7507
7512
  /* @__PURE__ */ jsx(
7508
7513
  "button",
7509
7514
  {
@@ -7518,15 +7523,15 @@ const registerChaiLibrary = (o, n) => {
7518
7523
  gridCols: r,
7519
7524
  parentId: o,
7520
7525
  position: n,
7521
- groups: u.groups,
7522
- blocks: u.blocks
7526
+ groups: d.groups,
7527
+ blocks: d.blocks
7523
7528
  }
7524
7529
  );
7525
7530
  }, ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, n) => {
7526
7531
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...n });
7527
7532
  }, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4", disableBlockGroupsSidebar: i }) => {
7528
7533
  var E;
7529
- const { t: c } = useTranslation(), [u] = useBlocksStore(), [p, d] = useState(""), g = useRef(null), [m] = useAtom$1(addBlockTabAtom), h = (E = find(u, (j) => j._id === r)) == null ? void 0 : E._type, [f, x] = useState("all"), [b, y] = useState(null), C = useRef(null);
7534
+ const { t: c } = useTranslation(), [d] = useBlocksStore(), [p, u] = useState(""), g = useRef(null), [m] = useAtom$1(addBlockTabAtom), h = (E = find(d, (j) => j._id === r)) == null ? void 0 : E._type, [f, x] = useState("all"), [b, y] = useState(null), S = useRef(null);
7530
7535
  useEffect(() => {
7531
7536
  const j = setTimeout(() => {
7532
7537
  var N;
@@ -7535,17 +7540,17 @@ const registerChaiLibrary = (o, n) => {
7535
7540
  return () => clearTimeout(j);
7536
7541
  }, [m]), useEffect(() => {
7537
7542
  p && (x("all"), y(null));
7538
- }, [p]), useEffect(() => (C.current = debounce((j) => {
7543
+ }, [p]), useEffect(() => (S.current = debounce((j) => {
7539
7544
  x(j);
7540
7545
  }, 500), () => {
7541
- C.current && C.current.cancel();
7546
+ S.current && S.current.cancel();
7542
7547
  }), []);
7543
- const S = useCallback((j) => {
7544
- y(j), C.current && C.current(j);
7545
- }, []), w = useCallback(() => {
7546
- y(null), C.current && C.current.cancel();
7548
+ const C = useCallback((j) => {
7549
+ y(j), S.current && S.current(j);
7550
+ }, []), v = useCallback(() => {
7551
+ y(null), S.current && S.current.cancel();
7547
7552
  }, []), _ = useCallback((j) => {
7548
- C.current && C.current.cancel(), x(j), y(null);
7553
+ S.current && S.current.cancel(), x(j), y(null);
7549
7554
  }, []), B = useMemo(
7550
7555
  () => p ? values(n).filter(
7551
7556
  (j) => {
@@ -7562,7 +7567,7 @@ const registerChaiLibrary = (o, n) => {
7562
7567
  ), k = useMemo(
7563
7568
  () => sortBy(I, (j) => CORE_GROUPS.indexOf(j) === -1 ? 99 : CORE_GROUPS.indexOf(j)),
7564
7569
  [I]
7565
- ), A = useMemo(() => f === "all" ? B : filter(values(B), { group: f }), [B, f]), v = useMemo(() => f === "all" ? k : [f], [k, f]);
7570
+ ), A = useMemo(() => f === "all" ? B : filter(values(B), { group: f }), [B, f]), w = useMemo(() => f === "all" ? k : [f], [k, f]);
7566
7571
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7567
7572
  /* @__PURE__ */ jsx("div", { className: `${i ? "px-2" : "px-4"} sticky top-0 py-2 z-10 bg-background/80 backdrop-blur-sm`, children: /* @__PURE__ */ jsx(
7568
7573
  Input$1,
@@ -7572,7 +7577,7 @@ const registerChaiLibrary = (o, n) => {
7572
7577
  placeholder: c("Search blocks..."),
7573
7578
  value: p,
7574
7579
  className: "-ml-2",
7575
- onChange: (j) => d(j.target.value)
7580
+ onChange: (j) => u(j.target.value)
7576
7581
  }
7577
7582
  ) }),
7578
7583
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
@@ -7581,8 +7586,8 @@ const registerChaiLibrary = (o, n) => {
7581
7586
  "button",
7582
7587
  {
7583
7588
  onClick: () => _("all"),
7584
- onMouseEnter: () => S("all"),
7585
- onMouseLeave: w,
7589
+ onMouseEnter: () => C("all"),
7590
+ onMouseLeave: v,
7586
7591
  className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${f === "all" || b === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7587
7592
  children: c("All")
7588
7593
  },
@@ -7592,8 +7597,8 @@ const registerChaiLibrary = (o, n) => {
7592
7597
  "button",
7593
7598
  {
7594
7599
  onClick: () => _(j),
7595
- onMouseEnter: () => S(j),
7596
- onMouseLeave: w,
7600
+ onMouseEnter: () => C(j),
7601
+ onMouseLeave: v,
7597
7602
  className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${f === j || b === j ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7598
7603
  children: capitalize(c(j.toLowerCase()))
7599
7604
  },
@@ -7609,7 +7614,7 @@ const registerChaiLibrary = (o, n) => {
7609
7614
  ' "',
7610
7615
  p,
7611
7616
  '"'
7612
- ] }) }) : /* @__PURE__ */ jsx("div", { className: `${i ? "p-0" : "p-4"} space-y-6`, children: v.map((j) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7617
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: `${i ? "p-0" : "p-4"} space-y-6`, children: w.map((j) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7613
7618
  /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(c(j.toLowerCase())) }),
7614
7619
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7615
7620
  f === "all" ? filter(values(A), { group: j }) : values(A),
@@ -7635,7 +7640,7 @@ const registerChaiLibrary = (o, n) => {
7635
7640
  parentId: r = void 0,
7636
7641
  position: a = -1
7637
7642
  }) => {
7638
- const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, u] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("flags.importHtml", !0), { data: d } = usePartialBlocksList(), g = Object.keys(d || {}).length > 0, { hasPermission: m } = usePermissions();
7643
+ const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("flags.importHtml", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission: m } = usePermissions();
7639
7644
  useEffect(() => {
7640
7645
  i === "partials" && !g && c("library");
7641
7646
  }, [i, g, c]);
@@ -7652,8 +7657,8 @@ const registerChaiLibrary = (o, n) => {
7652
7657
  /* @__PURE__ */ jsxs(
7653
7658
  Tabs,
7654
7659
  {
7655
- onValueChange: (C) => {
7656
- u(""), c(C);
7660
+ onValueChange: (S) => {
7661
+ d(""), c(S);
7657
7662
  },
7658
7663
  value: i,
7659
7664
  className: "flex h-full max-h-full flex-col overflow-hidden",
@@ -7663,13 +7668,13 @@ const registerChaiLibrary = (o, n) => {
7663
7668
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
7664
7669
  g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7665
7670
  x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7666
- map(f, (C) => /* @__PURE__ */ jsx(TabsTrigger, { value: C.id, children: React__default.createElement(C.tab) }, `tab-add-block-${C.id}`))
7671
+ map(f, (S) => /* @__PURE__ */ jsx(TabsTrigger, { value: S.id, children: React__default.createElement(S.tab) }, `tab-add-block-${S.id}`))
7667
7672
  ] }),
7668
7673
  /* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7669
7674
  y && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
7670
7675
  g && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7671
7676
  x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
7672
- map(f, (C) => /* @__PURE__ */ jsx(TabsContent, { value: C.id, children: React__default.createElement(C.tabContent, { close: h, parentId: r, position: a }) }, `panel-add-block-${C.id}`))
7677
+ map(f, (S) => /* @__PURE__ */ jsx(TabsContent, { value: S.id, children: React__default.createElement(S.tabContent, { close: h, parentId: r, position: a }) }, `panel-add-block-${S.id}`))
7673
7678
  ]
7674
7679
  }
7675
7680
  )
@@ -7779,10 +7784,10 @@ const registerChaiSaveToLibrary = (o) => {
7779
7784
  }, SaveToLibraryModal = () => {
7780
7785
  const [o, n] = useAtom$1(saveToLibraryModalAtom), { t: r } = useTranslation(), [a] = useBlocksStore(), l = () => n({ isOpen: !1, blockId: null }), i = useSaveToLibraryComponent(), c = useMemo(() => {
7781
7786
  if (!o.blockId) return [];
7782
- const u = find(a, { _id: o.blockId });
7783
- return u == null || delete u._parent, [u, ...getBlocks(a, u == null ? void 0 : u._id)];
7787
+ const d = find(a, { _id: o.blockId });
7788
+ return d == null || delete d._parent, [d, ...getBlocks(a, d == null ? void 0 : d._id)];
7784
7789
  }, [o.blockId, a]);
7785
- return /* @__PURE__ */ jsx(Dialog, { open: o.isOpen, onOpenChange: (u) => !u && l(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "p-4 sm:max-w-[450px]", children: [
7790
+ return /* @__PURE__ */ jsx(Dialog, { open: o.isOpen, onOpenChange: (d) => !d && l(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "p-4 sm:max-w-[450px]", children: [
7786
7791
  /* @__PURE__ */ jsx(DialogHeader, { className: "pb-2", children: /* @__PURE__ */ jsx(DialogTitle, { children: r("Save to Library") }) }),
7787
7792
  i && !isEmpty(o.blockId) && /* @__PURE__ */ jsx(i, { blockId: o.blockId, blocks: c, close: l })
7788
7793
  ] }) });
@@ -7824,35 +7829,35 @@ const registerChaiSaveToLibrary = (o) => {
7824
7829
  }
7825
7830
  ) : null;
7826
7831
  }, CopyPasteBlocks = () => {
7827
- const [o] = useBlocksStore(), [n] = useSelectedBlockIds(), { pasteBlocks: r } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(), u = useBuilderProp("flags.copyPaste", !0), p = useCallback(() => {
7828
- const d = n.map((g) => {
7832
+ const [o] = useBlocksStore(), [n] = useSelectedBlockIds(), { pasteBlocks: r } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(), d = useBuilderProp("flags.copyPaste", !0), p = useCallback(() => {
7833
+ const u = n.map((g) => {
7829
7834
  const m = o.find((h) => h._id === g);
7830
7835
  return {
7831
7836
  id: g,
7832
7837
  data: m
7833
7838
  };
7834
7839
  });
7835
- l(d.map((g) => g.id)) ? toast.warning("Partial blocks detected. Clone partial blocks?", {
7840
+ l(u.map((g) => g.id)) ? toast.warning("Partial blocks detected. Clone partial blocks?", {
7836
7841
  cancel: {
7837
7842
  label: i("No"),
7838
7843
  onClick: () => {
7839
- a(d.map((g) => g.id)), toast.dismiss();
7844
+ a(u.map((g) => g.id)), toast.dismiss();
7840
7845
  }
7841
7846
  },
7842
7847
  action: {
7843
7848
  label: i("Yes"),
7844
7849
  onClick: () => {
7845
7850
  a(
7846
- d.map((g) => g.id),
7851
+ u.map((g) => g.id),
7847
7852
  !0
7848
7853
  ), toast.dismiss();
7849
7854
  }
7850
7855
  },
7851
7856
  position: "top-center"
7852
- }) : a(d.map((g) => g.id));
7857
+ }) : a(u.map((g) => g.id));
7853
7858
  }, [n, o, a, l]);
7854
7859
  return /* @__PURE__ */ jsxs(Fragment, { children: [
7855
- u && /* @__PURE__ */ jsxs(
7860
+ d && /* @__PURE__ */ jsxs(
7856
7861
  DropdownMenuItem,
7857
7862
  {
7858
7863
  disabled: !canDuplicateBlock(c == null ? void 0 : c._type),
@@ -7865,7 +7870,7 @@ const registerChaiSaveToLibrary = (o) => {
7865
7870
  ]
7866
7871
  }
7867
7872
  ),
7868
- u && /* @__PURE__ */ jsxs(
7873
+ d && /* @__PURE__ */ jsxs(
7869
7874
  DropdownMenuItem,
7870
7875
  {
7871
7876
  className: "flex items-center gap-x-4 text-xs",
@@ -7919,7 +7924,7 @@ const registerChaiSaveToLibrary = (o) => {
7919
7924
  }
7920
7925
  );
7921
7926
  }, BlockContextMenuContent = ({ node: o }) => {
7922
- const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), { hasPermission: i } = usePermissions(), { librarySite: c } = useBuilderProp("flags", { librarySite: !1 }), u = useCallback(() => {
7927
+ const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), { hasPermission: i } = usePermissions(), { librarySite: c } = useBuilderProp("flags", { librarySite: !1 }), d = useCallback(() => {
7923
7928
  a(r);
7924
7929
  }, [r, a]), p = useMemo(() => has(l, "_libBlockId") && !isEmpty(l._libBlockId), [l == null ? void 0 : l._libBlockId]);
7925
7930
  return o === "BODY" ? /* @__PURE__ */ jsx(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: i(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -7941,7 +7946,7 @@ const registerChaiSaveToLibrary = (o) => {
7941
7946
  DropdownMenuItem,
7942
7947
  {
7943
7948
  disabled: !1,
7944
- onClick: (d) => d.preventDefault(),
7949
+ onClick: (u) => u.preventDefault(),
7945
7950
  className: "flex items-center gap-x-4 text-xs",
7946
7951
  children: /* @__PURE__ */ jsx(ClearCanvas, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4 text-xs", children: [
7947
7952
  /* @__PURE__ */ jsx(EraserIcon, {}),
@@ -7970,7 +7975,7 @@ const registerChaiSaveToLibrary = (o) => {
7970
7975
  {
7971
7976
  disabled: !canDuplicateBlock(l == null ? void 0 : l._type),
7972
7977
  className: "flex items-center gap-x-4 text-xs",
7973
- onClick: u,
7978
+ onClick: d,
7974
7979
  children: [
7975
7980
  /* @__PURE__ */ jsx(CardStackPlusIcon, {}),
7976
7981
  " ",
@@ -8042,24 +8047,24 @@ const Input = ({ node: o }) => {
8042
8047
  }, truncateText = (o, n) => o.length > n ? o.substring(0, n) + "..." : o, Node$1 = memo(({ node: o, style: n, dragHandle: r }) => {
8043
8048
  var D;
8044
8049
  const { t: a } = useTranslation(), l = useUpdateBlocksProps(), [i] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
8045
- let u = null;
8046
- const p = o.children.length > 0, { highlightBlock: d, clearHighlight: g } = useBlockHighlight(), { id: m, data: h, isSelected: f, willReceiveDrop: x, isDragging: b, isEditing: y, handleClick: C } = o, S = get(h, "_show", !0), w = (L) => {
8047
- L.stopPropagation(), S && o.toggle();
8050
+ let d = null;
8051
+ const p = o.children.length > 0, { highlightBlock: u, clearHighlight: g } = useBlockHighlight(), { id: m, data: h, isSelected: f, willReceiveDrop: x, isDragging: b, isEditing: y, handleClick: S } = o, C = get(h, "_show", !0), v = (L) => {
8052
+ L.stopPropagation(), C && o.toggle();
8048
8053
  }, _ = (L) => {
8049
- L.isInternal && (u = L.isOpen, L.isOpen && L.close());
8054
+ L.isInternal && (d = L.isOpen, L.isOpen && L.close());
8050
8055
  }, B = (L) => {
8051
- L.isInternal && u !== null && (u ? L.open() : L.close(), u = null);
8056
+ L.isInternal && d !== null && (d ? L.open() : L.close(), d = null);
8052
8057
  }, [I, k] = useAtom$1(currentAddSelection), A = () => {
8053
8058
  var L;
8054
- v(), o.parent.isSelected || k((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
8055
- }, v = () => {
8059
+ w(), o.parent.isSelected || k((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
8060
+ }, w = () => {
8056
8061
  k(null);
8057
8062
  }, E = (L) => {
8058
- v(), L.stopPropagation(), !o.isOpen && S && o.toggle(), C(L);
8063
+ w(), L.stopPropagation(), !o.isOpen && C && o.toggle(), S(L);
8059
8064
  };
8060
8065
  useEffect(() => {
8061
8066
  const L = setTimeout(() => {
8062
- x && !o.isOpen && !b && S && o.toggle();
8067
+ x && !o.isOpen && !b && C && o.toggle();
8063
8068
  }, 500);
8064
8069
  return () => clearTimeout(L);
8065
8070
  }, [x, o, b]);
@@ -8069,7 +8074,7 @@ const Input = ({ node: o }) => {
8069
8074
  const V = M.getBoundingClientRect(), H = i.getBoundingClientRect();
8070
8075
  V.top >= H.top && V.left >= H.left && V.bottom <= H.bottom && V.right <= H.right || (F.documentElement.scrollTop = M.offsetTop - H.top);
8071
8076
  }, N = (L) => {
8072
- v();
8077
+ w();
8073
8078
  const O = get(o, "parent.id");
8074
8079
  O !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: O, position: L }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: L });
8075
8080
  };
@@ -8095,7 +8100,7 @@ const Input = ({ node: o }) => {
8095
8100
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
8096
8101
  "div",
8097
8102
  {
8098
- onMouseEnter: () => d(m),
8103
+ onMouseEnter: () => u(m),
8099
8104
  onMouseLeave: () => g(),
8100
8105
  onClick: E,
8101
8106
  style: n,
@@ -8120,7 +8125,7 @@ const Input = ({ node: o }) => {
8120
8125
  L.stopPropagation(), N(o.childIndex);
8121
8126
  },
8122
8127
  onMouseEnter: A,
8123
- onMouseLeave: v,
8128
+ onMouseLeave: w,
8124
8129
  className: "absolute -top-0.5 h-0.5 w-[90%] rounded bg-primary/80 opacity-0 delay-200 duration-200 group-hover:opacity-100",
8125
8130
  children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary/80 p-1 outline outline-2 outline-white hover:bg-primary/80", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-2 w-2 stroke-[2] text-white" }) })
8126
8131
  }
@@ -8134,7 +8139,7 @@ const Input = ({ node: o }) => {
8134
8139
  x && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
8135
8140
  (o == null ? void 0 : o.id) === I ? "bg-primary/10" : "",
8136
8141
  b && "opacity-20",
8137
- S ? "" : "line-through opacity-50",
8142
+ C ? "" : "line-through opacity-50",
8138
8143
  P && f && "bg-primary/20 text-primary"
8139
8144
  ),
8140
8145
  children: [
@@ -8143,7 +8148,7 @@ const Input = ({ node: o }) => {
8143
8148
  "div",
8144
8149
  {
8145
8150
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
8146
- children: p && /* @__PURE__ */ jsx("button", { onClick: w, type: "button", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) })
8151
+ children: p && /* @__PURE__ */ jsx("button", { onClick: v, type: "button", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) })
8147
8152
  }
8148
8153
  ),
8149
8154
  /* @__PURE__ */ jsxs(
@@ -8173,7 +8178,7 @@ const Input = ({ node: o }) => {
8173
8178
  )
8174
8179
  ] }),
8175
8180
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-px group-hover:visible", children: [
8176
- canAddChildBlock(h == null ? void 0 : h._type) && S && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8181
+ canAddChildBlock(h == null ? void 0 : h._type) && C && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8177
8182
  /* @__PURE__ */ jsx(
8178
8183
  TooltipTrigger,
8179
8184
  {
@@ -8190,14 +8195,14 @@ const Input = ({ node: o }) => {
8190
8195
  TooltipTrigger,
8191
8196
  {
8192
8197
  onClick: (L) => {
8193
- L.stopPropagation(), l([m], { _show: !S }), o.isOpen && o.toggle();
8198
+ L.stopPropagation(), l([m], { _show: !C }), o.isOpen && o.toggle();
8194
8199
  },
8195
8200
  className: "cursor-pointer rounded bg-transparent p-0.5 hover:bg-primary/10",
8196
8201
  asChild: !0,
8197
- children: S ? /* @__PURE__ */ jsx(EyeClosedIcon, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(EyeOpenIcon, { className: "h-4 w-4" })
8202
+ children: C ? /* @__PURE__ */ jsx(EyeClosedIcon, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(EyeOpenIcon, { className: "h-4 w-4" })
8198
8203
  }
8199
8204
  ),
8200
- /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999] text-xs", side: "bottom", children: a(S ? "Hide the block from page" : "Show the block on page") })
8205
+ /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999] text-xs", side: "bottom", children: a(C ? "Hide the block from page" : "Show the block on page") })
8201
8206
  ] }),
8202
8207
  /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: m, children: /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded bg-transparent p-px hover:bg-primary/10", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "h-3 w-3" }) }) })
8203
8208
  ] })
@@ -8240,8 +8245,8 @@ const Input = ({ node: o }) => {
8240
8245
  return (n, r) => {
8241
8246
  var i;
8242
8247
  const a = (i = find(o, { _id: r })) == null ? void 0 : i._type, l = first(n.map((c) => {
8243
- var u;
8244
- return (u = find(o, { _id: c })) == null ? void 0 : u._type;
8248
+ var d;
8249
+ return (d = find(o, { _id: c })) == null ? void 0 : d._type;
8245
8250
  }));
8246
8251
  return canAcceptChildBlock(a, l);
8247
8252
  };
@@ -8642,12 +8647,12 @@ const Input = ({ node: o }) => {
8642
8647
  console.warn("Failed to clear previous theme from localStorage:", o);
8643
8648
  }
8644
8649
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
8645
- const [n, r] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), u = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: d } = usePermissions(), g = useBuilderProp("flags.importTheme", !0), m = useBuilderProp("flags.darkMode", !0);
8646
- if (u) {
8647
- const k = u.map((A) => Object.keys(A)[0]);
8650
+ const [n, r] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions(), g = useBuilderProp("flags.importTheme", !0), m = useBuilderProp("flags.darkMode", !0);
8651
+ if (d) {
8652
+ const k = d.map((A) => Object.keys(A)[0]);
8648
8653
  DEFAULT_THEME_PRESET.forEach((A) => {
8649
- const v = Object.keys(A)[0];
8650
- k.includes(v) || u.push(A);
8654
+ const w = Object.keys(A)[0];
8655
+ k.includes(w) || d.push(A);
8651
8656
  });
8652
8657
  }
8653
8658
  const [h, f] = useTheme(), x = useThemeOptions(), { t: b } = useTranslation(), y = React.useCallback(
@@ -8668,16 +8673,16 @@ const Input = ({ node: o }) => {
8668
8673
  });
8669
8674
  },
8670
8675
  [h, f]
8671
- ), C = () => {
8672
- const k = u.find((A) => Object.keys(A)[0] === a);
8676
+ ), S = () => {
8677
+ const k = d.find((A) => Object.keys(A)[0] === a);
8673
8678
  if (k) {
8674
8679
  const A = Object.values(k)[0];
8675
8680
  A && typeof A == "object" && "fontFamily" in A && "borderRadius" in A && "colors" in A ? (y(A), l("")) : console.error("Invalid preset structure:", A);
8676
8681
  } else
8677
8682
  console.error("Preset not found:", a);
8678
- }, S = (k) => {
8683
+ }, C = (k) => {
8679
8684
  y(k), l("");
8680
- }, w = useDebouncedCallback(
8685
+ }, v = useDebouncedCallback(
8681
8686
  (k, A) => {
8682
8687
  f(() => ({
8683
8688
  ...h,
@@ -8700,12 +8705,12 @@ const Input = ({ node: o }) => {
8700
8705
  ), B = useDebouncedCallback(
8701
8706
  (k, A) => {
8702
8707
  f(() => {
8703
- const v = get(h, `colors.${k}`);
8704
- return n ? set(v, 1, A) : set(v, 0, A), {
8708
+ const w = get(h, `colors.${k}`);
8709
+ return n ? set(w, 1, A) : set(w, 0, A), {
8705
8710
  ...h,
8706
8711
  colors: {
8707
8712
  ...h.colors,
8708
- [k]: v
8713
+ [k]: w
8709
8714
  }
8710
8715
  };
8711
8716
  });
@@ -8713,21 +8718,21 @@ const Input = ({ node: o }) => {
8713
8718
  [h],
8714
8719
  200
8715
8720
  ), I = (k) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(k.items).map(([A]) => {
8716
- const v = get(h, `colors.${A}.${n ? 1 : 0}`);
8717
- return v ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8721
+ const w = get(h, `colors.${A}.${n ? 1 : 0}`);
8722
+ return w ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8718
8723
  /* @__PURE__ */ jsx(
8719
8724
  ColorPickerInput,
8720
8725
  {
8721
- value: v,
8726
+ value: w,
8722
8727
  onChange: (E) => B(A, E)
8723
8728
  }
8724
8729
  ),
8725
8730
  /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: A.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!A.toLowerCase().includes("foreground") && !A.toLowerCase().includes("border") && !A.toLowerCase().includes("input") && !A.toLowerCase().includes("ring") && !A.toLowerCase().includes("background") ? " Background" : "") })
8726
8731
  ] }, A) : null;
8727
8732
  }) });
8728
- return d("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
8733
+ return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
8729
8734
  /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
8730
- u.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mx-0 my-2 flex flex-col gap-1 py-2", children: [
8735
+ d.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mx-0 my-2 flex flex-col gap-1 py-2", children: [
8731
8736
  /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
8732
8737
  /* @__PURE__ */ jsx(Label, { className: "text-sm", children: b("Presets") }),
8733
8738
  /* @__PURE__ */ jsx("div", { className: "flex gap-2", children: g && /* @__PURE__ */ jsxs(Button, { className: "px-1", variant: "link", size: "sm", onClick: () => c(!0), children: [
@@ -8738,12 +8743,12 @@ const Input = ({ node: o }) => {
8738
8743
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
8739
8744
  /* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
8740
8745
  /* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: b("Select preset") }) }),
8741
- /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(u) && u.map((k) => {
8742
- const A = Object.keys(k)[0], v = A.replaceAll("_", " ");
8743
- return /* @__PURE__ */ jsx(SelectItem, { value: A, children: capitalize(v) }, A);
8746
+ /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((k) => {
8747
+ const A = Object.keys(k)[0], w = A.replaceAll("_", " ");
8748
+ return /* @__PURE__ */ jsx(SelectItem, { value: A, children: capitalize(w) }, A);
8744
8749
  }) })
8745
8750
  ] }) }),
8746
- /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: C, children: b("Apply") }) })
8751
+ /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: S, children: b("Apply") }) })
8747
8752
  ] })
8748
8753
  ] }),
8749
8754
  /* @__PURE__ */ jsx(Separator, {}),
@@ -8757,7 +8762,7 @@ const Input = ({ node: o }) => {
8757
8762
  {
8758
8763
  label: k,
8759
8764
  value: h.fontFamily[k.replace(/font-/g, "")] || A[Object.keys(A)[0]],
8760
- onChange: (v) => w(k, v)
8765
+ onChange: (w) => v(k, w)
8761
8766
  },
8762
8767
  k
8763
8768
  )) }),
@@ -8800,7 +8805,7 @@ const Input = ({ node: o }) => {
8800
8805
  {
8801
8806
  open: i,
8802
8807
  onOpenChange: c,
8803
- onImport: S
8808
+ onImport: C
8804
8809
  }
8805
8810
  ) })
8806
8811
  ] }),
@@ -9314,17 +9319,17 @@ function QuickPrompts({ onClick: o }) {
9314
9319
  lang: get(LANGUAGES, a, a)
9315
9320
  })
9316
9321
  }), /* @__PURE__ */ jsx("div", { className: n ? "pointer-events-none opacity-50" : "", children: /* @__PURE__ */ jsx("ul", { className: "space-y-1", children: c.map(
9317
- ({ name: u, icon: p, subMenus: d, prompt: g }) => d ? /* @__PURE__ */ jsxs(Popover, { children: [
9322
+ ({ name: d, icon: p, subMenus: u, prompt: g }) => u ? /* @__PURE__ */ jsxs(Popover, { children: [
9318
9323
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
9319
9324
  "li",
9320
9325
  {
9321
9326
  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",
9322
9327
  children: [
9323
9328
  /* @__PURE__ */ jsx(p, { className: "h-4 w-4" }),
9324
- /* @__PURE__ */ jsx("span", { children: u })
9329
+ /* @__PURE__ */ jsx("span", { children: d })
9325
9330
  ]
9326
9331
  },
9327
- u
9332
+ d
9328
9333
  ) }),
9329
9334
  /* @__PURE__ */ jsx(PopoverContent, { side: "right", children: /* @__PURE__ */ jsx("ul", { children: /* @__PURE__ */ jsx("li", { children: r("Happy") }) }) })
9330
9335
  ] }) : /* @__PURE__ */ jsxs(
@@ -9334,28 +9339,28 @@ function QuickPrompts({ onClick: o }) {
9334
9339
  className: "flex cursor-pointer items-center space-x-2 rounded p-1 text-xs hover:bg-primary/10 hover:text-primary dark:hover:bg-gray-800",
9335
9340
  children: [
9336
9341
  /* @__PURE__ */ jsx(p, { className: "h-3.5 w-3.5" }),
9337
- /* @__PURE__ */ jsx("span", { children: r(u) })
9342
+ /* @__PURE__ */ jsx("span", { children: r(d) })
9338
9343
  ]
9339
9344
  },
9340
- u
9345
+ d
9341
9346
  )
9342
9347
  ) }) });
9343
9348
  }
9344
9349
  const AIUserPrompt = ({ blockId: o }) => {
9345
- const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), u = useRef(null), p = useRef(null), d = useSelectedBlock();
9350
+ const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), u = useSelectedBlock();
9346
9351
  useEffect(() => {
9347
9352
  var m;
9348
- (m = u.current) == null || m.focus();
9353
+ (m = d.current) == null || m.focus();
9349
9354
  }, []);
9350
9355
  const g = () => {
9351
9356
  l || c("");
9352
9357
  };
9353
9358
  return /* @__PURE__ */ jsx("div", { className: "", children: o ? /* @__PURE__ */ jsxs("div", { className: "", children: [
9354
9359
  /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-gray-500", children: "Selected block" }),
9355
- d && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1 rounded border border-primary/20 bg-primary/10 p-1.5 text-xs text-primary", children: [
9356
- /* @__PURE__ */ jsx(TypeIcon, { type: d._type }),
9360
+ u && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1 rounded border border-primary/20 bg-primary/10 p-1.5 text-xs text-primary", children: [
9361
+ /* @__PURE__ */ jsx(TypeIcon, { type: u._type }),
9357
9362
  " ",
9358
- /* @__PURE__ */ jsx("p", { className: "truncate whitespace-nowrap leading-none", children: d._name || d._type })
9363
+ /* @__PURE__ */ jsx("p", { className: "truncate whitespace-nowrap leading-none", children: u._name || u._type })
9359
9364
  ] }),
9360
9365
  /* @__PURE__ */ jsx("br", {}),
9361
9366
  /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-gray-500", children: "Quick actions" }),
@@ -9373,7 +9378,7 @@ const AIUserPrompt = ({ blockId: o }) => {
9373
9378
  /* @__PURE__ */ jsx(
9374
9379
  Textarea,
9375
9380
  {
9376
- ref: u,
9381
+ ref: d,
9377
9382
  value: i,
9378
9383
  onChange: (m) => c(m.target.value),
9379
9384
  placeholder: n("Ask AI to edit content"),
@@ -9452,7 +9457,7 @@ const UndoRedo = () => {
9452
9457
  /* @__PURE__ */ jsxs("div", { className: "flex h-full items-center", children: [
9453
9458
  n ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
9454
9459
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", className: "h-7 w-7 rounded-md p-1", children: /* @__PURE__ */ jsx(DotsHorizontalIcon, { className: "h-4 w-4" }) }) }),
9455
- /* @__PURE__ */ jsx(DropdownMenuContent, { className: "w-56 border-border text-xs", children: /* @__PURE__ */ jsxs(DropdownMenuItem, { className: "flex items-center gap-2", onSelect: (u) => u.preventDefault(), children: [
9460
+ /* @__PURE__ */ jsx(DropdownMenuContent, { className: "w-56 border-border text-xs", children: /* @__PURE__ */ jsxs(DropdownMenuItem, { className: "flex items-center gap-2", onSelect: (d) => d.preventDefault(), children: [
9456
9461
  /* @__PURE__ */ jsx(LightningBoltIcon, { className: "h-4 w-4 text-gray-500" }),
9457
9462
  /* @__PURE__ */ jsx("span", { className: "flex-1", children: l("Data Binding") }),
9458
9463
  /* @__PURE__ */ jsx(Switch, { checked: r, onCheckedChange: () => a(!r) })
@@ -9463,8 +9468,8 @@ const UndoRedo = () => {
9463
9468
  ] });
9464
9469
  }, AddBlocksDialog = () => {
9465
9470
  const { t: o } = useTranslation(), [n, r] = useState(""), [a, l] = useState(-1), [i, c] = useState(!1);
9466
- return usePubSub(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, (u) => {
9467
- r(u ? u._id : null), l(isNaN(u == null ? void 0 : u.position) ? -1 : u == null ? void 0 : u.position), c(!0);
9471
+ return usePubSub(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, (d) => {
9472
+ r(d ? d._id : null), l(isNaN(d == null ? void 0 : d.position) ? -1 : d == null ? void 0 : d.position), c(!0);
9468
9473
  }), usePubSub(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK, () => {
9469
9474
  r(""), l(-1), c(!1);
9470
9475
  }), /* @__PURE__ */ jsx(AlertDialog, { open: i, onOpenChange: () => i ? c(!1) : "", children: /* @__PURE__ */ jsxs(AlertDialogContent, { className: "max-w-5xl overflow-hidden border-border", children: [
@@ -9485,37 +9490,37 @@ const UndoRedo = () => {
9485
9490
  preloadedAttributes: n = [],
9486
9491
  onAttributesChange: r
9487
9492
  }) {
9488
- const [a, l] = useState([]), [i, c] = useState(""), [u, p] = useState(""), [d, g] = useState(null), [m, h] = useState(""), f = useRef(null), x = useRef(null), b = usePageExternalData(), { t: y } = useTranslation();
9493
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), f = useRef(null), x = useRef(null), b = usePageExternalData(), { t: y } = useTranslation();
9489
9494
  useEffect(() => {
9490
9495
  l(n);
9491
9496
  }, [n]);
9492
- const C = () => {
9497
+ const S = () => {
9493
9498
  if (i.startsWith("@")) {
9494
9499
  h("Attribute keys cannot start with '@'");
9495
9500
  return;
9496
9501
  }
9497
9502
  if (i) {
9498
- const k = [...a, { key: i, value: u }];
9503
+ const k = [...a, { key: i, value: d }];
9499
9504
  r(k), l(a), c(""), p(""), h("");
9500
9505
  }
9501
- }, S = (k) => {
9502
- const A = a.filter((v, E) => E !== k);
9506
+ }, C = (k) => {
9507
+ const A = a.filter((w, E) => E !== k);
9503
9508
  r(A), l(A);
9504
- }, w = (k) => {
9509
+ }, v = (k) => {
9505
9510
  g(k), c(a[k].key), p(a[k].value);
9506
9511
  }, _ = () => {
9507
9512
  if (i.startsWith("@")) {
9508
9513
  h("Attribute keys cannot start with '@'");
9509
9514
  return;
9510
9515
  }
9511
- if (d !== null && i) {
9516
+ if (u !== null && i) {
9512
9517
  const k = [...a];
9513
- k[d] = { key: i, value: u }, r(k), l(k), g(null), c(""), p(""), h("");
9518
+ k[u] = { key: i, value: d }, r(k), l(k), g(null), c(""), p(""), h("");
9514
9519
  }
9515
9520
  }, B = (k) => {
9516
- k.key === "Enter" && !k.shiftKey && (k.preventDefault(), d !== null ? _() : C());
9521
+ k.key === "Enter" && !k.shiftKey && (k.preventDefault(), u !== null ? _() : S());
9517
9522
  }, I = useCallback((k) => {
9518
- const A = (j) => /[.,!?;:]/.test(j), v = (j, N, T) => {
9523
+ const A = (j) => /[.,!?;:]/.test(j), w = (j, N, T) => {
9519
9524
  let P = "", R = "";
9520
9525
  const D = N > 0 ? j[N - 1] : "", L = N < j.length ? j[N] : "";
9521
9526
  return N > 0 && (D === "." || !A(D) && D !== " ") && (P = " "), N < j.length && !A(L) && L !== " " && (R = " "), {
@@ -9527,11 +9532,11 @@ const UndoRedo = () => {
9527
9532
  if (E) {
9528
9533
  const j = E.selectionStart || 0, N = E.value || "", T = E.selectionEnd || j;
9529
9534
  if (T > j) {
9530
- const O = `{{${k}}}`, { text: F } = v(N, j, O), M = N.slice(0, j) + F + N.slice(T);
9535
+ const O = `{{${k}}}`, { text: F } = w(N, j, O), M = N.slice(0, j) + F + N.slice(T);
9531
9536
  p(M);
9532
9537
  return;
9533
9538
  }
9534
- const R = `{{${k}}}`, { text: D } = v(N, j, R), L = N.slice(0, j) + D + N.slice(j);
9539
+ const R = `{{${k}}}`, { text: D } = w(N, j, R), L = N.slice(0, j) + D + N.slice(j);
9535
9540
  p(L);
9536
9541
  }
9537
9542
  }, []);
@@ -9540,7 +9545,7 @@ const UndoRedo = () => {
9540
9545
  "form",
9541
9546
  {
9542
9547
  onSubmit: (k) => {
9543
- k.preventDefault(), d !== null ? _() : C();
9548
+ k.preventDefault(), u !== null ? _() : S();
9544
9549
  },
9545
9550
  className: "space-y-3",
9546
9551
  children: [
@@ -9576,7 +9581,7 @@ const UndoRedo = () => {
9576
9581
  id: "attrValue",
9577
9582
  rows: 2,
9578
9583
  ref: x,
9579
- value: u,
9584
+ value: d,
9580
9585
  onChange: (k) => p(k.target.value),
9581
9586
  onKeyDown: B,
9582
9587
  placeholder: "Enter Value",
@@ -9585,7 +9590,7 @@ const UndoRedo = () => {
9585
9590
  )
9586
9591
  ] })
9587
9592
  ] }),
9588
- /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !i.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: d !== null ? "Save" : "Add" }) }),
9593
+ /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !i.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: u !== null ? "Save" : "Add" }) }),
9589
9594
  m && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: m })
9590
9595
  ]
9591
9596
  }
@@ -9596,22 +9601,22 @@ const UndoRedo = () => {
9596
9601
  /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: k.value.toString() })
9597
9602
  ] }),
9598
9603
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9599
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => w(A), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
9600
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => S(A), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
9604
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(A), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
9605
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => C(A), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
9601
9606
  ] })
9602
9607
  ] }, A)) })
9603
9608
  ] });
9604
9609
  }), BlockAttributesEditor = React.memo(() => {
9605
9610
  const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
9606
9611
  React.useEffect(() => {
9607
- const u = map(get(o, i), (p, d) => ({ key: d, value: p }));
9608
- isEmpty(u) ? r([]) : r(u);
9612
+ const d = map(get(o, i), (p, u) => ({ key: u, value: p }));
9613
+ isEmpty(d) ? r([]) : r(d);
9609
9614
  }, [get(o, i)]);
9610
9615
  const c = React.useCallback(
9611
- (u = []) => {
9616
+ (d = []) => {
9612
9617
  const p = {};
9613
- forEach(u, (d) => {
9614
- isEmpty(d.key) || set(p, d.key, d.value);
9618
+ forEach(d, (u) => {
9619
+ isEmpty(u.key) || set(p, u.key, u.value);
9615
9620
  }), l([get(o, "_id")], { [i]: p });
9616
9621
  },
9617
9622
  [o, l, i]
@@ -9757,28 +9762,28 @@ registerChaiSidebarPanel("outline", {
9757
9762
  panel: () => /* @__PURE__ */ jsx("div", { className: "-mt-8", children: /* @__PURE__ */ jsx(ListTree, {}) })
9758
9763
  });
9759
9764
  const RootLayout = () => {
9760
- const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, u] = useRightPanel(), p = useChaiSidebarPanels("top"), d = useChaiSidebarPanels("bottom"), g = reverse([...d ?? []]), m = useCallback((k) => {
9765
+ const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = reverse([...u ?? []]), m = useCallback((k) => {
9761
9766
  k.preventDefault();
9762
9767
  }, []), h = useMemo(() => {
9763
- const k = [p].flat(), A = k.find((E) => E.id === "chai-chat-panel"), v = k.filter((E) => E.id !== "chai-chat-panel");
9764
- return A ? [A, ...v] : k;
9768
+ const k = [p].flat(), A = k.find((E) => E.id === "chai-chat-panel"), w = k.filter((E) => E.id !== "chai-chat-panel");
9769
+ return A ? [A, ...w] : k;
9765
9770
  }, [p]), f = useCallback(
9766
9771
  (k) => {
9767
9772
  console.log("handleMenuItemClick", k, n), r(n === k ? null : k);
9768
9773
  },
9769
9774
  [n, r]
9770
- ), { t: x } = useTranslation(), b = useMemo(() => [...p, ...d], [p, d]), y = useBuilderProp("htmlDir", "ltr"), C = find(b, { id: n }) ?? first(b), S = get(C, "width", DEFAULT_PANEL_WIDTH);
9775
+ ), { t: x } = useTranslation(), b = useMemo(() => [...p, ...u], [p, u]), y = useBuilderProp("htmlDir", "ltr"), S = find(b, { id: n }) ?? first(b), C = get(S, "width", DEFAULT_PANEL_WIDTH);
9771
9776
  useEffect(() => {
9772
9777
  if (n !== null) {
9773
9778
  const k = find(b, { id: n });
9774
9779
  k && get(k, "view", "standard") === "standard" && (a.current = n, i(get(k, "width", DEFAULT_PANEL_WIDTH)));
9775
9780
  }
9776
9781
  }, [n, b]);
9777
- const w = useMemo(() => {
9782
+ const v = useMemo(() => {
9778
9783
  if (n === null) return 0;
9779
9784
  const k = find(b, { id: n });
9780
- return get(k, "view", "standard") === "standard" ? S : l;
9781
- }, [n, S, l, b]), _ = useCallback(() => {
9785
+ return get(k, "view", "standard") === "standard" ? C : l;
9786
+ }, [n, C, l, b]), _ = useCallback(() => {
9782
9787
  r(a.current);
9783
9788
  }, [r, n]), B = useCallback(() => {
9784
9789
  r("outline");
@@ -9827,18 +9832,18 @@ const RootLayout = () => {
9827
9832
  {
9828
9833
  id: "left-panel",
9829
9834
  className: "h-full max-h-full border-r border-border",
9830
- initial: { width: w },
9831
- animate: { width: w },
9835
+ initial: { width: v },
9836
+ animate: { width: v },
9832
9837
  transition: { duration: 0.3, ease: "easeInOut" },
9833
- children: n !== null && get(C, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
9838
+ children: n !== null && get(S, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
9834
9839
  /* @__PURE__ */ jsx(
9835
9840
  "div",
9836
9841
  {
9837
- className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(C, "isInternal", !1) ? "" : "w-64"}`,
9838
- children: /* @__PURE__ */ jsx("span", { children: x(get(C, "label", "")) })
9842
+ className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(S, "isInternal", !1) ? "" : "w-64"}`,
9843
+ children: /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
9839
9844
  }
9840
9845
  ),
9841
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(C, "panel", NoopComponent), {}) }) })
9846
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {}) }) })
9842
9847
  ] })
9843
9848
  }
9844
9849
  ),
@@ -9867,7 +9872,7 @@ const RootLayout = () => {
9867
9872
  /* @__PURE__ */ jsx(
9868
9873
  Button,
9869
9874
  {
9870
- onClick: () => u("block"),
9875
+ onClick: () => d("block"),
9871
9876
  variant: "ghost",
9872
9877
  size: "icon",
9873
9878
  className: "text-xs",
@@ -9884,34 +9889,34 @@ const RootLayout = () => {
9884
9889
  }
9885
9890
  ),
9886
9891
  /* @__PURE__ */ jsx(AddBlocksDialog, {}),
9887
- n !== null && get(C, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(
9892
+ n !== null && get(S, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(
9888
9893
  SheetContent,
9889
9894
  {
9890
9895
  side: "left",
9891
9896
  className: "flex flex-col gap-0 p-0 sm:max-w-full",
9892
- style: { width: `${S}px` },
9897
+ style: { width: `${C}px` },
9893
9898
  children: [
9894
9899
  /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
9895
- /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(C, "icon", null) }),
9896
- /* @__PURE__ */ jsx("span", { children: x(get(C, "label", "")) })
9900
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(S, "icon", null) }),
9901
+ /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
9897
9902
  ] }) }),
9898
- /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(C, "panel", NoopComponent), {
9903
+ /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {
9899
9904
  close: B
9900
9905
  }) }) })
9901
9906
  ]
9902
9907
  }
9903
9908
  ) }),
9904
9909
  " ",
9905
- n !== null && get(C, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${S}px` }, children: [
9910
+ n !== null && get(S, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${C}px` }, children: [
9906
9911
  /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
9907
- /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(C, "icon", null) }),
9908
- /* @__PURE__ */ jsx("span", { children: x(get(C, "label", "")) })
9912
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(S, "icon", null) }),
9913
+ /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
9909
9914
  ] }) }),
9910
- /* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(C, "panel", NoopComponent), {
9915
+ /* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {
9911
9916
  close: B
9912
9917
  }) }) })
9913
9918
  ] }) }),
9914
- n !== null && get(C, "view") === "overlay" && /* @__PURE__ */ jsx(
9919
+ n !== null && get(S, "view") === "overlay" && /* @__PURE__ */ jsx(
9915
9920
  motion.div,
9916
9921
  {
9917
9922
  className: "absolute bottom-0 left-12 right-0 top-0 z-50",
@@ -9930,12 +9935,12 @@ const RootLayout = () => {
9930
9935
  children: [
9931
9936
  /* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
9932
9937
  /* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
9933
- /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(C, "icon", null) }),
9934
- /* @__PURE__ */ jsx("span", { children: x(get(C, "label", "")) })
9938
+ /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(S, "icon", null) }),
9939
+ /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
9935
9940
  ] }),
9936
9941
  /* @__PURE__ */ jsx(Button, { onClick: () => _(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-5 w-5" }) })
9937
9942
  ] }),
9938
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(C, "panel", NoopComponent), {
9943
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {
9939
9944
  close: B
9940
9945
  }) }) })
9941
9946
  ]
@@ -9991,30 +9996,30 @@ const RootLayout = () => {
9991
9996
  position: n,
9992
9997
  updatePosition: r
9993
9998
  }) => {
9994
- const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, u] = useState(!1), [p, d] = useState({ x: 0, y: 0 }), g = useMemo(() => {
9999
+ const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
9995
10000
  if (!l.trim()) return a;
9996
10001
  const x = l.toLowerCase();
9997
10002
  return Object.fromEntries(
9998
10003
  Object.entries(a).filter(([b, y]) => {
9999
- var C;
10000
- return (b == null ? void 0 : b.toLowerCase().includes(x)) || ((C = y == null ? void 0 : y.description) == null ? void 0 : C.toLowerCase().includes(x));
10004
+ var S;
10005
+ return (b == null ? void 0 : b.toLowerCase().includes(x)) || ((S = y == null ? void 0 : y.description) == null ? void 0 : S.toLowerCase().includes(x));
10001
10006
  })
10002
10007
  );
10003
10008
  }, [a, l]), m = (x) => {
10004
- u(!0), d({
10009
+ d(!0), u({
10005
10010
  x: x.clientX - n.x,
10006
10011
  y: x.clientY - n.y
10007
10012
  });
10008
10013
  }, h = (x) => {
10009
10014
  if (!c) return;
10010
- const b = x.clientX - p.x, y = x.clientY - p.y, C = x.currentTarget, S = C.offsetWidth, w = C.offsetHeight, _ = window.innerWidth - S, B = window.innerHeight - w, I = Math.max(0, Math.min(b, _)), k = Math.max(0, Math.min(y, B));
10015
+ const b = x.clientX - p.x, y = x.clientY - p.y, S = x.currentTarget, C = S.offsetWidth, v = S.offsetHeight, _ = window.innerWidth - C, B = window.innerHeight - v, I = Math.max(0, Math.min(b, _)), k = Math.max(0, Math.min(y, B));
10011
10016
  r(I, k);
10012
10017
  }, f = () => {
10013
- u(!1);
10018
+ d(!1);
10014
10019
  };
10015
10020
  return useEffect(() => {
10016
10021
  const x = () => {
10017
- c && u(!1);
10022
+ c && d(!1);
10018
10023
  };
10019
10024
  return window.addEventListener("mouseup", x), () => window.removeEventListener("mouseup", x);
10020
10025
  }, [c]), !n || n.x < 0 || n.y < 0 ? null : /* @__PURE__ */ jsxs(
@@ -10203,7 +10208,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10203
10208
  let i = a.get(n);
10204
10209
  return i || (i = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, a.set(n, i), l == null || l(o, n)), i;
10205
10210
  }, flushCallbacks = (o) => {
10206
- const n = getBuildingBlocks(o), r = n[1], a = n[3], l = n[4], i = n[5], c = n[6], u = n[13], p = [], d = (g) => {
10211
+ const n = getBuildingBlocks(o), r = n[1], a = n[3], l = n[4], i = n[5], c = n[6], d = n[13], p = [], u = (g) => {
10207
10212
  try {
10208
10213
  g();
10209
10214
  } catch (m) {
@@ -10211,30 +10216,30 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10211
10216
  }
10212
10217
  };
10213
10218
  do {
10214
- c.f && d(c.f);
10219
+ c.f && u(c.f);
10215
10220
  const g = /* @__PURE__ */ new Set(), m = g.add.bind(g);
10216
10221
  a.forEach((h) => {
10217
10222
  var f;
10218
10223
  return (f = r.get(h)) == null ? void 0 : f.l.forEach(m);
10219
- }), a.clear(), i.forEach(m), i.clear(), l.forEach(m), l.clear(), g.forEach(d), a.size && u(o);
10224
+ }), a.clear(), i.forEach(m), i.clear(), l.forEach(m), l.clear(), g.forEach(u), a.size && d(o);
10220
10225
  } while (a.size || i.size || l.size);
10221
10226
  if (p.length)
10222
10227
  throw new AggregateError(p);
10223
10228
  }, recomputeInvalidatedAtoms = (o) => {
10224
- const n = getBuildingBlocks(o), r = n[1], a = n[2], l = n[3], i = n[11], c = n[14], u = n[17], p = [], d = /* @__PURE__ */ new WeakSet(), g = /* @__PURE__ */ new WeakSet(), m = Array.from(l);
10229
+ const n = getBuildingBlocks(o), r = n[1], a = n[2], l = n[3], i = n[11], c = n[14], d = n[17], p = [], u = /* @__PURE__ */ new WeakSet(), g = /* @__PURE__ */ new WeakSet(), m = Array.from(l);
10225
10230
  for (; m.length; ) {
10226
10231
  const h = m[m.length - 1], f = i(o, h);
10227
10232
  if (g.has(h)) {
10228
10233
  m.pop();
10229
10234
  continue;
10230
10235
  }
10231
- if (d.has(h)) {
10236
+ if (u.has(h)) {
10232
10237
  a.get(h) === f.n && p.push([h, f]), g.add(h), m.pop();
10233
10238
  continue;
10234
10239
  }
10235
- d.add(h);
10240
+ u.add(h);
10236
10241
  for (const x of getMountedOrPendingDependents(h, f, r))
10237
- d.has(x) || m.push(x);
10242
+ u.has(x) || m.push(x);
10238
10243
  }
10239
10244
  for (let h = p.length - 1; h >= 0; --h) {
10240
10245
  const [f, x] = p[h];
@@ -10244,11 +10249,11 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10244
10249
  b = !0;
10245
10250
  break;
10246
10251
  }
10247
- b && (c(o, f), u(o, f)), a.delete(f);
10252
+ b && (c(o, f), d(o, f)), a.delete(f);
10248
10253
  }
10249
10254
  }, readAtomState = (o, n) => {
10250
10255
  var r;
10251
- const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], u = a[6], p = a[7], d = a[11], g = a[12], m = a[13], h = a[14], f = a[16], x = a[17], b = d(o, n);
10256
+ const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], d = a[6], p = a[7], u = a[11], g = a[12], m = a[13], h = a[14], f = a[16], x = a[17], b = u(o, n);
10252
10257
  if (isAtomStateInitialized(b) && (l.has(n) && i.get(n) !== b.n || Array.from(b.d).every(
10253
10258
  ([k, A]) => (
10254
10259
  // Recursively, read the atom state of the dependency, and
@@ -10259,13 +10264,13 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10259
10264
  return b;
10260
10265
  b.d.clear();
10261
10266
  let y = !0;
10262
- function C() {
10267
+ function S() {
10263
10268
  l.has(n) && (x(o, n), m(o), g(o));
10264
10269
  }
10265
- function S(k) {
10270
+ function C(k) {
10266
10271
  var A;
10267
10272
  if (isSelfAtom(n, k)) {
10268
- const E = d(o, k);
10273
+ const E = u(o, k);
10269
10274
  if (!isAtomStateInitialized(E))
10270
10275
  if (hasInitialValue(k))
10271
10276
  setAtomStateValueOrPromise(o, k, k.init);
@@ -10273,17 +10278,17 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10273
10278
  throw new Error("no atom init");
10274
10279
  return returnAtomValue(E);
10275
10280
  }
10276
- const v = h(o, k);
10281
+ const w = h(o, k);
10277
10282
  try {
10278
- return returnAtomValue(v);
10283
+ return returnAtomValue(w);
10279
10284
  } finally {
10280
- b.d.set(k, v.n), isPendingPromise(b.v) && addPendingPromiseToDependency(n, b.v, v), (A = l.get(k)) == null || A.t.add(n), y || C();
10285
+ b.d.set(k, w.n), isPendingPromise(b.v) && addPendingPromiseToDependency(n, b.v, w), (A = l.get(k)) == null || A.t.add(n), y || S();
10281
10286
  }
10282
10287
  }
10283
- let w, _;
10288
+ let v, _;
10284
10289
  const B = {
10285
10290
  get signal() {
10286
- return w || (w = new AbortController()), w.signal;
10291
+ return v || (v = new AbortController()), v.signal;
10287
10292
  },
10288
10293
  get setSelf() {
10289
10294
  return !_ && isActuallyWritableAtom(n) && (_ = (...k) => {
@@ -10297,39 +10302,39 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10297
10302
  }
10298
10303
  }, I = b.n;
10299
10304
  try {
10300
- const k = p(o, n, S, B);
10301
- return setAtomStateValueOrPromise(o, n, k), isPromiseLike$1(k) && (registerAbortHandler(k, () => w == null ? void 0 : w.abort()), k.then(C, C)), b;
10305
+ const k = p(o, n, C, B);
10306
+ return setAtomStateValueOrPromise(o, n, k), isPromiseLike$1(k) && (registerAbortHandler(k, () => v == null ? void 0 : v.abort()), k.then(S, S)), b;
10302
10307
  } catch (k) {
10303
10308
  return delete b.v, b.e = k, ++b.n, b;
10304
10309
  } finally {
10305
- y = !1, I !== b.n && i.get(n) === I && (i.set(n, b.n), c.add(n), (r = u.c) == null || r.call(u, n));
10310
+ y = !1, I !== b.n && i.get(n) === I && (i.set(n, b.n), c.add(n), (r = d.c) == null || r.call(d, n));
10306
10311
  }
10307
10312
  }, invalidateDependents = (o, n) => {
10308
10313
  const r = getBuildingBlocks(o), a = r[1], l = r[2], i = r[11], c = [n];
10309
10314
  for (; c.length; ) {
10310
- const u = c.pop(), p = i(o, u);
10311
- for (const d of getMountedOrPendingDependents(u, p, a)) {
10312
- const g = i(o, d);
10313
- l.set(d, g.n), c.push(d);
10315
+ const d = c.pop(), p = i(o, d);
10316
+ for (const u of getMountedOrPendingDependents(d, p, a)) {
10317
+ const g = i(o, u);
10318
+ l.set(u, g.n), c.push(u);
10314
10319
  }
10315
10320
  }
10316
10321
  }, writeAtomState = (o, n, ...r) => {
10317
- const a = getBuildingBlocks(o), l = a[3], i = a[6], c = a[8], u = a[11], p = a[12], d = a[13], g = a[14], m = a[15], h = a[17];
10322
+ const a = getBuildingBlocks(o), l = a[3], i = a[6], c = a[8], d = a[11], p = a[12], u = a[13], g = a[14], m = a[15], h = a[17];
10318
10323
  let f = !0;
10319
- const x = (y) => returnAtomValue(g(o, y)), b = (y, ...C) => {
10320
- var S;
10321
- const w = u(o, y);
10324
+ const x = (y) => returnAtomValue(g(o, y)), b = (y, ...S) => {
10325
+ var C;
10326
+ const v = d(o, y);
10322
10327
  try {
10323
10328
  if (isSelfAtom(n, y)) {
10324
10329
  if (!hasInitialValue(y))
10325
10330
  throw new Error("atom not writable");
10326
- const _ = w.n, B = C[0];
10327
- setAtomStateValueOrPromise(o, y, B), h(o, y), _ !== w.n && (l.add(y), (S = i.c) == null || S.call(i, y), m(o, y));
10331
+ const _ = v.n, B = S[0];
10332
+ setAtomStateValueOrPromise(o, y, B), h(o, y), _ !== v.n && (l.add(y), (C = i.c) == null || C.call(i, y), m(o, y));
10328
10333
  return;
10329
10334
  } else
10330
- return writeAtomState(o, y, ...C);
10335
+ return writeAtomState(o, y, ...S);
10331
10336
  } finally {
10332
- f || (d(o), p(o));
10337
+ f || (u(o), p(o));
10333
10338
  }
10334
10339
  };
10335
10340
  try {
@@ -10339,12 +10344,12 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10339
10344
  }
10340
10345
  }, mountDependencies = (o, n) => {
10341
10346
  var r;
10342
- const a = getBuildingBlocks(o), l = a[1], i = a[3], c = a[6], u = a[11], p = a[15], d = a[18], g = a[19], m = u(o, n), h = l.get(n);
10347
+ const a = getBuildingBlocks(o), l = a[1], i = a[3], c = a[6], d = a[11], p = a[15], u = a[18], g = a[19], m = d(o, n), h = l.get(n);
10343
10348
  if (h && !isPendingPromise(m.v)) {
10344
10349
  for (const [f, x] of m.d)
10345
10350
  if (!h.d.has(f)) {
10346
- const b = u(o, f);
10347
- d(o, f).t.add(n), h.d.add(f), x !== b.n && (i.add(f), (r = c.c) == null || r.call(c, f), p(o, f));
10351
+ const b = d(o, f);
10352
+ u(o, f).t.add(n), h.d.add(f), x !== b.n && (i.add(f), (r = c.c) == null || r.call(c, f), p(o, f));
10348
10353
  }
10349
10354
  for (const f of h.d || [])
10350
10355
  if (!m.d.has(f)) {
@@ -10355,7 +10360,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10355
10360
  }
10356
10361
  }, mountAtom = (o, n) => {
10357
10362
  var r;
10358
- const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], u = a[10], p = a[11], d = a[12], g = a[13], m = a[14], h = a[16], f = p(o, n);
10363
+ const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], d = a[10], p = a[11], u = a[12], g = a[13], m = a[14], h = a[16], f = p(o, n);
10359
10364
  let x = l.get(n);
10360
10365
  if (!x) {
10361
10366
  m(o, n);
@@ -10368,19 +10373,19 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10368
10373
  }, l.set(n, x), (r = c.m) == null || r.call(c, n), isActuallyWritableAtom(n)) {
10369
10374
  const b = () => {
10370
10375
  let y = !0;
10371
- const C = (...S) => {
10376
+ const S = (...C) => {
10372
10377
  try {
10373
- return h(o, n, ...S);
10378
+ return h(o, n, ...C);
10374
10379
  } finally {
10375
- y || (g(o), d(o));
10380
+ y || (g(o), u(o));
10376
10381
  }
10377
10382
  };
10378
10383
  try {
10379
- const S = u(o, n, C);
10380
- S && (x.u = () => {
10384
+ const C = d(o, n, S);
10385
+ C && (x.u = () => {
10381
10386
  y = !0;
10382
10387
  try {
10383
- S();
10388
+ C();
10384
10389
  } finally {
10385
10390
  y = !1;
10386
10391
  }
@@ -10395,14 +10400,14 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10395
10400
  return x;
10396
10401
  }, unmountAtom = (o, n) => {
10397
10402
  var r;
10398
- const a = getBuildingBlocks(o), l = a[1], i = a[5], c = a[6], u = a[11], p = a[19], d = u(o, n);
10403
+ const a = getBuildingBlocks(o), l = a[1], i = a[5], c = a[6], d = a[11], p = a[19], u = d(o, n);
10399
10404
  let g = l.get(n);
10400
10405
  if (g && !g.l.size && !Array.from(g.t).some((m) => {
10401
10406
  var h;
10402
10407
  return (h = l.get(m)) == null ? void 0 : h.d.has(n);
10403
10408
  })) {
10404
10409
  g.u && i.add(g.u), g = void 0, l.delete(n), (r = c.u) == null || r.call(c, n);
10405
- for (const m of d.d.keys()) {
10410
+ for (const m of u.d.keys()) {
10406
10411
  const h = p(o, m);
10407
10412
  h == null || h.t.delete(n);
10408
10413
  }
@@ -10412,11 +10417,11 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10412
10417
  }, setAtomStateValueOrPromise = (o, n, r) => {
10413
10418
  const a = getBuildingBlocks(o)[11], l = a(o, n), i = "v" in l, c = l.v;
10414
10419
  if (isPromiseLike$1(r))
10415
- for (const u of l.d.keys())
10420
+ for (const d of l.d.keys())
10416
10421
  addPendingPromiseToDependency(
10417
10422
  n,
10418
10423
  r,
10419
- a(o, u)
10424
+ a(o, d)
10420
10425
  );
10421
10426
  l.v = r, delete l.e, (!i || !Object.is(c, l.v)) && (++l.n, isPromiseLike$1(c) && abortPromise(c));
10422
10427
  }, storeGet = (o, n) => {
@@ -10523,23 +10528,23 @@ const isPromiseLike = (o) => typeof (o == null ? void 0 : o.then) == "function",
10523
10528
  let r = continuablePromiseMap.get(o);
10524
10529
  return r || (r = new Promise((a, l) => {
10525
10530
  let i = o;
10526
- const c = (d) => (g) => {
10527
- i === d && a(g);
10528
- }, u = (d) => (g) => {
10529
- i === d && l(g);
10531
+ const c = (u) => (g) => {
10532
+ i === u && a(g);
10533
+ }, d = (u) => (g) => {
10534
+ i === u && l(g);
10530
10535
  }, p = () => {
10531
10536
  try {
10532
- const d = n();
10533
- isPromiseLike(d) ? (continuablePromiseMap.set(d, r), i = d, d.then(c(d), u(d)), registerAbortHandler(d, p)) : a(d);
10534
- } catch (d) {
10535
- l(d);
10537
+ const u = n();
10538
+ isPromiseLike(u) ? (continuablePromiseMap.set(u, r), i = u, u.then(c(u), d(u)), registerAbortHandler(u, p)) : a(u);
10539
+ } catch (u) {
10540
+ l(u);
10536
10541
  }
10537
10542
  };
10538
- o.then(c(o), u(o)), registerAbortHandler(o, p);
10543
+ o.then(c(o), d(o)), registerAbortHandler(o, p);
10539
10544
  }), continuablePromiseMap.set(o, r)), r;
10540
10545
  };
10541
10546
  function useAtomValue(o, n) {
10542
- const { delay: r, unstable_promiseStatus: a = !React__default.use } = {}, l = useStore(), [[i, c, u], p] = useReducer(
10547
+ const { delay: r, unstable_promiseStatus: a = !React__default.use } = {}, l = useStore(), [[i, c, d], p] = useReducer(
10543
10548
  (g) => {
10544
10549
  const m = l.get(o);
10545
10550
  return Object.is(g[0], m) && g[1] === l && g[2] === o ? g : [m, l, o];
@@ -10547,8 +10552,8 @@ function useAtomValue(o, n) {
10547
10552
  void 0,
10548
10553
  () => [l.get(o), l, o]
10549
10554
  );
10550
- let d = i;
10551
- if ((c !== l || u !== o) && (p(), d = l.get(o)), useEffect(() => {
10555
+ let u = i;
10556
+ if ((c !== l || d !== o) && (p(), u = l.get(o)), useEffect(() => {
10552
10557
  const g = l.sub(o, () => {
10553
10558
  if (a)
10554
10559
  try {
@@ -10565,11 +10570,11 @@ function useAtomValue(o, n) {
10565
10570
  p();
10566
10571
  });
10567
10572
  return p(), g;
10568
- }, [l, o, r, a]), useDebugValue(d), isPromiseLike(d)) {
10569
- const g = createContinuablePromise(d, () => l.get(o));
10573
+ }, [l, o, r, a]), useDebugValue(u), isPromiseLike(u)) {
10574
+ const g = createContinuablePromise(u, () => l.get(o));
10570
10575
  return a && attachPromiseStatus(g), use(g);
10571
10576
  }
10572
- return d;
10577
+ return u;
10573
10578
  }
10574
10579
  function useSetAtom(o, n) {
10575
10580
  const r = useStore();
@@ -10586,10 +10591,10 @@ function useAtom(o, n) {
10586
10591
  ];
10587
10592
  }
10588
10593
  function domToJsx(o, n = 0) {
10589
- var d;
10594
+ var u;
10590
10595
  const r = " ".repeat(n);
10591
10596
  if (o.nodeType === Node.TEXT_NODE) {
10592
- const g = (d = o.textContent) == null ? void 0 : d.trim();
10597
+ const g = (u = o.textContent) == null ? void 0 : u.trim();
10593
10598
  return g ? `${r}${g}
10594
10599
  ` : "";
10595
10600
  }
@@ -10623,10 +10628,10 @@ function domToJsx(o, n = 0) {
10623
10628
  } else if (h.name === "style" && h.value) {
10624
10629
  const f = h.value.split(";").reduce(
10625
10630
  (x, b) => {
10626
- const [y, C] = b.split(":").map((S) => S.trim());
10627
- if (y && C) {
10628
- const S = y.replace(/-([a-z])/g, (w) => w[1].toUpperCase());
10629
- x[S] = C.replace(/['"]/g, "");
10631
+ const [y, S] = b.split(":").map((C) => C.trim());
10632
+ if (y && S) {
10633
+ const C = y.replace(/-([a-z])/g, (v) => v[1].toUpperCase());
10634
+ x[C] = S.replace(/['"]/g, "");
10630
10635
  }
10631
10636
  return x;
10632
10637
  },
@@ -10654,7 +10659,7 @@ function domToJsx(o, n = 0) {
10654
10659
  (h, f) => {
10655
10660
  const [x, b] = f.split(":").map((y) => y.trim());
10656
10661
  if (x && b) {
10657
- const y = x.replace(/-([a-z])/g, (C) => C[1].toUpperCase());
10662
+ const y = x.replace(/-([a-z])/g, (S) => S[1].toUpperCase());
10658
10663
  h[y] = b.replace(/['"]/g, "");
10659
10664
  }
10660
10665
  return h;
@@ -10665,8 +10670,8 @@ function domToJsx(o, n = 0) {
10665
10670
  } else
10666
10671
  c.push(`${g.name}="${g.value}"`);
10667
10672
  c.length > 0 && (i += " " + c.join(" "));
10668
- const u = Array.from(o.childNodes);
10669
- if (!u.some((g) => {
10673
+ const d = Array.from(o.childNodes);
10674
+ if (!d.some((g) => {
10670
10675
  var m;
10671
10676
  return g.nodeType === Node.TEXT_NODE ? (m = g.textContent) == null ? void 0 : m.trim() : !0;
10672
10677
  }))
@@ -10675,7 +10680,7 @@ function domToJsx(o, n = 0) {
10675
10680
  else {
10676
10681
  i += `>
10677
10682
  `;
10678
- for (const g of u)
10683
+ for (const g of d)
10679
10684
  i += domToJsx(g, n + 1);
10680
10685
  i += `${r}</${a}>
10681
10686
  `;
@@ -10710,7 +10715,7 @@ const getExportedCoded = async ({
10710
10715
  isTypeScript: r = !1
10711
10716
  }) => {
10712
10717
  let a = (o == null ? void 0 : o._name) || (o == null ? void 0 : o._type) || "Component";
10713
- a = camelCase(a).replace(/^./, (d) => d.toUpperCase());
10718
+ a = camelCase(a).replace(/^./, (u) => u.toUpperCase());
10714
10719
  const l = " ";
10715
10720
  let { jsx: i, html: c } = await convertHtmlToJsx(n);
10716
10721
  return i = i == null ? void 0 : i.split(`
@@ -10723,8 +10728,8 @@ ${l}${l}${i == null ? void 0 : i.trimEnd()}
10723
10728
  ${l})
10724
10729
  }`, { jsx: i, html: formatHtml(c), componentName: a };
10725
10730
  }, ExportCodeModalContent = ({ tab: o }) => {
10726
- var C;
10727
- const { t: n } = useTranslation(), [r, a] = useState({ html: "", jsx: "" }), l = useSelectedBlock(), i = useBlocksHtmlForAi(), [c, u] = useState(""), [p, d] = useState(!1), g = () => {
10731
+ var S;
10732
+ const { t: n } = useTranslation(), [r, a] = useState({ html: "", jsx: "" }), l = useSelectedBlock(), i = useBlocksHtmlForAi(), [c, d] = useState(""), [p, u] = useState(!1), g = () => {
10728
10733
  switch (o) {
10729
10734
  case "js":
10730
10735
  return `${c}.jsx`;
@@ -10747,51 +10752,51 @@ ${l})
10747
10752
  }
10748
10753
  }, h = useCallback(async () => {
10749
10754
  try {
10750
- d(!1), await new Promise((k) => setTimeout(k, 1e3));
10751
- const S = i({ EXTRA_CORE_BLOCKS: ["Icon"] }), w = o === "ts", {
10755
+ u(!1), await new Promise((k) => setTimeout(k, 1e3));
10756
+ const C = i({ EXTRA_CORE_BLOCKS: ["Icon"] }), v = o === "ts", {
10752
10757
  jsx: _,
10753
10758
  html: B,
10754
10759
  componentName: I
10755
10760
  } = await getExportedCoded({
10756
10761
  selectedBlock: l,
10757
- html: S,
10758
- isTypeScript: w
10762
+ html: C,
10763
+ isTypeScript: v
10759
10764
  });
10760
- a({ html: B, jsx: _ }), u(I), d(!0);
10765
+ a({ html: B, jsx: _ }), d(I), u(!0);
10761
10766
  } catch {
10762
- const w = "<div>Export failed. Close the modal and try again.</div>";
10763
- a({ html: w, jsx: w }), toast.error(n("Failed to generate export HTML"));
10767
+ const v = "<div>Export failed. Close the modal and try again.</div>";
10768
+ a({ html: v, jsx: v }), toast.error(n("Failed to generate export HTML"));
10764
10769
  }
10765
10770
  }, [n, o, l, i]);
10766
10771
  useEffect(() => {
10767
10772
  h();
10768
10773
  }, [h, o]);
10769
10774
  const f = useCallback(
10770
- async (S) => {
10775
+ async (C) => {
10771
10776
  try {
10772
- navigator.clipboard.writeText(S), toast.success(n("Export code copied!"));
10777
+ navigator.clipboard.writeText(C), toast.success(n("Export code copied!"));
10773
10778
  } catch {
10774
10779
  toast.error(n("Failed to copy export code"));
10775
10780
  }
10776
10781
  },
10777
10782
  [n]
10778
- ), x = (S) => {
10779
- const w = new Blob([S], { type: "text/jsx" }), _ = URL.createObjectURL(w), B = document.createElement("a");
10783
+ ), x = (C) => {
10784
+ const v = new Blob([C], { type: "text/jsx" }), _ = URL.createObjectURL(v), B = document.createElement("a");
10780
10785
  B.href = _, B.download = g(), document.body.appendChild(B), B.click(), URL.revokeObjectURL(_), document.body.removeChild(B), toast.success(n("Export code downloaded successfully!"));
10781
10786
  }, b = /* @__PURE__ */ jsxs("span", { children: [
10782
10787
  "Download ",
10783
10788
  /* @__PURE__ */ jsx("span", { className: "font-mono text-xs font-light text-gray-300", children: g() })
10784
10789
  ] }), y = useMemo(() => {
10785
- const S = { extend: shadcnTheme() }, w = JSON.stringify(S, null, 2);
10790
+ const C = { extend: shadcnTheme() }, v = JSON.stringify(C, null, 2);
10786
10791
  return `{
10787
10792
  // Your tailwind config ...
10788
10793
 
10789
- "theme": ${w == null ? void 0 : w.split(`
10794
+ "theme": ${v == null ? void 0 : v.split(`
10790
10795
  `).join(`
10791
10796
  `)},
10792
10797
  }`;
10793
10798
  }, []);
10794
- return ((C = r == null ? void 0 : r.jsx) == null ? void 0 : C.length) > 0 && p ? /* @__PURE__ */ jsx(
10799
+ return ((S = r == null ? void 0 : r.jsx) == null ? void 0 : S.length) > 0 && p ? /* @__PURE__ */ jsx(
10795
10800
  CodeDisplay,
10796
10801
  {
10797
10802
  onCopy: f,
@@ -10857,8 +10862,8 @@ ${l})
10857
10862
  }, [o.locale]), useEffect(() => {
10858
10863
  setDebugLogs(o.debugLogs);
10859
10864
  }, [o.debugLogs]), useEffect(() => {
10860
- o.translations && each(o.translations, (c, u) => {
10861
- i18n.addResourceBundle(u, "translation", c, !0, !0);
10865
+ o.translations && each(o.translations, (c, d) => {
10866
+ i18n.addResourceBundle(d, "translation", c, !0, !0);
10862
10867
  });
10863
10868
  }, [o.translations]), useEffect(() => (a !== "SAVED" ? window.onbeforeunload = () => "" : window.onbeforeunload = null, () => {
10864
10869
  window.onbeforeunload = null;