@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
package/dist/index-ebd86d7f.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var Tn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};var c=(e,t,n)=>(Tn(e,t,"read from private field"),n?n.call(e):t.get(e)),U=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},j=(e,t,n,s)=>(Tn(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n);var cn=(e,t,n,s)=>({set _(r){j(e,t,r,n)},get _(){return c(e,t,s)}}),H=(e,t,n)=>(Tn(e,t,"access private method"),n);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"),Is=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"),Ds=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 n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}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 n=`atom${++Pi}`,s={toString:()=>n};return typeof e=="function"?s.read=e:(s.init=e,s.read=r=>r(s),s.write=(r,i,o)=>i(s,typeof o=="function"?o(r(s)):o)),t&&(s.write=t),s}const Ls=e=>"init"in e,Ms=e=>!!e.write,vn=new WeakMap,Oi=(e,t)=>{vn.set(e,t),e.catch(()=>{}).finally(()=>vn.delete(e))},Ns=(e,t)=>{const n=vn.get(e);n&&(vn.delete(e),n(t))},Ts=(e,t)=>{e.status="fulfilled",e.value=t},Us=(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),Fs=(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,un=e=>{if("e"in e)throw e.e;return e.v},Bi=()=>{const e=new WeakMap,t=new WeakMap,n=new Map;let s,r,i;const o=m=>e.get(m),a=(m,x)=>{const R=e.get(m);if(e.set(m,x),n.has(m)||n.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);Ns(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);Ts(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);Us(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=>Ts(O,d),d=>Us(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&&Fs(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),un(d);if(Ls(Q))return R.set(Q,void 0),Q.init;throw new Error("no atom init")}const W=w(Q);return R.set(Q,W),un(W)};let O,E;const K={get signal(){return O||(O=new AbortController),O.signal},get setSelf(){return!E&&Ms(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=>un(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=>un(w(E)),I=(E,...K)=>{let Q;if(E===m){if(!Ls(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),Ms(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)&&Ns(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(;n.size;){const x=Array.from(n);n.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)||Fs(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 Un;const _i=()=>(Un||(Un=Bi()),Un),Ri=Symbol();function Ii(e,t){const n=Re(e,(s,r,i)=>r(n,t(s(n),i)));return n}const qs=(e,t,n)=>(t.has(n)?t:t.set(n,e())).get(n),Di=new WeakMap,Li=(e,t,n)=>{const s=qs(()=>new WeakMap,Di,t);return qs(e,s,n)},Mi={},$s=e=>!!e.write,Ni=e=>typeof e=="function";function Ti(e,t){return Li(()=>{const n=new WeakMap,s=(o,a)=>{let f=n.get(o);if(f)return f;const u=a&&n.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=s(k,D==null?void 0:D.arr).keyList.indexOf(C);if(q<0||q>=k.length){const F=o[s(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=s(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]=$s(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},n.set(o,f),f},r=Re(o=>{const a=o(r),f=o(e);return s(f,a==null?void 0:a.arr)});r.init=void 0;const i=$s(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,n;const s={getItem:(r,i)=>{var o,a;const f=h=>{if(h=h||"",t!==h){try{n=JSON.parse(h)}catch{return i}t=h}return n},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"&&(s.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)}}),s}const qi=Fi(()=>typeof window<"u"?window.localStorage:void 0);function st(e,t,n=qi,s){const r=s==null?void 0:s.unstable_getOnInit,i=Re(r?n.getItem(e,t):t);return i.onMount=a=>{r||a(n.getItem(e,t));let f;return n.subscribe&&(f=n.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),n.removeItem(e)):h instanceof Promise?h.then(y=>(f(i,y),n.setItem(e,y))):(f(i,h),n.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 n=Ur(t),[[s,r,i],o]=L.useReducer(u=>{const h=n.get(e);return Object.is(u[0],h)&&u[1]===n&&u[2]===e?u:[h,n,e]},void 0,()=>[n.get(e),n,e]);let a=s;(r!==n||i!==e)&&(o(),a=n.get(e));const f=t==null?void 0:t.delay;return L.useEffect(()=>{const u=n.sub(e,()=>{if(typeof f=="number"){setTimeout(o,f);return}o()});return o(),u},[n,e,f]),L.useDebugValue(a),Vi(a)?Qi(a):a}function zi(e,t){const n=Ur(t);return L.useCallback((...r)=>n.set(e,...r),[n,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(n=>{if(n=t!==null?{...n,parent:t}:n,n.children&&n.children.length){const s=[...n.children];return delete n.children,l.flatten([n,...Fr(s,n._id)])}return n}));function qr(e,t,n){const s=l.filter(e,i=>i._parent===t),r=[];for(let i=0;i<s.length;i++){const o=$r(s[i]);if(Object.keys(o).length>0&&Object.keys(o).forEach(a=>{s[i][a]=`slot:${ie.generateUUID()}`}),l.filter(e,{_parent:s[i]._id}).length>0){const a=ie.generateUUID();r.push({...s[i],oldId:s[i]._id,_id:a,_parent:n}),r.push(l.flatten(qr(e,s[i]._id,a)))}else r.push({...s[i],oldId:s[i]._id,_id:ie.generateUUID(),_parent:n})}return l.flatten(r)}function Wi(e){let t=Gi.convert(e.map(n=>l.omit(n,["settings"])));return t=!t.type&&t.blockNodes?t.blockNodes:l.isEmpty(t)?[]:[t],t}const $r=e=>{const t={};return Object.keys(e).forEach(n=>{l.isString(e[n])&&e[n].startsWith("slot")&&(t[n]=e[n].replace("slot:",""))}),t},Yi=(e,t,n=null)=>{let s=l.find(e,{_id:t});s={...s,oldId:s._id,_id:ie.generateUUID()},n&&(s={...s,_parent:n});const r=[s];l.filter(e,{_parent:t}).length>0&&r.push(l.flatten(qr(e,t,s._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:n}=t;return e.map(s=>(n.ids.includes(s._id)&&!l.isEmpty(t.payload.props)&&Object.keys(t.payload.props).forEach(r=>{l.set(s,r,t.payload.props[r])}),s));default:return e}},{debug:!1,ignoreInitialState:!1,limit:30,filter:Nt.excludeAction(["update_props_realtime","add_duplicate_blocks","set_page_blocks"])}),An=Ii({past:[],present:[],future:[]},Ji);An.debugLabel="pageBlocksAtom";const ge=g.atom(e=>{var t;return(t=e(An))==null?void 0:t.present});ge.debugLabel="presentBlocksAtom";const cs=Ti(ge);cs.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(An);return e},ea=()=>{const e=ye(),t=g.useAtomValue(Vr),n=L.useCallback(s=>{const r=Fr(s);e({type:"set_page_blocks",payload:r})},[e]);return[t,n]},Kr=()=>{const e=ye();return[L.useCallback(n=>{e({type:"set_page_blocks",payload:n})},[e])]},Kn=e=>["Box","Slot","Form","DataContext","Link","List","ListItem","Row","Column","Table","TableCell"].includes(e),ta=e=>!["Slot"].includes(e),na=e=>!["Slot"].includes(e);function sa(e,t){return e==="Slot"||t==="List"&&e!=="ListItem"||t==="Row"&&e!=="Column"?!1:Kn(t)}const ra=(e,{dragSource:t,dropTarget:n})=>{const s=l.get(t,"data._type",""),r=l.get(n,"data._type","");return s==="Slot"||l.get(t,"id")&&l.get(t,"id")===l.get(n,"id")?!1:l.isEmpty(r)?!0:sa(s,r)},zr=g.atom([]);zr.debugLabel="buildingBlocksAtom";const oa=g.atom(e=>{const t=e(zr);return l.filter(t,n=>l.has(n,"blockId"))}),ia=()=>{},us=()=>{const e=Nr.useChaiBlocks(),t=g.useAtomValue(oa),n=()=>{},s=L.useCallback(()=>ia(),[]);return[e,t,n,s]},ls=g.atom([]);ls.debugLabel="selectedBlockIdsAtom";const ds=g.atom(e=>{const t=e(ge),n=e(ls);return l.map(l.filter(t,({_id:s})=>l.includes(n,s)),s=>({...s}))});ds.debugLabel="selectedBlocksAtom";const fs=g.atom(e=>{const t=e(ds);return t.length===0?null:t.length===1?t[0]:{type:"Multiple",id:l.map(t,"id")}});fs.debugLabel="selectedBlockAtom";const aa=e=>l.get(e,"parent",null),ca=g.atom(e=>{const t=e(ds),n=l.map(t,aa);return l.filter(e(ge),s=>l.includes(n,s._id))});ca.debugLabel="selectedBlocksParentsAtom";const Hr=g.atom(()=>!1);Hr.debugLabel="selectedBlockFlexChildAtom";const Gr=g.atom(()=>!1);Gr.debugLabel="selectedBlockGridChildAtom";const hs=g.atom("");hs.debugLabel="styleStateAtom";const Wr=st("styleBreakpoint","xs");Wr.debugLabel="styleBreakpointAtom";const ua=()=>({flexChild:g.useAtomValue(Hr),gridChild:g.useAtomValue(Gr)}),la=()=>g.useAtomValue(fs),$e=()=>{const[e,t]=g.useAtom(ls),n=L.useCallback(s=>{t(r=>l.includes(r,s)?l.without(r,s):[...r,s])},[t]);return[e,t,n]},zn=(e,t="")=>{switch(e.type){case"singular":return e.uiSchema;case"model":const{properties:n}=e,s={};return Object.keys(n).forEach(o=>{const a=n[o];if(l.includes(["slot","styles"],a.type))return;const f=l.get(a,"i18n",!1)?`${o}-${t}`:o;s[f]=zn(a,t)}),s;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]=zn(a,t)}),i;default:return{}}},Hn=(e,t="")=>{switch(e.type){case"singular":return e.schema;case"model":const{properties:n,title:s}=e,r={title:s,type:"object",properties:{}};return Object.keys(n).forEach(f=>{const u=n[f];if(l.includes(["slot","styles"],u.type))return;const h=l.get(u,"i18n",!1)?`${f}-${t}`:f;r.properties[h]=Hn(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]=Hn(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(n=>{t[n]=fa(e[n])}),t},da=e=>{if(l.isEmpty(e.default))return[];const{itemProperties:t}=e;return l.map(e.default,n=>{const s={...n};return l.forIn(n,(r,i)=>{l.has(t,i)&&l.get(t[i],"i18n",!1)&&(s[i]=me.I18N_KEY)}),s})},fa=e=>{switch(e.type){case"styles":return e.default;case"slot":return`${me.SLOT_KEY}${ie.generateUUID()}`;case"singular":const{i18n:t,schema:n}=e;return t?me.I18N_KEY:l.get(n,"default","");case"model":return Yr(e.properties);case"list":return da(e);default:return""}},Jr=()=>g.useAtomValue(ge);function Vs(e,t,n,s,r){if(t===null)return[...e,...s];if(n!==null){const f=l.findIndex(e,{_parent:t}),u=(f===-1?0:f)+n;return e.splice(u,0,...s),e}if(!r){const u=l.findIndex(e,{_id:t})+1;return e.splice(u,0,...s),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,...s),e}const ha=()=>{const e=ye(),t=Jr(),[,n]=us(),[,s]=$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?Kn(v._type):!0;!C&&v&&(w._parent=v._parent);const _=[w,...y];return e({type:"set_blocks",payload:Vs(t,a||null,f||null,_,C)}),s([w._id]),w},[t,e,s]),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?Kn(u._type):!0;return!h&&u&&(o[0]._parent=u._parent),e({type:"set_blocks",payload:Vs(t,a||null,f||null,o,h)}),s([(y=l.first(o))==null?void 0:y._id]),l.first(o)},[t,e,s,n]);return{addCoreBlock:r,addPredefinedBlock:i}},Qs={xs:420,sm:620,md:768,lg:1024,xl:1280,"2xl":1536},Ks=["xs","sm","md","lg","xl","2xl"];function pa(e,t){if(t===null)return"baseClasses";const n=t.mq;if(n==="xs"||t.dark||t.mod!=="")return"classes";let s="baseClasses",r=Ks.indexOf(n);for(;r>0;){const i=Ks[r-1];if(l.find(e,{mq:i,property:t.property})){s="classes";break}r--}return s}const zs=[];function ma(e="",t="",n=[]){e=e.trim().replace(/ +/g,"");let s=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(zs,u.property));const i=[],o=[];l.each(n,u=>{const h=ie.constructClassObject(u),y=l.find(s,l.pick(h,["dark","mq","mod","property"]));if(y&&(s=l.filter(s,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(s,h)==="baseClasses"&&!l.includes(zs,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([...s,...i],u=>Qs[u.mq]),"fullCls").join(" ");return`${l.map(l.sortBy([...r,...o],u=>Qs[u.mq]),"fullCls").join(" ").trim()},${a.trim()}`.trim().replace(/ +/g,"")}const nn=g.atom([]);nn.debugLabel="selectedStylingBlocksAtom";const ps=()=>g.useAtom(nn),ga=e=>{const t=e.replace(me.STYLES_KEY,"").split(",");return{baseClasses:t[0],classes:t[1]}},ya=g.atom(null,(e,t,{blockIds:n,newClasses:s,dispatch:r})=>{const i=l.filter(e(cs),a=>n.includes(e(a)._id)),o=l.first(e(nn));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,s)}`}}})})}),va=()=>{const e=ye(),t=g.useSetAtom(ya);return L.useCallback((n,s,r)=>{t({blockIds:n,newClasses:s,dispatch:e}),r&&setTimeout(()=>e({type:"create_snapshot"}),500)},[e,t])},ba=g.atom(!1),ms=()=>{const[e,t]=g.useAtom(ba);return[e,t]},xa=g.atom(ie.BRANDING_OPTIONS_DEFAULTS),gs=()=>{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 ys=(e,t)=>l.flatten(e.map(n=>{if(n=t?{...n,parent:t}:{...n},n.children){const s=[...n.children];return delete n.children,l.flatten([n,...ys(s,n._id)])}return n}));function vs(e,t=!1){for(let n=0;n<e.length;n++){const s=e[n];s.global&&!t?e[n]={type:"GlobalBlock",_parent:l.get(s,"parent",null),blockId:s.blockId,_id:s._id}:s.children&&s.children.length&&vs(s.children)}}function eo(e){let t=[],n=l.filter(e,{type:"GlobalBlock"});return n.length>0&&(n=l.map(n,to),l.each(n,s=>{t=[...t,...Ea(s)]})),t}function Ea(e){let t=[];const n=l.get(l.first(e),"parent",null);l.set(l.first(e),"parent",null);const s=[Zr.convert(no(e))];vs(s,!0);let r=ys(s,e[0]._id);return r=l.set(r,"0.parent",n),t=[...t,r,...eo(r)],t}function to(e){const t=l.find(Gn,{_id:e._id});if(!t)return[];const n=[t],s=l.filter(Gn,{_parent:e._id});return s.length?l.flatten([...n,...l.flatten(l.map(s,to))]):l.flatten(n)}const no=e=>JSON.parse(JSON.stringify(e));let Gn=[];function ka(e){Gn=e;const t=Sa(no(e));vs(t);const n=ys(t,null),s=eo(n),r={};return l.each(s,i=>l.set(r,l.first(i).blockId,i)),[n,r]}const bs=()=>{const[e]=gs(),{currentPage:t}=Xr(),n=g.useAtomValue(ge);return L.useCallback(()=>{const s=l.map(n,o=>l.omit(o,["expanded","order","title","siblings","tempClasses"])),[r=[],i=[]]=ka(s);return{currentPage:t,blocks:r,globalBlocks:i}},[e,t,n])};st("blockStylingActiveTab",1);g.atom([]);const so=g.atom(!1);so.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";st("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 Pn=g.atom({undoCount:0,redoCount:0});Pn.debugLabel="historyStatesAtom";const On=g.atom("SAVED");On.debugLabel="pageSyncStateAtom";const ja=()=>{const[e,t]=g.useAtom(On),n=be.useBuilderProp("onSaveBlocks",async()=>{}),s=be.useBuilderProp("onSyncStatusChange",()=>{}),r=bs(),i=g.useSetAtom(Pn),{undoCount:o,redoCount:a}=sn();return{savePage:pi.useThrottledCallback(async()=>{t("SAVING"),s("SAVING");const u=r();return await n({blocks:u.blocks,globalBlocks:u.globalBlocks}),setTimeout(()=>{i({undoCount:o,redoCount:a}),t("SAVED"),s("SAVED")},100),!0},[r,t,s,n],5e3),syncState:e,setSyncState:t}},sn=()=>{const e=g.useAtomValue(An),[{undoCount:t,redoCount:n}]=g.useAtom(Pn),s=ye(),[r]=ms(),[,i]=$e(),[,o]=ps(),[,a]=g.useAtom(On),f=be.useBuilderProp("onSyncStatusChange",()=>{}),u=L.useCallback(()=>{s({type:"create_snapshot"})},[s]);return L.useEffect(()=>{t!==(e==null?void 0:e.past.length)||n!==(e==null?void 0:e.future.length)?(a("UNSAVED"),f("UNSAVED")):t===(e==null?void 0:e.past.length)&&n===(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,n,f,a]),{undoCount:e==null?void 0:e.past.length,redoCount:e==null?void 0:e.future.length,undo:L.useCallback(()=>{r||(s(Nt.ActionCreators.undo()),setTimeout(()=>{o([]),i([])},200))},[s,r,a]),redo:L.useCallback(()=>{r||(s(Nt.ActionCreators.redo()),setTimeout(()=>{o([]),i([])},200))},[r,s]),clear:()=>{s(Nt.ActionCreators.clearHistory())},createSnapshot:u}},ho=()=>g.useAtom(Wr),po=st("canvasWidth",360),mo=g.atom(e=>{const t=e(po);return ie.getBreakpointValue(t).toLowerCase()}),Ca=()=>{const[e,t]=g.useAtom(po),n=g.useAtomValue(mo),[s,r]=ho();return L.useEffect(()=>{s!=="xs"&&r(n)},[n,s,r]),[e,n,t]},Ba=st("canvasZoom",100),_a=()=>g.useAtom(Ba),go=g.atom([]),xs=()=>{const[e,t]=g.useAtom(go),n=g.useSetAtom(ws),s=L.useCallback(r=>{t(r),n([])},[t,n]);return[e,s]},ws=g.atom([]),yo=()=>{const[e,t]=g.useAtom(ws),n=g.useSetAtom(go),s=L.useCallback(r=>{t(r),n([])},[t,n]);return[e,s]},vo=st("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]},Ss=()=>{const e=ye(),t=g.useAtomValue(ge),[,n]=$e();return L.useCallback((s,r=null)=>{const i=[];l.each(s,o=>{const f=Yi(t,o,r===o?null:r);i.push(l.get(f,"0._id","")),e({type:"add_duplicate_blocks",payload:f})}),n(i),e({type:"create_snapshot"})},[t,n,e])},La=g.atom([]),Ma=()=>{const[e,t]=g.useAtom(La),n=L.useCallback(s=>{t(r=>l.includes(r,s)?l.without(r,s):[...r,s])},[t]);return[e,t,n]},Na=g.atom(""),bo=()=>g.useAtom(Na),Ta=()=>{const e=g.useAtomValue(ge),t=ye(),n=bs(),[,,s]=us();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}),s()},[e,t,n,s])},Ua=()=>({}),Fa=()=>{const e=g.useAtomValue(ge),t=ye();return L.useCallback((n,s)=>{const r=l.map(e,i=>(l.includes(n,l.get(i,"_id"))&&l.set(i,"_parent",s),i));t({type:"set_blocks",payload:r})},[e,t])},xo=()=>{const e=g.useAtomValue(ws),[t,n]=xs(),s=Ss(),r=Fa();return{canPaste:L.useMemo(()=>t.length>0||e.length>0,[e,t]),pasteBlocks:L.useCallback(o=>{l.isEmpty(e)?r(t,o):s(e,o),n(()=>[])},[t,e,s,r,n])}},qa=g.atom(""),$a=()=>{const e=g.useAtomValue(qa),t=L.useCallback(()=>{},[]),n=L.useCallback(()=>{},[]),s=L.useCallback(()=>{},[]);return{currentProject:e,createProject:s,deleteProject:t,updateProject:n}},wo=(e,t)=>{const n=[],s=l.filter(e,r=>l.includes(t,r._id)||l.includes(t,r._parent)?(n.push(r._id),!1):!0);return l.isEmpty(n)?s:wo(s,n)},So=()=>{const e=ye(),t=g.useAtomValue(ge),[n,s]=$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}),s(i?[i]:[])},[t,s,e,n])},Va=g.atom(null,(e,t,{blockIds:n,fullClasses:s,dispatch:r})=>{const i=l.first(e(nn)),o=l.filter(e(cs),a=>n.includes(e(a)._id));l.each(o,a=>{const f=e(a),u=s;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((n,s)=>{t({blockIds:n,fullClasses:s,dispatch:e}),setTimeout(()=>e({type:"create_snapshot"}))},[e,t])},Eo=g.atom(e=>{const t=l.first(e(nn)),n=e(fs);if(!t||t.blockId!==l.get(n,"_id",null))return[];const r=l.get(n,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),Hs={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},za=g.atom(e=>{const t=e(mo),n=e(hs),s=e(vo),r=Ha(t);let i=l.filter(e(Eo),{mod:n});return l.startsWith(n,"_")||(i=l.filter(i,o=>r.includes(o.mq))),i=i.sort((o,a)=>Hs[o.mq]-Hs[a.mq]),s||(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(hs),ko=g.atom(null,(e,t,{blockIds:n,props:s,dispatch:r})=>{r({type:"update_props_realtime",payload:{ids:n,props:s}})}),Ya=()=>{const{createSnapshot:e}=sn(),t=ye(),n=g.useSetAtom(ko);return L.useCallback((s,r)=>{n({blockIds:s,props:r,dispatch:t}),e()},[e,t,n])},Ja=()=>{const e=ye(),t=g.useSetAtom(ko);return L.useCallback((n,s)=>{t({blockIds:n,props:s,dispatch:e})},[e,t])},Ao={name:"",props:{},modalProps:{},backdropClose:!0},Xa=g.atom(Ao),Za=()=>{const[e,t]=g.useAtom(Xa),n=L.useCallback((r,i={},o={})=>{t({name:r,props:i,modalProps:o})},[t]),s=L.useCallback((...r)=>{l.get(e,"props.onClose",()=>{})(...r),t(Ao)},[t,e]);return{activeModal:e,openModal:n,closeModal:s}},ec=()=>g.useAtomValue(so),tc=g.atom(""),nc=g.atom(null),sc=()=>g.useAtom(tc),rc=()=>g.useAtom(nc),oc=st("selectedBreakpoints",["XS","MD","XL"]),ic=()=>{const[e,t]=g.useAtom(oc);return[e,t]},Po=()=>{const e=g.useSetAtom(Pn),{clear:t}=sn(),[,n]=$e(),[,s]=bo(),[,r]=ps();return()=>{n([]),r([]),s(""),t(),e({undoCount:0,redoCount:0})}},ac=g.atom({en:{}}),cc=()=>{const[e,t]=g.useAtom(ac),n=L.useCallback((s,r,i)=>{l.set(e,`${s}.${r}`,i),t(e)},[e,t]);return[e,n]},uc=(e,t)=>{const[n]=g.useAtom(be.chaiBuilderPropsAtom);return l.get(n,e,t)},lc=g.atom([]),dc=()=>{const[e,t]=L.useState(!1),[n,s]=g.useAtom(lc),r=be.useBuilderProp("getUILibraryBlocks",()=>[]);return L.useEffect(()=>{(async()=>n.length>0||(t(!0),s(await r()),t(!1)))()},[]),{data:n,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[n]=Oo(),s=`${e}${n?`-${n}`:""}`;return{content:l.get(t,s,l.get(t,e,"")),propKey:e}},vc=()=>{const[e,t]=ms(),n=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:n?B.jsxRuntimeExports.jsx(L.Suspense,{fallback:B.jsxRuntimeExports.jsx(be.Skeleton,{className:"h-96 w-full"}),children:L.createElement(n)}):null})]})},bc=()=>{const[e,t]=$e(),[,n]=yo(),s=So(),r=Ss(),[,i]=xs(),{pasteBlocks:o}=xo(),{undo:a,redo:f}=sn();Ce.useHotkeys("esc",()=>t([]),{},[t]),Ce.useHotkeys("ctrl+c,command+c",()=>n(e),{},[e,n]),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(),s(e)},{},[e,s])},xc=(e,t)=>{const n=[];let s=l.find(e,{_id:t}),r=l.get(s,"_parent","");for(;l.isString(r)&&!l.isEmpty(r);)n.push(s==null?void 0:s._parent),s=l.find(e,{_id:r}),r=s==null?void 0:s._parent;return l.flatten(n)},jo=g.atom([]),wc=()=>{const[e]=$e(),t=g.useAtomValue(ge),[,n]=g.useAtom(jo);L.useEffect(()=>{let s=[];const r=l.first(e);l.isString(r)&&(s=[r,...xc(t,r)]),n(s)},[e,t,n])},Sc=()=>g.useAtomValue(jo),Ec=L.lazy(()=>Promise.resolve().then(()=>require("./SidePanels-934159a4.cjs"))),kc=L.lazy(()=>Promise.resolve().then(()=>require("./Topbar-c083cc2a.cjs"))),Ac=L.lazy(()=>Promise.resolve().then(()=>require("./CanvasArea-e855c4a2.cjs"))),Pc=L.lazy(()=>Promise.resolve().then(()=>require("./Settings-bee21026.cjs"))),Oc=()=>{const[e]=Hi(On),t=n=>{n.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 Gs(e,t,n,s,r){for(t=t.split?t.split("."):t,s=0;s<t.length;s++)e=e?e[t[s]]:r;return e===r?n:e}var ln="undefined",Ws="object",Co="any",Bo="*",et="__",bn=typeof process<"u"?process:{};bn.env&&bn.env.NODE_ENV;var xe=typeof document<"u";bn.versions!=null&&bn.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 xn(e,t){t===void 0&&(t=!0);var n=_c(e);return t?Bc(n):n}function rn(e,t){return typeof t===e}var Pe=rn.bind(null,"function"),at=rn.bind(null,"string"),ot=rn.bind(null,"undefined"),Rc=rn.bind(null,"boolean");rn.bind(null,"symbol");function Ro(e){return e===null}function Ic(e){return xn(e)==="number"&&!isNaN(e)}function Dc(e){return xn(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 n=xn(new e(""));if(Nc(t))for(;t;){if(xn(t)===n)return!0;t=Object.getPrototypeOf(t)}return!1}Io.bind(null,TypeError);Io.bind(null,SyntaxError);function jn(e,t){var n=e instanceof Element||e instanceof HTMLDocument;return n&&t?Tc(e,t):n}function Tc(e,t){return t===void 0&&(t=""),e&&e.nodeName===t.toUpperCase()}function Cn(e){var t=[].slice.call(arguments,1);return function(){return e.apply(void 0,[].slice.call(arguments).concat(t))}}Cn(jn,"form");Cn(jn,"button");Cn(jn,"input");Cn(jn,"select");function Ys(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 n,s=Object.create(null),r=/([^&=]+)=?([^&]*)/g;n=r.exec(t);){var i=Ys(n[1]),o=Ys(n[2]);i.substring(i.length-2)==="[]"?(s[i=i.substring(0,i.length-2)]||(s[i]=[])).push(o):s[i]=o===""||o}for(var a in s){var f=a.split("[");f.length>1&&($c(s,f.map(function(u){return u.replace(/[?[\]\\ ]/g,"")}),s[a]),delete s[a])}return s}(function(t){if(t){var n=t.match(/\?(.*)/);return n&&n[1]?n[1].split("#")[0]:""}return xe&&window.location.search.substring(1)}(e))}function $c(e,t,n){for(var s=t.length-1,r=0;r<s;++r){var i=t[r];if(i==="__proto__"||i==="constructor")break;i in e||(e[i]={}),e=e[i]}e[t[s]]=n}function Bn(){for(var e="",t=0,n=4294967295*Math.random()|0;t++<36;){var s="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],r=15&n;e+=s=="-"||s=="4"?s:(s=="x"?r:3&r|8).toString(16),n=t%8==0?4294967295*Math.random()|0:n>>4}return e}var Tt="global",Pt=et+"global"+et,Ot=typeof self===Ws&&self.self===self&&self||typeof global===Ws&&global.global===global&&global||void 0;function tt(e){return Ot[Pt][e]}function nt(e,t){return Ot[Pt][e]=t}function Bt(e){delete Ot[Pt][e]}function _t(e,t,n){var s;try{if(Es(e)){var r=window[e];s=r[t].bind(r)}}catch{}return s||n}Ot[Pt]||(Ot[Pt]={});var dn={};function Es(e){if(typeof dn[e]!==ln)return dn[e];try{var t=window[e];t.setItem(ln,ln),t.removeItem(ln)}catch{return dn[e]=!1}return dn[e]=!0}function V(){return V=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},V.apply(this,arguments)}var Ie="function",je="undefined",Vc="@@redux/"+Math.random().toString(36),Js=function(){return typeof Symbol===Ie&&Symbol.observable||"@@observable"}(),fn=" != "+Ie;function Do(e,t,n){var s;if(typeof t===Ie&&typeof n===je&&(n=t,t=void 0),typeof n!==je){if(typeof n!==Ie)throw new Error("enhancer"+fn);return n(Do)(e,t)}if(typeof e!==Ie)throw new Error("reducer"+fn);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"+fn);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"}),(s={dispatch:w,subscribe:y,getState:h,replaceReducer:function(v){if(typeof v!==Ie)throw new Error("next reducer"+fn);r=v,w({type:"@@redux/INIT"})}})[Js]=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)}}})[Js]=function(){return this},v},s}function Qc(e,t){var n=t&&t.type;return"action "+(n&&n.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,n){return function(){return t(n.apply(void 0,[].slice.call(arguments)))}})}function Kc(){var e=arguments;return function(t){return function(n,s,r){var i,o=t(n,s,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",gn=["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"],Wn=["name","EVENTS","config","loaded"],$=gn.reduce(function(e,t){return e[t]=t,e},{registerPluginType:function(e){return"registerPlugin:"+e},pluginReadyType:function(e){return"ready:"+e}}),Xs=/^utm_/,Zs=/^an_prop_/,er=/^an_trait_/;function zc(e){var t=e.storage.setItem;return function(n){return function(s){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(Xs)||_.match(/^(d|g)clid/)){var b=_.replace(Xs,"");C.campaign[b==="campaign"?"name":b]=i[_]}return _.match(Zs)&&(C.props[_.replace(Zs,"")]=i[_]),_.match(er)&&(C.traits[_.replace(er,"")]=i[_]),C},{campaign:{},props:{},traits:{}});n.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&&n.dispatch({type:$.campaign,campaign:v.campaign})}}return s(r)}}}}function Hc(e){return function(t,n){if(t===void 0&&(t={}),n===void 0&&(n={}),n.type===$.setItemEnd){if(n.key===qe)return V({},t,{anonymousId:n.value});if(n.key===Ze)return V({},t,{userId:n.value})}switch(n.type){case $.identify:return Object.assign({},t,{userId:n.userId,traits:V({},t.traits,n.traits)});case $.reset:return[Ze,qe,ct].forEach(function(s){e.removeItem(s)}),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 Yn=function(e){return et+"TEMP"+et+e};function Gc(e){var t=e.storage,n=t.setItem,s=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){s(v)}),[_e,it,"traits"].forEach(function(v){Bt(Yn(v))})),a.type===$.identify){r(qe)||n(qe,Bn());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&&n(Ze,f),u&&n(ct,V({},w,u))}return o(a)}}}}var Lt={};function nr(e,t){Lt[e]&&Pe(Lt[e])&&(Lt[e](t),delete Lt[e])}function Lo(e,t,n){return new Promise(function(s,r){return t()?s(e):n<1?r(V({},e,{queue:!0})):new Promise(function(i){return setTimeout(i,10)}).then(function(i){return Lo(e,t,n-10).then(s,r)})})}function Mo(e,t,n){var s=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=s[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:n});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 Fn=function(e){var t=e.data,n=e.action,s=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=n.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}}}(s,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:s,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(n))).then(function(F){k[D]=F});k[D]=n}();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),$n(M,A))return qn({data:M,method:y,instance:s,pluginName:A,store:a}),Promise.resolve(F);if($n(F,A))return k&&qn({data:F,method:y,instance:s,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:s,config:or(A,u,i),plugins:u})).then(function(x){var R=ue(x)?x:{},S=V({},F,R),I=b[A];if($n(I,A))qn({data:I,method:y,instance:s,pluginName:A,store:a});else{var O=y+":"+A;(O.match(/:/g)||[]).length<2&&!y.match(sr)&&!y.match(rr)&&s.dispatch(V({},w?S:M,{type:O,_:{called:O,from:"submethod"}}))}return Promise.resolve(S)})})}catch(F){return Promise.reject(F)}},Promise.resolve(n))).then(function(P){if(!(y.match(ut)||y.match(/^registerPlugin/)||y.match(rr)||y.match(sr)||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$/,sr=/^bootstrap/,rr=/^ready/;function qn(e){var t=e.pluginName,n=e.method+"Aborted"+(t?":"+t:"");e.store.dispatch(V({},e.data,{type:n,_:{called:n,from:"abort"}}))}function or(e,t,n){var s=t[e]||n[e];return s&&s.config?s.config:{}}function ir(e,t){return t.reduce(function(n,s){return s[e]?n.concat({methodName:e,pluginName:s.name,method:s[e]}):n},[])}function ar(e,t){var n=e.replace(ut,""),s=t?":"+t:"";return[""+e+s,""+n+s,n+"End"+s]}function $n(e,t){var n=e.abort;return!!n&&(n===!0||cr(n,t)||n&&cr(n.plugins,t))}function No(e,t){var n=e.abort;if(!n)return!1;if(n===!0||at(n))return!0;var s=n.plugins;return $t(n)&&n.length===t||$t(s)&&s.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,n){return n==="type"||(t[n]=ue(e[n])?Object.assign({},e[n]):e[n]),t},{})}function Yc(e,t,n){var s={};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 nr(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 s[q]||(r.dispatch({type:$.pluginReadyType(q),name:q,events:Object.keys(k).filter(function(m){return!Wn.includes(m)})}),s[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(Fn({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(Fn({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&&nr(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(Fn({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,n)).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(n){return function(s){var r=s.type,i=s.key,o=s.value,a=s.options;if(r===$.setItem||r===$.removeItem){if(s.abort)return n(s);r===$.setItem?e.setItem(i,o,a):e.removeItem(i,a)}return n(s)}}}}var Xc=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(t,n){e[n]=e[n].concat(t)},this.removeMiddleware=function(t,n){var s=e[n].findIndex(function(r){return r===t});s!==-1&&(e[n]=[].concat(e[n].slice(0,s),e[n].slice(s+1)))},this.dynamicMiddlewares=function(t){return function(n){return function(s){return function(r){var i={getState:n.getState,dispatch:function(a){return n.dispatch(a)}},o=e[t].map(function(a){return a(i)});return jt.apply(void 0,o)(s)(r)}}}}};function Zc(e){return function(t,n){t===void 0&&(t={});var s={};if(n.type==="initialize:aborted")return t;if(/^registerPlugin:([^:]*)$/.test(n.type)){var r=lr(n.type,"registerPlugin"),i=e()[r];if(!i||!r)return t;var o=n.enabled,a=i.config;return s[r]={enabled:o,initialized:!!o&&!i.initialize,loaded:!!o&&!!i.loaded({config:a}),config:a},V({},t,s)}if(/^initialize:([^:]*)$/.test(n.type)){var f=lr(n.type,$.initialize),u=e()[f];return u&&f?(s[f]=V({},t[f],{initialized:!0,loaded:!!u.loaded({config:u.config})}),V({},t,s)):t}if(/^ready:([^:]*)$/.test(n.type))return s[n.name]=V({},t[n.name],{loaded:!0}),V({},t,s);switch(n.type){case $.disablePlugin:return V({},t,dr(n.plugins,!1,t));case $.enablePlugin:return V({},t,dr(n.plugins,!0,t));default:return t}}}function lr(e,t){return e.substring(t.length+1,e.length)}function dr(e,t,n){return e.reduce(function(s,r){return s[r]=V({},n[r],{enabled:t}),s},n)}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 n=t.options,s=t.meta;if(t.type===$.track){var r=To(V({event:t.event,properties:t.properties},Object.keys(n).length&&{options:n},{meta:s}));return V({},e,{last:r,history:e.history.concat(r)})}return e}var nu={actions:[]};function su(e,t){e===void 0&&(e=nu);var n=t.payload;switch(t.type){case"queue":var s;return s=n&&n.type&&n.type===$.identify?[t].concat(e.actions):e.actions.concat(t),V({},e,{actions:s});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,n=t.title,s=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:n,url:h,path:ru(h),hash:f,search:u,width:o,height:a};return s&&s!==""&&(y.referrer=s),V({},y,e)},iu={last:{},history:[]};function au(e,t){e===void 0&&(e=iu);var n=t.options;if(t.type===$.page){var s=To(V({properties:t.properties,meta:t.meta},Object.keys(n).length&&{options:n}));return V({},e,{last:s,history:e.history.concat(s)})}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:Bn(),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 n=e.initialized,s=t.campaign;switch(t.type){case $.campaign:return V({},e,{campaign:s});case $.offline:return V({},e,{offline:!0});case $.online:return V({},e,{offline:!1});default:return n?e:V({},fr,e,{initialized:!0})}}var uu=["plugins","reducers","storage"];function lu(e,t,n){if(xe){var s=window[(n?"add":"remove")+"EventListener"];e.split(" ").forEach(function(r){s(r,t)})}}function du(e){var t=lu.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(e)});return t(!0),function(n){return t(!1)}}function Qo(){return nt("analytics",[]),function(e){return function(t,n,s){var r=e(t,n,s),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 Vn(e){return e?Dc(e)?e:[e]:[]}function pr(e,t,n){e===void 0&&(e={});var s,r,i=Bn();return t&&(Lt[i]=(s=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}(n),function(o){r&&r(o),s(o)})),V({},e,{rid:i,ts:new Date().getTime()},t?{hasCallback:!0}:{})}function fu(e){e===void 0&&(e={});var t=e.reducers||{},n=e.initialUser||{},s=(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:nt,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(Yn(p))||null)}}(r),o=s.plugins,a=s.events.filter(function(d){return!Wn.includes(d)}).sort(),f=new Set(a.concat(gn).filter(function(d){return!Wn.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,n,b.an_uid?{userId:b.an_uid}:{},b.an_aid?{anonymousId:b.an_aid}:{});N.anonymousId||(N.anonymousId=Bn());var D=V({enable:function(d,p){return new Promise(function(T){E.dispatch({type:$.enablePlugin,plugins:Vn(d),_:{originalAction:$.enablePlugin}},T,[p])})},disable:function(d,p){return new Promise(function(T){E.dispatch({type:$.disablePlugin,plugins:Vn(d),_:{originalAction:$.disablePlugin}},T,[p])})}},s.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();nt(Yn(_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?Gs(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,hn),w(G,pn),function(){v(z,hn),v(G,pn)}}var Y=d.match(T)?hn:pn,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?Gs(p,d):Object.assign({},p)},dispatch:function(d){var p=at(d)?{type:d}:d;if(gn.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:gn,plugins:a}},q=s.middlewares.concat([function(d){return function(p){return function(T){return T.meta||(T.meta=pr()),p(T)}}},C(hn),Yc(A,h,{all:u,plugins:a}),Jc(r),zc(A),Gc(A),C(pn)]),F={context:cu,user:Hc(r),page:au,track:tu,plugins:Zc(h),queue:su},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=s.pluginsArray.reduce(function(d,p){var T=p.name,z=p.config,G=p.loaded,Y=s.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 an=re[It],Rs=X[an],Nn=(0,T[an])(Rs,ee);if(typeof Nn===je){var ci=Qc(an,ee);throw new Error(ci)}we[an]=Nn,J=J||Nn!==Rs}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,Vn(T))});return R.apply(null,[z])});var K=Object.keys(o);E.dispatch({type:$.bootstrap,plugins:K,config:S,params:b,user:N,initialUser:n,persistedUser:P});var Q=K.filter(function(d){return s.pluginEnabled[d]}),W=K.filter(function(d){return!s.pluginEnabled[d]});return E.dispatch({type:$.registerPlugins,plugins:K,enabled:s.pluginEnabled}),s.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:s.pluginEnabled[G],plugin:d}),s.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 hn="before",pn="after",Ut="cookie",Ve=Ho(),Ko=_n,hu=_n;function zo(e){return Ve?_n(e,"",-1):Bt(e)}function Ho(){if(Ve!==void 0)return Ve;var e="cookiecookie";try{_n(e,e),Ve=document.cookie.indexOf(e)!==-1,zo(e)}catch{Ve=!1}return Ve}function _n(e,t,n,s,r,i){if(typeof window<"u"){var o=arguments.length>1;return Ve===!1&&(o?nt(e,t):tt(e)),o?document.cookie=e+"="+encodeURIComponent(t)+(n?"; expires="+new Date(+new Date+1e3*n).toUTCString()+(s?"; path="+s:"")+(r?"; domain="+r:"")+(i?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}}var Ft="localStorage",pu=Es.bind(null,"localStorage");_t("localStorage","getItem",tt);_t("localStorage","setItem",nt);_t("localStorage","removeItem",Bt);var qt="sessionStorage",mu=Es.bind(null,"sessionStorage");_t("sessionStorage","getItem",tt);_t("sessionStorage","setItem",nt);_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 n=ks(t),s=!js(n),r=As(n)?lt(localStorage.getItem(e)):void 0;if(s&&!ot(r))return r;var i=Ps(n)?lt(Ko(e)):void 0;if(s&&i)return i;var o=Os(n)?lt(sessionStorage.getItem(e)):void 0;if(s&&o)return o;var a=tt(e);return s?a:{localStorage:r,sessionStorage:o,cookie:i,global:a}}}function bu(e,t,n){if(e&&!ot(t)){var s={},r=ks(n),i=JSON.stringify(t),o=!js(r);return As(r)&&(s[Ft]=mn(Ft,t,lt(localStorage.getItem(e))),localStorage.setItem(e,i),o)?s[Ft]:Ps(r)&&(s[Ut]=mn(Ut,t,lt(Ko(e))),hu(e,i),o)?s[Ut]:Os(r)&&(s[qt]=mn(qt,t,lt(sessionStorage.getItem(e))),sessionStorage.setItem(e,i),o)?s[qt]:(s[Tt]=mn(Tt,t,tt(e)),nt(e,t),o?s[Tt]:s)}}function xu(e,t){if(e){var n=ks(t),s=Go(e,Bo),r={};return!ot(s.localStorage)&&As(n)&&(localStorage.removeItem(e),r[Ft]=s.localStorage),!ot(s.cookie)&&Ps(n)&&(zo(e),r[Ut]=s.cookie),!ot(s.sessionStorage)&&Os(n)&&(sessionStorage.removeItem(e),r[qt]=s.sessionStorage),!ot(s.global)&&Rn(n,Tt)&&(Bt(e),r[Tt]=s.global),r}}function ks(e){return e?at(e)?e:e.storage:Co}function As(e){return gu&&Rn(e,Ft)}function Ps(e){return vu&&Rn(e,Ut)}function Os(e){return yu&&Rn(e,qt)}function js(e){return e===Bo||e==="all"}function Rn(e,t){return e===Co||e===t||js(e)}function mn(e,t,n){return{location:e,current:t,previous:n}}var wu={setItem:bu,getItem:Go,removeItem:xu};function Su(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function mr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,s)}return n}function gr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?mr(Object(n),!0).forEach(function(s){Su(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mr(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}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.3",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"},"./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(n=>n.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:Is.MultiBackend}}=e,[n]=Kr(),[,s]=gs(),r=Po();return L.useEffect(()=>{jc.set(be.chaiBuilderPropsAtom,l.omit(e,["blocks","globalBlocks","brandingOptions"]))},[e]),L.useEffect(()=>{n(Nr.syncBlocksWithDefaults(e.blocks||[])),r()},[e.blocks]),L.useEffect(()=>{s(e.brandingOptions)},[e.brandingOptions]),L.useEffect(()=>{Nu.page()},[]),B.jsxRuntimeExports.jsx(fi.DndProvider,{...t,options:Is.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 Jn(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:n="all",exact:s,fetchStatus:r,predicate:i,queryKey:o,stale:a}=e;if(o){if(s){if(t.queryHash!==Cs(o,t.options))return!1}else if(!Qt(t.queryKey,o))return!1}if(n!=="all"){const f=t.isActive();if(n==="active"&&!f||n==="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:n,status:s,predicate:r,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Vt(t.options.mutationKey)!==Vt(i))return!1}else if(!Qt(t.options.mutationKey,i))return!1}return!(s&&t.state.status!==s||r&&!r(t))}function Cs(e,t){return((t==null?void 0:t.queryKeyHashFn)||Vt)(e)}function Vt(e){return JSON.stringify(e,(t,n)=>Xn(n)?Object.keys(n).sort().reduce((s,r)=>(s[r]=n[r],s),{}):n)}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(n=>!Qt(e[n],t[n])):!1}function Jo(e,t){if(e===t)return e;const n=wr(e)&&wr(t);if(n||Xn(e)&&Xn(t)){const s=n?e.length:Object.keys(e).length,r=n?t:Object.keys(t),i=r.length,o=n?[]:{};let a=0;for(let f=0;f<i;f++){const u=n?f:r[f];o[u]=Jo(e[u],t[u]),o[u]===e[u]&&a++}return s===i&&a===s?e:o}return t}function wn(e,t){if(e&&!t||t&&!e)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function wr(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Xn(e){if(!Sr(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const n=t.prototype;return!(!Sr(n)||!n.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 Zn(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Jo(e,t):t}function qu(e,t,n=0){const s=[...e,t];return n&&s.length>n?s.slice(1):s}function $u(e,t,n=0){const s=[t,...e];return n&&s.length>n?s.slice(0,-1):s}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 n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}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 n;j(this,dt,t),(n=c(this,De))==null||n.call(this),j(this,De,t(s=>{typeof s=="boolean"?this.setFocused(s):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),Sn=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 n=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",s)}}})}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 n;j(this,ht,t),(n=c(this,Le))==null||n.call(this),j(this,Le,t(this.setOnline.bind(this)))}setOnline(t){c(this,ft)!==t&&(j(this,ft,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return c(this,ft)}},ft=new WeakMap,Le=new WeakMap,ht=new WeakMap,jr),En=new Qu;function Ku(e){return Math.min(1e3*2**e,3e4)}function In(e){return(e??"online")==="online"?En.isOnline():!0}var Zo=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Qn(e){return e instanceof Zo}function ei(e){let t=!1,n=0,s=!1,r,i,o;const a=new Promise((b,P)=>{i=b,o=P}),f=b=>{var P;s||(v(new Zo(b)),(P=e.abort)==null||P.call(e))},u=()=>{t=!0},h=()=>{t=!1},y=()=>!Sn.isFocused()||e.networkMode!=="always"&&!En.isOnline(),w=b=>{var P;s||(s=!0,(P=e.onSuccess)==null||P.call(e,b),r==null||r(),i(b))},v=b=>{var P;s||(s=!0,(P=e.onError)==null||P.call(e,b),r==null||r(),o(b))},C=()=>new Promise(b=>{var P;r=N=>{const D=s||!y();return D&&b(N),D},(P=e.onPause)==null||P.call(e)}).then(()=>{var b;r=void 0,s||(b=e.onContinue)==null||b.call(e)}),_=()=>{if(s)return;let b;try{b=e.fn()}catch(P){b=Promise.reject(P)}Promise.resolve(b).then(w).catch(P=>{var q;if(s)return;const N=e.retry??(Ct?0:3),D=e.retryDelay??Ku,k=typeof D=="function"?D(n,P):D,A=N===!0||typeof N=="number"&&n<N||typeof N=="function"&&N(n,P);if(t||!A){v(P);return}n++,(q=e.onFail)==null||q.call(e,n,P),Xo(k).then(()=>{if(y())return C()}).then(()=>{t?v(P):_()})})};return In(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,n=h=>{h()},s=h=>{h()};const r=h=>{let y;t++;try{y=h()}finally{t--,t||a()}return y},i=h=>{t?e.push(h):Er(()=>{n(h)})},o=h=>(...y)=>{i(()=>{h(...y)})},a=()=>{const h=e;e=[],h.length&&Er(()=>{s(()=>{h.forEach(y=>{n(y)})})})};return{batch:r,batchCalls:o,schedule:i,setNotifyFunction:h=>{n=h},setBatchNotifyFunction:h=>{s=h}}}var se=zu(),Ke,Cr,ti=(Cr=class{constructor(){U(this,Ke,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Jn(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,ne,Kt,ze,gt,yn,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,ne,void 0);U(this,Kt,void 0);U(this,ze,void 0);j(this,ze,!1),j(this,Kt,t.defaultOptions),H(this,gt,yn).call(this,t.options),j(this,ne,[]),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,ne).length&&this.state.fetchStatus==="idle"&&c(this,de).remove(this)}setData(t,n){const s=Zn(this.state.data,t,this.options);return H(this,ve,Oe).call(this,{data:s,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),s}setState(t,n){H(this,ve,Oe).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var s;const n=c(this,Me);return(s=c(this,fe))==null||s.cancel(t),n?n.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,ne).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||c(this,ne).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!Yo(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=c(this,ne).find(s=>s.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=c(this,fe))==null||n.continue()}onOnline(){var n;const t=c(this,ne).find(s=>s.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=c(this,fe))==null||n.continue()}addObserver(t){c(this,ne).includes(t)||(c(this,ne).push(t),this.clearGcTimeout(),c(this,de).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){c(this,ne).includes(t)&&(j(this,ne,c(this,ne).filter(n=>n!==t)),c(this,ne).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,ne).length}invalidate(){this.state.isInvalidated||H(this,ve,Oe).call(this,{type:"invalidate"})}fetch(t,n){var u,h,y,w;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(n!=null&&n.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,yn).call(this,t),!this.options.queryFn){const v=c(this,ne).find(C=>C.options.queryFn);v&&H(this,gt,yn).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 s=new AbortController,r={queryKey:this.queryKey,meta:this.meta},i=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>(j(this,ze,!0),s.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:n,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;Qn(v)&&v.silent||H(this,ve,Oe).call(this,{type:"error",error:v}),Qn(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:s.abort.bind(s),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,ne=new WeakMap,Kt=new WeakMap,ze=new WeakMap,gt=new WeakSet,yn=function(t){this.options={...c(this,Kt),...t},this.updateGcTime(this.options.gcTime)},ve=new WeakSet,Oe=function(t){const n=s=>{switch(t.type){case"failed":return{...s,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:In(this.options.networkMode)?"fetching":"paused",...!s.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...s,data:t.data,dataUpdateCount:s.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 Qn(r)&&r.revert&&c(this,mt)?{...c(this,mt),fetchStatus:"idle"}:{...s,error:r,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=n(this.state),se.batch(()=>{c(this,ne).forEach(s=>{s.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,n=typeof t<"u",s=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"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,n,s){const r=n.queryKey,i=n.queryHash??Cs(r,n);let o=this.get(i);return o||(o=new Hu({cache:this,queryKey:r,queryHash:i,options:t.defaultQueryOptions(n),state:s,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 n=c(this,Se).get(t.queryHash);n&&(t.destroy(),n===t&&c(this,Se).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){se.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 n={exact:!0,...t};return this.getAll().find(s=>br(n,s))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(s=>br(t,s)):n}notify(t){se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){se.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){se.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||ni(),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(n=>n!==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 n=()=>(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),s=this.state.status==="pending";try{if(!s){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 n();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 n=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!In(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),se.batch(()=>{c(this,Ee).forEach(s=>{s.onMutationUpdate(t)}),c(this,ce).notify({mutation:this,type:"updated",action:t})})},Rr);function ni(){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,n,s){const r=new Yu({mutationCache:this,mutationId:++cn(this,Ht)._,options:t.defaultMutationOptions(n),state:s});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(n=>n!==t)),this.notify({type:"removed",mutation:t})}clear(){se.batch(()=>{c(this,he).forEach(t=>{this.remove(t)})})}getAll(){return c(this,he)}find(t){const n={exact:!0,...t};return c(this,he).find(s=>xr(n,s))}findAll(t={}){return c(this,he).filter(n=>xr(t,n))}notify(t){se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){return j(this,He,(c(this,He)??Promise.resolve()).then(()=>{const t=c(this,he).filter(n=>n.state.isPaused);return se.batch(()=>t.reduce((n,s)=>n.then(()=>s.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,n)=>{const s=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,s,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=s}}}function kr(e,{pages:t,pageParams:n}){const s=t.length-1;return e.getNextPageParam(t[s],t,n[s],n)}function Zu(e,{pages:t,pageParams:n}){var s;return(s=e.getPreviousPageParam)==null?void 0:s.call(e,t[0],t,n[0],n)}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(){cn(this,Ue)._++,c(this,Ue)===1&&(j(this,xt,Sn.subscribe(()=>{Sn.isFocused()&&(this.resumePausedMutations(),c(this,te).onFocus())})),j(this,wt,En.subscribe(()=>{En.isOnline()&&(this.resumePausedMutations(),c(this,te).onOnline())})))}unmount(){var e,t;cn(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:n})=>{const s=n.data;return[t,s]})}setQueryData(e,t,n){const s=c(this,te).find({queryKey:e}),r=s==null?void 0:s.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,{...n,manual:!0})}setQueriesData(e,t,n){return se.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,n)]))}getQueryState(e){var t;return(t=c(this,te).find({queryKey:e}))==null?void 0:t.state}removeQueries(e){const t=c(this,te);se.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=c(this,te),s={type:"active",...e};return se.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries(s,t)))}cancelQueries(e={},t={}){const n={revert:!0,...t},s=se.batch(()=>c(this,te).findAll(e).map(r=>r.cancel(n)));return Promise.all(s).then(pe).catch(pe)}invalidateQueries(e={},t={}){return se.batch(()=>{if(c(this,te).findAll(e).forEach(s=>{s.invalidate()}),e.refetchType==="none")return Promise.resolve();const n={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(n,t)})}refetchQueries(e={},t){const n={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},s=se.batch(()=>c(this,te).findAll(e).filter(r=>!r.isDisabled()).map(r=>{let i=r.fetch(void 0,n);return n.throwOnError||(i=i.catch(pe)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(pe)}fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const n=c(this,te).build(this,t);return n.isStaleByTime(t.staleTime)?n.fetch(t):Promise.resolve(n.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 n={};return t.forEach(s=>{Qt(e,s.queryKey)&&(n={...n,...s.defaultOptions})}),n}setMutationDefaults(e,t){c(this,bt).set(Vt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...c(this,bt).values()];let n={};return t.forEach(s=>{Qt(e,s.mutationKey)&&(n={...n,...s.defaultOptions})}),n}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=Cs(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,es,Yt,ts,Jt,ns,Xt,ss,Zt,rs,en,os,tn,is,kn,si,Lr,tl=(Lr=class extends Rt{constructor(t,n){super();U(this,Xe);U(this,Wt);U(this,Yt);U(this,Jt);U(this,Xt);U(this,Zt);U(this,en);U(this,tn);U(this,kn);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=n,j(this,Ae,null),this.bindMethods(),this.setOptions(n)}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,ss).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return as(c(this,Z),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return as(c(this,Z),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,H(this,Zt,rs).call(this),H(this,en,os).call(this),c(this,Z).removeObserver(this)}setOptions(t,n){const s=this.options,r=c(this,Z);if(this.options=c(this,ae).defaultQueryOptions(t),wn(s,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=s.queryKey),H(this,tn,is).call(this);const i=this.hasListeners();i&&Pr(c(this,Z),r,this.options,s)&&H(this,Xe,Mt).call(this),this.updateResult(n),i&&(c(this,Z)!==r||this.options.enabled!==s.enabled||this.options.staleTime!==s.staleTime)&&H(this,Wt,es).call(this);const o=H(this,Yt,ts).call(this);i&&(c(this,Z)!==r||this.options.enabled!==s.enabled||o!==c(this,Fe))&&H(this,Jt,ns).call(this,o)}getOptimisticResult(t){const n=c(this,ae).getQueryCache().build(c(this,ae),t),s=this.createResult(n,t);return sl(this,s)&&(j(this,oe,s),j(this,Et,this.options),j(this,Ge,c(this,Z).state)),s}getCurrentResult(){return c(this,oe)}trackResult(t){const n={};return Object.keys(t).forEach(s=>{Object.defineProperty(n,s,{configurable:!1,enumerable:!0,get:()=>(c(this,Je).add(s),t[s])})}),n}getCurrentQuery(){return c(this,Z)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=c(this,ae).defaultQueryOptions(t),s=c(this,ae).getQueryCache().build(c(this,ae),n);return s.isFetchingOptimistic=!0,s.fetch().then(()=>this.createResult(s,n))}fetch(t){return H(this,Xe,Mt).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),c(this,oe)))}createResult(t,n){var q;const s=c(this,Z),r=this.options,i=c(this,oe),o=c(this,Ge),a=c(this,Et),u=t!==s?t.state:c(this,St),{state:h}=t;let{error:y,errorUpdatedAt:w,fetchStatus:v,status:C}=h,_=!1,b;if(n._optimisticResults){const F=this.hasListeners(),M=!F&&Ar(t,n),m=F&&Pr(t,s,n,r);(M||m)&&(v=In(t.options.networkMode)?"fetching":"paused",h.dataUpdatedAt||(C="pending")),n._optimisticResults==="isRestoring"&&(v="idle")}if(n.select&&typeof h.data<"u")if(i&&h.data===(o==null?void 0:o.data)&&n.select===c(this,Gt))b=c(this,kt);else try{j(this,Gt,n.select),b=n.select(h.data),b=Zn(i==null?void 0:i.data,b,n),j(this,kt,b),j(this,Ae,null)}catch(F){j(this,Ae,F)}else b=h.data;if(typeof n.placeholderData<"u"&&typeof b>"u"&&C==="pending"){let F;if(i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))F=i.data;else if(F=typeof n.placeholderData=="function"?n.placeholderData((q=c(this,At))==null?void 0:q.state.data,c(this,At)):n.placeholderData,n.select&&typeof F<"u")try{F=n.select(F),j(this,Ae,null)}catch(M){j(this,Ae,M)}typeof F<"u"&&(C="success",b=Zn(i==null?void 0:i.data,F,n),_=!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:Bs(t,n),refetch:this.refetch}}updateResult(t){const n=c(this,oe),s=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)),wn(s,n))return;j(this,oe,s);const r={},i=()=>{if(!n)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]!==n[h]&&f.has(h)})};(t==null?void 0:t.listeners)!==!1&&i()&&(r.listeners=!0),H(this,kn,si).call(this,{...r,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&H(this,Xt,ss).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,tn,is).call(this);let n=c(this,Z).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(pe)),n},Wt=new WeakSet,es=function(){if(H(this,Zt,rs).call(this),Ct||c(this,oe).isStale||!Jn(this.options.staleTime))return;const n=Yo(c(this,oe).dataUpdatedAt,this.options.staleTime)+1;j(this,We,setTimeout(()=>{c(this,oe).isStale||this.updateResult()},n))},Yt=new WeakSet,ts=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(c(this,Z)):this.options.refetchInterval)??!1},Jt=new WeakSet,ns=function(t){H(this,en,os).call(this),j(this,Fe,t),!(Ct||this.options.enabled===!1||!Jn(c(this,Fe))||c(this,Fe)===0)&&j(this,Ye,setInterval(()=>{(this.options.refetchIntervalInBackground||Sn.isFocused())&&H(this,Xe,Mt).call(this)},c(this,Fe)))},Xt=new WeakSet,ss=function(){H(this,Wt,es).call(this),H(this,Jt,ns).call(this,H(this,Yt,ts).call(this))},Zt=new WeakSet,rs=function(){c(this,We)&&(clearTimeout(c(this,We)),j(this,We,void 0))},en=new WeakSet,os=function(){c(this,Ye)&&(clearInterval(c(this,Ye)),j(this,Ye,void 0))},tn=new WeakSet,is=function(){const t=c(this,ae).getQueryCache().build(c(this,ae),this.options);if(t===c(this,Z))return;const n=c(this,Z);j(this,Z,t),j(this,St,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},kn=new WeakSet,si=function(t){se.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(c(this,oe))}),c(this,ae).getQueryCache().notify({query:c(this,Z),type:"observerResultsUpdated"})})},Lr);function nl(e,t){return t.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ar(e,t){return nl(e,t)||e.state.dataUpdatedAt>0&&as(e,t,t.refetchOnMount)}function as(e,t,n){if(t.enabled!==!1){const s=typeof n=="function"?n(e):n;return s==="always"||s!==!1&&Bs(e,t)}return!1}function Pr(e,t,n,s){return n.enabled!==!1&&(e!==t||s.enabled===!1)&&(!n.suspense||e.state.status!=="error")&&Bs(e,n)}function Bs(e,t){return e.isStaleByTime(t.staleTime)}function sl(e,t){return!wn(e.getCurrentResult(),t)}var ri=le.createContext(void 0),on=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:n,query:s})=>e.isError&&!t.isReset()&&!e.isFetching&&ii(n,[e.error,s]),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,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function ml(e,t,n){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 s=on(n),r=ol(),i=cl(),o=s.defaultQueryOptions(e);o._optimisticResults=r?"isRestoring":"optimistic",fl(o),ul(o,i),ll(i);const[a]=le.useState(()=>new t(s,o)),f=a.getOptimisticResult(o);if(le.useSyncExternalStore(le.useCallback(u=>{const h=r?()=>{}:a.subscribe(se.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 Dn(e,t){return ml(e,tl,t)}const gl=()=>Dn({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 Ln(){return on().getQueryData(["apiBaseUrl"])||"/api/chaibuilder"}const _s=()=>{const e=on();let t=e.getQueryData(["currentPage"]);return t||(t=localStorage.getItem("currentPage")),[t||"",n=>{localStorage.setItem("currentPage",n),e.setQueryData(["currentPage"],n)}]},Mn=()=>{const[e,t]=_s(),n=Ln();return Dn({queryKey:["project"],queryFn:async()=>{const s=await fetch(`${n}/project`).then(r=>r.json());return!e&&s&&t(s.homepage),s}})},ai=()=>{const{data:e}=Mn(),t=Ln(),n=e==null?void 0:e.uuid;return Dn({queryKey:["pages",n],queryFn:async()=>await fetch(`${t}/pages`).then(r=>r.json())||[],enabled:!!n})},vl=()=>{const[e,t]=_s(),{data:n}=Mn(),s=Ln();return Dn({queryKey:["page_data",e],queryFn:async()=>{const r=await fetch(`${s}/page?uuid=${e}`);return r.ok?r.json():(t(n.homepage),null)},enabled:!!e})},bl=L.lazy(()=>Promise.resolve().then(()=>require("./PagesPanel-5698953d.cjs"))),xl=L.lazy(()=>Promise.resolve().then(()=>require("./ProjectPanel-a3cb7396.cjs"))),wl=()=>{const{data:e,isLoading:t}=Mn(),{data:n,isLoading:s}=ai(),{data:r}=vl();return t||!e?B.jsxRuntimeExports.jsx("div",{children:"Loading..."}):s||!n?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:Ds.FileTextIcon,name:"pages",panel:bl},{icon:Ds.GearIcon,name:"settings",panel:xl}]}})}):B.jsxRuntimeExports.jsx("div",{children:"Loading..."})},Sl=e=>{const{data:t}=gl(),n=on();return L.useEffect(()=>{n.setQueryData(["apiBaseUrl"],e.apiBaseUrl||"/api/chaibuilder")},[e.apiBaseUrl,n]),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=na;exports.canDropBlock=ra;exports.canDuplicateBlock=ta;exports.canvasIframeAtom=co;exports.editLayerNameAtom=ao;exports.enableStyling=Pl;exports.getBlockJSONFromSchemas=Hn;exports.getBlockJSONFromUISchemas=zn;exports.getDefaultState=ni;exports.inlineEditingActiveAtom=ro;exports.networkModeAtom=io;exports.notifyManager=se;exports.setBlockProps=Al;exports.shallowEqualObjects=wn;exports.shouldThrowError=ii;exports.showPredefinedBlockCategoryAtom=fo;exports.useActiveLanguage=Oo;exports.useActiveModal=Za;exports.useActivePanel=sc;exports.useAddBlock=ha;exports.useAddBlockParent=rc;exports.useAddClassesToBlocks=va;exports.useAllBlocks=Jr;exports.useApiBaseUrl=Ln;exports.useBlockContentByLanguage=yc;exports.useBrandingOptions=gs;exports.useBuilderReset=Po;exports.useBuildingBlocks=us;exports.useCanvasHistory=sn;exports.useCanvasWidth=Ca;exports.useCanvasZoom=_a;exports.useCopyBlockIds=yo;exports.useCurrentPage=_s;exports.useCurrentPage$1=Xr;exports.useCutBlockIds=xs;exports.useDarkMode=Ra;exports.useDeveloperPreviewMode=Da;exports.useDuplicateBlocks=Ss;exports.useExpandedIds=Sc;exports.useFeatureSupport=uc;exports.useGetPageData=bs;exports.useHiddenBlockIds=Ma;exports.useHighlightBlockId=bo;exports.useLanguages=gc;exports.useMarkAsGlobalBlock=Ta;exports.useMoveBlocks=Ua;exports.usePages=ai;exports.usePasteBlocks=xo;exports.usePreviewMode=ms;exports.usePrimaryLanguage=mc;exports.useProject=Mn;exports.useProject$1=$a;exports.useQueryClient=on;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=ps;exports.useSetAllBlocks=Kr;exports.useStylingBreakpoint=ho;exports.useStylingState=Wa;exports.useTranslations=cc;exports.useTreeData=ea;exports.useUILibraryBlocks=dc;exports.useUpdateBlocksProps=Ya;exports.useUpdateBlocksPropsRealtime=Ja;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./jsx-runtime-5c3ac4f7.cjs"),q=require("react"),c=require("lodash"),H=require("@radix-ui/react-icons"),w=require("./useBuilderProp-5e57d0c8.cjs"),L=require("./scroll-area-088530b9.cjs"),d=require("@chaibuilder/blocks"),z=require("./index-207f2cbf.cjs"),p=require("./form-6eac0287.cjs"),N=require("./index-ebd86d7f.cjs"),b=require("./useProjectActions-5092ed79.cjs");require("@radix-ui/react-slot");require("class-variance-authority");require("./utils-3c452dd0.cjs");require("clsx");require("tailwind-merge");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");require("jotai");require("@radix-ui/react-scroll-area");require("react-dom");require("@rjsf/core");require("@rjsf/validator-ajv8");require("./link-86c532b5.cjs");require("react-icons-picker");require("./dialog-170eaad9.cjs");require("@radix-ui/react-dialog");require("./ImagesPanel-addb2bf9.cjs");require("./tabs-860e37aa.cjs");require("@radix-ui/react-tabs");require("react-quill");require("react-i18next");require("i18next");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("react-hotkeys-hook");require("flat-to-nested");require("./Class-7d6aadbc.cjs");require("redux-undo");require("@react-hookz/web");require("./CONTROLS-031e1de3.cjs");const _=q.lazy(()=>Promise.resolve().then(()=>require("./delete-page-modal-1e3914e3.cjs"))),B=q.lazy(()=>Promise.resolve().then(()=>require("./confirm-alert-4f50caa7.cjs"))),h=n=>{if(!c.isString(n)||!(n.includes("/[")&&n.includes("]")))return!1;const s=/^\[((?:\.{3})?[a-zA-Z0-9_-]+)\]$/,g=/^[a-zA-Z0-9_-]+$/;let e=!0;return n.split("/").forEach(u=>{e&&(u.includes("[[")&&u.includes("]]")?e=/^\[\[\.{3}[a-zA-Z0-9_-]+\]\]$/.test(u):u.includes("[")&&u.includes("]")?e=s.test(u):e=g.test(u))}),e},P=n=>n&&c.isEmpty(n.seoData)?{...n,seoData:{title:"",description:"",image:""}}:n,G=(n,o)=>{const s=!c.isEqual(c.omit(n,["seoData"]),c.omit(o,["seoData"])),g=!c.isEqual(P(o).seoData,P(n).seoData);return s||g},Y=({open:n,setOpen:o,pageData:s})=>{const g=N.useQueryClient(),{data:e}=N.useProject(),u=b.useUpdateProject(),m=b.useUpdateProject("Homepage updated successfully."),[i,y]=q.useState(P(s)),[a,A]=q.useState({isHomePage:(e==null?void 0:e.homepage)===s.uuid}),E=G(i,s);q.useEffect(()=>{const l=!c.isEqual(P(s),i),r=(e==null?void 0:e.homepage)!==s.uuid&&a.isHomePage;o(l||r?"PENDING":"OPEN")},[e,s,i,a,o]);const j=()=>{if(E){if(s.type==="DYNAMIC"&&!h((i==null?void 0:i.slug)||"")){n==="ALERT"&&o("PENDING");return}u.mutate(i,{onSuccess:()=>{g.invalidateQueries({refetchType:"active",queryKey:["pages",e==null?void 0:e.uuid]}),o("CLOSE"),z.Nt.success("Page updated successfully.")}})}a.isHomePage&&(e==null?void 0:e.homepage)!==s.uuid&&m.mutate({...e,homepage:s==null?void 0:s.uuid},{onSuccess:()=>o("CLOSE")})},S=({formData:l},r)=>{y(f=>{var C,R;if(!r)return f;const x={[r]:l[r]};return r==="page_name"?x.slug=c.kebabCase((C=l[r])==null?void 0:C.replace(/\d/g,"")):r==="slug"?x.slug=(R=l[r])==null?void 0:R.replace(/\d/g,"").replace(/\s+/g,"").replace("--","-").replace("__","_"):r==="seo_data"&&(x.seo_data={title:l[r].title||"",description:l[r].description||"",image:l[r].image||""}),{...f,...x}})},I=({formData:l},r)=>{A(f=>{const x={[r]:l[r]};return{...f,...x}})},T={page_name:d.SingleLineText({title:"Page Name",default:i.name}),slug:d.SingleLineText({title:"Page Slug",default:i.slug})},v={seo_data:d.Model({title:"",description:"",default:{title:"",description:"",image:""},properties:{title:d.SingleLineText({title:"Meta Title",default:i.name}),description:d.MultilineText({title:"Meta Description",default:i.slug}),image:d.Image({title:"Social Media Image",default:""})}})},M={isHomePage:d.Checkbox({title:"Set as homepage",default:a.isHomePage})};return t.jsxRuntimeExports.jsxs(L.ScrollArea,{className:"flex h-full select-none flex-col",children:[t.jsxRuntimeExports.jsx(B,{open:n==="ALERT",title:"Do yo want to save changes?",onCancel:()=>o("CLOSE"),onConfirm:j,disabled:m.isPending||u.isPending}),t.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-background/30 px-2.5 py-1",children:t.jsxRuntimeExports.jsx("h1",{className:"px-1 font-semibold",children:"Page Details"})}),t.jsxRuntimeExports.jsx("div",{className:"px-2.5 pt-2",children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col space-y-2",children:[t.jsxRuntimeExports.jsx(p.Form,{title:"Basic Details",formData:i,properties:T,onChange:S,disabled:u.isPending||m.isPending}),t.jsxRuntimeExports.jsx("div",{className:"h-2 w-full"}),t.jsxRuntimeExports.jsx(p.Form,{title:"SEO Details",formData:i,properties:v,onChange:S,disabled:u.isPending||m.isPending}),(e==null?void 0:e.homepage)!==s.uuid&&s.type==="STATIC"?t.jsxRuntimeExports.jsx(p.Form,{formData:a,properties:M,onChange:I,disabled:u.isPending||m.isPending}):s.type==="STATIC"&&t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-1 px-1 pt-2 text-xs font-medium text-gray-500",children:[t.jsxRuntimeExports.jsx(H.HomeIcon,{})," This is homepage"," "]}),i.type==="DYNAMIC"&&!h((i==null?void 0:i.slug)||"")&&t.jsxRuntimeExports.jsxs("small",{className:"px-1 text-red-400",children:["Add dynamic ID in page slug Eg: ",t.jsxRuntimeExports.jsx("i",{className:"underline",children:"some-url/[some-id]"})]}),t.jsxRuntimeExports.jsxs("div",{className:"my-2 flex w-full items-center justify-between gap-x-2 px-1",children:[t.jsxRuntimeExports.jsx(w.Button,{className:"w-full",type:"submit",onClick:j,disabled:(e==null?void 0:e.homepage)!==s.uuid&&a.isHomePage?!1:c.isEmpty(i.name)||c.isEmpty(i.slug)||!E||u.isPending||m.isPending||i.type==="DYNAMIC"&&!h((i==null?void 0:i.slug)||""),children:"Save"}),t.jsxRuntimeExports.jsx(_,{pageData:s,projectData:e})]})]})})]})};exports.default=Y;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("./index-ebd86d7f.cjs"),n=require("./index-207f2cbf.cjs");require("react-i18next");const a=require("./useBuilderProp-5e57d0c8.cjs"),c=()=>{const[s]=["SAVED"],[e,u]=t.useCurrentPage(),r=t.useBuilderReset();return i=>s==="UNSAVED"?(a.toast({variant:"destructive",title:"Please save unsaved changes"}),!1):e===i.uuid?!1:(r(),setTimeout(()=>{u(i.uuid)},100),!0)},d=()=>{const s=t.useQueryClient(),e=c();return n.useMutation({mutationFn:async u=>fetch("/pages",{method:"POST",body:JSON.stringify(u)}).then(r=>r.json()),onSuccess:u=>{s.invalidateQueries({queryKey:["pages"]}),e({uuid:u.uuid,slug:u.slug}),n.Nt.success("Page added successfully.")}})},o=()=>{const s=t.useQueryClient();return n.useMutation({mutationFn:async e=>fetch(`/page?uuid=${e.uuid}`,{method:"DELETE",body:JSON.stringify(e)}),onSuccess:()=>{n.Nt.success("Page deleted successfully."),s.invalidateQueries({queryKey:["pages"]})}})};exports.useAddPage=d;exports.useDeletePage=o;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { X as u, Y as o } from "./index-390f7bef.js";
|
|
2
|
-
import { u as a, N as c } from "./index-824a7bd0.js";
|
|
3
|
-
const p = (e = "Project updated successfully.") => {
|
|
4
|
-
const s = u(), t = o();
|
|
5
|
-
return a({
|
|
6
|
-
mutationFn: async (r) => await fetch(`${t}/project`, {
|
|
7
|
-
method: "PUT",
|
|
8
|
-
body: JSON.stringify(r)
|
|
9
|
-
}),
|
|
10
|
-
onSuccess: () => {
|
|
11
|
-
s.invalidateQueries({ queryKey: ["project"] }), c.success(e);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
export {
|
|
16
|
-
p as u
|
|
17
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./index-ebd86d7f.cjs"),t=require("./index-207f2cbf.cjs"),n=(s="Project updated successfully.")=>{const c=e.useQueryClient(),r=e.useApiBaseUrl();return t.useMutation({mutationFn:async u=>await fetch(`${r}/project`,{method:"PUT",body:JSON.stringify(u)}),onSuccess:()=>{c.invalidateQueries({queryKey:["project"]}),t.Nt.success(s)}})};exports.useUpdateProject=n;
|