@chaibuilder/sdk 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,15 +1,15 @@
1
1
  var G = Object.defineProperty;
2
2
  var K = (o, n, r) => n in o ? G(o, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[n] = r;
3
3
  var V = (o, n, r) => K(o, typeof n != "symbol" ? n + "" : n, r);
4
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
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, useState, useRef, Suspense, createElement, memo, lazy } from "react";
7
7
  import { O as DropdownMenu, P as DropdownMenuTrigger, Q as DropdownMenuContent, R as DropdownMenuItem, S as Skeleton, B as Button, a6 as Label, H as Dialog, I as DialogTrigger, J as DialogContent, a7 as Popover, ak as Tooltip, al as TooltipTrigger, a8 as PopoverTrigger, am as TooltipContent, a9 as PopoverContent, v as Command, x as CommandInput, y as CommandList, z as CommandEmpty, D as CommandGroup, E as CommandItem, K as DialogHeader, M as DialogTitle, n as Badge, V as DropdownMenuLabel, W as DropdownMenuSeparator, T as DropdownMenuCheckboxItem, a2 as HoverCard, a3 as HoverCardTrigger, a4 as HoverCardContent, aj as Textarea, a5 as Input$1, ao as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, aa as ScrollArea, Y as DropdownMenuGroup, X as DropdownMenuShortcut, A as Accordion, C as Card, q as CardHeader, t as CardDescription, u as CardContent, r as CardFooter, af as Tabs, ag as TabsList, ah as TabsTrigger, ai as TabsContent, e as AlertDialog, f as AlertDialogTrigger, g as AlertDialogContent, h as AlertDialogHeader, j as AlertDialogTitle, k as AlertDialogDescription, i as AlertDialogFooter, m as AlertDialogCancel, l as AlertDialogAction, ae as Switch, ac as Separator, an as TooltipProvider, ad as Toaster } from "./tooltip-PKiP886L.js";
8
- import { atom as atom$1, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
9
- import { find, filter, flatten, map, omit, isString, has, isObject, memoize, get, compact, isEmpty, noop, includes, without, each, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, findIndex, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split, take, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
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
+ 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, startCase, debounce, capitalize, split, take, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
10
10
  import { Provider as Provider$1 } from "react-wrap-balancer";
11
11
  import { useTranslation, initReactI18next } from "react-i18next";
12
- import { useTranslation as Ve } from "react-i18next";
12
+ import { useTranslation as He } from "react-i18next";
13
13
  import { g as generateUUID, a as getBreakpointValue, c as cn$1 } from "./Functions-BGzDsf1z.js";
14
14
  import { flip } from "@floating-ui/dom";
15
15
  import { useFloating, shift } from "@floating-ui/react-dom";
@@ -17,7 +17,7 @@ import { PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, Plus
17
17
  import { useThrottledCallback, useDebouncedCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
18
18
  import { useFeature, FlagsProvider } from "flagged";
19
19
  import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredChaiBlocks, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
20
- import { registerChaiBlock as Fe } from "@chaibuilder/runtime";
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
22
  import TreeModel from "tree-model";
23
23
  import { useHotkeys } from "react-hotkeys-hook";
@@ -36,7 +36,6 @@ import { ErrorBoundary } from "react-error-boundary";
36
36
  import { Resizable } from "re-resizable";
37
37
  import RjForm from "@rjsf/core";
38
38
  import validator from "@rjsf/validator-ajv8";
39
- import { isEmpty as isEmpty$1, get as get$1 } from "lodash";
40
39
  import Link from "@tiptap/extension-link";
41
40
  import TextAlign from "@tiptap/extension-text-align";
42
41
  import Underline from "@tiptap/extension-underline";
@@ -46,7 +45,7 @@ import Fuse from "fuse.js";
46
45
  import { parse, stringify } from "himalaya";
47
46
  import { Tree } from "react-arborist";
48
47
  import i18n from "i18next";
49
- import { default as We } from "i18next";
48
+ import { default as ze } from "i18next";
50
49
  import { motion } from "framer-motion";
51
50
  const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.write, isAtomStateInitialized = (o) => "v" in o || "e" in o, returnAtomValue = (o) => {
52
51
  if ("e" in o)
@@ -94,197 +93,197 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
94
93
  for (const i of n.p)
95
94
  l.add(i);
96
95
  return l;
97
- }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (h, ...f) => h.read(...f), p = (h, ...f) => h.write(...f), u = (h, f) => {
98
- var x;
99
- return (x = h.unstable_onInit) == null ? void 0 : x.call(h, f);
100
- }, g = (h, f) => {
101
- var x;
102
- return (x = h.onMount) == null ? void 0 : x.call(h, f);
96
+ }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (x, ...f) => x.read(...f), p = (x, ...f) => x.write(...f), u = (x, f) => {
97
+ var h;
98
+ return (h = x.unstable_onInit) == null ? void 0 : h.call(x, f);
99
+ }, g = (x, f) => {
100
+ var h;
101
+ return (h = x.onMount) == null ? void 0 : h.call(x, f);
103
102
  }, ...m) => {
104
- const h = m[0] || ((C) => {
105
- let L = o.get(C);
106
- return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(C, L), u == null || u(C, S)), L;
103
+ const x = m[0] || ((w) => {
104
+ let L = o.get(w);
105
+ return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(w, L), u == null || u(w, S)), L;
107
106
  }), f = m[1] || (() => {
108
- let C, L;
109
- const v = (k) => {
107
+ let w, L;
108
+ const v = (y) => {
110
109
  try {
111
- k();
112
- } catch (A) {
113
- C || (C = !0, L = A);
110
+ y();
111
+ } catch (E) {
112
+ w || (w = !0, L = E);
114
113
  }
115
114
  };
116
115
  do {
117
116
  c.f && v(c.f);
118
- const k = /* @__PURE__ */ new Set(), A = k.add.bind(k);
117
+ const y = /* @__PURE__ */ new Set(), E = y.add.bind(y);
119
118
  a.forEach((T) => {
120
119
  var I;
121
- return (I = n.get(T)) == null ? void 0 : I.l.forEach(A);
122
- }), a.clear(), i.forEach(A), i.clear(), l.forEach(A), l.clear(), k.forEach(v), a.size && x();
120
+ return (I = n.get(T)) == null ? void 0 : I.l.forEach(E);
121
+ }), a.clear(), i.forEach(E), i.clear(), l.forEach(E), l.clear(), y.forEach(v), a.size && h();
123
122
  } while (a.size || i.size || l.size);
124
- if (C)
123
+ if (w)
125
124
  throw L;
126
- }), x = m[2] || (() => {
127
- const C = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
128
- for (; k.length; ) {
129
- const A = k[k.length - 1], T = h(A);
130
- if (v.has(A)) {
131
- k.pop();
125
+ }), h = m[2] || (() => {
126
+ const w = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
127
+ for (; y.length; ) {
128
+ const E = y[y.length - 1], T = x(E);
129
+ if (v.has(E)) {
130
+ y.pop();
132
131
  continue;
133
132
  }
134
- if (L.has(A)) {
135
- r.get(A) === T.n && C.push([A, T]), v.add(A), k.pop();
133
+ if (L.has(E)) {
134
+ r.get(E) === T.n && w.push([E, T]), v.add(E), y.pop();
136
135
  continue;
137
136
  }
138
- L.add(A);
139
- for (const I of getMountedOrPendingDependents(A, T, n))
140
- L.has(I) || k.push(I);
137
+ L.add(E);
138
+ for (const I of getMountedOrPendingDependents(E, T, n))
139
+ L.has(I) || y.push(I);
141
140
  }
142
- for (let A = C.length - 1; A >= 0; --A) {
143
- const [T, I] = C[A];
144
- let P = !1;
145
- for (const N of I.d.keys())
146
- if (N !== T && a.has(N)) {
147
- P = !0;
141
+ for (let E = w.length - 1; E >= 0; --E) {
142
+ const [T, I] = w[E];
143
+ let R = !1;
144
+ for (const P of I.d.keys())
145
+ if (P !== T && a.has(P)) {
146
+ R = !0;
148
147
  break;
149
148
  }
150
- P && (b(T), E(T)), r.delete(T);
149
+ R && (b(T), B(T)), r.delete(T);
151
150
  }
152
- }), b = m[3] || ((C) => {
151
+ }), b = m[3] || ((w) => {
153
152
  var L, v;
154
- const k = h(C);
155
- if (isAtomStateInitialized(k) && (n.has(C) && r.get(C) !== k.n || Array.from(k.d).every(
156
- ([R, O]) => (
153
+ const y = x(w);
154
+ if (isAtomStateInitialized(y) && (n.has(w) && r.get(w) !== y.n || Array.from(y.d).every(
155
+ ([D, O]) => (
157
156
  // Recursively, read the atom state of the dependency, and
158
157
  // check if the atom epoch number is unchanged
159
- b(R).n === O
158
+ b(D).n === O
160
159
  )
161
160
  )))
162
- return k;
163
- k.d.clear();
164
- let A = !0;
161
+ return y;
162
+ y.d.clear();
163
+ let E = !0;
165
164
  const T = () => {
166
- n.has(C) && (E(C), x(), f());
167
- }, I = (R) => {
165
+ n.has(w) && (B(w), h(), f());
166
+ }, I = (D) => {
168
167
  var O;
169
- if (isSelfAtom(C, R)) {
170
- const H = h(R);
168
+ if (isSelfAtom(w, D)) {
169
+ const H = x(D);
171
170
  if (!isAtomStateInitialized(H))
172
- if (hasInitialValue(R))
173
- setAtomStateValueOrPromise(R, R.init, h);
171
+ if (hasInitialValue(D))
172
+ setAtomStateValueOrPromise(D, D.init, x);
174
173
  else
175
174
  throw new Error("no atom init");
176
175
  return returnAtomValue(H);
177
176
  }
178
- const M = b(R);
177
+ const $ = b(D);
179
178
  try {
180
- return returnAtomValue(M);
179
+ return returnAtomValue($);
181
180
  } finally {
182
- k.d.set(R, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(C, k.v, M), (O = n.get(R)) == null || O.t.add(C), A || T();
181
+ y.d.set(D, $.n), isPendingPromise(y.v) && addPendingPromiseToDependency(w, y.v, $), (O = n.get(D)) == null || O.t.add(w), E || T();
183
182
  }
184
183
  };
185
- let P, N;
186
- const D = {
184
+ let R, P;
185
+ const N = {
187
186
  get signal() {
188
- return P || (P = new AbortController()), P.signal;
187
+ return R || (R = new AbortController()), R.signal;
189
188
  },
190
189
  get setSelf() {
191
- return !N && isActuallyWritableAtom(C) && (N = (...R) => {
192
- if (!A)
190
+ return !P && isActuallyWritableAtom(w) && (P = (...D) => {
191
+ if (!E)
193
192
  try {
194
- return B(C, ...R);
193
+ return A(w, ...D);
195
194
  } finally {
196
- x(), f();
195
+ h(), f();
197
196
  }
198
- }), N;
197
+ }), P;
199
198
  }
200
- }, $ = k.n;
199
+ }, M = y.n;
201
200
  try {
202
- const R = d(C, I, D);
203
- return setAtomStateValueOrPromise(C, R, h), isPromiseLike$2(R) && ((L = R.onCancel) == null || L.call(R, () => P == null ? void 0 : P.abort()), R.then(
201
+ const D = d(w, I, N);
202
+ return setAtomStateValueOrPromise(w, D, x), isPromiseLike$2(D) && ((L = D.onCancel) == null || L.call(D, () => R == null ? void 0 : R.abort()), D.then(
204
203
  T,
205
204
  T
206
- )), k;
207
- } catch (R) {
208
- return delete k.v, k.e = R, ++k.n, k;
205
+ )), y;
206
+ } catch (D) {
207
+ return delete y.v, y.e = D, ++y.n, y;
209
208
  } finally {
210
- A = !1, $ !== k.n && r.get(C) === $ && (r.set(C, k.n), a.add(C), (v = c.c) == null || v.call(c, C));
209
+ E = !1, M !== y.n && r.get(w) === M && (r.set(w, y.n), a.add(w), (v = c.c) == null || v.call(c, w));
211
210
  }
212
- }), y = m[4] || ((C) => {
213
- const L = [C];
211
+ }), k = m[4] || ((w) => {
212
+ const L = [w];
214
213
  for (; L.length; ) {
215
- const v = L.pop(), k = h(v);
216
- for (const A of getMountedOrPendingDependents(v, k, n)) {
217
- const T = h(A);
218
- r.set(A, T.n), L.push(A);
214
+ const v = L.pop(), y = x(v);
215
+ for (const E of getMountedOrPendingDependents(v, y, n)) {
216
+ const T = x(E);
217
+ r.set(E, T.n), L.push(E);
219
218
  }
220
219
  }
221
- }), B = m[5] || ((C, ...L) => {
220
+ }), A = m[5] || ((w, ...L) => {
222
221
  let v = !0;
223
- const k = (T) => returnAtomValue(b(T)), A = (T, ...I) => {
224
- var P;
225
- const N = h(T);
222
+ const y = (T) => returnAtomValue(b(T)), E = (T, ...I) => {
223
+ var R;
224
+ const P = x(T);
226
225
  try {
227
- if (isSelfAtom(C, T)) {
226
+ if (isSelfAtom(w, T)) {
228
227
  if (!hasInitialValue(T))
229
228
  throw new Error("atom not writable");
230
- const D = N.n, $ = I[0];
231
- setAtomStateValueOrPromise(T, $, h), E(T), D !== N.n && (a.add(T), (P = c.c) == null || P.call(c, T), y(T));
229
+ const N = P.n, M = I[0];
230
+ setAtomStateValueOrPromise(T, M, x), B(T), N !== P.n && (a.add(T), (R = c.c) == null || R.call(c, T), k(T));
232
231
  return;
233
232
  } else
234
- return B(T, ...I);
233
+ return A(T, ...I);
235
234
  } finally {
236
- v || (x(), f());
235
+ v || (h(), f());
237
236
  }
238
237
  };
239
238
  try {
240
- return p(C, k, A, ...L);
239
+ return p(w, y, E, ...L);
241
240
  } finally {
242
241
  v = !1;
243
242
  }
244
- }), E = m[6] || ((C) => {
243
+ }), B = m[6] || ((w) => {
245
244
  var L;
246
- const v = h(C), k = n.get(C);
247
- if (k && !isPendingPromise(v.v)) {
248
- for (const [A, T] of v.d)
249
- if (!k.d.has(A)) {
250
- const I = h(A);
251
- w(A).t.add(C), k.d.add(A), T !== I.n && (a.add(A), (L = c.c) == null || L.call(c, A), y(A));
245
+ const v = x(w), y = n.get(w);
246
+ if (y && !isPendingPromise(v.v)) {
247
+ for (const [E, T] of v.d)
248
+ if (!y.d.has(E)) {
249
+ const I = x(E);
250
+ C(E).t.add(w), y.d.add(E), T !== I.n && (a.add(E), (L = c.c) == null || L.call(c, E), k(E));
252
251
  }
253
- for (const A of k.d || [])
254
- if (!v.d.has(A)) {
255
- k.d.delete(A);
256
- const T = _(A);
257
- T == null || T.t.delete(C);
252
+ for (const E of y.d || [])
253
+ if (!v.d.has(E)) {
254
+ y.d.delete(E);
255
+ const T = j(E);
256
+ T == null || T.t.delete(w);
258
257
  }
259
258
  }
260
- }), w = m[7] || ((C) => {
259
+ }), C = m[7] || ((w) => {
261
260
  var L;
262
- const v = h(C);
263
- let k = n.get(C);
264
- if (!k) {
265
- b(C);
266
- for (const A of v.d.keys())
267
- w(A).t.add(C);
268
- if (k = {
261
+ const v = x(w);
262
+ let y = n.get(w);
263
+ if (!y) {
264
+ b(w);
265
+ for (const E of v.d.keys())
266
+ C(E).t.add(w);
267
+ if (y = {
269
268
  l: /* @__PURE__ */ new Set(),
270
269
  d: new Set(v.d.keys()),
271
270
  t: /* @__PURE__ */ new Set()
272
- }, n.set(C, k), (L = c.m) == null || L.call(c, C), isActuallyWritableAtom(C)) {
273
- const A = () => {
271
+ }, n.set(w, y), (L = c.m) == null || L.call(c, w), isActuallyWritableAtom(w)) {
272
+ const E = () => {
274
273
  let T = !0;
275
- const I = (...P) => {
274
+ const I = (...R) => {
276
275
  try {
277
- return B(C, ...P);
276
+ return A(w, ...R);
278
277
  } finally {
279
- T || (x(), f());
278
+ T || (h(), f());
280
279
  }
281
280
  };
282
281
  try {
283
- const P = g(C, I);
284
- P && (k.u = () => {
282
+ const R = g(w, I);
283
+ R && (y.u = () => {
285
284
  T = !0;
286
285
  try {
287
- P();
286
+ R();
288
287
  } finally {
289
288
  T = !1;
290
289
  }
@@ -293,27 +292,27 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
293
292
  T = !1;
294
293
  }
295
294
  };
296
- l.add(A);
295
+ l.add(E);
297
296
  }
298
297
  }
299
- return k;
300
- }), _ = m[8] || ((C) => {
298
+ return y;
299
+ }), j = m[8] || ((w) => {
301
300
  var L;
302
- const v = h(C);
303
- let k = n.get(C);
304
- if (k && !k.l.size && !Array.from(k.t).some((A) => {
301
+ const v = x(w);
302
+ let y = n.get(w);
303
+ if (y && !y.l.size && !Array.from(y.t).some((E) => {
305
304
  var T;
306
- return (T = n.get(A)) == null ? void 0 : T.d.has(C);
305
+ return (T = n.get(E)) == null ? void 0 : T.d.has(w);
307
306
  })) {
308
- k.u && i.add(k.u), k = void 0, n.delete(C), (L = c.u) == null || L.call(c, C);
309
- for (const A of v.d.keys()) {
310
- const T = _(A);
311
- T == null || T.t.delete(C);
307
+ y.u && i.add(y.u), y = void 0, n.delete(w), (L = c.u) == null || L.call(c, w);
308
+ for (const E of v.d.keys()) {
309
+ const T = j(E);
310
+ T == null || T.t.delete(w);
312
311
  }
313
312
  return;
314
313
  }
315
- return k;
316
- }), j = [
314
+ return y;
315
+ }), _ = [
317
316
  // store state
318
317
  o,
319
318
  n,
@@ -328,32 +327,32 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
328
327
  u,
329
328
  g,
330
329
  // building-block functions
331
- h,
332
- f,
333
330
  x,
331
+ f,
332
+ h,
334
333
  b,
335
- y,
334
+ k,
335
+ A,
336
336
  B,
337
- E,
338
- w,
339
- _
337
+ C,
338
+ j
340
339
  ], S = {
341
- get: (C) => returnAtomValue(b(C)),
342
- set: (C, ...L) => {
340
+ get: (w) => returnAtomValue(b(w)),
341
+ set: (w, ...L) => {
343
342
  try {
344
- return B(C, ...L);
343
+ return A(w, ...L);
345
344
  } finally {
346
- x(), f();
345
+ h(), f();
347
346
  }
348
347
  },
349
- sub: (C, L) => {
350
- const k = w(C).l;
351
- return k.add(L), f(), () => {
352
- k.delete(L), _(C), f();
348
+ sub: (w, L) => {
349
+ const y = C(w).l;
350
+ return y.add(L), f(), () => {
351
+ y.delete(L), j(w), f();
353
352
  };
354
353
  }
355
354
  };
356
- return Object.defineProperty(S, BUILDING_BLOCKS, { value: j }), S;
355
+ return Object.defineProperty(S, BUILDING_BLOCKS, { value: _ }), S;
357
356
  }, INTERNAL_buildStoreRev1 = buildStore;
358
357
  let keyCount = 0;
359
358
  function atom(o, n) {
@@ -389,36 +388,36 @@ function splitAtom(o, n) {
389
388
  if (p)
390
389
  return p;
391
390
  const u = d && r.get(d), g = [], m = [];
392
- return c.forEach((h, f) => {
393
- const x = f;
394
- m[f] = x;
395
- const b = u && u.atomList[u.keyList.indexOf(x)];
391
+ return c.forEach((x, f) => {
392
+ const h = f;
393
+ m[f] = h;
394
+ const b = u && u.atomList[u.keyList.indexOf(h)];
396
395
  if (b) {
397
396
  g[f] = b;
398
397
  return;
399
398
  }
400
- const y = (E) => {
401
- const w = E(l), _ = E(o), S = a(_, w == null ? void 0 : w.arr).keyList.indexOf(x);
402
- if (S < 0 || S >= _.length) {
403
- const C = c[a(c).keyList.indexOf(x)];
404
- if (C)
405
- return C;
399
+ const k = (B) => {
400
+ const C = B(l), j = B(o), S = a(j, C == null ? void 0 : C.arr).keyList.indexOf(h);
401
+ if (S < 0 || S >= j.length) {
402
+ const w = c[a(c).keyList.indexOf(h)];
403
+ if (w)
404
+ return w;
406
405
  throw new Error("splitAtom: index out of bounds for read");
407
406
  }
408
- return _[S];
409
- }, B = (E, w, _) => {
410
- const j = E(l), S = E(o), L = a(S, j == null ? void 0 : j.arr).keyList.indexOf(x);
407
+ return j[S];
408
+ }, A = (B, C, j) => {
409
+ const _ = B(l), S = B(o), L = a(S, _ == null ? void 0 : _.arr).keyList.indexOf(h);
411
410
  if (L < 0 || L >= S.length)
412
411
  throw new Error("splitAtom: index out of bounds for write");
413
- const v = isFunction(_) ? _(S[L]) : _;
414
- Object.is(S[L], v) || w(o, [
412
+ const v = isFunction(j) ? j(S[L]) : j;
413
+ Object.is(S[L], v) || C(o, [
415
414
  ...S.slice(0, L),
416
415
  v,
417
416
  ...S.slice(L + 1)
418
417
  ]);
419
418
  };
420
- g[f] = isWritable(o) ? atom(y, B) : atom(y);
421
- }), 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;
419
+ g[f] = isWritable(o) ? atom(k, A) : atom(k);
420
+ }), u && u.keyList.length === m.length && u.keyList.every((x, f) => x === m[f]) ? p = u : p = { arr: c, atomList: g, keyList: m }, r.set(c, p), p;
422
421
  }, l = atom((c) => {
423
422
  const d = c(l), p = c(o);
424
423
  return a(p, d == null ? void 0 : d.arr);
@@ -491,18 +490,18 @@ function createJSONStorage(o = () => {
491
490
  const i = {
492
491
  getItem: (p, u) => {
493
492
  var g, m;
494
- const h = (x) => {
495
- if (x = x || "", a !== x) {
493
+ const x = (h) => {
494
+ if (h = h || "", a !== h) {
496
495
  try {
497
- l = JSON.parse(x, n == null ? void 0 : n.reviver);
496
+ l = JSON.parse(h, n == null ? void 0 : n.reviver);
498
497
  } catch {
499
498
  return u;
500
499
  }
501
- a = x;
500
+ a = h;
502
501
  }
503
502
  return l;
504
503
  }, f = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
505
- return isPromiseLike$1(f) ? f.then(h) : h(f);
504
+ return isPromiseLike$1(f) ? f.then(x) : x(f);
506
505
  },
507
506
  setItem: (p, u) => {
508
507
  var g;
@@ -515,10 +514,10 @@ function createJSONStorage(o = () => {
515
514
  var u;
516
515
  return (u = o()) == null ? void 0 : u.removeItem(p);
517
516
  }
518
- }, c = (p) => (u, g, m) => p(u, (h) => {
517
+ }, c = (p) => (u, g, m) => p(u, (x) => {
519
518
  let f;
520
519
  try {
521
- f = JSON.parse(h || "");
520
+ f = JSON.parse(x || "");
522
521
  } catch {
523
522
  f = m;
524
523
  }
@@ -653,8 +652,6 @@ const activePanelAtom = atom$1("outline");
653
652
  activePanelAtom.debugLabel = "activePanelAtom";
654
653
  const showPredefinedBlockCategoryAtom = atom$1("");
655
654
  showPredefinedBlockCategoryAtom.debugLabel = "showPredefinedBlockCategoryAtom";
656
- const historyStatesAtom = atom$1({ undoCount: 0, redoCount: 0 });
657
- historyStatesAtom.debugLabel = "historyStatesAtom";
658
655
  const inlineEditingActiveAtom = atom$1("");
659
656
  inlineEditingActiveAtom.debugLabel = "inlineEditingActiveAtom";
660
657
  const draggingFlagAtom = atom$1(!1);
@@ -930,7 +927,22 @@ function requireUndomanager() {
930
927
  }(undomanager)), undomanager.exports;
931
928
  }
932
929
  var undomanagerExports = requireUndomanager();
933
- const UndoManager = /* @__PURE__ */ getDefaultExportFromCjs(undomanagerExports), MODIFIERS = [
930
+ const UndoManager = /* @__PURE__ */ getDefaultExportFromCjs(undomanagerExports), chaiBuilderPropsAtom = atom$1(null);
931
+ chaiBuilderPropsAtom.debugLabel = "chaiBuilderPropsAtom";
932
+ const chaiExternalDataAtom = atom$1({});
933
+ chaiExternalDataAtom.debugLabel = "chaiExternalDataAtom";
934
+ const chaiRjsfFieldsAtom = atom$1({});
935
+ chaiRjsfFieldsAtom.debugLabel = "chaiRjsfFieldsAtom";
936
+ const chaiRjsfWidgetsAtom = atom$1({});
937
+ chaiRjsfWidgetsAtom.debugLabel = "chaiRjsfWidgetsAtom";
938
+ const chaiRjsfTemplatesAtom = atom$1({});
939
+ chaiRjsfTemplatesAtom.debugLabel = "chaiRjsfTemplatesAtom";
940
+ const chaiPageExternalDataAtom = atom$1({});
941
+ chaiPageExternalDataAtom.debugLabel = "chaiPageExternalDataAtom";
942
+ const usePageExternalData = () => useAtomValue$1(chaiPageExternalDataAtom), useBuilderProp = (o, n = void 0) => {
943
+ const r = useAtomValue$1(chaiBuilderPropsAtom);
944
+ return get(r, o, n);
945
+ }, MODIFIERS = [
934
946
  "hover",
935
947
  "focus",
936
948
  "focus-within",
@@ -1003,21 +1015,12 @@ const useBrandingOptions = () => {
1003
1015
  blocks: a
1004
1016
  };
1005
1017
  }, [o, n, r]);
1006
- }, chaiBuilderPropsAtom = atom$1(null);
1007
- chaiBuilderPropsAtom.debugLabel = "chaiBuilderPropsAtom";
1008
- const chaiExternalDataAtom = atom$1({});
1009
- chaiExternalDataAtom.debugLabel = "chaiExternalDataAtom";
1010
- const chaiRjsfFieldsAtom = atom$1({});
1011
- chaiRjsfFieldsAtom.debugLabel = "chaiRjsfFieldsAtom";
1012
- const chaiRjsfWidgetsAtom = atom$1({});
1013
- chaiRjsfWidgetsAtom.debugLabel = "chaiRjsfWidgetsAtom";
1014
- const chaiRjsfTemplatesAtom = atom$1({});
1015
- chaiRjsfTemplatesAtom.debugLabel = "chaiRjsfTemplatesAtom";
1016
- const chaiPageExternalDataAtom = atom$1({});
1017
- chaiPageExternalDataAtom.debugLabel = "chaiPageExternalDataAtom";
1018
- const usePageExternalData = () => useAtomValue$1(chaiPageExternalDataAtom), useBuilderProp = (o, n = void 0) => {
1019
- const r = useAtomValue$1(chaiBuilderPropsAtom);
1020
- return get(r, o, n);
1018
+ }, usePermissions = () => {
1019
+ const o = useBuilderProp("permissions", void 0);
1020
+ return { hasPermission: useCallback(
1021
+ (r) => o ? o.includes(r) : !0,
1022
+ [o]
1023
+ ) };
1021
1024
  }, getDefaultThemeValues = (o = defaultThemeOptions) => {
1022
1025
  const n = {};
1023
1026
  return o.fontFamily && (n.fontFamily = Object.entries(o.fontFamily).reduce(
@@ -1044,15 +1047,17 @@ const usePageExternalData = () => useAtomValue$1(chaiPageExternalDataAtom), useB
1044
1047
  }, rightPanelAtom = atom$1("block"), useRightPanel = () => useAtom$1(rightPanelAtom), builderSaveStateAtom = atom$1("SAVED");
1045
1048
  builderSaveStateAtom.debugLabel = "builderSaveStateAtom";
1046
1049
  const useSavePage = () => {
1047
- const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (d) => {
1048
- }), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme();
1050
+ const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (p) => {
1051
+ }), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions();
1049
1052
  return { savePage: useThrottledCallback(
1050
- async (d = !1) => {
1053
+ async (p = !1) => {
1054
+ if (!c("save_page"))
1055
+ return;
1051
1056
  n("SAVING"), a("SAVING");
1052
- const p = l();
1057
+ const u = l();
1053
1058
  return await r({
1054
- autoSave: d,
1055
- blocks: p.blocks,
1059
+ autoSave: p,
1060
+ blocks: u.blocks,
1056
1061
  theme: i
1057
1062
  }), setTimeout(() => {
1058
1063
  n("SAVED"), a("SAVED");
@@ -1152,15 +1157,15 @@ const useSelectedBlocksDisplayChild = () => ({
1152
1157
  if (!p || !p._parent) return;
1153
1158
  const u = p._parent, g = r.filter((m) => m._parent === u);
1154
1159
  if (g.length === 2) {
1155
- const m = g.find((h) => h._id !== d);
1160
+ const m = g.find((x) => x._id !== d);
1156
1161
  if (m && m._type === "Text") {
1157
- const h = r.find((f) => f._id === u);
1158
- h && "content" in h && (r = r.map((f) => {
1162
+ const x = r.find((f) => f._id === u);
1163
+ x && "content" in x && (r = r.map((f) => {
1159
1164
  if (f._id === u) {
1160
- const x = { ...f, content: m.content };
1165
+ const h = { ...f, content: m.content };
1161
1166
  return Object.keys(m).forEach((b) => {
1162
- b.startsWith("content-") && (x[b] = m[b]);
1163
- }), x;
1167
+ b.startsWith("content-") && (h[b] = m[b]);
1168
+ }), h;
1164
1169
  }
1165
1170
  return f;
1166
1171
  }), a.push(m._id));
@@ -1170,14 +1175,15 @@ const useSelectedBlocksDisplayChild = () => ({
1170
1175
  const l = [...n, ...a], i = [], c = filter(r, (d) => includes(l, d._id) || includes(l, d._parent) ? (i.push(d._id), !1) : !0);
1171
1176
  return isEmpty(i) ? c : removeNestedBlocks(c, i);
1172
1177
  }, useRemoveBlocks = () => {
1173
- const [o] = useBlocksStore(), [n, r] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions();
1178
+ const [o] = useBlocksStore(), [n, r] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions(), { hasPermission: l } = usePermissions();
1174
1179
  return useCallback(
1175
- (l) => {
1176
- var c;
1177
- const i = ((c = find(o, { _id: l[0] })) == null ? void 0 : c._parent) || null;
1178
- a(removeNestedBlocks(o, l)), setTimeout(() => r(i ? [i] : []), 200);
1180
+ (i) => {
1181
+ var d;
1182
+ if (!l(PERMISSIONS.DELETE_BLOCK)) return;
1183
+ const c = ((d = find(o, { _id: i[0] })) == null ? void 0 : d._parent) || null;
1184
+ a(removeNestedBlocks(o, i)), setTimeout(() => r(c ? [c] : []), 200);
1179
1185
  },
1180
- [o, r, n]
1186
+ [o, r, n, l]
1181
1187
  );
1182
1188
  }, builderStore = getDefaultStore$1(), writeAtomValue = atom$1(
1183
1189
  null,
@@ -1227,20 +1233,20 @@ function insertBlocksAtPosition(o, n, r, a) {
1227
1233
  if (r) {
1228
1234
  const u = o.find((g) => g._id === r);
1229
1235
  if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
1230
- const h = {
1236
+ const x = {
1231
1237
  _id: generateUUID(),
1232
1238
  _parent: r,
1233
1239
  _type: "Text",
1234
1240
  content: u.content
1235
1241
  };
1236
1242
  Object.keys(u).forEach((f) => {
1237
- f.startsWith("content-") && (h[f] = u[f]);
1238
- }), l.unshift(h), i = i.map((f) => {
1243
+ f.startsWith("content-") && (x[f] = u[f]);
1244
+ }), l.unshift(x), i = i.map((f) => {
1239
1245
  if (f._id === r) {
1240
- const x = { ...f, content: "" };
1241
- return Object.keys(x).forEach((b) => {
1242
- b.startsWith("content-") && (x[b] = "");
1243
- }), x;
1246
+ const h = { ...f, content: "" };
1247
+ return Object.keys(h).forEach((b) => {
1248
+ b.startsWith("content-") && (h[b] = "");
1249
+ }), h;
1244
1250
  }
1245
1251
  return f;
1246
1252
  });
@@ -1390,65 +1396,65 @@ const useBlocksStoreManager = () => {
1390
1396
  updateBlocksProps: c
1391
1397
  } = useBlocksStoreManager();
1392
1398
  return {
1393
- moveBlocks: (x, b, y) => {
1394
- const B = map(x, (w) => {
1395
- const j = n.find((L) => L._id === w)._parent || null, C = n.filter((L) => j ? L._parent === j : !L._parent).map((L) => L._id).indexOf(w);
1396
- return { _id: w, oldParent: j, oldPosition: C };
1397
- }), E = B.find(({ _id: w }) => w === x[0]);
1398
- E && E.oldParent === b && E.oldPosition === y || (i(x, b, y), o({
1399
- undo: () => each(B, ({ _id: w, oldParent: _, oldPosition: j }) => {
1400
- i([w], _, j);
1399
+ moveBlocks: (h, b, k) => {
1400
+ const A = map(h, (C) => {
1401
+ const _ = n.find((L) => L._id === C)._parent || null, w = n.filter((L) => _ ? L._parent === _ : !L._parent).map((L) => L._id).indexOf(C);
1402
+ return { _id: C, oldParent: _, oldPosition: w };
1403
+ }), B = A.find(({ _id: C }) => C === h[0]);
1404
+ B && B.oldParent === b && B.oldPosition === k || (i(h, b, k), o({
1405
+ undo: () => each(A, ({ _id: C, oldParent: j, oldPosition: _ }) => {
1406
+ i([C], j, _);
1401
1407
  }),
1402
- redo: () => i(x, b, y)
1408
+ redo: () => i(h, b, k)
1403
1409
  }));
1404
1410
  },
1405
- addBlocks: (x, b, y) => {
1406
- a(x, b, y), o({
1407
- undo: () => l(map(x, "_id")),
1408
- redo: () => a(x, b, y)
1411
+ addBlocks: (h, b, k) => {
1412
+ a(h, b, k), o({
1413
+ undo: () => l(map(h, "_id")),
1414
+ redo: () => a(h, b, k)
1409
1415
  });
1410
1416
  },
1411
- removeBlocks: (x) => {
1412
- var E;
1413
- const b = (E = first(x)) == null ? void 0 : E._parent, B = n.filter((w) => b ? w._parent === b : !w._parent).indexOf(first(x));
1414
- l(map(x, "_id")), o({
1415
- undo: () => a(x, b, B),
1416
- redo: () => l(map(x, "_id"))
1417
+ removeBlocks: (h) => {
1418
+ var B;
1419
+ const b = (B = first(h)) == null ? void 0 : B._parent, A = n.filter((C) => b ? C._parent === b : !C._parent).indexOf(first(h));
1420
+ l(map(h, "_id")), o({
1421
+ undo: () => a(h, b, A),
1422
+ redo: () => l(map(h, "_id"))
1417
1423
  });
1418
1424
  },
1419
- updateBlocks: (x, b, y) => {
1420
- let B = [];
1421
- if (y)
1422
- B = map(x, (E) => ({ _id: E, ...y }));
1425
+ updateBlocks: (h, b, k) => {
1426
+ let A = [];
1427
+ if (k)
1428
+ A = map(h, (B) => ({ _id: B, ...k }));
1423
1429
  else {
1424
- const E = keys(b);
1425
- B = map(x, (w) => {
1426
- const _ = n.find((S) => S._id === w), j = { _id: w };
1427
- return each(E, (S) => j[S] = _[S]), j;
1430
+ const B = keys(b);
1431
+ A = map(h, (C) => {
1432
+ const j = n.find((S) => S._id === C), _ = { _id: C };
1433
+ return each(B, (S) => _[S] = j[S]), _;
1428
1434
  });
1429
1435
  }
1430
- c(map(x, (E) => ({ _id: E, ...b }))), o({
1431
- undo: () => c(B),
1432
- redo: () => c(map(x, (E) => ({ _id: E, ...b })))
1436
+ c(map(h, (B) => ({ _id: B, ...b }))), o({
1437
+ undo: () => c(A),
1438
+ redo: () => c(map(h, (B) => ({ _id: B, ...b })))
1433
1439
  });
1434
1440
  },
1435
- updateBlocksRuntime: (x, b) => {
1436
- c(map(x, (y) => ({ _id: y, ...b })));
1441
+ updateBlocksRuntime: (h, b) => {
1442
+ c(map(h, (k) => ({ _id: k, ...b })));
1437
1443
  },
1438
- setNewBlocks: (x) => {
1439
- r(x), o({
1444
+ setNewBlocks: (h) => {
1445
+ r(h), o({
1440
1446
  undo: () => r(n),
1441
- redo: () => r(x)
1447
+ redo: () => r(h)
1442
1448
  });
1443
1449
  },
1444
- updateMultipleBlocksProps: (x) => {
1450
+ updateMultipleBlocksProps: (h) => {
1445
1451
  let b = [];
1446
- b = map(x, (y) => {
1447
- const B = keys(y), E = n.find((_) => _._id === y._id), w = {};
1448
- return each(B, (_) => w[_] = E[_]), w;
1449
- }), c(x), o({
1452
+ b = map(h, (k) => {
1453
+ const A = keys(k), B = n.find((j) => j._id === k._id), C = {};
1454
+ return each(A, (j) => C[j] = B[j]), C;
1455
+ }), c(h), o({
1450
1456
  undo: () => c(b),
1451
- redo: () => c(x)
1457
+ redo: () => c(h)
1452
1458
  });
1453
1459
  }
1454
1460
  };
@@ -1484,17 +1490,17 @@ import.meta.vitest && describe("canDropBlock Function", () => {
1484
1490
  const useAddBlock = () => {
1485
1491
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
1486
1492
  (i, c, d) => {
1487
- var h;
1493
+ var x;
1488
1494
  for (let f = 0; f < i.length; f++) {
1489
- const { _id: x } = i[f];
1495
+ const { _id: h } = i[f];
1490
1496
  i[f]._id = generateUUID();
1491
- const b = filter(i, { _parent: x });
1492
- for (let y = 0; y < b.length; y++)
1493
- b[y]._parent = i[f]._id;
1497
+ const b = filter(i, { _parent: h });
1498
+ for (let k = 0; k < b.length; k++)
1499
+ b[k]._parent = i[f]._id;
1494
1500
  }
1495
1501
  const p = first(i);
1496
1502
  let u, g;
1497
- return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(h = first(i)) == null ? void 0 : h._id]), first(i);
1503
+ return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(x = first(i)) == null ? void 0 : x._id]), first(i);
1498
1504
  },
1499
1505
  [r, o, n]
1500
1506
  );
@@ -1511,8 +1517,8 @@ const useAddBlock = () => {
1511
1517
  ...has(i, "_name") && { _name: i._name },
1512
1518
  ...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
1513
1519
  };
1514
- let m, h;
1515
- return c && (m = find(o, { _id: c }), g._parent = c, h = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, h = m._parent), r([g], h, d), n([g._id]), g;
1520
+ let m, x;
1521
+ return c && (m = find(o, { _id: c }), g._parent = c, x = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, x = m._parent), r([g], x, d), n([g._id]), g;
1516
1522
  },
1517
1523
  [r, a, o, n]
1518
1524
  ), addPredefinedBlock: a };
@@ -2958,41 +2964,41 @@ const getBlockWithChildren = (o, n) => {
2958
2964
  return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
2959
2965
  })
2960
2966
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
2961
- 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) => {
2962
- const x = cloneDeep(f.find((b) => b._id === h));
2963
- for (const b in x) {
2964
- const y = x[b];
2965
- if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
2966
- const { baseClasses: B, classes: E } = getSplitChaiClasses(y);
2967
- x[b] = compact(flattenDeep([B, E])).join(" ");
2967
+ 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 = (x, f) => {
2968
+ const h = cloneDeep(f.find((b) => b._id === x));
2969
+ for (const b in h) {
2970
+ const k = h[b];
2971
+ if (typeof k == "string" && startsWith(k, STYLES_KEY)) {
2972
+ const { baseClasses: A, classes: B } = getSplitChaiClasses(k);
2973
+ h[b] = compact(flattenDeep([A, B])).join(" ");
2968
2974
  } else
2969
- b !== "_id" && delete x[b];
2975
+ b !== "_id" && delete h[b];
2970
2976
  }
2971
- return x;
2977
+ return h;
2972
2978
  };
2973
2979
  return {
2974
2980
  askAi: useCallback(
2975
- async (h, f, x, b) => {
2981
+ async (x, f, h, b) => {
2976
2982
  if (l) {
2977
2983
  n(!0), a(null);
2978
2984
  try {
2979
- const y = p === u ? "" : p, B = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [m(f, d)], E = await l(h, addLangToPrompt(x, g, h), B, y), { blocks: w, error: _ } = E;
2980
- if (_) {
2981
- a(_);
2985
+ const k = p === u ? "" : p, A = x === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [m(f, d)], B = await l(x, addLangToPrompt(h, g, x), A, k), { blocks: C, error: j } = B;
2986
+ if (j) {
2987
+ a(j);
2982
2988
  return;
2983
2989
  }
2984
- if (h === "styles") {
2985
- const j = w.map((S) => {
2986
- for (const C in S)
2987
- C !== "_id" && (S[C] = `${STYLES_KEY},${S[C]}`);
2990
+ if (x === "styles") {
2991
+ const _ = C.map((S) => {
2992
+ for (const w in S)
2993
+ w !== "_id" && (S[w] = `${STYLES_KEY},${S[w]}`);
2988
2994
  return S;
2989
2995
  });
2990
- c(j);
2996
+ c(_);
2991
2997
  } else
2992
- i(w);
2993
- b && b(E);
2994
- } catch (y) {
2995
- a(y);
2998
+ i(C);
2999
+ b && b(B);
3000
+ } catch (k) {
3001
+ a(k);
2996
3002
  } finally {
2997
3003
  n(!1), b && b();
2998
3004
  }
@@ -3083,9 +3089,9 @@ const useBlockHighlight = () => {
3083
3089
  d();
3084
3090
  }, []), { data: l, isLoading: o, refetch: d, error: r };
3085
3091
  }, useBuilderReset = () => {
3086
- const o = useSetAtom$1(historyStatesAtom), { clear: n } = useUndoManager(), [, r] = useSelectedBlockIds(), { clearHighlight: a } = useBlockHighlight(), [, l] = useSelectedStylingBlocks(), [, i] = useAtom(aiAssistantActiveAtom), { reset: c } = usePartailBlocksStore();
3092
+ const { clear: o } = useUndoManager(), [, n] = useSelectedBlockIds(), { clearHighlight: r } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom(aiAssistantActiveAtom), { reset: i } = usePartailBlocksStore(), { setSaveState: c } = useSavePage();
3087
3093
  return () => {
3088
- r([]), l([]), a(), n(), i(!1), o({ undoCount: 0, redoCount: 0 }), c();
3094
+ n([]), a([]), r(), o(), l(!1), i(), c("SAVED");
3089
3095
  };
3090
3096
  }, canvasZoomAtom = atomWithStorage("canvasZoom", 100), useCanvasZoom = () => useAtom$1(canvasZoomAtom), codeEditorAtom = atom$1(null), useCodeEditor = () => useAtom$1(codeEditorAtom), cutBlockIdsAtom = atom$1([]), useCutBlockIds = () => {
3091
3097
  const [o, n] = useAtom$1(cutBlockIdsAtom), r = useSetAtom$1(copiedBlockIdsAtom), a = useCallback(
@@ -3131,11 +3137,11 @@ const useBlockHighlight = () => {
3131
3137
  (a, l = null) => {
3132
3138
  const i = [];
3133
3139
  each(a, (c) => {
3134
- const d = o.find((h) => h._id === c);
3140
+ const d = o.find((x) => x._id === c);
3135
3141
  l ? l === "root" && (l = null) : l = d._parent;
3136
3142
  const g = filter(
3137
3143
  o,
3138
- (h) => isString(l) ? h._parent === l : !h._parent
3144
+ (x) => isString(l) ? x._parent === l : !x._parent
3139
3145
  ).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
3140
3146
  r(m, l, g), i.push(get(m, "0._id", ""));
3141
3147
  }), n(i);
@@ -3231,12 +3237,12 @@ const useBlockHighlight = () => {
3231
3237
  const d = o(c), p = a;
3232
3238
  let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
3233
3239
  return each(p, (m) => {
3234
- const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
3240
+ const x = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${x}(?=\\s|$)`, "g");
3235
3241
  u = u.replace(f, " ").replace(/\s+/g, " ").trim();
3236
- const x = first(m.split(":"));
3237
- includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
3242
+ const h = first(m.split(":"));
3243
+ includes(["2xl", "xl", "lg", "md", "sm"], h) && p.push(m.split(":").pop().trim());
3238
3244
  }), each(p, (m) => {
3239
- const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
3245
+ const x = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${x}(?=\\s|$)`, "g");
3240
3246
  g = g.replace(f, " ").replace(/\s+/g, " ").trim();
3241
3247
  }), {
3242
3248
  ids: [d._id],
@@ -3323,136 +3329,53 @@ wrapperBlockAtom.debugLabel = "wrapperBlockAtom";
3323
3329
  const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), layoutVariantAtom = atomWithStorage("_layout_variant_mode", "DUAL_SIDE_PANEL"), useLayoutVariant = () => {
3324
3330
  const [o, n] = useAtom$1(layoutVariantAtom), r = useBuilderProp("layoutVariant", "DUAL_SIDE_PANEL");
3325
3331
  return [o || r, n];
3326
- }, draggedBlockAtom = atom$1(null), dropTargetBlockIdAtom = atom$1(null);
3327
- class PubSub {
3328
- constructor() {
3329
- V(this, "subscribers", /* @__PURE__ */ new Map());
3330
- }
3331
- subscribe(n, r) {
3332
- return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
3333
- const a = this.subscribers.get(n);
3334
- a && (a.delete(r), a.size === 0 && this.subscribers.delete(n));
3335
- };
3336
- }
3337
- publish(n, r) {
3338
- const a = this.subscribers.get(n);
3339
- a && a.forEach((l) => l(r));
3340
- }
3341
- }
3342
- const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
3343
- const { t: r } = useTranslation(), [a] = useBlocksStore(), l = get(o, "_id"), i = get(o, "_parent"), c = filter(a, (g) => i ? get(g, "_parent") === i : !get(g, "_parent")), d = canAddChildBlock(get(o, "_type", "")), p = findIndex(c, { _id: l }), u = (g) => {
3344
- if (g === "CHILD")
3345
- pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
3346
- else {
3347
- const m = { _id: i || "", position: c == null ? void 0 : c.length };
3348
- g === "BEFORE" ? m.position = Math.max(p, 0) : g === "AFTER" && (m.position = p + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, m);
3349
- }
3350
- };
3351
- return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
3352
- /* @__PURE__ */ jsx(DropdownMenuTrigger, { children: n }),
3353
- /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-500 bg-blue-500 text-white shadow-2xl", children: [
3354
- d && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => u("CHILD"), children: r("Add inside") }),
3355
- /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => u("BEFORE"), children: r("Add before") }),
3356
- /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => u("AFTER"), children: r("Add after") })
3357
- ] })
3358
- ] });
3359
3332
  };
3360
- function getOrientation(o) {
3361
- const n = window.getComputedStyle(o), r = n.display;
3362
- if (r === "flex" || r === "inline-flex") {
3363
- const a = n.flexDirection;
3364
- return a === "column" || a === "column-reverse" ? "vertical" : "horizontal";
3365
- } else if (r === "grid") {
3366
- const a = n.gridAutoFlow, l = n.gridTemplateColumns;
3367
- return a.includes("column") || l && l !== "none" && l !== "" && !l.includes("calc") && // Handle calc expressions
3368
- l.split(" ").length <= 1 ? "vertical" : "horizontal";
3369
- } else if (r === "block" || r === "inline-block")
3370
- return "vertical";
3371
- return "horizontal";
3372
- }
3373
- if (import.meta.vitest) {
3374
- const { test: o, expect: n } = import.meta.vitest;
3375
- o("getOrientation default div should be vertical", () => {
3376
- n(getOrientation(document.createElement("div"))).toBe("vertical");
3377
- }), o("getOrientation flex with default direction should be horizontal", () => {
3378
- const r = document.createElement("div");
3379
- r.style.display = "flex", n(getOrientation(r)).toBe("horizontal");
3380
- }), o("getOrientation inline-flex with default direction should be horizontal", () => {
3381
- const r = document.createElement("div");
3382
- r.style.display = "inline-flex", n(getOrientation(r)).toBe("horizontal");
3383
- }), o("getOrientation flex with row direction should be horizontal", () => {
3384
- const r = document.createElement("div");
3385
- r.style.display = "flex", r.style.flexDirection = "row", n(getOrientation(r)).toBe("horizontal");
3386
- }), o("getOrientation flex with row-reverse direction should be horizontal", () => {
3387
- const r = document.createElement("div");
3388
- r.style.display = "flex", r.style.flexDirection = "row-reverse", n(getOrientation(r)).toBe("horizontal");
3389
- }), o("getOrientation flex with column direction should be vertical", () => {
3390
- const r = document.createElement("div");
3391
- r.style.display = "flex", r.style.flexDirection = "column", n(getOrientation(r)).toBe("vertical");
3392
- }), o("getOrientation flex with column-reverse direction should be vertical", () => {
3393
- const r = document.createElement("div");
3394
- r.style.display = "flex", r.style.flexDirection = "column-reverse", n(getOrientation(r)).toBe("vertical");
3395
- }), o("getOrientation grid with default settings should be horizontal", () => {
3396
- const r = document.createElement("div");
3397
- r.style.display = "grid", n(getOrientation(r)).toBe("horizontal");
3398
- }), o("getOrientation grid with row auto-flow should be horizontal", () => {
3399
- const r = document.createElement("div");
3400
- r.style.display = "grid", r.style.gridAutoFlow = "row", n(getOrientation(r)).toBe("horizontal");
3401
- }), o("getOrientation grid with column auto-flow should be vertical", () => {
3402
- const r = document.createElement("div");
3403
- r.style.display = "grid", r.style.gridAutoFlow = "column", n(getOrientation(r)).toBe("vertical");
3404
- }), o("getOrientation grid with dense column auto-flow should be vertical", () => {
3405
- const r = document.createElement("div");
3406
- r.style.display = "grid", r.style.gridAutoFlow = "column dense", n(getOrientation(r)).toBe("vertical");
3407
- }), o("getOrientation grid with single column should be vertical", () => {
3408
- const r = document.createElement("div");
3409
- r.style.display = "grid", r.style.gridTemplateColumns = "1fr", n(getOrientation(r)).toBe("vertical");
3410
- }), o("getOrientation grid with multiple columns should be horizontal", () => {
3411
- const r = document.createElement("div");
3412
- r.style.display = "grid", r.style.gridTemplateColumns = "1fr 1fr", n(getOrientation(r)).toBe("horizontal");
3413
- }), o("getOrientation block should be vertical", () => {
3414
- const r = document.createElement("div");
3415
- r.style.display = "block", n(getOrientation(r)).toBe("vertical");
3416
- }), o("getOrientation inline-block should be vertical", () => {
3417
- const r = document.createElement("div");
3418
- r.style.display = "inline-block", n(getOrientation(r)).toBe("vertical");
3419
- }), o("getOrientation inline should be horizontal", () => {
3420
- const r = document.createElement("div");
3421
- r.style.display = "inline", n(getOrientation(r)).toBe("horizontal");
3422
- }), o("getOrientation table should be horizontal", () => {
3423
- const r = document.createElement("div");
3424
- r.style.display = "table", n(getOrientation(r)).toBe("horizontal");
3425
- });
3333
+ function getOrientation(o, n = null) {
3334
+ const r = window.getComputedStyle(o), a = n ? window.getComputedStyle(n) : null, l = r.display, i = a ? a.display : null;
3335
+ if (l === "flex" || l === "inline-flex") {
3336
+ const c = r.flexDirection;
3337
+ return c === "column" || c === "column-reverse" ? "vertical" : "horizontal";
3338
+ } else if (l === "grid") {
3339
+ const c = r.gridAutoFlow, d = r.gridTemplateColumns;
3340
+ return c.includes("column") || d && d !== "none" && d !== "" && !d.includes("calc") && // Handle calc expressions
3341
+ d.split(" ").length <= 1 ? "vertical" : "horizontal";
3342
+ } else if (i === "inline-block" || i === "inline")
3343
+ return "horizontal";
3344
+ return "vertical";
3426
3345
  }
3427
3346
  const CONTROLS = [
3428
3347
  { ControlIcon: PinTopIcon, dir: "VERTICAL", key: "UP" },
3429
3348
  { ControlIcon: PinBottomIcon, dir: "VERTICAL", key: "DOWN" },
3430
3349
  { ControlIcon: PinLeftIcon, dir: "HORIZONTAL", key: "LEFT" },
3431
3350
  { ControlIcon: PinRightIcon, dir: "HORIZONTAL", key: "RIGHT" }
3432
- ], getParentBlockOrientation = (o, n) => {
3351
+ ], getParentBlockOrientation = (o, n, r) => {
3433
3352
  try {
3434
- if (!o || !n) return "VERTICAL";
3435
- const r = `[data-block-id='${o}']`, a = n == null ? void 0 : n.querySelector(r);
3436
- return a ? getOrientation(a).toUpperCase() : "VERTICAL";
3353
+ if (!o || !r) return "VERTICAL";
3354
+ const a = `[data-block-id='${o}']`, l = r == null ? void 0 : r.querySelector(a);
3355
+ if (l) {
3356
+ const i = r == null ? void 0 : r.querySelector(`[data-block-id='${n}']`);
3357
+ return getOrientation(l, i).toUpperCase();
3358
+ }
3359
+ return "VERTICAL";
3437
3360
  } catch {
3438
3361
  return "VERTICAL";
3439
3362
  }
3440
3363
  }, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
3441
- const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, a), f = useCallback(
3442
- (x) => {
3443
- isDisabledControl(g, m, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
3364
+ const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (h) => c ? get(h, "_parent") === c : !get(h, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), x = getParentBlockOrientation(c, i, a), f = useCallback(
3365
+ (h) => {
3366
+ isDisabledControl(g, m, h) || p || (h === "UP" || h === "LEFT" ? l([i], c || null, u - 1) : (h === "DOWN" || h === "RIGHT") && l([i], c || null, u + 2), n());
3444
3367
  },
3445
3368
  [g, m, p, u, i, c, n]
3446
3369
  );
3447
3370
  return useHotkeys(
3448
3371
  "shift+up, shift+down, shift+left, shift+right",
3449
- ({ key: x }) => {
3372
+ ({ key: h }) => {
3450
3373
  var b;
3451
- f((b = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : b.toUpperCase());
3374
+ f((b = h == null ? void 0 : h.replace("Arrow", "")) == null ? void 0 : b.toUpperCase());
3452
3375
  },
3453
3376
  { document: a == null ? void 0 : a.contentDocument },
3454
3377
  [f]
3455
- ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation: h };
3378
+ ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation: x };
3456
3379
  }, BlockController = ({ block: o, updateFloatingBar: n }) => {
3457
3380
  const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
3458
3381
  o,
@@ -3470,7 +3393,40 @@ const CONTROLS = [
3470
3393
  u
3471
3394
  );
3472
3395
  }) });
3473
- }, BlockActionLabel = ({ block: o, label: n }) => {
3396
+ };
3397
+ class PubSub {
3398
+ constructor() {
3399
+ V(this, "subscribers", /* @__PURE__ */ new Map());
3400
+ }
3401
+ subscribe(n, r) {
3402
+ return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
3403
+ const a = this.subscribers.get(n);
3404
+ a && (a.delete(r), a.size === 0 && this.subscribers.delete(n));
3405
+ };
3406
+ }
3407
+ publish(n, r) {
3408
+ const a = this.subscribers.get(n);
3409
+ a && a.forEach((l) => l(r));
3410
+ }
3411
+ }
3412
+ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
3413
+ const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (m) => c ? get(m, "_parent") === c : !get(m, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (m) => {
3414
+ if (m === "CHILD")
3415
+ pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
3416
+ else {
3417
+ const x = { _id: c || "", position: d == null ? void 0 : d.length };
3418
+ m === "BEFORE" ? x.position = Math.max(u, 0) : m === "AFTER" && (x.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, x);
3419
+ }
3420
+ };
3421
+ return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
3422
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { children: n }),
3423
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-500 bg-blue-500 text-white shadow-2xl", children: [
3424
+ p && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("CHILD"), children: r("Add inside") }),
3425
+ /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("BEFORE"), children: r("Add before") }),
3426
+ /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("AFTER"), children: r("Add after") })
3427
+ ] })
3428
+ ] }) : null;
3429
+ }, draggedBlockAtom = atom$1(null), dropTargetBlockIdAtom = atom$1(null), BlockActionLabel = ({ block: o, label: n }) => {
3474
3430
  const [, r] = useSelectedBlockIds(), [, a] = useHighlightBlockId(), [, l] = useAtom$1(draggedBlockAtom), i = useFeature("dnd");
3475
3431
  return /* @__PURE__ */ jsxs(
3476
3432
  "div",
@@ -3489,46 +3445,46 @@ const CONTROLS = [
3489
3445
  }
3490
3446
  );
3491
3447
  }, BlockFloatingSelector = ({ selectedBlockElement: o, block: n }) => {
3492
- const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), [d] = useAtom$1(inlineEditingActiveAtom), { document: p } = useFrame(), { floatingStyles: u, refs: g, update: m } = useFloating({
3448
+ const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: m, update: x } = useFloating({
3493
3449
  placement: "top-start",
3494
3450
  middleware: [shift(), flip()],
3495
3451
  elements: {
3496
3452
  reference: o
3497
3453
  }
3498
3454
  });
3499
- useResizeObserver(o, () => m(), o !== null), useResizeObserver(p == null ? void 0 : p.body, () => m(), (p == null ? void 0 : p.body) !== null);
3500
- const h = get(n, "_parent", null), f = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
3501
- return !o || !n || d ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
3455
+ useResizeObserver(o, () => x(), o !== null), useResizeObserver(u == null ? void 0 : u.body, () => x(), (u == null ? void 0 : u.body) !== null);
3456
+ const f = get(n, "_parent", null), h = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
3457
+ return !o || !n || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
3502
3458
  "div",
3503
3459
  {
3504
3460
  role: "button",
3505
3461
  tabIndex: 0,
3506
- ref: g.setFloating,
3507
- style: u,
3508
- onClick: (x) => {
3509
- x.stopPropagation(), x.preventDefault();
3462
+ ref: m.setFloating,
3463
+ style: g,
3464
+ onClick: (b) => {
3465
+ b.stopPropagation(), b.preventDefault();
3510
3466
  },
3511
- onMouseEnter: (x) => {
3512
- x.stopPropagation(), i(null);
3467
+ onMouseEnter: (b) => {
3468
+ b.stopPropagation(), i(null);
3513
3469
  },
3514
- onKeyDown: (x) => x.stopPropagation(),
3470
+ onKeyDown: (b) => b.stopPropagation(),
3515
3471
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3516
3472
  children: [
3517
- h && /* @__PURE__ */ jsx(
3473
+ f && /* @__PURE__ */ jsx(
3518
3474
  ArrowUpIcon,
3519
3475
  {
3520
3476
  className: "hover:scale-105",
3521
3477
  onClick: () => {
3522
- c([]), l([h]);
3478
+ c([]), l([f]);
3523
3479
  }
3524
3480
  }
3525
3481
  ),
3526
- /* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: n }),
3482
+ /* @__PURE__ */ jsx(BlockActionLabel, { label: h, block: n }),
3527
3483
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
3528
3484
  /* @__PURE__ */ jsx(AddBlockDropdown, { block: n, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
3529
- canDuplicateBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([n == null ? void 0 : n._id]) }) : null,
3530
- canDeleteBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null,
3531
- /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar: m })
3485
+ canDuplicateBlock(get(n, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([n == null ? void 0 : n._id]) }) : null,
3486
+ canDeleteBlock(get(n, "_type", "")) && d(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null,
3487
+ d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar: x })
3532
3488
  ] })
3533
3489
  ]
3534
3490
  }
@@ -3589,15 +3545,15 @@ const CONTROLS = [
3589
3545
  <div class="frame-root h-full"></div>
3590
3546
  </body>
3591
3547
  </html>`, useKeyEventWatcher = (o) => {
3592
- const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), h = o ? { document: o } : {};
3548
+ const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), x = o ? { document: o } : {};
3593
3549
  useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys("ctrl+c,command+c", () => u(n), {}, [n, u]), useHotkeys(
3594
3550
  "ctrl+v,command+v",
3595
3551
  () => {
3596
3552
  g(n[0]) && m(n);
3597
3553
  },
3598
- { ...h, preventDefault: !0 },
3554
+ { ...x, preventDefault: !0 },
3599
3555
  [n, g, m]
3600
- ), useHotkeys("esc", () => r([]), h, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...h, preventDefault: !0 }, [
3556
+ ), useHotkeys("esc", () => r([]), x, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...x, preventDefault: !0 }, [
3601
3557
  n,
3602
3558
  i
3603
3559
  ]), useHotkeys(
@@ -3605,25 +3561,22 @@ const CONTROLS = [
3605
3561
  (f) => {
3606
3562
  f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
3607
3563
  },
3608
- h,
3564
+ x,
3609
3565
  [n, l]
3610
3566
  );
3611
3567
  }, KeyboardHandler = () => {
3612
3568
  const { document: o } = useFrame();
3613
3569
  return useKeyEventWatcher(o), null;
3614
- }, CHAI_BUILDER_EVENTS = {
3615
- OPEN_ADD_BLOCK: "OPEN_ADD_BLOCK",
3616
- CLOSE_ADD_BLOCK: "CLOSE_ADD_BLOCK",
3617
- SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS"
3618
3570
  }, AddBlockAtBottom = () => {
3619
- const { t: o } = useTranslation();
3620
- return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer py-2", children: [
3571
+ const { t: o } = useTranslation(), { hasPermission: n } = usePermissions();
3572
+ return n(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer py-2", children: [
3621
3573
  /* @__PURE__ */ jsx("br", {}),
3622
3574
  /* @__PURE__ */ jsx(
3623
3575
  "div",
3624
3576
  {
3577
+ role: "button",
3625
3578
  onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),
3626
- className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
3579
+ className: "block h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
3627
3580
  children: /* @__PURE__ */ jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-xs leading-tight text-white hover:bg-purple-500", children: [
3628
3581
  /* @__PURE__ */ jsx(PlusIcon$1, { className: "size-2.5 stroke-[3]" }),
3629
3582
  " ",
@@ -3632,7 +3585,7 @@ const CONTROLS = [
3632
3585
  }
3633
3586
  ),
3634
3587
  /* @__PURE__ */ jsx("br", {})
3635
- ] });
3588
+ ] }) : null;
3636
3589
  };
3637
3590
  let iframeDocument = null, possiblePositions = [], dropTarget = null, dropIndex = null;
3638
3591
  const positionPlaceholder = (o, n, r) => {
@@ -3688,33 +3641,33 @@ const useDnd = () => {
3688
3641
  };
3689
3642
  return iframeDocument = o, {
3690
3643
  isDragging: n,
3691
- onDragOver: (h) => {
3692
- h.preventDefault(), h.stopPropagation(), throttledDragOver(h);
3644
+ onDragOver: (x) => {
3645
+ x.preventDefault(), x.stopPropagation(), throttledDragOver(x);
3693
3646
  },
3694
- onDrop: (h) => {
3695
- var _;
3696
- const f = dropTarget, b = getOrientation(f) === "vertical" ? h.clientY + ((_ = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : _.scrollY) : h.clientX;
3647
+ onDrop: (x) => {
3648
+ var j;
3649
+ const f = dropTarget, b = getOrientation(f) === "vertical" ? x.clientY + ((j = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : j.scrollY) : x.clientX;
3697
3650
  dropIndex = calculateDropIndex(b, possiblePositions);
3698
- const y = d, B = f.getAttribute("data-block-id"), E = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3699
- if ((y == null ? void 0 : y._id) === B || !E) {
3651
+ const k = d, A = f.getAttribute("data-block-id"), B = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3652
+ if ((k == null ? void 0 : k._id) === A || !B) {
3700
3653
  m();
3701
3654
  return;
3702
3655
  }
3703
- if (!has(y, "_id")) {
3704
- a(y, B === "canvas" ? null : B, dropIndex), setTimeout(m, 300);
3656
+ if (!has(k, "_id")) {
3657
+ a(k, A === "canvas" ? null : A, dropIndex), setTimeout(m, 300);
3705
3658
  return;
3706
3659
  }
3707
- let w = f.getAttribute("data-block-id");
3708
- w === null && (w = h.target.parentElement.getAttribute("data-block-id")), c([y._id], w === "canvas" ? null : w, dropIndex), m(), setTimeout(removePlaceholder, 300);
3660
+ let C = f.getAttribute("data-block-id");
3661
+ C === null && (C = x.target.parentElement.getAttribute("data-block-id")), c([k._id], C === "canvas" ? null : C, dropIndex), m(), setTimeout(removePlaceholder, 300);
3709
3662
  },
3710
- onDragEnter: (h) => {
3711
- const f = h, x = f.target;
3712
- dropTarget = x;
3713
- const b = x.getAttribute("data-block-id"), y = x.getAttribute("data-dnd-dragged") !== "yes";
3714
- u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(x), r(!0), l(""), i([]);
3663
+ onDragEnter: (x) => {
3664
+ const f = x, h = f.target;
3665
+ dropTarget = h;
3666
+ const b = h.getAttribute("data-block-id"), k = h.getAttribute("data-dnd-dragged") !== "yes";
3667
+ u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], k && calculatePossiblePositions(h), r(!0), l(""), i([]);
3715
3668
  },
3716
- onDragLeave: (h) => {
3717
- h.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
3669
+ onDragLeave: (x) => {
3670
+ x.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
3718
3671
  }
3719
3672
  };
3720
3673
  };
@@ -3745,8 +3698,8 @@ const useHandleCanvasDblClick = (o, n) => {
3745
3698
  const f = o.getHTML();
3746
3699
  a([m], { content: f }), n.style.display = "none", u.style.visibility = "visible";
3747
3700
  }), i(m);
3748
- const h = d(m).content;
3749
- o.commands.setContent(h), n.style.display = "block", u.style.visibility = "hidden", n.style.position = "absolute", n.style.top = `${u.offsetTop}px`, n.style.left = `${u.offsetLeft}px`, n.style.width = `${u.offsetWidth}px`, n.style.height = `${u.offsetHeight}px`, n.classList.add(...u.classList);
3701
+ const x = d(m).content;
3702
+ o.commands.setContent(x), n.style.display = "block", u.style.visibility = "hidden", n.style.position = "absolute", n.style.top = `${u.offsetTop}px`, n.style.left = `${u.offsetLeft}px`, n.style.width = `${u.offsetWidth}px`, n.style.height = `${u.offsetHeight}px`, n.classList.add(...u.classList);
3750
3703
  },
3751
3704
  [l, c, d, i, a, o, n]
3752
3705
  );
@@ -3787,17 +3740,17 @@ const useHandleCanvasDblClick = (o, n) => {
3787
3740
  return;
3788
3741
  const f = getElementByDataBlockId(n, first(r));
3789
3742
  if (f) {
3790
- const x = f.getAttribute("data-style-prop");
3791
- if (x) {
3792
- const b = f.getAttribute("data-style-id"), y = f.getAttribute("data-block-parent");
3793
- l([{ id: b, prop: x, blockId: y }]);
3743
+ const h = f.getAttribute("data-style-prop");
3744
+ if (h) {
3745
+ const b = f.getAttribute("data-style-id"), k = f.getAttribute("data-block-parent");
3746
+ l([{ id: b, prop: h, blockId: k }]);
3794
3747
  }
3795
3748
  }
3796
3749
  }, 100);
3797
3750
  }, [n, r, l, a]);
3798
3751
  const c = useEditor({
3799
3752
  extensions: [StarterKit]
3800
- }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), h = useDnd();
3753
+ }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), x = useDnd();
3801
3754
  return /* @__PURE__ */ jsx(
3802
3755
  "div",
3803
3756
  {
@@ -3807,8 +3760,8 @@ const useHandleCanvasDblClick = (o, n) => {
3807
3760
  onDoubleClick: p,
3808
3761
  onMouseMove: g,
3809
3762
  onMouseLeave: m,
3810
- ...omit(h, "isDragging"),
3811
- className: "relative h-full max-w-full p-px " + (h.isDragging ? "dragging" : ""),
3763
+ ...omit(x, "isDragging"),
3764
+ className: "relative h-full max-w-full p-px " + (x.isDragging ? "dragging" : ""),
3812
3765
  children: o
3813
3766
  }
3814
3767
  );
@@ -3817,7 +3770,7 @@ const useHandleCanvasDblClick = (o, n) => {
3817
3770
  d == null ? void 0 : d.getElementById("selected-block")
3818
3771
  ), [m] = useState(
3819
3772
  d == null ? void 0 : d.getElementById("selected-styling-block")
3820
- ), [h] = useState(
3773
+ ), [x] = useState(
3821
3774
  d == null ? void 0 : d.getElementById("dragged-block")
3822
3775
  );
3823
3776
  useEffect(() => {
@@ -3842,15 +3795,15 @@ const useHandleCanvasDblClick = (o, n) => {
3842
3795
  forms,
3843
3796
  aspectRatio,
3844
3797
  containerQueries,
3845
- plugin(function({ addBase: b, theme: y }) {
3798
+ plugin(function({ addBase: b, theme: k }) {
3846
3799
  b({
3847
3800
  "h1,h2,h3,h4,h5,h6": {
3848
- fontFamily: y("fontFamily.heading")
3801
+ fontFamily: k("fontFamily.heading")
3849
3802
  },
3850
3803
  body: {
3851
- fontFamily: y("fontFamily.body"),
3852
- color: y("colors.foreground"),
3853
- backgroundColor: y("colors.background")
3804
+ fontFamily: k("fontFamily.body"),
3805
+ color: k("colors.foreground"),
3806
+ backgroundColor: k("colors.background")
3854
3807
  }
3855
3808
  });
3856
3809
  })
@@ -3861,8 +3814,8 @@ const useHandleCanvasDblClick = (o, n) => {
3861
3814
  outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
3862
3815
  }`);
3863
3816
  }, [r, g]), useEffect(() => {
3864
- h.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
3865
- }, [i, h]), useEffect(() => {
3817
+ x.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
3818
+ }, [i, x]), useEffect(() => {
3866
3819
  u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
3867
3820
  }, [u]), useEffect(() => {
3868
3821
  m && (m.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
@@ -3874,10 +3827,10 @@ const useHandleCanvasDblClick = (o, n) => {
3874
3827
  const f = useMemo(
3875
3828
  () => getChaiThemeCssVariables(o),
3876
3829
  [o]
3877
- ), x = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3830
+ ), h = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3878
3831
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3879
3832
  /* @__PURE__ */ jsx("style", { id: "chai-theme", children: f }),
3880
- /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: x } })
3833
+ /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: h } })
3881
3834
  ] });
3882
3835
  }, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
3883
3836
  const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
@@ -3957,10 +3910,10 @@ const getBlockRuntimeProps = memoize((o) => {
3957
3910
  const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), m = useMemo(
3958
3911
  () => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
3959
3912
  [r, l, a, d, u]
3960
- ), h = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), f = useMemo(
3913
+ ), x = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), f = useMemo(
3961
3914
  () => c(r._id, getBlockRuntimeProps(r._type)),
3962
3915
  [r._id, r._type, c, getBlockRuntimeProps]
3963
- ), x = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), b = useMemo(
3916
+ ), h = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), b = useMemo(
3964
3917
  () => ({
3965
3918
  blockProps: {
3966
3919
  "data-block-id": r._id,
@@ -3969,9 +3922,9 @@ const getBlockRuntimeProps = memoize((o) => {
3969
3922
  inBuilder: !0,
3970
3923
  lang: l || i,
3971
3924
  ...m,
3972
- ...h,
3925
+ ...x,
3973
3926
  ...f,
3974
- ...x
3927
+ ...h
3975
3928
  }),
3976
3929
  [
3977
3930
  r._id,
@@ -3979,9 +3932,9 @@ const getBlockRuntimeProps = memoize((o) => {
3979
3932
  l,
3980
3933
  i,
3981
3934
  m,
3982
- h,
3935
+ x,
3983
3936
  f,
3984
- x
3937
+ h
3985
3938
  ]
3986
3939
  );
3987
3940
  return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...b, children: n }) });
@@ -4013,11 +3966,11 @@ const getBlockRuntimeProps = memoize((o) => {
4013
3966
  if (d < n) {
4014
3967
  const u = parseFloat((d / n).toFixed(2).toString());
4015
3968
  let g = {};
4016
- const m = p * u, h = d * u;
3969
+ const m = p * u, x = d * u;
4017
3970
  p && (g = {
4018
3971
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
4019
3972
  height: 100 + (p - m) / m * 100 + "%",
4020
- width: 100 + (d - h) / h * 100 + "%"
3973
+ width: 100 + (d - x) / x * 100 + "%"
4021
3974
  }), i({
4022
3975
  position: "relative",
4023
3976
  top: 0,
@@ -4034,39 +3987,39 @@ const getBlockRuntimeProps = memoize((o) => {
4034
3987
  c();
4035
3988
  }, [n, o, r, c]), l;
4036
3989
  }, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
4037
- 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), B = useBuilderProp("htmlDir", "ltr"), E = (j) => {
4038
- p((S) => ({ ...S, width: j }));
3990
+ 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([]), [, x] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [h, b] = useSelectedStylingBlocks(), k = useBuilderProp("loading", !1), A = useBuilderProp("htmlDir", "ltr"), B = (_) => {
3991
+ p((S) => ({ ...S, width: _ }));
4039
3992
  };
4040
3993
  useEffect(() => {
4041
3994
  if (!c.current) return;
4042
- const { clientWidth: j, clientHeight: S } = c.current;
4043
- p({ width: j, height: S });
3995
+ const { clientWidth: _, clientHeight: S } = c.current;
3996
+ p({ width: _, height: S });
4044
3997
  }, [c, n]);
4045
- const w = (j, S = 0) => {
4046
- const { top: C } = j.getBoundingClientRect();
4047
- return C + S >= 0 && C - S <= window.innerHeight;
3998
+ const C = (_, S = 0) => {
3999
+ const { top: w } = _.getBoundingClientRect();
4000
+ return w + S >= 0 && w - S <= window.innerHeight;
4048
4001
  };
4049
4002
  useEffect(() => {
4050
- var j, S;
4003
+ var _, S;
4051
4004
  if (a && a.type !== "Multiple" && i.current) {
4052
- const C = getElementByDataBlockId(i.current.contentDocument, a._id);
4053
- C && (w(C) || (S = (j = i.current) == null ? void 0 : j.contentWindow) == null || S.scrollTo({ top: C.offsetTop, behavior: "smooth" }), m([C]));
4005
+ const w = getElementByDataBlockId(i.current.contentDocument, a._id);
4006
+ w && (C(w) || (S = (_ = i.current) == null ? void 0 : _.contentWindow) == null || S.scrollTo({ top: w.offsetTop, behavior: "smooth" }), m([w]));
4054
4007
  }
4055
4008
  }, [a]), useEffect(() => {
4056
- if (!isEmpty(x) && i.current) {
4057
- const j = getElementByStyleId(
4009
+ if (!isEmpty(h) && i.current) {
4010
+ const _ = getElementByStyleId(
4058
4011
  i.current.contentDocument,
4059
- first(x).id
4012
+ first(h).id
4060
4013
  );
4061
- h(j ? [j] : [null]);
4014
+ x(_ ? [_] : [null]);
4062
4015
  } else
4063
- h([null]);
4064
- }, [x]);
4065
- const _ = useMemo(() => {
4066
- let j = IframeInitialContent;
4067
- return j = j.replace("__HTML_DIR__", B), o === "offline" && (j = j.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), j;
4068
- }, [o, B]);
4069
- return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: E, onResize: E, children: /* @__PURE__ */ jsx(
4016
+ x([null]);
4017
+ }, [h]);
4018
+ const j = useMemo(() => {
4019
+ let _ = IframeInitialContent;
4020
+ return _ = _.replace("__HTML_DIR__", A), o === "offline" && (_ = _.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), _;
4021
+ }, [o, A]);
4022
+ return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: B, onResize: B, children: /* @__PURE__ */ jsx(
4070
4023
  "div",
4071
4024
  {
4072
4025
  onClick: () => {
@@ -4083,7 +4036,7 @@ const getBlockRuntimeProps = memoize((o) => {
4083
4036
  id: "canvas-iframe",
4084
4037
  style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
4085
4038
  className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
4086
- initialContent: _,
4039
+ initialContent: j,
4087
4040
  children: [
4088
4041
  /* @__PURE__ */ jsx(KeyboardHandler, {}),
4089
4042
  /* @__PURE__ */ jsx(
@@ -4095,7 +4048,7 @@ const getBlockRuntimeProps = memoize((o) => {
4095
4048
  ),
4096
4049
  /* @__PURE__ */ jsx(HeadTags, {}),
4097
4050
  /* @__PURE__ */ jsx(Provider$1, { children: /* @__PURE__ */ jsxs(Canvas, { children: [
4098
- y ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
4051
+ k ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
4099
4052
  /* @__PURE__ */ jsx(AddBlockAtBottom, {}),
4100
4053
  /* @__PURE__ */ jsx("br", {}),
4101
4054
  /* @__PURE__ */ jsx("br", {}),
@@ -4256,78 +4209,78 @@ const getBlockRuntimeProps = memoize((o) => {
4256
4209
  }
4257
4210
  );
4258
4211
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
4259
- const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [c, d] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), g = (y) => {
4260
- a(y);
4261
- }, m = () => {
4262
- const y = l.find((B) => Object.keys(B)[0] === r);
4263
- if (y) {
4264
- const B = Object.values(y)[0];
4265
- B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? d(B) : console.error("Invalid preset structure:", B);
4212
+ 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 = (A) => {
4213
+ a(A);
4214
+ }, x = () => {
4215
+ const A = l.find((B) => Object.keys(B)[0] === r);
4216
+ if (A) {
4217
+ const B = Object.values(A)[0];
4218
+ B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? p(B) : console.error("Invalid preset structure:", B);
4266
4219
  } else
4267
4220
  console.error("Preset not found:", r);
4268
- }, h = useDebouncedCallback(
4269
- (y, B) => {
4270
- d(() => ({
4271
- ...c,
4221
+ }, f = useDebouncedCallback(
4222
+ (A, B) => {
4223
+ p(() => ({
4224
+ ...d,
4272
4225
  fontFamily: {
4273
- ...c.fontFamily,
4274
- [y.replace(/font-/g, "")]: B
4226
+ ...d.fontFamily,
4227
+ [A.replace(/font-/g, "")]: B
4275
4228
  }
4276
4229
  }));
4277
4230
  },
4278
- [c],
4231
+ [d],
4279
4232
  200
4280
- ), f = useDebouncedCallback(
4281
- (y) => {
4282
- d(() => ({
4283
- ...c,
4284
- borderRadius: `${y}px`
4233
+ ), h = useDebouncedCallback(
4234
+ (A) => {
4235
+ p(() => ({
4236
+ ...d,
4237
+ borderRadius: `${A}px`
4285
4238
  }));
4286
4239
  },
4287
- [c],
4240
+ [d],
4288
4241
  200
4289
- ), x = useDebouncedCallback(
4290
- (y, B) => {
4291
- d(() => {
4292
- const E = get(c, `colors.${y}`);
4293
- return n ? set(E, 1, B) : set(E, 0, B), {
4294
- ...c,
4242
+ ), b = useDebouncedCallback(
4243
+ (A, B) => {
4244
+ p(() => {
4245
+ const C = get(d, `colors.${A}`);
4246
+ return n ? set(C, 1, B) : set(C, 0, B), {
4247
+ ...d,
4295
4248
  colors: {
4296
- ...c.colors,
4297
- [y]: E
4249
+ ...d.colors,
4250
+ [A]: C
4298
4251
  }
4299
4252
  };
4300
4253
  });
4301
4254
  },
4302
- [c],
4255
+ [d],
4303
4256
  200
4304
- ), b = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([B]) => {
4305
- const E = get(c, `colors.${B}.${n ? 1 : 0}`);
4257
+ ), k = (A) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(A.items).map(([B]) => {
4258
+ const C = get(d, `colors.${B}.${n ? 1 : 0}`);
4306
4259
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
4307
4260
  /* @__PURE__ */ jsx(
4308
4261
  ColorPickerInput,
4309
4262
  {
4310
- value: E,
4311
- onChange: (w) => x(B, w)
4263
+ value: C,
4264
+ onChange: (j) => b(B, j)
4312
4265
  }
4313
4266
  ),
4314
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
4267
+ /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((j) => j.charAt(0).toUpperCase() + j.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
4315
4268
  ] }, B);
4316
4269
  }) });
4317
- return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
4270
+ return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
4318
4271
  /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
4319
4272
  l.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 py-2", children: [
4320
4273
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
4321
- /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Presets") }),
4274
+ /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Presets") }),
4322
4275
  /* @__PURE__ */ jsxs(
4323
4276
  "select",
4324
4277
  {
4325
4278
  value: r,
4326
- onChange: (y) => g(y.target.value),
4279
+ onChange: (A) => m(A.target.value),
4327
4280
  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",
4328
4281
  children: [
4329
4282
  /* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
4330
- Array.isArray(l) && l.map((y) => /* @__PURE__ */ jsx("option", { value: Object.keys(y)[0], children: capitalize(Object.keys(y)[0]) }, Object.keys(y)[0]))
4283
+ Array.isArray(l) && l.map((A) => /* @__PURE__ */ jsx("option", { value: Object.keys(A)[0], children: capitalize(Object.keys(A)[0]) }, Object.keys(A)[0]))
4331
4284
  ]
4332
4285
  }
4333
4286
  )
@@ -4338,31 +4291,31 @@ const getBlockRuntimeProps = memoize((o) => {
4338
4291
  className: "w-full text-sm",
4339
4292
  disabled: r === "",
4340
4293
  variant: "default",
4341
- onClick: m,
4342
- children: u("Apply")
4294
+ onClick: x,
4295
+ children: g("Apply")
4343
4296
  }
4344
4297
  ) })
4345
4298
  ] }),
4346
4299
  /* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
4347
- (p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, B]) => /* @__PURE__ */ jsx(
4300
+ (u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([A, B]) => /* @__PURE__ */ jsx(
4348
4301
  FontSelector,
4349
4302
  {
4350
- label: y,
4351
- value: c.fontFamily[y.replace(/font-/g, "")] || B[Object.keys(B)[0]],
4352
- onChange: (E) => h(y, E)
4303
+ label: A,
4304
+ value: d.fontFamily[A.replace(/font-/g, "")] || B[Object.keys(B)[0]],
4305
+ onChange: (C) => f(A, C)
4353
4306
  },
4354
- y
4307
+ A
4355
4308
  )) }),
4356
- (p == null ? void 0 : p.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
4357
- /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Border Radius") }),
4309
+ (u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
4310
+ /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Border Radius") }),
4358
4311
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
4359
- /* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange: f }),
4360
- /* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: c.borderRadius })
4312
+ /* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange: h }),
4313
+ /* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: d.borderRadius })
4361
4314
  ] })
4362
4315
  ] }),
4363
- (p == null ? void 0 : p.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
4364
- /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Colors") }),
4365
- /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) => b(y)) }, n ? "dark" : "light")
4316
+ (u == null ? void 0 : u.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
4317
+ /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Colors") }),
4318
+ /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((A) => k(A)) }, n ? "dark" : "light")
4366
4319
  ] })
4367
4320
  ] }),
4368
4321
  /* @__PURE__ */ jsx("br", {}),
@@ -4371,7 +4324,7 @@ const getBlockRuntimeProps = memoize((o) => {
4371
4324
  /* @__PURE__ */ jsx("br", {})
4372
4325
  ] }),
4373
4326
  i && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(i) })
4374
- ] });
4327
+ ] }) : /* @__PURE__ */ jsx("div", { className: "relative w-full", children: /* @__PURE__ */ jsx("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto text-center", o), children: /* @__PURE__ */ jsx("div", { className: "mt-10 h-full items-center justify-center gap-2 text-muted-foreground", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: "You don't have permission to edit the theme. Please contact your administrator to get access." }) }) }) });
4375
4328
  }), removeSizeAttributes = (o) => {
4376
4329
  try {
4377
4330
  return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi, "<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi, "<svg$1$2>");
@@ -4455,19 +4408,19 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4455
4408
  }, [a, o]);
4456
4409
  const u = (f) => Array.isArray(f) ? "array" : typeof f == "object" && f !== null ? "object" : "value", g = React.useCallback(
4457
4410
  (f) => {
4458
- const x = (b) => r === "value" ? b === "value" || b === "object" : r === "array" ? b === "array" : b === r;
4459
- f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) : x(f.type) && (n([...i, f.key].join(".")), l(!1));
4411
+ const h = (b) => r === "value" ? b === "value" || b === "object" : r === "array" ? b === "array" : b === r;
4412
+ f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) : h(f.type) && (n([...i, f.key].join(".")), l(!1));
4460
4413
  },
4461
4414
  [i, n, r]
4462
4415
  ), m = React.useCallback(() => {
4463
4416
  if (i.length > 0) {
4464
4417
  const f = i.slice(0, -1);
4465
- c(f), p(f.reduce((x, b) => x[b], o));
4418
+ c(f), p(f.reduce((h, b) => h[b], o));
4466
4419
  }
4467
- }, [i, o]), h = React.useMemo(() => Object.entries(d).map(([f, x]) => ({
4420
+ }, [i, o]), x = React.useMemo(() => Object.entries(d).map(([f, h]) => ({
4468
4421
  key: f,
4469
- value: x,
4470
- type: u(x)
4422
+ value: h,
4423
+ type: u(h)
4471
4424
  })).filter((f) => r === "value" ? f.type === "value" || f.type === "object" : r === "array" ? f.type === "array" || f.type === "object" : r === "object" ? f.type === "object" : !0), [d, r]);
4472
4425
  return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
4473
4426
  /* @__PURE__ */ jsxs(Tooltip, { children: [
@@ -4493,7 +4446,7 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4493
4446
  /* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
4494
4447
  "Back"
4495
4448
  ] }),
4496
- h.map((f) => /* @__PURE__ */ jsxs(
4449
+ x.map((f) => /* @__PURE__ */ jsxs(
4497
4450
  CommandItem,
4498
4451
  {
4499
4452
  value: f.key,
@@ -4509,8 +4462,8 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4509
4462
  size: "sm",
4510
4463
  variant: "ghost",
4511
4464
  className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
4512
- onClick: (x) => {
4513
- x.stopPropagation(), n([...i, f.key].join(".")), l(!1);
4465
+ onClick: (h) => {
4466
+ h.stopPropagation(), n([...i, f.key].join(".")), l(!1);
4514
4467
  },
4515
4468
  children: "Select"
4516
4469
  }
@@ -4686,8 +4639,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4686
4639
  z-index: 9999 !important;
4687
4640
  }
4688
4641
  `, document.head.appendChild(m), () => {
4689
- const h = document.getElementById("rte-modal-styles");
4690
- h && h.remove();
4642
+ const x = document.getElementById("rte-modal-styles");
4643
+ x && x.remove();
4691
4644
  };
4692
4645
  }
4693
4646
  }, [o]);
@@ -4709,12 +4662,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4709
4662
  ],
4710
4663
  content: a || "",
4711
4664
  onUpdate: ({ editor: m }) => {
4712
- const h = m.getHTML();
4713
- l(h);
4665
+ const x = m.getHTML();
4666
+ l(x);
4714
4667
  },
4715
4668
  onBlur: ({ editor: m }) => {
4716
- const h = m.getHTML();
4717
- i(r, h);
4669
+ const x = m.getHTML();
4670
+ i(r, x);
4718
4671
  },
4719
4672
  editorProps: {
4720
4673
  attributes: {
@@ -4731,17 +4684,17 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4731
4684
  }, [u, o]);
4732
4685
  const g = (m) => {
4733
4686
  if (!u) return;
4734
- const h = `{{${m}}}`;
4687
+ const x = `{{${m}}}`;
4735
4688
  u.commands.focus();
4736
- const { from: f, to: x } = u.state.selection;
4737
- if (f !== x)
4738
- u.chain().deleteSelection().insertContent(h).run();
4689
+ const { from: f, to: h } = u.state.selection;
4690
+ if (f !== h)
4691
+ u.chain().deleteSelection().insertContent(x).run();
4739
4692
  else {
4740
- const { state: y } = u, B = y.selection.from, E = y.doc.textBetween(Math.max(0, B - 1), B), w = y.doc.textBetween(B, Math.min(B + 1, y.doc.content.size));
4741
- let _ = "";
4742
- B > 0 && E !== " " && !/[.,!?;:]/.test(E) && (_ = " ");
4693
+ const { state: k } = u, A = k.selection.from, B = k.doc.textBetween(Math.max(0, A - 1), A), C = k.doc.textBetween(A, Math.min(A + 1, k.doc.content.size));
4743
4694
  let j = "";
4744
- w && w !== " " && !/[.,!?;:]/.test(w) && (j = " "), u.chain().insertContent(_ + h + j).run();
4695
+ A > 0 && B !== " " && !/[.,!?;:]/.test(B) && (j = " ");
4696
+ let _ = "";
4697
+ C && C !== " " && !/[.,!?;:]/.test(C) && (_ = " "), u.chain().insertContent(j + x + _).run();
4745
4698
  }
4746
4699
  };
4747
4700
  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: [
@@ -4777,12 +4730,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4777
4730
  ],
4778
4731
  content: r || "",
4779
4732
  onUpdate: ({ editor: f }) => {
4780
- const x = f.getHTML();
4781
- a(x), c || u(x);
4733
+ const h = f.getHTML();
4734
+ a(h), c || u(h);
4782
4735
  },
4783
4736
  onBlur: ({ editor: f }) => {
4784
- const x = f.getHTML();
4785
- l(o, x);
4737
+ const h = f.getHTML();
4738
+ l(o, h);
4786
4739
  },
4787
4740
  editorProps: {
4788
4741
  attributes: {
@@ -4797,7 +4750,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4797
4750
  }, [r]);
4798
4751
  const m = (f) => {
4799
4752
  a(f);
4800
- }, h = () => {
4753
+ }, x = () => {
4801
4754
  d(!1), g && g.commands.setContent(p);
4802
4755
  };
4803
4756
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -4809,7 +4762,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4809
4762
  RTEModal,
4810
4763
  {
4811
4764
  isOpen: c,
4812
- onClose: h,
4765
+ onClose: x,
4813
4766
  id: o,
4814
4767
  value: p,
4815
4768
  onChange: m,
@@ -4823,41 +4776,41 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4823
4776
  onChange: r
4824
4777
  }) => {
4825
4778
  var L;
4826
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), B = useRef(null), E = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
4779
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, x] = useState(""), [f, h] = useState([]), [b, k] = useState(-1), A = useRef(null), B = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
4827
4780
  useEffect(() => {
4828
- if (h(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4829
- const v = split(o, ":"), k = get(v, 1, "page") || "page";
4830
- g(k), (async () => {
4831
- const A = await l(k, [get(v, 2, "page")]);
4832
- A && Array.isArray(A) && h(get(A, [0, "name"], ""));
4781
+ if (x(""), h([]), k(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4782
+ const v = split(o, ":"), y = get(v, 1, "page") || "page";
4783
+ g(y), (async () => {
4784
+ const E = await l(y, [get(v, 2, "page")]);
4785
+ E && Array.isArray(E) && x(get(E, [0, "name"], ""));
4833
4786
  })();
4834
4787
  }, [o]);
4835
- const w = useDebouncedCallback(
4788
+ const C = useDebouncedCallback(
4836
4789
  async (v) => {
4837
4790
  if (isEmpty(v))
4838
- x([]);
4791
+ h([]);
4839
4792
  else {
4840
- const k = await l(u, v);
4841
- x(k);
4793
+ const y = await l(u, v);
4794
+ h(y);
4842
4795
  }
4843
- c(!1), y(-1);
4796
+ c(!1), k(-1);
4844
4797
  },
4845
4798
  [u],
4846
4799
  300
4847
- ), _ = (v) => {
4848
- const k = ["pageType", u, v.id];
4849
- k[1] && (r(k.join(":")), h(v.name), p(!1), x([]), y(-1));
4850
- }, j = (v) => {
4800
+ ), j = (v) => {
4801
+ const y = ["pageType", u, v.id];
4802
+ y[1] && (r(y.join(":")), x(v.name), p(!1), h([]), k(-1));
4803
+ }, _ = (v) => {
4851
4804
  switch (v.key) {
4852
4805
  case "ArrowDown":
4853
- v.preventDefault(), y((k) => k < f.length - 1 ? k + 1 : k);
4806
+ v.preventDefault(), k((y) => y < f.length - 1 ? y + 1 : y);
4854
4807
  break;
4855
4808
  case "ArrowUp":
4856
- v.preventDefault(), y((k) => k > 0 ? k - 1 : k);
4809
+ v.preventDefault(), k((y) => y > 0 ? y - 1 : y);
4857
4810
  break;
4858
4811
  case "Enter":
4859
4812
  if (v.preventDefault(), f.length === 0) return;
4860
- b >= 0 && _(f[b]);
4813
+ b >= 0 && j(f[b]);
4861
4814
  break;
4862
4815
  case "Escape":
4863
4816
  v.preventDefault(), S();
@@ -4865,15 +4818,15 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4865
4818
  }
4866
4819
  };
4867
4820
  useEffect(() => {
4868
- if (b >= 0 && B.current) {
4869
- const v = B.current.children[b];
4821
+ if (b >= 0 && A.current) {
4822
+ const v = A.current.children[b];
4870
4823
  v == null || v.scrollIntoView({ block: "nearest" });
4871
4824
  }
4872
4825
  }, [b]);
4873
4826
  const S = () => {
4874
- h(""), x([]), y(-1), p(!1), r("");
4875
- }, C = (v) => {
4876
- h(v), p(!isEmpty(v)), c(!0), w(v);
4827
+ x(""), h([]), k(-1), p(!1), r("");
4828
+ }, w = (v) => {
4829
+ x(v), p(!isEmpty(v)), c(!0), C(v);
4877
4830
  };
4878
4831
  return /* @__PURE__ */ jsxs("div", { children: [
4879
4832
  /* @__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)) }),
@@ -4883,9 +4836,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4883
4836
  {
4884
4837
  type: "text",
4885
4838
  value: m,
4886
- onChange: (v) => C(v.target.value),
4887
- onKeyDown: j,
4888
- placeholder: a(`Search ${E ?? ""}`),
4839
+ onChange: (v) => w(v.target.value),
4840
+ onKeyDown: _,
4841
+ placeholder: a(`Search ${B ?? ""}`),
4889
4842
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4890
4843
  }
4891
4844
  ),
@@ -4899,11 +4852,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4899
4852
  ' "',
4900
4853
  m,
4901
4854
  '"'
4902
- ] }) : /* @__PURE__ */ jsx("ul", { ref: B, children: map(f == null ? void 0 : f.slice(0, 20), (v, k) => /* @__PURE__ */ jsxs(
4855
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(f == null ? void 0 : f.slice(0, 20), (v, y) => /* @__PURE__ */ jsxs(
4903
4856
  "li",
4904
4857
  {
4905
- onClick: () => _(v),
4906
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : k === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
4858
+ onClick: () => j(v),
4859
+ 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"}`,
4907
4860
  children: [
4908
4861
  v.name,
4909
4862
  " ",
@@ -4997,29 +4950,29 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4997
4950
  u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
4998
4951
  }, [o, u]);
4999
4952
  const m = () => {
5000
- const x = findIndex(u, { _id: g });
5001
- if (x > -1) {
5002
- const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
5003
- if (!y) return;
5004
- n({ ...o, currentSlide: y }), c([y]);
4953
+ const h = findIndex(u, { _id: g });
4954
+ if (h > -1) {
4955
+ const b = (h + 1) % u.length, k = get(u, [b, "_id"]);
4956
+ if (!k) return;
4957
+ n({ ...o, currentSlide: k }), c([k]);
5005
4958
  }
5006
- }, h = () => {
5007
- const x = findIndex(u, { _id: g });
5008
- if (x > -1) {
5009
- const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
5010
- if (!y) return;
5011
- n({ ...o, currentSlide: y }), c([y]);
4959
+ }, x = () => {
4960
+ const h = findIndex(u, { _id: g });
4961
+ if (h > -1) {
4962
+ const b = (h - 1 + u.length) % u.length, k = get(u, [b, "_id"]);
4963
+ if (!k) return;
4964
+ n({ ...o, currentSlide: k }), c([k]);
5012
4965
  }
5013
4966
  }, f = () => {
5014
- const x = i(
4967
+ const h = i(
5015
4968
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
5016
4969
  p == null ? void 0 : p._id
5017
- ), b = x == null ? void 0 : x._id;
4970
+ ), b = h == null ? void 0 : h._id;
5018
4971
  b && (n({ ...o, currentSlide: b }), c([b]));
5019
4972
  };
5020
4973
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
5021
4974
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
5022
- /* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
4975
+ /* @__PURE__ */ jsx("button", { onClick: x, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
5023
4976
  /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
5024
4977
  /* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
5025
4978
  " ",
@@ -5093,8 +5046,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5093
5046
  value: o == null ? void 0 : o.autoplayInterval,
5094
5047
  className: "text-xs",
5095
5048
  pattern: "[0-9]*",
5096
- onChange: (x) => {
5097
- let b = x.target.value;
5049
+ onChange: (h) => {
5050
+ let b = h.target.value;
5098
5051
  b.length && (b = b.replace("-", "")), n({ ...o, autoplayInterval: b });
5099
5052
  }
5100
5053
  }
@@ -5134,65 +5087,65 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5134
5087
  formData: g,
5135
5088
  onChange: m
5136
5089
  }) => {
5137
- const { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = isEmpty$1(x) ? "" : isEmpty$1(h) ? f : h, y = get$1(LANGUAGES, b, b), B = usePageExternalData(), E = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = get$1(w, [E == null ? void 0 : E._type, "i18nProps"], []) || [], [j, S] = useState(null), C = useCallback(
5138
- (k) => {
5139
- const A = (N) => /[.,!?;:]/.test(N), T = (N, D, $) => {
5140
- let R = "", O = "";
5141
- const M = D > 0 ? N[D - 1] : "", H = D < N.length ? N[D] : "";
5142
- return D > 0 && (M === "." || !A(M) && M !== " ") && (R = " "), D < N.length && !A(H) && H !== " " && (O = " "), {
5143
- text: R + $ + O,
5144
- prefixLength: R.length,
5090
+ const { selectedLang: x, fallbackLang: f, languages: h } = useLanguages(), b = isEmpty(h) ? "" : isEmpty(x) ? f : x, k = get(LANGUAGES, b, b), A = usePageExternalData(), B = useSelectedBlock(), C = useRegisteredChaiBlocks(), j = get(C, [B == null ? void 0 : B._type, "i18nProps"], []) || [], [_, S] = useState(null), w = useCallback(
5091
+ (y) => {
5092
+ const E = (P) => /[.,!?;:]/.test(P), T = (P, N, M) => {
5093
+ let D = "", O = "";
5094
+ const $ = N > 0 ? P[N - 1] : "", H = N < P.length ? P[N] : "";
5095
+ return N > 0 && ($ === "." || !E($) && $ !== " ") && (D = " "), N < P.length && !E(H) && H !== " " && (O = " "), {
5096
+ text: D + M + O,
5097
+ prefixLength: D.length,
5145
5098
  suffixLength: O.length
5146
5099
  };
5147
5100
  }, I = document.getElementById(o);
5148
5101
  if (!I) return;
5149
- const P = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
5150
- if (P && (P.querySelector(".ProseMirror") || P.__chaiRTE)) {
5151
- const N = P.__chaiRTE;
5152
- if (N) {
5153
- const D = `{{${k}}}`;
5154
- N.commands.focus();
5155
- const { from: $, to: R } = N.state.selection;
5156
- if ($ !== R)
5157
- N.chain().deleteSelection().insertContent(D).run();
5102
+ const R = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
5103
+ if (R && (R.querySelector(".ProseMirror") || R.__chaiRTE)) {
5104
+ const P = R.__chaiRTE;
5105
+ if (P) {
5106
+ const N = `{{${y}}}`;
5107
+ P.commands.focus();
5108
+ const { from: M, to: D } = P.state.selection;
5109
+ if (M !== D)
5110
+ P.chain().deleteSelection().insertContent(N).run();
5158
5111
  else {
5159
- const { state: M } = N, H = M.selection.from, F = M.doc.textBetween(Math.max(0, H - 1), H), U = M.doc.textBetween(H, Math.min(H + 1, M.doc.content.size));
5112
+ const { state: $ } = P, H = $.selection.from, U = $.doc.textBetween(Math.max(0, H - 1), H), F = $.doc.textBetween(H, Math.min(H + 1, $.doc.content.size));
5160
5113
  let z = "";
5161
- H > 0 && F !== " " && !A(F) && (z = " ");
5114
+ H > 0 && U !== " " && !E(U) && (z = " ");
5162
5115
  let W = "";
5163
- U && U !== " " && !A(U) && (W = " "), N.chain().insertContent(z + D + W).run();
5116
+ F && F !== " " && !E(F) && (W = " "), P.chain().insertContent(z + N + W).run();
5164
5117
  }
5165
- setTimeout(() => m(N.getHTML(), {}, o), 100);
5118
+ setTimeout(() => m(P.getHTML(), {}, o), 100);
5166
5119
  return;
5167
5120
  }
5168
5121
  } else {
5169
- const N = I, D = N.selectionStart || 0, $ = N.value || "", R = N.selectionEnd || D;
5170
- if (R > D) {
5171
- const U = `{{${k}}}`, { text: z } = T($, D, U), W = $.slice(0, D) + z + $.slice(R);
5122
+ const P = I, N = P.selectionStart || 0, M = P.value || "", D = P.selectionEnd || N;
5123
+ if (D > N) {
5124
+ const F = `{{${y}}}`, { text: z } = T(M, N, F), W = M.slice(0, N) + z + M.slice(D);
5172
5125
  m(W, {}, o);
5173
5126
  return;
5174
5127
  }
5175
- const M = `{{${k}}}`, { text: H } = T($, D, M), F = $.slice(0, D) + H + $.slice(D);
5176
- m(F, {}, o);
5128
+ const $ = `{{${y}}}`, { text: H } = T(M, N, $), U = M.slice(0, N) + H + M.slice(N);
5129
+ m(U, {}, o);
5177
5130
  }
5178
5131
  },
5179
- [o, m, g, E == null ? void 0 : E._id]
5132
+ [o, m, g, B == null ? void 0 : B._id]
5180
5133
  );
5181
5134
  if (d)
5182
5135
  return null;
5183
5136
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
5184
- const v = _ == null ? void 0 : _.includes(o.replace("root.", ""));
5137
+ const v = j == null ? void 0 : j.includes(o.replace("root.", ""));
5185
5138
  if (u.type === "array") {
5186
- const k = j === o;
5139
+ const y = _ === o;
5187
5140
  return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
5188
5141
  u.title && /* @__PURE__ */ jsxs(
5189
5142
  "label",
5190
5143
  {
5191
5144
  htmlFor: o,
5192
- onClick: () => S(k ? null : o),
5145
+ onClick: () => S(y ? null : o),
5193
5146
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
5194
5147
  children: [
5195
- k ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
5148
+ y ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
5196
5149
  /* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
5197
5150
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: r }),
5198
5151
  " ",
@@ -5200,7 +5153,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5200
5153
  ]
5201
5154
  }
5202
5155
  ),
5203
- (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: [
5156
+ (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: [
5204
5157
  c,
5205
5158
  a,
5206
5159
  l,
@@ -5215,11 +5168,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5215
5168
  " ",
5216
5169
  v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5217
5170
  " ",
5218
- y
5171
+ k
5219
5172
  ] }),
5220
5173
  p && u.type !== "object" ? " *" : null
5221
5174
  ] }),
5222
- u.type === "string" && !u.enum && !u.oneOf && B && /* @__PURE__ */ jsx(NestedPathSelector, { data: B, onSelect: C, dataType: "value" })
5175
+ u.type === "string" && !u.enum && !u.oneOf && A && /* @__PURE__ */ jsx(NestedPathSelector, { data: A, onSelect: w, dataType: "value" })
5223
5176
  ] }),
5224
5177
  c,
5225
5178
  a,
@@ -5274,8 +5227,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5274
5227
  formData: a,
5275
5228
  onChange: ({ formData: g }, m) => {
5276
5229
  if (!m || o !== (g == null ? void 0 : g._id)) return;
5277
- const h = take(m.split("."), 2).join(".").replace("root.", "");
5278
- u({ formData: g }, h);
5230
+ const x = take(m.split("."), 2).join(".").replace("root.", "");
5231
+ u({ formData: g }, x);
5279
5232
  }
5280
5233
  },
5281
5234
  i
@@ -5318,35 +5271,35 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5318
5271
  }), a;
5319
5272
  };
5320
5273
  function BlockSettings() {
5321
- 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 }, S, C) => {
5322
- S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(j, S) }, C);
5323
- }, x = useCallback(
5324
- debounce(({ formData: j }, S, C) => {
5325
- f({ formData: j }, S, C), d(j);
5274
+ 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), x = formDataWithSelectedLang(g, o, m), f = ({ formData: _ }, S, w) => {
5275
+ S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(_, S) }, w);
5276
+ }, h = useCallback(
5277
+ debounce(({ formData: _ }, S, w) => {
5278
+ f({ formData: _ }, S, w), d(_);
5326
5279
  }, 1500),
5327
5280
  [n == null ? void 0 : n._id, o]
5328
- ), b = ({ formData: j }, S) => {
5329
- S && (r([n._id], { [S]: get(j, S) }), x({ formData: j }, S, { [S]: get(c, S) }));
5330
- }, y = ({ formData: j }, S) => {
5331
- S && (r([g._id], { [S]: get(j, S) }), x({ formData: j }, S, { [S]: get(c, S) }));
5281
+ ), b = ({ formData: _ }, S) => {
5282
+ S && (r([n._id], { [S]: get(_, S) }), h({ formData: _ }, S, { [S]: get(c, S) }));
5283
+ }, k = ({ formData: _ }, S) => {
5284
+ S && (r([g._id], { [S]: get(_, S) }), h({ formData: _ }, S, { [S]: get(c, S) }));
5332
5285
  };
5333
5286
  keys(get(i, "_bindings", {}));
5334
- const { schema: B, uiSchema: E } = useMemo(() => {
5335
- const j = n == null ? void 0 : n._type;
5336
- if (j)
5337
- return getBlockFormSchemas(j);
5338
- }, [n]), { wrapperSchema: w, wrapperUiSchema: _ } = useMemo(() => {
5287
+ const { schema: A, uiSchema: B } = useMemo(() => {
5288
+ const _ = n == null ? void 0 : n._type;
5289
+ if (_)
5290
+ return getBlockFormSchemas(_);
5291
+ }, [n]), { wrapperSchema: C, wrapperUiSchema: j } = useMemo(() => {
5339
5292
  if (!g || !(g != null && g._type))
5340
5293
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5341
- const j = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: C = {} } = getBlockFormSchemas(j);
5342
- return { wrapperSchema: S, wrapperUiSchema: C };
5294
+ const _ = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: w = {} } = getBlockFormSchemas(_);
5295
+ return { wrapperSchema: S, wrapperUiSchema: w };
5343
5296
  }, [g]);
5344
5297
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5345
5298
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
5346
5299
  /* @__PURE__ */ jsxs(
5347
5300
  "div",
5348
5301
  {
5349
- onClick: () => u((j) => !j),
5302
+ onClick: () => u((_) => !_),
5350
5303
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5351
5304
  children: [
5352
5305
  p ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
@@ -5365,21 +5318,21 @@ function BlockSettings() {
5365
5318
  JSONForm,
5366
5319
  {
5367
5320
  blockId: g == null ? void 0 : g._id,
5368
- onChange: y,
5369
- formData: h,
5370
- schema: w,
5371
- uiSchema: _
5321
+ onChange: k,
5322
+ formData: x,
5323
+ schema: C,
5324
+ uiSchema: j
5372
5325
  }
5373
5326
  ) })
5374
5327
  ] }),
5375
- isEmpty(B) ? null : /* @__PURE__ */ jsx(
5328
+ isEmpty(A) ? null : /* @__PURE__ */ jsx(
5376
5329
  JSONForm,
5377
5330
  {
5378
5331
  blockId: n == null ? void 0 : n._id,
5379
5332
  onChange: b,
5380
5333
  formData: i,
5381
- schema: B,
5382
- uiSchema: E
5334
+ schema: A,
5335
+ uiSchema: B
5383
5336
  }
5384
5337
  ),
5385
5338
  (n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlockSettings, {}) : null
@@ -5484,32 +5437,32 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5484
5437
  canvas: n = !1,
5485
5438
  tooltip: r = !0
5486
5439
  }) => {
5487
- const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (y) => {
5488
- u.includes(y) ? u.length > 2 && g(u.filter((B) => B !== y)) : g((B) => [...B, y]);
5489
- }, x = (y) => {
5490
- n || l(y), c(y);
5440
+ const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), x = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (k) => {
5441
+ u.includes(k) ? u.length > 2 && g(u.filter((A) => A !== k)) : g((A) => [...A, k]);
5442
+ }, h = (k) => {
5443
+ n || l(k), c(k);
5491
5444
  }, b = getBreakpointValue(n ? i : a).toLowerCase();
5492
- return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (y) => /* @__PURE__ */ createElement(
5445
+ return x.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(x, (k) => /* @__PURE__ */ createElement(
5493
5446
  BreakpointCard,
5494
5447
  {
5495
5448
  canvas: n,
5496
- ...y,
5497
- onClick: x,
5498
- key: y.breakpoint,
5449
+ ...k,
5450
+ onClick: h,
5451
+ key: k.breakpoint,
5499
5452
  currentBreakpoint: b
5500
5453
  }
5501
5454
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
5502
5455
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
5503
- h.filter((y) => includes(u, toUpper(y.breakpoint))),
5504
- (y) => /* @__PURE__ */ createElement(
5456
+ x.filter((k) => includes(u, toUpper(k.breakpoint))),
5457
+ (k) => /* @__PURE__ */ createElement(
5505
5458
  BreakpointCard,
5506
5459
  {
5507
5460
  canvas: n,
5508
5461
  openDelay: o,
5509
5462
  tooltip: r,
5510
- ...y,
5511
- onClick: x,
5512
- key: y.breakpoint,
5463
+ ...k,
5464
+ onClick: h,
5465
+ key: k.breakpoint,
5513
5466
  currentBreakpoint: b
5514
5467
  }
5515
5468
  )
@@ -5519,15 +5472,15 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5519
5472
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
5520
5473
  /* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
5521
5474
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
5522
- map(h, (y) => /* @__PURE__ */ jsx(
5475
+ map(x, (k) => /* @__PURE__ */ jsx(
5523
5476
  DropdownMenuCheckboxItem,
5524
5477
  {
5525
- disabled: y.breakpoint === "xs",
5526
- onCheckedChange: () => f(toUpper(y.breakpoint)),
5527
- checked: includes(u, toUpper(y.breakpoint)),
5528
- children: m(y.title)
5478
+ disabled: k.breakpoint === "xs",
5479
+ onCheckedChange: () => f(toUpper(k.breakpoint)),
5480
+ checked: includes(u, toUpper(k.breakpoint)),
5481
+ children: m(k.title)
5529
5482
  },
5530
- y.breakpoint
5483
+ k.breakpoint
5531
5484
  ))
5532
5485
  ] })
5533
5486
  ] })
@@ -5604,11 +5557,11 @@ function Countdown() {
5604
5557
  const AskAIStyles = ({ blockId: o }) => {
5605
5558
  const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
5606
5559
  useEffect(() => {
5607
- var h;
5608
- (h = d.current) == null || h.focus();
5560
+ var x;
5561
+ (x = d.current) == null || x.focus();
5609
5562
  }, []);
5610
- const m = (h) => {
5611
- const { usage: f } = h || {};
5563
+ const m = (x) => {
5564
+ const { usage: f } = x || {};
5612
5565
  !l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
5613
5566
  };
5614
5567
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
@@ -5618,12 +5571,12 @@ const AskAIStyles = ({ blockId: o }) => {
5618
5571
  {
5619
5572
  ref: d,
5620
5573
  value: i,
5621
- onChange: (h) => c(h.target.value),
5574
+ onChange: (x) => c(x.target.value),
5622
5575
  placeholder: n("Ask AI to edit styles"),
5623
5576
  className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
5624
5577
  rows: 4,
5625
- onKeyDown: (h) => {
5626
- h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
5578
+ onKeyDown: (x) => {
5579
+ x.key === "Enter" && (x.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
5627
5580
  }
5628
5581
  }
5629
5582
  ),
@@ -5665,24 +5618,24 @@ const AskAIStyles = ({ blockId: o }) => {
5665
5618
  };
5666
5619
  function ManualClasses() {
5667
5620
  var T;
5668
- 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, "")), B = y.split(" ").filter((I) => !isEmpty(I)), E = () => {
5621
+ 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(), x = useBuilderProp("askAiCallBack", null), [f, h] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: k } = getSplitChaiClasses(get(p, b, "")), A = k.split(" ").filter((I) => !isEmpty(I)), B = () => {
5669
5622
  const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5670
- u(m, I, !0), x("");
5671
- }, [w, _] = useState([]), j = ({ value: I }) => {
5672
- const P = I.trim().toLowerCase(), N = P.match(/.+:/g);
5673
- let D = [];
5674
- if (N && N.length > 0) {
5675
- const [$] = N, R = P.replace($, "");
5676
- D = i.search(R).map((M) => ({
5677
- ...M,
5678
- item: { ...M.item, name: $ + M.item.name }
5623
+ u(m, I, !0), h("");
5624
+ }, [C, j] = useState([]), _ = ({ value: I }) => {
5625
+ const R = I.trim().toLowerCase(), P = R.match(/.+:/g);
5626
+ let N = [];
5627
+ if (P && P.length > 0) {
5628
+ const [M] = P, D = R.replace(M, "");
5629
+ N = i.search(D).map(($) => ({
5630
+ ...$,
5631
+ item: { ...$.item, name: M + $.item.name }
5679
5632
  }));
5680
5633
  } else
5681
- D = i.search(P);
5682
- return _(map(D, "item"));
5634
+ N = i.search(R);
5635
+ return j(map(N, "item"));
5683
5636
  }, S = () => {
5684
- _([]);
5685
- }, C = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), v = useMemo(
5637
+ j([]);
5638
+ }, w = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), v = useMemo(
5686
5639
  () => ({
5687
5640
  ref: o,
5688
5641
  autoComplete: "off",
@@ -5692,33 +5645,33 @@ function ManualClasses() {
5692
5645
  placeholder: c("Enter classes separated by space"),
5693
5646
  value: f,
5694
5647
  onKeyDown: (I) => {
5695
- I.key === "Enter" && f.trim() !== "" && E();
5648
+ I.key === "Enter" && f.trim() !== "" && B();
5696
5649
  },
5697
- onChange: (I, { newValue: P }) => x(P),
5650
+ onChange: (I, { newValue: R }) => h(R),
5698
5651
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
5699
5652
  }),
5700
5653
  [f, c, o]
5701
- ), k = (I) => {
5654
+ ), y = (I) => {
5702
5655
  debugger;
5703
- const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5704
- g(m, [I]), u(m, P, !0), r(""), l(-1);
5705
- }, A = () => {
5656
+ const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5657
+ g(m, [I]), u(m, R, !0), r(""), l(-1);
5658
+ }, E = () => {
5706
5659
  if (navigator.clipboard === void 0) {
5707
5660
  toast.error(c("Clipboard not supported"));
5708
5661
  return;
5709
5662
  }
5710
- navigator.clipboard.writeText(B.join(" ")), toast.success(c("Classes copied to clipboard"));
5663
+ navigator.clipboard.writeText(A.join(" ")), toast.success(c("Classes copied to clipboard"));
5711
5664
  };
5712
5665
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
5713
5666
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
5714
5667
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
5715
5668
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
5716
5669
  /* @__PURE__ */ jsxs(Tooltip, { children: [
5717
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: A, className: "cursor-pointer" }) }),
5670
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: E, className: "cursor-pointer" }) }),
5718
5671
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
5719
5672
  ] })
5720
5673
  ] }),
5721
- h ? /* @__PURE__ */ jsxs(Popover, { children: [
5674
+ x ? /* @__PURE__ */ jsxs(Popover, { children: [
5722
5675
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
5723
5676
  /* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
5724
5677
  /* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
@@ -5730,10 +5683,10 @@ function ManualClasses() {
5730
5683
  /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
5731
5684
  Autosuggest,
5732
5685
  {
5733
- suggestions: w,
5734
- onSuggestionsFetchRequested: j,
5686
+ suggestions: C,
5687
+ onSuggestionsFetchRequested: _,
5735
5688
  onSuggestionsClearRequested: S,
5736
- getSuggestionValue: C,
5689
+ getSuggestionValue: w,
5737
5690
  renderSuggestion: L,
5738
5691
  inputProps: v,
5739
5692
  containerProps: {
@@ -5751,25 +5704,25 @@ function ManualClasses() {
5751
5704
  {
5752
5705
  variant: "outline",
5753
5706
  className: "h-6 border-border",
5754
- onClick: E,
5707
+ onClick: B,
5755
5708
  disabled: f.trim() === "",
5756
5709
  size: "sm",
5757
5710
  children: /* @__PURE__ */ jsx(PlusIcon, {})
5758
5711
  }
5759
5712
  )
5760
5713
  ] }),
5761
- /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: B.map(
5762
- (I, P) => a === P ? /* @__PURE__ */ jsx(
5714
+ /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: A.map(
5715
+ (I, R) => a === R ? /* @__PURE__ */ jsx(
5763
5716
  "input",
5764
5717
  {
5765
5718
  ref: o,
5766
5719
  value: n,
5767
- onChange: (N) => r(N.target.value),
5720
+ onChange: (P) => r(P.target.value),
5768
5721
  onBlur: () => {
5769
- k(I);
5722
+ y(I);
5770
5723
  },
5771
- onKeyDown: (N) => {
5772
- N.key === "Enter" && k(I);
5724
+ onKeyDown: (P) => {
5725
+ P.key === "Enter" && y(I);
5773
5726
  },
5774
5727
  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"
5775
5728
  },
@@ -6129,10 +6082,10 @@ const COLOR_PROP = {
6129
6082
  ringColor: "ring",
6130
6083
  ringOffsetColor: "ring-offset"
6131
6084
  }, ColorChoice = ({ property: o, onChange: n }) => {
6132
- 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(
6085
+ 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", ""), x = useCallback(
6133
6086
  // eslint-disable-next-line no-shadow
6134
6087
  (b) => {
6135
- ["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" })));
6088
+ ["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" })));
6136
6089
  },
6137
6090
  [c, p]
6138
6091
  );
@@ -6151,18 +6104,18 @@ const COLOR_PROP = {
6151
6104
  useEffect(() => {
6152
6105
  p({ color: "", shade: "" });
6153
6106
  }, [r]);
6154
- const { match: x } = useTailwindClassList();
6107
+ const { match: h } = useTailwindClassList();
6155
6108
  return useEffect(() => {
6156
- const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6157
- x(o, y) && n(y, o);
6158
- }, [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: [
6109
+ const k = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6110
+ h(o, k) && n(k, o);
6111
+ }, [h, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
6159
6112
  /* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
6160
6113
  DropDown,
6161
6114
  {
6162
6115
  disabled: !l,
6163
6116
  rounded: !0,
6164
6117
  selected: g,
6165
- onChange: h,
6118
+ onChange: x,
6166
6119
  options: [
6167
6120
  "current",
6168
6121
  "transparent",
@@ -6392,50 +6345,50 @@ const COLOR_PROP = {
6392
6345
  },
6393
6346
  a
6394
6347
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
6395
- 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(""), [B, E] = useState(!1), [w, _] = useState(!1);
6348
+ const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, x] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, h] = useState(!1), [b, k] = useState(""), [A, B] = useState(!1), [C, j] = useState(!1);
6396
6349
  useEffect(() => {
6397
- const { value: v, unit: k } = getClassValueAndUnit(i);
6398
- if (k === "") {
6399
- l(v), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
6350
+ const { value: v, unit: y } = getClassValueAndUnit(i);
6351
+ if (y === "") {
6352
+ l(v), x(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
6400
6353
  return;
6401
6354
  }
6402
- h(k), l(k === "class" || isEmpty(v) ? "" : v);
6355
+ x(y), l(y === "class" || isEmpty(v) ? "" : v);
6403
6356
  }, [i, p, u]);
6404
- const j = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), S = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), C = useCallback(
6357
+ const _ = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), S = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), w = useCallback(
6405
6358
  (v = !1) => {
6406
- const k = getUserInputValues(`${a}`, u);
6407
- if (get(k, "error", !1)) {
6408
- x(!0);
6359
+ const y = getUserInputValues(`${a}`, u);
6360
+ if (get(y, "error", !1)) {
6361
+ h(!0);
6409
6362
  return;
6410
6363
  }
6411
- const A = get(k, "unit") !== "" ? get(k, "unit") : m;
6412
- if (A === "auto" || A === "none") {
6413
- j(`${d}${A}`);
6364
+ const E = get(y, "unit") !== "" ? get(y, "unit") : m;
6365
+ if (E === "auto" || E === "none") {
6366
+ _(`${d}${E}`);
6414
6367
  return;
6415
6368
  }
6416
- if (get(k, "value") === "")
6369
+ if (get(y, "value") === "")
6417
6370
  return;
6418
- const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${A === "-" ? "" : A}]`;
6419
- v ? S(I) : j(I);
6371
+ const I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
6372
+ v ? S(I) : _(I);
6420
6373
  },
6421
- [j, S, a, m, d, u]
6374
+ [_, S, a, m, d, u]
6422
6375
  ), L = useCallback(
6423
6376
  (v) => {
6424
- const k = getUserInputValues(`${a}`, u);
6425
- if (get(k, "error", !1)) {
6426
- x(!0);
6377
+ const y = getUserInputValues(`${a}`, u);
6378
+ if (get(y, "error", !1)) {
6379
+ h(!0);
6427
6380
  return;
6428
6381
  }
6429
6382
  if (v === "auto" || v === "none") {
6430
- j(`${d}${v}`);
6383
+ _(`${d}${v}`);
6431
6384
  return;
6432
6385
  }
6433
- if (get(k, "value") === "")
6386
+ if (get(y, "value") === "")
6434
6387
  return;
6435
- const A = get(k, "unit") !== "" ? get(k, "unit") : v, I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${A === "-" ? "" : A}]`;
6436
- j(I);
6388
+ const E = get(y, "unit") !== "" ? get(y, "unit") : v, I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
6389
+ _(I);
6437
6390
  },
6438
- [j, a, d, u]
6391
+ [_, a, d, u]
6439
6392
  );
6440
6393
  return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
6441
6394
  /* @__PURE__ */ jsx(
@@ -6450,37 +6403,37 @@ const COLOR_PROP = {
6450
6403
  /* @__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, {}) }) }),
6451
6404
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
6452
6405
  ] })
6453
- ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${B ? "z-auto" : ""}`, children: [
6406
+ ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
6454
6407
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
6455
6408
  ["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
6456
6409
  "input",
6457
6410
  {
6458
6411
  readOnly: m === "class",
6459
6412
  onKeyPress: (v) => {
6460
- v.key === "Enter" && C();
6413
+ v.key === "Enter" && w();
6461
6414
  },
6462
6415
  onKeyDown: (v) => {
6463
6416
  if (v.keyCode !== 38 && v.keyCode !== 40)
6464
6417
  return;
6465
- v.preventDefault(), _(!0);
6466
- const k = parseInt$1(v.target.value);
6467
- let A = isNaN$1(k) ? 0 : k;
6468
- v.keyCode === 38 && (A += 1), v.keyCode === 40 && (A -= 1);
6469
- const T = `${A}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${m === "-" ? "" : m}]`;
6470
- S(P);
6418
+ v.preventDefault(), j(!0);
6419
+ const y = parseInt$1(v.target.value);
6420
+ let E = isNaN$1(y) ? 0 : y;
6421
+ v.keyCode === 38 && (E += 1), v.keyCode === 40 && (E -= 1);
6422
+ const T = `${E}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${m === "-" ? "" : m}]`;
6423
+ S(R);
6471
6424
  },
6472
6425
  onKeyUp: (v) => {
6473
- w && (v.preventDefault(), _(!1));
6426
+ C && (v.preventDefault(), j(!1));
6474
6427
  },
6475
- onBlur: () => C(),
6428
+ onBlur: () => w(),
6476
6429
  onChange: (v) => {
6477
- x(!1), l(v.target.value);
6430
+ h(!1), l(v.target.value);
6478
6431
  },
6479
6432
  onClick: (v) => {
6480
- var k;
6481
- (k = v == null ? void 0 : v.target) == null || k.select(), r(!1);
6433
+ var y;
6434
+ (y = v == null ? void 0 : v.target) == null || y.select(), r(!1);
6482
6435
  },
6483
- value: B ? b : a,
6436
+ value: A ? b : a,
6484
6437
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
6485
6438
  " ",
6486
6439
  f ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -6506,27 +6459,27 @@ const COLOR_PROP = {
6506
6459
  units: u,
6507
6460
  current: m,
6508
6461
  onSelect: (v) => {
6509
- r(!1), h(v), L(v);
6462
+ r(!1), x(v), L(v);
6510
6463
  }
6511
6464
  }
6512
6465
  ) }) })
6513
6466
  ] })
6514
6467
  ] }),
6515
- ["none", "auto"].indexOf(m) !== -1 || B ? null : /* @__PURE__ */ jsx(
6468
+ ["none", "auto"].indexOf(m) !== -1 || A ? null : /* @__PURE__ */ jsx(
6516
6469
  DragStyleButton,
6517
6470
  {
6518
- onDragStart: () => E(!0),
6471
+ onDragStart: () => B(!0),
6519
6472
  onDragEnd: (v) => {
6520
- if (y(() => ""), E(!1), isEmpty(v))
6473
+ if (k(() => ""), B(!1), isEmpty(v))
6521
6474
  return;
6522
- const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
6523
- j(T);
6475
+ const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
6476
+ _(T);
6524
6477
  },
6525
6478
  onDrag: (v) => {
6526
6479
  if (isEmpty(v))
6527
6480
  return;
6528
- y(v);
6529
- const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
6481
+ k(v);
6482
+ const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
6530
6483
  S(T);
6531
6484
  },
6532
6485
  currentValue: a,
@@ -6624,23 +6577,23 @@ const COLOR_PROP = {
6624
6577
  "2xl": "1536px"
6625
6578
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6626
6579
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
6627
- }, 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(
6628
- (S, C = !0) => {
6580
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), x = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), k = useCallback(
6581
+ (S, w = !0) => {
6629
6582
  const L = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
6630
6583
  (p || u !== "") && (L.mq = "xs");
6631
6584
  const v = generateFullClsName(L);
6632
- h(x, [v], C);
6585
+ x(h, [v], w);
6633
6586
  },
6634
- [x, p, g, u, l, h]
6635
- ), B = useCallback(() => {
6636
- f(x, [b], !0);
6637
- }, [x, b, f]), E = useMemo(() => canChangeClass(m, g), [m, g]);
6587
+ [h, p, g, u, l, x]
6588
+ ), A = useCallback(() => {
6589
+ f(h, [b], !0);
6590
+ }, [h, b, f]), B = useMemo(() => canChangeClass(m, g), [m, g]);
6638
6591
  useEffect(() => {
6639
- i(E, m);
6640
- }, [E, i, m]);
6641
- const [, , w] = useScreenSizeWidth(), _ = useCallback(
6592
+ i(B, m);
6593
+ }, [B, i, m]);
6594
+ const [, , C] = useScreenSizeWidth(), j = useCallback(
6642
6595
  (S) => {
6643
- w({
6596
+ C({
6644
6597
  xs: 400,
6645
6598
  sm: 640,
6646
6599
  md: 800,
@@ -6649,10 +6602,10 @@ const COLOR_PROP = {
6649
6602
  "2xl": 1920
6650
6603
  }[S]);
6651
6604
  },
6652
- [w]
6653
- ), j = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6654
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: E, canReset: m && j, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6655
- /* @__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) }) }),
6605
+ [C]
6606
+ ), _ = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6607
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: m && _, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6608
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !_ ? "text-foreground" : ""}`, children: n(a) }) }),
6656
6609
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6657
6610
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
6658
6611
  r === "arbitrary" ? /* @__PURE__ */ jsx(
@@ -6661,17 +6614,17 @@ const COLOR_PROP = {
6661
6614
  currentClass: get(m, "cls", ""),
6662
6615
  classPrefix: get(CLASS_PREFIXES, l, ""),
6663
6616
  units: c || [],
6664
- onChange: y,
6617
+ onChange: k,
6665
6618
  negative: d,
6666
6619
  cssProperty: l
6667
6620
  }
6668
6621
  ) : null,
6669
- r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: y }),
6670
- r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: y }),
6671
- r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
6672
- r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
6622
+ r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: k }),
6623
+ r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: k }),
6624
+ r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: k }),
6625
+ r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: k })
6673
6626
  ] }),
6674
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: j ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => B(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : E && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6627
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: _ ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6675
6628
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6676
6629
  "button",
6677
6630
  {
@@ -6691,7 +6644,7 @@ const COLOR_PROP = {
6691
6644
  "button",
6692
6645
  {
6693
6646
  type: "button",
6694
- onClick: () => _(get(m, "mq")),
6647
+ onClick: () => j(get(m, "mq")),
6695
6648
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
6696
6649
  children: [
6697
6650
  "Switch to ",
@@ -6712,7 +6665,7 @@ const COLOR_PROP = {
6712
6665
  units: i = basicUnits,
6713
6666
  negative: c = !1
6714
6667
  }) => {
6715
- const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((h) => map(g, "property").includes(h), [g]);
6668
+ const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((x) => map(g, "property").includes(x), [g]);
6716
6669
  return /* @__PURE__ */ jsxs(
6717
6670
  "div",
6718
6671
  {
@@ -6721,7 +6674,7 @@ const COLOR_PROP = {
6721
6674
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
6722
6675
  o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
6723
6676
  /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
6724
- n.map(({ label: h, key: f }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6677
+ n.map(({ label: x, key: f }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6725
6678
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6726
6679
  "button",
6727
6680
  {
@@ -6736,7 +6689,7 @@ const COLOR_PROP = {
6736
6689
  ]
6737
6690
  }
6738
6691
  ) }),
6739
- /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(h)) })
6692
+ /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(x)) })
6740
6693
  ] }) }))
6741
6694
  ) })
6742
6695
  ] }),
@@ -6876,11 +6829,11 @@ function BlockStyling() {
6876
6829
  }), d = useThrottledCallback(
6877
6830
  (u) => {
6878
6831
  const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
6879
- let h = parseFloat(i.dragStartValue);
6880
- h = isNaN(h) ? 0 : h;
6832
+ let x = parseFloat(i.dragStartValue);
6833
+ x = isNaN(x) ? 0 : x;
6881
6834
  let f = MAPPER[i.dragUnit];
6882
6835
  (startsWith(m, "scale") || m === "opacity") && (f = 10);
6883
- let b = (i.dragStartY - u.pageY) / f + h;
6836
+ let b = (i.dragStartY - u.pageY) / f + x;
6884
6837
  g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
6885
6838
  },
6886
6839
  [i],
@@ -6917,26 +6870,30 @@ function BlockStyling() {
6917
6870
  ] })
6918
6871
  ] });
6919
6872
  }
6920
- const CoreBlock = ({
6873
+ const CHAI_BUILDER_EVENTS = {
6874
+ OPEN_ADD_BLOCK: "OPEN_ADD_BLOCK",
6875
+ CLOSE_ADD_BLOCK: "CLOSE_ADD_BLOCK",
6876
+ SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS"
6877
+ }, CoreBlock = ({
6921
6878
  block: o,
6922
6879
  disabled: n,
6923
6880
  parentId: r,
6924
6881
  position: a
6925
6882
  }) => {
6926
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
6883
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), x = () => {
6927
6884
  if (console.log("addBlockToPage", o), has(o, "blocks")) {
6928
6885
  const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
6929
6886
  u(syncBlocksWithDefaults(b), r || null, a);
6930
6887
  } else
6931
6888
  p(o, r || null, a);
6932
6889
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6933
- }, f = useFeature("dnd"), { t: x } = useTranslation();
6890
+ }, f = useFeature("dnd"), { t: h } = useTranslation();
6934
6891
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6935
6892
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6936
6893
  "button",
6937
6894
  {
6938
6895
  disabled: n,
6939
- onClick: h,
6896
+ onClick: x,
6940
6897
  type: "button",
6941
6898
  onDragStart: (b) => {
6942
6899
  b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
@@ -6947,11 +6904,11 @@ const CoreBlock = ({
6947
6904
  className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
6948
6905
  children: [
6949
6906
  createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
6950
- /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
6907
+ /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(h(d || i)) })
6951
6908
  ]
6952
6909
  }
6953
6910
  ) }),
6954
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
6911
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: h(d || i) }) })
6955
6912
  ] }) });
6956
6913
  }, DefaultChaiBlocks = ({
6957
6914
  parentId: o,
@@ -7139,22 +7096,22 @@ const CoreBlock = ({
7139
7096
  }
7140
7097
  }
7141
7098
  }, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
7142
- var m, h, f, x, b, y, B, E;
7099
+ var m, x, f, h, b, k, A, B;
7143
7100
  if (r.type === "comment") return [];
7144
7101
  console.log("node ===>", r);
7145
7102
  let a = { _id: generateUUID() };
7146
7103
  if (n && (a._parent = n.block._id), r.type === "text")
7147
7104
  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", "") };
7148
7105
  const l = get(r, "attributes", []), i = l.find(
7149
- (w) => w.key === "data-chai-richtext" || w.key === "chai-richtext"
7106
+ (C) => C.key === "data-chai-richtext" || C.key === "chai-richtext"
7150
7107
  ), c = l.find(
7151
- (w) => w.key === "data-chai-lightbox" || w.key === "chai-lightbox"
7108
+ (C) => C.key === "data-chai-lightbox" || C.key === "chai-lightbox"
7152
7109
  ), d = l.find(
7153
- (w) => w.key === "data-chai-dropdown" || w.key === "chai-dropdown"
7110
+ (C) => C.key === "data-chai-dropdown" || C.key === "chai-dropdown"
7154
7111
  ), p = l.find(
7155
- (w) => w.key === "data-chai-dropdown-button" || w.key === "chai-dropdown-button"
7112
+ (C) => C.key === "data-chai-dropdown-button" || C.key === "chai-dropdown-button"
7156
7113
  ), u = l.find(
7157
- (w) => w.key === "data-chai-dropdown-content" || w.key === "chai-dropdown-content"
7114
+ (C) => C.key === "data-chai-dropdown-content" || C.key === "chai-dropdown-content"
7158
7115
  );
7159
7116
  if (a = {
7160
7117
  ...a,
@@ -7162,13 +7119,13 @@ const CoreBlock = ({
7162
7119
  ...getAttrs(r),
7163
7120
  ...getStyles(r)
7164
7121
  }, r.attributes) {
7165
- const w = r.attributes.find((_) => includes(NAME_ATTRIBUTES, _.key));
7166
- w && (a._name = w.value);
7122
+ const C = r.attributes.find((j) => includes(NAME_ATTRIBUTES, j.key));
7123
+ C && (a._name = C.value);
7167
7124
  }
7168
7125
  if (i)
7169
7126
  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];
7170
7127
  if (c) {
7171
- const w = [
7128
+ const C = [
7172
7129
  "data-chai-lightbox",
7173
7130
  "chai-lightbox",
7174
7131
  "data-vbtype",
@@ -7180,44 +7137,44 @@ const CoreBlock = ({
7180
7137
  ];
7181
7138
  a = {
7182
7139
  ...a,
7183
- href: ((m = l.find((_) => _.key === "href")) == null ? void 0 : m.value) || "",
7184
- hrefType: ((h = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
7185
- autoplay: ((f = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
7186
- maxWidth: ((b = (x = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : b.replace("px", "")) || "",
7187
- backdropColor: ((y = l.find((_) => _.key === "data-overlay")) == null ? void 0 : y.value) || "",
7188
- galleryName: ((B = l.find((_) => _.key === "data-gall")) == null ? void 0 : B.value) || ""
7189
- }, forEach(w, (_) => {
7190
- has(a, `styles_attrs.${_}`) && delete a.styles_attrs[_];
7140
+ href: ((m = l.find((j) => j.key === "href")) == null ? void 0 : m.value) || "",
7141
+ hrefType: ((x = l.find((j) => j.key === "data-vbtype")) == null ? void 0 : x.value) || "video",
7142
+ autoplay: ((f = l.find((j) => j.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
7143
+ maxWidth: ((b = (h = l.find((j) => j.key === "data-maxwidth")) == null ? void 0 : h.value) == null ? void 0 : b.replace("px", "")) || "",
7144
+ backdropColor: ((k = l.find((j) => j.key === "data-overlay")) == null ? void 0 : k.value) || "",
7145
+ galleryName: ((A = l.find((j) => j.key === "data-gall")) == null ? void 0 : A.value) || ""
7146
+ }, forEach(C, (j) => {
7147
+ has(a, `styles_attrs.${j}`) && delete a.styles_attrs[j];
7191
7148
  });
7192
7149
  }
7193
7150
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
7194
7151
  delete a.styles_attrs;
7195
- const w = filter(r.children || [], (j) => (j == null ? void 0 : j.tagName) !== "span");
7196
- a.content = getTextContent(w);
7197
- const _ = find(
7152
+ const C = filter(r.children || [], (_) => (_ == null ? void 0 : _.tagName) !== "span");
7153
+ a.content = getTextContent(C);
7154
+ const j = find(
7198
7155
  r.children || [],
7199
- (j) => (j == null ? void 0 : j.tagName) === "span" && some(j.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg")
7156
+ (_) => (_ == null ? void 0 : _.tagName) === "span" && some(_.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg")
7200
7157
  );
7201
- if (_) {
7202
- const j = find(_.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg");
7203
- if (j) {
7204
- a.icon = stringify([j]);
7205
- const { height: S, width: C } = getSvgDimensions(j, "16px", "16px");
7206
- a.iconHeight = S, a.iconWidth = C;
7158
+ if (j) {
7159
+ const _ = find(j.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg");
7160
+ if (_) {
7161
+ a.icon = stringify([_]);
7162
+ const { height: S, width: w } = getSvgDimensions(_, "16px", "16px");
7163
+ a.iconHeight = S, a.iconWidth = w;
7207
7164
  }
7208
7165
  }
7209
7166
  return [a];
7210
7167
  }
7211
7168
  if (a._type === "Input") {
7212
- const w = a.inputType || "text";
7213
- w === "checkbox" ? set(a, "_type", "Checkbox") : w === "radio" && set(a, "_type", "Radio");
7169
+ const C = a.inputType || "text";
7170
+ C === "checkbox" ? set(a, "_type", "Checkbox") : C === "radio" && set(a, "_type", "Radio");
7214
7171
  } else if (r.tagName === "video" || r.tagName === "iframe") {
7215
- const w = stringify([r]);
7216
- return hasVideoEmbed(w) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(w)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = w, [a];
7172
+ const C = stringify([r]);
7173
+ return hasVideoEmbed(C) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(C)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = C, [a];
7217
7174
  } else if (r.tagName === "svg") {
7218
- const w = find(r.attributes, { key: "height" }), _ = find(r.attributes, { key: "width" }), j = get(w, "value") ? `[${get(w, "value")}px]` : "24px", S = get(_, "value") ? `[${get(_, "value")}px]` : "24px", C = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
7219
- return a.styles = `${STYLES_KEY}, ${cn$1(`w-${S} h-${j}`, C)}`.trim(), r.attributes = filter(r.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([r]), [a];
7220
- } else if (r.tagName == "option" && n && ((E = n.block) == null ? void 0 : E._type) === "Select")
7175
+ const C = find(r.attributes, { key: "height" }), j = find(r.attributes, { key: "width" }), _ = get(C, "value") ? `[${get(C, "value")}px]` : "24px", S = get(j, "value") ? `[${get(j, "value")}px]` : "24px", w = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
7176
+ return a.styles = `${STYLES_KEY}, ${cn$1(`w-${S} h-${_}`, w)}`.trim(), r.attributes = filter(r.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([r]), [a];
7177
+ } else if (r.tagName == "option" && n && ((B = n.block) == null ? void 0 : B._type) === "Select")
7221
7178
  return n.block.options.push({
7222
7179
  label: getTextContent(r.children),
7223
7180
  ...getAttrs(r)
@@ -7290,29 +7247,29 @@ const CoreBlock = ({
7290
7247
  error: c
7291
7248
  }), g(!0);
7292
7249
  else if (!l && Object.keys(a || {}).length > 0) {
7293
- const h = Object.entries(a).map(([x, b]) => {
7294
- const y = b, B = y.type || "partial", E = formatReadableName(B);
7250
+ const x = Object.entries(a).map(([h, b]) => {
7251
+ const k = b, A = k.type || "partial", B = formatReadableName(A);
7295
7252
  return {
7296
7253
  type: "PartialBlock",
7297
7254
  // Set the type to PartialBlock
7298
- label: formatReadableName(y.name || x),
7299
- description: y.description || "",
7255
+ label: formatReadableName(k.name || h),
7256
+ description: k.description || "",
7300
7257
  icon: Globe,
7301
- group: E,
7258
+ group: B,
7302
7259
  // Use formatted type as group
7303
7260
  category: "partial",
7304
- partialBlockId: x,
7261
+ partialBlockId: h,
7305
7262
  // Store the original ID as partialBlockId
7306
- _name: y.name
7263
+ _name: k.name
7307
7264
  };
7308
- }), f = uniq(map(h, "group"));
7265
+ }), f = uniq(map(x, "group"));
7309
7266
  p({
7310
- blocks: h,
7267
+ blocks: x,
7311
7268
  groups: f,
7312
7269
  isLoading: !1,
7313
7270
  error: null
7314
7271
  }), g(!0);
7315
- } else l ? p((h) => ({ ...h, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
7272
+ } else l ? p((x) => ({ ...x, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
7316
7273
  blocks: [],
7317
7274
  groups: [],
7318
7275
  isLoading: !1,
@@ -7328,7 +7285,7 @@ const CoreBlock = ({
7328
7285
  c
7329
7286
  ]);
7330
7287
  const m = () => {
7331
- p((h) => ({ ...h, isLoading: !0, error: null })), g(!1), i();
7288
+ p((x) => ({ ...x, isLoading: !0, error: null })), g(!1), i();
7332
7289
  };
7333
7290
  return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
7334
7291
  /* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
@@ -7352,43 +7309,43 @@ const CoreBlock = ({
7352
7309
  );
7353
7310
  }, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
7354
7311
  var v;
7355
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (v = find(c, (k) => k._id === r)) == null ? void 0 : v._type, [h, f] = useState("all"), [x, b] = useState(null), y = useRef(null);
7312
+ 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, [x, f] = useState("all"), [h, b] = useState(null), k = useRef(null);
7356
7313
  useEffect(() => {
7357
- const k = setTimeout(() => {
7358
- var A;
7359
- (A = u.current) == null || A.focus();
7314
+ const y = setTimeout(() => {
7315
+ var E;
7316
+ (E = u.current) == null || E.focus();
7360
7317
  }, 0);
7361
- return () => clearTimeout(k);
7318
+ return () => clearTimeout(y);
7362
7319
  }, [g]), useEffect(() => {
7363
7320
  d && (f("all"), b(null));
7364
- }, [d]), useEffect(() => (y.current = debounce((k) => {
7365
- f(k);
7321
+ }, [d]), useEffect(() => (k.current = debounce((y) => {
7322
+ f(y);
7366
7323
  }, 500), () => {
7367
- y.current && y.current.cancel();
7324
+ k.current && k.current.cancel();
7368
7325
  }), []);
7369
- const B = useCallback((k) => {
7370
- b(k), y.current && y.current(k);
7371
- }, []), E = useCallback(() => {
7372
- b(null), y.current && y.current.cancel();
7373
- }, []), w = useCallback((k) => {
7374
- y.current && y.current.cancel(), f(k), b(null);
7375
- }, []), _ = useMemo(
7326
+ const A = useCallback((y) => {
7327
+ b(y), k.current && k.current(y);
7328
+ }, []), B = useCallback(() => {
7329
+ b(null), k.current && k.current.cancel();
7330
+ }, []), C = useCallback((y) => {
7331
+ k.current && k.current.cancel(), f(y), b(null);
7332
+ }, []), j = useMemo(
7376
7333
  () => d ? values(n).filter(
7377
- (k) => {
7378
- var A, T;
7379
- return (((A = k.label) == null ? void 0 : A.toLowerCase()) + " " + ((T = k.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
7334
+ (y) => {
7335
+ var E, T;
7336
+ return (((E = y.label) == null ? void 0 : E.toLowerCase()) + " " + ((T = y.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
7380
7337
  }
7381
7338
  ) : n,
7382
7339
  [n, d]
7383
- ), j = useMemo(
7340
+ ), _ = useMemo(
7384
7341
  () => d ? o.filter(
7385
- (k) => reject(filter(values(_), { group: k }), { hidden: !0 }).length > 0
7386
- ) : o.filter((k) => reject(filter(values(n), { group: k }), { hidden: !0 }).length > 0),
7387
- [n, _, o, d]
7342
+ (y) => reject(filter(values(j), { group: y }), { hidden: !0 }).length > 0
7343
+ ) : o.filter((y) => reject(filter(values(n), { group: y }), { hidden: !0 }).length > 0),
7344
+ [n, j, o, d]
7388
7345
  ), S = useMemo(
7389
- () => sortBy(j, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7390
- [j]
7391
- ), C = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), L = useMemo(() => h === "all" ? S : [h], [S, h]);
7346
+ () => sortBy(_, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
7347
+ [_]
7348
+ ), w = useMemo(() => x === "all" ? j : filter(values(j), { group: x }), [j, x]), L = useMemo(() => x === "all" ? S : [x], [S, x]);
7392
7349
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7393
7350
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7394
7351
  Input$1,
@@ -7398,7 +7355,7 @@ const CoreBlock = ({
7398
7355
  placeholder: i("Search blocks..."),
7399
7356
  value: d,
7400
7357
  className: "-ml-2",
7401
- onChange: (k) => p(k.target.value)
7358
+ onChange: (y) => p(y.target.value)
7402
7359
  }
7403
7360
  ) }),
7404
7361
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
@@ -7406,49 +7363,49 @@ const CoreBlock = ({
7406
7363
  /* @__PURE__ */ jsx(
7407
7364
  "button",
7408
7365
  {
7409
- onClick: () => w("all"),
7410
- onMouseEnter: () => B("all"),
7411
- onMouseLeave: E,
7412
- 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"}`,
7366
+ onClick: () => C("all"),
7367
+ onMouseEnter: () => A("all"),
7368
+ onMouseLeave: B,
7369
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${x === "all" || h === "all" ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7413
7370
  children: i("All")
7414
7371
  },
7415
7372
  "sidebar-all"
7416
7373
  ),
7417
- S.map((k) => /* @__PURE__ */ jsx(
7374
+ S.map((y) => /* @__PURE__ */ jsx(
7418
7375
  "button",
7419
7376
  {
7420
- onClick: () => w(k),
7421
- onMouseEnter: () => B(k),
7422
- onMouseLeave: E,
7423
- 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"}`,
7424
- children: capitalize(i(k.toLowerCase()))
7377
+ onClick: () => C(y),
7378
+ onMouseEnter: () => A(y),
7379
+ onMouseLeave: B,
7380
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${x === y || h === y ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7381
+ children: capitalize(i(y.toLowerCase()))
7425
7382
  },
7426
- `sidebar-${k}`
7383
+ `sidebar-${y}`
7427
7384
  ))
7428
7385
  ] }) }) }),
7429
- /* @__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: [
7386
+ /* @__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: _.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: [
7430
7387
  i("No blocks found matching"),
7431
7388
  ' "',
7432
7389
  d,
7433
7390
  '"'
7434
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7435
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
7391
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((y) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7392
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(y.toLowerCase())) }),
7436
7393
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
7437
7394
  reject(
7438
- h === "all" ? filter(values(C), { group: k }) : values(C),
7395
+ x === "all" ? filter(values(w), { group: y }) : values(w),
7439
7396
  { hidden: !0 }
7440
- ).map((A) => /* @__PURE__ */ jsx(
7397
+ ).map((E) => /* @__PURE__ */ jsx(
7441
7398
  CoreBlock,
7442
7399
  {
7443
7400
  parentId: r,
7444
7401
  position: a,
7445
- block: A,
7446
- disabled: !canAcceptChildBlock(m, A.type) || !canBeNestedInside(m, A.type)
7402
+ block: E,
7403
+ disabled: !canAcceptChildBlock(m, E.type) || !canBeNestedInside(m, E.type)
7447
7404
  },
7448
- A.type
7405
+ E.type
7449
7406
  ))
7450
7407
  ) })
7451
- ] }, k)) }) }) })
7408
+ ] }, y)) }) }) })
7452
7409
  ] })
7453
7410
  ] });
7454
7411
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -7457,13 +7414,13 @@ const CoreBlock = ({
7457
7414
  parentId: r = void 0,
7458
7415
  position: a = -1
7459
7416
  }) => {
7460
- const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), m = Object.keys(g || {}).length > 0;
7417
+ const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), m = Object.keys(g || {}).length > 0, { hasPermission: x } = usePermissions();
7461
7418
  useEffect(() => {
7462
7419
  i === "partials" && !m && c("library");
7463
7420
  }, [i, m, c]);
7464
- const h = useCallback(() => {
7421
+ const f = useCallback(() => {
7465
7422
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7466
- }, []);
7423
+ }, []), h = p && x(PERMISSIONS.IMPORT_HTML);
7467
7424
  return /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
7468
7425
  n ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
7469
7426
  /* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: l("Add block") }),
@@ -7472,8 +7429,8 @@ const CoreBlock = ({
7472
7429
  /* @__PURE__ */ jsxs(
7473
7430
  Tabs,
7474
7431
  {
7475
- onValueChange: (f) => {
7476
- d(""), c(f);
7432
+ onValueChange: (b) => {
7433
+ d(""), c(b);
7477
7434
  },
7478
7435
  value: i,
7479
7436
  className: "flex h-full max-h-full flex-col overflow-hidden",
@@ -7482,14 +7439,14 @@ const CoreBlock = ({
7482
7439
  /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
7483
7440
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
7484
7441
  m && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7485
- p ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7486
- map(u, (f) => /* @__PURE__ */ jsx(TabsTrigger, { value: f.key, children: React__default.createElement(f.tab) }))
7442
+ h ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7443
+ map(u, (b) => /* @__PURE__ */ jsx(TabsTrigger, { value: b.key, children: React__default.createElement(b.tab) }))
7487
7444
  ] }),
7488
7445
  /* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7489
7446
  /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
7490
7447
  m && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7491
- p ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
7492
- map(u, (f) => /* @__PURE__ */ jsx(TabsContent, { value: f.key, children: React__default.createElement(f.tabContent, { close: h, parentId: r, position: a }) }))
7448
+ h ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
7449
+ map(u, (b) => /* @__PURE__ */ jsx(TabsContent, { value: b.key, children: React__default.createElement(b.tabContent, { close: f, parentId: r, position: a }) }))
7493
7450
  ]
7494
7451
  }
7495
7452
  )
@@ -7546,18 +7503,18 @@ const BlockCard = ({
7546
7503
  parentId: r = void 0,
7547
7504
  position: a = -1
7548
7505
  }) => {
7549
- 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 = (B) => {
7550
- const E = has(B, "styles_attrs.data-page-section");
7551
- return B._type === "Box" && E;
7506
+ 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")), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), h = (A) => {
7507
+ const B = has(A, "styles_attrs.data-page-section");
7508
+ return A._type === "Box" && B;
7552
7509
  }, b = useCallback(
7553
- async (B) => {
7554
- if (B.stopPropagation(), has(o, "component")) {
7510
+ async (A) => {
7511
+ if (A.stopPropagation(), has(o, "component")) {
7555
7512
  d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7556
7513
  return;
7557
7514
  }
7558
7515
  i(!0);
7559
- const E = await c(n, o);
7560
- isEmpty(E) || p(syncBlocksWithDefaults(E), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7516
+ const B = await c(n, o);
7517
+ isEmpty(B) || p(syncBlocksWithDefaults(B), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7561
7518
  },
7562
7519
  [d, p, o, c, n, r, a]
7563
7520
  );
@@ -7567,20 +7524,20 @@ const BlockCard = ({
7567
7524
  {
7568
7525
  onClick: l ? () => {
7569
7526
  } : b,
7570
- draggable: h ? "true" : "false",
7571
- onDragStart: async (B) => {
7572
- const E = await c(n, o);
7573
- let w = r;
7574
- if (x(first(E)) && (w = null), !isEmpty(E)) {
7575
- const _ = { blocks: E, uiLibrary: !0, parent: w };
7576
- if (B.dataTransfer.setData("text/plain", JSON.stringify(_)), o.preview) {
7577
- const j = new Image();
7578
- j.src = o.preview, j.onload = () => {
7579
- B.dataTransfer.setDragImage(j, 0, 0);
7527
+ draggable: x ? "true" : "false",
7528
+ onDragStart: async (A) => {
7529
+ const B = await c(n, o);
7530
+ let C = r;
7531
+ if (h(first(B)) && (C = null), !isEmpty(B)) {
7532
+ const j = { blocks: B, uiLibrary: !0, parent: C };
7533
+ if (A.dataTransfer.setData("text/plain", JSON.stringify(j)), o.preview) {
7534
+ const _ = new Image();
7535
+ _.src = o.preview, _.onload = () => {
7536
+ A.dataTransfer.setDragImage(_, 0, 0);
7580
7537
  };
7581
7538
  } else
7582
- B.dataTransfer.setDragImage(new Image(), 0, 0);
7583
- f(_), setTimeout(() => {
7539
+ A.dataTransfer.setDragImage(new Image(), 0, 0);
7540
+ f(j), setTimeout(() => {
7584
7541
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7585
7542
  }, 200);
7586
7543
  }
@@ -7612,9 +7569,9 @@ const BlockCard = ({
7612
7569
  })();
7613
7570
  }, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
7614
7571
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7615
- const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((w) => w.category === "custom"), d = l.find((w) => w.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [m, h] = useState("Hero"), f = get(g, m, []), x = useRef(null), { t: b } = useTranslation(), y = (w) => {
7616
- x.current && (clearTimeout(x.current), x.current = null), x.current = setTimeout(() => {
7617
- x.current && h(w);
7572
+ const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((C) => C.category === "custom"), d = l.find((C) => C.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [m, x] = useState("Hero"), f = get(g, m, []), h = useRef(null), { t: b } = useTranslation(), k = (C) => {
7573
+ h.current && (clearTimeout(h.current), h.current = null), h.current = setTimeout(() => {
7574
+ h.current && x(C);
7618
7575
  }, 300);
7619
7576
  };
7620
7577
  if (u)
@@ -7622,7 +7579,7 @@ const BlockCard = ({
7622
7579
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7623
7580
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7624
7581
  ] });
7625
- const B = filter(f, (w, _) => _ % 2 === 0), E = filter(f, (w, _) => _ % 2 === 1);
7582
+ const A = filter(f, (C, j) => j % 2 === 0), B = filter(f, (C, j) => j % 2 === 1);
7626
7583
  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: [
7627
7584
  /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
7628
7585
  /* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
@@ -7630,22 +7587,22 @@ const BlockCard = ({
7630
7587
  /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: b("Groups") }),
7631
7588
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7632
7589
  /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: React__default.Children.toArray(
7633
- map(g, (w, _) => /* @__PURE__ */ jsxs(
7590
+ map(g, (C, j) => /* @__PURE__ */ jsxs(
7634
7591
  "div",
7635
7592
  {
7636
- onMouseEnter: () => y(_),
7637
- onMouseLeave: () => clearTimeout(x.current),
7638
- onClick: () => h(_),
7593
+ onMouseEnter: () => k(j),
7594
+ onMouseLeave: () => clearTimeout(h.current),
7595
+ onClick: () => x(j),
7639
7596
  className: cn$1(
7640
7597
  "flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
7641
- _ === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7598
+ j === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7642
7599
  ),
7643
7600
  children: [
7644
- /* @__PURE__ */ jsx("span", { children: capitalize(b(_.toLowerCase())) }),
7601
+ /* @__PURE__ */ jsx("span", { children: capitalize(b(j.toLowerCase())) }),
7645
7602
  /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
7646
7603
  ]
7647
7604
  },
7648
- _
7605
+ j
7649
7606
  ))
7650
7607
  ) })
7651
7608
  ] })
@@ -7653,15 +7610,15 @@ const BlockCard = ({
7653
7610
  /* @__PURE__ */ jsxs(
7654
7611
  ScrollArea,
7655
7612
  {
7656
- onMouseEnter: () => x.current ? clearTimeout(x.current) : null,
7613
+ onMouseEnter: () => h.current ? clearTimeout(h.current) : null,
7657
7614
  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",
7658
7615
  children: [
7659
7616
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
7660
7617
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7661
- B.map((w) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: w, library: d }))
7618
+ A.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
7662
7619
  ) }),
7663
7620
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7664
- E.map((w) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: w, library: d }))
7621
+ B.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
7665
7622
  ) })
7666
7623
  ] }),
7667
7624
  /* @__PURE__ */ jsx("br", {}),
@@ -7671,7 +7628,18 @@ const BlockCard = ({
7671
7628
  }
7672
7629
  )
7673
7630
  ] }) }) });
7674
- }, UILibrariesPanel = ({ parentId: o, position: n }) => /* @__PURE__ */ jsx(UILibrarySection, { parentId: o, position: n }), PasteAtRootContextMenu = ({ parentContext: o, setParentContext: n }) => {
7631
+ }, UILibrariesPanel = ({ parentId: o, position: n }) => /* @__PURE__ */ jsx(UILibrarySection, { parentId: o, position: n }), PERMISSIONS = {
7632
+ ADD_BLOCK: "add_block",
7633
+ DELETE_BLOCK: "delete_block",
7634
+ EDIT_BLOCK: "edit_block",
7635
+ MOVE_BLOCK: "move_block",
7636
+ EDIT_THEME: "edit_theme",
7637
+ SAVE_PAGE: "save_page",
7638
+ EDIT_STYLES: "edit_styles",
7639
+ IMPORT_HTML: "import_html"
7640
+ };
7641
+ Object.values(PERMISSIONS);
7642
+ const PasteAtRootContextMenu = ({ parentContext: o, setParentContext: n }) => {
7675
7643
  const { t: r } = useTranslation(), { canPaste: a, pasteBlocks: l } = usePasteBlocks();
7676
7644
  return useEffect(() => {
7677
7645
  a("root") || n(null);
@@ -7771,41 +7739,43 @@ const BlockCard = ({
7771
7739
  }
7772
7740
  );
7773
7741
  }, BlockContextMenuContent = ({ node: o }) => {
7774
- const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), i = useBuilderProp("blockMoreOptions", []), c = useCallback(() => {
7742
+ const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), { hasPermission: i } = usePermissions(), c = useBuilderProp("blockMoreOptions", []), d = useCallback(() => {
7775
7743
  a(r);
7776
7744
  }, [r, a]);
7777
7745
  return /* @__PURE__ */ jsxs(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: [
7778
- /* @__PURE__ */ jsxs(
7779
- DropdownMenuItem,
7780
- {
7781
- disabled: !canAddChildBlock(l == null ? void 0 : l._type),
7782
- className: "flex items-center gap-x-4 text-xs",
7783
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, l),
7784
- children: [
7785
- /* @__PURE__ */ jsx(PlusIcon$1, { size: "14" }),
7786
- " ",
7787
- n("Add block")
7788
- ]
7789
- }
7790
- ),
7791
- /* @__PURE__ */ jsxs(
7792
- DropdownMenuItem,
7793
- {
7794
- disabled: !canDuplicateBlock(l == null ? void 0 : l._type),
7795
- className: "flex items-center gap-x-4 text-xs",
7796
- onClick: c,
7797
- children: [
7798
- /* @__PURE__ */ jsx(CardStackPlusIcon, {}),
7799
- " ",
7800
- n("Duplicate")
7801
- ]
7802
- }
7803
- ),
7746
+ i(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsxs(Fragment, { children: [
7747
+ /* @__PURE__ */ jsxs(
7748
+ DropdownMenuItem,
7749
+ {
7750
+ disabled: !canAddChildBlock(l == null ? void 0 : l._type),
7751
+ className: "flex items-center gap-x-4 text-xs",
7752
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, l),
7753
+ children: [
7754
+ /* @__PURE__ */ jsx(PlusIcon$1, { size: "14" }),
7755
+ " ",
7756
+ n("Add block")
7757
+ ]
7758
+ }
7759
+ ),
7760
+ /* @__PURE__ */ jsxs(
7761
+ DropdownMenuItem,
7762
+ {
7763
+ disabled: !canDuplicateBlock(l == null ? void 0 : l._type),
7764
+ className: "flex items-center gap-x-4 text-xs",
7765
+ onClick: d,
7766
+ children: [
7767
+ /* @__PURE__ */ jsx(CardStackPlusIcon, {}),
7768
+ " ",
7769
+ n("Duplicate")
7770
+ ]
7771
+ }
7772
+ )
7773
+ ] }),
7804
7774
  /* @__PURE__ */ jsx(RenameBlock, { node: o }),
7805
- /* @__PURE__ */ jsx(CutBlocks, {}),
7806
- /* @__PURE__ */ jsx(CopyPasteBlocks, {}),
7807
- /* @__PURE__ */ jsx(RemoveBlocks, {}),
7808
- i.map((d, p) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("span", { children: "Loading..." }), children: React__default.createElement(d, { block: l }) }, `more-${p}`))
7775
+ i(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(CutBlocks, {}),
7776
+ i(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(CopyPasteBlocks, {}),
7777
+ i(PERMISSIONS.DELETE_BLOCK) && /* @__PURE__ */ jsx(RemoveBlocks, {}),
7778
+ c.map((p, u) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("span", { children: "Loading..." }), children: React__default.createElement(p, { block: l }) }, `more-${u}`))
7809
7779
  ] });
7810
7780
  }, BlockMoreOptions = ({ children: o, id: n, node: r }) => {
7811
7781
  const [, a] = useSelectedBlockIds();
@@ -7890,52 +7860,53 @@ const selectParent = (o, n) => {
7890
7860
  r.isInternal && n && r.close();
7891
7861
  }, currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, dragHandle: r }) => {
7892
7862
  var P;
7893
- const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
7894
- let p = null;
7895
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: h, data: f, isSelected: x, willReceiveDrop: b, isDragging: y, isEditing: B, handleClick: E } = o, w = (N) => {
7896
- N.stopPropagation(), !i.includes(h) && o.toggle();
7863
+ const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom), { hasPermission: p } = usePermissions();
7864
+ let u = null;
7865
+ const g = o.children.length > 0, { highlightBlock: m, clearHighlight: x } = useBlockHighlight(), { id: f, data: h, isSelected: b, willReceiveDrop: k, isDragging: A, isEditing: B, handleClick: C } = o, j = (N) => {
7866
+ N.stopPropagation(), !i.includes(f) && o.toggle();
7897
7867
  }, _ = (N) => {
7898
- N.isInternal && (p = N.isOpen, N.isOpen && N.close());
7899
- }, j = (N) => {
7900
- N.isInternal && p !== null && (p ? N.open() : N.close(), p = null);
7901
- }, [S, C] = useAtom$1(currentAddSelection), L = () => {
7868
+ N.isInternal && (u = N.isOpen, N.isOpen && N.close());
7869
+ }, S = (N) => {
7870
+ N.isInternal && u !== null && (u ? N.open() : N.close(), u = null);
7871
+ }, [w, L] = useAtom$1(currentAddSelection), v = () => {
7902
7872
  var N;
7903
- v(), o.parent.isSelected || C((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7904
- }, v = () => {
7905
- C(null);
7906
- }, k = (N) => {
7907
- v(), N.stopPropagation(), !o.isOpen && !i.includes(h) && o.toggle(), E(N);
7873
+ y(), o.parent.isSelected || L((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7874
+ }, y = () => {
7875
+ L(null);
7876
+ }, E = (N) => {
7877
+ y(), N.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), C(N);
7908
7878
  };
7909
7879
  useEffect(() => {
7910
7880
  const N = setTimeout(() => {
7911
- b && !o.isOpen && !y && !i.includes(h) && o.toggle();
7881
+ k && !o.isOpen && !A && !i.includes(f) && o.toggle();
7912
7882
  }, 500);
7913
7883
  return () => clearTimeout(N);
7914
- }, [b, o, y]);
7915
- const A = useMemo(() => {
7916
- const N = Object.keys(f), D = [];
7917
- for (let $ = 0; $ < N.length; $++)
7918
- if (N[$].endsWith("_attrs")) {
7919
- const R = f[N[$]], O = Object.keys(R).join("|");
7920
- O.match(/x-data/) && D.push("data"), O.match(/x-on/) && D.push("event"), O.match(/x-show|x-if/) && D.push("show");
7884
+ }, [k, o, A]);
7885
+ const T = useMemo(() => {
7886
+ const N = Object.keys(h), M = [];
7887
+ for (let D = 0; D < N.length; D++)
7888
+ if (N[D].endsWith("_attrs")) {
7889
+ const O = h[N[D]], $ = Object.keys(O).join("|");
7890
+ $.match(/x-data/) && M.push("data"), $.match(/x-on/) && M.push("event"), $.match(/x-show|x-if/) && M.push("show");
7921
7891
  }
7922
- return D;
7923
- }, [f]), T = (N, D) => {
7924
- const $ = d.contentDocument || d.contentWindow.document, R = $.querySelector(`[data-block-id=${N}]`);
7925
- R && R.setAttribute("data-drop", D);
7926
- const O = R.getBoundingClientRect(), M = d.getBoundingClientRect();
7927
- O.top >= M.top && O.left >= M.left && O.bottom <= M.bottom && O.right <= M.right || ($.documentElement.scrollTop = R.offsetTop - M.top);
7928
- }, I = (N) => {
7929
- v();
7930
- const D = get(o, "parent.id");
7931
- D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: N }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: N });
7892
+ return M;
7893
+ }, [h]), I = (N, M) => {
7894
+ const D = d.contentDocument || d.contentWindow.document, O = D.querySelector(`[data-block-id=${N}]`);
7895
+ O && O.setAttribute("data-drop", M);
7896
+ const $ = O.getBoundingClientRect(), H = d.getBoundingClientRect();
7897
+ $.top >= H.top && $.left >= H.left && $.bottom <= H.bottom && $.right <= H.right || (D.documentElement.scrollTop = O.offsetTop - H.top);
7898
+ }, R = (N) => {
7899
+ y();
7900
+ const M = get(o, "parent.id");
7901
+ 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 });
7932
7902
  };
7933
- return h === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7903
+ return f === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7934
7904
  /* @__PURE__ */ jsx("br", {}),
7935
- /* @__PURE__ */ jsx(
7905
+ p(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
7936
7906
  "div",
7937
7907
  {
7938
- onClick: () => I(-1),
7908
+ role: "button",
7909
+ onClick: () => R(-1),
7939
7910
  className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
7940
7911
  children: /* @__PURE__ */ jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-[9px] leading-tight text-white hover:bg-purple-500", children: [
7941
7912
  /* @__PURE__ */ jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
@@ -7948,32 +7919,32 @@ const selectParent = (o, n) => {
7948
7919
  ] }) : /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7949
7920
  "div",
7950
7921
  {
7951
- onMouseEnter: () => g(h),
7952
- onMouseLeave: () => m(),
7953
- onClick: k,
7922
+ onMouseEnter: () => m(f),
7923
+ onMouseLeave: () => x(),
7924
+ onClick: E,
7954
7925
  style: n,
7955
- "data-node-id": h,
7956
- ref: i.includes(h) ? null : r,
7926
+ "data-node-id": f,
7927
+ ref: i.includes(f) ? null : r,
7957
7928
  onDragStart: () => _(o),
7958
- onDragEnd: () => j(o),
7929
+ onDragEnd: () => S(o),
7959
7930
  onDragOver: (N) => {
7960
- N.preventDefault(), T(h, "yes");
7931
+ N.preventDefault(), I(f, "yes");
7961
7932
  },
7962
7933
  onDragLeave: (N) => {
7963
- N.preventDefault(), T(h, "no");
7934
+ N.preventDefault(), I(f, "no");
7964
7935
  },
7965
7936
  onDrop: (N) => {
7966
- N.preventDefault(), T(h, "no");
7937
+ N.preventDefault(), I(f, "no");
7967
7938
  },
7968
7939
  children: [
7969
- (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
7940
+ p(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
7970
7941
  "div",
7971
7942
  {
7972
7943
  onClick: (N) => {
7973
- N.stopPropagation(), I(o.childIndex);
7944
+ N.stopPropagation(), R(o.childIndex);
7974
7945
  },
7975
- onMouseEnter: L,
7976
- onMouseLeave: v,
7946
+ onMouseEnter: v,
7947
+ onMouseLeave: y,
7977
7948
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
7978
7949
  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" }) })
7979
7950
  }
@@ -7983,11 +7954,11 @@ const selectParent = (o, n) => {
7983
7954
  {
7984
7955
  className: cn$1(
7985
7956
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
7986
- x ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
7987
- b && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
7988
- (o == null ? void 0 : o.id) === S ? "bg-purple-100" : "",
7989
- y && "opacity-20",
7990
- i.includes(h) ? "opacity-50" : ""
7957
+ b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
7958
+ k && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7959
+ (o == null ? void 0 : o.id) === w ? "bg-purple-100" : "",
7960
+ A && "opacity-20",
7961
+ i.includes(f) ? "opacity-50" : ""
7991
7962
  ),
7992
7963
  children: [
7993
7964
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -7995,11 +7966,11 @@ const selectParent = (o, n) => {
7995
7966
  "div",
7996
7967
  {
7997
7968
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
7998
- children: u && /* @__PURE__ */ jsx("button", { onClick: w, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${x ? "text-slate-200" : "text-slate-400"}` }) })
7969
+ children: g && /* @__PURE__ */ jsx("button", { onClick: j, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}` }) })
7999
7970
  }
8000
7971
  ),
8001
7972
  /* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
8002
- /* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
7973
+ /* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
8003
7974
  B ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
8004
7975
  "div",
8005
7976
  {
@@ -8008,32 +7979,32 @@ const selectParent = (o, n) => {
8008
7979
  N.stopPropagation(), o.edit(), o.deselect();
8009
7980
  },
8010
7981
  children: [
8011
- /* @__PURE__ */ jsx("span", { children: (f == null ? void 0 : f._name) || (f == null ? void 0 : f._type.split("/").pop()) }),
8012
- A.includes("data") && /* @__PURE__ */ jsx(FileJson, { className: "h-3 w-3 text-orange-600" }),
8013
- A.includes("event") && /* @__PURE__ */ jsx(Zap, { className: "h-3 w-3 text-yellow-500" }),
8014
- A.includes("show") && /* @__PURE__ */ jsx(EyeOff, { className: "h-3 w-3 text-orange-600" })
7982
+ /* @__PURE__ */ jsx("span", { children: (h == null ? void 0 : h._name) || (h == null ? void 0 : h._type.split("/").pop()) }),
7983
+ T.includes("data") && /* @__PURE__ */ jsx(FileJson, { className: "h-3 w-3 text-orange-600" }),
7984
+ T.includes("event") && /* @__PURE__ */ jsx(Zap, { className: "h-3 w-3 text-yellow-500" }),
7985
+ T.includes("show") && /* @__PURE__ */ jsx(EyeOff, { className: "h-3 w-3 text-orange-600" })
8015
7986
  ]
8016
7987
  }
8017
7988
  )
8018
7989
  ] })
8019
7990
  ] }),
8020
7991
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
8021
- !i.includes(h) && a.map((N) => /* @__PURE__ */ jsxs(Tooltip, { children: [
7992
+ !i.includes(f) && a.map((N) => /* @__PURE__ */ jsxs(Tooltip, { children: [
8022
7993
  /* @__PURE__ */ jsx(
8023
7994
  TooltipTrigger,
8024
7995
  {
8025
7996
  className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
8026
7997
  asChild: !0,
8027
- children: React__default.createElement(N.item, { blockId: h })
7998
+ children: React__default.createElement(N.item, { blockId: f })
8028
7999
  }
8029
8000
  ),
8030
8001
  /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: N.tooltip })
8031
8002
  ] })),
8032
- canAddChildBlock(f == null ? void 0 : f._type) && !i.includes(h) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8003
+ canAddChildBlock(h == null ? void 0 : h._type) && !i.includes(f) && p(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8033
8004
  /* @__PURE__ */ jsx(
8034
8005
  TooltipTrigger,
8035
8006
  {
8036
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: h }),
8007
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: f }),
8037
8008
  className: "cursor-pointer rounded bg-transparent hover:text-black",
8038
8009
  asChild: !0,
8039
8010
  children: /* @__PURE__ */ jsx(PlusIcon$1, { size: "15" })
@@ -8046,7 +8017,7 @@ const selectParent = (o, n) => {
8046
8017
  TooltipTrigger,
8047
8018
  {
8048
8019
  onClick: (N) => {
8049
- N.stopPropagation(), c(h), o.isOpen && o.toggle();
8020
+ N.stopPropagation(), c(f), o.isOpen && o.toggle();
8050
8021
  },
8051
8022
  className: "cursor-pointer rounded bg-transparent hover:text-black",
8052
8023
  asChild: !0,
@@ -8055,7 +8026,7 @@ const selectParent = (o, n) => {
8055
8026
  ),
8056
8027
  /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999]", side: "left", children: l("Hide block") })
8057
8028
  ] }),
8058
- /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: h, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
8029
+ /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: f, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
8059
8030
  ] })
8060
8031
  ]
8061
8032
  }
@@ -8152,21 +8123,32 @@ const selectParent = (o, n) => {
8152
8123
  break;
8153
8124
  }
8154
8125
  };
8155
- return useEffect(() => {
8126
+ useEffect(() => {
8156
8127
  const o = () => {
8157
8128
  treeRef.current && setTreeRef(treeRef.current);
8158
8129
  };
8159
8130
  o();
8160
8131
  const n = new MutationObserver(o);
8161
8132
  return n.observe(document.body, { childList: !0, subtree: !0 }), () => n.disconnect();
8162
- }, [setTreeRef]), isEmpty(treeData) ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { className: "mt-10 flex h-full w-full items-center justify-center p-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "mb-1.5 text-sm text-gray-400", children: [
8133
+ }, [setTreeRef]);
8134
+ const { hasPermission } = usePermissions();
8135
+ return isEmpty(treeData) ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { className: "mt-10 flex h-full w-full items-center justify-center p-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "mb-1.5 text-sm text-gray-400", children: [
8163
8136
  t("This page is empty"),
8164
8137
  /* @__PURE__ */ jsx("br", {}),
8165
8138
  /* @__PURE__ */ jsx("br", {}),
8166
- /* @__PURE__ */ jsxs(Button, { onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK), variant: "default", size: "sm", children: [
8167
- "+ ",
8168
- t("Add Block")
8169
- ] })
8139
+ hasPermission(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsxs(
8140
+ Button,
8141
+ {
8142
+ disabled: !hasPermission(PERMISSIONS.ADD_BLOCK),
8143
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),
8144
+ variant: "default",
8145
+ size: "sm",
8146
+ children: [
8147
+ "+ ",
8148
+ t("Add Block")
8149
+ ]
8150
+ }
8151
+ )
8170
8152
  ] }) }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
8171
8153
  /* @__PURE__ */ jsx("div", { className: cn$1("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxs(
8172
8154
  "div",
@@ -8704,14 +8686,14 @@ function QuickPrompts({ onClick: o }) {
8704
8686
  ) }) });
8705
8687
  }
8706
8688
  const AIUserPrompt = ({ blockId: o }) => {
8707
- const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), h = useRef(null);
8689
+ const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), x = useRef(null);
8708
8690
  useEffect(() => {
8709
- var x;
8710
- (x = m.current) == null || x.focus();
8691
+ var h;
8692
+ (h = m.current) == null || h.focus();
8711
8693
  }, []);
8712
- const f = (x) => {
8713
- const { usage: b } = x || {};
8714
- !l && b && g(b), h.current = setTimeout(() => g(void 0), 1e4), l || c("");
8694
+ const f = (h) => {
8695
+ const { usage: b } = h || {};
8696
+ !l && b && g(b), x.current = setTimeout(() => g(void 0), 1e4), l || c("");
8715
8697
  };
8716
8698
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8717
8699
  /* @__PURE__ */ jsxs(
@@ -8731,12 +8713,12 @@ const AIUserPrompt = ({ blockId: o }) => {
8731
8713
  {
8732
8714
  ref: m,
8733
8715
  value: i,
8734
- onChange: (x) => c(x.target.value),
8716
+ onChange: (h) => c(h.target.value),
8735
8717
  placeholder: n("Ask AI to edit content"),
8736
8718
  className: "w-full",
8737
8719
  rows: 3,
8738
- onKeyDown: (x) => {
8739
- x.key === "Enter" && (x.preventDefault(), h.current && clearTimeout(h.current), g(void 0), r("content", o, i, f));
8720
+ onKeyDown: (h) => {
8721
+ h.key === "Enter" && (h.preventDefault(), x.current && clearTimeout(x.current), g(void 0), r("content", o, i, f));
8740
8722
  }
8741
8723
  }
8742
8724
  ),
@@ -8746,7 +8728,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8746
8728
  {
8747
8729
  disabled: i.trim().length < 5 || a,
8748
8730
  onClick: () => {
8749
- h.current && clearTimeout(h.current), g(void 0), r("content", o, i, f);
8731
+ x.current && clearTimeout(x.current), g(void 0), r("content", o, i, f);
8750
8732
  },
8751
8733
  variant: "default",
8752
8734
  className: "w-fit",
@@ -8778,8 +8760,8 @@ const AIUserPrompt = ({ blockId: o }) => {
8778
8760
  /* @__PURE__ */ jsx(
8779
8761
  QuickPrompts,
8780
8762
  {
8781
- onClick: (x) => {
8782
- h.current && clearTimeout(h.current), g(void 0), r("content", o, x, f);
8763
+ onClick: (h) => {
8764
+ x.current && clearTimeout(x.current), g(void 0), r("content", o, h, f);
8783
8765
  }
8784
8766
  }
8785
8767
  )
@@ -8793,7 +8775,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8793
8775
  useEffect(() => {
8794
8776
  n && a(n);
8795
8777
  }, [n]);
8796
- const h = async () => {
8778
+ const x = async () => {
8797
8779
  try {
8798
8780
  d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
8799
8781
  } catch (f) {
@@ -8823,7 +8805,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8823
8805
  className: "mt-1 w-full",
8824
8806
  rows: 10,
8825
8807
  onKeyDown: (f) => {
8826
- f.key === "Enter" && (f.preventDefault(), h());
8808
+ f.key === "Enter" && (f.preventDefault(), x());
8827
8809
  }
8828
8810
  }
8829
8811
  ),
@@ -8835,7 +8817,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8835
8817
  Button,
8836
8818
  {
8837
8819
  disabled: r.trim().length < 5,
8838
- onClick: () => h(),
8820
+ onClick: () => x(),
8839
8821
  variant: "default",
8840
8822
  className: "w-fit",
8841
8823
  size: "sm",
@@ -8864,7 +8846,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8864
8846
  AlertDialogAction,
8865
8847
  {
8866
8848
  onClick: () => {
8867
- a(""), h();
8849
+ a(""), x();
8868
8850
  },
8869
8851
  children: o("Yes, Delete")
8870
8852
  }
@@ -8945,8 +8927,8 @@ function usePubSub(o, n) {
8945
8927
  }, [o, n]);
8946
8928
  }
8947
8929
  const AiAssistant = () => {
8948
- const o = useAiAssistant(), [n] = useRightPanel(), r = useBuilderProp("askAiCallBack", null), { t: a } = useTranslation();
8949
- return r ? /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
8930
+ const o = useAiAssistant(), [n] = useRightPanel(), r = useBuilderProp("askAiCallBack", null), { t: a } = useTranslation(), { hasPermission: l } = usePermissions();
8931
+ return !r || !l(PERMISSIONS.EDIT_BLOCK) ? null : /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
8950
8932
  /* @__PURE__ */ jsxs(Label, { htmlFor: "ai-assistant", className: "flex items-center gap-x-1 text-sm text-yellow-600", children: [
8951
8933
  /* @__PURE__ */ jsx(SparklesIcon, { className: "w-4" }),
8952
8934
  a("AI Assistant")
@@ -8956,13 +8938,13 @@ const AiAssistant = () => {
8956
8938
  {
8957
8939
  className: "scale-90",
8958
8940
  checked: n === "ai",
8959
- onCheckedChange: (l) => {
8960
- o(l);
8941
+ onCheckedChange: (i) => {
8942
+ o(i);
8961
8943
  },
8962
8944
  id: "ai-assistant"
8963
8945
  }
8964
8946
  )
8965
- ] }) : null;
8947
+ ] });
8966
8948
  }, ClearCanvas = () => {
8967
8949
  const { t: o } = useTranslation(), { setNewBlocks: n } = useBlocksStoreUndoableActions(), [, r] = useSelectedBlockIds(), [, a] = useSelectedStylingBlocks(), l = useCallback(() => {
8968
8950
  n([]), r([]), a([]);
@@ -9021,54 +9003,54 @@ const AiAssistant = () => {
9021
9003
  preloadedAttributes: n = [],
9022
9004
  onAttributesChange: r
9023
9005
  }) {
9024
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), f = useRef(null), x = useRef(null), b = usePageExternalData();
9006
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, x] = useState(""), f = useRef(null), h = useRef(null), b = usePageExternalData();
9025
9007
  useEffect(() => {
9026
9008
  l(n);
9027
9009
  }, [n]);
9028
- const y = () => {
9010
+ const k = () => {
9029
9011
  if (i.startsWith("@")) {
9030
- h("Attribute keys cannot start with '@'");
9012
+ x("Attribute keys cannot start with '@'");
9031
9013
  return;
9032
9014
  }
9033
9015
  if (i) {
9034
9016
  const S = [...a, { key: i, value: d }];
9035
- r(S), l(a), c(""), p(""), h("");
9017
+ r(S), l(a), c(""), p(""), x("");
9036
9018
  }
9019
+ }, A = (S) => {
9020
+ const w = a.filter((L, v) => v !== S);
9021
+ r(w), l(w);
9037
9022
  }, B = (S) => {
9038
- const C = a.filter((L, v) => v !== S);
9039
- r(C), l(C);
9040
- }, E = (S) => {
9041
9023
  g(S), c(a[S].key), p(a[S].value);
9042
- }, w = () => {
9024
+ }, C = () => {
9043
9025
  if (i.startsWith("@")) {
9044
- h("Attribute keys cannot start with '@'");
9026
+ x("Attribute keys cannot start with '@'");
9045
9027
  return;
9046
9028
  }
9047
9029
  if (u !== null && i) {
9048
9030
  const S = [...a];
9049
- S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), h("");
9031
+ S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), x("");
9050
9032
  }
9051
- }, _ = (S) => {
9052
- S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : y());
9053
- }, j = useCallback((S) => {
9054
- const C = (k) => /[.,!?;:]/.test(k), L = (k, A, T) => {
9055
- let I = "", P = "";
9056
- const N = A > 0 ? k[A - 1] : "", D = A < k.length ? k[A] : "";
9057
- return A > 0 && (N === "." || !C(N) && N !== " ") && (I = " "), A < k.length && !C(D) && D !== " " && (P = " "), {
9058
- text: I + T + P,
9033
+ }, j = (S) => {
9034
+ S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? C() : k());
9035
+ }, _ = useCallback((S) => {
9036
+ const w = (y) => /[.,!?;:]/.test(y), L = (y, E, T) => {
9037
+ let I = "", R = "";
9038
+ const P = E > 0 ? y[E - 1] : "", N = E < y.length ? y[E] : "";
9039
+ return E > 0 && (P === "." || !w(P) && P !== " ") && (I = " "), E < y.length && !w(N) && N !== " " && (R = " "), {
9040
+ text: I + T + R,
9059
9041
  prefixLength: I.length,
9060
- suffixLength: P.length
9042
+ suffixLength: R.length
9061
9043
  };
9062
- }, v = x.current;
9044
+ }, v = h.current;
9063
9045
  if (v) {
9064
- const k = v.selectionStart || 0, A = v.value || "", T = v.selectionEnd || k;
9065
- if (T > k) {
9066
- const $ = `{{${S}}}`, { text: R } = L(A, k, $), O = A.slice(0, k) + R + A.slice(T);
9046
+ const y = v.selectionStart || 0, E = v.value || "", T = v.selectionEnd || y;
9047
+ if (T > y) {
9048
+ const M = `{{${S}}}`, { text: D } = L(E, y, M), O = E.slice(0, y) + D + E.slice(T);
9067
9049
  p(O);
9068
9050
  return;
9069
9051
  }
9070
- const P = `{{${S}}}`, { text: N } = L(A, k, P), D = A.slice(0, k) + N + A.slice(k);
9071
- p(D);
9052
+ const R = `{{${S}}}`, { text: P } = L(E, y, R), N = E.slice(0, y) + P + E.slice(y);
9053
+ p(N);
9072
9054
  }
9073
9055
  }, []);
9074
9056
  return /* @__PURE__ */ jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
@@ -9076,7 +9058,7 @@ const AiAssistant = () => {
9076
9058
  "form",
9077
9059
  {
9078
9060
  onSubmit: (S) => {
9079
- S.preventDefault(), u !== null ? w() : y();
9061
+ S.preventDefault(), u !== null ? C() : k();
9080
9062
  },
9081
9063
  className: "space-y-3",
9082
9064
  children: [
@@ -9101,7 +9083,7 @@ const AiAssistant = () => {
9101
9083
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9102
9084
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9103
9085
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9104
- !isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: j })
9086
+ !isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: _ })
9105
9087
  ] }),
9106
9088
  /* @__PURE__ */ jsx(
9107
9089
  Textarea,
@@ -9111,10 +9093,10 @@ const AiAssistant = () => {
9111
9093
  spellCheck: "false",
9112
9094
  id: "attrValue",
9113
9095
  rows: 2,
9114
- ref: x,
9096
+ ref: h,
9115
9097
  value: d,
9116
9098
  onChange: (S) => p(S.target.value),
9117
- onKeyDown: _,
9099
+ onKeyDown: j,
9118
9100
  placeholder: "Enter Value",
9119
9101
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
9120
9102
  }
@@ -9126,16 +9108,16 @@ const AiAssistant = () => {
9126
9108
  ]
9127
9109
  }
9128
9110
  ),
9129
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, C) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9111
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, w) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9130
9112
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9131
9113
  /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
9132
9114
  /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: S.value.toString() })
9133
9115
  ] }),
9134
9116
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9135
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => E(C), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9136
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(C), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9117
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(w), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9118
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(w), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9137
9119
  ] })
9138
- ] }, C)) })
9120
+ ] }, w)) })
9139
9121
  ] });
9140
9122
  }), BlockAttributesEditor = React.memo(() => {
9141
9123
  const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9172,10 +9154,26 @@ function BlockAttributesToggle() {
9172
9154
  ] });
9173
9155
  }
9174
9156
  const SettingsPanel = () => {
9175
- const o = useSelectedBlock(), { t: n } = useTranslation(), r = useBuilderProp("onError", noop);
9176
- return isNull(o) ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
9157
+ const o = useSelectedBlock(), { t: n } = useTranslation(), r = useBuilderProp("onError", noop), { hasPermission: a } = usePermissions();
9158
+ let l = !a(PERMISSIONS.EDIT_BLOCK);
9159
+ const i = !a(PERMISSIONS.EDIT_STYLES), c = a("!" + PERMISSIONS.EDIT_BLOCK + "_" + (o == null ? void 0 : o._type));
9160
+ return l = l || c, isNull(o) ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
9177
9161
  /* @__PURE__ */ jsx(MixerHorizontalIcon, { className: "mx-auto text-3xl" }),
9178
9162
  /* @__PURE__ */ jsx("h1", { children: n("Please select a block to edit settings or styles") })
9163
+ ] }) }) : l && i ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
9164
+ /* @__PURE__ */ jsx(MixerHorizontalIcon, { className: "mx-auto text-3xl" }),
9165
+ /* @__PURE__ */ jsx("h1", { children: n("You don't have permission to edit settings or styles") }),
9166
+ /* @__PURE__ */ jsx("p", { children: n("Please contact your administrator to get access") })
9167
+ ] }) }) : i ? /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs("div", { className: "no-scrollbar h-full max-h-min w-full overflow-y-auto", children: [
9168
+ /* @__PURE__ */ jsx(BlockSettings, {}),
9169
+ /* @__PURE__ */ jsx("br", {}),
9170
+ /* @__PURE__ */ jsx("br", {})
9171
+ ] }) }) : l ? /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs("div", { className: "no-scrollbar h-full max-h-min w-full overflow-y-auto overflow-x-hidden", children: [
9172
+ /* @__PURE__ */ jsx(BlockStyling, {}),
9173
+ /* @__PURE__ */ jsx(BlockAttributesToggle, {}),
9174
+ /* @__PURE__ */ jsx("br", {}),
9175
+ /* @__PURE__ */ jsx("br", {}),
9176
+ /* @__PURE__ */ jsx("br", {})
9179
9177
  ] }) }) : /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "settings", className: "flex flex-1 flex-col", children: [
9180
9178
  /* @__PURE__ */ jsxs(TabsList, { className: "grid h-auto w-full grid-cols-2 p-1 py-1", children: [
9181
9179
  /* @__PURE__ */ jsx(TabsTrigger, { value: "settings", className: "text-xs", children: "Settings" }),
@@ -9329,11 +9327,11 @@ const RootLayout = () => {
9329
9327
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9330
9328
  n(1);
9331
9329
  });
9332
- const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (x) => {
9333
- x.preventDefault();
9334
- }, u = (x) => {
9335
- n(o === x ? null : x);
9336
- }, g = useSidebarMenuItems(), { t: m } = useTranslation(), h = [...g, ...c], f = useBuilderProp("htmlDir", "ltr");
9330
+ const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (h) => {
9331
+ h.preventDefault();
9332
+ }, u = (h) => {
9333
+ n(o === h ? null : h);
9334
+ }, g = useSidebarMenuItems(), { t: m } = useTranslation(), x = [...g, ...c], f = useBuilderProp("htmlDir", "ltr");
9337
9335
  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: [
9338
9336
  /* @__PURE__ */ jsxs(
9339
9337
  "div",
@@ -9344,21 +9342,21 @@ const RootLayout = () => {
9344
9342
  /* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
9345
9343
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9346
9344
  /* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9347
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: h.map((x, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9345
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: x.map((h, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9348
9346
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
9349
9347
  Button,
9350
9348
  {
9351
9349
  variant: o === b ? "default" : "ghost",
9352
9350
  className: "mb-2 rounded-lg p-2 transition-colors",
9353
9351
  onClick: () => u(b),
9354
- children: get(x, "icon", null)
9352
+ children: get(h, "icon", null)
9355
9353
  },
9356
9354
  b
9357
9355
  ) }),
9358
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(x.label) }) })
9356
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(h.label) }) })
9359
9357
  ] }, "button" + b)) }),
9360
9358
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9361
- /* @__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}`)) })
9359
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((h, b) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(h, {}) }, `sidebar-component-${b}`)) })
9362
9360
  ] }),
9363
9361
  /* @__PURE__ */ jsx(
9364
9362
  motion.div,
@@ -9371,14 +9369,14 @@ const RootLayout = () => {
9371
9369
  /* @__PURE__ */ jsxs(
9372
9370
  "div",
9373
9371
  {
9374
- 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"}`,
9372
+ className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(x, `${o}.isInternal`, !1) ? "" : "w-64"}`,
9375
9373
  children: [
9376
- /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(h, `${o}.icon`, null) }),
9377
- /* @__PURE__ */ jsx("span", { children: m(h[o].label) })
9374
+ /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(x, `${o}.icon`, null) }),
9375
+ /* @__PURE__ */ jsx("span", { children: m(x[o].label) })
9378
9376
  ]
9379
9377
  }
9380
9378
  ),
9381
- /* @__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), {}) }) })
9379
+ /* @__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(x, `${o}.component`, null), {}) }) })
9382
9380
  ] })
9383
9381
  }
9384
9382
  ),
@@ -9516,6 +9514,7 @@ export {
9516
9514
  DefaultChaiBlocks,
9517
9515
  ImportHTML,
9518
9516
  ListTree as Outline,
9517
+ PERMISSIONS,
9519
9518
  Breakpoints$1 as ScreenSizes,
9520
9519
  ThemeConfigPanel as ThemeOptions,
9521
9520
  UILibrariesPanel as UILibraries,
@@ -9523,9 +9522,9 @@ export {
9523
9522
  generateUUID as generateBlockId,
9524
9523
  getBlocksFromHTML,
9525
9524
  getClassValueAndUnit,
9526
- We as i18n,
9525
+ ze as i18n,
9527
9526
  cn$1 as mergeClasses,
9528
- Fe as registerChaiBlock,
9527
+ Ue as registerChaiBlock,
9529
9528
  useAddBlock,
9530
9529
  useAddClassesToBlocks,
9531
9530
  useAskAi,
@@ -9551,6 +9550,7 @@ export {
9551
9550
  usePartailBlocksStore,
9552
9551
  usePartialBlocksList,
9553
9552
  usePasteBlocks,
9553
+ usePermissions,
9554
9554
  usePreviewMode,
9555
9555
  useRemoveBlocks,
9556
9556
  useRemoveClassesFromBlocks,
@@ -9568,7 +9568,7 @@ export {
9568
9568
  useStylingState,
9569
9569
  useTheme,
9570
9570
  useThemeOptions,
9571
- Ve as useTranslation,
9571
+ He as useTranslation,
9572
9572
  useUILibraryBlocks,
9573
9573
  useUndoManager,
9574
9574
  useUpdateBlocksProps,