@chaibuilder/sdk 0.1.6 → 0.1.7
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-671fde09.js → AddBlocks-0d80d14e.js} +1 -1
- package/dist/{AddBlocks-862cf7e0.cjs → AddBlocks-263e048b.cjs} +1 -1
- package/dist/{BrandingOptions-520c438d.js → BrandingOptions-2eb3a20f.js} +1 -1
- package/dist/{BrandingOptions-8bbdd54f.cjs → BrandingOptions-fe2c729f.cjs} +1 -1
- package/dist/{CanvasArea-86eef07f.cjs → CanvasArea-35fe4de9.cjs} +2 -2
- package/dist/{CanvasArea-d912e63e.js → CanvasArea-366fc7f5.js} +2 -2
- package/dist/{Layers-db65053b.js → Layers-c375ab6b.js} +2 -2
- package/dist/{Layers-ae78b10e.cjs → Layers-ec26b885.cjs} +1 -1
- package/dist/{MarkAsGlobalBlock-a1274d49.js → MarkAsGlobalBlock-3ecff4e8.js} +1 -1
- package/dist/{MarkAsGlobalBlock-d5b40fdb.cjs → MarkAsGlobalBlock-b60aa4a5.cjs} +1 -1
- package/dist/{PagesPanel-41ebbdd1.cjs → PagesPanel-27e831e4.cjs} +1 -1
- package/dist/{PagesPanel-48cb686f.js → PagesPanel-28b02d06.js} +2 -2
- package/dist/{ProjectPanel-08a229f3.cjs → ProjectPanel-d77ca4b1.cjs} +1 -1
- package/dist/{ProjectPanel-920b0f75.js → ProjectPanel-e6e95d71.js} +2 -2
- package/dist/{Settings-9ccc4a65.js → Settings-4c13f136.js} +1 -1
- package/dist/{Settings-0c125f1b.cjs → Settings-f533682d.cjs} +1 -1
- package/dist/{SidePanels-9684bfe2.js → SidePanels-0f011b5d.js} +2 -2
- package/dist/{SidePanels-ef33ed66.cjs → SidePanels-8a461fbd.cjs} +1 -1
- package/dist/{Topbar-2f40d770.js → Topbar-d609b15e.js} +1 -1
- package/dist/{Topbar-84eadc0e.cjs → Topbar-e3b28705.cjs} +1 -1
- package/dist/add-page-modal-345f02a4.cjs +1 -0
- package/dist/{add-page-modal-fb7d069a.js → add-page-modal-fb1e7f3d.js} +16 -18
- package/dist/core.cjs +1 -1
- package/dist/core.js +10 -10
- package/dist/{delete-page-modal-cc906461.js → delete-page-modal-1e7c44c4.js} +3 -5
- package/dist/delete-page-modal-83b69ad2.cjs +1 -0
- package/dist/{index-32519c31.js → index-0f2acc34.js} +1433 -1366
- package/dist/index-334beafe.cjs +2 -0
- package/dist/{page-viewer-77998a4d.js → page-viewer-791fb7c7.js} +7 -8
- package/dist/page-viewer-83157368.cjs +1 -0
- package/dist/{project-general-setting-a8be43b9.cjs → project-general-setting-b8508aa1.cjs} +1 -1
- package/dist/{project-general-setting-e66f4966.js → project-general-setting-ba6333d9.js} +1 -1
- package/dist/{single-page-detail-a0332ab5.js → single-page-detail-69dd268b.js} +14 -16
- package/dist/single-page-detail-a186cd56.cjs +1 -0
- package/package.json +1 -1
- package/dist/add-page-modal-7fc782b9.cjs +0 -1
- package/dist/delete-page-modal-15e71ba4.cjs +0 -1
- package/dist/index-1217461b.cjs +0 -2
- package/dist/page-viewer-15b9eb5f.cjs +0 -1
- package/dist/single-page-detail-116281ae.cjs +0 -1
- package/dist/useChangePage-6a7c7374.js +0 -12
- package/dist/useChangePage-f22cea36.cjs +0 -1
- package/dist/usePageActions-5e28a006.cjs +0 -1
- package/dist/usePageActions-d6e1d325.js +0 -38
package/dist/index-1217461b.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var Ks=(e,t,s)=>{if(!t.has(e))throw TypeError("Cannot "+s)};var a=(e,t,s)=>(Ks(e,t,"read from private field"),s?s.call(e):t.get(e)),I=(e,t,s)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,s)},k=(e,t,s,n)=>(Ks(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s);var ps=(e,t,s,n)=>({set _(r){k(e,t,r,s)},get _(){return a(e,t,n)}}),K=(e,t,s)=>(Ks(e,t,"access private method"),s);const O=require("./jsx-runtime-5c3ac4f7.cjs"),So=require("i18next"),Eo=require("react-i18next"),ko=require("flagged"),L=require("react"),Ao=require("react-dnd"),d=require("lodash"),Vn=require("@minoru/react-dnd-treeview"),ve=require("./useBuilderProp-5e57d0c8.cjs"),y=require("jotai"),Po=require("./utils-3c452dd0.cjs"),Re=require("react-hotkeys-hook"),Hr=require("flat-to-nested"),fe=require("./Class-6c695ccb.cjs"),Qt=require("redux-undo"),Co=require("@react-hookz/web"),ce=require("./MODIFIERS-70fef873.cjs"),Gr=require("@chaibuilder/blocks"),Zs=require("sonner"),Qn=require("@radix-ui/react-icons"),jo=require("lucide-react");function Oo(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const re=Oo(L),_o="Dark mode",Bo="This page has no blocks. Add a block by clicking the + button",Ro="This page is empty",Io="Please select a block to edit settings or styles",Do="Please select a styling block",Mo="Drop your block here",Lo={dark_mode:_o,tree_view_no_blocks:Bo,canvas_empty:Ro,no_block_selected_for_styling:Io,no_styling_block_selected:Do,drop_here_message:Mo};So.use(Eo.initReactI18next).init({resources:{en:{translation:Lo}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});const No="";const To={};class Wr 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?O.jsxRuntimeExports.jsx("h1",{children:"Something went wrong."}):this.props.children}}const Uo=e=>{const t=e.replace(ce.STYLES_KEY,"").split(",");return{baseClasses:t[0],classes:t[1]}};let Fo=0;function Me(e,t){const s=`atom${++Fo}`,n={toString:()=>s};return typeof e=="function"?n.read=e:(n.init=e,n.read=r=>r(n),n.write=(r,i,o)=>i(n,typeof o=="function"?o(r(n)):o)),t&&(n.write=t),n}const Kn=e=>"init"in e,zn=e=>!!e.write,Ps=new WeakMap,qo=(e,t)=>{Ps.set(e,t),e.catch(()=>{}).finally(()=>Ps.delete(e))},Hn=(e,t)=>{const s=Ps.get(e);s&&(Ps.delete(e),s(t))},Gn=(e,t)=>{e.status="fulfilled",e.value=t},Wn=(e,t)=>{e.status="rejected",e.reason=t},$o=e=>typeof(e==null?void 0:e.then)=="function",qt=(e,t)=>"v"in e&&"v"in t&&Object.is(e.v,t.v),Yn=(e,t)=>"e"in e&&"e"in t&&Object.is(e.e,t.e),lt=e=>"v"in e&&e.v instanceof Promise,Vo=(e,t)=>"v"in e&&"v"in t&&e.v.orig&&e.v.orig===t.v.orig,ms=e=>{if("e"in e)throw e.e;return e.v},Qo=()=>{const e=new WeakMap,t=new WeakMap,s=new Map;let n,r,i;const o=m=>e.get(m),c=(m,x)=>{const R=e.get(m);if(e.set(m,x),s.has(m)||s.set(m,R),R&<(R)){const w="v"in x?x.v instanceof Promise?x.v:Promise.resolve(x.v):Promise.reject(x.e);Hn(R.v,w)}},l=(m,x,R)=>{const w=new Map;let D=!1;R.forEach((j,S)=>{!j&&S===m&&(j=x),j&&(w.set(S,j),x.d.get(S)!==j&&(D=!0))}),(D||x.d.size!==w.size)&&(x.d=w)},u=(m,x,R)=>{const w=o(m),D={d:(w==null?void 0:w.d)||new Map,v:x};if(R&&l(m,D,R),w&&qt(w,D)&&w.d===D.d)return w;if(w&<(w)&<(D)&&Vo(w,D)){if(w.d===D.d)return w;D.v=w.v}return c(m,D),D},h=(m,x,R,w)=>{if($o(x)){let D;const j=new Promise((S,z)=>{let Q=!1;x.then(W=>{if(!Q){Q=!0;const f=o(m),p=u(m,j,R);Gn(j,W),S(W),(f==null?void 0:f.d)!==p.d&&q(m,p,f==null?void 0:f.d)}},W=>{if(!Q){Q=!0;const f=o(m),p=u(m,j,R);Wn(j,W),z(W),(f==null?void 0:f.d)!==p.d&&q(m,p,f==null?void 0:f.d)}}),D=W=>{Q||(Q=!0,W.then(f=>Gn(j,f),f=>Wn(j,f)),S(W))}});return j.orig=x,j.status="pending",qo(j,S=>{S&&D(S),w==null||w()}),u(m,j,R)}return u(m,x,R)},g=(m,x,R)=>{const w=o(m),D={d:(w==null?void 0:w.d)||new Map,e:x};return R&&l(m,D,R),w&&Yn(w,D)&&w.d===D.d?w:(c(m,D),D)},A=m=>{const x=o(m);if(x&&(x.d.forEach((Q,W)=>{W!==m&&!t.has(W)&&A(W)}),Array.from(x.d).every(([Q,W])=>{const f=o(Q);return Q===m||f===W||f&&!lt(f)&&qt(f,W)})))return x;const R=new Map;let w=!0;const D=Q=>{if(Q===m){const f=o(Q);if(f)return R.set(Q,f),ms(f);if(Kn(Q))return R.set(Q,void 0),Q.init;throw new Error("no atom init")}const W=A(Q);return R.set(Q,W),ms(W)};let j,S;const z={get signal(){return j||(j=new AbortController),j.signal},get setSelf(){return!S&&zn(m)&&(S=(...Q)=>{if(!w)return M(m,...Q)}),S}};try{const Q=m.read(D,z);return h(m,Q,R,()=>j==null?void 0:j.abort())}catch(Q){return g(m,Q,R)}finally{w=!1}},v=m=>ms(A(m)),_=m=>{let x=t.get(m);return x||(x=E(m)),x},B=(m,x)=>!x.l.size&&(!x.t.size||x.t.size===1&&x.t.has(m)),b=m=>{const x=t.get(m);x&&B(m,x)&&P(m)},C=m=>{const x=new Map,R=new WeakMap,w=j=>{const S=t.get(j);S==null||S.t.forEach(z=>{z!==j&&(x.set(z,(x.get(z)||new Set).add(j)),R.set(z,(R.get(z)||0)+1),w(z))})};w(m);const D=j=>{const S=t.get(j);S==null||S.t.forEach(z=>{var Q;if(z!==j){let W=R.get(z);if(W&&R.set(z,--W),!W){let f=!!((Q=x.get(z))!=null&&Q.size);if(f){const p=o(z),T=A(z);f=!p||!qt(p,T)}f||x.forEach(p=>p.delete(z))}D(z)}})};D(m)},U=(m,...x)=>{let R=!0;const w=S=>ms(A(S)),D=(S,...z)=>{let Q;if(S===m){if(!Kn(S))throw new Error("atom not writable");const W=o(S),f=h(S,z[0]);(!W||!qt(W,f))&&C(S)}else Q=U(S,...z);if(!R){const W=F()}return Q},j=m.write(w,D,...x);return R=!1,j},M=(m,...x)=>{const R=U(m,...x),w=F();return R},E=(m,x)=>{const R={t:new Set(x&&[x]),l:new Set};if(t.set(m,R),A(m).d.forEach((w,D)=>{const j=t.get(D);j?j.t.add(m):D!==m&&E(D,m)}),A(m),zn(m)&&m.onMount){const w=m.onMount((...D)=>M(m,...D));w&&(R.u=w)}return R},P=m=>{var x;const R=(x=t.get(m))==null?void 0:x.u;R&&R(),t.delete(m);const w=o(m);w&&(lt(w)&&Hn(w.v),w.d.forEach((D,j)=>{if(j!==m){const S=t.get(j);S&&(S.t.delete(m),B(j,S)&&P(j))}}))},q=(m,x,R)=>{const w=new Set(x.d.keys());R==null||R.forEach((D,j)=>{if(w.has(j)){w.delete(j);return}const S=t.get(j);S&&(S.t.delete(m),B(j,S)&&P(j))}),w.forEach(D=>{const j=t.get(D);j?j.t.add(m):t.has(m)&&E(D,m)})},F=()=>{let m;for(;s.size;){const x=Array.from(s);s.clear(),x.forEach(([R,w])=>{const D=o(R);if(D){D.d!==(w==null?void 0:w.d)&&q(R,D,w==null?void 0:w.d);const j=t.get(R);j&&!(w&&!lt(w)&&(qt(w,D)||Yn(w,D)))&&j.l.forEach(S=>S())}})}};return{get:v,set:M,sub:(m,x)=>{const R=_(m),w=F(),D=R.l;return D.add(x),()=>{D.delete(x),b(m)}}}};let zs;const Ko=()=>(zs||(zs=Qo()),zs),zo=Symbol();function Ho(e,t){const s=Me(e,(n,r,i)=>r(s,t(n(s),i)));return s}const Jn=(e,t,s)=>(t.has(s)?t:t.set(s,e())).get(s),Go=new WeakMap,Wo=(e,t,s)=>{const n=Jn(()=>new WeakMap,Go,t);return Jn(e,n,s)},Yo={},Zn=e=>!!e.write,Jo=e=>typeof e=="function";function Zo(e,t){return Wo(()=>{const s=new WeakMap,n=(o,c)=>{let l=s.get(o);if(l)return l;const u=c&&s.get(c),h=[],g=[];return o.forEach((A,v)=>{const _=t?t(A):v;g[v]=_;const B=u&&u.atomList[u.keyList.indexOf(_)];if(B){h[v]=B;return}const b=U=>{const M=U(r),E=U(e),q=n(E,M==null?void 0:M.arr).keyList.indexOf(_);if(q<0||q>=E.length){const F=o[n(o).keyList.indexOf(_)];if(F)return F;throw new Error("splitAtom: index out of bounds for read")}return E[q]},C=(U,M,E)=>{const P=U(r),q=U(e),N=n(q,P==null?void 0:P.arr).keyList.indexOf(_);if(N<0||N>=q.length)throw new Error("splitAtom: index out of bounds for write");const m=Jo(E)?E(q[N]):E;M(e,[...q.slice(0,N),m,...q.slice(N+1)])};h[v]=Zn(e)?Me(b,C):Me(b)}),u&&u.keyList.length===g.length&&u.keyList.every((A,v)=>A===g[v])?l=u:l={arr:o,atomList:h,keyList:g},s.set(o,l),l},r=Me(o=>{const c=o(r),l=o(e);return n(l,c==null?void 0:c.arr)});r.init=void 0;const i=Zn(e)?Me(o=>o(r).atomList,(o,c,l)=>{switch(l.type){case"remove":{const u=o(i).indexOf(l.atom);if(u>=0){const h=o(e);c(e,[...h.slice(0,u),...h.slice(u+1)])}break}case"insert":{const u=l.before?o(i).indexOf(l.before):o(i).length;if(u>=0){const h=o(e);c(e,[...h.slice(0,u),l.value,...h.slice(u)])}break}case"move":{const u=o(i).indexOf(l.atom),h=l.before?o(i).indexOf(l.before):o(i).length;if(u>=0&&h>=0){const g=o(e);u<h?c(e,[...g.slice(0,u),...g.slice(u+1,h),g[u],...g.slice(h)]):c(e,[...g.slice(0,h),g[u],...g.slice(h,u),...g.slice(u+1)])}break}}}):Me(o=>o(r).atomList);return i},e,t||Yo)}const Xo=e=>typeof(e==null?void 0:e.then)=="function";function ea(e){let t,s;const n={getItem:(r,i)=>{var o,c;const l=h=>{if(h=h||"",t!==h){try{s=JSON.parse(h)}catch{return i}t=h}return s},u=(c=(o=e())==null?void 0:o.getItem(r))!=null?c:null;return Xo(u)?u.then(l):l(u)},setItem:(r,i)=>{var o;return(o=e())==null?void 0:o.setItem(r,JSON.stringify(i))},removeItem:r=>{var i;return(i=e())==null?void 0:i.removeItem(r)}};return typeof window<"u"&&typeof window.addEventListener=="function"&&(n.subscribe=(r,i,o)=>{if(!(e()instanceof window.Storage))return()=>{};const c=l=>{if(l.storageArea===e()&&l.key===r){let u;try{u=JSON.parse(l.newValue||"")}catch{u=o}i(u)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}}),n}const ta=ea(()=>typeof window<"u"?window.localStorage:void 0);function ct(e,t,s=ta,n){const r=n==null?void 0:n.unstable_getOnInit,i=Me(r?s.getItem(e,t):t);return i.onMount=c=>{r||c(s.getItem(e,t));let l;return s.subscribe&&(l=s.subscribe(e,c,t)),l},Me(c=>c(i),(c,l,u)=>{const h=typeof u=="function"?u(c(i)):u;return h===zo?(l(i,t),s.removeItem(e)):h instanceof Promise?h.then(g=>(l(i,g),s.setItem(e,g))):(l(i,h),s.setItem(e,h))})}const sa=L.createContext(void 0),Yr=e=>{const t=L.useContext(sa);return(e==null?void 0:e.store)||t||Ko()},na=e=>typeof(e==null?void 0:e.then)=="function",ra=L.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)});function ia(e,t){const s=Yr(t),[[n,r,i],o]=L.useReducer(u=>{const h=s.get(e);return Object.is(u[0],h)&&u[1]===s&&u[2]===e?u:[h,s,e]},void 0,()=>[s.get(e),s,e]);let c=n;(r!==s||i!==e)&&(o(),c=s.get(e));const l=t==null?void 0:t.delay;return L.useEffect(()=>{const u=s.sub(e,()=>{if(typeof l=="number"){setTimeout(o,l);return}o()});return o(),u},[s,e,l]),L.useDebugValue(c),na(c)?ra(c):c}function oa(e,t){const s=Yr(t);return L.useCallback((...r)=>s.set(e,...r),[s,e])}function aa(e,t){return[ia(e,t),oa(e,t)]}const ca=new Hr({children:"blockNodes"}),Jr=(e,t=null)=>d.flatten(e.map(s=>{if(s=t!==null?{...s,parent:t}:s,s.children&&s.children.length){const n=[...s.children];return delete s.children,d.flatten([s,...Jr(n,s._id)])}return s}));function Zr(e,t,s){const n=d.filter(e,i=>i._parent===t),r=[];for(let i=0;i<n.length;i++){const o=Xr(n[i]);if(Object.keys(o).length>0&&Object.keys(o).forEach(c=>{n[i][c]=`slot:${fe.generateUUID()}`}),d.filter(e,{_parent:n[i]._id}).length>0){const c=fe.generateUUID();r.push({...n[i],oldId:n[i]._id,_id:c,_parent:s}),r.push(d.flatten(Zr(e,n[i]._id,c)))}else r.push({...n[i],oldId:n[i]._id,_id:fe.generateUUID(),_parent:s})}return d.flatten(r)}function ua(e){let t=ca.convert(e.map(s=>d.omit(s,["settings"])));return t=!t.type&&t.blockNodes?t.blockNodes:d.isEmpty(t)?[]:[t],t}const Xr=e=>{const t={};return Object.keys(e).forEach(s=>{d.isString(e[s])&&e[s].startsWith("slot")&&(t[s]=e[s].replace("slot:",""))}),t},la=(e,t,s=null)=>{let n=d.find(e,{_id:t});n={...n,oldId:n._id,_id:fe.generateUUID()},s&&(n={...n,_parent:s});const r=[n];d.filter(e,{_parent:t}).length>0&&r.push(d.flatten(Zr(e,t,n._id)));const i=d.flatten(r);return d.map(i,o=>{const c=o,l=Xr(c);return Object.keys(l).length>0&&Object.keys(l).forEach(u=>{const h=d.find(i,{oldId:l[u].replace("slot:","")});c[u]=`slot:${h._id}`}),d.omit(c,["global","oldId"])})},da=Qt((e=[],t)=>{switch(t.type){case"add_new_blocks":case"add_duplicate_blocks":return[...e,...t.payload];case"create_snapshot":return[...e];case"set_blocks":case"set_page_blocks":return[...t.payload];case"update_props":case"update_props_realtime":const{payload:s}=t;return e.map(n=>(s.ids.includes(n._id)&&!d.isEmpty(t.payload.props)&&Object.keys(t.payload.props).forEach(r=>{d.set(n,r,t.payload.props[r])}),n));default:return e}},{debug:!1,ignoreInitialState:!1,limit:30,filter:Qt.excludeAction(["update_props_realtime","add_duplicate_blocks","set_page_blocks"])}),Is=Ho({past:[],present:[],future:[]},da);Is.debugLabel="pageBlocksAtom";const be=y.atom(e=>{var t;return(t=e(Is))==null?void 0:t.present});be.debugLabel="presentBlocksAtom";const vn=Zo(be);vn.debugLabel="pageBlocksAtomsAtom";const ei=y.atom(e=>ua(e(be)));ei.debugLabel="pageBlocksTreeAtom";const fa=y.atom("");fa.debugLabel="builderActivePageAtom";const ha=y.atom(-1);ha.debugLabel="destinationDropIndexAtom";const ti=y.atom(!1);ti.debugLabel="addBlocksModalAtom";const xe=()=>{const[,e]=y.useAtom(Is);return e},pa=()=>{const e=xe(),t=y.useAtomValue(ei),s=L.useCallback(n=>{const r=Jr(n);e({type:"set_page_blocks",payload:r})},[e]);return[t,s]},si=()=>{const e=xe();return[L.useCallback(s=>{e({type:"set_page_blocks",payload:s})},[e])]},Xs=e=>["Box","Slot","Form","DataContext","Link","List","ListItem","Row","Column","Table","TableCell"].includes(e),ma=e=>!["Slot"].includes(e),ga=e=>!["Slot"].includes(e);function ya(e,t){return e==="Slot"||t==="List"&&e!=="ListItem"||t==="Row"&&e!=="Column"?!1:Xs(t)}const va=(e,{dragSource:t,dropTarget:s})=>{const n=d.get(t,"data._type",""),r=d.get(s,"data._type","");return n==="Slot"||d.get(t,"id")&&d.get(t,"id")===d.get(s,"id")?!1:d.isEmpty(r)?!0:ya(n,r)},bn=y.atom([]);bn.debugLabel="selectedBlockIdsAtom";const xn=y.atom(e=>{const t=e(be),s=e(bn);return d.map(d.filter(t,({_id:n})=>d.includes(s,n)),n=>({...n}))});xn.debugLabel="selectedBlocksAtom";const wn=y.atom(e=>{const t=e(xn);return t.length===0?null:t.length===1?t[0]:{type:"Multiple",id:d.map(t,"id")}});wn.debugLabel="selectedBlockAtom";const ba=e=>d.get(e,"parent",null),xa=y.atom(e=>{const t=e(xn),s=d.map(t,ba);return d.filter(e(be),n=>d.includes(s,n._id))});xa.debugLabel="selectedBlocksParentsAtom";const ni=y.atom(()=>!1);ni.debugLabel="selectedBlockFlexChildAtom";const ri=y.atom(()=>!1);ri.debugLabel="selectedBlockGridChildAtom";const Sn=y.atom("");Sn.debugLabel="styleStateAtom";const ii=ct("styleBreakpoint","xs");ii.debugLabel="styleBreakpointAtom";const wa=()=>({flexChild:y.useAtomValue(ni),gridChild:y.useAtomValue(ri)}),Sa=()=>y.useAtomValue(wn),ze=()=>{const[e,t]=y.useAtom(bn),s=L.useCallback(n=>{t(r=>d.includes(r,n)?d.without(r,n):[...r,n])},[t]);return[e,t,s]},en=(e,t="")=>{switch(e.type){case"singular":return e.uiSchema;case"model":const{properties:s}=e,n={};return Object.keys(s).forEach(o=>{const c=s[o];if(d.includes(["slot","styles"],c.type))return;const l=d.get(c,"i18n",!1)?`${o}-${t}`:o;n[l]=en(c,t)}),n;case"list":const{itemProperties:r}=e,i={items:{}};return Object.keys(r).forEach(o=>{const c=r[o];if(d.includes(["slot","styles"],c.type))return;const l=d.get(c,"i18n",!1)?`${o}-${t}`:o;i.items[l]=en(c,t)}),i;default:return{}}},tn=(e,t="")=>{switch(e.type){case"singular":return e.schema;case"model":const{properties:s,title:n}=e,r={title:n,type:"object",properties:{}};return Object.keys(s).forEach(l=>{const u=s[l];if(d.includes(["slot","styles"],u.type))return;const h=d.get(u,"i18n",!1)?`${l}-${t}`:l;r.properties[h]=tn(u,t)}),r;case"list":const{itemProperties:i,title:o}=e,c={title:o,type:"array",items:{type:"object",properties:{}}};return Object.keys(i).forEach(l=>{const u=i[l];if(d.includes(["slot","styles"],u.type))return;const h=d.get(u,"i18n",!1)?`${l}-${t}`:l;c.items.properties[h]=tn(u,t),d.set(c.items,"title",d.get(u,"itemTitle",`${o} item`))}),c;default:return{}}},oi=e=>{const t={};return Object.keys(e).forEach(s=>{t[s]=ka(e[s])}),t},Ea=e=>{if(d.isEmpty(e.default))return[];const{itemProperties:t}=e;return d.map(e.default,s=>{const n={...s};return d.forIn(s,(r,i)=>{d.has(t,i)&&d.get(t[i],"i18n",!1)&&(n[i]=ce.I18N_KEY)}),n})},ka=e=>{switch(e.type){case"styles":return e.default;case"slot":return`${ce.SLOT_KEY}${fe.generateUUID()}`;case"singular":const{i18n:t,schema:s}=e;return t?ce.I18N_KEY:d.get(s,"default","");case"model":return oi(e.properties);case"list":return Ea(e);default:return""}},ai=()=>y.useAtomValue(be);function Xn(e,t,s,n,r){if(t===null)return[...e,...n];if(s!==null){const l=d.findIndex(e,{_parent:t}),u=(l===-1?0:l)+s;return e.splice(u,0,...n),e}if(!r){const u=d.findIndex(e,{_id:t})+1;return e.splice(u,0,...n),e}let i=d.findIndex(e,{_id:t});const o=d.filter(e,{_parent:t});d.isEmpty(o)||(i=d.findIndex(e,{_id:d.last(o)._id}));const c=i+1;return e.splice(c,0,...n),e}const Aa=()=>{const e=xe(),t=ai(),[,s]=ze(),n=L.useCallback((i,o,c)=>{var h;for(let g=0;g<i.length;g++){const{_id:A}=i[g];i[g]._id=fe.generateUUID();const v=d.filter(i,{_parent:A});for(let _=0;_<v.length;_++)v[_]._parent=i[g]._id}let l;o&&(l=d.find(t,{_id:o}),i[0]._parent=o);const u=l?Xs(l._type):!0;return!u&&l&&(i[0]._parent=l._parent),e({type:"set_blocks",payload:Xn(t,o||null,c||null,i,u)}),s([(h=d.first(i))==null?void 0:h._id]),d.first(i)},[t,e,s]);return{addCoreBlock:L.useCallback((i,o,c)=>{if(d.has(i,"blocks")){const B=i.blocks;return n(B,o,c)}const l=fe.generateUUID(),u=oi(i.props),h=[];d.forIn(u,(B,b)=>{if(d.startsWith(B,ce.SLOT_KEY)){const C=B.replace(ce.SLOT_KEY,"");h.push({_id:C,_type:"Slot",_parent:l,_name:i.props[b].name,_styles:i.props[b].styles,_emptyStyles:i.props[b].emptyStyles})}});const g={_type:i.type,_id:l,...u};let A;o&&(A=d.find(t,{_id:o}),g._parent=o);const v=A?Xs(A._type):!0;!v&&A&&(g._parent=A._parent);const _=[g,...h];return e({type:"set_blocks",payload:Xn(t,o||null,c||null,_,v)}),s([g._id]),g},[n,t,e,s]),addPredefinedBlock:n}},er={xs:420,sm:620,md:768,lg:1024,xl:1280,"2xl":1536},tr=["xs","sm","md","lg","xl","2xl"];function Pa(e,t){if(t===null)return"baseClasses";const s=t.mq;if(s==="xs"||t.dark||t.mod!=="")return"classes";let n="baseClasses",r=tr.indexOf(s);for(;r>0;){const i=tr[r-1];if(d.find(e,{mq:i,property:t.property})){n="classes";break}r--}return n}const sr=[];function Ca(e="",t="",s=[]){e=e.trim().replace(/ +/g,"");let n=d.filter(d.map(e.split(" "),fe.constructClassObject),u=>!d.isNull(u)),r=d.filter(d.map(t.split(" "),fe.constructClassObject),u=>!d.isNull(u));r=d.filter(r,u=>!d.includes(sr,u.property));const i=[],o=[];d.each(s,u=>{const h=fe.constructClassObject(u),g=d.find(n,d.pick(h,["dark","mq","mod","property"]));if(g&&(n=d.filter(n,A=>A.fullCls!==(g==null?void 0:g.fullCls))),i.push(h),h.mq==="xs"&&!h.dark&&h.mod===""&&(r=d.filter(r,A=>A.property!==h.property)),Pa(n,h)==="baseClasses"&&!d.includes(sr,h.property)){const A=d.find(r,d.pick(h,["property"]));g&&(r=d.filter(r,v=>v.fullCls!==(A==null?void 0:A.fullCls))),o.push({...h,fullCls:h.cls,mq:"xs"})}});const c=d.map(d.sortBy([...n,...i],u=>er[u.mq]),"fullCls").join(" ");return`${d.map(d.sortBy([...r,...o],u=>er[u.mq]),"fullCls").join(" ").trim()},${c.trim()}`.trim().replace(/ +/g,"")}const ls=y.atom([]);ls.debugLabel="selectedStylingBlocksAtom";const En=()=>y.useAtom(ls),ja=e=>{const t=e.replace(ce.STYLES_KEY,"").split(",");return{baseClasses:t[0],classes:t[1]}},Oa=y.atom(null,(e,t,{blockIds:s,newClasses:n,dispatch:r})=>{const i=d.filter(e(vn),c=>s.includes(e(c)._id)),o=d.first(e(ls));d.each(i,c=>{const l=e(c),u=d.get(l,o.prop,`${ce.STYLES_KEY},`),{baseClasses:h,classes:g}=ja(u);r({type:"update_props_realtime",payload:{ids:[l._id],props:{[o.prop]:`${ce.STYLES_KEY}${Ca(g,h,n)}`}}})})}),_a=()=>{const e=xe(),t=y.useSetAtom(Oa);return L.useCallback((s,n,r)=>{t({blockIds:s,newClasses:n,dispatch:e}),r&&setTimeout(()=>e({type:"create_snapshot"}),500)},[e,t])},ci=y.atom([]);ci.debugLabel="buildingBlocksAtom";const Ba=y.atom(e=>{const t=e(ci);return d.filter(t,s=>d.has(s,"blockId"))}),Ra=()=>{},ui=()=>{const e=Gr.useChaiBlocks(),t=y.useAtomValue(Ba),s=()=>{},n=L.useCallback(()=>Ra(),[]);return[e,t,s,n]},Ia=y.atom(!1),kn=()=>{const[e,t]=y.useAtom(Ia);return[e,t]},Da=y.atom(ce.BRANDING_OPTIONS_DEFAULTS),An=()=>{const[e,t]=y.useAtom(Da);return[d.isObject(e)?{...e,...ce.BRANDING_OPTIONS_DEFAULTS}:ce.BRANDING_OPTIONS_DEFAULTS,t]},Ma=y.atom(null),li=()=>({currentPage:y.useAtomValue(Ma)}),di=new Hr({});function La(e){let t=di.convert(e);return t=!t.type&&t.children&&t.children.length?t.children:d.isEmpty(t)?[]:[t],t}const Pn=(e,t)=>d.flatten(e.map(s=>{if(s=t?{...s,parent:t}:{...s},s.children){const n=[...s.children];return delete s.children,d.flatten([s,...Pn(n,s._id)])}return s}));function Cn(e,t=!1){for(let s=0;s<e.length;s++){const n=e[s];n.global&&!t?e[s]={type:"GlobalBlock",_parent:d.get(n,"parent",null),blockId:n.blockId,_id:n._id}:n.children&&n.children.length&&Cn(n.children)}}function fi(e){let t=[],s=d.filter(e,{type:"GlobalBlock"});return s.length>0&&(s=d.map(s,hi),d.each(s,n=>{t=[...t,...Na(n)]})),t}function Na(e){let t=[];const s=d.get(d.first(e),"parent",null);d.set(d.first(e),"parent",null);const n=[di.convert(pi(e))];Cn(n,!0);let r=Pn(n,e[0]._id);return r=d.set(r,"0.parent",s),t=[...t,r,...fi(r)],t}function hi(e){const t=d.find(sn,{_id:e._id});if(!t)return[];const s=[t],n=d.filter(sn,{_parent:e._id});return n.length?d.flatten([...s,...d.flatten(d.map(n,hi))]):d.flatten(s)}const pi=e=>JSON.parse(JSON.stringify(e));let sn=[];function Ta(e){sn=e;const t=La(pi(e));Cn(t);const s=Pn(t,null),n=fi(s),r={};return d.each(n,i=>d.set(r,d.first(i).blockId,i)),[s,r]}const jn=()=>{const[e]=An(),{currentPage:t}=li(),s=y.useAtomValue(be);return L.useCallback(()=>{const n=d.map(s,o=>d.omit(o,["expanded","order","title","siblings","tempClasses"])),[r=[],i=[]]=Ta(n);return{currentPage:t,blocks:r,globalBlocks:i}},[e,t,s])};ct("blockStylingActiveTab",1);y.atom([]);const mi=y.atom(!1);mi.debugLabel="readOnlyModeAtom";const gi=y.atom(!1);gi.debugLabel="inlineEditingActiveAtom";const yi=y.atom(!1);yi.debugLabel="advanceStylingOpenAtom";const vi=y.atom("online");vi.debugLabel="networkModeAtom";ct("currentUiLibrary","");const Ua=y.atom(!1);Ua.debugLabel="codeEditorOpenAtom";const bi=y.atom(!1);bi.debugLabel="editLayerNameAtom";const Fa=y.atom("");Fa.debugLabel="activeLanguageAtom";const qa=y.atom("");qa.debugLabel="primaryLanguageAtom";const xi=y.atom(null);xi.debugLabel="canvasIframeAtom";const wi=y.atom("layers");wi.debugLabel="activePanelAtom";const Si=y.atom(!1);Si.debugLabel="addBlockOffCanvasAtom";const Ei=y.atom("");Ei.debugLabel="showPredefinedBlockCategoryAtom";const Ds=y.atom({undoCount:0,redoCount:0});Ds.debugLabel="historyStatesAtom";const Ms=y.atom("SAVED");Ms.debugLabel="pageSyncStateAtom";const $a=()=>{const[e,t]=y.useAtom(Ms),s=ve.useBuilderProp("onSaveBlocks",async()=>{}),n=ve.useBuilderProp("onSyncStatusChange",()=>{}),r=jn(),i=y.useSetAtom(Ds),{undoCount:o,redoCount:c}=ds();return{savePage:Co.useThrottledCallback(async()=>{t("SAVING"),n("SAVING");const u=r();return await s({blocks:u.blocks,identifier:"pageData.id"}),setTimeout(()=>{i({undoCount:o,redoCount:c}),t("SAVED"),n("SAVED")},100),!0},[r,t,n,s],5e3),syncState:e,setSyncState:t}},ds=()=>{const e=y.useAtomValue(Is),[{undoCount:t,redoCount:s}]=y.useAtom(Ds),n=xe(),[r]=kn(),[,i]=ze(),[,o]=En(),[,c]=y.useAtom(Ms),l=ve.useBuilderProp("onSyncStatusChange",()=>{}),u=L.useCallback(()=>{n({type:"create_snapshot"})},[n]);return L.useEffect(()=>{t!==(e==null?void 0:e.past.length)||s!==(e==null?void 0:e.future.length)?(c("UNSAVED"),l("UNSAVED")):t===(e==null?void 0:e.past.length)&&s===(e==null?void 0:e.future.length)&&(c("SAVED"),l("SAVED"))},[e==null?void 0:e.past.length,e==null?void 0:e.future.length,t,s,l,c]),{undoCount:e==null?void 0:e.past.length,redoCount:e==null?void 0:e.future.length,undo:L.useCallback(()=>{r||(n(Qt.ActionCreators.undo()),setTimeout(()=>{o([]),i([])},200))},[n,r,c]),redo:L.useCallback(()=>{r||(n(Qt.ActionCreators.redo()),setTimeout(()=>{o([]),i([])},200))},[r,n]),clear:()=>{n(Qt.ActionCreators.clearHistory())},createSnapshot:u}},ki=()=>y.useAtom(ii),Ai=ct("canvasWidth",360),Pi=y.atom(e=>{const t=e(Ai);return fe.getBreakpointValue(t).toLowerCase()}),Va=()=>{const[e,t]=y.useAtom(Ai),s=y.useAtomValue(Pi),[n,r]=ki();return L.useEffect(()=>{n!=="xs"&&r(s)},[s,n,r]),[e,s,t]},Qa=ct("canvasZoom",100),Ka=()=>y.useAtom(Qa),Ci=y.atom([]),On=()=>{const[e,t]=y.useAtom(Ci),s=y.useSetAtom(_n),n=L.useCallback(r=>{t(r),s([])},[t,s]);return[e,n]},_n=y.atom([]),ji=()=>{const[e,t]=y.useAtom(_n),s=y.useSetAtom(Ci),n=L.useCallback(r=>{t(r),s([])},[t,s]);return[e,n]},Oi=ct("darkMode",!1),za=()=>{const[e,t]=y.useAtom(Oi);return[e,t]},Ha=y.atom(!1),Ga=()=>{const[e,t]=y.useAtom(Ha);return[e,t]},Bn=()=>{const e=xe(),t=y.useAtomValue(be),[,s]=ze();return L.useCallback((n,r=null)=>{const i=[];d.each(n,o=>{const l=la(t,o,r===o?null:r);i.push(d.get(l,"0._id","")),e({type:"add_duplicate_blocks",payload:l})}),s(i),e({type:"create_snapshot"})},[t,s,e])},Wa=y.atom([]),Ya=()=>{const[e,t]=y.useAtom(Wa),s=L.useCallback(n=>{t(r=>d.includes(r,n)?d.without(r,n):[...r,n])},[t]);return[e,t,s]},Ja=y.atom(""),_i=()=>y.useAtom(Ja),Za=()=>{const e=y.useAtomValue(be),t=xe(),s=jn(),[,,n]=ui();return L.useCallback(async(r,i)=>{const o=fe.generateUUID(16),c=d.map(e,l=>(l._id===r&&(l._globalBlockId=o,l._name=i),l));t({type:"set_page_blocks",payload:c}),n()},[e,t,s,n])},Xa=()=>({}),ec=()=>{const e=y.useAtomValue(be),t=xe();return L.useCallback((s,n)=>{const r=d.map(e,i=>(d.includes(s,d.get(i,"_id"))&&d.set(i,"_parent",n),i));t({type:"set_blocks",payload:r})},[e,t])},Bi=()=>{const e=y.useAtomValue(_n),[t,s]=On(),n=Bn(),r=ec();return{canPaste:L.useMemo(()=>t.length>0||e.length>0,[e,t]),pasteBlocks:L.useCallback(o=>{d.isEmpty(e)?r(t,o):n(e,o),s(()=>[])},[t,e,n,r,s])}},tc=y.atom(""),sc=()=>{const e=y.useAtomValue(tc),t=L.useCallback(()=>{},[]),s=L.useCallback(()=>{},[]),n=L.useCallback(()=>{},[]);return{currentProject:e,createProject:n,deleteProject:t,updateProject:s}},Ri=(e,t)=>{const s=[],n=d.filter(e,r=>d.includes(t,r._id)||d.includes(t,r._parent)?(s.push(r._id),!1):!0);return d.isEmpty(s)?n:Ri(n,s)},Ii=()=>{const e=xe(),t=y.useAtomValue(be),[s,n]=ze();return L.useCallback(r=>{var c;const i=((c=d.find(t,{_id:r[0]}))==null?void 0:c._parent)||null,o=Ri(t,r);e({type:"set_blocks",payload:o}),n(i?[i]:[])},[t,n,e,s])},nc=y.atom(null,(e,t,{blockIds:s,fullClasses:n,dispatch:r})=>{const i=d.first(e(ls)),o=d.filter(e(vn),c=>s.includes(e(c)._id));d.each(o,c=>{const l=e(c),u=n;let{classes:h,baseClasses:g}=Uo(d.get(l,i.prop,"styles:,"));d.each(u,A=>{const v=new RegExp(`(^| )${A.replace("[","\\[").replace("]","\\]")}($| )`,"g");h=h.replace(v," ").replace(/ +/g," ").trim();const _=d.first(A.split(":"));d.includes(["2xl","xl","lg","md","sm"],_)&&u.push(A.split(":").pop().trim())}),d.each(u,A=>{const v=new RegExp(`(^| )${A.replace("[","\\[").replace("]","\\]")}($| )`,"g");g=g.replace(v," ").replace(/ +/g," ").trim()}),r({type:"update_props_realtime",payload:{ids:[l._id],props:{[i.prop]:`${ce.STYLES_KEY}${g},${h}`}}})})}),rc=()=>{const e=xe(),t=y.useSetAtom(nc);return L.useCallback((s,n)=>{t({blockIds:s,fullClasses:n,dispatch:e}),setTimeout(()=>e({type:"create_snapshot"}))},[e,t])},Di=y.atom(e=>{const t=d.first(e(ls)),s=e(wn);if(!t||t.blockId!==d.get(s,"_id",null))return[];const r=d.get(s,t.prop,`${ce.STYLES_KEY},`).replace(ce.STYLES_KEY,"").split(",").join(" ");return d.filter(d.map(r.trim().split(" "),fe.constructClassObject),i=>!d.isNull(i))}),ic=()=>y.useAtomValue(Di),nr={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},oc=y.atom(e=>{const t=e(Pi),s=e(Sn),n=e(Oi),r=ac(t);let i=d.filter(e(Di),{mod:s});return d.startsWith(s,"_")||(i=d.filter(i,o=>r.includes(o.mq))),i=i.sort((o,c)=>nr[o.mq]-nr[c.mq]),n||(i=d.filter(i,{dark:!1})),i}),ac=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},cc=()=>y.useAtomValue(oc),uc=()=>y.useAtom(Sn),Mi=y.atom(null,(e,t,{blockIds:s,props:n,dispatch:r})=>{r({type:"update_props_realtime",payload:{ids:s,props:n}})}),lc=()=>{const{createSnapshot:e}=ds(),t=xe(),s=y.useSetAtom(Mi);return L.useCallback((n,r)=>{s({blockIds:n,props:r,dispatch:t}),e()},[e,t,s])},dc=()=>{const e=xe(),t=y.useSetAtom(Mi);return L.useCallback((s,n)=>{t({blockIds:s,props:n,dispatch:e})},[e,t])},Li={name:"",props:{},modalProps:{},backdropClose:!0},fc=y.atom(Li),hc=()=>{const[e,t]=y.useAtom(fc),s=L.useCallback((r,i={},o={})=>{t({name:r,props:i,modalProps:o})},[t]),n=L.useCallback((...r)=>{d.get(e,"props.onClose",()=>{})(...r),t(Li)},[t,e]);return{activeModal:e,openModal:s,closeModal:n}},pc=()=>y.useAtomValue(mi),mc=y.atom(""),gc=y.atom(null),yc=()=>y.useAtom(mc),vc=()=>y.useAtom(gc),bc=ct("selectedBreakpoints",["XS","MD","XL"]),xc=()=>{const[e,t]=y.useAtom(bc);return[e,t]},Ni=()=>{const e=y.useSetAtom(Ds),{clear:t}=ds(),[,s]=ze(),[,n]=_i(),[,r]=En();return()=>{s([]),r([]),n(""),t(),e({undoCount:0,redoCount:0})}},wc=y.atom({en:{}}),Sc=()=>{const[e,t]=y.useAtom(wc),s=L.useCallback((n,r,i)=>{d.set(e,`${n}.${r}`,i),t(e)},[e,t]);return[e,s]},Ec=(e,t)=>{const[s]=y.useAtom(ve.chaiBuilderPropsAtom);return d.get(s,e,t)},kc=y.atom([]),Ac=()=>{const[e,t]=L.useState(!1),[s,n]=y.useAtom(kc),r=ve.useBuilderProp("getUILibraryBlocks",()=>[]);return L.useEffect(()=>{(async()=>s.length>0||(t(!0),n(await r()),t(!1)))()},[]),{data:s,isLoading:e}},Pc=y.atom("en"),Cc=y.atom("en"),jc=y.atom(["en"]),Ti=()=>y.useAtom(Pc),Oc=()=>y.useAtom(Cc),_c=()=>y.useAtom(jc),Bc=(e,t)=>{const[s]=Ti(),n=`${e}${s?`-${s}`:""}`;return{content:d.get(t,n,d.get(t,e,"")),propKey:e}},Rc=()=>{const[e,t]=kn(),s=ve.useBuilderProp("previewComponent");return O.jsxRuntimeExports.jsxs("div",{className:Po.cn("fixed inset-0 z-[999] bg-background",e?"block":"hidden"),children:[O.jsxRuntimeExports.jsx(ve.Button,{size:"sm",className:"absolute right-0 top-0 m-4",onClick:()=>t(!1),children:"Close Preview"}),O.jsxRuntimeExports.jsx("div",{children:s?O.jsxRuntimeExports.jsx(L.Suspense,{fallback:O.jsxRuntimeExports.jsx(ve.Skeleton,{className:"h-96 w-full"}),children:L.createElement(s)}):null})]})},Ic=()=>{const[e,t]=ze(),[,s]=ji(),n=Ii(),r=Bn(),[,i]=On(),{pasteBlocks:o}=Bi(),{undo:c,redo:l}=ds();Re.useHotkeys("esc",()=>t([]),{},[t]),Re.useHotkeys("ctrl+c,command+c",()=>s(e),{},[e,s]),Re.useHotkeys("ctrl+d,command+d",()=>r(e),{preventDefault:!0},[e,r]),Re.useHotkeys("ctrl+x,command+x",()=>i(e),{},[e,i]),Re.useHotkeys("ctrl+v,command+v",()=>e.length===1?o(e[0]):null,{},[e,o]),Re.useHotkeys("ctrl+z,command+z",()=>c(),{},[c]),Re.useHotkeys("ctrl+y,command+y",()=>l(),{},[l]),Re.useHotkeys("del, backspace",u=>{u.preventDefault(),n(e)},{},[e,n])},Dc=(e,t)=>{const s=[];let n=d.find(e,{_id:t}),r=d.get(n,"_parent","");for(;d.isString(r)&&!d.isEmpty(r);)s.push(n==null?void 0:n._parent),n=d.find(e,{_id:r}),r=n==null?void 0:n._parent;return d.flatten(s)},Ui=y.atom([]),Mc=()=>{const[e]=ze(),t=y.useAtomValue(be),[,s]=y.useAtom(Ui);L.useEffect(()=>{let n=[];const r=d.first(e);d.isString(r)&&(n=[r,...Dc(t,r)]),s(n)},[e,t,s])},Lc=()=>y.useAtomValue(Ui),Nc=L.lazy(()=>Promise.resolve().then(()=>require("./SidePanels-ef33ed66.cjs"))),Tc=L.lazy(()=>Promise.resolve().then(()=>require("./Topbar-84eadc0e.cjs"))),Uc=L.lazy(()=>Promise.resolve().then(()=>require("./CanvasArea-86eef07f.cjs"))),Fc=L.lazy(()=>Promise.resolve().then(()=>require("./Settings-0c125f1b.cjs"))),qc=()=>{const[e]=aa(Ms),t=s=>{s.preventDefault()};return Ic(),Mc(),L.useEffect(()=>(e!=="SAVED"?window.onbeforeunload=()=>"":window.onbeforeunload=null,()=>{window.onbeforeunload=null}),[e]),O.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-background text-foreground",children:O.jsxRuntimeExports.jsxs(ve.TooltipProvider,{children:[O.jsxRuntimeExports.jsxs("div",{onContextMenu:t,className:"flex h-screen flex-col overflow-hidden bg-background text-foreground",children:[O.jsxRuntimeExports.jsx("div",{className:"h-14 w-screen shrink-0 border-b border-border",children:O.jsxRuntimeExports.jsx(L.Suspense,{children:O.jsxRuntimeExports.jsx(Tc,{})})}),O.jsxRuntimeExports.jsxs("main",{className:"flex h-full flex-row",children:[O.jsxRuntimeExports.jsx("div",{className:"flex h-full w-fit border-border",children:O.jsxRuntimeExports.jsx(L.Suspense,{children:O.jsxRuntimeExports.jsx(Nc,{})})}),O.jsxRuntimeExports.jsx("div",{className:"h-full flex-1 bg-slate-800/20",children:O.jsxRuntimeExports.jsx(L.Suspense,{children:O.jsxRuntimeExports.jsx(Uc,{})})}),O.jsxRuntimeExports.jsx("div",{className:"flex h-full w-[280px] min-w-[280px] border-l border-border",children:O.jsxRuntimeExports.jsx(L.Suspense,{children:O.jsxRuntimeExports.jsx(Fc,{})})})]})]}),O.jsxRuntimeExports.jsx(Rc,{})]})})},$c=y.getDefaultStore();y.atom({});function rr(e,t,s,n,r){for(t=t.split?t.split("."):t,n=0;n<t.length;n++)e=e?e[t[n]]:r;return e===r?s:e}var gs="undefined",ir="object",Fi="any",qi="*",it="__",Cs=typeof process<"u"?process:{};Cs.env&&Cs.env.NODE_ENV;var Se=typeof document<"u";Cs.versions!=null&&Cs.versions.node!=null;typeof Deno<"u"&&Deno.core;Se&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function $i(e,t){return t.charAt(0)[e]()+t.slice(1)}var Vc=$i.bind(null,"toUpperCase"),Qc=$i.bind(null,"toLowerCase");function Kc(e){return Vi(e)?Vc("null"):typeof e=="object"?Yc(e):Object.prototype.toString.call(e).slice(8,-1)}function js(e,t){t===void 0&&(t=!0);var s=Kc(e);return t?Qc(s):s}function fs(e,t){return typeof t===e}var je=fs.bind(null,"function"),ht=fs.bind(null,"string"),dt=fs.bind(null,"undefined"),zc=fs.bind(null,"boolean");fs.bind(null,"symbol");function Vi(e){return e===null}function Hc(e){return js(e)==="number"&&!isNaN(e)}function Gc(e){return js(e)==="array"}function de(e){if(!Wc(e))return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Wc(e){return e&&(typeof e=="object"||e!==null)}function Yc(e){return je(e.constructor)?e.constructor.name:null}function Jc(e){return e instanceof Error||ht(e.message)&&e.constructor&&Hc(e.constructor.stackTraceLimit)}function Qi(e,t){if(typeof t!="object"||Vi(t))return!1;if(t instanceof e)return!0;var s=js(new e(""));if(Jc(t))for(;t;){if(js(t)===s)return!0;t=Object.getPrototypeOf(t)}return!1}Qi.bind(null,TypeError);Qi.bind(null,SyntaxError);function Ls(e,t){var s=e instanceof Element||e instanceof HTMLDocument;return s&&t?Zc(e,t):s}function Zc(e,t){return t===void 0&&(t=""),e&&e.nodeName===t.toUpperCase()}function Ns(e){var t=[].slice.call(arguments,1);return function(){return e.apply(void 0,[].slice.call(arguments).concat(t))}}Ns(Ls,"form");Ns(Ls,"button");Ns(Ls,"input");Ns(Ls,"select");function or(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function Xc(){if(Se){var e=navigator,t=e.languages;return e.userLanguage||(t&&t.length?t[0]:e.language)}}function eu(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function tu(e){return function(t){for(var s,n=Object.create(null),r=/([^&=]+)=?([^&]*)/g;s=r.exec(t);){var i=or(s[1]),o=or(s[2]);i.substring(i.length-2)==="[]"?(n[i=i.substring(0,i.length-2)]||(n[i]=[])).push(o):n[i]=o===""||o}for(var c in n){var l=c.split("[");l.length>1&&(su(n,l.map(function(u){return u.replace(/[?[\]\\ ]/g,"")}),n[c]),delete n[c])}return n}(function(t){if(t){var s=t.match(/\?(.*)/);return s&&s[1]?s[1].split("#")[0]:""}return Se&&window.location.search.substring(1)}(e))}function su(e,t,s){for(var n=t.length-1,r=0;r<n;++r){var i=t[r];if(i==="__proto__"||i==="constructor")break;i in e||(e[i]={}),e=e[i]}e[t[n]]=s}function Ts(){for(var e="",t=0,s=4294967295*Math.random()|0;t++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],r=15&s;e+=n=="-"||n=="4"?n:(n=="x"?r:3&r|8).toString(16),s=t%8==0?4294967295*Math.random()|0:s>>4}return e}var Kt="global",It=it+"global"+it,Dt=typeof self===ir&&self.self===self&&self||typeof global===ir&&global.global===global&&global||void 0;function ot(e){return Dt[It][e]}function at(e,t){return Dt[It][e]=t}function Nt(e){delete Dt[It][e]}function Tt(e,t,s){var n;try{if(Rn(e)){var r=window[e];n=r[t].bind(r)}}catch{}return n||s}Dt[It]||(Dt[It]={});var ys={};function Rn(e){if(typeof ys[e]!==gs)return ys[e];try{var t=window[e];t.setItem(gs,gs),t.removeItem(gs)}catch{return ys[e]=!1}return ys[e]=!0}function V(){return V=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},V.apply(this,arguments)}var Le="function",Be="undefined",nu="@@redux/"+Math.random().toString(36),ar=function(){return typeof Symbol===Le&&Symbol.observable||"@@observable"}(),vs=" != "+Le;function Ki(e,t,s){var n;if(typeof t===Le&&typeof s===Be&&(s=t,t=void 0),typeof s!==Be){if(typeof s!==Le)throw new Error("enhancer"+vs);return s(Ki)(e,t)}if(typeof e!==Le)throw new Error("reducer"+vs);var r=e,i=t,o=[],c=o,l=!1;function u(){c===o&&(c=o.slice())}function h(){return i}function g(v){if(typeof v!==Le)throw new Error("Listener"+vs);var _=!0;return u(),c.push(v),function(){if(_){_=!1,u();var B=c.indexOf(v);c.splice(B,1)}}}function A(v){if(!de(v))throw new Error("Act != obj");if(typeof v.type===Be)throw new Error("ActType "+Be);if(l)throw new Error("Dispatch in reducer");try{l=!0,i=r(i,v)}finally{l=!1}for(var _=o=c,B=0;B<_.length;B++)(0,_[B])();return v}return A({type:"@@redux/INIT"}),(n={dispatch:A,subscribe:g,getState:h,replaceReducer:function(v){if(typeof v!==Le)throw new Error("next reducer"+vs);r=v,A({type:"@@redux/INIT"})}})[ar]=function(){var v,_=g;return(v={subscribe:function(B){if(typeof B!="object")throw new TypeError("Observer != obj");function b(){B.next&&B.next(h())}return b(),{unsubscribe:_(b)}}})[ar]=function(){return this},v},n}function ru(e,t){var s=t&&t.type;return"action "+(s&&s.toString()||"?")+"reducer "+e+" returns "+Be}function Mt(){var e=[].slice.call(arguments);return e.length===0?function(t){return t}:e.length===1?e[0]:e.reduce(function(t,s){return function(){return t(s.apply(void 0,[].slice.call(arguments)))}})}function iu(){var e=arguments;return function(t){return function(s,n,r){var i,o=t(s,n,r),c=o.dispatch,l={getState:o.getState,dispatch:function(u){return c(u)}};return i=[].slice.call(e).map(function(u){return u(l)}),V({},o,{dispatch:c=Mt.apply(void 0,i)(o.dispatch)})}}}var Ke=it+"anon_id",rt=it+"user_id",pt=it+"user_traits",De="userId",ft="anonymousId",Ss=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],nn=["name","EVENTS","config","loaded"],$=Ss.reduce(function(e,t){return e[t]=t,e},{registerPluginType:function(e){return"registerPlugin:"+e},pluginReadyType:function(e){return"ready:"+e}}),cr=/^utm_/,ur=/^an_prop_/,lr=/^an_trait_/;function ou(e){var t=e.storage.setItem;return function(s){return function(n){return function(r){if(r.type===$.bootstrap){var i=r.params,o=r.user,c=r.persistedUser,l=r.initialUser,u=c.userId===o.userId;c.anonymousId!==o.anonymousId&&t(Ke,o.anonymousId),u||t(rt,o.userId),l.traits&&t(pt,V({},u&&c.traits?c.traits:{},l.traits));var h=Object.keys(r.params);if(h.length){var g=i.an_uid,A=i.an_event,v=h.reduce(function(_,B){if(B.match(cr)||B.match(/^(d|g)clid/)){var b=B.replace(cr,"");_.campaign[b==="campaign"?"name":b]=i[B]}return B.match(ur)&&(_.props[B.replace(ur,"")]=i[B]),B.match(lr)&&(_.traits[B.replace(lr,"")]=i[B]),_},{campaign:{},props:{},traits:{}});s.dispatch(V({type:$.params,raw:i},v,g?{userId:g}:{})),g&&setTimeout(function(){return e.identify(g,v.traits)},0),A&&setTimeout(function(){return e.track(A,v.props)},0),Object.keys(v.campaign).length&&s.dispatch({type:$.campaign,campaign:v.campaign})}}return n(r)}}}}function au(e){return function(t,s){if(t===void 0&&(t={}),s===void 0&&(s={}),s.type===$.setItemEnd){if(s.key===Ke)return V({},t,{anonymousId:s.value});if(s.key===rt)return V({},t,{userId:s.value})}switch(s.type){case $.identify:return Object.assign({},t,{userId:s.userId,traits:V({},t.traits,s.traits)});case $.reset:return[rt,Ke,pt].forEach(function(n){e.removeItem(n)}),Object.assign({},t,{userId:null,anonymousId:null,traits:{}});default:return t}}}function dr(e){return{userId:e.getItem(rt),anonymousId:e.getItem(Ke),traits:e.getItem(pt)}}var rn=function(e){return it+"TEMP"+it+e};function cu(e){var t=e.storage,s=t.setItem,n=t.removeItem,r=t.getItem;return function(i){return function(o){return function(c){var l=c.userId,u=c.traits,h=c.options;if(c.type===$.reset&&([rt,pt,Ke].forEach(function(v){n(v)}),[De,ft,"traits"].forEach(function(v){Nt(rn(v))})),c.type===$.identify){r(Ke)||s(Ke,Ts());var g=r(rt),A=r(pt)||{};g&&g!==l&&i.dispatch({type:$.userIdChanged,old:{userId:g,traits:A},new:{userId:l,traits:u},options:h}),l&&s(rt,l),u&&s(pt,V({},A,u))}return o(c)}}}}var $t={};function fr(e,t){$t[e]&&je($t[e])&&($t[e](t),delete $t[e])}function zi(e,t,s){return new Promise(function(n,r){return t()?n(e):s<1?r(V({},e,{queue:!0})):new Promise(function(i){return setTimeout(i,10)}).then(function(i){return zi(e,t,s-10).then(n,r)})})}function Hi(e,t,s){var n=t(),r=e.getState(),i=r.plugins,o=r.queue,c=r.user;if(!r.context.offline&&o&&o.actions&&o.actions.length){var l=o.actions.reduce(function(h,g,A){return i[g.plugin].loaded?(h.process.push(g),h.processIndex.push(A)):(h.requeue.push(g),h.requeueIndex.push(A)),h},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(l.processIndex&&l.processIndex.length){l.processIndex.forEach(function(h){var g=o.actions[h],A=g.plugin,v=g.payload.type,_=n[A][v];if(_&&je(_)){var B=function(C,U){return C===void 0&&(C={}),U===void 0&&(U={}),[De,ft].reduce(function(M,E){return C.hasOwnProperty(E)&&U[E]&&U[E]!==C[E]&&(M[E]=U[E]),M},C)}(g.payload,c);_({payload:B,config:i[A].config,instance:s});var b=v+":"+A;e.dispatch(V({},B,{type:b,_:{called:b,from:"queueDrain"}}))}});var u=o.actions.filter(function(h,g){return!~l.processIndex.indexOf(g)});o.actions=u}}}var Hs=function(e){var t=e.data,s=e.action,n=e.instance,r=e.state,i=e.allPlugins,o=e.allMatches,c=e.store,l=e.EVENTS;try{var u=r.plugins,h=r.context,g=s.type,A=g.match(mt),v=t.exact.map(function(b){return b.pluginName});A&&(v=o.during.map(function(b){return b.pluginName}));var _=function(b,C){return function(U,M,E){var P=M.config,q=M.name,F=q+"."+U.type;E&&(F=E.event);var N=U.type.match(mt)?function(m,x,R,w,D){return function(j,S){var z=w?w.name:m,Q=S&&Wt(S)?S:R;if(w&&(!(Q=S&&Wt(S)?S:[m]).includes(m)||Q.length!==1))throw new Error("Method "+x+" can only abort "+m+" plugin. "+JSON.stringify(Q)+" input valid");return V({},D,{abort:{reason:j,plugins:Q,caller:x,_:z}})}}(q,F,C,E,U):function(m,x){return function(){throw new Error(m.type+" action not cancellable. Remove abort in "+x)}}(U,F);return{payload:uu(U),instance:b,config:P||{},abort:N}}}(n,v),B=t.exact.reduce(function(b,C){var U=C.pluginName,M=C.methodName,E=!1;return M.match(/^initialize/)||M.match(/^reset/)||(E=!u[U].loaded),h.offline&&M.match(/^(page|track|identify)/)&&(E=!0),b[""+U]=E,b},{});return Promise.resolve(t.exact.reduce(function(b,C,U){try{var M=C.pluginName;return Promise.resolve(b).then(function(E){function P(){return Promise.resolve(E)}var q=function(){if(t.namespaced&&t.namespaced[M])return Promise.resolve(t.namespaced[M].reduce(function(F,N,m){try{return Promise.resolve(F).then(function(x){return N.method&&je(N.method)?(function(j,S){var z=br(j);if(z&&z.name===S){var Q=br(z.method);throw new Error([S+" plugin is calling method "+j,"Plugins cant call self","Use "+z.method+" "+(Q?"or "+Q.method:"")+" in "+S+" plugin insteadof "+j].join(`
|
|
2
|
-
`))}}(N.methodName,N.pluginName),Promise.resolve(N.method({payload:x,instance:n,abort:(R=x,w=M,D=N.pluginName,function(j,S){return V({},R,{abort:{reason:j,plugins:S||[w],caller:g,from:D||w}})}),config:mr(N.pluginName,u,i),plugins:u})).then(function(j){var S=de(j)?j:{};return Promise.resolve(V({},x,S))})):x;var R,w,D})}catch(x){return Promise.reject(x)}},Promise.resolve(s))).then(function(F){E[M]=F});E[M]=s}();return q&&q.then?q.then(P):P()})}catch(E){return Promise.reject(E)}},Promise.resolve({}))).then(function(b){return Promise.resolve(t.exact.reduce(function(C,U,M){try{var E=t.exact.length===M+1,P=U.pluginName,q=i[P];return Promise.resolve(C).then(function(F){var N=b[P]?b[P]:{};if(A&&(N=F),Ws(N,P))return Gs({data:N,method:g,instance:n,pluginName:P,store:c}),Promise.resolve(F);if(Ws(F,P))return E&&Gs({data:F,method:g,instance:n,store:c}),Promise.resolve(F);if(B.hasOwnProperty(P)&&B[P]===!0)return c.dispatch({type:"queue",plugin:P,payload:N,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(F);var m=_(b[P],i[P]);return Promise.resolve(q[g]({abort:m.abort,payload:N,instance:n,config:mr(P,u,i),plugins:u})).then(function(x){var R=de(x)?x:{},w=V({},F,R),D=b[P];if(Ws(D,P))Gs({data:D,method:g,instance:n,pluginName:P,store:c});else{var j=g+":"+P;(j.match(/:/g)||[]).length<2&&!g.match(hr)&&!g.match(pr)&&n.dispatch(V({},A?w:N,{type:j,_:{called:j,from:"submethod"}}))}return Promise.resolve(w)})})}catch(F){return Promise.reject(F)}},Promise.resolve(s))).then(function(C){if(!(g.match(mt)||g.match(/^registerPlugin/)||g.match(pr)||g.match(hr)||g.match(/^params/)||g.match(/^userIdChanged/))){if(l.plugins.includes(g),C._&&C._.originalAction===g)return C;var U=V({},C,{_:{originalAction:C.type,called:C.type,from:"engineEnd"}});Gi(C,t.exact.length)&&!g.match(/End$/)&&(U=V({},U,{type:C.type+"Aborted"})),c.dispatch(U)}return C})})}catch(b){return Promise.reject(b)}},mt=/Start$/,hr=/^bootstrap/,pr=/^ready/;function Gs(e){var t=e.pluginName,s=e.method+"Aborted"+(t?":"+t:"");e.store.dispatch(V({},e.data,{type:s,_:{called:s,from:"abort"}}))}function mr(e,t,s){var n=t[e]||s[e];return n&&n.config?n.config:{}}function gr(e,t){return t.reduce(function(s,n){return n[e]?s.concat({methodName:e,pluginName:n.name,method:n[e]}):s},[])}function yr(e,t){var s=e.replace(mt,""),n=t?":"+t:"";return[""+e+n,""+s+n,s+"End"+n]}function Ws(e,t){var s=e.abort;return!!s&&(s===!0||vr(s,t)||s&&vr(s.plugins,t))}function Gi(e,t){var s=e.abort;if(!s)return!1;if(s===!0||ht(s))return!0;var n=s.plugins;return Wt(s)&&s.length===t||Wt(n)&&n.length===t}function Wt(e){return Array.isArray(e)}function vr(e,t){return!(!e||!Wt(e))&&e.includes(t)}function br(e){var t=e.match(/(.*):(.*)/);return!!t&&{method:t[1],name:t[2]}}function uu(e){return Object.keys(e).reduce(function(t,s){return s==="type"||(t[s]=de(e[s])?Object.assign({},e[s]):e[s]),t},{})}function lu(e,t,s){var n={};return function(r){return function(i){return function(o){try{var c,l=function(E){return c?E:i(g)},u=o.type,h=o.plugins,g=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 fr(o.meta.rid,{payload:o})},0),u===$.initializeEnd){var A=t(),v=Object.keys(A),_=v.filter(function(E){return h.includes(E)}).map(function(E){return A[E]}),B=[],b=[],C=o.disabled,U=_.map(function(E){var P=E.loaded,q=E.name,F=E.config;return zi(E,function(){return P({config:F})},1e4).then(function(N){return n[q]||(r.dispatch({type:$.pluginReadyType(q),name:q,events:Object.keys(E).filter(function(m){return!nn.includes(m)})}),n[q]=!0),B=B.concat(q),E}).catch(function(N){if(N instanceof Error)throw new Error(N);return b=b.concat(N.name),N})});Promise.all(U).then(function(E){var P={plugins:B,failed:b,disabled:C};setTimeout(function(){v.length===U.length+C.length&&r.dispatch(V({},{type:$.ready},P))},0)})}var M=function(){if(u!==$.bootstrap)return/^ready:([^:]*)$/.test(u)&&setTimeout(function(){return Hi(r,t,e)},0),Promise.resolve(function(E,P,q,F,N){try{var m=je(P)?P():P,x=E.type,R=x.replace(mt,"");if(E._&&E._.called)return Promise.resolve(E);var w=q.getState(),D=(z=m,(Q=w.plugins)===void 0&&(Q={}),(W=E.options)===void 0&&(W={}),Object.keys(z).filter(function(f){var p=W.plugins||{};return zc(p[f])?p[f]:p.all!==!1&&(!Q[f]||Q[f].enabled!==!1)}).map(function(f){return z[f]}));x===$.initializeStart&&E.fromEnable&&(D=Object.keys(w.plugins).filter(function(f){var p=w.plugins[f];return E.plugins.includes(f)&&!p.initialized}).map(function(f){return m[f]}));var j=D.map(function(f){return f.name}),S=function(f,p,T){var H=yr(f).map(function(G){return gr(G,p)});return p.reduce(function(G,Y){var ie=Y.name,Z=yr(f,ie).map(function(Ft){return gr(Ft,p)}),ee=Z[0],J=Z[1],Ee=Z[2];return ee.length&&(G.beforeNS[ie]=ee),J.length&&(G.duringNS[ie]=J),Ee.length&&(G.afterNS[ie]=Ee),G},{before:H[0],beforeNS:{},during:H[1],duringNS:{},after:H[2],afterNS:{}})}(x,D);return Promise.resolve(Hs({action:E,data:{exact:S.before,namespaced:S.beforeNS},state:w,allPlugins:m,allMatches:S,instance:q,store:F,EVENTS:N})).then(function(f){function p(){var G=function(){if(x.match(mt))return Promise.resolve(Hs({action:V({},T,{type:R+"End"}),data:{exact:S.after,namespaced:S.afterNS},state:w,allPlugins:m,allMatches:S,instance:q,store:F,EVENTS:N})).then(function(Y){Y.meta&&Y.meta.hasCallback&&fr(Y.meta.rid,{payload:Y})})}();return G&&G.then?G.then(function(){return f}):f}if(Gi(f,j.length))return f;var T,H=function(){if(x!==R)return Promise.resolve(Hs({action:V({},f,{type:R}),data:{exact:S.during,namespaced:S.duringNS},state:w,allPlugins:m,allMatches:S,instance:q,store:F,EVENTS:N})).then(function(G){T=G});T=f}();return H&&H.then?H.then(p):p()})}catch(f){return Promise.reject(f)}var z,Q,W}(o,t,e,r,s)).then(function(E){return c=1,i(E)})}();return Promise.resolve(M&&M.then?M.then(l):l(M))}catch(E){return Promise.reject(E)}}}}}function du(e){return function(t){return function(s){return function(n){var r=n.type,i=n.key,o=n.value,c=n.options;if(r===$.setItem||r===$.removeItem){if(n.abort)return s(n);r===$.setItem?e.setItem(i,o,c):e.removeItem(i,c)}return s(n)}}}}var fu=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(t,s){e[s]=e[s].concat(t)},this.removeMiddleware=function(t,s){var n=e[s].findIndex(function(r){return r===t});n!==-1&&(e[s]=[].concat(e[s].slice(0,n),e[s].slice(n+1)))},this.dynamicMiddlewares=function(t){return function(s){return function(n){return function(r){var i={getState:s.getState,dispatch:function(c){return s.dispatch(c)}},o=e[t].map(function(c){return c(i)});return Mt.apply(void 0,o)(n)(r)}}}}};function hu(e){return function(t,s){t===void 0&&(t={});var n={};if(s.type==="initialize:aborted")return t;if(/^registerPlugin:([^:]*)$/.test(s.type)){var r=xr(s.type,"registerPlugin"),i=e()[r];if(!i||!r)return t;var o=s.enabled,c=i.config;return n[r]={enabled:o,initialized:!!o&&!i.initialize,loaded:!!o&&!!i.loaded({config:c}),config:c},V({},t,n)}if(/^initialize:([^:]*)$/.test(s.type)){var l=xr(s.type,$.initialize),u=e()[l];return u&&l?(n[l]=V({},t[l],{initialized:!0,loaded:!!u.loaded({config:u.config})}),V({},t,n)):t}if(/^ready:([^:]*)$/.test(s.type))return n[s.name]=V({},t[s.name],{loaded:!0}),V({},t,n);switch(s.type){case $.disablePlugin:return V({},t,wr(s.plugins,!1,t));case $.enablePlugin:return V({},t,wr(s.plugins,!0,t));default:return t}}}function xr(e,t){return e.substring(t.length+1,e.length)}function wr(e,t,s){return e.reduce(function(n,r){return n[r]=V({},s[r],{enabled:t}),n},s)}function Wi(e){try{return JSON.parse(JSON.stringify(e))}catch{}return e}var pu={last:{},history:[]};function mu(e,t){e===void 0&&(e=pu);var s=t.options,n=t.meta;if(t.type===$.track){var r=Wi(V({event:t.event,properties:t.properties},Object.keys(s).length&&{options:s},{meta:n}));return V({},e,{last:r,history:e.history.concat(r)})}return e}var gu={actions:[]};function yu(e,t){e===void 0&&(e=gu);var s=t.payload;switch(t.type){case"queue":var n;return n=s&&s.type&&s.type===$.identify?[t].concat(e.actions):e.actions.concat(t),V({},e,{actions:n});case"dequeue":return[];default:return e}}var Yi=/#.*$/;function vu(e){var t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(Yi,""):"")}var Ji,Zi,Xi,eo,bu=function(e){if(e===void 0&&(e={}),!Se)return e;var t=document,s=t.title,n=t.referrer,r=window,i=r.location,o=r.innerWidth,c=r.innerHeight,l=i.hash,u=i.search,h=function(A){var v=function(){if(Se){for(var _,B=document.getElementsByTagName("link"),b=0;_=B[b];b++)if(_.getAttribute("rel")==="canonical")return _.getAttribute("href")}}();return v?v.match(/\?/)?v:v+A:window.location.href.replace(Yi,"")}(u),g={title:s,url:h,path:vu(h),hash:l,search:u,width:o,height:c};return n&&n!==""&&(g.referrer=n),V({},g,e)},xu={last:{},history:[]};function wu(e,t){e===void 0&&(e=xu);var s=t.options;if(t.type===$.page){var n=Wi(V({properties:t.properties,meta:t.meta},Object.keys(s).length&&{options:s}));return V({},e,{last:n,history:e.history.concat(n)})}return e}Ji=function(){if(!Se)return!1;var e=navigator.appVersion;return~e.indexOf("Win")?"Windows":~e.indexOf("Mac")?"MacOS":~e.indexOf("X11")?"UNIX":~e.indexOf("Linux")?"Linux":"Unknown OS"}(),Zi=Se?document.referrer:null,Xi=Xc(),eo=eu();var Sr={initialized:!1,sessionId:Ts(),app:null,version:null,debug:!1,offline:!!Se&&!navigator.onLine,os:{name:Ji},userAgent:Se?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.5"},timezone:eo,locale:Xi,campaign:{},referrer:Zi};function Su(e,t){e===void 0&&(e=Sr);var s=e.initialized,n=t.campaign;switch(t.type){case $.campaign:return V({},e,{campaign:n});case $.offline:return V({},e,{offline:!0});case $.online:return V({},e,{offline:!1});default:return s?e:V({},Sr,e,{initialized:!0})}}var Eu=["plugins","reducers","storage"];function ku(e,t,s){if(Se){var n=window[(s?"add":"remove")+"EventListener"];e.split(" ").forEach(function(r){n(r,t)})}}function Au(e){var t=ku.bind(null,"online offline",function(s){return Promise.resolve(!navigator.onLine).then(e)});return t(!0),function(s){return t(!1)}}function to(){return at("analytics",[]),function(e){return function(t,s,n){var r=e(t,s,n),i=r.dispatch;return Object.assign(r,{dispatch:function(o){return Dt[It].analytics.push(o.action||o),i(o)}})}}}function Er(e){return function(){return Mt(Mt.apply(null,arguments),to())}}function Ys(e){return e?Gc(e)?e:[e]:[]}function kr(e,t,s){e===void 0&&(e={});var n,r,i=Ts();return t&&($t[i]=(n=t,r=function(o){for(var c,l=o||Array.prototype.slice.call(arguments),u=0;u<l.length;u++)if(je(l[u])){c=l[u];break}return c}(s),function(o){r&&r(o),n(o)})),V({},e,{rid:i,ts:new Date().getTime()},t?{hasCallback:!0}:{})}function Pu(e){e===void 0&&(e={});var t=e.reducers||{},s=e.initialUser||{},n=(e.plugins||[]).reduce(function(f,p){if(je(p))return f.middlewares=f.middlewares.concat(p),f;if(p.NAMESPACE&&(p.name=p.NAMESPACE),!p.name)throw new Error("https://lytics.dev/errors/1");p.config||(p.config={});var T=p.EVENTS?Object.keys(p.EVENTS).map(function(Y){return p.EVENTS[Y]}):[];f.pluginEnabled[p.name]=!(p.enabled===!1||p.config.enabled===!1),delete p.enabled,p.methods&&(f.methods[p.name]=Object.keys(p.methods).reduce(function(Y,ie){var Z;return Y[ie]=(Z=p.methods[ie],function(){for(var ee=Array.prototype.slice.call(arguments),J=new Array(Z.length),Ee=0;Ee<ee.length;Ee++)J[Ee]=ee[Ee];return J[J.length]=P,Z.apply({instance:P},J)}),Y},{}),delete p.methods);var H=Object.keys(p).concat(T),G=new Set(f.events.concat(H));if(f.events=Array.from(G),f.pluginsArray=f.pluginsArray.concat(p),f.plugins[p.name])throw new Error(p.name+"AlreadyLoaded");return f.plugins[p.name]=p,f.plugins[p.name].loaded||(f.plugins[p.name].loaded=function(){return!0}),f},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),r=e.storage?e.storage:{getItem:ot,setItem:at,removeItem:Nt},i=function(f){return function(p,T,H){return T.getState("user")[p]||(H&&de(H)&&H[p]?H[p]:dr(f)[p]||ot(rn(p))||null)}}(r),o=n.plugins,c=n.events.filter(function(f){return!nn.includes(f)}).sort(),l=new Set(c.concat(Ss).filter(function(f){return!nn.includes(f)})),u=Array.from(l).sort(),h=function(){return o},g=new fu,A=g.addMiddleware,v=g.removeMiddleware,_=g.dynamicMiddlewares,B=function(){throw new Error("Abort disabled inListener")},b=tu(),C=dr(r),U=V({},C,s,b.an_uid?{userId:b.an_uid}:{},b.an_aid?{anonymousId:b.an_aid}:{});U.anonymousId||(U.anonymousId=Ts());var M=V({enable:function(f,p){return new Promise(function(T){S.dispatch({type:$.enablePlugin,plugins:Ys(f),_:{originalAction:$.enablePlugin}},T,[p])})},disable:function(f,p){return new Promise(function(T){S.dispatch({type:$.disablePlugin,plugins:Ys(f),_:{originalAction:$.disablePlugin}},T,[p])})}},n.methods),E=!1,P={identify:function(f,p,T,H){try{var G=ht(f)?f:null,Y=de(f)?f:p,ie=T||{},Z=P.user();at(rn(De),G);var ee=G||Y.userId||i(De,P,Y);return Promise.resolve(new Promise(function(J){S.dispatch(V({type:$.identifyStart,userId:ee,traits:Y||{},options:ie,anonymousId:Z.anonymousId},Z.id&&Z.id!==G&&{previousId:Z.id}),J,[p,T,H])}))}catch(J){return Promise.reject(J)}},track:function(f,p,T,H){try{var G=de(f)?f.event:f;if(!G||!ht(G))throw new Error("EventMissing");var Y=de(f)?f:p||{},ie=de(T)?T:{};return Promise.resolve(new Promise(function(Z){S.dispatch({type:$.trackStart,event:G,properties:Y,options:ie,userId:i(De,P,p),anonymousId:i(ft,P,p)},Z,[p,T,H])}))}catch(Z){return Promise.reject(Z)}},page:function(f,p,T){try{var H=de(f)?f:{},G=de(p)?p:{};return Promise.resolve(new Promise(function(Y){S.dispatch({type:$.pageStart,properties:bu(H),options:G,userId:i(De,P,H),anonymousId:i(ft,P,H)},Y,[f,p,T])}))}catch(Y){return Promise.reject(Y)}},user:function(f){if(f===De||f==="id")return i(De,P);if(f===ft||f==="anonId")return i(ft,P);var p=P.getState("user");return f?rr(p,f):p},reset:function(f){return new Promise(function(p){S.dispatch({type:$.resetStart},p,f)})},ready:function(f){return E&&f({plugins:M,instance:P}),P.on($.ready,function(p){f(p),E=!0})},on:function(f,p){if(!f||!je(p))return!1;if(f===$.bootstrap)throw new Error(".on disabled for "+f);var T=/Start$|Start:/;if(f==="*"){var H=function(Z){return function(ee){return function(J){return J.type.match(T)&&p({payload:J,instance:P,plugins:o}),ee(J)}}},G=function(Z){return function(ee){return function(J){return J.type.match(T)||p({payload:J,instance:P,plugins:o}),ee(J)}}};return A(H,bs),A(G,xs),function(){v(H,bs),v(G,xs)}}var Y=f.match(T)?bs:xs,ie=function(Z){return function(ee){return function(J){return J.type===f&&p({payload:J,instance:P,plugins:o,abort:B}),ee(J)}}};return A(ie,Y),function(){return v(ie,Y)}},once:function(f,p){if(!f||!je(p))return!1;if(f===$.bootstrap)throw new Error(".once disabled for "+f);var T=P.on(f,function(H){p({payload:H.payload,instance:P,plugins:o,abort:B}),T()});return T},getState:function(f){var p=S.getState();return f?rr(p,f):Object.assign({},p)},dispatch:function(f){var p=ht(f)?{type:f}:f;if(Ss.includes(p.type))throw new Error("reserved action "+p.type);var T=V({},p,{_:V({originalAction:p.type},f._||{})});S.dispatch(T)},enablePlugin:M.enable,disablePlugin:M.disable,plugins:M,storage:{getItem:r.getItem,setItem:function(f,p,T){S.dispatch({type:$.setItemStart,key:f,value:p,options:T})},removeItem:function(f,p){S.dispatch({type:$.removeItemStart,key:f,options:p})}},setAnonymousId:function(f,p){P.storage.setItem(Ke,f,p)},events:{core:Ss,plugins:c}},q=n.middlewares.concat([function(f){return function(p){return function(T){return T.meta||(T.meta=kr()),p(T)}}},_(bs),lu(P,h,{all:u,plugins:c}),du(r),ou(P),cu(P),_(xs)]),F={context:Su,user:au(r),page:wu,track:mu,plugins:hu(h),queue:yu},N=Mt,m=Mt;if(Se&&e.debug){var x=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;x&&(N=x({trace:!0,traceLimit:25})),m=function(){return arguments.length===0?to():de(typeof arguments[0])?Er():Er().apply(null,arguments)}}var R,w=function(f){return Object.keys(f).reduce(function(p,T){return Eu.includes(T)||(p[T]=f[T]),p},{})}(e),D=n.pluginsArray.reduce(function(f,p){var T=p.name,H=p.config,G=p.loaded,Y=n.pluginEnabled[T];return f[T]={enabled:Y,initialized:!!Y&&!p.initialize,loaded:!!G({config:H}),config:H},f},{}),j={context:w,user:U,plugins:D},S=Ki(function(f){for(var p=Object.keys(f),T={},H=0;H<p.length;H++){var G=p[H];typeof f[G]===Le&&(T[G]=f[G])}var Y,ie=Object.keys(T);try{(function(Z){Object.keys(Z).forEach(function(ee){var J=Z[ee];if(typeof J(void 0,{type:"@@redux/INIT"})===Be||typeof J(void 0,{type:nu})===Be)throw new Error("reducer "+ee+" "+Be)})})(T)}catch(Z){Y=Z}return function(Z,ee){if(Z===void 0&&(Z={}),Y)throw Y;for(var J=!1,Ee={},Ft=0;Ft<ie.length;Ft++){var hs=ie[Ft],$n=Z[hs],Qs=(0,T[hs])($n,ee);if(typeof Qs===Be){var wo=ru(hs,ee);throw new Error(wo)}Ee[hs]=Qs,J=J||Qs!==$n}return J?Ee:Z}}(V({},F,t)),j,m(N(iu.apply(void 0,q))));S.dispatch=(R=S.dispatch,function(f,p,T){var H=V({},f,{meta:kr(f.meta,p,Ys(T))});return R.apply(null,[H])});var z=Object.keys(o);S.dispatch({type:$.bootstrap,plugins:z,config:w,params:b,user:U,initialUser:s,persistedUser:C});var Q=z.filter(function(f){return n.pluginEnabled[f]}),W=z.filter(function(f){return!n.pluginEnabled[f]});return S.dispatch({type:$.registerPlugins,plugins:z,enabled:n.pluginEnabled}),n.pluginsArray.map(function(f,p){var T=f.bootstrap,H=f.config,G=f.name;T&&je(T)&&T({instance:P,config:H,payload:f}),S.dispatch({type:$.registerPluginType(G),name:G,enabled:n.pluginEnabled[G],plugin:f}),n.pluginsArray.length===p+1&&S.dispatch({type:$.initializeStart,plugins:Q,disabled:W})}),Au(function(f){S.dispatch({type:f?$.offline:$.online})}),function(f,p,T){setInterval(function(){return Hi(f,p,T)},3e3)}(S,h,P),P}var bs="before",xs="after",zt="cookie",Ge=ro(),so=Us,Cu=Us;function no(e){return Ge?Us(e,"",-1):Nt(e)}function ro(){if(Ge!==void 0)return Ge;var e="cookiecookie";try{Us(e,e),Ge=document.cookie.indexOf(e)!==-1,no(e)}catch{Ge=!1}return Ge}function Us(e,t,s,n,r,i){if(typeof window<"u"){var o=arguments.length>1;return Ge===!1&&(o?at(e,t):ot(e)),o?document.cookie=e+"="+encodeURIComponent(t)+(s?"; expires="+new Date(+new Date+1e3*s).toUTCString()+(n?"; path="+n:"")+(r?"; domain="+r:"")+(i?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}}var Ht="localStorage",ju=Rn.bind(null,"localStorage");Tt("localStorage","getItem",ot);Tt("localStorage","setItem",at);Tt("localStorage","removeItem",Nt);var Gt="sessionStorage",Ou=Rn.bind(null,"sessionStorage");Tt("sessionStorage","getItem",ot);Tt("sessionStorage","setItem",at);Tt("sessionStorage","removeItem",Nt);function gt(e){var t=e;try{if((t=JSON.parse(e))==="true")return!0;if(t==="false")return!1;if(de(t))return t;parseFloat(t)===t&&(t=parseFloat(t))}catch{}if(t!==null&&t!=="")return t}var _u=ju(),Bu=Ou(),Ru=ro();function io(e,t){if(e){var s=In(t),n=!Nn(s),r=Dn(s)?gt(localStorage.getItem(e)):void 0;if(n&&!dt(r))return r;var i=Mn(s)?gt(so(e)):void 0;if(n&&i)return i;var o=Ln(s)?gt(sessionStorage.getItem(e)):void 0;if(n&&o)return o;var c=ot(e);return n?c:{localStorage:r,sessionStorage:o,cookie:i,global:c}}}function Iu(e,t,s){if(e&&!dt(t)){var n={},r=In(s),i=JSON.stringify(t),o=!Nn(r);return Dn(r)&&(n[Ht]=ws(Ht,t,gt(localStorage.getItem(e))),localStorage.setItem(e,i),o)?n[Ht]:Mn(r)&&(n[zt]=ws(zt,t,gt(so(e))),Cu(e,i),o)?n[zt]:Ln(r)&&(n[Gt]=ws(Gt,t,gt(sessionStorage.getItem(e))),sessionStorage.setItem(e,i),o)?n[Gt]:(n[Kt]=ws(Kt,t,ot(e)),at(e,t),o?n[Kt]:n)}}function Du(e,t){if(e){var s=In(t),n=io(e,qi),r={};return!dt(n.localStorage)&&Dn(s)&&(localStorage.removeItem(e),r[Ht]=n.localStorage),!dt(n.cookie)&&Mn(s)&&(no(e),r[zt]=n.cookie),!dt(n.sessionStorage)&&Ln(s)&&(sessionStorage.removeItem(e),r[Gt]=n.sessionStorage),!dt(n.global)&&Fs(s,Kt)&&(Nt(e),r[Kt]=n.global),r}}function In(e){return e?ht(e)?e:e.storage:Fi}function Dn(e){return _u&&Fs(e,Ht)}function Mn(e){return Ru&&Fs(e,zt)}function Ln(e){return Bu&&Fs(e,Gt)}function Nn(e){return e===qi||e==="all"}function Fs(e,t){return e===Fi||e===t||Nn(e)}function ws(e,t,s){return{location:e,current:t,previous:s}}var Mu={setItem:Iu,getItem:io,removeItem:Du};function Lu(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function Ar(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),s.push.apply(s,n)}return s}function Pr(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?Ar(Object(s),!0).forEach(function(n){Lu(e,n,s[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Ar(Object(s)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(s,n))})}return e}function Nu(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t={storage:Mu};return Pu(Pr(Pr({},t),e))}const Tu="@chaibuilder/sdk",Uu="0.1.6",Fu="module",qu=["dist"],$u="dist/core.js",Vu=!1,Qu={".":{import:"./dist/core.js",require:"./dist/core.cjs",types:"./dist/core.d.ts"},"./render":{import:"./dist/render.js",require:"./dist/render.cjs",types:"./dist/render.d.ts"},"./ui":{import:"./dist/ui.js",require:"./dist/ui.cjs",types:"./dist/ui.d.ts"},"./lib":{import:"./dist/lib.js",require:"./dist/lib.cjs",types:"./dist/lib.d.ts"},"./server":{import:"./dist/server.js",require:"./dist/server.cjs",types:"./dist/server.d.ts"},"./styles":{import:"./dist/style.css",require:"./dist/style.css"}},Ku={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"},zu={"@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"},Hu={"@commitlint/cli":"17.7.1","@commitlint/config-conventional":"17.7.0","@faker-js/faker":"^8.3.1","@nozbe/watermelondb":"^0.27.1","@playwright/test":"^1.39.0","@tanstack/eslint-plugin-query":"^5.8.4","@types/better-sqlite3":"^7.6.7","@types/jest":"^29.5.7","@types/lodash":"^4.14.200","@types/node":"^20.8.10","@types/react":"^18.2.15","@types/react-dom":"^18.2.7","@typescript-eslint/eslint-plugin":"^6.0.0","@typescript-eslint/parser":"^6.0.0","@vitejs/plugin-react-swc":"^3.3.2",autoprefixer:"^10.4.16","better-docs":"^2.7.2","better-sqlite3":"^9.1.1","drizzle-kit":"^0.20.4","drizzle-orm":"^0.29.0",eslint:"^8.45.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.4.3",jest:"^29.7.0","jest-environment-jsdom":"^29.7.0",jsdoc:"^4.0.2",msw:"^2.0.8",postcss:"^8.4.31",prettier:"^3.0.3","prettier-plugin-tailwindcss":"^0.5.6","prop-types":"^15.8.1","react-router-dom":"^6.19.0",tailwindcss:"^3.3.5","ts-jest":"^29.1.1",typescript:"^5.0.2",vite:"^4.4.5","vite-plugin-dts":"^3.6.3"},Gu={workerDirectory:"public"},Wu={name:Tu,private:!1,version:Uu,type:Fu,files:qu,main:$u,sideEffects:Vu,exports:Qu,scripts:Ku,dependencies:zu,devDependencies:Hu,msw:Gu},Cr="https://api.chaibuilder.com",jr=()=>typeof window>"u"?!1:window.location.href.includes("localhost");function Yu(){return{name:"chaibuilder-analytics",config:{},initialize:()=>{if(typeof window>"u")return!1;window.chaibuilderAnalyticsLoaded=!0},page:e=>{if(typeof window>"u")return!1;if(jr())return;const{payload:t}=e;fetch(`${Cr}/v1/log`,{method:"post",body:JSON.stringify(t)}).then(s=>s.json())},track:({payload:e})=>{if(typeof window>"u")return!1;jr()||fetch(`${Cr}/v1/log`,{method:"post",body:JSON.stringify(e)})},loaded:()=>typeof window>"u"?!0:!!window.chaibuilderAnalyticsLoaded}}const Ju=Nu({app:"chaibuilder",version:Wu.version,plugins:[Yu()]});({}).NODE_ENV==="development"&&console.log("Chai Builder:",No);const Zu=e=>O.jsxRuntimeExports.jsx(O.jsxRuntimeExports.Fragment,{children:e.children}),Xu=e=>{const{dndOptions:t={backend:Vn.MultiBackend}}=e,[s]=si(),[,n]=An(),r=Ni();return L.useEffect(()=>{$c.set(ve.chaiBuilderPropsAtom,d.omit(e,["blocks","globalBlocks","brandingOptions"]))},[e]),L.useEffect(()=>{s(Gr.syncBlocksWithDefaults(e.blocks||[])),r()},[e.blocks]),L.useEffect(()=>{n(e.brandingOptions)},[e.brandingOptions]),L.useEffect(()=>{Ju.page()},[]),O.jsxRuntimeExports.jsx(Ao.DndProvider,{...t,options:Vn.getBackendOptions(),children:O.jsxRuntimeExports.jsx(Zu,{children:O.jsxRuntimeExports.jsx(qc,{})})})},oo=e=>O.jsxRuntimeExports.jsxs(Wr,{children:[O.jsxRuntimeExports.jsx(ko.FlagsProvider,{features:To,children:O.jsxRuntimeExports.jsx(Xu,{...e})}),O.jsxRuntimeExports.jsx(ve.Toaster,{})]});var Ut=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(){}},Lt=typeof window>"u"||"Deno"in window;function ye(){}function el(e,t){return typeof e=="function"?e(t):e}function on(e){return typeof e=="number"&&e>=0&&e!==1/0}function ao(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Or(e,t){const{type:s="all",exact:n,fetchStatus:r,predicate:i,queryKey:o,stale:c}=e;if(o){if(n){if(t.queryHash!==Tn(o,t.options))return!1}else if(!Jt(t.queryKey,o))return!1}if(s!=="all"){const l=t.isActive();if(s==="active"&&!l||s==="inactive"&&l)return!1}return!(typeof c=="boolean"&&t.isStale()!==c||typeof r<"u"&&r!==t.state.fetchStatus||i&&!i(t))}function _r(e,t){const{exact:s,status:n,predicate:r,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(s){if(Yt(t.options.mutationKey)!==Yt(i))return!1}else if(!Jt(t.options.mutationKey,i))return!1}return!(n&&t.state.status!==n||r&&!r(t))}function Tn(e,t){return((t==null?void 0:t.queryKeyHashFn)||Yt)(e)}function Yt(e){return JSON.stringify(e,(t,s)=>an(s)?Object.keys(s).sort().reduce((n,r)=>(n[r]=s[r],n),{}):s)}function Jt(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(s=>!Jt(e[s],t[s])):!1}function co(e,t){if(e===t)return e;const s=Br(e)&&Br(t);if(s||an(e)&&an(t)){const n=s?e.length:Object.keys(e).length,r=s?t:Object.keys(t),i=r.length,o=s?[]:{};let c=0;for(let l=0;l<i;l++){const u=s?l:r[l];o[u]=co(e[u],t[u]),o[u]===e[u]&&c++}return n===i&&c===n?e:o}return t}function Os(e,t){if(e&&!t||t&&!e)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function Br(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function an(e){if(!Rr(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const s=t.prototype;return!(!Rr(s)||!s.hasOwnProperty("isPrototypeOf"))}function Rr(e){return Object.prototype.toString.call(e)==="[object Object]"}function uo(e){return new Promise(t=>{setTimeout(t,e)})}function Ir(e){uo(0).then(e)}function cn(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?co(e,t):t}function tl(e,t,s=0){const n=[...e,t];return s&&n.length>s?n.slice(1):n}function sl(e,t,s=0){const n=[t,...e];return s&&n.length>s?n.slice(0,-1):n}var We,Ne,yt,Nr,nl=(Nr=class extends Ut{constructor(){super();I(this,We,void 0);I(this,Ne,void 0);I(this,yt,void 0);k(this,yt,t=>{if(!Lt&&window.addEventListener){const s=()=>t();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){a(this,Ne)||this.setEventListener(a(this,yt))}onUnsubscribe(){var t;this.hasListeners()||((t=a(this,Ne))==null||t.call(this),k(this,Ne,void 0))}setEventListener(t){var s;k(this,yt,t),(s=a(this,Ne))==null||s.call(this),k(this,Ne,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){a(this,We)!==t&&(k(this,We,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof a(this,We)=="boolean"?a(this,We):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},We=new WeakMap,Ne=new WeakMap,yt=new WeakMap,Nr),_s=new nl,vt,Te,bt,Tr,rl=(Tr=class extends Ut{constructor(){super();I(this,vt,!0);I(this,Te,void 0);I(this,bt,void 0);k(this,bt,t=>{if(!Lt&&window.addEventListener){const s=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",n)}}})}onSubscribe(){a(this,Te)||this.setEventListener(a(this,bt))}onUnsubscribe(){var t;this.hasListeners()||((t=a(this,Te))==null||t.call(this),k(this,Te,void 0))}setEventListener(t){var s;k(this,bt,t),(s=a(this,Te))==null||s.call(this),k(this,Te,t(this.setOnline.bind(this)))}setOnline(t){a(this,vt)!==t&&(k(this,vt,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return a(this,vt)}},vt=new WeakMap,Te=new WeakMap,bt=new WeakMap,Tr),Bs=new rl;function il(e){return Math.min(1e3*2**e,3e4)}function qs(e){return(e??"online")==="online"?Bs.isOnline():!0}var lo=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Js(e){return e instanceof lo}function fo(e){let t=!1,s=0,n=!1,r,i,o;const c=new Promise((b,C)=>{i=b,o=C}),l=b=>{var C;n||(v(new lo(b)),(C=e.abort)==null||C.call(e))},u=()=>{t=!0},h=()=>{t=!1},g=()=>!_s.isFocused()||e.networkMode!=="always"&&!Bs.isOnline(),A=b=>{var C;n||(n=!0,(C=e.onSuccess)==null||C.call(e,b),r==null||r(),i(b))},v=b=>{var C;n||(n=!0,(C=e.onError)==null||C.call(e,b),r==null||r(),o(b))},_=()=>new Promise(b=>{var C;r=U=>{const M=n||!g();return M&&b(U),M},(C=e.onPause)==null||C.call(e)}).then(()=>{var b;r=void 0,n||(b=e.onContinue)==null||b.call(e)}),B=()=>{if(n)return;let b;try{b=e.fn()}catch(C){b=Promise.reject(C)}Promise.resolve(b).then(A).catch(C=>{var q;if(n)return;const U=e.retry??(Lt?0:3),M=e.retryDelay??il,E=typeof M=="function"?M(s,C):M,P=U===!0||typeof U=="number"&&s<U||typeof U=="function"&&U(s,C);if(t||!P){v(C);return}s++,(q=e.onFail)==null||q.call(e,s,C),uo(E).then(()=>{if(g())return _()}).then(()=>{t?v(C):B()})})};return qs(e.networkMode)?B():_().then(B),{promise:c,cancel:l,continue:()=>(r==null?void 0:r())?c:Promise.resolve(),cancelRetry:u,continueRetry:h}}function ol(){let e=[],t=0,s=h=>{h()},n=h=>{h()};const r=h=>{let g;t++;try{g=h()}finally{t--,t||c()}return g},i=h=>{t?e.push(h):Ir(()=>{s(h)})},o=h=>(...g)=>{i(()=>{h(...g)})},c=()=>{const h=e;e=[],h.length&&Ir(()=>{n(()=>{h.forEach(g=>{s(g)})})})};return{batch:r,batchCalls:o,schedule:i,setNotifyFunction:h=>{s=h},setBatchNotifyFunction:h=>{n=h}}}var se=ol(),Ye,Ur,ho=(Ur=class{constructor(){I(this,Ye,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),on(this.gcTime)&&k(this,Ye,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Lt?1/0:5*60*1e3))}clearGcTimeout(){a(this,Ye)&&(clearTimeout(a(this,Ye)),k(this,Ye,void 0))}},Ye=new WeakMap,Ur),xt,wt,he,Ue,pe,ne,Zt,Je,St,Es,we,Oe,Fr,al=(Fr=class extends ho{constructor(t){super();I(this,St);I(this,we);I(this,xt,void 0);I(this,wt,void 0);I(this,he,void 0);I(this,Ue,void 0);I(this,pe,void 0);I(this,ne,void 0);I(this,Zt,void 0);I(this,Je,void 0);k(this,Je,!1),k(this,Zt,t.defaultOptions),K(this,St,Es).call(this,t.options),k(this,ne,[]),k(this,he,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,k(this,xt,t.state||cl(this.options)),this.state=a(this,xt),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!a(this,ne).length&&this.state.fetchStatus==="idle"&&a(this,he).remove(this)}setData(t,s){const n=cn(this.state.data,t,this.options);return K(this,we,Oe).call(this,{data:n,type:"success",dataUpdatedAt:s==null?void 0:s.updatedAt,manual:s==null?void 0:s.manual}),n}setState(t,s){K(this,we,Oe).call(this,{type:"setState",state:t,setStateOptions:s})}cancel(t){var n;const s=a(this,Ue);return(n=a(this,pe))==null||n.cancel(t),s?s.then(ye).catch(ye):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(a(this,xt))}isActive(){return a(this,ne).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||a(this,ne).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!ao(this.state.dataUpdatedAt,t)}onFocus(){var s;const t=a(this,ne).find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(s=a(this,pe))==null||s.continue()}onOnline(){var s;const t=a(this,ne).find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(s=a(this,pe))==null||s.continue()}addObserver(t){a(this,ne).includes(t)||(a(this,ne).push(t),this.clearGcTimeout(),a(this,he).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){a(this,ne).includes(t)&&(k(this,ne,a(this,ne).filter(s=>s!==t)),a(this,ne).length||(a(this,pe)&&(a(this,Je)?a(this,pe).cancel({revert:!0}):a(this,pe).cancelRetry()),this.scheduleGc()),a(this,he).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return a(this,ne).length}invalidate(){this.state.isInvalidated||K(this,we,Oe).call(this,{type:"invalidate"})}fetch(t,s){var u,h,g,A;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(a(this,Ue))return(u=a(this,pe))==null||u.continueRetry(),a(this,Ue)}if(t&&K(this,St,Es).call(this,t),!this.options.queryFn){const v=a(this,ne).find(_=>_.options.queryFn);v&&K(this,St,Es).call(this,v.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,r={queryKey:this.queryKey,meta:this.meta},i=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>(k(this,Je,!0),n.signal)})};i(r);const o=()=>this.options.queryFn?(k(this,Je,!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}'`)),c={fetchOptions:s,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:o};i(c),(h=this.options.behavior)==null||h.onFetch(c,this),k(this,wt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((g=c.fetchOptions)==null?void 0:g.meta))&&K(this,we,Oe).call(this,{type:"fetch",meta:(A=c.fetchOptions)==null?void 0:A.meta});const l=v=>{var _,B,b,C;Js(v)&&v.silent||K(this,we,Oe).call(this,{type:"error",error:v}),Js(v)||((B=(_=a(this,he).config).onError)==null||B.call(_,v,this),(C=(b=a(this,he).config).onSettled)==null||C.call(b,this.state.data,v,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return k(this,pe,fo({fn:c.fetchFn,abort:n.abort.bind(n),onSuccess:v=>{var _,B,b,C;if(typeof v>"u"){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),l(new Error(`${this.queryHash} data is undefined`));return}this.setData(v),(B=(_=a(this,he).config).onSuccess)==null||B.call(_,v,this),(C=(b=a(this,he).config).onSettled)==null||C.call(b,v,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:l,onFail:(v,_)=>{K(this,we,Oe).call(this,{type:"failed",failureCount:v,error:_})},onPause:()=>{K(this,we,Oe).call(this,{type:"pause"})},onContinue:()=>{K(this,we,Oe).call(this,{type:"continue"})},retry:c.options.retry,retryDelay:c.options.retryDelay,networkMode:c.options.networkMode})),k(this,Ue,a(this,pe).promise),a(this,Ue)}},xt=new WeakMap,wt=new WeakMap,he=new WeakMap,Ue=new WeakMap,pe=new WeakMap,ne=new WeakMap,Zt=new WeakMap,Je=new WeakMap,St=new WeakSet,Es=function(t){this.options={...a(this,Zt),...t},this.updateGcTime(this.options.gcTime)},we=new WeakSet,Oe=function(t){const s=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:qs(this.options.networkMode)?"fetching":"paused",...!n.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...n,data:t.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const r=t.error;return Js(r)&&r.revert&&a(this,wt)?{...a(this,wt),fetchStatus:"idle"}:{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=s(this.state),se.batch(()=>{a(this,ne).forEach(n=>{n.onQueryUpdate()}),a(this,he).notify({query:this,type:"updated",action:t})})},Fr);function cl(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=typeof t<"u",n=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var ke,qr,ul=(qr=class extends Ut{constructor(t={}){super();I(this,ke,void 0);this.config=t,k(this,ke,new Map)}build(t,s,n){const r=s.queryKey,i=s.queryHash??Tn(r,s);let o=this.get(i);return o||(o=new al({cache:this,queryKey:r,queryHash:i,options:t.defaultQueryOptions(s),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(o)),o}add(t){a(this,ke).has(t.queryHash)||(a(this,ke).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const s=a(this,ke).get(t.queryHash);s&&(t.destroy(),s===t&&a(this,ke).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){se.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return a(this,ke).get(t)}getAll(){return[...a(this,ke).values()]}find(t){const s={exact:!0,...t};return this.getAll().find(n=>Or(s,n))}findAll(t={}){const s=this.getAll();return Object.keys(t).length>0?s.filter(n=>Or(t,n)):s}notify(t){se.batch(()=>{this.listeners.forEach(s=>{s(t)})})}onFocus(){se.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){se.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},ke=new WeakMap,qr),Ae,Xt,le,Et,Pe,Ie,$r,ll=($r=class extends ho{constructor(t){super();I(this,Pe);I(this,Ae,void 0);I(this,Xt,void 0);I(this,le,void 0);I(this,Et,void 0);this.mutationId=t.mutationId,k(this,Xt,t.defaultOptions),k(this,le,t.mutationCache),k(this,Ae,[]),this.state=t.state||po(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...a(this,Xt),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){a(this,Ae).includes(t)||(a(this,Ae).push(t),this.clearGcTimeout(),a(this,le).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){k(this,Ae,a(this,Ae).filter(s=>s!==t)),this.scheduleGc(),a(this,le).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){a(this,Ae).length||(this.state.status==="pending"?this.scheduleGc():a(this,le).remove(this))}continue(){var t;return((t=a(this,Et))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var r,i,o,c,l,u,h,g,A,v,_,B,b,C,U,M,E,P,q,F;const s=()=>(k(this,Et,fo({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(N,m)=>{K(this,Pe,Ie).call(this,{type:"failed",failureCount:N,error:m})},onPause:()=>{K(this,Pe,Ie).call(this,{type:"pause"})},onContinue:()=>{K(this,Pe,Ie).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),a(this,Et).promise),n=this.state.status==="pending";try{if(!n){K(this,Pe,Ie).call(this,{type:"pending",variables:t}),await((i=(r=a(this,le).config).onMutate)==null?void 0:i.call(r,t,this));const m=await((c=(o=this.options).onMutate)==null?void 0:c.call(o,t));m!==this.state.context&&K(this,Pe,Ie).call(this,{type:"pending",context:m,variables:t})}const N=await s();return await((u=(l=a(this,le).config).onSuccess)==null?void 0:u.call(l,N,t,this.state.context,this)),await((g=(h=this.options).onSuccess)==null?void 0:g.call(h,N,t,this.state.context)),await((v=(A=a(this,le).config).onSettled)==null?void 0:v.call(A,N,null,this.state.variables,this.state.context,this)),await((B=(_=this.options).onSettled)==null?void 0:B.call(_,N,null,t,this.state.context)),K(this,Pe,Ie).call(this,{type:"success",data:N}),N}catch(N){try{throw await((C=(b=a(this,le).config).onError)==null?void 0:C.call(b,N,t,this.state.context,this)),await((M=(U=this.options).onError)==null?void 0:M.call(U,N,t,this.state.context)),await((P=(E=a(this,le).config).onSettled)==null?void 0:P.call(E,void 0,N,this.state.variables,this.state.context,this)),await((F=(q=this.options).onSettled)==null?void 0:F.call(q,void 0,N,t,this.state.context)),N}finally{K(this,Pe,Ie).call(this,{type:"error",error:N})}}}},Ae=new WeakMap,Xt=new WeakMap,le=new WeakMap,Et=new WeakMap,Pe=new WeakSet,Ie=function(t){const s=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!qs(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=s(this.state),se.batch(()=>{a(this,Ae).forEach(n=>{n.onMutationUpdate(t)}),a(this,le).notify({mutation:this,type:"updated",action:t})})},$r);function po(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var me,es,Ze,Vr,dl=(Vr=class extends Ut{constructor(t={}){super();I(this,me,void 0);I(this,es,void 0);I(this,Ze,void 0);this.config=t,k(this,me,[]),k(this,es,0)}build(t,s,n){const r=new ll({mutationCache:this,mutationId:++ps(this,es)._,options:t.defaultMutationOptions(s),state:n});return this.add(r),r}add(t){a(this,me).push(t),this.notify({type:"added",mutation:t})}remove(t){k(this,me,a(this,me).filter(s=>s!==t)),this.notify({type:"removed",mutation:t})}clear(){se.batch(()=>{a(this,me).forEach(t=>{this.remove(t)})})}getAll(){return a(this,me)}find(t){const s={exact:!0,...t};return a(this,me).find(n=>_r(s,n))}findAll(t={}){return a(this,me).filter(s=>_r(t,s))}notify(t){se.batch(()=>{this.listeners.forEach(s=>{s(t)})})}resumePausedMutations(){return k(this,Ze,(a(this,Ze)??Promise.resolve()).then(()=>{const t=a(this,me).filter(s=>s.state.isPaused);return se.batch(()=>t.reduce((s,n)=>s.then(()=>n.continue().catch(ye)),Promise.resolve()))}).then(()=>{k(this,Ze,void 0)})),a(this,Ze)}},me=new WeakMap,es=new WeakMap,Ze=new WeakMap,Vr);function fl(e){return{onFetch:(t,s)=>{const n=async()=>{var _,B,b,C,U;const r=t.options,i=(b=(B=(_=t.fetchOptions)==null?void 0:_.meta)==null?void 0:B.fetchMore)==null?void 0:b.direction,o=((C=t.state.data)==null?void 0:C.pages)||[],c=((U=t.state.data)==null?void 0:U.pageParams)||[],l={pages:[],pageParams:[]};let u=!1;const h=M=>{Object.defineProperty(M,"signal",{enumerable:!0,get:()=>(t.signal.aborted?u=!0:t.signal.addEventListener("abort",()=>{u=!0}),t.signal)})},g=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),A=async(M,E,P)=>{if(u)return Promise.reject();if(E==null&&M.pages.length)return Promise.resolve(M);const q={queryKey:t.queryKey,pageParam:E,direction:P?"backward":"forward",meta:t.options.meta};h(q);const F=await g(q),{maxPages:N}=t.options,m=P?sl:tl;return{pages:m(M.pages,F,N),pageParams:m(M.pageParams,E,N)}};let v;if(i&&o.length){const M=i==="backward",E=M?hl:Dr,P={pages:o,pageParams:c},q=E(r,P);v=await A(P,q,M)}else{v=await A(l,c[0]??r.initialPageParam);const M=e??o.length;for(let E=1;E<M;E++){const P=Dr(r,v);v=await A(v,P)}}return v};t.options.persister?t.fetchFn=()=>{var r,i;return(i=(r=t.options).persister)==null?void 0:i.call(r,n,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s)}:t.fetchFn=n}}}function Dr(e,{pages:t,pageParams:s}){const n=t.length-1;return e.getNextPageParam(t[n],t,s[n],s)}function hl(e,{pages:t,pageParams:s}){var n;return(n=e.getPreviousPageParam)==null?void 0:n.call(e,t[0],t,s[0],s)}var te,Fe,qe,kt,At,$e,Pt,Ct,Qr,pl=(Qr=class{constructor(e={}){I(this,te,void 0);I(this,Fe,void 0);I(this,qe,void 0);I(this,kt,void 0);I(this,At,void 0);I(this,$e,void 0);I(this,Pt,void 0);I(this,Ct,void 0);k(this,te,e.queryCache||new ul),k(this,Fe,e.mutationCache||new dl),k(this,qe,e.defaultOptions||{}),k(this,kt,new Map),k(this,At,new Map),k(this,$e,0)}mount(){ps(this,$e)._++,a(this,$e)===1&&(k(this,Pt,_s.subscribe(()=>{_s.isFocused()&&(this.resumePausedMutations(),a(this,te).onFocus())})),k(this,Ct,Bs.subscribe(()=>{Bs.isOnline()&&(this.resumePausedMutations(),a(this,te).onOnline())})))}unmount(){var e,t;ps(this,$e)._--,a(this,$e)===0&&((e=a(this,Pt))==null||e.call(this),k(this,Pt,void 0),(t=a(this,Ct))==null||t.call(this),k(this,Ct,void 0))}isFetching(e){return a(this,te).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return a(this,Fe).findAll({...e,status:"pending"}).length}getQueryData(e){var t;return(t=a(this,te).find({queryKey:e}))==null?void 0:t.state.data}ensureQueryData(e){const t=this.getQueryData(e.queryKey);return t!==void 0?Promise.resolve(t):this.fetchQuery(e)}getQueriesData(e){return this.getQueryCache().findAll(e).map(({queryKey:t,state:s})=>{const n=s.data;return[t,n]})}setQueryData(e,t,s){const n=a(this,te).find({queryKey:e}),r=n==null?void 0:n.state.data,i=el(t,r);if(typeof i>"u")return;const o=this.defaultQueryOptions({queryKey:e});return a(this,te).build(this,o).setData(i,{...s,manual:!0})}setQueriesData(e,t,s){return se.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,s)]))}getQueryState(e){var t;return(t=a(this,te).find({queryKey:e}))==null?void 0:t.state}removeQueries(e){const t=a(this,te);se.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=a(this,te),n={type:"active",...e};return se.batch(()=>(s.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries(n,t)))}cancelQueries(e={},t={}){const s={revert:!0,...t},n=se.batch(()=>a(this,te).findAll(e).map(r=>r.cancel(s)));return Promise.all(n).then(ye).catch(ye)}invalidateQueries(e={},t={}){return se.batch(()=>{if(a(this,te).findAll(e).forEach(n=>{n.invalidate()}),e.refetchType==="none")return Promise.resolve();const s={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(s,t)})}refetchQueries(e={},t){const s={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},n=se.batch(()=>a(this,te).findAll(e).filter(r=>!r.isDisabled()).map(r=>{let i=r.fetch(void 0,s);return s.throwOnError||(i=i.catch(ye)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(ye)}fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const s=a(this,te).build(this,t);return s.isStaleByTime(t.staleTime)?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ye).catch(ye)}fetchInfiniteQuery(e){return e.behavior=fl(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ye).catch(ye)}resumePausedMutations(){return a(this,Fe).resumePausedMutations()}getQueryCache(){return a(this,te)}getMutationCache(){return a(this,Fe)}getDefaultOptions(){return a(this,qe)}setDefaultOptions(e){k(this,qe,e)}setQueryDefaults(e,t){a(this,kt).set(Yt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...a(this,kt).values()];let s={};return t.forEach(n=>{Jt(e,n.queryKey)&&(s={...s,...n.defaultOptions})}),s}setMutationDefaults(e,t){a(this,At).set(Yt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...a(this,At).values()];let s={};return t.forEach(n=>{Jt(e,n.mutationKey)&&(s={...s,...n.defaultOptions})}),s}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...a(this,qe).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Tn(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...a(this,qe).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){a(this,te).clear(),a(this,Fe).clear()}},te=new WeakMap,Fe=new WeakMap,qe=new WeakMap,kt=new WeakMap,At=new WeakMap,$e=new WeakMap,Pt=new WeakMap,Ct=new WeakMap,Qr),ue,X,jt,oe,Xe,Ot,Ce,ts,_t,Bt,et,tt,Ve,st,nt,Vt,ss,un,ns,ln,rs,dn,is,fn,os,hn,as,pn,cs,mn,Rs,mo,Kr,ml=(Kr=class extends Ut{constructor(t,s){super();I(this,nt);I(this,ss);I(this,ns);I(this,rs);I(this,is);I(this,os);I(this,as);I(this,cs);I(this,Rs);I(this,ue,void 0);I(this,X,void 0);I(this,jt,void 0);I(this,oe,void 0);I(this,Xe,void 0);I(this,Ot,void 0);I(this,Ce,void 0);I(this,ts,void 0);I(this,_t,void 0);I(this,Bt,void 0);I(this,et,void 0);I(this,tt,void 0);I(this,Ve,void 0);I(this,st,void 0);k(this,X,void 0),k(this,jt,void 0),k(this,oe,void 0),k(this,st,new Set),k(this,ue,t),this.options=s,k(this,Ce,null),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(a(this,X).addObserver(this),Mr(a(this,X),this.options)?K(this,nt,Vt).call(this):this.updateResult(),K(this,is,fn).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return gn(a(this,X),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return gn(a(this,X),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,K(this,os,hn).call(this),K(this,as,pn).call(this),a(this,X).removeObserver(this)}setOptions(t,s){const n=this.options,r=a(this,X);if(this.options=a(this,ue).defaultQueryOptions(t),Os(n,this.options)||a(this,ue).getQueryCache().notify({type:"observerOptionsUpdated",query:a(this,X),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=n.queryKey),K(this,cs,mn).call(this);const i=this.hasListeners();i&&Lr(a(this,X),r,this.options,n)&&K(this,nt,Vt).call(this),this.updateResult(s),i&&(a(this,X)!==r||this.options.enabled!==n.enabled||this.options.staleTime!==n.staleTime)&&K(this,ss,un).call(this);const o=K(this,ns,ln).call(this);i&&(a(this,X)!==r||this.options.enabled!==n.enabled||o!==a(this,Ve))&&K(this,rs,dn).call(this,o)}getOptimisticResult(t){const s=a(this,ue).getQueryCache().build(a(this,ue),t),n=this.createResult(s,t);return yl(this,n)&&(k(this,oe,n),k(this,Ot,this.options),k(this,Xe,a(this,X).state)),n}getCurrentResult(){return a(this,oe)}trackResult(t){const s={};return Object.keys(t).forEach(n=>{Object.defineProperty(s,n,{configurable:!1,enumerable:!0,get:()=>(a(this,st).add(n),t[n])})}),s}getCurrentQuery(){return a(this,X)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=a(this,ue).defaultQueryOptions(t),n=a(this,ue).getQueryCache().build(a(this,ue),s);return n.isFetchingOptimistic=!0,n.fetch().then(()=>this.createResult(n,s))}fetch(t){return K(this,nt,Vt).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),a(this,oe)))}createResult(t,s){var q;const n=a(this,X),r=this.options,i=a(this,oe),o=a(this,Xe),c=a(this,Ot),u=t!==n?t.state:a(this,jt),{state:h}=t;let{error:g,errorUpdatedAt:A,fetchStatus:v,status:_}=h,B=!1,b;if(s._optimisticResults){const F=this.hasListeners(),N=!F&&Mr(t,s),m=F&&Lr(t,n,s,r);(N||m)&&(v=qs(t.options.networkMode)?"fetching":"paused",h.dataUpdatedAt||(_="pending")),s._optimisticResults==="isRestoring"&&(v="idle")}if(s.select&&typeof h.data<"u")if(i&&h.data===(o==null?void 0:o.data)&&s.select===a(this,ts))b=a(this,_t);else try{k(this,ts,s.select),b=s.select(h.data),b=cn(i==null?void 0:i.data,b,s),k(this,_t,b),k(this,Ce,null)}catch(F){k(this,Ce,F)}else b=h.data;if(typeof s.placeholderData<"u"&&typeof b>"u"&&_==="pending"){let F;if(i!=null&&i.isPlaceholderData&&s.placeholderData===(c==null?void 0:c.placeholderData))F=i.data;else if(F=typeof s.placeholderData=="function"?s.placeholderData((q=a(this,Bt))==null?void 0:q.state.data,a(this,Bt)):s.placeholderData,s.select&&typeof F<"u")try{F=s.select(F),k(this,Ce,null)}catch(N){k(this,Ce,N)}typeof F<"u"&&(_="success",b=cn(i==null?void 0:i.data,F,s),B=!0)}a(this,Ce)&&(g=a(this,Ce),b=a(this,_t),A=Date.now(),_="error");const C=v==="fetching",U=_==="pending",M=_==="error",E=U&&C;return{status:_,fetchStatus:v,isPending:U,isSuccess:_==="success",isError:M,isInitialLoading:E,isLoading:E,data:b,dataUpdatedAt:h.dataUpdatedAt,error:g,errorUpdatedAt:A,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:C,isRefetching:C&&!U,isLoadingError:M&&h.dataUpdatedAt===0,isPaused:v==="paused",isPlaceholderData:B,isRefetchError:M&&h.dataUpdatedAt!==0,isStale:Un(t,s),refetch:this.refetch}}updateResult(t){const s=a(this,oe),n=this.createResult(a(this,X),this.options);if(k(this,Xe,a(this,X).state),k(this,Ot,this.options),a(this,Xe).data!==void 0&&k(this,Bt,a(this,X)),Os(n,s))return;k(this,oe,n);const r={},i=()=>{if(!s)return!0;const{notifyOnChangeProps:o}=this.options,c=typeof o=="function"?o():o;if(c==="all"||!c&&!a(this,st).size)return!0;const l=new Set(c??a(this,st));return this.options.throwOnError&&l.add("error"),Object.keys(a(this,oe)).some(u=>{const h=u;return a(this,oe)[h]!==s[h]&&l.has(h)})};(t==null?void 0:t.listeners)!==!1&&i()&&(r.listeners=!0),K(this,Rs,mo).call(this,{...r,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&K(this,is,fn).call(this)}},ue=new WeakMap,X=new WeakMap,jt=new WeakMap,oe=new WeakMap,Xe=new WeakMap,Ot=new WeakMap,Ce=new WeakMap,ts=new WeakMap,_t=new WeakMap,Bt=new WeakMap,et=new WeakMap,tt=new WeakMap,Ve=new WeakMap,st=new WeakMap,nt=new WeakSet,Vt=function(t){K(this,cs,mn).call(this);let s=a(this,X).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(ye)),s},ss=new WeakSet,un=function(){if(K(this,os,hn).call(this),Lt||a(this,oe).isStale||!on(this.options.staleTime))return;const s=ao(a(this,oe).dataUpdatedAt,this.options.staleTime)+1;k(this,et,setTimeout(()=>{a(this,oe).isStale||this.updateResult()},s))},ns=new WeakSet,ln=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(a(this,X)):this.options.refetchInterval)??!1},rs=new WeakSet,dn=function(t){K(this,as,pn).call(this),k(this,Ve,t),!(Lt||this.options.enabled===!1||!on(a(this,Ve))||a(this,Ve)===0)&&k(this,tt,setInterval(()=>{(this.options.refetchIntervalInBackground||_s.isFocused())&&K(this,nt,Vt).call(this)},a(this,Ve)))},is=new WeakSet,fn=function(){K(this,ss,un).call(this),K(this,rs,dn).call(this,K(this,ns,ln).call(this))},os=new WeakSet,hn=function(){a(this,et)&&(clearTimeout(a(this,et)),k(this,et,void 0))},as=new WeakSet,pn=function(){a(this,tt)&&(clearInterval(a(this,tt)),k(this,tt,void 0))},cs=new WeakSet,mn=function(){const t=a(this,ue).getQueryCache().build(a(this,ue),this.options);if(t===a(this,X))return;const s=a(this,X);k(this,X,t),k(this,jt,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},Rs=new WeakSet,mo=function(t){se.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(a(this,oe))}),a(this,ue).getQueryCache().notify({query:a(this,X),type:"observerResultsUpdated"})})},Kr);function gl(e,t){return t.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Mr(e,t){return gl(e,t)||e.state.dataUpdatedAt>0&&gn(e,t,t.refetchOnMount)}function gn(e,t,s){if(t.enabled!==!1){const n=typeof s=="function"?s(e):s;return n==="always"||n!==!1&&Un(e,t)}return!1}function Lr(e,t,s,n){return s.enabled!==!1&&(e!==t||n.enabled===!1)&&(!s.suspense||e.state.status!=="error")&&Un(e,s)}function Un(e,t){return e.isStaleByTime(t.staleTime)}function yl(e,t){return!Os(e.getCurrentResult(),t)}var Qe,ae,ge,_e,Rt,ks,us,yn,zr,vl=(zr=class extends Ut{constructor(t,s){super();I(this,Rt);I(this,us);I(this,Qe,void 0);I(this,ae,void 0);I(this,ge,void 0);I(this,_e,void 0);k(this,ae,void 0),k(this,Qe,t),this.setOptions(s),this.bindMethods(),K(this,Rt,ks).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var n;const s=this.options;this.options=a(this,Qe).defaultMutationOptions(t),Os(s,this.options)||a(this,Qe).getMutationCache().notify({type:"observerOptionsUpdated",mutation:a(this,ge),observer:this}),(n=a(this,ge))==null||n.setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=a(this,ge))==null||t.removeObserver(this)}onMutationUpdate(t){K(this,Rt,ks).call(this),K(this,us,yn).call(this,t)}getCurrentResult(){return a(this,ae)}reset(){k(this,ge,void 0),K(this,Rt,ks).call(this),K(this,us,yn).call(this)}mutate(t,s){var n;return k(this,_e,s),(n=a(this,ge))==null||n.removeObserver(this),k(this,ge,a(this,Qe).getMutationCache().build(a(this,Qe),this.options)),a(this,ge).addObserver(this),a(this,ge).execute(t)}},Qe=new WeakMap,ae=new WeakMap,ge=new WeakMap,_e=new WeakMap,Rt=new WeakSet,ks=function(){var s;const t=((s=a(this,ge))==null?void 0:s.state)??po();k(this,ae,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},us=new WeakSet,yn=function(t){se.batch(()=>{var s,n,r,i,o,c,l,u;a(this,_e)&&this.hasListeners()&&((t==null?void 0:t.type)==="success"?((n=(s=a(this,_e)).onSuccess)==null||n.call(s,t.data,a(this,ae).variables,a(this,ae).context),(i=(r=a(this,_e)).onSettled)==null||i.call(r,t.data,null,a(this,ae).variables,a(this,ae).context)):(t==null?void 0:t.type)==="error"&&((c=(o=a(this,_e)).onError)==null||c.call(o,t.error,a(this,ae).variables,a(this,ae).context),(u=(l=a(this,_e)).onSettled)==null||u.call(l,void 0,t.error,a(this,ae).variables,a(this,ae).context))),this.listeners.forEach(h=>{h(a(this,ae))})})},zr),go=re.createContext(void 0),He=e=>{const t=re.useContext(go);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},bl=({client:e,children:t})=>(re.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),re.createElement(go.Provider,{value:e},t)),yo=re.createContext(!1),xl=()=>re.useContext(yo);yo.Provider;function wl(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Sl=re.createContext(wl()),El=()=>re.useContext(Sl);function vo(e,t){return typeof e=="function"?e(...t):!!e}var kl=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},Al=e=>{re.useEffect(()=>{e.clearReset()},[e])},Pl=({result:e,errorResetBoundary:t,throwOnError:s,query:n})=>e.isError&&!t.isReset()&&!e.isFetching&&vo(s,[e.error,n]),Cl=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},jl=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Ol=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function _l(e,t,s){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=He(s),r=xl(),i=El(),o=n.defaultQueryOptions(e);o._optimisticResults=r?"isRestoring":"optimistic",Cl(o),kl(o,i),Al(i);const[c]=re.useState(()=>new t(n,o)),l=c.getOptimisticResult(o);if(re.useSyncExternalStore(re.useCallback(u=>{const h=r?()=>{}:c.subscribe(se.batchCalls(u));return c.updateResult(),h},[c,r]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),re.useEffect(()=>{c.setOptions(o,{listeners:!1})},[o,c]),jl(o,l))throw Ol(o,c,i);if(Pl({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:c.getCurrentQuery()}))throw l.error;return o.notifyOnChangeProps?l:c.trackResult(l)}function $s(e,t){return _l(e,ml,t)}function Fn(e,t){const s=He(t),[n]=re.useState(()=>new vl(s,e));re.useEffect(()=>{n.setOptions(e)},[n,e]);const r=re.useSyncExternalStore(re.useCallback(o=>n.subscribe(se.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=re.useCallback((o,c)=>{n.mutate(o,c).catch(Bl)},[n]);if(r.error&&vo(n.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:i,mutateAsync:r.mutate}}function Bl(){}function ut(){return He().getQueryData(["apiBaseUrl"])||"/api/chaibuilder"}const Rl=()=>{const e=ut(),t=He();return Fn({mutationFn:async s=>fetch(`${e}/authenticate`,{method:"POST",body:JSON.stringify(s)}).then(n=>n.json()).catch(n=>{throw new Error(n)}),onSuccess:s=>{localStorage.setItem("__anon_token",s.token),t.invalidateQueries({queryKey:["verify"]}),Zs.toast.success("Authenticated successfully.")},onError:()=>{Zs.toast.error("Incorrect password. Please try again.")}})},Il=()=>{const e=ut();return $s({queryKey:["verify"],queryFn:async()=>{const t=localStorage.getItem("__anon_token");if(!t)return{valid:!1};try{return await(await fetch(`${e}/verify?token=`+t,{method:"GET"})).json()}catch{return localStorage.removeItem("__anon_token"),{valid:!1}}}})},Dl=()=>{const[e,t]=L.useState(""),{mutate:s,isPending:n}=Rl(),r=()=>{s({password:e})};return O.jsxRuntimeExports.jsx("section",{className:"py-10 h-screen bg-gray-50 sm:py-16 lg:py-24",children:O.jsxRuntimeExports.jsxs("div",{className:"px-4 mx-auto max-w-7xl sm:px-6 lg:px-8",children:[O.jsxRuntimeExports.jsxs("div",{className:"max-w-2xl mx-auto text-center",children:[O.jsxRuntimeExports.jsx("h2",{className:"text-3xl font-bold leading-tight text-black sm:text-4xl lg:text-5xl",children:"Your Brand"}),O.jsxRuntimeExports.jsx("p",{className:"max-w-xl mx-auto mt-4 text-base leading-relaxed text-gray-600",children:"Enter password to continue"})]}),O.jsxRuntimeExports.jsx("div",{className:"relative max-w-md mx-auto mt-8 md:mt-16",children:O.jsxRuntimeExports.jsx("div",{className:"overflow-hidden bg-white rounded-md shadow-md",children:O.jsxRuntimeExports.jsx("div",{className:"px-4 py-6 sm:px-8 sm:py-7",children:O.jsxRuntimeExports.jsx("div",{children:O.jsxRuntimeExports.jsxs("div",{className:"space-y-5",children:[O.jsxRuntimeExports.jsxs("div",{children:[O.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between",children:O.jsxRuntimeExports.jsx("label",{htmlFor:"pwd",className:"text-base font-medium text-gray-900",children:"Password"})}),O.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[O.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:O.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:O.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"})})}),O.jsxRuntimeExports.jsx("input",{value:e,onChange:i=>t(i.target.value),type:"password",id:"pwd",placeholder:"Enter 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"})]})]}),O.jsxRuntimeExports.jsx("div",{children:O.jsxRuntimeExports.jsx("button",{disabled:n||d.isEmpty(e)||e.length<3,onClick:r,type:"button",className:"inline-flex disabled:bg-gray-400 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:n?"Authenticating...":"Authenticate"})})]})})})})})]})})},qn=()=>{const e=He();let t=e.getQueryData(["currentPage"]);return t||(t=localStorage.getItem("currentPage")),[t||"",s=>{localStorage.setItem("currentPage",s||""),e.setQueryData(["currentPage"],s||"")}]},Vs=()=>{const[e,t]=qn(),s=ut();return $s({queryKey:["project"],queryFn:async()=>{const n=await fetch(`${s}/project`).then(r=>r.json());return!e&&n&&t(n.homepage),n}})},bo=()=>{const{data:e}=Vs(),t=ut(),s=e==null?void 0:e.uuid;return $s({queryKey:["pages",s],queryFn:async()=>await fetch(`${t}/pages`).then(r=>r.json())||[],enabled:!!s})},Ml=()=>{const[e,t]=qn(),{data:s}=Vs(),n=ut();return $s({queryKey:["page_data",e],queryFn:async()=>{const r=await fetch(`${n}/page?uuid=${e}`);return r.ok?r.json():(t(s.homepage),null)},enabled:!!e})},As=()=>O.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen",children:O.jsxRuntimeExports.jsx("div",{className:"flex h-full w-full justify-center items-center",children:O.jsxRuntimeExports.jsxs("div",{role:"status",children:[O.jsxRuntimeExports.jsxs("svg",{"aria-hidden":"true",className:"w-8 mx-auto mb-4 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[O.jsxRuntimeExports.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),O.jsxRuntimeExports.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]}),O.jsxRuntimeExports.jsx("p",{children:"Loading... Please wait..."}),O.jsxRuntimeExports.jsx("span",{className:"sr-only",children:"Loading..."})]})})}),xo=(e="Project updated successfully.")=>{const t=He(),s=ut();return Fn({mutationFn:async n=>await fetch(`${s}/project`,{method:"PUT",body:JSON.stringify(n)}),onSuccess:()=>{t.invalidateQueries({queryKey:["project"]}),Zs.toast.success(e)}})},Ll=L.lazy(()=>Promise.resolve().then(()=>require("./PagesPanel-41ebbdd1.cjs"))),Nl=L.lazy(()=>Promise.resolve().then(()=>require("./ProjectPanel-08a229f3.cjs"))),Tl=()=>O.jsxRuntimeExports.jsx("h2",{children:"Your Logo"}),Ul=()=>O.jsxRuntimeExports.jsx("div",{className:"border-gray-200 rounded-md p-2 mb-2 border",children:O.jsxRuntimeExports.jsx(jo.LogOutIcon,{className:"w-4 h-4 text-red-500"})}),Fl=()=>O.jsxRuntimeExports.jsx(ve.Button,{className:"bg-blue-600 text-white",children:"Publish"}),ql=e=>{const{data:t,isLoading:s}=Vs(),{data:n,isLoading:r}=bo(),{data:i}=Ml(),{mutate:o}=xo(),{logo:c=Tl}=e;return s||!t?O.jsxRuntimeExports.jsx(As,{}):r||!n?O.jsxRuntimeExports.jsx(As,{}):i?O.jsxRuntimeExports.jsx("div",{className:"bg-background text-foreground",children:O.jsxRuntimeExports.jsx(oo,{blocks:i.blocks,brandingOptions:t.brandingOptions,darkMode:e.darkMode||!1,onSaveBlocks:async({blocks:l,type:u})=>{console.log(u,l)},onSaveBrandingOptions:async l=>{o({brandingOptions:l})},topBarComponents:{left:[c],right:[Fl]},sideBarComponents:{top:[{icon:Qn.FileTextIcon,name:"pages",panel:Ll},{icon:Qn.GearIcon,name:"settings",panel:Nl}],bottom:[Ul]}})}):O.jsxRuntimeExports.jsx(As,{})},$l=e=>{const{data:t,isLoading:s}=Il(),n=He();return L.useEffect(()=>{n.setQueryData(["apiBaseUrl"],e.apiBaseUrl||"/api/chaibuilder")},[e.apiBaseUrl,n]),s?O.jsxRuntimeExports.jsx(As,{}):t!=null&&t.valid?O.jsxRuntimeExports.jsx(ql,{...e}):O.jsxRuntimeExports.jsx(Dl,{})},Vl=new pl,Ql=e=>O.jsxRuntimeExports.jsx(bl,{client:Vl,children:O.jsxRuntimeExports.jsx($l,{...e})}),Kl=e=>({...e}),zl=e=>({...e});exports.ChaiBuilderEditor=oo;exports.ChaiBuilderStudio=Ql;exports.ErrorBoundary=Wr;exports.activePanelAtom=wi;exports.addBlockOffCanvasAtom=Si;exports.addBlocksModalAtom=ti;exports.advanceStylingOpenAtom=yi;exports.canDeleteBlock=ga;exports.canDropBlock=va;exports.canDuplicateBlock=ma;exports.canvasIframeAtom=xi;exports.editLayerNameAtom=bi;exports.enableStyling=zl;exports.getBlockJSONFromSchemas=tn;exports.getBlockJSONFromUISchemas=en;exports.inlineEditingActiveAtom=gi;exports.networkModeAtom=vi;exports.setBlockProps=Kl;exports.showPredefinedBlockCategoryAtom=Ei;exports.useActiveLanguage=Ti;exports.useActiveModal=hc;exports.useActivePanel=yc;exports.useAddBlock=Aa;exports.useAddBlockParent=vc;exports.useAddClassesToBlocks=_a;exports.useAllBlocks=ai;exports.useApiBaseUrl=ut;exports.useBlockContentByLanguage=Bc;exports.useBrandingOptions=An;exports.useBuilderReset=Ni;exports.useBuildingBlocks=ui;exports.useCanvasHistory=ds;exports.useCanvasWidth=Va;exports.useCanvasZoom=Ka;exports.useCopyBlockIds=ji;exports.useCurrentPage=qn;exports.useCurrentPage$1=li;exports.useCutBlockIds=On;exports.useDarkMode=za;exports.useDeveloperPreviewMode=Ga;exports.useDuplicateBlocks=Bn;exports.useExpandedIds=Lc;exports.useFeatureSupport=Ec;exports.useGetPageData=jn;exports.useHiddenBlockIds=Ya;exports.useHighlightBlockId=_i;exports.useLanguages=_c;exports.useMarkAsGlobalBlock=Za;exports.useMoveBlocks=Xa;exports.useMutation=Fn;exports.usePages=bo;exports.usePasteBlocks=Bi;exports.usePreviewMode=kn;exports.usePrimaryLanguage=Oc;exports.useProject=Vs;exports.useProject$1=sc;exports.useQueryClient=He;exports.useReadOnlyMode=pc;exports.useRemoveBlocks=Ii;exports.useRemoveClassesFromBlocks=rc;exports.useSavePage=$a;exports.useSelectedBlock=Sa;exports.useSelectedBlockAllClasses=ic;exports.useSelectedBlockCurrentClasses=cc;exports.useSelectedBlockIds=ze;exports.useSelectedBlocksDisplayChild=wa;exports.useSelectedBreakpoints=xc;exports.useSelectedStylingBlocks=En;exports.useSetAllBlocks=si;exports.useStylingBreakpoint=ki;exports.useStylingState=uc;exports.useTranslations=Sc;exports.useTreeData=pa;exports.useUILibraryBlocks=Ac;exports.useUpdateBlocksProps=lc;exports.useUpdateBlocksPropsRealtime=dc;exports.useUpdateProject=xo;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-5c3ac4f7.cjs"),n=require("react"),u=require("@radix-ui/react-icons"),o=require("./popover-7cb9079b.cjs"),x=require("./index-1217461b.cjs"),j=require("./useChangePage-f22cea36.cjs");require("@radix-ui/react-popover");require("./utils-3c452dd0.cjs");require("clsx");require("tailwind-merge");require("i18next");require("react-i18next");require("flagged");require("react-dnd");require("lodash");require("@minoru/react-dnd-treeview");require("./useBuilderProp-5e57d0c8.cjs");require("@radix-ui/react-slot");require("class-variance-authority");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");require("jotai");require("react-hotkeys-hook");require("flat-to-nested");require("./Class-6c695ccb.cjs");require("./MODIFIERS-70fef873.cjs");require("redux-undo");require("@react-hookz/web");require("@chaibuilder/blocks");require("sonner");require("lucide-react");const m=n.lazy(()=>Promise.resolve().then(()=>require("./single-page-detail-116281ae.cjs"))),p=({pageData:s})=>{const[r,t]=n.useState("CLOSE");return e.jsxRuntimeExports.jsxs(o.Popover,{open:r==="OPEN"||r==="ALERT"||r==="PENDING",onOpenChange:i=>{t(r==="PENDING"?"ALERT":i?"OPEN":"CLOSE")},children:[e.jsxRuntimeExports.jsx(o.PopoverTrigger,{asChild:!0,onClick:i=>{i.stopPropagation(),t("OPEN")},children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between",children:r==="OPEN"||r==="ALERT"||r==="PENDING"?e.jsxRuntimeExports.jsx(u.ChevronRightIcon,{}):e.jsxRuntimeExports.jsx("div",{className:"hidden hover:text-blue-600 group-hover:flex",children:e.jsxRuntimeExports.jsx(u.GearIcon,{})})})}),e.jsxRuntimeExports.jsx(o.PopoverContent,{side:"right",align:"start",alignOffset:-35,className:"h-screen w-96",children:e.jsxRuntimeExports.jsx(n.Suspense,{fallback:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full animate-pulse flex-col gap-y-3",children:[e.jsxRuntimeExports.jsx("div",{className:"bg-background-300 h-6 w-1/2"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-300 h-20 w-full"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-300 h-20 w-full"})]}),children:e.jsxRuntimeExports.jsx(m,{pageData:s,open:r,setOpen:t})})})]})},d=s=>{const[r]=x.useCurrentPage(),{data:t}=x.useProject(),i=j.useChangePage(),a=(t==null?void 0:t.homepage)===s.uuid,l=r===s.uuid,c=()=>i(s);return t?e.jsxRuntimeExports.jsxs("button",{className:`group relative flex w-full cursor-pointer items-center justify-between px-2.5 py-2 ${l?"bg-blue-200 ":""}`,onClick:c,type:"button",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-1.5",children:[a?e.jsxRuntimeExports.jsx(u.HomeIcon,{}):e.jsxRuntimeExports.jsx(u.FileTextIcon,{})," ",s.name]}),e.jsxRuntimeExports.jsx(p,{pageData:s})]}):null},g=({pages:s,isLoading:r})=>r?e.jsxRuntimeExports.jsxs("div",{className:"flex animate-pulse flex-col gap-y-1 px-2.5 pt-2",children:[e.jsxRuntimeExports.jsx("div",{className:"bg-background-200 h-7 w-full"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-200 h-7 w-full"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-200 h-7 w-full"})]}):s.length===0?e.jsxRuntimeExports.jsx("div",{className:"px-2.5 pb-2 pt-4",children:"No pages"}):e.jsxRuntimeExports.jsx("div",{className:"-mb-2",children:n.Children.toArray(s.map(t=>e.jsxRuntimeExports.jsx(d,{...t})))});exports.default=g;
|
|
@@ -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"),M=require("@radix-ui/react-icons"),H=require("./useBuilderProp-5e57d0c8.cjs"),w=require("./scroll-area-088530b9.cjs"),d=require("@chaibuilder/blocks"),L=require("sonner"),h=require("./form-6eac0287.cjs"),p=require("./index-1217461b.cjs"),z=require("./usePageActions-5e28a006.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("@rjsf/core");require("@rjsf/validator-ajv8");require("./link-86c532b5.cjs");require("react-icons-picker");require("react-dom");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-6c695ccb.cjs");require("./MODIFIERS-70fef873.cjs");require("redux-undo");require("@react-hookz/web");require("lucide-react");require("./useChangePage-f22cea36.cjs");const B=q.lazy(()=>Promise.resolve().then(()=>require("./delete-page-modal-15e71ba4.cjs"))),G=q.lazy(()=>Promise.resolve().then(()=>require("./confirm-alert-4f50caa7.cjs"))),E=n=>{if(!c.isString(n)||!(n.includes("/[")&&n.includes("]")))return!1;const i=/^\[((?:\.{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=i.test(u):e=g.test(u))}),e},P=n=>n&&c.isEmpty(n.seoData)?{...n,seoData:{title:"",description:"",image:""}}:n,Y=(n,o)=>{const i=!c.isEqual(c.omit(n,["seoData"]),c.omit(o,["seoData"])),g=!c.isEqual(P(o).seoData,P(n).seoData);return i||g},F=({open:n,setOpen:o,pageData:i})=>{const g=p.useQueryClient(),{data:e}=p.useProject(),u=z.useUpdatePage(),m=p.useUpdateProject("Homepage updated successfully."),[s,b]=q.useState(P(i)),[a,y]=q.useState({isHomePage:(e==null?void 0:e.homepage)===i.uuid}),j=Y(s,i);q.useEffect(()=>{const l=!c.isEqual(P(i),s),r=(e==null?void 0:e.homepage)!==i.uuid&&a.isHomePage;o(l||r?"PENDING":"OPEN")},[e,i,s,a,o]);const S=()=>{if(j){if(i.type==="DYNAMIC"&&!E((s==null?void 0:s.slug)||"")){n==="ALERT"&&o("PENDING");return}u.mutate(s,{onSuccess:()=>{g.invalidateQueries({refetchType:"active",queryKey:["pages",e==null?void 0:e.uuid]}),o("CLOSE"),L.toast.success("Page updated successfully.")}})}a.isHomePage&&(e==null?void 0:e.homepage)!==i.uuid&&m.mutate({...e,homepage:i==null?void 0:i.uuid},{onSuccess:()=>o("CLOSE")})},C=({formData:l},r)=>{b(f=>{var R,N;if(!r)return f;const x={[r]:l[r]};return r==="name"?x.slug=c.kebabCase((R=l[r])==null?void 0:R.replace(/\d/g,"")):r==="slug"?x.slug=(N=l[r])==null?void 0:N.replace(/\d/g,"").replace(/\s+/g,"").replace("--","-").replace("__","_"):r==="seoData"&&(x.seoData={title:l[r].title||"",description:l[r].description||"",image:l[r].image||""}),{...f,...x}})},A=({formData:l},r)=>{y(f=>{const x={[r]:l[r]};return{...f,...x}})},I={name:d.SingleLineText({title:"Page Name",default:s.name}),slug:d.SingleLineText({title:"Page Slug",default:s.slug})},T={seoData:d.Model({title:"",description:"",default:{title:"",description:"",image:""},properties:{title:d.SingleLineText({title:"Meta Title",default:s.name}),description:d.MultilineText({title:"Meta Description",default:s.slug}),image:d.Image({title:"Social Media Image",default:""})}})},v={isHomePage:d.Checkbox({title:"Set as homepage",default:a.isHomePage})};return t.jsxRuntimeExports.jsxs(w.ScrollArea,{className:"flex h-full select-none flex-col",children:[t.jsxRuntimeExports.jsx(G,{open:n==="ALERT",title:"Do yo want to save changes?",onCancel:()=>o("CLOSE"),onConfirm:S,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(h.Form,{title:"Basic Details",formData:s,properties:I,onChange:C,disabled:u.isPending||m.isPending}),t.jsxRuntimeExports.jsx("div",{className:"h-2 w-full"}),t.jsxRuntimeExports.jsx(h.Form,{title:"SEO Details",formData:s,properties:T,onChange:C,disabled:u.isPending||m.isPending}),(e==null?void 0:e.homepage)!==i.uuid&&i.type==="STATIC"?t.jsxRuntimeExports.jsx(h.Form,{formData:a,properties:v,onChange:A,disabled:u.isPending||m.isPending}):i.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(M.HomeIcon,{})," This is homepage"," "]}),s.type==="DYNAMIC"&&!E((s==null?void 0:s.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(H.Button,{className:"w-full",type:"submit",onClick:S,disabled:(e==null?void 0:e.homepage)!==i.uuid&&a.isHomePage?!1:c.isEmpty(s.name)||c.isEmpty(s.slug)||!j||u.isPending||m.isPending||s.type==="DYNAMIC"&&!E((s==null?void 0:s.slug)||""),children:"Save"}),t.jsxRuntimeExports.jsx(B,{pageData:i,projectData:e})]})]})})]})};exports.default=F;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { X as a, Y as n } from "./index-32519c31.js";
|
|
2
|
-
import "react-i18next";
|
|
3
|
-
import { t as i } from "./useBuilderProp-81a14920.js";
|
|
4
|
-
const f = () => {
|
|
5
|
-
const [t] = ["SAVED"], [r, s] = a(), u = n();
|
|
6
|
-
return (e) => t === "UNSAVED" ? (i({ variant: "destructive", title: "Please save unsaved changes" }), !1) : r === e.uuid ? !1 : (u(), setTimeout(() => {
|
|
7
|
-
s(e.uuid);
|
|
8
|
-
}, 100), !0);
|
|
9
|
-
};
|
|
10
|
-
export {
|
|
11
|
-
f as u
|
|
12
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const r=require("./index-1217461b.cjs");require("react-i18next");const a=require("./useBuilderProp-5e57d0c8.cjs"),i=()=>{const[t]=["SAVED"],[u,s]=r.useCurrentPage(),n=r.useBuilderReset();return e=>t==="UNSAVED"?(a.toast({variant:"destructive",title:"Please save unsaved changes"}),!1):u===e.uuid?!1:(n(),setTimeout(()=>{s(e.uuid)},100),!0)};exports.useChangePage=i;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./index-1217461b.cjs"),a=require("sonner"),i=require("./useChangePage-f22cea36.cjs"),r=()=>{const u=e.useQueryClient(),s=i.useChangePage(),n=e.useApiBaseUrl();return e.useMutation({mutationFn:async t=>fetch(`${n}/pages`,{method:"POST",body:JSON.stringify(t)}).then(c=>c.json()),onSuccess:t=>{u.invalidateQueries({queryKey:["pages"]}),s({uuid:t.uuid,slug:t.slug}),a.toast.success("Page added successfully.")}})},o=()=>{const u=e.useApiBaseUrl();return e.useMutation({mutationFn:async s=>fetch(`${u}/page?uuid=${s.uuid}`,{method:"PUT",body:JSON.stringify(s)})})},d=()=>{const u=e.useQueryClient(),s=e.useApiBaseUrl();return e.useMutation({mutationFn:async n=>fetch(`${s}/page?uuid=${n.uuid}`,{method:"DELETE"}),onSuccess:()=>{a.toast.success("Page deleted successfully."),u.invalidateQueries({queryKey:["pages"]})}})};exports.useAddPage=r;exports.useDeletePage=d;exports.useUpdatePage=o;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { $ as a, a0 as n, _ as c } from "./index-32519c31.js";
|
|
2
|
-
import { toast as i } from "sonner";
|
|
3
|
-
import { u as r } from "./useChangePage-6a7c7374.js";
|
|
4
|
-
const y = () => {
|
|
5
|
-
const s = c(), e = r(), t = a();
|
|
6
|
-
return n({
|
|
7
|
-
mutationFn: async (u) => fetch(`${t}/pages`, {
|
|
8
|
-
method: "POST",
|
|
9
|
-
body: JSON.stringify(u)
|
|
10
|
-
}).then((o) => o.json()),
|
|
11
|
-
onSuccess: (u) => {
|
|
12
|
-
s.invalidateQueries({ queryKey: ["pages"] }), e({ uuid: u.uuid, slug: u.slug }), i.success("Page added successfully.");
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}, m = () => {
|
|
16
|
-
const s = a();
|
|
17
|
-
return n({
|
|
18
|
-
mutationFn: async (e) => fetch(`${s}/page?uuid=${e.uuid}`, {
|
|
19
|
-
method: "PUT",
|
|
20
|
-
body: JSON.stringify(e)
|
|
21
|
-
})
|
|
22
|
-
});
|
|
23
|
-
}, f = () => {
|
|
24
|
-
const s = c(), e = a();
|
|
25
|
-
return n({
|
|
26
|
-
mutationFn: async (t) => fetch(`${e}/page?uuid=${t.uuid}`, {
|
|
27
|
-
method: "DELETE"
|
|
28
|
-
}),
|
|
29
|
-
onSuccess: () => {
|
|
30
|
-
i.success("Page deleted successfully."), s.invalidateQueries({ queryKey: ["pages"] });
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
export {
|
|
35
|
-
m as a,
|
|
36
|
-
f as b,
|
|
37
|
-
y as u
|
|
38
|
-
};
|