@chaibuilder/sdk 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AddBlocks-0916e841.cjs → AddBlocks-1f683caa.cjs} +1 -1
- package/dist/{AddBlocks-c195f577.js → AddBlocks-b6a12d50.js} +1 -1
- package/dist/{BrandingOptions-742992b6.cjs → BrandingOptions-02e4ebcf.cjs} +1 -1
- package/dist/{BrandingOptions-766c19c6.js → BrandingOptions-1190723a.js} +1 -1
- package/dist/{CanvasArea-25800a3e.js → CanvasArea-15458836.js} +2 -2
- package/dist/{CanvasArea-e855c4a2.cjs → CanvasArea-f5d27245.cjs} +2 -2
- package/dist/{Layers-a2169d0b.cjs → Layers-06fa708d.cjs} +1 -1
- package/dist/{Layers-f7e792f6.js → Layers-ff4ef9c0.js} +2 -2
- package/dist/{MarkAsGlobalBlock-6bac1842.js → MarkAsGlobalBlock-dea26aa7.js} +1 -1
- package/dist/{MarkAsGlobalBlock-6187e6fd.cjs → MarkAsGlobalBlock-fa0e0543.cjs} +1 -1
- package/dist/{PagesPanel-0827c264.js → PagesPanel-3e9163c4.js} +2 -2
- package/dist/{PagesPanel-5698953d.cjs → PagesPanel-b08e1357.cjs} +1 -1
- package/dist/{ProjectPanel-e577029a.js → ProjectPanel-17c5f131.js} +5 -5
- package/dist/ProjectPanel-f0b94e3f.cjs +1 -0
- package/dist/{Settings-b214f859.js → Settings-6f2e86a9.js} +1 -1
- package/dist/{Settings-bee21026.cjs → Settings-739cff3b.cjs} +1 -1
- package/dist/{SidePanels-03fa10e8.js → SidePanels-96e64da9.js} +2 -2
- package/dist/{SidePanels-934159a4.cjs → SidePanels-ce4d41d5.cjs} +1 -1
- package/dist/{Topbar-9bc8c9cf.js → Topbar-08d10607.js} +1 -1
- package/dist/{Topbar-c083cc2a.cjs → Topbar-b97472fc.cjs} +1 -1
- package/dist/add-page-modal-3275cfb2.cjs +1 -0
- package/dist/{add-page-modal-63858244.js → add-page-modal-bcd9249e.js} +13 -12
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/delete-page-modal-420a17e3.cjs +1 -0
- package/dist/{delete-page-modal-def9012d.js → delete-page-modal-fa7b4272.js} +4 -4
- package/dist/index-133d90a5.cjs +2 -0
- package/dist/{index-390f7bef.js → index-3f65447f.js} +184 -179
- package/dist/{page-viewer-83ce2c70.cjs → page-viewer-139bfb2a.cjs} +1 -1
- package/dist/{page-viewer-41cbb548.js → page-viewer-f1452439.js} +2 -2
- package/dist/{project-general-setting-2c8bed74.cjs → project-general-setting-0d7715b8.cjs} +1 -1
- package/dist/{project-general-setting-0262fe62.js → project-general-setting-e5d14fa6.js} +1 -1
- package/dist/server.cjs +1 -0
- package/dist/server.d.ts +142 -0
- package/dist/server.js +126 -0
- package/dist/single-page-detail-54d7feca.cjs +1 -0
- package/dist/{single-page-detail-924d57fc.js → single-page-detail-74f88ed2.js} +14 -13
- package/dist/useMutation-7d536740.cjs +1 -0
- package/dist/useMutation-97876a40.js +126 -0
- package/dist/usePageActions-ac9ad321.cjs +1 -0
- package/dist/{usePageActions-f86f6f65.js → usePageActions-de3b7515.js} +12 -11
- package/dist/useProjectActions-3b1dbb5e.js +18 -0
- package/dist/useProjectActions-41af0f70.cjs +1 -0
- package/package.json +7 -2
- package/dist/ProjectPanel-a3cb7396.cjs +0 -1
- package/dist/add-page-modal-cb367c9d.cjs +0 -1
- package/dist/delete-page-modal-1e3914e3.cjs +0 -1
- package/dist/index-207f2cbf.cjs +0 -2
- package/dist/index-824a7bd0.js +0 -188
- package/dist/index-ebd86d7f.cjs +0 -2
- package/dist/single-page-detail-cfeae896.cjs +0 -1
- package/dist/usePageActions-3bed2330.cjs +0 -1
- package/dist/useProjectActions-1de05f63.js +0 -17
- package/dist/useProjectActions-5092ed79.cjs +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var Ns=(e,t,s)=>{if(!t.has(e))throw TypeError("Cannot "+s)};var c=(e,t,s)=>(Ns(e,t,"read from private field"),s?s.call(e):t.get(e)),U=(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)},j=(e,t,s,n)=>(Ns(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s);var as=(e,t,s,n)=>({set _(r){j(e,t,r,s)},get _(){return c(e,t,n)}}),H=(e,t,s)=>(Ns(e,t,"access private method"),s);const B=require("./jsx-runtime-5c3ac4f7.cjs"),ui=require("i18next"),li=require("react-i18next"),di=require("flagged"),L=require("react"),fi=require("react-dnd"),l=require("lodash"),In=require("@minoru/react-dnd-treeview"),be=require("./useBuilderProp-5e57d0c8.cjs"),g=require("jotai"),hi=require("./utils-3c452dd0.cjs"),Ce=require("react-hotkeys-hook"),Mr=require("flat-to-nested"),ie=require("./Class-7d6aadbc.cjs"),Nt=require("redux-undo"),pi=require("@react-hookz/web"),Nr=require("@chaibuilder/blocks"),Dn=require("@radix-ui/react-icons"),me=require("./CONTROLS-031e1de3.cjs");function mi(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 le=mi(L),gi="Dark mode",yi="This page has no blocks. Add a block by clicking the + button",vi="This page is empty",bi="Please select a block to edit settings or styles",xi="Please select a styling block",wi="Drop your block here",Si={dark_mode:gi,tree_view_no_blocks:yi,canvas_empty:vi,no_block_selected_for_styling:bi,no_styling_block_selected:xi,drop_here_message:wi};ui.use(li.initReactI18next).init({resources:{en:{translation:Si}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});const Ei="";const ki={};class Tr 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?B.jsxRuntimeExports.jsx("h1",{children:"Something went wrong."}):this.props.children}}const Ai=e=>{const t=e.replace(me.STYLES_KEY,"").split(",");return{baseClasses:t[0],classes:t[1]}};let Pi=0;function Re(e,t){const s=`atom${++Pi}`,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 Ln=e=>"init"in e,Mn=e=>!!e.write,ys=new WeakMap,Oi=(e,t)=>{ys.set(e,t),e.catch(()=>{}).finally(()=>ys.delete(e))},Nn=(e,t)=>{const s=ys.get(e);s&&(ys.delete(e),s(t))},Tn=(e,t)=>{e.status="fulfilled",e.value=t},Un=(e,t)=>{e.status="rejected",e.reason=t},ji=e=>typeof(e==null?void 0:e.then)=="function",Dt=(e,t)=>"v"in e&&"v"in t&&Object.is(e.v,t.v),Fn=(e,t)=>"e"in e&&"e"in t&&Object.is(e.e,t.e),rt=e=>"v"in e&&e.v instanceof Promise,Ci=(e,t)=>"v"in e&&"v"in t&&e.v.orig&&e.v.orig===t.v.orig,cs=e=>{if("e"in e)throw e.e;return e.v},Bi=()=>{const e=new WeakMap,t=new WeakMap,s=new Map;let n,r,i;const o=m=>e.get(m),a=(m,x)=>{const R=e.get(m);if(e.set(m,x),s.has(m)||s.set(m,R),R&&rt(R)){const S="v"in x?x.v instanceof Promise?x.v:Promise.resolve(x.v):Promise.reject(x.e);Nn(R.v,S)}},f=(m,x,R)=>{const S=new Map;let I=!1;R.forEach((O,E)=>{!O&&E===m&&(O=x),O&&(S.set(E,O),x.d.get(E)!==O&&(I=!0))}),(I||x.d.size!==S.size)&&(x.d=S)},u=(m,x,R)=>{const S=o(m),I={d:(S==null?void 0:S.d)||new Map,v:x};if(R&&f(m,I,R),S&&Dt(S,I)&&S.d===I.d)return S;if(S&&rt(S)&&rt(I)&&Ci(S,I)){if(S.d===I.d)return S;I.v=S.v}return a(m,I),I},h=(m,x,R,S)=>{if(ji(x)){let I;const O=new Promise((E,K)=>{let Q=!1;x.then(W=>{if(!Q){Q=!0;const d=o(m),p=u(m,O,R);Tn(O,W),E(W),(d==null?void 0:d.d)!==p.d&&q(m,p,d==null?void 0:d.d)}},W=>{if(!Q){Q=!0;const d=o(m),p=u(m,O,R);Un(O,W),K(W),(d==null?void 0:d.d)!==p.d&&q(m,p,d==null?void 0:d.d)}}),I=W=>{Q||(Q=!0,W.then(d=>Tn(O,d),d=>Un(O,d)),E(W))}});return O.orig=x,O.status="pending",Oi(O,E=>{E&&I(E),S==null||S()}),u(m,O,R)}return u(m,x,R)},y=(m,x,R)=>{const S=o(m),I={d:(S==null?void 0:S.d)||new Map,e:x};return R&&f(m,I,R),S&&Fn(S,I)&&S.d===I.d?S:(a(m,I),I)},w=m=>{const x=o(m);if(x&&(x.d.forEach((Q,W)=>{W!==m&&!t.has(W)&&w(W)}),Array.from(x.d).every(([Q,W])=>{const d=o(Q);return Q===m||d===W||d&&!rt(d)&&Dt(d,W)})))return x;const R=new Map;let S=!0;const I=Q=>{if(Q===m){const d=o(Q);if(d)return R.set(Q,d),cs(d);if(Ln(Q))return R.set(Q,void 0),Q.init;throw new Error("no atom init")}const W=w(Q);return R.set(Q,W),cs(W)};let O,E;const K={get signal(){return O||(O=new AbortController),O.signal},get setSelf(){return!E&&Mn(m)&&(E=(...Q)=>{if(!S)return D(m,...Q)}),E}};try{const Q=m.read(I,K);return h(m,Q,R,()=>O==null?void 0:O.abort())}catch(Q){return y(m,Q,R)}finally{S=!1}},v=m=>cs(w(m)),C=m=>{let x=t.get(m);return x||(x=k(m)),x},_=(m,x)=>!x.l.size&&(!x.t.size||x.t.size===1&&x.t.has(m)),b=m=>{const x=t.get(m);x&&_(m,x)&&A(m)},P=m=>{const x=new Map,R=new WeakMap,S=O=>{const E=t.get(O);E==null||E.t.forEach(K=>{K!==O&&(x.set(K,(x.get(K)||new Set).add(O)),R.set(K,(R.get(K)||0)+1),S(K))})};S(m);const I=O=>{const E=t.get(O);E==null||E.t.forEach(K=>{var Q;if(K!==O){let W=R.get(K);if(W&&R.set(K,--W),!W){let d=!!((Q=x.get(K))!=null&&Q.size);if(d){const p=o(K),T=w(K);d=!p||!Dt(p,T)}d||x.forEach(p=>p.delete(K))}I(K)}})};I(m)},N=(m,...x)=>{let R=!0;const S=E=>cs(w(E)),I=(E,...K)=>{let Q;if(E===m){if(!Ln(E))throw new Error("atom not writable");const W=o(E),d=h(E,K[0]);(!W||!Dt(W,d))&&P(E)}else Q=N(E,...K);if(!R){const W=F()}return Q},O=m.write(S,I,...x);return R=!1,O},D=(m,...x)=>{const R=N(m,...x),S=F();return R},k=(m,x)=>{const R={t:new Set(x&&[x]),l:new Set};if(t.set(m,R),w(m).d.forEach((S,I)=>{const O=t.get(I);O?O.t.add(m):I!==m&&k(I,m)}),w(m),Mn(m)&&m.onMount){const S=m.onMount((...I)=>D(m,...I));S&&(R.u=S)}return R},A=m=>{var x;const R=(x=t.get(m))==null?void 0:x.u;R&&R(),t.delete(m);const S=o(m);S&&(rt(S)&&Nn(S.v),S.d.forEach((I,O)=>{if(O!==m){const E=t.get(O);E&&(E.t.delete(m),_(O,E)&&A(O))}}))},q=(m,x,R)=>{const S=new Set(x.d.keys());R==null||R.forEach((I,O)=>{if(S.has(O)){S.delete(O);return}const E=t.get(O);E&&(E.t.delete(m),_(O,E)&&A(O))}),S.forEach(I=>{const O=t.get(I);O?O.t.add(m):t.has(m)&&k(I,m)})},F=()=>{let m;for(;s.size;){const x=Array.from(s);s.clear(),x.forEach(([R,S])=>{const I=o(R);if(I){I.d!==(S==null?void 0:S.d)&&q(R,I,S==null?void 0:S.d);const O=t.get(R);O&&!(S&&!rt(S)&&(Dt(S,I)||Fn(S,I)))&&O.l.forEach(E=>E())}})}};return{get:v,set:D,sub:(m,x)=>{const R=C(m),S=F(),I=R.l;return I.add(x),()=>{I.delete(x),b(m)}}}};let Ts;const _i=()=>(Ts||(Ts=Bi()),Ts),Ri=Symbol();function Ii(e,t){const s=Re(e,(n,r,i)=>r(s,t(n(s),i)));return s}const qn=(e,t,s)=>(t.has(s)?t:t.set(s,e())).get(s),Di=new WeakMap,Li=(e,t,s)=>{const n=qn(()=>new WeakMap,Di,t);return qn(e,n,s)},Mi={},$n=e=>!!e.write,Ni=e=>typeof e=="function";function Ti(e,t){return Li(()=>{const s=new WeakMap,n=(o,a)=>{let f=s.get(o);if(f)return f;const u=a&&s.get(a),h=[],y=[];return o.forEach((w,v)=>{const C=t?t(w):v;y[v]=C;const _=u&&u.atomList[u.keyList.indexOf(C)];if(_){h[v]=_;return}const b=N=>{const D=N(r),k=N(e),q=n(k,D==null?void 0:D.arr).keyList.indexOf(C);if(q<0||q>=k.length){const F=o[n(o).keyList.indexOf(C)];if(F)return F;throw new Error("splitAtom: index out of bounds for read")}return k[q]},P=(N,D,k)=>{const A=N(r),q=N(e),M=n(q,A==null?void 0:A.arr).keyList.indexOf(C);if(M<0||M>=q.length)throw new Error("splitAtom: index out of bounds for write");const m=Ni(k)?k(q[M]):k;D(e,[...q.slice(0,M),m,...q.slice(M+1)])};h[v]=$n(e)?Re(b,P):Re(b)}),u&&u.keyList.length===y.length&&u.keyList.every((w,v)=>w===y[v])?f=u:f={arr:o,atomList:h,keyList:y},s.set(o,f),f},r=Re(o=>{const a=o(r),f=o(e);return n(f,a==null?void 0:a.arr)});r.init=void 0;const i=$n(e)?Re(o=>o(r).atomList,(o,a,f)=>{switch(f.type){case"remove":{const u=o(i).indexOf(f.atom);if(u>=0){const h=o(e);a(e,[...h.slice(0,u),...h.slice(u+1)])}break}case"insert":{const u=f.before?o(i).indexOf(f.before):o(i).length;if(u>=0){const h=o(e);a(e,[...h.slice(0,u),f.value,...h.slice(u)])}break}case"move":{const u=o(i).indexOf(f.atom),h=f.before?o(i).indexOf(f.before):o(i).length;if(u>=0&&h>=0){const y=o(e);u<h?a(e,[...y.slice(0,u),...y.slice(u+1,h),y[u],...y.slice(h)]):a(e,[...y.slice(0,h),y[u],...y.slice(h,u),...y.slice(u+1)])}break}}}):Re(o=>o(r).atomList);return i},e,t||Mi)}const Ui=e=>typeof(e==null?void 0:e.then)=="function";function Fi(e){let t,s;const n={getItem:(r,i)=>{var o,a;const f=h=>{if(h=h||"",t!==h){try{s=JSON.parse(h)}catch{return i}t=h}return s},u=(a=(o=e())==null?void 0:o.getItem(r))!=null?a:null;return Ui(u)?u.then(f):f(u)},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 a=f=>{if(f.storageArea===e()&&f.key===r){let u;try{u=JSON.parse(f.newValue||"")}catch{u=o}i(u)}};return window.addEventListener("storage",a),()=>{window.removeEventListener("storage",a)}}),n}const qi=Fi(()=>typeof window<"u"?window.localStorage:void 0);function nt(e,t,s=qi,n){const r=n==null?void 0:n.unstable_getOnInit,i=Re(r?s.getItem(e,t):t);return i.onMount=a=>{r||a(s.getItem(e,t));let f;return s.subscribe&&(f=s.subscribe(e,a,t)),f},Re(a=>a(i),(a,f,u)=>{const h=typeof u=="function"?u(a(i)):u;return h===Ri?(f(i,t),s.removeItem(e)):h instanceof Promise?h.then(y=>(f(i,y),s.setItem(e,y))):(f(i,h),s.setItem(e,h))})}const $i=L.createContext(void 0),Ur=e=>{const t=L.useContext($i);return(e==null?void 0:e.store)||t||_i()},Vi=e=>typeof(e==null?void 0:e.then)=="function",Qi=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 Ki(e,t){const s=Ur(t),[[n,r,i],o]=L.useReducer(u=>{const h=s.get(e);return Object.is(u[0],h)&&u[1]===s&&u[2]===e?u:[h,s,e]},void 0,()=>[s.get(e),s,e]);let a=n;(r!==s||i!==e)&&(o(),a=s.get(e));const f=t==null?void 0:t.delay;return L.useEffect(()=>{const u=s.sub(e,()=>{if(typeof f=="number"){setTimeout(o,f);return}o()});return o(),u},[s,e,f]),L.useDebugValue(a),Vi(a)?Qi(a):a}function zi(e,t){const s=Ur(t);return L.useCallback((...r)=>s.set(e,...r),[s,e])}function Hi(e,t){return[Ki(e,t),zi(e,t)]}const Gi=new Mr({children:"blockNodes"}),Fr=(e,t=null)=>l.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,l.flatten([s,...Fr(n,s._id)])}return s}));function qr(e,t,s){const n=l.filter(e,i=>i._parent===t),r=[];for(let i=0;i<n.length;i++){const o=$r(n[i]);if(Object.keys(o).length>0&&Object.keys(o).forEach(a=>{n[i][a]=`slot:${ie.generateUUID()}`}),l.filter(e,{_parent:n[i]._id}).length>0){const a=ie.generateUUID();r.push({...n[i],oldId:n[i]._id,_id:a,_parent:s}),r.push(l.flatten(qr(e,n[i]._id,a)))}else r.push({...n[i],oldId:n[i]._id,_id:ie.generateUUID(),_parent:s})}return l.flatten(r)}function Wi(e){let t=Gi.convert(e.map(s=>l.omit(s,["settings"])));return t=!t.type&&t.blockNodes?t.blockNodes:l.isEmpty(t)?[]:[t],t}const $r=e=>{const t={};return Object.keys(e).forEach(s=>{l.isString(e[s])&&e[s].startsWith("slot")&&(t[s]=e[s].replace("slot:",""))}),t},Yi=(e,t,s=null)=>{let n=l.find(e,{_id:t});n={...n,oldId:n._id,_id:ie.generateUUID()},s&&(n={...n,_parent:s});const r=[n];l.filter(e,{_parent:t}).length>0&&r.push(l.flatten(qr(e,t,n._id)));const i=l.flatten(r);return l.map(i,o=>{const a=o,f=$r(a);return Object.keys(f).length>0&&Object.keys(f).forEach(u=>{const h=l.find(i,{oldId:f[u].replace("slot:","")});a[u]=`slot:${h._id}`}),l.omit(a,["global","oldId"])})},Ji=Nt((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)&&!l.isEmpty(t.payload.props)&&Object.keys(t.payload.props).forEach(r=>{l.set(n,r,t.payload.props[r])}),n));default:return e}},{debug:!1,ignoreInitialState:!1,limit:30,filter:Nt.excludeAction(["update_props_realtime","add_duplicate_blocks","set_page_blocks"])}),ks=Ii({past:[],present:[],future:[]},Ji);ks.debugLabel="pageBlocksAtom";const ge=g.atom(e=>{var t;return(t=e(ks))==null?void 0:t.present});ge.debugLabel="presentBlocksAtom";const cn=Ti(ge);cn.debugLabel="pageBlocksAtomsAtom";const Vr=g.atom(e=>Wi(e(ge)));Vr.debugLabel="pageBlocksTreeAtom";const Xi=g.atom("");Xi.debugLabel="builderActivePageAtom";const Zi=g.atom(-1);Zi.debugLabel="destinationDropIndexAtom";const Qr=g.atom(!1);Qr.debugLabel="addBlocksModalAtom";const ye=()=>{const[,e]=g.useAtom(ks);return e},ea=()=>{const e=ye(),t=g.useAtomValue(Vr),s=L.useCallback(n=>{const r=Fr(n);e({type:"set_page_blocks",payload:r})},[e]);return[t,s]},Kr=()=>{const e=ye();return[L.useCallback(s=>{e({type:"set_page_blocks",payload:s})},[e])]},Qs=e=>["Box","Slot","Form","DataContext","Link","List","ListItem","Row","Column","Table","TableCell"].includes(e),ta=e=>!["Slot"].includes(e),sa=e=>!["Slot"].includes(e);function na(e,t){return e==="Slot"||t==="List"&&e!=="ListItem"||t==="Row"&&e!=="Column"?!1:Qs(t)}const ra=(e,{dragSource:t,dropTarget:s})=>{const n=l.get(t,"data._type",""),r=l.get(s,"data._type","");return n==="Slot"||l.get(t,"id")&&l.get(t,"id")===l.get(s,"id")?!1:l.isEmpty(r)?!0:na(n,r)},zr=g.atom([]);zr.debugLabel="buildingBlocksAtom";const oa=g.atom(e=>{const t=e(zr);return l.filter(t,s=>l.has(s,"blockId"))}),ia=()=>{},un=()=>{const e=Nr.useChaiBlocks(),t=g.useAtomValue(oa),s=()=>{},n=L.useCallback(()=>ia(),[]);return[e,t,s,n]},ln=g.atom([]);ln.debugLabel="selectedBlockIdsAtom";const dn=g.atom(e=>{const t=e(ge),s=e(ln);return l.map(l.filter(t,({_id:n})=>l.includes(s,n)),n=>({...n}))});dn.debugLabel="selectedBlocksAtom";const fn=g.atom(e=>{const t=e(dn);return t.length===0?null:t.length===1?t[0]:{type:"Multiple",id:l.map(t,"id")}});fn.debugLabel="selectedBlockAtom";const aa=e=>l.get(e,"parent",null),ca=g.atom(e=>{const t=e(dn),s=l.map(t,aa);return l.filter(e(ge),n=>l.includes(s,n._id))});ca.debugLabel="selectedBlocksParentsAtom";const Hr=g.atom(()=>!1);Hr.debugLabel="selectedBlockFlexChildAtom";const Gr=g.atom(()=>!1);Gr.debugLabel="selectedBlockGridChildAtom";const hn=g.atom("");hn.debugLabel="styleStateAtom";const Wr=nt("styleBreakpoint","xs");Wr.debugLabel="styleBreakpointAtom";const ua=()=>({flexChild:g.useAtomValue(Hr),gridChild:g.useAtomValue(Gr)}),la=()=>g.useAtomValue(fn),$e=()=>{const[e,t]=g.useAtom(ln),s=L.useCallback(n=>{t(r=>l.includes(r,n)?l.without(r,n):[...r,n])},[t]);return[e,t,s]},Ks=(e,t="")=>{switch(e.type){case"singular":return e.uiSchema;case"model":const{properties:s}=e,n={};return Object.keys(s).forEach(o=>{const a=s[o];if(l.includes(["slot","styles"],a.type))return;const f=l.get(a,"i18n",!1)?`${o}-${t}`:o;n[f]=Ks(a,t)}),n;case"list":const{itemProperties:r}=e,i={items:{}};return Object.keys(r).forEach(o=>{const a=r[o];if(l.includes(["slot","styles"],a.type))return;const f=l.get(a,"i18n",!1)?`${o}-${t}`:o;i.items[f]=Ks(a,t)}),i;default:return{}}},zs=(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(f=>{const u=s[f];if(l.includes(["slot","styles"],u.type))return;const h=l.get(u,"i18n",!1)?`${f}-${t}`:f;r.properties[h]=zs(u,t)}),r;case"list":const{itemProperties:i,title:o}=e,a={title:o,type:"array",items:{type:"object",properties:{}}};return Object.keys(i).forEach(f=>{const u=i[f];if(l.includes(["slot","styles"],u.type))return;const h=l.get(u,"i18n",!1)?`${f}-${t}`:f;a.items.properties[h]=zs(u,t),l.set(a.items,"title",l.get(u,"itemTitle",`${o} item`))}),a;default:return{}}},Yr=e=>{const t={};return Object.keys(e).forEach(s=>{t[s]=fa(e[s])}),t},da=e=>{if(l.isEmpty(e.default))return[];const{itemProperties:t}=e;return l.map(e.default,s=>{const n={...s};return l.forIn(s,(r,i)=>{l.has(t,i)&&l.get(t[i],"i18n",!1)&&(n[i]=me.I18N_KEY)}),n})},fa=e=>{switch(e.type){case"styles":return e.default;case"slot":return`${me.SLOT_KEY}${ie.generateUUID()}`;case"singular":const{i18n:t,schema:s}=e;return t?me.I18N_KEY:l.get(s,"default","");case"model":return Yr(e.properties);case"list":return da(e);default:return""}},Jr=()=>g.useAtomValue(ge);function Vn(e,t,s,n,r){if(t===null)return[...e,...n];if(s!==null){const f=l.findIndex(e,{_parent:t}),u=(f===-1?0:f)+s;return e.splice(u,0,...n),e}if(!r){const u=l.findIndex(e,{_id:t})+1;return e.splice(u,0,...n),e}let i=l.findIndex(e,{_id:t});const o=l.filter(e,{_parent:t});l.isEmpty(o)||(i=l.findIndex(e,{_id:l.last(o)._id}));const a=i+1;return e.splice(a,0,...n),e}const ha=()=>{const e=ye(),t=Jr(),[,s]=un(),[,n]=$e(),r=L.useCallback((o,a,f)=>{if(l.has(o,"blocks")){const b=o.blocks;return i(b,a,f)}const u=ie.generateUUID(),h=Yr(o.props),y=[];l.forIn(h,(b,P)=>{if(l.startsWith(b,me.SLOT_KEY)){const N=b.replace(me.SLOT_KEY,"");y.push({_id:N,_type:"Slot",_parent:u,_name:o.props[P].name,_styles:o.props[P].styles,_emptyStyles:o.props[P].emptyStyles})}});const w={_type:o.type,_id:u,...h};let v;a&&(v=l.find(t,{_id:a}),w._parent=a);const C=v?Qs(v._type):!0;!C&&v&&(w._parent=v._parent);const _=[w,...y];return e({type:"set_blocks",payload:Vn(t,a||null,f||null,_,C)}),n([w._id]),w},[t,e,n]),i=L.useCallback((o,a,f)=>{var y;for(let w=0;w<o.length;w++){const{_id:v}=o[w];o[w]._id=ie.generateUUID();const C=l.filter(o,{_parent:v});for(let _=0;_<C.length;_++)C[_]._parent=o[w]._id}let u;a&&(u=l.find(t,{_id:a}),o[0]._parent=a);const h=u?Qs(u._type):!0;return!h&&u&&(o[0]._parent=u._parent),e({type:"set_blocks",payload:Vn(t,a||null,f||null,o,h)}),n([(y=l.first(o))==null?void 0:y._id]),l.first(o)},[t,e,n,s]);return{addCoreBlock:r,addPredefinedBlock:i}},Qn={xs:420,sm:620,md:768,lg:1024,xl:1280,"2xl":1536},Kn=["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=Kn.indexOf(s);for(;r>0;){const i=Kn[r-1];if(l.find(e,{mq:i,property:t.property})){n="classes";break}r--}return n}const zn=[];function ma(e="",t="",s=[]){e=e.trim().replace(/ +/g,"");let n=l.filter(l.map(e.split(" "),ie.constructClassObject),u=>!l.isNull(u)),r=l.filter(l.map(t.split(" "),ie.constructClassObject),u=>!l.isNull(u));r=l.filter(r,u=>!l.includes(zn,u.property));const i=[],o=[];l.each(s,u=>{const h=ie.constructClassObject(u),y=l.find(n,l.pick(h,["dark","mq","mod","property"]));if(y&&(n=l.filter(n,w=>w.fullCls!==(y==null?void 0:y.fullCls))),i.push(h),h.mq==="xs"&&!h.dark&&h.mod===""&&(r=l.filter(r,w=>w.property!==h.property)),pa(n,h)==="baseClasses"&&!l.includes(zn,h.property)){const w=l.find(r,l.pick(h,["property"]));y&&(r=l.filter(r,v=>v.fullCls!==(w==null?void 0:w.fullCls))),o.push({...h,fullCls:h.cls,mq:"xs"})}});const a=l.map(l.sortBy([...n,...i],u=>Qn[u.mq]),"fullCls").join(" ");return`${l.map(l.sortBy([...r,...o],u=>Qn[u.mq]),"fullCls").join(" ").trim()},${a.trim()}`.trim().replace(/ +/g,"")}const ss=g.atom([]);ss.debugLabel="selectedStylingBlocksAtom";const pn=()=>g.useAtom(ss),ga=e=>{const t=e.replace(me.STYLES_KEY,"").split(",");return{baseClasses:t[0],classes:t[1]}},ya=g.atom(null,(e,t,{blockIds:s,newClasses:n,dispatch:r})=>{const i=l.filter(e(cn),a=>s.includes(e(a)._id)),o=l.first(e(ss));l.each(i,a=>{const f=e(a),u=l.get(f,o.prop,`${me.STYLES_KEY},`),{baseClasses:h,classes:y}=ga(u);r({type:"update_props_realtime",payload:{ids:[f._id],props:{[o.prop]:`${me.STYLES_KEY}${ma(y,h,n)}`}}})})}),va=()=>{const e=ye(),t=g.useSetAtom(ya);return L.useCallback((s,n,r)=>{t({blockIds:s,newClasses:n,dispatch:e}),r&&setTimeout(()=>e({type:"create_snapshot"}),500)},[e,t])},ba=g.atom(!1),mn=()=>{const[e,t]=g.useAtom(ba);return[e,t]},xa=g.atom(ie.BRANDING_OPTIONS_DEFAULTS),gn=()=>{const[e,t]=g.useAtom(xa);return[l.isObject(e)?{...e,...ie.BRANDING_OPTIONS_DEFAULTS}:ie.BRANDING_OPTIONS_DEFAULTS,t]},wa=g.atom(null),Xr=()=>({currentPage:g.useAtomValue(wa)}),Zr=new Mr({});function Sa(e){let t=Zr.convert(e);return t=!t.type&&t.children&&t.children.length?t.children:l.isEmpty(t)?[]:[t],t}const yn=(e,t)=>l.flatten(e.map(s=>{if(s=t?{...s,parent:t}:{...s},s.children){const n=[...s.children];return delete s.children,l.flatten([s,...yn(n,s._id)])}return s}));function vn(e,t=!1){for(let s=0;s<e.length;s++){const n=e[s];n.global&&!t?e[s]={type:"GlobalBlock",_parent:l.get(n,"parent",null),blockId:n.blockId,_id:n._id}:n.children&&n.children.length&&vn(n.children)}}function eo(e){let t=[],s=l.filter(e,{type:"GlobalBlock"});return s.length>0&&(s=l.map(s,to),l.each(s,n=>{t=[...t,...Ea(n)]})),t}function Ea(e){let t=[];const s=l.get(l.first(e),"parent",null);l.set(l.first(e),"parent",null);const n=[Zr.convert(so(e))];vn(n,!0);let r=yn(n,e[0]._id);return r=l.set(r,"0.parent",s),t=[...t,r,...eo(r)],t}function to(e){const t=l.find(Hs,{_id:e._id});if(!t)return[];const s=[t],n=l.filter(Hs,{_parent:e._id});return n.length?l.flatten([...s,...l.flatten(l.map(n,to))]):l.flatten(s)}const so=e=>JSON.parse(JSON.stringify(e));let Hs=[];function ka(e){Hs=e;const t=Sa(so(e));vn(t);const s=yn(t,null),n=eo(s),r={};return l.each(n,i=>l.set(r,l.first(i).blockId,i)),[s,r]}const bn=()=>{const[e]=gn(),{currentPage:t}=Xr(),s=g.useAtomValue(ge);return L.useCallback(()=>{const n=l.map(s,o=>l.omit(o,["expanded","order","title","siblings","tempClasses"])),[r=[],i=[]]=ka(n);return{currentPage:t,blocks:r,globalBlocks:i}},[e,t,s])};nt("blockStylingActiveTab",1);g.atom([]);const no=g.atom(!1);no.debugLabel="readOnlyModeAtom";const ro=g.atom(!1);ro.debugLabel="inlineEditingActiveAtom";const oo=g.atom(!1);oo.debugLabel="advanceStylingOpenAtom";const io=g.atom("online");io.debugLabel="networkModeAtom";nt("currentUiLibrary","");const Aa=g.atom(!1);Aa.debugLabel="codeEditorOpenAtom";const ao=g.atom(!1);ao.debugLabel="editLayerNameAtom";const Pa=g.atom("");Pa.debugLabel="activeLanguageAtom";const Oa=g.atom("");Oa.debugLabel="primaryLanguageAtom";const co=g.atom(null);co.debugLabel="canvasIframeAtom";const uo=g.atom("layers");uo.debugLabel="activePanelAtom";const lo=g.atom(!1);lo.debugLabel="addBlockOffCanvasAtom";const fo=g.atom("");fo.debugLabel="showPredefinedBlockCategoryAtom";const As=g.atom({undoCount:0,redoCount:0});As.debugLabel="historyStatesAtom";const Ps=g.atom("SAVED");Ps.debugLabel="pageSyncStateAtom";const ja=()=>{const[e,t]=g.useAtom(Ps),s=be.useBuilderProp("onSaveBlocks",async()=>{}),n=be.useBuilderProp("onSyncStatusChange",()=>{}),r=bn(),i=g.useSetAtom(As),{undoCount:o,redoCount:a}=ns();return{savePage:pi.useThrottledCallback(async()=>{t("SAVING"),n("SAVING");const u=r();return await s({blocks:u.blocks,globalBlocks:u.globalBlocks}),setTimeout(()=>{i({undoCount:o,redoCount:a}),t("SAVED"),n("SAVED")},100),!0},[r,t,n,s],5e3),syncState:e,setSyncState:t}},ns=()=>{const e=g.useAtomValue(ks),[{undoCount:t,redoCount:s}]=g.useAtom(As),n=ye(),[r]=mn(),[,i]=$e(),[,o]=pn(),[,a]=g.useAtom(Ps),f=be.useBuilderProp("onSyncStatusChange",()=>{}),u=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)?(a("UNSAVED"),f("UNSAVED")):t===(e==null?void 0:e.past.length)&&s===(e==null?void 0:e.future.length)&&(a("SAVED"),f("SAVED"))},[e==null?void 0:e.past.length,e==null?void 0:e.future.length,t,s,f,a]),{undoCount:e==null?void 0:e.past.length,redoCount:e==null?void 0:e.future.length,undo:L.useCallback(()=>{r||(n(Nt.ActionCreators.undo()),setTimeout(()=>{o([]),i([])},200))},[n,r,a]),redo:L.useCallback(()=>{r||(n(Nt.ActionCreators.redo()),setTimeout(()=>{o([]),i([])},200))},[r,n]),clear:()=>{n(Nt.ActionCreators.clearHistory())},createSnapshot:u}},ho=()=>g.useAtom(Wr),po=nt("canvasWidth",360),mo=g.atom(e=>{const t=e(po);return ie.getBreakpointValue(t).toLowerCase()}),Ca=()=>{const[e,t]=g.useAtom(po),s=g.useAtomValue(mo),[n,r]=ho();return L.useEffect(()=>{n!=="xs"&&r(s)},[s,n,r]),[e,s,t]},Ba=nt("canvasZoom",100),_a=()=>g.useAtom(Ba),go=g.atom([]),xn=()=>{const[e,t]=g.useAtom(go),s=g.useSetAtom(wn),n=L.useCallback(r=>{t(r),s([])},[t,s]);return[e,n]},wn=g.atom([]),yo=()=>{const[e,t]=g.useAtom(wn),s=g.useSetAtom(go),n=L.useCallback(r=>{t(r),s([])},[t,s]);return[e,n]},vo=nt("darkMode",!1),Ra=()=>{const[e,t]=g.useAtom(vo);return[e,t]},Ia=g.atom(!1),Da=()=>{const[e,t]=g.useAtom(Ia);return[e,t]},Sn=()=>{const e=ye(),t=g.useAtomValue(ge),[,s]=$e();return L.useCallback((n,r=null)=>{const i=[];l.each(n,o=>{const f=Yi(t,o,r===o?null:r);i.push(l.get(f,"0._id","")),e({type:"add_duplicate_blocks",payload:f})}),s(i),e({type:"create_snapshot"})},[t,s,e])},La=g.atom([]),Ma=()=>{const[e,t]=g.useAtom(La),s=L.useCallback(n=>{t(r=>l.includes(r,n)?l.without(r,n):[...r,n])},[t]);return[e,t,s]},Na=g.atom(""),bo=()=>g.useAtom(Na),Ta=()=>{const e=g.useAtomValue(ge),t=ye(),s=bn(),[,,n]=un();return L.useCallback(async(r,i)=>{const o=ie.generateUUID(16),a=l.map(e,f=>(f._id===r&&(f._globalBlockId=o,f._name=i),f));t({type:"set_page_blocks",payload:a}),n()},[e,t,s,n])},Ua=()=>({}),Fa=()=>{const e=g.useAtomValue(ge),t=ye();return L.useCallback((s,n)=>{const r=l.map(e,i=>(l.includes(s,l.get(i,"_id"))&&l.set(i,"_parent",n),i));t({type:"set_blocks",payload:r})},[e,t])},xo=()=>{const e=g.useAtomValue(wn),[t,s]=xn(),n=Sn(),r=Fa();return{canPaste:L.useMemo(()=>t.length>0||e.length>0,[e,t]),pasteBlocks:L.useCallback(o=>{l.isEmpty(e)?r(t,o):n(e,o),s(()=>[])},[t,e,n,r,s])}},qa=g.atom(""),$a=()=>{const e=g.useAtomValue(qa),t=L.useCallback(()=>{},[]),s=L.useCallback(()=>{},[]),n=L.useCallback(()=>{},[]);return{currentProject:e,createProject:n,deleteProject:t,updateProject:s}},wo=(e,t)=>{const s=[],n=l.filter(e,r=>l.includes(t,r._id)||l.includes(t,r._parent)?(s.push(r._id),!1):!0);return l.isEmpty(s)?n:wo(n,s)},So=()=>{const e=ye(),t=g.useAtomValue(ge),[s,n]=$e();return L.useCallback(r=>{var a;const i=((a=l.find(t,{_id:r[0]}))==null?void 0:a._parent)||null,o=wo(t,r);e({type:"set_blocks",payload:o}),n(i?[i]:[])},[t,n,e,s])},Va=g.atom(null,(e,t,{blockIds:s,fullClasses:n,dispatch:r})=>{const i=l.first(e(ss)),o=l.filter(e(cn),a=>s.includes(e(a)._id));l.each(o,a=>{const f=e(a),u=n;let{classes:h,baseClasses:y}=Ai(l.get(f,i.prop,"styles:,"));l.each(u,w=>{const v=new RegExp(`(^| )${w.replace("[","\\[").replace("]","\\]")}($| )`,"g");h=h.replace(v," ").replace(/ +/g," ").trim();const C=l.first(w.split(":"));l.includes(["2xl","xl","lg","md","sm"],C)&&u.push(w.split(":").pop().trim())}),l.each(u,w=>{const v=new RegExp(`(^| )${w.replace("[","\\[").replace("]","\\]")}($| )`,"g");y=y.replace(v," ").replace(/ +/g," ").trim()}),r({type:"update_props_realtime",payload:{ids:[f._id],props:{[i.prop]:`${me.STYLES_KEY}${y},${h}`}}})})}),Qa=()=>{const e=ye(),t=g.useSetAtom(Va);return L.useCallback((s,n)=>{t({blockIds:s,fullClasses:n,dispatch:e}),setTimeout(()=>e({type:"create_snapshot"}))},[e,t])},Eo=g.atom(e=>{const t=l.first(e(ss)),s=e(fn);if(!t||t.blockId!==l.get(s,"_id",null))return[];const r=l.get(s,t.prop,`${me.STYLES_KEY},`).replace(me.STYLES_KEY,"").split(",").join(" ");return l.filter(l.map(r.trim().split(" "),ie.constructClassObject),i=>!l.isNull(i))}),Ka=()=>g.useAtomValue(Eo),Hn={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},za=g.atom(e=>{const t=e(mo),s=e(hn),n=e(vo),r=Ha(t);let i=l.filter(e(Eo),{mod:s});return l.startsWith(s,"_")||(i=l.filter(i,o=>r.includes(o.mq))),i=i.sort((o,a)=>Hn[o.mq]-Hn[a.mq]),n||(i=l.filter(i,{dark:!1})),i}),Ha=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},Ga=()=>g.useAtomValue(za),Wa=()=>g.useAtom(hn),ko=g.atom(null,(e,t,{blockIds:s,props:n,dispatch:r})=>{r({type:"update_props_realtime",payload:{ids:s,props:n}})}),Ya=()=>{const{createSnapshot:e}=ns(),t=ye(),s=g.useSetAtom(ko);return L.useCallback((n,r)=>{s({blockIds:n,props:r,dispatch:t}),e()},[e,t,s])},Ja=()=>{const e=ye(),t=g.useSetAtom(ko);return L.useCallback((s,n)=>{t({blockIds:s,props:n,dispatch:e})},[e,t])},Ao={name:"",props:{},modalProps:{},backdropClose:!0},Xa=g.atom(Ao),Za=()=>{const[e,t]=g.useAtom(Xa),s=L.useCallback((r,i={},o={})=>{t({name:r,props:i,modalProps:o})},[t]),n=L.useCallback((...r)=>{l.get(e,"props.onClose",()=>{})(...r),t(Ao)},[t,e]);return{activeModal:e,openModal:s,closeModal:n}},ec=()=>g.useAtomValue(no),tc=g.atom(""),sc=g.atom(null),nc=()=>g.useAtom(tc),rc=()=>g.useAtom(sc),oc=nt("selectedBreakpoints",["XS","MD","XL"]),ic=()=>{const[e,t]=g.useAtom(oc);return[e,t]},Po=()=>{const e=g.useSetAtom(As),{clear:t}=ns(),[,s]=$e(),[,n]=bo(),[,r]=pn();return()=>{s([]),r([]),n(""),t(),e({undoCount:0,redoCount:0})}},ac=g.atom({en:{}}),cc=()=>{const[e,t]=g.useAtom(ac),s=L.useCallback((n,r,i)=>{l.set(e,`${n}.${r}`,i),t(e)},[e,t]);return[e,s]},uc=(e,t)=>{const[s]=g.useAtom(be.chaiBuilderPropsAtom);return l.get(s,e,t)},lc=g.atom([]),dc=()=>{const[e,t]=L.useState(!1),[s,n]=g.useAtom(lc),r=be.useBuilderProp("getUILibraryBlocks",()=>[]);return L.useEffect(()=>{(async()=>s.length>0||(t(!0),n(await r()),t(!1)))()},[]),{data:s,isLoading:e}},fc=g.atom("en"),hc=g.atom("en"),pc=g.atom(["en"]),Oo=()=>g.useAtom(fc),mc=()=>g.useAtom(hc),gc=()=>g.useAtom(pc),yc=(e,t)=>{const[s]=Oo(),n=`${e}${s?`-${s}`:""}`;return{content:l.get(t,n,l.get(t,e,"")),propKey:e}},vc=()=>{const[e,t]=mn(),s=be.useBuilderProp("previewComponent");return B.jsxRuntimeExports.jsxs("div",{className:hi.cn("fixed inset-0 z-[999] bg-background",e?"block":"hidden"),children:[B.jsxRuntimeExports.jsx(be.Button,{size:"sm",className:"absolute right-0 top-0 m-4",onClick:()=>t(!1),children:"Close Preview"}),B.jsxRuntimeExports.jsx("div",{children:s?B.jsxRuntimeExports.jsx(L.Suspense,{fallback:B.jsxRuntimeExports.jsx(be.Skeleton,{className:"h-96 w-full"}),children:L.createElement(s)}):null})]})},bc=()=>{const[e,t]=$e(),[,s]=yo(),n=So(),r=Sn(),[,i]=xn(),{pasteBlocks:o}=xo(),{undo:a,redo:f}=ns();Ce.useHotkeys("esc",()=>t([]),{},[t]),Ce.useHotkeys("ctrl+c,command+c",()=>s(e),{},[e,s]),Ce.useHotkeys("ctrl+d,command+d",()=>r(e),{preventDefault:!0},[e,r]),Ce.useHotkeys("ctrl+x,command+x",()=>i(e),{},[e,i]),Ce.useHotkeys("ctrl+v,command+v",()=>e.length===1?o(e[0]):null,{},[e,o]),Ce.useHotkeys("ctrl+z,command+z",()=>a(),{},[a]),Ce.useHotkeys("ctrl+y,command+y",()=>f(),{},[f]),Ce.useHotkeys("del, backspace",u=>{u.preventDefault(),n(e)},{},[e,n])},xc=(e,t)=>{const s=[];let n=l.find(e,{_id:t}),r=l.get(n,"_parent","");for(;l.isString(r)&&!l.isEmpty(r);)s.push(n==null?void 0:n._parent),n=l.find(e,{_id:r}),r=n==null?void 0:n._parent;return l.flatten(s)},jo=g.atom([]),wc=()=>{const[e]=$e(),t=g.useAtomValue(ge),[,s]=g.useAtom(jo);L.useEffect(()=>{let n=[];const r=l.first(e);l.isString(r)&&(n=[r,...xc(t,r)]),s(n)},[e,t,s])},Sc=()=>g.useAtomValue(jo),Ec=L.lazy(()=>Promise.resolve().then(()=>require("./SidePanels-ce4d41d5.cjs"))),kc=L.lazy(()=>Promise.resolve().then(()=>require("./Topbar-b97472fc.cjs"))),Ac=L.lazy(()=>Promise.resolve().then(()=>require("./CanvasArea-f5d27245.cjs"))),Pc=L.lazy(()=>Promise.resolve().then(()=>require("./Settings-739cff3b.cjs"))),Oc=()=>{const[e]=Hi(Ps),t=s=>{s.preventDefault()};return bc(),wc(),L.useEffect(()=>(e!=="SAVED"?window.onbeforeunload=()=>"":window.onbeforeunload=null,()=>{window.onbeforeunload=null}),[e]),B.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-background text-foreground",children:B.jsxRuntimeExports.jsxs(be.TooltipProvider,{children:[B.jsxRuntimeExports.jsxs("div",{onContextMenu:t,className:"flex h-screen flex-col overflow-hidden bg-background text-foreground",children:[B.jsxRuntimeExports.jsx("div",{className:"h-14 w-screen shrink-0 border-b border-border",children:B.jsxRuntimeExports.jsx(L.Suspense,{children:B.jsxRuntimeExports.jsx(kc,{})})}),B.jsxRuntimeExports.jsxs("main",{className:"flex h-full flex-row",children:[B.jsxRuntimeExports.jsx("div",{className:"flex h-full w-fit border-border",children:B.jsxRuntimeExports.jsx(L.Suspense,{children:B.jsxRuntimeExports.jsx(Ec,{})})}),B.jsxRuntimeExports.jsx("div",{className:"h-full flex-1 bg-slate-800/20",children:B.jsxRuntimeExports.jsx(L.Suspense,{children:B.jsxRuntimeExports.jsx(Ac,{})})}),B.jsxRuntimeExports.jsx("div",{className:"flex h-full w-[280px] min-w-[280px] border-l border-border",children:B.jsxRuntimeExports.jsx(L.Suspense,{children:B.jsxRuntimeExports.jsx(Pc,{})})})]})]}),B.jsxRuntimeExports.jsx(vc,{})]})})},jc=g.getDefaultStore();g.atom({});function Gn(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 us="undefined",Wn="object",Co="any",Bo="*",et="__",vs=typeof process<"u"?process:{};vs.env&&vs.env.NODE_ENV;var xe=typeof document<"u";vs.versions!=null&&vs.versions.node!=null;typeof Deno<"u"&&Deno.core;xe&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function _o(e,t){return t.charAt(0)[e]()+t.slice(1)}var Cc=_o.bind(null,"toUpperCase"),Bc=_o.bind(null,"toLowerCase");function _c(e){return Ro(e)?Cc("null"):typeof e=="object"?Mc(e):Object.prototype.toString.call(e).slice(8,-1)}function bs(e,t){t===void 0&&(t=!0);var s=_c(e);return t?Bc(s):s}function rs(e,t){return typeof t===e}var Pe=rs.bind(null,"function"),at=rs.bind(null,"string"),ot=rs.bind(null,"undefined"),Rc=rs.bind(null,"boolean");rs.bind(null,"symbol");function Ro(e){return e===null}function Ic(e){return bs(e)==="number"&&!isNaN(e)}function Dc(e){return bs(e)==="array"}function ue(e){if(!Lc(e))return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Lc(e){return e&&(typeof e=="object"||e!==null)}function Mc(e){return Pe(e.constructor)?e.constructor.name:null}function Nc(e){return e instanceof Error||at(e.message)&&e.constructor&&Ic(e.constructor.stackTraceLimit)}function Io(e,t){if(typeof t!="object"||Ro(t))return!1;if(t instanceof e)return!0;var s=bs(new e(""));if(Nc(t))for(;t;){if(bs(t)===s)return!0;t=Object.getPrototypeOf(t)}return!1}Io.bind(null,TypeError);Io.bind(null,SyntaxError);function Os(e,t){var s=e instanceof Element||e instanceof HTMLDocument;return s&&t?Tc(e,t):s}function Tc(e,t){return t===void 0&&(t=""),e&&e.nodeName===t.toUpperCase()}function js(e){var t=[].slice.call(arguments,1);return function(){return e.apply(void 0,[].slice.call(arguments).concat(t))}}js(Os,"form");js(Os,"button");js(Os,"input");js(Os,"select");function Yn(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function Uc(){if(xe){var e=navigator,t=e.languages;return e.userLanguage||(t&&t.length?t[0]:e.language)}}function Fc(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function qc(e){return function(t){for(var s,n=Object.create(null),r=/([^&=]+)=?([^&]*)/g;s=r.exec(t);){var i=Yn(s[1]),o=Yn(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 a in n){var f=a.split("[");f.length>1&&($c(n,f.map(function(u){return u.replace(/[?[\]\\ ]/g,"")}),n[a]),delete n[a])}return n}(function(t){if(t){var s=t.match(/\?(.*)/);return s&&s[1]?s[1].split("#")[0]:""}return xe&&window.location.search.substring(1)}(e))}function $c(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 Cs(){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 Tt="global",Pt=et+"global"+et,Ot=typeof self===Wn&&self.self===self&&self||typeof global===Wn&&global.global===global&&global||void 0;function tt(e){return Ot[Pt][e]}function st(e,t){return Ot[Pt][e]=t}function Bt(e){delete Ot[Pt][e]}function _t(e,t,s){var n;try{if(En(e)){var r=window[e];n=r[t].bind(r)}}catch{}return n||s}Ot[Pt]||(Ot[Pt]={});var ls={};function En(e){if(typeof ls[e]!==us)return ls[e];try{var t=window[e];t.setItem(us,us),t.removeItem(us)}catch{return ls[e]=!1}return ls[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 Ie="function",je="undefined",Vc="@@redux/"+Math.random().toString(36),Jn=function(){return typeof Symbol===Ie&&Symbol.observable||"@@observable"}(),ds=" != "+Ie;function Do(e,t,s){var n;if(typeof t===Ie&&typeof s===je&&(s=t,t=void 0),typeof s!==je){if(typeof s!==Ie)throw new Error("enhancer"+ds);return s(Do)(e,t)}if(typeof e!==Ie)throw new Error("reducer"+ds);var r=e,i=t,o=[],a=o,f=!1;function u(){a===o&&(a=o.slice())}function h(){return i}function y(v){if(typeof v!==Ie)throw new Error("Listener"+ds);var C=!0;return u(),a.push(v),function(){if(C){C=!1,u();var _=a.indexOf(v);a.splice(_,1)}}}function w(v){if(!ue(v))throw new Error("Act != obj");if(typeof v.type===je)throw new Error("ActType "+je);if(f)throw new Error("Dispatch in reducer");try{f=!0,i=r(i,v)}finally{f=!1}for(var C=o=a,_=0;_<C.length;_++)(0,C[_])();return v}return w({type:"@@redux/INIT"}),(n={dispatch:w,subscribe:y,getState:h,replaceReducer:function(v){if(typeof v!==Ie)throw new Error("next reducer"+ds);r=v,w({type:"@@redux/INIT"})}})[Jn]=function(){var v,C=y;return(v={subscribe:function(_){if(typeof _!="object")throw new TypeError("Observer != obj");function b(){_.next&&_.next(h())}return b(),{unsubscribe:C(b)}}})[Jn]=function(){return this},v},n}function Qc(e,t){var s=t&&t.type;return"action "+(s&&s.toString()||"?")+"reducer "+e+" returns "+je}function jt(){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 Kc(){var e=arguments;return function(t){return function(s,n,r){var i,o=t(s,n,r),a=o.dispatch,f={getState:o.getState,dispatch:function(u){return a(u)}};return i=[].slice.call(e).map(function(u){return u(f)}),V({},o,{dispatch:a=jt.apply(void 0,i)(o.dispatch)})}}}var qe=et+"anon_id",Ze=et+"user_id",ct=et+"user_traits",_e="userId",it="anonymousId",ms=["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"],Gs=["name","EVENTS","config","loaded"],$=ms.reduce(function(e,t){return e[t]=t,e},{registerPluginType:function(e){return"registerPlugin:"+e},pluginReadyType:function(e){return"ready:"+e}}),Xn=/^utm_/,Zn=/^an_prop_/,er=/^an_trait_/;function zc(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,a=r.persistedUser,f=r.initialUser,u=a.userId===o.userId;a.anonymousId!==o.anonymousId&&t(qe,o.anonymousId),u||t(Ze,o.userId),f.traits&&t(ct,V({},u&&a.traits?a.traits:{},f.traits));var h=Object.keys(r.params);if(h.length){var y=i.an_uid,w=i.an_event,v=h.reduce(function(C,_){if(_.match(Xn)||_.match(/^(d|g)clid/)){var b=_.replace(Xn,"");C.campaign[b==="campaign"?"name":b]=i[_]}return _.match(Zn)&&(C.props[_.replace(Zn,"")]=i[_]),_.match(er)&&(C.traits[_.replace(er,"")]=i[_]),C},{campaign:{},props:{},traits:{}});s.dispatch(V({type:$.params,raw:i},v,y?{userId:y}:{})),y&&setTimeout(function(){return e.identify(y,v.traits)},0),w&&setTimeout(function(){return e.track(w,v.props)},0),Object.keys(v.campaign).length&&s.dispatch({type:$.campaign,campaign:v.campaign})}}return n(r)}}}}function Hc(e){return function(t,s){if(t===void 0&&(t={}),s===void 0&&(s={}),s.type===$.setItemEnd){if(s.key===qe)return V({},t,{anonymousId:s.value});if(s.key===Ze)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[Ze,qe,ct].forEach(function(n){e.removeItem(n)}),Object.assign({},t,{userId:null,anonymousId:null,traits:{}});default:return t}}}function tr(e){return{userId:e.getItem(Ze),anonymousId:e.getItem(qe),traits:e.getItem(ct)}}var Ws=function(e){return et+"TEMP"+et+e};function Gc(e){var t=e.storage,s=t.setItem,n=t.removeItem,r=t.getItem;return function(i){return function(o){return function(a){var f=a.userId,u=a.traits,h=a.options;if(a.type===$.reset&&([Ze,ct,qe].forEach(function(v){n(v)}),[_e,it,"traits"].forEach(function(v){Bt(Ws(v))})),a.type===$.identify){r(qe)||s(qe,Cs());var y=r(Ze),w=r(ct)||{};y&&y!==f&&i.dispatch({type:$.userIdChanged,old:{userId:y,traits:w},new:{userId:f,traits:u},options:h}),f&&s(Ze,f),u&&s(ct,V({},w,u))}return o(a)}}}}var Lt={};function sr(e,t){Lt[e]&&Pe(Lt[e])&&(Lt[e](t),delete Lt[e])}function Lo(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 Lo(e,t,s-10).then(n,r)})})}function Mo(e,t,s){var n=t(),r=e.getState(),i=r.plugins,o=r.queue,a=r.user;if(!r.context.offline&&o&&o.actions&&o.actions.length){var f=o.actions.reduce(function(h,y,w){return i[y.plugin].loaded?(h.process.push(y),h.processIndex.push(w)):(h.requeue.push(y),h.requeueIndex.push(w)),h},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(h){var y=o.actions[h],w=y.plugin,v=y.payload.type,C=n[w][v];if(C&&Pe(C)){var _=function(P,N){return P===void 0&&(P={}),N===void 0&&(N={}),[_e,it].reduce(function(D,k){return P.hasOwnProperty(k)&&N[k]&&N[k]!==P[k]&&(D[k]=N[k]),D},P)}(y.payload,a);C({payload:_,config:i[w].config,instance:s});var b=v+":"+w;e.dispatch(V({},_,{type:b,_:{called:b,from:"queueDrain"}}))}});var u=o.actions.filter(function(h,y){return!~f.processIndex.indexOf(y)});o.actions=u}}}var Us=function(e){var t=e.data,s=e.action,n=e.instance,r=e.state,i=e.allPlugins,o=e.allMatches,a=e.store,f=e.EVENTS;try{var u=r.plugins,h=r.context,y=s.type,w=y.match(ut),v=t.exact.map(function(b){return b.pluginName});w&&(v=o.during.map(function(b){return b.pluginName}));var C=function(b,P){return function(N,D,k){var A=D.config,q=D.name,F=q+"."+N.type;k&&(F=k.event);var M=N.type.match(ut)?function(m,x,R,S,I){return function(O,E){var K=S?S.name:m,Q=E&&$t(E)?E:R;if(S&&(!(Q=E&&$t(E)?E:[m]).includes(m)||Q.length!==1))throw new Error("Method "+x+" can only abort "+m+" plugin. "+JSON.stringify(Q)+" input valid");return V({},I,{abort:{reason:O,plugins:Q,caller:x,_:K}})}}(q,F,P,k,N):function(m,x){return function(){throw new Error(m.type+" action not cancellable. Remove abort in "+x)}}(N,F);return{payload:Wc(N),instance:b,config:A||{},abort:M}}}(n,v),_=t.exact.reduce(function(b,P){var N=P.pluginName,D=P.methodName,k=!1;return D.match(/^initialize/)||D.match(/^reset/)||(k=!u[N].loaded),h.offline&&D.match(/^(page|track|identify)/)&&(k=!0),b[""+N]=k,b},{});return Promise.resolve(t.exact.reduce(function(b,P,N){try{var D=P.pluginName;return Promise.resolve(b).then(function(k){function A(){return Promise.resolve(k)}var q=function(){if(t.namespaced&&t.namespaced[D])return Promise.resolve(t.namespaced[D].reduce(function(F,M,m){try{return Promise.resolve(F).then(function(x){return M.method&&Pe(M.method)?(function(O,E){var K=ur(O);if(K&&K.name===E){var Q=ur(K.method);throw new Error([E+" plugin is calling method "+O,"Plugins cant call self","Use "+K.method+" "+(Q?"or "+Q.method:"")+" in "+E+" plugin insteadof "+O].join(`
|
|
2
|
+
`))}}(M.methodName,M.pluginName),Promise.resolve(M.method({payload:x,instance:n,abort:(R=x,S=D,I=M.pluginName,function(O,E){return V({},R,{abort:{reason:O,plugins:E||[S],caller:y,from:I||S}})}),config:or(M.pluginName,u,i),plugins:u})).then(function(O){var E=ue(O)?O:{};return Promise.resolve(V({},x,E))})):x;var R,S,I})}catch(x){return Promise.reject(x)}},Promise.resolve(s))).then(function(F){k[D]=F});k[D]=s}();return q&&q.then?q.then(A):A()})}catch(k){return Promise.reject(k)}},Promise.resolve({}))).then(function(b){return Promise.resolve(t.exact.reduce(function(P,N,D){try{var k=t.exact.length===D+1,A=N.pluginName,q=i[A];return Promise.resolve(P).then(function(F){var M=b[A]?b[A]:{};if(w&&(M=F),qs(M,A))return Fs({data:M,method:y,instance:n,pluginName:A,store:a}),Promise.resolve(F);if(qs(F,A))return k&&Fs({data:F,method:y,instance:n,store:a}),Promise.resolve(F);if(_.hasOwnProperty(A)&&_[A]===!0)return a.dispatch({type:"queue",plugin:A,payload:M,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(F);var m=C(b[A],i[A]);return Promise.resolve(q[y]({abort:m.abort,payload:M,instance:n,config:or(A,u,i),plugins:u})).then(function(x){var R=ue(x)?x:{},S=V({},F,R),I=b[A];if(qs(I,A))Fs({data:I,method:y,instance:n,pluginName:A,store:a});else{var O=y+":"+A;(O.match(/:/g)||[]).length<2&&!y.match(nr)&&!y.match(rr)&&n.dispatch(V({},w?S:M,{type:O,_:{called:O,from:"submethod"}}))}return Promise.resolve(S)})})}catch(F){return Promise.reject(F)}},Promise.resolve(s))).then(function(P){if(!(y.match(ut)||y.match(/^registerPlugin/)||y.match(rr)||y.match(nr)||y.match(/^params/)||y.match(/^userIdChanged/))){if(f.plugins.includes(y),P._&&P._.originalAction===y)return P;var N=V({},P,{_:{originalAction:P.type,called:P.type,from:"engineEnd"}});No(P,t.exact.length)&&!y.match(/End$/)&&(N=V({},N,{type:P.type+"Aborted"})),a.dispatch(N)}return P})})}catch(b){return Promise.reject(b)}},ut=/Start$/,nr=/^bootstrap/,rr=/^ready/;function Fs(e){var t=e.pluginName,s=e.method+"Aborted"+(t?":"+t:"");e.store.dispatch(V({},e.data,{type:s,_:{called:s,from:"abort"}}))}function or(e,t,s){var n=t[e]||s[e];return n&&n.config?n.config:{}}function ir(e,t){return t.reduce(function(s,n){return n[e]?s.concat({methodName:e,pluginName:n.name,method:n[e]}):s},[])}function ar(e,t){var s=e.replace(ut,""),n=t?":"+t:"";return[""+e+n,""+s+n,s+"End"+n]}function qs(e,t){var s=e.abort;return!!s&&(s===!0||cr(s,t)||s&&cr(s.plugins,t))}function No(e,t){var s=e.abort;if(!s)return!1;if(s===!0||at(s))return!0;var n=s.plugins;return $t(s)&&s.length===t||$t(n)&&n.length===t}function $t(e){return Array.isArray(e)}function cr(e,t){return!(!e||!$t(e))&&e.includes(t)}function ur(e){var t=e.match(/(.*):(.*)/);return!!t&&{method:t[1],name:t[2]}}function Wc(e){return Object.keys(e).reduce(function(t,s){return s==="type"||(t[s]=ue(e[s])?Object.assign({},e[s]):e[s]),t},{})}function Yc(e,t,s){var n={};return function(r){return function(i){return function(o){try{var a,f=function(k){return a?k:i(y)},u=o.type,h=o.plugins,y=o;if(o.abort)return Promise.resolve(i(o));if(u===$.enablePlugin&&r.dispatch({type:$.initializeStart,plugins:h,disabled:[],fromEnable:!0,meta:o.meta}),u===$.disablePlugin&&setTimeout(function(){return sr(o.meta.rid,{payload:o})},0),u===$.initializeEnd){var w=t(),v=Object.keys(w),C=v.filter(function(k){return h.includes(k)}).map(function(k){return w[k]}),_=[],b=[],P=o.disabled,N=C.map(function(k){var A=k.loaded,q=k.name,F=k.config;return Lo(k,function(){return A({config:F})},1e4).then(function(M){return n[q]||(r.dispatch({type:$.pluginReadyType(q),name:q,events:Object.keys(k).filter(function(m){return!Gs.includes(m)})}),n[q]=!0),_=_.concat(q),k}).catch(function(M){if(M instanceof Error)throw new Error(M);return b=b.concat(M.name),M})});Promise.all(N).then(function(k){var A={plugins:_,failed:b,disabled:P};setTimeout(function(){v.length===N.length+P.length&&r.dispatch(V({},{type:$.ready},A))},0)})}var D=function(){if(u!==$.bootstrap)return/^ready:([^:]*)$/.test(u)&&setTimeout(function(){return Mo(r,t,e)},0),Promise.resolve(function(k,A,q,F,M){try{var m=Pe(A)?A():A,x=k.type,R=x.replace(ut,"");if(k._&&k._.called)return Promise.resolve(k);var S=q.getState(),I=(K=m,(Q=S.plugins)===void 0&&(Q={}),(W=k.options)===void 0&&(W={}),Object.keys(K).filter(function(d){var p=W.plugins||{};return Rc(p[d])?p[d]:p.all!==!1&&(!Q[d]||Q[d].enabled!==!1)}).map(function(d){return K[d]}));x===$.initializeStart&&k.fromEnable&&(I=Object.keys(S.plugins).filter(function(d){var p=S.plugins[d];return k.plugins.includes(d)&&!p.initialized}).map(function(d){return m[d]}));var O=I.map(function(d){return d.name}),E=function(d,p,T){var z=ar(d).map(function(G){return ir(G,p)});return p.reduce(function(G,Y){var re=Y.name,X=ar(d,re).map(function(It){return ir(It,p)}),ee=X[0],J=X[1],we=X[2];return ee.length&&(G.beforeNS[re]=ee),J.length&&(G.duringNS[re]=J),we.length&&(G.afterNS[re]=we),G},{before:z[0],beforeNS:{},during:z[1],duringNS:{},after:z[2],afterNS:{}})}(x,I);return Promise.resolve(Us({action:k,data:{exact:E.before,namespaced:E.beforeNS},state:S,allPlugins:m,allMatches:E,instance:q,store:F,EVENTS:M})).then(function(d){function p(){var G=function(){if(x.match(ut))return Promise.resolve(Us({action:V({},T,{type:R+"End"}),data:{exact:E.after,namespaced:E.afterNS},state:S,allPlugins:m,allMatches:E,instance:q,store:F,EVENTS:M})).then(function(Y){Y.meta&&Y.meta.hasCallback&&sr(Y.meta.rid,{payload:Y})})}();return G&&G.then?G.then(function(){return d}):d}if(No(d,O.length))return d;var T,z=function(){if(x!==R)return Promise.resolve(Us({action:V({},d,{type:R}),data:{exact:E.during,namespaced:E.duringNS},state:S,allPlugins:m,allMatches:E,instance:q,store:F,EVENTS:M})).then(function(G){T=G});T=d}();return z&&z.then?z.then(p):p()})}catch(d){return Promise.reject(d)}var K,Q,W}(o,t,e,r,s)).then(function(k){return a=1,i(k)})}();return Promise.resolve(D&&D.then?D.then(f):f(D))}catch(k){return Promise.reject(k)}}}}}function Jc(e){return function(t){return function(s){return function(n){var r=n.type,i=n.key,o=n.value,a=n.options;if(r===$.setItem||r===$.removeItem){if(n.abort)return s(n);r===$.setItem?e.setItem(i,o,a):e.removeItem(i,a)}return s(n)}}}}var Xc=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(a){return s.dispatch(a)}},o=e[t].map(function(a){return a(i)});return jt.apply(void 0,o)(n)(r)}}}}};function Zc(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=lr(s.type,"registerPlugin"),i=e()[r];if(!i||!r)return t;var o=s.enabled,a=i.config;return n[r]={enabled:o,initialized:!!o&&!i.initialize,loaded:!!o&&!!i.loaded({config:a}),config:a},V({},t,n)}if(/^initialize:([^:]*)$/.test(s.type)){var f=lr(s.type,$.initialize),u=e()[f];return u&&f?(n[f]=V({},t[f],{initialized:!0,loaded:!!u.loaded({config:u.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,dr(s.plugins,!1,t));case $.enablePlugin:return V({},t,dr(s.plugins,!0,t));default:return t}}}function lr(e,t){return e.substring(t.length+1,e.length)}function dr(e,t,s){return e.reduce(function(n,r){return n[r]=V({},s[r],{enabled:t}),n},s)}function To(e){try{return JSON.parse(JSON.stringify(e))}catch{}return e}var eu={last:{},history:[]};function tu(e,t){e===void 0&&(e=eu);var s=t.options,n=t.meta;if(t.type===$.track){var r=To(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 su={actions:[]};function nu(e,t){e===void 0&&(e=su);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 Uo=/#.*$/;function ru(e){var t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(Uo,""):"")}var Fo,qo,$o,Vo,ou=function(e){if(e===void 0&&(e={}),!xe)return e;var t=document,s=t.title,n=t.referrer,r=window,i=r.location,o=r.innerWidth,a=r.innerHeight,f=i.hash,u=i.search,h=function(w){var v=function(){if(xe){for(var C,_=document.getElementsByTagName("link"),b=0;C=_[b];b++)if(C.getAttribute("rel")==="canonical")return C.getAttribute("href")}}();return v?v.match(/\?/)?v:v+w:window.location.href.replace(Uo,"")}(u),y={title:s,url:h,path:ru(h),hash:f,search:u,width:o,height:a};return n&&n!==""&&(y.referrer=n),V({},y,e)},iu={last:{},history:[]};function au(e,t){e===void 0&&(e=iu);var s=t.options;if(t.type===$.page){var n=To(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}Fo=function(){if(!xe)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"}(),qo=xe?document.referrer:null,$o=Uc(),Vo=Fc();var fr={initialized:!1,sessionId:Cs(),app:null,version:null,debug:!1,offline:!!xe&&!navigator.onLine,os:{name:Fo},userAgent:xe?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.5"},timezone:Vo,locale:$o,campaign:{},referrer:qo};function cu(e,t){e===void 0&&(e=fr);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({},fr,e,{initialized:!0})}}var uu=["plugins","reducers","storage"];function lu(e,t,s){if(xe){var n=window[(s?"add":"remove")+"EventListener"];e.split(" ").forEach(function(r){n(r,t)})}}function du(e){var t=lu.bind(null,"online offline",function(s){return Promise.resolve(!navigator.onLine).then(e)});return t(!0),function(s){return t(!1)}}function Qo(){return st("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 Ot[Pt].analytics.push(o.action||o),i(o)}})}}}function hr(e){return function(){return jt(jt.apply(null,arguments),Qo())}}function $s(e){return e?Dc(e)?e:[e]:[]}function pr(e,t,s){e===void 0&&(e={});var n,r,i=Cs();return t&&(Lt[i]=(n=t,r=function(o){for(var a,f=o||Array.prototype.slice.call(arguments),u=0;u<f.length;u++)if(Pe(f[u])){a=f[u];break}return a}(s),function(o){r&&r(o),n(o)})),V({},e,{rid:i,ts:new Date().getTime()},t?{hasCallback:!0}:{})}function fu(e){e===void 0&&(e={});var t=e.reducers||{},s=e.initialUser||{},n=(e.plugins||[]).reduce(function(d,p){if(Pe(p))return d.middlewares=d.middlewares.concat(p),d;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]}):[];d.pluginEnabled[p.name]=!(p.enabled===!1||p.config.enabled===!1),delete p.enabled,p.methods&&(d.methods[p.name]=Object.keys(p.methods).reduce(function(Y,re){var X;return Y[re]=(X=p.methods[re],function(){for(var ee=Array.prototype.slice.call(arguments),J=new Array(X.length),we=0;we<ee.length;we++)J[we]=ee[we];return J[J.length]=A,X.apply({instance:A},J)}),Y},{}),delete p.methods);var z=Object.keys(p).concat(T),G=new Set(d.events.concat(z));if(d.events=Array.from(G),d.pluginsArray=d.pluginsArray.concat(p),d.plugins[p.name])throw new Error(p.name+"AlreadyLoaded");return d.plugins[p.name]=p,d.plugins[p.name].loaded||(d.plugins[p.name].loaded=function(){return!0}),d},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),r=e.storage?e.storage:{getItem:tt,setItem:st,removeItem:Bt},i=function(d){return function(p,T,z){return T.getState("user")[p]||(z&&ue(z)&&z[p]?z[p]:tr(d)[p]||tt(Ws(p))||null)}}(r),o=n.plugins,a=n.events.filter(function(d){return!Gs.includes(d)}).sort(),f=new Set(a.concat(ms).filter(function(d){return!Gs.includes(d)})),u=Array.from(f).sort(),h=function(){return o},y=new Xc,w=y.addMiddleware,v=y.removeMiddleware,C=y.dynamicMiddlewares,_=function(){throw new Error("Abort disabled inListener")},b=qc(),P=tr(r),N=V({},P,s,b.an_uid?{userId:b.an_uid}:{},b.an_aid?{anonymousId:b.an_aid}:{});N.anonymousId||(N.anonymousId=Cs());var D=V({enable:function(d,p){return new Promise(function(T){E.dispatch({type:$.enablePlugin,plugins:$s(d),_:{originalAction:$.enablePlugin}},T,[p])})},disable:function(d,p){return new Promise(function(T){E.dispatch({type:$.disablePlugin,plugins:$s(d),_:{originalAction:$.disablePlugin}},T,[p])})}},n.methods),k=!1,A={identify:function(d,p,T,z){try{var G=at(d)?d:null,Y=ue(d)?d:p,re=T||{},X=A.user();st(Ws(_e),G);var ee=G||Y.userId||i(_e,A,Y);return Promise.resolve(new Promise(function(J){E.dispatch(V({type:$.identifyStart,userId:ee,traits:Y||{},options:re,anonymousId:X.anonymousId},X.id&&X.id!==G&&{previousId:X.id}),J,[p,T,z])}))}catch(J){return Promise.reject(J)}},track:function(d,p,T,z){try{var G=ue(d)?d.event:d;if(!G||!at(G))throw new Error("EventMissing");var Y=ue(d)?d:p||{},re=ue(T)?T:{};return Promise.resolve(new Promise(function(X){E.dispatch({type:$.trackStart,event:G,properties:Y,options:re,userId:i(_e,A,p),anonymousId:i(it,A,p)},X,[p,T,z])}))}catch(X){return Promise.reject(X)}},page:function(d,p,T){try{var z=ue(d)?d:{},G=ue(p)?p:{};return Promise.resolve(new Promise(function(Y){E.dispatch({type:$.pageStart,properties:ou(z),options:G,userId:i(_e,A,z),anonymousId:i(it,A,z)},Y,[d,p,T])}))}catch(Y){return Promise.reject(Y)}},user:function(d){if(d===_e||d==="id")return i(_e,A);if(d===it||d==="anonId")return i(it,A);var p=A.getState("user");return d?Gn(p,d):p},reset:function(d){return new Promise(function(p){E.dispatch({type:$.resetStart},p,d)})},ready:function(d){return k&&d({plugins:D,instance:A}),A.on($.ready,function(p){d(p),k=!0})},on:function(d,p){if(!d||!Pe(p))return!1;if(d===$.bootstrap)throw new Error(".on disabled for "+d);var T=/Start$|Start:/;if(d==="*"){var z=function(X){return function(ee){return function(J){return J.type.match(T)&&p({payload:J,instance:A,plugins:o}),ee(J)}}},G=function(X){return function(ee){return function(J){return J.type.match(T)||p({payload:J,instance:A,plugins:o}),ee(J)}}};return w(z,fs),w(G,hs),function(){v(z,fs),v(G,hs)}}var Y=d.match(T)?fs:hs,re=function(X){return function(ee){return function(J){return J.type===d&&p({payload:J,instance:A,plugins:o,abort:_}),ee(J)}}};return w(re,Y),function(){return v(re,Y)}},once:function(d,p){if(!d||!Pe(p))return!1;if(d===$.bootstrap)throw new Error(".once disabled for "+d);var T=A.on(d,function(z){p({payload:z.payload,instance:A,plugins:o,abort:_}),T()});return T},getState:function(d){var p=E.getState();return d?Gn(p,d):Object.assign({},p)},dispatch:function(d){var p=at(d)?{type:d}:d;if(ms.includes(p.type))throw new Error("reserved action "+p.type);var T=V({},p,{_:V({originalAction:p.type},d._||{})});E.dispatch(T)},enablePlugin:D.enable,disablePlugin:D.disable,plugins:D,storage:{getItem:r.getItem,setItem:function(d,p,T){E.dispatch({type:$.setItemStart,key:d,value:p,options:T})},removeItem:function(d,p){E.dispatch({type:$.removeItemStart,key:d,options:p})}},setAnonymousId:function(d,p){A.storage.setItem(qe,d,p)},events:{core:ms,plugins:a}},q=n.middlewares.concat([function(d){return function(p){return function(T){return T.meta||(T.meta=pr()),p(T)}}},C(fs),Yc(A,h,{all:u,plugins:a}),Jc(r),zc(A),Gc(A),C(hs)]),F={context:cu,user:Hc(r),page:au,track:tu,plugins:Zc(h),queue:nu},M=jt,m=jt;if(xe&&e.debug){var x=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;x&&(M=x({trace:!0,traceLimit:25})),m=function(){return arguments.length===0?Qo():ue(typeof arguments[0])?hr():hr().apply(null,arguments)}}var R,S=function(d){return Object.keys(d).reduce(function(p,T){return uu.includes(T)||(p[T]=d[T]),p},{})}(e),I=n.pluginsArray.reduce(function(d,p){var T=p.name,z=p.config,G=p.loaded,Y=n.pluginEnabled[T];return d[T]={enabled:Y,initialized:!!Y&&!p.initialize,loaded:!!G({config:z}),config:z},d},{}),O={context:S,user:N,plugins:I},E=Do(function(d){for(var p=Object.keys(d),T={},z=0;z<p.length;z++){var G=p[z];typeof d[G]===Ie&&(T[G]=d[G])}var Y,re=Object.keys(T);try{(function(X){Object.keys(X).forEach(function(ee){var J=X[ee];if(typeof J(void 0,{type:"@@redux/INIT"})===je||typeof J(void 0,{type:Vc})===je)throw new Error("reducer "+ee+" "+je)})})(T)}catch(X){Y=X}return function(X,ee){if(X===void 0&&(X={}),Y)throw Y;for(var J=!1,we={},It=0;It<re.length;It++){var is=re[It],Rn=X[is],Ms=(0,T[is])(Rn,ee);if(typeof Ms===je){var ci=Qc(is,ee);throw new Error(ci)}we[is]=Ms,J=J||Ms!==Rn}return J?we:X}}(V({},F,t)),O,m(M(Kc.apply(void 0,q))));E.dispatch=(R=E.dispatch,function(d,p,T){var z=V({},d,{meta:pr(d.meta,p,$s(T))});return R.apply(null,[z])});var K=Object.keys(o);E.dispatch({type:$.bootstrap,plugins:K,config:S,params:b,user:N,initialUser:s,persistedUser:P});var Q=K.filter(function(d){return n.pluginEnabled[d]}),W=K.filter(function(d){return!n.pluginEnabled[d]});return E.dispatch({type:$.registerPlugins,plugins:K,enabled:n.pluginEnabled}),n.pluginsArray.map(function(d,p){var T=d.bootstrap,z=d.config,G=d.name;T&&Pe(T)&&T({instance:A,config:z,payload:d}),E.dispatch({type:$.registerPluginType(G),name:G,enabled:n.pluginEnabled[G],plugin:d}),n.pluginsArray.length===p+1&&E.dispatch({type:$.initializeStart,plugins:Q,disabled:W})}),du(function(d){E.dispatch({type:d?$.offline:$.online})}),function(d,p,T){setInterval(function(){return Mo(d,p,T)},3e3)}(E,h,A),A}var fs="before",hs="after",Ut="cookie",Ve=Ho(),Ko=Bs,hu=Bs;function zo(e){return Ve?Bs(e,"",-1):Bt(e)}function Ho(){if(Ve!==void 0)return Ve;var e="cookiecookie";try{Bs(e,e),Ve=document.cookie.indexOf(e)!==-1,zo(e)}catch{Ve=!1}return Ve}function Bs(e,t,s,n,r,i){if(typeof window<"u"){var o=arguments.length>1;return Ve===!1&&(o?st(e,t):tt(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 Ft="localStorage",pu=En.bind(null,"localStorage");_t("localStorage","getItem",tt);_t("localStorage","setItem",st);_t("localStorage","removeItem",Bt);var qt="sessionStorage",mu=En.bind(null,"sessionStorage");_t("sessionStorage","getItem",tt);_t("sessionStorage","setItem",st);_t("sessionStorage","removeItem",Bt);function lt(e){var t=e;try{if((t=JSON.parse(e))==="true")return!0;if(t==="false")return!1;if(ue(t))return t;parseFloat(t)===t&&(t=parseFloat(t))}catch{}if(t!==null&&t!=="")return t}var gu=pu(),yu=mu(),vu=Ho();function Go(e,t){if(e){var s=kn(t),n=!jn(s),r=An(s)?lt(localStorage.getItem(e)):void 0;if(n&&!ot(r))return r;var i=Pn(s)?lt(Ko(e)):void 0;if(n&&i)return i;var o=On(s)?lt(sessionStorage.getItem(e)):void 0;if(n&&o)return o;var a=tt(e);return n?a:{localStorage:r,sessionStorage:o,cookie:i,global:a}}}function bu(e,t,s){if(e&&!ot(t)){var n={},r=kn(s),i=JSON.stringify(t),o=!jn(r);return An(r)&&(n[Ft]=ps(Ft,t,lt(localStorage.getItem(e))),localStorage.setItem(e,i),o)?n[Ft]:Pn(r)&&(n[Ut]=ps(Ut,t,lt(Ko(e))),hu(e,i),o)?n[Ut]:On(r)&&(n[qt]=ps(qt,t,lt(sessionStorage.getItem(e))),sessionStorage.setItem(e,i),o)?n[qt]:(n[Tt]=ps(Tt,t,tt(e)),st(e,t),o?n[Tt]:n)}}function xu(e,t){if(e){var s=kn(t),n=Go(e,Bo),r={};return!ot(n.localStorage)&&An(s)&&(localStorage.removeItem(e),r[Ft]=n.localStorage),!ot(n.cookie)&&Pn(s)&&(zo(e),r[Ut]=n.cookie),!ot(n.sessionStorage)&&On(s)&&(sessionStorage.removeItem(e),r[qt]=n.sessionStorage),!ot(n.global)&&_s(s,Tt)&&(Bt(e),r[Tt]=n.global),r}}function kn(e){return e?at(e)?e:e.storage:Co}function An(e){return gu&&_s(e,Ft)}function Pn(e){return vu&&_s(e,Ut)}function On(e){return yu&&_s(e,qt)}function jn(e){return e===Bo||e==="all"}function _s(e,t){return e===Co||e===t||jn(e)}function ps(e,t,s){return{location:e,current:t,previous:s}}var wu={setItem:bu,getItem:Go,removeItem:xu};function Su(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function mr(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 gr(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?mr(Object(s),!0).forEach(function(n){Su(e,n,s[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):mr(Object(s)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(s,n))})}return e}function Eu(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t={storage:wu};return fu(gr(gr({},t),e))}const ku="@chaibuilder/sdk",Au="0.1.4",Pu="module",Ou=["dist"],ju="dist/core.js",Cu=!1,Bu={".":{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"}},_u={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"},Ru={"@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"},Iu={"@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",tailwindcss:"^3.3.5","ts-jest":"^29.1.1",typescript:"^5.0.2",vite:"^4.4.5","vite-plugin-dts":"^3.6.3"},Du={workerDirectory:"public"},Lu={name:ku,private:!1,version:Au,type:Pu,files:Ou,main:ju,sideEffects:Cu,exports:Bu,scripts:_u,dependencies:Ru,devDependencies:Iu,msw:Du},yr="https://api.chaibuilder.com",vr=()=>typeof window>"u"?!1:window.location.href.includes("localhost");function Mu(){return{name:"chaibuilder-analytics",config:{},initialize:()=>{if(typeof window>"u")return!1;window.chaibuilderAnalyticsLoaded=!0},page:e=>{if(typeof window>"u")return!1;if(vr())return;const{payload:t}=e;fetch(`${yr}/v1/log`,{method:"post",body:JSON.stringify(t)}).then(s=>s.json())},track:({payload:e})=>{if(typeof window>"u")return!1;vr()||fetch(`${yr}/v1/log`,{method:"post",body:JSON.stringify(e)})},loaded:()=>typeof window>"u"?!0:!!window.chaibuilderAnalyticsLoaded}}const Nu=Eu({app:"chaibuilder",version:Lu.version,plugins:[Mu()]});({}).NODE_ENV==="development"&&console.log("Chai Builder:",Ei);const Tu=e=>B.jsxRuntimeExports.jsx(B.jsxRuntimeExports.Fragment,{children:e.children}),Uu=e=>{const{dndOptions:t={backend:In.MultiBackend}}=e,[s]=Kr(),[,n]=gn(),r=Po();return L.useEffect(()=>{jc.set(be.chaiBuilderPropsAtom,l.omit(e,["blocks","globalBlocks","brandingOptions"]))},[e]),L.useEffect(()=>{s(Nr.syncBlocksWithDefaults(e.blocks||[])),r()},[e.blocks]),L.useEffect(()=>{n(e.brandingOptions)},[e.brandingOptions]),L.useEffect(()=>{Nu.page()},[]),B.jsxRuntimeExports.jsx(fi.DndProvider,{...t,options:In.getBackendOptions(),children:B.jsxRuntimeExports.jsx(Tu,{children:B.jsxRuntimeExports.jsx(Oc,{})})})},Wo=e=>B.jsxRuntimeExports.jsxs(Tr,{children:[B.jsxRuntimeExports.jsx(di.FlagsProvider,{features:ki,children:B.jsxRuntimeExports.jsx(Uu,{...e})}),B.jsxRuntimeExports.jsx(be.Toaster,{})]});var Rt=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(){}},Ct=typeof window>"u"||"Deno"in window;function pe(){}function Fu(e,t){return typeof e=="function"?e(t):e}function Ys(e){return typeof e=="number"&&e>=0&&e!==1/0}function Yo(e,t){return Math.max(e+(t||0)-Date.now(),0)}function br(e,t){const{type:s="all",exact:n,fetchStatus:r,predicate:i,queryKey:o,stale:a}=e;if(o){if(n){if(t.queryHash!==Cn(o,t.options))return!1}else if(!Qt(t.queryKey,o))return!1}if(s!=="all"){const f=t.isActive();if(s==="active"&&!f||s==="inactive"&&f)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||typeof r<"u"&&r!==t.state.fetchStatus||i&&!i(t))}function xr(e,t){const{exact:s,status:n,predicate:r,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(s){if(Vt(t.options.mutationKey)!==Vt(i))return!1}else if(!Qt(t.options.mutationKey,i))return!1}return!(n&&t.state.status!==n||r&&!r(t))}function Cn(e,t){return((t==null?void 0:t.queryKeyHashFn)||Vt)(e)}function Vt(e){return JSON.stringify(e,(t,s)=>Js(s)?Object.keys(s).sort().reduce((n,r)=>(n[r]=s[r],n),{}):s)}function Qt(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(s=>!Qt(e[s],t[s])):!1}function Jo(e,t){if(e===t)return e;const s=wr(e)&&wr(t);if(s||Js(e)&&Js(t)){const n=s?e.length:Object.keys(e).length,r=s?t:Object.keys(t),i=r.length,o=s?[]:{};let a=0;for(let f=0;f<i;f++){const u=s?f:r[f];o[u]=Jo(e[u],t[u]),o[u]===e[u]&&a++}return n===i&&a===n?e:o}return t}function xs(e,t){if(e&&!t||t&&!e)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function wr(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Js(e){if(!Sr(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const s=t.prototype;return!(!Sr(s)||!s.hasOwnProperty("isPrototypeOf"))}function Sr(e){return Object.prototype.toString.call(e)==="[object Object]"}function Xo(e){return new Promise(t=>{setTimeout(t,e)})}function Er(e){Xo(0).then(e)}function Xs(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?Jo(e,t):t}function qu(e,t,s=0){const n=[...e,t];return s&&n.length>s?n.slice(1):n}function $u(e,t,s=0){const n=[t,...e];return s&&n.length>s?n.slice(0,-1):n}var Qe,De,dt,Or,Vu=(Or=class extends Rt{constructor(){super();U(this,Qe,void 0);U(this,De,void 0);U(this,dt,void 0);j(this,dt,t=>{if(!Ct&&window.addEventListener){const s=()=>t();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){c(this,De)||this.setEventListener(c(this,dt))}onUnsubscribe(){var t;this.hasListeners()||((t=c(this,De))==null||t.call(this),j(this,De,void 0))}setEventListener(t){var s;j(this,dt,t),(s=c(this,De))==null||s.call(this),j(this,De,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){c(this,Qe)!==t&&(j(this,Qe,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof c(this,Qe)=="boolean"?c(this,Qe):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Qe=new WeakMap,De=new WeakMap,dt=new WeakMap,Or),ws=new Vu,ft,Le,ht,jr,Qu=(jr=class extends Rt{constructor(){super();U(this,ft,!0);U(this,Le,void 0);U(this,ht,void 0);j(this,ht,t=>{if(!Ct&&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(){c(this,Le)||this.setEventListener(c(this,ht))}onUnsubscribe(){var t;this.hasListeners()||((t=c(this,Le))==null||t.call(this),j(this,Le,void 0))}setEventListener(t){var s;j(this,ht,t),(s=c(this,Le))==null||s.call(this),j(this,Le,t(this.setOnline.bind(this)))}setOnline(t){c(this,ft)!==t&&(j(this,ft,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return c(this,ft)}},ft=new WeakMap,Le=new WeakMap,ht=new WeakMap,jr),Ss=new Qu;function Ku(e){return Math.min(1e3*2**e,3e4)}function Rs(e){return(e??"online")==="online"?Ss.isOnline():!0}var Zo=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Vs(e){return e instanceof Zo}function ei(e){let t=!1,s=0,n=!1,r,i,o;const a=new Promise((b,P)=>{i=b,o=P}),f=b=>{var P;n||(v(new Zo(b)),(P=e.abort)==null||P.call(e))},u=()=>{t=!0},h=()=>{t=!1},y=()=>!ws.isFocused()||e.networkMode!=="always"&&!Ss.isOnline(),w=b=>{var P;n||(n=!0,(P=e.onSuccess)==null||P.call(e,b),r==null||r(),i(b))},v=b=>{var P;n||(n=!0,(P=e.onError)==null||P.call(e,b),r==null||r(),o(b))},C=()=>new Promise(b=>{var P;r=N=>{const D=n||!y();return D&&b(N),D},(P=e.onPause)==null||P.call(e)}).then(()=>{var b;r=void 0,n||(b=e.onContinue)==null||b.call(e)}),_=()=>{if(n)return;let b;try{b=e.fn()}catch(P){b=Promise.reject(P)}Promise.resolve(b).then(w).catch(P=>{var q;if(n)return;const N=e.retry??(Ct?0:3),D=e.retryDelay??Ku,k=typeof D=="function"?D(s,P):D,A=N===!0||typeof N=="number"&&s<N||typeof N=="function"&&N(s,P);if(t||!A){v(P);return}s++,(q=e.onFail)==null||q.call(e,s,P),Xo(k).then(()=>{if(y())return C()}).then(()=>{t?v(P):_()})})};return Rs(e.networkMode)?_():C().then(_),{promise:a,cancel:f,continue:()=>(r==null?void 0:r())?a:Promise.resolve(),cancelRetry:u,continueRetry:h}}function zu(){let e=[],t=0,s=h=>{h()},n=h=>{h()};const r=h=>{let y;t++;try{y=h()}finally{t--,t||a()}return y},i=h=>{t?e.push(h):Er(()=>{s(h)})},o=h=>(...y)=>{i(()=>{h(...y)})},a=()=>{const h=e;e=[],h.length&&Er(()=>{n(()=>{h.forEach(y=>{s(y)})})})};return{batch:r,batchCalls:o,schedule:i,setNotifyFunction:h=>{s=h},setBatchNotifyFunction:h=>{n=h}}}var ne=zu(),Ke,Cr,ti=(Cr=class{constructor(){U(this,Ke,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ys(this.gcTime)&&j(this,Ke,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ct?1/0:5*60*1e3))}clearGcTimeout(){c(this,Ke)&&(clearTimeout(c(this,Ke)),j(this,Ke,void 0))}},Ke=new WeakMap,Cr),pt,mt,de,Me,fe,se,Kt,ze,gt,gs,ve,Oe,Br,Hu=(Br=class extends ti{constructor(t){super();U(this,gt);U(this,ve);U(this,pt,void 0);U(this,mt,void 0);U(this,de,void 0);U(this,Me,void 0);U(this,fe,void 0);U(this,se,void 0);U(this,Kt,void 0);U(this,ze,void 0);j(this,ze,!1),j(this,Kt,t.defaultOptions),H(this,gt,gs).call(this,t.options),j(this,se,[]),j(this,de,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,j(this,pt,t.state||Gu(this.options)),this.state=c(this,pt),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!c(this,se).length&&this.state.fetchStatus==="idle"&&c(this,de).remove(this)}setData(t,s){const n=Xs(this.state.data,t,this.options);return H(this,ve,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){H(this,ve,Oe).call(this,{type:"setState",state:t,setStateOptions:s})}cancel(t){var n;const s=c(this,Me);return(n=c(this,fe))==null||n.cancel(t),s?s.then(pe).catch(pe):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(c(this,pt))}isActive(){return c(this,se).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||c(this,se).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!Yo(this.state.dataUpdatedAt,t)}onFocus(){var s;const t=c(this,se).find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(s=c(this,fe))==null||s.continue()}onOnline(){var s;const t=c(this,se).find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(s=c(this,fe))==null||s.continue()}addObserver(t){c(this,se).includes(t)||(c(this,se).push(t),this.clearGcTimeout(),c(this,de).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){c(this,se).includes(t)&&(j(this,se,c(this,se).filter(s=>s!==t)),c(this,se).length||(c(this,fe)&&(c(this,ze)?c(this,fe).cancel({revert:!0}):c(this,fe).cancelRetry()),this.scheduleGc()),c(this,de).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return c(this,se).length}invalidate(){this.state.isInvalidated||H(this,ve,Oe).call(this,{type:"invalidate"})}fetch(t,s){var u,h,y,w;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(c(this,Me))return(u=c(this,fe))==null||u.continueRetry(),c(this,Me)}if(t&&H(this,gt,gs).call(this,t),!this.options.queryFn){const v=c(this,se).find(C=>C.options.queryFn);v&&H(this,gt,gs).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:()=>(j(this,ze,!0),n.signal)})};i(r);const o=()=>this.options.queryFn?(j(this,ze,!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}'`)),a={fetchOptions:s,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:o};i(a),(h=this.options.behavior)==null||h.onFetch(a,this),j(this,mt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((y=a.fetchOptions)==null?void 0:y.meta))&&H(this,ve,Oe).call(this,{type:"fetch",meta:(w=a.fetchOptions)==null?void 0:w.meta});const f=v=>{var C,_,b,P;Vs(v)&&v.silent||H(this,ve,Oe).call(this,{type:"error",error:v}),Vs(v)||((_=(C=c(this,de).config).onError)==null||_.call(C,v,this),(P=(b=c(this,de).config).onSettled)==null||P.call(b,this.state.data,v,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return j(this,fe,ei({fn:a.fetchFn,abort:n.abort.bind(n),onSuccess:v=>{var C,_,b,P;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}`),f(new Error(`${this.queryHash} data is undefined`));return}this.setData(v),(_=(C=c(this,de).config).onSuccess)==null||_.call(C,v,this),(P=(b=c(this,de).config).onSettled)==null||P.call(b,v,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:f,onFail:(v,C)=>{H(this,ve,Oe).call(this,{type:"failed",failureCount:v,error:C})},onPause:()=>{H(this,ve,Oe).call(this,{type:"pause"})},onContinue:()=>{H(this,ve,Oe).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode})),j(this,Me,c(this,fe).promise),c(this,Me)}},pt=new WeakMap,mt=new WeakMap,de=new WeakMap,Me=new WeakMap,fe=new WeakMap,se=new WeakMap,Kt=new WeakMap,ze=new WeakMap,gt=new WeakSet,gs=function(t){this.options={...c(this,Kt),...t},this.updateGcTime(this.options.gcTime)},ve=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:Rs(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 Vs(r)&&r.revert&&c(this,mt)?{...c(this,mt),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),ne.batch(()=>{c(this,se).forEach(n=>{n.onQueryUpdate()}),c(this,de).notify({query:this,type:"updated",action:t})})},Br);function Gu(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 Se,_r,Wu=(_r=class extends Rt{constructor(t={}){super();U(this,Se,void 0);this.config=t,j(this,Se,new Map)}build(t,s,n){const r=s.queryKey,i=s.queryHash??Cn(r,s);let o=this.get(i);return o||(o=new Hu({cache:this,queryKey:r,queryHash:i,options:t.defaultQueryOptions(s),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(o)),o}add(t){c(this,Se).has(t.queryHash)||(c(this,Se).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const s=c(this,Se).get(t.queryHash);s&&(t.destroy(),s===t&&c(this,Se).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ne.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return c(this,Se).get(t)}getAll(){return[...c(this,Se).values()]}find(t){const s={exact:!0,...t};return this.getAll().find(n=>br(s,n))}findAll(t={}){const s=this.getAll();return Object.keys(t).length>0?s.filter(n=>br(t,n)):s}notify(t){ne.batch(()=>{this.listeners.forEach(s=>{s(t)})})}onFocus(){ne.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ne.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Se=new WeakMap,_r),Ee,zt,ce,yt,ke,Be,Rr,Yu=(Rr=class extends ti{constructor(t){super();U(this,ke);U(this,Ee,void 0);U(this,zt,void 0);U(this,ce,void 0);U(this,yt,void 0);this.mutationId=t.mutationId,j(this,zt,t.defaultOptions),j(this,ce,t.mutationCache),j(this,Ee,[]),this.state=t.state||si(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...c(this,zt),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){c(this,Ee).includes(t)||(c(this,Ee).push(t),this.clearGcTimeout(),c(this,ce).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){j(this,Ee,c(this,Ee).filter(s=>s!==t)),this.scheduleGc(),c(this,ce).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){c(this,Ee).length||(this.state.status==="pending"?this.scheduleGc():c(this,ce).remove(this))}continue(){var t;return((t=c(this,yt))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var r,i,o,a,f,u,h,y,w,v,C,_,b,P,N,D,k,A,q,F;const s=()=>(j(this,yt,ei({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(M,m)=>{H(this,ke,Be).call(this,{type:"failed",failureCount:M,error:m})},onPause:()=>{H(this,ke,Be).call(this,{type:"pause"})},onContinue:()=>{H(this,ke,Be).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),c(this,yt).promise),n=this.state.status==="pending";try{if(!n){H(this,ke,Be).call(this,{type:"pending",variables:t}),await((i=(r=c(this,ce).config).onMutate)==null?void 0:i.call(r,t,this));const m=await((a=(o=this.options).onMutate)==null?void 0:a.call(o,t));m!==this.state.context&&H(this,ke,Be).call(this,{type:"pending",context:m,variables:t})}const M=await s();return await((u=(f=c(this,ce).config).onSuccess)==null?void 0:u.call(f,M,t,this.state.context,this)),await((y=(h=this.options).onSuccess)==null?void 0:y.call(h,M,t,this.state.context)),await((v=(w=c(this,ce).config).onSettled)==null?void 0:v.call(w,M,null,this.state.variables,this.state.context,this)),await((_=(C=this.options).onSettled)==null?void 0:_.call(C,M,null,t,this.state.context)),H(this,ke,Be).call(this,{type:"success",data:M}),M}catch(M){try{throw await((P=(b=c(this,ce).config).onError)==null?void 0:P.call(b,M,t,this.state.context,this)),await((D=(N=this.options).onError)==null?void 0:D.call(N,M,t,this.state.context)),await((A=(k=c(this,ce).config).onSettled)==null?void 0:A.call(k,void 0,M,this.state.variables,this.state.context,this)),await((F=(q=this.options).onSettled)==null?void 0:F.call(q,void 0,M,t,this.state.context)),M}finally{H(this,ke,Be).call(this,{type:"error",error:M})}}}},Ee=new WeakMap,zt=new WeakMap,ce=new WeakMap,yt=new WeakMap,ke=new WeakSet,Be=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:!Rs(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),ne.batch(()=>{c(this,Ee).forEach(n=>{n.onMutationUpdate(t)}),c(this,ce).notify({mutation:this,type:"updated",action:t})})},Rr);function si(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var he,Ht,He,Ir,Ju=(Ir=class extends Rt{constructor(t={}){super();U(this,he,void 0);U(this,Ht,void 0);U(this,He,void 0);this.config=t,j(this,he,[]),j(this,Ht,0)}build(t,s,n){const r=new Yu({mutationCache:this,mutationId:++as(this,Ht)._,options:t.defaultMutationOptions(s),state:n});return this.add(r),r}add(t){c(this,he).push(t),this.notify({type:"added",mutation:t})}remove(t){j(this,he,c(this,he).filter(s=>s!==t)),this.notify({type:"removed",mutation:t})}clear(){ne.batch(()=>{c(this,he).forEach(t=>{this.remove(t)})})}getAll(){return c(this,he)}find(t){const s={exact:!0,...t};return c(this,he).find(n=>xr(s,n))}findAll(t={}){return c(this,he).filter(s=>xr(t,s))}notify(t){ne.batch(()=>{this.listeners.forEach(s=>{s(t)})})}resumePausedMutations(){return j(this,He,(c(this,He)??Promise.resolve()).then(()=>{const t=c(this,he).filter(s=>s.state.isPaused);return ne.batch(()=>t.reduce((s,n)=>s.then(()=>n.continue().catch(pe)),Promise.resolve()))}).then(()=>{j(this,He,void 0)})),c(this,He)}},he=new WeakMap,Ht=new WeakMap,He=new WeakMap,Ir);function Xu(e){return{onFetch:(t,s)=>{const n=async()=>{var C,_,b,P,N;const r=t.options,i=(b=(_=(C=t.fetchOptions)==null?void 0:C.meta)==null?void 0:_.fetchMore)==null?void 0:b.direction,o=((P=t.state.data)==null?void 0:P.pages)||[],a=((N=t.state.data)==null?void 0:N.pageParams)||[],f={pages:[],pageParams:[]};let u=!1;const h=D=>{Object.defineProperty(D,"signal",{enumerable:!0,get:()=>(t.signal.aborted?u=!0:t.signal.addEventListener("abort",()=>{u=!0}),t.signal)})},y=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),w=async(D,k,A)=>{if(u)return Promise.reject();if(k==null&&D.pages.length)return Promise.resolve(D);const q={queryKey:t.queryKey,pageParam:k,direction:A?"backward":"forward",meta:t.options.meta};h(q);const F=await y(q),{maxPages:M}=t.options,m=A?$u:qu;return{pages:m(D.pages,F,M),pageParams:m(D.pageParams,k,M)}};let v;if(i&&o.length){const D=i==="backward",k=D?Zu:kr,A={pages:o,pageParams:a},q=k(r,A);v=await w(A,q,D)}else{v=await w(f,a[0]??r.initialPageParam);const D=e??o.length;for(let k=1;k<D;k++){const A=kr(r,v);v=await w(v,A)}}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 kr(e,{pages:t,pageParams:s}){const n=t.length-1;return e.getNextPageParam(t[n],t,s[n],s)}function Zu(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,Ne,Te,vt,bt,Ue,xt,wt,Dr,el=(Dr=class{constructor(e={}){U(this,te,void 0);U(this,Ne,void 0);U(this,Te,void 0);U(this,vt,void 0);U(this,bt,void 0);U(this,Ue,void 0);U(this,xt,void 0);U(this,wt,void 0);j(this,te,e.queryCache||new Wu),j(this,Ne,e.mutationCache||new Ju),j(this,Te,e.defaultOptions||{}),j(this,vt,new Map),j(this,bt,new Map),j(this,Ue,0)}mount(){as(this,Ue)._++,c(this,Ue)===1&&(j(this,xt,ws.subscribe(()=>{ws.isFocused()&&(this.resumePausedMutations(),c(this,te).onFocus())})),j(this,wt,Ss.subscribe(()=>{Ss.isOnline()&&(this.resumePausedMutations(),c(this,te).onOnline())})))}unmount(){var e,t;as(this,Ue)._--,c(this,Ue)===0&&((e=c(this,xt))==null||e.call(this),j(this,xt,void 0),(t=c(this,wt))==null||t.call(this),j(this,wt,void 0))}isFetching(e){return c(this,te).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return c(this,Ne).findAll({...e,status:"pending"}).length}getQueryData(e){var t;return(t=c(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=c(this,te).find({queryKey:e}),r=n==null?void 0:n.state.data,i=Fu(t,r);if(typeof i>"u")return;const o=this.defaultQueryOptions({queryKey:e});return c(this,te).build(this,o).setData(i,{...s,manual:!0})}setQueriesData(e,t,s){return ne.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,s)]))}getQueryState(e){var t;return(t=c(this,te).find({queryKey:e}))==null?void 0:t.state}removeQueries(e){const t=c(this,te);ne.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=c(this,te),n={type:"active",...e};return ne.batch(()=>(s.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries(n,t)))}cancelQueries(e={},t={}){const s={revert:!0,...t},n=ne.batch(()=>c(this,te).findAll(e).map(r=>r.cancel(s)));return Promise.all(n).then(pe).catch(pe)}invalidateQueries(e={},t={}){return ne.batch(()=>{if(c(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=ne.batch(()=>c(this,te).findAll(e).filter(r=>!r.isDisabled()).map(r=>{let i=r.fetch(void 0,s);return s.throwOnError||(i=i.catch(pe)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(pe)}fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const s=c(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(pe).catch(pe)}fetchInfiniteQuery(e){return e.behavior=Xu(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(pe).catch(pe)}resumePausedMutations(){return c(this,Ne).resumePausedMutations()}getQueryCache(){return c(this,te)}getMutationCache(){return c(this,Ne)}getDefaultOptions(){return c(this,Te)}setDefaultOptions(e){j(this,Te,e)}setQueryDefaults(e,t){c(this,vt).set(Vt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...c(this,vt).values()];let s={};return t.forEach(n=>{Qt(e,n.queryKey)&&(s={...s,...n.defaultOptions})}),s}setMutationDefaults(e,t){c(this,bt).set(Vt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...c(this,bt).values()];let s={};return t.forEach(n=>{Qt(e,n.mutationKey)&&(s={...s,...n.defaultOptions})}),s}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...c(this,Te).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Cn(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:{...c(this,Te).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){c(this,te).clear(),c(this,Ne).clear()}},te=new WeakMap,Ne=new WeakMap,Te=new WeakMap,vt=new WeakMap,bt=new WeakMap,Ue=new WeakMap,xt=new WeakMap,wt=new WeakMap,Dr),ae,Z,St,oe,Ge,Et,Ae,Gt,kt,At,We,Ye,Fe,Je,Xe,Mt,Wt,Zs,Yt,en,Jt,tn,Xt,sn,Zt,nn,es,rn,ts,on,Es,ni,Lr,tl=(Lr=class extends Rt{constructor(t,s){super();U(this,Xe);U(this,Wt);U(this,Yt);U(this,Jt);U(this,Xt);U(this,Zt);U(this,es);U(this,ts);U(this,Es);U(this,ae,void 0);U(this,Z,void 0);U(this,St,void 0);U(this,oe,void 0);U(this,Ge,void 0);U(this,Et,void 0);U(this,Ae,void 0);U(this,Gt,void 0);U(this,kt,void 0);U(this,At,void 0);U(this,We,void 0);U(this,Ye,void 0);U(this,Fe,void 0);U(this,Je,void 0);j(this,Z,void 0),j(this,St,void 0),j(this,oe,void 0),j(this,Je,new Set),j(this,ae,t),this.options=s,j(this,Ae,null),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(c(this,Z).addObserver(this),Ar(c(this,Z),this.options)?H(this,Xe,Mt).call(this):this.updateResult(),H(this,Xt,sn).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return an(c(this,Z),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return an(c(this,Z),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,H(this,Zt,nn).call(this),H(this,es,rn).call(this),c(this,Z).removeObserver(this)}setOptions(t,s){const n=this.options,r=c(this,Z);if(this.options=c(this,ae).defaultQueryOptions(t),xs(n,this.options)||c(this,ae).getQueryCache().notify({type:"observerOptionsUpdated",query:c(this,Z),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),H(this,ts,on).call(this);const i=this.hasListeners();i&&Pr(c(this,Z),r,this.options,n)&&H(this,Xe,Mt).call(this),this.updateResult(s),i&&(c(this,Z)!==r||this.options.enabled!==n.enabled||this.options.staleTime!==n.staleTime)&&H(this,Wt,Zs).call(this);const o=H(this,Yt,en).call(this);i&&(c(this,Z)!==r||this.options.enabled!==n.enabled||o!==c(this,Fe))&&H(this,Jt,tn).call(this,o)}getOptimisticResult(t){const s=c(this,ae).getQueryCache().build(c(this,ae),t),n=this.createResult(s,t);return nl(this,n)&&(j(this,oe,n),j(this,Et,this.options),j(this,Ge,c(this,Z).state)),n}getCurrentResult(){return c(this,oe)}trackResult(t){const s={};return Object.keys(t).forEach(n=>{Object.defineProperty(s,n,{configurable:!1,enumerable:!0,get:()=>(c(this,Je).add(n),t[n])})}),s}getCurrentQuery(){return c(this,Z)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=c(this,ae).defaultQueryOptions(t),n=c(this,ae).getQueryCache().build(c(this,ae),s);return n.isFetchingOptimistic=!0,n.fetch().then(()=>this.createResult(n,s))}fetch(t){return H(this,Xe,Mt).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),c(this,oe)))}createResult(t,s){var q;const n=c(this,Z),r=this.options,i=c(this,oe),o=c(this,Ge),a=c(this,Et),u=t!==n?t.state:c(this,St),{state:h}=t;let{error:y,errorUpdatedAt:w,fetchStatus:v,status:C}=h,_=!1,b;if(s._optimisticResults){const F=this.hasListeners(),M=!F&&Ar(t,s),m=F&&Pr(t,n,s,r);(M||m)&&(v=Rs(t.options.networkMode)?"fetching":"paused",h.dataUpdatedAt||(C="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===c(this,Gt))b=c(this,kt);else try{j(this,Gt,s.select),b=s.select(h.data),b=Xs(i==null?void 0:i.data,b,s),j(this,kt,b),j(this,Ae,null)}catch(F){j(this,Ae,F)}else b=h.data;if(typeof s.placeholderData<"u"&&typeof b>"u"&&C==="pending"){let F;if(i!=null&&i.isPlaceholderData&&s.placeholderData===(a==null?void 0:a.placeholderData))F=i.data;else if(F=typeof s.placeholderData=="function"?s.placeholderData((q=c(this,At))==null?void 0:q.state.data,c(this,At)):s.placeholderData,s.select&&typeof F<"u")try{F=s.select(F),j(this,Ae,null)}catch(M){j(this,Ae,M)}typeof F<"u"&&(C="success",b=Xs(i==null?void 0:i.data,F,s),_=!0)}c(this,Ae)&&(y=c(this,Ae),b=c(this,kt),w=Date.now(),C="error");const P=v==="fetching",N=C==="pending",D=C==="error",k=N&&P;return{status:C,fetchStatus:v,isPending:N,isSuccess:C==="success",isError:D,isInitialLoading:k,isLoading:k,data:b,dataUpdatedAt:h.dataUpdatedAt,error:y,errorUpdatedAt:w,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:P,isRefetching:P&&!N,isLoadingError:D&&h.dataUpdatedAt===0,isPaused:v==="paused",isPlaceholderData:_,isRefetchError:D&&h.dataUpdatedAt!==0,isStale:Bn(t,s),refetch:this.refetch}}updateResult(t){const s=c(this,oe),n=this.createResult(c(this,Z),this.options);if(j(this,Ge,c(this,Z).state),j(this,Et,this.options),c(this,Ge).data!==void 0&&j(this,At,c(this,Z)),xs(n,s))return;j(this,oe,n);const r={},i=()=>{if(!s)return!0;const{notifyOnChangeProps:o}=this.options,a=typeof o=="function"?o():o;if(a==="all"||!a&&!c(this,Je).size)return!0;const f=new Set(a??c(this,Je));return this.options.throwOnError&&f.add("error"),Object.keys(c(this,oe)).some(u=>{const h=u;return c(this,oe)[h]!==s[h]&&f.has(h)})};(t==null?void 0:t.listeners)!==!1&&i()&&(r.listeners=!0),H(this,Es,ni).call(this,{...r,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&H(this,Xt,sn).call(this)}},ae=new WeakMap,Z=new WeakMap,St=new WeakMap,oe=new WeakMap,Ge=new WeakMap,Et=new WeakMap,Ae=new WeakMap,Gt=new WeakMap,kt=new WeakMap,At=new WeakMap,We=new WeakMap,Ye=new WeakMap,Fe=new WeakMap,Je=new WeakMap,Xe=new WeakSet,Mt=function(t){H(this,ts,on).call(this);let s=c(this,Z).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(pe)),s},Wt=new WeakSet,Zs=function(){if(H(this,Zt,nn).call(this),Ct||c(this,oe).isStale||!Ys(this.options.staleTime))return;const s=Yo(c(this,oe).dataUpdatedAt,this.options.staleTime)+1;j(this,We,setTimeout(()=>{c(this,oe).isStale||this.updateResult()},s))},Yt=new WeakSet,en=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(c(this,Z)):this.options.refetchInterval)??!1},Jt=new WeakSet,tn=function(t){H(this,es,rn).call(this),j(this,Fe,t),!(Ct||this.options.enabled===!1||!Ys(c(this,Fe))||c(this,Fe)===0)&&j(this,Ye,setInterval(()=>{(this.options.refetchIntervalInBackground||ws.isFocused())&&H(this,Xe,Mt).call(this)},c(this,Fe)))},Xt=new WeakSet,sn=function(){H(this,Wt,Zs).call(this),H(this,Jt,tn).call(this,H(this,Yt,en).call(this))},Zt=new WeakSet,nn=function(){c(this,We)&&(clearTimeout(c(this,We)),j(this,We,void 0))},es=new WeakSet,rn=function(){c(this,Ye)&&(clearInterval(c(this,Ye)),j(this,Ye,void 0))},ts=new WeakSet,on=function(){const t=c(this,ae).getQueryCache().build(c(this,ae),this.options);if(t===c(this,Z))return;const s=c(this,Z);j(this,Z,t),j(this,St,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},Es=new WeakSet,ni=function(t){ne.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(c(this,oe))}),c(this,ae).getQueryCache().notify({query:c(this,Z),type:"observerResultsUpdated"})})},Lr);function sl(e,t){return t.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ar(e,t){return sl(e,t)||e.state.dataUpdatedAt>0&&an(e,t,t.refetchOnMount)}function an(e,t,s){if(t.enabled!==!1){const n=typeof s=="function"?s(e):s;return n==="always"||n!==!1&&Bn(e,t)}return!1}function Pr(e,t,s,n){return s.enabled!==!1&&(e!==t||n.enabled===!1)&&(!s.suspense||e.state.status!=="error")&&Bn(e,s)}function Bn(e,t){return e.isStaleByTime(t.staleTime)}function nl(e,t){return!xs(e.getCurrentResult(),t)}var ri=le.createContext(void 0),os=e=>{const t=le.useContext(ri);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},rl=({client:e,children:t})=>(le.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),le.createElement(ri.Provider,{value:e},t)),oi=le.createContext(!1),ol=()=>le.useContext(oi);oi.Provider;function il(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var al=le.createContext(il()),cl=()=>le.useContext(al);function ii(e,t){return typeof e=="function"?e(...t):!!e}var ul=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},ll=e=>{le.useEffect(()=>{e.clearReset()},[e])},dl=({result:e,errorResetBoundary:t,throwOnError:s,query:n})=>e.isError&&!t.isReset()&&!e.isFetching&&ii(s,[e.error,n]),fl=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},hl=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,pl=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function ml(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=os(s),r=ol(),i=cl(),o=n.defaultQueryOptions(e);o._optimisticResults=r?"isRestoring":"optimistic",fl(o),ul(o,i),ll(i);const[a]=le.useState(()=>new t(n,o)),f=a.getOptimisticResult(o);if(le.useSyncExternalStore(le.useCallback(u=>{const h=r?()=>{}:a.subscribe(ne.batchCalls(u));return a.updateResult(),h},[a,r]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),le.useEffect(()=>{a.setOptions(o,{listeners:!1})},[o,a]),hl(o,f))throw pl(o,a,i);if(dl({result:f,errorResetBoundary:i,throwOnError:o.throwOnError,query:a.getCurrentQuery()}))throw f.error;return o.notifyOnChangeProps?f:a.trackResult(f)}function Is(e,t){return ml(e,tl,t)}const gl=()=>Is({queryKey:["user"],queryFn:async()=>await localStorage.getItem("__nano_id")}),yl=()=>B.jsxRuntimeExports.jsx("section",{className:"py-10 h-screen bg-gray-50 sm:py-16 lg:py-24",children:B.jsxRuntimeExports.jsxs("div",{className:"px-4 mx-auto max-w-7xl sm:px-6 lg:px-8",children:[B.jsxRuntimeExports.jsxs("div",{className:"max-w-2xl mx-auto text-center",children:[B.jsxRuntimeExports.jsx("h2",{className:"text-3xl font-bold leading-tight text-black sm:text-4xl lg:text-5xl",children:"Welcome Back!"}),B.jsxRuntimeExports.jsx("p",{className:"max-w-xl mx-auto mt-4 text-base leading-relaxed text-gray-600",children:"Login to your account"})]}),B.jsxRuntimeExports.jsx("div",{className:"relative max-w-md mx-auto mt-8 md:mt-16",children:B.jsxRuntimeExports.jsx("div",{className:"overflow-hidden bg-white rounded-md shadow-md",children:B.jsxRuntimeExports.jsx("div",{className:"px-4 py-6 sm:px-8 sm:py-7",children:B.jsxRuntimeExports.jsx("form",{action:"#",method:"POST",children:B.jsxRuntimeExports.jsxs("div",{className:"space-y-5",children:[B.jsxRuntimeExports.jsxs("div",{children:[B.jsxRuntimeExports.jsx("label",{htmlFor:"",className:"text-base font-medium text-gray-900",children:"Email address"}),B.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[B.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:B.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:B.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"})})}),B.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"})]})]}),B.jsxRuntimeExports.jsxs("div",{children:[B.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between",children:B.jsxRuntimeExports.jsx("label",{htmlFor:"",className:"text-base font-medium text-gray-900",children:"Password"})}),B.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[B.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:B.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:B.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"})})}),B.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"})]})]}),B.jsxRuntimeExports.jsx("div",{children:B.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 Ds(){return os().getQueryData(["apiBaseUrl"])||"/api/chaibuilder"}const _n=()=>{const e=os();let t=e.getQueryData(["currentPage"]);return t||(t=localStorage.getItem("currentPage")),[t||"",s=>{localStorage.setItem("currentPage",s||""),e.setQueryData(["currentPage"],s||"")}]},Ls=()=>{const[e,t]=_n(),s=Ds();return Is({queryKey:["project"],queryFn:async()=>{const n=await fetch(`${s}/project`).then(r=>r.json());return!e&&n&&t(n.homepage),n}})},ai=()=>{const{data:e}=Ls(),t=Ds(),s=e==null?void 0:e.uuid;return Is({queryKey:["pages",s],queryFn:async()=>await fetch(`${t}/pages`).then(r=>r.json())||[],enabled:!!s})},vl=()=>{const[e,t]=_n(),{data:s}=Ls(),n=Ds();return Is({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})},bl=L.lazy(()=>Promise.resolve().then(()=>require("./PagesPanel-b08e1357.cjs"))),xl=L.lazy(()=>Promise.resolve().then(()=>require("./ProjectPanel-f0b94e3f.cjs"))),wl=()=>{const{data:e,isLoading:t}=Ls(),{data:s,isLoading:n}=ai(),{data:r}=vl();return t||!e?B.jsxRuntimeExports.jsx("div",{children:"Loading..."}):n||!s?B.jsxRuntimeExports.jsx("div",{children:"Loading..."}):r?B.jsxRuntimeExports.jsx("div",{className:"bg-background text-foreground",children:B.jsxRuntimeExports.jsx(Wo,{blocks:r.blocks,brandingOptions:e.brandingOptions,darkMode:!0,onSaveBlocks:async()=>{},onSaveBrandingOptions:async()=>{},sideBarComponents:{top:[{icon:Dn.FileTextIcon,name:"pages",panel:bl},{icon:Dn.GearIcon,name:"settings",panel:xl}]}})}):B.jsxRuntimeExports.jsx("div",{children:"Loading..."})},Sl=e=>{const{data:t}=gl(),s=os();return L.useEffect(()=>{s.setQueryData(["apiBaseUrl"],e.apiBaseUrl||"/api/chaibuilder")},[e.apiBaseUrl,s]),t?B.jsxRuntimeExports.jsx(wl,{}):B.jsxRuntimeExports.jsx(yl,{})},El=new el,kl=e=>B.jsxRuntimeExports.jsx(rl,{client:El,children:B.jsxRuntimeExports.jsx(Sl,{...e})}),Al=e=>({...e}),Pl=e=>({...e});exports.ChaiBuilderEditor=Wo;exports.ChaiBuilderStudio=kl;exports.ErrorBoundary=Tr;exports.Subscribable=Rt;exports.activePanelAtom=uo;exports.addBlockOffCanvasAtom=lo;exports.addBlocksModalAtom=Qr;exports.advanceStylingOpenAtom=oo;exports.canDeleteBlock=sa;exports.canDropBlock=ra;exports.canDuplicateBlock=ta;exports.canvasIframeAtom=co;exports.editLayerNameAtom=ao;exports.enableStyling=Pl;exports.getBlockJSONFromSchemas=zs;exports.getBlockJSONFromUISchemas=Ks;exports.getDefaultState=si;exports.inlineEditingActiveAtom=ro;exports.networkModeAtom=io;exports.notifyManager=ne;exports.setBlockProps=Al;exports.shallowEqualObjects=xs;exports.shouldThrowError=ii;exports.showPredefinedBlockCategoryAtom=fo;exports.useActiveLanguage=Oo;exports.useActiveModal=Za;exports.useActivePanel=nc;exports.useAddBlock=ha;exports.useAddBlockParent=rc;exports.useAddClassesToBlocks=va;exports.useAllBlocks=Jr;exports.useApiBaseUrl=Ds;exports.useBlockContentByLanguage=yc;exports.useBrandingOptions=gn;exports.useBuilderReset=Po;exports.useBuildingBlocks=un;exports.useCanvasHistory=ns;exports.useCanvasWidth=Ca;exports.useCanvasZoom=_a;exports.useCopyBlockIds=yo;exports.useCurrentPage=_n;exports.useCurrentPage$1=Xr;exports.useCutBlockIds=xn;exports.useDarkMode=Ra;exports.useDeveloperPreviewMode=Da;exports.useDuplicateBlocks=Sn;exports.useExpandedIds=Sc;exports.useFeatureSupport=uc;exports.useGetPageData=bn;exports.useHiddenBlockIds=Ma;exports.useHighlightBlockId=bo;exports.useLanguages=gc;exports.useMarkAsGlobalBlock=Ta;exports.useMoveBlocks=Ua;exports.usePages=ai;exports.usePasteBlocks=xo;exports.usePreviewMode=mn;exports.usePrimaryLanguage=mc;exports.useProject=Ls;exports.useProject$1=$a;exports.useQueryClient=os;exports.useReadOnlyMode=ec;exports.useRemoveBlocks=So;exports.useRemoveClassesFromBlocks=Qa;exports.useSavePage=ja;exports.useSelectedBlock=la;exports.useSelectedBlockAllClasses=Ka;exports.useSelectedBlockCurrentClasses=Ga;exports.useSelectedBlockIds=$e;exports.useSelectedBlocksDisplayChild=ua;exports.useSelectedBreakpoints=ic;exports.useSelectedStylingBlocks=pn;exports.useSetAllBlocks=Kr;exports.useStylingBreakpoint=ho;exports.useStylingState=Wa;exports.useTranslations=cc;exports.useTreeData=ea;exports.useUILibraryBlocks=dc;exports.useUpdateBlocksProps=Ya;exports.useUpdateBlocksPropsRealtime=Ja;
|