@chaibuilder/sdk 4.0.0-beta.21 → 4.0.0-beta.23
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/{2SSKDMRQ-BqJwQTJP.cjs → 2SSKDMRQ-DVWVGtU8.cjs} +1 -1
- package/dist/{2SSKDMRQ-K_lVxLR7.js → 2SSKDMRQ-SUA5eA2S.js} +2 -2
- package/dist/{AP7HFJJL-Y6zxYGVM.cjs → AP7HFJJL-CUN5zddU.cjs} +1 -1
- package/dist/{AP7HFJJL-BEwHZHHc.js → AP7HFJJL-Co5bLh3I.js} +1 -1
- package/dist/{WDYDFRGG-BnH0DBnC.cjs → WDYDFRGG-BpSteEEf.cjs} +1 -1
- package/dist/{WDYDFRGG-Di67d8vj.js → WDYDFRGG-DjCIT9L-.js} +2 -2
- package/dist/{active-in-another-tab-DpQoRUmT.cjs → active-in-another-tab-C8-vpt8f.cjs} +1 -1
- package/dist/{active-in-another-tab-D6ePJu79.js → active-in-another-tab-DfRJcvAz.js} +1 -1
- package/dist/{add-new-language-page-_pqb4S0R.cjs → add-new-language-page-B2BEmfil.cjs} +1 -1
- package/dist/{add-new-language-page-B-JzDQQ0.js → add-new-language-page-jZ7Pg0Fv.js} +1 -1
- package/dist/{add-new-page-DBH5pNfJ.cjs → add-new-page-DbEBB3w7.cjs} +1 -1
- package/dist/{add-new-page-BgW7nGDL.js → add-new-page-YZF_XF8X.js} +1 -1
- package/dist/{ai-panel-content-B5vcWxUO.cjs → ai-panel-content-Bf_ojKwt.cjs} +1 -1
- package/dist/{ai-panel-content-DlRmIHbb.js → ai-panel-content-C8ecaQnv.js} +2 -2
- package/dist/{ai-panel-default-lang-BrJ73OtI.js → ai-panel-default-lang-BC8Gq_jl.js} +1 -1
- package/dist/{ai-panel-default-lang-B9Hw6Phv.cjs → ai-panel-default-lang-DokOmE_Q.cjs} +1 -1
- package/dist/{ai-panel-other-lang-wfBIM8OQ.js → ai-panel-other-lang-BJ30SL7z.js} +2 -2
- package/dist/{ai-panel-other-lang-DLM4BTyS.cjs → ai-panel-other-lang-Ccx1t8pp.cjs} +1 -1
- package/dist/{ai-translation-prompt-IEYEa0eJ.js → ai-translation-prompt-BRRzei71.js} +1 -1
- package/dist/{ai-translation-prompt-mjnE5yPb.cjs → ai-translation-prompt-spS-OC6L.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-DRIFj4Ti.cjs → continue-editing-in-this-client-B3CnmiZ2.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-C7C5lfiy.js → continue-editing-in-this-client-vICoETHN.js} +1 -1
- package/dist/{delete-page-DBK8uFLn.cjs → delete-page-D5mzl-ET.cjs} +1 -1
- package/dist/{delete-page-B2HLFxUP.js → delete-page-Dlv8srng.js} +1 -1
- package/dist/{digital-asset-manager-CHynKbGn.js → digital-asset-manager-o_bNl9qj.js} +1 -1
- package/dist/{digital-asset-manager-CiRIglzD.cjs → digital-asset-manager-v2LfDXwR.cjs} +1 -1
- package/dist/{duplicate-page-CnxmhbNs.js → duplicate-page-BjqgghN0.js} +1 -1
- package/dist/{duplicate-page-Cy438XWV.cjs → duplicate-page-CEuF8dll.cjs} +1 -1
- package/dist/{dynamic-page-selector-D6JcU__y.js → dynamic-page-selector-BWC7kHJ1.js} +1 -1
- package/dist/{dynamic-page-selector-zjKnz5wv.cjs → dynamic-page-selector-D4EWs4Qd.cjs} +1 -1
- package/dist/index-BJVYKKJq.cjs +5 -0
- package/dist/{index-Dt1_GZLJ.js → index-BvluH-oT.js} +1426 -1351
- package/dist/{json-diff-viewer-CVsMPRJ1.cjs → json-diff-viewer-BjCIlzd7.cjs} +1 -1
- package/dist/{json-diff-viewer-CGOrxXjs.js → json-diff-viewer-WX0GIjq-.js} +1 -1
- package/dist/{lang-panel-ClT8ve6W.cjs → lang-panel--yfjRDE2.cjs} +1 -1
- package/dist/{lang-panel-PMX1peUB.js → lang-panel-C4x7bcyb.js} +2 -2
- package/dist/{mark-as-template-RdAktYuH.cjs → mark-as-template-BH0W9p2G.cjs} +1 -1
- package/dist/{mark-as-template-CR8yhSbj.js → mark-as-template-DpZSFrLK.js} +1 -1
- package/dist/{no-language-page-content-DSb_CYBo.js → no-language-page-content-D0lcCseQ.js} +1 -1
- package/dist/{no-language-page-content-xHMBSnjk.cjs → no-language-page-content-D7btm8zX.cjs} +1 -1
- package/dist/{no-language-page-dialog-4peaKhJz.js → no-language-page-dialog-BdW7oXvt.js} +2 -2
- package/dist/{no-language-page-dialog-Bjbyvuda.cjs → no-language-page-dialog-sYOmLnpY.cjs} +1 -1
- package/dist/{page-creator-Bqoej-Of.cjs → page-creator-B-jBAGZl.cjs} +1 -1
- package/dist/{page-creator-DHDoEAmA.js → page-creator-O_QpbMlB.js} +1 -1
- package/dist/{page-lock-DeJdUgZb.cjs → page-lock-BrVqfmVm.cjs} +1 -1
- package/dist/{page-lock-Dh39XtpD.js → page-lock-CmQKpw1U.js} +2 -2
- package/dist/{page-locked-dialog-xkaIQrI5.js → page-locked-dialog-BjeJOXuN.js} +2 -2
- package/dist/page-locked-dialog-ChHVSk7X.cjs +1 -0
- package/dist/{page-manager-new-DVK6MAnp.cjs → page-manager-new-B90zLpRY.cjs} +1 -1
- package/dist/{page-manager-new-TbakCzvm.js → page-manager-new-wcsdorbd.js} +2 -2
- package/dist/{page-manager-search-and-filter-yUZuvidd.cjs → page-manager-search-and-filter-Bb_Zfpsj.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-MjOXc_GB.js → page-manager-search-and-filter-DY_NsetM.js} +1 -1
- package/dist/{page-revisions-content-CdBeng9g.js → page-revisions-content-5h39VYXj.js} +2 -2
- package/dist/{page-revisions-content-B7j1MkFd.cjs → page-revisions-content-CVpi-467.cjs} +1 -1
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +144 -0
- package/dist/pages.js +22 -19
- package/dist/{publish-pages-content-BdYSPXQ8.cjs → publish-pages-content-BG1GIuIz.cjs} +1 -1
- package/dist/{publish-pages-content-BjFpLMqb.js → publish-pages-content-rrfvXks4.js} +2 -2
- package/dist/{save-to-lib-ByKVoeLj.js → save-to-lib-Bm7R2K7j.js} +1 -1
- package/dist/{save-to-lib-CcFk-jmu.cjs → save-to-lib-YvzDV5ee.cjs} +1 -1
- package/dist/{selected-block-display-gWBsfJIM.js → selected-block-display-BAulh0Nz.js} +1 -1
- package/dist/{selected-block-display-B_lzmRLJ.cjs → selected-block-display-bdClAekS.cjs} +1 -1
- package/dist/{seo-panel-BIVw5O3s.js → seo-panel-CT0D3I44.js} +1 -1
- package/dist/{seo-panel-CKrfiPLx.cjs → seo-panel-D9wnaLG-.cjs} +1 -1
- package/dist/{shared-json-ld-BoG2JTtt.js → shared-json-ld-CuhqVL8H.js} +1 -1
- package/dist/{shared-json-ld-BIi5Rt26.cjs → shared-json-ld-ON6LaybZ.cjs} +1 -1
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.js +1 -1
- package/dist/{take-over-request-BDQcfLhg.js → take-over-request-BmeR6t3b.js} +3 -3
- package/dist/take-over-request-CrILj_3q.cjs +1 -0
- package/dist/{theme-panel-footer-CPfiA7BL.cjs → theme-panel-footer-BMx5lGB4.cjs} +1 -1
- package/dist/{theme-panel-footer-C2IuNUyk.js → theme-panel-footer-D4oCAY2G.js} +1 -1
- package/dist/types.d.ts +90 -0
- package/dist/{unmark-as-template--HC_u2RZ.cjs → unmark-as-template-BYiyJloZ.cjs} +1 -1
- package/dist/{unmark-as-template-CnSuJROd.js → unmark-as-template-CEEMIY1A.js} +1 -1
- package/dist/{unpublish-page-0ALLHcVy.cjs → unpublish-page-B0aY1JnO.cjs} +1 -1
- package/dist/{unpublish-page-CK-A_QKW.js → unpublish-page-Bm20P3TB.js} +1 -1
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +22 -23
- package/dist/{web-preview-CTHyfn9R.js → web-preview-BtEn4Vc-.js} +1 -1
- package/dist/{web-preview-Dga82dCu.cjs → web-preview-iQgiotU6.cjs} +1 -1
- package/package.json +1 -2
- package/dist/index-Cndn0h7y.cjs +0 -5
- package/dist/page-locked-dialog-CP34yOvv.cjs +0 -1
- package/dist/take-over-request-CqULR7_A.cjs +0 -1
package/dist/index-Cndn0h7y.cjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";var lr=Object.create;var In=Object.defineProperty;var cr=Object.getOwnPropertyDescriptor;var ur=Object.getOwnPropertyNames;var dr=Object.getPrototypeOf,fr=Object.prototype.hasOwnProperty;var Ln=e=>{throw TypeError(e)};var hr=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ur(t))!fr.call(e,r)&&r!==n&&In(e,r,{get:()=>t[r],enumerable:!(s=cr(t,r))||s.enumerable});return e};var gr=(e,t,n)=>(n=e!=null?lr(dr(e)):{},hr(t||!e||!e.__esModule?In(n,"default",{value:e,enumerable:!0}):n,e));var Nn=(e,t,n)=>t.has(e)||Ln("Cannot "+n);var w=(e,t,n)=>(Nn(e,t,"read from private field"),n?n.call(e):t.get(e)),M=(e,t,n)=>t.has(e)?Ln("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),R=(e,t,n,s)=>(Nn(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n);const o=require("react/jsx-runtime"),g=require("./index-DWGTiEak.cjs"),I=require("./register-chai-top-bar-DWTuRU53.cjs"),Q=require("jotai"),p=require("lodash-es"),h=require("react"),x=require("@tanstack/react-query"),v=require("lucide-react"),he=require("react-i18next"),mr=require("./plugin-BGlQf0iy.cjs"),Gt=require("./common-functions-B3a4xKt_.cjs"),F=require("sonner"),Er=require("./core-BWQrViOY.cjs"),pr=require("./apply-binding-nqrhHgIz.cjs"),yr=require("./web-blocks.cjs"),Ar=require("react-error-boundary");function Tr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const z=Tr(h),rt=Q.atom(null),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_FIELDS:"UPDATE_WEBSITE_FIELDS",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",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"},Sr=Q.atom({}),qt=()=>Q.useAtom(Sr),ae=(e,t)=>{const[n]=qt();return h.useMemo(()=>p.get(n,e,t),[n,e,t])},L=()=>ae("apiUrl","/chai/api"),Qn=()=>ae("websocket",null),zn=async(e,t,n={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(t)}),Pr=()=>{const e=k(),t=L();return h.useCallback(async({body:n,headers:s={},url:r=t,streamResponse:a=!1})=>e(r,n,s,a),[e])},k=()=>{const e=ae("onLogout",p.noop),t=ae("getAccessToken"),n=L();return h.useCallback(async(s=n,r,a={},i=!1)=>{const l=await t();try{const c=p.get(r,"action","").toLowerCase(),d=await zn(s+(c?`?action=${c}`:""),r,{...a,Authorization:`Bearer ${l}`});if(i)return d;if(d.status===401)return console.log("401 Response",d),await e("SESSION_EXPIRED"),null;if(!d.ok){const u=await d.json();throw console.error(`API Error (${d.status}):`,u),{status:d.status,statusText:d.statusText,...u,message:u.error||u.message||`Server error: ${d.status}`}}return await d.json()}catch(c){throw console.error("API request failed:",r,c),c}},[e,t])};function ue(){const[e,t]=h.useState(new URLSearchParams(window.location.search));return h.useEffect(()=>{const n=()=>{t(new URLSearchParams(window.location.search))};return window.addEventListener("popstate",n),()=>{window.removeEventListener("popstate",n)}},[]),[e,t]}const Se=e=>{const t=L(),[n]=ue(),s=e??n.get("page"),r=k();return x.useQuery({queryKey:[y.GET_LANGUAGE_PAGES,s],staleTime:1/0,gcTime:0,placeholderData:[],queryFn:async()=>{if(!s)return null;const a=await r(t,{action:y.GET_LANGUAGE_PAGES,data:{id:s}});return p.reverse(p.sortBy(a,"primaryPage"))},enabled:!!s})},xr=Q.atom(null),$n=()=>Q.useAtom(xr),dn=()=>{const[e]=$n();return(e==null?void 0:e.slug)||""};function _r(e,t){const[n,s]=h.useState(e);return h.useEffect(()=>{const r=setTimeout(()=>s(e),t);return()=>clearTimeout(r)},[e,t]),n}const wr=({query:e,uuid:t})=>{const{selectedLang:n,fallbackLang:s}=g.useLanguages(),{data:r}=ne(),a=r==null?void 0:r.pageType,i=L(),l=k(),{data:c,isFetching:d}=x.useQuery({queryKey:[y.GET_DYNAMIC_PAGES,e,a,t],staleTime:3600*1e3,placeholderData:[],queryFn:async()=>await l(i,{action:y.GET_DYNAMIC_PAGES,data:{query:e,pageType:a,uuid:t}})||[],enabled:!!a}),u=h.useMemo(()=>n===""?c.filter(f=>f.lang===""||f.lang===s):c.filter(f=>f.lang===n),[n,s,c]);return{allLangPages:c,data:u,isFetching:d}},Wn=()=>{const{selectedLang:e,fallbackLang:t}=g.useLanguages(),[n,s]=$n(),[r,a]=h.useState(""),i=_r(r,500),{allLangPages:l,data:c,isFetching:d}=wr({query:i}),u=h.useCallback(m=>s(m),[s]),f=h.useCallback(m=>a(m),[a]),E=h.useCallback(()=>{if(!n)return;const m=!(n!=null&&n.primaryPage),S=e.length===0,A=m?n==null?void 0:n.id:n==null?void 0:n.primaryPage,_=l.filter(T=>(T==null?void 0:T.primaryPage)===A||T.id===A).find(T=>S?T.lang===e||T.lang===t:T.lang===e);s(_||n)},[n,e,l,s,t]);return{isFetching:d,dynamicPage:n,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:u,updateSearchQuery:f,onChangeLanguage:E}},vr=Q.atom({lastSaved:void 0}),fn=()=>Q.useAtom(vr),ne=()=>{const[e]=ue(),t=e.get("page"),{data:n,isFetching:s}=Se();return{data:h.useMemo(()=>({...p.find(n,{id:t})||{}}),[n,t]),isFetching:s}},ge=()=>{const[e]=ue(),t=e.get("lang")??"",{data:n,isFetching:s}=Se();return{data:h.useMemo(()=>p.find(n,{lang:t})||{},[n,t]),isFetching:s}},br=Q.atom({}),Cr=()=>Q.useAtom(br),Ir=()=>{const{data:e}=ge(),t=dn(),n=ae("getLiveUrl",p.noop),s=e==null?void 0:e.slug,r=n(s||"/");return t?r+t:r},re={...g.PERMISSIONS,ADD_PAGE:"add_page",EDIT_PAGE:"edit_page",DELETE_PAGE:"delete_page",CHANGE_PAGE_TYPE:"change_page_type",PUBLISH_PAGE:"publish_page",UNPUBLISH_PAGE:"unpublish_page",MARK_AS_TEMPLATE:"mark_as_template",EDIT_SEO:"edit_seo",RESTORE_REVISION:"restore_revision",DELETE_REVISION:"delete_revision",DELETE_LIBRARY_BLOCK:"delete_library_block"},me=()=>{const e=L(),t=k();return x.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},Yn=e=>{const{data:t}=me();return h.useMemo(()=>t==null?void 0:t.find(n=>n.key===e),[t,e])},Lr=()=>{const e=L(),t=k();return x.useMutation({mutationFn:async({pageType:n,query:s})=>{try{return t(e,{action:y.SEARCH_PAGES,data:{pageType:n,query:Array.isArray(s)&&s.length>0?s[0]:s}})||[]}catch(r){return console.error(r),[]}}})},Jn=({page:e,setDuplicatePage:t,setAddEditPage:n,setUnpublishPage:s,setDeletePage:r,setMarkAsTemplate:a,setUnmarkAsTemplate:i,children:l,isLanguagePage:c})=>{const{t:d}=he.useTranslation(),{hasPermission:u}=g.usePermissions(),{data:f}=me(),E=h.useMemo(()=>p.find(f,{key:e.pageType}),[f,e.pageType]),m=h.useMemo(()=>!!e.isTemplate,[e.isTemplate]),S=h.useMemo(()=>!!(E!=null&&E.hasSlug),[E==null?void 0:E.hasSlug]);return!u(re.EDIT_PAGE)&&!u(re.DELETE_PAGE)&&!u(re.UNPUBLISH_PAGE)||!e?null:o.jsxs(g.DropdownMenu,{children:[o.jsx(g.DropdownMenuTrigger,{asChild:!0,onClick:P=>P.stopPropagation(),children:l}),o.jsxs(g.DropdownMenuContent,{align:"center",className:"text-sm",children:[u(re.ADD_PAGE)&&!c&&o.jsxs(g.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"]}),u(re.EDIT_PAGE)&&o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),n({...e,global:!(E!=null&&E.hasSlug)})},children:[o.jsx(v.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&u(re.UNPUBLISH_PAGE)&&o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),s(e)},children:[o.jsx(v.Power,{className:"size-3"}),d("Unpublish")]}),u(re.DELETE_PAGE)&&o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),r(e)},children:[o.jsx(v.Trash,{className:"size-3"}),d("Delete")]}),u(re.MARK_AS_TEMPLATE)&&S&&!c&&o.jsx(o.Fragment,{children:m?o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),i(e)},children:[o.jsx(v.SquareLibrary,{className:"size-3"}),d("Unmark as template")]}):o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),a(e)},children:[o.jsx(v.SquareLibrary,{className:"size-3"}),d("Mark as template")]})})]})]})},Pe=()=>{const e=L(),t=k();return x.useQuery({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS],staleTime:300*1e3,placeholderData:{languages:[],theme:mr.defaultThemeValues,appKey:"",fallbackLang:"",designTokens:{}},queryFn:async()=>t(e,{action:y.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})},Kt=()=>{const e=ae("currentUser"),t=ae("onLogout");return{isLoggedIn:!!e,user:e,logout:t}},J={LOCKED:"LOCKED",EDITING:"EDITING",CHECKING:"CHECKING",TAKE_OVER_REQUESTED:"TAKE_OVER_REQUESTED",ACTIVE_IN_ANOTHER_TAB:"ACTIVE_IN_ANOTHER_TAB",FORCE_TAKE_OVER:"FORCE_TAKE_OVER",CONNECTION_LOST:"CONNECTION_LOST"},X={FORCE_TAKE_OVER:"FORCE_TAKE_OVER",TAKE_OVER_REQUEST:"TAKE_OVER_REQUEST",TAKE_OVER_APPROVED:"TAKE_OVER_APPROVED",TAKE_OVER_REJECTED:"TAKE_OVER_REJECTED",FORCE_TAKE_OVER_REQUEST:"FORCE_TAKE_OVER_REQUEST",CONTINUE_EDITING_IN_THIS_CLIENT:"CONTINUE_EDITING_IN_THIS_CLIENT",CONTINUE_EDITING_IN_THIS_TAB_REQUEST:"CONTINUE_EDITING_IN_THIS_TAB_REQUEST"},Nr=["sync","join","leave"],jr=[X.FORCE_TAKE_OVER,X.TAKE_OVER_REQUEST,X.TAKE_OVER_APPROVED,X.TAKE_OVER_REJECTED,X.FORCE_TAKE_OVER_REQUEST,X.CONTINUE_EDITING_IN_THIS_CLIENT,X.CONTINUE_EDITING_IN_THIS_TAB_REQUEST],Gr=Q.atom({}),Zn=Q.atom(null),kr=Q.atom(J.CHECKING),Or=Q.atom({}),Rr=e=>{const t={},n=p.groupBy(p.values(e).map(p.first).filter(Boolean),"pageId");return Object.entries(n).forEach(([s,r])=>t[s]=p.minBy(r,"onlineAt")),t},Dr=e=>{const t=p.minBy(p.values(e).map(p.first).filter(Boolean),"onlineAt"),n=t==null?void 0:t.onlineAt;return n?n-100:+new Date-1e3*60*60*4},Pt=()=>{const{user:e}=Kt();return e==null?void 0:e.id},Mr=()=>{const{data:e}=Pe();return`WEBSITE:${e==null?void 0:e.appKey}`},xt=()=>{const{data:e}=ne();return e==null?void 0:e.id},pe=crypto.randomUUID();let Yt=null;const Je=10,Ur=1e3,Br=2,Fr=16e3,hn=()=>{const[e,t]=Q.useAtom(Gr);return{pageToUser:e,setPageToUser:t}},oe=()=>{const[e,t]=Q.useAtom(kr),n=[J.LOCKED,J.ACTIVE_IN_ANOTHER_TAB].includes(e),s=[J.EDITING].includes(e);return{pageStatus:e,setPageStatus:t,isLocked:n,isEditing:s}},gn=()=>{const[e,t]=Q.useAtom(Or);return{pageLockMeta:e,setPageLockMeta:t}},Xn=()=>{const e=xt(),{pageToUser:t}=hn();return h.useMemo(()=>t[e],[t,e])},mn=()=>{const e=Qn(),{setPageStatus:t}=oe(),[n]=Q.useAtom(Zn);return h.useEffect(()=>{if(clearTimeout(Yt),!e)return Yt=setTimeout(()=>{e||t(J.EDITING)},500),()=>clearTimeout(Yt)},[e,t]),n},qr=()=>{const e=xt(),t=Pt(),n=mn(),{setPageToUser:s}=hn(),{setPageStatus:r,pageStatus:a}=oe(),i=h.useRef(e);return i.current=e,h.useCallback(l=>{const c=l||n;if(!c)return[];const d=c==null?void 0:c.presenceState(),u=Rr(d);s(u);const f=u[i.current];if(!f)r(J.CHECKING);else if(!t)r(J.CHECKING);else if(f.userId===t&&f.clientId===pe){if(a===J.TAKE_OVER_REQUESTED)return;r(J.EDITING)}else f.userId===t&&f.clientId!==pe?r(J.ACTIVE_IN_ANOTHER_TAB):r(J.LOCKED)},[n,s,r,t,a])},es=()=>{const e=Pt(),t=xt(),n=mn(),s=Xn(),{setPageLockMeta:r}=gn(),a=h.useRef(t);return a.current=t,h.useCallback(async(i,l)=>{if(!n)return;const c=l||{};c.userId=e,c.pageId=a.current,c.senderClientId=pe,c.receiverClientId=(l==null?void 0:l.requestingClientId)||(s==null?void 0:s.clientId),await n.send({event:i,payload:c,type:"broadcast"}),r({})},[n,e,s,r])},Kr=()=>{const e=Pt(),t=xt(),n=mn(),{setPageStatus:s}=oe(),{setPageLockMeta:r}=gn(),a=es(),i=h.useRef(t),{savePageAsync:l}=g.useSavePage();return i.current=t,h.useCallback(c=>async({payload:d})=>{const u=d||{};if(!(!(u!=null&&u.pageId)||(u==null?void 0:u.pageId)!==i.current||(u==null?void 0:u.receiverClientId)!==pe))switch(r({}),c){case X.FORCE_TAKE_OVER_REQUEST:case X.CONTINUE_EDITING_IN_THIS_TAB_REQUEST:{try{await l(!0)}catch(f){console.error("Failed to save page before releasing lock:",f)}await a(X.CONTINUE_EDITING_IN_THIS_CLIENT,{requestingClientId:u==null?void 0:u.senderClientId}),setTimeout(()=>r({type:c}),0);break}case X.TAKE_OVER_REQUEST:{r({requestingUserId:u==null?void 0:u.userId,requestingClientId:u==null?void 0:u.senderClientId}),s(J.TAKE_OVER_REQUESTED);break}case X.CONTINUE_EDITING_IN_THIS_CLIENT:{const f=Dr(n==null?void 0:n.presenceState());s(J.CHECKING),await(n==null?void 0:n.track({onlineAt:f,pageId:i.current,userId:e,clientId:pe}));break}case X.TAKE_OVER_REJECTED:{r({type:X.TAKE_OVER_REJECTED});break}}},[a,r,s,n,e,l])},Vr=()=>{const e=Qn(),t=Pt(),n=xt(),s=Mr(),[r,a]=Q.useAtom(Zn),i=Kr(),l=qr(),c=h.useRef(i),d=h.useRef(l),u=h.useRef(null),f=h.useRef(!1),E=h.useRef(0),m=h.useRef(r);h.useEffect(()=>{c.current=i,d.current=l,m.current=r},[i,l,r]);const S=h.useCallback(P=>{jr.forEach(_=>{P.on("broadcast",{event:_},T=>{c.current(_)(T)})}),Nr.forEach(_=>{P.on("presence",{event:_},()=>{d.current(P)})})},[]),A=h.useCallback(()=>{if(f.current||!e||!t||!s)return;if(E.current>=Je){console.error(`Maximum reconnection attempts (${Je}) reached. Stopping reconnection attempts.`);return}f.current=!0,E.current+=1,console.log(`Attempting to reconnect realtime channel (attempt ${E.current}/${Je})`),u.current&&(clearTimeout(u.current),u.current=null),m.current&&(e.removeChannel(m.current),a(null),m.current=null);const P=Math.min(Ur*Math.pow(Br,E.current-1),Fr);u.current=setTimeout(()=>{const _=e.channel(s,{config:{presence:{key:pe}}});S(_),_.subscribe(async T=>{T==="SUBSCRIBED"?(console.log("Realtime connection established successfully"),a(_),m.current=_,E.current=0,f.current=!1):T==="CHANNEL_ERROR"||T==="TIMED_OUT"?(console.log(`Realtime connection failed: ${T}. Attempt ${E.current}/${Je}`),E.current<Je?setTimeout(()=>{f.current=!1,A()},500):(console.error("Maximum reconnection attempts reached"),f.current=!1)):T==="CLOSED"&&(console.log("Realtime connection closed"),f.current=!1)})},P)},[e,t,s,a,S]);h.useEffect(()=>{if(!e||!t||!s||r&&r.topic===s)return;E.current=0,f.current=!1;const P=e.channel(s,{config:{presence:{key:pe}}});return S(P),P.subscribe(async _=>{_==="SUBSCRIBED"?(console.log("Realtime connection established successfully"),a(P),m.current=P,E.current=0):_==="CHANNEL_ERROR"||_==="TIMED_OUT"?(console.log(`Realtime connection failed: ${_}. Will attempt to reconnect...`),f.current||A()):_==="CLOSED"&&console.log("Realtime connection closed")}),()=>{u.current&&(clearTimeout(u.current),u.current=null),f.current=!1,E.current=0,m.current===P&&(m.current=null),a(null),e.removeChannel(P)}},[e,t,s,a,A,S]),h.useEffect(()=>{const P=()=>{if(document.visibilityState==="visible"){if(console.log("Tab became visible, checking realtime connection..."),!e||!t||!s){console.log("Required dependencies not available, skipping reconnection");return}if(f.current){console.log("Reconnection already in progress, skipping visibility change reconnect");return}if(m.current){const _=m.current.state;_!=="joined"&&(console.log(`Channel state is ${_}, reconnecting...`),A())}else console.log("No active channel found, reconnecting..."),A()}};return document.addEventListener("visibilitychange",P),()=>{document.removeEventListener("visibilitychange",P)}},[e,t,s,A]),h.useEffect(()=>(r&&n&&t&&r.track({pageId:n,userId:t,clientId:pe,onlineAt:+new Date}),()=>{r&&n&&r.untrack()}),[r,n,t])},Vt=()=>{const{data:e}=Pe();return h.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},En=()=>{const e=k(),t=L();return x.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:n=>n||[]})},Hr=e=>{const t=k(),n=L(),s=Vt();return x.useQuery({queryKey:[y.GET_WEBSITE_PAGES,e,s],staleTime:1e3*60*5,enabled:!!e,queryFn:async()=>{if(s===e)return{};const r=await t(n,{action:y.GET_WEBSITE_PAGES,data:{lang:e}})||[];return p.keyBy(p.map(r,a=>({...a,lang:e})),"primaryPage")},placeholderData:r=>r||{}})};function pn(e,t,n=!1){const s=e.toString()?`?${e.toString()}`:"/";n?window.history.replaceState(null,"",s):window.history.pushState({},"",s),t(e),window.dispatchEvent(new PopStateEvent("popstate"))}const Qr=h.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-DVK6MAnp.cjs"))),ts=({children:e})=>{const{t}=he.useTranslation(),[n,s]=ue(),r=n.get("page"),{data:a,isFetching:i}=ne(),{data:l,isFetching:c}=En(),[d,u]=h.useState(!1),[f,E]=h.useState(!0),{savePage:m}=g.useSavePage(),S=!!r&&!p.isEmpty(a),{isLocked:A}=oe(),P=h.useMemo(()=>{if(!l||c)return!1;const G=l.find(q=>q.slug==="/");return G==null?void 0:G.id},[l,c]);h.useEffect(()=>{if(c||!P||l.some(N=>N.id===r))return;const q=new URLSearchParams({page:P});pn(q,s),!c&&l&&E(!1)},[r,c,l,P,s]);const _=!f&&!r,T=!f&&!i&&p.isEmpty(a),C=d||_||T;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(g.Tooltip,{children:[o.jsx(g.TooltipTrigger,{asChild:!0,onClick:()=>{A||m(),u(!0)},children:e||o.jsx(I.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(g.TooltipContent,{side:"right",children:o.jsx("p",{children:t("Open pages manager")})})]})})}),o.jsx(g.Sheet,{open:C,onOpenChange:G=>!G&&S&&u(!1),children:o.jsxs(g.SheetContent,{side:"left","aria-describedby":"pages-manager-description",className:`z-50 !min-w-[50vh] !max-w-[800px] border-border p-0 ${S?"":"sheet-hide-close-btn"}`,children:[o.jsxs(g.SheetHeader,{className:"mb-3 px-4 pt-4",children:[o.jsxs(g.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:t("Pages")}),o.jsx("span",{id:"pages-manager-description",className:"text-xs font-normal text-muted-foreground",children:t("Manage your site structure")})]})]}),o.jsx(g.SheetDescription,{className:"sr-only",children:t("Manage your site structure")})]}),o.jsx("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:C&&o.jsx(h.Suspense,{children:o.jsx(Qr,{close:()=>u(!1)})})})]})})]})},zr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-DBH5pNfJ.cjs"))),$r=h.lazy(()=>Promise.resolve().then(()=>require("./delete-page-DBK8uFLn.cjs"))),Wr=h.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-Cy438XWV.cjs"))),Yr=h.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-RdAktYuH.cjs"))),Jr=h.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template--HC_u2RZ.cjs"))),Zr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-0ALLHcVy.cjs"))),Xr=()=>{const[e,t]=h.useState(null),[n,s]=h.useState(null),[r,a]=h.useState(null),[i,l]=h.useState(null),[c,d]=h.useState(null),[u,f]=h.useState(null),{data:E,isFetching:m}=ge(),{selectedLang:S,fallbackLang:A}=g.useLanguages(),{data:P}=Se(),_=P==null?void 0:P.find(N=>N.lang===S),{isLocked:T}=oe(),C=!(E!=null&&E.slug),G=Q.useSetAtom(rt);if(!E)return null;const q=N=>{S.length>0&&S!==A?G({edit:!0,id:N==null?void 0:N.id,primaryPage:N==null?void 0:N.primaryPage}):f(N)};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(ts,{children:o.jsx(I.Button,{className:"flex h-7 max-w-[200px] cursor-pointer items-center truncate rounded px-1 text-xs font-medium",variant:"ghost",children:m?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:[C?o.jsx(v.Hash,{className:"mr-1 h-4 w-4"}):o.jsx(v.File,{className:"mr-1 h-4 w-4"}),p.get(_||E,"name")??""]})})}),T?o.jsx(I.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(Jn,{page:E,setDuplicatePage:N=>d(N),setAddEditPage:N=>q(N),setUnpublishPage:N=>s(N),setDeletePage:N=>t(N),setMarkAsTemplate:N=>a(N),setUnmarkAsTemplate:N=>l(N),isLanguagePage:S.length>0&&S!==A,children:o.jsx(I.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:o.jsx(v.MoreHorizontal,{className:"h-4 w-4"})})})]}),u&&o.jsx(h.Suspense,{children:o.jsx(zr,{closePanel:()=>f(null),editPage:()=>{},addEditPage:u,setAddEditPage:f})}),e&&o.jsx(h.Suspense,{children:o.jsx($r,{page:e,onClose:()=>t(null)})}),n&&o.jsx(h.Suspense,{children:o.jsx(Zr,{page:n,onClose:()=>s(null)})}),r&&o.jsx(h.Suspense,{children:o.jsx(Yr,{page:r,onClose:()=>a(null)})}),i&&o.jsx(h.Suspense,{children:o.jsx(Jr,{page:i,onClose:()=>l(null)})}),c&&o.jsx(h.Suspense,{children:o.jsx(Wr,{page:c,onClose:()=>d(null),closePanel:()=>f(null)})})]})},Ht=({children:e,className:t=""})=>o.jsx("div",{className:Gt.cn("fixed bottom-0 left-0 right-0 top-[50px] z-[20] flex w-screen flex-col items-center justify-center bg-black/40 transition-all",t),children:e}),ea=({hasDynamicPage:e})=>o.jsx(Ht,{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"})]})}),Ze={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"},ta=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-_pqb4S0R.cjs"))),na=()=>{const e=ae("topLeftCorner",null);return e?o.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:h.createElement(e,{})}):null},ns=({showAdd:e=!0,variant:t="ghost",goToDefaultLang:n=!1})=>{const{fallbackLang:s,languages:r,selectedLang:a,setSelectedLang:i}=g.useLanguages(),l=p.isEmpty(a)?s:a,[,c]=ue(),{isLocked:d}=oe(),{t:u}=he.useTranslation();h.useEffect(()=>{const T=new URLSearchParams(window.location.search),C=T.get("lang");C&&(r.includes(C)?i(C):(T.delete("lang"),c(T),i("")))},[r,c,i]);const f=Q.useSetAtom(rt),{data:E}=ne(),{data:m}=Pe(),{data:S}=Se(),A=h.useMemo(()=>{const T=p.compact(p.map(p.get(m,"languages"),C=>{const G=p.find(S,{lang:C});return{key:C,value:p.get(Ze,C,C),isLangPageAdded:!!G}})).filter(Boolean);return[{key:s,value:p.get(Ze,s),isLangPageAdded:!0},...T]},[s,S,m]),P=T=>{if(document.querySelector('[data-panel-id="seo"]')){const G=new CustomEvent("seo-language-switch-check",{detail:{fromLang:l,toLang:T,switchHandler:()=>_(T)}});window.dispatchEvent(G);return}_(T)},_=T=>{i(T);const C=new URLSearchParams(window.location.search);T===s?C.delete("lang"):C.set("lang",T),pn(C,c)};return p.isEmpty(r)?null:d?o.jsxs(I.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(Ze,l,l),o.jsx(v.ChevronDown,{className:"h-4 w-4"})]}):n?o.jsx(I.Button,{onClick:()=>_(s),variant:"link",size:"sm",children:u("Switch to default language")}):o.jsx(o.Fragment,{children:o.jsxs(g.DropdownMenu,{children:[o.jsx(g.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:o.jsxs(I.Button,{disabled:!!d,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(Ze,l,l),o.jsx(v.ChevronDown,{className:"h-4 w-4"})]})}),o.jsxs(g.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(A.filter(T=>T.isLangPageAdded),T=>o.jsxs(g.DropdownMenuItem,{className:Gt.cn("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",T.key===l&&"!bg-gray-200 text-gray-700"),onClick:()=>P(T.key),children:[o.jsx("div",{className:"text-slate-600",children:T.value}),T.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"]})]},T.value)),e&&!p.isEmpty(A.filter(T=>!T.isLangPageAdded))&&o.jsxs(o.Fragment,{children:[o.jsx(g.Separator,{}),o.jsxs(I.Button,{size:"sm",variant:"ghost",onClick:()=>{E&&f({edit:!1,primaryPage:E.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 Language"]})]})]})]})})};function sa(){const e=Q.useAtomValue(rt),t=Q.useSetAtom(rt);return o.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[o.jsx(na,{}),o.jsx(ts,{}),e&&o.jsx(h.Suspense,{children:o.jsx(ta,{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 ra(){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(g.Skeleton,{className:"h-4 w-3/4"}),o.jsx(g.Skeleton,{className:"h-3 w-1/2"}),o.jsx(g.Skeleton,{className:"mt-1 h-5 w-20"})]}),o.jsx(g.Skeleton,{className:"h-8 w-8 rounded-full"})]},t))})}const aa=z.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-B7j1MkFd.cjs")));function oa(){const[e,t]=z.useState(!1);return o.jsx(g.TooltipProvider,{children:o.jsxs(g.Tooltip,{delayDuration:0,children:[o.jsxs(g.Sheet,{open:e,onOpenChange:t,children:[o.jsx(g.SheetTrigger,{asChild:!0,children:o.jsx(g.TooltipTrigger,{asChild:!0,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsxs(I.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(g.SheetContent,{className:"flex h-[100vh] flex-col",children:e&&o.jsx(h.Suspense,{fallback:o.jsx(ra,{}),children:o.jsx(aa,{isOpen:e})})})]}),o.jsx(g.TooltipContent,{side:"bottom",children:o.jsx("p",{children:"Revision history"})})]})})}const It=({permission:e,permissions:t,children:n,fallback:s=null})=>{const{hasPermission:r}=g.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?s:n},ia={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},la=()=>{const e=L(),t=x.useQueryClient(),n=k(),{data:s}=me();return x.useMutation({mutationFn:async r=>await n(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(s,{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(s,{key:a.pageType});F.toast.error(`Failed to add new ${i!=null&&i.hasSlug?"page":i.name}.`,{description:p.get(ia,r.message,r.message)})}})},ca=()=>{const e=L(),t=x.useQueryClient(),n=k(),{data:s}=ge(),{data:r}=me();return x.useMutation({mutationFn:async a=>await n(e,{action:y.UPDATE_PAGE,data:a}),onSuccess:(a,i)=>{(s==null?void 0:s.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})}})},ua=()=>{const e=L(),t=x.useQueryClient(),n=k(),{data:s}=me();return x.useMutation({mutationFn:async r=>n(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(s,{key:a.pageType});F.toast.error(`Failed to delete ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},da=()=>{const e=L(),t=x.useQueryClient(),n=k(),{data:s}=me();return x.useMutation({mutationFn:async r=>n(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(s,{key:a.pageType});F.toast.success(i!=null&&i.hasSlug?"Page unpublished successfully.":"New "+i.name+" added successfully.")},onError:(r,a)=>{const i=p.find(s,{key:a.pageType});F.toast.error(`Failed to take offline ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},yn=()=>{const e=L(),t=k(),n=x.useQueryClient(),{data:s}=ne(),{savePageAsync:r}=g.useSavePage();return x.useMutation({mutationFn:async({ids:a})=>(await r(),t(e,{action:y.PUBLISH_CHANGES,data:{ids:a}})),onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_CHANGES]}),n.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),n.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,s==null?void 0:s.id]})},onError:a=>{console.log("##",a),F.toast.error("Failed to publish pages.")}})},fa=()=>{const e=L(),t=k(),n=x.useQueryClient();return x.useMutation({mutationFn:async s=>{var r;return t(e,{action:y.MARK_AS_TEMPLATE,data:{id:(r=s.page)==null?void 0:r.id,name:s.name,description:s.description,pageType:s.pageType,previewImage:s.previewImage}})},onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page marked as template successfully.")},onError:()=>{F.toast.error("Failed to mark page as template.")}})},ha=()=>{const e=L(),t=k(),n=x.useQueryClient();return x.useMutation({mutationFn:async s=>t(e,{action:y.UNMARK_AS_TEMPLATE,data:{id:s==null?void 0:s.id}}),onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page unmarked as template successfully.")},onError:()=>{F.toast.error("Failed to unmark page as template.")}})},ga=()=>{const e=L(),t=k(),n=x.useQueryClient();return x.useMutation({mutationFn:async({id:s,slug:r})=>t(e,{action:y.CHANGE_SLUG,data:{id:s,slug:r}}),onSuccess:(s,{primaryPage:r})=>{F.toast.success("Slug changed successfully."),r?n.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,r]}):n.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:()=>{F.toast.error("Failed to change slug")}})},ma=h.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-BdYSPXQ8.cjs")));function Ea({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:n,isPending:s}=yn();return o.jsx(g.Dialog,{open:e,onOpenChange:s?()=>{}:t,children:e&&o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"h-96 w-96 animate-pulse bg-gray-100"}),children:o.jsx(ma,{onClose:t,isPending:s,publishPage:n})})})}const ss=e=>{const{fallbackLang:t}=g.useLanguages(),{data:n}=Pe(),{data:s,isFetching:r}=Se(),a=h.useMemo(()=>{const i={[t]:!0};return p.each(p.get(n,"languages"),l=>{const c=p.find(s,{lang:l});i[l]=!!c}),i},[t,s,n]);return r||p.isEmpty(e)||e&&a[e]},pa={particleCount:350,spread:120,origin:{y:.6},angle:90},ya={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},Aa=async()=>{const{default:e}=await import("canvas-confetti");return e},Lt=e=>{let t=ya[e];t||(t={});const n={...pa,...t};Aa().then(s=>s(n))};function Qt({children:e,content:t,side:n="bottom",delayDuration:s=700,showTooltip:r=!0}){return r?o.jsx(g.TooltipProvider,{children:o.jsxs(g.Tooltip,{delayDuration:s,children:[o.jsx(g.TooltipTrigger,{asChild:!0,children:e}),o.jsx(g.TooltipContent,{side:n,sideOffset:10,children:o.jsx("p",{children:t})})]})}):e}const Ta=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-0ALLHcVy.cjs"))),Sa=h.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-ChL7oDO1.cjs"))),Pa=h.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-CVsMPRJ1.cjs"))),xa=()=>{const{t:e}=he.useTranslation(),{selectedLang:t,fallbackLang:n}=g.useLanguages(),s=ae("getPreviewUrl",async E=>E),[r,a]=h.useState(""),{data:i}=ne(),{data:l}=Se(),{data:c}=me(),d=h.useMemo(()=>{var E;return(E=l==null?void 0:l.find(m=>(m==null?void 0:m.lang)===t))==null?void 0:E.slug},[t,l]),u=h.useCallback(E=>{var m;return(m=p.find(c,{key:E}))==null?void 0:m.hasSlug},[c]),f=t===n?"":t;return h.useEffect(()=>{(async()=>{if(typeof s=="function"){const E=!u(i==null?void 0:i.pageType),m=await s(E?`/_partial/${f!==""?f+"/":""}${i==null?void 0:i.id}`:d||"");a(m)}else a("")})()},[s,d,i==null?void 0:i.pageType,u,i==null?void 0:i.id,f]),o.jsx(o.Fragment,{children:o.jsx(Qt,{content:e("Open preview in new tab"),delayDuration:0,children:o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:o.jsx(I.Button,{variant:"ghost",size:"sm",className:"gap-2",children:o.jsx(v.Play,{className:"h-4 w-4"})})})})})},_a=()=>{const{t:e}=he.useTranslation(),[t,n]=g.useRightPanel();return o.jsxs(o.Fragment,{children:[o.jsx(Qt,{content:e("Theme"),delayDuration:0,children:o.jsx(I.Button,{variant:t==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>n(t==="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"})]})},wa=()=>{const{t:e}=he.useTranslation(),[t,n]=h.useState(!1),{isLocked:s}=oe(),{savePageAsync:r,saveState:a}=g.useSavePage();h.useEffect(()=>{const u=f=>{a==="UNSAVED"&&(f.preventDefault(),f.returnValue=!1)};return a==="UNSAVED"&&window.addEventListener("beforeunload",u),()=>{window.removeEventListener("beforeunload",u)}},[a]);const i=h.useCallback(async()=>{t||(n(!0),await r(),n(!1))},[r,t]),{buttonIcon:l,buttonClass:c,tooltipContent:d}=h.useMemo(()=>{switch(a){case"UNSAVED":return{tooltipContent:e("Save draft"),buttonIcon:o.jsx(v.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:e("Saving"),buttonIcon:o.jsx(v.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:e("Saved"),buttonIcon:o.jsx(v.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[a,e]);return s?null:o.jsxs(I.Button,{size:"sm",variant:"ghost",onClick:i,className:`${c} w-24 max-w-24`,children:[l," ",d]})},va=()=>{const{t:e}=he.useTranslation(),{selectedLang:t}=g.useLanguages(),{data:n}=ge(),{data:s}=Se(),[r,a]=h.useState(!1),[i,l]=h.useState(!1),[c,d]=h.useState(null),[u,f]=h.useState(!1),{savePageAsync:E}=g.useSavePage(),[m,S]=h.useState(!1),{data:A}=ne(),{mutate:P,isPending:_}=yn(),{needTranslations:T}=g.useSavePage(),C=T(),{buttonText:G,buttonClassName:q,isPublished:N,hasUnpublishedChanges:ie}=h.useMemo(()=>{const K=A&&(A==null?void 0:A.online),ee=!p.isEmpty(A==null?void 0:A.changes);let xe=K?"hover:bg-green-600 bg-green-500":"",se=e(K?"Published":"Publish");return K&&ee&&(xe="hover:bg-blue-600 bg-blue-500",se=e("Publish")),{buttonClassName:xe,isPublished:K,hasUnpublishedChanges:ee,buttonText:se}},[A,e]),de=async()=>{if(C){S(!0);return}V()},V=()=>{const K=[n==null?void 0:n.id,n==null?void 0:n.primaryPage];P({ids:p.compact(K)},{onSuccess:()=>Lt("TOP_RIGHT")})},j=()=>{S(!1),V()},O=async()=>{S(!1),await E()},$=h.useMemo(()=>p.map(s??[],"id"),[s]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex",children:[o.jsxs(I.Button,{size:"sm",onClick:de,disabled:_||!(A!=null&&A.id),className:`relative flex items-center gap-1 overflow-hidden rounded-r-none text-white transition-all duration-300 ease-in-out ${q}`,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[o.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${i?"-translate-y-10":""}`,children:N?ie?o.jsx(v.Pencil,{className:"h-4 w-4"}):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 ${i?"":"translate-y-10"}`,children:N?o.jsx(v.Rocket,{className:"h-4 w-4"}):o.jsx(v.Send,{className:"h-4 w-4"})}),o.jsx("span",{children:G}),t?`(${p.upperCase(t)})`:""]}),o.jsxs(g.DropdownMenu,{children:[o.jsx(g.DropdownMenuTrigger,{asChild:!0,children:o.jsx(I.Button,{size:"sm",disabled:_||!(A!=null&&A.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${q}`,children:o.jsx(v.ChevronDown,{className:"h-4 w-4"})})}),o.jsxs(g.DropdownMenuContent,{align:"end",className:"w-52",children:[o.jsxs(g.DropdownMenuItem,{disabled:_,className:"cursor-pointer text-xs",onClick:()=>P({ids:$},{onSuccess:()=>Lt("TOP_RIGHT")}),children:[e("Publish")," with translation pages"]}),!N&&o.jsxs(g.DropdownMenuItem,{disabled:_,className:"cursor-pointer text-xs",onClick:()=>P({ids:[A==null?void 0:A.id]},{onSuccess:()=>Lt("TOP_RIGHT")}),children:[e("Publish")," page"]}),o.jsxs(g.DropdownMenuItem,{onClick:()=>a(!0),className:"cursor-pointer text-xs",children:[e("Open")," publish menu"]}),N&&ie&&o.jsx(g.DropdownMenuItem,{onClick:()=>f(!0),className:"cursor-pointer text-xs",children:e("View Unpublished changes")}),N&&o.jsxs(g.DropdownMenuItem,{onClick:()=>d(n),className:"cursor-pointer text-xs",children:[e("Unpublish")," page ",t?`(${p.upperCase(t)})`:""]})]})]})]}),o.jsx(Ea,{showModal:r,onClose:()=>a(!1)}),c&&o.jsx(h.Suspense,{children:o.jsx(Ta,{page:c,onClose:()=>d(null)})}),u&&o.jsx(h.Suspense,{children:o.jsx(Pa,{open:u,onOpenChange:f,compare:[{label:"draft",uid:`draft:${A==null?void 0:A.id}`,item:A},{label:"live",uid:`live:${A==null?void 0:A.id}`,item:{}}]})}),m&&o.jsx(h.Suspense,{children:o.jsx(Sa,{isOpen:m,onClose:O,onContinue:j,isPending:_})})]})};function ba(){const{isLocked:e}=oe(),[t]=ue(),n=t.get("lang"),s=ss(n);return e||!s?o.jsx("div",{}):o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[o.jsx(oa,{}),o.jsx(It,{permission:re.EDIT_THEME,children:o.jsx(_a,{})}),o.jsx(xa,{}),o.jsx(It,{permission:re.SAVE_PAGE,children:o.jsx(wa,{})}),o.jsx(It,{permission:re.PUBLISH_PAGE,children:o.jsx(va,{})})]})}const Ca=h.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-zjKnz5wv.cjs"))),Ia=()=>{const{dynamicPage:e,allLangPages:t,isFetching:n}=Wn(),s=t.length>0;return n?null:o.jsxs("div",{className:"relative",children:[!e&&o.jsx(ea,{hasDynamicPage:s}),o.jsx(h.Suspense,{children:o.jsx(Ca,{})})]})},La=()=>{const{data:e,isFetching:t}=ge(),{data:n,isFetching:s}=ne(),r=p.get(n,"dynamic",!1),a=dn(),i=I.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,d=Ir(),u=t||s,E=(c?`Partial: ${e==null?void 0:e.name} `:`${l}${a}`).replace(window.location.host,"");return o.jsxs("div",{className:"relative flex items-center",children:[o.jsx("div",{className:Gt.cn("flex h-8 w-auto max-w-[600px] items-center rounded-l-md border border-r-0 border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800",u&&"max-w-0 overflow-hidden opacity-0"),children:o.jsx(Xr,{})}),o.jsxs("div",{className:Gt.cn("flex h-8 w-auto max-w-[600px] items-center rounded-r-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800"+(c?" pr-2":""),u&&"max-w-0 overflow-hidden opacity-0"),children:[o.jsx(ns,{}),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:E==="/"?o.jsxs("span",{className:"text-gray-900",children:["/",o.jsx("span",{className:"text-[11px] font-light italic text-gray-400",children:"(Homepage)"})]}):E}),!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(Ia,{})]})},Na=()=>o.jsxs("div",{className:"grid h-full w-full grid-cols-3 items-center px-2",children:[o.jsx("div",{className:"flex justify-start",children:o.jsx(sa,{})}),o.jsx("div",{className:"flex justify-center",children:o.jsx(La,{})}),o.jsx("div",{className:"flex justify-end",children:o.jsx(ba,{})})]}),rs=()=>{const e=x.useQueryClient(),{data:t}=x.useQuery({queryKey:[y.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:h.useCallback(s=>{e.setQueryData([y.AI_CONTEXT],s)},[e]),aiContext:t}},ja=()=>{const e=L(),{aiContext:t}=rs(),n=k();return h.useCallback(async(s,r,a,i)=>n(e,{action:y.ASK_AI,data:{type:s,prompt:r,blocks:a,context:t,lang:i}}),[e,t,n])},Ga=e=>h.useMemo(()=>{if(!e||p.isEmpty(e))return{blocks:[]};const t=p.filter(e,n=>!p.includes(n==null?void 0:n._type,"@chai/"));return{blocks:Er.syncBlocksWithDefaultProps(t)}},[e]),ka=()=>{const[e]=ue(),t=e.get("page"),n=L(),{setAiContext:s}=rs(),[,r]=fn(),[,a]=Cr(),[,i]=g.useIsPageLoaded(),l=k();return x.useQuery({queryKey:[y.GET_DRAFT_PAGE,t],staleTime:1/0,gcTime:0,queryFn:async()=>{i(!1);const c=await l(n,{action:y.GET_DRAFT_PAGE,data:{id:t,draft:!0}}),d=c.blocks??[],u=p.find(d,{_type:"@chai/ai-context"});return s(p.get(u,"_value","")||""),r(f=>({...f,lastSaved:c.lastSaved})),a(p.get(c,"metadata",{})),setTimeout(()=>i(!0),500),d},enabled:!!t})},as=()=>{const{data:e}=ne(),{data:t}=ge(),n=L(),s=k(),r=Vt(),a=dn();return x.useQuery({queryKey:[y.GET_BUILDER_PAGE_DATA,t==null?void 0:t.id,a],staleTime:1/0,gcTime:0,queryFn:async()=>s(n,{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})},os=()=>{const e=L(),t=x.useQueryClient(),n=k();return x.useMutation({mutationFn:async s=>n(e,{action:y.UPDATE_WEBSITE_FIELDS,data:s}),onSuccess:(s,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:s=>{F.toast.error("Failed to update website settings",{description:s.message})}})},Oa=()=>{const e=L(),t=x.useQueryClient(),n=k(),{selectedLang:s}=g.useLanguages();return x.useMutation({mutationFn:async r=>n(e,{action:y.ADD_GLOBAL_SCHEMA,data:{...r,lang:s}}),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})}})},Ra=()=>{const e=L(),t=x.useQueryClient(),n=k(),{selectedLang:s}=g.useLanguages();return x.useMutation({mutationFn:async r=>n(e,{action:y.UPDATE_GLOBAL_SCHEMA,data:{...r,lang:s}}),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})}})},Da=()=>{const e=L(),t=x.useQueryClient(),n=k();return x.useMutation({mutationFn:async s=>n(e,{action:y.DELETE_GLOBAL_SCHEMA,data:{id:s}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema deleted successfully.")},onError:s=>{F.toast.error("Failed to delete schema",{description:s.message})}})},Ma=()=>{const e=L(),t=k();return x.useMutation({mutationFn:async n=>t(e,{action:y.TOGGLE_PAGE_GLOBAL_SCHEMA,data:n}),onError:n=>{F.toast.error("Failed to toggle schema",{description:n.message})}})},Ua=()=>{const e=L(),t=k();return x.useMutation({mutationFn:async n=>t(e,{action:y.APPLY_SCHEMA_TO_ALL_PAGES,data:{schemaId:n}}),onSuccess:n=>{F.toast.success(`Schema applied to ${n.count} page(s)`)},onError:n=>{F.toast.error("Failed to apply schema to all pages",{description:n.message})}})},Ba=()=>{const e=L(),t=k();return x.useMutation({mutationFn:async n=>t(e,{action:y.REMOVE_SCHEMA_FROM_ALL_PAGES,data:{schemaId:n}}),onSuccess:n=>{F.toast.success(`Schema removed from ${n.count} page(s)`)},onError:n=>{F.toast.error("Failed to remove schema from all pages",{description:n.message})}})},jn={async getUILibraryBlock(e,t,n){const s=await t(n,{action:"GET_LIBRARY_ITEM",data:{id:e.id}}),r=p.get(s,"html",""),a=p.get(s,"blocks",[]);return p.isArray(a)?a:pr.getBlocksFromHTML(r)},async getUILibraryBlocks(e,t,n){return(await t(n,{action:"GET_LIBRARY_ITEMS",data:{id:e.id}})).map(r=>({...r}))}},Fa=()=>{const e=L(),t=k();return x.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const s=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return s.forEach(r=>{I.registerChaiLibrary(r.id,{name:r.isSiteLibrary?r.name+" (Current Site) ":r.name,description:r.description,getBlocksList:a=>jn.getUILibraryBlocks(a,t,e),getBlock:({block:a})=>jn.getUILibraryBlock(a,t,e)})}),s}})},qa=(e=300)=>{const t=ae("onLogout",p.noop),n=ae("getAccessToken"),s=L();return x.useQuery({queryKey:["check-user-access"],queryFn:async()=>{const r=await n(),i=await zn(s+"?action=check_user_access",{action:"CHECK_USER_ACCESS"},{Authorization:`Bearer ${r}`});if(i.status===401)throw console.log("401 Response",i),F.toast.error("You do not have access to edit this website. Please contact administrator"),await t("UNAUTHORIZED"),new Error("Unauthorized");return i},refetchInterval:e*1e3,refetchIntervalInBackground:!0,retry:!1})},is=()=>{const e=L(),t=k(),{user:n}=Kt(),s=n==null?void 0:n.id;return x.useQuery({queryKey:[y.GET_ROLE_AND_PERMISSIONS,s],queryFn:()=>t(e,{action:y.GET_ROLE_AND_PERMISSIONS,data:{}}),enabled:!!s,staleTime:1/0})},Ka=()=>{const e=L(),t=k(),[,n]=fn(),s=x.useQueryClient();return{onSave:async({page:a,blocks:i,needTranslations:l})=>{try{const c=await t(e,{action:"UPDATE_PAGE",data:{id:a,blocks:i,needTranslations:l}});return c.code==="PAGE_LOCKED"?!0:(n(d=>({...d,lastSaved:new Date().toISOString()})),s.setQueryData([y.GET_LANGUAGE_PAGES,a],d=>d&&(d==null?void 0:d.map(u=>(u==null?void 0:u.id)===a?{...u,changes:["Page"]}:u))),s.setQueryData([y.GET_WEBSITE_PAGES],d=>d&&(d==null?void 0:d.map(u=>(u==null?void 0:u.id)===a?{...u,changes:["Page"]}:u))),c)}catch(c){return console.error(c),new Error("Failed to save blocks")}}}},Va=()=>{const{data:e}=En(),t=L(),n=k();return{getPartialBlocks:h.useCallback(async()=>{const s={};for(const r of e??[])p.isEmpty(r==null?void 0:r.slug)&&(s[r.id]={type:r.pageType,name:p.startCase(r.name??r.slug),description:""});return s},[e]),getPartialBlockBlocks:h.useCallback(async s=>{if(!s)return[];try{const r=await n(t,{action:"GET_DRAFT_PAGE",data:{id:s,draft:!0,editor:!1,mergePartials:!0}});return p.filter(r.blocks,a=>p.has(a,"_id"))}catch(r){return console.error(r),[]}},[n,t])}},Ha=h.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-content-B5vcWxUO.cjs"))),ls="chai-chat-panel",Qa=({className:e="h-full w-full"})=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",version:"1.1",className:e,children:[o.jsx("title",{children:"ai"}),o.jsx("g",{id:"Page-1",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:o.jsx("g",{id:"icon",fill:"currentColor",transform:"translate(64.000000, 64.000000)",children:o.jsx("path",{d:"M320,64 L320,320 L64,320 L64,64 L320,64 Z M171.749388,128 L146.817842,128 L99.4840387,256 L121.976629,256 L130.913039,230.977 L187.575039,230.977 L196.319607,256 L220.167172,256 L171.749388,128 Z M260.093778,128 L237.691519,128 L237.691519,256 L260.093778,256 L260.093778,128 Z M159.094727,149.47526 L181.409039,213.333 L137.135039,213.333 L159.094727,149.47526 Z M341.333333,256 L384,256 L384,298.666667 L341.333333,298.666667 L341.333333,256 Z M85.3333333,341.333333 L128,341.333333 L128,384 L85.3333333,384 L85.3333333,341.333333 Z M170.666667,341.333333 L213.333333,341.333333 L213.333333,384 L170.666667,384 L170.666667,341.333333 Z M85.3333333,0 L128,0 L128,42.6666667 L85.3333333,42.6666667 L85.3333333,0 Z M256,341.333333 L298.666667,341.333333 L298.666667,384 L256,384 L256,341.333333 Z M170.666667,0 L213.333333,0 L213.333333,42.6666667 L170.666667,42.6666667 L170.666667,0 Z M256,0 L298.666667,0 L298.666667,42.6666667 L256,42.6666667 L256,0 Z M341.333333,170.666667 L384,170.666667 L384,213.333333 L341.333333,213.333333 L341.333333,170.666667 Z M0,256 L42.6666667,256 L42.6666667,298.666667 L0,298.666667 L0,256 Z M341.333333,85.3333333 L384,85.3333333 L384,128 L341.333333,128 L341.333333,85.3333333 Z M0,170.666667 L42.6666667,170.666667 L42.6666667,213.333333 L0,213.333333 L0,170.666667 Z M0,85.3333333 L42.6666667,85.3333333 L42.6666667,128 L0,128 L0,85.3333333 Z",id:"Combined-Shape"})})})]}),za=({isActive:e,show:t})=>g.useBuilderProp("flags.ai",!1)?o.jsx(I.Button,{size:"icon",className:"p-0 [&_svg]:size-6",onClick:t,variant:e?"default":"ghost",children:o.jsx(Qa,{className:e?"h-5 w-5 text-white":"h-5 w-5 text-primary"})}):null,$a={id:ls,label:"AI Assistant",button:za,panel:Ha,position:"top"},Wa=h.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-ClT8ve6W.cjs"))),Ya=({isActive:e,show:t})=>{const{data:n}=Pe();return!p.has(n,"languages")||!p.get(n,"languages",[]).length?null:o.jsx(I.Button,{size:"sm",onClick:t,variant:e?"default":"ghost",children:o.jsx(v.LanguagesIcon,{className:"h-4 w-4"})})},cs="lang",Ja={id:cs,label:"Languages",position:"top",panel:Wa,button:Ya,view:"modal",width:400},Za=h.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-CKrfiPLx.cjs"))),us="seo",Xa=({isActive:e,show:t})=>{const{data:n}=ne(),s=Yn(n==null?void 0:n.pageType);return!p.has(s,"hasSlug")||!s.hasSlug?null:o.jsx(I.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"})]})})},eo={id:us,label:"SEO",panel:Za,button:Xa,position:"top",width:600,view:"modal"},ds="user-info",to=()=>{const{t:e}=he.useTranslation(),{user:t,logout:n}=Kt(),s=ae("onLogout",p.noop);return t?o.jsxs(g.HoverCard,{children:[o.jsx(g.HoverCardTrigger,{asChild:!0,children:o.jsx(I.Button,{variant:"ghost",className:"text-sm font-medium",children:o.jsx(v.User,{className:"h-4 w-4"})})}),o.jsxs(g.HoverCardContent,{className:"w-auto space-y-2 p-4",children:[o.jsx("div",{className:"text-sm font-medium",children:t.name??t.email}),o.jsx("div",{className:"text-xs text-muted-foreground",children:t.email}),o.jsxs(g.AlertDialog,{children:[o.jsx(g.AlertDialogTrigger,{asChild:!0,children:o.jsx(I.Button,{variant:"outline",size:"sm",className:"w-full",children:e("Logout")})}),o.jsxs(g.AlertDialogContent,{children:[o.jsxs(g.AlertDialogHeader,{children:[o.jsx(g.AlertDialogTitle,{children:e("Are you sure you want to logout?")}),o.jsx(g.AlertDialogDescription,{children:e("You will be redirected to the login page.")})]}),o.jsxs(g.AlertDialogFooter,{children:[o.jsx(g.AlertDialogCancel,{children:e("Cancel")}),o.jsx(g.AlertDialogAction,{onClick:()=>{n(),p.isFunction(s)&&s()},children:e("Logout")})]})]})]})]})]}):null},no={id:ds,label:"User Info",button:to,position:"bottom"},so=()=>{I.registerChaiSidebarPanel(us,eo),I.registerChaiSidebarPanel(cs,Ja),I.registerChaiSidebarPanel(ds,no),I.registerChaiSidebarPanel(ls,$a)};var b={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return Gn(this.context.count)},getNextContextId(){return Gn(this.context.count++)}};function Gn(e){const t=String(e),n=t.length-1;return b.context.id+(n?String.fromCharCode(96+n):"")+t}function Xe(e){b.context=e}var fs=!1,ro=(e,t)=>e===t,kt=Symbol("solid-proxy"),hs=typeof Proxy=="function",An=Symbol("solid-track"),Ot={equals:ro},gs=Ps,Ee=1,Rt=2,ms={owned:null,cleanups:null,context:null,owner:null},Jt={},D=null,Zt=null,ao=null,U=null,Z=null,fe=null,zt=0;function ye(e,t){const n=U,s=D,r=e.length===0,a=t===void 0?s:t,i=r?ms:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>Y(()=>at(i)));D=i,U=null;try{return ce(l,!0)}finally{U=n,D=s}}function H(e,t){t=t?Object.assign({},Ot,t):Ot;const n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},s=r=>(typeof r=="function"&&(r=r(n.value)),Ss(n,r));return[Ts.bind(n),s]}function Es(e,t,n){const s=$t(e,t,!0,Ee);Ye(s)}function Ae(e,t,n){const s=$t(e,t,!1,Ee);Ye(s)}function Tn(e,t,n){gs=Ao;const s=$t(e,t,!1,Ee);(!n||!n.render)&&(s.user=!0),fe?fe.push(s):Ye(s)}function W(e,t,n){n=n?Object.assign({},Ot,n):Ot;const s=$t(e,t,!0,0);return s.observers=null,s.observerSlots=null,s.comparator=n.equals||void 0,Ye(s),Ts.bind(s)}function oo(e){return e&&typeof e=="object"&&"then"in e}function io(e,t,n){let s,r,a;s=!0,r=e,a={};let i=null,l=Jt,c=null,d=!1,u="initialValue"in a,f=typeof s=="function"&&W(s);const E=new Set,[m,S]=(a.storage||H)(a.initialValue),[A,P]=H(void 0),[_,T]=H(void 0,{equals:!1}),[C,G]=H(u?"ready":"unresolved");b.context&&(c=b.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:b.load&&b.has(c)&&(l=b.load(c)));function q(j,O,$,K){return i===j&&(i=null,K!==void 0&&(u=!0),(j===l||O===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(K,{value:O})),l=Jt,N(O,$)),O}function N(j,O){ce(()=>{O===void 0&&S(()=>j),G(O!==void 0?"errored":u?"ready":"unresolved"),P(O);for(const $ of E.keys())$.decrement();E.clear()},!1)}function ie(){const j=Eo,O=m(),$=A();if($!==void 0&&!i)throw $;return U&&U.user,O}function de(j=!0){if(j!==!1&&d)return;d=!1;const O=f?f():s;if(O==null||O===!1){q(i,Y(m));return}let $;const K=l!==Jt?l:Y(()=>{try{return r(O,{value:m(),refetching:j})}catch(ee){$=ee}});if($!==void 0){q(i,void 0,Nt($),O);return}else if(!oo(K))return q(i,K,void 0,O),K;return i=K,"v"in K?(K.s===1?q(i,K.v,void 0,O):q(i,void 0,Nt(K.v),O),K):(d=!0,queueMicrotask(()=>d=!1),ce(()=>{G(u?"refreshing":"pending"),T()},!1),K.then(ee=>q(K,ee,void 0,O),ee=>q(K,void 0,Nt(ee),O)))}Object.defineProperties(ie,{state:{get:()=>C()},error:{get:()=>A()},loading:{get(){const j=C();return j==="pending"||j==="refreshing"}},latest:{get(){if(!u)return ie();const j=A();if(j&&!i)throw j;return m()}}});let V=D;return f?Es(()=>(V=D,de(!1))):de(!1),[ie,{refetch:j=>ys(V,()=>de(j)),mutate:S}]}function lo(e){return ce(e,!1)}function Y(e){if(U===null)return e();const t=U;U=null;try{return e()}finally{U=t}}function co(e,t,n){const s=Array.isArray(e);let r,a=n&&n.defer;return i=>{let l;if(s){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=Y(()=>t(l,r,i));return r=l,c}}function ps(e){Tn(()=>Y(e))}function $e(e){return D===null||(D.cleanups===null?D.cleanups=[e]:D.cleanups.push(e)),e}function kn(){return D}function ys(e,t){const n=D,s=U;D=e,U=null;try{return ce(t,!0)}catch(r){Sn(r)}finally{D=n,U=s}}function uo(e){const t=U,n=D;return Promise.resolve().then(()=>{U=t,D=n;let s;return ce(e,!1),U=D=null,s?s.done:void 0})}var[fo,xl]=H(!1);function ho(){return[fo,uo]}function go(e,t){const n=Symbol("context");return{id:n,Provider:To(n),defaultValue:e}}function mo(e){let t;return D&&D.context&&(t=D.context[e.id])!==void 0?t:e.defaultValue}function As(e){const t=W(e),n=W(()=>tn(t()));return n.toArray=()=>{const s=n();return Array.isArray(s)?s:s!=null?[s]:[]},n}var Eo;function Ts(){if(this.sources&&this.state)if(this.state===Ee)Ye(this);else{const e=Z;Z=null,ce(()=>Mt(this),!1),Z=e}if(U){const e=this.observers?this.observers.length:0;U.sources?(U.sources.push(this),U.sourceSlots.push(e)):(U.sources=[this],U.sourceSlots=[e]),this.observers?(this.observers.push(U),this.observerSlots.push(U.sources.length-1)):(this.observers=[U],this.observerSlots=[U.sources.length-1])}return this.value}function Ss(e,t,n){let s=e.value;return(!e.comparator||!e.comparator(s,t))&&(e.value=t,e.observers&&e.observers.length&&ce(()=>{for(let r=0;r<e.observers.length;r+=1){const a=e.observers[r],i=Zt&&Zt.running;i&&Zt.disposed.has(a),(i?!a.tState:!a.state)&&(a.pure?Z.push(a):fe.push(a),a.observers&&xs(a)),i||(a.state=Ee)}if(Z.length>1e6)throw Z=[],new Error},!1)),t}function Ye(e){if(!e.fn)return;at(e);const t=zt;po(e,e.value,t)}function po(e,t,n){let s;const r=D,a=U;U=D=e;try{s=e.fn(t)}catch(i){return e.pure&&(e.state=Ee,e.owned&&e.owned.forEach(at),e.owned=null),e.updatedAt=n+1,Sn(i)}finally{U=a,D=r}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&"observers"in e?Ss(e,s):e.value=s,e.updatedAt=n)}function $t(e,t,n,s=Ee,r){const a={fn:e,state:s,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:D,context:D?D.context:null,pure:n};return D===null||D!==ms&&(D.owned?D.owned.push(a):D.owned=[a]),a}function Dt(e){if(e.state===0)return;if(e.state===Rt)return Mt(e);if(e.suspense&&Y(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<zt);)e.state&&t.push(e);for(let n=t.length-1;n>=0;n--)if(e=t[n],e.state===Ee)Ye(e);else if(e.state===Rt){const s=Z;Z=null,ce(()=>Mt(e,t[0]),!1),Z=s}}function ce(e,t){if(Z)return e();let n=!1;t||(Z=[]),fe?n=!0:fe=[],zt++;try{const s=e();return yo(n),s}catch(s){n||(fe=null),Z=null,Sn(s)}}function yo(e){if(Z&&(Ps(Z),Z=null),e)return;const t=fe;fe=null,t.length&&ce(()=>gs(t),!1)}function Ps(e){for(let t=0;t<e.length;t++)Dt(e[t])}function Ao(e){let t,n=0;for(t=0;t<e.length;t++){const s=e[t];s.user?e[n++]=s:Dt(s)}if(b.context){if(b.count){b.effects||(b.effects=[]),b.effects.push(...e.slice(0,n));return}Xe()}for(b.effects&&(b.done||!b.count)&&(e=[...b.effects,...e],n+=b.effects.length,delete b.effects),t=0;t<n;t++)Dt(e[t])}function Mt(e,t){e.state=0;for(let n=0;n<e.sources.length;n+=1){const s=e.sources[n];if(s.sources){const r=s.state;r===Ee?s!==t&&(!s.updatedAt||s.updatedAt<zt)&&Dt(s):r===Rt&&Mt(s,t)}}}function xs(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=Rt,n.pure?Z.push(n):fe.push(n),n.observers&&xs(n))}}function at(e){let t;if(e.sources)for(;e.sources.length;){const n=e.sources.pop(),s=e.sourceSlots.pop(),r=n.observers;if(r&&r.length){const a=r.pop(),i=n.observerSlots.pop();s<r.length&&(a.sourceSlots[i]=s,r[s]=a,n.observerSlots[s]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)at(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)at(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 Nt(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function Sn(e,t=D){throw Nt(e)}function tn(e){if(typeof e=="function"&&!e.length)return tn(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const s=tn(e[n]);Array.isArray(s)?t.push.apply(t,s):t.push(s)}return t}return e}function To(e,t){return function(s){let r;return Ae(()=>r=Y(()=>(D.context={...D.context,[e]:s.value},As(()=>s.children))),void 0),r}}var nn=Symbol("fallback");function Ut(e){for(let t=0;t<e.length;t++)e[t]()}function So(e,t,n={}){let s=[],r=[],a=[],i=0,l=t.length>1?[]:null;return $e(()=>Ut(a)),()=>{let c=e()||[],d=c.length,u,f;return c[An],Y(()=>{let m,S,A,P,_,T,C,G,q;if(d===0)i!==0&&(Ut(a),a=[],s=[],r=[],i=0,l&&(l=[])),n.fallback&&(s=[nn],r[0]=ye(N=>(a[0]=N,n.fallback())),i=1);else if(i===0){for(r=new Array(d),f=0;f<d;f++)s[f]=c[f],r[f]=ye(E);i=d}else{for(A=new Array(d),P=new Array(d),l&&(_=new Array(d)),T=0,C=Math.min(i,d);T<C&&s[T]===c[T];T++);for(C=i-1,G=d-1;C>=T&&G>=T&&s[C]===c[G];C--,G--)A[G]=r[C],P[G]=a[C],l&&(_[G]=l[C]);for(m=new Map,S=new Array(G+1),f=G;f>=T;f--)q=c[f],u=m.get(q),S[f]=u===void 0?-1:u,m.set(q,f);for(u=T;u<=C;u++)q=s[u],f=m.get(q),f!==void 0&&f!==-1?(A[f]=r[u],P[f]=a[u],l&&(_[f]=l[u]),f=S[f],m.set(q,f)):a[u]();for(f=T;f<d;f++)f in A?(r[f]=A[f],a[f]=P[f],l&&(l[f]=_[f],l[f](f))):r[f]=ye(E);r=r.slice(0,i=d),s=c.slice(0)}return r});function E(m){if(a[f]=m,l){const[S,A]=H(f);return l[f]=A,t(c[f],S)}return t(c[f])}}}function Po(e,t,n={}){let s=[],r=[],a=[],i=[],l=0,c;return $e(()=>Ut(a)),()=>{const d=e()||[],u=d.length;return d[An],Y(()=>{if(u===0)return l!==0&&(Ut(a),a=[],s=[],r=[],l=0,i=[]),n.fallback&&(s=[nn],r[0]=ye(E=>(a[0]=E,n.fallback())),l=1),r;for(s[0]===nn&&(a[0](),a=[],s=[],r=[],l=0),c=0;c<u;c++)c<s.length&&s[c]!==d[c]?i[c](()=>d[c]):c>=s.length&&(r[c]=ye(f));for(;c<s.length;c++)a[c]();return l=i.length=a.length=u,s=d.slice(0),r=r.slice(0,l)});function f(E){a[c]=E;const[m,S]=H(d[c]);return i[c]=S,t(m,c)}}}function Pn(e,t){return Y(()=>e(t||{}))}function vt(){return!0}var sn={get(e,t,n){return t===kt?n:e.get(t)},has(e,t){return t===kt?!0:e.has(t)},set:vt,deleteProperty:vt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:vt,deleteProperty:vt}},ownKeys(e){return e.keys()}};function Xt(e){return(e=typeof e=="function"?e():e)?e:{}}function xo(){for(let e=0,t=this.length;e<t;++e){const n=this[e]();if(n!==void 0)return n}}function xn(...e){let t=!1;for(let i=0;i<e.length;i++){const l=e[i];t=t||!!l&&kt in l,e[i]=typeof l=="function"?(t=!0,W(l)):l}if(hs&&t)return new Proxy({get(i){for(let l=e.length-1;l>=0;l--){const c=Xt(e[l])[i];if(c!==void 0)return c}},has(i){for(let l=e.length-1;l>=0;l--)if(i in Xt(e[l]))return!0;return!1},keys(){const i=[];for(let l=0;l<e.length;l++)i.push(...Object.keys(Xt(e[l])));return[...new Set(i)]}},sn);const n={},s=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 u=c[d];if(u==="__proto__"||u==="constructor")continue;const f=Object.getOwnPropertyDescriptor(l,u);if(!s[u])s[u]=f.get?{enumerable:!0,configurable:!0,get:xo.bind(n[u]=[f.get.bind(l)])}:f.value!==void 0?f:void 0;else{const E=n[u];E&&(f.get?E.push(f.get.bind(l)):f.value!==void 0&&E.push(()=>f.value))}}}const r={},a=Object.keys(s);for(let i=a.length-1;i>=0;i--){const l=a[i],c=s[l];c&&c.get?Object.defineProperty(r,l,c):r[l]=c?c.value:void 0}return r}function _s(e,...t){if(hs&&kt 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)}},sn));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))}},sn)),a}const n={},s=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?s[c][r]=a.value:Object.defineProperty(s[c],r,a)),++c;l||(i?n[r]=a.value:Object.defineProperty(n,r,a))}return[...s,n]}function ws(e){let t,n;const s=r=>{const a=b.context;if(a){const[l,c]=H();b.count||(b.count=0),b.count++,(n||(n=e())).then(d=>{!b.done&&Xe(a),b.count--,c(()=>d.default),Xe()}),t=l}else if(!t){const[l]=io(()=>(n||(n=e())).then(c=>c.default));t=l}let i;return W(()=>(i=t())?Y(()=>{if(!a||b.done)return i(r);const l=b.context;Xe(a);const c=i(r);return Xe(l),c}):"")};return s.preload=()=>n||((n=e()).then(r=>t=()=>r.default),n),s}var _o=0;function wo(){return b.context?b.getNextContextId():`cl-${_o++}`}var vs=e=>`Stale read from <${e}>.`;function vo(e){const t="fallback"in e&&{fallback:()=>e.fallback};return W(So(()=>e.each,e.children,t||void 0))}function bo(e){const t="fallback"in e&&{fallback:()=>e.fallback};return W(Po(()=>e.each,e.children,t||void 0))}function Co(e){const t=e.keyed,n=W(()=>e.when,void 0,void 0),s=t?n:W(n,void 0,{equals:(r,a)=>!r==!a});return W(()=>{const r=s();if(r){const a=e.children;return typeof a=="function"&&a.length>0?Y(()=>a(t?r:()=>{if(!Y(s))throw vs("Show");return n()})):a}return e.fallback},void 0,void 0)}function Io(e){const t=As(()=>e.children),n=W(()=>{const s=t(),r=Array.isArray(s)?s:[s];let a=()=>{};for(let i=0;i<r.length;i++){const l=i,c=r[i],d=a,u=W(()=>d()?void 0:c.when,void 0,void 0),f=c.keyed?u:W(u,void 0,{equals:(E,m)=>!E==!m});a=()=>d()||(f()?[l,u,c]:void 0)}return a});return W(()=>{const s=n()();if(!s)return e.fallback;const[r,a,i]=s,l=i.children;return typeof l=="function"&&l.length>0?Y(()=>l(i.keyed?a():()=>{var d;if(((d=Y(n)())==null?void 0:d[0])!==r)throw vs("Match");return a()})):l},void 0,void 0)}function Lo(e){return e}var No=["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"],jo=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",...No]),Go=new Set(["innerHTML","textContent","innerText","children"]),ko=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),Oo=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 Ro(e,t){const n=Oo[e];return typeof n=="object"?n[t]?n.$:void 0:n}var Do=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),Mo=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"]),Uo={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},Bo=e=>W(()=>e());function Fo(e,t,n){let s=n.length,r=t.length,a=s,i=0,l=0,c=t[r-1].nextSibling,d=null;for(;i<r||l<a;){if(t[i]===n[l]){i++,l++;continue}for(;t[r-1]===n[a-1];)r--,a--;if(r===i){const u=a<s?l?n[l-1].nextSibling:n[a-l]:c;for(;l<a;)e.insertBefore(n[l++],u)}else if(a===l)for(;i<r;)(!d||!d.has(t[i]))&&t[i].remove(),i++;else if(t[i]===n[a-1]&&n[l]===t[r-1]){const u=t[--r].nextSibling;e.insertBefore(n[l++],t[i++].nextSibling),e.insertBefore(n[--a],u),t[r]=n[a]}else{if(!d){d=new Map;let f=l;for(;f<a;)d.set(n[f],f++)}const u=d.get(t[i]);if(u!=null)if(l<u&&u<a){let f=i,E=1,m;for(;++f<r&&f<a&&!((m=d.get(t[f]))==null||m!==u+E);)E++;if(E>u-l){const S=t[i];for(;l<u;)e.insertBefore(n[l++],S)}else e.replaceChild(n[l++],t[i++])}else i++;else t[i++].remove()}}}var nt="_$DX_DELEGATE";function bs(e,t,n,s={}){let r;return ye(a=>{r=a,t===document?e():Ft(t,e(),t.firstChild?null:void 0,n)},s.owner),()=>{r(),t.textContent=""}}function qo(e,t,n,s){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 Cs(e,t=window.document){const n=t[nt]||(t[nt]=new Set);for(let s=0,r=e.length;s<r;s++){const a=e[s];n.has(a)||(n.add(a),t.addEventListener(a,Gs))}}function Ko(e=window.document){if(e[nt]){for(let t of e[nt].keys())e.removeEventListener(t,Gs);delete e[nt]}}function Bt(e,t,n){be(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function Vo(e,t,n,s){be(e)||(s==null?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,s))}function Ho(e,t,n){be(e)||(n?e.setAttribute(t,""):e.removeAttribute(t))}function Is(e,t){be(e)||(t==null?e.removeAttribute("class"):e.className=t)}function Ls(e,t,n,s){if(s)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){const r=n[0];e.addEventListener(t,n[0]=a=>r.call(e,n[1],a))}else e.addEventListener(t,n,typeof n!="function"&&n)}function Qo(e,t,n={}){const s=Object.keys(t||{}),r=Object.keys(n);let a,i;for(a=0,i=r.length;a<i;a++){const l=r[a];!l||l==="undefined"||t[l]||(On(e,l,!1),delete n[l])}for(a=0,i=s.length;a<i;a++){const l=s[a],c=!!t[l];!l||l==="undefined"||n[l]===c||!c||(On(e,l,!0),n[l]=c)}return n}function zo(e,t,n){if(!t)return n?Bt(e,"style"):t;const s=e.style;if(typeof t=="string")return s.cssText=t;typeof n=="string"&&(s.cssText=n=void 0),n||(n={}),t||(t={});let r,a;for(a in n)t[a]==null&&s.removeProperty(a),delete n[a];for(a in t)r=t[a],r!==n[a]&&(s.setProperty(a,r),n[a]=r);return n}function Ns(e,t={},n,s){const r={};return s||Ae(()=>r.children=ot(e,t.children,r.children)),Ae(()=>typeof t.ref=="function"&&js(t.ref,e)),Ae(()=>$o(e,t,n,!0,r,!0)),r}function js(e,t,n){return Y(()=>e(t,n))}function Ft(e,t,n,s){if(n!==void 0&&!s&&(s=[]),typeof t!="function")return ot(e,t,s,n);Ae(r=>ot(e,t(),r,n),s)}function $o(e,t,n,s,r={},a=!1){t||(t={});for(const i in r)if(!(i in t)){if(i==="children")continue;r[i]=Rn(e,i,null,r[i],n,a,t)}for(const i in t){if(i==="children")continue;const l=t[i];r[i]=Rn(e,i,l,r[i],n,a,t)}}function Wo(e){let t,n;return!be()||!(t=b.registry.get(n=Jo()))?e():(b.completed&&b.completed.add(t),b.registry.delete(n),t)}function be(e){return!!b.context&&!b.done&&(!e||e.isConnected)}function Yo(e){return e.toLowerCase().replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function On(e,t,n){const s=t.trim().split(/\s+/);for(let r=0,a=s.length;r<a;r++)e.classList.toggle(s[r],n)}function Rn(e,t,n,s,r,a,i){let l,c,d,u,f;if(t==="style")return zo(e,n,s);if(t==="classList")return Qo(e,n,s);if(n===s)return s;if(t==="ref")a||n(e);else if(t.slice(0,3)==="on:"){const E=t.slice(3);s&&e.removeEventListener(E,s,typeof s!="function"&&s),n&&e.addEventListener(E,n,typeof n!="function"&&n)}else if(t.slice(0,10)==="oncapture:"){const E=t.slice(10);s&&e.removeEventListener(E,s,!0),n&&e.addEventListener(E,n,!0)}else if(t.slice(0,2)==="on"){const E=t.slice(2).toLowerCase(),m=Do.has(E);if(!m&&s){const S=Array.isArray(s)?s[0]:s;e.removeEventListener(E,S)}(m||n)&&(Ls(e,E,n,m),m&&Cs([E]))}else if(t.slice(0,5)==="attr:")Bt(e,t.slice(5),n);else if(t.slice(0,5)==="bool:")Ho(e,t.slice(5),n);else if((f=t.slice(0,5)==="prop:")||(d=Go.has(t))||!r&&((u=Ro(t,e.tagName))||(c=jo.has(t)))||(l=e.nodeName.includes("-")||"is"in i)){if(f)t=t.slice(5),c=!0;else if(be(e))return n;t==="class"||t==="className"?Is(e,n):l&&!c&&!d?e[Yo(t)]=n:e[u||t]=n}else{const E=r&&t.indexOf(":")>-1&&Uo[t.split(":")[0]];E?Vo(e,E,t,n):Bt(e,ko[t]||t,n)}return n}function Gs(e){if(b.registry&&b.events&&b.events.find(([c,d])=>d===e))return;let t=e.target;const n=`$$${e.type}`,s=e.target,r=e.currentTarget,a=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),i=()=>{const c=t[n];if(c&&!t.disabled){const d=t[`${n}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(s)}function ot(e,t,n,s,r){const a=be(e);if(a){!n&&(n=[...e.childNodes]);let c=[];for(let d=0;d<n.length;d++){const u=n[d];u.nodeType===8&&u.data.slice(0,2)==="!$"?u.remove():c.push(u)}n=c}for(;typeof n=="function";)n=n();if(t===n)return n;const i=typeof t,l=s!==void 0;if(e=l&&n[0]&&n[0].parentNode||e,i==="string"||i==="number"){if(a||i==="number"&&(t=t.toString(),t===n))return n;if(l){let c=n[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),n=Ie(e,n,s,c)}else n!==""&&typeof n=="string"?n=e.firstChild.data=t:n=e.textContent=t}else if(t==null||i==="boolean"){if(a)return n;n=Ie(e,n,s)}else{if(i==="function")return Ae(()=>{let c=t();for(;typeof c=="function";)c=c();n=ot(e,c,n,s)}),()=>n;if(Array.isArray(t)){const c=[],d=n&&Array.isArray(n);if(rn(c,t,n,r))return Ae(()=>n=ot(e,c,n,s,!0)),()=>n;if(a){if(!c.length)return n;if(s===void 0)return n=[...e.childNodes];let u=c[0];if(u.parentNode!==e)return n;const f=[u];for(;(u=u.nextSibling)!==s;)f.push(u);return n=f}if(c.length===0){if(n=Ie(e,n,s),l)return n}else d?n.length===0?Dn(e,c,s):Fo(e,n,c):(n&&Ie(e),Dn(e,c));n=c}else if(t.nodeType){if(a&&t.parentNode)return n=l?[t]:t;if(Array.isArray(n)){if(l)return n=Ie(e,n,s,t);Ie(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function rn(e,t,n,s){let r=!1;for(let a=0,i=t.length;a<i;a++){let l=t[a],c=n&&n[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=rn(e,l,c)||r;else if(d==="function")if(s){for(;typeof l=="function";)l=l();r=rn(e,Array.isArray(l)?l:[l],Array.isArray(c)?c:[c])||r}else e.push(l),r=!0;else{const u=String(l);c&&c.nodeType===3&&c.data===u?e.push(c):e.push(document.createTextNode(u))}}return r}function Dn(e,t,n=null){for(let s=0,r=t.length;s<r;s++)e.insertBefore(t[s],n)}function Ie(e,t,n,s){if(n===void 0)return e.textContent="";const r=s||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,n):c&&l.remove()}else a=!0}}else e.insertBefore(r,n);return[r]}function Jo(){return b.getNextContextId()}var Zo="http://www.w3.org/2000/svg";function ks(e,t=!1){return t?document.createElementNS(Zo,e):document.createElement(e)}function Xo(e){const{useShadow:t}=e,n=document.createTextNode(""),s=()=>e.mount||document.body,r=kn();let a,i=!!b.context;return Tn(()=>{i&&(kn().user=i=!1),a||(a=ys(r,()=>W(()=>e.children)));const l=s();if(l instanceof HTMLHeadElement){const[c,d]=H(!1),u=()=>d(!0);ye(f=>Ft(l,()=>c()?f():a(),null)),$e(u)}else{const c=ks(e.isSVG?"g":"div",e.isSVG),d=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return n.parentNode},configurable:!0}),Ft(d,a),l.appendChild(c),e.ref&&e.ref(c),$e(()=>l.removeChild(c))}},void 0,{render:!i}),n}function ei(e,t){const n=W(e);return W(()=>{const s=n();switch(typeof s){case"function":return Y(()=>s(t));case"string":const r=Mo.has(s),a=b.context?Wo():ks(s,r);return Ns(a,t,r),a}})}function ti(e){const[,t]=_s(e,["component"]);return ei(()=>e.component,t)}var ni=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()}},Os=class{constructor(e){this.generateIdentifier=e,this.kv=new ni}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)}},si=class extends Os{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 ri(e){if("values"in Object)return Object.values(e);const t=[];for(const n in e)e.hasOwnProperty(n)&&t.push(e[n]);return t}function ai(e,t){const n=ri(e);if("find"in n)return n.find(t);const s=n;for(let r=0;r<s.length;r++){const a=s[r];if(t(a))return a}}function We(e,t){Object.entries(e).forEach(([n,s])=>t(s,n))}function jt(e,t){return e.indexOf(t)!==-1}function Mn(e,t){for(let n=0;n<e.length;n++){const s=e[n];if(t(s))return s}}var oi=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return ai(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},ii=e=>Object.prototype.toString.call(e).slice(8,-1),Rs=e=>typeof e>"u",li=e=>e===null,it=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,an=e=>it(e)&&Object.keys(e).length===0,Te=e=>Array.isArray(e),ci=e=>typeof e=="string",ui=e=>typeof e=="number"&&!isNaN(e),di=e=>typeof e=="boolean",fi=e=>e instanceof RegExp,lt=e=>e instanceof Map,ct=e=>e instanceof Set,Ds=e=>ii(e)==="Symbol",hi=e=>e instanceof Date&&!isNaN(e.valueOf()),gi=e=>e instanceof Error,Un=e=>typeof e=="number"&&isNaN(e),mi=e=>di(e)||li(e)||Rs(e)||ui(e)||ci(e)||Ds(e),Ei=e=>typeof e=="bigint",pi=e=>e===1/0||e===-1/0,yi=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),Ai=e=>e instanceof URL,Ms=e=>e.replace(/\./g,"\\."),en=e=>e.map(String).map(Ms).join("."),st=e=>{const t=[];let n="";for(let r=0;r<e.length;r++){let a=e.charAt(r);if(a==="\\"&&e.charAt(r+1)==="."){n+=".",r++;continue}if(a==="."){t.push(n),n="";continue}n+=a}const s=n;return t.push(s),t};function le(e,t,n,s){return{isApplicable:e,annotation:t,transform:n,untransform:s}}var Us=[le(Rs,"undefined",()=>null,()=>{}),le(Ei,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),le(hi,"Date",e=>e.toISOString(),e=>new Date(e)),le(gi,"Error",(e,t)=>{const n={name:e.name,message:e.message};return t.allowedErrorProps.forEach(s=>{n[s]=e[s]}),n},(e,t)=>{const n=new Error(e.message);return n.name=e.name,n.stack=e.stack,t.allowedErrorProps.forEach(s=>{n[s]=e[s]}),n}),le(fi,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),n=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,n)}),le(ct,"set",e=>[...e.values()],e=>new Set(e)),le(lt,"map",e=>[...e.entries()],e=>new Map(e)),le(e=>Un(e)||pi(e),"number",e=>Un(e)?"NaN":e>0?"Infinity":"-Infinity",Number),le(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),le(Ai,"URL",e=>e.toString(),e=>new URL(e))];function Wt(e,t,n,s){return{isApplicable:e,annotation:t,transform:n,untransform:s}}var Bs=Wt((e,t)=>Ds(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,n)=>{const s=n.symbolRegistry.getValue(t[1]);if(!s)throw new Error("Trying to deserialize unknown symbol");return s}),Ti=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),Fs=Wt(yi,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const n=Ti[t[1]];if(!n)throw new Error("Trying to deserialize unknown typed array");return new n(e)});function qs(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var Ks=Wt(qs,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const n=t.classRegistry.getAllowedProps(e.constructor);if(!n)return{...e};const s={};return n.forEach(r=>{s[r]=e[r]}),s},(e,t,n)=>{const s=n.classRegistry.getValue(t[1]);if(!s)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(s.prototype),e)}),Vs=Wt((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,n)=>{const s=n.customTransformerRegistry.findByName(t[1]);if(!s)throw new Error("Trying to deserialize unknown custom value");return s.deserialize(e)}),Si=[Ks,Bs,Vs,Fs],Bn=(e,t)=>{const n=Mn(Si,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation(e,t)};const s=Mn(Us,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation}},Hs={};Us.forEach(e=>{Hs[e.annotation]=e});var Pi=(e,t,n)=>{if(Te(t))switch(t[0]){case"symbol":return Bs.untransform(e,t,n);case"class":return Ks.untransform(e,t,n);case"custom":return Vs.untransform(e,t,n);case"typed-array":return Fs.untransform(e,t,n);default:throw new Error("Unknown transformation: "+t)}else{const s=Hs[t];if(!s)throw new Error("Unknown transformation: "+t);return s.untransform(e,n)}},Le=(e,t)=>{if(t>e.size)throw new Error("index out of bounds");const n=e.keys();for(;t>0;)n.next(),t--;return n.next().value};function Qs(e){if(jt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(jt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(jt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var xi=(e,t)=>{Qs(t);for(let n=0;n<t.length;n++){const s=t[n];if(ct(e))e=Le(e,+s);else if(lt(e)){const r=+s,a=+t[++n]==0?"key":"value",i=Le(e,r);switch(a){case"key":e=i;break;case"value":e=e.get(i);break}}else e=e[s]}return e},on=(e,t,n)=>{if(Qs(t),t.length===0)return n(e);let s=e;for(let a=0;a<t.length-1;a++){const i=t[a];if(Te(s)){const l=+i;s=s[l]}else if(it(s))s=s[i];else if(ct(s)){const l=+i;s=Le(s,l)}else if(lt(s)){if(a===t.length-2)break;const c=+i,d=+t[++a]==0?"key":"value",u=Le(s,c);switch(d){case"key":s=u;break;case"value":s=s.get(u);break}}}const r=t[t.length-1];if(Te(s)?s[+r]=n(s[+r]):it(s)&&(s[r]=n(s[r])),ct(s)){const a=Le(s,+r),i=n(a);a!==i&&(s.delete(a),s.add(i))}if(lt(s)){const a=+t[t.length-2],i=Le(s,a);switch(+r==0?"key":"value"){case"key":{const c=n(i);s.set(c,s.get(i)),c!==i&&s.delete(i);break}case"value":{s.set(i,n(s.get(i)));break}}}return e};function ln(e,t,n=[]){if(!e)return;if(!Te(e)){We(e,(a,i)=>ln(a,t,[...n,...st(i)]));return}const[s,r]=e;r&&We(r,(a,i)=>{ln(a,t,[...n,...st(i)])}),t(s,n)}function _i(e,t,n){return ln(t,(s,r)=>{e=on(e,r,a=>Pi(a,s,n))}),e}function wi(e,t){function n(s,r){const a=xi(e,st(r));s.map(st).forEach(i=>{e=on(e,i,()=>a)})}if(Te(t)){const[s,r]=t;s.forEach(a=>{e=on(e,st(a),()=>e)}),r&&We(r,n)}else We(t,n);return e}var vi=(e,t)=>it(e)||Te(e)||lt(e)||ct(e)||qs(e,t);function bi(e,t,n){const s=n.get(e);s?s.push(t):n.set(e,[t])}function Ci(e,t){const n={};let s;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?s=i.map(en):n[en(a)]=i.map(en)}),s?an(n)?[s]:[s,n]:an(n)?void 0:n}var zs=(e,t,n,s,r=[],a=[],i=new Map)=>{const l=mi(e);if(!l){bi(e,r,t);const m=i.get(e);if(m)return s?{transformedValue:null}:m}if(!vi(e,n)){const m=Bn(e,n),S=m?{transformedValue:m.value,annotations:[m.type]}:{transformedValue:e};return l||i.set(e,S),S}if(jt(a,e))return{transformedValue:null};const c=Bn(e,n),d=(c==null?void 0:c.value)??e,u=Te(d)?[]:{},f={};We(d,(m,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 A=zs(m,t,n,s,[...r,S],[...a,e],i);u[S]=A.transformedValue,Te(A.annotations)?f[S]=A.annotations:it(A.annotations)&&We(A.annotations,(P,_)=>{f[Ms(S)+"."+_]=P})});const E=an(f)?{transformedValue:u,annotations:c?[c.type]:void 0}:{transformedValue:u,annotations:c?[c.type,f]:f};return l||i.set(e,E),E};function $s(e){return Object.prototype.toString.call(e).slice(8,-1)}function Fn(e){return $s(e)==="Array"}function Ii(e){if($s(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function Li(e,t,n,s,r){const a={}.propertyIsEnumerable.call(s,t)?"enumerable":"nonenumerable";a==="enumerable"&&(e[t]=n),r&&a==="nonenumerable"&&Object.defineProperty(e,t,{value:n,enumerable:!1,writable:!0,configurable:!0})}function cn(e,t={}){if(Fn(e))return e.map(r=>cn(r,t));if(!Ii(e))return e;const n=Object.getOwnPropertyNames(e),s=Object.getOwnPropertySymbols(e);return[...n,...s].reduce((r,a)=>{if(Fn(t.props)&&!t.props.includes(a))return r;const i=e[a],l=cn(i,t);return Li(r,a,l,e,t.nonenumerable),r},{})}var B=class{constructor({dedupe:e=!1}={}){this.classRegistry=new si,this.symbolRegistry=new Os(t=>t.description??""),this.customTransformerRegistry=new oi,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,n=zs(e,t,this,this.dedupe),s={json:n.transformedValue};n.annotations&&(s.meta={...s.meta,values:n.annotations});const r=Ci(t,this.dedupe);return r&&(s.meta={...s.meta,referentialEqualities:r}),s}deserialize(e){const{json:t,meta:n}=e;let s=cn(t);return n!=null&&n.values&&(s=_i(s,n.values,this)),n!=null&&n.referentialEqualities&&(s=wi(s,n.referentialEqualities)),s}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 Ws=B.serialize,Ni=B.stringify;function ji(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function Gi(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function ki({queryState:e,observerCount:t,isStale:n}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":n?"yellow":"green":"gray"}function Oi({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function Ri(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var Di=(e,t=!1)=>{const{json:n}=Ws(e);return JSON.stringify(n,null,t?2:void 0)},bt=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,Mi=(e,t)=>e.queryHash.localeCompare(t.queryHash),Ys=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,Ui=(e,t)=>bt(e)===bt(t)?Ys(e,t):bt(e)>bt(t)?1:-1,Bi={status:Ui,"query hash":Mi,"last updated":Ys},Ct=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,Js=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,Fi=(e,t)=>Ct(e)===Ct(t)?Js(e,t):Ct(e)>Ct(t)?1:-1,qi={status:Fi,"last updated":Js},Ki=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),Vi=()=>{const[e,t]=H("dark");return ps(()=>{const n=window.matchMedia("(prefers-color-scheme: dark)");t(n.matches?"dark":"light");const s=r=>{t(r.matches?"dark":"light")};n.addEventListener("change",s),$e(()=>n.removeEventListener("change",s))}),e},et=(e,t,n)=>{if(t.length===0)return n;if(e instanceof Map){const s=new Map(e);if(t.length===1)return s.set(t[0],n),s;const[r,...a]=t;return s.set(r,et(s.get(r),a,n)),s}if(e instanceof Set){const s=et(Array.from(e),t,n);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s[t[0]]=n,s;const[r,...a]=t;return s[r]=et(s[r],a,n),s}if(e instanceof Object){const s={...e};if(t.length===1)return s[t[0]]=n,s;const[r,...a]=t;return s[r]=et(s[r],a,n),s}return e},tt=(e,t)=>{if(e instanceof Map){const n=new Map(e);if(t.length===1)return n.delete(t[0]),n;const[s,...r]=t;return n.set(s,tt(n.get(s),r)),n}if(e instanceof Set){const n=tt(Array.from(e),t);return new Set(n)}if(Array.isArray(e)){const n=[...e];if(t.length===1)return n.filter((a,i)=>i.toString()!==t[0]);const[s,...r]=t;return n[s]=tt(n[s],r),n}if(e instanceof Object){const n={...e};if(t.length===1)return delete n[t[0]],n;const[s,...r]=t;return n[s]=tt(n[s],r),n}return e},Zs=(e,t)=>{if(!e||document.querySelector("#_goober")||(t==null?void 0:t.querySelector("#_goober")))return;const s=document.createElement("style"),r=document.createTextNode("");s.appendChild(r),s.id="_goober",s.setAttribute("nonce",e),t?t.appendChild(s):document.head.appendChild(s)},Ne,ut,dt,ft,we,ht,je,Ge,ke,Oe,Re,gt,De,Me,mt,Vn,Hi=(Vn=class{constructor(e){M(this,Ne);M(this,ut);M(this,dt);M(this,ft);M(this,we,!1);M(this,ht);M(this,je);M(this,Ge);M(this,ke);M(this,Oe);M(this,Re);M(this,gt);M(this,De);M(this,Me);M(this,mt);const{client:t,queryFlavor:n,version:s,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:u,hideDisabledQueries:f,theme:E}=e;R(this,Ne,H(t)),R(this,dt,n),R(this,ft,s),R(this,ut,r),R(this,ht,d),R(this,je,u),R(this,Ge,H(a)),R(this,ke,H(i)),R(this,Oe,H(l)),R(this,Re,H(c)),R(this,gt,H(f)),R(this,Me,H(E))}setButtonPosition(e){w(this,Ge)[1](e)}setPosition(e){w(this,ke)[1](e)}setInitialIsOpen(e){w(this,Oe)[1](e)}setErrorTypes(e){w(this,Re)[1](e)}setClient(e){w(this,Ne)[1](e)}setTheme(e){w(this,Me)[1](e)}mount(e){if(w(this,we))throw new Error("Devtools is already mounted");const t=bs(()=>{const n=this,[s]=w(this,Ge),[r]=w(this,ke),[a]=w(this,Oe),[i]=w(this,Re),[l]=w(this,gt),[c]=w(this,Ne),[d]=w(this,Me);let u;return w(this,De)?u=w(this,De):(u=ws(()=>Promise.resolve().then(()=>require("./WDYDFRGG-BnH0DBnC.cjs"))),R(this,De,u)),Zs(w(this,ht),w(this,je)),Pn(u,xn({get queryFlavor(){return w(n,dt)},get version(){return w(n,ft)},get onlineManager(){return w(n,ut)},get shadowDOMTarget(){return w(n,je)}},{get client(){return c()},get buttonPosition(){return s()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()},get theme(){return d()}}))},e);R(this,we,!0),R(this,mt,t)}unmount(){var e;if(!w(this,we))throw new Error("Devtools is not mounted");(e=w(this,mt))==null||e.call(this),R(this,we,!1)}},Ne=new WeakMap,ut=new WeakMap,dt=new WeakMap,ft=new WeakMap,we=new WeakMap,ht=new WeakMap,je=new WeakMap,Ge=new WeakMap,ke=new WeakMap,Oe=new WeakMap,Re=new WeakMap,gt=new WeakMap,De=new WeakMap,Me=new WeakMap,mt=new WeakMap,Vn),Ue,Et,pt,yt,ve,At,Be,Fe,qe,Ke,Ve,Tt,He,Qe,ze,St,Hn,Qi=(Hn=class{constructor(e){M(this,Ue);M(this,Et);M(this,pt);M(this,yt);M(this,ve,!1);M(this,At);M(this,Be);M(this,Fe);M(this,qe);M(this,Ke);M(this,Ve);M(this,Tt);M(this,He);M(this,Qe);M(this,ze);M(this,St);const{client:t,queryFlavor:n,version:s,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:u,onClose:f,hideDisabledQueries:E,theme:m}=e;R(this,Ue,H(t)),R(this,pt,n),R(this,yt,s),R(this,Et,r),R(this,At,d),R(this,Be,u),R(this,Fe,H(a)),R(this,qe,H(i)),R(this,Ke,H(l)),R(this,Ve,H(c)),R(this,Tt,H(E)),R(this,He,H(f)),R(this,ze,H(m))}setButtonPosition(e){w(this,Fe)[1](e)}setPosition(e){w(this,qe)[1](e)}setInitialIsOpen(e){w(this,Ke)[1](e)}setErrorTypes(e){w(this,Ve)[1](e)}setClient(e){w(this,Ue)[1](e)}setOnClose(e){w(this,He)[1](()=>e)}setTheme(e){w(this,ze)[1](e)}mount(e){if(w(this,ve))throw new Error("Devtools is already mounted");const t=bs(()=>{const n=this,[s]=w(this,Fe),[r]=w(this,qe),[a]=w(this,Ke),[i]=w(this,Ve),[l]=w(this,Tt),[c]=w(this,Ue),[d]=w(this,He),[u]=w(this,ze);let f;return w(this,Qe)?f=w(this,Qe):(f=ws(()=>Promise.resolve().then(()=>require("./2SSKDMRQ-BqJwQTJP.cjs"))),R(this,Qe,f)),Zs(w(this,At),w(this,Be)),Pn(f,xn({get queryFlavor(){return w(n,pt)},get version(){return w(n,yt)},get onlineManager(){return w(n,Et)},get shadowDOMTarget(){return w(n,Be)}},{get client(){return c()},get buttonPosition(){return s()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()},get onClose(){return d()},get theme(){return u()}}))},e);R(this,ve,!0),R(this,St,t)}unmount(){var e;if(!w(this,ve))throw new Error("Devtools is not mounted");(e=w(this,St))==null||e.call(this),R(this,ve,!1)}},Ue=new WeakMap,Et=new WeakMap,pt=new WeakMap,yt=new WeakMap,ve=new WeakMap,At=new WeakMap,Be=new WeakMap,Fe=new WeakMap,qe=new WeakMap,Ke=new WeakMap,Ve=new WeakMap,Tt=new WeakMap,He=new WeakMap,Qe=new WeakMap,ze=new WeakMap,St=new WeakMap,Hn);function zi(e){const t=x.useQueryClient(e.client),n=z.useRef(null),{buttonPosition:s,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d,theme:u}=e,[f]=z.useState(new Hi({client:t,queryFlavor:"React Query",version:"5",onlineManager:x.onlineManager,buttonPosition:s,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d,theme:u}));return z.useEffect(()=>{f.setClient(t)},[t,f]),z.useEffect(()=>{s&&f.setButtonPosition(s)},[s,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(()=>{f.setTheme(u)},[u,f]),z.useEffect(()=>(n.current&&f.mount(n.current),()=>{f.unmount()}),[f]),o.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:n})}function $i(e){const t=x.useQueryClient(e.client),n=z.useRef(null),{errorTypes:s,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:i,theme:l}=e,[c]=z.useState(new Qi({client:t,queryFlavor:"React Query",version:"5",onlineManager:x.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:s,styleNonce:r,shadowDOMTarget:a,onClose:e.onClose,hideDisabledQueries:i,theme:l}));return z.useEffect(()=>{c.setClient(t)},[t,c]),z.useEffect(()=>{c.setOnClose(e.onClose??(()=>{}))},[e.onClose,c]),z.useEffect(()=>{c.setErrorTypes(s||[])},[s,c]),z.useEffect(()=>{c.setTheme(l)},[l,c]),z.useEffect(()=>(n.current&&c.mount(n.current),()=>{c.unmount()}),[c]),o.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:n})}var qn=process.env.NODE_ENV!=="development"?function(){return null}:zi;process.env.NODE_ENV;const Xs=Q.atom(""),Wi=()=>{I.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),I.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"})},Yi=()=>{const e=L(),t=k();return x.useQuery({queryKey:[y.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:y.GET_COLLECTIONS})})},Ji=()=>{const{data:e}=ne(),{data:t}=ge(),{data:n}=Pe(),s=L(),r=k(),a=h.useMemo(()=>(n==null?void 0:n.fallbackLang)||"en",[n==null?void 0:n.fallbackLang]),i=h.useRef(new Map);return x.useMutation({mutationFn:async({block:l})=>{const c=l._id,d=(t==null?void 0:t.lang)||a,u=`${c}:${d}`;if(i.current.has(u))return i.current.get(u);const f=r(s,{action:y.GET_BLOCK_ASYNC_PROPS,data:{block:l,lang:d,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}}});return i.current.set(u,f),f.finally(()=>{i.current.delete(u)}),f}})},er=()=>{const[,e]=ue();return h.useCallback((t,n)=>{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")),n==null||n()},[e])},tr=()=>{const e=er();return h.useCallback(({pageId:t})=>{e(t)},[e])},Zi={SITE_WIDE_USAGE:"SITE_WIDE_USAGE"},Xi=e=>{const t=k(),n=L();return x.useQuery({queryKey:[Zi.SITE_WIDE_USAGE],queryFn:async()=>e?t(n,{action:"GET_SITE_WIDE_USAGE"}):{},retry:!1})},el=h.lazy(()=>Promise.resolve().then(()=>require("./page-lock-DeJdUgZb.cjs"))),tl=h.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-dialog-Bjbyvuda.cjs"))),nl=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-CiRIglzD.cjs"))),sl=h.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-CcFk-jmu.cjs"))),rl=h.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-CPfiA7BL.cjs"))),al=h.lazy(()=>Promise.resolve().then(()=>require("./web-preview-Dga82dCu.cjs")));Wi();yr.loadWebBlocks();I.registerChaiTopBar(Na);so();I.registerChaiMediaManager(nl);I.registerChaiSaveToLibrary(sl);const ol={role:"",permissions:null},Kn=e=>{const{isLoading:t}=qa();return t?o.jsx(Ht,{className:"fixed inset-0 bg-white",children:o.jsx(v.Loader,{className:"h-6 w-6 animate-spin text-primary"})}):o.jsx(il,{...e})},il=e=>{var vn;const{data:t}=Fa(),n=Vt(),{data:s=ol,isFetching:r}=is(),{data:a,isFetching:i}=me(),{data:l,isFetching:c}=Yi(),{data:d,isFetching:u}=Pe(),f=r||i||c||u,[E]=ue(),m=E.get("page"),{data:S}=ne(),{data:A,isFetching:P}=ka(),{blocks:_}=Ga(A),{data:T,isFetching:C}=as(),{pageStatus:G}=oe(),q=ja(),{onSave:N}=Ka(),{mutateAsync:ie}=Ji(),{getPartialBlocks:de,getPartialBlockBlocks:V}=Va(),{mutateAsync:j}=Lr(),{mutateAsync:O}=os(),{data:$}=Xi(((vn=e.flags)==null?void 0:vn.designTokens)??!0),K=tr(),[ee,xe]=h.useState(!1),se=h.useRef([]),Ce=h.useMemo(()=>p.get(d,"theme",{})||{},[d]),_e=G===J.EDITING,sr=G===J.CHECKING,_n=P||sr||C;h.useEffect(()=>{se.current=_},[_]);const[rr]=Q.useAtom(Xs);h.useEffect(()=>{const te=()=>{document.hidden?xe(!0):xe(!1)};return window.addEventListener("visibilitychange",te),()=>window.removeEventListener("visibilitychange",te)},[]);const ar=h.useMemo(()=>{const te={};return s&&(te.permissions=p.get(s,"permissions",null),te.role=p.get(s,"role","user")),te},[s]),wn=h.useMemo(()=>t==null?void 0:t.some(te=>te.isSiteLibrary),[t]),or=h.useCallback(async(te,_t)=>await j({pageType:te,query:_t}),[j]);return o.jsxs(o.Fragment,{children:[_n&&o.jsx(Ht,{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"}`})}),rr&&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(al,{})}),o.jsx(g.ChaiBuilderEditor,{siteWideUsage:$??{},flags:e.flags?{...e.flags,librarySite:wn}:{librarySite:wn},gotoPage:K,collections:l??[],getBlockAsyncProps:ie,pageExternalData:T,themePresets:e.themePresets??[],pageId:S==null?void 0:S.id,loading:P,fallbackLang:n,languages:(d==null?void 0:d.languages)||[],brandingOptions:(d==null?void 0:d.theme)||{},designTokens:(d==null?void 0:d.designTokens)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!ee&&_e&&(e.autoSave??!0),autoSaveActionsCount:e.autoSaveActionsCount??10,onError:e.onError||console.error,getPartialBlockBlocks:V,getPartialBlocks:de,blocks:P?[]:_,theme:p.cloneDeep(Ce),pageTypes:a,searchPageTypeItems:or,askAiCallBack:q,onSave:async({blocks:te,theme:_t,needTranslations:ir,designTokens:bn})=>{if(!m)return!0;se.current=te;const Cn=[...te];await N({page:m,blocks:Cn,needTranslations:ir}),se.current=Cn;const wt={};return p.isEqual(_t,Ce)||(wt.theme=_t),p.isEqual(bn,d==null?void 0:d.designTokens)||(wt.designTokens=bn),p.isEmpty(wt)||await O({settings:wt}),!0},themePanelComponent:rl,...ar,children:o.jsx(el,{isFetchingPageData:_n})}),o.jsx("div",{children:o.jsx(tl,{})})]})},ll=new x.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),cl=e=>{const[,t]=qt(),[n,s]=h.useState(!1);return h.useEffect(()=>(t(p.pick(e,["apiUrl","usersApiUrl","assetsApiUrl","getPreviewUrl","getLiveUrl","topLeftCorner","onLogout","getAccessToken","websocket","getLoggedInUser","features","currentUser"])),setTimeout(()=>{s(!0)},200),()=>{s(!1),t({})}),[e,t]),n?p.get(e,"hasReactQueryProvider",!1)===!0?o.jsxs(o.Fragment,{children:[o.jsx(Kn,{...e}),o.jsx(qn,{})]}):o.jsxs(x.QueryClientProvider,{client:ll,children:[o.jsx(Kn,{...e}),o.jsx(qn,{})]}):o.jsx("div",{})},ul=z.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-CHYz7cdB.cjs")));function nr({data:e,onSelect:t,dataType:n="value",disabled:s=!1}){const[r,a]=z.useState(!1);return o.jsxs(g.Popover,{open:r,onOpenChange:a,children:[o.jsxs(g.Tooltip,{children:[o.jsx(g.TooltipTrigger,{asChild:!0,children:o.jsx(g.PopoverTrigger,{asChild:!0,children:o.jsx(I.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:s,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(g.TooltipContent,{children:"Add field"})]}),r&&o.jsx(z.Suspense,{children:o.jsx(ul,{data:e,onSelect:t,dataType:n,open:r,setOpen:a})})]})}const dl=()=>{const{savePageAsync:e}=g.useSavePage(),t=x.useQueryClient(),{isLocked:n}=oe();return h.useCallback(async()=>{n||await e(),t.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]})},[e,t,n])},fl=()=>{const e=x.useQueryClient();return h.useCallback(()=>{e.clear()},[e])},hl=()=>{const e=L(),t=k(),{data:n}=ge(),s=x.useQueryClient();return x.useMutation({mutationFn:async r=>{if(!(n!=null&&n.id))throw new Error("No active page found");return await t(`${e}`,{action:y.UPDATE_PAGE_METADATA,data:{id:n.id,metadata:r}})},onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]}),s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]})},onError:()=>{console.error("Failed to update metadata")}})},gl=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-CiRIglzD.cjs"))),ml=({assetId:e,assetUrl:t,onChange:n,className:s="",placeholder:r="Select an image",disabled:a=!1})=>{const{t:i}=he.useTranslation(),[l,c]=h.useState(!1),d=()=>{a||c(!0)},u=()=>{c(!1)},f=S=>{const A=Array.isArray(S)?S[0]:S;A!=null&&A.url&&n(p.pick(A,["url","id"])),c(!1)},E=()=>{n({url:"",id:""})},m=(t==null?void 0:t.startsWith("{{"))&&(t==null?void 0:t.endsWith("}}"));return o.jsxs("div",{className:`w-full ${s}`,children:[t?o.jsxs("div",{className:"relative overflow-hidden rounded-md border",children:[m?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:d,src:t,alt:i("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(I.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white text-red-500",onClick:E,disabled:a,children:m?o.jsx(v.X,{className:"h-4 w-4"}):o.jsx(v.Trash2,{className:"h-4 w-4"})}),!m&&o.jsx(I.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white/80 hover:bg-white/90",onClick:d,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:d,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(g.Dialog,{open:l,onOpenChange:c,children:o.jsxs(g.DialogContent,{className:"h-fit w-full max-w-7xl overflow-hidden p-0",children:[o.jsxs(g.DialogHeader,{className:"hidden border-b px-4 py-2",children:[o.jsx(g.DialogTitle,{children:i("Select Image")}),o.jsx(I.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:u,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(gl,{close:u,onSelect:f,mode:"image",assetId:e})})})]})})]})},El=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),un=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,n=[];let s=e,r;for(;(r=t.exec(e))!==null;){const a=r[0],i=r.index,l=`"__placeholder_${n.length}__"`;n.push({original:a,replaced:l,position:i}),s=s.replace(a,l)}try{return{isValid:!0,parsed:JSON.parse(s),error:null,placeholders:n}}catch(a){const i=a,l=i.message.match(/position (\d+)/),c=l?parseInt(l[1]):void 0;let d,u;if(c!==void 0){const f=s.substring(0,c).split(`
|
|
2
|
-
`);d=f.length,u=f[f.length-1].length+1}return{isValid:!1,parsed:null,placeholders:n,error:{message:i.message,line:d,column:u,position:c}}}},pl=(e,t)=>{let s=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const i=`"__placeholder_${a}__"`,l=new RegExp(El(i),"g");s=s.replace(l,r)}),s},yl=(e,t)=>{if(!e)return"";let n=JSON.stringify(e,null,2);const s=/{{([^{}]+)}}/g;let r;for(;(r=s.exec(n))!==null;){const a=r[1],i=p.get(t,a,null);n=n.replace(r[0],i)}return n},Al=h.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-BIi5Rt26.cjs"))),Tl=({value:e,onChange:t,disabled:n=!1,readOnly:s=!1,placeholder:r="Enter JSON",rows:a=6,id:i="json-input",pageData:l={},handleFieldInsert:c,hasJsonLdForSelectedLang:d,copyJsonLDFromDefaultPage:u})=>{const[f,E]=h.useState("edit"),[m,S]=h.useState(null),[A,P]=h.useState(""),_=h.useRef(null),[T]=qt(),C=i==="jsonLD"&&p.get(T,"features.sharedJsonLD",!1),G=i==="jsonLD"&&!d&&!!u;h.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const q=V=>{if(s)return;const j=V.target.value;t(j)},N=V=>{if(V.key==="Tab"){V.preventDefault();const j=V.currentTarget,O=j.selectionStart,$=j.selectionEnd;if(O!==$){const ee=e.substring(O,$).split(`
|
|
3
|
-
`);if(V.shiftKey){const se=ee.map(_e=>_e.startsWith(" ")?_e.substring(2):_e).join(`
|
|
4
|
-
`),Ce=e.substring(0,O)+se+e.substring($);t(Ce),setTimeout(()=>{j.selectionStart=O,j.selectionEnd=O+se.length},0)}else{const se=ee.map(_e=>` ${_e}`).join(`
|
|
5
|
-
`),Ce=e.substring(0,O)+se+e.substring($);t(Ce),setTimeout(()=>{j.selectionStart=O,j.selectionEnd=O+se.length},0)}}else{const K=e.substring(0,O)+" "+e.substring($);t(K),setTimeout(()=>{j.selectionStart=j.selectionEnd=O+2},0)}}};h.useEffect(()=>{const V=un(e);V.isValid?h.startTransition(()=>{if(S(null),V.parsed){const j=yl(V.parsed,l);P(j)}else P("")}):h.startTransition(()=>{S(V.error),P("")})},[e,l]);const ie=()=>{const V=un(e);if(V.isValid&&V.parsed){const j=pl(V.parsed,V.placeholders);t(j)}},de=()=>{m!=null&&m.position&&_.current&&(_.current.focus(),_.current.setSelectionRange(m.position,m.position+1))};return o.jsx(Ar.ErrorBoundary,{fallback:o.jsx("div",{children:"Some error"}),children:o.jsx("div",{className:"space-y-2",children:o.jsxs(g.Tabs,{value:f,onValueChange:E,className:"w-full",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[o.jsxs(g.TabsList,{className:"w-max",children:[o.jsxs(g.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(g.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!e.trim()||m!==null||G,children:[o.jsx(v.Eye,{className:"h-4 w-4"}),o.jsx("span",{children:"Preview"})]}),C&&o.jsxs(g.TabsTrigger,{value:"shared",className:"flex items-center gap-1",disabled:!e.trim()||m!==null,children:[o.jsx(v.Share2,{className:"h-4 w-4"}),o.jsx("span",{children:"Shared"})]})]}),G?null:f==="edit"&&!s&&o.jsx("div",{className:"flex items-center gap-2",children:o.jsx(nr,{dataType:"value",data:l??{},onSelect:V=>c&&c(V,i)})})]}),o.jsxs(g.TabsContent,{value:"edit",className:"relative mt-0",children:[!G&&f==="edit"&&o.jsx(Qt,{content:"Format JSON",side:"right",showTooltip:!n&&!m,children:o.jsx(I.Button,{type:"button",variant:"outline",size:"icon",onClick:ie,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||n||m!==null,children:o.jsx(v.FileCode2,{})})}),G?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(I.Button,{type:"button",variant:"default",size:"sm",onClick:u,children:[o.jsx(v.Plus,{}),"Copy & Edit from default language"]})]})}):o.jsx(g.Textarea,{ref:_,id:i,name:i,className:`rounded-md border border-input text-xs ${m?"border-red-500":""}`,onChange:q,onKeyDown:N,value:e,placeholder:r,rows:a,disabled:n,readOnly:s}),m&&o.jsxs(I.Alert,{variant:"destructive",className:"mt-2",children:[o.jsx(v.AlertTriangle,{className:"h-4 w-4"}),o.jsxs(I.AlertDescription,{className:"flex flex-col",children:[o.jsx("span",{className:"font-medium",children:"Invalid JSON"}),o.jsx("span",{className:"text-sm",children:m.message}),m.line&&m.column&&o.jsxs("span",{className:"text-sm",children:["Error at line ",m.line,", column ",m.column]}),o.jsx(I.Button,{type:"button",variant:"link",size:"sm",className:"mt-1 h-auto self-start p-0 text-sm",onClick:de,children:"Show position"})]})]})]}),o.jsxs(g.TabsContent,{value:"preview",className:"mt-0",children:[o.jsx(g.Textarea,{rows:a,value:A,readOnly:!0,className:"cursor-default bg-muted font-mono text-sm"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This is how the JSON will look after placeholder substitution."})]}),C&&o.jsx(g.TabsContent,{value:"shared",className:"mt-0",children:o.jsx(h.Suspense,{children:o.jsx(Al,{})})})]})})})},Sl=e=>{const t=L(),n=k();return x.useQuery({queryKey:[y.GET_CHAI_USER,e],queryFn:async()=>{const s=await n(t,{action:y.GET_CHAI_USER,data:{userId:e}}),r=(s==null?void 0:s.data)||{};return{...r,name:r.name||r.email}},enabled:!p.isEmpty(e),staleTime:"static"})};if(typeof window>"u")throw new Error("@chaibuilder/pages is not available on the server");exports.$TRACK=An;exports.ACTIONS=y;exports.BlurContainer=Ht;exports.ChaiWebsiteBuilder=cl;exports.Dynamic=ti;exports.EVENT=X;exports.For=vo;exports.ImagePicker=ml;exports.Index=bo;exports.LANGUAGES=Ze;exports.LanguageSwitcher=ns;exports.Match=Lo;exports.NestedPathSelector=nr;exports.PAGES_PERMISSIONS=re;exports.PAGE_STATUS=J;exports.PageActionsDropdown=Jn;exports.PermissionChecker=It;exports.Portal=Xo;exports.Show=Co;exports.SmartJsonInput=Tl;exports.Switch=Io;exports.Tooltip=Qt;exports.addEventListener=Ls;exports.addNewLangAtom=rt;exports.batch=lo;exports.className=Is;exports.clearDelegatedEvents=Ko;exports.convertRemToPixels=Ki;exports.createComponent=Pn;exports.createComputed=Es;exports.createContext=go;exports.createEffect=Tn;exports.createMemo=W;exports.createRenderEffect=Ae;exports.createRoot=ye;exports.createSignal=H;exports.createUniqueId=wo;exports.delegateEvents=Cs;exports.deleteNestedDataByPath=tt;exports.displayValue=Di;exports.getMutationStatusColor=Oi;exports.getPreferredColorScheme=Vi;exports.getQueryStatusColor=ki;exports.getQueryStatusColorByLabel=Ri;exports.getQueryStatusLabel=ji;exports.getSidedProp=Gi;exports.insert=Ft;exports.memo=Bo;exports.mergeProps=xn;exports.mutationSortFns=qi;exports.navigateToPage=pn;exports.on=co;exports.onCleanup=$e;exports.onMount=ps;exports.parseJSONWithPlaceholders=un;exports.previewUrlAtom=Xs;exports.serialize=Ws;exports.setAttribute=Bt;exports.sortFns=Bi;exports.splitProps=_s;exports.spread=Ns;exports.stringify=Ni;exports.template=qo;exports.throwConfetti=Lt;exports.untrack=Y;exports.updateNestedDataByPath=et;exports.use=js;exports.useActivePage=ge;exports.useAddGlobalSchema=Oa;exports.useApiUrl=L;exports.useApplySchemaToAllPages=Ua;exports.useBuilderFetch=Pr;exports.useBuilderPageData=as;exports.useChaiAuth=Kt;exports.useChaiCurrentPage=ne;exports.useChaiUserInfo=Sl;exports.useChaibuilderRealtime=Vr;exports.useChangePage=er;exports.useChangeSlug=ga;exports.useClearAll=fl;exports.useContext=mo;exports.useCreatePage=la;exports.useCurrentPageOwner=Xn;exports.useDeleteGlobalSchema=Da;exports.useDeletePage=ua;exports.useDynamicPageSelector=Wn;exports.useFallbackLang=Vt;exports.useFetch=k;exports.useGotoPage=tr;exports.useIsLanguagePageCreated=ss;exports.useLanguagePages=Se;exports.useMarkAsTemplate=fa;exports.usePageEditInfo=fn;exports.usePageLockMeta=gn;exports.usePageLockStatus=oe;exports.usePageToUser=hn;exports.usePageType=Yn;exports.usePageTypes=me;exports.usePagesProps=qt;exports.usePublishPages=yn;exports.useReloadPage=dl;exports.useRemoveSchemaFromAllPages=Ba;exports.useSearchParams=ue;exports.useSendRealtimeEvent=es;exports.useTogglePageGlobalSchema=Ma;exports.useTransition=ho;exports.useUnmarkAsTemplate=ha;exports.useUnpublishPage=da;exports.useUpdateActivePageMetadata=hl;exports.useUpdateGlobalSchema=Ra;exports.useUpdatePage=ca;exports.useUpdateWebsiteFields=os;exports.useUserId=Pt;exports.useUserRoleAndPermissions=is;exports.useWebsiteLanguagePages=Hr;exports.useWebsitePages=En;exports.useWebsiteSetting=Pe;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-DWGTiEak.cjs"),p=require("./register-chai-top-bar-DWTuRU53.cjs"),t=require("./index-Cndn0h7y.cjs"),c=require("lucide-react"),d=require("react"),O=require("react-i18next"),_=()=>{const m=t.useCurrentPageOwner(),f=t.useSendRealtimeEvent(),{setPageStatus:j}=t.usePageLockStatus(),{data:s,isFetching:v}=t.useChaiUserInfo((m==null?void 0:m.userId)||""),{pageLockMeta:o,setPageLockMeta:g}=t.usePageLockMeta(),{t:r}=O.useTranslation(),[u,i]=d.useState(""),[a,N]=d.useState({}),[T,k]=d.useState(!1),l=d.useRef(null);d.useEffect(()=>{o!=null&&o.type&&(l.current&&clearTimeout(l.current),d.startTransition(()=>{N(o),g({}),i("")}))},[o,g]);const b=()=>{u!==t.EVENT.TAKE_OVER_REQUEST&&(i(t.EVENT.TAKE_OVER_REQUEST),f(t.EVENT.TAKE_OVER_REQUEST),l.current=setTimeout(()=>i(""),2e4))},R=()=>{u!==t.EVENT.FORCE_TAKE_OVER_REQUEST&&(i(t.EVENT.FORCE_TAKE_OVER_REQUEST),f(t.EVENT.FORCE_TAKE_OVER_REQUEST),j(t.PAGE_STATUS.CHECKING),l.current=setTimeout(()=>i(""),2e4))},y=()=>{N({}),l.current&&clearTimeout(l.current),i("")},x=v?"Loading...":(s==null?void 0:s.name)||"Current editor",h=u===t.EVENT.TAKE_OVER_REQUEST,E=u===t.EVENT.FORCE_TAKE_OVER_REQUEST;return e.jsx(t.BlurContainer,{children:e.jsxs(n.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(n.CardHeader,{className:"space-y-1 border-b pb-3",children:e.jsxs(n.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(c.LockKeyhole,{className:"h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500"}),e.jsx("span",{children:r("Page Locked for Editing")})]})}),e.jsxs(n.CardContent,{className:"space-y-4 p-4",children:[e.jsxs("div",{className:"relative rounded-md border border-green-500 px-2 pb-2 pt-4",children:[e.jsx("div",{className:"absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white",children:"Current Editor"}),e.jsxs("div",{className:"flex items-center space-x-4 p-1",children:[s!=null&&s.avatar?e.jsx("img",{src:s.avatar,alt:s.name,className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}):e.jsx(c.UserIcon,{className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}),e.jsxs("div",{className:"flex-1 space-y-0",children:[e.jsx("div",{className:"truncate font-medium leading-tight text-black",children:x}),(s==null?void 0:s.email)&&e.jsx("p",{className:"truncate text-sm leading-tight text-muted-foreground",children:s.email})]})]})]}),((a==null?void 0:a.type)===t.EVENT.TAKE_OVER_REJECTED||(a==null?void 0:a.type)===t.EVENT.FORCE_TAKE_OVER_REQUEST)&&e.jsx("section",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-x-2 rounded border border-red-500 bg-red-500/10 py-2 pl-3 pr-2 text-sm font-medium text-red-500",children:[e.jsxs("div",{className:"flex items-start gap-x-2",children:[e.jsx(c.AlertCircleIcon,{className:"mt-px flex h-4 w-4 shrink-0"}),e.jsxs("div",{className:"font-light leading-tight",children:[e.jsx("span",{className:"font-medium",children:(s==null?void 0:s.name)||"The current editor"}),(a==null?void 0:a.type)===t.EVENT.TAKE_OVER_REJECTED?" rejected your take over request.":" forcefully took over this page."]})]}),e.jsx(p.Button,{size:"icon",variant:"ghost",onClick:y,className:"flex-shrink-0",children:e.jsx(c.X,{className:"h-4 w-4"})})]})})]}),e.jsx(n.CardFooter,{className:"flex flex-col gap-3 border-t pt-3",children:e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:r("Take Over Options")}),e.jsxs("div",{className:"rounded-md border bg-muted/40 p-3",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("p",{className:"text-sm font-medium",children:r("Take Over Request:")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r("Send a request to {{currentEditorName}} asking them to release the page. They can accept or decline your request.",{currentEditorName:x})})]}),e.jsxs(p.Button,{disabled:h,variant:"default",onClick:b,className:"mt-3 w-full gap-2",children:[e.jsx(c.Edit,{className:"h-4 w-4"}),h?"Take over request sent":"Send Take Over Request"]}),h&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:r("Request sent. If no response, try again or use force take over.")})]}),e.jsx(n.Accordion,{type:"single",collapsible:!0,className:"w-full",children:e.jsxs(n.AccordionItem,{value:"force-takeover",className:"rounded-md border border-destructive/40 bg-destructive/5",children:[e.jsx(n.AccordionTrigger,{className:"px-3 py-2 hover:no-underline",children:e.jsx("div",{className:"flex items-center gap-2 text-left",children:e.jsxs("div",{children:[e.jsxs("p",{className:"flex items-center gap-x-2 text-sm font-medium text-destructive",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4 text-destructive"}),r("Force Take Over")]}),e.jsx("p",{className:"pl-6 text-xs font-normal leading-tight text-muted-foreground",children:r("Immediately take control (use with caution)")})]})})}),e.jsx(n.AccordionContent,{className:"px-3 pb-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-background p-2",children:[e.jsx("input",{type:"checkbox",id:"force-takeover",checked:T,onChange:C=>k(C.target.checked),className:"mt-0.5 h-4 w-4 rounded border-gray-300"}),e.jsx("label",{htmlFor:"force-takeover",className:"flex-1 text-xs text-muted-foreground",children:r("I understand this will immediately close the editor for {{currentEditorName}}. I am using this option with caution.",{currentEditorName:x})})]}),e.jsxs(p.Button,{disabled:!T||E,variant:"destructive",onClick:R,className:"w-full gap-2",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4"}),r(E?"Take over page...":"Force Take Over")]}),E&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r("Attempting to forcefully take over this page. Please wait while we update the editing session.")})]})})]})})]})})]})})};exports.default=_;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("./register-chai-top-bar-DWTuRU53.cjs"),r=require("./index-DWGTiEak.cjs"),t=require("./index-Cndn0h7y.cjs"),l=require("lucide-react"),f=require("react"),j=require("react-i18next"),T=()=>{const i=t.useSendRealtimeEvent(),{pageLockMeta:n}=t.usePageLockMeta(),{setPageStatus:d}=t.usePageLockStatus(),{savePageAsync:x}=r.useSavePage(),h=n==null?void 0:n.requestingUserId,{data:s,isFetching:g}=t.useChaiUserInfo(h||""),o=g?"Fetching user...":(s==null?void 0:s.name)||"Current editor",[u,c]=f.useState(!1),N=async()=>{c(!0),await x(),i(t.EVENT.CONTINUE_EDITING_IN_THIS_CLIENT,n),d(t.PAGE_STATUS.CHECKING),setTimeout(()=>c(!1),2e3)},p=()=>{c(!0),i(t.EVENT.TAKE_OVER_REJECTED,n),d(t.PAGE_STATUS.EDITING),setTimeout(()=>c(!1),2e3)},{t:a}=j.useTranslation();return e.jsx(t.BlurContainer,{children:e.jsxs(r.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(r.CardHeader,{className:"space-y-1",children:e.jsxs(r.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(l.AlertCircle,{className:"h-8 w-8 rounded-md bg-amber-500/20 p-1.5 text-amber-500"}),a("Take Over Requested")]})}),e.jsxs(r.CardContent,{className:"space-y-4",children:[e.jsxs("div",{className:"relative rounded-md border border-green-500 px-2 pb-2 pt-4",children:[e.jsx("div",{className:"absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white",children:"Requested by"}),e.jsxs("div",{className:"flex items-center space-x-4 p-1",children:[s!=null&&s.avatar?e.jsx("img",{src:s.avatar,alt:s.name,className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}):e.jsx(l.UserIcon,{className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}),e.jsxs("div",{className:"flex-1 space-y-0",children:[e.jsx("div",{className:"truncate font-medium leading-tight text-black",children:o}),(s==null?void 0:s.email)&&e.jsx("p",{className:"truncate text-sm leading-tight text-muted-foreground",children:s.email})]})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-gray-700",children:o})," ",a("has requested to")," ",e.jsx("span",{className:"font-medium text-gray-500",children:"take over"})," ",a("editing this page."),"."," ",a("Do you want to allow them to continue?")]})]}),e.jsxs(r.CardFooter,{className:"flex gap-2",children:[e.jsxs(m.Button,{disabled:u,variant:"default",onClick:N,className:"flex-1 gap-2",children:[e.jsx(l.Check,{className:"h-4 w-4"}),a("Accept")]}),e.jsxs(m.Button,{disabled:u,variant:"outline",onClick:p,className:"flex-1 gap-2",children:[e.jsx(l.X,{className:"h-4 w-4"}),a("Reject")]})]})]})})};exports.default=T;
|