@chaibuilder/pages 0.15.3 → 0.15.6
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-o6FgGSqg.cjs → 2AITGKQY-BnzAO102.cjs} +1 -1
- package/dist/{2AITGKQY-DhC0sF1x.js → 2AITGKQY-tXLat8E2.js} +2 -2
- package/dist/{NCMVHL6D-D7HU3akD.js → NCMVHL6D-BwDANa-N.js} +2 -2
- package/dist/{NCMVHL6D-BPM6RHYa.cjs → NCMVHL6D-DooF4Fqf.cjs} +1 -1
- package/dist/{ZDWCUMSJ-Cr1v3giV.js → ZDWCUMSJ-DWeYRRkj.js} +1 -1
- package/dist/{ZDWCUMSJ-NVCxv9uE.cjs → ZDWCUMSJ-DiH9kc7o.cjs} +1 -1
- package/dist/add-new-language-page-BCUrfgTy.cjs +1 -0
- package/dist/add-new-language-page-DZhjVBBf.js +401 -0
- package/dist/add-new-page-DWHANcUx.cjs +1 -0
- package/dist/add-new-page-DYuuentN.js +31 -0
- package/dist/delete-page-1dSWwUBg.js +40 -0
- package/dist/delete-page-m-Cuz7rG.cjs +1 -0
- package/dist/digital-asset-manager-BWZlrwFf.js +913 -0
- package/dist/digital-asset-manager-By_JTIbb.cjs +1 -0
- package/dist/duplicate-page-Dzs8ya8l.cjs +1 -0
- package/dist/duplicate-page-fUuBTAs7.js +133 -0
- package/dist/{dynamic-page-selector-CF9nb6i_.cjs → dynamic-page-selector-CwhL4z6F.cjs} +1 -1
- package/dist/{dynamic-page-selector-DTk4oull.js → dynamic-page-selector-X2qgdiNQ.js} +1 -1
- package/dist/image-editor-CeSSNbFY.js +108 -0
- package/dist/image-editor-CnDnY97s.cjs +1 -0
- package/dist/index-0cMGDekp.cjs +5 -0
- package/dist/{index-BuXZJnGo.js → index-Bk8tPO5R.js} +1605 -1571
- package/dist/index.cjs +1 -1
- package/dist/index.js +8 -8
- package/dist/{json-diff-viewer-zBoPBSd3.cjs → json-diff-viewer-Cfa9BjZ6.cjs} +1 -1
- package/dist/{json-diff-viewer-oyxMD3Hc.js → json-diff-viewer-Cm84g19X.js} +1 -1
- package/dist/lang-panel-CaSKOJ8G.js +225 -0
- package/dist/lang-panel-CkSfJqr8.cjs +1 -0
- package/dist/mark-as-template-Ci82hbOm.cjs +1 -0
- package/dist/mark-as-template-CwsW86Zv.js +153 -0
- package/dist/no-language-page-content-CPt4aPy9.cjs +1 -0
- package/dist/no-language-page-content-DDz81nqg.js +42 -0
- package/dist/{page-creator-BG2hc82u.cjs → page-creator-Cd2LrG4u.cjs} +1 -1
- package/dist/{page-creator-y6kl3nw5.js → page-creator-Dr566_Yf.js} +2 -2
- package/dist/page-lock-request-Bw_Wye1t.cjs +1 -0
- package/dist/page-lock-request-ECxkQMdS.js +75 -0
- package/dist/page-locked-by-dialog-AbutJT_V.cjs +1 -0
- package/dist/page-locked-by-dialog-CnkVUpjt.js +68 -0
- package/dist/page-manager-new-DLMvOata.cjs +1 -0
- package/dist/page-manager-new-DkqNLZ5C.js +354 -0
- package/dist/page-manager-search-and-filter-B98nz9xS.js +201 -0
- package/dist/page-manager-search-and-filter-CfEfWFeo.cjs +1 -0
- package/dist/{page-revisions-content-BaTqBnko.js → page-revisions-content-CBQPYFZI.js} +18 -18
- package/dist/{page-revisions-content-Tb3T6zvU.cjs → page-revisions-content-D12GEp8C.cjs} +1 -1
- package/dist/{publish-pages-content-C9CgEWo0.js → publish-pages-content-BF5yMo_L.js} +6 -6
- package/dist/{publish-pages-content-BGkEZ3GK.cjs → publish-pages-content-LNCr9tKv.cjs} +1 -1
- package/dist/{save-to-lib-DNK4GPNw.cjs → save-to-lib-C1B6tWEF.cjs} +1 -1
- package/dist/{save-to-lib-DGtyTG6H.js → save-to-lib-SpilaoOL.js} +1 -1
- package/dist/{seo-panel-CrK7z4bR.cjs → seo-panel-DkgkJUT6.cjs} +1 -1
- package/dist/{seo-panel-DESVAQM5.js → seo-panel-sbYoo746.js} +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +96 -96
- package/dist/shared-json-ld-CEUgLAev.cjs +1 -0
- package/dist/shared-json-ld-D_YyVPk3.js +565 -0
- package/dist/{slug-input-DMYhARDW.cjs → slug-input-Cqj9EBju.cjs} +1 -1
- package/dist/{slug-input-DfAsMPg8.js → slug-input-Df-BG6xl.js} +1 -1
- package/dist/theme-panel-footer-B6leVWSV.js +25 -0
- package/dist/theme-panel-footer-Ca1UF5DA.cjs +1 -0
- package/dist/unmark-as-template-BOE-nKOb.cjs +1 -0
- package/dist/unmark-as-template-Cho9B4RN.js +39 -0
- package/dist/unpublish-page-BcxxZ8pr.cjs +1 -0
- package/dist/unpublish-page-Dr4qbwUx.js +27 -0
- package/dist/{web-preview-DNgPjdgZ.js → web-preview-Cq82TNaS.js} +1 -1
- package/dist/{web-preview-BcULgiw_.cjs → web-preview-ued-fdxs.cjs} +1 -1
- package/package.json +3 -4
- package/dist/add-new-language-page-8q4Ku3eg.js +0 -390
- package/dist/add-new-language-page-D3PSLiUv.cjs +0 -1
- package/dist/add-new-page-BpvpSM4X.js +0 -30
- package/dist/add-new-page-YpzILOYq.cjs +0 -1
- package/dist/delete-page-CXRJjJ4o.js +0 -38
- package/dist/delete-page-w64MO7db.cjs +0 -1
- package/dist/digital-asset-manager-B2m5T22s.js +0 -1001
- package/dist/digital-asset-manager-BGyKKd_6.cjs +0 -1
- package/dist/duplicate-page-CSQs2MOp.js +0 -120
- package/dist/duplicate-page-DB_c7V2t.cjs +0 -1
- package/dist/image-editor-D9MPdtxC.js +0 -107
- package/dist/image-editor-Da6lrqkL.cjs +0 -1
- package/dist/index-Cds1vIhw.cjs +0 -5
- package/dist/lang-panel-B_HcsPPo.js +0 -218
- package/dist/lang-panel-D2YUMeJZ.cjs +0 -1
- package/dist/mark-as-template-C4wH4UKf.cjs +0 -1
- package/dist/mark-as-template-CPEPYXg7.js +0 -146
- package/dist/no-language-page-content-CVyOpT9h.js +0 -35
- package/dist/no-language-page-content-ECt0SxFX.cjs +0 -1
- package/dist/page-lock-request-DC62b588.js +0 -64
- package/dist/page-lock-request-fGZbOFTp.cjs +0 -1
- package/dist/page-locked-by-dialog-BIC-c0Jl.cjs +0 -1
- package/dist/page-locked-by-dialog-D-vXaoga.js +0 -63
- package/dist/page-manager-new-CUfjlMed.cjs +0 -1
- package/dist/page-manager-new-Cto2r7Va.js +0 -354
- package/dist/page-manager-search-and-filter-sVnGlF46.js +0 -197
- package/dist/page-manager-search-and-filter-z2b4sgvb.cjs +0 -1
- package/dist/shared-json-ld-BMfQzOWc.js +0 -650
- package/dist/shared-json-ld-_ozYsSHn.cjs +0 -1
- package/dist/theme-panel-footer-Bj2yHtxO.cjs +0 -1
- package/dist/theme-panel-footer-RrxiDGoD.js +0 -25
- package/dist/unmark-as-template-BjetSrYF.js +0 -38
- package/dist/unmark-as-template-C8hTjRVk.cjs +0 -1
- package/dist/unpublish-page-BTPEVAkv.js +0 -26
- package/dist/unpublish-page-gtGfNOAq.cjs +0 -1
package/dist/index-Cds1vIhw.cjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";var Vn=Object.defineProperty;var ms=e=>{throw TypeError(e)};var Qn=(e,t,s)=>t in e?Vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var ge=(e,t,s)=>Qn(e,typeof t!="symbol"?t+"":t,s),Es=(e,t,s)=>t.has(e)||ms("Cannot "+s);var w=(e,t,s)=>(Es(e,t,"read from private field"),s?s.call(e):t.get(e)),R=(e,t,s)=>t.has(e)?ms("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),k=(e,t,s,n)=>(Es(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"),H=require("jotai"),T=require("@tanstack/react-query"),C=require("@chaibuilder/sdk"),F=require("sonner"),m=require("@chaibuilder/sdk/ui"),v=require("lucide-react"),Ns=require("@chaibuilder/runtime"),zn=require("@chaibuilder/sdk/web-blocks");function $n(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 z=$n(h),y={GET_GLOBAL_JSONLD_ITEMS:"GET_GLOBAL_JSONLD_ITEMS",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",ADD_GLOBAL_SCHEMA:"ADD_GLOBAL_SCHEMA",UPDATE_GLOBAL_SCHEMA:"UPDATE_GLOBAL_SCHEMA",DELETE_GLOBAL_SCHEMA:"DELETE_GLOBAL_SCHEMA",TOGGLE_PAGE_GLOBAL_SCHEMA:"TOGGLE_PAGE_GLOBAL_SCHEMA",APPLY_SCHEMA_TO_ALL_PAGES:"APPLY_SCHEMA_TO_ALL_PAGES",REMOVE_SCHEMA_FROM_ALL_PAGES:"REMOVE_SCHEMA_FROM_ALL_PAGES",UPLOAD_ASSET:"UPLOAD_ASSET",DELETE_ASSET:"DELETE_ASSET",UPDATE_ASSET:"UPDATE_ASSET",GET_ASSETS:"GET_ASSETS",GET_ASSET:"GET_ASSET"},Wn=H.atom({}),Dt=()=>H.useAtom(Wn),ee=(e,t)=>{const[s]=Dt();return h.useMemo(()=>p.get(s,e,t),[s,e,t])},j=()=>ee("apiUrl","/chai/api"),Gs=()=>ee("usersApiUrl","/chai/users"),Yn=()=>ee("assetsApiUrl","/chai/assets"),Jn=()=>ee("websocket",null),Xn=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)}),L=()=>{const e=ee("onLogout"),t=ee("getAccessToken");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 Xn(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 te(){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 ye=e=>{const t=j(),[s]=te(),n=e??s.get("page"),r=L();return T.useQuery({queryKey:[y.GET_LANGUAGE_PAGES,n],staleTime:1/0,gcTime:0,placeholderData:[],queryFn:async()=>{if(!n)return null;const a=await r(t,{action:y.GET_LANGUAGE_PAGES,data:{id:n}});return p.reverse(p.sortBy(a,"primaryPage"))},enabled:!!n})},Ae=()=>{const e=j(),t=L();return T.useQuery({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS],staleTime:5*60*1e3,placeholderData:{languages:[],theme:{fontFamily:"",borderRadius:"",colors:{}},appKey:"",fallbackLang:""},queryFn:async()=>t(e,{action:y.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})},ts=e=>{const{fallbackLang:t}=C.useLanguages(),{data:s}=Ae(),{data:n,isFetching:r}=ye(),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 Ds{constructor(t,s,n,r){ge(this,"channelId");ge(this,"websocket");ge(this,"channel",null);ge(this,"userId",null);ge(this,"clientId",null);ge(this,"pageId",null);ge(this,"callback");var a,i,l,c,d,f;this.userId=n,this.websocket=t,this.clientId=this.getClientId(),this.channelId=`WEBSITE:${s}`,this.callback=r,this.channel=this.websocket.channel(this.channelId,{config:{presence:{key:this.clientId}}}),(f=(d=(c=(l=(i=(a=this.channel)==null?void 0:a.on("presence",{event:"sync"},u=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",u)}))==null?void 0:i.on("presence",{event:"leave"},u=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",u)}))==null?void 0:l.on("presence",{event:"join"},u=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",u)}))==null?void 0:c.on("broadcast",{event:"TAKE_OVER_REQUESTED"},({payload:u})=>this.onReceiveEvent("TAKE_OVER_REQUESTED",u)))==null?void 0:d.on("broadcast",{event:"TAKE_OVER_REQUEST_ACCEPTED"},({payload:u})=>this.onReceiveEvent("TAKE_OVER_REQUEST_ACCEPTED",u)))==null||f.on("broadcast",{event:"TAKE_OVER_REQUEST_REJECTED"},({payload:u})=>this.onReceiveEvent("TAKE_OVER_REQUEST_REJECTED",u)).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 Zn=H.atom(null),ks=()=>H.useAtom(Zn),ss=()=>{const[e]=ks();return(e==null?void 0:e.slug)||""};function er(e,t){const[s,n]=h.useState(e);return h.useEffect(()=>{const r=setTimeout(()=>n(e),t);return()=>clearTimeout(r)},[e,t]),s}const tr=({query:e,uuid:t})=>{const{selectedLang:s,fallbackLang:n}=C.useLanguages(),{data:r}=Z(),a=r==null?void 0:r.pageType,i=j(),l=L(),{data:c,isFetching:d}=T.useQuery({queryKey:[y.GET_DYNAMIC_PAGES,e,a,t],staleTime:60*60*1e3,placeholderData:[],queryFn:async()=>await l(i,{action:y.GET_DYNAMIC_PAGES,data:{query:e,pageType:a,uuid:t}})||[],enabled:!!a}),f=h.useMemo(()=>s===""?c.filter(u=>u.lang===""||u.lang===n):c.filter(u=>u.lang===s),[s,n,c]);return{allLangPages:c,data:f,isFetching:d}},js=()=>{const{selectedLang:e,fallbackLang:t}=C.useLanguages(),[s,n]=ks(),[r,a]=h.useState(""),i=er(r,500),{allLangPages:l,data:c,isFetching:d}=tr({query:i}),f=h.useCallback(E=>n(E),[n]),u=h.useCallback(E=>a(E),[a]),g=h.useCallback(()=>{if(!s)return;const E=!(s!=null&&s.primaryPage),S=e.length===0,P=E?s==null?void 0:s.id:s==null?void 0:s.primaryPage,A=l.filter(x=>(x==null?void 0:x.primaryPage)===P||x.id===P).find(x=>S?x.lang===e||x.lang===t:x.lang===e);n(A||s)},[s,e,l,n,t]);return{isFetching:d,dynamicPage:s,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:f,updateSearchQuery:u,onChangeLanguage:g}},sr=H.atom({lastSaved:void 0}),kt=()=>H.useAtom(sr),Z=()=>{const[e]=te(),t=e.get("page"),{data:s,isFetching:n}=ye();return{data:h.useMemo(()=>({...p.find(s,{id:t})||{}}),[s,t]),isFetching:n}},ue=()=>{const[e]=te(),t=e.get("lang")??"",{data:s,isFetching:n}=ye();return{data:h.useMemo(()=>p.find(s,{lang:t})||{},[s,t]),isFetching:n}},nr=H.atom({}),rr=()=>H.useAtom(nr),ar=()=>{const{data:e}=ue(),t=ss(),s=ee("getLiveUrl",p.noop),n=e==null?void 0:e.slug,r=s(n||"/");return t?r+t:r},He=()=>{const e=ee("currentUser"),t=ee("onLogout");return{isLoggedIn:!!e,user:e,logout:t}},Os=e=>{const t=Gs(),s=L();return T.useQuery({queryKey:[y.GET_CHAI_USER,e],queryFn:async()=>{const r=await s(t,{action:y.GET_CHAI_USER,data:{userId:e}});return{...r,name:r.name||r.email}},enabled:!p.isEmpty(e),staleTime:"static"})},ir=H.atom({status:"checking",requestedBy:"",isTakeOverRequested:!1,requestingClientId:"",isActiveInOtherTab:!1}),or=H.atom(""),lr=H.atom(null),ns=H.atom({}),cr=()=>H.useAtom(ns),Se=()=>{const[e]=te(),t=e.get("page"),[s,n]=H.useAtom(ir),[r,a]=H.useAtom(lr),[i,l]=H.useAtom(or),[c]=H.useAtom(ns);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"}},ur=()=>{const e=Jn(),{data:t}=Z(),{user:s}=He(),n=t==null?void 0:t.id,{data:r}=Ae(),{pageLock:a,setPageLock:i,setLockingStatus:l,realtimeInstance:c,setRealtimeInstance:d}=Se(),[,f]=H.useAtom(ns),u=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 S=async(_,A)=>{var x,D;switch(_){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(((x=g==null?void 0:g.current)==null?void 0:x.status)==="editing")return;((D=g==null?void 0:g.current)==null?void 0:D.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"),F.toast.success("Your Page Take Over Request Accepted",{position:"top-center"})),i({...g==null?void 0:g.current,status:"editing",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}},P=new Ds(e,r==null?void 0:r.appKey,s==null?void 0:s.id,S);d(P)}},[d,e,r==null?void 0:r.appKey]),h.useEffect(()=>{g.current=a},[a]),h.useEffect(()=>{if(!(!c||!n||!(s!=null&&s.id)||u.current))return u.current=!0,c==null||c.joinPage(n),()=>{c&&u.current&&(u.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},Rs=()=>{const{data:e}=Z(),{user:t}=He(),s=e==null?void 0:e.id,{pageLock:n,setPageLock:r,realtimeInstance:a}=Se(),{savePageAsync:i}=C.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]),d=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:d,requestTakeOver:l}},dr=h.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-content-ECt0SxFX.cjs"))),fr=h.lazy(()=>Promise.resolve().then(()=>require("./page-locked-by-dialog-BIC-c0Jl.cjs"))),Ft=h.lazy(()=>Promise.resolve().then(()=>require("./page-lock-request-fGZbOFTp.cjs"))),hr=({isFetchingPage:e})=>{const{pageLock:t,requestTakeOver:s}=Rs(),{currentEditor:n,lockingStatus:r,setLockingStatus:a,realtimePageLockEnabled:i}=Se(),{data:l,isFetching:c}=Os(n),[d]=te(),f=d.get("page"),[u]=kt(),g=T.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(Ft,{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(Ft,{lockingStatus:r,onContinue:()=>{g.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),a("")}})}):null:t!=null&&t.isActiveInOtherTab?o.jsx(h.Suspense,{children:o.jsx(Ft,{lockingStatus:"page_is_active_in_other_tab",onContinue:s})}):o.jsx(h.Suspense,{children:o.jsx(fr,{...l,isFetchingUserInfo:c,name:(l==null?void 0:l.name)||"Unknown User",email:(l==null?void 0:l.email)||"",lastSaved:(u==null?void 0:u.lastSaved)||"",onTakeOver:E,realtimePageLockEnabled:i,isRequestRejected:r==="take_over_request_rejected"})})},gr=()=>{const[e]=te(),t=e.get("lang");return ts(t)?null:o.jsx(h.Suspense,{children:o.jsx(dr,{})})},$e={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 rs(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 jt=H.atom(null),Ot=()=>{const{data:e}=Ae();return h.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},as=()=>{const e=L(),t=j();return T.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:s=>s||[]})},mr=e=>{const t=L(),s=j(),n=Ot();return T.useQuery({queryKey:[y.GET_WEBSITE_PAGES,e,n],staleTime:1e3*60*5,enabled:!!e,queryFn:async()=>{if(n===e)return{};const r=await t(s,{action:y.GET_WEBSITE_PAGES,data:{lang:e}})||[];return p.keyBy(p.map(r,a=>({...a,lang:e})),"primaryPage")},placeholderData:r=>r||{}})},Er=h.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-CUfjlMed.cjs"))),Us=({children:e})=>{const[t,s]=te(),n=t.get("page"),{data:r,isFetching:a}=Z(),{data:i,isFetching:l}=as(),[c,d]=h.useState(!1),[f,u]=h.useState(!0),{savePage:g}=C.useSavePage(),E=!!n&&!p.isEmpty(r),S=h.useMemo(()=>{if(!i||l)return!1;const x=i.find(D=>D.slug==="/");return x==null?void 0:x.id},[i,l]);h.useEffect(()=>{if(l||!S||i.some(q=>q.id===n))return;const D=new URLSearchParams({page:S});rs(D,s),!l&&i&&u(!1)},[n,l,i,S,s]);const P=!f&&!n,_=!f&&!a&&p.isEmpty(r),A=c||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(),d(!0)},children:e||o.jsx(m.Button,{variant:"outline",className:"flex w-full items-center space-x-2 py-1",children:o.jsx(v.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:x=>!x&&E&&d(!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(v.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(Er,{close:()=>d(!1)})})})]})})]})},pr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-D3PSLiUv.cjs"))),yr=()=>{const e=ee("topLeftCorner",null);return e?o.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:h.createElement(e,{})}):null},Ms=({showAdd:e=!0,variant:t="ghost"})=>{const{fallbackLang:s,languages:n,selectedLang:r,setSelectedLang:a}=C.useLanguages(),i=p.isEmpty(r)?s:r,[,l]=te(),{isLocked:c}=Se();h.useEffect(()=>{const _=new URLSearchParams(window.location.search),A=_.get("lang");A&&(n.includes(A)?a(A):(_.delete("lang"),l(_),a("")))},[n,l,a]);const[,d]=H.useAtom(jt),{data:f}=Z(),{data:u}=Ae(),{data:g}=ye(),E=h.useMemo(()=>{const _=p.compact(p.map(p.get(u,"languages"),A=>{const x=p.find(g,{lang:A});return{key:A,value:p.get($e,A,A),isLangPageAdded:!!x}})).filter(Boolean);return[{key:s,value:p.get($e,s),isLangPageAdded:!0},..._]},[s,g,u]),S=_=>{if(document.querySelector('[data-panel-id="seo"]')){const x=new CustomEvent("seo-language-switch-check",{detail:{fromLang:i,toLang:_,switchHandler:()=>P(_)}});window.dispatchEvent(x);return}P(_)},P=_=>{a(_);const A=new URLSearchParams(window.location.search);_===s?A.delete("lang"):A.set("lang",_),rs(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(v.Languages,{className:"h-4 w-4"}),p.get($e,i,i),o.jsx(v.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(v.Languages,{className:"h-4 w-4"}),p.get($e,i,i),o.jsx(v.ChevronDown,{className:"h-4 w-4"})]})}),o.jsxs(m.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(E.filter(_=>_.isLangPageAdded),_=>o.jsxs(m.DropdownMenuItem,{className:C.mergeClasses("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",_.key===i&&"!bg-gray-200 text-gray-700"),onClick:()=>S(_.key),children:[o.jsx("div",{className:"text-slate-600",children:_.value}),_.key===s&&o.jsxs("small",{className:"flex items-center gap-x-1 text-[9px] leading-none text-orange-500",children:[o.jsx(v.Star,{fill:"orange",className:"h-2 w-2"}),"Primary"]})]},_.value)),e&&!p.isEmpty(E.filter(_=>!_.isLangPageAdded))&&o.jsxs(o.Fragment,{children:[o.jsx(m.Separator,{}),o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:()=>{f&&d({edit:!1,primaryPage:f.id})},className:"text-xs font-normal duration-200 hover:bg-slate-300 hover:text-slate-800",children:[o.jsx(v.Plus,{className:"mr-1 h-3 w-3"})," Add Langauge"]})]})]})]})})};function Ar(){const[e,t]=H.useAtom(jt);return o.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[o.jsx(yr,{}),o.jsx(Us,{}),e&&o.jsx(h.Suspense,{children:o.jsx(pr,{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)})})]})}function Sr(){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 Tr=z.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-Tb3T6zvU.cjs")));function Pr(){const[e,t]=z.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(v.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(Sr,{}),children:o.jsx(Tr,{isOpen:e})})})]}),o.jsx(m.TooltipContent,{side:"bottom",children:o.jsx("p",{children:"Revision history"})})]})})}const Tt=({permission:e,permissions:t,children:s,fallback:n=null})=>{const{hasPermission:r}=C.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?n:s},Y={TOGGLE_PREVIEW:"Toggle Preview",OPEN_PREVIEW_IN_NEW_TAB:"Open preview in new tab",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."},_r={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},de=()=>{const e=j(),t=L();return T.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},Bs=e=>{const{data:t}=de();return h.useMemo(()=>t==null?void 0:t.find(s=>s.key===e),[t,e])},xr=()=>{const e=j(),t=L();return T.useMutation({mutationFn:async({pageType:s,query:n})=>{try{return t(e,{action:y.SEARCH_PAGES,data:{pageType:s,query:Array.isArray(n)&&n.length>0?n[0]:n}})||[]}catch(r){return console.error(r),[]}}})},wr=()=>{const e=j(),t=T.useQueryClient(),s=L(),{data:n}=de();return T.useMutation({mutationFn:async r=>await s(e,{action:y.CREATE_PAGE,data:r}),onSuccess:(r,a)=>{var l;a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES,a==null?void 0:a.lang]})):t.invalidateQueries({queryKey:[y.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";F.toast.success(i)},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});F.toast.error(`Failed to add new ${i!=null&&i.hasSlug?"page":i.name}.`,{description:p.get(_r,r.message,r.message)})}})},vr=()=>{const e=j(),t=T.useQueryClient(),s=L(),{data:n}=ue(),{data:r}=de();return T.useMutation({mutationFn:async a=>await s(e,{action:y.UPDATE_PAGE,data:a}),onSuccess:(a,i)=>{(n==null?void 0:n.id)===(i==null?void 0:i.id)&&t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]}),i&&(i!=null&&i.primaryPage||i!=null&&i.seo)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(a,i)=>{const l=p.find(r,{key:i.pageType});F.toast.error(`Failed to update ${l!=null&&l.hasSlug?"page":l.name}.`,{description:a.message})}})},br=()=>{const e=j(),t=T.useQueryClient(),s=L(),{data:n}=de();return T.useMutation({mutationFn:async r=>s(e,{action:y.DELETE_PAGE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{if(r.code==="PAGE_LOCKED"){F.toast.error("Delete not allowed",{description:"Page is currently being edited by another user."});return}a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});F.toast.error(`Failed to delete ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},Cr=()=>{const e=j(),t=T.useQueryClient(),s=L(),{data:n}=de();return T.useMutation({mutationFn:async r=>s(e,{action:y.TAKE_OFFLINE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const i=p.find(n,{key:a.pageType});F.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});F.toast.error(`Failed to take offline ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},is=()=>{const e=j(),t=L(),s=T.useQueryClient(),{data:n}=Z(),{savePageAsync:r}=C.useSavePage();return T.useMutation({mutationFn:async({ids:a})=>(await r(),t(e,{action:y.PUBLISH_CHANGES,data:{ids:a}})),onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_CHANGES]}),s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,n==null?void 0:n.id]})},onError:a=>{console.log("##",a),F.toast.error("Failed to publish pages.")}})},Ir=()=>{const e=j(),t=L(),s=T.useQueryClient();return T.useMutation({mutationFn:async n=>{var r;return t(e,{action:y.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:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page marked as template successfully.")},onError:()=>{F.toast.error("Failed to mark page as template.")}})},Lr=()=>{const e=j(),t=L(),s=T.useQueryClient();return T.useMutation({mutationFn:async n=>t(e,{action:y.UNMARK_AS_TEMPLATE,data:{id:n==null?void 0:n.id}}),onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page unmarked as template successfully.")},onError:()=>{F.toast.error("Failed to unmark page as template.")}})},Nr=()=>{const e=j(),t=L(),s=T.useQueryClient();return T.useMutation({mutationFn:async({id:n,slug:r})=>t(e,{action:y.CHANGE_SLUG,data:{id:n,slug:r}}),onSuccess:(n,{primaryPage:r})=>{F.toast.success(Y.SLUG_CHANGE_SUCCESS),r?s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,r]}):s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:()=>{F.toast.error("Failed to change slug")}})},Gr=h.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-BGkEZ3GK.cjs")));function Dr({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:s,isPending:n}=is();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(Gr,{onClose:t,isPending:n,publishPage:s})})})}const se={...C.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"},kr={particleCount:350,spread:120,origin:{y:.6},angle:90},jr={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},Or=async()=>{const{default:e}=await Promise.resolve().then(()=>require("./confetti.module-BuUnQuWk.cjs"));return e},Pt=e=>{let t=jr[e];t||(t={});const s={...kr,...t};Or().then(n=>n(s))};function Rt({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 Rr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-gtGfNOAq.cjs"))),Ur=h.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-Kctu12rQ.cjs"))),Mr=()=>{const{selectedLang:e,fallbackLang:t}=C.useLanguages(),s=ee("getPreviewUrl",async u=>u),[n,r]=h.useState(""),{data:a}=Z(),{data:i}=ye(),{data:l}=de(),c=h.useMemo(()=>{var u;return(u=i==null?void 0:i.find(g=>(g==null?void 0:g.lang)===e))==null?void 0:u.slug},[e,i]),d=h.useCallback(u=>{var g;return(g=p.find(l,{key:u}))==null?void 0:g.hasSlug},[l]),f=e===t?"":e;return h.useEffect(()=>{(async()=>{if(typeof s=="function"){const u=!d(a==null?void 0:a.pageType),g=await s(u?`${f!==""?f+"/":""}${a==null?void 0:a.id}`:c||"");r(g)}else r("")})()},[s,c,a==null?void 0:a.pageType,d,a==null?void 0:a.id,f]),o.jsx(o.Fragment,{children:o.jsx(Rt,{content:Y.OPEN_PREVIEW_IN_NEW_TAB,delayDuration:0,children:o.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:o.jsx(m.Button,{variant:"ghost",size:"sm",className:"gap-2",children:o.jsx(v.Play,{className:"h-4 w-4"})})})})})},Br=()=>{const[e,t]=C.useRightPanel();return o.jsxs(o.Fragment,{children:[o.jsx(Rt,{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(v.Palette,{className:"h-4 w-4"})})}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})},Fr=()=>{const[e,t]=h.useState(!1),{isLocked:s}=Se(),{savePageAsync:n,saveState:r}=C.useSavePage();h.useEffect(()=>{const d=f=>{r==="UNSAVED"&&(f.preventDefault(),f.returnValue=!1)};return r==="UNSAVED"&&window.addEventListener("beforeunload",d),()=>{window.removeEventListener("beforeunload",d)}},[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(v.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:Y.SAVING,buttonIcon:o.jsx(v.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:Y.SAVED,buttonIcon:o.jsx(v.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]})},qr=()=>{const{selectedLang:e}=C.useLanguages(),{data:t}=ue(),{data:s}=ye(),[n,r]=h.useState(!1),[a,i]=h.useState(!1),[l,c]=h.useState(null),{savePageAsync:d}=C.useSavePage(),[f,u]=h.useState(!1),{data:g}=Z(),{mutate:E,isPending:S}=is(),{needTranslations:P}=C.useSavePage(),_=P(),{buttonText:A,buttonClassName:x,isPublished:D}=h.useMemo(()=>{const U=g&&(g==null?void 0:g.online);return{buttonClassName:U?"hover:bg-green-600 bg-green-500":"",isPublished:U,buttonText:U?Y.PUBLISHED:Y.PUBLISH}},[g]),q=async()=>{if(_){u(!0);return}V()},V=()=>{const U=[t==null?void 0:t.id,t==null?void 0:t.primaryPage];E({ids:p.compact(U)},{onSuccess:()=>Pt("TOP_RIGHT")})},O=()=>{u(!1),V()},oe=async()=>{u(!1),await d()},le=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:q,disabled:S||!(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 ${x}`,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:D?o.jsx(v.Send,{className:"h-4 w-4"}):o.jsx(v.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:D?o.jsx(v.Rocket,{className:"h-4 w-4"}):o.jsx(v.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:S||!(g!=null&&g.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${x}`,children:o.jsx(v.ChevronDown,{className:"h-4 w-4"})})}),o.jsxs(m.DropdownMenuContent,{align:"end",className:"w-52",children:[o.jsxs(m.DropdownMenuItem,{disabled:S,className:"cursor-pointer text-xs",onClick:()=>E({ids:le},{onSuccess:()=>Pt("TOP_RIGHT")}),children:[Y.PUBLISH," with translation pages"]}),!D&&o.jsxs(m.DropdownMenuItem,{disabled:S,className:"cursor-pointer text-xs",onClick:()=>E({ids:[g==null?void 0:g.id]},{onSuccess:()=>Pt("TOP_RIGHT")}),children:[Y.PUBLISH," page"]}),o.jsxs(m.DropdownMenuItem,{onClick:()=>r(!0),className:"cursor-pointer text-xs",children:[Y.OPEN," publish menu"]}),D&&o.jsxs(m.DropdownMenuItem,{onClick:()=>c(t),className:"cursor-pointer text-xs",children:[Y.UNPUBLISH," page ",e?`(${p.upperCase(e)})`:""]})]})]})]}),o.jsx(Dr,{showModal:n,onClose:()=>r(!1)}),l&&o.jsx(h.Suspense,{children:o.jsx(Rr,{page:l,onClose:()=>c(null)})}),f&&o.jsx(h.Suspense,{children:o.jsx(Ur,{isOpen:f,onClose:oe,onContinue:O,isPending:S})})]})};function Kr(){const{isLocked:e}=Se(),[t]=te(),s=t.get("lang"),n=ts(s);return e||!n?o.jsx("div",{}):o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[o.jsx(Pr,{}),o.jsx(Tt,{permission:se.EDIT_THEME,children:o.jsx(Br,{})}),o.jsx(Mr,{}),o.jsx(Tt,{permission:se.SAVE_PAGE,children:o.jsx(Fr,{})}),o.jsx(Tt,{permission:se.PUBLISH_PAGE,children:o.jsx(qr,{})})]})}const Fs=({page:e,setDuplicatePage:t,setAddEditPage:s,setUnpublishPage:n,setDeletePage:r,setMarkAsTemplate:a,setUnmarkAsTemplate:i,children:l,isLanguagePage:c})=>{const{hasPermission:d}=C.usePermissions(),{data:f}=de(),u=h.useMemo(()=>p.find(f,{key:e.pageType}),[f,e.pageType]),g=h.useMemo(()=>!!e.isTemplate,[e.isTemplate]),E=h.useMemo(()=>!!(u!=null&&u.hasSlug),[u==null?void 0:u.hasSlug]);return!d(se.EDIT_PAGE)&&!d(se.DELETE_PAGE)&&!d(se.UNPUBLISH_PAGE)||!e?null:o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,onClick:P=>P.stopPropagation(),children:l}),o.jsxs(m.DropdownMenuContent,{align:"center",className:"text-sm",children:[d(se.ADD_PAGE)&&!c&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),t(e)},children:[o.jsx(v.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),d(se.EDIT_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),s({...e,global:!(u!=null&&u.hasSlug)})},children:[o.jsx(v.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&d(se.UNPUBLISH_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),n(e)},children:[o.jsx(v.Power,{className:"size-3"}),Y.UNPUBLISH]}),d(se.DELETE_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),r(e)},children:[o.jsx(v.Trash,{className:"size-3"}),Y.DELETE]}),d(se.MARK_AS_TEMPLATE)&&E&&!c&&o.jsx(o.Fragment,{children:g?o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),i(e)},children:[o.jsx(v.SquareLibrary,{className:"size-3"}),Y.UNMARK_AS_TEMPLATE]}):o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),a(e)},children:[o.jsx(v.SquareLibrary,{className:"size-3"}),Y.MARK_AS_TEMPLATE]})})]})]})},Hr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-YpzILOYq.cjs"))),Vr=h.lazy(()=>Promise.resolve().then(()=>require("./delete-page-w64MO7db.cjs"))),Qr=h.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-DB_c7V2t.cjs"))),zr=h.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-C4wH4UKf.cjs"))),$r=h.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-C8hTjRVk.cjs"))),Wr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-gtGfNOAq.cjs"))),Yr=()=>{const[e,t]=h.useState(null),[s,n]=h.useState(null),[r,a]=h.useState(null),[i,l]=h.useState(null),[c,d]=h.useState(null),[f,u]=h.useState(null),{data:g,isFetching:E}=ue(),{selectedLang:S,fallbackLang:P}=C.useLanguages(),{data:_}=ye(),A=_==null?void 0:_.find(O=>O.lang===S),{isLocked:x}=Se(),D=!(g!=null&&g.slug),[,q]=H.useAtom(jt);if(!g)return null;const V=O=>{S.length>0&&S!==P?q({edit:!0,id:O==null?void 0:O.id,primaryPage:O==null?void 0:O.primaryPage}):u(O)};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(Us,{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(v.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:[D?o.jsx(v.Globe,{className:"mr-1 h-4 w-4"}):o.jsx(v.File,{className:"mr-1 h-4 w-4"}),p.get(A||g,"name")??""]})})}),x?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(v.MoreHorizontal,{className:"h-4 w-4"})}):o.jsx(Fs,{page:g,setDuplicatePage:O=>d(O),setAddEditPage:O=>V(O),setUnpublishPage:O=>n(O),setDeletePage:O=>t(O),setMarkAsTemplate:O=>a(O),setUnmarkAsTemplate:O=>l(O),isLanguagePage:S.length>0&&S!==P,children:o.jsx(m.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:o.jsx(v.MoreHorizontal,{className:"h-4 w-4"})})})]}),f&&o.jsx(h.Suspense,{children:o.jsx(Hr,{closePanel:()=>u(null),editPage:()=>{},addEditPage:f,setAddEditPage:u})}),e&&o.jsx(h.Suspense,{children:o.jsx(Vr,{page:e,onClose:()=>t(null)})}),s&&o.jsx(h.Suspense,{children:o.jsx(Wr,{page:s,onClose:()=>n(null)})}),r&&o.jsx(h.Suspense,{children:o.jsx(zr,{page:r,onClose:()=>a(null)})}),i&&o.jsx(h.Suspense,{children:o.jsx($r,{page:i,onClose:()=>l(null)})}),c&&o.jsx(h.Suspense,{children:o.jsx(Qr,{page:c,onClose:()=>d(null),closePanel:()=>u(null)})})]})},os=({children:e,className:t=""})=>o.jsx("div",{className:C.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}),Jr=({hasDynamicPage:e})=>o.jsx(os,{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"})]})}),Xr=h.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-CF9nb6i_.cjs"))),Zr=()=>{const{dynamicPage:e,allLangPages:t,isFetching:s}=js(),n=t.length>0;return s?null:o.jsxs("div",{className:"relative",children:[!e&&o.jsx(Jr,{hasDynamicPage:n}),o.jsx(h.Suspense,{children:o.jsx(Xr,{})})]})},ea=()=>{const{data:e,isFetching:t}=ue(),{data:s,isFetching:n}=Z(),r=p.get(s,"dynamic",!1),a=ss(),i=C.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,d=ar(),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:C.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(Yr,{})}),o.jsxs("div",{className:C.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(Ms,{}),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:d,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(v.ExternalLink,{className:"h-4 w-4",strokeWidth:1})})})]})]}),r&&i&&o.jsx(Zr,{})]})},ta=()=>o.jsxs("div",{className:"flex h-full w-full items-center justify-between px-2",children:[o.jsx(Ar,{}),o.jsx(ea,{}),o.jsx(Kr,{})]}),qs=()=>{const e=T.useQueryClient(),{data:t}=T.useQuery({queryKey:[y.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:h.useCallback(n=>{e.setQueryData([y.AI_CONTEXT],n)},[e]),aiContext:t}},sa=()=>{const e=j(),{aiContext:t}=qs(),s=L();return h.useCallback(async(n,r,a,i)=>s(e,{action:y.ASK_AI,data:{type:n,prompt:r,blocks:a,context:t,lang:i}}),[e,t,s])},na=(e,t)=>t.map(s=>{if(p.has(e,s._type)){const n=Ns.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}),ra=e=>{const t=Ns.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:na(t,s)}},[e,t])},aa=()=>{const[e]=te(),t=e.get("page"),s=j(),{setAiContext:n}=qs(),[,r]=kt(),[,a]=rr(),[,i]=C.useIsPageLoaded(),l=L();return T.useQuery({queryKey:[y.GET_DRAFT_PAGE,t],staleTime:1/0,gcTime:0,queryFn:async()=>{i(!1);const c=await l(s,{action:y.GET_DRAFT_PAGE,data:{id:t,draft:!0}}),d=c.blocks??[],f=p.find(d,{_type:"@chai/ai-context"});return n(p.get(f,"_value","")||""),r(u=>({...u,lastSaved:c.lastSaved})),a(p.get(c,"metadata",{})),setTimeout(()=>i(!0),500),d},enabled:!!t})},Ks=()=>{const{data:e}=Z(),{data:t}=ue(),s=j(),n=L(),r=Ot(),a=ss();return T.useQuery({queryKey:[y.GET_BUILDER_PAGE_DATA,t==null?void 0:t.id,a],staleTime:1/0,gcTime:0,queryFn:async()=>n(s,{action:y.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})},Hs=()=>{const e=j(),t=T.useQueryClient(),s=L();return T.useMutation({mutationFn:async n=>s(e,{action:y.UPDATE_WEBSITE_SETTINGS,data:n}),onSuccess:(n,r)=>{var a;t.invalidateQueries({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS]}),(a=r==null?void 0:r.settings)!=null&&a.theme||F.toast.success("Website settings updated successfully.")},onError:n=>{F.toast.error("Failed to update website settings",{description:n.message})}})},ia=()=>{const e=j(),t=T.useQueryClient(),s=L(),{selectedLang:n}=C.useLanguages();return T.useMutation({mutationFn:async r=>s(e,{action:y.ADD_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema added successfully.")},onError:r=>{F.toast.error("Failed to add schema",{description:r.message})}})},oa=()=>{const e=j(),t=T.useQueryClient(),s=L(),{selectedLang:n}=C.useLanguages();return T.useMutation({mutationFn:async r=>s(e,{action:y.UPDATE_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema updated successfully.")},onError:r=>{F.toast.error("Failed to update schema",{description:r.message})}})},la=()=>{const e=j(),t=T.useQueryClient(),s=L();return T.useMutation({mutationFn:async n=>s(e,{action:y.DELETE_GLOBAL_SCHEMA,data:{id:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema deleted successfully.")},onError:n=>{F.toast.error("Failed to delete schema",{description:n.message})}})},ca=()=>{const e=j(),t=L();return T.useMutation({mutationFn:async s=>t(e,{action:y.TOGGLE_PAGE_GLOBAL_SCHEMA,data:s}),onError:s=>{F.toast.error("Failed to toggle schema",{description:s.message})}})},ua=()=>{const e=j(),t=L();return T.useMutation({mutationFn:async s=>t(e,{action:y.APPLY_SCHEMA_TO_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{F.toast.success(`Schema applied to ${s.count} page(s)`)},onError:s=>{F.toast.error("Failed to apply schema to all pages",{description:s.message})}})},da=()=>{const e=j(),t=L();return T.useMutation({mutationFn:async s=>t(e,{action:y.REMOVE_SCHEMA_FROM_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{F.toast.success(`Schema removed from ${s.count} page(s)`)},onError:s=>{F.toast.error("Failed to remove schema from all pages",{description:s.message})}})},ps={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:C.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),[]}}},fa=()=>{const e=j(),t=L();return T.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const n=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return n.forEach(r=>{C.registerChaiLibrary(r.id,{name:r.isSiteLibrary?r.name+" (Current Site) ":r.name,description:r.description,getBlocksList:a=>ps.getUILibraryBlocks(a,t,e),getBlock:({block:a})=>ps.getUILibraryBlock(a,t,e)})}),n}})},Vs=()=>{const e=Gs(),t=L(),{user:s}=He(),n=s==null?void 0:s.id;return T.useQuery({queryKey:[y.GET_ROLE_AND_PERMISSIONS,n],queryFn:()=>t(e,{action:y.GET_ROLE_AND_PERMISSIONS,data:{userId:n}}),enabled:!!n,staleTime:1/0})},ha=()=>{const e=j(),t=L(),[,s]=kt();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")}}}},ga=()=>{const{data:e}=as(),t=j(),s=L();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])}},ma=h.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-D2YUMeJZ.cjs"))),Ea=({isActive:e,show:t})=>{const{data:s}=Ae();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(v.LanguagesIcon,{className:"h-4 w-4"})})},Qs="lang",pa={id:Qs,label:"Languages",position:"top",panel:ma,button:Ea,view:"modal",width:400},ya=h.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-CrK7z4bR.cjs"))),zs="seo",Aa=({isActive:e,show:t})=>{const{data:s}=Z(),n=Bs(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"})]})})},Sa={id:zs,label:"SEO",panel:ya,button:Aa,position:"top",width:600,view:"modal"},$s="user-info",Ta=()=>{const{user:e,logout:t}=He(),s=ee("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(v.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},Pa={id:$s,label:"User Info",button:Ta,position:"bottom"},_a=()=>{C.registerChaiSidebarPanel(zs,Sa),C.registerChaiSidebarPanel(Qs,pa),C.registerChaiSidebarPanel($s,Pa)};var b={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return ys(this.context.count)},getNextContextId(){return ys(this.context.count++)}};function ys(e){const t=String(e),s=t.length-1;return b.context.id+(s?String.fromCharCode(96+s):"")+t}function We(e){b.context=e}var Ws=!1,xa=(e,t)=>e===t,wt=Symbol("solid-proxy"),Ys=typeof Proxy=="function",ls=Symbol("solid-track"),vt={equals:xa},Js=an,fe=1,bt=2,Xs={owned:null,cleanups:null,context:null,owner:null},qt={},G=null,Kt=null,wa=null,M=null,X=null,ce=null,Ut=0;function me(e,t){const s=M,n=G,r=e.length===0,a=t===void 0?n:t,i=r?Xs:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>J(()=>et(i)));G=i,M=null;try{return ie(l,!0)}finally{M=s,G=n}}function K(e,t){t=t?Object.assign({},vt,t):vt;const s={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},n=r=>(typeof r=="function"&&(r=r(s.value)),rn(s,r));return[nn.bind(s),n]}function Zs(e,t,s){const n=Mt(e,t,!0,fe);Ve(n)}function Ee(e,t,s){const n=Mt(e,t,!1,fe);Ve(n)}function cs(e,t,s){Js=Ua;const n=Mt(e,t,!1,fe);(!s||!s.render)&&(n.user=!0),ce?ce.push(n):Ve(n)}function $(e,t,s){s=s?Object.assign({},vt,s):vt;const n=Mt(e,t,!0,0);return n.observers=null,n.observerSlots=null,n.comparator=s.equals||void 0,Ve(n),nn.bind(n)}function va(e){return e&&typeof e=="object"&&"then"in e}function ba(e,t,s){let n,r,a;n=!0,r=e,a={};let i=null,l=qt,c=null,d=!1,f="initialValue"in a,u=typeof n=="function"&&$(n);const g=new Set,[E,S]=(a.storage||K)(a.initialValue),[P,_]=K(void 0),[A,x]=K(void 0,{equals:!1}),[D,q]=K(f?"ready":"unresolved");b.context&&(c=b.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:b.load&&b.has(c)&&(l=b.load(c)));function V(I,N,W,Q){return i===I&&(i=null,Q!==void 0&&(f=!0),(I===l||N===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(Q,{value:N})),l=qt,O(N,W)),N}function O(I,N){ie(()=>{N===void 0&&S(()=>I),q(N!==void 0?"errored":f?"ready":"unresolved"),_(N);for(const W of g.keys())W.decrement();g.clear()},!1)}function oe(){const I=ja,N=E(),W=P();if(W!==void 0&&!i)throw W;return M&&M.user,N}function le(I=!0){if(I!==!1&&d)return;d=!1;const N=u?u():n;if(N==null||N===!1){V(i,J(E));return}let W;const Q=l!==qt?l:J(()=>{try{return r(N,{value:E(),refetching:I})}catch(ne){W=ne}});if(W!==void 0){V(i,void 0,_t(W),N);return}else if(!va(Q))return V(i,Q,void 0,N),Q;return i=Q,"v"in Q?(Q.s===1?V(i,Q.v,void 0,N):V(i,void 0,_t(Q.v),N),Q):(d=!0,queueMicrotask(()=>d=!1),ie(()=>{q(f?"refreshing":"pending"),x()},!1),Q.then(ne=>V(Q,ne,void 0,N),ne=>V(Q,void 0,_t(ne),N)))}Object.defineProperties(oe,{state:{get:()=>D()},error:{get:()=>P()},loading:{get(){const I=D();return I==="pending"||I==="refreshing"}},latest:{get(){if(!f)return oe();const I=P();if(I&&!i)throw I;return E()}}});let U=G;return u?Zs(()=>(U=G,le(!1))):le(!1),[oe,{refetch:I=>tn(U,()=>le(I)),mutate:S}]}function Ca(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 Ia(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 d=0;d<e.length;d++)l[d]=e[d]()}else l=e();if(a)return a=!1,i;const c=J(()=>t(l,r,i));return r=l,c}}function en(e){cs(()=>J(e))}function qe(e){return G===null||(G.cleanups===null?G.cleanups=[e]:G.cleanups.push(e)),e}function As(){return G}function tn(e,t){const s=G,n=M;G=e,M=null;try{return ie(t,!0)}catch(r){us(r)}finally{G=s,M=n}}function La(e){const t=M,s=G;return Promise.resolve().then(()=>{M=t,G=s;let n;return ie(e,!1),M=G=null,n?n.done:void 0})}var[Na,Mo]=K(!1);function Ga(){return[Na,La]}function Da(e,t){const s=Symbol("context");return{id:s,Provider:Ma(s),defaultValue:e}}function ka(e){let t;return G&&G.context&&(t=G.context[e.id])!==void 0?t:e.defaultValue}function sn(e){const t=$(e),s=$(()=>Qt(t()));return s.toArray=()=>{const n=s();return Array.isArray(n)?n:n!=null?[n]:[]},s}var ja;function nn(){if(this.sources&&this.state)if(this.state===fe)Ve(this);else{const e=X;X=null,ie(()=>It(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 rn(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=Kt&&Kt.running;i&&Kt.disposed.has(a),(i?!a.tState:!a.state)&&(a.pure?X.push(a):ce.push(a),a.observers&&on(a)),i||(a.state=fe)}if(X.length>1e6)throw X=[],new Error},!1)),t}function Ve(e){if(!e.fn)return;et(e);const t=Ut;Oa(e,e.value,t)}function Oa(e,t,s){let n;const r=G,a=M;M=G=e;try{n=e.fn(t)}catch(i){return e.pure&&(e.state=fe,e.owned&&e.owned.forEach(et),e.owned=null),e.updatedAt=s+1,us(i)}finally{M=a,G=r}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?rn(e,n):e.value=n,e.updatedAt=s)}function Mt(e,t,s,n=fe,r){const a={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:G,context:G?G.context:null,pure:s};return G===null||G!==Xs&&(G.owned?G.owned.push(a):G.owned=[a]),a}function Ct(e){if(e.state===0)return;if(e.state===bt)return It(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<Ut);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===fe)Ve(e);else if(e.state===bt){const n=X;X=null,ie(()=>It(e,t[0]),!1),X=n}}function ie(e,t){if(X)return e();let s=!1;t||(X=[]),ce?s=!0:ce=[],Ut++;try{const n=e();return Ra(s),n}catch(n){s||(ce=null),X=null,us(n)}}function Ra(e){if(X&&(an(X),X=null),e)return;const t=ce;ce=null,t.length&&ie(()=>Js(t),!1)}function an(e){for(let t=0;t<e.length;t++)Ct(e[t])}function Ua(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:Ct(n)}if(b.context){if(b.count){b.effects||(b.effects=[]),b.effects.push(...e.slice(0,s));return}We()}for(b.effects&&(b.done||!b.count)&&(e=[...b.effects,...e],s+=b.effects.length,delete b.effects),t=0;t<s;t++)Ct(e[t])}function It(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===fe?n!==t&&(!n.updatedAt||n.updatedAt<Ut)&&Ct(n):r===bt&&It(n,t)}}}function on(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=bt,s.pure?X.push(s):ce.push(s),s.observers&&on(s))}}function et(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--)et(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)et(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 _t(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function us(e,t=G){throw _t(e)}function Qt(e){if(typeof e=="function"&&!e.length)return Qt(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const n=Qt(e[s]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Ma(e,t){return function(n){let r;return Ee(()=>r=J(()=>(G.context={...G.context,[e]:n.value},sn(()=>n.children))),void 0),r}}var zt=Symbol("fallback");function Lt(e){for(let t=0;t<e.length;t++)e[t]()}function Ba(e,t,s={}){let n=[],r=[],a=[],i=0,l=t.length>1?[]:null;return qe(()=>Lt(a)),()=>{let c=e()||[],d=c.length,f,u;return c[ls],J(()=>{let E,S,P,_,A,x,D,q,V;if(d===0)i!==0&&(Lt(a),a=[],n=[],r=[],i=0,l&&(l=[])),s.fallback&&(n=[zt],r[0]=me(O=>(a[0]=O,s.fallback())),i=1);else if(i===0){for(r=new Array(d),u=0;u<d;u++)n[u]=c[u],r[u]=me(g);i=d}else{for(P=new Array(d),_=new Array(d),l&&(A=new Array(d)),x=0,D=Math.min(i,d);x<D&&n[x]===c[x];x++);for(D=i-1,q=d-1;D>=x&&q>=x&&n[D]===c[q];D--,q--)P[q]=r[D],_[q]=a[D],l&&(A[q]=l[D]);for(E=new Map,S=new Array(q+1),u=q;u>=x;u--)V=c[u],f=E.get(V),S[u]=f===void 0?-1:f,E.set(V,u);for(f=x;f<=D;f++)V=n[f],u=E.get(V),u!==void 0&&u!==-1?(P[u]=r[f],_[u]=a[f],l&&(A[u]=l[f]),u=S[u],E.set(V,u)):a[f]();for(u=x;u<d;u++)u in P?(r[u]=P[u],a[u]=_[u],l&&(l[u]=A[u],l[u](u))):r[u]=me(g);r=r.slice(0,i=d),n=c.slice(0)}return r});function g(E){if(a[u]=E,l){const[S,P]=K(u);return l[u]=P,t(c[u],S)}return t(c[u])}}}function Fa(e,t,s={}){let n=[],r=[],a=[],i=[],l=0,c;return qe(()=>Lt(a)),()=>{const d=e()||[],f=d.length;return d[ls],J(()=>{if(f===0)return l!==0&&(Lt(a),a=[],n=[],r=[],l=0,i=[]),s.fallback&&(n=[zt],r[0]=me(g=>(a[0]=g,s.fallback())),l=1),r;for(n[0]===zt&&(a[0](),a=[],n=[],r=[],l=0),c=0;c<f;c++)c<n.length&&n[c]!==d[c]?i[c](()=>d[c]):c>=n.length&&(r[c]=me(u));for(;c<n.length;c++)a[c]();return l=i.length=a.length=f,n=d.slice(0),r=r.slice(0,l)});function u(g){a[c]=g;const[E,S]=K(d[c]);return i[c]=S,t(E,c)}}}function ds(e,t){return J(()=>e(t||{}))}function yt(){return!0}var $t={get(e,t,s){return t===wt?s:e.get(t)},has(e,t){return t===wt?!0:e.has(t)},set:yt,deleteProperty:yt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:yt,deleteProperty:yt}},ownKeys(e){return e.keys()}};function Ht(e){return(e=typeof e=="function"?e():e)?e:{}}function qa(){for(let e=0,t=this.length;e<t;++e){const s=this[e]();if(s!==void 0)return s}}function fs(...e){let t=!1;for(let i=0;i<e.length;i++){const l=e[i];t=t||!!l&&wt in l,e[i]=typeof l=="function"?(t=!0,$(l)):l}if(Ys&&t)return new Proxy({get(i){for(let l=e.length-1;l>=0;l--){const c=Ht(e[l])[i];if(c!==void 0)return c}},has(i){for(let l=e.length-1;l>=0;l--)if(i in Ht(e[l]))return!0;return!1},keys(){const i=[];for(let l=0;l<e.length;l++)i.push(...Object.keys(Ht(e[l])));return[...new Set(i)]}},$t);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 d=c.length-1;d>=0;d--){const f=c[d];if(f==="__proto__"||f==="constructor")continue;const u=Object.getOwnPropertyDescriptor(l,f);if(!n[f])n[f]=u.get?{enumerable:!0,configurable:!0,get:qa.bind(s[f]=[u.get.bind(l)])}:u.value!==void 0?u:void 0;else{const g=s[f];g&&(u.get?g.push(u.get.bind(l)):u.value!==void 0&&g.push(()=>u.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 ln(e,...t){if(Ys&&wt 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)}},$t));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))}},$t)),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 d of t)d.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 cn(e){let t,s;const n=r=>{const a=b.context;if(a){const[l,c]=K();b.count||(b.count=0),b.count++,(s||(s=e())).then(d=>{!b.done&&We(a),b.count--,c(()=>d.default),We()}),t=l}else if(!t){const[l]=ba(()=>(s||(s=e())).then(c=>c.default));t=l}let i;return $(()=>(i=t())?J(()=>{if(!a||b.done)return i(r);const l=b.context;We(a);const c=i(r);return We(l),c}):"")};return n.preload=()=>s||((s=e()).then(r=>t=()=>r.default),s),n}var Ka=0;function Ha(){return b.context?b.getNextContextId():`cl-${Ka++}`}var un=e=>`Stale read from <${e}>.`;function Va(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(Ba(()=>e.each,e.children,t||void 0))}function Qa(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(Fa(()=>e.each,e.children,t||void 0))}function za(e){const t=e.keyed,s=$(()=>e.when,void 0,void 0),n=t?s:$(s,void 0,{equals:(r,a)=>!r==!a});return $(()=>{const r=n();if(r){const a=e.children;return typeof a=="function"&&a.length>0?J(()=>a(t?r:()=>{if(!J(n))throw un("Show");return s()})):a}return e.fallback},void 0,void 0)}function $a(e){const t=sn(()=>e.children),s=$(()=>{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],d=a,f=$(()=>d()?void 0:c.when,void 0,void 0),u=c.keyed?f:$(f,void 0,{equals:(g,E)=>!g==!E});a=()=>d()||(u()?[l,f,c]:void 0)}return a});return $(()=>{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 d;if(((d=J(s)())==null?void 0:d[0])!==r)throw un("Match");return a()})):l},void 0,void 0)}function Wa(e){return e}var Ya=["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"],Ja=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",...Ya]),Xa=new Set(["innerHTML","textContent","innerText","children"]),Za=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),ei=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 ti(e,t){const s=ei[e];return typeof s=="object"?s[t]?s.$:void 0:s}var si=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),ni=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"]),ri={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},ai=e=>$(()=>e());function ii(e,t,s){let n=s.length,r=t.length,a=n,i=0,l=0,c=t[r-1].nextSibling,d=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;)(!d||!d.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(!d){d=new Map;let u=l;for(;u<a;)d.set(s[u],u++)}const f=d.get(t[i]);if(f!=null)if(l<f&&f<a){let u=i,g=1,E;for(;++u<r&&u<a&&!((E=d.get(t[u]))==null||E!==f+g);)g++;if(g>f-l){const S=t[i];for(;l<f;)e.insertBefore(s[l++],S)}else e.replaceChild(s[l++],t[i++])}else i++;else t[i++].remove()}}}var Xe="_$DX_DELEGATE";function dn(e,t,s,n={}){let r;return me(a=>{r=a,t===document?e():Gt(t,e(),t.firstChild?null:void 0,s)},n.owner),()=>{r(),t.textContent=""}}function oi(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 fn(e,t=window.document){const s=t[Xe]||(t[Xe]=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,pn))}}function li(e=window.document){if(e[Xe]){for(let t of e[Xe].keys())e.removeEventListener(t,pn);delete e[Xe]}}function Nt(e,t,s){xe(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function ci(e,t,s,n){xe(e)||(n==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,n))}function ui(e,t,s){xe(e)||(s?e.setAttribute(t,""):e.removeAttribute(t))}function hn(e,t){xe(e)||(t==null?e.removeAttribute("class"):e.className=t)}function gn(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 di(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]||(Ss(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||(Ss(e,l,!0),s[l]=c)}return s}function fi(e,t,s){if(!t)return s?Nt(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 mn(e,t={},s,n){const r={};return n||Ee(()=>r.children=tt(e,t.children,r.children)),Ee(()=>typeof t.ref=="function"&&En(t.ref,e)),Ee(()=>hi(e,t,s,!0,r,!0)),r}function En(e,t,s){return J(()=>e(t,s))}function Gt(e,t,s,n){if(s!==void 0&&!n&&(n=[]),typeof t!="function")return tt(e,t,n,s);Ee(r=>tt(e,t(),r,s),n)}function hi(e,t,s,n,r={},a=!1){t||(t={});for(const i in r)if(!(i in t)){if(i==="children")continue;r[i]=Ts(e,i,null,r[i],s,a,t)}for(const i in t){if(i==="children")continue;const l=t[i];r[i]=Ts(e,i,l,r[i],s,a,t)}}function gi(e){let t,s;return!xe()||!(t=b.registry.get(s=Ei()))?e():(b.completed&&b.completed.add(t),b.registry.delete(s),t)}function xe(e){return!!b.context&&!b.done&&(!e||e.isConnected)}function mi(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function Ss(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 Ts(e,t,s,n,r,a,i){let l,c,d,f,u;if(t==="style")return fi(e,s,n);if(t==="classList")return di(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=si.has(g);if(!E&&n){const S=Array.isArray(n)?n[0]:n;e.removeEventListener(g,S)}(E||s)&&(gn(e,g,s,E),E&&fn([g]))}else if(t.slice(0,5)==="attr:")Nt(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")ui(e,t.slice(5),s);else if((u=t.slice(0,5)==="prop:")||(d=Xa.has(t))||!r&&((f=ti(t,e.tagName))||(c=Ja.has(t)))||(l=e.nodeName.includes("-")||"is"in i)){if(u)t=t.slice(5),c=!0;else if(xe(e))return s;t==="class"||t==="className"?hn(e,s):l&&!c&&!d?e[mi(t)]=s:e[f||t]=s}else{const g=r&&t.indexOf(":")>-1&&ri[t.split(":")[0]];g?ci(e,g,t,s):Nt(e,Za[t]||t,s)}return s}function pn(e){if(b.registry&&b.events&&b.events.find(([c,d])=>d===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 d=t[`${s}Data`];if(d!==void 0?c.call(t,d,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 d=0;d<c.length-2&&(t=c[d],!!i());d++){if(t._$host){t=t._$host,l();break}if(t.parentNode===r)break}}else l();a(n)}function tt(e,t,s,n,r){const a=xe(e);if(a){!s&&(s=[...e.childNodes]);let c=[];for(let d=0;d<s.length;d++){const f=s[d];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=we(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=we(e,s,n)}else{if(i==="function")return Ee(()=>{let c=t();for(;typeof c=="function";)c=c();s=tt(e,c,s,n)}),()=>s;if(Array.isArray(t)){const c=[],d=s&&Array.isArray(s);if(Wt(c,t,s,r))return Ee(()=>s=tt(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 u=[f];for(;(f=f.nextSibling)!==n;)u.push(f);return s=u}if(c.length===0){if(s=we(e,s,n),l)return s}else d?s.length===0?Ps(e,c,n):ii(e,s,c):(s&&we(e),Ps(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=we(e,s,n,t);we(e,s,null,t)}else s==null||s===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);s=t}}return s}function Wt(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],d;if(!(l==null||l===!0||l===!1))if((d=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))r=Wt(e,l,c)||r;else if(d==="function")if(n){for(;typeof l=="function";)l=l();r=Wt(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 Ps(e,t,s=null){for(let n=0,r=t.length;n<r;n++)e.insertBefore(t[n],s)}function we(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 Ei(){return b.getNextContextId()}var pi="http://www.w3.org/2000/svg";function yn(e,t=!1){return t?document.createElementNS(pi,e):document.createElement(e)}function yi(e){const{useShadow:t}=e,s=document.createTextNode(""),n=()=>e.mount||document.body,r=As();let a,i=!!b.context;return cs(()=>{i&&(As().user=i=!1),a||(a=tn(r,()=>$(()=>e.children)));const l=n();if(l instanceof HTMLHeadElement){const[c,d]=K(!1),f=()=>d(!0);me(u=>Gt(l,()=>c()?u():a(),null)),qe(f)}else{const c=yn(e.isSVG?"g":"div",e.isSVG),d=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return s.parentNode},configurable:!0}),Gt(d,a),l.appendChild(c),e.ref&&e.ref(c),qe(()=>l.removeChild(c))}},void 0,{render:!i}),s}function Ai(e,t){const s=$(e);return $(()=>{const n=s();switch(typeof n){case"function":return J(()=>n(t));case"string":const r=ni.has(n),a=b.context?gi():yn(n,r);return mn(a,t,r),a}})}function Si(e){const[,t]=ln(e,["component"]);return Ai(()=>e.component,t)}var Ti=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()}},An=class{constructor(e){this.generateIdentifier=e,this.kv=new Ti}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)}},Pi=class extends An{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 _i(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 xi(e,t){const s=_i(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 Ke(e,t){Object.entries(e).forEach(([s,n])=>t(n,s))}function xt(e,t){return e.indexOf(t)!==-1}function _s(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var wi=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return xi(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},vi=e=>Object.prototype.toString.call(e).slice(8,-1),Sn=e=>typeof e>"u",bi=e=>e===null,st=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,Yt=e=>st(e)&&Object.keys(e).length===0,pe=e=>Array.isArray(e),Ci=e=>typeof e=="string",Ii=e=>typeof e=="number"&&!isNaN(e),Li=e=>typeof e=="boolean",Ni=e=>e instanceof RegExp,nt=e=>e instanceof Map,rt=e=>e instanceof Set,Tn=e=>vi(e)==="Symbol",Gi=e=>e instanceof Date&&!isNaN(e.valueOf()),Di=e=>e instanceof Error,xs=e=>typeof e=="number"&&isNaN(e),ki=e=>Li(e)||bi(e)||Sn(e)||Ii(e)||Ci(e)||Tn(e),ji=e=>typeof e=="bigint",Oi=e=>e===1/0||e===-1/0,Ri=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),Ui=e=>e instanceof URL,Pn=e=>e.replace(/\./g,"\\."),Vt=e=>e.map(String).map(Pn).join("."),Ze=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 _n=[ae(Sn,"undefined",()=>null,()=>{}),ae(ji,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),ae(Gi,"Date",e=>e.toISOString(),e=>new Date(e)),ae(Di,"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(Ni,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),ae(rt,"set",e=>[...e.values()],e=>new Set(e)),ae(nt,"map",e=>[...e.entries()],e=>new Map(e)),ae(e=>xs(e)||Oi(e),"number",e=>xs(e)?"NaN":e>0?"Infinity":"-Infinity",Number),ae(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),ae(Ui,"URL",e=>e.toString(),e=>new URL(e))];function Bt(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var xn=Bt((e,t)=>Tn(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}),Mi=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),wn=Bt(Ri,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=Mi[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function vn(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var bn=Bt(vn,(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)}),Cn=Bt((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)}),Bi=[bn,xn,Cn,wn],ws=(e,t)=>{const s=_s(Bi,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=_s(_n,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},In={};_n.forEach(e=>{In[e.annotation]=e});var Fi=(e,t,s)=>{if(pe(t))switch(t[0]){case"symbol":return xn.untransform(e,t,s);case"class":return bn.untransform(e,t,s);case"custom":return Cn.untransform(e,t,s);case"typed-array":return wn.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const n=In[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,s)}},ve=(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 Ln(e){if(xt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(xt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(xt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var qi=(e,t)=>{Ln(t);for(let s=0;s<t.length;s++){const n=t[s];if(rt(e))e=ve(e,+n);else if(nt(e)){const r=+n,a=+t[++s]==0?"key":"value",i=ve(e,r);switch(a){case"key":e=i;break;case"value":e=e.get(i);break}}else e=e[n]}return e},Jt=(e,t,s)=>{if(Ln(t),t.length===0)return s(e);let n=e;for(let a=0;a<t.length-1;a++){const i=t[a];if(pe(n)){const l=+i;n=n[l]}else if(st(n))n=n[i];else if(rt(n)){const l=+i;n=ve(n,l)}else if(nt(n)){if(a===t.length-2)break;const c=+i,d=+t[++a]==0?"key":"value",f=ve(n,c);switch(d){case"key":n=f;break;case"value":n=n.get(f);break}}}const r=t[t.length-1];if(pe(n)?n[+r]=s(n[+r]):st(n)&&(n[r]=s(n[r])),rt(n)){const a=ve(n,+r),i=s(a);a!==i&&(n.delete(a),n.add(i))}if(nt(n)){const a=+t[t.length-2],i=ve(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 Xt(e,t,s=[]){if(!e)return;if(!pe(e)){Ke(e,(a,i)=>Xt(a,t,[...s,...Ze(i)]));return}const[n,r]=e;r&&Ke(r,(a,i)=>{Xt(a,t,[...s,...Ze(i)])}),t(n,s)}function Ki(e,t,s){return Xt(t,(n,r)=>{e=Jt(e,r,a=>Fi(a,n,s))}),e}function Hi(e,t){function s(n,r){const a=qi(e,Ze(r));n.map(Ze).forEach(i=>{e=Jt(e,i,()=>a)})}if(pe(t)){const[n,r]=t;n.forEach(a=>{e=Jt(e,Ze(a),()=>e)}),r&&Ke(r,s)}else Ke(t,s);return e}var Vi=(e,t)=>st(e)||pe(e)||nt(e)||rt(e)||vn(e,t);function Qi(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function zi(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(Vt):s[Vt(a)]=i.map(Vt)}),n?Yt(s)?[n]:[n,s]:Yt(s)?void 0:s}var Nn=(e,t,s,n,r=[],a=[],i=new Map)=>{const l=ki(e);if(!l){Qi(e,r,t);const E=i.get(e);if(E)return n?{transformedValue:null}:E}if(!Vi(e,s)){const E=ws(e,s),S=E?{transformedValue:E.value,annotations:[E.type]}:{transformedValue:e};return l||i.set(e,S),S}if(xt(a,e))return{transformedValue:null};const c=ws(e,s),d=(c==null?void 0:c.value)??e,f=pe(d)?[]:{},u={};Ke(d,(E,S)=>{if(S==="__proto__"||S==="constructor"||S==="prototype")throw new Error(`Detected property ${S}. This is a prototype pollution risk, please remove it from your object.`);const P=Nn(E,t,s,n,[...r,S],[...a,e],i);f[S]=P.transformedValue,pe(P.annotations)?u[S]=P.annotations:st(P.annotations)&&Ke(P.annotations,(_,A)=>{u[Pn(S)+"."+A]=_})});const g=Yt(u)?{transformedValue:f,annotations:c?[c.type]:void 0}:{transformedValue:f,annotations:c?[c.type,u]:u};return l||i.set(e,g),g};function Gn(e){return Object.prototype.toString.call(e).slice(8,-1)}function vs(e){return Gn(e)==="Array"}function $i(e){if(Gn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function Wi(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 Zt(e,t={}){if(vs(e))return e.map(r=>Zt(r,t));if(!$i(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((r,a)=>{if(vs(t.props)&&!t.props.includes(a))return r;const i=e[a],l=Zt(i,t);return Wi(r,a,l,e,t.nonenumerable),r},{})}var B=class{constructor({dedupe:e=!1}={}){this.classRegistry=new Pi,this.symbolRegistry=new An(t=>t.description??""),this.customTransformerRegistry=new wi,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=Nn(e,t,this,this.dedupe),n={json:s.transformedValue};s.annotations&&(n.meta={...n.meta,values:s.annotations});const r=zi(t,this.dedupe);return r&&(n.meta={...n.meta,referentialEqualities:r}),n}deserialize(e){const{json:t,meta:s}=e;let n=Zt(t);return s!=null&&s.values&&(n=Ki(n,s.values,this)),s!=null&&s.referentialEqualities&&(n=Hi(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 Dn=B.serialize,Yi=B.stringify;function Ji(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function Xi(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function Zi({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function eo({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function to(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var so=(e,t=!1)=>{const{json:s}=Dn(e);return JSON.stringify(s,null,t?2:void 0)},At=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,no=(e,t)=>e.queryHash.localeCompare(t.queryHash),kn=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,ro=(e,t)=>At(e)===At(t)?kn(e,t):At(e)>At(t)?1:-1,ao={status:ro,"query hash":no,"last updated":kn},St=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,jn=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,io=(e,t)=>St(e)===St(t)?jn(e,t):St(e)>St(t)?1:-1,oo={status:io,"last updated":jn},lo=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),co=()=>{const[e,t]=K("dark");return en(()=>{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),qe(()=>s.removeEventListener("change",n))}),e},Ye=(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,Ye(n.get(r),a,s)),n}if(e instanceof Set){const n=Ye(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]=Ye(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]=Ye(n[r],a,s),n}return e},Je=(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,Je(s.get(n),r)),s}if(e instanceof Set){const s=Je(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]=Je(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]=Je(s[n],r),s}return e},On=(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)},be,at,it,ot,Pe,lt,Ce,Ie,Le,Ne,Ge,ct,De,ut,Is,uo=(Is=class{constructor(e){R(this,be);R(this,at);R(this,it);R(this,ot);R(this,Pe,!1);R(this,lt);R(this,Ce);R(this,Ie);R(this,Le);R(this,Ne);R(this,Ge);R(this,ct);R(this,De);R(this,ut);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:f,hideDisabledQueries:u}=e;k(this,be,K(t)),k(this,it,s),k(this,ot,n),k(this,at,r),k(this,lt,d),k(this,Ce,f),k(this,Ie,K(a)),k(this,Le,K(i)),k(this,Ne,K(l)),k(this,Ge,K(c)),k(this,ct,K(u))}setButtonPosition(e){w(this,Ie)[1](e)}setPosition(e){w(this,Le)[1](e)}setInitialIsOpen(e){w(this,Ne)[1](e)}setErrorTypes(e){w(this,Ge)[1](e)}setClient(e){w(this,be)[1](e)}mount(e){if(w(this,Pe))throw new Error("Devtools is already mounted");const t=dn(()=>{const s=this,[n]=w(this,Ie),[r]=w(this,Le),[a]=w(this,Ne),[i]=w(this,Ge),[l]=w(this,ct),[c]=w(this,be);let d;return w(this,De)?d=w(this,De):(d=cn(()=>Promise.resolve().then(()=>require("./NCMVHL6D-BPM6RHYa.cjs"))),k(this,De,d)),On(w(this,lt),w(this,Ce)),ds(d,fs({get queryFlavor(){return w(s,it)},get version(){return w(s,ot)},get onlineManager(){return w(s,at)},get shadowDOMTarget(){return w(s,Ce)}},{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);k(this,Pe,!0),k(this,ut,t)}unmount(){var e;if(!w(this,Pe))throw new Error("Devtools is not mounted");(e=w(this,ut))==null||e.call(this),k(this,Pe,!1)}},be=new WeakMap,at=new WeakMap,it=new WeakMap,ot=new WeakMap,Pe=new WeakMap,lt=new WeakMap,Ce=new WeakMap,Ie=new WeakMap,Le=new WeakMap,Ne=new WeakMap,Ge=new WeakMap,ct=new WeakMap,De=new WeakMap,ut=new WeakMap,Is),ke,dt,ft,ht,_e,gt,je,Oe,Re,Ue,Me,mt,Be,Fe,Et,Ls,fo=(Ls=class{constructor(e){R(this,ke);R(this,dt);R(this,ft);R(this,ht);R(this,_e,!1);R(this,gt);R(this,je);R(this,Oe);R(this,Re);R(this,Ue);R(this,Me);R(this,mt);R(this,Be);R(this,Fe);R(this,Et);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:f,onClose:u,hideDisabledQueries:g}=e;k(this,ke,K(t)),k(this,ft,s),k(this,ht,n),k(this,dt,r),k(this,gt,d),k(this,je,f),k(this,Oe,K(a)),k(this,Re,K(i)),k(this,Ue,K(l)),k(this,Me,K(c)),k(this,mt,K(g)),k(this,Be,K(u))}setButtonPosition(e){w(this,Oe)[1](e)}setPosition(e){w(this,Re)[1](e)}setInitialIsOpen(e){w(this,Ue)[1](e)}setErrorTypes(e){w(this,Me)[1](e)}setClient(e){w(this,ke)[1](e)}setOnClose(e){w(this,Be)[1](()=>e)}mount(e){if(w(this,_e))throw new Error("Devtools is already mounted");const t=dn(()=>{const s=this,[n]=w(this,Oe),[r]=w(this,Re),[a]=w(this,Ue),[i]=w(this,Me),[l]=w(this,mt),[c]=w(this,ke),[d]=w(this,Be);let f;return w(this,Fe)?f=w(this,Fe):(f=cn(()=>Promise.resolve().then(()=>require("./2AITGKQY-o6FgGSqg.cjs"))),k(this,Fe,f)),On(w(this,gt),w(this,je)),ds(f,fs({get queryFlavor(){return w(s,ft)},get version(){return w(s,ht)},get onlineManager(){return w(s,dt)},get shadowDOMTarget(){return w(s,je)}},{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 d()}}))},e);k(this,_e,!0),k(this,Et,t)}unmount(){var e;if(!w(this,_e))throw new Error("Devtools is not mounted");(e=w(this,Et))==null||e.call(this),k(this,_e,!1)}},ke=new WeakMap,dt=new WeakMap,ft=new WeakMap,ht=new WeakMap,_e=new WeakMap,gt=new WeakMap,je=new WeakMap,Oe=new WeakMap,Re=new WeakMap,Ue=new WeakMap,Me=new WeakMap,mt=new WeakMap,Be=new WeakMap,Fe=new WeakMap,Et=new WeakMap,Ls);function ho(e){const t=T.useQueryClient(e.client),s=z.useRef(null),{buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d}=e,[f]=z.useState(new uo({client:t,queryFlavor:"React Query",version:"5",onlineManager:T.onlineManager,buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d}));return z.useEffect(()=>{f.setClient(t)},[t,f]),z.useEffect(()=>{n&&f.setButtonPosition(n)},[n,f]),z.useEffect(()=>{r&&f.setPosition(r)},[r,f]),z.useEffect(()=>{f.setInitialIsOpen(a||!1)},[a,f]),z.useEffect(()=>{f.setErrorTypes(i||[])},[i,f]),z.useEffect(()=>(s.current&&f.mount(s.current),()=>{f.unmount()}),[f]),o.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:s})}function go(e){const t=T.useQueryClient(e.client),s=z.useRef(null),{errorTypes:n,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:i}=e,[l]=z.useState(new fo({client:t,queryFlavor:"React Query",version:"5",onlineManager:T.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:n,styleNonce:r,shadowDOMTarget:a,onClose:e.onClose,hideDisabledQueries:i}));return z.useEffect(()=>{l.setClient(t)},[t,l]),z.useEffect(()=>{l.setOnClose(e.onClose??(()=>{}))},[e.onClose,l]),z.useEffect(()=>{l.setErrorTypes(n||[])},[n,l]),z.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 bs=process.env.NODE_ENV!=="development"?function(){return null}:ho;process.env.NODE_ENV;const Rn=H.atom(""),mo=()=>{C.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),C.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"})},Eo=()=>{const e=j(),t=L();return T.useQuery({queryKey:[y.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:y.GET_COLLECTIONS})})},po=()=>{const{data:e}=Z(),{data:t}=ue(),{data:s}=Ae(),n=j(),r=L(),a=h.useMemo(()=>(s==null?void 0:s.fallbackLang)||"en",[s==null?void 0:s.fallbackLang]);return T.useMutation({mutationFn:async({block:i})=>r(n,{action:y.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}}})})},Un=()=>{const[,e]=te();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])},Mn=()=>{const e=Un();return h.useCallback(({pageId:t})=>{e(t)},[e])},yo=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-BGyKKd_6.cjs"))),Ao=h.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-DNK4GPNw.cjs"))),So=h.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-Bj2yHtxO.cjs"))),To=h.lazy(()=>Promise.resolve().then(()=>require("./web-preview-BcULgiw_.cjs")));mo();zn.loadWebBlocks();C.registerChaiTopBar(ta);_a();C.registerChaiMediaManager(yo);C.registerChaiSaveToLibrary(Ao);const Po={role:"",permissions:null},Cs=e=>{fa(),ur();const t=Ot(),{data:s=Po,isFetching:n}=Vs(),{data:r,isFetching:a}=de(),{data:i,isFetching:l}=Eo(),{data:c,isFetching:d}=Ae(),f=n||a||l||d,[u]=te(),g=u.get("page"),{data:E}=Z(),{data:S,isFetching:P}=aa(),{blocks:_}=ra(S),{lockingStatus:A,pageLock:x}=Se(),{data:D,isFetching:q}=Ks(),V=sa(),{onSave:O}=ha(),{mutateAsync:oe}=po(),{getPartialBlocks:le,getPartialBlockBlocks:U}=ga(),{mutateAsync:I}=xr(),{mutateAsync:N}=Hs(),W=Mn(),[Q,ne]=h.useState(!1),Qe=h.useRef([]),he=h.useMemo(()=>p.get(c,"theme",{})||{},[c]),ze=p.isEmpty(A)&&(x==null?void 0:x.status)==="editing",Te=(x==null?void 0:x.status)==="checking",hs=P||Te||q;Qe.current=_;const[Fn]=H.useAtom(Rn);h.useEffect(()=>{const re=()=>{document.hidden?ne(!0):ne(!1)};return window.addEventListener("visibilitychange",re),()=>window.removeEventListener("visibilitychange",re)},[]);const qn=h.useMemo(()=>{const re={};return s&&(re.permissions=p.get(s,"permissions",null),re.role=p.get(s,"role","user")),re},[s]),Kn=h.useCallback(async(re,pt)=>await I({pageType:re,query:pt}),[I]);return o.jsxs(o.Fragment,{children:[hs&&o.jsx(os,{className:f?"fixed inset-0 bg-white":"bg-white/75",children:o.jsx(v.Loader,{className:`animate-spin text-primary ${f?"h-6 w-6":"h-5 w-5"}`})}),Fn&&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(v.Loader,{className:"h-6 w-6 animate-spin text-primary"})}),children:o.jsx(To,{})}),o.jsx(C.ChaiBuilderEditor,{gotoPage:W,collections:i??[],getBlockAsyncProps:oe,pageExternalData:D,themePresets:e.themePresets??[],pageId:E==null?void 0:E.id,loading:P,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:!Q&&ze&&(e.autoSave??!0),autoSaveInterval:e.autoSaveInterval??15,onError:e.onError||console.error,getPartialBlockBlocks:U,getPartialBlocks:le,blocks:P?[]:_,theme:p.cloneDeep(he),pageTypes:r,searchPageTypeItems:Kn,askAiCallBack:V,onSave:async({blocks:re,theme:pt,needTranslations:Hn})=>{if(!g)return!0;Qe.current=re;const gs=[...re];return await O({page:g,blocks:gs,needTranslations:Hn}),Qe.current=gs,p.isEqual(pt,he)||await N({settings:{theme:pt}}),!0},themePanelComponent:So,...qn}),o.jsxs("div",{children:[o.jsx(hr,{isFetchingPage:hs}),o.jsx(gr,{})]})]})},_o=new T.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),xo=e=>{const[,t]=Dt(),[s,n]=h.useState(!1);return h.useEffect(()=>(t(p.pick(e,["apiUrl","usersApiUrl","assetsApiUrl","getPreviewUrl","getLiveUrl","topLeftCorner","onLogout","getAccessToken","websocket","getLoggedInUser","features","currentUser"])),setTimeout(()=>{n(!0)},200),()=>{n(!1),t({})}),[e,t]),s?p.get(e,"hasReactQueryProvider",!1)===!0?o.jsxs(o.Fragment,{children:[o.jsx(Cs,{...e}),o.jsx(bs,{})]}):o.jsxs(T.QueryClientProvider,{client:_o,children:[o.jsx(Cs,{...e}),o.jsx(bs,{})]}):o.jsx("div",{})},wo=z.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-D_iF9Sm3.cjs")));function Bn({data:e,onSelect:t,dataType:s="value",disabled:n=!1}){const[r,a]=z.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(z.Suspense,{children:o.jsx(wo,{data:e,onSelect:t,dataType:s,open:r,setOpen:a})})]})}const vo=()=>{const{savePageAsync:e}=C.useSavePage(),t=T.useQueryClient();return h.useCallback(async()=>{await e(),t.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]})},[e,t])},bo=()=>{const e=T.useQueryClient();return h.useCallback(()=>{e.clear()},[e])},Co=()=>{const e=j(),t=L(),{data:s}=ue(),n=T.useQueryClient();return T.useMutation({mutationFn:async r=>{if(!(s!=null&&s.id))throw new Error("No active page found");return await t(`${e}`,{action:y.UPDATE_PAGE_METADATA,data:{id:s.id,metadata:r}})},onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]}),n.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]})},onError:()=>{console.error("Failed to update metadata")}})},Io=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-BGyKKd_6.cjs"))),Lo=({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)},d=()=>{l(!1)},f=E=>{const S=Array.isArray(E)?E[0]:E;S!=null&&S.url&&s(p.pick(S,["url","id"])),l(!1)},u=()=>{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:u,disabled:a,children:g?o.jsx(v.X,{className:"h-4 w-4"}):o.jsx(v.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(v.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(v.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:d,children:o.jsx(v.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"h-full flex-1 p-4",children:o.jsx(h.Suspense,{children:o.jsx(Io,{close:d,onSelect:f,mode:"image",assetId:e})})})]})})]})},No=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),es=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 d,f;if(c!==void 0){const u=n.substring(0,c).split(`
|
|
2
|
-
`);d=u.length,f=u[u.length-1].length+1}return{isValid:!1,parsed:null,placeholders:s,error:{message:i.message,line:d,column:f,position:c}}}},Go=(e,t)=>{let n=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const i=`"__placeholder_${a}__"`,l=new RegExp(No(i),"g");n=n.replace(l,r)}),n},Do=(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},ko=h.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-_ozYsSHn.cjs"))),jo=({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:d,copyJsonLDFromDefaultPage:f})=>{const[u,g]=h.useState("edit"),[E,S]=h.useState(null),[P,_]=h.useState(""),A=h.useRef(null),[x]=Dt(),D=i==="jsonLD"&&p.get(x,"features.sharedJsonLD",!1),q=i==="jsonLD"&&!d&&!!f;h.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const V=U=>{if(n)return;const I=U.target.value;t(I)},O=U=>{if(U.key==="Tab"){U.preventDefault();const I=U.currentTarget,N=I.selectionStart,W=I.selectionEnd;if(N!==W){const ne=e.substring(N,W).split(`
|
|
3
|
-
`);if(U.shiftKey){const he=ne.map(Te=>Te.startsWith(" ")?Te.substring(2):Te).join(`
|
|
4
|
-
`),ze=e.substring(0,N)+he+e.substring(W);t(ze),setTimeout(()=>{I.selectionStart=N,I.selectionEnd=N+he.length},0)}else{const he=ne.map(Te=>` ${Te}`).join(`
|
|
5
|
-
`),ze=e.substring(0,N)+he+e.substring(W);t(ze),setTimeout(()=>{I.selectionStart=N,I.selectionEnd=N+he.length},0)}}else{const Q=e.substring(0,N)+" "+e.substring(W);t(Q),setTimeout(()=>{I.selectionStart=I.selectionEnd=N+2},0)}}};h.useEffect(()=>{const U=es(e);if(U.isValid)if(S(null),U.parsed){const I=Do(U.parsed,l);_(I)}else _("");else S(U.error),_("")},[e,l]);const oe=()=>{const U=es(e);if(U.isValid&&U.parsed){const I=Go(U.parsed,U.placeholders);t(I)}},le=()=>{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:u,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(v.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||q,children:[o.jsx(v.Eye,{className:"h-4 w-4"}),o.jsx("span",{children:"Preview"})]}),D&&o.jsxs(m.TabsTrigger,{value:"shared",className:"flex items-center gap-1",disabled:!e.trim()||E!==null,children:[o.jsx(v.Share2,{className:"h-4 w-4"}),o.jsx("span",{children:"Shared"})]})]}),q?null:u==="edit"&&!n&&o.jsx("div",{className:"flex items-center gap-2",children:o.jsx(Bn,{dataType:"value",data:l??{},onSelect:U=>c&&c(U,i)})})]}),o.jsxs(m.TabsContent,{value:"edit",className:"relative mt-0",children:[!q&&u==="edit"&&o.jsx(Rt,{content:"Format JSON",side:"right",showTooltip:!s&&!E,children:o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",onClick:oe,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||s||E!==null,children:o.jsx(v.FileCode2,{})})}),q?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(v.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:V,onKeyDown:O,value:e,placeholder:r,rows:a,disabled:s,readOnly:n}),E&&o.jsxs(m.Alert,{variant:"destructive",className:"mt-2",children:[o.jsx(v.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:le,children:"Show position"})]})]})]}),o.jsxs(m.TabsContent,{value:"preview",className:"mt-0",children:[o.jsx(m.Textarea,{rows:a,value:P,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."})]}),D&&o.jsx(m.TabsContent,{value:"shared",className:"mt-0",children:o.jsx(h.Suspense,{children:o.jsx(ko,{})})})]})})},Oo=()=>{const e=ee("getAccessToken");return{getAccessToken:h.useCallback(async()=>{try{return await e()}catch{return""}},[e])}},Ro=()=>{const{logout:e}=He(),{getAccessToken:t}=Oo();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=ls;exports.ACTIONS=y;exports.BlurContainer=os;exports.CONTENT=Y;exports.ChaiBuilderPages=xo;exports.ChaiBuilderPagesRealtime=Ds;exports.Dynamic=Si;exports.For=Va;exports.ImagePicker=Lo;exports.Index=Qa;exports.LANGUAGES=$e;exports.LanguageSwitcher=Ms;exports.Match=Wa;exports.NestedPathSelector=Bn;exports.PAGES_PERMISSIONS=se;exports.PageActionsDropdown=Fs;exports.PermissionChecker=Tt;exports.Portal=yi;exports.Show=za;exports.SmartJsonInput=jo;exports.Switch=$a;exports.Tooltip=Rt;exports.addEventListener=gn;exports.addNewLangAtom=jt;exports.batch=Ca;exports.className=hn;exports.clearDelegatedEvents=li;exports.convertRemToPixels=lo;exports.createComponent=ds;exports.createComputed=Zs;exports.createContext=Da;exports.createEffect=cs;exports.createMemo=$;exports.createRenderEffect=Ee;exports.createRoot=me;exports.createSignal=K;exports.createUniqueId=Ha;exports.delegateEvents=fn;exports.deleteNestedDataByPath=Je;exports.displayValue=so;exports.getMutationStatusColor=eo;exports.getPreferredColorScheme=co;exports.getQueryStatusColor=Zi;exports.getQueryStatusColorByLabel=to;exports.getQueryStatusLabel=Ji;exports.getSidedProp=Xi;exports.insert=Gt;exports.memo=ai;exports.mergeProps=fs;exports.mutationSortFns=oo;exports.navigateToPage=rs;exports.on=Ia;exports.onCleanup=qe;exports.onMount=en;exports.parseJSONWithPlaceholders=es;exports.previewUrlAtom=Rn;exports.serialize=Dn;exports.setAttribute=Nt;exports.sortFns=ao;exports.splitProps=ln;exports.spread=mn;exports.stringify=Yi;exports.template=oi;exports.throwConfetti=Pt;exports.untrack=J;exports.updateNestedDataByPath=Ye;exports.use=En;exports.useActivePage=ue;exports.useAddGlobalSchema=ia;exports.useApiUrl=j;exports.useApplySchemaToAllPages=ua;exports.useAssetsApiUrl=Yn;exports.useBuilderPageData=Ks;exports.useChaiAuth=He;exports.useChaiFetch=Ro;exports.useChaiUserInfo=Os;exports.useChangePage=Un;exports.useChangeSlug=Nr;exports.useClearAll=bo;exports.useContext=ka;exports.useCreatePage=wr;exports.useCurrentPage=Z;exports.useDeleteGlobalSchema=la;exports.useDeletePage=br;exports.useDynamicPageSelector=js;exports.useFallbackLang=Ot;exports.useFetch=L;exports.useGotoPage=Mn;exports.useIsLanguagePageCreated=ts;exports.useLanguagePages=ye;exports.useMarkAsTemplate=Ir;exports.usePageEditInfo=kt;exports.usePageLockRequestTakeOver=Rs;exports.usePageType=Bs;exports.usePageTypes=de;exports.usePageUserMapping=cr;exports.usePagesProps=Dt;exports.usePublishPages=is;exports.useReloadPage=vo;exports.useRemoveSchemaFromAllPages=da;exports.useSearchParams=te;exports.useTogglePageGlobalSchema=ca;exports.useTransition=Ga;exports.useUnmarkAsTemplate=Lr;exports.useUnpublishPage=Cr;exports.useUpdateActivePageMetadata=Co;exports.useUpdateGlobalSchema=oa;exports.useUpdatePage=vr;exports.useUpdateWebsiteSettings=Hs;exports.useUserRoleAndPermissions=Vs;exports.useWebsiteLanguagePages=mr;exports.useWebsitePages=as;exports.useWebsiteSetting=Ae;
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import { jsx as e, jsxs as s, Fragment as $ } from "react/jsx-runtime";
|
|
2
|
-
import { ao as M, h as k, L as I, ap as j, g as F, aq as H, e as O, ar as g, as as c, C as x } from "./index-BuXZJnGo.js";
|
|
3
|
-
import { Dialog as W, DialogContent as B, DialogHeader as q, DialogTitle as R, DialogDescription as J, Alert as K, Label as Q, Input as V, DialogFooter as X, Button as A, DropdownMenu as Y, DropdownMenuTrigger as Z, DropdownMenuContent as ee, DropdownMenuItem as b } from "@chaibuilder/sdk/ui";
|
|
4
|
-
import { find as G, startsWith as w, isEqual as se, filter as ae, get as D, map as le, isEmpty as ne } from "lodash-es";
|
|
5
|
-
import { AlertCircle as te, StarIcon as ie, MoreHorizontal as re, PencilIcon as ce, Power as oe, TrashIcon as de } from "lucide-react";
|
|
6
|
-
import { useState as S, lazy as U, useMemo as me, Suspense as L } from "react";
|
|
7
|
-
import { toast as ue } from "sonner";
|
|
8
|
-
import { useLanguages as he } from "@chaibuilder/sdk";
|
|
9
|
-
import { useAtom as ge } from "jotai";
|
|
10
|
-
const pe = ({
|
|
11
|
-
page: a,
|
|
12
|
-
onClose: p
|
|
13
|
-
}) => {
|
|
14
|
-
const [t, v] = S(a.slug || ""), { mutate: N, isPending: f } = M(), { data: n } = k(), i = G(n, { key: a == null ? void 0 : a.pageType }), y = (d) => {
|
|
15
|
-
if (d.preventDefault(), !(a != null && a.primaryPage) && Object.keys(I).some((h) => t === `/${h}` || w(t, `/${h}/`))) {
|
|
16
|
-
ue.error("Error", {
|
|
17
|
-
description: "Slugs cannot start with a language code for primary page"
|
|
18
|
-
});
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
N({ ...a, slug: t }, { onSuccess: p });
|
|
22
|
-
}, o = (a == null ? void 0 : a.lang) || "";
|
|
23
|
-
return /* @__PURE__ */ e(W, { open: !!a, onOpenChange: p, children: /* @__PURE__ */ s(B, { children: [
|
|
24
|
-
/* @__PURE__ */ s(q, { children: [
|
|
25
|
-
/* @__PURE__ */ e(R, { children: "Change Slug" }),
|
|
26
|
-
/* @__PURE__ */ e(J, { className: "text-xs", children: /* @__PURE__ */ s(K, { variant: "destructive", className: "mt-2", children: [
|
|
27
|
-
/* @__PURE__ */ e(te, { className: "h-4 w-4" }),
|
|
28
|
-
"Changing the slug may have impact on your SEO. Please proceed with caution."
|
|
29
|
-
] }) })
|
|
30
|
-
] }),
|
|
31
|
-
/* @__PURE__ */ s("form", { onSubmit: y, children: [
|
|
32
|
-
/* @__PURE__ */ s("div", { className: "space-y-4 py-4 text-sm ", children: [
|
|
33
|
-
/* @__PURE__ */ s("div", { className: "space-y-1", children: [
|
|
34
|
-
/* @__PURE__ */ s("div", { children: [
|
|
35
|
-
/* @__PURE__ */ e("span", { children: "Type:" }),
|
|
36
|
-
/* @__PURE__ */ s("span", { className: "font-medium text-gray-600", children: [
|
|
37
|
-
" ",
|
|
38
|
-
(i == null ? void 0 : i.name) || (a == null ? void 0 : a.pageType)
|
|
39
|
-
] })
|
|
40
|
-
] }),
|
|
41
|
-
/* @__PURE__ */ s("div", { children: [
|
|
42
|
-
/* @__PURE__ */ e("span", { children: "Name:" }),
|
|
43
|
-
/* @__PURE__ */ s("span", { className: "font-medium text-gray-600", children: [
|
|
44
|
-
" ",
|
|
45
|
-
a.name
|
|
46
|
-
] })
|
|
47
|
-
] })
|
|
48
|
-
] }),
|
|
49
|
-
/* @__PURE__ */ s("div", { className: "space-y-1", children: [
|
|
50
|
-
/* @__PURE__ */ s(Q, { htmlFor: "slug", className: "text-right", children: [
|
|
51
|
-
"Slug",
|
|
52
|
-
" ",
|
|
53
|
-
/* @__PURE__ */ s("small", { className: "font-light text-gray-500", children: [
|
|
54
|
-
"Slug should start with /",
|
|
55
|
-
o
|
|
56
|
-
] })
|
|
57
|
-
] }),
|
|
58
|
-
/* @__PURE__ */ e(
|
|
59
|
-
V,
|
|
60
|
-
{
|
|
61
|
-
id: "slug",
|
|
62
|
-
value: t,
|
|
63
|
-
onChange: (d) => {
|
|
64
|
-
const m = d.target.value;
|
|
65
|
-
w(m, `/${o}`) && v(m);
|
|
66
|
-
},
|
|
67
|
-
className: "col-span-3",
|
|
68
|
-
required: !0,
|
|
69
|
-
pattern: "^/.*",
|
|
70
|
-
title: "Slug must start with /",
|
|
71
|
-
placeholder: "Enter page slug"
|
|
72
|
-
}
|
|
73
|
-
)
|
|
74
|
-
] })
|
|
75
|
-
] }),
|
|
76
|
-
/* @__PURE__ */ e(X, { children: /* @__PURE__ */ e(
|
|
77
|
-
A,
|
|
78
|
-
{
|
|
79
|
-
type: "submit",
|
|
80
|
-
disabled: f || !w(t, `/${o}`) || se(a == null ? void 0 : a.slug, t),
|
|
81
|
-
children: f ? "Changing..." : "Change Slug"
|
|
82
|
-
}
|
|
83
|
-
) })
|
|
84
|
-
] })
|
|
85
|
-
] }) });
|
|
86
|
-
}, Ne = U(() => import("./delete-page-CXRJjJ4o.js")), fe = U(() => import("./unpublish-page-BTPEVAkv.js")), Ae = () => {
|
|
87
|
-
const [, a] = ge(j), { selectedLang: p, fallbackLang: t, setSelectedLang: v } = he(), { data: N, isFetching: f } = F(), { data: n } = H(), { data: i } = k(), y = me(() => {
|
|
88
|
-
const l = i == null ? void 0 : i.find((u) => u.key === (n == null ? void 0 : n.pageType));
|
|
89
|
-
return n != null && n.dynamic ? l == null ? void 0 : l.dynamicSlug : "";
|
|
90
|
-
}, [i, n == null ? void 0 : n.pageType, n == null ? void 0 : n.dynamic]), [o, d] = S(null), [m, C] = S(null), [h, _] = S(null), { data: P } = O(), z = ae(
|
|
91
|
-
D(P, "languages") || ["en"],
|
|
92
|
-
(l) => !G(N, { lang: l }) && l !== D(P, "fallbackLang")
|
|
93
|
-
);
|
|
94
|
-
return /* @__PURE__ */ s("div", { className: "space-y-4", children: [
|
|
95
|
-
/* @__PURE__ */ e("ul", { className: "space-y-2", children: f ? /* @__PURE__ */ s("div", { className: "w-full space-y-3 py-4", children: [
|
|
96
|
-
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
|
|
97
|
-
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
|
|
98
|
-
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" })
|
|
99
|
-
] }) : le(N, (l) => {
|
|
100
|
-
const u = l.lang, E = l.slug, T = !l.primaryPage;
|
|
101
|
-
return /* @__PURE__ */ s($, { children: [
|
|
102
|
-
/* @__PURE__ */ s(
|
|
103
|
-
"li",
|
|
104
|
-
{
|
|
105
|
-
className: `flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${u === p ? "bg-gray-200" : "hover:bg-gray-100"}`,
|
|
106
|
-
onClick: () => v(u),
|
|
107
|
-
children: [
|
|
108
|
-
/* @__PURE__ */ s("div", { className: "flex-1 gap-x-3", children: [
|
|
109
|
-
/* @__PURE__ */ s("div", { className: "flex items-center gap-x-2 text-[13px] text-slate-800", children: [
|
|
110
|
-
/* @__PURE__ */ e("div", { className: `h-2.5 w-2.5 rounded-full ${l.online ? "bg-green-300" : "bg-gray-300"}` }),
|
|
111
|
-
D(I, T ? t : u, u)
|
|
112
|
-
] }),
|
|
113
|
-
/* @__PURE__ */ s("div", { children: [
|
|
114
|
-
E && /* @__PURE__ */ s("div", { className: "text-[11px] font-light text-slate-600", children: [
|
|
115
|
-
"Slug: ",
|
|
116
|
-
/* @__PURE__ */ e("b", { className: "font-mono font-medium", children: y ? `${E}/${y}` : E })
|
|
117
|
-
] }),
|
|
118
|
-
/* @__PURE__ */ s("div", { className: "text-[11px] font-light text-slate-600", children: [
|
|
119
|
-
"Name:",
|
|
120
|
-
/* @__PURE__ */ s("b", { className: "font-medium", children: [
|
|
121
|
-
" ",
|
|
122
|
-
l.name,
|
|
123
|
-
" "
|
|
124
|
-
] })
|
|
125
|
-
] })
|
|
126
|
-
] })
|
|
127
|
-
] }),
|
|
128
|
-
T ? /* @__PURE__ */ s("div", { className: "flex items-center gap-x-1 text-[11px] text-orange-500", children: [
|
|
129
|
-
/* @__PURE__ */ e(ie, { fill: "orange", className: "h-3 w-3" }),
|
|
130
|
-
/* @__PURE__ */ e("b", { children: " Primary" })
|
|
131
|
-
] }) : /* @__PURE__ */ e("div", { className: "flex items-center gap-x-3", children: /* @__PURE__ */ e(
|
|
132
|
-
g,
|
|
133
|
-
{
|
|
134
|
-
permissions: [
|
|
135
|
-
c.EDIT_PAGE,
|
|
136
|
-
c.DELETE_PAGE,
|
|
137
|
-
c.UNPUBLISH_PAGE
|
|
138
|
-
],
|
|
139
|
-
children: /* @__PURE__ */ s(Y, { children: [
|
|
140
|
-
/* @__PURE__ */ e(Z, { asChild: !0, onClick: (r) => r.stopPropagation(), children: /* @__PURE__ */ e(A, { variant: "ghost", size: "sm", className: "h-8 w-8 p-0", children: /* @__PURE__ */ e(re, { className: "h-4 w-4" }) }) }),
|
|
141
|
-
/* @__PURE__ */ s(ee, { align: "end", className: "z-[9999] text-sm", children: [
|
|
142
|
-
/* @__PURE__ */ e(g, { permissions: [c.EDIT_PAGE], children: /* @__PURE__ */ s(
|
|
143
|
-
b,
|
|
144
|
-
{
|
|
145
|
-
className: "flex cursor-pointer items-center gap-2",
|
|
146
|
-
onClick: (r) => {
|
|
147
|
-
r.stopPropagation(), a({
|
|
148
|
-
edit: !0,
|
|
149
|
-
id: l.id,
|
|
150
|
-
primaryPage: l.primaryPage
|
|
151
|
-
});
|
|
152
|
-
},
|
|
153
|
-
children: [
|
|
154
|
-
/* @__PURE__ */ e(ce, { className: "size-3" }),
|
|
155
|
-
x.EDIT
|
|
156
|
-
]
|
|
157
|
-
}
|
|
158
|
-
) }),
|
|
159
|
-
/* @__PURE__ */ e(g, { permissions: [c.UNPUBLISH_PAGE], children: (l == null ? void 0 : l.online) && /* @__PURE__ */ s(
|
|
160
|
-
b,
|
|
161
|
-
{
|
|
162
|
-
className: "flex cursor-pointer items-center gap-2",
|
|
163
|
-
onClick: (r) => {
|
|
164
|
-
r.stopPropagation(), C(l);
|
|
165
|
-
},
|
|
166
|
-
children: [
|
|
167
|
-
/* @__PURE__ */ e(oe, { className: "size-3" }),
|
|
168
|
-
x.UNPUBLISH
|
|
169
|
-
]
|
|
170
|
-
}
|
|
171
|
-
) }),
|
|
172
|
-
/* @__PURE__ */ e(g, { permissions: [c.DELETE_PAGE], children: /* @__PURE__ */ s(
|
|
173
|
-
b,
|
|
174
|
-
{
|
|
175
|
-
className: "flex cursor-pointer items-center gap-2",
|
|
176
|
-
onClick: (r) => {
|
|
177
|
-
r.stopPropagation(), d(l);
|
|
178
|
-
},
|
|
179
|
-
children: [
|
|
180
|
-
/* @__PURE__ */ e(de, { className: "size-3" }),
|
|
181
|
-
x.DELETE
|
|
182
|
-
]
|
|
183
|
-
}
|
|
184
|
-
) })
|
|
185
|
-
] })
|
|
186
|
-
] })
|
|
187
|
-
}
|
|
188
|
-
) })
|
|
189
|
-
]
|
|
190
|
-
},
|
|
191
|
-
l.id
|
|
192
|
-
),
|
|
193
|
-
/* @__PURE__ */ e("div", { className: "h-1 w-full border-b" })
|
|
194
|
-
] });
|
|
195
|
-
}) }),
|
|
196
|
-
/* @__PURE__ */ e(g, { permissions: [c.ADD_PAGE], children: /* @__PURE__ */ e("div", { className: "flex w-full justify-center", children: /* @__PURE__ */ e(
|
|
197
|
-
A,
|
|
198
|
-
{
|
|
199
|
-
variant: "default",
|
|
200
|
-
size: "sm",
|
|
201
|
-
disabled: ne(z),
|
|
202
|
-
onClick: () => {
|
|
203
|
-
a({
|
|
204
|
-
primaryPage: n == null ? void 0 : n.id,
|
|
205
|
-
edit: !1
|
|
206
|
-
});
|
|
207
|
-
},
|
|
208
|
-
children: x.ADD_NEW_LANGUAGE
|
|
209
|
-
}
|
|
210
|
-
) }) }),
|
|
211
|
-
o && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(Ne, { page: o, onClose: () => d(null) }) }),
|
|
212
|
-
m && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(fe, { page: m, onClose: () => C(null) }) }),
|
|
213
|
-
h && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(pe, { page: h, onClose: () => _(null) }) })
|
|
214
|
-
] });
|
|
215
|
-
};
|
|
216
|
-
export {
|
|
217
|
-
Ae as default
|
|
218
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-Cds1vIhw.cjs"),i=require("@chaibuilder/sdk/ui"),a=require("lodash-es"),g=require("lucide-react"),r=require("react"),w=require("sonner"),D=require("@chaibuilder/sdk"),T=require("jotai"),L=({page:n,onClose:S})=>{const[c,y]=r.useState(n.slug||""),{mutate:N,isPending:p}=s.useChangeSlug(),{data:l}=s.usePageTypes(),o=a.find(l,{key:n==null?void 0:n.pageType}),E=m=>{if(m.preventDefault(),!(n!=null&&n.primaryPage)&&Object.keys(s.LANGUAGES).some(j=>c===`/${j}`||a.startsWith(c,`/${j}/`))){w.toast.error("Error",{description:"Slugs cannot start with a language code for primary page"});return}N({...n,slug:c},{onSuccess:S})},u=(n==null?void 0:n.lang)||"";return e.jsx(i.Dialog,{open:!!n,onOpenChange:S,children:e.jsxs(i.DialogContent,{children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Change Slug"}),e.jsx(i.DialogDescription,{className:"text-xs",children:e.jsxs(i.Alert,{variant:"destructive",className:"mt-2",children:[e.jsx(g.AlertCircle,{className:"h-4 w-4"}),"Changing the slug may have impact on your SEO. Please proceed with caution."]})})]}),e.jsxs("form",{onSubmit:E,children:[e.jsxs("div",{className:"space-y-4 py-4 text-sm ",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Type:"}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(o==null?void 0:o.name)||(n==null?void 0:n.pageType)]})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Name:"}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",n.name]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(i.Label,{htmlFor:"slug",className:"text-right",children:["Slug"," ",e.jsxs("small",{className:"font-light text-gray-500",children:["Slug should start with /",u]})]}),e.jsx(i.Input,{id:"slug",value:c,onChange:m=>{const h=m.target.value;a.startsWith(h,`/${u}`)&&y(h)},className:"col-span-3",required:!0,pattern:"^/.*",title:"Slug must start with /",placeholder:"Enter page slug"})]})]}),e.jsx(i.DialogFooter,{children:e.jsx(i.Button,{type:"submit",disabled:p||!a.startsWith(c,`/${u}`)||a.isEqual(n==null?void 0:n.slug,c),children:p?"Changing...":"Change Slug"})})]})]})})},G=r.lazy(()=>Promise.resolve().then(()=>require("./delete-page-w64MO7db.cjs"))),k=r.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-gtGfNOAq.cjs"))),M=()=>{const[,n]=T.useAtom(s.addNewLangAtom),{selectedLang:S,fallbackLang:c,setSelectedLang:y}=D.useLanguages(),{data:N,isFetching:p}=s.useLanguagePages(),{data:l}=s.useCurrentPage(),{data:o}=s.usePageTypes(),E=r.useMemo(()=>{const t=o==null?void 0:o.find(x=>x.key===(l==null?void 0:l.pageType));return l!=null&&l.dynamic?t==null?void 0:t.dynamicSlug:""},[o,l==null?void 0:l.pageType,l==null?void 0:l.dynamic]),[u,m]=r.useState(null),[h,f]=r.useState(null),[j,b]=r.useState(null),{data:C}=s.useWebsiteSetting(),A=a.filter(a.get(C,"languages")||["en"],t=>!a.find(N,{lang:t})&&t!==a.get(C,"fallbackLang"));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ul",{className:"space-y-2",children:p?e.jsxs("div",{className:"w-full space-y-3 py-4",children:[e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"})]}):a.map(N,t=>{const x=t.lang,P=t.slug,v=!t.primaryPage,I=x===S;return e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:`flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${I?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>y(x),children:[e.jsxs("div",{className:"flex-1 gap-x-3",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-[13px] text-slate-800",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),a.get(s.LANGUAGES,v?c:x,x)]}),e.jsxs("div",{children:[P&&e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Slug: ",e.jsx("b",{className:"font-mono font-medium",children:E?`${P}/${E}`:P})]}),e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Name:",e.jsxs("b",{className:"font-medium",children:[" ",t.name," "]})]})]})]}),v?e.jsxs("div",{className:"flex items-center gap-x-1 text-[11px] text-orange-500",children:[e.jsx(g.StarIcon,{fill:"orange",className:"h-3 w-3"}),e.jsx("b",{children:" Primary"})]}):e.jsx("div",{className:"flex items-center gap-x-3",children:e.jsx(s.PermissionChecker,{permissions:[s.PAGES_PERMISSIONS.EDIT_PAGE,s.PAGES_PERMISSIONS.DELETE_PAGE,s.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,onClick:d=>d.stopPropagation(),children:e.jsx(i.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(g.MoreHorizontal,{className:"h-4 w-4"})})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"z-[9999] text-sm",children:[e.jsx(s.PermissionChecker,{permissions:[s.PAGES_PERMISSIONS.EDIT_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:d=>{d.stopPropagation(),n({edit:!0,id:t.id,primaryPage:t.primaryPage})},children:[e.jsx(g.PencilIcon,{className:"size-3"}),s.CONTENT.EDIT]})}),e.jsx(s.PermissionChecker,{permissions:[s.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:(t==null?void 0:t.online)&&e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:d=>{d.stopPropagation(),f(t)},children:[e.jsx(g.Power,{className:"size-3"}),s.CONTENT.UNPUBLISH]})}),e.jsx(s.PermissionChecker,{permissions:[s.PAGES_PERMISSIONS.DELETE_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:d=>{d.stopPropagation(),m(t)},children:[e.jsx(g.TrashIcon,{className:"size-3"}),s.CONTENT.DELETE]})})]})]})})})]},t.id),e.jsx("div",{className:"h-1 w-full border-b"})]})})}),e.jsx(s.PermissionChecker,{permissions:[s.PAGES_PERMISSIONS.ADD_PAGE],children:e.jsx("div",{className:"flex w-full justify-center",children:e.jsx(i.Button,{variant:"default",size:"sm",disabled:a.isEmpty(A),onClick:()=>{n({primaryPage:l==null?void 0:l.id,edit:!1})},children:s.CONTENT.ADD_NEW_LANGUAGE})})}),u&&e.jsx(r.Suspense,{children:e.jsx(G,{page:u,onClose:()=>m(null)})}),h&&e.jsx(r.Suspense,{children:e.jsx(k,{page:h,onClose:()=>f(null)})}),j&&e.jsx(r.Suspense,{children:e.jsx(L,{page:j,onClose:()=>b(null)})})]})};exports.default=M;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./index-Cds1vIhw.cjs"),s=require("@chaibuilder/sdk/ui"),b=require("lodash-es"),o=require("lucide-react"),i=require("react"),y=require("sonner"),S=1*1024*1024,M=({page:n,onClose:d})=>{const[h,m]=i.useState(!1),[g,w]=i.useState(""),[l,f]=i.useState(""),[j,u]=i.useState(!1),r=i.useRef(null),k=v.useMarkAsTemplate(),{data:p}=v.usePageTypes(),x=p==null?void 0:p.find(a=>a.key===n.pageType),C=(x==null?void 0:x.name)||b.startCase(n.pageType),I=i.useCallback(a=>{var N;const c=(N=a.target.files)==null?void 0:N[0];if(c){if(c.size>S){y.toast.error("File too large",{description:`Maximum file size is 1MB. Selected file is ${(c.size/1024).toFixed(2)}KB.`}),r.current&&(r.current.value="");return}try{u(!0);const t=new FileReader;t.onloadend=()=>{f(t.result),u(!1)},t.readAsDataURL(c)}catch(t){console.error("Error reading file:",t),u(!1),y.toast.error("Failed to process image",{description:t instanceof Error?t.message:"Unknown error"})}}},[]),T=()=>{f(""),r.current&&(r.current.value="")},D=()=>{var a;(a=r.current)==null||a.click()},F=()=>{m(!0),k.mutate({page:n,name:n.name,description:g.trim()||void 0,pageType:n.pageType,...l?{previewImage:l}:{}},{onSuccess:()=>{m(!1),d()},onError:()=>{m(!1)}})};return e.jsx(s.Dialog,{open:!0,onOpenChange:d,children:e.jsxs(s.DialogContent,{children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Mark as template"}),e.jsxs(s.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:["Are you sure you want to mark this page as a template?",e.jsx("br",{}),"Templates can be used to create new pages with the same content."]})]}),e.jsxs("div",{className:"mb-4 space-y-4 text-xs",children:[e.jsxs("div",{className:"space-y-3 rounded border bg-slate-50 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o.Tag,{className:"h-4 w-4 text-slate-500"}),e.jsx("span",{className:"font-medium text-slate-500",children:"Page Name:"}),e.jsx("span",{className:"font-semibold",children:b.startCase(n.name)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o.File,{className:"h-4 w-4 text-slate-500"}),e.jsx("span",{className:"font-medium text-slate-500",children:"Type:"}),e.jsx("span",{className:"font-semibold",children:C})]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"description",className:"text-xs font-medium",children:"Description (Optional)"}),e.jsx(s.Textarea,{id:"description",placeholder:"Describe this template's purpose",className:"mt-1 h-24 resize-none text-xs",value:g,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{htmlFor:"previewImage",className:"text-xs font-medium",children:"Preview Image (Optional)"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Input,{type:"file",id:"previewImage",ref:r,onChange:I,accept:"image/*",className:"hidden"}),e.jsx(s.Button,{type:"button",variant:"outline",onClick:D,disabled:j,className:"w-full",children:j?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(o.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),l&&e.jsx(s.Button,{type:"button",variant:"outline",size:"icon",onClick:T,children:e.jsx(o.X,{className:"h-4 w-4"})})]}),l&&e.jsx("div",{className:"aspect-video overflow-hidden rounded-md border",children:e.jsx("img",{src:l,alt:"Preview",className:"h-full max-h-[200px] w-full object-contain"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"max 1mb"})]})]})]}),e.jsxs(s.DialogFooter,{className:h?"pointer-events-none opacity-75":"",children:[e.jsx(s.Button,{variant:"outline",onClick:a=>{a.stopPropagation(),d()},children:"Cancel"}),e.jsx(s.Button,{variant:"default",disabled:h,onClick:F,children:"Mark as template"})]})]})})};exports.default=M;
|