@chaibuilder/sdk 2.0.7 → 2.0.9

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
@@ -4,7 +4,7 @@ var V = (o, n, r) => K(o, typeof n != "symbol" ? n + "" : n, r);
4
4
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
5
5
  import * as React from "react";
6
6
  import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, useMemo, Component, Children, useRef, useState, Suspense, createElement, memo, lazy } from "react";
7
- import { O as DropdownMenu, P as DropdownMenuTrigger, Q as DropdownMenuContent, R as DropdownMenuItem, S as Skeleton, B as Button, H as Dialog, I as DialogTrigger, J as DialogContent, a7 as Popover, ak as Tooltip, al as TooltipTrigger, a8 as PopoverTrigger, am as TooltipContent, a9 as PopoverContent, v as Command, x as CommandInput, y as CommandList, z as CommandEmpty, D as CommandGroup, E as CommandItem, K as DialogHeader, M as DialogTitle, n as Badge, V as DropdownMenuLabel, W as DropdownMenuSeparator, T as DropdownMenuCheckboxItem, a2 as HoverCard, a3 as HoverCardTrigger, a4 as HoverCardContent, aj as Textarea, a5 as Input$1, ao as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, A as Accordion, C as Card, q as CardHeader, t as CardDescription, u as CardContent, a6 as Label, r as CardFooter, aa as ScrollArea, af as Tabs, ag as TabsList, ah as TabsTrigger, ai as TabsContent, e as AlertDialog, f as AlertDialogTrigger, g as AlertDialogContent, h as AlertDialogHeader, j as AlertDialogTitle, k as AlertDialogDescription, i as AlertDialogFooter, m as AlertDialogCancel, l as AlertDialogAction, ae as Switch, ac as Separator, an as TooltipProvider, ad as Toaster } from "./tooltip-PKiP886L.js";
7
+ import { R as DropdownMenu, T as DropdownMenuTrigger, U as DropdownMenuContent, V as DropdownMenuItem, S as Skeleton, B as Button, K as Dialog, L as DialogTrigger, M as DialogContent, aa as Popover, an as Tooltip, ao as TooltipTrigger, ab as PopoverTrigger, ap as TooltipContent, ac as PopoverContent, y as Command, D as CommandInput, E as CommandList, F as CommandEmpty, G as CommandGroup, H as CommandItem, N as DialogHeader, P as DialogTitle, q as Badge, Y as DropdownMenuLabel, Z as DropdownMenuSeparator, W as DropdownMenuCheckboxItem, a5 as HoverCard, a6 as HoverCardTrigger, a7 as HoverCardContent, am as Textarea, a8 as Input$1, ar as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, A as Accordion, C as Card, t as CardHeader, w as CardDescription, x as CardContent, a9 as Label, u as CardFooter, ad as ScrollArea, ai as Tabs, aj as TabsList, ak as TabsTrigger, al as TabsContent, e as AlertDialog, f as AlertDialogTrigger, g as AlertDialogContent, h as AlertDialogHeader, j as AlertDialogTitle, k as AlertDialogDescription, i as AlertDialogFooter, m as AlertDialogCancel, l as AlertDialogAction, ah as Switch, n as Avatar, af as Separator, aq as TooltipProvider, ag as Toaster } from "./tooltip-VMv3Eoxb.js";
8
8
  import { atom as atom$1, useAtomValue as useAtomValue$1, useAtom as useAtom$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
9
9
  import { find, filter, flatten, map, omit, isString, has, get, isObject, memoize, compact, isEmpty, noop, includes, without, each, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, findIndex, throttle, isFunction as isFunction$1, reverse, split, take, startCase, debounce, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, capitalize, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
10
10
  import { Provider as Provider$1 } from "react-wrap-balancer";
@@ -19,7 +19,7 @@ import { useFeature, FlagsProvider } from "flagged";
19
19
  import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredChaiBlocks, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
20
20
  import { registerChaiBlock as Ue } from "@chaibuilder/runtime";
21
21
  import { e as getDefaultExportFromCjs, d as defaultThemeOptions, g as getChaiThemeOptions, p as plugin, a as getChaiThemeCssVariables, c as getThemeFontsLinkMarkup } from "./ChaiThemeFn-Cort9tch.js";
22
- import { PlusIcon as PlusIcon$1, ChevronRight, DatabaseIcon, ChevronLeft, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, X, Plus, PlusCircle, ChevronDown, Loader, SparklesIcon, Globe, PencilIcon, FileJson, Zap, EyeOff, MoreVertical, Eye, ChevronsDown, ChevronsUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, Moon, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
22
+ import { PlusIcon as PlusIcon$1, ChevronRight, DatabaseIcon, ChevronLeft, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, X, Plus, PlusCircle, ChevronDown, Loader, SparklesIcon, Globe, PencilIcon, FileJson, Zap, EyeOff, MoreVertical, Eye, ChevronsDown, ChevronsUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
23
23
  import RjForm from "@rjsf/core";
24
24
  import validator from "@rjsf/validator-ajv8";
25
25
  import Link from "@tiptap/extension-link";
@@ -100,46 +100,46 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
100
100
  var x;
101
101
  return (x = h.onMount) == null ? void 0 : x.call(h, f);
102
102
  }, ...m) => {
103
- const h = m[0] || ((B) => {
104
- let L = o.get(B);
105
- return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(B, L), u == null || u(B, C)), L;
103
+ const h = m[0] || ((A) => {
104
+ let L = o.get(A);
105
+ return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, L), u == null || u(A, w)), L;
106
106
  }), f = m[1] || (() => {
107
- let B, L;
108
- const v = (y) => {
107
+ let A, L;
108
+ const C = (k) => {
109
109
  try {
110
- y();
110
+ k();
111
111
  } catch (_) {
112
- B || (B = !0, L = _);
112
+ A || (A = !0, L = _);
113
113
  }
114
114
  };
115
115
  do {
116
- c.f && v(c.f);
117
- const y = /* @__PURE__ */ new Set(), _ = y.add.bind(y);
116
+ c.f && C(c.f);
117
+ const k = /* @__PURE__ */ new Set(), _ = k.add.bind(k);
118
118
  a.forEach((T) => {
119
119
  var I;
120
120
  return (I = n.get(T)) == null ? void 0 : I.l.forEach(_);
121
- }), a.clear(), i.forEach(_), i.clear(), l.forEach(_), l.clear(), y.forEach(v), a.size && x();
121
+ }), a.clear(), i.forEach(_), i.clear(), l.forEach(_), l.clear(), k.forEach(C), a.size && x();
122
122
  } while (a.size || i.size || l.size);
123
- if (B)
123
+ if (A)
124
124
  throw L;
125
125
  }), x = m[2] || (() => {
126
- const B = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
127
- for (; y.length; ) {
128
- const _ = y[y.length - 1], T = h(_);
129
- if (v.has(_)) {
130
- y.pop();
126
+ const A = [], L = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
127
+ for (; k.length; ) {
128
+ const _ = k[k.length - 1], T = h(_);
129
+ if (C.has(_)) {
130
+ k.pop();
131
131
  continue;
132
132
  }
133
133
  if (L.has(_)) {
134
- r.get(_) === T.n && B.push([_, T]), v.add(_), y.pop();
134
+ r.get(_) === T.n && A.push([_, T]), C.add(_), k.pop();
135
135
  continue;
136
136
  }
137
137
  L.add(_);
138
138
  for (const I of getMountedOrPendingDependents(_, T, n))
139
- L.has(I) || y.push(I);
139
+ L.has(I) || k.push(I);
140
140
  }
141
- for (let _ = B.length - 1; _ >= 0; --_) {
142
- const [T, I] = B[_];
141
+ for (let _ = A.length - 1; _ >= 0; --_) {
142
+ const [T, I] = A[_];
143
143
  let R = !1;
144
144
  for (const P of I.d.keys())
145
145
  if (P !== T && a.has(P)) {
@@ -148,24 +148,24 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
148
148
  }
149
149
  R && (b(T), S(T)), r.delete(T);
150
150
  }
151
- }), b = m[3] || ((B) => {
152
- var L, v;
153
- const y = h(B);
154
- if (isAtomStateInitialized(y) && (n.has(B) && r.get(B) !== y.n || Array.from(y.d).every(
151
+ }), b = m[3] || ((A) => {
152
+ var L, C;
153
+ const k = h(A);
154
+ if (isAtomStateInitialized(k) && (n.has(A) && r.get(A) !== k.n || Array.from(k.d).every(
155
155
  ([D, O]) => (
156
156
  // Recursively, read the atom state of the dependency, and
157
157
  // check if the atom epoch number is unchanged
158
158
  b(D).n === O
159
159
  )
160
160
  )))
161
- return y;
162
- y.d.clear();
161
+ return k;
162
+ k.d.clear();
163
163
  let _ = !0;
164
164
  const T = () => {
165
- n.has(B) && (S(B), x(), f());
165
+ n.has(A) && (S(A), x(), f());
166
166
  }, I = (D) => {
167
167
  var O;
168
- if (isSelfAtom(B, D)) {
168
+ if (isSelfAtom(A, D)) {
169
169
  const H = h(D);
170
170
  if (!isAtomStateInitialized(H))
171
171
  if (hasInitialValue(D))
@@ -178,7 +178,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
178
178
  try {
179
179
  return returnAtomValue($);
180
180
  } finally {
181
- y.d.set(D, $.n), isPendingPromise(y.v) && addPendingPromiseToDependency(B, y.v, $), (O = n.get(D)) == null || O.t.add(B), _ || T();
181
+ k.d.set(D, $.n), isPendingPromise(k.v) && addPendingPromiseToDependency(A, k.v, $), (O = n.get(D)) == null || O.t.add(A), _ || T();
182
182
  }
183
183
  };
184
184
  let R, P;
@@ -187,100 +187,100 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
187
187
  return R || (R = new AbortController()), R.signal;
188
188
  },
189
189
  get setSelf() {
190
- return !P && isActuallyWritableAtom(B) && (P = (...D) => {
190
+ return !P && isActuallyWritableAtom(A) && (P = (...D) => {
191
191
  if (!_)
192
192
  try {
193
- return w(B, ...D);
193
+ return v(A, ...D);
194
194
  } finally {
195
195
  x(), f();
196
196
  }
197
197
  }), P;
198
198
  }
199
- }, M = y.n;
199
+ }, M = k.n;
200
200
  try {
201
- const D = d(B, I, N);
202
- return setAtomStateValueOrPromise(B, D, h), isPromiseLike$2(D) && ((L = D.onCancel) == null || L.call(D, () => R == null ? void 0 : R.abort()), D.then(
201
+ const D = d(A, I, N);
202
+ return setAtomStateValueOrPromise(A, D, h), isPromiseLike$2(D) && ((L = D.onCancel) == null || L.call(D, () => R == null ? void 0 : R.abort()), D.then(
203
203
  T,
204
204
  T
205
- )), y;
205
+ )), k;
206
206
  } catch (D) {
207
- return delete y.v, y.e = D, ++y.n, y;
207
+ return delete k.v, k.e = D, ++k.n, k;
208
208
  } finally {
209
- _ = !1, M !== y.n && r.get(B) === M && (r.set(B, y.n), a.add(B), (v = c.c) == null || v.call(c, B));
209
+ _ = !1, M !== k.n && r.get(A) === M && (r.set(A, k.n), a.add(A), (C = c.c) == null || C.call(c, A));
210
210
  }
211
- }), k = m[4] || ((B) => {
212
- const L = [B];
211
+ }), y = m[4] || ((A) => {
212
+ const L = [A];
213
213
  for (; L.length; ) {
214
- const v = L.pop(), y = h(v);
215
- for (const _ of getMountedOrPendingDependents(v, y, n)) {
214
+ const C = L.pop(), k = h(C);
215
+ for (const _ of getMountedOrPendingDependents(C, k, n)) {
216
216
  const T = h(_);
217
217
  r.set(_, T.n), L.push(_);
218
218
  }
219
219
  }
220
- }), w = m[5] || ((B, ...L) => {
221
- let v = !0;
222
- const y = (T) => returnAtomValue(b(T)), _ = (T, ...I) => {
220
+ }), v = m[5] || ((A, ...L) => {
221
+ let C = !0;
222
+ const k = (T) => returnAtomValue(b(T)), _ = (T, ...I) => {
223
223
  var R;
224
224
  const P = h(T);
225
225
  try {
226
- if (isSelfAtom(B, T)) {
226
+ if (isSelfAtom(A, T)) {
227
227
  if (!hasInitialValue(T))
228
228
  throw new Error("atom not writable");
229
229
  const N = P.n, M = I[0];
230
- setAtomStateValueOrPromise(T, M, h), S(T), N !== P.n && (a.add(T), (R = c.c) == null || R.call(c, T), k(T));
230
+ setAtomStateValueOrPromise(T, M, h), S(T), N !== P.n && (a.add(T), (R = c.c) == null || R.call(c, T), y(T));
231
231
  return;
232
232
  } else
233
- return w(T, ...I);
233
+ return v(T, ...I);
234
234
  } finally {
235
- v || (x(), f());
235
+ C || (x(), f());
236
236
  }
237
237
  };
238
238
  try {
239
- return p(B, y, _, ...L);
239
+ return p(A, k, _, ...L);
240
240
  } finally {
241
- v = !1;
241
+ C = !1;
242
242
  }
243
- }), S = m[6] || ((B) => {
243
+ }), S = m[6] || ((A) => {
244
244
  var L;
245
- const v = h(B), y = n.get(B);
246
- if (y && !isPendingPromise(v.v)) {
247
- for (const [_, T] of v.d)
248
- if (!y.d.has(_)) {
245
+ const C = h(A), k = n.get(A);
246
+ if (k && !isPendingPromise(C.v)) {
247
+ for (const [_, T] of C.d)
248
+ if (!k.d.has(_)) {
249
249
  const I = h(_);
250
- A(_).t.add(B), y.d.add(_), T !== I.n && (a.add(_), (L = c.c) == null || L.call(c, _), k(_));
250
+ B(_).t.add(A), k.d.add(_), T !== I.n && (a.add(_), (L = c.c) == null || L.call(c, _), y(_));
251
251
  }
252
- for (const _ of y.d || [])
253
- if (!v.d.has(_)) {
254
- y.d.delete(_);
252
+ for (const _ of k.d || [])
253
+ if (!C.d.has(_)) {
254
+ k.d.delete(_);
255
255
  const T = E(_);
256
- T == null || T.t.delete(B);
256
+ T == null || T.t.delete(A);
257
257
  }
258
258
  }
259
- }), A = m[7] || ((B) => {
259
+ }), B = m[7] || ((A) => {
260
260
  var L;
261
- const v = h(B);
262
- let y = n.get(B);
263
- if (!y) {
264
- b(B);
265
- for (const _ of v.d.keys())
266
- A(_).t.add(B);
267
- if (y = {
261
+ const C = h(A);
262
+ let k = n.get(A);
263
+ if (!k) {
264
+ b(A);
265
+ for (const _ of C.d.keys())
266
+ B(_).t.add(A);
267
+ if (k = {
268
268
  l: /* @__PURE__ */ new Set(),
269
- d: new Set(v.d.keys()),
269
+ d: new Set(C.d.keys()),
270
270
  t: /* @__PURE__ */ new Set()
271
- }, n.set(B, y), (L = c.m) == null || L.call(c, B), isActuallyWritableAtom(B)) {
271
+ }, n.set(A, k), (L = c.m) == null || L.call(c, A), isActuallyWritableAtom(A)) {
272
272
  const _ = () => {
273
273
  let T = !0;
274
274
  const I = (...R) => {
275
275
  try {
276
- return w(B, ...R);
276
+ return v(A, ...R);
277
277
  } finally {
278
278
  T || (x(), f());
279
279
  }
280
280
  };
281
281
  try {
282
- const R = g(B, I);
283
- R && (y.u = () => {
282
+ const R = g(A, I);
283
+ R && (k.u = () => {
284
284
  T = !0;
285
285
  try {
286
286
  R();
@@ -295,23 +295,23 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
295
295
  l.add(_);
296
296
  }
297
297
  }
298
- return y;
299
- }), E = m[8] || ((B) => {
298
+ return k;
299
+ }), E = m[8] || ((A) => {
300
300
  var L;
301
- const v = h(B);
302
- let y = n.get(B);
303
- if (y && !y.l.size && !Array.from(y.t).some((_) => {
301
+ const C = h(A);
302
+ let k = n.get(A);
303
+ if (k && !k.l.size && !Array.from(k.t).some((_) => {
304
304
  var T;
305
- return (T = n.get(_)) == null ? void 0 : T.d.has(B);
305
+ return (T = n.get(_)) == null ? void 0 : T.d.has(A);
306
306
  })) {
307
- y.u && i.add(y.u), y = void 0, n.delete(B), (L = c.u) == null || L.call(c, B);
308
- for (const _ of v.d.keys()) {
307
+ k.u && i.add(k.u), k = void 0, n.delete(A), (L = c.u) == null || L.call(c, A);
308
+ for (const _ of C.d.keys()) {
309
309
  const T = E(_);
310
- T == null || T.t.delete(B);
310
+ T == null || T.t.delete(A);
311
311
  }
312
312
  return;
313
313
  }
314
- return y;
314
+ return k;
315
315
  }), j = [
316
316
  // store state
317
317
  o,
@@ -331,28 +331,28 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
331
331
  f,
332
332
  x,
333
333
  b,
334
- k,
335
- w,
334
+ y,
335
+ v,
336
336
  S,
337
- A,
337
+ B,
338
338
  E
339
- ], C = {
340
- get: (B) => returnAtomValue(b(B)),
341
- set: (B, ...L) => {
339
+ ], w = {
340
+ get: (A) => returnAtomValue(b(A)),
341
+ set: (A, ...L) => {
342
342
  try {
343
- return w(B, ...L);
343
+ return v(A, ...L);
344
344
  } finally {
345
345
  x(), f();
346
346
  }
347
347
  },
348
- sub: (B, L) => {
349
- const y = A(B).l;
350
- return y.add(L), f(), () => {
351
- y.delete(L), E(B), f();
348
+ sub: (A, L) => {
349
+ const k = B(A).l;
350
+ return k.add(L), f(), () => {
351
+ k.delete(L), E(A), f();
352
352
  };
353
353
  }
354
354
  };
355
- return Object.defineProperty(C, BUILDING_BLOCKS, { value: j }), C;
355
+ return Object.defineProperty(w, BUILDING_BLOCKS, { value: j }), w;
356
356
  }, INTERNAL_buildStoreRev1 = buildStore;
357
357
  let keyCount = 0;
358
358
  function atom(o, n) {
@@ -396,27 +396,27 @@ function splitAtom(o, n) {
396
396
  g[f] = b;
397
397
  return;
398
398
  }
399
- const k = (S) => {
400
- const A = S(l), E = S(o), C = a(E, A == null ? void 0 : A.arr).keyList.indexOf(x);
401
- if (C < 0 || C >= E.length) {
402
- const B = c[a(c).keyList.indexOf(x)];
403
- if (B)
404
- return B;
399
+ const y = (S) => {
400
+ const B = S(l), E = S(o), w = a(E, B == null ? void 0 : B.arr).keyList.indexOf(x);
401
+ if (w < 0 || w >= E.length) {
402
+ const A = c[a(c).keyList.indexOf(x)];
403
+ if (A)
404
+ return A;
405
405
  throw new Error("splitAtom: index out of bounds for read");
406
406
  }
407
- return E[C];
408
- }, w = (S, A, E) => {
409
- const j = S(l), C = S(o), L = a(C, j == null ? void 0 : j.arr).keyList.indexOf(x);
410
- if (L < 0 || L >= C.length)
407
+ return E[w];
408
+ }, v = (S, B, E) => {
409
+ const j = S(l), w = S(o), L = a(w, j == null ? void 0 : j.arr).keyList.indexOf(x);
410
+ if (L < 0 || L >= w.length)
411
411
  throw new Error("splitAtom: index out of bounds for write");
412
- const v = isFunction(E) ? E(C[L]) : E;
413
- Object.is(C[L], v) || A(o, [
414
- ...C.slice(0, L),
415
- v,
416
- ...C.slice(L + 1)
412
+ const C = isFunction(E) ? E(w[L]) : E;
413
+ Object.is(w[L], C) || B(o, [
414
+ ...w.slice(0, L),
415
+ C,
416
+ ...w.slice(L + 1)
417
417
  ]);
418
418
  };
419
- g[f] = isWritable(o) ? atom(k, w) : atom(k);
419
+ g[f] = isWritable(o) ? atom(y, v) : atom(y);
420
420
  }), u && u.keyList.length === m.length && u.keyList.every((h, f) => h === m[f]) ? p = u : p = { arr: c, atomList: g, keyList: m }, r.set(c, p), p;
421
421
  }, l = atom((c) => {
422
422
  const d = c(l), p = c(o);
@@ -672,10 +672,8 @@ const selectedLibraryAtom = atomWithStorage("_selectedLibrary", null);
672
672
  selectedLibraryAtom.debugLabel = "selectedLibraryAtom";
673
673
  const dataBindingActiveAtom = atom$1(!0);
674
674
  dataBindingActiveAtom.debugLabel = "dataBindingActiveAtom";
675
- let doc, win;
676
- typeof document < "u" && (doc = document);
677
- typeof window < "u" && (win = window);
678
- const FrameContext = React__default.createContext({ document: doc, window: win }), useFrame = () => React__default.useContext(FrameContext), { Provider: FrameContextProvider, Consumer: FrameContextConsumer } = FrameContext;
675
+ const sidebarActivePanelAtom = atom$1("outline");
676
+ sidebarActivePanelAtom.debugLabel = "sidebarActivePanelAtom";
679
677
  class Content extends Component {
680
678
  componentDidMount() {
681
679
  this.props.contentDidMount();
@@ -687,6 +685,10 @@ class Content extends Component {
687
685
  return Children.only(this.props.children);
688
686
  }
689
687
  }
688
+ let doc, win;
689
+ typeof document < "u" && (doc = document);
690
+ typeof window < "u" && (win = window);
691
+ const FrameContext = React__default.createContext({ document: doc, window: win }), useFrame = () => React__default.useContext(FrameContext), { Provider: FrameContextProvider, Consumer: FrameContextConsumer } = FrameContext;
690
692
  class Frame extends Component {
691
693
  constructor(r, a) {
692
694
  super(r, a);
@@ -1396,50 +1398,50 @@ const useBlocksStoreManager = () => {
1396
1398
  updateBlocksProps: c
1397
1399
  } = useBlocksStoreManager();
1398
1400
  return {
1399
- moveBlocks: (x, b, k) => {
1400
- const w = map(x, (A) => {
1401
- const j = n.find((L) => L._id === A)._parent || null, B = n.filter((L) => j ? L._parent === j : !L._parent).map((L) => L._id).indexOf(A);
1402
- return { _id: A, oldParent: j, oldPosition: B };
1403
- }), S = w.find(({ _id: A }) => A === x[0]);
1404
- S && S.oldParent === b && S.oldPosition === k || (i(x, b, k), o({
1405
- undo: () => each(w, ({ _id: A, oldParent: E, oldPosition: j }) => {
1406
- i([A], E, j);
1401
+ moveBlocks: (x, b, y) => {
1402
+ const v = map(x, (B) => {
1403
+ const j = n.find((L) => L._id === B)._parent || null, A = n.filter((L) => j ? L._parent === j : !L._parent).map((L) => L._id).indexOf(B);
1404
+ return { _id: B, oldParent: j, oldPosition: A };
1405
+ }), S = v.find(({ _id: B }) => B === x[0]);
1406
+ S && S.oldParent === b && S.oldPosition === y || (i(x, b, y), o({
1407
+ undo: () => each(v, ({ _id: B, oldParent: E, oldPosition: j }) => {
1408
+ i([B], E, j);
1407
1409
  }),
1408
- redo: () => i(x, b, k)
1410
+ redo: () => i(x, b, y)
1409
1411
  }));
1410
1412
  },
1411
- addBlocks: (x, b, k) => {
1412
- a(x, b, k), o({
1413
+ addBlocks: (x, b, y) => {
1414
+ a(x, b, y), o({
1413
1415
  undo: () => l(map(x, "_id")),
1414
- redo: () => a(x, b, k)
1416
+ redo: () => a(x, b, y)
1415
1417
  });
1416
1418
  },
1417
1419
  removeBlocks: (x) => {
1418
1420
  var S;
1419
- const b = (S = first(x)) == null ? void 0 : S._parent, w = n.filter((A) => b ? A._parent === b : !A._parent).indexOf(first(x));
1421
+ const b = (S = first(x)) == null ? void 0 : S._parent, v = n.filter((B) => b ? B._parent === b : !B._parent).indexOf(first(x));
1420
1422
  l(map(x, "_id")), o({
1421
- undo: () => a(x, b, w),
1423
+ undo: () => a(x, b, v),
1422
1424
  redo: () => l(map(x, "_id"))
1423
1425
  });
1424
1426
  },
1425
- updateBlocks: (x, b, k) => {
1426
- let w = [];
1427
- if (k)
1428
- w = map(x, (S) => ({ _id: S, ...k }));
1427
+ updateBlocks: (x, b, y) => {
1428
+ let v = [];
1429
+ if (y)
1430
+ v = map(x, (S) => ({ _id: S, ...y }));
1429
1431
  else {
1430
1432
  const S = keys(b);
1431
- w = map(x, (A) => {
1432
- const E = n.find((C) => C._id === A), j = { _id: A };
1433
- return each(S, (C) => j[C] = E[C]), j;
1433
+ v = map(x, (B) => {
1434
+ const E = n.find((w) => w._id === B), j = { _id: B };
1435
+ return each(S, (w) => j[w] = E[w]), j;
1434
1436
  });
1435
1437
  }
1436
1438
  c(map(x, (S) => ({ _id: S, ...b }))), o({
1437
- undo: () => c(w),
1439
+ undo: () => c(v),
1438
1440
  redo: () => c(map(x, (S) => ({ _id: S, ...b })))
1439
1441
  });
1440
1442
  },
1441
1443
  updateBlocksRuntime: (x, b) => {
1442
- c(map(x, (k) => ({ _id: k, ...b })));
1444
+ c(map(x, (y) => ({ _id: y, ...b })));
1443
1445
  },
1444
1446
  setNewBlocks: (x) => {
1445
1447
  r(x), o({
@@ -1449,9 +1451,9 @@ const useBlocksStoreManager = () => {
1449
1451
  },
1450
1452
  updateMultipleBlocksProps: (x) => {
1451
1453
  let b = [];
1452
- b = map(x, (k) => {
1453
- const w = keys(k), S = n.find((E) => E._id === k._id), A = {};
1454
- return each(w, (E) => A[E] = S[E]), A;
1454
+ b = map(x, (y) => {
1455
+ const v = keys(y), S = n.find((E) => E._id === y._id), B = {};
1456
+ return each(v, (E) => B[E] = S[E]), B;
1455
1457
  }), c(x), o({
1456
1458
  undo: () => c(b),
1457
1459
  redo: () => c(x)
@@ -1511,8 +1513,8 @@ const useAddBlock = () => {
1511
1513
  const { _id: x } = i[f];
1512
1514
  i[f]._id = generateUUID();
1513
1515
  const b = filter(i, { _parent: x });
1514
- for (let k = 0; k < b.length; k++)
1515
- b[k]._parent = i[f]._id;
1516
+ for (let y = 0; y < b.length; y++)
1517
+ b[y]._parent = i[f]._id;
1516
1518
  }
1517
1519
  const p = first(i);
1518
1520
  let u, g;
@@ -2983,10 +2985,10 @@ const getBlockWithChildren = (o, n) => {
2983
2985
  const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (h, f) => {
2984
2986
  const x = cloneDeep(f.find((b) => b._id === h));
2985
2987
  for (const b in x) {
2986
- const k = x[b];
2987
- if (typeof k == "string" && startsWith(k, STYLES_KEY)) {
2988
- const { baseClasses: w, classes: S } = getSplitChaiClasses(k);
2989
- x[b] = compact(flattenDeep([w, S])).join(" ");
2988
+ const y = x[b];
2989
+ if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
2990
+ const { baseClasses: v, classes: S } = getSplitChaiClasses(y);
2991
+ x[b] = compact(flattenDeep([v, S])).join(" ");
2990
2992
  } else
2991
2993
  b !== "_id" && delete x[b];
2992
2994
  }
@@ -2998,23 +3000,23 @@ const getBlockWithChildren = (o, n) => {
2998
3000
  if (l) {
2999
3001
  n(!0), a(null);
3000
3002
  try {
3001
- const k = p === u ? "" : p, w = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [m(f, d)], S = await l(h, addLangToPrompt(x, g, h), w, k), { blocks: A, error: E } = S;
3003
+ const y = p === u ? "" : p, v = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [m(f, d)], S = await l(h, addLangToPrompt(x, g, h), v, y), { blocks: B, error: E } = S;
3002
3004
  if (E) {
3003
3005
  a(E);
3004
3006
  return;
3005
3007
  }
3006
3008
  if (h === "styles") {
3007
- const j = A.map((C) => {
3008
- for (const B in C)
3009
- B !== "_id" && (C[B] = `${STYLES_KEY},${C[B]}`);
3010
- return C;
3009
+ const j = B.map((w) => {
3010
+ for (const A in w)
3011
+ A !== "_id" && (w[A] = `${STYLES_KEY},${w[A]}`);
3012
+ return w;
3011
3013
  });
3012
3014
  c(j);
3013
3015
  } else
3014
- i(A);
3016
+ i(B);
3015
3017
  b && b(S);
3016
- } catch (k) {
3017
- a(k);
3018
+ } catch (y) {
3019
+ a(y);
3018
3020
  } finally {
3019
3021
  n(!1), b && b();
3020
3022
  }
@@ -3664,23 +3666,23 @@ const useDnd = () => {
3664
3666
  var E;
3665
3667
  const f = dropTarget, b = getOrientation(f) === "vertical" ? h.clientY + ((E = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : E.scrollY) : h.clientX;
3666
3668
  dropIndex = calculateDropIndex(b, possiblePositions);
3667
- const k = d, w = f.getAttribute("data-block-id"), S = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3668
- if ((k == null ? void 0 : k._id) === w || !S) {
3669
+ const y = d, v = f.getAttribute("data-block-id"), S = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3670
+ if ((y == null ? void 0 : y._id) === v || !S) {
3669
3671
  m();
3670
3672
  return;
3671
3673
  }
3672
- if (!has(k, "_id")) {
3673
- a(k, w === "canvas" ? null : w, dropIndex), setTimeout(m, 300);
3674
+ if (!has(y, "_id")) {
3675
+ a(y, v === "canvas" ? null : v, dropIndex), setTimeout(m, 300);
3674
3676
  return;
3675
3677
  }
3676
- let A = f.getAttribute("data-block-id");
3677
- A === null && (A = h.target.parentElement.getAttribute("data-block-id")), c([k._id], A === "canvas" ? null : A, dropIndex), m(), setTimeout(removePlaceholder, 300);
3678
+ let B = f.getAttribute("data-block-id");
3679
+ B === null && (B = h.target.parentElement.getAttribute("data-block-id")), c([y._id], B === "canvas" ? null : B, dropIndex), m(), setTimeout(removePlaceholder, 300);
3678
3680
  },
3679
3681
  onDragEnter: (h) => {
3680
3682
  const f = h, x = f.target;
3681
3683
  dropTarget = x;
3682
- const b = x.getAttribute("data-block-id"), k = x.getAttribute("data-dnd-dragged") !== "yes";
3683
- u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], k && calculatePossiblePositions(x), r(!0), l(""), i([]);
3684
+ const b = x.getAttribute("data-block-id"), y = x.getAttribute("data-dnd-dragged") !== "yes";
3685
+ u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(x), r(!0), l(""), i([]);
3684
3686
  },
3685
3687
  onDragLeave: (h) => {
3686
3688
  h.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
@@ -3758,8 +3760,8 @@ const useHandleCanvasDblClick = (o, n) => {
3758
3760
  if (f) {
3759
3761
  const x = f.getAttribute("data-style-prop");
3760
3762
  if (x) {
3761
- const b = f.getAttribute("data-style-id"), k = f.getAttribute("data-block-parent");
3762
- l([{ id: b, prop: x, blockId: k }]);
3763
+ const b = f.getAttribute("data-style-id"), y = f.getAttribute("data-block-parent");
3764
+ l([{ id: b, prop: x, blockId: y }]);
3763
3765
  }
3764
3766
  }
3765
3767
  }, 100);
@@ -3811,15 +3813,15 @@ const useHandleCanvasDblClick = (o, n) => {
3811
3813
  forms,
3812
3814
  aspectRatio,
3813
3815
  containerQueries,
3814
- plugin(function({ addBase: b, theme: k }) {
3816
+ plugin(function({ addBase: b, theme: y }) {
3815
3817
  b({
3816
3818
  "h1,h2,h3,h4,h5,h6": {
3817
- fontFamily: k("fontFamily.heading")
3819
+ fontFamily: y("fontFamily.heading")
3818
3820
  },
3819
3821
  body: {
3820
- fontFamily: k("fontFamily.body"),
3821
- color: k("colors.foreground"),
3822
- backgroundColor: k("colors.background")
3822
+ fontFamily: y("fontFamily.body"),
3823
+ color: y("colors.foreground"),
3824
+ backgroundColor: y("colors.background")
3823
3825
  }
3824
3826
  });
3825
3827
  })
@@ -4003,23 +4005,23 @@ const getBlockRuntimeProps = memoize((o) => {
4003
4005
  c();
4004
4006
  }, [n, o, r, c]), l;
4005
4007
  }, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
4006
- 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([]), [, h] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [x, b] = useSelectedStylingBlocks(), k = useBuilderProp("loading", !1), w = useBuilderProp("htmlDir", "ltr"), S = (j) => {
4007
- p((C) => ({ ...C, width: j }));
4008
+ 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([]), [, h] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [x, b] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), v = useBuilderProp("htmlDir", "ltr"), S = (j) => {
4009
+ p((w) => ({ ...w, width: j }));
4008
4010
  };
4009
4011
  useEffect(() => {
4010
4012
  if (!c.current) return;
4011
- const { clientWidth: j, clientHeight: C } = c.current;
4012
- p({ width: j, height: C });
4013
+ const { clientWidth: j, clientHeight: w } = c.current;
4014
+ p({ width: j, height: w });
4013
4015
  }, [c, n]);
4014
- const A = (j, C = 0) => {
4015
- const { top: B } = j.getBoundingClientRect();
4016
- return B + C >= 0 && B - C <= window.innerHeight;
4016
+ const B = (j, w = 0) => {
4017
+ const { top: A } = j.getBoundingClientRect();
4018
+ return A + w >= 0 && A - w <= window.innerHeight;
4017
4019
  };
4018
4020
  useEffect(() => {
4019
- var j, C;
4021
+ var j, w;
4020
4022
  if (a && a.type !== "Multiple" && i.current) {
4021
- const B = getElementByDataBlockId(i.current.contentDocument, a._id);
4022
- B && (A(B) || (C = (j = i.current) == null ? void 0 : j.contentWindow) == null || C.scrollTo({ top: B.offsetTop, behavior: "smooth" }), m([B]));
4023
+ const A = getElementByDataBlockId(i.current.contentDocument, a._id);
4024
+ A && (B(A) || (w = (j = i.current) == null ? void 0 : j.contentWindow) == null || w.scrollTo({ top: A.offsetTop, behavior: "smooth" }), m([A]));
4023
4025
  }
4024
4026
  }, [a]), useEffect(() => {
4025
4027
  if (!isEmpty(x) && i.current) {
@@ -4033,8 +4035,8 @@ const getBlockRuntimeProps = memoize((o) => {
4033
4035
  }, [x]);
4034
4036
  const E = useMemo(() => {
4035
4037
  let j = IframeInitialContent;
4036
- return j = j.replace("__HTML_DIR__", w), o === "offline" && (j = j.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), j;
4037
- }, [o, w]);
4038
+ return j = j.replace("__HTML_DIR__", v), o === "offline" && (j = j.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), j;
4039
+ }, [o, v]);
4038
4040
  return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: S, onResize: S, children: /* @__PURE__ */ jsx(
4039
4041
  "div",
4040
4042
  {
@@ -4064,7 +4066,7 @@ const getBlockRuntimeProps = memoize((o) => {
4064
4066
  ),
4065
4067
  /* @__PURE__ */ jsx(HeadTags, {}),
4066
4068
  /* @__PURE__ */ jsx(Provider$1, { children: /* @__PURE__ */ jsxs(Canvas, { children: [
4067
- k ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
4069
+ y ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
4068
4070
  /* @__PURE__ */ jsx(AddBlockAtBottom, {}),
4069
4071
  /* @__PURE__ */ jsx("br", {}),
4070
4072
  /* @__PURE__ */ jsx("br", {}),
@@ -4114,7 +4116,7 @@ const getBlockRuntimeProps = memoize((o) => {
4114
4116
  l !== o.length - 1 && /* @__PURE__ */ jsx(ChevronRight, { className: "rtl:rotate-180", size: 16 })
4115
4117
  ] }, l))
4116
4118
  ] }) });
4117
- }, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-C-jeR5bt.js")), CanvasArea = () => {
4119
+ }, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-ZtRSywKI.js")), CanvasArea = () => {
4118
4120
  const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
4119
4121
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2", children: [
4120
4122
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -4486,11 +4488,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4486
4488
  if (f !== x)
4487
4489
  u.chain().deleteSelection().insertContent(h).run();
4488
4490
  else {
4489
- const { state: k } = u, w = k.selection.from, S = k.doc.textBetween(Math.max(0, w - 1), w), A = k.doc.textBetween(w, Math.min(w + 1, k.doc.content.size));
4491
+ const { state: y } = u, v = y.selection.from, S = y.doc.textBetween(Math.max(0, v - 1), v), B = y.doc.textBetween(v, Math.min(v + 1, y.doc.content.size));
4490
4492
  let E = "";
4491
- w > 0 && S !== " " && !/[.,!?;:]/.test(S) && (E = " ");
4493
+ v > 0 && S !== " " && !/[.,!?;:]/.test(S) && (E = " ");
4492
4494
  let j = "";
4493
- A && A !== " " && !/[.,!?;:]/.test(A) && (j = " "), u.chain().insertContent(E + h + j).run();
4495
+ B && B !== " " && !/[.,!?;:]/.test(B) && (j = " "), u.chain().insertContent(E + h + j).run();
4494
4496
  }
4495
4497
  };
4496
4498
  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: [
@@ -4572,73 +4574,73 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4572
4574
  onChange: r
4573
4575
  }) => {
4574
4576
  var L;
4575
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [b, k] = useState(-1), w = useRef(null), S = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
4577
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), v = useRef(null), S = (L = n == null ? void 0 : n.find((C) => C.key === u)) == null ? void 0 : L.name;
4576
4578
  useEffect(() => {
4577
- if (h(""), x([]), k(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4578
- const v = split(o, ":"), y = get(v, 1, "page") || "page";
4579
- g(y), (async () => {
4580
- const _ = await l(y, [get(v, 2, "page")]);
4579
+ if (h(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4580
+ const C = split(o, ":"), k = get(C, 1, "page") || "page";
4581
+ g(k), (async () => {
4582
+ const _ = await l(k, [get(C, 2, "page")]);
4581
4583
  _ && Array.isArray(_) && h(get(_, [0, "name"], ""));
4582
4584
  })();
4583
4585
  }, [o]);
4584
- const A = useDebouncedCallback(
4585
- async (v) => {
4586
- if (isEmpty(v))
4586
+ const B = useDebouncedCallback(
4587
+ async (C) => {
4588
+ if (isEmpty(C))
4587
4589
  x([]);
4588
4590
  else {
4589
- const y = await l(u, v);
4590
- x(y);
4591
+ const k = await l(u, C);
4592
+ x(k);
4591
4593
  }
4592
- c(!1), k(-1);
4594
+ c(!1), y(-1);
4593
4595
  },
4594
4596
  [u],
4595
4597
  300
4596
- ), E = (v) => {
4597
- const y = ["pageType", u, v.id];
4598
- y[1] && (r(y.join(":")), h(v.name), p(!1), x([]), k(-1));
4599
- }, j = (v) => {
4600
- switch (v.key) {
4598
+ ), E = (C) => {
4599
+ const k = ["pageType", u, C.id];
4600
+ k[1] && (r(k.join(":")), h(C.name), p(!1), x([]), y(-1));
4601
+ }, j = (C) => {
4602
+ switch (C.key) {
4601
4603
  case "ArrowDown":
4602
- v.preventDefault(), k((y) => y < f.length - 1 ? y + 1 : y);
4604
+ C.preventDefault(), y((k) => k < f.length - 1 ? k + 1 : k);
4603
4605
  break;
4604
4606
  case "ArrowUp":
4605
- v.preventDefault(), k((y) => y > 0 ? y - 1 : y);
4607
+ C.preventDefault(), y((k) => k > 0 ? k - 1 : k);
4606
4608
  break;
4607
4609
  case "Enter":
4608
- if (v.preventDefault(), f.length === 0) return;
4610
+ if (C.preventDefault(), f.length === 0) return;
4609
4611
  b >= 0 && E(f[b]);
4610
4612
  break;
4611
4613
  case "Escape":
4612
- v.preventDefault(), C();
4614
+ C.preventDefault(), w();
4613
4615
  break;
4614
4616
  }
4615
4617
  };
4616
4618
  useEffect(() => {
4617
- if (b >= 0 && w.current) {
4618
- const v = w.current.children[b];
4619
- v == null || v.scrollIntoView({ block: "nearest" });
4619
+ if (b >= 0 && v.current) {
4620
+ const C = v.current.children[b];
4621
+ C == null || C.scrollIntoView({ block: "nearest" });
4620
4622
  }
4621
4623
  }, [b]);
4622
- const C = () => {
4623
- h(""), x([]), k(-1), p(!1), r("");
4624
- }, B = (v) => {
4625
- h(v), p(!isEmpty(v)), c(!0), A(v);
4624
+ const w = () => {
4625
+ h(""), x([]), y(-1), p(!1), r("");
4626
+ }, A = (C) => {
4627
+ h(C), p(!isEmpty(C)), c(!0), B(C);
4626
4628
  };
4627
4629
  return /* @__PURE__ */ jsxs("div", { children: [
4628
- /* @__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)) }),
4630
+ /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (C) => g(C.target.value), children: map(n, (C) => /* @__PURE__ */ jsx("option", { value: C.key, children: C.name }, C.key)) }),
4629
4631
  u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
4630
4632
  /* @__PURE__ */ jsx(
4631
4633
  "input",
4632
4634
  {
4633
4635
  type: "text",
4634
4636
  value: m,
4635
- onChange: (v) => B(v.target.value),
4637
+ onChange: (C) => A(C.target.value),
4636
4638
  onKeyDown: j,
4637
4639
  placeholder: a(`Search ${S ?? ""}`),
4638
4640
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4639
4641
  }
4640
4642
  ),
4641
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: C, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4643
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: w, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4642
4644
  ] }),
4643
4645
  (i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
4644
4646
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -4648,22 +4650,22 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4648
4650
  ' "',
4649
4651
  m,
4650
4652
  '"'
4651
- ] }) : /* @__PURE__ */ jsx("ul", { ref: w, children: map(f == null ? void 0 : f.slice(0, 20), (v, y) => /* @__PURE__ */ jsxs(
4653
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(f == null ? void 0 : f.slice(0, 20), (C, k) => /* @__PURE__ */ jsxs(
4652
4654
  "li",
4653
4655
  {
4654
- onClick: () => E(v),
4655
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : y === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
4656
+ onClick: () => E(C),
4657
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(C.id) ? "bg-blue-200" : k === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
4656
4658
  children: [
4657
- v.name,
4659
+ C.name,
4658
4660
  " ",
4659
- v.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4661
+ C.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4660
4662
  "( ",
4661
- v.slug,
4663
+ C.slug,
4662
4664
  " )"
4663
4665
  ] })
4664
4666
  ]
4665
4667
  },
4666
- v.id
4668
+ C.id
4667
4669
  )) }) })
4668
4670
  ] });
4669
4671
  }, LinkField = ({ schema: o, formData: n, onChange: r }) => {
@@ -4748,16 +4750,16 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4748
4750
  const m = () => {
4749
4751
  const x = findIndex(u, { _id: g });
4750
4752
  if (x > -1) {
4751
- const b = (x + 1) % u.length, k = get(u, [b, "_id"]);
4752
- if (!k) return;
4753
- n({ ...o, currentSlide: k }), c([k]);
4753
+ const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
4754
+ if (!y) return;
4755
+ n({ ...o, currentSlide: y }), c([y]);
4754
4756
  }
4755
4757
  }, h = () => {
4756
4758
  const x = findIndex(u, { _id: g });
4757
4759
  if (x > -1) {
4758
- const b = (x - 1 + u.length) % u.length, k = get(u, [b, "_id"]);
4759
- if (!k) return;
4760
- n({ ...o, currentSlide: k }), c([k]);
4760
+ const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
4761
+ if (!y) return;
4762
+ n({ ...o, currentSlide: y }), c([y]);
4761
4763
  }
4762
4764
  }, f = () => {
4763
4765
  const x = i(
@@ -4883,8 +4885,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4883
4885
  formData: g,
4884
4886
  onChange: m
4885
4887
  }) => {
4886
- const { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = isEmpty(x) ? "" : isEmpty(h) ? f : h, k = get(LANGUAGES, b, b), w = usePageExternalData(), S = useSelectedBlock(), A = useRegisteredChaiBlocks(), E = get(A, [S == null ? void 0 : S._type, "i18nProps"], []) || [], [j, C] = useState(null), B = useCallback(
4887
- (y) => {
4888
+ const { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = isEmpty(x) ? "" : isEmpty(h) ? f : h, y = get(LANGUAGES, b, b), v = usePageExternalData(), S = useSelectedBlock(), B = useRegisteredChaiBlocks(), E = get(B, [S == null ? void 0 : S._type, "i18nProps"], []) || [], [j, w] = useState(null), A = useCallback(
4889
+ (k) => {
4888
4890
  const _ = (P) => /[.,!?;:]/.test(P), T = (P, N, M) => {
4889
4891
  let D = "", O = "";
4890
4892
  const $ = N > 0 ? P[N - 1] : "", H = N < P.length ? P[N] : "";
@@ -4899,7 +4901,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4899
4901
  if (R && (R.querySelector(".ProseMirror") || R.__chaiRTE)) {
4900
4902
  const P = R.__chaiRTE;
4901
4903
  if (P) {
4902
- const N = `{{${y}}}`;
4904
+ const N = `{{${k}}}`;
4903
4905
  P.commands.focus();
4904
4906
  const { from: M, to: D } = P.state.selection;
4905
4907
  if (M !== D)
@@ -4917,11 +4919,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4917
4919
  } else {
4918
4920
  const P = I, N = P.selectionStart || 0, M = P.value || "", D = P.selectionEnd || N;
4919
4921
  if (D > N) {
4920
- const F = `{{${y}}}`, { text: z } = T(M, N, F), W = M.slice(0, N) + z + M.slice(D);
4922
+ const F = `{{${k}}}`, { text: z } = T(M, N, F), W = M.slice(0, N) + z + M.slice(D);
4921
4923
  m(W, {}, o);
4922
4924
  return;
4923
4925
  }
4924
- const $ = `{{${y}}}`, { text: H } = T(M, N, $), U = M.slice(0, N) + H + M.slice(N);
4926
+ const $ = `{{${k}}}`, { text: H } = T(M, N, $), U = M.slice(0, N) + H + M.slice(N);
4925
4927
  m(U, {}, o);
4926
4928
  }
4927
4929
  },
@@ -4930,18 +4932,18 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4930
4932
  if (d)
4931
4933
  return null;
4932
4934
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
4933
- const v = E == null ? void 0 : E.includes(o.replace("root.", ""));
4935
+ const C = E == null ? void 0 : E.includes(o.replace("root.", ""));
4934
4936
  if (u.type === "array") {
4935
- const y = j === o;
4937
+ const k = j === o;
4936
4938
  return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
4937
4939
  u.title && /* @__PURE__ */ jsxs(
4938
4940
  "label",
4939
4941
  {
4940
4942
  htmlFor: o,
4941
- onClick: () => C(y ? null : o),
4943
+ onClick: () => w(k ? null : o),
4942
4944
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
4943
4945
  children: [
4944
- y ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
4946
+ k ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
4945
4947
  /* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
4946
4948
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: r }),
4947
4949
  " ",
@@ -4949,7 +4951,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4949
4951
  ]
4950
4952
  }
4951
4953
  ),
4952
- (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${y ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
4954
+ (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: [
4953
4955
  c,
4954
4956
  a,
4955
4957
  l,
@@ -4962,13 +4964,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4962
4964
  /* @__PURE__ */ jsxs("label", { htmlFor: o, className: u.type === "object" ? "pb-2" : "", children: [
4963
4965
  r,
4964
4966
  " ",
4965
- v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
4967
+ C && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
4966
4968
  " ",
4967
- k
4969
+ y
4968
4970
  ] }),
4969
4971
  p && u.type !== "object" ? " *" : null
4970
4972
  ] }),
4971
- u.type === "string" && !u.enum && !u.oneOf && w && /* @__PURE__ */ jsx(NestedPathSelector, { data: w, onSelect: B, dataType: "value" })
4973
+ u.type === "string" && !u.enum && !u.oneOf && v && /* @__PURE__ */ jsx(NestedPathSelector, { data: v, onSelect: A, dataType: "value" })
4972
4974
  ] }),
4973
4975
  c,
4974
4976
  a,
@@ -5067,28 +5069,28 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5067
5069
  }), a;
5068
5070
  };
5069
5071
  function BlockSettings() {
5070
- const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), f = ({ formData: j }, C, B) => {
5071
- C && (c == null ? void 0 : c._id) === n._id && a([n._id], { [C]: get(j, C) }, B);
5072
+ const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), f = ({ formData: j }, w, A) => {
5073
+ w && (c == null ? void 0 : c._id) === n._id && a([n._id], { [w]: get(j, w) }, A);
5072
5074
  }, x = useCallback(
5073
- debounce(({ formData: j }, C, B) => {
5074
- f({ formData: j }, C, B), d(j);
5075
+ debounce(({ formData: j }, w, A) => {
5076
+ f({ formData: j }, w, A), d(j);
5075
5077
  }, 1500),
5076
5078
  [n == null ? void 0 : n._id, o]
5077
- ), b = ({ formData: j }, C) => {
5078
- C && (r([n._id], { [C]: get(j, C) }), x({ formData: j }, C, { [C]: get(c, C) }));
5079
- }, k = ({ formData: j }, C) => {
5080
- C && (r([g._id], { [C]: get(j, C) }), x({ formData: j }, C, { [C]: get(c, C) }));
5079
+ ), b = ({ formData: j }, w) => {
5080
+ w && (r([n._id], { [w]: get(j, w) }), x({ formData: j }, w, { [w]: get(c, w) }));
5081
+ }, y = ({ formData: j }, w) => {
5082
+ w && (r([g._id], { [w]: get(j, w) }), x({ formData: j }, w, { [w]: get(c, w) }));
5081
5083
  };
5082
5084
  keys(get(i, "_bindings", {}));
5083
- const { schema: w, uiSchema: S } = useMemo(() => {
5085
+ const { schema: v, uiSchema: S } = useMemo(() => {
5084
5086
  const j = n == null ? void 0 : n._type;
5085
5087
  if (j)
5086
5088
  return getBlockFormSchemas(j);
5087
- }, [n]), { wrapperSchema: A, wrapperUiSchema: E } = useMemo(() => {
5089
+ }, [n]), { wrapperSchema: B, wrapperUiSchema: E } = useMemo(() => {
5088
5090
  if (!g || !(g != null && g._type))
5089
5091
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5090
- const j = g == null ? void 0 : g._type, { schema: C = {}, uiSchema: B = {} } = getBlockFormSchemas(j);
5091
- return { wrapperSchema: C, wrapperUiSchema: B };
5092
+ const j = g == null ? void 0 : g._type, { schema: w = {}, uiSchema: A = {} } = getBlockFormSchemas(j);
5093
+ return { wrapperSchema: w, wrapperUiSchema: A };
5092
5094
  }, [g]);
5093
5095
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5094
5096
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
@@ -5114,20 +5116,20 @@ function BlockSettings() {
5114
5116
  JSONForm,
5115
5117
  {
5116
5118
  blockId: g == null ? void 0 : g._id,
5117
- onChange: k,
5119
+ onChange: y,
5118
5120
  formData: h,
5119
- schema: A,
5121
+ schema: B,
5120
5122
  uiSchema: E
5121
5123
  }
5122
5124
  ) })
5123
5125
  ] }),
5124
- isEmpty(w) ? null : /* @__PURE__ */ jsx(
5126
+ isEmpty(v) ? null : /* @__PURE__ */ jsx(
5125
5127
  JSONForm,
5126
5128
  {
5127
5129
  blockId: n == null ? void 0 : n._id,
5128
5130
  onChange: b,
5129
5131
  formData: i,
5130
- schema: w,
5132
+ schema: v,
5131
5133
  uiSchema: S
5132
5134
  }
5133
5135
  ),
@@ -5233,32 +5235,32 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5233
5235
  canvas: n = !1,
5234
5236
  tooltip: r = !0
5235
5237
  }) => {
5236
- const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (k) => {
5237
- u.includes(k) ? u.length > 2 && g(u.filter((w) => w !== k)) : g((w) => [...w, k]);
5238
- }, x = (k) => {
5239
- n || l(k), c(k);
5238
+ const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (y) => {
5239
+ u.includes(y) ? u.length > 2 && g(u.filter((v) => v !== y)) : g((v) => [...v, y]);
5240
+ }, x = (y) => {
5241
+ n || l(y), c(y);
5240
5242
  }, b = getBreakpointValue(n ? i : a).toLowerCase();
5241
- return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (k) => /* @__PURE__ */ createElement(
5243
+ return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (y) => /* @__PURE__ */ createElement(
5242
5244
  BreakpointCard,
5243
5245
  {
5244
5246
  canvas: n,
5245
- ...k,
5247
+ ...y,
5246
5248
  onClick: x,
5247
- key: k.breakpoint,
5249
+ key: y.breakpoint,
5248
5250
  currentBreakpoint: b
5249
5251
  }
5250
5252
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
5251
5253
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
5252
- h.filter((k) => includes(u, toUpper(k.breakpoint))),
5253
- (k) => /* @__PURE__ */ createElement(
5254
+ h.filter((y) => includes(u, toUpper(y.breakpoint))),
5255
+ (y) => /* @__PURE__ */ createElement(
5254
5256
  BreakpointCard,
5255
5257
  {
5256
5258
  canvas: n,
5257
5259
  openDelay: o,
5258
5260
  tooltip: r,
5259
- ...k,
5261
+ ...y,
5260
5262
  onClick: x,
5261
- key: k.breakpoint,
5263
+ key: y.breakpoint,
5262
5264
  currentBreakpoint: b
5263
5265
  }
5264
5266
  )
@@ -5268,15 +5270,15 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5268
5270
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
5269
5271
  /* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
5270
5272
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
5271
- map(h, (k) => /* @__PURE__ */ jsx(
5273
+ map(h, (y) => /* @__PURE__ */ jsx(
5272
5274
  DropdownMenuCheckboxItem,
5273
5275
  {
5274
- disabled: k.breakpoint === "xs",
5275
- onCheckedChange: () => f(toUpper(k.breakpoint)),
5276
- checked: includes(u, toUpper(k.breakpoint)),
5277
- children: m(k.title)
5276
+ disabled: y.breakpoint === "xs",
5277
+ onCheckedChange: () => f(toUpper(y.breakpoint)),
5278
+ checked: includes(u, toUpper(y.breakpoint)),
5279
+ children: m(y.title)
5278
5280
  },
5279
- k.breakpoint
5281
+ y.breakpoint
5280
5282
  ))
5281
5283
  ] })
5282
5284
  ] })
@@ -5414,10 +5416,10 @@ const AskAIStyles = ({ blockId: o }) => {
5414
5416
  };
5415
5417
  function ManualClasses() {
5416
5418
  var T;
5417
- const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: k } = getSplitChaiClasses(get(p, b, "")), w = k.split(" ").filter((I) => !isEmpty(I)), S = () => {
5419
+ const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: y } = getSplitChaiClasses(get(p, b, "")), v = y.split(" ").filter((I) => !isEmpty(I)), S = () => {
5418
5420
  const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5419
5421
  u(m, I, !0), x("");
5420
- }, [A, E] = useState([]), j = ({ value: I }) => {
5422
+ }, [B, E] = useState([]), j = ({ value: I }) => {
5421
5423
  const R = I.trim().toLowerCase(), P = R.match(/.+:/g);
5422
5424
  let N = [];
5423
5425
  if (P && P.length > 0) {
@@ -5429,9 +5431,9 @@ function ManualClasses() {
5429
5431
  } else
5430
5432
  N = i.search(R);
5431
5433
  return E(map(N, "item"));
5432
- }, C = () => {
5434
+ }, w = () => {
5433
5435
  E([]);
5434
- }, B = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), v = useMemo(
5436
+ }, A = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), C = useMemo(
5435
5437
  () => ({
5436
5438
  ref: o,
5437
5439
  autoComplete: "off",
@@ -5447,7 +5449,7 @@ function ManualClasses() {
5447
5449
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
5448
5450
  }),
5449
5451
  [f, c, o]
5450
- ), y = (I) => {
5452
+ ), k = (I) => {
5451
5453
  debugger;
5452
5454
  const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5453
5455
  g(m, [I]), u(m, R, !0), r(""), l(-1);
@@ -5456,7 +5458,7 @@ function ManualClasses() {
5456
5458
  toast.error(c("Clipboard not supported"));
5457
5459
  return;
5458
5460
  }
5459
- navigator.clipboard.writeText(w.join(" ")), toast.success(c("Classes copied to clipboard"));
5461
+ navigator.clipboard.writeText(v.join(" ")), toast.success(c("Classes copied to clipboard"));
5460
5462
  };
5461
5463
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
5462
5464
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
@@ -5479,12 +5481,12 @@ function ManualClasses() {
5479
5481
  /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
5480
5482
  Autosuggest,
5481
5483
  {
5482
- suggestions: A,
5484
+ suggestions: B,
5483
5485
  onSuggestionsFetchRequested: j,
5484
- onSuggestionsClearRequested: C,
5485
- getSuggestionValue: B,
5486
+ onSuggestionsClearRequested: w,
5487
+ getSuggestionValue: A,
5486
5488
  renderSuggestion: L,
5487
- inputProps: v,
5489
+ inputProps: C,
5488
5490
  containerProps: {
5489
5491
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
5490
5492
  },
@@ -5507,7 +5509,7 @@ function ManualClasses() {
5507
5509
  }
5508
5510
  )
5509
5511
  ] }),
5510
- /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: w.map(
5512
+ /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: v.map(
5511
5513
  (I, R) => a === R ? /* @__PURE__ */ jsx(
5512
5514
  "input",
5513
5515
  {
@@ -5515,10 +5517,10 @@ function ManualClasses() {
5515
5517
  value: n,
5516
5518
  onChange: (P) => r(P.target.value),
5517
5519
  onBlur: () => {
5518
- y(I);
5520
+ k(I);
5519
5521
  },
5520
5522
  onKeyDown: (P) => {
5521
- P.key === "Enter" && y(I);
5523
+ P.key === "Enter" && k(I);
5522
5524
  },
5523
5525
  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"
5524
5526
  },
@@ -5712,7 +5714,7 @@ const COLOR_PROP = {
5712
5714
  const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""), h = useCallback(
5713
5715
  // eslint-disable-next-line no-shadow
5714
5716
  (b) => {
5715
- ["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((k) => ({ ...k, color: b, shade: k.shade ? k.shade : "500" })));
5717
+ ["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" })));
5716
5718
  },
5717
5719
  [c, p]
5718
5720
  );
@@ -5733,8 +5735,8 @@ const COLOR_PROP = {
5733
5735
  }, [r]);
5734
5736
  const { match: x } = useTailwindClassList();
5735
5737
  return useEffect(() => {
5736
- const k = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
5737
- x(o, k) && n(k, o);
5738
+ const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
5739
+ x(o, y) && n(y, o);
5738
5740
  }, [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: [
5739
5741
  /* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
5740
5742
  DropDown,
@@ -6166,47 +6168,47 @@ const COLOR_PROP = {
6166
6168
  },
6167
6169
  a
6168
6170
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
6169
- const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [b, k] = useState(""), [w, S] = useState(!1), [A, E] = useState(!1);
6171
+ const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [b, y] = useState(""), [v, S] = useState(!1), [B, E] = useState(!1);
6170
6172
  useEffect(() => {
6171
- const { value: v, unit: y } = getClassValueAndUnit(i);
6172
- if (y === "") {
6173
- l(v), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
6173
+ const { value: C, unit: k } = getClassValueAndUnit(i);
6174
+ if (k === "") {
6175
+ l(C), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
6174
6176
  return;
6175
6177
  }
6176
- h(y), l(y === "class" || isEmpty(v) ? "" : v);
6178
+ h(k), l(k === "class" || isEmpty(C) ? "" : C);
6177
6179
  }, [i, p, u]);
6178
- const j = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), C = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), B = useCallback(
6179
- (v = !1) => {
6180
- const y = getUserInputValues(`${a}`, u);
6181
- if (get(y, "error", !1)) {
6180
+ const j = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), w = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), A = useCallback(
6181
+ (C = !1) => {
6182
+ const k = getUserInputValues(`${a}`, u);
6183
+ if (get(k, "error", !1)) {
6182
6184
  x(!0);
6183
6185
  return;
6184
6186
  }
6185
- const _ = get(y, "unit") !== "" ? get(y, "unit") : m;
6187
+ const _ = get(k, "unit") !== "" ? get(k, "unit") : m;
6186
6188
  if (_ === "auto" || _ === "none") {
6187
6189
  j(`${d}${_}`);
6188
6190
  return;
6189
6191
  }
6190
- if (get(y, "value") === "")
6192
+ if (get(k, "value") === "")
6191
6193
  return;
6192
- const I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
6193
- v ? C(I) : j(I);
6194
+ const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
6195
+ C ? w(I) : j(I);
6194
6196
  },
6195
- [j, C, a, m, d, u]
6197
+ [j, w, a, m, d, u]
6196
6198
  ), L = useCallback(
6197
- (v) => {
6198
- const y = getUserInputValues(`${a}`, u);
6199
- if (get(y, "error", !1)) {
6199
+ (C) => {
6200
+ const k = getUserInputValues(`${a}`, u);
6201
+ if (get(k, "error", !1)) {
6200
6202
  x(!0);
6201
6203
  return;
6202
6204
  }
6203
- if (v === "auto" || v === "none") {
6204
- j(`${d}${v}`);
6205
+ if (C === "auto" || C === "none") {
6206
+ j(`${d}${C}`);
6205
6207
  return;
6206
6208
  }
6207
- if (get(y, "value") === "")
6209
+ if (get(k, "value") === "")
6208
6210
  return;
6209
- const _ = get(y, "unit") !== "" ? get(y, "unit") : v, I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
6211
+ const _ = get(k, "unit") !== "" ? get(k, "unit") : C, I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
6210
6212
  j(I);
6211
6213
  },
6212
6214
  [j, a, d, u]
@@ -6224,37 +6226,37 @@ const COLOR_PROP = {
6224
6226
  /* @__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, {}) }) }),
6225
6227
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
6226
6228
  ] })
6227
- ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${w ? "z-auto" : ""}`, children: [
6229
+ ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${v ? "z-auto" : ""}`, children: [
6228
6230
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
6229
6231
  ["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
6230
6232
  "input",
6231
6233
  {
6232
6234
  readOnly: m === "class",
6233
- onKeyPress: (v) => {
6234
- v.key === "Enter" && B();
6235
+ onKeyPress: (C) => {
6236
+ C.key === "Enter" && A();
6235
6237
  },
6236
- onKeyDown: (v) => {
6237
- if (v.keyCode !== 38 && v.keyCode !== 40)
6238
+ onKeyDown: (C) => {
6239
+ if (C.keyCode !== 38 && C.keyCode !== 40)
6238
6240
  return;
6239
- v.preventDefault(), E(!0);
6240
- const y = parseInt$1(v.target.value);
6241
- let _ = isNaN$1(y) ? 0 : y;
6242
- v.keyCode === 38 && (_ += 1), v.keyCode === 40 && (_ -= 1);
6241
+ C.preventDefault(), E(!0);
6242
+ const k = parseInt$1(C.target.value);
6243
+ let _ = isNaN$1(k) ? 0 : k;
6244
+ C.keyCode === 38 && (_ += 1), C.keyCode === 40 && (_ -= 1);
6243
6245
  const T = `${_}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${m === "-" ? "" : m}]`;
6244
- C(R);
6246
+ w(R);
6245
6247
  },
6246
- onKeyUp: (v) => {
6247
- A && (v.preventDefault(), E(!1));
6248
+ onKeyUp: (C) => {
6249
+ B && (C.preventDefault(), E(!1));
6248
6250
  },
6249
- onBlur: () => B(),
6250
- onChange: (v) => {
6251
- x(!1), l(v.target.value);
6251
+ onBlur: () => A(),
6252
+ onChange: (C) => {
6253
+ x(!1), l(C.target.value);
6252
6254
  },
6253
- onClick: (v) => {
6254
- var y;
6255
- (y = v == null ? void 0 : v.target) == null || y.select(), r(!1);
6255
+ onClick: (C) => {
6256
+ var k;
6257
+ (k = C == null ? void 0 : C.target) == null || k.select(), r(!1);
6256
6258
  },
6257
- value: w ? b : a,
6259
+ value: v ? b : a,
6258
6260
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
6259
6261
  " ",
6260
6262
  f ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -6279,29 +6281,29 @@ const COLOR_PROP = {
6279
6281
  {
6280
6282
  units: u,
6281
6283
  current: m,
6282
- onSelect: (v) => {
6283
- r(!1), h(v), L(v);
6284
+ onSelect: (C) => {
6285
+ r(!1), h(C), L(C);
6284
6286
  }
6285
6287
  }
6286
6288
  ) }) })
6287
6289
  ] })
6288
6290
  ] }),
6289
- ["none", "auto"].indexOf(m) !== -1 || w ? null : /* @__PURE__ */ jsx(
6291
+ ["none", "auto"].indexOf(m) !== -1 || v ? null : /* @__PURE__ */ jsx(
6290
6292
  DragStyleButton,
6291
6293
  {
6292
6294
  onDragStart: () => S(!0),
6293
- onDragEnd: (v) => {
6294
- if (k(() => ""), S(!1), isEmpty(v))
6295
+ onDragEnd: (C) => {
6296
+ if (y(() => ""), S(!1), isEmpty(C))
6295
6297
  return;
6296
- const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
6298
+ const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
6297
6299
  j(T);
6298
6300
  },
6299
- onDrag: (v) => {
6300
- if (isEmpty(v))
6301
+ onDrag: (C) => {
6302
+ if (isEmpty(C))
6301
6303
  return;
6302
- k(v);
6303
- const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
6304
- C(T);
6304
+ y(C);
6305
+ const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
6306
+ w(T);
6305
6307
  },
6306
6308
  currentValue: a,
6307
6309
  unit: m,
@@ -6398,32 +6400,32 @@ const COLOR_PROP = {
6398
6400
  "2xl": "1536px"
6399
6401
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6400
6402
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
6401
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), k = useCallback(
6402
- (C, B = !0) => {
6403
- const L = { dark: p, mq: g, mod: u, cls: C, property: l, fullCls: "" };
6403
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
6404
+ (w, A = !0) => {
6405
+ const L = { dark: p, mq: g, mod: u, cls: w, property: l, fullCls: "" };
6404
6406
  (p || u !== "") && (L.mq = "xs");
6405
- const v = generateFullClsName(L);
6406
- h(x, [v], B);
6407
+ const C = generateFullClsName(L);
6408
+ h(x, [C], A);
6407
6409
  },
6408
6410
  [x, p, g, u, l, h]
6409
- ), w = useCallback(() => {
6411
+ ), v = useCallback(() => {
6410
6412
  f(x, [b], !0);
6411
6413
  }, [x, b, f]), S = useMemo(() => canChangeClass(m, g), [m, g]);
6412
6414
  useEffect(() => {
6413
6415
  i(S, m);
6414
6416
  }, [S, i, m]);
6415
- const [, , A] = useScreenSizeWidth(), E = useCallback(
6416
- (C) => {
6417
- A({
6417
+ const [, , B] = useScreenSizeWidth(), E = useCallback(
6418
+ (w) => {
6419
+ B({
6418
6420
  xs: 400,
6419
6421
  sm: 640,
6420
6422
  md: 800,
6421
6423
  lg: 1024,
6422
6424
  xl: 1420,
6423
6425
  "2xl": 1920
6424
- }[C]);
6426
+ }[w]);
6425
6427
  },
6426
- [A]
6428
+ [B]
6427
6429
  ), j = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6428
6430
  return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: S, canReset: m && j, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6429
6431
  /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !j ? "text-foreground" : ""}`, children: n(a) }) }),
@@ -6435,17 +6437,17 @@ const COLOR_PROP = {
6435
6437
  currentClass: get(m, "cls", ""),
6436
6438
  classPrefix: get(CLASS_PREFIXES, l, ""),
6437
6439
  units: c || [],
6438
- onChange: k,
6440
+ onChange: y,
6439
6441
  negative: d,
6440
6442
  cssProperty: l
6441
6443
  }
6442
6444
  ) : null,
6443
- r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: k }),
6444
- r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: k }),
6445
- r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: k }),
6446
- r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: k })
6445
+ r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: y }),
6446
+ r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: y }),
6447
+ r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
6448
+ r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
6447
6449
  ] }),
6448
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: j ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => w(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : S && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6450
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: j ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : S && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6449
6451
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6450
6452
  "button",
6451
6453
  {
@@ -6857,22 +6859,22 @@ const CHAI_BUILDER_EVENTS = {
6857
6859
  }
6858
6860
  }
6859
6861
  }, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
6860
- var m, h, f, x, b, k, w, S;
6862
+ var m, h, f, x, b, y, v, S;
6861
6863
  if (r.type === "comment") return [];
6862
6864
  console.log("node ===>", r);
6863
6865
  let a = { _id: generateUUID() };
6864
6866
  if (n && (a._parent = n.block._id), r.type === "text")
6865
6867
  return isEmpty(get(r, "content", "")) ? [] : n && shouldAddText(n.node, n.block) ? (set(n, "block.content", get(r, "content", "")), []) : { ...a, _type: "Text", content: get(r, "content", "") };
6866
6868
  const l = get(r, "attributes", []), i = l.find(
6867
- (A) => A.key === "data-chai-richtext" || A.key === "chai-richtext"
6869
+ (B) => B.key === "data-chai-richtext" || B.key === "chai-richtext"
6868
6870
  ), c = l.find(
6869
- (A) => A.key === "data-chai-lightbox" || A.key === "chai-lightbox"
6871
+ (B) => B.key === "data-chai-lightbox" || B.key === "chai-lightbox"
6870
6872
  ), d = l.find(
6871
- (A) => A.key === "data-chai-dropdown" || A.key === "chai-dropdown"
6873
+ (B) => B.key === "data-chai-dropdown" || B.key === "chai-dropdown"
6872
6874
  ), p = l.find(
6873
- (A) => A.key === "data-chai-dropdown-button" || A.key === "chai-dropdown-button"
6875
+ (B) => B.key === "data-chai-dropdown-button" || B.key === "chai-dropdown-button"
6874
6876
  ), u = l.find(
6875
- (A) => A.key === "data-chai-dropdown-content" || A.key === "chai-dropdown-content"
6877
+ (B) => B.key === "data-chai-dropdown-content" || B.key === "chai-dropdown-content"
6876
6878
  );
6877
6879
  if (a = {
6878
6880
  ...a,
@@ -6880,13 +6882,13 @@ const CHAI_BUILDER_EVENTS = {
6880
6882
  ...getAttrs(r),
6881
6883
  ...getStyles(r)
6882
6884
  }, r.attributes) {
6883
- const A = r.attributes.find((E) => includes(NAME_ATTRIBUTES, E.key));
6884
- A && (a._name = A.value);
6885
+ const B = r.attributes.find((E) => includes(NAME_ATTRIBUTES, E.key));
6886
+ B && (a._name = B.value);
6885
6887
  }
6886
6888
  if (i)
6887
6889
  return a.content = stringify(r.children), has(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], has(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
6888
6890
  if (c) {
6889
- const A = [
6891
+ const B = [
6890
6892
  "data-chai-lightbox",
6891
6893
  "chai-lightbox",
6892
6894
  "data-vbtype",
@@ -6902,39 +6904,39 @@ const CHAI_BUILDER_EVENTS = {
6902
6904
  hrefType: ((h = l.find((E) => E.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
6903
6905
  autoplay: ((f = l.find((E) => E.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
6904
6906
  maxWidth: ((b = (x = l.find((E) => E.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : b.replace("px", "")) || "",
6905
- backdropColor: ((k = l.find((E) => E.key === "data-overlay")) == null ? void 0 : k.value) || "",
6906
- galleryName: ((w = l.find((E) => E.key === "data-gall")) == null ? void 0 : w.value) || ""
6907
- }, forEach(A, (E) => {
6907
+ backdropColor: ((y = l.find((E) => E.key === "data-overlay")) == null ? void 0 : y.value) || "",
6908
+ galleryName: ((v = l.find((E) => E.key === "data-gall")) == null ? void 0 : v.value) || ""
6909
+ }, forEach(B, (E) => {
6908
6910
  has(a, `styles_attrs.${E}`) && delete a.styles_attrs[E];
6909
6911
  });
6910
6912
  }
6911
6913
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
6912
6914
  delete a.styles_attrs;
6913
- const A = filter(r.children || [], (j) => (j == null ? void 0 : j.tagName) !== "span");
6914
- a.content = getTextContent(A);
6915
+ const B = filter(r.children || [], (j) => (j == null ? void 0 : j.tagName) !== "span");
6916
+ a.content = getTextContent(B);
6915
6917
  const E = find(
6916
6918
  r.children || [],
6917
- (j) => (j == null ? void 0 : j.tagName) === "span" && some(j.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg")
6919
+ (j) => (j == null ? void 0 : j.tagName) === "span" && some(j.children || [], (w) => (w == null ? void 0 : w.tagName) === "svg")
6918
6920
  );
6919
6921
  if (E) {
6920
- const j = find(E.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg");
6922
+ const j = find(E.children || [], (w) => (w == null ? void 0 : w.tagName) === "svg");
6921
6923
  if (j) {
6922
6924
  a.icon = stringify([j]);
6923
- const { height: C, width: B } = getSvgDimensions(j, "16px", "16px");
6924
- a.iconHeight = C, a.iconWidth = B;
6925
+ const { height: w, width: A } = getSvgDimensions(j, "16px", "16px");
6926
+ a.iconHeight = w, a.iconWidth = A;
6925
6927
  }
6926
6928
  }
6927
6929
  return [a];
6928
6930
  }
6929
6931
  if (a._type === "Input") {
6930
- const A = a.inputType || "text";
6931
- A === "checkbox" ? set(a, "_type", "Checkbox") : A === "radio" && set(a, "_type", "Radio");
6932
+ const B = a.inputType || "text";
6933
+ B === "checkbox" ? set(a, "_type", "Checkbox") : B === "radio" && set(a, "_type", "Radio");
6932
6934
  } else if (r.tagName === "video" || r.tagName === "iframe") {
6933
- const A = stringify([r]);
6934
- return hasVideoEmbed(A) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(A)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = A, [a];
6935
+ const B = stringify([r]);
6936
+ return hasVideoEmbed(B) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(B)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = B, [a];
6935
6937
  } else if (r.tagName === "svg") {
6936
- const A = find(r.attributes, { key: "height" }), E = find(r.attributes, { key: "width" }), j = get(A, "value") ? `[${get(A, "value")}px]` : "24px", C = get(E, "value") ? `[${get(E, "value")}px]` : "24px", B = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
6937
- return a.styles = `${STYLES_KEY}, ${cn$1(`w-${C} h-${j}`, B)}`.trim(), r.attributes = filter(r.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([r]), [a];
6938
+ const B = find(r.attributes, { key: "height" }), E = find(r.attributes, { key: "width" }), j = get(B, "value") ? `[${get(B, "value")}px]` : "24px", w = get(E, "value") ? `[${get(E, "value")}px]` : "24px", A = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
6939
+ return a.styles = `${STYLES_KEY}, ${cn$1(`w-${w} h-${j}`, A)}`.trim(), r.attributes = filter(r.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([r]), [a];
6938
6940
  } else if (r.tagName == "option" && n && ((S = n.block) == null ? void 0 : S._type) === "Select")
6939
6941
  return n.block.options.push({
6940
6942
  label: getTextContent(r.children),
@@ -7009,19 +7011,19 @@ const CHAI_BUILDER_EVENTS = {
7009
7011
  }), g(!0);
7010
7012
  else if (!l && Object.keys(a || {}).length > 0) {
7011
7013
  const h = Object.entries(a).map(([x, b]) => {
7012
- const k = b, w = k.type || "partial", S = formatReadableName(w);
7014
+ const y = b, v = y.type || "partial", S = formatReadableName(v);
7013
7015
  return {
7014
7016
  type: "PartialBlock",
7015
7017
  // Set the type to PartialBlock
7016
- label: formatReadableName(k.name || x),
7017
- description: k.description || "",
7018
+ label: formatReadableName(y.name || x),
7019
+ description: y.description || "",
7018
7020
  icon: Globe,
7019
7021
  group: S,
7020
7022
  // Use formatted type as group
7021
7023
  category: "partial",
7022
7024
  partialBlockId: x,
7023
7025
  // Store the original ID as partialBlockId
7024
- _name: k.name
7026
+ _name: y.name
7025
7027
  };
7026
7028
  }), f = uniq(map(h, "group"));
7027
7029
  p({
@@ -7069,44 +7071,44 @@ const CHAI_BUILDER_EVENTS = {
7069
7071
  }
7070
7072
  );
7071
7073
  }, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
7072
- var v;
7073
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (v = find(c, (y) => y._id === r)) == null ? void 0 : v._type, [h, f] = useState("all"), [x, b] = useState(null), k = useRef(null);
7074
+ var C;
7075
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (C = find(c, (k) => k._id === r)) == null ? void 0 : C._type, [h, f] = useState("all"), [x, b] = useState(null), y = useRef(null);
7074
7076
  useEffect(() => {
7075
- const y = setTimeout(() => {
7077
+ const k = setTimeout(() => {
7076
7078
  var _;
7077
7079
  (_ = u.current) == null || _.focus();
7078
7080
  }, 0);
7079
- return () => clearTimeout(y);
7081
+ return () => clearTimeout(k);
7080
7082
  }, [g]), useEffect(() => {
7081
7083
  d && (f("all"), b(null));
7082
- }, [d]), useEffect(() => (k.current = debounce((y) => {
7083
- f(y);
7084
+ }, [d]), useEffect(() => (y.current = debounce((k) => {
7085
+ f(k);
7084
7086
  }, 500), () => {
7085
- k.current && k.current.cancel();
7087
+ y.current && y.current.cancel();
7086
7088
  }), []);
7087
- const w = useCallback((y) => {
7088
- b(y), k.current && k.current(y);
7089
+ const v = useCallback((k) => {
7090
+ b(k), y.current && y.current(k);
7089
7091
  }, []), S = useCallback(() => {
7090
- b(null), k.current && k.current.cancel();
7091
- }, []), A = useCallback((y) => {
7092
- k.current && k.current.cancel(), f(y), b(null);
7092
+ b(null), y.current && y.current.cancel();
7093
+ }, []), B = useCallback((k) => {
7094
+ y.current && y.current.cancel(), f(k), b(null);
7093
7095
  }, []), E = useMemo(
7094
7096
  () => d ? values(n).filter(
7095
- (y) => {
7097
+ (k) => {
7096
7098
  var _, T;
7097
- return (((_ = y.label) == null ? void 0 : _.toLowerCase()) + " " + ((T = y.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
7099
+ return (((_ = k.label) == null ? void 0 : _.toLowerCase()) + " " + ((T = k.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
7098
7100
  }
7099
7101
  ) : n,
7100
7102
  [n, d]
7101
7103
  ), j = useMemo(
7102
7104
  () => d ? o.filter(
7103
- (y) => reject(filter(values(E), { group: y }), { hidden: !0 }).length > 0
7104
- ) : o.filter((y) => reject(filter(values(n), { group: y }), { hidden: !0 }).length > 0),
7105
+ (k) => reject(filter(values(E), { group: k }), { hidden: !0 }).length > 0
7106
+ ) : o.filter((k) => reject(filter(values(n), { group: k }), { hidden: !0 }).length > 0),
7105
7107
  [n, E, o, d]
7106
- ), C = useMemo(
7107
- () => sortBy(j, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
7108
+ ), w = useMemo(
7109
+ () => sortBy(j, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7108
7110
  [j]
7109
- ), B = useMemo(() => h === "all" ? E : filter(values(E), { group: h }), [E, h]), L = useMemo(() => h === "all" ? C : [h], [C, h]);
7111
+ ), A = useMemo(() => h === "all" ? E : filter(values(E), { group: h }), [E, h]), L = useMemo(() => h === "all" ? w : [h], [w, h]);
7110
7112
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7111
7113
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7112
7114
  Input$1,
@@ -7116,32 +7118,32 @@ const CHAI_BUILDER_EVENTS = {
7116
7118
  placeholder: i("Search blocks..."),
7117
7119
  value: d,
7118
7120
  className: "-ml-2",
7119
- onChange: (y) => p(y.target.value)
7121
+ onChange: (k) => p(k.target.value)
7120
7122
  }
7121
7123
  ) }),
7122
7124
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
7123
- C.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: [
7125
+ w.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: [
7124
7126
  /* @__PURE__ */ jsx(
7125
7127
  "button",
7126
7128
  {
7127
- onClick: () => A("all"),
7128
- onMouseEnter: () => w("all"),
7129
+ onClick: () => B("all"),
7130
+ onMouseEnter: () => v("all"),
7129
7131
  onMouseLeave: S,
7130
7132
  className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || x === "all" ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7131
7133
  children: i("All")
7132
7134
  },
7133
7135
  "sidebar-all"
7134
7136
  ),
7135
- C.map((y) => /* @__PURE__ */ jsx(
7137
+ w.map((k) => /* @__PURE__ */ jsx(
7136
7138
  "button",
7137
7139
  {
7138
- onClick: () => A(y),
7139
- onMouseEnter: () => w(y),
7140
+ onClick: () => B(k),
7141
+ onMouseEnter: () => v(k),
7140
7142
  onMouseLeave: S,
7141
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === y || x === y ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7142
- children: capitalize(i(y.toLowerCase()))
7143
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === k || x === k ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7144
+ children: capitalize(i(k.toLowerCase()))
7143
7145
  },
7144
- `sidebar-${y}`
7146
+ `sidebar-${k}`
7145
7147
  ))
7146
7148
  ] }) }) }),
7147
7149
  /* @__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: j.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: [
@@ -7149,10 +7151,10 @@ const CHAI_BUILDER_EVENTS = {
7149
7151
  ' "',
7150
7152
  d,
7151
7153
  '"'
7152
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((y) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7153
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(y.toLowerCase())) }),
7154
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7155
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
7154
7156
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7155
- h === "all" ? filter(values(B), { group: y }) : values(B),
7157
+ h === "all" ? filter(values(A), { group: k }) : values(A),
7156
7158
  { hidden: !0 }
7157
7159
  ).map((_) => /* @__PURE__ */ jsx(
7158
7160
  CoreBlock,
@@ -7164,7 +7166,7 @@ const CHAI_BUILDER_EVENTS = {
7164
7166
  },
7165
7167
  _.type
7166
7168
  )) })
7167
- ] }, y)) }) }) })
7169
+ ] }, k)) }) }) })
7168
7170
  ] })
7169
7171
  ] });
7170
7172
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -7262,12 +7264,12 @@ const BlockCard = ({
7262
7264
  parentId: r = void 0,
7263
7265
  position: a = -1
7264
7266
  }) => {
7265
- 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")), h = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), x = (w) => {
7266
- const S = has(w, "styles_attrs.data-page-section");
7267
- return w._type === "Box" && S;
7267
+ 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")), h = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), x = (v) => {
7268
+ const S = has(v, "styles_attrs.data-page-section");
7269
+ return v._type === "Box" && S;
7268
7270
  }, b = useCallback(
7269
- async (w) => {
7270
- if (w.stopPropagation(), has(o, "component")) {
7271
+ async (v) => {
7272
+ if (v.stopPropagation(), has(o, "component")) {
7271
7273
  d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7272
7274
  return;
7273
7275
  }
@@ -7284,18 +7286,18 @@ const BlockCard = ({
7284
7286
  onClick: l ? () => {
7285
7287
  } : b,
7286
7288
  draggable: h ? "true" : "false",
7287
- onDragStart: async (w) => {
7289
+ onDragStart: async (v) => {
7288
7290
  const S = await c(n, o);
7289
- let A = r;
7290
- if (x(first(S)) && (A = null), !isEmpty(S)) {
7291
- const E = { blocks: S, uiLibrary: !0, parent: A };
7292
- if (w.dataTransfer.setData("text/plain", JSON.stringify(E)), o.preview) {
7291
+ let B = r;
7292
+ if (x(first(S)) && (B = null), !isEmpty(S)) {
7293
+ const E = { blocks: S, uiLibrary: !0, parent: B };
7294
+ if (v.dataTransfer.setData("text/plain", JSON.stringify(E)), o.preview) {
7293
7295
  const j = new Image();
7294
7296
  j.src = o.preview, j.onload = () => {
7295
- w.dataTransfer.setDragImage(j, 0, 0);
7297
+ v.dataTransfer.setDragImage(j, 0, 0);
7296
7298
  };
7297
7299
  } else
7298
- w.dataTransfer.setDragImage(new Image(), 0, 0);
7300
+ v.dataTransfer.setDragImage(new Image(), 0, 0);
7299
7301
  f(E), setTimeout(() => {
7300
7302
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7301
7303
  }, 200);
@@ -7316,13 +7318,13 @@ const BlockCard = ({
7316
7318
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: m }) })
7317
7319
  ] });
7318
7320
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7319
- const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = l.find((w) => w.id === r) || first(l), { data: c, isLoading: d } = useLibraryBlocks(i), p = groupBy([...c], "group"), [u, g] = useState(null);
7321
+ const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = l.find((v) => v.id === r) || first(l), { data: c, isLoading: d } = useLibraryBlocks(i), p = groupBy([...c], "group"), [u, g] = useState(null);
7320
7322
  useEffect(() => {
7321
7323
  u || g(first(keys(p)));
7322
7324
  }, [p, u]);
7323
- const m = get(p, u, []), h = useRef(null), { t: f } = useTranslation(), x = (w) => {
7325
+ const m = get(p, u, []), h = useRef(null), { t: f } = useTranslation(), x = (v) => {
7324
7326
  h.current && (clearTimeout(h.current), h.current = null), h.current = setTimeout(() => {
7325
- h.current && g(w);
7327
+ h.current && g(v);
7326
7328
  }, 300);
7327
7329
  };
7328
7330
  if (d)
@@ -7330,14 +7332,14 @@ const BlockCard = ({
7330
7332
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7331
7333
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7332
7334
  ] });
7333
- const b = filter(m, (w, S) => S % 2 === 0), k = filter(m, (w, S) => S % 2 === 1);
7335
+ const b = filter(m, (v, S) => S % 2 === 0), y = filter(m, (v, S) => S % 2 === 1);
7334
7336
  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: [
7335
7337
  /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
7336
7338
  /* @__PURE__ */ jsx(UILibrariesSelect, { library: i == null ? void 0 : i.id, setLibrary: a, uiLibraries: l }),
7337
7339
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7338
7340
  /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: f("Groups") }),
7339
7341
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7340
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: map(p, (w, S) => /* @__PURE__ */ jsxs(
7342
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: map(p, (v, S) => /* @__PURE__ */ jsxs(
7341
7343
  "div",
7342
7344
  {
7343
7345
  onMouseEnter: () => x(S),
@@ -7363,22 +7365,22 @@ const BlockCard = ({
7363
7365
  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",
7364
7366
  children: [
7365
7367
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
7366
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: b.map((w, S) => /* @__PURE__ */ jsx(
7368
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: b.map((v, S) => /* @__PURE__ */ jsx(
7367
7369
  BlockCard,
7368
7370
  {
7369
7371
  parentId: o,
7370
7372
  position: n,
7371
- block: w,
7373
+ block: v,
7372
7374
  library: i
7373
7375
  },
7374
7376
  `block-${S}`
7375
7377
  )) }),
7376
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: k.map((w, S) => /* @__PURE__ */ jsx(
7378
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: y.map((v, S) => /* @__PURE__ */ jsx(
7377
7379
  BlockCard,
7378
7380
  {
7379
7381
  parentId: o,
7380
7382
  position: n,
7381
- block: w,
7383
+ block: v,
7382
7384
  library: i
7383
7385
  },
7384
7386
  `block-${S}`
@@ -7625,26 +7627,26 @@ const selectParent = (o, n) => {
7625
7627
  var P;
7626
7628
  const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom), { hasPermission: p } = usePermissions();
7627
7629
  let u = null;
7628
- const g = o.children.length > 0, { highlightBlock: m, clearHighlight: h } = useBlockHighlight(), { id: f, data: x, isSelected: b, willReceiveDrop: k, isDragging: w, isEditing: S, handleClick: A } = o, E = (N) => {
7630
+ const g = o.children.length > 0, { highlightBlock: m, clearHighlight: h } = useBlockHighlight(), { id: f, data: x, isSelected: b, willReceiveDrop: y, isDragging: v, isEditing: S, handleClick: B } = o, E = (N) => {
7629
7631
  N.stopPropagation(), !i.includes(f) && o.toggle();
7630
7632
  }, j = (N) => {
7631
7633
  N.isInternal && (u = N.isOpen, N.isOpen && N.close());
7632
- }, C = (N) => {
7634
+ }, w = (N) => {
7633
7635
  N.isInternal && u !== null && (u ? N.open() : N.close(), u = null);
7634
- }, [B, L] = useAtom$1(currentAddSelection), v = () => {
7636
+ }, [A, L] = useAtom$1(currentAddSelection), C = () => {
7635
7637
  var N;
7636
- y(), o.parent.isSelected || L((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7637
- }, y = () => {
7638
+ k(), o.parent.isSelected || L((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7639
+ }, k = () => {
7638
7640
  L(null);
7639
7641
  }, _ = (N) => {
7640
- y(), N.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), A(N);
7642
+ k(), N.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), B(N);
7641
7643
  };
7642
7644
  useEffect(() => {
7643
7645
  const N = setTimeout(() => {
7644
- k && !o.isOpen && !w && !i.includes(f) && o.toggle();
7646
+ y && !o.isOpen && !v && !i.includes(f) && o.toggle();
7645
7647
  }, 500);
7646
7648
  return () => clearTimeout(N);
7647
- }, [k, o, w]);
7649
+ }, [y, o, v]);
7648
7650
  const T = useMemo(() => {
7649
7651
  const N = Object.keys(x), M = [];
7650
7652
  for (let D = 0; D < N.length; D++)
@@ -7659,7 +7661,7 @@ const selectParent = (o, n) => {
7659
7661
  const $ = O.getBoundingClientRect(), H = d.getBoundingClientRect();
7660
7662
  $.top >= H.top && $.left >= H.left && $.bottom <= H.bottom && $.right <= H.right || (D.documentElement.scrollTop = O.offsetTop - H.top);
7661
7663
  }, R = (N) => {
7662
- y();
7664
+ k();
7663
7665
  const M = get(o, "parent.id");
7664
7666
  M !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: M, position: N }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: N });
7665
7667
  };
@@ -7689,7 +7691,7 @@ const selectParent = (o, n) => {
7689
7691
  "data-node-id": f,
7690
7692
  ref: i.includes(f) ? null : r,
7691
7693
  onDragStart: () => j(o),
7692
- onDragEnd: () => C(o),
7694
+ onDragEnd: () => w(o),
7693
7695
  onDragOver: (N) => {
7694
7696
  N.preventDefault(), I(f, "yes");
7695
7697
  },
@@ -7706,8 +7708,8 @@ const selectParent = (o, n) => {
7706
7708
  onClick: (N) => {
7707
7709
  N.stopPropagation(), R(o.childIndex);
7708
7710
  },
7709
- onMouseEnter: v,
7710
- onMouseLeave: y,
7711
+ onMouseEnter: C,
7712
+ onMouseLeave: k,
7711
7713
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
7712
7714
  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" }) })
7713
7715
  }
@@ -7718,9 +7720,9 @@ const selectParent = (o, n) => {
7718
7720
  className: cn$1(
7719
7721
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
7720
7722
  b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
7721
- k && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
7722
- (o == null ? void 0 : o.id) === B ? "bg-purple-100" : "",
7723
- w && "opacity-20",
7723
+ y && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
7724
+ (o == null ? void 0 : o.id) === A ? "bg-purple-100" : "",
7725
+ v && "opacity-20",
7724
7726
  i.includes(f) ? "opacity-50" : ""
7725
7727
  ),
7726
7728
  children: [
@@ -8093,58 +8095,58 @@ const selectParent = (o, n) => {
8093
8095
  }
8094
8096
  );
8095
8097
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
8096
- const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), m = (w) => {
8097
- a(w);
8098
+ const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), m = (v) => {
8099
+ a(v);
8098
8100
  }, h = () => {
8099
- const w = l.find((S) => Object.keys(S)[0] === r);
8100
- if (w) {
8101
- const S = Object.values(w)[0];
8101
+ const v = l.find((S) => Object.keys(S)[0] === r);
8102
+ if (v) {
8103
+ const S = Object.values(v)[0];
8102
8104
  S && typeof S == "object" && "fontFamily" in S && "borderRadius" in S && "colors" in S ? p(S) : console.error("Invalid preset structure:", S);
8103
8105
  } else
8104
8106
  console.error("Preset not found:", r);
8105
8107
  }, f = useDebouncedCallback(
8106
- (w, S) => {
8108
+ (v, S) => {
8107
8109
  p(() => ({
8108
8110
  ...d,
8109
8111
  fontFamily: {
8110
8112
  ...d.fontFamily,
8111
- [w.replace(/font-/g, "")]: S
8113
+ [v.replace(/font-/g, "")]: S
8112
8114
  }
8113
8115
  }));
8114
8116
  },
8115
8117
  [d],
8116
8118
  200
8117
8119
  ), x = useDebouncedCallback(
8118
- (w) => {
8120
+ (v) => {
8119
8121
  p(() => ({
8120
8122
  ...d,
8121
- borderRadius: `${w}px`
8123
+ borderRadius: `${v}px`
8122
8124
  }));
8123
8125
  },
8124
8126
  [d],
8125
8127
  200
8126
8128
  ), b = useDebouncedCallback(
8127
- (w, S) => {
8129
+ (v, S) => {
8128
8130
  p(() => {
8129
- const A = get(d, `colors.${w}`);
8130
- return n ? set(A, 1, S) : set(A, 0, S), {
8131
+ const B = get(d, `colors.${v}`);
8132
+ return n ? set(B, 1, S) : set(B, 0, S), {
8131
8133
  ...d,
8132
8134
  colors: {
8133
8135
  ...d.colors,
8134
- [w]: A
8136
+ [v]: B
8135
8137
  }
8136
8138
  };
8137
8139
  });
8138
8140
  },
8139
8141
  [d],
8140
8142
  200
8141
- ), k = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([S]) => {
8142
- const A = get(d, `colors.${S}.${n ? 1 : 0}`);
8143
+ ), y = (v) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(v.items).map(([S]) => {
8144
+ const B = get(d, `colors.${S}.${n ? 1 : 0}`);
8143
8145
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8144
8146
  /* @__PURE__ */ jsx(
8145
8147
  ColorPickerInput,
8146
8148
  {
8147
- value: A,
8149
+ value: B,
8148
8150
  onChange: (E) => b(S, E)
8149
8151
  }
8150
8152
  ),
@@ -8160,11 +8162,11 @@ const selectParent = (o, n) => {
8160
8162
  "select",
8161
8163
  {
8162
8164
  value: r,
8163
- onChange: (w) => m(w.target.value),
8165
+ onChange: (v) => m(v.target.value),
8164
8166
  className: "w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
8165
8167
  children: [
8166
8168
  /* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
8167
- Array.isArray(l) && l.map((w) => /* @__PURE__ */ jsx("option", { value: Object.keys(w)[0], children: capitalize(Object.keys(w)[0]) }, Object.keys(w)[0]))
8169
+ Array.isArray(l) && l.map((v) => /* @__PURE__ */ jsx("option", { value: Object.keys(v)[0], children: capitalize(Object.keys(v)[0]) }, Object.keys(v)[0]))
8168
8170
  ]
8169
8171
  }
8170
8172
  )
@@ -8181,14 +8183,14 @@ const selectParent = (o, n) => {
8181
8183
  ) })
8182
8184
  ] }),
8183
8185
  /* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
8184
- (u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([w, S]) => /* @__PURE__ */ jsx(
8186
+ (u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([v, S]) => /* @__PURE__ */ jsx(
8185
8187
  FontSelector,
8186
8188
  {
8187
- label: w,
8188
- value: d.fontFamily[w.replace(/font-/g, "")] || S[Object.keys(S)[0]],
8189
- onChange: (A) => f(w, A)
8189
+ label: v,
8190
+ value: d.fontFamily[v.replace(/font-/g, "")] || S[Object.keys(S)[0]],
8191
+ onChange: (B) => f(v, B)
8190
8192
  },
8191
- w
8193
+ v
8192
8194
  )) }),
8193
8195
  (u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
8194
8196
  /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Border Radius") }),
@@ -8199,7 +8201,7 @@ const selectParent = (o, n) => {
8199
8201
  ] }),
8200
8202
  (u == null ? void 0 : u.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
8201
8203
  /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Colors") }),
8202
- /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((w) => k(w)) }, n ? "dark" : "light")
8204
+ /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((v) => y(v)) }, n ? "dark" : "light")
8203
8205
  ] })
8204
8206
  ] }),
8205
8207
  /* @__PURE__ */ jsx("br", {}),
@@ -8887,7 +8889,8 @@ function getFromQueryParams(o) {
8887
8889
  return (r = new URLSearchParams(window.location.search).get("flags")) == null ? void 0 : r.includes(o);
8888
8890
  }
8889
8891
  const FEATURE_TOGGLES = {
8890
- dnd: getFromQueryParams("dnd")
8892
+ dnd: getFromQueryParams("dnd"),
8893
+ aiChat: getFromQueryParams("ai-chat")
8891
8894
  }, setDebugLogs = (o) => {
8892
8895
  }, getParentNodeIds = (o, n) => {
8893
8896
  const r = [];
@@ -8909,6 +8912,138 @@ function usePubSub(o, n) {
8909
8912
  return () => r();
8910
8913
  }, [o, n]);
8911
8914
  }
8915
+ function AIChatPanel() {
8916
+ const [o, n] = useState([]), [r, a] = useState(""), [l, i] = useState(!1), [c, d] = useState(null), p = useRef(null), u = useRef(null), g = useRef(null);
8917
+ useEffect(() => {
8918
+ var y;
8919
+ (y = u.current) == null || y.scrollIntoView({ behavior: "smooth" });
8920
+ }, [o]), useEffect(() => {
8921
+ g.current && (g.current.style.height = "auto", g.current.style.height = `${Math.min(g.current.scrollHeight, 120)}px`);
8922
+ }, [r]);
8923
+ const m = async () => {
8924
+ if (!r.trim() && !c) return;
8925
+ const y = {
8926
+ id: Date.now().toString(),
8927
+ role: "user",
8928
+ content: r,
8929
+ timestamp: /* @__PURE__ */ new Date()
8930
+ };
8931
+ n((v) => [...v, y]), a(""), i(!0), setTimeout(() => {
8932
+ const v = {
8933
+ id: (Date.now() + 1).toString(),
8934
+ role: "assistant",
8935
+ content: "This is a sample response from the AI assistant. In a real implementation, this would be replaced with an actual response from the AI model.",
8936
+ timestamp: /* @__PURE__ */ new Date()
8937
+ };
8938
+ n((S) => [...S, v]), i(!1), d(null);
8939
+ }, 1500);
8940
+ }, h = (y) => {
8941
+ y.key === "Enter" && !y.shiftKey && (y.preventDefault(), m());
8942
+ }, f = (y) => {
8943
+ var S;
8944
+ const v = (S = y.target.files) == null ? void 0 : S[0];
8945
+ if (v) {
8946
+ const B = new FileReader();
8947
+ B.onload = (E) => {
8948
+ var j;
8949
+ d((j = E.target) == null ? void 0 : j.result);
8950
+ }, B.readAsDataURL(v);
8951
+ }
8952
+ }, x = () => {
8953
+ var y;
8954
+ (y = p.current) == null || y.click();
8955
+ }, b = () => {
8956
+ d(null), p.current && (p.current.value = "");
8957
+ };
8958
+ return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
8959
+ /* @__PURE__ */ jsx(ScrollArea, { className: "flex-1 p-3", children: o.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "mt-10 flex h-full flex-col items-center justify-center p-4 text-center text-muted-foreground", children: [
8960
+ /* @__PURE__ */ jsx(Sparkles, { className: "mb-2 h-8 w-8 text-primary/50" }),
8961
+ /* @__PURE__ */ jsx("p", { className: "text-sm", children: "Ask me anything to get started" })
8962
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
8963
+ o.map((y) => /* @__PURE__ */ jsxs(
8964
+ "div",
8965
+ {
8966
+ className: cn(
8967
+ "flex max-w-full gap-2",
8968
+ y.role === "assistant" ? "items-start" : "items-start justify-end"
8969
+ ),
8970
+ children: [
8971
+ y.role === "assistant" && /* @__PURE__ */ jsx(Avatar, { className: "h-6 w-6 bg-primary/10", children: /* @__PURE__ */ jsx(Sparkles, { className: "h-3 w-3 text-primary" }) }),
8972
+ /* @__PURE__ */ jsx(
8973
+ "div",
8974
+ {
8975
+ className: cn(
8976
+ "rounded-lg px-3 py-2 text-sm",
8977
+ y.role === "assistant" ? "bg-muted text-foreground" : "bg-primary text-primary-foreground"
8978
+ ),
8979
+ children: y.content
8980
+ }
8981
+ ),
8982
+ y.role === "user" && /* @__PURE__ */ jsx(Avatar, { className: "h-6 w-6 bg-primary", children: /* @__PURE__ */ jsx("span", { className: "text-xs text-primary-foreground", children: "You" }) })
8983
+ ]
8984
+ },
8985
+ y.id
8986
+ )),
8987
+ l && /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
8988
+ /* @__PURE__ */ jsx(Avatar, { className: "h-6 w-6 bg-primary/10", children: /* @__PURE__ */ jsx(Sparkles, { className: "h-3 w-3 text-primary" }) }),
8989
+ /* @__PURE__ */ jsx("div", { className: "rounded-lg bg-muted px-3 py-2", children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-muted-foreground" }) })
8990
+ ] }),
8991
+ /* @__PURE__ */ jsx("div", { ref: u })
8992
+ ] }) }),
8993
+ c && /* @__PURE__ */ jsx("div", { className: "px-3 pt-2", children: /* @__PURE__ */ jsxs("div", { className: "relative h-20 w-20 overflow-hidden rounded-md", children: [
8994
+ /* @__PURE__ */ jsx("img", { src: c || "/placeholder.svg", alt: "Attachment", className: "h-full w-full object-cover" }),
8995
+ /* @__PURE__ */ jsx(
8996
+ Button,
8997
+ {
8998
+ size: "icon",
8999
+ variant: "destructive",
9000
+ className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
9001
+ onClick: b,
9002
+ children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
9003
+ }
9004
+ )
9005
+ ] }) }),
9006
+ /* @__PURE__ */ jsx("div", { className: "mt-auto p-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
9007
+ /* @__PURE__ */ jsxs("div", { className: "relative flex-1", children: [
9008
+ /* @__PURE__ */ jsx(
9009
+ Textarea,
9010
+ {
9011
+ ref: g,
9012
+ value: r,
9013
+ onChange: (y) => a(y.target.value),
9014
+ onKeyDown: h,
9015
+ placeholder: "Ask something...",
9016
+ className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
9017
+ }
9018
+ ),
9019
+ /* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: f, accept: "image/*", className: "hidden" }),
9020
+ /* @__PURE__ */ jsx(
9021
+ Button,
9022
+ {
9023
+ size: "icon",
9024
+ variant: "ghost",
9025
+ className: "absolute bottom-2 right-2 h-6 w-6",
9026
+ onClick: x,
9027
+ children: /* @__PURE__ */ jsx(Image$1, { className: "h-4 w-4 text-muted-foreground" })
9028
+ }
9029
+ )
9030
+ ] }),
9031
+ /* @__PURE__ */ jsxs(
9032
+ Button,
9033
+ {
9034
+ size: "sm",
9035
+ className: "h-10 px-3",
9036
+ onClick: m,
9037
+ disabled: l || !r.trim() && !c,
9038
+ children: [
9039
+ /* @__PURE__ */ jsx(Send, { className: "mr-1 h-4 w-4" }),
9040
+ "Send"
9041
+ ]
9042
+ }
9043
+ )
9044
+ ] }) })
9045
+ ] });
9046
+ }
8912
9047
  const AiAssistant = () => {
8913
9048
  const o = useAiAssistant(), [n] = useRightPanel(), r = useBuilderProp("askAiCallBack", null), { t: a } = useTranslation(), { hasPermission: l } = usePermissions();
8914
9049
  return !r || !l(PERMISSIONS.EDIT_BLOCK) ? null : /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
@@ -8956,7 +9091,7 @@ const AiAssistant = () => {
8956
9091
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: a("Toggle Data Binding") }) })
8957
9092
  ] }) });
8958
9093
  }, CanvasTopBar = () => {
8959
- const o = useBuilderProp("darkMode", !0), [n] = useCanvasZoom();
9094
+ const o = useBuilderProp("darkMode", !0), n = useFeature("aiChat"), [r] = useCanvasZoom();
8960
9095
  return /* @__PURE__ */ jsxs("div", { className: "flex h-10 items-center justify-between border-b border-border bg-background/70 px-2", children: [
8961
9096
  /* @__PURE__ */ jsxs("div", { className: "flex h-full space-x-2", children: [
8962
9097
  /* @__PURE__ */ jsx(Breakpoints$1, { canvas: !0, openDelay: 400 }),
@@ -8969,7 +9104,7 @@ const AiAssistant = () => {
8969
9104
  /* @__PURE__ */ jsx(ZoomInIcon, { className: "h-3.5 w-3.5 flex-shrink-0" }),
8970
9105
  " ",
8971
9106
  /* @__PURE__ */ jsxs("div", { className: "text-xs leading-3", children: [
8972
- round(n, 0),
9107
+ round(r, 0),
8973
9108
  "%"
8974
9109
  ] })
8975
9110
  ] }),
@@ -8979,7 +9114,7 @@ const AiAssistant = () => {
8979
9114
  ] }),
8980
9115
  /* @__PURE__ */ jsxs("div", { className: "flex h-full items-center space-x-2", children: [
8981
9116
  /* @__PURE__ */ jsx(ClearCanvas, {}),
8982
- /* @__PURE__ */ jsx(AiAssistant, {})
9117
+ n ? null : /* @__PURE__ */ jsx(AiAssistant, {})
8983
9118
  ] })
8984
9119
  ] });
8985
9120
  }, AttrsEditor = React__default.memo(function o({
@@ -8990,49 +9125,49 @@ const AiAssistant = () => {
8990
9125
  useEffect(() => {
8991
9126
  l(n);
8992
9127
  }, [n]);
8993
- const k = () => {
9128
+ const y = () => {
8994
9129
  if (i.startsWith("@")) {
8995
9130
  h("Attribute keys cannot start with '@'");
8996
9131
  return;
8997
9132
  }
8998
9133
  if (i) {
8999
- const C = [...a, { key: i, value: d }];
9000
- r(C), l(a), c(""), p(""), h("");
9134
+ const w = [...a, { key: i, value: d }];
9135
+ r(w), l(a), c(""), p(""), h("");
9001
9136
  }
9002
- }, w = (C) => {
9003
- const B = a.filter((L, v) => v !== C);
9004
- r(B), l(B);
9005
- }, S = (C) => {
9006
- g(C), c(a[C].key), p(a[C].value);
9007
- }, A = () => {
9137
+ }, v = (w) => {
9138
+ const A = a.filter((L, C) => C !== w);
9139
+ r(A), l(A);
9140
+ }, S = (w) => {
9141
+ g(w), c(a[w].key), p(a[w].value);
9142
+ }, B = () => {
9008
9143
  if (i.startsWith("@")) {
9009
9144
  h("Attribute keys cannot start with '@'");
9010
9145
  return;
9011
9146
  }
9012
9147
  if (u !== null && i) {
9013
- const C = [...a];
9014
- C[u] = { key: i, value: d }, r(C), l(C), g(null), c(""), p(""), h("");
9148
+ const w = [...a];
9149
+ w[u] = { key: i, value: d }, r(w), l(w), g(null), c(""), p(""), h("");
9015
9150
  }
9016
- }, E = (C) => {
9017
- C.key === "Enter" && !C.shiftKey && (C.preventDefault(), u !== null ? A() : k());
9018
- }, j = useCallback((C) => {
9019
- const B = (y) => /[.,!?;:]/.test(y), L = (y, _, T) => {
9151
+ }, E = (w) => {
9152
+ w.key === "Enter" && !w.shiftKey && (w.preventDefault(), u !== null ? B() : y());
9153
+ }, j = useCallback((w) => {
9154
+ const A = (k) => /[.,!?;:]/.test(k), L = (k, _, T) => {
9020
9155
  let I = "", R = "";
9021
- const P = _ > 0 ? y[_ - 1] : "", N = _ < y.length ? y[_] : "";
9022
- return _ > 0 && (P === "." || !B(P) && P !== " ") && (I = " "), _ < y.length && !B(N) && N !== " " && (R = " "), {
9156
+ const P = _ > 0 ? k[_ - 1] : "", N = _ < k.length ? k[_] : "";
9157
+ return _ > 0 && (P === "." || !A(P) && P !== " ") && (I = " "), _ < k.length && !A(N) && N !== " " && (R = " "), {
9023
9158
  text: I + T + R,
9024
9159
  prefixLength: I.length,
9025
9160
  suffixLength: R.length
9026
9161
  };
9027
- }, v = x.current;
9028
- if (v) {
9029
- const y = v.selectionStart || 0, _ = v.value || "", T = v.selectionEnd || y;
9030
- if (T > y) {
9031
- const M = `{{${C}}}`, { text: D } = L(_, y, M), O = _.slice(0, y) + D + _.slice(T);
9162
+ }, C = x.current;
9163
+ if (C) {
9164
+ const k = C.selectionStart || 0, _ = C.value || "", T = C.selectionEnd || k;
9165
+ if (T > k) {
9166
+ const M = `{{${w}}}`, { text: D } = L(_, k, M), O = _.slice(0, k) + D + _.slice(T);
9032
9167
  p(O);
9033
9168
  return;
9034
9169
  }
9035
- const R = `{{${C}}}`, { text: P } = L(_, y, R), N = _.slice(0, y) + P + _.slice(y);
9170
+ const R = `{{${w}}}`, { text: P } = L(_, k, R), N = _.slice(0, k) + P + _.slice(k);
9036
9171
  p(N);
9037
9172
  }
9038
9173
  }, []);
@@ -9040,8 +9175,8 @@ const AiAssistant = () => {
9040
9175
  /* @__PURE__ */ jsxs(
9041
9176
  "form",
9042
9177
  {
9043
- onSubmit: (C) => {
9044
- C.preventDefault(), u !== null ? A() : k();
9178
+ onSubmit: (w) => {
9179
+ w.preventDefault(), u !== null ? B() : y();
9045
9180
  },
9046
9181
  className: "space-y-3",
9047
9182
  children: [
@@ -9057,7 +9192,7 @@ const AiAssistant = () => {
9057
9192
  id: "attrKey",
9058
9193
  ref: f,
9059
9194
  value: i,
9060
- onChange: (C) => c(C.target.value),
9195
+ onChange: (w) => c(w.target.value),
9061
9196
  placeholder: "Enter Key",
9062
9197
  className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
9063
9198
  }
@@ -9078,7 +9213,7 @@ const AiAssistant = () => {
9078
9213
  rows: 2,
9079
9214
  ref: x,
9080
9215
  value: d,
9081
- onChange: (C) => p(C.target.value),
9216
+ onChange: (w) => p(w.target.value),
9082
9217
  onKeyDown: E,
9083
9218
  placeholder: "Enter Value",
9084
9219
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
@@ -9091,16 +9226,16 @@ const AiAssistant = () => {
9091
9226
  ]
9092
9227
  }
9093
9228
  ),
9094
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((C, B) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9229
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((w, A) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9095
9230
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9096
- /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: C.key }),
9097
- /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: C.value.toString() })
9231
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: w.key }),
9232
+ /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: w.value.toString() })
9098
9233
  ] }),
9099
9234
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9100
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => S(B), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9101
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => w(B), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9235
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => S(A), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9236
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(A), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9102
9237
  ] })
9103
- ] }, B)) })
9238
+ ] }, A)) })
9104
9239
  ] });
9105
9240
  }), BlockAttributesEditor = React.memo(() => {
9106
9241
  const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9294,27 +9429,38 @@ const ChooseLayout = ({ open: o, close: n }) => {
9294
9429
  )
9295
9430
  ] }) })
9296
9431
  ] }) });
9297
- }, TopBar = lazy(() => import("./Topbar-DZ2jHLv7.js"));
9432
+ }, TopBar = lazy(() => import("./Topbar-CX5hnmQJ.js")), DEFAULT_PANEL_WIDTH = 280;
9298
9433
  function useSidebarMenuItems() {
9299
- return useMemo(() => compact([
9300
- {
9434
+ const o = useBuilderProp("askAiCallBack", null), n = useFeature("aiChat");
9435
+ return useMemo(() => {
9436
+ const r = [];
9437
+ return r.push({
9438
+ id: "outline",
9301
9439
  icon: /* @__PURE__ */ jsx(Layers, { size: 20 }),
9302
9440
  label: "Outline",
9303
9441
  isInternal: !0,
9442
+ width: DEFAULT_PANEL_WIDTH,
9304
9443
  component: () => /* @__PURE__ */ jsx("div", { className: "-mt-8", children: /* @__PURE__ */ jsx(ListTree, {}) })
9305
- }
9306
- ]), []);
9444
+ }), o && n && r.unshift({
9445
+ id: "ai",
9446
+ icon: /* @__PURE__ */ jsx(SparklesIcon, { size: 20 }),
9447
+ label: "AI Assistant",
9448
+ isInternal: !0,
9449
+ width: 450,
9450
+ component: () => /* @__PURE__ */ jsx("div", { className: "-mt-8 h-full max-h-full", children: /* @__PURE__ */ jsx(AIChatPanel, {}) })
9451
+ }), compact(r);
9452
+ }, [o, n]);
9307
9453
  }
9308
9454
  const RootLayout = () => {
9309
- const [o, n] = useState(0), [r, a] = useState(!1), [l, i] = useRightPanel();
9455
+ const [o, n] = useAtom$1(sidebarActivePanelAtom), [r, a] = useState(!1), [l, i] = useRightPanel();
9310
9456
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9311
- n(1);
9457
+ n("outline");
9312
9458
  });
9313
- const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (x) => {
9314
- x.preventDefault();
9315
- }, u = (x) => {
9316
- n(o === x ? null : x);
9317
- }, g = useSidebarMenuItems(), { t: m } = useTranslation(), h = [...g, ...c], f = useBuilderProp("htmlDir", "ltr");
9459
+ const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (y) => {
9460
+ y.preventDefault();
9461
+ }, u = (y) => {
9462
+ n(o === y ? null : y);
9463
+ }, g = useSidebarMenuItems(), { t: m } = useTranslation(), h = useMemo(() => [...g, ...c], [g, c]), f = useBuilderProp("htmlDir", "ltr"), x = find(h, { id: o }), b = get(x, "width", DEFAULT_PANEL_WIDTH);
9318
9464
  return /* @__PURE__ */ jsx("div", { dir: f, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9319
9465
  /* @__PURE__ */ jsxs(
9320
9466
  "div",
@@ -9324,42 +9470,42 @@ const RootLayout = () => {
9324
9470
  children: [
9325
9471
  /* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
9326
9472
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9327
- /* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9328
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: h.map((x, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9473
+ /* @__PURE__ */ jsxs("div", { className: "flex h-full w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9474
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: h.map((y, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9329
9475
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
9330
9476
  Button,
9331
9477
  {
9332
- variant: o === b ? "default" : "ghost",
9478
+ variant: o === y.id ? "default" : "ghost",
9333
9479
  className: "mb-2 rounded-lg p-2 transition-colors",
9334
- onClick: () => u(b),
9335
- children: get(x, "icon", null)
9480
+ onClick: () => u(y.id),
9481
+ children: get(y, "icon", null)
9336
9482
  },
9337
- b
9483
+ v
9338
9484
  ) }),
9339
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(x.label) }) })
9340
- ] }, "button" + b)) }),
9485
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(y.label) }) })
9486
+ ] }, "button" + v)) }),
9341
9487
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9342
- /* @__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}`)) })
9488
+ /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col", children: d == null ? void 0 : d.map((y, v) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(y, {}) }, `sidebar-component-${v}`)) })
9343
9489
  ] }),
9344
9490
  /* @__PURE__ */ jsx(
9345
9491
  motion.div,
9346
9492
  {
9347
9493
  className: "h-full max-h-full border-r border-border",
9348
- initial: { width: 280 },
9349
- animate: { width: o !== null ? 280 : 0 },
9494
+ initial: { width: b },
9495
+ animate: { width: o !== null ? b : 0 },
9350
9496
  transition: { duration: 0.3, ease: "easeInOut" },
9351
9497
  children: o !== null && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
9352
9498
  /* @__PURE__ */ jsxs(
9353
9499
  "div",
9354
9500
  {
9355
- className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(h, `${o}.isInternal`, !1) ? "" : "w-64"}`,
9501
+ className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(x, "isInternal", !1) ? "" : "w-64"}`,
9356
9502
  children: [
9357
- /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(h, `${o}.icon`, null) }),
9358
- /* @__PURE__ */ jsx("span", { children: m(h[o].label) })
9503
+ /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(x, "icon", null) }),
9504
+ /* @__PURE__ */ jsx("span", { children: m(x == null ? void 0 : x.label) })
9359
9505
  ]
9360
9506
  }
9361
9507
  ),
9362
- /* @__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(h, `${o}.component`, null), {}) }) })
9508
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(x, "component", null), {}) }) })
9363
9509
  ] })
9364
9510
  }
9365
9511
  ),
@@ -9371,8 +9517,8 @@ const RootLayout = () => {
9371
9517
  motion.div,
9372
9518
  {
9373
9519
  className: "h-full max-h-full border-l border-border",
9374
- initial: { width: 280 },
9375
- animate: { width: 280 },
9520
+ initial: { width: o === "ai" ? 0 : DEFAULT_PANEL_WIDTH },
9521
+ animate: { width: o === "ai" ? 0 : DEFAULT_PANEL_WIDTH },
9376
9522
  transition: { duration: 0.3, ease: "easeInOut" },
9377
9523
  children: /* @__PURE__ */ jsx("div", { className: "no-scrollbar overflow h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col overflow-hidden p-3", children: [
9378
9524
  /* @__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: [
@@ -9395,7 +9541,7 @@ const RootLayout = () => {
9395
9541
  }
9396
9542
  )
9397
9543
  ] }) : null }) }) }),
9398
- /* @__PURE__ */ jsx("div", { className: "flex max-h-full w-full", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: l === "ai" ? /* @__PURE__ */ jsx(AskAI, {}) : l === "theme" ? /* @__PURE__ */ jsx(ThemeConfigPanel, {}) : /* @__PURE__ */ jsx(SettingsPanel, {}) }) })
9544
+ /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: l === "ai" ? /* @__PURE__ */ jsx(AskAI, {}) : l === "theme" ? /* @__PURE__ */ jsx(ThemeConfigPanel, {}) : /* @__PURE__ */ jsx(SettingsPanel, {}) }) })
9399
9545
  ] }) })
9400
9546
  }
9401
9547
  )