@chaibuilder/pages 0.1.0 → 0.1.2

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.
@@ -1,2 +0,0 @@
1
- "use strict";var Ns=e=>{throw TypeError(e)};var Cs=(e,t,s)=>t.has(e)||Ns("Cannot "+s);var D=(e,t,s)=>(Cs(e,t,"read from private field"),s?s.call(e):t.get(e)),X=(e,t,s)=>t.has(e)?Ns("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),Y=(e,t,s,n)=>(Cs(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s);const r=require("react/jsx-runtime"),ve=require("@chaibuilder/sdk"),Vn=require("@chaibuilder/sdk/web-blocks"),F=require("@tanstack/react-query"),v=require("react"),g=require("lodash-es"),I=require("lucide-react"),Ht=require("jotai"),Bs=require("@chaibuilder/runtime"),ae=require("sonner"),u=require("@chaibuilder/sdk/ui");function Wn(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 he=Wn(v);var G={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return As(this.context.count)},getNextContextId(){return As(this.context.count++)}};function As(e){const t=String(e),s=t.length-1;return G.context.id+(s?String.fromCharCode(96+s):"")+t}function lt(e){G.context=e}var Kn=(e,t)=>e===t,Dt=Symbol("solid-proxy"),Os=typeof Proxy=="function",us=Symbol("solid-track"),Gt={equals:Kn},Rs=Ks,De=1,Mt=2,Fs={owned:null,cleanups:null,context:null,owner:null},Yt={},Q=null,Xt=null,zn=null,Z=null,ye=null,Le=null,$t=0;function Ge(e,t){const s=Z,n=Q,a=e.length===0,i=t===void 0?n:t,o=a?Fs:{owned:null,cleanups:null,context:i?i.context:null,owner:i},l=a?e:()=>e(()=>fe(()=>ft(o)));Q=o,Z=null;try{return Te(l,!0)}finally{Z=s,Q=n}}function le(e,t){t=t?Object.assign({},Gt,t):Gt;const s={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},n=a=>(typeof a=="function"&&(a=a(s.value)),Ws(s,a));return[Vs.bind(s),n]}function qs(e,t,s){const n=Vt(e,t,!0,De);ot(n)}function Me(e,t,s){const n=Vt(e,t,!1,De);ot(n)}function ds(e,t,s){Rs=lr;const n=Vt(e,t,!1,De);(!s||!s.render)&&(n.user=!0),Le?Le.push(n):ot(n)}function xe(e,t,s){s=s?Object.assign({},Gt,s):Gt;const n=Vt(e,t,!0,0);return n.observers=null,n.observerSlots=null,n.comparator=s.equals||void 0,ot(n),Vs.bind(n)}function Qn(e){return e&&typeof e=="object"&&"then"in e}function Yn(e,t,s){let n,a,i;arguments.length===1?(n=!0,a=e,i={}):(n=e,a=t,i={});let o=null,l=Yt,c=null,h=!1,f="initialValue"in i,m=typeof n=="function"&&xe(n);const C=new Set,[x,S]=(i.storage||le)(i.initialValue),[w,j]=le(void 0),[P,V]=le(void 0,{equals:!1}),[N,p]=le(f?"ready":"unresolved");G.context&&(c=G.getNextContextId(),i.ssrLoadFrom==="initial"?l=i.initialValue:G.load&&G.has(c)&&(l=G.load(c)));function E(M,W,K,re){return o===M&&(o=null,re!==void 0&&(f=!0),(M===l||W===l)&&i.onHydrated&&queueMicrotask(()=>i.onHydrated(re,{value:W})),l=Yt,ee(W,K)),W}function ee(M,W){Te(()=>{W===void 0&&S(()=>M),p(W!==void 0?"errored":f?"ready":"unresolved"),j(W);for(const K of C.keys())K.decrement();C.clear()},!1)}function A(){const M=ar,W=x(),K=w();if(K!==void 0&&!o)throw K;return Z&&Z.user,W}function q(M=!0){if(M!==!1&&h)return;h=!1;const W=m?m():n;if(W==null||W===!1){E(o,fe(x));return}const K=l!==Yt?l:fe(()=>a(W,{value:x(),refetching:M}));return Qn(K)?(o=K,"value"in K?(K.status==="success"?E(o,K.value,void 0,W):E(o,void 0,ts(K.value),W),K):(h=!0,queueMicrotask(()=>h=!1),Te(()=>{p(f?"refreshing":"pending"),V()},!1),K.then(re=>E(K,re,void 0,W),re=>E(K,void 0,ts(re),W)))):(E(o,K,void 0,W),K)}return Object.defineProperties(A,{state:{get:()=>N()},error:{get:()=>w()},loading:{get(){const M=N();return M==="pending"||M==="refreshing"}},latest:{get(){if(!f)return A();const M=w();if(M&&!o)throw M;return x()}}}),m?qs(()=>q(!1)):q(!1),[A,{refetch:q,mutate:S}]}function Xn(e){return Te(e,!1)}function fe(e){if(Z===null)return e();const t=Z;Z=null;try{return e()}finally{Z=t}}function Zn(e,t,s){const n=Array.isArray(e);let a,i=s&&s.defer;return o=>{let l;if(n){l=Array(e.length);for(let h=0;h<e.length;h++)l[h]=e[h]()}else l=e();if(i)return i=!1,o;const c=fe(()=>t(l,a,o));return a=l,c}}function Hs(e){ds(()=>fe(e))}function at(e){return Q===null||(Q.cleanups===null?Q.cleanups=[e]:Q.cleanups.push(e)),e}function Ts(){return Q}function Jn(e,t){const s=Q,n=Z;Q=e,Z=null;try{return Te(t,!0)}catch(a){hs(a)}finally{Q=s,Z=n}}function er(e){const t=Z,s=Q;return Promise.resolve().then(()=>{Z=t,Q=s;let n;return Te(e,!1),Z=Q=null,n?n.done:void 0})}var[tr,Li]=le(!1);function sr(){return[tr,er]}function nr(e,t){const s=Symbol("context");return{id:s,Provider:cr(s),defaultValue:e}}function rr(e){let t;return Q&&Q.context&&(t=Q.context[e.id])!==void 0?t:e.defaultValue}function $s(e){const t=xe(e),s=xe(()=>ss(t()));return s.toArray=()=>{const n=s();return Array.isArray(n)?n:n!=null?[n]:[]},s}var ar;function Vs(){if(this.sources&&this.state)if(this.state===De)ot(this);else{const e=ye;ye=null,Te(()=>Bt(this),!1),ye=e}if(Z){const e=this.observers?this.observers.length:0;Z.sources?(Z.sources.push(this),Z.sourceSlots.push(e)):(Z.sources=[this],Z.sourceSlots=[e]),this.observers?(this.observers.push(Z),this.observerSlots.push(Z.sources.length-1)):(this.observers=[Z],this.observerSlots=[Z.sources.length-1])}return this.value}function Ws(e,t,s){let n=e.value;return(!e.comparator||!e.comparator(n,t))&&(e.value=t,e.observers&&e.observers.length&&Te(()=>{for(let a=0;a<e.observers.length;a+=1){const i=e.observers[a],o=Xt&&Xt.running;o&&Xt.disposed.has(i),(o?!i.tState:!i.state)&&(i.pure?ye.push(i):Le.push(i),i.observers&&zs(i)),o||(i.state=De)}if(ye.length>1e6)throw ye=[],new Error},!1)),t}function ot(e){if(!e.fn)return;ft(e);const t=$t;ir(e,e.value,t)}function ir(e,t,s){let n;const a=Q,i=Z;Z=Q=e;try{n=e.fn(t)}catch(o){return e.pure&&(e.state=De,e.owned&&e.owned.forEach(ft),e.owned=null),e.updatedAt=s+1,hs(o)}finally{Z=i,Q=a}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?Ws(e,n):e.value=n,e.updatedAt=s)}function Vt(e,t,s,n=De,a){const i={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:Q,context:Q?Q.context:null,pure:s};return Q===null||Q!==Fs&&(Q.owned?Q.owned.push(i):Q.owned=[i]),i}function Ut(e){if(e.state===0)return;if(e.state===Mt)return Bt(e);if(e.suspense&&fe(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<$t);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===De)ot(e);else if(e.state===Mt){const n=ye;ye=null,Te(()=>Bt(e,t[0]),!1),ye=n}}function Te(e,t){if(ye)return e();let s=!1;t||(ye=[]),Le?s=!0:Le=[],$t++;try{const n=e();return or(s),n}catch(n){s||(Le=null),ye=null,hs(n)}}function or(e){if(ye&&(Ks(ye),ye=null),e)return;const t=Le;Le=null,t.length&&Te(()=>Rs(t),!1)}function Ks(e){for(let t=0;t<e.length;t++)Ut(e[t])}function lr(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:Ut(n)}if(G.context){if(G.count){G.effects||(G.effects=[]),G.effects.push(...e.slice(0,s));return}lt()}for(G.effects&&(G.done||!G.count)&&(e=[...G.effects,...e],s+=G.effects.length,delete G.effects),t=0;t<s;t++)Ut(e[t])}function Bt(e,t){e.state=0;for(let s=0;s<e.sources.length;s+=1){const n=e.sources[s];if(n.sources){const a=n.state;a===De?n!==t&&(!n.updatedAt||n.updatedAt<$t)&&Ut(n):a===Mt&&Bt(n,t)}}}function zs(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=Mt,s.pure?ye.push(s):Le.push(s),s.observers&&zs(s))}}function ft(e){let t;if(e.sources)for(;e.sources.length;){const s=e.sources.pop(),n=e.sourceSlots.pop(),a=s.observers;if(a&&a.length){const i=a.pop(),o=s.observerSlots.pop();n<a.length&&(i.sourceSlots[o]=n,a[n]=i,s.observerSlots[n]=o)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)ft(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)ft(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function ts(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function hs(e,t=Q){throw ts(e)}function ss(e){if(typeof e=="function"&&!e.length)return ss(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const n=ss(e[s]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function cr(e,t){return function(n){let a;return Me(()=>a=fe(()=>(Q.context={...Q.context,[e]:n.value},$s(()=>n.children))),void 0),a}}var ns=Symbol("fallback");function Ot(e){for(let t=0;t<e.length;t++)e[t]()}function ur(e,t,s={}){let n=[],a=[],i=[],o=0,l=t.length>1?[]:null;return at(()=>Ot(i)),()=>{let c=e()||[],h=c.length,f,m;return c[us],fe(()=>{let x,S,w,j,P,V,N,p,E;if(h===0)o!==0&&(Ot(i),i=[],n=[],a=[],o=0,l&&(l=[])),s.fallback&&(n=[ns],a[0]=Ge(ee=>(i[0]=ee,s.fallback())),o=1);else if(o===0){for(a=new Array(h),m=0;m<h;m++)n[m]=c[m],a[m]=Ge(C);o=h}else{for(w=new Array(h),j=new Array(h),l&&(P=new Array(h)),V=0,N=Math.min(o,h);V<N&&n[V]===c[V];V++);for(N=o-1,p=h-1;N>=V&&p>=V&&n[N]===c[p];N--,p--)w[p]=a[N],j[p]=i[N],l&&(P[p]=l[N]);for(x=new Map,S=new Array(p+1),m=p;m>=V;m--)E=c[m],f=x.get(E),S[m]=f===void 0?-1:f,x.set(E,m);for(f=V;f<=N;f++)E=n[f],m=x.get(E),m!==void 0&&m!==-1?(w[m]=a[f],j[m]=i[f],l&&(P[m]=l[f]),m=S[m],x.set(E,m)):i[f]();for(m=V;m<h;m++)m in w?(a[m]=w[m],i[m]=j[m],l&&(l[m]=P[m],l[m](m))):a[m]=Ge(C);a=a.slice(0,o=h),n=c.slice(0)}return a});function C(x){if(i[m]=x,l){const[S,w]=le(m);return l[m]=w,t(c[m],S)}return t(c[m])}}}function dr(e,t,s={}){let n=[],a=[],i=[],o=[],l=0,c;return at(()=>Ot(i)),()=>{const h=e()||[],f=h.length;return h[us],fe(()=>{if(f===0)return l!==0&&(Ot(i),i=[],n=[],a=[],l=0,o=[]),s.fallback&&(n=[ns],a[0]=Ge(C=>(i[0]=C,s.fallback())),l=1),a;for(n[0]===ns&&(i[0](),i=[],n=[],a=[],l=0),c=0;c<f;c++)c<n.length&&n[c]!==h[c]?o[c](()=>h[c]):c>=n.length&&(a[c]=Ge(m));for(;c<n.length;c++)i[c]();return l=o.length=i.length=f,n=h.slice(0),a=a.slice(0,l)});function m(C){i[c]=C;const[x,S]=le(h[c]);return o[c]=S,t(x,c)}}}function fs(e,t){return fe(()=>e(t||{}))}function kt(){return!0}var rs={get(e,t,s){return t===Dt?s:e.get(t)},has(e,t){return t===Dt?!0:e.has(t)},set:kt,deleteProperty:kt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:kt,deleteProperty:kt}},ownKeys(e){return e.keys()}};function Zt(e){return(e=typeof e=="function"?e():e)?e:{}}function hr(){for(let e=0,t=this.length;e<t;++e){const s=this[e]();if(s!==void 0)return s}}function ms(...e){let t=!1;for(let o=0;o<e.length;o++){const l=e[o];t=t||!!l&&Dt in l,e[o]=typeof l=="function"?(t=!0,xe(l)):l}if(Os&&t)return new Proxy({get(o){for(let l=e.length-1;l>=0;l--){const c=Zt(e[l])[o];if(c!==void 0)return c}},has(o){for(let l=e.length-1;l>=0;l--)if(o in Zt(e[l]))return!0;return!1},keys(){const o=[];for(let l=0;l<e.length;l++)o.push(...Object.keys(Zt(e[l])));return[...new Set(o)]}},rs);const s={},n=Object.create(null);for(let o=e.length-1;o>=0;o--){const l=e[o];if(!l)continue;const c=Object.getOwnPropertyNames(l);for(let h=c.length-1;h>=0;h--){const f=c[h];if(f==="__proto__"||f==="constructor")continue;const m=Object.getOwnPropertyDescriptor(l,f);if(!n[f])n[f]=m.get?{enumerable:!0,configurable:!0,get:hr.bind(s[f]=[m.get.bind(l)])}:m.value!==void 0?m:void 0;else{const C=s[f];C&&(m.get?C.push(m.get.bind(l)):m.value!==void 0&&C.push(()=>m.value))}}}const a={},i=Object.keys(n);for(let o=i.length-1;o>=0;o--){const l=i[o],c=n[l];c&&c.get?Object.defineProperty(a,l,c):a[l]=c?c.value:void 0}return a}function Qs(e,...t){if(Os&&Dt in e){const a=new Set(t.length>1?t.flat():t[0]),i=t.map(o=>new Proxy({get(l){return o.includes(l)?e[l]:void 0},has(l){return o.includes(l)&&l in e},keys(){return o.filter(l=>l in e)}},rs));return i.push(new Proxy({get(o){return a.has(o)?void 0:e[o]},has(o){return a.has(o)?!1:o in e},keys(){return Object.keys(e).filter(o=>!a.has(o))}},rs)),i}const s={},n=t.map(()=>({}));for(const a of Object.getOwnPropertyNames(e)){const i=Object.getOwnPropertyDescriptor(e,a),o=!i.get&&!i.set&&i.enumerable&&i.writable&&i.configurable;let l=!1,c=0;for(const h of t)h.includes(a)&&(l=!0,o?n[c][a]=i.value:Object.defineProperty(n[c],a,i)),++c;l||(o?s[a]=i.value:Object.defineProperty(s,a,i))}return[...n,s]}function Ys(e){let t,s;const n=a=>{const i=G.context;if(i){const[l,c]=le();G.count||(G.count=0),G.count++,(s||(s=e())).then(h=>{!G.done&&lt(i),G.count--,c(()=>h.default),lt()}),t=l}else if(!t){const[l]=Yn(()=>(s||(s=e())).then(c=>c.default));t=l}let o;return xe(()=>(o=t())?fe(()=>{if(!i||G.done)return o(a);const l=G.context;lt(i);const c=o(a);return lt(l),c}):"")};return n.preload=()=>s||((s=e()).then(a=>t=()=>a.default),s),n}var fr=0;function mr(){return G.context?G.getNextContextId():`cl-${fr++}`}var Xs=e=>`Stale read from <${e}>.`;function gr(e){const t="fallback"in e&&{fallback:()=>e.fallback};return xe(ur(()=>e.each,e.children,t||void 0))}function yr(e){const t="fallback"in e&&{fallback:()=>e.fallback};return xe(dr(()=>e.each,e.children,t||void 0))}function xr(e){const t=e.keyed,s=xe(()=>e.when,void 0,{equals:(n,a)=>t?n===a:!n==!a});return xe(()=>{const n=s();if(n){const a=e.children;return typeof a=="function"&&a.length>0?fe(()=>a(t?n:()=>{if(!fe(s))throw Xs("Show");return e.when})):a}return e.fallback},void 0,void 0)}function pr(e){let t=!1;const s=(i,o)=>(t?i[1]===o[1]:!i[1]==!o[1])&&i[2]===o[2],n=$s(()=>e.children),a=xe(()=>{let i=n();Array.isArray(i)||(i=[i]);for(let o=0;o<i.length;o++){const l=i[o].when;if(l)return t=!!i[o].keyed,[o,l,i[o]]}return[-1]},void 0,{equals:s});return xe(()=>{const[i,o,l]=a();if(i<0)return e.fallback;const c=l.children;return typeof c=="function"&&c.length>0?fe(()=>c(t?o:()=>{if(fe(a)[0]!==i)throw Xs("Match");return l.when})):c},void 0,void 0)}function vr(e){return e}var Sr=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"],wr=new Set(["className","value","readOnly","formNoValidate","isMap","noModule","playsInline",...Sr]),Er=new Set(["innerHTML","textContent","innerText","children"]),br=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),jr=Object.assign(Object.create(null),{class:"className",formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1}});function Nr(e,t){const s=jr[e];return typeof s=="object"?s[t]?s.$:void 0:s}var Cr=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),Ar=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),Tr={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"};function Pr(e,t,s){let n=s.length,a=t.length,i=n,o=0,l=0,c=t[a-1].nextSibling,h=null;for(;o<a||l<i;){if(t[o]===s[l]){o++,l++;continue}for(;t[a-1]===s[i-1];)a--,i--;if(a===o){const f=i<n?l?s[l-1].nextSibling:s[i-l]:c;for(;l<i;)e.insertBefore(s[l++],f)}else if(i===l)for(;o<a;)(!h||!h.has(t[o]))&&t[o].remove(),o++;else if(t[o]===s[i-1]&&s[l]===t[a-1]){const f=t[--a].nextSibling;e.insertBefore(s[l++],t[o++].nextSibling),e.insertBefore(s[--i],f),t[a]=s[i]}else{if(!h){h=new Map;let m=l;for(;m<i;)h.set(s[m],m++)}const f=h.get(t[o]);if(f!=null)if(l<f&&f<i){let m=o,C=1,x;for(;++m<a&&m<i&&!((x=h.get(t[m]))==null||x!==f+C);)C++;if(C>f-l){const S=t[o];for(;l<f;)e.insertBefore(s[l++],S)}else e.replaceChild(s[l++],t[o++])}else o++;else t[o++].remove()}}}var dt="_$DX_DELEGATE";function Zs(e,t,s,n={}){let a;return Ge(i=>{a=i,t===document?e():Ft(t,e(),t.firstChild?null:void 0,s)},n.owner),()=>{a(),t.textContent=""}}function kr(e,t,s){let n;const a=()=>{const o=document.createElement("template");return o.innerHTML=e,o.content.firstChild},i=()=>(n||(n=a())).cloneNode(!0);return i.cloneNode=i,i}function Js(e,t=window.document){const s=t[dt]||(t[dt]=new Set);for(let n=0,a=e.length;n<a;n++){const i=e[n];s.has(i)||(s.add(i),t.addEventListener(i,rn))}}function Ir(e=window.document){if(e[dt]){for(let t of e[dt].keys())e.removeEventListener(t,rn);delete e[dt]}}function Rt(e,t,s){Fe(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function Lr(e,t,s,n){Fe(e)||(n==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,n))}function _r(e,t,s){Fe(e)||(s?e.setAttribute(t,""):e.removeAttribute(t))}function en(e,t){Fe(e)||(t==null?e.removeAttribute("class"):e.className=t)}function tn(e,t,s,n){if(n)Array.isArray(s)?(e[`$$${t}`]=s[0],e[`$$${t}Data`]=s[1]):e[`$$${t}`]=s;else if(Array.isArray(s)){const a=s[0];e.addEventListener(t,s[0]=i=>a.call(e,s[1],i))}else e.addEventListener(t,s,typeof s!="function"&&s)}function Dr(e,t,s={}){const n=Object.keys(t||{}),a=Object.keys(s);let i,o;for(i=0,o=a.length;i<o;i++){const l=a[i];!l||l==="undefined"||t[l]||(Ps(e,l,!1),delete s[l])}for(i=0,o=n.length;i<o;i++){const l=n[i],c=!!t[l];!l||l==="undefined"||s[l]===c||!c||(Ps(e,l,!0),s[l]=c)}return s}function Gr(e,t,s){if(!t)return s?Rt(e,"style"):t;const n=e.style;if(typeof t=="string")return n.cssText=t;typeof s=="string"&&(n.cssText=s=void 0),s||(s={}),t||(t={});let a,i;for(i in s)t[i]==null&&n.removeProperty(i),delete s[i];for(i in t)a=t[i],a!==s[i]&&(n.setProperty(i,a),s[i]=a);return s}function sn(e,t={},s,n){const a={};return n||Me(()=>a.children=mt(e,t.children,a.children)),Me(()=>typeof t.ref=="function"&&nn(t.ref,e)),Me(()=>Mr(e,t,s,!0,a,!0)),a}function nn(e,t,s){return fe(()=>e(t,s))}function Ft(e,t,s,n){if(s!==void 0&&!n&&(n=[]),typeof t!="function")return mt(e,t,n,s);Me(a=>mt(e,t(),a,s),n)}function Mr(e,t,s,n,a={},i=!1){t||(t={});for(const o in a)if(!(o in t)){if(o==="children")continue;a[o]=ks(e,o,null,a[o],s,i,t)}for(const o in t){if(o==="children")continue;const l=t[o];a[o]=ks(e,o,l,a[o],s,i,t)}}function Ur(e){let t,s;return!Fe()||!(t=G.registry.get(s=Or()))?e():(G.completed&&G.completed.add(t),G.registry.delete(s),t)}function Fe(e){return!!G.context&&!G.done&&(!e||e.isConnected)}function Br(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function Ps(e,t,s){const n=t.trim().split(/\s+/);for(let a=0,i=n.length;a<i;a++)e.classList.toggle(n[a],s)}function ks(e,t,s,n,a,i,o){let l,c,h,f,m;if(t==="style")return Gr(e,s,n);if(t==="classList")return Dr(e,s,n);if(s===n)return n;if(t==="ref")i||s(e);else if(t.slice(0,3)==="on:"){const C=t.slice(3);n&&e.removeEventListener(C,n,typeof n!="function"&&n),s&&e.addEventListener(C,s,typeof s!="function"&&s)}else if(t.slice(0,10)==="oncapture:"){const C=t.slice(10);n&&e.removeEventListener(C,n,!0),s&&e.addEventListener(C,s,!0)}else if(t.slice(0,2)==="on"){const C=t.slice(2).toLowerCase(),x=Cr.has(C);if(!x&&n){const S=Array.isArray(n)?n[0]:n;e.removeEventListener(C,S)}(x||s)&&(tn(e,C,s,x),x&&Js([C]))}else if(t.slice(0,5)==="attr:")Rt(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")_r(e,t.slice(5),s);else if((m=t.slice(0,5)==="prop:")||(h=Er.has(t))||!a&&((f=Nr(t,e.tagName))||(c=wr.has(t)))||(l=e.nodeName.includes("-")||"is"in o)){if(m)t=t.slice(5),c=!0;else if(Fe(e))return s;t==="class"||t==="className"?en(e,s):l&&!c&&!h?e[Br(t)]=s:e[f||t]=s}else{const C=a&&t.indexOf(":")>-1&&Tr[t.split(":")[0]];C?Lr(e,C,t,s):Rt(e,br[t]||t,s)}return s}function rn(e){if(G.registry&&G.events&&G.events.find(([c,h])=>h===e))return;let t=e.target;const s=`$$${e.type}`,n=e.target,a=e.currentTarget,i=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),o=()=>{const c=t[s];if(c&&!t.disabled){const h=t[`${s}Data`];if(h!==void 0?c.call(t,h,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&i(t.host),!0},l=()=>{for(;o()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),G.registry&&!G.done&&(G.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();i(c[0]);for(let h=0;h<c.length-2&&(t=c[h],!!o());h++){if(t._$host){t=t._$host,l();break}if(t.parentNode===a)break}}else l();i(n)}function mt(e,t,s,n,a){const i=Fe(e);if(i){!s&&(s=[...e.childNodes]);let c=[];for(let h=0;h<s.length;h++){const f=s[h];f.nodeType===8&&f.data.slice(0,2)==="!$"?f.remove():c.push(f)}s=c}for(;typeof s=="function";)s=s();if(t===s)return s;const o=typeof t,l=n!==void 0;if(e=l&&s[0]&&s[0].parentNode||e,o==="string"||o==="number"){if(i||o==="number"&&(t=t.toString(),t===s))return s;if(l){let c=s[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),s=qe(e,s,n,c)}else s!==""&&typeof s=="string"?s=e.firstChild.data=t:s=e.textContent=t}else if(t==null||o==="boolean"){if(i)return s;s=qe(e,s,n)}else{if(o==="function")return Me(()=>{let c=t();for(;typeof c=="function";)c=c();s=mt(e,c,s,n)}),()=>s;if(Array.isArray(t)){const c=[],h=s&&Array.isArray(s);if(as(c,t,s,a))return Me(()=>s=mt(e,c,s,n,!0)),()=>s;if(i){if(!c.length)return s;if(n===void 0)return s=[...e.childNodes];let f=c[0];if(f.parentNode!==e)return s;const m=[f];for(;(f=f.nextSibling)!==n;)m.push(f);return s=m}if(c.length===0){if(s=qe(e,s,n),l)return s}else h?s.length===0?Is(e,c,n):Pr(e,s,c):(s&&qe(e),Is(e,c));s=c}else if(t.nodeType){if(i&&t.parentNode)return s=l?[t]:t;if(Array.isArray(s)){if(l)return s=qe(e,s,n,t);qe(e,s,null,t)}else s==null||s===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);s=t}}return s}function as(e,t,s,n){let a=!1;for(let i=0,o=t.length;i<o;i++){let l=t[i],c=s&&s[e.length],h;if(!(l==null||l===!0||l===!1))if((h=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))a=as(e,l,c)||a;else if(h==="function")if(n){for(;typeof l=="function";)l=l();a=as(e,Array.isArray(l)?l:[l],Array.isArray(c)?c:[c])||a}else e.push(l),a=!0;else{const f=String(l);c&&c.nodeType===3&&c.data===f?e.push(c):e.push(document.createTextNode(f))}}return a}function Is(e,t,s=null){for(let n=0,a=t.length;n<a;n++)e.insertBefore(t[n],s)}function qe(e,t,s,n){if(s===void 0)return e.textContent="";const a=n||document.createTextNode("");if(t.length){let i=!1;for(let o=t.length-1;o>=0;o--){const l=t[o];if(a!==l){const c=l.parentNode===e;!i&&!o?c?e.replaceChild(a,l):e.insertBefore(a,s):c&&l.remove()}else i=!0}}else e.insertBefore(a,s);return[a]}function Or(){return G.getNextContextId()}var Rr="http://www.w3.org/2000/svg";function an(e,t=!1){return t?document.createElementNS(Rr,e):document.createElement(e)}function Fr(e){const{useShadow:t}=e,s=document.createTextNode(""),n=()=>e.mount||document.body,a=Ts();let i,o=!!G.context;return ds(()=>{o&&(Ts().user=o=!1),i||(i=Jn(a,()=>xe(()=>e.children)));const l=n();if(l instanceof HTMLHeadElement){const[c,h]=le(!1),f=()=>h(!0);Ge(m=>Ft(l,()=>c()?m():i(),null)),at(f)}else{const c=an(e.isSVG?"g":"div",e.isSVG),h=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return s.parentNode},configurable:!0}),Ft(h,i),l.appendChild(c),e.ref&&e.ref(c),at(()=>l.removeChild(c))}},void 0,{render:!o}),s}function qr(e){const[t,s]=Qs(e,["component"]),n=xe(()=>t.component);return xe(()=>{const a=n();switch(typeof a){case"function":return fe(()=>a(s));case"string":const i=Ar.has(a),o=G.context?Ur():an(a,i);return sn(o,s,i),o}})}var Hr=class{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,t){this.keyToValue.set(e,t),this.valueToKey.set(t,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}},on=class{constructor(e){this.generateIdentifier=e,this.kv=new Hr}register(e,t){this.kv.getByValue(e)||(t||(t=this.generateIdentifier(e)),this.kv.set(t,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}},$r=class extends on{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,t){typeof t=="object"?(t.allowProps&&this.classToAllowedProps.set(e,t.allowProps),super.register(e,t.identifier)):super.register(e,t)}getAllowedProps(e){return this.classToAllowedProps.get(e)}};function Vr(e){if("values"in Object)return Object.values(e);const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push(e[s]);return t}function Wr(e,t){const s=Vr(e);if("find"in s)return s.find(t);const n=s;for(let a=0;a<n.length;a++){const i=n[a];if(t(i))return i}}function it(e,t){Object.entries(e).forEach(([s,n])=>t(n,s))}function _t(e,t){return e.indexOf(t)!==-1}function Ls(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var Kr=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return Wr(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},zr=e=>Object.prototype.toString.call(e).slice(8,-1),ln=e=>typeof e>"u",Qr=e=>e===null,gt=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,is=e=>gt(e)&&Object.keys(e).length===0,Ue=e=>Array.isArray(e),Yr=e=>typeof e=="string",Xr=e=>typeof e=="number"&&!isNaN(e),Zr=e=>typeof e=="boolean",Jr=e=>e instanceof RegExp,yt=e=>e instanceof Map,xt=e=>e instanceof Set,cn=e=>zr(e)==="Symbol",ea=e=>e instanceof Date&&!isNaN(e.valueOf()),ta=e=>e instanceof Error,_s=e=>typeof e=="number"&&isNaN(e),sa=e=>Zr(e)||Qr(e)||ln(e)||Xr(e)||Yr(e)||cn(e),na=e=>typeof e=="bigint",ra=e=>e===1/0||e===-1/0,aa=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),ia=e=>e instanceof URL,un=e=>e.replace(/\./g,"\\."),Jt=e=>e.map(String).map(un).join("."),ht=e=>{const t=[];let s="";for(let a=0;a<e.length;a++){let i=e.charAt(a);if(i==="\\"&&e.charAt(a+1)==="."){s+=".",a++;continue}if(i==="."){t.push(s),s="";continue}s+=i}const n=s;return t.push(n),t};function Ae(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var dn=[Ae(ln,"undefined",()=>null,()=>{}),Ae(na,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),Ae(ea,"Date",e=>e.toISOString(),e=>new Date(e)),Ae(ta,"Error",(e,t)=>{const s={name:e.name,message:e.message};return t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s},(e,t)=>{const s=new Error(e.message);return s.name=e.name,s.stack=e.stack,t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s}),Ae(Jr,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),Ae(xt,"set",e=>[...e.values()],e=>new Set(e)),Ae(yt,"map",e=>[...e.entries()],e=>new Map(e)),Ae(e=>_s(e)||ra(e),"number",e=>_s(e)?"NaN":e>0?"Infinity":"-Infinity",Number),Ae(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),Ae(ia,"URL",e=>e.toString(),e=>new URL(e))];function Wt(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var hn=Wt((e,t)=>cn(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,s)=>{const n=s.symbolRegistry.getValue(t[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),oa=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),fn=Wt(aa,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=oa[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function mn(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var gn=Wt(mn,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const s=t.classRegistry.getAllowedProps(e.constructor);if(!s)return{...e};const n={};return s.forEach(a=>{n[a]=e[a]}),n},(e,t,s)=>{const n=s.classRegistry.getValue(t[1]);if(!n)throw new Error("Trying to deserialize unknown class - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564");return Object.assign(Object.create(n.prototype),e)}),yn=Wt((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,s)=>{const n=s.customTransformerRegistry.findByName(t[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(e)}),la=[gn,hn,yn,fn],Ds=(e,t)=>{const s=Ls(la,a=>a.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=Ls(dn,a=>a.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},xn={};dn.forEach(e=>{xn[e.annotation]=e});var ca=(e,t,s)=>{if(Ue(t))switch(t[0]){case"symbol":return hn.untransform(e,t,s);case"class":return gn.untransform(e,t,s);case"custom":return yn.untransform(e,t,s);case"typed-array":return fn.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const n=xn[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,s)}},He=(e,t)=>{const s=e.keys();for(;t>0;)s.next(),t--;return s.next().value};function pn(e){if(_t(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(_t(e,"prototype"))throw new Error("prototype is not allowed as a property");if(_t(e,"constructor"))throw new Error("constructor is not allowed as a property")}var ua=(e,t)=>{pn(t);for(let s=0;s<t.length;s++){const n=t[s];if(xt(e))e=He(e,+n);else if(yt(e)){const a=+n,i=+t[++s]==0?"key":"value",o=He(e,a);switch(i){case"key":e=o;break;case"value":e=e.get(o);break}}else e=e[n]}return e},os=(e,t,s)=>{if(pn(t),t.length===0)return s(e);let n=e;for(let i=0;i<t.length-1;i++){const o=t[i];if(Ue(n)){const l=+o;n=n[l]}else if(gt(n))n=n[o];else if(xt(n)){const l=+o;n=He(n,l)}else if(yt(n)){if(i===t.length-2)break;const c=+o,h=+t[++i]==0?"key":"value",f=He(n,c);switch(h){case"key":n=f;break;case"value":n=n.get(f);break}}}const a=t[t.length-1];if(Ue(n)?n[+a]=s(n[+a]):gt(n)&&(n[a]=s(n[a])),xt(n)){const i=He(n,+a),o=s(i);i!==o&&(n.delete(i),n.add(o))}if(yt(n)){const i=+t[t.length-2],o=He(n,i);switch(+a==0?"key":"value"){case"key":{const c=s(o);n.set(c,n.get(o)),c!==o&&n.delete(o);break}case"value":{n.set(o,s(n.get(o)));break}}}return e};function ls(e,t,s=[]){if(!e)return;if(!Ue(e)){it(e,(i,o)=>ls(i,t,[...s,...ht(o)]));return}const[n,a]=e;a&&it(a,(i,o)=>{ls(i,t,[...s,...ht(o)])}),t(n,s)}function da(e,t,s){return ls(t,(n,a)=>{e=os(e,a,i=>ca(i,n,s))}),e}function ha(e,t){function s(n,a){const i=ua(e,ht(a));n.map(ht).forEach(o=>{e=os(e,o,()=>i)})}if(Ue(t)){const[n,a]=t;n.forEach(i=>{e=os(e,ht(i),()=>e)}),a&&it(a,s)}else it(t,s);return e}var fa=(e,t)=>gt(e)||Ue(e)||yt(e)||xt(e)||mn(e,t);function ma(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function ga(e,t){const s={};let n;return e.forEach(a=>{if(a.length<=1)return;t||(a=a.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[i,...o]=a;i.length===0?n=o.map(Jt):s[Jt(i)]=o.map(Jt)}),n?is(s)?[n]:[n,s]:is(s)?void 0:s}var vn=(e,t,s,n,a=[],i=[],o=new Map)=>{const l=sa(e);if(!l){ma(e,a,t);const x=o.get(e);if(x)return n?{transformedValue:null}:x}if(!fa(e,s)){const x=Ds(e,s),S=x?{transformedValue:x.value,annotations:[x.type]}:{transformedValue:e};return l||o.set(e,S),S}if(_t(i,e))return{transformedValue:null};const c=Ds(e,s),h=(c==null?void 0:c.value)??e,f=Ue(h)?[]:{},m={};it(h,(x,S)=>{if(S==="__proto__"||S==="constructor"||S==="prototype")throw new Error(`Detected property ${S}. This is a prototype pollution risk, please remove it from your object.`);const w=vn(x,t,s,n,[...a,S],[...i,e],o);f[S]=w.transformedValue,Ue(w.annotations)?m[S]=w.annotations:gt(w.annotations)&&it(w.annotations,(j,P)=>{m[un(S)+"."+P]=j})});const C=is(m)?{transformedValue:f,annotations:c?[c.type]:void 0}:{transformedValue:f,annotations:c?[c.type,m]:m};return l||o.set(e,C),C};function Sn(e){return Object.prototype.toString.call(e).slice(8,-1)}function Gs(e){return Sn(e)==="Array"}function ya(e){if(Sn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function xa(e,t,s,n,a){const i={}.propertyIsEnumerable.call(n,t)?"enumerable":"nonenumerable";i==="enumerable"&&(e[t]=s),a&&i==="nonenumerable"&&Object.defineProperty(e,t,{value:s,enumerable:!1,writable:!0,configurable:!0})}function cs(e,t={}){if(Gs(e))return e.map(a=>cs(a,t));if(!ya(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((a,i)=>{if(Gs(t.props)&&!t.props.includes(i))return a;const o=e[i],l=cs(o,t);return xa(a,i,l,e,t.nonenumerable),a},{})}var J=class{constructor({dedupe:e=!1}={}){this.classRegistry=new $r,this.symbolRegistry=new on(t=>t.description??""),this.customTransformerRegistry=new Kr,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=vn(e,t,this,this.dedupe),n={json:s.transformedValue};s.annotations&&(n.meta={...n.meta,values:s.annotations});const a=ga(t,this.dedupe);return a&&(n.meta={...n.meta,referentialEqualities:a}),n}deserialize(e){const{json:t,meta:s}=e;let n=cs(t);return s!=null&&s.values&&(n=da(n,s.values,this)),s!=null&&s.referentialEqualities&&(n=ha(n,s.referentialEqualities)),n}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};J.defaultInstance=new J;J.serialize=J.defaultInstance.serialize.bind(J.defaultInstance);J.deserialize=J.defaultInstance.deserialize.bind(J.defaultInstance);J.stringify=J.defaultInstance.stringify.bind(J.defaultInstance);J.parse=J.defaultInstance.parse.bind(J.defaultInstance);J.registerClass=J.defaultInstance.registerClass.bind(J.defaultInstance);J.registerSymbol=J.defaultInstance.registerSymbol.bind(J.defaultInstance);J.registerCustom=J.defaultInstance.registerCustom.bind(J.defaultInstance);J.allowErrorProps=J.defaultInstance.allowErrorProps.bind(J.defaultInstance);var wn=J.serialize,pa=J.stringify;function va(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function Sa(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function wa({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function Ea({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function ba(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var ja=(e,t=!1)=>{const{json:s}=wn(e);return JSON.stringify(s,null,t?2:void 0)},It=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,Na=(e,t)=>e.queryHash.localeCompare(t.queryHash),En=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,Ca=(e,t)=>It(e)===It(t)?En(e,t):It(e)>It(t)?1:-1,Aa={status:Ca,"query hash":Na,"last updated":En},Lt=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,bn=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,Ta=(e,t)=>Lt(e)===Lt(t)?bn(e,t):Lt(e)>Lt(t)?1:-1,Pa={status:Ta,"last updated":bn},ka=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),Ia=()=>{const[e,t]=le("dark");return Hs(()=>{const s=window.matchMedia("(prefers-color-scheme: dark)");t(s.matches?"dark":"light");const n=a=>{t(a.matches?"dark":"light")};s.addEventListener("change",n),at(()=>s.removeEventListener("change",n))}),e},ct=(e,t,s)=>{if(t.length===0)return s;if(e instanceof Map){const n=new Map(e);if(t.length===1)return n.set(t[0],s),n;const[a,...i]=t;return n.set(a,ct(n.get(a),i,s)),n}if(e instanceof Set){const n=ct(Array.from(e),t,s);return new Set(n)}if(Array.isArray(e)){const n=[...e];if(t.length===1)return n[t[0]]=s,n;const[a,...i]=t;return n[a]=ct(n[a],i,s),n}if(e instanceof Object){const n={...e};if(t.length===1)return n[t[0]]=s,n;const[a,...i]=t;return n[a]=ct(n[a],i,s),n}return e},ut=(e,t)=>{if(e instanceof Map){const s=new Map(e);if(t.length===1)return s.delete(t[0]),s;const[n,...a]=t;return s.set(n,ut(s.get(n),a)),s}if(e instanceof Set){const s=ut(Array.from(e),t);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s.filter((i,o)=>o.toString()!==t[0]);const[n,...a]=t;return s[n]=ut(s[n],a),s}if(e instanceof Object){const s={...e};if(t.length===1)return delete s[t[0]],s;const[n,...a]=t;return s[n]=ut(s[n],a),s}return e},jn=(e,t)=>{if(!e||document.querySelector("#_goober")||(t==null?void 0:t.querySelector("#_goober")))return;const n=document.createElement("style"),a=document.createTextNode("");n.appendChild(a),n.id="_goober",n.setAttribute("nonce",e),t?t.appendChild(n):document.head.appendChild(n)},$e,pt,vt,St,Oe,wt,Ve,We,Ke,ze,Qe,Ye,Et,Ms,La=(Ms=class{constructor(e){X(this,$e);X(this,pt);X(this,vt);X(this,St);X(this,Oe,!1);X(this,wt);X(this,Ve);X(this,We);X(this,Ke);X(this,ze);X(this,Qe);X(this,Ye);X(this,Et);const{client:t,queryFlavor:s,version:n,onlineManager:a,buttonPosition:i,position:o,initialIsOpen:l,errorTypes:c,styleNonce:h,shadowDOMTarget:f}=e;Y(this,$e,le(t)),Y(this,vt,s),Y(this,St,n),Y(this,pt,a),Y(this,wt,h),Y(this,Ve,f),Y(this,We,le(i)),Y(this,Ke,le(o)),Y(this,ze,le(l)),Y(this,Qe,le(c))}setButtonPosition(e){D(this,We)[1](e)}setPosition(e){D(this,Ke)[1](e)}setInitialIsOpen(e){D(this,ze)[1](e)}setErrorTypes(e){D(this,Qe)[1](e)}setClient(e){D(this,$e)[1](e)}mount(e){if(D(this,Oe))throw new Error("Devtools is already mounted");const t=Zs(()=>{const s=this,[n]=D(this,We),[a]=D(this,Ke),[i]=D(this,ze),[o]=D(this,Qe),[l]=D(this,$e);let c;return D(this,Ye)?c=D(this,Ye):(c=Ys(()=>Promise.resolve().then(()=>require("./HO4MOOFI-CxJmuEBT.cjs"))),Y(this,Ye,c)),jn(D(this,wt),D(this,Ve)),fs(c,ms({get queryFlavor(){return D(s,vt)},get version(){return D(s,St)},get onlineManager(){return D(s,pt)},get shadowDOMTarget(){return D(s,Ve)}},{get client(){return l()},get buttonPosition(){return n()},get position(){return a()},get initialIsOpen(){return i()},get errorTypes(){return o()}}))},e);Y(this,Oe,!0),Y(this,Et,t)}unmount(){var e;if(!D(this,Oe))throw new Error("Devtools is not mounted");(e=D(this,Et))==null||e.call(this),Y(this,Oe,!1)}},$e=new WeakMap,pt=new WeakMap,vt=new WeakMap,St=new WeakMap,Oe=new WeakMap,wt=new WeakMap,Ve=new WeakMap,We=new WeakMap,Ke=new WeakMap,ze=new WeakMap,Qe=new WeakMap,Ye=new WeakMap,Et=new WeakMap,Ms),Xe,bt,jt,Nt,Re,Ct,Ze,Je,et,tt,st,nt,rt,At,Us,_a=(Us=class{constructor(e){X(this,Xe);X(this,bt);X(this,jt);X(this,Nt);X(this,Re,!1);X(this,Ct);X(this,Ze);X(this,Je);X(this,et);X(this,tt);X(this,st);X(this,nt);X(this,rt);X(this,At);const{client:t,queryFlavor:s,version:n,onlineManager:a,buttonPosition:i,position:o,initialIsOpen:l,errorTypes:c,styleNonce:h,shadowDOMTarget:f,onClose:m}=e;Y(this,Xe,le(t)),Y(this,jt,s),Y(this,Nt,n),Y(this,bt,a),Y(this,Ct,h),Y(this,Ze,f),Y(this,Je,le(i)),Y(this,et,le(o)),Y(this,tt,le(l)),Y(this,st,le(c)),Y(this,nt,le(m))}setButtonPosition(e){D(this,Je)[1](e)}setPosition(e){D(this,et)[1](e)}setInitialIsOpen(e){D(this,tt)[1](e)}setErrorTypes(e){D(this,st)[1](e)}setClient(e){D(this,Xe)[1](e)}setOnClose(e){D(this,nt)[1](()=>e)}mount(e){if(D(this,Re))throw new Error("Devtools is already mounted");const t=Zs(()=>{const s=this,[n]=D(this,Je),[a]=D(this,et),[i]=D(this,tt),[o]=D(this,st),[l]=D(this,Xe),[c]=D(this,nt);let h;return D(this,rt)?h=D(this,rt):(h=Ys(()=>Promise.resolve().then(()=>require("./HUY7CZI3-B1ZKq-An.cjs"))),Y(this,rt,h)),jn(D(this,Ct),D(this,Ze)),fs(h,ms({get queryFlavor(){return D(s,jt)},get version(){return D(s,Nt)},get onlineManager(){return D(s,bt)},get shadowDOMTarget(){return D(s,Ze)}},{get client(){return l()},get buttonPosition(){return n()},get position(){return a()},get initialIsOpen(){return i()},get errorTypes(){return o()},get onClose(){return c()}}))},e);Y(this,Re,!0),Y(this,At,t)}unmount(){var e;if(!D(this,Re))throw new Error("Devtools is not mounted");(e=D(this,At))==null||e.call(this),Y(this,Re,!1)}},Xe=new WeakMap,bt=new WeakMap,jt=new WeakMap,Nt=new WeakMap,Re=new WeakMap,Ct=new WeakMap,Ze=new WeakMap,Je=new WeakMap,et=new WeakMap,tt=new WeakMap,st=new WeakMap,nt=new WeakMap,rt=new WeakMap,At=new WeakMap,Us);function Da(e){const t=F.useQueryClient(e.client),s=he.useRef(null),{buttonPosition:n,position:a,initialIsOpen:i,errorTypes:o,styleNonce:l,shadowDOMTarget:c}=e,[h]=he.useState(new La({client:t,queryFlavor:"React Query",version:"5",onlineManager:F.onlineManager,buttonPosition:n,position:a,initialIsOpen:i,errorTypes:o,styleNonce:l,shadowDOMTarget:c}));return he.useEffect(()=>{h.setClient(t)},[t,h]),he.useEffect(()=>{n&&h.setButtonPosition(n)},[n,h]),he.useEffect(()=>{a&&h.setPosition(a)},[a,h]),he.useEffect(()=>{h.setInitialIsOpen(i||!1)},[i,h]),he.useEffect(()=>{h.setErrorTypes(o||[])},[o,h]),he.useEffect(()=>(s.current&&h.mount(s.current),()=>{h.unmount()}),[h]),r.jsx("div",{className:"tsqd-parent-container",ref:s})}function Ga(e){const t=F.useQueryClient(e.client),s=he.useRef(null),{errorTypes:n,styleNonce:a,shadowDOMTarget:i}=e,[o]=he.useState(new _a({client:t,queryFlavor:"React Query",version:"5",onlineManager:F.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:n,styleNonce:a,shadowDOMTarget:i,onClose:e.onClose}));return he.useEffect(()=>{o.setClient(t)},[t,o]),he.useEffect(()=>{o.setOnClose(e.onClose??(()=>{}))},[e.onClose,o]),he.useEffect(()=>{o.setErrorTypes(n||[])},[n,o]),he.useEffect(()=>(s.current&&o.mount(s.current),()=>{o.unmount()}),[o]),r.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:s})}var Ma=process.env.NODE_ENV!=="development"?function(){return null}:Da;process.env.NODE_ENV;const L={ASK_AI:"ASK_AI",GET_PAGE:"GET_PAGE",CREATE_PAGE:"CREATE_PAGE",UPDATE_PAGE:"UPDATE_PAGE",DELETE_PAGE:"DELETE_PAGE",CHANGE_SLUG:"CHANGE_SLUG",TAKE_OFFLINE:"TAKE_OFFLINE",PUBLISH_PAGE:"PUBLISH_PAGE",PUBLISH_CHANGES:"PUBLISH_CHANGES",ADD_NEW_LANGUAGE:"ADD_NEW_LANGUAGE",EDIT_LANGUAGE:"EDIT_LANGUAGE",DELETE_LANGUAGE:"DELETE_LANGUAGE",GET_CHANGES:"GET_CHANGES",GET_SERVER_BLOCK:"GET_SERVER_BLOCK",GET_LANGUAGE_PAGES:"GET_LANGUAGE_PAGES",GET_PROJECT_PAGES:"GET_PROJECT_PAGES",GET_WEBSITE_PAGES:"GET_WEBSITE_PAGES",UPDATE_WEBSITE_SETTINGS:"UPDATE_WEBSITE_SETTINGS",GET_COLLECTIONS:"GET_COLLECTIONS",GET_PAGE_TYPES:"GET_PAGE_TYPES",SEARCH_PAGES:"SEARCH_PAGES",GET_WEBSITE_SETTINGS:"GET_WEBSITE_SETTINGS",AI_CONTEXT:"AI_CONTEXT",GET_WEBSITE_DATA:"GET_WEBSITE_DATA",UPDATE_WEBSITE_DATA:"UPDATE_WEBSITE_DATA",GET_CHAI_USER:"GET_CHAI_USER",RELEASE_LOCK:"RELEASE_LOCK",GET_SEO_FIELDS:"GET_SEO_FIELDS",GET_BUILDER_PAGE_DATA:"GET_BUILDER_PAGE_DATA"},gs=()=>{const e=F.useQueryClient(),{data:t}=F.useQuery({queryKey:[L.AI_CONTEXT],initialData:"",queryFn:()=>""});return{setAiContext:v.useCallback(n=>{e.setQueryData([L.AI_CONTEXT],n)},[]),aiContext:t}},Ua=Ht.atom({}),Nn=()=>Ht.useAtom(Ua),_e=(e,t)=>{const[s]=Nn();return g.get(s,e,t)},ce=()=>_e("apiUrl","/chai/api"),Ba=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)}),ue=()=>{const e=_e("user"),t=_e("onSessionExpired"),s=v.useMemo(()=>e==null?void 0:e.authToken,[e==null?void 0:e.authToken]);return v.useCallback(async(n,a,i={})=>{if(s)try{const o=g.get(a,"action","").toLowerCase(),l=await Ba(n+(o?`?action=${o}`:""),a,{...i,Authorization:`Bearer ${s}`});if(l.status===401)throw console.log("session expired",a,l),t(),new Error("Session expired");if(l.status===400)throw console.log("Something went wrong",a,l),new Error((await l.json()).error);return await l.json()}catch(o){throw console.log("Something went wrong",a,o),o}},[s,t])},Oa=()=>{const e=ce(),{aiContext:t}=gs(),s=ue();return v.useCallback(async(n,a,i,o)=>s(e,{action:L.ASK_AI,data:{type:n,prompt:a,blocks:i,context:t,lang:o}}),[e,t,s])};function we(){const[e,t]=v.useState(new URLSearchParams(window.location.search));return v.useEffect(()=>{const s=()=>{t(new URLSearchParams(window.location.search))};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[]),[e,t]}const Kt=()=>{const e=ue(),t=ce();return F.useQuery({queryKey:[L.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:L.GET_WEBSITE_PAGES})||[]})},Pe=()=>{const[e]=we(),t=e.get("page"),{data:s,isFetching:n}=Kt();return{data:v.useMemo(()=>g.find(s,{id:t})||{},[s,t]),isFetching:n}},Ra=(e,t)=>t.map(s=>{if(g.has(e,s._type)){const n=Bs.getDefaultBlockProps(s._type);return{...n,...g.pick(s,[...g.keys(n),"_type","_id","_name","_parent","_bindings"]),...g.pickBy(s,(a,i)=>g.endsWith(i,"_attrs")),...s}}return s}),Fa=e=>{const t=Bs.useRegisteredChaiBlocks();return v.useMemo(()=>{if(!e||g.isEmpty(e))return{blocks:[]};const s=g.filter(e,n=>!g.includes(n==null?void 0:n._type,"@chai/"));return{blocks:Ra(t,s)}},[e,t])},Cn=e=>{const t=ce(),s=ue();return F.useQuery({queryKey:["chaiUserInfo",e],queryFn:async()=>await s(t,{action:L.GET_CHAI_USER,data:{userId:e}}),enabled:!!e&&e!=="EXPIRED"})},qa=Ht.atom(void 0),Tt=()=>{const[e]=we(),t=e.get("page"),s=_e("user"),[n,a]=Ht.useAtom(qa);return v.useMemo(()=>({isLocked:t&&(s==null?void 0:s.id)!==n,currentEditor:n,setCurrentEditor:i=>a(i)}),[n,t,a,s==null?void 0:s.id])},An=()=>{const[e]=we(),t=e.get("page"),s=ce(),{setAiContext:n}=gs(),{setCurrentEditor:a}=Tt(),i=ue();return F.useQuery({queryKey:[L.GET_PAGE,t],initialData:[],queryFn:async()=>{a("");const o=await i(s,{action:L.GET_PAGE,data:{id:t,draft:!0}});a(o.currentEditor);const l=o.blocks??[],c=g.find(l,{_type:"@chai/ai-context"});return n(g.get(c,"_value","")||""),l},enabled:!!t})},Tn=({pageType:e,lang:t})=>{const s=ce(),n=ue();return F.useQuery({queryKey:[L.GET_BUILDER_PAGE_DATA,e,t],initialData:{},queryFn:async()=>n(s,{action:L.GET_BUILDER_PAGE_DATA,data:{pageType:e,lang:t}}),enabled:!!e&&!!t})},Pn=()=>{const e=ce(),t=F.useQueryClient(),s=ue();return F.useMutation({mutationFn:async n=>s(e,{action:L.RELEASE_LOCK,data:n}),onSuccess:(n,a)=>{t.invalidateQueries({queryKey:[L.GET_PAGE,a.id??""]})}})},kn=()=>{const e=ce(),t=F.useQueryClient(),s=ue();return F.useMutation({mutationFn:async n=>s(e,{action:L.UPDATE_WEBSITE_SETTINGS,data:n}),onSuccess:(n,a)=>{var i;t.invalidateQueries({queryKey:[L.GET_WEBSITE_SETTINGS]}),(i=a==null?void 0:a.settings)!=null&&i.theme||ae.toast.success("Website settings updated successfully.")},onError:n=>{ae.toast.error("Failed to update website settings",{description:n.message})}})},Ha=()=>{const e=ce(),t=F.useQueryClient(),s=ue();return F.useMutation({mutationFn:async n=>s(e,{action:L.UPDATE_WEBSITE_DATA,data:n}),onSuccess:()=>{t.invalidateQueries({queryKey:[L.GET_WEBSITE_DATA]}),ae.toast.success("Website data updated successfully.")},onError:n=>{ae.toast.error("Failed to update website data",{description:n.message})}})},Se=()=>{const e=ce(),t=ue();return F.useQuery({queryKey:[L.GET_PAGE_TYPES],initialData:[],queryFn:async()=>t(e,{action:L.GET_PAGE_TYPES})})},$a=()=>{const e=ce(),t=ue();return F.useMutation({mutationFn:async({pageType:s,query:n})=>{try{return t(e,{action:L.SEARCH_PAGES,data:{pageType:s,query:Array.isArray(n)&&n.length>0?n[0]:n}})||[]}catch(a){return console.error(a),[]}}})},Va=()=>F.useQuery({queryKey:["uiLibraries"],initialData:[],queryFn:async()=>[{uuid:"chaiblocks",name:"UI Blocks",url:"https://chaibuilder.com/chaiblocks"}]}),zt=()=>{const e=ce(),t=ue();return F.useQuery({queryKey:[L.GET_WEBSITE_SETTINGS],initialData:{theme:{},fallbackLang:"en",languages:[]},queryFn:async()=>t(e,{action:L.GET_WEBSITE_SETTINGS,data:{draft:!0}})})},Wa=()=>{const e=ce(),t=ue(),{setCurrentEditor:s}=Tt();return{getUILibraryBlock:async(o,l)=>{const f=(await(await fetch(o.url+(l.path?"/blocks/"+l.path:"/"+l.uuid+".html"))).text()).replace(/---([\s\S]*?)---/g,"");return ve.getBlocksFromHTML(`${f}`)},getUILibraryBlocks:async o=>{try{return(await(await fetch(o.url+"/blocks.json")).json()).map(h=>({...h,preview:o.url.replace("chaiblocks","")+h.preview}))}catch(l){return console.error(l),[]}},onSave:async({page:o,blocks:l})=>{try{const c=await t(e,{action:"UPDATE_PAGE",data:{id:o,blocks:l}});return c.code==="PAGE_LOCKED"?(s(c.editor===null?"EXPIRED":c.editor),!0):c}catch(c){return console.error(c),new Error("Failed to save blocks")}}}},Ka=()=>{const{data:e}=Kt(),t=ce(),s=ue();return{getPartialBlocks:v.useCallback(async()=>{const n={};for(const a of e??[])g.isEmpty(a==null?void 0:a.slug)&&(n[a.id]={type:a.pageType,name:g.startCase(a.name??a.slug),description:""});return n},[e]),getPartialBlockBlocks:v.useCallback(async n=>{if(!n)return[];const a=await s(t,{action:"GET_PAGE",data:{id:n,draft:!0,editor:!1}});return g.filter(a.blocks,i=>g.has(i,"_id"))},[s,t])}},U={PREVIEW:"Preview",THEME:"Theme",SAVEDRAFT:"Save draft",SAVING:"Saving",SAVED:"Saved",PUBLISHED:"Published",PUBLISH:"Publish",UNPUBLISH:"Unpublish",WEBSITEDATA:"Website data",OPEN:"Open",EDIT_LANGUAGE:"Edit language",ADD_NEW_LANGUAGE:"Add New language",ENTER_LANGUAGE_DETAILS:"Enter the details for the language",LANGUAGE:"Language",PAGE_NAME:"Page Name",SLUG:"Slug",UPDATE:"Update",UPDATING:"Updating...",ADDING:"Adding...",CHOOSE_LANGUAGE:"Choose language",ALL_AVAILABLE_LANGUAGE_PAGE:"All available language page is created.",TO_UPDATE_SLUG:"To update slug use 'Change slug' action",SLUG_SHOULD_START_WITH:" (Slug should start with /{lang})",CHOOSE_LANGUAGE_TO_ADD_SLUG:"Choose language to add slug",ENTER_PAGE_SLUG:"Enter page slug",ENTER_PAGE_NAME:"Enter page name",DELETE:"Delete",CHANGE_SLUG:"Change slug",PRIMARY:"Primary",SLUG_MUST_START_WITH:"Slug must start with /",EDIT:"Edit",UNPUBLISH_MSG:"Are you sure you want to unpublish",PAGE_ADD_SUCCESS:"New page added successfully.",GLOBAL_BLOCK_ADD_SUCCESS:"New global block added successfully.",SEO_SETTINGS_UPDATE_SUCCESS:"SEO Settings updated successfully.",PAGE_UPDATE_SUCCESS:"Page updated successfully.",GLOBAL_BLOCK_UPDATE_SUCCESS:"Global block updated successfully.",PAGE_DELETE_SUCCESS:"Page deleted successfully.",GLOBAL_BLOCK_DELETE_SUCCESS:"Global block deleted successfully.",PAGE_UNPUBLISH_SUCCESS:"Page unpublished successfully.",GLOBAL_BLOCK_UNPUBLISH_SUCCESS:"Global block unpublished successfully.",PAGE_PUBLISH_SUCCESS:"Page published successfully.",GLOBAL_BLOCK_PUBLISH_SUCCESS:"Global block published successfully.",PAGES_PUBLISH_SUCCESS:"Your changes have been published successfully.",SLUG_CHANGE_SUCCESS:"Slug changed successfully."},Ne={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"},za={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},In=()=>{const e=ce(),t=F.useQueryClient(),s=ue(),{data:n}=Se();return F.useMutation({mutationFn:async a=>s(e,{action:L.CREATE_PAGE,data:a}),onSuccess:(a,i)=>{i&&(i!=null&&i.primaryPage)?t.invalidateQueries({queryKey:[L.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}):t.invalidateQueries({queryKey:[L.GET_WEBSITE_PAGES]})},onError:(a,i)=>{const o=g.find(n,{key:i.pageType});ae.toast.error(`Failed to add new ${o!=null&&o.hasSlug?"page":o.name}.`,{description:g.get(za,a.message,a.message)})}})},ys=()=>{const e=ce(),t=F.useQueryClient(),s=ue(),{data:n}=Se();return F.useMutation({mutationFn:async a=>await s(e,{action:L.UPDATE_PAGE,data:a}),onSuccess:(a,i)=>{i&&(i!=null&&i.primaryPage||i!=null&&i.seo)?t.invalidateQueries({queryKey:[L.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}):t.invalidateQueries({queryKey:[L.GET_WEBSITE_PAGES]})},onError:(a,i)=>{const o=g.find(n,{key:i.pageType});ae.toast.error(`Failed to update ${o!=null&&o.hasSlug?"page":o.name}.`,{description:a.message})}})},Qa=()=>{const e=ce(),t=F.useQueryClient(),s=ue(),{data:n}=Se();return F.useMutation({mutationFn:async a=>s(e,{action:L.DELETE_PAGE,data:{id:a==null?void 0:a.id}}),onSuccess:(a,i)=>{if(a.code==="PAGE_LOCKED"){ae.toast.error("Delete not allowed",{description:"Page is currently being edited by another user."});return}i&&(i!=null&&i.primaryPage)?t.invalidateQueries({queryKey:[L.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}):t.invalidateQueries({queryKey:[L.GET_WEBSITE_PAGES]})},onError:(a,i)=>{const o=g.find(n,{key:i.pageType});ae.toast.error(`Failed to delete ${o!=null&&o.hasSlug?"page":o.name}.`,{description:a.message})}})},Ya=()=>{const e=ce(),t=F.useQueryClient(),s=ue(),{data:n}=Se();return F.useMutation({mutationFn:async a=>s(e,{action:L.TAKE_OFFLINE,data:{id:a==null?void 0:a.id}}),onSuccess:(a,i)=>{i&&(i!=null&&i.primaryPage)?t.invalidateQueries({queryKey:[L.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}):t.invalidateQueries({queryKey:[L.GET_WEBSITE_PAGES]});const o=g.find(n,{key:i.pageType});ae.toast.success(o!=null&&o.hasSlug?U.PAGE_UNPUBLISH_SUCCESS:"New "+o.name+" added successfully.")},onError:(a,i)=>{const o=g.find(n,{key:i.pageType});ae.toast.error(`Failed to take offline ${o!=null&&o.hasSlug?"page":o.name}.`,{description:a.message})}})},xs=()=>{const e=ce(),t=ue(),s=F.useQueryClient(),{data:n}=Pe();return F.useMutation({mutationFn:async({ids:a})=>t(e,{action:L.PUBLISH_CHANGES,data:{ids:a}}),onSuccess:()=>{s.invalidateQueries({queryKey:[L.GET_CHANGES]}),s.invalidateQueries({queryKey:[L.GET_WEBSITE_PAGES]}),s.invalidateQueries({queryKey:[L.GET_LANGUAGE_PAGES,n==null?void 0:n.id]})},onError:()=>{ae.toast.error("Failed to publish pages.")}})},Xa=()=>{const e=ce(),t=ue(),s=F.useQueryClient();return F.useMutation({mutationFn:async({id:n,slug:a})=>t(e,{action:L.CHANGE_SLUG,data:{id:n,slug:a}}),onSuccess:(n,{primaryPage:a})=>{ae.toast.success(U.SLUG_CHANGE_SUCCESS),a?s.invalidateQueries({queryKey:[L.GET_LANGUAGE_PAGES,a]}):s.invalidateQueries({queryKey:[L.GET_WEBSITE_PAGES]})},onError:()=>{ae.toast.error("Failed to change slug")}})},Pt=()=>{const e=ce(),[t]=we(),s=t.get("page"),n=ue();return F.useQuery({queryKey:[L.GET_LANGUAGE_PAGES,s],initialData:[],queryFn:async()=>{if(!s)return null;const a=await n(e,{action:L.GET_LANGUAGE_PAGES,data:{id:s}});return g.reverse(g.sortBy(a,"primaryPage"))},enabled:!!s})},Za=({page:e,onClose:t})=>{const[s,n]=v.useState(e.slug||""),{mutate:a,isPending:i}=Xa(),{data:o}=Se(),l=g.find(o,{key:e==null?void 0:e.pageType}),c=f=>{if(f.preventDefault(),!(e!=null&&e.primaryPage)&&Object.keys(Ne).some(x=>s===`/${x}`||g.startsWith(s,`/${x}/`))){ae.toast.error("Error",{description:"Slugs cannot start with a language code for primary page"});return}a({...e,slug:s},{onSuccess:t})},h=(e==null?void 0:e.lang)||"";return r.jsx(u.Dialog,{open:!!e,onOpenChange:t,children:r.jsxs(u.DialogContent,{children:[r.jsxs(u.DialogHeader,{children:[r.jsx(u.DialogTitle,{children:"Change Slug"}),r.jsx(u.DialogDescription,{className:"text-xs",children:r.jsxs(u.Alert,{variant:"destructive",className:"mt-2",children:[r.jsx(I.AlertCircle,{className:"h-4 w-4"}),"Changing the slug may have impact on your SEO. Please proceed with caution."]})})]}),r.jsxs("form",{onSubmit:c,children:[r.jsxs("div",{className:"space-y-4 py-4 text-sm ",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{children:[r.jsx("span",{children:"Type:"}),r.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(l==null?void 0:l.name)||(e==null?void 0:e.pageType)]})]}),r.jsxs("div",{children:[r.jsx("span",{children:"Name:"}),r.jsxs("span",{className:"font-medium text-gray-600",children:[" ",e.name]})]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs(u.Label,{htmlFor:"slug",className:"text-right",children:["Slug"," ",r.jsxs("small",{className:"font-light text-gray-500",children:["Slug should start with /",h]})]}),r.jsx(u.Input,{id:"slug",value:s,onChange:f=>{const m=f.target.value;g.startsWith(m,`/${h}`)&&n(m)},className:"col-span-3",required:!0,pattern:"^/.*",title:"Slug must start with /",placeholder:"Enter page slug"})]})]}),r.jsx(u.DialogFooter,{children:r.jsx(u.Button,{type:"submit",disabled:i||!g.startsWith(s,`/${h}`)||g.isEqual(e==null?void 0:e.slug,s),children:i?"Changing...":"Change Slug"})})]})]})})};function Ln({page:e,onClose:t}){const[,s]=we(),{mutate:n,isPending:a}=Qa(),{data:i}=Se(),o=()=>{n(e,{onSuccess:()=>{e!=null&&e.primaryPage||(window.history.replaceState(null,"","/"),s(new URLSearchParams({})),window.dispatchEvent(new PopStateEvent("popstate"))),t()}})},l=i==null?void 0:i.find(c=>c.key===(e==null?void 0:e.pageType));return r.jsx(u.Dialog,{open:!!e,onOpenChange:t,children:r.jsxs(u.DialogContent,{children:[r.jsxs(u.DialogHeader,{children:[r.jsx(u.DialogTitle,{children:"Confirm Deletion"}),r.jsxs(u.DialogDescription,{className:"py-4 text-slate-500",children:[r.jsxs("div",{children:["Are you sure you want to remove ",r.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)})," ",l!=null&&l.hasSlug?(l==null?void 0:l.name)+"?":`page? ${e!=null&&e.primaryPage?"":"This will also delete all associated language pages."}`]}),e.lang&&r.jsxs("div",{className:"py-2 text-sm",children:["Language:"," ",r.jsx("span",{className:"font-medium text-gray-500",children:g.get(Ne,e.lang,e.lang)})]})]})]}),r.jsxs(u.DialogFooter,{children:[r.jsx(u.Button,{variant:"outline",onClick:t,children:"Cancel"}),r.jsx(u.Button,{variant:"destructive",disabled:a,onClick:o,children:a?"Deleting...":"Delete"})]})]})})}const ps=({page:e,onClose:t})=>{const{mutate:s,isPending:n}=Ya(),a=async()=>{s(e,{onSuccess:t})};return r.jsx(u.Dialog,{open:!!e,onOpenChange:t,children:r.jsxs(u.DialogContent,{children:[r.jsxs(u.DialogHeader,{children:[r.jsx(u.DialogTitle,{children:"Confirm action"}),r.jsxs(u.DialogDescription,{children:[U.UNPUBLISH_MSG," ",r.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)}),"?"]})]}),r.jsxs(u.DialogFooter,{children:[r.jsx(u.Button,{variant:"outline",onClick:t,children:"Cancel"}),r.jsx(u.Button,{variant:"destructive",disabled:n,onClick:a,children:n?U.UPDATING:U.UNPUBLISH})]})]})})},_n=({langProps:e,onClose:t,languages:s})=>{const{data:n}=Pe(),{data:a}=Se(),[i,o]=v.useState(e.name||""),[l,c]=v.useState(e.edit?e.lang:""),[h,f]=v.useState(e.edit?e.slug:""),{mutate:m,isPending:C}=In(),{mutate:x,isPending:S}=ys(),w=v.useMemo(()=>a==null?void 0:a.find(N=>N.key===e.pageType),[a,e.pageType]),j=!(w!=null&&w.hasSlug),P=C||S,V=N=>{N.preventDefault();const p={name:i,lang:l,primaryPage:n==null?void 0:n.id,slug:h,pageType:n==null?void 0:n.pageType};p.pageType=e.pageType,e.edit&&(p.id=e==null?void 0:e.id),e.edit?x(p,{onSuccess:t}):m(p,{onSuccess:t})};return r.jsx(u.Dialog,{open:!!e,onOpenChange:t,children:r.jsxs(u.DialogContent,{className:"sm:max-w-[425px] text-slate-600",children:[r.jsxs(u.DialogHeader,{children:[r.jsx(u.DialogTitle,{children:e.edit?U.EDIT_LANGUAGE:U.ADD_NEW_LANGUAGE}),r.jsx(u.DialogDescription,{className:"font-light",children:U.ENTER_LANGUAGE_DETAILS})]}),r.jsxs("form",{onSubmit:V,children:[r.jsxs("div",{className:"grid gap-4 py-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(u.Label,{htmlFor:"lang",className:"text-right",children:U.LANGUAGE}),r.jsxs("select",{value:l,disabled:e.edit||g.isEmpty(s),onChange:N=>{const p=N.target.value;c(p),!j&&f(`/${p}`)},className:"flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 col-span-3",children:[r.jsx("option",{value:"",disabled:!0,selected:!0,children:e.edit?g.get(Ne,e.lang,e.lang):g.isEmpty(s)?U.ALL_AVAILABLE_LANGUAGE_PAGE:U.CHOOSE_LANGUAGE}),g.map(s,N=>r.jsx("option",{value:N,children:g.get(Ne,N,N)},N))]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(u.Label,{htmlFor:"slug",className:"text-right",children:U.PAGE_NAME}),r.jsx(u.Input,{id:"name",value:i,onChange:N=>o(N.target.value),className:"col-span-3",required:!0,placeholder:U.ENTER_PAGE_NAME})]}),!j&&r.jsxs("div",{className:"space-y-1",children:[r.jsxs(u.Label,{htmlFor:"slug",className:"text-right",children:[U.SLUG," ",r.jsx("small",{className:"font-light",children:U.SLUG_SHOULD_START_WITH})]}),r.jsx(u.Input,{id:"slug",value:h,onChange:N=>{const p=N.target.value;g.startsWith(p,`/${l}`)&&f(g.toLower(g.trim(p)))},className:"col-span-3",required:!0,pattern:"^/.*",disabled:g.isEmpty(l),title:U.SLUG_MUST_START_WITH,placeholder:g.isEmpty(l)?U.CHOOSE_LANGUAGE_TO_ADD_SLUG:U.ENTER_PAGE_SLUG})]})]}),r.jsx(u.DialogFooter,{children:r.jsx(u.Button,{type:"submit",disabled:P||!i||!l||!j&&!g.startsWith(h,`/${l}`),children:P?e.edit?U.UPDATING:U.ADDING:e.edit?U.UPDATE:U.ADD_NEW_LANGUAGE})})]})]})})},Ja=()=>{const[e,t]=v.useState(null),{selectedLang:s,fallbackLang:n,setSelectedLang:a}=ve.useLanguages(),{data:i,isFetching:o}=Pt(),{data:l}=Pe(),[c,h]=v.useState(null),[f,m]=v.useState(null),[C,x]=v.useState(null),{data:S}=zt(),w=g.filter(g.get(S,"languages")||["en"],j=>!g.find(i,{lang:j})&&j!==g.get(S,"fallbackLang"));return r.jsxs("div",{className:"space-y-4 pt-2",children:[r.jsx("ul",{className:"space-y-2 mt-4",children:o?r.jsxs("div",{className:"w-full space-y-3 py-4",children:[r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"})]}):g.map(i,j=>{const P=j.lang,V=j.slug,N=!j.primaryPage,p=P===s;return r.jsxs(r.Fragment,{children:[r.jsxs("li",{className:`text-slate-500 w-full p-2 rounded cursor-pointer flex items-center justify-between ${p?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>a(P),children:[r.jsxs("div",{className:" flex-1 gap-x-3",children:[r.jsxs("div",{className:"text-[13px] text-slate-800 flex items-center gap-x-2",children:[r.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${j.online?"bg-green-300":"bg-gray-300"}`}),g.get(Ne,N?n:P,P)]}),r.jsxs("div",{children:[V&&r.jsxs("div",{className:"text-[11px] text-slate-600 font-light",children:["Slug: ",r.jsx("b",{className:"font-medium",children:V})]}),r.jsxs("div",{className:"text-[11px] text-slate-600 font-light",children:["Name:",r.jsxs("b",{className:"font-medium",children:[" ",j.name," "]})]})]})]}),N?r.jsxs("div",{className:"flex items-center text-[11px] text-orange-500 gap-x-1",children:[r.jsx(I.StarIcon,{fill:"orange",className:"w-3 h-3"}),r.jsx("b",{children:" Primary"})]}):r.jsx("div",{className:"flex items-center gap-x-3",children:r.jsxs(u.DropdownMenu,{children:[r.jsx(u.DropdownMenuTrigger,{asChild:!0,onClick:E=>E.stopPropagation(),children:r.jsx(u.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:r.jsx(I.MoreHorizontal,{className:"h-4 w-4"})})}),r.jsxs(u.DropdownMenuContent,{align:"end",className:"text-sm",children:[r.jsxs(u.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:E=>{E.stopPropagation(),t({...j,edit:!0})},children:[r.jsx(I.PencilIcon,{className:"size-3"}),U.EDIT]}),(j==null?void 0:j.online)&&r.jsxs(u.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:E=>{E.stopPropagation(),m(j)},children:[r.jsx(I.Power,{className:"size-3"}),U.UNPUBLISH]}),r.jsxs(u.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:E=>{E.stopPropagation(),h(j)},children:[r.jsx(I.TrashIcon,{className:"size-3"}),U.DELETE]})]})]})})]},j.id),r.jsx("div",{className:"h-1 w-full border-b"})]})})}),r.jsx("div",{className:"flex justify-center w-full",children:r.jsx(u.Button,{variant:"default",size:"sm",disabled:g.isEmpty(w),onClick:()=>{t({name:l==null?void 0:l.name,pageType:l==null?void 0:l.pageType,lang:"",slug:"",edit:!1})},children:U.ADD_NEW_LANGUAGE})}),e&&r.jsx(_n,{languages:w,langProps:e,onClose:()=>t(null)}),c&&r.jsx(Ln,{page:c,onClose:()=>h(null)}),f&&r.jsx(ps,{page:f,onClose:()=>m(null)}),C&&r.jsx(Za,{page:C,onClose:()=>x(null)})]})},Dn=e=>{const{fallbackLang:t}=ve.useLanguages(),{data:s}=zt(),{data:n,isFetching:a}=Pt(),i=v.useMemo(()=>{const o={[t]:!0};return g.each(g.get(s,"languages"),l=>{const c=g.find(n,{lang:l});o[l]=!!c}),o},[t,n,s]);return a||g.isEmpty(e)||e&&i[e]};function ei({avatar:e,name:t,email:s,onTakeOver:n,currentEditor:a}){const[i,o]=v.useState(!1),l=()=>{o(!1),n()};return r.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-[20] flex items-center justify-center w-screen top-14 bg-black/30 backdrop-blur-sm",children:r.jsxs(u.Card,{className:"w-full max-w-md mx-auto",children:[r.jsx(u.CardHeader,{className:"space-y-1",children:r.jsxs(u.CardTitle,{className:"flex items-center gap-2 text-2xl",children:[r.jsx(I.LockIcon,{className:"w-6 h-6 text-yellow-500"}),a==="EXPIRED"?"Editing access timed out":"Page locked for editing"]})}),r.jsx(u.CardContent,{className:"grid gap-4",children:a==="EXPIRED"?r.jsx("div",{children:r.jsx("p",{children:"Your editing access has been paused due to inactivity. Please refresh the page to continue"})}):r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center space-x-4",children:[e?r.jsx("img",{src:e,alt:t,className:"w-12 h-12 border border-gray-300 rounded-full"}):r.jsx(I.UserIcon,{className:"w-12 h-12 p-2 border border-gray-300 rounded-full"}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("h3",{className:"font-semibold",children:t}),s&&r.jsx("p",{className:"text-sm text-muted-foreground",children:s})]})]}),r.jsx("div",{className:"text-sm",children:r.jsx("p",{children:"This user is currently editing the page. You cannot make changes."})})]})}),r.jsx(u.CardFooter,{children:a==="EXPIRED"?r.jsx("div",{children:r.jsx(u.Button,{className:"w-full",onClick:()=>window.location.reload(),variant:"destructive",children:"Refresh"})}):r.jsxs(u.AlertDialog,{open:i,onOpenChange:o,children:[r.jsx(u.AlertDialogTrigger,{asChild:!0,children:r.jsxs("span",{className:"flex flex-col items-center",children:[r.jsx(u.Button,{className:"w-full",variant:"destructive",children:"Take Over"}),r.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"If you need to edit, you can take over the lock, but be aware that the other user might lose unsaved changes."})]})}),r.jsxs(u.AlertDialogContent,{className:"z-[99]",children:[r.jsxs(u.AlertDialogHeader,{children:[r.jsx(u.AlertDialogTitle,{children:"Are you sure you want to take over?"}),r.jsxs(u.AlertDialogDescription,{children:[r.jsxs("p",{className:"flex items-center space-x-2 text-yellow-500",children:[r.jsx(I.AlertTriangleIcon,{className:"w-5 h-5"}),r.jsx("span",{children:"This action might cause the other user to lose unsaved changes."})]}),r.jsxs("p",{className:"mt-2",children:["By taking over, you will become the active editor of this page, and ",t," will lose their editing access."]})]})]}),r.jsxs(u.AlertDialogFooter,{children:[r.jsx(u.AlertDialogCancel,{children:"Cancel"}),r.jsx(u.AlertDialogAction,{onClick:l,children:"Yes, Take Over"})]})]})]})})]})})}const ti=()=>{const{isLocked:e,currentEditor:t}=Tt(),{data:s}=Cn(t),n=_e("pageLockComponent",ei),[a]=we(),i=a.get("page"),{mutate:o}=Pn(),{isFetching:l}=An(),c=v.useCallback(()=>{o({id:i})},[i,o]);return!e||l?r.jsx("div",{className:""}):r.jsx(n,{...s,isLocked:e,currentEditor:t,onTakeOver:c})},si=()=>{const[e,t]=we(),s=e.get("lang"),n=Dn(s),{setSelectedLang:a}=ve.useLanguages(),i=()=>{const l=new URLSearchParams(window.location.search);l.delete("lang");const c=l.toString(),h=`${window.location.pathname}${c?`?${c}`:""}`;window.history.pushState({},"",h),t(l),a(""),window.dispatchEvent(new PopStateEvent("popstate"))};if(n)return null;const o=g.get(Ne,s);return r.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-[20] flex items-center justify-center w-screen top-14 bg-black/30 backdrop-blur-sm",children:r.jsxs(u.Card,{className:"w-full max-w-md mx-auto",children:[r.jsx(u.CardHeader,{className:"space-y-1",children:r.jsxs(u.CardTitle,{className:"flex items-center gap-2 text-2xl",children:[r.jsx(I.LockIcon,{className:"w-6 h-6 text-yellow-500"}),'Page missing for "',o,'" language.']})}),r.jsx(u.CardContent,{className:"grid gap-4",children:r.jsxs("div",{children:['Page is not available in the "',o,'" language. Either create the page in the "',o,'" language or switch to the base language.']})}),r.jsx(u.CardFooter,{children:r.jsx(u.Button,{onClick:i,className:"w-full",variant:"destructive",children:"Switch to default language"})})]})})},ni=()=>{const{selectedLang:e}=ve.useLanguages(),{data:t,isFetching:s}=Pt();return{data:v.useMemo(()=>g.find(t,{lang:e||""})||{},[t,e]),isFetching:s}};function Ie({data:e,onSelect:t,dataType:s="value"}){const[n,a]=he.useState(!1),[i,o]=he.useState([]),[l,c]=he.useState(e);he.useEffect(()=>{n||o([]),c(e)},[e,n]);const h=x=>Array.isArray(x)?"array":typeof x=="object"&&x!==null?"object":"value",f=he.useCallback(x=>{const S=w=>s==="value"?w==="value"||w==="object":s==="array"?w==="array":w===s;x.type==="object"?(o(w=>[...w,x.key]),c(x.value)):S(x.type)&&(t([...i,x.key].join(".")),a(!1))},[i,t,s]),m=he.useCallback(()=>{if(i.length>0){const x=i.slice(0,-1);o(x),c(x.reduce((S,w)=>S[w],e))}},[i,e]),C=he.useMemo(()=>Object.entries(l).map(([x,S])=>({key:x,value:S,type:h(S)})).filter(x=>s==="value"?x.type==="value"||x.type==="object":s==="array"?x.type==="array"||x.type==="object":s==="object"?x.type==="object":!0),[l,s]);return r.jsxs(u.Popover,{open:n,onOpenChange:a,children:[r.jsxs(u.Tooltip,{children:[r.jsx(u.TooltipTrigger,{asChild:!0,children:r.jsx(u.PopoverTrigger,{asChild:!0,children:r.jsx(u.Button,{size:"sm",variant:"outline",className:"h-6 w-6 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":n,children:r.jsx(I.DatabaseIcon,{className:"h-3 w-3"})})})}),r.jsx(u.TooltipContent,{children:"Add field"})]}),r.jsx(u.PopoverContent,{className:"w-[200px] p-0",children:r.jsxs(u.Command,{children:[r.jsx(u.CommandInput,{className:"border-none",placeholder:"Search..."}),r.jsxs(u.CommandList,{children:[r.jsx(u.CommandEmpty,{children:"No option found."}),r.jsxs(u.CommandGroup,{children:[i.length>0&&r.jsxs(u.CommandItem,{onSelect:m,className:"flex items-center text-sm",children:[r.jsx(I.ChevronLeft,{className:"w-4 h-4 mr-2"}),"Back"]}),C.map(x=>r.jsxs(u.CommandItem,{onSelect:()=>f(x),className:"flex items-center justify-between",children:[r.jsx("span",{children:x.key}),r.jsxs("div",{className:"flex items-center gap-2",children:[s==="object"&&x.type==="object"&&r.jsx(u.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:S=>{S.stopPropagation(),t([...i,x.key].join(".")),a(!1)},children:"Select"}),(x.type==="object"||x.type==="array")&&r.jsx("div",{className:"p-1 rounded hover:bg-muted cursor-pointer",children:r.jsx(I.ChevronRight,{className:"w-4 h-4 opacity-50"})})]})]},x.key))]})]})]})})]})}const ri=(e,t)=>{const s=e.selectionStart||0,n=e.selectionEnd||0,a=e.value,i=a.substring(0,s),o=a.substring(n);let l=!1;if(s>0&&i.length>0){const S=i.charAt(i.length-1);l=!/[\s.,!?;:()[\]{}]/.test(S)&&S!==""}let c=!1;if(o.length>0){const S=o.charAt(0);c=!/[\s.,!?;:()[\]{}]/.test(S)&&S!==""}const h=l?" ":"",f=c?" ":"",m=`{{${t}}}`,C=i+(l?h:"")+m+(c?f:"")+o,x=s+(l?1:0)+m.length;return{value:C,newCursorPos:x}},Gn=()=>{const{selectedLang:e,fallbackLang:t,languages:s}=ve.useLanguages(),{data:n}=Pe(),{data:a}=Tn({lang:e||t,pageType:n==null?void 0:n.pageType}),{data:i,isFetching:o}=ni(),l=i==null?void 0:i.seo,c=v.useRef(null),[h,f]=v.useState({title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",searchTitle:"",searchDescription:"",jsonLD:"",...l}),m=v.useRef({initial:h,updated:h}),C=e.length?e:t,{mutate:x,isPending:S}=ys(),w=S;v.useEffect(()=>{!o&&l&&f({title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",searchTitle:"",searchDescription:"",jsonLD:"",...l})},[o,l]);const j=async()=>{x({id:i==null?void 0:i.id,seo:h}),m.current.initial=h,m.current.updated=h},P=()=>{f({...h,ogTitle:h.title,ogDescription:h.description})},V=()=>{f({...h,searchTitle:h.ogTitle,searchDescription:h.ogDescription})},N=(E,ee)=>{const A=document.getElementById(ee);if(A){const{value:q,newCursorPos:M}=ri(A,E);c.current={id:ee,position:M},A.tagName.toLowerCase()==="input"?(A.value=q,f(re=>({...re,[A.name]:q})),A.focus(),A.setSelectionRange(M,M),[0,10,50,100,200].forEach(re=>{setTimeout(()=>{const R=document.getElementById(ee);R&&(R.focus(),R.setSelectionRange(M,M))},re)})):(f(K=>({...K,[A.name]:q})),requestAnimationFrame(()=>{const K=document.getElementById(ee);K&&(K.focus(),K.setSelectionRange(M,M),setTimeout(()=>{const re=document.getElementById(ee);re&&(re.focus(),re.setSelectionRange(M,M))},50))}))}},p=E=>{const ee={...h,[E.target.name]:E.target.name==="noIndex"||E.target.name==="noFollow"?E.target.checked:E.target.value};f(ee),m.current.updated=ee};return r.jsxs("div",{className:"relative pb-40",children:[r.jsxs("div",{className:"p-2 text-xs text-left bg-gray-100 rounded-md",children:["Slug: ",i==null?void 0:i.slug,"  ",s.length>0&&r.jsxs("span",{className:"font-semibold text-blue-500",children:["(",g.get(Ne,C,C),")"]})]}),r.jsx("form",{className:"space-y-8",children:r.jsxs(u.Accordion,{type:"multiple",defaultValue:["page"],children:[r.jsxs(u.AccordionItem,{value:"page",children:[r.jsx(u.AccordionTrigger,{className:"font-semibold text-slate-700",children:"SEO"}),r.jsx(u.AccordionContent,{className:"pt-2",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(u.Label,{className:"text-xs",htmlFor:"title",children:"SEO Title"}),r.jsx(Ie,{dataType:"value",data:a??{},onSelect:E=>N(E,"title")})]}),r.jsx(u.Input,{type:"text",id:"title",name:"title",value:h.title,onChange:p,disabled:w,placeholder:"Enter SEO title"})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(u.Label,{className:"text-xs",htmlFor:"description",children:"SEO Description"}),r.jsx(Ie,{data:a??{},onSelect:E=>N(E,"description")})]}),r.jsx(u.Textarea,{id:"description",name:"description",rows:5,value:h.description,onChange:p,disabled:w,placeholder:"Enter SEO description"})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(u.Label,{className:"text-xs",htmlFor:"title",children:"Canonical URL"}),r.jsx(Ie,{dataType:"value",data:a??{},onSelect:E=>N(E,"canonicalUrl")})]}),r.jsx(u.Input,{type:"text",id:"canonicalUrl",name:"canonicalUrl",value:h.canonicalUrl,onChange:p,disabled:w,placeholder:"Enter Canonical URL"})]}),r.jsxs("div",{className:"",children:[r.jsxs("div",{className:"flex items-center gap-x-2",children:[r.jsx(u.Input,{type:"checkbox",id:"noIndex",name:"noIndex",checked:h.noIndex,onChange:p,disabled:w,className:"w-4 h-4"}),r.jsx(u.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:"No Index"})]}),r.jsx("p",{className:"mt-0 text-[10px] font-light text-gray-400 leading-4",children:"Check this if you don't want search engines to index this page."})]}),r.jsxs("div",{className:"",children:[r.jsxs("div",{className:"flex items-center gap-x-2",children:[r.jsx(u.Input,{type:"checkbox",id:"noFollow",name:"noFollow",checked:h.noFollow,onChange:p,disabled:w,className:"w-4 h-4"}),r.jsx(u.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:"No Follow"})]}),r.jsx("p",{className:"text-[10px] font-light text-gray-400 leading-4",children:"Check this if you don't want search engines to follow links on this page."})]})]})})]}),r.jsxs(u.AccordionItem,{value:"og",children:[r.jsx(u.AccordionTrigger,{className:"font-bold text-slate-700",children:"Open Graph"}),r.jsx(u.AccordionContent,{children:r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsx(u.Button,{type:"button",variant:"outline",size:"sm",onClick:P,children:"Copy from SEO Settings"})}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(u.Label,{className:"text-xs",htmlFor:"ogTitle",children:"OG Title"}),r.jsx(Ie,{dataType:"value",data:a??{},onSelect:E=>N(E,"ogTitle")})]}),r.jsx(u.Input,{type:"text",id:"ogTitle",name:"ogTitle",value:h.ogTitle,onChange:p,disabled:w,placeholder:"Enter OG title"})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(u.Label,{className:"text-xs",htmlFor:"ogDescription",children:"OG Description"}),r.jsx(Ie,{dataType:"value",data:a??{},onSelect:E=>N(E,"ogDescription")})]}),r.jsx(u.Textarea,{id:"ogDescription",name:"ogDescription",rows:5,value:h.ogDescription,onChange:p,disabled:w,placeholder:"Enter OG description"})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(u.Label,{className:"text-xs",htmlFor:"ogImage",children:"OG Image URL"}),r.jsx(Ie,{dataType:"value",data:a??{},onSelect:E=>N(E,"ogImage")})]}),r.jsx(u.Input,{type:"text",id:"ogImage",name:"ogImage",value:h.ogImage,onChange:p,disabled:w,placeholder:"Enter OG image URL"})]})]})})]}),r.jsxs(u.AccordionItem,{value:"search",children:[r.jsx(u.AccordionTrigger,{className:"font-bold text-slate-700",children:"Search"}),r.jsx(u.AccordionContent,{children:r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsx(u.Button,{type:"button",variant:"outline",size:"sm",onClick:V,children:"Copy from OG Settings"})}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(u.Label,{className:"text-xs",htmlFor:"searchTitle",children:"Search Title"}),r.jsx(Ie,{dataType:"value",data:a??{},onSelect:E=>N(E,"searchTitle")})]}),r.jsx(u.Input,{type:"text",id:"searchTitle",name:"searchTitle",value:h.searchTitle,onChange:p,disabled:w,placeholder:"Enter search title"})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(u.Label,{className:"text-xs",htmlFor:"searchDescription",children:"Search Description"}),r.jsx(Ie,{dataType:"value",data:a??{},onSelect:E=>N(E,"searchDescription")})]}),r.jsx(u.Textarea,{id:"searchDescription",rows:5,name:"searchDescription",value:h.searchDescription,onChange:p,placeholder:"Enter search description"})]})]})})]}),r.jsxs(u.AccordionItem,{value:"jsonLD",children:[r.jsx(u.AccordionTrigger,{className:"font-bold text-slate-700",children:"JSON-LD"}),r.jsx(u.AccordionContent,{children:r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(u.Label,{className:"text-xs",htmlFor:"jsonLD",children:"JSON-LD"}),r.jsx(Ie,{dataType:"value",data:a??{},onSelect:E=>N(E,"jsonLD")})]}),r.jsx(u.Textarea,{id:"jsonLD",name:"jsonLD",rows:6,value:h.jsonLD,onChange:p,placeholder:"Enter JSON-LD"})]})})})]})]})}),r.jsx("div",{className:"flex items-center justify-end w-full mt-4",children:r.jsx(u.Button,{size:"lg",variant:"default",onClick:j,disabled:g.isEqual(m.current.initial,h)||w,children:S?"Saving...":"Save"})})]})};Gn.displayName="SeoPanel";var vs={};(function e(t,s,n,a){var i=!!(t.Worker&&t.Blob&&t.Promise&&t.OffscreenCanvas&&t.OffscreenCanvasRenderingContext2D&&t.HTMLCanvasElement&&t.HTMLCanvasElement.prototype.transferControlToOffscreen&&t.URL&&t.URL.createObjectURL),o=typeof Path2D=="function"&&typeof DOMMatrix=="function",l=function(){if(!t.OffscreenCanvas)return!1;var y=new OffscreenCanvas(1,1),d=y.getContext("2d");d.fillRect(0,0,1,1);var T=y.transferToImageBitmap();try{d.createPattern(T,"no-repeat")}catch{return!1}return!0}();function c(){}function h(y){var d=s.exports.Promise,T=d!==void 0?d:t.Promise;return typeof T=="function"?new T(y):(y(c,c),null)}var f=function(y,d){return{transform:function(T){if(y)return T;if(d.has(T))return d.get(T);var _=new OffscreenCanvas(T.width,T.height),B=_.getContext("2d");return B.drawImage(T,0,0),d.set(T,_),_},clear:function(){d.clear()}}}(l,new Map),m=function(){var y=Math.floor(16.666666666666668),d,T,_={},B=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(d=function(O){var H=Math.random();return _[H]=requestAnimationFrame(function k($){B===$||B+y-1<$?(B=$,delete _[H],O()):_[H]=requestAnimationFrame(k)}),H},T=function(O){_[O]&&cancelAnimationFrame(_[O])}):(d=function(O){return setTimeout(O,y)},T=function(O){return clearTimeout(O)}),{frame:d,cancel:T}}(),C=function(){var y,d,T={};function _(B){function O(H,k){B.postMessage({options:H||{},callback:k})}B.init=function(k){var $=k.transferControlToOffscreen();B.postMessage({canvas:$},[$])},B.fire=function(k,$,se){if(d)return O(k,null),d;var ie=Math.random().toString(36).slice(2);return d=h(function(ne){function oe(me){me.data.callback===ie&&(delete T[ie],B.removeEventListener("message",oe),d=null,f.clear(),se(),ne())}B.addEventListener("message",oe),O(k,ie),T[ie]=oe.bind(null,{data:{callback:ie}})}),d},B.reset=function(){B.postMessage({reset:!0});for(var k in T)T[k](),delete T[k]}}return function(){if(y)return y;if(!n&&i){var B=["var CONFETTI, SIZE = {}, module = {};","("+e.toString()+")(this, module, true, SIZE);","onmessage = function(msg) {"," if (msg.data.options) {"," CONFETTI(msg.data.options).then(function () {"," if (msg.data.callback) {"," postMessage({ callback: msg.data.callback });"," }"," });"," } else if (msg.data.reset) {"," CONFETTI && CONFETTI.reset();"," } else if (msg.data.resize) {"," SIZE.width = msg.data.resize.width;"," SIZE.height = msg.data.resize.height;"," } else if (msg.data.canvas) {"," SIZE.width = msg.data.canvas.width;"," SIZE.height = msg.data.canvas.height;"," CONFETTI = module.exports.create(msg.data.canvas);"," }","}"].join(`
2
- `);try{y=new Worker(URL.createObjectURL(new Blob([B])))}catch(O){return typeof console!==void 0&&typeof console.warn=="function"&&console.warn("🎊 Could not load worker",O),null}_(y)}return y}}(),x={particleCount:50,angle:90,spread:45,startVelocity:45,decay:.9,gravity:1,drift:0,ticks:200,x:.5,y:.5,shapes:["square","circle"],zIndex:100,colors:["#26ccff","#a25afd","#ff5e7e","#88ff5a","#fcff42","#ffa62d","#ff36ff"],disableForReducedMotion:!1,scalar:1};function S(y,d){return d?d(y):y}function w(y){return y!=null}function j(y,d,T){return S(y&&w(y[d])?y[d]:x[d],T)}function P(y){return y<0?0:Math.floor(y)}function V(y,d){return Math.floor(Math.random()*(d-y))+y}function N(y){return parseInt(y,16)}function p(y){return y.map(E)}function E(y){var d=String(y).replace(/[^0-9a-f]/gi,"");return d.length<6&&(d=d[0]+d[0]+d[1]+d[1]+d[2]+d[2]),{r:N(d.substring(0,2)),g:N(d.substring(2,4)),b:N(d.substring(4,6))}}function ee(y){var d=j(y,"origin",Object);return d.x=j(d,"x",Number),d.y=j(d,"y",Number),d}function A(y){y.width=document.documentElement.clientWidth,y.height=document.documentElement.clientHeight}function q(y){var d=y.getBoundingClientRect();y.width=d.width,y.height=d.height}function M(y){var d=document.createElement("canvas");return d.style.position="fixed",d.style.top="0px",d.style.left="0px",d.style.pointerEvents="none",d.style.zIndex=y,d}function W(y,d,T,_,B,O,H,k,$){y.save(),y.translate(d,T),y.rotate(O),y.scale(_,B),y.arc(0,0,1,H,k,$),y.restore()}function K(y){var d=y.angle*(Math.PI/180),T=y.spread*(Math.PI/180);return{x:y.x,y:y.y,wobble:Math.random()*10,wobbleSpeed:Math.min(.11,Math.random()*.1+.05),velocity:y.startVelocity*.5+Math.random()*y.startVelocity,angle2D:-d+(.5*T-Math.random()*T),tiltAngle:(Math.random()*(.75-.25)+.25)*Math.PI,color:y.color,shape:y.shape,tick:0,totalTicks:y.ticks,decay:y.decay,drift:y.drift,random:Math.random()+2,tiltSin:0,tiltCos:0,wobbleX:0,wobbleY:0,gravity:y.gravity*3,ovalScalar:.6,scalar:y.scalar,flat:y.flat}}function re(y,d){d.x+=Math.cos(d.angle2D)*d.velocity+d.drift,d.y+=Math.sin(d.angle2D)*d.velocity+d.gravity,d.velocity*=d.decay,d.flat?(d.wobble=0,d.wobbleX=d.x+10*d.scalar,d.wobbleY=d.y+10*d.scalar,d.tiltSin=0,d.tiltCos=0,d.random=1):(d.wobble+=d.wobbleSpeed,d.wobbleX=d.x+10*d.scalar*Math.cos(d.wobble),d.wobbleY=d.y+10*d.scalar*Math.sin(d.wobble),d.tiltAngle+=.1,d.tiltSin=Math.sin(d.tiltAngle),d.tiltCos=Math.cos(d.tiltAngle),d.random=Math.random()+2);var T=d.tick++/d.totalTicks,_=d.x+d.random*d.tiltCos,B=d.y+d.random*d.tiltSin,O=d.wobbleX+d.random*d.tiltCos,H=d.wobbleY+d.random*d.tiltSin;if(y.fillStyle="rgba("+d.color.r+", "+d.color.g+", "+d.color.b+", "+(1-T)+")",y.beginPath(),o&&d.shape.type==="path"&&typeof d.shape.path=="string"&&Array.isArray(d.shape.matrix))y.fill(Ee(d.shape.path,d.shape.matrix,d.x,d.y,Math.abs(O-_)*.1,Math.abs(H-B)*.1,Math.PI/10*d.wobble));else if(d.shape.type==="bitmap"){var k=Math.PI/10*d.wobble,$=Math.abs(O-_)*.1,se=Math.abs(H-B)*.1,ie=d.shape.bitmap.width*d.scalar,ne=d.shape.bitmap.height*d.scalar,oe=new DOMMatrix([Math.cos(k)*$,Math.sin(k)*$,-Math.sin(k)*se,Math.cos(k)*se,d.x,d.y]);oe.multiplySelf(new DOMMatrix(d.shape.matrix));var me=y.createPattern(f.transform(d.shape.bitmap),"no-repeat");me.setTransform(oe),y.globalAlpha=1-T,y.fillStyle=me,y.fillRect(d.x-ie/2,d.y-ne/2,ie,ne),y.globalAlpha=1}else if(d.shape==="circle")y.ellipse?y.ellipse(d.x,d.y,Math.abs(O-_)*d.ovalScalar,Math.abs(H-B)*d.ovalScalar,Math.PI/10*d.wobble,0,2*Math.PI):W(y,d.x,d.y,Math.abs(O-_)*d.ovalScalar,Math.abs(H-B)*d.ovalScalar,Math.PI/10*d.wobble,0,2*Math.PI);else if(d.shape==="star")for(var z=Math.PI/2*3,pe=4*d.scalar,be=8*d.scalar,je=d.x,ke=d.y,Be=5,Ce=Math.PI/Be;Be--;)je=d.x+Math.cos(z)*be,ke=d.y+Math.sin(z)*be,y.lineTo(je,ke),z+=Ce,je=d.x+Math.cos(z)*pe,ke=d.y+Math.sin(z)*pe,y.lineTo(je,ke),z+=Ce;else y.moveTo(Math.floor(d.x),Math.floor(d.y)),y.lineTo(Math.floor(d.wobbleX),Math.floor(B)),y.lineTo(Math.floor(O),Math.floor(H)),y.lineTo(Math.floor(_),Math.floor(d.wobbleY));return y.closePath(),y.fill(),d.tick<d.totalTicks}function R(y,d,T,_,B){var O=d.slice(),H=y.getContext("2d"),k,$,se=h(function(ie){function ne(){k=$=null,H.clearRect(0,0,_.width,_.height),f.clear(),B(),ie()}function oe(){n&&!(_.width===a.width&&_.height===a.height)&&(_.width=y.width=a.width,_.height=y.height=a.height),!_.width&&!_.height&&(T(y),_.width=y.width,_.height=y.height),H.clearRect(0,0,_.width,_.height),O=O.filter(function(me){return re(H,me)}),O.length?k=m.frame(oe):ne()}k=m.frame(oe),$=ne});return{addFettis:function(ie){return O=O.concat(ie),se},canvas:y,promise:se,reset:function(){k&&m.cancel(k),$&&$()}}}function de(y,d){var T=!y,_=!!j(d||{},"resize"),B=!1,O=j(d,"disableForReducedMotion",Boolean),H=i&&!!j(d||{},"useWorker"),k=H?C():null,$=T?A:q,se=y&&k?!!y.__confetti_initialized:!1,ie=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion)").matches,ne;function oe(z,pe,be){for(var je=j(z,"particleCount",P),ke=j(z,"angle",Number),Be=j(z,"spread",Number),Ce=j(z,"startVelocity",Number),Un=j(z,"decay",Number),Bn=j(z,"gravity",Number),On=j(z,"drift",Number),ws=j(z,"colors",p),Rn=j(z,"ticks",Number),Es=j(z,"shapes"),Fn=j(z,"scalar"),qn=!!j(z,"flat"),bs=ee(z),js=je,Qt=[],Hn=y.width*bs.x,$n=y.height*bs.y;js--;)Qt.push(K({x:Hn,y:$n,angle:ke,spread:Be,startVelocity:Ce,color:ws[js%ws.length],shape:Es[V(0,Es.length)],ticks:Rn,decay:Un,gravity:Bn,drift:On,scalar:Fn,flat:qn}));return ne?ne.addFettis(Qt):(ne=R(y,Qt,$,pe,be),ne.promise)}function me(z){var pe=O||j(z,"disableForReducedMotion",Boolean),be=j(z,"zIndex",Number);if(pe&&ie)return h(function(Ce){Ce()});T&&ne?y=ne.canvas:T&&!y&&(y=M(be),document.body.appendChild(y)),_&&!se&&$(y);var je={width:y.width,height:y.height};k&&!se&&k.init(y),se=!0,k&&(y.__confetti_initialized=!0);function ke(){if(k){var Ce={getBoundingClientRect:function(){if(!T)return y.getBoundingClientRect()}};$(Ce),k.postMessage({resize:{width:Ce.width,height:Ce.height}});return}je.width=je.height=null}function Be(){ne=null,_&&(B=!1,t.removeEventListener("resize",ke)),T&&y&&(document.body.contains(y)&&document.body.removeChild(y),y=null,se=!1)}return _&&!B&&(B=!0,t.addEventListener("resize",ke,!1)),k?k.fire(z,je,Be):oe(z,je,Be)}return me.reset=function(){k&&k.reset(),ne&&ne.reset()},me}var b;function te(){return b||(b=de(null,{useWorker:!0,resize:!0})),b}function Ee(y,d,T,_,B,O,H){var k=new Path2D(y),$=new Path2D;$.addPath(k,new DOMMatrix(d));var se=new Path2D;return se.addPath($,new DOMMatrix([Math.cos(H)*B,Math.sin(H)*B,-Math.sin(H)*O,Math.cos(H)*O,T,_])),se}function ge(y){if(!o)throw new Error("path confetti are not supported in this browser");var d,T;typeof y=="string"?d=y:(d=y.path,T=y.matrix);var _=new Path2D(d),B=document.createElement("canvas"),O=B.getContext("2d");if(!T){for(var H=1e3,k=H,$=H,se=0,ie=0,ne,oe,me=0;me<H;me+=2)for(var z=0;z<H;z+=2)O.isPointInPath(_,me,z,"nonzero")&&(k=Math.min(k,me),$=Math.min($,z),se=Math.max(se,me),ie=Math.max(ie,z));ne=se-k,oe=ie-$;var pe=10,be=Math.min(pe/ne,pe/oe);T=[be,0,0,be,-Math.round(ne/2+k)*be,-Math.round(oe/2+$)*be]}return{type:"path",path:d,matrix:T}}function Ss(y){var d,T=1,_="#000000",B='"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color", "Android Emoji", "Twemoji Mozilla", "system emoji", sans-serif';typeof y=="string"?d=y:(d=y.text,T="scalar"in y?y.scalar:T,B="fontFamily"in y?y.fontFamily:B,_="color"in y?y.color:_);var O=10*T,H=""+O+"px "+B,k=new OffscreenCanvas(O,O),$=k.getContext("2d");$.font=H;var se=$.measureText(d),ie=Math.ceil(se.actualBoundingBoxRight+se.actualBoundingBoxLeft),ne=Math.ceil(se.actualBoundingBoxAscent+se.actualBoundingBoxDescent),oe=2,me=se.actualBoundingBoxLeft+oe,z=se.actualBoundingBoxAscent+oe;ie+=oe+oe,ne+=oe+oe,k=new OffscreenCanvas(ie,ne),$=k.getContext("2d"),$.font=H,$.fillStyle=_,$.fillText(d,me,z);var pe=1/T;return{type:"bitmap",bitmap:k.transferToImageBitmap(),matrix:[pe,0,0,pe,-ie*pe/2,-ne*pe/2]}}s.exports=function(){return te().apply(this,arguments)},s.exports.reset=function(){te().reset()},s.exports.create=de,s.exports.shapeFromPath=ge,s.exports.shapeFromText=Ss})(function(){return typeof window<"u"?window:typeof self<"u"?self:this||{}}(),vs,!1);const ai=vs.exports;vs.exports.create;const ii={particleCount:350,spread:120,origin:{y:.6},angle:90},oi={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},qt=e=>{let t=oi[e];t||(t={});const s={...ii,...t};ai(s)},li=()=>{const[e]=ve.useTheme(),{mutate:t,isPending:s}=xs(),{mutateAsync:n,isPending:a}=kn(),i=()=>{n({settings:{theme:e}})},o=()=>{t({ids:["THEME"]},{onSuccess:()=>{qt("BOTTOM_RIGHT")}})};return r.jsxs("div",{className:"bg-white py-3 flex items-center justify-center gap-x-3 border-t",children:[r.jsx(u.Button,{size:"sm",variant:"outline",disabled:s||a,onClick:i,children:"Save draft"}),r.jsx(u.Button,{size:"sm",disabled:s||a,onClick:o,children:"Publish"})]})};function ci({addEditPage:e,additionalPageTypes:t=[],close:s}){var R,de;const n=!!(e!=null&&e.id),{data:a}=Kt(),{mutate:i,isPending:o}=In(),{mutate:l,isPending:c}=ys(),[h,f]=v.useState(null),[m,C]=v.useState((e==null?void 0:e.pageType)??"page"),[x,S]=v.useState(t.find(b=>b.key===m)),[w,j]=v.useState((e==null?void 0:e.parent)??""),[P,V]=v.useState((e==null?void 0:e.name)??""),[N,p]=v.useState(((e==null?void 0:e.slug)??"").split("/").pop()||""),[E,ee]=v.useState((e==null?void 0:e.dynamic)??!1),A=o||c,q=t.find(b=>b.key===m),M=b=>{C(b),j(""),p(""),ee(!1),S(t.find(te=>te.key===b))},W=b=>{ee(b),b&&p("")},K=b=>{if(j(b),b&&b!=="none"){const te=a==null?void 0:a.find(ge=>ge.id===b),Ee=(te==null?void 0:te.slug)||"";if(N.startsWith(Ee)){const ge=N.slice(Ee.length).replace(/^\/+/,"");p(ge)}else p(N.replace(/^\/+/,""))}else p(N?`${N}`:"")},re=b=>{if(b.preventDefault(),N.length>0&&!E&&!N.match(/^[a-zA-Z0-9-_]+$/)){f("Slug can only contain letters, numbers, and hyphens");return}if(E&&N!==""){f("Slug must be empty when using dynamic slug");return}if(!P.trim()){ae.toast.error("Name is required");return}if(!(x!=null&&x.hasSlug)){const te={pageType:x==null?void 0:x.key,name:P,slug:"",hasSlug:!1};if(n){l({id:e==null?void 0:e.id,name:P},{onSuccess:()=>{ae.toast.success((x==null?void 0:x.name)+" updated successfully"),s()}});return}i(te,{onSuccess:()=>{ae.toast.success((x==null?void 0:x.name)+" created successfully"),s()}});return}if(w&&w!=="none"){if(!N.trim()&&!E){ae.toast.error("Child page slug is required");return}const te=a==null?void 0:a.find(T=>T.id===w),Ee=(te==null?void 0:te.slug)||"",ge=Ee==="/"?`/${N}`:`${Ee}/${N}`;if(Object.keys(Ne).some(T=>ge===`/${T}`||(ge==null?void 0:ge.startsWith(`/${T}/`)))){ae.toast.error("Slugs cannot start with a language code for primary page");return}const d={pageType:m,name:P,slug:ge.replace(/\/$/,""),parent:w,dynamic:E,hasSlug:!0};if(n){l({id:e==null?void 0:e.id,...d},{onSuccess:()=>{ae.toast.success("Page updated successfully"),s()}});return}i(d,{onSuccess:()=>{ae.toast.success("Page created successfully"),s()}})}else{const te={pageType:m,name:P,slug:N===""?"/":`/${N.replace(/\/$/,"")}`};if(n){l({id:e==null?void 0:e.id,...te},{onSuccess:()=>{ae.toast.success("Page updated successfully"),s()}});return}i(te,{onSuccess:()=>{ae.toast.success("Page created successfully"),s()}})}};return x!=null&&x.hasSlug?(console.log(a),r.jsxs("form",{onSubmit:re,className:"w-full max-w-md mx-auto space-y-4",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(u.Label,{htmlFor:"pageType",className:"text-sm",children:"Page Type"}),r.jsx("select",{id:"pageType",value:m,disabled:n,onChange:b=>M(b.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${n?"cursor-not-allowed text-gray-500":""}`,children:t.map(b=>r.jsx("option",{value:b.key,children:b.name},b.key))})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(u.Label,{htmlFor:"parentPage",className:"text-sm",children:"Parent"}),r.jsxs("select",{id:"parentPage",value:w,onChange:b=>K(b.target.value),className:"w-full rounded-md border border-gray-300 px-3 py-2",children:[r.jsx("option",{value:"none",children:"None"}),a==null?void 0:a.filter(b=>!g.isEmpty(b.slug)).filter(b=>b.slug!=="/").sort((b,te)=>b.name.localeCompare(te.name)).map(b=>r.jsxs("option",{value:b.id,children:[b.name," (",b.slug,")"]},b.id))]})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(u.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),r.jsx(u.Input,{id:"name",value:P,onChange:b=>V(b.target.value),required:!0,"aria-required":"true"})]}),(q==null?void 0:q.dynamicSegments)&&w&&w!=="none"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx("input",{type:"checkbox",id:"useDynamicSlug",checked:E,onChange:b=>W(b.target.checked),className:"rounded border-gray-300"}),r.jsx(u.Label,{htmlFor:"useDynamicSlug",className:"text-sm",children:"Use Dynamic Slug"})]}),E&&r.jsxs("div",{className:"text-sm text-gray-500",children:["Pages will use pattern: ",q==null?void 0:q.dynamicSlug]})]}),(!(q!=null&&q.dynamicSegments)||!E)&&r.jsxs("div",{className:"space-y-0.5",children:[r.jsxs(u.Label,{htmlFor:"slug",className:"text-sm",children:["Slug",w&&w!=="none"&&r.jsxs("span",{className:"ml-2 text-sm text-gray-500",children:["Parent:"," ",(de=a==null?void 0:a.find(b=>b.id===w))==null?void 0:de.slug]})]}),r.jsx(u.Input,{id:"slug",value:N,onChange:b=>p(b.target.value),placeholder:w&&w!=="none"?"Enter page slug":m==="page"?"Leave empty for home page":"Required - e.g. /your-slug"}),h&&r.jsx("p",{className:"text-xs text-red-500",children:h})]}),r.jsx(u.Button,{disabled:A,type:"submit",className:"w-full",children:n?A?"Updating...":"Update page":A?"Creating...":"Create Page"})]})):r.jsxs("form",{onSubmit:re,className:"w-full max-w-md mx-auto space-y-4",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(u.Label,{htmlFor:"pageType",className:"text-sm",children:"Page Type"}),r.jsx("select",{id:"pageType",value:m,disabled:n,onChange:b=>M(b.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${n?"cursor-not-allowed text-gray-500":""}`,children:t.map(b=>r.jsx("option",{value:b.key,children:b.name},b.key))}),r.jsx("p",{className:"text-sm text-gray-500",children:(R=t.find(b=>b.key===m))==null?void 0:R.helpText})]}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(u.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),r.jsx(u.Input,{id:"name",value:P,onChange:b=>V(b.target.value),required:!0,"aria-required":"true"})]}),r.jsx(u.Button,{disabled:A,type:"submit",className:"w-full",children:n?A?"Updating...":"Update "+(x==null?void 0:x.name):A?"Creating...":"Create "+(x==null?void 0:x.name)})]})}const ui=({addEditPage:e,setAddEditPage:t})=>{const{data:s}=Se(),n=!!(e!=null&&e.id);return r.jsx(u.Dialog,{open:!!e,onOpenChange:()=>t(void 0),children:r.jsxs(u.DialogContent,{className:"sm:max-w-[425px]",children:[r.jsxs(u.DialogHeader,{children:[r.jsxs(u.DialogTitle,{children:[n?"Edit":"Add New"," "]}),r.jsx(u.DialogDescription,{children:n?"Update your page name":"Enter details to create a new page"})]}),r.jsx(ci,{addEditPage:e,close:()=>t(void 0),additionalPageTypes:s??[]})]})})},es=({parentSlug:e,page:t,active:s,changeActivePage:n,setUnpublishPage:a,setDeletePage:i,setAddEditPage:o})=>{const{data:l}=Se(),c=v.useMemo(()=>g.find(l,{key:t.pageType}),[l,t.pageType]),h=g.get(t,"slug").replace(e,"")||"/";return r.jsxs("div",{onClick:()=>n(g.get(t,"id")),className:`rounded flex p-1.5 items-center justify-between leading-none duration-300 cursor-pointer px-3 py-1.5 ${s?"bg-gray-200":"hover:bg-gray-100"}`,children:[r.jsxs("div",{className:"flex items-center gap-x-2",children:[t.dynamic?r.jsx("div",{className:"w-4 h-4 text-slate-500 stroke-[1]",children:r.jsx(I.StarsIcon,{className:"w-4 h-4 text-yellow-400"})}):c!=null&&c.icon?r.jsx("div",{className:"w-4 h-4 text-slate-500 stroke-[1]",dangerouslySetInnerHTML:{__html:c.icon}}):c!=null&&c.hasSlug?r.jsx(I.File,{className:"w-4 h-4 text-slate-500 stroke-[1]"}):r.jsx(I.Globe,{className:"w-4 h-4 text-slate-500 stroke-[1]"}),r.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),r.jsx("span",{className:"font-light leading-none truncate text-slate-800",children:g.startCase(t.name)??""}),c!=null&&c.hasSlug?r.jsxs(u.Badge,{variant:"outline",className:`ml-2 text-xs max-w-full leading-tight py-px font-normal rounded-full text-gray-400 border ${s?"border-gray-300":"border-gray-200"}`,children:[h,t.dynamic&&r.jsx("span",{className:"text-xs font-light leading-none text-slate-500",children:g.endsWith(h,"/")?`${c==null?void 0:c.dynamicSlug}`:`/${c==null?void 0:c.dynamicSlug}`})]}):r.jsx(u.Badge,{variant:"outline",className:`ml-2 text-xs max-w-full leading-tight py-px font-normal rounded-full text-gray-400 border ${s?"border-gray-300":"border-gray-200"}`,children:c==null?void 0:c.name})]}),r.jsx("div",{className:"flex items-center space-x-4",children:r.jsxs(u.DropdownMenu,{children:[r.jsx(u.DropdownMenuTrigger,{asChild:!0,onClick:f=>f.stopPropagation(),children:r.jsx(I.MoreHorizontal,{className:"h-4 w-4 hover:stroke-[3]"})}),r.jsxs(u.DropdownMenuContent,{align:"end",className:"text-sm",children:[r.jsxs(u.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:f=>{f.stopPropagation(),o({...t,global:!(c!=null&&c.hasSlug)})},children:[r.jsx(I.Pencil,{className:"size-3"}),"Edit"]}),(t==null?void 0:t.online)&&r.jsxs(u.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:f=>{f.stopPropagation(),a(t)},children:[r.jsx(I.Power,{className:"size-3"}),U.UNPUBLISH]}),r.jsxs(u.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:f=>{f.stopPropagation(),i(t)},children:[r.jsx(I.Trash,{className:"size-3"}),U.DELETE]})]})]})})]})},di=({close:e})=>{const[,t]=v.useState([]),[s,n]=v.useState(""),[a,i]=v.useState(null),[o,l]=v.useState(null),[c,h]=v.useState(null),{mutate:f}=Pn(),{data:m,isFetching:C}=Kt(),[x,S]=v.useState(""),[w,j]=we(),P=w.get("page"),{data:V}=Se(),N=v.useCallback(A=>{var q;return(q=g.find(V,{key:A}))==null?void 0:q.hasSlug},[V]);v.useEffect(()=>{if(!g.isEmpty(x))return;const A=sessionStorage.getItem("pageTypeFilter")||"all";!g.isEmpty(V)&&A&&(g.find(V,{key:A})?S(A):S("all"))},[V,x]);const p=A=>{S(A),sessionStorage.setItem("pageTypeFilter",A)},E=v.useCallback(A=>{P&&f({id:P});const M=new URLSearchParams(window.location.search).get("lang"),W=new URLSearchParams({page:A});M&&W.set("lang",M),window.history.pushState({},"",`?${W.toString()}`),j(W),window.dispatchEvent(new PopStateEvent("popstate")),e()},[P,j,e,f]);v.useEffect(()=>{if(P&&!C){const A=g.find(m,{id:P});A&&(A!=null&&A.pageType)?t(q=>[...q,A==null?void 0:A.pageType]):(window.history.replaceState(null,"","/"),j(new URLSearchParams({})),window.dispatchEvent(new PopStateEvent("popstate")))}},[m,P,C,j]);const ee=v.useMemo(()=>{const A=g.filter(m,R=>g.isEmpty(s)?!0:g.includes(g.toLower(R==null?void 0:R.name),g.toLower(s))||g.includes(g.toLower(R==null?void 0:R.slug),g.toLower(s)));if(x!=="all")return g.filter(A,{pageType:x});const q=new Map;A.forEach(R=>{q.set(R.id,{...R,children:[]})});const M=[],W=[];q.forEach(R=>{if(R.parent){const de=q.get(R.parent);de?de.children.push(R):M.push(R)}else W.push(R)}),M.sort((R,de)=>R.name.localeCompare(de.name)),M.forEach(R=>{R.children.sort((de,b)=>de.name.localeCompare(b.name))});const K=g.filter(W,R=>!N(R.pageType)),re=g.filter(W,R=>N(R.pageType)).sort((R,de)=>R.name.localeCompare(de.name));return g.compact([...re,...K,...M])},[m,N,s,x]);return r.jsxs("div",{className:"flex flex-col justify-between h-full",children:[r.jsxs("div",{className:"flex flex-col h-full space-y-6",children:[r.jsxs("div",{className:"relative flex item-center gap-x-4",children:[r.jsx(I.Search,{strokeWidth:2.5,className:"absolute left-3 top-2.5 h-4 w-4 text-gray-400"}),r.jsx(u.Input,{placeholder:"Search pages...",className:"text-xs font-medium leading-none text-gray-700 pl-9 pr-24 placeholder:text-gray-400",value:s,onChange:A=>n(A.target.value)}),!g.isEmpty(x)&&r.jsxs(u.Select,{value:x,onValueChange:p,children:[r.jsx(u.SelectTrigger,{className:`${x==="all"?"bg-gray-50 hover:bg-gray-100":"bg-gray-100 hover:bg-gray-50"} min-w-[120px] h-max p-0 py-1 pl-2 pr-1 top-1.5 -mt-px absolute text-gray-600 right-1.5 w-max text-xs whitespace-nowrap ring-0 focus:ring-0 shadow-none`,children:r.jsx(u.SelectValue,{placeholder:"Select page type"})}),r.jsx(u.SelectContent,{align:"end",children:g.map(g.concat([{key:"all",name:"All"}],V),A=>r.jsx(u.SelectItem,{value:g.get(A,"key"),children:g.get(A,"name")}))})]})]}),C?r.jsx("div",{className:"space-y-2",children:g.map([...Array(5).keys()],A=>r.jsx("div",{className:"w-full bg-gray-200 rounded h-9 animate-pulse"},A))}):g.isEmpty(ee)?r.jsxs("div",{className:"h-[70vh] flex flex-col gap-y-1 items-center justify-center text-slate-500 text-sm font-medium",children:[r.jsx(I.File,{className:"h-6 w-6 stroke-[1]"}),"Empty List!",r.jsx("span",{className:"font-light",children:"Add new page to start"})]}):r.jsx("div",{className:"text-sm text-slate-700 space-y-2 h-[70vh] overflow-y-auto",children:g.map(ee,A=>g.isEmpty(A==null?void 0:A.children)?r.jsx(es,{changeActivePage:E,setUnpublishPage:l,setDeletePage:i,setAddEditPage:h,active:P===A.id,page:A},A.id):r.jsxs("div",{className:"border-0",children:[r.jsx(es,{changeActivePage:E,setUnpublishPage:l,setDeletePage:i,setAddEditPage:h,active:P===A.id,page:A}),r.jsx("div",{className:"pt-2 pl-6 bg-white",children:g.map(g.get(A,"children",[]),q=>{const M=P===g.get(q,"id");return r.jsx(es,{parentSlug:A.slug,changeActivePage:E,setUnpublishPage:l,setDeletePage:i,setAddEditPage:h,active:M,page:q},q.id)})})]},A.key))})]}),r.jsxs(u.Button,{className:"flex text-sm gap-x-2",onClick:()=>{h({slug:"",name:"",pageType:x==="all"?"page":x})},children:[r.jsx(I.Plus,{className:"w-4 h-4"})," Add New"]}),c&&r.jsx(ui,{editPage:E,addEditPage:c,setAddEditPage:h}),a&&r.jsx(Ln,{page:a,onClose:()=>i(null)}),o&&r.jsx(ps,{page:o,onClose:()=>l(null)})]})},hi=()=>{const e=_e("logo",null);return e?r.jsx("div",{className:"w-full max-h-9 overflow-hidden pr-2",children:v.createElement(e,{})}):null},fi=()=>{const[e]=we(),t=e.get("page"),{data:s,isFetching:n}=Pe(),[a,i]=v.useState(!1),o=!!t&&!g.isEmpty(s),l=!t||!n&&g.isEmpty(s)||a;return r.jsxs(r.Fragment,{children:[r.jsxs(u.Button,{variant:"secondary",className:"flex items-center w-full space-x-2 py-1",onClick:()=>i(!0),children:[r.jsx("div",{children:r.jsx(I.Logs,{className:"h-4 w-4"})}),r.jsxs("span",{className:"truncate leading-tight flex items-center max-w-[200px]",children:[r.jsx("span",{className:"text-slate-600 pr-1 font-light",children:"Editing:"}),n?r.jsx(I.Loader,{className:"h-4 w-4 animate-spin text-slate-400 ml-2"}):g.startCase(g.get(s,"name"))??""]})]},"template-viewer"),r.jsx(u.Sheet,{open:l,onOpenChange:c=>!c&&o&&i(!1),children:r.jsxs(u.SheetContent,{side:"left",className:`!max-w-screen-md z-50 border-border w-full ${o?"":"sheet-hide-close-btn"}`,children:[r.jsx(u.SheetHeader,{className:"mb-3",children:r.jsxs(u.SheetTitle,{className:"text-sm flex items-center gap-2 font-semibold",children:[r.jsx("div",{className:"p-2 rounded-md bg-primary text-primary-foreground",children:r.jsx(I.File,{className:"w-6 h-6"})}),r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{className:"text-sm font-semibold",children:"Pages"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Manage your site structure"})]})]})}),r.jsx("div",{className:"h-[calc(100vh-100px)] overflow-y-auto",children:r.jsx(di,{close:()=>i(!1)})})]})})]})},mi=()=>{const{fallbackLang:e,languages:t,selectedLang:s,setSelectedLang:n}=ve.useLanguages(),a=g.isEmpty(s)?e:s,[,i]=we();v.useEffect(()=>{const S=new URLSearchParams(window.location.search),w=S.get("lang");w&&(t.includes(w)?n(w):(S.delete("lang"),i(S),n("")))},[t,i,n]);const[o,l]=v.useState(null),{data:c}=Pe(),{data:h}=zt(),{data:f,isFetching:m}=Pt(),C=v.useMemo(()=>{const S=g.compact(g.map(g.get(h,"languages"),w=>{const j=g.find(f,{lang:w});return{key:w,value:g.get(Ne,w,w),isLangPageAdded:!!j}})).filter(Boolean);return[{key:e,value:g.get(Ne,e),isLangPageAdded:!0},...S]},[e,f,h]),x=S=>{n(S);const w=new URLSearchParams(window.location.search);S===e?w.delete("lang"):w.set("lang",S);const j=w.toString(),P=`${window.location.pathname}${j?`?${j}`:""}`;window.history.pushState({},"",P),i(w),window.dispatchEvent(new PopStateEvent("popstate"))};return g.isEmpty(t)||m?null:r.jsxs(r.Fragment,{children:[r.jsxs(u.DropdownMenu,{children:[r.jsx(u.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:r.jsxs(u.Button,{variant:"ghost",size:"sm",className:"gap-2",children:[r.jsx(I.Languages,{className:"w-4 h-4"}),g.get(Ne,a,a),r.jsx(I.ChevronDown,{className:"w-4 h-4"})]})}),r.jsxs(u.DropdownMenuContent,{className:"border-border space-y-1",children:[g.map(C.filter(S=>S.isLangPageAdded),S=>r.jsxs(u.DropdownMenuItem,{className:ve.mergeClasses("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",S.key===a&&"!bg-gray-200 text-gray-700"),onClick:()=>x(S.key),children:[r.jsx("div",{className:"text-slate-600",children:S.value}),S.key===e&&r.jsxs("small",{className:"text-[9px] flex items-center gap-x-1 text-orange-500 leading-none",children:[r.jsx(I.Star,{fill:"orange",className:"w-2 h-2"}),"Primary"]})]},S.value)),!g.isEmpty(C.filter(S=>!S.isLangPageAdded))&&r.jsxs(r.Fragment,{children:[r.jsx(u.Separator,{}),r.jsxs(u.Button,{size:"sm",variant:"ghost",onClick:()=>{l({name:c==null?void 0:c.name,pageType:c==null?void 0:c.pageType,lang:"",slug:"",edit:!1})},className:"hover:bg-slate-300 duration-200 font-normal text-xs hover:text-slate-800",children:[r.jsx(I.Plus,{className:"w-3 h-3 mr-1"})," Add Langauge"]})]})]})]}),o&&r.jsx(_n,{languages:t,langProps:o,onClose:()=>l(null)})]})};function gi(){return r.jsxs("div",{className:"flex relative z-10 items-center justify-end gap-1",children:[r.jsx(hi,{}),r.jsx(fi,{}),r.jsx(mi,{})]})}function Mn({children:e,content:t}){return r.jsx(u.TooltipProvider,{children:r.jsxs(u.Tooltip,{children:[r.jsx(u.TooltipTrigger,{asChild:!0,children:e}),r.jsx(u.TooltipContent,{side:"bottom",sideOffset:10,children:r.jsx("p",{children:t})})]})})}const yi=()=>{const e=ce(),t=ue();return F.useQuery({queryKey:[L.GET_CHANGES],queryFn:async()=>t(e,{action:L.GET_CHANGES})})},xi=({currentEditor:e})=>{const{data:t}=Cn(e);return t==null?void 0:t.name};function pi({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const[s,n]=v.useState([]),{data:a,isFetching:i}=yi(),{data:o}=Se(),l=v.useCallback(p=>{var E;return(E=g.find(o,{key:p}))==null?void 0:E.hasSlug},[o]),c=v.useMemo(()=>g.filter(o,p=>!l(p.key)).map(p=>p.key),[l,o]),h=v.useMemo(()=>g.filter(a,p=>!c.includes(p.pageType)),[a,c]),f=v.useMemo(()=>g.filter(a,p=>c.includes(p.pageType)),[a,c]),m=v.useMemo(()=>g.find(a,{pageType:"theme",id:"THEME"}),[a]),{mutate:C,isPending:x}=xs();v.useEffect(()=>{const p=g.map(g.filter(a,{online:!0}),"id");m&&p.push(m==null?void 0:m.id),n(p)},[a,m]);const S=s.length===(a==null?void 0:a.length),w=p=>{n(E=>g.includes(E,p)?g.filter(E,ee=>ee!==p):g.concat(E,p))},j=()=>{n(S?[]:g.map(a,"id"))},P=()=>{C({ids:g.uniq(s)},{onSuccess:()=>{t(),qt("CENTER_CENTER")}})},V=p=>{if(p==="theme")return"Theme";const E=g.find(o,{key:p});return E?E==null?void 0:E.name:p},N=v.useMemo(()=>{const p=[{label:"Updated",top:"pt-2"},...g.orderBy(g.filter(h,{online:!0}),"pageType"),...g.orderBy(g.filter(f,{online:!0}),"pageType")].filter(A=>A.pageType!=="theme"),E=[{label:"Offline",top:"pt-6"},...g.orderBy(g.filter(h,{online:!1}),"pageType"),...g.orderBy(g.filter(f,{online:!1}),"pageType")],ee=m?[{label:"Theme",top:"pt-6"},m]:[];return[...p,...ee,...E]},[h,f,m]);return r.jsx(u.Dialog,{open:e,onOpenChange:x?()=>{}:t,children:r.jsxs(u.DialogContent,{className:"max-w-4xl max-h-[80%] flex flex-col",children:[r.jsxs(u.DialogHeader,{children:[r.jsx(u.DialogTitle,{children:"Publish changes"}),r.jsx(u.DialogDescription,{className:"text-xs",children:"Select the pages you want to publish. Click publish when you're done."})]}),r.jsx("div",{className:"relative h-full max-h-full -mx-4 overflow-y-auto no-scrollbar",children:i?r.jsxs("div",{className:"px-1 space-y-2",children:[r.jsx("div",{className:"w-full h-6 mt-2 bg-gray-200 rounded animate-pulse"}),r.jsx("div",{className:"w-full h-6 bg-gray-200 rounded animate-pulse"}),r.jsx("div",{className:"w-full h-6 bg-gray-200 rounded animate-pulse"}),r.jsx("div",{className:"w-full h-6 bg-gray-200 rounded animate-pulse"})]}):r.jsxs("table",{className:"w-full text-xs text-left text-gray-500 rtl:text-right dark:text-gray-400",children:[r.jsx("thead",{className:"text-gray-700 border-b bg-gray-50 dark:bg-gray-700 dark:text-gray-400",children:r.jsxs("tr",{children:[r.jsxs("th",{scope:"col",className:"px-6 py-3 flex items-center gap-x-2 w-[1 50px]",children:[r.jsx("input",{checked:S,onClick:p=>{p.stopPropagation(),j()},type:"checkbox",className:"mt-1 rounded cursor-pointer focus:outline-none focus:ring-0"}),"Name"]}),r.jsx("th",{scope:"col",className:"px-2 py-3 w-[100px]",children:"Language"}),r.jsx("th",{scope:"col",className:"px-2 py-3 w-[100px]",children:"Type"}),r.jsx("th",{scope:"col",className:"px-4 py-3 w-[150px] text-right",children:"Status"})]})}),r.jsx("tbody",{children:g.map(N,p=>p.label?r.jsx("tr",{children:r.jsxs("td",{colSpan:4,className:`px-6 py-2 text-xs font-medium text-gray-800 relative ${p.top}`,children:[r.jsx("div",{className:"absolute inset-0 flex items-center left-6",children:r.jsx("div",{className:"w-full order-gray-300"})}),r.jsx("div",{className:"relative flex justify-start",children:r.jsx("span",{className:"pr-2 bg-gray-50",children:p.label})})]})},"separator"):r.jsxs("tr",{className:"border-b group hover:bg-gray-50 last:border-b-0",children:[r.jsxs("td",{scope:"row",className:"flex items-center px-6 py-2 text-gray-900 whitespace-nowrap dark:text-white gap-x-1",children:[r.jsx("input",{checked:g.includes(s,p==null?void 0:p.id),onClick:E=>{E.stopPropagation(),w(p==null?void 0:p.id)},type:"checkbox",className:"rounded cursor-pointer focus:outline-none focus:ring-0"})," ",l(p.pageType)?r.jsx(I.File,{className:"w-4 h-4"}):r.jsx(I.GlobeIcon,{className:"w-4 h-4"}),p.name,p.slug&&r.jsxs("span",{className:"text-xs text-gray-500",children:["(",p.slug,")"]}),p.currentEditor&&r.jsx("div",{className:"flex items-center gap-x-1",children:r.jsxs("span",{className:"flex text-xs font-bold text-gray-500",children:[" ","-"," ",r.jsx(xi,{currentEditor:p.currentEditor})," ","is editing"]})})]}),r.jsx("td",{className:"px-2",children:p.lang}),r.jsx("td",{className:"px-2",children:V(p==null?void 0:p.pageType)}),r.jsx("td",{className:"px-4 text-right",children:g.first(p.changes)||""})]},p==null?void 0:p.id))})]})}),r.jsxs(u.DialogFooter,{className:"mt-10",children:[r.jsx(u.Button,{disabled:x,variant:"outline",onClick:t,children:"Cancel"}),r.jsx(u.Button,{disabled:x||i||g.isEmpty(a),onClick:P,children:x?"Publishing...":"Publish"})]})]})})}const vi=()=>{const e=ue(),t=ce();return F.useQuery({queryKey:[L.GET_WEBSITE_DATA],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:L.GET_WEBSITE_DATA,data:{draft:!0}})})};function Si({onClose:e}){const{data:t,isFetching:s}=vi(),{mutateAsync:n,isPending:a}=Ha(),i=_e("settingComponent",null),o=g.debounce(async l=>(await n({data:l}),!0),300);return i?r.jsx(u.Dialog,{open:!0,onOpenChange:e,children:r.jsxs(u.DialogContent,{className:"w-full",children:[r.jsx(u.DialogHeader,{children:r.jsx(u.DialogTitle,{children:"Website Settings"})}),s?r.jsxs("div",{className:"w-full space-y-3 py-4",children:[r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"})]}):r.jsx("div",{children:v.createElement(i,{data:t||{},onSave:a?()=>{}:o,cancel:a?()=>{}:e})})]})}):null}const wi=()=>{const{selectedLang:e}=ve.useLanguages(),t=_e("getPreviewUrl",async f=>f),[s,n]=v.useState(""),{data:a,isFetching:i}=Pe(),{data:o}=Pt(),{data:l}=Se(),c=v.useMemo(()=>{var f;return(f=o==null?void 0:o.find(m=>(m==null?void 0:m.lang)===e))==null?void 0:f.slug},[e,o]),h=v.useCallback(f=>{var m;return(m=g.find(l,{key:f}))==null?void 0:m.hasSlug},[l]);return v.useEffect(()=>{(async()=>{if(c&&typeof t=="function"){const f=await t(c||"");n(f)}else n("")})()},[t,c]),!s||!h(a==null?void 0:a.pageType)||i?null:r.jsx(r.Fragment,{children:r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:r.jsxs(u.Button,{variant:"ghost",size:"sm",className:"gap-2",children:[r.jsx(I.Eye,{className:"w-4 h-4"})," ",U.PREVIEW]})})})},Ei=()=>{const[e,t]=ve.useRightPanel();return r.jsxs(r.Fragment,{children:[r.jsx(Mn,{content:U.THEME,children:r.jsx(u.Button,{variant:e==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>t(e==="theme"?"block":"theme"),children:r.jsx(I.Palette,{className:"w-4 h-4"})})}),r.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700"})]})},bi=()=>{const[e,t]=v.useState(!1),{isLocked:s}=Tt(),{savePage:n,saveState:a}=ve.useSavePage();v.useEffect(()=>{const f=m=>{a==="UNSAVED"&&(m.preventDefault(),m.returnValue=!1)};return a==="UNSAVED"&&window.addEventListener("beforeunload",f),()=>{window.removeEventListener("beforeunload",f)}},[a]);const i=v.useCallback(async()=>{t(!0),await n(!1)},[n]);v.useEffect(()=>{a==="SAVED"&&t(!1)},[a]);const o=v.useMemo(()=>{if(a==="SAVED"||a==="UNSAVED")return a;if(a==="SAVING")return e?a:"SAVED"},[e,a]),{buttonIcon:l,buttonClass:c,tooltipContent:h}=v.useMemo(()=>{switch(o){case"UNSAVED":return{tooltipContent:U.SAVEDRAFT,buttonIcon:r.jsx(I.Save,{className:"w-4 h-4"}),buttonClass:"flex items-center gap-x-1 leading-tight"};case"SAVING":return{tooltipContent:U.SAVING,buttonIcon:r.jsx(I.Loader,{className:"w-4 h-4 animate-spin"}),buttonClass:"flex items-center gap-x-1 leading-tight"};case"SAVED":return{tooltipContent:U.SAVED,buttonIcon:r.jsx(I.CheckCircle,{className:"w-4 h-4"}),buttonClass:"text-green-500 flex items-center gap-x-1 leading-tight"}}},[o]);return s?null:r.jsxs(u.Button,{size:"sm",variant:"ghost",onClick:i,className:c,children:[l," ",h]})},ji=()=>{const[e,t]=v.useState(!1),[s,n]=v.useState(!1),[a,i]=v.useState(null),{data:o}=Pe(),{mutate:l,isPending:c}=xs(),[h]=ve.useBlocksStore(),{buttonText:f,buttonClassName:m,isPublished:C}=v.useMemo(()=>{const S=o&&(o==null?void 0:o.online);return{buttonClassName:S?"hover:bg-green-600 bg-green-500":"",isPublished:S,buttonText:S?U.PUBLISHED:U.PUBLISH}},[o]),x=async()=>{var w,j;const S=((j=(w=h==null?void 0:h.filter(P=>(P==null?void 0:P._type)==="GlobalBlock"))==null?void 0:w.map(P=>P==null?void 0:P.globalBlock))==null?void 0:j.filter(P=>typeof P=="string"))||[];l({ids:[o==null?void 0:o.id,...S]},{onSuccess:()=>qt("TOP_RIGHT")})};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex",children:[r.jsxs(u.Button,{size:"sm",onClick:x,disabled:c||!(o!=null&&o.id),className:`relative overflow-hidden transition-all duration-300 ease-in-out text-white flex items-center gap-1 rounded-r-none ${m}`,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[r.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${s?"-translate-y-10":""}`,children:C?r.jsx(I.Send,{className:"w-4 h-4"}):r.jsx(I.Rocket,{className:"w-4 h-4"})}),r.jsx("span",{className:`absolute inset-0 flex items-center left-3 transition-transform duration-300 ease-in-out ${s?"":"translate-y-10"}`,children:C?r.jsx(I.Rocket,{className:"w-4 h-4"}):r.jsx(I.Send,{className:"w-4 h-4"})}),r.jsx("span",{children:f})]}),r.jsxs(u.DropdownMenu,{children:[r.jsx(u.DropdownMenuTrigger,{asChild:!0,children:r.jsx(u.Button,{size:"sm",disabled:c||!(o!=null&&o.id),className:`px-2 text-white border-l border-white/50 rounded-l-none ${m}`,children:r.jsx(I.ChevronDown,{className:"w-4 h-4"})})}),r.jsxs(u.DropdownMenuContent,{align:"end",className:"w-36",children:[!C&&r.jsxs(u.DropdownMenuItem,{disabled:c,className:"text-xs cursor-pointer",onClick:()=>l({ids:[o==null?void 0:o.id]},{onSuccess:()=>qt("TOP_RIGHT")}),children:[U.PUBLISH," page"]}),r.jsxs(u.DropdownMenuItem,{onClick:()=>t(!0),className:"text-xs cursor-pointer",children:[U.OPEN," publish menu"]}),C&&r.jsxs(u.DropdownMenuItem,{onClick:()=>i(o),className:"text-xs cursor-pointer",children:[U.UNPUBLISH," page"]})]})]})]}),r.jsx(pi,{showModal:e,onClose:()=>t(!1)}),a&&r.jsx(ps,{page:a,onClose:()=>i(null)})]})},Ni=()=>{const e=_e("settingComponent",null),[t,s]=v.useState(!1);return e?r.jsxs(r.Fragment,{children:[r.jsx(Mn,{content:U.WEBSITEDATA,children:r.jsx(u.Button,{variant:"ghost",size:"icon",className:"gap-2",onClick:()=>s(!0),children:r.jsx(I.Settings,{className:"w-4 h-4"})})}),t&&r.jsx(Si,{onClose:()=>s(!1)}),r.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700"})]}):null},Ci=()=>{const{data:e}=Pe(),t=e&&(e==null?void 0:e.online),{data:s}=Se();return v.useCallback(a=>{var i;return(i=g.find(s,{key:a}))==null?void 0:i.hasSlug},[s])(e==null?void 0:e.pageType)?r.jsxs(u.Button,{onClick:()=>t&&window.open(`${window.location.origin}${e.slug}`,"_blank"),disabled:!t,variant:"ghost",size:"sm",className:"flex items-center gap-1",children:[r.jsx(I.ExternalLink,{className:"w-4 h-4"}),r.jsx("span",{className:"hidden sm:inline",children:U.OPEN})]}):null};function Ai(){const{isLocked:e}=Tt(),[t]=we(),s=t.get("lang"),n=Dn(s);return e||!n?null:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(Ei,{}),r.jsx(Ni,{}),r.jsx(wi,{}),r.jsx(bi,{}),r.jsx(ji,{}),r.jsx(Ci,{})]})}Vn.loadWebBlocks();const Ti=e=>{const t=v.useRef([]),[s]=we(),n=s.get("page"),a=s.get("lang"),{data:i}=Pe(),{data:o}=Va(),{data:l,isFetching:c}=An(),{blocks:h}=Fa(l),{data:f}=zt(),{data:m}=Se(),{mutateAsync:C}=kn(),x=Oa(),{getUILibraryBlock:S,getUILibraryBlocks:w,onSave:j}=Wa(),{getPartialBlocks:P,getPartialBlockBlocks:V}=Ka(),{aiContext:N,setAiContext:p}=gs(),{mutateAsync:E}=$a(),[ee,A]=v.useState(!1),q=v.useMemo(()=>(f==null?void 0:f.fallbackLang)||"en",[f]),{data:M}=Tn({pageType:i==null?void 0:i.pageType,lang:a||q});v.useEffect(()=>{const b=()=>{document.hidden?A(!0):A(!1)};return window.addEventListener("visibilitychange",b),()=>window.removeEventListener("visibilitychange",b)},[]),t.current=h;const W=v.useMemo(()=>{const b={};return e.mediaManagerComponent&&(b.mediaManagerComponent=e.mediaManagerComponent),b},[e.mediaManagerComponent]),K=v.useMemo(()=>Array.isArray(e==null?void 0:e.uiLibraries)?[...o,...e==null?void 0:e.uiLibraries]:o,[o,e==null?void 0:e.uiLibraries]),re=v.useCallback(async(b,te)=>await E({pageType:b,query:te}),[E]),R=v.useMemo(()=>g.get(f,"theme",{})||{},[f]),de=v.useMemo(()=>m==null?void 0:m.find(b=>b.key===(i==null?void 0:i.pageType)),[m,i==null?void 0:i.pageType]);return r.jsxs(r.Fragment,{children:[c&&r.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center w-screen h-screen bg-white/30",children:r.jsx("div",{className:"flex items-center justify-center bg-white rounded-full size-10",children:r.jsx(I.Loader2,{className:"size-5 animate-spin"})})}),r.jsx(ve.ChaiBuilderEditor,{pageExternalData:M,themePresets:e.themePresets??[],pageId:i==null?void 0:i.id,addBlocksDialogTabs:e.addBlocksDialogTabs||[],loading:c,fallbackLang:q,languages:(f==null?void 0:f.languages)||[],brandingOptions:(f==null?void 0:f.theme)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSaveSupport:!ee&&(e.autoSaveSupport??!0),autoSaveInterval:e.autoSaveInterval??15,onError:e.onError||console.error,getPartialBlockBlocks:V,getPartialBlocks:P,blocks:c?[]:h,theme:g.cloneDeep(R),getUILibraryBlock:S,getUILibraryBlocks:w,uiLibraries:K,pageTypes:m,searchPageTypeItems:re,saveAiContextCallback:async b=>{if(!n)return!0;const te=t.current,Ee={_type:"@chai/ai-context",_value:g.isString(b)?b:""},ge=[...te,Ee];return await j({page:n,blocks:ge}),p(b),!0},aiContext:N,askAiCallBack:x,onSave:async({blocks:b,theme:te})=>{if(!n)return!0;t.current=b;const Ee={_type:"@chai/ai-context",_value:g.isString(N)?N:""},ge=[...b,Ee];return await j({page:n,blocks:ge}),t.current=ge,g.isEqual(te,R)||await C({settings:{theme:te}}),!0},topBarComponents:{left:[gi],right:[Ai]},sideBarComponents:{top:[...de!=null&&de.hasSlug?[{label:"SEO Setting",component:Gn,icon:r.jsx(r.Fragment,{children:r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 21 21",fill:"currentColor",width:"21",height:"21",children:[r.jsx("path",{d:"M9.931 6.818c-1.238 0-2.136.925-2.136 2.2 0 1.279.898 2.207 2.136 2.207.664 0 1.257-.246 1.67-.694a.15.15 0 0 0-.009-.213l-.311-.286a.15.15 0 0 0-.213.009c-.273.297-.677.46-1.137.46-.699 0-1.233-.444-1.375-1.12h3.295a.15.15 0 0 0 .151-.151v-.211c0-1.295-.852-2.2-2.072-2.2m0 .724c.697 0 1.188.422 1.315 1.113h-2.69c.142-.673.676-1.113 1.374-1.113m4.332-.724c-1.246 0-2.15.925-2.15 2.2 0 1.279.904 2.207 2.15 2.207.596 0 1.143-.223 1.538-.628s.612-.965.612-1.579c0-1.275-.904-2.2-2.15-2.2m0 3.683c-.826 0-1.426-.624-1.426-1.483 0-.855.6-1.475 1.426-1.475s1.426.621 1.426 1.476c0 .423-.144.804-.406 1.073-.258.264-.62.41-1.019.41M6.318 8.71c-.665-.206-.902-.335-.902-.645 0-.47.564-.521.806-.521.29 0 .552.07.801.215a.15.15 0 0 0 .206-.055l.212-.366a.15.15 0 0 0-.055-.206 2.27 2.27 0 0 0-1.165-.312c-.915 0-1.53.501-1.53 1.245 0 .899.816 1.152 1.411 1.336.655.203.812.307.804.53-.016.398-.567.429-.735.429-.386 0-.722-.129-.972-.374q-.043-.042-.107-.043a.15.15 0 0 0-.106.045l-.295.302a.15.15 0 0 0 .002.213c.383.374.908.58 1.478.58.859 0 1.432-.441 1.459-1.125.031-.833-.746-1.074-1.313-1.249"}),r.jsx("path",{d:"M20.396 2.049H.604A.604.604 0 0 0 0 2.653v12.7c0 .333.27.604.604.604h6.941c-.266 1.296-.881 1.966-.886 1.971a.604.604 0 0 0 .434 1.024h6.815a.604.604 0 0 0 .434-1.024c-.007-.007-.621-.675-.886-1.971h6.941c.333 0 .604-.27.604-.604V2.652a.604.604 0 0 0-.604-.604m-.604 12.701h-.985v-.17a.604.604 0 0 0-1.208 0v.17h-.63v-.17a.604.604 0 0 0-1.208 0v.17H1.207V3.256h18.585z"})]})})}]:[],...g.isEmpty(f==null?void 0:f.languages)?[]:[{label:`Language ${de!=null&&de.hasSlug?"":"page"}`,component:Ja,icon:r.jsx(I.Languages,{className:"w-5 h-5 stroke-[2]"})}]],bottom:[...e!=null&&e.sidebarBottomComponents?[...e.sidebarBottomComponents]:[],ti,si]},themePanelComponent:li,...W})]})},Pi=new F.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1}}}),ki=e=>{const[,t]=Nn(),[s,n]=v.useState(!1);return v.useEffect(()=>(t(g.pick(e,["apiUrl","getPreviewUrl","logo","settingComponent","user","onSessionExpired","pageLockComponent"])),setTimeout(()=>{n(!0)},200),()=>{n(!1),t({})}),[e,t]),s?r.jsxs(F.QueryClientProvider,{client:Pi,children:[r.jsx(Ti,{...e}),r.jsx(Ma,{})]}):r.jsx("div",{})};exports.$TRACK=us;exports.ChaiBuilderPages=ki;exports.Dynamic=qr;exports.For=gr;exports.Index=yr;exports.Match=vr;exports.Portal=Fr;exports.Show=xr;exports.Switch=pr;exports.addEventListener=tn;exports.batch=Xn;exports.className=en;exports.clearDelegatedEvents=Ir;exports.convertRemToPixels=ka;exports.createComponent=fs;exports.createComputed=qs;exports.createContext=nr;exports.createEffect=ds;exports.createMemo=xe;exports.createRenderEffect=Me;exports.createRoot=Ge;exports.createSignal=le;exports.createUniqueId=mr;exports.delegateEvents=Js;exports.deleteNestedDataByPath=ut;exports.displayValue=ja;exports.getMutationStatusColor=Ea;exports.getPreferredColorScheme=Ia;exports.getQueryStatusColor=wa;exports.getQueryStatusColorByLabel=ba;exports.getQueryStatusLabel=va;exports.getSidedProp=Sa;exports.insert=Ft;exports.mergeProps=ms;exports.mutationSortFns=Pa;exports.on=Zn;exports.onCleanup=at;exports.onMount=Hs;exports.serialize=wn;exports.setAttribute=Rt;exports.sortFns=Aa;exports.splitProps=Qs;exports.spread=sn;exports.stringify=pa;exports.template=kr;exports.untrack=fe;exports.updateNestedDataByPath=ct;exports.use=nn;exports.useContext=rr;exports.useTransition=sr;