@chaibuilder/sdk 1.2.91 → 1.2.93-beta.1

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.
Files changed (40) hide show
  1. package/dist/{CodeEditor-_Pim7pDO.js → CodeEditor-_pniWL9A.js} +20 -18
  2. package/dist/CodeEditor-hbpcHA6a.cjs +1 -0
  3. package/dist/GlobalBlockSettings-1Ix883dP.cjs +1 -0
  4. package/dist/GlobalBlockSettings-eytCBAHr.js +44 -0
  5. package/dist/Topbar-0dGbwmC_.cjs +1 -0
  6. package/dist/{Topbar-4ejjKoRn.js → Topbar-AzDg5F6n.js} +14 -12
  7. package/dist/{UnsplashImages-fpbR9Jbs.js → UnsplashImages-Gdm78EC5.js} +11 -9
  8. package/dist/UnsplashImages-etSQzJ6J.cjs +1 -0
  9. package/dist/{UploadImages-9hzL5Hu1.js → UploadImages-2XWy9JHd.js} +31 -56
  10. package/dist/UploadImages-lyC-Th50.cjs +1 -0
  11. package/dist/_commonjsHelpers-f3sTPFkQ.js +8 -0
  12. package/dist/_commonjsHelpers-f52AuuUj.cjs +1 -0
  13. package/dist/core.cjs +1 -1
  14. package/dist/core.d.ts +34 -11
  15. package/dist/core.js +71 -67
  16. package/dist/{iconBase-zweRWSz0.js → iconBase-HBZkvN04.js} +29 -22
  17. package/dist/iconBase-kuD_VwQx.cjs +1 -0
  18. package/dist/index-lynOzeB3.cjs +223 -0
  19. package/dist/{index-ry3B_D93.js → index-zgy8mVKm.js} +9626 -10802
  20. package/dist/plugin-02QsHeBE.cjs +1 -0
  21. package/dist/{plugin-P0tpo_XZ.cjs → plugin-BXpjdQxx.cjs} +1 -1
  22. package/dist/{plugin-f5uJtdXY.js → plugin-DdKuAR7p.js} +1 -1
  23. package/dist/plugin-VDzc8jUO.js +52 -0
  24. package/dist/render.cjs +2 -2
  25. package/dist/render.js +7 -6
  26. package/dist/tailwind.cjs +1 -1
  27. package/dist/tailwind.js +7 -6
  28. package/dist/useGlobalBlocksStore-1wJUEOl4.cjs +1 -0
  29. package/dist/useGlobalBlocksStore-HlGhDxuV.js +1258 -0
  30. package/dist/web-blocks.cjs +1 -1
  31. package/dist/web-blocks.js +257 -229
  32. package/package.json +2 -2
  33. package/dist/CodeEditor-Imjgt7mh.cjs +0 -1
  34. package/dist/Topbar-irIirqy7.cjs +0 -1
  35. package/dist/UnsplashImages-NfwOtGHo.cjs +0 -1
  36. package/dist/UploadImages-OVHnYeiL.cjs +0 -1
  37. package/dist/iconBase-vJD0OXxU.cjs +0 -1
  38. package/dist/index-VBJLJ6fO.cjs +0 -223
  39. package/dist/plugin-_F-KZp1i.cjs +0 -1
  40. package/dist/plugin-sJ3Hzvpv.js +0 -57
@@ -0,0 +1 @@
1
+ "use strict";const f=require("./_commonjsHelpers-f52AuuUj.cjs");var o={},a={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return i}});function u(t,e){return{handler:t,config:e}}u.withOptions=function(t,e=()=>({})){const r=function(l){return{__options:l,handler:t(l),config:e(l)}};return r.__isOptionsFunction=!0,r.__pluginFunction=t,r.__configFunction=e,r};const i=u})(a);(function(n){Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return t}});const u=i(a);function i(e){return e&&e.__esModule?e:{default:e}}const t=u.default})(o);let c=o;var _=(c.__esModule?c:{default:c}).default;const d=f.getDefaultExportFromCjs(_);exports.plugin=d;
@@ -1 +1 @@
1
- "use strict";const r=require("lodash-es"),u=require("tailwindcss-palette-generator"),b=require("./plugin-_F-KZp1i.cjs"),f=o=>{const t=r.get(o,"primaryColor","#000"),c=r.get(o,"secondaryColor","#ccc"),i=r.get(o,"headingFont","Inter"),l=r.get(o,"bodyFont","Inter"),n=r.get(o,"roundedCorners","0"),a=r.get(o,"bodyBgLightColor","#fff"),d=r.get(o,"bodyBgDarkColor","#000"),g=r.get(o,"bodyTextLightColor","#000"),e=r.get(o,"bodyTextDarkColor","#fff"),s=u([{color:t,name:"primary"},{color:c,name:"secondary"}]),y={"bg-light":a,"bg-dark":d,"text-dark":e,"text-light":g};return{container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},fontFamily:{heading:[i],body:[l]},borderRadius:{DEFAULT:`${n||"0px"}px`},colors:{...s,...y}}},C=b.plugin(function({addBase:o,theme:t}){o({"h1,h2,h3,h4,h5,h6":{fontFamily:t("fontFamily.heading")},body:{fontFamily:t("fontFamily.body"),color:t("colors.text-light"),backgroundColor:t("colors.bg-light")},".dark body":{color:t("colors.text-dark"),backgroundColor:t("colors.bg-dark")}})});exports.chaiBuilderPlugin=C;exports.getChaiBuilderTheme=f;
1
+ "use strict";const r=require("lodash-es"),u=require("tailwindcss-palette-generator"),b=require("./plugin-02QsHeBE.cjs"),f=o=>{const t=r.get(o,"primaryColor","#000"),c=r.get(o,"secondaryColor","#ccc"),i=r.get(o,"headingFont","Inter"),l=r.get(o,"bodyFont","Inter"),n=r.get(o,"roundedCorners","0"),a=r.get(o,"bodyBgLightColor","#fff"),d=r.get(o,"bodyBgDarkColor","#000"),g=r.get(o,"bodyTextLightColor","#000"),e=r.get(o,"bodyTextDarkColor","#fff"),s=u([{color:t,name:"primary"},{color:c,name:"secondary"}]),y={"bg-light":a,"bg-dark":d,"text-dark":e,"text-light":g};return{container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},fontFamily:{heading:[i],body:[l]},borderRadius:{DEFAULT:`${n||"0px"}px`},colors:{...s,...y}}},C=b.plugin(function({addBase:o,theme:t}){o({"h1,h2,h3,h4,h5,h6":{fontFamily:t("fontFamily.heading")},body:{fontFamily:t("fontFamily.body"),color:t("colors.text-light"),backgroundColor:t("colors.bg-light")},".dark body":{color:t("colors.text-dark"),backgroundColor:t("colors.bg-dark")}})});exports.chaiBuilderPlugin=C;exports.getChaiBuilderTheme=f;
@@ -1,6 +1,6 @@
1
1
  import { get as r } from "lodash-es";
2
2
  import e from "tailwindcss-palette-generator";
3
- import { p as f } from "./plugin-sJ3Hzvpv.js";
3
+ import { p as f } from "./plugin-VDzc8jUO.js";
4
4
  const C = (o) => {
5
5
  const n = r(o, "primaryColor", "#000"), a = r(o, "secondaryColor", "#ccc"), c = r(o, "headingFont", "Inter"), d = r(o, "bodyFont", "Inter"), t = r(o, "roundedCorners", "0"), l = r(o, "bodyBgLightColor", "#fff"), i = r(o, "bodyBgDarkColor", "#000"), s = r(o, "bodyTextLightColor", "#000"), g = r(o, "bodyTextDarkColor", "#fff"), y = e([
6
6
  { color: n, name: "primary" },
@@ -0,0 +1,52 @@
1
+ import { g as f } from "./_commonjsHelpers-f3sTPFkQ.js";
2
+ var a = {}, c = {};
3
+ (function(n) {
4
+ Object.defineProperty(n, "__esModule", {
5
+ value: !0
6
+ }), Object.defineProperty(n, "default", {
7
+ enumerable: !0,
8
+ get: function() {
9
+ return i;
10
+ }
11
+ });
12
+ function u(t, e) {
13
+ return {
14
+ handler: t,
15
+ config: e
16
+ };
17
+ }
18
+ u.withOptions = function(t, e = () => ({})) {
19
+ const r = function(l) {
20
+ return {
21
+ __options: l,
22
+ handler: t(l),
23
+ config: e(l)
24
+ };
25
+ };
26
+ return r.__isOptionsFunction = !0, r.__pluginFunction = t, r.__configFunction = e, r;
27
+ };
28
+ const i = u;
29
+ })(c);
30
+ (function(n) {
31
+ Object.defineProperty(n, "__esModule", {
32
+ value: !0
33
+ }), Object.defineProperty(n, "default", {
34
+ enumerable: !0,
35
+ get: function() {
36
+ return t;
37
+ }
38
+ });
39
+ const u = /* @__PURE__ */ i(c);
40
+ function i(e) {
41
+ return e && e.__esModule ? e : {
42
+ default: e
43
+ };
44
+ }
45
+ const t = u.default;
46
+ })(a);
47
+ let o = a;
48
+ var _ = (o.__esModule ? o : { default: o }).default;
49
+ const s = /* @__PURE__ */ f(_);
50
+ export {
51
+ s as p
52
+ };
package/dist/render.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("lodash-es"),a=require("./STRINGS-Yl7cSWDc.cjs"),p=require("./jsx-runtime-JYMCiFoE.cjs"),h=require("react"),w=require("tailwind-merge"),x=require("@chaibuilder/runtime"),B=require("@mhsdesign/jit-browser-tailwindcss"),C=require("@tailwindcss/forms"),Y=require("@tailwindcss/typography"),q=require("@tailwindcss/aspect-ratio"),E=require("./plugin-P0tpo_XZ.cjs");require("tailwindcss-palette-generator");require("./plugin-_F-KZp1i.cjs");const _=(e,n="")=>{const s=e.replace(a.STYLES_KEY,"").split(",").map(i=>i.split(" ").map(l=>{if(l==="")return"";if(l.includes(":")){const o=l.split(":");return o[o.length-1]=n+r.last(o),o.join(":")}return`${n}${l}`}).join(" "));return r.flattenDeep(s).join(" ")},O=e=>{if(!e)return[];try{return JSON.parse(R(e)).filter(t=>!t._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function R(e){const n=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(n,t=>{const s=decodeURIComponent(t),i=s.indexOf("public");return i!==-1?s.substring(i+6):s})}const K=e=>{const n={};return Object.keys(e).forEach(t=>{r.isString(e[t])&&e[t].startsWith(a.SLOT_KEY)&&(n[t]=e[t].replace(a.SLOT_KEY,"").split(","))}),n},A=r.memoize((e,n)=>{const t=e.replace(a.STYLES_KEY,"").split(","),s=w.twMerge(t[0],t[1]);return n===""?s.replace(a.STYLES_KEY,"").trim():_(s,n).replace(a.STYLES_KEY,"").trim()});function L(e,n){const t=r.get(e,`${n}_attrs`,{});r.has(t,"data-ai-key")&&delete t["data-ai-key"];const s=r.keys(t).join(" ");return r.includes(s,"x-show")&&!r.includes(s,"x-transition")&&(t["x-transition"]=""),t}function N(e,n){const t={};return Object.keys(e).forEach(s=>{if(r.isString(e[s])&&e[s].startsWith(a.STYLES_KEY)){const i=A(e[s],n);t[s]={className:i,...L(e,s)}}}),t}function P(e,n){const t=r.get(e,"_bindings",{});return r.isEmpty(t)?{...e}:(r.each(t,(s,i)=>{r.isString(s)&&r.get(n,s,null)&&(e[i]=r.get(n,s,null))}),e)}function m({blocks:e,parent:n,classPrefix:t="",externalData:s={},blockModifierCallback:i}){const u=e,y=o=>N(o,t),l=n?r.filter(e,{_parent:n}):r.filter(e,o=>r.isEmpty(o._parent));return p.jsxRuntimeExports.jsx(p.jsxRuntimeExports.Fragment,{children:h.Children.toArray(l.map((o,j)=>{const d=K(o),g={};r.isEmpty(d)||Object.keys(d).forEach(c=>{g[c]=h.Children.toArray(d[c].map(S=>p.jsxRuntimeExports.jsx(m,{externalData:s,classPrefix:t,blocks:u,parent:S})))});const T=r.filter(u,{_parent:o._id});g.children=T.length>0?p.jsxRuntimeExports.jsx(m,{externalData:s,classPrefix:t,parent:o._id,blocks:u}):null;const f=x.getBlockComponent(o._type);if(f!==null){let c=o;const S=f.component;return c={...f.defaults,...o},i&&(c=i(c)),h.createElement(S,r.omit({blockProps:{},inBuilder:!1,...c,index:j,...P(o,s),...y(c),...g},["_parent"]))}return p.jsxRuntimeExports.jsxs("noscript",{children:[o._type," not found"]})}))})}async function $(e,n,t=[],s="",i=!1){return await B.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:t,theme:E.getChaiBuilderTheme(e),plugins:[C,Y,q,E.chaiBuilderPlugin],corePlugins:{preflight:i},...s?{prefix:`${s}`}:{}}}).generateStylesFromContent(` ${i?"@tailwind base;":""}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("lodash-es"),a=require("./STRINGS-Yl7cSWDc.cjs"),p=require("./jsx-runtime-JYMCiFoE.cjs"),h=require("react"),w=require("tailwind-merge"),x=require("@chaibuilder/runtime"),B=require("@mhsdesign/jit-browser-tailwindcss"),q=require("@tailwindcss/forms"),C=require("@tailwindcss/typography"),Y=require("@tailwindcss/aspect-ratio"),E=require("./plugin-BXpjdQxx.cjs");require("tailwindcss-palette-generator");require("./plugin-02QsHeBE.cjs");require("./_commonjsHelpers-f52AuuUj.cjs");const _=(e,r="")=>{const s=e.replace(a.STYLES_KEY,"").split(",").map(i=>i.split(" ").map(l=>{if(l==="")return"";if(l.includes(":")){const o=l.split(":");return o[o.length-1]=r+n.last(o),o.join(":")}return`${r}${l}`}).join(" "));return n.flattenDeep(s).join(" ")},O=e=>{if(!e)return[];try{return JSON.parse(R(e)).filter(t=>!t._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function R(e){const r=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(r,t=>{const s=decodeURIComponent(t),i=s.indexOf("public");return i!==-1?s.substring(i+6):s})}const K=e=>{const r={};return Object.keys(e).forEach(t=>{n.isString(e[t])&&e[t].startsWith(a.SLOT_KEY)&&(r[t]=e[t].replace(a.SLOT_KEY,"").split(","))}),r},A=n.memoize((e,r)=>{const t=e.replace(a.STYLES_KEY,"").split(","),s=w.twMerge(t[0],t[1]);return r===""?s.replace(a.STYLES_KEY,"").trim():_(s,r).replace(a.STYLES_KEY,"").trim()});function L(e,r){const t=n.get(e,`${r}_attrs`,{});n.has(t,"data-ai-key")&&delete t["data-ai-key"];const s=n.keys(t).join(" ");return n.includes(s,"x-show")&&!n.includes(s,"x-transition")&&(t["x-transition"]=""),t}function N(e,r){const t={};return Object.keys(e).forEach(s=>{if(n.isString(e[s])&&e[s].startsWith(a.STYLES_KEY)){const i=A(e[s],r);t[s]={className:i,...L(e,s)}}}),t}function P(e,r){const t=n.get(e,"_bindings",{});return n.isEmpty(t)?{...e}:(n.each(t,(s,i)=>{n.isString(s)&&n.get(r,s,null)&&(e[i]=n.get(r,s,null))}),e)}function m({blocks:e,parent:r,classPrefix:t="",externalData:s={},blockModifierCallback:i}){const u=e,y=o=>N(o,t),l=r?n.filter(e,{_parent:r}):n.filter(e,o=>n.isEmpty(o._parent));return p.jsxRuntimeExports.jsx(p.jsxRuntimeExports.Fragment,{children:h.Children.toArray(l.map((o,j)=>{const d=K(o),g={};n.isEmpty(d)||Object.keys(d).forEach(c=>{g[c]=h.Children.toArray(d[c].map(S=>p.jsxRuntimeExports.jsx(m,{externalData:s,classPrefix:t,blocks:u,parent:S})))});const T=n.filter(u,{_parent:o._id});g.children=T.length>0?p.jsxRuntimeExports.jsx(m,{externalData:s,classPrefix:t,parent:o._id,blocks:u}):null;const f=x.getBlockComponent(o._type);if(f!==null){let c=o;const S=f.component;return c={...f.defaults,...o},i&&(c=i(c)),h.createElement(S,n.omit({blockProps:{},inBuilder:!1,...c,index:j,...P(o,s),...y(c),...g},["_parent"]))}return p.jsxRuntimeExports.jsxs("noscript",{children:[o._type," not found"]})}))})}async function $(e,r,t=[],s="",i=!1){return await B.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:t,theme:E.getChaiBuilderTheme(e),plugins:[q,C,Y,E.chaiBuilderPlugin],corePlugins:{preflight:i},...s?{prefix:`${s}`}:{}}}).generateStylesFromContent(` ${i?"@tailwind base;":""}
2
2
  @tailwind components;
3
- @tailwind utilities;`,n)}const v=(e,n)=>e.map(t=>{const s={};return Object.keys(t).forEach(i=>{r.startsWith(t[i],a.STYLES_KEY)&&(s[i]=_(t[i],n))}),s}),I=(e,n,t="",s=!1)=>$(n,[r.replace(JSON.stringify(v(e,t)),/#styles:/g,"")],[],t,s),J=async(e,n={},t="",s=!0)=>await I(e,n,t,s);exports.RenderChaiBlocks=m;exports.convertToBlocks=O;exports.getStylesForBlocks=J;
3
+ @tailwind utilities;`,r)}const v=(e,r)=>e.map(t=>{const s={};return Object.keys(t).forEach(i=>{n.startsWith(t[i],a.STYLES_KEY)&&(s[i]=_(t[i],r))}),s}),I=(e,r,t="",s=!1)=>$(r,[n.replace(JSON.stringify(v(e,t)),/#styles:/g,"")],[],t,s),J=async(e,r={},t="",s=!0)=>await I(e,r,t,s);exports.RenderChaiBlocks=m;exports.convertToBlocks=O;exports.getStylesForBlocks=J;
package/dist/render.js CHANGED
@@ -8,9 +8,10 @@ import { createTailwindcss as v } from "@mhsdesign/jit-browser-tailwindcss";
8
8
  import F from "@tailwindcss/forms";
9
9
  import L from "@tailwindcss/typography";
10
10
  import U from "@tailwindcss/aspect-ratio";
11
- import { g as z, c as M } from "./plugin-f5uJtdXY.js";
11
+ import { g as z, c as M } from "./plugin-DdKuAR7p.js";
12
12
  import "tailwindcss-palette-generator";
13
- import "./plugin-sJ3Hzvpv.js";
13
+ import "./plugin-VDzc8jUO.js";
14
+ import "./_commonjsHelpers-f3sTPFkQ.js";
14
15
  const E = (s, r = "") => {
15
16
  const e = s.replace(c, "").split(",").map((n) => n.split(" ").map((a) => {
16
17
  if (a === "")
@@ -22,7 +23,7 @@ const E = (s, r = "") => {
22
23
  return `${r}${a}`;
23
24
  }).join(" "));
24
25
  return A(e).join(" ");
25
- }, ft = (s) => {
26
+ }, mt = (s) => {
26
27
  if (!s)
27
28
  return [];
28
29
  try {
@@ -160,9 +161,9 @@ const D = (s, r) => s.map((t) => {
160
161
  [],
161
162
  t,
162
163
  e
163
- ), mt = async (s, r = {}, t = "", e = !0) => await b(s, r, t, e);
164
+ ), dt = async (s, r = {}, t = "", e = !0) => await b(s, r, t, e);
164
165
  export {
165
166
  B as RenderChaiBlocks,
166
- ft as convertToBlocks,
167
- mt as getStylesForBlocks
167
+ mt as convertToBlocks,
168
+ dt as getStylesForBlocks
168
169
  };
package/dist/tailwind.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@tailwindcss/typography"),a=require("@tailwindcss/forms"),i=require("@tailwindcss/aspect-ratio"),n=require("tailwindcss-animate"),r=require("./plugin-P0tpo_XZ.cjs");require("lodash-es");require("tailwindcss-palette-generator");require("./plugin-_F-KZp1i.cjs");function d(){return{colors:{border:"hsl(var(--border))",input:"hsl(var(--input))",ring:"hsl(var(--ring))",background:"hsl(var(--background))",foreground:"hsl(var(--foreground))",primary:{DEFAULT:"hsl(var(--primary))",foreground:"hsl(var(--primary-foreground))"},secondary:{DEFAULT:"hsl(var(--secondary))",foreground:"hsl(var(--secondary-foreground))"},destructive:{DEFAULT:"hsl(var(--destructive))",foreground:"hsl(var(--destructive-foreground))"},muted:{DEFAULT:"hsl(var(--muted))",foreground:"hsl(var(--muted-foreground))"},accent:{DEFAULT:"hsl(var(--accent))",foreground:"hsl(var(--accent-foreground))"},popover:{DEFAULT:"hsl(var(--popover))",foreground:"hsl(var(--popover-foreground))"},card:{DEFAULT:"hsl(var(--card))",foreground:"hsl(var(--card-foreground))"}},borderRadius:{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"},keyframes:{"accordion-down":{from:{height:"0"},to:{height:"var(--radix-accordion-content-height)"}},"accordion-up":{from:{height:"var(--radix-accordion-content-height)"},to:{height:"0"}}},animation:{"accordion-down":"accordion-down 0.2s ease-out","accordion-up":"accordion-up 0.2s ease-out"}}}const u=e=>({darkMode:"class",content:[...e,"node_modules/@chaibuilder/sdk/dist/*.{js,cjs}","node_modules/@chaibuilder/runtime/dist/*.{js,cjs}"],theme:{container:{center:!0,padding:"2rem",screens:{"2xl":"1400px"}},extend:d()},plugins:[n,o,a,i]});exports.chaiBuilderPlugin=r.chaiBuilderPlugin;exports.getChaiBuilderTheme=r.getChaiBuilderTheme;exports.getChaiBuilderTailwindConfig=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@tailwindcss/typography"),a=require("@tailwindcss/forms"),i=require("@tailwindcss/aspect-ratio"),n=require("tailwindcss-animate"),r=require("./plugin-BXpjdQxx.cjs");require("lodash-es");require("tailwindcss-palette-generator");require("./plugin-02QsHeBE.cjs");require("./_commonjsHelpers-f52AuuUj.cjs");function d(){return{colors:{border:"hsl(var(--border))",input:"hsl(var(--input))",ring:"hsl(var(--ring))",background:"hsl(var(--background))",foreground:"hsl(var(--foreground))",primary:{DEFAULT:"hsl(var(--primary))",foreground:"hsl(var(--primary-foreground))"},secondary:{DEFAULT:"hsl(var(--secondary))",foreground:"hsl(var(--secondary-foreground))"},destructive:{DEFAULT:"hsl(var(--destructive))",foreground:"hsl(var(--destructive-foreground))"},muted:{DEFAULT:"hsl(var(--muted))",foreground:"hsl(var(--muted-foreground))"},accent:{DEFAULT:"hsl(var(--accent))",foreground:"hsl(var(--accent-foreground))"},popover:{DEFAULT:"hsl(var(--popover))",foreground:"hsl(var(--popover-foreground))"},card:{DEFAULT:"hsl(var(--card))",foreground:"hsl(var(--card-foreground))"}},borderRadius:{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"},keyframes:{"accordion-down":{from:{height:"0"},to:{height:"var(--radix-accordion-content-height)"}},"accordion-up":{from:{height:"var(--radix-accordion-content-height)"},to:{height:"0"}}},animation:{"accordion-down":"accordion-down 0.2s ease-out","accordion-up":"accordion-up 0.2s ease-out"}}}const u=e=>({darkMode:"class",content:[...e,"node_modules/@chaibuilder/sdk/dist/*.{js,cjs}","node_modules/@chaibuilder/runtime/dist/*.{js,cjs}"],theme:{container:{center:!0,padding:"2rem",screens:{"2xl":"1400px"}},extend:d()},plugins:[n,o,a,i]});exports.chaiBuilderPlugin=r.chaiBuilderPlugin;exports.getChaiBuilderTheme=r.getChaiBuilderTheme;exports.getChaiBuilderTailwindConfig=u;
package/dist/tailwind.js CHANGED
@@ -2,10 +2,11 @@ import o from "@tailwindcss/typography";
2
2
  import e from "@tailwindcss/forms";
3
3
  import a from "@tailwindcss/aspect-ratio";
4
4
  import d from "tailwindcss-animate";
5
- import { c as v, g as f } from "./plugin-f5uJtdXY.js";
5
+ import { c as f, g as T } from "./plugin-DdKuAR7p.js";
6
6
  import "lodash-es";
7
7
  import "tailwindcss-palette-generator";
8
- import "./plugin-sJ3Hzvpv.js";
8
+ import "./plugin-VDzc8jUO.js";
9
+ import "./_commonjsHelpers-f3sTPFkQ.js";
9
10
  function n() {
10
11
  return {
11
12
  colors: {
@@ -64,7 +65,7 @@ function n() {
64
65
  }
65
66
  };
66
67
  }
67
- const g = (r) => ({
68
+ const m = (r) => ({
68
69
  darkMode: "class",
69
70
  content: [
70
71
  ...r,
@@ -84,7 +85,7 @@ const g = (r) => ({
84
85
  plugins: [d, o, e, a]
85
86
  });
86
87
  export {
87
- v as chaiBuilderPlugin,
88
- g as getChaiBuilderTailwindConfig,
89
- f as getChaiBuilderTheme
88
+ f as chaiBuilderPlugin,
89
+ m as getChaiBuilderTailwindConfig,
90
+ T as getChaiBuilderTheme
90
91
  };
@@ -0,0 +1 @@
1
+ "use strict";const P=require("react"),u=require("lodash-es"),b=require("jotai"),$=require("./iconBase-kuD_VwQx.cjs"),Ze=require("./_commonjsHelpers-f52AuuUj.cjs"),$e=require("@react-hookz/web");require("react-i18next");require("@chaibuilder/runtime");const Ke=require("tree-model");var x={VITE_OPENAI_API_KEY:"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",VITE_UNSPASH_ACCESS_KEY:"XgYBCm-XCHecRMsbfhw6oZWGkltco1U5TYMEd0LXZeA",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};let Qe=0;function T(e,t){const o=`atom${++Qe}`,n={toString:()=>o};return typeof e=="function"?n.read=e:(n.init=e,n.read=s=>s(n),n.write=(s,r,c)=>r(n,typeof c=="function"?c(s(n)):c)),t&&(n.write=t),n}const te=e=>"init"in e,oe=e=>!!e.write,K=new WeakMap,et=(e,t)=>{K.set(e,t),e.catch(()=>{}).finally(()=>K.delete(e))},he=(e,t)=>{const o=K.get(e);o&&(K.delete(e),o(t))},ke=(e,t)=>{e.status="fulfilled",e.value=t},Be=(e,t)=>{e.status="rejected",e.reason=t},tt=e=>typeof(e==null?void 0:e.then)=="function",z=(e,t)=>"v"in e&&"v"in t&&Object.is(e.v,t.v),ve=(e,t)=>"e"in e&&"e"in t&&Object.is(e.e,t.e),H=e=>"v"in e&&e.v instanceof Promise,ot=(e,t)=>"v"in e&&"v"in t&&e.v.orig&&e.v.orig===t.v.orig,Z=e=>{if("e"in e)throw e.e;return e.v},Se=()=>{const e=new WeakMap,t=new WeakMap,o=new Map;let n,s,r;(x?"production":void 0)!=="production"&&(n=new Set,s=new Set,r=new Set);const c=l=>e.get(l),a=(l,f)=>{(x?"production":void 0)!=="production"&&Object.freeze(f);const m=e.get(l);if(e.set(l,f),o.has(l)||o.set(l,m),m&&H(m)){const p="v"in f?f.v instanceof Promise?f.v:Promise.resolve(f.v):Promise.reject(f.e);he(m.v,p)}},d=(l,f,m)=>{const p=new Map;let h=!1;m.forEach((g,B)=>{!g&&B===l&&(g=f),g?(p.set(B,g),f.d.get(B)!==g&&(h=!0)):(x?"production":void 0)!=="production"&&console.warn("[Bug] atom state not found")}),(h||f.d.size!==p.size)&&(f.d=p)},i=(l,f,m)=>{const p=c(l),h={d:(p==null?void 0:p.d)||new Map,v:f};if(m&&d(l,h,m),p&&z(p,h)&&p.d===h.d)return p;if(p&&H(p)&&H(h)&&ot(p,h)){if(p.d===h.d)return p;h.v=p.v}return a(l,h),h},k=(l,f,m,p)=>{if(tt(f)){let h;const g=new Promise((B,L)=>{let A=!1;f.then(S=>{if(!A){A=!0;const _=c(l),j=i(l,g,m);ke(g,S),B(S),(_==null?void 0:_.d)!==j.d&&M(l,j,_==null?void 0:_.d)}},S=>{if(!A){A=!0;const _=c(l),j=i(l,g,m);Be(g,S),L(S),(_==null?void 0:_.d)!==j.d&&M(l,j,_==null?void 0:_.d)}}),h=S=>{A||(A=!0,S.then(_=>ke(g,_),_=>Be(g,_)),B(S))}});return g.orig=f,g.status="pending",et(g,B=>{B&&h(B),p==null||p()}),i(l,g,m)}return i(l,f,m)},O=(l,f,m)=>{const p=c(l),h={d:(p==null?void 0:p.d)||new Map,e:f};return m&&d(l,h,m),p&&ve(p,h)&&p.d===h.d?p:(a(l,h),h)},F=l=>{const f=c(l);if(f&&(f.d.forEach((A,S)=>{S!==l&&!t.has(S)&&F(S)}),Array.from(f.d).every(([A,S])=>{const _=c(A);return A===l||_===S||_&&!H(_)&&z(_,S)})))return f;const m=new Map;let p=!0;const h=A=>{if(A===l){const _=c(A);if(_)return m.set(A,_),Z(_);if(te(A))return m.set(A,void 0),A.init;throw new Error("no atom init")}const S=F(A);return m.set(A,S),Z(S)};let g,B;const L={get signal(){return g||(g=new AbortController),g.signal},get setSelf(){return(x?"production":void 0)!=="production"&&!oe(l)&&console.warn("setSelf function cannot be used with read-only atom"),!B&&oe(l)&&(B=(...A)=>{if((x?"production":void 0)!=="production"&&p&&console.warn("setSelf function cannot be called in sync"),!p)return w(l,...A)}),B}};try{const A=l.read(h,L);return k(l,A,m,()=>g==null?void 0:g.abort())}catch(A){return O(l,A,m)}finally{p=!1}},V=l=>Z(F(l)),v=l=>{let f=t.get(l);return f||(f=C(l)),f},E=(l,f)=>!f.l.size&&(!f.t.size||f.t.size===1&&f.t.has(l)),I=l=>{const f=t.get(l);f&&E(l,f)&&D(l)},U=l=>{const f=new Map,m=new WeakMap,p=g=>{const B=t.get(g);B==null||B.t.forEach(L=>{L!==g&&(f.set(L,(f.get(L)||new Set).add(g)),m.set(L,(m.get(L)||0)+1),p(L))})};p(l);const h=g=>{const B=t.get(g);B==null||B.t.forEach(L=>{var A;if(L!==g){let S=m.get(L);if(S&&m.set(L,--S),!S){let _=!!((A=f.get(L))!=null&&A.size);if(_){const j=c(L),Je=F(L);_=!j||!z(j,Je)}_||f.forEach(j=>j.delete(L))}h(L)}})};h(l)},y=(l,...f)=>{let m=!0;const p=B=>Z(F(B)),h=(B,...L)=>{let A;if(B===l){if(!te(B))throw new Error("atom not writable");const S=c(B),_=k(B,L[0]);(!S||!z(S,_))&&U(B)}else A=y(B,...L);if(!m){const S=N();(x?"production":void 0)!=="production"&&s.forEach(_=>_({type:"async-write",flushed:S}))}return A},g=l.write(p,h,...f);return m=!1,g},w=(l,...f)=>{const m=y(l,...f),p=N();return(x?"production":void 0)!=="production"&&s.forEach(h=>h({type:"write",flushed:p})),m},C=(l,f)=>{const m={t:new Set(f&&[f]),l:new Set};if(t.set(l,m),(x?"production":void 0)!=="production"&&r.add(l),F(l).d.forEach((p,h)=>{const g=t.get(h);g?g.t.add(l):h!==l&&C(h,l)}),F(l),oe(l)&&l.onMount){const p=l.onMount((...h)=>w(l,...h));p&&(m.u=p)}return m},D=l=>{var f;const m=(f=t.get(l))==null?void 0:f.u;m&&m(),t.delete(l),(x?"production":void 0)!=="production"&&r.delete(l);const p=c(l);p?(H(p)&&he(p.v),p.d.forEach((h,g)=>{if(g!==l){const B=t.get(g);B&&(B.t.delete(l),E(g,B)&&D(g))}})):(x?"production":void 0)!=="production"&&console.warn("[Bug] could not find atom state to unmount",l)},M=(l,f,m)=>{const p=new Set(f.d.keys());m==null||m.forEach((h,g)=>{if(p.has(g)){p.delete(g);return}const B=t.get(g);B&&(B.t.delete(l),E(g,B)&&D(g))}),p.forEach(h=>{const g=t.get(h);g?g.t.add(l):t.has(l)&&C(h,l)})},N=()=>{let l;for((x?"production":void 0)!=="production"&&(l=new Set);o.size;){const f=Array.from(o);o.clear(),f.forEach(([m,p])=>{const h=c(m);if(h){h.d!==(p==null?void 0:p.d)&&M(m,h,p==null?void 0:p.d);const g=t.get(m);g&&!(p&&!H(p)&&(z(p,h)||ve(p,h)))&&(g.l.forEach(B=>B()),(x?"production":void 0)!=="production"&&l.add(m))}else(x?"production":void 0)!=="production"&&console.warn("[Bug] no atom state to flush")})}if((x?"production":void 0)!=="production")return n.forEach(f=>f("state")),l},R=(l,f)=>{const m=v(l),p=N(),h=m.l;return h.add(f),(x?"production":void 0)!=="production"&&(n.forEach(g=>g("sub")),s.forEach(g=>g({type:"sub",flushed:p}))),()=>{h.delete(f),I(l),(x?"production":void 0)!=="production"&&(n.forEach(g=>g("unsub")),s.forEach(g=>g({type:"unsub"})))}};return(x?"production":void 0)!=="production"?{get:V,set:w,sub:R,dev_subscribe_store:(l,f)=>f!==2?(console.warn("The current StoreListener revision is 2. The older ones are deprecated."),n.add(l),()=>{n.delete(l)}):(s.add(l),()=>{s.delete(l)}),dev_get_mounted_atoms:()=>r.values(),dev_get_atom_state:l=>e.get(l),dev_get_mounted:l=>t.get(l),dev_restore_atoms:l=>{for(const[m,p]of l)te(m)&&(k(m,p),U(m));const f=N();s.forEach(m=>m({type:"restore",flushed:f}))}}:{get:V,set:w,sub:R}};let ne;const nt=()=>(ne||(ne=Se()),ne);var ce={VITE_OPENAI_API_KEY:"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",VITE_UNSPASH_ACCESS_KEY:"XgYBCm-XCHecRMsbfhw6oZWGkltco1U5TYMEd0LXZeA",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const Ee=Symbol(),be=(e,t,o)=>(t.has(o)?t:t.set(o,e())).get(o),st=new WeakMap,rt=(e,t,o)=>{const n=be(()=>new WeakMap,st,t);return be(e,n,o)},ct={},Ae=e=>!!e.write,lt=e=>typeof e=="function";function it(e,t){return rt(()=>{const o=new WeakMap,n=(c,a)=>{let d=o.get(c);if(d)return d;const i=a&&o.get(a),k=[],O=[];return c.forEach((F,V)=>{const v=t?t(F):V;O[V]=v;const E=i&&i.atomList[i.keyList.indexOf(v)];if(E){k[V]=E;return}const I=y=>{const w=y(s),C=y(e),M=n(C,w==null?void 0:w.arr).keyList.indexOf(v);if(M<0||M>=C.length){const N=c[n(c).keyList.indexOf(v)];if(N)return N;throw new Error("splitAtom: index out of bounds for read")}return C[M]},U=(y,w,C)=>{const D=y(s),M=y(e),R=n(M,D==null?void 0:D.arr).keyList.indexOf(v);if(R<0||R>=M.length)throw new Error("splitAtom: index out of bounds for write");const l=lt(C)?C(M[R]):C;w(e,[...M.slice(0,R),l,...M.slice(R+1)])};k[V]=Ae(e)?T(I,U):T(I)}),i&&i.keyList.length===O.length&&i.keyList.every((F,V)=>F===O[V])?d=i:d={arr:c,atomList:k,keyList:O},o.set(c,d),d},s=T(c=>{const a=c(s),d=c(e);return n(d,a==null?void 0:a.arr)});(ce?"production":void 0)!=="production"&&(s.debugPrivate=!0),s.init=void 0;const r=Ae(e)?T(c=>c(s).atomList,(c,a,d)=>{switch(d.type){case"remove":{const i=c(r).indexOf(d.atom);if(i>=0){const k=c(e);a(e,[...k.slice(0,i),...k.slice(i+1)])}break}case"insert":{const i=d.before?c(r).indexOf(d.before):c(r).length;if(i>=0){const k=c(e);a(e,[...k.slice(0,i),d.value,...k.slice(i)])}break}case"move":{const i=c(r).indexOf(d.atom),k=d.before?c(r).indexOf(d.before):c(r).length;if(i>=0&&k>=0){const O=c(e);i<k?a(e,[...O.slice(0,i),...O.slice(i+1,k),O[i],...O.slice(k)]):a(e,[...O.slice(0,k),O[i],...O.slice(k,i),...O.slice(i+1)])}break}}}):T(c=>c(s).atomList);return r},e,t||ct)}function ut(e){const t=Symbol(),o=T(t);(ce?"production":void 0)!=="production"&&(o.debugPrivate=!0);const n=T((s,r)=>{const c=s(o);return c!==t?c:e(s,r)},(s,r,c)=>{if(c===Ee)r(o,t);else if(typeof c=="function"){const a=s(n);r(o,c(a))}else r(o,c)});return n}const at=e=>typeof(e==null?void 0:e.then)=="function";function dt(e){let t,o;const n={getItem:(s,r)=>{var c,a;const d=k=>{if(k=k||"",t!==k){try{o=JSON.parse(k)}catch{return r}t=k}return o},i=(a=(c=e())==null?void 0:c.getItem(s))!=null?a:null;return at(i)?i.then(d):d(i)},setItem:(s,r)=>{var c;return(c=e())==null?void 0:c.setItem(s,JSON.stringify(r))},removeItem:s=>{var r;return(r=e())==null?void 0:r.removeItem(s)}};return typeof window<"u"&&typeof window.addEventListener=="function"&&(n.subscribe=(s,r,c)=>{if(!(e()instanceof window.Storage))return()=>{};const a=d=>{if(d.storageArea===e()&&d.key===s){let i;try{i=JSON.parse(d.newValue||"")}catch{i=c}r(i)}};return window.addEventListener("storage",a),()=>{window.removeEventListener("storage",a)}}),n}const ft=dt(()=>typeof window<"u"?window.localStorage:void 0);function we(e,t,o=ft,n){const s=n==null?void 0:n.unstable_getOnInit,r=T(s?o.getItem(e,t):t);return(ce?"production":void 0)!=="production"&&(r.debugPrivate=!0),r.onMount=a=>{s||a(o.getItem(e,t));let d;return o.subscribe&&(d=o.subscribe(e,a,t)),d},T(a=>a(r),(a,d,i)=>{const k=typeof i=="function"?i(a(r)):i;return k===Ee?(d(r,t),o.removeItem(e)):k instanceof Promise?k.then(O=>(d(r,O),o.setItem(e,O))):(d(r,k),o.setItem(e,k))})}var pt={VITE_OPENAI_API_KEY:"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",VITE_UNSPASH_ACCESS_KEY:"XgYBCm-XCHecRMsbfhw6oZWGkltco1U5TYMEd0LXZeA",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const gt=P.createContext(void 0),le=e=>{const t=P.useContext(gt);return(e==null?void 0:e.store)||t||nt()},mt=e=>typeof(e==null?void 0:e.then)=="function",ht=P.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)});function ye(e,t){const o=le(t),[[n,s,r],c]=P.useReducer(i=>{const k=o.get(e);return Object.is(i[0],k)&&i[1]===o&&i[2]===e?i:[k,o,e]},void 0,()=>[o.get(e),o,e]);let a=n;(s!==o||r!==e)&&(c(),a=o.get(e));const d=t==null?void 0:t.delay;return P.useEffect(()=>{const i=o.sub(e,()=>{if(typeof d=="number"){setTimeout(c,d);return}c()});return c(),i},[o,e,d]),P.useDebugValue(a),mt(a)?ht(a):a}function Pe(e,t){const o=le(t);return P.useCallback((...s)=>{if((pt?"production":void 0)!=="production"&&!("write"in e))throw new Error("not writable atom");return o.set(e,...s)},[o,e])}function J(e,t){return[ye(e,t),Pe(e,t)]}function Le(e,t,o){const n=u.filter(e,r=>r._parent===t),s=[];for(let r=0;r<n.length;r++){const c=Ie(n[r]);if(Object.keys(c).length>0&&Object.keys(c).forEach(a=>{n[r][a]=`slot:${$.generateUUID()}`}),u.filter(e,{_parent:n[r]._id}).length>0){const a=$.generateUUID();s.push({...n[r],oldId:n[r]._id,_id:a,_parent:o}),s.push(u.flatten(Le(e,n[r]._id,a)))}else s.push({...n[r],oldId:n[r]._id,_id:$.generateUUID(),_parent:o})}return u.flatten(s)}function Ce(e){const t={};e.forEach(n=>{t[n._id]={...n,children:[]}});const o=[];return e.forEach(n=>{if(n._parent){const s=t[n._parent];s&&s.children.push(t[n._id])}else o.push(t[n._id])}),o}const Ie=e=>{const t={};return Object.keys(e).forEach(o=>{u.isString(e[o])&&e[o].startsWith("slot")&&(t[o]=e[o].replace("slot:",""))}),t},kt=(e,t,o=null)=>{let n=u.find(e,{_id:t});n={...n,oldId:n._id,_id:$.generateUUID()},o&&(n={...n,_parent:o});const s=[n];u.filter(e,{_parent:t}).length>0&&s.push(u.flatten(Le(e,t,n._id)));const r=u.flatten(s);return u.map(r,c=>{const a=c,d=Ie(a);return Object.keys(d).length>0&&Object.keys(d).forEach(i=>{const k=u.find(r,{oldId:d[i].replace("slot:","")});a[i]=`slot:${k._id}`}),u.omit(a,["global","oldId"])})},Y=b.atom([]);Y.debugLabel="presentBlocksAtom";const Oe=b.atom(e=>{const t=e(Y);return Ce([...t])});Oe.debugLabel="treeDSBlocks";Y.debugLabel="presentBlocksAtom";const Me=it(Y);Me.debugLabel="pageBlocksAtomsAtom";const Bt=b.atom("");Bt.debugLabel="builderActivePageAtom";const vt=b.atom(-1);vt.debugLabel="destinationDropIndexAtom";const xe=b.atom([]);xe.debugLabel="buildingBlocksAtom";const bt=b.atom(e=>{const t=e(xe);return u.filter(t,o=>u.has(o,"blockId"))});bt.debugLabel="globalBlocksAtom";const ie=b.atom([]);ie.debugLabel="selectedBlockIdsAtom";const ue=b.atom(e=>{const t=e(Y),o=e(ie);return u.map(u.filter(t,({_id:n})=>u.includes(o,n)),n=>({...n}))});ue.debugLabel="selectedBlocksAtom";const Q=b.atom(e=>{const t=e(ue);if(t.length===0)return null;if(t.length===1)return t[0]});Q.debugLabel="selectedBlockAtom";const At=e=>u.get(e,"_parent",null),_t=b.atom(e=>{const t=e(ue),o=u.map(t,At);return u.filter(e(Y),n=>u.includes(o,n._id))});_t.debugLabel="selectedBlocksParentsAtom";const De=b.atom(()=>!1);De.debugLabel="selectedBlockFlexChildAtom";const Ue=b.atom(()=>!1);Ue.debugLabel="selectedBlockGridChildAtom";const Re=b.atom("");Re.debugLabel="styleStateAtom";const Te=we("styleBreakpoint","xs");Te.debugLabel="styleBreakpointAtom";const St=()=>({flexChild:b.useAtomValue(De),gridChild:b.useAtomValue(Ue)}),Et=()=>b.useAtomValue(Q),wt=b.atom(e=>{const t=e(Q),o=e(Y);let n=t;const s=[t];do{const r=o.find(({_id:c})=>c===(n==null?void 0:n._parent));n=r,r&&s.push(r)}while(n!=null&&n._parent);return s}),yt=()=>u.compact(b.useAtomValue(wt)),Fe=()=>{const[e,t]=b.useAtom(ie),o=P.useCallback(n=>{t(s=>u.includes(s,n)?u.without(s,n):[...s,n])},[t]);return[e,t,o]};var Ve={exports:{}};(function(e){(function(){function t(n,s,r){return n.splice(s,!r||1+r-s+(!(r<0^s>=0)&&(r<0||-1)*n.length)),n.length}let o=function(){let n=[],s=-1,r=0,c=!1,a;function d(i,k){return!i||typeof i[k]!="function"?this:(c=!0,i[k](),c=!1,this)}return{add:function(i){return c?this:(n.splice(s+1,n.length-s),n.push(i),r&&n.length>r&&t(n,0,-(r+1)),s=n.length-1,a&&a(),this)},setCallback:function(i){a=i},undo:function(){let i=n[s];if(!i)return this;const k=i.groupId;for(;i.groupId===k&&(d(i,"undo"),s-=1,i=n[s],!(!i||!i.groupId)););return a&&a(),this},redo:function(){let i=n[s+1];if(!i)return this;const k=i.groupId;for(;i.groupId===k&&(d(i,"redo"),s+=1,i=n[s+1],!(!i||!i.groupId)););return a&&a(),this},clear:function(){let i=n.length;n=[],s=-1,a&&i>0&&a()},hasUndo:function(){return s!==-1},hasRedo:function(){return s<n.length-1},getCommands:function(i){return i?n.filter(k=>k.groupId===i):n},getIndex:function(){return s},setLimit:function(i){r=i}}};e.exports?e.exports=o:window.UndoManager=o})()})(Ve);var Pt=Ve.exports;const Lt=Ze.getDefaultExportFromCjs(Pt),Ct=["hover","focus","focus-within","focus-visible","active","visited","target","first","last","only","odd","even","first-of-type","last-of-type","only-of-type","empty","disabled","checked","indeterminate","default","required","valid","invalid","in-range","out-of-range","placeholder-shown","autofill","read-only","open","before","after","first-letter","first-line","marker","selection","file","placeholder","hs-collapse-open","hs-accordion-active"],se={bodyFont:"Inter",headingFont:"Inter",roundedCorners:5,primaryColor:"#570df8",secondaryColor:"#f002b8",bodyBgDarkColor:"#031022",bodyBgLightColor:"#fcfcfc",bodyTextDarkColor:"#ffffff",bodyTextLightColor:"#000000"},It=b.atom(se),Ot=b.atom(null),ae=()=>{const[e,t]=b.useAtom(It);return[u.isObject(e)?{...se,...e}:se,t]},Mt=()=>b.useAtom(Ot),xt=b.atom(null),Ne=()=>({currentPage:b.useAtomValue(xt)});function je(e){return Ce(e)}const de=(e,t)=>u.flatten(e.map(o=>{if(o=t?{...o,_parent:t}:{...o},o.children){const n=[...o.children];return delete o.children,u.flatten([o,...de(n,o._id)])}return o}));function fe(e,t=!1){for(let o=0;o<e.length;o++){const n=e[o];n.global&&!t?e[o]={type:"GlobalBlock",blockId:n.blockId,_parent:u.get(n,"_parent",null),_id:n._id}:n.children&&n.children.length&&fe(n.children)}}function Ge(e){let t=[],o=u.filter(e,{type:"GlobalBlock"});return o.length>0&&(o=u.map(o,Ye),u.each(o,n=>{t=[...t,...Dt(n)]})),t}function Dt(e){let t=[];const o=u.get(u.first(e),"_parent",null);u.set(u.first(e),"_parent",null);const n=[flatToNestedInstance.convert(We(e))];fe(n,!0);let s=de(n,e[0]._id);return s=u.set(s,"0._parent",o),t=[...t,s,...Ge(s)],t}function Ye(e){const t=u.find(re,{_id:e._id});if(!t)return[];const o=[t],n=u.filter(re,{_parent:e._id});return n.length?u.flatten([...o,...u.flatten(u.map(n,Ye))]):u.flatten(o)}const We=e=>JSON.parse(JSON.stringify(e));let re=[];function Ut(e){re=e;const t=je(We(e));fe(t);const o=de(t,null),n=Ge(o),s={};return u.each(n,r=>u.set(s,u.first(r).blockId,r)),[o,s]}const Rt=()=>{const[e]=ae(),{currentPage:t}=Ne(),[o]=q();return P.useCallback(()=>{const n=u.map(o,r=>u.omit(r,["expanded","order","title","siblings","tempClasses"])),[s=[]]=Ut(n);return{currentPage:t,blocks:s}},[e,t,o])},pe=b.atom(null);pe.debugLabel="chaiBuilderPropsAtom";const He=b.atom({});He.debugLabel="chaiExternalDataAtom";const X=(e,t=void 0)=>{const o=b.useAtomValue(pe);return u.get(o,e,t)},ge=b.atom([]);ge.debugLabel="dataProvidersAtom";const Xe=()=>b.useAtom(ge),ee=b.atom("SAVED");ee.debugLabel="builderSaveStateAtom";const Tt=()=>{const[e,t]=b.useAtom(ee),o=X("onSave",async d=>{}),n=X("onSaveStateChange",u.noop),s=Rt(),[r]=Xe(),[c]=ae();return{savePage:$e.useThrottledCallback(async()=>{t("SAVING"),n("SAVING");const d=s();return await o({blocks:d.blocks,providers:r,brandingOptions:c,themeConfiguration:c}),setTimeout(()=>{t("SAVED"),n("SAVED")},100),!0},[s,t,c,o,n],3e3),saveState:e,setSaveState:t}},G=new Lt;G.setLimit(50);const qe=()=>{const[,e]=b.useAtom(ee),t=X("onSaveStateChange",u.noop);return P.useEffect(()=>(G.setCallback(()=>{e("UNSAVED"),t("UNSAVED")}),()=>{G.setCallback(u.noop)}),[]),{add:G.add,undo:G.undo,redo:G.redo,hasRedo:G.hasRedo,hasUndo:G.hasUndo,clear:G.clear}},me=(e,t)=>{const o=[],n=u.filter(e,s=>u.includes(t,s._id)||u.includes(t,s._parent)?(o.push(s._id),!1):!0);return u.isEmpty(o)?n:me(n,o)},Ft=()=>{const[e]=q(),[t,o]=Fe(),{setNewBlocks:n}=W();return P.useCallback(s=>{var c;const r=((c=u.find(e,{_id:s[0]}))==null?void 0:c._parent)||null;n(me(e,s)),setTimeout(()=>o(r?[r]:[]),200)},[e,o,t])};function Vt(e,t,o,n){let s=e.filter(a=>!a._parent);o&&(s=e.filter(a=>a._parent===o));const r=n!==void 0?n:s.length;let c=e.length;for(let a=0,d=0;a<e.length;a++)if(e[a]._parent===o){if(d===r){c=a;break}d++}return!o&&n!==void 0&&n>=s.length&&(c=e.length),[...e.slice(0,c),...t,...e.slice(c)]}function Nt(e){let t=[];return e.walk(o=>(delete o.model.children,t.push(o.model),!0)),t}function _e(e,t){return e.first(o=>o.model._id===t)||null}function jt(e,t,o,n){const s=_e(e,t),r=_e(e,o);if(s&&r){s.drop(),r.children||(r.model.children=[]);try{r.addChildAtIndex(s,n)}catch(c){return console.error("Error adding child to parent:",c),!1}return!0}return!1}function Gt(e,t,o,n){if(!t)return e;o=o||"root";const r=new Ke().parse({_id:"root",children:je(e)});if(jt(r,t,o,n)){const c=Nt(r),a=c.find(d=>d._id===t);return a&&(a._parent=o==="root"?null:o),c.shift(),c}return e}const Yt=()=>{const[,e]=q();return{setNewBlocks:t=>{e(t)},addBlocks:(t,o,n)=>{e(s=>Vt(s,t,o,n))},removeBlocks:t=>{e(o=>me(o,t))},moveBlocks:(t,o,n)=>{e(s=>{let r=s;for(let c=0;c<t.length;c++)r=Gt(r,t[c],o,n);return r})},updateBlocksProps:t=>{e(o=>{const n=t.map(s=>s._id);return o.map(s=>{if(n.includes(s._id)){const r=u.find(t,{_id:s._id});return{...s,...u.omit(r,"_id")}}return s})})}}},q=()=>b.useAtom(Y),W=()=>{const{add:e}=qe(),[t]=q(),{setNewBlocks:o,addBlocks:n,removeBlocks:s,moveBlocks:r,updateBlocksProps:c}=Yt();return{moveBlocks:(v,E,I)=>{const U=u.map(v,w=>{const D=t.find(R=>R._id===w)._parent||null,N=t.filter(R=>D?R._parent===D:!R._parent).map(R=>R._id).indexOf(w);return{_id:w,oldParent:D,oldPosition:N}}),y=U.find(({_id:w})=>w===v[0]);y&&y.oldParent===E&&y.oldPosition===I||(r(v,E,I),e({undo:()=>u.each(U,({_id:w,oldParent:C,oldPosition:D})=>{r([w],C,D)}),redo:()=>r(v,E,I)}))},addBlocks:(v,E,I)=>{n(v,E,I),e({undo:()=>s(u.map(v,"_id")),redo:()=>n(v,E,I)})},removeBlocks:v=>{var y;const E=(y=u.first(v))==null?void 0:y._parent,U=t.filter(w=>E?w._parent===E:!w._parent).indexOf(u.first(v));s(u.map(v,"_id")),e({undo:()=>n(v,E,U),redo:()=>s(u.map(v,"_id"))})},updateBlocks:(v,E,I)=>{let U=[];if(I)U=u.map(v,y=>({_id:y,...I}));else{const y=u.keys(E);U=u.map(v,w=>{const C=t.find(M=>M._id===w),D={_id:w};return u.each(y,M=>D[M]=C[M]),D})}c(u.map(v,y=>({_id:y,...E}))),e({undo:()=>c(U),redo:()=>c(u.map(v,y=>({_id:y,...E})))})},updateBlocksRuntime:(v,E)=>{c(u.map(v,I=>({_id:I,...E})))},setNewBlocks:v=>{o(v),e({undo:()=>o(t),redo:()=>o(v)})},updateMultipleBlocksProps:v=>{let E=[];E=u.map(v,I=>{const U=u.keys(I),y=t.find(C=>C._id===I._id),w={};return u.each(U,C=>w[C]=y[C]),w}),c(v),e({undo:()=>c(E),redo:()=>c(v)})}}},Wt=()=>{const{updateBlocks:e}=W();return P.useCallback((t,o,n)=>{e(t,o,n)},[e])},Ht=()=>{const{updateMultipleBlocksProps:e}=W();return P.useCallback(t=>{e(t)},[e])},Xt=()=>{const{updateBlocksRuntime:e}=W();return P.useCallback(async(t,o,n=30)=>{const s=u.keys(u.omit(o,["_id"]));for(const r of s){const c=o[r];if(u.isString(c)){const a=u.chunk(c.split(""),12);let d="";e([t],{[r]:""});for(let i=0;i<a.length;i++)d+=a[i].join(""),e([t],{[r]:d}),await new Promise(k=>setTimeout(k,n))}}},[e])},qt=()=>{const{updateMultipleBlocksProps:e}=W(),t=Xt();return P.useCallback(async o=>{for(const n of o)await t(n._id,n);e(o)},[e])},zt=()=>{const{updateBlocksRuntime:e}=W();return P.useCallback((t,o)=>{e(t,o)},[e])},ze=T({}),Jt=T({}),Zt=()=>{const[e,t]=J(ze),o=P.useCallback(s=>u.get(e,s==null?void 0:s.globalBlock,[]),[e]),n=P.useCallback(()=>{t({})},[t]);return{getGlobalBlocks:o,reset:n}},$t=()=>{const[e]=q(),[t,o]=J(ze),[n,s]=J(Jt),r=X("getGlobalBlockBlocks",async a=>[]),c=P.useMemo(()=>e.filter(d=>d._type==="GlobalBlock").filter(d=>d._type==="GlobalBlock").map(d=>d.globalBlock),[e]);P.useEffect(()=>{u.forEach(c,a=>{u.has(t,a)||u.get(n,`${a}.loading`,!1)||(s(d=>({...d,[a]:{loading:!0,error:null}})),r(a).then(d=>{o(i=>({...i,[a]:d})),s(i=>({...i,[a]:{loading:!1,error:null}}))}).catch(d=>{s(i=>({...i,[a]:{loading:!1,error:d.message}}))}))})},[r,t,c,n,o,s])},Kt=T({}),Qt=()=>{const[e,t]=P.useState(!1),[o,n]=J(Kt),s=X("getGlobalBlocks",async()=>[]),r=P.useCallback(async()=>{t(!0);const c=await s();n(c),t(!1)},[s,n]);return P.useEffect(()=>{r()},[]),{data:o,isLoading:e,refetch:r}};exports.MODIFIERS=Ct;exports.atom=T;exports.atomWithDefault=ut;exports.atomWithStorage=we;exports.builderSaveStateAtom=ee;exports.chaiBuilderPropsAtom=pe;exports.chaiExternalDataAtom=He;exports.createStore=Se;exports.dataProvidersAtom=ge;exports.getDuplicatedBlocks=kt;exports.pageBlocksAtomsAtom=Me;exports.presentBlocksAtom=Y;exports.selectedBlockAtom=Q;exports.styleBreakpointAtom=Te;exports.styleStateAtom=Re;exports.treeDSBlocks=Oe;exports.useAtom=J;exports.useAtomValue=ye;exports.useBlocksContainer=Mt;exports.useBlocksStore=q;exports.useBlocksStoreUndoableActions=W;exports.useBrandingOptions=ae;exports.useBuilderProp=X;exports.useCurrentPage=Ne;exports.useGlobalBlocksList=Qt;exports.useGlobalBlocksStore=Zt;exports.usePageDataProviders=Xe;exports.useRemoveBlocks=Ft;exports.useSavePage=Tt;exports.useSelectedBlock=Et;exports.useSelectedBlockHierarchy=yt;exports.useSelectedBlockIds=Fe;exports.useSelectedBlocksDisplayChild=St;exports.useSetAtom=Pe;exports.useStore=le;exports.useStreamMultipleBlocksProps=qt;exports.useUndoManager=qe;exports.useUpdateBlocksProps=Wt;exports.useUpdateBlocksPropsRealtime=zt;exports.useUpdateMultipleBlocksProps=Ht;exports.useWatchGlobalBlocks=$t;