@chaibuilder/sdk 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,19 +1,19 @@
1
1
  var G = Object.defineProperty;
2
2
  var K = (o, n, r) => n in o ? G(o, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[n] = r;
3
3
  var V = (o, n, r) => K(o, typeof n != "symbol" ? n + "" : n, r);
4
- import { jsx, Fragment, jsxs } from "react/jsx-runtime";
4
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import * as React from "react";
6
6
  import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, useMemo, Component, Children, useState, useRef, Suspense, createElement, memo, lazy } from "react";
7
- import { S as Skeleton, B as Button, a6 as Label, H as Dialog, I as DialogTrigger, J as DialogContent, a7 as Popover, ak as Tooltip, al as TooltipTrigger, a8 as PopoverTrigger, am as TooltipContent, a9 as PopoverContent, v as Command, x as CommandInput, y as CommandList, z as CommandEmpty, D as CommandGroup, E as CommandItem, K as DialogHeader, M as DialogTitle, n as Badge, O as DropdownMenu, P as DropdownMenuTrigger, Q as DropdownMenuContent, V as DropdownMenuLabel, W as DropdownMenuSeparator, T as DropdownMenuCheckboxItem, a2 as HoverCard, a3 as HoverCardTrigger, a4 as HoverCardContent, aj as Textarea, a5 as Input$1, ao as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, aa as ScrollArea, Y as DropdownMenuGroup, R as DropdownMenuItem, X as DropdownMenuShortcut, A as Accordion, C as Card, q as CardHeader, t as CardDescription, u as CardContent, r as CardFooter, af as Tabs, ag as TabsList, ah as TabsTrigger, ai as TabsContent, e as AlertDialog, f as AlertDialogTrigger, g as AlertDialogContent, h as AlertDialogHeader, j as AlertDialogTitle, k as AlertDialogDescription, i as AlertDialogFooter, m as AlertDialogCancel, l as AlertDialogAction, ae as Switch, ac as Separator, an as TooltipProvider, ad as Toaster } from "./tooltip-PKiP886L.js";
7
+ import { O as DropdownMenu, P as DropdownMenuTrigger, Q as DropdownMenuContent, R as DropdownMenuItem, S as Skeleton, B as Button, a6 as Label, H as Dialog, I as DialogTrigger, J as DialogContent, a7 as Popover, ak as Tooltip, al as TooltipTrigger, a8 as PopoverTrigger, am as TooltipContent, a9 as PopoverContent, v as Command, x as CommandInput, y as CommandList, z as CommandEmpty, D as CommandGroup, E as CommandItem, K as DialogHeader, M as DialogTitle, n as Badge, V as DropdownMenuLabel, W as DropdownMenuSeparator, T as DropdownMenuCheckboxItem, a2 as HoverCard, a3 as HoverCardTrigger, a4 as HoverCardContent, aj as Textarea, a5 as Input$1, ao as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, aa as ScrollArea, Y as DropdownMenuGroup, X as DropdownMenuShortcut, A as Accordion, C as Card, q as CardHeader, t as CardDescription, u as CardContent, r as CardFooter, af as Tabs, ag as TabsList, ah as TabsTrigger, ai as TabsContent, e as AlertDialog, f as AlertDialogTrigger, g as AlertDialogContent, h as AlertDialogHeader, j as AlertDialogTitle, k as AlertDialogDescription, i as AlertDialogFooter, m as AlertDialogCancel, l as AlertDialogAction, ae as Switch, ac as Separator, an as TooltipProvider, ad as Toaster } from "./tooltip-PKiP886L.js";
8
8
  import { atom as atom$1, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
9
- import { find, filter, flatten, map, omit, isString, has, isObject, memoize, get, compact, isEmpty, noop, includes, without, each, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split, findIndex, take, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
9
+ import { find, filter, flatten, map, omit, isString, has, isObject, memoize, get, compact, isEmpty, noop, includes, without, each, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, findIndex, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split, take, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
10
10
  import { Provider as Provider$1 } from "react-wrap-balancer";
11
11
  import { useTranslation, initReactI18next } from "react-i18next";
12
12
  import { useTranslation as He } from "react-i18next";
13
13
  import { g as generateUUID, a as getBreakpointValue, c as cn$1 } from "./Functions-BGzDsf1z.js";
14
14
  import { flip } from "@floating-ui/dom";
15
15
  import { useFloating, shift } from "@floating-ui/react-dom";
16
- import { ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxModelIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, Cross2Icon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon, InfoCircledIcon, BoxIcon, MinusIcon, TriangleDownIcon, RowSpacingIcon, CrossCircledIcon, CaretDownIcon, CaretRightIcon, CardStackIcon, CardStackPlusIcon, ScissorsIcon, CheckIcon, SunIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
16
+ import { PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxModelIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, Cross2Icon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon, InfoCircledIcon, BoxIcon, MinusIcon, TriangleDownIcon, RowSpacingIcon, CrossCircledIcon, CaretDownIcon, CaretRightIcon, CardStackIcon, CardStackPlusIcon, ScissorsIcon, CheckIcon, SunIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
17
17
  import { useThrottledCallback, useDebouncedCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
18
18
  import { useFeature, FlagsProvider } from "flagged";
19
19
  import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredChaiBlocks, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
@@ -93,17 +93,17 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
93
93
  for (const i of n.p)
94
94
  l.add(i);
95
95
  return l;
96
- }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...h) => m.read(...h), p = (m, ...h) => m.write(...h), u = (m, h) => {
96
+ }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...f) => m.read(...f), p = (m, ...f) => m.write(...f), u = (m, f) => {
97
97
  var x;
98
- return (x = m.unstable_onInit) == null ? void 0 : x.call(m, h);
99
- }, g = (m, h) => {
98
+ return (x = m.unstable_onInit) == null ? void 0 : x.call(m, f);
99
+ }, g = (m, f) => {
100
100
  var x;
101
- return (x = m.onMount) == null ? void 0 : x.call(m, h);
102
- }, ...f) => {
103
- const m = f[0] || ((C) => {
101
+ return (x = m.onMount) == null ? void 0 : x.call(m, f);
102
+ }, ...h) => {
103
+ const m = h[0] || ((C) => {
104
104
  let L = o.get(C);
105
105
  return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(C, L), u == null || u(C, S)), L;
106
- }), h = f[1] || (() => {
106
+ }), f = h[1] || (() => {
107
107
  let C, L;
108
108
  const v = (k) => {
109
109
  try {
@@ -122,7 +122,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
122
122
  } while (a.size || i.size || l.size);
123
123
  if (C)
124
124
  throw L;
125
- }), x = f[2] || (() => {
125
+ }), x = h[2] || (() => {
126
126
  const C = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
127
127
  for (; k.length; ) {
128
128
  const B = k[k.length - 1], T = m(B);
@@ -146,23 +146,23 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
146
146
  P = !0;
147
147
  break;
148
148
  }
149
- P && (y(T), E(T)), r.delete(T);
149
+ P && (b(T), E(T)), r.delete(T);
150
150
  }
151
- }), y = f[3] || ((C) => {
151
+ }), b = h[3] || ((C) => {
152
152
  var L, v;
153
153
  const k = m(C);
154
154
  if (isAtomStateInitialized(k) && (n.has(C) && r.get(C) !== k.n || Array.from(k.d).every(
155
155
  ([R, O]) => (
156
156
  // Recursively, read the atom state of the dependency, and
157
157
  // check if the atom epoch number is unchanged
158
- y(R).n === O
158
+ b(R).n === O
159
159
  )
160
160
  )))
161
161
  return k;
162
162
  k.d.clear();
163
163
  let B = !0;
164
164
  const T = () => {
165
- n.has(C) && (E(C), x(), h());
165
+ n.has(C) && (E(C), x(), f());
166
166
  }, I = (R) => {
167
167
  var O;
168
168
  if (isSelfAtom(C, R)) {
@@ -174,11 +174,11 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
174
174
  throw new Error("no atom init");
175
175
  return returnAtomValue(H);
176
176
  }
177
- const M = y(R);
177
+ const $ = b(R);
178
178
  try {
179
- return returnAtomValue(M);
179
+ return returnAtomValue($);
180
180
  } finally {
181
- k.d.set(R, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(C, k.v, M), (O = n.get(R)) == null || O.t.add(C), B || T();
181
+ k.d.set(R, $.n), isPendingPromise(k.v) && addPendingPromiseToDependency(C, k.v, $), (O = n.get(R)) == null || O.t.add(C), B || T();
182
182
  }
183
183
  };
184
184
  let P, N;
@@ -192,11 +192,11 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
192
192
  try {
193
193
  return A(C, ...R);
194
194
  } finally {
195
- x(), h();
195
+ x(), f();
196
196
  }
197
197
  }), N;
198
198
  }
199
- }, $ = k.n;
199
+ }, M = k.n;
200
200
  try {
201
201
  const R = d(C, I, D);
202
202
  return setAtomStateValueOrPromise(C, R, m), isPromiseLike$2(R) && ((L = R.onCancel) == null || L.call(R, () => P == null ? void 0 : P.abort()), R.then(
@@ -206,9 +206,9 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
206
206
  } catch (R) {
207
207
  return delete k.v, k.e = R, ++k.n, k;
208
208
  } finally {
209
- B = !1, $ !== k.n && r.get(C) === $ && (r.set(C, k.n), a.add(C), (v = c.c) == null || v.call(c, C));
209
+ B = !1, M !== k.n && r.get(C) === M && (r.set(C, k.n), a.add(C), (v = c.c) == null || v.call(c, C));
210
210
  }
211
- }), b = f[4] || ((C) => {
211
+ }), y = h[4] || ((C) => {
212
212
  const L = [C];
213
213
  for (; L.length; ) {
214
214
  const v = L.pop(), k = m(v);
@@ -217,22 +217,22 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
217
217
  r.set(B, T.n), L.push(B);
218
218
  }
219
219
  }
220
- }), A = f[5] || ((C, ...L) => {
220
+ }), A = h[5] || ((C, ...L) => {
221
221
  let v = !0;
222
- const k = (T) => returnAtomValue(y(T)), B = (T, ...I) => {
222
+ const k = (T) => returnAtomValue(b(T)), B = (T, ...I) => {
223
223
  var P;
224
224
  const N = m(T);
225
225
  try {
226
226
  if (isSelfAtom(C, T)) {
227
227
  if (!hasInitialValue(T))
228
228
  throw new Error("atom not writable");
229
- const D = N.n, $ = I[0];
230
- setAtomStateValueOrPromise(T, $, m), E(T), D !== N.n && (a.add(T), (P = c.c) == null || P.call(c, T), b(T));
229
+ const D = N.n, M = I[0];
230
+ setAtomStateValueOrPromise(T, M, m), E(T), D !== N.n && (a.add(T), (P = c.c) == null || P.call(c, T), y(T));
231
231
  return;
232
232
  } else
233
233
  return A(T, ...I);
234
234
  } finally {
235
- v || (x(), h());
235
+ v || (x(), f());
236
236
  }
237
237
  };
238
238
  try {
@@ -240,14 +240,14 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
240
240
  } finally {
241
241
  v = !1;
242
242
  }
243
- }), E = f[6] || ((C) => {
243
+ }), E = h[6] || ((C) => {
244
244
  var L;
245
245
  const v = m(C), k = n.get(C);
246
246
  if (k && !isPendingPromise(v.v)) {
247
247
  for (const [B, T] of v.d)
248
248
  if (!k.d.has(B)) {
249
249
  const I = m(B);
250
- w(B).t.add(C), k.d.add(B), T !== I.n && (a.add(B), (L = c.c) == null || L.call(c, B), b(B));
250
+ w(B).t.add(C), k.d.add(B), T !== I.n && (a.add(B), (L = c.c) == null || L.call(c, B), y(B));
251
251
  }
252
252
  for (const B of k.d || [])
253
253
  if (!v.d.has(B)) {
@@ -256,12 +256,12 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
256
256
  T == null || T.t.delete(C);
257
257
  }
258
258
  }
259
- }), w = f[7] || ((C) => {
259
+ }), w = h[7] || ((C) => {
260
260
  var L;
261
261
  const v = m(C);
262
262
  let k = n.get(C);
263
263
  if (!k) {
264
- y(C);
264
+ b(C);
265
265
  for (const B of v.d.keys())
266
266
  w(B).t.add(C);
267
267
  if (k = {
@@ -275,7 +275,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
275
275
  try {
276
276
  return A(C, ...P);
277
277
  } finally {
278
- T || (x(), h());
278
+ T || (x(), f());
279
279
  }
280
280
  };
281
281
  try {
@@ -296,7 +296,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
296
296
  }
297
297
  }
298
298
  return k;
299
- }), _ = f[8] || ((C) => {
299
+ }), _ = h[8] || ((C) => {
300
300
  var L;
301
301
  const v = m(C);
302
302
  let k = n.get(C);
@@ -328,27 +328,27 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
328
328
  g,
329
329
  // building-block functions
330
330
  m,
331
- h,
331
+ f,
332
332
  x,
333
- y,
334
333
  b,
334
+ y,
335
335
  A,
336
336
  E,
337
337
  w,
338
338
  _
339
339
  ], S = {
340
- get: (C) => returnAtomValue(y(C)),
340
+ get: (C) => returnAtomValue(b(C)),
341
341
  set: (C, ...L) => {
342
342
  try {
343
343
  return A(C, ...L);
344
344
  } finally {
345
- x(), h();
345
+ x(), f();
346
346
  }
347
347
  },
348
348
  sub: (C, L) => {
349
349
  const k = w(C).l;
350
- return k.add(L), h(), () => {
351
- k.delete(L), _(C), h();
350
+ return k.add(L), f(), () => {
351
+ k.delete(L), _(C), f();
352
352
  };
353
353
  }
354
354
  };
@@ -387,16 +387,16 @@ function splitAtom(o, n) {
387
387
  let p = r.get(c);
388
388
  if (p)
389
389
  return p;
390
- const u = d && r.get(d), g = [], f = [];
391
- return c.forEach((m, h) => {
392
- const x = h;
393
- f[h] = x;
394
- const y = u && u.atomList[u.keyList.indexOf(x)];
395
- if (y) {
396
- g[h] = y;
390
+ const u = d && r.get(d), g = [], h = [];
391
+ return c.forEach((m, f) => {
392
+ const x = f;
393
+ h[f] = x;
394
+ const b = u && u.atomList[u.keyList.indexOf(x)];
395
+ if (b) {
396
+ g[f] = b;
397
397
  return;
398
398
  }
399
- const b = (E) => {
399
+ const y = (E) => {
400
400
  const w = E(l), _ = E(o), S = a(_, w == null ? void 0 : w.arr).keyList.indexOf(x);
401
401
  if (S < 0 || S >= _.length) {
402
402
  const C = c[a(c).keyList.indexOf(x)];
@@ -416,8 +416,8 @@ function splitAtom(o, n) {
416
416
  ...S.slice(L + 1)
417
417
  ]);
418
418
  };
419
- g[h] = isWritable(o) ? atom(b, A) : atom(b);
420
- }), u && u.keyList.length === f.length && u.keyList.every((m, h) => m === f[h]) ? p = u : p = { arr: c, atomList: g, keyList: f }, r.set(c, p), p;
419
+ g[f] = isWritable(o) ? atom(y, A) : atom(y);
420
+ }), u && u.keyList.length === h.length && u.keyList.every((m, f) => m === h[f]) ? p = u : p = { arr: c, atomList: g, keyList: h }, r.set(c, p), p;
421
421
  }, l = atom((c) => {
422
422
  const d = c(l), p = c(o);
423
423
  return a(p, d == null ? void 0 : d.arr);
@@ -453,17 +453,17 @@ function splitAtom(o, n) {
453
453
  case "move": {
454
454
  const u = c(i).indexOf(p.atom), g = p.before ? c(i).indexOf(p.before) : c(i).length;
455
455
  if (u >= 0 && g >= 0) {
456
- const f = c(o);
456
+ const h = c(o);
457
457
  u < g ? d(o, [
458
- ...f.slice(0, u),
459
- ...f.slice(u + 1, g),
460
- f[u],
461
- ...f.slice(g)
458
+ ...h.slice(0, u),
459
+ ...h.slice(u + 1, g),
460
+ h[u],
461
+ ...h.slice(g)
462
462
  ]) : d(o, [
463
- ...f.slice(0, g),
464
- f[u],
465
- ...f.slice(g, u),
466
- ...f.slice(u + 1)
463
+ ...h.slice(0, g),
464
+ h[u],
465
+ ...h.slice(g, u),
466
+ ...h.slice(u + 1)
467
467
  ]);
468
468
  }
469
469
  break;
@@ -489,7 +489,7 @@ function createJSONStorage(o = () => {
489
489
  let a, l;
490
490
  const i = {
491
491
  getItem: (p, u) => {
492
- var g, f;
492
+ var g, h;
493
493
  const m = (x) => {
494
494
  if (x = x || "", a !== x) {
495
495
  try {
@@ -500,8 +500,8 @@ function createJSONStorage(o = () => {
500
500
  a = x;
501
501
  }
502
502
  return l;
503
- }, h = (f = (g = o()) == null ? void 0 : g.getItem(p)) != null ? f : null;
504
- return isPromiseLike$1(h) ? h.then(m) : m(h);
503
+ }, f = (h = (g = o()) == null ? void 0 : g.getItem(p)) != null ? h : null;
504
+ return isPromiseLike$1(f) ? f.then(m) : m(f);
505
505
  },
506
506
  setItem: (p, u) => {
507
507
  var g;
@@ -514,14 +514,14 @@ function createJSONStorage(o = () => {
514
514
  var u;
515
515
  return (u = o()) == null ? void 0 : u.removeItem(p);
516
516
  }
517
- }, c = (p) => (u, g, f) => p(u, (m) => {
518
- let h;
517
+ }, c = (p) => (u, g, h) => p(u, (m) => {
518
+ let f;
519
519
  try {
520
- h = JSON.parse(m || "");
520
+ f = JSON.parse(m || "");
521
521
  } catch {
522
- h = f;
522
+ f = h;
523
523
  }
524
- g(h);
524
+ g(f);
525
525
  });
526
526
  let d;
527
527
  try {
@@ -532,8 +532,8 @@ function createJSONStorage(o = () => {
532
532
  if (!(o() instanceof window.Storage))
533
533
  return () => {
534
534
  };
535
- const g = (f) => {
536
- f.storageArea === o() && f.key === p && u(f.newValue);
535
+ const g = (h) => {
536
+ h.storageArea === o() && h.key === p && u(h.newValue);
537
537
  };
538
538
  return window.addEventListener("storage", g), () => {
539
539
  window.removeEventListener("storage", g);
@@ -1147,22 +1147,22 @@ const useSelectedBlocksDisplayChild = () => ({
1147
1147
  }, removeNestedBlocks = (o, n) => {
1148
1148
  let r = [...o], a = [];
1149
1149
  n.forEach((d) => {
1150
- const p = r.find((f) => f._id === d);
1150
+ const p = r.find((h) => h._id === d);
1151
1151
  if (!p || !p._parent) return;
1152
- const u = p._parent, g = r.filter((f) => f._parent === u);
1152
+ const u = p._parent, g = r.filter((h) => h._parent === u);
1153
1153
  if (g.length === 2) {
1154
- const f = g.find((m) => m._id !== d);
1155
- if (f && f._type === "Text") {
1156
- const m = r.find((h) => h._id === u);
1157
- m && "content" in m && (r = r.map((h) => {
1158
- if (h._id === u) {
1159
- const x = { ...h, content: f.content };
1160
- return Object.keys(f).forEach((y) => {
1161
- y.startsWith("content-") && (x[y] = f[y]);
1154
+ const h = g.find((m) => m._id !== d);
1155
+ if (h && h._type === "Text") {
1156
+ const m = r.find((f) => f._id === u);
1157
+ m && "content" in m && (r = r.map((f) => {
1158
+ if (f._id === u) {
1159
+ const x = { ...f, content: h.content };
1160
+ return Object.keys(h).forEach((b) => {
1161
+ b.startsWith("content-") && (x[b] = h[b]);
1162
1162
  }), x;
1163
1163
  }
1164
- return h;
1165
- }), a.push(f._id));
1164
+ return f;
1165
+ }), a.push(h._id));
1166
1166
  }
1167
1167
  }
1168
1168
  });
@@ -1225,23 +1225,23 @@ function insertBlocksAtPosition(o, n, r, a) {
1225
1225
  let i = [...o];
1226
1226
  if (r) {
1227
1227
  const u = o.find((g) => g._id === r);
1228
- if (u && u.content !== void 0 && u.content !== "" && !o.some((f) => f._parent === r)) {
1228
+ if (u && u.content !== void 0 && u.content !== "" && !o.some((h) => h._parent === r)) {
1229
1229
  const m = {
1230
1230
  _id: generateUUID(),
1231
1231
  _parent: r,
1232
1232
  _type: "Text",
1233
1233
  content: u.content
1234
1234
  };
1235
- Object.keys(u).forEach((h) => {
1236
- h.startsWith("content-") && (m[h] = u[h]);
1237
- }), l.unshift(m), i = i.map((h) => {
1238
- if (h._id === r) {
1239
- const x = { ...h, content: "" };
1240
- return Object.keys(x).forEach((y) => {
1241
- y.startsWith("content-") && (x[y] = "");
1235
+ Object.keys(u).forEach((f) => {
1236
+ f.startsWith("content-") && (m[f] = u[f]);
1237
+ }), l.unshift(m), i = i.map((f) => {
1238
+ if (f._id === r) {
1239
+ const x = { ...f, content: "" };
1240
+ return Object.keys(x).forEach((b) => {
1241
+ b.startsWith("content-") && (x[b] = "");
1242
1242
  }), x;
1243
1243
  }
1244
- return h;
1244
+ return f;
1245
1245
  });
1246
1246
  }
1247
1247
  }
@@ -1250,7 +1250,7 @@ function insertBlocksAtPosition(o, n, r, a) {
1250
1250
  const d = !isNaN(a) || a > -1 ? Math.min(a, c.length) : c.length;
1251
1251
  let p = i.length;
1252
1252
  for (let u = 0, g = 0; u < i.length; u++)
1253
- if (i[u]._parent === r) {
1253
+ if (r !== void 0 ? i[u]._parent === r : !i[u]._parent) {
1254
1254
  if (g === d) {
1255
1255
  p = u;
1256
1256
  break;
@@ -1270,17 +1270,19 @@ function findNodeById(o, n) {
1270
1270
  return o.first((r) => r.model._id === n) || null;
1271
1271
  }
1272
1272
  function moveNode(o, n, r, a) {
1273
+ var u, g;
1273
1274
  const l = findNodeById(o, n), i = findNodeById(o, r);
1274
- if (l && i) {
1275
- l.drop(), i.children || (i.model.children = []);
1276
- try {
1277
- i.addChildAtIndex(l, a);
1278
- } catch (c) {
1279
- return console.error("Error adding child to parent:", c), !1;
1280
- }
1281
- return !0;
1275
+ if (!l || !i) return !1;
1276
+ i.children || (i.model.children = []);
1277
+ let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((h) => h.model._id === n);
1278
+ l.drop(), c = Math.max(c, 0);
1279
+ const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === r && c <= a ? a - 1 : a;
1280
+ try {
1281
+ i.addChildAtIndex(l, p);
1282
+ } catch (h) {
1283
+ return console.error("Error adding child to parent:", h), !1;
1282
1284
  }
1283
- return !1;
1285
+ return !0;
1284
1286
  }
1285
1287
  function handleOldParentTextBlock(o, n) {
1286
1288
  if (!n || !n._parent) return o;
@@ -1319,8 +1321,8 @@ function handleNewParentTextBlock(o, n, r) {
1319
1321
  const d = o.map((u) => {
1320
1322
  if (u._id === r) {
1321
1323
  const g = { ...u, content: "" };
1322
- return Object.keys(g).forEach((f) => {
1323
- f.startsWith("content-") && (g[f] = "");
1324
+ return Object.keys(g).forEach((h) => {
1325
+ h.startsWith("content-") && (g[h] = "");
1324
1326
  }), g;
1325
1327
  }
1326
1328
  return u;
@@ -1337,7 +1339,7 @@ function moveBlocksWithChildren(o, n, r, a) {
1337
1339
  const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
1338
1340
  if (moveNode(p, n, c, a)) {
1339
1341
  let u = flattenTree(p);
1340
- const g = u.find((f) => f._id === n);
1342
+ const g = u.find((h) => h._id === n);
1341
1343
  return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
1342
1344
  }
1343
1345
  return i;
@@ -1387,50 +1389,50 @@ const useBlocksStoreManager = () => {
1387
1389
  updateBlocksProps: c
1388
1390
  } = useBlocksStoreManager();
1389
1391
  return {
1390
- moveBlocks: (x, y, b) => {
1392
+ moveBlocks: (x, b, y) => {
1391
1393
  const A = map(x, (w) => {
1392
1394
  const j = n.find((L) => L._id === w)._parent || null, C = n.filter((L) => j ? L._parent === j : !L._parent).map((L) => L._id).indexOf(w);
1393
1395
  return { _id: w, oldParent: j, oldPosition: C };
1394
1396
  }), E = A.find(({ _id: w }) => w === x[0]);
1395
- E && E.oldParent === y && E.oldPosition === b || (i(x, y, b), o({
1397
+ E && E.oldParent === b && E.oldPosition === y || (i(x, b, y), o({
1396
1398
  undo: () => each(A, ({ _id: w, oldParent: _, oldPosition: j }) => {
1397
1399
  i([w], _, j);
1398
1400
  }),
1399
- redo: () => i(x, y, b)
1401
+ redo: () => i(x, b, y)
1400
1402
  }));
1401
1403
  },
1402
- addBlocks: (x, y, b) => {
1403
- a(x, y, b), o({
1404
+ addBlocks: (x, b, y) => {
1405
+ a(x, b, y), o({
1404
1406
  undo: () => l(map(x, "_id")),
1405
- redo: () => a(x, y, b)
1407
+ redo: () => a(x, b, y)
1406
1408
  });
1407
1409
  },
1408
1410
  removeBlocks: (x) => {
1409
1411
  var E;
1410
- const y = (E = first(x)) == null ? void 0 : E._parent, A = n.filter((w) => y ? w._parent === y : !w._parent).indexOf(first(x));
1412
+ const b = (E = first(x)) == null ? void 0 : E._parent, A = n.filter((w) => b ? w._parent === b : !w._parent).indexOf(first(x));
1411
1413
  l(map(x, "_id")), o({
1412
- undo: () => a(x, y, A),
1414
+ undo: () => a(x, b, A),
1413
1415
  redo: () => l(map(x, "_id"))
1414
1416
  });
1415
1417
  },
1416
- updateBlocks: (x, y, b) => {
1418
+ updateBlocks: (x, b, y) => {
1417
1419
  let A = [];
1418
- if (b)
1419
- A = map(x, (E) => ({ _id: E, ...b }));
1420
+ if (y)
1421
+ A = map(x, (E) => ({ _id: E, ...y }));
1420
1422
  else {
1421
- const E = keys(y);
1423
+ const E = keys(b);
1422
1424
  A = map(x, (w) => {
1423
1425
  const _ = n.find((S) => S._id === w), j = { _id: w };
1424
1426
  return each(E, (S) => j[S] = _[S]), j;
1425
1427
  });
1426
1428
  }
1427
- c(map(x, (E) => ({ _id: E, ...y }))), o({
1429
+ c(map(x, (E) => ({ _id: E, ...b }))), o({
1428
1430
  undo: () => c(A),
1429
- redo: () => c(map(x, (E) => ({ _id: E, ...y })))
1431
+ redo: () => c(map(x, (E) => ({ _id: E, ...b })))
1430
1432
  });
1431
1433
  },
1432
- updateBlocksRuntime: (x, y) => {
1433
- c(map(x, (b) => ({ _id: b, ...y })));
1434
+ updateBlocksRuntime: (x, b) => {
1435
+ c(map(x, (y) => ({ _id: y, ...b })));
1434
1436
  },
1435
1437
  setNewBlocks: (x) => {
1436
1438
  r(x), o({
@@ -1439,12 +1441,12 @@ const useBlocksStoreManager = () => {
1439
1441
  });
1440
1442
  },
1441
1443
  updateMultipleBlocksProps: (x) => {
1442
- let y = [];
1443
- y = map(x, (b) => {
1444
- const A = keys(b), E = n.find((_) => _._id === b._id), w = {};
1444
+ let b = [];
1445
+ b = map(x, (y) => {
1446
+ const A = keys(y), E = n.find((_) => _._id === y._id), w = {};
1445
1447
  return each(A, (_) => w[_] = E[_]), w;
1446
1448
  }), c(x), o({
1447
- undo: () => c(y),
1449
+ undo: () => c(b),
1448
1450
  redo: () => c(x)
1449
1451
  });
1450
1452
  }
@@ -1482,12 +1484,12 @@ const useAddBlock = () => {
1482
1484
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
1483
1485
  (i, c, d) => {
1484
1486
  var m;
1485
- for (let h = 0; h < i.length; h++) {
1486
- const { _id: x } = i[h];
1487
- i[h]._id = generateUUID();
1488
- const y = filter(i, { _parent: x });
1489
- for (let b = 0; b < y.length; b++)
1490
- y[b]._parent = i[h]._id;
1487
+ for (let f = 0; f < i.length; f++) {
1488
+ const { _id: x } = i[f];
1489
+ i[f]._id = generateUUID();
1490
+ const b = filter(i, { _parent: x });
1491
+ for (let y = 0; y < b.length; y++)
1492
+ b[y]._parent = i[f]._id;
1491
1493
  }
1492
1494
  const p = first(i);
1493
1495
  let u, g;
@@ -1498,8 +1500,8 @@ const useAddBlock = () => {
1498
1500
  return { addCoreBlock: useCallback(
1499
1501
  (i, c, d) => {
1500
1502
  if (has(i, "blocks")) {
1501
- const y = i.blocks;
1502
- return a(y, c, d);
1503
+ const b = i.blocks;
1504
+ return a(b, c, d);
1503
1505
  }
1504
1506
  const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
1505
1507
  _type: i.type,
@@ -1508,8 +1510,8 @@ const useAddBlock = () => {
1508
1510
  ...has(i, "_name") && { _name: i._name },
1509
1511
  ...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
1510
1512
  };
1511
- let f, m;
1512
- return c && (f = find(o, { _id: c }), g._parent = c, m = c), !canAcceptChildBlock(f == null ? void 0 : f._type, g._type) && f && (g._parent = f._parent, m = f._parent), r([g], m, d), n([g._id]), g;
1513
+ let h, m;
1514
+ return c && (h = find(o, { _id: c }), g._parent = c, m = c), !canAcceptChildBlock(h == null ? void 0 : h._type, g._type) && h && (g._parent = h._parent, m = h._parent), r([g], m, d), n([g._id]), g;
1513
1515
  },
1514
1516
  [r, a, o, n]
1515
1517
  ), addPredefinedBlock: a };
@@ -2955,25 +2957,25 @@ const getBlockWithChildren = (o, n) => {
2955
2957
  return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
2956
2958
  })
2957
2959
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
2958
- const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, f = (m, h) => {
2959
- const x = cloneDeep(h.find((y) => y._id === m));
2960
- for (const y in x) {
2961
- const b = x[y];
2962
- if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
2963
- const { baseClasses: A, classes: E } = getSplitChaiClasses(b);
2964
- x[y] = compact(flattenDeep([A, E])).join(" ");
2960
+ const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m, f) => {
2961
+ const x = cloneDeep(f.find((b) => b._id === m));
2962
+ for (const b in x) {
2963
+ const y = x[b];
2964
+ if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
2965
+ const { baseClasses: A, classes: E } = getSplitChaiClasses(y);
2966
+ x[b] = compact(flattenDeep([A, E])).join(" ");
2965
2967
  } else
2966
- y !== "_id" && delete x[y];
2968
+ b !== "_id" && delete x[b];
2967
2969
  }
2968
2970
  return x;
2969
2971
  };
2970
2972
  return {
2971
2973
  askAi: useCallback(
2972
- async (m, h, x, y) => {
2974
+ async (m, f, x, b) => {
2973
2975
  if (l) {
2974
2976
  n(!0), a(null);
2975
2977
  try {
2976
- const b = p === u ? "" : p, A = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, d)), p) : [f(h, d)], E = await l(m, addLangToPrompt(x, g, m), A, b), { blocks: w, error: _ } = E;
2978
+ const y = p === u ? "" : p, A = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [h(f, d)], E = await l(m, addLangToPrompt(x, g, m), A, y), { blocks: w, error: _ } = E;
2977
2979
  if (_) {
2978
2980
  a(_);
2979
2981
  return;
@@ -2987,11 +2989,11 @@ const getBlockWithChildren = (o, n) => {
2987
2989
  c(j);
2988
2990
  } else
2989
2991
  i(w);
2990
- y && y(E);
2991
- } catch (b) {
2992
- a(b);
2992
+ b && b(E);
2993
+ } catch (y) {
2994
+ a(y);
2993
2995
  } finally {
2994
- n(!1), y && y();
2996
+ n(!1), b && b();
2995
2997
  }
2996
2998
  }
2997
2999
  },
@@ -3133,8 +3135,8 @@ const useBlockHighlight = () => {
3133
3135
  const g = filter(
3134
3136
  o,
3135
3137
  (m) => isString(l) ? m._parent === l : !m._parent
3136
- ).indexOf(d) + 1, f = getDuplicatedBlocks(o, c, l);
3137
- r(f, l, g), i.push(get(f, "0._id", ""));
3138
+ ).indexOf(d) + 1, h = getDuplicatedBlocks(o, c, l);
3139
+ r(h, l, g), i.push(get(h, "0._id", ""));
3138
3140
  }), n(i);
3139
3141
  },
3140
3142
  [o, n]
@@ -3227,14 +3229,14 @@ const useBlockHighlight = () => {
3227
3229
  return map(i, (c) => {
3228
3230
  const d = o(c), p = a;
3229
3231
  let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
3230
- return each(p, (f) => {
3231
- const m = f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
3232
- u = u.replace(h, " ").replace(/\s+/g, " ").trim();
3233
- const x = first(f.split(":"));
3234
- includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(f.split(":").pop().trim());
3235
- }), each(p, (f) => {
3236
- const m = f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
3237
- g = g.replace(h, " ").replace(/\s+/g, " ").trim();
3232
+ return each(p, (h) => {
3233
+ const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
3234
+ u = u.replace(f, " ").replace(/\s+/g, " ").trim();
3235
+ const x = first(h.split(":"));
3236
+ includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(h.split(":").pop().trim());
3237
+ }), each(p, (h) => {
3238
+ const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
3239
+ g = g.replace(f, " ").replace(/\s+/g, " ").trim();
3238
3240
  }), {
3239
3241
  ids: [d._id],
3240
3242
  props: {
@@ -3320,11 +3322,7 @@ wrapperBlockAtom.debugLabel = "wrapperBlockAtom";
3320
3322
  const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), layoutVariantAtom = atomWithStorage("_layout_variant_mode", "DUAL_SIDE_PANEL"), useLayoutVariant = () => {
3321
3323
  const [o, n] = useAtom$1(layoutVariantAtom), r = useBuilderProp("layoutVariant", "DUAL_SIDE_PANEL");
3322
3324
  return [o || r, n];
3323
- }, CHAI_BUILDER_EVENTS = {
3324
- OPEN_ADD_BLOCK: "OPEN_ADD_BLOCK",
3325
- CLOSE_ADD_BLOCK: "CLOSE_ADD_BLOCK",
3326
- SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS"
3327
- };
3325
+ }, draggedBlockAtom = atom$1(null), dropTargetBlockIdAtom = atom$1(null);
3328
3326
  class PubSub {
3329
3327
  constructor() {
3330
3328
  V(this, "subscribers", /* @__PURE__ */ new Map());
@@ -3340,7 +3338,86 @@ class PubSub {
3340
3338
  a && a.forEach((l) => l(r));
3341
3339
  }
3342
3340
  }
3343
- const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdAtom = atom$1(null), BlockActionLabel = ({ block: o, label: n }) => {
3341
+ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
3342
+ const [r] = useBlocksStore(), a = get(o, "_id"), l = get(o, "_parent"), i = filter(r, (u) => l ? get(u, "_parent") === l : !get(u, "_parent")), c = canAddChildBlock(get(o, "_type", "")), d = findIndex(i, { _id: a }), p = (u) => {
3343
+ if (u === "CHILD")
3344
+ pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
3345
+ else {
3346
+ const g = { _id: l || "", position: i == null ? void 0 : i.length };
3347
+ u === "BEFORE" ? g.position = Math.max(d, 0) : u === "AFTER" && (g.position = d + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, g);
3348
+ }
3349
+ };
3350
+ return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
3351
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { children: n }),
3352
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-200 shadow-2xl", children: [
3353
+ c && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer", onClick: () => p("CHILD"), children: "Add child block" }),
3354
+ /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer", onClick: () => p("BEFORE"), children: "Add block before" }),
3355
+ /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer", onClick: () => p("AFTER"), children: "Add block after" })
3356
+ ] })
3357
+ ] });
3358
+ };
3359
+ function getOrientation(o) {
3360
+ const n = window.getComputedStyle(o), r = n.display;
3361
+ if (r === "flex" || r === "inline-flex") {
3362
+ const a = n.flexDirection;
3363
+ return a === "column" || a === "column-reverse" ? "vertical" : "horizontal";
3364
+ } else if (r === "grid") {
3365
+ const a = n.gridAutoFlow, l = n.gridTemplateRows, i = n.gridTemplateColumns;
3366
+ return a.includes("column") || l.split(" ").length > i.split(" ").length ? "vertical" : "horizontal";
3367
+ } else if (r === "block" || r === "inline-block")
3368
+ return "vertical";
3369
+ return "horizontal";
3370
+ }
3371
+ const CONTROLS = [
3372
+ { ControlIcon: PinTopIcon, dir: "VERTICAL", key: "UP" },
3373
+ { ControlIcon: PinBottomIcon, dir: "VERTICAL", key: "DOWN" },
3374
+ { ControlIcon: PinLeftIcon, dir: "HORIZONTAL", key: "LEFT" },
3375
+ { ControlIcon: PinRightIcon, dir: "HORIZONTAL", key: "RIGHT" }
3376
+ ], getParentBlockOrientation = (o, n) => {
3377
+ try {
3378
+ if (!o || !n) return "VERTICAL";
3379
+ const r = `[data-block-id='${o}']`, a = n == null ? void 0 : n.querySelector(r);
3380
+ return a ? getOrientation(a).toUpperCase() : "VERTICAL";
3381
+ } catch {
3382
+ return "VERTICAL";
3383
+ }
3384
+ }, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
3385
+ const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, h = u + 1 === (d == null ? void 0 : d.length), m = getParentBlockOrientation(c, a), f = useCallback(
3386
+ (x) => {
3387
+ isDisabledControl(g, h, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
3388
+ },
3389
+ [g, h, p, u, i, c, n]
3390
+ );
3391
+ return useHotkeys(
3392
+ "shift+up, shift+down, shift+left, shift+right",
3393
+ ({ key: x }) => {
3394
+ var b;
3395
+ f((b = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : b.toUpperCase());
3396
+ },
3397
+ { document: a == null ? void 0 : a.contentDocument },
3398
+ [f]
3399
+ ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: f, orientation: m };
3400
+ }, BlockController = ({ block: o, updateFloatingBar: n }) => {
3401
+ const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
3402
+ o,
3403
+ n
3404
+ );
3405
+ return r ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
3406
+ /* @__PURE__ */ jsx("div", { className: "mx-1 h-3 w-px bg-white/50" }),
3407
+ CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => {
3408
+ if (c !== p) return null;
3409
+ const g = isDisabledControl(a, l, u);
3410
+ return /* @__PURE__ */ jsx(
3411
+ d,
3412
+ {
3413
+ onClick: () => i(u),
3414
+ className: `${g ? "pointer-events-none cursor-not-allowed opacity-50" : "duration-300 hover:scale-95 hover:opacity-80"}`
3415
+ },
3416
+ u
3417
+ );
3418
+ })
3419
+ ] });
3420
+ }, BlockActionLabel = ({ block: o, label: n }) => {
3344
3421
  const [, r] = useSelectedBlockIds(), [, a] = useHighlightBlockId(), [, l] = useAtom$1(draggedBlockAtom), i = useFeature("dnd");
3345
3422
  return /* @__PURE__ */ jsxs(
3346
3423
  "div",
@@ -3359,51 +3436,46 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3359
3436
  }
3360
3437
  );
3361
3438
  }, BlockFloatingSelector = ({ selectedBlockElement: o, block: n }) => {
3362
- const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), [d] = useAtom$1(inlineEditingActiveAtom), { floatingStyles: p, refs: u, update: g } = useFloating({
3439
+ const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), [d] = useAtom$1(inlineEditingActiveAtom), { document: p } = useFrame(), { floatingStyles: u, refs: g, update: h } = useFloating({
3363
3440
  placement: "top-start",
3364
3441
  middleware: [shift(), flip()],
3365
3442
  elements: {
3366
3443
  reference: o
3367
3444
  }
3368
3445
  });
3369
- useResizeObserver(o, () => g(), o !== null);
3370
- const f = get(n, "_parent", null), m = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
3446
+ useResizeObserver(o, () => h(), o !== null), useResizeObserver(p == null ? void 0 : p.body, () => h(), (p == null ? void 0 : p.body) !== null);
3447
+ const m = get(n, "_parent", null), f = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
3371
3448
  return !o || !n || d ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
3372
3449
  "div",
3373
3450
  {
3374
3451
  role: "button",
3375
3452
  tabIndex: 0,
3376
- ref: u.setFloating,
3377
- style: p,
3378
- onClick: (h) => {
3379
- h.stopPropagation(), h.preventDefault();
3453
+ ref: g.setFloating,
3454
+ style: u,
3455
+ onClick: (x) => {
3456
+ x.stopPropagation(), x.preventDefault();
3380
3457
  },
3381
- onMouseEnter: (h) => {
3382
- h.stopPropagation(), i(null);
3458
+ onMouseEnter: (x) => {
3459
+ x.stopPropagation(), i(null);
3383
3460
  },
3384
- onKeyDown: (h) => h.stopPropagation(),
3461
+ onKeyDown: (x) => x.stopPropagation(),
3385
3462
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3386
3463
  children: [
3387
- f && /* @__PURE__ */ jsx(
3464
+ m && /* @__PURE__ */ jsx(
3388
3465
  ArrowUpIcon,
3389
3466
  {
3390
3467
  className: "hover:scale-105",
3391
3468
  onClick: () => {
3392
- c([]), l([f]);
3469
+ c([]), l([m]);
3393
3470
  }
3394
3471
  }
3395
3472
  ),
3396
- /* @__PURE__ */ jsx(BlockActionLabel, { label: m, block: n }),
3397
- /* @__PURE__ */ jsxs("div", { className: "flex gap-2 px-1", children: [
3398
- canAddChildBlock(get(n, "_type", "")) && /* @__PURE__ */ jsx(
3399
- PlusIcon,
3400
- {
3401
- className: "hover:scale-105",
3402
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, n)
3403
- }
3404
- ),
3473
+ /* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: n }),
3474
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
3475
+ /* @__PURE__ */ jsx(AddBlockDropdown, { block: n, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
3405
3476
  canDuplicateBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([n == null ? void 0 : n._id]) }) : null,
3406
- canDeleteBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null
3477
+ canDeleteBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null,
3478
+ /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar: h })
3407
3479
  ] })
3408
3480
  ]
3409
3481
  }
@@ -3464,21 +3536,21 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3464
3536
  <div class="frame-root h-full"></div>
3465
3537
  </body>
3466
3538
  </html>`, useKeyEventWatcher = (o) => {
3467
- const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: f } = usePasteBlocks(), m = o ? { document: o } : {};
3539
+ const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: h } = usePasteBlocks(), m = o ? { document: o } : {};
3468
3540
  useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys("ctrl+c,command+c", () => u(n), {}, [n, u]), useHotkeys(
3469
3541
  "ctrl+v,command+v",
3470
3542
  () => {
3471
- g(n[0]) && f(n);
3543
+ g(n[0]) && h(n);
3472
3544
  },
3473
3545
  { ...m, preventDefault: !0 },
3474
- [n, g, f]
3546
+ [n, g, h]
3475
3547
  ), useHotkeys("esc", () => r([]), m, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...m, preventDefault: !0 }, [
3476
3548
  n,
3477
3549
  i
3478
3550
  ]), useHotkeys(
3479
3551
  "del, backspace",
3480
- (h) => {
3481
- h.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
3552
+ (f) => {
3553
+ f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
3482
3554
  },
3483
3555
  m,
3484
3556
  [n, l]
@@ -3486,6 +3558,10 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3486
3558
  }, KeyboardHandler = () => {
3487
3559
  const { document: o } = useFrame();
3488
3560
  return useKeyEventWatcher(o), null;
3561
+ }, CHAI_BUILDER_EVENTS = {
3562
+ OPEN_ADD_BLOCK: "OPEN_ADD_BLOCK",
3563
+ CLOSE_ADD_BLOCK: "CLOSE_ADD_BLOCK",
3564
+ SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS"
3489
3565
  }, AddBlockAtBottom = () => {
3490
3566
  const { t: o } = useTranslation();
3491
3567
  return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer py-2", children: [
@@ -3505,18 +3581,6 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3505
3581
  /* @__PURE__ */ jsx("br", {})
3506
3582
  ] });
3507
3583
  };
3508
- function getOrientation(o) {
3509
- const n = window.getComputedStyle(o), r = n.display;
3510
- if (r === "flex" || r === "inline-flex") {
3511
- const a = n.flexDirection;
3512
- return a === "column" || a === "column-reverse" ? "vertical" : "horizontal";
3513
- } else if (r === "grid") {
3514
- const a = n.gridAutoFlow, l = n.gridTemplateRows, i = n.gridTemplateColumns;
3515
- return a.includes("column") || l.split(" ").length > i.split(" ").length ? "vertical" : "horizontal";
3516
- } else if (r === "block" || r === "inline-block")
3517
- return "vertical";
3518
- return "horizontal";
3519
- }
3520
3584
  let iframeDocument = null, possiblePositions = [], dropTarget = null, dropIndex = null;
3521
3585
  const positionPlaceholder = (o, n, r) => {
3522
3586
  if (!iframeDocument || !o) return;
@@ -3566,7 +3630,7 @@ function removeDataDrop() {
3566
3630
  const useDnd = () => {
3567
3631
  const { document: o } = useFrame(), [n, r] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: c } = useBlocksStoreUndoableActions(), [d, p] = useAtom$1(draggedBlockAtom), [, u] = useAtom$1(dropTargetBlockIdAtom);
3568
3632
  if (!useFeature("dnd")) return {};
3569
- const f = () => {
3633
+ const h = () => {
3570
3634
  removePlaceholder(), r(!1), p(null), u(null), possiblePositions = [];
3571
3635
  };
3572
3636
  return iframeDocument = o, {
@@ -3576,25 +3640,25 @@ const useDnd = () => {
3576
3640
  },
3577
3641
  onDrop: (m) => {
3578
3642
  var _;
3579
- const h = dropTarget, y = getOrientation(h) === "vertical" ? m.clientY + ((_ = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : _.scrollY) : m.clientX;
3580
- dropIndex = calculateDropIndex(y, possiblePositions);
3581
- const b = d, A = h.getAttribute("data-block-id"), E = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3582
- if ((b == null ? void 0 : b._id) === A || !E) {
3583
- f();
3643
+ const f = dropTarget, b = getOrientation(f) === "vertical" ? m.clientY + ((_ = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : _.scrollY) : m.clientX;
3644
+ dropIndex = calculateDropIndex(b, possiblePositions);
3645
+ const y = d, A = f.getAttribute("data-block-id"), E = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3646
+ if ((y == null ? void 0 : y._id) === A || !E) {
3647
+ h();
3584
3648
  return;
3585
3649
  }
3586
- if (!has(b, "_id")) {
3587
- a(b, A === "canvas" ? null : A, dropIndex), setTimeout(f, 300);
3650
+ if (!has(y, "_id")) {
3651
+ a(y, A === "canvas" ? null : A, dropIndex), setTimeout(h, 300);
3588
3652
  return;
3589
3653
  }
3590
- let w = h.getAttribute("data-block-id");
3591
- w === null && (w = m.target.parentElement.getAttribute("data-block-id")), c([b._id], w === "canvas" ? null : w, dropIndex), f(), setTimeout(removePlaceholder, 300);
3654
+ let w = f.getAttribute("data-block-id");
3655
+ w === null && (w = m.target.parentElement.getAttribute("data-block-id")), c([y._id], w === "canvas" ? null : w, dropIndex), h(), setTimeout(removePlaceholder, 300);
3592
3656
  },
3593
3657
  onDragEnter: (m) => {
3594
- const h = m, x = h.target;
3658
+ const f = m, x = f.target;
3595
3659
  dropTarget = x;
3596
- const y = x.getAttribute("data-block-id"), b = x.getAttribute("data-dnd-dragged") !== "yes";
3597
- u(y), h.stopPropagation(), h.preventDefault(), possiblePositions = [], b && calculatePossiblePositions(x), r(!0), l(""), i([]);
3660
+ const b = x.getAttribute("data-block-id"), y = x.getAttribute("data-dnd-dragged") !== "yes";
3661
+ u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(x), r(!0), l(""), i([]);
3598
3662
  },
3599
3663
  onDragLeave: (m) => {
3600
3664
  m.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
@@ -3619,16 +3683,16 @@ const useHandleCanvasDblClick = (o, n) => {
3619
3683
  const g = u.getAttribute("data-block-type");
3620
3684
  if (!g || !r.includes(g))
3621
3685
  return;
3622
- const f = u.getAttribute("data-block-id");
3623
- if (!f) return;
3624
- o.on("update", ({ editor: h }) => {
3625
- console.log(h.getHTML());
3686
+ const h = u.getAttribute("data-block-id");
3687
+ if (!h) return;
3688
+ o.on("update", ({ editor: f }) => {
3689
+ console.log(f.getHTML());
3626
3690
  }), o.on("blur", () => {
3627
3691
  console.log("blur");
3628
- const h = o.getHTML();
3629
- a([f], { content: h }), n.style.display = "none", u.style.visibility = "visible";
3630
- }), i(f);
3631
- const m = d(f).content;
3692
+ const f = o.getHTML();
3693
+ a([h], { content: f }), n.style.display = "none", u.style.visibility = "visible";
3694
+ }), i(h);
3695
+ const m = d(h).content;
3632
3696
  o.commands.setContent(m), n.style.display = "block", u.style.visibility = "hidden", n.style.position = "absolute", n.style.top = `${u.offsetTop}px`, n.style.left = `${u.offsetLeft}px`, n.style.width = `${u.offsetWidth}px`, n.style.height = `${u.offsetHeight}px`, n.classList.add(...u.classList);
3633
3697
  },
3634
3698
  [l, c, d, i, a, o, n]
@@ -3668,19 +3732,19 @@ const useHandleCanvasDblClick = (o, n) => {
3668
3732
  setTimeout(() => {
3669
3733
  if (!isEmpty(a))
3670
3734
  return;
3671
- const h = getElementByDataBlockId(n, first(r));
3672
- if (h) {
3673
- const x = h.getAttribute("data-style-prop");
3735
+ const f = getElementByDataBlockId(n, first(r));
3736
+ if (f) {
3737
+ const x = f.getAttribute("data-style-prop");
3674
3738
  if (x) {
3675
- const y = h.getAttribute("data-style-id"), b = h.getAttribute("data-block-parent");
3676
- l([{ id: y, prop: x, blockId: b }]);
3739
+ const b = f.getAttribute("data-style-id"), y = f.getAttribute("data-block-parent");
3740
+ l([{ id: b, prop: x, blockId: y }]);
3677
3741
  }
3678
3742
  }
3679
3743
  }, 100);
3680
3744
  }, [n, r, l, a]);
3681
3745
  const c = useEditor({
3682
3746
  extensions: [StarterKit]
3683
- }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), f = useHandleMouseLeave(), m = useDnd();
3747
+ }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), h = useHandleMouseLeave(), m = useDnd();
3684
3748
  return /* @__PURE__ */ jsx(
3685
3749
  "div",
3686
3750
  {
@@ -3689,7 +3753,7 @@ const useHandleCanvasDblClick = (o, n) => {
3689
3753
  onClick: u,
3690
3754
  onDoubleClick: p,
3691
3755
  onMouseMove: g,
3692
- onMouseLeave: f,
3756
+ onMouseLeave: h,
3693
3757
  ...omit(m, "isDragging"),
3694
3758
  className: "relative h-full max-w-full p-px " + (m.isDragging ? "dragging" : ""),
3695
3759
  children: o
@@ -3698,7 +3762,7 @@ const useHandleCanvasDblClick = (o, n) => {
3698
3762
  }, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), HeadTags = () => {
3699
3763
  const [o] = useTheme(), n = useThemeOptions(), [r] = useSelectedBlockIds(), [a] = useDarkMode(), [l] = useSelectedStylingBlocks(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), { document: d, window: p } = useFrame(), [u] = useState(d == null ? void 0 : d.getElementById("highlighted-block")), [g] = useState(
3700
3764
  d == null ? void 0 : d.getElementById("selected-block")
3701
- ), [f] = useState(
3765
+ ), [h] = useState(
3702
3766
  d == null ? void 0 : d.getElementById("selected-styling-block")
3703
3767
  ), [m] = useState(
3704
3768
  d == null ? void 0 : d.getElementById("dragged-block")
@@ -3725,22 +3789,22 @@ const useHandleCanvasDblClick = (o, n) => {
3725
3789
  forms,
3726
3790
  aspectRatio,
3727
3791
  containerQueries,
3728
- plugin(function({ addBase: y, theme: b }) {
3729
- y({
3792
+ plugin(function({ addBase: b, theme: y }) {
3793
+ b({
3730
3794
  "h1,h2,h3,h4,h5,h6": {
3731
- fontFamily: b("fontFamily.heading")
3795
+ fontFamily: y("fontFamily.heading")
3732
3796
  },
3733
3797
  body: {
3734
- fontFamily: b("fontFamily.body"),
3735
- color: b("colors.foreground"),
3736
- backgroundColor: b("colors.background")
3798
+ fontFamily: y("fontFamily.body"),
3799
+ color: y("colors.foreground"),
3800
+ backgroundColor: y("colors.background")
3737
3801
  }
3738
3802
  });
3739
3803
  })
3740
3804
  ]
3741
3805
  });
3742
3806
  }, [o, n, p]), useEffect(() => {
3743
- g && (g.textContent = `${map(r, (y) => `[data-block-id="${y}"]`).join(",")}{
3807
+ g && (g.textContent = `${map(r, (b) => `[data-block-id="${b}"]`).join(",")}{
3744
3808
  outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
3745
3809
  }`);
3746
3810
  }, [r, g]), useEffect(() => {
@@ -3748,18 +3812,18 @@ const useHandleCanvasDblClick = (o, n) => {
3748
3812
  }, [i, m]), useEffect(() => {
3749
3813
  u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
3750
3814
  }, [u]), useEffect(() => {
3751
- f && (f.textContent = `${map(l, ({ id: y }) => `[data-style-id="${y}"]`).join(",")}{
3815
+ h && (h.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
3752
3816
  outline: 1px solid orange !important; outline-offset: -1px;
3753
3817
  }`);
3754
- }, [l, f]), useEffect(() => {
3818
+ }, [l, h]), useEffect(() => {
3755
3819
  d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
3756
3820
  }, [c, d]);
3757
- const h = useMemo(
3821
+ const f = useMemo(
3758
3822
  () => getChaiThemeCssVariables(o),
3759
3823
  [o]
3760
3824
  ), x = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3761
3825
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3762
- /* @__PURE__ */ jsx("style", { id: "chai-theme", children: h }),
3826
+ /* @__PURE__ */ jsx("style", { id: "chai-theme", children: f }),
3763
3827
  /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: x } })
3764
3828
  ] });
3765
3829
  }, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
@@ -3837,13 +3901,13 @@ const getBlockRuntimeProps = memoize((o) => {
3837
3901
  [o]
3838
3902
  );
3839
3903
  }, BlockRenderer = ({ blockAtom: o, children: n }) => {
3840
- const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), f = useMemo(
3904
+ const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), h = useMemo(
3841
3905
  () => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
3842
3906
  [r, l, a, d, u]
3843
- ), m = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), h = useMemo(
3907
+ ), m = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), f = useMemo(
3844
3908
  () => c(r._id, getBlockRuntimeProps(r._type)),
3845
3909
  [r._id, r._type, c, getBlockRuntimeProps]
3846
- ), x = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), y = useMemo(
3910
+ ), x = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), b = useMemo(
3847
3911
  () => ({
3848
3912
  blockProps: {
3849
3913
  "data-block-id": r._id,
@@ -3851,9 +3915,9 @@ const getBlockRuntimeProps = memoize((o) => {
3851
3915
  },
3852
3916
  inBuilder: !0,
3853
3917
  lang: l || i,
3854
- ...f,
3855
- ...m,
3856
3918
  ...h,
3919
+ ...m,
3920
+ ...f,
3857
3921
  ...x
3858
3922
  }),
3859
3923
  [
@@ -3861,13 +3925,13 @@ const getBlockRuntimeProps = memoize((o) => {
3861
3925
  r._type,
3862
3926
  l,
3863
3927
  i,
3864
- f,
3865
- m,
3866
3928
  h,
3929
+ m,
3930
+ f,
3867
3931
  x
3868
3932
  ]
3869
3933
  );
3870
- return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...y, children: n }) });
3934
+ return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...b, children: n }) });
3871
3935
  }, PartialBlocksRenderer = ({ partialBlockId: o }) => {
3872
3936
  const { getPartailBlocks: n } = usePartailBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom$1(r)), [r]);
3873
3937
  return isEmpty(r) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r });
@@ -3896,10 +3960,10 @@ const getBlockRuntimeProps = memoize((o) => {
3896
3960
  if (d < n) {
3897
3961
  const u = parseFloat((d / n).toFixed(2).toString());
3898
3962
  let g = {};
3899
- const f = p * u, m = d * u;
3963
+ const h = p * u, m = d * u;
3900
3964
  p && (g = {
3901
3965
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
3902
- height: 100 + (p - f) / f * 100 + "%",
3966
+ height: 100 + (p - h) / h * 100 + "%",
3903
3967
  width: 100 + (d - m) / m * 100 + "%"
3904
3968
  }), i({
3905
3969
  position: "relative",
@@ -3917,7 +3981,7 @@ const getBlockRuntimeProps = memoize((o) => {
3917
3981
  c();
3918
3982
  }, [n, o, r, c]), l;
3919
3983
  }, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
3920
- const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, f] = useState([]), [, m] = useState([]), [, h] = useAtom$1(canvasIframeAtom), [x, y] = useSelectedStylingBlocks(), b = useBuilderProp("loading", !1), A = useBuilderProp("htmlDir", "ltr"), E = (j) => {
3984
+ const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, h] = useState([]), [, m] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [x, b] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), A = useBuilderProp("htmlDir", "ltr"), E = (j) => {
3921
3985
  p((S) => ({ ...S, width: j }));
3922
3986
  };
3923
3987
  useEffect(() => {
@@ -3933,7 +3997,7 @@ const getBlockRuntimeProps = memoize((o) => {
3933
3997
  var j, S;
3934
3998
  if (a && a.type !== "Multiple" && i.current) {
3935
3999
  const C = getElementByDataBlockId(i.current.contentDocument, a._id);
3936
- C && (w(C) || (S = (j = i.current) == null ? void 0 : j.contentWindow) == null || S.scrollTo({ top: C.offsetTop, behavior: "smooth" }), f([C]));
4000
+ C && (w(C) || (S = (j = i.current) == null ? void 0 : j.contentWindow) == null || S.scrollTo({ top: C.offsetTop, behavior: "smooth" }), h([C]));
3937
4001
  }
3938
4002
  }, [a]), useEffect(() => {
3939
4003
  if (!isEmpty(x) && i.current) {
@@ -3953,7 +4017,7 @@ const getBlockRuntimeProps = memoize((o) => {
3953
4017
  "div",
3954
4018
  {
3955
4019
  onClick: () => {
3956
- r([]), y([]);
4020
+ r([]), b([]);
3957
4021
  },
3958
4022
  onMouseLeave: () => setTimeout(() => l(""), 300),
3959
4023
  className: "relative mx-auto h-full w-full overflow-hidden",
@@ -3961,7 +4025,7 @@ const getBlockRuntimeProps = memoize((o) => {
3961
4025
  children: /* @__PURE__ */ jsxs(
3962
4026
  ChaiFrame,
3963
4027
  {
3964
- contentDidMount: () => h(i.current),
4028
+ contentDidMount: () => f(i.current),
3965
4029
  ref: i,
3966
4030
  id: "canvas-iframe",
3967
4031
  style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
@@ -3978,7 +4042,7 @@ const getBlockRuntimeProps = memoize((o) => {
3978
4042
  ),
3979
4043
  /* @__PURE__ */ jsx(HeadTags, {}),
3980
4044
  /* @__PURE__ */ jsx(Provider$1, { children: /* @__PURE__ */ jsxs(Canvas, { children: [
3981
- b ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
4045
+ y ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
3982
4046
  /* @__PURE__ */ jsx(AddBlockAtBottom, {}),
3983
4047
  /* @__PURE__ */ jsx("br", {}),
3984
4048
  /* @__PURE__ */ jsx("br", {}),
@@ -4139,52 +4203,52 @@ const getBlockRuntimeProps = memoize((o) => {
4139
4203
  }
4140
4204
  );
4141
4205
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
4142
- const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [c, d] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), g = (b) => {
4143
- a(b);
4144
- }, f = () => {
4145
- const b = l.find((A) => Object.keys(A)[0] === r);
4146
- if (b) {
4147
- const A = Object.values(b)[0];
4206
+ const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [c, d] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), g = (y) => {
4207
+ a(y);
4208
+ }, h = () => {
4209
+ const y = l.find((A) => Object.keys(A)[0] === r);
4210
+ if (y) {
4211
+ const A = Object.values(y)[0];
4148
4212
  A && typeof A == "object" && "fontFamily" in A && "borderRadius" in A && "colors" in A ? d(A) : console.error("Invalid preset structure:", A);
4149
4213
  } else
4150
4214
  console.error("Preset not found:", r);
4151
4215
  }, m = useDebouncedCallback(
4152
- (b, A) => {
4216
+ (y, A) => {
4153
4217
  d(() => ({
4154
4218
  ...c,
4155
4219
  fontFamily: {
4156
4220
  ...c.fontFamily,
4157
- [b.replace(/font-/g, "")]: A
4221
+ [y.replace(/font-/g, "")]: A
4158
4222
  }
4159
4223
  }));
4160
4224
  },
4161
4225
  [c],
4162
4226
  200
4163
- ), h = useDebouncedCallback(
4164
- (b) => {
4227
+ ), f = useDebouncedCallback(
4228
+ (y) => {
4165
4229
  d(() => ({
4166
4230
  ...c,
4167
- borderRadius: `${b}px`
4231
+ borderRadius: `${y}px`
4168
4232
  }));
4169
4233
  },
4170
4234
  [c],
4171
4235
  200
4172
4236
  ), x = useDebouncedCallback(
4173
- (b, A) => {
4237
+ (y, A) => {
4174
4238
  d(() => {
4175
- const E = get(c, `colors.${b}`);
4239
+ const E = get(c, `colors.${y}`);
4176
4240
  return n ? set(E, 1, A) : set(E, 0, A), {
4177
4241
  ...c,
4178
4242
  colors: {
4179
4243
  ...c.colors,
4180
- [b]: E
4244
+ [y]: E
4181
4245
  }
4182
4246
  };
4183
4247
  });
4184
4248
  },
4185
4249
  [c],
4186
4250
  200
4187
- ), y = (b) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(b.items).map(([A]) => {
4251
+ ), b = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([A]) => {
4188
4252
  const E = get(c, `colors.${A}.${n ? 1 : 0}`);
4189
4253
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
4190
4254
  /* @__PURE__ */ jsx(
@@ -4206,11 +4270,11 @@ const getBlockRuntimeProps = memoize((o) => {
4206
4270
  "select",
4207
4271
  {
4208
4272
  value: r,
4209
- onChange: (b) => g(b.target.value),
4273
+ onChange: (y) => g(y.target.value),
4210
4274
  className: "w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
4211
4275
  children: [
4212
4276
  /* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
4213
- Array.isArray(l) && l.map((b) => /* @__PURE__ */ jsx("option", { value: Object.keys(b)[0], children: capitalize(Object.keys(b)[0]) }, Object.keys(b)[0]))
4277
+ Array.isArray(l) && l.map((y) => /* @__PURE__ */ jsx("option", { value: Object.keys(y)[0], children: capitalize(Object.keys(y)[0]) }, Object.keys(y)[0]))
4214
4278
  ]
4215
4279
  }
4216
4280
  )
@@ -4221,31 +4285,31 @@ const getBlockRuntimeProps = memoize((o) => {
4221
4285
  className: "w-full text-sm",
4222
4286
  disabled: r === "",
4223
4287
  variant: "default",
4224
- onClick: f,
4288
+ onClick: h,
4225
4289
  children: u("Apply")
4226
4290
  }
4227
4291
  ) })
4228
4292
  ] }),
4229
4293
  /* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
4230
- (p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([b, A]) => /* @__PURE__ */ jsx(
4294
+ (p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, A]) => /* @__PURE__ */ jsx(
4231
4295
  FontSelector,
4232
4296
  {
4233
- label: b,
4234
- value: c.fontFamily[b.replace(/font-/g, "")] || A[Object.keys(A)[0]],
4235
- onChange: (E) => m(b, E)
4297
+ label: y,
4298
+ value: c.fontFamily[y.replace(/font-/g, "")] || A[Object.keys(A)[0]],
4299
+ onChange: (E) => m(y, E)
4236
4300
  },
4237
- b
4301
+ y
4238
4302
  )) }),
4239
4303
  (p == null ? void 0 : p.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
4240
4304
  /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Border Radius") }),
4241
4305
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
4242
- /* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange: h }),
4306
+ /* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange: f }),
4243
4307
  /* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: c.borderRadius })
4244
4308
  ] })
4245
4309
  ] }),
4246
4310
  (p == null ? void 0 : p.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
4247
4311
  /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Colors") }),
4248
- /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((b) => y(b)) }, n ? "dark" : "light")
4312
+ /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) => b(y)) }, n ? "dark" : "light")
4249
4313
  ] })
4250
4314
  ] }),
4251
4315
  /* @__PURE__ */ jsx("br", {}),
@@ -4336,22 +4400,22 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4336
4400
  useEffect(() => {
4337
4401
  a || c([]), p(o);
4338
4402
  }, [a, o]);
4339
- const u = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", g = React.useCallback(
4340
- (h) => {
4341
- const x = (y) => r === "value" ? y === "value" || y === "object" : r === "array" ? y === "array" : y === r;
4342
- h.type === "object" ? (c((y) => [...y, h.key]), p(h.value)) : x(h.type) && (n([...i, h.key].join(".")), l(!1));
4403
+ const u = (f) => Array.isArray(f) ? "array" : typeof f == "object" && f !== null ? "object" : "value", g = React.useCallback(
4404
+ (f) => {
4405
+ const x = (b) => r === "value" ? b === "value" || b === "object" : r === "array" ? b === "array" : b === r;
4406
+ f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) : x(f.type) && (n([...i, f.key].join(".")), l(!1));
4343
4407
  },
4344
4408
  [i, n, r]
4345
- ), f = React.useCallback(() => {
4409
+ ), h = React.useCallback(() => {
4346
4410
  if (i.length > 0) {
4347
- const h = i.slice(0, -1);
4348
- c(h), p(h.reduce((x, y) => x[y], o));
4411
+ const f = i.slice(0, -1);
4412
+ c(f), p(f.reduce((x, b) => x[b], o));
4349
4413
  }
4350
- }, [i, o]), m = React.useMemo(() => Object.entries(d).map(([h, x]) => ({
4351
- key: h,
4414
+ }, [i, o]), m = React.useMemo(() => Object.entries(d).map(([f, x]) => ({
4415
+ key: f,
4352
4416
  value: x,
4353
4417
  type: u(x)
4354
- })).filter((h) => r === "value" ? h.type === "value" || h.type === "object" : r === "array" ? h.type === "array" || h.type === "object" : r === "object" ? h.type === "object" : !0), [d, r]);
4418
+ })).filter((f) => r === "value" ? f.type === "value" || f.type === "object" : r === "array" ? f.type === "array" || f.type === "object" : r === "object" ? f.type === "object" : !0), [d, r]);
4355
4419
  return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
4356
4420
  /* @__PURE__ */ jsxs(Tooltip, { children: [
4357
4421
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
@@ -4372,37 +4436,37 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4372
4436
  /* @__PURE__ */ jsxs(CommandList, { children: [
4373
4437
  /* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
4374
4438
  /* @__PURE__ */ jsxs(CommandGroup, { children: [
4375
- i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: f, className: "flex items-center text-sm", children: [
4439
+ i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: h, className: "flex items-center text-sm", children: [
4376
4440
  /* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
4377
4441
  "Back"
4378
4442
  ] }),
4379
- m.map((h) => /* @__PURE__ */ jsxs(
4443
+ m.map((f) => /* @__PURE__ */ jsxs(
4380
4444
  CommandItem,
4381
4445
  {
4382
- value: h.key,
4446
+ value: f.key,
4383
4447
  disabled: !1,
4384
- onSelect: () => g(h),
4448
+ onSelect: () => g(f),
4385
4449
  className: "flex items-center justify-between",
4386
4450
  children: [
4387
- /* @__PURE__ */ jsx("span", { children: h.key }),
4451
+ /* @__PURE__ */ jsx("span", { children: f.key }),
4388
4452
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
4389
- r === "object" && h.type === "object" && /* @__PURE__ */ jsx(
4453
+ r === "object" && f.type === "object" && /* @__PURE__ */ jsx(
4390
4454
  Button,
4391
4455
  {
4392
4456
  size: "sm",
4393
4457
  variant: "ghost",
4394
4458
  className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
4395
4459
  onClick: (x) => {
4396
- x.stopPropagation(), n([...i, h.key].join(".")), l(!1);
4460
+ x.stopPropagation(), n([...i, f.key].join(".")), l(!1);
4397
4461
  },
4398
4462
  children: "Select"
4399
4463
  }
4400
4464
  ),
4401
- (h.type === "object" || h.type === "array") && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
4465
+ (f.type === "object" || f.type === "array") && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
4402
4466
  ] })
4403
4467
  ]
4404
4468
  },
4405
- h.key
4469
+ f.key
4406
4470
  ))
4407
4471
  ] })
4408
4472
  ] })
@@ -4561,14 +4625,14 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4561
4625
  const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
4562
4626
  useEffect(() => {
4563
4627
  if (o) {
4564
- const f = document.createElement("style");
4565
- return f.id = "rte-modal-styles", f.innerHTML = `
4628
+ const h = document.createElement("style");
4629
+ return h.id = "rte-modal-styles", h.innerHTML = `
4566
4630
  /* Ensure the NestedPathSelector popover appears above the dialog */
4567
4631
  .rte-path-selector + [data-radix-popper-content-wrapper],
4568
4632
  [data-radix-popper-content-wrapper] {
4569
4633
  z-index: 9999 !important;
4570
4634
  }
4571
- `, document.head.appendChild(f), () => {
4635
+ `, document.head.appendChild(h), () => {
4572
4636
  const m = document.getElementById("rte-modal-styles");
4573
4637
  m && m.remove();
4574
4638
  };
@@ -4591,12 +4655,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4591
4655
  Underline
4592
4656
  ],
4593
4657
  content: a || "",
4594
- onUpdate: ({ editor: f }) => {
4595
- const m = f.getHTML();
4658
+ onUpdate: ({ editor: h }) => {
4659
+ const m = h.getHTML();
4596
4660
  l(m);
4597
4661
  },
4598
- onBlur: ({ editor: f }) => {
4599
- const m = f.getHTML();
4662
+ onBlur: ({ editor: h }) => {
4663
+ const m = h.getHTML();
4600
4664
  i(r, m);
4601
4665
  },
4602
4666
  editorProps: {
@@ -4612,22 +4676,22 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4612
4676
  }, [o, u]), useEffect(() => {
4613
4677
  c.current && u && (c.current.__chaiRTE = u);
4614
4678
  }, [u, o]);
4615
- const g = (f) => {
4679
+ const g = (h) => {
4616
4680
  if (!u) return;
4617
- const m = `{{${f}}}`;
4681
+ const m = `{{${h}}}`;
4618
4682
  u.commands.focus();
4619
- const { from: h, to: x } = u.state.selection;
4620
- if (h !== x)
4683
+ const { from: f, to: x } = u.state.selection;
4684
+ if (f !== x)
4621
4685
  u.chain().deleteSelection().insertContent(m).run();
4622
4686
  else {
4623
- const { state: b } = u, A = b.selection.from, E = b.doc.textBetween(Math.max(0, A - 1), A), w = b.doc.textBetween(A, Math.min(A + 1, b.doc.content.size));
4687
+ const { state: y } = u, A = y.selection.from, E = y.doc.textBetween(Math.max(0, A - 1), A), w = y.doc.textBetween(A, Math.min(A + 1, y.doc.content.size));
4624
4688
  let _ = "";
4625
4689
  A > 0 && E !== " " && !/[.,!?;:]/.test(E) && (_ = " ");
4626
4690
  let j = "";
4627
4691
  w && w !== " " && !/[.,!?;:]/.test(w) && (j = " "), u.chain().insertContent(_ + m + j).run();
4628
4692
  }
4629
4693
  };
4630
- return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (f) => !f && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
4694
+ return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (h) => !h && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
4631
4695
  /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
4632
4696
  /* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
4633
4697
  p && Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -4659,12 +4723,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4659
4723
  Underline
4660
4724
  ],
4661
4725
  content: r || "",
4662
- onUpdate: ({ editor: h }) => {
4663
- const x = h.getHTML();
4726
+ onUpdate: ({ editor: f }) => {
4727
+ const x = f.getHTML();
4664
4728
  a(x), c || u(x);
4665
4729
  },
4666
- onBlur: ({ editor: h }) => {
4667
- const x = h.getHTML();
4730
+ onBlur: ({ editor: f }) => {
4731
+ const x = f.getHTML();
4668
4732
  l(o, x);
4669
4733
  },
4670
4734
  editorProps: {
@@ -4678,8 +4742,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4678
4742
  }, [g]), useEffect(() => {
4679
4743
  u(r || "");
4680
4744
  }, [r]);
4681
- const f = (h) => {
4682
- a(h);
4745
+ const h = (f) => {
4746
+ a(f);
4683
4747
  }, m = () => {
4684
4748
  d(!1), g && g.commands.setContent(p);
4685
4749
  };
@@ -4695,7 +4759,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4695
4759
  onClose: m,
4696
4760
  id: o,
4697
4761
  value: p,
4698
- onChange: f,
4762
+ onChange: h,
4699
4763
  onBlur: l
4700
4764
  }
4701
4765
  )
@@ -4706,9 +4770,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4706
4770
  onChange: r
4707
4771
  }) => {
4708
4772
  var L;
4709
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [f, m] = useState(""), [h, x] = useState([]), [y, b] = useState(-1), A = useRef(null), E = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
4773
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), A = useRef(null), E = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
4710
4774
  useEffect(() => {
4711
- if (m(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4775
+ if (m(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4712
4776
  const v = split(o, ":"), k = get(v, 1, "page") || "page";
4713
4777
  g(k), (async () => {
4714
4778
  const B = await l(k, [get(v, 2, "page")]);
@@ -4723,24 +4787,24 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4723
4787
  const k = await l(u, v);
4724
4788
  x(k);
4725
4789
  }
4726
- c(!1), b(-1);
4790
+ c(!1), y(-1);
4727
4791
  },
4728
4792
  [u],
4729
4793
  300
4730
4794
  ), _ = (v) => {
4731
4795
  const k = ["pageType", u, v.id];
4732
- k[1] && (r(k.join(":")), m(v.name), p(!1), x([]), b(-1));
4796
+ k[1] && (r(k.join(":")), m(v.name), p(!1), x([]), y(-1));
4733
4797
  }, j = (v) => {
4734
4798
  switch (v.key) {
4735
4799
  case "ArrowDown":
4736
- v.preventDefault(), b((k) => k < h.length - 1 ? k + 1 : k);
4800
+ v.preventDefault(), y((k) => k < f.length - 1 ? k + 1 : k);
4737
4801
  break;
4738
4802
  case "ArrowUp":
4739
- v.preventDefault(), b((k) => k > 0 ? k - 1 : k);
4803
+ v.preventDefault(), y((k) => k > 0 ? k - 1 : k);
4740
4804
  break;
4741
4805
  case "Enter":
4742
- if (v.preventDefault(), h.length === 0) return;
4743
- y >= 0 && _(h[y]);
4806
+ if (v.preventDefault(), f.length === 0) return;
4807
+ b >= 0 && _(f[b]);
4744
4808
  break;
4745
4809
  case "Escape":
4746
4810
  v.preventDefault(), S();
@@ -4748,13 +4812,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4748
4812
  }
4749
4813
  };
4750
4814
  useEffect(() => {
4751
- if (y >= 0 && A.current) {
4752
- const v = A.current.children[y];
4815
+ if (b >= 0 && A.current) {
4816
+ const v = A.current.children[b];
4753
4817
  v == null || v.scrollIntoView({ block: "nearest" });
4754
4818
  }
4755
- }, [y]);
4819
+ }, [b]);
4756
4820
  const S = () => {
4757
- m(""), x([]), b(-1), p(!1), r("");
4821
+ m(""), x([]), y(-1), p(!1), r("");
4758
4822
  }, C = (v) => {
4759
4823
  m(v), p(!isEmpty(v)), c(!0), w(v);
4760
4824
  };
@@ -4765,28 +4829,28 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4765
4829
  "input",
4766
4830
  {
4767
4831
  type: "text",
4768
- value: f,
4832
+ value: h,
4769
4833
  onChange: (v) => C(v.target.value),
4770
4834
  onKeyDown: j,
4771
4835
  placeholder: a(`Search ${E ?? ""}`),
4772
4836
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4773
4837
  }
4774
4838
  ),
4775
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: f && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4839
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4776
4840
  ] }),
4777
- (i || !isEmpty(h) || d && isEmpty(h)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
4841
+ (i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
4778
4842
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
4779
4843
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
4780
- ] }) : d && isEmpty(h) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4844
+ ] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4781
4845
  a("No results found for"),
4782
4846
  ' "',
4783
- f,
4847
+ h,
4784
4848
  '"'
4785
- ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(h == null ? void 0 : h.slice(0, 20), (v, k) => /* @__PURE__ */ jsxs(
4849
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(f == null ? void 0 : f.slice(0, 20), (v, k) => /* @__PURE__ */ jsxs(
4786
4850
  "li",
4787
4851
  {
4788
4852
  onClick: () => _(v),
4789
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : k === y ? "bg-gray-100" : "hover:bg-gray-100"}`,
4853
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : k === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
4790
4854
  children: [
4791
4855
  v.name,
4792
4856
  " ",
@@ -4879,26 +4943,26 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4879
4943
  }, [a]), useEffect(() => {
4880
4944
  u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
4881
4945
  }, [o, u]);
4882
- const f = () => {
4946
+ const h = () => {
4883
4947
  const x = findIndex(u, { _id: g });
4884
4948
  if (x > -1) {
4885
- const y = (x + 1) % u.length, b = get(u, [y, "_id"]);
4886
- if (!b) return;
4887
- n({ ...o, currentSlide: b }), c([b]);
4949
+ const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
4950
+ if (!y) return;
4951
+ n({ ...o, currentSlide: y }), c([y]);
4888
4952
  }
4889
4953
  }, m = () => {
4890
4954
  const x = findIndex(u, { _id: g });
4891
4955
  if (x > -1) {
4892
- const y = (x - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
4893
- if (!b) return;
4894
- n({ ...o, currentSlide: b }), c([b]);
4956
+ const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
4957
+ if (!y) return;
4958
+ n({ ...o, currentSlide: y }), c([y]);
4895
4959
  }
4896
- }, h = () => {
4960
+ }, f = () => {
4897
4961
  const x = i(
4898
4962
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4899
4963
  p == null ? void 0 : p._id
4900
- ), y = x == null ? void 0 : x._id;
4901
- y && (n({ ...o, currentSlide: y }), c([y]));
4964
+ ), b = x == null ? void 0 : x._id;
4965
+ b && (n({ ...o, currentSlide: b }), c([b]));
4902
4966
  };
4903
4967
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4904
4968
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
@@ -4911,11 +4975,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4911
4975
  "/",
4912
4976
  u.length
4913
4977
  ] }) : "-" }),
4914
- /* @__PURE__ */ jsx("button", { onClick: f, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
4978
+ /* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
4915
4979
  /* @__PURE__ */ jsxs(
4916
4980
  "button",
4917
4981
  {
4918
- onClick: h,
4982
+ onClick: f,
4919
4983
  className: "flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",
4920
4984
  children: [
4921
4985
  /* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
@@ -4977,8 +5041,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4977
5041
  className: "text-xs",
4978
5042
  pattern: "[0-9]*",
4979
5043
  onChange: (x) => {
4980
- let y = x.target.value;
4981
- y.length && (y = y.replace("-", "")), n({ ...o, autoplayInterval: y });
5044
+ let b = x.target.value;
5045
+ b.length && (b = b.replace("-", "")), n({ ...o, autoplayInterval: b });
4982
5046
  }
4983
5047
  }
4984
5048
  )
@@ -5015,15 +5079,15 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5015
5079
  required: p,
5016
5080
  schema: u,
5017
5081
  formData: g,
5018
- onChange: f
5082
+ onChange: h
5019
5083
  }) => {
5020
- const { selectedLang: m, fallbackLang: h, languages: x } = useLanguages(), y = isEmpty(x) ? "" : isEmpty(m) ? h : m, b = get(LANGUAGES, y, y), A = usePageExternalData(), E = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = get(w, [E == null ? void 0 : E._type, "i18nProps"], []) || [], [j, S] = useState(null), C = useCallback(
5084
+ const { selectedLang: m, fallbackLang: f, languages: x } = useLanguages(), b = isEmpty(x) ? "" : isEmpty(m) ? f : m, y = get(LANGUAGES, b, b), A = usePageExternalData(), E = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = get(w, [E == null ? void 0 : E._type, "i18nProps"], []) || [], [j, S] = useState(null), C = useCallback(
5021
5085
  (k) => {
5022
- const B = (N) => /[.,!?;:]/.test(N), T = (N, D, $) => {
5086
+ const B = (N) => /[.,!?;:]/.test(N), T = (N, D, M) => {
5023
5087
  let R = "", O = "";
5024
- const M = D > 0 ? N[D - 1] : "", H = D < N.length ? N[D] : "";
5025
- return D > 0 && (M === "." || !B(M) && M !== " ") && (R = " "), D < N.length && !B(H) && H !== " " && (O = " "), {
5026
- text: R + $ + O,
5088
+ const $ = D > 0 ? N[D - 1] : "", H = D < N.length ? N[D] : "";
5089
+ return D > 0 && ($ === "." || !B($) && $ !== " ") && (R = " "), D < N.length && !B(H) && H !== " " && (O = " "), {
5090
+ text: R + M + O,
5027
5091
  prefixLength: R.length,
5028
5092
  suffixLength: O.length
5029
5093
  };
@@ -5035,31 +5099,31 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5035
5099
  if (N) {
5036
5100
  const D = `{{${k}}}`;
5037
5101
  N.commands.focus();
5038
- const { from: $, to: R } = N.state.selection;
5039
- if ($ !== R)
5102
+ const { from: M, to: R } = N.state.selection;
5103
+ if (M !== R)
5040
5104
  N.chain().deleteSelection().insertContent(D).run();
5041
5105
  else {
5042
- const { state: M } = N, H = M.selection.from, F = M.doc.textBetween(Math.max(0, H - 1), H), U = M.doc.textBetween(H, Math.min(H + 1, M.doc.content.size));
5106
+ const { state: $ } = N, H = $.selection.from, F = $.doc.textBetween(Math.max(0, H - 1), H), U = $.doc.textBetween(H, Math.min(H + 1, $.doc.content.size));
5043
5107
  let z = "";
5044
5108
  H > 0 && F !== " " && !B(F) && (z = " ");
5045
5109
  let W = "";
5046
5110
  U && U !== " " && !B(U) && (W = " "), N.chain().insertContent(z + D + W).run();
5047
5111
  }
5048
- setTimeout(() => f(N.getHTML(), {}, o), 100);
5112
+ setTimeout(() => h(N.getHTML(), {}, o), 100);
5049
5113
  return;
5050
5114
  }
5051
5115
  } else {
5052
- const N = I, D = N.selectionStart || 0, $ = N.value || "", R = N.selectionEnd || D;
5116
+ const N = I, D = N.selectionStart || 0, M = N.value || "", R = N.selectionEnd || D;
5053
5117
  if (R > D) {
5054
- const U = `{{${k}}}`, { text: z } = T($, D, U), W = $.slice(0, D) + z + $.slice(R);
5055
- f(W, {}, o);
5118
+ const U = `{{${k}}}`, { text: z } = T(M, D, U), W = M.slice(0, D) + z + M.slice(R);
5119
+ h(W, {}, o);
5056
5120
  return;
5057
5121
  }
5058
- const M = `{{${k}}}`, { text: H } = T($, D, M), F = $.slice(0, D) + H + $.slice(D);
5059
- f(F, {}, o);
5122
+ const $ = `{{${k}}}`, { text: H } = T(M, D, $), F = M.slice(0, D) + H + M.slice(D);
5123
+ h(F, {}, o);
5060
5124
  }
5061
5125
  },
5062
- [o, f, g, E == null ? void 0 : E._id]
5126
+ [o, h, g, E == null ? void 0 : E._id]
5063
5127
  );
5064
5128
  if (d)
5065
5129
  return null;
@@ -5098,7 +5162,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5098
5162
  " ",
5099
5163
  v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5100
5164
  " ",
5101
- b
5165
+ y
5102
5166
  ] }),
5103
5167
  p && u.type !== "object" ? " *" : null
5104
5168
  ] }),
@@ -5115,8 +5179,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5115
5179
  /* @__PURE__ */ jsx("span", { children: "Add" })
5116
5180
  ] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
5117
5181
  const { selectedLang: i } = useLanguages(), [c] = useAtom$1(chaiRjsfWidgetsAtom), [d] = useAtom$1(chaiRjsfFieldsAtom), [p] = useAtom$1(chaiRjsfTemplatesAtom), u = useThrottledCallback(
5118
- async ({ formData: g }, f) => {
5119
- l({ formData: g }, f);
5182
+ async ({ formData: g }, h) => {
5183
+ l({ formData: g }, h);
5120
5184
  },
5121
5185
  [l, i],
5122
5186
  400
@@ -5155,9 +5219,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5155
5219
  uiSchema: r,
5156
5220
  schema: n,
5157
5221
  formData: a,
5158
- onChange: ({ formData: g }, f) => {
5159
- if (!f || o !== (g == null ? void 0 : g._id)) return;
5160
- const m = take(f.split("."), 2).join(".").replace("root.", "");
5222
+ onChange: ({ formData: g }, h) => {
5223
+ if (!h || o !== (g == null ? void 0 : g._id)) return;
5224
+ const m = take(h.split("."), 2).join(".").replace("root.", "");
5161
5225
  u({ formData: g }, m);
5162
5226
  }
5163
5227
  },
@@ -5201,16 +5265,16 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5201
5265
  }), a;
5202
5266
  };
5203
5267
  function BlockSettings() {
5204
- const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), f = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, f), h = ({ formData: j }, S, C) => {
5268
+ const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), f = ({ formData: j }, S, C) => {
5205
5269
  S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(j, S) }, C);
5206
5270
  }, x = useCallback(
5207
5271
  debounce(({ formData: j }, S, C) => {
5208
- h({ formData: j }, S, C), d(j);
5272
+ f({ formData: j }, S, C), d(j);
5209
5273
  }, 1500),
5210
5274
  [n == null ? void 0 : n._id, o]
5211
- ), y = ({ formData: j }, S) => {
5275
+ ), b = ({ formData: j }, S) => {
5212
5276
  S && (r([n._id], { [S]: get(j, S) }), x({ formData: j }, S, { [S]: get(c, S) }));
5213
- }, b = ({ formData: j }, S) => {
5277
+ }, y = ({ formData: j }, S) => {
5214
5278
  S && (r([g._id], { [S]: get(j, S) }), x({ formData: j }, S, { [S]: get(c, S) }));
5215
5279
  };
5216
5280
  keys(get(i, "_bindings", {}));
@@ -5248,7 +5312,7 @@ function BlockSettings() {
5248
5312
  JSONForm,
5249
5313
  {
5250
5314
  blockId: g == null ? void 0 : g._id,
5251
- onChange: b,
5315
+ onChange: y,
5252
5316
  formData: m,
5253
5317
  schema: w,
5254
5318
  uiSchema: _
@@ -5259,7 +5323,7 @@ function BlockSettings() {
5259
5323
  JSONForm,
5260
5324
  {
5261
5325
  blockId: n == null ? void 0 : n._id,
5262
- onChange: y,
5326
+ onChange: b,
5263
5327
  formData: i,
5264
5328
  schema: A,
5265
5329
  uiSchema: E
@@ -5367,50 +5431,50 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5367
5431
  canvas: n = !1,
5368
5432
  tooltip: r = !0
5369
5433
  }) => {
5370
- const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: f } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), h = (b) => {
5371
- u.includes(b) ? u.length > 2 && g(u.filter((A) => A !== b)) : g((A) => [...A, b]);
5372
- }, x = (b) => {
5373
- n || l(b), c(b);
5374
- }, y = getBreakpointValue(n ? i : a).toLowerCase();
5375
- return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
5434
+ const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (y) => {
5435
+ u.includes(y) ? u.length > 2 && g(u.filter((A) => A !== y)) : g((A) => [...A, y]);
5436
+ }, x = (y) => {
5437
+ n || l(y), c(y);
5438
+ }, b = getBreakpointValue(n ? i : a).toLowerCase();
5439
+ return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (y) => /* @__PURE__ */ createElement(
5376
5440
  BreakpointCard,
5377
5441
  {
5378
5442
  canvas: n,
5379
- ...b,
5443
+ ...y,
5380
5444
  onClick: x,
5381
- key: b.breakpoint,
5382
- currentBreakpoint: y
5445
+ key: y.breakpoint,
5446
+ currentBreakpoint: b
5383
5447
  }
5384
5448
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
5385
5449
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
5386
- m.filter((b) => includes(u, toUpper(b.breakpoint))),
5387
- (b) => /* @__PURE__ */ createElement(
5450
+ m.filter((y) => includes(u, toUpper(y.breakpoint))),
5451
+ (y) => /* @__PURE__ */ createElement(
5388
5452
  BreakpointCard,
5389
5453
  {
5390
5454
  canvas: n,
5391
5455
  openDelay: o,
5392
5456
  tooltip: r,
5393
- ...b,
5457
+ ...y,
5394
5458
  onClick: x,
5395
- key: b.breakpoint,
5396
- currentBreakpoint: y
5459
+ key: y.breakpoint,
5460
+ currentBreakpoint: b
5397
5461
  }
5398
5462
  )
5399
5463
  ) }),
5400
5464
  /* @__PURE__ */ jsxs(DropdownMenu, { children: [
5401
5465
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer px-2.5 hover:opacity-80", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "scale-90 transform" }) }) }),
5402
5466
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
5403
- /* @__PURE__ */ jsx(DropdownMenuLabel, { children: f("Screen sizes") }),
5467
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: h("Screen sizes") }),
5404
5468
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
5405
- map(m, (b) => /* @__PURE__ */ jsx(
5469
+ map(m, (y) => /* @__PURE__ */ jsx(
5406
5470
  DropdownMenuCheckboxItem,
5407
5471
  {
5408
- disabled: b.breakpoint === "xs",
5409
- onCheckedChange: () => h(toUpper(b.breakpoint)),
5410
- checked: includes(u, toUpper(b.breakpoint)),
5411
- children: f(b.title)
5472
+ disabled: y.breakpoint === "xs",
5473
+ onCheckedChange: () => f(toUpper(y.breakpoint)),
5474
+ checked: includes(u, toUpper(y.breakpoint)),
5475
+ children: h(y.title)
5412
5476
  },
5413
- b.breakpoint
5477
+ y.breakpoint
5414
5478
  ))
5415
5479
  ] })
5416
5480
  ] })
@@ -5490,9 +5554,9 @@ const AskAIStyles = ({ blockId: o }) => {
5490
5554
  var m;
5491
5555
  (m = d.current) == null || m.focus();
5492
5556
  }, []);
5493
- const f = (m) => {
5494
- const { usage: h } = m || {};
5495
- !l && h && g(h), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
5557
+ const h = (m) => {
5558
+ const { usage: f } = m || {};
5559
+ !l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
5496
5560
  };
5497
5561
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
5498
5562
  /* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("Ask AI") }),
@@ -5506,7 +5570,7 @@ const AskAIStyles = ({ blockId: o }) => {
5506
5570
  className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
5507
5571
  rows: 4,
5508
5572
  onKeyDown: (m) => {
5509
- m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, f));
5573
+ m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, h));
5510
5574
  }
5511
5575
  }
5512
5576
  ),
@@ -5516,7 +5580,7 @@ const AskAIStyles = ({ blockId: o }) => {
5516
5580
  {
5517
5581
  disabled: i.trim().length < 5 || a,
5518
5582
  onClick: () => {
5519
- p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, f);
5583
+ p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, h);
5520
5584
  },
5521
5585
  variant: "default",
5522
5586
  className: "w-fit",
@@ -5548,17 +5612,17 @@ const AskAIStyles = ({ blockId: o }) => {
5548
5612
  };
5549
5613
  function ManualClasses() {
5550
5614
  var T;
5551
- const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [h, x] = useState(""), y = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), A = b.split(" ").filter((I) => !isEmpty(I)), E = () => {
5552
- const I = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5553
- u(f, I, !0), x("");
5615
+ const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: y } = getSplitChaiClasses(get(p, b, "")), A = y.split(" ").filter((I) => !isEmpty(I)), E = () => {
5616
+ const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5617
+ u(h, I, !0), x("");
5554
5618
  }, [w, _] = useState([]), j = ({ value: I }) => {
5555
5619
  const P = I.trim().toLowerCase(), N = P.match(/.+:/g);
5556
5620
  let D = [];
5557
5621
  if (N && N.length > 0) {
5558
- const [$] = N, R = P.replace($, "");
5559
- D = i.search(R).map((M) => ({
5560
- ...M,
5561
- item: { ...M.item, name: $ + M.item.name }
5622
+ const [M] = N, R = P.replace(M, "");
5623
+ D = i.search(R).map(($) => ({
5624
+ ...$,
5625
+ item: { ...$.item, name: M + $.item.name }
5562
5626
  }));
5563
5627
  } else
5564
5628
  D = i.search(P);
@@ -5573,18 +5637,18 @@ function ManualClasses() {
5573
5637
  autoCapitalize: "off",
5574
5638
  spellCheck: !1,
5575
5639
  placeholder: c("Enter classes separated by space"),
5576
- value: h,
5640
+ value: f,
5577
5641
  onKeyDown: (I) => {
5578
- I.key === "Enter" && h.trim() !== "" && E();
5642
+ I.key === "Enter" && f.trim() !== "" && E();
5579
5643
  },
5580
5644
  onChange: (I, { newValue: P }) => x(P),
5581
5645
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
5582
5646
  }),
5583
- [h, c, o]
5647
+ [f, c, o]
5584
5648
  ), k = (I) => {
5585
5649
  debugger;
5586
5650
  const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5587
- g(f, [I]), u(f, P, !0), r(""), l(-1);
5651
+ g(h, [I]), u(h, P, !0), r(""), l(-1);
5588
5652
  }, B = () => {
5589
5653
  if (navigator.clipboard === void 0) {
5590
5654
  toast.error(c("Clipboard not supported"));
@@ -5635,7 +5699,7 @@ function ManualClasses() {
5635
5699
  variant: "outline",
5636
5700
  className: "h-6 border-border",
5637
5701
  onClick: E,
5638
- disabled: h.trim() === "",
5702
+ disabled: f.trim() === "",
5639
5703
  size: "sm",
5640
5704
  children: /* @__PURE__ */ jsx(PlusIcon, {})
5641
5705
  }
@@ -5666,7 +5730,7 @@ function ManualClasses() {
5666
5730
  n !== I && /* @__PURE__ */ jsx(
5667
5731
  Cross2Icon,
5668
5732
  {
5669
- onClick: () => g(f, [I], !0),
5733
+ onClick: () => g(h, [I], !0),
5670
5734
  className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
5671
5735
  }
5672
5736
  )
@@ -6012,10 +6076,10 @@ const COLOR_PROP = {
6012
6076
  ringColor: "ring",
6013
6077
  ringOffsetColor: "ring-offset"
6014
6078
  }, ColorChoice = ({ property: o, onChange: n }) => {
6015
- const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), f = get(u, "2", ""), m = useCallback(
6079
+ const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), h = get(u, "2", ""), m = useCallback(
6016
6080
  // eslint-disable-next-line no-shadow
6017
- (y) => {
6018
- ["current", "inherit", "transparent", "black", "white"].includes(y) ? (c([]), p({ color: y })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: y, shade: b.shade ? b.shade : "500" })));
6081
+ (b) => {
6082
+ ["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" })));
6019
6083
  },
6020
6084
  [c, p]
6021
6085
  );
@@ -6024,10 +6088,10 @@ const COLOR_PROP = {
6024
6088
  return c([]);
6025
6089
  c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
6026
6090
  }, [g]);
6027
- const h = useCallback(
6091
+ const f = useCallback(
6028
6092
  // eslint-disable-next-line no-shadow
6029
- (y) => {
6030
- p({ color: g, shade: y });
6093
+ (b) => {
6094
+ p({ color: g, shade: b });
6031
6095
  },
6032
6096
  [g]
6033
6097
  );
@@ -6036,8 +6100,8 @@ const COLOR_PROP = {
6036
6100
  }, [r]);
6037
6101
  const { match: x } = useTailwindClassList();
6038
6102
  return useEffect(() => {
6039
- const b = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6040
- x(o, b) && n(b, o);
6103
+ const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6104
+ x(o, y) && n(y, o);
6041
6105
  }, [x, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
6042
6106
  /* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
6043
6107
  DropDown,
@@ -6078,7 +6142,7 @@ const COLOR_PROP = {
6078
6142
  ]
6079
6143
  }
6080
6144
  ) }),
6081
- /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: f, disabled: !g || !l, onChange: h, options: i }) })
6145
+ /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: f, options: i }) })
6082
6146
  ] });
6083
6147
  }, IconChoices = ({ property: o, onChange: n }) => {
6084
6148
  const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
@@ -6275,7 +6339,7 @@ const COLOR_PROP = {
6275
6339
  },
6276
6340
  a
6277
6341
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
6278
- const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [f, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [h, x] = useState(!1), [y, b] = useState(""), [A, E] = useState(!1), [w, _] = useState(!1);
6342
+ const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [b, y] = useState(""), [A, E] = useState(!1), [w, _] = useState(!1);
6279
6343
  useEffect(() => {
6280
6344
  const { value: v, unit: k } = getClassValueAndUnit(i);
6281
6345
  if (k === "") {
@@ -6291,7 +6355,7 @@ const COLOR_PROP = {
6291
6355
  x(!0);
6292
6356
  return;
6293
6357
  }
6294
- const B = get(k, "unit") !== "" ? get(k, "unit") : f;
6358
+ const B = get(k, "unit") !== "" ? get(k, "unit") : h;
6295
6359
  if (B === "auto" || B === "none") {
6296
6360
  j(`${d}${B}`);
6297
6361
  return;
@@ -6301,7 +6365,7 @@ const COLOR_PROP = {
6301
6365
  const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
6302
6366
  v ? S(I) : j(I);
6303
6367
  },
6304
- [j, S, a, f, d, u]
6368
+ [j, S, a, h, d, u]
6305
6369
  ), L = useCallback(
6306
6370
  (v) => {
6307
6371
  const k = getUserInputValues(`${a}`, u);
@@ -6320,7 +6384,7 @@ const COLOR_PROP = {
6320
6384
  },
6321
6385
  [j, a, d, u]
6322
6386
  );
6323
- return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: f === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
6387
+ return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: h === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
6324
6388
  /* @__PURE__ */ jsx(
6325
6389
  "input",
6326
6390
  {
@@ -6335,10 +6399,10 @@ const COLOR_PROP = {
6335
6399
  ] })
6336
6400
  ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
6337
6401
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
6338
- ["none", "auto"].indexOf(f) !== -1 ? null : /* @__PURE__ */ jsx(
6402
+ ["none", "auto"].indexOf(h) !== -1 ? null : /* @__PURE__ */ jsx(
6339
6403
  "input",
6340
6404
  {
6341
- readOnly: f === "class",
6405
+ readOnly: h === "class",
6342
6406
  onKeyPress: (v) => {
6343
6407
  v.key === "Enter" && C();
6344
6408
  },
@@ -6349,7 +6413,7 @@ const COLOR_PROP = {
6349
6413
  const k = parseInt$1(v.target.value);
6350
6414
  let B = isNaN$1(k) ? 0 : k;
6351
6415
  v.keyCode === 38 && (B += 1), v.keyCode === 40 && (B -= 1);
6352
- const T = `${B}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${f === "-" ? "" : f}]`;
6416
+ const T = `${B}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${h === "-" ? "" : h}]`;
6353
6417
  S(P);
6354
6418
  },
6355
6419
  onKeyUp: (v) => {
@@ -6363,10 +6427,10 @@ const COLOR_PROP = {
6363
6427
  var k;
6364
6428
  (k = v == null ? void 0 : v.target) == null || k.select(), r(!1);
6365
6429
  },
6366
- value: A ? y : a,
6430
+ value: A ? b : a,
6367
6431
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
6368
6432
  " ",
6369
- h ? "border-red-500 text-red-500" : "border-foreground/20"
6433
+ f ? "border-red-500 text-red-500" : "border-foreground/20"
6370
6434
  )
6371
6435
  }
6372
6436
  ),
@@ -6378,7 +6442,7 @@ const COLOR_PROP = {
6378
6442
  onClick: () => r(!n),
6379
6443
  className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
6380
6444
  children: [
6381
- /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: f }),
6445
+ /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: h }),
6382
6446
  u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
6383
6447
  ]
6384
6448
  }
@@ -6387,7 +6451,7 @@ const COLOR_PROP = {
6387
6451
  UnitSelection,
6388
6452
  {
6389
6453
  units: u,
6390
- current: f,
6454
+ current: h,
6391
6455
  onSelect: (v) => {
6392
6456
  r(!1), m(v), L(v);
6393
6457
  }
@@ -6395,25 +6459,25 @@ const COLOR_PROP = {
6395
6459
  ) }) })
6396
6460
  ] })
6397
6461
  ] }),
6398
- ["none", "auto"].indexOf(f) !== -1 || A ? null : /* @__PURE__ */ jsx(
6462
+ ["none", "auto"].indexOf(h) !== -1 || A ? null : /* @__PURE__ */ jsx(
6399
6463
  DragStyleButton,
6400
6464
  {
6401
6465
  onDragStart: () => E(!0),
6402
6466
  onDragEnd: (v) => {
6403
- if (b(() => ""), E(!1), isEmpty(v))
6467
+ if (y(() => ""), E(!1), isEmpty(v))
6404
6468
  return;
6405
- const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${f === "-" ? "" : f}]`;
6469
+ const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
6406
6470
  j(T);
6407
6471
  },
6408
6472
  onDrag: (v) => {
6409
6473
  if (isEmpty(v))
6410
6474
  return;
6411
- b(v);
6412
- const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${f === "-" ? "" : f}]`;
6475
+ y(v);
6476
+ const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
6413
6477
  S(T);
6414
6478
  },
6415
6479
  currentValue: a,
6416
- unit: f,
6480
+ unit: h,
6417
6481
  negative: g,
6418
6482
  cssProperty: p
6419
6483
  }
@@ -6507,7 +6571,7 @@ const COLOR_PROP = {
6507
6571
  "2xl": "1536px"
6508
6572
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6509
6573
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
6510
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), f = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(f, "fullCls", ""), [f]), b = useCallback(
6574
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(h, "fullCls", ""), [h]), y = useCallback(
6511
6575
  (S, C = !0) => {
6512
6576
  const L = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
6513
6577
  (p || u !== "") && (L.mq = "xs");
@@ -6516,11 +6580,11 @@ const COLOR_PROP = {
6516
6580
  },
6517
6581
  [x, p, g, u, l, m]
6518
6582
  ), A = useCallback(() => {
6519
- h(x, [y], !0);
6520
- }, [x, y, h]), E = useMemo(() => canChangeClass(f, g), [f, g]);
6583
+ f(x, [b], !0);
6584
+ }, [x, b, f]), E = useMemo(() => canChangeClass(h, g), [h, g]);
6521
6585
  useEffect(() => {
6522
- i(E, f);
6523
- }, [E, i, f]);
6586
+ i(E, h);
6587
+ }, [E, i, h]);
6524
6588
  const [, , w] = useScreenSizeWidth(), _ = useCallback(
6525
6589
  (S) => {
6526
6590
  w({
@@ -6533,28 +6597,28 @@ const COLOR_PROP = {
6533
6597
  }[S]);
6534
6598
  },
6535
6599
  [w]
6536
- ), j = get(f, "dark", null) === p && get(f, "mod", null) === u && get(f, "mq", null) === g;
6537
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: E, canReset: f && j, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6538
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${f && !j ? "text-foreground" : ""}`, children: n(a) }) }),
6600
+ ), j = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
6601
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: E, canReset: h && j, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6602
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !j ? "text-foreground" : ""}`, children: n(a) }) }),
6539
6603
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6540
6604
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
6541
6605
  r === "arbitrary" ? /* @__PURE__ */ jsx(
6542
6606
  AdvanceChoices,
6543
6607
  {
6544
- currentClass: get(f, "cls", ""),
6608
+ currentClass: get(h, "cls", ""),
6545
6609
  classPrefix: get(CLASS_PREFIXES, l, ""),
6546
6610
  units: c || [],
6547
- onChange: b,
6611
+ onChange: y,
6548
6612
  negative: d,
6549
6613
  cssProperty: l
6550
6614
  }
6551
6615
  ) : null,
6552
- r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: b }),
6553
- r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: b }),
6554
- r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
6555
- r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
6616
+ r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: y }),
6617
+ r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: y }),
6618
+ r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
6619
+ r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
6556
6620
  ] }),
6557
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: j ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : E && f ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6621
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: j ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : E && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6558
6622
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6559
6623
  "button",
6560
6624
  {
@@ -6566,19 +6630,19 @@ const COLOR_PROP = {
6566
6630
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
6567
6631
  "Current style is set at  ",
6568
6632
  /* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
6569
- getBreakpoint(get(f, "mq")),
6570
- p && !f.dark ? "(Light mode)" : ""
6633
+ getBreakpoint(get(h, "mq")),
6634
+ p && !h.dark ? "(Light mode)" : ""
6571
6635
  ] }),
6572
6636
  /* @__PURE__ */ jsx("br", {}),
6573
6637
  /* @__PURE__ */ jsxs(
6574
6638
  "button",
6575
6639
  {
6576
6640
  type: "button",
6577
- onClick: () => _(get(f, "mq")),
6641
+ onClick: () => _(get(h, "mq")),
6578
6642
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
6579
6643
  children: [
6580
6644
  "Switch to ",
6581
- get(f, "mq").toUpperCase()
6645
+ get(h, "mq").toUpperCase()
6582
6646
  ]
6583
6647
  }
6584
6648
  )
@@ -6595,7 +6659,7 @@ const COLOR_PROP = {
6595
6659
  units: i = basicUnits,
6596
6660
  negative: c = !1
6597
6661
  }) => {
6598
- const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), f = useCallback((m) => map(g, "property").includes(m), [g]);
6662
+ const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), h = useCallback((m) => map(g, "property").includes(m), [g]);
6599
6663
  return /* @__PURE__ */ jsxs(
6600
6664
  "div",
6601
6665
  {
@@ -6604,18 +6668,18 @@ const COLOR_PROP = {
6604
6668
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
6605
6669
  o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
6606
6670
  /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
6607
- n.map(({ label: m, key: h }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6671
+ n.map(({ label: m, key: f }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6608
6672
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6609
6673
  "button",
6610
6674
  {
6611
6675
  type: "button",
6612
- onClick: () => u(h),
6613
- className: `relative cursor-pointer rounded-full p-1 text-[8px] ${h === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6676
+ onClick: () => u(f),
6677
+ className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6614
6678
  children: [
6615
6679
  React__default.createElement("div", {
6616
- className: f(h) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6680
+ className: h(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6617
6681
  }),
6618
- React__default.createElement(get(EDITOR_ICONS, h, BoxIcon), { className: "text-inherit w-3 h-3" })
6682
+ React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
6619
6683
  ]
6620
6684
  }
6621
6685
  ) }),
@@ -6758,13 +6822,13 @@ function BlockStyling() {
6758
6822
  cssProperty: ""
6759
6823
  }), d = useThrottledCallback(
6760
6824
  (u) => {
6761
- const g = !get(i, "negative", !1), f = get(i, "cssProperty", "");
6825
+ const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
6762
6826
  let m = parseFloat(i.dragStartValue);
6763
6827
  m = isNaN(m) ? 0 : m;
6764
- let h = MAPPER[i.dragUnit];
6765
- (startsWith(f, "scale") || f === "opacity") && (h = 10);
6766
- let y = (i.dragStartY - u.pageY) / h + m;
6767
- g && y < 0 && (y = 0), f === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6828
+ let f = MAPPER[i.dragUnit];
6829
+ (startsWith(h, "scale") || h === "opacity") && (f = 10);
6830
+ let b = (i.dragStartY - u.pageY) / f + m;
6831
+ g && b < 0 && (b = 0), h === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
6768
6832
  },
6769
6833
  [i],
6770
6834
  50
@@ -6806,14 +6870,14 @@ const CoreBlock = ({
6806
6870
  parentId: r,
6807
6871
  position: a
6808
6872
  }) => {
6809
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: f } = useBlockHighlight(), m = () => {
6873
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
6810
6874
  if (console.log("addBlockToPage", o), has(o, "blocks")) {
6811
- const y = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
6812
- u(syncBlocksWithDefaults(y), r || null, a);
6875
+ const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
6876
+ u(syncBlocksWithDefaults(b), r || null, a);
6813
6877
  } else
6814
6878
  p(o, r || null, a);
6815
6879
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6816
- }, h = useFeature("dnd"), { t: x } = useTranslation();
6880
+ }, f = useFeature("dnd"), { t: x } = useTranslation();
6817
6881
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6818
6882
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6819
6883
  "button",
@@ -6821,12 +6885,12 @@ const CoreBlock = ({
6821
6885
  disabled: n,
6822
6886
  onClick: m,
6823
6887
  type: "button",
6824
- onDragStart: (y) => {
6825
- y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6826
- g([]), f();
6888
+ onDragStart: (b) => {
6889
+ b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6890
+ g([]), h();
6827
6891
  }, 200);
6828
6892
  },
6829
- draggable: h ? "true" : "false",
6893
+ draggable: f ? "true" : "false",
6830
6894
  className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
6831
6895
  children: [
6832
6896
  createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
@@ -7022,7 +7086,7 @@ const CoreBlock = ({
7022
7086
  }
7023
7087
  }
7024
7088
  }, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
7025
- var f, m, h, x, y, b, A, E;
7089
+ var h, m, f, x, b, y, A, E;
7026
7090
  if (r.type === "comment") return [];
7027
7091
  console.log("node ===>", r);
7028
7092
  let a = { _id: generateUUID() };
@@ -7063,11 +7127,11 @@ const CoreBlock = ({
7063
7127
  ];
7064
7128
  a = {
7065
7129
  ...a,
7066
- href: ((f = l.find((_) => _.key === "href")) == null ? void 0 : f.value) || "",
7130
+ href: ((h = l.find((_) => _.key === "href")) == null ? void 0 : h.value) || "",
7067
7131
  hrefType: ((m = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
7068
- autoplay: ((h = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : h.value) === "true" ? "true" : "false",
7069
- maxWidth: ((y = (x = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : y.replace("px", "")) || "",
7070
- backdropColor: ((b = l.find((_) => _.key === "data-overlay")) == null ? void 0 : b.value) || "",
7132
+ autoplay: ((f = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
7133
+ maxWidth: ((b = (x = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : b.replace("px", "")) || "",
7134
+ backdropColor: ((y = l.find((_) => _.key === "data-overlay")) == null ? void 0 : y.value) || "",
7071
7135
  galleryName: ((A = l.find((_) => _.key === "data-gall")) == null ? void 0 : A.value) || ""
7072
7136
  }, forEach(w, (_) => {
7073
7137
  has(a, `styles_attrs.${_}`) && delete a.styles_attrs[_];
@@ -7173,25 +7237,25 @@ const CoreBlock = ({
7173
7237
  error: c
7174
7238
  }), g(!0);
7175
7239
  else if (!l && Object.keys(a || {}).length > 0) {
7176
- const m = Object.entries(a).map(([x, y]) => {
7177
- const b = y, A = b.type || "partial", E = formatReadableName(A);
7240
+ const m = Object.entries(a).map(([x, b]) => {
7241
+ const y = b, A = y.type || "partial", E = formatReadableName(A);
7178
7242
  return {
7179
7243
  type: "PartialBlock",
7180
7244
  // Set the type to PartialBlock
7181
- label: formatReadableName(b.name || x),
7182
- description: b.description || "",
7245
+ label: formatReadableName(y.name || x),
7246
+ description: y.description || "",
7183
7247
  icon: Globe,
7184
7248
  group: E,
7185
7249
  // Use formatted type as group
7186
7250
  category: "partial",
7187
7251
  partialBlockId: x,
7188
7252
  // Store the original ID as partialBlockId
7189
- _name: b.name
7253
+ _name: y.name
7190
7254
  };
7191
- }), h = uniq(map(m, "group"));
7255
+ }), f = uniq(map(m, "group"));
7192
7256
  p({
7193
7257
  blocks: m,
7194
- groups: h,
7258
+ groups: f,
7195
7259
  isLoading: !1,
7196
7260
  error: null
7197
7261
  }), g(!0);
@@ -7210,7 +7274,7 @@ const CoreBlock = ({
7210
7274
  d.blocks,
7211
7275
  c
7212
7276
  ]);
7213
- const f = () => {
7277
+ const h = () => {
7214
7278
  p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
7215
7279
  };
7216
7280
  return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
@@ -7218,7 +7282,7 @@ const CoreBlock = ({
7218
7282
  /* @__PURE__ */ jsx(
7219
7283
  "button",
7220
7284
  {
7221
- onClick: f,
7285
+ onClick: h,
7222
7286
  className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
7223
7287
  children: "Refresh"
7224
7288
  }
@@ -7235,7 +7299,7 @@ const CoreBlock = ({
7235
7299
  );
7236
7300
  }, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
7237
7301
  var v;
7238
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), f = (v = find(c, (k) => k._id === r)) == null ? void 0 : v._type, [m, h] = useState("all"), [x, y] = useState(null), b = useRef(null);
7302
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (v = find(c, (k) => k._id === r)) == null ? void 0 : v._type, [m, f] = useState("all"), [x, b] = useState(null), y = useRef(null);
7239
7303
  useEffect(() => {
7240
7304
  const k = setTimeout(() => {
7241
7305
  var B;
@@ -7243,18 +7307,18 @@ const CoreBlock = ({
7243
7307
  }, 0);
7244
7308
  return () => clearTimeout(k);
7245
7309
  }, [g]), useEffect(() => {
7246
- d && (h("all"), y(null));
7247
- }, [d]), useEffect(() => (b.current = debounce((k) => {
7248
- h(k);
7310
+ d && (f("all"), b(null));
7311
+ }, [d]), useEffect(() => (y.current = debounce((k) => {
7312
+ f(k);
7249
7313
  }, 500), () => {
7250
- b.current && b.current.cancel();
7314
+ y.current && y.current.cancel();
7251
7315
  }), []);
7252
7316
  const A = useCallback((k) => {
7253
- y(k), b.current && b.current(k);
7317
+ b(k), y.current && y.current(k);
7254
7318
  }, []), E = useCallback(() => {
7255
- y(null), b.current && b.current.cancel();
7319
+ b(null), y.current && y.current.cancel();
7256
7320
  }, []), w = useCallback((k) => {
7257
- b.current && b.current.cancel(), h(k), y(null);
7321
+ y.current && y.current.cancel(), f(k), b(null);
7258
7322
  }, []), _ = useMemo(
7259
7323
  () => d ? values(n).filter(
7260
7324
  (k) => {
@@ -7326,7 +7390,7 @@ const CoreBlock = ({
7326
7390
  parentId: r,
7327
7391
  position: a,
7328
7392
  block: B,
7329
- disabled: !canAcceptChildBlock(f, B.type) || !canBeNestedInside(f, B.type)
7393
+ disabled: !canAcceptChildBlock(h, B.type) || !canBeNestedInside(h, B.type)
7330
7394
  },
7331
7395
  B.type
7332
7396
  ))
@@ -7340,10 +7404,10 @@ const CoreBlock = ({
7340
7404
  parentId: r = void 0,
7341
7405
  position: a = -1
7342
7406
  }) => {
7343
- const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), f = Object.keys(g || {}).length > 0;
7407
+ const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), h = Object.keys(g || {}).length > 0;
7344
7408
  useEffect(() => {
7345
- i === "partials" && !f && c("library");
7346
- }, [i, f, c]);
7409
+ i === "partials" && !h && c("library");
7410
+ }, [i, h, c]);
7347
7411
  const m = useCallback(() => {
7348
7412
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7349
7413
  }, []);
@@ -7355,8 +7419,8 @@ const CoreBlock = ({
7355
7419
  /* @__PURE__ */ jsxs(
7356
7420
  Tabs,
7357
7421
  {
7358
- onValueChange: (h) => {
7359
- d(""), c(h);
7422
+ onValueChange: (f) => {
7423
+ d(""), c(f);
7360
7424
  },
7361
7425
  value: i,
7362
7426
  className: "flex h-full max-h-full flex-col overflow-hidden",
@@ -7364,15 +7428,15 @@ const CoreBlock = ({
7364
7428
  /* @__PURE__ */ jsxs(TabsList, { className: "flex w-full items-center", children: [
7365
7429
  /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
7366
7430
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
7367
- f && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7431
+ h && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7368
7432
  p ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7369
- map(u, (h) => /* @__PURE__ */ jsx(TabsTrigger, { value: h.key, children: React__default.createElement(h.tab) }))
7433
+ map(u, (f) => /* @__PURE__ */ jsx(TabsTrigger, { value: f.key, children: React__default.createElement(f.tab) }))
7370
7434
  ] }),
7371
7435
  /* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7372
7436
  /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
7373
- f && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7437
+ h && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7374
7438
  p ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
7375
- map(u, (h) => /* @__PURE__ */ jsx(TabsContent, { value: h.key, children: React__default.createElement(h.tabContent, { close: m, parentId: r, position: a }) }))
7439
+ map(u, (f) => /* @__PURE__ */ jsx(TabsContent, { value: f.key, children: React__default.createElement(f.tabContent, { close: m, parentId: r, position: a }) }))
7376
7440
  ]
7377
7441
  }
7378
7442
  )
@@ -7429,10 +7493,10 @@ const BlockCard = ({
7429
7493
  parentId: r = void 0,
7430
7494
  position: a = -1
7431
7495
  }) => {
7432
- const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), f = get(o, "name", get(o, "label")), m = useFeature("dnd"), [, h] = useAtom$1(draggedBlockAtom), x = (A) => {
7496
+ const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), x = (A) => {
7433
7497
  const E = has(A, "styles_attrs.data-page-section");
7434
7498
  return A._type === "Box" && E;
7435
- }, y = useCallback(
7499
+ }, b = useCallback(
7436
7500
  async (A) => {
7437
7501
  if (A.stopPropagation(), has(o, "component")) {
7438
7502
  d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
@@ -7449,7 +7513,7 @@ const BlockCard = ({
7449
7513
  "div",
7450
7514
  {
7451
7515
  onClick: l ? () => {
7452
- } : y,
7516
+ } : b,
7453
7517
  draggable: m ? "true" : "false",
7454
7518
  onDragStart: async (A) => {
7455
7519
  const E = await c(n, o);
@@ -7463,7 +7527,7 @@ const BlockCard = ({
7463
7527
  };
7464
7528
  } else
7465
7529
  A.dataTransfer.setDragImage(new Image(), 0, 0);
7466
- h(_), setTimeout(() => {
7530
+ f(_), setTimeout(() => {
7467
7531
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7468
7532
  }, 200);
7469
7533
  }
@@ -7476,11 +7540,11 @@ const BlockCard = ({
7476
7540
  /* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
7477
7541
  /* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
7478
7542
  ] }),
7479
- o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: f }) : /* @__PURE__ */ jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: f }) })
7543
+ o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: h }) : /* @__PURE__ */ jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: h }) })
7480
7544
  ]
7481
7545
  }
7482
7546
  ) }),
7483
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: f }) })
7547
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: h }) })
7484
7548
  ] });
7485
7549
  }, libraryBlocksAtom = atom$1(
7486
7550
  {}
@@ -7495,7 +7559,7 @@ const BlockCard = ({
7495
7559
  })();
7496
7560
  }, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
7497
7561
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7498
- const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((w) => w.category === "custom"), d = l.find((w) => w.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [f, m] = useState("Hero"), h = get(g, f, []), x = useRef(null), { t: y } = useTranslation(), b = (w) => {
7562
+ const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((w) => w.category === "custom"), d = l.find((w) => w.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [h, m] = useState("Hero"), f = get(g, h, []), x = useRef(null), { t: b } = useTranslation(), y = (w) => {
7499
7563
  x.current && (clearTimeout(x.current), x.current = null), x.current = setTimeout(() => {
7500
7564
  x.current && m(w);
7501
7565
  }, 300);
@@ -7505,26 +7569,26 @@ const BlockCard = ({
7505
7569
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7506
7570
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7507
7571
  ] });
7508
- const A = filter(h, (w, _) => _ % 2 === 0), E = filter(h, (w, _) => _ % 2 === 1);
7572
+ const A = filter(f, (w, _) => _ % 2 === 0), E = filter(f, (w, _) => _ % 2 === 1);
7509
7573
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full pt-2", children: [
7510
7574
  /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
7511
7575
  /* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
7512
7576
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7513
- /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: y("Groups") }),
7577
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: b("Groups") }),
7514
7578
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7515
7579
  /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: React__default.Children.toArray(
7516
7580
  map(g, (w, _) => /* @__PURE__ */ jsxs(
7517
7581
  "div",
7518
7582
  {
7519
- onMouseEnter: () => b(_),
7583
+ onMouseEnter: () => y(_),
7520
7584
  onMouseLeave: () => clearTimeout(x.current),
7521
7585
  onClick: () => m(_),
7522
7586
  className: cn$1(
7523
7587
  "flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
7524
- _ === f ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7588
+ _ === h ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7525
7589
  ),
7526
7590
  children: [
7527
- /* @__PURE__ */ jsx("span", { children: capitalize(y(_.toLowerCase())) }),
7591
+ /* @__PURE__ */ jsx("span", { children: capitalize(b(_.toLowerCase())) }),
7528
7592
  /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
7529
7593
  ]
7530
7594
  },
@@ -7774,7 +7838,7 @@ const selectParent = (o, n) => {
7774
7838
  var P;
7775
7839
  const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
7776
7840
  let p = null;
7777
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: f } = useBlockHighlight(), { id: m, data: h, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: A, handleClick: E } = o, w = (N) => {
7841
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: f, isSelected: x, willReceiveDrop: b, isDragging: y, isEditing: A, handleClick: E } = o, w = (N) => {
7778
7842
  N.stopPropagation(), !i.includes(m) && o.toggle();
7779
7843
  }, _ = (N) => {
7780
7844
  N.isInternal && (p = N.isOpen, N.isOpen && N.close());
@@ -7790,23 +7854,23 @@ const selectParent = (o, n) => {
7790
7854
  };
7791
7855
  useEffect(() => {
7792
7856
  const N = setTimeout(() => {
7793
- y && !o.isOpen && !b && !i.includes(m) && o.toggle();
7857
+ b && !o.isOpen && !y && !i.includes(m) && o.toggle();
7794
7858
  }, 500);
7795
7859
  return () => clearTimeout(N);
7796
- }, [y, o, b]);
7860
+ }, [b, o, y]);
7797
7861
  const B = useMemo(() => {
7798
- const N = Object.keys(h), D = [];
7799
- for (let $ = 0; $ < N.length; $++)
7800
- if (N[$].endsWith("_attrs")) {
7801
- const R = h[N[$]], O = Object.keys(R).join("|");
7862
+ const N = Object.keys(f), D = [];
7863
+ for (let M = 0; M < N.length; M++)
7864
+ if (N[M].endsWith("_attrs")) {
7865
+ const R = f[N[M]], O = Object.keys(R).join("|");
7802
7866
  O.match(/x-data/) && D.push("data"), O.match(/x-on/) && D.push("event"), O.match(/x-show|x-if/) && D.push("show");
7803
7867
  }
7804
7868
  return D;
7805
- }, [h]), T = (N, D) => {
7806
- const $ = d.contentDocument || d.contentWindow.document, R = $.querySelector(`[data-block-id=${N}]`);
7869
+ }, [f]), T = (N, D) => {
7870
+ const M = d.contentDocument || d.contentWindow.document, R = M.querySelector(`[data-block-id=${N}]`);
7807
7871
  R && R.setAttribute("data-drop", D);
7808
- const O = R.getBoundingClientRect(), M = d.getBoundingClientRect();
7809
- O.top >= M.top && O.left >= M.left && O.bottom <= M.bottom && O.right <= M.right || ($.documentElement.scrollTop = R.offsetTop - M.top);
7872
+ const O = R.getBoundingClientRect(), $ = d.getBoundingClientRect();
7873
+ O.top >= $.top && O.left >= $.left && O.bottom <= $.bottom && O.right <= $.right || (M.documentElement.scrollTop = R.offsetTop - $.top);
7810
7874
  }, I = (N) => {
7811
7875
  v();
7812
7876
  const D = get(o, "parent.id");
@@ -7831,7 +7895,7 @@ const selectParent = (o, n) => {
7831
7895
  "div",
7832
7896
  {
7833
7897
  onMouseEnter: () => g(m),
7834
- onMouseLeave: () => f(),
7898
+ onMouseLeave: () => h(),
7835
7899
  onClick: k,
7836
7900
  style: n,
7837
7901
  "data-node-id": m,
@@ -7866,9 +7930,9 @@ const selectParent = (o, n) => {
7866
7930
  className: cn$1(
7867
7931
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
7868
7932
  x ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
7869
- y && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7933
+ b && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
7870
7934
  (o == null ? void 0 : o.id) === S ? "bg-purple-100" : "",
7871
- b && "opacity-20",
7935
+ y && "opacity-20",
7872
7936
  i.includes(m) ? "opacity-50" : ""
7873
7937
  ),
7874
7938
  children: [
@@ -7881,7 +7945,7 @@ const selectParent = (o, n) => {
7881
7945
  }
7882
7946
  ),
7883
7947
  /* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
7884
- /* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
7948
+ /* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
7885
7949
  A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
7886
7950
  "div",
7887
7951
  {
@@ -7890,7 +7954,7 @@ const selectParent = (o, n) => {
7890
7954
  N.stopPropagation(), o.edit(), o.deselect();
7891
7955
  },
7892
7956
  children: [
7893
- /* @__PURE__ */ jsx("span", { children: (h == null ? void 0 : h._name) || (h == null ? void 0 : h._type.split("/").pop()) }),
7957
+ /* @__PURE__ */ jsx("span", { children: (f == null ? void 0 : f._name) || (f == null ? void 0 : f._type.split("/").pop()) }),
7894
7958
  B.includes("data") && /* @__PURE__ */ jsx(FileJson, { className: "h-3 w-3 text-orange-600" }),
7895
7959
  B.includes("event") && /* @__PURE__ */ jsx(Zap, { className: "h-3 w-3 text-yellow-500" }),
7896
7960
  B.includes("show") && /* @__PURE__ */ jsx(EyeOff, { className: "h-3 w-3 text-orange-600" })
@@ -7911,7 +7975,7 @@ const selectParent = (o, n) => {
7911
7975
  ),
7912
7976
  /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: N.tooltip })
7913
7977
  ] })),
7914
- canAddChildBlock(h == null ? void 0 : h._type) && !i.includes(m) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7978
+ canAddChildBlock(f == null ? void 0 : f._type) && !i.includes(m) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7915
7979
  /* @__PURE__ */ jsx(
7916
7980
  TooltipTrigger,
7917
7981
  {
@@ -8586,14 +8650,14 @@ function QuickPrompts({ onClick: o }) {
8586
8650
  ) }) });
8587
8651
  }
8588
8652
  const AIUserPrompt = ({ blockId: o }) => {
8589
- const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), f = useRef(null), m = useRef(null);
8653
+ const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), h = useRef(null), m = useRef(null);
8590
8654
  useEffect(() => {
8591
8655
  var x;
8592
- (x = f.current) == null || x.focus();
8656
+ (x = h.current) == null || x.focus();
8593
8657
  }, []);
8594
- const h = (x) => {
8595
- const { usage: y } = x || {};
8596
- !l && y && g(y), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8658
+ const f = (x) => {
8659
+ const { usage: b } = x || {};
8660
+ !l && b && g(b), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8597
8661
  };
8598
8662
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8599
8663
  /* @__PURE__ */ jsxs(
@@ -8611,14 +8675,14 @@ const AIUserPrompt = ({ blockId: o }) => {
8611
8675
  /* @__PURE__ */ jsx(
8612
8676
  Textarea,
8613
8677
  {
8614
- ref: f,
8678
+ ref: h,
8615
8679
  value: i,
8616
8680
  onChange: (x) => c(x.target.value),
8617
8681
  placeholder: n("Ask AI to edit content"),
8618
8682
  className: "w-full",
8619
8683
  rows: 3,
8620
8684
  onKeyDown: (x) => {
8621
- x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), r("content", o, i, h));
8685
+ x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), r("content", o, i, f));
8622
8686
  }
8623
8687
  }
8624
8688
  ),
@@ -8628,7 +8692,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8628
8692
  {
8629
8693
  disabled: i.trim().length < 5 || a,
8630
8694
  onClick: () => {
8631
- m.current && clearTimeout(m.current), g(void 0), r("content", o, i, h);
8695
+ m.current && clearTimeout(m.current), g(void 0), r("content", o, i, f);
8632
8696
  },
8633
8697
  variant: "default",
8634
8698
  className: "w-fit",
@@ -8661,7 +8725,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8661
8725
  QuickPrompts,
8662
8726
  {
8663
8727
  onClick: (x) => {
8664
- m.current && clearTimeout(m.current), g(void 0), r("content", o, x, h);
8728
+ m.current && clearTimeout(m.current), g(void 0), r("content", o, x, f);
8665
8729
  }
8666
8730
  }
8667
8731
  )
@@ -8671,15 +8735,15 @@ const AIUserPrompt = ({ blockId: o }) => {
8671
8735
  ] }) }) : null
8672
8736
  ] });
8673
8737
  }, AISetContext = () => {
8674
- const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), f = useRef(null);
8738
+ const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), h = useRef(null);
8675
8739
  useEffect(() => {
8676
8740
  n && a(n);
8677
8741
  }, [n]);
8678
8742
  const m = async () => {
8679
8743
  try {
8680
- d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), f.current.click();
8681
- } catch (h) {
8682
- u(h);
8744
+ d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), h.current.click();
8745
+ } catch (f) {
8746
+ u(f);
8683
8747
  } finally {
8684
8748
  d(!1);
8685
8749
  }
@@ -8687,25 +8751,25 @@ const AIUserPrompt = ({ blockId: o }) => {
8687
8751
  return /* @__PURE__ */ jsx(
8688
8752
  Accordion,
8689
8753
  {
8690
- onValueChange: (h) => {
8691
- g(h !== "");
8754
+ onValueChange: (f) => {
8755
+ g(f !== "");
8692
8756
  },
8693
8757
  type: "single",
8694
8758
  collapsible: !0,
8695
8759
  children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
8696
- /* @__PURE__ */ jsx(AccordionTrigger, { ref: f, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
8760
+ /* @__PURE__ */ jsx(AccordionTrigger, { ref: h, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
8697
8761
  /* @__PURE__ */ jsxs(AccordionContent, { children: [
8698
8762
  /* @__PURE__ */ jsx(
8699
8763
  Textarea,
8700
8764
  {
8701
8765
  ref: l,
8702
8766
  value: r,
8703
- onChange: (h) => a(h.target.value),
8767
+ onChange: (f) => a(f.target.value),
8704
8768
  placeholder: o("Tell about this page eg this page is about"),
8705
8769
  className: "mt-1 w-full",
8706
8770
  rows: 10,
8707
- onKeyDown: (h) => {
8708
- h.key === "Enter" && (h.preventDefault(), m());
8771
+ onKeyDown: (f) => {
8772
+ f.key === "Enter" && (f.preventDefault(), m());
8709
8773
  }
8710
8774
  }
8711
8775
  ),
@@ -8903,11 +8967,11 @@ const AiAssistant = () => {
8903
8967
  preloadedAttributes: n = [],
8904
8968
  onAttributesChange: r
8905
8969
  }) {
8906
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [f, m] = useState(""), h = useRef(null), x = useRef(null), y = usePageExternalData();
8970
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), f = useRef(null), x = useRef(null), b = usePageExternalData();
8907
8971
  useEffect(() => {
8908
8972
  l(n);
8909
8973
  }, [n]);
8910
- const b = () => {
8974
+ const y = () => {
8911
8975
  if (i.startsWith("@")) {
8912
8976
  m("Attribute keys cannot start with '@'");
8913
8977
  return;
@@ -8931,7 +8995,7 @@ const AiAssistant = () => {
8931
8995
  S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), m("");
8932
8996
  }
8933
8997
  }, _ = (S) => {
8934
- S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : b());
8998
+ S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : y());
8935
8999
  }, j = useCallback((S) => {
8936
9000
  const C = (k) => /[.,!?;:]/.test(k), L = (k, B, T) => {
8937
9001
  let I = "", P = "";
@@ -8945,7 +9009,7 @@ const AiAssistant = () => {
8945
9009
  if (v) {
8946
9010
  const k = v.selectionStart || 0, B = v.value || "", T = v.selectionEnd || k;
8947
9011
  if (T > k) {
8948
- const $ = `{{${S}}}`, { text: R } = L(B, k, $), O = B.slice(0, k) + R + B.slice(T);
9012
+ const M = `{{${S}}}`, { text: R } = L(B, k, M), O = B.slice(0, k) + R + B.slice(T);
8949
9013
  p(O);
8950
9014
  return;
8951
9015
  }
@@ -8958,7 +9022,7 @@ const AiAssistant = () => {
8958
9022
  "form",
8959
9023
  {
8960
9024
  onSubmit: (S) => {
8961
- S.preventDefault(), u !== null ? w() : b();
9025
+ S.preventDefault(), u !== null ? w() : y();
8962
9026
  },
8963
9027
  className: "space-y-3",
8964
9028
  children: [
@@ -8972,7 +9036,7 @@ const AiAssistant = () => {
8972
9036
  autoCorrect: "off",
8973
9037
  spellCheck: "false",
8974
9038
  id: "attrKey",
8975
- ref: h,
9039
+ ref: f,
8976
9040
  value: i,
8977
9041
  onChange: (S) => c(S.target.value),
8978
9042
  placeholder: "Enter Key",
@@ -8983,7 +9047,7 @@ const AiAssistant = () => {
8983
9047
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
8984
9048
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
8985
9049
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
8986
- !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: j })
9050
+ !isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: j })
8987
9051
  ] }),
8988
9052
  /* @__PURE__ */ jsx(
8989
9053
  Textarea,
@@ -9004,7 +9068,7 @@ const AiAssistant = () => {
9004
9068
  ] })
9005
9069
  ] }),
9006
9070
  /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !i.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: u !== null ? "Save" : "Add" }) }),
9007
- f && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: f })
9071
+ h && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: h })
9008
9072
  ]
9009
9073
  }
9010
9074
  ),
@@ -9215,8 +9279,8 @@ const RootLayout = () => {
9215
9279
  x.preventDefault();
9216
9280
  }, u = (x) => {
9217
9281
  n(o === x ? null : x);
9218
- }, g = useSidebarMenuItems(), { t: f } = useTranslation(), m = [...g, ...c], h = useBuilderProp("htmlDir", "ltr");
9219
- return /* @__PURE__ */ jsx("div", { dir: h, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9282
+ }, g = useSidebarMenuItems(), { t: h } = useTranslation(), m = [...g, ...c], f = useBuilderProp("htmlDir", "ltr");
9283
+ return /* @__PURE__ */ jsx("div", { dir: f, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9220
9284
  /* @__PURE__ */ jsxs(
9221
9285
  "div",
9222
9286
  {
@@ -9226,21 +9290,21 @@ const RootLayout = () => {
9226
9290
  /* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
9227
9291
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9228
9292
  /* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9229
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: m.map((x, y) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9293
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: m.map((x, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9230
9294
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
9231
9295
  Button,
9232
9296
  {
9233
- variant: o === y ? "default" : "ghost",
9297
+ variant: o === b ? "default" : "ghost",
9234
9298
  className: "mb-2 rounded-lg p-2 transition-colors",
9235
- onClick: () => u(y),
9299
+ onClick: () => u(b),
9236
9300
  children: get(x, "icon", null)
9237
9301
  },
9238
- y
9302
+ b
9239
9303
  ) }),
9240
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(x.label) }) })
9241
- ] }, "button" + y)) }),
9304
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h(x.label) }) })
9305
+ ] }, "button" + b)) }),
9242
9306
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9243
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((x, y) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(x, {}) }, `sidebar-component-${y}`)) })
9307
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((x, b) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(x, {}) }, `sidebar-component-${b}`)) })
9244
9308
  ] }),
9245
9309
  /* @__PURE__ */ jsx(
9246
9310
  motion.div,
@@ -9256,7 +9320,7 @@ const RootLayout = () => {
9256
9320
  className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(m, `${o}.isInternal`, !1) ? "" : "w-64"}`,
9257
9321
  children: [
9258
9322
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(m, `${o}.icon`, null) }),
9259
- /* @__PURE__ */ jsx("span", { children: f(m[o].label) })
9323
+ /* @__PURE__ */ jsx("span", { children: h(m[o].label) })
9260
9324
  ]
9261
9325
  }
9262
9326
  ),
@@ -9279,11 +9343,11 @@ const RootLayout = () => {
9279
9343
  /* @__PURE__ */ jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between gap-2", children: l === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9280
9344
  /* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
9281
9345
  " ",
9282
- f("AI Assistant")
9346
+ h("AI Assistant")
9283
9347
  ] }) }) : l === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
9284
9348
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
9285
9349
  /* @__PURE__ */ jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
9286
- f("Theme Settings")
9350
+ h("Theme Settings")
9287
9351
  ] }),
9288
9352
  /* @__PURE__ */ jsx(
9289
9353
  Button,