@chaibuilder/sdk 2.0.0-beta.108 → 2.0.0-beta.110

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
@@ -6,7 +6,7 @@ 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
7
  import { S as Skeleton, B as Button, al as Label, X as Dialog, Y as DialogTrigger, Z as DialogContent, am as Popover, az as Tooltip, aA as TooltipTrigger, an as PopoverTrigger, aB as TooltipContent, ao as PopoverContent, v as Command, x as CommandInput, y as CommandList, z as CommandEmpty, D as CommandGroup, E as CommandItem, _ as DialogHeader, a0 as DialogTitle, n as Badge, a2 as DropdownMenu, a3 as DropdownMenuTrigger, a4 as DropdownMenuContent, a8 as DropdownMenuLabel, a9 as DropdownMenuSeparator, a6 as DropdownMenuCheckboxItem, ah as HoverCard, ai as HoverCardTrigger, aj as HoverCardContent, ay as Textarea, ak as Input$1, aD as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, ap as ScrollArea, ab as DropdownMenuGroup, a5 as DropdownMenuItem, aa as DropdownMenuShortcut, A as Accordion, C as Card, q as CardHeader, t as CardDescription, u as CardContent, r as CardFooter, au as Tabs, av as TabsList, aw as TabsTrigger, ax as TabsContent, H as ContextMenu, I as ContextMenuTrigger, J as ContextMenuContent, K as ContextMenuItem, 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, at as Switch, ar as Separator, aC as TooltipProvider, as as Toaster } from "./tooltip-CuxBhGWF.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, each, set, first, get, isObject, memoize, compact, isEmpty, noop, includes, without, keys, range, values, flattenDeep, 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, 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";
10
10
  import { Provider as Provider$1 } from "react-wrap-balancer";
11
11
  import { useTranslation, initReactI18next } from "react-i18next";
12
12
  import { useTranslation as Ve } from "react-i18next";
@@ -94,194 +94,194 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
94
94
  for (const i of n.p)
95
95
  l.add(i);
96
96
  return l;
97
- }, 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 = (f, ...h) => f.read(...h), p = (f, ...h) => f.write(...h), u = (f, h) => {
98
- var b;
99
- return (b = f.unstable_onInit) == null ? void 0 : b.call(f, h);
100
- }, g = (f, h) => {
101
- var b;
102
- return (b = f.onMount) == null ? void 0 : b.call(f, h);
103
- }, ...m) => {
104
- const f = m[0] || ((w) => {
97
+ }, 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) => {
98
+ var x;
99
+ return (x = m.unstable_onInit) == null ? void 0 : x.call(m, h);
100
+ }, g = (m, h) => {
101
+ var x;
102
+ return (x = m.onMount) == null ? void 0 : x.call(m, h);
103
+ }, ...f) => {
104
+ const m = f[0] || ((w) => {
105
105
  let L = o.get(w);
106
106
  return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(w, L), u == null || u(w, _)), L;
107
- }), h = m[1] || (() => {
107
+ }), h = f[1] || (() => {
108
108
  let w, L;
109
- const k = (v) => {
109
+ const v = (k) => {
110
110
  try {
111
- v();
112
- } catch (N) {
113
- w || (w = !0, L = N);
111
+ k();
112
+ } catch (E) {
113
+ w || (w = !0, L = E);
114
114
  }
115
115
  };
116
116
  do {
117
- c.f && k(c.f);
118
- const v = /* @__PURE__ */ new Set(), N = v.add.bind(v);
117
+ c.f && v(c.f);
118
+ const k = /* @__PURE__ */ new Set(), E = k.add.bind(k);
119
119
  a.forEach((T) => {
120
120
  var I;
121
- return (I = n.get(T)) == null ? void 0 : I.l.forEach(N);
122
- }), a.clear(), i.forEach(N), i.clear(), l.forEach(N), l.clear(), v.forEach(k), a.size && b();
121
+ return (I = n.get(T)) == null ? void 0 : I.l.forEach(E);
122
+ }), a.clear(), i.forEach(E), i.clear(), l.forEach(E), l.clear(), k.forEach(v), a.size && x();
123
123
  } while (a.size || i.size || l.size);
124
124
  if (w)
125
125
  throw L;
126
- }), b = m[2] || (() => {
127
- const w = [], L = /* @__PURE__ */ new WeakSet(), k = /* @__PURE__ */ new WeakSet(), v = Array.from(a);
128
- for (; v.length; ) {
129
- const N = v[v.length - 1], T = f(N);
130
- if (k.has(N)) {
131
- v.pop();
126
+ }), x = f[2] || (() => {
127
+ const w = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
128
+ for (; k.length; ) {
129
+ const E = k[k.length - 1], T = m(E);
130
+ if (v.has(E)) {
131
+ k.pop();
132
132
  continue;
133
133
  }
134
- if (L.has(N)) {
135
- r.get(N) === T.n && w.push([N, T]), k.add(N), v.pop();
134
+ if (L.has(E)) {
135
+ r.get(E) === T.n && w.push([E, T]), v.add(E), k.pop();
136
136
  continue;
137
137
  }
138
- L.add(N);
139
- for (const I of getMountedOrPendingDependents(N, T, n))
140
- L.has(I) || v.push(I);
138
+ L.add(E);
139
+ for (const I of getMountedOrPendingDependents(E, T, n))
140
+ L.has(I) || k.push(I);
141
141
  }
142
- for (let N = w.length - 1; N >= 0; --N) {
143
- const [T, I] = w[N];
142
+ for (let E = w.length - 1; E >= 0; --E) {
143
+ const [T, I] = w[E];
144
144
  let R = !1;
145
- for (const E of I.d.keys())
146
- if (E !== T && a.has(E)) {
145
+ for (const N of I.d.keys())
146
+ if (N !== T && a.has(N)) {
147
147
  R = !0;
148
148
  break;
149
149
  }
150
- R && (x(T), j(T)), r.delete(T);
150
+ R && (b(T), j(T)), r.delete(T);
151
151
  }
152
- }), x = m[3] || ((w) => {
153
- var L, k;
154
- const v = f(w);
155
- if (isAtomStateInitialized(v) && (n.has(w) && r.get(w) !== v.n || Array.from(v.d).every(
152
+ }), b = f[3] || ((w) => {
153
+ var L, v;
154
+ const k = m(w);
155
+ if (isAtomStateInitialized(k) && (n.has(w) && r.get(w) !== k.n || Array.from(k.d).every(
156
156
  ([P, O]) => (
157
157
  // Recursively, read the atom state of the dependency, and
158
158
  // check if the atom epoch number is unchanged
159
- x(P).n === O
159
+ b(P).n === O
160
160
  )
161
161
  )))
162
- return v;
163
- v.d.clear();
164
- let N = !0;
162
+ return k;
163
+ k.d.clear();
164
+ let E = !0;
165
165
  const T = () => {
166
- n.has(w) && (j(w), b(), h());
166
+ n.has(w) && (j(w), x(), h());
167
167
  }, I = (P) => {
168
168
  var O;
169
169
  if (isSelfAtom(w, P)) {
170
- const H = f(P);
170
+ const H = m(P);
171
171
  if (!isAtomStateInitialized(H))
172
172
  if (hasInitialValue(P))
173
- setAtomStateValueOrPromise(P, P.init, f);
173
+ setAtomStateValueOrPromise(P, P.init, m);
174
174
  else
175
175
  throw new Error("no atom init");
176
176
  return returnAtomValue(H);
177
177
  }
178
- const $ = x(P);
178
+ const $ = b(P);
179
179
  try {
180
180
  return returnAtomValue($);
181
181
  } finally {
182
- v.d.set(P, $.n), isPendingPromise(v.v) && addPendingPromiseToDependency(w, v.v, $), (O = n.get(P)) == null || O.t.add(w), N || T();
182
+ k.d.set(P, $.n), isPendingPromise(k.v) && addPendingPromiseToDependency(w, k.v, $), (O = n.get(P)) == null || O.t.add(w), E || T();
183
183
  }
184
184
  };
185
- let R, E;
185
+ let R, N;
186
186
  const D = {
187
187
  get signal() {
188
188
  return R || (R = new AbortController()), R.signal;
189
189
  },
190
190
  get setSelf() {
191
- return !E && isActuallyWritableAtom(w) && (E = (...P) => {
192
- if (!N)
191
+ return !N && isActuallyWritableAtom(w) && (N = (...P) => {
192
+ if (!E)
193
193
  try {
194
- return A(w, ...P);
194
+ return B(w, ...P);
195
195
  } finally {
196
- b(), h();
196
+ x(), h();
197
197
  }
198
- }), E;
198
+ }), N;
199
199
  }
200
- }, M = v.n;
200
+ }, M = k.n;
201
201
  try {
202
202
  const P = d(w, I, D);
203
- return setAtomStateValueOrPromise(w, P, f), isPromiseLike$2(P) && ((L = P.onCancel) == null || L.call(P, () => R == null ? void 0 : R.abort()), P.then(
203
+ return setAtomStateValueOrPromise(w, P, m), isPromiseLike$2(P) && ((L = P.onCancel) == null || L.call(P, () => R == null ? void 0 : R.abort()), P.then(
204
204
  T,
205
205
  T
206
- )), v;
206
+ )), k;
207
207
  } catch (P) {
208
- return delete v.v, v.e = P, ++v.n, v;
208
+ return delete k.v, k.e = P, ++k.n, k;
209
209
  } finally {
210
- N = !1, M !== v.n && r.get(w) === M && (r.set(w, v.n), a.add(w), (k = c.c) == null || k.call(c, w));
210
+ E = !1, M !== k.n && r.get(w) === M && (r.set(w, k.n), a.add(w), (v = c.c) == null || v.call(c, w));
211
211
  }
212
- }), y = m[4] || ((w) => {
212
+ }), y = f[4] || ((w) => {
213
213
  const L = [w];
214
214
  for (; L.length; ) {
215
- const k = L.pop(), v = f(k);
216
- for (const N of getMountedOrPendingDependents(k, v, n)) {
217
- const T = f(N);
218
- r.set(N, T.n), L.push(N);
215
+ const v = L.pop(), k = m(v);
216
+ for (const E of getMountedOrPendingDependents(v, k, n)) {
217
+ const T = m(E);
218
+ r.set(E, T.n), L.push(E);
219
219
  }
220
220
  }
221
- }), A = m[5] || ((w, ...L) => {
222
- let k = !0;
223
- const v = (T) => returnAtomValue(x(T)), N = (T, ...I) => {
221
+ }), B = f[5] || ((w, ...L) => {
222
+ let v = !0;
223
+ const k = (T) => returnAtomValue(b(T)), E = (T, ...I) => {
224
224
  var R;
225
- const E = f(T);
225
+ const N = m(T);
226
226
  try {
227
227
  if (isSelfAtom(w, T)) {
228
228
  if (!hasInitialValue(T))
229
229
  throw new Error("atom not writable");
230
- const D = E.n, M = I[0];
231
- setAtomStateValueOrPromise(T, M, f), j(T), D !== E.n && (a.add(T), (R = c.c) == null || R.call(c, T), y(T));
230
+ const D = N.n, M = I[0];
231
+ setAtomStateValueOrPromise(T, M, m), j(T), D !== N.n && (a.add(T), (R = c.c) == null || R.call(c, T), y(T));
232
232
  return;
233
233
  } else
234
- return A(T, ...I);
234
+ return B(T, ...I);
235
235
  } finally {
236
- k || (b(), h());
236
+ v || (x(), h());
237
237
  }
238
238
  };
239
239
  try {
240
- return p(w, v, N, ...L);
240
+ return p(w, k, E, ...L);
241
241
  } finally {
242
- k = !1;
242
+ v = !1;
243
243
  }
244
- }), j = m[6] || ((w) => {
244
+ }), j = f[6] || ((w) => {
245
245
  var L;
246
- const k = f(w), v = n.get(w);
247
- if (v && !isPendingPromise(k.v)) {
248
- for (const [N, T] of k.d)
249
- if (!v.d.has(N)) {
250
- const I = f(N);
251
- C(N).t.add(w), v.d.add(N), T !== I.n && (a.add(N), (L = c.c) == null || L.call(c, N), y(N));
246
+ const v = m(w), k = n.get(w);
247
+ if (k && !isPendingPromise(v.v)) {
248
+ for (const [E, T] of v.d)
249
+ if (!k.d.has(E)) {
250
+ const I = m(E);
251
+ C(E).t.add(w), k.d.add(E), T !== I.n && (a.add(E), (L = c.c) == null || L.call(c, E), y(E));
252
252
  }
253
- for (const N of v.d || [])
254
- if (!k.d.has(N)) {
255
- v.d.delete(N);
256
- const T = S(N);
253
+ for (const E of k.d || [])
254
+ if (!v.d.has(E)) {
255
+ k.d.delete(E);
256
+ const T = S(E);
257
257
  T == null || T.t.delete(w);
258
258
  }
259
259
  }
260
- }), C = m[7] || ((w) => {
260
+ }), C = f[7] || ((w) => {
261
261
  var L;
262
- const k = f(w);
263
- let v = n.get(w);
264
- if (!v) {
265
- x(w);
266
- for (const N of k.d.keys())
267
- C(N).t.add(w);
268
- if (v = {
262
+ const v = m(w);
263
+ let k = n.get(w);
264
+ if (!k) {
265
+ b(w);
266
+ for (const E of v.d.keys())
267
+ C(E).t.add(w);
268
+ if (k = {
269
269
  l: /* @__PURE__ */ new Set(),
270
- d: new Set(k.d.keys()),
270
+ d: new Set(v.d.keys()),
271
271
  t: /* @__PURE__ */ new Set()
272
- }, n.set(w, v), (L = c.m) == null || L.call(c, w), isActuallyWritableAtom(w)) {
273
- const N = () => {
272
+ }, n.set(w, k), (L = c.m) == null || L.call(c, w), isActuallyWritableAtom(w)) {
273
+ const E = () => {
274
274
  let T = !0;
275
275
  const I = (...R) => {
276
276
  try {
277
- return A(w, ...R);
277
+ return B(w, ...R);
278
278
  } finally {
279
- T || (b(), h());
279
+ T || (x(), h());
280
280
  }
281
281
  };
282
282
  try {
283
283
  const R = g(w, I);
284
- R && (v.u = () => {
284
+ R && (k.u = () => {
285
285
  T = !0;
286
286
  try {
287
287
  R();
@@ -293,27 +293,27 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
293
293
  T = !1;
294
294
  }
295
295
  };
296
- l.add(N);
296
+ l.add(E);
297
297
  }
298
298
  }
299
- return v;
300
- }), S = m[8] || ((w) => {
299
+ return k;
300
+ }), S = f[8] || ((w) => {
301
301
  var L;
302
- const k = f(w);
303
- let v = n.get(w);
304
- if (v && !v.l.size && !Array.from(v.t).some((N) => {
302
+ const v = m(w);
303
+ let k = n.get(w);
304
+ if (k && !k.l.size && !Array.from(k.t).some((E) => {
305
305
  var T;
306
- return (T = n.get(N)) == null ? void 0 : T.d.has(w);
306
+ return (T = n.get(E)) == null ? void 0 : T.d.has(w);
307
307
  })) {
308
- v.u && i.add(v.u), v = void 0, n.delete(w), (L = c.u) == null || L.call(c, w);
309
- for (const N of k.d.keys()) {
310
- const T = S(N);
308
+ k.u && i.add(k.u), k = void 0, n.delete(w), (L = c.u) == null || L.call(c, w);
309
+ for (const E of v.d.keys()) {
310
+ const T = S(E);
311
311
  T == null || T.t.delete(w);
312
312
  }
313
313
  return;
314
314
  }
315
- return v;
316
- }), B = [
315
+ return k;
316
+ }), A = [
317
317
  // store state
318
318
  o,
319
319
  n,
@@ -328,32 +328,32 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
328
328
  u,
329
329
  g,
330
330
  // building-block functions
331
- f,
331
+ m,
332
332
  h,
333
- b,
334
333
  x,
334
+ b,
335
335
  y,
336
- A,
336
+ B,
337
337
  j,
338
338
  C,
339
339
  S
340
340
  ], _ = {
341
- get: (w) => returnAtomValue(x(w)),
341
+ get: (w) => returnAtomValue(b(w)),
342
342
  set: (w, ...L) => {
343
343
  try {
344
- return A(w, ...L);
344
+ return B(w, ...L);
345
345
  } finally {
346
- b(), h();
346
+ x(), h();
347
347
  }
348
348
  },
349
349
  sub: (w, L) => {
350
- const v = C(w).l;
351
- return v.add(L), h(), () => {
352
- v.delete(L), S(w), h();
350
+ const k = C(w).l;
351
+ return k.add(L), h(), () => {
352
+ k.delete(L), S(w), h();
353
353
  };
354
354
  }
355
355
  };
356
- return Object.defineProperty(_, BUILDING_BLOCKS, { value: B }), _;
356
+ return Object.defineProperty(_, BUILDING_BLOCKS, { value: A }), _;
357
357
  }, INTERNAL_buildStoreRev1 = buildStore;
358
358
  let keyCount = 0;
359
359
  function atom(o, n) {
@@ -388,37 +388,37 @@ function splitAtom(o, n) {
388
388
  let p = r.get(c);
389
389
  if (p)
390
390
  return p;
391
- const u = d && r.get(d), g = [], m = [];
392
- return c.forEach((f, h) => {
393
- const b = h;
394
- m[h] = b;
395
- const x = u && u.atomList[u.keyList.indexOf(b)];
396
- if (x) {
397
- g[h] = x;
391
+ const u = d && r.get(d), g = [], f = [];
392
+ return c.forEach((m, h) => {
393
+ const x = h;
394
+ f[h] = x;
395
+ const b = u && u.atomList[u.keyList.indexOf(x)];
396
+ if (b) {
397
+ g[h] = b;
398
398
  return;
399
399
  }
400
400
  const y = (j) => {
401
- const C = j(l), S = j(o), _ = a(S, C == null ? void 0 : C.arr).keyList.indexOf(b);
401
+ const C = j(l), S = j(o), _ = a(S, C == null ? void 0 : C.arr).keyList.indexOf(x);
402
402
  if (_ < 0 || _ >= S.length) {
403
- const w = c[a(c).keyList.indexOf(b)];
403
+ const w = c[a(c).keyList.indexOf(x)];
404
404
  if (w)
405
405
  return w;
406
406
  throw new Error("splitAtom: index out of bounds for read");
407
407
  }
408
408
  return S[_];
409
- }, A = (j, C, S) => {
410
- const B = j(l), _ = j(o), L = a(_, B == null ? void 0 : B.arr).keyList.indexOf(b);
409
+ }, B = (j, C, S) => {
410
+ const A = j(l), _ = j(o), L = a(_, A == null ? void 0 : A.arr).keyList.indexOf(x);
411
411
  if (L < 0 || L >= _.length)
412
412
  throw new Error("splitAtom: index out of bounds for write");
413
- const k = isFunction(S) ? S(_[L]) : S;
414
- Object.is(_[L], k) || C(o, [
413
+ const v = isFunction(S) ? S(_[L]) : S;
414
+ Object.is(_[L], v) || C(o, [
415
415
  ..._.slice(0, L),
416
- k,
416
+ v,
417
417
  ..._.slice(L + 1)
418
418
  ]);
419
419
  };
420
- g[h] = isWritable(o) ? atom(y, A) : atom(y);
421
- }), u && u.keyList.length === m.length && u.keyList.every((f, h) => f === m[h]) ? p = u : p = { arr: c, atomList: g, keyList: m }, r.set(c, p), p;
420
+ g[h] = isWritable(o) ? atom(y, B) : atom(y);
421
+ }), 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;
422
422
  }, l = atom((c) => {
423
423
  const d = c(l), p = c(o);
424
424
  return a(p, d == null ? void 0 : d.arr);
@@ -454,17 +454,17 @@ function splitAtom(o, n) {
454
454
  case "move": {
455
455
  const u = c(i).indexOf(p.atom), g = p.before ? c(i).indexOf(p.before) : c(i).length;
456
456
  if (u >= 0 && g >= 0) {
457
- const m = c(o);
457
+ const f = c(o);
458
458
  u < g ? d(o, [
459
- ...m.slice(0, u),
460
- ...m.slice(u + 1, g),
461
- m[u],
462
- ...m.slice(g)
459
+ ...f.slice(0, u),
460
+ ...f.slice(u + 1, g),
461
+ f[u],
462
+ ...f.slice(g)
463
463
  ]) : d(o, [
464
- ...m.slice(0, g),
465
- m[u],
466
- ...m.slice(g, u),
467
- ...m.slice(u + 1)
464
+ ...f.slice(0, g),
465
+ f[u],
466
+ ...f.slice(g, u),
467
+ ...f.slice(u + 1)
468
468
  ]);
469
469
  }
470
470
  break;
@@ -490,19 +490,19 @@ function createJSONStorage(o = () => {
490
490
  let a, l;
491
491
  const i = {
492
492
  getItem: (p, u) => {
493
- var g, m;
494
- const f = (b) => {
495
- if (b = b || "", a !== b) {
493
+ var g, f;
494
+ const m = (x) => {
495
+ if (x = x || "", a !== x) {
496
496
  try {
497
- l = JSON.parse(b, n == null ? void 0 : n.reviver);
497
+ l = JSON.parse(x, n == null ? void 0 : n.reviver);
498
498
  } catch {
499
499
  return u;
500
500
  }
501
- a = b;
501
+ a = x;
502
502
  }
503
503
  return l;
504
- }, h = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
505
- return isPromiseLike$1(h) ? h.then(f) : f(h);
504
+ }, h = (f = (g = o()) == null ? void 0 : g.getItem(p)) != null ? f : null;
505
+ return isPromiseLike$1(h) ? h.then(m) : m(h);
506
506
  },
507
507
  setItem: (p, u) => {
508
508
  var g;
@@ -515,12 +515,12 @@ function createJSONStorage(o = () => {
515
515
  var u;
516
516
  return (u = o()) == null ? void 0 : u.removeItem(p);
517
517
  }
518
- }, c = (p) => (u, g, m) => p(u, (f) => {
518
+ }, c = (p) => (u, g, f) => p(u, (m) => {
519
519
  let h;
520
520
  try {
521
- h = JSON.parse(f || "");
521
+ h = JSON.parse(m || "");
522
522
  } catch {
523
- h = m;
523
+ h = f;
524
524
  }
525
525
  g(h);
526
526
  });
@@ -533,8 +533,8 @@ function createJSONStorage(o = () => {
533
533
  if (!(o() instanceof window.Storage))
534
534
  return () => {
535
535
  };
536
- const g = (m) => {
537
- m.storageArea === o() && m.key === p && u(m.newValue);
536
+ const g = (f) => {
537
+ f.storageArea === o() && f.key === p && u(f.newValue);
538
538
  };
539
539
  return window.addEventListener("storage", g), () => {
540
540
  window.removeEventListener("storage", g);
@@ -930,61 +930,7 @@ function requireUndomanager() {
930
930
  }(undomanager)), undomanager.exports;
931
931
  }
932
932
  var undomanagerExports = requireUndomanager();
933
- const UndoManager = /* @__PURE__ */ getDefaultExportFromCjs(undomanagerExports);
934
- function getBlocksTree(o) {
935
- return convertToBlocksTree(o);
936
- }
937
- const nestedToFlatArray = (o, n) => flatten(
938
- o.map((r) => {
939
- if (r = n ? { ...r, _parent: n } : { ...r }, r.children) {
940
- const a = [...r.children];
941
- return delete r.children, flatten([r, ...nestedToFlatArray(a, r._id)]);
942
- }
943
- return r;
944
- })
945
- );
946
- function setProjectBlocksInMemory(o, n = !1) {
947
- for (let r = 0; r < o.length; r++) {
948
- const a = o[r];
949
- a.global && !n ? o[r] = {
950
- type: "GlobalBlock",
951
- blockId: a.blockId,
952
- _parent: get(a, "_parent", null),
953
- _id: a._id
954
- } : a.children && a.children.length && setProjectBlocksInMemory(a.children);
955
- }
956
- }
957
- function getInnerBlocks(o) {
958
- let n = [], r = filter(o, { type: "GlobalBlock" });
959
- return r.length > 0 && (r = map(r, getPBlocks), each(r, (a) => {
960
- n = [...n, ...getSingleBlock(a)];
961
- })), n;
962
- }
963
- function getSingleBlock(o) {
964
- let n = [];
965
- const r = get(first(o), "_parent", null);
966
- set(first(o), "_parent", null);
967
- const a = [flatToNestedInstance.convert(clone(o))];
968
- setProjectBlocksInMemory(a, !0);
969
- let l = nestedToFlatArray(a, o[0]._id);
970
- return l = set(l, "0._parent", r), n = [...n, l, ...getInnerBlocks(l)], n;
971
- }
972
- function getPBlocks(o) {
973
- const n = find(FLAT_ARRAY, { _id: o._id });
974
- if (!n) return [];
975
- const r = [n], a = filter(FLAT_ARRAY, { _parent: o._id });
976
- return a.length ? flatten([...r, ...flatten(map(a, getPBlocks))]) : flatten(r);
977
- }
978
- const clone = (o) => JSON.parse(JSON.stringify(o));
979
- let FLAT_ARRAY = [];
980
- function splitPageBlocks(o) {
981
- FLAT_ARRAY = o;
982
- const n = getBlocksTree(clone(o));
983
- setProjectBlocksInMemory(n);
984
- const r = nestedToFlatArray(n, null), a = getInnerBlocks(r), l = {};
985
- return each(a, (i) => set(l, first(i).blockId, i)), [r, l];
986
- }
987
- const MODIFIERS = [
933
+ const UndoManager = /* @__PURE__ */ getDefaultExportFromCjs(undomanagerExports), MODIFIERS = [
988
934
  "hover",
989
935
  "focus",
990
936
  "focus-within",
@@ -1051,10 +997,10 @@ const useBrandingOptions = () => {
1051
997
  }), useGetPageData = () => {
1052
998
  const [o] = useBrandingOptions(), { currentPage: n } = useCurrentPage(), [r] = useBlocksStore();
1053
999
  return useCallback(() => {
1054
- const a = map(r, (i) => omit(i, getBlockBuilderProps(i._type))), [l = []] = splitPageBlocks(a);
1000
+ const a = map(r, (l) => omit(l, getBlockBuilderProps(l._type)));
1055
1001
  return {
1056
1002
  currentPage: n,
1057
- blocks: l
1003
+ blocks: a
1058
1004
  };
1059
1005
  }, [o, n, r]);
1060
1006
  }, chaiBuilderPropsAtom = atom$1(null);
@@ -1200,8 +1146,29 @@ const useSelectedBlocksDisplayChild = () => ({
1200
1146
  );
1201
1147
  return [o, n, r];
1202
1148
  }, removeNestedBlocks = (o, n) => {
1203
- const r = [], a = filter(o, (l) => includes(n, l._id) || includes(n, l._parent) ? (r.push(l._id), !1) : !0);
1204
- return isEmpty(r) ? a : removeNestedBlocks(a, r);
1149
+ let r = [...o], a = [];
1150
+ n.forEach((d) => {
1151
+ const p = r.find((f) => f._id === d);
1152
+ if (!p || !p._parent) return;
1153
+ const u = p._parent, g = r.filter((f) => f._parent === u);
1154
+ if (g.length === 2) {
1155
+ const f = g.find((m) => m._id !== d);
1156
+ if (f && f._type === "Text") {
1157
+ const m = r.find((h) => h._id === u);
1158
+ m && "content" in m && (r = r.map((h) => {
1159
+ if (h._id === u) {
1160
+ const x = { ...h, content: f.content };
1161
+ return Object.keys(f).forEach((b) => {
1162
+ b.startsWith("content-") && (x[b] = f[b]);
1163
+ }), x;
1164
+ }
1165
+ return h;
1166
+ }), a.push(f._id));
1167
+ }
1168
+ }
1169
+ });
1170
+ const l = [...n, ...a], i = [], c = filter(r, (d) => includes(l, d._id) || includes(l, d._parent) ? (i.push(d._id), !1) : !0);
1171
+ return isEmpty(i) ? c : removeNestedBlocks(c, i);
1205
1172
  }, useRemoveBlocks = () => {
1206
1173
  const [o] = useBlocksStore(), [n, r] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions();
1207
1174
  return useCallback(
@@ -1255,19 +1222,46 @@ const useSelectedBlocksDisplayChild = () => ({
1255
1222
  { store: builderStore }
1256
1223
  );
1257
1224
  function insertBlocksAtPosition(o, n, r, a) {
1258
- let l = o.filter((d) => !d._parent);
1259
- r && (l = o.filter((d) => d._parent === r));
1260
- const i = !isNaN(a) || a > -1 ? Math.min(a, l.length) : l.length;
1261
- let c = o.length;
1262
- for (let d = 0, p = 0; d < o.length; d++)
1263
- if (o[d]._parent === r) {
1264
- if (p === i) {
1265
- c = d;
1225
+ const l = [...n];
1226
+ let i = [...o];
1227
+ if (r) {
1228
+ const u = o.find((g) => g._id === r);
1229
+ if (u && u.content !== void 0 && u.content !== "" && !o.some((f) => f._parent === r)) {
1230
+ const m = {
1231
+ _id: generateUUID(),
1232
+ _parent: r,
1233
+ _type: "Text",
1234
+ content: u.content
1235
+ };
1236
+ Object.keys(u).forEach((h) => {
1237
+ h.startsWith("content-") && (m[h] = u[h]);
1238
+ }), l.unshift(m), i = i.map((h) => {
1239
+ if (h._id === r) {
1240
+ const x = { ...h, content: "" };
1241
+ return Object.keys(x).forEach((b) => {
1242
+ b.startsWith("content-") && (x[b] = "");
1243
+ }), x;
1244
+ }
1245
+ return h;
1246
+ });
1247
+ }
1248
+ }
1249
+ let c = i.filter((u) => !u._parent);
1250
+ r && (c = i.filter((u) => u._parent === r));
1251
+ const d = !isNaN(a) || a > -1 ? Math.min(a, c.length) : c.length;
1252
+ let p = i.length;
1253
+ for (let u = 0, g = 0; u < i.length; u++)
1254
+ if (i[u]._parent === r) {
1255
+ if (g === d) {
1256
+ p = u;
1266
1257
  break;
1267
1258
  }
1268
- p++;
1259
+ g++;
1269
1260
  }
1270
- return !r && a !== void 0 && a >= l.length && (c = o.length), [...o.slice(0, c), ...n, ...o.slice(c)];
1261
+ return !r && a !== void 0 && a >= c.length && (p = i.length), [...i.slice(0, p), ...l, ...i.slice(p)];
1262
+ }
1263
+ function getBlocksTree(o) {
1264
+ return convertToBlocksTree(o);
1271
1265
  }
1272
1266
  function flattenTree(o) {
1273
1267
  let n = [];
@@ -1289,15 +1283,65 @@ function moveNode(o, n, r, a) {
1289
1283
  }
1290
1284
  return !1;
1291
1285
  }
1286
+ function handleOldParentTextBlock(o, n) {
1287
+ if (!n || !n._parent) return o;
1288
+ const r = n._parent, a = o.find((i) => i._id === r);
1289
+ if (!a) return o;
1290
+ const l = o.filter((i) => i._parent === r);
1291
+ if (l.length === 2) {
1292
+ const i = l.find((c) => c._id !== n._id);
1293
+ if (i && i._type === "Text" && "content" in a)
1294
+ return o.map((d) => {
1295
+ if (d._id === r) {
1296
+ const p = { ...d, content: i.content };
1297
+ return Object.keys(i).forEach((u) => {
1298
+ u.startsWith("content-") && (p[u] = i[u]);
1299
+ }), p;
1300
+ }
1301
+ return d;
1302
+ }).filter((d) => d._id !== i._id);
1303
+ }
1304
+ return o;
1305
+ }
1306
+ function handleNewParentTextBlock(o, n, r) {
1307
+ if (!r || r === "root") return o;
1308
+ const a = o.find((l) => l._id === r);
1309
+ if (!a) return o;
1310
+ if (a.content !== void 0 && a.content !== "" && !o.some((i) => i._parent === r && i._id !== n._id)) {
1311
+ const c = {
1312
+ _id: generateUUID(),
1313
+ _parent: r,
1314
+ _type: "Text",
1315
+ content: a.content
1316
+ };
1317
+ Object.keys(a).forEach((u) => {
1318
+ u.startsWith("content-") && (c[u] = a[u]);
1319
+ });
1320
+ const d = o.map((u) => {
1321
+ if (u._id === r) {
1322
+ const g = { ...u, content: "" };
1323
+ return Object.keys(g).forEach((f) => {
1324
+ f.startsWith("content-") && (g[f] = "");
1325
+ }), g;
1326
+ }
1327
+ return u;
1328
+ }), p = d.findIndex((u) => u._id === n._id);
1329
+ return p !== -1 ? [...d.slice(0, p), c, ...d.slice(p)] : [c, ...d];
1330
+ }
1331
+ return o;
1332
+ }
1292
1333
  function moveBlocksWithChildren(o, n, r, a) {
1293
1334
  if (!n) return o;
1294
- r = r || "root";
1295
- const i = new TreeModel().parse({ _id: "root", children: getBlocksTree(o) });
1296
- if (moveNode(i, n, r, a)) {
1297
- const c = flattenTree(i), d = c.find((p) => p._id === n);
1298
- return d && (d._parent = r === "root" ? null : r), c.shift(), c;
1335
+ const l = o.find((u) => u._id === n);
1336
+ if (!l) return o;
1337
+ let i = handleOldParentTextBlock(o, l);
1338
+ const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
1339
+ if (moveNode(p, n, c, a)) {
1340
+ let u = flattenTree(p);
1341
+ const g = u.find((f) => f._id === n);
1342
+ return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
1299
1343
  }
1300
- return o;
1344
+ return i;
1301
1345
  }
1302
1346
  const useBlocksStoreManager = () => {
1303
1347
  const [, o] = useBlocksStore(), { postMessage: n } = useBroadcastChannel(), r = useUpdateBlockAtom();
@@ -1344,65 +1388,65 @@ const useBlocksStoreManager = () => {
1344
1388
  updateBlocksProps: c
1345
1389
  } = useBlocksStoreManager();
1346
1390
  return {
1347
- moveBlocks: (b, x, y) => {
1348
- const A = map(b, (C) => {
1349
- const B = n.find((L) => L._id === C)._parent || null, w = n.filter((L) => B ? L._parent === B : !L._parent).map((L) => L._id).indexOf(C);
1350
- return { _id: C, oldParent: B, oldPosition: w };
1351
- }), j = A.find(({ _id: C }) => C === b[0]);
1352
- j && j.oldParent === x && j.oldPosition === y || (i(b, x, y), o({
1353
- undo: () => each(A, ({ _id: C, oldParent: S, oldPosition: B }) => {
1354
- i([C], S, B);
1391
+ moveBlocks: (x, b, y) => {
1392
+ const B = map(x, (C) => {
1393
+ const A = n.find((L) => L._id === C)._parent || null, w = n.filter((L) => A ? L._parent === A : !L._parent).map((L) => L._id).indexOf(C);
1394
+ return { _id: C, oldParent: A, oldPosition: w };
1395
+ }), j = B.find(({ _id: C }) => C === x[0]);
1396
+ j && j.oldParent === b && j.oldPosition === y || (i(x, b, y), o({
1397
+ undo: () => each(B, ({ _id: C, oldParent: S, oldPosition: A }) => {
1398
+ i([C], S, A);
1355
1399
  }),
1356
- redo: () => i(b, x, y)
1400
+ redo: () => i(x, b, y)
1357
1401
  }));
1358
1402
  },
1359
- addBlocks: (b, x, y) => {
1360
- a(b, x, y), o({
1361
- undo: () => l(map(b, "_id")),
1362
- redo: () => a(b, x, y)
1403
+ addBlocks: (x, b, y) => {
1404
+ a(x, b, y), o({
1405
+ undo: () => l(map(x, "_id")),
1406
+ redo: () => a(x, b, y)
1363
1407
  });
1364
1408
  },
1365
- removeBlocks: (b) => {
1409
+ removeBlocks: (x) => {
1366
1410
  var j;
1367
- const x = (j = first(b)) == null ? void 0 : j._parent, A = n.filter((C) => x ? C._parent === x : !C._parent).indexOf(first(b));
1368
- l(map(b, "_id")), o({
1369
- undo: () => a(b, x, A),
1370
- redo: () => l(map(b, "_id"))
1411
+ const b = (j = first(x)) == null ? void 0 : j._parent, B = n.filter((C) => b ? C._parent === b : !C._parent).indexOf(first(x));
1412
+ l(map(x, "_id")), o({
1413
+ undo: () => a(x, b, B),
1414
+ redo: () => l(map(x, "_id"))
1371
1415
  });
1372
1416
  },
1373
- updateBlocks: (b, x, y) => {
1374
- let A = [];
1417
+ updateBlocks: (x, b, y) => {
1418
+ let B = [];
1375
1419
  if (y)
1376
- A = map(b, (j) => ({ _id: j, ...y }));
1420
+ B = map(x, (j) => ({ _id: j, ...y }));
1377
1421
  else {
1378
- const j = keys(x);
1379
- A = map(b, (C) => {
1380
- const S = n.find((_) => _._id === C), B = { _id: C };
1381
- return each(j, (_) => B[_] = S[_]), B;
1422
+ const j = keys(b);
1423
+ B = map(x, (C) => {
1424
+ const S = n.find((_) => _._id === C), A = { _id: C };
1425
+ return each(j, (_) => A[_] = S[_]), A;
1382
1426
  });
1383
1427
  }
1384
- c(map(b, (j) => ({ _id: j, ...x }))), o({
1385
- undo: () => c(A),
1386
- redo: () => c(map(b, (j) => ({ _id: j, ...x })))
1428
+ c(map(x, (j) => ({ _id: j, ...b }))), o({
1429
+ undo: () => c(B),
1430
+ redo: () => c(map(x, (j) => ({ _id: j, ...b })))
1387
1431
  });
1388
1432
  },
1389
- updateBlocksRuntime: (b, x) => {
1390
- c(map(b, (y) => ({ _id: y, ...x })));
1433
+ updateBlocksRuntime: (x, b) => {
1434
+ c(map(x, (y) => ({ _id: y, ...b })));
1391
1435
  },
1392
- setNewBlocks: (b) => {
1393
- r(b), o({
1436
+ setNewBlocks: (x) => {
1437
+ r(x), o({
1394
1438
  undo: () => r(n),
1395
- redo: () => r(b)
1439
+ redo: () => r(x)
1396
1440
  });
1397
1441
  },
1398
- updateMultipleBlocksProps: (b) => {
1399
- let x = [];
1400
- x = map(b, (y) => {
1401
- const A = keys(y), j = n.find((S) => S._id === y._id), C = {};
1402
- return each(A, (S) => C[S] = j[S]), C;
1403
- }), c(b), o({
1404
- undo: () => c(x),
1405
- redo: () => c(b)
1442
+ updateMultipleBlocksProps: (x) => {
1443
+ let b = [];
1444
+ b = map(x, (y) => {
1445
+ const B = keys(y), j = n.find((S) => S._id === y._id), C = {};
1446
+ return each(B, (S) => C[S] = j[S]), C;
1447
+ }), c(x), o({
1448
+ undo: () => c(b),
1449
+ redo: () => c(x)
1406
1450
  });
1407
1451
  }
1408
1452
  };
@@ -1438,33 +1482,35 @@ import.meta.vitest && describe("canDropBlock Function", () => {
1438
1482
  const useAddBlock = () => {
1439
1483
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
1440
1484
  (i, c, d) => {
1441
- var f;
1485
+ var m;
1442
1486
  for (let h = 0; h < i.length; h++) {
1443
- const { _id: b } = i[h];
1487
+ const { _id: x } = i[h];
1444
1488
  i[h]._id = generateUUID();
1445
- const x = filter(i, { _parent: b });
1446
- for (let y = 0; y < x.length; y++)
1447
- x[y]._parent = i[h]._id;
1489
+ const b = filter(i, { _parent: x });
1490
+ for (let y = 0; y < b.length; y++)
1491
+ b[y]._parent = i[h]._id;
1448
1492
  }
1449
1493
  const p = first(i);
1450
1494
  let u, g;
1451
- return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(f = first(i)) == null ? void 0 : f._id]), first(i);
1495
+ return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(m = first(i)) == null ? void 0 : m._id]), first(i);
1452
1496
  },
1453
1497
  [r, o, n]
1454
1498
  );
1455
1499
  return { addCoreBlock: useCallback(
1456
1500
  (i, c, d) => {
1457
1501
  if (has(i, "blocks")) {
1458
- const x = i.blocks;
1459
- return a(x, c, d);
1502
+ const b = i.blocks;
1503
+ return a(b, c, d);
1460
1504
  }
1461
1505
  const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
1462
1506
  _type: i.type,
1463
1507
  _id: p,
1464
- ...u
1508
+ ...u,
1509
+ ...has(i, "_name") && { _name: i._name },
1510
+ ...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
1465
1511
  };
1466
- let m, f;
1467
- return c && (m = find(o, { _id: c }), g._parent = c, f = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, f = m._parent), r([g], f, d), n([g._id]), g;
1512
+ let f, m;
1513
+ 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;
1468
1514
  },
1469
1515
  [r, a, o, n]
1470
1516
  ), addPredefinedBlock: a };
@@ -2910,43 +2956,43 @@ const getBlockWithChildren = (o, n) => {
2910
2956
  return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
2911
2957
  })
2912
2958
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
2913
- const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (f, h) => {
2914
- const b = cloneDeep(h.find((x) => x._id === f));
2915
- for (const x in b) {
2916
- const y = b[x];
2959
+ 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) => {
2960
+ const x = cloneDeep(h.find((b) => b._id === m));
2961
+ for (const b in x) {
2962
+ const y = x[b];
2917
2963
  if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
2918
- const { baseClasses: A, classes: j } = getSplitChaiClasses(y);
2919
- b[x] = compact(flattenDeep([A, j])).join(" ");
2964
+ const { baseClasses: B, classes: j } = getSplitChaiClasses(y);
2965
+ x[b] = compact(flattenDeep([B, j])).join(" ");
2920
2966
  } else
2921
- x !== "_id" && delete b[x];
2967
+ b !== "_id" && delete x[b];
2922
2968
  }
2923
- return b;
2969
+ return x;
2924
2970
  };
2925
2971
  return {
2926
2972
  askAi: useCallback(
2927
- async (f, h, b, x) => {
2973
+ async (m, h, x, b) => {
2928
2974
  if (l) {
2929
2975
  n(!0), a(null);
2930
2976
  try {
2931
- const y = p === u ? "" : p, A = f === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, d)), p) : [m(h, d)], j = await l(f, addLangToPrompt(b, g, f), A, y), { blocks: C, error: S } = j;
2977
+ const y = p === u ? "" : p, B = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, d)), p) : [f(h, d)], j = await l(m, addLangToPrompt(x, g, m), B, y), { blocks: C, error: S } = j;
2932
2978
  if (S) {
2933
2979
  a(S);
2934
2980
  return;
2935
2981
  }
2936
- if (f === "styles") {
2937
- const B = C.map((_) => {
2982
+ if (m === "styles") {
2983
+ const A = C.map((_) => {
2938
2984
  for (const w in _)
2939
2985
  w !== "_id" && (_[w] = `${STYLES_KEY},${_[w]}`);
2940
2986
  return _;
2941
2987
  });
2942
- c(B);
2988
+ c(A);
2943
2989
  } else
2944
2990
  i(C);
2945
- x && x(j);
2991
+ b && b(j);
2946
2992
  } catch (y) {
2947
2993
  a(y);
2948
2994
  } finally {
2949
- n(!1), x && x();
2995
+ n(!1), b && b();
2950
2996
  }
2951
2997
  }
2952
2998
  },
@@ -2994,11 +3040,11 @@ const useBlockHighlight = () => {
2994
3040
  ), clearHighlight: () => {
2995
3041
  lastHighlighted && (lastHighlighted.removeAttribute("data-highlighted"), lastHighlighted = null);
2996
3042
  }, lastHighlighted };
2997
- }, globalBlocksStoreAtom = atom({}), globalBlocksLoadingStateAtom = atom({}), useGlobalBlocksStore = () => {
2998
- const [o, n] = useAtom(globalBlocksStoreAtom), r = useCallback((l) => get(o, l, []), [o]), a = useCallback(() => n({}), [n]);
2999
- return { getGlobalBlocks: r, reset: a };
3000
- }, useWatchGlobalBlocks = () => {
3001
- const [o] = useBlocksStore(), [n, r] = useAtom(globalBlocksStoreAtom), [a, l] = useAtom(globalBlocksLoadingStateAtom), i = useBuilderProp("getGlobalBlockBlocks", async (d) => []), c = useMemo(() => o.filter((p) => p._type === "GlobalBlock").filter((p) => p._type === "GlobalBlock").map((p) => p.globalBlock), [o]);
3043
+ }, partialBlocksStoreAtom = atom({}), partialBlocksLoadingStateAtom = atom({}), usePartailBlocksStore = () => {
3044
+ const [o, n] = useAtom(partialBlocksStoreAtom), r = useCallback((l) => get(o, l, []), [o]), a = useCallback(() => n({}), [n]);
3045
+ return { getPartailBlocks: r, reset: a };
3046
+ }, useWatchPartailBlocks = () => {
3047
+ const [o] = useBlocksStore(), [n, r] = useAtom(partialBlocksStoreAtom), [a, l] = useAtom(partialBlocksLoadingStateAtom), i = useBuilderProp("getPartialBlockBlocks", async (d) => []), c = useMemo(() => o.filter((d) => d._type === "PartialBlock" || d._type === "GlobalBlock").map((d) => get(d, "partialBlockId", get(d, "globalBlock", ""))), [o]);
3002
3048
  useEffect(() => {
3003
3049
  forEach(c, (d) => {
3004
3050
  has(n, d) || get(a, `${d}.loading`, !1) || (l((p) => ({ ...p, [d]: { loading: !0, error: null } })), i(d).then((p) => {
@@ -3016,22 +3062,26 @@ const useBlockHighlight = () => {
3016
3062
  }, [
3017
3063
  i,
3018
3064
  n,
3019
- c,
3020
3065
  a,
3021
3066
  r,
3022
- l
3067
+ l,
3068
+ c
3023
3069
  ]);
3024
- }, globalBlocksListAtom = atom({}), useGlobalBlocksList = () => {
3025
- const [o, n] = useState(!1), [r, a] = useAtom(globalBlocksListAtom), l = useBuilderProp("getGlobalBlocks", async () => []), i = useCallback(async () => {
3026
- n(!0);
3027
- const c = await l();
3028
- a(c), n(!1);
3029
- }, [l, a]);
3070
+ }, partialBlocksListAtom = atom({}), usePartialBlocksList = () => {
3071
+ const [o, n] = useState(!1), [r, a] = useState(null), [l, i] = useAtom(partialBlocksListAtom), c = useBuilderProp("getPartialBlocks", async () => []), d = useCallback(async () => {
3072
+ n(!0), a(null);
3073
+ try {
3074
+ const p = await c();
3075
+ i(p), n(!1);
3076
+ } catch (p) {
3077
+ a(p instanceof Error ? p.message : "Failed to fetch partial blocks"), n(!1);
3078
+ }
3079
+ }, [c, i]);
3030
3080
  return useEffect(() => {
3031
- i();
3032
- }, []), { data: r, isLoading: o, refetch: i };
3081
+ d();
3082
+ }, []), { data: l, isLoading: o, refetch: d, error: r };
3033
3083
  }, useBuilderReset = () => {
3034
- const o = useSetAtom$1(historyStatesAtom), { clear: n } = useUndoManager(), [, r] = useSelectedBlockIds(), { clearHighlight: a } = useBlockHighlight(), [, l] = useSelectedStylingBlocks(), [, i] = useAtom(aiAssistantActiveAtom), { reset: c } = useGlobalBlocksStore();
3084
+ const o = useSetAtom$1(historyStatesAtom), { clear: n } = useUndoManager(), [, r] = useSelectedBlockIds(), { clearHighlight: a } = useBlockHighlight(), [, l] = useSelectedStylingBlocks(), [, i] = useAtom(aiAssistantActiveAtom), { reset: c } = usePartailBlocksStore();
3035
3085
  return () => {
3036
3086
  r([]), l([]), a(), n(), i(!1), o({ undoCount: 0, redoCount: 0 }), c();
3037
3087
  };
@@ -3079,13 +3129,13 @@ const useBlockHighlight = () => {
3079
3129
  (a, l = null) => {
3080
3130
  const i = [];
3081
3131
  each(a, (c) => {
3082
- const d = o.find((f) => f._id === c);
3132
+ const d = o.find((m) => m._id === c);
3083
3133
  l ? l === "root" && (l = null) : l = d._parent;
3084
3134
  const g = filter(
3085
3135
  o,
3086
- (f) => isString(l) ? f._parent === l : !f._parent
3087
- ).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
3088
- r(m, l, g), i.push(get(m, "0._id", ""));
3136
+ (m) => isString(l) ? m._parent === l : !m._parent
3137
+ ).indexOf(d) + 1, f = getDuplicatedBlocks(o, c, l);
3138
+ r(f, l, g), i.push(get(f, "0._id", ""));
3089
3139
  }), n(i);
3090
3140
  },
3091
3141
  [o, n]
@@ -3178,13 +3228,13 @@ const useBlockHighlight = () => {
3178
3228
  return map(i, (c) => {
3179
3229
  const d = o(c), p = a;
3180
3230
  let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
3181
- return each(p, (m) => {
3182
- const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
3231
+ return each(p, (f) => {
3232
+ const m = f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
3183
3233
  u = u.replace(h, " ").replace(/\s+/g, " ").trim();
3184
- const b = first(m.split(":"));
3185
- includes(["2xl", "xl", "lg", "md", "sm"], b) && p.push(m.split(":").pop().trim());
3186
- }), each(p, (m) => {
3187
- const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
3234
+ const x = first(f.split(":"));
3235
+ includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(f.split(":").pop().trim());
3236
+ }), each(p, (f) => {
3237
+ const m = f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
3188
3238
  g = g.replace(h, " ").replace(/\s+/g, " ").trim();
3189
3239
  }), {
3190
3240
  ids: [d._id],
@@ -3318,7 +3368,7 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3318
3368
  }
3319
3369
  });
3320
3370
  useResizeObserver(o, () => g(), o !== null);
3321
- const m = get(n, "_parent", null), f = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
3371
+ const f = get(n, "_parent", null), m = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
3322
3372
  return !o || !n || d ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
3323
3373
  "div",
3324
3374
  {
@@ -3335,16 +3385,16 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3335
3385
  onKeyDown: (h) => h.stopPropagation(),
3336
3386
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3337
3387
  children: [
3338
- m && /* @__PURE__ */ jsx(
3388
+ f && /* @__PURE__ */ jsx(
3339
3389
  ArrowUpIcon,
3340
3390
  {
3341
3391
  className: "hover:scale-105",
3342
3392
  onClick: () => {
3343
- c([]), l([m]);
3393
+ c([]), l([f]);
3344
3394
  }
3345
3395
  }
3346
3396
  ),
3347
- /* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: n }),
3397
+ /* @__PURE__ */ jsx(BlockActionLabel, { label: m, block: n }),
3348
3398
  /* @__PURE__ */ jsxs("div", { className: "flex gap-2 px-1", children: [
3349
3399
  canAddChildBlock(get(n, "_type", "")) && /* @__PURE__ */ jsx(
3350
3400
  PlusIcon,
@@ -3397,7 +3447,7 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3397
3447
  .frame-root .frame-content { height: 100%; }
3398
3448
  [data-drop="yes"] { outline: 2px dashed orange !important; outline-offset: -2px }
3399
3449
  [data-dnd="yes"] { pointer-events: auto !important}
3400
- [data-dnd="no"],[data-block-type="GlobalBlock"] > * { pointer-events: none !important; }
3450
+ [data-dnd="no"],[data-block-type="GlobalBlock"],[data-block-type="PartialBlock"] > * { pointer-events: none !important; }
3401
3451
  [data-dnd-dragged="yes"] { opacity: 0.6; pointer-events: none; }
3402
3452
  [data-dnd-dragged="no"] { opacity: 1; pointer-events: auto !important; }
3403
3453
  [force-show] { display: block !important; }
@@ -3415,15 +3465,15 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3415
3465
  <div class="frame-root h-full"></div>
3416
3466
  </body>
3417
3467
  </html>`, useKeyEventWatcher = (o) => {
3418
- const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), f = o ? { document: o } : {};
3468
+ 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 } : {};
3419
3469
  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(
3420
3470
  "ctrl+v,command+v",
3421
3471
  () => {
3422
- g(n[0]) && m(n);
3472
+ g(n[0]) && f(n);
3423
3473
  },
3424
- { ...f, preventDefault: !0 },
3425
- [n, g, m]
3426
- ), useHotkeys("esc", () => r([]), f, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...f, preventDefault: !0 }, [
3474
+ { ...m, preventDefault: !0 },
3475
+ [n, g, f]
3476
+ ), useHotkeys("esc", () => r([]), m, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...m, preventDefault: !0 }, [
3427
3477
  n,
3428
3478
  i
3429
3479
  ]), useHotkeys(
@@ -3431,7 +3481,7 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3431
3481
  (h) => {
3432
3482
  h.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
3433
3483
  },
3434
- f,
3484
+ m,
3435
3485
  [n, l]
3436
3486
  );
3437
3487
  }, KeyboardHandler = () => {
@@ -3517,38 +3567,38 @@ function removeDataDrop() {
3517
3567
  const useDnd = () => {
3518
3568
  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);
3519
3569
  if (!useFeature("dnd")) return {};
3520
- const m = () => {
3570
+ const f = () => {
3521
3571
  removePlaceholder(), r(!1), p(null), u(null), possiblePositions = [];
3522
3572
  };
3523
3573
  return iframeDocument = o, {
3524
3574
  isDragging: n,
3525
- onDragOver: (f) => {
3526
- f.preventDefault(), f.stopPropagation(), throttledDragOver(f);
3575
+ onDragOver: (m) => {
3576
+ m.preventDefault(), m.stopPropagation(), throttledDragOver(m);
3527
3577
  },
3528
- onDrop: (f) => {
3578
+ onDrop: (m) => {
3529
3579
  var S;
3530
- const h = dropTarget, x = getOrientation(h) === "vertical" ? f.clientY + ((S = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : S.scrollY) : f.clientX;
3531
- dropIndex = calculateDropIndex(x, possiblePositions);
3532
- const y = d, A = h.getAttribute("data-block-id"), j = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3533
- if ((y == null ? void 0 : y._id) === A || !j) {
3534
- m();
3580
+ const h = dropTarget, b = getOrientation(h) === "vertical" ? m.clientY + ((S = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : S.scrollY) : m.clientX;
3581
+ dropIndex = calculateDropIndex(b, possiblePositions);
3582
+ const y = d, B = h.getAttribute("data-block-id"), j = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3583
+ if ((y == null ? void 0 : y._id) === B || !j) {
3584
+ f();
3535
3585
  return;
3536
3586
  }
3537
3587
  if (!has(y, "_id")) {
3538
- a(y, A === "canvas" ? null : A, dropIndex), setTimeout(m, 300);
3588
+ a(y, B === "canvas" ? null : B, dropIndex), setTimeout(f, 300);
3539
3589
  return;
3540
3590
  }
3541
3591
  let C = h.getAttribute("data-block-id");
3542
- C === null && (C = f.target.parentElement.getAttribute("data-block-id")), c([y._id], C === "canvas" ? null : C, dropIndex), m(), setTimeout(removePlaceholder, 300);
3592
+ C === null && (C = m.target.parentElement.getAttribute("data-block-id")), c([y._id], C === "canvas" ? null : C, dropIndex), f(), setTimeout(removePlaceholder, 300);
3543
3593
  },
3544
- onDragEnter: (f) => {
3545
- const h = f, b = h.target;
3546
- dropTarget = b;
3547
- const x = b.getAttribute("data-block-id"), y = b.getAttribute("data-dnd-dragged") !== "yes";
3548
- u(x), h.stopPropagation(), h.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(b), r(!0), l(""), i([]);
3594
+ onDragEnter: (m) => {
3595
+ const h = m, x = h.target;
3596
+ dropTarget = x;
3597
+ const b = x.getAttribute("data-block-id"), y = x.getAttribute("data-dnd-dragged") !== "yes";
3598
+ u(b), h.stopPropagation(), h.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(x), r(!0), l(""), i([]);
3549
3599
  },
3550
- onDragLeave: (f) => {
3551
- f.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
3600
+ onDragLeave: (m) => {
3601
+ m.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
3552
3602
  }
3553
3603
  };
3554
3604
  };
@@ -3570,17 +3620,17 @@ const useHandleCanvasDblClick = (o, n) => {
3570
3620
  const g = u.getAttribute("data-block-type");
3571
3621
  if (!g || !r.includes(g))
3572
3622
  return;
3573
- const m = u.getAttribute("data-block-id");
3574
- if (!m) return;
3623
+ const f = u.getAttribute("data-block-id");
3624
+ if (!f) return;
3575
3625
  o.on("update", ({ editor: h }) => {
3576
3626
  console.log(h.getHTML());
3577
3627
  }), o.on("blur", () => {
3578
3628
  console.log("blur");
3579
3629
  const h = o.getHTML();
3580
- a([m], { content: h }), n.style.display = "none", u.style.visibility = "visible";
3581
- }), i(m);
3582
- const f = d(m).content;
3583
- o.commands.setContent(f), 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);
3630
+ a([f], { content: h }), n.style.display = "none", u.style.visibility = "visible";
3631
+ }), i(f);
3632
+ const m = d(f).content;
3633
+ 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);
3584
3634
  },
3585
3635
  [l, c, d, i, a, o, n]
3586
3636
  );
@@ -3621,17 +3671,17 @@ const useHandleCanvasDblClick = (o, n) => {
3621
3671
  return;
3622
3672
  const h = getElementByDataBlockId(n, first(r));
3623
3673
  if (h) {
3624
- const b = h.getAttribute("data-style-prop");
3625
- if (b) {
3626
- const x = h.getAttribute("data-style-id"), y = h.getAttribute("data-block-parent");
3627
- l([{ id: x, prop: b, blockId: y }]);
3674
+ const x = h.getAttribute("data-style-prop");
3675
+ if (x) {
3676
+ const b = h.getAttribute("data-style-id"), y = h.getAttribute("data-block-parent");
3677
+ l([{ id: b, prop: x, blockId: y }]);
3628
3678
  }
3629
3679
  }
3630
3680
  }, 100);
3631
3681
  }, [n, r, l, a]);
3632
3682
  const c = useEditor({
3633
3683
  extensions: [StarterKit]
3634
- }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), f = useDnd();
3684
+ }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), f = useHandleMouseLeave(), m = useDnd();
3635
3685
  return /* @__PURE__ */ jsx(
3636
3686
  "div",
3637
3687
  {
@@ -3640,18 +3690,18 @@ const useHandleCanvasDblClick = (o, n) => {
3640
3690
  onClick: u,
3641
3691
  onDoubleClick: p,
3642
3692
  onMouseMove: g,
3643
- onMouseLeave: m,
3644
- ...omit(f, "isDragging"),
3645
- className: "relative h-full max-w-full p-px " + (f.isDragging ? "dragging" : ""),
3693
+ onMouseLeave: f,
3694
+ ...omit(m, "isDragging"),
3695
+ className: "relative h-full max-w-full p-px " + (m.isDragging ? "dragging" : ""),
3646
3696
  children: o
3647
3697
  }
3648
3698
  );
3649
3699
  }, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), HeadTags = () => {
3650
3700
  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(
3651
3701
  d == null ? void 0 : d.getElementById("selected-block")
3652
- ), [m] = useState(
3653
- d == null ? void 0 : d.getElementById("selected-styling-block")
3654
3702
  ), [f] = useState(
3703
+ d == null ? void 0 : d.getElementById("selected-styling-block")
3704
+ ), [m] = useState(
3655
3705
  d == null ? void 0 : d.getElementById("dragged-block")
3656
3706
  );
3657
3707
  useEffect(() => {
@@ -3676,8 +3726,8 @@ const useHandleCanvasDblClick = (o, n) => {
3676
3726
  forms,
3677
3727
  aspectRatio,
3678
3728
  containerQueries,
3679
- plugin(function({ addBase: x, theme: y }) {
3680
- x({
3729
+ plugin(function({ addBase: b, theme: y }) {
3730
+ b({
3681
3731
  "h1,h2,h3,h4,h5,h6": {
3682
3732
  fontFamily: y("fontFamily.heading")
3683
3733
  },
@@ -3691,27 +3741,27 @@ const useHandleCanvasDblClick = (o, n) => {
3691
3741
  ]
3692
3742
  });
3693
3743
  }, [o, n, p]), useEffect(() => {
3694
- g && (g.textContent = `${map(r, (x) => `[data-block-id="${x}"]`).join(",")}{
3744
+ g && (g.textContent = `${map(r, (b) => `[data-block-id="${b}"]`).join(",")}{
3695
3745
  outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
3696
3746
  }`);
3697
3747
  }, [r, g]), useEffect(() => {
3698
- f.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
3699
- }, [i, f]), useEffect(() => {
3748
+ m.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
3749
+ }, [i, m]), useEffect(() => {
3700
3750
  u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
3701
3751
  }, [u]), useEffect(() => {
3702
- m && (m.textContent = `${map(l, ({ id: x }) => `[data-style-id="${x}"]`).join(",")}{
3752
+ f && (f.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
3703
3753
  outline: 1px solid orange !important; outline-offset: -1px;
3704
3754
  }`);
3705
- }, [l, m]), useEffect(() => {
3755
+ }, [l, f]), useEffect(() => {
3706
3756
  d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
3707
3757
  }, [c, d]);
3708
3758
  const h = useMemo(
3709
3759
  () => getChaiThemeCssVariables(o),
3710
3760
  [o]
3711
- ), b = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3761
+ ), x = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3712
3762
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3713
3763
  /* @__PURE__ */ jsx("style", { id: "chai-theme", children: h }),
3714
- /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: b } })
3764
+ /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: x } })
3715
3765
  ] });
3716
3766
  }, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
3717
3767
  const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
@@ -3788,13 +3838,13 @@ const getBlockRuntimeProps = memoize((o) => {
3788
3838
  [o]
3789
3839
  );
3790
3840
  }, BlockRenderer = ({ blockAtom: o, children: n }) => {
3791
- 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), m = useMemo(
3841
+ 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(
3792
3842
  () => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
3793
3843
  [r, l, a, d, u]
3794
- ), f = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), h = useMemo(
3844
+ ), m = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), h = useMemo(
3795
3845
  () => c(r._id, getBlockRuntimeProps(r._type)),
3796
3846
  [r._id, r._type, c, getBlockRuntimeProps]
3797
- ), b = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), x = useMemo(
3847
+ ), x = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), b = useMemo(
3798
3848
  () => ({
3799
3849
  blockProps: {
3800
3850
  "data-block-id": r._id,
@@ -3802,25 +3852,25 @@ const getBlockRuntimeProps = memoize((o) => {
3802
3852
  },
3803
3853
  inBuilder: !0,
3804
3854
  lang: l || i,
3805
- ...m,
3806
3855
  ...f,
3856
+ ...m,
3807
3857
  ...h,
3808
- ...b
3858
+ ...x
3809
3859
  }),
3810
3860
  [
3811
3861
  r._id,
3812
3862
  r._type,
3813
3863
  l,
3814
3864
  i,
3815
- m,
3816
3865
  f,
3866
+ m,
3817
3867
  h,
3818
- b
3868
+ x
3819
3869
  ]
3820
3870
  );
3821
- return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...x, children: n }) });
3822
- }, GlobalBlocksRenderer = ({ globalBlockId: o }) => {
3823
- const { getGlobalBlocks: n } = useGlobalBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom$1(r)), [r]);
3871
+ return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...b, children: n }) });
3872
+ }, PartialBlocksRenderer = ({ partialBlockId: o }) => {
3873
+ const { getPartailBlocks: n } = usePartailBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom$1(r)), [r]);
3824
3874
  return isEmpty(r) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r });
3825
3875
  }, BlocksRenderer = ({
3826
3876
  blocks: o,
@@ -3833,7 +3883,7 @@ const getBlockRuntimeProps = memoize((o) => {
3833
3883
  ), i = useCallback((c) => filter(o, (d) => d._parent === c._id).length > 0, [o]);
3834
3884
  return map(l, (c) => {
3835
3885
  const d = a(c._id);
3836
- return d ? /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, children: c._type === "GlobalBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(GlobalBlocksRenderer, { globalBlockId: get(c, "globalBlock", "") }) }) : i(c) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) : null }, c._id) : null;
3886
+ return d ? /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, children: c._type === "GlobalBlock" || c._type === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: get(c, "partialBlockId", get(c, "globalBlock", "")) }) }) : i(c) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) : null }, c._id) : null;
3837
3887
  });
3838
3888
  }, PageBlocksRenderer = () => {
3839
3889
  const [o] = useBlocksStore();
@@ -3847,11 +3897,11 @@ const getBlockRuntimeProps = memoize((o) => {
3847
3897
  if (d < n) {
3848
3898
  const u = parseFloat((d / n).toFixed(2).toString());
3849
3899
  let g = {};
3850
- const m = p * u, f = d * u;
3900
+ const f = p * u, m = d * u;
3851
3901
  p && (g = {
3852
3902
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
3853
- height: 100 + (p - m) / m * 100 + "%",
3854
- width: 100 + (d - f) / f * 100 + "%"
3903
+ height: 100 + (p - f) / f * 100 + "%",
3904
+ width: 100 + (d - m) / m * 100 + "%"
3855
3905
  }), i({
3856
3906
  position: "relative",
3857
3907
  top: 0,
@@ -3868,43 +3918,43 @@ const getBlockRuntimeProps = memoize((o) => {
3868
3918
  c();
3869
3919
  }, [n, o, r, c]), l;
3870
3920
  }, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
3871
- 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, m] = useState([]), [, f] = useState([]), [, h] = useAtom$1(canvasIframeAtom), [b, x] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), A = useBuilderProp("htmlDir", "ltr"), j = (B) => {
3872
- p((_) => ({ ..._, width: B }));
3921
+ 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, b] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), B = useBuilderProp("htmlDir", "ltr"), j = (A) => {
3922
+ p((_) => ({ ..._, width: A }));
3873
3923
  };
3874
3924
  useEffect(() => {
3875
3925
  if (!c.current) return;
3876
- const { clientWidth: B, clientHeight: _ } = c.current;
3877
- p({ width: B, height: _ });
3926
+ const { clientWidth: A, clientHeight: _ } = c.current;
3927
+ p({ width: A, height: _ });
3878
3928
  }, [c, n]);
3879
- const C = (B, _ = 0) => {
3880
- const { top: w } = B.getBoundingClientRect();
3929
+ const C = (A, _ = 0) => {
3930
+ const { top: w } = A.getBoundingClientRect();
3881
3931
  return w + _ >= 0 && w - _ <= window.innerHeight;
3882
3932
  };
3883
3933
  useEffect(() => {
3884
- var B, _;
3934
+ var A, _;
3885
3935
  if (a && a.type !== "Multiple" && i.current) {
3886
3936
  const w = getElementByDataBlockId(i.current.contentDocument, a._id);
3887
- w && (C(w) || (_ = (B = i.current) == null ? void 0 : B.contentWindow) == null || _.scrollTo({ top: w.offsetTop, behavior: "smooth" }), m([w]));
3937
+ w && (C(w) || (_ = (A = i.current) == null ? void 0 : A.contentWindow) == null || _.scrollTo({ top: w.offsetTop, behavior: "smooth" }), f([w]));
3888
3938
  }
3889
3939
  }, [a]), useEffect(() => {
3890
- if (!isEmpty(b) && i.current) {
3891
- const B = getElementByStyleId(
3940
+ if (!isEmpty(x) && i.current) {
3941
+ const A = getElementByStyleId(
3892
3942
  i.current.contentDocument,
3893
- first(b).id
3943
+ first(x).id
3894
3944
  );
3895
- f(B ? [B] : [null]);
3945
+ m(A ? [A] : [null]);
3896
3946
  } else
3897
- f([null]);
3898
- }, [b]);
3947
+ m([null]);
3948
+ }, [x]);
3899
3949
  const S = useMemo(() => {
3900
- let B = IframeInitialContent;
3901
- return B = B.replace("__HTML_DIR__", A), o === "offline" && (B = B.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), B;
3902
- }, [o, A]);
3950
+ let A = IframeInitialContent;
3951
+ return A = A.replace("__HTML_DIR__", B), o === "offline" && (A = A.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), A;
3952
+ }, [o, B]);
3903
3953
  return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: j, onResize: j, children: /* @__PURE__ */ jsx(
3904
3954
  "div",
3905
3955
  {
3906
3956
  onClick: () => {
3907
- r([]), x([]);
3957
+ r([]), b([]);
3908
3958
  },
3909
3959
  onMouseLeave: () => setTimeout(() => l(""), 300),
3910
3960
  className: "relative mx-auto h-full w-full overflow-hidden",
@@ -4092,20 +4142,20 @@ const getBlockRuntimeProps = memoize((o) => {
4092
4142
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
4093
4143
  const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [c, d] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), g = (y) => {
4094
4144
  a(y);
4095
- }, m = () => {
4096
- const y = l.find((A) => Object.keys(A)[0] === r);
4145
+ }, f = () => {
4146
+ const y = l.find((B) => Object.keys(B)[0] === r);
4097
4147
  if (y) {
4098
- const A = Object.values(y)[0];
4099
- A && typeof A == "object" && "fontFamily" in A && "borderRadius" in A && "colors" in A ? d(A) : console.error("Invalid preset structure:", A);
4148
+ const B = Object.values(y)[0];
4149
+ B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? d(B) : console.error("Invalid preset structure:", B);
4100
4150
  } else
4101
4151
  console.error("Preset not found:", r);
4102
- }, f = useDebouncedCallback(
4103
- (y, A) => {
4152
+ }, m = useDebouncedCallback(
4153
+ (y, B) => {
4104
4154
  d(() => ({
4105
4155
  ...c,
4106
4156
  fontFamily: {
4107
4157
  ...c.fontFamily,
4108
- [y.replace(/font-/g, "")]: A
4158
+ [y.replace(/font-/g, "")]: B
4109
4159
  }
4110
4160
  }));
4111
4161
  },
@@ -4120,11 +4170,11 @@ const getBlockRuntimeProps = memoize((o) => {
4120
4170
  },
4121
4171
  [c],
4122
4172
  200
4123
- ), b = useDebouncedCallback(
4124
- (y, A) => {
4173
+ ), x = useDebouncedCallback(
4174
+ (y, B) => {
4125
4175
  d(() => {
4126
4176
  const j = get(c, `colors.${y}`);
4127
- return n ? set(j, 1, A) : set(j, 0, A), {
4177
+ return n ? set(j, 1, B) : set(j, 0, B), {
4128
4178
  ...c,
4129
4179
  colors: {
4130
4180
  ...c.colors,
@@ -4135,18 +4185,18 @@ const getBlockRuntimeProps = memoize((o) => {
4135
4185
  },
4136
4186
  [c],
4137
4187
  200
4138
- ), x = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([A]) => {
4139
- const j = get(c, `colors.${A}.${n ? 1 : 0}`);
4188
+ ), b = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([B]) => {
4189
+ const j = get(c, `colors.${B}.${n ? 1 : 0}`);
4140
4190
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
4141
4191
  /* @__PURE__ */ jsx(
4142
4192
  ColorPickerInput,
4143
4193
  {
4144
4194
  value: j,
4145
- onChange: (C) => b(A, C)
4195
+ onChange: (C) => x(B, C)
4146
4196
  }
4147
4197
  ),
4148
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: A.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((C) => C.charAt(0).toUpperCase() + C.slice(1)).join(" ") + (!A.toLowerCase().includes("foreground") && !A.toLowerCase().includes("border") && !A.toLowerCase().includes("input") && !A.toLowerCase().includes("ring") && !A.toLowerCase().includes("background") ? " Background" : "") })
4149
- ] }, A);
4198
+ /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((C) => C.charAt(0).toUpperCase() + C.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
4199
+ ] }, B);
4150
4200
  }) });
4151
4201
  return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
4152
4202
  /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
@@ -4172,18 +4222,18 @@ const getBlockRuntimeProps = memoize((o) => {
4172
4222
  className: "w-full text-sm",
4173
4223
  disabled: r === "",
4174
4224
  variant: "default",
4175
- onClick: m,
4225
+ onClick: f,
4176
4226
  children: u("Apply")
4177
4227
  }
4178
4228
  ) })
4179
4229
  ] }),
4180
4230
  /* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
4181
- (p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, A]) => /* @__PURE__ */ jsx(
4231
+ (p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, B]) => /* @__PURE__ */ jsx(
4182
4232
  FontSelector,
4183
4233
  {
4184
4234
  label: y,
4185
- value: c.fontFamily[y.replace(/font-/g, "")] || A[Object.keys(A)[0]],
4186
- onChange: (j) => f(y, j)
4235
+ value: c.fontFamily[y.replace(/font-/g, "")] || B[Object.keys(B)[0]],
4236
+ onChange: (j) => m(y, j)
4187
4237
  },
4188
4238
  y
4189
4239
  )) }),
@@ -4196,7 +4246,7 @@ const getBlockRuntimeProps = memoize((o) => {
4196
4246
  ] }),
4197
4247
  (p == null ? void 0 : p.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
4198
4248
  /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Colors") }),
4199
- /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) => x(y)) }, n ? "dark" : "light")
4249
+ /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) => b(y)) }, n ? "dark" : "light")
4200
4250
  ] })
4201
4251
  ] }),
4202
4252
  /* @__PURE__ */ jsx("br", {}),
@@ -4206,38 +4256,7 @@ const getBlockRuntimeProps = memoize((o) => {
4206
4256
  ] }),
4207
4257
  i && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(i) })
4208
4258
  ] });
4209
- }), GlobalBlockSettings = () => {
4210
- const o = useSelectedBlock(), { data: n, refetch: r, isLoading: a } = useGlobalBlocksList(), l = useUpdateBlocksProps();
4211
- return /* @__PURE__ */ jsxs("div", { children: [
4212
- /* @__PURE__ */ jsx("label", { className: "text-sm", children: "Choose a global block" }),
4213
- /* @__PURE__ */ jsxs(
4214
- "select",
4215
- {
4216
- className: "h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",
4217
- value: (o == null ? void 0 : o.globalBlock) || "",
4218
- onChange: (i) => {
4219
- var c;
4220
- l([o._id], {
4221
- globalBlock: i.target.value,
4222
- _name: `Global: ${startCase((c = get(n, i.target.value, "")) == null ? void 0 : c.name)}`
4223
- });
4224
- },
4225
- children: [
4226
- /* @__PURE__ */ jsx("option", { value: "", children: "Select a global block" }),
4227
- Object.keys(n).map((i) => /* @__PURE__ */ jsx("option", { value: i, children: n[i].name || i }, i))
4228
- ]
4229
- }
4230
- ),
4231
- /* @__PURE__ */ jsx("div", { className: "mt-2 text-xs", children: /* @__PURE__ */ jsx(
4232
- "button",
4233
- {
4234
- onClick: r,
4235
- className: "rounded-md bg-gray-100 p-1 px-2 text-xs hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700",
4236
- children: a ? "Loading..." : "Refresh List"
4237
- }
4238
- ) })
4239
- ] });
4240
- }, ICON_PICKER_CONTAINER_ID = "icon-picker-item-container", removeSizeAttributes = (o) => {
4259
+ }), ICON_PICKER_CONTAINER_ID = "icon-picker-item-container", removeSizeAttributes = (o) => {
4241
4260
  try {
4242
4261
  return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi, "<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi, "<svg$1$2>");
4243
4262
  } catch {
@@ -4370,19 +4389,19 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4370
4389
  }, [a, o]);
4371
4390
  const u = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", g = React.useCallback(
4372
4391
  (h) => {
4373
- const b = (x) => r === "value" ? x === "value" || x === "object" : r === "array" ? x === "array" : x === r;
4374
- h.type === "object" ? (c((x) => [...x, h.key]), p(h.value)) : b(h.type) && (n([...i, h.key].join(".")), l(!1));
4392
+ const x = (b) => r === "value" ? b === "value" || b === "object" : r === "array" ? b === "array" : b === r;
4393
+ h.type === "object" ? (c((b) => [...b, h.key]), p(h.value)) : x(h.type) && (n([...i, h.key].join(".")), l(!1));
4375
4394
  },
4376
4395
  [i, n, r]
4377
- ), m = React.useCallback(() => {
4396
+ ), f = React.useCallback(() => {
4378
4397
  if (i.length > 0) {
4379
4398
  const h = i.slice(0, -1);
4380
- c(h), p(h.reduce((b, x) => b[x], o));
4399
+ c(h), p(h.reduce((x, b) => x[b], o));
4381
4400
  }
4382
- }, [i, o]), f = React.useMemo(() => Object.entries(d).map(([h, b]) => ({
4401
+ }, [i, o]), m = React.useMemo(() => Object.entries(d).map(([h, x]) => ({
4383
4402
  key: h,
4384
- value: b,
4385
- type: u(b)
4403
+ value: x,
4404
+ type: u(x)
4386
4405
  })).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]);
4387
4406
  return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
4388
4407
  /* @__PURE__ */ jsxs(Tooltip, { children: [
@@ -4404,11 +4423,11 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4404
4423
  /* @__PURE__ */ jsxs(CommandList, { children: [
4405
4424
  /* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
4406
4425
  /* @__PURE__ */ jsxs(CommandGroup, { children: [
4407
- i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: m, className: "flex items-center text-sm", children: [
4426
+ i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: f, className: "flex items-center text-sm", children: [
4408
4427
  /* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
4409
4428
  "Back"
4410
4429
  ] }),
4411
- f.map((h) => /* @__PURE__ */ jsxs(
4430
+ m.map((h) => /* @__PURE__ */ jsxs(
4412
4431
  CommandItem,
4413
4432
  {
4414
4433
  value: h.key,
@@ -4424,8 +4443,8 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4424
4443
  size: "sm",
4425
4444
  variant: "ghost",
4426
4445
  className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
4427
- onClick: (b) => {
4428
- b.stopPropagation(), n([...i, h.key].join(".")), l(!1);
4446
+ onClick: (x) => {
4447
+ x.stopPropagation(), n([...i, h.key].join(".")), l(!1);
4429
4448
  },
4430
4449
  children: "Select"
4431
4450
  }
@@ -4593,16 +4612,16 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4593
4612
  const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
4594
4613
  useEffect(() => {
4595
4614
  if (o) {
4596
- const m = document.createElement("style");
4597
- return m.id = "rte-modal-styles", m.innerHTML = `
4615
+ const f = document.createElement("style");
4616
+ return f.id = "rte-modal-styles", f.innerHTML = `
4598
4617
  /* Ensure the NestedPathSelector popover appears above the dialog */
4599
4618
  .rte-path-selector + [data-radix-popper-content-wrapper],
4600
4619
  [data-radix-popper-content-wrapper] {
4601
4620
  z-index: 9999 !important;
4602
4621
  }
4603
- `, document.head.appendChild(m), () => {
4604
- const f = document.getElementById("rte-modal-styles");
4605
- f && f.remove();
4622
+ `, document.head.appendChild(f), () => {
4623
+ const m = document.getElementById("rte-modal-styles");
4624
+ m && m.remove();
4606
4625
  };
4607
4626
  }
4608
4627
  }, [o]);
@@ -4623,13 +4642,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4623
4642
  Underline
4624
4643
  ],
4625
4644
  content: a || "",
4626
- onUpdate: ({ editor: m }) => {
4627
- const f = m.getHTML();
4628
- l(f);
4645
+ onUpdate: ({ editor: f }) => {
4646
+ const m = f.getHTML();
4647
+ l(m);
4629
4648
  },
4630
- onBlur: ({ editor: m }) => {
4631
- const f = m.getHTML();
4632
- i(r, f);
4649
+ onBlur: ({ editor: f }) => {
4650
+ const m = f.getHTML();
4651
+ i(r, m);
4633
4652
  },
4634
4653
  editorProps: {
4635
4654
  attributes: {
@@ -4644,22 +4663,22 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4644
4663
  }, [o, u]), useEffect(() => {
4645
4664
  c.current && u && (c.current.__chaiRTE = u);
4646
4665
  }, [u, o]);
4647
- const g = (m) => {
4666
+ const g = (f) => {
4648
4667
  if (!u) return;
4649
- const f = `{{${m}}}`;
4668
+ const m = `{{${f}}}`;
4650
4669
  u.commands.focus();
4651
- const { from: h, to: b } = u.state.selection;
4652
- if (h !== b)
4653
- u.chain().deleteSelection().insertContent(f).run();
4670
+ const { from: h, to: x } = u.state.selection;
4671
+ if (h !== x)
4672
+ u.chain().deleteSelection().insertContent(m).run();
4654
4673
  else {
4655
- const { state: y } = u, A = y.selection.from, j = y.doc.textBetween(Math.max(0, A - 1), A), C = y.doc.textBetween(A, Math.min(A + 1, y.doc.content.size));
4674
+ const { state: y } = u, B = y.selection.from, j = y.doc.textBetween(Math.max(0, B - 1), B), C = y.doc.textBetween(B, Math.min(B + 1, y.doc.content.size));
4656
4675
  let S = "";
4657
- A > 0 && j !== " " && !/[.,!?;:]/.test(j) && (S = " ");
4658
- let B = "";
4659
- C && C !== " " && !/[.,!?;:]/.test(C) && (B = " "), u.chain().insertContent(S + f + B).run();
4676
+ B > 0 && j !== " " && !/[.,!?;:]/.test(j) && (S = " ");
4677
+ let A = "";
4678
+ C && C !== " " && !/[.,!?;:]/.test(C) && (A = " "), u.chain().insertContent(S + m + A).run();
4660
4679
  }
4661
4680
  };
4662
- return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (m) => !m && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
4681
+ 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: [
4663
4682
  /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
4664
4683
  /* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
4665
4684
  p && Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -4692,12 +4711,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4692
4711
  ],
4693
4712
  content: r || "",
4694
4713
  onUpdate: ({ editor: h }) => {
4695
- const b = h.getHTML();
4696
- a(b), c || u(b);
4714
+ const x = h.getHTML();
4715
+ a(x), c || u(x);
4697
4716
  },
4698
4717
  onBlur: ({ editor: h }) => {
4699
- const b = h.getHTML();
4700
- l(o, b);
4718
+ const x = h.getHTML();
4719
+ l(o, x);
4701
4720
  },
4702
4721
  editorProps: {
4703
4722
  attributes: {
@@ -4710,9 +4729,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4710
4729
  }, [g]), useEffect(() => {
4711
4730
  u(r || "");
4712
4731
  }, [r]);
4713
- const m = (h) => {
4732
+ const f = (h) => {
4714
4733
  a(h);
4715
- }, f = () => {
4734
+ }, m = () => {
4716
4735
  d(!1), g && g.commands.setContent(p);
4717
4736
  };
4718
4737
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -4724,10 +4743,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4724
4743
  RTEModal,
4725
4744
  {
4726
4745
  isOpen: c,
4727
- onClose: f,
4746
+ onClose: m,
4728
4747
  id: o,
4729
4748
  value: p,
4730
- onChange: m,
4749
+ onChange: f,
4731
4750
  onBlur: l
4732
4751
  }
4733
4752
  )
@@ -4738,73 +4757,73 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4738
4757
  onChange: r
4739
4758
  }) => {
4740
4759
  var L;
4741
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (k, v) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, f] = useState(""), [h, b] = useState([]), [x, y] = useState(-1), A = useRef(null), j = (L = n == null ? void 0 : n.find((k) => k.key === u)) == null ? void 0 : L.name;
4760
+ 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([]), [b, y] = useState(-1), B = useRef(null), j = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
4742
4761
  useEffect(() => {
4743
- if (f(""), b([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4744
- const k = split(o, ":"), v = get(k, 1, "page") || "page";
4745
- g(v), (async () => {
4746
- const N = await l(v, [get(k, 2, "page")]);
4747
- N && Array.isArray(N) && f(get(N, [0, "name"], ""));
4762
+ if (m(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4763
+ const v = split(o, ":"), k = get(v, 1, "page") || "page";
4764
+ g(k), (async () => {
4765
+ const E = await l(k, [get(v, 2, "page")]);
4766
+ E && Array.isArray(E) && m(get(E, [0, "name"], ""));
4748
4767
  })();
4749
4768
  }, [o]);
4750
4769
  const C = useDebouncedCallback(
4751
- async (k) => {
4752
- if (isEmpty(k))
4753
- b([]);
4770
+ async (v) => {
4771
+ if (isEmpty(v))
4772
+ x([]);
4754
4773
  else {
4755
- const v = await l(u, k);
4756
- b(v);
4774
+ const k = await l(u, v);
4775
+ x(k);
4757
4776
  }
4758
4777
  c(!1), y(-1);
4759
4778
  },
4760
4779
  [u],
4761
4780
  300
4762
- ), S = (k) => {
4763
- const v = ["pageType", u, k.id];
4764
- v[1] && (r(v.join(":")), f(k.name), p(!1), b([]), y(-1));
4765
- }, B = (k) => {
4766
- switch (k.key) {
4781
+ ), S = (v) => {
4782
+ const k = ["pageType", u, v.id];
4783
+ k[1] && (r(k.join(":")), m(v.name), p(!1), x([]), y(-1));
4784
+ }, A = (v) => {
4785
+ switch (v.key) {
4767
4786
  case "ArrowDown":
4768
- k.preventDefault(), y((v) => v < h.length - 1 ? v + 1 : v);
4787
+ v.preventDefault(), y((k) => k < h.length - 1 ? k + 1 : k);
4769
4788
  break;
4770
4789
  case "ArrowUp":
4771
- k.preventDefault(), y((v) => v > 0 ? v - 1 : v);
4790
+ v.preventDefault(), y((k) => k > 0 ? k - 1 : k);
4772
4791
  break;
4773
4792
  case "Enter":
4774
- if (k.preventDefault(), h.length === 0) return;
4775
- x >= 0 && S(h[x]);
4793
+ if (v.preventDefault(), h.length === 0) return;
4794
+ b >= 0 && S(h[b]);
4776
4795
  break;
4777
4796
  case "Escape":
4778
- k.preventDefault(), _();
4797
+ v.preventDefault(), _();
4779
4798
  break;
4780
4799
  }
4781
4800
  };
4782
4801
  useEffect(() => {
4783
- if (x >= 0 && A.current) {
4784
- const k = A.current.children[x];
4785
- k == null || k.scrollIntoView({ block: "nearest" });
4802
+ if (b >= 0 && B.current) {
4803
+ const v = B.current.children[b];
4804
+ v == null || v.scrollIntoView({ block: "nearest" });
4786
4805
  }
4787
- }, [x]);
4806
+ }, [b]);
4788
4807
  const _ = () => {
4789
- f(""), b([]), y(-1), p(!1), r("");
4790
- }, w = (k) => {
4791
- f(k), p(!isEmpty(k)), c(!0), C(k);
4808
+ m(""), x([]), y(-1), p(!1), r("");
4809
+ }, w = (v) => {
4810
+ m(v), p(!isEmpty(v)), c(!0), C(v);
4792
4811
  };
4793
4812
  return /* @__PURE__ */ jsxs("div", { children: [
4794
- /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (k) => g(k.target.value), children: map(n, (k) => /* @__PURE__ */ jsx("option", { value: k.key, children: k.name }, k.key)) }),
4813
+ /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (v) => g(v.target.value), children: map(n, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
4795
4814
  u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
4796
4815
  /* @__PURE__ */ jsx(
4797
4816
  "input",
4798
4817
  {
4799
4818
  type: "text",
4800
- value: m,
4801
- onChange: (k) => w(k.target.value),
4802
- onKeyDown: B,
4819
+ value: f,
4820
+ onChange: (v) => w(v.target.value),
4821
+ onKeyDown: A,
4803
4822
  placeholder: a(`Search ${j ?? ""}`),
4804
4823
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4805
4824
  }
4806
4825
  ),
4807
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: _, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4826
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: f && /* @__PURE__ */ jsx("button", { onClick: _, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4808
4827
  ] }),
4809
4828
  (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: [
4810
4829
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -4812,24 +4831,24 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4812
4831
  ] }) : d && isEmpty(h) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4813
4832
  a("No results found for"),
4814
4833
  ' "',
4815
- m,
4834
+ f,
4816
4835
  '"'
4817
- ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(h == null ? void 0 : h.slice(0, 20), (k, v) => /* @__PURE__ */ jsxs(
4836
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: B, children: map(h == null ? void 0 : h.slice(0, 20), (v, k) => /* @__PURE__ */ jsxs(
4818
4837
  "li",
4819
4838
  {
4820
- onClick: () => S(k),
4821
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(k.id) ? "bg-blue-200" : v === x ? "bg-gray-100" : "hover:bg-gray-100"}`,
4839
+ onClick: () => S(v),
4840
+ 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"}`,
4822
4841
  children: [
4823
- k.name,
4842
+ v.name,
4824
4843
  " ",
4825
- k.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4844
+ v.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4826
4845
  "( ",
4827
- k.slug,
4846
+ v.slug,
4828
4847
  " )"
4829
4848
  ] })
4830
4849
  ]
4831
4850
  },
4832
- k.id
4851
+ v.id
4833
4852
  )) }) })
4834
4853
  ] });
4835
4854
  }, LinkField = ({ schema: o, formData: n, onChange: r }) => {
@@ -4911,30 +4930,30 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4911
4930
  }, [a]), useEffect(() => {
4912
4931
  u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
4913
4932
  }, [o, u]);
4914
- const m = () => {
4915
- const b = findIndex(u, { _id: g });
4916
- if (b > -1) {
4917
- const x = (b + 1) % u.length, y = get(u, [x, "_id"]);
4933
+ const f = () => {
4934
+ const x = findIndex(u, { _id: g });
4935
+ if (x > -1) {
4936
+ const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
4918
4937
  if (!y) return;
4919
4938
  n({ ...o, currentSlide: y }), c([y]);
4920
4939
  }
4921
- }, f = () => {
4922
- const b = findIndex(u, { _id: g });
4923
- if (b > -1) {
4924
- const x = (b - 1 + u.length) % u.length, y = get(u, [x, "_id"]);
4940
+ }, m = () => {
4941
+ const x = findIndex(u, { _id: g });
4942
+ if (x > -1) {
4943
+ const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
4925
4944
  if (!y) return;
4926
4945
  n({ ...o, currentSlide: y }), c([y]);
4927
4946
  }
4928
4947
  }, h = () => {
4929
- const b = i(
4948
+ const x = i(
4930
4949
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4931
4950
  p == null ? void 0 : p._id
4932
- ), x = b == null ? void 0 : b._id;
4933
- x && (n({ ...o, currentSlide: x }), c([x]));
4951
+ ), b = x == null ? void 0 : x._id;
4952
+ b && (n({ ...o, currentSlide: b }), c([b]));
4934
4953
  };
4935
4954
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4936
4955
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
4937
- /* @__PURE__ */ jsx("button", { onClick: f, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
4956
+ /* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
4938
4957
  /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
4939
4958
  /* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
4940
4959
  " ",
@@ -4943,7 +4962,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4943
4962
  "/",
4944
4963
  u.length
4945
4964
  ] }) : "-" }),
4946
- /* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
4965
+ /* @__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]" }) }),
4947
4966
  /* @__PURE__ */ jsxs(
4948
4967
  "button",
4949
4968
  {
@@ -5008,9 +5027,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5008
5027
  value: o == null ? void 0 : o.autoplayInterval,
5009
5028
  className: "text-xs",
5010
5029
  pattern: "[0-9]*",
5011
- onChange: (b) => {
5012
- let x = b.target.value;
5013
- x.length && (x = x.replace("-", "")), n({ ...o, autoplayInterval: x });
5030
+ onChange: (x) => {
5031
+ let b = x.target.value;
5032
+ b.length && (b = b.replace("-", "")), n({ ...o, autoplayInterval: b });
5014
5033
  }
5015
5034
  }
5016
5035
  )
@@ -5047,14 +5066,14 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5047
5066
  required: p,
5048
5067
  schema: u,
5049
5068
  formData: g,
5050
- onChange: m
5069
+ onChange: f
5051
5070
  }) => {
5052
- const { selectedLang: f, fallbackLang: h, languages: b } = useLanguages(), x = isEmpty(b) ? "" : isEmpty(f) ? h : f, y = get(LANGUAGES, x, x), A = usePageExternalData(), j = useSelectedBlock(), C = useRegisteredChaiBlocks(), S = get(C, [j == null ? void 0 : j._type, "i18nProps"], []) || [], [B, _] = useState(null), w = useCallback(
5053
- (v) => {
5054
- const N = (E) => /[.,!?;:]/.test(E), T = (E, D, M) => {
5071
+ const { selectedLang: m, fallbackLang: h, languages: x } = useLanguages(), b = isEmpty(x) ? "" : isEmpty(m) ? h : m, y = get(LANGUAGES, b, b), B = usePageExternalData(), j = useSelectedBlock(), C = useRegisteredChaiBlocks(), S = get(C, [j == null ? void 0 : j._type, "i18nProps"], []) || [], [A, _] = useState(null), w = useCallback(
5072
+ (k) => {
5073
+ const E = (N) => /[.,!?;:]/.test(N), T = (N, D, M) => {
5055
5074
  let P = "", O = "";
5056
- const $ = D > 0 ? E[D - 1] : "", H = D < E.length ? E[D] : "";
5057
- return D > 0 && ($ === "." || !N($) && $ !== " ") && (P = " "), D < E.length && !N(H) && H !== " " && (O = " "), {
5075
+ const $ = D > 0 ? N[D - 1] : "", H = D < N.length ? N[D] : "";
5076
+ return D > 0 && ($ === "." || !E($) && $ !== " ") && (P = " "), D < N.length && !E(H) && H !== " " && (O = " "), {
5058
5077
  text: P + M + O,
5059
5078
  prefixLength: P.length,
5060
5079
  suffixLength: O.length
@@ -5063,51 +5082,51 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5063
5082
  if (!I) return;
5064
5083
  const R = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
5065
5084
  if (R && (R.querySelector(".ProseMirror") || R.__chaiRTE)) {
5066
- const E = R.__chaiRTE;
5067
- if (E) {
5068
- const D = `{{${v}}}`;
5069
- E.commands.focus();
5070
- const { from: M, to: P } = E.state.selection;
5085
+ const N = R.__chaiRTE;
5086
+ if (N) {
5087
+ const D = `{{${k}}}`;
5088
+ N.commands.focus();
5089
+ const { from: M, to: P } = N.state.selection;
5071
5090
  if (M !== P)
5072
- E.chain().deleteSelection().insertContent(D).run();
5091
+ N.chain().deleteSelection().insertContent(D).run();
5073
5092
  else {
5074
- const { state: $ } = E, H = $.selection.from, F = $.doc.textBetween(Math.max(0, H - 1), H), U = $.doc.textBetween(H, Math.min(H + 1, $.doc.content.size));
5093
+ 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));
5075
5094
  let z = "";
5076
- H > 0 && F !== " " && !N(F) && (z = " ");
5095
+ H > 0 && F !== " " && !E(F) && (z = " ");
5077
5096
  let W = "";
5078
- U && U !== " " && !N(U) && (W = " "), E.chain().insertContent(z + D + W).run();
5097
+ U && U !== " " && !E(U) && (W = " "), N.chain().insertContent(z + D + W).run();
5079
5098
  }
5080
- setTimeout(() => m(E.getHTML(), {}, o), 100);
5099
+ setTimeout(() => f(N.getHTML(), {}, o), 100);
5081
5100
  return;
5082
5101
  }
5083
5102
  } else {
5084
- const E = I, D = E.selectionStart || 0, M = E.value || "", P = E.selectionEnd || D;
5103
+ const N = I, D = N.selectionStart || 0, M = N.value || "", P = N.selectionEnd || D;
5085
5104
  if (P > D) {
5086
- const U = `{{${v}}}`, { text: z } = T(M, D, U), W = M.slice(0, D) + z + M.slice(P);
5087
- m(W, {}, o);
5105
+ const U = `{{${k}}}`, { text: z } = T(M, D, U), W = M.slice(0, D) + z + M.slice(P);
5106
+ f(W, {}, o);
5088
5107
  return;
5089
5108
  }
5090
- const $ = `{{${v}}}`, { text: H } = T(M, D, $), F = M.slice(0, D) + H + M.slice(D);
5091
- m(F, {}, o);
5109
+ const $ = `{{${k}}}`, { text: H } = T(M, D, $), F = M.slice(0, D) + H + M.slice(D);
5110
+ f(F, {}, o);
5092
5111
  }
5093
5112
  },
5094
- [o, m, g, j == null ? void 0 : j._id]
5113
+ [o, f, g, j == null ? void 0 : j._id]
5095
5114
  );
5096
5115
  if (d)
5097
5116
  return null;
5098
5117
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
5099
- const k = S == null ? void 0 : S.includes(o.replace("root.", ""));
5118
+ const v = S == null ? void 0 : S.includes(o.replace("root.", ""));
5100
5119
  if (u.type === "array") {
5101
- const v = B === o;
5120
+ const k = A === o;
5102
5121
  return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
5103
5122
  u.title && /* @__PURE__ */ jsxs(
5104
5123
  "label",
5105
5124
  {
5106
5125
  htmlFor: o,
5107
- onClick: () => _(v ? null : o),
5126
+ onClick: () => _(k ? null : o),
5108
5127
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
5109
5128
  children: [
5110
- v ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
5129
+ k ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
5111
5130
  /* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
5112
5131
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: r }),
5113
5132
  " ",
@@ -5115,7 +5134,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5115
5134
  ]
5116
5135
  }
5117
5136
  ),
5118
- (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${v ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
5137
+ (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${k ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
5119
5138
  c,
5120
5139
  a,
5121
5140
  l,
@@ -5128,13 +5147,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5128
5147
  /* @__PURE__ */ jsxs("label", { htmlFor: o, className: u.type === "object" ? "pb-2" : "", children: [
5129
5148
  r,
5130
5149
  " ",
5131
- k && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5150
+ v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5132
5151
  " ",
5133
5152
  y
5134
5153
  ] }),
5135
5154
  p && u.type !== "object" ? " *" : null
5136
5155
  ] }),
5137
- u.type === "string" && !u.enum && !u.oneOf && A && /* @__PURE__ */ jsx(NestedPathSelector, { data: A, onSelect: w, dataType: "value" })
5156
+ u.type === "string" && !u.enum && !u.oneOf && B && /* @__PURE__ */ jsx(NestedPathSelector, { data: B, onSelect: w, dataType: "value" })
5138
5157
  ] }),
5139
5158
  c,
5140
5159
  a,
@@ -5147,8 +5166,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5147
5166
  /* @__PURE__ */ jsx("span", { children: "Add" })
5148
5167
  ] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
5149
5168
  const { selectedLang: i } = useLanguages(), [c] = useAtom$1(chaiRjsfWidgetsAtom), [d] = useAtom$1(chaiRjsfFieldsAtom), [p] = useAtom$1(chaiRjsfTemplatesAtom), u = useThrottledCallback(
5150
- async ({ formData: g }, m) => {
5151
- l({ formData: g }, m);
5169
+ async ({ formData: g }, f) => {
5170
+ l({ formData: g }, f);
5152
5171
  },
5153
5172
  [l, i],
5154
5173
  400
@@ -5187,42 +5206,73 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5187
5206
  uiSchema: r,
5188
5207
  schema: n,
5189
5208
  formData: a,
5190
- onChange: ({ formData: g }, m) => {
5191
- if (!m || o !== (g == null ? void 0 : g._id)) return;
5192
- const f = take(m.split("."), 2).join(".").replace("root.", "");
5193
- u({ formData: g }, f);
5209
+ onChange: ({ formData: g }, f) => {
5210
+ if (!f || o !== (g == null ? void 0 : g._id)) return;
5211
+ const m = take(f.split("."), 2).join(".").replace("root.", "");
5212
+ u({ formData: g }, m);
5194
5213
  }
5195
5214
  },
5196
5215
  i
5197
5216
  );
5198
- }), formDataWithSelectedLang = (o, n, r) => {
5217
+ }), GlobalBlockSettings = () => {
5218
+ const o = useSelectedBlock(), { data: n, refetch: r, isLoading: a } = usePartialBlocksList(), l = useUpdateBlocksProps();
5219
+ return /* @__PURE__ */ jsxs("div", { children: [
5220
+ /* @__PURE__ */ jsx("label", { className: "text-sm", children: "Choose a global block" }),
5221
+ /* @__PURE__ */ jsxs(
5222
+ "select",
5223
+ {
5224
+ className: "h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",
5225
+ value: (o == null ? void 0 : o.globalBlock) || "",
5226
+ onChange: (i) => {
5227
+ var c;
5228
+ l([o._id], {
5229
+ globalBlock: i.target.value,
5230
+ _name: `Global Block: ${startCase((c = get(n, i.target.value, "")) == null ? void 0 : c.name)}`
5231
+ });
5232
+ },
5233
+ children: [
5234
+ /* @__PURE__ */ jsx("option", { value: "", children: "Select a global block" }),
5235
+ Object.keys(n).map((i) => /* @__PURE__ */ jsx("option", { value: i, children: n[i].name || i }, i))
5236
+ ]
5237
+ }
5238
+ ),
5239
+ /* @__PURE__ */ jsx("div", { className: "mt-2 text-xs", children: /* @__PURE__ */ jsx(
5240
+ "button",
5241
+ {
5242
+ onClick: r,
5243
+ className: "rounded-md bg-gray-100 p-1 px-2 text-xs hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700",
5244
+ children: a ? "Loading..." : "Refresh List"
5245
+ }
5246
+ ) })
5247
+ ] });
5248
+ }, formDataWithSelectedLang = (o, n, r) => {
5199
5249
  const a = cloneDeep(o);
5200
5250
  return forEach(keys(o), (l) => {
5201
5251
  includes(get(r, "i18nProps", []), l) && !isEmpty(n) && (a[l] = get(o, `${l}-${n}`));
5202
5252
  }), a;
5203
5253
  };
5204
5254
  function BlockSettings() {
5205
- const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), f = formDataWithSelectedLang(g, o, m), h = ({ formData: B }, _, w) => {
5206
- _ && (c == null ? void 0 : c._id) === n._id && a([n._id], { [_]: get(B, _) }, w);
5207
- }, b = useCallback(
5208
- debounce(({ formData: B }, _, w) => {
5209
- h({ formData: B }, _, w), d(B);
5255
+ 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: A }, _, w) => {
5256
+ _ && (c == null ? void 0 : c._id) === n._id && a([n._id], { [_]: get(A, _) }, w);
5257
+ }, x = useCallback(
5258
+ debounce(({ formData: A }, _, w) => {
5259
+ h({ formData: A }, _, w), d(A);
5210
5260
  }, 1500),
5211
5261
  [n == null ? void 0 : n._id, o]
5212
- ), x = ({ formData: B }, _) => {
5213
- _ && (r([n._id], { [_]: get(B, _) }), b({ formData: B }, _, { [_]: get(c, _) }));
5214
- }, y = ({ formData: B }, _) => {
5215
- _ && (r([g._id], { [_]: get(B, _) }), b({ formData: B }, _, { [_]: get(c, _) }));
5262
+ ), b = ({ formData: A }, _) => {
5263
+ _ && (r([n._id], { [_]: get(A, _) }), x({ formData: A }, _, { [_]: get(c, _) }));
5264
+ }, y = ({ formData: A }, _) => {
5265
+ _ && (r([g._id], { [_]: get(A, _) }), x({ formData: A }, _, { [_]: get(c, _) }));
5216
5266
  };
5217
5267
  keys(get(i, "_bindings", {}));
5218
- const { schema: A, uiSchema: j } = useMemo(() => {
5219
- const B = n == null ? void 0 : n._type;
5220
- if (B)
5221
- return getBlockFormSchemas(B);
5268
+ const { schema: B, uiSchema: j } = useMemo(() => {
5269
+ const A = n == null ? void 0 : n._type;
5270
+ if (A)
5271
+ return getBlockFormSchemas(A);
5222
5272
  }, [n]), { wrapperSchema: C, wrapperUiSchema: S } = useMemo(() => {
5223
5273
  if (!g || !(g != null && g._type))
5224
5274
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5225
- const B = g == null ? void 0 : g._type, { schema: _ = {}, uiSchema: w = {} } = getBlockFormSchemas(B);
5275
+ const A = g == null ? void 0 : g._type, { schema: _ = {}, uiSchema: w = {} } = getBlockFormSchemas(A);
5226
5276
  return { wrapperSchema: _, wrapperUiSchema: w };
5227
5277
  }, [g]);
5228
5278
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
@@ -5230,7 +5280,7 @@ function BlockSettings() {
5230
5280
  /* @__PURE__ */ jsxs(
5231
5281
  "div",
5232
5282
  {
5233
- onClick: () => u((B) => !B),
5283
+ onClick: () => u((A) => !A),
5234
5284
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5235
5285
  children: [
5236
5286
  p ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
@@ -5250,19 +5300,19 @@ function BlockSettings() {
5250
5300
  {
5251
5301
  blockId: g == null ? void 0 : g._id,
5252
5302
  onChange: y,
5253
- formData: f,
5303
+ formData: m,
5254
5304
  schema: C,
5255
5305
  uiSchema: S
5256
5306
  }
5257
5307
  ) })
5258
5308
  ] }),
5259
- isEmpty(A) ? null : /* @__PURE__ */ jsx(
5309
+ isEmpty(B) ? null : /* @__PURE__ */ jsx(
5260
5310
  JSONForm,
5261
5311
  {
5262
5312
  blockId: n == null ? void 0 : n._id,
5263
- onChange: x,
5313
+ onChange: b,
5264
5314
  formData: i,
5265
- schema: A,
5315
+ schema: B,
5266
5316
  uiSchema: j
5267
5317
  }
5268
5318
  ),
@@ -5328,57 +5378,72 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5328
5378
  ], BreakpointCard = ({
5329
5379
  canvas: o = !1,
5330
5380
  openDelay: n = 400,
5331
- title: r,
5332
- content: a,
5333
- currentBreakpoint: l,
5334
- breakpoint: i,
5335
- width: c,
5336
- icon: d,
5337
- onClick: p
5381
+ tooltip: r = !0,
5382
+ title: a,
5383
+ content: l,
5384
+ currentBreakpoint: i,
5385
+ breakpoint: c,
5386
+ width: d,
5387
+ icon: p,
5388
+ onClick: u
5338
5389
  }) => {
5339
- const { t: u } = useTranslation();
5340
- return /* @__PURE__ */ jsxs(HoverCard, { openDelay: n, children: [
5390
+ const { t: g } = useTranslation();
5391
+ return r ? /* @__PURE__ */ jsxs(HoverCard, { openDelay: n, children: [
5341
5392
  /* @__PURE__ */ jsx(HoverCardTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5342
5393
  Button,
5343
5394
  {
5344
- onClick: () => p(c),
5395
+ onClick: () => u(d),
5345
5396
  size: "sm",
5346
5397
  className: "h-7 w-7 rounded-md p-1",
5347
- variant: i === l ? "outline" : "ghost",
5348
- children: d
5398
+ variant: c === i ? "outline" : "ghost",
5399
+ children: p
5349
5400
  }
5350
5401
  ) }),
5351
5402
  /* @__PURE__ */ jsx(HoverCardContent, { className: "w-fit max-w-52 border-border", children: /* @__PURE__ */ jsx("div", { className: "flex justify-between space-x-4", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
5352
- /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: u(r) }),
5353
- o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: u(a) })
5403
+ /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: g(a) }),
5404
+ o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: g(l) })
5354
5405
  ] }) }) })
5355
- ] });
5356
- }, Breakpoints$1 = ({ openDelay: o = 400, canvas: n = !1 }) => {
5357
- const [r, , a] = useScreenSizeWidth(), [l, i] = useCanvasDisplayWidth(), [c, d] = useSelectedBreakpoints(), p = c, u = d, { t: g } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (x) => {
5358
- p.includes(x) ? p.length > 2 && u(p.filter((y) => y !== x)) : u((y) => [...y, x]);
5359
- }, h = (x) => {
5360
- n || a(x), i(x);
5361
- }, b = getBreakpointValue(n ? l : r).toLowerCase();
5362
- return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (x) => /* @__PURE__ */ createElement(
5406
+ ] }) : /* @__PURE__ */ jsx(
5407
+ Button,
5408
+ {
5409
+ onClick: () => u(d),
5410
+ size: "sm",
5411
+ className: "h-7 w-7 rounded-md p-1",
5412
+ variant: c === i ? "outline" : "ghost",
5413
+ children: p
5414
+ }
5415
+ );
5416
+ }, Breakpoints$1 = ({
5417
+ openDelay: o = 400,
5418
+ canvas: n = !1,
5419
+ tooltip: r = !0
5420
+ }) => {
5421
+ const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: f } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), h = (y) => {
5422
+ u.includes(y) ? u.length > 2 && g(u.filter((B) => B !== y)) : g((B) => [...B, y]);
5423
+ }, x = (y) => {
5424
+ n || l(y), c(y);
5425
+ }, b = getBreakpointValue(n ? i : a).toLowerCase();
5426
+ return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (y) => /* @__PURE__ */ createElement(
5363
5427
  BreakpointCard,
5364
5428
  {
5365
5429
  canvas: n,
5366
- ...x,
5367
- onClick: h,
5368
- key: x.breakpoint,
5430
+ ...y,
5431
+ onClick: x,
5432
+ key: y.breakpoint,
5369
5433
  currentBreakpoint: b
5370
5434
  }
5371
5435
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
5372
5436
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
5373
- m.filter((x) => includes(p, toUpper(x.breakpoint))),
5374
- (x) => /* @__PURE__ */ createElement(
5437
+ m.filter((y) => includes(u, toUpper(y.breakpoint))),
5438
+ (y) => /* @__PURE__ */ createElement(
5375
5439
  BreakpointCard,
5376
5440
  {
5377
5441
  canvas: n,
5378
5442
  openDelay: o,
5379
- ...x,
5380
- onClick: h,
5381
- key: x.breakpoint,
5443
+ tooltip: r,
5444
+ ...y,
5445
+ onClick: x,
5446
+ key: y.breakpoint,
5382
5447
  currentBreakpoint: b
5383
5448
  }
5384
5449
  )
@@ -5386,17 +5451,17 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5386
5451
  /* @__PURE__ */ jsxs(DropdownMenu, { children: [
5387
5452
  /* @__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" }) }) }),
5388
5453
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
5389
- /* @__PURE__ */ jsx(DropdownMenuLabel, { children: g("Screen sizes") }),
5454
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: f("Screen sizes") }),
5390
5455
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
5391
- map(m, (x) => /* @__PURE__ */ jsx(
5456
+ map(m, (y) => /* @__PURE__ */ jsx(
5392
5457
  DropdownMenuCheckboxItem,
5393
5458
  {
5394
- disabled: x.breakpoint === "xs",
5395
- onCheckedChange: () => f(toUpper(x.breakpoint)),
5396
- checked: includes(p, toUpper(x.breakpoint)),
5397
- children: g(x.title)
5459
+ disabled: y.breakpoint === "xs",
5460
+ onCheckedChange: () => h(toUpper(y.breakpoint)),
5461
+ checked: includes(u, toUpper(y.breakpoint)),
5462
+ children: f(y.title)
5398
5463
  },
5399
- x.breakpoint
5464
+ y.breakpoint
5400
5465
  ))
5401
5466
  ] })
5402
5467
  ] })
@@ -5410,9 +5475,13 @@ function BreakpointSelector() {
5410
5475
  return /* @__PURE__ */ jsxs(Fragment, { children: [
5411
5476
  /* @__PURE__ */ jsxs("div", { className: "sticky top-0 z-10 flex items-center justify-start bg-muted px-2 py-1 shadow-sm", children: [
5412
5477
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Screen: " }),
5413
- /* @__PURE__ */ jsx(Breakpoints$1, { openDelay: 500 })
5478
+ /* @__PURE__ */ jsx(Breakpoints$1, { openDelay: 1e3, tooltip: !1 })
5414
5479
  ] }),
5415
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between rounded-md rounded-t-none border border-border p-1", children: /* @__PURE__ */ jsx("p", { className: "flex-1 text-[10px] text-muted-foreground", children: n }) })
5480
+ /* @__PURE__ */ jsx("div", { className: "mb-2 flex items-center justify-between rounded-md rounded-t-none border border-border p-1", children: /* @__PURE__ */ jsx("p", { className: "flex flex-1 items-center space-x-2 text-[10px] text-foreground", children: /* @__PURE__ */ jsxs("span", { className: "text-xs text-foreground", children: [
5481
+ /* @__PURE__ */ jsx("span", { className: "rounded-md bg-muted px-1 py-px text-xs font-bold uppercase text-muted-foreground", children: o === "xs" ? "Base" : o }),
5482
+ "  ",
5483
+ n
5484
+ ] }) }) })
5416
5485
  ] });
5417
5486
  }
5418
5487
  function FaLanguage(o) {
@@ -5481,11 +5550,11 @@ function Countdown() {
5481
5550
  const AskAIStyles = ({ blockId: o }) => {
5482
5551
  const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
5483
5552
  useEffect(() => {
5484
- var f;
5485
- (f = d.current) == null || f.focus();
5553
+ var m;
5554
+ (m = d.current) == null || m.focus();
5486
5555
  }, []);
5487
- const m = (f) => {
5488
- const { usage: h } = f || {};
5556
+ const f = (m) => {
5557
+ const { usage: h } = m || {};
5489
5558
  !l && h && g(h), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
5490
5559
  };
5491
5560
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
@@ -5495,12 +5564,12 @@ const AskAIStyles = ({ blockId: o }) => {
5495
5564
  {
5496
5565
  ref: d,
5497
5566
  value: i,
5498
- onChange: (f) => c(f.target.value),
5567
+ onChange: (m) => c(m.target.value),
5499
5568
  placeholder: n("Ask AI to edit styles"),
5500
5569
  className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
5501
5570
  rows: 4,
5502
- onKeyDown: (f) => {
5503
- f.key === "Enter" && (f.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
5571
+ onKeyDown: (m) => {
5572
+ m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, f));
5504
5573
  }
5505
5574
  }
5506
5575
  ),
@@ -5510,7 +5579,7 @@ const AskAIStyles = ({ blockId: o }) => {
5510
5579
  {
5511
5580
  disabled: i.trim().length < 5 || a,
5512
5581
  onClick: () => {
5513
- p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m);
5582
+ p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, f);
5514
5583
  },
5515
5584
  variant: "default",
5516
5585
  className: "w-fit",
@@ -5542,14 +5611,14 @@ const AskAIStyles = ({ blockId: o }) => {
5542
5611
  };
5543
5612
  function ManualClasses() {
5544
5613
  var T;
5545
- const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), f = useBuilderProp("askAiCallBack", null), [h, b] = useState(""), x = (T = first(d)) == null ? void 0 : T.prop, { classes: y } = getSplitChaiClasses(get(p, x, "")), A = y.split(" ").filter((I) => !isEmpty(I)), j = () => {
5614
+ 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(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: y } = getSplitChaiClasses(get(p, b, "")), B = y.split(" ").filter((I) => !isEmpty(I)), j = () => {
5546
5615
  const I = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5547
- u(m, I, !0), b("");
5548
- }, [C, S] = useState([]), B = ({ value: I }) => {
5549
- const R = I.trim().toLowerCase(), E = R.match(/.+:/g);
5616
+ u(f, I, !0), x("");
5617
+ }, [C, S] = useState([]), A = ({ value: I }) => {
5618
+ const R = I.trim().toLowerCase(), N = R.match(/.+:/g);
5550
5619
  let D = [];
5551
- if (E && E.length > 0) {
5552
- const [M] = E, P = R.replace(M, "");
5620
+ if (N && N.length > 0) {
5621
+ const [M] = N, P = R.replace(M, "");
5553
5622
  D = i.search(P).map(($) => ({
5554
5623
  ...$,
5555
5624
  item: { ...$.item, name: M + $.item.name }
@@ -5559,7 +5628,7 @@ function ManualClasses() {
5559
5628
  return S(map(D, "item"));
5560
5629
  }, _ = () => {
5561
5630
  S([]);
5562
- }, w = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), k = useMemo(
5631
+ }, w = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), v = useMemo(
5563
5632
  () => ({
5564
5633
  ref: o,
5565
5634
  autoComplete: "off",
@@ -5571,31 +5640,31 @@ function ManualClasses() {
5571
5640
  onKeyDown: (I) => {
5572
5641
  I.key === "Enter" && h.trim() !== "" && j();
5573
5642
  },
5574
- onChange: (I, { newValue: R }) => b(R),
5643
+ onChange: (I, { newValue: R }) => x(R),
5575
5644
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
5576
5645
  }),
5577
5646
  [h, c, o]
5578
- ), v = (I) => {
5647
+ ), k = (I) => {
5579
5648
  debugger;
5580
5649
  const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5581
- g(m, [I]), u(m, R, !0), r(""), l(-1);
5582
- }, N = () => {
5650
+ g(f, [I]), u(f, R, !0), r(""), l(-1);
5651
+ }, E = () => {
5583
5652
  if (navigator.clipboard === void 0) {
5584
5653
  toast.error(c("Clipboard not supported"));
5585
5654
  return;
5586
5655
  }
5587
- navigator.clipboard.writeText(A.join(" ")), toast.success(c("Classes copied to clipboard"));
5656
+ navigator.clipboard.writeText(B.join(" ")), toast.success(c("Classes copied to clipboard"));
5588
5657
  };
5589
5658
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
5590
5659
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
5591
5660
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
5592
5661
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
5593
5662
  /* @__PURE__ */ jsxs(Tooltip, { children: [
5594
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: N, className: "cursor-pointer" }) }),
5663
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: E, className: "cursor-pointer" }) }),
5595
5664
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
5596
5665
  ] })
5597
5666
  ] }),
5598
- f ? /* @__PURE__ */ jsxs(Popover, { children: [
5667
+ m ? /* @__PURE__ */ jsxs(Popover, { children: [
5599
5668
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
5600
5669
  /* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
5601
5670
  /* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
@@ -5608,11 +5677,11 @@ function ManualClasses() {
5608
5677
  Autosuggest,
5609
5678
  {
5610
5679
  suggestions: C,
5611
- onSuggestionsFetchRequested: B,
5680
+ onSuggestionsFetchRequested: A,
5612
5681
  onSuggestionsClearRequested: _,
5613
5682
  getSuggestionValue: w,
5614
5683
  renderSuggestion: L,
5615
- inputProps: k,
5684
+ inputProps: v,
5616
5685
  containerProps: {
5617
5686
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
5618
5687
  },
@@ -5635,18 +5704,18 @@ function ManualClasses() {
5635
5704
  }
5636
5705
  )
5637
5706
  ] }),
5638
- /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: A.map(
5707
+ /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: B.map(
5639
5708
  (I, R) => a === R ? /* @__PURE__ */ jsx(
5640
5709
  "input",
5641
5710
  {
5642
5711
  ref: o,
5643
5712
  value: n,
5644
- onChange: (E) => r(E.target.value),
5713
+ onChange: (N) => r(N.target.value),
5645
5714
  onBlur: () => {
5646
- v(I);
5715
+ k(I);
5647
5716
  },
5648
- onKeyDown: (E) => {
5649
- E.key === "Enter" && v(I);
5717
+ onKeyDown: (N) => {
5718
+ N.key === "Enter" && k(I);
5650
5719
  },
5651
5720
  className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
5652
5721
  },
@@ -5660,7 +5729,7 @@ function ManualClasses() {
5660
5729
  n !== I && /* @__PURE__ */ jsx(
5661
5730
  Cross2Icon,
5662
5731
  {
5663
- onClick: () => g(m, [I], !0),
5732
+ onClick: () => g(f, [I], !0),
5664
5733
  className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
5665
5734
  }
5666
5735
  )
@@ -6006,10 +6075,10 @@ const COLOR_PROP = {
6006
6075
  ringColor: "ring",
6007
6076
  ringOffsetColor: "ring-offset"
6008
6077
  }, ColorChoice = ({ property: o, onChange: n }) => {
6009
- const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""), f = useCallback(
6078
+ 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(
6010
6079
  // eslint-disable-next-line no-shadow
6011
- (x) => {
6012
- ["current", "inherit", "transparent", "black", "white"].includes(x) ? (c([]), p({ color: x })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: x, shade: y.shade ? y.shade : "500" })));
6080
+ (b) => {
6081
+ ["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" })));
6013
6082
  },
6014
6083
  [c, p]
6015
6084
  );
@@ -6020,26 +6089,26 @@ const COLOR_PROP = {
6020
6089
  }, [g]);
6021
6090
  const h = useCallback(
6022
6091
  // eslint-disable-next-line no-shadow
6023
- (x) => {
6024
- p({ color: g, shade: x });
6092
+ (b) => {
6093
+ p({ color: g, shade: b });
6025
6094
  },
6026
6095
  [g]
6027
6096
  );
6028
6097
  useEffect(() => {
6029
6098
  p({ color: "", shade: "" });
6030
6099
  }, [r]);
6031
- const { match: b } = useTailwindClassList();
6100
+ const { match: x } = useTailwindClassList();
6032
6101
  return useEffect(() => {
6033
6102
  const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6034
- b(o, y) && n(y, o);
6035
- }, [b, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
6103
+ x(o, y) && n(y, o);
6104
+ }, [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: [
6036
6105
  /* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
6037
6106
  DropDown,
6038
6107
  {
6039
6108
  disabled: !l,
6040
6109
  rounded: !0,
6041
6110
  selected: g,
6042
- onChange: f,
6111
+ onChange: m,
6043
6112
  options: [
6044
6113
  "current",
6045
6114
  "transparent",
@@ -6072,7 +6141,7 @@ const COLOR_PROP = {
6072
6141
  ]
6073
6142
  }
6074
6143
  ) }),
6075
- /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: h, options: i }) })
6144
+ /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: f, disabled: !g || !l, onChange: h, options: i }) })
6076
6145
  ] });
6077
6146
  }, IconChoices = ({ property: o, onChange: n }) => {
6078
6147
  const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
@@ -6269,52 +6338,52 @@ const COLOR_PROP = {
6269
6338
  },
6270
6339
  a
6271
6340
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
6272
- const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, f] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [h, b] = useState(!1), [x, y] = useState(""), [A, j] = useState(!1), [C, S] = useState(!1);
6341
+ 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), [b, y] = useState(""), [B, j] = useState(!1), [C, S] = useState(!1);
6273
6342
  useEffect(() => {
6274
- const { value: k, unit: v } = getClassValueAndUnit(i);
6275
- if (v === "") {
6276
- l(k), f(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
6343
+ const { value: v, unit: k } = getClassValueAndUnit(i);
6344
+ if (k === "") {
6345
+ l(v), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
6277
6346
  return;
6278
6347
  }
6279
- f(v), l(v === "class" || isEmpty(k) ? "" : k);
6348
+ m(k), l(k === "class" || isEmpty(v) ? "" : v);
6280
6349
  }, [i, p, u]);
6281
- const B = useThrottledCallback((k) => c(k), [c], THROTTLE_TIME), _ = useThrottledCallback((k) => c(k, !1), [c], THROTTLE_TIME), w = useCallback(
6282
- (k = !1) => {
6283
- const v = getUserInputValues(`${a}`, u);
6284
- if (get(v, "error", !1)) {
6285
- b(!0);
6350
+ const A = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), _ = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), w = useCallback(
6351
+ (v = !1) => {
6352
+ const k = getUserInputValues(`${a}`, u);
6353
+ if (get(k, "error", !1)) {
6354
+ x(!0);
6286
6355
  return;
6287
6356
  }
6288
- const N = get(v, "unit") !== "" ? get(v, "unit") : m;
6289
- if (N === "auto" || N === "none") {
6290
- B(`${d}${N}`);
6357
+ const E = get(k, "unit") !== "" ? get(k, "unit") : f;
6358
+ if (E === "auto" || E === "none") {
6359
+ A(`${d}${E}`);
6291
6360
  return;
6292
6361
  }
6293
- if (get(v, "value") === "")
6362
+ if (get(k, "value") === "")
6294
6363
  return;
6295
- const I = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
6296
- k ? _(I) : B(I);
6364
+ const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
6365
+ v ? _(I) : A(I);
6297
6366
  },
6298
- [B, _, a, m, d, u]
6367
+ [A, _, a, f, d, u]
6299
6368
  ), L = useCallback(
6300
- (k) => {
6301
- const v = getUserInputValues(`${a}`, u);
6302
- if (get(v, "error", !1)) {
6303
- b(!0);
6369
+ (v) => {
6370
+ const k = getUserInputValues(`${a}`, u);
6371
+ if (get(k, "error", !1)) {
6372
+ x(!0);
6304
6373
  return;
6305
6374
  }
6306
- if (k === "auto" || k === "none") {
6307
- B(`${d}${k}`);
6375
+ if (v === "auto" || v === "none") {
6376
+ A(`${d}${v}`);
6308
6377
  return;
6309
6378
  }
6310
- if (get(v, "value") === "")
6379
+ if (get(k, "value") === "")
6311
6380
  return;
6312
- const N = get(v, "unit") !== "" ? get(v, "unit") : k, I = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
6313
- B(I);
6381
+ const E = get(k, "unit") !== "" ? get(k, "unit") : v, I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
6382
+ A(I);
6314
6383
  },
6315
- [B, a, d, u]
6384
+ [A, a, d, u]
6316
6385
  );
6317
- return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
6386
+ 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: [
6318
6387
  /* @__PURE__ */ jsx(
6319
6388
  "input",
6320
6389
  {
@@ -6327,37 +6396,37 @@ const COLOR_PROP = {
6327
6396
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsx(InfoCircledIcon, {}) }) }),
6328
6397
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
6329
6398
  ] })
6330
- ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
6399
+ ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${B ? "z-auto" : ""}`, children: [
6331
6400
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
6332
- ["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
6401
+ ["none", "auto"].indexOf(f) !== -1 ? null : /* @__PURE__ */ jsx(
6333
6402
  "input",
6334
6403
  {
6335
- readOnly: m === "class",
6336
- onKeyPress: (k) => {
6337
- k.key === "Enter" && w();
6404
+ readOnly: f === "class",
6405
+ onKeyPress: (v) => {
6406
+ v.key === "Enter" && w();
6338
6407
  },
6339
- onKeyDown: (k) => {
6340
- if (k.keyCode !== 38 && k.keyCode !== 40)
6408
+ onKeyDown: (v) => {
6409
+ if (v.keyCode !== 38 && v.keyCode !== 40)
6341
6410
  return;
6342
- k.preventDefault(), S(!0);
6343
- const v = parseInt$1(k.target.value);
6344
- let N = isNaN$1(v) ? 0 : v;
6345
- k.keyCode === 38 && (N += 1), k.keyCode === 40 && (N -= 1);
6346
- const T = `${N}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${m === "-" ? "" : m}]`;
6411
+ v.preventDefault(), S(!0);
6412
+ const k = parseInt$1(v.target.value);
6413
+ let E = isNaN$1(k) ? 0 : k;
6414
+ v.keyCode === 38 && (E += 1), v.keyCode === 40 && (E -= 1);
6415
+ const T = `${E}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${f === "-" ? "" : f}]`;
6347
6416
  _(R);
6348
6417
  },
6349
- onKeyUp: (k) => {
6350
- C && (k.preventDefault(), S(!1));
6418
+ onKeyUp: (v) => {
6419
+ C && (v.preventDefault(), S(!1));
6351
6420
  },
6352
6421
  onBlur: () => w(),
6353
- onChange: (k) => {
6354
- b(!1), l(k.target.value);
6422
+ onChange: (v) => {
6423
+ x(!1), l(v.target.value);
6355
6424
  },
6356
- onClick: (k) => {
6357
- var v;
6358
- (v = k == null ? void 0 : k.target) == null || v.select(), r(!1);
6425
+ onClick: (v) => {
6426
+ var k;
6427
+ (k = v == null ? void 0 : v.target) == null || k.select(), r(!1);
6359
6428
  },
6360
- value: A ? x : a,
6429
+ value: B ? b : a,
6361
6430
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
6362
6431
  " ",
6363
6432
  h ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -6372,7 +6441,7 @@ const COLOR_PROP = {
6372
6441
  onClick: () => r(!n),
6373
6442
  className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
6374
6443
  children: [
6375
- /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
6444
+ /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: f }),
6376
6445
  u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
6377
6446
  ]
6378
6447
  }
@@ -6381,33 +6450,33 @@ const COLOR_PROP = {
6381
6450
  UnitSelection,
6382
6451
  {
6383
6452
  units: u,
6384
- current: m,
6385
- onSelect: (k) => {
6386
- r(!1), f(k), L(k);
6453
+ current: f,
6454
+ onSelect: (v) => {
6455
+ r(!1), m(v), L(v);
6387
6456
  }
6388
6457
  }
6389
6458
  ) }) })
6390
6459
  ] })
6391
6460
  ] }),
6392
- ["none", "auto"].indexOf(m) !== -1 || A ? null : /* @__PURE__ */ jsx(
6461
+ ["none", "auto"].indexOf(f) !== -1 || B ? null : /* @__PURE__ */ jsx(
6393
6462
  DragStyleButton,
6394
6463
  {
6395
6464
  onDragStart: () => j(!0),
6396
- onDragEnd: (k) => {
6397
- if (y(() => ""), j(!1), isEmpty(k))
6465
+ onDragEnd: (v) => {
6466
+ if (y(() => ""), j(!1), isEmpty(v))
6398
6467
  return;
6399
- const v = `${k}`, T = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${m === "-" ? "" : m}]`;
6400
- B(T);
6468
+ const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${f === "-" ? "" : f}]`;
6469
+ A(T);
6401
6470
  },
6402
- onDrag: (k) => {
6403
- if (isEmpty(k))
6471
+ onDrag: (v) => {
6472
+ if (isEmpty(v))
6404
6473
  return;
6405
- y(k);
6406
- const v = `${k}`, T = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${m === "-" ? "" : m}]`;
6474
+ y(v);
6475
+ const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${f === "-" ? "" : f}]`;
6407
6476
  _(T);
6408
6477
  },
6409
6478
  currentValue: a,
6410
- unit: m,
6479
+ unit: f,
6411
6480
  negative: g,
6412
6481
  cssProperty: p
6413
6482
  }
@@ -6501,20 +6570,20 @@ const COLOR_PROP = {
6501
6570
  "2xl": "1536px"
6502
6571
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6503
6572
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
6504
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), f = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [b] = useSelectedBlockIds(), x = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
6573
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), f = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(f, "fullCls", ""), [f]), y = useCallback(
6505
6574
  (_, w = !0) => {
6506
6575
  const L = { dark: p, mq: g, mod: u, cls: _, property: l, fullCls: "" };
6507
6576
  (p || u !== "") && (L.mq = "xs");
6508
- const k = generateFullClsName(L);
6509
- f(b, [k], w);
6577
+ const v = generateFullClsName(L);
6578
+ m(x, [v], w);
6510
6579
  },
6511
- [b, p, g, u, l, f]
6512
- ), A = useCallback(() => {
6513
- h(b, [x], !0);
6514
- }, [b, x, h]), j = useMemo(() => canChangeClass(m, g), [m, g]);
6580
+ [x, p, g, u, l, m]
6581
+ ), B = useCallback(() => {
6582
+ h(x, [b], !0);
6583
+ }, [x, b, h]), j = useMemo(() => canChangeClass(f, g), [f, g]);
6515
6584
  useEffect(() => {
6516
- i(j, m);
6517
- }, [j, i, m]);
6585
+ i(j, f);
6586
+ }, [j, i, f]);
6518
6587
  const [, , C] = useScreenSizeWidth(), S = useCallback(
6519
6588
  (_) => {
6520
6589
  C({
@@ -6527,15 +6596,15 @@ const COLOR_PROP = {
6527
6596
  }[_]);
6528
6597
  },
6529
6598
  [C]
6530
- ), B = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6531
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: j, canReset: m && B, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6532
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !B ? "text-foreground" : ""}`, children: n(a) }) }),
6599
+ ), A = get(f, "dark", null) === p && get(f, "mod", null) === u && get(f, "mq", null) === g;
6600
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: j, canReset: f && A, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6601
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${f && !A ? "text-foreground" : ""}`, children: n(a) }) }),
6533
6602
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6534
6603
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
6535
6604
  r === "arbitrary" ? /* @__PURE__ */ jsx(
6536
6605
  AdvanceChoices,
6537
6606
  {
6538
- currentClass: get(m, "cls", ""),
6607
+ currentClass: get(f, "cls", ""),
6539
6608
  classPrefix: get(CLASS_PREFIXES, l, ""),
6540
6609
  units: c || [],
6541
6610
  onChange: y,
@@ -6548,7 +6617,7 @@ const COLOR_PROP = {
6548
6617
  r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
6549
6618
  r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
6550
6619
  ] }),
6551
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${x ? "visible" : "invisible"}`, children: B ? /* @__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" }) }) : j && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6620
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: A ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => B(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : j && f ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6552
6621
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6553
6622
  "button",
6554
6623
  {
@@ -6560,19 +6629,19 @@ const COLOR_PROP = {
6560
6629
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
6561
6630
  "Current style is set at  ",
6562
6631
  /* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
6563
- getBreakpoint(get(m, "mq")),
6564
- p && !m.dark ? "(Light mode)" : ""
6632
+ getBreakpoint(get(f, "mq")),
6633
+ p && !f.dark ? "(Light mode)" : ""
6565
6634
  ] }),
6566
6635
  /* @__PURE__ */ jsx("br", {}),
6567
6636
  /* @__PURE__ */ jsxs(
6568
6637
  "button",
6569
6638
  {
6570
6639
  type: "button",
6571
- onClick: () => S(get(m, "mq")),
6640
+ onClick: () => S(get(f, "mq")),
6572
6641
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
6573
6642
  children: [
6574
6643
  "Switch to ",
6575
- get(m, "mq").toUpperCase()
6644
+ get(f, "mq").toUpperCase()
6576
6645
  ]
6577
6646
  }
6578
6647
  )
@@ -6589,7 +6658,7 @@ const COLOR_PROP = {
6589
6658
  units: i = basicUnits,
6590
6659
  negative: c = !1
6591
6660
  }) => {
6592
- const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((f) => map(g, "property").includes(f), [g]);
6661
+ const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), f = useCallback((m) => map(g, "property").includes(m), [g]);
6593
6662
  return /* @__PURE__ */ jsxs(
6594
6663
  "div",
6595
6664
  {
@@ -6598,7 +6667,7 @@ const COLOR_PROP = {
6598
6667
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
6599
6668
  o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
6600
6669
  /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
6601
- n.map(({ label: f, key: h }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6670
+ n.map(({ label: m, key: h }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6602
6671
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6603
6672
  "button",
6604
6673
  {
@@ -6607,13 +6676,13 @@ const COLOR_PROP = {
6607
6676
  className: `relative cursor-pointer rounded-full p-1 text-[8px] ${h === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6608
6677
  children: [
6609
6678
  React__default.createElement("div", {
6610
- className: m(h) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6679
+ className: f(h) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6611
6680
  }),
6612
6681
  React__default.createElement(get(EDITOR_ICONS, h, BoxIcon), { className: "text-inherit w-3 h-3" })
6613
6682
  ]
6614
6683
  }
6615
6684
  ) }),
6616
- /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(f)) })
6685
+ /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(m)) })
6617
6686
  ] }) }))
6618
6687
  ) })
6619
6688
  ] }),
@@ -6752,13 +6821,13 @@ function BlockStyling() {
6752
6821
  cssProperty: ""
6753
6822
  }), d = useThrottledCallback(
6754
6823
  (u) => {
6755
- const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
6756
- let f = parseFloat(i.dragStartValue);
6757
- f = isNaN(f) ? 0 : f;
6824
+ const g = !get(i, "negative", !1), f = get(i, "cssProperty", "");
6825
+ let m = parseFloat(i.dragStartValue);
6826
+ m = isNaN(m) ? 0 : m;
6758
6827
  let h = MAPPER[i.dragUnit];
6759
- (startsWith(m, "scale") || m === "opacity") && (h = 10);
6760
- let x = (i.dragStartY - u.pageY) / h + f;
6761
- g && x < 0 && (x = 0), m === "opacity" && x > 1 && (x = 1), i.onDrag(`${x}`), l(`${x}`);
6828
+ (startsWith(f, "scale") || f === "opacity") && (h = 10);
6829
+ let b = (i.dragStartY - u.pageY) / h + m;
6830
+ g && b < 0 && (b = 0), f === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
6762
6831
  },
6763
6832
  [i],
6764
6833
  50
@@ -6800,35 +6869,35 @@ const CoreBlock = ({
6800
6869
  parentId: r,
6801
6870
  position: a
6802
6871
  }) => {
6803
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), f = () => {
6804
- if (has(o, "blocks")) {
6805
- const x = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
6806
- u(syncBlocksWithDefaults(x), r || null, a);
6872
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: f } = useBlockHighlight(), m = () => {
6873
+ if (console.log("addBlockToPage", o), has(o, "blocks")) {
6874
+ const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
6875
+ u(syncBlocksWithDefaults(b), r || null, a);
6807
6876
  } else
6808
6877
  p(o, r || null, a);
6809
6878
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6810
- }, h = useFeature("dnd"), { t: b } = useTranslation();
6879
+ }, h = useFeature("dnd"), { t: x } = useTranslation();
6811
6880
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6812
6881
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6813
6882
  "button",
6814
6883
  {
6815
6884
  disabled: n,
6816
- onClick: f,
6885
+ onClick: m,
6817
6886
  type: "button",
6818
- onDragStart: (x) => {
6819
- x.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), x.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6820
- g([]), m();
6887
+ onDragStart: (b) => {
6888
+ b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6889
+ g([]), f();
6821
6890
  }, 200);
6822
6891
  },
6823
6892
  draggable: h ? "true" : "false",
6824
6893
  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",
6825
6894
  children: [
6826
6895
  createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
6827
- /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(b(d || i)) })
6896
+ /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
6828
6897
  ]
6829
6898
  }
6830
6899
  ) }),
6831
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: b(d || i) }) })
6900
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
6832
6901
  ] }) });
6833
6902
  }, DefaultChaiBlocks = ({
6834
6903
  parentId: o,
@@ -7016,7 +7085,7 @@ const CoreBlock = ({
7016
7085
  }
7017
7086
  }
7018
7087
  }, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
7019
- var m, f, h, b, x, y, A, j;
7088
+ var f, m, h, x, b, y, B, j;
7020
7089
  if (r.type === "comment") return [];
7021
7090
  console.log("node ===>", r);
7022
7091
  let a = { _id: generateUUID() };
@@ -7057,29 +7126,29 @@ const CoreBlock = ({
7057
7126
  ];
7058
7127
  a = {
7059
7128
  ...a,
7060
- href: ((m = l.find((S) => S.key === "href")) == null ? void 0 : m.value) || "",
7061
- hrefType: ((f = l.find((S) => S.key === "data-vbtype")) == null ? void 0 : f.value) || "video",
7129
+ href: ((f = l.find((S) => S.key === "href")) == null ? void 0 : f.value) || "",
7130
+ hrefType: ((m = l.find((S) => S.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
7062
7131
  autoplay: ((h = l.find((S) => S.key === "data-autoplay")) == null ? void 0 : h.value) === "true" ? "true" : "false",
7063
- maxWidth: ((x = (b = l.find((S) => S.key === "data-maxwidth")) == null ? void 0 : b.value) == null ? void 0 : x.replace("px", "")) || "",
7132
+ maxWidth: ((b = (x = l.find((S) => S.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : b.replace("px", "")) || "",
7064
7133
  backdropColor: ((y = l.find((S) => S.key === "data-overlay")) == null ? void 0 : y.value) || "",
7065
- galleryName: ((A = l.find((S) => S.key === "data-gall")) == null ? void 0 : A.value) || ""
7134
+ galleryName: ((B = l.find((S) => S.key === "data-gall")) == null ? void 0 : B.value) || ""
7066
7135
  }, forEach(C, (S) => {
7067
7136
  has(a, `styles_attrs.${S}`) && delete a.styles_attrs[S];
7068
7137
  });
7069
7138
  }
7070
7139
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
7071
7140
  delete a.styles_attrs;
7072
- const C = filter(r.children || [], (B) => (B == null ? void 0 : B.tagName) !== "span");
7141
+ const C = filter(r.children || [], (A) => (A == null ? void 0 : A.tagName) !== "span");
7073
7142
  a.content = getTextContent(C);
7074
7143
  const S = find(
7075
7144
  r.children || [],
7076
- (B) => (B == null ? void 0 : B.tagName) === "span" && some(B.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg")
7145
+ (A) => (A == null ? void 0 : A.tagName) === "span" && some(A.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg")
7077
7146
  );
7078
7147
  if (S) {
7079
- const B = find(S.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg");
7080
- if (B) {
7081
- a.icon = stringify([B]);
7082
- const { height: _, width: w } = getSvgDimensions(B, "16px", "16px");
7148
+ const A = find(S.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg");
7149
+ if (A) {
7150
+ a.icon = stringify([A]);
7151
+ const { height: _, width: w } = getSvgDimensions(A, "16px", "16px");
7083
7152
  a.iconHeight = _, a.iconWidth = w;
7084
7153
  }
7085
7154
  }
@@ -7092,8 +7161,8 @@ const CoreBlock = ({
7092
7161
  const C = stringify([r]);
7093
7162
  return hasVideoEmbed(C) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(C)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = C, [a];
7094
7163
  } else if (r.tagName === "svg") {
7095
- const C = find(r.attributes, { key: "height" }), S = find(r.attributes, { key: "width" }), B = get(C, "value") ? `[${get(C, "value")}px]` : "24px", _ = get(S, "value") ? `[${get(S, "value")}px]` : "24px", w = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
7096
- return a.styles = `${STYLES_KEY}, ${cn$1(`w-${_} h-${B}`, w)}`.trim(), r.attributes = filter(r.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([r]), [a];
7164
+ const C = find(r.attributes, { key: "height" }), S = find(r.attributes, { key: "width" }), A = get(C, "value") ? `[${get(C, "value")}px]` : "24px", _ = get(S, "value") ? `[${get(S, "value")}px]` : "24px", w = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
7165
+ return a.styles = `${STYLES_KEY}, ${cn$1(`w-${_} h-${A}`, w)}`.trim(), r.attributes = filter(r.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([r]), [a];
7097
7166
  } else if (r.tagName == "option" && n && ((j = n.block) == null ? void 0 : j._type) === "Select")
7098
7167
  return n.block.options.push({
7099
7168
  label: getTextContent(r.children),
@@ -7142,23 +7211,129 @@ const CoreBlock = ({
7142
7211
  ] }) }),
7143
7212
  /* @__PURE__ */ jsx(CardFooter, { className: "flex flex-col justify-end p-3", children: /* @__PURE__ */ jsx(Button, { disabled: a.trim() === "", onClick: () => c(), size: "sm", className: "w-fit", children: r("Import HTML") }) })
7144
7213
  ] });
7214
+ }, partialBlocksDataAtom = atom$1({
7215
+ blocks: [],
7216
+ groups: [],
7217
+ isLoading: !0,
7218
+ error: null
7219
+ }), hasInitializedPartialBlocksAtom = atom$1(!1), formatReadableName = (o) => {
7220
+ if (!o) return "";
7221
+ let n = o.replace(/[-_]/g, " ");
7222
+ return n = n.replace(/([a-z])([A-Z])/g, "$1 $2"), n.split(" ").map((r) => r.charAt(0).toUpperCase() + r.slice(1).toLowerCase()).join(" ");
7223
+ }, PartialBlocks = ({
7224
+ parentId: o,
7225
+ position: n,
7226
+ gridCols: r = "grid-cols-2"
7227
+ }) => {
7228
+ const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u, g] = useAtom$1(hasInitializedPartialBlocksAtom);
7229
+ useEffect(() => {
7230
+ if (!u || Object.keys(d.blocks).length === 0)
7231
+ if (c)
7232
+ p({
7233
+ blocks: [],
7234
+ groups: [],
7235
+ isLoading: !1,
7236
+ error: c
7237
+ }), g(!0);
7238
+ else if (!l && Object.keys(a || {}).length > 0) {
7239
+ const m = Object.entries(a).map(([x, b]) => {
7240
+ const y = b, B = y.type || "partial", j = formatReadableName(B);
7241
+ return {
7242
+ type: "PartialBlock",
7243
+ // Set the type to PartialBlock
7244
+ label: formatReadableName(y.name || x),
7245
+ description: y.description || "",
7246
+ group: j,
7247
+ // Use formatted type as group
7248
+ category: "partial",
7249
+ partialBlockId: x
7250
+ // Store the original ID as partialBlockId
7251
+ };
7252
+ }), h = uniq(map(m, "group"));
7253
+ p({
7254
+ blocks: m,
7255
+ groups: h,
7256
+ isLoading: !1,
7257
+ error: null
7258
+ }), g(!0);
7259
+ } else l ? p((m) => ({ ...m, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
7260
+ blocks: [],
7261
+ groups: [],
7262
+ isLoading: !1,
7263
+ error: "No partial blocks available"
7264
+ }), g(!0));
7265
+ }, [
7266
+ l,
7267
+ a,
7268
+ u,
7269
+ g,
7270
+ p,
7271
+ d.blocks,
7272
+ c
7273
+ ]);
7274
+ const f = () => {
7275
+ p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
7276
+ };
7277
+ 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: [
7278
+ /* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
7279
+ /* @__PURE__ */ jsx(
7280
+ "button",
7281
+ {
7282
+ onClick: f,
7283
+ className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
7284
+ children: "Refresh"
7285
+ }
7286
+ )
7287
+ ] }) : /* @__PURE__ */ jsx(
7288
+ ChaiBuilderBlocks,
7289
+ {
7290
+ gridCols: r,
7291
+ parentId: o,
7292
+ position: n,
7293
+ groups: d.groups,
7294
+ blocks: d.blocks
7295
+ }
7296
+ );
7145
7297
  }, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
7146
- var b;
7147
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (b = find(c, (x) => x._id === r)) == null ? void 0 : b._type;
7298
+ var v;
7299
+ 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, b] = useState(null), y = useRef(null);
7148
7300
  useEffect(() => {
7149
- const x = setTimeout(() => {
7150
- var y;
7151
- (y = u.current) == null || y.focus();
7301
+ const k = setTimeout(() => {
7302
+ var E;
7303
+ (E = u.current) == null || E.focus();
7152
7304
  }, 0);
7153
- return () => clearTimeout(x);
7154
- }, [g]);
7155
- const f = d ? values(n).filter(
7156
- (x) => {
7157
- var y, A;
7158
- return (((y = x.label) == null ? void 0 : y.toLowerCase()) + " " + ((A = x.type) == null ? void 0 : A.toLowerCase())).includes(d.toLowerCase());
7159
- }
7160
- ) : n, h = d ? o.filter((x) => reject(filter(values(f), { group: x }), { hidden: !0 }).length > 0) : o.filter((x) => reject(filter(values(n), { group: x }), { hidden: !0 }).length > 0);
7161
- return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-2xl flex-col", children: [
7305
+ return () => clearTimeout(k);
7306
+ }, [g]), useEffect(() => {
7307
+ d && (h("all"), b(null));
7308
+ }, [d]), useEffect(() => (y.current = debounce((k) => {
7309
+ h(k);
7310
+ }, 500), () => {
7311
+ y.current && y.current.cancel();
7312
+ }), []);
7313
+ const B = useCallback((k) => {
7314
+ b(k), y.current && y.current(k);
7315
+ }, []), j = useCallback(() => {
7316
+ b(null), y.current && y.current.cancel();
7317
+ }, []), C = useCallback((k) => {
7318
+ y.current && y.current.cancel(), h(k), b(null);
7319
+ }, []), S = useMemo(
7320
+ () => d ? values(n).filter(
7321
+ (k) => {
7322
+ var E, T;
7323
+ return (((E = k.label) == null ? void 0 : E.toLowerCase()) + " " + ((T = k.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
7324
+ }
7325
+ ) : n,
7326
+ [n, d]
7327
+ ), A = useMemo(
7328
+ () => d ? o.filter(
7329
+ (k) => reject(filter(values(S), { group: k }), { hidden: !0 }).length > 0
7330
+ ) : o.filter((k) => reject(filter(values(n), { group: k }), { hidden: !0 }).length > 0),
7331
+ [n, S, o, d]
7332
+ ), _ = useMemo(
7333
+ () => sortBy(A, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7334
+ [A]
7335
+ ), w = useMemo(() => m === "all" ? S : filter(values(S), { group: m }), [S, m]), L = useMemo(() => m === "all" ? _ : [m], [_, m]);
7336
+ return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7162
7337
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7163
7338
  Input$1,
7164
7339
  {
@@ -7166,32 +7341,59 @@ const CoreBlock = ({
7166
7341
  type: "search",
7167
7342
  placeholder: i("Search blocks..."),
7168
7343
  value: d,
7169
- onChange: (x) => p(x.target.value)
7344
+ className: "-ml-2",
7345
+ onChange: (k) => p(k.target.value)
7170
7346
  }
7171
7347
  ) }),
7172
- /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: h.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
7173
- i("No blocks found matching"),
7174
- ' "',
7175
- d,
7176
- '"'
7177
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: sortBy(
7178
- h,
7179
- (x) => CORE_GROUPS.indexOf(x) === -1 ? 99 : CORE_GROUPS.indexOf(x)
7180
- ).map((x) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7181
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(x.toLowerCase())) }),
7182
- /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
7183
- reject(filter(values(f), { group: x }), { hidden: !0 }).map((y) => /* @__PURE__ */ jsx(
7184
- CoreBlock,
7348
+ /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
7349
+ _.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
7350
+ /* @__PURE__ */ jsx(
7351
+ "button",
7352
+ {
7353
+ onClick: () => C("all"),
7354
+ onMouseEnter: () => B("all"),
7355
+ onMouseLeave: j,
7356
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || x === "all" ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7357
+ children: i("All")
7358
+ },
7359
+ "sidebar-all"
7360
+ ),
7361
+ _.map((k) => /* @__PURE__ */ jsx(
7362
+ "button",
7185
7363
  {
7186
- parentId: r,
7187
- position: a,
7188
- block: y,
7189
- disabled: !canAcceptChildBlock(m, y.type) || !canBeNestedInside(m, y.type)
7364
+ onClick: () => C(k),
7365
+ onMouseEnter: () => B(k),
7366
+ onMouseLeave: j,
7367
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === k || x === k ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7368
+ children: capitalize(i(k.toLowerCase()))
7190
7369
  },
7191
- y.type
7370
+ `sidebar-${k}`
7192
7371
  ))
7193
- ) })
7194
- ] }, x)) }) })
7372
+ ] }) }) }),
7373
+ /* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: A.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
7374
+ i("No blocks found matching"),
7375
+ ' "',
7376
+ d,
7377
+ '"'
7378
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7379
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
7380
+ /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
7381
+ reject(
7382
+ m === "all" ? filter(values(w), { group: k }) : values(w),
7383
+ { hidden: !0 }
7384
+ ).map((E) => /* @__PURE__ */ jsx(
7385
+ CoreBlock,
7386
+ {
7387
+ parentId: r,
7388
+ position: a,
7389
+ block: E,
7390
+ disabled: !canAcceptChildBlock(f, E.type) || !canBeNestedInside(f, E.type)
7391
+ },
7392
+ E.type
7393
+ ))
7394
+ ) })
7395
+ ] }, k)) }) }) })
7396
+ ] })
7195
7397
  ] });
7196
7398
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
7197
7399
  className: o,
@@ -7199,7 +7401,11 @@ const CoreBlock = ({
7199
7401
  parentId: r = void 0,
7200
7402
  position: a = -1
7201
7403
  }) => {
7202
- const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), g = useCallback(() => {
7404
+ 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;
7405
+ useEffect(() => {
7406
+ i === "partials" && !f && c("library");
7407
+ }, [i, f, c]);
7408
+ const m = useCallback(() => {
7203
7409
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7204
7410
  }, []);
7205
7411
  return /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
@@ -7210,8 +7416,8 @@ const CoreBlock = ({
7210
7416
  /* @__PURE__ */ jsxs(
7211
7417
  Tabs,
7212
7418
  {
7213
- onValueChange: (m) => {
7214
- d(""), c(m);
7419
+ onValueChange: (h) => {
7420
+ d(""), c(h);
7215
7421
  },
7216
7422
  value: i,
7217
7423
  className: "flex h-full max-h-full flex-col overflow-hidden",
@@ -7219,13 +7425,15 @@ const CoreBlock = ({
7219
7425
  /* @__PURE__ */ jsxs(TabsList, { className: "flex w-full items-center", children: [
7220
7426
  /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
7221
7427
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
7428
+ f && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7222
7429
  p ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7223
- map(u, (m) => /* @__PURE__ */ jsx(TabsTrigger, { value: m.key, children: React__default.createElement(m.tab) }))
7430
+ map(u, (h) => /* @__PURE__ */ jsx(TabsTrigger, { value: h.key, children: React__default.createElement(h.tab) }))
7224
7431
  ] }),
7225
- /* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ScrollArea, { className: "-mx-1.5 h-full max-h-full overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "mt-2 w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7432
+ /* @__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 }) }) }) }),
7226
7433
  /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
7434
+ 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 }) }) }) }),
7227
7435
  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,
7228
- map(u, (m) => /* @__PURE__ */ jsx(TabsContent, { value: m.key, children: React__default.createElement(m.tabContent, { close: g, parentId: r, position: a }) }))
7436
+ map(u, (h) => /* @__PURE__ */ jsx(TabsContent, { value: h.key, children: React__default.createElement(h.tabContent, { close: m, parentId: r, position: a }) }))
7229
7437
  ]
7230
7438
  }
7231
7439
  )
@@ -7282,12 +7490,12 @@ const BlockCard = ({
7282
7490
  parentId: r = void 0,
7283
7491
  position: a = -1
7284
7492
  }) => {
7285
- const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), f = useFeature("dnd"), [, h] = useAtom$1(draggedBlockAtom), b = (A) => {
7286
- const j = has(A, "styles_attrs.data-page-section");
7287
- return A._type === "Box" && j;
7288
- }, x = useCallback(
7289
- async (A) => {
7290
- if (A.stopPropagation(), has(o, "component")) {
7493
+ 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 = (B) => {
7494
+ const j = has(B, "styles_attrs.data-page-section");
7495
+ return B._type === "Box" && j;
7496
+ }, b = useCallback(
7497
+ async (B) => {
7498
+ if (B.stopPropagation(), has(o, "component")) {
7291
7499
  d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7292
7500
  return;
7293
7501
  }
@@ -7302,20 +7510,20 @@ const BlockCard = ({
7302
7510
  "div",
7303
7511
  {
7304
7512
  onClick: l ? () => {
7305
- } : x,
7306
- draggable: f ? "true" : "false",
7307
- onDragStart: async (A) => {
7513
+ } : b,
7514
+ draggable: m ? "true" : "false",
7515
+ onDragStart: async (B) => {
7308
7516
  const j = await c(n, o);
7309
7517
  let C = r;
7310
- if (b(first(j)) && (C = null), !isEmpty(j)) {
7518
+ if (x(first(j)) && (C = null), !isEmpty(j)) {
7311
7519
  const S = { blocks: j, uiLibrary: !0, parent: C };
7312
- if (A.dataTransfer.setData("text/plain", JSON.stringify(S)), o.preview) {
7313
- const B = new Image();
7314
- B.src = o.preview, B.onload = () => {
7315
- A.dataTransfer.setDragImage(B, 0, 0);
7520
+ if (B.dataTransfer.setData("text/plain", JSON.stringify(S)), o.preview) {
7521
+ const A = new Image();
7522
+ A.src = o.preview, A.onload = () => {
7523
+ B.dataTransfer.setDragImage(A, 0, 0);
7316
7524
  };
7317
7525
  } else
7318
- A.dataTransfer.setDragImage(new Image(), 0, 0);
7526
+ B.dataTransfer.setDragImage(new Image(), 0, 0);
7319
7527
  h(S), setTimeout(() => {
7320
7528
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7321
7529
  }, 200);
@@ -7329,11 +7537,11 @@ const BlockCard = ({
7329
7537
  /* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
7330
7538
  /* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
7331
7539
  ] }),
7332
- o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: m }) : /* @__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: m }) })
7540
+ 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 }) })
7333
7541
  ]
7334
7542
  }
7335
7543
  ) }),
7336
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: m }) })
7544
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: f }) })
7337
7545
  ] });
7338
7546
  }, libraryBlocksAtom = atom$1(
7339
7547
  {}
@@ -7348,9 +7556,9 @@ const BlockCard = ({
7348
7556
  })();
7349
7557
  }, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
7350
7558
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7351
- const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((C) => C.category === "custom"), d = l.find((C) => C.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [m, f] = useState("Hero"), h = get(g, m, []), b = useRef(null), { t: x } = useTranslation(), y = (C) => {
7352
- b.current && (clearTimeout(b.current), b.current = null), b.current = setTimeout(() => {
7353
- b.current && f(C);
7559
+ const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((C) => C.category === "custom"), d = l.find((C) => C.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: b } = useTranslation(), y = (C) => {
7560
+ x.current && (clearTimeout(x.current), x.current = null), x.current = setTimeout(() => {
7561
+ x.current && m(C);
7354
7562
  }, 300);
7355
7563
  };
7356
7564
  if (u)
@@ -7358,26 +7566,26 @@ const BlockCard = ({
7358
7566
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7359
7567
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7360
7568
  ] });
7361
- const A = filter(h, (C, S) => S % 2 === 0), j = filter(h, (C, S) => S % 2 === 1);
7569
+ const B = filter(h, (C, S) => S % 2 === 0), j = filter(h, (C, S) => S % 2 === 1);
7362
7570
  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: [
7363
7571
  /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
7364
7572
  /* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
7365
7573
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7366
- /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: x("Groups") }),
7574
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: b("Groups") }),
7367
7575
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7368
7576
  /* @__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(
7369
7577
  map(g, (C, S) => /* @__PURE__ */ jsxs(
7370
7578
  "div",
7371
7579
  {
7372
7580
  onMouseEnter: () => y(S),
7373
- onMouseLeave: () => clearTimeout(b.current),
7374
- onClick: () => f(S),
7581
+ onMouseLeave: () => clearTimeout(x.current),
7582
+ onClick: () => m(S),
7375
7583
  className: cn$1(
7376
7584
  "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",
7377
- S === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7585
+ S === f ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7378
7586
  ),
7379
7587
  children: [
7380
- /* @__PURE__ */ jsx("span", { children: capitalize(x(S.toLowerCase())) }),
7588
+ /* @__PURE__ */ jsx("span", { children: capitalize(b(S.toLowerCase())) }),
7381
7589
  /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
7382
7590
  ]
7383
7591
  },
@@ -7389,12 +7597,12 @@ const BlockCard = ({
7389
7597
  /* @__PURE__ */ jsxs(
7390
7598
  ScrollArea,
7391
7599
  {
7392
- onMouseEnter: () => b.current ? clearTimeout(b.current) : null,
7600
+ onMouseEnter: () => x.current ? clearTimeout(x.current) : null,
7393
7601
  className: "z-10 -mt-2 flex h-full max-h-full w-full flex-col gap-2 border-l border-border transition-all ease-linear",
7394
7602
  children: [
7395
7603
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
7396
7604
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7397
- A.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
7605
+ B.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
7398
7606
  ) }),
7399
7607
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7400
7608
  j.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
@@ -7620,45 +7828,45 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7620
7828
  var R;
7621
7829
  const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
7622
7830
  let p = null;
7623
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: f, data: h, isSelected: b, willReceiveDrop: x, isDragging: y, isEditing: A, handleClick: j } = o, C = (E) => {
7624
- E.stopPropagation(), !i.includes(f) && o.toggle();
7625
- }, S = (E) => {
7626
- E.isInternal && (p = E.isOpen, E.isOpen && E.close());
7627
- }, B = (E) => {
7628
- E.isInternal && p !== null && (p ? E.open() : E.close(), p = null);
7831
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: f } = useBlockHighlight(), { id: m, data: h, isSelected: x, willReceiveDrop: b, isDragging: y, isEditing: B, handleClick: j } = o, C = (N) => {
7832
+ N.stopPropagation(), !i.includes(m) && o.toggle();
7833
+ }, S = (N) => {
7834
+ N.isInternal && (p = N.isOpen, N.isOpen && N.close());
7835
+ }, A = (N) => {
7836
+ N.isInternal && p !== null && (p ? N.open() : N.close(), p = null);
7629
7837
  }, [_, w] = useAtom$1(currentAddSelection), L = () => {
7630
- var E;
7631
- k(), o.parent.isSelected || w((E = o == null ? void 0 : o.parent) == null ? void 0 : E.id);
7632
- }, k = () => {
7838
+ var N;
7839
+ v(), o.parent.isSelected || w((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7840
+ }, v = () => {
7633
7841
  w(null);
7634
- }, v = (E) => {
7635
- k(), E.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), j(E);
7842
+ }, k = (N) => {
7843
+ v(), N.stopPropagation(), !o.isOpen && !i.includes(m) && o.toggle(), j(N);
7636
7844
  };
7637
7845
  useEffect(() => {
7638
- const E = setTimeout(() => {
7639
- x && !o.isOpen && !y && !i.includes(f) && o.toggle();
7846
+ const N = setTimeout(() => {
7847
+ b && !o.isOpen && !y && !i.includes(m) && o.toggle();
7640
7848
  }, 500);
7641
- return () => clearTimeout(E);
7642
- }, [x, o, y]);
7643
- const N = useMemo(() => {
7644
- const E = Object.keys(h), D = [];
7645
- for (let M = 0; M < E.length; M++)
7646
- if (E[M].endsWith("_attrs")) {
7647
- const P = h[E[M]], O = Object.keys(P).join("|");
7849
+ return () => clearTimeout(N);
7850
+ }, [b, o, y]);
7851
+ const E = useMemo(() => {
7852
+ const N = Object.keys(h), D = [];
7853
+ for (let M = 0; M < N.length; M++)
7854
+ if (N[M].endsWith("_attrs")) {
7855
+ const P = h[N[M]], O = Object.keys(P).join("|");
7648
7856
  O.match(/x-data/) && D.push("data"), O.match(/x-on/) && D.push("event"), O.match(/x-show|x-if/) && D.push("show");
7649
7857
  }
7650
7858
  return D;
7651
- }, [h]), T = (E, D) => {
7652
- const M = d.contentDocument || d.contentWindow.document, P = M.querySelector(`[data-block-id=${E}]`);
7859
+ }, [h]), T = (N, D) => {
7860
+ const M = d.contentDocument || d.contentWindow.document, P = M.querySelector(`[data-block-id=${N}]`);
7653
7861
  P && P.setAttribute("data-drop", D);
7654
7862
  const O = P.getBoundingClientRect(), $ = d.getBoundingClientRect();
7655
7863
  O.top >= $.top && O.left >= $.left && O.bottom <= $.bottom && O.right <= $.right || (M.documentElement.scrollTop = P.offsetTop - $.top);
7656
- }, I = (E) => {
7657
- k();
7864
+ }, I = (N) => {
7865
+ v();
7658
7866
  const D = get(o, "parent.id");
7659
- D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: E }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: E });
7867
+ D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: N }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: N });
7660
7868
  };
7661
- return f === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7869
+ return m === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7662
7870
  /* @__PURE__ */ jsx("br", {}),
7663
7871
  /* @__PURE__ */ jsx(
7664
7872
  "div",
@@ -7673,35 +7881,35 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7673
7881
  }
7674
7882
  ),
7675
7883
  /* @__PURE__ */ jsx("br", {})
7676
- ] }) : /* @__PURE__ */ jsx(BlockContextMenu, { id: f, children: /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7884
+ ] }) : /* @__PURE__ */ jsx(BlockContextMenu, { id: m, children: /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7677
7885
  "div",
7678
7886
  {
7679
- onMouseEnter: () => g(f),
7680
- onMouseLeave: () => m(),
7681
- onClick: v,
7887
+ onMouseEnter: () => g(m),
7888
+ onMouseLeave: () => f(),
7889
+ onClick: k,
7682
7890
  style: n,
7683
- "data-node-id": f,
7684
- ref: i.includes(f) ? null : r,
7891
+ "data-node-id": m,
7892
+ ref: i.includes(m) ? null : r,
7685
7893
  onDragStart: () => S(o),
7686
- onDragEnd: () => B(o),
7687
- onDragOver: (E) => {
7688
- E.preventDefault(), T(f, "yes");
7894
+ onDragEnd: () => A(o),
7895
+ onDragOver: (N) => {
7896
+ N.preventDefault(), T(m, "yes");
7689
7897
  },
7690
- onDragLeave: (E) => {
7691
- E.preventDefault(), T(f, "no");
7898
+ onDragLeave: (N) => {
7899
+ N.preventDefault(), T(m, "no");
7692
7900
  },
7693
- onDrop: (E) => {
7694
- E.preventDefault(), T(f, "no");
7901
+ onDrop: (N) => {
7902
+ N.preventDefault(), T(m, "no");
7695
7903
  },
7696
7904
  children: [
7697
7905
  (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((R = o == null ? void 0 : o.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
7698
7906
  "div",
7699
7907
  {
7700
- onClick: (E) => {
7701
- E.stopPropagation(), I(o.childIndex);
7908
+ onClick: (N) => {
7909
+ N.stopPropagation(), I(o.childIndex);
7702
7910
  },
7703
7911
  onMouseEnter: L,
7704
- onMouseLeave: k,
7912
+ onMouseLeave: v,
7705
7913
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
7706
7914
  children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsx(PlusIcon$1, { className: "h-3 w-3 stroke-[4] text-white" }) })
7707
7915
  }
@@ -7711,11 +7919,11 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7711
7919
  {
7712
7920
  className: cn$1(
7713
7921
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
7714
- b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
7715
- x && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7922
+ x ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
7923
+ b && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7716
7924
  (o == null ? void 0 : o.id) === _ ? "bg-purple-100" : "",
7717
7925
  y && "opacity-20",
7718
- i.includes(f) ? "opacity-50" : ""
7926
+ i.includes(m) ? "opacity-50" : ""
7719
7927
  ),
7720
7928
  children: [
7721
7929
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -7726,47 +7934,47 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7726
7934
  children: u && /* @__PURE__ */ jsx("button", { onClick: C, type: "button", children: /* @__PURE__ */ jsx(
7727
7935
  ChevronRight,
7728
7936
  {
7729
- className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}`
7937
+ className: `h-3 w-3 stroke-[3] ${x ? "text-slate-200" : "text-slate-400"}`
7730
7938
  }
7731
7939
  ) })
7732
7940
  }
7733
7941
  ),
7734
7942
  /* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
7735
7943
  /* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
7736
- A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
7944
+ B ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
7737
7945
  "div",
7738
7946
  {
7739
7947
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
7740
- onDoubleClick: (E) => {
7741
- E.stopPropagation(), o.edit(), o.deselect();
7948
+ onDoubleClick: (N) => {
7949
+ N.stopPropagation(), o.edit(), o.deselect();
7742
7950
  },
7743
7951
  children: [
7744
7952
  /* @__PURE__ */ jsx("span", { children: (h == null ? void 0 : h._name) || (h == null ? void 0 : h._type.split("/").pop()) }),
7745
- N.includes("data") && /* @__PURE__ */ jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
7746
- N.includes("event") && /* @__PURE__ */ jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
7747
- N.includes("show") && /* @__PURE__ */ jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
7953
+ E.includes("data") && /* @__PURE__ */ jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
7954
+ E.includes("event") && /* @__PURE__ */ jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
7955
+ E.includes("show") && /* @__PURE__ */ jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
7748
7956
  ]
7749
7957
  }
7750
7958
  )
7751
7959
  ] })
7752
7960
  ] }),
7753
7961
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
7754
- !i.includes(f) && a.map((E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
7962
+ !i.includes(m) && a.map((N) => /* @__PURE__ */ jsxs(Tooltip, { children: [
7755
7963
  /* @__PURE__ */ jsx(
7756
7964
  TooltipTrigger,
7757
7965
  {
7758
7966
  className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
7759
7967
  asChild: !0,
7760
- children: React__default.createElement(E.item, { blockId: f })
7968
+ children: React__default.createElement(N.item, { blockId: m })
7761
7969
  }
7762
7970
  ),
7763
- /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: E.tooltip })
7971
+ /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: N.tooltip })
7764
7972
  ] })),
7765
- canAddChildBlock(h == null ? void 0 : h._type) && !i.includes(f) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7973
+ canAddChildBlock(h == null ? void 0 : h._type) && !i.includes(m) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7766
7974
  /* @__PURE__ */ jsx(
7767
7975
  TooltipTrigger,
7768
7976
  {
7769
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: f }),
7977
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: m }),
7770
7978
  className: "cursor-pointer rounded bg-transparent hover:text-black",
7771
7979
  asChild: !0,
7772
7980
  children: /* @__PURE__ */ jsx(PlusIcon$1, { size: "15" })
@@ -7778,8 +7986,8 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7778
7986
  /* @__PURE__ */ jsx(
7779
7987
  TooltipTrigger,
7780
7988
  {
7781
- onClick: (E) => {
7782
- E.stopPropagation(), c(f), o.isOpen && o.toggle();
7989
+ onClick: (N) => {
7990
+ N.stopPropagation(), c(m), o.isOpen && o.toggle();
7783
7991
  },
7784
7992
  className: "cursor-pointer rounded bg-transparent hover:text-black",
7785
7993
  asChild: !0,
@@ -8439,14 +8647,14 @@ function QuickPrompts({ onClick: o }) {
8439
8647
  ) }) });
8440
8648
  }
8441
8649
  const AIUserPrompt = ({ blockId: o }) => {
8442
- const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), f = useRef(null);
8650
+ 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);
8443
8651
  useEffect(() => {
8444
- var b;
8445
- (b = m.current) == null || b.focus();
8652
+ var x;
8653
+ (x = f.current) == null || x.focus();
8446
8654
  }, []);
8447
- const h = (b) => {
8448
- const { usage: x } = b || {};
8449
- !l && x && g(x), f.current = setTimeout(() => g(void 0), 1e4), l || c("");
8655
+ const h = (x) => {
8656
+ const { usage: b } = x || {};
8657
+ !l && b && g(b), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8450
8658
  };
8451
8659
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8452
8660
  /* @__PURE__ */ jsxs(
@@ -8464,14 +8672,14 @@ const AIUserPrompt = ({ blockId: o }) => {
8464
8672
  /* @__PURE__ */ jsx(
8465
8673
  Textarea,
8466
8674
  {
8467
- ref: m,
8675
+ ref: f,
8468
8676
  value: i,
8469
- onChange: (b) => c(b.target.value),
8677
+ onChange: (x) => c(x.target.value),
8470
8678
  placeholder: n("Ask AI to edit content"),
8471
8679
  className: "w-full",
8472
8680
  rows: 3,
8473
- onKeyDown: (b) => {
8474
- b.key === "Enter" && (b.preventDefault(), f.current && clearTimeout(f.current), g(void 0), r("content", o, i, h));
8681
+ onKeyDown: (x) => {
8682
+ x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), r("content", o, i, h));
8475
8683
  }
8476
8684
  }
8477
8685
  ),
@@ -8481,7 +8689,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8481
8689
  {
8482
8690
  disabled: i.trim().length < 5 || a,
8483
8691
  onClick: () => {
8484
- f.current && clearTimeout(f.current), g(void 0), r("content", o, i, h);
8692
+ m.current && clearTimeout(m.current), g(void 0), r("content", o, i, h);
8485
8693
  },
8486
8694
  variant: "default",
8487
8695
  className: "w-fit",
@@ -8513,8 +8721,8 @@ const AIUserPrompt = ({ blockId: o }) => {
8513
8721
  /* @__PURE__ */ jsx(
8514
8722
  QuickPrompts,
8515
8723
  {
8516
- onClick: (b) => {
8517
- f.current && clearTimeout(f.current), g(void 0), r("content", o, b, h);
8724
+ onClick: (x) => {
8725
+ m.current && clearTimeout(m.current), g(void 0), r("content", o, x, h);
8518
8726
  }
8519
8727
  }
8520
8728
  )
@@ -8524,13 +8732,13 @@ const AIUserPrompt = ({ blockId: o }) => {
8524
8732
  ] }) }) : null
8525
8733
  ] });
8526
8734
  }, AISetContext = () => {
8527
- 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), m = useRef(null);
8735
+ 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);
8528
8736
  useEffect(() => {
8529
8737
  n && a(n);
8530
8738
  }, [n]);
8531
- const f = async () => {
8739
+ const m = async () => {
8532
8740
  try {
8533
- d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
8741
+ d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), f.current.click();
8534
8742
  } catch (h) {
8535
8743
  u(h);
8536
8744
  } finally {
@@ -8546,7 +8754,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8546
8754
  type: "single",
8547
8755
  collapsible: !0,
8548
8756
  children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
8549
- /* @__PURE__ */ jsx(AccordionTrigger, { ref: m, 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") }) }) }),
8757
+ /* @__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") }) }) }),
8550
8758
  /* @__PURE__ */ jsxs(AccordionContent, { children: [
8551
8759
  /* @__PURE__ */ jsx(
8552
8760
  Textarea,
@@ -8558,7 +8766,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8558
8766
  className: "mt-1 w-full",
8559
8767
  rows: 10,
8560
8768
  onKeyDown: (h) => {
8561
- h.key === "Enter" && (h.preventDefault(), f());
8769
+ h.key === "Enter" && (h.preventDefault(), m());
8562
8770
  }
8563
8771
  }
8564
8772
  ),
@@ -8570,7 +8778,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8570
8778
  Button,
8571
8779
  {
8572
8780
  disabled: r.trim().length < 5,
8573
- onClick: () => f(),
8781
+ onClick: () => m(),
8574
8782
  variant: "default",
8575
8783
  className: "w-fit",
8576
8784
  size: "sm",
@@ -8599,7 +8807,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8599
8807
  AlertDialogAction,
8600
8808
  {
8601
8809
  onClick: () => {
8602
- a(""), f();
8810
+ a(""), m();
8603
8811
  },
8604
8812
  children: o("Yes, Delete")
8605
8813
  }
@@ -8753,32 +8961,32 @@ const AiAssistant = () => {
8753
8961
  ] })
8754
8962
  ] });
8755
8963
  }, AttrsEditor = React__default.memo(function o({ preloadedAttributes: n = [], onAttributesChange: r }) {
8756
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, f] = useState(""), h = useRef(null), b = useRef(null);
8964
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [f, m] = useState(""), h = useRef(null), x = useRef(null);
8757
8965
  useEffect(() => {
8758
8966
  l(n);
8759
8967
  }, [n]);
8760
- const x = () => {
8968
+ const b = () => {
8761
8969
  if (i.startsWith("@")) {
8762
- f("Attribute keys cannot start with '@'");
8970
+ m("Attribute keys cannot start with '@'");
8763
8971
  return;
8764
8972
  }
8765
8973
  if (i) {
8766
8974
  const S = [...a, { key: i, value: d }];
8767
- r(S), l(a), c(""), p(""), f("");
8975
+ r(S), l(a), c(""), p(""), m("");
8768
8976
  }
8769
8977
  }, y = (S) => {
8770
- const B = a.filter((_, w) => w !== S);
8771
- r(B), l(B);
8772
- }, A = (S) => {
8978
+ const A = a.filter((_, w) => w !== S);
8979
+ r(A), l(A);
8980
+ }, B = (S) => {
8773
8981
  g(S), c(a[S].key), p(a[S].value);
8774
8982
  }, j = () => {
8775
8983
  if (i.startsWith("@")) {
8776
- f("Attribute keys cannot start with '@'");
8984
+ m("Attribute keys cannot start with '@'");
8777
8985
  return;
8778
8986
  }
8779
8987
  if (u !== null && i) {
8780
8988
  const S = [...a];
8781
- S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), f("");
8989
+ S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), m("");
8782
8990
  }
8783
8991
  };
8784
8992
  return /* @__PURE__ */ jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
@@ -8786,7 +8994,7 @@ const AiAssistant = () => {
8786
8994
  "form",
8787
8995
  {
8788
8996
  onSubmit: (S) => {
8789
- S.preventDefault(), u !== null ? j() : x();
8997
+ S.preventDefault(), u !== null ? j() : b();
8790
8998
  },
8791
8999
  className: "space-y-3",
8792
9000
  children: [
@@ -8818,11 +9026,11 @@ const AiAssistant = () => {
8818
9026
  spellCheck: "false",
8819
9027
  id: "attrValue",
8820
9028
  rows: 2,
8821
- ref: b,
9029
+ ref: x,
8822
9030
  value: d,
8823
9031
  onChange: (S) => p(S.target.value),
8824
9032
  onKeyDown: (S) => {
8825
- S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? j() : x());
9033
+ S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? j() : b());
8826
9034
  },
8827
9035
  placeholder: "Enter Value",
8828
9036
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
@@ -8831,20 +9039,20 @@ const AiAssistant = () => {
8831
9039
  ] })
8832
9040
  ] }),
8833
9041
  /* @__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" }) }),
8834
- m && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: m })
9042
+ f && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: f })
8835
9043
  ]
8836
9044
  }
8837
9045
  ),
8838
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, B) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9046
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, A) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
8839
9047
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
8840
9048
  /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
8841
9049
  /* @__PURE__ */ jsx("span", { className: "text-wrap max-w-[200px] font-normal", children: S.value.toString() })
8842
9050
  ] }),
8843
9051
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
8844
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(B), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
8845
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => y(B), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9052
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(A), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9053
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => y(A), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
8846
9054
  ] })
8847
- ] }, B)) })
9055
+ ] }, A)) })
8848
9056
  ] });
8849
9057
  }), BlockAttributesEditor = React.memo(() => {
8850
9058
  const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9038,11 +9246,11 @@ const RootLayout = () => {
9038
9246
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9039
9247
  n(1);
9040
9248
  });
9041
- const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (b) => {
9042
- b.preventDefault();
9043
- }, u = (b) => {
9044
- n(o === b ? null : b);
9045
- }, g = useSidebarMenuItems(), { t: m } = useTranslation(), f = [...g, ...c], h = useBuilderProp("htmlDir", "ltr");
9249
+ const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (x) => {
9250
+ x.preventDefault();
9251
+ }, u = (x) => {
9252
+ n(o === x ? null : x);
9253
+ }, g = useSidebarMenuItems(), { t: f } = useTranslation(), m = [...g, ...c], h = useBuilderProp("htmlDir", "ltr");
9046
9254
  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: [
9047
9255
  /* @__PURE__ */ jsxs(
9048
9256
  "div",
@@ -9053,21 +9261,21 @@ const RootLayout = () => {
9053
9261
  /* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
9054
9262
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9055
9263
  /* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9056
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: f.map((b, x) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9264
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: m.map((x, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9057
9265
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
9058
9266
  Button,
9059
9267
  {
9060
- variant: o === x ? "default" : "ghost",
9268
+ variant: o === b ? "default" : "ghost",
9061
9269
  className: "mb-2 rounded-lg p-2 transition-colors",
9062
- onClick: () => u(x),
9063
- children: get(b, "icon", null)
9270
+ onClick: () => u(b),
9271
+ children: get(x, "icon", null)
9064
9272
  },
9065
- x
9273
+ b
9066
9274
  ) }),
9067
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(b.label) }) })
9068
- ] }, "button" + x)) }),
9275
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(x.label) }) })
9276
+ ] }, "button" + b)) }),
9069
9277
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9070
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((b, x) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(b, {}) }, `sidebar-component-${x}`)) })
9278
+ /* @__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}`)) })
9071
9279
  ] }),
9072
9280
  /* @__PURE__ */ jsx(
9073
9281
  motion.div,
@@ -9080,14 +9288,14 @@ const RootLayout = () => {
9080
9288
  /* @__PURE__ */ jsxs(
9081
9289
  "div",
9082
9290
  {
9083
- className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(f, `${o}.isInternal`, !1) ? "" : "w-64"}`,
9291
+ 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"}`,
9084
9292
  children: [
9085
- /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(f, `${o}.icon`, null) }),
9086
- /* @__PURE__ */ jsx("span", { children: m(f[o].label) })
9293
+ /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(m, `${o}.icon`, null) }),
9294
+ /* @__PURE__ */ jsx("span", { children: f(m[o].label) })
9087
9295
  ]
9088
9296
  }
9089
9297
  ),
9090
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(f, `${o}.component`, null), {}) }) })
9298
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(m, `${o}.component`, null), {}) }) })
9091
9299
  ] })
9092
9300
  }
9093
9301
  ),
@@ -9106,11 +9314,11 @@ const RootLayout = () => {
9106
9314
  /* @__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: [
9107
9315
  /* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
9108
9316
  " ",
9109
- m("AI Assistant")
9317
+ f("AI Assistant")
9110
9318
  ] }) }) : l === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
9111
9319
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
9112
9320
  /* @__PURE__ */ jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
9113
- m("Theme Settings")
9321
+ f("Theme Settings")
9114
9322
  ] }),
9115
9323
  /* @__PURE__ */ jsx(
9116
9324
  Button,
@@ -9162,7 +9370,7 @@ const RootLayout = () => {
9162
9370
  }, r * 1e3);
9163
9371
  }, ChaiBuilderComponent = (o) => {
9164
9372
  const [, n] = useBlocksStore(), r = useBuilderReset(), [a] = useAtom(builderSaveStateAtom), l = useMemo(() => o.layout || RootLayout, [o.layout]);
9165
- useAtom(selectedLibraryAtom), useKeyEventWatcher(), useExpandTree(), useAutoSave(), useWatchGlobalBlocks(), useUnmountBroadcastChannel();
9373
+ useAtom(selectedLibraryAtom), useKeyEventWatcher(), useExpandTree(), useAutoSave(), useWatchPartailBlocks(), useUnmountBroadcastChannel();
9166
9374
  const { postMessage: i } = useBroadcastChannel();
9167
9375
  return useEffect(() => {
9168
9376
  builderStore.set(
@@ -9253,12 +9461,12 @@ export {
9253
9461
  useCutBlockIds,
9254
9462
  useDarkMode,
9255
9463
  useDuplicateBlocks,
9256
- useGlobalBlocksList,
9257
- useGlobalBlocksStore,
9258
9464
  useHiddenBlockIds,
9259
9465
  useHighlightBlockId,
9260
9466
  useLanguages,
9261
9467
  useLayoutVariant,
9468
+ usePartailBlocksStore,
9469
+ usePartialBlocksList,
9262
9470
  usePasteBlocks,
9263
9471
  usePreviewMode,
9264
9472
  useRemoveBlocks,