@chaibuilder/sdk 4.0.0-beta.37 → 4.0.0-beta.38

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.
Files changed (78) hide show
  1. package/dist/{2SSKDMRQ-B9Y7DUaU.js → 2SSKDMRQ-BUqDyvkj.js} +2 -2
  2. package/dist/{2SSKDMRQ-Dost66qm.cjs → 2SSKDMRQ-Cmm80_70.cjs} +1 -1
  3. package/dist/{AP7HFJJL-DxBuLcYj.cjs → AP7HFJJL-C_bpDijV.cjs} +1 -1
  4. package/dist/{AP7HFJJL-Db0-YeT-.js → AP7HFJJL-Rixab3nP.js} +1 -1
  5. package/dist/{WDYDFRGG-BLnyHnIr.cjs → WDYDFRGG-Bcgsloma.cjs} +1 -1
  6. package/dist/{WDYDFRGG-DjIZGWcU.js → WDYDFRGG-Joc-MsHY.js} +2 -2
  7. package/dist/{active-in-another-tab-D6BuBAvD.cjs → active-in-another-tab-CIQzlzBZ.cjs} +1 -1
  8. package/dist/{active-in-another-tab-DvKdkseG.js → active-in-another-tab-CJp4HNlP.js} +1 -1
  9. package/dist/{add-new-language-page-DXaV4Znu.cjs → add-new-language-page-C9UowLOR.cjs} +1 -1
  10. package/dist/{add-new-language-page-Bt-EHTdP.js → add-new-language-page-CSXgqNU5.js} +1 -1
  11. package/dist/{add-new-page-D1X6uewl.cjs → add-new-page-C-0jOcj3.cjs} +1 -1
  12. package/dist/{add-new-page-JSrqASzg.js → add-new-page-CmkKdxHb.js} +1 -1
  13. package/dist/{ai-panel-content-BcU74IAG.js → ai-panel-content-CEjBTXKP.js} +2 -2
  14. package/dist/{ai-panel-content-Ci6Vp7Cf.cjs → ai-panel-content-CRLL24Tv.cjs} +1 -1
  15. package/dist/{ai-panel-default-lang-CfuUmamx.cjs → ai-panel-default-lang-DCkOcBIN.cjs} +1 -1
  16. package/dist/{ai-panel-default-lang-CxEaZ63K.js → ai-panel-default-lang-V2HKlFDJ.js} +1 -1
  17. package/dist/{ai-panel-other-lang-B1uL_scz.js → ai-panel-other-lang-BACuqAOo.js} +2 -2
  18. package/dist/{ai-panel-other-lang-BA1TOdh_.cjs → ai-panel-other-lang-Ccap1QP9.cjs} +1 -1
  19. package/dist/{ai-translation-prompt-D8N5bmVu.cjs → ai-translation-prompt-BGdITGTs.cjs} +1 -1
  20. package/dist/{ai-translation-prompt-DFX27zHM.js → ai-translation-prompt-CV3Pphg9.js} +1 -1
  21. package/dist/{change-password-modal-kdADAvi2.js → change-password-modal-BjUNbNkW.js} +1 -1
  22. package/dist/{change-password-modal-3rWUghQW.cjs → change-password-modal-j9tdsI_2.cjs} +1 -1
  23. package/dist/{continue-editing-in-this-client-CIheMKdX.cjs → continue-editing-in-this-client-272pil3h.cjs} +1 -1
  24. package/dist/{continue-editing-in-this-client-Dl72_nLZ.js → continue-editing-in-this-client-H3JLxXUK.js} +1 -1
  25. package/dist/{delete-page-BtG5kYkI.cjs → delete-page-Bz9yVuhF.cjs} +1 -1
  26. package/dist/{delete-page-DNz6-CLI.js → delete-page-D8PgbaSa.js} +1 -1
  27. package/dist/{digital-asset-manager-BdNe83F3.js → digital-asset-manager-BuIBKQrY.js} +1 -1
  28. package/dist/{digital-asset-manager-CASGSQ33.cjs → digital-asset-manager-D1DIZyiG.cjs} +1 -1
  29. package/dist/{duplicate-page-C7e9snhW.cjs → duplicate-page-BSwuz2ak.cjs} +1 -1
  30. package/dist/{duplicate-page-DYxGlrmd.js → duplicate-page-qJiGrwSD.js} +1 -1
  31. package/dist/{dynamic-page-selector-Cot9d5fm.cjs → dynamic-page-selector-B945c22e.cjs} +1 -1
  32. package/dist/{dynamic-page-selector-Seiq-wJc.js → dynamic-page-selector-C59-N_34.js} +1 -1
  33. package/dist/index-B3Ozovj5.cjs +5 -0
  34. package/dist/{index-CHoZEbKv.js → index-B6QztICX.js} +18 -18
  35. package/dist/{json-diff-viewer-CMd26XKs.cjs → json-diff-viewer-4PFpOzQv.cjs} +1 -1
  36. package/dist/{json-diff-viewer-BzXIZ79o.js → json-diff-viewer-kPE5IxCR.js} +1 -1
  37. package/dist/{lang-panel-CxmuZt3k.cjs → lang-panel-B02TlFSc.cjs} +1 -1
  38. package/dist/{lang-panel-DPhpM-pr.js → lang-panel-CjEa8M_P.js} +2 -2
  39. package/dist/{mark-as-template-mD6fOtmk.cjs → mark-as-template-C5EqDqmm.cjs} +1 -1
  40. package/dist/{mark-as-template-BEz6ecRQ.js → mark-as-template-DvKWMavv.js} +1 -1
  41. package/dist/{no-language-page-content-DvBnZrhb.cjs → no-language-page-content-BV4xcqPt.cjs} +1 -1
  42. package/dist/{no-language-page-content-BAHxTRff.js → no-language-page-content-XewglkiB.js} +1 -1
  43. package/dist/{no-language-page-dialog-Di0PXuKT.js → no-language-page-dialog-CSYcONeC.js} +2 -2
  44. package/dist/{no-language-page-dialog-AU6R_Umm.cjs → no-language-page-dialog-DW2TmmL1.cjs} +1 -1
  45. package/dist/{page-creator-D5tEK7Vm.cjs → page-creator-DTpgqMLr.cjs} +1 -1
  46. package/dist/{page-creator-VvmlAgTA.js → page-creator-DsoCu0o8.js} +1 -1
  47. package/dist/{page-lock-COOgRF1e.js → page-lock-DN3eOz6T.js} +2 -2
  48. package/dist/{page-lock-B6d47DbD.cjs → page-lock-sMf1iA9z.cjs} +1 -1
  49. package/dist/{page-locked-dialog-BKTQmsMr.cjs → page-locked-dialog-DpUcmy3n.cjs} +1 -1
  50. package/dist/{page-locked-dialog-DSWy_zpi.js → page-locked-dialog-Dz8MAwEM.js} +1 -1
  51. package/dist/{page-manager-new-xSa6-2s3.cjs → page-manager-new-DzQb_sTK.cjs} +1 -1
  52. package/dist/{page-manager-new-ABq5ZgFr.js → page-manager-new-TPjfGU8A.js} +2 -2
  53. package/dist/{page-manager-search-and-filter-C6p6v1qj.js → page-manager-search-and-filter-BJhl_ZxK.js} +1 -1
  54. package/dist/{page-manager-search-and-filter-DXgvy0ys.cjs → page-manager-search-and-filter-C8kgR5aV.cjs} +1 -1
  55. package/dist/{page-revisions-content-CAgq7kLY.js → page-revisions-content-BRG1nseD.js} +2 -2
  56. package/dist/{page-revisions-content-BuNpklOO.cjs → page-revisions-content-_H3kwIfa.cjs} +1 -1
  57. package/dist/pages.cjs +1 -1
  58. package/dist/pages.js +1 -1
  59. package/dist/{publish-pages-content-Ct7VDbNE.js → publish-pages-content-CLOtvebk.js} +2 -2
  60. package/dist/{publish-pages-content-CX1nQ8PA.cjs → publish-pages-content-DvbbUJj3.cjs} +1 -1
  61. package/dist/{save-to-lib-CAzWtI64.js → save-to-lib-C4HuEFUH.js} +1 -1
  62. package/dist/{save-to-lib-C67fQ8_8.cjs → save-to-lib-rk39Z0EK.cjs} +1 -1
  63. package/dist/{selected-block-display-DqC6ZtSA.cjs → selected-block-display-Cz7nEg_I.cjs} +1 -1
  64. package/dist/{selected-block-display-B_6-n75b.js → selected-block-display-UVPjfycv.js} +1 -1
  65. package/dist/{seo-panel-DQmVSmiq.cjs → seo-panel-B8I2tcq2.cjs} +1 -1
  66. package/dist/{seo-panel-DGnUvVO2.js → seo-panel-DsTInOQg.js} +1 -1
  67. package/dist/{shared-json-ld-CuMx_qAL.js → shared-json-ld-BCga2JTe.js} +1 -1
  68. package/dist/{shared-json-ld-BpcG0rtf.cjs → shared-json-ld-DlSg_ICN.cjs} +1 -1
  69. package/dist/{take-over-request-BJaH6pnu.cjs → take-over-request-AoVTkMXG.cjs} +1 -1
  70. package/dist/{take-over-request-B2vspYrb.js → take-over-request-C58OJb7y.js} +1 -1
  71. package/dist/{unmark-as-template-DEs6DnT4.js → unmark-as-template-B9EobxLL.js} +1 -1
  72. package/dist/{unmark-as-template-BYjs9XbH.cjs → unmark-as-template-ZgV3cNi0.cjs} +1 -1
  73. package/dist/{unpublish-page-rlnt_4EX.cjs → unpublish-page-2AJbqM5f.cjs} +1 -1
  74. package/dist/{unpublish-page-D-5iWXIB.js → unpublish-page-Cyx4HU4j.js} +1 -1
  75. package/dist/{web-preview-Daz-wyo3.cjs → web-preview-C1Hj1GDt.cjs} +1 -1
  76. package/dist/{web-preview-DRp7Zk7f.js → web-preview-DTp6O2zH.js} +1 -1
  77. package/package.json +1 -1
  78. package/dist/index-d1_bmLx3.cjs +0 -5
@@ -0,0 +1,5 @@
1
+ "use strict";var fr=Object.create;var as=Object.defineProperty;var hr=Object.getOwnPropertyDescriptor;var gr=Object.getOwnPropertyNames;var mr=Object.getPrototypeOf,Er=Object.prototype.hasOwnProperty;var ks=e=>{throw TypeError(e)};var pr=(e,t,s)=>t in e?as(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var yr=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of gr(t))!Er.call(e,r)&&r!==s&&as(e,r,{get:()=>t[r],enumerable:!(n=hr(t,r))||n.enumerable});return e};var Ar=(e,t,s)=>(s=e!=null?fr(mr(e)):{},yr(t||!e||!e.__esModule?as(s,"default",{value:e,enumerable:!0}):s,e));var is=(e,t,s)=>pr(e,typeof t!="symbol"?t+"":t,s),Ds=(e,t,s)=>t.has(e)||ks("Cannot "+s);var _=(e,t,s)=>(Ds(e,t,"read from private field"),s?s.call(e):t.get(e)),R=(e,t,s)=>t.has(e)?ks("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),k=(e,t,s,n)=>(Ds(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s);const o=require("react/jsx-runtime"),C=require("./register-chai-top-bar-DyW9GPzV.cjs"),g=require("./index-P-2SvZA9.cjs"),Js=require("@radix-ui/react-icons"),p=require("lodash-es"),V=require("jotai"),P=require("lucide-react"),oe=require("react-i18next"),f=require("react"),x=require("@tanstack/react-query"),Tr=require("./default-theme-options-DN-3gIjM.cjs"),U=require("sonner"),Ht=require("./common-functions-B3a4xKt_.cjs"),Sr=require("./core-czmLeR0h.cjs"),Pr=require("./web-blocks.cjs"),xr=require("react-error-boundary");function _r(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const Y=_r(f),wr=()=>{const[e]=g.useCanvasZoom();return o.jsxs("div",{className:"flex w-12 cursor-not-allowed items-center justify-center gap-x-1 space-x-0 font-medium text-gray-400",children:[o.jsx(Js.ZoomInIcon,{className:"h-3.5 w-3.5 flex-shrink-0"})," ",o.jsxs("div",{className:"text-xs leading-3",children:[p.round(e,0),"%"]})]})},br=()=>{const e=g.useBuilderProp("flags.darkMode",!1),t=g.useBuilderProp("flags.dataBinding",!0),[s,n]=V.useAtom(g.dataBindingActiveAtom),{t:r}=oe.useTranslation(),a=e,i=t;return o.jsxs("div",{className:"flex h-10 items-center justify-between px-2",children:[o.jsx("div",{className:"flex h-full space-x-2",children:a?o.jsx(g.DarkMode,{}):null}),o.jsxs("div",{className:"flex h-full items-center space-x-2",children:[o.jsx(g.Breakpoints,{canvas:!0,openDelay:400,activeButtonClass:"bg-gray-200"}),o.jsx(wr,{}),o.jsx(g.UndoRedo,{})]}),o.jsxs("div",{className:"flex h-full items-center",children:[o.jsx(g.ClearCanvas,{}),i?o.jsxs(g.DropdownMenu,{children:[o.jsx(g.DropdownMenuTrigger,{asChild:!0,children:o.jsx(C.Button,{size:"sm",variant:"ghost",className:"size-2 h-7 w-7 rounded-md p-1",children:o.jsx(P.MoreVertical,{className:"h-2 w-2"})})}),o.jsx(g.DropdownMenuContent,{className:"w-56 border-border text-xs",children:o.jsxs(g.DropdownMenuItem,{className:"flex items-center gap-2",onSelect:l=>l.preventDefault(),children:[o.jsx(Js.LightningBoltIcon,{className:"h-4 w-4 text-gray-500"}),o.jsx("span",{className:"flex-1",children:r("Data Binding")}),o.jsx(g.Switch,{checked:s,onCheckedChange:()=>n(!s)})]})})]}):null]})]})},ut=V.atom(null),vr=V.atom({}),Ct=()=>V.useAtom(vr),re=(e,t)=>{const[s]=Ct();return f.useMemo(()=>p.get(s,e,t),[s,e,t])},j=()=>re("apiUrl","/chai/api"),Ss=()=>re("realtimeAdapter",null);function he(){const[e,t]=f.useState(new URLSearchParams(window.location.search));return f.useEffect(()=>{const s=()=>{t(new URLSearchParams(window.location.search))};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[]),[e,t]}const 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",CHANGE_PASSWORD:"CHANGE_PASSWORD",GET_SEO_FIELDS:"GET_SEO_FIELDS",GET_BUILDER_PAGE_DATA:"GET_BUILDER_PAGE_DATA",GET_PAGE_ALL_DATA:"GET_PAGE_ALL_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",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",UI_LIBRARIES:"uiLibraries",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"},Ys=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)}),Cr=()=>{const e=O(),t=j();return f.useCallback(async({body:s,headers:n={},url:r=t,streamResponse:a=!1})=>e(r,s,n,a),[e])},O=()=>{const e=re("onLogout",p.noop),t=re("getAccessToken"),s=j();return f.useCallback(async(n=s,r,a={},i=!1)=>{const l=await t();try{const c=p.get(r,"action","").toLowerCase(),d=await Ys(n+(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 h=await d.json();throw console.error(`API Error (${d.status}):`,h),{status:d.status,statusText:d.statusText,...h,message:h.error||h.message||`Server error: ${d.status}`}}return await d.json()}catch(c){throw console.error("API request failed:",r,c),c}},[e,t])},Ir=V.atom(null),Zs=()=>V.useAtom(Ir),Yt=()=>{const[e]=Zs();return(e==null?void 0:e.slug)||""};function Nr(e,t){const[s,n]=f.useState(e);return f.useEffect(()=>{const r=setTimeout(()=>n(e),t);return()=>clearTimeout(r)},[e,t]),s}const Lr=({query:e,uuid:t})=>{const{selectedLang:s,fallbackLang:n}=g.useLanguages(),{data:r}=ae(),a=r==null?void 0:r.pageType,i=j(),l=O(),{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}),h=f.useMemo(()=>s===""?c.filter(u=>u.lang===""||u.lang===n):c.filter(u=>u.lang===s),[s,n,c]);return{allLangPages:c,data:h,isFetching:d}},Xs=()=>{const{selectedLang:e,fallbackLang:t}=g.useLanguages(),[s,n]=Zs(),[r,a]=f.useState(""),i=Nr(r,500),{allLangPages:l,data:c,isFetching:d}=Lr({query:i}),h=f.useCallback(m=>n(m),[n]),u=f.useCallback(m=>a(m),[a]),E=f.useCallback(()=>{if(!s)return;const m=!(s!=null&&s.primaryPage),A=e.length===0,w=m?s==null?void 0:s.id:s==null?void 0:s.primaryPage,T=l.filter(S=>(S==null?void 0:S.primaryPage)===w||S.id===w).find(S=>A?S.lang===e||S.lang===t:S.lang===e);n(T||s)},[s,e,l,n,t]);return{isFetching:d,dynamicPage:s,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:h,updateSearchQuery:u,onChangeLanguage:E}},xe=()=>{const e=j(),t=O();return x.useQuery({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS],staleTime:300*1e3,placeholderData:{languages:[],theme:Tr.defaultThemeValues,appKey:"",fallbackLang:"",settings:{},designTokens:{}},queryFn:async()=>t(e,{action:y.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})},Zt=()=>{const{data:e}=xe();return f.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},Ce=()=>{const e=O(),t=j();return x.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:s=>s||[]})},en=e=>{const t=O(),s=j(),n=Zt();return x.useQuery({queryKey:[y.GET_WEBSITE_PAGES,e,n],staleTime:1e3*60*5,enabled:!!e,queryFn:async()=>{if(n===e)return{};const r=await t(s,{action:y.GET_WEBSITE_PAGES,data:{lang:e}})||[];return p.keyBy(p.map(r,a=>({...a,lang:e})),"primaryPage")},placeholderData:r=>r||{}})},jr=V.atom({lastSaved:void 0}),tn=()=>V.useAtom(jr),ae=()=>{const[e]=he(),t=e.get("page"),{data:s,isFetching:n}=Ce();return{data:f.useMemo(()=>({...p.find(s,{id:t})||{}}),[s,t]),isFetching:n}},ge=()=>{const[e]=he(),t=e.get("lang")??"",s=e.get("page"),{data:n,isFetching:r}=en(t),{data:a}=Ce();return{data:f.useMemo(()=>p.find([...p.values(n),...a],{lang:t,id:s})||{},[n,a,t,s]),isFetching:r}};V.atom({});const kr=()=>{const{data:e}=ge(),t=Yt(),s=re("getLiveUrl",p.noop),n=e==null?void 0:e.slug,r=s(n||"/");return t?r+t:r},It=e=>{const t=j(),[s]=he(),n=e??s.get("page"),r=O(),{languages:a}=g.useLanguages();return x.useQuery({queryKey:[y.GET_LANGUAGE_PAGES,n],staleTime:1/0,gcTime:0,placeholderData:[],queryFn:async()=>{if(!n)return null;const i=await r(t,{action:y.GET_LANGUAGE_PAGES,data:{id:n}});return p.reverse(p.sortBy(i,"primaryPage"))},enabled:!!n&&!!(a!=null&&a.length)})},le={...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",EDIT_SEO:"edit_seo",RESTORE_REVISION:"restore_revision",DELETE_REVISION:"delete_revision",DELETE_LIBRARY_BLOCK:"delete_library_block"},_e=()=>{const e=j(),t=O();return x.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},sn=e=>{const{data:t}=_e();return f.useMemo(()=>t==null?void 0:t.find(s=>s.key===e),[t,e])},Dr=()=>{const e=j(),t=O();return x.useMutation({mutationFn:async({pageType:s,query:n})=>{try{return t(e,{action:y.SEARCH_PAGES,data:{pageType:s,query:Array.isArray(n)&&n.length>0?n[0]:n}})||[]}catch(r){return console.error(r),[]}}})},nn=({page:e,setDuplicatePage:t,setAddEditPage:s,setUnpublishPage:n,setDeletePage:r,children:a,isLanguagePage:i})=>{const{t:l}=oe.useTranslation(),{hasPermission:c}=g.usePermissions(),{data:d}=_e(),h=f.useMemo(()=>p.find(d,{key:e.pageType}),[d,e.pageType]);return!c(le.EDIT_PAGE)&&!c(le.DELETE_PAGE)&&!c(le.UNPUBLISH_PAGE)||!e?null:o.jsxs(g.DropdownMenu,{children:[o.jsx(g.DropdownMenuTrigger,{asChild:!0,onClick:E=>E.stopPropagation(),children:a}),o.jsxs(g.DropdownMenuContent,{align:"center",className:"text-sm",children:[c(le.ADD_PAGE)&&!i&&o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:E=>{E.stopPropagation(),t(e)},children:[o.jsx(P.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),c(le.EDIT_PAGE)&&o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:E=>{E.stopPropagation(),s({...e,global:!(h!=null&&h.hasSlug)})},children:[o.jsx(P.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&c(le.UNPUBLISH_PAGE)&&o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:E=>{E.stopPropagation(),n(e)},children:[o.jsx(P.Power,{className:"size-3"}),l("Unpublish")]}),c(le.DELETE_PAGE)&&o.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:E=>{E.stopPropagation(),r(e)},children:[o.jsx(P.Trash,{className:"size-3"}),l("Delete")]})]})]})},Gr=(e,t,s)=>((e.includes("THEME")||(t==null?void 0:t.theme)!==void 0)&&(e.push("THEME"),s&&(t!=null&&t.theme)&&s(t.theme)),e),Or=(e,t,s)=>((e.includes("DESIGN_TOKENS")||(t==null?void 0:t.designTokens)!==void 0)&&(e.push("DESIGN_TOKENS"),s&&t.designTokens&&s(t.designTokens)),e),Rr=(e,t,s,n)=>{let r=(e==null?void 0:e.appChanges)||[];return r=Gr(r,t,s),r=Or(r,t,n),e?{...e,...t,appChanges:r}:t},Mr=({queryClient:e,queryKey:t,data:s,setTheme:n,setDesignTokens:r})=>{e.setQueryData(t,a=>Rr(a,s,n,r))},Ur=(e,t,s,n,r)=>e.id===t?{...e,designTokens:s,links:n,partialBlocks:r,changes:[{type:"Page"}]}:e,Br=({queryClient:e,pageId:t,designTokens:s,linkPageIds:n,partialIds:r})=>{e.setQueryData([y.GET_WEBSITE_PAGES],a=>{if(!a||!Array.isArray(a))return a;const i=n.join(" | "),l=r.join(" | ");return a.map(c=>Ur(c,t,s,i,l))})},Fr=(e,t,s,n,r,a,i)=>{t.settings&&(Mr({queryClient:e,queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS],data:t.settings,setTheme:a,setDesignTokens:i}),!s&&n&&(t.settings.theme!==void 0&&U.toast.success(r("Theme Updated"),{description:r("{{userName}} updated the theme",{userName:n}),position:"bottom-left"}),t.settings.designTokens!==void 0&&U.toast.success(r("Design Tokens Updated"),{description:r("{{userName}} updated the design tokens",{userName:n}),position:"bottom-left"})))},Hr=(e,t)=>{t.pageId&&t.designTokens&&t.linkPageIds&&t.partialIds&&Br({queryClient:e,pageId:t.pageId,designTokens:t.designTokens,linkPageIds:t.linkPageIds,partialIds:t.partialIds})},Gs=(e,t)=>t.includes(e.id)?{...e,changes:[],online:!0}:e,qr=(e,t)=>{if(!e)return e;const n=(e.appChanges||[]).filter(r=>!t.includes(r));return{...e,appChanges:n}},Kr=({queryClient:e,ids:t})=>{e.setQueryData([y.GET_WEBSITE_PAGES],s=>!s||!Array.isArray(s)?s:s.map(n=>Gs(n,t))),e.setQueryData([y.GET_LANGUAGE_PAGES],s=>!s||!Array.isArray(s)?s:s.map(n=>Gs(n,t))),(t.includes("THEME")||t.includes("DESIGN_TOKENS"))&&e.setQueryData([y.GET_WEBSITE_DRAFT_SETTINGS],s=>qr(s,t))},Os=(e,t)=>e.id===t?{...e,online:!1}:e,Vr=({queryClient:e,pageId:t,primaryPage:s})=>{s?e.setQueryData([y.GET_LANGUAGE_PAGES,s],n=>!n||!Array.isArray(n)?n:n.map(r=>Os(r,t))):e.setQueryData([y.GET_WEBSITE_PAGES],n=>!n||!Array.isArray(n)?n:n.map(r=>Os(r,t)))},Qr=(e,t,s,n)=>{e&&t(s,{data:n})},zr=(e,t,s,n,r)=>{const{type:a,data:i,sync:l=!1,userName:c}=e;switch(a){case"UPDATE_WEBSITE_DATA":Fr(t,i,l,c,r,s,n);break;case"UPDATE_PAGE_DATA":Hr(t,i);break;case"PUBLISH_CHANGES":i.ids&&Kr({queryClient:t,ids:i.ids});break;case"UNPUBLISH_PAGE":i.pageId&&Vr({queryClient:t,pageId:i.pageId,primaryPage:i.primaryPage});break;default:console.log(r("Unknown sync type"),a)}return l},Nt=()=>{const e=x.useQueryClient(),t=ws(),[s,n]=V.useAtom(g.chaiThemeValuesAtom),[,r]=V.useAtom(g.chaiDesignTokensAtom),{t:a}=oe.useTranslation(),i=f.useCallback(c=>{r(c)},[r]);return{handleQuerySync:f.useCallback(c=>{const d=zr(c,e,n,i,a);Qr(d,t,c.type,c.data)},[e,t,n,i,a])}},Xt=()=>{const e=re("currentUser"),t=re("onLogout");return{isLoggedIn:!!e,user:e,logout:t}},ee={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"},W={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",UPDATE_WEBSITE_DATA:"UPDATE_WEBSITE_DATA",UPDATE_PAGE_DATA:"UPDATE_PAGE_DATA",PUBLISH_CHANGES:"PUBLISH_CHANGES",UNPUBLISH_PAGE:"UNPUBLISH_PAGE"},$r=["sync","join","leave"],Wr=[W.FORCE_TAKE_OVER,W.TAKE_OVER_REQUEST,W.TAKE_OVER_APPROVED,W.TAKE_OVER_REJECTED,W.FORCE_TAKE_OVER_REQUEST,W.CONTINUE_EDITING_IN_THIS_CLIENT,W.CONTINUE_EDITING_IN_THIS_TAB_REQUEST,W.UPDATE_WEBSITE_DATA,W.UPDATE_PAGE_DATA,W.PUBLISH_CHANGES,W.UNPUBLISH_PAGE],Jr=V.atom({}),rn=V.atom(null),Yr=V.atom(ee.CHECKING),Zr=V.atom({}),Xr=e=>{const t={},s=p.groupBy(p.values(e).map(p.first).filter(Boolean),"pageId");return Object.entries(s).forEach(([n,r])=>t[n]=p.minBy(r,"onlineAt")),t},ea=e=>{const t=p.minBy(p.values(e).map(p.first).filter(Boolean),"onlineAt"),s=t==null?void 0:t.onlineAt;return s?s-100:+new Date-1e3*60*60*4},Lt=()=>{const{user:e}=Xt();return e==null?void 0:e.id},ta=()=>{const{data:e}=xe();return`WEBSITE:${e==null?void 0:e.appKey}`},jt=()=>{const{data:e}=ae();return e==null?void 0:e.id},Ae=crypto.randomUUID();let os=null;const st=10,sa=1e3,na=2,ra=16e3,Ps=()=>{const[e,t]=V.useAtom(Jr);return{pageToUser:e,setPageToUser:t}},ce=()=>{const[e,t]=V.useAtom(Yr),s=[ee.LOCKED,ee.ACTIVE_IN_ANOTHER_TAB].includes(e),n=[ee.EDITING].includes(e);return{pageStatus:e,setPageStatus:t,isLocked:s,isEditing:n}},xs=()=>{const[e,t]=V.useAtom(Zr);return{pageLockMeta:e,setPageLockMeta:t}},an=()=>{const e=jt(),{pageToUser:t}=Ps();return f.useMemo(()=>t[e],[t,e])},_s=()=>{const e=Ss(),{setPageStatus:t}=ce(),[s]=V.useAtom(rn);return f.useEffect(()=>{if(clearTimeout(os),!e)return os=setTimeout(()=>{e||t(ee.EDITING)},500),()=>clearTimeout(os)},[e,t]),s},aa=()=>{const e=jt(),t=Lt(),s=_s(),{setPageToUser:n}=Ps(),{setPageStatus:r,pageStatus:a}=ce(),i=f.useRef(e);return f.useEffect(()=>{i.current=e},[e]),f.useCallback(l=>{const c=l||s;if(!c)return[];const d=c==null?void 0:c.presenceState(),h=Xr(d);n(h);const u=h[i.current];if(!u)r(ee.CHECKING);else if(!t)r(ee.CHECKING);else if(u.userId===t&&u.clientId===Ae){if(a===ee.TAKE_OVER_REQUESTED)return;r(ee.EDITING)}else u.userId===t&&u.clientId!==Ae?r(ee.ACTIVE_IN_ANOTHER_TAB):r(ee.LOCKED)},[s,n,r,t,a])},ws=()=>{const e=Lt(),t=jt(),s=_s(),n=an(),{setPageLockMeta:r}=xs(),{user:a}=Xt(),i=f.useRef(t);return f.useEffect(()=>{i.current=t},[t]),f.useCallback(async(l,c)=>{if(!s)return;const d=c||{};d.userId=e,d.userName=(a==null?void 0:a.name)||(a==null?void 0:a.email)||"Unknown user",d.pageId=i.current,d.senderClientId=Ae,d.receiverClientId=(c==null?void 0:c.requestingClientId)||(n==null?void 0:n.clientId),await s.send(l,d),r({})},[s,e,n,r,a])},ia=()=>{const e=Lt(),t=jt(),s=_s(),{setPageStatus:n}=ce(),{setPageLockMeta:r}=xs(),a=ws(),i=f.useRef(t),{savePageAsync:l}=g.useSavePage(),{handleQuerySync:c}=Nt();return f.useEffect(()=>{i.current=t},[t]),f.useCallback(d=>async({payload:h})=>{const u=h||{};if(d===W.UPDATE_WEBSITE_DATA||d===W.UPDATE_PAGE_DATA||d===W.PUBLISH_CHANGES||d===W.UNPUBLISH_PAGE){c({type:d,data:u==null?void 0:u.data,sync:!1,userName:u==null?void 0:u.userName});return}if(!(!(u!=null&&u.pageId)||(u==null?void 0:u.pageId)!==i.current||(u==null?void 0:u.receiverClientId)!==Ae))switch(r({}),d){case W.FORCE_TAKE_OVER_REQUEST:case W.CONTINUE_EDITING_IN_THIS_TAB_REQUEST:{try{await l(!0)}catch(E){console.error("Failed to save page before releasing lock:",E)}await a(W.CONTINUE_EDITING_IN_THIS_CLIENT,{requestingClientId:u==null?void 0:u.senderClientId}),setTimeout(()=>r({type:d}),0);break}case W.TAKE_OVER_REQUEST:{r({requestingUserId:u==null?void 0:u.userId,requestingClientId:u==null?void 0:u.senderClientId}),n(ee.TAKE_OVER_REQUESTED);break}case W.CONTINUE_EDITING_IN_THIS_CLIENT:{const E=ea(s==null?void 0:s.presenceState());n(ee.CHECKING),await(s==null?void 0:s.track({onlineAt:E,pageId:i.current,userId:e,clientId:Ae}));break}case W.TAKE_OVER_REJECTED:{r({type:W.TAKE_OVER_REJECTED});break}}},[a,r,n,s,e,l,c])},oa=()=>{const e=Ss(),t=Lt(),s=jt(),n=ta(),[r,a]=V.useAtom(rn),i=ia(),l=aa(),c=f.useRef(i),d=f.useRef(l),h=f.useRef(null),u=f.useRef(!1),E=f.useRef(0),m=f.useRef(r),A=f.useRef(()=>{});f.useEffect(()=>{c.current=i,d.current=l,m.current=r},[i,l,r]);const w=f.useCallback(T=>{Wr.forEach(S=>{T.onBroadcast(S,I=>{c.current(S)(I)})}),$r.forEach(S=>{T.onPresence(S,()=>{d.current(T)})})},[]),N=f.useCallback(()=>{if(u.current||!e||!t||!n)return;if(E.current>=st){console.error(`Maximum reconnection attempts (${st}) reached. Stopping reconnection attempts.`);return}u.current=!0,E.current+=1,console.log(`Attempting to reconnect realtime channel (attempt ${E.current}/${st})`),h.current&&(clearTimeout(h.current),h.current=null),m.current&&(m.current.unsubscribe(),a(null),m.current=null);const T=Math.min(sa*Math.pow(na,E.current-1),ra);h.current=setTimeout(()=>{const S=e.channel(n,{config:{presence:{key:Ae}}});w(S),S.subscribe(async I=>{I==="SUBSCRIBED"?(console.log("Realtime connection established successfully"),a(S),m.current=S,E.current=0,u.current=!1):I==="CHANNEL_ERROR"||I==="TIMED_OUT"?(console.log(`Realtime connection failed: ${I}. Attempt ${E.current}/${st}`),E.current<st?setTimeout(()=>{u.current=!1,A.current()},500):(console.error("Maximum reconnection attempts reached"),u.current=!1)):I==="CLOSED"&&(console.log("Realtime connection closed"),u.current=!1)})},T)},[e,t,n,a,w]);f.useEffect(()=>{A.current=N},[N]),f.useEffect(()=>{if(!e||!t||!n||r&&r.topic===n)return;E.current=0,u.current=!1;const T=e.channel(n,{config:{presence:{key:Ae}}});return w(T),T.subscribe(async S=>{S==="SUBSCRIBED"?(console.log("Realtime connection established successfully"),a(T),m.current=T,E.current=0):S==="CHANNEL_ERROR"||S==="TIMED_OUT"?(console.log(`Realtime connection failed: ${S}. Will attempt to reconnect...`),u.current||N()):S==="CLOSED"&&console.log("Realtime connection closed")}),()=>{h.current&&(clearTimeout(h.current),h.current=null),u.current=!1,E.current=0,m.current===T&&(m.current=null),a(null),T.unsubscribe()}},[e,t,n,a,N,w]),f.useEffect(()=>{const T=()=>{if(document.visibilityState==="visible"){if(console.log("Tab became visible, checking realtime connection..."),!e||!t||!n){console.log("Required dependencies not available, skipping reconnection");return}if(u.current){console.log("Reconnection already in progress, skipping visibility change reconnect");return}m.current?m.current.getState()!=="JOINED"&&(console.log("Channel is not active, reconnecting..."),N()):(console.log("No active channel found, reconnecting..."),N())}};return document.addEventListener("visibilitychange",T),()=>{document.removeEventListener("visibilitychange",T)}},[e,t,n,N]),f.useEffect(()=>(r&&s&&t&&r.track({pageId:s,userId:t,clientId:Ae,onlineAt:+new Date}),()=>{r&&s&&r.untrack()}),[r,s,t])},la=f.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-C-0jOcj3.cjs"))),ca=f.lazy(()=>Promise.resolve().then(()=>require("./delete-page-Bz9yVuhF.cjs"))),ua=f.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-BSwuz2ak.cjs"))),da=f.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-C5EqDqmm.cjs"))),fa=f.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-ZgV3cNi0.cjs"))),ha=f.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-2AJbqM5f.cjs"))),ga=()=>{const[e,t]=f.useState(null),[s,n]=f.useState(null),[r,a]=f.useState(null),[i,l]=f.useState(null),[c,d]=f.useState(null),[h,u]=f.useState(null),{data:E,isFetching:m}=ge(),{selectedLang:A,fallbackLang:w}=g.useLanguages(),{data:N}=It(),T=N==null?void 0:N.find(H=>H.lang===A),{isLocked:S}=ce(),I=!(E!=null&&E.slug),z=V.useSetAtom(ut);if(!E)return null;const Q=H=>{A.length>0&&A!==w?z({edit:!0,id:H==null?void 0:H.id,primaryPage:H==null?void 0:H.primaryPage}):u(H)};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("p",{className:"flex h-7 max-w-[200px] items-center truncate rounded px-1 text-xs font-medium",children:m?o.jsx(P.Loader,{className:"h-4 w-4 animate-spin text-slate-400"}):o.jsxs("span",{className:"flex items-end overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-xs font-medium",children:[I?o.jsx(P.Hash,{className:"mr-1 h-4 w-4"}):o.jsx(P.File,{className:"mr-1 h-4 w-4"}),p.get(T||E,"name")??""]})}),S?o.jsx(C.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 cursor-not-allowed rounded opacity-50 hover:bg-transparent",children:o.jsx(P.MoreHorizontal,{className:"h-4 w-4"})}):o.jsx(nn,{page:E,setDuplicatePage:H=>d(H),setAddEditPage:H=>Q(H),setUnpublishPage:H=>n(H),setDeletePage:H=>t(H),isLanguagePage:A.length>0&&A!==w,children:o.jsx(C.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:o.jsx(P.MoreVertical,{className:"h-4 w-4"})})})]}),h&&o.jsx(f.Suspense,{children:o.jsx(la,{closePanel:()=>u(null),editPage:()=>{},addEditPage:h,setAddEditPage:u})}),e&&o.jsx(f.Suspense,{children:o.jsx(ca,{page:e,onClose:()=>t(null)})}),s&&o.jsx(f.Suspense,{children:o.jsx(ha,{page:s,onClose:()=>n(null)})}),r&&o.jsx(f.Suspense,{children:o.jsx(da,{page:r,onClose:()=>a(null)})}),i&&o.jsx(f.Suspense,{children:o.jsx(fa,{page:i,onClose:()=>l(null)})}),c&&o.jsx(f.Suspense,{children:o.jsx(ua,{page:c,onClose:()=>d(null),closePanel:()=>u(null)})})]})},Je=({children:e,className:t=""})=>o.jsx("div",{className:Ht.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}),ma=({hasDynamicPage:e})=>o.jsx(Je,{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"})]})}),nt={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"};function on(e,t,s=!1){const n=e.toString()?`?${e.toString()}`:"/";s?window.history.replaceState(null,"",n):window.history.pushState({},"",n),t(e),window.dispatchEvent(new PopStateEvent("popstate"))}const Ea=f.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-C9UowLOR.cjs"))),pa=()=>{const e=re("topLeftCorner",null);return e?o.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:f.createElement(e,{})}):null},ln=({showAdd:e=!0,goToDefaultLang:t=!1})=>{const{fallbackLang:s,languages:n,selectedLang:r,setSelectedLang:a}=g.useLanguages(),i=p.isEmpty(r)?s:r,[,l]=he(),{isLocked:c}=ce(),{t:d}=oe.useTranslation();f.useEffect(()=>{const T=new URLSearchParams(window.location.search),S=T.get("lang");S&&(n.includes(S)?a(S):(T.delete("lang"),l(T),a("")))},[n,l,a]);const h=V.useSetAtom(ut),{data:u}=ae(),{data:E}=xe(),{data:m}=It(),A=f.useMemo(()=>{const T=p.compact(p.map(p.get(E,"languages"),S=>{const I=p.find(m,{lang:S});return{key:S,value:p.get(nt,S,S),isLangPageAdded:!!I}})).filter(Boolean);return[{key:s,value:p.get(nt,s),isLangPageAdded:!0},...T]},[s,m,E]),w=T=>{if(document.querySelector('[data-panel-id="seo"]')){const I=new CustomEvent("seo-language-switch-check",{detail:{fromLang:i,toLang:T,switchHandler:()=>N(T)}});window.dispatchEvent(I);return}N(T)},N=T=>{a(T);const S=new URLSearchParams(window.location.search);T===s?S.delete("lang"):S.set("lang",T),on(S,l)};return p.isEmpty(n)?null:c?o.jsxs(C.Button,{variant:"ghost",size:"sm",className:"ml-px h-max cursor-not-allowed gap-2 py-1.5 opacity-50",children:[o.jsx(P.Languages,{className:"h-4 w-4"}),p.get(nt,i,i),o.jsx(P.ChevronDown,{className:"h-4 w-4"})]}):t?o.jsx(C.Button,{onClick:()=>N(s),variant:"link",size:"sm",children:d("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(C.Button,{disabled:!!c,variant:"outline",size:"sm",className:"ml-px h-max gap-2 py-1.5",children:[o.jsx(P.Languages,{className:"h-4 w-4"}),p.get(nt,i,i),o.jsx(P.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:Ht.cn("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",T.key===i&&"!bg-gray-200 text-gray-700"),onClick:()=>w(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(P.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(C.Button,{size:"sm",variant:"ghost",onClick:()=>{u&&h({edit:!1,primaryPage:u.id})},className:"text-xs font-normal duration-200 hover:bg-slate-300 hover:text-slate-800",children:[o.jsx(P.Plus,{className:"mr-1 h-3 w-3"})," Add Language"]})]})]})]})})};function ya(){const e=V.useAtomValue(ut),t=V.useSetAtom(ut);return o.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[o.jsx(pa,{}),e&&o.jsx(f.Suspense,{children:o.jsx(Ea,{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 Aa(){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 Ta=Y.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-_H3kwIfa.cjs")));function Sa(){const[e,t]=Y.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(C.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[o.jsx(P.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(f.Suspense,{fallback:o.jsx(Aa,{}),children:o.jsx(Ta,{isOpen:e})})})]}),o.jsx(g.TooltipContent,{side:"bottom",children:o.jsx("p",{children:"Revision history"})})]})})}const Ut=({permission:e,permissions:t,children:s,fallback:n=null})=>{const{hasPermission:r}=g.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?n:s},Pa={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},cn=()=>{var t;const[e]=Ct();return((t=e==null?void 0:e.flags)==null?void 0:t.revisions)??!1},xa=()=>{const e=j(),t=x.useQueryClient(),s=O(),{data:n}=_e();return x.useMutation({mutationFn:async r=>await s(e,{action:y.CREATE_PAGE,data:r}),onSuccess:(r,a)=>{var l;a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES,a==null?void 0:a.lang]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const i=a.template?`Page created from "${a.template.name}" template`:a.hasSlug===!1?"New "+((l=p.find(n,{key:a.pageType}))==null?void 0:l.name)+" added successfully":"New page added successfully";U.toast.success(i)},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});U.toast.error(`Failed to add new ${i!=null&&i.hasSlug?"page":i.name}.`,{description:p.get(Pa,r.message,r.message)})}})},_a=()=>{const e=j(),t=x.useQueryClient(),s=O(),{data:n}=ge(),{data:r}=_e();return x.useMutation({mutationFn:async a=>await s(e,{action:y.UPDATE_PAGE,data:a}),onSuccess:(a,i)=>{(n==null?void 0:n.id)===(i==null?void 0:i.id)&&t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]}),i&&(i!=null&&i.primaryPage||i!=null&&i.seo)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(a,i)=>{const l=p.find(r,{key:i.pageType});U.toast.error(`Failed to update ${l!=null&&l.hasSlug?"page":l.name}.`,{description:a.message})}})},wa=()=>{const e=j(),t=x.useQueryClient(),s=O(),{data:n}=_e();return x.useMutation({mutationFn:async r=>s(e,{action:y.DELETE_PAGE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{if(r.code==="PAGE_LOCKED"){U.toast.error("Delete not allowed",{description:"Page is currently being edited by another user."});return}a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});U.toast.error(`Failed to delete ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},ba=()=>{const e=j(),t=O(),{data:s}=_e(),{handleQuerySync:n}=Nt();return x.useMutation({mutationFn:async r=>t(e,{action:y.TAKE_OFFLINE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{n({type:"UNPUBLISH_PAGE",data:{pageId:a==null?void 0:a.id,primaryPage:a==null?void 0:a.primaryPage},sync:!0});const i=p.find(s,{key:a.pageType});U.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});U.toast.error(`Failed to take offline ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},un=()=>{const e=j(),t=O(),{savePageAsync:s}=g.useSavePage(),n=cn(),{handleQuerySync:r}=Nt();return x.useMutation({mutationFn:async({ids:a})=>(await s(),t(e,{action:y.PUBLISH_CHANGES,data:{ids:a,revisions:n}})),onSuccess:(a,{ids:i})=>{r({type:"PUBLISH_CHANGES",data:{ids:i},sync:!0})},onError:a=>{console.log("##",a),U.toast.error("Failed to publish pages.")}})},va=()=>{const e=j(),t=O(),s=x.useQueryClient();return x.useMutation({mutationFn:async n=>{var r;return t(e,{action:y.MARK_AS_TEMPLATE,data:{id:(r=n.page)==null?void 0:r.id,name:n.name,description:n.description,pageType:n.pageType,previewImage:n.previewImage}})},onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),U.toast.success("Page marked as template successfully.")},onError:()=>{U.toast.error("Failed to mark page as template.")}})},Ca=()=>{const e=j(),t=O(),s=x.useQueryClient();return x.useMutation({mutationFn:async n=>t(e,{action:y.UNMARK_AS_TEMPLATE,data:{id:n==null?void 0:n.id}}),onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),U.toast.success("Page unmarked as template successfully.")},onError:()=>{U.toast.error("Failed to unmark page as template.")}})},Ia=()=>{const e=j(),t=O(),s=x.useQueryClient();return x.useMutation({mutationFn:async({id:n,slug:r})=>t(e,{action:y.CHANGE_SLUG,data:{id:n,slug:r}}),onSuccess:(n,{primaryPage:r})=>{U.toast.success("Slug changed successfully."),r?s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,r]}):s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:()=>{U.toast.error("Failed to change slug")}})},Na=f.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-DvbbUJj3.cjs")));function La({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:s,isPending:n}=un();return o.jsx(g.Dialog,{open:e,onOpenChange:n?()=>{}:t,children:e&&o.jsx(f.Suspense,{fallback:o.jsx("div",{className:"h-96 w-96 animate-pulse bg-gray-100"}),children:o.jsx(Na,{onClose:t,isPending:n,publishPage:s})})})}const ja=()=>{const[e]=g.useBlocksStore(),{data:t}=Ce();return f.useCallback(()=>{if(!t)return{ids:[],names:[],partialBlocksInfo:[]};const n=p.filter(e,c=>c._type==="PartialBlock"),r=p.uniq(p.compact(n.map(c=>p.get(c,"partialBlockId","")))),a=p.compact(r.map(c=>{const d=p.find(t,{id:c});if(!d)return null;if(d.online){if(!p.isEmpty(d.changes))return{id:d.id,name:d.name||d.slug||d.id,status:"unpublished_changes"}}else return{id:d.id,name:d.name||d.slug||d.id,status:"unpublished"};return null})),i=a.map(c=>c.id),l=a.map(c=>c.name);return{ids:i,names:l,partialBlocksInfo:a}},[e,t])},dn=e=>{const{fallbackLang:t}=g.useLanguages(),{data:s}=xe(),{data:n,isFetching:r}=It(),a=f.useMemo(()=>{const i={[t]:!0};return p.each(p.get(s,"languages"),l=>{const c=p.find(n,{lang:l});i[l]=!!c}),i},[t,n,s]);return r||p.isEmpty(e)||e&&a[e]},ka=()=>{const{data:e,isLoading:t}=xe(),s=e==null?void 0:e.appChanges,n=s==null?void 0:s.includes("THEME"),r=s==null?void 0:s.includes("DESIGN_TOKENS");return{hasUnpublishedSettings:n||r,hasUnpublishedTheme:n,hasUnpublishedDesignToken:r,isLoading:t}},Da={particleCount:350,spread:120,origin:{y:.6},angle:90},Ga={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},Oa=async()=>{const{default:e}=await import("canvas-confetti");return e},rt=e=>{let t=Ga[e];t||(t={});const s={...Da,...t};Oa().then(n=>n(s))};function Xe({children:e,content:t,side:s="bottom",delayDuration:n=700,showTooltip:r=!0}){return r?o.jsx(g.TooltipProvider,{children:o.jsxs(g.Tooltip,{delayDuration:n,children:[o.jsx(g.TooltipTrigger,{asChild:!0,children:e}),o.jsx(g.TooltipContent,{side:s,sideOffset:10,children:o.jsx("p",{children:t})})]})}):e}const Ra=f.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-2AJbqM5f.cjs"))),Ma=f.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-BxV_8mCE.cjs"))),Ua=f.lazy(()=>Promise.resolve().then(()=>require("./unpublished-partials-modal-D50Hxk6N.cjs"))),Ba=f.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-4PFpOzQv.cjs"))),Fa=()=>{const{t:e}=oe.useTranslation(),{selectedLang:t,fallbackLang:s}=g.useLanguages(),n=re("getPreviewUrl",async E=>E),[r,a]=f.useState(""),{data:i}=ae(),{data:l}=It(),{data:c}=_e(),d=f.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]),h=f.useCallback(E=>{var m;return(m=p.find(c,{key:E}))==null?void 0:m.hasSlug},[c]),u=t===s?"":t;return f.useEffect(()=>{(async()=>{if(typeof n=="function"){const E=!h(i==null?void 0:i.pageType),m=await n(E?`/_partial/${u!==""?u+"/":""}${i==null?void 0:i.id}`:d||"");a(m)}else a("")})()},[n,d,i==null?void 0:i.pageType,h,i==null?void 0:i.id,u]),o.jsxs(o.Fragment,{children:[o.jsx(Xe,{content:e("Open preview in new tab"),delayDuration:0,children:o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:o.jsx(C.Button,{variant:"ghost",size:"sm",className:"gap-2",children:o.jsx(P.Play,{className:"h-4 w-4"})})})}),o.jsx("div",{className:"h-4 w-px bg-gray-200"})]})},Ha=()=>{const{t:e}=oe.useTranslation(),[t,s]=g.useRightPanel();return o.jsxs(o.Fragment,{children:[o.jsx(Xe,{content:e("Theme"),delayDuration:0,children:o.jsx(C.Button,{variant:t==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>s(t==="theme"?"block":"theme"),children:o.jsx(P.Palette,{className:"h-4 w-4"})})}),o.jsx("div",{className:"h-4 w-px bg-gray-200"})]})},qa=()=>{const{t:e}=oe.useTranslation(),[t,s]=f.useState(!1),{isLocked:n}=ce(),{savePageAsync:r,saveState:a}=g.useSavePage();f.useEffect(()=>{const h=u=>{a==="UNSAVED"&&(u.preventDefault(),u.returnValue=!1)};return a==="UNSAVED"&&window.addEventListener("beforeunload",h),()=>{window.removeEventListener("beforeunload",h)}},[a]);const i=f.useCallback(async()=>{t||(s(!0),await r(),s(!1))},[r,t]),{buttonIcon:l,buttonClass:c,tooltipContent:d}=f.useMemo(()=>{switch(a){case"UNSAVED":return{tooltipContent:e("Save draft"),buttonIcon:o.jsx(P.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:e("Saving"),buttonIcon:o.jsx(P.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:e("Saved"),buttonIcon:o.jsx(P.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[a,e]);return n?null:o.jsx(Xe,{content:d,children:o.jsx(C.Button,{size:"sm",variant:"ghost",onClick:i,className:`${c}`,children:l})})},Ka=()=>{const{t:e}=oe.useTranslation(),{selectedLang:t}=g.useLanguages(),{data:s}=ge(),n=ja(),[r,a]=f.useState(!1),[i,l]=f.useState(!1),[c,d]=f.useState(null),[h,u]=f.useState(!1),{savePageAsync:E}=g.useSavePage(),[m,A]=f.useState(!1),{hasUnpublishedSettings:w,hasUnpublishedTheme:N,hasUnpublishedDesignToken:T}=ka(),[S,I]=f.useState(!1),[z,Q]=f.useState([]),[H,ie]=f.useState([]),{data:D}=ae(),{mutate:M,isPending:v}=un(),{needTranslations:L}=g.useSavePage(),J=L(),{buttonText:$,buttonClassName:ne,isPublished:me,hasUnpublishedChanges:ue}=f.useMemo(()=>{const q=D&&(D==null?void 0:D.online),se=!p.isEmpty(D==null?void 0:D.changes);let Ne=q?"hover:bg-green-600 bg-green-500":"",Gt=e(q?"Published":"Publish");return q&&se&&(Ne="hover:bg-blue-600 bg-blue-500",Gt=e("Publish")),{buttonClassName:Ne,isPublished:q,hasUnpublishedChanges:se,buttonText:Gt}},[D,e]),we=async()=>{if(J){A(!0);return}tt([s==null?void 0:s.id,s==null?void 0:s.primaryPage])},Ee=q=>{const se=[s==null?void 0:s.id,s==null?void 0:s.primaryPage,...Array.isArray(q)?q:[]];M({ids:p.compact(se)},{onSuccess:()=>rt("TOP_RIGHT")})},tt=f.useCallback(q=>{const{ids:se,partialBlocksInfo:Ne}=n();se.length>0?(Q(se),ie(Ne),I(!0)):M({ids:p.compact(q)},{onSuccess:()=>rt("TOP_RIGHT")})},[n,M]),ns=()=>{I(!1),Ee(z),Q([]),ie([])},kt=()=>{I(!1),Q([]),ie([])},rs=()=>{A(!1),tt([s==null?void 0:s.id,s==null?void 0:s.primaryPage])},Dt=async()=>{A(!1),await E()};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex",children:[o.jsxs(C.Button,{size:"sm",onClick:we,disabled:v||!(D!=null&&D.id),className:`relative flex items-center gap-1 overflow-hidden rounded-r-none text-white transition-all duration-300 ease-in-out ${ne}`,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:me?ue?o.jsx(P.Pencil,{className:"h-4 w-4"}):o.jsx(P.Send,{className:"h-4 w-4"}):o.jsx(P.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:me?o.jsx(P.Rocket,{className:"h-4 w-4"}):o.jsx(P.Send,{className:"h-4 w-4"})}),o.jsx("span",{children:$}),t?`(${p.upperCase(t)})`:""]}),o.jsxs(g.DropdownMenu,{children:[o.jsx(g.DropdownMenuTrigger,{asChild:!0,children:o.jsxs(C.Button,{size:"sm",disabled:v||!(D!=null&&D.id),className:`relative rounded-l-none border-l border-white/50 px-2 text-white ${w?"bg-gray-500 hover:bg-gray-600":ne}`,children:[o.jsx(P.ChevronDown,{className:"h-4 w-4"}),w&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-orange-500"}),o.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-2 w-2 animate-ping rounded-full bg-orange-500"})]})]})}),o.jsxs(g.DropdownMenuContent,{align:"end",className:"w-60",children:[o.jsx(g.DropdownMenuLabel,{className:"-mt-1 text-xs font-light text-gray-600",children:e("Page")}),me&&ue&&o.jsxs(g.DropdownMenuItem,{onClick:()=>u(!0),className:"cursor-pointer text-xs",children:[o.jsx(P.Eye,{className:"mr-0.5 h-3 w-3"}),e("View Unpublished changes")]}),!me&&o.jsxs(g.DropdownMenuItem,{disabled:v,className:"cursor-pointer text-xs",onClick:()=>tt([D==null?void 0:D.id]),children:[e("Publish")," page"]}),me&&o.jsxs(g.DropdownMenuItem,{onClick:()=>d(s),className:"cursor-pointer text-xs",children:[o.jsx(P.TriangleAlert,{className:"mr-0.5 h-3 w-3"}),e("Unpublish")," page ",t?`(${p.upperCase(t)})`:""]}),w&&o.jsxs(o.Fragment,{children:[o.jsx(g.DropdownMenuSeparator,{className:"bg-gray-200"}),o.jsx(g.DropdownMenuLabel,{className:"-mt-1 text-xs font-light text-gray-600",children:e("Unpublished website settings")})]}),N&&o.jsx(g.DropdownMenuItem,{disabled:v,className:"cursor-pointer text-xs",onClick:()=>M({ids:["THEME"]},{onSuccess:()=>rt("TOP_RIGHT")}),children:o.jsxs("span",{className:"flex h-full w-full items-center gap-2",children:[o.jsx("span",{className:"mt-0.5 h-1 w-1 animate-pulse rounded-full bg-orange-500"}),e("Publish")," theme"]})}),T&&o.jsx(g.DropdownMenuItem,{disabled:v,className:"cursor-pointer text-xs",onClick:()=>M({ids:["DESIGN_TOKENS"]},{onSuccess:()=>rt("TOP_RIGHT")}),children:o.jsxs("span",{className:"flex h-full w-full items-center gap-2",children:[o.jsx("span",{className:"mt-0.5 h-1 w-1 animate-pulse rounded-full bg-orange-500"}),e("Publish")," design token"]})})]})]})]}),o.jsx(La,{showModal:r,onClose:()=>a(!1)}),c&&o.jsx(f.Suspense,{children:o.jsx(Ra,{page:c,onClose:()=>d(null)})}),h&&o.jsx(f.Suspense,{children:o.jsx(Ba,{open:h,onOpenChange:u,compare:[{label:"live",uid:`live:${D==null?void 0:D.id}`,item:{}},{label:"draft",uid:`draft:${D==null?void 0:D.id}`,item:D}]})}),m&&o.jsx(f.Suspense,{children:o.jsx(Ma,{isOpen:m,onClose:Dt,onContinue:rs,isPending:v})}),S&&o.jsx(f.Suspense,{children:o.jsx(Ua,{isOpen:S,onClose:kt,onContinue:ns,isPending:v,partialBlocksInfo:H})})]})};function Va(){const{isLocked:e}=ce(),[t]=he(),s=t.get("lang"),n=dn(s),r=cn();return e||!n?o.jsx("div",{}):o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r&&o.jsx(Sa,{}),o.jsx(Ut,{permission:le.EDIT_THEME,children:o.jsx(Ha,{})}),o.jsx(Fa,{}),o.jsx(Ut,{permission:le.SAVE_PAGE,children:o.jsx(qa,{})}),o.jsx(Ut,{permission:le.PUBLISH_PAGE,children:o.jsx(Ka,{})})]})}const Qa=f.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-DzQb_sTK.cjs"))),za=({children:e})=>{const{t}=oe.useTranslation(),[s]=he(),n=s.get("page"),{data:r,isFetching:a}=ae(),{data:i,isFetching:l}=Ce(),[c,d]=f.useState(!1),[h,u]=f.useState(!0),{savePage:E}=g.useSavePage(),m=!!n&&!p.isEmpty(r),{isLocked:A}=ce();f.useEffect(()=>{!l&&i&&u(!1)},[l,i]);const w=!h&&!n,N=!h&&!a&&p.isEmpty(r),T=c||w||N;return o.jsxs(o.Fragment,{children:[o.jsxs(g.Tooltip,{children:[o.jsx(g.TooltipTrigger,{asChild:!0,onClick:()=>{A||E(),d(!0)},children:e||o.jsxs(C.Button,{variant:"ghost",className:"flex w-full items-center justify-center rounded-md p-2 pl-0",children:[o.jsx(P.Folder,{className:"ml-2 h-10 w-10 fill-primary text-primary"}),o.jsx("div",{className:"flex flex-col items-start",children:o.jsx("span",{className:"text-sm font-semibold",children:t("Pages")})})]},"template-viewer")}),o.jsx(g.TooltipContent,{side:"right",children:o.jsx("p",{children:t("Open pages manager")})})]}),o.jsx(g.Sheet,{open:T,onOpenChange:S=>!S&&m&&d(!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 ${m?"":"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(P.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:T&&o.jsx(f.Suspense,{children:o.jsx(Qa,{close:()=>d(!1)})})})]})})]})},$a=f.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-B945c22e.cjs"))),Wa=()=>{const{dynamicPage:e,allLangPages:t,isFetching:s}=Xs(),n=t.length>0;return s?null:o.jsxs("div",{className:"relative",children:[!e&&o.jsx(ma,{hasDynamicPage:n}),o.jsx(f.Suspense,{children:o.jsx($a,{})})]})},Ja=()=>{const{data:e,isFetching:t}=ge(),{data:s,isFetching:n}=ae(),r=p.get(s,"dynamic",!1),a=Yt(),i=C.useChaiFeatureFlag("dynamic-page-selector"),{t:l}=oe.useTranslation(),c=e==null?void 0:e.slug,d=!c,h=kr(),u=t||n,m=(d?`Partial: ${e==null?void 0:e.name} `:`${c}${a}`).replace(window.location.host,"");return o.jsxs("div",{className:"relative flex items-center",children:[o.jsxs("div",{className:"flex items-center",children:[o.jsx("div",{className:Ht.cn("flex h-8 items-center",u&&"max-w-0 overflow-hidden opacity-0"),children:o.jsx(za,{})}),o.jsx(P.ChevronRight,{className:"mx-1 h-3 w-3 flex-shrink-0 text-gray-400"}),o.jsx("div",{className:Ht.cn("flex h-8 items-center",u&&"max-w-0 overflow-hidden opacity-0"),children:o.jsx(ga,{})}),o.jsx(P.ChevronRight,{className:"mx-1 h-3 w-3 flex-shrink-0 text-gray-400"}),o.jsxs("div",{className:"group flex items-center overflow-hidden",children:[o.jsx("div",{className:`w-full max-w-[200px] overflow-hidden overflow-ellipsis whitespace-nowrap text-xs ${d?"italic":"font-mono"}`,children:m==="/"?o.jsxs("span",{children:["/",o.jsx("span",{className:"text-[11px] font-light italic",children:"(Homepage)"})]}):m}),!d&&o.jsx(Xe,{content:l("Open page"),children:o.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"",children:o.jsx("div",{className:"ml-2 mr-px flex-shrink-0 rounded-sm p-1.5 opacity-0 transition-opacity group-hover:opacity-100",children:o.jsx(P.ExternalLink,{className:"h-4 w-4",strokeWidth:1})})})})]})]}),r&&i&&o.jsx(Wa,{})]})},Ya=()=>o.jsxs("div",{className:"grid h-full w-full grid-cols-3 items-center px-2",children:[o.jsxs("div",{className:"flex justify-start",children:[o.jsx(ya,{}),o.jsx(Ja,{})]}),o.jsx("div",{className:"flex justify-center",children:o.jsx(br,{})}),o.jsxs("div",{className:"flex items-center justify-end",children:[o.jsx(ln,{}),o.jsx(Va,{})]})]}),Za=()=>{const e=x.useQueryClient(),{data:t}=x.useQuery({queryKey:[y.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:f.useCallback(n=>{e.setQueryData([y.AI_CONTEXT],n)},[e]),aiContext:t}},Xa=()=>{const e=j(),{aiContext:t}=Za(),s=O();return f.useCallback(async(n,r,a,i)=>s(e,{action:y.ASK_AI,data:{type:n,prompt:r,blocks:a,context:t,lang:i}}),[e,t,s])},ei=e=>f.useMemo(()=>{if(!e||p.isEmpty(e))return{blocks:[]};const t=p.filter(e,s=>!p.includes(s==null?void 0:s._type,"@chai/"));return{blocks:Sr.syncBlocksWithDefaultProps(t)}},[e]),fn=()=>{const[e]=he(),t=e.get("page"),s=j(),n=O(),r=x.useQueryClient(),{data:a}=ae(),{data:i}=ge(),l=Zt(),c=Yt();return x.useQuery({queryKey:[y.GET_PAGE_ALL_DATA,t,i==null?void 0:i.id,c],staleTime:1/0,gcTime:0,queryFn:async()=>{const d=await n(s,{action:y.GET_PAGE_ALL_DATA,data:{id:t,lang:(i==null?void 0:i.lang)||l,pageType:a==null?void 0:a.pageType,pageProps:{slug:(i==null?void 0:i.slug)+c,searchParams:{},pageType:i==null?void 0:i.pageType,fallbackLang:l,lastSaved:i==null?void 0:i.lastSaved,pageId:a==null?void 0:a.id,primaryPageId:(i==null?void 0:i.primaryPage)||(a==null?void 0:a.id),pageBaseSlug:i==null?void 0:i.slug,dynamic:a==null?void 0:a.dynamic,languagePageId:i==null?void 0:i.id,metadata:(a==null?void 0:a.metadata)||{}}}});return r.setQueryData([y.GET_BUILDER_PAGE_DATA,i==null?void 0:i.id,c],d.builderPageData),r.setQueryData([y.GET_LANGUAGE_PAGES,t],d.languagePages),d},enabled:!!t&&!!(a!=null&&a.pageType)&&!!(i!=null&&i.id)})},ti=()=>{const e=j(),t=O(),{handleQuerySync:s}=Nt();return x.useMutation({mutationFn:async n=>t(e,{action:y.UPDATE_WEBSITE_FIELDS,data:n}),onSuccess:(n,r)=>{s({type:"UPDATE_WEBSITE_DATA",data:r,sync:!0})},onError:n=>{U.toast.error("Failed to update website settings",{description:n.message})}})},si=()=>{const e=j(),t=x.useQueryClient(),s=O(),{selectedLang:n}=g.useLanguages();return x.useMutation({mutationFn:async r=>s(e,{action:y.ADD_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),U.toast.success("Schema added successfully.")},onError:r=>{U.toast.error("Failed to add schema",{description:r.message})}})},ni=()=>{const e=j(),t=x.useQueryClient(),s=O(),{selectedLang:n}=g.useLanguages();return x.useMutation({mutationFn:async r=>s(e,{action:y.UPDATE_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),U.toast.success("Schema updated successfully.")},onError:r=>{U.toast.error("Failed to update schema",{description:r.message})}})},ri=()=>{const e=j(),t=x.useQueryClient(),s=O();return x.useMutation({mutationFn:async n=>s(e,{action:y.DELETE_GLOBAL_SCHEMA,data:{id:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),U.toast.success("Schema deleted successfully.")},onError:n=>{U.toast.error("Failed to delete schema",{description:n.message})}})},ai=()=>{const e=j(),t=O();return x.useMutation({mutationFn:async s=>t(e,{action:y.TOGGLE_PAGE_GLOBAL_SCHEMA,data:s}),onError:s=>{U.toast.error("Failed to toggle schema",{description:s.message})}})},ii=()=>{const e=j(),t=O();return x.useMutation({mutationFn:async s=>t(e,{action:y.APPLY_SCHEMA_TO_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{U.toast.success(`Schema applied to ${s.count} page(s)`)},onError:s=>{U.toast.error("Failed to apply schema to all pages",{description:s.message})}})},oi=()=>{const e=j(),t=O();return x.useMutation({mutationFn:async s=>t(e,{action:y.REMOVE_SCHEMA_FROM_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{U.toast.success(`Schema removed from ${s.count} page(s)`)},onError:s=>{U.toast.error("Failed to remove schema from all pages",{description:s.message})}})},bs=(e=300)=>{const t=re("onLogout",p.noop),s=re("getAccessToken"),n=j();return x.useQuery({queryKey:["check-user-access"],queryFn:async()=>{const r=await s(),i=await Ys(n+"?action=check_user_access",{action:"CHECK_USER_ACCESS"},{Authorization:`Bearer ${r}`});if(i.status===401)throw console.log("401 Response",i),U.toast.error("You do not have access to edit this website. Please contact administrator"),await t("UNAUTHORIZED"),new Error("Unauthorized");return await i.json()},refetchInterval:e*1e3,refetchIntervalInBackground:!0,retry:!1})},li=()=>{const e=j(),t=O(),[,s]=tn(),n=x.useQueryClient(),{handleQuerySync:r}=Nt();return{onSave:async({page:i,blocks:l,needTranslations:c,partialIds:d,linkPageIds:h,designTokens:u})=>{try{const E=await t(e,{action:"UPDATE_PAGE",data:{id:i,blocks:l,needTranslations:c}});return E.code==="PAGE_LOCKED"?!0:(s(m=>({...m,lastSaved:new Date().toISOString()})),n.setQueryData([y.GET_LANGUAGE_PAGES,i],m=>m&&(m==null?void 0:m.map(A=>(A==null?void 0:A.id)===i?{...A,changes:["Page"]}:A))),r({type:"UPDATE_PAGE_DATA",data:{pageId:i,partialIds:d,linkPageIds:h,designTokens:u},sync:!0}),E)}catch(E){return console.error(E),new Error("Failed to save blocks")}}}},ci=()=>{const{data:e}=Ce(),t=j(),s=O();return{getPartialBlocks:f.useCallback(async()=>{const n={};for(const r of e??[])p.isEmpty(r==null?void 0:r.slug)&&(n[r.id]={type:r.pageType,name:p.startCase(r.name??r.slug),description:""});return n},[e]),getPartialBlockBlocks:f.useCallback(async n=>{if(!n)return[];try{const r=await s(t,{action:"GET_DRAFT_PAGE",data:{id:n,draft:!0,editor:!1,mergePartials:!0}});return p.filter(r.blocks,a=>p.has(a,"_id"))}catch(r){return console.error(r),[]}},[s,t])}},ui=f.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-content-CRLL24Tv.cjs"))),hn="chai-chat-panel",di=({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"})})})]}),fi=({isActive:e,show:t})=>g.useBuilderProp("flags.ai",!1)?o.jsx(C.Button,{size:"icon",className:"p-0 [&_svg]:size-6",onClick:t,variant:e?"default":"ghost",children:o.jsx(di,{className:e?"h-5 w-5 text-white":"h-5 w-5 text-primary"})}):null,hi={id:hn,label:"AI Assistant",button:fi,panel:ui,position:"top"},gi=f.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-B02TlFSc.cjs"))),mi=({isActive:e,show:t})=>{const{data:s}=xe();return!p.has(s,"languages")||!p.get(s,"languages",[]).length?null:o.jsx(C.Button,{size:"sm",onClick:t,variant:e?"default":"ghost",children:o.jsx(P.LanguagesIcon,{className:"h-4 w-4"})})},gn="lang",Ei={id:gn,label:"Languages",position:"top",panel:gi,button:mi,view:"modal",width:400},pi=f.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-B8I2tcq2.cjs"))),mn="seo",yi=({isActive:e,show:t})=>{const{data:s}=ae(),n=sn(s==null?void 0:s.pageType);return!p.has(n,"hasSlug")||!n.hasSlug?null:o.jsx(C.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"})]})})},Ai={id:mn,label:"SEO",panel:pi,button:yi,position:"top",width:600,view:"modal"},Ti=f.lazy(()=>Promise.resolve().then(()=>require("./change-password-modal-j9tdsI_2.cjs")).then(e=>({default:e.ChangePasswordModal}))),En="user-info",Si=()=>{const{t:e}=oe.useTranslation(),{user:t,logout:s}=Xt(),n=re("onLogout",p.noop),[r,a]=f.useState(!1);return t?o.jsxs(g.HoverCard,{children:[o.jsx(g.HoverCardTrigger,{asChild:!0,children:o.jsx(C.Button,{variant:"ghost",className:"text-sm font-medium",children:o.jsx(P.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.jsx(C.Button,{variant:"outline",size:"sm",className:"w-full",onClick:()=>a(!0),children:e("Change Password")}),r&&o.jsx(f.Suspense,{fallback:o.jsx(g.Dialog,{open:r,onOpenChange:a,children:o.jsx(g.DialogContent,{className:"sm:max-w-[425px]",children:o.jsx("div",{className:"flex h-[340px] items-center justify-center",children:o.jsx(P.Loader,{className:"h-8 w-8 animate-spin text-muted-foreground"})})})}),children:o.jsx(Ti,{open:r,onOpenChange:a})}),o.jsxs(g.AlertDialog,{children:[o.jsx(g.AlertDialogTrigger,{asChild:!0,children:o.jsx(C.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:()=>{s(),p.isFunction(n)&&n()},children:e("Logout")})]})]})]})]})]}):null},Pi={id:En,label:"User Info",button:Si,position:"bottom"},xi=()=>{C.registerChaiSidebarPanel(mn,Ai),C.registerChaiSidebarPanel(gn,Ei),C.registerChaiSidebarPanel(En,Pi),C.registerChaiSidebarPanel(hn,hi)};var b={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return Rs(this.context.count)},getNextContextId(){return Rs(this.context.count++)}};function Rs(e){const t=String(e),s=t.length-1;return b.context.id+(s?String.fromCharCode(96+s):"")+t}function at(e){b.context=e}var pn=!1,_i=(e,t)=>e===t,qt=Symbol("solid-proxy"),yn=typeof Proxy=="function",vs=Symbol("solid-track"),Kt={equals:_i},An=vn,ye=1,Vt=2,Tn={owned:null,cleanups:null,context:null,owner:null},ls={},G=null,cs=null,wi=null,B=null,te=null,pe=null,es=0;function Te(e,t){const s=B,n=G,r=e.length===0,a=t===void 0?n:t,i=r?Tn:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>X(()=>dt(i)));G=i,B=null;try{return fe(l,!0)}finally{B=s,G=n}}function K(e,t){t=t?Object.assign({},Kt,t):Kt;const s={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},n=r=>(typeof r=="function"&&(r=r(s.value)),bn(s,r));return[wn.bind(s),n]}function Sn(e,t,s){const n=ts(e,t,!0,ye);et(n)}function Se(e,t,s){const n=ts(e,t,!1,ye);et(n)}function Cs(e,t,s){An=Mi;const n=ts(e,t,!1,ye);(!s||!s.render)&&(n.user=!0),pe?pe.push(n):et(n)}function Z(e,t,s){s=s?Object.assign({},Kt,s):Kt;const n=ts(e,t,!0,0);return n.observers=null,n.observerSlots=null,n.comparator=s.equals||void 0,et(n),wn.bind(n)}function bi(e){return e&&typeof e=="object"&&"then"in e}function vi(e,t,s){let n,r,a;n=!0,r=e,a={};let i=null,l=ls,c=null,d=!1,h="initialValue"in a,u=typeof n=="function"&&Z(n);const E=new Set,[m,A]=(a.storage||K)(a.initialValue),[w,N]=K(void 0),[T,S]=K(void 0,{equals:!1}),[I,z]=K(h?"ready":"unresolved");b.context&&(c=b.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:b.load&&b.has(c)&&(l=b.load(c)));function Q(v,L,J,$){return i===v&&(i=null,$!==void 0&&(h=!0),(v===l||L===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated($,{value:L})),l=ls,H(L,J)),L}function H(v,L){fe(()=>{L===void 0&&A(()=>v),z(L!==void 0?"errored":h?"ready":"unresolved"),N(L);for(const J of E.keys())J.decrement();E.clear()},!1)}function ie(){const v=Gi,L=m(),J=w();if(J!==void 0&&!i)throw J;return B&&B.user,L}function D(v=!0){if(v!==!1&&d)return;d=!1;const L=u?u():n;if(L==null||L===!1){Q(i,X(m));return}let J;const $=l!==ls?l:X(()=>{try{return r(L,{value:m(),refetching:v})}catch(ne){J=ne}});if(J!==void 0){Q(i,void 0,Bt(J),L);return}else if(!bi($))return Q(i,$,void 0,L),$;return i=$,"v"in $?($.s===1?Q(i,$.v,void 0,L):Q(i,void 0,Bt($.v),L),$):(d=!0,queueMicrotask(()=>d=!1),fe(()=>{z(h?"refreshing":"pending"),S()},!1),$.then(ne=>Q($,ne,void 0,L),ne=>Q($,void 0,Bt(ne),L)))}Object.defineProperties(ie,{state:{get:()=>I()},error:{get:()=>w()},loading:{get(){const v=I();return v==="pending"||v==="refreshing"}},latest:{get(){if(!h)return ie();const v=w();if(v&&!i)throw v;return m()}}});let M=G;return u?Sn(()=>(M=G,D(!1))):D(!1),[ie,{refetch:v=>xn(M,()=>D(v)),mutate:A}]}function Ci(e){return fe(e,!1)}function X(e){if(B===null)return e();const t=B;B=null;try{return e()}finally{B=t}}function Ii(e,t,s){const n=Array.isArray(e);let r,a=s&&s.defer;return i=>{let l;if(n){l=Array(e.length);for(let d=0;d<e.length;d++)l[d]=e[d]()}else l=e();if(a)return a=!1,i;const c=X(()=>t(l,r,i));return r=l,c}}function Pn(e){Cs(()=>X(e))}function Ye(e){return G===null||(G.cleanups===null?G.cleanups=[e]:G.cleanups.push(e)),e}function Ms(){return G}function xn(e,t){const s=G,n=B;G=e,B=null;try{return fe(t,!0)}catch(r){Is(r)}finally{G=s,B=n}}function Ni(e){const t=B,s=G;return Promise.resolve().then(()=>{B=t,G=s;let n;return fe(e,!1),B=G=null,n?n.done:void 0})}var[Li,Kl]=K(!1);function ji(){return[Li,Ni]}function ki(e,t){const s=Symbol("context");return{id:s,Provider:Ui(s),defaultValue:e}}function Di(e){let t;return G&&G.context&&(t=G.context[e.id])!==void 0?t:e.defaultValue}function _n(e){const t=Z(e),s=Z(()=>fs(t()));return s.toArray=()=>{const n=s();return Array.isArray(n)?n:n!=null?[n]:[]},s}var Gi;function wn(){if(this.sources&&this.state)if(this.state===ye)et(this);else{const e=te;te=null,fe(()=>zt(this),!1),te=e}if(B){const e=this.observers?this.observers.length:0;B.sources?(B.sources.push(this),B.sourceSlots.push(e)):(B.sources=[this],B.sourceSlots=[e]),this.observers?(this.observers.push(B),this.observerSlots.push(B.sources.length-1)):(this.observers=[B],this.observerSlots=[B.sources.length-1])}return this.value}function bn(e,t,s){let n=e.value;return(!e.comparator||!e.comparator(n,t))&&(e.value=t,e.observers&&e.observers.length&&fe(()=>{for(let r=0;r<e.observers.length;r+=1){const a=e.observers[r],i=cs&&cs.running;i&&cs.disposed.has(a),(i?!a.tState:!a.state)&&(a.pure?te.push(a):pe.push(a),a.observers&&Cn(a)),i||(a.state=ye)}if(te.length>1e6)throw te=[],new Error},!1)),t}function et(e){if(!e.fn)return;dt(e);const t=es;Oi(e,e.value,t)}function Oi(e,t,s){let n;const r=G,a=B;B=G=e;try{n=e.fn(t)}catch(i){return e.pure&&(e.state=ye,e.owned&&e.owned.forEach(dt),e.owned=null),e.updatedAt=s+1,Is(i)}finally{B=a,G=r}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?bn(e,n):e.value=n,e.updatedAt=s)}function ts(e,t,s,n=ye,r){const a={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:G,context:G?G.context:null,pure:s};return G===null||G!==Tn&&(G.owned?G.owned.push(a):G.owned=[a]),a}function Qt(e){if(e.state===0)return;if(e.state===Vt)return zt(e);if(e.suspense&&X(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<es);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===ye)et(e);else if(e.state===Vt){const n=te;te=null,fe(()=>zt(e,t[0]),!1),te=n}}function fe(e,t){if(te)return e();let s=!1;t||(te=[]),pe?s=!0:pe=[],es++;try{const n=e();return Ri(s),n}catch(n){s||(pe=null),te=null,Is(n)}}function Ri(e){if(te&&(vn(te),te=null),e)return;const t=pe;pe=null,t.length&&fe(()=>An(t),!1)}function vn(e){for(let t=0;t<e.length;t++)Qt(e[t])}function Mi(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:Qt(n)}if(b.context){if(b.count){b.effects||(b.effects=[]),b.effects.push(...e.slice(0,s));return}at()}for(b.effects&&(b.done||!b.count)&&(e=[...b.effects,...e],s+=b.effects.length,delete b.effects),t=0;t<s;t++)Qt(e[t])}function zt(e,t){e.state=0;for(let s=0;s<e.sources.length;s+=1){const n=e.sources[s];if(n.sources){const r=n.state;r===ye?n!==t&&(!n.updatedAt||n.updatedAt<es)&&Qt(n):r===Vt&&zt(n,t)}}}function Cn(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=Vt,s.pure?te.push(s):pe.push(s),s.observers&&Cn(s))}}function dt(e){let t;if(e.sources)for(;e.sources.length;){const s=e.sources.pop(),n=e.sourceSlots.pop(),r=s.observers;if(r&&r.length){const a=r.pop(),i=s.observerSlots.pop();n<r.length&&(a.sourceSlots[i]=n,r[n]=a,s.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)dt(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)dt(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 Bt(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function Is(e,t=G){throw Bt(e)}function fs(e){if(typeof e=="function"&&!e.length)return fs(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const n=fs(e[s]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Ui(e,t){return function(n){let r;return Se(()=>r=X(()=>(G.context={...G.context,[e]:n.value},_n(()=>n.children))),void 0),r}}var hs=Symbol("fallback");function $t(e){for(let t=0;t<e.length;t++)e[t]()}function Bi(e,t,s={}){let n=[],r=[],a=[],i=0,l=t.length>1?[]:null;return Ye(()=>$t(a)),()=>{let c=e()||[],d=c.length,h,u;return c[vs],X(()=>{let m,A,w,N,T,S,I,z,Q;if(d===0)i!==0&&($t(a),a=[],n=[],r=[],i=0,l&&(l=[])),s.fallback&&(n=[hs],r[0]=Te(H=>(a[0]=H,s.fallback())),i=1);else if(i===0){for(r=new Array(d),u=0;u<d;u++)n[u]=c[u],r[u]=Te(E);i=d}else{for(w=new Array(d),N=new Array(d),l&&(T=new Array(d)),S=0,I=Math.min(i,d);S<I&&n[S]===c[S];S++);for(I=i-1,z=d-1;I>=S&&z>=S&&n[I]===c[z];I--,z--)w[z]=r[I],N[z]=a[I],l&&(T[z]=l[I]);for(m=new Map,A=new Array(z+1),u=z;u>=S;u--)Q=c[u],h=m.get(Q),A[u]=h===void 0?-1:h,m.set(Q,u);for(h=S;h<=I;h++)Q=n[h],u=m.get(Q),u!==void 0&&u!==-1?(w[u]=r[h],N[u]=a[h],l&&(T[u]=l[h]),u=A[u],m.set(Q,u)):a[h]();for(u=S;u<d;u++)u in w?(r[u]=w[u],a[u]=N[u],l&&(l[u]=T[u],l[u](u))):r[u]=Te(E);r=r.slice(0,i=d),n=c.slice(0)}return r});function E(m){if(a[u]=m,l){const[A,w]=K(u);return l[u]=w,t(c[u],A)}return t(c[u])}}}function Fi(e,t,s={}){let n=[],r=[],a=[],i=[],l=0,c;return Ye(()=>$t(a)),()=>{const d=e()||[],h=d.length;return d[vs],X(()=>{if(h===0)return l!==0&&($t(a),a=[],n=[],r=[],l=0,i=[]),s.fallback&&(n=[hs],r[0]=Te(E=>(a[0]=E,s.fallback())),l=1),r;for(n[0]===hs&&(a[0](),a=[],n=[],r=[],l=0),c=0;c<h;c++)c<n.length&&n[c]!==d[c]?i[c](()=>d[c]):c>=n.length&&(r[c]=Te(u));for(;c<n.length;c++)a[c]();return l=i.length=a.length=h,n=d.slice(0),r=r.slice(0,l)});function u(E){a[c]=E;const[m,A]=K(d[c]);return i[c]=A,t(m,c)}}}function Ns(e,t){return X(()=>e(t||{}))}function Ot(){return!0}var gs={get(e,t,s){return t===qt?s:e.get(t)},has(e,t){return t===qt?!0:e.has(t)},set:Ot,deleteProperty:Ot,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:Ot,deleteProperty:Ot}},ownKeys(e){return e.keys()}};function us(e){return(e=typeof e=="function"?e():e)?e:{}}function Hi(){for(let e=0,t=this.length;e<t;++e){const s=this[e]();if(s!==void 0)return s}}function Ls(...e){let t=!1;for(let i=0;i<e.length;i++){const l=e[i];t=t||!!l&&qt in l,e[i]=typeof l=="function"?(t=!0,Z(l)):l}if(yn&&t)return new Proxy({get(i){for(let l=e.length-1;l>=0;l--){const c=us(e[l])[i];if(c!==void 0)return c}},has(i){for(let l=e.length-1;l>=0;l--)if(i in us(e[l]))return!0;return!1},keys(){const i=[];for(let l=0;l<e.length;l++)i.push(...Object.keys(us(e[l])));return[...new Set(i)]}},gs);const s={},n=Object.create(null);for(let i=e.length-1;i>=0;i--){const l=e[i];if(!l)continue;const c=Object.getOwnPropertyNames(l);for(let d=c.length-1;d>=0;d--){const h=c[d];if(h==="__proto__"||h==="constructor")continue;const u=Object.getOwnPropertyDescriptor(l,h);if(!n[h])n[h]=u.get?{enumerable:!0,configurable:!0,get:Hi.bind(s[h]=[u.get.bind(l)])}:u.value!==void 0?u:void 0;else{const E=s[h];E&&(u.get?E.push(u.get.bind(l)):u.value!==void 0&&E.push(()=>u.value))}}}const r={},a=Object.keys(n);for(let i=a.length-1;i>=0;i--){const l=a[i],c=n[l];c&&c.get?Object.defineProperty(r,l,c):r[l]=c?c.value:void 0}return r}function In(e,...t){if(yn&&qt 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)}},gs));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))}},gs)),a}const s={},n=t.map(()=>({}));for(const r of Object.getOwnPropertyNames(e)){const a=Object.getOwnPropertyDescriptor(e,r),i=!a.get&&!a.set&&a.enumerable&&a.writable&&a.configurable;let l=!1,c=0;for(const d of t)d.includes(r)&&(l=!0,i?n[c][r]=a.value:Object.defineProperty(n[c],r,a)),++c;l||(i?s[r]=a.value:Object.defineProperty(s,r,a))}return[...n,s]}function Nn(e){let t,s;const n=r=>{const a=b.context;if(a){const[l,c]=K();b.count||(b.count=0),b.count++,(s||(s=e())).then(d=>{!b.done&&at(a),b.count--,c(()=>d.default),at()}),t=l}else if(!t){const[l]=vi(()=>(s||(s=e())).then(c=>c.default));t=l}let i;return Z(()=>(i=t())?X(()=>{if(!a||b.done)return i(r);const l=b.context;at(a);const c=i(r);return at(l),c}):"")};return n.preload=()=>s||((s=e()).then(r=>t=()=>r.default),s),n}var qi=0;function Ki(){return b.context?b.getNextContextId():`cl-${qi++}`}var Ln=e=>`Stale read from <${e}>.`;function Vi(e){const t="fallback"in e&&{fallback:()=>e.fallback};return Z(Bi(()=>e.each,e.children,t||void 0))}function Qi(e){const t="fallback"in e&&{fallback:()=>e.fallback};return Z(Fi(()=>e.each,e.children,t||void 0))}function zi(e){const t=e.keyed,s=Z(()=>e.when,void 0,void 0),n=t?s:Z(s,void 0,{equals:(r,a)=>!r==!a});return Z(()=>{const r=n();if(r){const a=e.children;return typeof a=="function"&&a.length>0?X(()=>a(t?r:()=>{if(!X(n))throw Ln("Show");return s()})):a}return e.fallback},void 0,void 0)}function $i(e){const t=_n(()=>e.children),s=Z(()=>{const n=t(),r=Array.isArray(n)?n:[n];let a=()=>{};for(let i=0;i<r.length;i++){const l=i,c=r[i],d=a,h=Z(()=>d()?void 0:c.when,void 0,void 0),u=c.keyed?h:Z(h,void 0,{equals:(E,m)=>!E==!m});a=()=>d()||(u()?[l,h,c]:void 0)}return a});return Z(()=>{const n=s()();if(!n)return e.fallback;const[r,a,i]=n,l=i.children;return typeof l=="function"&&l.length>0?X(()=>l(i.keyed?a():()=>{var d;if(((d=X(s)())==null?void 0:d[0])!==r)throw Ln("Match");return a()})):l},void 0,void 0)}function Wi(e){return e}var Ji=["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"],Yi=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",...Ji]),Zi=new Set(["innerHTML","textContent","innerText","children"]),Xi=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),eo=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 to(e,t){const s=eo[e];return typeof s=="object"?s[t]?s.$:void 0:s}var so=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),no=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"]),ro={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},ao=e=>Z(()=>e());function io(e,t,s){let n=s.length,r=t.length,a=n,i=0,l=0,c=t[r-1].nextSibling,d=null;for(;i<r||l<a;){if(t[i]===s[l]){i++,l++;continue}for(;t[r-1]===s[a-1];)r--,a--;if(r===i){const h=a<n?l?s[l-1].nextSibling:s[a-l]:c;for(;l<a;)e.insertBefore(s[l++],h)}else if(a===l)for(;i<r;)(!d||!d.has(t[i]))&&t[i].remove(),i++;else if(t[i]===s[a-1]&&s[l]===t[r-1]){const h=t[--r].nextSibling;e.insertBefore(s[l++],t[i++].nextSibling),e.insertBefore(s[--a],h),t[r]=s[a]}else{if(!d){d=new Map;let u=l;for(;u<a;)d.set(s[u],u++)}const h=d.get(t[i]);if(h!=null)if(l<h&&h<a){let u=i,E=1,m;for(;++u<r&&u<a&&!((m=d.get(t[u]))==null||m!==h+E);)E++;if(E>h-l){const A=t[i];for(;l<h;)e.insertBefore(s[l++],A)}else e.replaceChild(s[l++],t[i++])}else i++;else t[i++].remove()}}}var lt="_$DX_DELEGATE";function jn(e,t,s,n={}){let r;return Te(a=>{r=a,t===document?e():Jt(t,e(),t.firstChild?null:void 0,s)},n.owner),()=>{r(),t.textContent=""}}function oo(e,t,s,n){let r;const a=()=>{const l=document.createElement("template");return l.innerHTML=e,l.content.firstChild},i=()=>(r||(r=a())).cloneNode(!0);return i.cloneNode=i,i}function kn(e,t=window.document){const s=t[lt]||(t[lt]=new Set);for(let n=0,r=e.length;n<r;n++){const a=e[n];s.has(a)||(s.add(a),t.addEventListener(a,Mn))}}function lo(e=window.document){if(e[lt]){for(let t of e[lt].keys())e.removeEventListener(t,Mn);delete e[lt]}}function Wt(e,t,s){Ie(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function co(e,t,s,n){Ie(e)||(n==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,n))}function uo(e,t,s){Ie(e)||(s?e.setAttribute(t,""):e.removeAttribute(t))}function Dn(e,t){Ie(e)||(t==null?e.removeAttribute("class"):e.className=t)}function Gn(e,t,s,n){if(n)Array.isArray(s)?(e[`$$${t}`]=s[0],e[`$$${t}Data`]=s[1]):e[`$$${t}`]=s;else if(Array.isArray(s)){const r=s[0];e.addEventListener(t,s[0]=a=>r.call(e,s[1],a))}else e.addEventListener(t,s,typeof s!="function"&&s)}function fo(e,t,s={}){const n=Object.keys(t||{}),r=Object.keys(s);let a,i;for(a=0,i=r.length;a<i;a++){const l=r[a];!l||l==="undefined"||t[l]||(Us(e,l,!1),delete s[l])}for(a=0,i=n.length;a<i;a++){const l=n[a],c=!!t[l];!l||l==="undefined"||s[l]===c||!c||(Us(e,l,!0),s[l]=c)}return s}function ho(e,t,s){if(!t)return s?Wt(e,"style"):t;const n=e.style;if(typeof t=="string")return n.cssText=t;typeof s=="string"&&(n.cssText=s=void 0),s||(s={}),t||(t={});let r,a;for(a in s)t[a]==null&&n.removeProperty(a),delete s[a];for(a in t)r=t[a],r!==s[a]&&(n.setProperty(a,r),s[a]=r);return s}function On(e,t={},s,n){const r={};return n||Se(()=>r.children=ft(e,t.children,r.children)),Se(()=>typeof t.ref=="function"&&Rn(t.ref,e)),Se(()=>go(e,t,s,!0,r,!0)),r}function Rn(e,t,s){return X(()=>e(t,s))}function Jt(e,t,s,n){if(s!==void 0&&!n&&(n=[]),typeof t!="function")return ft(e,t,n,s);Se(r=>ft(e,t(),r,s),n)}function go(e,t,s,n,r={},a=!1){t||(t={});for(const i in r)if(!(i in t)){if(i==="children")continue;r[i]=Bs(e,i,null,r[i],s,a,t)}for(const i in t){if(i==="children")continue;const l=t[i];r[i]=Bs(e,i,l,r[i],s,a,t)}}function mo(e){let t,s;return!Ie()||!(t=b.registry.get(s=po()))?e():(b.completed&&b.completed.add(t),b.registry.delete(s),t)}function Ie(e){return!!b.context&&!b.done&&(!e||e.isConnected)}function Eo(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function Us(e,t,s){const n=t.trim().split(/\s+/);for(let r=0,a=n.length;r<a;r++)e.classList.toggle(n[r],s)}function Bs(e,t,s,n,r,a,i){let l,c,d,h,u;if(t==="style")return ho(e,s,n);if(t==="classList")return fo(e,s,n);if(s===n)return n;if(t==="ref")a||s(e);else if(t.slice(0,3)==="on:"){const E=t.slice(3);n&&e.removeEventListener(E,n,typeof n!="function"&&n),s&&e.addEventListener(E,s,typeof s!="function"&&s)}else if(t.slice(0,10)==="oncapture:"){const E=t.slice(10);n&&e.removeEventListener(E,n,!0),s&&e.addEventListener(E,s,!0)}else if(t.slice(0,2)==="on"){const E=t.slice(2).toLowerCase(),m=so.has(E);if(!m&&n){const A=Array.isArray(n)?n[0]:n;e.removeEventListener(E,A)}(m||s)&&(Gn(e,E,s,m),m&&kn([E]))}else if(t.slice(0,5)==="attr:")Wt(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")uo(e,t.slice(5),s);else if((u=t.slice(0,5)==="prop:")||(d=Zi.has(t))||!r&&((h=to(t,e.tagName))||(c=Yi.has(t)))||(l=e.nodeName.includes("-")||"is"in i)){if(u)t=t.slice(5),c=!0;else if(Ie(e))return s;t==="class"||t==="className"?Dn(e,s):l&&!c&&!d?e[Eo(t)]=s:e[h||t]=s}else{const E=r&&t.indexOf(":")>-1&&ro[t.split(":")[0]];E?co(e,E,t,s):Wt(e,Xi[t]||t,s)}return s}function Mn(e){if(b.registry&&b.events&&b.events.find(([c,d])=>d===e))return;let t=e.target;const s=`$$${e.type}`,n=e.target,r=e.currentTarget,a=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),i=()=>{const c=t[s];if(c&&!t.disabled){const d=t[`${s}Data`];if(d!==void 0?c.call(t,d,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&a(t.host),!0},l=()=>{for(;i()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),b.registry&&!b.done&&(b.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();a(c[0]);for(let d=0;d<c.length-2&&(t=c[d],!!i());d++){if(t._$host){t=t._$host,l();break}if(t.parentNode===r)break}}else l();a(n)}function ft(e,t,s,n,r){const a=Ie(e);if(a){!s&&(s=[...e.childNodes]);let c=[];for(let d=0;d<s.length;d++){const h=s[d];h.nodeType===8&&h.data.slice(0,2)==="!$"?h.remove():c.push(h)}s=c}for(;typeof s=="function";)s=s();if(t===s)return s;const i=typeof t,l=n!==void 0;if(e=l&&s[0]&&s[0].parentNode||e,i==="string"||i==="number"){if(a||i==="number"&&(t=t.toString(),t===s))return s;if(l){let c=s[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),s=Le(e,s,n,c)}else s!==""&&typeof s=="string"?s=e.firstChild.data=t:s=e.textContent=t}else if(t==null||i==="boolean"){if(a)return s;s=Le(e,s,n)}else{if(i==="function")return Se(()=>{let c=t();for(;typeof c=="function";)c=c();s=ft(e,c,s,n)}),()=>s;if(Array.isArray(t)){const c=[],d=s&&Array.isArray(s);if(ms(c,t,s,r))return Se(()=>s=ft(e,c,s,n,!0)),()=>s;if(a){if(!c.length)return s;if(n===void 0)return s=[...e.childNodes];let h=c[0];if(h.parentNode!==e)return s;const u=[h];for(;(h=h.nextSibling)!==n;)u.push(h);return s=u}if(c.length===0){if(s=Le(e,s,n),l)return s}else d?s.length===0?Fs(e,c,n):io(e,s,c):(s&&Le(e),Fs(e,c));s=c}else if(t.nodeType){if(a&&t.parentNode)return s=l?[t]:t;if(Array.isArray(s)){if(l)return s=Le(e,s,n,t);Le(e,s,null,t)}else s==null||s===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);s=t}}return s}function ms(e,t,s,n){let r=!1;for(let a=0,i=t.length;a<i;a++){let l=t[a],c=s&&s[e.length],d;if(!(l==null||l===!0||l===!1))if((d=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))r=ms(e,l,c)||r;else if(d==="function")if(n){for(;typeof l=="function";)l=l();r=ms(e,Array.isArray(l)?l:[l],Array.isArray(c)?c:[c])||r}else e.push(l),r=!0;else{const h=String(l);c&&c.nodeType===3&&c.data===h?e.push(c):e.push(document.createTextNode(h))}}return r}function Fs(e,t,s=null){for(let n=0,r=t.length;n<r;n++)e.insertBefore(t[n],s)}function Le(e,t,s,n){if(s===void 0)return e.textContent="";const r=n||document.createTextNode("");if(t.length){let a=!1;for(let i=t.length-1;i>=0;i--){const l=t[i];if(r!==l){const c=l.parentNode===e;!a&&!i?c?e.replaceChild(r,l):e.insertBefore(r,s):c&&l.remove()}else a=!0}}else e.insertBefore(r,s);return[r]}function po(){return b.getNextContextId()}var yo="http://www.w3.org/2000/svg";function Un(e,t=!1){return t?document.createElementNS(yo,e):document.createElement(e)}function Ao(e){const{useShadow:t}=e,s=document.createTextNode(""),n=()=>e.mount||document.body,r=Ms();let a,i=!!b.context;return Cs(()=>{i&&(Ms().user=i=!1),a||(a=xn(r,()=>Z(()=>e.children)));const l=n();if(l instanceof HTMLHeadElement){const[c,d]=K(!1),h=()=>d(!0);Te(u=>Jt(l,()=>c()?u():a(),null)),Ye(h)}else{const c=Un(e.isSVG?"g":"div",e.isSVG),d=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return s.parentNode},configurable:!0}),Jt(d,a),l.appendChild(c),e.ref&&e.ref(c),Ye(()=>l.removeChild(c))}},void 0,{render:!i}),s}function To(e,t){const s=Z(e);return Z(()=>{const n=s();switch(typeof n){case"function":return X(()=>n(t));case"string":const r=no.has(n),a=b.context?mo():Un(n,r);return On(a,t,r),a}})}function So(e){const[,t]=In(e,["component"]);return To(()=>e.component,t)}var Po=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()}},Bn=class{constructor(e){this.generateIdentifier=e,this.kv=new Po}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)}},xo=class extends Bn{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 _o(e){if("values"in Object)return Object.values(e);const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push(e[s]);return t}function wo(e,t){const s=_o(e);if("find"in s)return s.find(t);const n=s;for(let r=0;r<n.length;r++){const a=n[r];if(t(a))return a}}function Ze(e,t){Object.entries(e).forEach(([s,n])=>t(n,s))}function Ft(e,t){return e.indexOf(t)!==-1}function Hs(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var bo=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return wo(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},vo=e=>Object.prototype.toString.call(e).slice(8,-1),Fn=e=>typeof e>"u",Co=e=>e===null,ht=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,Es=e=>ht(e)&&Object.keys(e).length===0,Pe=e=>Array.isArray(e),Io=e=>typeof e=="string",No=e=>typeof e=="number"&&!isNaN(e),Lo=e=>typeof e=="boolean",jo=e=>e instanceof RegExp,gt=e=>e instanceof Map,mt=e=>e instanceof Set,Hn=e=>vo(e)==="Symbol",ko=e=>e instanceof Date&&!isNaN(e.valueOf()),Do=e=>e instanceof Error,qs=e=>typeof e=="number"&&isNaN(e),Go=e=>Lo(e)||Co(e)||Fn(e)||No(e)||Io(e)||Hn(e),Oo=e=>typeof e=="bigint",Ro=e=>e===1/0||e===-1/0,Mo=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),Uo=e=>e instanceof URL,qn=e=>e.replace(/\./g,"\\."),ds=e=>e.map(String).map(qn).join("."),ct=e=>{const t=[];let s="";for(let r=0;r<e.length;r++){let a=e.charAt(r);if(a==="\\"&&e.charAt(r+1)==="."){s+=".",r++;continue}if(a==="."){t.push(s),s="";continue}s+=a}const n=s;return t.push(n),t};function de(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var Kn=[de(Fn,"undefined",()=>null,()=>{}),de(Oo,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),de(ko,"Date",e=>e.toISOString(),e=>new Date(e)),de(Do,"Error",(e,t)=>{const s={name:e.name,message:e.message};return t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s},(e,t)=>{const s=new Error(e.message);return s.name=e.name,s.stack=e.stack,t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s}),de(jo,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),de(mt,"set",e=>[...e.values()],e=>new Set(e)),de(gt,"map",e=>[...e.entries()],e=>new Map(e)),de(e=>qs(e)||Ro(e),"number",e=>qs(e)?"NaN":e>0?"Infinity":"-Infinity",Number),de(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),de(Uo,"URL",e=>e.toString(),e=>new URL(e))];function ss(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var Vn=ss((e,t)=>Hn(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,s)=>{const n=s.symbolRegistry.getValue(t[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),Bo=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),Qn=ss(Mo,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=Bo[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function zn(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var $n=ss(zn,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const s=t.classRegistry.getAllowedProps(e.constructor);if(!s)return{...e};const n={};return s.forEach(r=>{n[r]=e[r]}),n},(e,t,s)=>{const n=s.classRegistry.getValue(t[1]);if(!n)throw new Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(n.prototype),e)}),Wn=ss((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,s)=>{const n=s.customTransformerRegistry.findByName(t[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(e)}),Fo=[$n,Vn,Wn,Qn],Ks=(e,t)=>{const s=Hs(Fo,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=Hs(Kn,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},Jn={};Kn.forEach(e=>{Jn[e.annotation]=e});var Ho=(e,t,s)=>{if(Pe(t))switch(t[0]){case"symbol":return Vn.untransform(e,t,s);case"class":return $n.untransform(e,t,s);case"custom":return Wn.untransform(e,t,s);case"typed-array":return Qn.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const n=Jn[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,s)}},je=(e,t)=>{if(t>e.size)throw new Error("index out of bounds");const s=e.keys();for(;t>0;)s.next(),t--;return s.next().value};function Yn(e){if(Ft(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Ft(e,"prototype"))throw new Error("prototype is not allowed as a property");if(Ft(e,"constructor"))throw new Error("constructor is not allowed as a property")}var qo=(e,t)=>{Yn(t);for(let s=0;s<t.length;s++){const n=t[s];if(mt(e))e=je(e,+n);else if(gt(e)){const r=+n,a=+t[++s]==0?"key":"value",i=je(e,r);switch(a){case"key":e=i;break;case"value":e=e.get(i);break}}else e=e[n]}return e},ps=(e,t,s)=>{if(Yn(t),t.length===0)return s(e);let n=e;for(let a=0;a<t.length-1;a++){const i=t[a];if(Pe(n)){const l=+i;n=n[l]}else if(ht(n))n=n[i];else if(mt(n)){const l=+i;n=je(n,l)}else if(gt(n)){if(a===t.length-2)break;const c=+i,d=+t[++a]==0?"key":"value",h=je(n,c);switch(d){case"key":n=h;break;case"value":n=n.get(h);break}}}const r=t[t.length-1];if(Pe(n)?n[+r]=s(n[+r]):ht(n)&&(n[r]=s(n[r])),mt(n)){const a=je(n,+r),i=s(a);a!==i&&(n.delete(a),n.add(i))}if(gt(n)){const a=+t[t.length-2],i=je(n,a);switch(+r==0?"key":"value"){case"key":{const c=s(i);n.set(c,n.get(i)),c!==i&&n.delete(i);break}case"value":{n.set(i,s(n.get(i)));break}}}return e};function ys(e,t,s=[]){if(!e)return;if(!Pe(e)){Ze(e,(a,i)=>ys(a,t,[...s,...ct(i)]));return}const[n,r]=e;r&&Ze(r,(a,i)=>{ys(a,t,[...s,...ct(i)])}),t(n,s)}function Ko(e,t,s){return ys(t,(n,r)=>{e=ps(e,r,a=>Ho(a,n,s))}),e}function Vo(e,t){function s(n,r){const a=qo(e,ct(r));n.map(ct).forEach(i=>{e=ps(e,i,()=>a)})}if(Pe(t)){const[n,r]=t;n.forEach(a=>{e=ps(e,ct(a),()=>e)}),r&&Ze(r,s)}else Ze(t,s);return e}var Qo=(e,t)=>ht(e)||Pe(e)||gt(e)||mt(e)||zn(e,t);function zo(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function $o(e,t){const s={};let n;return e.forEach(r=>{if(r.length<=1)return;t||(r=r.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[a,...i]=r;a.length===0?n=i.map(ds):s[ds(a)]=i.map(ds)}),n?Es(s)?[n]:[n,s]:Es(s)?void 0:s}var Zn=(e,t,s,n,r=[],a=[],i=new Map)=>{const l=Go(e);if(!l){zo(e,r,t);const m=i.get(e);if(m)return n?{transformedValue:null}:m}if(!Qo(e,s)){const m=Ks(e,s),A=m?{transformedValue:m.value,annotations:[m.type]}:{transformedValue:e};return l||i.set(e,A),A}if(Ft(a,e))return{transformedValue:null};const c=Ks(e,s),d=(c==null?void 0:c.value)??e,h=Pe(d)?[]:{},u={};Ze(d,(m,A)=>{if(A==="__proto__"||A==="constructor"||A==="prototype")throw new Error(`Detected property ${A}. This is a prototype pollution risk, please remove it from your object.`);const w=Zn(m,t,s,n,[...r,A],[...a,e],i);h[A]=w.transformedValue,Pe(w.annotations)?u[A]=w.annotations:ht(w.annotations)&&Ze(w.annotations,(N,T)=>{u[qn(A)+"."+T]=N})});const E=Es(u)?{transformedValue:h,annotations:c?[c.type]:void 0}:{transformedValue:h,annotations:c?[c.type,u]:u};return l||i.set(e,E),E};function Xn(e){return Object.prototype.toString.call(e).slice(8,-1)}function Vs(e){return Xn(e)==="Array"}function Wo(e){if(Xn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function Jo(e,t,s,n,r){const a={}.propertyIsEnumerable.call(n,t)?"enumerable":"nonenumerable";a==="enumerable"&&(e[t]=s),r&&a==="nonenumerable"&&Object.defineProperty(e,t,{value:s,enumerable:!1,writable:!0,configurable:!0})}function As(e,t={}){if(Vs(e))return e.map(r=>As(r,t));if(!Wo(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((r,a)=>{if(Vs(t.props)&&!t.props.includes(a))return r;const i=e[a],l=As(i,t);return Jo(r,a,l,e,t.nonenumerable),r},{})}var F=class{constructor({dedupe:e=!1}={}){this.classRegistry=new xo,this.symbolRegistry=new Bn(t=>t.description??""),this.customTransformerRegistry=new bo,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=Zn(e,t,this,this.dedupe),n={json:s.transformedValue};s.annotations&&(n.meta={...n.meta,values:s.annotations});const r=$o(t,this.dedupe);return r&&(n.meta={...n.meta,referentialEqualities:r}),n}deserialize(e){const{json:t,meta:s}=e;let n=As(t);return s!=null&&s.values&&(n=Ko(n,s.values,this)),s!=null&&s.referentialEqualities&&(n=Vo(n,s.referentialEqualities)),n}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};F.defaultInstance=new F;F.serialize=F.defaultInstance.serialize.bind(F.defaultInstance);F.deserialize=F.defaultInstance.deserialize.bind(F.defaultInstance);F.stringify=F.defaultInstance.stringify.bind(F.defaultInstance);F.parse=F.defaultInstance.parse.bind(F.defaultInstance);F.registerClass=F.defaultInstance.registerClass.bind(F.defaultInstance);F.registerSymbol=F.defaultInstance.registerSymbol.bind(F.defaultInstance);F.registerCustom=F.defaultInstance.registerCustom.bind(F.defaultInstance);F.allowErrorProps=F.defaultInstance.allowErrorProps.bind(F.defaultInstance);var er=F.serialize,Yo=F.stringify;function Zo(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function Xo(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function el({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function tl({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function sl(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var nl=(e,t=!1)=>{const{json:s}=er(e);return JSON.stringify(s,null,t?2:void 0)},Rt=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,rl=(e,t)=>e.queryHash.localeCompare(t.queryHash),tr=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,al=(e,t)=>Rt(e)===Rt(t)?tr(e,t):Rt(e)>Rt(t)?1:-1,il={status:al,"query hash":rl,"last updated":tr},Mt=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,sr=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,ol=(e,t)=>Mt(e)===Mt(t)?sr(e,t):Mt(e)>Mt(t)?1:-1,ll={status:ol,"last updated":sr},cl=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),ul=()=>{const[e,t]=K("dark");return Pn(()=>{const s=window.matchMedia("(prefers-color-scheme: dark)");t(s.matches?"dark":"light");const n=r=>{t(r.matches?"dark":"light")};s.addEventListener("change",n),Ye(()=>s.removeEventListener("change",n))}),e},it=(e,t,s)=>{if(t.length===0)return s;if(e instanceof Map){const n=new Map(e);if(t.length===1)return n.set(t[0],s),n;const[r,...a]=t;return n.set(r,it(n.get(r),a,s)),n}if(e instanceof Set){const n=it(Array.from(e),t,s);return new Set(n)}if(Array.isArray(e)){const n=[...e];if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=it(n[r],a,s),n}if(e instanceof Object){const n={...e};if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=it(n[r],a,s),n}return e},ot=(e,t)=>{if(e instanceof Map){const s=new Map(e);if(t.length===1)return s.delete(t[0]),s;const[n,...r]=t;return s.set(n,ot(s.get(n),r)),s}if(e instanceof Set){const s=ot(Array.from(e),t);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s.filter((a,i)=>i.toString()!==t[0]);const[n,...r]=t;return s[n]=ot(s[n],r),s}if(e instanceof Object){const s={...e};if(t.length===1)return delete s[t[0]],s;const[n,...r]=t;return s[n]=ot(s[n],r),s}return e},nr=(e,t)=>{if(!e||document.querySelector("#_goober")||(t==null?void 0:t.querySelector("#_goober")))return;const n=document.createElement("style"),r=document.createTextNode("");n.appendChild(r),n.id="_goober",n.setAttribute("nonce",e),t?t.appendChild(n):document.head.appendChild(n)},ke,Et,pt,yt,be,At,De,Ge,Oe,Re,Me,Tt,Ue,Be,St,$s,dl=($s=class{constructor(e){R(this,ke);R(this,Et);R(this,pt);R(this,yt);R(this,be,!1);R(this,At);R(this,De);R(this,Ge);R(this,Oe);R(this,Re);R(this,Me);R(this,Tt);R(this,Ue);R(this,Be);R(this,St);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:h,hideDisabledQueries:u,theme:E}=e;k(this,ke,K(t)),k(this,pt,s),k(this,yt,n),k(this,Et,r),k(this,At,d),k(this,De,h),k(this,Ge,K(a)),k(this,Oe,K(i)),k(this,Re,K(l)),k(this,Me,K(c)),k(this,Tt,K(u)),k(this,Be,K(E))}setButtonPosition(e){_(this,Ge)[1](e)}setPosition(e){_(this,Oe)[1](e)}setInitialIsOpen(e){_(this,Re)[1](e)}setErrorTypes(e){_(this,Me)[1](e)}setClient(e){_(this,ke)[1](e)}setTheme(e){_(this,Be)[1](e)}mount(e){if(_(this,be))throw new Error("Devtools is already mounted");const t=jn(()=>{const s=this,[n]=_(this,Ge),[r]=_(this,Oe),[a]=_(this,Re),[i]=_(this,Me),[l]=_(this,Tt),[c]=_(this,ke),[d]=_(this,Be);let h;return _(this,Ue)?h=_(this,Ue):(h=Nn(()=>Promise.resolve().then(()=>require("./WDYDFRGG-Bcgsloma.cjs"))),k(this,Ue,h)),nr(_(this,At),_(this,De)),Ns(h,Ls({get queryFlavor(){return _(s,pt)},get version(){return _(s,yt)},get onlineManager(){return _(s,Et)},get shadowDOMTarget(){return _(s,De)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()},get theme(){return d()}}))},e);k(this,be,!0),k(this,St,t)}unmount(){var e;if(!_(this,be))throw new Error("Devtools is not mounted");(e=_(this,St))==null||e.call(this),k(this,be,!1)}},ke=new WeakMap,Et=new WeakMap,pt=new WeakMap,yt=new WeakMap,be=new WeakMap,At=new WeakMap,De=new WeakMap,Ge=new WeakMap,Oe=new WeakMap,Re=new WeakMap,Me=new WeakMap,Tt=new WeakMap,Ue=new WeakMap,Be=new WeakMap,St=new WeakMap,$s),Fe,Pt,xt,_t,ve,wt,He,qe,Ke,Ve,Qe,bt,ze,$e,We,vt,Ws,fl=(Ws=class{constructor(e){R(this,Fe);R(this,Pt);R(this,xt);R(this,_t);R(this,ve,!1);R(this,wt);R(this,He);R(this,qe);R(this,Ke);R(this,Ve);R(this,Qe);R(this,bt);R(this,ze);R(this,$e);R(this,We);R(this,vt);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:h,onClose:u,hideDisabledQueries:E,theme:m}=e;k(this,Fe,K(t)),k(this,xt,s),k(this,_t,n),k(this,Pt,r),k(this,wt,d),k(this,He,h),k(this,qe,K(a)),k(this,Ke,K(i)),k(this,Ve,K(l)),k(this,Qe,K(c)),k(this,bt,K(E)),k(this,ze,K(u)),k(this,We,K(m))}setButtonPosition(e){_(this,qe)[1](e)}setPosition(e){_(this,Ke)[1](e)}setInitialIsOpen(e){_(this,Ve)[1](e)}setErrorTypes(e){_(this,Qe)[1](e)}setClient(e){_(this,Fe)[1](e)}setOnClose(e){_(this,ze)[1](()=>e)}setTheme(e){_(this,We)[1](e)}mount(e){if(_(this,ve))throw new Error("Devtools is already mounted");const t=jn(()=>{const s=this,[n]=_(this,qe),[r]=_(this,Ke),[a]=_(this,Ve),[i]=_(this,Qe),[l]=_(this,bt),[c]=_(this,Fe),[d]=_(this,ze),[h]=_(this,We);let u;return _(this,$e)?u=_(this,$e):(u=Nn(()=>Promise.resolve().then(()=>require("./2SSKDMRQ-Cmm80_70.cjs"))),k(this,$e,u)),nr(_(this,wt),_(this,He)),Ns(u,Ls({get queryFlavor(){return _(s,xt)},get version(){return _(s,_t)},get onlineManager(){return _(s,Pt)},get shadowDOMTarget(){return _(s,He)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()},get onClose(){return d()},get theme(){return h()}}))},e);k(this,ve,!0),k(this,vt,t)}unmount(){var e;if(!_(this,ve))throw new Error("Devtools is not mounted");(e=_(this,vt))==null||e.call(this),k(this,ve,!1)}},Fe=new WeakMap,Pt=new WeakMap,xt=new WeakMap,_t=new WeakMap,ve=new WeakMap,wt=new WeakMap,He=new WeakMap,qe=new WeakMap,Ke=new WeakMap,Ve=new WeakMap,Qe=new WeakMap,bt=new WeakMap,ze=new WeakMap,$e=new WeakMap,We=new WeakMap,vt=new WeakMap,Ws);function hl(e){const t=x.useQueryClient(e.client),s=Y.useRef(null),{buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d,theme:h}=e,[u]=Y.useState(new dl({client:t,queryFlavor:"React Query",version:"5",onlineManager:x.onlineManager,buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d,theme:h}));return Y.useEffect(()=>{u.setClient(t)},[t,u]),Y.useEffect(()=>{n&&u.setButtonPosition(n)},[n,u]),Y.useEffect(()=>{r&&u.setPosition(r)},[r,u]),Y.useEffect(()=>{u.setInitialIsOpen(a||!1)},[a,u]),Y.useEffect(()=>{u.setErrorTypes(i||[])},[i,u]),Y.useEffect(()=>{u.setTheme(h)},[h,u]),Y.useEffect(()=>(s.current&&u.mount(s.current),()=>{u.unmount()}),[u]),o.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:s})}function gl(e){const t=x.useQueryClient(e.client),s=Y.useRef(null),{errorTypes:n,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:i,theme:l}=e,[c]=Y.useState(new fl({client:t,queryFlavor:"React Query",version:"5",onlineManager:x.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:n,styleNonce:r,shadowDOMTarget:a,onClose:e.onClose,hideDisabledQueries:i,theme:l}));return Y.useEffect(()=>{c.setClient(t)},[t,c]),Y.useEffect(()=>{c.setOnClose(e.onClose??(()=>{}))},[e.onClose,c]),Y.useEffect(()=>{c.setErrorTypes(n||[])},[n,c]),Y.useEffect(()=>{c.setTheme(l)},[l,c]),Y.useEffect(()=>(s.current&&c.mount(s.current),()=>{c.unmount()}),[c]),o.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:s})}var Qs=process.env.NODE_ENV!=="development"?function(){return null}:hl;process.env.NODE_ENV;const rr=V.atom(""),ml=()=>{C.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),C.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"})},El=()=>{const{data:e}=ae(),{data:t}=ge(),{data:s}=xe(),n=j(),r=O(),a=f.useMemo(()=>(s==null?void 0:s.fallbackLang)||"en",[s==null?void 0:s.fallbackLang]),i=f.useRef(new Map);return x.useMutation({mutationFn:async({block:l})=>{const c=l._id,d=(t==null?void 0:t.lang)||a,h=`${c}:${d}`;if(i.current.has(h))return i.current.get(h);const u=r(n,{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(h,u),u.finally(()=>{i.current.delete(h)}),u}})},ar=()=>{const[,e]=he();return f.useCallback((t,s)=>{const r=new URLSearchParams(window.location.search).get("lang"),a=new URLSearchParams({page:t});r&&a.set("lang",r),window.history.pushState({},"",`?${a.toString()}`),e(a),window.dispatchEvent(new PopStateEvent("popstate")),s==null||s()},[e])},ir=()=>{const e=ar();return f.useCallback(({pageId:t})=>{e(t)},[e])},or=()=>{const e=O(),t=j(),s=x.useQueryClient();return x.useQuery({queryKey:[y.GET_WEBSITE_DATA],staleTime:300*1e3,queryFn:async()=>{const n=await e(t,{action:y.GET_WEBSITE_DATA});return s.setQueryData([y.GET_WEBSITE_DRAFT_SETTINGS],n.websiteSettings),s.setQueryData([y.GET_WEBSITE_PAGES],n.websitePages),s.setQueryData([y.GET_PAGE_TYPES],n.pageTypes),s.setQueryData([y.UI_LIBRARIES],n.libraries),s.setQueryData([y.GET_COLLECTIONS],n.collections),n}})};function pl(e){const t={};for(const s of e)t[s.id]={name:s.name,isPartial:p.isEmpty(s.slug),partialBlocks:s.partialBlocks?s.partialBlocks.split("|").filter(Boolean):[],links:s.links?s.links.split("|").filter(Boolean):[],designTokens:s.designTokens??{}};return t}const lr=()=>{const{data:e}=Ce();return{data:f.useMemo(()=>pl(e??[]),[e])}},yl=f.lazy(()=>Promise.resolve().then(()=>require("./page-lock-sMf1iA9z.cjs"))),Al=f.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-dialog-DW2TmmL1.cjs"))),Tl=f.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-D1DIZyiG.cjs"))),Sl=f.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-rk39Z0EK.cjs"))),Pl=f.lazy(()=>Promise.resolve().then(()=>require("./web-preview-C1Hj1GDt.cjs")));ml();Pr.loadWebBlocks();C.registerChaiTopBar(Ya);xi();C.registerChaiMediaManager(Tl);C.registerChaiSaveToLibrary(Sl);const xl={role:"admin",permissions:null},zs=e=>{const{isLoading:t}=bs();return t?o.jsx(Je,{className:"fixed inset-0 bg-white",children:o.jsx(P.Loader,{className:"h-6 w-6 animate-spin text-primary"})}):o.jsx(_l,{...e})},_l=e=>{const{data:t,isFetching:s,isError:n}=or();return!t||s?o.jsx(Je,{className:"fixed inset-0 bg-white",children:o.jsx(P.Loader,{className:"h-6 w-6 animate-spin text-primary"})}):n?o.jsxs(Je,{className:"fixed inset-0 bg-white",children:[o.jsx("p",{children:"Failed to load website data"}),o.jsx(C.Button,{onClick:()=>window.location.reload(),children:"Retry"})]}):o.jsx(wl,{...e})},wl=({...e})=>{var Dt;const{data:t}=or(),{data:s}=lr(),{libraries:n,collections:r,pageTypes:a,websiteSettings:i}=t,l=f.useMemo(()=>(i==null?void 0:i.fallbackLang)||"en",[i]),{data:c,isFetching:d}=bs(),h=c||xl,[u]=he(),E=u.get("page"),{data:m}=ae(),{data:A,isFetching:w}=fn(),{blocks:N}=ei(((Dt=A==null?void 0:A.draftPage)==null?void 0:Dt.blocks)??[]),{pageStatus:T}=ce(),S=Xa(),{onSave:I}=li(),{mutateAsync:z}=El(),{getPartialBlocks:Q,getPartialBlockBlocks:H}=ci(),{mutateAsync:ie}=Dr(),{mutateAsync:D}=ti(),M=ir(),[v,L]=f.useState(!1),J=f.useRef([]),$=f.useMemo(()=>p.get(i,"theme",{})||{},[i]),ne=f.useMemo(()=>p.get(i,"languages",[])||[],[i]),me=f.useMemo(()=>p.get(i,"designTokens",{})||{},[i]),ue=T===ee.EDITING,we=T===ee.CHECKING,Ee=w||we;f.useEffect(()=>{J.current=N},[N]);const[tt]=V.useAtom(rr);f.useEffect(()=>{const q=()=>{document.hidden?L(!0):L(!1)};return window.addEventListener("visibilitychange",q),()=>window.removeEventListener("visibilitychange",q)},[]);const ns=f.useMemo(()=>{const q={};return h&&(q.permissions=p.get(h,"permissions",null),q.role=p.get(h,"role","user")),q.pageExternalData=(A==null?void 0:A.builderPageData)??{},q},[h,A]),kt=f.useMemo(()=>n==null?void 0:n.some(q=>q.isSiteLibrary),[n]),rs=f.useCallback(async(q,se)=>await ie({pageType:q,query:se}),[ie]);return o.jsxs(o.Fragment,{children:[w&&o.jsx(Je,{className:d?"fixed inset-0 bg-white":"bg-white/75",children:o.jsx(P.Loader,{className:`animate-spin text-primary ${d?"h-6 w-6":"h-5 w-5"}`})}),tt&&o.jsx(f.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(P.Loader,{className:"h-6 w-6 animate-spin text-primary"})}),children:o.jsx(Pl,{})}),o.jsx(g.ChaiBuilderEditor,{siteWideUsage:s??{},flags:e.flags?{...e.flags,librarySite:kt}:{librarySite:kt},gotoPage:M,collections:r??[],getBlockAsyncProps:z,themePresets:e.themePresets??[],pageId:m==null?void 0:m.id,loading:Ee,fallbackLang:l,languages:ne,brandingOptions:$,designTokens:me,translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!v&&ue&&(e.autoSave??!0),autoSaveActionsCount:e.autoSaveActionsCount??10,onError:e.onError||console.error,getPartialBlockBlocks:H,getPartialBlocks:Q,blocks:w?[]:N,theme:p.cloneDeep($),pageTypes:a,searchPageTypeItems:rs,askAiCallBack:S,onSave:async({blocks:q,needTranslations:se,partialIds:Ne,linkPageIds:Gt,designTokens:dr})=>{if(!E)return!0;J.current=q;const js=[...q];return await I({page:E,blocks:js,needTranslations:se,partialIds:Ne,linkPageIds:Gt,designTokens:dr}),J.current=js,!0},onSaveWebsiteData:async({type:q,data:se})=>(q==="THEME"?await D({settings:{theme:se}}):q==="DESIGN_TOKENS"&&await D({settings:{designTokens:se}}),!0),...ns,children:o.jsx(yl,{isFetchingPageData:w})}),o.jsx("div",{children:o.jsx(Al,{})})]})},bl=new x.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),vl=e=>{const[,t]=Ct(),[s,n]=f.useState(!1);return f.useEffect(()=>(t(p.pick(e,["apiUrl","usersApiUrl","assetsApiUrl","getPreviewUrl","getLiveUrl","topLeftCorner","onLogout","getAccessToken","websocket","realtimeAdapter","getLoggedInUser","flags","currentUser"])),setTimeout(()=>{n(!0)},200),()=>{n(!1),t({})}),[e,t]),s?p.get(e,"hasReactQueryProvider",!1)===!0?o.jsxs(o.Fragment,{children:[o.jsx(zs,{...e}),o.jsx(Qs,{})]}):o.jsxs(x.QueryClientProvider,{client:bl,children:[o.jsx(zs,{...e}),o.jsx(Qs,{})]}):o.jsx("div",{})},Cl=Y.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-BHPOfftZ.cjs")));function cr({data:e,onSelect:t,dataType:s="value",disabled:n=!1}){const[r,a]=Y.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(C.Button,{size:"sm",variant:"outline",className:"h-6 w-6 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,disabled:n,children:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:o.jsx("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"#000000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),o.jsx(g.TooltipContent,{children:"Add field"})]}),r&&o.jsx(Y.Suspense,{children:o.jsx(Cl,{data:e,onSelect:t,dataType:s,open:r,setOpen:a})})]})}const Il=()=>{const{data:e}=ae(),{data:t}=ge(),s=j(),n=O(),r=Zt(),a=Yt();return x.useQuery({queryKey:[y.GET_BUILDER_PAGE_DATA,t==null?void 0:t.id,a],staleTime:1/0,gcTime:0,queryFn:async()=>n(s,{action:y.GET_BUILDER_PAGE_DATA,data:{pageType:e==null?void 0:e.pageType,lang:(t==null?void 0:t.lang)||r,dynamic:e==null?void 0:e.dynamic,pageProps:{slug:(t==null?void 0:t.slug)+a,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:r,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id,metadata:e.metadata||{}}}}),enabled:!!(e!=null&&e.pageType)&&!!t.id})},Nl=()=>{const{savePageAsync:e}=g.useSavePage(),t=x.useQueryClient(),{isLocked:s}=ce();return f.useCallback(async()=>{s||await e(),t.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]})},[e,t,s])},Ll=()=>{const e=x.useQueryClient();return f.useCallback(()=>{e.clear()},[e])},jl=()=>{const e=j(),t=O(),{data:s}=ge(),n=x.useQueryClient();return x.useMutation({mutationFn:async r=>{if(!(s!=null&&s.id))throw new Error("No active page found");return await t(`${e}`,{action:y.UPDATE_PAGE_METADATA,data:{id:s.id,metadata:r}})},onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]}),n.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]})},onError:()=>{console.error("Failed to update metadata")}})},kl=f.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-D1DIZyiG.cjs"))),Dl=({assetId:e,assetUrl:t,onChange:s,className:n="",placeholder:r="Select an image",disabled:a=!1})=>{const{t:i}=oe.useTranslation(),[l,c]=f.useState(!1),d=()=>{a||c(!0)},h=()=>{c(!1)},u=A=>{const w=Array.isArray(A)?A[0]:A;w!=null&&w.url&&s(p.pick(w,["url","id"])),c(!1)},E=()=>{s({url:"",id:""})},m=(t==null?void 0:t.startsWith("{{"))&&(t==null?void 0:t.endsWith("}}"));return o.jsxs("div",{className:`w-full ${n}`,children:[t?o.jsxs("div",{className:"relative overflow-hidden rounded-md border",children:[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(C.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(P.X,{className:"h-4 w-4"}):o.jsx(P.Trash2,{className:"h-4 w-4"})}),!m&&o.jsx(C.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(P.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(P.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(C.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:h,children:o.jsx(P.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"h-full flex-1 p-4",children:o.jsx(f.Suspense,{children:o.jsx(kl,{close:h,onSelect:u,mode:"image",assetId:e})})})]})})]})},Gl=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Ts=e=>{if(!e.trim())return{isValid:!1,parsed:null,placeholders:[],error:{message:"JSON is empty"}};try{return{isValid:!0,parsed:JSON.parse(e),error:null,placeholders:[]}}catch{}const t=/{{([^{}]+)}}/g,s=[];let n=e,r;for(;(r=t.exec(e))!==null;){const a=r[0],i=r.index,l=`"__placeholder_${s.length}__"`;s.push({original:a,replaced:l,position:i}),n=n.replace(a,l)}try{return{isValid:!0,parsed:JSON.parse(n),error:null,placeholders:s}}catch(a){const i=a,l=i.message.match(/position (\d+)/),c=l?parseInt(l[1]):void 0;let d,h;if(c!==void 0){const u=n.substring(0,c).split(`
2
+ `);d=u.length,h=u[u.length-1].length+1}return{isValid:!1,parsed:null,placeholders:s,error:{message:i.message,line:d,column:h,position:c}}}},Ol=(e,t)=>{let n=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const i=`"__placeholder_${a}__"`,l=new RegExp(Gl(i),"g");n=n.replace(l,r)}),n},Rl=(e,t)=>{if(!e)return"";let s=JSON.stringify(e,null,2);const n=/{{([^{}]+)}}/g;let r;for(;(r=n.exec(s))!==null;){const a=r[1],i=p.get(t,a,null);s=s.replace(r[0],i)}return s},Ml=f.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-DlSg_ICN.cjs"))),Ul=({value:e,onChange:t,disabled:s=!1,readOnly:n=!1,placeholder:r="Enter JSON",rows:a=6,id:i="json-input",pageData:l={},handleFieldInsert:c,hasJsonLdForSelectedLang:d,copyJsonLDFromDefaultPage:h})=>{const[u,E]=f.useState("edit"),[m,A]=f.useState(null),[w,N]=f.useState(""),T=f.useRef(null),[S]=Ct(),I=i==="jsonLD"&&p.get(S,"flags.sharedJsonLD",!1),z=i==="jsonLD"&&!d&&!!h;f.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const Q=M=>{if(n)return;const v=M.target.value;t(v)},H=M=>{if(M.key==="Tab"){M.preventDefault();const v=M.currentTarget,L=v.selectionStart,J=v.selectionEnd;if(L!==J){const ne=e.substring(L,J).split(`
3
+ `);if(M.shiftKey){const ue=ne.map(Ee=>Ee.startsWith(" ")?Ee.substring(2):Ee).join(`
4
+ `),we=e.substring(0,L)+ue+e.substring(J);t(we),setTimeout(()=>{v.selectionStart=L,v.selectionEnd=L+ue.length},0)}else{const ue=ne.map(Ee=>` ${Ee}`).join(`
5
+ `),we=e.substring(0,L)+ue+e.substring(J);t(we),setTimeout(()=>{v.selectionStart=L,v.selectionEnd=L+ue.length},0)}}else{const $=e.substring(0,L)+" "+e.substring(J);t($),setTimeout(()=>{v.selectionStart=v.selectionEnd=L+2},0)}}};f.useEffect(()=>{const M=Ts(e);M.isValid?f.startTransition(()=>{if(A(null),M.parsed){const v=Rl(M.parsed,l);N(v)}else N("")}):f.startTransition(()=>{A(M.error),N("")})},[e,l]);const ie=()=>{const M=Ts(e);if(M.isValid&&M.parsed){const v=Ol(M.parsed,M.placeholders);t(v)}},D=()=>{m!=null&&m.position&&T.current&&(T.current.focus(),T.current.setSelectionRange(m.position,m.position+1))};return o.jsx(xr.ErrorBoundary,{fallback:o.jsx("div",{children:"Some error"}),children:o.jsx("div",{className:"space-y-2",children:o.jsxs(g.Tabs,{value:u,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(P.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||z,children:[o.jsx(P.Eye,{className:"h-4 w-4"}),o.jsx("span",{children:"Preview"})]}),I&&o.jsxs(g.TabsTrigger,{value:"shared",className:"flex items-center gap-1",disabled:!e.trim()||m!==null,children:[o.jsx(P.Share2,{className:"h-4 w-4"}),o.jsx("span",{children:"Shared"})]})]}),z?null:u==="edit"&&!n&&o.jsx("div",{className:"flex items-center gap-2",children:o.jsx(cr,{dataType:"value",data:l??{},onSelect:M=>c&&c(M,i)})})]}),o.jsxs(g.TabsContent,{value:"edit",className:"relative mt-0",children:[!z&&u==="edit"&&o.jsx(Xe,{content:"Format JSON",side:"right",showTooltip:!s&&!m,children:o.jsx(C.Button,{type:"button",variant:"outline",size:"icon",onClick:ie,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||s||m!==null,children:o.jsx(P.FileCode2,{})})}),z?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(C.Button,{type:"button",variant:"default",size:"sm",onClick:h,children:[o.jsx(P.Plus,{}),"Copy & Edit from default language"]})]})}):o.jsx(g.Textarea,{ref:T,id:i,name:i,className:`rounded-md border border-input text-xs ${m?"border-red-500":""}`,onChange:Q,onKeyDown:H,value:e,placeholder:r,rows:a,disabled:s,readOnly:n}),m&&o.jsxs(C.Alert,{variant:"destructive",className:"mt-2",children:[o.jsx(P.AlertTriangle,{className:"h-4 w-4"}),o.jsxs(C.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(C.Button,{type:"button",variant:"link",size:"sm",className:"mt-1 h-auto self-start p-0 text-sm",onClick:D,children:"Show position"})]})]})]}),o.jsxs(g.TabsContent,{value:"preview",className:"mt-0",children:[o.jsx(g.Textarea,{rows:a,value:w,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."})]}),I&&o.jsx(g.TabsContent,{value:"shared",className:"mt-0",children:o.jsx(f.Suspense,{children:o.jsx(Ml,{})})})]})})})},Bl=e=>{const t=j(),s=O();return x.useQuery({queryKey:[y.GET_CHAI_USER,e],queryFn:async()=>{const n=await s(t,{action:y.GET_CHAI_USER,data:{userId:e}}),r=(n==null?void 0:n.data)||{};return{...r,name:r.name||r.email}},enabled:!p.isEmpty(e),staleTime:"static"})};class Fl{constructor(t){is(this,"channel");this.channel=t}get topic(){return this.channel.topic}getState(){const t=this.channel.state;return{closed:"CLOSED",errored:"ERROR",joined:"JOINED",joining:"JOINING",leaving:"LEAVING"}[t]||"CLOSED"}async subscribe(t){this.channel.subscribe(s=>{t(s)})}unsubscribe(){this.channel.unsubscribe()}onBroadcast(t,s){this.channel.on("broadcast",{event:t},s)}onPresence(t,s){this.channel.on("presence",{event:t},s)}async send(t,s){await this.channel.send({event:t,payload:s,type:"broadcast"})}async track(t){await this.channel.track(t)}untrack(){this.channel.untrack()}presenceState(){return this.channel.presenceState()}}class ur{constructor(t){is(this,"client");this.client=t}channel(t,s){const n=this.client.channel(t,s);return new Fl(n)}}function Hl(e){return new ur(e)}if(typeof window>"u")throw new Error("@chaibuilder/pages is not available on the server");exports.$TRACK=vs;exports.ACTIONS=y;exports.BlurContainer=Je;exports.ChaiWebsiteBuilder=vl;exports.Dynamic=So;exports.EVENT=W;exports.For=Vi;exports.ImagePicker=Dl;exports.Index=Qi;exports.LANGUAGES=nt;exports.LanguageSwitcher=ln;exports.Match=Wi;exports.NestedPathSelector=cr;exports.PAGES_PERMISSIONS=le;exports.PAGE_STATUS=ee;exports.PageActionsDropdown=nn;exports.PermissionChecker=Ut;exports.Portal=Ao;exports.Show=zi;exports.SmartJsonInput=Ul;exports.SupabaseRealtimeAdapter=ur;exports.Switch=$i;exports.Tooltip=Xe;exports.addEventListener=Gn;exports.addNewLangAtom=ut;exports.batch=Ci;exports.className=Dn;exports.clearDelegatedEvents=lo;exports.convertRemToPixels=cl;exports.createComponent=Ns;exports.createComputed=Sn;exports.createContext=ki;exports.createEffect=Cs;exports.createMemo=Z;exports.createRealtimeAdapter=Hl;exports.createRenderEffect=Se;exports.createRoot=Te;exports.createSignal=K;exports.createUniqueId=Ki;exports.delegateEvents=kn;exports.deleteNestedDataByPath=ot;exports.displayValue=nl;exports.getMutationStatusColor=tl;exports.getPreferredColorScheme=ul;exports.getQueryStatusColor=el;exports.getQueryStatusColorByLabel=sl;exports.getQueryStatusLabel=Zo;exports.getSidedProp=Xo;exports.insert=Jt;exports.memo=ao;exports.mergeProps=Ls;exports.mutationSortFns=ll;exports.navigateToPage=on;exports.on=Ii;exports.onCleanup=Ye;exports.onMount=Pn;exports.parseJSONWithPlaceholders=Ts;exports.previewUrlAtom=rr;exports.serialize=er;exports.setAttribute=Wt;exports.sortFns=il;exports.splitProps=In;exports.spread=On;exports.stringify=Yo;exports.template=oo;exports.throwConfetti=rt;exports.untrack=X;exports.updateNestedDataByPath=it;exports.use=Rn;exports.useAddGlobalSchema=si;exports.useApiUrl=j;exports.useApplySchemaToAllPages=ii;exports.useBuilderFetch=Cr;exports.useBuilderPageData=Il;exports.useChaiAuth=Xt;exports.useChaiUserInfo=Bl;exports.useChaibuilderRealtime=oa;exports.useChangePage=ar;exports.useChangeSlug=Ia;exports.useCheckUserAccess=bs;exports.useClearAll=Ll;exports.useContext=Di;exports.useCreatePage=xa;exports.useCurrentActivePage=ge;exports.useCurrentPageOwner=an;exports.useDeleteGlobalSchema=ri;exports.useDeletePage=wa;exports.useDynamicPageSelector=Xs;exports.useFallbackLang=Zt;exports.useFetch=O;exports.useGotoPage=ir;exports.useIsLanguagePageCreated=dn;exports.useLanguagePages=It;exports.useMarkAsTemplate=va;exports.usePageAllData=fn;exports.usePageEditInfo=tn;exports.usePageLockMeta=xs;exports.usePageLockStatus=ce;exports.usePageToUser=Ps;exports.usePageType=sn;exports.usePageTypes=_e;exports.usePagesProp=re;exports.usePagesProps=Ct;exports.usePrimaryPage=ae;exports.useRealtimeAdapter=Ss;exports.useReloadPage=Nl;exports.useRemoveSchemaFromAllPages=oi;exports.useSearchParams=he;exports.useSendRealtimeEvent=ws;exports.useSiteWideUsage=lr;exports.useTogglePageGlobalSchema=ai;exports.useTransition=ji;exports.useUnmarkAsTemplate=Ca;exports.useUnpublishPage=ba;exports.useUpdateActivePageMetadata=jl;exports.useUpdateGlobalSchema=ni;exports.useUpdatePage=_a;exports.useUserId=Lt;exports.useWebsiteLanguagePages=en;exports.useWebsitePrimaryPages=Ce;exports.useWebsiteSetting=xe;
@@ -277,7 +277,7 @@ const Ci = ({ query: e, uuid: t }) => {
277
277
  const [e] = Ce(), t = e.get("lang") ?? "", n = e.get("page"), { data: s, isFetching: r } = Gi(t), { data: a } = dt();
278
278
  return { data: j(
279
279
  () => ce([...jn(s), ...a], { lang: t, id: n }) || {},
280
- [s, t, n]
280
+ [s, a, t, n]
281
281
  ), isFetching: r };
282
282
  };
283
283
  we({});
@@ -758,7 +758,7 @@ const gt = 10, ao = 1e3, io = 2, oo = 16e3, Js = () => {
758
758
  }), () => {
759
759
  r && n && r.untrack();
760
760
  }), [r, n, t]);
761
- }, fo = V(() => import("./add-new-page-JSrqASzg.js")), ho = V(() => import("./delete-page-DNz6-CLI.js")), go = V(() => import("./duplicate-page-DYxGlrmd.js")), mo = V(() => import("./mark-as-template-BEz6ecRQ.js")), Eo = V(() => import("./unmark-as-template-DEs6DnT4.js")), po = V(() => import("./unpublish-page-D-5iWXIB.js")), yo = () => {
761
+ }, fo = V(() => import("./add-new-page-CmkKdxHb.js")), ho = V(() => import("./delete-page-D8PgbaSa.js")), go = V(() => import("./duplicate-page-qJiGrwSD.js")), mo = V(() => import("./mark-as-template-DvKWMavv.js")), Eo = V(() => import("./unmark-as-template-B9EobxLL.js")), po = V(() => import("./unpublish-page-Cyx4HU4j.js")), yo = () => {
762
762
  const [e, t] = R(null), [n, s] = R(null), [r, a] = R(null), [i, l] = R(null), [c, d] = R(null), [f, u] = R(null), { data: g, isFetching: h } = Le(), { selectedLang: p, fallbackLang: S } = Pe(), { data: b } = An(), y = b == null ? void 0 : b.find((M) => M.lang === p), { isLocked: A } = be(), w = !(g != null && g.slug), $ = Zn(nn);
763
763
  if (!g) return null;
764
764
  const q = (M) => {
@@ -1023,7 +1023,7 @@ function To(e, t, n = !1) {
1023
1023
  const s = e.toString() ? `?${e.toString()}` : "/";
1024
1024
  n ? window.history.replaceState(null, "", s) : window.history.pushState({}, "", s), t(e), window.dispatchEvent(new PopStateEvent("popstate"));
1025
1025
  }
1026
- const So = V(() => import("./add-new-language-page-Bt-EHTdP.js")), _o = () => {
1026
+ const So = V(() => import("./add-new-language-page-CSXgqNU5.js")), _o = () => {
1027
1027
  const e = he("topLeftCorner", null);
1028
1028
  return e ? /* @__PURE__ */ o("div", { className: "max-h-9 w-full overflow-hidden pr-2", children: pi.createElement(e, {}) }) : null;
1029
1029
  }, Po = ({
@@ -1155,7 +1155,7 @@ function bo() {
1155
1155
  /* @__PURE__ */ o($t, { className: "h-8 w-8 rounded-full" })
1156
1156
  ] }, t)) });
1157
1157
  }
1158
- const No = Y.lazy(() => import("./page-revisions-content-CAgq7kLY.js"));
1158
+ const No = Y.lazy(() => import("./page-revisions-content-BRG1nseD.js"));
1159
1159
  function Io() {
1160
1160
  const [e, t] = Y.useState(!1);
1161
1161
  return /* @__PURE__ */ o(Os, { children: /* @__PURE__ */ m(hn, { delayDuration: 0, children: [
@@ -1371,7 +1371,7 @@ const Ln = ({
1371
1371
  x.error("Failed to change slug");
1372
1372
  }
1373
1373
  });
1374
- }, Co = V(() => import("./publish-pages-content-Ct7VDbNE.js"));
1374
+ }, Co = V(() => import("./publish-pages-content-CLOtvebk.js"));
1375
1375
  function Lo({
1376
1376
  showModal: e = !1,
1377
1377
  onClose: t = () => console.log("Cancelled")
@@ -1458,11 +1458,11 @@ function Ft({
1458
1458
  /* @__PURE__ */ o(mn, { side: n, sideOffset: 10, children: /* @__PURE__ */ o("p", { children: t }) })
1459
1459
  ] }) }) : e;
1460
1460
  }
1461
- const Uo = V(() => import("./unpublish-page-D-5iWXIB.js")), Bo = V(
1461
+ const Uo = V(() => import("./unpublish-page-Cyx4HU4j.js")), Bo = V(
1462
1462
  () => import("./translation-warning-modal-DEW8JWRh.js")
1463
1463
  ), Mo = V(
1464
1464
  () => import("./unpublished-partials-modal-Do2HSNYq.js")
1465
- ), Fo = V(() => import("./json-diff-viewer-BzXIZ79o.js")), Ho = () => {
1465
+ ), Fo = V(() => import("./json-diff-viewer-kPE5IxCR.js")), Ho = () => {
1466
1466
  const { t: e } = ge(), { selectedLang: t, fallbackLang: n } = Pe(), s = he("getPreviewUrl", async (g) => g), [r, a] = R(""), { data: i } = Ee(), { data: l } = An(), { data: c } = Ke(), d = j(
1467
1467
  () => {
1468
1468
  var g;
@@ -1719,7 +1719,7 @@ function $o() {
1719
1719
  /* @__PURE__ */ o(Ln, { permission: Se.PUBLISH_PAGE, children: /* @__PURE__ */ o(qo, {}) })
1720
1720
  ] });
1721
1721
  }
1722
- const Qo = V(() => import("./page-manager-new-ABq5ZgFr.js")), Wo = ({ children: e }) => {
1722
+ const Qo = V(() => import("./page-manager-new-TPjfGU8A.js")), Wo = ({ children: e }) => {
1723
1723
  const { t } = ge(), [n] = Ce(), s = n.get("page"), { data: r, isFetching: a } = Ee(), { data: i, isFetching: l } = dt(), [c, d] = R(!1), [f, u] = R(!0), { savePage: g } = Me(), h = !!s && !de(r), { isLocked: p } = be();
1724
1724
  Z(() => {
1725
1725
  !l && i && u(!1);
@@ -1772,7 +1772,7 @@ const Qo = V(() => import("./page-manager-new-ABq5ZgFr.js")), Wo = ({ children:
1772
1772
  }
1773
1773
  ) })
1774
1774
  ] });
1775
- }, zo = V(() => import("./dynamic-page-selector-Seiq-wJc.js")), jo = () => {
1775
+ }, zo = V(() => import("./dynamic-page-selector-C59-N_34.js")), jo = () => {
1776
1776
  const { dynamicPage: e, allLangPages: t, isFetching: n } = Li(), s = t.length > 0;
1777
1777
  return n ? null : /* @__PURE__ */ m("div", { className: "relative", children: [
1778
1778
  !e && /* @__PURE__ */ o(Ao, { hasDynamicPage: s }),
@@ -2050,7 +2050,7 @@ const Qo = V(() => import("./page-manager-new-ABq5ZgFr.js")), Wo = ({ children:
2050
2050
  [n, t]
2051
2051
  )
2052
2052
  };
2053
- }, al = V(() => import("./ai-panel-content-BcU74IAG.js")), sr = "chai-chat-panel", il = ({ className: e = "h-full w-full" }) => /* @__PURE__ */ m("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", version: "1.1", className: e, children: [
2053
+ }, al = V(() => import("./ai-panel-content-CEjBTXKP.js")), sr = "chai-chat-panel", il = ({ className: e = "h-full w-full" }) => /* @__PURE__ */ m("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", version: "1.1", className: e, children: [
2054
2054
  /* @__PURE__ */ o("title", { children: "ai" }),
2055
2055
  /* @__PURE__ */ o("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ o("g", { id: "icon", fill: "currentColor", transform: "translate(64.000000, 64.000000)", children: /* @__PURE__ */ o(
2056
2056
  "path",
@@ -2065,7 +2065,7 @@ const Qo = V(() => import("./page-manager-new-ABq5ZgFr.js")), Wo = ({ children:
2065
2065
  button: ol,
2066
2066
  panel: al,
2067
2067
  position: "top"
2068
- }, cl = V(() => import("./lang-panel-DPhpM-pr.js")), ul = ({ isActive: e, show: t }) => {
2068
+ }, cl = V(() => import("./lang-panel-CjEa8M_P.js")), ul = ({ isActive: e, show: t }) => {
2069
2069
  const { data: n } = He();
2070
2070
  return !Jn(n, "languages") || !J(n, "languages", []).length ? null : /* @__PURE__ */ o(U, { size: "sm", onClick: t, variant: e ? "default" : "ghost", children: /* @__PURE__ */ o(ui, { className: "h-4 w-4" }) });
2071
2071
  }, rr = "lang", dl = {
@@ -2076,7 +2076,7 @@ const Qo = V(() => import("./page-manager-new-ABq5ZgFr.js")), Wo = ({ children:
2076
2076
  button: ul,
2077
2077
  view: "modal",
2078
2078
  width: 400
2079
- }, fl = V(() => import("./seo-panel-DGnUvVO2.js")), ar = "seo", hl = ({ isActive: e, show: t }) => {
2079
+ }, fl = V(() => import("./seo-panel-DsTInOQg.js")), ar = "seo", hl = ({ isActive: e, show: t }) => {
2080
2080
  const { data: n } = Ee(), s = Oi(n == null ? void 0 : n.pageType);
2081
2081
  return !Jn(s, "hasSlug") || !s.hasSlug ? null : /* @__PURE__ */ o(U, { size: "icon", className: "my-1 p-0", onClick: t, variant: e ? "default" : "ghost", children: /* @__PURE__ */ m(
2082
2082
  "svg",
@@ -2105,7 +2105,7 @@ const Qo = V(() => import("./page-manager-new-ABq5ZgFr.js")), Wo = ({ children:
2105
2105
  width: 600,
2106
2106
  view: "modal"
2107
2107
  }, ml = V(
2108
- () => import("./change-password-modal-kdADAvi2.js").then((e) => ({ default: e.ChangePasswordModal }))
2108
+ () => import("./change-password-modal-BjUNbNkW.js").then((e) => ({ default: e.ChangePasswordModal }))
2109
2109
  ), ir = "user-info", El = () => {
2110
2110
  const { t: e } = ge(), { user: t, logout: n } = es(), s = he("onLogout", En), [r, a] = R(!1);
2111
2111
  return t ? /* @__PURE__ */ m(pa, { children: [
@@ -3992,7 +3992,7 @@ var pd = (e, t = !1) => {
3992
3992
  const t = Pr(() => {
3993
3993
  const n = this, [s] = T(this, je), [r] = T(this, Ye), [a] = T(this, Je), [i] = T(this, Ze), [l] = T(this, Lt), [c] = T(this, We), [d] = T(this, et);
3994
3994
  let f;
3995
- return T(this, Xe) ? f = T(this, Xe) : (f = Sr(() => import("./WDYDFRGG-DjIZGWcU.js")), I(this, Xe, f)), Kr(T(this, Ct), T(this, ze)), Ar(f, Tr({
3995
+ return T(this, Xe) ? f = T(this, Xe) : (f = Sr(() => import("./WDYDFRGG-Joc-MsHY.js")), I(this, Xe, f)), Kr(T(this, Ct), T(this, ze)), Ar(f, Tr({
3996
3996
  get queryFlavor() {
3997
3997
  return T(n, It);
3998
3998
  },
@@ -4099,7 +4099,7 @@ var pd = (e, t = !1) => {
4099
4099
  const t = Pr(() => {
4100
4100
  const n = this, [s] = T(this, st), [r] = T(this, rt), [a] = T(this, at), [i] = T(this, it), [l] = T(this, Rt), [c] = T(this, tt), [d] = T(this, ot), [f] = T(this, ct);
4101
4101
  let u;
4102
- return T(this, lt) ? u = T(this, lt) : (u = Sr(() => import("./2SSKDMRQ-B9Y7DUaU.js")), I(this, lt, u)), Kr(T(this, Ot), T(this, nt)), Ar(u, Tr({
4102
+ return T(this, lt) ? u = T(this, lt) : (u = Sr(() => import("./2SSKDMRQ-BUqDyvkj.js")), I(this, lt, u)), Kr(T(this, Ot), T(this, nt)), Ar(u, Tr({
4103
4103
  get queryFlavor() {
4104
4104
  return T(n, kt);
4105
4105
  },
@@ -4318,7 +4318,7 @@ function Yc(e) {
4318
4318
  const Jc = () => {
4319
4319
  const { data: e } = dt();
4320
4320
  return { data: j(() => Yc(e ?? []), [e]) };
4321
- }, Zc = V(() => import("./page-lock-COOgRF1e.js")), Xc = V(() => import("./no-language-page-dialog-Di0PXuKT.js")), eu = V(() => import("./digital-asset-manager-BdNe83F3.js")), tu = V(() => import("./save-to-lib-CAzWtI64.js")), nu = V(() => import("./web-preview-DRp7Zk7f.js"));
4321
+ }, Zc = V(() => import("./page-lock-DN3eOz6T.js")), Xc = V(() => import("./no-language-page-dialog-CSYcONeC.js")), eu = V(() => import("./digital-asset-manager-BuIBKQrY.js")), tu = V(() => import("./save-to-lib-C4HuEFUH.js")), nu = V(() => import("./web-preview-DTp6O2zH.js"));
4322
4322
  Qc();
4323
4323
  _i();
4324
4324
  Yr(Jo);
@@ -4556,7 +4556,7 @@ const Pd = () => {
4556
4556
  console.error("Failed to update metadata");
4557
4557
  }
4558
4558
  });
4559
- }, cu = V(() => import("./digital-asset-manager-BdNe83F3.js")), Id = ({
4559
+ }, cu = V(() => import("./digital-asset-manager-BuIBKQrY.js")), Id = ({
4560
4560
  assetId: e,
4561
4561
  assetUrl: t,
4562
4562
  onChange: n,
@@ -4699,7 +4699,7 @@ const Pd = () => {
4699
4699
  n = n.replace(r[0], i);
4700
4700
  }
4701
4701
  return n;
4702
- }, hu = V(() => import("./shared-json-ld-CuMx_qAL.js")), vd = ({
4702
+ }, hu = V(() => import("./shared-json-ld-BCga2JTe.js")), vd = ({
4703
4703
  value: e,
4704
4704
  onChange: t,
4705
4705
  disabled: n = !1,
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("./index-P-2SvZA9.cjs"),L=require("./register-chai-top-bar-DyW9GPzV.cjs"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-d1_bmLx3.cjs"),H=require("@tanstack/react-query");function K(t,r){const o=O.useApiUrl(),n=O.useFetch(),d=p.startsWith(t.uid,"draft:")||p.startsWith(r.uid,"live:");return H.useQuery({queryKey:["revision-comparison",t.uid,r.uid],queryFn:async()=>{if(!t.uid||!r.uid)throw new Error("Both revision IDs are required for comparison");const l=h=>h==="draft"||h==="live"?h:"revision",s=h=>p.replace(h.uid,`${h.label}:`,"");return await n(o,{action:O.ACTIONS.GET_COMPARE_DATA,data:{versions:{version1:{type:l(t.label),id:s(t)},version2:{type:l(r.label),id:s(r)}}}})},enabled:!!t.uid&&!!r.uid,staleTime:d?0:1/0,refetchOnMount:d?"always":!1,gcTime:d?0:void 0})}const V=({version:t})=>{const r=t==null?void 0:t.item,{data:o}=O.useChaiUserInfo(r==null?void 0:r.currentEditor),n=t.label==="live",d=t.label==="draft";return e.jsxs("span",{className:`flex min-h-8 items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${n?"border-green-500/30":d?"border-amber-500/30":"border-purple-500/30"}`,children:[e.jsx("div",{className:"h-full items-center rounded px-1.5 py-0.5 font-medium capitalize"+(n?" bg-green-500 text-green-50":d?" bg-amber-500 text-amber-50":" bg-purple-500 text-purple-50"),children:t.label}),e.jsxs("div",{className:"py-1 text-xs font-light leading-none text-gray-800",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-light opacity-90",children:d?"Currently editing":"Published by"}),!d&&e.jsx("span",{className:"pl-1 font-medium",children:(o==null?void 0:o.name)||"Unknown"})]}),(r==null?void 0:r.createdAt)&&e.jsx("div",{className:"pt-0.5 text-[10px] leading-tight",children:z.formatDate(r.createdAt,"dd MMM yyyy, h:mm a")})]})]})},F=({version:t})=>e.jsx(V,{version:t});function U(t,r,o="data.json"){const n=JSON.stringify(t,null,2),d=JSON.stringify(r,null,2),l=n.split(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("./index-P-2SvZA9.cjs"),L=require("./register-chai-top-bar-DyW9GPzV.cjs"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-B3Ozovj5.cjs"),H=require("@tanstack/react-query");function K(t,r){const o=O.useApiUrl(),n=O.useFetch(),d=p.startsWith(t.uid,"draft:")||p.startsWith(r.uid,"live:");return H.useQuery({queryKey:["revision-comparison",t.uid,r.uid],queryFn:async()=>{if(!t.uid||!r.uid)throw new Error("Both revision IDs are required for comparison");const l=h=>h==="draft"||h==="live"?h:"revision",s=h=>p.replace(h.uid,`${h.label}:`,"");return await n(o,{action:O.ACTIONS.GET_COMPARE_DATA,data:{versions:{version1:{type:l(t.label),id:s(t)},version2:{type:l(r.label),id:s(r)}}}})},enabled:!!t.uid&&!!r.uid,staleTime:d?0:1/0,refetchOnMount:d?"always":!1,gcTime:d?0:void 0})}const V=({version:t})=>{const r=t==null?void 0:t.item,{data:o}=O.useChaiUserInfo(r==null?void 0:r.currentEditor),n=t.label==="live",d=t.label==="draft";return e.jsxs("span",{className:`flex min-h-8 items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${n?"border-green-500/30":d?"border-amber-500/30":"border-purple-500/30"}`,children:[e.jsx("div",{className:"h-full items-center rounded px-1.5 py-0.5 font-medium capitalize"+(n?" bg-green-500 text-green-50":d?" bg-amber-500 text-amber-50":" bg-purple-500 text-purple-50"),children:t.label}),e.jsxs("div",{className:"py-1 text-xs font-light leading-none text-gray-800",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-light opacity-90",children:d?"Currently editing":"Published by"}),!d&&e.jsx("span",{className:"pl-1 font-medium",children:(o==null?void 0:o.name)||"Unknown"})]}),(r==null?void 0:r.createdAt)&&e.jsx("div",{className:"pt-0.5 text-[10px] leading-tight",children:z.formatDate(r.createdAt,"dd MMM yyyy, h:mm a")})]})]})},F=({version:t})=>e.jsx(V,{version:t});function U(t,r,o="data.json"){const n=JSON.stringify(t,null,2),d=JSON.stringify(r,null,2),l=n.split(`
2
2
  `),s=d.split(`
3
3
  `);let u=`--- a/${o}
4
4
  `;u+=`+++ b/${o}
@@ -6,7 +6,7 @@ import { startsWith as T, replace as W, isString as X, trim as Y, isArray as Z,
6
6
  import { FileJson as B, Loader as ne, Check as F, Copy as H } from "lucide-react";
7
7
  import { useState as D, useMemo as I } from "react";
8
8
  import { parseDiff as se, Diff as ae, Hunk as le } from "react-diff-view";
9
- import { ap as ie, aq as oe, A as ce, an as de } from "./index-CHoZEbKv.js";
9
+ import { ap as ie, aq as oe, A as ce, an as de } from "./index-B6QztICX.js";
10
10
  import { useQuery as fe } from "@tanstack/react-query";
11
11
  function me(t, n) {
12
12
  const o = ie(), s = oe(), d = T(t.uid, "draft:") || T(n.uid, "live:");
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("./register-chai-top-bar-DyW9GPzV.cjs"),a=require("./index-P-2SvZA9.cjs"),n=require("./index-d1_bmLx3.cjs"),r=require("lodash-es"),j=require("lucide-react"),c=require("react"),I=require("react-i18next"),L=require("sonner"),k=require("jotai"),M=({page:s,onClose:p})=>{const{t:l}=I.useTranslation(),[o,P]=c.useState(s.slug||""),{mutate:y,isPending:f}=n.useChangeSlug(),{data:i}=n.usePageTypes(),d=r.find(i,{key:s==null?void 0:s.pageType}),E=h=>{if(h.preventDefault(),!(s!=null&&s.primaryPage)&&Object.keys(n.LANGUAGES).some(S=>o===`/${S}`||r.startsWith(o,`/${S}/`))){L.toast.error(l("Error"),{description:l("Slugs cannot start with a language code for primary page")});return}y({...s,slug:o},{onSuccess:p})},m=(s==null?void 0:s.lang)||"";return e.jsx(a.Dialog,{open:!!s,onOpenChange:p,children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:l("Change Slug")}),e.jsx(a.DialogDescription,{className:"text-xs",children:e.jsxs(N.Alert,{variant:"destructive",className:"mt-2",children:[e.jsx(j.AlertCircle,{className:"h-4 w-4"}),l("Changing the slug may have impact on your SEO. Please proceed with caution.")]})})]}),e.jsxs("form",{onSubmit:E,children:[e.jsxs("div",{className:"space-y-4 py-4 text-sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{children:[e.jsxs("span",{children:[l("Type"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(d==null?void 0:d.name)||(s==null?void 0:s.pageType)]})]}),e.jsxs("div",{children:[e.jsxs("span",{children:[l("Name"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",s.name]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(a.Label,{htmlFor:"slug",className:"text-right",children:[l("Slug")," ",e.jsxs("small",{className:"font-light text-gray-500",children:[l("Slug should start with")," /",m]})]}),e.jsx(N.Input,{id:"slug",value:o,onChange:h=>{const x=h.target.value;r.startsWith(x,`/${m}`)&&P(x)},className:"col-span-3",required:!0,pattern:"^/.*",title:l("Slug must start with /"),placeholder:l("Enter page slug")})]})]}),e.jsx(a.DialogFooter,{children:e.jsx(N.Button,{type:"submit",disabled:f||!r.startsWith(o,`/${m}`)||r.isEqual(s==null?void 0:s.slug,o),children:l(f?"Changing...":"Change Slug")})})]})]})})},T=c.lazy(()=>Promise.resolve().then(()=>require("./delete-page-BtG5kYkI.cjs"))),q=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-rlnt_4EX.cjs"))),_=()=>{const{t:s}=I.useTranslation(),p=k.useSetAtom(n.addNewLangAtom),{selectedLang:l,fallbackLang:o,setSelectedLang:P}=a.useLanguages(),{data:y,isFetching:f}=n.useLanguagePages(),{data:i}=n.usePrimaryPage(),{data:d}=n.usePageTypes(),E=c.useMemo(()=>{const t=d==null?void 0:d.find(g=>g.key===(i==null?void 0:i.pageType));return i!=null&&i.dynamic?t==null?void 0:t.dynamicSlug:""},[d,i==null?void 0:i.pageType,i==null?void 0:i.dynamic]),[m,h]=c.useState(null),[x,v]=c.useState(null),[S,A]=c.useState(null),{data:b}=n.useWebsiteSetting(),D=r.filter(r.get(b,"languages")||["en"],t=>!r.find(y,{lang:t})&&t!==r.get(b,"fallbackLang"));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ul",{className:"space-y-2",children:f?e.jsxs("div",{className:"w-full space-y-3 py-4",children:[e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"})]}):r.map(y,t=>{const g=t.lang,C=t.slug,w=!t.primaryPage,G=g===l;return e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:`flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${G?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>P(g),children:[e.jsxs("div",{className:"flex-1 gap-x-3",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-[13px] text-slate-800",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),r.get(n.LANGUAGES,w?o:g,g)]}),e.jsxs("div",{children:[C&&e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Slug: ",e.jsx("b",{className:"font-mono font-medium",children:E?`${C}/${E}`:C})]}),e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Name:",e.jsxs("b",{className:"font-medium",children:[" ",t.name," "]})]})]})]}),w?e.jsxs("div",{className:"flex items-center gap-x-1 text-[11px] text-orange-500",children:[e.jsx(j.StarIcon,{fill:"orange",className:"h-3 w-3"}),e.jsx("b",{children:" Primary"})]}):e.jsx("div",{className:"flex items-center gap-x-3",children:e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE,n.PAGES_PERMISSIONS.DELETE_PAGE,n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,onClick:u=>u.stopPropagation(),children:e.jsx(N.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(j.MoreHorizontal,{className:"h-4 w-4"})})}),e.jsxs(a.DropdownMenuContent,{align:"end",className:"z-[9999] text-sm",children:[e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE],children:e.jsxs(a.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),p({edit:!0,id:t.id,primaryPage:t.primaryPage})},children:[e.jsx(j.PencilIcon,{className:"size-3"}),s("Edit")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:(t==null?void 0:t.online)&&e.jsxs(a.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),v(t)},children:[e.jsx(j.Power,{className:"size-3"}),s("Unpublish")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.DELETE_PAGE],children:e.jsxs(a.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),h(t)},children:[e.jsx(j.TrashIcon,{className:"size-3"}),s("Delete")]})})]})]})})})]},t.id),e.jsx("div",{className:"h-1 w-full border-b"})]})})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.ADD_PAGE],children:e.jsx("div",{className:"flex w-full justify-center",children:e.jsx(N.Button,{variant:"default",size:"sm",disabled:r.isEmpty(D),onClick:()=>{p({primaryPage:i==null?void 0:i.id,edit:!1})},children:s("Add new language page")})})}),m&&e.jsx(c.Suspense,{children:e.jsx(T,{page:m,onClose:()=>h(null)})}),x&&e.jsx(c.Suspense,{children:e.jsx(q,{page:x,onClose:()=>v(null)})}),S&&e.jsx(c.Suspense,{children:e.jsx(M,{page:S,onClose:()=>A(null)})})]})};exports.default=_;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("./register-chai-top-bar-DyW9GPzV.cjs"),a=require("./index-P-2SvZA9.cjs"),n=require("./index-B3Ozovj5.cjs"),r=require("lodash-es"),j=require("lucide-react"),c=require("react"),I=require("react-i18next"),L=require("sonner"),k=require("jotai"),M=({page:s,onClose:p})=>{const{t:l}=I.useTranslation(),[o,P]=c.useState(s.slug||""),{mutate:y,isPending:f}=n.useChangeSlug(),{data:i}=n.usePageTypes(),d=r.find(i,{key:s==null?void 0:s.pageType}),E=h=>{if(h.preventDefault(),!(s!=null&&s.primaryPage)&&Object.keys(n.LANGUAGES).some(S=>o===`/${S}`||r.startsWith(o,`/${S}/`))){L.toast.error(l("Error"),{description:l("Slugs cannot start with a language code for primary page")});return}y({...s,slug:o},{onSuccess:p})},m=(s==null?void 0:s.lang)||"";return e.jsx(a.Dialog,{open:!!s,onOpenChange:p,children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:l("Change Slug")}),e.jsx(a.DialogDescription,{className:"text-xs",children:e.jsxs(N.Alert,{variant:"destructive",className:"mt-2",children:[e.jsx(j.AlertCircle,{className:"h-4 w-4"}),l("Changing the slug may have impact on your SEO. Please proceed with caution.")]})})]}),e.jsxs("form",{onSubmit:E,children:[e.jsxs("div",{className:"space-y-4 py-4 text-sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{children:[e.jsxs("span",{children:[l("Type"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(d==null?void 0:d.name)||(s==null?void 0:s.pageType)]})]}),e.jsxs("div",{children:[e.jsxs("span",{children:[l("Name"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",s.name]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(a.Label,{htmlFor:"slug",className:"text-right",children:[l("Slug")," ",e.jsxs("small",{className:"font-light text-gray-500",children:[l("Slug should start with")," /",m]})]}),e.jsx(N.Input,{id:"slug",value:o,onChange:h=>{const x=h.target.value;r.startsWith(x,`/${m}`)&&P(x)},className:"col-span-3",required:!0,pattern:"^/.*",title:l("Slug must start with /"),placeholder:l("Enter page slug")})]})]}),e.jsx(a.DialogFooter,{children:e.jsx(N.Button,{type:"submit",disabled:f||!r.startsWith(o,`/${m}`)||r.isEqual(s==null?void 0:s.slug,o),children:l(f?"Changing...":"Change Slug")})})]})]})})},T=c.lazy(()=>Promise.resolve().then(()=>require("./delete-page-Bz9yVuhF.cjs"))),q=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-2AJbqM5f.cjs"))),_=()=>{const{t:s}=I.useTranslation(),p=k.useSetAtom(n.addNewLangAtom),{selectedLang:l,fallbackLang:o,setSelectedLang:P}=a.useLanguages(),{data:y,isFetching:f}=n.useLanguagePages(),{data:i}=n.usePrimaryPage(),{data:d}=n.usePageTypes(),E=c.useMemo(()=>{const t=d==null?void 0:d.find(g=>g.key===(i==null?void 0:i.pageType));return i!=null&&i.dynamic?t==null?void 0:t.dynamicSlug:""},[d,i==null?void 0:i.pageType,i==null?void 0:i.dynamic]),[m,h]=c.useState(null),[x,v]=c.useState(null),[S,A]=c.useState(null),{data:b}=n.useWebsiteSetting(),D=r.filter(r.get(b,"languages")||["en"],t=>!r.find(y,{lang:t})&&t!==r.get(b,"fallbackLang"));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ul",{className:"space-y-2",children:f?e.jsxs("div",{className:"w-full space-y-3 py-4",children:[e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"})]}):r.map(y,t=>{const g=t.lang,C=t.slug,w=!t.primaryPage,G=g===l;return e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:`flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${G?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>P(g),children:[e.jsxs("div",{className:"flex-1 gap-x-3",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-[13px] text-slate-800",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),r.get(n.LANGUAGES,w?o:g,g)]}),e.jsxs("div",{children:[C&&e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Slug: ",e.jsx("b",{className:"font-mono font-medium",children:E?`${C}/${E}`:C})]}),e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Name:",e.jsxs("b",{className:"font-medium",children:[" ",t.name," "]})]})]})]}),w?e.jsxs("div",{className:"flex items-center gap-x-1 text-[11px] text-orange-500",children:[e.jsx(j.StarIcon,{fill:"orange",className:"h-3 w-3"}),e.jsx("b",{children:" Primary"})]}):e.jsx("div",{className:"flex items-center gap-x-3",children:e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE,n.PAGES_PERMISSIONS.DELETE_PAGE,n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,onClick:u=>u.stopPropagation(),children:e.jsx(N.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(j.MoreHorizontal,{className:"h-4 w-4"})})}),e.jsxs(a.DropdownMenuContent,{align:"end",className:"z-[9999] text-sm",children:[e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE],children:e.jsxs(a.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),p({edit:!0,id:t.id,primaryPage:t.primaryPage})},children:[e.jsx(j.PencilIcon,{className:"size-3"}),s("Edit")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:(t==null?void 0:t.online)&&e.jsxs(a.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),v(t)},children:[e.jsx(j.Power,{className:"size-3"}),s("Unpublish")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.DELETE_PAGE],children:e.jsxs(a.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),h(t)},children:[e.jsx(j.TrashIcon,{className:"size-3"}),s("Delete")]})})]})]})})})]},t.id),e.jsx("div",{className:"h-1 w-full border-b"})]})})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.ADD_PAGE],children:e.jsx("div",{className:"flex w-full justify-center",children:e.jsx(N.Button,{variant:"default",size:"sm",disabled:r.isEmpty(D),onClick:()=>{p({primaryPage:i==null?void 0:i.id,edit:!1})},children:s("Add new language page")})})}),m&&e.jsx(c.Suspense,{children:e.jsx(T,{page:m,onClose:()=>h(null)})}),x&&e.jsx(c.Suspense,{children:e.jsx(q,{page:x,onClose:()=>v(null)})}),S&&e.jsx(c.Suspense,{children:e.jsx(M,{page:S,onClose:()=>A(null)})})]})};exports.default=_;
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as s, Fragment as M } from "react/jsx-runtime";
2
2
  import { D as j, z as F, B as A } from "./register-chai-top-bar-D6GjnauV.js";
3
3
  import { D as B, e as H, f as O, g as W, o as q, p as R, q as J, d as K, r as Q, s as V, t as X, v as w } from "./index-7OSd9ssH.js";
4
- import { as as Y, k as T, L as I, at as Z, j as ee, au as se, h as ae, av as f, aw as o } from "./index-CHoZEbKv.js";
4
+ import { as as Y, k as T, L as I, at as Z, j as ee, au as se, h as ae, av as f, aw as o } from "./index-B6QztICX.js";
5
5
  import { find as G, startsWith as E, isEqual as te, filter as ne, get as D, map as le, isEmpty as ie } from "lodash-es";
6
6
  import { AlertCircle as re, StarIcon as ce, MoreHorizontal as oe, PencilIcon as de, Power as me, TrashIcon as ue } from "lucide-react";
7
7
  import { useState as S, useMemo as he, Suspense as L, lazy as z } from "react";
@@ -81,7 +81,7 @@ const fe = ({ page: a, onClose: g }) => {
81
81
  /* @__PURE__ */ e(J, { children: /* @__PURE__ */ e(A, { type: "submit", disabled: y || !E(i, `/${d}`) || te(a == null ? void 0 : a.slug, i), children: l(y ? "Changing..." : "Change Slug") }) })
82
82
  ] })
83
83
  ] }) });
84
- }, Ne = z(() => import("./delete-page-DNz6-CLI.js")), ye = z(() => import("./unpublish-page-D-5iWXIB.js")), ke = () => {
84
+ }, Ne = z(() => import("./delete-page-D8PgbaSa.js")), ye = z(() => import("./unpublish-page-Cyx4HU4j.js")), ke = () => {
85
85
  const { t: a } = U(), g = pe(Z), { selectedLang: l, fallbackLang: i, setSelectedLang: v } = K(), { data: N, isFetching: y } = ee(), { data: n } = se(), { data: r } = T(), x = he(() => {
86
86
  const t = r == null ? void 0 : r.find((h) => h.key === (n == null ? void 0 : n.pageType));
87
87
  return n != null && n.dynamic ? t == null ? void 0 : t.dynamicSlug : "";