@chaibuilder/sdk 0.1.3 → 0.1.5

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 (81) hide show
  1. package/dist/{AddBlocks-c195f577.js → AddBlocks-5d928d58.js} +20 -19
  2. package/dist/AddBlocks-df0ea47a.cjs +3 -0
  3. package/dist/BrandingOptions-b76762a4.cjs +1 -0
  4. package/dist/{BrandingOptions-766c19c6.js → BrandingOptions-bf7e6a38.js} +11 -9
  5. package/dist/{CanvasArea-25800a3e.js → CanvasArea-688987d1.js} +226 -224
  6. package/dist/{CanvasArea-e855c4a2.cjs → CanvasArea-9287e1bd.cjs} +2 -2
  7. package/dist/{Class-e34b2337.js → Class-1fb4c0c4.js} +110 -169
  8. package/dist/Class-6c695ccb.cjs +1 -0
  9. package/dist/Layers-11b26a20.cjs +1 -0
  10. package/dist/{Layers-f7e792f6.js → Layers-c053dfb8.js} +12 -10
  11. package/dist/MODIFIERS-70fef873.cjs +1 -0
  12. package/dist/MODIFIERS-c2e02614.js +67 -0
  13. package/dist/{MarkAsGlobalBlock-6bac1842.js → MarkAsGlobalBlock-111d739d.js} +10 -8
  14. package/dist/MarkAsGlobalBlock-4c85ba27.cjs +1 -0
  15. package/dist/{PagesPanel-0827c264.js → PagesPanel-48d0f29b.js} +12 -10
  16. package/dist/PagesPanel-97dbe8c3.cjs +1 -0
  17. package/dist/ProjectPanel-24543eac.cjs +1 -0
  18. package/dist/{ProjectPanel-e577029a.js → ProjectPanel-e19b9778.js} +10 -11
  19. package/dist/Settings-0358ce2f.cjs +1 -0
  20. package/dist/{Settings-b214f859.js → Settings-f4118350.js} +7 -5
  21. package/dist/{SidePanels-03fa10e8.js → SidePanels-73e79a7d.js} +8 -6
  22. package/dist/SidePanels-e48c2ba6.cjs +1 -0
  23. package/dist/Topbar-26d18e9d.cjs +1 -0
  24. package/dist/{Topbar-9bc8c9cf.js → Topbar-5574394f.js} +7 -5
  25. package/dist/add-page-modal-61d5bad7.js +93 -0
  26. package/dist/add-page-modal-6a60b790.cjs +1 -0
  27. package/dist/core.cjs +1 -1
  28. package/dist/core.d.ts +13 -11
  29. package/dist/core.js +63 -61
  30. package/dist/{delete-page-modal-def9012d.js → delete-page-modal-62641e4c.js} +10 -9
  31. package/dist/delete-page-modal-ecdd890a.cjs +1 -0
  32. package/dist/html-to-json-01cc5fe0.cjs +1 -0
  33. package/dist/{html-to-json-9304dbda.js → html-to-json-d20aafdd.js} +2 -2
  34. package/dist/index-89fce4e7.cjs +2 -0
  35. package/dist/index-de0f72ce.js +4911 -0
  36. package/dist/lib.cjs +1 -1
  37. package/dist/lib.js +4 -4
  38. package/dist/{page-viewer-41cbb548.js → page-viewer-14a69dba.js} +21 -18
  39. package/dist/page-viewer-e8469cfa.cjs +1 -0
  40. package/dist/{project-general-setting-2c8bed74.cjs → project-general-setting-decde8d1.cjs} +1 -1
  41. package/dist/{project-general-setting-0262fe62.js → project-general-setting-f7cfce70.js} +7 -5
  42. package/dist/render.cjs +2 -2
  43. package/dist/render.d.ts +9 -3
  44. package/dist/render.js +154 -134
  45. package/dist/server.cjs +1 -0
  46. package/dist/server.d.ts +142 -0
  47. package/dist/server.js +126 -0
  48. package/dist/{single-page-detail-924d57fc.js → single-page-detail-16682af2.js} +45 -43
  49. package/dist/single-page-detail-60edc711.cjs +1 -0
  50. package/dist/style.css +1 -1
  51. package/dist/useChangePage-5a62d7fc.cjs +1 -0
  52. package/dist/useChangePage-6b957e49.js +12 -0
  53. package/dist/usePageActions-32ea32a5.cjs +1 -0
  54. package/dist/usePageActions-37599b0c.js +38 -0
  55. package/package.json +7 -1
  56. package/dist/AddBlocks-0916e841.cjs +0 -3
  57. package/dist/BrandingOptions-742992b6.cjs +0 -1
  58. package/dist/CONTROLS-031e1de3.cjs +0 -1
  59. package/dist/CONTROLS-442caee5.js +0 -6
  60. package/dist/Class-7d6aadbc.cjs +0 -1
  61. package/dist/Layers-a2169d0b.cjs +0 -1
  62. package/dist/MarkAsGlobalBlock-6187e6fd.cjs +0 -1
  63. package/dist/PagesPanel-5698953d.cjs +0 -1
  64. package/dist/ProjectPanel-a3cb7396.cjs +0 -1
  65. package/dist/Settings-bee21026.cjs +0 -1
  66. package/dist/SidePanels-934159a4.cjs +0 -1
  67. package/dist/Topbar-c083cc2a.cjs +0 -1
  68. package/dist/add-page-modal-63858244.js +0 -92
  69. package/dist/add-page-modal-cb367c9d.cjs +0 -1
  70. package/dist/delete-page-modal-1e3914e3.cjs +0 -1
  71. package/dist/html-to-json-9c9961da.cjs +0 -1
  72. package/dist/index-207f2cbf.cjs +0 -2
  73. package/dist/index-390f7bef.js +0 -4749
  74. package/dist/index-824a7bd0.js +0 -188
  75. package/dist/index-ebd86d7f.cjs +0 -2
  76. package/dist/page-viewer-83ce2c70.cjs +0 -1
  77. package/dist/single-page-detail-cfeae896.cjs +0 -1
  78. package/dist/usePageActions-3bed2330.cjs +0 -1
  79. package/dist/usePageActions-f86f6f65.js +0 -36
  80. package/dist/useProjectActions-1de05f63.js +0 -17
  81. package/dist/useProjectActions-5092ed79.cjs +0 -1
@@ -0,0 +1,2 @@
1
+ "use strict";var Ks=(e,t,s)=>{if(!t.has(e))throw TypeError("Cannot "+s)};var a=(e,t,s)=>(Ks(e,t,"read from private field"),s?s.call(e):t.get(e)),I=(e,t,s)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,s)},A=(e,t,s,n)=>(Ks(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s);var ps=(e,t,s,n)=>({set _(r){A(e,t,r,s)},get _(){return a(e,t,n)}}),K=(e,t,s)=>(Ks(e,t,"access private method"),s);const k=require("./jsx-runtime-5c3ac4f7.cjs"),wo=require("i18next"),So=require("react-i18next"),Eo=require("flagged"),L=require("react"),ko=require("react-dnd"),d=require("lodash"),qn=require("@minoru/react-dnd-treeview"),ve=require("./useBuilderProp-5e57d0c8.cjs"),y=require("jotai"),Ao=require("./utils-3c452dd0.cjs"),_e=require("react-hotkeys-hook"),Kr=require("flat-to-nested"),fe=require("./Class-6c695ccb.cjs"),Vt=require("redux-undo"),Po=require("@react-hookz/web"),ue=require("./MODIFIERS-70fef873.cjs"),zr=require("@chaibuilder/blocks"),$n=require("@radix-ui/react-icons"),jo=require("lucide-react"),Co=require("sonner");function Oo(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const re=Oo(L),Ro="Dark mode",Bo="This page has no blocks. Add a block by clicking the + button",_o="This page is empty",Io="Please select a block to edit settings or styles",Do="Please select a styling block",Mo="Drop your block here",Lo={dark_mode:Ro,tree_view_no_blocks:Bo,canvas_empty:_o,no_block_selected_for_styling:Io,no_styling_block_selected:Do,drop_here_message:Mo};wo.use(So.initReactI18next).init({resources:{en:{translation:Lo}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});const No="";const To={};class Hr extends L.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return console.error(t),{hasError:!0}}render(){return this.state.hasError?k.jsxRuntimeExports.jsx("h1",{children:"Something went wrong."}):this.props.children}}const Uo=e=>{const t=e.replace(ue.STYLES_KEY,"").split(",");return{baseClasses:t[0],classes:t[1]}};let Fo=0;function Me(e,t){const s=`atom${++Fo}`,n={toString:()=>s};return typeof e=="function"?n.read=e:(n.init=e,n.read=r=>r(n),n.write=(r,i,o)=>i(n,typeof o=="function"?o(r(n)):o)),t&&(n.write=t),n}const Vn=e=>"init"in e,Qn=e=>!!e.write,Ps=new WeakMap,qo=(e,t)=>{Ps.set(e,t),e.catch(()=>{}).finally(()=>Ps.delete(e))},Kn=(e,t)=>{const s=Ps.get(e);s&&(Ps.delete(e),s(t))},zn=(e,t)=>{e.status="fulfilled",e.value=t},Hn=(e,t)=>{e.status="rejected",e.reason=t},$o=e=>typeof(e==null?void 0:e.then)=="function",Ft=(e,t)=>"v"in e&&"v"in t&&Object.is(e.v,t.v),Gn=(e,t)=>"e"in e&&"e"in t&&Object.is(e.e,t.e),ct=e=>"v"in e&&e.v instanceof Promise,Vo=(e,t)=>"v"in e&&"v"in t&&e.v.orig&&e.v.orig===t.v.orig,ms=e=>{if("e"in e)throw e.e;return e.v},Qo=()=>{const e=new WeakMap,t=new WeakMap,s=new Map;let n,r,i;const o=m=>e.get(m),u=(m,x)=>{const _=e.get(m);if(e.set(m,x),s.has(m)||s.set(m,_),_&&ct(_)){const w="v"in x?x.v instanceof Promise?x.v:Promise.resolve(x.v):Promise.reject(x.e);Kn(_.v,w)}},l=(m,x,_)=>{const w=new Map;let D=!1;_.forEach((O,S)=>{!O&&S===m&&(O=x),O&&(w.set(S,O),x.d.get(S)!==O&&(D=!0))}),(D||x.d.size!==w.size)&&(x.d=w)},c=(m,x,_)=>{const w=o(m),D={d:(w==null?void 0:w.d)||new Map,v:x};if(_&&l(m,D,_),w&&Ft(w,D)&&w.d===D.d)return w;if(w&&ct(w)&&ct(D)&&Vo(w,D)){if(w.d===D.d)return w;D.v=w.v}return u(m,D),D},h=(m,x,_,w)=>{if($o(x)){let D;const O=new Promise((S,z)=>{let Q=!1;x.then(W=>{if(!Q){Q=!0;const f=o(m),p=c(m,O,_);zn(O,W),S(W),(f==null?void 0:f.d)!==p.d&&q(m,p,f==null?void 0:f.d)}},W=>{if(!Q){Q=!0;const f=o(m),p=c(m,O,_);Hn(O,W),z(W),(f==null?void 0:f.d)!==p.d&&q(m,p,f==null?void 0:f.d)}}),D=W=>{Q||(Q=!0,W.then(f=>zn(O,f),f=>Hn(O,f)),S(W))}});return O.orig=x,O.status="pending",qo(O,S=>{S&&D(S),w==null||w()}),c(m,O,_)}return c(m,x,_)},g=(m,x,_)=>{const w=o(m),D={d:(w==null?void 0:w.d)||new Map,e:x};return _&&l(m,D,_),w&&Gn(w,D)&&w.d===D.d?w:(u(m,D),D)},P=m=>{const x=o(m);if(x&&(x.d.forEach((Q,W)=>{W!==m&&!t.has(W)&&P(W)}),Array.from(x.d).every(([Q,W])=>{const f=o(Q);return Q===m||f===W||f&&!ct(f)&&Ft(f,W)})))return x;const _=new Map;let w=!0;const D=Q=>{if(Q===m){const f=o(Q);if(f)return _.set(Q,f),ms(f);if(Vn(Q))return _.set(Q,void 0),Q.init;throw new Error("no atom init")}const W=P(Q);return _.set(Q,W),ms(W)};let O,S;const z={get signal(){return O||(O=new AbortController),O.signal},get setSelf(){return!S&&Qn(m)&&(S=(...Q)=>{if(!w)return M(m,...Q)}),S}};try{const Q=m.read(D,z);return h(m,Q,_,()=>O==null?void 0:O.abort())}catch(Q){return g(m,Q,_)}finally{w=!1}},v=m=>ms(P(m)),R=m=>{let x=t.get(m);return x||(x=E(m)),x},B=(m,x)=>!x.l.size&&(!x.t.size||x.t.size===1&&x.t.has(m)),b=m=>{const x=t.get(m);x&&B(m,x)&&j(m)},C=m=>{const x=new Map,_=new WeakMap,w=O=>{const S=t.get(O);S==null||S.t.forEach(z=>{z!==O&&(x.set(z,(x.get(z)||new Set).add(O)),_.set(z,(_.get(z)||0)+1),w(z))})};w(m);const D=O=>{const S=t.get(O);S==null||S.t.forEach(z=>{var Q;if(z!==O){let W=_.get(z);if(W&&_.set(z,--W),!W){let f=!!((Q=x.get(z))!=null&&Q.size);if(f){const p=o(z),T=P(z);f=!p||!Ft(p,T)}f||x.forEach(p=>p.delete(z))}D(z)}})};D(m)},U=(m,...x)=>{let _=!0;const w=S=>ms(P(S)),D=(S,...z)=>{let Q;if(S===m){if(!Vn(S))throw new Error("atom not writable");const W=o(S),f=h(S,z[0]);(!W||!Ft(W,f))&&C(S)}else Q=U(S,...z);if(!_){const W=F()}return Q},O=m.write(w,D,...x);return _=!1,O},M=(m,...x)=>{const _=U(m,...x),w=F();return _},E=(m,x)=>{const _={t:new Set(x&&[x]),l:new Set};if(t.set(m,_),P(m).d.forEach((w,D)=>{const O=t.get(D);O?O.t.add(m):D!==m&&E(D,m)}),P(m),Qn(m)&&m.onMount){const w=m.onMount((...D)=>M(m,...D));w&&(_.u=w)}return _},j=m=>{var x;const _=(x=t.get(m))==null?void 0:x.u;_&&_(),t.delete(m);const w=o(m);w&&(ct(w)&&Kn(w.v),w.d.forEach((D,O)=>{if(O!==m){const S=t.get(O);S&&(S.t.delete(m),B(O,S)&&j(O))}}))},q=(m,x,_)=>{const w=new Set(x.d.keys());_==null||_.forEach((D,O)=>{if(w.has(O)){w.delete(O);return}const S=t.get(O);S&&(S.t.delete(m),B(O,S)&&j(O))}),w.forEach(D=>{const O=t.get(D);O?O.t.add(m):t.has(m)&&E(D,m)})},F=()=>{let m;for(;s.size;){const x=Array.from(s);s.clear(),x.forEach(([_,w])=>{const D=o(_);if(D){D.d!==(w==null?void 0:w.d)&&q(_,D,w==null?void 0:w.d);const O=t.get(_);O&&!(w&&!ct(w)&&(Ft(w,D)||Gn(w,D)))&&O.l.forEach(S=>S())}})}};return{get:v,set:M,sub:(m,x)=>{const _=R(m),w=F(),D=_.l;return D.add(x),()=>{D.delete(x),b(m)}}}};let zs;const Ko=()=>(zs||(zs=Qo()),zs),zo=Symbol();function Ho(e,t){const s=Me(e,(n,r,i)=>r(s,t(n(s),i)));return s}const Wn=(e,t,s)=>(t.has(s)?t:t.set(s,e())).get(s),Go=new WeakMap,Wo=(e,t,s)=>{const n=Wn(()=>new WeakMap,Go,t);return Wn(e,n,s)},Yo={},Yn=e=>!!e.write,Jo=e=>typeof e=="function";function Zo(e,t){return Wo(()=>{const s=new WeakMap,n=(o,u)=>{let l=s.get(o);if(l)return l;const c=u&&s.get(u),h=[],g=[];return o.forEach((P,v)=>{const R=t?t(P):v;g[v]=R;const B=c&&c.atomList[c.keyList.indexOf(R)];if(B){h[v]=B;return}const b=U=>{const M=U(r),E=U(e),q=n(E,M==null?void 0:M.arr).keyList.indexOf(R);if(q<0||q>=E.length){const F=o[n(o).keyList.indexOf(R)];if(F)return F;throw new Error("splitAtom: index out of bounds for read")}return E[q]},C=(U,M,E)=>{const j=U(r),q=U(e),N=n(q,j==null?void 0:j.arr).keyList.indexOf(R);if(N<0||N>=q.length)throw new Error("splitAtom: index out of bounds for write");const m=Jo(E)?E(q[N]):E;M(e,[...q.slice(0,N),m,...q.slice(N+1)])};h[v]=Yn(e)?Me(b,C):Me(b)}),c&&c.keyList.length===g.length&&c.keyList.every((P,v)=>P===g[v])?l=c:l={arr:o,atomList:h,keyList:g},s.set(o,l),l},r=Me(o=>{const u=o(r),l=o(e);return n(l,u==null?void 0:u.arr)});r.init=void 0;const i=Yn(e)?Me(o=>o(r).atomList,(o,u,l)=>{switch(l.type){case"remove":{const c=o(i).indexOf(l.atom);if(c>=0){const h=o(e);u(e,[...h.slice(0,c),...h.slice(c+1)])}break}case"insert":{const c=l.before?o(i).indexOf(l.before):o(i).length;if(c>=0){const h=o(e);u(e,[...h.slice(0,c),l.value,...h.slice(c)])}break}case"move":{const c=o(i).indexOf(l.atom),h=l.before?o(i).indexOf(l.before):o(i).length;if(c>=0&&h>=0){const g=o(e);c<h?u(e,[...g.slice(0,c),...g.slice(c+1,h),g[c],...g.slice(h)]):u(e,[...g.slice(0,h),g[c],...g.slice(h,c),...g.slice(c+1)])}break}}}):Me(o=>o(r).atomList);return i},e,t||Yo)}const Xo=e=>typeof(e==null?void 0:e.then)=="function";function ea(e){let t,s;const n={getItem:(r,i)=>{var o,u;const l=h=>{if(h=h||"",t!==h){try{s=JSON.parse(h)}catch{return i}t=h}return s},c=(u=(o=e())==null?void 0:o.getItem(r))!=null?u:null;return Xo(c)?c.then(l):l(c)},setItem:(r,i)=>{var o;return(o=e())==null?void 0:o.setItem(r,JSON.stringify(i))},removeItem:r=>{var i;return(i=e())==null?void 0:i.removeItem(r)}};return typeof window<"u"&&typeof window.addEventListener=="function"&&(n.subscribe=(r,i,o)=>{if(!(e()instanceof window.Storage))return()=>{};const u=l=>{if(l.storageArea===e()&&l.key===r){let c;try{c=JSON.parse(l.newValue||"")}catch{c=o}i(c)}};return window.addEventListener("storage",u),()=>{window.removeEventListener("storage",u)}}),n}const ta=ea(()=>typeof window<"u"?window.localStorage:void 0);function at(e,t,s=ta,n){const r=n==null?void 0:n.unstable_getOnInit,i=Me(r?s.getItem(e,t):t);return i.onMount=u=>{r||u(s.getItem(e,t));let l;return s.subscribe&&(l=s.subscribe(e,u,t)),l},Me(u=>u(i),(u,l,c)=>{const h=typeof c=="function"?c(u(i)):c;return h===zo?(l(i,t),s.removeItem(e)):h instanceof Promise?h.then(g=>(l(i,g),s.setItem(e,g))):(l(i,h),s.setItem(e,h))})}const sa=L.createContext(void 0),Gr=e=>{const t=L.useContext(sa);return(e==null?void 0:e.store)||t||Ko()},na=e=>typeof(e==null?void 0:e.then)=="function",ra=L.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 ia(e,t){const s=Gr(t),[[n,r,i],o]=L.useReducer(c=>{const h=s.get(e);return Object.is(c[0],h)&&c[1]===s&&c[2]===e?c:[h,s,e]},void 0,()=>[s.get(e),s,e]);let u=n;(r!==s||i!==e)&&(o(),u=s.get(e));const l=t==null?void 0:t.delay;return L.useEffect(()=>{const c=s.sub(e,()=>{if(typeof l=="number"){setTimeout(o,l);return}o()});return o(),c},[s,e,l]),L.useDebugValue(u),na(u)?ra(u):u}function oa(e,t){const s=Gr(t);return L.useCallback((...r)=>s.set(e,...r),[s,e])}function aa(e,t){return[ia(e,t),oa(e,t)]}const ua=new Kr({children:"blockNodes"}),Wr=(e,t=null)=>d.flatten(e.map(s=>{if(s=t!==null?{...s,parent:t}:s,s.children&&s.children.length){const n=[...s.children];return delete s.children,d.flatten([s,...Wr(n,s._id)])}return s}));function Yr(e,t,s){const n=d.filter(e,i=>i._parent===t),r=[];for(let i=0;i<n.length;i++){const o=Jr(n[i]);if(Object.keys(o).length>0&&Object.keys(o).forEach(u=>{n[i][u]=`slot:${fe.generateUUID()}`}),d.filter(e,{_parent:n[i]._id}).length>0){const u=fe.generateUUID();r.push({...n[i],oldId:n[i]._id,_id:u,_parent:s}),r.push(d.flatten(Yr(e,n[i]._id,u)))}else r.push({...n[i],oldId:n[i]._id,_id:fe.generateUUID(),_parent:s})}return d.flatten(r)}function ca(e){let t=ua.convert(e.map(s=>d.omit(s,["settings"])));return t=!t.type&&t.blockNodes?t.blockNodes:d.isEmpty(t)?[]:[t],t}const Jr=e=>{const t={};return Object.keys(e).forEach(s=>{d.isString(e[s])&&e[s].startsWith("slot")&&(t[s]=e[s].replace("slot:",""))}),t},la=(e,t,s=null)=>{let n=d.find(e,{_id:t});n={...n,oldId:n._id,_id:fe.generateUUID()},s&&(n={...n,_parent:s});const r=[n];d.filter(e,{_parent:t}).length>0&&r.push(d.flatten(Yr(e,t,n._id)));const i=d.flatten(r);return d.map(i,o=>{const u=o,l=Jr(u);return Object.keys(l).length>0&&Object.keys(l).forEach(c=>{const h=d.find(i,{oldId:l[c].replace("slot:","")});u[c]=`slot:${h._id}`}),d.omit(u,["global","oldId"])})},da=Vt((e=[],t)=>{switch(t.type){case"add_new_blocks":case"add_duplicate_blocks":return[...e,...t.payload];case"create_snapshot":return[...e];case"set_blocks":case"set_page_blocks":return[...t.payload];case"update_props":case"update_props_realtime":const{payload:s}=t;return e.map(n=>(s.ids.includes(n._id)&&!d.isEmpty(t.payload.props)&&Object.keys(t.payload.props).forEach(r=>{d.set(n,r,t.payload.props[r])}),n));default:return e}},{debug:!1,ignoreInitialState:!1,limit:30,filter:Vt.excludeAction(["update_props_realtime","add_duplicate_blocks","set_page_blocks"])}),Is=Ho({past:[],present:[],future:[]},da);Is.debugLabel="pageBlocksAtom";const be=y.atom(e=>{var t;return(t=e(Is))==null?void 0:t.present});be.debugLabel="presentBlocksAtom";const yn=Zo(be);yn.debugLabel="pageBlocksAtomsAtom";const Zr=y.atom(e=>ca(e(be)));Zr.debugLabel="pageBlocksTreeAtom";const fa=y.atom("");fa.debugLabel="builderActivePageAtom";const ha=y.atom(-1);ha.debugLabel="destinationDropIndexAtom";const Xr=y.atom(!1);Xr.debugLabel="addBlocksModalAtom";const xe=()=>{const[,e]=y.useAtom(Is);return e},pa=()=>{const e=xe(),t=y.useAtomValue(Zr),s=L.useCallback(n=>{const r=Wr(n);e({type:"set_page_blocks",payload:r})},[e]);return[t,s]},ei=()=>{const e=xe();return[L.useCallback(s=>{e({type:"set_page_blocks",payload:s})},[e])]},Zs=e=>["Box","Slot","Form","DataContext","Link","List","ListItem","Row","Column","Table","TableCell"].includes(e),ma=e=>!["Slot"].includes(e),ga=e=>!["Slot"].includes(e);function ya(e,t){return e==="Slot"||t==="List"&&e!=="ListItem"||t==="Row"&&e!=="Column"?!1:Zs(t)}const va=(e,{dragSource:t,dropTarget:s})=>{const n=d.get(t,"data._type",""),r=d.get(s,"data._type","");return n==="Slot"||d.get(t,"id")&&d.get(t,"id")===d.get(s,"id")?!1:d.isEmpty(r)?!0:ya(n,r)},vn=y.atom([]);vn.debugLabel="selectedBlockIdsAtom";const bn=y.atom(e=>{const t=e(be),s=e(vn);return d.map(d.filter(t,({_id:n})=>d.includes(s,n)),n=>({...n}))});bn.debugLabel="selectedBlocksAtom";const xn=y.atom(e=>{const t=e(bn);return t.length===0?null:t.length===1?t[0]:{type:"Multiple",id:d.map(t,"id")}});xn.debugLabel="selectedBlockAtom";const ba=e=>d.get(e,"parent",null),xa=y.atom(e=>{const t=e(bn),s=d.map(t,ba);return d.filter(e(be),n=>d.includes(s,n._id))});xa.debugLabel="selectedBlocksParentsAtom";const ti=y.atom(()=>!1);ti.debugLabel="selectedBlockFlexChildAtom";const si=y.atom(()=>!1);si.debugLabel="selectedBlockGridChildAtom";const wn=y.atom("");wn.debugLabel="styleStateAtom";const ni=at("styleBreakpoint","xs");ni.debugLabel="styleBreakpointAtom";const wa=()=>({flexChild:y.useAtomValue(ti),gridChild:y.useAtomValue(si)}),Sa=()=>y.useAtomValue(xn),ze=()=>{const[e,t]=y.useAtom(vn),s=L.useCallback(n=>{t(r=>d.includes(r,n)?d.without(r,n):[...r,n])},[t]);return[e,t,s]},Xs=(e,t="")=>{switch(e.type){case"singular":return e.uiSchema;case"model":const{properties:s}=e,n={};return Object.keys(s).forEach(o=>{const u=s[o];if(d.includes(["slot","styles"],u.type))return;const l=d.get(u,"i18n",!1)?`${o}-${t}`:o;n[l]=Xs(u,t)}),n;case"list":const{itemProperties:r}=e,i={items:{}};return Object.keys(r).forEach(o=>{const u=r[o];if(d.includes(["slot","styles"],u.type))return;const l=d.get(u,"i18n",!1)?`${o}-${t}`:o;i.items[l]=Xs(u,t)}),i;default:return{}}},en=(e,t="")=>{switch(e.type){case"singular":return e.schema;case"model":const{properties:s,title:n}=e,r={title:n,type:"object",properties:{}};return Object.keys(s).forEach(l=>{const c=s[l];if(d.includes(["slot","styles"],c.type))return;const h=d.get(c,"i18n",!1)?`${l}-${t}`:l;r.properties[h]=en(c,t)}),r;case"list":const{itemProperties:i,title:o}=e,u={title:o,type:"array",items:{type:"object",properties:{}}};return Object.keys(i).forEach(l=>{const c=i[l];if(d.includes(["slot","styles"],c.type))return;const h=d.get(c,"i18n",!1)?`${l}-${t}`:l;u.items.properties[h]=en(c,t),d.set(u.items,"title",d.get(c,"itemTitle",`${o} item`))}),u;default:return{}}},ri=e=>{const t={};return Object.keys(e).forEach(s=>{t[s]=ka(e[s])}),t},Ea=e=>{if(d.isEmpty(e.default))return[];const{itemProperties:t}=e;return d.map(e.default,s=>{const n={...s};return d.forIn(s,(r,i)=>{d.has(t,i)&&d.get(t[i],"i18n",!1)&&(n[i]=ue.I18N_KEY)}),n})},ka=e=>{switch(e.type){case"styles":return e.default;case"slot":return`${ue.SLOT_KEY}${fe.generateUUID()}`;case"singular":const{i18n:t,schema:s}=e;return t?ue.I18N_KEY:d.get(s,"default","");case"model":return ri(e.properties);case"list":return Ea(e);default:return""}},ii=()=>y.useAtomValue(be);function Jn(e,t,s,n,r){if(t===null)return[...e,...n];if(s!==null){const l=d.findIndex(e,{_parent:t}),c=(l===-1?0:l)+s;return e.splice(c,0,...n),e}if(!r){const c=d.findIndex(e,{_id:t})+1;return e.splice(c,0,...n),e}let i=d.findIndex(e,{_id:t});const o=d.filter(e,{_parent:t});d.isEmpty(o)||(i=d.findIndex(e,{_id:d.last(o)._id}));const u=i+1;return e.splice(u,0,...n),e}const Aa=()=>{const e=xe(),t=ii(),[,s]=ze(),n=L.useCallback((i,o,u)=>{var h;for(let g=0;g<i.length;g++){const{_id:P}=i[g];i[g]._id=fe.generateUUID();const v=d.filter(i,{_parent:P});for(let R=0;R<v.length;R++)v[R]._parent=i[g]._id}let l;o&&(l=d.find(t,{_id:o}),i[0]._parent=o);const c=l?Zs(l._type):!0;return!c&&l&&(i[0]._parent=l._parent),e({type:"set_blocks",payload:Jn(t,o||null,u||null,i,c)}),s([(h=d.first(i))==null?void 0:h._id]),d.first(i)},[t,e,s]);return{addCoreBlock:L.useCallback((i,o,u)=>{if(d.has(i,"blocks")){const B=i.blocks;return n(B,o,u)}const l=fe.generateUUID(),c=ri(i.props),h=[];d.forIn(c,(B,b)=>{if(d.startsWith(B,ue.SLOT_KEY)){const C=B.replace(ue.SLOT_KEY,"");h.push({_id:C,_type:"Slot",_parent:l,_name:i.props[b].name,_styles:i.props[b].styles,_emptyStyles:i.props[b].emptyStyles})}});const g={_type:i.type,_id:l,...c};let P;o&&(P=d.find(t,{_id:o}),g._parent=o);const v=P?Zs(P._type):!0;!v&&P&&(g._parent=P._parent);const R=[g,...h];return e({type:"set_blocks",payload:Jn(t,o||null,u||null,R,v)}),s([g._id]),g},[n,t,e,s]),addPredefinedBlock:n}},Zn={xs:420,sm:620,md:768,lg:1024,xl:1280,"2xl":1536},Xn=["xs","sm","md","lg","xl","2xl"];function Pa(e,t){if(t===null)return"baseClasses";const s=t.mq;if(s==="xs"||t.dark||t.mod!=="")return"classes";let n="baseClasses",r=Xn.indexOf(s);for(;r>0;){const i=Xn[r-1];if(d.find(e,{mq:i,property:t.property})){n="classes";break}r--}return n}const er=[];function ja(e="",t="",s=[]){e=e.trim().replace(/ +/g,"");let n=d.filter(d.map(e.split(" "),fe.constructClassObject),c=>!d.isNull(c)),r=d.filter(d.map(t.split(" "),fe.constructClassObject),c=>!d.isNull(c));r=d.filter(r,c=>!d.includes(er,c.property));const i=[],o=[];d.each(s,c=>{const h=fe.constructClassObject(c),g=d.find(n,d.pick(h,["dark","mq","mod","property"]));if(g&&(n=d.filter(n,P=>P.fullCls!==(g==null?void 0:g.fullCls))),i.push(h),h.mq==="xs"&&!h.dark&&h.mod===""&&(r=d.filter(r,P=>P.property!==h.property)),Pa(n,h)==="baseClasses"&&!d.includes(er,h.property)){const P=d.find(r,d.pick(h,["property"]));g&&(r=d.filter(r,v=>v.fullCls!==(P==null?void 0:P.fullCls))),o.push({...h,fullCls:h.cls,mq:"xs"})}});const u=d.map(d.sortBy([...n,...i],c=>Zn[c.mq]),"fullCls").join(" ");return`${d.map(d.sortBy([...r,...o],c=>Zn[c.mq]),"fullCls").join(" ").trim()},${u.trim()}`.trim().replace(/ +/g,"")}const cs=y.atom([]);cs.debugLabel="selectedStylingBlocksAtom";const Sn=()=>y.useAtom(cs),Ca=e=>{const t=e.replace(ue.STYLES_KEY,"").split(",");return{baseClasses:t[0],classes:t[1]}},Oa=y.atom(null,(e,t,{blockIds:s,newClasses:n,dispatch:r})=>{const i=d.filter(e(yn),u=>s.includes(e(u)._id)),o=d.first(e(cs));d.each(i,u=>{const l=e(u),c=d.get(l,o.prop,`${ue.STYLES_KEY},`),{baseClasses:h,classes:g}=Ca(c);r({type:"update_props_realtime",payload:{ids:[l._id],props:{[o.prop]:`${ue.STYLES_KEY}${ja(g,h,n)}`}}})})}),Ra=()=>{const e=xe(),t=y.useSetAtom(Oa);return L.useCallback((s,n,r)=>{t({blockIds:s,newClasses:n,dispatch:e}),r&&setTimeout(()=>e({type:"create_snapshot"}),500)},[e,t])},oi=y.atom([]);oi.debugLabel="buildingBlocksAtom";const Ba=y.atom(e=>{const t=e(oi);return d.filter(t,s=>d.has(s,"blockId"))}),_a=()=>{},ai=()=>{const e=zr.useChaiBlocks(),t=y.useAtomValue(Ba),s=()=>{},n=L.useCallback(()=>_a(),[]);return[e,t,s,n]},Ia=y.atom(!1),En=()=>{const[e,t]=y.useAtom(Ia);return[e,t]},Da=y.atom(ue.BRANDING_OPTIONS_DEFAULTS),kn=()=>{const[e,t]=y.useAtom(Da);return[d.isObject(e)?{...e,...ue.BRANDING_OPTIONS_DEFAULTS}:ue.BRANDING_OPTIONS_DEFAULTS,t]},Ma=y.atom(null),ui=()=>({currentPage:y.useAtomValue(Ma)}),ci=new Kr({});function La(e){let t=ci.convert(e);return t=!t.type&&t.children&&t.children.length?t.children:d.isEmpty(t)?[]:[t],t}const An=(e,t)=>d.flatten(e.map(s=>{if(s=t?{...s,parent:t}:{...s},s.children){const n=[...s.children];return delete s.children,d.flatten([s,...An(n,s._id)])}return s}));function Pn(e,t=!1){for(let s=0;s<e.length;s++){const n=e[s];n.global&&!t?e[s]={type:"GlobalBlock",_parent:d.get(n,"parent",null),blockId:n.blockId,_id:n._id}:n.children&&n.children.length&&Pn(n.children)}}function li(e){let t=[],s=d.filter(e,{type:"GlobalBlock"});return s.length>0&&(s=d.map(s,di),d.each(s,n=>{t=[...t,...Na(n)]})),t}function Na(e){let t=[];const s=d.get(d.first(e),"parent",null);d.set(d.first(e),"parent",null);const n=[ci.convert(fi(e))];Pn(n,!0);let r=An(n,e[0]._id);return r=d.set(r,"0.parent",s),t=[...t,r,...li(r)],t}function di(e){const t=d.find(tn,{_id:e._id});if(!t)return[];const s=[t],n=d.filter(tn,{_parent:e._id});return n.length?d.flatten([...s,...d.flatten(d.map(n,di))]):d.flatten(s)}const fi=e=>JSON.parse(JSON.stringify(e));let tn=[];function Ta(e){tn=e;const t=La(fi(e));Pn(t);const s=An(t,null),n=li(s),r={};return d.each(n,i=>d.set(r,d.first(i).blockId,i)),[s,r]}const jn=()=>{const[e]=kn(),{currentPage:t}=ui(),s=y.useAtomValue(be);return L.useCallback(()=>{const n=d.map(s,o=>d.omit(o,["expanded","order","title","siblings","tempClasses"])),[r=[],i=[]]=Ta(n);return{currentPage:t,blocks:r,globalBlocks:i}},[e,t,s])};at("blockStylingActiveTab",1);y.atom([]);const hi=y.atom(!1);hi.debugLabel="readOnlyModeAtom";const pi=y.atom(!1);pi.debugLabel="inlineEditingActiveAtom";const mi=y.atom(!1);mi.debugLabel="advanceStylingOpenAtom";const gi=y.atom("online");gi.debugLabel="networkModeAtom";at("currentUiLibrary","");const Ua=y.atom(!1);Ua.debugLabel="codeEditorOpenAtom";const yi=y.atom(!1);yi.debugLabel="editLayerNameAtom";const Fa=y.atom("");Fa.debugLabel="activeLanguageAtom";const qa=y.atom("");qa.debugLabel="primaryLanguageAtom";const vi=y.atom(null);vi.debugLabel="canvasIframeAtom";const bi=y.atom("layers");bi.debugLabel="activePanelAtom";const xi=y.atom(!1);xi.debugLabel="addBlockOffCanvasAtom";const wi=y.atom("");wi.debugLabel="showPredefinedBlockCategoryAtom";const Ds=y.atom({undoCount:0,redoCount:0});Ds.debugLabel="historyStatesAtom";const Ms=y.atom("SAVED");Ms.debugLabel="pageSyncStateAtom";const $a=()=>{const[e,t]=y.useAtom(Ms),s=ve.useBuilderProp("onSaveBlocks",async()=>{}),n=ve.useBuilderProp("onSyncStatusChange",()=>{}),r=jn(),i=y.useSetAtom(Ds),{undoCount:o,redoCount:u}=ls();return{savePage:Po.useThrottledCallback(async()=>{t("SAVING"),n("SAVING");const c=r();return await s({blocks:c.blocks,identifier:"pageData.id"}),setTimeout(()=>{i({undoCount:o,redoCount:u}),t("SAVED"),n("SAVED")},100),!0},[r,t,n,s],5e3),syncState:e,setSyncState:t}},ls=()=>{const e=y.useAtomValue(Is),[{undoCount:t,redoCount:s}]=y.useAtom(Ds),n=xe(),[r]=En(),[,i]=ze(),[,o]=Sn(),[,u]=y.useAtom(Ms),l=ve.useBuilderProp("onSyncStatusChange",()=>{}),c=L.useCallback(()=>{n({type:"create_snapshot"})},[n]);return L.useEffect(()=>{t!==(e==null?void 0:e.past.length)||s!==(e==null?void 0:e.future.length)?(u("UNSAVED"),l("UNSAVED")):t===(e==null?void 0:e.past.length)&&s===(e==null?void 0:e.future.length)&&(u("SAVED"),l("SAVED"))},[e==null?void 0:e.past.length,e==null?void 0:e.future.length,t,s,l,u]),{undoCount:e==null?void 0:e.past.length,redoCount:e==null?void 0:e.future.length,undo:L.useCallback(()=>{r||(n(Vt.ActionCreators.undo()),setTimeout(()=>{o([]),i([])},200))},[n,r,u]),redo:L.useCallback(()=>{r||(n(Vt.ActionCreators.redo()),setTimeout(()=>{o([]),i([])},200))},[r,n]),clear:()=>{n(Vt.ActionCreators.clearHistory())},createSnapshot:c}},Si=()=>y.useAtom(ni),Ei=at("canvasWidth",360),ki=y.atom(e=>{const t=e(Ei);return fe.getBreakpointValue(t).toLowerCase()}),Va=()=>{const[e,t]=y.useAtom(Ei),s=y.useAtomValue(ki),[n,r]=Si();return L.useEffect(()=>{n!=="xs"&&r(s)},[s,n,r]),[e,s,t]},Qa=at("canvasZoom",100),Ka=()=>y.useAtom(Qa),Ai=y.atom([]),Cn=()=>{const[e,t]=y.useAtom(Ai),s=y.useSetAtom(On),n=L.useCallback(r=>{t(r),s([])},[t,s]);return[e,n]},On=y.atom([]),Pi=()=>{const[e,t]=y.useAtom(On),s=y.useSetAtom(Ai),n=L.useCallback(r=>{t(r),s([])},[t,s]);return[e,n]},ji=at("darkMode",!1),za=()=>{const[e,t]=y.useAtom(ji);return[e,t]},Ha=y.atom(!1),Ga=()=>{const[e,t]=y.useAtom(Ha);return[e,t]},Rn=()=>{const e=xe(),t=y.useAtomValue(be),[,s]=ze();return L.useCallback((n,r=null)=>{const i=[];d.each(n,o=>{const l=la(t,o,r===o?null:r);i.push(d.get(l,"0._id","")),e({type:"add_duplicate_blocks",payload:l})}),s(i),e({type:"create_snapshot"})},[t,s,e])},Wa=y.atom([]),Ya=()=>{const[e,t]=y.useAtom(Wa),s=L.useCallback(n=>{t(r=>d.includes(r,n)?d.without(r,n):[...r,n])},[t]);return[e,t,s]},Ja=y.atom(""),Ci=()=>y.useAtom(Ja),Za=()=>{const e=y.useAtomValue(be),t=xe(),s=jn(),[,,n]=ai();return L.useCallback(async(r,i)=>{const o=fe.generateUUID(16),u=d.map(e,l=>(l._id===r&&(l._globalBlockId=o,l._name=i),l));t({type:"set_page_blocks",payload:u}),n()},[e,t,s,n])},Xa=()=>({}),eu=()=>{const e=y.useAtomValue(be),t=xe();return L.useCallback((s,n)=>{const r=d.map(e,i=>(d.includes(s,d.get(i,"_id"))&&d.set(i,"_parent",n),i));t({type:"set_blocks",payload:r})},[e,t])},Oi=()=>{const e=y.useAtomValue(On),[t,s]=Cn(),n=Rn(),r=eu();return{canPaste:L.useMemo(()=>t.length>0||e.length>0,[e,t]),pasteBlocks:L.useCallback(o=>{d.isEmpty(e)?r(t,o):n(e,o),s(()=>[])},[t,e,n,r,s])}},tu=y.atom(""),su=()=>{const e=y.useAtomValue(tu),t=L.useCallback(()=>{},[]),s=L.useCallback(()=>{},[]),n=L.useCallback(()=>{},[]);return{currentProject:e,createProject:n,deleteProject:t,updateProject:s}},Ri=(e,t)=>{const s=[],n=d.filter(e,r=>d.includes(t,r._id)||d.includes(t,r._parent)?(s.push(r._id),!1):!0);return d.isEmpty(s)?n:Ri(n,s)},Bi=()=>{const e=xe(),t=y.useAtomValue(be),[s,n]=ze();return L.useCallback(r=>{var u;const i=((u=d.find(t,{_id:r[0]}))==null?void 0:u._parent)||null,o=Ri(t,r);e({type:"set_blocks",payload:o}),n(i?[i]:[])},[t,n,e,s])},nu=y.atom(null,(e,t,{blockIds:s,fullClasses:n,dispatch:r})=>{const i=d.first(e(cs)),o=d.filter(e(yn),u=>s.includes(e(u)._id));d.each(o,u=>{const l=e(u),c=n;let{classes:h,baseClasses:g}=Uo(d.get(l,i.prop,"styles:,"));d.each(c,P=>{const v=new RegExp(`(^| )${P.replace("[","\\[").replace("]","\\]")}($| )`,"g");h=h.replace(v," ").replace(/ +/g," ").trim();const R=d.first(P.split(":"));d.includes(["2xl","xl","lg","md","sm"],R)&&c.push(P.split(":").pop().trim())}),d.each(c,P=>{const v=new RegExp(`(^| )${P.replace("[","\\[").replace("]","\\]")}($| )`,"g");g=g.replace(v," ").replace(/ +/g," ").trim()}),r({type:"update_props_realtime",payload:{ids:[l._id],props:{[i.prop]:`${ue.STYLES_KEY}${g},${h}`}}})})}),ru=()=>{const e=xe(),t=y.useSetAtom(nu);return L.useCallback((s,n)=>{t({blockIds:s,fullClasses:n,dispatch:e}),setTimeout(()=>e({type:"create_snapshot"}))},[e,t])},_i=y.atom(e=>{const t=d.first(e(cs)),s=e(xn);if(!t||t.blockId!==d.get(s,"_id",null))return[];const r=d.get(s,t.prop,`${ue.STYLES_KEY},`).replace(ue.STYLES_KEY,"").split(",").join(" ");return d.filter(d.map(r.trim().split(" "),fe.constructClassObject),i=>!d.isNull(i))}),iu=()=>y.useAtomValue(_i),tr={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},ou=y.atom(e=>{const t=e(ki),s=e(wn),n=e(ji),r=au(t);let i=d.filter(e(_i),{mod:s});return d.startsWith(s,"_")||(i=d.filter(i,o=>r.includes(o.mq))),i=i.sort((o,u)=>tr[o.mq]-tr[u.mq]),n||(i=d.filter(i,{dark:!1})),i}),au=e=>{let t=[];switch(e){case"xs":t=["xs"];break;case"sm":t=["xs","sm"];break;case"md":t=["xs","sm","md"];break;case"lg":t=["xs","sm","md","lg"];break;case"xl":t=["xs","sm","md","lg","xl"];break;case"2xl":t=["xs","sm","md","lg","xl","2xl"];break;default:t=["xs"];break}return t},uu=()=>y.useAtomValue(ou),cu=()=>y.useAtom(wn),Ii=y.atom(null,(e,t,{blockIds:s,props:n,dispatch:r})=>{r({type:"update_props_realtime",payload:{ids:s,props:n}})}),lu=()=>{const{createSnapshot:e}=ls(),t=xe(),s=y.useSetAtom(Ii);return L.useCallback((n,r)=>{s({blockIds:n,props:r,dispatch:t}),e()},[e,t,s])},du=()=>{const e=xe(),t=y.useSetAtom(Ii);return L.useCallback((s,n)=>{t({blockIds:s,props:n,dispatch:e})},[e,t])},Di={name:"",props:{},modalProps:{},backdropClose:!0},fu=y.atom(Di),hu=()=>{const[e,t]=y.useAtom(fu),s=L.useCallback((r,i={},o={})=>{t({name:r,props:i,modalProps:o})},[t]),n=L.useCallback((...r)=>{d.get(e,"props.onClose",()=>{})(...r),t(Di)},[t,e]);return{activeModal:e,openModal:s,closeModal:n}},pu=()=>y.useAtomValue(hi),mu=y.atom(""),gu=y.atom(null),yu=()=>y.useAtom(mu),vu=()=>y.useAtom(gu),bu=at("selectedBreakpoints",["XS","MD","XL"]),xu=()=>{const[e,t]=y.useAtom(bu);return[e,t]},Mi=()=>{const e=y.useSetAtom(Ds),{clear:t}=ls(),[,s]=ze(),[,n]=Ci(),[,r]=Sn();return()=>{s([]),r([]),n(""),t(),e({undoCount:0,redoCount:0})}},wu=y.atom({en:{}}),Su=()=>{const[e,t]=y.useAtom(wu),s=L.useCallback((n,r,i)=>{d.set(e,`${n}.${r}`,i),t(e)},[e,t]);return[e,s]},Eu=(e,t)=>{const[s]=y.useAtom(ve.chaiBuilderPropsAtom);return d.get(s,e,t)},ku=y.atom([]),Au=()=>{const[e,t]=L.useState(!1),[s,n]=y.useAtom(ku),r=ve.useBuilderProp("getUILibraryBlocks",()=>[]);return L.useEffect(()=>{(async()=>s.length>0||(t(!0),n(await r()),t(!1)))()},[]),{data:s,isLoading:e}},Pu=y.atom("en"),ju=y.atom("en"),Cu=y.atom(["en"]),Li=()=>y.useAtom(Pu),Ou=()=>y.useAtom(ju),Ru=()=>y.useAtom(Cu),Bu=(e,t)=>{const[s]=Li(),n=`${e}${s?`-${s}`:""}`;return{content:d.get(t,n,d.get(t,e,"")),propKey:e}},_u=()=>{const[e,t]=En(),s=ve.useBuilderProp("previewComponent");return k.jsxRuntimeExports.jsxs("div",{className:Ao.cn("fixed inset-0 z-[999] bg-background",e?"block":"hidden"),children:[k.jsxRuntimeExports.jsx(ve.Button,{size:"sm",className:"absolute right-0 top-0 m-4",onClick:()=>t(!1),children:"Close Preview"}),k.jsxRuntimeExports.jsx("div",{children:s?k.jsxRuntimeExports.jsx(L.Suspense,{fallback:k.jsxRuntimeExports.jsx(ve.Skeleton,{className:"h-96 w-full"}),children:L.createElement(s)}):null})]})},Iu=()=>{const[e,t]=ze(),[,s]=Pi(),n=Bi(),r=Rn(),[,i]=Cn(),{pasteBlocks:o}=Oi(),{undo:u,redo:l}=ls();_e.useHotkeys("esc",()=>t([]),{},[t]),_e.useHotkeys("ctrl+c,command+c",()=>s(e),{},[e,s]),_e.useHotkeys("ctrl+d,command+d",()=>r(e),{preventDefault:!0},[e,r]),_e.useHotkeys("ctrl+x,command+x",()=>i(e),{},[e,i]),_e.useHotkeys("ctrl+v,command+v",()=>e.length===1?o(e[0]):null,{},[e,o]),_e.useHotkeys("ctrl+z,command+z",()=>u(),{},[u]),_e.useHotkeys("ctrl+y,command+y",()=>l(),{},[l]),_e.useHotkeys("del, backspace",c=>{c.preventDefault(),n(e)},{},[e,n])},Du=(e,t)=>{const s=[];let n=d.find(e,{_id:t}),r=d.get(n,"_parent","");for(;d.isString(r)&&!d.isEmpty(r);)s.push(n==null?void 0:n._parent),n=d.find(e,{_id:r}),r=n==null?void 0:n._parent;return d.flatten(s)},Ni=y.atom([]),Mu=()=>{const[e]=ze(),t=y.useAtomValue(be),[,s]=y.useAtom(Ni);L.useEffect(()=>{let n=[];const r=d.first(e);d.isString(r)&&(n=[r,...Du(t,r)]),s(n)},[e,t,s])},Lu=()=>y.useAtomValue(Ni),Nu=L.lazy(()=>Promise.resolve().then(()=>require("./SidePanels-e48c2ba6.cjs"))),Tu=L.lazy(()=>Promise.resolve().then(()=>require("./Topbar-26d18e9d.cjs"))),Uu=L.lazy(()=>Promise.resolve().then(()=>require("./CanvasArea-9287e1bd.cjs"))),Fu=L.lazy(()=>Promise.resolve().then(()=>require("./Settings-0358ce2f.cjs"))),qu=()=>{const[e]=aa(Ms),t=s=>{s.preventDefault()};return Iu(),Mu(),L.useEffect(()=>(e!=="SAVED"?window.onbeforeunload=()=>"":window.onbeforeunload=null,()=>{window.onbeforeunload=null}),[e]),k.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-background text-foreground",children:k.jsxRuntimeExports.jsxs(ve.TooltipProvider,{children:[k.jsxRuntimeExports.jsxs("div",{onContextMenu:t,className:"flex h-screen flex-col overflow-hidden bg-background text-foreground",children:[k.jsxRuntimeExports.jsx("div",{className:"h-14 w-screen shrink-0 border-b border-border",children:k.jsxRuntimeExports.jsx(L.Suspense,{children:k.jsxRuntimeExports.jsx(Tu,{})})}),k.jsxRuntimeExports.jsxs("main",{className:"flex h-full flex-row",children:[k.jsxRuntimeExports.jsx("div",{className:"flex h-full w-fit border-border",children:k.jsxRuntimeExports.jsx(L.Suspense,{children:k.jsxRuntimeExports.jsx(Nu,{})})}),k.jsxRuntimeExports.jsx("div",{className:"h-full flex-1 bg-slate-800/20",children:k.jsxRuntimeExports.jsx(L.Suspense,{children:k.jsxRuntimeExports.jsx(Uu,{})})}),k.jsxRuntimeExports.jsx("div",{className:"flex h-full w-[280px] min-w-[280px] border-l border-border",children:k.jsxRuntimeExports.jsx(L.Suspense,{children:k.jsxRuntimeExports.jsx(Fu,{})})})]})]}),k.jsxRuntimeExports.jsx(_u,{})]})})},$u=y.getDefaultStore();y.atom({});function sr(e,t,s,n,r){for(t=t.split?t.split("."):t,n=0;n<t.length;n++)e=e?e[t[n]]:r;return e===r?s:e}var gs="undefined",nr="object",Ti="any",Ui="*",rt="__",js=typeof process<"u"?process:{};js.env&&js.env.NODE_ENV;var Se=typeof document<"u";js.versions!=null&&js.versions.node!=null;typeof Deno<"u"&&Deno.core;Se&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function Fi(e,t){return t.charAt(0)[e]()+t.slice(1)}var Vu=Fi.bind(null,"toUpperCase"),Qu=Fi.bind(null,"toLowerCase");function Ku(e){return qi(e)?Vu("null"):typeof e=="object"?Yu(e):Object.prototype.toString.call(e).slice(8,-1)}function Cs(e,t){t===void 0&&(t=!0);var s=Ku(e);return t?Qu(s):s}function ds(e,t){return typeof t===e}var Ce=ds.bind(null,"function"),ft=ds.bind(null,"string"),lt=ds.bind(null,"undefined"),zu=ds.bind(null,"boolean");ds.bind(null,"symbol");function qi(e){return e===null}function Hu(e){return Cs(e)==="number"&&!isNaN(e)}function Gu(e){return Cs(e)==="array"}function de(e){if(!Wu(e))return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Wu(e){return e&&(typeof e=="object"||e!==null)}function Yu(e){return Ce(e.constructor)?e.constructor.name:null}function Ju(e){return e instanceof Error||ft(e.message)&&e.constructor&&Hu(e.constructor.stackTraceLimit)}function $i(e,t){if(typeof t!="object"||qi(t))return!1;if(t instanceof e)return!0;var s=Cs(new e(""));if(Ju(t))for(;t;){if(Cs(t)===s)return!0;t=Object.getPrototypeOf(t)}return!1}$i.bind(null,TypeError);$i.bind(null,SyntaxError);function Ls(e,t){var s=e instanceof Element||e instanceof HTMLDocument;return s&&t?Zu(e,t):s}function Zu(e,t){return t===void 0&&(t=""),e&&e.nodeName===t.toUpperCase()}function Ns(e){var t=[].slice.call(arguments,1);return function(){return e.apply(void 0,[].slice.call(arguments).concat(t))}}Ns(Ls,"form");Ns(Ls,"button");Ns(Ls,"input");Ns(Ls,"select");function rr(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function Xu(){if(Se){var e=navigator,t=e.languages;return e.userLanguage||(t&&t.length?t[0]:e.language)}}function ec(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function tc(e){return function(t){for(var s,n=Object.create(null),r=/([^&=]+)=?([^&]*)/g;s=r.exec(t);){var i=rr(s[1]),o=rr(s[2]);i.substring(i.length-2)==="[]"?(n[i=i.substring(0,i.length-2)]||(n[i]=[])).push(o):n[i]=o===""||o}for(var u in n){var l=u.split("[");l.length>1&&(sc(n,l.map(function(c){return c.replace(/[?[\]\\ ]/g,"")}),n[u]),delete n[u])}return n}(function(t){if(t){var s=t.match(/\?(.*)/);return s&&s[1]?s[1].split("#")[0]:""}return Se&&window.location.search.substring(1)}(e))}function sc(e,t,s){for(var n=t.length-1,r=0;r<n;++r){var i=t[r];if(i==="__proto__"||i==="constructor")break;i in e||(e[i]={}),e=e[i]}e[t[n]]=s}function Ts(){for(var e="",t=0,s=4294967295*Math.random()|0;t++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],r=15&s;e+=n=="-"||n=="4"?n:(n=="x"?r:3&r|8).toString(16),s=t%8==0?4294967295*Math.random()|0:s>>4}return e}var Qt="global",_t=rt+"global"+rt,It=typeof self===nr&&self.self===self&&self||typeof global===nr&&global.global===global&&global||void 0;function it(e){return It[_t][e]}function ot(e,t){return It[_t][e]=t}function Lt(e){delete It[_t][e]}function Nt(e,t,s){var n;try{if(Bn(e)){var r=window[e];n=r[t].bind(r)}}catch{}return n||s}It[_t]||(It[_t]={});var ys={};function Bn(e){if(typeof ys[e]!==gs)return ys[e];try{var t=window[e];t.setItem(gs,gs),t.removeItem(gs)}catch{return ys[e]=!1}return ys[e]=!0}function V(){return V=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},V.apply(this,arguments)}var Le="function",Be="undefined",nc="@@redux/"+Math.random().toString(36),ir=function(){return typeof Symbol===Le&&Symbol.observable||"@@observable"}(),vs=" != "+Le;function Vi(e,t,s){var n;if(typeof t===Le&&typeof s===Be&&(s=t,t=void 0),typeof s!==Be){if(typeof s!==Le)throw new Error("enhancer"+vs);return s(Vi)(e,t)}if(typeof e!==Le)throw new Error("reducer"+vs);var r=e,i=t,o=[],u=o,l=!1;function c(){u===o&&(u=o.slice())}function h(){return i}function g(v){if(typeof v!==Le)throw new Error("Listener"+vs);var R=!0;return c(),u.push(v),function(){if(R){R=!1,c();var B=u.indexOf(v);u.splice(B,1)}}}function P(v){if(!de(v))throw new Error("Act != obj");if(typeof v.type===Be)throw new Error("ActType "+Be);if(l)throw new Error("Dispatch in reducer");try{l=!0,i=r(i,v)}finally{l=!1}for(var R=o=u,B=0;B<R.length;B++)(0,R[B])();return v}return P({type:"@@redux/INIT"}),(n={dispatch:P,subscribe:g,getState:h,replaceReducer:function(v){if(typeof v!==Le)throw new Error("next reducer"+vs);r=v,P({type:"@@redux/INIT"})}})[ir]=function(){var v,R=g;return(v={subscribe:function(B){if(typeof B!="object")throw new TypeError("Observer != obj");function b(){B.next&&B.next(h())}return b(),{unsubscribe:R(b)}}})[ir]=function(){return this},v},n}function rc(e,t){var s=t&&t.type;return"action "+(s&&s.toString()||"?")+"reducer "+e+" returns "+Be}function Dt(){var e=[].slice.call(arguments);return e.length===0?function(t){return t}:e.length===1?e[0]:e.reduce(function(t,s){return function(){return t(s.apply(void 0,[].slice.call(arguments)))}})}function ic(){var e=arguments;return function(t){return function(s,n,r){var i,o=t(s,n,r),u=o.dispatch,l={getState:o.getState,dispatch:function(c){return u(c)}};return i=[].slice.call(e).map(function(c){return c(l)}),V({},o,{dispatch:u=Dt.apply(void 0,i)(o.dispatch)})}}}var Ke=rt+"anon_id",nt=rt+"user_id",ht=rt+"user_traits",De="userId",dt="anonymousId",Ss=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],sn=["name","EVENTS","config","loaded"],$=Ss.reduce(function(e,t){return e[t]=t,e},{registerPluginType:function(e){return"registerPlugin:"+e},pluginReadyType:function(e){return"ready:"+e}}),or=/^utm_/,ar=/^an_prop_/,ur=/^an_trait_/;function oc(e){var t=e.storage.setItem;return function(s){return function(n){return function(r){if(r.type===$.bootstrap){var i=r.params,o=r.user,u=r.persistedUser,l=r.initialUser,c=u.userId===o.userId;u.anonymousId!==o.anonymousId&&t(Ke,o.anonymousId),c||t(nt,o.userId),l.traits&&t(ht,V({},c&&u.traits?u.traits:{},l.traits));var h=Object.keys(r.params);if(h.length){var g=i.an_uid,P=i.an_event,v=h.reduce(function(R,B){if(B.match(or)||B.match(/^(d|g)clid/)){var b=B.replace(or,"");R.campaign[b==="campaign"?"name":b]=i[B]}return B.match(ar)&&(R.props[B.replace(ar,"")]=i[B]),B.match(ur)&&(R.traits[B.replace(ur,"")]=i[B]),R},{campaign:{},props:{},traits:{}});s.dispatch(V({type:$.params,raw:i},v,g?{userId:g}:{})),g&&setTimeout(function(){return e.identify(g,v.traits)},0),P&&setTimeout(function(){return e.track(P,v.props)},0),Object.keys(v.campaign).length&&s.dispatch({type:$.campaign,campaign:v.campaign})}}return n(r)}}}}function ac(e){return function(t,s){if(t===void 0&&(t={}),s===void 0&&(s={}),s.type===$.setItemEnd){if(s.key===Ke)return V({},t,{anonymousId:s.value});if(s.key===nt)return V({},t,{userId:s.value})}switch(s.type){case $.identify:return Object.assign({},t,{userId:s.userId,traits:V({},t.traits,s.traits)});case $.reset:return[nt,Ke,ht].forEach(function(n){e.removeItem(n)}),Object.assign({},t,{userId:null,anonymousId:null,traits:{}});default:return t}}}function cr(e){return{userId:e.getItem(nt),anonymousId:e.getItem(Ke),traits:e.getItem(ht)}}var nn=function(e){return rt+"TEMP"+rt+e};function uc(e){var t=e.storage,s=t.setItem,n=t.removeItem,r=t.getItem;return function(i){return function(o){return function(u){var l=u.userId,c=u.traits,h=u.options;if(u.type===$.reset&&([nt,ht,Ke].forEach(function(v){n(v)}),[De,dt,"traits"].forEach(function(v){Lt(nn(v))})),u.type===$.identify){r(Ke)||s(Ke,Ts());var g=r(nt),P=r(ht)||{};g&&g!==l&&i.dispatch({type:$.userIdChanged,old:{userId:g,traits:P},new:{userId:l,traits:c},options:h}),l&&s(nt,l),c&&s(ht,V({},P,c))}return o(u)}}}}var qt={};function lr(e,t){qt[e]&&Ce(qt[e])&&(qt[e](t),delete qt[e])}function Qi(e,t,s){return new Promise(function(n,r){return t()?n(e):s<1?r(V({},e,{queue:!0})):new Promise(function(i){return setTimeout(i,10)}).then(function(i){return Qi(e,t,s-10).then(n,r)})})}function Ki(e,t,s){var n=t(),r=e.getState(),i=r.plugins,o=r.queue,u=r.user;if(!r.context.offline&&o&&o.actions&&o.actions.length){var l=o.actions.reduce(function(h,g,P){return i[g.plugin].loaded?(h.process.push(g),h.processIndex.push(P)):(h.requeue.push(g),h.requeueIndex.push(P)),h},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(l.processIndex&&l.processIndex.length){l.processIndex.forEach(function(h){var g=o.actions[h],P=g.plugin,v=g.payload.type,R=n[P][v];if(R&&Ce(R)){var B=function(C,U){return C===void 0&&(C={}),U===void 0&&(U={}),[De,dt].reduce(function(M,E){return C.hasOwnProperty(E)&&U[E]&&U[E]!==C[E]&&(M[E]=U[E]),M},C)}(g.payload,u);R({payload:B,config:i[P].config,instance:s});var b=v+":"+P;e.dispatch(V({},B,{type:b,_:{called:b,from:"queueDrain"}}))}});var c=o.actions.filter(function(h,g){return!~l.processIndex.indexOf(g)});o.actions=c}}}var Hs=function(e){var t=e.data,s=e.action,n=e.instance,r=e.state,i=e.allPlugins,o=e.allMatches,u=e.store,l=e.EVENTS;try{var c=r.plugins,h=r.context,g=s.type,P=g.match(pt),v=t.exact.map(function(b){return b.pluginName});P&&(v=o.during.map(function(b){return b.pluginName}));var R=function(b,C){return function(U,M,E){var j=M.config,q=M.name,F=q+"."+U.type;E&&(F=E.event);var N=U.type.match(pt)?function(m,x,_,w,D){return function(O,S){var z=w?w.name:m,Q=S&&Gt(S)?S:_;if(w&&(!(Q=S&&Gt(S)?S:[m]).includes(m)||Q.length!==1))throw new Error("Method "+x+" can only abort "+m+" plugin. "+JSON.stringify(Q)+" input valid");return V({},D,{abort:{reason:O,plugins:Q,caller:x,_:z}})}}(q,F,C,E,U):function(m,x){return function(){throw new Error(m.type+" action not cancellable. Remove abort in "+x)}}(U,F);return{payload:cc(U),instance:b,config:j||{},abort:N}}}(n,v),B=t.exact.reduce(function(b,C){var U=C.pluginName,M=C.methodName,E=!1;return M.match(/^initialize/)||M.match(/^reset/)||(E=!c[U].loaded),h.offline&&M.match(/^(page|track|identify)/)&&(E=!0),b[""+U]=E,b},{});return Promise.resolve(t.exact.reduce(function(b,C,U){try{var M=C.pluginName;return Promise.resolve(b).then(function(E){function j(){return Promise.resolve(E)}var q=function(){if(t.namespaced&&t.namespaced[M])return Promise.resolve(t.namespaced[M].reduce(function(F,N,m){try{return Promise.resolve(F).then(function(x){return N.method&&Ce(N.method)?(function(O,S){var z=yr(O);if(z&&z.name===S){var Q=yr(z.method);throw new Error([S+" plugin is calling method "+O,"Plugins cant call self","Use "+z.method+" "+(Q?"or "+Q.method:"")+" in "+S+" plugin insteadof "+O].join(`
2
+ `))}}(N.methodName,N.pluginName),Promise.resolve(N.method({payload:x,instance:n,abort:(_=x,w=M,D=N.pluginName,function(O,S){return V({},_,{abort:{reason:O,plugins:S||[w],caller:g,from:D||w}})}),config:hr(N.pluginName,c,i),plugins:c})).then(function(O){var S=de(O)?O:{};return Promise.resolve(V({},x,S))})):x;var _,w,D})}catch(x){return Promise.reject(x)}},Promise.resolve(s))).then(function(F){E[M]=F});E[M]=s}();return q&&q.then?q.then(j):j()})}catch(E){return Promise.reject(E)}},Promise.resolve({}))).then(function(b){return Promise.resolve(t.exact.reduce(function(C,U,M){try{var E=t.exact.length===M+1,j=U.pluginName,q=i[j];return Promise.resolve(C).then(function(F){var N=b[j]?b[j]:{};if(P&&(N=F),Ws(N,j))return Gs({data:N,method:g,instance:n,pluginName:j,store:u}),Promise.resolve(F);if(Ws(F,j))return E&&Gs({data:F,method:g,instance:n,store:u}),Promise.resolve(F);if(B.hasOwnProperty(j)&&B[j]===!0)return u.dispatch({type:"queue",plugin:j,payload:N,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(F);var m=R(b[j],i[j]);return Promise.resolve(q[g]({abort:m.abort,payload:N,instance:n,config:hr(j,c,i),plugins:c})).then(function(x){var _=de(x)?x:{},w=V({},F,_),D=b[j];if(Ws(D,j))Gs({data:D,method:g,instance:n,pluginName:j,store:u});else{var O=g+":"+j;(O.match(/:/g)||[]).length<2&&!g.match(dr)&&!g.match(fr)&&n.dispatch(V({},P?w:N,{type:O,_:{called:O,from:"submethod"}}))}return Promise.resolve(w)})})}catch(F){return Promise.reject(F)}},Promise.resolve(s))).then(function(C){if(!(g.match(pt)||g.match(/^registerPlugin/)||g.match(fr)||g.match(dr)||g.match(/^params/)||g.match(/^userIdChanged/))){if(l.plugins.includes(g),C._&&C._.originalAction===g)return C;var U=V({},C,{_:{originalAction:C.type,called:C.type,from:"engineEnd"}});zi(C,t.exact.length)&&!g.match(/End$/)&&(U=V({},U,{type:C.type+"Aborted"})),u.dispatch(U)}return C})})}catch(b){return Promise.reject(b)}},pt=/Start$/,dr=/^bootstrap/,fr=/^ready/;function Gs(e){var t=e.pluginName,s=e.method+"Aborted"+(t?":"+t:"");e.store.dispatch(V({},e.data,{type:s,_:{called:s,from:"abort"}}))}function hr(e,t,s){var n=t[e]||s[e];return n&&n.config?n.config:{}}function pr(e,t){return t.reduce(function(s,n){return n[e]?s.concat({methodName:e,pluginName:n.name,method:n[e]}):s},[])}function mr(e,t){var s=e.replace(pt,""),n=t?":"+t:"";return[""+e+n,""+s+n,s+"End"+n]}function Ws(e,t){var s=e.abort;return!!s&&(s===!0||gr(s,t)||s&&gr(s.plugins,t))}function zi(e,t){var s=e.abort;if(!s)return!1;if(s===!0||ft(s))return!0;var n=s.plugins;return Gt(s)&&s.length===t||Gt(n)&&n.length===t}function Gt(e){return Array.isArray(e)}function gr(e,t){return!(!e||!Gt(e))&&e.includes(t)}function yr(e){var t=e.match(/(.*):(.*)/);return!!t&&{method:t[1],name:t[2]}}function cc(e){return Object.keys(e).reduce(function(t,s){return s==="type"||(t[s]=de(e[s])?Object.assign({},e[s]):e[s]),t},{})}function lc(e,t,s){var n={};return function(r){return function(i){return function(o){try{var u,l=function(E){return u?E:i(g)},c=o.type,h=o.plugins,g=o;if(o.abort)return Promise.resolve(i(o));if(c===$.enablePlugin&&r.dispatch({type:$.initializeStart,plugins:h,disabled:[],fromEnable:!0,meta:o.meta}),c===$.disablePlugin&&setTimeout(function(){return lr(o.meta.rid,{payload:o})},0),c===$.initializeEnd){var P=t(),v=Object.keys(P),R=v.filter(function(E){return h.includes(E)}).map(function(E){return P[E]}),B=[],b=[],C=o.disabled,U=R.map(function(E){var j=E.loaded,q=E.name,F=E.config;return Qi(E,function(){return j({config:F})},1e4).then(function(N){return n[q]||(r.dispatch({type:$.pluginReadyType(q),name:q,events:Object.keys(E).filter(function(m){return!sn.includes(m)})}),n[q]=!0),B=B.concat(q),E}).catch(function(N){if(N instanceof Error)throw new Error(N);return b=b.concat(N.name),N})});Promise.all(U).then(function(E){var j={plugins:B,failed:b,disabled:C};setTimeout(function(){v.length===U.length+C.length&&r.dispatch(V({},{type:$.ready},j))},0)})}var M=function(){if(c!==$.bootstrap)return/^ready:([^:]*)$/.test(c)&&setTimeout(function(){return Ki(r,t,e)},0),Promise.resolve(function(E,j,q,F,N){try{var m=Ce(j)?j():j,x=E.type,_=x.replace(pt,"");if(E._&&E._.called)return Promise.resolve(E);var w=q.getState(),D=(z=m,(Q=w.plugins)===void 0&&(Q={}),(W=E.options)===void 0&&(W={}),Object.keys(z).filter(function(f){var p=W.plugins||{};return zu(p[f])?p[f]:p.all!==!1&&(!Q[f]||Q[f].enabled!==!1)}).map(function(f){return z[f]}));x===$.initializeStart&&E.fromEnable&&(D=Object.keys(w.plugins).filter(function(f){var p=w.plugins[f];return E.plugins.includes(f)&&!p.initialized}).map(function(f){return m[f]}));var O=D.map(function(f){return f.name}),S=function(f,p,T){var H=mr(f).map(function(G){return pr(G,p)});return p.reduce(function(G,Y){var ie=Y.name,Z=mr(f,ie).map(function(Ut){return pr(Ut,p)}),ee=Z[0],J=Z[1],Ee=Z[2];return ee.length&&(G.beforeNS[ie]=ee),J.length&&(G.duringNS[ie]=J),Ee.length&&(G.afterNS[ie]=Ee),G},{before:H[0],beforeNS:{},during:H[1],duringNS:{},after:H[2],afterNS:{}})}(x,D);return Promise.resolve(Hs({action:E,data:{exact:S.before,namespaced:S.beforeNS},state:w,allPlugins:m,allMatches:S,instance:q,store:F,EVENTS:N})).then(function(f){function p(){var G=function(){if(x.match(pt))return Promise.resolve(Hs({action:V({},T,{type:_+"End"}),data:{exact:S.after,namespaced:S.afterNS},state:w,allPlugins:m,allMatches:S,instance:q,store:F,EVENTS:N})).then(function(Y){Y.meta&&Y.meta.hasCallback&&lr(Y.meta.rid,{payload:Y})})}();return G&&G.then?G.then(function(){return f}):f}if(zi(f,O.length))return f;var T,H=function(){if(x!==_)return Promise.resolve(Hs({action:V({},f,{type:_}),data:{exact:S.during,namespaced:S.duringNS},state:w,allPlugins:m,allMatches:S,instance:q,store:F,EVENTS:N})).then(function(G){T=G});T=f}();return H&&H.then?H.then(p):p()})}catch(f){return Promise.reject(f)}var z,Q,W}(o,t,e,r,s)).then(function(E){return u=1,i(E)})}();return Promise.resolve(M&&M.then?M.then(l):l(M))}catch(E){return Promise.reject(E)}}}}}function dc(e){return function(t){return function(s){return function(n){var r=n.type,i=n.key,o=n.value,u=n.options;if(r===$.setItem||r===$.removeItem){if(n.abort)return s(n);r===$.setItem?e.setItem(i,o,u):e.removeItem(i,u)}return s(n)}}}}var fc=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(t,s){e[s]=e[s].concat(t)},this.removeMiddleware=function(t,s){var n=e[s].findIndex(function(r){return r===t});n!==-1&&(e[s]=[].concat(e[s].slice(0,n),e[s].slice(n+1)))},this.dynamicMiddlewares=function(t){return function(s){return function(n){return function(r){var i={getState:s.getState,dispatch:function(u){return s.dispatch(u)}},o=e[t].map(function(u){return u(i)});return Dt.apply(void 0,o)(n)(r)}}}}};function hc(e){return function(t,s){t===void 0&&(t={});var n={};if(s.type==="initialize:aborted")return t;if(/^registerPlugin:([^:]*)$/.test(s.type)){var r=vr(s.type,"registerPlugin"),i=e()[r];if(!i||!r)return t;var o=s.enabled,u=i.config;return n[r]={enabled:o,initialized:!!o&&!i.initialize,loaded:!!o&&!!i.loaded({config:u}),config:u},V({},t,n)}if(/^initialize:([^:]*)$/.test(s.type)){var l=vr(s.type,$.initialize),c=e()[l];return c&&l?(n[l]=V({},t[l],{initialized:!0,loaded:!!c.loaded({config:c.config})}),V({},t,n)):t}if(/^ready:([^:]*)$/.test(s.type))return n[s.name]=V({},t[s.name],{loaded:!0}),V({},t,n);switch(s.type){case $.disablePlugin:return V({},t,br(s.plugins,!1,t));case $.enablePlugin:return V({},t,br(s.plugins,!0,t));default:return t}}}function vr(e,t){return e.substring(t.length+1,e.length)}function br(e,t,s){return e.reduce(function(n,r){return n[r]=V({},s[r],{enabled:t}),n},s)}function Hi(e){try{return JSON.parse(JSON.stringify(e))}catch{}return e}var pc={last:{},history:[]};function mc(e,t){e===void 0&&(e=pc);var s=t.options,n=t.meta;if(t.type===$.track){var r=Hi(V({event:t.event,properties:t.properties},Object.keys(s).length&&{options:s},{meta:n}));return V({},e,{last:r,history:e.history.concat(r)})}return e}var gc={actions:[]};function yc(e,t){e===void 0&&(e=gc);var s=t.payload;switch(t.type){case"queue":var n;return n=s&&s.type&&s.type===$.identify?[t].concat(e.actions):e.actions.concat(t),V({},e,{actions:n});case"dequeue":return[];default:return e}}var Gi=/#.*$/;function vc(e){var t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(Gi,""):"")}var Wi,Yi,Ji,Zi,bc=function(e){if(e===void 0&&(e={}),!Se)return e;var t=document,s=t.title,n=t.referrer,r=window,i=r.location,o=r.innerWidth,u=r.innerHeight,l=i.hash,c=i.search,h=function(P){var v=function(){if(Se){for(var R,B=document.getElementsByTagName("link"),b=0;R=B[b];b++)if(R.getAttribute("rel")==="canonical")return R.getAttribute("href")}}();return v?v.match(/\?/)?v:v+P:window.location.href.replace(Gi,"")}(c),g={title:s,url:h,path:vc(h),hash:l,search:c,width:o,height:u};return n&&n!==""&&(g.referrer=n),V({},g,e)},xc={last:{},history:[]};function wc(e,t){e===void 0&&(e=xc);var s=t.options;if(t.type===$.page){var n=Hi(V({properties:t.properties,meta:t.meta},Object.keys(s).length&&{options:s}));return V({},e,{last:n,history:e.history.concat(n)})}return e}Wi=function(){if(!Se)return!1;var e=navigator.appVersion;return~e.indexOf("Win")?"Windows":~e.indexOf("Mac")?"MacOS":~e.indexOf("X11")?"UNIX":~e.indexOf("Linux")?"Linux":"Unknown OS"}(),Yi=Se?document.referrer:null,Ji=Xu(),Zi=ec();var xr={initialized:!1,sessionId:Ts(),app:null,version:null,debug:!1,offline:!!Se&&!navigator.onLine,os:{name:Wi},userAgent:Se?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.5"},timezone:Zi,locale:Ji,campaign:{},referrer:Yi};function Sc(e,t){e===void 0&&(e=xr);var s=e.initialized,n=t.campaign;switch(t.type){case $.campaign:return V({},e,{campaign:n});case $.offline:return V({},e,{offline:!0});case $.online:return V({},e,{offline:!1});default:return s?e:V({},xr,e,{initialized:!0})}}var Ec=["plugins","reducers","storage"];function kc(e,t,s){if(Se){var n=window[(s?"add":"remove")+"EventListener"];e.split(" ").forEach(function(r){n(r,t)})}}function Ac(e){var t=kc.bind(null,"online offline",function(s){return Promise.resolve(!navigator.onLine).then(e)});return t(!0),function(s){return t(!1)}}function Xi(){return ot("analytics",[]),function(e){return function(t,s,n){var r=e(t,s,n),i=r.dispatch;return Object.assign(r,{dispatch:function(o){return It[_t].analytics.push(o.action||o),i(o)}})}}}function wr(e){return function(){return Dt(Dt.apply(null,arguments),Xi())}}function Ys(e){return e?Gu(e)?e:[e]:[]}function Sr(e,t,s){e===void 0&&(e={});var n,r,i=Ts();return t&&(qt[i]=(n=t,r=function(o){for(var u,l=o||Array.prototype.slice.call(arguments),c=0;c<l.length;c++)if(Ce(l[c])){u=l[c];break}return u}(s),function(o){r&&r(o),n(o)})),V({},e,{rid:i,ts:new Date().getTime()},t?{hasCallback:!0}:{})}function Pc(e){e===void 0&&(e={});var t=e.reducers||{},s=e.initialUser||{},n=(e.plugins||[]).reduce(function(f,p){if(Ce(p))return f.middlewares=f.middlewares.concat(p),f;if(p.NAMESPACE&&(p.name=p.NAMESPACE),!p.name)throw new Error("https://lytics.dev/errors/1");p.config||(p.config={});var T=p.EVENTS?Object.keys(p.EVENTS).map(function(Y){return p.EVENTS[Y]}):[];f.pluginEnabled[p.name]=!(p.enabled===!1||p.config.enabled===!1),delete p.enabled,p.methods&&(f.methods[p.name]=Object.keys(p.methods).reduce(function(Y,ie){var Z;return Y[ie]=(Z=p.methods[ie],function(){for(var ee=Array.prototype.slice.call(arguments),J=new Array(Z.length),Ee=0;Ee<ee.length;Ee++)J[Ee]=ee[Ee];return J[J.length]=j,Z.apply({instance:j},J)}),Y},{}),delete p.methods);var H=Object.keys(p).concat(T),G=new Set(f.events.concat(H));if(f.events=Array.from(G),f.pluginsArray=f.pluginsArray.concat(p),f.plugins[p.name])throw new Error(p.name+"AlreadyLoaded");return f.plugins[p.name]=p,f.plugins[p.name].loaded||(f.plugins[p.name].loaded=function(){return!0}),f},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),r=e.storage?e.storage:{getItem:it,setItem:ot,removeItem:Lt},i=function(f){return function(p,T,H){return T.getState("user")[p]||(H&&de(H)&&H[p]?H[p]:cr(f)[p]||it(nn(p))||null)}}(r),o=n.plugins,u=n.events.filter(function(f){return!sn.includes(f)}).sort(),l=new Set(u.concat(Ss).filter(function(f){return!sn.includes(f)})),c=Array.from(l).sort(),h=function(){return o},g=new fc,P=g.addMiddleware,v=g.removeMiddleware,R=g.dynamicMiddlewares,B=function(){throw new Error("Abort disabled inListener")},b=tc(),C=cr(r),U=V({},C,s,b.an_uid?{userId:b.an_uid}:{},b.an_aid?{anonymousId:b.an_aid}:{});U.anonymousId||(U.anonymousId=Ts());var M=V({enable:function(f,p){return new Promise(function(T){S.dispatch({type:$.enablePlugin,plugins:Ys(f),_:{originalAction:$.enablePlugin}},T,[p])})},disable:function(f,p){return new Promise(function(T){S.dispatch({type:$.disablePlugin,plugins:Ys(f),_:{originalAction:$.disablePlugin}},T,[p])})}},n.methods),E=!1,j={identify:function(f,p,T,H){try{var G=ft(f)?f:null,Y=de(f)?f:p,ie=T||{},Z=j.user();ot(nn(De),G);var ee=G||Y.userId||i(De,j,Y);return Promise.resolve(new Promise(function(J){S.dispatch(V({type:$.identifyStart,userId:ee,traits:Y||{},options:ie,anonymousId:Z.anonymousId},Z.id&&Z.id!==G&&{previousId:Z.id}),J,[p,T,H])}))}catch(J){return Promise.reject(J)}},track:function(f,p,T,H){try{var G=de(f)?f.event:f;if(!G||!ft(G))throw new Error("EventMissing");var Y=de(f)?f:p||{},ie=de(T)?T:{};return Promise.resolve(new Promise(function(Z){S.dispatch({type:$.trackStart,event:G,properties:Y,options:ie,userId:i(De,j,p),anonymousId:i(dt,j,p)},Z,[p,T,H])}))}catch(Z){return Promise.reject(Z)}},page:function(f,p,T){try{var H=de(f)?f:{},G=de(p)?p:{};return Promise.resolve(new Promise(function(Y){S.dispatch({type:$.pageStart,properties:bc(H),options:G,userId:i(De,j,H),anonymousId:i(dt,j,H)},Y,[f,p,T])}))}catch(Y){return Promise.reject(Y)}},user:function(f){if(f===De||f==="id")return i(De,j);if(f===dt||f==="anonId")return i(dt,j);var p=j.getState("user");return f?sr(p,f):p},reset:function(f){return new Promise(function(p){S.dispatch({type:$.resetStart},p,f)})},ready:function(f){return E&&f({plugins:M,instance:j}),j.on($.ready,function(p){f(p),E=!0})},on:function(f,p){if(!f||!Ce(p))return!1;if(f===$.bootstrap)throw new Error(".on disabled for "+f);var T=/Start$|Start:/;if(f==="*"){var H=function(Z){return function(ee){return function(J){return J.type.match(T)&&p({payload:J,instance:j,plugins:o}),ee(J)}}},G=function(Z){return function(ee){return function(J){return J.type.match(T)||p({payload:J,instance:j,plugins:o}),ee(J)}}};return P(H,bs),P(G,xs),function(){v(H,bs),v(G,xs)}}var Y=f.match(T)?bs:xs,ie=function(Z){return function(ee){return function(J){return J.type===f&&p({payload:J,instance:j,plugins:o,abort:B}),ee(J)}}};return P(ie,Y),function(){return v(ie,Y)}},once:function(f,p){if(!f||!Ce(p))return!1;if(f===$.bootstrap)throw new Error(".once disabled for "+f);var T=j.on(f,function(H){p({payload:H.payload,instance:j,plugins:o,abort:B}),T()});return T},getState:function(f){var p=S.getState();return f?sr(p,f):Object.assign({},p)},dispatch:function(f){var p=ft(f)?{type:f}:f;if(Ss.includes(p.type))throw new Error("reserved action "+p.type);var T=V({},p,{_:V({originalAction:p.type},f._||{})});S.dispatch(T)},enablePlugin:M.enable,disablePlugin:M.disable,plugins:M,storage:{getItem:r.getItem,setItem:function(f,p,T){S.dispatch({type:$.setItemStart,key:f,value:p,options:T})},removeItem:function(f,p){S.dispatch({type:$.removeItemStart,key:f,options:p})}},setAnonymousId:function(f,p){j.storage.setItem(Ke,f,p)},events:{core:Ss,plugins:u}},q=n.middlewares.concat([function(f){return function(p){return function(T){return T.meta||(T.meta=Sr()),p(T)}}},R(bs),lc(j,h,{all:c,plugins:u}),dc(r),oc(j),uc(j),R(xs)]),F={context:Sc,user:ac(r),page:wc,track:mc,plugins:hc(h),queue:yc},N=Dt,m=Dt;if(Se&&e.debug){var x=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;x&&(N=x({trace:!0,traceLimit:25})),m=function(){return arguments.length===0?Xi():de(typeof arguments[0])?wr():wr().apply(null,arguments)}}var _,w=function(f){return Object.keys(f).reduce(function(p,T){return Ec.includes(T)||(p[T]=f[T]),p},{})}(e),D=n.pluginsArray.reduce(function(f,p){var T=p.name,H=p.config,G=p.loaded,Y=n.pluginEnabled[T];return f[T]={enabled:Y,initialized:!!Y&&!p.initialize,loaded:!!G({config:H}),config:H},f},{}),O={context:w,user:U,plugins:D},S=Vi(function(f){for(var p=Object.keys(f),T={},H=0;H<p.length;H++){var G=p[H];typeof f[G]===Le&&(T[G]=f[G])}var Y,ie=Object.keys(T);try{(function(Z){Object.keys(Z).forEach(function(ee){var J=Z[ee];if(typeof J(void 0,{type:"@@redux/INIT"})===Be||typeof J(void 0,{type:nc})===Be)throw new Error("reducer "+ee+" "+Be)})})(T)}catch(Z){Y=Z}return function(Z,ee){if(Z===void 0&&(Z={}),Y)throw Y;for(var J=!1,Ee={},Ut=0;Ut<ie.length;Ut++){var hs=ie[Ut],Fn=Z[hs],Qs=(0,T[hs])(Fn,ee);if(typeof Qs===Be){var xo=rc(hs,ee);throw new Error(xo)}Ee[hs]=Qs,J=J||Qs!==Fn}return J?Ee:Z}}(V({},F,t)),O,m(N(ic.apply(void 0,q))));S.dispatch=(_=S.dispatch,function(f,p,T){var H=V({},f,{meta:Sr(f.meta,p,Ys(T))});return _.apply(null,[H])});var z=Object.keys(o);S.dispatch({type:$.bootstrap,plugins:z,config:w,params:b,user:U,initialUser:s,persistedUser:C});var Q=z.filter(function(f){return n.pluginEnabled[f]}),W=z.filter(function(f){return!n.pluginEnabled[f]});return S.dispatch({type:$.registerPlugins,plugins:z,enabled:n.pluginEnabled}),n.pluginsArray.map(function(f,p){var T=f.bootstrap,H=f.config,G=f.name;T&&Ce(T)&&T({instance:j,config:H,payload:f}),S.dispatch({type:$.registerPluginType(G),name:G,enabled:n.pluginEnabled[G],plugin:f}),n.pluginsArray.length===p+1&&S.dispatch({type:$.initializeStart,plugins:Q,disabled:W})}),Ac(function(f){S.dispatch({type:f?$.offline:$.online})}),function(f,p,T){setInterval(function(){return Ki(f,p,T)},3e3)}(S,h,j),j}var bs="before",xs="after",Kt="cookie",He=so(),eo=Us,jc=Us;function to(e){return He?Us(e,"",-1):Lt(e)}function so(){if(He!==void 0)return He;var e="cookiecookie";try{Us(e,e),He=document.cookie.indexOf(e)!==-1,to(e)}catch{He=!1}return He}function Us(e,t,s,n,r,i){if(typeof window<"u"){var o=arguments.length>1;return He===!1&&(o?ot(e,t):it(e)),o?document.cookie=e+"="+encodeURIComponent(t)+(s?"; expires="+new Date(+new Date+1e3*s).toUTCString()+(n?"; path="+n:"")+(r?"; domain="+r:"")+(i?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}}var zt="localStorage",Cc=Bn.bind(null,"localStorage");Nt("localStorage","getItem",it);Nt("localStorage","setItem",ot);Nt("localStorage","removeItem",Lt);var Ht="sessionStorage",Oc=Bn.bind(null,"sessionStorage");Nt("sessionStorage","getItem",it);Nt("sessionStorage","setItem",ot);Nt("sessionStorage","removeItem",Lt);function mt(e){var t=e;try{if((t=JSON.parse(e))==="true")return!0;if(t==="false")return!1;if(de(t))return t;parseFloat(t)===t&&(t=parseFloat(t))}catch{}if(t!==null&&t!=="")return t}var Rc=Cc(),Bc=Oc(),_c=so();function no(e,t){if(e){var s=_n(t),n=!Ln(s),r=In(s)?mt(localStorage.getItem(e)):void 0;if(n&&!lt(r))return r;var i=Dn(s)?mt(eo(e)):void 0;if(n&&i)return i;var o=Mn(s)?mt(sessionStorage.getItem(e)):void 0;if(n&&o)return o;var u=it(e);return n?u:{localStorage:r,sessionStorage:o,cookie:i,global:u}}}function Ic(e,t,s){if(e&&!lt(t)){var n={},r=_n(s),i=JSON.stringify(t),o=!Ln(r);return In(r)&&(n[zt]=ws(zt,t,mt(localStorage.getItem(e))),localStorage.setItem(e,i),o)?n[zt]:Dn(r)&&(n[Kt]=ws(Kt,t,mt(eo(e))),jc(e,i),o)?n[Kt]:Mn(r)&&(n[Ht]=ws(Ht,t,mt(sessionStorage.getItem(e))),sessionStorage.setItem(e,i),o)?n[Ht]:(n[Qt]=ws(Qt,t,it(e)),ot(e,t),o?n[Qt]:n)}}function Dc(e,t){if(e){var s=_n(t),n=no(e,Ui),r={};return!lt(n.localStorage)&&In(s)&&(localStorage.removeItem(e),r[zt]=n.localStorage),!lt(n.cookie)&&Dn(s)&&(to(e),r[Kt]=n.cookie),!lt(n.sessionStorage)&&Mn(s)&&(sessionStorage.removeItem(e),r[Ht]=n.sessionStorage),!lt(n.global)&&Fs(s,Qt)&&(Lt(e),r[Qt]=n.global),r}}function _n(e){return e?ft(e)?e:e.storage:Ti}function In(e){return Rc&&Fs(e,zt)}function Dn(e){return _c&&Fs(e,Kt)}function Mn(e){return Bc&&Fs(e,Ht)}function Ln(e){return e===Ui||e==="all"}function Fs(e,t){return e===Ti||e===t||Ln(e)}function ws(e,t,s){return{location:e,current:t,previous:s}}var Mc={setItem:Ic,getItem:no,removeItem:Dc};function Lc(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function Er(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),s.push.apply(s,n)}return s}function kr(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?Er(Object(s),!0).forEach(function(n){Lc(e,n,s[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Er(Object(s)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(s,n))})}return e}function Nc(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t={storage:Mc};return Pc(kr(kr({},t),e))}const Tc="@chaibuilder/sdk",Uc="0.1.4",Fc="module",qc=["dist"],$c="dist/core.js",Vc=!1,Qc={".":{import:"./dist/core.js",require:"./dist/core.cjs",types:"./dist/core.d.ts"},"./render":{import:"./dist/render.js",require:"./dist/render.cjs",types:"./dist/render.d.ts"},"./ui":{import:"./dist/ui.js",require:"./dist/ui.cjs",types:"./dist/ui.d.ts"},"./lib":{import:"./dist/lib.js",require:"./dist/lib.cjs",types:"./dist/lib.d.ts"},"./server":{import:"./dist/server.js",require:"./dist/server.cjs",types:"./dist/server.d.ts"},"./styles":{import:"./dist/style.css",require:"./dist/style.css"}},Kc={dev:"vite",build:"tsc && vite build",lint:"eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",preview:"vite preview",test:"jest --colors","test:watch":"jest --watch --colors","test:coverage":"jest --coverage --colors",e2e:"playwright test","e2e:report":"playwright show-report","e2e:ui":"playwright test --ui",docs:"jsdoc -c jsdoc.conf.json"},zc={"@analytics/google-analytics":"^1.0.7","@bobthered/tailwindcss-palette-generator":"3.1.1","@chaibuilder/blocks":"^0.1.0","@floating-ui/dom":"1.4.5","@floating-ui/react-dom":"2.0.1","@mhsdesign/jit-browser-tailwindcss":"0.3.0","@minoru/react-dnd-treeview":"3.4.4","@radix-ui/react-accordion":"^1.1.2","@radix-ui/react-alert-dialog":"^1.0.4","@radix-ui/react-context-menu":"^2.1.4","@radix-ui/react-dialog":"^1.0.4","@radix-ui/react-dropdown-menu":"^2.0.5","@radix-ui/react-hover-card":"^1.0.6","@radix-ui/react-icons":"^1.3.0","@radix-ui/react-label":"^2.0.2","@radix-ui/react-menubar":"^1.0.3","@radix-ui/react-navigation-menu":"^1.1.3","@radix-ui/react-popover":"^1.0.6","@radix-ui/react-scroll-area":"^1.0.4","@radix-ui/react-select":"^1.2.2","@radix-ui/react-separator":"^1.0.3","@radix-ui/react-slot":"^1.0.2","@radix-ui/react-switch":"^1.0.3","@radix-ui/react-tabs":"^1.0.4","@radix-ui/react-toast":"^1.1.4","@radix-ui/react-toggle":"^1.0.3","@radix-ui/react-tooltip":"^1.0.6","@react-hookz/web":"23.1.0","@rjsf/core":"5.11.2","@rjsf/utils":"5.11.2","@rjsf/validator-ajv8":"5.11.2","@tailwindcss/aspect-ratio":"0.4.2","@tailwindcss/forms":"^0.5.6","@tailwindcss/line-clamp":"^0.4.4","@tailwindcss/typography":"^0.5.10","@tanstack/react-query":"^5.8.4",analytics:"^0.8.9","class-variance-authority":"0.6.1",clsx:"1.2.1",cmdk:"0.2.0","date-fns":"^2.30.0",flagged:"2.0.9","flat-to-nested":"1.1.1","focus-trap-react":"^10.2.1","forgiving-xml-parser":"1.4.0","framer-motion":"^10.12.18","fuse.js":"6.6.2","gray-matter":"^4.0.3",himalaya:"^1.1.0","html-formatter":"0.1.9",i18next:"^23.2.8",jotai:"2.2.2",lodash:"4.17.21","lucide-react":"^0.244.0",nanoid:"^4.0.2","post-robot":"10.0.46",react:"^18.2.0","react-autosuggest":"10.1.0","react-colorful":"5.6.1","react-dnd":"16.0.1","react-dnd-html5-backend":"16.0.1","react-dom":"^18.2.0","react-hotkeys-hook":"4.4.1","react-i18next":"13.0.1","react-icons":"^4.10.1","react-icons-picker":"^1.0.9","react-quill":"^2.0.0","react-textarea-autosize":"^8.5.2","react-wrap-balancer":"^1.0.0","redux-undo":"1.1.0",sonner:"^1.2.0","tailwind-merge":"1.13.2","tailwindcss-animate":"1.0.6","tippy.js":"^6.3.7","unist-util-visit":"^4.1.2","unsplash-js":"^7.0.18"},Hc={"@commitlint/cli":"17.7.1","@commitlint/config-conventional":"17.7.0","@faker-js/faker":"^8.3.1","@nozbe/watermelondb":"^0.27.1","@playwright/test":"^1.39.0","@tanstack/eslint-plugin-query":"^5.8.4","@types/better-sqlite3":"^7.6.7","@types/jest":"^29.5.7","@types/lodash":"^4.14.200","@types/node":"^20.8.10","@types/react":"^18.2.15","@types/react-dom":"^18.2.7","@typescript-eslint/eslint-plugin":"^6.0.0","@typescript-eslint/parser":"^6.0.0","@vitejs/plugin-react-swc":"^3.3.2",autoprefixer:"^10.4.16","better-docs":"^2.7.2","better-sqlite3":"^9.1.1","drizzle-kit":"^0.20.4","drizzle-orm":"^0.29.0",eslint:"^8.45.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.4.3",jest:"^29.7.0","jest-environment-jsdom":"^29.7.0",jsdoc:"^4.0.2",msw:"^2.0.8",postcss:"^8.4.31",prettier:"^3.0.3","prettier-plugin-tailwindcss":"^0.5.6","prop-types":"^15.8.1","react-router-dom":"^6.19.0",tailwindcss:"^3.3.5","ts-jest":"^29.1.1",typescript:"^5.0.2",vite:"^4.4.5","vite-plugin-dts":"^3.6.3"},Gc={workerDirectory:"public"},Wc={name:Tc,private:!1,version:Uc,type:Fc,files:qc,main:$c,sideEffects:Vc,exports:Qc,scripts:Kc,dependencies:zc,devDependencies:Hc,msw:Gc},Ar="https://api.chaibuilder.com",Pr=()=>typeof window>"u"?!1:window.location.href.includes("localhost");function Yc(){return{name:"chaibuilder-analytics",config:{},initialize:()=>{if(typeof window>"u")return!1;window.chaibuilderAnalyticsLoaded=!0},page:e=>{if(typeof window>"u")return!1;if(Pr())return;const{payload:t}=e;fetch(`${Ar}/v1/log`,{method:"post",body:JSON.stringify(t)}).then(s=>s.json())},track:({payload:e})=>{if(typeof window>"u")return!1;Pr()||fetch(`${Ar}/v1/log`,{method:"post",body:JSON.stringify(e)})},loaded:()=>typeof window>"u"?!0:!!window.chaibuilderAnalyticsLoaded}}const Jc=Nc({app:"chaibuilder",version:Wc.version,plugins:[Yc()]});({}).NODE_ENV==="development"&&console.log("Chai Builder:",No);const Zc=e=>k.jsxRuntimeExports.jsx(k.jsxRuntimeExports.Fragment,{children:e.children}),Xc=e=>{const{dndOptions:t={backend:qn.MultiBackend}}=e,[s]=ei(),[,n]=kn(),r=Mi();return L.useEffect(()=>{$u.set(ve.chaiBuilderPropsAtom,d.omit(e,["blocks","globalBlocks","brandingOptions"]))},[e]),L.useEffect(()=>{s(zr.syncBlocksWithDefaults(e.blocks||[])),r()},[e.blocks]),L.useEffect(()=>{n(e.brandingOptions)},[e.brandingOptions]),L.useEffect(()=>{Jc.page()},[]),k.jsxRuntimeExports.jsx(ko.DndProvider,{...t,options:qn.getBackendOptions(),children:k.jsxRuntimeExports.jsx(Zc,{children:k.jsxRuntimeExports.jsx(qu,{})})})},ro=e=>k.jsxRuntimeExports.jsxs(Hr,{children:[k.jsxRuntimeExports.jsx(Eo.FlagsProvider,{features:To,children:k.jsxRuntimeExports.jsx(Xc,{...e})}),k.jsxRuntimeExports.jsx(ve.Toaster,{})]});var Tt=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Mt=typeof window>"u"||"Deno"in window;function ye(){}function el(e,t){return typeof e=="function"?e(t):e}function rn(e){return typeof e=="number"&&e>=0&&e!==1/0}function io(e,t){return Math.max(e+(t||0)-Date.now(),0)}function jr(e,t){const{type:s="all",exact:n,fetchStatus:r,predicate:i,queryKey:o,stale:u}=e;if(o){if(n){if(t.queryHash!==Nn(o,t.options))return!1}else if(!Yt(t.queryKey,o))return!1}if(s!=="all"){const l=t.isActive();if(s==="active"&&!l||s==="inactive"&&l)return!1}return!(typeof u=="boolean"&&t.isStale()!==u||typeof r<"u"&&r!==t.state.fetchStatus||i&&!i(t))}function Cr(e,t){const{exact:s,status:n,predicate:r,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(s){if(Wt(t.options.mutationKey)!==Wt(i))return!1}else if(!Yt(t.options.mutationKey,i))return!1}return!(n&&t.state.status!==n||r&&!r(t))}function Nn(e,t){return((t==null?void 0:t.queryKeyHashFn)||Wt)(e)}function Wt(e){return JSON.stringify(e,(t,s)=>on(s)?Object.keys(s).sort().reduce((n,r)=>(n[r]=s[r],n),{}):s)}function Yt(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(s=>!Yt(e[s],t[s])):!1}function oo(e,t){if(e===t)return e;const s=Or(e)&&Or(t);if(s||on(e)&&on(t)){const n=s?e.length:Object.keys(e).length,r=s?t:Object.keys(t),i=r.length,o=s?[]:{};let u=0;for(let l=0;l<i;l++){const c=s?l:r[l];o[c]=oo(e[c],t[c]),o[c]===e[c]&&u++}return n===i&&u===n?e:o}return t}function Os(e,t){if(e&&!t||t&&!e)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function Or(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function on(e){if(!Rr(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const s=t.prototype;return!(!Rr(s)||!s.hasOwnProperty("isPrototypeOf"))}function Rr(e){return Object.prototype.toString.call(e)==="[object Object]"}function ao(e){return new Promise(t=>{setTimeout(t,e)})}function Br(e){ao(0).then(e)}function an(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?oo(e,t):t}function tl(e,t,s=0){const n=[...e,t];return s&&n.length>s?n.slice(1):n}function sl(e,t,s=0){const n=[t,...e];return s&&n.length>s?n.slice(0,-1):n}var Ge,Ne,gt,Mr,nl=(Mr=class extends Tt{constructor(){super();I(this,Ge,void 0);I(this,Ne,void 0);I(this,gt,void 0);A(this,gt,t=>{if(!Mt&&window.addEventListener){const s=()=>t();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){a(this,Ne)||this.setEventListener(a(this,gt))}onUnsubscribe(){var t;this.hasListeners()||((t=a(this,Ne))==null||t.call(this),A(this,Ne,void 0))}setEventListener(t){var s;A(this,gt,t),(s=a(this,Ne))==null||s.call(this),A(this,Ne,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){a(this,Ge)!==t&&(A(this,Ge,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof a(this,Ge)=="boolean"?a(this,Ge):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Ge=new WeakMap,Ne=new WeakMap,gt=new WeakMap,Mr),Rs=new nl,yt,Te,vt,Lr,rl=(Lr=class extends Tt{constructor(){super();I(this,yt,!0);I(this,Te,void 0);I(this,vt,void 0);A(this,vt,t=>{if(!Mt&&window.addEventListener){const s=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",n)}}})}onSubscribe(){a(this,Te)||this.setEventListener(a(this,vt))}onUnsubscribe(){var t;this.hasListeners()||((t=a(this,Te))==null||t.call(this),A(this,Te,void 0))}setEventListener(t){var s;A(this,vt,t),(s=a(this,Te))==null||s.call(this),A(this,Te,t(this.setOnline.bind(this)))}setOnline(t){a(this,yt)!==t&&(A(this,yt,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return a(this,yt)}},yt=new WeakMap,Te=new WeakMap,vt=new WeakMap,Lr),Bs=new rl;function il(e){return Math.min(1e3*2**e,3e4)}function qs(e){return(e??"online")==="online"?Bs.isOnline():!0}var uo=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Js(e){return e instanceof uo}function co(e){let t=!1,s=0,n=!1,r,i,o;const u=new Promise((b,C)=>{i=b,o=C}),l=b=>{var C;n||(v(new uo(b)),(C=e.abort)==null||C.call(e))},c=()=>{t=!0},h=()=>{t=!1},g=()=>!Rs.isFocused()||e.networkMode!=="always"&&!Bs.isOnline(),P=b=>{var C;n||(n=!0,(C=e.onSuccess)==null||C.call(e,b),r==null||r(),i(b))},v=b=>{var C;n||(n=!0,(C=e.onError)==null||C.call(e,b),r==null||r(),o(b))},R=()=>new Promise(b=>{var C;r=U=>{const M=n||!g();return M&&b(U),M},(C=e.onPause)==null||C.call(e)}).then(()=>{var b;r=void 0,n||(b=e.onContinue)==null||b.call(e)}),B=()=>{if(n)return;let b;try{b=e.fn()}catch(C){b=Promise.reject(C)}Promise.resolve(b).then(P).catch(C=>{var q;if(n)return;const U=e.retry??(Mt?0:3),M=e.retryDelay??il,E=typeof M=="function"?M(s,C):M,j=U===!0||typeof U=="number"&&s<U||typeof U=="function"&&U(s,C);if(t||!j){v(C);return}s++,(q=e.onFail)==null||q.call(e,s,C),ao(E).then(()=>{if(g())return R()}).then(()=>{t?v(C):B()})})};return qs(e.networkMode)?B():R().then(B),{promise:u,cancel:l,continue:()=>(r==null?void 0:r())?u:Promise.resolve(),cancelRetry:c,continueRetry:h}}function ol(){let e=[],t=0,s=h=>{h()},n=h=>{h()};const r=h=>{let g;t++;try{g=h()}finally{t--,t||u()}return g},i=h=>{t?e.push(h):Br(()=>{s(h)})},o=h=>(...g)=>{i(()=>{h(...g)})},u=()=>{const h=e;e=[],h.length&&Br(()=>{n(()=>{h.forEach(g=>{s(g)})})})};return{batch:r,batchCalls:o,schedule:i,setNotifyFunction:h=>{s=h},setBatchNotifyFunction:h=>{n=h}}}var se=ol(),We,Nr,lo=(Nr=class{constructor(){I(this,We,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),rn(this.gcTime)&&A(this,We,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Mt?1/0:5*60*1e3))}clearGcTimeout(){a(this,We)&&(clearTimeout(a(this,We)),A(this,We,void 0))}},We=new WeakMap,Nr),bt,xt,he,Ue,pe,ne,Jt,Ye,wt,Es,we,Oe,Tr,al=(Tr=class extends lo{constructor(t){super();I(this,wt);I(this,we);I(this,bt,void 0);I(this,xt,void 0);I(this,he,void 0);I(this,Ue,void 0);I(this,pe,void 0);I(this,ne,void 0);I(this,Jt,void 0);I(this,Ye,void 0);A(this,Ye,!1),A(this,Jt,t.defaultOptions),K(this,wt,Es).call(this,t.options),A(this,ne,[]),A(this,he,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,A(this,bt,t.state||ul(this.options)),this.state=a(this,bt),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!a(this,ne).length&&this.state.fetchStatus==="idle"&&a(this,he).remove(this)}setData(t,s){const n=an(this.state.data,t,this.options);return K(this,we,Oe).call(this,{data:n,type:"success",dataUpdatedAt:s==null?void 0:s.updatedAt,manual:s==null?void 0:s.manual}),n}setState(t,s){K(this,we,Oe).call(this,{type:"setState",state:t,setStateOptions:s})}cancel(t){var n;const s=a(this,Ue);return(n=a(this,pe))==null||n.cancel(t),s?s.then(ye).catch(ye):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(a(this,bt))}isActive(){return a(this,ne).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||a(this,ne).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!io(this.state.dataUpdatedAt,t)}onFocus(){var s;const t=a(this,ne).find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(s=a(this,pe))==null||s.continue()}onOnline(){var s;const t=a(this,ne).find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(s=a(this,pe))==null||s.continue()}addObserver(t){a(this,ne).includes(t)||(a(this,ne).push(t),this.clearGcTimeout(),a(this,he).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){a(this,ne).includes(t)&&(A(this,ne,a(this,ne).filter(s=>s!==t)),a(this,ne).length||(a(this,pe)&&(a(this,Ye)?a(this,pe).cancel({revert:!0}):a(this,pe).cancelRetry()),this.scheduleGc()),a(this,he).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return a(this,ne).length}invalidate(){this.state.isInvalidated||K(this,we,Oe).call(this,{type:"invalidate"})}fetch(t,s){var c,h,g,P;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(a(this,Ue))return(c=a(this,pe))==null||c.continueRetry(),a(this,Ue)}if(t&&K(this,wt,Es).call(this,t),!this.options.queryFn){const v=a(this,ne).find(R=>R.options.queryFn);v&&K(this,wt,Es).call(this,v.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,r={queryKey:this.queryKey,meta:this.meta},i=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>(A(this,Ye,!0),n.signal)})};i(r);const o=()=>this.options.queryFn?(A(this,Ye,!1),this.options.persister?this.options.persister(this.options.queryFn,r,this):this.options.queryFn(r)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),u={fetchOptions:s,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:o};i(u),(h=this.options.behavior)==null||h.onFetch(u,this),A(this,xt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((g=u.fetchOptions)==null?void 0:g.meta))&&K(this,we,Oe).call(this,{type:"fetch",meta:(P=u.fetchOptions)==null?void 0:P.meta});const l=v=>{var R,B,b,C;Js(v)&&v.silent||K(this,we,Oe).call(this,{type:"error",error:v}),Js(v)||((B=(R=a(this,he).config).onError)==null||B.call(R,v,this),(C=(b=a(this,he).config).onSettled)==null||C.call(b,this.state.data,v,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return A(this,pe,co({fn:u.fetchFn,abort:n.abort.bind(n),onSuccess:v=>{var R,B,b,C;if(typeof v>"u"){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),l(new Error(`${this.queryHash} data is undefined`));return}this.setData(v),(B=(R=a(this,he).config).onSuccess)==null||B.call(R,v,this),(C=(b=a(this,he).config).onSettled)==null||C.call(b,v,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:l,onFail:(v,R)=>{K(this,we,Oe).call(this,{type:"failed",failureCount:v,error:R})},onPause:()=>{K(this,we,Oe).call(this,{type:"pause"})},onContinue:()=>{K(this,we,Oe).call(this,{type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode})),A(this,Ue,a(this,pe).promise),a(this,Ue)}},bt=new WeakMap,xt=new WeakMap,he=new WeakMap,Ue=new WeakMap,pe=new WeakMap,ne=new WeakMap,Jt=new WeakMap,Ye=new WeakMap,wt=new WeakSet,Es=function(t){this.options={...a(this,Jt),...t},this.updateGcTime(this.options.gcTime)},we=new WeakSet,Oe=function(t){const s=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:qs(this.options.networkMode)?"fetching":"paused",...!n.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...n,data:t.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const r=t.error;return Js(r)&&r.revert&&a(this,xt)?{...a(this,xt),fetchStatus:"idle"}:{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=s(this.state),se.batch(()=>{a(this,ne).forEach(n=>{n.onQueryUpdate()}),a(this,he).notify({query:this,type:"updated",action:t})})},Tr);function ul(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=typeof t<"u",n=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var ke,Ur,cl=(Ur=class extends Tt{constructor(t={}){super();I(this,ke,void 0);this.config=t,A(this,ke,new Map)}build(t,s,n){const r=s.queryKey,i=s.queryHash??Nn(r,s);let o=this.get(i);return o||(o=new al({cache:this,queryKey:r,queryHash:i,options:t.defaultQueryOptions(s),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(o)),o}add(t){a(this,ke).has(t.queryHash)||(a(this,ke).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const s=a(this,ke).get(t.queryHash);s&&(t.destroy(),s===t&&a(this,ke).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){se.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return a(this,ke).get(t)}getAll(){return[...a(this,ke).values()]}find(t){const s={exact:!0,...t};return this.getAll().find(n=>jr(s,n))}findAll(t={}){const s=this.getAll();return Object.keys(t).length>0?s.filter(n=>jr(t,n)):s}notify(t){se.batch(()=>{this.listeners.forEach(s=>{s(t)})})}onFocus(){se.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){se.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},ke=new WeakMap,Ur),Ae,Zt,le,St,Pe,Ie,Fr,ll=(Fr=class extends lo{constructor(t){super();I(this,Pe);I(this,Ae,void 0);I(this,Zt,void 0);I(this,le,void 0);I(this,St,void 0);this.mutationId=t.mutationId,A(this,Zt,t.defaultOptions),A(this,le,t.mutationCache),A(this,Ae,[]),this.state=t.state||fo(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...a(this,Zt),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){a(this,Ae).includes(t)||(a(this,Ae).push(t),this.clearGcTimeout(),a(this,le).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){A(this,Ae,a(this,Ae).filter(s=>s!==t)),this.scheduleGc(),a(this,le).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){a(this,Ae).length||(this.state.status==="pending"?this.scheduleGc():a(this,le).remove(this))}continue(){var t;return((t=a(this,St))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var r,i,o,u,l,c,h,g,P,v,R,B,b,C,U,M,E,j,q,F;const s=()=>(A(this,St,co({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(N,m)=>{K(this,Pe,Ie).call(this,{type:"failed",failureCount:N,error:m})},onPause:()=>{K(this,Pe,Ie).call(this,{type:"pause"})},onContinue:()=>{K(this,Pe,Ie).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),a(this,St).promise),n=this.state.status==="pending";try{if(!n){K(this,Pe,Ie).call(this,{type:"pending",variables:t}),await((i=(r=a(this,le).config).onMutate)==null?void 0:i.call(r,t,this));const m=await((u=(o=this.options).onMutate)==null?void 0:u.call(o,t));m!==this.state.context&&K(this,Pe,Ie).call(this,{type:"pending",context:m,variables:t})}const N=await s();return await((c=(l=a(this,le).config).onSuccess)==null?void 0:c.call(l,N,t,this.state.context,this)),await((g=(h=this.options).onSuccess)==null?void 0:g.call(h,N,t,this.state.context)),await((v=(P=a(this,le).config).onSettled)==null?void 0:v.call(P,N,null,this.state.variables,this.state.context,this)),await((B=(R=this.options).onSettled)==null?void 0:B.call(R,N,null,t,this.state.context)),K(this,Pe,Ie).call(this,{type:"success",data:N}),N}catch(N){try{throw await((C=(b=a(this,le).config).onError)==null?void 0:C.call(b,N,t,this.state.context,this)),await((M=(U=this.options).onError)==null?void 0:M.call(U,N,t,this.state.context)),await((j=(E=a(this,le).config).onSettled)==null?void 0:j.call(E,void 0,N,this.state.variables,this.state.context,this)),await((F=(q=this.options).onSettled)==null?void 0:F.call(q,void 0,N,t,this.state.context)),N}finally{K(this,Pe,Ie).call(this,{type:"error",error:N})}}}},Ae=new WeakMap,Zt=new WeakMap,le=new WeakMap,St=new WeakMap,Pe=new WeakSet,Ie=function(t){const s=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!qs(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=s(this.state),se.batch(()=>{a(this,Ae).forEach(n=>{n.onMutationUpdate(t)}),a(this,le).notify({mutation:this,type:"updated",action:t})})},Fr);function fo(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var me,Xt,Je,qr,dl=(qr=class extends Tt{constructor(t={}){super();I(this,me,void 0);I(this,Xt,void 0);I(this,Je,void 0);this.config=t,A(this,me,[]),A(this,Xt,0)}build(t,s,n){const r=new ll({mutationCache:this,mutationId:++ps(this,Xt)._,options:t.defaultMutationOptions(s),state:n});return this.add(r),r}add(t){a(this,me).push(t),this.notify({type:"added",mutation:t})}remove(t){A(this,me,a(this,me).filter(s=>s!==t)),this.notify({type:"removed",mutation:t})}clear(){se.batch(()=>{a(this,me).forEach(t=>{this.remove(t)})})}getAll(){return a(this,me)}find(t){const s={exact:!0,...t};return a(this,me).find(n=>Cr(s,n))}findAll(t={}){return a(this,me).filter(s=>Cr(t,s))}notify(t){se.batch(()=>{this.listeners.forEach(s=>{s(t)})})}resumePausedMutations(){return A(this,Je,(a(this,Je)??Promise.resolve()).then(()=>{const t=a(this,me).filter(s=>s.state.isPaused);return se.batch(()=>t.reduce((s,n)=>s.then(()=>n.continue().catch(ye)),Promise.resolve()))}).then(()=>{A(this,Je,void 0)})),a(this,Je)}},me=new WeakMap,Xt=new WeakMap,Je=new WeakMap,qr);function fl(e){return{onFetch:(t,s)=>{const n=async()=>{var R,B,b,C,U;const r=t.options,i=(b=(B=(R=t.fetchOptions)==null?void 0:R.meta)==null?void 0:B.fetchMore)==null?void 0:b.direction,o=((C=t.state.data)==null?void 0:C.pages)||[],u=((U=t.state.data)==null?void 0:U.pageParams)||[],l={pages:[],pageParams:[]};let c=!1;const h=M=>{Object.defineProperty(M,"signal",{enumerable:!0,get:()=>(t.signal.aborted?c=!0:t.signal.addEventListener("abort",()=>{c=!0}),t.signal)})},g=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),P=async(M,E,j)=>{if(c)return Promise.reject();if(E==null&&M.pages.length)return Promise.resolve(M);const q={queryKey:t.queryKey,pageParam:E,direction:j?"backward":"forward",meta:t.options.meta};h(q);const F=await g(q),{maxPages:N}=t.options,m=j?sl:tl;return{pages:m(M.pages,F,N),pageParams:m(M.pageParams,E,N)}};let v;if(i&&o.length){const M=i==="backward",E=M?hl:_r,j={pages:o,pageParams:u},q=E(r,j);v=await P(j,q,M)}else{v=await P(l,u[0]??r.initialPageParam);const M=e??o.length;for(let E=1;E<M;E++){const j=_r(r,v);v=await P(v,j)}}return v};t.options.persister?t.fetchFn=()=>{var r,i;return(i=(r=t.options).persister)==null?void 0:i.call(r,n,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s)}:t.fetchFn=n}}}function _r(e,{pages:t,pageParams:s}){const n=t.length-1;return e.getNextPageParam(t[n],t,s[n],s)}function hl(e,{pages:t,pageParams:s}){var n;return(n=e.getPreviousPageParam)==null?void 0:n.call(e,t[0],t,s[0],s)}var te,Fe,qe,Et,kt,$e,At,Pt,$r,pl=($r=class{constructor(e={}){I(this,te,void 0);I(this,Fe,void 0);I(this,qe,void 0);I(this,Et,void 0);I(this,kt,void 0);I(this,$e,void 0);I(this,At,void 0);I(this,Pt,void 0);A(this,te,e.queryCache||new cl),A(this,Fe,e.mutationCache||new dl),A(this,qe,e.defaultOptions||{}),A(this,Et,new Map),A(this,kt,new Map),A(this,$e,0)}mount(){ps(this,$e)._++,a(this,$e)===1&&(A(this,At,Rs.subscribe(()=>{Rs.isFocused()&&(this.resumePausedMutations(),a(this,te).onFocus())})),A(this,Pt,Bs.subscribe(()=>{Bs.isOnline()&&(this.resumePausedMutations(),a(this,te).onOnline())})))}unmount(){var e,t;ps(this,$e)._--,a(this,$e)===0&&((e=a(this,At))==null||e.call(this),A(this,At,void 0),(t=a(this,Pt))==null||t.call(this),A(this,Pt,void 0))}isFetching(e){return a(this,te).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return a(this,Fe).findAll({...e,status:"pending"}).length}getQueryData(e){var t;return(t=a(this,te).find({queryKey:e}))==null?void 0:t.state.data}ensureQueryData(e){const t=this.getQueryData(e.queryKey);return t!==void 0?Promise.resolve(t):this.fetchQuery(e)}getQueriesData(e){return this.getQueryCache().findAll(e).map(({queryKey:t,state:s})=>{const n=s.data;return[t,n]})}setQueryData(e,t,s){const n=a(this,te).find({queryKey:e}),r=n==null?void 0:n.state.data,i=el(t,r);if(typeof i>"u")return;const o=this.defaultQueryOptions({queryKey:e});return a(this,te).build(this,o).setData(i,{...s,manual:!0})}setQueriesData(e,t,s){return se.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,s)]))}getQueryState(e){var t;return(t=a(this,te).find({queryKey:e}))==null?void 0:t.state}removeQueries(e){const t=a(this,te);se.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=a(this,te),n={type:"active",...e};return se.batch(()=>(s.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries(n,t)))}cancelQueries(e={},t={}){const s={revert:!0,...t},n=se.batch(()=>a(this,te).findAll(e).map(r=>r.cancel(s)));return Promise.all(n).then(ye).catch(ye)}invalidateQueries(e={},t={}){return se.batch(()=>{if(a(this,te).findAll(e).forEach(n=>{n.invalidate()}),e.refetchType==="none")return Promise.resolve();const s={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(s,t)})}refetchQueries(e={},t){const s={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},n=se.batch(()=>a(this,te).findAll(e).filter(r=>!r.isDisabled()).map(r=>{let i=r.fetch(void 0,s);return s.throwOnError||(i=i.catch(ye)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(ye)}fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const s=a(this,te).build(this,t);return s.isStaleByTime(t.staleTime)?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ye).catch(ye)}fetchInfiniteQuery(e){return e.behavior=fl(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ye).catch(ye)}resumePausedMutations(){return a(this,Fe).resumePausedMutations()}getQueryCache(){return a(this,te)}getMutationCache(){return a(this,Fe)}getDefaultOptions(){return a(this,qe)}setDefaultOptions(e){A(this,qe,e)}setQueryDefaults(e,t){a(this,Et).set(Wt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...a(this,Et).values()];let s={};return t.forEach(n=>{Yt(e,n.queryKey)&&(s={...s,...n.defaultOptions})}),s}setMutationDefaults(e,t){a(this,kt).set(Wt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...a(this,kt).values()];let s={};return t.forEach(n=>{Yt(e,n.mutationKey)&&(s={...s,...n.defaultOptions})}),s}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...a(this,qe).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Nn(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...a(this,qe).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){a(this,te).clear(),a(this,Fe).clear()}},te=new WeakMap,Fe=new WeakMap,qe=new WeakMap,Et=new WeakMap,kt=new WeakMap,$e=new WeakMap,At=new WeakMap,Pt=new WeakMap,$r),ce,X,jt,oe,Ze,Ct,je,es,Ot,Rt,Xe,et,Ve,tt,st,$t,ts,un,ss,cn,ns,ln,rs,dn,is,fn,os,hn,as,pn,_s,ho,Vr,ml=(Vr=class extends Tt{constructor(t,s){super();I(this,st);I(this,ts);I(this,ss);I(this,ns);I(this,rs);I(this,is);I(this,os);I(this,as);I(this,_s);I(this,ce,void 0);I(this,X,void 0);I(this,jt,void 0);I(this,oe,void 0);I(this,Ze,void 0);I(this,Ct,void 0);I(this,je,void 0);I(this,es,void 0);I(this,Ot,void 0);I(this,Rt,void 0);I(this,Xe,void 0);I(this,et,void 0);I(this,Ve,void 0);I(this,tt,void 0);A(this,X,void 0),A(this,jt,void 0),A(this,oe,void 0),A(this,tt,new Set),A(this,ce,t),this.options=s,A(this,je,null),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(a(this,X).addObserver(this),Ir(a(this,X),this.options)?K(this,st,$t).call(this):this.updateResult(),K(this,rs,dn).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return mn(a(this,X),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return mn(a(this,X),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,K(this,is,fn).call(this),K(this,os,hn).call(this),a(this,X).removeObserver(this)}setOptions(t,s){const n=this.options,r=a(this,X);if(this.options=a(this,ce).defaultQueryOptions(t),Os(n,this.options)||a(this,ce).getQueryCache().notify({type:"observerOptionsUpdated",query:a(this,X),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=n.queryKey),K(this,as,pn).call(this);const i=this.hasListeners();i&&Dr(a(this,X),r,this.options,n)&&K(this,st,$t).call(this),this.updateResult(s),i&&(a(this,X)!==r||this.options.enabled!==n.enabled||this.options.staleTime!==n.staleTime)&&K(this,ts,un).call(this);const o=K(this,ss,cn).call(this);i&&(a(this,X)!==r||this.options.enabled!==n.enabled||o!==a(this,Ve))&&K(this,ns,ln).call(this,o)}getOptimisticResult(t){const s=a(this,ce).getQueryCache().build(a(this,ce),t),n=this.createResult(s,t);return yl(this,n)&&(A(this,oe,n),A(this,Ct,this.options),A(this,Ze,a(this,X).state)),n}getCurrentResult(){return a(this,oe)}trackResult(t){const s={};return Object.keys(t).forEach(n=>{Object.defineProperty(s,n,{configurable:!1,enumerable:!0,get:()=>(a(this,tt).add(n),t[n])})}),s}getCurrentQuery(){return a(this,X)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=a(this,ce).defaultQueryOptions(t),n=a(this,ce).getQueryCache().build(a(this,ce),s);return n.isFetchingOptimistic=!0,n.fetch().then(()=>this.createResult(n,s))}fetch(t){return K(this,st,$t).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),a(this,oe)))}createResult(t,s){var q;const n=a(this,X),r=this.options,i=a(this,oe),o=a(this,Ze),u=a(this,Ct),c=t!==n?t.state:a(this,jt),{state:h}=t;let{error:g,errorUpdatedAt:P,fetchStatus:v,status:R}=h,B=!1,b;if(s._optimisticResults){const F=this.hasListeners(),N=!F&&Ir(t,s),m=F&&Dr(t,n,s,r);(N||m)&&(v=qs(t.options.networkMode)?"fetching":"paused",h.dataUpdatedAt||(R="pending")),s._optimisticResults==="isRestoring"&&(v="idle")}if(s.select&&typeof h.data<"u")if(i&&h.data===(o==null?void 0:o.data)&&s.select===a(this,es))b=a(this,Ot);else try{A(this,es,s.select),b=s.select(h.data),b=an(i==null?void 0:i.data,b,s),A(this,Ot,b),A(this,je,null)}catch(F){A(this,je,F)}else b=h.data;if(typeof s.placeholderData<"u"&&typeof b>"u"&&R==="pending"){let F;if(i!=null&&i.isPlaceholderData&&s.placeholderData===(u==null?void 0:u.placeholderData))F=i.data;else if(F=typeof s.placeholderData=="function"?s.placeholderData((q=a(this,Rt))==null?void 0:q.state.data,a(this,Rt)):s.placeholderData,s.select&&typeof F<"u")try{F=s.select(F),A(this,je,null)}catch(N){A(this,je,N)}typeof F<"u"&&(R="success",b=an(i==null?void 0:i.data,F,s),B=!0)}a(this,je)&&(g=a(this,je),b=a(this,Ot),P=Date.now(),R="error");const C=v==="fetching",U=R==="pending",M=R==="error",E=U&&C;return{status:R,fetchStatus:v,isPending:U,isSuccess:R==="success",isError:M,isInitialLoading:E,isLoading:E,data:b,dataUpdatedAt:h.dataUpdatedAt,error:g,errorUpdatedAt:P,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>c.dataUpdateCount||h.errorUpdateCount>c.errorUpdateCount,isFetching:C,isRefetching:C&&!U,isLoadingError:M&&h.dataUpdatedAt===0,isPaused:v==="paused",isPlaceholderData:B,isRefetchError:M&&h.dataUpdatedAt!==0,isStale:Tn(t,s),refetch:this.refetch}}updateResult(t){const s=a(this,oe),n=this.createResult(a(this,X),this.options);if(A(this,Ze,a(this,X).state),A(this,Ct,this.options),a(this,Ze).data!==void 0&&A(this,Rt,a(this,X)),Os(n,s))return;A(this,oe,n);const r={},i=()=>{if(!s)return!0;const{notifyOnChangeProps:o}=this.options,u=typeof o=="function"?o():o;if(u==="all"||!u&&!a(this,tt).size)return!0;const l=new Set(u??a(this,tt));return this.options.throwOnError&&l.add("error"),Object.keys(a(this,oe)).some(c=>{const h=c;return a(this,oe)[h]!==s[h]&&l.has(h)})};(t==null?void 0:t.listeners)!==!1&&i()&&(r.listeners=!0),K(this,_s,ho).call(this,{...r,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&K(this,rs,dn).call(this)}},ce=new WeakMap,X=new WeakMap,jt=new WeakMap,oe=new WeakMap,Ze=new WeakMap,Ct=new WeakMap,je=new WeakMap,es=new WeakMap,Ot=new WeakMap,Rt=new WeakMap,Xe=new WeakMap,et=new WeakMap,Ve=new WeakMap,tt=new WeakMap,st=new WeakSet,$t=function(t){K(this,as,pn).call(this);let s=a(this,X).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(ye)),s},ts=new WeakSet,un=function(){if(K(this,is,fn).call(this),Mt||a(this,oe).isStale||!rn(this.options.staleTime))return;const s=io(a(this,oe).dataUpdatedAt,this.options.staleTime)+1;A(this,Xe,setTimeout(()=>{a(this,oe).isStale||this.updateResult()},s))},ss=new WeakSet,cn=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(a(this,X)):this.options.refetchInterval)??!1},ns=new WeakSet,ln=function(t){K(this,os,hn).call(this),A(this,Ve,t),!(Mt||this.options.enabled===!1||!rn(a(this,Ve))||a(this,Ve)===0)&&A(this,et,setInterval(()=>{(this.options.refetchIntervalInBackground||Rs.isFocused())&&K(this,st,$t).call(this)},a(this,Ve)))},rs=new WeakSet,dn=function(){K(this,ts,un).call(this),K(this,ns,ln).call(this,K(this,ss,cn).call(this))},is=new WeakSet,fn=function(){a(this,Xe)&&(clearTimeout(a(this,Xe)),A(this,Xe,void 0))},os=new WeakSet,hn=function(){a(this,et)&&(clearInterval(a(this,et)),A(this,et,void 0))},as=new WeakSet,pn=function(){const t=a(this,ce).getQueryCache().build(a(this,ce),this.options);if(t===a(this,X))return;const s=a(this,X);A(this,X,t),A(this,jt,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},_s=new WeakSet,ho=function(t){se.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(a(this,oe))}),a(this,ce).getQueryCache().notify({query:a(this,X),type:"observerResultsUpdated"})})},Vr);function gl(e,t){return t.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ir(e,t){return gl(e,t)||e.state.dataUpdatedAt>0&&mn(e,t,t.refetchOnMount)}function mn(e,t,s){if(t.enabled!==!1){const n=typeof s=="function"?s(e):s;return n==="always"||n!==!1&&Tn(e,t)}return!1}function Dr(e,t,s,n){return s.enabled!==!1&&(e!==t||n.enabled===!1)&&(!s.suspense||e.state.status!=="error")&&Tn(e,s)}function Tn(e,t){return e.isStaleByTime(t.staleTime)}function yl(e,t){return!Os(e.getCurrentResult(),t)}var Qe,ae,ge,Re,Bt,ks,us,gn,Qr,vl=(Qr=class extends Tt{constructor(t,s){super();I(this,Bt);I(this,us);I(this,Qe,void 0);I(this,ae,void 0);I(this,ge,void 0);I(this,Re,void 0);A(this,ae,void 0),A(this,Qe,t),this.setOptions(s),this.bindMethods(),K(this,Bt,ks).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var n;const s=this.options;this.options=a(this,Qe).defaultMutationOptions(t),Os(s,this.options)||a(this,Qe).getMutationCache().notify({type:"observerOptionsUpdated",mutation:a(this,ge),observer:this}),(n=a(this,ge))==null||n.setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=a(this,ge))==null||t.removeObserver(this)}onMutationUpdate(t){K(this,Bt,ks).call(this),K(this,us,gn).call(this,t)}getCurrentResult(){return a(this,ae)}reset(){A(this,ge,void 0),K(this,Bt,ks).call(this),K(this,us,gn).call(this)}mutate(t,s){var n;return A(this,Re,s),(n=a(this,ge))==null||n.removeObserver(this),A(this,ge,a(this,Qe).getMutationCache().build(a(this,Qe),this.options)),a(this,ge).addObserver(this),a(this,ge).execute(t)}},Qe=new WeakMap,ae=new WeakMap,ge=new WeakMap,Re=new WeakMap,Bt=new WeakSet,ks=function(){var s;const t=((s=a(this,ge))==null?void 0:s.state)??fo();A(this,ae,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},us=new WeakSet,gn=function(t){se.batch(()=>{var s,n,r,i,o,u,l,c;a(this,Re)&&this.hasListeners()&&((t==null?void 0:t.type)==="success"?((n=(s=a(this,Re)).onSuccess)==null||n.call(s,t.data,a(this,ae).variables,a(this,ae).context),(i=(r=a(this,Re)).onSettled)==null||i.call(r,t.data,null,a(this,ae).variables,a(this,ae).context)):(t==null?void 0:t.type)==="error"&&((u=(o=a(this,Re)).onError)==null||u.call(o,t.error,a(this,ae).variables,a(this,ae).context),(c=(l=a(this,Re)).onSettled)==null||c.call(l,void 0,t.error,a(this,ae).variables,a(this,ae).context))),this.listeners.forEach(h=>{h(a(this,ae))})})},Qr),po=re.createContext(void 0),ut=e=>{const t=re.useContext(po);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},bl=({client:e,children:t})=>(re.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),re.createElement(po.Provider,{value:e},t)),mo=re.createContext(!1),xl=()=>re.useContext(mo);mo.Provider;function wl(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Sl=re.createContext(wl()),El=()=>re.useContext(Sl);function go(e,t){return typeof e=="function"?e(...t):!!e}var kl=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},Al=e=>{re.useEffect(()=>{e.clearReset()},[e])},Pl=({result:e,errorResetBoundary:t,throwOnError:s,query:n})=>e.isError&&!t.isReset()&&!e.isFetching&&go(s,[e.error,n]),jl=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},Cl=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Ol=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Rl(e,t,s){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=ut(s),r=xl(),i=El(),o=n.defaultQueryOptions(e);o._optimisticResults=r?"isRestoring":"optimistic",jl(o),kl(o,i),Al(i);const[u]=re.useState(()=>new t(n,o)),l=u.getOptimisticResult(o);if(re.useSyncExternalStore(re.useCallback(c=>{const h=r?()=>{}:u.subscribe(se.batchCalls(c));return u.updateResult(),h},[u,r]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),re.useEffect(()=>{u.setOptions(o,{listeners:!1})},[o,u]),Cl(o,l))throw Ol(o,u,i);if(Pl({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:u.getCurrentQuery()}))throw l.error;return o.notifyOnChangeProps?l:u.trackResult(l)}function $s(e,t){return Rl(e,ml,t)}function yo(e,t){const s=ut(t),[n]=re.useState(()=>new vl(s,e));re.useEffect(()=>{n.setOptions(e)},[n,e]);const r=re.useSyncExternalStore(re.useCallback(o=>n.subscribe(se.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=re.useCallback((o,u)=>{n.mutate(o,u).catch(Bl)},[n]);if(r.error&&go(n.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:i,mutateAsync:r.mutate}}function Bl(){}const _l=()=>$s({queryKey:["user"],queryFn:async()=>await localStorage.getItem("__nano_id")}),Il=()=>k.jsxRuntimeExports.jsx("section",{className:"py-10 h-screen bg-gray-50 sm:py-16 lg:py-24",children:k.jsxRuntimeExports.jsxs("div",{className:"px-4 mx-auto max-w-7xl sm:px-6 lg:px-8",children:[k.jsxRuntimeExports.jsxs("div",{className:"max-w-2xl mx-auto text-center",children:[k.jsxRuntimeExports.jsx("h2",{className:"text-3xl font-bold leading-tight text-black sm:text-4xl lg:text-5xl",children:"Welcome Back!"}),k.jsxRuntimeExports.jsx("p",{className:"max-w-xl mx-auto mt-4 text-base leading-relaxed text-gray-600",children:"Login to your account"})]}),k.jsxRuntimeExports.jsx("div",{className:"relative max-w-md mx-auto mt-8 md:mt-16",children:k.jsxRuntimeExports.jsx("div",{className:"overflow-hidden bg-white rounded-md shadow-md",children:k.jsxRuntimeExports.jsx("div",{className:"px-4 py-6 sm:px-8 sm:py-7",children:k.jsxRuntimeExports.jsx("form",{action:"#",method:"POST",children:k.jsxRuntimeExports.jsxs("div",{className:"space-y-5",children:[k.jsxRuntimeExports.jsxs("div",{children:[k.jsxRuntimeExports.jsx("label",{htmlFor:"",className:"text-base font-medium text-gray-900",children:"Email address"}),k.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[k.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:k.jsxRuntimeExports.jsx("svg",{className:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:k.jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M16 12a4 4 0 10-8 0 4 4 0 008 0zm0 0v1.5a2.5 2.5 0 005 0V12a9 9 0 10-9 9m4.5-1.206a8.959 8.959 0 01-4.5 1.207"})})}),k.jsxRuntimeExports.jsx("input",{type:"email",name:"",id:"",placeholder:"Enter email to get started",className:"block w-full py-4 pl-10 pr-4 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"})]})]}),k.jsxRuntimeExports.jsxs("div",{children:[k.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between",children:k.jsxRuntimeExports.jsx("label",{htmlFor:"",className:"text-base font-medium text-gray-900",children:"Password"})}),k.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[k.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:k.jsxRuntimeExports.jsx("svg",{className:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:k.jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 11c0 3.517-1.009 6.799-2.753 9.571m-3.44-2.04l.054-.09A13.916 13.916 0 008 11a4 4 0 118 0c0 1.017-.07 2.019-.203 3m-2.118 6.844A21.88 21.88 0 0015.171 17m3.839 1.132c.645-2.266.99-4.659.99-7.132A8 8 0 008 4.07M3 15.364c.64-1.319 1-2.8 1-4.364 0-1.457.39-2.823 1.07-4"})})}),k.jsxRuntimeExports.jsx("input",{type:"password",name:"",id:"",placeholder:"Enter your password",className:"block w-full py-4 pl-10 pr-4 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"})]})]}),k.jsxRuntimeExports.jsx("div",{children:k.jsxRuntimeExports.jsx("button",{type:"submit",className:"inline-flex items-center justify-center w-full px-4 py-4 text-base font-semibold text-white transition-all duration-200 bg-blue-600 border border-transparent rounded-md focus:outline-none hover:bg-blue-700 focus:bg-blue-700",children:"Log in"})})]})})})})})]})});function fs(){return ut().getQueryData(["apiBaseUrl"])||"/api/chaibuilder"}const Un=()=>{const e=ut();let t=e.getQueryData(["currentPage"]);return t||(t=localStorage.getItem("currentPage")),[t||"",s=>{localStorage.setItem("currentPage",s||""),e.setQueryData(["currentPage"],s||"")}]},Vs=()=>{const[e,t]=Un(),s=fs();return $s({queryKey:["project"],queryFn:async()=>{const n=await fetch(`${s}/project`).then(r=>r.json());return!e&&n&&t(n.homepage),n}})},vo=()=>{const{data:e}=Vs(),t=fs(),s=e==null?void 0:e.uuid;return $s({queryKey:["pages",s],queryFn:async()=>await fetch(`${t}/pages`).then(r=>r.json())||[],enabled:!!s})},Dl=()=>{const[e,t]=Un(),{data:s}=Vs(),n=fs();return $s({queryKey:["page_data",e],queryFn:async()=>{const r=await fetch(`${n}/page?uuid=${e}`);return r.ok?r.json():(t(s.homepage),null)},enabled:!!e})},As=()=>k.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen",children:k.jsxRuntimeExports.jsx("div",{className:"flex h-full w-full justify-center items-center",children:k.jsxRuntimeExports.jsxs("div",{role:"status",children:[k.jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",className:"w-8 mx-auto mb-4 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[k.jsxRuntimeExports.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),k.jsxRuntimeExports.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]}),k.jsxRuntimeExports.jsx("p",{children:"Loading... Please wait..."}),k.jsxRuntimeExports.jsx("span",{className:"sr-only",children:"Loading..."})]})})}),bo=(e="Project updated successfully.")=>{const t=ut(),s=fs();return yo({mutationFn:async n=>await fetch(`${s}/project`,{method:"PUT",body:JSON.stringify(n)}),onSuccess:()=>{t.invalidateQueries({queryKey:["project"]}),Co.toast.success(e)}})},Ml=L.lazy(()=>Promise.resolve().then(()=>require("./PagesPanel-97dbe8c3.cjs"))),Ll=L.lazy(()=>Promise.resolve().then(()=>require("./ProjectPanel-24543eac.cjs"))),Nl=()=>k.jsxRuntimeExports.jsx("h2",{children:"Your Logo"}),Tl=()=>k.jsxRuntimeExports.jsx("div",{className:"border-gray-200 rounded-md p-2 mb-2 border",children:k.jsxRuntimeExports.jsx(jo.LogOutIcon,{className:"w-4 h-4 text-red-500"})}),Ul=()=>k.jsxRuntimeExports.jsx(ve.Button,{className:"bg-blue-600 text-white",children:"Publish"}),Fl=e=>{const{data:t,isLoading:s}=Vs(),{data:n,isLoading:r}=vo(),{data:i}=Dl(),{mutate:o}=bo(),{logo:u=Nl}=e;return s||!t?k.jsxRuntimeExports.jsx(As,{}):r||!n?k.jsxRuntimeExports.jsx(As,{}):i?k.jsxRuntimeExports.jsx("div",{className:"bg-background text-foreground",children:k.jsxRuntimeExports.jsx(ro,{blocks:i.blocks,brandingOptions:t.brandingOptions,darkMode:e.darkMode||!1,onSaveBlocks:async({blocks:l,type:c})=>{console.log(c,l)},onSaveBrandingOptions:async l=>{o({brandingOptions:l})},topBarComponents:{left:[u],right:[Ul]},sideBarComponents:{top:[{icon:$n.FileTextIcon,name:"pages",panel:Ml},{icon:$n.GearIcon,name:"settings",panel:Ll}],bottom:[Tl]}})}):k.jsxRuntimeExports.jsx(As,{})},ql=e=>{const{data:t,isLoading:s}=_l(),n=ut();return L.useEffect(()=>{n.setQueryData(["apiBaseUrl"],e.apiBaseUrl||"/api/chaibuilder")},[e.apiBaseUrl,n]),s?k.jsxRuntimeExports.jsx(As,{}):t?k.jsxRuntimeExports.jsx(Il,{}):k.jsxRuntimeExports.jsx(Fl,{...e})},$l=new pl,Vl=e=>k.jsxRuntimeExports.jsx(bl,{client:$l,children:k.jsxRuntimeExports.jsx(ql,{...e})}),Ql=e=>({...e}),Kl=e=>({...e});exports.ChaiBuilderEditor=ro;exports.ChaiBuilderStudio=Vl;exports.ErrorBoundary=Hr;exports.activePanelAtom=bi;exports.addBlockOffCanvasAtom=xi;exports.addBlocksModalAtom=Xr;exports.advanceStylingOpenAtom=mi;exports.canDeleteBlock=ga;exports.canDropBlock=va;exports.canDuplicateBlock=ma;exports.canvasIframeAtom=vi;exports.editLayerNameAtom=yi;exports.enableStyling=Kl;exports.getBlockJSONFromSchemas=en;exports.getBlockJSONFromUISchemas=Xs;exports.inlineEditingActiveAtom=pi;exports.networkModeAtom=gi;exports.setBlockProps=Ql;exports.showPredefinedBlockCategoryAtom=wi;exports.useActiveLanguage=Li;exports.useActiveModal=hu;exports.useActivePanel=yu;exports.useAddBlock=Aa;exports.useAddBlockParent=vu;exports.useAddClassesToBlocks=Ra;exports.useAllBlocks=ii;exports.useApiBaseUrl=fs;exports.useBlockContentByLanguage=Bu;exports.useBrandingOptions=kn;exports.useBuilderReset=Mi;exports.useBuildingBlocks=ai;exports.useCanvasHistory=ls;exports.useCanvasWidth=Va;exports.useCanvasZoom=Ka;exports.useCopyBlockIds=Pi;exports.useCurrentPage=Un;exports.useCurrentPage$1=ui;exports.useCutBlockIds=Cn;exports.useDarkMode=za;exports.useDeveloperPreviewMode=Ga;exports.useDuplicateBlocks=Rn;exports.useExpandedIds=Lu;exports.useFeatureSupport=Eu;exports.useGetPageData=jn;exports.useHiddenBlockIds=Ya;exports.useHighlightBlockId=Ci;exports.useLanguages=Ru;exports.useMarkAsGlobalBlock=Za;exports.useMoveBlocks=Xa;exports.useMutation=yo;exports.usePages=vo;exports.usePasteBlocks=Oi;exports.usePreviewMode=En;exports.usePrimaryLanguage=Ou;exports.useProject=Vs;exports.useProject$1=su;exports.useQueryClient=ut;exports.useReadOnlyMode=pu;exports.useRemoveBlocks=Bi;exports.useRemoveClassesFromBlocks=ru;exports.useSavePage=$a;exports.useSelectedBlock=Sa;exports.useSelectedBlockAllClasses=iu;exports.useSelectedBlockCurrentClasses=uu;exports.useSelectedBlockIds=ze;exports.useSelectedBlocksDisplayChild=wa;exports.useSelectedBreakpoints=xu;exports.useSelectedStylingBlocks=Sn;exports.useSetAllBlocks=ei;exports.useStylingBreakpoint=Si;exports.useStylingState=cu;exports.useTranslations=Su;exports.useTreeData=pa;exports.useUILibraryBlocks=Au;exports.useUpdateBlocksProps=lu;exports.useUpdateBlocksPropsRealtime=du;exports.useUpdateProject=bo;