@chaibuilder/pages 0.1.19 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{B4MFY5CR-C_Pspicf.js → B4MFY5CR-Pz25m1RK.js} +1 -1
- package/dist/{B4MFY5CR-C5YWEgl9.cjs → B4MFY5CR-hFfovK0_.cjs} +1 -1
- package/dist/{HO4MOOFI-DY2QBu0y.cjs → HO4MOOFI-COdfBQo3.cjs} +1 -1
- package/dist/{HO4MOOFI-Do83nKZJ.js → HO4MOOFI-Cb3CTzDI.js} +2 -2
- package/dist/{HUY7CZI3-BL3e6hkF.cjs → HUY7CZI3-D4BY19cM.cjs} +1 -1
- package/dist/{HUY7CZI3-DGYGXLtV.js → HUY7CZI3-w0XnbOPP.js} +2 -2
- package/dist/index-DSDSpN_B.js +4844 -0
- package/dist/index-DhqrZyDj.cjs +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +21 -53
- package/dist/index.js +14 -7
- package/dist/server.cjs +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +76 -110
- package/package.json +3 -3
- package/dist/index-B8chLUn1.cjs +0 -2
- package/dist/index-filc7Z1g.js +0 -6711
package/dist/index-B8chLUn1.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var Ls=e=>{throw TypeError(e)};var Ds=(e,t,s)=>t.has(e)||Ls("Cannot "+s);var B=(e,t,s)=>(Ds(e,t,"read from private field"),s?s.call(e):t.get(e)),te=(e,t,s)=>t.has(e)?Ls("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),J=(e,t,s,r)=>(Ds(e,t,"write to private field"),r?r.call(e,s):t.set(e,s),s);const n=require("react/jsx-runtime"),ce=require("@chaibuilder/sdk"),tr=require("@chaibuilder/sdk/web-blocks"),U=require("@tanstack/react-query"),v=require("react"),g=require("lodash-es"),I=require("lucide-react"),ut=require("jotai"),ie=require("sonner"),Ks=require("@chaibuilder/runtime"),c=require("@chaibuilder/sdk/ui"),Gt=require("date-fns");function sr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const oe=sr(v);var F={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return ks(this.context.count)},getNextContextId(){return ks(this.context.count++)}};function ks(e){const t=String(e),s=t.length-1;return F.context.id+(s?String.fromCharCode(96+s):"")+t}function gt(e){F.context=e}var nr=(e,t)=>e===t,Ht=Symbol("solid-proxy"),Ws=typeof Proxy=="function",ps=Symbol("solid-track"),qt={equals:nr},zs=tn,Me=1,Vt=2,Qs={owned:null,cleanups:null,context:null,owner:null},ts={},X=null,ss=null,rr=null,se=null,pe=null,Ge=null,Xt=0;function Oe(e,t){const s=se,r=X,a=e.length===0,i=t===void 0?r:t,o=a?Qs:{owned:null,cleanups:null,context:i?i.context:null,owner:i},l=a?e:()=>e(()=>fe(()=>vt(o)));X=o,se=null;try{return _e(l,!0)}finally{se=s,X=r}}function he(e,t){t=t?Object.assign({},qt,t):qt;const s={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},r=a=>(typeof a=="function"&&(a=a(s.value)),en(s,a));return[Js.bind(s),r]}function Ys(e,t,s){const r=Zt(e,t,!0,Me);dt(r)}function Ue(e,t,s){const r=Zt(e,t,!1,Me);dt(r)}function ys(e,t,s){zs=yr;const r=Zt(e,t,!1,Me);(!s||!s.render)&&(r.user=!0),Ge?Ge.push(r):dt(r)}function Ee(e,t,s){s=s?Object.assign({},qt,s):qt;const r=Zt(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=s.equals||void 0,dt(r),Js.bind(r)}function ar(e){return e&&typeof e=="object"&&"then"in e}function ir(e,t,s){let r,a,i;arguments.length===1?(r=!0,a=e,i={}):(r=e,a=t,i={});let o=null,l=ts,u=null,d=!1,f="initialValue"in i,m=typeof r=="function"&&Ee(r);const w=new Set,[E,p]=(i.storage||he)(i.initialValue),[j,b]=he(void 0),[D,A]=he(void 0,{equals:!1}),[T,S]=he(f?"ready":"unresolved");F.context&&(u=F.getNextContextId(),i.ssrLoadFrom==="initial"?l=i.initialValue:F.load&&F.has(u)&&(l=F.load(u)));function P(N,G,V,Y){return o===N&&(o=null,Y!==void 0&&(f=!0),(N===l||G===l)&&i.onHydrated&&queueMicrotask(()=>i.onHydrated(Y,{value:G})),l=ts,H(G,V)),G}function H(N,G){_e(()=>{G===void 0&&p(()=>N),S(G!==void 0?"errored":f?"ready":"unresolved"),b(G);for(const V of w.keys())V.decrement();w.clear()},!1)}function C(){const N=gr,G=E(),V=j();if(V!==void 0&&!o)throw V;return se&&se.user,G}function k(N=!0){if(N!==!1&&d)return;d=!1;const G=m?m():r;if(G==null||G===!1){P(o,fe(E));return}const V=l!==ts?l:fe(()=>a(G,{value:E(),refetching:N}));return ar(V)?(o=V,"value"in V?(V.status==="success"?P(o,V.value,void 0,G):P(o,void 0,is(V.value),G),V):(d=!0,queueMicrotask(()=>d=!1),_e(()=>{S(f?"refreshing":"pending"),A()},!1),V.then(Y=>P(V,Y,void 0,G),Y=>P(V,void 0,is(Y),G)))):(P(o,V,void 0,G),V)}return Object.defineProperties(C,{state:{get:()=>T()},error:{get:()=>j()},loading:{get(){const N=T();return N==="pending"||N==="refreshing"}},latest:{get(){if(!f)return C();const N=j();if(N&&!o)throw N;return E()}}}),m?Ys(()=>k(!1)):k(!1),[C,{refetch:k,mutate:p}]}function or(e){return _e(e,!1)}function fe(e){if(se===null)return e();const t=se;se=null;try{return e()}finally{se=t}}function lr(e,t,s){const r=Array.isArray(e);let a,i=s&&s.defer;return o=>{let l;if(r){l=Array(e.length);for(let d=0;d<e.length;d++)l[d]=e[d]()}else l=e();if(i)return i=!1,o;const u=fe(()=>t(l,a,o));return a=l,u}}function Xs(e){ys(()=>fe(e))}function lt(e){return X===null||(X.cleanups===null?X.cleanups=[e]:X.cleanups.push(e)),e}function Gs(){return X}function cr(e,t){const s=X,r=se;X=e,se=null;try{return _e(t,!0)}catch(a){Es(a)}finally{X=s,se=r}}function ur(e){const t=se,s=X;return Promise.resolve().then(()=>{se=t,X=s;let r;return _e(e,!1),se=X=null,r?r.done:void 0})}var[dr,ho]=he(!1);function hr(){return[dr,ur]}function fr(e,t){const s=Symbol("context");return{id:s,Provider:Er(s),defaultValue:e}}function mr(e){let t;return X&&X.context&&(t=X.context[e.id])!==void 0?t:e.defaultValue}function Zs(e){const t=Ee(e),s=Ee(()=>os(t()));return s.toArray=()=>{const r=s();return Array.isArray(r)?r:r!=null?[r]:[]},s}var gr;function Js(){if(this.sources&&this.state)if(this.state===Me)dt(this);else{const e=pe;pe=null,_e(()=>Kt(this),!1),pe=e}if(se){const e=this.observers?this.observers.length:0;se.sources?(se.sources.push(this),se.sourceSlots.push(e)):(se.sources=[this],se.sourceSlots=[e]),this.observers?(this.observers.push(se),this.observerSlots.push(se.sources.length-1)):(this.observers=[se],this.observerSlots=[se.sources.length-1])}return this.value}function en(e,t,s){let r=e.value;return(!e.comparator||!e.comparator(r,t))&&(e.value=t,e.observers&&e.observers.length&&_e(()=>{for(let a=0;a<e.observers.length;a+=1){const i=e.observers[a],o=ss&&ss.running;o&&ss.disposed.has(i),(o?!i.tState:!i.state)&&(i.pure?pe.push(i):Ge.push(i),i.observers&&sn(i)),o||(i.state=Me)}if(pe.length>1e6)throw pe=[],new Error},!1)),t}function dt(e){if(!e.fn)return;vt(e);const t=Xt;xr(e,e.value,t)}function xr(e,t,s){let r;const a=X,i=se;se=X=e;try{r=e.fn(t)}catch(o){return e.pure&&(e.state=Me,e.owned&&e.owned.forEach(vt),e.owned=null),e.updatedAt=s+1,Es(o)}finally{se=i,X=a}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?en(e,r):e.value=r,e.updatedAt=s)}function Zt(e,t,s,r=Me,a){const i={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:X,context:X?X.context:null,pure:s};return X===null||X!==Qs&&(X.owned?X.owned.push(i):X.owned=[i]),i}function $t(e){if(e.state===0)return;if(e.state===Vt)return Kt(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<Xt);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===Me)dt(e);else if(e.state===Vt){const r=pe;pe=null,_e(()=>Kt(e,t[0]),!1),pe=r}}function _e(e,t){if(pe)return e();let s=!1;t||(pe=[]),Ge?s=!0:Ge=[],Xt++;try{const r=e();return pr(s),r}catch(r){s||(Ge=null),pe=null,Es(r)}}function pr(e){if(pe&&(tn(pe),pe=null),e)return;const t=Ge;Ge=null,t.length&&_e(()=>zs(t),!1)}function tn(e){for(let t=0;t<e.length;t++)$t(e[t])}function yr(e){let t,s=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[s++]=r:$t(r)}if(F.context){if(F.count){F.effects||(F.effects=[]),F.effects.push(...e.slice(0,s));return}gt()}for(F.effects&&(F.done||!F.count)&&(e=[...F.effects,...e],s+=F.effects.length,delete F.effects),t=0;t<s;t++)$t(e[t])}function Kt(e,t){e.state=0;for(let s=0;s<e.sources.length;s+=1){const r=e.sources[s];if(r.sources){const a=r.state;a===Me?r!==t&&(!r.updatedAt||r.updatedAt<Xt)&&$t(r):a===Vt&&Kt(r,t)}}}function sn(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=Vt,s.pure?pe.push(s):Ge.push(s),s.observers&&sn(s))}}function vt(e){let t;if(e.sources)for(;e.sources.length;){const s=e.sources.pop(),r=e.sourceSlots.pop(),a=s.observers;if(a&&a.length){const i=a.pop(),o=s.observerSlots.pop();r<a.length&&(i.sourceSlots[o]=r,a[r]=i,s.observerSlots[r]=o)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)vt(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)vt(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 is(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function Es(e,t=X){throw is(e)}function os(e){if(typeof e=="function"&&!e.length)return os(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const r=os(e[s]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function Er(e,t){return function(r){let a;return Ue(()=>a=fe(()=>(X.context={...X.context,[e]:r.value},Zs(()=>r.children))),void 0),a}}var ls=Symbol("fallback");function Wt(e){for(let t=0;t<e.length;t++)e[t]()}function vr(e,t,s={}){let r=[],a=[],i=[],o=0,l=t.length>1?[]:null;return lt(()=>Wt(i)),()=>{let u=e()||[],d=u.length,f,m;return u[ps],fe(()=>{let E,p,j,b,D,A,T,S,P;if(d===0)o!==0&&(Wt(i),i=[],r=[],a=[],o=0,l&&(l=[])),s.fallback&&(r=[ls],a[0]=Oe(H=>(i[0]=H,s.fallback())),o=1);else if(o===0){for(a=new Array(d),m=0;m<d;m++)r[m]=u[m],a[m]=Oe(w);o=d}else{for(j=new Array(d),b=new Array(d),l&&(D=new Array(d)),A=0,T=Math.min(o,d);A<T&&r[A]===u[A];A++);for(T=o-1,S=d-1;T>=A&&S>=A&&r[T]===u[S];T--,S--)j[S]=a[T],b[S]=i[T],l&&(D[S]=l[T]);for(E=new Map,p=new Array(S+1),m=S;m>=A;m--)P=u[m],f=E.get(P),p[m]=f===void 0?-1:f,E.set(P,m);for(f=A;f<=T;f++)P=r[f],m=E.get(P),m!==void 0&&m!==-1?(j[m]=a[f],b[m]=i[f],l&&(D[m]=l[f]),m=p[m],E.set(P,m)):i[f]();for(m=A;m<d;m++)m in j?(a[m]=j[m],i[m]=b[m],l&&(l[m]=D[m],l[m](m))):a[m]=Oe(w);a=a.slice(0,o=d),r=u.slice(0)}return a});function w(E){if(i[m]=E,l){const[p,j]=he(m);return l[m]=j,t(u[m],p)}return t(u[m])}}}function Sr(e,t,s={}){let r=[],a=[],i=[],o=[],l=0,u;return lt(()=>Wt(i)),()=>{const d=e()||[],f=d.length;return d[ps],fe(()=>{if(f===0)return l!==0&&(Wt(i),i=[],r=[],a=[],l=0,o=[]),s.fallback&&(r=[ls],a[0]=Oe(w=>(i[0]=w,s.fallback())),l=1),a;for(r[0]===ls&&(i[0](),i=[],r=[],a=[],l=0),u=0;u<f;u++)u<r.length&&r[u]!==d[u]?o[u](()=>d[u]):u>=r.length&&(a[u]=Oe(m));for(;u<r.length;u++)i[u]();return l=o.length=i.length=f,r=d.slice(0),a=a.slice(0,l)});function m(w){i[u]=w;const[E,p]=he(d[u]);return o[u]=p,t(E,u)}}}function vs(e,t){return fe(()=>e(t||{}))}function Ut(){return!0}var cs={get(e,t,s){return t===Ht?s:e.get(t)},has(e,t){return t===Ht?!0:e.has(t)},set:Ut,deleteProperty:Ut,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:Ut,deleteProperty:Ut}},ownKeys(e){return e.keys()}};function ns(e){return(e=typeof e=="function"?e():e)?e:{}}function br(){for(let e=0,t=this.length;e<t;++e){const s=this[e]();if(s!==void 0)return s}}function Ss(...e){let t=!1;for(let o=0;o<e.length;o++){const l=e[o];t=t||!!l&&Ht in l,e[o]=typeof l=="function"?(t=!0,Ee(l)):l}if(Ws&&t)return new Proxy({get(o){for(let l=e.length-1;l>=0;l--){const u=ns(e[l])[o];if(u!==void 0)return u}},has(o){for(let l=e.length-1;l>=0;l--)if(o in ns(e[l]))return!0;return!1},keys(){const o=[];for(let l=0;l<e.length;l++)o.push(...Object.keys(ns(e[l])));return[...new Set(o)]}},cs);const s={},r=Object.create(null);for(let o=e.length-1;o>=0;o--){const l=e[o];if(!l)continue;const u=Object.getOwnPropertyNames(l);for(let d=u.length-1;d>=0;d--){const f=u[d];if(f==="__proto__"||f==="constructor")continue;const m=Object.getOwnPropertyDescriptor(l,f);if(!r[f])r[f]=m.get?{enumerable:!0,configurable:!0,get:br.bind(s[f]=[m.get.bind(l)])}:m.value!==void 0?m:void 0;else{const w=s[f];w&&(m.get?w.push(m.get.bind(l)):m.value!==void 0&&w.push(()=>m.value))}}}const a={},i=Object.keys(r);for(let o=i.length-1;o>=0;o--){const l=i[o],u=r[l];u&&u.get?Object.defineProperty(a,l,u):a[l]=u?u.value:void 0}return a}function nn(e,...t){if(Ws&&Ht 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)}},cs));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))}},cs)),i}const s={},r=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,u=0;for(const d of t)d.includes(a)&&(l=!0,o?r[u][a]=i.value:Object.defineProperty(r[u],a,i)),++u;l||(o?s[a]=i.value:Object.defineProperty(s,a,i))}return[...r,s]}function rn(e){let t,s;const r=a=>{const i=F.context;if(i){const[l,u]=he();F.count||(F.count=0),F.count++,(s||(s=e())).then(d=>{!F.done&>(i),F.count--,u(()=>d.default),gt()}),t=l}else if(!t){const[l]=ir(()=>(s||(s=e())).then(u=>u.default));t=l}let o;return Ee(()=>(o=t())?fe(()=>{if(!i||F.done)return o(a);const l=F.context;gt(i);const u=o(a);return gt(l),u}):"")};return r.preload=()=>s||((s=e()).then(a=>t=()=>a.default),s),r}var wr=0;function jr(){return F.context?F.getNextContextId():`cl-${wr++}`}var an=e=>`Stale read from <${e}>.`;function Nr(e){const t="fallback"in e&&{fallback:()=>e.fallback};return Ee(vr(()=>e.each,e.children,t||void 0))}function Ar(e){const t="fallback"in e&&{fallback:()=>e.fallback};return Ee(Sr(()=>e.each,e.children,t||void 0))}function Tr(e){const t=e.keyed,s=Ee(()=>e.when,void 0,{equals:(r,a)=>t?r===a:!r==!a});return Ee(()=>{const r=s();if(r){const a=e.children;return typeof a=="function"&&a.length>0?fe(()=>a(t?r:()=>{if(!fe(s))throw an("Show");return e.when})):a}return e.fallback},void 0,void 0)}function Cr(e){let t=!1;const s=(i,o)=>(t?i[1]===o[1]:!i[1]==!o[1])&&i[2]===o[2],r=Zs(()=>e.children),a=Ee(()=>{let i=r();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 Ee(()=>{const[i,o,l]=a();if(i<0)return e.fallback;const u=l.children;return typeof u=="function"&&u.length>0?fe(()=>u(t?o:()=>{if(fe(a)[0]!==i)throw an("Match");return l.when})):u},void 0,void 0)}function Pr(e){return e}var Ir=["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"],_r=new Set(["className","value","readOnly","formNoValidate","isMap","noModule","playsInline",...Ir]),Lr=new Set(["innerHTML","textContent","innerText","children"]),Dr=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),kr=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 Gr(e,t){const s=kr[e];return typeof s=="object"?s[t]?s.$:void 0:s}var Mr=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),Or=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"]),Ur={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"};function Rr(e,t,s){let r=s.length,a=t.length,i=r,o=0,l=0,u=t[a-1].nextSibling,d=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<r?l?s[l-1].nextSibling:s[i-l]:u;for(;l<i;)e.insertBefore(s[l++],f)}else if(i===l)for(;o<a;)(!d||!d.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(!d){d=new Map;let m=l;for(;m<i;)d.set(s[m],m++)}const f=d.get(t[o]);if(f!=null)if(l<f&&f<i){let m=o,w=1,E;for(;++m<a&&m<i&&!((E=d.get(t[m]))==null||E!==f+w);)w++;if(w>f-l){const p=t[o];for(;l<f;)e.insertBefore(s[l++],p)}else e.replaceChild(s[l++],t[o++])}else o++;else t[o++].remove()}}}var yt="_$DX_DELEGATE";function on(e,t,s,r={}){let a;return Oe(i=>{a=i,t===document?e():Qt(t,e(),t.firstChild?null:void 0,s)},r.owner),()=>{a(),t.textContent=""}}function Br(e,t,s){let r;const a=()=>{const o=document.createElement("template");return o.innerHTML=e,o.content.firstChild},i=()=>(r||(r=a())).cloneNode(!0);return i.cloneNode=i,i}function ln(e,t=window.document){const s=t[yt]||(t[yt]=new Set);for(let r=0,a=e.length;r<a;r++){const i=e[r];s.has(i)||(s.add(i),t.addEventListener(i,fn))}}function Fr(e=window.document){if(e[yt]){for(let t of e[yt].keys())e.removeEventListener(t,fn);delete e[yt]}}function zt(e,t,s){Ve(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function Hr(e,t,s,r){Ve(e)||(r==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,r))}function qr(e,t,s){Ve(e)||(s?e.setAttribute(t,""):e.removeAttribute(t))}function cn(e,t){Ve(e)||(t==null?e.removeAttribute("class"):e.className=t)}function un(e,t,s,r){if(r)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 Vr(e,t,s={}){const r=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]||(Ms(e,l,!1),delete s[l])}for(i=0,o=r.length;i<o;i++){const l=r[i],u=!!t[l];!l||l==="undefined"||s[l]===u||!u||(Ms(e,l,!0),s[l]=u)}return s}function $r(e,t,s){if(!t)return s?zt(e,"style"):t;const r=e.style;if(typeof t=="string")return r.cssText=t;typeof s=="string"&&(r.cssText=s=void 0),s||(s={}),t||(t={});let a,i;for(i in s)t[i]==null&&r.removeProperty(i),delete s[i];for(i in t)a=t[i],a!==s[i]&&(r.setProperty(i,a),s[i]=a);return s}function dn(e,t={},s,r){const a={};return r||Ue(()=>a.children=St(e,t.children,a.children)),Ue(()=>typeof t.ref=="function"&&hn(t.ref,e)),Ue(()=>Kr(e,t,s,!0,a,!0)),a}function hn(e,t,s){return fe(()=>e(t,s))}function Qt(e,t,s,r){if(s!==void 0&&!r&&(r=[]),typeof t!="function")return St(e,t,r,s);Ue(a=>St(e,t(),a,s),r)}function Kr(e,t,s,r,a={},i=!1){t||(t={});for(const o in a)if(!(o in t)){if(o==="children")continue;a[o]=Os(e,o,null,a[o],s,i,t)}for(const o in t){if(o==="children")continue;const l=t[o];a[o]=Os(e,o,l,a[o],s,i,t)}}function Wr(e){let t,s;return!Ve()||!(t=F.registry.get(s=Qr()))?e():(F.completed&&F.completed.add(t),F.registry.delete(s),t)}function Ve(e){return!!F.context&&!F.done&&(!e||e.isConnected)}function zr(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function Ms(e,t,s){const r=t.trim().split(/\s+/);for(let a=0,i=r.length;a<i;a++)e.classList.toggle(r[a],s)}function Os(e,t,s,r,a,i,o){let l,u,d,f,m;if(t==="style")return $r(e,s,r);if(t==="classList")return Vr(e,s,r);if(s===r)return r;if(t==="ref")i||s(e);else if(t.slice(0,3)==="on:"){const w=t.slice(3);r&&e.removeEventListener(w,r,typeof r!="function"&&r),s&&e.addEventListener(w,s,typeof s!="function"&&s)}else if(t.slice(0,10)==="oncapture:"){const w=t.slice(10);r&&e.removeEventListener(w,r,!0),s&&e.addEventListener(w,s,!0)}else if(t.slice(0,2)==="on"){const w=t.slice(2).toLowerCase(),E=Mr.has(w);if(!E&&r){const p=Array.isArray(r)?r[0]:r;e.removeEventListener(w,p)}(E||s)&&(un(e,w,s,E),E&&ln([w]))}else if(t.slice(0,5)==="attr:")zt(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")qr(e,t.slice(5),s);else if((m=t.slice(0,5)==="prop:")||(d=Lr.has(t))||!a&&((f=Gr(t,e.tagName))||(u=_r.has(t)))||(l=e.nodeName.includes("-")||"is"in o)){if(m)t=t.slice(5),u=!0;else if(Ve(e))return s;t==="class"||t==="className"?cn(e,s):l&&!u&&!d?e[zr(t)]=s:e[f||t]=s}else{const w=a&&t.indexOf(":")>-1&&Ur[t.split(":")[0]];w?Hr(e,w,t,s):zt(e,Dr[t]||t,s)}return s}function fn(e){if(F.registry&&F.events&&F.events.find(([u,d])=>d===e))return;let t=e.target;const s=`$$${e.type}`,r=e.target,a=e.currentTarget,i=u=>Object.defineProperty(e,"target",{configurable:!0,value:u}),o=()=>{const u=t[s];if(u&&!t.disabled){const d=t[`${s}Data`];if(d!==void 0?u.call(t,d,e):u.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}}),F.registry&&!F.done&&(F.done=_$HY.done=!0),e.composedPath){const u=e.composedPath();i(u[0]);for(let d=0;d<u.length-2&&(t=u[d],!!o());d++){if(t._$host){t=t._$host,l();break}if(t.parentNode===a)break}}else l();i(r)}function St(e,t,s,r,a){const i=Ve(e);if(i){!s&&(s=[...e.childNodes]);let u=[];for(let d=0;d<s.length;d++){const f=s[d];f.nodeType===8&&f.data.slice(0,2)==="!$"?f.remove():u.push(f)}s=u}for(;typeof s=="function";)s=s();if(t===s)return s;const o=typeof t,l=r!==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 u=s[0];u&&u.nodeType===3?u.data!==t&&(u.data=t):u=document.createTextNode(t),s=$e(e,s,r,u)}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=$e(e,s,r)}else{if(o==="function")return Ue(()=>{let u=t();for(;typeof u=="function";)u=u();s=St(e,u,s,r)}),()=>s;if(Array.isArray(t)){const u=[],d=s&&Array.isArray(s);if(us(u,t,s,a))return Ue(()=>s=St(e,u,s,r,!0)),()=>s;if(i){if(!u.length)return s;if(r===void 0)return s=[...e.childNodes];let f=u[0];if(f.parentNode!==e)return s;const m=[f];for(;(f=f.nextSibling)!==r;)m.push(f);return s=m}if(u.length===0){if(s=$e(e,s,r),l)return s}else d?s.length===0?Us(e,u,r):Rr(e,s,u):(s&&$e(e),Us(e,u));s=u}else if(t.nodeType){if(i&&t.parentNode)return s=l?[t]:t;if(Array.isArray(s)){if(l)return s=$e(e,s,r,t);$e(e,s,null,t)}else s==null||s===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);s=t}}return s}function us(e,t,s,r){let a=!1;for(let i=0,o=t.length;i<o;i++){let l=t[i],u=s&&s[e.length],d;if(!(l==null||l===!0||l===!1))if((d=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))a=us(e,l,u)||a;else if(d==="function")if(r){for(;typeof l=="function";)l=l();a=us(e,Array.isArray(l)?l:[l],Array.isArray(u)?u:[u])||a}else e.push(l),a=!0;else{const f=String(l);u&&u.nodeType===3&&u.data===f?e.push(u):e.push(document.createTextNode(f))}}return a}function Us(e,t,s=null){for(let r=0,a=t.length;r<a;r++)e.insertBefore(t[r],s)}function $e(e,t,s,r){if(s===void 0)return e.textContent="";const a=r||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 u=l.parentNode===e;!i&&!o?u?e.replaceChild(a,l):e.insertBefore(a,s):u&&l.remove()}else i=!0}}else e.insertBefore(a,s);return[a]}function Qr(){return F.getNextContextId()}var Yr="http://www.w3.org/2000/svg";function mn(e,t=!1){return t?document.createElementNS(Yr,e):document.createElement(e)}function Xr(e){const{useShadow:t}=e,s=document.createTextNode(""),r=()=>e.mount||document.body,a=Gs();let i,o=!!F.context;return ys(()=>{o&&(Gs().user=o=!1),i||(i=cr(a,()=>Ee(()=>e.children)));const l=r();if(l instanceof HTMLHeadElement){const[u,d]=he(!1),f=()=>d(!0);Oe(m=>Qt(l,()=>u()?m():i(),null)),lt(f)}else{const u=mn(e.isSVG?"g":"div",e.isSVG),d=t&&u.attachShadow?u.attachShadow({mode:"open"}):u;Object.defineProperty(u,"_$host",{get(){return s.parentNode},configurable:!0}),Qt(d,i),l.appendChild(u),e.ref&&e.ref(u),lt(()=>l.removeChild(u))}},void 0,{render:!o}),s}function Zr(e){const[t,s]=nn(e,["component"]),r=Ee(()=>t.component);return Ee(()=>{const a=r();switch(typeof a){case"function":return fe(()=>a(s));case"string":const i=Or.has(a),o=F.context?Wr():mn(a,i);return dn(o,s,i),o}})}var Jr=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()}},gn=class{constructor(e){this.generateIdentifier=e,this.kv=new Jr}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)}},ea=class extends gn{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 ta(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 sa(e,t){const s=ta(e);if("find"in s)return s.find(t);const r=s;for(let a=0;a<r.length;a++){const i=r[a];if(t(i))return i}}function ct(e,t){Object.entries(e).forEach(([s,r])=>t(r,s))}function Ft(e,t){return e.indexOf(t)!==-1}function Rs(e,t){for(let s=0;s<e.length;s++){const r=e[s];if(t(r))return r}}var na=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return sa(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},ra=e=>Object.prototype.toString.call(e).slice(8,-1),xn=e=>typeof e>"u",aa=e=>e===null,bt=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,ds=e=>bt(e)&&Object.keys(e).length===0,Re=e=>Array.isArray(e),ia=e=>typeof e=="string",oa=e=>typeof e=="number"&&!isNaN(e),la=e=>typeof e=="boolean",ca=e=>e instanceof RegExp,wt=e=>e instanceof Map,jt=e=>e instanceof Set,pn=e=>ra(e)==="Symbol",ua=e=>e instanceof Date&&!isNaN(e.valueOf()),da=e=>e instanceof Error,Bs=e=>typeof e=="number"&&isNaN(e),ha=e=>la(e)||aa(e)||xn(e)||oa(e)||ia(e)||pn(e),fa=e=>typeof e=="bigint",ma=e=>e===1/0||e===-1/0,ga=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),xa=e=>e instanceof URL,yn=e=>e.replace(/\./g,"\\."),rs=e=>e.map(String).map(yn).join("."),Et=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 r=s;return t.push(r),t};function Ie(e,t,s,r){return{isApplicable:e,annotation:t,transform:s,untransform:r}}var En=[Ie(xn,"undefined",()=>null,()=>{}),Ie(fa,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),Ie(ua,"Date",e=>e.toISOString(),e=>new Date(e)),Ie(da,"Error",(e,t)=>{const s={name:e.name,message:e.message};return t.allowedErrorProps.forEach(r=>{s[r]=e[r]}),s},(e,t)=>{const s=new Error(e.message);return s.name=e.name,s.stack=e.stack,t.allowedErrorProps.forEach(r=>{s[r]=e[r]}),s}),Ie(ca,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),Ie(jt,"set",e=>[...e.values()],e=>new Set(e)),Ie(wt,"map",e=>[...e.entries()],e=>new Map(e)),Ie(e=>Bs(e)||ma(e),"number",e=>Bs(e)?"NaN":e>0?"Infinity":"-Infinity",Number),Ie(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),Ie(xa,"URL",e=>e.toString(),e=>new URL(e))];function Jt(e,t,s,r){return{isApplicable:e,annotation:t,transform:s,untransform:r}}var vn=Jt((e,t)=>pn(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,s)=>{const r=s.symbolRegistry.getValue(t[1]);if(!r)throw new Error("Trying to deserialize unknown symbol");return r}),pa=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),Sn=Jt(ga,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=pa[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function bn(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var wn=Jt(bn,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const s=t.classRegistry.getAllowedProps(e.constructor);if(!s)return{...e};const r={};return s.forEach(a=>{r[a]=e[a]}),r},(e,t,s)=>{const r=s.classRegistry.getValue(t[1]);if(!r)throw new Error("Trying to deserialize unknown class - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564");return Object.assign(Object.create(r.prototype),e)}),jn=Jt((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 r=s.customTransformerRegistry.findByName(t[1]);if(!r)throw new Error("Trying to deserialize unknown custom value");return r.deserialize(e)}),ya=[wn,vn,jn,Sn],Fs=(e,t)=>{const s=Rs(ya,a=>a.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const r=Rs(En,a=>a.isApplicable(e,t));if(r)return{value:r.transform(e,t),type:r.annotation}},Nn={};En.forEach(e=>{Nn[e.annotation]=e});var Ea=(e,t,s)=>{if(Re(t))switch(t[0]){case"symbol":return vn.untransform(e,t,s);case"class":return wn.untransform(e,t,s);case"custom":return jn.untransform(e,t,s);case"typed-array":return Sn.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const r=Nn[t];if(!r)throw new Error("Unknown transformation: "+t);return r.untransform(e,s)}},Ke=(e,t)=>{const s=e.keys();for(;t>0;)s.next(),t--;return s.next().value};function An(e){if(Ft(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Ft(e,"prototype"))throw new Error("prototype is not allowed as a property");if(Ft(e,"constructor"))throw new Error("constructor is not allowed as a property")}var va=(e,t)=>{An(t);for(let s=0;s<t.length;s++){const r=t[s];if(jt(e))e=Ke(e,+r);else if(wt(e)){const a=+r,i=+t[++s]==0?"key":"value",o=Ke(e,a);switch(i){case"key":e=o;break;case"value":e=e.get(o);break}}else e=e[r]}return e},hs=(e,t,s)=>{if(An(t),t.length===0)return s(e);let r=e;for(let i=0;i<t.length-1;i++){const o=t[i];if(Re(r)){const l=+o;r=r[l]}else if(bt(r))r=r[o];else if(jt(r)){const l=+o;r=Ke(r,l)}else if(wt(r)){if(i===t.length-2)break;const u=+o,d=+t[++i]==0?"key":"value",f=Ke(r,u);switch(d){case"key":r=f;break;case"value":r=r.get(f);break}}}const a=t[t.length-1];if(Re(r)?r[+a]=s(r[+a]):bt(r)&&(r[a]=s(r[a])),jt(r)){const i=Ke(r,+a),o=s(i);i!==o&&(r.delete(i),r.add(o))}if(wt(r)){const i=+t[t.length-2],o=Ke(r,i);switch(+a==0?"key":"value"){case"key":{const u=s(o);r.set(u,r.get(o)),u!==o&&r.delete(o);break}case"value":{r.set(o,s(r.get(o)));break}}}return e};function fs(e,t,s=[]){if(!e)return;if(!Re(e)){ct(e,(i,o)=>fs(i,t,[...s,...Et(o)]));return}const[r,a]=e;a&&ct(a,(i,o)=>{fs(i,t,[...s,...Et(o)])}),t(r,s)}function Sa(e,t,s){return fs(t,(r,a)=>{e=hs(e,a,i=>Ea(i,r,s))}),e}function ba(e,t){function s(r,a){const i=va(e,Et(a));r.map(Et).forEach(o=>{e=hs(e,o,()=>i)})}if(Re(t)){const[r,a]=t;r.forEach(i=>{e=hs(e,Et(i),()=>e)}),a&&ct(a,s)}else ct(t,s);return e}var wa=(e,t)=>bt(e)||Re(e)||wt(e)||jt(e)||bn(e,t);function ja(e,t,s){const r=s.get(e);r?r.push(t):s.set(e,[t])}function Na(e,t){const s={};let r;return e.forEach(a=>{if(a.length<=1)return;t||(a=a.map(l=>l.map(String)).sort((l,u)=>l.length-u.length));const[i,...o]=a;i.length===0?r=o.map(rs):s[rs(i)]=o.map(rs)}),r?ds(s)?[r]:[r,s]:ds(s)?void 0:s}var Tn=(e,t,s,r,a=[],i=[],o=new Map)=>{const l=ha(e);if(!l){ja(e,a,t);const E=o.get(e);if(E)return r?{transformedValue:null}:E}if(!wa(e,s)){const E=Fs(e,s),p=E?{transformedValue:E.value,annotations:[E.type]}:{transformedValue:e};return l||o.set(e,p),p}if(Ft(i,e))return{transformedValue:null};const u=Fs(e,s),d=(u==null?void 0:u.value)??e,f=Re(d)?[]:{},m={};ct(d,(E,p)=>{if(p==="__proto__"||p==="constructor"||p==="prototype")throw new Error(`Detected property ${p}. This is a prototype pollution risk, please remove it from your object.`);const j=Tn(E,t,s,r,[...a,p],[...i,e],o);f[p]=j.transformedValue,Re(j.annotations)?m[p]=j.annotations:bt(j.annotations)&&ct(j.annotations,(b,D)=>{m[yn(p)+"."+D]=b})});const w=ds(m)?{transformedValue:f,annotations:u?[u.type]:void 0}:{transformedValue:f,annotations:u?[u.type,m]:m};return l||o.set(e,w),w};function Cn(e){return Object.prototype.toString.call(e).slice(8,-1)}function Hs(e){return Cn(e)==="Array"}function Aa(e){if(Cn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function Ta(e,t,s,r,a){const i={}.propertyIsEnumerable.call(r,t)?"enumerable":"nonenumerable";i==="enumerable"&&(e[t]=s),a&&i==="nonenumerable"&&Object.defineProperty(e,t,{value:s,enumerable:!1,writable:!0,configurable:!0})}function ms(e,t={}){if(Hs(e))return e.map(a=>ms(a,t));if(!Aa(e))return e;const s=Object.getOwnPropertyNames(e),r=Object.getOwnPropertySymbols(e);return[...s,...r].reduce((a,i)=>{if(Hs(t.props)&&!t.props.includes(i))return a;const o=e[i],l=ms(o,t);return Ta(a,i,l,e,t.nonenumerable),a},{})}var ne=class{constructor({dedupe:e=!1}={}){this.classRegistry=new ea,this.symbolRegistry=new gn(t=>t.description??""),this.customTransformerRegistry=new na,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=Tn(e,t,this,this.dedupe),r={json:s.transformedValue};s.annotations&&(r.meta={...r.meta,values:s.annotations});const a=Na(t,this.dedupe);return a&&(r.meta={...r.meta,referentialEqualities:a}),r}deserialize(e){const{json:t,meta:s}=e;let r=ms(t);return s!=null&&s.values&&(r=Sa(r,s.values,this)),s!=null&&s.referentialEqualities&&(r=ba(r,s.referentialEqualities)),r}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)}};ne.defaultInstance=new ne;ne.serialize=ne.defaultInstance.serialize.bind(ne.defaultInstance);ne.deserialize=ne.defaultInstance.deserialize.bind(ne.defaultInstance);ne.stringify=ne.defaultInstance.stringify.bind(ne.defaultInstance);ne.parse=ne.defaultInstance.parse.bind(ne.defaultInstance);ne.registerClass=ne.defaultInstance.registerClass.bind(ne.defaultInstance);ne.registerSymbol=ne.defaultInstance.registerSymbol.bind(ne.defaultInstance);ne.registerCustom=ne.defaultInstance.registerCustom.bind(ne.defaultInstance);ne.allowErrorProps=ne.defaultInstance.allowErrorProps.bind(ne.defaultInstance);var Pn=ne.serialize,Ca=ne.stringify;function Pa(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function Ia(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function _a({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function La({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function Da(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var ka=(e,t=!1)=>{const{json:s}=Pn(e);return JSON.stringify(s,null,t?2:void 0)},Rt=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,Ga=(e,t)=>e.queryHash.localeCompare(t.queryHash),In=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,Ma=(e,t)=>Rt(e)===Rt(t)?In(e,t):Rt(e)>Rt(t)?1:-1,Oa={status:Ma,"query hash":Ga,"last updated":In},Bt=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,_n=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,Ua=(e,t)=>Bt(e)===Bt(t)?_n(e,t):Bt(e)>Bt(t)?1:-1,Ra={status:Ua,"last updated":_n},Ba=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),Fa=()=>{const[e,t]=he("dark");return Xs(()=>{const s=window.matchMedia("(prefers-color-scheme: dark)");t(s.matches?"dark":"light");const r=a=>{t(a.matches?"dark":"light")};s.addEventListener("change",r),lt(()=>s.removeEventListener("change",r))}),e},xt=(e,t,s)=>{if(t.length===0)return s;if(e instanceof Map){const r=new Map(e);if(t.length===1)return r.set(t[0],s),r;const[a,...i]=t;return r.set(a,xt(r.get(a),i,s)),r}if(e instanceof Set){const r=xt(Array.from(e),t,s);return new Set(r)}if(Array.isArray(e)){const r=[...e];if(t.length===1)return r[t[0]]=s,r;const[a,...i]=t;return r[a]=xt(r[a],i,s),r}if(e instanceof Object){const r={...e};if(t.length===1)return r[t[0]]=s,r;const[a,...i]=t;return r[a]=xt(r[a],i,s),r}return e},pt=(e,t)=>{if(e instanceof Map){const s=new Map(e);if(t.length===1)return s.delete(t[0]),s;const[r,...a]=t;return s.set(r,pt(s.get(r),a)),s}if(e instanceof Set){const s=pt(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[r,...a]=t;return s[r]=pt(s[r],a),s}if(e instanceof Object){const s={...e};if(t.length===1)return delete s[t[0]],s;const[r,...a]=t;return s[r]=pt(s[r],a),s}return e},Ln=(e,t)=>{if(!e||document.querySelector("#_goober")||(t==null?void 0:t.querySelector("#_goober")))return;const r=document.createElement("style"),a=document.createTextNode("");r.appendChild(a),r.id="_goober",r.setAttribute("nonce",e),t?t.appendChild(r):document.head.appendChild(r)},We,Nt,At,Tt,He,Ct,ze,Qe,Ye,Xe,Ze,Je,Pt,Vs,Ha=(Vs=class{constructor(e){te(this,We);te(this,Nt);te(this,At);te(this,Tt);te(this,He,!1);te(this,Ct);te(this,ze);te(this,Qe);te(this,Ye);te(this,Xe);te(this,Ze);te(this,Je);te(this,Pt);const{client:t,queryFlavor:s,version:r,onlineManager:a,buttonPosition:i,position:o,initialIsOpen:l,errorTypes:u,styleNonce:d,shadowDOMTarget:f}=e;J(this,We,he(t)),J(this,At,s),J(this,Tt,r),J(this,Nt,a),J(this,Ct,d),J(this,ze,f),J(this,Qe,he(i)),J(this,Ye,he(o)),J(this,Xe,he(l)),J(this,Ze,he(u))}setButtonPosition(e){B(this,Qe)[1](e)}setPosition(e){B(this,Ye)[1](e)}setInitialIsOpen(e){B(this,Xe)[1](e)}setErrorTypes(e){B(this,Ze)[1](e)}setClient(e){B(this,We)[1](e)}mount(e){if(B(this,He))throw new Error("Devtools is already mounted");const t=on(()=>{const s=this,[r]=B(this,Qe),[a]=B(this,Ye),[i]=B(this,Xe),[o]=B(this,Ze),[l]=B(this,We);let u;return B(this,Je)?u=B(this,Je):(u=rn(()=>Promise.resolve().then(()=>require("./HO4MOOFI-DY2QBu0y.cjs"))),J(this,Je,u)),Ln(B(this,Ct),B(this,ze)),vs(u,Ss({get queryFlavor(){return B(s,At)},get version(){return B(s,Tt)},get onlineManager(){return B(s,Nt)},get shadowDOMTarget(){return B(s,ze)}},{get client(){return l()},get buttonPosition(){return r()},get position(){return a()},get initialIsOpen(){return i()},get errorTypes(){return o()}}))},e);J(this,He,!0),J(this,Pt,t)}unmount(){var e;if(!B(this,He))throw new Error("Devtools is not mounted");(e=B(this,Pt))==null||e.call(this),J(this,He,!1)}},We=new WeakMap,Nt=new WeakMap,At=new WeakMap,Tt=new WeakMap,He=new WeakMap,Ct=new WeakMap,ze=new WeakMap,Qe=new WeakMap,Ye=new WeakMap,Xe=new WeakMap,Ze=new WeakMap,Je=new WeakMap,Pt=new WeakMap,Vs),et,It,_t,Lt,qe,Dt,tt,st,nt,rt,at,it,ot,kt,$s,qa=($s=class{constructor(e){te(this,et);te(this,It);te(this,_t);te(this,Lt);te(this,qe,!1);te(this,Dt);te(this,tt);te(this,st);te(this,nt);te(this,rt);te(this,at);te(this,it);te(this,ot);te(this,kt);const{client:t,queryFlavor:s,version:r,onlineManager:a,buttonPosition:i,position:o,initialIsOpen:l,errorTypes:u,styleNonce:d,shadowDOMTarget:f,onClose:m}=e;J(this,et,he(t)),J(this,_t,s),J(this,Lt,r),J(this,It,a),J(this,Dt,d),J(this,tt,f),J(this,st,he(i)),J(this,nt,he(o)),J(this,rt,he(l)),J(this,at,he(u)),J(this,it,he(m))}setButtonPosition(e){B(this,st)[1](e)}setPosition(e){B(this,nt)[1](e)}setInitialIsOpen(e){B(this,rt)[1](e)}setErrorTypes(e){B(this,at)[1](e)}setClient(e){B(this,et)[1](e)}setOnClose(e){B(this,it)[1](()=>e)}mount(e){if(B(this,qe))throw new Error("Devtools is already mounted");const t=on(()=>{const s=this,[r]=B(this,st),[a]=B(this,nt),[i]=B(this,rt),[o]=B(this,at),[l]=B(this,et),[u]=B(this,it);let d;return B(this,ot)?d=B(this,ot):(d=rn(()=>Promise.resolve().then(()=>require("./HUY7CZI3-BL3e6hkF.cjs"))),J(this,ot,d)),Ln(B(this,Dt),B(this,tt)),vs(d,Ss({get queryFlavor(){return B(s,_t)},get version(){return B(s,Lt)},get onlineManager(){return B(s,It)},get shadowDOMTarget(){return B(s,tt)}},{get client(){return l()},get buttonPosition(){return r()},get position(){return a()},get initialIsOpen(){return i()},get errorTypes(){return o()},get onClose(){return u()}}))},e);J(this,qe,!0),J(this,kt,t)}unmount(){var e;if(!B(this,qe))throw new Error("Devtools is not mounted");(e=B(this,kt))==null||e.call(this),J(this,qe,!1)}},et=new WeakMap,It=new WeakMap,_t=new WeakMap,Lt=new WeakMap,qe=new WeakMap,Dt=new WeakMap,tt=new WeakMap,st=new WeakMap,nt=new WeakMap,rt=new WeakMap,at=new WeakMap,it=new WeakMap,ot=new WeakMap,kt=new WeakMap,$s);function Va(e){const t=U.useQueryClient(e.client),s=oe.useRef(null),{buttonPosition:r,position:a,initialIsOpen:i,errorTypes:o,styleNonce:l,shadowDOMTarget:u}=e,[d]=oe.useState(new Ha({client:t,queryFlavor:"React Query",version:"5",onlineManager:U.onlineManager,buttonPosition:r,position:a,initialIsOpen:i,errorTypes:o,styleNonce:l,shadowDOMTarget:u}));return oe.useEffect(()=>{d.setClient(t)},[t,d]),oe.useEffect(()=>{r&&d.setButtonPosition(r)},[r,d]),oe.useEffect(()=>{a&&d.setPosition(a)},[a,d]),oe.useEffect(()=>{d.setInitialIsOpen(i||!1)},[i,d]),oe.useEffect(()=>{d.setErrorTypes(o||[])},[o,d]),oe.useEffect(()=>(s.current&&d.mount(s.current),()=>{d.unmount()}),[d]),n.jsx("div",{className:"tsqd-parent-container",ref:s})}function $a(e){const t=U.useQueryClient(e.client),s=oe.useRef(null),{errorTypes:r,styleNonce:a,shadowDOMTarget:i}=e,[o]=oe.useState(new qa({client:t,queryFlavor:"React Query",version:"5",onlineManager:U.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:r,styleNonce:a,shadowDOMTarget:i,onClose:e.onClose}));return oe.useEffect(()=>{o.setClient(t)},[t,o]),oe.useEffect(()=>{o.setOnClose(e.onClose??(()=>{}))},[e.onClose,o]),oe.useEffect(()=>{o.setErrorTypes(r||[])},[r,o]),oe.useEffect(()=>(s.current&&o.mount(s.current),()=>{o.unmount()}),[o]),n.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:s})}var Ka=process.env.NODE_ENV!=="development"?function(){return null}:Va;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",GET_PAGE_REVISIONS:"GET_PAGE_REVISIONS",DELETE_PAGE_REVISION:"DELETE_PAGE_REVISION",RESTORE_PAGE_REVISION:"RESTORE_PAGE_REVISION",GET_ROLE_AND_PERMISSIONS:"GET_ROLE_AND_PERMISSIONS",UPSERT_LIBRARY_ITEM:"UPSERT_LIBRARY_ITEM",GET_LIBRARIES:"GET_LIBRARIES",GET_LIBRARY_ITEM:"GET_LIBRARY_ITEM",GET_LIBRARY_ITEMS:"GET_LIBRARY_ITEMS"},bs=()=>{const e=U.useQueryClient(),{data:t}=U.useQuery({queryKey:[L.AI_CONTEXT],initialData:"",queryFn:()=>""});return{setAiContext:v.useCallback(r=>{e.setQueryData([L.AI_CONTEXT],r)},[]),aiContext:t}},Wa=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)}),za=()=>{const e=Ne("user"),t=Ne("onSessionExpired"),s=v.useMemo(()=>e==null?void 0:e.authToken,[e==null?void 0:e.authToken]);return v.useCallback(async(r,a,i={})=>{if(s)try{const o=await fetch(r,{method:"POST",body:a,headers:{...i,Authorization:`Bearer ${s}`,"x-chai-upload":"true"}});if(o.status===401)throw console.log("session expired",a,o),t(),new Error("Session expired");if(o.status===400)throw console.log("Something went wrong",a,o),new Error((await o.json()).error);return await o.json()}catch(o){throw console.log("Something went wrong",a,o),o}},[s,t])},Z=()=>{const e=Ne("user"),t=Ne("onSessionExpired"),s=v.useMemo(()=>e==null?void 0:e.authToken,[e==null?void 0:e.authToken]);return v.useCallback(async(r,a,i={})=>{if(s)try{const o=g.get(a,"action","").toLowerCase(),l=await Wa(r+(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])},Dn=()=>{const e=ee(),t=U.useQueryClient(),s=Z();return U.useMutation({mutationFn:async r=>s(e,{action:L.RELEASE_LOCK,data:r}),onSuccess:(r,a)=>{t.invalidateQueries({queryKey:[L.GET_PAGE,a.id??""]})}})},kn=()=>{const e=ee(),t=U.useQueryClient(),s=Z();return U.useMutation({mutationFn:async r=>s(e,{action:L.UPDATE_WEBSITE_SETTINGS,data:r}),onSuccess:(r,a)=>{var i;t.invalidateQueries({queryKey:[L.GET_WEBSITE_SETTINGS]}),(i=a==null?void 0:a.settings)!=null&&i.theme||ie.toast.success("Website settings updated successfully.")},onError:r=>{ie.toast.error("Failed to update website settings",{description:r.message})}})},Qa=()=>{const e=ee(),t=U.useQueryClient(),s=Z();return U.useMutation({mutationFn:async r=>s(e,{action:L.UPDATE_WEBSITE_DATA,data:r}),onSuccess:()=>{t.invalidateQueries({queryKey:[L.GET_WEBSITE_DATA]}),ie.toast.success("Website data updated successfully.")},onError:r=>{ie.toast.error("Failed to update website data",{description:r.message})}})},Ya=e=>{const t=ee(),s=Z(),{resetLibrary:r}=ce.useLibraryBlocks(e);return U.useMutation({mutationFn:async a=>s(t,{action:L.UPSERT_LIBRARY_ITEM,data:a}),onSuccess:()=>{console.log("resetLibrary",e),r(),ie.toast.success("Library updated successfully.")},onError:a=>{ie.toast.error("Failed to update library item",{description:a.message})}})};function je(){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 Xa=ut.atom({}),Gn=()=>ut.useAtom(Xa),Za=()=>{const[e]=je(),t=e.get("page"),s=v.useRef(""),{mutate:r}=Dn();v.useEffect(()=>{!g.isEmpty(s.current)&&t!==s.current&&r({id:s.current}),s.current=t},[t,r,s])},Ne=(e,t)=>{const[s]=Gn();return g.get(s,e,t)},ee=()=>Ne("apiUrl","/chai/api"),Ja=()=>{const e=ee(),{aiContext:t}=bs(),s=Z();return v.useCallback(async(r,a,i,o)=>s(e,{action:L.ASK_AI,data:{type:r,prompt:a,blocks:i,context:t,lang:o}}),[e,t,s])},Mt=()=>{const e=Z(),t=ee();return U.useQuery({queryKey:[L.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:L.GET_WEBSITE_PAGES})||[]})},ei=ut.atom({lastSaved:void 0}),ws=()=>ut.useAtom(ei),be=()=>{const[e]=je(),t=e.get("page"),{data:s,isFetching:r}=Mt();return{data:v.useMemo(()=>g.find(s,{id:t})||{},[s,t]),isFetching:r}},ti=(e,t)=>t.map(s=>{if(g.has(e,s._type)){const r=Ks.getDefaultBlockProps(s._type);return{...r,...g.pick(s,[...g.keys(r),"_type","_id","_name","_parent","_bindings"]),...g.pickBy(s,(a,i)=>g.endsWith(i,"_attrs")),...s}}return s}),si=e=>{const t=Ks.useRegisteredChaiBlocks();return v.useMemo(()=>{if(!e||g.isEmpty(e))return{blocks:[]};const s=g.filter(e,r=>!g.includes(r==null?void 0:r._type,"@chai/"));return{blocks:ti(t,s)}},[e,t])},ht=e=>{const t=ee(),s=Z();return U.useQuery({queryKey:["chaiUserInfo",e],queryFn:async()=>await s(t,{action:L.GET_CHAI_USER,data:{userId:e}}),enabled:!!e&&e!=="EXPIRED"})},ni=ut.atom(void 0),Ot=()=>{const[e]=je(),t=e.get("page"),s=Ne("user"),[r,a]=ut.useAtom(ni);return v.useMemo(()=>({isLocked:t&&(s==null?void 0:s.id)!==r,currentEditor:r,setCurrentEditor:i=>a(i)}),[r,t,a,s==null?void 0:s.id])},Mn=()=>{const[e]=je(),t=e.get("page"),s=ee(),{setAiContext:r}=bs(),{setCurrentEditor:a}=Ot(),[,i]=ws(),o=Z();return U.useQuery({queryKey:[L.GET_PAGE,t],staleTime:1/0,gcTime:1/0,queryFn:async()=>{a("");const l=await o(s,{action:L.GET_PAGE,data:{id:t,draft:!0}});a(l.currentEditor);const u=l.blocks??[],d=g.find(u,{_type:"@chai/ai-context"});return r(g.get(d,"_value","")||""),i(f=>({...f,lastSaved:l.lastSaved})),u},enabled:!!t})},On=({pageType:e,lang:t})=>{const s=ee(),r=Z();return U.useQuery({queryKey:[L.GET_BUILDER_PAGE_DATA,e,t],initialData:{},queryFn:async()=>r(s,{action:L.GET_BUILDER_PAGE_DATA,data:{pageType:e,lang:t}}),enabled:!!e&&!!t})},ve=()=>{const e=ee(),t=Z();return U.useQuery({queryKey:[L.GET_PAGE_TYPES],initialData:[],queryFn:async()=>t(e,{action:L.GET_PAGE_TYPES})})},ri=e=>{const{data:t}=ve();return v.useMemo(()=>t==null?void 0:t.find(s=>s.key===e),[t,e])},ai=()=>{const e=ee(),t=Z();return U.useMutation({mutationFn:async({pageType:s,query:r})=>{try{return t(e,{action:L.SEARCH_PAGES,data:{pageType:s,query:Array.isArray(r)&&r.length>0?r[0]:r}})||[]}catch(a){return console.error(a),[]}}})},ii=()=>{const e=ee(),t=Z();return U.useQuery({queryKey:["uiLibraries"],initialData:[],queryFn:async()=>(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}))})},ft=()=>{const e=ee(),t=Z();return U.useQuery({queryKey:[L.GET_WEBSITE_SETTINGS],initialData:{theme:{},fallbackLang:"en",languages:[]},queryFn:async()=>t(e,{action:L.GET_WEBSITE_SETTINGS,data:{draft:!0}})})},oi=()=>{const e=ee(),t=Z(),{setCurrentEditor:s}=Ot(),[,r]=ws();return{getUILibraryBlock:async(l,u)=>{const d=await t(e,{action:"GET_LIBRARY_ITEM",data:{id:u.id}}),f=g.get(d,"html",""),m=g.get(d,"blocks",[]);return g.isArray(m)?m:ce.getBlocksFromHTML(f)},getUILibraryBlocks:async l=>{try{return(await t(e,{action:"GET_LIBRARY_ITEMS",data:{id:l.id}})).map(d=>({...d}))}catch(u){return console.error(u),[]}},onSave:async({page:l,blocks:u})=>{try{const d=await t(e,{action:"UPDATE_PAGE",data:{id:l,blocks:u}});return d.code==="PAGE_LOCKED"?(s(d.editor===null?"EXPIRED":d.editor),!0):(r(f=>({...f,lastSaved:new Date().toISOString()})),d)}catch(d){return console.error(d),new Error("Failed to save blocks")}}}},li=()=>{const{data:e}=Mt(),t=ee(),s=Z();return{getPartialBlocks:v.useCallback(async()=>{const r={};for(const a of e??[])g.isEmpty(a==null?void 0:a.slug)&&(r[a.id]={type:a.pageType,name:g.startCase(a.name??a.slug),description:""});return r},[e]),getPartialBlockBlocks:v.useCallback(async r=>{if(!r)return[];const a=await s(t,{action:"GET_PAGE",data:{id:r,draft:!0,editor:!1}});return g.filter(a.blocks,i=>g.has(i,"_id"))},[s,t])}},Ce={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"},mt=()=>{const e=ee(),[t]=je(),s=t.get("page"),r=Z();return U.useQuery({queryKey:[L.GET_LANGUAGE_PAGES,s],initialData:[],queryFn:async()=>{if(!s)return null;const a=await r(e,{action:L.GET_LANGUAGE_PAGES,data:{id:s}});return g.reverse(g.sortBy(a,"primaryPage"))},enabled:!!s})},Un=e=>{const{fallbackLang:t}=ce.useLanguages(),{data:s}=ft(),{data:r,isFetching:a}=mt(),i=v.useMemo(()=>{const o={[t]:!0};return g.each(g.get(s,"languages"),l=>{const u=g.find(r,{lang:l});o[l]=!!u}),o},[t,r,s]);return a||g.isEmpty(e)||e&&i[e]};function ci({avatar:e,name:t,email:s,onTakeOver:r,currentEditor:a}){const[i,o]=v.useState(!1),l=()=>{o(!1),r()};return n.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:n.jsxs(c.Card,{className:"w-full max-w-md mx-auto",children:[n.jsx(c.CardHeader,{className:"space-y-1",children:n.jsxs(c.CardTitle,{className:"flex items-center gap-2 text-2xl",children:[n.jsx(I.LockIcon,{className:"w-6 h-6 text-yellow-500"}),a==="EXPIRED"?"Editing access timed out":"Page locked for editing"]})}),n.jsx(c.CardContent,{className:"grid gap-4",children:a==="EXPIRED"?n.jsx("div",{children:n.jsx("p",{children:"Your editing access has been paused due to inactivity. Please refresh the page to continue"})}):n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[e?n.jsx("img",{src:e,alt:t,className:"w-12 h-12 border border-gray-300 rounded-full"}):n.jsx(I.UserIcon,{className:"w-12 h-12 p-2 border border-gray-300 rounded-full"}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("h3",{className:"font-semibold",children:t}),s&&n.jsx("p",{className:"text-sm text-muted-foreground",children:s})]})]}),n.jsx("div",{className:"text-sm mt-4",children:n.jsx("p",{children:"This user is currently editing the page. You cannot make changes."})})]})}),n.jsx(c.CardFooter,{children:a==="EXPIRED"?n.jsx("div",{children:n.jsx(c.Button,{className:"w-full",onClick:()=>window.location.reload(),variant:"destructive",children:"Refresh"})}):n.jsxs(c.AlertDialog,{open:i,onOpenChange:o,children:[n.jsx(c.AlertDialogTrigger,{asChild:!0,children:n.jsxs("span",{className:"flex flex-col items-center",children:[n.jsx(c.Button,{className:"w-full",variant:"destructive",children:"Take Over"}),n.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."})]})}),n.jsxs(c.AlertDialogContent,{className:"z-[99]",children:[n.jsxs(c.AlertDialogHeader,{children:[n.jsx(c.AlertDialogTitle,{children:"Are you sure you want to take over?"}),n.jsxs(c.AlertDialogDescription,{children:[n.jsxs("span",{className:"flex items-center space-x-2 text-yellow-500",children:[n.jsx(I.AlertTriangleIcon,{className:"w-5 h-5"}),n.jsx("span",{children:"This action might cause the other user to lose unsaved changes."})]}),n.jsx("br",{}),n.jsxs("span",{className:"mt-2",children:["By taking over, you will become the active editor of this page, and ",t," will lose their editing access."]})]})]}),n.jsxs(c.AlertDialogFooter,{children:[n.jsx(c.AlertDialogCancel,{children:"Cancel"}),n.jsx(c.AlertDialogAction,{onClick:l,children:"Yes, Take Over"})]})]})]})})]})})}const ui=()=>{const{isLocked:e,currentEditor:t}=Ot(),{data:s}=ht(t),r=Ne("pageLockComponent",ci),[a]=je(),i=a.get("page"),{mutate:o}=Dn(),{isFetching:l}=Mn(),u=v.useCallback(()=>{o({id:i})},[i,o]);return!e||l?n.jsx("div",{className:""}):n.jsx(r,{...s,isLocked:e,currentEditor:t,onTakeOver:u})},di=()=>{const[e,t]=je(),s=e.get("lang"),r=Un(s),{setSelectedLang:a}=ce.useLanguages(),i=()=>{const l=new URLSearchParams(window.location.search);l.delete("lang");const u=l.toString(),d=`${window.location.pathname}${u?`?${u}`:""}`;window.history.pushState({},"",d),t(l),a(""),window.dispatchEvent(new PopStateEvent("popstate"))};if(r)return null;const o=g.get(Ce,s);return n.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:n.jsxs(c.Card,{className:"w-full max-w-md mx-auto",children:[n.jsx(c.CardHeader,{className:"space-y-1",children:n.jsxs(c.CardTitle,{className:"flex items-center gap-2 text-2xl",children:[n.jsx(I.LockIcon,{className:"w-6 h-6 text-yellow-500"}),'Page missing for "',o,'" language.']})}),n.jsx(c.CardContent,{className:"grid gap-4",children:n.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.']})}),n.jsx(c.CardFooter,{children:n.jsx(c.Button,{onClick:i,className:"w-full",variant:"destructive",children:"Switch to default language"})})]})})},hi=()=>{const e=ee(),t=Z();return U.useQuery({queryKey:[L.GET_LIBRARIES],initialData:[],queryFn:async()=>t(e,{action:L.GET_LIBRARIES})})},fi=e=>{const t=ee(),s=Z();return U.useQuery({queryKey:[L.GET_LIBRARY_ITEMS,e],initialData:[],queryFn:async()=>e?s(t,{action:L.GET_LIBRARY_ITEMS,data:{id:e}}):[],enabled:!!e})},Rn=(e,t)=>{const s=g.filter(e,{_parent:t});if(s.length===0)return[];const r=[...s];return s.forEach(a=>{r.push(...Rn(e,a==null?void 0:a._id))}),r},qs=({block:e,page:t,open:s,setOpen:r})=>{const a=!!t,[i,o]=v.useState("CREATE"),[l,u]=v.useState(""),[d,f]=v.useState(a?(t==null?void 0:t.name)+" template":""),[m,w]=v.useState(""),[E,p]=v.useState(""),[j]=ce.useBlocksStore(),b=Ya({id:l}),{data:D,isLoading:A}=hi(),{data:T,isLoading:S}=fi(l),P=A||S||b.isPending;v.useEffect(()=>{D.length>0&&u(D[0].id)},[D]);const H=()=>{if(a){const C={pageId:t==null?void 0:t.id,libraryId:l,group:m,name:d};E&&(C.id=E),b.mutate(C,{onSuccess:()=>r(!1)})}else if(e){const C=e==null?void 0:e._id,k=g.cloneDeep(e);k==null||delete k._parent;const G={blocks:[k,...Rn(j,C)],libraryId:l,group:m};E&&(G.id=E),G.name=d,b.mutate(G,{onSuccess:()=>r(!1)})}};return n.jsx(c.Dialog,{open:s,onOpenChange:r,children:n.jsxs(c.DialogContent,{children:[n.jsxs(c.DialogHeader,{children:[n.jsx(c.DialogTitle,{children:a?"Save page as template":"Add/Update library block"}),n.jsxs(c.DialogDescription,{className:`py-4 text-slate-500 space-y-1 text-xs ${P?"opacity-75 pointer-events-none":""}`,children:[n.jsx(c.Tabs,{value:i,onValueChange:o,className:"w-full",children:n.jsxs(c.TabsList,{className:"w-full",children:[n.jsxs(c.TabsTrigger,{value:"CREATE",className:"w-full",children:["Create new ",a?"template":""]}),n.jsxs(c.TabsTrigger,{value:"UPDATE",className:"w-full",children:["Update existing ",a?"template":""]})]})}),n.jsx("br",{}),n.jsx(c.Label,{className:"text-xs",children:"Choose Library"}),n.jsxs(c.Select,{disabled:P,value:l,onValueChange:u,children:[n.jsx(c.SelectTrigger,{className:"ring-0 focus:ring-0",onClick:C=>C.preventDefault(),children:n.jsx(c.SelectValue,{})}),n.jsx(c.SelectContent,{className:"z-[9999999]",children:g.map(D,C=>n.jsx(c.SelectItem,{value:C.id,children:C.name},C.id))})]}),n.jsx("br",{}),n.jsx(c.Label,{className:"text-xs",children:"Group"}),n.jsx(c.Input,{value:m,placeholder:"Enter group name",onClick:C=>C.stopPropagation(),onKeyDown:C=>C.stopPropagation(),onChange:C=>{w(C.target.value)}}),n.jsx("br",{}),i==="CREATE"?n.jsxs(n.Fragment,{children:[n.jsxs(c.Label,{className:"text-xs",children:[a?"Template":"Block"," name"]}),n.jsx(c.Input,{value:d,placeholder:`Enter ${a?"template":"block"} name`,onClick:C=>C.stopPropagation(),onKeyDown:C=>C.stopPropagation(),onChange:C=>{f(C.target.value)}})]}):n.jsxs(n.Fragment,{children:[n.jsxs(c.Label,{className:"text-xs",children:["Choose ",a?"template":"block"," to update"]}),n.jsxs(c.Select,{disabled:S,value:E,onValueChange:p,children:[n.jsx(c.SelectTrigger,{className:"ring-0 focus:ring-0",onClick:C=>C.preventDefault(),children:n.jsx(c.SelectValue,{placeholder:`Select ${a?"template":"block"}`})}),n.jsx(c.SelectContent,{className:"z-[9999999]",children:g.map(T,C=>n.jsx(c.SelectItem,{value:C.id,children:C.name},C.id))})]})]})]})]}),n.jsxs(c.DialogFooter,{className:P?"opacity-75 pointer-events-none":"",children:[n.jsx(c.Button,{variant:"outline",onClick:C=>{C.stopPropagation(),r(!1)},children:"Cancel"}),n.jsx(c.Button,{variant:"default",className:"capitalize",disabled:S||P||i==="CREATE"&&((d==null?void 0:d.length)<3||(m==null?void 0:m.length)<3)||i==="UPDATE"&&(l.length<1||E.length<1),onClick:H,children:i.toLowerCase()})]})]})})},Bn=({block:e,page:t,onClose:s=()=>{}})=>{const[r,a]=v.useState(!1),i=(e==null?void 0:e._type)==="PartialBlock";return t?n.jsx(qs,{page:t,open:!0,setOpen:s}):n.jsxs(n.Fragment,{children:[n.jsxs(c.DropdownMenuItem,{disabled:i,onClick:o=>{o.stopPropagation(),o.preventDefault(),a(l=>!l)},className:"flex items-center gap-x-4 text-xs",children:[n.jsx(I.SquareLibrary,{className:"h-4 w-4"})," Save to library"]}),r&&e&&n.jsx(qs,{block:e,page:t,open:r,setOpen:()=>{a(!1),s()}})]})},q={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",SAVE_AS_TEMPLATE:"Save as template",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."},mi={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},Fn=()=>{const e=ee(),t=U.useQueryClient(),s=Z(),{data:r}=ve();return U.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(r,{key:i.pageType});ie.toast.error(`Failed to add new ${o!=null&&o.hasSlug?"page":o.name}.`,{description:g.get(mi,a.message,a.message)})}})},js=()=>{const e=ee(),t=U.useQueryClient(),s=Z(),{data:r}=ve();return U.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(r,{key:i.pageType});ie.toast.error(`Failed to update ${o!=null&&o.hasSlug?"page":o.name}.`,{description:a.message})}})},gi=()=>{const e=ee(),t=U.useQueryClient(),s=Z(),{data:r}=ve();return U.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"){ie.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(r,{key:i.pageType});ie.toast.error(`Failed to delete ${o!=null&&o.hasSlug?"page":o.name}.`,{description:a.message})}})},xi=()=>{const e=ee(),t=U.useQueryClient(),s=Z(),{data:r}=ve();return U.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(r,{key:i.pageType});ie.toast.success(o!=null&&o.hasSlug?q.PAGE_UNPUBLISH_SUCCESS:"New "+o.name+" added successfully.")},onError:(a,i)=>{const o=g.find(r,{key:i.pageType});ie.toast.error(`Failed to take offline ${o!=null&&o.hasSlug?"page":o.name}.`,{description:a.message})}})},Ns=()=>{const e=ee(),t=Z(),s=U.useQueryClient(),{data:r}=be();return U.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,r==null?void 0:r.id]})},onError:()=>{ie.toast.error("Failed to publish pages.")}})},pi=()=>{const e=ee(),t=Z(),s=U.useQueryClient();return U.useMutation({mutationFn:async({id:r,slug:a})=>t(e,{action:L.CHANGE_SLUG,data:{id:r,slug:a}}),onSuccess:(r,{primaryPage:a})=>{ie.toast.success(q.SLUG_CHANGE_SUCCESS),a?s.invalidateQueries({queryKey:[L.GET_LANGUAGE_PAGES,a]}):s.invalidateQueries({queryKey:[L.GET_WEBSITE_PAGES]})},onError:()=>{ie.toast.error("Failed to change slug")}})};var As={};(function e(t,s,r,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 x=new OffscreenCanvas(1,1),h=x.getContext("2d");h.fillRect(0,0,1,1);var _=x.transferToImageBitmap();try{h.createPattern(_,"no-repeat")}catch{return!1}return!0}();function u(){}function d(x){var h=s.exports.Promise,_=h!==void 0?h:t.Promise;return typeof _=="function"?new _(x):(x(u,u),null)}var f=function(x,h){return{transform:function(_){if(x)return _;if(h.has(_))return h.get(_);var R=new OffscreenCanvas(_.width,_.height),$=R.getContext("2d");return $.drawImage(_,0,0),h.set(_,R),R},clear:function(){h.clear()}}}(l,new Map),m=function(){var x=Math.floor(16.666666666666668),h,_,R={},$=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(h=function(K){var W=Math.random();return R[W]=requestAnimationFrame(function O(z){$===z||$+x-1<z?($=z,delete R[W],K()):R[W]=requestAnimationFrame(O)}),W},_=function(K){R[K]&&cancelAnimationFrame(R[K])}):(h=function(K){return setTimeout(K,x)},_=function(K){return clearTimeout(K)}),{frame:h,cancel:_}}(),w=function(){var x,h,_={};function R($){function K(W,O){$.postMessage({options:W||{},callback:O})}$.init=function(O){var z=O.transferControlToOffscreen();$.postMessage({canvas:z},[z])},$.fire=function(O,z,re){if(h)return K(O,null),h;var ue=Math.random().toString(36).slice(2);return h=d(function(ae){function de(ge){ge.data.callback===ue&&(delete _[ue],$.removeEventListener("message",de),h=null,f.clear(),re(),ae())}$.addEventListener("message",de),K(O,ue),_[ue]=de.bind(null,{data:{callback:ue}})}),h},$.reset=function(){$.postMessage({reset:!0});for(var O in _)_[O](),delete _[O]}}return function(){if(x)return x;if(!r&&i){var $=["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{x=new Worker(URL.createObjectURL(new Blob([$])))}catch(K){return typeof console!==void 0&&typeof console.warn=="function"&&console.warn("🎊 Could not load worker",K),null}R(x)}return x}}(),E={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 p(x,h){return h?h(x):x}function j(x){return x!=null}function b(x,h,_){return p(x&&j(x[h])?x[h]:E[h],_)}function D(x){return x<0?0:Math.floor(x)}function A(x,h){return Math.floor(Math.random()*(h-x))+x}function T(x){return parseInt(x,16)}function S(x){return x.map(P)}function P(x){var h=String(x).replace(/[^0-9a-f]/gi,"");return h.length<6&&(h=h[0]+h[0]+h[1]+h[1]+h[2]+h[2]),{r:T(h.substring(0,2)),g:T(h.substring(2,4)),b:T(h.substring(4,6))}}function H(x){var h=b(x,"origin",Object);return h.x=b(h,"x",Number),h.y=b(h,"y",Number),h}function C(x){x.width=document.documentElement.clientWidth,x.height=document.documentElement.clientHeight}function k(x){var h=x.getBoundingClientRect();x.width=h.width,x.height=h.height}function N(x){var h=document.createElement("canvas");return h.style.position="fixed",h.style.top="0px",h.style.left="0px",h.style.pointerEvents="none",h.style.zIndex=x,h}function G(x,h,_,R,$,K,W,O,z){x.save(),x.translate(h,_),x.rotate(K),x.scale(R,$),x.arc(0,0,1,W,O,z),x.restore()}function V(x){var h=x.angle*(Math.PI/180),_=x.spread*(Math.PI/180);return{x:x.x,y:x.y,wobble:Math.random()*10,wobbleSpeed:Math.min(.11,Math.random()*.1+.05),velocity:x.startVelocity*.5+Math.random()*x.startVelocity,angle2D:-h+(.5*_-Math.random()*_),tiltAngle:(Math.random()*(.75-.25)+.25)*Math.PI,color:x.color,shape:x.shape,tick:0,totalTicks:x.ticks,decay:x.decay,drift:x.drift,random:Math.random()+2,tiltSin:0,tiltCos:0,wobbleX:0,wobbleY:0,gravity:x.gravity*3,ovalScalar:.6,scalar:x.scalar,flat:x.flat}}function Y(x,h){h.x+=Math.cos(h.angle2D)*h.velocity+h.drift,h.y+=Math.sin(h.angle2D)*h.velocity+h.gravity,h.velocity*=h.decay,h.flat?(h.wobble=0,h.wobbleX=h.x+10*h.scalar,h.wobbleY=h.y+10*h.scalar,h.tiltSin=0,h.tiltCos=0,h.random=1):(h.wobble+=h.wobbleSpeed,h.wobbleX=h.x+10*h.scalar*Math.cos(h.wobble),h.wobbleY=h.y+10*h.scalar*Math.sin(h.wobble),h.tiltAngle+=.1,h.tiltSin=Math.sin(h.tiltAngle),h.tiltCos=Math.cos(h.tiltAngle),h.random=Math.random()+2);var _=h.tick++/h.totalTicks,R=h.x+h.random*h.tiltCos,$=h.y+h.random*h.tiltSin,K=h.wobbleX+h.random*h.tiltCos,W=h.wobbleY+h.random*h.tiltSin;if(x.fillStyle="rgba("+h.color.r+", "+h.color.g+", "+h.color.b+", "+(1-_)+")",x.beginPath(),o&&h.shape.type==="path"&&typeof h.shape.path=="string"&&Array.isArray(h.shape.matrix))x.fill(xe(h.shape.path,h.shape.matrix,h.x,h.y,Math.abs(K-R)*.1,Math.abs(W-$)*.1,Math.PI/10*h.wobble));else if(h.shape.type==="bitmap"){var O=Math.PI/10*h.wobble,z=Math.abs(K-R)*.1,re=Math.abs(W-$)*.1,ue=h.shape.bitmap.width*h.scalar,ae=h.shape.bitmap.height*h.scalar,de=new DOMMatrix([Math.cos(O)*z,Math.sin(O)*z,-Math.sin(O)*re,Math.cos(O)*re,h.x,h.y]);de.multiplySelf(new DOMMatrix(h.shape.matrix));var ge=x.createPattern(f.transform(h.shape.bitmap),"no-repeat");ge.setTransform(de),x.globalAlpha=1-_,x.fillStyle=ge,x.fillRect(h.x-ue/2,h.y-ae/2,ue,ae),x.globalAlpha=1}else if(h.shape==="circle")x.ellipse?x.ellipse(h.x,h.y,Math.abs(K-R)*h.ovalScalar,Math.abs(W-$)*h.ovalScalar,Math.PI/10*h.wobble,0,2*Math.PI):G(x,h.x,h.y,Math.abs(K-R)*h.ovalScalar,Math.abs(W-$)*h.ovalScalar,Math.PI/10*h.wobble,0,2*Math.PI);else if(h.shape==="star")for(var Q=Math.PI/2*3,Se=4*h.scalar,Ae=8*h.scalar,Te=h.x,De=h.y,Fe=5,Pe=Math.PI/Fe;Fe--;)Te=h.x+Math.cos(Q)*Ae,De=h.y+Math.sin(Q)*Ae,x.lineTo(Te,De),Q+=Pe,Te=h.x+Math.cos(Q)*Se,De=h.y+Math.sin(Q)*Se,x.lineTo(Te,De),Q+=Pe;else x.moveTo(Math.floor(h.x),Math.floor(h.y)),x.lineTo(Math.floor(h.wobbleX),Math.floor($)),x.lineTo(Math.floor(K),Math.floor(W)),x.lineTo(Math.floor(R),Math.floor(h.wobbleY));return x.closePath(),x.fill(),h.tick<h.totalTicks}function Le(x,h,_,R,$){var K=h.slice(),W=x.getContext("2d"),O,z,re=d(function(ue){function ae(){O=z=null,W.clearRect(0,0,R.width,R.height),f.clear(),$(),ue()}function de(){r&&!(R.width===a.width&&R.height===a.height)&&(R.width=x.width=a.width,R.height=x.height=a.height),!R.width&&!R.height&&(_(x),R.width=x.width,R.height=x.height),W.clearRect(0,0,R.width,R.height),K=K.filter(function(ge){return Y(W,ge)}),K.length?O=m.frame(de):ae()}O=m.frame(de),z=ae});return{addFettis:function(ue){return K=K.concat(ue),re},canvas:x,promise:re,reset:function(){O&&m.cancel(O),z&&z()}}}function me(x,h){var _=!x,R=!!b(h||{},"resize"),$=!1,K=b(h,"disableForReducedMotion",Boolean),W=i&&!!b(h||{},"useWorker"),O=W?w():null,z=_?C:k,re=x&&O?!!x.__confetti_initialized:!1,ue=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion)").matches,ae;function de(Q,Se,Ae){for(var Te=b(Q,"particleCount",D),De=b(Q,"angle",Number),Fe=b(Q,"spread",Number),Pe=b(Q,"startVelocity",Number),Wn=b(Q,"decay",Number),zn=b(Q,"gravity",Number),Qn=b(Q,"drift",Number),Cs=b(Q,"colors",S),Yn=b(Q,"ticks",Number),Ps=b(Q,"shapes"),Xn=b(Q,"scalar"),Zn=!!b(Q,"flat"),Is=H(Q),_s=Te,es=[],Jn=x.width*Is.x,er=x.height*Is.y;_s--;)es.push(V({x:Jn,y:er,angle:De,spread:Fe,startVelocity:Pe,color:Cs[_s%Cs.length],shape:Ps[A(0,Ps.length)],ticks:Yn,decay:Wn,gravity:zn,drift:Qn,scalar:Xn,flat:Zn}));return ae?ae.addFettis(es):(ae=Le(x,es,z,Se,Ae),ae.promise)}function ge(Q){var Se=K||b(Q,"disableForReducedMotion",Boolean),Ae=b(Q,"zIndex",Number);if(Se&&ue)return d(function(Pe){Pe()});_&&ae?x=ae.canvas:_&&!x&&(x=N(Ae),document.body.appendChild(x)),R&&!re&&z(x);var Te={width:x.width,height:x.height};O&&!re&&O.init(x),re=!0,O&&(x.__confetti_initialized=!0);function De(){if(O){var Pe={getBoundingClientRect:function(){if(!_)return x.getBoundingClientRect()}};z(Pe),O.postMessage({resize:{width:Pe.width,height:Pe.height}});return}Te.width=Te.height=null}function Fe(){ae=null,R&&($=!1,t.removeEventListener("resize",De)),_&&x&&(document.body.contains(x)&&document.body.removeChild(x),x=null,re=!1)}return R&&!$&&($=!0,t.addEventListener("resize",De,!1)),O?O.fire(Q,Te,Fe):de(Q,Te,Fe)}return ge.reset=function(){O&&O.reset(),ae&&ae.reset()},ge}var y;function M(){return y||(y=me(null,{useWorker:!0,resize:!0})),y}function xe(x,h,_,R,$,K,W){var O=new Path2D(x),z=new Path2D;z.addPath(O,new DOMMatrix(h));var re=new Path2D;return re.addPath(z,new DOMMatrix([Math.cos(W)*$,Math.sin(W)*$,-Math.sin(W)*K,Math.cos(W)*K,_,R])),re}function ye(x){if(!o)throw new Error("path confetti are not supported in this browser");var h,_;typeof x=="string"?h=x:(h=x.path,_=x.matrix);var R=new Path2D(h),$=document.createElement("canvas"),K=$.getContext("2d");if(!_){for(var W=1e3,O=W,z=W,re=0,ue=0,ae,de,ge=0;ge<W;ge+=2)for(var Q=0;Q<W;Q+=2)K.isPointInPath(R,ge,Q,"nonzero")&&(O=Math.min(O,ge),z=Math.min(z,Q),re=Math.max(re,ge),ue=Math.max(ue,Q));ae=re-O,de=ue-z;var Se=10,Ae=Math.min(Se/ae,Se/de);_=[Ae,0,0,Ae,-Math.round(ae/2+O)*Ae,-Math.round(de/2+z)*Ae]}return{type:"path",path:h,matrix:_}}function Be(x){var h,_=1,R="#000000",$='"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color", "Android Emoji", "Twemoji Mozilla", "system emoji", sans-serif';typeof x=="string"?h=x:(h=x.text,_="scalar"in x?x.scalar:_,$="fontFamily"in x?x.fontFamily:$,R="color"in x?x.color:R);var K=10*_,W=""+K+"px "+$,O=new OffscreenCanvas(K,K),z=O.getContext("2d");z.font=W;var re=z.measureText(h),ue=Math.ceil(re.actualBoundingBoxRight+re.actualBoundingBoxLeft),ae=Math.ceil(re.actualBoundingBoxAscent+re.actualBoundingBoxDescent),de=2,ge=re.actualBoundingBoxLeft+de,Q=re.actualBoundingBoxAscent+de;ue+=de+de,ae+=de+de,O=new OffscreenCanvas(ue,ae),z=O.getContext("2d"),z.font=W,z.fillStyle=R,z.fillText(h,ge,Q);var Se=1/_;return{type:"bitmap",bitmap:O.transferToImageBitmap(),matrix:[Se,0,0,Se,-ue*Se/2,-ae*Se/2]}}s.exports=function(){return M().apply(this,arguments)},s.exports.reset=function(){M().reset()},s.exports.create=me,s.exports.shapeFromPath=ye,s.exports.shapeFromText=Be})(function(){return typeof window<"u"?window:typeof self<"u"?self:this||{}}(),As,!1);const yi=As.exports;As.exports.create;const Ei={particleCount:350,spread:120,origin:{y:.6},angle:90},vi={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},Yt=e=>{let t=vi[e];t||(t={});const s={...Ei,...t};yi(s)},Si=()=>{const[e]=ce.useTheme(),{mutate:t,isPending:s}=Ns(),{mutateAsync:r,isPending:a}=kn(),i=()=>{r({settings:{theme:e}})},o=()=>{t({ids:["THEME"]},{onSuccess:()=>{Yt("BOTTOM_RIGHT")}})};return n.jsxs("div",{className:"bg-white py-3 flex items-center justify-center gap-x-3 border-t",children:[n.jsx(c.Button,{size:"sm",variant:"outline",disabled:s||a,onClick:i,children:"Save draft"}),n.jsx(c.Button,{size:"sm",disabled:s||a,onClick:o,children:"Publish"})]})},le={...ce.PERMISSIONS,ADD_PAGE:"add_page",EDIT_PAGE:"edit_page",EDIT_SLUG:"edit_slug",DELETE_PAGE:"delete_page",PUBLISH_PAGE:"publish_page",UNPUBLISH_PAGE:"unpublish_page",SAVE_AS_TEMPLATE:"save_as_template",ADD_PARTIAL:"add_partial",EDIT_PARTIAL:"edit_partial",DELETE_PARTIAL:"delete_partial",PUBLISH_PARTIAL:"publish_partial",UNPUBLISH_PARTIAL:"unpublish_partial",EDIT_SEO:"edit_seo",RESTORE_REVISION:"restore_revision",DELETE_REVISION:"delete_revision",PUBLISH_THEME:"publish_theme",EDIT_SETTINGS:"edit_settings",ADD_LIBRARY_BLOCK:"add_library_block",ADD_LIBRARY_TEMPLATE:"add_library_template",EDIT_LIBRARY_BLOCK:"edit_library_block",EDIT_LIBRARY_TEMPLATE:"edit_library_template",DELETE_LIBRARY_BLOCK:"delete_library_block",DELETE_LIBRARY_TEMPLATE:"delete_library_template",ADD_MEDIA:"add_media",EDIT_MEDIA:"edit_media",DELETE_MEDIA:"delete_media"},bi=({page:e,onClose:t})=>{const[s,r]=v.useState(e.slug||""),{mutate:a,isPending:i}=pi(),{data:o}=ve(),l=g.find(o,{key:e==null?void 0:e.pageType}),u=f=>{if(f.preventDefault(),!(e!=null&&e.primaryPage)&&Object.keys(Ce).some(E=>s===`/${E}`||g.startsWith(s,`/${E}/`))){ie.toast.error("Error",{description:"Slugs cannot start with a language code for primary page"});return}a({...e,slug:s},{onSuccess:t})},d=(e==null?void 0:e.lang)||"";return n.jsx(c.Dialog,{open:!!e,onOpenChange:t,children:n.jsxs(c.DialogContent,{children:[n.jsxs(c.DialogHeader,{children:[n.jsx(c.DialogTitle,{children:"Change Slug"}),n.jsx(c.DialogDescription,{className:"text-xs",children:n.jsxs(c.Alert,{variant:"destructive",className:"mt-2",children:[n.jsx(I.AlertCircle,{className:"h-4 w-4"}),"Changing the slug may have impact on your SEO. Please proceed with caution."]})})]}),n.jsxs("form",{onSubmit:u,children:[n.jsxs("div",{className:"space-y-4 py-4 text-sm ",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{children:[n.jsx("span",{children:"Type:"}),n.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(l==null?void 0:l.name)||(e==null?void 0:e.pageType)]})]}),n.jsxs("div",{children:[n.jsx("span",{children:"Name:"}),n.jsxs("span",{className:"font-medium text-gray-600",children:[" ",e.name]})]})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs(c.Label,{htmlFor:"slug",className:"text-right",children:["Slug"," ",n.jsxs("small",{className:"font-light text-gray-500",children:["Slug should start with /",d]})]}),n.jsx(c.Input,{id:"slug",value:s,onChange:f=>{const m=f.target.value;g.startsWith(m,`/${d}`)&&r(m)},className:"col-span-3",required:!0,pattern:"^/.*",title:"Slug must start with /",placeholder:"Enter page slug"})]})]}),n.jsx(c.DialogFooter,{children:n.jsx(c.Button,{type:"submit",disabled:i||!g.startsWith(s,`/${d}`)||g.isEqual(e==null?void 0:e.slug,s),children:i?"Changing...":"Change Slug"})})]})]})})};function Hn({page:e,onClose:t}){const[,s]=je(),{mutate:r,isPending:a}=gi(),{data:i}=ve(),o=()=>{r(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(u=>u.key===(e==null?void 0:e.pageType));return n.jsx(c.Dialog,{open:!!e,onOpenChange:t,children:n.jsxs(c.DialogContent,{children:[n.jsxs(c.DialogHeader,{children:[n.jsx(c.DialogTitle,{children:"Confirm Deletion"}),n.jsxs(c.DialogDescription,{className:"py-4 text-slate-500",children:[n.jsxs("div",{children:["Are you sure you want to remove ",n.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&&n.jsxs("div",{className:"py-2 text-sm",children:["Language:"," ",n.jsx("span",{className:"font-medium text-gray-500",children:g.get(Ce,e.lang,e.lang)})]})]})]}),n.jsxs(c.DialogFooter,{children:[n.jsx(c.Button,{variant:"outline",onClick:t,children:"Cancel"}),n.jsx(c.Button,{variant:"destructive",disabled:a,onClick:o,children:a?"Deleting...":"Delete"})]})]})})}const we=({permission:e,permissions:t,children:s,fallback:r=null})=>{const{hasPermission:a}=ce.usePermissions();return e&&!a(e)||t&&!t.some(i=>a(i))?r:s},Ts=({page:e,onClose:t})=>{const{mutate:s,isPending:r}=xi(),a=async()=>{s(e,{onSuccess:t})};return n.jsx(c.Dialog,{open:!!e,onOpenChange:t,children:n.jsxs(c.DialogContent,{children:[n.jsxs(c.DialogHeader,{children:[n.jsx(c.DialogTitle,{children:"Confirm action"}),n.jsxs(c.DialogDescription,{children:[q.UNPUBLISH_MSG," ",n.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)}),"?"]})]}),n.jsxs(c.DialogFooter,{children:[n.jsx(c.Button,{variant:"outline",onClick:t,children:"Cancel"}),n.jsx(c.Button,{variant:"destructive",disabled:r,onClick:a,children:r?q.UPDATING:q.UNPUBLISH})]})]})})},qn=({langProps:e,onClose:t,languages:s})=>{const{data:r}=be(),{data:a}=ve(),[i,o]=v.useState(e.name||""),[l,u]=v.useState(e.edit?e.lang:""),[d,f]=v.useState(e.edit?e.slug:""),{mutate:m,isPending:w}=Fn(),{mutate:E,isPending:p}=js(),j=v.useMemo(()=>a==null?void 0:a.find(T=>T.key===e.pageType),[a,e.pageType]),b=!(j!=null&&j.hasSlug),D=w||p,A=T=>{T.preventDefault();const S={name:i,lang:l,primaryPage:r==null?void 0:r.id,slug:d,pageType:r==null?void 0:r.pageType};S.pageType=e.pageType,e.edit&&(S.id=e==null?void 0:e.id),e.edit?E(S,{onSuccess:t}):m(S,{onSuccess:t})};return n.jsx(c.Dialog,{open:!!e,onOpenChange:t,children:n.jsxs(c.DialogContent,{className:"sm:max-w-[425px] text-slate-600",children:[n.jsxs(c.DialogHeader,{children:[n.jsx(c.DialogTitle,{children:e.edit?q.EDIT_LANGUAGE:q.ADD_NEW_LANGUAGE}),n.jsx(c.DialogDescription,{className:"font-light",children:q.ENTER_LANGUAGE_DETAILS})]}),n.jsxs("form",{onSubmit:A,children:[n.jsxs("div",{className:"grid gap-4 py-4",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(c.Label,{htmlFor:"lang",className:"text-right",children:q.LANGUAGE}),n.jsxs("select",{value:l,disabled:e.edit||g.isEmpty(s),onChange:T=>{const S=T.target.value;u(S),!b&&f(`/${S}`)},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:[n.jsx("option",{value:"",disabled:!0,selected:!0,children:e.edit?g.get(Ce,e.lang,e.lang):g.isEmpty(s)?q.ALL_AVAILABLE_LANGUAGE_PAGE:q.CHOOSE_LANGUAGE}),g.map(s,T=>n.jsx("option",{value:T,children:g.get(Ce,T,T)},T))]})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(c.Label,{htmlFor:"slug",className:"text-right",children:q.PAGE_NAME}),n.jsx(c.Input,{id:"name",value:i,onChange:T=>o(T.target.value),className:"col-span-3",required:!0,placeholder:q.ENTER_PAGE_NAME})]}),!b&&n.jsxs("div",{className:"space-y-1",children:[n.jsxs(c.Label,{htmlFor:"slug",className:"text-right",children:[q.SLUG," ",n.jsx("small",{className:"font-light",children:q.SLUG_SHOULD_START_WITH})]}),n.jsx(c.Input,{id:"slug",value:d,onChange:T=>{const S=T.target.value;g.startsWith(S,`/${l}`)&&f(g.toLower(g.trim(S)))},className:"col-span-3",required:!0,pattern:"^/.*",disabled:g.isEmpty(l),title:q.SLUG_MUST_START_WITH,placeholder:g.isEmpty(l)?q.CHOOSE_LANGUAGE_TO_ADD_SLUG:q.ENTER_PAGE_SLUG})]})]}),n.jsx(c.DialogFooter,{children:n.jsx(c.Button,{type:"submit",disabled:D||!i||!l||!b&&!g.startsWith(d,`/${l}`),children:D?e.edit?q.UPDATING:q.ADDING:e.edit?q.UPDATE:q.ADD_NEW_LANGUAGE})})]})]})})},wi=()=>{const[e,t]=v.useState(null),{selectedLang:s,fallbackLang:r,setSelectedLang:a}=ce.useLanguages(),{data:i,isFetching:o}=mt(),{data:l}=be(),[u,d]=v.useState(null),[f,m]=v.useState(null),[w,E]=v.useState(null),{data:p}=ft(),j=g.filter(g.get(p,"languages")||["en"],b=>!g.find(i,{lang:b})&&b!==g.get(p,"fallbackLang"));return n.jsxs("div",{className:"space-y-4 pt-2",children:[n.jsx("ul",{className:"space-y-2 mt-4",children:o?n.jsxs("div",{className:"w-full space-y-3 py-4",children:[n.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),n.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),n.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"})]}):g.map(i,b=>{const D=b.lang,A=b.slug,T=!b.primaryPage,S=D===s;return n.jsxs(n.Fragment,{children:[n.jsxs("li",{className:`text-slate-500 w-full p-2 rounded cursor-pointer flex items-center justify-between ${S?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>a(D),children:[n.jsxs("div",{className:" flex-1 gap-x-3",children:[n.jsxs("div",{className:"text-[13px] text-slate-800 flex items-center gap-x-2",children:[n.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${b.online?"bg-green-300":"bg-gray-300"}`}),g.get(Ce,T?r:D,D)]}),n.jsxs("div",{children:[A&&n.jsxs("div",{className:"text-[11px] text-slate-600 font-light",children:["Slug: ",n.jsx("b",{className:"font-medium",children:A})]}),n.jsxs("div",{className:"text-[11px] text-slate-600 font-light",children:["Name:",n.jsxs("b",{className:"font-medium",children:[" ",b.name," "]})]})]})]}),T?n.jsxs("div",{className:"flex items-center text-[11px] text-orange-500 gap-x-1",children:[n.jsx(I.StarIcon,{fill:"orange",className:"w-3 h-3"}),n.jsx("b",{children:" Primary"})]}):n.jsx("div",{className:"flex items-center gap-x-3",children:n.jsx(we,{permissions:[le.EDIT_PAGE,le.DELETE_PAGE,le.UNPUBLISH_PAGE],children:n.jsxs(c.DropdownMenu,{children:[n.jsx(c.DropdownMenuTrigger,{asChild:!0,onClick:P=>P.stopPropagation(),children:n.jsx(c.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:n.jsx(I.MoreHorizontal,{className:"h-4 w-4"})})}),n.jsxs(c.DropdownMenuContent,{align:"end",className:"text-sm",children:[n.jsx(we,{permissions:[le.EDIT_PAGE],children:n.jsxs(c.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:P=>{P.stopPropagation(),t({...b,edit:!0})},children:[n.jsx(I.PencilIcon,{className:"size-3"}),q.EDIT]})}),n.jsx(we,{permissions:[le.UNPUBLISH_PAGE],children:(b==null?void 0:b.online)&&n.jsxs(c.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:P=>{P.stopPropagation(),m(b)},children:[n.jsx(I.Power,{className:"size-3"}),q.UNPUBLISH]})}),n.jsx(we,{permissions:[le.DELETE_PAGE],children:n.jsxs(c.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:P=>{P.stopPropagation(),d(b)},children:[n.jsx(I.TrashIcon,{className:"size-3"}),q.DELETE]})})]})]})})})]},b.id),n.jsx("div",{className:"h-1 w-full border-b"})]})})}),n.jsx(we,{permissions:[le.ADD_PAGE],children:n.jsx("div",{className:"flex justify-center w-full",children:n.jsx(c.Button,{variant:"default",size:"sm",disabled:g.isEmpty(j),onClick:()=>{t({name:l==null?void 0:l.name,pageType:l==null?void 0:l.pageType,lang:"",slug:"",edit:!1})},children:q.ADD_NEW_LANGUAGE})})}),e&&n.jsx(qn,{languages:j,langProps:e,onClose:()=>t(null)}),u&&n.jsx(Hn,{page:u,onClose:()=>d(null)}),f&&n.jsx(Ts,{page:f,onClose:()=>m(null)}),w&&n.jsx(bi,{page:w,onClose:()=>E(null)})]})};function ji({addEditPage:e,additionalPageTypes:t=[],close:s}){var Le,me;const r=!!(e!=null&&e.id),{data:a}=Mt(),{mutate:i,isPending:o}=Fn(),{mutate:l,isPending:u}=js(),[d,f]=v.useState(null),[m,w]=v.useState((e==null?void 0:e.pageType)??"page"),[E,p]=v.useState(t.find(y=>y.key===m)),[j,b]=v.useState((e==null?void 0:e.parent)??""),[D,A]=v.useState((e==null?void 0:e.name)??""),[T,S]=v.useState(((e==null?void 0:e.slug)??"").split("/").pop()||""),[P,H]=v.useState((e==null?void 0:e.dynamic)??!1),C=o||u,k=t.find(y=>y.key===m),N=y=>{w(y),b(""),S(""),H(!1),p(t.find(M=>M.key===y))},G=y=>{H(y),y&&S("")},V=y=>{if(b(y),y&&y!=="none"){const M=a==null?void 0:a.find(ye=>ye.id===y),xe=(M==null?void 0:M.slug)||"";if(T.startsWith(xe)){const ye=T.slice(xe.length).replace(/^\/+/,"");S(ye)}else S(T.replace(/^\/+/,""))}else S(T?`${T}`:"")},Y=y=>{if(y.preventDefault(),T.length>0&&!P&&!T.match(/^[a-zA-Z0-9-_]+$/)){f("Slug can only contain letters, numbers, and hyphens");return}if(P&&T!==""){f("Slug must be empty when using dynamic slug");return}if(!D.trim()){ie.toast.error("Name is required");return}if(!(E!=null&&E.hasSlug)){const M={pageType:E==null?void 0:E.key,name:D,slug:"",hasSlug:!1};if(r){l({id:e==null?void 0:e.id,name:D},{onSuccess:()=>{ie.toast.success((E==null?void 0:E.name)+" updated successfully"),s()}});return}i(M,{onSuccess:()=>{ie.toast.success((E==null?void 0:E.name)+" created successfully"),s()}});return}if(j&&j!=="none"){if(!T.trim()&&!P){ie.toast.error("Child page slug is required");return}const M=a==null?void 0:a.find(_=>_.id===j),xe=(M==null?void 0:M.slug)||"",ye=xe==="/"?`/${T}`:`${xe}/${T}`;if(Object.keys(Ce).some(_=>ye===`/${_}`||(ye==null?void 0:ye.startsWith(`/${_}/`)))){ie.toast.error("Slugs cannot start with a language code for primary page");return}const h={pageType:m,name:D,slug:ye.replace(/\/$/,""),parent:j,dynamic:P,hasSlug:!0};if(r){l({id:e==null?void 0:e.id,...h},{onSuccess:()=>{ie.toast.success("Page updated successfully"),s()}});return}i(h,{onSuccess:()=>{ie.toast.success("Page created successfully"),s()}})}else{const M={pageType:m,name:D,slug:T===""?"/":`/${T.replace(/\/$/,"")}`};if(r){l({id:e==null?void 0:e.id,...M},{onSuccess:()=>{ie.toast.success("Page updated successfully"),s()}});return}i(M,{onSuccess:()=>{ie.toast.success("Page created successfully"),s()}})}};return E!=null&&E.hasSlug?(console.log(a),n.jsxs("form",{onSubmit:Y,className:"w-full max-w-md mx-auto space-y-4",children:[n.jsxs("div",{className:"space-y-0.5",children:[n.jsx(c.Label,{htmlFor:"pageType",className:"text-sm",children:"Page Type"}),n.jsxs("select",{id:"pageType",value:m,disabled:r,onChange:y=>N(y.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${r?"cursor-not-allowed text-gray-500":""}`,children:[n.jsx("optgroup",{label:"Pages",children:t.filter(y=>y.hasSlug!==!1).map(y=>n.jsx("option",{value:y.key,children:y.name},y.key))}),n.jsx("optgroup",{label:"Partials",children:t.filter(y=>y.hasSlug===!1).map(y=>n.jsx("option",{value:y.key,children:y.name},y.key))})]})]}),n.jsxs("div",{className:"space-y-0.5",children:[n.jsx(c.Label,{htmlFor:"parentPage",className:"text-sm",children:"Parent"}),n.jsxs("select",{id:"parentPage",value:j,onChange:y=>V(y.target.value),className:"w-full rounded-md border border-gray-300 px-3 py-2",children:[n.jsx("option",{value:"none",children:"None"}),a==null?void 0:a.filter(y=>!g.isEmpty(y.slug)).filter(y=>y.slug!=="/").sort((y,M)=>y.name.localeCompare(M.name)).map(y=>n.jsxs("option",{value:y.id,children:[y.name," (",y.slug,")"]},y.id))]})]}),n.jsxs("div",{className:"space-y-0.5",children:[n.jsx(c.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),n.jsx(c.Input,{id:"name",value:D,onChange:y=>A(y.target.value),required:!0,"aria-required":"true"})]}),(k==null?void 0:k.dynamicSegments)&&j&&j!=="none"&&n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"useDynamicSlug",checked:P,onChange:y=>G(y.target.checked),className:"rounded border-gray-300"}),n.jsx(c.Label,{htmlFor:"useDynamicSlug",className:"text-sm",children:"Use Dynamic Slug"})]}),P&&n.jsxs("div",{className:"text-sm text-gray-500",children:["Pages will use pattern: ",k==null?void 0:k.dynamicSlug]})]}),(!(k!=null&&k.dynamicSegments)||!P)&&n.jsxs("div",{className:"space-y-0.5",children:[n.jsxs(c.Label,{htmlFor:"slug",className:"text-sm",children:["Slug",j&&j!=="none"&&n.jsxs("span",{className:"ml-2 text-sm text-gray-500",children:["Parent:"," ",(me=a==null?void 0:a.find(y=>y.id===j))==null?void 0:me.slug]})]}),n.jsx(c.Input,{id:"slug",value:T,onChange:y=>S(y.target.value),placeholder:j&&j!=="none"?"Enter page slug":m==="page"?"Leave empty for home page":"Required - e.g. /your-slug"}),d&&n.jsx("p",{className:"text-xs text-red-500",children:d})]}),n.jsx(c.Button,{disabled:C,type:"submit",className:"w-full",children:r?C?"Updating...":"Update page":C?"Creating...":"Create Page"})]})):n.jsxs("form",{onSubmit:Y,className:"w-full max-w-md mx-auto space-y-4",children:[n.jsxs("div",{className:"space-y-0.5",children:[n.jsx(c.Label,{htmlFor:"pageType",className:"text-sm",children:"Page Type"}),n.jsxs("select",{id:"pageType",value:m,disabled:r,onChange:y=>N(y.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${r?"cursor-not-allowed text-gray-500":""}`,children:[n.jsx("optgroup",{label:"Pages",children:t.filter(y=>y.hasSlug!==!1).map(y=>n.jsx("option",{value:y.key,children:y.name},y.key))}),n.jsx("optgroup",{label:"Partials",children:t.filter(y=>y.hasSlug===!1).map(y=>n.jsx("option",{value:y.key,children:y.name},y.key))})]}),n.jsx("p",{className:"text-sm text-gray-500",children:(Le=t.find(y=>y.key===m))==null?void 0:Le.helpText})]}),n.jsxs("div",{className:"space-y-0.5",children:[n.jsx(c.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),n.jsx(c.Input,{id:"name",value:D,onChange:y=>A(y.target.value),required:!0,"aria-required":"true"})]}),n.jsx(c.Button,{disabled:C,type:"submit",className:"w-full",children:r?C?"Updating...":"Update "+(E==null?void 0:E.name):C?"Creating...":"Create "+(E==null?void 0:E.name)})]})}const Ni=({addEditPage:e,setAddEditPage:t})=>{const{data:s}=ve(),r=!!(e!=null&&e.id);return n.jsx(c.Dialog,{open:!!e,onOpenChange:()=>t(void 0),children:n.jsxs(c.DialogContent,{className:"sm:max-w-[425px]",children:[n.jsxs(c.DialogHeader,{children:[n.jsxs(c.DialogTitle,{children:[r?"Edit":"Add New"," "]}),n.jsx(c.DialogDescription,{children:r?"Update your page name":"Enter details to create a new page"})]}),n.jsx(ji,{addEditPage:e,close:()=>t(void 0),additionalPageTypes:s??[]})]})})},as=({parentSlug:e,page:t,active:s,changeActivePage:r,setUnpublishPage:a,setDeletePage:i,setAddEditPage:o,setSaveAsTemp:l})=>{const{data:u}=ve(),{hasPermission:d}=ce.usePermissions(),f=v.useMemo(()=>g.find(u,{key:t.pageType}),[u,t.pageType]),m=g.get(t,"slug").replace(e,"")||"/",w=!d(le.EDIT_PAGE)&&!d(le.DELETE_PAGE)&&!d(le.UNPUBLISH_PAGE);return n.jsxs("div",{onClick:()=>r(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:[n.jsxs("div",{className:"flex items-center gap-x-2",children:[t.dynamic?n.jsx("div",{className:"w-4 h-4 text-slate-500 stroke-[1]",children:n.jsx(I.StarsIcon,{className:"w-4 h-4 text-yellow-400"})}):f!=null&&f.icon?n.jsx("div",{className:"w-4 h-4 text-slate-500 stroke-[1]",dangerouslySetInnerHTML:{__html:f.icon}}):f!=null&&f.hasSlug?n.jsx(I.File,{className:"w-4 h-4 text-slate-500 stroke-[1]"}):n.jsx(I.Globe,{className:"w-4 h-4 text-slate-500 stroke-[1]"}),n.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),n.jsx("span",{className:"font-light leading-none truncate text-slate-800",children:g.startCase(t.name)??""}),f!=null&&f.hasSlug?n.jsxs(c.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:[m,t.dynamic&&n.jsx("span",{className:"text-xs font-light leading-none text-slate-500",children:g.endsWith(m,"/")?`${f==null?void 0:f.dynamicSlug}`:`/${f==null?void 0:f.dynamicSlug}`})]}):n.jsx(c.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:f==null?void 0:f.name})]}),n.jsx("div",{className:"flex items-center space-x-4",children:!w&&n.jsxs(c.DropdownMenu,{children:[n.jsx(c.DropdownMenuTrigger,{asChild:!0,onClick:E=>E.stopPropagation(),children:n.jsx(I.MoreHorizontal,{className:"h-4 w-4 hover:stroke-[3]"})}),n.jsxs(c.DropdownMenuContent,{align:"end",className:"text-sm",children:[d(le.EDIT_PAGE)&&n.jsxs(c.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:E=>{E.stopPropagation(),o({...t,global:!(f!=null&&f.hasSlug)})},children:[n.jsx(I.Pencil,{className:"size-3"}),"Edit"]}),(t==null?void 0:t.online)&&d(le.UNPUBLISH_PAGE)&&n.jsxs(c.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:E=>{E.stopPropagation(),a(t)},children:[n.jsx(I.Power,{className:"size-3"}),q.UNPUBLISH]}),d(le.DELETE_PAGE)&&n.jsxs(c.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:E=>{E.stopPropagation(),i(t)},children:[n.jsx(I.Trash,{className:"size-3"}),q.DELETE]}),d(le.SAVE_AS_TEMPLATE)&&n.jsxs(c.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:E=>{E.stopPropagation(),l(t)},children:[n.jsx(I.SquareLibrary,{className:"size-3"}),q.SAVE_AS_TEMPLATE]})]})]})})]})},Ai=({close:e})=>{const[,t]=v.useState([]),[s,r]=v.useState(""),[a,i]=v.useState(null),[o,l]=v.useState(null),[u,d]=v.useState(null),{data:f,isFetching:m}=Mt(),[w,E]=v.useState(""),{hasPermission:p}=ce.usePermissions(),[j,b]=v.useState(null),[D,A]=je(),T=D.get("page"),{data:S}=ve(),P=v.useCallback(N=>{var G;return(G=g.find(S,{key:N}))==null?void 0:G.hasSlug},[S]);v.useEffect(()=>{if(!g.isEmpty(w))return;const N=sessionStorage.getItem("pageTypeFilter")||"all";!g.isEmpty(S)&&N&&(g.find(S,{key:N})?E(N):E("all"))},[S,w]);const H=N=>{E(N),sessionStorage.setItem("pageTypeFilter",N)},C=v.useCallback(N=>{const V=new URLSearchParams(window.location.search).get("lang"),Y=new URLSearchParams({page:N});V&&Y.set("lang",V),window.history.pushState({},"",`?${Y.toString()}`),A(Y),window.dispatchEvent(new PopStateEvent("popstate")),e()},[A,e]);v.useEffect(()=>{if(T&&!m){const N=g.find(f,{id:T});N&&(N!=null&&N.pageType)?t(G=>[...G,N==null?void 0:N.pageType]):(window.history.replaceState(null,"","/"),A(new URLSearchParams({})),window.dispatchEvent(new PopStateEvent("popstate")))}},[f,T,m,A]);const k=v.useMemo(()=>{const N=g.filter(f,y=>g.isEmpty(s)?!0:g.includes(g.toLower(y==null?void 0:y.name),g.toLower(s))||g.includes(g.toLower(y==null?void 0:y.slug),g.toLower(s)));if(w!=="all")return g.filter(N,{pageType:w});const G=new Map;N.forEach(y=>{G.set(y.id,{...y,children:[]})});const V=[],Y=[];G.forEach(y=>{if(y.parent){const M=G.get(y.parent);M?M.children.push(y):V.push(y)}else Y.push(y)}),V.sort((y,M)=>y.name.localeCompare(M.name)),V.forEach(y=>{y.children.sort((M,xe)=>M.name.localeCompare(xe.name))});const Le=g.filter(Y,y=>!P(y.pageType)),me=g.filter(Y,y=>P(y.pageType)).sort((y,M)=>y.name.localeCompare(M.name));return g.compact([...me,...Le,...V])},[f,P,s,w]);return n.jsxs("div",{className:"flex flex-col justify-between h-full",children:[n.jsxs("div",{className:"flex flex-col h-full space-y-6",children:[n.jsxs("div",{className:"relative flex item-center gap-x-4",children:[n.jsx(I.Search,{strokeWidth:2.5,className:"absolute left-3 top-2.5 h-4 w-4 text-gray-400"}),n.jsx(c.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:N=>r(N.target.value)}),!g.isEmpty(w)&&n.jsxs(c.Select,{value:w,onValueChange:H,children:[n.jsx(c.SelectTrigger,{className:`${w==="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:n.jsx(c.SelectValue,{placeholder:"Select page type"})}),n.jsx(c.SelectContent,{align:"end",children:g.map(g.concat([{key:"all",name:"All"}],S),N=>n.jsx(c.SelectItem,{value:g.get(N,"key"),children:g.get(N,"name")}))})]})]}),m?n.jsx("div",{className:"space-y-2",children:g.map([...Array(5).keys()],N=>n.jsx("div",{className:"w-full bg-gray-200 rounded h-9 animate-pulse"},N))}):g.isEmpty(k)?n.jsxs("div",{className:"h-[70vh] flex flex-col gap-y-1 items-center justify-center text-slate-500 text-sm font-medium",children:[n.jsx(I.File,{className:"h-6 w-6 stroke-[1]"}),"Empty List!",n.jsx("span",{className:"font-light",children:"Add new page to start"})]}):n.jsx("div",{className:"text-sm text-slate-700 space-y-2 h-[70vh] overflow-y-auto",children:g.map(k,N=>g.isEmpty(N==null?void 0:N.children)?n.jsx(as,{changeActivePage:C,setUnpublishPage:l,setDeletePage:i,setAddEditPage:d,active:T===N.id,page:N,setSaveAsTemp:b},N.id):n.jsxs("div",{className:"border-0",children:[n.jsx(as,{changeActivePage:C,setUnpublishPage:l,setDeletePage:i,setAddEditPage:d,active:T===N.id,page:N,setSaveAsTemp:b}),n.jsx("div",{className:"pt-2 pl-6 bg-white",children:g.map(g.get(N,"children",[]),G=>{const V=T===g.get(G,"id");return n.jsx(as,{parentSlug:N.slug,changeActivePage:C,setUnpublishPage:l,setDeletePage:i,setAddEditPage:d,active:V,page:G,setSaveAsTemp:b},G.id)})})]},N.key))})]}),p(le.ADD_PAGE)&&n.jsxs(c.Button,{className:"flex text-sm gap-x-2",onClick:()=>{d({slug:"",name:"",pageType:w==="all"?"page":w})},children:[n.jsx(I.Plus,{className:"w-4 h-4"})," Add New"]}),u&&n.jsx(Ni,{editPage:C,addEditPage:u,setAddEditPage:d}),a&&n.jsx(Hn,{page:a,onClose:()=>i(null)}),o&&n.jsx(Ts,{page:o,onClose:()=>l(null)}),j&&n.jsx(Bn,{page:j,onClose:()=>b(null)})]})},Ti=()=>{const e=Ne("logo",null);return e?n.jsx("div",{className:"w-full max-h-9 overflow-hidden pr-2",children:v.createElement(e,{})}):null},Ci=()=>{const[e]=je(),t=e.get("page"),{data:s,isFetching:r}=be(),[a,i]=v.useState(!1),o=!!t&&!g.isEmpty(s),l=!t||!r&&g.isEmpty(s)||a;return n.jsxs(n.Fragment,{children:[n.jsxs(c.Button,{variant:"secondary",className:"flex items-center w-full space-x-2 py-1",onClick:()=>i(!0),children:[n.jsx("div",{children:n.jsx(I.Logs,{className:"h-4 w-4"})}),n.jsxs("span",{className:"truncate leading-tight flex items-center max-w-[200px]",children:[n.jsx("span",{className:"text-slate-600 pr-1 font-light",children:"Editing:"}),r?n.jsx(I.Loader,{className:"h-4 w-4 animate-spin text-slate-400 ml-2"}):g.startCase(g.get(s,"name"))??""]})]},"template-viewer"),n.jsx(c.Sheet,{open:l,onOpenChange:u=>!u&&o&&i(!1),children:n.jsxs(c.SheetContent,{side:"left",className:`!max-w-screen-md z-50 border-border w-full ${o?"":"sheet-hide-close-btn"}`,children:[n.jsx(c.SheetHeader,{className:"mb-3",children:n.jsxs(c.SheetTitle,{className:"text-sm flex items-center gap-2 font-semibold",children:[n.jsx("div",{className:"p-2 rounded-md bg-primary text-primary-foreground",children:n.jsx(I.File,{className:"w-6 h-6"})}),n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{className:"text-sm font-semibold",children:"Pages"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Manage your site structure"})]})]})}),n.jsx("div",{className:"h-[calc(100vh-100px)] overflow-y-auto",children:n.jsx(Ai,{close:()=>i(!1)})})]})})]})},Pi=()=>{const{fallbackLang:e,languages:t,selectedLang:s,setSelectedLang:r}=ce.useLanguages(),a=g.isEmpty(s)?e:s,[,i]=je();v.useEffect(()=>{const p=new URLSearchParams(window.location.search),j=p.get("lang");j&&(t.includes(j)?r(j):(p.delete("lang"),i(p),r("")))},[t,i,r]);const[o,l]=v.useState(null),{data:u}=be(),{data:d}=ft(),{data:f,isFetching:m}=mt(),w=v.useMemo(()=>{const p=g.compact(g.map(g.get(d,"languages"),j=>{const b=g.find(f,{lang:j});return{key:j,value:g.get(Ce,j,j),isLangPageAdded:!!b}})).filter(Boolean);return[{key:e,value:g.get(Ce,e),isLangPageAdded:!0},...p]},[e,f,d]),E=p=>{r(p);const j=new URLSearchParams(window.location.search);p===e?j.delete("lang"):j.set("lang",p);const b=j.toString(),D=`${window.location.pathname}${b?`?${b}`:""}`;window.history.pushState({},"",D),i(j),window.dispatchEvent(new PopStateEvent("popstate"))};return g.isEmpty(t)||m?null:n.jsxs(n.Fragment,{children:[n.jsxs(c.DropdownMenu,{children:[n.jsx(c.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:n.jsxs(c.Button,{variant:"ghost",size:"sm",className:"gap-2",children:[n.jsx(I.Languages,{className:"w-4 h-4"}),g.get(Ce,a,a),n.jsx(I.ChevronDown,{className:"w-4 h-4"})]})}),n.jsxs(c.DropdownMenuContent,{className:"border-border space-y-1",children:[g.map(w.filter(p=>p.isLangPageAdded),p=>n.jsxs(c.DropdownMenuItem,{className:ce.mergeClasses("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",p.key===a&&"!bg-gray-200 text-gray-700"),onClick:()=>E(p.key),children:[n.jsx("div",{className:"text-slate-600",children:p.value}),p.key===e&&n.jsxs("small",{className:"text-[9px] flex items-center gap-x-1 text-orange-500 leading-none",children:[n.jsx(I.Star,{fill:"orange",className:"w-2 h-2"}),"Primary"]})]},p.value)),!g.isEmpty(w.filter(p=>!p.isLangPageAdded))&&n.jsxs(n.Fragment,{children:[n.jsx(c.Separator,{}),n.jsxs(c.Button,{size:"sm",variant:"ghost",onClick:()=>{l({name:u==null?void 0:u.name,pageType:u==null?void 0:u.pageType,lang:"",slug:"",edit:!1})},className:"hover:bg-slate-300 duration-200 font-normal text-xs hover:text-slate-800",children:[n.jsx(I.Plus,{className:"w-3 h-3 mr-1"})," Add Langauge"]})]})]})]}),o&&n.jsx(qn,{languages:t,langProps:o,onClose:()=>l(null)})]})};function Ii(){return n.jsxs("div",{className:"flex relative z-10 items-center justify-end gap-1",children:[n.jsx(Ti,{}),n.jsx(Ci,{}),n.jsx(Pi,{})]})}function Vn({children:e,content:t}){return n.jsx(c.TooltipProvider,{children:n.jsxs(c.Tooltip,{children:[n.jsx(c.TooltipTrigger,{asChild:!0,children:e}),n.jsx(c.TooltipContent,{side:"bottom",sideOffset:10,children:n.jsx("p",{children:t})})]})})}function _i(e){const t=ee(),s=Z();return U.useQuery({queryKey:["revisions",e],queryFn:async()=>await s(t,{action:L.GET_PAGE_REVISIONS,data:{pageId:e}}),enabled:!!e,gcTime:0,staleTime:0})}const Li=()=>{const e=ee(),t=Z(),s=U.useQueryClient();return U.useMutation({mutationFn:async r=>await t(e,{action:L.DELETE_PAGE_REVISION,data:{revisionId:r}}),onSuccess:()=>{s.invalidateQueries({queryKey:["revisions"]})}})},Di=()=>{const e=ee(),t=Z(),s=U.useQueryClient();return U.useMutation({mutationFn:async({revisionId:r,discardCurrent:a})=>await t(e,{action:L.RESTORE_PAGE_REVISION,data:{revisionId:r,discardCurrent:a}}),onSuccess:()=>{s.invalidateQueries({queryKey:["revisions"]})}})};function ki(){const{data:e}=be(),{saveState:t}=ce.useSavePage(),[s]=ws();return e?n.jsx("div",{className:"flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50 bg-primary/5 mb-4",children:n.jsxs("div",{className:"flex-1 space-y-1",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsx("p",{className:"text-sm flex items-center gap-1 font-medium leading-none",children:n.jsx("span",{className:"font-bold",children:"Currently editing"})})}),n.jsx("div",{className:"flex items-center text-xs text-muted-foreground",children:!g.isEmpty(s.lastSaved)&&n.jsxs("span",{children:["Last updated"," ",Gt.formatDistanceToNow(new Date(s.lastSaved),{addSuffix:!0})]})}),n.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[n.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600",children:[n.jsx(I.Edit,{className:"h-3 w-3"}),n.jsx("span",{children:"Draft"})]}),t==="UNSAVED"?n.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-xs text-red-600",children:[n.jsx(I.Save,{className:"h-3 w-3"}),n.jsx("span",{children:" Unsaved changes"})]}):null]})]})}):null}function Gi(){const[e,t]=oe.useState(!1),[s,r]=oe.useState(null),[a,i]=oe.useState(!1),[o,l]=oe.useState(!1),{data:u}=be(),{data:d,isFetching:f,error:m,refetch:w}=_i(u==null?void 0:u.id),{mutate:E,isPending:p}=Li(),{mutate:j,isPending:b}=Di(),D=U.useQueryClient(),A=H=>{s&&j({revisionId:s.uid,discardCurrent:H},{onSuccess:()=>{i(!1),r(null),D.invalidateQueries({queryKey:[L.GET_PAGE]})}})},T=H=>{r(H),i(!0)},S=H=>{r(H),l(!0)},P=()=>{s&&E(s.uid,{onSuccess:()=>{l(!1),r(null)}})};return v.useEffect(()=>{e&&w()},[e,w]),n.jsxs(n.Fragment,{children:[n.jsx(c.TooltipProvider,{children:n.jsxs(c.Tooltip,{children:[n.jsxs(c.Sheet,{open:e,onOpenChange:t,children:[n.jsx(c.SheetTrigger,{asChild:!0,children:n.jsx(c.TooltipTrigger,{asChild:!0,children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsxs(c.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[n.jsx(I.History,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"View revision history"})]}),n.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700"})]})})}),n.jsxs(c.SheetContent,{className:"sm:max-w-md p-4",children:[n.jsxs(c.SheetHeader,{className:"pb-2",children:[n.jsxs(c.SheetTitle,{className:"flex items-center gap-2",children:[n.jsx(I.History,{className:"h-5 w-5"}),"Revision History"]}),(u==null?void 0:u.createdAt)&&n.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Page created on"," ",Gt.format(new Date(u.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),n.jsx(c.ScrollArea,{className:"h-[calc(100vh-6rem)] pr-2",children:f?n.jsx(Mi,{}):m?n.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Failed to load revisions. Please try again."}):n.jsxs("div",{className:"mt-2 space-y-2",children:[n.jsx(ki,{}),d==null?void 0:d.map(H=>n.jsx(Oi,{revision:H,isLatest:H.uid==="current",onRestore:()=>T(H),onDelete:()=>S(H)},H.uid))]})})]})]}),n.jsx(c.TooltipContent,{side:"bottom",children:n.jsx("p",{children:"Revision history"})})]})}),n.jsx(Ri,{open:a,onOpenChange:i,revision:s,onRestore:A,isRestoring:b}),n.jsx(Bi,{open:o,onOpenChange:l,revision:s,onDelete:P,isDeleting:p})]})}function Mi(){return n.jsx("div",{className:"space-y-2 mt-2",children:Array.from({length:5}).map((e,t)=>n.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[n.jsxs("div",{className:"flex-1 space-y-1",children:[n.jsx(c.Skeleton,{className:"h-4 w-3/4"}),n.jsx(c.Skeleton,{className:"h-3 w-1/2"}),n.jsx(c.Skeleton,{className:"h-5 w-20 mt-1"})]}),n.jsx(c.Skeleton,{className:"h-8 w-8 rounded-full"})]},t))})}function Oi({revision:e,isLatest:t,onRestore:s,onDelete:r}){const{data:a}=ht(e.currentEditor),i=(a==null?void 0:a.name)||"Unknown";return n.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50",children:[n.jsxs("div",{className:"flex-1 space-y-1",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("p",{className:"text-sm flex items-center gap-1 font-medium leading-none",children:[e.type==="published"?"Published":"Draft"," by ",n.jsx("span",{className:"font-bold",children:i}),t&&n.jsxs("span",{className:"ml-2 flex items-center gap-1 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[n.jsxs("span",{className:"mr-1 relative flex h-2 w-2",children:[n.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"}),n.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-green-500"})]}),"Live"]})]})}),n.jsx("div",{className:"flex items-center text-xs text-muted-foreground",children:n.jsx("span",{children:Gt.format(e.createdAt,"MMM d, h:mm a")})}),n.jsx("div",{className:"flex items-center gap-2 pt-0.5",children:e.type==="published"?n.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-green-500/10 px-1.5 py-0.5 text-xs text-green-600",children:[n.jsx(I.ArrowUpRight,{className:"h-3 w-3"}),n.jsx("span",{children:"Published"})]}):n.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600",children:[n.jsx(I.Clock,{className:"h-3 w-3"}),n.jsx("span",{children:"Draft"})]})})]}),n.jsx(we,{permissions:[le.RESTORE_REVISION,le.DELETE_REVISION],children:n.jsx(Ui,{revision:e,onRestore:s,onDelete:r})})]})}function Ui({revision:e,onRestore:t,onDelete:s}){return n.jsxs(c.DropdownMenu,{children:[n.jsx(c.DropdownMenuTrigger,{asChild:!0,children:n.jsxs(c.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 -mr-1",children:[n.jsx(I.MoreHorizontal,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"More options"})]})}),n.jsxs(c.DropdownMenuContent,{align:"end",className:"text-xs",children:[n.jsx(we,{permission:le.RESTORE_REVISION,children:n.jsxs(c.DropdownMenuItem,{onClick:t,className:"cursor-pointer",children:[n.jsx(I.Undo2,{className:"mr-2 h-4 w-4"}),n.jsx("span",{children:"Restore this version"})]})}),n.jsx(we,{permission:le.DELETE_REVISION,children:e.uid!=="current"&&n.jsxs(n.Fragment,{children:[n.jsx(c.DropdownMenuSeparator,{}),n.jsxs(c.DropdownMenuItem,{onClick:s,className:"cursor-pointer text-destructive",children:[n.jsx(I.Trash,{className:"mr-2 h-4 w-4"}),n.jsx("span",{children:"Delete this version"})]})]})})]})]})}function Ri({open:e,onOpenChange:t,revision:s,onRestore:r,isRestoring:a}){const{data:i}=ht((s==null?void 0:s.currentEditor)||""),o=(i==null?void 0:i.name)||"Unknown";return s?n.jsx(c.Dialog,{open:e,onOpenChange:l=>{a||t(l)},children:n.jsxs(c.DialogContent,{className:"sm:max-w-md",children:[n.jsxs(c.DialogHeader,{children:[n.jsx(c.DialogTitle,{children:"Restore Revision"}),n.jsxs(c.DialogDescription,{children:["You are about to restore to revision ",s.uid.substring(0,8)," ","from ",Gt.format(s.createdAt,"MMM d, yyyy 'at' h:mm a")," by"," ",o]})]}),n.jsx("div",{className:"py-2",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:"How would you like to handle your current edits?"})}),n.jsxs(c.DialogFooter,{className:"flex flex-col sm:flex-row gap-2",children:[n.jsx(c.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>r(!1),disabled:a,children:a?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Saving as draft..."]}):n.jsxs(n.Fragment,{children:[n.jsx(I.CloudOff,{className:"mr-2 h-4 w-4"}),"Save as draft"]})}),n.jsx(c.Button,{variant:"default",className:"sm:flex-1",onClick:()=>r(!0),disabled:a,children:a?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Discarding current..."]}):n.jsxs(n.Fragment,{children:[n.jsx(I.Undo2,{className:"mr-2 h-4 w-4"}),"Discard current"]})})]})]})}):null}function Bi({open:e,onOpenChange:t,revision:s,onDelete:r,isDeleting:a}){const{data:i}=ht((s==null?void 0:s.currentEditor)||""),o=(i==null?void 0:i.name)||"Unknown";return s?n.jsx(c.Dialog,{open:e,onOpenChange:l=>{a||t(l)},children:n.jsxs(c.DialogContent,{className:"sm:max-w-md",children:[n.jsxs(c.DialogHeader,{children:[n.jsx(c.DialogTitle,{children:"Delete Revision"}),n.jsxs(c.DialogDescription,{children:["You are about to delete revision ",s.uid.substring(0,8)," from"," ",Gt.format(s.createdAt,"MMM d, yyyy 'at' h:mm a")," by"," ",o]})]}),n.jsx("div",{className:"py-2",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone. Are you sure you want to proceed?"})}),n.jsxs(c.DialogFooter,{className:"flex flex-col sm:flex-row gap-2",children:[n.jsx(c.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>t(!1),disabled:a,children:"Cancel"}),n.jsx(c.Button,{variant:"destructive",className:"sm:flex-1",onClick:r,disabled:a,children:a?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Deleting..."]}):n.jsxs(n.Fragment,{children:[n.jsx(I.Trash,{className:"mr-2 h-4 w-4"}),"Delete Revision"]})})]})]})}):null}const Fi=()=>{const e=ee(),t=Z();return U.useQuery({queryKey:[L.GET_CHANGES],queryFn:async()=>t(e,{action:L.GET_CHANGES})})},Hi=({currentEditor:e})=>{const{data:t}=ht(e);return t==null?void 0:t.name};function qi({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const[s,r]=v.useState([]),{data:a,isFetching:i}=Fi(),{data:o}=ve(),l=v.useCallback(S=>{var P;return(P=g.find(o,{key:S}))==null?void 0:P.hasSlug},[o]),u=v.useMemo(()=>g.filter(o,S=>!l(S.key)).map(S=>S.key),[l,o]),d=v.useMemo(()=>g.filter(a,S=>!u.includes(S.pageType)),[a,u]),f=v.useMemo(()=>g.filter(a,S=>u.includes(S.pageType)),[a,u]),m=v.useMemo(()=>g.find(a,{pageType:"theme",id:"THEME"}),[a]),{mutate:w,isPending:E}=Ns();v.useEffect(()=>{const S=g.map(g.filter(a,{online:!0}),"id");m&&S.push(m==null?void 0:m.id),r(S)},[a,m]);const p=s.length===(a==null?void 0:a.length),j=S=>{r(P=>g.includes(P,S)?g.filter(P,H=>H!==S):g.concat(P,S))},b=()=>{r(p?[]:g.map(a,"id"))},D=()=>{w({ids:g.uniq(s)},{onSuccess:()=>{t(),Yt("CENTER_CENTER")}})},A=S=>{if(S==="theme")return"Theme";const P=g.find(o,{key:S});return P?P==null?void 0:P.name:S},T=v.useMemo(()=>{const S=[{label:"Updated",top:"pt-2"},...g.orderBy(g.filter(d,{online:!0}),"pageType"),...g.orderBy(g.filter(f,{online:!0}),"pageType")].filter(C=>C.pageType!=="theme"),P=[{label:"Offline",top:"pt-6"},...g.orderBy(g.filter(d,{online:!1}),"pageType"),...g.orderBy(g.filter(f,{online:!1}),"pageType")],H=m?[{label:"Theme",top:"pt-6"},m]:[];return[...S,...H,...P]},[d,f,m]);return n.jsx(c.Dialog,{open:e,onOpenChange:E?()=>{}:t,children:n.jsxs(c.DialogContent,{className:"max-w-4xl max-h-[80%] flex flex-col",children:[n.jsxs(c.DialogHeader,{children:[n.jsx(c.DialogTitle,{children:"Publish changes"}),n.jsx(c.DialogDescription,{className:"text-xs",children:"Select the pages you want to publish. Click publish when you're done."})]}),n.jsx("div",{className:"relative h-full max-h-full -mx-4 overflow-y-auto no-scrollbar",children:i?n.jsxs("div",{className:"px-1 space-y-2",children:[n.jsx("div",{className:"w-full h-6 mt-2 bg-gray-200 rounded animate-pulse"}),n.jsx("div",{className:"w-full h-6 bg-gray-200 rounded animate-pulse"}),n.jsx("div",{className:"w-full h-6 bg-gray-200 rounded animate-pulse"}),n.jsx("div",{className:"w-full h-6 bg-gray-200 rounded animate-pulse"})]}):n.jsxs("table",{className:"w-full text-xs text-left text-gray-500 rtl:text-right dark:text-gray-400",children:[n.jsx("thead",{className:"text-gray-700 border-b bg-gray-50 dark:bg-gray-700 dark:text-gray-400",children:n.jsxs("tr",{children:[n.jsxs("th",{scope:"col",className:"px-6 py-3 flex items-center gap-x-2 w-[1 50px]",children:[n.jsx("input",{checked:p,onClick:S=>{S.stopPropagation(),b()},type:"checkbox",className:"mt-1 rounded cursor-pointer focus:outline-none focus:ring-0"}),"Name"]}),n.jsx("th",{scope:"col",className:"px-2 py-3 w-[100px]",children:"Language"}),n.jsx("th",{scope:"col",className:"px-2 py-3 w-[100px]",children:"Type"}),n.jsx("th",{scope:"col",className:"px-4 py-3 w-[150px] text-right",children:"Status"})]})}),n.jsx("tbody",{children:g.map(T,S=>S.label?n.jsx("tr",{children:n.jsxs("td",{colSpan:4,className:`px-6 py-2 text-xs font-medium text-gray-800 relative ${S.top}`,children:[n.jsx("div",{className:"absolute inset-0 flex items-center left-6",children:n.jsx("div",{className:"w-full order-gray-300"})}),n.jsx("div",{className:"relative flex justify-start",children:n.jsx("span",{className:"pr-2 bg-gray-50",children:S.label})})]})},"separator"):n.jsxs("tr",{className:"border-b group hover:bg-gray-50 last:border-b-0",children:[n.jsxs("td",{scope:"row",className:"flex items-center px-6 py-2 text-gray-900 whitespace-nowrap dark:text-white gap-x-1",children:[n.jsx("input",{checked:g.includes(s,S==null?void 0:S.id),onClick:P=>{P.stopPropagation(),j(S==null?void 0:S.id)},type:"checkbox",className:"rounded cursor-pointer focus:outline-none focus:ring-0"})," ",l(S.pageType)?n.jsx(I.File,{className:"w-4 h-4"}):n.jsx(I.GlobeIcon,{className:"w-4 h-4"}),S.name,S.slug&&n.jsxs("span",{className:"text-xs text-gray-500",children:["(",S.slug,")"]}),S.currentEditor&&n.jsx("div",{className:"flex items-center gap-x-1",children:n.jsxs("span",{className:"flex text-xs font-bold text-gray-500",children:[" ","-"," ",n.jsx(Hi,{currentEditor:S.currentEditor})," ","is editing"]})})]}),n.jsx("td",{className:"px-2",children:S.lang}),n.jsx("td",{className:"px-2",children:A(S==null?void 0:S.pageType)}),n.jsx("td",{className:"px-4 text-right",children:g.first(S.changes)||""})]},S==null?void 0:S.id))})]})}),n.jsxs(c.DialogFooter,{className:"mt-10",children:[n.jsx(c.Button,{disabled:E,variant:"outline",onClick:t,children:"Cancel"}),n.jsx(c.Button,{disabled:E||i||g.isEmpty(a),onClick:D,children:E?"Publishing...":"Publish"})]})]})})}const Vi=()=>{const e=Z(),t=ee();return U.useQuery({queryKey:[L.GET_WEBSITE_DATA],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:L.GET_WEBSITE_DATA,data:{draft:!0}})})};function $i({onClose:e}){const{data:t,isFetching:s}=Vi(),{mutateAsync:r,isPending:a}=Qa(),i=Ne("settingComponent",null),o=g.debounce(async l=>(await r({data:l}),!0),300);return i?n.jsx(c.Dialog,{open:!0,onOpenChange:e,children:n.jsxs(c.DialogContent,{className:"w-full",children:[n.jsx(c.DialogHeader,{children:n.jsx(c.DialogTitle,{children:"Website Settings"})}),s?n.jsxs("div",{className:"w-full space-y-3 py-4",children:[n.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),n.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),n.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),n.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),n.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),n.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"})]}):n.jsx("div",{children:v.createElement(i,{data:t||{},onSave:a?()=>{}:o,cancel:a?()=>{}:e})})]})}):null}const Ki=()=>{const{selectedLang:e}=ce.useLanguages(),t=Ne("getPreviewUrl",async f=>f),[s,r]=v.useState(""),{data:a,isFetching:i}=be(),{data:o}=mt(),{data:l}=ve(),u=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]),d=v.useCallback(f=>{var m;return(m=g.find(l,{key:f}))==null?void 0:m.hasSlug},[l]);return v.useEffect(()=>{(async()=>{if(u&&typeof t=="function"){const f=await t(u||"");r(f)}else r("")})()},[t,u]),!s||!d(a==null?void 0:a.pageType)||i?null:n.jsx(n.Fragment,{children:n.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:n.jsxs(c.Button,{variant:"ghost",size:"sm",className:"gap-2",children:[n.jsx(I.Eye,{className:"w-4 h-4"})," ",q.PREVIEW]})})})},Wi=()=>{const[e,t]=ce.useRightPanel();return n.jsxs(n.Fragment,{children:[n.jsx(Vn,{content:q.THEME,children:n.jsx(c.Button,{variant:e==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>t(e==="theme"?"block":"theme"),children:n.jsx(I.Palette,{className:"w-4 h-4"})})}),n.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700"})]})},zi=()=>{const[e,t]=v.useState(!1),{isLocked:s}=Ot(),{savePage:r,saveState:a}=ce.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 r(!1)},[r]);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:u,tooltipContent:d}=v.useMemo(()=>{switch(o){case"UNSAVED":return{tooltipContent:q.SAVEDRAFT,buttonIcon:n.jsx(I.Save,{className:"w-4 h-4"}),buttonClass:"flex items-center gap-x-1 leading-tight"};case"SAVING":return{tooltipContent:q.SAVING,buttonIcon:n.jsx(I.Loader,{className:"w-4 h-4 animate-spin"}),buttonClass:"flex items-center gap-x-1 leading-tight"};case"SAVED":return{tooltipContent:q.SAVED,buttonIcon:n.jsx(I.CheckCircle,{className:"w-4 h-4"}),buttonClass:"text-green-500 flex items-center gap-x-1 leading-tight"}}},[o]);return s?null:n.jsxs(c.Button,{size:"sm",variant:"ghost",onClick:i,className:u,children:[l," ",d]})},Qi=()=>{const[e,t]=v.useState(!1),[s,r]=v.useState(!1),[a,i]=v.useState(null),{data:o}=be(),{mutate:l,isPending:u}=Ns(),[d]=ce.useBlocksStore(),{buttonText:f,buttonClassName:m,isPublished:w}=v.useMemo(()=>{const p=o&&(o==null?void 0:o.online);return{buttonClassName:p?"hover:bg-green-600 bg-green-500":"",isPublished:p,buttonText:p?q.PUBLISHED:q.PUBLISH}},[o]),E=async()=>{var j,b;const p=((b=(j=d==null?void 0:d.filter(D=>(D==null?void 0:D._type)==="GlobalBlock"))==null?void 0:j.map(D=>D==null?void 0:D.globalBlock))==null?void 0:b.filter(D=>typeof D=="string"))||[];l({ids:[o==null?void 0:o.id,...p]},{onSuccess:()=>Yt("TOP_RIGHT")})};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex",children:[n.jsxs(c.Button,{size:"sm",onClick:E,disabled:u||!(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:()=>r(!0),onMouseLeave:()=>r(!1),children:[n.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${s?"-translate-y-10":""}`,children:w?n.jsx(I.Send,{className:"w-4 h-4"}):n.jsx(I.Rocket,{className:"w-4 h-4"})}),n.jsx("span",{className:`absolute inset-0 flex items-center left-3 transition-transform duration-300 ease-in-out ${s?"":"translate-y-10"}`,children:w?n.jsx(I.Rocket,{className:"w-4 h-4"}):n.jsx(I.Send,{className:"w-4 h-4"})}),n.jsx("span",{children:f})]}),n.jsxs(c.DropdownMenu,{children:[n.jsx(c.DropdownMenuTrigger,{asChild:!0,children:n.jsx(c.Button,{size:"sm",disabled:u||!(o!=null&&o.id),className:`px-2 text-white border-l border-white/50 rounded-l-none ${m}`,children:n.jsx(I.ChevronDown,{className:"w-4 h-4"})})}),n.jsxs(c.DropdownMenuContent,{align:"end",className:"w-36",children:[!w&&n.jsxs(c.DropdownMenuItem,{disabled:u,className:"text-xs cursor-pointer",onClick:()=>l({ids:[o==null?void 0:o.id]},{onSuccess:()=>Yt("TOP_RIGHT")}),children:[q.PUBLISH," page"]}),n.jsxs(c.DropdownMenuItem,{onClick:()=>t(!0),className:"text-xs cursor-pointer",children:[q.OPEN," publish menu"]}),w&&n.jsxs(c.DropdownMenuItem,{onClick:()=>i(o),className:"text-xs cursor-pointer",children:[q.UNPUBLISH," page"]})]})]})]}),n.jsx(qi,{showModal:e,onClose:()=>t(!1)}),a&&n.jsx(Ts,{page:a,onClose:()=>i(null)})]})},Yi=()=>{const e=Ne("settingComponent",null),[t,s]=v.useState(!1);return e?n.jsxs(n.Fragment,{children:[n.jsx(Vn,{content:q.WEBSITEDATA,children:n.jsx(c.Button,{variant:"ghost",size:"icon",className:"gap-2",onClick:()=>s(!0),children:n.jsx(I.Settings,{className:"w-4 h-4"})})}),t&&n.jsx($i,{onClose:()=>s(!1)}),n.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700"})]}):null},Xi=()=>{const{data:e}=be(),t=e&&(e==null?void 0:e.online),{data:s}=ve();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)?n.jsxs(c.Button,{onClick:()=>t&&window.open(`${window.location.origin}${e.slug}`,"_blank"),disabled:!t,variant:"ghost",size:"sm",className:"flex items-center gap-1",children:[n.jsx(I.ExternalLink,{className:"w-4 h-4"}),n.jsx("span",{className:"hidden sm:inline",children:q.OPEN})]}):null};function Zi(){const{isLocked:e}=Ot(),[t]=je(),s=t.get("lang"),r=Un(s);return e||!r?null:n.jsxs("div",{className:"flex items-center justify-end gap-1",children:[n.jsx(Gi,{}),n.jsx(we,{permission:le.EDIT_THEME,children:n.jsx(Wi,{})}),n.jsx(we,{permission:le.EDIT_SETTINGS,children:n.jsx(Yi,{})}),n.jsx(Ki,{}),n.jsx(we,{permission:le.SAVE_PAGE,children:n.jsx(zi,{})}),n.jsx(we,{permission:le.PUBLISH_PAGE,children:n.jsx(Qi,{})}),n.jsx(Xi,{})]})}const $n=()=>{const e=ee(),t=Z(),s=Ne("user"),r=s==null?void 0:s.id;return U.useQuery({queryKey:["permissions",r],queryFn:()=>t(e,{action:L.GET_ROLE_AND_PERMISSIONS,data:{userId:r}}),enabled:!!r})},gs={},xs=(e,t)=>{g.has(gs,e)&&console.warn(`Panel ${e} already registered. Overriding...`),g.set(gs,e,{id:e,...t})},Ji=()=>{const{data:e}=be(),{data:t}=ft(),s=ri(e==null?void 0:e.pageType);return v.useMemo(()=>!s||!e||!t?[]:Object.values(gs).filter(r=>r.showIf({page:e,pageType:s,websiteSetting:t})).map(r=>g.omit(r,"showIf")),[t,s,e])},eo="lang",to={label:"Lang",component:wi,icon:n.jsx(I.LanguagesIcon,{}),showIf:({websiteSetting:e})=>e.languages.length>0},so=()=>{const{selectedLang:e}=ce.useLanguages(),{data:t,isFetching:s}=mt();return{data:v.useMemo(()=>g.find(t,{lang:e||""})||{},[t,e]),isFetching:s}};function ke({data:e,onSelect:t,dataType:s="value",disabled:r=!1}){const[a,i]=oe.useState(!1),[o,l]=oe.useState([]),[u,d]=oe.useState(e);oe.useEffect(()=>{a||l([]),d(e)},[e,a]);const f=p=>Array.isArray(p)?"array":typeof p=="object"&&p!==null?"object":"value",m=oe.useCallback(p=>{const j=b=>s==="value"?b==="value"||b==="object":s==="array"?b==="array":b===s;p.type==="object"?(l(b=>[...b,p.key]),d(p.value)):j(p.type)&&(t([...o,p.key].join(".")),i(!1))},[o,t,s]),w=oe.useCallback(()=>{if(o.length>0){const p=o.slice(0,-1);l(p),d(p.reduce((j,b)=>j[b],e))}},[o,e]),E=oe.useMemo(()=>Object.entries(u).map(([p,j])=>({key:p,value:j,type:f(j)})).filter(p=>s==="value"?p.type==="value"||p.type==="object":s==="array"?p.type==="array"||p.type==="object":s==="object"?p.type==="object":!0),[u,s]);return n.jsxs(c.Popover,{open:a,onOpenChange:i,children:[n.jsxs(c.Tooltip,{children:[n.jsx(c.TooltipTrigger,{asChild:!0,children:n.jsx(c.PopoverTrigger,{asChild:!0,children:n.jsx(c.Button,{size:"sm",variant:"outline",className:"h-6 w-6 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":a,disabled:r,children:n.jsx(I.DatabaseIcon,{className:"h-3 w-3"})})})}),n.jsx(c.TooltipContent,{children:"Add field"})]}),n.jsx(c.PopoverContent,{className:"w-[200px] p-0",children:n.jsxs(c.Command,{children:[n.jsx(c.CommandInput,{className:"border-none",placeholder:"Search..."}),n.jsxs(c.CommandList,{children:[n.jsx(c.CommandEmpty,{children:"No option found."}),n.jsxs(c.CommandGroup,{children:[o.length>0&&n.jsxs(c.CommandItem,{onSelect:w,className:"flex items-center text-sm",children:[n.jsx(I.ChevronLeft,{className:"w-4 h-4 mr-2"}),"Back"]}),E.map(p=>n.jsxs(c.CommandItem,{onSelect:()=>m(p),className:"flex items-center justify-between",children:[n.jsx("span",{children:p.key}),n.jsxs("div",{className:"flex items-center gap-2",children:[s==="object"&&p.type==="object"&&n.jsx(c.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:j=>{j.stopPropagation(),t([...o,p.key].join(".")),i(!1)},children:"Select"}),(p.type==="object"||p.type==="array")&&n.jsx("div",{className:"p-1 rounded hover:bg-muted cursor-pointer",children:n.jsx(I.ChevronRight,{className:"w-4 h-4 opacity-50"})})]})]},p.key))]})]})]})})]})}const no=(e,t)=>{const s=e.selectionStart||0,r=e.selectionEnd||0,a=e.value,i=a.substring(0,s),o=a.substring(r);let l=!1;if(s>0&&i.length>0){const p=i.charAt(i.length-1);l=!/[\s.,!?;:()[\]{}]/.test(p)&&p!==""}let u=!1;if(o.length>0){const p=o.charAt(0);u=!/[\s.,!?;:()[\]{}]/.test(p)&&p!==""}const d=l?" ":"",f=u?" ":"",m=`{{${t}}}`,w=i+(l?d:"")+m+(u?f:"")+o,E=s+(l?1:0)+m.length;return{value:w,newCursorPos:E}},Kn=()=>{const{t:e}=ce.useTranslation(),{selectedLang:t,fallbackLang:s,languages:r}=ce.useLanguages(),{data:a}=be(),{data:i}=On({lang:t||s,pageType:a==null?void 0:a.pageType}),{data:o,isFetching:l}=so(),u=o==null?void 0:o.seo,d=v.useRef(null),[f,m]=v.useState({title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",searchTitle:"",searchDescription:"",jsonLD:"",...u}),w=v.useRef({initial:f,updated:f}),E=t.length?t:s,{mutate:p,isPending:j}=js(),b=j,{hasPermission:D}=ce.usePermissions(),A=D(le.EDIT_SEO);v.useEffect(()=>{!l&&u&&m({title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",searchTitle:"",searchDescription:"",jsonLD:"",...u})},[l,u]);const T=async()=>{p({id:o==null?void 0:o.id,seo:f}),w.current.initial=f,w.current.updated=f},S=()=>{m({...f,ogTitle:f.title,ogDescription:f.description})},P=()=>{m({...f,searchTitle:f.ogTitle,searchDescription:f.ogDescription})},H=(k,N)=>{const G=document.getElementById(N);if(G){const{value:V,newCursorPos:Y}=no(G,k);d.current={id:N,position:Y},G.tagName.toLowerCase()==="input"?(G.value=V,m(y=>({...y,[G.name]:V})),G.focus(),G.setSelectionRange(Y,Y),[0,10,50,100,200].forEach(y=>{setTimeout(()=>{const M=document.getElementById(N);M&&(M.focus(),M.setSelectionRange(Y,Y))},y)})):(m(me=>({...me,[G.name]:V})),requestAnimationFrame(()=>{const me=document.getElementById(N);me&&(me.focus(),me.setSelectionRange(Y,Y),setTimeout(()=>{const y=document.getElementById(N);y&&(y.focus(),y.setSelectionRange(Y,Y))},50))}))}},C=k=>{const N={...f,[k.target.name]:k.target.name==="noIndex"||k.target.name==="noFollow"?k.target.checked:k.target.value};m(N),w.current.updated=N};return n.jsxs("div",{className:"relative pb-40",children:[!A&&n.jsx("div",{className:"absolute inset-0 z-10 backdrop-blur-sm flex items-center justify-center",children:n.jsx(c.Alert,{variant:"default",className:"w-[80%] max-w-md text-xs",children:n.jsx(c.AlertDescription,{children:e("You don't have permission to edit SEO settings. Contact your administrator for access.")})})}),n.jsxs("div",{className:"p-2 text-xs text-left bg-gray-100 rounded-md",children:[e("Slug"),": ",o==null?void 0:o.slug," ",r.length>0&&n.jsxs("span",{className:"font-semibold text-blue-500",children:["(",g.get(Ce,E,E),")"]})]}),n.jsx("form",{className:"space-y-8",children:n.jsxs(c.Accordion,{type:"multiple",defaultValue:["page"],children:[n.jsxs(c.AccordionItem,{value:"page",children:[n.jsx(c.AccordionTrigger,{className:"font-semibold text-slate-700",children:e("SEO")}),n.jsx(c.AccordionContent,{className:"pt-2",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(c.Label,{className:"text-xs",htmlFor:"title",children:e("SEO Title")}),A&&n.jsx(ke,{dataType:"value",data:i??{},onSelect:k=>H(k,"title")})]}),n.jsx(c.Input,{type:"text",id:"title",name:"title",value:f.title,onChange:C,disabled:b||!A,placeholder:e("Enter SEO title"),readOnly:!A})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(c.Label,{className:"text-xs",htmlFor:"description",children:e("SEO Description")}),A&&n.jsx(ke,{data:i??{},onSelect:k=>H(k,"description")})]}),n.jsx(c.Textarea,{id:"description",name:"description",rows:5,value:f.description,onChange:C,disabled:b||!A,placeholder:e("Enter SEO description"),readOnly:!A})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(c.Label,{className:"text-xs",htmlFor:"title",children:e("Canonical URL")}),A&&n.jsx(ke,{dataType:"value",data:i??{},onSelect:k=>H(k,"canonicalUrl")})]}),n.jsx(c.Input,{type:"text",id:"canonicalUrl",name:"canonicalUrl",value:f.canonicalUrl,onChange:C,disabled:b||!A,placeholder:e("Enter Canonical URL"),readOnly:!A})]}),n.jsxs("div",{className:"",children:[n.jsxs("div",{className:"flex items-center gap-x-2",children:[n.jsx(c.Input,{type:"checkbox",id:"noIndex",name:"noIndex",checked:f.noIndex,onChange:C,disabled:b||!A,className:"w-4 h-4"}),n.jsx(c.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:e("No Index")})]}),n.jsx("p",{className:"mt-0 text-[10px] font-light text-gray-400 leading-4",children:e("Check this if you don't want search engines to index this page.")})]}),n.jsxs("div",{className:"",children:[n.jsxs("div",{className:"flex items-center gap-x-2",children:[n.jsx(c.Input,{type:"checkbox",id:"noFollow",name:"noFollow",checked:f.noFollow,onChange:C,disabled:b||!A,className:"w-4 h-4"}),n.jsx(c.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:e("No Follow")})]}),n.jsx("p",{className:"text-[10px] font-light text-gray-400 leading-4",children:e("Check this if you don't want search engines to follow links on this page.")})]})]})})]}),n.jsxs(c.AccordionItem,{value:"og",children:[n.jsx(c.AccordionTrigger,{className:"font-bold text-slate-700",children:e("Open Graph")}),n.jsx(c.AccordionContent,{children:n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsx(c.Button,{type:"button",variant:"outline",size:"sm",onClick:S,disabled:!A,children:e("Copy from SEO Settings")})}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(c.Label,{className:"text-xs",htmlFor:"ogTitle",children:e("OG Title")}),A&&n.jsx(ke,{dataType:"value",data:i??{},onSelect:k=>H(k,"ogTitle")})]}),n.jsx(c.Input,{type:"text",id:"ogTitle",name:"ogTitle",value:f.ogTitle,onChange:C,disabled:b||!A,placeholder:e("Enter OG title"),readOnly:!A})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(c.Label,{className:"text-xs",htmlFor:"ogDescription",children:e("OG Description")}),A&&n.jsx(ke,{dataType:"value",data:i??{},onSelect:k=>H(k,"ogDescription")})]}),n.jsx(c.Textarea,{id:"ogDescription",name:"ogDescription",rows:5,value:f.ogDescription,onChange:C,disabled:b||!A,placeholder:e("Enter OG description"),readOnly:!A})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(c.Label,{className:"text-xs",htmlFor:"ogImage",children:e("OG Image URL")}),A&&n.jsx(ke,{dataType:"value",data:i??{},onSelect:k=>H(k,"ogImage")})]}),n.jsx(c.Input,{type:"text",id:"ogImage",name:"ogImage",value:f.ogImage,onChange:C,disabled:b||!A,placeholder:e("Enter OG image URL"),readOnly:!A})]})]})})]}),n.jsxs(c.AccordionItem,{value:"search",children:[n.jsx(c.AccordionTrigger,{className:"font-bold text-slate-700",children:e("Search")}),n.jsx(c.AccordionContent,{children:n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsx(c.Button,{type:"button",variant:"outline",size:"sm",onClick:P,disabled:!A,children:e("Copy from OG Settings")})}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(c.Label,{className:"text-xs",htmlFor:"searchTitle",children:e("Search Title")}),A&&n.jsx(ke,{dataType:"value",data:i??{},onSelect:k=>H(k,"searchTitle")})]}),n.jsx(c.Input,{type:"text",id:"searchTitle",name:"searchTitle",value:f.searchTitle,onChange:C,disabled:b||!A,placeholder:e("Enter search title"),readOnly:!A})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(c.Label,{className:"text-xs",htmlFor:"searchDescription",children:e("Search Description")}),A&&n.jsx(ke,{dataType:"value",data:i??{},onSelect:k=>H(k,"searchDescription")})]}),n.jsx(c.Textarea,{id:"searchDescription",rows:5,name:"searchDescription",value:f.searchDescription,onChange:C,placeholder:e("Enter search description"),disabled:b||!A,readOnly:!A})]})]})})]}),n.jsxs(c.AccordionItem,{value:"jsonLD",children:[n.jsx(c.AccordionTrigger,{className:"font-bold text-slate-700",children:e("JSON-LD")}),n.jsx(c.AccordionContent,{children:n.jsx("div",{className:"space-y-4",children:n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(c.Label,{className:"text-xs",htmlFor:"jsonLD",children:e("JSON-LD")}),A&&n.jsx(ke,{dataType:"value",data:i??{},onSelect:k=>H(k,"jsonLD")})]}),n.jsx(c.Textarea,{id:"jsonLD",name:"jsonLD",rows:6,value:f.jsonLD,onChange:C,placeholder:e("Enter JSON-LD"),disabled:b||!A,readOnly:!A})]})})})]})]})}),A&&n.jsx("div",{className:"flex items-center justify-end w-full mt-4",children:n.jsx(c.Button,{size:"lg",variant:"default",onClick:T,disabled:g.isEqual(w.current.initial,f)||b||!A,children:e(j?"Saving...":"Save")})})]})};Kn.displayName="SeoPanel";const ro="seo",ao={label:"SEO",component:Kn,icon:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 21 21",fill:"currentColor",width:"21",height:"21",children:[n.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"}),n.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"})]}),showIf:({pageType:e})=>!!(g.has(e,"hasSlug")&&e.hasSlug)},io=()=>{xs(ro,ao),xs(eo,to)};tr.loadWebBlocks();io();const oo=e=>{const t=v.useRef([]),[s]=je(),r=s.get("page"),a=s.get("lang"),{data:i}=be(),{data:o={role:"",permissions:null}}=$n(),{data:l}=ii(),{data:u,isFetching:d}=Mn(),{blocks:f}=si(u),{data:m}=ft(),{data:w}=ve(),{mutateAsync:E}=kn(),p=Ja(),{getUILibraryBlock:j,getUILibraryBlocks:b,onSave:D}=oi(),{getPartialBlocks:A,getPartialBlockBlocks:T}=li(),{aiContext:S,setAiContext:P}=bs(),{mutateAsync:H}=ai(),[C,k]=v.useState(!1),N=v.useMemo(()=>(m==null?void 0:m.fallbackLang)||"en",[m]),{data:G}=On({pageType:i==null?void 0:i.pageType,lang:a||N});Za(),v.useEffect(()=>{const M=()=>{document.hidden?k(!0):k(!1)};return window.addEventListener("visibilitychange",M),()=>window.removeEventListener("visibilitychange",M)},[]),t.current=f;const V=v.useMemo(()=>{const M={};return e.mediaManagerComponent&&(M.mediaManagerComponent=e.mediaManagerComponent),o&&(M.permissions=g.get(o,"permissions",null),M.role=g.get(o,"role","user")),M},[e.mediaManagerComponent,o]),Y=v.useMemo(()=>Array.isArray(e==null?void 0:e.uiLibraries)?[...l,...e==null?void 0:e.uiLibraries]:l,[l,e==null?void 0:e.uiLibraries]),Le=v.useCallback(async(M,xe)=>await H({pageType:M,query:xe}),[H]),me=v.useMemo(()=>g.get(m,"theme",{})||{},[m]),y=Ji();return n.jsxs(n.Fragment,{children:[d&&n.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center w-screen h-screen bg-white/30",children:n.jsx("div",{className:"flex items-center justify-center bg-white rounded-full size-10",children:n.jsx(I.Loader2,{className:"size-5 animate-spin"})})}),n.jsx(ce.ChaiBuilderEditor,{pageExternalData:G,themePresets:e.themePresets??[],pageId:i==null?void 0:i.id,addBlocksDialogTabs:e.addBlocksDialogTabs||[],loading:d,fallbackLang:N,languages:(m==null?void 0:m.languages)||[],brandingOptions:(m==null?void 0:m.theme)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSaveSupport:!C&&(e.autoSaveSupport??!0),autoSaveInterval:e.autoSaveInterval??15,onError:e.onError||console.error,getPartialBlockBlocks:T,getPartialBlocks:A,blocks:d?[]:f,theme:g.cloneDeep(me),getUILibraryBlock:j,getUILibraryBlocks:b,uiLibraries:Y,pageTypes:w,searchPageTypeItems:Le,saveAiContextCallback:async M=>{if(!r)return!0;const xe=t.current,ye={_type:"@chai/ai-context",_value:g.isString(M)?M:""},Be=[...xe,ye];return await D({page:r,blocks:Be}),P(M),!0},aiContext:S,askAiCallBack:p,onSave:async({blocks:M,theme:xe})=>{if(!r)return!0;t.current=M;const ye={_type:"@chai/ai-context",_value:g.isString(S)?S:""},Be=[...M,ye];return await D({page:r,blocks:Be}),t.current=Be,g.isEqual(xe,me)||await E({settings:{theme:xe}}),!0},topBarComponents:{left:[Ii],right:[Zi]},sideBarComponents:{top:y,bottom:[...e!=null&&e.sidebarBottomComponents?[...e.sidebarBottomComponents]:[],ui,di]},themePanelComponent:Si,blockMoreOptions:[Bn],...V})]})},lo=new U.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1}}}),co=e=>{const[,t]=Gn(),[s,r]=v.useState(!1);return v.useEffect(()=>(t(g.pick(e,["apiUrl","getPreviewUrl","logo","settingComponent","user","onSessionExpired","pageLockComponent"])),setTimeout(()=>{r(!0)},200),()=>{r(!1),t({})}),[e,t]),s?n.jsxs(U.QueryClientProvider,{client:lo,children:[n.jsx(oo,{...e}),n.jsx(Ka,{})]}):n.jsx("div",{})};if(typeof window>"u")throw new Error("@chaibuilder/pages is not available on the server");exports.$TRACK=ps;exports.ChaiBuilderPages=co;exports.Dynamic=Zr;exports.For=Nr;exports.Index=Ar;exports.Match=Pr;exports.PermissionChecker=we;exports.Portal=Xr;exports.Show=Tr;exports.Switch=Cr;exports.addEventListener=un;exports.batch=or;exports.className=cn;exports.clearDelegatedEvents=Fr;exports.convertRemToPixels=Ba;exports.createComponent=vs;exports.createComputed=Ys;exports.createContext=fr;exports.createEffect=ys;exports.createMemo=Ee;exports.createRenderEffect=Ue;exports.createRoot=Oe;exports.createSignal=he;exports.createUniqueId=jr;exports.delegateEvents=ln;exports.deleteNestedDataByPath=pt;exports.displayValue=ka;exports.getMutationStatusColor=La;exports.getPreferredColorScheme=Fa;exports.getQueryStatusColor=_a;exports.getQueryStatusColorByLabel=Da;exports.getQueryStatusLabel=Pa;exports.getSidedProp=Ia;exports.insert=Qt;exports.mergeProps=Ss;exports.mutationSortFns=Ra;exports.on=lr;exports.onCleanup=lt;exports.onMount=Xs;exports.registerChaiPanel=xs;exports.serialize=Pn;exports.setAttribute=zt;exports.sortFns=Oa;exports.splitProps=nn;exports.spread=dn;exports.stringify=Ca;exports.template=Br;exports.untrack=fe;exports.updateNestedDataByPath=xt;exports.use=hn;exports.useChaiUserInfo=ht;exports.useContext=mr;exports.useCurrentPage=be;exports.useFetch=Z;exports.useFetchUpload=za;exports.useLanguagePages=mt;exports.useTransition=hr;exports.useUserRoleAndPermissions=$n;exports.useWebsitePages=Mt;exports.useWebsiteSetting=ft;
|