@chaibuilder/pages 0.13.4 → 0.14.1
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/{2AITGKQY-Dx_Cte-P.js → 2AITGKQY-Cti4x7QE.js} +5 -5
- package/dist/{2AITGKQY-DpAgk_u8.cjs → 2AITGKQY-PHs1xUsz.cjs} +1 -1
- package/dist/{NCMVHL6D-B6lv7Umq.cjs → NCMVHL6D-BChQ0wDN.cjs} +1 -1
- package/dist/{NCMVHL6D-CT2qHOTS.js → NCMVHL6D-fAWarBw8.js} +4 -4
- package/dist/{ZDWCUMSJ-C1vrgsti.cjs → ZDWCUMSJ-CwWfQqyn.cjs} +1 -1
- package/dist/{ZDWCUMSJ-W9xywtZH.js → ZDWCUMSJ-DRWuu_nE.js} +1 -1
- package/dist/add-new-language-page-CcBqDtYv.js +390 -0
- package/dist/add-new-language-page-Dt9DWunK.cjs +1 -0
- package/dist/add-new-page-BN3z9rSq.cjs +1 -0
- package/dist/add-new-page-CTUiEKzv.js +30 -0
- package/dist/confetti.module-BuUnQuWk.cjs +2 -0
- package/dist/confetti.module-DCmCkDyV.js +409 -0
- package/dist/delete-page-8MnGZ_mz.js +38 -0
- package/dist/delete-page-jELwTpGY.cjs +1 -0
- package/dist/digital-asset-manager-BJhwyEdT.js +976 -0
- package/dist/digital-asset-manager-ZyQJP6AO.cjs +1 -0
- package/dist/duplicate-page-BGYZLkco.js +120 -0
- package/dist/duplicate-page-BRjKFpBP.cjs +1 -0
- package/dist/dynamic-page-selector-CR-ZpSJ8.cjs +1 -0
- package/dist/dynamic-page-selector-CrbujoYg.js +86 -0
- package/dist/get-seo-defaults-9zHebckY.js +65 -0
- package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
- package/dist/image-compression-DZ9WMmyn.cjs +1 -0
- package/dist/image-compression-DsZ1oqpb.js +37 -0
- package/dist/index-Byi6-4u1.js +5164 -0
- package/dist/index-DSUpSpeI.cjs +5 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -22
- package/dist/index.js +18 -19
- package/dist/json-diff-viewer-DKlC7yl6.cjs +8 -0
- package/dist/json-diff-viewer-De2bStRw.js +258 -0
- package/dist/lang-panel-B3bC1gKq.cjs +1 -0
- package/dist/lang-panel-G7RoMOP7.js +218 -0
- package/dist/mark-as-template-B1TpGPms.js +146 -0
- package/dist/mark-as-template-OgR8I38n.cjs +1 -0
- package/dist/nested-path-selector-content-D_iF9Sm3.cjs +1 -0
- package/dist/nested-path-selector-content-DvIL_EoN.js +87 -0
- package/dist/no-language-page-content-CqH4FMNy.js +35 -0
- package/dist/no-language-page-content-iZo2ztXp.cjs +1 -0
- package/dist/page-creator-Chnj3W4j.js +796 -0
- package/dist/page-creator-DUXzx-zg.cjs +1 -0
- package/dist/page-lock-request-D3gmV8Yq.cjs +1 -0
- package/dist/page-lock-request-Dc-JkLEZ.js +64 -0
- package/dist/page-locked-by-dialog-B9pGi6zb.cjs +1 -0
- package/dist/page-locked-by-dialog-DC8UKy9e.js +63 -0
- package/dist/page-manager-new-CFtYUNbS.cjs +1 -0
- package/dist/page-manager-new-DYYWpxWy.js +354 -0
- package/dist/page-manager-search-and-filter-B4xo9IJO.js +197 -0
- package/dist/page-manager-search-and-filter-DT9V9AoS.cjs +1 -0
- package/dist/page-revisions-content-BjIECUPY.cjs +1 -0
- package/dist/page-revisions-content-KJGhm9Pl.js +446 -0
- package/dist/publish-pages-content-BWLQZGjd.js +178 -0
- package/dist/publish-pages-content-CTduLNtg.cjs +1 -0
- package/dist/save-to-lib-B07GbG4I.js +476 -0
- package/dist/save-to-lib-CsrSeusU.cjs +1 -0
- package/dist/seo-panel-B20DCgo0.js +667 -0
- package/dist/seo-panel-QphuqXT2.cjs +1 -0
- package/dist/shared-json-ld-C_vIO-Qk.cjs +1 -0
- package/dist/shared-json-ld-CkOQRUEw.js +337 -0
- package/dist/slug-input-71BuN79c.cjs +1 -0
- package/dist/slug-input-rAe3mMkd.js +87 -0
- package/dist/theme-panel-footer-DFUfCqKP.js +25 -0
- package/dist/theme-panel-footer-DHRs6ag2.cjs +1 -0
- package/dist/translation-warning-modal-DalBhNQy.js +26 -0
- package/dist/translation-warning-modal-Kctu12rQ.cjs +1 -0
- package/dist/unmark-as-template-Cx0CqrpM.cjs +1 -0
- package/dist/unmark-as-template-_VyWoVNk.js +38 -0
- package/dist/unpublish-page-CuSJRr5c.js +26 -0
- package/dist/unpublish-page-D3NM8b3u.cjs +1 -0
- package/dist/use-page-expand-manager-MjYZ3CDZ.cjs +1 -0
- package/dist/use-page-expand-manager-_msrWd0a.js +85 -0
- package/dist/web-preview-BL-vsgoa.js +73 -0
- package/dist/web-preview-CI3Vz7Yp.cjs +1 -0
- package/package.json +1 -1
- package/dist/index-C4j31Yhz.js +0 -11471
- package/dist/index-DnjETHks.cjs +0 -6
- package/dist/page-revisions-content-Gx-Qf_91.cjs +0 -8
- package/dist/page-revisions-content-_-Nd4U11.js +0 -712
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var sr=Object.defineProperty;var Ts=e=>{throw TypeError(e)};var nr=(e,t,s)=>t in e?sr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var me=(e,t,s)=>nr(e,typeof t!="symbol"?t+"":t,s),Ps=(e,t,s)=>t.has(e)||Ts("Cannot "+s);var v=(e,t,s)=>(Ps(e,t,"read from private field"),s?s.call(e):t.get(e)),G=(e,t,s)=>t.has(e)?Ts("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),D=(e,t,s,n)=>(Ps(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s);const o=require("react/jsx-runtime"),p=require("lodash-es"),h=require("react"),K=require("jotai"),w=require("@tanstack/react-query"),N=require("@chaibuilder/sdk"),$=require("sonner"),m=require("@chaibuilder/sdk/ui"),_=require("lucide-react"),Bs=require("@chaibuilder/runtime"),Pt=require("zod"),rr=require("@chaibuilder/sdk/web-blocks");function ar(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const Q=ar(h),S={GENERATE_SEO_FIELD:"GENERATE_SEO_FIELD",UPDATE_PAGE_METADATA:"UPDATE_PAGE_METADATA",GET_BLOCK_ASYNC_PROPS:"GET_BLOCK_ASYNC_PROPS",ASK_AI:"ASK_AI",GET_DRAFT_PAGE:"GET_DRAFT_PAGE",CREATE_PAGE:"CREATE_PAGE",UPDATE_PAGE:"UPDATE_PAGE",DELETE_PAGE:"DELETE_PAGE",DUPLICATE_PAGE:"DUPLICATE_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_DRAFT_SETTINGS:"GET_WEBSITE_DRAFT_SETTINGS",AI_CONTEXT:"AI_CONTEXT",GET_WEBSITE_DATA:"GET_WEBSITE_DATA",UPDATE_WEBSITE_DATA:"UPDATE_WEBSITE_DATA",GET_CHAI_USER:"GET_CHAI_USER",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_REVISION_DATA:"GET_REVISION_DATA",GET_PAGE_DATA:"GET_PAGE_DATA",GET_COMPARE_DATA:"GET_COMPARE_DATA",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",DELETE_LIBRARY_ITEM:"DELETE_LIBRARY_ITEM",MARK_AS_TEMPLATE:"MARK_AS_TEMPLATE",UNMARK_AS_TEMPLATE:"UNMARK_AS_TEMPLATE",GET_TEMPLATES_BY_TYPE:"GET_TEMPLATES_BY_TYPE",GET_DYNAMIC_PAGES:"GET_DYNAMIC_PAGES",GET_APP_SHARED_JSONLD:"GET_APP_SHARED_JSONLD",UPDATE_APP_SHARED_JSONLD:"UPDATE_APP_SHARED_JSONLD",UPLOAD_ASSET:"UPLOAD_ASSET",DELETE_ASSET:"DELETE_ASSET",UPDATE_ASSET:"UPDATE_ASSET",GET_ASSETS:"GET_ASSETS",GET_ASSET:"GET_ASSET"},ir=K.atom({}),Gt=()=>K.useAtom(ir),oe=(e,t)=>{const[s]=Gt();return h.useMemo(()=>p.get(s,e,t),[s,e,t])},F=()=>oe("apiUrl","/chai/api"),Ot=()=>oe("usersApiUrl","/chai/users"),or=()=>oe("assetsApiUrl","/chai/assets"),lr=()=>oe("supabaseInstance",null);let cr=0;function xs(e,t){const s=`atom${++cr}`,n={toString(){return s}};return typeof e=="function"?n.read=e:(n.init=e,n.read=ur,n.write=dr),t&&(n.write=t),n}function ur(e){return e(this)}function dr(e,t,s){return t(this,typeof s=="function"?s(e(this)):s)}const fr=Symbol(""),Fs=e=>typeof(e==null?void 0:e.then)=="function";function hr(e=()=>{try{return window.localStorage}catch{return}},t){var s;let n,r;const a={getItem:(c,u)=>{var f,d;const g=y=>{if(y=y||"",n!==y){try{r=JSON.parse(y,t==null?void 0:t.reviver)}catch{return u}n=y}return r},E=(d=(f=e())==null?void 0:f.getItem(c))!=null?d:null;return Fs(E)?E.then(g):g(E)},setItem:(c,u)=>{var f;return(f=e())==null?void 0:f.setItem(c,JSON.stringify(u,void 0))},removeItem:c=>{var u;return(u=e())==null?void 0:u.removeItem(c)}},i=c=>(u,f,d)=>c(u,g=>{let E;try{E=JSON.parse(g||"")}catch{E=d}f(E)});let l;try{l=(s=e())==null?void 0:s.subscribe}catch{}return!l&&typeof window<"u"&&typeof window.addEventListener=="function"&&window.Storage&&(l=(c,u)=>{if(!(e()instanceof window.Storage))return()=>{};const f=d=>{d.storageArea===e()&&d.key===c&&u(d.newValue)};return window.addEventListener("storage",f),()=>{window.removeEventListener("storage",f)}}),l&&(a.subscribe=i(l)),a}const gr=hr();function qs(e,t,s=gr,n){const r=xs(t);return r.onMount=i=>{i(s.getItem(e,t));let l;return s.subscribe&&(l=s.subscribe(e,i,t)),l},xs(i=>i(r),(i,l,c)=>{const u=typeof c=="function"?c(i(r)):c;return u===fr?(l(r,t),s.removeItem(e)):Fs(u)?u.then(f=>(l(r,f),s.setItem(e,f))):(l(r,u),s.setItem(e,u))})}localStorage.removeItem("_chai_user");localStorage.removeItem("__chai__user");const Ks="__logged_in_user",mr=qs(Ks,null),re=()=>{const[e,t]=K.useAtom(mr),s=h.useCallback(()=>{t(null),localStorage.removeItem(Ks)},[t]);return{isLoggedIn:!!e,user:e,setUser:t,logout:s}},as=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)});let be=null;function Er(){const{user:e,setUser:t,logout:s}=re(),n=Ot(),r=oe("getAccessToken",!1),a=async()=>{if(r===!1&&e&&!(!p.has(e,"expiresAt")||!p.has(e,"accessToken")||!p.has(e,"refreshToken")))try{const i=await as(n,{action:"REFRESH_TOKEN",data:{refreshToken:e.refreshToken,accessToken:e.accessToken}});if(!i.ok){s(),window.location.reload();return}const l=await i.json();if(p.has(l,"id")&&p.has(l,"email")&&p.has(l,"accessToken")&&p.has(l,"refreshToken"))return t(l),l;s(),window.location.reload()}catch{s(),window.location.reload()}};return w.useMutation({mutationFn:async()=>{if(be)return await be;be=a();try{return await be}finally{be=null}},onSuccess:()=>{}})}function pr(){return be}const Vs=()=>{const{user:e,setUser:t}=re(),{mutateAsync:s}=Er(),n=60,r=h.useCallback(()=>{if(!(e!=null&&e.expiresAt))return!1;if(!e||!(e!=null&&e.refreshToken))return!0;const l=Math.floor(Date.now()/1e3);return e.expiresAt-l<=n},[e]),i=oe("getAccessToken",async()=>{if(!p.has(e,"expiresAt")||!p.has(e,"accessToken")||!p.has(e,"refreshToken"))return(e==null?void 0:e.accessToken)||"";if(r()){const l=pr();if(l){const u=await l;return u&&t(u),(u==null?void 0:u.accessToken)||""}const c=await s();return c&&t(c),(c==null?void 0:c.accessToken)||""}return(e==null?void 0:e.accessToken)||""});return{getAccessToken:h.useCallback(async()=>{try{return await i()}catch{return""}},[i])}},R=()=>{const{logout:e}=re(),{getAccessToken:t}=Vs();return h.useCallback(async(s,n,r={})=>{const a=await t();if(!a)return console.error("No auth token found"),null;try{const i=p.get(n,"action","").toLowerCase(),l=await as(s+(i?`?action=${i}`:""),n,{...r,Authorization:`Bearer ${a}`});if(l.status===401)return console.log("401 Response",l),e(),window.location.reload(),null;if(!l.ok){const c=await l.json();throw console.error(`API Error (${l.status}):`,c),{status:l.status,statusText:l.statusText,...c,message:c.error||c.message||`Server error: ${l.status}`}}return await l.json()}catch(i){throw console.error("API request failed:",n,i),i}},[e,t])};function ee(){const[e,t]=h.useState(new URLSearchParams(window.location.search));return h.useEffect(()=>{const s=()=>{t(new URLSearchParams(window.location.search))};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[]),[e,t]}const Ae=e=>{const t=F(),[s]=ee(),n=e??s.get("page"),r=R();return w.useQuery({queryKey:[S.GET_LANGUAGE_PAGES,n],staleTime:1/0,gcTime:0,placeholderData:[],queryFn:async()=>{if(!n)return null;const a=await r(t,{action:S.GET_LANGUAGE_PAGES,data:{id:n}});return p.reverse(p.sortBy(a,"primaryPage"))},enabled:!!n})},Se=()=>{const e=F(),t=R();return w.useQuery({queryKey:[S.GET_WEBSITE_DRAFT_SETTINGS],staleTime:5*60*1e3,placeholderData:{languages:[],theme:{fontFamily:"",borderRadius:"",colors:{}},appKey:"",fallbackLang:""},queryFn:async()=>t(e,{action:S.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})},is=e=>{const{fallbackLang:t}=N.useLanguages(),{data:s}=Se(),{data:n,isFetching:r}=Ae(),a=h.useMemo(()=>{const i={[t]:!0};return p.each(p.get(s,"languages"),l=>{const c=p.find(n,{lang:l});i[l]=!!c}),i},[t,n,s]);return r||p.isEmpty(e)||e&&a[e]};class Hs{constructor(t,s,n,r){me(this,"channelId");me(this,"supabase");me(this,"channel",null);me(this,"userId",null);me(this,"clientId",null);me(this,"pageId",null);me(this,"callback");var a,i,l,c,u,f;this.userId=n,this.supabase=t,this.clientId=this.getClientId(),this.channelId=`WEBSITE:${s}`,this.callback=r,this.channel=this.supabase.channel(this.channelId,{config:{presence:{key:this.clientId}}}),(f=(u=(c=(l=(i=(a=this.channel)==null?void 0:a.on("presence",{event:"sync"},d=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",d)}))==null?void 0:i.on("presence",{event:"leave"},d=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",d)}))==null?void 0:l.on("presence",{event:"join"},d=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",d)}))==null?void 0:c.on("broadcast",{event:"TAKE_OVER_REQUESTED"},({payload:d})=>this.onReceiveEvent("TAKE_OVER_REQUESTED",d)))==null?void 0:u.on("broadcast",{event:"TAKE_OVER_REQUEST_ACCEPTED"},({payload:d})=>this.onReceiveEvent("TAKE_OVER_REQUEST_ACCEPTED",d)))==null||f.on("broadcast",{event:"TAKE_OVER_REQUEST_REJECTED"},({payload:d})=>this.onReceiveEvent("TAKE_OVER_REQUEST_REJECTED",d)).subscribe()}getClientId(){return crypto.randomUUID()}getOnlineUsers({pageId:t,userId:s}){var a;const n=(a=this.channel)==null?void 0:a.presenceState();let r=Object.values(n||{}).map(i=>i[0]).filter(Boolean);return t?r=r.filter(i=>i.pageId===t):s&&(r=r.filter(i=>i.userId===s)),r.sort((i,l)=>i.onlineAt-l.onlineAt)}getPageOwner(){const t=this.getOnlineUsers({pageId:this.pageId});return t.length>0?t[0]:null}getPageUserMapping(){const t=this.getOnlineUsers({}),s=p.groupBy(t,"pageId"),n={};return Object.keys(s).forEach(r=>{var i;const a=(i=p.minBy(s[r],"onlineAt"))==null?void 0:i.userId;a!==this.userId&&(n[r]=a)}),n}onReceiveEvent(t,s){if(!this.pageId)return;const n=this.getPageOwner();if(!n||n.clientId===this.clientId?this.callback("USER_JOINED",{isActiveInOtherTab:!1}):this.callback("PAGE_LOCKED",{isActiveInOtherTab:(n==null?void 0:n.userId)===this.userId&&(n==null?void 0:n.clientId)!==this.clientId}),s.targetClientId===this.clientId)switch(t){case"TAKE_OVER_REQUESTED":this.callback("TAKE_OVER_REQUESTED",{requestedBy:s==null?void 0:s.userId,requestingClientId:s==null?void 0:s.senderClientId,isRequestedFromAnotherTab:(s==null?void 0:s.senderClientId)!==this.clientId&&(s==null?void 0:s.userId)===this.userId});break;case"TAKE_OVER_REQUEST_ACCEPTED":this.channel.track({pageId:this.pageId,userId:this.userId,clientId:this.clientId,onlineAt:n?n.onlineAt-10:+new Date}),this.callback("TAKE_OVER_REQUEST_ACCEPTED",{isTakingOverFromAnotherTab:(s==null?void 0:s.senderClientId)!==this.clientId&&(s==null?void 0:s.userId)===this.userId});break;case"TAKE_OVER_REQUEST_REJECTED":this.callback("TAKE_OVER_REQUEST_REJECTED");break}}async joinPage(t){var s;this.pageId=t,(s=this.channel)==null||s.track({pageId:this.pageId,userId:this.userId,clientId:this.clientId,onlineAt:+new Date})}async leavePage(){var t;this.channel&&((t=this.channel)==null||t.untrack())}async sendEvent(t,s){var n,r;if(this.channel){const a={pageId:this.pageId,userId:this.userId,senderClientId:this.clientId};t==="TAKE_OVER_REQUESTED"?a.targetClientId=(n=this.getPageOwner())==null?void 0:n.clientId:(t==="TAKE_OVER_REQUEST_ACCEPTED"||t==="TAKE_OVER_REQUEST_REJECTED")&&(a.targetClientId=s==null?void 0:s.requestingClientId),await((r=this.channel)==null?void 0:r.send({event:t,payload:a,type:"broadcast"}))}}}const yr=K.atom(null),Qs=()=>K.useAtom(yr),os=()=>{const[e]=Qs();return(e==null?void 0:e.slug)||""};function Ar(e,t){const[s,n]=h.useState(e);return h.useEffect(()=>{const r=setTimeout(()=>n(e),t);return()=>clearTimeout(r)},[e,t]),s}const Sr=({query:e,uuid:t})=>{const{selectedLang:s,fallbackLang:n}=N.useLanguages(),{data:r}=Z(),a=r==null?void 0:r.pageType,i=F(),l=R(),{data:c,isFetching:u}=w.useQuery({queryKey:[S.GET_DYNAMIC_PAGES,e,a,t],staleTime:60*60*1e3,placeholderData:[],queryFn:async()=>await l(i,{action:S.GET_DYNAMIC_PAGES,data:{query:e,pageType:a,uuid:t}})||[],enabled:!!a}),f=h.useMemo(()=>s===""?c.filter(d=>d.lang===""||d.lang===n):c.filter(d=>d.lang===s),[s,n,c]);return{allLangPages:c,data:f,isFetching:u}},zs=()=>{const{selectedLang:e,fallbackLang:t}=N.useLanguages(),[s,n]=Qs(),[r,a]=h.useState(""),i=Ar(r,500),{allLangPages:l,data:c,isFetching:u}=Sr({query:i}),f=h.useCallback(E=>n(E),[n]),d=h.useCallback(E=>a(E),[a]),g=h.useCallback(()=>{if(!s)return;const E=!(s!=null&&s.primaryPage),y=e.length===0,x=E?s==null?void 0:s.id:s==null?void 0:s.primaryPage,A=l.filter(T=>(T==null?void 0:T.primaryPage)===x||T.id===x).find(T=>y?T.lang===e||T.lang===t:T.lang===e);n(A||s)},[s,e,l,n,t]);return{isFetching:u,dynamicPage:s,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:f,updateSearchQuery:d,onChangeLanguage:g}},Tr=K.atom({lastSaved:void 0}),Rt=()=>K.useAtom(Tr),Z=()=>{const[e]=ee(),t=e.get("page"),{data:s,isFetching:n}=Ae();return{data:h.useMemo(()=>({...p.find(s,{id:t})||{}}),[s,t]),isFetching:n}},de=()=>{const[e]=ee(),t=e.get("lang")??"",{data:s,isFetching:n}=Ae();return{data:h.useMemo(()=>p.find(s,{lang:t})||{},[s,t]),isFetching:n}},Pr=K.atom({}),xr=()=>K.useAtom(Pr),_r=()=>{const{data:e}=de(),t=os(),s=oe("getLiveUrl",p.noop),n=e==null?void 0:e.slug,r=s(n||"/");return t?r+t:r},$s=e=>{const t=Ot(),s=R();return w.useQuery({queryKey:[S.GET_CHAI_USER,e],queryFn:async()=>{const r=await s(t,{action:S.GET_CHAI_USER,data:{userId:e}});return{...r,name:r.name||r.email}},enabled:!p.isEmpty(e),staleTime:"static"})},wr=K.atom({status:"checking",requestedBy:"",isTakeOverRequested:!1,requestingClientId:"",isActiveInOtherTab:!1}),vr=K.atom(""),br=K.atom(null),ls=K.atom({}),Cr=()=>K.useAtom(ls),Te=()=>{const[e]=ee(),t=e.get("page"),[s,n]=K.useAtom(wr),[r,a]=K.useAtom(br),[i,l]=K.useAtom(vr),[c]=K.useAtom(ls);return{pageLock:s,pageToUser:c,lockingStatus:i,realtimeInstance:r,setPageLock:n,setLockingStatus:l,setRealtimeInstance:a,realtimePageLockEnabled:!!r,currentEditor:c[t||""],isLocked:t&&s.status==="locked"}},Ir=()=>{const e=lr(),{data:t}=Z(),{user:s}=re(),n=t==null?void 0:t.id,{data:r}=Se(),{pageLock:a,setPageLock:i,setLockingStatus:l,realtimeInstance:c,setRealtimeInstance:u}=Te(),[,f]=K.useAtom(ls),d=h.useRef(!1),g=h.useRef(a),E=h.useRef(!1);return h.useEffect(()=>{if(s!=null&&s.id&&e&&!c&&(r!=null&&r.appKey)&&!E.current){E.current=!0;const y=async(P,A)=>{var T,C;switch(P){case"UPDATE_ONLINE_USERS":f((A==null?void 0:A.pageToUser)||{});break;case"PAGE_LOCKED":i({...g==null?void 0:g.current,requestedBy:"",status:"locked",isActiveInOtherTab:A==null?void 0:A.isActiveInOtherTab});break;case"USER_JOINED":if(((T=g==null?void 0:g.current)==null?void 0:T.status)==="editing")return;((C=g==null?void 0:g.current)==null?void 0:C.status)==="locked"&&l("can_edit_now"),i({...g==null?void 0:g.current,requestedBy:"",status:"editing",isActiveInOtherTab:A==null?void 0:A.isActiveInOtherTab});break;case"TAKE_OVER_REQUESTED":i({...g==null?void 0:g.current,requestingClientId:A==null?void 0:A.requestingClientId,requestedBy:A!=null&&A.isRequestedFromAnotherTab?"ANOTHER_TAB":A==null?void 0:A.requestedBy});break;case"TAKE_OVER_REQUEST_ACCEPTED":A!=null&&A.isTakingOverFromAnotherTab||(l("take_over_request_accepted"),$.toast.success("Your Page Take Over Request Accepted",{position:"top-center"})),i({...g==null?void 0:g.current,status:"checking",requestedBy:"",requestingClientId:"",isTakeOverRequested:!1});break;case"TAKE_OVER_REQUEST_REJECTED":l("take_over_request_rejected"),i({...g==null?void 0:g.current,requestedBy:"",requestingClientId:"",isTakeOverRequested:!1});break}},x=new Hs(e,r==null?void 0:r.appKey,s==null?void 0:s.id,y);u(x)}},[u,e,r==null?void 0:r.appKey]),h.useEffect(()=>{g.current=a},[a]),h.useEffect(()=>{if(!(!c||!n||!(s!=null&&s.id)||d.current))return d.current=!0,c==null||c.joinPage(n),()=>{c&&d.current&&(d.current=!1,g.current={requestedBy:"",status:"checking",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1},l(""),i(g.current),c==null||c.leavePage())}},[n,c]),a==null?void 0:a.status},Ws=()=>{const{data:e}=Z(),{user:t}=re(),s=e==null?void 0:e.id,{pageLock:n,setPageLock:r,realtimeInstance:a}=Te(),{savePageAsync:i}=N.useSavePage(),l=h.useCallback(()=>{!a||!s||!(t!=null&&t.id)||(r({...n,isTakeOverRequested:!0}),a==null||a.sendEvent("TAKE_OVER_REQUESTED"))},[a,s,t==null?void 0:t.id,r,n]),c=h.useCallback(async()=>{!a||!s||!(t!=null&&t.id)||(await i(),a==null||a.sendEvent("TAKE_OVER_REQUEST_ACCEPTED",{requestingClientId:n==null?void 0:n.requestingClientId}),r({requestedBy:"",status:"locked",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1}))},[s,a,t==null?void 0:t.id,r,i,n]),u=h.useCallback(()=>{!a||!s||!(t!=null&&t.id)||(a==null||a.sendEvent("TAKE_OVER_REQUEST_REJECTED",{requestingClientId:n==null?void 0:n.requestingClientId}),r({...n,requestedBy:"",status:"editing",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1}))},[s,a,t==null?void 0:t.id,r,n]);return{pageLock:n,acceptTakeOver:c,rejectTakeOver:u,requestTakeOver:l}},Nr=h.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-content-iZo2ztXp.cjs"))),Lr=h.lazy(()=>Promise.resolve().then(()=>require("./page-locked-by-dialog-B9pGi6zb.cjs"))),Vt=h.lazy(()=>Promise.resolve().then(()=>require("./page-lock-request-D3gmV8Yq.cjs"))),jr=({isFetchingPage:e})=>{const{pageLock:t,requestTakeOver:s}=Ws(),{currentEditor:n,lockingStatus:r,setLockingStatus:a,realtimePageLockEnabled:i}=Te(),{data:l,isFetching:c}=$s(n),[u]=ee(),f=u.get("page"),[d]=Rt(),g=w.useQueryClient(),E=h.useCallback(()=>{s()},[s]);return!f||e||!i||(t==null?void 0:t.status)==="checking"?null:t!=null&&t.requestedBy?o.jsx(h.Suspense,{children:o.jsx(Vt,{lockingStatus:"",onContinue:()=>{s()}})}):(t==null?void 0:t.status)!=="locked"?r==="take_over_request_accepted"||r==="can_edit_now"?o.jsx(h.Suspense,{children:o.jsx(Vt,{lockingStatus:r,onContinue:()=>{g.invalidateQueries({queryKey:[S.GET_DRAFT_PAGE]}),a("")}})}):null:t!=null&&t.isActiveInOtherTab?o.jsx(h.Suspense,{children:o.jsx(Vt,{lockingStatus:"page_is_active_in_other_tab",onContinue:s})}):o.jsx(h.Suspense,{children:o.jsx(Lr,{...l,isFetchingUserInfo:c,name:(l==null?void 0:l.name)||"Unknown User",email:(l==null?void 0:l.email)||"",lastSaved:(d==null?void 0:d.lastSaved)||"",onTakeOver:E,realtimePageLockEnabled:i,isRequestRejected:r==="take_over_request_rejected"})})},kr=()=>{const[e]=ee(),t=e.get("lang");return is(t)?null:o.jsx(h.Suspense,{children:o.jsx(Nr,{})})},We={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"};function cs(e,t,s=!1){const n=e.toString()?`?${e.toString()}`:"/";s?window.history.replaceState(null,"",n):window.history.pushState({},"",n),t(e),window.dispatchEvent(new PopStateEvent("popstate"))}const Ut=K.atom(null),Mt=()=>{const{data:e}=Se();return h.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},us=()=>{const e=R(),t=F();return w.useQuery({queryKey:[S.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:S.GET_WEBSITE_PAGES})||[],placeholderData:s=>s||[]})},Dr=e=>{const t=R(),s=F(),n=Mt();return w.useQuery({queryKey:[S.GET_WEBSITE_PAGES,e,n],staleTime:1e3*60*5,enabled:!!e,queryFn:async()=>{if(n===e)return{};const r=await t(s,{action:S.GET_WEBSITE_PAGES,data:{lang:e}})||[];return p.keyBy(p.map(r,a=>({...a,lang:e})),"primaryPage")},placeholderData:r=>r||{}})},Gr=h.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-CFtYUNbS.cjs"))),Ys=({children:e})=>{const[t,s]=ee(),n=t.get("page"),{data:r,isFetching:a}=Z(),{data:i,isFetching:l}=us(),[c,u]=h.useState(!1),[f,d]=h.useState(!0),{savePage:g}=N.useSavePage(),E=!!n&&!p.isEmpty(r),y=h.useMemo(()=>{if(!i||l)return!1;const T=i.find(C=>C.slug==="/");return T==null?void 0:T.id},[i,l]);h.useEffect(()=>{if(l||!y||i.some(U=>U.id===n))return;const C=new URLSearchParams({page:y});cs(C,s),!l&&i&&d(!1)},[n,l,i,y,s]);const x=!f&&!n,P=!f&&!a&&p.isEmpty(r),A=c||x||P;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex items-center gap-x-1",children:o.jsx("div",{className:"relative",children:o.jsxs(m.Tooltip,{children:[o.jsx(m.TooltipTrigger,{asChild:!0,onClick:()=>{g(),u(!0)},children:e||o.jsx(m.Button,{variant:"outline",className:"flex w-full items-center space-x-2 py-1",children:o.jsx(_.LogsIcon,{className:"h-4 w-4"})},"template-viewer")}),o.jsx(m.TooltipContent,{side:"right",children:o.jsx("p",{children:"Open pages manager"})})]})})}),o.jsx(m.Sheet,{open:A,onOpenChange:T=>!T&&E&&u(!1),children:o.jsxs(m.SheetContent,{side:"left","aria-describedby":"pages-manager-description",className:`z-50 !min-w-[50vh] !max-w-[800px] border-border p-0 ${E?"":"sheet-hide-close-btn"}`,children:[o.jsxs(m.SheetHeader,{className:"mb-3 px-4 pt-4",children:[o.jsxs(m.SheetTitle,{className:"flex items-center gap-2 text-sm font-semibold",children:[o.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:o.jsx(_.Folder,{className:"h-4 w-4"})}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-semibold",children:"Pages"}),o.jsx("span",{id:"pages-manager-description",className:"text-xs font-normal text-muted-foreground",children:"Manage your site structure"})]})]}),o.jsx(m.SheetDescription,{className:"sr-only",children:"Manage your site structure"})]}),o.jsx("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:A&&o.jsx(h.Suspense,{children:o.jsx(Gr,{close:()=>u(!1)})})})]})})]})},Or=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-Dt9DWunK.cjs"))),Rr=()=>{const e=oe("topLeftCorner",null);return e?o.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:h.createElement(e,{})}):null},Js=({showAdd:e=!0,variant:t="ghost"})=>{const{fallbackLang:s,languages:n,selectedLang:r,setSelectedLang:a}=N.useLanguages(),i=p.isEmpty(r)?s:r,[,l]=ee(),{isLocked:c}=Te();h.useEffect(()=>{const P=new URLSearchParams(window.location.search),A=P.get("lang");A&&(n.includes(A)?a(A):(P.delete("lang"),l(P),a("")))},[n,l,a]);const[,u]=K.useAtom(Ut),{data:f}=Z(),{data:d}=Se(),{data:g}=Ae(),E=h.useMemo(()=>{const P=p.compact(p.map(p.get(d,"languages"),A=>{const T=p.find(g,{lang:A});return{key:A,value:p.get(We,A,A),isLangPageAdded:!!T}})).filter(Boolean);return[{key:s,value:p.get(We,s),isLangPageAdded:!0},...P]},[s,g,d]),y=P=>{if(document.querySelector('[data-panel-id="seo"]')){const T=new CustomEvent("seo-language-switch-check",{detail:{fromLang:i,toLang:P,switchHandler:()=>x(P)}});window.dispatchEvent(T);return}x(P)},x=P=>{a(P);const A=new URLSearchParams(window.location.search);P===s?A.delete("lang"):A.set("lang",P),cs(A,l)};return p.isEmpty(n)?null:c?o.jsxs(m.Button,{variant:"ghost",size:"sm",className:"ml-px h-max cursor-not-allowed gap-2 py-1.5 opacity-50",children:[o.jsx(_.Languages,{className:"h-4 w-4"}),p.get(We,i,i),o.jsx(_.ChevronDown,{className:"h-4 w-4"})]}):o.jsx(o.Fragment,{children:o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:o.jsxs(m.Button,{disabled:!!c,variant:t,size:"sm",className:"ml-px h-max gap-2 py-1.5",children:[o.jsx(_.Languages,{className:"h-4 w-4"}),p.get(We,i,i),o.jsx(_.ChevronDown,{className:"h-4 w-4"})]})}),o.jsxs(m.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(E.filter(P=>P.isLangPageAdded),P=>o.jsxs(m.DropdownMenuItem,{className:N.mergeClasses("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",P.key===i&&"!bg-gray-200 text-gray-700"),onClick:()=>y(P.key),children:[o.jsx("div",{className:"text-slate-600",children:P.value}),P.key===s&&o.jsxs("small",{className:"flex items-center gap-x-1 text-[9px] leading-none text-orange-500",children:[o.jsx(_.Star,{fill:"orange",className:"h-2 w-2"}),"Primary"]})]},P.value)),e&&!p.isEmpty(E.filter(P=>!P.isLangPageAdded))&&o.jsxs(o.Fragment,{children:[o.jsx(m.Separator,{}),o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:()=>{f&&u({edit:!1,primaryPage:f.id})},className:"text-xs font-normal duration-200 hover:bg-slate-300 hover:text-slate-800",children:[o.jsx(_.Plus,{className:"mr-1 h-3 w-3"})," Add Langauge"]})]})]})]})})};function Ur(){const[e,t]=K.useAtom(Ut);return o.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[o.jsx(Rr,{}),o.jsx(Ys,{}),e&&o.jsx(h.Suspense,{children:o.jsx(Or,{isOpen:!0,id:e==null?void 0:e.id,edit:!!(e!=null&&e.id),primaryPage:e==null?void 0:e.primaryPage,preselectedLang:e==null?void 0:e.preselectedLang,onClose:()=>t(null)})})]})}const ds=K.atom("");function Mr(){return o.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((e,t)=>o.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[o.jsxs("div",{className:"flex-1 space-y-1",children:[o.jsx(m.Skeleton,{className:"h-4 w-3/4"}),o.jsx(m.Skeleton,{className:"h-3 w-1/2"}),o.jsx(m.Skeleton,{className:"mt-1 h-5 w-20"})]}),o.jsx(m.Skeleton,{className:"h-8 w-8 rounded-full"})]},t))})}const Br=Q.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-BjIECUPY.cjs")));function Fr(){const[e,t]=Q.useState(!1);return o.jsx(m.TooltipProvider,{children:o.jsxs(m.Tooltip,{delayDuration:0,children:[o.jsxs(m.Sheet,{open:e,onOpenChange:t,children:[o.jsx(m.SheetTrigger,{asChild:!0,children:o.jsx(m.TooltipTrigger,{asChild:!0,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsxs(m.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[o.jsx(_.History,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"View revision history"})]}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})})}),o.jsx(m.SheetContent,{className:"flex h-[100vh] flex-col",children:e&&o.jsx(h.Suspense,{fallback:o.jsx(Mr,{}),children:o.jsx(Br,{isOpen:e})})})]}),o.jsx(m.TooltipContent,{side:"bottom",children:o.jsx("p",{children:"Revision history"})})]})})}const xt=({permission:e,permissions:t,children:s,fallback:n=null})=>{const{hasPermission:r}=N.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?n:s},Y={TOGGLE_PREVIEW:"Toggle 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 page",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",MARK_AS_TEMPLATE:"Mark as template",UNMARK_AS_TEMPLATE:"Unmark 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."},qr={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},fe=()=>{const e=F(),t=R();return w.useQuery({queryKey:[S.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:S.GET_PAGE_TYPES})})},Xs=e=>{const{data:t}=fe();return h.useMemo(()=>t==null?void 0:t.find(s=>s.key===e),[t,e])},Kr=()=>{const e=F(),t=R();return w.useMutation({mutationFn:async({pageType:s,query:n})=>{try{return t(e,{action:S.SEARCH_PAGES,data:{pageType:s,query:Array.isArray(n)&&n.length>0?n[0]:n}})||[]}catch(r){return console.error(r),[]}}})},Vr=()=>{const e=F(),t=w.useQueryClient(),s=R(),{data:n}=fe();return w.useMutation({mutationFn:async r=>await s(e,{action:S.CREATE_PAGE,data:r}),onSuccess:(r,a)=>{var l;a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[S.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[S.GET_WEBSITE_PAGES,a==null?void 0:a.lang]})):t.invalidateQueries({queryKey:[S.GET_WEBSITE_PAGES]});const i=a.template?`Page created from "${a.template.name}" template`:a.hasSlug===!1?"New "+((l=p.find(n,{key:a.pageType}))==null?void 0:l.name)+" added successfully":"New page added successfully";$.toast.success(i)},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});$.toast.error(`Failed to add new ${i!=null&&i.hasSlug?"page":i.name}.`,{description:p.get(qr,r.message,r.message)})}})},Hr=()=>{const e=F(),t=w.useQueryClient(),s=R(),{data:n}=de(),{data:r}=fe();return w.useMutation({mutationFn:async a=>await s(e,{action:S.UPDATE_PAGE,data:a}),onSuccess:(a,i)=>{(n==null?void 0:n.id)===(i==null?void 0:i.id)&&t.invalidateQueries({queryKey:[S.GET_LANGUAGE_PAGES]}),i&&(i!=null&&i.primaryPage||i!=null&&i.seo)?(t.invalidateQueries({queryKey:[S.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}),t.invalidateQueries({queryKey:[S.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[S.GET_WEBSITE_PAGES]})},onError:(a,i)=>{const l=p.find(r,{key:i.pageType});$.toast.error(`Failed to update ${l!=null&&l.hasSlug?"page":l.name}.`,{description:a.message})}})},Qr=()=>{const e=F(),t=w.useQueryClient(),s=R(),{data:n}=fe();return w.useMutation({mutationFn:async r=>s(e,{action:S.DELETE_PAGE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{if(r.code==="PAGE_LOCKED"){$.toast.error("Delete not allowed",{description:"Page is currently being edited by another user."});return}a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[S.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[S.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[S.GET_WEBSITE_PAGES]})},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});$.toast.error(`Failed to delete ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},zr=()=>{const e=F(),t=w.useQueryClient(),s=R(),{data:n}=fe();return w.useMutation({mutationFn:async r=>s(e,{action:S.TAKE_OFFLINE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[S.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[S.GET_WEBSITE_PAGES]});const i=p.find(n,{key:a.pageType});$.toast.success(i!=null&&i.hasSlug?Y.PAGE_UNPUBLISH_SUCCESS:"New "+i.name+" added successfully.")},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});$.toast.error(`Failed to take offline ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},fs=()=>{const e=F(),t=R(),s=w.useQueryClient(),{data:n}=Z(),{savePageAsync:r}=N.useSavePage();return w.useMutation({mutationFn:async({ids:a})=>(await r(),t(e,{action:S.PUBLISH_CHANGES,data:{ids:a}})),onSuccess:()=>{s.invalidateQueries({queryKey:[S.GET_CHANGES]}),s.invalidateQueries({queryKey:[S.GET_WEBSITE_PAGES]}),s.invalidateQueries({queryKey:[S.GET_LANGUAGE_PAGES,n==null?void 0:n.id]})},onError:a=>{console.log("##",a),$.toast.error("Failed to publish pages.")}})},$r=()=>{const e=F(),t=R(),s=w.useQueryClient();return w.useMutation({mutationFn:async n=>{var r;return t(e,{action:S.MARK_AS_TEMPLATE,data:{id:(r=n.page)==null?void 0:r.id,name:n.name,description:n.description,pageType:n.pageType,previewImage:n.previewImage}})},onSuccess:()=>{s.invalidateQueries({queryKey:[S.GET_WEBSITE_PAGES]}),$.toast.success("Page marked as template successfully.")},onError:()=>{$.toast.error("Failed to mark page as template.")}})},Wr=()=>{const e=F(),t=R(),s=w.useQueryClient();return w.useMutation({mutationFn:async n=>t(e,{action:S.UNMARK_AS_TEMPLATE,data:{id:n==null?void 0:n.id}}),onSuccess:()=>{s.invalidateQueries({queryKey:[S.GET_WEBSITE_PAGES]}),$.toast.success("Page unmarked as template successfully.")},onError:()=>{$.toast.error("Failed to unmark page as template.")}})},Yr=()=>{const e=F(),t=R(),s=w.useQueryClient();return w.useMutation({mutationFn:async({id:n,slug:r})=>t(e,{action:S.CHANGE_SLUG,data:{id:n,slug:r}}),onSuccess:(n,{primaryPage:r})=>{$.toast.success(Y.SLUG_CHANGE_SUCCESS),r?s.invalidateQueries({queryKey:[S.GET_LANGUAGE_PAGES,r]}):s.invalidateQueries({queryKey:[S.GET_WEBSITE_PAGES]})},onError:()=>{$.toast.error("Failed to change slug")}})},Jr=h.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-CTduLNtg.cjs")));function Xr({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:s,isPending:n}=fs();return o.jsx(m.Dialog,{open:e,onOpenChange:n?()=>{}:t,children:e&&o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"h-96 w-96 animate-pulse bg-gray-100"}),children:o.jsx(Jr,{onClose:t,isPending:n,publishPage:s})})})}const te={...N.PERMISSIONS,ADD_PAGE:"add_page",EDIT_PAGE:"edit_page",EDIT_SLUG:"edit_slug",DELETE_PAGE:"delete_page",CHANGE_PAGE_TYPE:"change_page_type",PUBLISH_PAGE:"publish_page",UNPUBLISH_PAGE:"unpublish_page",MARK_AS_TEMPLATE:"mark_as_template",UNMARK_AS_TEMPLATE:"unmark_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:"create_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"},Zr={particleCount:350,spread:120,origin:{y:.6},angle:90},ea={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},ta=async()=>{const{default:e}=await Promise.resolve().then(()=>require("./confetti.module-BuUnQuWk.cjs"));return e},_t=e=>{let t=ea[e];t||(t={});const s={...Zr,...t};ta().then(n=>n(s))};function Bt({children:e,content:t,side:s="bottom",delayDuration:n=700,showTooltip:r=!0}){return r?o.jsx(m.TooltipProvider,{children:o.jsxs(m.Tooltip,{delayDuration:n,children:[o.jsx(m.TooltipTrigger,{asChild:!0,children:e}),o.jsx(m.TooltipContent,{side:s,sideOffset:10,children:o.jsx("p",{children:t})})]})}):e}const sa=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-D3NM8b3u.cjs"))),na=h.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-Kctu12rQ.cjs"))),ra=()=>{const{selectedLang:e,fallbackLang:t}=N.useLanguages(),s=oe("getPreviewUrl",async E=>E),[,n]=K.useAtom(ds),[r,a]=h.useState(""),{data:i}=Z(),{data:l}=Ae(),{data:c}=fe(),u=h.useMemo(()=>{var E;return(E=l==null?void 0:l.find(y=>(y==null?void 0:y.lang)===e))==null?void 0:E.slug},[e,l]),f=h.useCallback(E=>{var y;return(y=p.find(c,{key:E}))==null?void 0:y.hasSlug},[c]),d=e===t?"":e;h.useEffect(()=>{(async()=>{if(typeof s=="function"){const E=!f(i==null?void 0:i.pageType),y=await s(E?`${d!==""?d+"/":""}${i==null?void 0:i.id}`:u||"");a(y)}else a("")})()},[s,u,i==null?void 0:i.pageType,f,i==null?void 0:i.id,d]);const g=()=>{n(r)};return o.jsx(o.Fragment,{children:o.jsx(Bt,{content:Y.TOGGLE_PREVIEW,delayDuration:0,children:o.jsx(m.Button,{variant:"ghost",size:"sm",className:"gap-2",onClick:g,children:o.jsx(_.Play,{className:"h-4 w-4"})})})})},aa=()=>{const[e,t]=N.useRightPanel();return o.jsxs(o.Fragment,{children:[o.jsx(Bt,{content:Y.THEME,delayDuration:0,children:o.jsx(m.Button,{variant:e==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>t(e==="theme"?"block":"theme"),children:o.jsx(_.Palette,{className:"h-4 w-4"})})}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})},ia=()=>{const[e,t]=h.useState(!1),{isLocked:s}=Te(),{savePageAsync:n,saveState:r}=N.useSavePage();h.useEffect(()=>{const u=f=>{r==="UNSAVED"&&(f.preventDefault(),f.returnValue=!1)};return r==="UNSAVED"&&window.addEventListener("beforeunload",u),()=>{window.removeEventListener("beforeunload",u)}},[r]);const a=h.useCallback(async()=>{e||(t(!0),await n(),t(!1))},[n,e]),{buttonIcon:i,buttonClass:l,tooltipContent:c}=h.useMemo(()=>{switch(r){case"UNSAVED":return{tooltipContent:Y.SAVEDRAFT,buttonIcon:o.jsx(_.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:Y.SAVING,buttonIcon:o.jsx(_.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:Y.SAVED,buttonIcon:o.jsx(_.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[r]);return s?null:o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:a,className:`${l} w-24 max-w-24`,children:[i," ",c]})},oa=()=>{const{selectedLang:e}=N.useLanguages(),{data:t}=de(),{data:s}=Ae(),[n,r]=h.useState(!1),[a,i]=h.useState(!1),[l,c]=h.useState(null),{savePageAsync:u}=N.useSavePage(),[f,d]=h.useState(!1),{data:g}=Z(),{mutate:E,isPending:y}=fs(),{needTranslations:x}=N.useSavePage(),P=x(),{buttonText:A,buttonClassName:T,isPublished:C}=h.useMemo(()=>{const O=g&&(g==null?void 0:g.online);return{buttonClassName:O?"hover:bg-green-600 bg-green-500":"",isPublished:O,buttonText:O?Y.PUBLISHED:Y.PUBLISH}},[g]),U=async()=>{if(P){d(!0);return}q()},q=()=>{const O=[t==null?void 0:t.id,t==null?void 0:t.primaryPage];E({ids:p.compact(O)},{onSuccess:()=>_t("TOP_RIGHT")})},L=()=>{d(!1),q()},le=async()=>{d(!1),await u()},ce=h.useMemo(()=>p.map(s??[],"id"),[s]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex",children:[o.jsxs(m.Button,{size:"sm",onClick:U,disabled:y||!(g!=null&&g.id),className:`relative flex items-center gap-1 overflow-hidden rounded-r-none text-white transition-all duration-300 ease-in-out ${T}`,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[o.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${a?"-translate-y-10":""}`,children:C?o.jsx(_.Send,{className:"h-4 w-4"}):o.jsx(_.Rocket,{className:"h-4 w-4"})}),o.jsx("span",{className:`absolute inset-0 left-3 flex items-center transition-transform duration-300 ease-in-out ${a?"":"translate-y-10"}`,children:C?o.jsx(_.Rocket,{className:"h-4 w-4"}):o.jsx(_.Send,{className:"h-4 w-4"})}),o.jsx("span",{children:A}),e?`(${p.upperCase(e)})`:""]}),o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,children:o.jsx(m.Button,{size:"sm",disabled:y||!(g!=null&&g.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${T}`,children:o.jsx(_.ChevronDown,{className:"h-4 w-4"})})}),o.jsxs(m.DropdownMenuContent,{align:"end",className:"w-52",children:[o.jsxs(m.DropdownMenuItem,{disabled:y,className:"cursor-pointer text-xs",onClick:()=>E({ids:ce},{onSuccess:()=>_t("TOP_RIGHT")}),children:[Y.PUBLISH," with translation pages"]}),!C&&o.jsxs(m.DropdownMenuItem,{disabled:y,className:"cursor-pointer text-xs",onClick:()=>E({ids:[g==null?void 0:g.id]},{onSuccess:()=>_t("TOP_RIGHT")}),children:[Y.PUBLISH," page"]}),o.jsxs(m.DropdownMenuItem,{onClick:()=>r(!0),className:"cursor-pointer text-xs",children:[Y.OPEN," publish menu"]}),C&&o.jsxs(m.DropdownMenuItem,{onClick:()=>c(t),className:"cursor-pointer text-xs",children:[Y.UNPUBLISH," page ",e?`(${p.upperCase(e)})`:""]})]})]})]}),o.jsx(Xr,{showModal:n,onClose:()=>r(!1)}),l&&o.jsx(h.Suspense,{children:o.jsx(sa,{page:l,onClose:()=>c(null)})}),f&&o.jsx(h.Suspense,{children:o.jsx(na,{isOpen:f,onClose:le,onContinue:L,isPending:y})})]})};function la(){const{isLocked:e}=Te(),[t]=ee(),s=t.get("lang"),n=is(s);return e||!n?o.jsx("div",{}):o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[o.jsx(Fr,{}),o.jsx(xt,{permission:te.EDIT_THEME,children:o.jsx(aa,{})}),o.jsx(ra,{}),o.jsx(xt,{permission:te.SAVE_PAGE,children:o.jsx(ia,{})}),o.jsx(xt,{permission:te.PUBLISH_PAGE,children:o.jsx(oa,{})})]})}const Zs=({page:e,setDuplicatePage:t,setAddEditPage:s,setUnpublishPage:n,setDeletePage:r,setMarkAsTemplate:a,setUnmarkAsTemplate:i,children:l,isLanguagePage:c})=>{const{hasPermission:u}=N.usePermissions(),{data:f}=fe(),d=h.useMemo(()=>p.find(f,{key:e.pageType}),[f,e.pageType]),g=h.useMemo(()=>!!e.isTemplate,[e.isTemplate]),E=h.useMemo(()=>!!(d!=null&&d.hasSlug),[d==null?void 0:d.hasSlug]);return!u(te.EDIT_PAGE)&&!u(te.DELETE_PAGE)&&!u(te.UNPUBLISH_PAGE)||!e?null:o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,onClick:x=>x.stopPropagation(),children:l}),o.jsxs(m.DropdownMenuContent,{align:"center",className:"text-sm",children:[u(te.ADD_PAGE)&&!c&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),t(e)},children:[o.jsx(_.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),u(te.EDIT_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),s({...e,global:!(d!=null&&d.hasSlug)})},children:[o.jsx(_.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&u(te.UNPUBLISH_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),n(e)},children:[o.jsx(_.Power,{className:"size-3"}),Y.UNPUBLISH]}),u(te.DELETE_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),r(e)},children:[o.jsx(_.Trash,{className:"size-3"}),Y.DELETE]}),u(te.MARK_AS_TEMPLATE)&&E&&!c&&o.jsx(o.Fragment,{children:g?o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),i(e)},children:[o.jsx(_.SquareLibrary,{className:"size-3"}),Y.UNMARK_AS_TEMPLATE]}):o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),a(e)},children:[o.jsx(_.SquareLibrary,{className:"size-3"}),Y.MARK_AS_TEMPLATE]})})]})]})},ca=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-BN3z9rSq.cjs"))),ua=h.lazy(()=>Promise.resolve().then(()=>require("./delete-page-jELwTpGY.cjs"))),da=h.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-BRjKFpBP.cjs"))),fa=h.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-OgR8I38n.cjs"))),ha=h.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-Cx0CqrpM.cjs"))),ga=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-D3NM8b3u.cjs"))),ma=()=>{const[e,t]=h.useState(null),[s,n]=h.useState(null),[r,a]=h.useState(null),[i,l]=h.useState(null),[c,u]=h.useState(null),[f,d]=h.useState(null),{data:g,isFetching:E}=de(),{selectedLang:y,fallbackLang:x}=N.useLanguages(),{data:P}=Ae(),A=P==null?void 0:P.find(L=>L.lang===y),{isLocked:T}=Te(),C=!(g!=null&&g.slug),[,U]=K.useAtom(Ut);if(!g)return null;const q=L=>{y.length>0&&y!==x?U({edit:!0,id:L==null?void 0:L.id,primaryPage:L==null?void 0:L.primaryPage}):d(L)};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between rounded px-[2px] transition-colors duration-200",children:[o.jsx(Ys,{children:o.jsx(m.Button,{className:"flex h-7 max-w-[200px] cursor-pointer items-center truncate rounded px-1 text-xs font-medium",variant:"ghost",children:E?o.jsx(_.Loader,{className:"h-4 w-4 animate-spin text-slate-400"}):o.jsxs("span",{className:"flex w-full cursor-pointer items-end overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-xs font-medium",children:[C?o.jsx(_.Globe,{className:"mr-1 h-4 w-4"}):o.jsx(_.File,{className:"mr-1 h-4 w-4"}),p.get(A||g,"name")??""]})})}),T?o.jsx(m.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 cursor-not-allowed rounded opacity-50 hover:bg-transparent",children:o.jsx(_.MoreHorizontal,{className:"h-4 w-4"})}):o.jsx(Zs,{page:g,setDuplicatePage:L=>u(L),setAddEditPage:L=>q(L),setUnpublishPage:L=>n(L),setDeletePage:L=>t(L),setMarkAsTemplate:L=>a(L),setUnmarkAsTemplate:L=>l(L),isLanguagePage:y.length>0&&y!==x,children:o.jsx(m.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:o.jsx(_.MoreHorizontal,{className:"h-4 w-4"})})})]}),f&&o.jsx(h.Suspense,{children:o.jsx(ca,{closePanel:()=>d(null),editPage:()=>{},addEditPage:f,setAddEditPage:d})}),e&&o.jsx(h.Suspense,{children:o.jsx(ua,{page:e,onClose:()=>t(null)})}),s&&o.jsx(h.Suspense,{children:o.jsx(ga,{page:s,onClose:()=>n(null)})}),r&&o.jsx(h.Suspense,{children:o.jsx(fa,{page:r,onClose:()=>a(null)})}),i&&o.jsx(h.Suspense,{children:o.jsx(ha,{page:i,onClose:()=>l(null)})}),c&&o.jsx(h.Suspense,{children:o.jsx(da,{page:c,onClose:()=>u(null),closePanel:()=>d(null)})})]})},hs=({children:e,className:t=""})=>o.jsx("div",{className:N.mergeClasses("fixed bottom-0 left-0 right-0 top-[50px] z-[20] flex w-screen flex-col items-center justify-center bg-black/40 transition-all",t),children:e}),Ea=({hasDynamicPage:e})=>o.jsx(hs,{children:o.jsxs("div",{className:"flex min-w-[300px] max-w-[400px] flex-col items-center justify-center rounded-lg border bg-white p-4 shadow-lg",children:[o.jsx("h1",{className:"text-lg font-medium",children:e?"Select a page":"No pages found"}),o.jsx("p",{className:"pt-2 text-center text-sm font-light text-gray-600",children:e?"Please select a page from the list in the top header. This will enable you to edit the page.":"Please add a new page"})]})}),pa=h.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-CR-ZpSJ8.cjs"))),ya=()=>{const{dynamicPage:e,allLangPages:t,isFetching:s}=zs(),n=t.length>0;return s?null:o.jsxs("div",{className:"relative",children:[!e&&o.jsx(Ea,{hasDynamicPage:n}),o.jsx(h.Suspense,{children:o.jsx(pa,{})})]})},Aa=()=>{const{data:e,isFetching:t}=de(),{data:s,isFetching:n}=Z(),r=p.get(s,"dynamic",!1),a=os(),i=N.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,u=_r(),f=t||n,g=(c?`Partial: ${e==null?void 0:e.name} `:`${l}${a}`).replace(window.location.host,"");return o.jsxs("div",{className:"relative flex items-center gap-x-1",children:[o.jsx("div",{className:N.mergeClasses("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800",f&&"max-w-0 overflow-hidden opacity-0"),children:o.jsx(ma,{})}),o.jsxs("div",{className:N.mergeClasses("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800"+(c?" pr-2":""),f&&"max-w-0 overflow-hidden opacity-0"),children:[o.jsx(Js,{}),o.jsxs("div",{className:"flex w-full items-center overflow-hidden",children:[o.jsx("div",{className:`w-full max-w-[200px] overflow-hidden overflow-ellipsis whitespace-nowrap pl-1 text-xs ${c?"italic text-gray-400":"font-mono text-gray-500"}`,children:g==="/"?o.jsxs("span",{className:"text-gray-900",children:["/",o.jsx("span",{className:"text-[11px] font-light italic text-gray-400",children:"(Homepage)"})]}):g}),!c&&o.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:o.jsx("div",{className:"ml-2 mr-px flex-shrink-0 rounded-sm p-1.5 text-gray-500 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300",children:o.jsx(_.ExternalLink,{className:"h-4 w-4",strokeWidth:1})})})]})]}),r&&i&&o.jsx(ya,{})]})},Sa=()=>o.jsxs("div",{className:"flex h-full w-full items-center justify-between px-2",children:[o.jsx(Ur,{}),o.jsx(Aa,{}),o.jsx(la,{})]}),en=()=>{const e=w.useQueryClient(),{data:t}=w.useQuery({queryKey:[S.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:h.useCallback(n=>{e.setQueryData([S.AI_CONTEXT],n)},[e]),aiContext:t}},Ta=()=>{const e=F(),{aiContext:t}=en(),s=R();return h.useCallback(async(n,r,a,i)=>s(e,{action:S.ASK_AI,data:{type:n,prompt:r,blocks:a,context:t,lang:i}}),[e,t,s])},Pa=(e,t)=>t.map(s=>{if(p.has(e,s._type)){const n=Bs.getDefaultBlockProps(s._type);return{...n,...p.pick(s,[...p.keys(n),"_type","_id","_name","_parent","_bindings"]),...p.pickBy(s,(r,a)=>p.endsWith(a,"_attrs")),...s}}return s}),xa=e=>{const t=Bs.useRegisteredChaiBlocks();return h.useMemo(()=>{if(!e||p.isEmpty(e))return{blocks:[]};const s=p.filter(e,n=>!p.includes(n==null?void 0:n._type,"@chai/"));return{blocks:Pa(t,s)}},[e,t])},_a=()=>{const[e]=ee(),t=e.get("page"),s=F(),{setAiContext:n}=en(),[,r]=Rt(),[,a]=xr(),[,i]=N.useIsPageLoaded(),l=R();return w.useQuery({queryKey:[S.GET_DRAFT_PAGE,t],staleTime:1/0,gcTime:0,queryFn:async()=>{i(!1);const c=await l(s,{action:S.GET_DRAFT_PAGE,data:{id:t,draft:!0}}),u=c.blocks??[],f=p.find(u,{_type:"@chai/ai-context"});return n(p.get(f,"_value","")||""),r(d=>({...d,lastSaved:c.lastSaved})),a(p.get(c,"metadata",{})),setTimeout(()=>i(!0),500),u},enabled:!!t})},tn=()=>{const{data:e}=Z(),{data:t}=de(),s=F(),n=R(),r=Mt(),a=os();return w.useQuery({queryKey:[S.GET_BUILDER_PAGE_DATA,t==null?void 0:t.id,a],staleTime:1/0,gcTime:0,queryFn:async()=>n(s,{action:S.GET_BUILDER_PAGE_DATA,data:{pageType:e==null?void 0:e.pageType,lang:(t==null?void 0:t.lang)||r,dynamic:e==null?void 0:e.dynamic,pageProps:{slug:(t==null?void 0:t.slug)+a,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:r,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id,metadata:e.metadata||{}}}}),enabled:!!(e!=null&&e.pageType)&&!!t.id})},sn=()=>{const e=F(),t=w.useQueryClient(),s=R();return w.useMutation({mutationFn:async n=>s(e,{action:S.UPDATE_WEBSITE_SETTINGS,data:n}),onSuccess:(n,r)=>{var a;t.invalidateQueries({queryKey:[S.GET_WEBSITE_DRAFT_SETTINGS]}),(a=r==null?void 0:r.settings)!=null&&a.theme||$.toast.success("Website settings updated successfully.")},onError:n=>{$.toast.error("Failed to update website settings",{description:n.message})}})},wa=()=>{const e=F(),t=w.useQueryClient(),s=R();return w.useMutation({mutationFn:async n=>s(e,{action:S.UPDATE_APP_SHARED_JSONLD,data:JSON.stringify(n)}),onSuccess:()=>{t.invalidateQueries({queryKey:[S.GET_APP_SHARED_JSONLD]}),$.toast.success("Shared JSON-LD updated successfully.")},onError:n=>{$.toast.error("Failed to update shared JSON-LD",{description:n.message})}})},_s={async getUILibraryBlock(e,t,s){const n=await t(s,{action:"GET_LIBRARY_ITEM",data:{id:e.id}}),r=p.get(n,"html",""),a=p.get(n,"blocks",[]);return p.isArray(a)?a:N.getBlocksFromHTML(r)},async getUILibraryBlocks(e,t,s){try{return(await t(s,{action:"GET_LIBRARY_ITEMS",data:{id:e.id}})).map(r=>({...r}))}catch(n){return console.error(n),[]}}},va=()=>{const e=F(),t=R();return w.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const n=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return n.forEach(r=>{N.registerChaiLibrary(r.id,{name:r.isSiteLibrary?r.name+" (Current Site) ":r.name,description:r.description,getBlocksList:a=>_s.getUILibraryBlocks(a,t,e),getBlock:({block:a})=>_s.getUILibraryBlock(a,t,e)})}),n}})},nn=()=>{const e=Ot(),t=R(),{user:s}=re(),n=s==null?void 0:s.id;return w.useQuery({queryKey:[S.GET_ROLE_AND_PERMISSIONS,n],queryFn:()=>t(e,{action:S.GET_ROLE_AND_PERMISSIONS,data:{userId:n}}),enabled:!!n,staleTime:1/0})},ba=()=>{const e=F(),t=R(),[,s]=Rt();return{onSave:async({page:r,blocks:a,needTranslations:i})=>{try{const l=await t(e,{action:"UPDATE_PAGE",data:{id:r,blocks:a,needTranslations:i}});return l.code==="PAGE_LOCKED"?!0:(s(c=>({...c,lastSaved:new Date().toISOString()})),l)}catch(l){return console.error(l),new Error("Failed to save blocks")}}}},Ca=()=>{const{data:e}=us(),t=F(),s=R();return{getPartialBlocks:h.useCallback(async()=>{const n={};for(const r of e??[])p.isEmpty(r==null?void 0:r.slug)&&(n[r.id]={type:r.pageType,name:p.startCase(r.name??r.slug),description:""});return n},[e]),getPartialBlockBlocks:h.useCallback(async n=>{if(!n)return[];try{const r=await s(t,{action:"GET_DRAFT_PAGE",data:{id:n,draft:!0,editor:!1}});return p.filter(r.blocks,a=>p.has(a,"_id"))}catch(r){return console.error(r),[]}},[s,t])}},ws=Pt.z.object({email:Pt.z.string().email({message:"Please enter a valid email address"}),password:Pt.z.string().min(6,{message:"Password must be at least 6 characters"})}),Ia=()=>{const{setUser:e,logout:t}=re(),s=Ot(),[n,r]=h.useState(""),[a,i]=h.useState(""),[l,c]=h.useState({}),[u,f]=h.useState(!1),[d,g]=h.useState(""),E=w.useMutation({mutationFn:async P=>{g("");const A=await as(s,{action:"LOGIN",data:P});if(!A.ok){const C=await A.json();throw new Error(C.error||"Login failed")}const T=await A.json();if(p.has(T,"id")&&p.has(T,"email")&&p.has(T,"accessToken")&&p.has(T,"refreshToken"))e(T);else throw t(),new Error("Something went wrong. Please try again.");return T},onSuccess:()=>{c({}),g("")},onError:P=>{c({email:" ",password:" "}),g(P.message?"Invalid email or password":"Something went wrong")}}),y=async P=>{P.preventDefault(),c({});const A={email:n,password:a};try{const T=ws.parse(A);E.mutate(T)}catch(T){if(T instanceof Pt.z.ZodError){const C=T.issues.reduce((U,q)=>{const L=q.path[0];return U[L]=q.message,U},{});c(C)}}},x=ws.safeParse({email:n,password:a}).success;return o.jsx("div",{className:"flex min-h-screen items-center justify-center bg-slate-50",children:o.jsxs(m.Card,{className:"w-full max-w-md",children:[o.jsxs(m.CardHeader,{children:[o.jsx(m.CardTitle,{className:"text-2xl",children:"Sign in"}),o.jsx(m.CardDescription,{children:"Enter your credentials to sign in to visual builder"})]}),o.jsx(m.CardContent,{children:o.jsxs("form",{onSubmit:y,className:"space-y-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(m.Label,{htmlFor:"email",children:"Email"}),o.jsx(m.Input,{id:"email",placeholder:"you@example.com",type:"email",value:n,onChange:P=>r(P.target.value),className:l.email?"border-destructive":""}),l.email&&o.jsx("p",{className:"text-sm text-destructive",children:l.email})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(m.Label,{htmlFor:"password",children:"Password"}),o.jsxs("div",{className:"relative",children:[o.jsx(m.Input,{id:"password",placeholder:"Enter your password",type:u?"text":"password",value:a,onChange:P=>i(P.target.value),className:l.password?"border-destructive":""}),o.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",onClick:()=>f(!u),children:u?o.jsx(_.EyeOff,{className:"h-4 w-4"}):o.jsx(_.Eye,{className:"h-4 w-4"})})]}),l.password&&o.jsx("p",{className:"text-sm text-destructive",children:l.password})]}),o.jsx("div",{children:o.jsx("p",{className:"text-sm text-destructive",children:d})}),o.jsx(m.Button,{type:"submit",className:"w-full",disabled:!x||E.isPending,children:E.isPending?o.jsxs(o.Fragment,{children:[o.jsx(_.Loader,{className:"mr-2 h-4 w-4 animate-spin"}),"Logging in..."]}):"Login"})]})}),o.jsxs(m.CardFooter,{className:"flex flex-col justify-center",children:[o.jsxs("p",{className:"text-sm text-muted-foreground",children:["Forgot your password?"," ",o.jsx("a",{target:"_blank",href:"https://chaibuilder.com/forgot-password",className:"text-primary hover:underline",children:"Reset password"})]}),o.jsx("br",{}),o.jsx("br",{}),o.jsxs("div",{className:"flex items-center gap-2 border-t px-10 pt-2",children:["Powered by"," ",o.jsxs("a",{target:"_blank",href:"https://chaibuilder.com",className:"flex items-center gap-1 text-primary hover:underline",children:[o.jsx("img",{src:"https://ucarecdn.com/a82e256c-1cf2-4755-b65c-5d85e7652daa/-/preview/400x400",alt:"Chai Builder",className:"h-4 w-4 rounded font-bold uppercase"}),"Chai Builder"]})]})]})]})})};let Wt=Ia;const Na=()=>h.useMemo(()=>Wt,[Wt]),La=e=>{Wt=e},vs=()=>{const e=Na();return o.jsx(h.Suspense,{fallback:o.jsx("div",{children:"Loading..."}),children:o.jsx(e,{})})},ja=h.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-B3bC1gKq.cjs"))),ka=({isActive:e,show:t})=>{const{data:s}=Se();return!p.has(s,"languages")||!p.get(s,"languages",[]).length?null:o.jsx(m.Button,{size:"sm",onClick:t,variant:e?"default":"ghost",children:o.jsx(_.LanguagesIcon,{className:"h-4 w-4"})})},rn="lang",Da={id:rn,label:"Languages",position:"top",panel:ja,button:ka,view:"modal",width:400},Ga=h.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-QphuqXT2.cjs"))),an="seo",Oa=({isActive:e,show:t})=>{const{data:s}=Z(),n=Xs(s==null?void 0:s.pageType);return!p.has(n,"hasSlug")||!n.hasSlug?null:o.jsx(m.Button,{size:"icon",className:"my-1 p-0",onClick:t,variant:e?"default":"ghost",children:o.jsxs("svg",{stroke:"currentColor",fill:"none",style:{height:"20px",width:"20px"},strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M7 8h-3a1 1 0 0 0 -1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-3"}),o.jsx("path",{d:"M14 16h-4v-8h4"}),o.jsx("path",{d:"M11 12h2"}),o.jsx("path",{d:"M17 8m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]})})},Ra={id:an,label:"SEO",panel:Ga,button:Oa,position:"top",width:600,view:"modal"},on="user-info",Ua=()=>{const{user:e,logout:t}=re(),s=oe("onLogout",p.noop);return e?o.jsxs(m.HoverCard,{children:[o.jsx(m.HoverCardTrigger,{asChild:!0,children:o.jsx(m.Button,{variant:"ghost",className:"text-sm font-medium",children:o.jsx(_.User,{className:"h-4 w-4"})})}),o.jsxs(m.HoverCardContent,{className:"w-auto space-y-2 p-4",children:[o.jsx("div",{className:"text-sm font-medium",children:e.name??e.email}),o.jsx("div",{className:"text-xs text-muted-foreground",children:e.email}),o.jsxs(m.AlertDialog,{children:[o.jsx(m.AlertDialogTrigger,{asChild:!0,children:o.jsx(m.Button,{variant:"outline",size:"sm",className:"w-full",children:"Logout"})}),o.jsxs(m.AlertDialogContent,{children:[o.jsxs(m.AlertDialogHeader,{children:[o.jsx(m.AlertDialogTitle,{children:"Are you sure you want to logout?"}),o.jsx(m.AlertDialogDescription,{children:"You will be redirected to the login page."})]}),o.jsxs(m.AlertDialogFooter,{children:[o.jsx(m.AlertDialogCancel,{children:"Cancel"}),o.jsx(m.AlertDialogAction,{onClick:()=>{t(),p.isFunction(s)&&s()},children:"Logout"})]})]})]})]})]}):null},Ma={id:on,label:"User Info",button:Ua,position:"bottom"},Ba=()=>{N.registerChaiSidebarPanel(an,Ra),N.registerChaiSidebarPanel(rn,Da),N.registerChaiSidebarPanel(on,Ma)};var b={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return bs(this.context.count)},getNextContextId(){return bs(this.context.count++)}};function bs(e){const t=String(e),s=t.length-1;return b.context.id+(s?String.fromCharCode(96+s):"")+t}function Ye(e){b.context=e}var ln=!1,Fa=(e,t)=>e===t,bt=Symbol("solid-proxy"),cn=typeof Proxy=="function",gs=Symbol("solid-track"),Ct={equals:Fa},un=yn,he=1,It=2,dn={owned:null,cleanups:null,context:null,owner:null},Ht={},k=null,Qt=null,qa=null,M=null,X=null,ue=null,Ft=0;function Ee(e,t){const s=M,n=k,r=e.length===0,a=t===void 0?n:t,i=r?dn:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>J(()=>tt(i)));k=i,M=null;try{return ie(l,!0)}finally{M=s,k=n}}function V(e,t){t=t?Object.assign({},Ct,t):Ct;const s={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},n=r=>(typeof r=="function"&&(r=r(s.value)),pn(s,r));return[En.bind(s),n]}function fn(e,t,s){const n=qt(e,t,!0,he);Qe(n)}function pe(e,t,s){const n=qt(e,t,!1,he);Qe(n)}function ms(e,t,s){un=ti;const n=qt(e,t,!1,he);(!s||!s.render)&&(n.user=!0),ue?ue.push(n):Qe(n)}function z(e,t,s){s=s?Object.assign({},Ct,s):Ct;const n=qt(e,t,!0,0);return n.observers=null,n.observerSlots=null,n.comparator=s.equals||void 0,Qe(n),En.bind(n)}function Ka(e){return e&&typeof e=="object"&&"then"in e}function Va(e,t,s){let n,r,a;n=!0,r=e,a={};let i=null,l=Ht,c=null,u=!1,f="initialValue"in a,d=typeof n=="function"&&z(n);const g=new Set,[E,y]=(a.storage||V)(a.initialValue),[x,P]=V(void 0),[A,T]=V(void 0,{equals:!1}),[C,U]=V(f?"ready":"unresolved");b.context&&(c=b.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:b.load&&b.has(c)&&(l=b.load(c)));function q(I,j,W,H){return i===I&&(i=null,H!==void 0&&(f=!0),(I===l||j===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(H,{value:j})),l=Ht,L(j,W)),j}function L(I,j){ie(()=>{j===void 0&&y(()=>I),U(j!==void 0?"errored":f?"ready":"unresolved"),P(j);for(const W of g.keys())W.decrement();g.clear()},!1)}function le(){const I=Xa,j=E(),W=x();if(W!==void 0&&!i)throw W;return M&&M.user,j}function ce(I=!0){if(I!==!1&&u)return;u=!1;const j=d?d():n;if(j==null||j===!1){q(i,J(E));return}let W;const H=l!==Ht?l:J(()=>{try{return r(j,{value:E(),refetching:I})}catch(se){W=se}});if(W!==void 0){q(i,void 0,wt(W),j);return}else if(!Ka(H))return q(i,H,void 0,j),H;return i=H,"v"in H?(H.s===1?q(i,H.v,void 0,j):q(i,void 0,wt(H.v),j),H):(u=!0,queueMicrotask(()=>u=!1),ie(()=>{U(f?"refreshing":"pending"),T()},!1),H.then(se=>q(H,se,void 0,j),se=>q(H,void 0,wt(se),j)))}Object.defineProperties(le,{state:{get:()=>C()},error:{get:()=>x()},loading:{get(){const I=C();return I==="pending"||I==="refreshing"}},latest:{get(){if(!f)return le();const I=x();if(I&&!i)throw I;return E()}}});let O=k;return d?fn(()=>(O=k,ce(!1))):ce(!1),[le,{refetch:I=>gn(O,()=>ce(I)),mutate:y}]}function Ha(e){return ie(e,!1)}function J(e){if(M===null)return e();const t=M;M=null;try{return e()}finally{M=t}}function Qa(e,t,s){const n=Array.isArray(e);let r,a=s&&s.defer;return i=>{let l;if(n){l=Array(e.length);for(let u=0;u<e.length;u++)l[u]=e[u]()}else l=e();if(a)return a=!1,i;const c=J(()=>t(l,r,i));return r=l,c}}function hn(e){ms(()=>J(e))}function Ve(e){return k===null||(k.cleanups===null?k.cleanups=[e]:k.cleanups.push(e)),e}function Cs(){return k}function gn(e,t){const s=k,n=M;k=e,M=null;try{return ie(t,!0)}catch(r){Es(r)}finally{k=s,M=n}}function za(e){const t=M,s=k;return Promise.resolve().then(()=>{M=t,k=s;let n;return ie(e,!1),M=k=null,n?n.done:void 0})}var[$a,tl]=V(!1);function Wa(){return[$a,za]}function Ya(e,t){const s=Symbol("context");return{id:s,Provider:si(s),defaultValue:e}}function Ja(e){let t;return k&&k.context&&(t=k.context[e.id])!==void 0?t:e.defaultValue}function mn(e){const t=z(e),s=z(()=>Yt(t()));return s.toArray=()=>{const n=s();return Array.isArray(n)?n:n!=null?[n]:[]},s}var Xa;function En(){if(this.sources&&this.state)if(this.state===he)Qe(this);else{const e=X;X=null,ie(()=>Lt(this),!1),X=e}if(M){const e=this.observers?this.observers.length:0;M.sources?(M.sources.push(this),M.sourceSlots.push(e)):(M.sources=[this],M.sourceSlots=[e]),this.observers?(this.observers.push(M),this.observerSlots.push(M.sources.length-1)):(this.observers=[M],this.observerSlots=[M.sources.length-1])}return this.value}function pn(e,t,s){let n=e.value;return(!e.comparator||!e.comparator(n,t))&&(e.value=t,e.observers&&e.observers.length&&ie(()=>{for(let r=0;r<e.observers.length;r+=1){const a=e.observers[r],i=Qt&&Qt.running;i&&Qt.disposed.has(a),(i?!a.tState:!a.state)&&(a.pure?X.push(a):ue.push(a),a.observers&&An(a)),i||(a.state=he)}if(X.length>1e6)throw X=[],new Error},!1)),t}function Qe(e){if(!e.fn)return;tt(e);const t=Ft;Za(e,e.value,t)}function Za(e,t,s){let n;const r=k,a=M;M=k=e;try{n=e.fn(t)}catch(i){return e.pure&&(e.state=he,e.owned&&e.owned.forEach(tt),e.owned=null),e.updatedAt=s+1,Es(i)}finally{M=a,k=r}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?pn(e,n):e.value=n,e.updatedAt=s)}function qt(e,t,s,n=he,r){const a={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:k,context:k?k.context:null,pure:s};return k===null||k!==dn&&(k.owned?k.owned.push(a):k.owned=[a]),a}function Nt(e){if(e.state===0)return;if(e.state===It)return Lt(e);if(e.suspense&&J(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<Ft);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===he)Qe(e);else if(e.state===It){const n=X;X=null,ie(()=>Lt(e,t[0]),!1),X=n}}function ie(e,t){if(X)return e();let s=!1;t||(X=[]),ue?s=!0:ue=[],Ft++;try{const n=e();return ei(s),n}catch(n){s||(ue=null),X=null,Es(n)}}function ei(e){if(X&&(yn(X),X=null),e)return;const t=ue;ue=null,t.length&&ie(()=>un(t),!1)}function yn(e){for(let t=0;t<e.length;t++)Nt(e[t])}function ti(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:Nt(n)}if(b.context){if(b.count){b.effects||(b.effects=[]),b.effects.push(...e.slice(0,s));return}Ye()}for(b.effects&&(b.done||!b.count)&&(e=[...b.effects,...e],s+=b.effects.length,delete b.effects),t=0;t<s;t++)Nt(e[t])}function Lt(e,t){e.state=0;for(let s=0;s<e.sources.length;s+=1){const n=e.sources[s];if(n.sources){const r=n.state;r===he?n!==t&&(!n.updatedAt||n.updatedAt<Ft)&&Nt(n):r===It&&Lt(n,t)}}}function An(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=It,s.pure?X.push(s):ue.push(s),s.observers&&An(s))}}function tt(e){let t;if(e.sources)for(;e.sources.length;){const s=e.sources.pop(),n=e.sourceSlots.pop(),r=s.observers;if(r&&r.length){const a=r.pop(),i=s.observerSlots.pop();n<r.length&&(a.sourceSlots[i]=n,r[n]=a,s.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)tt(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)tt(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 wt(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function Es(e,t=k){throw wt(e)}function Yt(e){if(typeof e=="function"&&!e.length)return Yt(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const n=Yt(e[s]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function si(e,t){return function(n){let r;return pe(()=>r=J(()=>(k.context={...k.context,[e]:n.value},mn(()=>n.children))),void 0),r}}var Jt=Symbol("fallback");function jt(e){for(let t=0;t<e.length;t++)e[t]()}function ni(e,t,s={}){let n=[],r=[],a=[],i=0,l=t.length>1?[]:null;return Ve(()=>jt(a)),()=>{let c=e()||[],u=c.length,f,d;return c[gs],J(()=>{let E,y,x,P,A,T,C,U,q;if(u===0)i!==0&&(jt(a),a=[],n=[],r=[],i=0,l&&(l=[])),s.fallback&&(n=[Jt],r[0]=Ee(L=>(a[0]=L,s.fallback())),i=1);else if(i===0){for(r=new Array(u),d=0;d<u;d++)n[d]=c[d],r[d]=Ee(g);i=u}else{for(x=new Array(u),P=new Array(u),l&&(A=new Array(u)),T=0,C=Math.min(i,u);T<C&&n[T]===c[T];T++);for(C=i-1,U=u-1;C>=T&&U>=T&&n[C]===c[U];C--,U--)x[U]=r[C],P[U]=a[C],l&&(A[U]=l[C]);for(E=new Map,y=new Array(U+1),d=U;d>=T;d--)q=c[d],f=E.get(q),y[d]=f===void 0?-1:f,E.set(q,d);for(f=T;f<=C;f++)q=n[f],d=E.get(q),d!==void 0&&d!==-1?(x[d]=r[f],P[d]=a[f],l&&(A[d]=l[f]),d=y[d],E.set(q,d)):a[f]();for(d=T;d<u;d++)d in x?(r[d]=x[d],a[d]=P[d],l&&(l[d]=A[d],l[d](d))):r[d]=Ee(g);r=r.slice(0,i=u),n=c.slice(0)}return r});function g(E){if(a[d]=E,l){const[y,x]=V(d);return l[d]=x,t(c[d],y)}return t(c[d])}}}function ri(e,t,s={}){let n=[],r=[],a=[],i=[],l=0,c;return Ve(()=>jt(a)),()=>{const u=e()||[],f=u.length;return u[gs],J(()=>{if(f===0)return l!==0&&(jt(a),a=[],n=[],r=[],l=0,i=[]),s.fallback&&(n=[Jt],r[0]=Ee(g=>(a[0]=g,s.fallback())),l=1),r;for(n[0]===Jt&&(a[0](),a=[],n=[],r=[],l=0),c=0;c<f;c++)c<n.length&&n[c]!==u[c]?i[c](()=>u[c]):c>=n.length&&(r[c]=Ee(d));for(;c<n.length;c++)a[c]();return l=i.length=a.length=f,n=u.slice(0),r=r.slice(0,l)});function d(g){a[c]=g;const[E,y]=V(u[c]);return i[c]=y,t(E,c)}}}function ps(e,t){return J(()=>e(t||{}))}function At(){return!0}var Xt={get(e,t,s){return t===bt?s:e.get(t)},has(e,t){return t===bt?!0:e.has(t)},set:At,deleteProperty:At,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:At,deleteProperty:At}},ownKeys(e){return e.keys()}};function zt(e){return(e=typeof e=="function"?e():e)?e:{}}function ai(){for(let e=0,t=this.length;e<t;++e){const s=this[e]();if(s!==void 0)return s}}function ys(...e){let t=!1;for(let i=0;i<e.length;i++){const l=e[i];t=t||!!l&&bt in l,e[i]=typeof l=="function"?(t=!0,z(l)):l}if(cn&&t)return new Proxy({get(i){for(let l=e.length-1;l>=0;l--){const c=zt(e[l])[i];if(c!==void 0)return c}},has(i){for(let l=e.length-1;l>=0;l--)if(i in zt(e[l]))return!0;return!1},keys(){const i=[];for(let l=0;l<e.length;l++)i.push(...Object.keys(zt(e[l])));return[...new Set(i)]}},Xt);const s={},n=Object.create(null);for(let i=e.length-1;i>=0;i--){const l=e[i];if(!l)continue;const c=Object.getOwnPropertyNames(l);for(let u=c.length-1;u>=0;u--){const f=c[u];if(f==="__proto__"||f==="constructor")continue;const d=Object.getOwnPropertyDescriptor(l,f);if(!n[f])n[f]=d.get?{enumerable:!0,configurable:!0,get:ai.bind(s[f]=[d.get.bind(l)])}:d.value!==void 0?d:void 0;else{const g=s[f];g&&(d.get?g.push(d.get.bind(l)):d.value!==void 0&&g.push(()=>d.value))}}}const r={},a=Object.keys(n);for(let i=a.length-1;i>=0;i--){const l=a[i],c=n[l];c&&c.get?Object.defineProperty(r,l,c):r[l]=c?c.value:void 0}return r}function Sn(e,...t){if(cn&&bt in e){const r=new Set(t.length>1?t.flat():t[0]),a=t.map(i=>new Proxy({get(l){return i.includes(l)?e[l]:void 0},has(l){return i.includes(l)&&l in e},keys(){return i.filter(l=>l in e)}},Xt));return a.push(new Proxy({get(i){return r.has(i)?void 0:e[i]},has(i){return r.has(i)?!1:i in e},keys(){return Object.keys(e).filter(i=>!r.has(i))}},Xt)),a}const s={},n=t.map(()=>({}));for(const r of Object.getOwnPropertyNames(e)){const a=Object.getOwnPropertyDescriptor(e,r),i=!a.get&&!a.set&&a.enumerable&&a.writable&&a.configurable;let l=!1,c=0;for(const u of t)u.includes(r)&&(l=!0,i?n[c][r]=a.value:Object.defineProperty(n[c],r,a)),++c;l||(i?s[r]=a.value:Object.defineProperty(s,r,a))}return[...n,s]}function Tn(e){let t,s;const n=r=>{const a=b.context;if(a){const[l,c]=V();b.count||(b.count=0),b.count++,(s||(s=e())).then(u=>{!b.done&&Ye(a),b.count--,c(()=>u.default),Ye()}),t=l}else if(!t){const[l]=Va(()=>(s||(s=e())).then(c=>c.default));t=l}let i;return z(()=>(i=t())?J(()=>{if(!a||b.done)return i(r);const l=b.context;Ye(a);const c=i(r);return Ye(l),c}):"")};return n.preload=()=>s||((s=e()).then(r=>t=()=>r.default),s),n}var ii=0;function oi(){return b.context?b.getNextContextId():`cl-${ii++}`}var Pn=e=>`Stale read from <${e}>.`;function li(e){const t="fallback"in e&&{fallback:()=>e.fallback};return z(ni(()=>e.each,e.children,t||void 0))}function ci(e){const t="fallback"in e&&{fallback:()=>e.fallback};return z(ri(()=>e.each,e.children,t||void 0))}function ui(e){const t=e.keyed,s=z(()=>e.when,void 0,void 0),n=t?s:z(s,void 0,{equals:(r,a)=>!r==!a});return z(()=>{const r=n();if(r){const a=e.children;return typeof a=="function"&&a.length>0?J(()=>a(t?r:()=>{if(!J(n))throw Pn("Show");return s()})):a}return e.fallback},void 0,void 0)}function di(e){const t=mn(()=>e.children),s=z(()=>{const n=t(),r=Array.isArray(n)?n:[n];let a=()=>{};for(let i=0;i<r.length;i++){const l=i,c=r[i],u=a,f=z(()=>u()?void 0:c.when,void 0,void 0),d=c.keyed?f:z(f,void 0,{equals:(g,E)=>!g==!E});a=()=>u()||(d()?[l,f,c]:void 0)}return a});return z(()=>{const n=s()();if(!n)return e.fallback;const[r,a,i]=n,l=i.children;return typeof l=="function"&&l.length>0?J(()=>l(i.keyed?a():()=>{var u;if(((u=J(s)())==null?void 0:u[0])!==r)throw Pn("Match");return a()})):l},void 0,void 0)}function fi(e){return e}var hi=["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"],gi=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",...hi]),mi=new Set(["innerHTML","textContent","innerText","children"]),Ei=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),pi=Object.assign(Object.create(null),{class:"className",novalidate:{$:"noValidate",FORM:1},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 yi(e,t){const s=pi[e];return typeof s=="object"?s[t]?s.$:void 0:s}var Ai=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),Si=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"]),Ti={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},Pi=e=>z(()=>e());function xi(e,t,s){let n=s.length,r=t.length,a=n,i=0,l=0,c=t[r-1].nextSibling,u=null;for(;i<r||l<a;){if(t[i]===s[l]){i++,l++;continue}for(;t[r-1]===s[a-1];)r--,a--;if(r===i){const f=a<n?l?s[l-1].nextSibling:s[a-l]:c;for(;l<a;)e.insertBefore(s[l++],f)}else if(a===l)for(;i<r;)(!u||!u.has(t[i]))&&t[i].remove(),i++;else if(t[i]===s[a-1]&&s[l]===t[r-1]){const f=t[--r].nextSibling;e.insertBefore(s[l++],t[i++].nextSibling),e.insertBefore(s[--a],f),t[r]=s[a]}else{if(!u){u=new Map;let d=l;for(;d<a;)u.set(s[d],d++)}const f=u.get(t[i]);if(f!=null)if(l<f&&f<a){let d=i,g=1,E;for(;++d<r&&d<a&&!((E=u.get(t[d]))==null||E!==f+g);)g++;if(g>f-l){const y=t[i];for(;l<f;)e.insertBefore(s[l++],y)}else e.replaceChild(s[l++],t[i++])}else i++;else t[i++].remove()}}}var Ze="_$DX_DELEGATE";function xn(e,t,s,n={}){let r;return Ee(a=>{r=a,t===document?e():Dt(t,e(),t.firstChild?null:void 0,s)},n.owner),()=>{r(),t.textContent=""}}function _i(e,t,s,n){let r;const a=()=>{const l=document.createElement("template");return l.innerHTML=e,l.content.firstChild},i=()=>(r||(r=a())).cloneNode(!0);return i.cloneNode=i,i}function _n(e,t=window.document){const s=t[Ze]||(t[Ze]=new Set);for(let n=0,r=e.length;n<r;n++){const a=e[n];s.has(a)||(s.add(a),t.addEventListener(a,In))}}function wi(e=window.document){if(e[Ze]){for(let t of e[Ze].keys())e.removeEventListener(t,In);delete e[Ze]}}function kt(e,t,s){we(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function vi(e,t,s,n){we(e)||(n==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,n))}function bi(e,t,s){we(e)||(s?e.setAttribute(t,""):e.removeAttribute(t))}function wn(e,t){we(e)||(t==null?e.removeAttribute("class"):e.className=t)}function vn(e,t,s,n){if(n)Array.isArray(s)?(e[`$$${t}`]=s[0],e[`$$${t}Data`]=s[1]):e[`$$${t}`]=s;else if(Array.isArray(s)){const r=s[0];e.addEventListener(t,s[0]=a=>r.call(e,s[1],a))}else e.addEventListener(t,s,typeof s!="function"&&s)}function Ci(e,t,s={}){const n=Object.keys(t||{}),r=Object.keys(s);let a,i;for(a=0,i=r.length;a<i;a++){const l=r[a];!l||l==="undefined"||t[l]||(Is(e,l,!1),delete s[l])}for(a=0,i=n.length;a<i;a++){const l=n[a],c=!!t[l];!l||l==="undefined"||s[l]===c||!c||(Is(e,l,!0),s[l]=c)}return s}function Ii(e,t,s){if(!t)return s?kt(e,"style"):t;const n=e.style;if(typeof t=="string")return n.cssText=t;typeof s=="string"&&(n.cssText=s=void 0),s||(s={}),t||(t={});let r,a;for(a in s)t[a]==null&&n.removeProperty(a),delete s[a];for(a in t)r=t[a],r!==s[a]&&(n.setProperty(a,r),s[a]=r);return s}function bn(e,t={},s,n){const r={};return n||pe(()=>r.children=st(e,t.children,r.children)),pe(()=>typeof t.ref=="function"&&Cn(t.ref,e)),pe(()=>Ni(e,t,s,!0,r,!0)),r}function Cn(e,t,s){return J(()=>e(t,s))}function Dt(e,t,s,n){if(s!==void 0&&!n&&(n=[]),typeof t!="function")return st(e,t,n,s);pe(r=>st(e,t(),r,s),n)}function Ni(e,t,s,n,r={},a=!1){t||(t={});for(const i in r)if(!(i in t)){if(i==="children")continue;r[i]=Ns(e,i,null,r[i],s,a,t)}for(const i in t){if(i==="children")continue;const l=t[i];r[i]=Ns(e,i,l,r[i],s,a,t)}}function Li(e){let t,s;return!we()||!(t=b.registry.get(s=ki()))?e():(b.completed&&b.completed.add(t),b.registry.delete(s),t)}function we(e){return!!b.context&&!b.done&&(!e||e.isConnected)}function ji(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function Is(e,t,s){const n=t.trim().split(/\s+/);for(let r=0,a=n.length;r<a;r++)e.classList.toggle(n[r],s)}function Ns(e,t,s,n,r,a,i){let l,c,u,f,d;if(t==="style")return Ii(e,s,n);if(t==="classList")return Ci(e,s,n);if(s===n)return n;if(t==="ref")a||s(e);else if(t.slice(0,3)==="on:"){const g=t.slice(3);n&&e.removeEventListener(g,n,typeof n!="function"&&n),s&&e.addEventListener(g,s,typeof s!="function"&&s)}else if(t.slice(0,10)==="oncapture:"){const g=t.slice(10);n&&e.removeEventListener(g,n,!0),s&&e.addEventListener(g,s,!0)}else if(t.slice(0,2)==="on"){const g=t.slice(2).toLowerCase(),E=Ai.has(g);if(!E&&n){const y=Array.isArray(n)?n[0]:n;e.removeEventListener(g,y)}(E||s)&&(vn(e,g,s,E),E&&_n([g]))}else if(t.slice(0,5)==="attr:")kt(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")bi(e,t.slice(5),s);else if((d=t.slice(0,5)==="prop:")||(u=mi.has(t))||!r&&((f=yi(t,e.tagName))||(c=gi.has(t)))||(l=e.nodeName.includes("-")||"is"in i)){if(d)t=t.slice(5),c=!0;else if(we(e))return s;t==="class"||t==="className"?wn(e,s):l&&!c&&!u?e[ji(t)]=s:e[f||t]=s}else{const g=r&&t.indexOf(":")>-1&&Ti[t.split(":")[0]];g?vi(e,g,t,s):kt(e,Ei[t]||t,s)}return s}function In(e){if(b.registry&&b.events&&b.events.find(([c,u])=>u===e))return;let t=e.target;const s=`$$${e.type}`,n=e.target,r=e.currentTarget,a=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),i=()=>{const c=t[s];if(c&&!t.disabled){const u=t[`${s}Data`];if(u!==void 0?c.call(t,u,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&a(t.host),!0},l=()=>{for(;i()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),b.registry&&!b.done&&(b.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();a(c[0]);for(let u=0;u<c.length-2&&(t=c[u],!!i());u++){if(t._$host){t=t._$host,l();break}if(t.parentNode===r)break}}else l();a(n)}function st(e,t,s,n,r){const a=we(e);if(a){!s&&(s=[...e.childNodes]);let c=[];for(let u=0;u<s.length;u++){const f=s[u];f.nodeType===8&&f.data.slice(0,2)==="!$"?f.remove():c.push(f)}s=c}for(;typeof s=="function";)s=s();if(t===s)return s;const i=typeof t,l=n!==void 0;if(e=l&&s[0]&&s[0].parentNode||e,i==="string"||i==="number"){if(a||i==="number"&&(t=t.toString(),t===s))return s;if(l){let c=s[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),s=ve(e,s,n,c)}else s!==""&&typeof s=="string"?s=e.firstChild.data=t:s=e.textContent=t}else if(t==null||i==="boolean"){if(a)return s;s=ve(e,s,n)}else{if(i==="function")return pe(()=>{let c=t();for(;typeof c=="function";)c=c();s=st(e,c,s,n)}),()=>s;if(Array.isArray(t)){const c=[],u=s&&Array.isArray(s);if(Zt(c,t,s,r))return pe(()=>s=st(e,c,s,n,!0)),()=>s;if(a){if(!c.length)return s;if(n===void 0)return s=[...e.childNodes];let f=c[0];if(f.parentNode!==e)return s;const d=[f];for(;(f=f.nextSibling)!==n;)d.push(f);return s=d}if(c.length===0){if(s=ve(e,s,n),l)return s}else u?s.length===0?Ls(e,c,n):xi(e,s,c):(s&&ve(e),Ls(e,c));s=c}else if(t.nodeType){if(a&&t.parentNode)return s=l?[t]:t;if(Array.isArray(s)){if(l)return s=ve(e,s,n,t);ve(e,s,null,t)}else s==null||s===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);s=t}}return s}function Zt(e,t,s,n){let r=!1;for(let a=0,i=t.length;a<i;a++){let l=t[a],c=s&&s[e.length],u;if(!(l==null||l===!0||l===!1))if((u=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))r=Zt(e,l,c)||r;else if(u==="function")if(n){for(;typeof l=="function";)l=l();r=Zt(e,Array.isArray(l)?l:[l],Array.isArray(c)?c:[c])||r}else e.push(l),r=!0;else{const f=String(l);c&&c.nodeType===3&&c.data===f?e.push(c):e.push(document.createTextNode(f))}}return r}function Ls(e,t,s=null){for(let n=0,r=t.length;n<r;n++)e.insertBefore(t[n],s)}function ve(e,t,s,n){if(s===void 0)return e.textContent="";const r=n||document.createTextNode("");if(t.length){let a=!1;for(let i=t.length-1;i>=0;i--){const l=t[i];if(r!==l){const c=l.parentNode===e;!a&&!i?c?e.replaceChild(r,l):e.insertBefore(r,s):c&&l.remove()}else a=!0}}else e.insertBefore(r,s);return[r]}function ki(){return b.getNextContextId()}var Di="http://www.w3.org/2000/svg";function Nn(e,t=!1){return t?document.createElementNS(Di,e):document.createElement(e)}function Gi(e){const{useShadow:t}=e,s=document.createTextNode(""),n=()=>e.mount||document.body,r=Cs();let a,i=!!b.context;return ms(()=>{i&&(Cs().user=i=!1),a||(a=gn(r,()=>z(()=>e.children)));const l=n();if(l instanceof HTMLHeadElement){const[c,u]=V(!1),f=()=>u(!0);Ee(d=>Dt(l,()=>c()?d():a(),null)),Ve(f)}else{const c=Nn(e.isSVG?"g":"div",e.isSVG),u=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return s.parentNode},configurable:!0}),Dt(u,a),l.appendChild(c),e.ref&&e.ref(c),Ve(()=>l.removeChild(c))}},void 0,{render:!i}),s}function Oi(e,t){const s=z(e);return z(()=>{const n=s();switch(typeof n){case"function":return J(()=>n(t));case"string":const r=Si.has(n),a=b.context?Li():Nn(n,r);return bn(a,t,r),a}})}function Ri(e){const[,t]=Sn(e,["component"]);return Oi(()=>e.component,t)}var Ui=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()}},Ln=class{constructor(e){this.generateIdentifier=e,this.kv=new Ui}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)}},Mi=class extends Ln{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 Bi(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 Fi(e,t){const s=Bi(e);if("find"in s)return s.find(t);const n=s;for(let r=0;r<n.length;r++){const a=n[r];if(t(a))return a}}function He(e,t){Object.entries(e).forEach(([s,n])=>t(n,s))}function vt(e,t){return e.indexOf(t)!==-1}function js(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var qi=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return Fi(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},Ki=e=>Object.prototype.toString.call(e).slice(8,-1),jn=e=>typeof e>"u",Vi=e=>e===null,nt=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,es=e=>nt(e)&&Object.keys(e).length===0,ye=e=>Array.isArray(e),Hi=e=>typeof e=="string",Qi=e=>typeof e=="number"&&!isNaN(e),zi=e=>typeof e=="boolean",$i=e=>e instanceof RegExp,rt=e=>e instanceof Map,at=e=>e instanceof Set,kn=e=>Ki(e)==="Symbol",Wi=e=>e instanceof Date&&!isNaN(e.valueOf()),Yi=e=>e instanceof Error,ks=e=>typeof e=="number"&&isNaN(e),Ji=e=>zi(e)||Vi(e)||jn(e)||Qi(e)||Hi(e)||kn(e),Xi=e=>typeof e=="bigint",Zi=e=>e===1/0||e===-1/0,eo=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),to=e=>e instanceof URL,Dn=e=>e.replace(/\./g,"\\."),$t=e=>e.map(String).map(Dn).join("."),et=e=>{const t=[];let s="";for(let r=0;r<e.length;r++){let a=e.charAt(r);if(a==="\\"&&e.charAt(r+1)==="."){s+=".",r++;continue}if(a==="."){t.push(s),s="";continue}s+=a}const n=s;return t.push(n),t};function ae(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var Gn=[ae(jn,"undefined",()=>null,()=>{}),ae(Xi,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),ae(Wi,"Date",e=>e.toISOString(),e=>new Date(e)),ae(Yi,"Error",(e,t)=>{const s={name:e.name,message:e.message};return t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s},(e,t)=>{const s=new Error(e.message);return s.name=e.name,s.stack=e.stack,t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s}),ae($i,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),ae(at,"set",e=>[...e.values()],e=>new Set(e)),ae(rt,"map",e=>[...e.entries()],e=>new Map(e)),ae(e=>ks(e)||Zi(e),"number",e=>ks(e)?"NaN":e>0?"Infinity":"-Infinity",Number),ae(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),ae(to,"URL",e=>e.toString(),e=>new URL(e))];function Kt(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var On=Kt((e,t)=>kn(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,s)=>{const n=s.symbolRegistry.getValue(t[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),so=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),Rn=Kt(eo,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=so[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function Un(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var Mn=Kt(Un,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const s=t.classRegistry.getAllowedProps(e.constructor);if(!s)return{...e};const n={};return s.forEach(r=>{n[r]=e[r]}),n},(e,t,s)=>{const n=s.classRegistry.getValue(t[1]);if(!n)throw new Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(n.prototype),e)}),Bn=Kt((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,s)=>{const n=s.customTransformerRegistry.findByName(t[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(e)}),no=[Mn,On,Bn,Rn],Ds=(e,t)=>{const s=js(no,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=js(Gn,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},Fn={};Gn.forEach(e=>{Fn[e.annotation]=e});var ro=(e,t,s)=>{if(ye(t))switch(t[0]){case"symbol":return On.untransform(e,t,s);case"class":return Mn.untransform(e,t,s);case"custom":return Bn.untransform(e,t,s);case"typed-array":return Rn.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const n=Fn[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,s)}},Ce=(e,t)=>{if(t>e.size)throw new Error("index out of bounds");const s=e.keys();for(;t>0;)s.next(),t--;return s.next().value};function qn(e){if(vt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(vt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(vt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var ao=(e,t)=>{qn(t);for(let s=0;s<t.length;s++){const n=t[s];if(at(e))e=Ce(e,+n);else if(rt(e)){const r=+n,a=+t[++s]==0?"key":"value",i=Ce(e,r);switch(a){case"key":e=i;break;case"value":e=e.get(i);break}}else e=e[n]}return e},ts=(e,t,s)=>{if(qn(t),t.length===0)return s(e);let n=e;for(let a=0;a<t.length-1;a++){const i=t[a];if(ye(n)){const l=+i;n=n[l]}else if(nt(n))n=n[i];else if(at(n)){const l=+i;n=Ce(n,l)}else if(rt(n)){if(a===t.length-2)break;const c=+i,u=+t[++a]==0?"key":"value",f=Ce(n,c);switch(u){case"key":n=f;break;case"value":n=n.get(f);break}}}const r=t[t.length-1];if(ye(n)?n[+r]=s(n[+r]):nt(n)&&(n[r]=s(n[r])),at(n)){const a=Ce(n,+r),i=s(a);a!==i&&(n.delete(a),n.add(i))}if(rt(n)){const a=+t[t.length-2],i=Ce(n,a);switch(+r==0?"key":"value"){case"key":{const c=s(i);n.set(c,n.get(i)),c!==i&&n.delete(i);break}case"value":{n.set(i,s(n.get(i)));break}}}return e};function ss(e,t,s=[]){if(!e)return;if(!ye(e)){He(e,(a,i)=>ss(a,t,[...s,...et(i)]));return}const[n,r]=e;r&&He(r,(a,i)=>{ss(a,t,[...s,...et(i)])}),t(n,s)}function io(e,t,s){return ss(t,(n,r)=>{e=ts(e,r,a=>ro(a,n,s))}),e}function oo(e,t){function s(n,r){const a=ao(e,et(r));n.map(et).forEach(i=>{e=ts(e,i,()=>a)})}if(ye(t)){const[n,r]=t;n.forEach(a=>{e=ts(e,et(a),()=>e)}),r&&He(r,s)}else He(t,s);return e}var lo=(e,t)=>nt(e)||ye(e)||rt(e)||at(e)||Un(e,t);function co(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function uo(e,t){const s={};let n;return e.forEach(r=>{if(r.length<=1)return;t||(r=r.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[a,...i]=r;a.length===0?n=i.map($t):s[$t(a)]=i.map($t)}),n?es(s)?[n]:[n,s]:es(s)?void 0:s}var Kn=(e,t,s,n,r=[],a=[],i=new Map)=>{const l=Ji(e);if(!l){co(e,r,t);const E=i.get(e);if(E)return n?{transformedValue:null}:E}if(!lo(e,s)){const E=Ds(e,s),y=E?{transformedValue:E.value,annotations:[E.type]}:{transformedValue:e};return l||i.set(e,y),y}if(vt(a,e))return{transformedValue:null};const c=Ds(e,s),u=(c==null?void 0:c.value)??e,f=ye(u)?[]:{},d={};He(u,(E,y)=>{if(y==="__proto__"||y==="constructor"||y==="prototype")throw new Error(`Detected property ${y}. This is a prototype pollution risk, please remove it from your object.`);const x=Kn(E,t,s,n,[...r,y],[...a,e],i);f[y]=x.transformedValue,ye(x.annotations)?d[y]=x.annotations:nt(x.annotations)&&He(x.annotations,(P,A)=>{d[Dn(y)+"."+A]=P})});const g=es(d)?{transformedValue:f,annotations:c?[c.type]:void 0}:{transformedValue:f,annotations:c?[c.type,d]:d};return l||i.set(e,g),g};function Vn(e){return Object.prototype.toString.call(e).slice(8,-1)}function Gs(e){return Vn(e)==="Array"}function fo(e){if(Vn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function ho(e,t,s,n,r){const a={}.propertyIsEnumerable.call(n,t)?"enumerable":"nonenumerable";a==="enumerable"&&(e[t]=s),r&&a==="nonenumerable"&&Object.defineProperty(e,t,{value:s,enumerable:!1,writable:!0,configurable:!0})}function ns(e,t={}){if(Gs(e))return e.map(r=>ns(r,t));if(!fo(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((r,a)=>{if(Gs(t.props)&&!t.props.includes(a))return r;const i=e[a],l=ns(i,t);return ho(r,a,l,e,t.nonenumerable),r},{})}var B=class{constructor({dedupe:e=!1}={}){this.classRegistry=new Mi,this.symbolRegistry=new Ln(t=>t.description??""),this.customTransformerRegistry=new qi,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=Kn(e,t,this,this.dedupe),n={json:s.transformedValue};s.annotations&&(n.meta={...n.meta,values:s.annotations});const r=uo(t,this.dedupe);return r&&(n.meta={...n.meta,referentialEqualities:r}),n}deserialize(e){const{json:t,meta:s}=e;let n=ns(t);return s!=null&&s.values&&(n=io(n,s.values,this)),s!=null&&s.referentialEqualities&&(n=oo(n,s.referentialEqualities)),n}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};B.defaultInstance=new B;B.serialize=B.defaultInstance.serialize.bind(B.defaultInstance);B.deserialize=B.defaultInstance.deserialize.bind(B.defaultInstance);B.stringify=B.defaultInstance.stringify.bind(B.defaultInstance);B.parse=B.defaultInstance.parse.bind(B.defaultInstance);B.registerClass=B.defaultInstance.registerClass.bind(B.defaultInstance);B.registerSymbol=B.defaultInstance.registerSymbol.bind(B.defaultInstance);B.registerCustom=B.defaultInstance.registerCustom.bind(B.defaultInstance);B.allowErrorProps=B.defaultInstance.allowErrorProps.bind(B.defaultInstance);var Hn=B.serialize,go=B.stringify;function mo(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function Eo(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function po({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function yo({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function Ao(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var So=(e,t=!1)=>{const{json:s}=Hn(e);return JSON.stringify(s,null,t?2:void 0)},St=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,To=(e,t)=>e.queryHash.localeCompare(t.queryHash),Qn=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,Po=(e,t)=>St(e)===St(t)?Qn(e,t):St(e)>St(t)?1:-1,xo={status:Po,"query hash":To,"last updated":Qn},Tt=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,zn=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,_o=(e,t)=>Tt(e)===Tt(t)?zn(e,t):Tt(e)>Tt(t)?1:-1,wo={status:_o,"last updated":zn},vo=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),bo=()=>{const[e,t]=V("dark");return hn(()=>{const s=window.matchMedia("(prefers-color-scheme: dark)");t(s.matches?"dark":"light");const n=r=>{t(r.matches?"dark":"light")};s.addEventListener("change",n),Ve(()=>s.removeEventListener("change",n))}),e},Je=(e,t,s)=>{if(t.length===0)return s;if(e instanceof Map){const n=new Map(e);if(t.length===1)return n.set(t[0],s),n;const[r,...a]=t;return n.set(r,Je(n.get(r),a,s)),n}if(e instanceof Set){const n=Je(Array.from(e),t,s);return new Set(n)}if(Array.isArray(e)){const n=[...e];if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=Je(n[r],a,s),n}if(e instanceof Object){const n={...e};if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=Je(n[r],a,s),n}return e},Xe=(e,t)=>{if(e instanceof Map){const s=new Map(e);if(t.length===1)return s.delete(t[0]),s;const[n,...r]=t;return s.set(n,Xe(s.get(n),r)),s}if(e instanceof Set){const s=Xe(Array.from(e),t);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s.filter((a,i)=>i.toString()!==t[0]);const[n,...r]=t;return s[n]=Xe(s[n],r),s}if(e instanceof Object){const s={...e};if(t.length===1)return delete s[t[0]],s;const[n,...r]=t;return s[n]=Xe(s[n],r),s}return e},$n=(e,t)=>{if(!e||document.querySelector("#_goober")||(t==null?void 0:t.querySelector("#_goober")))return;const n=document.createElement("style"),r=document.createTextNode("");n.appendChild(r),n.id="_goober",n.setAttribute("nonce",e),t?t.appendChild(n):document.head.appendChild(n)},Ie,it,ot,lt,xe,ct,Ne,Le,je,ke,De,ut,Ge,dt,Us,Co=(Us=class{constructor(e){G(this,Ie);G(this,it);G(this,ot);G(this,lt);G(this,xe,!1);G(this,ct);G(this,Ne);G(this,Le);G(this,je);G(this,ke);G(this,De);G(this,ut);G(this,Ge);G(this,dt);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:u,shadowDOMTarget:f,hideDisabledQueries:d}=e;D(this,Ie,V(t)),D(this,ot,s),D(this,lt,n),D(this,it,r),D(this,ct,u),D(this,Ne,f),D(this,Le,V(a)),D(this,je,V(i)),D(this,ke,V(l)),D(this,De,V(c)),D(this,ut,V(d))}setButtonPosition(e){v(this,Le)[1](e)}setPosition(e){v(this,je)[1](e)}setInitialIsOpen(e){v(this,ke)[1](e)}setErrorTypes(e){v(this,De)[1](e)}setClient(e){v(this,Ie)[1](e)}mount(e){if(v(this,xe))throw new Error("Devtools is already mounted");const t=xn(()=>{const s=this,[n]=v(this,Le),[r]=v(this,je),[a]=v(this,ke),[i]=v(this,De),[l]=v(this,ut),[c]=v(this,Ie);let u;return v(this,Ge)?u=v(this,Ge):(u=Tn(()=>Promise.resolve().then(()=>require("./NCMVHL6D-BChQ0wDN.cjs"))),D(this,Ge,u)),$n(v(this,ct),v(this,Ne)),ps(u,ys({get queryFlavor(){return v(s,ot)},get version(){return v(s,lt)},get onlineManager(){return v(s,it)},get shadowDOMTarget(){return v(s,Ne)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()}}))},e);D(this,xe,!0),D(this,dt,t)}unmount(){var e;if(!v(this,xe))throw new Error("Devtools is not mounted");(e=v(this,dt))==null||e.call(this),D(this,xe,!1)}},Ie=new WeakMap,it=new WeakMap,ot=new WeakMap,lt=new WeakMap,xe=new WeakMap,ct=new WeakMap,Ne=new WeakMap,Le=new WeakMap,je=new WeakMap,ke=new WeakMap,De=new WeakMap,ut=new WeakMap,Ge=new WeakMap,dt=new WeakMap,Us),Oe,ft,ht,gt,_e,mt,Re,Ue,Me,Be,Fe,Et,qe,Ke,pt,Ms,Io=(Ms=class{constructor(e){G(this,Oe);G(this,ft);G(this,ht);G(this,gt);G(this,_e,!1);G(this,mt);G(this,Re);G(this,Ue);G(this,Me);G(this,Be);G(this,Fe);G(this,Et);G(this,qe);G(this,Ke);G(this,pt);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:u,shadowDOMTarget:f,onClose:d,hideDisabledQueries:g}=e;D(this,Oe,V(t)),D(this,ht,s),D(this,gt,n),D(this,ft,r),D(this,mt,u),D(this,Re,f),D(this,Ue,V(a)),D(this,Me,V(i)),D(this,Be,V(l)),D(this,Fe,V(c)),D(this,Et,V(g)),D(this,qe,V(d))}setButtonPosition(e){v(this,Ue)[1](e)}setPosition(e){v(this,Me)[1](e)}setInitialIsOpen(e){v(this,Be)[1](e)}setErrorTypes(e){v(this,Fe)[1](e)}setClient(e){v(this,Oe)[1](e)}setOnClose(e){v(this,qe)[1](()=>e)}mount(e){if(v(this,_e))throw new Error("Devtools is already mounted");const t=xn(()=>{const s=this,[n]=v(this,Ue),[r]=v(this,Me),[a]=v(this,Be),[i]=v(this,Fe),[l]=v(this,Et),[c]=v(this,Oe),[u]=v(this,qe);let f;return v(this,Ke)?f=v(this,Ke):(f=Tn(()=>Promise.resolve().then(()=>require("./2AITGKQY-PHs1xUsz.cjs"))),D(this,Ke,f)),$n(v(this,mt),v(this,Re)),ps(f,ys({get queryFlavor(){return v(s,ht)},get version(){return v(s,gt)},get onlineManager(){return v(s,ft)},get shadowDOMTarget(){return v(s,Re)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()},get onClose(){return u()}}))},e);D(this,_e,!0),D(this,pt,t)}unmount(){var e;if(!v(this,_e))throw new Error("Devtools is not mounted");(e=v(this,pt))==null||e.call(this),D(this,_e,!1)}},Oe=new WeakMap,ft=new WeakMap,ht=new WeakMap,gt=new WeakMap,_e=new WeakMap,mt=new WeakMap,Re=new WeakMap,Ue=new WeakMap,Me=new WeakMap,Be=new WeakMap,Fe=new WeakMap,Et=new WeakMap,qe=new WeakMap,Ke=new WeakMap,pt=new WeakMap,Ms);function No(e){const t=w.useQueryClient(e.client),s=Q.useRef(null),{buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:u}=e,[f]=Q.useState(new Co({client:t,queryFlavor:"React Query",version:"5",onlineManager:w.onlineManager,buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:u}));return Q.useEffect(()=>{f.setClient(t)},[t,f]),Q.useEffect(()=>{n&&f.setButtonPosition(n)},[n,f]),Q.useEffect(()=>{r&&f.setPosition(r)},[r,f]),Q.useEffect(()=>{f.setInitialIsOpen(a||!1)},[a,f]),Q.useEffect(()=>{f.setErrorTypes(i||[])},[i,f]),Q.useEffect(()=>(s.current&&f.mount(s.current),()=>{f.unmount()}),[f]),o.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:s})}function Lo(e){const t=w.useQueryClient(e.client),s=Q.useRef(null),{errorTypes:n,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:i}=e,[l]=Q.useState(new Io({client:t,queryFlavor:"React Query",version:"5",onlineManager:w.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:n,styleNonce:r,shadowDOMTarget:a,onClose:e.onClose,hideDisabledQueries:i}));return Q.useEffect(()=>{l.setClient(t)},[t,l]),Q.useEffect(()=>{l.setOnClose(e.onClose??(()=>{}))},[e.onClose,l]),Q.useEffect(()=>{l.setErrorTypes(n||[])},[n,l]),Q.useEffect(()=>(s.current&&l.mount(s.current),()=>{l.unmount()}),[l]),o.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:s})}var Os=process.env.NODE_ENV!=="development"?function(){return null}:No;process.env.NODE_ENV;const jo=()=>{N.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),N.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"})},ko=()=>{const e=F(),t=R();return w.useQuery({queryKey:[S.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:S.GET_COLLECTIONS})})},Do=()=>{const{data:e}=Z(),{data:t}=de(),{data:s}=Se(),n=F(),r=R(),a=h.useMemo(()=>(s==null?void 0:s.fallbackLang)||"en",[s==null?void 0:s.fallbackLang]);return w.useMutation({mutationFn:async({block:i})=>r(n,{action:S.GET_BLOCK_ASYNC_PROPS,data:{block:i,lang:(t==null?void 0:t.lang)||a,pageProps:{slug:t==null?void 0:t.slug,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:a,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id}}})})},Wn=()=>{const[,e]=ee();return h.useCallback((t,s)=>{const r=new URLSearchParams(window.location.search).get("lang"),a=new URLSearchParams({page:t});r&&a.set("lang",r),window.history.pushState({},"",`?${a.toString()}`),e(a),window.dispatchEvent(new PopStateEvent("popstate")),s==null||s()},[e])},Yn=()=>{const e=Wn();return h.useCallback(({pageId:t})=>{e(t)},[e])},Go=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-ZyQJP6AO.cjs"))),Oo=h.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-CsrSeusU.cjs"))),Ro=h.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-DHRs6ag2.cjs"))),Uo=h.lazy(()=>Promise.resolve().then(()=>require("./web-preview-CI3Vz7Yp.cjs")));jo();rr.loadWebBlocks();N.registerChaiTopBar(Sa);Ba();N.registerChaiMediaManager(Go);N.registerChaiSaveToLibrary(Oo);const Mo={role:"",permissions:null},Rs=e=>{va(),Ir();const t=Mt(),{data:s=Mo,isFetching:n}=nn(),{data:r,isFetching:a}=fe(),{data:i,isFetching:l}=ko(),{data:c,isFetching:u}=Se(),f=n||a||l||u,[d]=ee(),g=d.get("page"),{data:E}=Z(),{data:y,isFetching:x}=_a(),{blocks:P}=xa(y),{lockingStatus:A,pageLock:T}=Te(),{data:C,isFetching:U}=tn(),q=Ta(),{onSave:L}=ba(),{mutateAsync:le}=Do(),{getPartialBlocks:ce,getPartialBlockBlocks:O}=Ca(),{mutateAsync:I}=Kr(),{mutateAsync:j}=sn(),W=Yn(),[H,se]=h.useState(!1),ze=h.useRef([]),ge=h.useMemo(()=>p.get(c,"theme",{})||{},[c]),$e=p.isEmpty(A)&&(T==null?void 0:T.status)==="editing",Pe=(T==null?void 0:T.status)==="checking",As=x||Pe||U;ze.current=P;const[Xn]=K.useAtom(ds);h.useEffect(()=>{const ne=()=>{document.hidden?se(!0):se(!1)};return window.addEventListener("visibilitychange",ne),()=>window.removeEventListener("visibilitychange",ne)},[]);const Zn=h.useMemo(()=>{const ne={};return s&&(ne.permissions=p.get(s,"permissions",null),ne.role=p.get(s,"role","user")),ne},[s]),er=h.useCallback(async(ne,yt)=>await I({pageType:ne,query:yt}),[I]);return o.jsxs(o.Fragment,{children:[As&&o.jsx(hs,{className:f?"fixed inset-0 bg-white":"bg-white/75",children:o.jsx(_.Loader,{className:`animate-spin text-primary ${f?"h-6 w-6":"h-5 w-5"}`})}),Xn&&o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"absolute inset-0 z-[999999] flex min-h-screen w-screen items-center justify-center bg-gray-100",children:o.jsx(_.Loader,{className:"h-6 w-6 animate-spin text-primary"})}),children:o.jsx(Uo,{})}),o.jsx(N.ChaiBuilderEditor,{gotoPage:W,collections:i??[],getBlockAsyncProps:le,pageExternalData:C,themePresets:e.themePresets??[],pageId:E==null?void 0:E.id,loading:x,fallbackLang:t,languages:(c==null?void 0:c.languages)||[],brandingOptions:(c==null?void 0:c.theme)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!H&&$e&&(e.autoSave??!0),autoSaveInterval:e.autoSaveInterval??15,onError:e.onError||console.error,getPartialBlockBlocks:O,getPartialBlocks:ce,blocks:x?[]:P,theme:p.cloneDeep(ge),pageTypes:r,searchPageTypeItems:er,askAiCallBack:q,onSave:async({blocks:ne,theme:yt,needTranslations:tr})=>{if(!g)return!0;ze.current=ne;const Ss=[...ne];return await L({page:g,blocks:Ss,needTranslations:tr}),ze.current=Ss,p.isEqual(yt,ge)||await j({settings:{theme:yt}}),!0},themePanelComponent:Ro,...Zn}),o.jsxs("div",{children:[o.jsx(jr,{isFetchingPage:As}),o.jsx(kr,{})]})]})},Bo=new w.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1}}}),Fo=e=>{const{isLoggedIn:t}=re(),[,s]=Gt(),[n,r]=h.useState(!1);return h.useEffect(()=>(s(p.pick(e,["apiUrl","usersApiUrl","assetsApiUrl","getPreviewUrl","getLiveUrl","topLeftCorner","onLogout","getAccessToken","supabaseInstance","features"])),setTimeout(()=>{r(!0)},200),()=>{r(!1),s({})}),[e,s]),n?p.get(e,"hasReactQueryProvider",!1)===!0?o.jsxs(o.Fragment,{children:[t?o.jsx(Rs,{...e}):o.jsx(vs,{}),o.jsx(Os,{})]}):o.jsxs(w.QueryClientProvider,{client:Bo,children:[t?o.jsx(Rs,{...e}):o.jsx(vs,{}),o.jsx(Os,{})]}):o.jsx("div",{})},qo=Q.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-D_iF9Sm3.cjs")));function Jn({data:e,onSelect:t,dataType:s="value",disabled:n=!1}){const[r,a]=Q.useState(!1);return o.jsxs(m.Popover,{open:r,onOpenChange:a,children:[o.jsxs(m.Tooltip,{children:[o.jsx(m.TooltipTrigger,{asChild:!0,children:o.jsx(m.PopoverTrigger,{asChild:!0,children:o.jsx(m.Button,{size:"sm",variant:"outline",className:"h-6 w-6 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,disabled:n,children:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:o.jsx("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"#000000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),o.jsx(m.TooltipContent,{children:"Add field"})]}),r&&o.jsx(Q.Suspense,{children:o.jsx(qo,{data:e,onSelect:t,dataType:s,open:r,setOpen:a})})]})}const Ko=()=>{const{savePageAsync:e}=N.useSavePage(),t=w.useQueryClient();return h.useCallback(async()=>{await e(),t.invalidateQueries({queryKey:[S.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[S.GET_BUILDER_PAGE_DATA]})},[e,t])},Vo=()=>{const e=w.useQueryClient();return h.useCallback(()=>{e.clear()},[e])},Ho=()=>{const e=F(),t=R(),{data:s}=de(),n=w.useQueryClient();return w.useMutation({mutationFn:async r=>{if(!(s!=null&&s.id))throw new Error("No active page found");return await t(`${e}`,{action:S.UPDATE_PAGE_METADATA,data:{id:s.id,metadata:r}})},onSuccess:()=>{n.invalidateQueries({queryKey:[S.GET_BUILDER_PAGE_DATA]}),n.invalidateQueries({queryKey:[S.GET_LANGUAGE_PAGES]})},onError:()=>{console.error("Failed to update metadata")}})},Qo=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-ZyQJP6AO.cjs"))),zo=({assetId:e,assetUrl:t,onChange:s,className:n="",placeholder:r="Select an image",disabled:a=!1})=>{const[i,l]=h.useState(!1),c=()=>{a||l(!0)},u=()=>{l(!1)},f=E=>{const y=Array.isArray(E)?E[0]:E;y!=null&&y.url&&s(p.pick(y,["url","id"])),l(!1)},d=()=>{s({url:"",id:""})},g=(t==null?void 0:t.startsWith("{{"))&&(t==null?void 0:t.endsWith("}}"));return o.jsxs("div",{className:`w-full ${n}`,children:[t?o.jsxs("div",{className:"relative overflow-hidden rounded-md border",children:[g?o.jsx("div",{className:"flex h-12 items-center bg-gray-100 px-4",children:o.jsx("p",{className:"text-xs text-gray-500",children:t})}):o.jsx("img",{onClick:c,src:t,alt:"Selected image",className:"h-auto max-h-[100px] w-full bg-gray-100 object-contain"}),o.jsxs("div",{className:"absolute right-2 top-2 flex gap-2",children:[o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white text-red-500",onClick:d,disabled:a,children:g?o.jsx(_.X,{className:"h-4 w-4"}):o.jsx(_.Trash2,{className:"h-4 w-4"})}),!g&&o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white/80 hover:bg-white/90",onClick:c,disabled:a,children:o.jsx(_.ImageIcon,{className:"h-4 w-4"})})]})]}):o.jsx("div",{className:`flex cursor-pointer items-center justify-center rounded-md border border-dashed p-6 ${a?"cursor-not-allowed opacity-50":"hover:border-gray-400"}`,onClick:c,children:o.jsxs("div",{className:"flex flex-col items-center gap-2",children:[o.jsx(_.ImageIcon,{className:"h-10 w-10 text-gray-400"}),o.jsx("p",{className:"text-sm text-gray-500",children:r})]})}),o.jsx(m.Dialog,{open:i,onOpenChange:l,children:o.jsxs(m.DialogContent,{className:"h-fit w-full max-w-7xl overflow-hidden p-0",children:[o.jsxs(m.DialogHeader,{className:"hidden border-b px-4 py-2",children:[o.jsx(m.DialogTitle,{children:"Select Image"}),o.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:u,children:o.jsx(_.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"h-full flex-1 p-4",children:o.jsx(h.Suspense,{children:o.jsx(Qo,{close:u,onSelect:f,mode:"image",assetId:e})})})]})})]})},$o=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),rs=e=>{if(!e.trim())return{isValid:!1,parsed:null,placeholders:[],error:{message:"JSON is empty"}};try{return{isValid:!0,parsed:JSON.parse(e),error:null,placeholders:[]}}catch{}const t=/{{([^{}]+)}}/g,s=[];let n=e,r;for(;(r=t.exec(e))!==null;){const a=r[0],i=r.index,l=`"__placeholder_${s.length}__"`;s.push({original:a,replaced:l,position:i}),n=n.replace(a,l)}try{return{isValid:!0,parsed:JSON.parse(n),error:null,placeholders:s}}catch(a){const i=a,l=i.message.match(/position (\d+)/),c=l?parseInt(l[1]):void 0;let u,f;if(c!==void 0){const d=n.substring(0,c).split(`
|
|
2
|
+
`);u=d.length,f=d[d.length-1].length+1}return{isValid:!1,parsed:null,placeholders:s,error:{message:i.message,line:u,column:f,position:c}}}},Wo=(e,t)=>{let n=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const i=`"__placeholder_${a}__"`,l=new RegExp($o(i),"g");n=n.replace(l,r)}),n},Yo=(e,t)=>{if(!e)return"";let s=JSON.stringify(e,null,2);const n=/{{([^{}]+)}}/g;let r;for(;(r=n.exec(s))!==null;){const a=r[1],i=p.get(t,a,null);s=s.replace(r[0],i)}return s},Jo=h.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-C_vIO-Qk.cjs"))),Xo=({value:e,onChange:t,disabled:s=!1,readOnly:n=!1,placeholder:r="Enter JSON",rows:a=6,id:i="json-input",pageData:l={},handleFieldInsert:c,hasJsonLdForSelectedLang:u,copyJsonLDFromDefaultPage:f})=>{const[d,g]=h.useState("edit"),[E,y]=h.useState(null),[x,P]=h.useState(""),A=h.useRef(null),[T]=Gt(),C=i==="jsonLD"&&p.get(T,"features.sharedJsonLD",!1),U=i==="jsonLD"&&!u&&!!f;h.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const q=O=>{if(n)return;const I=O.target.value;t(I)},L=O=>{if(O.key==="Tab"){O.preventDefault();const I=O.currentTarget,j=I.selectionStart,W=I.selectionEnd;if(j!==W){const se=e.substring(j,W).split(`
|
|
3
|
+
`);if(O.shiftKey){const ge=se.map(Pe=>Pe.startsWith(" ")?Pe.substring(2):Pe).join(`
|
|
4
|
+
`),$e=e.substring(0,j)+ge+e.substring(W);t($e),setTimeout(()=>{I.selectionStart=j,I.selectionEnd=j+ge.length},0)}else{const ge=se.map(Pe=>` ${Pe}`).join(`
|
|
5
|
+
`),$e=e.substring(0,j)+ge+e.substring(W);t($e),setTimeout(()=>{I.selectionStart=j,I.selectionEnd=j+ge.length},0)}}else{const H=e.substring(0,j)+" "+e.substring(W);t(H),setTimeout(()=>{I.selectionStart=I.selectionEnd=j+2},0)}}};h.useEffect(()=>{const O=rs(e);if(O.isValid)if(y(null),O.parsed){const I=Yo(O.parsed,l);P(I)}else P("");else y(O.error),P("")},[e,l]);const le=()=>{const O=rs(e);if(O.isValid&&O.parsed){const I=Wo(O.parsed,O.placeholders);t(I)}},ce=()=>{E!=null&&E.position&&A.current&&(A.current.focus(),A.current.setSelectionRange(E.position,E.position+1))};return o.jsx("div",{className:"space-y-2",children:o.jsxs(m.Tabs,{value:d,onValueChange:g,className:"w-full",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[o.jsxs(m.TabsList,{className:"w-max",children:[o.jsxs(m.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[o.jsx(_.Code,{className:"h-4 w-4"}),o.jsx("span",{children:"Edit"})]}),o.jsxs(m.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!e.trim()||E!==null||U,children:[o.jsx(_.Eye,{className:"h-4 w-4"}),o.jsx("span",{children:"Preview"})]}),C&&o.jsxs(m.TabsTrigger,{value:"shared",className:"flex items-center gap-1",disabled:!e.trim()||E!==null,children:[o.jsx(_.Share2,{className:"h-4 w-4"}),o.jsx("span",{children:"Shared"})]})]}),U?null:d==="edit"&&!n&&o.jsx("div",{className:"flex items-center gap-2",children:o.jsx(Jn,{dataType:"value",data:l??{},onSelect:O=>c&&c(O,i)})})]}),o.jsxs(m.TabsContent,{value:"edit",className:"relative mt-0",children:[!U&&d==="edit"&&o.jsx(Bt,{content:"Format JSON",side:"right",showTooltip:!s&&!E,children:o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",onClick:le,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||s||E!==null,children:o.jsx(_.FileCode2,{})})}),U?o.jsx("div",{className:"flex h-40 items-center justify-center rounded-md bg-black/20",children:o.jsxs("div",{className:"flex max-w-[400px] flex-col items-center gap-2 rounded-md bg-white p-4 shadow-lg",children:[o.jsx("div",{className:"max-w-xl text-center text-xs text-gray-500",children:"JSON-LD for is not added for selected language. JSON LD will be used from default language."}),o.jsxs(m.Button,{type:"button",variant:"default",size:"sm",onClick:f,children:[o.jsx(_.Plus,{}),"Copy & Edit from default language"]})]})}):o.jsx(m.Textarea,{ref:A,id:i,name:i,className:`rounded-md border border-input text-xs ${E?"border-red-500":""}`,onChange:q,onKeyDown:L,value:e,placeholder:r,rows:a,disabled:s,readOnly:n}),E&&o.jsxs(m.Alert,{variant:"destructive",className:"mt-2",children:[o.jsx(_.AlertTriangle,{className:"h-4 w-4"}),o.jsxs(m.AlertDescription,{className:"flex flex-col",children:[o.jsx("span",{className:"font-medium",children:"Invalid JSON"}),o.jsx("span",{className:"text-sm",children:E.message}),E.line&&E.column&&o.jsxs("span",{className:"text-sm",children:["Error at line ",E.line,", column ",E.column]}),o.jsx(m.Button,{type:"button",variant:"link",size:"sm",className:"mt-1 h-auto self-start p-0 text-sm",onClick:ce,children:"Show position"})]})]})]}),o.jsxs(m.TabsContent,{value:"preview",className:"mt-0",children:[o.jsx(m.Textarea,{rows:a,value:x,readOnly:!0,className:"cursor-default bg-muted font-mono text-sm"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This is how the JSON will look after placeholder substitution."})]}),C&&o.jsx(m.TabsContent,{value:"shared",className:"mt-0",children:o.jsx(h.Suspense,{children:o.jsx(Jo,{})})})]})})},Zo=()=>{const{logout:e}=re(),{getAccessToken:t}=Vs();return h.useCallback(async({url:s,method:n="GET",body:r={},headers:a={}})=>{const i=await t();if(!i)throw new Error("No auth token");if(!s)throw new Error("URL is required");try{const l=await fetch(s,{method:n,headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`,...a},body:JSON.stringify(r)});if(l.status===401)return console.log("Session expired",l),await e(),window.location.reload(),null;if(l.status===400)throw new Error((await l.json()).error);return await l.json()}catch(l){throw console.log("Something went wrong",l),l}},[e,t])};if(typeof window>"u")throw new Error("@chaibuilder/pages is not available on the server");exports.$TRACK=gs;exports.ACTIONS=S;exports.BlurContainer=hs;exports.CONTENT=Y;exports.ChaiBuilderPages=Fo;exports.ChaiBuilderPagesRealtime=Hs;exports.Dynamic=Ri;exports.For=li;exports.ImagePicker=zo;exports.Index=ci;exports.LANGUAGES=We;exports.LanguageSwitcher=Js;exports.Match=fi;exports.NestedPathSelector=Jn;exports.PAGES_PERMISSIONS=te;exports.PageActionsDropdown=Zs;exports.PermissionChecker=xt;exports.Portal=Gi;exports.Show=ui;exports.SmartJsonInput=Xo;exports.Switch=di;exports.Tooltip=Bt;exports.addEventListener=vn;exports.addNewLangAtom=Ut;exports.atomWithStorage=qs;exports.batch=Ha;exports.className=wn;exports.clearDelegatedEvents=wi;exports.convertRemToPixels=vo;exports.createComponent=ps;exports.createComputed=fn;exports.createContext=Ya;exports.createEffect=ms;exports.createMemo=z;exports.createRenderEffect=pe;exports.createRoot=Ee;exports.createSignal=V;exports.createUniqueId=oi;exports.delegateEvents=_n;exports.deleteNestedDataByPath=Xe;exports.displayValue=So;exports.getMutationStatusColor=yo;exports.getPreferredColorScheme=bo;exports.getQueryStatusColor=po;exports.getQueryStatusColorByLabel=Ao;exports.getQueryStatusLabel=mo;exports.getSidedProp=Eo;exports.insert=Dt;exports.memo=Pi;exports.mergeProps=ys;exports.mutationSortFns=wo;exports.navigateToPage=cs;exports.on=Qa;exports.onCleanup=Ve;exports.onMount=hn;exports.parseJSONWithPlaceholders=rs;exports.previewUrlAtom=ds;exports.registerLoginComponent=La;exports.serialize=Hn;exports.setAttribute=kt;exports.sortFns=xo;exports.splitProps=Sn;exports.spread=bn;exports.stringify=go;exports.template=_i;exports.throwConfetti=_t;exports.untrack=J;exports.updateNestedDataByPath=Je;exports.use=Cn;exports.useActivePage=de;exports.useApiUrl=F;exports.useAssetsApiUrl=or;exports.useBuilderPageData=tn;exports.useChaiAuth=re;exports.useChaiFetch=Zo;exports.useChaiUserInfo=$s;exports.useChangePage=Wn;exports.useChangeSlug=Yr;exports.useClearAll=Vo;exports.useContext=Ja;exports.useCreatePage=Vr;exports.useCurrentPage=Z;exports.useDeletePage=Qr;exports.useDynamicPageSelector=zs;exports.useFallbackLang=Mt;exports.useFetch=R;exports.useGotoPage=Yn;exports.useIsLanguagePageCreated=is;exports.useLanguagePages=Ae;exports.useMarkAsTemplate=$r;exports.usePageEditInfo=Rt;exports.usePageLockRequestTakeOver=Ws;exports.usePageType=Xs;exports.usePageTypes=fe;exports.usePageUserMapping=Cr;exports.usePagesProps=Gt;exports.usePublishPages=fs;exports.useReloadPage=Ko;exports.useSearchParams=ee;exports.useTransition=Wa;exports.useUnmarkAsTemplate=Wr;exports.useUnpublishPage=zr;exports.useUpdateActivePageMetadata=Ho;exports.useUpdateAppSharedJsonLD=wa;exports.useUpdatePage=Hr;exports.useUpdateWebsiteSettings=sn;exports.useUserRoleAndPermissions=nn;exports.useWebsiteLanguagePages=Dr;exports.useWebsitePages=us;exports.useWebsiteSetting=Se;
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-DSUpSpeI.cjs"),s=require("@chaibuilder/sdk");exports.ChaiBuilderPagesRealtime=e.ChaiBuilderPagesRealtime;exports.ChaiJsonInput=e.SmartJsonInput;exports.ImagePicker=e.ImagePicker;exports.LanguageSwitcher=e.LanguageSwitcher;exports.NestedPathSelector=e.NestedPathSelector;exports.PermissionChecker=e.PermissionChecker;exports.default=e.ChaiBuilderPages;exports.registerChaiLoginComponent=e.registerLoginComponent;exports.useActivePage=e.useActivePage;exports.useBuilderPageData=e.useBuilderPageData;exports.useChaiAuth=e.useChaiAuth;exports.useChaiCurrentPage=e.useCurrentPage;exports.useChaiFetch=e.useChaiFetch;exports.useChaiUserInfo=e.useChaiUserInfo;exports.useClearAll=e.useClearAll;exports.useFallbackLang=e.useFallbackLang;exports.useFetch=e.useFetch;exports.useGotoPage=e.useGotoPage;exports.useLanguagePages=e.useLanguagePages;exports.usePageTypes=e.usePageTypes;exports.useReloadPage=e.useReloadPage;exports.useUpdateActivePageMetadata=e.useUpdateActivePageMetadata;exports.useUserPermissions=e.useUserRoleAndPermissions;exports.useWebsitePages=e.useWebsitePages;exports.useWebsiteSetting=e.useWebsiteSetting;Object.keys(s).forEach(a=>{a!=="default"&&!Object.prototype.hasOwnProperty.call(exports,a)&&Object.defineProperty(exports,a,{enumerable:!0,get:()=>s[a]})});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ChaiBuilderEditorProps } from '@chaibuilder/sdk';
|
|
2
2
|
import { ComponentType } from 'react';
|
|
3
3
|
import { default as default_2 } from 'react';
|
|
4
|
-
import { DefinedUseQueryResult } from '@tanstack/react-query';
|
|
5
4
|
import { JSX } from 'react/jsx-runtime';
|
|
6
5
|
import { ReactNode } from 'react';
|
|
7
6
|
import { RESET } from 'jotai/utils';
|
|
@@ -56,16 +55,6 @@ declare interface ChaiBuilderPagesRealtimeInterface {
|
|
|
56
55
|
|
|
57
56
|
export declare const ChaiJsonInput: React.FC<SmartJsonInputProps>;
|
|
58
57
|
|
|
59
|
-
declare interface ChaiSiteSetting {
|
|
60
|
-
id: string;
|
|
61
|
-
label: string;
|
|
62
|
-
panel: ComponentType;
|
|
63
|
-
button: React.ComponentType<{
|
|
64
|
-
isActive: boolean;
|
|
65
|
-
onClick: () => void;
|
|
66
|
-
}>;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
58
|
declare type ChaiWebsiteSetting = {
|
|
70
59
|
appKey: string;
|
|
71
60
|
fallbackLang: string;
|
|
@@ -128,13 +117,6 @@ export declare const PermissionChecker: ({ permission, permissions, children, fa
|
|
|
128
117
|
|
|
129
118
|
export declare const registerChaiLoginComponent: (component: ComponentType) => void;
|
|
130
119
|
|
|
131
|
-
/**
|
|
132
|
-
* Register a new site setting tab
|
|
133
|
-
* @param settingId - Unique identifier for the setting
|
|
134
|
-
* @param options - Configuration options for the setting
|
|
135
|
-
*/
|
|
136
|
-
export declare const registerChaiSiteSetting: (settingId: string, options: Omit<ChaiSiteSetting, "id">) => void;
|
|
137
|
-
|
|
138
120
|
declare interface SmartJsonInputProps {
|
|
139
121
|
value: string;
|
|
140
122
|
onChange: (value: string) => void;
|
|
@@ -154,7 +136,7 @@ export declare const useActivePage: () => {
|
|
|
154
136
|
isFetching: boolean;
|
|
155
137
|
};
|
|
156
138
|
|
|
157
|
-
export declare const useBuilderPageData: () =>
|
|
139
|
+
export declare const useBuilderPageData: () => UseQueryResult<any, Error>;
|
|
158
140
|
|
|
159
141
|
export declare const useChaiAuth: () => {
|
|
160
142
|
readonly isLoggedIn: boolean;
|
|
@@ -195,9 +177,9 @@ export declare const useGotoPage: () => ({ pageId }: {
|
|
|
195
177
|
pageId: string;
|
|
196
178
|
}) => void;
|
|
197
179
|
|
|
198
|
-
export declare const useLanguagePages: (pageId?: string | undefined) =>
|
|
180
|
+
export declare const useLanguagePages: (pageId?: string | undefined) => UseQueryResult<any[] | null, Error>;
|
|
199
181
|
|
|
200
|
-
export declare const usePageTypes: () =>
|
|
182
|
+
export declare const usePageTypes: () => UseQueryResult<any, Error>;
|
|
201
183
|
|
|
202
184
|
export declare const useReloadPage: () => () => Promise<void>;
|
|
203
185
|
|
|
@@ -207,7 +189,7 @@ export declare const useUserPermissions: () => UseQueryResult<any, Error>;
|
|
|
207
189
|
|
|
208
190
|
export declare const useWebsitePages: () => UseQueryResult<any, Error>;
|
|
209
191
|
|
|
210
|
-
export declare const useWebsiteSetting: () =>
|
|
192
|
+
export declare const useWebsiteSetting: () => UseQueryResult<ChaiWebsiteSetting, Error>;
|
|
211
193
|
|
|
212
194
|
|
|
213
195
|
export * from "@chaibuilder/sdk";
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aT as s, aI as t, aH as u, aF as i, aG as g, av as r, aK as o, aP as P, aL as h, aC as n, aQ as l, am as C, aS as c, aq as m, aM as d, f as p, al as f, aN as L, g as b, h as A, aO as F, an as I, aR as S, b as k, e as v } from "./index-Byi6-4u1.js";
|
|
2
2
|
export * from "@chaibuilder/sdk";
|
|
3
3
|
export {
|
|
4
4
|
s as ChaiBuilderPagesRealtime,
|
|
5
5
|
t as ChaiJsonInput,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
u as ImagePicker,
|
|
7
|
+
i as LanguageSwitcher,
|
|
8
8
|
g as NestedPathSelector,
|
|
9
9
|
r as PermissionChecker,
|
|
10
10
|
o as default,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
l as
|
|
15
|
-
C as
|
|
16
|
-
c as
|
|
17
|
-
d as useChaiFetch,
|
|
11
|
+
P as registerChaiLoginComponent,
|
|
12
|
+
h as useActivePage,
|
|
13
|
+
n as useBuilderPageData,
|
|
14
|
+
l as useChaiAuth,
|
|
15
|
+
C as useChaiCurrentPage,
|
|
16
|
+
c as useChaiFetch,
|
|
18
17
|
m as useChaiUserInfo,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
d as useClearAll,
|
|
19
|
+
p as useFallbackLang,
|
|
20
|
+
f as useFetch,
|
|
21
|
+
L as useGotoPage,
|
|
22
|
+
b as useLanguagePages,
|
|
24
23
|
A as usePageTypes,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
F as useReloadPage,
|
|
25
|
+
I as useUpdateActivePageMetadata,
|
|
26
|
+
S as useUserPermissions,
|
|
27
|
+
k as useWebsitePages,
|
|
29
28
|
v as useWebsiteSetting
|
|
30
29
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk/ui"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-DSUpSpeI.cjs"),B=require("@tanstack/react-query");function H(t,r){const o=O.useApiUrl(),n=O.useFetch(),f=p.startsWith(t.uid,"draft:")||p.startsWith(r.uid,"live:");return B.useQuery({queryKey:["revision-comparison",t.uid,r.uid],queryFn:async()=>{if(!t.uid||!r.uid)throw new Error("Both revision IDs are required for comparison");const l=u=>u==="draft"||u==="live"?u:"revision",s=u=>p.replace(u.uid,`${u.label}:`,"");return await n(o,{action:O.ACTIONS.GET_COMPARE_DATA,data:{versions:{version1:{type:l(t.label),id:s(t)},version2:{type:l(r.label),id:s(r)}}}})},enabled:!!t.uid&&!!r.uid,staleTime:f?0:1/0})}const K=({version:t})=>{const r=t==null?void 0:t.item,{data:o}=O.useChaiUserInfo(r==null?void 0:r.currentEditor),n=t.label==="live",f=t.label==="draft";return e.jsxs("span",{className:`flex items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${n?"border-green-500/30":f?"border-amber-500/30":"border-purple-500/30"}`,children:[e.jsx("div",{className:"h-full items-center rounded px-1.5 py-0.5 font-medium capitalize"+(n?" bg-green-500 text-green-50":f?" bg-amber-500 text-amber-50":" bg-purple-500 text-purple-50"),children:t.label}),e.jsxs("div",{className:"py-1 text-xs font-light leading-none text-gray-800",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-light opacity-90",children:f?"Currently editing":"Published by"}),!f&&e.jsx("span",{className:"pl-1 font-medium",children:(o==null?void 0:o.name)||"Unknown"})]}),e.jsx("div",{className:"text-[10px] leading-tight",children:z.formatDate(r.createdAt,"dd MMM yyyy, h:mm a")})]})]})},L=({version:t})=>e.jsx(K,{version:t});function V(t,r,o="data.json"){const n=JSON.stringify(t,null,2),f=JSON.stringify(r,null,2),l=n.split(`
|
|
2
|
+
`),s=f.split(`
|
|
3
|
+
`);let d=`--- a/${o}
|
|
4
|
+
`;d+=`+++ b/${o}
|
|
5
|
+
`;const u=[];let c=0,m=0;for(;c<l.length||m<s.length;){const g=l[c]||"",v=s[m]||"";if(g===v)u.push(` ${g}`),c++,m++;else{let h=-1,j=-1;for(let a=c+1;a<l.length;a++)if(s[m]===l[a]){h=a;break}for(let a=m+1;a<s.length;a++)if(l[c]===s[a]){j=a;break}if(h!==-1&&(j===-1||h-c<=j-m)){for(let a=c;a<h;a++)u.push(`-${l[a]}`);c=h}else if(j!==-1){for(let a=m;a<j;a++)u.push(`+${s[a]}`);m=j}else g&&u.push(`-${g}`),v&&u.push(`+${v}`),c++,m++}}const w=l.length,J=s.length;return d+=`@@ -1,${w} +1,${J} @@
|
|
6
|
+
`,d+=u.join(`
|
|
7
|
+
`)+`
|
|
8
|
+
`,d}function T(t,r=!0,o=!1){if(p.isString(t)){const n=p.trim(t);if(p.startsWith(n,"{")||p.startsWith(n,"[")||r&&(n==="true"||n==="false"||n==="null"||/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(n)))try{const l=JSON.parse(n);return T(l,r,o)}catch{if(o)throw new Error(`Invalid JSON string: ${n}`);return{}}return t}return p.isArray(t)?p.map(t,n=>T(n,r,o)):p.isPlainObject(t)?p.mapValues(t,n=>T(n,r,o)):t}const U=t=>{switch(t){case"blocks":return"Blocks";case"seo":return"SEO";case"tracking":return"Tracking";default:return t}},W=(t,r)=>{if(!t||!r)return[{key:"blocks",label:"Blocks"}];const o=Object.keys(t),n=Object.keys(r);return o.filter(s=>n.includes(s)).map(s=>({key:s,label:U(s)})).filter(s=>s.key.length>0)},_=(t,r=3)=>{const o=new Set;t.map((s,d)=>({change:s,index:d})).filter(({change:s})=>s.type!=="normal").map(({index:s})=>s).forEach(s=>{const d=Math.max(0,s-r),u=Math.min(t.length-1,s+r);for(let c=d;c<=u;c++)o.add(c)});const f=[];let l=-1;return t.forEach((s,d)=>{if(o.has(d)){if(l!==-1&&d-l>1){const u=t[l].lineNumber!=null?t[l].lineNumber+1:l+2,c=t[d].lineNumber!=null?t[d].lineNumber-1:d;f.push({content:e.jsx(x.Badge,{className:"pointer-events-none w-60 -translate-x-1/2 cursor-default border-none bg-transparent py-1 shadow-none",children:e.jsxs("span",{className:"rounded border border-border bg-muted px-3 py-1 text-xs font-light leading-none text-muted-foreground",children:["No changes from ",u," to ",c," line"]})})})}f.push(s),l=d}}),f};function P({open:t,compare:r,onOpenChange:o}){const n=r[0],f=r[1],[l,s]=b.useState(null),[d,u]=b.useState("split"),[c,m]=b.useState(!1),[w,J]=b.useState(!0),[g,v]=b.useState("blocks"),{data:h,isLoading:j}=H(n,f),{leftData:a,rightData:k,options:F}=b.useMemo(()=>{var y,R;const i=(y=h==null?void 0:h.version1)==null?void 0:y[g],C=(R=h==null?void 0:h.version2)==null?void 0:R[g],S=T(i),D=T(C),q=W(h==null?void 0:h.version1,h==null?void 0:h.version2);return{leftData:S,rightData:D,options:q}},[h,g]),$=b.useMemo(()=>!a||!k?"":V(a,k),[a,k]),A=b.useMemo(()=>{if(!$)return[];try{return M.parseDiff($)}catch(i){return console.error("Failed to parse diff:",i),[]}},[$]),I=async(i,C)=>{try{await navigator.clipboard.writeText(JSON.stringify(i,null,2)),s(C),setTimeout(()=>s(null),2e3)}catch(S){console.error("Failed to copy:",S)}},E=i=>JSON.stringify(i,null,2);return e.jsx(x.Dialog,{open:t,onOpenChange:o,children:e.jsxs(x.DialogContent,{className:"flex h-[90vh] w-[95vw] max-w-[1900px] flex-col p-6",children:[e.jsx(x.DialogHeader,{className:"pb-4 pt-0",children:e.jsxs(x.DialogTitle,{className:"flex items-center justify-between gap-2 leading-none",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N.FileJson,{className:"h-5 w-5"}),"Compare","",F.map(i=>e.jsx("div",{className:`cursor-pointer rounded-full border px-2.5 py-1 text-xs leading-none ${g===i.key?"border-blue-500 bg-blue-500 text-white":"border-gray-600 text-gray-600 hover:bg-gray-200"}`,onClick:()=>v(i.key),children:i.label},i.key))]}),e.jsx("div",{className:"flex flex-1 items-center justify-end pr-8",children:e.jsxs("div",{className:"flex w-max items-center justify-end gap-2 rounded-md border px-1.5 py-1",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx(x.Switch,{disabled:c,checked:c?!0:d==="split",onCheckedChange:i=>u(i?"split":"unified")}),e.jsx("label",{className:"text-sm",children:"Split View"})]}),e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx(x.Switch,{checked:c,onCheckedChange:i=>m(i)}),e.jsx("label",{className:"text-sm",children:"Show Raw Data"})]}),e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx(x.Switch,{checked:w,onCheckedChange:i=>J(i)}),e.jsx("label",{className:"text-sm",children:"Hide Common Data"})]})]})})]})}),j?e.jsx("div",{className:"flex h-full w-full items-center justify-center",children:e.jsx(N.Loader,{className:"h-6 w-6 animate-spin text-primary"})}):e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsxs("div",{className:"relative min-h-0 flex-1",children:[e.jsxs("div",{className:"absolute -top-5 z-50 mt-0.5 flex w-full items-center justify-between gap-2",children:[e.jsx("div",{className:"flex w-1/2 items-center justify-center gap-2",children:e.jsx(L,{version:n})}),e.jsx("div",{className:"flex w-1/2 items-center justify-center gap-2",children:e.jsx(L,{version:f})})]}),c?e.jsxs("div",{className:"grid h-full grid-cols-2 gap-3 rounded-lg border",children:[e.jsxs("div",{className:"relative flex min-h-0 flex-col border-r",children:[e.jsx("div",{className:"absolute -top-4 right-4 z-50",children:e.jsxs(x.Button,{variant:"outline",size:"sm",onClick:()=>I(a,"left"),children:[l==="left"?e.jsx(N.Check,{className:"text-green-500"}):e.jsx(N.Copy,{}),"Copy"]})}),e.jsx(x.ScrollArea,{className:"flex-1 rounded-lg bg-slate-50 p-3 dark:bg-slate-900",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:E(a)})})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-col",children:[e.jsx("div",{className:"absolute -top-4 right-4 z-50",children:e.jsxs(x.Button,{variant:"outline",size:"sm",onClick:()=>I(k,"right"),children:[l==="right"?e.jsx(N.Check,{className:"text-green-500"}):e.jsx(N.Copy,{}),"Copy"]})}),e.jsx(x.ScrollArea,{className:"flex-1 rounded-lg bg-slate-50 p-3 dark:bg-slate-900",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:E(k)})})]})]}):e.jsx(x.ScrollArea,{className:"h-full overflow-y-auto rounded-lg border bg-slate-50 text-xs dark:bg-slate-900",children:A.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(N.FileJson,{className:"mx-auto mb-2 h-8 w-8 opacity-50"}),e.jsx("p",{children:"No differences found or unable to parse diff"})]})}):e.jsx("div",{children:A.map((i,C)=>e.jsx("div",{className:"relative mb-4",children:e.jsx(M.Diff,{viewType:d,diffType:i.type,hunks:i.hunks,className:"rounded-lg text-xs",children:S=>S.map((D,q)=>{const y=w?_(D.changes):D.changes;return(y==null?void 0:y.length)===0?e.jsx("div",{className:"absolute h-full w-full border-l pt-64 text-center font-sans text-sm",children:e.jsx("span",{children:"No difference found"})}):e.jsx(M.Hunk,{hunk:{...D,changes:y}},q)})},w?"hide-common-data":"show-common-data")},C))})})]})})]})})}exports.default=P;
|