@chaibuilder/sdk 2.1.8 → 2.2.0

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,6 +1,6 @@
1
1
  var G = Object.defineProperty;
2
2
  var K = (o, r, n) => r in o ? G(o, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[r] = n;
3
- var U = (o, r, n) => K(o, typeof r != "symbol" ? r + "" : r, n);
3
+ var V = (o, r, n) => K(o, typeof r != "symbol" ? r + "" : r, n);
4
4
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
5
5
  import * as React from "react";
6
6
  import React__default, { Component, Children, useEffect, useCallback, useMemo, useRef, useState, Suspense, createElement, memo, createContext, useContext, useReducer, useDebugValue } from "react";
@@ -10,7 +10,7 @@ import { find, filter, flatten, map, omit, isString, has, includes, without, get
10
10
  import { Provider as Provider$1 } from "react-wrap-balancer";
11
11
  import { atomWithStorage, splitAtom, useAtomCallback } from "jotai/utils";
12
12
  import { useTranslation, initReactI18next } from "react-i18next";
13
- import { useTranslation as Ve } from "react-i18next";
13
+ import { useTranslation as Ue } from "react-i18next";
14
14
  import { g as generateUUID, a as getBreakpointValue, c as cn$1 } from "./Functions-BGzDsf1z.js";
15
15
  import { flip } from "@floating-ui/dom";
16
16
  import { useFloating, shift } from "@floating-ui/react-dom";
@@ -18,7 +18,7 @@ import { PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, Plus
18
18
  import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
19
19
  import { useFeature, FlagsProvider } from "flagged";
20
20
  import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, useRegisteredChaiBlocks, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
21
- import { PlusIcon as PlusIcon$1, ChevronRight, AlertCircle, DatabaseIcon, ChevronLeft, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, X, Plus, PlusCircle, ChevronDown, Loader, SparklesIcon, Globe, SaveIcon, PencilIcon, EyeOffIcon, MoreVertical, Eye, ChevronsDown, ChevronsUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
21
+ import { PlusIcon as PlusIcon$1, ChevronRight, AlertCircle, DatabaseIcon, ChevronLeft, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, X, Plus, PlusCircle, ChevronDown, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, PencilIcon, EyeOffIcon, MoreVertical, Eye, ChevronsDown, ChevronsUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
22
22
  import RjForm from "@rjsf/core";
23
23
  import validator from "@rjsf/validator-ajv8";
24
24
  import Link from "@tiptap/extension-link";
@@ -31,7 +31,7 @@ import { twMerge } from "tailwind-merge";
31
31
  import Autosuggest from "react-autosuggest";
32
32
  import { toast } from "sonner";
33
33
  import Fuse from "fuse.js";
34
- import { d as defaultThemeOptions, g as getChaiThemeOptions, p as plugin, a as getChaiThemeCssVariables, c as getThemeFontsLinkMarkup, e as getThemeCustomFontFace } from "./chai-theme-helpers-CVkLfKt7.js";
34
+ import { d as defaultThemeOptions, h as hexToHSL, a as getChaiThemeCssVariables, g as getChaiThemeOptions, p as plugin, c as getThemeFontsLinkMarkup, e as getThemeCustomFontFace } from "./chai-theme-helpers-FO9vdd-R.js";
35
35
  import { S as STYLES_KEY, g as getSplitChaiClasses, R as ROOT_TEMP_KEY } from "./getSplitClasses-DphwgQiE.js";
36
36
  import UndoManager from "undo-manager";
37
37
  import { parse, stringify } from "himalaya";
@@ -42,10 +42,10 @@ import { ErrorBoundary } from "react-error-boundary";
42
42
  import { useHotkeys } from "react-hotkeys-hook";
43
43
  import { motion } from "framer-motion";
44
44
  import TreeModel from "tree-model";
45
- import aspectRatio from "@tailwindcss/aspect-ratio";
46
- import containerQueries from "@tailwindcss/container-queries";
47
- import forms from "@tailwindcss/forms";
48
- import typography from "@tailwindcss/typography";
45
+ import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
46
+ import twContainer from "@tailwindcss/container-queries";
47
+ import tailwindForms from "@tailwindcss/forms";
48
+ import tailwindTypography from "@tailwindcss/typography";
49
49
  import ReactDOM from "react-dom";
50
50
  import { Resizable } from "re-resizable";
51
51
  const readOnlyModeAtom = atom(!1);
@@ -103,17 +103,17 @@ const FrameContext = React__default.createContext({ document: doc, window: win }
103
103
  class Frame extends Component {
104
104
  constructor(n, a) {
105
105
  super(n, a);
106
- U(this, "setRef", (n) => {
106
+ V(this, "setRef", (n) => {
107
107
  this.nodeRef.current = n;
108
108
  const { forwardedRef: a } = this.props;
109
109
  typeof a == "function" ? a(n) : a && (a.current = n);
110
110
  });
111
- U(this, "handleLoad", () => {
111
+ V(this, "handleLoad", () => {
112
112
  clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
113
113
  });
114
114
  // In certain situations on a cold cache DOMContentLoaded never gets called
115
115
  // fallback to an interval to check if that's the case
116
- U(this, "loadCheck", () => setInterval(() => {
116
+ V(this, "loadCheck", () => setInterval(() => {
117
117
  this.handleLoad();
118
118
  }, 500));
119
119
  this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
@@ -150,7 +150,7 @@ class Frame extends Component {
150
150
  return delete n.head, delete n.initialContent, delete n.mountTarget, delete n.contentDidMount, delete n.contentDidUpdate, delete n.forwardedRef, /* @__PURE__ */ jsx("iframe", { ...n, ref: this.setRef, onLoad: this.handleLoad, children: this.state.iframeLoaded && this.renderFrameContents() });
151
151
  }
152
152
  }
153
- U(Frame, "defaultProps", {
153
+ V(Frame, "defaultProps", {
154
154
  style: {},
155
155
  head: null,
156
156
  children: void 0,
@@ -313,8 +313,8 @@ const useSelectedBlocksDisplayChild = () => ({
313
313
  m && "content" in m && (n = n.map((h) => {
314
314
  if (h._id === u) {
315
315
  const x = { ...h, content: f.content };
316
- return Object.keys(f).forEach((y) => {
317
- y.startsWith("content-") && (x[y] = f[y]);
316
+ return Object.keys(f).forEach((k) => {
317
+ k.startsWith("content-") && (x[k] = f[k]);
318
318
  }), x;
319
319
  }
320
320
  return h;
@@ -394,8 +394,8 @@ function insertBlocksAtPosition(o, r, n, a) {
394
394
  }), l.unshift(m), i = i.map((h) => {
395
395
  if (h._id === n) {
396
396
  const x = { ...h, content: "" };
397
- return Object.keys(x).forEach((y) => {
398
- y.startsWith("content-") && (x[y] = "");
397
+ return Object.keys(x).forEach((k) => {
398
+ k.startsWith("content-") && (x[k] = "");
399
399
  }), x;
400
400
  }
401
401
  return h;
@@ -702,50 +702,50 @@ const useUndoManager = () => {
702
702
  updateBlocksProps: c
703
703
  } = useBlocksStoreManager();
704
704
  return {
705
- moveBlocks: (x, y, b) => {
706
- const v = map(x, (j) => {
707
- const w = r.find((I) => I._id === j)._parent || null, B = r.filter((I) => w ? I._parent === w : !I._parent).map((I) => I._id).indexOf(j);
708
- return { _id: j, oldParent: w, oldPosition: B };
709
- }), S = v.find(({ _id: j }) => j === x[0]);
710
- S && S.oldParent === y && S.oldPosition === b || (i(x, y, b), o({
711
- undo: () => each(v, ({ _id: j, oldParent: E, oldPosition: w }) => {
712
- i([j], E, w);
705
+ moveBlocks: (x, k, b) => {
706
+ const S = map(x, (A) => {
707
+ const C = r.find((L) => L._id === A)._parent || null, _ = r.filter((L) => C ? L._parent === C : !L._parent).map((L) => L._id).indexOf(A);
708
+ return { _id: A, oldParent: C, oldPosition: _ };
709
+ }), w = S.find(({ _id: A }) => A === x[0]);
710
+ w && w.oldParent === k && w.oldPosition === b || (i(x, k, b), o({
711
+ undo: () => each(S, ({ _id: A, oldParent: E, oldPosition: C }) => {
712
+ i([A], E, C);
713
713
  }),
714
- redo: () => i(x, y, b)
714
+ redo: () => i(x, k, b)
715
715
  }));
716
716
  },
717
- addBlocks: (x, y, b) => {
718
- a(x, y, b), o({
717
+ addBlocks: (x, k, b) => {
718
+ a(x, k, b), o({
719
719
  undo: () => l(map(x, "_id")),
720
- redo: () => a(x, y, b)
720
+ redo: () => a(x, k, b)
721
721
  });
722
722
  },
723
723
  removeBlocks: (x) => {
724
- var S;
725
- const y = (S = first(x)) == null ? void 0 : S._parent, v = r.filter((j) => y ? j._parent === y : !j._parent).indexOf(first(x));
724
+ var w;
725
+ const k = (w = first(x)) == null ? void 0 : w._parent, S = r.filter((A) => k ? A._parent === k : !A._parent).indexOf(first(x));
726
726
  l(map(x, "_id")), o({
727
- undo: () => a(x, y, v),
727
+ undo: () => a(x, k, S),
728
728
  redo: () => l(map(x, "_id"))
729
729
  });
730
730
  },
731
- updateBlocks: (x, y, b) => {
732
- let v = [];
731
+ updateBlocks: (x, k, b) => {
732
+ let S = [];
733
733
  if (b)
734
- v = map(x, (S) => ({ _id: S, ...b }));
734
+ S = map(x, (w) => ({ _id: w, ...b }));
735
735
  else {
736
- const S = keys(y);
737
- v = map(x, (j) => {
738
- const E = r.find((A) => A._id === j), w = { _id: j };
739
- return each(S, (A) => w[A] = E[A]), w;
736
+ const w = keys(k);
737
+ S = map(x, (A) => {
738
+ const E = r.find((B) => B._id === A), C = { _id: A };
739
+ return each(w, (B) => C[B] = E[B]), C;
740
740
  });
741
741
  }
742
- c(map(x, (S) => ({ _id: S, ...y }))), o({
743
- undo: () => c(v),
744
- redo: () => c(map(x, (S) => ({ _id: S, ...y })))
742
+ c(map(x, (w) => ({ _id: w, ...k }))), o({
743
+ undo: () => c(S),
744
+ redo: () => c(map(x, (w) => ({ _id: w, ...k })))
745
745
  });
746
746
  },
747
- updateBlocksRuntime: (x, y) => {
748
- c(map(x, (b) => ({ _id: b, ...y })));
747
+ updateBlocksRuntime: (x, k) => {
748
+ c(map(x, (b) => ({ _id: b, ...k })));
749
749
  },
750
750
  setNewBlocks: (x) => {
751
751
  n(x), o({
@@ -754,12 +754,12 @@ const useUndoManager = () => {
754
754
  });
755
755
  },
756
756
  updateMultipleBlocksProps: (x) => {
757
- let y = [];
758
- y = map(x, (b) => {
759
- const v = keys(b), S = r.find((E) => E._id === b._id), j = {};
760
- return each(v, (E) => j[E] = S[E]), j;
757
+ let k = [];
758
+ k = map(x, (b) => {
759
+ const S = keys(b), w = r.find((E) => E._id === b._id), A = {};
760
+ return each(S, (E) => A[E] = w[E]), A;
761
761
  }), c(x), o({
762
- undo: () => c(y),
762
+ undo: () => c(k),
763
763
  redo: () => c(x)
764
764
  });
765
765
  }
@@ -824,9 +824,9 @@ const useAddBlock = () => {
824
824
  for (let h = 0; h < i.length; h++) {
825
825
  const { _id: x } = i[h];
826
826
  i[h]._id = generateUUID();
827
- const y = filter(i, { _parent: x });
828
- for (let b = 0; b < y.length; b++)
829
- y[b]._parent = i[h]._id;
827
+ const k = filter(i, { _parent: x });
828
+ for (let b = 0; b < k.length; b++)
829
+ k[b]._parent = i[h]._id;
830
830
  }
831
831
  const p = first(i);
832
832
  let u, g;
@@ -837,8 +837,8 @@ const useAddBlock = () => {
837
837
  return { addCoreBlock: useCallback(
838
838
  (i, c, d) => {
839
839
  if (has(i, "blocks")) {
840
- const y = i.blocks;
841
- return a(y, c, d);
840
+ const k = i.blocks;
841
+ return a(k, c, d);
842
842
  }
843
843
  const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
844
844
  _type: i.type,
@@ -2295,42 +2295,42 @@ const getBlockWithChildren = (o, r) => {
2295
2295
  })
2296
2296
  ), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2297
2297
  const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, f = (m, h) => {
2298
- const x = cloneDeep(h.find((y) => y._id === m));
2299
- for (const y in x) {
2300
- const b = x[y];
2298
+ const x = cloneDeep(h.find((k) => k._id === m));
2299
+ for (const k in x) {
2300
+ const b = x[k];
2301
2301
  if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
2302
- const { baseClasses: v, classes: S } = getSplitChaiClasses(b);
2303
- x[y] = compact(flattenDeep([v, S])).join(" ");
2302
+ const { baseClasses: S, classes: w } = getSplitChaiClasses(b);
2303
+ x[k] = compact(flattenDeep([S, w])).join(" ");
2304
2304
  } else
2305
- y !== "_id" && delete x[y];
2305
+ k !== "_id" && delete x[k];
2306
2306
  }
2307
2307
  return x;
2308
2308
  };
2309
2309
  return {
2310
2310
  askAi: useCallback(
2311
- async (m, h, x, y) => {
2311
+ async (m, h, x, k) => {
2312
2312
  if (l) {
2313
2313
  r(!0), a(null);
2314
2314
  try {
2315
- const b = p === u ? "" : p, v = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, d)), p) : [f(h, d)], S = await l(m, addLangToPrompt(x, g, m), v, b), { blocks: j, error: E } = S;
2315
+ const b = p === u ? "" : p, S = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, d)), p) : [f(h, d)], w = await l(m, addLangToPrompt(x, g, m), S, b), { blocks: A, error: E } = w;
2316
2316
  if (E) {
2317
2317
  a(E);
2318
2318
  return;
2319
2319
  }
2320
2320
  if (m === "styles") {
2321
- const w = j.map((A) => {
2322
- for (const B in A)
2323
- B !== "_id" && (A[B] = `${STYLES_KEY},${A[B]}`);
2324
- return A;
2321
+ const C = A.map((B) => {
2322
+ for (const _ in B)
2323
+ _ !== "_id" && (B[_] = `${STYLES_KEY},${B[_]}`);
2324
+ return B;
2325
2325
  });
2326
- c(w);
2326
+ c(C);
2327
2327
  } else
2328
- i(j);
2329
- y && y(S);
2328
+ i(A);
2329
+ k && k(w);
2330
2330
  } catch (b) {
2331
2331
  a(b);
2332
2332
  } finally {
2333
- r(!1), y && y();
2333
+ r(!1), k && k();
2334
2334
  }
2335
2335
  }
2336
2336
  },
@@ -2699,8 +2699,8 @@ const CONTROLS = [
2699
2699
  return useHotkeys(
2700
2700
  "shift+up, shift+down, shift+left, shift+right",
2701
2701
  ({ key: x }) => {
2702
- var y;
2703
- h((y = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : y.toUpperCase());
2702
+ var k;
2703
+ h((k = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : k.toUpperCase());
2704
2704
  },
2705
2705
  { document: a == null ? void 0 : a.contentDocument },
2706
2706
  [h]
@@ -2729,7 +2729,7 @@ const CONTROLS = [
2729
2729
  };
2730
2730
  class PubSub {
2731
2731
  constructor() {
2732
- U(this, "subscribers", /* @__PURE__ */ new Map());
2732
+ V(this, "subscribers", /* @__PURE__ */ new Map());
2733
2733
  }
2734
2734
  subscribe(r, n) {
2735
2735
  return this.subscribers.has(r) || this.subscribers.set(r, /* @__PURE__ */ new Set()), this.subscribers.get(r).add(n), () => {
@@ -2794,13 +2794,13 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: r }) => {
2794
2794
  tabIndex: 0,
2795
2795
  ref: f.setFloating,
2796
2796
  style: g,
2797
- onClick: (y) => {
2798
- y.stopPropagation(), y.preventDefault();
2797
+ onClick: (k) => {
2798
+ k.stopPropagation(), k.preventDefault();
2799
2799
  },
2800
- onMouseEnter: (y) => {
2801
- y.stopPropagation(), i(null);
2800
+ onMouseEnter: (k) => {
2801
+ k.stopPropagation(), i(null);
2802
2802
  },
2803
- onKeyDown: (y) => y.stopPropagation(),
2803
+ onKeyDown: (k) => k.stopPropagation(),
2804
2804
  className: "isolate z-[999] flex h-6 items-center bg-primary py-2 text-xs text-white",
2805
2805
  children: [
2806
2806
  h && /* @__PURE__ */ jsx(
@@ -2979,25 +2979,25 @@ const useDnd = () => {
2979
2979
  },
2980
2980
  onDrop: (m) => {
2981
2981
  var E;
2982
- const h = dropTarget, y = getOrientation(h) === "vertical" ? m.clientY + ((E = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : E.scrollY) : m.clientX;
2983
- dropIndex = calculateDropIndex(y, possiblePositions);
2984
- const b = d, v = h.getAttribute("data-block-id"), S = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
2985
- if ((b == null ? void 0 : b._id) === v || !S) {
2982
+ const h = dropTarget, k = getOrientation(h) === "vertical" ? m.clientY + ((E = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : E.scrollY) : m.clientX;
2983
+ dropIndex = calculateDropIndex(k, possiblePositions);
2984
+ const b = d, S = h.getAttribute("data-block-id"), w = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
2985
+ if ((b == null ? void 0 : b._id) === S || !w) {
2986
2986
  f();
2987
2987
  return;
2988
2988
  }
2989
2989
  if (!has(b, "_id")) {
2990
- a(b, v === "canvas" ? null : v, dropIndex), setTimeout(f, 300);
2990
+ a(b, S === "canvas" ? null : S, dropIndex), setTimeout(f, 300);
2991
2991
  return;
2992
2992
  }
2993
- let j = h.getAttribute("data-block-id");
2994
- j === null && (j = m.target.parentElement.getAttribute("data-block-id")), c([b._id], j === "canvas" ? null : j, dropIndex), f(), setTimeout(removePlaceholder, 300);
2993
+ let A = h.getAttribute("data-block-id");
2994
+ A === null && (A = m.target.parentElement.getAttribute("data-block-id")), c([b._id], A === "canvas" ? null : A, dropIndex), f(), setTimeout(removePlaceholder, 300);
2995
2995
  },
2996
2996
  onDragEnter: (m) => {
2997
2997
  const h = m, x = h.target;
2998
2998
  dropTarget = x;
2999
- const y = x.getAttribute("data-block-id"), b = x.getAttribute("data-dnd-dragged") !== "yes";
3000
- u(y), h.stopPropagation(), h.preventDefault(), possiblePositions = [], b && calculatePossiblePositions(x), n(!0), l(""), i([]);
2999
+ const k = x.getAttribute("data-block-id"), b = x.getAttribute("data-dnd-dragged") !== "yes";
3000
+ u(k), h.stopPropagation(), h.preventDefault(), possiblePositions = [], b && calculatePossiblePositions(x), n(!0), l(""), i([]);
3001
3001
  },
3002
3002
  onDragLeave: (m) => {
3003
3003
  m.target.getAttribute("data-block-id") === "canvas" && (u(null), n(!1), removePlaceholder(), possiblePositions = []);
@@ -3075,8 +3075,8 @@ const useHandleCanvasDblClick = (o, r) => {
3075
3075
  if (h) {
3076
3076
  const x = h.getAttribute("data-style-prop");
3077
3077
  if (x) {
3078
- const y = h.getAttribute("data-style-id"), b = h.getAttribute("data-block-parent");
3079
- l([{ id: y, prop: x, blockId: b }]);
3078
+ const k = h.getAttribute("data-style-id"), b = h.getAttribute("data-block-parent");
3079
+ l([{ id: k, prop: x, blockId: b }]);
3080
3080
  }
3081
3081
  }
3082
3082
  }, 100);
@@ -3098,7 +3098,21 @@ const useHandleCanvasDblClick = (o, r) => {
3098
3098
  children: o
3099
3099
  }
3100
3100
  );
3101
- }, getElementByDataBlockId = (o, r) => o.querySelector(`[data-block-id="${r}"]`), HeadTags = () => {
3101
+ }, getElementByDataBlockId = (o, r) => o.querySelector(`[data-block-id="${r}"]`), CssThemeVariables = () => {
3102
+ const [o] = useTheme(), r = useMemo(() => getChaiThemeCssVariables(o), [o]);
3103
+ return /* @__PURE__ */ jsx("style", { id: "chai-theme", children: r });
3104
+ }, PrimaryColorCSSVariable = () => {
3105
+ const [o] = useTheme(), r = get(o, "colors.primary", ["#2563EB", "#3B82F6"]), n = get(o, "colors.primary-foreground", ["#ffffff", "#ffffff"]);
3106
+ return /* @__PURE__ */ jsx("style", { id: "chai-theme", children: `:root {
3107
+ --primary: ${hexToHSL(r[0])};
3108
+ --primary-foreground: ${hexToHSL(n[0])};
3109
+
3110
+ .dark {
3111
+ --primary: ${hexToHSL(r[1])};
3112
+ --primary-foreground: ${hexToHSL(n[1])};
3113
+ }
3114
+ }` });
3115
+ }, HeadTags = () => {
3102
3116
  const [o] = useTheme(), r = useThemeOptions(), [n] = useSelectedBlockIds(), [a] = useDarkMode(), [l] = useSelectedStylingBlocks(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), { document: d, window: p } = useFrame(), [u] = useState(d == null ? void 0 : d.getElementById("highlighted-block")), [g] = useState(
3103
3117
  d == null ? void 0 : d.getElementById("selected-block")
3104
3118
  ), [f] = useState(
@@ -3126,19 +3140,19 @@ const useHandleCanvasDblClick = (o, r) => {
3126
3140
  }
3127
3141
  },
3128
3142
  plugins: [
3129
- typography,
3130
- forms,
3131
- aspectRatio,
3132
- containerQueries,
3133
- plugin(function({ addBase: S, theme: j }) {
3143
+ tailwindTypography,
3144
+ tailwindForms,
3145
+ tailwindAspectRatio,
3146
+ twContainer,
3147
+ plugin(function({ addBase: S, theme: w }) {
3134
3148
  S({
3135
3149
  "h1,h2,h3,h4,h5,h6": {
3136
- fontFamily: j("fontFamily.heading")
3150
+ fontFamily: w("fontFamily.heading")
3137
3151
  },
3138
3152
  body: {
3139
- fontFamily: j("fontFamily.body"),
3140
- color: j("colors.foreground"),
3141
- backgroundColor: j("colors.background")
3153
+ fontFamily: w("fontFamily.body"),
3154
+ color: w("colors.foreground"),
3155
+ backgroundColor: w("colors.background")
3142
3156
  }
3143
3157
  });
3144
3158
  })
@@ -3159,20 +3173,20 @@ const useHandleCanvasDblClick = (o, r) => {
3159
3173
  }, [l, f]), useEffect(() => {
3160
3174
  d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
3161
3175
  }, [c, d]);
3162
- const x = useMemo(() => getChaiThemeCssVariables(o), [o]), y = useMemo(() => {
3163
- const { heading: S, body: j } = {
3176
+ const x = useMemo(() => {
3177
+ const { heading: S, body: w } = {
3164
3178
  heading: get(o, "fontFamily.heading"),
3165
3179
  body: get(o, "fontFamily.body")
3166
3180
  };
3167
- return h.filter((E) => E.family === S || E.family === j);
3168
- }, [o == null ? void 0 : o.fontFamily, h]), b = useMemo(() => getThemeFontsLinkMarkup(filter(y, (S) => has(S, "url"))), [y]), v = useMemo(
3169
- () => getThemeCustomFontFace(filter(y, (S) => has(S, "src"))),
3170
- [y]
3181
+ return h.filter((A) => A.family === S || A.family === w);
3182
+ }, [o == null ? void 0 : o.fontFamily, h]), k = useMemo(() => getThemeFontsLinkMarkup(filter(x, (S) => has(S, "url"))), [x]), b = useMemo(
3183
+ () => getThemeCustomFontFace(filter(x, (S) => has(S, "src"))),
3184
+ [x]
3171
3185
  );
3172
3186
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3173
- /* @__PURE__ */ jsx("style", { id: "chai-theme", children: x }),
3174
- /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: b } }),
3175
- /* @__PURE__ */ jsx("style", { id: "chai-custom-fonts", dangerouslySetInnerHTML: { __html: v } })
3187
+ /* @__PURE__ */ jsx(CssThemeVariables, {}),
3188
+ /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: k } }),
3189
+ /* @__PURE__ */ jsx("style", { id: "chai-custom-fonts", dangerouslySetInnerHTML: { __html: b } })
3176
3190
  ] });
3177
3191
  }, ResizableCanvasWrapper = ({ children: o, onMount: r, onResize: n }) => {
3178
3192
  const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
@@ -3255,7 +3269,7 @@ const getBlockRuntimeProps = memoize((o) => {
3255
3269
  ), m = useMemo(() => getBlockTagAttributes(n), [n, getBlockTagAttributes]), h = useMemo(
3256
3270
  () => c(n._id, getBlockRuntimeProps(n._type)),
3257
3271
  [n._id, n._type, c, getBlockRuntimeProps]
3258
- ), x = useMemo(() => !has(a, "dataProvider") || !isFunction(a.dataProvider) ? {} : a.dataProvider(n, l), [n, l, a]), y = useMemo(
3272
+ ), x = useMemo(() => !has(a, "dataProvider") || !isFunction(a.dataProvider) ? {} : a.dataProvider(n, l), [n, l, a]), k = useMemo(
3259
3273
  () => ({
3260
3274
  blockProps: {
3261
3275
  "data-block-id": n._id,
@@ -3279,7 +3293,7 @@ const getBlockRuntimeProps = memoize((o) => {
3279
3293
  x
3280
3294
  ]
3281
3295
  );
3282
- return isNull(g) || p.includes(n._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...y, children: r }) });
3296
+ return isNull(g) || p.includes(n._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...k, children: r }) });
3283
3297
  }, PartialBlocksRenderer = ({ partialBlockId: o }) => {
3284
3298
  const { getPartailBlocks: r } = usePartailBlocksStore(), n = useMemo(() => r(o), [r, o]), a = useMemo(() => splitAtom(atom(n)), [n]);
3285
3299
  return isEmpty(n) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: n });
@@ -3329,43 +3343,43 @@ const getBlockRuntimeProps = memoize((o) => {
3329
3343
  c();
3330
3344
  }, [r, o, n, c]), l;
3331
3345
  }, getElementByStyleId = (o, r) => o.querySelector(`[data-style-id="${r}"]`), StaticCanvas = () => {
3332
- const [o] = useAtom$1(networkModeAtom), [r] = useCanvasDisplayWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, f] = useState([]), [, m] = useState([]), [, h] = useAtom$1(canvasIframeAtom), [x, y] = useSelectedStylingBlocks(), b = useBuilderProp("loading", !1), v = useBuilderProp("htmlDir", "ltr"), S = (w) => {
3333
- p((A) => ({ ...A, width: w }));
3346
+ const [o] = useAtom$1(networkModeAtom), [r] = useCanvasDisplayWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, f] = useState([]), [, m] = useState([]), [, h] = useAtom$1(canvasIframeAtom), [x, k] = useSelectedStylingBlocks(), b = useBuilderProp("loading", !1), S = useBuilderProp("htmlDir", "ltr"), w = (C) => {
3347
+ p((B) => ({ ...B, width: C }));
3334
3348
  };
3335
3349
  useEffect(() => {
3336
3350
  if (!c.current) return;
3337
- const { clientWidth: w, clientHeight: A } = c.current;
3338
- p({ width: w, height: A });
3351
+ const { clientWidth: C, clientHeight: B } = c.current;
3352
+ p({ width: C, height: B });
3339
3353
  }, [c, r]);
3340
- const j = (w, A = 0) => {
3341
- const { top: B } = w.getBoundingClientRect();
3342
- return B + A >= 0 && B - A <= window.innerHeight;
3354
+ const A = (C, B = 0) => {
3355
+ const { top: _ } = C.getBoundingClientRect();
3356
+ return _ + B >= 0 && _ - B <= window.innerHeight;
3343
3357
  };
3344
3358
  useEffect(() => {
3345
- var w, A;
3359
+ var C, B;
3346
3360
  if (a && a.type !== "Multiple" && i.current) {
3347
- const B = getElementByDataBlockId(i.current.contentDocument, a._id);
3348
- B && (j(B) || (A = (w = i.current) == null ? void 0 : w.contentWindow) == null || A.scrollTo({ top: B.offsetTop, behavior: "smooth" }), f([B]));
3361
+ const _ = getElementByDataBlockId(i.current.contentDocument, a._id);
3362
+ _ && (A(_) || (B = (C = i.current) == null ? void 0 : C.contentWindow) == null || B.scrollTo({ top: _.offsetTop, behavior: "smooth" }), f([_]));
3349
3363
  }
3350
3364
  }, [a]), useEffect(() => {
3351
3365
  if (!isEmpty(x) && i.current) {
3352
- const w = getElementByStyleId(
3366
+ const C = getElementByStyleId(
3353
3367
  i.current.contentDocument,
3354
3368
  first(x).id
3355
3369
  );
3356
- m(w ? [w] : [null]);
3370
+ m(C ? [C] : [null]);
3357
3371
  } else
3358
3372
  m([null]);
3359
3373
  }, [x]);
3360
3374
  const E = useMemo(() => {
3361
- let w = IframeInitialContent;
3362
- return w = w.replace("__HTML_DIR__", v), o === "offline" && (w = w.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), w;
3363
- }, [o, v]);
3364
- return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: S, onResize: S, children: /* @__PURE__ */ jsx(
3375
+ let C = IframeInitialContent;
3376
+ return C = C.replace("__HTML_DIR__", S), o === "offline" && (C = C.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), C;
3377
+ }, [o, S]);
3378
+ return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: w, onResize: w, children: /* @__PURE__ */ jsx(
3365
3379
  "div",
3366
3380
  {
3367
3381
  onClick: () => {
3368
- n([]), y([]);
3382
+ n([]), k([]);
3369
3383
  },
3370
3384
  onMouseLeave: () => setTimeout(() => l(""), 300),
3371
3385
  className: "relative mx-auto h-full w-full overflow-hidden",
@@ -3517,8 +3531,8 @@ const getBlockRuntimeProps = memoize((o) => {
3517
3531
  p(!1), g("Invalid asset URL");
3518
3532
  return;
3519
3533
  }
3520
- const y = x.headers.get("content-type") || "";
3521
- n === "image" && y.startsWith("image/") || n === "video" && y.startsWith("video/") || n === "audio" && y.startsWith("audio/") ? (p(!0), g(null)) : (p(!1), g(`URL does not point to a valid ${n} file`));
3534
+ const k = x.headers.get("content-type") || "";
3535
+ n === "image" && k.startsWith("image/") || n === "video" && k.startsWith("video/") || n === "audio" && k.startsWith("audio/") ? (p(!0), g(null)) : (p(!1), g(`URL does not point to a valid ${n} file`));
3522
3536
  } catch {
3523
3537
  p(!1), g("Error validating URL");
3524
3538
  } finally {
@@ -3599,14 +3613,14 @@ function NestedPathSelector({ data: o, onSelect: r, dataType: n = "value" }) {
3599
3613
  }, [a, o]);
3600
3614
  const u = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", g = React.useCallback(
3601
3615
  (h) => {
3602
- const x = (y) => n === "value" ? y === "value" || y === "object" : n === "array" ? y === "array" : y === n;
3603
- h.type === "object" ? (c((y) => [...y, h.key]), p(h.value)) : x(h.type) && (r([...i, h.key].join(".")), l(!1));
3616
+ const x = (k) => n === "value" ? k === "value" || k === "object" : n === "array" ? k === "array" : k === n;
3617
+ h.type === "object" ? (c((k) => [...k, h.key]), p(h.value)) : x(h.type) && (r([...i, h.key].join(".")), l(!1));
3604
3618
  },
3605
3619
  [i, r, n]
3606
3620
  ), f = React.useCallback(() => {
3607
3621
  if (i.length > 0) {
3608
3622
  const h = i.slice(0, -1);
3609
- c(h), p(h.reduce((x, y) => x[y], o));
3623
+ c(h), p(h.reduce((x, k) => x[k], o));
3610
3624
  }
3611
3625
  }, [i, o]), m = React.useMemo(() => Object.entries(d).map(([h, x]) => ({
3612
3626
  key: h,
@@ -3881,11 +3895,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
3881
3895
  if (h !== x)
3882
3896
  u.chain().deleteSelection().insertContent(m).run();
3883
3897
  else {
3884
- const { state: b } = u, v = b.selection.from, S = b.doc.textBetween(Math.max(0, v - 1), v), j = b.doc.textBetween(v, Math.min(v + 1, b.doc.content.size));
3898
+ const { state: b } = u, S = b.selection.from, w = b.doc.textBetween(Math.max(0, S - 1), S), A = b.doc.textBetween(S, Math.min(S + 1, b.doc.content.size));
3885
3899
  let E = "";
3886
- v > 0 && S !== " " && !/[.,!?;:]/.test(S) && (E = " ");
3887
- let w = "";
3888
- j && j !== " " && !/[.,!?;:]/.test(j) && (w = " "), u.chain().insertContent(E + m + w).run();
3900
+ S > 0 && w !== " " && !/[.,!?;:]/.test(w) && (E = " ");
3901
+ let C = "";
3902
+ A && A !== " " && !/[.,!?;:]/.test(A) && (C = " "), u.chain().insertContent(E + m + C).run();
3889
3903
  }
3890
3904
  };
3891
3905
  return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (f) => !f && r(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
@@ -3966,74 +3980,74 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
3966
3980
  pageTypes: r,
3967
3981
  onChange: n
3968
3982
  }) => {
3969
- var I;
3970
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [f, m] = useState(""), [h, x] = useState([]), [y, b] = useState(-1), v = useRef(null), S = (I = r == null ? void 0 : r.find((C) => C.key === u)) == null ? void 0 : I.name;
3983
+ var L;
3984
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [f, m] = useState(""), [h, x] = useState([]), [k, b] = useState(-1), S = useRef(null), w = (L = r == null ? void 0 : r.find((v) => v.key === u)) == null ? void 0 : L.name;
3971
3985
  useEffect(() => {
3972
3986
  if (m(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
3973
- const C = split(o, ":"), k = get(C, 1, "page") || "page";
3974
- g(k), (async () => {
3975
- const _ = await l(k, [get(C, 2, "page")]);
3976
- _ && Array.isArray(_) && m(get(_, [0, "name"], ""));
3987
+ const v = split(o, ":"), y = get(v, 1, "page") || "page";
3988
+ g(y), (async () => {
3989
+ const j = await l(y, [get(v, 2, "page")]);
3990
+ j && Array.isArray(j) && m(get(j, [0, "name"], ""));
3977
3991
  })();
3978
3992
  }, [o]);
3979
- const j = useDebouncedCallback(
3980
- async (C) => {
3981
- if (isEmpty(C))
3993
+ const A = useDebouncedCallback(
3994
+ async (v) => {
3995
+ if (isEmpty(v))
3982
3996
  x([]);
3983
3997
  else {
3984
- const k = await l(u, C);
3985
- x(k);
3998
+ const y = await l(u, v);
3999
+ x(y);
3986
4000
  }
3987
4001
  c(!1), b(-1);
3988
4002
  },
3989
4003
  [u],
3990
4004
  300
3991
- ), E = (C) => {
3992
- const k = ["pageType", u, C.id];
3993
- k[1] && (n(k.join(":")), m(C.name), p(!1), x([]), b(-1));
3994
- }, w = (C) => {
3995
- switch (C.key) {
4005
+ ), E = (v) => {
4006
+ const y = ["pageType", u, v.id];
4007
+ y[1] && (n(y.join(":")), m(v.name), p(!1), x([]), b(-1));
4008
+ }, C = (v) => {
4009
+ switch (v.key) {
3996
4010
  case "ArrowDown":
3997
- C.preventDefault(), b((k) => k < h.length - 1 ? k + 1 : k);
4011
+ v.preventDefault(), b((y) => y < h.length - 1 ? y + 1 : y);
3998
4012
  break;
3999
4013
  case "ArrowUp":
4000
- C.preventDefault(), b((k) => k > 0 ? k - 1 : k);
4014
+ v.preventDefault(), b((y) => y > 0 ? y - 1 : y);
4001
4015
  break;
4002
4016
  case "Enter":
4003
- if (C.preventDefault(), h.length === 0) return;
4004
- y >= 0 && E(h[y]);
4017
+ if (v.preventDefault(), h.length === 0) return;
4018
+ k >= 0 && E(h[k]);
4005
4019
  break;
4006
4020
  case "Escape":
4007
- C.preventDefault(), A();
4021
+ v.preventDefault(), B();
4008
4022
  break;
4009
4023
  }
4010
4024
  };
4011
4025
  useEffect(() => {
4012
- if (y >= 0 && v.current) {
4013
- const C = v.current.children[y];
4014
- C == null || C.scrollIntoView({ block: "nearest" });
4026
+ if (k >= 0 && S.current) {
4027
+ const v = S.current.children[k];
4028
+ v == null || v.scrollIntoView({ block: "nearest" });
4015
4029
  }
4016
- }, [y]);
4017
- const A = () => {
4030
+ }, [k]);
4031
+ const B = () => {
4018
4032
  m(""), x([]), b(-1), p(!1), n("");
4019
- }, B = (C) => {
4020
- m(C), p(!isEmpty(C)), c(!0), j(C);
4033
+ }, _ = (v) => {
4034
+ m(v), p(!isEmpty(v)), c(!0), A(v);
4021
4035
  };
4022
4036
  return /* @__PURE__ */ jsxs("div", { children: [
4023
- /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (C) => g(C.target.value), children: map(r, (C) => /* @__PURE__ */ jsx("option", { value: C.key, children: C.name }, C.key)) }),
4037
+ /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (v) => g(v.target.value), children: map(r, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
4024
4038
  u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
4025
4039
  /* @__PURE__ */ jsx(
4026
4040
  "input",
4027
4041
  {
4028
4042
  type: "text",
4029
4043
  value: f,
4030
- onChange: (C) => B(C.target.value),
4031
- onKeyDown: w,
4032
- placeholder: a(`Search ${S ?? ""}`),
4044
+ onChange: (v) => _(v.target.value),
4045
+ onKeyDown: C,
4046
+ placeholder: a(`Search ${w ?? ""}`),
4033
4047
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4034
4048
  }
4035
4049
  ),
4036
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: f && /* @__PURE__ */ jsx("button", { onClick: A, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4050
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: f && /* @__PURE__ */ jsx("button", { onClick: B, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4037
4051
  ] }),
4038
4052
  (i || !isEmpty(h) || d && isEmpty(h)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
4039
4053
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -4043,22 +4057,22 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4043
4057
  ' "',
4044
4058
  f,
4045
4059
  '"'
4046
- ] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(h == null ? void 0 : h.slice(0, 20), (C, k) => /* @__PURE__ */ jsxs(
4060
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: S, children: map(h == null ? void 0 : h.slice(0, 20), (v, y) => /* @__PURE__ */ jsxs(
4047
4061
  "li",
4048
4062
  {
4049
- onClick: () => E(C),
4050
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(C.id) ? "bg-blue-200" : k === y ? "bg-gray-100" : "hover:bg-gray-100"}`,
4063
+ onClick: () => E(v),
4064
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : y === k ? "bg-gray-100" : "hover:bg-gray-100"}`,
4051
4065
  children: [
4052
- C.name,
4066
+ v.name,
4053
4067
  " ",
4054
- C.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4068
+ v.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4055
4069
  "( ",
4056
- C.slug,
4070
+ v.slug,
4057
4071
  " )"
4058
4072
  ] })
4059
4073
  ]
4060
4074
  },
4061
- C.id
4075
+ v.id
4062
4076
  )) }) })
4063
4077
  ] });
4064
4078
  }, LinkField = ({ schema: o, formData: r, onChange: n }) => {
@@ -4143,14 +4157,14 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4143
4157
  const f = () => {
4144
4158
  const x = findIndex(u, { _id: g });
4145
4159
  if (x > -1) {
4146
- const y = (x + 1) % u.length, b = get(u, [y, "_id"]);
4160
+ const k = (x + 1) % u.length, b = get(u, [k, "_id"]);
4147
4161
  if (!b) return;
4148
4162
  r({ ...o, currentSlide: b }), c([b]);
4149
4163
  }
4150
4164
  }, m = () => {
4151
4165
  const x = findIndex(u, { _id: g });
4152
4166
  if (x > -1) {
4153
- const y = (x - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
4167
+ const k = (x - 1 + u.length) % u.length, b = get(u, [k, "_id"]);
4154
4168
  if (!b) return;
4155
4169
  r({ ...o, currentSlide: b }), c([b]);
4156
4170
  }
@@ -4158,8 +4172,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4158
4172
  const x = i(
4159
4173
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4160
4174
  p == null ? void 0 : p._id
4161
- ), y = x == null ? void 0 : x._id;
4162
- y && (r({ ...o, currentSlide: y }), c([y]));
4175
+ ), k = x == null ? void 0 : x._id;
4176
+ k && (r({ ...o, currentSlide: k }), c([k]));
4163
4177
  };
4164
4178
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4165
4179
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
@@ -4238,8 +4252,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4238
4252
  className: "text-xs",
4239
4253
  pattern: "[0-9]*",
4240
4254
  onChange: (x) => {
4241
- let y = x.target.value;
4242
- y.length && (y = y.replace("-", "")), r({ ...o, autoplayInterval: y });
4255
+ let k = x.target.value;
4256
+ k.length && (k = k.replace("-", "")), r({ ...o, autoplayInterval: k });
4243
4257
  }
4244
4258
  }
4245
4259
  )
@@ -4341,65 +4355,65 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4341
4355
  formData: g,
4342
4356
  onChange: f
4343
4357
  }) => {
4344
- const { selectedLang: m, fallbackLang: h, languages: x } = useLanguages(), y = isEmpty(x) ? "" : isEmpty(m) ? h : m, b = get(LANGUAGES, y, y), v = usePageExternalData(), S = useSelectedBlock(), j = useRegisteredChaiBlocks(), E = get(j, [S == null ? void 0 : S._type, "i18nProps"], []) || [], [w, A] = useState(null), B = useCallback(
4345
- (k) => {
4346
- const _ = (N) => /[.,!?;:]/.test(N), T = (N, D, O) => {
4358
+ const { selectedLang: m, fallbackLang: h, languages: x } = useLanguages(), k = isEmpty(x) ? "" : isEmpty(m) ? h : m, b = get(LANGUAGES, k, k), S = usePageExternalData(), w = useSelectedBlock(), A = useRegisteredChaiBlocks(), E = get(A, [w == null ? void 0 : w._type, "i18nProps"], []) || [], [C, B] = useState(null), _ = useCallback(
4359
+ (y) => {
4360
+ const j = (N) => /[.,!?;:]/.test(N), T = (N, D, O) => {
4347
4361
  let R = "", $ = "";
4348
4362
  const M = D > 0 ? N[D - 1] : "", H = D < N.length ? N[D] : "";
4349
- return D > 0 && (M === "." || !_(M) && M !== " ") && (R = " "), D < N.length && !_(H) && H !== " " && ($ = " "), {
4363
+ return D > 0 && (M === "." || !j(M) && M !== " ") && (R = " "), D < N.length && !j(H) && H !== " " && ($ = " "), {
4350
4364
  text: R + O + $,
4351
4365
  prefixLength: R.length,
4352
4366
  suffixLength: $.length
4353
4367
  };
4354
- }, L = document.getElementById(o);
4355
- if (!L) return;
4368
+ }, I = document.getElementById(o);
4369
+ if (!I) return;
4356
4370
  const P = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
4357
4371
  if (P && (P.querySelector(".ProseMirror") || P.__chaiRTE)) {
4358
4372
  const N = P.__chaiRTE;
4359
4373
  if (N) {
4360
- const D = `{{${k}}}`;
4374
+ const D = `{{${y}}}`;
4361
4375
  N.commands.focus();
4362
4376
  const { from: O, to: R } = N.state.selection;
4363
4377
  if (O !== R)
4364
4378
  N.chain().deleteSelection().insertContent(D).run();
4365
4379
  else {
4366
- const { state: M } = N, H = M.selection.from, F = M.doc.textBetween(Math.max(0, H - 1), H), V = M.doc.textBetween(H, Math.min(H + 1, M.doc.content.size));
4380
+ 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));
4367
4381
  let z = "";
4368
- H > 0 && F !== " " && !_(F) && (z = " ");
4382
+ H > 0 && F !== " " && !j(F) && (z = " ");
4369
4383
  let W = "";
4370
- V && V !== " " && !_(V) && (W = " "), N.chain().insertContent(z + D + W).run();
4384
+ U && U !== " " && !j(U) && (W = " "), N.chain().insertContent(z + D + W).run();
4371
4385
  }
4372
4386
  setTimeout(() => f(N.getHTML(), {}, o), 100);
4373
4387
  return;
4374
4388
  }
4375
4389
  } else {
4376
- const N = L, D = N.selectionStart || 0, O = N.value || "", R = N.selectionEnd || D;
4390
+ const N = I, D = N.selectionStart || 0, O = N.value || "", R = N.selectionEnd || D;
4377
4391
  if (R > D) {
4378
- const V = `{{${k}}}`, { text: z } = T(O, D, V), W = O.slice(0, D) + z + O.slice(R);
4392
+ const U = `{{${y}}}`, { text: z } = T(O, D, U), W = O.slice(0, D) + z + O.slice(R);
4379
4393
  f(W, {}, o);
4380
4394
  return;
4381
4395
  }
4382
- const M = `{{${k}}}`, { text: H } = T(O, D, M), F = O.slice(0, D) + H + O.slice(D);
4396
+ const M = `{{${y}}}`, { text: H } = T(O, D, M), F = O.slice(0, D) + H + O.slice(D);
4383
4397
  f(F, {}, o);
4384
4398
  }
4385
4399
  },
4386
- [o, f, g, S == null ? void 0 : S._id]
4400
+ [o, f, g, w == null ? void 0 : w._id]
4387
4401
  );
4388
4402
  if (d)
4389
4403
  return null;
4390
4404
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: a });
4391
- const C = E == null ? void 0 : E.includes(o.replace("root.", ""));
4405
+ const v = E == null ? void 0 : E.includes(o.replace("root.", ""));
4392
4406
  if (u.type === "array") {
4393
- const k = w === o;
4407
+ const y = C === o;
4394
4408
  return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
4395
4409
  u.title && /* @__PURE__ */ jsxs(
4396
4410
  "label",
4397
4411
  {
4398
4412
  htmlFor: o,
4399
- onClick: () => A(k ? null : o),
4413
+ onClick: () => B(y ? null : o),
4400
4414
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
4401
4415
  children: [
4402
- k ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
4416
+ y ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
4403
4417
  /* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
4404
4418
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: n }),
4405
4419
  " ",
@@ -4407,7 +4421,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4407
4421
  ]
4408
4422
  }
4409
4423
  ),
4410
- (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: [
4424
+ (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: [
4411
4425
  c,
4412
4426
  a,
4413
4427
  l,
@@ -4420,13 +4434,13 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4420
4434
  /* @__PURE__ */ jsxs("label", { htmlFor: o, className: u.type === "object" ? "pb-2" : "", children: [
4421
4435
  n,
4422
4436
  " ",
4423
- C && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
4437
+ v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
4424
4438
  " ",
4425
4439
  b
4426
4440
  ] }),
4427
4441
  p && u.type !== "object" ? " *" : null
4428
4442
  ] }),
4429
- u.type === "string" && !u.enum && !u.oneOf && v && /* @__PURE__ */ jsx(NestedPathSelector, { data: v, onSelect: B, dataType: "value" })
4443
+ u.type === "string" && !u.enum && !u.oneOf && S && /* @__PURE__ */ jsx(NestedPathSelector, { data: S, onSelect: _, dataType: "value" })
4430
4444
  ] }),
4431
4445
  c,
4432
4446
  a,
@@ -4495,38 +4509,38 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4495
4509
  }), a;
4496
4510
  };
4497
4511
  function BlockSettings() {
4498
- const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), f = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, f), h = ({ formData: w }, A, B) => {
4499
- A && (c == null ? void 0 : c._id) === r._id && a([r._id], { [A]: get(w, A) }, B);
4512
+ const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), f = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, f), h = ({ formData: C }, B, _) => {
4513
+ B && (c == null ? void 0 : c._id) === r._id && a([r._id], { [B]: get(C, B) }, _);
4500
4514
  }, x = useCallback(
4501
- debounce(({ formData: w }, A, B) => {
4502
- h({ formData: w }, A, B), d(w);
4515
+ debounce(({ formData: C }, B, _) => {
4516
+ h({ formData: C }, B, _), d(C);
4503
4517
  }, 1500),
4504
4518
  [r == null ? void 0 : r._id, o]
4505
- ), y = ({ formData: w }, A) => {
4506
- A && (n([r._id], { [A]: get(w, A) }), x({ formData: w }, A, { [A]: get(c, A) }));
4507
- }, b = ({ formData: w }, A) => {
4508
- A && (n([g._id], { [A]: get(w, A) }), x({ formData: w }, A, { [A]: get(c, A) }));
4509
- }, { schema: v, uiSchema: S } = useMemo(() => {
4510
- const w = r == null ? void 0 : r._type;
4511
- if (!w)
4519
+ ), k = ({ formData: C }, B) => {
4520
+ B && (n([r._id], { [B]: get(C, B) }), x({ formData: C }, B, { [B]: get(c, B) }));
4521
+ }, b = ({ formData: C }, B) => {
4522
+ B && (n([g._id], { [B]: get(C, B) }), x({ formData: C }, B, { [B]: get(c, B) }));
4523
+ }, { schema: S, uiSchema: w } = useMemo(() => {
4524
+ const C = r == null ? void 0 : r._type;
4525
+ if (!C)
4512
4526
  return { schema: {}, uiSchema: {} };
4513
4527
  try {
4514
- return getBlockFormSchemas(w);
4528
+ return getBlockFormSchemas(C);
4515
4529
  } catch {
4516
4530
  return { schema: {}, uiSchema: {} };
4517
4531
  }
4518
- }, [r]), { wrapperSchema: j, wrapperUiSchema: E } = useMemo(() => {
4532
+ }, [r]), { wrapperSchema: A, wrapperUiSchema: E } = useMemo(() => {
4519
4533
  if (!g || !(g != null && g._type))
4520
4534
  return { wrapperSchema: {}, wrapperUiSchema: {} };
4521
- const w = g == null ? void 0 : g._type, { schema: A = {}, uiSchema: B = {} } = getBlockFormSchemas(w);
4522
- return { wrapperSchema: A, wrapperUiSchema: B };
4535
+ const C = g == null ? void 0 : g._type, { schema: B = {}, uiSchema: _ = {} } = getBlockFormSchemas(C);
4536
+ return { wrapperSchema: B, wrapperUiSchema: _ };
4523
4537
  }, [g]);
4524
4538
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
4525
4539
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
4526
4540
  /* @__PURE__ */ jsxs(
4527
4541
  "div",
4528
4542
  {
4529
- onClick: () => u((w) => !w),
4543
+ onClick: () => u((C) => !C),
4530
4544
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
4531
4545
  children: [
4532
4546
  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" }),
@@ -4547,19 +4561,19 @@ function BlockSettings() {
4547
4561
  blockId: g == null ? void 0 : g._id,
4548
4562
  onChange: b,
4549
4563
  formData: m,
4550
- schema: j,
4564
+ schema: A,
4551
4565
  uiSchema: E
4552
4566
  }
4553
4567
  ) })
4554
4568
  ] }),
4555
- isEmpty(v) ? null : /* @__PURE__ */ jsx(
4569
+ isEmpty(S) ? null : /* @__PURE__ */ jsx(
4556
4570
  JSONForm,
4557
4571
  {
4558
4572
  blockId: r == null ? void 0 : r._id,
4559
- onChange: y,
4573
+ onChange: k,
4560
4574
  formData: i,
4561
- schema: v,
4562
- uiSchema: S
4575
+ schema: S,
4576
+ uiSchema: w
4563
4577
  }
4564
4578
  )
4565
4579
  ] });
@@ -4664,10 +4678,10 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
4664
4678
  tooltip: n = !0
4665
4679
  }) => {
4666
4680
  const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: f } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), h = (b) => {
4667
- u.includes(b) ? u.length > 2 && g(u.filter((v) => v !== b)) : g((v) => [...v, b]);
4681
+ u.includes(b) ? u.length > 2 && g(u.filter((S) => S !== b)) : g((S) => [...S, b]);
4668
4682
  }, x = (b) => {
4669
4683
  r || l(b), c(b);
4670
- }, y = getBreakpointValue(r ? i : a).toLowerCase();
4684
+ }, k = getBreakpointValue(r ? i : a).toLowerCase();
4671
4685
  return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
4672
4686
  BreakpointCard,
4673
4687
  {
@@ -4675,7 +4689,7 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
4675
4689
  ...b,
4676
4690
  onClick: x,
4677
4691
  key: b.breakpoint,
4678
- currentBreakpoint: y
4692
+ currentBreakpoint: k
4679
4693
  }
4680
4694
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
4681
4695
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
@@ -4689,7 +4703,7 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
4689
4703
  ...b,
4690
4704
  onClick: x,
4691
4705
  key: b.breakpoint,
4692
- currentBreakpoint: y
4706
+ currentBreakpoint: k
4693
4707
  }
4694
4708
  )
4695
4709
  ) }),
@@ -4844,11 +4858,11 @@ const AskAIStyles = ({ blockId: o }) => {
4844
4858
  };
4845
4859
  function ManualClasses() {
4846
4860
  var T;
4847
- const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [h, x] = useState(""), y = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), v = b.split(" ").filter((L) => !isEmpty(L)), S = () => {
4848
- const L = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
4849
- u(f, L, !0), x("");
4850
- }, [j, E] = useState([]), w = ({ value: L }) => {
4851
- const P = L.trim().toLowerCase(), N = P.match(/.+:/g);
4861
+ const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [h, x] = useState(""), k = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), S = b.split(" ").filter((I) => !isEmpty(I)), w = () => {
4862
+ const I = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
4863
+ u(f, I, !0), x("");
4864
+ }, [A, E] = useState([]), C = ({ value: I }) => {
4865
+ const P = I.trim().toLowerCase(), N = P.match(/.+:/g);
4852
4866
  let D = [];
4853
4867
  if (N && N.length > 0) {
4854
4868
  const [O] = N, R = P.replace(O, "");
@@ -4859,9 +4873,9 @@ function ManualClasses() {
4859
4873
  } else
4860
4874
  D = i.search(P);
4861
4875
  return E(map(D, "item"));
4862
- }, A = () => {
4876
+ }, B = () => {
4863
4877
  E([]);
4864
- }, B = (L) => L.name, I = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), C = useMemo(
4878
+ }, _ = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), v = useMemo(
4865
4879
  () => ({
4866
4880
  ref: o,
4867
4881
  autoComplete: "off",
@@ -4870,30 +4884,30 @@ function ManualClasses() {
4870
4884
  spellCheck: !1,
4871
4885
  placeholder: c("Enter classes separated by space"),
4872
4886
  value: h,
4873
- onKeyDown: (L) => {
4874
- L.key === "Enter" && h.trim() !== "" && S();
4887
+ onKeyDown: (I) => {
4888
+ I.key === "Enter" && h.trim() !== "" && w();
4875
4889
  },
4876
- onChange: (L, { newValue: P }) => x(P),
4890
+ onChange: (I, { newValue: P }) => x(P),
4877
4891
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
4878
4892
  }),
4879
4893
  [h, c, o]
4880
- ), k = (L) => {
4894
+ ), y = (I) => {
4881
4895
  debugger;
4882
4896
  const P = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
4883
- g(f, [L]), u(f, P, !0), n(""), l(-1);
4884
- }, _ = () => {
4897
+ g(f, [I]), u(f, P, !0), n(""), l(-1);
4898
+ }, j = () => {
4885
4899
  if (navigator.clipboard === void 0) {
4886
4900
  toast.error(c("Clipboard not supported"));
4887
4901
  return;
4888
4902
  }
4889
- navigator.clipboard.writeText(v.join(" ")), toast.success(c("Classes copied to clipboard"));
4903
+ navigator.clipboard.writeText(S.join(" ")), toast.success(c("Classes copied to clipboard"));
4890
4904
  };
4891
4905
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
4892
4906
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
4893
4907
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
4894
4908
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
4895
4909
  /* @__PURE__ */ jsxs(Tooltip, { children: [
4896
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: _, className: "cursor-pointer" }) }),
4910
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: j, className: "cursor-pointer" }) }),
4897
4911
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
4898
4912
  ] })
4899
4913
  ] }),
@@ -4909,12 +4923,12 @@ function ManualClasses() {
4909
4923
  /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
4910
4924
  Autosuggest,
4911
4925
  {
4912
- suggestions: j,
4913
- onSuggestionsFetchRequested: w,
4914
- onSuggestionsClearRequested: A,
4915
- getSuggestionValue: B,
4916
- renderSuggestion: I,
4917
- inputProps: C,
4926
+ suggestions: A,
4927
+ onSuggestionsFetchRequested: C,
4928
+ onSuggestionsClearRequested: B,
4929
+ getSuggestionValue: _,
4930
+ renderSuggestion: L,
4931
+ inputProps: v,
4918
4932
  containerProps: {
4919
4933
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
4920
4934
  },
@@ -4930,45 +4944,45 @@ function ManualClasses() {
4930
4944
  {
4931
4945
  variant: "outline",
4932
4946
  className: "h-6 border-border",
4933
- onClick: S,
4947
+ onClick: w,
4934
4948
  disabled: h.trim() === "",
4935
4949
  size: "sm",
4936
4950
  children: /* @__PURE__ */ jsx(PlusIcon, {})
4937
4951
  }
4938
4952
  )
4939
4953
  ] }),
4940
- /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: v.map(
4941
- (L, P) => a === P ? /* @__PURE__ */ jsx(
4954
+ /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: S.map(
4955
+ (I, P) => a === P ? /* @__PURE__ */ jsx(
4942
4956
  "input",
4943
4957
  {
4944
4958
  ref: o,
4945
4959
  value: r,
4946
4960
  onChange: (N) => n(N.target.value),
4947
4961
  onBlur: () => {
4948
- k(L);
4962
+ y(I);
4949
4963
  },
4950
4964
  onKeyDown: (N) => {
4951
- N.key === "Enter" && k(L);
4965
+ N.key === "Enter" && y(I);
4952
4966
  },
4953
4967
  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"
4954
4968
  },
4955
- L
4969
+ I
4956
4970
  ) : /* @__PURE__ */ jsxs(
4957
4971
  "button",
4958
4972
  {
4959
4973
  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",
4960
4974
  children: [
4961
- L,
4962
- r !== L && /* @__PURE__ */ jsx(
4975
+ I,
4976
+ r !== I && /* @__PURE__ */ jsx(
4963
4977
  Cross2Icon,
4964
4978
  {
4965
- onClick: () => g(f, [L], !0),
4979
+ onClick: () => g(f, [I], !0),
4966
4980
  className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
4967
4981
  }
4968
4982
  )
4969
4983
  ]
4970
4984
  },
4971
- L
4985
+ I
4972
4986
  )
4973
4987
  ) })
4974
4988
  ] });
@@ -5141,8 +5155,8 @@ const COLOR_PROP = {
5141
5155
  }, ColorChoice = ({ property: o, onChange: r }) => {
5142
5156
  const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), f = get(u, "2", ""), m = useCallback(
5143
5157
  // eslint-disable-next-line no-shadow
5144
- (y) => {
5145
- ["current", "inherit", "transparent", "black", "white"].includes(y) ? (c([]), p({ color: y })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: y, shade: b.shade ? b.shade : "500" })));
5158
+ (k) => {
5159
+ ["current", "inherit", "transparent", "black", "white"].includes(k) ? (c([]), p({ color: k })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: k, shade: b.shade ? b.shade : "500" })));
5146
5160
  },
5147
5161
  [c, p]
5148
5162
  );
@@ -5153,8 +5167,8 @@ const COLOR_PROP = {
5153
5167
  }, [g]);
5154
5168
  const h = useCallback(
5155
5169
  // eslint-disable-next-line no-shadow
5156
- (y) => {
5157
- p({ color: g, shade: y });
5170
+ (k) => {
5171
+ p({ color: g, shade: k });
5158
5172
  },
5159
5173
  [g]
5160
5174
  );
@@ -5596,50 +5610,50 @@ const COLOR_PROP = {
5596
5610
  },
5597
5611
  a
5598
5612
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5599
- const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [f, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [h, x] = useState(!1), [y, b] = useState(""), [v, S] = useState(!1), [j, E] = useState(!1);
5613
+ const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [f, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [h, x] = useState(!1), [k, b] = useState(""), [S, w] = useState(!1), [A, E] = useState(!1);
5600
5614
  useEffect(() => {
5601
- const { value: C, unit: k } = getClassValueAndUnit(i);
5602
- if (k === "") {
5603
- l(C), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5615
+ const { value: v, unit: y } = getClassValueAndUnit(i);
5616
+ if (y === "") {
5617
+ l(v), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5604
5618
  return;
5605
5619
  }
5606
- m(k), l(k === "class" || isEmpty(C) ? "" : C);
5620
+ m(y), l(y === "class" || isEmpty(v) ? "" : v);
5607
5621
  }, [i, p, u]);
5608
- const w = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), A = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), B = useCallback(
5609
- (C = !1) => {
5610
- const k = getUserInputValues(`${a}`, u);
5611
- if (get(k, "error", !1)) {
5622
+ const C = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), B = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), _ = useCallback(
5623
+ (v = !1) => {
5624
+ const y = getUserInputValues(`${a}`, u);
5625
+ if (get(y, "error", !1)) {
5612
5626
  x(!0);
5613
5627
  return;
5614
5628
  }
5615
- const _ = get(k, "unit") !== "" ? get(k, "unit") : f;
5616
- if (_ === "auto" || _ === "none") {
5617
- w(`${d}${_}`);
5629
+ const j = get(y, "unit") !== "" ? get(y, "unit") : f;
5630
+ if (j === "auto" || j === "none") {
5631
+ C(`${d}${j}`);
5618
5632
  return;
5619
5633
  }
5620
- if (get(k, "value") === "")
5634
+ if (get(y, "value") === "")
5621
5635
  return;
5622
- const L = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
5623
- C ? A(L) : w(L);
5636
+ const I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5637
+ v ? B(I) : C(I);
5624
5638
  },
5625
- [w, A, a, f, d, u]
5626
- ), I = useCallback(
5627
- (C) => {
5628
- const k = getUserInputValues(`${a}`, u);
5629
- if (get(k, "error", !1)) {
5639
+ [C, B, a, f, d, u]
5640
+ ), L = useCallback(
5641
+ (v) => {
5642
+ const y = getUserInputValues(`${a}`, u);
5643
+ if (get(y, "error", !1)) {
5630
5644
  x(!0);
5631
5645
  return;
5632
5646
  }
5633
- if (C === "auto" || C === "none") {
5634
- w(`${d}${C}`);
5647
+ if (v === "auto" || v === "none") {
5648
+ C(`${d}${v}`);
5635
5649
  return;
5636
5650
  }
5637
- if (get(k, "value") === "")
5651
+ if (get(y, "value") === "")
5638
5652
  return;
5639
- const _ = get(k, "unit") !== "" ? get(k, "unit") : C, L = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
5640
- w(L);
5653
+ const j = get(y, "unit") !== "" ? get(y, "unit") : v, I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5654
+ C(I);
5641
5655
  },
5642
- [w, a, d, u]
5656
+ [C, a, d, u]
5643
5657
  );
5644
5658
  return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: f === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5645
5659
  /* @__PURE__ */ jsx(
@@ -5654,37 +5668,37 @@ const COLOR_PROP = {
5654
5668
  /* @__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, {}) }) }),
5655
5669
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
5656
5670
  ] })
5657
- ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${v ? "z-auto" : ""}`, children: [
5671
+ ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${S ? "z-auto" : ""}`, children: [
5658
5672
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
5659
5673
  ["none", "auto"].indexOf(f) !== -1 ? null : /* @__PURE__ */ jsx(
5660
5674
  "input",
5661
5675
  {
5662
5676
  readOnly: f === "class",
5663
- onKeyPress: (C) => {
5664
- C.key === "Enter" && B();
5677
+ onKeyPress: (v) => {
5678
+ v.key === "Enter" && _();
5665
5679
  },
5666
- onKeyDown: (C) => {
5667
- if (C.keyCode !== 38 && C.keyCode !== 40)
5680
+ onKeyDown: (v) => {
5681
+ if (v.keyCode !== 38 && v.keyCode !== 40)
5668
5682
  return;
5669
- C.preventDefault(), E(!0);
5670
- const k = parseInt$1(C.target.value);
5671
- let _ = isNaN$1(k) ? 0 : k;
5672
- C.keyCode === 38 && (_ += 1), C.keyCode === 40 && (_ -= 1);
5673
- const T = `${_}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${f === "-" ? "" : f}]`;
5674
- A(P);
5683
+ v.preventDefault(), E(!0);
5684
+ const y = parseInt$1(v.target.value);
5685
+ let j = isNaN$1(y) ? 0 : y;
5686
+ v.keyCode === 38 && (j += 1), v.keyCode === 40 && (j -= 1);
5687
+ const T = `${j}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${f === "-" ? "" : f}]`;
5688
+ B(P);
5675
5689
  },
5676
- onKeyUp: (C) => {
5677
- j && (C.preventDefault(), E(!1));
5690
+ onKeyUp: (v) => {
5691
+ A && (v.preventDefault(), E(!1));
5678
5692
  },
5679
- onBlur: () => B(),
5680
- onChange: (C) => {
5681
- x(!1), l(C.target.value);
5693
+ onBlur: () => _(),
5694
+ onChange: (v) => {
5695
+ x(!1), l(v.target.value);
5682
5696
  },
5683
- onClick: (C) => {
5684
- var k;
5685
- (k = C == null ? void 0 : C.target) == null || k.select(), n(!1);
5697
+ onClick: (v) => {
5698
+ var y;
5699
+ (y = v == null ? void 0 : v.target) == null || y.select(), n(!1);
5686
5700
  },
5687
- value: v ? y : a,
5701
+ value: S ? k : a,
5688
5702
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
5689
5703
  " ",
5690
5704
  h ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -5709,29 +5723,29 @@ const COLOR_PROP = {
5709
5723
  {
5710
5724
  units: u,
5711
5725
  current: f,
5712
- onSelect: (C) => {
5713
- n(!1), m(C), I(C);
5726
+ onSelect: (v) => {
5727
+ n(!1), m(v), L(v);
5714
5728
  }
5715
5729
  }
5716
5730
  ) }) })
5717
5731
  ] })
5718
5732
  ] }),
5719
- ["none", "auto"].indexOf(f) !== -1 || v ? null : /* @__PURE__ */ jsx(
5733
+ ["none", "auto"].indexOf(f) !== -1 || S ? null : /* @__PURE__ */ jsx(
5720
5734
  DragStyleButton,
5721
5735
  {
5722
- onDragStart: () => S(!0),
5723
- onDragEnd: (C) => {
5724
- if (b(() => ""), S(!1), isEmpty(C))
5736
+ onDragStart: () => w(!0),
5737
+ onDragEnd: (v) => {
5738
+ if (b(() => ""), w(!1), isEmpty(v))
5725
5739
  return;
5726
- const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${f === "-" ? "" : f}]`;
5727
- w(T);
5740
+ const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${f === "-" ? "" : f}]`;
5741
+ C(T);
5728
5742
  },
5729
- onDrag: (C) => {
5730
- if (isEmpty(C))
5743
+ onDrag: (v) => {
5744
+ if (isEmpty(v))
5731
5745
  return;
5732
- b(C);
5733
- const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${f === "-" ? "" : f}]`;
5734
- A(T);
5746
+ b(v);
5747
+ const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${f === "-" ? "" : f}]`;
5748
+ B(T);
5735
5749
  },
5736
5750
  currentValue: a,
5737
5751
  unit: f,
@@ -5828,35 +5842,35 @@ const COLOR_PROP = {
5828
5842
  "2xl": "1536px"
5829
5843
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
5830
5844
  const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
5831
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), f = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(f, "fullCls", ""), [f]), b = useCallback(
5832
- (A, B = !0) => {
5833
- const I = { dark: p, mq: g, mod: u, cls: A, property: l, fullCls: "" };
5834
- (p || u !== "") && (I.mq = "xs");
5835
- const C = generateFullClsName(I);
5836
- m(x, [C], B);
5845
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), f = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), k = useMemo(() => get(f, "fullCls", ""), [f]), b = useCallback(
5846
+ (B, _ = !0) => {
5847
+ const L = { dark: p, mq: g, mod: u, cls: B, property: l, fullCls: "" };
5848
+ (p || u !== "") && (L.mq = "xs");
5849
+ const v = generateFullClsName(L);
5850
+ m(x, [v], _);
5837
5851
  },
5838
5852
  [x, p, g, u, l, m]
5839
- ), v = useCallback(() => {
5840
- h(x, [y], !0);
5841
- }, [x, y, h]), S = useMemo(() => canChangeClass(f, g), [f, g]);
5853
+ ), S = useCallback(() => {
5854
+ h(x, [k], !0);
5855
+ }, [x, k, h]), w = useMemo(() => canChangeClass(f, g), [f, g]);
5842
5856
  useEffect(() => {
5843
- i(S, f);
5844
- }, [S, i, f]);
5845
- const [, , j] = useScreenSizeWidth(), E = useCallback(
5846
- (A) => {
5847
- j({
5857
+ i(w, f);
5858
+ }, [w, i, f]);
5859
+ const [, , A] = useScreenSizeWidth(), E = useCallback(
5860
+ (B) => {
5861
+ A({
5848
5862
  xs: 400,
5849
5863
  sm: 640,
5850
5864
  md: 800,
5851
5865
  lg: 1024,
5852
5866
  xl: 1420,
5853
5867
  "2xl": 1920
5854
- }[A]);
5868
+ }[B]);
5855
5869
  },
5856
- [j]
5857
- ), w = get(f, "dark", null) === p && get(f, "mod", null) === u && get(f, "mq", null) === g;
5858
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: S, canReset: f && w, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
5859
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${f && !w ? "text-foreground" : ""}`, children: r(a) }) }),
5870
+ [A]
5871
+ ), C = get(f, "dark", null) === p && get(f, "mod", null) === u && get(f, "mq", null) === g;
5872
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: w, canReset: f && C, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
5873
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${f && !C ? "text-foreground" : ""}`, children: r(a) }) }),
5860
5874
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
5861
5875
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
5862
5876
  n === "arbitrary" ? /* @__PURE__ */ jsx(
@@ -5875,7 +5889,7 @@ const COLOR_PROP = {
5875
5889
  n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
5876
5890
  n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
5877
5891
  ] }),
5878
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: w ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : S && f ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5892
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${k ? "visible" : "invisible"}`, children: C ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => S(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : w && f ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5879
5893
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5880
5894
  "button",
5881
5895
  {
@@ -6025,8 +6039,8 @@ function BlockStyling() {
6025
6039
  m = isNaN(m) ? 0 : m;
6026
6040
  let h = MAPPER[i.dragUnit];
6027
6041
  (startsWith(f, "scale") || f === "opacity") && (h = 10);
6028
- let y = (i.dragStartY - u.pageY) / h + m;
6029
- g && y < 0 && (y = 0), f === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6042
+ let k = (i.dragStartY - u.pageY) / h + m;
6043
+ g && k < 0 && (k = 0), f === "opacity" && k > 1 && (k = 1), i.onDrag(`${k}`), l(`${k}`);
6030
6044
  },
6031
6045
  [i],
6032
6046
  50
@@ -6071,8 +6085,8 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6071
6085
  }) => {
6072
6086
  const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: f } = useBlockHighlight(), m = () => {
6073
6087
  if (console.log("addBlockToPage", o), has(o, "blocks")) {
6074
- const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
6075
- u(syncBlocksWithDefaults(y), n || null, a);
6088
+ const k = isFunction(o.blocks) ? o.blocks() : o.blocks;
6089
+ u(syncBlocksWithDefaults(k), n || null, a);
6076
6090
  } else
6077
6091
  p(o, n || null, a);
6078
6092
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
@@ -6084,8 +6098,8 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6084
6098
  disabled: r,
6085
6099
  onClick: m,
6086
6100
  type: "button",
6087
- onDragStart: (y) => {
6088
- y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6101
+ onDragStart: (k) => {
6102
+ k.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), k.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6089
6103
  g([]), f();
6090
6104
  }, 200);
6091
6105
  },
@@ -6285,22 +6299,22 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6285
6299
  }
6286
6300
  }
6287
6301
  }, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
6288
- var f, m, h, x, y, b, v, S;
6302
+ var f, m, h, x, k, b, S, w;
6289
6303
  if (n.type === "comment") return [];
6290
6304
  console.log("node ===>", n);
6291
6305
  let a = { _id: generateUUID() };
6292
6306
  if (r && (a._parent = r.block._id), n.type === "text")
6293
6307
  return isEmpty(get(n, "content", "")) ? [] : r && shouldAddText(r.node, r.block) ? (set(r, "block.content", get(n, "content", "")), []) : { ...a, _type: "Text", content: get(n, "content", "") };
6294
6308
  const l = get(n, "attributes", []), i = l.find(
6295
- (j) => j.key === "data-chai-richtext" || j.key === "chai-richtext"
6309
+ (A) => A.key === "data-chai-richtext" || A.key === "chai-richtext"
6296
6310
  ), c = l.find(
6297
- (j) => j.key === "data-chai-lightbox" || j.key === "chai-lightbox"
6311
+ (A) => A.key === "data-chai-lightbox" || A.key === "chai-lightbox"
6298
6312
  ), d = l.find(
6299
- (j) => j.key === "data-chai-dropdown" || j.key === "chai-dropdown"
6313
+ (A) => A.key === "data-chai-dropdown" || A.key === "chai-dropdown"
6300
6314
  ), p = l.find(
6301
- (j) => j.key === "data-chai-dropdown-button" || j.key === "chai-dropdown-button"
6315
+ (A) => A.key === "data-chai-dropdown-button" || A.key === "chai-dropdown-button"
6302
6316
  ), u = l.find(
6303
- (j) => j.key === "data-chai-dropdown-content" || j.key === "chai-dropdown-content"
6317
+ (A) => A.key === "data-chai-dropdown-content" || A.key === "chai-dropdown-content"
6304
6318
  );
6305
6319
  if (a = {
6306
6320
  ...a,
@@ -6308,13 +6322,13 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6308
6322
  ...getAttrs(n),
6309
6323
  ...getStyles(n)
6310
6324
  }, n.attributes) {
6311
- const j = n.attributes.find((E) => includes(NAME_ATTRIBUTES, E.key));
6312
- j && (a._name = j.value);
6325
+ const A = n.attributes.find((E) => includes(NAME_ATTRIBUTES, E.key));
6326
+ A && (a._name = A.value);
6313
6327
  }
6314
6328
  if (i)
6315
6329
  return a.content = stringify(n.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];
6316
6330
  if (c) {
6317
- const j = [
6331
+ const A = [
6318
6332
  "data-chai-lightbox",
6319
6333
  "chai-lightbox",
6320
6334
  "data-vbtype",
@@ -6329,41 +6343,41 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6329
6343
  href: ((f = l.find((E) => E.key === "href")) == null ? void 0 : f.value) || "",
6330
6344
  hrefType: ((m = l.find((E) => E.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
6331
6345
  autoplay: ((h = l.find((E) => E.key === "data-autoplay")) == null ? void 0 : h.value) === "true" ? "true" : "false",
6332
- maxWidth: ((y = (x = l.find((E) => E.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : y.replace("px", "")) || "",
6346
+ maxWidth: ((k = (x = l.find((E) => E.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : k.replace("px", "")) || "",
6333
6347
  backdropColor: ((b = l.find((E) => E.key === "data-overlay")) == null ? void 0 : b.value) || "",
6334
- galleryName: ((v = l.find((E) => E.key === "data-gall")) == null ? void 0 : v.value) || ""
6335
- }, forEach(j, (E) => {
6348
+ galleryName: ((S = l.find((E) => E.key === "data-gall")) == null ? void 0 : S.value) || ""
6349
+ }, forEach(A, (E) => {
6336
6350
  has(a, `styles_attrs.${E}`) && delete a.styles_attrs[E];
6337
6351
  });
6338
6352
  }
6339
6353
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
6340
6354
  delete a.styles_attrs;
6341
- const j = filter(n.children || [], (w) => (w == null ? void 0 : w.tagName) !== "span");
6342
- a.content = getTextContent(j);
6355
+ const A = filter(n.children || [], (C) => (C == null ? void 0 : C.tagName) !== "span");
6356
+ a.content = getTextContent(A);
6343
6357
  const E = find(
6344
6358
  n.children || [],
6345
- (w) => (w == null ? void 0 : w.tagName) === "span" && some(w.children || [], (A) => (A == null ? void 0 : A.tagName) === "svg")
6359
+ (C) => (C == null ? void 0 : C.tagName) === "span" && some(C.children || [], (B) => (B == null ? void 0 : B.tagName) === "svg")
6346
6360
  );
6347
6361
  if (E) {
6348
- const w = find(E.children || [], (A) => (A == null ? void 0 : A.tagName) === "svg");
6349
- if (w) {
6350
- a.icon = stringify([w]);
6351
- const { height: A, width: B } = getSvgDimensions(w, "16px", "16px");
6352
- a.iconHeight = A, a.iconWidth = B;
6362
+ const C = find(E.children || [], (B) => (B == null ? void 0 : B.tagName) === "svg");
6363
+ if (C) {
6364
+ a.icon = stringify([C]);
6365
+ const { height: B, width: _ } = getSvgDimensions(C, "16px", "16px");
6366
+ a.iconHeight = B, a.iconWidth = _;
6353
6367
  }
6354
6368
  }
6355
6369
  return [a];
6356
6370
  }
6357
6371
  if (a._type === "Input") {
6358
- const j = a.inputType || "text";
6359
- j === "checkbox" ? set(a, "_type", "Checkbox") : j === "radio" && set(a, "_type", "Radio");
6372
+ const A = a.inputType || "text";
6373
+ A === "checkbox" ? set(a, "_type", "Checkbox") : A === "radio" && set(a, "_type", "Radio");
6360
6374
  } else if (n.tagName === "video" || n.tagName === "iframe") {
6361
- const j = stringify([n]);
6362
- return hasVideoEmbed(j) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(j)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = j, [a];
6375
+ const A = stringify([n]);
6376
+ return hasVideoEmbed(A) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(A)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = A, [a];
6363
6377
  } else if (n.tagName === "svg") {
6364
- const j = find(n.attributes, { key: "height" }), E = find(n.attributes, { key: "width" }), w = get(j, "value") ? `[${get(j, "value")}px]` : "24px", A = get(E, "value") ? `[${get(E, "value")}px]` : "24px", B = get(find(n.attributes, { key: "class" }), "value", "w-full h-full");
6365
- return a.styles = `${STYLES_KEY}, ${cn$1(`w-${A} h-${w}`, B)}`.trim(), n.attributes = filter(n.attributes, (I) => !includes(["style", "width", "height", "class"], I.key)), a.icon = stringify([n]), [a];
6366
- } else if (n.tagName == "option" && r && ((S = r.block) == null ? void 0 : S._type) === "Select")
6378
+ const A = find(n.attributes, { key: "height" }), E = find(n.attributes, { key: "width" }), C = get(A, "value") ? `[${get(A, "value")}px]` : "24px", B = get(E, "value") ? `[${get(E, "value")}px]` : "24px", _ = get(find(n.attributes, { key: "class" }), "value", "w-full h-full");
6379
+ return a.styles = `${STYLES_KEY}, ${cn$1(`w-${B} h-${C}`, _)}`.trim(), n.attributes = filter(n.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([n]), [a];
6380
+ } else if (n.tagName == "option" && r && ((w = r.block) == null ? void 0 : w._type) === "Select")
6367
6381
  return r.block.options.push({
6368
6382
  label: getTextContent(n.children),
6369
6383
  ...getAttrs(n)
@@ -6411,91 +6425,6 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6411
6425
  ] }) }),
6412
6426
  /* @__PURE__ */ jsx(CardFooter, { className: "flex flex-col justify-end p-3", children: /* @__PURE__ */ jsx(Button, { disabled: a.trim() === "", onClick: () => c(), size: "sm", className: "w-fit", children: n("Import HTML") }) })
6413
6427
  ] });
6414
- }, partialBlocksDataAtom = atom({
6415
- blocks: [],
6416
- groups: [],
6417
- isLoading: !0,
6418
- error: null
6419
- }), hasInitializedPartialBlocksAtom = atom(!1), formatReadableName = (o) => {
6420
- if (!o) return "";
6421
- let r = o.replace(/[-_]/g, " ");
6422
- return r = r.replace(/([a-z])([A-Z])/g, "$1 $2"), r.split(" ").map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join(" ");
6423
- }, PartialBlocks = ({
6424
- parentId: o,
6425
- position: r,
6426
- gridCols: n = "grid-cols-2"
6427
- }) => {
6428
- const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u, g] = useAtom$1(hasInitializedPartialBlocksAtom);
6429
- useEffect(() => {
6430
- if (!u || Object.keys(d.blocks).length === 0)
6431
- if (c)
6432
- p({
6433
- blocks: [],
6434
- groups: [],
6435
- isLoading: !1,
6436
- error: c
6437
- }), g(!0);
6438
- else if (!l && Object.keys(a || {}).length > 0) {
6439
- const m = Object.entries(a).map(([x, y]) => {
6440
- const b = y, v = b.type || "partial", S = formatReadableName(v);
6441
- return {
6442
- type: "PartialBlock",
6443
- // Set the type to PartialBlock
6444
- label: formatReadableName(b.name || x),
6445
- description: b.description || "",
6446
- icon: Globe,
6447
- group: S,
6448
- // Use formatted type as group
6449
- category: "partial",
6450
- partialBlockId: x,
6451
- // Store the original ID as partialBlockId
6452
- _name: b.name
6453
- };
6454
- }), h = uniq(map(m, "group"));
6455
- p({
6456
- blocks: m,
6457
- groups: h,
6458
- isLoading: !1,
6459
- error: null
6460
- }), g(!0);
6461
- } else l ? p((m) => ({ ...m, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
6462
- blocks: [],
6463
- groups: [],
6464
- isLoading: !1,
6465
- error: "No partial blocks available"
6466
- }), g(!0));
6467
- }, [
6468
- l,
6469
- a,
6470
- u,
6471
- g,
6472
- p,
6473
- d.blocks,
6474
- c
6475
- ]);
6476
- const f = () => {
6477
- p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
6478
- };
6479
- 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: [
6480
- /* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
6481
- /* @__PURE__ */ jsx(
6482
- "button",
6483
- {
6484
- onClick: f,
6485
- className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
6486
- children: "Refresh"
6487
- }
6488
- )
6489
- ] }) : /* @__PURE__ */ jsx(
6490
- ChaiBuilderBlocks,
6491
- {
6492
- gridCols: n,
6493
- parentId: o,
6494
- position: r,
6495
- groups: d.groups,
6496
- blocks: d.blocks
6497
- }
6498
- );
6499
6428
  }, ChaiSelect = ({
6500
6429
  defaultValue: o = "",
6501
6430
  onValueChange: r,
@@ -6535,7 +6464,7 @@ function UILibrariesSelect({
6535
6464
  /* @__PURE__ */ jsx(
6536
6465
  ChaiSelect,
6537
6466
  {
6538
- className: "mt-1",
6467
+ className: "mb-1",
6539
6468
  options: o.map((l) => ({
6540
6469
  value: l.id,
6541
6470
  label: l.name
@@ -6552,18 +6481,18 @@ const BlockCard = ({
6552
6481
  parentId: n = void 0,
6553
6482
  position: a = -1
6554
6483
  }) => {
6555
- const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), f = get(o, "name", get(o, "label")), m = useFeature("dnd"), [, h] = useAtom$1(draggedBlockAtom), x = (v) => {
6556
- const S = has(v, "styles_attrs.data-page-section");
6557
- return v._type === "Box" && S;
6558
- }, y = useCallback(
6559
- async (v) => {
6560
- if (v.stopPropagation(), has(o, "component")) {
6484
+ const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), f = get(o, "name", get(o, "label")), m = get(o, "description", ""), h = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), k = (w) => {
6485
+ const A = has(w, "styles_attrs.data-page-section");
6486
+ return w._type === "Box" && A;
6487
+ }, b = useCallback(
6488
+ async (w) => {
6489
+ if (w.stopPropagation(), has(o, "component")) {
6561
6490
  d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6562
6491
  return;
6563
6492
  }
6564
6493
  i(!0);
6565
- const S = await c(r, o);
6566
- isEmpty(S) || p(syncBlocksWithDefaults(S), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6494
+ const A = await c(r, o);
6495
+ isEmpty(A) || p(syncBlocksWithDefaults(A), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6567
6496
  },
6568
6497
  [d, p, o, c, r, n, a]
6569
6498
  );
@@ -6572,21 +6501,21 @@ const BlockCard = ({
6572
6501
  "div",
6573
6502
  {
6574
6503
  onClick: l ? () => {
6575
- } : y,
6576
- draggable: m ? "true" : "false",
6577
- onDragStart: async (v) => {
6578
- const S = await c(r, o);
6579
- let j = n;
6580
- if (x(first(S)) && (j = null), !isEmpty(S)) {
6581
- const E = { blocks: S, uiLibrary: !0, parent: j };
6582
- if (v.dataTransfer.setData("text/plain", JSON.stringify(E)), o.preview) {
6583
- const w = new Image();
6584
- w.src = o.preview, w.onload = () => {
6585
- v.dataTransfer.setDragImage(w, 0, 0);
6504
+ } : b,
6505
+ draggable: h ? "true" : "false",
6506
+ onDragStart: async (w) => {
6507
+ const A = await c(r, o);
6508
+ let E = n;
6509
+ if (k(first(A)) && (E = null), !isEmpty(A)) {
6510
+ const C = { blocks: A, uiLibrary: !0, parent: E };
6511
+ if (w.dataTransfer.setData("text/plain", JSON.stringify(C)), o.preview) {
6512
+ const B = new Image();
6513
+ B.src = o.preview, B.onload = () => {
6514
+ w.dataTransfer.setDragImage(B, 0, 0);
6586
6515
  };
6587
6516
  } else
6588
- v.dataTransfer.setDragImage(new Image(), 0, 0);
6589
- h(E), setTimeout(() => {
6517
+ w.dataTransfer.setDragImage(new Image(), 0, 0);
6518
+ x(C), setTimeout(() => {
6590
6519
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6591
6520
  }, 200);
6592
6521
  }
@@ -6599,128 +6528,273 @@ const BlockCard = ({
6599
6528
  /* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
6600
6529
  /* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
6601
6530
  ] }),
6602
- o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: f }) : /* @__PURE__ */ jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: f }) })
6531
+ o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: f }) : /* @__PURE__ */ jsxs("div", { className: "flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center", children: [
6532
+ /* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: f }),
6533
+ m && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600", children: m })
6534
+ ] })
6603
6535
  ]
6604
6536
  }
6605
6537
  ) }),
6606
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: f }) })
6538
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsxs("div", { className: "max-w-xs", children: [
6539
+ /* @__PURE__ */ jsx("p", { className: "font-medium", children: f }),
6540
+ m && o.preview && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-primary-foreground", children: m })
6541
+ ] }) })
6607
6542
  ] });
6608
6543
  }, UILibrarySection = ({ parentId: o, position: r }) => {
6609
- const [n, a] = useSelectedLibrary(), l = useBuilderProp("uiLibraries", []), i = l.find((v) => v.id === n) || first(l), { data: c, isLoading: d } = useLibraryBlocks(i), p = groupBy([...c], "group"), [u, g] = useState(null);
6544
+ const [n, a] = useSelectedLibrary(), l = useBuilderProp("uiLibraries", []), i = l.find((y) => y.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [f, m] = useState([]), h = useRef(null);
6610
6545
  useEffect(() => {
6611
- u || g(first(keys(p)));
6612
- }, [p, u]);
6613
- const f = get(p, u, []), m = useRef(null), { t: h } = useTranslation(), x = (v) => {
6614
- m.current && (clearTimeout(m.current), m.current = null), m.current = setTimeout(() => {
6615
- m.current && g(v);
6616
- }, 300);
6546
+ c && c.length > 0 && (h.current = new Fuse(c, {
6547
+ keys: ["name", "label", "description", "group"],
6548
+ threshold: 0.4,
6549
+ ignoreLocation: !0
6550
+ }));
6551
+ }, [c]), useEffect(() => {
6552
+ if (!u.trim() || !h.current) {
6553
+ m([]);
6554
+ return;
6555
+ }
6556
+ const y = h.current.search(u).map((j) => j.item);
6557
+ m(y);
6558
+ }, [u]);
6559
+ const x = u.trim() && !isEmpty(f) ? f : c, k = groupBy(x, "group"), [b, S] = useState(null);
6560
+ useEffect(() => {
6561
+ if (isEmpty(keys(k))) {
6562
+ S(null);
6563
+ return;
6564
+ }
6565
+ if (!b || !k[b]) {
6566
+ S(first(keys(k)));
6567
+ return;
6568
+ }
6569
+ }, [k, b]);
6570
+ const w = get(k, b, []), A = useRef(null), { t: E } = useTranslation(), C = (y) => {
6571
+ A.current && (clearTimeout(A.current), A.current = null), A.current = setTimeout(() => {
6572
+ A.current && S(y);
6573
+ }, 400);
6574
+ }, B = () => {
6575
+ i != null && i.id && p(i.id);
6576
+ }, _ = () => {
6577
+ g("");
6617
6578
  };
6618
6579
  if (d)
6619
6580
  return /* @__PURE__ */ jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
6620
6581
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
6621
6582
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
6622
6583
  ] });
6623
- const y = filter(f, (v, S) => S % 2 === 0), b = filter(f, (v, S) => S % 2 === 1);
6624
- 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: [
6625
- /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-72 flex-col gap-1 px-1 pr-2", children: [
6626
- /* @__PURE__ */ jsx(UILibrariesSelect, { library: i == null ? void 0 : i.id, setLibrary: a, uiLibraries: l }),
6627
- /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
6628
- /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: h("Groups") }),
6629
- /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
6630
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: map(p, (v, S) => /* @__PURE__ */ jsxs(
6631
- "div",
6632
- {
6633
- onMouseEnter: () => x(S),
6634
- onMouseLeave: () => clearTimeout(m.current),
6635
- role: "button",
6636
- onClick: () => g(S),
6637
- className: cn$1(
6638
- "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",
6639
- S === u ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
6640
- ),
6641
- children: [
6642
- /* @__PURE__ */ jsx("span", { children: capitalize(h(S.toLowerCase())) }),
6643
- /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
6644
- ]
6645
- },
6646
- S
6647
- )) })
6648
- ] })
6649
- ] }),
6650
- /* @__PURE__ */ jsxs(
6651
- ScrollArea,
6584
+ const L = filter(w, (y, j) => j % 2 === 0), v = filter(w, (y, j) => j % 2 === 1);
6585
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
6586
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
6587
+ /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
6588
+ /* @__PURE__ */ jsx(
6589
+ Input$1,
6590
+ {
6591
+ placeholder: E("Search blocks..."),
6592
+ value: u,
6593
+ onChange: (y) => g(y.target.value),
6594
+ className: "w-full pl-8 pr-8"
6595
+ }
6596
+ ),
6597
+ u && /* @__PURE__ */ jsx(
6598
+ "button",
6599
+ {
6600
+ onClick: _,
6601
+ className: "absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",
6602
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
6603
+ }
6604
+ )
6605
+ ] }) }),
6606
+ /* @__PURE__ */ jsx("div", { className: "relative flex h-full max-h-full flex-1 overflow-hidden bg-background", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-1 pt-2", children: [
6607
+ /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 min-w-60 max-w-60 flex-col gap-1 px-1 pr-2", children: [
6608
+ /* @__PURE__ */ jsx(UILibrariesSelect, { library: i == null ? void 0 : i.id, setLibrary: a, uiLibraries: l }),
6609
+ /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
6610
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: E("Groups") }),
6611
+ /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
6612
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: E("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
6613
+ /* @__PURE__ */ jsx("p", { className: "text-sm", children: E("Failed to load the UI library. Try again") }),
6614
+ /* @__PURE__ */ jsxs(Button, { onClick: B, variant: "outline", size: "sm", className: "gap-2", children: [
6615
+ /* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
6616
+ E("Retry")
6617
+ ] })
6618
+ ] }) }) : map(k, (y, j) => /* @__PURE__ */ jsxs(
6619
+ "div",
6620
+ {
6621
+ onMouseEnter: () => C(j),
6622
+ onMouseLeave: () => clearTimeout(A.current),
6623
+ role: "button",
6624
+ onClick: () => S(j),
6625
+ className: cn$1(
6626
+ "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",
6627
+ j === b ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
6628
+ ),
6629
+ children: [
6630
+ /* @__PURE__ */ jsx("span", { children: capitalize(E(j.toLowerCase())) }),
6631
+ /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
6632
+ ]
6633
+ },
6634
+ j
6635
+ )) })
6636
+ ] })
6637
+ ] }),
6638
+ /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-col border-l border-border", children: /* @__PURE__ */ jsxs(
6639
+ ScrollArea,
6640
+ {
6641
+ onMouseEnter: () => A.current ? clearTimeout(A.current) : null,
6642
+ className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
6643
+ children: [
6644
+ isEmpty(w) && !isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: E("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
6645
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: L.map((y, j) => /* @__PURE__ */ jsx(
6646
+ BlockCard,
6647
+ {
6648
+ parentId: o,
6649
+ position: r,
6650
+ block: y,
6651
+ library: i
6652
+ },
6653
+ `block-${j}`
6654
+ )) }),
6655
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: v.map((y, j) => /* @__PURE__ */ jsx(
6656
+ BlockCard,
6657
+ {
6658
+ parentId: o,
6659
+ position: r,
6660
+ block: y,
6661
+ library: i
6662
+ },
6663
+ `block-second-${j}`
6664
+ )) })
6665
+ ] }),
6666
+ /* @__PURE__ */ jsx("br", {}),
6667
+ /* @__PURE__ */ jsx("br", {}),
6668
+ /* @__PURE__ */ jsx("br", {})
6669
+ ]
6670
+ }
6671
+ ) })
6672
+ ] }) })
6673
+ ] }) });
6674
+ }, UILibrariesPanel = ({ parentId: o, position: r }) => /* @__PURE__ */ jsx(UILibrarySection, { parentId: o, position: r }), partialBlocksDataAtom = atom({
6675
+ blocks: [],
6676
+ groups: [],
6677
+ isLoading: !0,
6678
+ error: null
6679
+ }), hasInitializedPartialBlocksAtom = atom(!1), formatReadableName = (o) => {
6680
+ if (!o) return "";
6681
+ let r = o.replace(/[-_]/g, " ");
6682
+ return r = r.replace(/([a-z])([A-Z])/g, "$1 $2"), r.split(" ").map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join(" ");
6683
+ }, PartialBlocks = ({
6684
+ parentId: o,
6685
+ position: r,
6686
+ gridCols: n = "grid-cols-2"
6687
+ }) => {
6688
+ const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u, g] = useAtom$1(hasInitializedPartialBlocksAtom);
6689
+ useEffect(() => {
6690
+ if (!u || Object.keys(d.blocks).length === 0)
6691
+ if (c)
6692
+ p({
6693
+ blocks: [],
6694
+ groups: [],
6695
+ isLoading: !1,
6696
+ error: c
6697
+ }), g(!0);
6698
+ else if (!l && Object.keys(a || {}).length > 0) {
6699
+ const m = Object.entries(a).map(([x, k]) => {
6700
+ const b = k, S = b.type || "partial", w = formatReadableName(S);
6701
+ return {
6702
+ type: "PartialBlock",
6703
+ // Set the type to PartialBlock
6704
+ label: formatReadableName(b.name || x),
6705
+ description: b.description || "",
6706
+ icon: Globe,
6707
+ group: w,
6708
+ // Use formatted type as group
6709
+ category: "partial",
6710
+ partialBlockId: x,
6711
+ // Store the original ID as partialBlockId
6712
+ _name: b.name
6713
+ };
6714
+ }), h = uniq(map(m, "group"));
6715
+ p({
6716
+ blocks: m,
6717
+ groups: h,
6718
+ isLoading: !1,
6719
+ error: null
6720
+ }), g(!0);
6721
+ } else l ? p((m) => ({ ...m, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
6722
+ blocks: [],
6723
+ groups: [],
6724
+ isLoading: !1,
6725
+ error: "No partial blocks available"
6726
+ }), g(!0));
6727
+ }, [
6728
+ l,
6729
+ a,
6730
+ u,
6731
+ g,
6732
+ p,
6733
+ d.blocks,
6734
+ c
6735
+ ]);
6736
+ const f = () => {
6737
+ p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
6738
+ };
6739
+ 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: [
6740
+ /* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
6741
+ /* @__PURE__ */ jsx(
6742
+ "button",
6652
6743
  {
6653
- onMouseEnter: () => m.current ? clearTimeout(m.current) : null,
6654
- 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",
6655
- children: [
6656
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
6657
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: y.map((v, S) => /* @__PURE__ */ jsx(
6658
- BlockCard,
6659
- {
6660
- parentId: o,
6661
- position: r,
6662
- block: v,
6663
- library: i
6664
- },
6665
- `block-${S}`
6666
- )) }),
6667
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: b.map((v, S) => /* @__PURE__ */ jsx(
6668
- BlockCard,
6669
- {
6670
- parentId: o,
6671
- position: r,
6672
- block: v,
6673
- library: i
6674
- },
6675
- `block-${S}`
6676
- )) })
6677
- ] }),
6678
- /* @__PURE__ */ jsx("br", {}),
6679
- /* @__PURE__ */ jsx("br", {}),
6680
- /* @__PURE__ */ jsx("br", {})
6681
- ]
6744
+ onClick: f,
6745
+ className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
6746
+ children: "Refresh"
6682
6747
  }
6683
6748
  )
6684
- ] }) }) });
6685
- }, UILibrariesPanel = ({ parentId: o, position: r }) => /* @__PURE__ */ jsx(UILibrarySection, { parentId: o, position: r }), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: r, parentId: n, position: a, gridCols: l = "grid-cols-4" }) => {
6686
- var C;
6687
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), f = (C = find(c, (k) => k._id === n)) == null ? void 0 : C._type, [m, h] = useState("all"), [x, y] = useState(null), b = useRef(null);
6749
+ ] }) : /* @__PURE__ */ jsx(
6750
+ ChaiBuilderBlocks,
6751
+ {
6752
+ gridCols: n,
6753
+ parentId: o,
6754
+ position: r,
6755
+ groups: d.groups,
6756
+ blocks: d.blocks
6757
+ }
6758
+ );
6759
+ }, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: r, parentId: n, position: a, gridCols: l = "grid-cols-4" }) => {
6760
+ var v;
6761
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), f = (v = find(c, (y) => y._id === n)) == null ? void 0 : v._type, [m, h] = useState("all"), [x, k] = useState(null), b = useRef(null);
6688
6762
  useEffect(() => {
6689
- const k = setTimeout(() => {
6690
- var _;
6691
- (_ = u.current) == null || _.focus();
6763
+ const y = setTimeout(() => {
6764
+ var j;
6765
+ (j = u.current) == null || j.focus();
6692
6766
  }, 0);
6693
- return () => clearTimeout(k);
6767
+ return () => clearTimeout(y);
6694
6768
  }, [g]), useEffect(() => {
6695
- d && (h("all"), y(null));
6696
- }, [d]), useEffect(() => (b.current = debounce((k) => {
6697
- h(k);
6769
+ d && (h("all"), k(null));
6770
+ }, [d]), useEffect(() => (b.current = debounce((y) => {
6771
+ h(y);
6698
6772
  }, 500), () => {
6699
6773
  b.current && b.current.cancel();
6700
6774
  }), []);
6701
- const v = useCallback((k) => {
6702
- y(k), b.current && b.current(k);
6703
- }, []), S = useCallback(() => {
6704
- y(null), b.current && b.current.cancel();
6705
- }, []), j = useCallback((k) => {
6706
- b.current && b.current.cancel(), h(k), y(null);
6775
+ const S = useCallback((y) => {
6776
+ k(y), b.current && b.current(y);
6777
+ }, []), w = useCallback(() => {
6778
+ k(null), b.current && b.current.cancel();
6779
+ }, []), A = useCallback((y) => {
6780
+ b.current && b.current.cancel(), h(y), k(null);
6707
6781
  }, []), E = useMemo(
6708
6782
  () => d ? values(r).filter(
6709
- (k) => {
6710
- var _, T;
6711
- return (((_ = k.label) == null ? void 0 : _.toLowerCase()) + " " + ((T = k.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
6783
+ (y) => {
6784
+ var j, T;
6785
+ return (((j = y.label) == null ? void 0 : j.toLowerCase()) + " " + ((T = y.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
6712
6786
  }
6713
6787
  ) : r,
6714
6788
  [r, d]
6715
- ), w = useMemo(
6789
+ ), C = useMemo(
6716
6790
  () => d ? o.filter(
6717
- (k) => reject(filter(values(E), { group: k }), { hidden: !0 }).length > 0
6718
- ) : o.filter((k) => reject(filter(values(r), { group: k }), { hidden: !0 }).length > 0),
6791
+ (y) => reject(filter(values(E), { group: y }), { hidden: !0 }).length > 0
6792
+ ) : o.filter((y) => reject(filter(values(r), { group: y }), { hidden: !0 }).length > 0),
6719
6793
  [r, E, o, d]
6720
- ), A = useMemo(
6721
- () => sortBy(w, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
6722
- [w]
6723
- ), B = useMemo(() => m === "all" ? E : filter(values(E), { group: m }), [E, m]), I = useMemo(() => m === "all" ? A : [m], [A, m]);
6794
+ ), B = useMemo(
6795
+ () => sortBy(C, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
6796
+ [C]
6797
+ ), _ = useMemo(() => m === "all" ? E : filter(values(E), { group: m }), [E, m]), L = useMemo(() => m === "all" ? B : [m], [B, m]);
6724
6798
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
6725
6799
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
6726
6800
  Input$1,
@@ -6730,55 +6804,55 @@ const BlockCard = ({
6730
6804
  placeholder: i("Search blocks..."),
6731
6805
  value: d,
6732
6806
  className: "-ml-2",
6733
- onChange: (k) => p(k.target.value)
6807
+ onChange: (y) => p(y.target.value)
6734
6808
  }
6735
6809
  ) }),
6736
6810
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
6737
- A.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
6811
+ B.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
6738
6812
  /* @__PURE__ */ jsx(
6739
6813
  "button",
6740
6814
  {
6741
- onClick: () => j("all"),
6742
- onMouseEnter: () => v("all"),
6743
- onMouseLeave: S,
6815
+ onClick: () => A("all"),
6816
+ onMouseEnter: () => S("all"),
6817
+ onMouseLeave: w,
6744
6818
  className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || x === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
6745
6819
  children: i("All")
6746
6820
  },
6747
6821
  "sidebar-all"
6748
6822
  ),
6749
- A.map((k) => /* @__PURE__ */ jsx(
6823
+ B.map((y) => /* @__PURE__ */ jsx(
6750
6824
  "button",
6751
6825
  {
6752
- onClick: () => j(k),
6753
- onMouseEnter: () => v(k),
6754
- onMouseLeave: S,
6755
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === k || x === k ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
6756
- children: capitalize(i(k.toLowerCase()))
6826
+ onClick: () => A(y),
6827
+ onMouseEnter: () => S(y),
6828
+ onMouseLeave: w,
6829
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === y || x === y ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
6830
+ children: capitalize(i(y.toLowerCase()))
6757
6831
  },
6758
- `sidebar-${k}`
6832
+ `sidebar-${y}`
6759
6833
  ))
6760
6834
  ] }) }) }),
6761
- /* @__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: w.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: [
6835
+ /* @__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: C.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: [
6762
6836
  i("No blocks found matching"),
6763
6837
  ' "',
6764
6838
  d,
6765
6839
  '"'
6766
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: I.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
6767
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
6840
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((y) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
6841
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(y.toLowerCase())) }),
6768
6842
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
6769
- m === "all" ? filter(values(B), { group: k }) : values(B),
6843
+ m === "all" ? filter(values(_), { group: y }) : values(_),
6770
6844
  { hidden: !0 }
6771
- ).map((_) => /* @__PURE__ */ jsx(
6845
+ ).map((j) => /* @__PURE__ */ jsx(
6772
6846
  CoreBlock,
6773
6847
  {
6774
6848
  parentId: n,
6775
6849
  position: a,
6776
- block: _,
6777
- disabled: !canAcceptChildBlock(f, _.type) || !canBeNestedInside(f, _.type)
6850
+ block: j,
6851
+ disabled: !canAcceptChildBlock(f, j.type) || !canBeNestedInside(f, j.type)
6778
6852
  },
6779
- _.type
6853
+ j.type
6780
6854
  )) })
6781
- ] }, k)) }) }) })
6855
+ ] }, y)) }) }) })
6782
6856
  ] })
6783
6857
  ] });
6784
6858
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -6804,8 +6878,8 @@ const BlockCard = ({
6804
6878
  /* @__PURE__ */ jsxs(
6805
6879
  Tabs,
6806
6880
  {
6807
- onValueChange: (v) => {
6808
- d(""), c(v);
6881
+ onValueChange: (S) => {
6882
+ d(""), c(S);
6809
6883
  },
6810
6884
  value: i,
6811
6885
  className: "flex h-full max-h-full flex-col overflow-hidden",
@@ -6815,13 +6889,13 @@ const BlockCard = ({
6815
6889
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
6816
6890
  g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
6817
6891
  x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
6818
- map(h, (v) => /* @__PURE__ */ jsx(TabsTrigger, { value: v.id, children: React__default.createElement(v.tab) }, `tab-add-block-${v.id}`))
6892
+ map(h, (S) => /* @__PURE__ */ jsx(TabsTrigger, { value: S.id, children: React__default.createElement(S.tab) }, `tab-add-block-${S.id}`))
6819
6893
  ] }),
6820
6894
  /* @__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: n, position: a }) }) }) }),
6821
6895
  b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: n, position: a }) }),
6822
6896
  g && /* @__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: n, position: a }) }) }) }),
6823
6897
  x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: n, position: a }) }) : null,
6824
- map(h, (v) => /* @__PURE__ */ jsx(TabsContent, { value: v.id, children: React__default.createElement(v.tabContent, { close: m, parentId: n, position: a }) }, `panel-add-block-${v.id}`))
6898
+ map(h, (S) => /* @__PURE__ */ jsx(TabsContent, { value: S.id, children: React__default.createElement(S.tabContent, { close: m, parentId: n, position: a }) }, `panel-add-block-${S.id}`))
6825
6899
  ]
6826
6900
  }
6827
6901
  )
@@ -6839,7 +6913,6 @@ const BlockCard = ({
6839
6913
  CREATE_LIBRARY_BLOCK: "create_library_block",
6840
6914
  CREATE_LIBRARY_GROUP: "create_library_group",
6841
6915
  EDIT_LIBRARY_BLOCK: "edit_library_block",
6842
- EDIT_LIBRARY_GROUP: "edit_library_group",
6843
6916
  DELETE_LIBRARY_BLOCK: "delete_library_block"
6844
6917
  };
6845
6918
  Object.values(PERMISSIONS);
@@ -7120,33 +7193,33 @@ const selectParent = (o, r) => {
7120
7193
  var P;
7121
7194
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7122
7195
  let p = null;
7123
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: f } = useBlockHighlight(), { id: m, data: h, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: v, handleClick: S } = o, j = (N) => {
7196
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: f } = useBlockHighlight(), { id: m, data: h, isSelected: x, willReceiveDrop: k, isDragging: b, isEditing: S, handleClick: w } = o, A = (N) => {
7124
7197
  N.stopPropagation(), !l.includes(m) && o.toggle();
7125
7198
  }, E = (N) => {
7126
7199
  N.isInternal && (p = N.isOpen, N.isOpen && N.close());
7127
- }, w = (N) => {
7200
+ }, C = (N) => {
7128
7201
  N.isInternal && p !== null && (p ? N.open() : N.close(), p = null);
7129
- }, [A, B] = useAtom$1(currentAddSelection), I = () => {
7202
+ }, [B, _] = useAtom$1(currentAddSelection), L = () => {
7130
7203
  var N;
7131
- C(), o.parent.isSelected || B((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7132
- }, C = () => {
7133
- B(null);
7134
- }, k = (N) => {
7135
- C(), N.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), S(N);
7204
+ v(), o.parent.isSelected || _((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7205
+ }, v = () => {
7206
+ _(null);
7207
+ }, y = (N) => {
7208
+ v(), N.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), w(N);
7136
7209
  };
7137
7210
  useEffect(() => {
7138
7211
  const N = setTimeout(() => {
7139
- y && !o.isOpen && !b && !l.includes(m) && o.toggle();
7212
+ k && !o.isOpen && !b && !l.includes(m) && o.toggle();
7140
7213
  }, 500);
7141
7214
  return () => clearTimeout(N);
7142
- }, [y, o, b]);
7143
- const _ = (N, D) => {
7215
+ }, [k, o, b]);
7216
+ const j = (N, D) => {
7144
7217
  const O = c.contentDocument || c.contentWindow.document, R = O.querySelector(`[data-block-id=${N}]`);
7145
7218
  R && R.setAttribute("data-drop", D);
7146
7219
  const $ = R.getBoundingClientRect(), M = c.getBoundingClientRect();
7147
7220
  $.top >= M.top && $.left >= M.left && $.bottom <= M.bottom && $.right <= M.right || (O.documentElement.scrollTop = R.offsetTop - M.top);
7148
7221
  }, T = (N) => {
7149
- C();
7222
+ v();
7150
7223
  const D = get(o, "parent.id");
7151
7224
  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 });
7152
7225
  };
@@ -7168,26 +7241,26 @@ const selectParent = (o, r) => {
7168
7241
  ),
7169
7242
  /* @__PURE__ */ jsx("br", {})
7170
7243
  ] });
7171
- const L = useMemo(() => has(h, "_libBlockId") && !isEmpty(h._libBlockId), [h]);
7244
+ const I = useMemo(() => has(h, "_libBlockId") && !isEmpty(h._libBlockId) && (d(PERMISSIONS.CREATE_LIBRARY_BLOCK) || d(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [h, d]);
7172
7245
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7173
7246
  "div",
7174
7247
  {
7175
7248
  onMouseEnter: () => g(m),
7176
7249
  onMouseLeave: () => f(),
7177
- onClick: k,
7250
+ onClick: y,
7178
7251
  style: r,
7179
7252
  "data-node-id": m,
7180
7253
  ref: l.includes(m) ? null : n,
7181
7254
  onDragStart: () => E(o),
7182
- onDragEnd: () => w(o),
7255
+ onDragEnd: () => C(o),
7183
7256
  onDragOver: (N) => {
7184
- N.preventDefault(), _(m, "yes");
7257
+ N.preventDefault(), j(m, "yes");
7185
7258
  },
7186
7259
  onDragLeave: (N) => {
7187
- N.preventDefault(), _(m, "no");
7260
+ N.preventDefault(), j(m, "no");
7188
7261
  },
7189
7262
  onDrop: (N) => {
7190
- N.preventDefault(), _(m, "no");
7263
+ N.preventDefault(), j(m, "no");
7191
7264
  },
7192
7265
  children: [
7193
7266
  d(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(
@@ -7196,8 +7269,8 @@ const selectParent = (o, r) => {
7196
7269
  onClick: (N) => {
7197
7270
  N.stopPropagation(), T(o.childIndex);
7198
7271
  },
7199
- onMouseEnter: I,
7200
- onMouseLeave: C,
7272
+ onMouseEnter: L,
7273
+ onMouseLeave: v,
7201
7274
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
7202
7275
  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-primary p-1 outline outline-2 outline-white hover:bg-primary", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3 stroke-[4] text-white" }) })
7203
7276
  }
@@ -7208,11 +7281,11 @@ const selectParent = (o, r) => {
7208
7281
  className: cn(
7209
7282
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
7210
7283
  x ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
7211
- y && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7212
- (o == null ? void 0 : o.id) === A ? "bg-primary/10" : "",
7284
+ k && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7285
+ (o == null ? void 0 : o.id) === B ? "bg-primary/10" : "",
7213
7286
  b && "opacity-20",
7214
7287
  l.includes(m) ? "opacity-50" : "",
7215
- L && x && "bg-primary/20 text-primary"
7288
+ I && x && "bg-primary/20 text-primary"
7216
7289
  ),
7217
7290
  children: [
7218
7291
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -7220,7 +7293,7 @@ const selectParent = (o, r) => {
7220
7293
  "div",
7221
7294
  {
7222
7295
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
7223
- children: u && /* @__PURE__ */ jsx("button", { onClick: j, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${x ? "text-primary" : "text-slate-400"}` }) })
7296
+ children: u && /* @__PURE__ */ jsx("button", { onClick: A, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${x ? "text-primary" : "text-slate-400"}` }) })
7224
7297
  }
7225
7298
  ),
7226
7299
  /* @__PURE__ */ jsxs(
@@ -7228,12 +7301,12 @@ const selectParent = (o, r) => {
7228
7301
  {
7229
7302
  className: cn(
7230
7303
  "leading-1 flex items-center",
7231
- L && "text-primary/60",
7232
- L && x && "text-primary/80"
7304
+ I && "text-primary/60",
7305
+ I && x && "text-primary/80"
7233
7306
  ),
7234
7307
  children: [
7235
7308
  /* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
7236
- v ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
7309
+ S ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
7237
7310
  "div",
7238
7311
  {
7239
7312
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
@@ -7511,63 +7584,63 @@ const selectParent = (o, r) => {
7511
7584
  )
7512
7585
  ] });
7513
7586
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
7514
- const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), f = (v) => {
7515
- a(v);
7587
+ const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), f = (S) => {
7588
+ a(S);
7516
7589
  }, m = () => {
7517
- const v = l.find((S) => Object.keys(S)[0] === n);
7518
- if (v) {
7519
- const S = Object.values(v)[0];
7520
- S && typeof S == "object" && "fontFamily" in S && "borderRadius" in S && "colors" in S ? p(S) : console.error("Invalid preset structure:", S);
7590
+ const S = l.find((w) => Object.keys(w)[0] === n);
7591
+ if (S) {
7592
+ const w = Object.values(S)[0];
7593
+ w && typeof w == "object" && "fontFamily" in w && "borderRadius" in w && "colors" in w ? p(w) : console.error("Invalid preset structure:", w);
7521
7594
  } else
7522
7595
  console.error("Preset not found:", n);
7523
7596
  }, h = useDebouncedCallback(
7524
- (v, S) => {
7597
+ (S, w) => {
7525
7598
  p(() => ({
7526
7599
  ...d,
7527
7600
  fontFamily: {
7528
7601
  ...d.fontFamily,
7529
- [v.replace(/font-/g, "")]: S
7602
+ [S.replace(/font-/g, "")]: w
7530
7603
  }
7531
7604
  }));
7532
7605
  },
7533
7606
  [d],
7534
7607
  200
7535
7608
  ), x = useDebouncedCallback(
7536
- (v) => {
7609
+ (S) => {
7537
7610
  p(() => ({
7538
7611
  ...d,
7539
- borderRadius: `${v}px`
7612
+ borderRadius: `${S}px`
7540
7613
  }));
7541
7614
  },
7542
7615
  [d],
7543
7616
  200
7544
- ), y = useDebouncedCallback(
7545
- (v, S) => {
7617
+ ), k = useDebouncedCallback(
7618
+ (S, w) => {
7546
7619
  p(() => {
7547
- const j = get(d, `colors.${v}`);
7548
- return r ? set(j, 1, S) : set(j, 0, S), {
7620
+ const A = get(d, `colors.${S}`);
7621
+ return r ? set(A, 1, w) : set(A, 0, w), {
7549
7622
  ...d,
7550
7623
  colors: {
7551
7624
  ...d.colors,
7552
- [v]: j
7625
+ [S]: A
7553
7626
  }
7554
7627
  };
7555
7628
  });
7556
7629
  },
7557
7630
  [d],
7558
7631
  200
7559
- ), b = (v) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(v.items).map(([S]) => {
7560
- const j = get(d, `colors.${S}.${r ? 1 : 0}`);
7632
+ ), b = (S) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(S.items).map(([w]) => {
7633
+ const A = get(d, `colors.${w}.${r ? 1 : 0}`);
7561
7634
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
7562
7635
  /* @__PURE__ */ jsx(
7563
7636
  ColorPickerInput,
7564
7637
  {
7565
- value: j,
7566
- onChange: (E) => y(S, E)
7638
+ value: A,
7639
+ onChange: (E) => k(w, E)
7567
7640
  }
7568
7641
  ),
7569
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: S.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!S.toLowerCase().includes("foreground") && !S.toLowerCase().includes("border") && !S.toLowerCase().includes("input") && !S.toLowerCase().includes("ring") && !S.toLowerCase().includes("background") ? " Background" : "") })
7570
- ] }, S);
7642
+ /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: w.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!w.toLowerCase().includes("foreground") && !w.toLowerCase().includes("border") && !w.toLowerCase().includes("input") && !w.toLowerCase().includes("ring") && !w.toLowerCase().includes("background") ? " Background" : "") })
7643
+ ] }, w);
7571
7644
  }) });
7572
7645
  return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7573
7646
  /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
@@ -7578,11 +7651,11 @@ const selectParent = (o, r) => {
7578
7651
  "select",
7579
7652
  {
7580
7653
  value: n,
7581
- onChange: (v) => f(v.target.value),
7654
+ onChange: (S) => f(S.target.value),
7582
7655
  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",
7583
7656
  children: [
7584
7657
  /* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
7585
- Array.isArray(l) && l.map((v) => /* @__PURE__ */ jsx("option", { value: Object.keys(v)[0], children: capitalize(Object.keys(v)[0]) }, Object.keys(v)[0]))
7658
+ Array.isArray(l) && l.map((S) => /* @__PURE__ */ jsx("option", { value: Object.keys(S)[0], children: capitalize(Object.keys(S)[0]) }, Object.keys(S)[0]))
7586
7659
  ]
7587
7660
  }
7588
7661
  )
@@ -7599,14 +7672,14 @@ const selectParent = (o, r) => {
7599
7672
  ) })
7600
7673
  ] }),
7601
7674
  /* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
7602
- (u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([v, S]) => /* @__PURE__ */ jsx(
7675
+ (u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([S, w]) => /* @__PURE__ */ jsx(
7603
7676
  FontSelector,
7604
7677
  {
7605
- label: v,
7606
- value: d.fontFamily[v.replace(/font-/g, "")] || S[Object.keys(S)[0]],
7607
- onChange: (j) => h(v, j)
7678
+ label: S,
7679
+ value: d.fontFamily[S.replace(/font-/g, "")] || w[Object.keys(w)[0]],
7680
+ onChange: (A) => h(S, A)
7608
7681
  },
7609
- v
7682
+ S
7610
7683
  )) }),
7611
7684
  (u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
7612
7685
  /* @__PURE__ */ jsx(Label, { className: "text-sm", children: g("Border Radius") }),
@@ -7617,7 +7690,7 @@ const selectParent = (o, r) => {
7617
7690
  ] }),
7618
7691
  (u == null ? void 0 : u.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
7619
7692
  /* @__PURE__ */ jsx(Label, { className: "text-sm", children: g("Colors") }),
7620
- /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((v) => b(v)) }, r ? "dark" : "light")
7693
+ /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((S) => b(S)) }, r ? "dark" : "light")
7621
7694
  ] })
7622
7695
  ] }),
7623
7696
  /* @__PURE__ */ jsx("br", {}),
@@ -8093,8 +8166,8 @@ const AIUserPrompt = ({ blockId: o }) => {
8093
8166
  (x = f.current) == null || x.focus();
8094
8167
  }, []);
8095
8168
  const h = (x) => {
8096
- const { usage: y } = x || {};
8097
- !l && y && g(y), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8169
+ const { usage: k } = x || {};
8170
+ !l && k && g(k), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8098
8171
  };
8099
8172
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8100
8173
  /* @__PURE__ */ jsxs(
@@ -8352,72 +8425,72 @@ const UndoRedo = () => {
8352
8425
  var x;
8353
8426
  return (x = m.onMount) == null ? void 0 : x.call(m, h);
8354
8427
  }, ...f) => {
8355
- const m = f[0] || ((B) => {
8356
- let I = o.get(B);
8357
- return I || (I = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(B, I), u == null || u(B, A)), I;
8428
+ const m = f[0] || ((_) => {
8429
+ let L = o.get(_);
8430
+ return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(_, L), u == null || u(_, B)), L;
8358
8431
  }), h = f[1] || (() => {
8359
- let B, I;
8360
- const C = (k) => {
8432
+ let _, L;
8433
+ const v = (y) => {
8361
8434
  try {
8362
- k();
8363
- } catch (_) {
8364
- B || (B = !0, I = _);
8435
+ y();
8436
+ } catch (j) {
8437
+ _ || (_ = !0, L = j);
8365
8438
  }
8366
8439
  };
8367
8440
  do {
8368
- c.f && C(c.f);
8369
- const k = /* @__PURE__ */ new Set(), _ = k.add.bind(k);
8441
+ c.f && v(c.f);
8442
+ const y = /* @__PURE__ */ new Set(), j = y.add.bind(y);
8370
8443
  a.forEach((T) => {
8371
- var L;
8372
- return (L = r.get(T)) == null ? void 0 : L.l.forEach(_);
8373
- }), a.clear(), i.forEach(_), i.clear(), l.forEach(_), l.clear(), k.forEach(C), a.size && x();
8444
+ var I;
8445
+ return (I = r.get(T)) == null ? void 0 : I.l.forEach(j);
8446
+ }), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), y.forEach(v), a.size && x();
8374
8447
  } while (a.size || i.size || l.size);
8375
- if (B)
8376
- throw I;
8448
+ if (_)
8449
+ throw L;
8377
8450
  }), x = f[2] || (() => {
8378
- const B = [], I = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
8379
- for (; k.length; ) {
8380
- const _ = k[k.length - 1], T = m(_);
8381
- if (C.has(_)) {
8382
- k.pop();
8451
+ const _ = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
8452
+ for (; y.length; ) {
8453
+ const j = y[y.length - 1], T = m(j);
8454
+ if (v.has(j)) {
8455
+ y.pop();
8383
8456
  continue;
8384
8457
  }
8385
- if (I.has(_)) {
8386
- n.get(_) === T.n && B.push([_, T]), C.add(_), k.pop();
8458
+ if (L.has(j)) {
8459
+ n.get(j) === T.n && _.push([j, T]), v.add(j), y.pop();
8387
8460
  continue;
8388
8461
  }
8389
- I.add(_);
8390
- for (const L of getMountedOrPendingDependents(_, T, r))
8391
- I.has(L) || k.push(L);
8462
+ L.add(j);
8463
+ for (const I of getMountedOrPendingDependents(j, T, r))
8464
+ L.has(I) || y.push(I);
8392
8465
  }
8393
- for (let _ = B.length - 1; _ >= 0; --_) {
8394
- const [T, L] = B[_];
8466
+ for (let j = _.length - 1; j >= 0; --j) {
8467
+ const [T, I] = _[j];
8395
8468
  let P = !1;
8396
- for (const N of L.d.keys())
8469
+ for (const N of I.d.keys())
8397
8470
  if (N !== T && a.has(N)) {
8398
8471
  P = !0;
8399
8472
  break;
8400
8473
  }
8401
- P && (y(T), S(T)), n.delete(T);
8474
+ P && (k(T), w(T)), n.delete(T);
8402
8475
  }
8403
- }), y = f[3] || ((B) => {
8404
- var I, C;
8405
- const k = m(B);
8406
- if (isAtomStateInitialized(k) && (r.has(B) && n.get(B) !== k.n || Array.from(k.d).every(
8476
+ }), k = f[3] || ((_) => {
8477
+ var L, v;
8478
+ const y = m(_);
8479
+ if (isAtomStateInitialized(y) && (r.has(_) && n.get(_) !== y.n || Array.from(y.d).every(
8407
8480
  ([R, $]) => (
8408
8481
  // Recursively, read the atom state of the dependency, and
8409
8482
  // check if the atom epoch number is unchanged
8410
- y(R).n === $
8483
+ k(R).n === $
8411
8484
  )
8412
8485
  )))
8413
- return k;
8414
- k.d.clear();
8415
- let _ = !0;
8486
+ return y;
8487
+ y.d.clear();
8488
+ let j = !0;
8416
8489
  const T = () => {
8417
- r.has(B) && (S(B), x(), h());
8418
- }, L = (R) => {
8490
+ r.has(_) && (w(_), x(), h());
8491
+ }, I = (R) => {
8419
8492
  var $;
8420
- if (isSelfAtom(B, R)) {
8493
+ if (isSelfAtom(_, R)) {
8421
8494
  const H = m(R);
8422
8495
  if (!isAtomStateInitialized(H))
8423
8496
  if (hasInitialValue(R))
@@ -8426,11 +8499,11 @@ const UndoRedo = () => {
8426
8499
  throw new Error("no atom init");
8427
8500
  return returnAtomValue(H);
8428
8501
  }
8429
- const M = y(R);
8502
+ const M = k(R);
8430
8503
  try {
8431
8504
  return returnAtomValue(M);
8432
8505
  } finally {
8433
- k.d.set(R, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(B, k.v, M), ($ = r.get(R)) == null || $.t.add(B), _ || T();
8506
+ y.d.set(R, M.n), isPendingPromise(y.v) && addPendingPromiseToDependency(_, y.v, M), ($ = r.get(R)) == null || $.t.add(_), j || T();
8434
8507
  }
8435
8508
  };
8436
8509
  let P, N;
@@ -8439,100 +8512,100 @@ const UndoRedo = () => {
8439
8512
  return P || (P = new AbortController()), P.signal;
8440
8513
  },
8441
8514
  get setSelf() {
8442
- return !N && isActuallyWritableAtom(B) && (N = (...R) => {
8443
- if (!_)
8515
+ return !N && isActuallyWritableAtom(_) && (N = (...R) => {
8516
+ if (!j)
8444
8517
  try {
8445
- return v(B, ...R);
8518
+ return S(_, ...R);
8446
8519
  } finally {
8447
8520
  x(), h();
8448
8521
  }
8449
8522
  }), N;
8450
8523
  }
8451
- }, O = k.n;
8524
+ }, O = y.n;
8452
8525
  try {
8453
- const R = d(B, L, D);
8454
- return setAtomStateValueOrPromise(B, R, m), isPromiseLike$1(R) && ((I = R.onCancel) == null || I.call(R, () => P == null ? void 0 : P.abort()), R.then(
8526
+ const R = d(_, I, D);
8527
+ return setAtomStateValueOrPromise(_, R, m), isPromiseLike$1(R) && ((L = R.onCancel) == null || L.call(R, () => P == null ? void 0 : P.abort()), R.then(
8455
8528
  T,
8456
8529
  T
8457
- )), k;
8530
+ )), y;
8458
8531
  } catch (R) {
8459
- return delete k.v, k.e = R, ++k.n, k;
8532
+ return delete y.v, y.e = R, ++y.n, y;
8460
8533
  } finally {
8461
- _ = !1, O !== k.n && n.get(B) === O && (n.set(B, k.n), a.add(B), (C = c.c) == null || C.call(c, B));
8534
+ j = !1, O !== y.n && n.get(_) === O && (n.set(_, y.n), a.add(_), (v = c.c) == null || v.call(c, _));
8462
8535
  }
8463
- }), b = f[4] || ((B) => {
8464
- const I = [B];
8465
- for (; I.length; ) {
8466
- const C = I.pop(), k = m(C);
8467
- for (const _ of getMountedOrPendingDependents(C, k, r)) {
8468
- const T = m(_);
8469
- n.set(_, T.n), I.push(_);
8536
+ }), b = f[4] || ((_) => {
8537
+ const L = [_];
8538
+ for (; L.length; ) {
8539
+ const v = L.pop(), y = m(v);
8540
+ for (const j of getMountedOrPendingDependents(v, y, r)) {
8541
+ const T = m(j);
8542
+ n.set(j, T.n), L.push(j);
8470
8543
  }
8471
8544
  }
8472
- }), v = f[5] || ((B, ...I) => {
8473
- let C = !0;
8474
- const k = (T) => returnAtomValue(y(T)), _ = (T, ...L) => {
8545
+ }), S = f[5] || ((_, ...L) => {
8546
+ let v = !0;
8547
+ const y = (T) => returnAtomValue(k(T)), j = (T, ...I) => {
8475
8548
  var P;
8476
8549
  const N = m(T);
8477
8550
  try {
8478
- if (isSelfAtom(B, T)) {
8551
+ if (isSelfAtom(_, T)) {
8479
8552
  if (!hasInitialValue(T))
8480
8553
  throw new Error("atom not writable");
8481
- const D = N.n, O = L[0];
8482
- setAtomStateValueOrPromise(T, O, m), S(T), D !== N.n && (a.add(T), (P = c.c) == null || P.call(c, T), b(T));
8554
+ const D = N.n, O = I[0];
8555
+ setAtomStateValueOrPromise(T, O, m), w(T), D !== N.n && (a.add(T), (P = c.c) == null || P.call(c, T), b(T));
8483
8556
  return;
8484
8557
  } else
8485
- return v(T, ...L);
8558
+ return S(T, ...I);
8486
8559
  } finally {
8487
- C || (x(), h());
8560
+ v || (x(), h());
8488
8561
  }
8489
8562
  };
8490
8563
  try {
8491
- return p(B, k, _, ...I);
8564
+ return p(_, y, j, ...L);
8492
8565
  } finally {
8493
- C = !1;
8566
+ v = !1;
8494
8567
  }
8495
- }), S = f[6] || ((B) => {
8496
- var I;
8497
- const C = m(B), k = r.get(B);
8498
- if (k && !isPendingPromise(C.v)) {
8499
- for (const [_, T] of C.d)
8500
- if (!k.d.has(_)) {
8501
- const L = m(_);
8502
- j(_).t.add(B), k.d.add(_), T !== L.n && (a.add(_), (I = c.c) == null || I.call(c, _), b(_));
8568
+ }), w = f[6] || ((_) => {
8569
+ var L;
8570
+ const v = m(_), y = r.get(_);
8571
+ if (y && !isPendingPromise(v.v)) {
8572
+ for (const [j, T] of v.d)
8573
+ if (!y.d.has(j)) {
8574
+ const I = m(j);
8575
+ A(j).t.add(_), y.d.add(j), T !== I.n && (a.add(j), (L = c.c) == null || L.call(c, j), b(j));
8503
8576
  }
8504
- for (const _ of k.d || [])
8505
- if (!C.d.has(_)) {
8506
- k.d.delete(_);
8507
- const T = E(_);
8508
- T == null || T.t.delete(B);
8577
+ for (const j of y.d || [])
8578
+ if (!v.d.has(j)) {
8579
+ y.d.delete(j);
8580
+ const T = E(j);
8581
+ T == null || T.t.delete(_);
8509
8582
  }
8510
8583
  }
8511
- }), j = f[7] || ((B) => {
8512
- var I;
8513
- const C = m(B);
8514
- let k = r.get(B);
8515
- if (!k) {
8516
- y(B);
8517
- for (const _ of C.d.keys())
8518
- j(_).t.add(B);
8519
- if (k = {
8584
+ }), A = f[7] || ((_) => {
8585
+ var L;
8586
+ const v = m(_);
8587
+ let y = r.get(_);
8588
+ if (!y) {
8589
+ k(_);
8590
+ for (const j of v.d.keys())
8591
+ A(j).t.add(_);
8592
+ if (y = {
8520
8593
  l: /* @__PURE__ */ new Set(),
8521
- d: new Set(C.d.keys()),
8594
+ d: new Set(v.d.keys()),
8522
8595
  t: /* @__PURE__ */ new Set()
8523
- }, r.set(B, k), (I = c.m) == null || I.call(c, B), isActuallyWritableAtom(B)) {
8524
- const _ = () => {
8596
+ }, r.set(_, y), (L = c.m) == null || L.call(c, _), isActuallyWritableAtom(_)) {
8597
+ const j = () => {
8525
8598
  let T = !0;
8526
- const L = (...P) => {
8599
+ const I = (...P) => {
8527
8600
  try {
8528
- return v(B, ...P);
8601
+ return S(_, ...P);
8529
8602
  } finally {
8530
8603
  T || (x(), h());
8531
8604
  }
8532
8605
  };
8533
8606
  try {
8534
- const P = g(B, L);
8535
- P && (k.u = () => {
8607
+ const P = g(_, I);
8608
+ P && (y.u = () => {
8536
8609
  T = !0;
8537
8610
  try {
8538
8611
  P();
@@ -8544,27 +8617,27 @@ const UndoRedo = () => {
8544
8617
  T = !1;
8545
8618
  }
8546
8619
  };
8547
- l.add(_);
8620
+ l.add(j);
8548
8621
  }
8549
8622
  }
8550
- return k;
8551
- }), E = f[8] || ((B) => {
8552
- var I;
8553
- const C = m(B);
8554
- let k = r.get(B);
8555
- if (k && !k.l.size && !Array.from(k.t).some((_) => {
8623
+ return y;
8624
+ }), E = f[8] || ((_) => {
8625
+ var L;
8626
+ const v = m(_);
8627
+ let y = r.get(_);
8628
+ if (y && !y.l.size && !Array.from(y.t).some((j) => {
8556
8629
  var T;
8557
- return (T = r.get(_)) == null ? void 0 : T.d.has(B);
8630
+ return (T = r.get(j)) == null ? void 0 : T.d.has(_);
8558
8631
  })) {
8559
- k.u && i.add(k.u), k = void 0, r.delete(B), (I = c.u) == null || I.call(c, B);
8560
- for (const _ of C.d.keys()) {
8561
- const T = E(_);
8562
- T == null || T.t.delete(B);
8632
+ y.u && i.add(y.u), y = void 0, r.delete(_), (L = c.u) == null || L.call(c, _);
8633
+ for (const j of v.d.keys()) {
8634
+ const T = E(j);
8635
+ T == null || T.t.delete(_);
8563
8636
  }
8564
8637
  return;
8565
8638
  }
8566
- return k;
8567
- }), w = [
8639
+ return y;
8640
+ }), C = [
8568
8641
  // store state
8569
8642
  o,
8570
8643
  r,
@@ -8582,29 +8655,29 @@ const UndoRedo = () => {
8582
8655
  m,
8583
8656
  h,
8584
8657
  x,
8585
- y,
8658
+ k,
8586
8659
  b,
8587
- v,
8588
8660
  S,
8589
- j,
8661
+ w,
8662
+ A,
8590
8663
  E
8591
- ], A = {
8592
- get: (B) => returnAtomValue(y(B)),
8593
- set: (B, ...I) => {
8664
+ ], B = {
8665
+ get: (_) => returnAtomValue(k(_)),
8666
+ set: (_, ...L) => {
8594
8667
  try {
8595
- return v(B, ...I);
8668
+ return S(_, ...L);
8596
8669
  } finally {
8597
8670
  x(), h();
8598
8671
  }
8599
8672
  },
8600
- sub: (B, I) => {
8601
- const k = j(B).l;
8602
- return k.add(I), h(), () => {
8603
- k.delete(I), E(B), h();
8673
+ sub: (_, L) => {
8674
+ const y = A(_).l;
8675
+ return y.add(L), h(), () => {
8676
+ y.delete(L), E(_), h();
8604
8677
  };
8605
8678
  }
8606
8679
  };
8607
- return Object.defineProperty(A, BUILDING_BLOCKS, { value: w }), A;
8680
+ return Object.defineProperty(B, BUILDING_BLOCKS, { value: C }), B;
8608
8681
  }, INTERNAL_buildStoreRev1 = buildStore, createStore = () => INTERNAL_buildStoreRev1();
8609
8682
  let defaultStore;
8610
8683
  const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), defaultStore), StoreContext = createContext(
@@ -8728,31 +8801,31 @@ function AIChatPanel() {
8728
8801
  content: n,
8729
8802
  timestamp: /* @__PURE__ */ new Date()
8730
8803
  };
8731
- r((v) => [...v, b]), a(""), i(!0), setTimeout(() => {
8732
- const v = {
8804
+ r((S) => [...S, b]), a(""), i(!0), setTimeout(() => {
8805
+ const S = {
8733
8806
  id: (Date.now() + 1).toString(),
8734
8807
  role: "assistant",
8735
8808
  content: "This is a sample response from the AI assistant. In a real implementation, this would be replaced with an actual response from the AI model.",
8736
8809
  timestamp: /* @__PURE__ */ new Date()
8737
8810
  };
8738
- r((S) => [...S, v]), i(!1), d(null);
8811
+ r((w) => [...w, S]), i(!1), d(null);
8739
8812
  }, 1500);
8740
8813
  }, m = (b) => {
8741
8814
  b.key === "Enter" && !b.shiftKey && (b.preventDefault(), f());
8742
8815
  }, h = (b) => {
8743
- var S;
8744
- const v = (S = b.target.files) == null ? void 0 : S[0];
8745
- if (v) {
8746
- const j = new FileReader();
8747
- j.onload = (E) => {
8748
- var w;
8749
- d((w = E.target) == null ? void 0 : w.result);
8750
- }, j.readAsDataURL(v);
8816
+ var w;
8817
+ const S = (w = b.target.files) == null ? void 0 : w[0];
8818
+ if (S) {
8819
+ const A = new FileReader();
8820
+ A.onload = (E) => {
8821
+ var C;
8822
+ d((C = E.target) == null ? void 0 : C.result);
8823
+ }, A.readAsDataURL(S);
8751
8824
  }
8752
8825
  }, x = () => {
8753
8826
  var b;
8754
8827
  (b = p.current) == null || b.click();
8755
- }, y = () => {
8828
+ }, k = () => {
8756
8829
  d(null), p.current && (p.current.value = "");
8757
8830
  };
8758
8831
  return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
@@ -8798,7 +8871,7 @@ function AIChatPanel() {
8798
8871
  size: "icon",
8799
8872
  variant: "destructive",
8800
8873
  className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
8801
- onClick: y,
8874
+ onClick: k,
8802
8875
  children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
8803
8876
  }
8804
8877
  )
@@ -8941,7 +9014,7 @@ const AiAssistant = () => {
8941
9014
  preloadedAttributes: r = [],
8942
9015
  onAttributesChange: n
8943
9016
  }) {
8944
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [f, m] = useState(""), h = useRef(null), x = useRef(null), y = usePageExternalData();
9017
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [f, m] = useState(""), h = useRef(null), x = useRef(null), k = usePageExternalData();
8945
9018
  useEffect(() => {
8946
9019
  l(r);
8947
9020
  }, [r]);
@@ -8951,43 +9024,43 @@ const AiAssistant = () => {
8951
9024
  return;
8952
9025
  }
8953
9026
  if (i) {
8954
- const A = [...a, { key: i, value: d }];
8955
- n(A), l(a), c(""), p(""), m("");
9027
+ const B = [...a, { key: i, value: d }];
9028
+ n(B), l(a), c(""), p(""), m("");
8956
9029
  }
8957
- }, v = (A) => {
8958
- const B = a.filter((I, C) => C !== A);
8959
- n(B), l(B);
8960
- }, S = (A) => {
8961
- g(A), c(a[A].key), p(a[A].value);
8962
- }, j = () => {
9030
+ }, S = (B) => {
9031
+ const _ = a.filter((L, v) => v !== B);
9032
+ n(_), l(_);
9033
+ }, w = (B) => {
9034
+ g(B), c(a[B].key), p(a[B].value);
9035
+ }, A = () => {
8963
9036
  if (i.startsWith("@")) {
8964
9037
  m("Attribute keys cannot start with '@'");
8965
9038
  return;
8966
9039
  }
8967
9040
  if (u !== null && i) {
8968
- const A = [...a];
8969
- A[u] = { key: i, value: d }, n(A), l(A), g(null), c(""), p(""), m("");
9041
+ const B = [...a];
9042
+ B[u] = { key: i, value: d }, n(B), l(B), g(null), c(""), p(""), m("");
8970
9043
  }
8971
- }, E = (A) => {
8972
- A.key === "Enter" && !A.shiftKey && (A.preventDefault(), u !== null ? j() : b());
8973
- }, w = useCallback((A) => {
8974
- const B = (k) => /[.,!?;:]/.test(k), I = (k, _, T) => {
8975
- let L = "", P = "";
8976
- const N = _ > 0 ? k[_ - 1] : "", D = _ < k.length ? k[_] : "";
8977
- return _ > 0 && (N === "." || !B(N) && N !== " ") && (L = " "), _ < k.length && !B(D) && D !== " " && (P = " "), {
8978
- text: L + T + P,
8979
- prefixLength: L.length,
9044
+ }, E = (B) => {
9045
+ B.key === "Enter" && !B.shiftKey && (B.preventDefault(), u !== null ? A() : b());
9046
+ }, C = useCallback((B) => {
9047
+ const _ = (y) => /[.,!?;:]/.test(y), L = (y, j, T) => {
9048
+ let I = "", P = "";
9049
+ const N = j > 0 ? y[j - 1] : "", D = j < y.length ? y[j] : "";
9050
+ return j > 0 && (N === "." || !_(N) && N !== " ") && (I = " "), j < y.length && !_(D) && D !== " " && (P = " "), {
9051
+ text: I + T + P,
9052
+ prefixLength: I.length,
8980
9053
  suffixLength: P.length
8981
9054
  };
8982
- }, C = x.current;
8983
- if (C) {
8984
- const k = C.selectionStart || 0, _ = C.value || "", T = C.selectionEnd || k;
8985
- if (T > k) {
8986
- const O = `{{${A}}}`, { text: R } = I(_, k, O), $ = _.slice(0, k) + R + _.slice(T);
9055
+ }, v = x.current;
9056
+ if (v) {
9057
+ const y = v.selectionStart || 0, j = v.value || "", T = v.selectionEnd || y;
9058
+ if (T > y) {
9059
+ const O = `{{${B}}}`, { text: R } = L(j, y, O), $ = j.slice(0, y) + R + j.slice(T);
8987
9060
  p($);
8988
9061
  return;
8989
9062
  }
8990
- const P = `{{${A}}}`, { text: N } = I(_, k, P), D = _.slice(0, k) + N + _.slice(k);
9063
+ const P = `{{${B}}}`, { text: N } = L(j, y, P), D = j.slice(0, y) + N + j.slice(y);
8991
9064
  p(D);
8992
9065
  }
8993
9066
  }, []);
@@ -8995,8 +9068,8 @@ const AiAssistant = () => {
8995
9068
  /* @__PURE__ */ jsxs(
8996
9069
  "form",
8997
9070
  {
8998
- onSubmit: (A) => {
8999
- A.preventDefault(), u !== null ? j() : b();
9071
+ onSubmit: (B) => {
9072
+ B.preventDefault(), u !== null ? A() : b();
9000
9073
  },
9001
9074
  className: "space-y-3",
9002
9075
  children: [
@@ -9012,7 +9085,7 @@ const AiAssistant = () => {
9012
9085
  id: "attrKey",
9013
9086
  ref: h,
9014
9087
  value: i,
9015
- onChange: (A) => c(A.target.value),
9088
+ onChange: (B) => c(B.target.value),
9016
9089
  placeholder: "Enter Key",
9017
9090
  className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
9018
9091
  }
@@ -9021,7 +9094,7 @@ const AiAssistant = () => {
9021
9094
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9022
9095
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9023
9096
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9024
- !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: w })
9097
+ !isEmpty(k) && /* @__PURE__ */ jsx(NestedPathSelector, { data: k, onSelect: C })
9025
9098
  ] }),
9026
9099
  /* @__PURE__ */ jsx(
9027
9100
  Textarea,
@@ -9033,7 +9106,7 @@ const AiAssistant = () => {
9033
9106
  rows: 2,
9034
9107
  ref: x,
9035
9108
  value: d,
9036
- onChange: (A) => p(A.target.value),
9109
+ onChange: (B) => p(B.target.value),
9037
9110
  onKeyDown: E,
9038
9111
  placeholder: "Enter Value",
9039
9112
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
@@ -9046,16 +9119,16 @@ const AiAssistant = () => {
9046
9119
  ]
9047
9120
  }
9048
9121
  ),
9049
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((A, B) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9122
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((B, _) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9050
9123
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9051
- /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: A.key }),
9052
- /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: A.value.toString() })
9124
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: B.key }),
9125
+ /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: B.value.toString() })
9053
9126
  ] }),
9054
9127
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9055
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => S(B), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9056
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(B), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9128
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => w(_), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9129
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => S(_), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9057
9130
  ] })
9058
- ] }, B)) })
9131
+ ] }, _)) })
9059
9132
  ] });
9060
9133
  }), BlockAttributesEditor = React.memo(() => {
9061
9134
  const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9164,34 +9237,34 @@ const RootLayout = () => {
9164
9237
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9165
9238
  n("outline");
9166
9239
  });
9167
- const p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = (w) => {
9168
- w.preventDefault();
9169
- }, f = (w) => {
9170
- n(r === w ? null : w);
9171
- }, m = useSidebarMenuItems(), { t: h } = useTranslation(), x = useMemo(() => [...m, ...p], [m, p]), y = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: r }) ?? first(x), v = get(b, "width", DEFAULT_PANEL_WIDTH);
9240
+ const p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = (C) => {
9241
+ C.preventDefault();
9242
+ }, f = (C) => {
9243
+ n(r === C ? null : C);
9244
+ }, m = useSidebarMenuItems(), { t: h } = useTranslation(), x = useMemo(() => [...m, ...p], [m, p]), k = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: r }) ?? first(x), S = get(b, "width", DEFAULT_PANEL_WIDTH);
9172
9245
  useEffect(() => {
9173
9246
  if (r !== null) {
9174
- const w = find(x, { id: r });
9175
- w && get(w, "view", "standard") === "standard" && (a.current = r, i(get(w, "width", DEFAULT_PANEL_WIDTH)));
9247
+ const C = find(x, { id: r });
9248
+ C && get(C, "view", "standard") === "standard" && (a.current = r, i(get(C, "width", DEFAULT_PANEL_WIDTH)));
9176
9249
  }
9177
9250
  }, [r, x]);
9178
- const S = useMemo(() => {
9251
+ const w = useMemo(() => {
9179
9252
  if (r === null) return 0;
9180
- const w = find(x, { id: r });
9181
- return get(w, "view", "standard") === "standard" ? v : l;
9182
- }, [r, v, l, x]), j = () => {
9253
+ const C = find(x, { id: r });
9254
+ return get(C, "view", "standard") === "standard" ? S : l;
9255
+ }, [r, S, l, x]), A = () => {
9183
9256
  n(a.current);
9184
9257
  };
9185
9258
  useEffect(() => {
9186
9259
  find(x, { id: r }) || n("outline");
9187
9260
  }, [r, x]);
9188
9261
  const E = useCallback(
9189
- (w) => {
9190
- f(w);
9262
+ (C) => {
9263
+ f(C);
9191
9264
  },
9192
9265
  [f]
9193
9266
  );
9194
- return /* @__PURE__ */ jsx("div", { dir: y, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9267
+ return /* @__PURE__ */ jsx("div", { dir: k, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9195
9268
  /* @__PURE__ */ jsxs(
9196
9269
  "div",
9197
9270
  {
@@ -9201,33 +9274,33 @@ const RootLayout = () => {
9201
9274
  /* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
9202
9275
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9203
9276
  /* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9204
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: x.map((w, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9205
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(w, "button", NoopComponent), {
9277
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: x.map((C, B) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9278
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(C, "button", NoopComponent), {
9206
9279
  position: "top",
9207
- panelId: w.id,
9208
- isActive: r === w.id,
9209
- show: () => E(w.id)
9280
+ panelId: C.id,
9281
+ isActive: r === C.id,
9282
+ show: () => E(C.id)
9210
9283
  }) }),
9211
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h(w.label) }) })
9212
- ] }, "button-top-" + A)) }),
9284
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h(C.label) }) })
9285
+ ] }, "button-top-" + B)) }),
9213
9286
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9214
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: u == null ? void 0 : u.map((w, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9215
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(w, "button", NoopComponent), {
9287
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: u == null ? void 0 : u.map((C, B) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9288
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(C, "button", NoopComponent), {
9216
9289
  position: "bottom",
9217
- panelId: w.id,
9218
- isActive: r === w.id,
9219
- show: () => E(w.id)
9290
+ panelId: C.id,
9291
+ isActive: r === C.id,
9292
+ show: () => E(C.id)
9220
9293
  }) }),
9221
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h(w.label) }) })
9222
- ] }, "button-bottom-" + A)) })
9294
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h(C.label) }) })
9295
+ ] }, "button-bottom-" + B)) })
9223
9296
  ] }),
9224
9297
  /* @__PURE__ */ jsx(
9225
9298
  motion.div,
9226
9299
  {
9227
9300
  id: "left-panel",
9228
9301
  className: "h-full max-h-full border-r border-border",
9229
- initial: { width: S },
9230
- animate: { width: S },
9302
+ initial: { width: w },
9303
+ animate: { width: w },
9231
9304
  transition: { duration: 0.3, ease: "easeInOut" },
9232
9305
  children: r !== null && get(b, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
9233
9306
  /* @__PURE__ */ jsx(
@@ -9278,7 +9351,7 @@ const RootLayout = () => {
9278
9351
  ] }) })
9279
9352
  }
9280
9353
  ),
9281
- r !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => j(), children: /* @__PURE__ */ jsxs(SheetContent, { side: "left", className: "p-0 sm:max-w-full", style: { width: `${v}px` }, children: [
9354
+ r !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => A(), children: /* @__PURE__ */ jsxs(SheetContent, { side: "left", className: "p-0 sm:max-w-full", style: { width: `${S}px` }, children: [
9282
9355
  /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border p-4 pb-2", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
9283
9356
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9284
9357
  /* @__PURE__ */ jsx("span", { children: h(get(b, "label", "")) })
@@ -9286,7 +9359,7 @@ const RootLayout = () => {
9286
9359
  /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {}) }) })
9287
9360
  ] }) }),
9288
9361
  " ",
9289
- r !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => j(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "p-0", style: { maxWidth: `${v}px` }, children: [
9362
+ r !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => A(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "p-0", style: { maxWidth: `${S}px` }, children: [
9290
9363
  /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border p-4 pb-2", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
9291
9364
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9292
9365
  /* @__PURE__ */ jsx("span", { children: h(get(b, "label", "")) })
@@ -9315,7 +9388,7 @@ const RootLayout = () => {
9315
9388
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9316
9389
  /* @__PURE__ */ jsx("span", { children: h(get(b, "label", "")) })
9317
9390
  ] }),
9318
- /* @__PURE__ */ jsx(Button, { onClick: () => j(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
9391
+ /* @__PURE__ */ jsx(Button, { onClick: () => A(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
9319
9392
  ] }),
9320
9393
  /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {}) }) })
9321
9394
  ]
@@ -9382,7 +9455,10 @@ const RootLayout = () => {
9382
9455
  });
9383
9456
  }, [o.translations]), useEffect(() => (a !== "SAVED" ? window.onbeforeunload = () => "" : window.onbeforeunload = null, () => {
9384
9457
  window.onbeforeunload = null;
9385
- }), [a]), /* @__PURE__ */ jsx(l, {});
9458
+ }), [a]), /* @__PURE__ */ jsxs(Fragment, { children: [
9459
+ /* @__PURE__ */ jsx(PrimaryColorCSSVariable, {}),
9460
+ /* @__PURE__ */ jsx(l, {})
9461
+ ] });
9386
9462
  }, ChaiBuilderEditor = (o) => {
9387
9463
  const r = o.onError || noop;
9388
9464
  return /* @__PURE__ */ jsx("div", { className: "h-screen w-screen", children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs(FlagsProvider, { features: { ...FEATURE_TOGGLES }, children: [
@@ -9472,7 +9548,7 @@ export {
9472
9548
  useStylingState,
9473
9549
  useTheme,
9474
9550
  useThemeOptions,
9475
- Ve as useTranslation,
9551
+ Ue as useTranslation,
9476
9552
  useUILibraryBlocks,
9477
9553
  useUndoManager,
9478
9554
  useUpdateBlocksProps,