@chaibuilder/sdk 3.2.2 → 3.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -109,18 +109,18 @@ class PubSub {
109
109
  }
110
110
  }
111
111
  const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
112
- const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: i } = usePermissions(), l = 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: l }), g = (m) => {
112
+ const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: i } = usePermissions(), l = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (m) => c ? get(m, "_parent") === c : !get(m, "_parent")), u = canAddChildBlock(get(o, "_type", "")), p = findIndex(d, { _id: l }), g = (m) => {
113
113
  if (m === "CHILD")
114
114
  pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
115
115
  else {
116
116
  const f = { _id: c || "", position: d == null ? void 0 : d.length };
117
- m === "BEFORE" ? f.position = Math.max(u, 0) : m === "AFTER" && (f.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, f);
117
+ m === "BEFORE" ? f.position = Math.max(p, 0) : m === "AFTER" && (f.position = p + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, f);
118
118
  }
119
119
  };
120
120
  return i(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
121
121
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { children: n }),
122
122
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-500 bg-primary text-white shadow-2xl", children: [
123
- p && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("CHILD"), children: r("Add inside") }),
123
+ u && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("CHILD"), children: r("Add inside") }),
124
124
  /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("BEFORE"), children: r("Add before") }),
125
125
  /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("AFTER"), children: r("Add after") })
126
126
  ] })
@@ -203,16 +203,16 @@ function insertBlocksAtPosition(o, n, r, a) {
203
203
  const i = [...n];
204
204
  let l = [...o];
205
205
  if (r) {
206
- const u = o.find((g) => g._id === r);
207
- if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
206
+ const p = o.find((g) => g._id === r);
207
+ if (p && p.content !== void 0 && p.content !== "" && !o.some((m) => m._parent === r)) {
208
208
  const f = {
209
209
  _id: generateUUID(),
210
210
  _parent: r,
211
211
  _type: "Text",
212
- content: u.content
212
+ content: p.content
213
213
  };
214
- Object.keys(u).forEach((h) => {
215
- h.startsWith("content-") && (f[h] = u[h]);
214
+ Object.keys(p).forEach((h) => {
215
+ h.startsWith("content-") && (f[h] = p[h]);
216
216
  }), i.unshift(f), l = l.map((h) => {
217
217
  if (h._id === r) {
218
218
  const x = { ...h, content: "" };
@@ -224,22 +224,22 @@ function insertBlocksAtPosition(o, n, r, a) {
224
224
  });
225
225
  }
226
226
  }
227
- let c = l.filter((u) => !u._parent);
228
- r && (c = l.filter((u) => u._parent === r));
227
+ let c = l.filter((p) => !p._parent);
228
+ r && (c = l.filter((p) => p._parent === r));
229
229
  const d = !isNaN(a) || a > -1 ? Math.min(a, c.length) : c.length;
230
- let p = l.length;
231
- for (let u = 0, g = 0; u < l.length; u++)
232
- if (r !== void 0 ? l[u]._parent === r : !l[u]._parent) {
230
+ let u = l.length;
231
+ for (let p = 0, g = 0; p < l.length; p++)
232
+ if (r !== void 0 ? l[p]._parent === r : !l[p]._parent) {
233
233
  if (g === d) {
234
- p = u;
234
+ u = p;
235
235
  break;
236
236
  }
237
237
  g++;
238
238
  }
239
- return !r && a !== void 0 && a >= c.length && (p = l.length), [
240
- ...l.slice(0, p),
239
+ return !r && a !== void 0 && a >= c.length && (u = l.length), [
240
+ ...l.slice(0, u),
241
241
  ...i,
242
- ...l.slice(p)
242
+ ...l.slice(u)
243
243
  ];
244
244
  }
245
245
  function getBlocksTree(o) {
@@ -253,15 +253,15 @@ function findNodeById(o, n) {
253
253
  return o.first((r) => r.model._id === n) || null;
254
254
  }
255
255
  function moveNode(o, n, r, a) {
256
- var u, g;
256
+ var p, g;
257
257
  const i = findNodeById(o, n), l = findNodeById(o, r);
258
258
  if (!i || !l) return !1;
259
259
  l.children || (l.model.children = []);
260
- let c = (u = l == null ? void 0 : l.children) == null ? void 0 : u.findIndex((m) => m.model._id === n);
260
+ let c = (p = l == null ? void 0 : l.children) == null ? void 0 : p.findIndex((m) => m.model._id === n);
261
261
  i.drop(), c = Math.max(c, 0);
262
- const p = (((g = i == null ? void 0 : i.model) == null ? void 0 : g._parent) || "root") === r && c <= a ? a - 1 : a;
262
+ const u = (((g = i == null ? void 0 : i.model) == null ? void 0 : g._parent) || "root") === r && c <= a ? a - 1 : a;
263
263
  try {
264
- l.addChildAtIndex(i, p);
264
+ l.addChildAtIndex(i, u);
265
265
  } catch (m) {
266
266
  return console.error("Error adding child to parent:", m), !1;
267
267
  }
@@ -277,10 +277,10 @@ function handleOldParentTextBlock(o, n) {
277
277
  if (l && l._type === "Text" && "content" in a)
278
278
  return o.map((d) => {
279
279
  if (d._id === r) {
280
- const p = { ...d, content: l.content };
281
- return Object.keys(l).forEach((u) => {
282
- u.startsWith("content-") && (p[u] = l[u]);
283
- }), p;
280
+ const u = { ...d, content: l.content };
281
+ return Object.keys(l).forEach((p) => {
282
+ p.startsWith("content-") && (u[p] = l[p]);
283
+ }), u;
284
284
  }
285
285
  return d;
286
286
  }).filter((d) => d._id !== l._id);
@@ -298,32 +298,32 @@ function handleNewParentTextBlock(o, n, r) {
298
298
  _type: "Text",
299
299
  content: a.content
300
300
  };
301
- Object.keys(a).forEach((u) => {
302
- u.startsWith("content-") && (c[u] = a[u]);
301
+ Object.keys(a).forEach((p) => {
302
+ p.startsWith("content-") && (c[p] = a[p]);
303
303
  });
304
- const d = o.map((u) => {
305
- if (u._id === r) {
306
- const g = { ...u, content: "" };
304
+ const d = o.map((p) => {
305
+ if (p._id === r) {
306
+ const g = { ...p, content: "" };
307
307
  return Object.keys(g).forEach((m) => {
308
308
  m.startsWith("content-") && (g[m] = "");
309
309
  }), g;
310
310
  }
311
- return u;
312
- }), p = d.findIndex((u) => u._id === n._id);
313
- return p !== -1 ? [...d.slice(0, p), c, ...d.slice(p)] : [c, ...d];
311
+ return p;
312
+ }), u = d.findIndex((p) => p._id === n._id);
313
+ return u !== -1 ? [...d.slice(0, u), c, ...d.slice(u)] : [c, ...d];
314
314
  }
315
315
  return o;
316
316
  }
317
317
  function moveBlocksWithChildren(o, n, r, a) {
318
318
  if (!n) return o;
319
- const i = o.find((u) => u._id === n);
319
+ const i = o.find((p) => p._id === n);
320
320
  if (!i) return o;
321
321
  let l = handleOldParentTextBlock(o, i);
322
- const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(l) });
323
- if (moveNode(p, n, c, a)) {
324
- let u = flattenTree(p);
325
- const g = u.find((m) => m._id === n);
326
- return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, i, r)), u;
322
+ const c = r || "root", u = new TreeModel().parse({ _id: "root", children: getBlocksTree(l) });
323
+ if (moveNode(u, n, c, a)) {
324
+ let p = flattenTree(u);
325
+ const g = p.find((m) => m._id === n);
326
+ return g && (g._parent = c === "root" ? null : c), p.shift(), r && (p = handleNewParentTextBlock(p, i, r)), p;
327
327
  }
328
328
  return l;
329
329
  }
@@ -397,15 +397,15 @@ const useSelectedBlocksDisplayChild = () => ({
397
397
  }, removeNestedBlocks = (o, n) => {
398
398
  let r = [...o], a = [];
399
399
  n.forEach((d) => {
400
- const p = r.find((m) => m._id === d);
401
- if (!p || !p._parent) return;
402
- const u = p._parent, g = r.filter((m) => m._parent === u);
400
+ const u = r.find((m) => m._id === d);
401
+ if (!u || !u._parent) return;
402
+ const p = u._parent, g = r.filter((m) => m._parent === p);
403
403
  if (g.length === 2) {
404
404
  const m = g.find((f) => f._id !== d);
405
405
  if (m && m._type === "Text") {
406
- const f = r.find((h) => h._id === u);
406
+ const f = r.find((h) => h._id === p);
407
407
  f && "content" in f && (r = r.map((h) => {
408
- if (h._id === u) {
408
+ if (h._id === p) {
409
409
  const x = { ...h, content: m.content };
410
410
  return Object.keys(m).forEach((b) => {
411
411
  b.startsWith("content-") && (x[b] = m[b]);
@@ -485,25 +485,25 @@ const useSelectedBlocksDisplayChild = () => ({
485
485
  description: "Prevents interactive elements (links, buttons with href) from being nested inside other interactive elements",
486
486
  validate: (o, n) => {
487
487
  const r = [], a = (l, c = !1, d = []) => {
488
- l.forEach((p) => {
489
- const u = [...d, p._id], g = p._type === "Link", m = p._type === "Button" && p.link && p.link.href && p.link.href.trim() !== "", f = g || m;
488
+ l.forEach((u) => {
489
+ const p = [...d, u._id], g = u._type === "Link", m = u._type === "Button" && u.link && u.link.href && u.link.href.trim() !== "", f = g || m;
490
490
  if (f && c) {
491
491
  const h = g ? "Link" : "Button with href";
492
492
  r.push({
493
- id: `nested-interactive-tree-${p._id}`,
493
+ id: `nested-interactive-tree-${u._id}`,
494
494
  message: `${h} cannot be nested inside another interactive element (link or button with href)`,
495
495
  severity: "error",
496
- blockId: p._id
496
+ blockId: u._id
497
497
  });
498
498
  }
499
- p.children && p.children.length > 0 && a(p.children, f, u);
499
+ u.children && u.children.length > 0 && a(u.children, f, p);
500
500
  });
501
501
  }, i = (l) => {
502
502
  l.filter((d) => d._type === "Link" || d._type === "Button" && d.link && d.link.href && d.link.href.trim() !== "").forEach((d) => {
503
503
  if (d._parent) {
504
- const p = l.find((f) => f._id === d._parent), u = p && p._type === "Link", g = p && p._type === "Button" && p.link && p.link.href && p.link.href.trim() !== "";
505
- if (u || g) {
506
- const f = d._type === "Link" ? "Link" : "Button with href", h = u ? "Link" : "Button with href";
504
+ const u = l.find((f) => f._id === d._parent), p = u && u._type === "Link", g = u && u._type === "Button" && u.link && u.link.href && u.link.href.trim() !== "";
505
+ if (p || g) {
506
+ const f = d._type === "Link" ? "Link" : "Button with href", h = p ? "Link" : "Button with href";
507
507
  r.push({
508
508
  id: `nested-interactive-parent-${d._id}`,
509
509
  message: `${f} cannot be nested inside ${h}`,
@@ -511,7 +511,7 @@ const useSelectedBlocksDisplayChild = () => ({
511
511
  blockId: d._id
512
512
  });
513
513
  }
514
- let m = p;
514
+ let m = u;
515
515
  for (; m && m._parent; ) {
516
516
  const f = l.find((h) => h._id === m._parent);
517
517
  if (f) {
@@ -560,8 +560,8 @@ const useSelectedBlocksDisplayChild = () => ({
560
560
  i.forEach((c) => {
561
561
  const d = [...l, c._type];
562
562
  if (c._type === "TableCell") {
563
- const p = d.includes("TableRow"), u = d.includes("TableHead") || d.includes("TableBody"), g = d.includes("Table");
564
- (!p || !u || !g) && r.push({
563
+ const u = d.includes("TableRow"), p = d.includes("TableHead") || d.includes("TableBody"), g = d.includes("Table");
564
+ (!u || !p || !g) && r.push({
565
565
  id: `table-cell-structure-${c._id}`,
566
566
  message: "Table Cell must be inside a Table Row, which must be inside Table Head/Body, which must be inside a Table",
567
567
  severity: "error",
@@ -615,8 +615,8 @@ const useSelectedBlocksDisplayChild = () => ({
615
615
  severity: "error",
616
616
  blockId: c._id
617
617
  }), c.children && c.children.length > 0) {
618
- const p = d ? [...l, c._id] : l;
619
- a(c.children, p);
618
+ const u = d ? [...l, c._id] : l;
619
+ a(c.children, u);
620
620
  }
621
621
  });
622
622
  };
@@ -630,8 +630,8 @@ const useSelectedBlocksDisplayChild = () => ({
630
630
  const r = [], a = [], i = (l, c = []) => {
631
631
  l.forEach((d) => {
632
632
  if (d._type === "Heading") {
633
- const p = d.tag || "h2", u = parseInt(p.replace("h", "")) || 2;
634
- a.push({ level: u, blockId: d._id, path: [...c, d._id] });
633
+ const u = d.tag || "h2", p = parseInt(u.replace("h", "")) || 2;
634
+ a.push({ level: p, blockId: d._id, path: [...c, d._id] });
635
635
  }
636
636
  d.children && d.children.length > 0 && i(d.children, [...c, d._id]);
637
637
  });
@@ -710,13 +710,13 @@ const defaultRuleRegistry = new StructureRuleRegistry(), useCheckStructure = (o
710
710
  const n = useBuilderProp("flags.validateStructure", !0), r = useSetAtom$1(structureErrorsAtom), a = useSetAtom$1(structureValidationValidAtom), i = useSetAtom$1(hasStructureErrorsAtom), l = useSetAtom$1(hasStructureWarningsAtom);
711
711
  return useCallback(
712
712
  (d) => {
713
- const p = d;
714
- if (!n || p.length === 0) return;
715
- const u = convertToBlocksTree(p), g = [];
713
+ const u = d;
714
+ if (!n || u.length === 0) return;
715
+ const p = convertToBlocksTree(u), g = [];
716
716
  let m = defaultRuleRegistry.getRules();
717
717
  o.enableAccessibilityRules && (defaultRuleRegistry.enableAccessibilityRules(), m = defaultRuleRegistry.getRules()), o.customRules && o.customRules.length > 0 && m.push(...o.customRules), m.forEach((b) => {
718
718
  try {
719
- const y = b.validate(p, u);
719
+ const y = b.validate(u, p);
720
720
  g.push(...y);
721
721
  } catch (y) {
722
722
  console.error(`Error running structure rule "${b.name}":`, y);
@@ -741,9 +741,9 @@ const defaultRuleRegistry = new StructureRuleRegistry(), useCheckStructure = (o
741
741
  o(l), n({ type: "blocks-updated", blocks: l });
742
742
  },
743
743
  addBlocks: (l, c, d) => {
744
- o((p) => {
745
- const u = insertBlocksAtPosition(p, l, c, d);
746
- return n({ type: "blocks-updated", blocks: u }), a(u), i(), u;
744
+ o((u) => {
745
+ const p = insertBlocksAtPosition(u, l, c, d);
746
+ return n({ type: "blocks-updated", blocks: p }), a(p), i(), p;
747
747
  });
748
748
  },
749
749
  removeBlocks: (l) => {
@@ -753,14 +753,14 @@ const defaultRuleRegistry = new StructureRuleRegistry(), useCheckStructure = (o
753
753
  });
754
754
  },
755
755
  moveBlocks: (l, c, d) => {
756
- o((p) => {
757
- let u = [...p];
756
+ o((u) => {
757
+ let p = [...u];
758
758
  for (let g = 0; g < l.length; g++)
759
- u = moveBlocksWithChildren(u, l[g], c, d);
759
+ p = moveBlocksWithChildren(p, l[g], c, d);
760
760
  return each(l, (g) => {
761
- const m = find(u, (f) => f._id === g);
761
+ const m = find(p, (f) => f._id === g);
762
762
  m && r({ id: g, props: { _parent: m._parent || null } });
763
- }), n({ type: "blocks-updated", blocks: u }), a(u), i(), u;
763
+ }), n({ type: "blocks-updated", blocks: p }), a(p), i(), p;
764
764
  });
765
765
  },
766
766
  updateBlocksProps: (l) => {
@@ -777,7 +777,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
777
777
  status: "idle",
778
778
  props: {},
779
779
  error: void 0
780
- }), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (h) => ({})), 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";
780
+ }), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (h) => ({})), u = useSetAtom$1(blockRepeaterDataAtom), p = 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";
781
781
  return useEffect(() => {
782
782
  if (n === "mock") {
783
783
  if (isFunction(a)) {
@@ -790,7 +790,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
790
790
  return;
791
791
  }
792
792
  n === "live" && (!g && !m || (l((h) => ({ ...h, status: "loading", props: {} })), d({ block: o }).then((h = {}) => {
793
- g ? (p((x) => ({
793
+ g ? (u((x) => ({
794
794
  ...x,
795
795
  [o._id]: {
796
796
  status: "loaded",
@@ -799,12 +799,12 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
799
799
  }
800
800
  })), l((x) => ({ ...x, status: "loaded", props: { totalItems: get(h, "totalItems") } })), c([o._id], { totalItems: get(h, "totalItems") })) : l((x) => ({ ...x, status: "loaded", props: isObject(h) ? h : {} }));
801
801
  }).catch((h) => {
802
- g ? (p((x) => ({
802
+ g ? (u((x) => ({
803
803
  ...x,
804
804
  [o._id]: { status: "error", error: h, props: [] }
805
805
  })), l((x) => ({ ...x, status: "error", error: h, props: {} }))) : l((x) => ({ ...x, status: "error", error: h, props: {} }));
806
806
  })));
807
- }, [o == null ? void 0 : o._id, u, g, m, a, n]), {
807
+ }, [o == null ? void 0 : o._id, p, g, m, a, n]), {
808
808
  $loading: get(i, "status") === "loading",
809
809
  ...o ? get(i, "props", {}) : {}
810
810
  };
@@ -960,13 +960,13 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
960
960
  }
961
961
  }) : !1, useSavePage = () => {
962
962
  const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (y) => {
963
- }), a = useBuilderProp("onSaveStateChange", noop), i = useGetPageData(), [l] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), [u] = useIsPageLoaded(), g = useAtomValue$1(chaiDesignTokensAtom), m = useCheckStructure(), [, f] = useAtom$1(userActionsCountAtom), h = () => {
963
+ }), a = useBuilderProp("onSaveStateChange", noop), i = useGetPageData(), [l] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: u } = useLanguages(), [p] = useIsPageLoaded(), g = useAtomValue$1(chaiDesignTokensAtom), m = useCheckStructure(), [, f] = useAtom$1(userActionsCountAtom), h = () => {
964
964
  const y = i();
965
- return !d || d === p ? !1 : checkMissingTranslations(y.blocks || [], d);
965
+ return !d || d === u ? !1 : checkMissingTranslations(y.blocks || [], d);
966
966
  };
967
967
  return { savePage: useThrottledCallback(
968
968
  async (y = !1, C = !1) => {
969
- if (!C && (!c("save_page") || !u))
969
+ if (!C && (!c("save_page") || !p))
970
970
  return;
971
971
  const k = i();
972
972
  return k != null && k.blocks && m(k.blocks), n("SAVING"), a("SAVING"), f(0), await r({
@@ -987,13 +987,13 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
987
987
  f,
988
988
  r,
989
989
  a,
990
- u,
990
+ p,
991
991
  m
992
992
  ],
993
993
  3e3
994
994
  // save only every 5 seconds
995
995
  ), savePageAsync: async (y = !1) => {
996
- if (!y && (!c("save_page") || !u))
996
+ if (!y && (!c("save_page") || !p))
997
997
  return;
998
998
  n("SAVING"), a("SAVING");
999
999
  const C = i();
@@ -1014,25 +1014,25 @@ const undoRedoStateAtom = atom({
1014
1014
  canRedo: !1
1015
1015
  }), useUndoManager = () => {
1016
1016
  const [, o] = useAtom$1(builderSaveStateAtom), [n, r] = useAtom$1(undoRedoStateAtom), a = useBuilderProp("onSaveStateChange", noop), i = useCallback(() => {
1017
- const u = {
1017
+ const p = {
1018
1018
  canUndo: undoManager.hasUndo(),
1019
1019
  canRedo: undoManager.hasRedo()
1020
1020
  };
1021
- r(u), o("UNSAVED"), a("UNSAVED");
1021
+ r(p), o("UNSAVED"), a("UNSAVED");
1022
1022
  }, [r, o, a]);
1023
1023
  useEffect(() => (undoManager.setCallback(i), () => {
1024
1024
  undoManager.setCallback(noop);
1025
1025
  }), [i]);
1026
1026
  const l = useCallback(
1027
- (u) => {
1028
- undoManager.add(u), i();
1027
+ (p) => {
1028
+ undoManager.add(p), i();
1029
1029
  },
1030
1030
  [i]
1031
1031
  ), c = useCallback(() => {
1032
1032
  undoManager.undo(), i();
1033
1033
  }, [i]), d = useCallback(() => {
1034
1034
  undoManager.redo(), i();
1035
- }, [i]), p = useCallback(() => {
1035
+ }, [i]), u = useCallback(() => {
1036
1036
  undoManager.clear(), r({
1037
1037
  canUndo: !1,
1038
1038
  canRedo: !1
@@ -1045,9 +1045,9 @@ const undoRedoStateAtom = atom({
1045
1045
  redo: d,
1046
1046
  hasUndo: () => n.canUndo,
1047
1047
  hasRedo: () => n.canRedo,
1048
- clear: p
1048
+ clear: u
1049
1049
  }),
1050
- [l, c, d, n.canUndo, n.canRedo, p]
1050
+ [l, c, d, n.canUndo, n.canRedo, u]
1051
1051
  );
1052
1052
  }, useBlocksStore = () => useAtom$1(presentBlocksAtom), useBlocksStoreUndoableActions = () => {
1053
1053
  const { add: o } = useUndoManager(), [n] = useBlocksStore(), {
@@ -1091,8 +1091,8 @@ const undoRedoStateAtom = atom({
1091
1091
  else {
1092
1092
  const k = keys(b);
1093
1093
  C = map(x, (S) => {
1094
- const A = n.find((E) => E._id === S), B = { _id: S };
1095
- return each(k, (E) => B[E] = A[E]), B;
1094
+ const A = n.find((_) => _._id === S), B = { _id: S };
1095
+ return each(k, (_) => B[_] = A[_]), B;
1096
1096
  });
1097
1097
  }
1098
1098
  c(map(x, (k) => ({ _id: k, ...b }))), o({
@@ -1131,11 +1131,11 @@ const undoRedoStateAtom = atom({
1131
1131
  for (let y = 0; y < b.length; y++)
1132
1132
  b[y]._parent = l[h]._id;
1133
1133
  }
1134
- const p = first(l);
1135
- let u, g;
1136
- return c && (u = find(o, { _id: c }), l[0]._parent = c, forEach(l, (h) => {
1134
+ const u = first(l);
1135
+ let p, g;
1136
+ return c && (p = find(o, { _id: c }), l[0]._parent = c, forEach(l, (h) => {
1137
1137
  h != null && h._parent || (h._parent = c);
1138
- }), g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (l[0]._parent = u._parent, g = u._parent), r(l, g, d), n([(f = first(l)) == null ? void 0 : f._id]), first(l);
1138
+ }), g = c), !(p ? canAcceptChildBlock(p == null ? void 0 : p._type, u._type) : !0) && p && (l[0]._parent = p._parent, g = p._parent), r(l, g, d), n([(f = first(l)) == null ? void 0 : f._id]), first(l);
1139
1139
  },
1140
1140
  [r, o, n]
1141
1141
  );
@@ -1145,10 +1145,10 @@ const undoRedoStateAtom = atom({
1145
1145
  const b = l.blocks;
1146
1146
  return a(b, c, d);
1147
1147
  }
1148
- const p = generateUUID(), u = getDefaultBlockProps(l.type), g = {
1148
+ const u = generateUUID(), p = getDefaultBlockProps(l.type), g = {
1149
1149
  _type: l.type,
1150
- _id: p,
1151
- ...u,
1150
+ _id: u,
1151
+ ...p,
1152
1152
  ...has(l, "_name") && { _name: l._name },
1153
1153
  ...has(l, "partialBlockId") && { partialBlockId: l.partialBlockId }
1154
1154
  };
@@ -2264,10 +2264,10 @@ function removeDuplicateClasses(o) {
2264
2264
  for (const i of r) {
2265
2265
  const l = i.property, c = n.indexOf(i.mq);
2266
2266
  for (let d = c + 1; d < n.length; d++) {
2267
- const p = n[d], u = r.find((g) => g.property === l && g.mq === p);
2268
- if (u && u.cls === i.cls)
2269
- a = a.replace(u.fullCls, "");
2270
- else if (u && u.cls !== i.cls)
2267
+ const u = n[d], p = r.find((g) => g.property === l && g.mq === u);
2268
+ if (p && p.cls === i.cls)
2269
+ a = a.replace(p.fullCls, "");
2270
+ else if (p && p.cls !== i.cls)
2271
2271
  break;
2272
2272
  }
2273
2273
  }
@@ -2287,12 +2287,12 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), add
2287
2287
  )
2288
2288
  ), l = first(o(selectedStylingBlocksAtom));
2289
2289
  return map(i, (c) => {
2290
- const d = o(c), p = get(d, l.prop, `${STYLES_KEY},`), { classes: u } = getSplitChaiClasses(p);
2290
+ const d = o(c), u = get(d, l.prop, `${STYLES_KEY},`), { classes: p } = getSplitChaiClasses(u);
2291
2291
  return {
2292
2292
  ids: [d._id],
2293
2293
  props: {
2294
2294
  [l.prop]: `${STYLES_KEY},${orderClassesByBreakpoint(
2295
- removeDuplicateClasses(twMerge(u, a))
2295
+ removeDuplicateClasses(twMerge(p, a))
2296
2296
  )}`
2297
2297
  }
2298
2298
  };
@@ -2534,10 +2534,10 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), add
2534
2534
  const c = r[l];
2535
2535
  if (isString(c)) {
2536
2536
  const d = chunk(c.split(""), 12);
2537
- let p = "";
2537
+ let u = "";
2538
2538
  o([n], { [l]: "" });
2539
- for (let u = 0; u < d.length; u++)
2540
- p += d[u].join(""), o([n], { [l]: p }), await new Promise((g) => setTimeout(g, a));
2539
+ for (let p = 0; p < d.length; p++)
2540
+ u += d[p].join(""), o([n], { [l]: u }), await new Promise((g) => setTimeout(g, a));
2541
2541
  }
2542
2542
  }
2543
2543
  },
@@ -2575,16 +2575,16 @@ const getBlockWithChildren = (o, n) => {
2575
2575
  return r = flattenDeep([...r, ...getChildBlocks$1(n, o, r)]), r;
2576
2576
  }, pickOnlyAIProps = (o, n, r) => compact(
2577
2577
  o.map((a) => {
2578
- const i = ["_id", "_type", "_parent"], l = pick(a, i), c = getRegisteredChaiBlock(a._type), d = {}, p = get(c, "aiProps", []);
2579
- for (const u in a)
2580
- if (!i.includes(u) && p.includes(u)) {
2581
- const g = get(a, `${u}-${n}`, ""), m = get(a, u, "");
2582
- d[u] = isString(g) && g.trim() || m, r && (d[u] = m);
2578
+ const i = ["_id", "_type", "_parent"], l = pick(a, i), c = getRegisteredChaiBlock(a._type), d = {}, u = get(c, "aiProps", []);
2579
+ for (const p in a)
2580
+ if (!i.includes(p) && u.includes(p)) {
2581
+ const g = get(a, `${p}-${n}`, ""), m = get(a, p, "");
2582
+ d[p] = isString(g) && g.trim() || m, r && (d[p] = m);
2583
2583
  }
2584
2584
  return isEmpty(d) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...d });
2585
2585
  })
2586
2586
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2587
- const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), i = useBuilderProp("askAiCallBack", null), l = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (f, h) => {
2587
+ const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), i = useBuilderProp("askAiCallBack", null), l = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: u, fallbackLang: p } = useLanguages(), g = u.length ? u : p, m = (f, h) => {
2588
2588
  const x = cloneDeep(h.find((b) => b._id === f));
2589
2589
  for (const b in x) {
2590
2590
  const y = x[b];
@@ -2602,18 +2602,18 @@ const getBlockWithChildren = (o, n) => {
2602
2602
  if (i) {
2603
2603
  n(!0), a(null);
2604
2604
  try {
2605
- const y = p === u ? "" : p, C = x.toLowerCase().includes("translate the content"), k = f === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, d)), p, C) : [m(h, d)], S = await i(f, addLangToPrompt(x, g, f), k, y), { blocks: A, error: B } = S;
2605
+ const y = u === p ? "" : u, C = x.toLowerCase().includes("translate the content"), k = f === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, d)), u, C) : [m(h, d)], S = await i(f, addLangToPrompt(x, g, f), k, y), { blocks: A, error: B } = S;
2606
2606
  if (B) {
2607
2607
  a(B);
2608
2608
  return;
2609
2609
  }
2610
2610
  if (f === "styles") {
2611
- const E = A.map((w) => {
2611
+ const _ = A.map((w) => {
2612
2612
  for (const j in w)
2613
2613
  j !== "_id" && (w[j] = `${STYLES_KEY},${w[j]}`);
2614
2614
  return w;
2615
2615
  });
2616
- c(E);
2616
+ c(_);
2617
2617
  } else
2618
2618
  l(A);
2619
2619
  b && b(S);
@@ -2627,8 +2627,8 @@ const getBlockWithChildren = (o, n) => {
2627
2627
  [
2628
2628
  i,
2629
2629
  n,
2630
- p,
2631
2630
  u,
2631
+ p,
2632
2632
  d,
2633
2633
  g,
2634
2634
  c,
@@ -2701,15 +2701,15 @@ const useBlockHighlight = () => {
2701
2701
  const [o] = useBlocksStore(), [n, r] = useAtom$1(partialBlocksStoreAtom), [a, i] = useAtom$1(partialBlocksLoadingStateAtom), l = useBuilderProp("getPartialBlockBlocks", async (d) => []), c = useMemo(() => o.filter((d) => d._type === "PartialBlock" || d._type === "GlobalBlock").map((d) => get(d, "partialBlockId", get(d, "globalBlock", ""))), [o]);
2702
2702
  useEffect(() => {
2703
2703
  forEach(c, (d) => {
2704
- has(n, d) || get(a, `${d}.loading`, !1) || (i((p) => ({ ...p, [d]: { loading: !0, error: null } })), l(d).then((p) => {
2705
- r((u) => ({ ...u, [d]: p })), i((u) => ({
2706
- ...u,
2704
+ has(n, d) || get(a, `${d}.loading`, !1) || (i((u) => ({ ...u, [d]: { loading: !0, error: null } })), l(d).then((u) => {
2705
+ r((p) => ({ ...p, [d]: u })), i((p) => ({
2706
+ ...p,
2707
2707
  [d]: { loading: !1, error: null }
2708
2708
  }));
2709
- }).catch((p) => {
2710
- i((u) => ({
2711
- ...u,
2712
- [d]: { loading: !1, error: p.message }
2709
+ }).catch((u) => {
2710
+ i((p) => ({
2711
+ ...p,
2712
+ [d]: { loading: !1, error: u.message }
2713
2713
  }));
2714
2714
  }));
2715
2715
  });
@@ -2725,19 +2725,19 @@ const useBlockHighlight = () => {
2725
2725
  const [o, n] = useState(!1), [r, a] = useState(null), [i, l] = useAtom$1(partialBlocksListAtom), c = useBuilderProp("getPartialBlocks", async () => []), d = useCallback(async () => {
2726
2726
  n(!0), a(null);
2727
2727
  try {
2728
- const p = await c();
2729
- l(p), n(!1);
2730
- } catch (p) {
2731
- a(p instanceof Error ? p.message : "Failed to fetch partial blocks"), n(!1);
2728
+ const u = await c();
2729
+ l(u), n(!1);
2730
+ } catch (u) {
2731
+ a(u instanceof Error ? u.message : "Failed to fetch partial blocks"), n(!1);
2732
2732
  }
2733
2733
  }, [c, l]);
2734
2734
  return useEffect(() => {
2735
2735
  d();
2736
2736
  }, []), { data: i, isLoading: o, refetch: d, error: r };
2737
2737
  }, useBuilderReset = () => {
2738
- const { clear: o } = useUndoManager(), [, n] = useSelectedBlockIds(), { clearHighlight: r } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, i] = useAtom$1(aiAssistantActiveAtom), { reset: l } = usePartialBlocksStore(), { setSaveState: c } = useSavePage(), [, d] = useBlockRepeaterDataAtom(), [, p] = useAtom$1(userActionsCountAtom);
2738
+ const { clear: o } = useUndoManager(), [, n] = useSelectedBlockIds(), { clearHighlight: r } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, i] = useAtom$1(aiAssistantActiveAtom), { reset: l } = usePartialBlocksStore(), { setSaveState: c } = useSavePage(), [, d] = useBlockRepeaterDataAtom(), [, u] = useAtom$1(userActionsCountAtom);
2739
2739
  return () => {
2740
- d({}), n([]), a([]), r(), o(), i(!1), l(), c("SAVED"), p(0);
2740
+ d({}), n([]), a([]), r(), o(), i(!1), l(), c("SAVED"), u(0);
2741
2741
  };
2742
2742
  }, canvasZoomAtom = atomWithStorage("canvasZoom", 100), useCanvasZoom = () => useAtom$1(canvasZoomAtom), codeEditorAtom = atom(null), useCodeEditor = () => useAtom$1(codeEditorAtom), cutBlockIdsAtom = atom([]), useCutBlockIds = () => {
2743
2743
  const [o, n] = useAtom$1(cutBlockIdsAtom), r = useSetAtom$1(copiedBlockIdsAtom), a = useCallback(
@@ -2749,17 +2749,17 @@ const useBlockHighlight = () => {
2749
2749
  return [o, a];
2750
2750
  }, copiedBlockIdsAtom = atom([]), useCopyBlocks = () => {
2751
2751
  const [o] = useBlocksStore(), [n, r] = useAtom$1(copiedBlockIdsAtom), a = useSetAtom$1(cutBlockIdsAtom), { getPartailBlocks: i } = usePartialBlocksStore(), l = useBuilderProp("flags.copyPaste", !0), c = useCallback(
2752
- (p) => p.some((u) => getDuplicatedBlocks(o, u, null).some((m) => m._type === "PartialBlock" || m._type === "GlobalBlock")),
2752
+ (u) => u.some((p) => getDuplicatedBlocks(o, p, null).some((m) => m._type === "PartialBlock" || m._type === "GlobalBlock")),
2753
2753
  [o]
2754
2754
  ), d = useCallback(
2755
- async (p, u = !1) => {
2755
+ async (u, p = !1) => {
2756
2756
  try {
2757
- if (isEmpty(p)) return;
2758
- r(p), a([]);
2757
+ if (isEmpty(u)) return;
2758
+ r(u), a([]);
2759
2759
  const g = {
2760
- _chai_copied_blocks: p.flatMap((m) => {
2760
+ _chai_copied_blocks: u.flatMap((m) => {
2761
2761
  const f = getDuplicatedBlocks(o, m, null);
2762
- if (!u)
2762
+ if (!p)
2763
2763
  return f;
2764
2764
  let h = [];
2765
2765
  for (const x of f)
@@ -2828,19 +2828,19 @@ const useBlockHighlight = () => {
2828
2828
  useEffect(() => {
2829
2829
  (async () => {
2830
2830
  if (!(l === "complete" || c.current === "loading")) {
2831
- c.current = "loading", r((p) => ({ ...p, [o == null ? void 0 : o.id]: { loading: "loading", blocks: [] } }));
2831
+ c.current = "loading", r((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "loading", blocks: [] } }));
2832
2832
  try {
2833
- const p = await a(o);
2834
- c.current = "idle", r((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: p || [] } }));
2833
+ const u = await a(o);
2834
+ c.current = "idle", r((p) => ({ ...p, [o == null ? void 0 : o.id]: { loading: "complete", blocks: u || [] } }));
2835
2835
  } catch {
2836
- c.current = "idle", r((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: [] } }));
2836
+ c.current = "idle", r((p) => ({ ...p, [o == null ? void 0 : o.id]: { loading: "complete", blocks: [] } }));
2837
2837
  }
2838
2838
  }
2839
2839
  })();
2840
2840
  }, [o, i, l, c, r, a]);
2841
2841
  const d = useCallback(
2842
- (p) => {
2843
- r((u) => ({ ...u, [p]: { loading: "idle", blocks: [] } }));
2842
+ (u) => {
2843
+ r((p) => ({ ...p, [u]: { loading: "idle", blocks: [] } }));
2844
2844
  },
2845
2845
  [r]
2846
2846
  );
@@ -2880,8 +2880,8 @@ const useBlockHighlight = () => {
2880
2880
  try {
2881
2881
  const d = await navigator.clipboard.readText();
2882
2882
  if (d) {
2883
- const p = JSON.parse(d);
2884
- return has(p, "_chai_copied_blocks");
2883
+ const u = JSON.parse(d);
2884
+ return has(u, "_chai_copied_blocks");
2885
2885
  }
2886
2886
  } catch {
2887
2887
  return !1;
@@ -2912,11 +2912,11 @@ const useBlockHighlight = () => {
2912
2912
  }
2913
2913
  toast.promise(
2914
2914
  async () => {
2915
- const p = await navigator.clipboard.readText();
2916
- if (p) {
2917
- const u = JSON.parse(p);
2918
- if (has(u, "_chai_copied_blocks"))
2919
- a(u._chai_copied_blocks, d === "root" ? null : d);
2915
+ const u = await navigator.clipboard.readText();
2916
+ if (u) {
2917
+ const p = JSON.parse(u);
2918
+ if (has(p, "_chai_copied_blocks"))
2919
+ a(p._chai_copied_blocks, d === "root" ? null : d);
2920
2920
  else
2921
2921
  throw new Error("Nothing to paste");
2922
2922
  } else
@@ -2943,20 +2943,20 @@ const useBlockHighlight = () => {
2943
2943
  )
2944
2944
  );
2945
2945
  return map(l, (c) => {
2946
- const d = o(c), p = a;
2947
- let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, i.prop, `${STYLES_KEY},`));
2948
- return each(p, (m) => {
2946
+ const d = o(c), u = a;
2947
+ let { classes: p, baseClasses: g } = getSplitChaiClasses(get(d, i.prop, `${STYLES_KEY},`));
2948
+ return each(u, (m) => {
2949
2949
  const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
2950
- u = u.replace(h, " ").replace(/\s+/g, " ").trim();
2950
+ p = p.replace(h, " ").replace(/\s+/g, " ").trim();
2951
2951
  const x = first(m.split(":"));
2952
- includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
2953
- }), each(p, (m) => {
2952
+ includes(["2xl", "xl", "lg", "md", "sm"], x) && u.push(m.split(":").pop().trim());
2953
+ }), each(u, (m) => {
2954
2954
  const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
2955
2955
  g = g.replace(h, " ").replace(/\s+/g, " ").trim();
2956
2956
  }), {
2957
2957
  ids: [d._id],
2958
2958
  props: {
2959
- [i.prop]: `${STYLES_KEY}${g},${u}`
2959
+ [i.prop]: `${STYLES_KEY}${g},${p}`
2960
2960
  }
2961
2961
  };
2962
2962
  });
@@ -2991,8 +2991,8 @@ const useBlockHighlight = () => {
2991
2991
  ), []), i = useCallback(
2992
2992
  (c) => {
2993
2993
  if (!o) return;
2994
- const p = r(o._type)[c] ?? "#styles:,";
2995
- n([o._id], { [c]: p });
2994
+ const u = r(o._type)[c] ?? "#styles:,";
2995
+ n([o._id], { [c]: u });
2996
2996
  },
2997
2997
  [o, r, n]
2998
2998
  );
@@ -3000,8 +3000,8 @@ const useBlockHighlight = () => {
3000
3000
  if (!o) return;
3001
3001
  const c = a(o);
3002
3002
  if (c.length === 0) return;
3003
- const d = r(o._type), p = pick(d, c);
3004
- n([o._id], p);
3003
+ const d = r(o._type), u = pick(d, c);
3004
+ n([o._id], u);
3005
3005
  }, [o, a, r, n]), reset: i };
3006
3006
  }, useStylingBreakpoint = () => useAtom$1(styleBreakpointAtom), canvasWidthAtom = atomWithStorage("canvasWidth", 800), canvasDisplayWidthAtom = atomWithStorage("canvasDisplayWidth", 800), canvasBreakpointAtom = atom((o) => {
3007
3007
  const n = o(canvasWidthAtom);
@@ -3106,32 +3106,32 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
3106
3106
  else {
3107
3107
  const d = `chai-${kebabCase(c)}`;
3108
3108
  o.tagName = d, o.attributes = [], o.attributes.push({ key: "chai-type", value: c });
3109
- const p = getRegisteredChaiBlock(c), u = n.find((g) => g._id === (i == null ? void 0 : i.value));
3110
- if (u && o.attributes.push(
3111
- ...Object.entries(u).filter(([g]) => !["_id", "_type", "_parent", "_index", "_name"].includes(g)).map(([g, m]) => ({
3109
+ const u = getRegisteredChaiBlock(c), p = n.find((g) => g._id === (i == null ? void 0 : i.value));
3110
+ if (p && o.attributes.push(
3111
+ ...Object.entries(p).filter(([g]) => !["_id", "_type", "_parent", "_index", "_name"].includes(g)).map(([g, m]) => ({
3112
3112
  key: g,
3113
3113
  value: typeof m == "string" ? m : JSON.stringify(m)
3114
3114
  }))
3115
- ), p && (p != null && p.description) && o.attributes.push({
3115
+ ), u && (u != null && u.description) && o.attributes.push({
3116
3116
  key: "about-this-component",
3117
- value: p.description
3118
- }), p) {
3119
- if (p.canMove) {
3120
- const g = typeof p.canMove == "function" ? p.canMove() : p.canMove;
3117
+ value: u.description
3118
+ }), u) {
3119
+ if (u.canMove) {
3120
+ const g = typeof u.canMove == "function" ? u.canMove() : u.canMove;
3121
3121
  o.attributes.push({
3122
3122
  key: "can-move",
3123
3123
  value: String(g)
3124
3124
  });
3125
3125
  }
3126
- if (p.canDelete) {
3127
- const g = typeof p.canDelete == "function" ? p.canDelete() : p.canDelete;
3126
+ if (u.canDelete) {
3127
+ const g = typeof u.canDelete == "function" ? u.canDelete() : u.canDelete;
3128
3128
  o.attributes.push({
3129
3129
  key: "can-delete",
3130
3130
  value: String(g)
3131
3131
  });
3132
3132
  }
3133
3133
  }
3134
- c === "Icon" && (o.attributes = o.attributes.filter((g) => g.key !== "icon")), p && p.canAcceptBlock ? o.children && (o.children = o.children.map((g) => transformNode(g, n, r))) : o.children = [];
3134
+ c === "Icon" && (o.attributes = o.attributes.filter((g) => g.key !== "icon")), u && u.canAcceptBlock ? o.children && (o.children = o.children.map((g) => transformNode(g, n, r))) : o.children = [];
3135
3135
  }
3136
3136
  } else
3137
3137
  o.children && (o.children = o.children.map((c) => transformNode(c, n, r)));
@@ -3140,13 +3140,13 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
3140
3140
  const [o] = useBlocksStore(), [n] = useCanvasIframe();
3141
3141
  return useCallback(
3142
3142
  (r) => {
3143
- var u, g;
3143
+ var p, g;
3144
3144
  if (!n) return "";
3145
- const a = r != null && r.blockId ? `[data-block-id="${r.blockId}"]` : "#canvas", i = (g = (u = n.contentDocument) == null ? void 0 : u.querySelector(a)) == null ? void 0 : g[a === "#canvas" ? "innerHTML" : "outerHTML"];
3145
+ const a = r != null && r.blockId ? `[data-block-id="${r.blockId}"]` : "#canvas", i = (g = (p = n.contentDocument) == null ? void 0 : p.querySelector(a)) == null ? void 0 : g[a === "#canvas" ? "innerHTML" : "outerHTML"];
3146
3146
  if (!i) return "";
3147
3147
  const d = parse(i).map(cleanNode).filter((m) => m !== null).map((m) => transformNode(m, o, r));
3148
- let p = stringify(d);
3149
- return p = p.replace(/#styles:,/g, "#styles:"), p.replace(/\s+/g, " ").trim();
3148
+ let u = stringify(d);
3149
+ return u = u.replace(/#styles:,/g, "#styles:"), u.replace(/\s+/g, " ").trim();
3150
3150
  },
3151
3151
  [n]
3152
3152
  );
@@ -3156,14 +3156,14 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
3156
3156
  const i = a.i18nProps;
3157
3157
  if (!i) return r;
3158
3158
  const l = filter(n, { _type: r._type }), c = pick(r, i);
3159
- return each(c, (d, p) => {
3160
- const u = find(l, (g) => {
3159
+ return each(c, (d, u) => {
3160
+ const p = find(l, (g) => {
3161
3161
  var h;
3162
- const m = typeof g[p] == "string" ? (h = g[p]) == null ? void 0 : h.trim().toLowerCase() : JSON.stringify(g[p]), f = typeof d == "string" ? d.trim().toLowerCase() : JSON.stringify(d);
3162
+ const m = typeof g[u] == "string" ? (h = g[u]) == null ? void 0 : h.trim().toLowerCase() : JSON.stringify(g[u]), f = typeof d == "string" ? d.trim().toLowerCase() : JSON.stringify(d);
3163
3163
  return m === f;
3164
3164
  });
3165
- if (u) {
3166
- const g = filter(Object.keys(u), (f) => startsWith(f, `${p}-`)), m = pick(u, g);
3165
+ if (p) {
3166
+ const g = filter(Object.keys(p), (f) => startsWith(f, `${u}-`)), m = pick(p, g);
3167
3167
  r = { ...r, ...m };
3168
3168
  }
3169
3169
  }), r;
@@ -3195,10 +3195,10 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
3195
3195
  if (!l) return null;
3196
3196
  const c = (l == null ? void 0 : l.i18nProps) ?? [];
3197
3197
  if (c.length === 0) return null;
3198
- const d = r === "ALL" ? Object.keys(i).filter((u) => c.find((g) => u.startsWith(g))) : c.map((u) => r ? `${u}-${r}` : u), p = pick(i, ["_id"]);
3199
- return each(d, (u) => {
3200
- p[u] = get(i, u, get(i, u.replace(`-${r}`, "")));
3201
- }), p;
3198
+ const d = r === "ALL" ? Object.keys(i).filter((p) => c.find((g) => p.startsWith(g))) : c.map((p) => r ? `${p}-${r}` : p), u = pick(i, ["_id"]);
3199
+ return each(d, (p) => {
3200
+ u[p] = get(i, p, get(i, p.replace(`-${r}`, "")));
3201
+ }), u;
3202
3202
  })
3203
3203
  ) : [];
3204
3204
  },
@@ -3229,10 +3229,10 @@ const getAllDescendantIds = (o, n) => {
3229
3229
  }, replaceBlock = (o, n, r) => {
3230
3230
  const a = find(o, { _id: n });
3231
3231
  if (!a) return o;
3232
- const i = o.findIndex((m) => m._id === n), l = getAllDescendantIds(o, n), c = /* @__PURE__ */ new Set([n, ...l]), 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);
3232
+ const i = o.findIndex((m) => m._id === n), l = getAllDescendantIds(o, n), c = /* @__PURE__ */ new Set([n, ...l]), d = o.filter((m) => !c.has(m._id)), u = new Set(r.map((m) => m._id)), p = r.map((m) => !m._parent || !u.has(m._parent) ? { ...m, _parent: a._parent } : m);
3233
3233
  return [
3234
3234
  ...d.slice(0, i),
3235
- ...u,
3235
+ ...p,
3236
3236
  ...d.slice(i)
3237
3237
  ];
3238
3238
  }, useReplaceBlock = () => {
@@ -3334,8 +3334,8 @@ const useDragParentHighlight = () => {
3334
3334
  left: 0,
3335
3335
  width: 0,
3336
3336
  height: 0
3337
- }), removeDropTargetAttributes$2(c), a(), c && c.querySelectorAll("[data-dragging]").forEach((p) => {
3338
- p.removeAttribute("data-dragging");
3337
+ }), removeDropTargetAttributes$2(c), a(), c && c.querySelectorAll("[data-dragging]").forEach((u) => {
3338
+ u.removeAttribute("data-dragging");
3339
3339
  }), setIsDragging(!1), l(i + 1);
3340
3340
  }, [o, n, c, a, i, l]);
3341
3341
  };
@@ -3430,33 +3430,33 @@ function detectGapZone(o, n, r, a) {
3430
3430
  const l = findClosestSiblingInRow(i, n, r, a);
3431
3431
  if (l) {
3432
3432
  const c = getSiblingsInSameRow(i, l, a);
3433
- c.sort((d, p) => {
3434
- const u = d.getBoundingClientRect(), g = p.getBoundingClientRect();
3435
- return a === "vertical" ? u.top - g.top : u.left - g.left;
3433
+ c.sort((d, u) => {
3434
+ const p = d.getBoundingClientRect(), g = u.getBoundingClientRect();
3435
+ return a === "vertical" ? p.top - g.top : p.left - g.left;
3436
3436
  });
3437
3437
  for (let d = 0; d < c.length - 1; d++) {
3438
- const p = c[d], u = c[d + 1], g = p.getBoundingClientRect(), m = u.getBoundingClientRect();
3438
+ const u = c[d], p = c[d + 1], g = u.getBoundingClientRect(), m = p.getBoundingClientRect();
3439
3439
  if (a === "vertical") {
3440
3440
  const f = g.bottom, h = m.top, x = h - f, b = r >= f && r <= h, y = n >= Math.min(g.left, m.left) && n <= Math.max(g.right, m.right);
3441
3441
  if (b && y && x >= ZONE_CONFIG.GAP_THRESHOLD)
3442
- return { before: p, after: u };
3442
+ return { before: u, after: p };
3443
3443
  } else {
3444
3444
  const f = g.right, h = m.left, x = h - f, b = n >= f && n <= h, y = r >= Math.min(g.top, m.top) && r <= Math.max(g.bottom, m.bottom);
3445
3445
  if (b && y && x >= ZONE_CONFIG.GAP_THRESHOLD)
3446
- return { before: p, after: u };
3446
+ return { before: u, after: p };
3447
3447
  }
3448
3448
  }
3449
3449
  }
3450
3450
  for (let c = 0; c < i.length - 1; c++) {
3451
- const d = i[c], p = i[c + 1], u = d.getBoundingClientRect(), g = p.getBoundingClientRect();
3451
+ const d = i[c], u = i[c + 1], p = d.getBoundingClientRect(), g = u.getBoundingClientRect();
3452
3452
  if (a === "vertical") {
3453
- const m = u.bottom, f = g.top, h = f - m, x = r >= m && r <= f, b = n >= Math.min(u.left, g.left) && n <= Math.max(u.right, g.right);
3453
+ const m = p.bottom, f = g.top, h = f - m, x = r >= m && r <= f, b = n >= Math.min(p.left, g.left) && n <= Math.max(p.right, g.right);
3454
3454
  if (x && b && h >= ZONE_CONFIG.GAP_THRESHOLD)
3455
- return { before: d, after: p };
3455
+ return { before: d, after: u };
3456
3456
  } else {
3457
- const m = u.right, f = g.left, h = f - m, x = n >= m && n <= f, b = r >= Math.min(u.top, g.top) && r <= Math.max(u.bottom, g.bottom);
3457
+ const m = p.right, f = g.left, h = f - m, x = n >= m && n <= f, b = r >= Math.min(p.top, g.top) && r <= Math.max(p.bottom, g.bottom);
3458
3458
  if (x && b && h >= ZONE_CONFIG.GAP_THRESHOLD)
3459
- return { before: d, after: p };
3459
+ return { before: d, after: u };
3460
3460
  }
3461
3461
  }
3462
3462
  return null;
@@ -3486,13 +3486,13 @@ function detectParentEdgeProximity(o, n, r, a) {
3486
3486
  function calculateElementZone(o, n, r, a, i) {
3487
3487
  const l = o.getBoundingClientRect();
3488
3488
  if (i === "vertical") {
3489
- const d = (r - l.top) / l.height, p = calculateEdgeZoneSize(l.height), u = p / l.height;
3490
- return a ? p > 0 && d < u ? {
3489
+ const d = (r - l.top) / l.height, u = calculateEdgeZoneSize(l.height), p = u / l.height;
3490
+ return a ? u > 0 && d < p ? {
3491
3491
  position: "before",
3492
- confidence: 1 - d / u
3493
- } : p > 0 && d > 1 - u ? {
3492
+ confidence: 1 - d / p
3493
+ } : u > 0 && d > 1 - p ? {
3494
3494
  position: "after",
3495
- confidence: (d - (1 - u)) / u
3495
+ confidence: (d - (1 - p)) / p
3496
3496
  } : {
3497
3497
  position: "inside",
3498
3498
  confidence: 1 - Math.abs(d - 0.5) * 2
@@ -3507,13 +3507,13 @@ function calculateElementZone(o, n, r, a, i) {
3507
3507
  // Higher confidence closer to bottom
3508
3508
  };
3509
3509
  } else {
3510
- const d = (n - l.left) / l.width, p = calculateEdgeZoneSize(l.width), u = p / l.width;
3511
- return a ? p > 0 && d < u ? {
3510
+ const d = (n - l.left) / l.width, u = calculateEdgeZoneSize(l.width), p = u / l.width;
3511
+ return a ? u > 0 && d < p ? {
3512
3512
  position: "before",
3513
- confidence: 1 - d / u
3514
- } : p > 0 && d > 1 - u ? {
3513
+ confidence: 1 - d / p
3514
+ } : u > 0 && d > 1 - p ? {
3515
3515
  position: "after",
3516
- confidence: (d - (1 - u)) / u
3516
+ confidence: (d - (1 - p)) / p
3517
3517
  } : {
3518
3518
  position: "inside",
3519
3519
  confidence: 1 - Math.abs(d - 0.5) * 2
@@ -3527,18 +3527,18 @@ function calculateElementZone(o, n, r, a, i) {
3527
3527
  }
3528
3528
  }
3529
3529
  function detectDropZone(o, n, r, a, i) {
3530
- var S, A, B, E;
3530
+ var S, A, B, _;
3531
3531
  const l = o.getAttribute("data-block-id"), c = o.getAttribute("data-block-type") || "Box";
3532
3532
  if (!l)
3533
3533
  return null;
3534
3534
  let d = o.parentElement;
3535
3535
  for (; d && !d.hasAttribute("data-block-id"); )
3536
3536
  d = d.parentElement;
3537
- const p = l === "canvas" ? l : d == null ? void 0 : d.getAttribute("data-block-id"), u = d ? getOrientation(d) : "vertical", g = getOrientation(o), m = isLeafBlock(c), f = !m && canAcceptChildBlock(c, a), h = ((S = i.defaultView) == null ? void 0 : S.scrollY) || 0, x = ((A = i.defaultView) == null ? void 0 : A.scrollX) || 0;
3537
+ const u = l === "canvas" ? l : d == null ? void 0 : d.getAttribute("data-block-id"), p = d ? getOrientation(d) : "vertical", g = getOrientation(o), m = isLeafBlock(c), f = !m && canAcceptChildBlock(c, a), h = ((S = i.defaultView) == null ? void 0 : S.scrollY) || 0, x = ((A = i.defaultView) == null ? void 0 : A.scrollX) || 0;
3538
3538
  if (l === "canvas" && hasChildBlocks(o)) {
3539
3539
  const w = getChildBlocks(o), j = w[w.length - 1];
3540
3540
  if (j) {
3541
- const v = j.getBoundingClientRect(), _ = o.getBoundingClientRect(), N = window.getComputedStyle(o), I = parseFloat(N.paddingLeft) || 0, P = parseFloat(N.paddingRight) || 0, D = _.width - I - P, R = _.left + x + I;
3541
+ const v = j.getBoundingClientRect(), E = o.getBoundingClientRect(), N = window.getComputedStyle(o), I = parseFloat(N.paddingLeft) || 0, P = parseFloat(N.paddingRight) || 0, D = E.width - I - P, R = E.left + x + I;
3542
3542
  return {
3543
3543
  position: "after",
3544
3544
  placeholderOrientation: "horizontal",
@@ -3559,13 +3559,13 @@ function detectDropZone(o, n, r, a, i) {
3559
3559
  if (f && !m && hasChildBlocks(o)) {
3560
3560
  const w = detectGapZone(o, n, r, g);
3561
3561
  if (w) {
3562
- const j = w.before.getBoundingClientRect(), v = w.after.getBoundingClientRect(), _ = o.getBoundingClientRect(), N = window.getComputedStyle(o), I = parseFloat(N.paddingLeft) || 0, P = parseFloat(N.paddingRight) || 0, D = getChildBlocks(o), R = getSiblingsInSameRow(D, w.before, g);
3562
+ const j = w.before.getBoundingClientRect(), v = w.after.getBoundingClientRect(), E = o.getBoundingClientRect(), N = window.getComputedStyle(o), I = parseFloat(N.paddingLeft) || 0, P = parseFloat(N.paddingRight) || 0, D = getChildBlocks(o), R = getSiblingsInSameRow(D, w.before, g);
3563
3563
  let $ = 0;
3564
3564
  if (R.forEach((F) => {
3565
3565
  const O = F.getBoundingClientRect();
3566
3566
  O.height > $ && ($ = O.height);
3567
3567
  }), g === "vertical") {
3568
- const F = _.width - I - P, O = _.left + x + I;
3568
+ const F = E.width - I - P, O = E.left + x + I;
3569
3569
  return {
3570
3570
  position: "after",
3571
3571
  placeholderOrientation: "horizontal",
@@ -3602,16 +3602,16 @@ function detectDropZone(o, n, r, a, i) {
3602
3602
  }
3603
3603
  }
3604
3604
  }
3605
- if (d && p) {
3606
- const w = detectParentEdgeProximity(d, n, r, u);
3605
+ if (d && u) {
3606
+ const w = detectParentEdgeProximity(d, n, r, p);
3607
3607
  if (w) {
3608
- const j = d.getBoundingClientRect(), v = window.getComputedStyle(d), _ = parseFloat(v.paddingLeft) || 0, N = parseFloat(v.paddingRight) || 0, I = parseFloat(v.paddingTop) || 0, P = parseFloat(v.paddingBottom) || 0, D = ((B = i.defaultView) == null ? void 0 : B.scrollY) || 0, R = ((E = i.defaultView) == null ? void 0 : E.scrollX) || 0, $ = u === "vertical" ? "horizontal" : "vertical", F = getMaxSiblingDimensions(d);
3608
+ const j = d.getBoundingClientRect(), v = window.getComputedStyle(d), E = parseFloat(v.paddingLeft) || 0, N = parseFloat(v.paddingRight) || 0, I = parseFloat(v.paddingTop) || 0, P = parseFloat(v.paddingBottom) || 0, D = ((B = i.defaultView) == null ? void 0 : B.scrollY) || 0, R = ((_ = i.defaultView) == null ? void 0 : _.scrollX) || 0, $ = p === "vertical" ? "horizontal" : "vertical", F = getMaxSiblingDimensions(d);
3609
3609
  if (w === "start") {
3610
3610
  const O = getChildBlocks(d)[0];
3611
3611
  if (O) {
3612
3612
  const L = O.getBoundingClientRect();
3613
- if (u === "vertical") {
3614
- const T = j.width - _ - N, M = j.left + R + _;
3613
+ if (p === "vertical") {
3614
+ const T = j.width - E - N, M = j.left + R + E;
3615
3615
  return {
3616
3616
  position: "before",
3617
3617
  placeholderOrientation: $,
@@ -3623,7 +3623,7 @@ function detectDropZone(o, n, r, a, i) {
3623
3623
  },
3624
3624
  targetElement: O,
3625
3625
  targetBlockId: O.getAttribute("data-block-id"),
3626
- targetParentId: p,
3626
+ targetParentId: u,
3627
3627
  confidence: 0.9
3628
3628
  };
3629
3629
  } else {
@@ -3639,7 +3639,7 @@ function detectDropZone(o, n, r, a, i) {
3639
3639
  },
3640
3640
  targetElement: O,
3641
3641
  targetBlockId: O.getAttribute("data-block-id"),
3642
- targetParentId: p,
3642
+ targetParentId: u,
3643
3643
  confidence: 0.9
3644
3644
  };
3645
3645
  }
@@ -3648,8 +3648,8 @@ function detectDropZone(o, n, r, a, i) {
3648
3648
  const O = getChildBlocks(d), L = O[O.length - 1];
3649
3649
  if (L) {
3650
3650
  const T = L.getBoundingClientRect();
3651
- if (u === "vertical") {
3652
- const M = j.width - _ - N, H = j.left + R + _;
3651
+ if (p === "vertical") {
3652
+ const M = j.width - E - N, H = j.left + R + E;
3653
3653
  return {
3654
3654
  position: "after",
3655
3655
  placeholderOrientation: $,
@@ -3661,7 +3661,7 @@ function detectDropZone(o, n, r, a, i) {
3661
3661
  },
3662
3662
  targetElement: L,
3663
3663
  targetBlockId: L.getAttribute("data-block-id"),
3664
- targetParentId: p,
3664
+ targetParentId: u,
3665
3665
  confidence: 0.9
3666
3666
  };
3667
3667
  } else {
@@ -3677,7 +3677,7 @@ function detectDropZone(o, n, r, a, i) {
3677
3677
  },
3678
3678
  targetElement: L,
3679
3679
  targetBlockId: L.getAttribute("data-block-id"),
3680
- targetParentId: p,
3680
+ targetParentId: u,
3681
3681
  confidence: 0.9
3682
3682
  };
3683
3683
  }
@@ -3685,10 +3685,10 @@ function detectDropZone(o, n, r, a, i) {
3685
3685
  }
3686
3686
  }
3687
3687
  }
3688
- let b = calculateElementZone(o, n, r, f, u);
3688
+ let b = calculateElementZone(o, n, r, f, p);
3689
3689
  if (m && b.position === "inside") {
3690
3690
  const w = o.getBoundingClientRect();
3691
- u === "vertical" ? b = {
3691
+ p === "vertical" ? b = {
3692
3692
  position: (r - w.top) / w.height < 0.5 ? "before" : "after",
3693
3693
  confidence: b.confidence
3694
3694
  } : b = {
@@ -3697,14 +3697,14 @@ function detectDropZone(o, n, r, a, i) {
3697
3697
  };
3698
3698
  }
3699
3699
  let y;
3700
- b.position === "inside" ? y = g === "vertical" ? "horizontal" : "vertical" : y = u === "vertical" ? "horizontal" : "vertical";
3700
+ b.position === "inside" ? y = g === "vertical" ? "horizontal" : "vertical" : y = p === "vertical" ? "horizontal" : "vertical";
3701
3701
  const C = calculatePlaceholderRect(
3702
3702
  o,
3703
3703
  d,
3704
3704
  b.position,
3705
3705
  y,
3706
3706
  i
3707
- ), k = b.position === "inside" ? l : p;
3707
+ ), k = b.position === "inside" ? l : u;
3708
3708
  return {
3709
3709
  position: b.position,
3710
3710
  placeholderOrientation: y,
@@ -3719,8 +3719,8 @@ function detectDropZone(o, n, r, a, i) {
3719
3719
  function findClosestSiblingInRow(o, n, r, a) {
3720
3720
  if (o.length === 0) return null;
3721
3721
  const i = o.filter((d) => {
3722
- const p = d.getBoundingClientRect();
3723
- return a === "vertical" ? r >= p.top && r <= p.bottom : n >= p.left && n <= p.right;
3722
+ const u = d.getBoundingClientRect();
3723
+ return a === "vertical" ? r >= u.top && r <= u.bottom : n >= u.left && n <= u.right;
3724
3724
  });
3725
3725
  if (i.length === 0) {
3726
3726
  const d = /* @__PURE__ */ new Map();
@@ -3728,16 +3728,16 @@ function findClosestSiblingInRow(o, n, r, a) {
3728
3728
  const m = g.getBoundingClientRect(), f = Math.round(a === "vertical" ? m.top : m.left);
3729
3729
  d.has(f) || d.set(f, []), d.get(f).push(g);
3730
3730
  });
3731
- let p = null, u = 1 / 0;
3731
+ let u = null, p = 1 / 0;
3732
3732
  d.forEach((g, m) => {
3733
3733
  const f = Math.abs(a === "vertical" ? r - m : n - m);
3734
- f < u && (u = f, p = g);
3735
- }), p && p.length > 0 && i.push(...p);
3734
+ f < p && (p = f, u = g);
3735
+ }), u && u.length > 0 && i.push(...u);
3736
3736
  }
3737
3737
  if (i.length === 0) return null;
3738
3738
  let l = i[0], c = 1 / 0;
3739
3739
  return i.forEach((d) => {
3740
- const p = d.getBoundingClientRect(), u = p.left + p.width / 2, g = p.top + p.height / 2, m = Math.sqrt(Math.pow(n - u, 2) + Math.pow(r - g, 2));
3740
+ const u = d.getBoundingClientRect(), p = u.left + u.width / 2, g = u.top + u.height / 2, m = Math.sqrt(Math.pow(n - p, 2) + Math.pow(r - g, 2));
3741
3741
  m < c && (c = m, l = d);
3742
3742
  }), l;
3743
3743
  }
@@ -3760,32 +3760,32 @@ function getSiblingsInSameRow(o, n, r) {
3760
3760
  }
3761
3761
  function calculatePlaceholderRect(o, n, r, a, i) {
3762
3762
  var I, P;
3763
- const l = o.getBoundingClientRect(), c = window.getComputedStyle(o), d = ((I = i.defaultView) == null ? void 0 : I.scrollY) || 0, p = ((P = i.defaultView) == null ? void 0 : P.scrollX) || 0, u = parseFloat(c.marginTop) || 0, g = parseFloat(c.marginBottom) || 0, m = parseFloat(c.marginLeft) || 0, f = parseFloat(c.marginRight) || 0, h = parseFloat(c.paddingTop) || 0, x = parseFloat(c.paddingBottom) || 0, b = parseFloat(c.paddingLeft) || 0, y = parseFloat(c.paddingRight) || 0, C = n == null ? void 0 : n.getBoundingClientRect(), k = n && parseFloat(window.getComputedStyle(n).paddingLeft) || 0, S = n && parseFloat(window.getComputedStyle(n).paddingRight) || 0, A = n && parseFloat(window.getComputedStyle(n).paddingTop) || 0, B = n && parseFloat(window.getComputedStyle(n).paddingBottom) || 0, E = n ? getMaxSiblingDimensions(n) : { maxWidth: 0, maxHeight: 0 }, w = n ? getOrientation(n) : "vertical", j = n ? getChildBlocks(n) : [], v = getSiblingsInSameRow(j, o, w);
3764
- let _ = 0, N = 0;
3763
+ const l = o.getBoundingClientRect(), c = window.getComputedStyle(o), d = ((I = i.defaultView) == null ? void 0 : I.scrollY) || 0, u = ((P = i.defaultView) == null ? void 0 : P.scrollX) || 0, p = parseFloat(c.marginTop) || 0, g = parseFloat(c.marginBottom) || 0, m = parseFloat(c.marginLeft) || 0, f = parseFloat(c.marginRight) || 0, h = parseFloat(c.paddingTop) || 0, x = parseFloat(c.paddingBottom) || 0, b = parseFloat(c.paddingLeft) || 0, y = parseFloat(c.paddingRight) || 0, C = n == null ? void 0 : n.getBoundingClientRect(), k = n && parseFloat(window.getComputedStyle(n).paddingLeft) || 0, S = n && parseFloat(window.getComputedStyle(n).paddingRight) || 0, A = n && parseFloat(window.getComputedStyle(n).paddingTop) || 0, B = n && parseFloat(window.getComputedStyle(n).paddingBottom) || 0, _ = n ? getMaxSiblingDimensions(n) : { maxWidth: 0, maxHeight: 0 }, w = n ? getOrientation(n) : "vertical", j = n ? getChildBlocks(n) : [], v = getSiblingsInSameRow(j, o, w);
3764
+ let E = 0, N = 0;
3765
3765
  if (v.forEach((D) => {
3766
3766
  const R = D.getBoundingClientRect();
3767
- R.height > _ && (_ = R.height), R.width > N && (N = R.width);
3767
+ R.height > E && (E = R.height), R.width > N && (N = R.width);
3768
3768
  }), r === "before")
3769
3769
  if (a === "horizontal") {
3770
- const D = C ? C.width - k - S : l.width, R = C ? C.left + p + k : l.left + p;
3770
+ const D = C ? C.width - k - S : l.width, R = C ? C.left + u + k : l.left + u;
3771
3771
  return {
3772
- top: l.top + d - u - 2,
3772
+ top: l.top + d - p - 2,
3773
3773
  left: R,
3774
3774
  width: D,
3775
3775
  height: 4
3776
3776
  };
3777
3777
  } else {
3778
- const D = l.top + d, R = w === "horizontal" && _ > 0 ? _ : E.maxHeight > 0 ? E.maxHeight : C ? C.height - A - B : l.height;
3778
+ const D = l.top + d, R = w === "horizontal" && E > 0 ? E : _.maxHeight > 0 ? _.maxHeight : C ? C.height - A - B : l.height;
3779
3779
  return {
3780
3780
  top: D,
3781
- left: l.left + p - m - 2,
3781
+ left: l.left + u - m - 2,
3782
3782
  width: 4,
3783
3783
  height: R
3784
3784
  };
3785
3785
  }
3786
3786
  else if (r === "after")
3787
3787
  if (a === "horizontal") {
3788
- const D = C ? C.width - k - S : l.width, R = C ? C.left + p + k : l.left + p;
3788
+ const D = C ? C.width - k - S : l.width, R = C ? C.left + u + k : l.left + u;
3789
3789
  return {
3790
3790
  top: l.bottom + d + g - 2,
3791
3791
  left: R,
@@ -3793,10 +3793,10 @@ function calculatePlaceholderRect(o, n, r, a, i) {
3793
3793
  height: 4
3794
3794
  };
3795
3795
  } else {
3796
- const D = l.top + d, R = w === "horizontal" && _ > 0 ? _ : E.maxHeight > 0 ? E.maxHeight : C ? C.height - A - B : l.height;
3796
+ const D = l.top + d, R = w === "horizontal" && E > 0 ? E : _.maxHeight > 0 ? _.maxHeight : C ? C.height - A - B : l.height;
3797
3797
  return {
3798
3798
  top: D,
3799
- left: l.right + p + f - 2,
3799
+ left: l.right + u + f - 2,
3800
3800
  width: 4,
3801
3801
  height: R
3802
3802
  };
@@ -3804,17 +3804,17 @@ function calculatePlaceholderRect(o, n, r, a, i) {
3804
3804
  else
3805
3805
  return hasChildBlocks(o) ? getOrientation(o) === "vertical" ? {
3806
3806
  top: l.bottom + d - x - 2,
3807
- left: l.left + p + b,
3807
+ left: l.left + u + b,
3808
3808
  width: l.width - b - y,
3809
3809
  height: 4
3810
3810
  } : {
3811
3811
  top: l.top + d + h,
3812
- left: l.right + p - y - 2,
3812
+ left: l.right + u - y - 2,
3813
3813
  width: 4,
3814
3814
  height: l.height - h - x
3815
3815
  } : {
3816
3816
  top: l.top + d + h,
3817
- left: l.left + p + b,
3817
+ left: l.left + u + b,
3818
3818
  width: l.width - b - y,
3819
3819
  height: Math.max(l.height - h - x, 20)
3820
3820
  };
@@ -3844,6 +3844,140 @@ function canDropAsSiblingWithoutCircularReference(o, n, r) {
3844
3844
  const i = a._parent;
3845
3845
  return canDropWithoutCircularReference(o, i, r);
3846
3846
  }
3847
+ const useBlockDrop = () => {
3848
+ const [o, n] = useAtom$1(dragAndDropAtom), [r, a] = useAtom$1(dropIndicatorAtom), [i] = useBlocksStore(), [l] = useCanvasIframe(), { addCoreBlock: c } = useAddBlock(), { moveBlocks: d } = useBlocksStoreUndoableActions(), [, u] = useSelectedBlockIds(), [, p] = useSelectedStylingBlocks(), { clearHighlight: g } = useBlockHighlight(), { clearParentHighlight: m } = useDragParentHighlight(), [f, h] = useAtom$1(canvasRenderKeyAtom), x = useUpdateBlocksProps(), b = l == null ? void 0 : l.contentDocument;
3849
+ return useCallback(
3850
+ (y) => {
3851
+ if (y.preventDefault(), y.stopPropagation(), setIsDragging(!1), restoreDraggedElementStyles(b), removeDropTargetAttributes$1(b), m(), a({
3852
+ isVisible: !1,
3853
+ isValid: !1,
3854
+ position: "inside",
3855
+ placeholderOrientation: "horizontal",
3856
+ isEmpty: !1,
3857
+ top: 0,
3858
+ left: 0,
3859
+ width: 0,
3860
+ height: 0
3861
+ }), setTimeout(() => {
3862
+ m(), removeDropTargetAttributes$1(b), a({
3863
+ isVisible: !1,
3864
+ isValid: !1,
3865
+ position: "inside",
3866
+ placeholderOrientation: "horizontal",
3867
+ isEmpty: !1,
3868
+ top: 0,
3869
+ left: 0,
3870
+ width: 0,
3871
+ height: 0
3872
+ });
3873
+ }, 50), !o)
3874
+ return;
3875
+ if (!r.isValid || !r.targetBlockId) {
3876
+ m();
3877
+ return;
3878
+ }
3879
+ n(null);
3880
+ const C = r.targetBlockId, k = r.targetParentId;
3881
+ if (!C)
3882
+ return;
3883
+ const { parentId: S, index: A, replaceImageUrl: B } = calculateInsertionIndex(
3884
+ i,
3885
+ C,
3886
+ k,
3887
+ r.position,
3888
+ o
3889
+ ), _ = o._id !== void 0;
3890
+ if (B && isDraggingOnlyImageBlock(o)) {
3891
+ x([C], { image: get(o, "blocks.0.image") }), setTimeout(() => {
3892
+ h(f + 1);
3893
+ }, 50);
3894
+ return;
3895
+ }
3896
+ if (_)
3897
+ d([o._id], S === null ? void 0 : S, A), g(), p([]), u([o._id]);
3898
+ else {
3899
+ const w = o._type || o.type, j = o != null && o.blocks ? isFunction(o == null ? void 0 : o.blocks) ? syncBlocksWithDefaults(o == null ? void 0 : o.blocks()) : o == null ? void 0 : o.blocks : null;
3900
+ c(
3901
+ w === "PartialBlock" ? {
3902
+ blocks: [{ _type: w, _id: "partial-block", partialBlockId: o.partialBlockId }]
3903
+ } : (j == null ? void 0 : j.length) > 0 ? { blocks: [...j] } : { type: w },
3904
+ S,
3905
+ A
3906
+ );
3907
+ }
3908
+ setTimeout(() => {
3909
+ h(f + 1);
3910
+ }, 50);
3911
+ },
3912
+ [
3913
+ o,
3914
+ r,
3915
+ i,
3916
+ b,
3917
+ c,
3918
+ d,
3919
+ n,
3920
+ a,
3921
+ m,
3922
+ g,
3923
+ u,
3924
+ p,
3925
+ f,
3926
+ h,
3927
+ x
3928
+ ]
3929
+ );
3930
+ }, isDraggingOnlyImageBlock = (o) => {
3931
+ var l, c;
3932
+ const n = has(o, "blocks"), r = o == null ? void 0 : o.blocks, a = (r == null ? void 0 : r.length) === 1 && ((l = r == null ? void 0 : r[0]) == null ? void 0 : l._type) === "Image", i = !((c = r == null ? void 0 : r[0]) != null && c._id);
3933
+ return n && a && i;
3934
+ };
3935
+ function calculateInsertionIndex(o, n, r, a, i) {
3936
+ var l, c;
3937
+ try {
3938
+ if (n === r && ((l = i == null ? void 0 : i.blocks) == null ? void 0 : l.length) === 1 && get(i, "blocks.0._type") === "Image" && ((c = find(o, { _id: n })) == null ? void 0 : c._type) === "Image")
3939
+ return { parentId: "", index: -1, replaceImageUrl: !0 };
3940
+ if (n === "canvas" || a === "inside" && n === "canvas")
3941
+ return {
3942
+ parentId: null,
3943
+ // null for root/canvas
3944
+ index: filter(o, (h) => !(h != null && h._parent)).length
3945
+ };
3946
+ if (a === "inside") {
3947
+ const f = filter(o, { _parent: n });
3948
+ return {
3949
+ parentId: n,
3950
+ index: f.length
3951
+ };
3952
+ }
3953
+ const d = !r || r === "canvas", u = d ? void 0 : r, p = filter(o, (f) => d ? !(f != null && f._parent) : (f == null ? void 0 : f._parent) === u), g = p.findIndex((f) => f._id === n);
3954
+ if (g === -1)
3955
+ return {
3956
+ parentId: d ? null : r,
3957
+ index: p.length
3958
+ };
3959
+ const m = a === "before" ? g : g + 1;
3960
+ return {
3961
+ parentId: d ? null : r,
3962
+ index: m
3963
+ };
3964
+ } catch {
3965
+ return {
3966
+ parentId: null,
3967
+ index: filter(o, (p) => !(p != null && p._parent)).length
3968
+ };
3969
+ }
3970
+ }
3971
+ function removeDropTargetAttributes$1(o) {
3972
+ if (!o) return;
3973
+ o.querySelectorAll("[data-drop-target]").forEach((r) => r.removeAttribute("data-drop-target"));
3974
+ }
3975
+ function restoreDraggedElementStyles(o) {
3976
+ if (!o) return;
3977
+ o.querySelectorAll("[data-dragging]").forEach((r) => {
3978
+ r.removeAttribute("data-dragging");
3979
+ });
3980
+ }
3847
3981
  const LEAF_BLOCK_TYPES = [
3848
3982
  "Heading",
3849
3983
  "Text",
@@ -3867,11 +4001,11 @@ const LEAF_BLOCK_TYPES = [
3867
4001
  /** Minimum scroll speed in pixels per frame */
3868
4002
  MIN_SCROLL_SPEED: 10
3869
4003
  }, useBlockDragOver = () => {
3870
- const [o] = useAtom$1(dragAndDropAtom), [n] = useCanvasIframe(), [, r] = useAtom$1(dropIndicatorAtom), { clearParentHighlight: a, highlightParent: i } = useDragParentHighlight(), [l] = useBlocksStore(), c = n == null ? void 0 : n.contentDocument, d = useRef(null), p = useRef(0), u = useCallback(
4004
+ const [o] = useAtom$1(dragAndDropAtom), [n] = useCanvasIframe(), [, r] = useAtom$1(dropIndicatorAtom), { clearParentHighlight: a, highlightParent: i } = useDragParentHighlight(), [l] = useBlocksStore(), c = n == null ? void 0 : n.contentDocument, d = useRef(null), u = useRef(0), p = useCallback(
3871
4005
  (m) => {
3872
4006
  if (!(c != null && c.defaultView)) return;
3873
4007
  const f = c.defaultView, h = f.innerHeight, x = f.scrollY, b = c.documentElement.scrollHeight;
3874
- p.current = m;
4008
+ u.current = m;
3875
4009
  const y = m, C = h - m;
3876
4010
  let k = !1, S = null, A = 0;
3877
4011
  if (y < AUTO_SCROLL_CONFIG.EDGE_ZONE && x > 0 ? (k = !0, S = "up", A = y) : C < AUTO_SCROLL_CONFIG.EDGE_ZONE && x + h < b && (k = !0, S = "down", A = C), !k && d.current !== null) {
@@ -3879,15 +4013,15 @@ const LEAF_BLOCK_TYPES = [
3879
4013
  return;
3880
4014
  }
3881
4015
  if (k && S) {
3882
- const B = 1 - A / AUTO_SCROLL_CONFIG.EDGE_ZONE, E = AUTO_SCROLL_CONFIG.MIN_SCROLL_SPEED + (AUTO_SCROLL_CONFIG.MAX_SCROLL_SPEED - AUTO_SCROLL_CONFIG.MIN_SCROLL_SPEED) * B, w = () => {
4016
+ const B = 1 - A / AUTO_SCROLL_CONFIG.EDGE_ZONE, _ = AUTO_SCROLL_CONFIG.MIN_SCROLL_SPEED + (AUTO_SCROLL_CONFIG.MAX_SCROLL_SPEED - AUTO_SCROLL_CONFIG.MIN_SCROLL_SPEED) * B, w = () => {
3883
4017
  if (!isDragging || !f) {
3884
4018
  d.current = null;
3885
4019
  return;
3886
4020
  }
3887
- const j = S === "up" ? -E : E;
4021
+ const j = S === "up" ? -_ : _;
3888
4022
  f.scrollBy(0, j);
3889
- const v = f.scrollY, _ = v > 0, N = v + h < b, I = p.current, P = h - p.current;
3890
- S === "up" && _ && I < AUTO_SCROLL_CONFIG.EDGE_ZONE || S === "down" && N && P < AUTO_SCROLL_CONFIG.EDGE_ZONE ? d.current = requestAnimationFrame(w) : d.current = null;
4023
+ const v = f.scrollY, E = v > 0, N = v + h < b, I = u.current, P = h - u.current;
4024
+ S === "up" && E && I < AUTO_SCROLL_CONFIG.EDGE_ZONE || S === "down" && N && P < AUTO_SCROLL_CONFIG.EDGE_ZONE ? d.current = requestAnimationFrame(w) : d.current = null;
3891
4025
  };
3892
4026
  d.current === null && (d.current = requestAnimationFrame(w));
3893
4027
  }
@@ -3914,26 +4048,42 @@ const LEAF_BLOCK_TYPES = [
3914
4048
  if (!C)
3915
4049
  return;
3916
4050
  const k = m.clientX, S = m.clientY;
3917
- u(S);
4051
+ p(S);
3918
4052
  const A = detectDropZone(h, k, S, C, c);
3919
4053
  if (!A)
3920
4054
  return;
3921
4055
  const B = h.getAttribute("data-block-type") || "Box";
3922
- let E = !1;
4056
+ let _ = !1;
3923
4057
  const w = LEAF_BLOCK_TYPES.includes(B);
4058
+ if (B === "Image" && C === "Image" && isDraggingOnlyImageBlock(o)) {
4059
+ i(x), r({
4060
+ isVisible: !0,
4061
+ isValid: !0,
4062
+ position: A.position,
4063
+ placeholderOrientation: A.placeholderOrientation,
4064
+ isEmpty: !0,
4065
+ top: h.offsetTop,
4066
+ left: A.rect.left,
4067
+ width: h.clientWidth,
4068
+ height: h.clientHeight,
4069
+ targetBlockId: A.targetBlockId,
4070
+ targetParentId: A.targetBlockId
4071
+ });
4072
+ return;
4073
+ }
3924
4074
  if (A.position === "inside") {
3925
4075
  if (w || y && !canDropWithoutCircularReference(y, x, l))
3926
4076
  return;
3927
- E = canAcceptChildBlock(B, C);
4077
+ _ = canAcceptChildBlock(B, C);
3928
4078
  } else {
3929
- let v = h.parentElement, _ = "Box";
4079
+ let v = h.parentElement, E = "Box";
3930
4080
  for (; v && !v.hasAttribute("data-block-id"); )
3931
4081
  v = v.parentElement;
3932
- if (v && (_ = v.getAttribute("data-block-type") || "Box"), y && !canDropAsSiblingWithoutCircularReference(y, x, l))
4082
+ if (v && (E = v.getAttribute("data-block-type") || "Box"), y && !canDropAsSiblingWithoutCircularReference(y, x, l))
3933
4083
  return;
3934
- E = canAcceptChildBlock(_, C);
4084
+ _ = canAcceptChildBlock(E, C);
3935
4085
  }
3936
- if (!E)
4086
+ if (!_)
3937
4087
  return;
3938
4088
  i(A.targetParentId);
3939
4089
  const j = A.targetParentId || b;
@@ -3949,9 +4099,9 @@ const LEAF_BLOCK_TYPES = [
3949
4099
  height: A.rect.height,
3950
4100
  targetBlockId: A.targetBlockId,
3951
4101
  targetParentId: j
3952
- }), removeDropTargetAttributes$1(c), A.targetElement.setAttribute("data-drop-target", "true");
4102
+ }), removeDropTargetAttributes(c), A.targetElement.setAttribute("data-drop-target", "true");
3953
4103
  }, 300),
3954
- [c, o, r, a, i, l, u]
4104
+ [c, o, r, a, i, l, p]
3955
4105
  );
3956
4106
  return useCallback(
3957
4107
  (m) => {
@@ -3987,7 +4137,7 @@ function getTargetDetail(o) {
3987
4137
  orientation: d
3988
4138
  };
3989
4139
  }
3990
- function removeDropTargetAttributes$1(o) {
4140
+ function removeDropTargetAttributes(o) {
3991
4141
  if (!o) return;
3992
4142
  o.querySelectorAll("[data-drop-target]").forEach((r) => r.removeAttribute("data-drop-target"));
3993
4143
  }
@@ -4011,11 +4161,11 @@ function cleanupDragImage(o) {
4011
4161
  const useBlockDragStart = () => {
4012
4162
  const [, o] = useSelectedBlockIds(), [, n] = useSelectedStylingBlocks(), { clearHighlight: r } = useBlockHighlight(), [, a] = useAtom$1(dragAndDropAtom), [, i] = useAtom$1(dropIndicatorAtom), l = useRef(null);
4013
4163
  return useCallback(
4014
- (c, d, p = !0) => {
4164
+ (c, d, u = !0) => {
4015
4165
  var g;
4016
4166
  l.current && (cleanupDragImage(l.current), l.current = null);
4017
- const u = p ? pick(d, ["type", "blocks", "partialBlockId"]) : d;
4018
- if (a(u), c.dataTransfer.setData("text/plain", JSON.stringify({ block: u })), c.dataTransfer.effectAllowed = "move", !p && d._id) {
4167
+ const p = u ? pick(d, ["type", "blocks", "partialBlockId"]) : d;
4168
+ if (a(p), c.dataTransfer.setData("text/plain", JSON.stringify({ block: p })), c.dataTransfer.effectAllowed = "move", !u && d._id) {
4019
4169
  const m = (g = document.getElementById("canvas-iframe")) == null ? void 0 : g.contentDocument;
4020
4170
  if (m) {
4021
4171
  const f = m.querySelector(`[data-block-id="${d._id}"]`);
@@ -4049,126 +4199,7 @@ const useBlockDragStart = () => {
4049
4199
  },
4050
4200
  [o, r, a, i]
4051
4201
  );
4052
- }, useBlockDrop = () => {
4053
- const [o, n] = useAtom$1(dragAndDropAtom), [r, a] = useAtom$1(dropIndicatorAtom), [i] = useBlocksStore(), [l] = useCanvasIframe(), { addCoreBlock: c } = useAddBlock(), { moveBlocks: d } = useBlocksStoreUndoableActions(), [, p] = useSelectedBlockIds(), [, u] = useSelectedStylingBlocks(), { clearHighlight: g } = useBlockHighlight(), { clearParentHighlight: m } = useDragParentHighlight(), [f, h] = useAtom$1(canvasRenderKeyAtom), x = l == null ? void 0 : l.contentDocument;
4054
- return useCallback(
4055
- (b) => {
4056
- if (b.preventDefault(), b.stopPropagation(), setIsDragging(!1), restoreDraggedElementStyles(x), removeDropTargetAttributes(x), m(), a({
4057
- isVisible: !1,
4058
- isValid: !1,
4059
- position: "inside",
4060
- placeholderOrientation: "horizontal",
4061
- isEmpty: !1,
4062
- top: 0,
4063
- left: 0,
4064
- width: 0,
4065
- height: 0
4066
- }), setTimeout(() => {
4067
- m(), removeDropTargetAttributes(x), a({
4068
- isVisible: !1,
4069
- isValid: !1,
4070
- position: "inside",
4071
- placeholderOrientation: "horizontal",
4072
- isEmpty: !1,
4073
- top: 0,
4074
- left: 0,
4075
- width: 0,
4076
- height: 0
4077
- });
4078
- }, 50), !o)
4079
- return;
4080
- if (!r.isValid || !r.targetBlockId) {
4081
- m();
4082
- return;
4083
- }
4084
- n(null);
4085
- const y = r.targetBlockId, C = r.targetParentId;
4086
- if (!y)
4087
- return;
4088
- const { parentId: k, index: S } = calculateInsertionIndex(
4089
- i,
4090
- y,
4091
- C,
4092
- r.position
4093
- );
4094
- if (o._id !== void 0)
4095
- d([o._id], k === null ? void 0 : k, S), g(), u([]), p([o._id]);
4096
- else {
4097
- const B = o._type || o.type, E = o != null && o.blocks ? isFunction(o == null ? void 0 : o.blocks) ? syncBlocksWithDefaults(o == null ? void 0 : o.blocks()) : o == null ? void 0 : o.blocks : null;
4098
- c(
4099
- B === "PartialBlock" ? {
4100
- blocks: [{ _type: B, _id: "partial-block", partialBlockId: o.partialBlockId }]
4101
- } : (E == null ? void 0 : E.length) > 0 ? { blocks: [...E] } : { type: B },
4102
- k,
4103
- S
4104
- );
4105
- }
4106
- setTimeout(() => {
4107
- h(f + 1);
4108
- }, 50);
4109
- },
4110
- [
4111
- o,
4112
- r,
4113
- i,
4114
- x,
4115
- c,
4116
- d,
4117
- n,
4118
- a,
4119
- m,
4120
- g,
4121
- p,
4122
- u,
4123
- f,
4124
- h
4125
- ]
4126
- );
4127
- };
4128
- function calculateInsertionIndex(o, n, r, a) {
4129
- try {
4130
- if (n === "canvas" || a === "inside" && n === "canvas")
4131
- return {
4132
- parentId: null,
4133
- // null for root/canvas
4134
- index: filter(o, (g) => !(g != null && g._parent)).length
4135
- };
4136
- if (a === "inside") {
4137
- const u = filter(o, { _parent: n });
4138
- return {
4139
- parentId: n,
4140
- index: u.length
4141
- };
4142
- }
4143
- const i = !r || r === "canvas", l = i ? void 0 : r, c = filter(o, (u) => i ? !(u != null && u._parent) : (u == null ? void 0 : u._parent) === l), d = c.findIndex((u) => u._id === n);
4144
- if (d === -1)
4145
- return {
4146
- parentId: i ? null : r,
4147
- index: c.length
4148
- };
4149
- const p = a === "before" ? d : d + 1;
4150
- return {
4151
- parentId: i ? null : r,
4152
- index: p
4153
- };
4154
- } catch {
4155
- return {
4156
- parentId: null,
4157
- index: filter(o, (c) => !(c != null && c._parent)).length
4158
- };
4159
- }
4160
- }
4161
- function removeDropTargetAttributes(o) {
4162
- if (!o) return;
4163
- o.querySelectorAll("[data-drop-target]").forEach((r) => r.removeAttribute("data-drop-target"));
4164
- }
4165
- function restoreDraggedElementStyles(o) {
4166
- if (!o) return;
4167
- o.querySelectorAll("[data-dragging]").forEach((r) => {
4168
- r.removeAttribute("data-dragging");
4169
- });
4170
- }
4171
- const useDragAndDrop = () => {
4202
+ }, useDragAndDrop = () => {
4172
4203
  const o = useBlockDragStart(), n = useBlockDragOver(), r = useBlockDrop(), a = useBlockDragEnd();
4173
4204
  return {
4174
4205
  onDragStart: o,
@@ -4205,11 +4236,11 @@ const FrameContext = React__default.createContext({ document: doc, window: win }
4205
4236
  return "VERTICAL";
4206
4237
  }
4207
4238
  }, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
4208
- const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: i } = useBlocksStoreUndoableActions(), l = 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: l }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), f = getParentBlockOrientation(c, l, a), h = useCallback(
4239
+ const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: i } = useBlocksStoreUndoableActions(), l = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), u = (d == null ? void 0 : d.length) <= 1, p = findIndex(d, { _id: l }), g = p <= 0, m = p + 1 === (d == null ? void 0 : d.length), f = getParentBlockOrientation(c, l, a), h = useCallback(
4209
4240
  (x) => {
4210
- isDisabledControl(g, m, x) || p || (x === "UP" || x === "LEFT" ? i([l], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && i([l], c || null, u + 2), n());
4241
+ isDisabledControl(g, m, x) || u || (x === "UP" || x === "LEFT" ? i([l], c || null, p - 1) : (x === "DOWN" || x === "RIGHT") && i([l], c || null, p + 2), n());
4211
4242
  },
4212
- [g, m, p, u, l, c, n]
4243
+ [g, m, u, p, l, c, n]
4213
4244
  );
4214
4245
  return useHotkeys(
4215
4246
  "shift+up, shift+down, shift+left, shift+right",
@@ -4219,19 +4250,19 @@ const FrameContext = React__default.createContext({ document: doc, window: win }
4219
4250
  },
4220
4251
  { document: a == null ? void 0 : a.contentDocument },
4221
4252
  [h]
4222
- ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: h, orientation: f };
4253
+ ), { isOnlyChild: u, isFirstBlock: g, isLastBlock: m, moveBlock: h, orientation: f };
4223
4254
  }, BlockController = ({ block: o, updateFloatingBar: n }) => {
4224
4255
  const { isOnlyChild: r, isFirstBlock: a, isLastBlock: i, moveBlock: l, orientation: c } = useBlockController(
4225
4256
  o,
4226
4257
  n
4227
4258
  );
4228
- return r ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => c !== p || isDisabledControl(a, i, u) ? null : /* @__PURE__ */ jsx(
4259
+ return r ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: d, dir: u, key: p }) => c !== u || isDisabledControl(a, i, p) ? null : /* @__PURE__ */ jsx(
4229
4260
  d,
4230
4261
  {
4231
- onClick: () => l(u),
4262
+ onClick: () => l(p),
4232
4263
  className: "rounded p-px hover:bg-white hover:text-blue-500"
4233
4264
  },
4234
- u
4265
+ p
4235
4266
  )) });
4236
4267
  }, AiIcon = ({
4237
4268
  className: o = "h-full w-full",
@@ -4269,8 +4300,8 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4269
4300
  const l = i.getAttribute("data-block-id");
4270
4301
  if (!l || !i) return;
4271
4302
  const c = i.closest('[data-block-type="Repeater"]');
4272
- c ? (d = c == null ? void 0 : c.childNodes) == null || d.forEach((p, u) => {
4273
- p.contains(i) && r(u);
4303
+ c ? (d = c == null ? void 0 : c.childNodes) == null || d.forEach((u, p) => {
4304
+ u.contains(i) && r(p);
4274
4305
  }) : r(-1), n(l);
4275
4306
  },
4276
4307
  [o, n, r]
@@ -4292,8 +4323,8 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4292
4323
  return;
4293
4324
  }
4294
4325
  if (l != null && l.getAttribute("data-block-parent")) {
4295
- const c = l.getAttribute("data-style-prop"), d = l.getAttribute("data-style-id"), p = l.getAttribute("data-block-parent");
4296
- pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, { blockId: p, styleId: d, styleProp: c });
4326
+ const c = l.getAttribute("data-style-prop"), d = l.getAttribute("data-style-id"), u = l.getAttribute("data-block-parent");
4327
+ pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, { blockId: u, styleId: d, styleProp: c });
4297
4328
  } else if (l != null && l.getAttribute("data-block-id")) {
4298
4329
  const c = l.getAttribute("data-block-id");
4299
4330
  pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, c === "canvas" ? [] : [c]);
@@ -4333,7 +4364,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4333
4364
  }
4334
4365
  );
4335
4366
  }, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), BlockSelectionHighlighter = () => {
4336
- const o = useSelectedBlock(), { document: n } = useFrame(), [r] = useSelectedStylingBlocks(), [a, i] = useState([]), [, l] = useState([]), { onDragStart: c, onDragEnd: d, isDragging: p } = useDragAndDrop(), [u, g] = useState(null), m = useIsDragAndDropEnabled(), f = (h, x = 0) => {
4367
+ const o = useSelectedBlock(), { document: n } = useFrame(), [r] = useSelectedStylingBlocks(), [a, i] = useState([]), [, l] = useState([]), { onDragStart: c, onDragEnd: d, isDragging: u } = useDragAndDrop(), [p, g] = useState(null), m = useIsDragAndDropEnabled(), f = (h, x = 0) => {
4337
4368
  const { top: b } = h.getBoundingClientRect();
4338
4369
  return b + x >= 0 && b - x <= window.innerHeight;
4339
4370
  };
@@ -4363,14 +4394,14 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4363
4394
  BlockFloatingSelector,
4364
4395
  {
4365
4396
  block: o,
4366
- isDragging: p && !!u,
4367
- selectedBlockElement: a[0] || (p ? u : null)
4397
+ isDragging: u && !!p,
4398
+ selectedBlockElement: a[0] || (u ? p : null)
4368
4399
  }
4369
4400
  )
4370
4401
  }
4371
4402
  );
4372
4403
  }, BlockFloatingSelector = ({ block: o, isDragging: n, selectedBlockElement: r }) => {
4373
- const a = useRemoveBlocks(), i = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, c] = useHighlightBlockId(), [, d] = useSelectedStylingBlocks(), { hasPermission: p } = usePermissions(), { editingBlockId: u } = useInlineEditing(), { document: g } = useFrame(), m = useIsDragAndDropEnabled(), f = useBuilderProp("flags.gotoSettings", !1), { floatingStyles: h, refs: x, update: b } = useFloating({
4404
+ const a = useRemoveBlocks(), i = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, c] = useHighlightBlockId(), [, d] = useSelectedStylingBlocks(), { hasPermission: u } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: g } = useFrame(), m = useIsDragAndDropEnabled(), f = useBuilderProp("flags.gotoSettings", !1), { floatingStyles: h, refs: x, update: b } = useFloating({
4374
4405
  placement: "top-start",
4375
4406
  middleware: [
4376
4407
  shift({
@@ -4408,7 +4439,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4408
4439
  });
4409
4440
  }, [r, o == null ? void 0 : o._id]);
4410
4441
  const [, k] = useSidebarActivePanel();
4411
- return !n && (!r || !o || u) ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
4442
+ return !n && (!r || !o || p) ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
4412
4443
  "div",
4413
4444
  {
4414
4445
  role: "button",
@@ -4438,7 +4469,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4438
4469
  ] }),
4439
4470
  /* @__PURE__ */ jsx("div", { className: `w-full ${m ? "cursor-grab active:cursor-grabbing" : ""}`, children: /* @__PURE__ */ jsx("div", { className: "mr-10 w-full items-center space-x-1 px-1 leading-tight", children: C }) }),
4440
4471
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 pl-1 pr-1.5", children: [
4441
- p(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
4472
+ u(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
4442
4473
  AiIcon,
4443
4474
  {
4444
4475
  className: "h-4 w-4 rounded hover:bg-white hover:text-blue-500",
@@ -4455,21 +4486,21 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4455
4486
  }
4456
4487
  ),
4457
4488
  !m && /* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500" }) }),
4458
- canDuplicateBlock(get(o, "_type", "")) && p(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(
4489
+ canDuplicateBlock(get(o, "_type", "")) && u(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(
4459
4490
  CopyIcon,
4460
4491
  {
4461
4492
  className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500",
4462
4493
  onClick: () => i([o == null ? void 0 : o._id])
4463
4494
  }
4464
4495
  ) : null,
4465
- canDeleteBlock(get(o, "_type", "")) && p(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(
4496
+ canDeleteBlock(get(o, "_type", "")) && u(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(
4466
4497
  TrashIcon,
4467
4498
  {
4468
4499
  className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500",
4469
4500
  onClick: () => a([o == null ? void 0 : o._id])
4470
4501
  }
4471
4502
  ) : null,
4472
- p(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: o, updateFloatingBar: b })
4503
+ u(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: o, updateFloatingBar: b })
4473
4504
  ] })
4474
4505
  ] })
4475
4506
  }
@@ -4672,7 +4703,7 @@ G(Frame, "defaultProps", {
4672
4703
  initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
4673
4704
  });
4674
4705
  const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: n })), useKeyEventWatcher = (o) => {
4675
- const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), i = useRemoveBlocks(), l = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), f = o ? { document: o } : {};
4706
+ const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), i = useRemoveBlocks(), l = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, u] = useCutBlockIds(), [, p] = useCopyBlocks(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), f = o ? { document: o } : {};
4676
4707
  useHotkeys(
4677
4708
  "ctrl+z,meta+z",
4678
4709
  (h) => {
@@ -4690,15 +4721,15 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
4690
4721
  ), useHotkeys(
4691
4722
  "ctrl+x,meta+x",
4692
4723
  (h) => {
4693
- h.preventDefault(), isEmpty(n) || p(n);
4724
+ h.preventDefault(), isEmpty(n) || u(n);
4694
4725
  },
4695
4726
  { ...f, enabled: !isEmpty(n), preventDefault: !0 },
4696
- [n, p]
4727
+ [n, u]
4697
4728
  ), useHotkeys(
4698
4729
  "ctrl+c,meta+c",
4699
- () => u(n),
4730
+ () => p(n),
4700
4731
  { ...f, enabled: !isEmpty(n), preventDefault: !0 },
4701
- [n, u]
4732
+ [n, p]
4702
4733
  ), useHotkeys(
4703
4734
  "ctrl+v,meta+v",
4704
4735
  () => {
@@ -4822,15 +4853,15 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
4822
4853
  }, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
4823
4854
  const [, a] = useSelectedBlockIds(), [, i] = useSelectedStylingBlocks(), l = useRef(null), c = useDebouncedCallback(
4824
4855
  () => {
4825
- const { clientWidth: p } = l.current;
4826
- r(p);
4856
+ const { clientWidth: u } = l.current;
4857
+ r(u);
4827
4858
  },
4828
4859
  [l.current],
4829
4860
  100
4830
4861
  );
4831
4862
  useResizeObserver(l.current, c, l.current !== null), useEffect(() => {
4832
- const { clientWidth: p } = l.current;
4833
- n(p);
4863
+ const { clientWidth: u } = l.current;
4864
+ n(u);
4834
4865
  }, []);
4835
4866
  const d = useCallback(() => {
4836
4867
  a([]), i([]);
@@ -4846,20 +4877,20 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
4846
4877
  }
4847
4878
  );
4848
4879
  }, useDirectBlockDrag = () => {
4849
- const [, o] = useSelectedBlockIds(), { onDragStart: n, onDragEnd: r } = useDragAndDrop(), [a] = useBlocksStore(), i = useRef(null), [l, c] = useAtom$1(lastClickTimeAtom), [d, p] = useAtom$1(clickCountAtom), u = useCallback(
4880
+ const [, o] = useSelectedBlockIds(), { onDragStart: n, onDragEnd: r } = useDragAndDrop(), [a] = useBlocksStore(), i = useRef(null), [l, c] = useAtom$1(lastClickTimeAtom), [d, u] = useAtom$1(clickCountAtom), p = useCallback(
4850
4881
  (f) => {
4851
4882
  var C;
4852
4883
  if (f.button !== 0) return;
4853
4884
  const h = Date.now(), x = h - l;
4854
4885
  if (x < 400 && x > 0) {
4855
- p(2);
4886
+ u(2);
4856
4887
  return;
4857
4888
  }
4858
4889
  c(h);
4859
4890
  const y = (C = f.target.closest("[data-block-id]")) == null ? void 0 : C.getAttribute("data-block-id");
4860
4891
  y && (o([y]), i.current = y);
4861
4892
  },
4862
- [o, l, c, d, p]
4893
+ [o, l, c, d, u]
4863
4894
  ), g = useCallback(
4864
4895
  (f) => {
4865
4896
  if (!i.current) return;
@@ -4871,7 +4902,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
4871
4902
  r(), i.current = null;
4872
4903
  }, [r]);
4873
4904
  return {
4874
- onMouseDown: u,
4905
+ onMouseDown: p,
4875
4906
  onDragStart: g,
4876
4907
  onDragEnd: m
4877
4908
  };
@@ -4889,8 +4920,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
4889
4920
  let d = find(o, { _id: n });
4890
4921
  for (; d; )
4891
4922
  c.push(d), d = find(o, { _id: d._parent });
4892
- const p = find(c, { _type: l.block });
4893
- return p && (a[i] = get(p, get(l, "prop"), null)), a;
4923
+ const u = find(c, { _type: l.block });
4924
+ return u && (a[i] = get(u, get(l, "prop"), null)), a;
4894
4925
  }, {}),
4895
4926
  [o]
4896
4927
  );
@@ -4905,23 +4936,23 @@ const RteDropdownMenu = ({
4905
4936
  from: a,
4906
4937
  menuRef: i
4907
4938
  }) => {
4908
- const { document: l } = useFrame(), [c, d] = useState({ left: void 0, right: void 0, top: void 0, bottom: void 0 }), [p, u] = useState(!1), g = useRef(null);
4939
+ const { document: l } = useFrame(), [c, d] = useState({ left: void 0, right: void 0, top: void 0, bottom: void 0 }), [u, p] = useState(!1), g = useRef(null);
4909
4940
  if (useEffect(() => {
4910
4941
  var C, k;
4911
- if (!p) {
4942
+ if (!u) {
4912
4943
  d({ left: void 0, right: void 0, top: void 0, bottom: void 0 });
4913
4944
  return;
4914
4945
  }
4915
4946
  const m = (C = g.current) == null ? void 0 : C.getBoundingClientRect(), f = (k = i.current) == null ? void 0 : k.getBoundingClientRect();
4916
4947
  let h = m == null ? void 0 : m.left, x = (m == null ? void 0 : m.bottom) + 4, b, y;
4917
4948
  (f == null ? void 0 : f.left) + (f == null ? void 0 : f.width) + 50 >= l.body.offsetWidth && (h = void 0, b = l.body.offsetWidth - (m == null ? void 0 : m.right)), x + 202 >= l.body.clientHeight && (x = null, y = l.body.clientHeight - (m == null ? void 0 : m.bottom) + (f == null ? void 0 : f.height)), d({ left: h, top: x, right: b, bottom: y });
4918
- }, [p]), a === "canvas") {
4949
+ }, [u]), a === "canvas") {
4919
4950
  const m = () => {
4920
- u(!1), o && (o == null || o.view.focus(), o == null || o.chain().focus().run());
4951
+ p(!1), o && (o == null || o.view.focus(), o == null || o.chain().focus().run());
4921
4952
  };
4922
4953
  return /* @__PURE__ */ jsxs(Fragment, { children: [
4923
- /* @__PURE__ */ jsx("div", { ref: g, onClick: () => u((f) => !f), className: "cursor-pointer", children: n }),
4924
- p && (c.left !== void 0 || c.top !== void 0 || c.right !== void 0 || c.bottom !== void 0) && createPortal(
4954
+ /* @__PURE__ */ jsx("div", { ref: g, onClick: () => p((f) => !f), className: "cursor-pointer", children: n }),
4955
+ u && (c.left !== void 0 || c.top !== void 0 || c.right !== void 0 || c.bottom !== void 0) && createPortal(
4925
4956
  /* @__PURE__ */ jsx(
4926
4957
  "div",
4927
4958
  {
@@ -4947,9 +4978,9 @@ const RteDropdownMenu = ({
4947
4978
  )
4948
4979
  ] });
4949
4980
  }
4950
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(DropdownMenu, { open: p, onOpenChange: u, children: [
4981
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(DropdownMenu, { open: u, onOpenChange: p, children: [
4951
4982
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { className: "relative outline-none", asChild: !0, children: n }),
4952
- /* @__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) })
4983
+ /* @__PURE__ */ jsx(DropdownMenuContent, { className: "z-50 rounded-md border bg-white p-1 text-xs shadow-xl", children: u && (typeof r == "function" ? r(() => p(!1)) : r) })
4953
4984
  ] }) });
4954
4985
  };
4955
4986
  atomWithStorage("chai-builder-blocks", []);
@@ -5022,7 +5053,7 @@ const getActiveClasses$1 = (o, n, r) => {
5022
5053
  onRemoveHighlightColor: l,
5023
5054
  onClose: c
5024
5055
  }) => {
5025
- const [d] = useDarkMode(), [p] = useAtom$1(lsThemeAtom), u = (p == null ? void 0 : p.colors) || {}, g = Object.values(u).map((h) => get(h, d ? "1" : "0")), [m, f] = useState("TEXT");
5056
+ const [d] = useDarkMode(), [u] = useAtom$1(lsThemeAtom), p = (u == null ? void 0 : u.colors) || {}, g = Object.values(p).map((h) => get(h, d ? "1" : "0")), [m, f] = useState("TEXT");
5026
5057
  return /* @__PURE__ */ jsxs("div", { id: "rte-widget-color-picker", className: "px-1", children: [
5027
5058
  /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center justify-between rounded-md border bg-muted", children: [
5028
5059
  /* @__PURE__ */ jsx(
@@ -5064,22 +5095,22 @@ const getActiveClasses$1 = (o, n, r) => {
5064
5095
  ] });
5065
5096
  }, RteColorPicker = ({ editor: o, from: n, menuRef: r }) => {
5066
5097
  var k, S;
5067
- const a = (k = o == null ? void 0 : o.getAttributes("textStyle")) == null ? void 0 : k.color, i = (S = o == null ? void 0 : o.getAttributes("highlight")) == null ? void 0 : S.color, [l, c] = useState(a || "#000000F2"), [d, p] = useState(i || "#00000057"), [u, g] = useDebouncedState(l, 150), [m, f] = useDebouncedState(d, 150), h = (A, B) => {
5098
+ const a = (k = o == null ? void 0 : o.getAttributes("textStyle")) == null ? void 0 : k.color, i = (S = o == null ? void 0 : o.getAttributes("highlight")) == null ? void 0 : S.color, [l, c] = useState(a || "#000000F2"), [d, u] = useState(i || "#00000057"), [p, g] = useDebouncedState(l, 150), [m, f] = useDebouncedState(d, 150), h = (A, B) => {
5068
5099
  B ? (c(A), g(A)) : (o == null || o.chain().setColor(A).run(), c(A));
5069
5100
  }, x = (A, B) => {
5070
- B ? (p(A), f(A)) : (o == null || o.chain().setHighlight({ color: A }).run(), p(A));
5101
+ B ? (u(A), f(A)) : (o == null || o.chain().setHighlight({ color: A }).run(), u(A));
5071
5102
  }, b = () => {
5072
5103
  o == null || o.chain().unsetColor().run(), c("#000000F2");
5073
5104
  }, y = () => {
5074
5105
  o == null || o.chain().unsetHighlight().run();
5075
5106
  };
5076
5107
  return useEffect(() => {
5077
- i && p(i);
5108
+ i && u(i);
5078
5109
  }, [i]), useEffect(() => {
5079
5110
  m != null && m.includes("#") && (m == null ? void 0 : m.length) >= 3 && (o == null || o.chain().setHighlight({ color: m }).run());
5080
5111
  }, [m]), useEffect(() => {
5081
- u != null && u.includes("#") && (u == null ? void 0 : u.length) >= 3 && (o == null || o.chain().setColor(u).run());
5082
- }, [u]), /* @__PURE__ */ jsx(
5112
+ p != null && p.includes("#") && (p == null ? void 0 : p.length) >= 3 && (o == null || o.chain().setColor(p).run());
5113
+ }, [p]), /* @__PURE__ */ jsx(
5083
5114
  RteDropdownMenu,
5084
5115
  {
5085
5116
  editor: o,
@@ -5422,11 +5453,11 @@ const RichTextEditor = memo(
5422
5453
  value: o,
5423
5454
  blockId: "active-inline-editing-element",
5424
5455
  placeholder: "Enter text here",
5425
- onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
5426
- onBlur: ({ editor: u, event: g }) => {
5456
+ onUpdate: ({ editor: p }) => a((p == null ? void 0 : p.getHTML()) || ""),
5457
+ onBlur: ({ editor: p, event: g }) => {
5427
5458
  const m = g == null ? void 0 : g.relatedTarget, f = l.querySelector(".ProseMirror"), h = l.querySelector(".tippy-box"), x = l.querySelector("#chai-rich-text-menu-bar"), b = f == null ? void 0 : f.contains(m), y = h == null ? void 0 : h.contains(m), C = x == null ? void 0 : x.contains(m), k = window.document.getElementById("rte-widget-color-picker");
5428
5459
  if (!b && !y && !C && !k) {
5429
- const S = (u == null ? void 0 : u.getHTML()) || "";
5460
+ const S = (p == null ? void 0 : p.getHTML()) || "";
5430
5461
  r(S);
5431
5462
  }
5432
5463
  },
@@ -5434,8 +5465,8 @@ const RichTextEditor = memo(
5434
5465
  });
5435
5466
  useEffect(() => {
5436
5467
  var g, m;
5437
- const u = getInitialTextAlign(n);
5438
- 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", {
5468
+ const p = getInitialTextAlign(n);
5469
+ p && ((g = c == null ? void 0 : c.commands) == null || g.setTextAlign(p)), (m = c == null ? void 0 : c.commands) == null || m.focus(), c == null || c.emit("focus", {
5439
5470
  editor: c,
5440
5471
  event: new FocusEvent("focus"),
5441
5472
  transaction: []
@@ -5443,14 +5474,14 @@ const RichTextEditor = memo(
5443
5474
  }, [c]);
5444
5475
  const d = useMemo(() => {
5445
5476
  var m;
5446
- const u = "max-w-none shadow-none outline outline-[2px] [&_*]:shadow-none";
5447
- if (!n) return u;
5477
+ const p = "max-w-none shadow-none outline outline-[2px] [&_*]:shadow-none";
5478
+ if (!n) return p;
5448
5479
  const g = ((m = n == null ? void 0 : n.className) == null ? void 0 : m.replace("sr-only", "")) || "";
5449
- return `${u} ${g}`;
5450
- }, [n]), p = (u) => {
5451
- u.key === "Escape" && i(u);
5480
+ return `${p} ${g}`;
5481
+ }, [n]), u = (p) => {
5482
+ p.key === "Escape" && i(p);
5452
5483
  };
5453
- return c && /* @__PURE__ */ jsxs("div", { onKeyDown: p, onClick: (u) => u.stopPropagation(), className: "relative", children: [
5484
+ return c && /* @__PURE__ */ jsxs("div", { onKeyDown: u, onClick: (p) => p.stopPropagation(), className: "relative", children: [
5454
5485
  /* @__PURE__ */ jsx(
5455
5486
  BubbleMenu,
5456
5487
  {
@@ -5465,7 +5496,7 @@ const RichTextEditor = memo(
5465
5496
  EditorContent,
5466
5497
  {
5467
5498
  id: "active-inline-editing-element",
5468
- onKeyDown: p,
5499
+ onKeyDown: u,
5469
5500
  value: o,
5470
5501
  editor: c,
5471
5502
  className: d
@@ -5491,11 +5522,11 @@ const RichTextEditor = memo(
5491
5522
  } else
5492
5523
  r();
5493
5524
  }, [c, d]);
5494
- const p = useMemo(() => {
5525
+ const u = useMemo(() => {
5495
5526
  var h;
5496
5527
  const f = ((h = o == null ? void 0 : o.tagName) == null ? void 0 : h.toLowerCase()) || "div";
5497
5528
  return f === "button" ? "div" : f;
5498
- }, [o]), u = useCallback(
5529
+ }, [o]), p = useCallback(
5499
5530
  (f) => {
5500
5531
  (f.key === "Enter" || f.key === "Escape") && l(f);
5501
5532
  },
@@ -5518,16 +5549,16 @@ const RichTextEditor = memo(
5518
5549
  }
5519
5550
  };
5520
5551
  }, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
5521
- return /* @__PURE__ */ jsx(Fragment, { children: createElement(p, {
5552
+ return /* @__PURE__ */ jsx(Fragment, { children: createElement(u, {
5522
5553
  ref: a,
5523
5554
  onBlur: g,
5524
- onKeyDown: u,
5555
+ onKeyDown: p,
5525
5556
  ...m
5526
5557
  }) });
5527
5558
  }
5528
5559
  ), WithBlockTextEditor = memo(
5529
5560
  ({ block: o, children: n }) => {
5530
- const r = "content", { document: a } = useFrame(), { editingBlockId: i, editingItemIndex: l, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), f = useUpdateBlocksProps(), { selectedLang: h } = useLanguages(), [, x] = useSelectedBlockIds(), b = useRef(null), y = i, { blockContent: C, blockType: k } = useMemo(() => {
5561
+ const r = "content", { document: a } = useFrame(), { editingBlockId: i, editingItemIndex: l, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [u, p] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), f = useUpdateBlocksProps(), { selectedLang: h } = useLanguages(), [, x] = useSelectedBlockIds(), b = useRef(null), y = i, { blockContent: C, blockType: k } = useMemo(() => {
5531
5562
  var N;
5532
5563
  const w = o._type;
5533
5564
  let j = o[r];
@@ -5537,7 +5568,7 @@ const RichTextEditor = memo(
5537
5568
  (w) => {
5538
5569
  var v;
5539
5570
  const j = w || ((v = g.current) == null ? void 0 : v.innerText);
5540
- f([y], { [r]: j }), u(null), c(null), d(-1), x([]), y && setTimeout(() => x([y]), 100);
5571
+ f([y], { [r]: j }), p(null), c(null), d(-1), x([]), y && setTimeout(() => x([y]), 100);
5541
5572
  },
5542
5573
  [y, f, c, x, h]
5543
5574
  ), A = useDebouncedCallback(
@@ -5556,16 +5587,16 @@ const RichTextEditor = memo(
5556
5587
  [x, y, h]
5557
5588
  );
5558
5589
  useEffect(() => {
5559
- var _;
5590
+ var E;
5560
5591
  if (!y) return;
5561
5592
  const w = `[data-block-id="${y}"]`, j = l >= 0 ? `[data-block-index="${l}"]` : "", v = a.querySelector(`${w}${j}`);
5562
- v && ((_ = v == null ? void 0 : v.classList) == null || _.add("sr-only"), u(v));
5593
+ v && ((E = v == null ? void 0 : v.classList) == null || E.add("sr-only"), p(v));
5563
5594
  }, [y, k, a, l]);
5564
- const E = useMemo(() => p ? (m(), ["RichText", "Paragraph"].includes(k) ? /* @__PURE__ */ jsx(
5595
+ const _ = useMemo(() => u ? (m(), ["RichText", "Paragraph"].includes(k) ? /* @__PURE__ */ jsx(
5565
5596
  RichTextEditor,
5566
5597
  {
5567
5598
  blockContent: C,
5568
- editingElement: p,
5599
+ editingElement: u,
5569
5600
  onChange: A,
5570
5601
  onClose: S,
5571
5602
  onEscape: B
@@ -5575,14 +5606,14 @@ const RichTextEditor = memo(
5575
5606
  {
5576
5607
  editorRef: g,
5577
5608
  blockContent: C,
5578
- editingElement: p,
5609
+ editingElement: u,
5579
5610
  onClose: S,
5580
5611
  onChange: A,
5581
5612
  onEscape: B
5582
5613
  }
5583
- )) : null, [p, y, k, C, S, h]);
5614
+ )) : null, [u, y, k, C, S, h]);
5584
5615
  return /* @__PURE__ */ jsxs(Fragment, { children: [
5585
- E,
5616
+ _,
5586
5617
  n
5587
5618
  ] });
5588
5619
  },
@@ -5615,7 +5646,7 @@ const RichTextEditor = memo(
5615
5646
  blockAtom: n,
5616
5647
  children: r
5617
5648
  }) => {
5618
- const { editingBlockId: a, editingItemIndex: i } = useInlineEditing(), [l] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(l._type), [l._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useAtom$1(dataBindingActiveAtom), f = get(c, "component", null), { index: h, key: x } = useContext(RepeaterContext), { mode: b } = useEditorMode(), y = useAtomValue$1(chaiDesignTokensAtom), C = useIsDragAndDropEnabled(), k = b === "edit", S = useDirectBlockDrag(), A = useMemo(
5649
+ const { editingBlockId: a, editingItemIndex: i } = useInlineEditing(), [l] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(l._type), [l._type]), { selectedLang: d, fallbackLang: u } = useLanguages(), p = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useAtom$1(dataBindingActiveAtom), f = get(c, "component", null), { index: h, key: x } = useContext(RepeaterContext), { mode: b } = useEditorMode(), y = useAtomValue$1(chaiDesignTokensAtom), C = useIsDragAndDropEnabled(), k = b === "edit", S = useDirectBlockDrag(), A = useMemo(
5619
5650
  () => m ? applyBindingToBlockProps(applyLanguage(l, d, c), g, {
5620
5651
  index: h,
5621
5652
  key: x
@@ -5624,9 +5655,9 @@ const RichTextEditor = memo(
5624
5655
  ), B = useMemo(
5625
5656
  () => getBlockTagAttributes(l, !0, y),
5626
5657
  [l, getBlockTagAttributes, y]
5627
- ), E = useMemo(
5628
- () => u(l._id, getBlockRuntimeProps(l._type)),
5629
- [l._id, l._type, u, getBlockRuntimeProps]
5658
+ ), _ = useMemo(
5659
+ () => p(l._id, getBlockRuntimeProps(l._type)),
5660
+ [l._id, l._type, p, getBlockRuntimeProps]
5630
5661
  ), w = useMemo(() => {
5631
5662
  const P = {
5632
5663
  "data-block-id": l._id,
@@ -5635,24 +5666,24 @@ const RichTextEditor = memo(
5635
5666
  };
5636
5667
  return k && C ? {
5637
5668
  ...P,
5638
- draggable: !0,
5669
+ draggable: !a,
5639
5670
  onMouseDown: S.onMouseDown,
5640
5671
  onDragStart: S.onDragStart,
5641
5672
  onDragEnd: S.onDragEnd
5642
5673
  } : P;
5643
- }, [l._id, l._type, h, k, C, S]), j = useMemo(
5674
+ }, [l._id, l._type, h, k, C, S, a]), j = useMemo(
5644
5675
  () => ({
5645
5676
  blockProps: w,
5646
5677
  inBuilder: b === "edit",
5647
- lang: d || p,
5678
+ lang: d || u,
5648
5679
  ...A,
5649
5680
  ...B,
5650
- ...E,
5681
+ ..._,
5651
5682
  ...o
5652
5683
  }),
5653
- [b, w, d, p, A, B, E, o]
5654
- ), v = useMemo(() => !CORE_BLOCKS.includes(l._type), [l._type]), _ = useMemo(() => get(l, "_show", !0), [l]);
5655
- if (isNull(f) || !_) return null;
5684
+ [b, w, d, u, A, B, _, o]
5685
+ ), v = useMemo(() => !CORE_BLOCKS.includes(l._type), [l._type]), E = useMemo(() => get(l, "_show", !0), [l]);
5686
+ if (isNull(f) || !E) return null;
5656
5687
  let N = /* @__PURE__ */ jsx(Suspense, { children: createElement(f, {
5657
5688
  ...j,
5658
5689
  children: r({
@@ -5705,12 +5736,12 @@ const RichTextEditor = memo(
5705
5736
  [o, n]
5706
5737
  );
5707
5738
  const c = useCallback(
5708
- (d) => filter(o, (p) => p._parent === d).length > 0,
5739
+ (d) => filter(o, (u) => u._parent === d).length > 0,
5709
5740
  [o]
5710
5741
  );
5711
5742
  return c && (a === "Heading" || a === "Paragraph" || a === "Link") && (l = adjustSpacingInContentBlocks(l)), map(l, (d) => {
5712
- const p = i(d._id);
5713
- return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: d, children: (u) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: p, asyncProps: u, children: ({ _id: g, _type: m, partialBlockId: f, repeaterItems: h, $repeaterItemsKey: x }) => m === "Repeater" ? isArray(h) && h.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: f }) }) : c(g) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) : null }) }, d._id) : null;
5743
+ const u = i(d._id);
5744
+ return u ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: d, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: u, asyncProps: p, children: ({ _id: g, _type: m, partialBlockId: f, repeaterItems: h, $repeaterItemsKey: x }) => m === "Repeater" ? isArray(h) && h.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: f }) }) : c(g) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) : null }) }, d._id) : null;
5714
5745
  });
5715
5746
  }, PageBlocksRenderer = () => {
5716
5747
  const [o] = useBlocksStore();
@@ -5720,24 +5751,24 @@ const RichTextEditor = memo(
5720
5751
  return /* @__PURE__ */ jsx(Fragment, { children: r });
5721
5752
  }, useCanvasScale = (o) => {
5722
5753
  const [n] = useCanvasDisplayWidth(), [, r] = useCanvasZoom(), a = useBuilderProp("htmlDir", "ltr"), [i, l] = useState({}), c = useCallback(() => {
5723
- const { width: d, height: p } = o;
5754
+ const { width: d, height: u } = o;
5724
5755
  if (d < n) {
5725
- const u = parseFloat((d / n).toFixed(2).toString());
5756
+ const p = parseFloat((d / n).toFixed(2).toString());
5726
5757
  let g = {};
5727
- const m = p * u, f = d * u;
5728
- p && (g = {
5758
+ const m = u * p, f = d * p;
5759
+ u && (g = {
5729
5760
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
5730
- height: 100 + (p - m) / m * 100 + "%",
5761
+ height: 100 + (u - m) / m * 100 + "%",
5731
5762
  width: 100 + (d - f) / f * 100 + "%"
5732
5763
  }), l({
5733
5764
  position: "relative",
5734
5765
  top: 0,
5735
- transform: `scale(${u})`,
5766
+ transform: `scale(${p})`,
5736
5767
  transformOrigin: a === "rtl" ? "top right" : "top left",
5737
5768
  ...g,
5738
5769
  maxWidth: "none"
5739
5770
  // TODO: Add max-width to the wrapper
5740
- }), r(u * 100);
5771
+ }), r(p * 100);
5741
5772
  } else
5742
5773
  l({}), r(100);
5743
5774
  }, [n, o, a, r]);
@@ -5752,10 +5783,10 @@ const RichTextEditor = memo(
5752
5783
  return;
5753
5784
  const d = getElementByDataBlockId(a, first(l));
5754
5785
  if (d) {
5755
- const p = d.getAttribute("data-style-prop");
5756
- if (p) {
5757
- const u = d.getAttribute("data-style-id"), g = d.getAttribute("data-block-parent");
5758
- r([{ id: u, prop: p, blockId: g }]);
5786
+ const u = d.getAttribute("data-style-prop");
5787
+ if (u) {
5788
+ const p = d.getAttribute("data-style-id"), g = d.getAttribute("data-block-parent");
5789
+ r([{ id: p, prop: u, blockId: g }]);
5759
5790
  }
5760
5791
  }
5761
5792
  }, 100);
@@ -5763,13 +5794,13 @@ const RichTextEditor = memo(
5763
5794
  d && (!isEmpty(d) && !includes(l, first(d)) && (c == null || c.closeAll()), o(d));
5764
5795
  }), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, (d) => {
5765
5796
  if (!d) return;
5766
- const { blockId: p, styleId: u, styleProp: g } = d;
5767
- p && (includes(l, p) || c == null || c.closeAll(), r([{ id: u, prop: g, blockId: p }]), o([p]));
5797
+ const { blockId: u, styleId: p, styleProp: g } = d;
5798
+ u && (includes(l, u) || c == null || c.closeAll(), r([{ id: p, prop: g, blockId: u }]), o([u]));
5768
5799
  }), usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION, () => {
5769
5800
  i(), o([]), r([]);
5770
5801
  }), null;
5771
5802
  }, StaticCanvas = () => {
5772
- const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [i, l] = useState({ width: 0, height: 0 }), c = useCanvasScale(i), [, d] = useCanvasIframe(), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), { onDragOver: g, onDrop: m, onDragEnd: f } = useDragAndDrop(), h = useDropIndicator(), x = useCallback(
5803
+ const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [i, l] = useState({ width: 0, height: 0 }), c = useCanvasScale(i), [, d] = useCanvasIframe(), u = useBuilderProp("loading", !1), p = useBuilderProp("htmlDir", "ltr"), { onDragOver: g, onDrop: m, onDragEnd: f } = useDragAndDrop(), h = useDropIndicator(), x = useCallback(
5773
5804
  (y) => {
5774
5805
  l((C) => ({ ...C, width: y }));
5775
5806
  },
@@ -5782,8 +5813,8 @@ const RichTextEditor = memo(
5782
5813
  }, [a, o]);
5783
5814
  const b = useMemo(() => {
5784
5815
  let y = IframeInitialContent;
5785
- return y = y.replace("__HTML_DIR__", u), y;
5786
- }, [u]);
5816
+ return y = y.replace("__HTML_DIR__", p), y;
5817
+ }, [p]);
5787
5818
  return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: x, onResize: x, children: /* @__PURE__ */ jsx(
5788
5819
  "div",
5789
5820
  {
@@ -5808,7 +5839,7 @@ const RichTextEditor = memo(
5808
5839
  /* @__PURE__ */ jsx(HeadTags, {}),
5809
5840
  /* @__PURE__ */ jsxs(Provider$1, { children: [
5810
5841
  /* @__PURE__ */ jsxs(Canvas, { children: [
5811
- p ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
5842
+ u ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
5812
5843
  /* @__PURE__ */ jsx(AddBlockAtBottom, {})
5813
5844
  ] }),
5814
5845
  /* @__PURE__ */ jsx(CanvasEventsWatcher, {})
@@ -5837,7 +5868,7 @@ const RichTextEditor = memo(
5837
5868
  /* @__PURE__ */ jsx("p", { className: "font-semibold", children: o("Oops! Something went wrong.") }),
5838
5869
  /* @__PURE__ */ jsx("p", { children: o("Please try again.") })
5839
5870
  ] }) });
5840
- }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-zas3OmxC.js")), CanvasArea = () => {
5871
+ }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-CelZf2Qf.js")), CanvasArea = () => {
5841
5872
  const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
5842
5873
  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: [
5843
5874
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -5878,8 +5909,8 @@ const RichTextEditor = memo(
5878
5909
  }, [o]);
5879
5910
  const c = (d) => {
5880
5911
  l(d);
5881
- const p = sanitizeSvg(d);
5882
- n(p);
5912
+ const u = sanitizeSvg(d);
5913
+ n(u);
5883
5914
  };
5884
5915
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex flex-col gap-2", id: "icon-picker-field", children: [
5885
5916
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
@@ -5905,24 +5936,24 @@ const RichTextEditor = memo(
5905
5936
  ] })
5906
5937
  ] });
5907
5938
  }, DefaultMediaManager = ({ close: o, onSelect: n, mode: r = "image" }) => {
5908
- const [a, i] = useState(""), [l, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), m = async (h) => {
5939
+ const [a, i] = useState(""), [l, c] = useState(!1), [d, u] = useState(!1), [p, g] = useState(null), m = async (h) => {
5909
5940
  if (!h.trim()) {
5910
- p(!1), g("Please enter a URL");
5941
+ u(!1), g("Please enter a URL");
5911
5942
  return;
5912
5943
  }
5913
5944
  try {
5914
- c(!0), g(null), p(!0), g(null);
5945
+ c(!0), g(null), u(!0), g(null);
5915
5946
  } catch {
5916
- p(!1), g("Error validating URL");
5947
+ u(!1), g("Error validating URL");
5917
5948
  } finally {
5918
5949
  c(!1);
5919
5950
  }
5920
5951
  }, { t: f } = useTranslation();
5921
5952
  return /* @__PURE__ */ jsxs("div", { className: "flex w-96 flex-col gap-4 p-4", children: [
5922
5953
  /* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold", children: f(`${r.charAt(0).toUpperCase() + r.slice(1)} Manager`) }),
5923
- u && /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
5954
+ p && /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
5924
5955
  /* @__PURE__ */ jsx(ExclamationTriangleIcon, { className: "h-4 w-4" }),
5925
- /* @__PURE__ */ jsx(AlertDescription, { children: u })
5956
+ /* @__PURE__ */ jsx(AlertDescription, { children: p })
5926
5957
  ] }),
5927
5958
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
5928
5959
  /* @__PURE__ */ jsx(
@@ -5958,12 +5989,12 @@ const RichTextEditor = memo(
5958
5989
  mode: a = "image"
5959
5990
  }) => {
5960
5991
  const [i, l] = useState(!1), c = useMediaManagerComponent();
5961
- return /* @__PURE__ */ jsxs(Dialog, { open: i, onOpenChange: (p) => l(p), children: [
5992
+ return /* @__PURE__ */ jsxs(Dialog, { open: i, onOpenChange: (u) => l(u), children: [
5962
5993
  /* @__PURE__ */ jsx(DialogTrigger, { asChild: !0, children: n }),
5963
5994
  /* @__PURE__ */ jsxs(DialogContent, { className: "flex max-h-[90vh] max-w-7xl border-border md:w-fit", children: [
5964
5995
  /* @__PURE__ */ jsx(DialogTitle, { className: "sr-only", children: "Media Manager" }),
5965
- /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: c ? /* @__PURE__ */ jsx(c, { close: () => l(!1), onSelect: (...p) => {
5966
- r.call(void 0, ...p), l(!1);
5996
+ /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: c ? /* @__PURE__ */ jsx(c, { close: () => l(!1), onSelect: (...u) => {
5997
+ r.call(void 0, ...u), l(!1);
5967
5998
  }, mode: a, assetId: o }) : null })
5968
5999
  ] })
5969
6000
  ] });
@@ -5975,19 +6006,19 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
5975
6006
  const n = ((i = o.split("/").pop()) == null ? void 0 : i.split("?")[0]) || "";
5976
6007
  return [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".bmp", ".ico", ".avif"].some((l) => n.toLowerCase().endsWith(l)) ? n : "";
5977
6008
  }, ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
5978
- const { t: i } = useTranslation(), { selectedLang: l } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = usePageExternalData(), u = r.split(".").pop() || "", g = l ? `_${u}Id-${l}` : `_${u}Id`, m = isEmpty(l) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), f = get(c, g, m ? c == null ? void 0 : c.assetId : ""), h = useMemo(() => {
6009
+ const { t: i } = useTranslation(), { selectedLang: l } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), u = usePageExternalData(), p = r.split(".").pop() || "", g = l ? `_${p}Id-${l}` : `_${p}Id`, m = isEmpty(l) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), f = get(c, g, m ? c == null ? void 0 : c.assetId : ""), h = useMemo(() => {
5979
6010
  if (!o || !c || !/\{\{.*?\}\}/.test(o)) return o;
5980
- const S = { ...c, [u]: o }, A = applyBindingToBlockProps(S, p, { index: -1, key: "" });
5981
- return get(A, u, o);
5982
- }, [o, c, p, u]), x = !!f || h !== PLACEHOLDER_IMAGE, b = (k) => {
6011
+ const S = { ...c, [p]: o }, A = applyBindingToBlockProps(S, u, { index: -1, key: "" });
6012
+ return get(A, p, o);
6013
+ }, [o, c, u, p]), x = !!f || h !== PLACEHOLDER_IMAGE, b = (k) => {
5983
6014
  const S = isArray(k) ? first(k) : k;
5984
6015
  if (S) {
5985
6016
  n(S == null ? void 0 : S.url);
5986
- const A = S == null ? void 0 : S.width, B = S == null ? void 0 : S.height, E = g.includes("mobile");
6017
+ const A = S == null ? void 0 : S.width, B = S == null ? void 0 : S.height, _ = g.includes("mobile");
5987
6018
  if (c != null && c._id) {
5988
6019
  const w = {
5989
- ...A && { [E ? "mobileWidth" : "width"]: A },
5990
- ...B && { [E ? "mobileHeight" : "height"]: B },
6020
+ ...A && { [_ ? "mobileWidth" : "width"]: A },
6021
+ ...B && { [_ ? "mobileHeight" : "height"]: B },
5991
6022
  ...S.description && { alt: S.description }
5992
6023
  };
5993
6024
  if (set(w, g, S.id), isEmpty(w)) return;
@@ -6052,13 +6083,13 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
6052
6083
  ] })
6053
6084
  ] });
6054
6085
  }, PathDropdown = ({ data: o, onSelect: n, dataType: r }) => {
6055
- const [a, i] = React__default.useState([]), [l, c] = React__default.useState(o), d = (m) => Array.isArray(m) ? "array" : typeof m == "object" && m !== null ? "object" : "value", p = React__default.useCallback(
6086
+ const [a, i] = React__default.useState([]), [l, c] = React__default.useState(o), d = (m) => Array.isArray(m) ? "array" : typeof m == "object" && m !== null ? "object" : "value", u = React__default.useCallback(
6056
6087
  (m) => {
6057
6088
  const f = (h) => r === "value" ? h === "value" || h === "object" : r === "array" ? h === "array" : h === r;
6058
6089
  m.type === "object" ? (i((h) => [...h, m.key]), c(m.value)) : f(m.type) && n([...a, m.key].join("."), r);
6059
6090
  },
6060
6091
  [a, n, r]
6061
- ), u = React__default.useCallback(() => {
6092
+ ), p = React__default.useCallback(() => {
6062
6093
  if (a.length > 0) {
6063
6094
  const m = a.slice(0, -1);
6064
6095
  i(m), c(m.reduce((f, h) => f[h], o));
@@ -6069,7 +6100,7 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
6069
6100
  /* @__PURE__ */ jsxs(CommandList, { children: [
6070
6101
  /* @__PURE__ */ jsx(CommandEmpty, { children: t("No option found.") }),
6071
6102
  /* @__PURE__ */ jsxs(CommandGroup, { children: [
6072
- a.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: u, className: "flex items-center text-sm", children: [
6103
+ a.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: p, className: "flex items-center text-sm", children: [
6073
6104
  /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "mr-2 h-4 w-4" }),
6074
6105
  t("Back")
6075
6106
  ] }),
@@ -6078,7 +6109,7 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
6078
6109
  {
6079
6110
  value: m.key,
6080
6111
  disabled: !1,
6081
- onSelect: () => p(m),
6112
+ onSelect: () => u(m),
6082
6113
  className: "flex items-center justify-between",
6083
6114
  children: [
6084
6115
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-2", children: [
@@ -6109,7 +6140,7 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
6109
6140
  ] });
6110
6141
  };
6111
6142
  function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
6112
- const [a, i] = React__default.useState(!1), l = useBuilderProp("collections", []), c = React__default.useMemo(() => r === "array" ? { ...l.map((p) => p.id).reduce((p, u) => ({ ...p, [COLLECTION_PREFIX + u]: [] }), {}), ...o } : o, [o, l, r]);
6143
+ const [a, i] = React__default.useState(!1), l = useBuilderProp("collections", []), c = React__default.useMemo(() => r === "array" ? { ...l.map((u) => u.id).reduce((u, p) => ({ ...u, [COLLECTION_PREFIX + p]: [] }), {}), ...o } : o, [o, l, r]);
6113
6144
  return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: i, children: [
6114
6145
  /* @__PURE__ */ jsxs(Tooltip, { children: [
6115
6146
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
@@ -6138,8 +6169,8 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
6138
6169
  PathDropdown,
6139
6170
  {
6140
6171
  data: c,
6141
- onSelect: (d, p) => {
6142
- n(d, p), i(!1);
6172
+ onSelect: (d, u) => {
6173
+ n(d, u), i(!1);
6143
6174
  },
6144
6175
  dataType: r
6145
6176
  }
@@ -6152,20 +6183,20 @@ const DataBindingSelector = ({
6152
6183
  id: r,
6153
6184
  formData: a
6154
6185
  }) => {
6155
- const i = usePageExternalData(), l = useBuilderProp("flags.dataBinding", !0), c = useSelectedBlockHierarchy(), d = useSelectedBlock(), p = useMemo(() => {
6186
+ const i = usePageExternalData(), l = useBuilderProp("flags.dataBinding", !0), c = useSelectedBlockHierarchy(), d = useSelectedBlock(), u = useMemo(() => {
6156
6187
  if (c.length === 1) return "";
6157
6188
  const m = c.find((x) => x._type === "Repeater"), h = get(m, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
6158
6189
  return `${REPEATER_PREFIX}${startsWith(h, COLLECTION_PREFIX) ? `${h}/${m._id}` : h}`;
6159
- }, [c]), u = useMemo(() => first(get(i, p.replace(REPEATER_PREFIX, ""), [])), [p, i]), g = useCallback(
6190
+ }, [c]), p = useMemo(() => first(get(i, u.replace(REPEATER_PREFIX, ""), [])), [u, i]), g = useCallback(
6160
6191
  (m, f) => {
6161
- if (m = isEmpty(p) ? m : m.replace(`${p}`, "$index"), f === "array" || f === "object") {
6192
+ if (m = isEmpty(u) ? m : m.replace(`${u}`, "$index"), f === "array" || f === "object") {
6162
6193
  n(`{{${m}}}`, {}, r);
6163
6194
  return;
6164
6195
  }
6165
6196
  const h = (C) => /[.,!?;:]/.test(C), x = (C, k, S) => {
6166
6197
  let A = "", B = "";
6167
- const E = k > 0 ? C[k - 1] : "", w = k < C.length ? C[k] : "";
6168
- return k > 0 && (E === "." || !h(E) && E !== " ") && (A = " "), k < C.length && !h(w) && w !== " " && (B = " "), {
6198
+ const _ = k > 0 ? C[k - 1] : "", w = k < C.length ? C[k] : "";
6199
+ return k > 0 && (_ === "." || !h(_) && _ !== " ") && (A = " "), k < C.length && !h(w) && w !== " " && (B = " "), {
6169
6200
  text: A + S + B,
6170
6201
  prefixLength: A.length,
6171
6202
  suffixLength: B.length
@@ -6182,11 +6213,11 @@ const DataBindingSelector = ({
6182
6213
  if (S !== A)
6183
6214
  C.chain().deleteSelection().insertContent(k).run();
6184
6215
  else {
6185
- const { state: E } = C, w = E.selection.from, j = E.doc.textBetween(Math.max(0, w - 1), w), v = E.doc.textBetween(w, Math.min(w + 1, E.doc.content.size));
6186
- let _ = "";
6187
- w > 0 && j !== " " && !h(j) && (_ = " ");
6216
+ const { state: _ } = C, w = _.selection.from, j = _.doc.textBetween(Math.max(0, w - 1), w), v = _.doc.textBetween(w, Math.min(w + 1, _.doc.content.size));
6217
+ let E = "";
6218
+ w > 0 && j !== " " && !h(j) && (E = " ");
6188
6219
  let N = "";
6189
- v && v !== " " && !h(v) && (N = " "), C.chain().insertContent(_ + k + N).run();
6220
+ v && v !== " " && !h(v) && (N = " "), C.chain().insertContent(E + k + N).run();
6190
6221
  }
6191
6222
  setTimeout(() => n(C.getHTML(), {}, r), 100);
6192
6223
  return;
@@ -6194,21 +6225,21 @@ const DataBindingSelector = ({
6194
6225
  } else {
6195
6226
  const C = b, k = C.selectionStart || 0, S = C.value || "", A = C.selectionEnd || k;
6196
6227
  if (A > k) {
6197
- const v = `{{${m}}}`, { text: _ } = x(S, k, v), N = S.slice(0, k) + _ + S.slice(A);
6228
+ const v = `{{${m}}}`, { text: E } = x(S, k, v), N = S.slice(0, k) + E + S.slice(A);
6198
6229
  n(N, {}, r);
6199
6230
  return;
6200
6231
  }
6201
- const E = `{{${m}}}`, { text: w } = x(S, k, E), j = S.slice(0, k) + w + S.slice(k);
6232
+ const _ = `{{${m}}}`, { text: w } = x(S, k, _), j = S.slice(0, k) + w + S.slice(k);
6202
6233
  n(j, {}, r);
6203
6234
  }
6204
6235
  },
6205
- [r, n, a, d == null ? void 0 : d._id, p]
6236
+ [r, n, a, d == null ? void 0 : d._id, u]
6206
6237
  );
6207
6238
  return l ? /* @__PURE__ */ jsx(
6208
6239
  NestedPathSelector,
6209
6240
  {
6210
6241
  data: {
6211
- ...u && { [p]: u },
6242
+ ...p && { [u]: p },
6212
6243
  ...i
6213
6244
  },
6214
6245
  onSelect: g,
@@ -6221,12 +6252,12 @@ const DataBindingSelector = ({
6221
6252
  onChange: r
6222
6253
  }) => {
6223
6254
  var j;
6224
- const { t: a } = useTranslation(), i = useBuilderProp("searchPageTypeItems", (v, _) => []), [l, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, f] = useState(""), [h, x] = useState([]), [b, y] = useState(-1), C = useRef(null), k = (j = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : j.name;
6255
+ const { t: a } = useTranslation(), i = useBuilderProp("searchPageTypeItems", (v, E) => []), [l, c] = useState(!1), [d, u] = useState(!1), [p, g] = useState("page"), [m, f] = useState(""), [h, x] = useState([]), [b, y] = useState(-1), C = useRef(null), k = (j = n == null ? void 0 : n.find((v) => v.key === p)) == null ? void 0 : j.name;
6225
6256
  useEffect(() => {
6226
- if (f(""), x([]), y(-1), p(!1), !o || l || !startsWith(o, "pageType:")) return;
6227
- const v = split(o, ":"), _ = get(v, 1, "page") || "page";
6228
- g(_), (async () => {
6229
- const N = await i(_, [get(v, 2, "page")]);
6257
+ if (f(""), x([]), y(-1), u(!1), !o || l || !startsWith(o, "pageType:")) return;
6258
+ const v = split(o, ":"), E = get(v, 1, "page") || "page";
6259
+ g(E), (async () => {
6260
+ const N = await i(E, [get(v, 2, "page")]);
6230
6261
  N && Array.isArray(N) && f(get(N, [0, "name"], ""));
6231
6262
  })();
6232
6263
  }, [o]);
@@ -6235,30 +6266,30 @@ const DataBindingSelector = ({
6235
6266
  if (isEmpty(v))
6236
6267
  x([]);
6237
6268
  else {
6238
- const _ = await i(u, v);
6239
- x(_);
6269
+ const E = await i(p, v);
6270
+ x(E);
6240
6271
  }
6241
6272
  c(!1), y(-1);
6242
6273
  },
6243
- [u],
6274
+ [p],
6244
6275
  300
6245
6276
  ), A = (v) => {
6246
- const _ = ["pageType", u, v.id];
6247
- _[1] && (r(_.join(":")), f(v.name), p(!1), x([]), y(-1));
6277
+ const E = ["pageType", p, v.id];
6278
+ E[1] && (r(E.join(":")), f(v.name), u(!1), x([]), y(-1));
6248
6279
  }, B = (v) => {
6249
6280
  switch (v.key) {
6250
6281
  case "ArrowDown":
6251
- v.preventDefault(), y((_) => _ < h.length - 1 ? _ + 1 : _);
6282
+ v.preventDefault(), y((E) => E < h.length - 1 ? E + 1 : E);
6252
6283
  break;
6253
6284
  case "ArrowUp":
6254
- v.preventDefault(), y((_) => _ > 0 ? _ - 1 : _);
6285
+ v.preventDefault(), y((E) => E > 0 ? E - 1 : E);
6255
6286
  break;
6256
6287
  case "Enter":
6257
6288
  if (v.preventDefault(), h.length === 0) return;
6258
6289
  b >= 0 && A(h[b]);
6259
6290
  break;
6260
6291
  case "Escape":
6261
- v.preventDefault(), E();
6292
+ v.preventDefault(), _();
6262
6293
  break;
6263
6294
  }
6264
6295
  };
@@ -6268,14 +6299,14 @@ const DataBindingSelector = ({
6268
6299
  v == null || v.scrollIntoView({ block: "nearest" });
6269
6300
  }
6270
6301
  }, [b]);
6271
- const E = () => {
6272
- f(""), x([]), y(-1), p(!1), r("");
6302
+ const _ = () => {
6303
+ f(""), x([]), y(-1), u(!1), r("");
6273
6304
  }, w = (v) => {
6274
- f(v), p(!isEmpty(v)), c(!0), S(v);
6305
+ f(v), u(!isEmpty(v)), c(!0), S(v);
6275
6306
  };
6276
6307
  return /* @__PURE__ */ jsxs("div", { children: [
6277
- /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (v) => g(v.target.value), children: map(n, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
6278
- u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
6308
+ /* @__PURE__ */ jsx("select", { name: "pageType", value: p, onChange: (v) => g(v.target.value), children: map(n, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
6309
+ p && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
6279
6310
  /* @__PURE__ */ jsx(
6280
6311
  "input",
6281
6312
  {
@@ -6287,7 +6318,7 @@ const DataBindingSelector = ({
6287
6318
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
6288
6319
  }
6289
6320
  ),
6290
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: E, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" }) }) })
6321
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: _, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" }) }) })
6291
6322
  ] }),
6292
6323
  (l || !isEmpty(h) || d && isEmpty(h)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: l ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
6293
6324
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -6297,11 +6328,11 @@ const DataBindingSelector = ({
6297
6328
  ' "',
6298
6329
  m,
6299
6330
  '"'
6300
- ] }) : /* @__PURE__ */ jsx("ul", { ref: C, children: map(h == null ? void 0 : h.slice(0, 20), (v, _) => /* @__PURE__ */ jsxs(
6331
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: C, children: map(h == null ? void 0 : h.slice(0, 20), (v, E) => /* @__PURE__ */ jsxs(
6301
6332
  "li",
6302
6333
  {
6303
6334
  onClick: () => A(v),
6304
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : _ === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
6335
+ 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"}`,
6305
6336
  children: [
6306
6337
  v.name,
6307
6338
  " ",
@@ -6316,10 +6347,10 @@ const DataBindingSelector = ({
6316
6347
  )) }) })
6317
6348
  ] });
6318
6349
  }, LinkField = ({ schema: o, formData: n, onChange: r, name: a }) => {
6319
- const { t: i } = useTranslation(), { type: l = "pageType", href: c = "", target: d = "self" } = n ?? {}, p = useBuilderProp("pageTypes", []), { selectedLang: u, fallbackLang: g, languages: m } = useLanguages(), f = useMemo(
6320
- () => isEmpty(m) ? "" : isEmpty(u) ? g : u,
6321
- [m, u, g]
6322
- ), h = useMemo(() => get(LANGUAGES, f, f), [f]), x = l === "pageType" && isEmpty(p) ? "url" : l;
6350
+ const { t: i } = useTranslation(), { type: l = "pageType", href: c = "", target: d = "self" } = n ?? {}, u = useBuilderProp("pageTypes", []), { selectedLang: p, fallbackLang: g, languages: m } = useLanguages(), f = useMemo(
6351
+ () => isEmpty(m) ? "" : isEmpty(p) ? g : p,
6352
+ [m, p, g]
6353
+ ), h = useMemo(() => get(LANGUAGES, f, f), [f]), x = l === "pageType" && isEmpty(u) ? "url" : l;
6323
6354
  return /* @__PURE__ */ jsxs("div", { children: [
6324
6355
  /* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between gap-x-2 text-xs font-medium", children: [
6325
6356
  /* @__PURE__ */ jsxs("span", { children: [
@@ -6341,7 +6372,7 @@ const DataBindingSelector = ({
6341
6372
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-1.5", children: [
6342
6373
  /* @__PURE__ */ jsx("select", { name: "type", value: l, onChange: (b) => r({ ...n, type: b.target.value }), children: map(
6343
6374
  [
6344
- ...isEmpty(p) ? [] : [{ const: "pageType", title: i("Goto Page") }],
6375
+ ...isEmpty(u) ? [] : [{ const: "pageType", title: i("Goto Page") }],
6345
6376
  { const: "url", title: i("Open URL") },
6346
6377
  { const: "email", title: i("Compose Email") },
6347
6378
  { const: "telephone", title: i("Call Phone") },
@@ -6349,11 +6380,11 @@ const DataBindingSelector = ({
6349
6380
  ],
6350
6381
  (b) => /* @__PURE__ */ jsx("option", { value: b.const, children: b.title }, b.const)
6351
6382
  ) }),
6352
- x === "pageType" && !isEmpty(p) ? /* @__PURE__ */ jsx(
6383
+ x === "pageType" && !isEmpty(u) ? /* @__PURE__ */ jsx(
6353
6384
  PageTypeField,
6354
6385
  {
6355
6386
  href: c,
6356
- pageTypes: p,
6387
+ pageTypes: u,
6357
6388
  onChange: (b) => r({ ...n, href: b })
6358
6389
  }
6359
6390
  ) : null,
@@ -6406,8 +6437,8 @@ const DataBindingSelector = ({
6406
6437
  ]
6407
6438
  }
6408
6439
  ) });
6409
- }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-2S4dpCHF.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: i, onBlur: l }) => {
6410
- const c = useRef(null), [d, p] = useState(!1), u = useRTEditor({
6440
+ }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-MLnVHEnQ.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: i, onBlur: l }) => {
6441
+ const c = useRef(null), [d, u] = useState(!1), p = useRTEditor({
6411
6442
  blockId: o,
6412
6443
  value: a,
6413
6444
  placeholder: r,
@@ -6421,16 +6452,16 @@ const DataBindingSelector = ({
6421
6452
  }
6422
6453
  });
6423
6454
  useEffect(() => {
6424
- c.current && u && (c.current.__chaiRTE = u);
6425
- }, [o, u]);
6455
+ c.current && p && (c.current.__chaiRTE = p);
6456
+ }, [o, p]);
6426
6457
  const g = () => {
6427
- p(!1);
6458
+ u(!1);
6428
6459
  }, m = /* @__PURE__ */ jsxs("div", { id: `chai-rte-${n}`, ref: c, className: "mt-1 rounded-md border border-input", children: [
6429
- /* @__PURE__ */ jsx(RteMenubar, { editor: u, onExpand: () => p(!0) }),
6460
+ /* @__PURE__ */ jsx(RteMenubar, { editor: p, onExpand: () => u(!0) }),
6430
6461
  /* @__PURE__ */ jsx(
6431
6462
  EditorContent,
6432
6463
  {
6433
- editor: u,
6464
+ editor: p,
6434
6465
  id: n,
6435
6466
  placeholder: r,
6436
6467
  className: `overflow-auto ${d ? "max-h-[500px] min-h-[400px]" : "max-h-[200px] min-h-[100px]"}`
@@ -6439,7 +6470,7 @@ const DataBindingSelector = ({
6439
6470
  )
6440
6471
  ] });
6441
6472
  return /* @__PURE__ */ jsxs(Fragment, { children: [
6442
- d && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(RTEModal, { isOpen: d, onClose: g, editor: u, rteElement: m }) }),
6473
+ d && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(RTEModal, { isOpen: d, onClose: g, editor: p, rteElement: m }) }),
6443
6474
  d ? /* @__PURE__ */ jsx("div", { children: "Open in modal" }) : /* @__PURE__ */ jsx("div", { className: "relative", children: m })
6444
6475
  ] });
6445
6476
  }, RichTextEditorField = (o) => {
@@ -6450,32 +6481,32 @@ const DataBindingSelector = ({
6450
6481
  }, SliderField = ({ formData: o, onChange: n }) => {
6451
6482
  const [r] = useBlocksStore(), a = useSelectedBlock(), i = useWrapperBlock(), { addCoreBlock: l } = useAddBlock(), [, c] = useSelectedBlockIds();
6452
6483
  if (!a && !i) return null;
6453
- const d = (a == null ? void 0 : a._type) === "Slider" ? a : i, p = find(r, { _parent: d == null ? void 0 : d._id, _type: "Slides" });
6454
- if (!p) return null;
6455
- const u = filter(r, { _parent: p == null ? void 0 : p._id, _type: "Slide" }), g = (o == null ? void 0 : o.currentSlide) || get(u, "0._id");
6484
+ const d = (a == null ? void 0 : a._type) === "Slider" ? a : i, u = find(r, { _parent: d == null ? void 0 : d._id, _type: "Slides" });
6485
+ if (!u) return null;
6486
+ const p = filter(r, { _parent: u == null ? void 0 : u._id, _type: "Slide" }), g = (o == null ? void 0 : o.currentSlide) || get(p, "0._id");
6456
6487
  useEffect(() => {
6457
6488
  (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 });
6458
6489
  }, [a]), useEffect(() => {
6459
- u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
6460
- }, [o, u]);
6490
+ p != null && p.length && !find(p, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(p, "0._id") });
6491
+ }, [o, p]);
6461
6492
  const m = () => {
6462
- const x = findIndex(u, { _id: g });
6493
+ const x = findIndex(p, { _id: g });
6463
6494
  if (x > -1) {
6464
- const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
6495
+ const b = (x + 1) % p.length, y = get(p, [b, "_id"]);
6465
6496
  if (!y) return;
6466
6497
  n({ ...o, currentSlide: y }), c([y]);
6467
6498
  }
6468
6499
  }, f = () => {
6469
- const x = findIndex(u, { _id: g });
6500
+ const x = findIndex(p, { _id: g });
6470
6501
  if (x > -1) {
6471
- const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
6502
+ const b = (x - 1 + p.length) % p.length, y = get(p, [b, "_id"]);
6472
6503
  if (!y) return;
6473
6504
  n({ ...o, currentSlide: y }), c([y]);
6474
6505
  }
6475
6506
  }, h = () => {
6476
6507
  const x = l(
6477
6508
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
6478
- p == null ? void 0 : p._id
6509
+ u == null ? void 0 : u._id
6479
6510
  ), b = x == null ? void 0 : x._id;
6480
6511
  b && (n({ ...o, currentSlide: b }), c([b]));
6481
6512
  };
@@ -6485,10 +6516,10 @@ const DataBindingSelector = ({
6485
6516
  /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
6486
6517
  /* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
6487
6518
  " ",
6488
- findIndex(u, { _id: g }) + 1
6519
+ findIndex(p, { _id: g }) + 1
6489
6520
  ] }),
6490
6521
  "/",
6491
- u.length
6522
+ p.length
6492
6523
  ] }) : "-" }),
6493
6524
  /* @__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" }) }),
6494
6525
  /* @__PURE__ */ jsxs(
@@ -6566,14 +6597,14 @@ const DataBindingSelector = ({
6566
6597
  ] });
6567
6598
  }, SourcesField = ({ formData: o, onChange: n }) => {
6568
6599
  const r = get(o, "srcsets", []) || [], a = (c, d) => {
6569
- const p = c.target.name, u = c.target.value;
6600
+ const u = c.target.name, p = c.target.value;
6570
6601
  n({
6571
- srcsets: map(r, (g, m) => m === d ? { ...g, [p]: u } : g)
6602
+ srcsets: map(r, (g, m) => m === d ? { ...g, [u]: p } : g)
6572
6603
  });
6573
6604
  }, i = () => {
6574
6605
  n({ srcsets: [...r, {}] });
6575
6606
  }, l = (c) => {
6576
- n({ srcsets: reject(r, (d, p) => p === c) });
6607
+ n({ srcsets: reject(r, (d, u) => u === c) });
6577
6608
  };
6578
6609
  return /* @__PURE__ */ jsxs("div", { children: [
6579
6610
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pb-2", children: [
@@ -6607,7 +6638,7 @@ const DataBindingSelector = ({
6607
6638
  placeholder: "Enter width (in px)",
6608
6639
  type: "number",
6609
6640
  value: get(c, "width"),
6610
- onChange: (p) => a(p, d),
6641
+ onChange: (u) => a(u, d),
6611
6642
  className: "!placeholder:text-gray-100 !mt-0 !rounded-none !border-0 !p-0 !text-xs"
6612
6643
  }
6613
6644
  )
@@ -6621,7 +6652,7 @@ const DataBindingSelector = ({
6621
6652
  placeholder: "Enter url",
6622
6653
  className: "!mt-0 !rounded-none !border-0 !p-0 !text-xs !shadow-none",
6623
6654
  value: get(c, "url", ""),
6624
- onChange: (p) => a(p, d)
6655
+ onChange: (u) => a(u, d)
6625
6656
  }
6626
6657
  )
6627
6658
  ] })
@@ -6631,8 +6662,8 @@ const DataBindingSelector = ({
6631
6662
  const { t: r } = useTranslation(), [, a] = useCodeEditor(), i = useSelectedBlock();
6632
6663
  if (typeof window > "u") return null;
6633
6664
  const l = o.replace("root.", ""), c = get(i, l, ""), d = () => {
6634
- const p = i == null ? void 0 : i._id;
6635
- a({ blockId: p, blockProp: l, placeholder: n, initialCode: get(i, l, c) });
6665
+ const u = i == null ? void 0 : i._id;
6666
+ a({ blockId: u, blockProp: l, placeholder: n, initialCode: get(i, l, c) });
6636
6667
  };
6637
6668
  return /* @__PURE__ */ jsxs("div", { className: "mt-2 flex flex-col gap-y-1", children: [
6638
6669
  /* @__PURE__ */ jsx(
@@ -6646,31 +6677,31 @@ const DataBindingSelector = ({
6646
6677
  /* @__PURE__ */ jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
6647
6678
  ] });
6648
6679
  }, CollectionFilterSortField = ({ id: o, value: n, onChange: r, onBlur: a }) => {
6649
- const i = useBuilderProp("collections", []), l = useSelectedBlock(), c = get(l, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1").replace(COLLECTION_PREFIX, ""), d = find(i, { id: c }), u = get(d, o === "root.filter" ? "filters" : "sorts", []);
6680
+ const i = useBuilderProp("collections", []), l = useSelectedBlock(), c = get(l, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1").replace(COLLECTION_PREFIX, ""), d = find(i, { id: c }), p = get(d, o === "root.filter" ? "filters" : "sorts", []);
6650
6681
  return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("select", { value: n, onChange: (g) => r(g.target.value), onBlur: (g) => a(o, g.target.value), children: [
6651
6682
  /* @__PURE__ */ jsx("option", { value: "", children: "Select" }),
6652
- u.map((g) => /* @__PURE__ */ jsx("option", { value: g.id, children: g.name }, g.id))
6683
+ p.map((g) => /* @__PURE__ */ jsx("option", { value: g.id, children: g.name }, g.id))
6653
6684
  ] }) });
6654
6685
  }, JSONFormFieldTemplate = (o) => {
6655
- const { id: n, classNames: r, label: a, children: i, errors: l, help: c, hidden: d, required: p, schema: u, formData: g, onChange: m } = o, { selectedLang: f, fallbackLang: h, languages: x } = useLanguages(), b = useMemo(
6686
+ const { id: n, classNames: r, label: a, children: i, errors: l, help: c, hidden: d, required: u, schema: p, formData: g, onChange: m } = o, { selectedLang: f, fallbackLang: h, languages: x } = useLanguages(), b = useMemo(
6656
6687
  () => isEmpty(x) ? "" : isEmpty(f) ? h : f,
6657
6688
  [x, f, h]
6658
6689
  ), y = useMemo(() => get(LANGUAGES, b, b), [b]), C = usePageExternalData(), k = useSelectedBlock(), S = useRegisteredChaiBlocks(), A = useMemo(
6659
6690
  () => get(S, [k == null ? void 0 : k._type, "i18nProps"], []),
6660
6691
  [S, k == null ? void 0 : k._type]
6661
- ), [B, E] = useState(null);
6692
+ ), [B, _] = useState(null);
6662
6693
  if (d)
6663
6694
  return null;
6664
- if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: i });
6695
+ if (p.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: i });
6665
6696
  const j = A == null ? void 0 : A.includes(n.replace("root.", ""));
6666
- if (u.type === "array") {
6697
+ if (p.type === "array") {
6667
6698
  const N = B === n;
6668
6699
  return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
6669
- u.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
6700
+ p.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
6670
6701
  "label",
6671
6702
  {
6672
6703
  htmlFor: n,
6673
- onClick: () => E(N ? null : n),
6704
+ onClick: () => _(N ? null : n),
6674
6705
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
6675
6706
  children: [
6676
6707
  N ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }),
@@ -6678,7 +6709,7 @@ const DataBindingSelector = ({
6678
6709
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: a }),
6679
6710
  " ",
6680
6711
  /* @__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 }) }),
6681
- u.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6712
+ p.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6682
6713
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6683
6714
  InfoCircledIcon,
6684
6715
  {
@@ -6687,7 +6718,7 @@ const DataBindingSelector = ({
6687
6718
  onMouseDown: (I) => I.stopPropagation()
6688
6719
  }
6689
6720
  ) }),
6690
- /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: u.description })
6721
+ /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: p.description })
6691
6722
  ] }) })
6692
6723
  ]
6693
6724
  }
@@ -6699,26 +6730,26 @@ const DataBindingSelector = ({
6699
6730
  ] })
6700
6731
  ] });
6701
6732
  }
6702
- const v = n.replace("root.", ""), _ = A.includes(v) && !isEmpty(f) && isEmpty(g);
6733
+ const v = n.replace("root.", ""), E = A.includes(v) && !isEmpty(f) && isEmpty(g);
6703
6734
  return /* @__PURE__ */ jsxs("div", { className: r, children: [
6704
- u.title && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
6735
+ p.title && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
6705
6736
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
6706
- /* @__PURE__ */ jsxs("label", { htmlFor: n, className: u.type === "object" ? "pb-2" : "", children: [
6737
+ /* @__PURE__ */ jsxs("label", { htmlFor: n, className: p.type === "object" ? "pb-2" : "", children: [
6707
6738
  a,
6708
6739
  " ",
6709
6740
  j && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
6710
6741
  " ",
6711
6742
  y
6712
6743
  ] }),
6713
- p && u.type !== "object" ? " *" : null
6744
+ u && p.type !== "object" ? " *" : null
6714
6745
  ] }),
6715
- u.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6746
+ p.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6716
6747
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(InfoCircledIcon, { className: "h-3 w-3 text-muted-foreground/70" }) }),
6717
- /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: u.description })
6748
+ /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: p.description })
6718
6749
  ] }) })
6719
6750
  ] }),
6720
- !u.enum && !u.oneOf && C && /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-1", children: [
6721
- _ ? /* @__PURE__ */ jsxs(Tooltip, { children: [
6751
+ !p.enum && !p.oneOf && C && /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-1", children: [
6752
+ E ? /* @__PURE__ */ jsxs(Tooltip, { children: [
6722
6753
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6723
6754
  "svg",
6724
6755
  {
@@ -6748,7 +6779,7 @@ const DataBindingSelector = ({
6748
6779
  /* @__PURE__ */ jsx(
6749
6780
  DataBindingSelector,
6750
6781
  {
6751
- schema: u,
6782
+ schema: p,
6752
6783
  onChange: (N) => {
6753
6784
  m(N, g, n);
6754
6785
  },
@@ -6799,7 +6830,7 @@ const DataBindingSelector = ({
6799
6830
  " ",
6800
6831
  /* @__PURE__ */ jsx("span", { children: "Add" })
6801
6832
  ] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: i }) => {
6802
- const { selectedLang: l } = useLanguages(), c = useBlockSettingComponents("widget"), d = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
6833
+ const { selectedLang: l } = useLanguages(), c = useBlockSettingComponents("widget"), d = useBlockSettingComponents("field"), u = useBlockSettingComponents("template"), p = useThrottledCallback(
6803
6834
  async ({ formData: g }, m) => {
6804
6835
  get(g, m) === void 0 && set(g, m, ""), i({ formData: g }, m);
6805
6836
  },
@@ -6831,7 +6862,7 @@ const DataBindingSelector = ({
6831
6862
  ButtonTemplates: {
6832
6863
  AddButton: CustomAddButton
6833
6864
  },
6834
- ...p
6865
+ ...u
6835
6866
  },
6836
6867
  idSeparator: ".",
6837
6868
  autoComplete: "off",
@@ -6845,7 +6876,7 @@ const DataBindingSelector = ({
6845
6876
  onChange: ({ formData: g }, m) => {
6846
6877
  if (!m || o !== (g == null ? void 0 : g._id)) return;
6847
6878
  const f = take(m.split("."), 2).join(".").replace("root.", "");
6848
- u({ formData: g }, f);
6879
+ p({ formData: g }, f);
6849
6880
  }
6850
6881
  },
6851
6882
  l
@@ -6857,46 +6888,46 @@ const DataBindingSelector = ({
6857
6888
  }), a;
6858
6889
  };
6859
6890
  function BlockSettings() {
6860
- const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), i = getRegisteredChaiBlock(n == null ? void 0 : n._type), l = formDataWithSelectedLang(n, o, i), [c, d] = useState(l), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), f = formDataWithSelectedLang(g, o, m), h = ({ formData: B }, E, w) => {
6861
- E && (c == null ? void 0 : c._id) === n._id && a([n._id], { [E]: get(B, E) }, w);
6891
+ const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), i = getRegisteredChaiBlock(n == null ? void 0 : n._type), l = formDataWithSelectedLang(n, o, i), [c, d] = useState(l), [u, p] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), f = formDataWithSelectedLang(g, o, m), h = ({ formData: B }, _, w) => {
6892
+ _ && (c == null ? void 0 : c._id) === n._id && a([n._id], { [_]: get(B, _) }, w);
6862
6893
  }, x = useCallback(
6863
- debounce(({ formData: B }, E, w) => {
6864
- h({ formData: B }, E, w), d(B);
6894
+ debounce(({ formData: B }, _, w) => {
6895
+ h({ formData: B }, _, w), d(B);
6865
6896
  }, 1500),
6866
6897
  [n == null ? void 0 : n._id, o]
6867
- ), b = ({ formData: B }, E) => {
6868
- E && (r([n._id], { [E]: get(B, E) }), x({ formData: B }, E, { [E]: get(c, E) }));
6869
- }, y = ({ formData: B }, E) => {
6870
- E && (r([g._id], { [E]: get(B, E) }), x({ formData: B }, E, { [E]: get(c, E) }));
6898
+ ), b = ({ formData: B }, _) => {
6899
+ _ && (r([n._id], { [_]: get(B, _) }), x({ formData: B }, _, { [_]: get(c, _) }));
6900
+ }, y = ({ formData: B }, _) => {
6901
+ _ && (r([g._id], { [_]: get(B, _) }), x({ formData: B }, _, { [_]: get(c, _) }));
6871
6902
  }, { schema: C, uiSchema: k } = useMemo(() => {
6872
6903
  const B = n == null ? void 0 : n._type;
6873
6904
  if (!B)
6874
6905
  return { schema: {}, uiSchema: {} };
6875
6906
  try {
6876
- const { schema: E, uiSchema: w } = getBlockFormSchemas(B);
6907
+ const { schema: _, uiSchema: w } = getBlockFormSchemas(B);
6877
6908
  if (B === "Repeater") {
6878
6909
  const j = get(n, "repeaterItems", "");
6879
6910
  startsWith(j, `{{${COLLECTION_PREFIX}`) ? (set(w, "filter", { "ui:widget": "collectionSelect" }), set(w, "sort", { "ui:widget": "collectionSelect" })) : (set(w, "filter", { "ui:widget": "hidden" }), set(w, "sort", { "ui:widget": "hidden" }));
6880
6911
  }
6881
- return { schema: E, uiSchema: w };
6912
+ return { schema: _, uiSchema: w };
6882
6913
  } catch {
6883
6914
  return { schema: {}, uiSchema: {} };
6884
6915
  }
6885
6916
  }, [n]), { wrapperSchema: S, wrapperUiSchema: A } = useMemo(() => {
6886
6917
  if (!g || !(g != null && g._type))
6887
6918
  return { wrapperSchema: {}, wrapperUiSchema: {} };
6888
- const B = g == null ? void 0 : g._type, { schema: E = {}, uiSchema: w = {} } = getBlockFormSchemas(B);
6889
- return { wrapperSchema: E, wrapperUiSchema: w };
6919
+ const B = g == null ? void 0 : g._type, { schema: _ = {}, uiSchema: w = {} } = getBlockFormSchemas(B);
6920
+ return { wrapperSchema: _, wrapperUiSchema: w };
6890
6921
  }, [g]);
6891
6922
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
6892
6923
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
6893
6924
  /* @__PURE__ */ jsxs(
6894
6925
  "div",
6895
6926
  {
6896
- onClick: () => u((B) => !B),
6927
+ onClick: () => p((B) => !B),
6897
6928
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
6898
6929
  children: [
6899
- p ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-4 w-4 text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 text-slate-400" }),
6930
+ u ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-4 w-4 text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 text-slate-400" }),
6900
6931
  startCase(g._type),
6901
6932
  " settings",
6902
6933
  " ",
@@ -6908,7 +6939,7 @@ function BlockSettings() {
6908
6939
  ]
6909
6940
  }
6910
6941
  ),
6911
- /* @__PURE__ */ jsx("div", { className: p ? "h-auto" : "invisible h-0", children: /* @__PURE__ */ jsx(
6942
+ /* @__PURE__ */ jsx("div", { className: u ? "h-auto" : "invisible h-0", children: /* @__PURE__ */ jsx(
6912
6943
  JSONForm,
6913
6944
  {
6914
6945
  blockId: g == null ? void 0 : g._id,
@@ -6937,8 +6968,8 @@ const BlockStylingProps = () => {
6937
6968
  if (!o) return null;
6938
6969
  const c = Object.keys(o).filter(
6939
6970
  (x) => typeof o[x] == "string" && o[x].startsWith("#styles:")
6940
- ), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (h = n[0]) == null ? void 0 : h.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, m = g ? g.split(" ").filter((x) => !isEmpty(x)) : [], f = (x) => find(n, (b) => b.prop === x);
6941
- return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
6971
+ ), { reset: d } = useResetBlockStyles(), u = !isEmpty(c) && c.length > 1, p = get(o, (h = n[0]) == null ? void 0 : h.prop, ""), { classes: g = "" } = getSplitChaiClasses(p) || {}, m = g ? g.split(" ").filter((x) => !isEmpty(x)) : [], f = (x) => find(n, (b) => b.prop === x);
6972
+ return /* @__PURE__ */ jsx(Fragment, { children: u && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
6942
6973
  /* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
6943
6974
  l("Style element"),
6944
6975
  ":"
@@ -7106,18 +7137,18 @@ const BlockStylingProps = () => {
7106
7137
  "button",
7107
7138
  {
7108
7139
  type: "button",
7109
- onMouseDown: (p) => {
7110
- const u = {
7140
+ onMouseDown: (u) => {
7141
+ const p = {
7111
7142
  onDrag: r,
7112
7143
  onDragEnd: a,
7113
7144
  dragging: !0,
7114
- dragStartY: p.pageY,
7145
+ dragStartY: u.pageY,
7115
7146
  dragStartValue: `${n}`,
7116
7147
  dragUnit: o,
7117
7148
  negative: l,
7118
7149
  cssProperty: c
7119
7150
  };
7120
- i(u), d(u);
7151
+ i(p), d(p);
7121
7152
  },
7122
7153
  color: void 0,
7123
7154
  className: "relative z-50 ml-1 hidden h-6 cursor-row-resize rounded bg-background/70 px-2 group-hover:inline",
@@ -7137,37 +7168,37 @@ const BlockStylingProps = () => {
7137
7168
  },
7138
7169
  a
7139
7170
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
7140
- const [n, r] = useState(!1), [a, i] = useState(""), { currentClass: l, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, f] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [h, x] = useState(!1), [b, y] = useState(""), [C, k] = useState(!1), [S, A] = useState(!1);
7171
+ const [n, r] = useState(!1), [a, i] = useState(""), { currentClass: l, onChange: c, classPrefix: d, cssProperty: u, units: p, negative: g } = o, [m, f] = useState(u != null && u.toLowerCase().includes("width") ? "%" : p[0]), [h, x] = useState(!1), [b, y] = useState(""), [C, k] = useState(!1), [S, A] = useState(!1);
7141
7172
  useEffect(() => {
7142
- const { value: v, unit: _ } = getClassValueAndUnit(l);
7143
- if (_ === "") {
7144
- i(v), f(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
7173
+ const { value: v, unit: E } = getClassValueAndUnit(l);
7174
+ if (E === "") {
7175
+ i(v), f(u != null && u.toLowerCase().includes("width") ? "%" : first(p));
7145
7176
  return;
7146
7177
  }
7147
- f(_), i(_ === "class" || isEmpty(v) ? "" : v);
7148
- }, [l, p, u]);
7149
- const B = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), E = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), w = useCallback(
7178
+ f(E), i(E === "class" || isEmpty(v) ? "" : v);
7179
+ }, [l, u, p]);
7180
+ const B = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), _ = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), w = useCallback(
7150
7181
  (v = !1) => {
7151
- const _ = getUserInputValues(`${a}`, u);
7152
- if (get(_, "error", !1)) {
7182
+ const E = getUserInputValues(`${a}`, p);
7183
+ if (get(E, "error", !1)) {
7153
7184
  x(!0);
7154
7185
  return;
7155
7186
  }
7156
- const N = get(_, "unit") !== "" ? get(_, "unit") : m;
7187
+ const N = get(E, "unit") !== "" ? get(E, "unit") : m;
7157
7188
  if (N === "auto" || N === "none") {
7158
7189
  B(`${d}${N}`);
7159
7190
  return;
7160
7191
  }
7161
- if (get(_, "value") === "")
7192
+ if (get(E, "value") === "")
7162
7193
  return;
7163
- const P = `${get(_, "value", "").startsWith("-") ? "-" : ""}${d}[${get(_, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
7164
- v ? E(P) : B(P);
7194
+ const P = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
7195
+ v ? _(P) : B(P);
7165
7196
  },
7166
- [B, E, a, m, d, u]
7197
+ [B, _, a, m, d, p]
7167
7198
  ), j = useCallback(
7168
7199
  (v) => {
7169
- const _ = getUserInputValues(`${a}`, u);
7170
- if (get(_, "error", !1)) {
7200
+ const E = getUserInputValues(`${a}`, p);
7201
+ if (get(E, "error", !1)) {
7171
7202
  x(!0);
7172
7203
  return;
7173
7204
  }
@@ -7175,12 +7206,12 @@ const BlockStylingProps = () => {
7175
7206
  B(`${d}${v}`);
7176
7207
  return;
7177
7208
  }
7178
- if (get(_, "value") === "")
7209
+ if (get(E, "value") === "")
7179
7210
  return;
7180
- const N = get(_, "unit") !== "" ? get(_, "unit") : v, P = `${get(_, "value", "").startsWith("-") ? "-" : ""}${d}[${get(_, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
7211
+ const N = get(E, "unit") !== "" ? get(E, "unit") : v, P = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
7181
7212
  B(P);
7182
7213
  },
7183
- [B, a, d, u]
7214
+ [B, a, d, p]
7184
7215
  );
7185
7216
  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: [
7186
7217
  /* @__PURE__ */ jsx(
@@ -7208,11 +7239,11 @@ const BlockStylingProps = () => {
7208
7239
  if (v.keyCode !== 38 && v.keyCode !== 40)
7209
7240
  return;
7210
7241
  v.preventDefault(), A(!0);
7211
- const _ = parseInt$1(v.target.value);
7212
- let N = isNaN$1(_) ? 0 : _;
7242
+ const E = parseInt$1(v.target.value);
7243
+ let N = isNaN$1(E) ? 0 : E;
7213
7244
  v.keyCode === 38 && (N += 1), v.keyCode === 40 && (N -= 1);
7214
7245
  const I = `${N}`, D = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${m === "-" ? "" : m}]`;
7215
- E(D);
7246
+ _(D);
7216
7247
  },
7217
7248
  onKeyUp: (v) => {
7218
7249
  S && (v.preventDefault(), A(!1));
@@ -7222,8 +7253,8 @@ const BlockStylingProps = () => {
7222
7253
  x(!1), i(v.target.value);
7223
7254
  },
7224
7255
  onClick: (v) => {
7225
- var _;
7226
- (_ = v == null ? void 0 : v.target) == null || _.select(), r(!1);
7256
+ var E;
7257
+ (E = v == null ? void 0 : v.target) == null || E.select(), r(!1);
7227
7258
  },
7228
7259
  value: C ? b : a,
7229
7260
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
@@ -7240,15 +7271,15 @@ const BlockStylingProps = () => {
7240
7271
  onClick: () => r(!n),
7241
7272
  className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
7242
7273
  children: [
7243
- /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
7244
- u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
7274
+ /* @__PURE__ */ jsx("span", { className: `inline-block ${p.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
7275
+ p.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
7245
7276
  ]
7246
7277
  }
7247
7278
  ) }),
7248
7279
  /* @__PURE__ */ jsx(TooltipContent, { className: "bg-background", children: /* @__PURE__ */ jsx(
7249
7280
  UnitSelection,
7250
7281
  {
7251
- units: u,
7282
+ units: p,
7252
7283
  current: m,
7253
7284
  onSelect: (v) => {
7254
7285
  r(!1), f(v), j(v);
@@ -7264,20 +7295,20 @@ const BlockStylingProps = () => {
7264
7295
  onDragEnd: (v) => {
7265
7296
  if (y(() => ""), k(!1), isEmpty(v))
7266
7297
  return;
7267
- const _ = `${v}`, I = `${_.startsWith("-") ? "-" : ""}${d}[${_.replace("-", "")}${m === "-" ? "" : m}]`;
7298
+ const E = `${v}`, I = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${m === "-" ? "" : m}]`;
7268
7299
  B(I);
7269
7300
  },
7270
7301
  onDrag: (v) => {
7271
7302
  if (isEmpty(v))
7272
7303
  return;
7273
7304
  y(v);
7274
- const _ = `${v}`, I = `${_.startsWith("-") ? "-" : ""}${d}[${_.replace("-", "")}${m === "-" ? "" : m}]`;
7275
- E(I);
7305
+ const E = `${v}`, I = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${m === "-" ? "" : m}]`;
7306
+ _(I);
7276
7307
  },
7277
7308
  currentValue: a,
7278
7309
  unit: m,
7279
7310
  negative: g,
7280
- cssProperty: p
7311
+ cssProperty: u
7281
7312
  }
7282
7313
  )
7283
7314
  ] }) }) });
@@ -7285,8 +7316,8 @@ const BlockStylingProps = () => {
7285
7316
  // eslint-disable-next-line react/jsx-no-constructed-context-values
7286
7317
  /* @__PURE__ */ jsx(StyleContext.Provider, { value: { canReset: n, canChange: r }, children: o })
7287
7318
  ), DropDownChoices = ({ label: o, property: n, onChange: r }) => {
7288
- const { getClasses: a } = useTailwindClassList(), i = a(n), l = useCurrentClassByProperty(n), c = useMemo(() => get(l, "cls", ""), [l]), { canChange: d } = useContext(StyleContext), p = /\[.*\]/g.test(c);
7289
- return /* @__PURE__ */ jsx("div", { className: o ? "w-full rounded" : "grow", children: p ? /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
7319
+ const { getClasses: a } = useTailwindClassList(), i = a(n), l = useCurrentClassByProperty(n), c = useMemo(() => get(l, "cls", ""), [l]), { canChange: d } = useContext(StyleContext), u = /\[.*\]/g.test(c);
7320
+ return /* @__PURE__ */ jsx("div", { className: o ? "w-full rounded" : "grow", children: u ? /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
7290
7321
  /* @__PURE__ */ jsx(Input$1, { className: "w-[70%] rounded py-1", readOnly: !0, value: c }),
7291
7322
  /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
7292
7323
  /* @__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, {}) }) }),
@@ -7296,7 +7327,7 @@ const BlockStylingProps = () => {
7296
7327
  DropDown,
7297
7328
  {
7298
7329
  rounded: o,
7299
- onChange: (u) => r(u, n),
7330
+ onChange: (p) => r(p, n),
7300
7331
  selected: c,
7301
7332
  options: i,
7302
7333
  disabled: !d
@@ -7310,14 +7341,14 @@ function DropDown({ selected: o, onChange: n, rounded: r = !1, options: a, disab
7310
7341
  {
7311
7342
  disabled: !a.length || i,
7312
7343
  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`,
7313
- onChange: (p) => n(p.target.value),
7314
- onKeyDown: (p) => {
7315
- p.ctrlKey && (p.key === "z" && c(), p.key === "y" && d());
7344
+ onChange: (u) => n(u.target.value),
7345
+ onKeyDown: (u) => {
7346
+ u.ctrlKey && (u.key === "z" && c(), u.key === "y" && d());
7316
7347
  },
7317
7348
  value: l,
7318
7349
  children: [
7319
7350
  /* @__PURE__ */ jsx("option", { className: "bg-transparent", value: "" }),
7320
- a.map((p, u) => /* @__PURE__ */ jsx("option", { className: "bg-transparent", value: p, children: p }, `option-${u}`))
7351
+ a.map((u, p) => /* @__PURE__ */ jsx("option", { className: "bg-transparent", value: u, children: u }, `option-${p}`))
7321
7352
  ]
7322
7353
  }
7323
7354
  );
@@ -7335,12 +7366,12 @@ const COLOR_PROP = {
7335
7366
  ringColor: "ring",
7336
7367
  ringOffsetColor: "ring-offset"
7337
7368
  }, ColorChoice = ({ property: o, onChange: n }) => {
7338
- const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: i } = useContext(StyleContext), [l, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""), f = useCallback(
7369
+ const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: i } = useContext(StyleContext), [l, c] = useState([]), [d, u] = useState({ color: "", shade: "" }), p = a.split("-"), g = get(p, "1", ""), m = get(p, "2", ""), f = useCallback(
7339
7370
  // eslint-disable-next-line no-shadow
7340
7371
  (b) => {
7341
- ["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" })));
7372
+ ["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), u({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), u((y) => ({ ...y, color: b, shade: y.shade ? y.shade : "500" })));
7342
7373
  },
7343
- [c, p]
7374
+ [c, u]
7344
7375
  );
7345
7376
  useEffect(() => {
7346
7377
  if (["current", "inherit", "transparent", "black", "white"].includes(g))
@@ -7350,12 +7381,12 @@ const COLOR_PROP = {
7350
7381
  const h = useCallback(
7351
7382
  // eslint-disable-next-line no-shadow
7352
7383
  (b) => {
7353
- p({ color: g, shade: b });
7384
+ u({ color: g, shade: b });
7354
7385
  },
7355
7386
  [g]
7356
7387
  );
7357
7388
  useEffect(() => {
7358
- p({ color: "", shade: "" });
7389
+ u({ color: "", shade: "" });
7359
7390
  }, [r]);
7360
7391
  const { match: x } = useTailwindClassList();
7361
7392
  return useEffect(() => {
@@ -7613,19 +7644,19 @@ const COLOR_PROP = {
7613
7644
  /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(d)) })
7614
7645
  ] })) });
7615
7646
  }, RangeChoices = ({ property: o, onChange: n }) => {
7616
- const { canReset: r, canChange: a } = useContext(StyleContext), i = useCurrentClassByProperty(o), l = useMemo(() => get(i, "cls", ""), [i]), { getClasses: c } = useTailwindClassList(), d = c(o, [""]), p = d.indexOf(l) > -1 ? d.indexOf(l) : 0, u = /\[.*\]/g.test(l);
7617
- 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: l }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7647
+ const { canReset: r, canChange: a } = useContext(StyleContext), i = useCurrentClassByProperty(o), l = useMemo(() => get(i, "cls", ""), [i]), { getClasses: c } = useTailwindClassList(), d = c(o, [""]), u = d.indexOf(l) > -1 ? d.indexOf(l) : 0, p = /\[.*\]/g.test(l);
7648
+ return /* @__PURE__ */ jsx("div", { className: "flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs", children: p ? /* @__PURE__ */ jsx("div", { className: "px-2 py-[5px]", children: l }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7618
7649
  /* @__PURE__ */ jsx(
7619
7650
  "button",
7620
7651
  {
7621
7652
  type: "button",
7622
7653
  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",
7623
- disabled: !a && (!r || p - 1 < 0),
7624
- onClick: () => n(nth(d, p - 1), o),
7654
+ disabled: !a && (!r || u - 1 < 0),
7655
+ onClick: () => n(nth(d, u - 1), o),
7625
7656
  children: /* @__PURE__ */ jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
7626
7657
  MinusIcon,
7627
7658
  {
7628
- className: !a && (!r || p - 1 < 0) ? "text-gray-500" : "text-black/60 dark:text-white/60"
7659
+ className: !a && (!r || u - 1 < 0) ? "text-gray-500" : "text-black/60 dark:text-white/60"
7629
7660
  }
7630
7661
  ) })
7631
7662
  }
@@ -7636,12 +7667,12 @@ const COLOR_PROP = {
7636
7667
  {
7637
7668
  type: "button",
7638
7669
  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",
7639
- disabled: !a && (!r || p + 1 >= d.length),
7640
- onClick: () => n(nth(d, p + 1), o),
7670
+ disabled: !a && (!r || u + 1 >= d.length),
7671
+ onClick: () => n(nth(d, u + 1), o),
7641
7672
  children: /* @__PURE__ */ jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
7642
7673
  PlusIcon,
7643
7674
  {
7644
- className: !a && (!r || p + 1 >= d.length) ? "text-gray-500" : "text-black/60 dark:text-white/60"
7675
+ className: !a && (!r || u + 1 >= d.length) ? "text-gray-500" : "text-black/60 dark:text-white/60"
7645
7676
  }
7646
7677
  ) })
7647
7678
  }
@@ -7735,14 +7766,14 @@ const COLOR_PROP = {
7735
7766
  "2xl": "1536px"
7736
7767
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
7737
7768
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: i, onEmitChange: l = () => {
7738
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(i), f = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
7739
- (E, w = !0) => {
7740
- const j = { dark: p, mq: g, mod: u, cls: E, property: i, fullCls: "" };
7741
- (p || u !== "") && (j.mq = "xs");
7769
+ }, units: c, negative: d = !1 } = o, [u] = useDarkMode(), [p] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(i), f = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
7770
+ (_, w = !0) => {
7771
+ const j = { dark: u, mq: g, mod: p, cls: _, property: i, fullCls: "" };
7772
+ (u || p !== "") && (j.mq = "xs");
7742
7773
  const v = generateFullClsName(j);
7743
7774
  f(x, [v], w);
7744
7775
  },
7745
- [x, p, g, u, i, f]
7776
+ [x, u, g, p, i, f]
7746
7777
  ), C = useCallback(() => {
7747
7778
  h(x, [b], !0);
7748
7779
  }, [x, b, h]), k = useMemo(() => canChangeClass(m, g), [m, g]);
@@ -7750,7 +7781,7 @@ const COLOR_PROP = {
7750
7781
  l(k, m);
7751
7782
  }, [k, l, m]);
7752
7783
  const [, , S] = useScreenSizeWidth(), A = useCallback(
7753
- (E) => {
7784
+ (_) => {
7754
7785
  S({
7755
7786
  xs: 400,
7756
7787
  sm: 640,
@@ -7758,10 +7789,10 @@ const COLOR_PROP = {
7758
7789
  lg: 1024,
7759
7790
  xl: 1420,
7760
7791
  "2xl": 1920
7761
- }[E]);
7792
+ }[_]);
7762
7793
  },
7763
7794
  [S]
7764
- ), B = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
7795
+ ), B = get(m, "dark", null) === u && get(m, "mod", null) === p && get(m, "mq", null) === g;
7765
7796
  return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: k, canReset: m && B, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
7766
7797
  /* @__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) }) }),
7767
7798
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
@@ -7795,7 +7826,7 @@ const COLOR_PROP = {
7795
7826
  "Current style is set at  ",
7796
7827
  /* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
7797
7828
  getBreakpoint(get(m, "mq")),
7798
- p && !m.dark ? "(Light mode)" : ""
7829
+ u && !m.dark ? "(Light mode)" : ""
7799
7830
  ] }),
7800
7831
  /* @__PURE__ */ jsx("br", {}),
7801
7832
  /* @__PURE__ */ jsxs(
@@ -7823,7 +7854,7 @@ const COLOR_PROP = {
7823
7854
  units: l = basicUnits,
7824
7855
  negative: c = !1
7825
7856
  }) => {
7826
- const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((f) => map(g, "property").includes(f), [g]);
7857
+ const { t: d } = useTranslation(), [u, p] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((f) => map(g, "property").includes(f), [g]);
7827
7858
  return /* @__PURE__ */ jsxs(
7828
7859
  "div",
7829
7860
  {
@@ -7836,8 +7867,8 @@ const COLOR_PROP = {
7836
7867
  "button",
7837
7868
  {
7838
7869
  type: "button",
7839
- onClick: () => u(h),
7840
- className: `relative cursor-pointer rounded-full p-1 text-[8px] ${h === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
7870
+ onClick: () => p(h),
7871
+ className: `relative cursor-pointer rounded-full p-1 text-[8px] ${h === u ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
7841
7872
  children: [
7842
7873
  React__default.createElement("div", {
7843
7874
  className: m(h) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
@@ -7855,7 +7886,7 @@ const COLOR_PROP = {
7855
7886
  type: i,
7856
7887
  units: [...l],
7857
7888
  label: "",
7858
- property: p,
7889
+ property: u,
7859
7890
  negative: c
7860
7891
  }
7861
7892
  ) })
@@ -7864,10 +7895,10 @@ const COLOR_PROP = {
7864
7895
  );
7865
7896
  }, NestedOptions = ({ heading: o, items: n }) => {
7866
7897
  const { t: r } = useTranslation(), a = useSelectedBlockCurrentClasses(), i = useMemo(() => {
7867
- const l = (p) => flatten(
7868
- p.map((u) => u.styleType === "multiple" ? map(u.options, "key") : u.property)
7898
+ const l = (u) => flatten(
7899
+ u.map((p) => p.styleType === "multiple" ? map(p.options, "key") : p.property)
7869
7900
  ), c = flatten(
7870
- n.map((p) => p.styleType === "accordion" ? l(p.items) : p.styleType === "multiple" ? map(p.options, "key") : p.property)
7901
+ n.map((u) => u.styleType === "accordion" ? l(u.items) : u.styleType === "multiple" ? map(u.options, "key") : u.property)
7871
7902
  ), d = map(a, "property");
7872
7903
  return intersection(c, d).length > 0;
7873
7904
  }, [a, n]);
@@ -7887,15 +7918,15 @@ const COLOR_PROP = {
7887
7918
  const { t: r } = useTranslation(), a = useSelectedBlockCurrentClasses(), i = useCallback(
7888
7919
  (c = []) => {
7889
7920
  const d = {};
7890
- for (let u = 0; u < a.length; u++)
7891
- d[a[u].property] = a[u].cls;
7892
- let p = !0;
7893
- for (const u in c)
7894
- if (!has(d, u) || d[u] !== c[u]) {
7895
- p = !1;
7921
+ for (let p = 0; p < a.length; p++)
7922
+ d[a[p].property] = a[p].cls;
7923
+ let u = !0;
7924
+ for (const p in c)
7925
+ if (!has(d, p) || d[p] !== c[p]) {
7926
+ u = !1;
7896
7927
  break;
7897
7928
  }
7898
- return p;
7929
+ return u;
7899
7930
  },
7900
7931
  [a]
7901
7932
  ), l = useMemo(() => ({}), []);
@@ -7966,8 +7997,8 @@ const COLOR_PROP = {
7966
7997
  currentBreakpoint: l,
7967
7998
  breakpoint: c,
7968
7999
  width: d,
7969
- icon: p,
7970
- onClick: u,
8000
+ icon: u,
8001
+ onClick: p,
7971
8002
  buttonClass: g = "",
7972
8003
  activeButtonClass: m = ""
7973
8004
  }) => {
@@ -7976,11 +8007,11 @@ const COLOR_PROP = {
7976
8007
  /* @__PURE__ */ jsx(HoverCardTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
7977
8008
  Button,
7978
8009
  {
7979
- onClick: () => u(d),
8010
+ onClick: () => p(d),
7980
8011
  size: "sm",
7981
8012
  className: cn$1("h-7 w-7 rounded-md p-1", c === l ? m : g),
7982
8013
  variant: c === l ? "outline" : "ghost",
7983
- children: p
8014
+ children: u
7984
8015
  }
7985
8016
  ) }),
7986
8017
  /* @__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: [
@@ -7990,11 +8021,11 @@ const COLOR_PROP = {
7990
8021
  ] }) : /* @__PURE__ */ jsx(
7991
8022
  Button,
7992
8023
  {
7993
- onClick: () => u(d),
8024
+ onClick: () => p(d),
7994
8025
  size: "sm",
7995
8026
  className: "h-7 w-7 rounded-md p-1",
7996
8027
  variant: c === l ? "outline" : "ghost",
7997
- children: p
8028
+ children: u
7998
8029
  }
7999
8030
  );
8000
8031
  }, Breakpoints$1 = ({
@@ -8004,10 +8035,10 @@ const COLOR_PROP = {
8004
8035
  buttonClass: a = "",
8005
8036
  activeButtonClass: i = ""
8006
8037
  }) => {
8007
- const [l, , c] = useScreenSizeWidth(), [d, p] = useCanvasDisplayWidth(), [u, g] = useSelectedBreakpoints(), m = u, f = g, { t: h } = useTranslation(), x = useBuilderProp("breakpoints", WEB_BREAKPOINTS), b = (k) => {
8038
+ const [l, , c] = useScreenSizeWidth(), [d, u] = useCanvasDisplayWidth(), [p, g] = useSelectedBreakpoints(), m = p, f = g, { t: h } = useTranslation(), x = useBuilderProp("breakpoints", WEB_BREAKPOINTS), b = (k) => {
8008
8039
  m.includes(k) ? m.length > 2 && f(m.filter((S) => S !== k)) : f((S) => [...S, k]);
8009
8040
  }, y = (k) => {
8010
- n || c(k), p(k);
8041
+ n || c(k), u(k);
8011
8042
  }, C = getBreakpointValue(n ? d : l).toLowerCase();
8012
8043
  return x.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(x, (k) => /* @__PURE__ */ createElement(
8013
8044
  BreakpointCard,
@@ -8079,7 +8110,7 @@ function BreakpointSelector() {
8079
8110
  const DesignTokensIcon = ({ className: o = "" }) => /* @__PURE__ */ jsx(FontStyleIcon, { className: o });
8080
8111
  function ManualClasses() {
8081
8112
  var O;
8082
- const o = useRef(null), [n, r] = useState(""), [a, i] = useState(-1), [, l] = useRightPanel(), c = useFuseSearch(), { t: d } = useTranslation(), [p] = useSelectedStylingBlocks(), u = useSelectedBlock(), g = useAddClassesToBlocks(), m = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), [h, x] = useState(""), b = useAtomValue$1(chaiDesignTokensAtom), y = (O = first(p)) == null ? void 0 : O.prop, { classes: C } = getSplitChaiClasses(get(u, y, "")), k = C.split(" ").filter((L) => !isEmpty(L)), S = useMemo(() => [...k].sort((L, T) => {
8113
+ const o = useRef(null), [n, r] = useState(""), [a, i] = useState(-1), [, l] = useRightPanel(), c = useFuseSearch(), { t: d } = useTranslation(), [u] = useSelectedStylingBlocks(), p = useSelectedBlock(), g = useAddClassesToBlocks(), m = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), [h, x] = useState(""), b = useAtomValue$1(chaiDesignTokensAtom), y = (O = first(u)) == null ? void 0 : O.prop, { classes: C } = getSplitChaiClasses(get(p, y, "")), k = C.split(" ").filter((L) => !isEmpty(L)), S = useMemo(() => [...k].sort((L, T) => {
8083
8114
  const M = L.startsWith(DESIGN_TOKEN_PREFIX), H = T.startsWith(DESIGN_TOKEN_PREFIX);
8084
8115
  return M && !H ? -1 : !M && H ? 1 : 0;
8085
8116
  }), [k]), A = useBuilderProp("flags.copyPaste", !0), B = (L) => {
@@ -8088,16 +8119,16 @@ function ManualClasses() {
8088
8119
  return T ? T.name : L;
8089
8120
  }
8090
8121
  return L;
8091
- }, E = (L) => {
8122
+ }, _ = (L) => {
8092
8123
  const T = Object.entries(b).find(([M, H]) => H.name === L);
8093
8124
  return T ? `${T[0]}` : L;
8094
8125
  }, w = () => {
8095
- const L = h.trim().replace(/ +(?= )/g, "").split(" ").map(E);
8126
+ const L = h.trim().replace(/ +(?= )/g, "").split(" ").map(_);
8096
8127
  g(f, L, !0), x("");
8097
- }, [j, v] = useState([]), _ = useBuilderProp("flags.designTokens", !1), N = ({ value: L }) => {
8128
+ }, [j, v] = useState([]), E = useBuilderProp("flags.designTokens", !1), N = ({ value: L }) => {
8098
8129
  const T = L.trim().toLowerCase(), M = T.match(/.+:/g);
8099
8130
  let H = [], W = [];
8100
- if (_ && (T === "" ? W = Object.entries(b).map(([V, U]) => ({
8131
+ if (E && (T === "" ? W = Object.entries(b).map(([V, U]) => ({
8101
8132
  name: U.name,
8102
8133
  id: `${V}`,
8103
8134
  isDesignToken: !0
@@ -8142,7 +8173,7 @@ function ManualClasses() {
8142
8173
  }),
8143
8174
  [h, d, o, j.length]
8144
8175
  ), $ = (L) => {
8145
- const T = n.trim().replace(/ +(?= )/g, "").split(" ").map(E);
8176
+ const T = n.trim().replace(/ +(?= )/g, "").split(" ").map(_);
8146
8177
  m(f, [L]), g(f, T, !0), r(""), i(-1);
8147
8178
  }, F = () => {
8148
8179
  if (navigator.clipboard === void 0) {
@@ -8154,13 +8185,13 @@ function ManualClasses() {
8154
8185
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
8155
8186
  /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-x-2", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-x-2 text-muted-foreground", children: [
8156
8187
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-1", children: [
8157
- /* @__PURE__ */ jsx("span", { children: d(_ ? "Styles" : "Classes") }),
8188
+ /* @__PURE__ */ jsx("span", { children: d(E ? "Styles" : "Classes") }),
8158
8189
  A && /* @__PURE__ */ jsxs(Tooltip, { children: [
8159
8190
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: F, className: "cursor-pointer" }) }),
8160
8191
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: d("Copy classes to clipboard") }) })
8161
8192
  ] })
8162
8193
  ] }),
8163
- _ && /* @__PURE__ */ jsx(Button, { variant: "link", className: "underline", onClick: () => l("design-tokens"), children: d("Design Tokens") })
8194
+ E && /* @__PURE__ */ jsx(Button, { variant: "link", className: "underline", onClick: () => l("design-tokens"), children: d("Design Tokens") })
8164
8195
  ] }) }),
8165
8196
  /* @__PURE__ */ jsxs("div", { className: "relative flex items-center gap-x-3", children: [
8166
8197
  /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
@@ -8174,7 +8205,7 @@ function ManualClasses() {
8174
8205
  inputProps: R,
8175
8206
  highlightFirstSuggestion: !0,
8176
8207
  onSuggestionSelected: (L, { suggestionValue: T }) => {
8177
- const M = E(T);
8208
+ const M = _(T);
8178
8209
  g(f, [M], !0), x("");
8179
8210
  },
8180
8211
  containerProps: {
@@ -8367,8 +8398,8 @@ const MAPPER = {
8367
8398
  };
8368
8399
  function BlockStyling() {
8369
8400
  const { flexChild: o, gridChild: n } = useSelectedBlocksDisplayChild(), [r] = useSelectedStylingBlocks(), [a, i] = React__default.useState(""), [l, c] = React__default.useState({
8370
- onDrag: (u) => u,
8371
- onDragEnd: (u) => u,
8401
+ onDrag: (p) => p,
8402
+ onDragEnd: (p) => p,
8372
8403
  dragStartY: 0,
8373
8404
  dragging: !1,
8374
8405
  dragStartValue: 0,
@@ -8376,21 +8407,21 @@ function BlockStyling() {
8376
8407
  negative: !1,
8377
8408
  cssProperty: ""
8378
8409
  }), d = useThrottledCallback(
8379
- (u) => {
8410
+ (p) => {
8380
8411
  const g = !get(l, "negative", !1), m = get(l, "cssProperty", "");
8381
8412
  let f = parseFloat(l.dragStartValue);
8382
8413
  f = isNaN(f) ? 0 : f;
8383
8414
  let h = MAPPER[l.dragUnit];
8384
8415
  (startsWith(m, "scale") || m === "opacity") && (h = 10);
8385
- let b = (l.dragStartY - u.pageY) / h + f;
8416
+ let b = (l.dragStartY - p.pageY) / h + f;
8386
8417
  g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), l.onDrag(`${b}`), i(`${b}`);
8387
8418
  },
8388
8419
  [l],
8389
8420
  50
8390
- ), p = useCallback(() => {
8421
+ ), u = useCallback(() => {
8391
8422
  setTimeout(() => l.onDragEnd(`${a}`), 100), c({
8392
- onDrag: (u) => u,
8393
- onDragEnd: (u) => u,
8423
+ onDrag: (p) => p,
8424
+ onDragEnd: (p) => p,
8394
8425
  dragStartY: 0,
8395
8426
  dragging: !1,
8396
8427
  dragStartValue: 0,
@@ -8404,7 +8435,7 @@ function BlockStyling() {
8404
8435
  "div",
8405
8436
  {
8406
8437
  onMouseMove: d,
8407
- onMouseUp: () => p(),
8438
+ onMouseUp: () => u(),
8408
8439
  className: "absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"
8409
8440
  }
8410
8441
  ) : null,
@@ -8413,7 +8444,7 @@ function BlockStyling() {
8413
8444
  /* @__PURE__ */ jsxs(Accordion, { defaultValue: ["Styles"], type: "multiple", className: "w-full", children: [
8414
8445
  o && /* @__PURE__ */ jsx(StylingGroup, { section: FLEX_CHILD_SECTION, showAccordian: o || n }),
8415
8446
  n && /* @__PURE__ */ jsx(StylingGroup, { section: GRID_CHILD_SECTION, showAccordian: o || n }),
8416
- SETTINGS_SECTIONS.map((u) => /* @__PURE__ */ jsx(StylingGroup, { section: u, showAccordian: o || n }, u.heading))
8447
+ SETTINGS_SECTIONS.map((p) => /* @__PURE__ */ jsx(StylingGroup, { section: p, showAccordian: o || n }, p.heading))
8417
8448
  ] })
8418
8449
  ] })
8419
8450
  ] });
@@ -8424,10 +8455,10 @@ const CoreBlock = ({
8424
8455
  parentId: r,
8425
8456
  position: a
8426
8457
  }) => {
8427
- const { type: i, icon: l, label: c } = o, { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), u = () => {
8458
+ const { type: i, icon: l, label: c } = o, { addCoreBlock: d, addPredefinedBlock: u } = useAddBlock(), p = () => {
8428
8459
  if (has(o, "blocks")) {
8429
8460
  const x = isFunction(o.blocks) ? o.blocks() : o.blocks;
8430
- p(syncBlocksWithDefaults(x), r || null, a);
8461
+ u(syncBlocksWithDefaults(x), r || null, a);
8431
8462
  } else
8432
8463
  d(o, r || null, a);
8433
8464
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
@@ -8437,7 +8468,7 @@ const CoreBlock = ({
8437
8468
  "button",
8438
8469
  {
8439
8470
  disabled: n,
8440
- onClick: u,
8471
+ onClick: p,
8441
8472
  type: "button",
8442
8473
  onDragStart: (x) => f(x, { ...o, label: c, icon: l }),
8443
8474
  onDragEnd: h,
@@ -8478,10 +8509,10 @@ const registerChaiPreImportHTMLHook = (o) => {
8478
8509
  position: n,
8479
8510
  fromSidebar: r
8480
8511
  }) => {
8481
- const { t: a } = useTranslation(), [i, l] = useState(""), { addPredefinedBlock: c } = useAddBlock(), [d, p] = useState(!1), u = async () => {
8482
- p(!0);
8512
+ const { t: a } = useTranslation(), [i, l] = useState(""), { addPredefinedBlock: c } = useAddBlock(), [d, u] = useState(!1), p = async () => {
8513
+ u(!0);
8483
8514
  const g = await getPreImportHTML(i), m = getBlocksFromHTML(g);
8484
- c([...m], o, n), l(""), p(!1), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
8515
+ c([...m], o, n), l(""), u(!1), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
8485
8516
  };
8486
8517
  return /* @__PURE__ */ jsxs(Card, { className: `border-border/0 p-0 shadow-none ${r ? "w-full" : "max-w-full"}`, children: [
8487
8518
  /* @__PURE__ */ jsx(CardHeader, { className: r ? "p-0" : "p-3", children: /* @__PURE__ */ jsx(CardDescription, { className: r ? "text-xs" : "", children: a("Use HTML snippets from Tailwind CSS component libraries") }) }),
@@ -8498,7 +8529,7 @@ const registerChaiPreImportHTMLHook = (o) => {
8498
8529
  }
8499
8530
  )
8500
8531
  ] }) }),
8501
- /* @__PURE__ */ jsx(CardFooter, { className: "flex flex-col justify-end p-3", children: /* @__PURE__ */ jsx(Button, { disabled: i.trim() === "" || d, onClick: () => u(), size: "sm", className: "w-fit", children: d ? /* @__PURE__ */ jsxs(Fragment, { children: [
8532
+ /* @__PURE__ */ jsx(CardFooter, { className: "flex flex-col justify-end p-3", children: /* @__PURE__ */ jsx(Button, { disabled: i.trim() === "" || d, onClick: () => p(), size: "sm", className: "w-fit", children: d ? /* @__PURE__ */ jsxs(Fragment, { children: [
8502
8533
  /* @__PURE__ */ jsx(CircleIcon, { className: "mr-2 h-4 w-4 animate-spin" }),
8503
8534
  " ",
8504
8535
  a("Importing...")
@@ -8512,8 +8543,8 @@ const registerChaiPreImportHTMLHook = (o) => {
8512
8543
  className: i = "",
8513
8544
  height: l = ""
8514
8545
  }) => {
8515
- const [c, d] = useState(o), p = (u) => {
8516
- const g = u.target.value;
8546
+ const [c, d] = useState(o), u = (p) => {
8547
+ const g = p.target.value;
8517
8548
  d(g), n(g);
8518
8549
  };
8519
8550
  return /* @__PURE__ */ jsx("div", { className: cn$1("relative inline-block w-full", i), children: /* @__PURE__ */ jsxs(
@@ -8524,10 +8555,10 @@ const registerChaiPreImportHTMLHook = (o) => {
8524
8555
  l
8525
8556
  ),
8526
8557
  value: c,
8527
- onChange: p,
8558
+ onChange: u,
8528
8559
  children: [
8529
8560
  /* @__PURE__ */ jsx("option", { value: "", disabled: !0, children: a }),
8530
- r.map((u) => /* @__PURE__ */ jsx("option", { value: u.value, children: u.label }, u.value))
8561
+ r.map((p) => /* @__PURE__ */ jsx("option", { value: p.value, children: p.label }, p.value))
8531
8562
  ]
8532
8563
  }
8533
8564
  ) });
@@ -8566,9 +8597,9 @@ const registerChaiLibrary = (o, n) => {
8566
8597
  onDragEnd: l,
8567
8598
  draggable: c,
8568
8599
  className: d = "",
8569
- type: p = "Box"
8600
+ type: u = "Box"
8570
8601
  }) => {
8571
- const { onDragStart: u, onDragEnd: g } = useDragAndDrop(), m = useIsDragAndDropEnabled(), [, f] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), x = c !== void 0 ? c : m;
8602
+ const { onDragStart: p, onDragEnd: g } = useDragAndDrop(), m = useIsDragAndDropEnabled(), [, f] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), x = c !== void 0 ? c : m;
8572
8603
  return /* @__PURE__ */ jsx(
8573
8604
  "div",
8574
8605
  {
@@ -8580,14 +8611,14 @@ const registerChaiLibrary = (o, n) => {
8580
8611
  return;
8581
8612
  }
8582
8613
  let k = null;
8583
- if (p === "Image") {
8614
+ if (u === "Image") {
8584
8615
  if (!(o != null && o.image)) return;
8585
8616
  k = {
8586
8617
  type: "Image",
8587
8618
  blocks: [
8588
8619
  {
8589
8620
  _type: "Image",
8590
- styles: "#styles:,w-full",
8621
+ styles: "#styles:,w-full h-full object-cover",
8591
8622
  image: o == null ? void 0 : o.image,
8592
8623
  alt: (o == null ? void 0 : o.alt) || "",
8593
8624
  _name: (o == null ? void 0 : o.name) || "Image"
@@ -8615,7 +8646,7 @@ const registerChaiLibrary = (o, n) => {
8615
8646
  k = typeof S == "object" ? omit(S, ["component", "icon"]) : S;
8616
8647
  }
8617
8648
  if (!k) return;
8618
- u(C, k, !0), setTimeout(() => {
8649
+ p(C, k, !0), setTimeout(() => {
8619
8650
  f([]), h();
8620
8651
  }, 200);
8621
8652
  } catch (k) {
@@ -8661,7 +8692,7 @@ const BlockCard = ({
8661
8692
  parentId: r = void 0,
8662
8693
  position: a = -1
8663
8694
  }) => {
8664
- const [i, l] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), u = get(o, "name", get(o, "label")), g = get(o, "description", ""), { onDragStart: m, onDragEnd: f } = useDragAndDrop(), h = useIsDragAndDropEnabled(), x = useCallback(
8695
+ const [i, l] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: u } = useAddBlock(), p = get(o, "name", get(o, "label")), g = get(o, "description", ""), { onDragStart: m, onDragEnd: f } = useDragAndDrop(), h = useIsDragAndDropEnabled(), x = useCallback(
8665
8696
  async (y) => {
8666
8697
  if (y.stopPropagation(), has(o, "component")) {
8667
8698
  d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
@@ -8669,15 +8700,15 @@ const BlockCard = ({
8669
8700
  }
8670
8701
  l(!0);
8671
8702
  let C = await c({ library: n, block: o });
8672
- typeof C == "string" && (C = getBlocksFromHTML(C)), isEmpty(C) || p(syncBlocksWithDefaults(C), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK), setTimeout(() => l(!1), 1e3);
8703
+ typeof C == "string" && (C = getBlocksFromHTML(C)), isEmpty(C) || u(syncBlocksWithDefaults(C), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK), setTimeout(() => l(!1), 1e3);
8673
8704
  },
8674
- [d, p, o, c, n, r, a]
8705
+ [d, u, o, c, n, r, a]
8675
8706
  );
8676
8707
  return /* @__PURE__ */ jsxs(Tooltip, { children: [
8677
8708
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(ChaiDraggableBlock, { draggable: h, onDragStart: async (y) => {
8678
8709
  if (!h) return;
8679
8710
  let C = await c({ library: n, block: o });
8680
- typeof C == "string" && (C = getBlocksFromHTML(C)), m(y, { type: "Box", blocks: C, name: u }, !0);
8711
+ typeof C == "string" && (C = getBlocksFromHTML(C)), m(y, { type: "Box", blocks: C, name: p }, !0);
8681
8712
  }, onDragEnd: f, children: /* @__PURE__ */ jsxs(
8682
8713
  "div",
8683
8714
  {
@@ -8692,21 +8723,21 @@ const BlockCard = ({
8692
8723
  /* @__PURE__ */ jsx(ReloadIcon, { className: "h-4 w-4 animate-spin text-white" }),
8693
8724
  /* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
8694
8725
  ] }),
8695
- o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: u }) : /* @__PURE__ */ jsxs("div", { className: "flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center", children: [
8696
- /* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: u }),
8726
+ o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: p }) : /* @__PURE__ */ jsxs("div", { className: "flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center", children: [
8727
+ /* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: p }),
8697
8728
  g && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600", children: g })
8698
8729
  ] })
8699
8730
  ]
8700
8731
  }
8701
8732
  ) }) }),
8702
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "max-w-xs", children: /* @__PURE__ */ jsx("p", { className: "font-medium", children: u }) }) })
8733
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "max-w-xs", children: /* @__PURE__ */ jsx("p", { className: "font-medium", children: p }) }) })
8703
8734
  ] });
8704
8735
  }, UILibrarySection = ({
8705
8736
  parentId: o,
8706
8737
  position: n,
8707
8738
  fromSidebar: r
8708
8739
  }) => {
8709
- const [a, i] = useSelectedLibrary(), l = useChaiLibraries(), c = l.find((N) => N.id === a) || first(l), { data: d, isLoading: p, resetLibrary: u } = useLibraryBlocks(c), [g, m] = useState(""), [f, h] = useState([]), x = useRef(null);
8740
+ const [a, i] = useSelectedLibrary(), l = useChaiLibraries(), c = l.find((N) => N.id === a) || first(l), { data: d, isLoading: u, resetLibrary: p } = useLibraryBlocks(c), [g, m] = useState(""), [f, h] = useState([]), x = useRef(null);
8710
8741
  useEffect(() => {
8711
8742
  d && d.length > 0 && (x.current = new Fuse(d, {
8712
8743
  keys: ["name", "label", "description", "group"],
@@ -8732,10 +8763,10 @@ const BlockCard = ({
8732
8763
  return;
8733
8764
  }
8734
8765
  }, [y, C]);
8735
- const S = get(y, C, []), A = useRef(null), { t: B } = useTranslation(), E = useRef(null);
8766
+ const S = get(y, C, []), A = useRef(null), { t: B } = useTranslation(), _ = useRef(null);
8736
8767
  useEffect(() => {
8737
8768
  var I;
8738
- const N = (I = E.current) == null ? void 0 : I.querySelector("[data-radix-scroll-area-viewport]");
8769
+ const N = (I = _.current) == null ? void 0 : I.querySelector("[data-radix-scroll-area-viewport]");
8739
8770
  N && N.scrollTo({ top: 0, behavior: "smooth" });
8740
8771
  }, [c, C]);
8741
8772
  const w = (N) => {
@@ -8743,14 +8774,14 @@ const BlockCard = ({
8743
8774
  A.current && k(N);
8744
8775
  }, 400);
8745
8776
  }, j = () => {
8746
- c != null && c.id && u(c.id);
8777
+ c != null && c.id && p(c.id);
8747
8778
  };
8748
- if (p)
8779
+ if (u)
8749
8780
  return /* @__PURE__ */ jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
8750
8781
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
8751
8782
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
8752
8783
  ] });
8753
- const v = filter(S, (N, I) => I % 2 === 0), _ = filter(S, (N, I) => I % 2 === 1);
8784
+ const v = filter(S, (N, I) => I % 2 === 0), E = filter(S, (N, I) => I % 2 === 1);
8754
8785
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
8755
8786
  /* @__PURE__ */ jsx(SearchInput, { value: g, setValue: m }),
8756
8787
  /* @__PURE__ */ jsx("div", { className: "relative flex h-full max-h-full flex-1 overflow-hidden bg-background", children: /* @__PURE__ */ jsxs("div", { className: `flex h-full flex-1 pt-2 ${r ? "flex-col" : ""}`, children: [
@@ -8803,7 +8834,7 @@ const BlockCard = ({
8803
8834
  /* @__PURE__ */ jsx("div", { className: `flex h-full max-h-full w-full flex-col border-border ${r ? "" : "border-l"}`, children: /* @__PURE__ */ jsxs(
8804
8835
  ScrollArea,
8805
8836
  {
8806
- ref: E,
8837
+ ref: _,
8807
8838
  onMouseEnter: () => A.current ? clearTimeout(A.current) : null,
8808
8839
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
8809
8840
  children: [
@@ -8818,7 +8849,7 @@ const BlockCard = ({
8818
8849
  },
8819
8850
  `block-${I}`
8820
8851
  )) }),
8821
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: _.map((N, I) => /* @__PURE__ */ jsx(
8852
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: E.map((N, I) => /* @__PURE__ */ jsx(
8822
8853
  BlockCard,
8823
8854
  {
8824
8855
  parentId: o,
@@ -8856,11 +8887,11 @@ const BlockCard = ({
8856
8887
  gridCols: r = "grid-cols-2",
8857
8888
  disableBlockGroupsSidebar: a = !1
8858
8889
  }) => {
8859
- const { data: i, isLoading: l, refetch: c, error: d } = usePartialBlocksList(), [p, u] = useAtom$1(partialBlocksDataAtom), [g, m] = useAtom$1(hasInitializedPartialBlocksAtom);
8890
+ const { data: i, isLoading: l, refetch: c, error: d } = usePartialBlocksList(), [u, p] = useAtom$1(partialBlocksDataAtom), [g, m] = useAtom$1(hasInitializedPartialBlocksAtom);
8860
8891
  useEffect(() => {
8861
- if (!g || Object.keys(p.blocks).length === 0)
8892
+ if (!g || Object.keys(u.blocks).length === 0)
8862
8893
  if (d)
8863
- u({
8894
+ p({
8864
8895
  blocks: [],
8865
8896
  groups: [],
8866
8897
  isLoading: !1,
@@ -8883,13 +8914,13 @@ const BlockCard = ({
8883
8914
  _name: C.name
8884
8915
  };
8885
8916
  }), x = uniq(map(h, "group"));
8886
- u({
8917
+ p({
8887
8918
  blocks: h,
8888
8919
  groups: x,
8889
8920
  isLoading: !1,
8890
8921
  error: null
8891
8922
  }), m(!0);
8892
- } else l ? u((h) => ({ ...h, isLoading: !0, error: null })) : !l && Object.keys(i || {}).length === 0 && (u({
8923
+ } else l ? p((h) => ({ ...h, isLoading: !0, error: null })) : !l && Object.keys(i || {}).length === 0 && (p({
8893
8924
  blocks: [],
8894
8925
  groups: [],
8895
8926
  isLoading: !1,
@@ -8900,15 +8931,15 @@ const BlockCard = ({
8900
8931
  i,
8901
8932
  g,
8902
8933
  m,
8903
- u,
8904
- p.blocks,
8934
+ p,
8935
+ u.blocks,
8905
8936
  d
8906
8937
  ]);
8907
8938
  const f = () => {
8908
- u((h) => ({ ...h, isLoading: !0, error: null })), m(!1), c();
8939
+ p((h) => ({ ...h, isLoading: !0, error: null })), m(!1), c();
8909
8940
  };
8910
- return p.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : p.error || p.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
8911
- /* @__PURE__ */ jsx("p", { children: p.error || "No partial blocks available" }),
8941
+ 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: [
8942
+ /* @__PURE__ */ jsx("p", { children: u.error || "No partial blocks available" }),
8912
8943
  /* @__PURE__ */ jsx(
8913
8944
  "button",
8914
8945
  {
@@ -8923,8 +8954,8 @@ const BlockCard = ({
8923
8954
  gridCols: r,
8924
8955
  parentId: o,
8925
8956
  position: n,
8926
- groups: p.groups,
8927
- blocks: p.blocks,
8957
+ groups: u.groups,
8958
+ blocks: u.blocks,
8928
8959
  disableBlockGroupsSidebar: a
8929
8960
  }
8930
8961
  );
@@ -8939,7 +8970,7 @@ const BlockCard = ({
8939
8970
  disableBlockGroupsSidebar: l
8940
8971
  }) => {
8941
8972
  var N;
8942
- const { t: c } = useTranslation(), [d] = useBlocksStore(), [p, u] = useState(""), g = useRef(null), [m] = useAtom$1(addBlockTabAtom), f = (N = find(d, (I) => I._id === r)) == null ? void 0 : N._type, [h, x] = useState("all"), [b, y] = useState(null), C = useRef(null), k = useBuilderProp("flags.dragAndDrop", !1);
8973
+ const { t: c } = useTranslation(), [d] = useBlocksStore(), [u, p] = useState(""), g = useRef(null), [m] = useAtom$1(addBlockTabAtom), f = (N = find(d, (I) => I._id === r)) == null ? void 0 : N._type, [h, x] = useState("all"), [b, y] = useState(null), C = useRef(null), k = useBuilderProp("flags.dragAndDrop", !1);
8943
8974
  useEffect(() => {
8944
8975
  const I = setTimeout(() => {
8945
8976
  var P;
@@ -8947,8 +8978,8 @@ const BlockCard = ({
8947
8978
  }, 0);
8948
8979
  return () => clearTimeout(I);
8949
8980
  }, [m]), useEffect(() => {
8950
- p && (x("all"), y(null));
8951
- }, [p]), useEffect(() => (C.current = debounce((I) => {
8981
+ u && (x("all"), y(null));
8982
+ }, [u]), useEffect(() => (C.current = debounce((I) => {
8952
8983
  x(I);
8953
8984
  }, 500), () => {
8954
8985
  C.current && C.current.cancel();
@@ -8959,25 +8990,25 @@ const BlockCard = ({
8959
8990
  y(null), C.current && C.current.cancel();
8960
8991
  }, []), B = useCallback((I) => {
8961
8992
  C.current && C.current.cancel(), x(I), y(null);
8962
- }, []), E = useMemo(
8963
- () => p ? values(n).filter(
8993
+ }, []), _ = useMemo(
8994
+ () => u ? values(n).filter(
8964
8995
  (I) => {
8965
8996
  var P, D;
8966
- return (((P = I.label) == null ? void 0 : P.toLowerCase()) + " " + ((D = I.type) == null ? void 0 : D.toLowerCase())).includes(p.toLowerCase());
8997
+ return (((P = I.label) == null ? void 0 : P.toLowerCase()) + " " + ((D = I.type) == null ? void 0 : D.toLowerCase())).includes(u.toLowerCase());
8967
8998
  }
8968
8999
  ) : n,
8969
- [n, p]
9000
+ [n, u]
8970
9001
  ), w = useMemo(
8971
- () => p ? o.filter(
8972
- (I) => reject(filter(values(E), { group: I }), { hidden: !0 }).length > 0
9002
+ () => u ? o.filter(
9003
+ (I) => reject(filter(values(_), { group: I }), { hidden: !0 }).length > 0
8973
9004
  ) : o.filter((I) => reject(filter(values(n), { group: I }), { hidden: !0 }).length > 0),
8974
- [n, E, o, p]
9005
+ [n, _, o, u]
8975
9006
  ), j = useMemo(
8976
9007
  () => sortBy(w, (I) => CORE_GROUPS.indexOf(I) === -1 ? 99 : CORE_GROUPS.indexOf(I)),
8977
9008
  [w]
8978
- ), v = useMemo(() => h === "all" ? E : filter(values(E), { group: h }), [E, h]), _ = useMemo(() => h === "all" ? j : [h], [j, h]);
9009
+ ), v = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), E = useMemo(() => h === "all" ? j : [h], [j, h]);
8979
9010
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full flex-col", children: [
8980
- /* @__PURE__ */ jsx(SearchInput, { value: p, setValue: u }),
9011
+ /* @__PURE__ */ jsx(SearchInput, { value: u, setValue: p }),
8981
9012
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden pt-2", children: [
8982
9013
  !l && j.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
8983
9014
  /* @__PURE__ */ jsx(
@@ -9007,12 +9038,12 @@ const BlockCard = ({
9007
9038
  "div",
9008
9039
  {
9009
9040
  className: `h-full flex-1 overflow-hidden ${!l && j.length > 0 ? "w-3/4" : "w-full"}`,
9010
- children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar h-full", children: w.length === 0 && p ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
9041
+ children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar h-full", children: w.length === 0 && u ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
9011
9042
  c("No blocks found matching"),
9012
9043
  ' "',
9013
- p,
9044
+ u,
9014
9045
  '"'
9015
- ] }) }) : /* @__PURE__ */ jsx("div", { className: `${l ? "p-0" : "p-4"} space-y-6`, children: _.map((I, P) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
9046
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: `${l ? "p-0" : "p-4"} space-y-6`, children: E.map((I, P) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
9016
9047
  /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(c(I.toLowerCase())) }),
9017
9048
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + i, children: reject(
9018
9049
  h === "all" ? filter(values(v), { group: I }) : values(v),
@@ -9039,13 +9070,13 @@ const BlockCard = ({
9039
9070
  position: a = -1,
9040
9071
  fromSidebar: i = !1
9041
9072
  }) => {
9042
- const { t: l } = useTranslation(), [c, d] = useAtom$1(addBlockTabAtom), [, p] = useAtom$1(showPredefinedBlockCategoryAtom), u = useBuilderProp("flags.importHtml", !0), { data: g } = usePartialBlocksList(), m = Object.keys(g || {}).length > 0, { hasPermission: f } = usePermissions();
9073
+ const { t: l } = useTranslation(), [c, d] = useAtom$1(addBlockTabAtom), [, u] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("flags.importHtml", !0), { data: g } = usePartialBlocksList(), m = Object.keys(g || {}).length > 0, { hasPermission: f } = usePermissions();
9043
9074
  useEffect(() => {
9044
9075
  c === "partials" && !m && d("library");
9045
9076
  }, [c, m, d]);
9046
9077
  const h = useCallback(() => {
9047
9078
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
9048
- }, []), x = useChaiAddBlockTabs(), b = u && f(PERMISSIONS.IMPORT_HTML), C = useChaiLibraries().length > 0;
9079
+ }, []), x = useChaiAddBlockTabs(), b = p && f(PERMISSIONS.IMPORT_HTML), C = useChaiLibraries().length > 0;
9049
9080
  return useEffect(() => {
9050
9081
  c === "library" && !C && d("core");
9051
9082
  }, [c, C, d]), /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
@@ -9057,7 +9088,7 @@ const BlockCard = ({
9057
9088
  Tabs,
9058
9089
  {
9059
9090
  onValueChange: (k) => {
9060
- p(""), d(k);
9091
+ u(""), d(k);
9061
9092
  },
9062
9093
  value: c,
9063
9094
  className: "flex h-full max-h-full flex-col overflow-hidden",
@@ -9255,7 +9286,7 @@ const registerChaiSaveToLibrary = (o) => {
9255
9286
  }
9256
9287
  ) : null;
9257
9288
  }, CopyPasteBlocks = ({ isFromBody: o = !1 }) => {
9258
- const [n] = useBlocksStore(), [r] = useSelectedBlockIds(), { pasteBlocks: a } = usePasteBlocks(), [, i, l] = useCopyBlocks(), { t: c } = useTranslation(), d = useSelectedBlock(), p = useBuilderProp("flags.copyPaste", !0), u = useCallback(() => {
9289
+ const [n] = useBlocksStore(), [r] = useSelectedBlockIds(), { pasteBlocks: a } = usePasteBlocks(), [, i, l] = useCopyBlocks(), { t: c } = useTranslation(), d = useSelectedBlock(), u = useBuilderProp("flags.copyPaste", !0), p = useCallback(() => {
9259
9290
  var f;
9260
9291
  const m = (o ? (f = n == null ? void 0 : n.filter((h) => !(h != null && h._parent))) == null ? void 0 : f.map((h) => h == null ? void 0 : h._id) : r).map((h) => {
9261
9292
  const x = n.find((b) => b._id === h);
@@ -9284,11 +9315,11 @@ const registerChaiSaveToLibrary = (o) => {
9284
9315
  }) : i(m.map((h) => h.id));
9285
9316
  }, [r, n, i, l]);
9286
9317
  return /* @__PURE__ */ jsxs(Fragment, { children: [
9287
- p && /* @__PURE__ */ jsxs(
9318
+ u && /* @__PURE__ */ jsxs(
9288
9319
  DropdownMenuItem,
9289
9320
  {
9290
9321
  disabled: !canDuplicateBlock(d == null ? void 0 : d._type),
9291
- onClick: u,
9322
+ onClick: p,
9292
9323
  className: "flex items-center gap-x-4 text-xs",
9293
9324
  children: [
9294
9325
  /* @__PURE__ */ jsx(CopyIcon, {}),
@@ -9297,7 +9328,7 @@ const registerChaiSaveToLibrary = (o) => {
9297
9328
  ]
9298
9329
  }
9299
9330
  ),
9300
- p && /* @__PURE__ */ jsxs(
9331
+ u && /* @__PURE__ */ jsxs(
9301
9332
  DropdownMenuItem,
9302
9333
  {
9303
9334
  className: "flex items-center gap-x-4 text-xs",
@@ -9351,9 +9382,9 @@ const registerChaiSaveToLibrary = (o) => {
9351
9382
  }
9352
9383
  );
9353
9384
  }, BlockContextMenuContent = ({ node: o }) => {
9354
- const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), i = useSelectedBlock(), { hasPermission: l } = usePermissions(), { librarySite: c } = useBuilderProp("flags", { librarySite: !1 }), d = useIsDragAndDropEnabled(), p = useCallback(() => {
9385
+ const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), i = useSelectedBlock(), { hasPermission: l } = usePermissions(), { librarySite: c } = useBuilderProp("flags", { librarySite: !1 }), d = useIsDragAndDropEnabled(), u = useCallback(() => {
9355
9386
  a(r);
9356
- }, [r, a]), u = useMemo(() => has(i, "_libBlockId") && !isEmpty(i._libBlockId), [i == null ? void 0 : i._libBlockId]);
9387
+ }, [r, a]), p = useMemo(() => has(i, "_libBlockId") && !isEmpty(i._libBlockId), [i == null ? void 0 : i._libBlockId]);
9357
9388
  return o === "BODY" ? /* @__PURE__ */ jsx(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: l(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsxs(Fragment, { children: [
9358
9389
  /* @__PURE__ */ jsxs(
9359
9390
  DropdownMenuItem,
@@ -9408,7 +9439,7 @@ const registerChaiSaveToLibrary = (o) => {
9408
9439
  {
9409
9440
  disabled: !canDuplicateBlock(i == null ? void 0 : i._type),
9410
9441
  className: "flex items-center gap-x-4 text-xs",
9411
- onClick: p,
9442
+ onClick: u,
9412
9443
  children: [
9413
9444
  /* @__PURE__ */ jsx(CardStackPlusIcon, {}),
9414
9445
  " ",
@@ -9420,7 +9451,7 @@ const registerChaiSaveToLibrary = (o) => {
9420
9451
  /* @__PURE__ */ jsx(RenameBlock, { node: o }),
9421
9452
  l(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(CutBlocks, {}),
9422
9453
  l(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(CopyPasteBlocks, {}),
9423
- u && c && /* @__PURE__ */ jsx(UnlinkLibraryBlock, {}),
9454
+ p && c && /* @__PURE__ */ jsx(UnlinkLibraryBlock, {}),
9424
9455
  l(PERMISSIONS.CREATE_LIBRARY_BLOCK) && c && /* @__PURE__ */ jsx(SaveToLibrary, {}),
9425
9456
  /* @__PURE__ */ jsx(ExportCode, {}),
9426
9457
  l(PERMISSIONS.DELETE_BLOCK) && /* @__PURE__ */ jsx(RemoveBlocks, {})
@@ -9467,9 +9498,9 @@ const useStructureValidation = () => {
9467
9498
  errorsByBlock: c,
9468
9499
  // Helper functions
9469
9500
  getBlockErrors: (d) => c[d] || [],
9470
- getErrorsBySeverity: (d) => o.filter((p) => p.severity === d),
9501
+ getErrorsBySeverity: (d) => o.filter((u) => u.severity === d),
9471
9502
  getErrorMessages: () => o.map((d) => d.message),
9472
- getErrorMessagesBySeverity: (d) => o.filter((p) => p.severity === d).map((p) => p.message),
9503
+ getErrorMessagesBySeverity: (d) => o.filter((u) => u.severity === d).map((u) => u.message),
9473
9504
  // Get all error messages for display
9474
9505
  getAllErrorMessages: () => ({
9475
9506
  errors: o.filter((d) => d.severity === "error").map((d) => d.message),
@@ -9502,17 +9533,17 @@ const useStructureValidation = () => {
9502
9533
  var L;
9503
9534
  const { t: a } = useTranslation(), i = useUpdateBlocksProps(), [l] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
9504
9535
  let d = null;
9505
- const p = o.children.length > 0, { highlightBlock: u, clearHighlight: g } = useBlockHighlight(), m = useIsDragAndDropEnabled(), { id: f, data: h, isSelected: x, willReceiveDrop: b, isDragging: y, isEditing: C, handleClick: k } = o, S = useStructureValidation(), A = useMemo(() => S.getBlockErrors(f), [S, f]), B = get(h, "_show", !0), E = (T) => {
9536
+ const u = o.children.length > 0, { highlightBlock: p, clearHighlight: g } = useBlockHighlight(), m = useIsDragAndDropEnabled(), { id: f, data: h, isSelected: x, willReceiveDrop: b, isDragging: y, isEditing: C, handleClick: k } = o, S = useStructureValidation(), A = useMemo(() => S.getBlockErrors(f), [S, f]), B = get(h, "_show", !0), _ = (T) => {
9506
9537
  T.stopPropagation(), B && o.toggle();
9507
9538
  }, w = (T) => {
9508
9539
  T.isInternal && (d = T.isOpen, T.isOpen && T.close());
9509
9540
  }, j = (T) => {
9510
9541
  T.isInternal && d !== null && (d ? T.open() : T.close(), d = null);
9511
- }, [v, _] = useAtom$1(currentAddSelection), N = () => {
9542
+ }, [v, E] = useAtom$1(currentAddSelection), N = () => {
9512
9543
  var T;
9513
- I(), o.parent.isSelected || _((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
9544
+ I(), o.parent.isSelected || E((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
9514
9545
  }, I = () => {
9515
- _(null);
9546
+ E(null);
9516
9547
  }, P = (T) => {
9517
9548
  I(), T.stopPropagation(), !o.isOpen && B && o.toggle(), k(T);
9518
9549
  };
@@ -9554,7 +9585,7 @@ const useStructureValidation = () => {
9554
9585
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
9555
9586
  "div",
9556
9587
  {
9557
- onMouseEnter: () => u(f),
9588
+ onMouseEnter: () => p(f),
9558
9589
  onMouseLeave: () => g(),
9559
9590
  onClick: P,
9560
9591
  style: n,
@@ -9602,7 +9633,7 @@ const useStructureValidation = () => {
9602
9633
  "div",
9603
9634
  {
9604
9635
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
9605
- children: p && /* @__PURE__ */ jsx("button", { onClick: E, type: "button", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) })
9636
+ children: u && /* @__PURE__ */ jsx("button", { onClick: _, type: "button", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) })
9606
9637
  }
9607
9638
  ),
9608
9639
  /* @__PURE__ */ jsxs(
@@ -10101,7 +10132,7 @@ const useStructureValidation = () => {
10101
10132
  console.warn("Failed to clear previous theme from localStorage:", o);
10102
10133
  }
10103
10134
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
10104
- const [n, r] = useDarkMode(), [a, i] = React.useState(""), [l, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions(), g = useBuilderProp("flags.importTheme", !0), m = useBuilderProp("flags.darkMode", !0), f = useIncrementActionsCount();
10135
+ const [n, r] = useDarkMode(), [a, i] = React.useState(""), [l, c] = React.useState(!1), d = useBuilderProp("themePresets", []), u = useBuilderProp("themePanelComponent", null), { hasPermission: p } = usePermissions(), g = useBuilderProp("flags.importTheme", !0), m = useBuilderProp("flags.darkMode", !0), f = useIncrementActionsCount();
10105
10136
  (!d || d.length === 0) && DEFAULT_THEME_PRESET.map((j) => {
10106
10137
  d.push(j);
10107
10138
  });
@@ -10152,15 +10183,15 @@ const useStructureValidation = () => {
10152
10183
  })), f();
10153
10184
  },
10154
10185
  [h, f]
10155
- ), E = useDebouncedCallback(
10186
+ ), _ = useDebouncedCallback(
10156
10187
  (j, v) => {
10157
10188
  x(() => {
10158
- const _ = get(h, `colors.${j}`);
10159
- return n ? set(_, 1, v) : set(_, 0, v), f(), {
10189
+ const E = get(h, `colors.${j}`);
10190
+ return n ? set(E, 1, v) : set(E, 0, v), f(), {
10160
10191
  ...h,
10161
10192
  colors: {
10162
10193
  ...h.colors,
10163
- [j]: _
10194
+ [j]: E
10164
10195
  }
10165
10196
  };
10166
10197
  });
@@ -10168,19 +10199,19 @@ const useStructureValidation = () => {
10168
10199
  [h, f],
10169
10200
  200
10170
10201
  ), w = (j) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(j.items).map(([v]) => {
10171
- const _ = get(h, `colors.${v}.${n ? 1 : 0}`);
10172
- return _ ? /* @__PURE__ */ jsxs("div", { id: `theme-${v}`, className: "mt-1 flex items-center gap-x-2", children: [
10202
+ const E = get(h, `colors.${v}.${n ? 1 : 0}`);
10203
+ return E ? /* @__PURE__ */ jsxs("div", { id: `theme-${v}`, className: "mt-1 flex items-center gap-x-2", children: [
10173
10204
  /* @__PURE__ */ jsx(
10174
10205
  ColorPickerInput,
10175
10206
  {
10176
- value: _,
10177
- onChange: (N) => E(v, N)
10207
+ value: E,
10208
+ onChange: (N) => _(v, N)
10178
10209
  }
10179
10210
  ),
10180
10211
  /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: v.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((N) => N.charAt(0).toUpperCase() + N.slice(1)).join(" ") + (!v.toLowerCase().includes("foreground") && !v.toLowerCase().includes("border") && !v.toLowerCase().includes("input") && !v.toLowerCase().includes("ring") && !v.toLowerCase().includes("background") ? " Background" : "") })
10181
10212
  ] }, v) : null;
10182
10213
  }) });
10183
- return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
10214
+ return p("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
10184
10215
  /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
10185
10216
  d.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mx-0 my-2 flex flex-col gap-1 py-2", children: [
10186
10217
  /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
@@ -10194,8 +10225,8 @@ const useStructureValidation = () => {
10194
10225
  /* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: i, children: [
10195
10226
  /* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: y("Select preset") }) }),
10196
10227
  /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((j) => {
10197
- const v = Object.keys(j)[0], _ = v.replaceAll("_", " ");
10198
- return /* @__PURE__ */ jsx(SelectItem, { value: v, children: capitalize(_) }, v);
10228
+ const v = Object.keys(j)[0], E = v.replaceAll("_", " ");
10229
+ return /* @__PURE__ */ jsx(SelectItem, { value: v, children: capitalize(E) }, v);
10199
10230
  }) })
10200
10231
  ] }) }),
10201
10232
  /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: k, children: y("Apply") }) })
@@ -10212,7 +10243,7 @@ const useStructureValidation = () => {
10212
10243
  {
10213
10244
  label: j,
10214
10245
  value: h.fontFamily[j.replace(/font-/g, "")] || v[Object.keys(v)[0]],
10215
- onChange: (_) => A(j, _)
10246
+ onChange: (E) => A(j, E)
10216
10247
  },
10217
10248
  j
10218
10249
  )) }),
@@ -10264,7 +10295,7 @@ const useStructureValidation = () => {
10264
10295
  /* @__PURE__ */ jsx("br", {}),
10265
10296
  /* @__PURE__ */ jsx("br", {})
10266
10297
  ] }),
10267
- p && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(p) })
10298
+ u && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(u) })
10268
10299
  ] }) : /* @__PURE__ */ jsx("div", { className: "relative w-full", children: /* @__PURE__ */ jsx("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto text-center", o), children: /* @__PURE__ */ jsx("div", { className: "mt-10 h-full items-center justify-center gap-2 text-muted-foreground", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: y("You don't have permission to edit the theme. Please contact your administrator to get access.") }) }) }) });
10269
10300
  }), Core = "Core", Import = "Import", Breakpoints = "Breakpoints", Clear = "Clear", Cancel = "Cancel", Yes = "Yes", Preview = "Preview", Settings = "Settings", Styling = "Style", SVG_code = "Enter SVG code here", Remove = "Remove", Choose = "Choose", Cut = "Cut", Copy = "Copy", Paste = "Paste", Delete = "Delete", classes = "classes", Theme = "Theme", Outline = "Outline", Copied = "Copied", Stop = "Stop", Edit = "Edit", Tag = "Tag", Value = "Value", URL$1 = "URL", Images = "Images", Library = "Library", Blocks = "Blocks", Basic = "Basic", Media = "Media", Advanced = "Advanced", Form = "Form", Groups = "Groups", Accordions = "Accordions", Buttons = "Buttons", Layouts = "Layouts", FAQ = "FAQ", Hero = "Hero", Features = "Features", Footer = "Footer", Navbar = "Navbar", Icons = "Icons", Testimonials = "Testimonials", Blog = "Blog", Saved = "Saved", Unsaved = "Unsaved", Randomize = "Randomize", Classes = "Classes", All = "All", Undo = "Undo", Redo = "Redo", Duplicate = "Duplicate", Close = "Close", Selected = "Selected", Select = "Select", Attributes = "Attributes", apply = "apply", presets = "presets", Orientation = "Orientation", Color = "Color", Upload = "Upload", Apply = "Apply", Back = "Back", Insert = "Insert", Rename = "Rename", Partials = "Partials", Happy = "Happy", Sad = "Sad", Retry = "Retry", canvas_empty = "Canvas is empty", Presets = "Presets", No = "No", Saving = "Saving", theme_config = { heading_font: "Heading Font", body_font: "Body Font", rounded_corner: "Rounded Corners", primary: "Primary", secondary: "Secondary", background: "Background", text_color: "Text Color", background_dark_mode: "Background (Dark Mode)", text_color_dark_mode: "Text Color (Dark Mode)" }, web_blocks = { box: "box", tag: "Tag", div: "div", level: "Level", header: "header", footer: "footer", section: "section", article: "article", aside: "aside", main: "main", nav: "navigation", figure: "figure", details: "details", summary: "summary", dialog: "dialog", strike: "strike", caption: "caption", legend: "legend", figcaption: "figure caption", mark: "mark", background_image: "Background Image", label: "Label", default: "default", icon_size: "Icon Size", icon_position: "Icon Position", start: "Start", end: "End", button: "Button", custom_html: "Custom HTML", html_code: "HTML Code", default_snippet: "The HTML snippet goes here...", placeholder: "Enter custom HTML code here", custom_script: "Custom Script", dark_mode: "Dark Mode", divider: "Divider", empty_box: "Empty Box", heading: "Heading", image: "Image", alt: "Alt", width: "Width", height: "Height", video: "Video", span: "Span", content: "Content", icon: "Icon", richtext: "Rich Text", list: "List", list_type: "List Type", listitem: "List Item", link: "Link", list_item: "List Item", none: "None", disc: "Disc", number: "Number", paragraph: "Paragraph", lightbox_link: "Lightbox Link", href: "Link", type: "Type", iframe: "iframe", inline: "inline", ajax: "ajax", autoplay: "Video autoplay", max_width: "Max Width", backdrop_color: "Background Color", gallery_name: "Gallery Name", slot: "Slot", empty_slot: "Empty Slot", text: "Text", video_url: "Video URL", controls: "Show Controls", loop: "Loop", muted: "Muted", checkbox: "Checkbox", required: "Required", checked: "Checked", submit_button: "Submit Button", form: "Form", submit_url: "Submit URL", error_message: "Error Message", success_message: "Success Message", input: "Input", value: "Value", show_label: "Show Label", field_name: "Field Name", radio: "Radio", multiple: "Multiple", options: "Options", select: "Select", multiple_choice: "Multiple Choice", textarea: "Textarea", rows: "Rows" }, Add = "Add", Save = "Save", Screen = "Screen", lngEn = {
10270
10301
  "Add block": "Add Block",
@@ -10775,13 +10806,13 @@ function QuickPrompts({ onClick: o }) {
10775
10806
  lang: get(LANGUAGES, a, a)
10776
10807
  })
10777
10808
  }), /* @__PURE__ */ jsx("div", { className: n ? "pointer-events-none opacity-50" : "", children: /* @__PURE__ */ jsx("ul", { className: "space-y-1", children: c.map(
10778
- ({ name: d, icon: p, subMenus: u, prompt: g }) => u ? /* @__PURE__ */ jsxs(Popover, { children: [
10809
+ ({ name: d, icon: u, subMenus: p, prompt: g }) => p ? /* @__PURE__ */ jsxs(Popover, { children: [
10779
10810
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
10780
10811
  "li",
10781
10812
  {
10782
10813
  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",
10783
10814
  children: [
10784
- /* @__PURE__ */ jsx(p, { className: "h-4 w-4" }),
10815
+ /* @__PURE__ */ jsx(u, { className: "h-4 w-4" }),
10785
10816
  /* @__PURE__ */ jsx("span", { children: d })
10786
10817
  ]
10787
10818
  },
@@ -10794,7 +10825,7 @@ function QuickPrompts({ onClick: o }) {
10794
10825
  onClick: () => o(g),
10795
10826
  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",
10796
10827
  children: [
10797
- /* @__PURE__ */ jsx(p, { className: "h-3.5 w-3.5" }),
10828
+ /* @__PURE__ */ jsx(u, { className: "h-3.5 w-3.5" }),
10798
10829
  /* @__PURE__ */ jsx("span", { children: r(d) })
10799
10830
  ]
10800
10831
  },
@@ -10803,7 +10834,7 @@ function QuickPrompts({ onClick: o }) {
10803
10834
  ) }) });
10804
10835
  }
10805
10836
  const AIUserPrompt = ({ blockId: o }) => {
10806
- const { t: n } = useTranslation(), { askAi: r, loading: a, error: i } = useAskAi(), [l, c] = useState(""), d = useRef(null), p = useRef(null), u = useSelectedBlock();
10837
+ const { t: n } = useTranslation(), { askAi: r, loading: a, error: i } = useAskAi(), [l, c] = useState(""), d = useRef(null), u = useRef(null), p = useSelectedBlock();
10807
10838
  useEffect(() => {
10808
10839
  var m;
10809
10840
  (m = d.current) == null || m.focus();
@@ -10813,10 +10844,10 @@ const AIUserPrompt = ({ blockId: o }) => {
10813
10844
  };
10814
10845
  return /* @__PURE__ */ jsx("div", { className: "", children: o ? /* @__PURE__ */ jsxs("div", { className: "", children: [
10815
10846
  /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-gray-500", children: n("Selected block") }),
10816
- 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: [
10817
- /* @__PURE__ */ jsx(TypeIcon, { type: u._type }),
10847
+ p && /* @__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: [
10848
+ /* @__PURE__ */ jsx(TypeIcon, { type: p._type }),
10818
10849
  " ",
10819
- /* @__PURE__ */ jsx("p", { className: "truncate whitespace-nowrap leading-none", children: u._name || u._type })
10850
+ /* @__PURE__ */ jsx("p", { className: "truncate whitespace-nowrap leading-none", children: p._name || p._type })
10820
10851
  ] }),
10821
10852
  /* @__PURE__ */ jsx("br", {}),
10822
10853
  /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-gray-500", children: n("Quick actions") }),
@@ -10824,7 +10855,7 @@ const AIUserPrompt = ({ blockId: o }) => {
10824
10855
  QuickPrompts,
10825
10856
  {
10826
10857
  onClick: (m) => {
10827
- p.current && clearTimeout(p.current), r("content", o, m, g);
10858
+ u.current && clearTimeout(u.current), r("content", o, m, g);
10828
10859
  }
10829
10860
  }
10830
10861
  ) }),
@@ -10841,7 +10872,7 @@ const AIUserPrompt = ({ blockId: o }) => {
10841
10872
  className: "w-full resize-none border-none p-0 text-xs shadow-none outline-none",
10842
10873
  rows: 3,
10843
10874
  onKeyDown: (m) => {
10844
- m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), r("content", o, l, g));
10875
+ m.key === "Enter" && (m.preventDefault(), u.current && clearTimeout(u.current), r("content", o, l, g));
10845
10876
  }
10846
10877
  }
10847
10878
  ),
@@ -10851,7 +10882,7 @@ const AIUserPrompt = ({ blockId: o }) => {
10851
10882
  Button,
10852
10883
  {
10853
10884
  onClick: () => {
10854
- p.current && clearTimeout(p.current), r("content", o, l, g);
10885
+ u.current && clearTimeout(u.current), r("content", o, l, g);
10855
10886
  },
10856
10887
  variant: "default",
10857
10888
  className: "h-7 w-7",
@@ -10915,11 +10946,11 @@ const UndoRedo = () => {
10915
10946
  const { hasErrors: o, hasWarnings: n, errorCount: r, warningCount: a, errors: i } = useStructureValidation(), [, l] = useSelectedBlockIds(), { t: c } = useTranslation();
10916
10947
  if (!o && !n)
10917
10948
  return null;
10918
- const d = () => o ? "text-red-500" : n ? "text-orange-500" : "text-gray-500", p = () => o ? /* @__PURE__ */ jsx(ExclamationTriangleIcon, { className: "h-4 w-4" }) : n ? /* @__PURE__ */ jsx(InfoCircledIcon, { className: "h-4 w-4" }) : null, u = () => o && n ? `${r} error${r > 1 ? "s" : ""}, ${a} warning${a > 1 ? "s" : ""}` : o ? `${r} error${r > 1 ? "s" : ""}` : n ? `${a} warning${a > 1 ? "s" : ""}` : "";
10949
+ const d = () => o ? "text-red-500" : n ? "text-orange-500" : "text-gray-500", u = () => o ? /* @__PURE__ */ jsx(ExclamationTriangleIcon, { className: "h-4 w-4" }) : n ? /* @__PURE__ */ jsx(InfoCircledIcon, { className: "h-4 w-4" }) : null, p = () => o && n ? `${r} error${r > 1 ? "s" : ""}, ${a} warning${a > 1 ? "s" : ""}` : o ? `${r} error${r > 1 ? "s" : ""}` : n ? `${a} warning${a > 1 ? "s" : ""}` : "";
10919
10950
  return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
10920
10951
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs("div", { className: `ml-2 flex cursor-pointer items-center gap-2 ${d()}`, children: [
10921
- p(),
10922
- /* @__PURE__ */ jsx("span", { className: "text-xs font-medium", children: u() })
10952
+ u(),
10953
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium", children: p() })
10923
10954
  ] }) }),
10924
10955
  /* @__PURE__ */ jsx(DropdownMenuContent, { side: "bottom", className: "max-w-xs p-2", align: "end", children: /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
10925
10956
  /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: c("Invalid structure") }),
@@ -10971,9 +11002,9 @@ const UndoRedo = () => {
10971
11002
  ] })
10972
11003
  ] });
10973
11004
  }, AddBlocksDialog = () => {
10974
- const { t: o } = useTranslation(), [n, r] = useState(""), [a, i] = useState(-1), [l, c] = useState(!1), d = useIsDragAndDropEnabled(), [, p] = useSidebarActivePanel();
10975
- return usePubSub(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, (u) => {
10976
- d ? p("add-block") : (r(u ? u._id : null), i(isNaN(u == null ? void 0 : u.position) ? -1 : u == null ? void 0 : u.position), c(!0));
11005
+ const { t: o } = useTranslation(), [n, r] = useState(""), [a, i] = useState(-1), [l, c] = useState(!1), d = useIsDragAndDropEnabled(), [, u] = useSidebarActivePanel();
11006
+ return usePubSub(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, (p) => {
11007
+ d ? u("add-block") : (r(p ? p._id : null), i(isNaN(p == null ? void 0 : p.position) ? -1 : p == null ? void 0 : p.position), c(!0));
10977
11008
  }), usePubSub(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK, () => {
10978
11009
  r(""), i(-1), c(!1);
10979
11010
  }), /* @__PURE__ */ jsx(AlertDialog, { open: l, onOpenChange: () => l ? c(!1) : "", children: /* @__PURE__ */ jsxs(AlertDialogContent, { className: "max-w-5xl overflow-hidden border-border", children: [
@@ -10994,7 +11025,7 @@ const UndoRedo = () => {
10994
11025
  preloadedAttributes: n = [],
10995
11026
  onAttributesChange: r
10996
11027
  }) {
10997
- const [a, i] = useState([]), [l, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, f] = useState(""), h = useRef(null), x = useRef(null), b = usePageExternalData(), { t: y } = useTranslation();
11028
+ const [a, i] = useState([]), [l, c] = useState(""), [d, u] = useState(""), [p, g] = useState(null), [m, f] = useState(""), h = useRef(null), x = useRef(null), b = usePageExternalData(), { t: y } = useTranslation();
10998
11029
  useEffect(() => {
10999
11030
  i(n);
11000
11031
  }, [n]);
@@ -11005,25 +11036,25 @@ const UndoRedo = () => {
11005
11036
  }
11006
11037
  if (l) {
11007
11038
  const w = [...a, { key: l, value: d }];
11008
- r(w), i(a), c(""), p(""), f("");
11039
+ r(w), i(a), c(""), u(""), f("");
11009
11040
  }
11010
11041
  }, k = (w) => {
11011
- const j = a.filter((v, _) => _ !== w);
11042
+ const j = a.filter((v, E) => E !== w);
11012
11043
  r(j), i(j);
11013
11044
  }, S = (w) => {
11014
- g(w), c(a[w].key), p(a[w].value);
11045
+ g(w), c(a[w].key), u(a[w].value);
11015
11046
  }, A = () => {
11016
11047
  if (l.startsWith("@")) {
11017
11048
  f(y("Attribute keys cannot start with @"));
11018
11049
  return;
11019
11050
  }
11020
- if (u !== null && l) {
11051
+ if (p !== null && l) {
11021
11052
  const w = [...a];
11022
- w[u] = { key: l, value: d }, r(w), i(w), g(null), c(""), p(""), f("");
11053
+ w[p] = { key: l, value: d }, r(w), i(w), g(null), c(""), u(""), f("");
11023
11054
  }
11024
11055
  }, B = (w) => {
11025
- w.key === "Enter" && !w.shiftKey && (w.preventDefault(), u !== null ? A() : C());
11026
- }, E = useCallback((w) => {
11056
+ w.key === "Enter" && !w.shiftKey && (w.preventDefault(), p !== null ? A() : C());
11057
+ }, _ = useCallback((w) => {
11027
11058
  const j = (N) => /[.,!?;:]/.test(N), v = (N, I, P) => {
11028
11059
  let D = "", R = "";
11029
11060
  const $ = I > 0 ? N[I - 1] : "", F = I < N.length ? N[I] : "";
@@ -11032,16 +11063,16 @@ const UndoRedo = () => {
11032
11063
  prefixLength: D.length,
11033
11064
  suffixLength: R.length
11034
11065
  };
11035
- }, _ = x.current;
11036
- if (_) {
11037
- const N = _.selectionStart || 0, I = _.value || "", P = _.selectionEnd || N;
11066
+ }, E = x.current;
11067
+ if (E) {
11068
+ const N = E.selectionStart || 0, I = E.value || "", P = E.selectionEnd || N;
11038
11069
  if (P > N) {
11039
11070
  const O = `{{${w}}}`, { text: L } = v(I, N, O), T = I.slice(0, N) + L + I.slice(P);
11040
- p(T);
11071
+ u(T);
11041
11072
  return;
11042
11073
  }
11043
11074
  const R = `{{${w}}}`, { text: $ } = v(I, N, R), F = I.slice(0, N) + $ + I.slice(N);
11044
- p(F);
11075
+ u(F);
11045
11076
  }
11046
11077
  }, []);
11047
11078
  return /* @__PURE__ */ jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
@@ -11049,7 +11080,7 @@ const UndoRedo = () => {
11049
11080
  "form",
11050
11081
  {
11051
11082
  onSubmit: (w) => {
11052
- w.preventDefault(), u !== null ? A() : C();
11083
+ w.preventDefault(), p !== null ? A() : C();
11053
11084
  },
11054
11085
  className: "space-y-3",
11055
11086
  children: [
@@ -11074,7 +11105,7 @@ const UndoRedo = () => {
11074
11105
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
11075
11106
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
11076
11107
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: y("Value") }),
11077
- !isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: E })
11108
+ !isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: _ })
11078
11109
  ] }),
11079
11110
  /* @__PURE__ */ jsx(
11080
11111
  Textarea,
@@ -11085,7 +11116,7 @@ const UndoRedo = () => {
11085
11116
  id: "attrValue",
11086
11117
  ref: x,
11087
11118
  value: d,
11088
- onChange: (w) => p(w.target.value),
11119
+ onChange: (w) => u(w.target.value),
11089
11120
  onKeyDown: B,
11090
11121
  placeholder: y("Enter value"),
11091
11122
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
@@ -11093,7 +11124,7 @@ const UndoRedo = () => {
11093
11124
  )
11094
11125
  ] })
11095
11126
  ] }),
11096
- /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !l.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: y(u !== null ? "Save" : "Add") }) }),
11127
+ /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !l.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: y(p !== null ? "Save" : "Add") }) }),
11097
11128
  m && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: m })
11098
11129
  ]
11099
11130
  }
@@ -11112,15 +11143,15 @@ const UndoRedo = () => {
11112
11143
  }), BlockAttributesEditor = React.memo(() => {
11113
11144
  const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), i = useUpdateBlocksProps(), l = `${get(a, "0.prop")}_attrs`;
11114
11145
  React.useEffect(() => {
11115
- const d = map(get(o, l), (p, u) => ({ key: u, value: p }));
11146
+ const d = map(get(o, l), (u, p) => ({ key: p, value: u }));
11116
11147
  isEmpty(d) ? r([]) : r(d);
11117
11148
  }, [get(o, l)]);
11118
11149
  const c = React.useCallback(
11119
11150
  (d = []) => {
11120
- const p = {};
11121
- forEach(d, (u) => {
11122
- isEmpty(u.key) || set(p, u.key, u.value);
11123
- }), i([get(o, "_id")], { [l]: p });
11151
+ const u = {};
11152
+ forEach(d, (p) => {
11153
+ isEmpty(p.key) || set(u, p.key, p.value);
11154
+ }), i([get(o, "_id")], { [l]: u });
11124
11155
  },
11125
11156
  [o, i, l]
11126
11157
  );
@@ -11279,13 +11310,13 @@ const PartialWrapper = ({ partialBlockId: o }) => {
11279
11310
  label: getBlockLabel(a)
11280
11311
  }));
11281
11312
  }, TokenUsagePopover = ({ tokenId: o, tokenName: n }) => {
11282
- const { t: r } = useTranslation(), [a] = useBlocksStore(), [i, l] = useSelectedBlockIds(), c = useBuilderProp("pageId"), d = useBuilderProp("siteWideUsage"), p = useMemo(() => collectTokenUsageOnPage(a, o), [a, o]), u = useMemo(
11283
- () => p.map((S) => ({
11313
+ const { t: r } = useTranslation(), [a] = useBlocksStore(), [i, l] = useSelectedBlockIds(), c = useBuilderProp("pageId"), d = useBuilderProp("siteWideUsage"), u = useMemo(() => collectTokenUsageOnPage(a, o), [a, o]), p = useMemo(
11314
+ () => u.map((S) => ({
11284
11315
  id: S.id,
11285
11316
  label: S.label,
11286
11317
  isSelected: i.includes(S.id)
11287
11318
  })),
11288
- [p, i]
11319
+ [u, i]
11289
11320
  ), g = useMemo(() => d ? Object.entries(d).reduce(
11290
11321
  (S, [A, B]) => (A === c || !(B != null && B.designTokens) || !Object.keys(B.designTokens).some((w) => typeof w != "string" ? !1 : w === o) || S.push({ id: A, name: B.name || A, isPartial: !!B.isPartial }), S),
11291
11322
  []
@@ -11321,7 +11352,7 @@ const PartialWrapper = ({ partialBlockId: o }) => {
11321
11352
  TokenUsageSection,
11322
11353
  {
11323
11354
  title: r("Blocks affected on this page"),
11324
- items: u,
11355
+ items: p,
11325
11356
  emptyLabel: r("None"),
11326
11357
  onSelect: h,
11327
11358
  icon: /* @__PURE__ */ jsx(ArrowRightIcon, { fontSize: 4 })
@@ -11351,7 +11382,7 @@ const PartialWrapper = ({ partialBlockId: o }) => {
11351
11382
  ] })
11352
11383
  ] });
11353
11384
  }, ManageDesignTokens = ({}) => {
11354
- const { t: o } = useTranslation(), [n, r] = useAtom$1(chaiDesignTokensAtom), [a, i] = useState(!1), [l, c] = useState(null), [d, p] = useState(!1), [u, g] = useState(!1), [m, f] = useState(""), [h, x] = useState(""), [b, y] = useState(""), [C, k] = useState(""), [S, A] = useState(""), [B, E] = useState(""), w = useIncrementActionsCount(), j = (L) => {
11385
+ const { t: o } = useTranslation(), [n, r] = useAtom$1(chaiDesignTokensAtom), [a, i] = useState(!1), [l, c] = useState(null), [d, u] = useState(!1), [p, g] = useState(!1), [m, f] = useState(""), [h, x] = useState(""), [b, y] = useState(""), [C, k] = useState(""), [S, A] = useState(""), [B, _] = useState(""), w = useIncrementActionsCount(), j = (L) => {
11355
11386
  const T = L.trim();
11356
11387
  return T.length === 0 || T.length > 25 ? !1 : /^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(T);
11357
11388
  }, v = (L, T = !1, M) => {
@@ -11359,7 +11390,7 @@ const PartialWrapper = ({ partialBlockId: o }) => {
11359
11390
  return H.length === 0 ? "" : H.length > 25 ? o("Token name must be 25 characters or less") : /^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(H) ? Object.entries(n).find(
11360
11391
  ([V, U]) => U.name === H && (!T || V !== M)
11361
11392
  ) ? o("Token name already exists") : "" : o("Only alphanumeric characters and hyphens allowed");
11362
- }, _ = () => {
11393
+ }, E = () => {
11363
11394
  if (!m.trim() || !h.trim()) {
11364
11395
  toast.error(o("Please fill in both token name and classes"));
11365
11396
  return;
@@ -11379,7 +11410,7 @@ const PartialWrapper = ({ partialBlockId: o }) => {
11379
11410
  value: h.trim()
11380
11411
  }
11381
11412
  };
11382
- r(M), f(""), x(""), i(!1), p(!1), w(), toast.success(o("Token added successfully"));
11413
+ r(M), f(""), x(""), i(!1), u(!1), w(), toast.success(o("Token added successfully"));
11383
11414
  }, N = () => {
11384
11415
  if (!b.trim() || !C.trim()) {
11385
11416
  toast.error(o("Please fill in both token name and classes"));
@@ -11412,17 +11443,17 @@ const PartialWrapper = ({ partialBlockId: o }) => {
11412
11443
  const T = n[L];
11413
11444
  T && (c(L), y(T.name), k(T.value), i(!1), g(!0));
11414
11445
  }, D = () => {
11415
- i(!0), c(null), f(""), x(""), A(""), p(!0);
11446
+ i(!0), c(null), f(""), x(""), A(""), u(!0);
11416
11447
  }, R = () => {
11417
- c(null), y(""), k(""), E(""), g(!1);
11448
+ c(null), y(""), k(""), _(""), g(!1);
11418
11449
  }, $ = () => {
11419
- i(!1), f(""), x(""), A(""), p(!1);
11450
+ i(!1), f(""), x(""), A(""), u(!1);
11420
11451
  }, F = (L) => {
11421
11452
  const T = L.replace(/\s+/g, "-");
11422
11453
  f(T), A(v(T));
11423
11454
  }, O = (L) => {
11424
11455
  const T = L.replace(/\s+/g, "-");
11425
- y(T), E(v(T, !0, l || void 0));
11456
+ y(T), _(v(T, !0, l || void 0));
11426
11457
  };
11427
11458
  return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col", children: [
11428
11459
  /* @__PURE__ */ jsx("div", { className: "", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxs(
@@ -11535,10 +11566,10 @@ const PartialWrapper = ({ partialBlockId: o }) => {
11535
11566
  ] }),
11536
11567
  /* @__PURE__ */ jsxs(DialogFooter, { children: [
11537
11568
  /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: $, className: "h-8 text-sm", children: o("Cancel") }),
11538
- /* @__PURE__ */ jsx(Button, { onClick: _, className: "h-8 text-sm", children: o("Add Token") })
11569
+ /* @__PURE__ */ jsx(Button, { onClick: E, className: "h-8 text-sm", children: o("Add Token") })
11539
11570
  ] })
11540
11571
  ] }) }),
11541
- /* @__PURE__ */ jsx(Dialog, { open: u, onOpenChange: R, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-md", children: [
11572
+ /* @__PURE__ */ jsx(Dialog, { open: p, onOpenChange: R, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-md", children: [
11542
11573
  /* @__PURE__ */ jsxs(DialogHeader, { children: [
11543
11574
  /* @__PURE__ */ jsx(DialogTitle, { className: "text-base", children: o("Edit Design Token") }),
11544
11575
  /* @__PURE__ */ jsx(DialogDescription, { className: "text-sm", children: o("Update the design token name and classes.") })
@@ -11602,14 +11633,14 @@ registerChaiSidebarPanel("outline", {
11602
11633
  panel: () => /* @__PURE__ */ jsx("div", { className: "-mt-8", children: /* @__PURE__ */ jsx(ListTree, {}) })
11603
11634
  });
11604
11635
  const RootLayout = () => {
11605
- const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [i, l] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = reverse([...u ?? []]), m = useCallback((w) => {
11636
+ const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [i, l] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), u = useChaiSidebarPanels("top"), p = useChaiSidebarPanels("bottom"), g = reverse([...p ?? []]), m = useCallback((w) => {
11606
11637
  w.preventDefault();
11607
- }, []), f = useMemo(() => [p].flat(), [p]), h = useCallback(
11638
+ }, []), f = useMemo(() => [u].flat(), [u]), h = useCallback(
11608
11639
  (w) => {
11609
11640
  console.log("handleMenuItemClick", w, n), r(n === w ? null : w);
11610
11641
  },
11611
11642
  [n, r]
11612
- ), { t: x } = useTranslation(), b = useMemo(() => [...p, ...u], [p, u]), y = useBuilderProp("htmlDir", "ltr"), C = find(b, { id: n }) ?? first(b), k = get(C, "width", DEFAULT_PANEL_WIDTH);
11643
+ ), { t: x } = useTranslation(), b = useMemo(() => [...u, ...p], [u, p]), y = useBuilderProp("htmlDir", "ltr"), C = find(b, { id: n }) ?? first(b), k = get(C, "width", DEFAULT_PANEL_WIDTH);
11613
11644
  useEffect(() => {
11614
11645
  if (n !== null) {
11615
11646
  const w = find(b, { id: n });
@@ -11628,7 +11659,7 @@ const RootLayout = () => {
11628
11659
  useEffect(() => {
11629
11660
  n !== null && !find(b, { id: n }) && r("outline");
11630
11661
  }, [n, b]);
11631
- const E = useCallback(
11662
+ const _ = useCallback(
11632
11663
  (w) => {
11633
11664
  h(w);
11634
11665
  },
@@ -11649,7 +11680,7 @@ const RootLayout = () => {
11649
11680
  position: "top",
11650
11681
  panelId: w.id,
11651
11682
  isActive: n === w.id,
11652
- show: () => E(w.id)
11683
+ show: () => _(w.id)
11653
11684
  }) }),
11654
11685
  /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(w.label) }) })
11655
11686
  ] }, "button-top-" + j)) }),
@@ -11659,7 +11690,7 @@ const RootLayout = () => {
11659
11690
  position: "bottom",
11660
11691
  panelId: w.id,
11661
11692
  isActive: n === w.id,
11662
- show: () => E(w.id)
11693
+ show: () => _(w.id)
11663
11694
  }) }),
11664
11695
  /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(w.label) }) })
11665
11696
  ] }, "button-bottom-" + j)) })
@@ -11848,7 +11879,7 @@ const RootLayout = () => {
11848
11879
  position: n,
11849
11880
  updatePosition: r
11850
11881
  }) => {
11851
- const a = useChaiFeatureFlags(), [i, l] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
11882
+ const a = useChaiFeatureFlags(), [i, l] = useState(""), [c, d] = useState(!1), [u, p] = useState({ x: 0, y: 0 }), g = useMemo(() => {
11852
11883
  if (!i.trim()) return a;
11853
11884
  const x = i.toLowerCase();
11854
11885
  return Object.fromEntries(
@@ -11858,14 +11889,14 @@ const RootLayout = () => {
11858
11889
  })
11859
11890
  );
11860
11891
  }, [a, i]), m = (x) => {
11861
- d(!0), u({
11892
+ d(!0), p({
11862
11893
  x: x.clientX - n.x,
11863
11894
  y: x.clientY - n.y
11864
11895
  });
11865
11896
  }, f = (x) => {
11866
11897
  if (!c) return;
11867
- const b = x.clientX - p.x, y = x.clientY - p.y, C = x.currentTarget, k = C.offsetWidth, S = C.offsetHeight, A = window.innerWidth - k, B = window.innerHeight - S, E = Math.max(0, Math.min(b, A)), w = Math.max(0, Math.min(y, B));
11868
- r(E, w);
11898
+ const b = x.clientX - u.x, y = x.clientY - u.y, C = x.currentTarget, k = C.offsetWidth, S = C.offsetHeight, A = window.innerWidth - k, B = window.innerHeight - S, _ = Math.max(0, Math.min(b, A)), w = Math.max(0, Math.min(y, B));
11899
+ r(_, w);
11869
11900
  }, h = () => {
11870
11901
  d(!1);
11871
11902
  };
@@ -11963,36 +11994,39 @@ const RootLayout = () => {
11963
11994
  const i = first(o);
11964
11995
  isString(i) && (a = [i, ...getParentNodeIds(n, i)]), r(a);
11965
11996
  }, [o, n, r]);
11966
- }, ScreenTooSmall = () => /* @__PURE__ */ jsx("section", { className: "fixed inset-0 z-50 flex h-screen w-screen items-center justify-center bg-white bg-[linear-gradient(to_right,#f3f4f6_1px,transparent_1px),linear-gradient(to_bottom,#f3f4f6_1px,transparent_1px)] bg-[size:10px_10px] py-12 sm:py-16 lg:py-20 xl:hidden", children: /* @__PURE__ */ jsx("div", { className: "mx-auto max-w-7xl px-4 sm:px-6 lg:px-8", children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-md space-y-6 text-center", children: [
11967
- /* @__PURE__ */ jsx(
11968
- "img",
11969
- {
11970
- src: "https://ucarecdn.com/fbfc3b05-cb73-4e99-92a2-3a367b7c36cd/",
11971
- alt: "Chai Builder",
11972
- className: "mx-auto h-20 w-20 rounded-full shadow-lg transition-transform duration-300 hover:scale-105"
11973
- }
11974
- ),
11975
- /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
11976
- /* @__PURE__ */ jsx("h2", { className: "text-5xl font-bold tracking-tight text-gray-900", children: "Screen too small" }),
11977
- /* @__PURE__ */ jsxs("p", { className: "mx-auto max-w-sm text-sm leading-7 text-gray-600", children: [
11978
- "Please view this page on greater than ",
11979
- /* @__PURE__ */ jsx("strong", { className: "font-medium", children: "1280px" }),
11980
- " screen width for the best experience."
11981
- ] })
11982
- ] }),
11983
- /* @__PURE__ */ jsx("div", { className: "pt-4", children: /* @__PURE__ */ jsxs("div", { className: "inline-flex items-center rounded-full bg-gray-100 px-4 py-2 text-sm text-gray-700", children: [
11984
- /* @__PURE__ */ jsx("svg", { className: "mr-2 h-5 w-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx(
11985
- "path",
11997
+ }, ScreenTooSmall = () => {
11998
+ const o = useBuilderProp("smallScreenComponent", null);
11999
+ return /* @__PURE__ */ jsx("section", { className: "fixed inset-0 z-[99999] flex h-screen w-screen items-center justify-center bg-white xl:hidden", children: o ? React__default.createElement(o) : /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center justify-center bg-[linear-gradient(to_right,#f3f4f6_1px,transparent_1px),linear-gradient(to_bottom,#f3f4f6_1px,transparent_1px)] bg-[size:10px_10px] py-12 sm:py-16 lg:py-20", children: /* @__PURE__ */ jsx("div", { className: "mx-auto max-w-7xl px-4 sm:px-6 lg:px-8", children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-md space-y-6 text-center", children: [
12000
+ /* @__PURE__ */ jsx(
12001
+ "img",
11986
12002
  {
11987
- strokeLinecap: "round",
11988
- strokeLinejoin: "round",
11989
- strokeWidth: "2",
11990
- d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
12003
+ src: "https://ucarecdn.com/fbfc3b05-cb73-4e99-92a2-3a367b7c36cd/",
12004
+ alt: "Chai Builder",
12005
+ className: "mx-auto h-20 w-20 rounded-full shadow-lg transition-transform duration-300 hover:scale-105"
11991
12006
  }
11992
- ) }),
11993
- "Minimum width: 1280px"
11994
- ] }) })
11995
- ] }) }) });
12007
+ ),
12008
+ /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
12009
+ /* @__PURE__ */ jsx("h2", { className: "text-5xl font-bold tracking-tight text-gray-900", children: "Screen too small" }),
12010
+ /* @__PURE__ */ jsxs("p", { className: "mx-auto max-w-sm text-sm leading-7 text-gray-600", children: [
12011
+ "Please view this page on greater than ",
12012
+ /* @__PURE__ */ jsx("strong", { className: "font-medium", children: "1280px" }),
12013
+ " screen width for the best experience."
12014
+ ] })
12015
+ ] }),
12016
+ /* @__PURE__ */ jsx("div", { className: "pt-4", children: /* @__PURE__ */ jsxs("div", { className: "inline-flex items-center rounded-full bg-gray-100 px-4 py-2 text-sm text-gray-700", children: [
12017
+ /* @__PURE__ */ jsx("svg", { className: "mr-2 h-5 w-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx(
12018
+ "path",
12019
+ {
12020
+ strokeLinecap: "round",
12021
+ strokeLinejoin: "round",
12022
+ strokeWidth: "2",
12023
+ d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
12024
+ }
12025
+ ) }),
12026
+ "Minimum width: 1280px"
12027
+ ] }) })
12028
+ ] }) }) }) });
12029
+ };
11996
12030
  function isSelfAtom(o, n) {
11997
12031
  return o.unstable_is ? o.unstable_is(n) : n === o;
11998
12032
  }
@@ -12060,41 +12094,41 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
12060
12094
  let l = a.get(n);
12061
12095
  return l || (l = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, a.set(n, l), i == null || i(o, n)), l;
12062
12096
  }, flushCallbacks = (o) => {
12063
- const n = getBuildingBlocks(o), r = n[1], a = n[3], i = n[4], l = n[5], c = n[6], d = n[13], p = [], u = (g) => {
12097
+ const n = getBuildingBlocks(o), r = n[1], a = n[3], i = n[4], l = n[5], c = n[6], d = n[13], u = [], p = (g) => {
12064
12098
  try {
12065
12099
  g();
12066
12100
  } catch (m) {
12067
- p.push(m);
12101
+ u.push(m);
12068
12102
  }
12069
12103
  };
12070
12104
  do {
12071
- c.f && u(c.f);
12105
+ c.f && p(c.f);
12072
12106
  const g = /* @__PURE__ */ new Set(), m = g.add.bind(g);
12073
12107
  a.forEach((f) => {
12074
12108
  var h;
12075
12109
  return (h = r.get(f)) == null ? void 0 : h.l.forEach(m);
12076
- }), a.clear(), l.forEach(m), l.clear(), i.forEach(m), i.clear(), g.forEach(u), a.size && d(o);
12110
+ }), a.clear(), l.forEach(m), l.clear(), i.forEach(m), i.clear(), g.forEach(p), a.size && d(o);
12077
12111
  } while (a.size || l.size || i.size);
12078
- if (p.length)
12079
- throw new AggregateError(p);
12112
+ if (u.length)
12113
+ throw new AggregateError(u);
12080
12114
  }, recomputeInvalidatedAtoms = (o) => {
12081
- const n = getBuildingBlocks(o), r = n[1], a = n[2], i = n[3], l = n[11], c = n[14], d = n[17], p = [], u = /* @__PURE__ */ new WeakSet(), g = /* @__PURE__ */ new WeakSet(), m = Array.from(i);
12115
+ const n = getBuildingBlocks(o), r = n[1], a = n[2], i = n[3], l = n[11], c = n[14], d = n[17], u = [], p = /* @__PURE__ */ new WeakSet(), g = /* @__PURE__ */ new WeakSet(), m = Array.from(i);
12082
12116
  for (; m.length; ) {
12083
12117
  const f = m[m.length - 1], h = l(o, f);
12084
12118
  if (g.has(f)) {
12085
12119
  m.pop();
12086
12120
  continue;
12087
12121
  }
12088
- if (u.has(f)) {
12089
- a.get(f) === h.n && p.push([f, h]), g.add(f), m.pop();
12122
+ if (p.has(f)) {
12123
+ a.get(f) === h.n && u.push([f, h]), g.add(f), m.pop();
12090
12124
  continue;
12091
12125
  }
12092
- u.add(f);
12126
+ p.add(f);
12093
12127
  for (const x of getMountedOrPendingDependents(f, h, r))
12094
- u.has(x) || m.push(x);
12128
+ p.has(x) || m.push(x);
12095
12129
  }
12096
- for (let f = p.length - 1; f >= 0; --f) {
12097
- const [h, x] = p[f];
12130
+ for (let f = u.length - 1; f >= 0; --f) {
12131
+ const [h, x] = u[f];
12098
12132
  let b = !1;
12099
12133
  for (const y of x.d.keys())
12100
12134
  if (y !== h && i.has(y)) {
@@ -12105,7 +12139,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
12105
12139
  }
12106
12140
  }, readAtomState = (o, n) => {
12107
12141
  var r;
12108
- const a = getBuildingBlocks(o), i = a[1], l = a[2], c = a[3], d = a[6], p = a[7], u = a[11], g = a[12], m = a[13], f = a[14], h = a[16], x = a[17], b = u(o, n);
12142
+ const a = getBuildingBlocks(o), i = a[1], l = a[2], c = a[3], d = a[6], u = a[7], p = a[11], g = a[12], m = a[13], f = a[14], h = a[16], x = a[17], b = p(o, n);
12109
12143
  if (isAtomStateInitialized(b) && (i.has(n) && l.get(n) !== b.n || Array.from(b.d).every(
12110
12144
  ([w, j]) => (
12111
12145
  // Recursively, read the atom state of the dependency, and
@@ -12122,13 +12156,13 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
12122
12156
  function k(w) {
12123
12157
  var j;
12124
12158
  if (isSelfAtom(n, w)) {
12125
- const _ = u(o, w);
12126
- if (!isAtomStateInitialized(_))
12159
+ const E = p(o, w);
12160
+ if (!isAtomStateInitialized(E))
12127
12161
  if (hasInitialValue(w))
12128
12162
  setAtomStateValueOrPromise(o, w, w.init);
12129
12163
  else
12130
12164
  throw new Error("no atom init");
12131
- return returnAtomValue(_);
12165
+ return returnAtomValue(E);
12132
12166
  }
12133
12167
  const v = f(o, w);
12134
12168
  try {
@@ -12152,26 +12186,26 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
12152
12186
  }
12153
12187
  }), A;
12154
12188
  }
12155
- }, E = b.n;
12189
+ }, _ = b.n;
12156
12190
  try {
12157
- const w = p(o, n, k, B);
12191
+ const w = u(o, n, k, B);
12158
12192
  return setAtomStateValueOrPromise(o, n, w), isPromiseLike$1(w) && (registerAbortHandler(w, () => S == null ? void 0 : S.abort()), w.then(C, C)), b;
12159
12193
  } catch (w) {
12160
12194
  return delete b.v, b.e = w, ++b.n, b;
12161
12195
  } finally {
12162
- y = !1, E !== b.n && l.get(n) === E && (l.set(n, b.n), c.add(n), (r = d.c) == null || r.call(d, n));
12196
+ y = !1, _ !== b.n && l.get(n) === _ && (l.set(n, b.n), c.add(n), (r = d.c) == null || r.call(d, n));
12163
12197
  }
12164
12198
  }, invalidateDependents = (o, n) => {
12165
12199
  const r = getBuildingBlocks(o), a = r[1], i = r[2], l = r[11], c = [n];
12166
12200
  for (; c.length; ) {
12167
- const d = c.pop(), p = l(o, d);
12168
- for (const u of getMountedOrPendingDependents(d, p, a)) {
12169
- const g = l(o, u);
12170
- i.set(u, g.n), c.push(u);
12201
+ const d = c.pop(), u = l(o, d);
12202
+ for (const p of getMountedOrPendingDependents(d, u, a)) {
12203
+ const g = l(o, p);
12204
+ i.set(p, g.n), c.push(p);
12171
12205
  }
12172
12206
  }
12173
12207
  }, writeAtomState = (o, n, ...r) => {
12174
- const a = getBuildingBlocks(o), i = a[3], l = a[6], c = a[8], d = a[11], p = a[12], u = a[13], g = a[14], m = a[15], f = a[17];
12208
+ const a = getBuildingBlocks(o), i = a[3], l = a[6], c = a[8], d = a[11], u = a[12], p = a[13], g = a[14], m = a[15], f = a[17];
12175
12209
  let h = !0;
12176
12210
  const x = (y) => returnAtomValue(g(o, y)), b = (y, ...C) => {
12177
12211
  var k;
@@ -12186,7 +12220,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
12186
12220
  } else
12187
12221
  return writeAtomState(o, y, ...C);
12188
12222
  } finally {
12189
- h || (u(o), p(o));
12223
+ h || (p(o), u(o));
12190
12224
  }
12191
12225
  };
12192
12226
  try {
@@ -12196,12 +12230,12 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
12196
12230
  }
12197
12231
  }, mountDependencies = (o, n) => {
12198
12232
  var r;
12199
- const a = getBuildingBlocks(o), i = a[1], l = a[3], c = a[6], d = a[11], p = a[15], u = a[18], g = a[19], m = d(o, n), f = i.get(n);
12233
+ const a = getBuildingBlocks(o), i = a[1], l = a[3], c = a[6], d = a[11], u = a[15], p = a[18], g = a[19], m = d(o, n), f = i.get(n);
12200
12234
  if (f && !isPendingPromise(m.v)) {
12201
12235
  for (const [h, x] of m.d)
12202
12236
  if (!f.d.has(h)) {
12203
12237
  const b = d(o, h);
12204
- u(o, h).t.add(n), f.d.add(h), x !== b.n && (l.add(h), (r = c.c) == null || r.call(c, h), p(o, h));
12238
+ p(o, h).t.add(n), f.d.add(h), x !== b.n && (l.add(h), (r = c.c) == null || r.call(c, h), u(o, h));
12205
12239
  }
12206
12240
  for (const h of f.d || [])
12207
12241
  if (!m.d.has(h)) {
@@ -12212,7 +12246,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
12212
12246
  }
12213
12247
  }, mountAtom = (o, n) => {
12214
12248
  var r;
12215
- const a = getBuildingBlocks(o), i = a[1], l = a[4], c = a[6], d = a[10], p = a[11], u = a[12], g = a[13], m = a[14], f = a[16], h = p(o, n);
12249
+ const a = getBuildingBlocks(o), i = a[1], l = a[4], c = a[6], d = a[10], u = a[11], p = a[12], g = a[13], m = a[14], f = a[16], h = u(o, n);
12216
12250
  let x = i.get(n);
12217
12251
  if (!x) {
12218
12252
  m(o, n);
@@ -12229,7 +12263,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
12229
12263
  try {
12230
12264
  return f(o, n, ...k);
12231
12265
  } finally {
12232
- y || (g(o), u(o));
12266
+ y || (g(o), p(o));
12233
12267
  }
12234
12268
  };
12235
12269
  try {
@@ -12252,15 +12286,15 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
12252
12286
  return x;
12253
12287
  }, unmountAtom = (o, n) => {
12254
12288
  var r;
12255
- const a = getBuildingBlocks(o), i = a[1], l = a[5], c = a[6], d = a[11], p = a[19], u = d(o, n);
12289
+ const a = getBuildingBlocks(o), i = a[1], l = a[5], c = a[6], d = a[11], u = a[19], p = d(o, n);
12256
12290
  let g = i.get(n);
12257
12291
  if (g && !g.l.size && !Array.from(g.t).some((m) => {
12258
12292
  var f;
12259
12293
  return (f = i.get(m)) == null ? void 0 : f.d.has(n);
12260
12294
  })) {
12261
12295
  g.u && l.add(g.u), g = void 0, i.delete(n), (r = c.u) == null || r.call(c, n);
12262
- for (const m of u.d.keys()) {
12263
- const f = p(o, m);
12296
+ for (const m of p.d.keys()) {
12297
+ const f = u(o, m);
12264
12298
  f == null || f.t.delete(n);
12265
12299
  }
12266
12300
  return;
@@ -12287,9 +12321,9 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
12287
12321
  l(o), i(o);
12288
12322
  }
12289
12323
  }, storeSub = (o, n, r) => {
12290
- const a = getBuildingBlocks(o), i = a[12], l = a[18], c = a[19], p = l(o, n).l;
12291
- return p.add(r), i(o), () => {
12292
- p.delete(r), c(o, n), i(o);
12324
+ const a = getBuildingBlocks(o), i = a[12], l = a[18], c = a[19], u = l(o, n).l;
12325
+ return u.add(r), i(o), () => {
12326
+ u.delete(r), c(o, n), i(o);
12293
12327
  };
12294
12328
  }, buildingBlockMap = /* @__PURE__ */ new WeakMap();
12295
12329
  function getBuildingBlocks(o) {
@@ -12380,23 +12414,23 @@ const isPromiseLike = (o) => typeof (o == null ? void 0 : o.then) == "function",
12380
12414
  let r = continuablePromiseMap.get(o);
12381
12415
  return r || (r = new Promise((a, i) => {
12382
12416
  let l = o;
12383
- const c = (u) => (g) => {
12384
- l === u && a(g);
12385
- }, d = (u) => (g) => {
12386
- l === u && i(g);
12387
- }, p = () => {
12417
+ const c = (p) => (g) => {
12418
+ l === p && a(g);
12419
+ }, d = (p) => (g) => {
12420
+ l === p && i(g);
12421
+ }, u = () => {
12388
12422
  try {
12389
- const u = n();
12390
- isPromiseLike(u) ? (continuablePromiseMap.set(u, r), l = u, u.then(c(u), d(u)), registerAbortHandler(u, p)) : a(u);
12391
- } catch (u) {
12392
- i(u);
12423
+ const p = n();
12424
+ isPromiseLike(p) ? (continuablePromiseMap.set(p, r), l = p, p.then(c(p), d(p)), registerAbortHandler(p, u)) : a(p);
12425
+ } catch (p) {
12426
+ i(p);
12393
12427
  }
12394
12428
  };
12395
- o.then(c(o), d(o)), registerAbortHandler(o, p);
12429
+ o.then(c(o), d(o)), registerAbortHandler(o, u);
12396
12430
  }), continuablePromiseMap.set(o, r)), r;
12397
12431
  };
12398
12432
  function useAtomValue(o, n) {
12399
- const { delay: r, unstable_promiseStatus: a = !React__default.use } = {}, i = useStore(), [[l, c, d], p] = useReducer(
12433
+ const { delay: r, unstable_promiseStatus: a = !React__default.use } = {}, i = useStore(), [[l, c, d], u] = useReducer(
12400
12434
  (g) => {
12401
12435
  const m = i.get(o);
12402
12436
  return Object.is(g[0], m) && g[1] === i && g[2] === o ? g : [m, i, o];
@@ -12404,8 +12438,8 @@ function useAtomValue(o, n) {
12404
12438
  void 0,
12405
12439
  () => [i.get(o), i, o]
12406
12440
  );
12407
- let u = l;
12408
- if ((c !== i || d !== o) && (p(), u = i.get(o)), useEffect(() => {
12441
+ let p = l;
12442
+ if ((c !== i || d !== o) && (u(), p = i.get(o)), useEffect(() => {
12409
12443
  const g = i.sub(o, () => {
12410
12444
  if (a)
12411
12445
  try {
@@ -12416,17 +12450,17 @@ function useAtomValue(o, n) {
12416
12450
  } catch {
12417
12451
  }
12418
12452
  if (typeof r == "number") {
12419
- setTimeout(p, r);
12453
+ setTimeout(u, r);
12420
12454
  return;
12421
12455
  }
12422
- p();
12456
+ u();
12423
12457
  });
12424
- return p(), g;
12425
- }, [i, o, r, a]), useDebugValue(u), isPromiseLike(u)) {
12426
- const g = createContinuablePromise(u, () => i.get(o));
12458
+ return u(), g;
12459
+ }, [i, o, r, a]), useDebugValue(p), isPromiseLike(p)) {
12460
+ const g = createContinuablePromise(p, () => i.get(o));
12427
12461
  return a && attachPromiseStatus(g), use(g);
12428
12462
  }
12429
- return u;
12463
+ return p;
12430
12464
  }
12431
12465
  function useSetAtom(o, n) {
12432
12466
  const r = useStore();
@@ -12546,7 +12580,7 @@ function convertAttributeName(o) {
12546
12580
  return r[o] ? r[o] : o;
12547
12581
  }
12548
12582
  function domToJsx(o, n = 0) {
12549
- var u;
12583
+ var p;
12550
12584
  if (Array.isArray(o)) {
12551
12585
  if (o.length === 0) return "";
12552
12586
  if (o.length === 1) return domToJsx(o[0], n);
@@ -12560,7 +12594,7 @@ function domToJsx(o, n = 0) {
12560
12594
  }
12561
12595
  const r = " ".repeat(n);
12562
12596
  if (o.nodeType === Node.TEXT_NODE) {
12563
- const g = (u = o.textContent) == null ? void 0 : u.trim();
12597
+ const g = (p = o.textContent) == null ? void 0 : p.trim();
12564
12598
  return g ? `${r}${g}
12565
12599
  ` : "";
12566
12600
  }
@@ -12679,7 +12713,7 @@ const getExportedCoded = async ({
12679
12713
  isTypeScript: r = !1
12680
12714
  }) => {
12681
12715
  let a = (o == null ? void 0 : o._name) || (o == null ? void 0 : o._type) || "Component";
12682
- a = camelCase(a).replace(/^./, (u) => u.toUpperCase());
12716
+ a = camelCase(a).replace(/^./, (p) => p.toUpperCase());
12683
12717
  const i = " ";
12684
12718
  let { jsx: l, html: c } = await convertHtmlToJsx(n);
12685
12719
  return l = l == null ? void 0 : l.split(`
@@ -12693,7 +12727,7 @@ ${i})
12693
12727
  }`, { jsx: l, html: formatHtml(c), componentName: a };
12694
12728
  }, ExportCodeModalContent = ({ tab: o }) => {
12695
12729
  var C;
12696
- const { t: n } = useTranslation(), [r, a] = useState({ html: "", jsx: "" }), i = useSelectedBlock(), l = useBlocksHtmlForAi(), [c, d] = useState(""), [p, u] = useState(!1), g = () => {
12730
+ const { t: n } = useTranslation(), [r, a] = useState({ html: "", jsx: "" }), i = useSelectedBlock(), l = useBlocksHtmlForAi(), [c, d] = useState(""), [u, p] = useState(!1), g = () => {
12697
12731
  switch (o) {
12698
12732
  case "js":
12699
12733
  return `${c}.jsx`;
@@ -12716,19 +12750,19 @@ ${i})
12716
12750
  }
12717
12751
  }, f = useCallback(async () => {
12718
12752
  try {
12719
- u(!1);
12753
+ p(!1);
12720
12754
  let k = l({ blockId: i == null ? void 0 : i._id, additionalCoreBlocks: ["Icon"] });
12721
12755
  k = k.replace(/\s*bid=["'][^"']*["']/g, "");
12722
12756
  const S = o === "ts", {
12723
12757
  jsx: A,
12724
12758
  html: B,
12725
- componentName: E
12759
+ componentName: _
12726
12760
  } = await getExportedCoded({
12727
12761
  selectedBlock: i,
12728
12762
  html: k,
12729
12763
  isTypeScript: S
12730
12764
  });
12731
- a({ html: B, jsx: A }), d(E), u(!0);
12765
+ a({ html: B, jsx: A }), d(_), p(!0);
12732
12766
  } catch {
12733
12767
  const S = "<div>Export failed. Close the modal and try again.</div>";
12734
12768
  a({ html: S, jsx: S }), toast.error(n("Failed to generate export HTML"));
@@ -12762,7 +12796,7 @@ ${i})
12762
12796
  `)},
12763
12797
  }`;
12764
12798
  }, []);
12765
- return ((C = r == null ? void 0 : r.jsx) == null ? void 0 : C.length) > 0 && p ? /* @__PURE__ */ jsx(
12799
+ return ((C = r == null ? void 0 : r.jsx) == null ? void 0 : C.length) > 0 && u ? /* @__PURE__ */ jsx(
12766
12800
  CodeDisplay,
12767
12801
  {
12768
12802
  onCopy: h,
@@ -12778,7 +12812,7 @@ ${i})
12778
12812
  l("js"), a("view"), r(!0);
12779
12813
  }, [n]);
12780
12814
  return usePubSub(CHAI_BUILDER_EVENTS.OPEN_EXPORT_CODE, c), /* @__PURE__ */ jsx(Dialog, { open: n, onOpenChange: async () => {
12781
- a("edit"), await new Promise((p) => setTimeout(p, 300)), r(!1);
12815
+ a("edit"), await new Promise((u) => setTimeout(u, 300)), r(!1);
12782
12816
  }, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-5xl overflow-hidden border-border", children: [
12783
12817
  /* @__PURE__ */ jsxs(DialogHeader, { className: "flex flex-row items-center justify-between", children: [
12784
12818
  /* @__PURE__ */ jsx(DialogTitle, { className: "text-foreground", children: o("Export Code") }),
@@ -12822,8 +12856,8 @@ ${i})
12822
12856
  }, [o.locale]), useEffect(() => {
12823
12857
  setDebugLogs(o.debugLogs);
12824
12858
  }, [o.debugLogs]), useEffect(() => {
12825
- o.translations && each(o.translations, (d, p) => {
12826
- i18n.addResourceBundle(p, "translation", d, !0, !0);
12859
+ o.translations && each(o.translations, (d, u) => {
12860
+ i18n.addResourceBundle(u, "translation", d, !0, !0);
12827
12861
  });
12828
12862
  }, [o.translations]), useEffect(() => (a !== "SAVED" ? window.onbeforeunload = () => "" : window.onbeforeunload = null, () => {
12829
12863
  window.onbeforeunload = null;