@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
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var Hs=(e,t,s)=>{if(!t.has(e))throw TypeError("Cannot "+s)};var a=(e,t,s)=>(Hs(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)=>(Hs(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s);var ys=(e,t,s,n)=>({set _(r){k(e,t,r,s)},get _(){return a(e,t,n)}}),K=(e,t,s)=>(Hs(e,t,"access private method"),s);const C=require("./jsx-runtime-5c3ac4f7.cjs"),Eo=require("i18next"),ko=require("react-i18next"),Ao=require("flagged"),L=require("react"),Po=require("react-dnd"),d=require("lodash"),Kn=require("@minoru/react-dnd-treeview"),fe=require("./useBuilderProp-5e57d0c8.cjs"),y=require("jotai"),Co=require("./utils-3c452dd0.cjs"),De=require("react-hotkeys-hook"),Wr=require("flat-to-nested"),he=require("./Class-6c695ccb.cjs"),zt=require("redux-undo"),jo=require("@react-hookz/web"),ue=require("./MODIFIERS-70fef873.cjs"),Jr=require("@chaibuilder/blocks"),ot=require("sonner"),zn=require("@radix-ui/react-icons"),Oo=require("lucide-react");function _o(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=_o(L),Bo="Dark mode",Ro="This page has no blocks. Add a block by clicking the + button",Io="This page is empty",Do="Please select a block to edit settings or styles",Mo="Please select a styling block",Lo="Drop your block here",No={dark_mode:Bo,tree_view_no_blocks:Ro,canvas_empty:Io,no_block_selected_for_styling:Do,no_styling_block_selected:Mo,drop_here_message:Lo};Eo.use(ko.initReactI18next).init({resources:{en:{translation:No}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});const To="";const Uo={};class Yr 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?C.jsxRuntimeExports.jsx("h1",{children:"Something went wrong."}):this.props.children}}const qo=e=>{const t=e.replace(ue.STYLES_KEY,"").split(",");return{baseClasses:t[0],classes:t[1]}};let Fo=0;function Ne(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 Gn=e=>"init"in e,Hn=e=>!!e.write,Os=new WeakMap,$o=(e,t)=>{Os.set(e,t),e.catch(()=>{}).finally(()=>Os.delete(e))},Wn=(e,t)=>{const s=Os.get(e);s&&(Os.delete(e),s(t))},Jn=(e,t)=>{e.status="fulfilled",e.value=t},Yn=(e,t)=>{e.status="rejected",e.reason=t},Vo=e=>typeof(e==null?void 0:e.then)=="function",Vt=(e,t)=>"v"in e&&"v"in t&&Object.is(e.v,t.v),Zn=(e,t)=>"e"in e&&"e"in t&&Object.is(e.e,t.e),dt=e=>"v"in e&&e.v instanceof Promise,Qo=(e,t)=>"v"in e&&"v"in t&&e.v.orig&&e.v.orig===t.v.orig,vs=e=>{if("e"in e)throw e.e;return e.v},Ko=()=>{const e=new WeakMap,t=new WeakMap,s=new Map;let n,r,i;const o=m=>e.get(m),u=(m,x)=>{const R=e.get(m);if(e.set(m,x),s.has(m)||s.set(m,R),R&&dt(R)){const S="v"in x?x.v instanceof Promise?x.v:Promise.resolve(x.v):Promise.reject(x.e);Wn(R.v,S)}},l=(m,x,R)=>{const S=new Map;let D=!1;R.forEach((O,w)=>{!O&&w===m&&(O=x),O&&(S.set(w,O),x.d.get(w)!==O&&(D=!0))}),(D||x.d.size!==S.size)&&(x.d=S)},c=(m,x,R)=>{const S=o(m),D={d:(S==null?void 0:S.d)||new Map,v:x};if(R&&l(m,D,R),S&&Vt(S,D)&&S.d===D.d)return S;if(S&&dt(S)&&dt(D)&&Qo(S,D)){if(S.d===D.d)return S;D.v=S.v}return u(m,D),D},h=(m,x,R,S)=>{if(Vo(x)){let D;const O=new Promise((w,z)=>{let Q=!1;x.then(W=>{if(!Q){Q=!0;const f=o(m),p=c(m,O,R);Jn(O,W),w(W),(f==null?void 0:f.d)!==p.d&&F(m,p,f==null?void 0:f.d)}},W=>{if(!Q){Q=!0;const f=o(m),p=c(m,O,R);Yn(O,W),z(W),(f==null?void 0:f.d)!==p.d&&F(m,p,f==null?void 0:f.d)}}),D=W=>{Q||(Q=!0,W.then(f=>Jn(O,f),f=>Yn(O,f)),w(W))}});return O.orig=x,O.status="pending",$o(O,w=>{w&&D(w),S==null||S()}),c(m,O,R)}return c(m,x,R)},g=(m,x,R)=>{const S=o(m),D={d:(S==null?void 0:S.d)||new Map,e:x};return R&&l(m,D,R),S&&Zn(S,D)&&S.d===D.d?S:(u(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&&!dt(f)&&Vt(f,W)})))return x;const R=new Map;let S=!0;const D=Q=>{if(Q===m){const f=o(Q);if(f)return R.set(Q,f),vs(f);if(Gn(Q))return R.set(Q,void 0),Q.init;throw new Error("no atom init")}const W=A(Q);return R.set(Q,W),vs(W)};let O,w;const z={get signal(){return O||(O=new AbortController),O.signal},get setSelf(){return!w&&Hn(m)&&(w=(...Q)=>{if(!S)return M(m,...Q)}),w}};try{const Q=m.read(D,z);return h(m,Q,R,()=>O==null?void 0:O.abort())}catch(Q){return g(m,Q,R)}finally{S=!1}},v=m=>vs(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)},j=m=>{const x=new Map,R=new WeakMap,S=O=>{const w=t.get(O);w==null||w.t.forEach(z=>{z!==O&&(x.set(z,(x.get(z)||new Set).add(O)),R.set(z,(R.get(z)||0)+1),S(z))})};S(m);const D=O=>{const w=t.get(O);w==null||w.t.forEach(z=>{var Q;if(z!==O){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||!Vt(p,T)}f||x.forEach(p=>p.delete(z))}D(z)}})};D(m)},U=(m,...x)=>{let R=!0;const S=w=>vs(A(w)),D=(w,...z)=>{let Q;if(w===m){if(!Gn(w))throw new Error("atom not writable");const W=o(w),f=h(w,z[0]);(!W||!Vt(W,f))&&j(w)}else Q=U(w,...z);if(!R){const W=q()}return Q},O=m.write(S,D,...x);return R=!1,O},M=(m,...x)=>{const R=U(m,...x),S=q();return R},E=(m,x)=>{const R={t:new Set(x&&[x]),l:new Set};if(t.set(m,R),A(m).d.forEach((S,D)=>{const O=t.get(D);O?O.t.add(m):D!==m&&E(D,m)}),A(m),Hn(m)&&m.onMount){const S=m.onMount((...D)=>M(m,...D));S&&(R.u=S)}return R},P=m=>{var x;const R=(x=t.get(m))==null?void 0:x.u;R&&R(),t.delete(m);const S=o(m);S&&(dt(S)&&Wn(S.v),S.d.forEach((D,O)=>{if(O!==m){const w=t.get(O);w&&(w.t.delete(m),B(O,w)&&P(O))}}))},F=(m,x,R)=>{const S=new Set(x.d.keys());R==null||R.forEach((D,O)=>{if(S.has(O)){S.delete(O);return}const w=t.get(O);w&&(w.t.delete(m),B(O,w)&&P(O))}),S.forEach(D=>{const O=t.get(D);O?O.t.add(m):t.has(m)&&E(D,m)})},q=()=>{let m;for(;s.size;){const x=Array.from(s);s.clear(),x.forEach(([R,S])=>{const D=o(R);if(D){D.d!==(S==null?void 0:S.d)&&F(R,D,S==null?void 0:S.d);const O=t.get(R);O&&!(S&&!dt(S)&&(Vt(S,D)||Zn(S,D)))&&O.l.forEach(w=>w())}})}};return{get:v,set:M,sub:(m,x)=>{const R=_(m),S=q(),D=R.l;return D.add(x),()=>{D.delete(x),b(m)}}}};let Ws;const zo=()=>(Ws||(Ws=Ko()),Ws),Go=Symbol();function Ho(e,t){const s=Ne(e,(n,r,i)=>r(s,t(n(s),i)));return s}const Xn=(e,t,s)=>(t.has(s)?t:t.set(s,e())).get(s),Wo=new WeakMap,Jo=(e,t,s)=>{const n=Xn(()=>new WeakMap,Wo,t);return Xn(e,n,s)},Yo={},er=e=>!!e.write,Zo=e=>typeof e=="function";function Xo(e,t){return Jo(()=>{const s=new WeakMap,n=(o,u)=>{let l=s.get(o);if(l)return l;const c=u&&s.get(u),h=[],g=[];return o.forEach((A,v)=>{const _=t?t(A):v;g[v]=_;const B=c&&c.atomList[c.keyList.indexOf(_)];if(B){h[v]=B;return}const b=U=>{const M=U(r),E=U(e),F=n(E,M==null?void 0:M.arr).keyList.indexOf(_);if(F<0||F>=E.length){const q=o[n(o).keyList.indexOf(_)];if(q)return q;throw new Error("splitAtom: index out of bounds for read")}return E[F]},j=(U,M,E)=>{const P=U(r),F=U(e),N=n(F,P==null?void 0:P.arr).keyList.indexOf(_);if(N<0||N>=F.length)throw new Error("splitAtom: index out of bounds for write");const m=Zo(E)?E(F[N]):E;M(e,[...F.slice(0,N),m,...F.slice(N+1)])};h[v]=er(e)?Ne(b,j):Ne(b)}),c&&c.keyList.length===g.length&&c.keyList.every((A,v)=>A===g[v])?l=c:l={arr:o,atomList:h,keyList:g},s.set(o,l),l},r=Ne(o=>{const u=o(r),l=o(e);return n(l,u==null?void 0:u.arr)});r.init=void 0;const i=er(e)?Ne(o=>o(r).atomList,(o,u,l)=>{switch(l.type){case"remove":{const c=o(i).indexOf(l.atom);if(c>=0){const h=o(e);u(e,[...h.slice(0,c),...h.slice(c+1)])}break}case"insert":{const c=l.before?o(i).indexOf(l.before):o(i).length;if(c>=0){const h=o(e);u(e,[...h.slice(0,c),l.value,...h.slice(c)])}break}case"move":{const c=o(i).indexOf(l.atom),h=l.before?o(i).indexOf(l.before):o(i).length;if(c>=0&&h>=0){const g=o(e);c<h?u(e,[...g.slice(0,c),...g.slice(c+1,h),g[c],...g.slice(h)]):u(e,[...g.slice(0,h),g[c],...g.slice(h,c),...g.slice(c+1)])}break}}}):Ne(o=>o(r).atomList);return i},e,t||Yo)}const ea=e=>typeof(e==null?void 0:e.then)=="function";function ta(e){let t,s;const n={getItem:(r,i)=>{var o,u;const l=h=>{if(h=h||"",t!==h){try{s=JSON.parse(h)}catch{return i}t=h}return s},c=(u=(o=e())==null?void 0:o.getItem(r))!=null?u:null;return ea(c)?c.then(l):l(c)},setItem:(r,i)=>{var o;return(o=e())==null?void 0:o.setItem(r,JSON.stringify(i))},removeItem:r=>{var i;return(i=e())==null?void 0:i.removeItem(r)}};return typeof window<"u"&&typeof window.addEventListener=="function"&&(n.subscribe=(r,i,o)=>{if(!(e()instanceof window.Storage))return()=>{};const u=l=>{if(l.storageArea===e()&&l.key===r){let c;try{c=JSON.parse(l.newValue||"")}catch{c=o}i(c)}};return window.addEventListener("storage",u),()=>{window.removeEventListener("storage",u)}}),n}const sa=ta(()=>typeof window<"u"?window.localStorage:void 0);function lt(e,t,s=sa,n){const r=n==null?void 0:n.unstable_getOnInit,i=Ne(r?s.getItem(e,t):t);return i.onMount=u=>{r||u(s.getItem(e,t));let l;return s.subscribe&&(l=s.subscribe(e,u,t)),l},Ne(u=>u(i),(u,l,c)=>{const h=typeof c=="function"?c(u(i)):c;return h===Go?(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 na=L.createContext(void 0),Zr=e=>{const t=L.useContext(na);return(e==null?void 0:e.store)||t||zo()},ra=e=>typeof(e==null?void 0:e.then)=="function",ia=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 oa(e,t){const s=Zr(t),[[n,r,i],o]=L.useReducer(c=>{const h=s.get(e);return Object.is(c[0],h)&&c[1]===s&&c[2]===e?c:[h,s,e]},void 0,()=>[s.get(e),s,e]);let u=n;(r!==s||i!==e)&&(o(),u=s.get(e));const l=t==null?void 0:t.delay;return L.useEffect(()=>{const c=s.sub(e,()=>{if(typeof l=="number"){setTimeout(o,l);return}o()});return o(),c},[s,e,l]),L.useDebugValue(u),ra(u)?ia(u):u}function aa(e,t){const s=Zr(t);return L.useCallback((...r)=>s.set(e,...r),[s,e])}function ua(e,t){return[oa(e,t),aa(e,t)]}const ca=new Wr({children:"blockNodes"}),Xr=(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,...Xr(n,s._id)])}return s}));function ei(e,t,s){const n=d.filter(e,i=>i._parent===t),r=[];for(let i=0;i<n.length;i++){const o=ti(n[i]);if(Object.keys(o).length>0&&Object.keys(o).forEach(u=>{n[i][u]=`slot:${he.generateUUID()}`}),d.filter(e,{_parent:n[i]._id}).length>0){const u=he.generateUUID();r.push({...n[i],oldId:n[i]._id,_id:u,_parent:s}),r.push(d.flatten(ei(e,n[i]._id,u)))}else r.push({...n[i],oldId:n[i]._id,_id:he.generateUUID(),_parent:s})}return d.flatten(r)}function la(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 ti=e=>{const t={};return Object.keys(e).forEach(s=>{d.isString(e[s])&&e[s].startsWith("slot")&&(t[s]=e[s].replace("slot:",""))}),t},da=(e,t,s=null)=>{let n=d.find(e,{_id:t});n={...n,oldId:n._id,_id:he.generateUUID()},s&&(n={...n,_parent:s});const r=[n];d.filter(e,{_parent:t}).length>0&&r.push(d.flatten(ei(e,t,n._id)));const i=d.flatten(r);return d.map(i,o=>{const u=o,l=ti(u);return Object.keys(l).length>0&&Object.keys(l).forEach(c=>{const h=d.find(i,{oldId:l[c].replace("slot:","")});u[c]=`slot:${h._id}`}),d.omit(u,["global","oldId"])})},fa=zt((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:zt.excludeAction(["update_props_realtime","add_duplicate_blocks","set_page_blocks"])}),Ls=Ho({past:[],present:[],future:[]},fa);Ls.debugLabel="pageBlocksAtom";const be=y.atom(e=>{var t;return(t=e(Ls))==null?void 0:t.present});be.debugLabel="presentBlocksAtom";const xn=Xo(be);xn.debugLabel="pageBlocksAtomsAtom";const si=y.atom(e=>la(e(be)));si.debugLabel="pageBlocksTreeAtom";const ha=y.atom("");ha.debugLabel="builderActivePageAtom";const pa=y.atom(-1);pa.debugLabel="destinationDropIndexAtom";const ni=y.atom(!1);ni.debugLabel="addBlocksModalAtom";const xe=()=>{const[,e]=y.useAtom(Ls);return e},ma=()=>{const e=xe(),t=y.useAtomValue(si),s=L.useCallback(n=>{const r=Xr(n);e({type:"set_page_blocks",payload:r})},[e]);return[t,s]},ri=()=>{const e=xe();return[L.useCallback(s=>{e({type:"set_page_blocks",payload:s})},[e])]},tn=e=>["Box","Slot","Form","DataContext","Link","List","ListItem","Row","Column","Table","TableCell"].includes(e),ga=e=>!["Slot"].includes(e),ya=e=>!["Slot"].includes(e);function va(e,t){return e==="Slot"||t==="List"&&e!=="ListItem"||t==="Row"&&e!=="Column"?!1:tn(t)}const ba=(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:va(n,r)},Sn=y.atom([]);Sn.debugLabel="selectedBlockIdsAtom";const wn=y.atom(e=>{const t=e(be),s=e(Sn);return d.map(d.filter(t,({_id:n})=>d.includes(s,n)),n=>({...n}))});wn.debugLabel="selectedBlocksAtom";const En=y.atom(e=>{const t=e(wn);return t.length===0?null:t.length===1?t[0]:{type:"Multiple",id:d.map(t,"id")}});En.debugLabel="selectedBlockAtom";const xa=e=>d.get(e,"parent",null),Sa=y.atom(e=>{const t=e(wn),s=d.map(t,xa);return d.filter(e(be),n=>d.includes(s,n._id))});Sa.debugLabel="selectedBlocksParentsAtom";const ii=y.atom(()=>!1);ii.debugLabel="selectedBlockFlexChildAtom";const oi=y.atom(()=>!1);oi.debugLabel="selectedBlockGridChildAtom";const kn=y.atom("");kn.debugLabel="styleStateAtom";const ai=lt("styleBreakpoint","xs");ai.debugLabel="styleBreakpointAtom";const wa=()=>({flexChild:y.useAtomValue(ii),gridChild:y.useAtomValue(oi)}),Ea=()=>y.useAtomValue(En),He=()=>{const[e,t]=y.useAtom(Sn),s=L.useCallback(n=>{t(r=>d.includes(r,n)?d.without(r,n):[...r,n])},[t]);return[e,t,s]},sn=(e,t="")=>{switch(e.type){case"singular":return e.uiSchema;case"model":const{properties:s}=e,n={};return Object.keys(s).forEach(o=>{const u=s[o];if(d.includes(["slot","styles"],u.type))return;const l=d.get(u,"i18n",!1)?`${o}-${t}`:o;n[l]=sn(u,t)}),n;case"list":const{itemProperties:r}=e,i={items:{}};return Object.keys(r).forEach(o=>{const u=r[o];if(d.includes(["slot","styles"],u.type))return;const l=d.get(u,"i18n",!1)?`${o}-${t}`:o;i.items[l]=sn(u,t)}),i;default:return{}}},nn=(e,t="")=>{switch(e.type){case"singular":return e.schema;case"model":const{properties:s,title:n}=e,r={title:n,type:"object",properties:{}};return Object.keys(s).forEach(l=>{const c=s[l];if(d.includes(["slot","styles"],c.type))return;const h=d.get(c,"i18n",!1)?`${l}-${t}`:l;r.properties[h]=nn(c,t)}),r;case"list":const{itemProperties:i,title:o}=e,u={title:o,type:"array",items:{type:"object",properties:{}}};return Object.keys(i).forEach(l=>{const c=i[l];if(d.includes(["slot","styles"],c.type))return;const h=d.get(c,"i18n",!1)?`${l}-${t}`:l;u.items.properties[h]=nn(c,t),d.set(u.items,"title",d.get(c,"itemTitle",`${o} item`))}),u;default:return{}}},ui=e=>{const t={};return Object.keys(e).forEach(s=>{t[s]=Aa(e[s])}),t},ka=e=>{if(d.isEmpty(e.default))return[];const{itemProperties:t}=e;return d.map(e.default,s=>{const n={...s};return d.forIn(s,(r,i)=>{d.has(t,i)&&d.get(t[i],"i18n",!1)&&(n[i]=ue.I18N_KEY)}),n})},Aa=e=>{switch(e.type){case"styles":return e.default;case"slot":return`${ue.SLOT_KEY}${he.generateUUID()}`;case"singular":const{i18n:t,schema:s}=e;return t?ue.I18N_KEY:d.get(s,"default","");case"model":return ui(e.properties);case"list":return ka(e);default:return""}},ci=()=>y.useAtomValue(be);function tr(e,t,s,n,r){if(t===null)return[...e,...n];if(s!==null){const l=d.findIndex(e,{_parent:t}),c=(l===-1?0:l)+s;return e.splice(c,0,...n),e}if(!r){const c=d.findIndex(e,{_id:t})+1;return e.splice(c,0,...n),e}let i=d.findIndex(e,{_id:t});const o=d.filter(e,{_parent:t});d.isEmpty(o)||(i=d.findIndex(e,{_id:d.last(o)._id}));const u=i+1;return e.splice(u,0,...n),e}const Pa=()=>{const e=xe(),t=ci(),[,s]=He(),n=L.useCallback((i,o,u)=>{var h;for(let g=0;g<i.length;g++){const{_id:A}=i[g];i[g]._id=he.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 c=l?tn(l._type):!0;return!c&&l&&(i[0]._parent=l._parent),e({type:"set_blocks",payload:tr(t,o||null,u||null,i,c)}),s([(h=d.first(i))==null?void 0:h._id]),d.first(i)},[t,e,s]);return{addCoreBlock:L.useCallback((i,o,u)=>{if(d.has(i,"blocks")){const B=i.blocks;return n(B,o,u)}const l=he.generateUUID(),c=ui(i.props),h=[];d.forIn(c,(B,b)=>{if(d.startsWith(B,ue.SLOT_KEY)){const j=B.replace(ue.SLOT_KEY,"");h.push({_id:j,_type:"Slot",_parent:l,_name:i.props[b].name,_styles:i.props[b].styles,_emptyStyles:i.props[b].emptyStyles})}});const g={_type:i.type,_id:l,...c};let A;o&&(A=d.find(t,{_id:o}),g._parent=o);const v=A?tn(A._type):!0;!v&&A&&(g._parent=A._parent);const _=[g,...h];return e({type:"set_blocks",payload:tr(t,o||null,u||null,_,v)}),s([g._id]),g},[n,t,e,s]),addPredefinedBlock:n}},sr={xs:420,sm:620,md:768,lg:1024,xl:1280,"2xl":1536},nr=["xs","sm","md","lg","xl","2xl"];function Ca(e,t){if(t===null)return"baseClasses";const s=t.mq;if(s==="xs"||t.dark||t.mod!=="")return"classes";let n="baseClasses",r=nr.indexOf(s);for(;r>0;){const i=nr[r-1];if(d.find(e,{mq:i,property:t.property})){n="classes";break}r--}return n}const rr=[];function ja(e="",t="",s=[]){e=e.trim().replace(/ +/g,"");let n=d.filter(d.map(e.split(" "),he.constructClassObject),c=>!d.isNull(c)),r=d.filter(d.map(t.split(" "),he.constructClassObject),c=>!d.isNull(c));r=d.filter(r,c=>!d.includes(rr,c.property));const i=[],o=[];d.each(s,c=>{const h=he.constructClassObject(c),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)),Ca(n,h)==="baseClasses"&&!d.includes(rr,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 u=d.map(d.sortBy([...n,...i],c=>sr[c.mq]),"fullCls").join(" ");return`${d.map(d.sortBy([...r,...o],c=>sr[c.mq]),"fullCls").join(" ").trim()},${u.trim()}`.trim().replace(/ +/g,"")}const fs=y.atom([]);fs.debugLabel="selectedStylingBlocksAtom";const An=()=>y.useAtom(fs),Oa=e=>{const t=e.replace(ue.STYLES_KEY,"").split(",");return{baseClasses:t[0],classes:t[1]}},_a=y.atom(null,(e,t,{blockIds:s,newClasses:n,dispatch:r})=>{const i=d.filter(e(xn),u=>s.includes(e(u)._id)),o=d.first(e(fs));d.each(i,u=>{const l=e(u),c=d.get(l,o.prop,`${ue.STYLES_KEY},`),{baseClasses:h,classes:g}=Oa(c);r({type:"update_props_realtime",payload:{ids:[l._id],props:{[o.prop]:`${ue.STYLES_KEY}${ja(g,h,n)}`}}})})}),Ba=()=>{const e=xe(),t=y.useSetAtom(_a);return L.useCallback((s,n,r)=>{t({blockIds:s,newClasses:n,dispatch:e}),r&&setTimeout(()=>e({type:"create_snapshot"}),500)},[e,t])},li=y.atom([]);li.debugLabel="buildingBlocksAtom";const Ra=y.atom(e=>{const t=e(li);return d.filter(t,s=>d.has(s,"blockId"))}),Ia=()=>{},di=()=>{const e=Jr.useChaiBlocks(),t=y.useAtomValue(Ra),s=()=>{},n=L.useCallback(()=>Ia(),[]);return[e,t,s,n]},Da=y.atom(!1),Pn=()=>{const[e,t]=y.useAtom(Da);return[e,t]},Ma=y.atom(ue.BRANDING_OPTIONS_DEFAULTS),Cn=()=>{const[e,t]=y.useAtom(Ma);return[d.isObject(e)?{...e,...ue.BRANDING_OPTIONS_DEFAULTS}:ue.BRANDING_OPTIONS_DEFAULTS,t]},La=y.atom(null),fi=()=>({currentPage:y.useAtomValue(La)}),hi=new Wr({});function Na(e){let t=hi.convert(e);return t=!t.type&&t.children&&t.children.length?t.children:d.isEmpty(t)?[]:[t],t}const jn=(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,...jn(n,s._id)])}return s}));function On(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&&On(n.children)}}function pi(e){let t=[],s=d.filter(e,{type:"GlobalBlock"});return s.length>0&&(s=d.map(s,mi),d.each(s,n=>{t=[...t,...Ta(n)]})),t}function Ta(e){let t=[];const s=d.get(d.first(e),"parent",null);d.set(d.first(e),"parent",null);const n=[hi.convert(gi(e))];On(n,!0);let r=jn(n,e[0]._id);return r=d.set(r,"0.parent",s),t=[...t,r,...pi(r)],t}function mi(e){const t=d.find(rn,{_id:e._id});if(!t)return[];const s=[t],n=d.filter(rn,{_parent:e._id});return n.length?d.flatten([...s,...d.flatten(d.map(n,mi))]):d.flatten(s)}const gi=e=>JSON.parse(JSON.stringify(e));let rn=[];function Ua(e){rn=e;const t=Na(gi(e));On(t);const s=jn(t,null),n=pi(s),r={};return d.each(n,i=>d.set(r,d.first(i).blockId,i)),[s,r]}const _n=()=>{const[e]=Cn(),{currentPage:t}=fi(),s=y.useAtomValue(be);return L.useCallback(()=>{const n=d.map(s,o=>d.omit(o,["expanded","order","title","siblings","tempClasses"])),[r=[],i=[]]=Ua(n);return{currentPage:t,blocks:r,globalBlocks:i}},[e,t,s])};lt("blockStylingActiveTab",1);y.atom([]);const yi=y.atom(!1);yi.debugLabel="readOnlyModeAtom";const vi=y.atom(!1);vi.debugLabel="inlineEditingActiveAtom";const bi=y.atom(!1);bi.debugLabel="advanceStylingOpenAtom";const xi=y.atom("online");xi.debugLabel="networkModeAtom";lt("currentUiLibrary","");const qa=y.atom(!1);qa.debugLabel="codeEditorOpenAtom";const Si=y.atom(!1);Si.debugLabel="editLayerNameAtom";const Fa=y.atom("");Fa.debugLabel="activeLanguageAtom";const $a=y.atom("");$a.debugLabel="primaryLanguageAtom";const wi=y.atom(null);wi.debugLabel="canvasIframeAtom";const Ei=y.atom("layers");Ei.debugLabel="activePanelAtom";const ki=y.atom(!1);ki.debugLabel="addBlockOffCanvasAtom";const Ai=y.atom("");Ai.debugLabel="showPredefinedBlockCategoryAtom";const Ns=y.atom({undoCount:0,redoCount:0});Ns.debugLabel="historyStatesAtom";const Ts=y.atom("SAVED");Ts.debugLabel="pageSyncStateAtom";const Va=()=>{const[e,t]=y.useAtom(Ts),s=fe.useBuilderProp("onSaveBlocks",async()=>{}),n=fe.useBuilderProp("onSyncStatusChange",()=>{}),r=_n(),i=y.useSetAtom(Ns),{undoCount:o,redoCount:u}=hs();return{savePage:jo.useThrottledCallback(async()=>{t("SAVING"),n("SAVING");const c=r();return await s({blocks:c.blocks,identifier:"pageData.id"}),setTimeout(()=>{i({undoCount:o,redoCount:u}),t("SAVED"),n("SAVED")},100),!0},[r,t,n,s],5e3),syncState:e,setSyncState:t}},hs=()=>{const e=y.useAtomValue(Ls),[{undoCount:t,redoCount:s}]=y.useAtom(Ns),n=xe(),[r]=Pn(),[,i]=He(),[,o]=An(),[,u]=y.useAtom(Ts),l=fe.useBuilderProp("onSyncStatusChange",()=>{}),c=L.useCallback(()=>{n({type:"create_snapshot"})},[n]);return L.useEffect(()=>{t!==(e==null?void 0:e.past.length)||s!==(e==null?void 0:e.future.length)?(u("UNSAVED"),l("UNSAVED")):t===(e==null?void 0:e.past.length)&&s===(e==null?void 0:e.future.length)&&(u("SAVED"),l("SAVED"))},[e==null?void 0:e.past.length,e==null?void 0:e.future.length,t,s,l,u]),{undoCount:e==null?void 0:e.past.length,redoCount:e==null?void 0:e.future.length,undo:L.useCallback(()=>{r||(n(zt.ActionCreators.undo()),setTimeout(()=>{o([]),i([])},200))},[n,r,u]),redo:L.useCallback(()=>{r||(n(zt.ActionCreators.redo()),setTimeout(()=>{o([]),i([])},200))},[r,n]),clear:()=>{n(zt.ActionCreators.clearHistory())},createSnapshot:c}},Pi=()=>y.useAtom(ai),Ci=lt("canvasWidth",360),ji=y.atom(e=>{const t=e(Ci);return he.getBreakpointValue(t).toLowerCase()}),Qa=()=>{const[e,t]=y.useAtom(Ci),s=y.useAtomValue(ji),[n,r]=Pi();return L.useEffect(()=>{n!=="xs"&&r(s)},[s,n,r]),[e,s,t]},Ka=lt("canvasZoom",100),za=()=>y.useAtom(Ka),Oi=y.atom([]),Bn=()=>{const[e,t]=y.useAtom(Oi),s=y.useSetAtom(Rn),n=L.useCallback(r=>{t(r),s([])},[t,s]);return[e,n]},Rn=y.atom([]),_i=()=>{const[e,t]=y.useAtom(Rn),s=y.useSetAtom(Oi),n=L.useCallback(r=>{t(r),s([])},[t,s]);return[e,n]},Bi=lt("darkMode",!1),Ga=()=>{const[e,t]=y.useAtom(Bi);return[e,t]},Ha=y.atom(!1),Wa=()=>{const[e,t]=y.useAtom(Ha);return[e,t]},In=()=>{const e=xe(),t=y.useAtomValue(be),[,s]=He();return L.useCallback((n,r=null)=>{const i=[];d.each(n,o=>{const l=da(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])},Ja=y.atom([]),Ya=()=>{const[e,t]=y.useAtom(Ja),s=L.useCallback(n=>{t(r=>d.includes(r,n)?d.without(r,n):[...r,n])},[t]);return[e,t,s]},Za=y.atom(""),Ri=()=>y.useAtom(Za),Xa=()=>{const e=y.useAtomValue(be),t=xe(),s=_n(),[,,n]=di();return L.useCallback(async(r,i)=>{const o=he.generateUUID(16),u=d.map(e,l=>(l._id===r&&(l._globalBlockId=o,l._name=i),l));t({type:"set_page_blocks",payload:u}),n()},[e,t,s,n])},eu=()=>({}),tu=()=>{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])},Ii=()=>{const e=y.useAtomValue(Rn),[t,s]=Bn(),n=In(),r=tu();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])}},su=y.atom(""),nu=()=>{const e=y.useAtomValue(su),t=L.useCallback(()=>{},[]),s=L.useCallback(()=>{},[]),n=L.useCallback(()=>{},[]);return{currentProject:e,createProject:n,deleteProject:t,updateProject:s}},Di=(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:Di(n,s)},Mi=()=>{const e=xe(),t=y.useAtomValue(be),[s,n]=He();return L.useCallback(r=>{var u;const i=((u=d.find(t,{_id:r[0]}))==null?void 0:u._parent)||null,o=Di(t,r);e({type:"set_blocks",payload:o}),n(i?[i]:[])},[t,n,e,s])},ru=y.atom(null,(e,t,{blockIds:s,fullClasses:n,dispatch:r})=>{const i=d.first(e(fs)),o=d.filter(e(xn),u=>s.includes(e(u)._id));d.each(o,u=>{const l=e(u),c=n;let{classes:h,baseClasses:g}=qo(d.get(l,i.prop,"styles:,"));d.each(c,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"],_)&&c.push(A.split(":").pop().trim())}),d.each(c,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]:`${ue.STYLES_KEY}${g},${h}`}}})})}),iu=()=>{const e=xe(),t=y.useSetAtom(ru);return L.useCallback((s,n)=>{t({blockIds:s,fullClasses:n,dispatch:e}),setTimeout(()=>e({type:"create_snapshot"}))},[e,t])},Li=y.atom(e=>{const t=d.first(e(fs)),s=e(En);if(!t||t.blockId!==d.get(s,"_id",null))return[];const r=d.get(s,t.prop,`${ue.STYLES_KEY},`).replace(ue.STYLES_KEY,"").split(",").join(" ");return d.filter(d.map(r.trim().split(" "),he.constructClassObject),i=>!d.isNull(i))}),ou=()=>y.useAtomValue(Li),ir={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},au=y.atom(e=>{const t=e(ji),s=e(kn),n=e(Bi),r=uu(t);let i=d.filter(e(Li),{mod:s});return d.startsWith(s,"_")||(i=d.filter(i,o=>r.includes(o.mq))),i=i.sort((o,u)=>ir[o.mq]-ir[u.mq]),n||(i=d.filter(i,{dark:!1})),i}),uu=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},cu=()=>y.useAtomValue(au),lu=()=>y.useAtom(kn),Ni=y.atom(null,(e,t,{blockIds:s,props:n,dispatch:r})=>{r({type:"update_props_realtime",payload:{ids:s,props:n}})}),du=()=>{const{createSnapshot:e}=hs(),t=xe(),s=y.useSetAtom(Ni);return L.useCallback((n,r)=>{s({blockIds:n,props:r,dispatch:t}),e()},[e,t,s])},fu=()=>{const e=xe(),t=y.useSetAtom(Ni);return L.useCallback((s,n)=>{t({blockIds:s,props:n,dispatch:e})},[e,t])},Ti={name:"",props:{},modalProps:{},backdropClose:!0},hu=y.atom(Ti),pu=()=>{const[e,t]=y.useAtom(hu),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(Ti)},[t,e]);return{activeModal:e,openModal:s,closeModal:n}},mu=()=>y.useAtomValue(yi),gu=y.atom(""),yu=y.atom(null),vu=()=>y.useAtom(gu),bu=()=>y.useAtom(yu),xu=lt("selectedBreakpoints",["XS","MD","XL"]),Su=()=>{const[e,t]=y.useAtom(xu);return[e,t]},Dn=()=>{const e=y.useSetAtom(Ns),{clear:t}=hs(),[,s]=He(),[,n]=Ri(),[,r]=An();return()=>{s([]),r([]),n(""),t(),e({undoCount:0,redoCount:0})}},wu=y.atom({en:{}}),Eu=()=>{const[e,t]=y.useAtom(wu),s=L.useCallback((n,r,i)=>{d.set(e,`${n}.${r}`,i),t(e)},[e,t]);return[e,s]},ku=(e,t)=>{const[s]=y.useAtom(fe.chaiBuilderPropsAtom);return d.get(s,e,t)},Au=y.atom([]),Pu=()=>{const[e,t]=L.useState(!1),[s,n]=y.useAtom(Au),r=fe.useBuilderProp("getUILibraryBlocks",()=>[]);return L.useEffect(()=>{(async()=>s.length>0||(t(!0),n(await r()),t(!1)))()},[]),{data:s,isLoading:e}},Cu=y.atom("en"),ju=y.atom("en"),Ou=y.atom(["en"]),Ui=()=>y.useAtom(Cu),_u=()=>y.useAtom(ju),Bu=()=>y.useAtom(Ou),Ru=(e,t)=>{const[s]=Ui(),n=`${e}${s?`-${s}`:""}`;return{content:d.get(t,n,d.get(t,e,"")),propKey:e}},Iu=()=>{const[e,t]=Pn(),s=fe.useBuilderProp("previewComponent");return C.jsxRuntimeExports.jsxs("div",{className:Co.cn("fixed inset-0 z-[999] bg-background",e?"block":"hidden"),children:[C.jsxRuntimeExports.jsx(fe.Button,{size:"sm",className:"absolute right-0 top-0 m-4",onClick:()=>t(!1),children:"Close Preview"}),C.jsxRuntimeExports.jsx("div",{children:s?C.jsxRuntimeExports.jsx(L.Suspense,{fallback:C.jsxRuntimeExports.jsx(fe.Skeleton,{className:"h-96 w-full"}),children:L.createElement(s)}):null})]})},Du=()=>{const[e,t]=He(),[,s]=_i(),n=Mi(),r=In(),[,i]=Bn(),{pasteBlocks:o}=Ii(),{undo:u,redo:l}=hs();De.useHotkeys("esc",()=>t([]),{},[t]),De.useHotkeys("ctrl+c,command+c",()=>s(e),{},[e,s]),De.useHotkeys("ctrl+d,command+d",()=>r(e),{preventDefault:!0},[e,r]),De.useHotkeys("ctrl+x,command+x",()=>i(e),{},[e,i]),De.useHotkeys("ctrl+v,command+v",()=>e.length===1?o(e[0]):null,{},[e,o]),De.useHotkeys("ctrl+z,command+z",()=>u(),{},[u]),De.useHotkeys("ctrl+y,command+y",()=>l(),{},[l]),De.useHotkeys("del, backspace",c=>{c.preventDefault(),n(e)},{},[e,n])},Mu=(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)},qi=y.atom([]),Lu=()=>{const[e]=He(),t=y.useAtomValue(be),[,s]=y.useAtom(qi);L.useEffect(()=>{let n=[];const r=d.first(e);d.isString(r)&&(n=[r,...Mu(t,r)]),s(n)},[e,t,s])},Nu=()=>y.useAtomValue(qi),Tu=L.lazy(()=>Promise.resolve().then(()=>require("./SidePanels-8a461fbd.cjs"))),Uu=L.lazy(()=>Promise.resolve().then(()=>require("./Topbar-e3b28705.cjs"))),qu=L.lazy(()=>Promise.resolve().then(()=>require("./CanvasArea-35fe4de9.cjs"))),Fu=L.lazy(()=>Promise.resolve().then(()=>require("./Settings-f533682d.cjs"))),$u=()=>{const[e]=ua(Ts),t=s=>{s.preventDefault()};return Du(),Lu(),L.useEffect(()=>(e!=="SAVED"?window.onbeforeunload=()=>"":window.onbeforeunload=null,()=>{window.onbeforeunload=null}),[e]),C.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-background text-foreground",children:C.jsxRuntimeExports.jsxs(fe.TooltipProvider,{children:[C.jsxRuntimeExports.jsxs("div",{onContextMenu:t,className:"flex h-screen flex-col overflow-hidden bg-background text-foreground",children:[C.jsxRuntimeExports.jsx("div",{className:"h-14 w-screen shrink-0 border-b border-border",children:C.jsxRuntimeExports.jsx(L.Suspense,{children:C.jsxRuntimeExports.jsx(Uu,{})})}),C.jsxRuntimeExports.jsxs("main",{className:"flex h-full flex-row",children:[C.jsxRuntimeExports.jsx("div",{className:"flex h-full w-fit border-border",children:C.jsxRuntimeExports.jsx(L.Suspense,{children:C.jsxRuntimeExports.jsx(Tu,{})})}),C.jsxRuntimeExports.jsx("div",{className:"h-full flex-1 bg-slate-800/20",children:C.jsxRuntimeExports.jsx(L.Suspense,{children:C.jsxRuntimeExports.jsx(qu,{})})}),C.jsxRuntimeExports.jsx("div",{className:"flex h-full w-[280px] min-w-[280px] border-l border-border",children:C.jsxRuntimeExports.jsx(L.Suspense,{children:C.jsxRuntimeExports.jsx(Fu,{})})})]})]}),C.jsxRuntimeExports.jsx(Iu,{})]})})},Vu=y.getDefaultStore();y.atom({});function or(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 bs="undefined",ar="object",Fi="any",$i="*",at="__",_s=typeof process<"u"?process:{};_s.env&&_s.env.NODE_ENV;var we=typeof document<"u";_s.versions!=null&&_s.versions.node!=null;typeof Deno<"u"&&Deno.core;we&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function Vi(e,t){return t.charAt(0)[e]()+t.slice(1)}var Qu=Vi.bind(null,"toUpperCase"),Ku=Vi.bind(null,"toLowerCase");function zu(e){return Qi(e)?Qu("null"):typeof e=="object"?Yu(e):Object.prototype.toString.call(e).slice(8,-1)}function Bs(e,t){t===void 0&&(t=!0);var s=zu(e);return t?Ku(s):s}function ps(e,t){return typeof t===e}var Oe=ps.bind(null,"function"),pt=ps.bind(null,"string"),ft=ps.bind(null,"undefined"),Gu=ps.bind(null,"boolean");ps.bind(null,"symbol");function Qi(e){return e===null}function Hu(e){return Bs(e)==="number"&&!isNaN(e)}function Wu(e){return Bs(e)==="array"}function de(e){if(!Ju(e))return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Ju(e){return e&&(typeof e=="object"||e!==null)}function Yu(e){return Oe(e.constructor)?e.constructor.name:null}function Zu(e){return e instanceof Error||pt(e.message)&&e.constructor&&Hu(e.constructor.stackTraceLimit)}function Ki(e,t){if(typeof t!="object"||Qi(t))return!1;if(t instanceof e)return!0;var s=Bs(new e(""));if(Zu(t))for(;t;){if(Bs(t)===s)return!0;t=Object.getPrototypeOf(t)}return!1}Ki.bind(null,TypeError);Ki.bind(null,SyntaxError);function Us(e,t){var s=e instanceof Element||e instanceof HTMLDocument;return s&&t?Xu(e,t):s}function Xu(e,t){return t===void 0&&(t=""),e&&e.nodeName===t.toUpperCase()}function qs(e){var t=[].slice.call(arguments,1);return function(){return e.apply(void 0,[].slice.call(arguments).concat(t))}}qs(Us,"form");qs(Us,"button");qs(Us,"input");qs(Us,"select");function ur(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function ec(){if(we){var e=navigator,t=e.languages;return e.userLanguage||(t&&t.length?t[0]:e.language)}}function tc(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function sc(e){return function(t){for(var s,n=Object.create(null),r=/([^&=]+)=?([^&]*)/g;s=r.exec(t);){var i=ur(s[1]),o=ur(s[2]);i.substring(i.length-2)==="[]"?(n[i=i.substring(0,i.length-2)]||(n[i]=[])).push(o):n[i]=o===""||o}for(var u in n){var l=u.split("[");l.length>1&&(nc(n,l.map(function(c){return c.replace(/[?[\]\\ ]/g,"")}),n[u]),delete n[u])}return n}(function(t){if(t){var s=t.match(/\?(.*)/);return s&&s[1]?s[1].split("#")[0]:""}return we&&window.location.search.substring(1)}(e))}function nc(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 Fs(){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 Gt="global",Dt=at+"global"+at,Mt=typeof self===ar&&self.self===self&&self||typeof global===ar&&global.global===global&&global||void 0;function ut(e){return Mt[Dt][e]}function ct(e,t){return Mt[Dt][e]=t}function Tt(e){delete Mt[Dt][e]}function Ut(e,t,s){var n;try{if(Mn(e)){var r=window[e];n=r[t].bind(r)}}catch{}return n||s}Mt[Dt]||(Mt[Dt]={});var xs={};function Mn(e){if(typeof xs[e]!==bs)return xs[e];try{var t=window[e];t.setItem(bs,bs),t.removeItem(bs)}catch{return xs[e]=!1}return xs[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 Te="function",Ie="undefined",rc="@@redux/"+Math.random().toString(36),cr=function(){return typeof Symbol===Te&&Symbol.observable||"@@observable"}(),Ss=" != "+Te;function zi(e,t,s){var n;if(typeof t===Te&&typeof s===Ie&&(s=t,t=void 0),typeof s!==Ie){if(typeof s!==Te)throw new Error("enhancer"+Ss);return s(zi)(e,t)}if(typeof e!==Te)throw new Error("reducer"+Ss);var r=e,i=t,o=[],u=o,l=!1;function c(){u===o&&(u=o.slice())}function h(){return i}function g(v){if(typeof v!==Te)throw new Error("Listener"+Ss);var _=!0;return c(),u.push(v),function(){if(_){_=!1,c();var B=u.indexOf(v);u.splice(B,1)}}}function A(v){if(!de(v))throw new Error("Act != obj");if(typeof v.type===Ie)throw new Error("ActType "+Ie);if(l)throw new Error("Dispatch in reducer");try{l=!0,i=r(i,v)}finally{l=!1}for(var _=o=u,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!==Te)throw new Error("next reducer"+Ss);r=v,A({type:"@@redux/INIT"})}})[cr]=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)}}})[cr]=function(){return this},v},n}function ic(e,t){var s=t&&t.type;return"action "+(s&&s.toString()||"?")+"reducer "+e+" returns "+Ie}function Lt(){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 oc(){var e=arguments;return function(t){return function(s,n,r){var i,o=t(s,n,r),u=o.dispatch,l={getState:o.getState,dispatch:function(c){return u(c)}};return i=[].slice.call(e).map(function(c){return c(l)}),V({},o,{dispatch:u=Lt.apply(void 0,i)(o.dispatch)})}}}var Ge=at+"anon_id",it=at+"user_id",mt=at+"user_traits",Le="userId",ht="anonymousId",As=["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"],on=["name","EVENTS","config","loaded"],$=As.reduce(function(e,t){return e[t]=t,e},{registerPluginType:function(e){return"registerPlugin:"+e},pluginReadyType:function(e){return"ready:"+e}}),lr=/^utm_/,dr=/^an_prop_/,fr=/^an_trait_/;function ac(e){var t=e.storage.setItem;return function(s){return function(n){return function(r){if(r.type===$.bootstrap){var i=r.params,o=r.user,u=r.persistedUser,l=r.initialUser,c=u.userId===o.userId;u.anonymousId!==o.anonymousId&&t(Ge,o.anonymousId),c||t(it,o.userId),l.traits&&t(mt,V({},c&&u.traits?u.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(lr)||B.match(/^(d|g)clid/)){var b=B.replace(lr,"");_.campaign[b==="campaign"?"name":b]=i[B]}return B.match(dr)&&(_.props[B.replace(dr,"")]=i[B]),B.match(fr)&&(_.traits[B.replace(fr,"")]=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 uc(e){return function(t,s){if(t===void 0&&(t={}),s===void 0&&(s={}),s.type===$.setItemEnd){if(s.key===Ge)return V({},t,{anonymousId:s.value});if(s.key===it)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[it,Ge,mt].forEach(function(n){e.removeItem(n)}),Object.assign({},t,{userId:null,anonymousId:null,traits:{}});default:return t}}}function hr(e){return{userId:e.getItem(it),anonymousId:e.getItem(Ge),traits:e.getItem(mt)}}var an=function(e){return at+"TEMP"+at+e};function cc(e){var t=e.storage,s=t.setItem,n=t.removeItem,r=t.getItem;return function(i){return function(o){return function(u){var l=u.userId,c=u.traits,h=u.options;if(u.type===$.reset&&([it,mt,Ge].forEach(function(v){n(v)}),[Le,ht,"traits"].forEach(function(v){Tt(an(v))})),u.type===$.identify){r(Ge)||s(Ge,Fs());var g=r(it),A=r(mt)||{};g&&g!==l&&i.dispatch({type:$.userIdChanged,old:{userId:g,traits:A},new:{userId:l,traits:c},options:h}),l&&s(it,l),c&&s(mt,V({},A,c))}return o(u)}}}}var Qt={};function pr(e,t){Qt[e]&&Oe(Qt[e])&&(Qt[e](t),delete Qt[e])}function Gi(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 Gi(e,t,s-10).then(n,r)})})}function Hi(e,t,s){var n=t(),r=e.getState(),i=r.plugins,o=r.queue,u=r.user;if(!r.context.offline&&o&&o.actions&&o.actions.length){var l=o.actions.reduce(function(h,g,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(_&&Oe(_)){var B=function(j,U){return j===void 0&&(j={}),U===void 0&&(U={}),[Le,ht].reduce(function(M,E){return j.hasOwnProperty(E)&&U[E]&&U[E]!==j[E]&&(M[E]=U[E]),M},j)}(g.payload,u);_({payload:B,config:i[A].config,instance:s});var b=v+":"+A;e.dispatch(V({},B,{type:b,_:{called:b,from:"queueDrain"}}))}});var c=o.actions.filter(function(h,g){return!~l.processIndex.indexOf(g)});o.actions=c}}}var Js=function(e){var t=e.data,s=e.action,n=e.instance,r=e.state,i=e.allPlugins,o=e.allMatches,u=e.store,l=e.EVENTS;try{var c=r.plugins,h=r.context,g=s.type,A=g.match(gt),v=t.exact.map(function(b){return b.pluginName});A&&(v=o.during.map(function(b){return b.pluginName}));var _=function(b,j){return function(U,M,E){var P=M.config,F=M.name,q=F+"."+U.type;E&&(q=E.event);var N=U.type.match(gt)?function(m,x,R,S,D){return function(O,w){var z=S?S.name:m,Q=w&&Yt(w)?w:R;if(S&&(!(Q=w&&Yt(w)?w:[m]).includes(m)||Q.length!==1))throw new Error("Method "+x+" can only abort "+m+" plugin. "+JSON.stringify(Q)+" input valid");return V({},D,{abort:{reason:O,plugins:Q,caller:x,_:z}})}}(F,q,j,E,U):function(m,x){return function(){throw new Error(m.type+" action not cancellable. Remove abort in "+x)}}(U,q);return{payload:lc(U),instance:b,config:P||{},abort:N}}}(n,v),B=t.exact.reduce(function(b,j){var U=j.pluginName,M=j.methodName,E=!1;return M.match(/^initialize/)||M.match(/^reset/)||(E=!c[U].loaded),h.offline&&M.match(/^(page|track|identify)/)&&(E=!0),b[""+U]=E,b},{});return Promise.resolve(t.exact.reduce(function(b,j,U){try{var M=j.pluginName;return Promise.resolve(b).then(function(E){function P(){return Promise.resolve(E)}var F=function(){if(t.namespaced&&t.namespaced[M])return Promise.resolve(t.namespaced[M].reduce(function(q,N,m){try{return Promise.resolve(q).then(function(x){return N.method&&Oe(N.method)?(function(O,w){var z=Sr(O);if(z&&z.name===w){var Q=Sr(z.method);throw new Error([w+" plugin is calling method "+O,"Plugins cant call self","Use "+z.method+" "+(Q?"or "+Q.method:"")+" in "+w+" plugin insteadof "+O].join(`
|
|
2
|
+
`))}}(N.methodName,N.pluginName),Promise.resolve(N.method({payload:x,instance:n,abort:(R=x,S=M,D=N.pluginName,function(O,w){return V({},R,{abort:{reason:O,plugins:w||[S],caller:g,from:D||S}})}),config:yr(N.pluginName,c,i),plugins:c})).then(function(O){var w=de(O)?O:{};return Promise.resolve(V({},x,w))})):x;var R,S,D})}catch(x){return Promise.reject(x)}},Promise.resolve(s))).then(function(q){E[M]=q});E[M]=s}();return F&&F.then?F.then(P):P()})}catch(E){return Promise.reject(E)}},Promise.resolve({}))).then(function(b){return Promise.resolve(t.exact.reduce(function(j,U,M){try{var E=t.exact.length===M+1,P=U.pluginName,F=i[P];return Promise.resolve(j).then(function(q){var N=b[P]?b[P]:{};if(A&&(N=q),Zs(N,P))return Ys({data:N,method:g,instance:n,pluginName:P,store:u}),Promise.resolve(q);if(Zs(q,P))return E&&Ys({data:q,method:g,instance:n,store:u}),Promise.resolve(q);if(B.hasOwnProperty(P)&&B[P]===!0)return u.dispatch({type:"queue",plugin:P,payload:N,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(q);var m=_(b[P],i[P]);return Promise.resolve(F[g]({abort:m.abort,payload:N,instance:n,config:yr(P,c,i),plugins:c})).then(function(x){var R=de(x)?x:{},S=V({},q,R),D=b[P];if(Zs(D,P))Ys({data:D,method:g,instance:n,pluginName:P,store:u});else{var O=g+":"+P;(O.match(/:/g)||[]).length<2&&!g.match(mr)&&!g.match(gr)&&n.dispatch(V({},A?S:N,{type:O,_:{called:O,from:"submethod"}}))}return Promise.resolve(S)})})}catch(q){return Promise.reject(q)}},Promise.resolve(s))).then(function(j){if(!(g.match(gt)||g.match(/^registerPlugin/)||g.match(gr)||g.match(mr)||g.match(/^params/)||g.match(/^userIdChanged/))){if(l.plugins.includes(g),j._&&j._.originalAction===g)return j;var U=V({},j,{_:{originalAction:j.type,called:j.type,from:"engineEnd"}});Wi(j,t.exact.length)&&!g.match(/End$/)&&(U=V({},U,{type:j.type+"Aborted"})),u.dispatch(U)}return j})})}catch(b){return Promise.reject(b)}},gt=/Start$/,mr=/^bootstrap/,gr=/^ready/;function Ys(e){var t=e.pluginName,s=e.method+"Aborted"+(t?":"+t:"");e.store.dispatch(V({},e.data,{type:s,_:{called:s,from:"abort"}}))}function yr(e,t,s){var n=t[e]||s[e];return n&&n.config?n.config:{}}function vr(e,t){return t.reduce(function(s,n){return n[e]?s.concat({methodName:e,pluginName:n.name,method:n[e]}):s},[])}function br(e,t){var s=e.replace(gt,""),n=t?":"+t:"";return[""+e+n,""+s+n,s+"End"+n]}function Zs(e,t){var s=e.abort;return!!s&&(s===!0||xr(s,t)||s&&xr(s.plugins,t))}function Wi(e,t){var s=e.abort;if(!s)return!1;if(s===!0||pt(s))return!0;var n=s.plugins;return Yt(s)&&s.length===t||Yt(n)&&n.length===t}function Yt(e){return Array.isArray(e)}function xr(e,t){return!(!e||!Yt(e))&&e.includes(t)}function Sr(e){var t=e.match(/(.*):(.*)/);return!!t&&{method:t[1],name:t[2]}}function lc(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 dc(e,t,s){var n={};return function(r){return function(i){return function(o){try{var u,l=function(E){return u?E:i(g)},c=o.type,h=o.plugins,g=o;if(o.abort)return Promise.resolve(i(o));if(c===$.enablePlugin&&r.dispatch({type:$.initializeStart,plugins:h,disabled:[],fromEnable:!0,meta:o.meta}),c===$.disablePlugin&&setTimeout(function(){return pr(o.meta.rid,{payload:o})},0),c===$.initializeEnd){var A=t(),v=Object.keys(A),_=v.filter(function(E){return h.includes(E)}).map(function(E){return A[E]}),B=[],b=[],j=o.disabled,U=_.map(function(E){var P=E.loaded,F=E.name,q=E.config;return Gi(E,function(){return P({config:q})},1e4).then(function(N){return n[F]||(r.dispatch({type:$.pluginReadyType(F),name:F,events:Object.keys(E).filter(function(m){return!on.includes(m)})}),n[F]=!0),B=B.concat(F),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:j};setTimeout(function(){v.length===U.length+j.length&&r.dispatch(V({},{type:$.ready},P))},0)})}var M=function(){if(c!==$.bootstrap)return/^ready:([^:]*)$/.test(c)&&setTimeout(function(){return Hi(r,t,e)},0),Promise.resolve(function(E,P,F,q,N){try{var m=Oe(P)?P():P,x=E.type,R=x.replace(gt,"");if(E._&&E._.called)return Promise.resolve(E);var S=F.getState(),D=(z=m,(Q=S.plugins)===void 0&&(Q={}),(W=E.options)===void 0&&(W={}),Object.keys(z).filter(function(f){var p=W.plugins||{};return Gu(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(S.plugins).filter(function(f){var p=S.plugins[f];return E.plugins.includes(f)&&!p.initialized}).map(function(f){return m[f]}));var O=D.map(function(f){return f.name}),w=function(f,p,T){var G=br(f).map(function(H){return vr(H,p)});return p.reduce(function(H,J){var ie=J.name,Z=br(f,ie).map(function($t){return vr($t,p)}),ee=Z[0],Y=Z[1],ke=Z[2];return ee.length&&(H.beforeNS[ie]=ee),Y.length&&(H.duringNS[ie]=Y),ke.length&&(H.afterNS[ie]=ke),H},{before:G[0],beforeNS:{},during:G[1],duringNS:{},after:G[2],afterNS:{}})}(x,D);return Promise.resolve(Js({action:E,data:{exact:w.before,namespaced:w.beforeNS},state:S,allPlugins:m,allMatches:w,instance:F,store:q,EVENTS:N})).then(function(f){function p(){var H=function(){if(x.match(gt))return Promise.resolve(Js({action:V({},T,{type:R+"End"}),data:{exact:w.after,namespaced:w.afterNS},state:S,allPlugins:m,allMatches:w,instance:F,store:q,EVENTS:N})).then(function(J){J.meta&&J.meta.hasCallback&&pr(J.meta.rid,{payload:J})})}();return H&&H.then?H.then(function(){return f}):f}if(Wi(f,O.length))return f;var T,G=function(){if(x!==R)return Promise.resolve(Js({action:V({},f,{type:R}),data:{exact:w.during,namespaced:w.duringNS},state:S,allPlugins:m,allMatches:w,instance:F,store:q,EVENTS:N})).then(function(H){T=H});T=f}();return G&&G.then?G.then(p):p()})}catch(f){return Promise.reject(f)}var z,Q,W}(o,t,e,r,s)).then(function(E){return u=1,i(E)})}();return Promise.resolve(M&&M.then?M.then(l):l(M))}catch(E){return Promise.reject(E)}}}}}function fc(e){return function(t){return function(s){return function(n){var r=n.type,i=n.key,o=n.value,u=n.options;if(r===$.setItem||r===$.removeItem){if(n.abort)return s(n);r===$.setItem?e.setItem(i,o,u):e.removeItem(i,u)}return s(n)}}}}var hc=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(t,s){e[s]=e[s].concat(t)},this.removeMiddleware=function(t,s){var n=e[s].findIndex(function(r){return r===t});n!==-1&&(e[s]=[].concat(e[s].slice(0,n),e[s].slice(n+1)))},this.dynamicMiddlewares=function(t){return function(s){return function(n){return function(r){var i={getState:s.getState,dispatch:function(u){return s.dispatch(u)}},o=e[t].map(function(u){return u(i)});return Lt.apply(void 0,o)(n)(r)}}}}};function pc(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=wr(s.type,"registerPlugin"),i=e()[r];if(!i||!r)return t;var o=s.enabled,u=i.config;return n[r]={enabled:o,initialized:!!o&&!i.initialize,loaded:!!o&&!!i.loaded({config:u}),config:u},V({},t,n)}if(/^initialize:([^:]*)$/.test(s.type)){var l=wr(s.type,$.initialize),c=e()[l];return c&&l?(n[l]=V({},t[l],{initialized:!0,loaded:!!c.loaded({config:c.config})}),V({},t,n)):t}if(/^ready:([^:]*)$/.test(s.type))return n[s.name]=V({},t[s.name],{loaded:!0}),V({},t,n);switch(s.type){case $.disablePlugin:return V({},t,Er(s.plugins,!1,t));case $.enablePlugin:return V({},t,Er(s.plugins,!0,t));default:return t}}}function wr(e,t){return e.substring(t.length+1,e.length)}function Er(e,t,s){return e.reduce(function(n,r){return n[r]=V({},s[r],{enabled:t}),n},s)}function Ji(e){try{return JSON.parse(JSON.stringify(e))}catch{}return e}var mc={last:{},history:[]};function gc(e,t){e===void 0&&(e=mc);var s=t.options,n=t.meta;if(t.type===$.track){var r=Ji(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 yc={actions:[]};function vc(e,t){e===void 0&&(e=yc);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 bc(e){var t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(Yi,""):"")}var Zi,Xi,eo,to,xc=function(e){if(e===void 0&&(e={}),!we)return e;var t=document,s=t.title,n=t.referrer,r=window,i=r.location,o=r.innerWidth,u=r.innerHeight,l=i.hash,c=i.search,h=function(A){var v=function(){if(we){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,"")}(c),g={title:s,url:h,path:bc(h),hash:l,search:c,width:o,height:u};return n&&n!==""&&(g.referrer=n),V({},g,e)},Sc={last:{},history:[]};function wc(e,t){e===void 0&&(e=Sc);var s=t.options;if(t.type===$.page){var n=Ji(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}Zi=function(){if(!we)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"}(),Xi=we?document.referrer:null,eo=ec(),to=tc();var kr={initialized:!1,sessionId:Fs(),app:null,version:null,debug:!1,offline:!!we&&!navigator.onLine,os:{name:Zi},userAgent:we?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.5"},timezone:to,locale:eo,campaign:{},referrer:Xi};function Ec(e,t){e===void 0&&(e=kr);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({},kr,e,{initialized:!0})}}var kc=["plugins","reducers","storage"];function Ac(e,t,s){if(we){var n=window[(s?"add":"remove")+"EventListener"];e.split(" ").forEach(function(r){n(r,t)})}}function Pc(e){var t=Ac.bind(null,"online offline",function(s){return Promise.resolve(!navigator.onLine).then(e)});return t(!0),function(s){return t(!1)}}function so(){return ct("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 Mt[Dt].analytics.push(o.action||o),i(o)}})}}}function Ar(e){return function(){return Lt(Lt.apply(null,arguments),so())}}function Xs(e){return e?Wu(e)?e:[e]:[]}function Pr(e,t,s){e===void 0&&(e={});var n,r,i=Fs();return t&&(Qt[i]=(n=t,r=function(o){for(var u,l=o||Array.prototype.slice.call(arguments),c=0;c<l.length;c++)if(Oe(l[c])){u=l[c];break}return u}(s),function(o){r&&r(o),n(o)})),V({},e,{rid:i,ts:new Date().getTime()},t?{hasCallback:!0}:{})}function Cc(e){e===void 0&&(e={});var t=e.reducers||{},s=e.initialUser||{},n=(e.plugins||[]).reduce(function(f,p){if(Oe(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(J){return p.EVENTS[J]}):[];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(J,ie){var Z;return J[ie]=(Z=p.methods[ie],function(){for(var ee=Array.prototype.slice.call(arguments),Y=new Array(Z.length),ke=0;ke<ee.length;ke++)Y[ke]=ee[ke];return Y[Y.length]=P,Z.apply({instance:P},Y)}),J},{}),delete p.methods);var G=Object.keys(p).concat(T),H=new Set(f.events.concat(G));if(f.events=Array.from(H),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:ut,setItem:ct,removeItem:Tt},i=function(f){return function(p,T,G){return T.getState("user")[p]||(G&&de(G)&&G[p]?G[p]:hr(f)[p]||ut(an(p))||null)}}(r),o=n.plugins,u=n.events.filter(function(f){return!on.includes(f)}).sort(),l=new Set(u.concat(As).filter(function(f){return!on.includes(f)})),c=Array.from(l).sort(),h=function(){return o},g=new hc,A=g.addMiddleware,v=g.removeMiddleware,_=g.dynamicMiddlewares,B=function(){throw new Error("Abort disabled inListener")},b=sc(),j=hr(r),U=V({},j,s,b.an_uid?{userId:b.an_uid}:{},b.an_aid?{anonymousId:b.an_aid}:{});U.anonymousId||(U.anonymousId=Fs());var M=V({enable:function(f,p){return new Promise(function(T){w.dispatch({type:$.enablePlugin,plugins:Xs(f),_:{originalAction:$.enablePlugin}},T,[p])})},disable:function(f,p){return new Promise(function(T){w.dispatch({type:$.disablePlugin,plugins:Xs(f),_:{originalAction:$.disablePlugin}},T,[p])})}},n.methods),E=!1,P={identify:function(f,p,T,G){try{var H=pt(f)?f:null,J=de(f)?f:p,ie=T||{},Z=P.user();ct(an(Le),H);var ee=H||J.userId||i(Le,P,J);return Promise.resolve(new Promise(function(Y){w.dispatch(V({type:$.identifyStart,userId:ee,traits:J||{},options:ie,anonymousId:Z.anonymousId},Z.id&&Z.id!==H&&{previousId:Z.id}),Y,[p,T,G])}))}catch(Y){return Promise.reject(Y)}},track:function(f,p,T,G){try{var H=de(f)?f.event:f;if(!H||!pt(H))throw new Error("EventMissing");var J=de(f)?f:p||{},ie=de(T)?T:{};return Promise.resolve(new Promise(function(Z){w.dispatch({type:$.trackStart,event:H,properties:J,options:ie,userId:i(Le,P,p),anonymousId:i(ht,P,p)},Z,[p,T,G])}))}catch(Z){return Promise.reject(Z)}},page:function(f,p,T){try{var G=de(f)?f:{},H=de(p)?p:{};return Promise.resolve(new Promise(function(J){w.dispatch({type:$.pageStart,properties:xc(G),options:H,userId:i(Le,P,G),anonymousId:i(ht,P,G)},J,[f,p,T])}))}catch(J){return Promise.reject(J)}},user:function(f){if(f===Le||f==="id")return i(Le,P);if(f===ht||f==="anonId")return i(ht,P);var p=P.getState("user");return f?or(p,f):p},reset:function(f){return new Promise(function(p){w.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||!Oe(p))return!1;if(f===$.bootstrap)throw new Error(".on disabled for "+f);var T=/Start$|Start:/;if(f==="*"){var G=function(Z){return function(ee){return function(Y){return Y.type.match(T)&&p({payload:Y,instance:P,plugins:o}),ee(Y)}}},H=function(Z){return function(ee){return function(Y){return Y.type.match(T)||p({payload:Y,instance:P,plugins:o}),ee(Y)}}};return A(G,ws),A(H,Es),function(){v(G,ws),v(H,Es)}}var J=f.match(T)?ws:Es,ie=function(Z){return function(ee){return function(Y){return Y.type===f&&p({payload:Y,instance:P,plugins:o,abort:B}),ee(Y)}}};return A(ie,J),function(){return v(ie,J)}},once:function(f,p){if(!f||!Oe(p))return!1;if(f===$.bootstrap)throw new Error(".once disabled for "+f);var T=P.on(f,function(G){p({payload:G.payload,instance:P,plugins:o,abort:B}),T()});return T},getState:function(f){var p=w.getState();return f?or(p,f):Object.assign({},p)},dispatch:function(f){var p=pt(f)?{type:f}:f;if(As.includes(p.type))throw new Error("reserved action "+p.type);var T=V({},p,{_:V({originalAction:p.type},f._||{})});w.dispatch(T)},enablePlugin:M.enable,disablePlugin:M.disable,plugins:M,storage:{getItem:r.getItem,setItem:function(f,p,T){w.dispatch({type:$.setItemStart,key:f,value:p,options:T})},removeItem:function(f,p){w.dispatch({type:$.removeItemStart,key:f,options:p})}},setAnonymousId:function(f,p){P.storage.setItem(Ge,f,p)},events:{core:As,plugins:u}},F=n.middlewares.concat([function(f){return function(p){return function(T){return T.meta||(T.meta=Pr()),p(T)}}},_(ws),dc(P,h,{all:c,plugins:u}),fc(r),ac(P),cc(P),_(Es)]),q={context:Ec,user:uc(r),page:wc,track:gc,plugins:pc(h),queue:vc},N=Lt,m=Lt;if(we&&e.debug){var x=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;x&&(N=x({trace:!0,traceLimit:25})),m=function(){return arguments.length===0?so():de(typeof arguments[0])?Ar():Ar().apply(null,arguments)}}var R,S=function(f){return Object.keys(f).reduce(function(p,T){return kc.includes(T)||(p[T]=f[T]),p},{})}(e),D=n.pluginsArray.reduce(function(f,p){var T=p.name,G=p.config,H=p.loaded,J=n.pluginEnabled[T];return f[T]={enabled:J,initialized:!!J&&!p.initialize,loaded:!!H({config:G}),config:G},f},{}),O={context:S,user:U,plugins:D},w=zi(function(f){for(var p=Object.keys(f),T={},G=0;G<p.length;G++){var H=p[G];typeof f[H]===Te&&(T[H]=f[H])}var J,ie=Object.keys(T);try{(function(Z){Object.keys(Z).forEach(function(ee){var Y=Z[ee];if(typeof Y(void 0,{type:"@@redux/INIT"})===Ie||typeof Y(void 0,{type:rc})===Ie)throw new Error("reducer "+ee+" "+Ie)})})(T)}catch(Z){J=Z}return function(Z,ee){if(Z===void 0&&(Z={}),J)throw J;for(var Y=!1,ke={},$t=0;$t<ie.length;$t++){var gs=ie[$t],Qn=Z[gs],Gs=(0,T[gs])(Qn,ee);if(typeof Gs===Ie){var wo=ic(gs,ee);throw new Error(wo)}ke[gs]=Gs,Y=Y||Gs!==Qn}return Y?ke:Z}}(V({},q,t)),O,m(N(oc.apply(void 0,F))));w.dispatch=(R=w.dispatch,function(f,p,T){var G=V({},f,{meta:Pr(f.meta,p,Xs(T))});return R.apply(null,[G])});var z=Object.keys(o);w.dispatch({type:$.bootstrap,plugins:z,config:S,params:b,user:U,initialUser:s,persistedUser:j});var Q=z.filter(function(f){return n.pluginEnabled[f]}),W=z.filter(function(f){return!n.pluginEnabled[f]});return w.dispatch({type:$.registerPlugins,plugins:z,enabled:n.pluginEnabled}),n.pluginsArray.map(function(f,p){var T=f.bootstrap,G=f.config,H=f.name;T&&Oe(T)&&T({instance:P,config:G,payload:f}),w.dispatch({type:$.registerPluginType(H),name:H,enabled:n.pluginEnabled[H],plugin:f}),n.pluginsArray.length===p+1&&w.dispatch({type:$.initializeStart,plugins:Q,disabled:W})}),Pc(function(f){w.dispatch({type:f?$.offline:$.online})}),function(f,p,T){setInterval(function(){return Hi(f,p,T)},3e3)}(w,h,P),P}var ws="before",Es="after",Ht="cookie",We=io(),no=$s,jc=$s;function ro(e){return We?$s(e,"",-1):Tt(e)}function io(){if(We!==void 0)return We;var e="cookiecookie";try{$s(e,e),We=document.cookie.indexOf(e)!==-1,ro(e)}catch{We=!1}return We}function $s(e,t,s,n,r,i){if(typeof window<"u"){var o=arguments.length>1;return We===!1&&(o?ct(e,t):ut(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 Wt="localStorage",Oc=Mn.bind(null,"localStorage");Ut("localStorage","getItem",ut);Ut("localStorage","setItem",ct);Ut("localStorage","removeItem",Tt);var Jt="sessionStorage",_c=Mn.bind(null,"sessionStorage");Ut("sessionStorage","getItem",ut);Ut("sessionStorage","setItem",ct);Ut("sessionStorage","removeItem",Tt);function yt(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 Bc=Oc(),Rc=_c(),Ic=io();function oo(e,t){if(e){var s=Ln(t),n=!qn(s),r=Nn(s)?yt(localStorage.getItem(e)):void 0;if(n&&!ft(r))return r;var i=Tn(s)?yt(no(e)):void 0;if(n&&i)return i;var o=Un(s)?yt(sessionStorage.getItem(e)):void 0;if(n&&o)return o;var u=ut(e);return n?u:{localStorage:r,sessionStorage:o,cookie:i,global:u}}}function Dc(e,t,s){if(e&&!ft(t)){var n={},r=Ln(s),i=JSON.stringify(t),o=!qn(r);return Nn(r)&&(n[Wt]=ks(Wt,t,yt(localStorage.getItem(e))),localStorage.setItem(e,i),o)?n[Wt]:Tn(r)&&(n[Ht]=ks(Ht,t,yt(no(e))),jc(e,i),o)?n[Ht]:Un(r)&&(n[Jt]=ks(Jt,t,yt(sessionStorage.getItem(e))),sessionStorage.setItem(e,i),o)?n[Jt]:(n[Gt]=ks(Gt,t,ut(e)),ct(e,t),o?n[Gt]:n)}}function Mc(e,t){if(e){var s=Ln(t),n=oo(e,$i),r={};return!ft(n.localStorage)&&Nn(s)&&(localStorage.removeItem(e),r[Wt]=n.localStorage),!ft(n.cookie)&&Tn(s)&&(ro(e),r[Ht]=n.cookie),!ft(n.sessionStorage)&&Un(s)&&(sessionStorage.removeItem(e),r[Jt]=n.sessionStorage),!ft(n.global)&&Vs(s,Gt)&&(Tt(e),r[Gt]=n.global),r}}function Ln(e){return e?pt(e)?e:e.storage:Fi}function Nn(e){return Bc&&Vs(e,Wt)}function Tn(e){return Ic&&Vs(e,Ht)}function Un(e){return Rc&&Vs(e,Jt)}function qn(e){return e===$i||e==="all"}function Vs(e,t){return e===Fi||e===t||qn(e)}function ks(e,t,s){return{location:e,current:t,previous:s}}var Lc={setItem:Dc,getItem:oo,removeItem:Mc};function Nc(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function Cr(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 jr(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?Cr(Object(s),!0).forEach(function(n){Nc(e,n,s[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Cr(Object(s)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(s,n))})}return e}function Tc(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t={storage:Lc};return Cc(jr(jr({},t),e))}const Uc="@chaibuilder/sdk",qc="0.1.7",Fc="module",$c=["dist"],Vc="dist/core.js",Qc=!1,Kc={".":{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"}},zc={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"},Gc={"@analytics/google-analytics":"^1.0.7","@bobthered/tailwindcss-palette-generator":"3.1.1","@chaibuilder/blocks":"^0.1.0","@floating-ui/dom":"1.4.5","@floating-ui/react-dom":"2.0.1","@mhsdesign/jit-browser-tailwindcss":"0.3.0","@minoru/react-dnd-treeview":"3.4.4","@radix-ui/react-accordion":"^1.1.2","@radix-ui/react-alert-dialog":"^1.0.4","@radix-ui/react-context-menu":"^2.1.4","@radix-ui/react-dialog":"^1.0.4","@radix-ui/react-dropdown-menu":"^2.0.5","@radix-ui/react-hover-card":"^1.0.6","@radix-ui/react-icons":"^1.3.0","@radix-ui/react-label":"^2.0.2","@radix-ui/react-menubar":"^1.0.3","@radix-ui/react-navigation-menu":"^1.1.3","@radix-ui/react-popover":"^1.0.6","@radix-ui/react-scroll-area":"^1.0.4","@radix-ui/react-select":"^1.2.2","@radix-ui/react-separator":"^1.0.3","@radix-ui/react-slot":"^1.0.2","@radix-ui/react-switch":"^1.0.3","@radix-ui/react-tabs":"^1.0.4","@radix-ui/react-toast":"^1.1.4","@radix-ui/react-toggle":"^1.0.3","@radix-ui/react-tooltip":"^1.0.6","@react-hookz/web":"23.1.0","@rjsf/core":"5.11.2","@rjsf/utils":"5.11.2","@rjsf/validator-ajv8":"5.11.2","@tailwindcss/aspect-ratio":"0.4.2","@tailwindcss/forms":"^0.5.6","@tailwindcss/line-clamp":"^0.4.4","@tailwindcss/typography":"^0.5.10","@tanstack/react-query":"^5.8.4",analytics:"^0.8.9","class-variance-authority":"0.6.1",clsx:"1.2.1",cmdk:"0.2.0","date-fns":"^2.30.0",flagged:"2.0.9","flat-to-nested":"1.1.1","focus-trap-react":"^10.2.1","forgiving-xml-parser":"1.4.0","framer-motion":"^10.12.18","fuse.js":"6.6.2","gray-matter":"^4.0.3",himalaya:"^1.1.0","html-formatter":"0.1.9",i18next:"^23.2.8",jotai:"2.2.2",lodash:"4.17.21","lucide-react":"^0.244.0",nanoid:"^4.0.2","post-robot":"10.0.46",react:"^18.2.0","react-autosuggest":"10.1.0","react-colorful":"5.6.1","react-dnd":"16.0.1","react-dnd-html5-backend":"16.0.1","react-dom":"^18.2.0","react-hotkeys-hook":"4.4.1","react-i18next":"13.0.1","react-icons":"^4.10.1","react-icons-picker":"^1.0.9","react-quill":"^2.0.0","react-textarea-autosize":"^8.5.2","react-wrap-balancer":"^1.0.0","redux-undo":"1.1.0",sonner:"^1.2.0","tailwind-merge":"1.13.2","tailwindcss-animate":"1.0.6","tippy.js":"^6.3.7","unist-util-visit":"^4.1.2","unsplash-js":"^7.0.18"},Hc={"@commitlint/cli":"17.7.1","@commitlint/config-conventional":"17.7.0","@faker-js/faker":"^8.3.1","@nozbe/watermelondb":"^0.27.1","@playwright/test":"^1.39.0","@tanstack/eslint-plugin-query":"^5.8.4","@types/better-sqlite3":"^7.6.7","@types/jest":"^29.5.7","@types/lodash":"^4.14.200","@types/node":"^20.8.10","@types/react":"^18.2.15","@types/react-dom":"^18.2.7","@typescript-eslint/eslint-plugin":"^6.0.0","@typescript-eslint/parser":"^6.0.0","@vitejs/plugin-react-swc":"^3.3.2",autoprefixer:"^10.4.16","better-docs":"^2.7.2","better-sqlite3":"^9.1.1","drizzle-kit":"^0.20.4","drizzle-orm":"^0.29.0",eslint:"^8.45.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.4.3",jest:"^29.7.0","jest-environment-jsdom":"^29.7.0",jsdoc:"^4.0.2",msw:"^2.0.8",postcss:"^8.4.31",prettier:"^3.0.3","prettier-plugin-tailwindcss":"^0.5.6","prop-types":"^15.8.1","react-router-dom":"^6.19.0",tailwindcss:"^3.3.5","ts-jest":"^29.1.1",typescript:"^5.0.2",vite:"^4.4.5","vite-plugin-dts":"^3.6.3"},Wc={workerDirectory:"public"},Jc={name:Uc,private:!1,version:qc,type:Fc,files:$c,main:Vc,sideEffects:Qc,exports:Kc,scripts:zc,dependencies:Gc,devDependencies:Hc,msw:Wc},Or="https://api.chaibuilder.com",_r=()=>typeof window>"u"?!1:window.location.href.includes("localhost");function Yc(){return{name:"chaibuilder-analytics",config:{},initialize:()=>{if(typeof window>"u")return!1;window.chaibuilderAnalyticsLoaded=!0},page:e=>{if(typeof window>"u")return!1;if(_r())return;const{payload:t}=e;fetch(`${Or}/v1/log`,{method:"post",body:JSON.stringify(t)}).then(s=>s.json())},track:({payload:e})=>{if(typeof window>"u")return!1;_r()||fetch(`${Or}/v1/log`,{method:"post",body:JSON.stringify(e)})},loaded:()=>typeof window>"u"?!0:!!window.chaibuilderAnalyticsLoaded}}const Zc=Tc({app:"chaibuilder",version:Jc.version,plugins:[Yc()]});({}).NODE_ENV==="development"&&console.log("Chai Builder:",To);const Xc=e=>C.jsxRuntimeExports.jsx(C.jsxRuntimeExports.Fragment,{children:e.children}),el=e=>{const{dndOptions:t={backend:Kn.MultiBackend}}=e,[s]=ri(),[,n]=Cn(),r=Dn();return L.useEffect(()=>{Vu.set(fe.chaiBuilderPropsAtom,d.omit(e,["blocks","globalBlocks","brandingOptions"]))},[e]),L.useEffect(()=>{s(Jr.syncBlocksWithDefaults(e.blocks||[])),r()},[e.blocks]),L.useEffect(()=>{n(e.brandingOptions)},[e.brandingOptions]),L.useEffect(()=>{Zc.page()},[]),C.jsxRuntimeExports.jsx(Po.DndProvider,{...t,options:Kn.getBackendOptions(),children:C.jsxRuntimeExports.jsx(Xc,{children:C.jsxRuntimeExports.jsx($u,{})})})},ao=e=>C.jsxRuntimeExports.jsxs(Yr,{children:[C.jsxRuntimeExports.jsx(Ao.FlagsProvider,{features:Uo,children:C.jsxRuntimeExports.jsx(el,{...e})}),C.jsxRuntimeExports.jsx(fe.Toaster,{})]});var qt=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(){}},Nt=typeof window>"u"||"Deno"in window;function ve(){}function tl(e,t){return typeof e=="function"?e(t):e}function un(e){return typeof e=="number"&&e>=0&&e!==1/0}function uo(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Br(e,t){const{type:s="all",exact:n,fetchStatus:r,predicate:i,queryKey:o,stale:u}=e;if(o){if(n){if(t.queryHash!==Fn(o,t.options))return!1}else if(!Xt(t.queryKey,o))return!1}if(s!=="all"){const l=t.isActive();if(s==="active"&&!l||s==="inactive"&&l)return!1}return!(typeof u=="boolean"&&t.isStale()!==u||typeof r<"u"&&r!==t.state.fetchStatus||i&&!i(t))}function Rr(e,t){const{exact:s,status:n,predicate:r,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(s){if(Zt(t.options.mutationKey)!==Zt(i))return!1}else if(!Xt(t.options.mutationKey,i))return!1}return!(n&&t.state.status!==n||r&&!r(t))}function Fn(e,t){return((t==null?void 0:t.queryKeyHashFn)||Zt)(e)}function Zt(e){return JSON.stringify(e,(t,s)=>cn(s)?Object.keys(s).sort().reduce((n,r)=>(n[r]=s[r],n),{}):s)}function Xt(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(s=>!Xt(e[s],t[s])):!1}function co(e,t){if(e===t)return e;const s=Ir(e)&&Ir(t);if(s||cn(e)&&cn(t)){const n=s?e.length:Object.keys(e).length,r=s?t:Object.keys(t),i=r.length,o=s?[]:{};let u=0;for(let l=0;l<i;l++){const c=s?l:r[l];o[c]=co(e[c],t[c]),o[c]===e[c]&&u++}return n===i&&u===n?e:o}return t}function Rs(e,t){if(e&&!t||t&&!e)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function Ir(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function cn(e){if(!Dr(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const s=t.prototype;return!(!Dr(s)||!s.hasOwnProperty("isPrototypeOf"))}function Dr(e){return Object.prototype.toString.call(e)==="[object Object]"}function lo(e){return new Promise(t=>{setTimeout(t,e)})}function Mr(e){lo(0).then(e)}function ln(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?co(e,t):t}function sl(e,t,s=0){const n=[...e,t];return s&&n.length>s?n.slice(1):n}function nl(e,t,s=0){const n=[t,...e];return s&&n.length>s?n.slice(0,-1):n}var Je,Ue,vt,Ur,rl=(Ur=class extends qt{constructor(){super();I(this,Je,void 0);I(this,Ue,void 0);I(this,vt,void 0);k(this,vt,t=>{if(!Nt&&window.addEventListener){const s=()=>t();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){a(this,Ue)||this.setEventListener(a(this,vt))}onUnsubscribe(){var t;this.hasListeners()||((t=a(this,Ue))==null||t.call(this),k(this,Ue,void 0))}setEventListener(t){var s;k(this,vt,t),(s=a(this,Ue))==null||s.call(this),k(this,Ue,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){a(this,Je)!==t&&(k(this,Je,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof a(this,Je)=="boolean"?a(this,Je):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Je=new WeakMap,Ue=new WeakMap,vt=new WeakMap,Ur),Is=new rl,bt,qe,xt,qr,il=(qr=class extends qt{constructor(){super();I(this,bt,!0);I(this,qe,void 0);I(this,xt,void 0);k(this,xt,t=>{if(!Nt&&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,qe)||this.setEventListener(a(this,xt))}onUnsubscribe(){var t;this.hasListeners()||((t=a(this,qe))==null||t.call(this),k(this,qe,void 0))}setEventListener(t){var s;k(this,xt,t),(s=a(this,qe))==null||s.call(this),k(this,qe,t(this.setOnline.bind(this)))}setOnline(t){a(this,bt)!==t&&(k(this,bt,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return a(this,bt)}},bt=new WeakMap,qe=new WeakMap,xt=new WeakMap,qr),Ds=new il;function ol(e){return Math.min(1e3*2**e,3e4)}function Qs(e){return(e??"online")==="online"?Ds.isOnline():!0}var fo=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function en(e){return e instanceof fo}function ho(e){let t=!1,s=0,n=!1,r,i,o;const u=new Promise((b,j)=>{i=b,o=j}),l=b=>{var j;n||(v(new fo(b)),(j=e.abort)==null||j.call(e))},c=()=>{t=!0},h=()=>{t=!1},g=()=>!Is.isFocused()||e.networkMode!=="always"&&!Ds.isOnline(),A=b=>{var j;n||(n=!0,(j=e.onSuccess)==null||j.call(e,b),r==null||r(),i(b))},v=b=>{var j;n||(n=!0,(j=e.onError)==null||j.call(e,b),r==null||r(),o(b))},_=()=>new Promise(b=>{var j;r=U=>{const M=n||!g();return M&&b(U),M},(j=e.onPause)==null||j.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(j){b=Promise.reject(j)}Promise.resolve(b).then(A).catch(j=>{var F;if(n)return;const U=e.retry??(Nt?0:3),M=e.retryDelay??ol,E=typeof M=="function"?M(s,j):M,P=U===!0||typeof U=="number"&&s<U||typeof U=="function"&&U(s,j);if(t||!P){v(j);return}s++,(F=e.onFail)==null||F.call(e,s,j),lo(E).then(()=>{if(g())return _()}).then(()=>{t?v(j):B()})})};return Qs(e.networkMode)?B():_().then(B),{promise:u,cancel:l,continue:()=>(r==null?void 0:r())?u:Promise.resolve(),cancelRetry:c,continueRetry:h}}function al(){let e=[],t=0,s=h=>{h()},n=h=>{h()};const r=h=>{let g;t++;try{g=h()}finally{t--,t||u()}return g},i=h=>{t?e.push(h):Mr(()=>{s(h)})},o=h=>(...g)=>{i(()=>{h(...g)})},u=()=>{const h=e;e=[],h.length&&Mr(()=>{n(()=>{h.forEach(g=>{s(g)})})})};return{batch:r,batchCalls:o,schedule:i,setNotifyFunction:h=>{s=h},setBatchNotifyFunction:h=>{n=h}}}var se=al(),Ye,Fr,po=(Fr=class{constructor(){I(this,Ye,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),un(this.gcTime)&&k(this,Ye,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Nt?1/0:5*60*1e3))}clearGcTimeout(){a(this,Ye)&&(clearTimeout(a(this,Ye)),k(this,Ye,void 0))}},Ye=new WeakMap,Fr),St,wt,pe,Fe,me,ne,es,Ze,Et,Ps,Se,Be,$r,ul=($r=class extends po{constructor(t){super();I(this,Et);I(this,Se);I(this,St,void 0);I(this,wt,void 0);I(this,pe,void 0);I(this,Fe,void 0);I(this,me,void 0);I(this,ne,void 0);I(this,es,void 0);I(this,Ze,void 0);k(this,Ze,!1),k(this,es,t.defaultOptions),K(this,Et,Ps).call(this,t.options),k(this,ne,[]),k(this,pe,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,k(this,St,t.state||cl(this.options)),this.state=a(this,St),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!a(this,ne).length&&this.state.fetchStatus==="idle"&&a(this,pe).remove(this)}setData(t,s){const n=ln(this.state.data,t,this.options);return K(this,Se,Be).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,Se,Be).call(this,{type:"setState",state:t,setStateOptions:s})}cancel(t){var n;const s=a(this,Fe);return(n=a(this,me))==null||n.cancel(t),s?s.then(ve).catch(ve):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(a(this,St))}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||!uo(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,me))==null||s.continue()}onOnline(){var s;const t=a(this,ne).find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(s=a(this,me))==null||s.continue()}addObserver(t){a(this,ne).includes(t)||(a(this,ne).push(t),this.clearGcTimeout(),a(this,pe).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,me)&&(a(this,Ze)?a(this,me).cancel({revert:!0}):a(this,me).cancelRetry()),this.scheduleGc()),a(this,pe).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return a(this,ne).length}invalidate(){this.state.isInvalidated||K(this,Se,Be).call(this,{type:"invalidate"})}fetch(t,s){var c,h,g,A;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(a(this,Fe))return(c=a(this,me))==null||c.continueRetry(),a(this,Fe)}if(t&&K(this,Et,Ps).call(this,t),!this.options.queryFn){const v=a(this,ne).find(_=>_.options.queryFn);v&&K(this,Et,Ps).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,Ze,!0),n.signal)})};i(r);const o=()=>this.options.queryFn?(k(this,Ze,!1),this.options.persister?this.options.persister(this.options.queryFn,r,this):this.options.queryFn(r)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),u={fetchOptions:s,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:o};i(u),(h=this.options.behavior)==null||h.onFetch(u,this),k(this,wt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((g=u.fetchOptions)==null?void 0:g.meta))&&K(this,Se,Be).call(this,{type:"fetch",meta:(A=u.fetchOptions)==null?void 0:A.meta});const l=v=>{var _,B,b,j;en(v)&&v.silent||K(this,Se,Be).call(this,{type:"error",error:v}),en(v)||((B=(_=a(this,pe).config).onError)==null||B.call(_,v,this),(j=(b=a(this,pe).config).onSettled)==null||j.call(b,this.state.data,v,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return k(this,me,ho({fn:u.fetchFn,abort:n.abort.bind(n),onSuccess:v=>{var _,B,b,j;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,pe).config).onSuccess)==null||B.call(_,v,this),(j=(b=a(this,pe).config).onSettled)==null||j.call(b,v,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:l,onFail:(v,_)=>{K(this,Se,Be).call(this,{type:"failed",failureCount:v,error:_})},onPause:()=>{K(this,Se,Be).call(this,{type:"pause"})},onContinue:()=>{K(this,Se,Be).call(this,{type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode})),k(this,Fe,a(this,me).promise),a(this,Fe)}},St=new WeakMap,wt=new WeakMap,pe=new WeakMap,Fe=new WeakMap,me=new WeakMap,ne=new WeakMap,es=new WeakMap,Ze=new WeakMap,Et=new WeakSet,Ps=function(t){this.options={...a(this,es),...t},this.updateGcTime(this.options.gcTime)},Se=new WeakSet,Be=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 en(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,pe).notify({query:this,type:"updated",action:t})})},$r);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 Ae,Vr,ll=(Vr=class extends qt{constructor(t={}){super();I(this,Ae,void 0);this.config=t,k(this,Ae,new Map)}build(t,s,n){const r=s.queryKey,i=s.queryHash??Fn(r,s);let o=this.get(i);return o||(o=new ul({cache:this,queryKey:r,queryHash:i,options:t.defaultQueryOptions(s),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(o)),o}add(t){a(this,Ae).has(t.queryHash)||(a(this,Ae).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const s=a(this,Ae).get(t.queryHash);s&&(t.destroy(),s===t&&a(this,Ae).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){se.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return a(this,Ae).get(t)}getAll(){return[...a(this,Ae).values()]}find(t){const s={exact:!0,...t};return this.getAll().find(n=>Br(s,n))}findAll(t={}){const s=this.getAll();return Object.keys(t).length>0?s.filter(n=>Br(t,n)):s}notify(t){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()})})}},Ae=new WeakMap,Vr),Pe,ts,le,kt,Ce,Me,Qr,dl=(Qr=class extends po{constructor(t){super();I(this,Ce);I(this,Pe,void 0);I(this,ts,void 0);I(this,le,void 0);I(this,kt,void 0);this.mutationId=t.mutationId,k(this,ts,t.defaultOptions),k(this,le,t.mutationCache),k(this,Pe,[]),this.state=t.state||mo(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...a(this,ts),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){a(this,Pe).includes(t)||(a(this,Pe).push(t),this.clearGcTimeout(),a(this,le).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){k(this,Pe,a(this,Pe).filter(s=>s!==t)),this.scheduleGc(),a(this,le).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){a(this,Pe).length||(this.state.status==="pending"?this.scheduleGc():a(this,le).remove(this))}continue(){var t;return((t=a(this,kt))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var r,i,o,u,l,c,h,g,A,v,_,B,b,j,U,M,E,P,F,q;const s=()=>(k(this,kt,ho({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(N,m)=>{K(this,Ce,Me).call(this,{type:"failed",failureCount:N,error:m})},onPause:()=>{K(this,Ce,Me).call(this,{type:"pause"})},onContinue:()=>{K(this,Ce,Me).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),a(this,kt).promise),n=this.state.status==="pending";try{if(!n){K(this,Ce,Me).call(this,{type:"pending",variables:t}),await((i=(r=a(this,le).config).onMutate)==null?void 0:i.call(r,t,this));const m=await((u=(o=this.options).onMutate)==null?void 0:u.call(o,t));m!==this.state.context&&K(this,Ce,Me).call(this,{type:"pending",context:m,variables:t})}const N=await s();return await((c=(l=a(this,le).config).onSuccess)==null?void 0:c.call(l,N,t,this.state.context,this)),await((g=(h=this.options).onSuccess)==null?void 0:g.call(h,N,t,this.state.context)),await((v=(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,Ce,Me).call(this,{type:"success",data:N}),N}catch(N){try{throw await((j=(b=a(this,le).config).onError)==null?void 0:j.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((q=(F=this.options).onSettled)==null?void 0:q.call(F,void 0,N,t,this.state.context)),N}finally{K(this,Ce,Me).call(this,{type:"error",error:N})}}}},Pe=new WeakMap,ts=new WeakMap,le=new WeakMap,kt=new WeakMap,Ce=new WeakSet,Me=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,Pe).forEach(n=>{n.onMutationUpdate(t)}),a(this,le).notify({mutation:this,type:"updated",action:t})})},Qr);function mo(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ge,ss,Xe,Kr,fl=(Kr=class extends qt{constructor(t={}){super();I(this,ge,void 0);I(this,ss,void 0);I(this,Xe,void 0);this.config=t,k(this,ge,[]),k(this,ss,0)}build(t,s,n){const r=new dl({mutationCache:this,mutationId:++ys(this,ss)._,options:t.defaultMutationOptions(s),state:n});return this.add(r),r}add(t){a(this,ge).push(t),this.notify({type:"added",mutation:t})}remove(t){k(this,ge,a(this,ge).filter(s=>s!==t)),this.notify({type:"removed",mutation:t})}clear(){se.batch(()=>{a(this,ge).forEach(t=>{this.remove(t)})})}getAll(){return a(this,ge)}find(t){const s={exact:!0,...t};return a(this,ge).find(n=>Rr(s,n))}findAll(t={}){return a(this,ge).filter(s=>Rr(t,s))}notify(t){se.batch(()=>{this.listeners.forEach(s=>{s(t)})})}resumePausedMutations(){return k(this,Xe,(a(this,Xe)??Promise.resolve()).then(()=>{const t=a(this,ge).filter(s=>s.state.isPaused);return se.batch(()=>t.reduce((s,n)=>s.then(()=>n.continue().catch(ve)),Promise.resolve()))}).then(()=>{k(this,Xe,void 0)})),a(this,Xe)}},ge=new WeakMap,ss=new WeakMap,Xe=new WeakMap,Kr);function hl(e){return{onFetch:(t,s)=>{const n=async()=>{var _,B,b,j,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=((j=t.state.data)==null?void 0:j.pages)||[],u=((U=t.state.data)==null?void 0:U.pageParams)||[],l={pages:[],pageParams:[]};let c=!1;const h=M=>{Object.defineProperty(M,"signal",{enumerable:!0,get:()=>(t.signal.aborted?c=!0:t.signal.addEventListener("abort",()=>{c=!0}),t.signal)})},g=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),A=async(M,E,P)=>{if(c)return Promise.reject();if(E==null&&M.pages.length)return Promise.resolve(M);const F={queryKey:t.queryKey,pageParam:E,direction:P?"backward":"forward",meta:t.options.meta};h(F);const q=await g(F),{maxPages:N}=t.options,m=P?nl:sl;return{pages:m(M.pages,q,N),pageParams:m(M.pageParams,E,N)}};let v;if(i&&o.length){const M=i==="backward",E=M?pl:Lr,P={pages:o,pageParams:u},F=E(r,P);v=await A(P,F,M)}else{v=await A(l,u[0]??r.initialPageParam);const M=e??o.length;for(let E=1;E<M;E++){const P=Lr(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 Lr(e,{pages:t,pageParams:s}){const n=t.length-1;return e.getNextPageParam(t[n],t,s[n],s)}function pl(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,$e,Ve,At,Pt,Qe,Ct,jt,zr,ml=(zr=class{constructor(e={}){I(this,te,void 0);I(this,$e,void 0);I(this,Ve,void 0);I(this,At,void 0);I(this,Pt,void 0);I(this,Qe,void 0);I(this,Ct,void 0);I(this,jt,void 0);k(this,te,e.queryCache||new ll),k(this,$e,e.mutationCache||new fl),k(this,Ve,e.defaultOptions||{}),k(this,At,new Map),k(this,Pt,new Map),k(this,Qe,0)}mount(){ys(this,Qe)._++,a(this,Qe)===1&&(k(this,Ct,Is.subscribe(()=>{Is.isFocused()&&(this.resumePausedMutations(),a(this,te).onFocus())})),k(this,jt,Ds.subscribe(()=>{Ds.isOnline()&&(this.resumePausedMutations(),a(this,te).onOnline())})))}unmount(){var e,t;ys(this,Qe)._--,a(this,Qe)===0&&((e=a(this,Ct))==null||e.call(this),k(this,Ct,void 0),(t=a(this,jt))==null||t.call(this),k(this,jt,void 0))}isFetching(e){return a(this,te).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return a(this,$e).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=tl(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(ve).catch(ve)}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(ve)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(ve)}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(ve).catch(ve)}fetchInfiniteQuery(e){return e.behavior=hl(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ve).catch(ve)}resumePausedMutations(){return a(this,$e).resumePausedMutations()}getQueryCache(){return a(this,te)}getMutationCache(){return a(this,$e)}getDefaultOptions(){return a(this,Ve)}setDefaultOptions(e){k(this,Ve,e)}setQueryDefaults(e,t){a(this,At).set(Zt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...a(this,At).values()];let s={};return t.forEach(n=>{Xt(e,n.queryKey)&&(s={...s,...n.defaultOptions})}),s}setMutationDefaults(e,t){a(this,Pt).set(Zt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...a(this,Pt).values()];let s={};return t.forEach(n=>{Xt(e,n.mutationKey)&&(s={...s,...n.defaultOptions})}),s}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...a(this,Ve).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Fn(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,Ve).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){a(this,te).clear(),a(this,$e).clear()}},te=new WeakMap,$e=new WeakMap,Ve=new WeakMap,At=new WeakMap,Pt=new WeakMap,Qe=new WeakMap,Ct=new WeakMap,jt=new WeakMap,zr),ce,X,Ot,oe,et,_t,je,ns,Bt,Rt,tt,st,Ke,nt,rt,Kt,rs,dn,is,fn,os,hn,as,pn,us,mn,cs,gn,ls,yn,Ms,go,Gr,gl=(Gr=class extends qt{constructor(t,s){super();I(this,rt);I(this,rs);I(this,is);I(this,os);I(this,as);I(this,us);I(this,cs);I(this,ls);I(this,Ms);I(this,ce,void 0);I(this,X,void 0);I(this,Ot,void 0);I(this,oe,void 0);I(this,et,void 0);I(this,_t,void 0);I(this,je,void 0);I(this,ns,void 0);I(this,Bt,void 0);I(this,Rt,void 0);I(this,tt,void 0);I(this,st,void 0);I(this,Ke,void 0);I(this,nt,void 0);k(this,X,void 0),k(this,Ot,void 0),k(this,oe,void 0),k(this,nt,new Set),k(this,ce,t),this.options=s,k(this,je,null),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(a(this,X).addObserver(this),Nr(a(this,X),this.options)?K(this,rt,Kt).call(this):this.updateResult(),K(this,as,pn).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return vn(a(this,X),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return vn(a(this,X),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,K(this,us,mn).call(this),K(this,cs,gn).call(this),a(this,X).removeObserver(this)}setOptions(t,s){const n=this.options,r=a(this,X);if(this.options=a(this,ce).defaultQueryOptions(t),Rs(n,this.options)||a(this,ce).getQueryCache().notify({type:"observerOptionsUpdated",query:a(this,X),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=n.queryKey),K(this,ls,yn).call(this);const i=this.hasListeners();i&&Tr(a(this,X),r,this.options,n)&&K(this,rt,Kt).call(this),this.updateResult(s),i&&(a(this,X)!==r||this.options.enabled!==n.enabled||this.options.staleTime!==n.staleTime)&&K(this,rs,dn).call(this);const o=K(this,is,fn).call(this);i&&(a(this,X)!==r||this.options.enabled!==n.enabled||o!==a(this,Ke))&&K(this,os,hn).call(this,o)}getOptimisticResult(t){const s=a(this,ce).getQueryCache().build(a(this,ce),t),n=this.createResult(s,t);return vl(this,n)&&(k(this,oe,n),k(this,_t,this.options),k(this,et,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,nt).add(n),t[n])})}),s}getCurrentQuery(){return a(this,X)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=a(this,ce).defaultQueryOptions(t),n=a(this,ce).getQueryCache().build(a(this,ce),s);return n.isFetchingOptimistic=!0,n.fetch().then(()=>this.createResult(n,s))}fetch(t){return K(this,rt,Kt).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),a(this,oe)))}createResult(t,s){var F;const n=a(this,X),r=this.options,i=a(this,oe),o=a(this,et),u=a(this,_t),c=t!==n?t.state:a(this,Ot),{state:h}=t;let{error:g,errorUpdatedAt:A,fetchStatus:v,status:_}=h,B=!1,b;if(s._optimisticResults){const q=this.hasListeners(),N=!q&&Nr(t,s),m=q&&Tr(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,ns))b=a(this,Bt);else try{k(this,ns,s.select),b=s.select(h.data),b=ln(i==null?void 0:i.data,b,s),k(this,Bt,b),k(this,je,null)}catch(q){k(this,je,q)}else b=h.data;if(typeof s.placeholderData<"u"&&typeof b>"u"&&_==="pending"){let q;if(i!=null&&i.isPlaceholderData&&s.placeholderData===(u==null?void 0:u.placeholderData))q=i.data;else if(q=typeof s.placeholderData=="function"?s.placeholderData((F=a(this,Rt))==null?void 0:F.state.data,a(this,Rt)):s.placeholderData,s.select&&typeof q<"u")try{q=s.select(q),k(this,je,null)}catch(N){k(this,je,N)}typeof q<"u"&&(_="success",b=ln(i==null?void 0:i.data,q,s),B=!0)}a(this,je)&&(g=a(this,je),b=a(this,Bt),A=Date.now(),_="error");const j=v==="fetching",U=_==="pending",M=_==="error",E=U&&j;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>c.dataUpdateCount||h.errorUpdateCount>c.errorUpdateCount,isFetching:j,isRefetching:j&&!U,isLoadingError:M&&h.dataUpdatedAt===0,isPaused:v==="paused",isPlaceholderData:B,isRefetchError:M&&h.dataUpdatedAt!==0,isStale:$n(t,s),refetch:this.refetch}}updateResult(t){const s=a(this,oe),n=this.createResult(a(this,X),this.options);if(k(this,et,a(this,X).state),k(this,_t,this.options),a(this,et).data!==void 0&&k(this,Rt,a(this,X)),Rs(n,s))return;k(this,oe,n);const r={},i=()=>{if(!s)return!0;const{notifyOnChangeProps:o}=this.options,u=typeof o=="function"?o():o;if(u==="all"||!u&&!a(this,nt).size)return!0;const l=new Set(u??a(this,nt));return this.options.throwOnError&&l.add("error"),Object.keys(a(this,oe)).some(c=>{const h=c;return a(this,oe)[h]!==s[h]&&l.has(h)})};(t==null?void 0:t.listeners)!==!1&&i()&&(r.listeners=!0),K(this,Ms,go).call(this,{...r,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&K(this,as,pn).call(this)}},ce=new WeakMap,X=new WeakMap,Ot=new WeakMap,oe=new WeakMap,et=new WeakMap,_t=new WeakMap,je=new WeakMap,ns=new WeakMap,Bt=new WeakMap,Rt=new WeakMap,tt=new WeakMap,st=new WeakMap,Ke=new WeakMap,nt=new WeakMap,rt=new WeakSet,Kt=function(t){K(this,ls,yn).call(this);let s=a(this,X).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(ve)),s},rs=new WeakSet,dn=function(){if(K(this,us,mn).call(this),Nt||a(this,oe).isStale||!un(this.options.staleTime))return;const s=uo(a(this,oe).dataUpdatedAt,this.options.staleTime)+1;k(this,tt,setTimeout(()=>{a(this,oe).isStale||this.updateResult()},s))},is=new WeakSet,fn=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(a(this,X)):this.options.refetchInterval)??!1},os=new WeakSet,hn=function(t){K(this,cs,gn).call(this),k(this,Ke,t),!(Nt||this.options.enabled===!1||!un(a(this,Ke))||a(this,Ke)===0)&&k(this,st,setInterval(()=>{(this.options.refetchIntervalInBackground||Is.isFocused())&&K(this,rt,Kt).call(this)},a(this,Ke)))},as=new WeakSet,pn=function(){K(this,rs,dn).call(this),K(this,os,hn).call(this,K(this,is,fn).call(this))},us=new WeakSet,mn=function(){a(this,tt)&&(clearTimeout(a(this,tt)),k(this,tt,void 0))},cs=new WeakSet,gn=function(){a(this,st)&&(clearInterval(a(this,st)),k(this,st,void 0))},ls=new WeakSet,yn=function(){const t=a(this,ce).getQueryCache().build(a(this,ce),this.options);if(t===a(this,X))return;const s=a(this,X);k(this,X,t),k(this,Ot,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},Ms=new WeakSet,go=function(t){se.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(a(this,oe))}),a(this,ce).getQueryCache().notify({query:a(this,X),type:"observerResultsUpdated"})})},Gr);function yl(e,t){return t.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Nr(e,t){return yl(e,t)||e.state.dataUpdatedAt>0&&vn(e,t,t.refetchOnMount)}function vn(e,t,s){if(t.enabled!==!1){const n=typeof s=="function"?s(e):s;return n==="always"||n!==!1&&$n(e,t)}return!1}function Tr(e,t,s,n){return s.enabled!==!1&&(e!==t||n.enabled===!1)&&(!s.suspense||e.state.status!=="error")&&$n(e,s)}function $n(e,t){return e.isStaleByTime(t.staleTime)}function vl(e,t){return!Rs(e.getCurrentResult(),t)}var ze,ae,ye,Re,It,Cs,ds,bn,Hr,bl=(Hr=class extends qt{constructor(t,s){super();I(this,It);I(this,ds);I(this,ze,void 0);I(this,ae,void 0);I(this,ye,void 0);I(this,Re,void 0);k(this,ae,void 0),k(this,ze,t),this.setOptions(s),this.bindMethods(),K(this,It,Cs).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,ze).defaultMutationOptions(t),Rs(s,this.options)||a(this,ze).getMutationCache().notify({type:"observerOptionsUpdated",mutation:a(this,ye),observer:this}),(n=a(this,ye))==null||n.setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=a(this,ye))==null||t.removeObserver(this)}onMutationUpdate(t){K(this,It,Cs).call(this),K(this,ds,bn).call(this,t)}getCurrentResult(){return a(this,ae)}reset(){k(this,ye,void 0),K(this,It,Cs).call(this),K(this,ds,bn).call(this)}mutate(t,s){var n;return k(this,Re,s),(n=a(this,ye))==null||n.removeObserver(this),k(this,ye,a(this,ze).getMutationCache().build(a(this,ze),this.options)),a(this,ye).addObserver(this),a(this,ye).execute(t)}},ze=new WeakMap,ae=new WeakMap,ye=new WeakMap,Re=new WeakMap,It=new WeakSet,Cs=function(){var s;const t=((s=a(this,ye))==null?void 0:s.state)??mo();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})},ds=new WeakSet,bn=function(t){se.batch(()=>{var s,n,r,i,o,u,l,c;a(this,Re)&&this.hasListeners()&&((t==null?void 0:t.type)==="success"?((n=(s=a(this,Re)).onSuccess)==null||n.call(s,t.data,a(this,ae).variables,a(this,ae).context),(i=(r=a(this,Re)).onSettled)==null||i.call(r,t.data,null,a(this,ae).variables,a(this,ae).context)):(t==null?void 0:t.type)==="error"&&((u=(o=a(this,Re)).onError)==null||u.call(o,t.error,a(this,ae).variables,a(this,ae).context),(c=(l=a(this,Re)).onSettled)==null||c.call(l,void 0,t.error,a(this,ae).variables,a(this,ae).context))),this.listeners.forEach(h=>{h(a(this,ae))})})},Hr),yo=re.createContext(void 0),Ee=e=>{const t=re.useContext(yo);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},xl=({client:e,children:t})=>(re.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),re.createElement(yo.Provider,{value:e},t)),vo=re.createContext(!1),Sl=()=>re.useContext(vo);vo.Provider;function wl(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var El=re.createContext(wl()),kl=()=>re.useContext(El);function bo(e,t){return typeof e=="function"?e(...t):!!e}var Al=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},Pl=e=>{re.useEffect(()=>{e.clearReset()},[e])},Cl=({result:e,errorResetBoundary:t,throwOnError:s,query:n})=>e.isError&&!t.isReset()&&!e.isFetching&&bo(s,[e.error,n]),jl=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},Ol=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,_l=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Bl(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=Ee(s),r=Sl(),i=kl(),o=n.defaultQueryOptions(e);o._optimisticResults=r?"isRestoring":"optimistic",jl(o),Al(o,i),Pl(i);const[u]=re.useState(()=>new t(n,o)),l=u.getOptimisticResult(o);if(re.useSyncExternalStore(re.useCallback(c=>{const h=r?()=>{}:u.subscribe(se.batchCalls(c));return u.updateResult(),h},[u,r]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),re.useEffect(()=>{u.setOptions(o,{listeners:!1})},[o,u]),Ol(o,l))throw _l(o,u,i);if(Cl({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:u.getCurrentQuery()}))throw l.error;return o.notifyOnChangeProps?l:u.trackResult(l)}function Ks(e,t){return Bl(e,gl,t)}function Ft(e,t){const s=Ee(t),[n]=re.useState(()=>new bl(s,e));re.useEffect(()=>{n.setOptions(e)},[n,e]);const r=re.useSyncExternalStore(re.useCallback(o=>n.subscribe(se.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=re.useCallback((o,u)=>{n.mutate(o,u).catch(Rl)},[n]);if(r.error&&bo(n.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:i,mutateAsync:r.mutate}}function Rl(){}function _e(){return Ee().getQueryData(["apiBaseUrl"])||"/api/chaibuilder"}const Il=()=>{const e=_e(),t=Ee();return Ft({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"]}),ot.toast.success("Authenticated successfully.")},onError:()=>{ot.toast.error("Incorrect password. Please try again.")}})},Dl=()=>{const e=_e();return Ks({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}}}})},Ml=()=>{const[e,t]=L.useState(""),{mutate:s,isPending:n}=Il(),r=()=>{s({password:e})};return C.jsxRuntimeExports.jsx("section",{className:"py-10 h-screen bg-gray-50 sm:py-16 lg:py-24",children:C.jsxRuntimeExports.jsxs("div",{className:"px-4 mx-auto max-w-7xl sm:px-6 lg:px-8",children:[C.jsxRuntimeExports.jsxs("div",{className:"max-w-2xl mx-auto text-center",children:[C.jsxRuntimeExports.jsx("h2",{className:"text-3xl font-bold leading-tight text-black sm:text-4xl lg:text-5xl",children:"Your Brand"}),C.jsxRuntimeExports.jsx("p",{className:"max-w-xl mx-auto mt-4 text-base leading-relaxed text-gray-600",children:"Enter password to continue"})]}),C.jsxRuntimeExports.jsx("div",{className:"relative max-w-md mx-auto mt-8 md:mt-16",children:C.jsxRuntimeExports.jsx("div",{className:"overflow-hidden bg-white rounded-md shadow-md",children:C.jsxRuntimeExports.jsx("div",{className:"px-4 py-6 sm:px-8 sm:py-7",children:C.jsxRuntimeExports.jsx("div",{children:C.jsxRuntimeExports.jsxs("div",{className:"space-y-5",children:[C.jsxRuntimeExports.jsxs("div",{children:[C.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between",children:C.jsxRuntimeExports.jsx("label",{htmlFor:"pwd",className:"text-base font-medium text-gray-900",children:"Password"})}),C.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[C.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:C.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:C.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"})})}),C.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"})]})]}),C.jsxRuntimeExports.jsx("div",{children:C.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"})})]})})})})})]})})},ms=()=>{const e=Ee();let t=e.getQueryData(["currentPage"]);return t||(t=localStorage.getItem("currentPage")),[t||"",s=>{localStorage.setItem("currentPage",s||""),e.setQueryData(["currentPage"],s||"")}]},zs=()=>{const[e,t]=ms(),s=_e();return Ks({queryKey:["project"],queryFn:async()=>{const n=await fetch(`${s}/project`).then(r=>r.json());return!e&&n&&t(n.homepage),n}})},Vn=()=>{const{data:e}=zs(),t=_e(),s=e==null?void 0:e.uuid;return Ks({queryKey:["pages",s],queryFn:async()=>await fetch(`${t}/pages`).then(r=>r.json())||[],enabled:!!s})},Ll=()=>{const[e,t]=ms(),{data:s}=zs(),n=_e();return Ks({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})},js=()=>C.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen",children:C.jsxRuntimeExports.jsx("div",{className:"flex h-full w-full justify-center items-center",children:C.jsxRuntimeExports.jsxs("div",{role:"status",children:[C.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:[C.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"}),C.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"})]}),C.jsxRuntimeExports.jsx("p",{children:"Loading... Please wait..."}),C.jsxRuntimeExports.jsx("span",{className:"sr-only",children:"Loading..."})]})})}),xo=(e="Project updated successfully.")=>{const t=Ee(),s=_e();return Ft({mutationFn:async n=>await fetch(`${s}/project`,{method:"PUT",body:JSON.stringify(n)}),onSuccess:()=>{t.invalidateQueries({queryKey:["project"]}),ot.toast.success(e)}})},So=()=>{const[e]=["SAVED"],[t,s]=ms(),n=Dn();return r=>e==="UNSAVED"?(fe.toast({variant:"destructive",title:"Please save unsaved changes"}),!1):t===r.uuid?!1:(n(),setTimeout(()=>{s(r.uuid)},100),!0)},Nl=()=>{const e=Ee(),t=So(),s=_e();return Ft({mutationFn:async n=>fetch(`${s}/pages`,{method:"POST",body:JSON.stringify(n)}).then(r=>r.json()),onSuccess:n=>{e.invalidateQueries({queryKey:["pages"]}),t({uuid:n.uuid,slug:n.slug}),ot.toast.success("Page added successfully.")}})},Tl=()=>{const e=_e();return Ft({mutationFn:async t=>fetch(`${e}/page?uuid=${t.uuid}`,{method:"PUT",body:JSON.stringify(t)})})},Ul=()=>{const e=_e(),{data:t}=Vn(),[s]=ms();return Ft({mutationFn:async()=>{const n=t.find(r=>r.uuid===s).slug;await fetch(`${e}/publish?slug=${n}`,{method:"GET"})},onSuccess:()=>{ot.toast.success("Page published successfully.",{position:"top-right",duration:2e3})}})},ql=()=>{const e=Ee(),t=_e();return Ft({mutationFn:async s=>fetch(`${t}/page?uuid=${s.uuid}`,{method:"DELETE"}),onSuccess:()=>{ot.toast.success("Page deleted successfully."),e.invalidateQueries({queryKey:["pages"]})}})},Fl=L.lazy(()=>Promise.resolve().then(()=>require("./PagesPanel-27e831e4.cjs"))),$l=L.lazy(()=>Promise.resolve().then(()=>require("./ProjectPanel-d77ca4b1.cjs"))),Vl=()=>C.jsxRuntimeExports.jsx("h2",{children:"Your Logo"}),Ql=()=>{const e=Ee();return C.jsxRuntimeExports.jsx("div",{className:"border-gray-200 rounded-md p-2 mb-2 border",children:C.jsxRuntimeExports.jsx(Oo.LogOutIcon,{className:"w-4 h-4 text-red-500",onClick:()=>{localStorage.removeItem("__anon_token"),e.invalidateQueries({queryKey:["verify"]})}})})},Kl=()=>{const{mutate:e}=Ul();return C.jsxRuntimeExports.jsx(fe.Button,{onClick:e,className:"bg-blue-600 text-white",children:"Publish"})},zl=e=>{const{data:t,isLoading:s}=zs(),{data:n,isLoading:r}=Vn(),{data:i}=Ll(),{mutate:o}=xo(),{logo:u=Vl}=e;return s||!t?C.jsxRuntimeExports.jsx(js,{}):r||!n?C.jsxRuntimeExports.jsx(js,{}):i?C.jsxRuntimeExports.jsx("div",{className:"bg-background text-foreground",children:C.jsxRuntimeExports.jsx(ao,{blocks:i.blocks,brandingOptions:t.brandingOptions,darkMode:e.darkMode||!1,onSaveBlocks:async({blocks:l,type:c})=>{console.log(c,l)},onSaveBrandingOptions:async l=>{o({brandingOptions:l})},topBarComponents:{left:[u],right:[Kl]},sideBarComponents:{top:[{icon:zn.FileTextIcon,name:"pages",panel:Fl},{icon:zn.GearIcon,name:"settings",panel:$l}],bottom:[Ql]}})}):C.jsxRuntimeExports.jsx(js,{})},Gl=e=>{const{data:t,isLoading:s}=Dl(),n=Ee();return L.useEffect(()=>{n.setQueryData(["apiBaseUrl"],e.apiBaseUrl||"/api/chaibuilder")},[e.apiBaseUrl,n]),s?C.jsxRuntimeExports.jsx(js,{}):t!=null&&t.valid?C.jsxRuntimeExports.jsx(zl,{...e}):C.jsxRuntimeExports.jsx(Ml,{})},Hl=new ml,Wl=e=>C.jsxRuntimeExports.jsxs(xl,{client:Hl,children:[C.jsxRuntimeExports.jsx(ot.Toaster,{richColors:!0}),C.jsxRuntimeExports.jsx(Gl,{...e})]}),Jl=e=>({...e}),Yl=e=>({...e});exports.ChaiBuilderEditor=ao;exports.ChaiBuilderStudio=Wl;exports.ErrorBoundary=Yr;exports.activePanelAtom=Ei;exports.addBlockOffCanvasAtom=ki;exports.addBlocksModalAtom=ni;exports.advanceStylingOpenAtom=bi;exports.canDeleteBlock=ya;exports.canDropBlock=ba;exports.canDuplicateBlock=ga;exports.canvasIframeAtom=wi;exports.editLayerNameAtom=Si;exports.enableStyling=Yl;exports.getBlockJSONFromSchemas=nn;exports.getBlockJSONFromUISchemas=sn;exports.inlineEditingActiveAtom=vi;exports.networkModeAtom=xi;exports.setBlockProps=Jl;exports.showPredefinedBlockCategoryAtom=Ai;exports.useActiveLanguage=Ui;exports.useActiveModal=pu;exports.useActivePanel=vu;exports.useAddBlock=Pa;exports.useAddBlockParent=bu;exports.useAddClassesToBlocks=Ba;exports.useAddPage=Nl;exports.useAllBlocks=ci;exports.useBlockContentByLanguage=Ru;exports.useBrandingOptions=Cn;exports.useBuilderReset=Dn;exports.useBuildingBlocks=di;exports.useCanvasHistory=hs;exports.useCanvasWidth=Qa;exports.useCanvasZoom=za;exports.useChangePage=So;exports.useCopyBlockIds=_i;exports.useCurrentPage=ms;exports.useCurrentPage$1=fi;exports.useCutBlockIds=Bn;exports.useDarkMode=Ga;exports.useDeletePage=ql;exports.useDeveloperPreviewMode=Wa;exports.useDuplicateBlocks=In;exports.useExpandedIds=Nu;exports.useFeatureSupport=ku;exports.useGetPageData=_n;exports.useHiddenBlockIds=Ya;exports.useHighlightBlockId=Ri;exports.useLanguages=Bu;exports.useMarkAsGlobalBlock=Xa;exports.useMoveBlocks=eu;exports.usePages=Vn;exports.usePasteBlocks=Ii;exports.usePreviewMode=Pn;exports.usePrimaryLanguage=_u;exports.useProject=zs;exports.useProject$1=nu;exports.useQueryClient=Ee;exports.useReadOnlyMode=mu;exports.useRemoveBlocks=Mi;exports.useRemoveClassesFromBlocks=iu;exports.useSavePage=Va;exports.useSelectedBlock=Ea;exports.useSelectedBlockAllClasses=ou;exports.useSelectedBlockCurrentClasses=cu;exports.useSelectedBlockIds=He;exports.useSelectedBlocksDisplayChild=wa;exports.useSelectedBreakpoints=Su;exports.useSelectedStylingBlocks=An;exports.useSetAllBlocks=ri;exports.useStylingBreakpoint=Pi;exports.useStylingState=lu;exports.useTranslations=Eu;exports.useTreeData=ma;exports.useUILibraryBlocks=Pu;exports.useUpdateBlocksProps=du;exports.useUpdateBlocksPropsRealtime=fu;exports.useUpdatePage=Tl;exports.useUpdateProject=xo;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { j as e } from "./jsx-runtime-944c88e2.js";
|
|
2
|
-
import o, { useState as
|
|
2
|
+
import o, { useState as c, Suspense as m } from "react";
|
|
3
3
|
import { HomeIcon as p, FileTextIcon as u, ChevronRightIcon as d, GearIcon as x } from "@radix-ui/react-icons";
|
|
4
4
|
import { P as g, a as h, b as f } from "./popover-f7addcf4.js";
|
|
5
|
-
import {
|
|
6
|
-
import { u as P } from "./useChangePage-6a7c7374.js";
|
|
5
|
+
import { Y as j, P as N, Z as P } from "./index-0f2acc34.js";
|
|
7
6
|
import "@radix-ui/react-popover";
|
|
8
7
|
import "./utils-ac68b2c8.js";
|
|
9
8
|
import "clsx";
|
|
@@ -29,8 +28,8 @@ import "@react-hookz/web";
|
|
|
29
28
|
import "@chaibuilder/blocks";
|
|
30
29
|
import "sonner";
|
|
31
30
|
import "lucide-react";
|
|
32
|
-
const b = o.lazy(() => import("./single-page-detail-
|
|
33
|
-
const [s, t] =
|
|
31
|
+
const b = o.lazy(() => import("./single-page-detail-69dd268b.js")), v = ({ pageData: r }) => {
|
|
32
|
+
const [s, t] = c("CLOSE");
|
|
34
33
|
return /* @__PURE__ */ e.jsxs(
|
|
35
34
|
g,
|
|
36
35
|
{
|
|
@@ -50,7 +49,7 @@ const b = o.lazy(() => import("./single-page-detail-a0332ab5.js")), v = ({ pageD
|
|
|
50
49
|
}
|
|
51
50
|
),
|
|
52
51
|
/* @__PURE__ */ e.jsx(f, { side: "right", align: "start", alignOffset: -35, className: "h-screen w-96", children: /* @__PURE__ */ e.jsx(
|
|
53
|
-
|
|
52
|
+
m,
|
|
54
53
|
{
|
|
55
54
|
fallback: /* @__PURE__ */ e.jsxs("div", { className: "flex w-full animate-pulse flex-col gap-y-3", children: [
|
|
56
55
|
/* @__PURE__ */ e.jsx("div", { className: "bg-background-300 h-6 w-1/2" }),
|
|
@@ -81,11 +80,11 @@ const b = o.lazy(() => import("./single-page-detail-a0332ab5.js")), v = ({ pageD
|
|
|
81
80
|
]
|
|
82
81
|
}
|
|
83
82
|
) : null;
|
|
84
|
-
},
|
|
83
|
+
}, ee = ({ pages: r, isLoading: s }) => s ? /* @__PURE__ */ e.jsxs("div", { className: "flex animate-pulse flex-col gap-y-1 px-2.5 pt-2", children: [
|
|
85
84
|
/* @__PURE__ */ e.jsx("div", { className: "bg-background-200 h-7 w-full" }),
|
|
86
85
|
/* @__PURE__ */ e.jsx("div", { className: "bg-background-200 h-7 w-full" }),
|
|
87
86
|
/* @__PURE__ */ e.jsx("div", { className: "bg-background-200 h-7 w-full" })
|
|
88
87
|
] }) : r.length === 0 ? /* @__PURE__ */ e.jsx("div", { className: "px-2.5 pb-2 pt-4", children: "No pages" }) : /* @__PURE__ */ e.jsx("div", { className: "-mb-2", children: o.Children.toArray(r.map((t) => /* @__PURE__ */ e.jsx(E, { ...t }))) });
|
|
89
88
|
export {
|
|
90
|
-
|
|
89
|
+
ee as default
|
|
91
90
|
};
|
|
@@ -0,0 +1 @@
|
|
|
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-334beafe.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 j=n.lazy(()=>Promise.resolve().then(()=>require("./single-page-detail-a186cd56.cjs"))),m=({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(j,{pageData:s,open:r,setOpen:t})})})]})},p=s=>{const[r]=x.useCurrentPage(),{data:t}=x.useProject(),i=x.useChangePage(),l=(t==null?void 0:t.homepage)===s.uuid,a=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 ${a?"bg-blue-200 ":""}`,onClick:c,type:"button",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-1.5",children:[l?e.jsxRuntimeExports.jsx(u.HomeIcon,{}):e.jsxRuntimeExports.jsx(u.FileTextIcon,{})," ",s.name]}),e.jsxRuntimeExports.jsx(m,{pageData:s})]}):null},d=({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(p,{...t})))});exports.default=d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./jsx-runtime-5c3ac4f7.cjs"),a=require("react"),f=require("./scroll-area-088530b9.cjs"),o=require("@chaibuilder/blocks"),m=require("./form-6eac0287.cjs"),d=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./jsx-runtime-5c3ac4f7.cjs"),a=require("react"),f=require("./scroll-area-088530b9.cjs"),o=require("@chaibuilder/blocks"),m=require("./form-6eac0287.cjs"),d=require("./index-334beafe.cjs");require("@radix-ui/react-scroll-area");require("./utils-3c452dd0.cjs");require("clsx");require("tailwind-merge");require("@rjsf/core");require("@rjsf/validator-ajv8");require("lodash");require("./link-86c532b5.cjs");require("react-icons-picker");require("react-dom");require("./dialog-170eaad9.cjs");require("@radix-ui/react-dialog");require("@radix-ui/react-icons");require("./ImagesPanel-addb2bf9.cjs");require("./tabs-860e37aa.cjs");require("@radix-ui/react-tabs");require("react-quill");require("react-i18next");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("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("sonner");require("lucide-react");function g(r){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const u=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(i,e,u.get?u:{enumerable:!0,get:()=>r[e]})}}return i.default=r,Object.freeze(i)}const j=g(a),b=({_projectData:r,seany:i})=>{const{data:e,isLoading:u}=d.useProject();j.useEffect(()=>{e&&i(e)},[e,i]);const q=({formData:l},t)=>{i(s=>({...s,[t]:l[t]}))},c={name:o.SingleLineText({title:"Project Name",default:e==null?void 0:e.name}),favicon:o.Image({title:"Favicon",default:e==null?void 0:e.favicon})};return n.jsxRuntimeExports.jsx(f.ScrollArea,{className:"flex h-full select-none flex-col",children:n.jsxRuntimeExports.jsx(m.Form,{properties:c,disabled:u,formData:r,onChange:q})})};exports.default=b;
|
|
@@ -3,7 +3,7 @@ import * as n from "react";
|
|
|
3
3
|
import { S as f } from "./scroll-area-9f64a082.js";
|
|
4
4
|
import { SingleLineText as c, Image as d } from "@chaibuilder/blocks";
|
|
5
5
|
import { F as u } from "./form-5d5c5c9e.js";
|
|
6
|
-
import { P as x } from "./index-
|
|
6
|
+
import { P as x } from "./index-0f2acc34.js";
|
|
7
7
|
import "@radix-ui/react-scroll-area";
|
|
8
8
|
import "./utils-ac68b2c8.js";
|
|
9
9
|
import "clsx";
|
|
@@ -3,12 +3,11 @@ import y, { useState as I, useEffect as L } from "react";
|
|
|
3
3
|
import { isEqual as x, isEmpty as C, isString as z, omit as j, kebabCase as B } from "lodash";
|
|
4
4
|
import { HomeIcon as G } from "@radix-ui/react-icons";
|
|
5
5
|
import { B as Y } from "./useBuilderProp-81a14920.js";
|
|
6
|
-
import { S as
|
|
7
|
-
import { SingleLineText as g, Model as
|
|
8
|
-
import { toast as
|
|
6
|
+
import { S as $ } from "./scroll-area-9f64a082.js";
|
|
7
|
+
import { SingleLineText as g, Model as q, MultilineText as Z, Image as F, Checkbox as O } from "@chaibuilder/blocks";
|
|
8
|
+
import { toast as Q } from "sonner";
|
|
9
9
|
import { F as P } from "./form-5d5c5c9e.js";
|
|
10
|
-
import {
|
|
11
|
-
import { a as X } from "./usePageActions-d6e1d325.js";
|
|
10
|
+
import { $ as U, P as V, a0 as X, O as _ } from "./index-0f2acc34.js";
|
|
12
11
|
import "@radix-ui/react-slot";
|
|
13
12
|
import "class-variance-authority";
|
|
14
13
|
import "./utils-ac68b2c8.js";
|
|
@@ -41,8 +40,7 @@ import "./MODIFIERS-c2e02614.js";
|
|
|
41
40
|
import "redux-undo";
|
|
42
41
|
import "@react-hookz/web";
|
|
43
42
|
import "lucide-react";
|
|
44
|
-
import "./
|
|
45
|
-
const K = y.lazy(() => import("./delete-page-modal-cc906461.js")), J = y.lazy(() => import("./confirm-alert-f2a47cc7.js")), h = (n) => {
|
|
43
|
+
const K = y.lazy(() => import("./delete-page-modal-1e7c44c4.js")), J = y.lazy(() => import("./confirm-alert-f2a47cc7.js")), h = (n) => {
|
|
46
44
|
if (!z(n) || !(n.includes("/[") && n.includes("]")))
|
|
47
45
|
return !1;
|
|
48
46
|
const s = /^\[((?:\.{3})?[a-zA-Z0-9_-]+)\]$/, u = /^[a-zA-Z0-9_-]+$/;
|
|
@@ -56,8 +54,8 @@ const K = y.lazy(() => import("./delete-page-modal-cc906461.js")), J = y.lazy(()
|
|
|
56
54
|
} : n, W = (n, l) => {
|
|
57
55
|
const s = !x(j(n, ["seoData"]), j(l, ["seoData"])), u = !x(f(l).seoData, f(n).seoData);
|
|
58
56
|
return s || u;
|
|
59
|
-
},
|
|
60
|
-
const u =
|
|
57
|
+
}, qe = ({ open: n, setOpen: l, pageData: s }) => {
|
|
58
|
+
const u = U(), { data: e } = V(), r = X(), c = _("Homepage updated successfully."), [i, T] = I(f(s)), [d, M] = I({
|
|
61
59
|
isHomePage: (e == null ? void 0 : e.homepage) === s.uuid
|
|
62
60
|
}), S = W(i, s);
|
|
63
61
|
L(() => {
|
|
@@ -75,7 +73,7 @@ const K = y.lazy(() => import("./delete-page-modal-cc906461.js")), J = y.lazy(()
|
|
|
75
73
|
u.invalidateQueries({
|
|
76
74
|
refetchType: "active",
|
|
77
75
|
queryKey: ["pages", e == null ? void 0 : e.uuid]
|
|
78
|
-
}), l("CLOSE"),
|
|
76
|
+
}), l("CLOSE"), Q.success("Page updated successfully.");
|
|
79
77
|
}
|
|
80
78
|
});
|
|
81
79
|
}
|
|
@@ -110,7 +108,7 @@ const K = y.lazy(() => import("./delete-page-modal-cc906461.js")), J = y.lazy(()
|
|
|
110
108
|
}),
|
|
111
109
|
slug: g({ title: "Page Slug", default: i.slug })
|
|
112
110
|
}, w = {
|
|
113
|
-
seoData:
|
|
111
|
+
seoData: q({
|
|
114
112
|
title: "",
|
|
115
113
|
description: "",
|
|
116
114
|
default: {
|
|
@@ -123,20 +121,20 @@ const K = y.lazy(() => import("./delete-page-modal-cc906461.js")), J = y.lazy(()
|
|
|
123
121
|
title: "Meta Title",
|
|
124
122
|
default: i.name
|
|
125
123
|
}),
|
|
126
|
-
description:
|
|
124
|
+
description: Z({
|
|
127
125
|
title: "Meta Description",
|
|
128
126
|
default: i.slug
|
|
129
127
|
}),
|
|
130
|
-
image:
|
|
128
|
+
image: F({ title: "Social Media Image", default: "" })
|
|
131
129
|
}
|
|
132
130
|
})
|
|
133
131
|
}, R = {
|
|
134
|
-
isHomePage:
|
|
132
|
+
isHomePage: O({
|
|
135
133
|
title: "Set as homepage",
|
|
136
134
|
default: d.isHomePage
|
|
137
135
|
})
|
|
138
136
|
};
|
|
139
|
-
return /* @__PURE__ */ t.jsxs(
|
|
137
|
+
return /* @__PURE__ */ t.jsxs($, { className: "flex h-full select-none flex-col", children: [
|
|
140
138
|
/* @__PURE__ */ t.jsx(
|
|
141
139
|
J,
|
|
142
140
|
{
|
|
@@ -204,5 +202,5 @@ const K = y.lazy(() => import("./delete-page-modal-cc906461.js")), J = y.lazy(()
|
|
|
204
202
|
] });
|
|
205
203
|
};
|
|
206
204
|
export {
|
|
207
|
-
|
|
205
|
+
qe as default
|
|
208
206
|
};
|
|
@@ -0,0 +1 @@
|
|
|
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"),p=require("./form-6eac0287.cjs"),P=require("./index-334beafe.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");const z=q.lazy(()=>Promise.resolve().then(()=>require("./delete-page-modal-83b69ad2.cjs"))),B=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},h=n=>n&&c.isEmpty(n.seoData)?{...n,seoData:{title:"",description:"",image:""}}:n,G=(n,o)=>{const i=!c.isEqual(c.omit(n,["seoData"]),c.omit(o,["seoData"])),g=!c.isEqual(h(o).seoData,h(n).seoData);return i||g},Y=({open:n,setOpen:o,pageData:i})=>{const g=P.useQueryClient(),{data:e}=P.useProject(),u=P.useUpdatePage(),m=P.useUpdateProject("Homepage updated successfully."),[s,b]=q.useState(h(i)),[a,y]=q.useState({isHomePage:(e==null?void 0:e.homepage)===i.uuid}),j=G(s,i);q.useEffect(()=>{const l=!c.isEqual(h(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(B,{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(p.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(p.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(p.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(z,{pageData:i,projectData:e})]})]})})]})};exports.default=Y;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-5c3ac4f7.cjs"),g=require("react"),R=require("lodash"),x=require("./useBuilderProp-5e57d0c8.cjs"),a=require("./dialog-170eaad9.cjs"),q=require("@chaibuilder/blocks"),b=require("./form-6eac0287.cjs"),f=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-icons");require("@radix-ui/react-toast");require("jotai");require("@radix-ui/react-dialog");require("@rjsf/core");require("@rjsf/validator-ajv8");require("./link-86c532b5.cjs");require("react-icons-picker");require("react-dom");require("./ImagesPanel-addb2bf9.cjs");require("./tabs-860e37aa.cjs");require("@radix-ui/react-tabs");require("react-quill");require("react-i18next");require("./index-1217461b.cjs");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("sonner");require("lucide-react");require("./useChangePage-f22cea36.cjs");const E=({closeModal:i})=>{var l,o;const s=f.useAddPage(),[r,m]=g.useState({name:"",slug:"",blocks:[],type:"STATIC",seoData:{}}),p=()=>{s.mutate(r,{onSuccess:()=>i()})},j=({formData:u},t)=>{m(h=>{var d,c;const n={[t]:u[t]};return t==="name"?n.slug=R.kebabCase((d=u[t])==null?void 0:d.replace(/\d/g,"")):t==="slug"&&(n.slug=(c=u[t])==null?void 0:c.replace(/\d/g,"").replace(/\s+/g,"").replace("--","-").replace("__","_")),{...h,...n}})},P={name:q.SingleLineText({title:"Page Name",default:r.name}),slug:q.SingleLineText({title:"Page Slug",default:r.slug})};return e.jsxRuntimeExports.jsxs(a.DialogContent,{children:[e.jsxRuntimeExports.jsx("div",{className:"px-1 font-bold",children:"Add Page"}),e.jsxRuntimeExports.jsx(b.Form,{formData:r,properties:P,onChange:j,disabled:s.isPending}),e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-end",children:e.jsxRuntimeExports.jsx(x.Button,{type:"submit",disabled:!r.name||!r.slug||((l=r.name)==null?void 0:l.length)<2||((o=r.slug)==null?void 0:o.length)<2||s.isPending,onClick:p,children:"Add Page"})})]})},S=()=>{const[i,s]=g.useState(!1);return e.jsxRuntimeExports.jsxs(a.Dialog,{open:i,onOpenChange:()=>s(!i),children:[e.jsxRuntimeExports.jsx(a.DialogTrigger,{children:e.jsxRuntimeExports.jsx(x.Button,{size:"sm",variant:"link",className:"text-blue-500",onClick:()=>s(!i),children:"+ New Page"})}),i&&e.jsxRuntimeExports.jsx(E,{closeModal:()=>s(!i)})]})};exports.default=S;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-5c3ac4f7.cjs"),l=require("./useBuilderProp-5e57d0c8.cjs"),r=require("./alert-dialog-4ce6ed22.cjs"),d=require("./usePageActions-5e28a006.cjs");require("react");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-icons");require("@radix-ui/react-toast");require("jotai");require("lodash");require("@radix-ui/react-alert-dialog");require("./index-1217461b.cjs");require("i18next");require("react-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("@chaibuilder/blocks");require("sonner");require("lucide-react");require("./useChangePage-f22cea36.cjs");const x=({pageData:i,projectData:s})=>{const n={},t=d.useDeletePage(),u=i.uuid===s.homepage,o=()=>{t.mutate(i,{onSuccess:()=>{n({uuid:s.homepage,slug:"/home"})}})};return e.jsxRuntimeExports.jsxs(r.AlertDialog,{children:[e.jsxRuntimeExports.jsx(r.AlertDialogTrigger,{disabled:u,children:e.jsxRuntimeExports.jsx("div",{className:`flex h-full items-center justify-center rounded-md border px-2 py-2 font-medium hover:bg-red-400 hover:text-white ${u?"cursor-not-allowed border-red-200 text-red-200":"cursor-pointer border-red-400 text-red-400"}`,children:e.jsxRuntimeExports.jsx("div",{children:"Del"})})}),e.jsxRuntimeExports.jsxs(r.AlertDialogContent,{children:[e.jsxRuntimeExports.jsxs(r.AlertDialogTitle,{children:["Are you sure you want to delete ",e.jsxRuntimeExports.jsx("i",{className:"text-red-500",children:i.name})," page?"]}),e.jsxRuntimeExports.jsx(r.AlertDialogDescription,{children:"This action cannot be undone. This will permanently delete your page."}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-end gap-x-3",children:[e.jsxRuntimeExports.jsx(r.AlertDialogCancel,{disabled:t.isPending,children:"Cancel"}),e.jsxRuntimeExports.jsx(l.Button,{variant:"destructive",onClick:o,disabled:t.isPending,children:"Yes, Delete"})]})]})]})};exports.default=x;
|