@chaibuilder/sdk 2.1.7 → 2.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -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
  }
@@ -770,15 +770,23 @@ const useUndoManager = () => {
770
770
  const [r, n] = useAtom$1(libraryBlocksAtom), a = useBuilderProp("getUILibraryBlocks", noop), l = get(r, `${o == null ? void 0 : o.id}.blocks`, null), i = get(r, `${o == null ? void 0 : o.id}.loading`, "idle"), c = useRef("idle");
771
771
  useEffect(() => {
772
772
  (async () => {
773
- if (i === "complete" || c.current === "loading") return;
774
- c.current = "loading", n((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "loading", blocks: [] } }));
775
- const p = await a(o);
776
- c.current = "idle", n((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: p || [] } }));
773
+ if (!(i === "complete" || c.current === "loading")) {
774
+ c.current = "loading", n((p) => ({ ...p, [o == null ? void 0 : o.id]: { loading: "loading", blocks: [] } }));
775
+ try {
776
+ const p = await a(o);
777
+ c.current = "idle", n((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: p || [] } }));
778
+ } catch {
779
+ c.current = "idle", n((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: [] } }));
780
+ }
781
+ }
777
782
  })();
778
783
  }, [o, l, i, c, n, a]);
779
- const d = useCallback(() => {
780
- n((p) => ({ ...p, [o == null ? void 0 : o.id]: { loading: "idle", blocks: [] } }));
781
- }, [o, n]);
784
+ const d = useCallback(
785
+ (p) => {
786
+ n((u) => ({ ...u, [p]: { loading: "idle", blocks: [] } }));
787
+ },
788
+ [n]
789
+ );
782
790
  return { data: l || [], isLoading: i === "loading", resetLibrary: d };
783
791
  }, canAcceptChildBlock = (o, r) => {
784
792
  if (!o) return !0;
@@ -816,9 +824,9 @@ const useAddBlock = () => {
816
824
  for (let h = 0; h < i.length; h++) {
817
825
  const { _id: x } = i[h];
818
826
  i[h]._id = generateUUID();
819
- const y = filter(i, { _parent: x });
820
- for (let b = 0; b < y.length; b++)
821
- 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;
822
830
  }
823
831
  const p = first(i);
824
832
  let u, g;
@@ -829,8 +837,8 @@ const useAddBlock = () => {
829
837
  return { addCoreBlock: useCallback(
830
838
  (i, c, d) => {
831
839
  if (has(i, "blocks")) {
832
- const y = i.blocks;
833
- return a(y, c, d);
840
+ const k = i.blocks;
841
+ return a(k, c, d);
834
842
  }
835
843
  const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
836
844
  _type: i.type,
@@ -2287,42 +2295,42 @@ const getBlockWithChildren = (o, r) => {
2287
2295
  })
2288
2296
  ), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2289
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) => {
2290
- const x = cloneDeep(h.find((y) => y._id === m));
2291
- for (const y in x) {
2292
- 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];
2293
2301
  if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
2294
- const { baseClasses: v, classes: S } = getSplitChaiClasses(b);
2295
- x[y] = compact(flattenDeep([v, S])).join(" ");
2302
+ const { baseClasses: S, classes: w } = getSplitChaiClasses(b);
2303
+ x[k] = compact(flattenDeep([S, w])).join(" ");
2296
2304
  } else
2297
- y !== "_id" && delete x[y];
2305
+ k !== "_id" && delete x[k];
2298
2306
  }
2299
2307
  return x;
2300
2308
  };
2301
2309
  return {
2302
2310
  askAi: useCallback(
2303
- async (m, h, x, y) => {
2311
+ async (m, h, x, k) => {
2304
2312
  if (l) {
2305
2313
  r(!0), a(null);
2306
2314
  try {
2307
- 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;
2308
2316
  if (E) {
2309
2317
  a(E);
2310
2318
  return;
2311
2319
  }
2312
2320
  if (m === "styles") {
2313
- const w = j.map((A) => {
2314
- for (const B in A)
2315
- B !== "_id" && (A[B] = `${STYLES_KEY},${A[B]}`);
2316
- return A;
2321
+ const C = A.map((B) => {
2322
+ for (const _ in B)
2323
+ _ !== "_id" && (B[_] = `${STYLES_KEY},${B[_]}`);
2324
+ return B;
2317
2325
  });
2318
- c(w);
2326
+ c(C);
2319
2327
  } else
2320
- i(j);
2321
- y && y(S);
2328
+ i(A);
2329
+ k && k(w);
2322
2330
  } catch (b) {
2323
2331
  a(b);
2324
2332
  } finally {
2325
- r(!1), y && y();
2333
+ r(!1), k && k();
2326
2334
  }
2327
2335
  }
2328
2336
  },
@@ -2648,7 +2656,7 @@ const useBlockHighlight = () => {
2648
2656
  return null;
2649
2657
  });
2650
2658
  wrapperBlockAtom.debugLabel = "wrapperBlockAtom";
2651
- const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), sidebarActivePanelAtom = atom("outline");
2659
+ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useSelectedLibrary = () => useAtom$1(selectedLibraryAtom), sidebarActivePanelAtom = atom("outline");
2652
2660
  sidebarActivePanelAtom.debugLabel = "sidebarActivePanelAtom";
2653
2661
  const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom);
2654
2662
  function getOrientation(o, r = null) {
@@ -2691,8 +2699,8 @@ const CONTROLS = [
2691
2699
  return useHotkeys(
2692
2700
  "shift+up, shift+down, shift+left, shift+right",
2693
2701
  ({ key: x }) => {
2694
- var y;
2695
- 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());
2696
2704
  },
2697
2705
  { document: a == null ? void 0 : a.contentDocument },
2698
2706
  [h]
@@ -2721,7 +2729,7 @@ const CONTROLS = [
2721
2729
  };
2722
2730
  class PubSub {
2723
2731
  constructor() {
2724
- U(this, "subscribers", /* @__PURE__ */ new Map());
2732
+ V(this, "subscribers", /* @__PURE__ */ new Map());
2725
2733
  }
2726
2734
  subscribe(r, n) {
2727
2735
  return this.subscribers.has(r) || this.subscribers.set(r, /* @__PURE__ */ new Set()), this.subscribers.get(r).add(n), () => {
@@ -2786,13 +2794,13 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: r }) => {
2786
2794
  tabIndex: 0,
2787
2795
  ref: f.setFloating,
2788
2796
  style: g,
2789
- onClick: (y) => {
2790
- y.stopPropagation(), y.preventDefault();
2797
+ onClick: (k) => {
2798
+ k.stopPropagation(), k.preventDefault();
2791
2799
  },
2792
- onMouseEnter: (y) => {
2793
- y.stopPropagation(), i(null);
2800
+ onMouseEnter: (k) => {
2801
+ k.stopPropagation(), i(null);
2794
2802
  },
2795
- onKeyDown: (y) => y.stopPropagation(),
2803
+ onKeyDown: (k) => k.stopPropagation(),
2796
2804
  className: "isolate z-[999] flex h-6 items-center bg-primary py-2 text-xs text-white",
2797
2805
  children: [
2798
2806
  h && /* @__PURE__ */ jsx(
@@ -2971,25 +2979,25 @@ const useDnd = () => {
2971
2979
  },
2972
2980
  onDrop: (m) => {
2973
2981
  var E;
2974
- const h = dropTarget, y = getOrientation(h) === "vertical" ? m.clientY + ((E = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : E.scrollY) : m.clientX;
2975
- dropIndex = calculateDropIndex(y, possiblePositions);
2976
- const b = d, v = h.getAttribute("data-block-id"), S = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
2977
- 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) {
2978
2986
  f();
2979
2987
  return;
2980
2988
  }
2981
2989
  if (!has(b, "_id")) {
2982
- a(b, v === "canvas" ? null : v, dropIndex), setTimeout(f, 300);
2990
+ a(b, S === "canvas" ? null : S, dropIndex), setTimeout(f, 300);
2983
2991
  return;
2984
2992
  }
2985
- let j = h.getAttribute("data-block-id");
2986
- 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);
2987
2995
  },
2988
2996
  onDragEnter: (m) => {
2989
2997
  const h = m, x = h.target;
2990
2998
  dropTarget = x;
2991
- const y = x.getAttribute("data-block-id"), b = x.getAttribute("data-dnd-dragged") !== "yes";
2992
- 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([]);
2993
3001
  },
2994
3002
  onDragLeave: (m) => {
2995
3003
  m.target.getAttribute("data-block-id") === "canvas" && (u(null), n(!1), removePlaceholder(), possiblePositions = []);
@@ -3067,8 +3075,8 @@ const useHandleCanvasDblClick = (o, r) => {
3067
3075
  if (h) {
3068
3076
  const x = h.getAttribute("data-style-prop");
3069
3077
  if (x) {
3070
- const y = h.getAttribute("data-style-id"), b = h.getAttribute("data-block-parent");
3071
- 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 }]);
3072
3080
  }
3073
3081
  }
3074
3082
  }, 100);
@@ -3090,7 +3098,21 @@ const useHandleCanvasDblClick = (o, r) => {
3090
3098
  children: o
3091
3099
  }
3092
3100
  );
3093
- }, 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 = () => {
3094
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(
3095
3117
  d == null ? void 0 : d.getElementById("selected-block")
3096
3118
  ), [f] = useState(
@@ -3118,19 +3140,19 @@ const useHandleCanvasDblClick = (o, r) => {
3118
3140
  }
3119
3141
  },
3120
3142
  plugins: [
3121
- typography,
3122
- forms,
3123
- aspectRatio,
3124
- containerQueries,
3125
- plugin(function({ addBase: S, theme: j }) {
3143
+ tailwindTypography,
3144
+ tailwindForms,
3145
+ tailwindAspectRatio,
3146
+ twContainer,
3147
+ plugin(function({ addBase: S, theme: w }) {
3126
3148
  S({
3127
3149
  "h1,h2,h3,h4,h5,h6": {
3128
- fontFamily: j("fontFamily.heading")
3150
+ fontFamily: w("fontFamily.heading")
3129
3151
  },
3130
3152
  body: {
3131
- fontFamily: j("fontFamily.body"),
3132
- color: j("colors.foreground"),
3133
- backgroundColor: j("colors.background")
3153
+ fontFamily: w("fontFamily.body"),
3154
+ color: w("colors.foreground"),
3155
+ backgroundColor: w("colors.background")
3134
3156
  }
3135
3157
  });
3136
3158
  })
@@ -3151,20 +3173,20 @@ const useHandleCanvasDblClick = (o, r) => {
3151
3173
  }, [l, f]), useEffect(() => {
3152
3174
  d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
3153
3175
  }, [c, d]);
3154
- const x = useMemo(() => getChaiThemeCssVariables(o), [o]), y = useMemo(() => {
3155
- const { heading: S, body: j } = {
3176
+ const x = useMemo(() => {
3177
+ const { heading: S, body: w } = {
3156
3178
  heading: get(o, "fontFamily.heading"),
3157
3179
  body: get(o, "fontFamily.body")
3158
3180
  };
3159
- return h.filter((E) => E.family === S || E.family === j);
3160
- }, [o == null ? void 0 : o.fontFamily, h]), b = useMemo(() => getThemeFontsLinkMarkup(filter(y, (S) => has(S, "url"))), [y]), v = useMemo(
3161
- () => getThemeCustomFontFace(filter(y, (S) => has(S, "src"))),
3162
- [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]
3163
3185
  );
3164
3186
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3165
- /* @__PURE__ */ jsx("style", { id: "chai-theme", children: x }),
3166
- /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: b } }),
3167
- /* @__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 } })
3168
3190
  ] });
3169
3191
  }, ResizableCanvasWrapper = ({ children: o, onMount: r, onResize: n }) => {
3170
3192
  const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
@@ -3247,7 +3269,7 @@ const getBlockRuntimeProps = memoize((o) => {
3247
3269
  ), m = useMemo(() => getBlockTagAttributes(n), [n, getBlockTagAttributes]), h = useMemo(
3248
3270
  () => c(n._id, getBlockRuntimeProps(n._type)),
3249
3271
  [n._id, n._type, c, getBlockRuntimeProps]
3250
- ), 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(
3251
3273
  () => ({
3252
3274
  blockProps: {
3253
3275
  "data-block-id": n._id,
@@ -3271,7 +3293,7 @@ const getBlockRuntimeProps = memoize((o) => {
3271
3293
  x
3272
3294
  ]
3273
3295
  );
3274
- 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 }) });
3275
3297
  }, PartialBlocksRenderer = ({ partialBlockId: o }) => {
3276
3298
  const { getPartailBlocks: r } = usePartailBlocksStore(), n = useMemo(() => r(o), [r, o]), a = useMemo(() => splitAtom(atom(n)), [n]);
3277
3299
  return isEmpty(n) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: n });
@@ -3321,43 +3343,43 @@ const getBlockRuntimeProps = memoize((o) => {
3321
3343
  c();
3322
3344
  }, [r, o, n, c]), l;
3323
3345
  }, getElementByStyleId = (o, r) => o.querySelector(`[data-style-id="${r}"]`), StaticCanvas = () => {
3324
- 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) => {
3325
- 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 }));
3326
3348
  };
3327
3349
  useEffect(() => {
3328
3350
  if (!c.current) return;
3329
- const { clientWidth: w, clientHeight: A } = c.current;
3330
- p({ width: w, height: A });
3351
+ const { clientWidth: C, clientHeight: B } = c.current;
3352
+ p({ width: C, height: B });
3331
3353
  }, [c, r]);
3332
- const j = (w, A = 0) => {
3333
- const { top: B } = w.getBoundingClientRect();
3334
- 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;
3335
3357
  };
3336
3358
  useEffect(() => {
3337
- var w, A;
3359
+ var C, B;
3338
3360
  if (a && a.type !== "Multiple" && i.current) {
3339
- const B = getElementByDataBlockId(i.current.contentDocument, a._id);
3340
- 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([_]));
3341
3363
  }
3342
3364
  }, [a]), useEffect(() => {
3343
3365
  if (!isEmpty(x) && i.current) {
3344
- const w = getElementByStyleId(
3366
+ const C = getElementByStyleId(
3345
3367
  i.current.contentDocument,
3346
3368
  first(x).id
3347
3369
  );
3348
- m(w ? [w] : [null]);
3370
+ m(C ? [C] : [null]);
3349
3371
  } else
3350
3372
  m([null]);
3351
3373
  }, [x]);
3352
3374
  const E = useMemo(() => {
3353
- let w = IframeInitialContent;
3354
- return w = w.replace("__HTML_DIR__", v), o === "offline" && (w = w.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), w;
3355
- }, [o, v]);
3356
- 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(
3357
3379
  "div",
3358
3380
  {
3359
3381
  onClick: () => {
3360
- n([]), y([]);
3382
+ n([]), k([]);
3361
3383
  },
3362
3384
  onMouseLeave: () => setTimeout(() => l(""), 300),
3363
3385
  className: "relative mx-auto h-full w-full overflow-hidden",
@@ -3509,8 +3531,8 @@ const getBlockRuntimeProps = memoize((o) => {
3509
3531
  p(!1), g("Invalid asset URL");
3510
3532
  return;
3511
3533
  }
3512
- const y = x.headers.get("content-type") || "";
3513
- 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`));
3514
3536
  } catch {
3515
3537
  p(!1), g("Error validating URL");
3516
3538
  } finally {
@@ -3591,14 +3613,14 @@ function NestedPathSelector({ data: o, onSelect: r, dataType: n = "value" }) {
3591
3613
  }, [a, o]);
3592
3614
  const u = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", g = React.useCallback(
3593
3615
  (h) => {
3594
- const x = (y) => n === "value" ? y === "value" || y === "object" : n === "array" ? y === "array" : y === n;
3595
- 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));
3596
3618
  },
3597
3619
  [i, r, n]
3598
3620
  ), f = React.useCallback(() => {
3599
3621
  if (i.length > 0) {
3600
3622
  const h = i.slice(0, -1);
3601
- c(h), p(h.reduce((x, y) => x[y], o));
3623
+ c(h), p(h.reduce((x, k) => x[k], o));
3602
3624
  }
3603
3625
  }, [i, o]), m = React.useMemo(() => Object.entries(d).map(([h, x]) => ({
3604
3626
  key: h,
@@ -3873,11 +3895,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
3873
3895
  if (h !== x)
3874
3896
  u.chain().deleteSelection().insertContent(m).run();
3875
3897
  else {
3876
- 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));
3877
3899
  let E = "";
3878
- v > 0 && S !== " " && !/[.,!?;:]/.test(S) && (E = " ");
3879
- let w = "";
3880
- 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();
3881
3903
  }
3882
3904
  };
3883
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: [
@@ -3958,74 +3980,74 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
3958
3980
  pageTypes: r,
3959
3981
  onChange: n
3960
3982
  }) => {
3961
- var I;
3962
- 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;
3963
3985
  useEffect(() => {
3964
3986
  if (m(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
3965
- const C = split(o, ":"), k = get(C, 1, "page") || "page";
3966
- g(k), (async () => {
3967
- const _ = await l(k, [get(C, 2, "page")]);
3968
- _ && 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"], ""));
3969
3991
  })();
3970
3992
  }, [o]);
3971
- const j = useDebouncedCallback(
3972
- async (C) => {
3973
- if (isEmpty(C))
3993
+ const A = useDebouncedCallback(
3994
+ async (v) => {
3995
+ if (isEmpty(v))
3974
3996
  x([]);
3975
3997
  else {
3976
- const k = await l(u, C);
3977
- x(k);
3998
+ const y = await l(u, v);
3999
+ x(y);
3978
4000
  }
3979
4001
  c(!1), b(-1);
3980
4002
  },
3981
4003
  [u],
3982
4004
  300
3983
- ), E = (C) => {
3984
- const k = ["pageType", u, C.id];
3985
- k[1] && (n(k.join(":")), m(C.name), p(!1), x([]), b(-1));
3986
- }, w = (C) => {
3987
- 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) {
3988
4010
  case "ArrowDown":
3989
- C.preventDefault(), b((k) => k < h.length - 1 ? k + 1 : k);
4011
+ v.preventDefault(), b((y) => y < h.length - 1 ? y + 1 : y);
3990
4012
  break;
3991
4013
  case "ArrowUp":
3992
- C.preventDefault(), b((k) => k > 0 ? k - 1 : k);
4014
+ v.preventDefault(), b((y) => y > 0 ? y - 1 : y);
3993
4015
  break;
3994
4016
  case "Enter":
3995
- if (C.preventDefault(), h.length === 0) return;
3996
- y >= 0 && E(h[y]);
4017
+ if (v.preventDefault(), h.length === 0) return;
4018
+ k >= 0 && E(h[k]);
3997
4019
  break;
3998
4020
  case "Escape":
3999
- C.preventDefault(), A();
4021
+ v.preventDefault(), B();
4000
4022
  break;
4001
4023
  }
4002
4024
  };
4003
4025
  useEffect(() => {
4004
- if (y >= 0 && v.current) {
4005
- const C = v.current.children[y];
4006
- 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" });
4007
4029
  }
4008
- }, [y]);
4009
- const A = () => {
4030
+ }, [k]);
4031
+ const B = () => {
4010
4032
  m(""), x([]), b(-1), p(!1), n("");
4011
- }, B = (C) => {
4012
- m(C), p(!isEmpty(C)), c(!0), j(C);
4033
+ }, _ = (v) => {
4034
+ m(v), p(!isEmpty(v)), c(!0), A(v);
4013
4035
  };
4014
4036
  return /* @__PURE__ */ jsxs("div", { children: [
4015
- /* @__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)) }),
4016
4038
  u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
4017
4039
  /* @__PURE__ */ jsx(
4018
4040
  "input",
4019
4041
  {
4020
4042
  type: "text",
4021
4043
  value: f,
4022
- onChange: (C) => B(C.target.value),
4023
- onKeyDown: w,
4024
- placeholder: a(`Search ${S ?? ""}`),
4044
+ onChange: (v) => _(v.target.value),
4045
+ onKeyDown: C,
4046
+ placeholder: a(`Search ${w ?? ""}`),
4025
4047
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4026
4048
  }
4027
4049
  ),
4028
- /* @__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" }) }) })
4029
4051
  ] }),
4030
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: [
4031
4053
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -4035,22 +4057,22 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4035
4057
  ' "',
4036
4058
  f,
4037
4059
  '"'
4038
- ] }) : /* @__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(
4039
4061
  "li",
4040
4062
  {
4041
- onClick: () => E(C),
4042
- 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"}`,
4043
4065
  children: [
4044
- C.name,
4066
+ v.name,
4045
4067
  " ",
4046
- 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: [
4047
4069
  "( ",
4048
- C.slug,
4070
+ v.slug,
4049
4071
  " )"
4050
4072
  ] })
4051
4073
  ]
4052
4074
  },
4053
- C.id
4075
+ v.id
4054
4076
  )) }) })
4055
4077
  ] });
4056
4078
  }, LinkField = ({ schema: o, formData: r, onChange: n }) => {
@@ -4135,14 +4157,14 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4135
4157
  const f = () => {
4136
4158
  const x = findIndex(u, { _id: g });
4137
4159
  if (x > -1) {
4138
- const y = (x + 1) % u.length, b = get(u, [y, "_id"]);
4160
+ const k = (x + 1) % u.length, b = get(u, [k, "_id"]);
4139
4161
  if (!b) return;
4140
4162
  r({ ...o, currentSlide: b }), c([b]);
4141
4163
  }
4142
4164
  }, m = () => {
4143
4165
  const x = findIndex(u, { _id: g });
4144
4166
  if (x > -1) {
4145
- 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"]);
4146
4168
  if (!b) return;
4147
4169
  r({ ...o, currentSlide: b }), c([b]);
4148
4170
  }
@@ -4150,8 +4172,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4150
4172
  const x = i(
4151
4173
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4152
4174
  p == null ? void 0 : p._id
4153
- ), y = x == null ? void 0 : x._id;
4154
- y && (r({ ...o, currentSlide: y }), c([y]));
4175
+ ), k = x == null ? void 0 : x._id;
4176
+ k && (r({ ...o, currentSlide: k }), c([k]));
4155
4177
  };
4156
4178
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4157
4179
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
@@ -4230,8 +4252,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4230
4252
  className: "text-xs",
4231
4253
  pattern: "[0-9]*",
4232
4254
  onChange: (x) => {
4233
- let y = x.target.value;
4234
- 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 });
4235
4257
  }
4236
4258
  }
4237
4259
  )
@@ -4333,65 +4355,65 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4333
4355
  formData: g,
4334
4356
  onChange: f
4335
4357
  }) => {
4336
- 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(
4337
- (k) => {
4338
- 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) => {
4339
4361
  let R = "", $ = "";
4340
4362
  const M = D > 0 ? N[D - 1] : "", H = D < N.length ? N[D] : "";
4341
- 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 !== " " && ($ = " "), {
4342
4364
  text: R + O + $,
4343
4365
  prefixLength: R.length,
4344
4366
  suffixLength: $.length
4345
4367
  };
4346
- }, L = document.getElementById(o);
4347
- if (!L) return;
4368
+ }, I = document.getElementById(o);
4369
+ if (!I) return;
4348
4370
  const P = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
4349
4371
  if (P && (P.querySelector(".ProseMirror") || P.__chaiRTE)) {
4350
4372
  const N = P.__chaiRTE;
4351
4373
  if (N) {
4352
- const D = `{{${k}}}`;
4374
+ const D = `{{${y}}}`;
4353
4375
  N.commands.focus();
4354
4376
  const { from: O, to: R } = N.state.selection;
4355
4377
  if (O !== R)
4356
4378
  N.chain().deleteSelection().insertContent(D).run();
4357
4379
  else {
4358
- 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));
4359
4381
  let z = "";
4360
- H > 0 && F !== " " && !_(F) && (z = " ");
4382
+ H > 0 && F !== " " && !j(F) && (z = " ");
4361
4383
  let W = "";
4362
- V && V !== " " && !_(V) && (W = " "), N.chain().insertContent(z + D + W).run();
4384
+ U && U !== " " && !j(U) && (W = " "), N.chain().insertContent(z + D + W).run();
4363
4385
  }
4364
4386
  setTimeout(() => f(N.getHTML(), {}, o), 100);
4365
4387
  return;
4366
4388
  }
4367
4389
  } else {
4368
- 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;
4369
4391
  if (R > D) {
4370
- 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);
4371
4393
  f(W, {}, o);
4372
4394
  return;
4373
4395
  }
4374
- 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);
4375
4397
  f(F, {}, o);
4376
4398
  }
4377
4399
  },
4378
- [o, f, g, S == null ? void 0 : S._id]
4400
+ [o, f, g, w == null ? void 0 : w._id]
4379
4401
  );
4380
4402
  if (d)
4381
4403
  return null;
4382
4404
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: a });
4383
- const C = E == null ? void 0 : E.includes(o.replace("root.", ""));
4405
+ const v = E == null ? void 0 : E.includes(o.replace("root.", ""));
4384
4406
  if (u.type === "array") {
4385
- const k = w === o;
4407
+ const y = C === o;
4386
4408
  return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
4387
4409
  u.title && /* @__PURE__ */ jsxs(
4388
4410
  "label",
4389
4411
  {
4390
4412
  htmlFor: o,
4391
- onClick: () => A(k ? null : o),
4413
+ onClick: () => B(y ? null : o),
4392
4414
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
4393
4415
  children: [
4394
- 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" }),
4395
4417
  /* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
4396
4418
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: n }),
4397
4419
  " ",
@@ -4399,7 +4421,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4399
4421
  ]
4400
4422
  }
4401
4423
  ),
4402
- (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: [
4403
4425
  c,
4404
4426
  a,
4405
4427
  l,
@@ -4412,13 +4434,13 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4412
4434
  /* @__PURE__ */ jsxs("label", { htmlFor: o, className: u.type === "object" ? "pb-2" : "", children: [
4413
4435
  n,
4414
4436
  " ",
4415
- C && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
4437
+ v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
4416
4438
  " ",
4417
4439
  b
4418
4440
  ] }),
4419
4441
  p && u.type !== "object" ? " *" : null
4420
4442
  ] }),
4421
- 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" })
4422
4444
  ] }),
4423
4445
  c,
4424
4446
  a,
@@ -4487,38 +4509,38 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4487
4509
  }), a;
4488
4510
  };
4489
4511
  function BlockSettings() {
4490
- 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) => {
4491
- 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) }, _);
4492
4514
  }, x = useCallback(
4493
- debounce(({ formData: w }, A, B) => {
4494
- h({ formData: w }, A, B), d(w);
4515
+ debounce(({ formData: C }, B, _) => {
4516
+ h({ formData: C }, B, _), d(C);
4495
4517
  }, 1500),
4496
4518
  [r == null ? void 0 : r._id, o]
4497
- ), y = ({ formData: w }, A) => {
4498
- A && (n([r._id], { [A]: get(w, A) }), x({ formData: w }, A, { [A]: get(c, A) }));
4499
- }, b = ({ formData: w }, A) => {
4500
- A && (n([g._id], { [A]: get(w, A) }), x({ formData: w }, A, { [A]: get(c, A) }));
4501
- }, { schema: v, uiSchema: S } = useMemo(() => {
4502
- const w = r == null ? void 0 : r._type;
4503
- 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)
4504
4526
  return { schema: {}, uiSchema: {} };
4505
4527
  try {
4506
- return getBlockFormSchemas(w);
4528
+ return getBlockFormSchemas(C);
4507
4529
  } catch {
4508
4530
  return { schema: {}, uiSchema: {} };
4509
4531
  }
4510
- }, [r]), { wrapperSchema: j, wrapperUiSchema: E } = useMemo(() => {
4532
+ }, [r]), { wrapperSchema: A, wrapperUiSchema: E } = useMemo(() => {
4511
4533
  if (!g || !(g != null && g._type))
4512
4534
  return { wrapperSchema: {}, wrapperUiSchema: {} };
4513
- const w = g == null ? void 0 : g._type, { schema: A = {}, uiSchema: B = {} } = getBlockFormSchemas(w);
4514
- return { wrapperSchema: A, wrapperUiSchema: B };
4535
+ const C = g == null ? void 0 : g._type, { schema: B = {}, uiSchema: _ = {} } = getBlockFormSchemas(C);
4536
+ return { wrapperSchema: B, wrapperUiSchema: _ };
4515
4537
  }, [g]);
4516
4538
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
4517
4539
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
4518
4540
  /* @__PURE__ */ jsxs(
4519
4541
  "div",
4520
4542
  {
4521
- onClick: () => u((w) => !w),
4543
+ onClick: () => u((C) => !C),
4522
4544
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
4523
4545
  children: [
4524
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" }),
@@ -4539,19 +4561,19 @@ function BlockSettings() {
4539
4561
  blockId: g == null ? void 0 : g._id,
4540
4562
  onChange: b,
4541
4563
  formData: m,
4542
- schema: j,
4564
+ schema: A,
4543
4565
  uiSchema: E
4544
4566
  }
4545
4567
  ) })
4546
4568
  ] }),
4547
- isEmpty(v) ? null : /* @__PURE__ */ jsx(
4569
+ isEmpty(S) ? null : /* @__PURE__ */ jsx(
4548
4570
  JSONForm,
4549
4571
  {
4550
4572
  blockId: r == null ? void 0 : r._id,
4551
- onChange: y,
4573
+ onChange: k,
4552
4574
  formData: i,
4553
- schema: v,
4554
- uiSchema: S
4575
+ schema: S,
4576
+ uiSchema: w
4555
4577
  }
4556
4578
  )
4557
4579
  ] });
@@ -4656,10 +4678,10 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
4656
4678
  tooltip: n = !0
4657
4679
  }) => {
4658
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) => {
4659
- 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]);
4660
4682
  }, x = (b) => {
4661
4683
  r || l(b), c(b);
4662
- }, y = getBreakpointValue(r ? i : a).toLowerCase();
4684
+ }, k = getBreakpointValue(r ? i : a).toLowerCase();
4663
4685
  return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
4664
4686
  BreakpointCard,
4665
4687
  {
@@ -4667,7 +4689,7 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
4667
4689
  ...b,
4668
4690
  onClick: x,
4669
4691
  key: b.breakpoint,
4670
- currentBreakpoint: y
4692
+ currentBreakpoint: k
4671
4693
  }
4672
4694
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
4673
4695
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
@@ -4681,7 +4703,7 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
4681
4703
  ...b,
4682
4704
  onClick: x,
4683
4705
  key: b.breakpoint,
4684
- currentBreakpoint: y
4706
+ currentBreakpoint: k
4685
4707
  }
4686
4708
  )
4687
4709
  ) }),
@@ -4836,11 +4858,11 @@ const AskAIStyles = ({ blockId: o }) => {
4836
4858
  };
4837
4859
  function ManualClasses() {
4838
4860
  var T;
4839
- 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 = () => {
4840
- const L = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
4841
- u(f, L, !0), x("");
4842
- }, [j, E] = useState([]), w = ({ value: L }) => {
4843
- 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);
4844
4866
  let D = [];
4845
4867
  if (N && N.length > 0) {
4846
4868
  const [O] = N, R = P.replace(O, "");
@@ -4851,9 +4873,9 @@ function ManualClasses() {
4851
4873
  } else
4852
4874
  D = i.search(P);
4853
4875
  return E(map(D, "item"));
4854
- }, A = () => {
4876
+ }, B = () => {
4855
4877
  E([]);
4856
- }, 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(
4857
4879
  () => ({
4858
4880
  ref: o,
4859
4881
  autoComplete: "off",
@@ -4862,30 +4884,30 @@ function ManualClasses() {
4862
4884
  spellCheck: !1,
4863
4885
  placeholder: c("Enter classes separated by space"),
4864
4886
  value: h,
4865
- onKeyDown: (L) => {
4866
- L.key === "Enter" && h.trim() !== "" && S();
4887
+ onKeyDown: (I) => {
4888
+ I.key === "Enter" && h.trim() !== "" && w();
4867
4889
  },
4868
- onChange: (L, { newValue: P }) => x(P),
4890
+ onChange: (I, { newValue: P }) => x(P),
4869
4891
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
4870
4892
  }),
4871
4893
  [h, c, o]
4872
- ), k = (L) => {
4894
+ ), y = (I) => {
4873
4895
  debugger;
4874
4896
  const P = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
4875
- g(f, [L]), u(f, P, !0), n(""), l(-1);
4876
- }, _ = () => {
4897
+ g(f, [I]), u(f, P, !0), n(""), l(-1);
4898
+ }, j = () => {
4877
4899
  if (navigator.clipboard === void 0) {
4878
4900
  toast.error(c("Clipboard not supported"));
4879
4901
  return;
4880
4902
  }
4881
- 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"));
4882
4904
  };
4883
4905
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
4884
4906
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
4885
4907
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
4886
4908
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
4887
4909
  /* @__PURE__ */ jsxs(Tooltip, { children: [
4888
- /* @__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" }) }),
4889
4911
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
4890
4912
  ] })
4891
4913
  ] }),
@@ -4901,12 +4923,12 @@ function ManualClasses() {
4901
4923
  /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
4902
4924
  Autosuggest,
4903
4925
  {
4904
- suggestions: j,
4905
- onSuggestionsFetchRequested: w,
4906
- onSuggestionsClearRequested: A,
4907
- getSuggestionValue: B,
4908
- renderSuggestion: I,
4909
- inputProps: C,
4926
+ suggestions: A,
4927
+ onSuggestionsFetchRequested: C,
4928
+ onSuggestionsClearRequested: B,
4929
+ getSuggestionValue: _,
4930
+ renderSuggestion: L,
4931
+ inputProps: v,
4910
4932
  containerProps: {
4911
4933
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
4912
4934
  },
@@ -4922,45 +4944,45 @@ function ManualClasses() {
4922
4944
  {
4923
4945
  variant: "outline",
4924
4946
  className: "h-6 border-border",
4925
- onClick: S,
4947
+ onClick: w,
4926
4948
  disabled: h.trim() === "",
4927
4949
  size: "sm",
4928
4950
  children: /* @__PURE__ */ jsx(PlusIcon, {})
4929
4951
  }
4930
4952
  )
4931
4953
  ] }),
4932
- /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: v.map(
4933
- (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(
4934
4956
  "input",
4935
4957
  {
4936
4958
  ref: o,
4937
4959
  value: r,
4938
4960
  onChange: (N) => n(N.target.value),
4939
4961
  onBlur: () => {
4940
- k(L);
4962
+ y(I);
4941
4963
  },
4942
4964
  onKeyDown: (N) => {
4943
- N.key === "Enter" && k(L);
4965
+ N.key === "Enter" && y(I);
4944
4966
  },
4945
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"
4946
4968
  },
4947
- L
4969
+ I
4948
4970
  ) : /* @__PURE__ */ jsxs(
4949
4971
  "button",
4950
4972
  {
4951
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",
4952
4974
  children: [
4953
- L,
4954
- r !== L && /* @__PURE__ */ jsx(
4975
+ I,
4976
+ r !== I && /* @__PURE__ */ jsx(
4955
4977
  Cross2Icon,
4956
4978
  {
4957
- onClick: () => g(f, [L], !0),
4979
+ onClick: () => g(f, [I], !0),
4958
4980
  className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
4959
4981
  }
4960
4982
  )
4961
4983
  ]
4962
4984
  },
4963
- L
4985
+ I
4964
4986
  )
4965
4987
  ) })
4966
4988
  ] });
@@ -5133,8 +5155,8 @@ const COLOR_PROP = {
5133
5155
  }, ColorChoice = ({ property: o, onChange: r }) => {
5134
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(
5135
5157
  // eslint-disable-next-line no-shadow
5136
- (y) => {
5137
- ["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" })));
5138
5160
  },
5139
5161
  [c, p]
5140
5162
  );
@@ -5145,8 +5167,8 @@ const COLOR_PROP = {
5145
5167
  }, [g]);
5146
5168
  const h = useCallback(
5147
5169
  // eslint-disable-next-line no-shadow
5148
- (y) => {
5149
- p({ color: g, shade: y });
5170
+ (k) => {
5171
+ p({ color: g, shade: k });
5150
5172
  },
5151
5173
  [g]
5152
5174
  );
@@ -5588,50 +5610,50 @@ const COLOR_PROP = {
5588
5610
  },
5589
5611
  a
5590
5612
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5591
- 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);
5592
5614
  useEffect(() => {
5593
- const { value: C, unit: k } = getClassValueAndUnit(i);
5594
- if (k === "") {
5595
- 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));
5596
5618
  return;
5597
5619
  }
5598
- m(k), l(k === "class" || isEmpty(C) ? "" : C);
5620
+ m(y), l(y === "class" || isEmpty(v) ? "" : v);
5599
5621
  }, [i, p, u]);
5600
- const w = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), A = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), B = useCallback(
5601
- (C = !1) => {
5602
- const k = getUserInputValues(`${a}`, u);
5603
- 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)) {
5604
5626
  x(!0);
5605
5627
  return;
5606
5628
  }
5607
- const _ = get(k, "unit") !== "" ? get(k, "unit") : f;
5608
- if (_ === "auto" || _ === "none") {
5609
- w(`${d}${_}`);
5629
+ const j = get(y, "unit") !== "" ? get(y, "unit") : f;
5630
+ if (j === "auto" || j === "none") {
5631
+ C(`${d}${j}`);
5610
5632
  return;
5611
5633
  }
5612
- if (get(k, "value") === "")
5634
+ if (get(y, "value") === "")
5613
5635
  return;
5614
- const L = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
5615
- 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);
5616
5638
  },
5617
- [w, A, a, f, d, u]
5618
- ), I = useCallback(
5619
- (C) => {
5620
- const k = getUserInputValues(`${a}`, u);
5621
- 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)) {
5622
5644
  x(!0);
5623
5645
  return;
5624
5646
  }
5625
- if (C === "auto" || C === "none") {
5626
- w(`${d}${C}`);
5647
+ if (v === "auto" || v === "none") {
5648
+ C(`${d}${v}`);
5627
5649
  return;
5628
5650
  }
5629
- if (get(k, "value") === "")
5651
+ if (get(y, "value") === "")
5630
5652
  return;
5631
- const _ = get(k, "unit") !== "" ? get(k, "unit") : C, L = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
5632
- 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);
5633
5655
  },
5634
- [w, a, d, u]
5656
+ [C, a, d, u]
5635
5657
  );
5636
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: [
5637
5659
  /* @__PURE__ */ jsx(
@@ -5646,37 +5668,37 @@ const COLOR_PROP = {
5646
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, {}) }) }),
5647
5669
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
5648
5670
  ] })
5649
- ] }) : /* @__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: [
5650
5672
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
5651
5673
  ["none", "auto"].indexOf(f) !== -1 ? null : /* @__PURE__ */ jsx(
5652
5674
  "input",
5653
5675
  {
5654
5676
  readOnly: f === "class",
5655
- onKeyPress: (C) => {
5656
- C.key === "Enter" && B();
5677
+ onKeyPress: (v) => {
5678
+ v.key === "Enter" && _();
5657
5679
  },
5658
- onKeyDown: (C) => {
5659
- if (C.keyCode !== 38 && C.keyCode !== 40)
5680
+ onKeyDown: (v) => {
5681
+ if (v.keyCode !== 38 && v.keyCode !== 40)
5660
5682
  return;
5661
- C.preventDefault(), E(!0);
5662
- const k = parseInt$1(C.target.value);
5663
- let _ = isNaN$1(k) ? 0 : k;
5664
- C.keyCode === 38 && (_ += 1), C.keyCode === 40 && (_ -= 1);
5665
- const T = `${_}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${f === "-" ? "" : f}]`;
5666
- 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);
5667
5689
  },
5668
- onKeyUp: (C) => {
5669
- j && (C.preventDefault(), E(!1));
5690
+ onKeyUp: (v) => {
5691
+ A && (v.preventDefault(), E(!1));
5670
5692
  },
5671
- onBlur: () => B(),
5672
- onChange: (C) => {
5673
- x(!1), l(C.target.value);
5693
+ onBlur: () => _(),
5694
+ onChange: (v) => {
5695
+ x(!1), l(v.target.value);
5674
5696
  },
5675
- onClick: (C) => {
5676
- var k;
5677
- (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);
5678
5700
  },
5679
- value: v ? y : a,
5701
+ value: S ? k : a,
5680
5702
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
5681
5703
  " ",
5682
5704
  h ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -5701,29 +5723,29 @@ const COLOR_PROP = {
5701
5723
  {
5702
5724
  units: u,
5703
5725
  current: f,
5704
- onSelect: (C) => {
5705
- n(!1), m(C), I(C);
5726
+ onSelect: (v) => {
5727
+ n(!1), m(v), L(v);
5706
5728
  }
5707
5729
  }
5708
5730
  ) }) })
5709
5731
  ] })
5710
5732
  ] }),
5711
- ["none", "auto"].indexOf(f) !== -1 || v ? null : /* @__PURE__ */ jsx(
5733
+ ["none", "auto"].indexOf(f) !== -1 || S ? null : /* @__PURE__ */ jsx(
5712
5734
  DragStyleButton,
5713
5735
  {
5714
- onDragStart: () => S(!0),
5715
- onDragEnd: (C) => {
5716
- if (b(() => ""), S(!1), isEmpty(C))
5736
+ onDragStart: () => w(!0),
5737
+ onDragEnd: (v) => {
5738
+ if (b(() => ""), w(!1), isEmpty(v))
5717
5739
  return;
5718
- const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${f === "-" ? "" : f}]`;
5719
- w(T);
5740
+ const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${f === "-" ? "" : f}]`;
5741
+ C(T);
5720
5742
  },
5721
- onDrag: (C) => {
5722
- if (isEmpty(C))
5743
+ onDrag: (v) => {
5744
+ if (isEmpty(v))
5723
5745
  return;
5724
- b(C);
5725
- const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${f === "-" ? "" : f}]`;
5726
- A(T);
5746
+ b(v);
5747
+ const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${f === "-" ? "" : f}]`;
5748
+ B(T);
5727
5749
  },
5728
5750
  currentValue: a,
5729
5751
  unit: f,
@@ -5820,35 +5842,35 @@ const COLOR_PROP = {
5820
5842
  "2xl": "1536px"
5821
5843
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
5822
5844
  const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
5823
- }, 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(
5824
- (A, B = !0) => {
5825
- const I = { dark: p, mq: g, mod: u, cls: A, property: l, fullCls: "" };
5826
- (p || u !== "") && (I.mq = "xs");
5827
- const C = generateFullClsName(I);
5828
- 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], _);
5829
5851
  },
5830
5852
  [x, p, g, u, l, m]
5831
- ), v = useCallback(() => {
5832
- h(x, [y], !0);
5833
- }, [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]);
5834
5856
  useEffect(() => {
5835
- i(S, f);
5836
- }, [S, i, f]);
5837
- const [, , j] = useScreenSizeWidth(), E = useCallback(
5838
- (A) => {
5839
- j({
5857
+ i(w, f);
5858
+ }, [w, i, f]);
5859
+ const [, , A] = useScreenSizeWidth(), E = useCallback(
5860
+ (B) => {
5861
+ A({
5840
5862
  xs: 400,
5841
5863
  sm: 640,
5842
5864
  md: 800,
5843
5865
  lg: 1024,
5844
5866
  xl: 1420,
5845
5867
  "2xl": 1920
5846
- }[A]);
5868
+ }[B]);
5847
5869
  },
5848
- [j]
5849
- ), w = get(f, "dark", null) === p && get(f, "mod", null) === u && get(f, "mq", null) === g;
5850
- 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: [
5851
- /* @__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) }) }),
5852
5874
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
5853
5875
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
5854
5876
  n === "arbitrary" ? /* @__PURE__ */ jsx(
@@ -5867,7 +5889,7 @@ const COLOR_PROP = {
5867
5889
  n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
5868
5890
  n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
5869
5891
  ] }),
5870
- /* @__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: [
5871
5893
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5872
5894
  "button",
5873
5895
  {
@@ -6017,8 +6039,8 @@ function BlockStyling() {
6017
6039
  m = isNaN(m) ? 0 : m;
6018
6040
  let h = MAPPER[i.dragUnit];
6019
6041
  (startsWith(f, "scale") || f === "opacity") && (h = 10);
6020
- let y = (i.dragStartY - u.pageY) / h + m;
6021
- 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}`);
6022
6044
  },
6023
6045
  [i],
6024
6046
  50
@@ -6063,8 +6085,8 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6063
6085
  }) => {
6064
6086
  const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: f } = useBlockHighlight(), m = () => {
6065
6087
  if (console.log("addBlockToPage", o), has(o, "blocks")) {
6066
- const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
6067
- u(syncBlocksWithDefaults(y), n || null, a);
6088
+ const k = isFunction(o.blocks) ? o.blocks() : o.blocks;
6089
+ u(syncBlocksWithDefaults(k), n || null, a);
6068
6090
  } else
6069
6091
  p(o, n || null, a);
6070
6092
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
@@ -6076,8 +6098,8 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6076
6098
  disabled: r,
6077
6099
  onClick: m,
6078
6100
  type: "button",
6079
- onDragStart: (y) => {
6080
- 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(() => {
6081
6103
  g([]), f();
6082
6104
  }, 200);
6083
6105
  },
@@ -6277,22 +6299,22 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6277
6299
  }
6278
6300
  }
6279
6301
  }, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
6280
- var f, m, h, x, y, b, v, S;
6302
+ var f, m, h, x, k, b, S, w;
6281
6303
  if (n.type === "comment") return [];
6282
6304
  console.log("node ===>", n);
6283
6305
  let a = { _id: generateUUID() };
6284
6306
  if (r && (a._parent = r.block._id), n.type === "text")
6285
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", "") };
6286
6308
  const l = get(n, "attributes", []), i = l.find(
6287
- (j) => j.key === "data-chai-richtext" || j.key === "chai-richtext"
6309
+ (A) => A.key === "data-chai-richtext" || A.key === "chai-richtext"
6288
6310
  ), c = l.find(
6289
- (j) => j.key === "data-chai-lightbox" || j.key === "chai-lightbox"
6311
+ (A) => A.key === "data-chai-lightbox" || A.key === "chai-lightbox"
6290
6312
  ), d = l.find(
6291
- (j) => j.key === "data-chai-dropdown" || j.key === "chai-dropdown"
6313
+ (A) => A.key === "data-chai-dropdown" || A.key === "chai-dropdown"
6292
6314
  ), p = l.find(
6293
- (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"
6294
6316
  ), u = l.find(
6295
- (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"
6296
6318
  );
6297
6319
  if (a = {
6298
6320
  ...a,
@@ -6300,13 +6322,13 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6300
6322
  ...getAttrs(n),
6301
6323
  ...getStyles(n)
6302
6324
  }, n.attributes) {
6303
- const j = n.attributes.find((E) => includes(NAME_ATTRIBUTES, E.key));
6304
- j && (a._name = j.value);
6325
+ const A = n.attributes.find((E) => includes(NAME_ATTRIBUTES, E.key));
6326
+ A && (a._name = A.value);
6305
6327
  }
6306
6328
  if (i)
6307
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];
6308
6330
  if (c) {
6309
- const j = [
6331
+ const A = [
6310
6332
  "data-chai-lightbox",
6311
6333
  "chai-lightbox",
6312
6334
  "data-vbtype",
@@ -6321,41 +6343,41 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6321
6343
  href: ((f = l.find((E) => E.key === "href")) == null ? void 0 : f.value) || "",
6322
6344
  hrefType: ((m = l.find((E) => E.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
6323
6345
  autoplay: ((h = l.find((E) => E.key === "data-autoplay")) == null ? void 0 : h.value) === "true" ? "true" : "false",
6324
- 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", "")) || "",
6325
6347
  backdropColor: ((b = l.find((E) => E.key === "data-overlay")) == null ? void 0 : b.value) || "",
6326
- galleryName: ((v = l.find((E) => E.key === "data-gall")) == null ? void 0 : v.value) || ""
6327
- }, forEach(j, (E) => {
6348
+ galleryName: ((S = l.find((E) => E.key === "data-gall")) == null ? void 0 : S.value) || ""
6349
+ }, forEach(A, (E) => {
6328
6350
  has(a, `styles_attrs.${E}`) && delete a.styles_attrs[E];
6329
6351
  });
6330
6352
  }
6331
6353
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
6332
6354
  delete a.styles_attrs;
6333
- const j = filter(n.children || [], (w) => (w == null ? void 0 : w.tagName) !== "span");
6334
- a.content = getTextContent(j);
6355
+ const A = filter(n.children || [], (C) => (C == null ? void 0 : C.tagName) !== "span");
6356
+ a.content = getTextContent(A);
6335
6357
  const E = find(
6336
6358
  n.children || [],
6337
- (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")
6338
6360
  );
6339
6361
  if (E) {
6340
- const w = find(E.children || [], (A) => (A == null ? void 0 : A.tagName) === "svg");
6341
- if (w) {
6342
- a.icon = stringify([w]);
6343
- const { height: A, width: B } = getSvgDimensions(w, "16px", "16px");
6344
- 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 = _;
6345
6367
  }
6346
6368
  }
6347
6369
  return [a];
6348
6370
  }
6349
6371
  if (a._type === "Input") {
6350
- const j = a.inputType || "text";
6351
- 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");
6352
6374
  } else if (n.tagName === "video" || n.tagName === "iframe") {
6353
- const j = stringify([n]);
6354
- 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];
6355
6377
  } else if (n.tagName === "svg") {
6356
- 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");
6357
- 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];
6358
- } 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")
6359
6381
  return r.block.options.push({
6360
6382
  label: getTextContent(n.children),
6361
6383
  ...getAttrs(n)
@@ -6403,91 +6425,6 @@ const ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
6403
6425
  ] }) }),
6404
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") }) })
6405
6427
  ] });
6406
- }, partialBlocksDataAtom = atom({
6407
- blocks: [],
6408
- groups: [],
6409
- isLoading: !0,
6410
- error: null
6411
- }), hasInitializedPartialBlocksAtom = atom(!1), formatReadableName = (o) => {
6412
- if (!o) return "";
6413
- let r = o.replace(/[-_]/g, " ");
6414
- return r = r.replace(/([a-z])([A-Z])/g, "$1 $2"), r.split(" ").map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join(" ");
6415
- }, PartialBlocks = ({
6416
- parentId: o,
6417
- position: r,
6418
- gridCols: n = "grid-cols-2"
6419
- }) => {
6420
- const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u, g] = useAtom$1(hasInitializedPartialBlocksAtom);
6421
- useEffect(() => {
6422
- if (!u || Object.keys(d.blocks).length === 0)
6423
- if (c)
6424
- p({
6425
- blocks: [],
6426
- groups: [],
6427
- isLoading: !1,
6428
- error: c
6429
- }), g(!0);
6430
- else if (!l && Object.keys(a || {}).length > 0) {
6431
- const m = Object.entries(a).map(([x, y]) => {
6432
- const b = y, v = b.type || "partial", S = formatReadableName(v);
6433
- return {
6434
- type: "PartialBlock",
6435
- // Set the type to PartialBlock
6436
- label: formatReadableName(b.name || x),
6437
- description: b.description || "",
6438
- icon: Globe,
6439
- group: S,
6440
- // Use formatted type as group
6441
- category: "partial",
6442
- partialBlockId: x,
6443
- // Store the original ID as partialBlockId
6444
- _name: b.name
6445
- };
6446
- }), h = uniq(map(m, "group"));
6447
- p({
6448
- blocks: m,
6449
- groups: h,
6450
- isLoading: !1,
6451
- error: null
6452
- }), g(!0);
6453
- } else l ? p((m) => ({ ...m, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
6454
- blocks: [],
6455
- groups: [],
6456
- isLoading: !1,
6457
- error: "No partial blocks available"
6458
- }), g(!0));
6459
- }, [
6460
- l,
6461
- a,
6462
- u,
6463
- g,
6464
- p,
6465
- d.blocks,
6466
- c
6467
- ]);
6468
- const f = () => {
6469
- p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
6470
- };
6471
- 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: [
6472
- /* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
6473
- /* @__PURE__ */ jsx(
6474
- "button",
6475
- {
6476
- onClick: f,
6477
- className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
6478
- children: "Refresh"
6479
- }
6480
- )
6481
- ] }) : /* @__PURE__ */ jsx(
6482
- ChaiBuilderBlocks,
6483
- {
6484
- gridCols: n,
6485
- parentId: o,
6486
- position: r,
6487
- groups: d.groups,
6488
- blocks: d.blocks
6489
- }
6490
- );
6491
6428
  }, ChaiSelect = ({
6492
6429
  defaultValue: o = "",
6493
6430
  onValueChange: r,
@@ -6527,7 +6464,7 @@ function UILibrariesSelect({
6527
6464
  /* @__PURE__ */ jsx(
6528
6465
  ChaiSelect,
6529
6466
  {
6530
- className: "mt-1",
6467
+ className: "mb-1",
6531
6468
  options: o.map((l) => ({
6532
6469
  value: l.id,
6533
6470
  label: l.name
@@ -6544,18 +6481,18 @@ const BlockCard = ({
6544
6481
  parentId: n = void 0,
6545
6482
  position: a = -1
6546
6483
  }) => {
6547
- 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) => {
6548
- const S = has(v, "styles_attrs.data-page-section");
6549
- return v._type === "Box" && S;
6550
- }, y = useCallback(
6551
- async (v) => {
6552
- 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")) {
6553
6490
  d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6554
6491
  return;
6555
6492
  }
6556
6493
  i(!0);
6557
- const S = await c(r, o);
6558
- 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);
6559
6496
  },
6560
6497
  [d, p, o, c, r, n, a]
6561
6498
  );
@@ -6564,21 +6501,21 @@ const BlockCard = ({
6564
6501
  "div",
6565
6502
  {
6566
6503
  onClick: l ? () => {
6567
- } : y,
6568
- draggable: m ? "true" : "false",
6569
- onDragStart: async (v) => {
6570
- const S = await c(r, o);
6571
- let j = n;
6572
- if (x(first(S)) && (j = null), !isEmpty(S)) {
6573
- const E = { blocks: S, uiLibrary: !0, parent: j };
6574
- if (v.dataTransfer.setData("text/plain", JSON.stringify(E)), o.preview) {
6575
- const w = new Image();
6576
- w.src = o.preview, w.onload = () => {
6577
- 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);
6578
6515
  };
6579
6516
  } else
6580
- v.dataTransfer.setDragImage(new Image(), 0, 0);
6581
- h(E), setTimeout(() => {
6517
+ w.dataTransfer.setDragImage(new Image(), 0, 0);
6518
+ x(C), setTimeout(() => {
6582
6519
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6583
6520
  }, 200);
6584
6521
  }
@@ -6591,128 +6528,273 @@ const BlockCard = ({
6591
6528
  /* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
6592
6529
  /* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
6593
6530
  ] }),
6594
- 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
+ ] })
6595
6535
  ]
6596
6536
  }
6597
6537
  ) }),
6598
- /* @__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
+ ] }) })
6599
6542
  ] });
6600
6543
  }, UILibrarySection = ({ parentId: o, position: r }) => {
6601
- const [n, a] = useAtom$1(selectedLibraryAtom), 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);
6545
+ useEffect(() => {
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);
6602
6560
  useEffect(() => {
6603
- u || g(first(keys(p)));
6604
- }, [p, u]);
6605
- const f = get(p, u, []), m = useRef(null), { t: h } = useTranslation(), x = (v) => {
6606
- m.current && (clearTimeout(m.current), m.current = null), m.current = setTimeout(() => {
6607
- m.current && g(v);
6608
- }, 300);
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("");
6609
6578
  };
6610
6579
  if (d)
6611
6580
  return /* @__PURE__ */ jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
6612
6581
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
6613
6582
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
6614
6583
  ] });
6615
- const y = filter(f, (v, S) => S % 2 === 0), b = filter(f, (v, S) => S % 2 === 1);
6616
- 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: [
6617
- /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
6618
- /* @__PURE__ */ jsx(UILibrariesSelect, { library: i == null ? void 0 : i.id, setLibrary: a, uiLibraries: l }),
6619
- /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
6620
- /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: h("Groups") }),
6621
- /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
6622
- /* @__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(
6623
- "div",
6624
- {
6625
- onMouseEnter: () => x(S),
6626
- onMouseLeave: () => clearTimeout(m.current),
6627
- role: "button",
6628
- onClick: () => g(S),
6629
- className: cn$1(
6630
- "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",
6631
- S === u ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
6632
- ),
6633
- children: [
6634
- /* @__PURE__ */ jsx("span", { children: capitalize(h(S.toLowerCase())) }),
6635
- /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
6636
- ]
6637
- },
6638
- S
6639
- )) })
6640
- ] })
6641
- ] }),
6642
- /* @__PURE__ */ jsxs(
6643
- 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-b border-border p-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",
6644
6743
  {
6645
- onMouseEnter: () => m.current ? clearTimeout(m.current) : null,
6646
- 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",
6647
- children: [
6648
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
6649
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: y.map((v, S) => /* @__PURE__ */ jsx(
6650
- BlockCard,
6651
- {
6652
- parentId: o,
6653
- position: r,
6654
- block: v,
6655
- library: i
6656
- },
6657
- `block-${S}`
6658
- )) }),
6659
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: b.map((v, S) => /* @__PURE__ */ jsx(
6660
- BlockCard,
6661
- {
6662
- parentId: o,
6663
- position: r,
6664
- block: v,
6665
- library: i
6666
- },
6667
- `block-${S}`
6668
- )) })
6669
- ] }),
6670
- /* @__PURE__ */ jsx("br", {}),
6671
- /* @__PURE__ */ jsx("br", {}),
6672
- /* @__PURE__ */ jsx("br", {})
6673
- ]
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"
6674
6747
  }
6675
6748
  )
6676
- ] }) }) });
6677
- }, 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" }) => {
6678
- var C;
6679
- 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);
6680
6762
  useEffect(() => {
6681
- const k = setTimeout(() => {
6682
- var _;
6683
- (_ = u.current) == null || _.focus();
6763
+ const y = setTimeout(() => {
6764
+ var j;
6765
+ (j = u.current) == null || j.focus();
6684
6766
  }, 0);
6685
- return () => clearTimeout(k);
6767
+ return () => clearTimeout(y);
6686
6768
  }, [g]), useEffect(() => {
6687
- d && (h("all"), y(null));
6688
- }, [d]), useEffect(() => (b.current = debounce((k) => {
6689
- h(k);
6769
+ d && (h("all"), k(null));
6770
+ }, [d]), useEffect(() => (b.current = debounce((y) => {
6771
+ h(y);
6690
6772
  }, 500), () => {
6691
6773
  b.current && b.current.cancel();
6692
6774
  }), []);
6693
- const v = useCallback((k) => {
6694
- y(k), b.current && b.current(k);
6695
- }, []), S = useCallback(() => {
6696
- y(null), b.current && b.current.cancel();
6697
- }, []), j = useCallback((k) => {
6698
- 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);
6699
6781
  }, []), E = useMemo(
6700
6782
  () => d ? values(r).filter(
6701
- (k) => {
6702
- var _, T;
6703
- 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());
6704
6786
  }
6705
6787
  ) : r,
6706
6788
  [r, d]
6707
- ), w = useMemo(
6789
+ ), C = useMemo(
6708
6790
  () => d ? o.filter(
6709
- (k) => reject(filter(values(E), { group: k }), { hidden: !0 }).length > 0
6710
- ) : 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),
6711
6793
  [r, E, o, d]
6712
- ), A = useMemo(
6713
- () => sortBy(w, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
6714
- [w]
6715
- ), 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]);
6716
6798
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
6717
6799
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
6718
6800
  Input$1,
@@ -6722,55 +6804,55 @@ const BlockCard = ({
6722
6804
  placeholder: i("Search blocks..."),
6723
6805
  value: d,
6724
6806
  className: "-ml-2",
6725
- onChange: (k) => p(k.target.value)
6807
+ onChange: (y) => p(y.target.value)
6726
6808
  }
6727
6809
  ) }),
6728
6810
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
6729
- 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: [
6730
6812
  /* @__PURE__ */ jsx(
6731
6813
  "button",
6732
6814
  {
6733
- onClick: () => j("all"),
6734
- onMouseEnter: () => v("all"),
6735
- onMouseLeave: S,
6815
+ onClick: () => A("all"),
6816
+ onMouseEnter: () => S("all"),
6817
+ onMouseLeave: w,
6736
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"}`,
6737
6819
  children: i("All")
6738
6820
  },
6739
6821
  "sidebar-all"
6740
6822
  ),
6741
- A.map((k) => /* @__PURE__ */ jsx(
6823
+ B.map((y) => /* @__PURE__ */ jsx(
6742
6824
  "button",
6743
6825
  {
6744
- onClick: () => j(k),
6745
- onMouseEnter: () => v(k),
6746
- onMouseLeave: S,
6747
- 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"}`,
6748
- 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()))
6749
6831
  },
6750
- `sidebar-${k}`
6832
+ `sidebar-${y}`
6751
6833
  ))
6752
6834
  ] }) }) }),
6753
- /* @__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: [
6754
6836
  i("No blocks found matching"),
6755
6837
  ' "',
6756
6838
  d,
6757
6839
  '"'
6758
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: I.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
6759
- /* @__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())) }),
6760
6842
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
6761
- m === "all" ? filter(values(B), { group: k }) : values(B),
6843
+ m === "all" ? filter(values(_), { group: y }) : values(_),
6762
6844
  { hidden: !0 }
6763
- ).map((_) => /* @__PURE__ */ jsx(
6845
+ ).map((j) => /* @__PURE__ */ jsx(
6764
6846
  CoreBlock,
6765
6847
  {
6766
6848
  parentId: n,
6767
6849
  position: a,
6768
- block: _,
6769
- disabled: !canAcceptChildBlock(f, _.type) || !canBeNestedInside(f, _.type)
6850
+ block: j,
6851
+ disabled: !canAcceptChildBlock(f, j.type) || !canBeNestedInside(f, j.type)
6770
6852
  },
6771
- _.type
6853
+ j.type
6772
6854
  )) })
6773
- ] }, k)) }) }) })
6855
+ ] }, y)) }) }) })
6774
6856
  ] })
6775
6857
  ] });
6776
6858
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -6796,8 +6878,8 @@ const BlockCard = ({
6796
6878
  /* @__PURE__ */ jsxs(
6797
6879
  Tabs,
6798
6880
  {
6799
- onValueChange: (v) => {
6800
- d(""), c(v);
6881
+ onValueChange: (S) => {
6882
+ d(""), c(S);
6801
6883
  },
6802
6884
  value: i,
6803
6885
  className: "flex h-full max-h-full flex-col overflow-hidden",
@@ -6807,13 +6889,13 @@ const BlockCard = ({
6807
6889
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
6808
6890
  g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
6809
6891
  x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
6810
- 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}`))
6811
6893
  ] }),
6812
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 }) }) }) }),
6813
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 }) }),
6814
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 }) }) }) }),
6815
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,
6816
- 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}`))
6817
6899
  ]
6818
6900
  }
6819
6901
  )
@@ -6831,9 +6913,7 @@ const BlockCard = ({
6831
6913
  CREATE_LIBRARY_BLOCK: "create_library_block",
6832
6914
  CREATE_LIBRARY_GROUP: "create_library_group",
6833
6915
  EDIT_LIBRARY_BLOCK: "edit_library_block",
6834
- EDIT_LIBRARY_GROUP: "edit_library_group",
6835
- DELETE_LIBRARY_BLOCK: "delete_library_block",
6836
- DELETE_LIBRARY_GROUP: "delete_library_group"
6916
+ DELETE_LIBRARY_BLOCK: "delete_library_block"
6837
6917
  };
6838
6918
  Object.values(PERMISSIONS);
6839
6919
  let SAVE_TO_LIB_COMPONENT = null;
@@ -7113,33 +7193,33 @@ const selectParent = (o, r) => {
7113
7193
  var P;
7114
7194
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7115
7195
  let p = null;
7116
- 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) => {
7117
7197
  N.stopPropagation(), !l.includes(m) && o.toggle();
7118
7198
  }, E = (N) => {
7119
7199
  N.isInternal && (p = N.isOpen, N.isOpen && N.close());
7120
- }, w = (N) => {
7200
+ }, C = (N) => {
7121
7201
  N.isInternal && p !== null && (p ? N.open() : N.close(), p = null);
7122
- }, [A, B] = useAtom$1(currentAddSelection), I = () => {
7202
+ }, [B, _] = useAtom$1(currentAddSelection), L = () => {
7123
7203
  var N;
7124
- C(), o.parent.isSelected || B((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7125
- }, C = () => {
7126
- B(null);
7127
- }, k = (N) => {
7128
- 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);
7129
7209
  };
7130
7210
  useEffect(() => {
7131
7211
  const N = setTimeout(() => {
7132
- y && !o.isOpen && !b && !l.includes(m) && o.toggle();
7212
+ k && !o.isOpen && !b && !l.includes(m) && o.toggle();
7133
7213
  }, 500);
7134
7214
  return () => clearTimeout(N);
7135
- }, [y, o, b]);
7136
- const _ = (N, D) => {
7215
+ }, [k, o, b]);
7216
+ const j = (N, D) => {
7137
7217
  const O = c.contentDocument || c.contentWindow.document, R = O.querySelector(`[data-block-id=${N}]`);
7138
7218
  R && R.setAttribute("data-drop", D);
7139
7219
  const $ = R.getBoundingClientRect(), M = c.getBoundingClientRect();
7140
7220
  $.top >= M.top && $.left >= M.left && $.bottom <= M.bottom && $.right <= M.right || (O.documentElement.scrollTop = R.offsetTop - M.top);
7141
7221
  }, T = (N) => {
7142
- C();
7222
+ v();
7143
7223
  const D = get(o, "parent.id");
7144
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 });
7145
7225
  };
@@ -7161,26 +7241,26 @@ const selectParent = (o, r) => {
7161
7241
  ),
7162
7242
  /* @__PURE__ */ jsx("br", {})
7163
7243
  ] });
7164
- 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]);
7165
7245
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7166
7246
  "div",
7167
7247
  {
7168
7248
  onMouseEnter: () => g(m),
7169
7249
  onMouseLeave: () => f(),
7170
- onClick: k,
7250
+ onClick: y,
7171
7251
  style: r,
7172
7252
  "data-node-id": m,
7173
7253
  ref: l.includes(m) ? null : n,
7174
7254
  onDragStart: () => E(o),
7175
- onDragEnd: () => w(o),
7255
+ onDragEnd: () => C(o),
7176
7256
  onDragOver: (N) => {
7177
- N.preventDefault(), _(m, "yes");
7257
+ N.preventDefault(), j(m, "yes");
7178
7258
  },
7179
7259
  onDragLeave: (N) => {
7180
- N.preventDefault(), _(m, "no");
7260
+ N.preventDefault(), j(m, "no");
7181
7261
  },
7182
7262
  onDrop: (N) => {
7183
- N.preventDefault(), _(m, "no");
7263
+ N.preventDefault(), j(m, "no");
7184
7264
  },
7185
7265
  children: [
7186
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(
@@ -7189,8 +7269,8 @@ const selectParent = (o, r) => {
7189
7269
  onClick: (N) => {
7190
7270
  N.stopPropagation(), T(o.childIndex);
7191
7271
  },
7192
- onMouseEnter: I,
7193
- onMouseLeave: C,
7272
+ onMouseEnter: L,
7273
+ onMouseLeave: v,
7194
7274
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
7195
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" }) })
7196
7276
  }
@@ -7201,11 +7281,11 @@ const selectParent = (o, r) => {
7201
7281
  className: cn(
7202
7282
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
7203
7283
  x ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
7204
- y && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7205
- (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" : "",
7206
7286
  b && "opacity-20",
7207
7287
  l.includes(m) ? "opacity-50" : "",
7208
- L && x && "bg-primary/20 text-primary"
7288
+ I && x && "bg-primary/20 text-primary"
7209
7289
  ),
7210
7290
  children: [
7211
7291
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -7213,7 +7293,7 @@ const selectParent = (o, r) => {
7213
7293
  "div",
7214
7294
  {
7215
7295
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
7216
- 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"}` }) })
7217
7297
  }
7218
7298
  ),
7219
7299
  /* @__PURE__ */ jsxs(
@@ -7221,12 +7301,12 @@ const selectParent = (o, r) => {
7221
7301
  {
7222
7302
  className: cn(
7223
7303
  "leading-1 flex items-center",
7224
- L && "text-primary/60",
7225
- L && x && "text-primary/80"
7304
+ I && "text-primary/60",
7305
+ I && x && "text-primary/80"
7226
7306
  ),
7227
7307
  children: [
7228
7308
  /* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
7229
- v ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
7309
+ S ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
7230
7310
  "div",
7231
7311
  {
7232
7312
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
@@ -7504,63 +7584,63 @@ const selectParent = (o, r) => {
7504
7584
  )
7505
7585
  ] });
7506
7586
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
7507
- 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) => {
7508
- 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);
7509
7589
  }, m = () => {
7510
- const v = l.find((S) => Object.keys(S)[0] === n);
7511
- if (v) {
7512
- const S = Object.values(v)[0];
7513
- 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);
7514
7594
  } else
7515
7595
  console.error("Preset not found:", n);
7516
7596
  }, h = useDebouncedCallback(
7517
- (v, S) => {
7597
+ (S, w) => {
7518
7598
  p(() => ({
7519
7599
  ...d,
7520
7600
  fontFamily: {
7521
7601
  ...d.fontFamily,
7522
- [v.replace(/font-/g, "")]: S
7602
+ [S.replace(/font-/g, "")]: w
7523
7603
  }
7524
7604
  }));
7525
7605
  },
7526
7606
  [d],
7527
7607
  200
7528
7608
  ), x = useDebouncedCallback(
7529
- (v) => {
7609
+ (S) => {
7530
7610
  p(() => ({
7531
7611
  ...d,
7532
- borderRadius: `${v}px`
7612
+ borderRadius: `${S}px`
7533
7613
  }));
7534
7614
  },
7535
7615
  [d],
7536
7616
  200
7537
- ), y = useDebouncedCallback(
7538
- (v, S) => {
7617
+ ), k = useDebouncedCallback(
7618
+ (S, w) => {
7539
7619
  p(() => {
7540
- const j = get(d, `colors.${v}`);
7541
- 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), {
7542
7622
  ...d,
7543
7623
  colors: {
7544
7624
  ...d.colors,
7545
- [v]: j
7625
+ [S]: A
7546
7626
  }
7547
7627
  };
7548
7628
  });
7549
7629
  },
7550
7630
  [d],
7551
7631
  200
7552
- ), b = (v) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(v.items).map(([S]) => {
7553
- 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}`);
7554
7634
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
7555
7635
  /* @__PURE__ */ jsx(
7556
7636
  ColorPickerInput,
7557
7637
  {
7558
- value: j,
7559
- onChange: (E) => y(S, E)
7638
+ value: A,
7639
+ onChange: (E) => k(w, E)
7560
7640
  }
7561
7641
  ),
7562
- /* @__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" : "") })
7563
- ] }, 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);
7564
7644
  }) });
7565
7645
  return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7566
7646
  /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
@@ -7571,11 +7651,11 @@ const selectParent = (o, r) => {
7571
7651
  "select",
7572
7652
  {
7573
7653
  value: n,
7574
- onChange: (v) => f(v.target.value),
7654
+ onChange: (S) => f(S.target.value),
7575
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",
7576
7656
  children: [
7577
7657
  /* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
7578
- 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]))
7579
7659
  ]
7580
7660
  }
7581
7661
  )
@@ -7592,14 +7672,14 @@ const selectParent = (o, r) => {
7592
7672
  ) })
7593
7673
  ] }),
7594
7674
  /* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
7595
- (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(
7596
7676
  FontSelector,
7597
7677
  {
7598
- label: v,
7599
- value: d.fontFamily[v.replace(/font-/g, "")] || S[Object.keys(S)[0]],
7600
- 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)
7601
7681
  },
7602
- v
7682
+ S
7603
7683
  )) }),
7604
7684
  (u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
7605
7685
  /* @__PURE__ */ jsx(Label, { className: "text-sm", children: g("Border Radius") }),
@@ -7610,7 +7690,7 @@ const selectParent = (o, r) => {
7610
7690
  ] }),
7611
7691
  (u == null ? void 0 : u.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
7612
7692
  /* @__PURE__ */ jsx(Label, { className: "text-sm", children: g("Colors") }),
7613
- /* @__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")
7614
7694
  ] })
7615
7695
  ] }),
7616
7696
  /* @__PURE__ */ jsx("br", {}),
@@ -8086,8 +8166,8 @@ const AIUserPrompt = ({ blockId: o }) => {
8086
8166
  (x = f.current) == null || x.focus();
8087
8167
  }, []);
8088
8168
  const h = (x) => {
8089
- const { usage: y } = x || {};
8090
- !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("");
8091
8171
  };
8092
8172
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8093
8173
  /* @__PURE__ */ jsxs(
@@ -8345,72 +8425,72 @@ const UndoRedo = () => {
8345
8425
  var x;
8346
8426
  return (x = m.onMount) == null ? void 0 : x.call(m, h);
8347
8427
  }, ...f) => {
8348
- const m = f[0] || ((B) => {
8349
- let I = o.get(B);
8350
- 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;
8351
8431
  }), h = f[1] || (() => {
8352
- let B, I;
8353
- const C = (k) => {
8432
+ let _, L;
8433
+ const v = (y) => {
8354
8434
  try {
8355
- k();
8356
- } catch (_) {
8357
- B || (B = !0, I = _);
8435
+ y();
8436
+ } catch (j) {
8437
+ _ || (_ = !0, L = j);
8358
8438
  }
8359
8439
  };
8360
8440
  do {
8361
- c.f && C(c.f);
8362
- 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);
8363
8443
  a.forEach((T) => {
8364
- var L;
8365
- return (L = r.get(T)) == null ? void 0 : L.l.forEach(_);
8366
- }), 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();
8367
8447
  } while (a.size || i.size || l.size);
8368
- if (B)
8369
- throw I;
8448
+ if (_)
8449
+ throw L;
8370
8450
  }), x = f[2] || (() => {
8371
- const B = [], I = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
8372
- for (; k.length; ) {
8373
- const _ = k[k.length - 1], T = m(_);
8374
- if (C.has(_)) {
8375
- 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();
8376
8456
  continue;
8377
8457
  }
8378
- if (I.has(_)) {
8379
- 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();
8380
8460
  continue;
8381
8461
  }
8382
- I.add(_);
8383
- for (const L of getMountedOrPendingDependents(_, T, r))
8384
- 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);
8385
8465
  }
8386
- for (let _ = B.length - 1; _ >= 0; --_) {
8387
- const [T, L] = B[_];
8466
+ for (let j = _.length - 1; j >= 0; --j) {
8467
+ const [T, I] = _[j];
8388
8468
  let P = !1;
8389
- for (const N of L.d.keys())
8469
+ for (const N of I.d.keys())
8390
8470
  if (N !== T && a.has(N)) {
8391
8471
  P = !0;
8392
8472
  break;
8393
8473
  }
8394
- P && (y(T), S(T)), n.delete(T);
8474
+ P && (k(T), w(T)), n.delete(T);
8395
8475
  }
8396
- }), y = f[3] || ((B) => {
8397
- var I, C;
8398
- const k = m(B);
8399
- 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(
8400
8480
  ([R, $]) => (
8401
8481
  // Recursively, read the atom state of the dependency, and
8402
8482
  // check if the atom epoch number is unchanged
8403
- y(R).n === $
8483
+ k(R).n === $
8404
8484
  )
8405
8485
  )))
8406
- return k;
8407
- k.d.clear();
8408
- let _ = !0;
8486
+ return y;
8487
+ y.d.clear();
8488
+ let j = !0;
8409
8489
  const T = () => {
8410
- r.has(B) && (S(B), x(), h());
8411
- }, L = (R) => {
8490
+ r.has(_) && (w(_), x(), h());
8491
+ }, I = (R) => {
8412
8492
  var $;
8413
- if (isSelfAtom(B, R)) {
8493
+ if (isSelfAtom(_, R)) {
8414
8494
  const H = m(R);
8415
8495
  if (!isAtomStateInitialized(H))
8416
8496
  if (hasInitialValue(R))
@@ -8419,11 +8499,11 @@ const UndoRedo = () => {
8419
8499
  throw new Error("no atom init");
8420
8500
  return returnAtomValue(H);
8421
8501
  }
8422
- const M = y(R);
8502
+ const M = k(R);
8423
8503
  try {
8424
8504
  return returnAtomValue(M);
8425
8505
  } finally {
8426
- 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();
8427
8507
  }
8428
8508
  };
8429
8509
  let P, N;
@@ -8432,100 +8512,100 @@ const UndoRedo = () => {
8432
8512
  return P || (P = new AbortController()), P.signal;
8433
8513
  },
8434
8514
  get setSelf() {
8435
- return !N && isActuallyWritableAtom(B) && (N = (...R) => {
8436
- if (!_)
8515
+ return !N && isActuallyWritableAtom(_) && (N = (...R) => {
8516
+ if (!j)
8437
8517
  try {
8438
- return v(B, ...R);
8518
+ return S(_, ...R);
8439
8519
  } finally {
8440
8520
  x(), h();
8441
8521
  }
8442
8522
  }), N;
8443
8523
  }
8444
- }, O = k.n;
8524
+ }, O = y.n;
8445
8525
  try {
8446
- const R = d(B, L, D);
8447
- 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(
8448
8528
  T,
8449
8529
  T
8450
- )), k;
8530
+ )), y;
8451
8531
  } catch (R) {
8452
- return delete k.v, k.e = R, ++k.n, k;
8532
+ return delete y.v, y.e = R, ++y.n, y;
8453
8533
  } finally {
8454
- _ = !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, _));
8455
8535
  }
8456
- }), b = f[4] || ((B) => {
8457
- const I = [B];
8458
- for (; I.length; ) {
8459
- const C = I.pop(), k = m(C);
8460
- for (const _ of getMountedOrPendingDependents(C, k, r)) {
8461
- const T = m(_);
8462
- 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);
8463
8543
  }
8464
8544
  }
8465
- }), v = f[5] || ((B, ...I) => {
8466
- let C = !0;
8467
- 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) => {
8468
8548
  var P;
8469
8549
  const N = m(T);
8470
8550
  try {
8471
- if (isSelfAtom(B, T)) {
8551
+ if (isSelfAtom(_, T)) {
8472
8552
  if (!hasInitialValue(T))
8473
8553
  throw new Error("atom not writable");
8474
- const D = N.n, O = L[0];
8475
- 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));
8476
8556
  return;
8477
8557
  } else
8478
- return v(T, ...L);
8558
+ return S(T, ...I);
8479
8559
  } finally {
8480
- C || (x(), h());
8560
+ v || (x(), h());
8481
8561
  }
8482
8562
  };
8483
8563
  try {
8484
- return p(B, k, _, ...I);
8564
+ return p(_, y, j, ...L);
8485
8565
  } finally {
8486
- C = !1;
8566
+ v = !1;
8487
8567
  }
8488
- }), S = f[6] || ((B) => {
8489
- var I;
8490
- const C = m(B), k = r.get(B);
8491
- if (k && !isPendingPromise(C.v)) {
8492
- for (const [_, T] of C.d)
8493
- if (!k.d.has(_)) {
8494
- const L = m(_);
8495
- 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));
8496
8576
  }
8497
- for (const _ of k.d || [])
8498
- if (!C.d.has(_)) {
8499
- k.d.delete(_);
8500
- const T = E(_);
8501
- 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(_);
8502
8582
  }
8503
8583
  }
8504
- }), j = f[7] || ((B) => {
8505
- var I;
8506
- const C = m(B);
8507
- let k = r.get(B);
8508
- if (!k) {
8509
- y(B);
8510
- for (const _ of C.d.keys())
8511
- j(_).t.add(B);
8512
- 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 = {
8513
8593
  l: /* @__PURE__ */ new Set(),
8514
- d: new Set(C.d.keys()),
8594
+ d: new Set(v.d.keys()),
8515
8595
  t: /* @__PURE__ */ new Set()
8516
- }, r.set(B, k), (I = c.m) == null || I.call(c, B), isActuallyWritableAtom(B)) {
8517
- const _ = () => {
8596
+ }, r.set(_, y), (L = c.m) == null || L.call(c, _), isActuallyWritableAtom(_)) {
8597
+ const j = () => {
8518
8598
  let T = !0;
8519
- const L = (...P) => {
8599
+ const I = (...P) => {
8520
8600
  try {
8521
- return v(B, ...P);
8601
+ return S(_, ...P);
8522
8602
  } finally {
8523
8603
  T || (x(), h());
8524
8604
  }
8525
8605
  };
8526
8606
  try {
8527
- const P = g(B, L);
8528
- P && (k.u = () => {
8607
+ const P = g(_, I);
8608
+ P && (y.u = () => {
8529
8609
  T = !0;
8530
8610
  try {
8531
8611
  P();
@@ -8537,27 +8617,27 @@ const UndoRedo = () => {
8537
8617
  T = !1;
8538
8618
  }
8539
8619
  };
8540
- l.add(_);
8620
+ l.add(j);
8541
8621
  }
8542
8622
  }
8543
- return k;
8544
- }), E = f[8] || ((B) => {
8545
- var I;
8546
- const C = m(B);
8547
- let k = r.get(B);
8548
- 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) => {
8549
8629
  var T;
8550
- return (T = r.get(_)) == null ? void 0 : T.d.has(B);
8630
+ return (T = r.get(j)) == null ? void 0 : T.d.has(_);
8551
8631
  })) {
8552
- k.u && i.add(k.u), k = void 0, r.delete(B), (I = c.u) == null || I.call(c, B);
8553
- for (const _ of C.d.keys()) {
8554
- const T = E(_);
8555
- 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(_);
8556
8636
  }
8557
8637
  return;
8558
8638
  }
8559
- return k;
8560
- }), w = [
8639
+ return y;
8640
+ }), C = [
8561
8641
  // store state
8562
8642
  o,
8563
8643
  r,
@@ -8575,29 +8655,29 @@ const UndoRedo = () => {
8575
8655
  m,
8576
8656
  h,
8577
8657
  x,
8578
- y,
8658
+ k,
8579
8659
  b,
8580
- v,
8581
8660
  S,
8582
- j,
8661
+ w,
8662
+ A,
8583
8663
  E
8584
- ], A = {
8585
- get: (B) => returnAtomValue(y(B)),
8586
- set: (B, ...I) => {
8664
+ ], B = {
8665
+ get: (_) => returnAtomValue(k(_)),
8666
+ set: (_, ...L) => {
8587
8667
  try {
8588
- return v(B, ...I);
8668
+ return S(_, ...L);
8589
8669
  } finally {
8590
8670
  x(), h();
8591
8671
  }
8592
8672
  },
8593
- sub: (B, I) => {
8594
- const k = j(B).l;
8595
- return k.add(I), h(), () => {
8596
- 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();
8597
8677
  };
8598
8678
  }
8599
8679
  };
8600
- return Object.defineProperty(A, BUILDING_BLOCKS, { value: w }), A;
8680
+ return Object.defineProperty(B, BUILDING_BLOCKS, { value: C }), B;
8601
8681
  }, INTERNAL_buildStoreRev1 = buildStore, createStore = () => INTERNAL_buildStoreRev1();
8602
8682
  let defaultStore;
8603
8683
  const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), defaultStore), StoreContext = createContext(
@@ -8721,31 +8801,31 @@ function AIChatPanel() {
8721
8801
  content: n,
8722
8802
  timestamp: /* @__PURE__ */ new Date()
8723
8803
  };
8724
- r((v) => [...v, b]), a(""), i(!0), setTimeout(() => {
8725
- const v = {
8804
+ r((S) => [...S, b]), a(""), i(!0), setTimeout(() => {
8805
+ const S = {
8726
8806
  id: (Date.now() + 1).toString(),
8727
8807
  role: "assistant",
8728
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.",
8729
8809
  timestamp: /* @__PURE__ */ new Date()
8730
8810
  };
8731
- r((S) => [...S, v]), i(!1), d(null);
8811
+ r((w) => [...w, S]), i(!1), d(null);
8732
8812
  }, 1500);
8733
8813
  }, m = (b) => {
8734
8814
  b.key === "Enter" && !b.shiftKey && (b.preventDefault(), f());
8735
8815
  }, h = (b) => {
8736
- var S;
8737
- const v = (S = b.target.files) == null ? void 0 : S[0];
8738
- if (v) {
8739
- const j = new FileReader();
8740
- j.onload = (E) => {
8741
- var w;
8742
- d((w = E.target) == null ? void 0 : w.result);
8743
- }, 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);
8744
8824
  }
8745
8825
  }, x = () => {
8746
8826
  var b;
8747
8827
  (b = p.current) == null || b.click();
8748
- }, y = () => {
8828
+ }, k = () => {
8749
8829
  d(null), p.current && (p.current.value = "");
8750
8830
  };
8751
8831
  return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
@@ -8791,7 +8871,7 @@ function AIChatPanel() {
8791
8871
  size: "icon",
8792
8872
  variant: "destructive",
8793
8873
  className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
8794
- onClick: y,
8874
+ onClick: k,
8795
8875
  children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
8796
8876
  }
8797
8877
  )
@@ -8934,7 +9014,7 @@ const AiAssistant = () => {
8934
9014
  preloadedAttributes: r = [],
8935
9015
  onAttributesChange: n
8936
9016
  }) {
8937
- 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();
8938
9018
  useEffect(() => {
8939
9019
  l(r);
8940
9020
  }, [r]);
@@ -8944,43 +9024,43 @@ const AiAssistant = () => {
8944
9024
  return;
8945
9025
  }
8946
9026
  if (i) {
8947
- const A = [...a, { key: i, value: d }];
8948
- n(A), l(a), c(""), p(""), m("");
9027
+ const B = [...a, { key: i, value: d }];
9028
+ n(B), l(a), c(""), p(""), m("");
8949
9029
  }
8950
- }, v = (A) => {
8951
- const B = a.filter((I, C) => C !== A);
8952
- n(B), l(B);
8953
- }, S = (A) => {
8954
- g(A), c(a[A].key), p(a[A].value);
8955
- }, 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 = () => {
8956
9036
  if (i.startsWith("@")) {
8957
9037
  m("Attribute keys cannot start with '@'");
8958
9038
  return;
8959
9039
  }
8960
9040
  if (u !== null && i) {
8961
- const A = [...a];
8962
- 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("");
8963
9043
  }
8964
- }, E = (A) => {
8965
- A.key === "Enter" && !A.shiftKey && (A.preventDefault(), u !== null ? j() : b());
8966
- }, w = useCallback((A) => {
8967
- const B = (k) => /[.,!?;:]/.test(k), I = (k, _, T) => {
8968
- let L = "", P = "";
8969
- const N = _ > 0 ? k[_ - 1] : "", D = _ < k.length ? k[_] : "";
8970
- return _ > 0 && (N === "." || !B(N) && N !== " ") && (L = " "), _ < k.length && !B(D) && D !== " " && (P = " "), {
8971
- text: L + T + P,
8972
- 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,
8973
9053
  suffixLength: P.length
8974
9054
  };
8975
- }, C = x.current;
8976
- if (C) {
8977
- const k = C.selectionStart || 0, _ = C.value || "", T = C.selectionEnd || k;
8978
- if (T > k) {
8979
- 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);
8980
9060
  p($);
8981
9061
  return;
8982
9062
  }
8983
- 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);
8984
9064
  p(D);
8985
9065
  }
8986
9066
  }, []);
@@ -8988,8 +9068,8 @@ const AiAssistant = () => {
8988
9068
  /* @__PURE__ */ jsxs(
8989
9069
  "form",
8990
9070
  {
8991
- onSubmit: (A) => {
8992
- A.preventDefault(), u !== null ? j() : b();
9071
+ onSubmit: (B) => {
9072
+ B.preventDefault(), u !== null ? A() : b();
8993
9073
  },
8994
9074
  className: "space-y-3",
8995
9075
  children: [
@@ -9005,7 +9085,7 @@ const AiAssistant = () => {
9005
9085
  id: "attrKey",
9006
9086
  ref: h,
9007
9087
  value: i,
9008
- onChange: (A) => c(A.target.value),
9088
+ onChange: (B) => c(B.target.value),
9009
9089
  placeholder: "Enter Key",
9010
9090
  className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
9011
9091
  }
@@ -9014,7 +9094,7 @@ const AiAssistant = () => {
9014
9094
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9015
9095
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9016
9096
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9017
- !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: w })
9097
+ !isEmpty(k) && /* @__PURE__ */ jsx(NestedPathSelector, { data: k, onSelect: C })
9018
9098
  ] }),
9019
9099
  /* @__PURE__ */ jsx(
9020
9100
  Textarea,
@@ -9026,7 +9106,7 @@ const AiAssistant = () => {
9026
9106
  rows: 2,
9027
9107
  ref: x,
9028
9108
  value: d,
9029
- onChange: (A) => p(A.target.value),
9109
+ onChange: (B) => p(B.target.value),
9030
9110
  onKeyDown: E,
9031
9111
  placeholder: "Enter Value",
9032
9112
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
@@ -9039,16 +9119,16 @@ const AiAssistant = () => {
9039
9119
  ]
9040
9120
  }
9041
9121
  ),
9042
- /* @__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: [
9043
9123
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9044
- /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: A.key }),
9045
- /* @__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() })
9046
9126
  ] }),
9047
9127
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9048
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => S(B), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9049
- /* @__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" }) })
9050
9130
  ] })
9051
- ] }, B)) })
9131
+ ] }, _)) })
9052
9132
  ] });
9053
9133
  }), BlockAttributesEditor = React.memo(() => {
9054
9134
  const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9157,34 +9237,34 @@ const RootLayout = () => {
9157
9237
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9158
9238
  n("outline");
9159
9239
  });
9160
- const p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = (w) => {
9161
- w.preventDefault();
9162
- }, f = (w) => {
9163
- n(r === w ? null : w);
9164
- }, 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);
9165
9245
  useEffect(() => {
9166
9246
  if (r !== null) {
9167
- const w = find(x, { id: r });
9168
- 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)));
9169
9249
  }
9170
9250
  }, [r, x]);
9171
- const S = useMemo(() => {
9251
+ const w = useMemo(() => {
9172
9252
  if (r === null) return 0;
9173
- const w = find(x, { id: r });
9174
- return get(w, "view", "standard") === "standard" ? v : l;
9175
- }, [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 = () => {
9176
9256
  n(a.current);
9177
9257
  };
9178
9258
  useEffect(() => {
9179
9259
  find(x, { id: r }) || n("outline");
9180
9260
  }, [r, x]);
9181
9261
  const E = useCallback(
9182
- (w) => {
9183
- f(w);
9262
+ (C) => {
9263
+ f(C);
9184
9264
  },
9185
9265
  [f]
9186
9266
  );
9187
- 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: [
9188
9268
  /* @__PURE__ */ jsxs(
9189
9269
  "div",
9190
9270
  {
@@ -9194,33 +9274,33 @@ const RootLayout = () => {
9194
9274
  /* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
9195
9275
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9196
9276
  /* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9197
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: x.map((w, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9198
- /* @__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), {
9199
9279
  position: "top",
9200
- panelId: w.id,
9201
- isActive: r === w.id,
9202
- show: () => E(w.id)
9280
+ panelId: C.id,
9281
+ isActive: r === C.id,
9282
+ show: () => E(C.id)
9203
9283
  }) }),
9204
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h(w.label) }) })
9205
- ] }, "button-top-" + A)) }),
9284
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h(C.label) }) })
9285
+ ] }, "button-top-" + B)) }),
9206
9286
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9207
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: u == null ? void 0 : u.map((w, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9208
- /* @__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), {
9209
9289
  position: "bottom",
9210
- panelId: w.id,
9211
- isActive: r === w.id,
9212
- show: () => E(w.id)
9290
+ panelId: C.id,
9291
+ isActive: r === C.id,
9292
+ show: () => E(C.id)
9213
9293
  }) }),
9214
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h(w.label) }) })
9215
- ] }, "button-bottom-" + A)) })
9294
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h(C.label) }) })
9295
+ ] }, "button-bottom-" + B)) })
9216
9296
  ] }),
9217
9297
  /* @__PURE__ */ jsx(
9218
9298
  motion.div,
9219
9299
  {
9220
9300
  id: "left-panel",
9221
9301
  className: "h-full max-h-full border-r border-border",
9222
- initial: { width: S },
9223
- animate: { width: S },
9302
+ initial: { width: w },
9303
+ animate: { width: w },
9224
9304
  transition: { duration: 0.3, ease: "easeInOut" },
9225
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: [
9226
9306
  /* @__PURE__ */ jsx(
@@ -9271,7 +9351,7 @@ const RootLayout = () => {
9271
9351
  ] }) })
9272
9352
  }
9273
9353
  ),
9274
- 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: [
9275
9355
  /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border p-4 pb-2", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
9276
9356
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9277
9357
  /* @__PURE__ */ jsx("span", { children: h(get(b, "label", "")) })
@@ -9279,7 +9359,7 @@ const RootLayout = () => {
9279
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), {}) }) })
9280
9360
  ] }) }),
9281
9361
  " ",
9282
- 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: [
9283
9363
  /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border p-4 pb-2", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
9284
9364
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9285
9365
  /* @__PURE__ */ jsx("span", { children: h(get(b, "label", "")) })
@@ -9308,7 +9388,7 @@ const RootLayout = () => {
9308
9388
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9309
9389
  /* @__PURE__ */ jsx("span", { children: h(get(b, "label", "")) })
9310
9390
  ] }),
9311
- /* @__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" }) })
9312
9392
  ] }),
9313
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), {}) }) })
9314
9394
  ]
@@ -9375,7 +9455,10 @@ const RootLayout = () => {
9375
9455
  });
9376
9456
  }, [o.translations]), useEffect(() => (a !== "SAVED" ? window.onbeforeunload = () => "" : window.onbeforeunload = null, () => {
9377
9457
  window.onbeforeunload = null;
9378
- }), [a]), /* @__PURE__ */ jsx(l, {});
9458
+ }), [a]), /* @__PURE__ */ jsxs(Fragment, { children: [
9459
+ /* @__PURE__ */ jsx(PrimaryColorCSSVariable, {}),
9460
+ /* @__PURE__ */ jsx(l, {})
9461
+ ] });
9379
9462
  }, ChaiBuilderEditor = (o) => {
9380
9463
  const r = o.onError || noop;
9381
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: [
@@ -9458,13 +9541,14 @@ export {
9458
9541
  useSelectedBlockIds,
9459
9542
  useSelectedBlocksDisplayChild,
9460
9543
  useSelectedBreakpoints,
9544
+ useSelectedLibrary,
9461
9545
  useSelectedStylingBlocks,
9462
9546
  useSidebarActivePanel,
9463
9547
  useStylingBreakpoint,
9464
9548
  useStylingState,
9465
9549
  useTheme,
9466
9550
  useThemeOptions,
9467
- Ve as useTranslation,
9551
+ Ue as useTranslation,
9468
9552
  useUILibraryBlocks,
9469
9553
  useUndoManager,
9470
9554
  useUpdateBlocksProps,