@chaibuilder/sdk 4.0.0-beta.22 → 4.0.0-beta.24

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 (117) hide show
  1. package/dist/{2SSKDMRQ-DVWVGtU8.cjs → 2SSKDMRQ-C6XmPkPR.cjs} +1 -1
  2. package/dist/{2SSKDMRQ-SUA5eA2S.js → 2SSKDMRQ-DTcPSOGn.js} +2 -2
  3. package/dist/{AP7HFJJL-CUN5zddU.cjs → AP7HFJJL-6aBLUYOi.cjs} +1 -1
  4. package/dist/{AP7HFJJL-Co5bLh3I.js → AP7HFJJL-CVazlaEj.js} +1 -1
  5. package/dist/{IconPicker-BZvFj3cg.js → IconPicker-CcBoA1K0.js} +1 -1
  6. package/dist/{IconPicker-Bmz6vXB8.cjs → IconPicker-sbWeQ9M9.cjs} +1 -1
  7. package/dist/{WDYDFRGG-BpSteEEf.cjs → WDYDFRGG-BtzyRDmj.cjs} +1 -1
  8. package/dist/{WDYDFRGG-DjCIT9L-.js → WDYDFRGG-CwiYliX0.js} +2 -2
  9. package/dist/{active-in-another-tab-DfRJcvAz.js → active-in-another-tab-B4O3FEEg.js} +2 -2
  10. package/dist/{active-in-another-tab-C8-vpt8f.cjs → active-in-another-tab-DRJY0QqU.cjs} +1 -1
  11. package/dist/{add-new-language-page-jZ7Pg0Fv.js → add-new-language-page-BfYL9jXF.js} +3 -3
  12. package/dist/{add-new-language-page-B2BEmfil.cjs → add-new-language-page-CKIRTFjr.cjs} +1 -1
  13. package/dist/{add-new-page-YZF_XF8X.js → add-new-page-DVgxz4fs.js} +2 -2
  14. package/dist/{add-new-page-DbEBB3w7.cjs → add-new-page-dzN_CD2c.cjs} +1 -1
  15. package/dist/{ai-panel-content-C8ecaQnv.js → ai-panel-content-D5eFLI_B.js} +3 -3
  16. package/dist/{ai-panel-content-Bf_ojKwt.cjs → ai-panel-content-Dyw4RHCV.cjs} +1 -1
  17. package/dist/{ai-panel-default-lang-BC8Gq_jl.js → ai-panel-default-lang-Cj7meZBD.js} +3 -3
  18. package/dist/{ai-panel-default-lang-DokOmE_Q.cjs → ai-panel-default-lang-DEj9Qx2M.cjs} +2 -2
  19. package/dist/{ai-panel-other-lang-BJ30SL7z.js → ai-panel-other-lang-Cbi6HKzd.js} +3 -3
  20. package/dist/{ai-panel-other-lang-Ccx1t8pp.cjs → ai-panel-other-lang-Da2XLEcm.cjs} +1 -1
  21. package/dist/{ai-prompt-input-SfeB6a2j.js → ai-prompt-input-B6QoqT9B.js} +1 -1
  22. package/dist/{ai-prompt-input-ED14e6NE.cjs → ai-prompt-input-DXS8gzex.cjs} +1 -1
  23. package/dist/{ai-translation-prompt-BRRzei71.js → ai-translation-prompt-Dmq_Ahjf.js} +1 -1
  24. package/dist/{ai-translation-prompt-spS-OC6L.cjs → ai-translation-prompt-Uswft8iz.cjs} +1 -1
  25. package/dist/{code-editor-CIqswl5j.cjs → code-editor-DbSBrsUA.cjs} +1 -1
  26. package/dist/{code-editor-CYiIxUKp.js → code-editor-wQWmwFKW.js} +1 -1
  27. package/dist/{continue-editing-in-this-client-vICoETHN.js → continue-editing-in-this-client-BV0OrgEU.js} +2 -2
  28. package/dist/{continue-editing-in-this-client-B3CnmiZ2.cjs → continue-editing-in-this-client-Dkkzk8YZ.cjs} +1 -1
  29. package/dist/core.cjs +1 -1
  30. package/dist/core.d.ts +1 -0
  31. package/dist/core.js +1 -1
  32. package/dist/{css-import-modal-CHFZPXXQ.cjs → css-import-modal-C3f5sphx.cjs} +1 -1
  33. package/dist/{css-import-modal-DautOct0.js → css-import-modal-Co_YLkLB.js} +1 -1
  34. package/dist/{delete-design-token-BmWHk_Ap.js → delete-design-token-CJPAcsWp.js} +1 -1
  35. package/dist/{delete-design-token-D-wGR5qS.cjs → delete-design-token-zzNmNYLR.cjs} +1 -1
  36. package/dist/{delete-page-D5mzl-ET.cjs → delete-page-6lInxYM_.cjs} +1 -1
  37. package/dist/{delete-page-Dlv8srng.js → delete-page-CQTjB7ZZ.js} +2 -2
  38. package/dist/{design-token-usage-hl29qR_q.js → design-token-usage-BQY6eqzE.js} +1 -1
  39. package/dist/{design-token-usage-DIszlgJK.cjs → design-token-usage-blwlGuEE.cjs} +1 -1
  40. package/dist/{digital-asset-manager-v2LfDXwR.cjs → digital-asset-manager-cGUpTcu3.cjs} +1 -1
  41. package/dist/{digital-asset-manager-o_bNl9qj.js → digital-asset-manager-lPKoJ4FH.js} +3 -3
  42. package/dist/{duplicate-page-BjqgghN0.js → duplicate-page-Dmgqp93w.js} +3 -3
  43. package/dist/{duplicate-page-CEuF8dll.cjs → duplicate-page-rYeBMwHR.cjs} +1 -1
  44. package/dist/{dynamic-page-selector-BWC7kHJ1.js → dynamic-page-selector-CVyA9Zp0.js} +2 -2
  45. package/dist/{dynamic-page-selector-D4EWs4Qd.cjs → dynamic-page-selector-zqGqpcww.cjs} +1 -1
  46. package/dist/{get-chai-builder-theme-DDVRJQ6Z.js → get-chai-builder-theme-CfJkQYZc.js} +1 -1
  47. package/dist/{get-chai-builder-theme-BApShjRz.cjs → get-chai-builder-theme-Dm1z70lQ.cjs} +1 -1
  48. package/dist/{image-editor-2h5axNuk.cjs → image-editor-Cn1DgrNp.cjs} +1 -1
  49. package/dist/{image-editor-B1-bjvPd.js → image-editor-mVBb0VD_.js} +1 -1
  50. package/dist/{index-BJVYKKJq.cjs → index-B5qvHqN5.cjs} +2 -2
  51. package/dist/{index-DWGTiEak.cjs → index-EFWvSWoi.cjs} +11 -11
  52. package/dist/{index-BvluH-oT.js → index-GfOB5KV1.js} +20 -20
  53. package/dist/{index-BN6yEl-H.js → index-lm46VtIP.js} +889 -887
  54. package/dist/{json-diff-viewer-BjCIlzd7.cjs → json-diff-viewer-BeSMdSd5.cjs} +1 -1
  55. package/dist/{json-diff-viewer-WX0GIjq-.js → json-diff-viewer-D5yJoFh1.js} +2 -2
  56. package/dist/{lang-panel-C4x7bcyb.js → lang-panel-7qTejsLm.js} +3 -3
  57. package/dist/{lang-panel--yfjRDE2.cjs → lang-panel-B-QUotOn.cjs} +1 -1
  58. package/dist/{manage-design-tokens-CRwsErkx.js → manage-design-tokens-DeH-yNJN.js} +2 -2
  59. package/dist/{manage-design-tokens-DhdwhzQu.cjs → manage-design-tokens-TeWNZekH.cjs} +1 -1
  60. package/dist/{mark-as-template-BH0W9p2G.cjs → mark-as-template-Co00KkhA.cjs} +1 -1
  61. package/dist/{mark-as-template-DpZSFrLK.js → mark-as-template-RkfNETRW.js} +2 -2
  62. package/dist/{nested-path-selector-content-BDQmZzlf.js → nested-path-selector-content-Dimjyy8J.js} +1 -1
  63. package/dist/{nested-path-selector-content-CHYz7cdB.cjs → nested-path-selector-content-hBvmT_2A.cjs} +1 -1
  64. package/dist/{no-language-page-content-D0lcCseQ.js → no-language-page-content-Bk3sTsdM.js} +2 -2
  65. package/dist/{no-language-page-content-D7btm8zX.cjs → no-language-page-content-CLovr1bL.cjs} +1 -1
  66. package/dist/{no-language-page-dialog-sYOmLnpY.cjs → no-language-page-dialog-C21Fq-UD.cjs} +1 -1
  67. package/dist/{no-language-page-dialog-BdW7oXvt.js → no-language-page-dialog-Cx-YOrAd.js} +2 -2
  68. package/dist/{page-creator-O_QpbMlB.js → page-creator-BBuYY84G.js} +3 -3
  69. package/dist/{page-creator-B-jBAGZl.cjs → page-creator-BDmospqO.cjs} +1 -1
  70. package/dist/{page-lock-CmQKpw1U.js → page-lock-BrGWj326.js} +2 -2
  71. package/dist/{page-lock-BrVqfmVm.cjs → page-lock-DG5IvZaG.cjs} +1 -1
  72. package/dist/{page-locked-dialog-ChHVSk7X.cjs → page-locked-dialog-DKnQpIMB.cjs} +1 -1
  73. package/dist/{page-locked-dialog-BjeJOXuN.js → page-locked-dialog-DUktYJzU.js} +2 -2
  74. package/dist/{page-manager-new-wcsdorbd.js → page-manager-new-BfKYDWs7.js} +3 -3
  75. package/dist/{page-manager-new-B90zLpRY.cjs → page-manager-new-iYsDkUzG.cjs} +1 -1
  76. package/dist/{page-manager-search-and-filter-Bb_Zfpsj.cjs → page-manager-search-and-filter-CIspvIW2.cjs} +1 -1
  77. package/dist/{page-manager-search-and-filter-DY_NsetM.js → page-manager-search-and-filter-DVAGxnlw.js} +2 -2
  78. package/dist/{page-revisions-content-CVpi-467.cjs → page-revisions-content-B84UtAxm.cjs} +1 -1
  79. package/dist/{page-revisions-content-5h39VYXj.js → page-revisions-content-DB4mj_Cw.js} +3 -3
  80. package/dist/pages.cjs +1 -1
  81. package/dist/pages.d.ts +1 -0
  82. package/dist/pages.js +1 -1
  83. package/dist/{plugin-BGlQf0iy.cjs → plugin-BfC_qpW2.cjs} +10 -10
  84. package/dist/{plugin-C-ht41UZ.js → plugin-DVNaUexn.js} +86 -80
  85. package/dist/{publish-pages-content-rrfvXks4.js → publish-pages-content-BRKsIr9W.js} +3 -3
  86. package/dist/{publish-pages-content-BG1GIuIz.cjs → publish-pages-content-ysv37LxZ.cjs} +1 -1
  87. package/dist/render.cjs +1 -1
  88. package/dist/render.d.ts +4 -1
  89. package/dist/render.js +2 -2
  90. package/dist/{rte-widget-modal-JRoPPuju.cjs → rte-widget-modal-BS040t_9.cjs} +1 -1
  91. package/dist/{rte-widget-modal-29WtCMJs.js → rte-widget-modal-Dj5BvA-1.js} +1 -1
  92. package/dist/{save-to-lib-YvzDV5ee.cjs → save-to-lib-ClCCNy6W.cjs} +1 -1
  93. package/dist/{save-to-lib-Bm7R2K7j.js → save-to-lib-D3kp0ovZ.js} +2 -2
  94. package/dist/{selected-block-display-BAulh0Nz.js → selected-block-display-BtlTAkei.js} +2 -2
  95. package/dist/{selected-block-display-bdClAekS.cjs → selected-block-display-BvRoOMt9.cjs} +1 -1
  96. package/dist/{seo-panel-D9wnaLG-.cjs → seo-panel-CHGdB8_7.cjs} +1 -1
  97. package/dist/{seo-panel-CT0D3I44.js → seo-panel-C_Cnwj1-.js} +2 -2
  98. package/dist/{shared-json-ld-ON6LaybZ.cjs → shared-json-ld-DA0wz-k3.cjs} +1 -1
  99. package/dist/{shared-json-ld-CuhqVL8H.js → shared-json-ld-DPr0Douk.js} +2 -2
  100. package/dist/{slug-input-DNeh6LBv.js → slug-input-CqhlfgAe.js} +1 -1
  101. package/dist/{slug-input-CxmcQbTR.cjs → slug-input-DltqfQ3y.cjs} +1 -1
  102. package/dist/{take-over-request-CrILj_3q.cjs → take-over-request-Bq7OF5Gp.cjs} +1 -1
  103. package/dist/{take-over-request-BmeR6t3b.js → take-over-request-ByUlm_HK.js} +2 -2
  104. package/dist/{theme-panel-footer-D4oCAY2G.js → theme-panel-footer-DG7Z5YjD.js} +2 -2
  105. package/dist/{theme-panel-footer-BMx5lGB4.cjs → theme-panel-footer-XYoM6sn5.cjs} +1 -1
  106. package/dist/{translation-warning-modal-ChL7oDO1.cjs → translation-warning-modal-DTxxfo0H.cjs} +1 -1
  107. package/dist/{translation-warning-modal-BNG9m-FC.js → translation-warning-modal-DaBUipEY.js} +1 -1
  108. package/dist/types.d.ts +1 -0
  109. package/dist/{unmark-as-template-CEEMIY1A.js → unmark-as-template-BOFHOO0_.js} +2 -2
  110. package/dist/{unmark-as-template-BYiyJloZ.cjs → unmark-as-template-C9EXTj0X.cjs} +1 -1
  111. package/dist/{unpublish-page-B0aY1JnO.cjs → unpublish-page-B5rev9W3.cjs} +1 -1
  112. package/dist/{unpublish-page-Bm20P3TB.js → unpublish-page-KDM7kEEV.js} +2 -2
  113. package/dist/utils.cjs +1 -1
  114. package/dist/utils.js +1 -1
  115. package/dist/{web-preview-BtEn4Vc-.js → web-preview-BDgUTTr8.js} +1 -1
  116. package/dist/{web-preview-iQgiotU6.cjs → web-preview-CvpevNzM.cjs} +1 -1
  117. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- "use strict";var ur=Object.create;var Yt=Object.defineProperty;var dr=Object.getOwnPropertyDescriptor;var fr=Object.getOwnPropertyNames;var hr=Object.getPrototypeOf,gr=Object.prototype.hasOwnProperty;var jn=e=>{throw TypeError(e)};var mr=(e,t,n)=>t in e?Yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Er=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of fr(t))!gr.call(e,r)&&r!==n&&Yt(e,r,{get:()=>t[r],enumerable:!(s=dr(t,r))||s.enumerable});return e};var pr=(e,t,n)=>(n=e!=null?ur(hr(e)):{},Er(t||!e||!e.__esModule?Yt(n,"default",{value:e,enumerable:!0}):n,e));var Jt=(e,t,n)=>mr(e,typeof t!="symbol"?t+"":t,n),Gn=(e,t,n)=>t.has(e)||jn("Cannot "+n);var _=(e,t,n)=>(Gn(e,t,"read from private field"),n?n.call(e):t.get(e)),M=(e,t,n)=>t.has(e)?jn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),R=(e,t,n,s)=>(Gn(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n);const i=require("react/jsx-runtime"),g=require("./index-DWGTiEak.cjs"),I=require("./register-chai-top-bar-DWTuRU53.cjs"),Q=require("jotai"),p=require("lodash-es"),h=require("react"),P=require("@tanstack/react-query"),b=require("lucide-react"),he=require("react-i18next"),yr=require("./plugin-BGlQf0iy.cjs"),Gt=require("./common-functions-B3a4xKt_.cjs"),F=require("sonner"),Ar=require("./core-BWQrViOY.cjs"),Sr=require("./apply-binding-nqrhHgIz.cjs"),Tr=require("./web-blocks.cjs"),Pr=require("react-error-boundary");function xr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const z=xr(h),rt=Q.atom(null),y={GET_GLOBAL_JSONLD_ITEMS:"GET_GLOBAL_JSONLD_ITEMS",GENERATE_SEO_FIELD:"GENERATE_SEO_FIELD",UPDATE_PAGE_METADATA:"UPDATE_PAGE_METADATA",GET_BLOCK_ASYNC_PROPS:"GET_BLOCK_ASYNC_PROPS",ASK_AI:"ASK_AI",GET_DRAFT_PAGE:"GET_DRAFT_PAGE",CREATE_PAGE:"CREATE_PAGE",UPDATE_PAGE:"UPDATE_PAGE",DELETE_PAGE:"DELETE_PAGE",DUPLICATE_PAGE:"DUPLICATE_PAGE",CHANGE_SLUG:"CHANGE_SLUG",TAKE_OFFLINE:"TAKE_OFFLINE",PUBLISH_PAGE:"PUBLISH_PAGE",PUBLISH_CHANGES:"PUBLISH_CHANGES",ADD_NEW_LANGUAGE:"ADD_NEW_LANGUAGE",EDIT_LANGUAGE:"EDIT_LANGUAGE",DELETE_LANGUAGE:"DELETE_LANGUAGE",GET_CHANGES:"GET_CHANGES",GET_SERVER_BLOCK:"GET_SERVER_BLOCK",GET_LANGUAGE_PAGES:"GET_LANGUAGE_PAGES",GET_PROJECT_PAGES:"GET_PROJECT_PAGES",GET_WEBSITE_PAGES:"GET_WEBSITE_PAGES",UPDATE_WEBSITE_FIELDS:"UPDATE_WEBSITE_FIELDS",GET_COLLECTIONS:"GET_COLLECTIONS",GET_PAGE_TYPES:"GET_PAGE_TYPES",SEARCH_PAGES:"SEARCH_PAGES",GET_WEBSITE_DRAFT_SETTINGS:"GET_WEBSITE_DRAFT_SETTINGS",AI_CONTEXT:"AI_CONTEXT",GET_WEBSITE_DATA:"GET_WEBSITE_DATA",GET_CHAI_USER:"GET_CHAI_USER",GET_SEO_FIELDS:"GET_SEO_FIELDS",GET_BUILDER_PAGE_DATA:"GET_BUILDER_PAGE_DATA",GET_PAGE_REVISIONS:"GET_PAGE_REVISIONS",DELETE_PAGE_REVISION:"DELETE_PAGE_REVISION",RESTORE_PAGE_REVISION:"RESTORE_PAGE_REVISION",GET_REVISION_DATA:"GET_REVISION_DATA",GET_PAGE_DATA:"GET_PAGE_DATA",GET_COMPARE_DATA:"GET_COMPARE_DATA",GET_ROLE_AND_PERMISSIONS:"GET_ROLE_AND_PERMISSIONS",UPSERT_LIBRARY_ITEM:"UPSERT_LIBRARY_ITEM",GET_LIBRARIES:"GET_LIBRARIES",GET_LIBRARY_ITEM:"GET_LIBRARY_ITEM",GET_LIBRARY_ITEMS:"GET_LIBRARY_ITEMS",DELETE_LIBRARY_ITEM:"DELETE_LIBRARY_ITEM",MARK_AS_TEMPLATE:"MARK_AS_TEMPLATE",UNMARK_AS_TEMPLATE:"UNMARK_AS_TEMPLATE",GET_TEMPLATES_BY_TYPE:"GET_TEMPLATES_BY_TYPE",GET_DYNAMIC_PAGES:"GET_DYNAMIC_PAGES",GET_APP_SHARED_JSONLD:"GET_APP_SHARED_JSONLD",UPDATE_APP_SHARED_JSONLD:"UPDATE_APP_SHARED_JSONLD",ADD_GLOBAL_SCHEMA:"ADD_GLOBAL_SCHEMA",UPDATE_GLOBAL_SCHEMA:"UPDATE_GLOBAL_SCHEMA",DELETE_GLOBAL_SCHEMA:"DELETE_GLOBAL_SCHEMA",TOGGLE_PAGE_GLOBAL_SCHEMA:"TOGGLE_PAGE_GLOBAL_SCHEMA",APPLY_SCHEMA_TO_ALL_PAGES:"APPLY_SCHEMA_TO_ALL_PAGES",REMOVE_SCHEMA_FROM_ALL_PAGES:"REMOVE_SCHEMA_FROM_ALL_PAGES",UPLOAD_ASSET:"UPLOAD_ASSET",DELETE_ASSET:"DELETE_ASSET",UPDATE_ASSET:"UPDATE_ASSET",GET_ASSETS:"GET_ASSETS",GET_ASSET:"GET_ASSET"},_r=Q.atom({}),qt=()=>Q.useAtom(_r),ae=(e,t)=>{const[n]=qt();return h.useMemo(()=>p.get(n,e,t),[n,e,t])},N=()=>ae("apiUrl","/chai/api"),hn=()=>ae("realtimeAdapter",null),$n=async(e,t,n={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(t)}),wr=()=>{const e=k(),t=N();return h.useCallback(async({body:n,headers:s={},url:r=t,streamResponse:a=!1})=>e(r,n,s,a),[e])},k=()=>{const e=ae("onLogout",p.noop),t=ae("getAccessToken"),n=N();return h.useCallback(async(s=n,r,a={},o=!1)=>{const l=await t();try{const c=p.get(r,"action","").toLowerCase(),d=await $n(s+(c?`?action=${c}`:""),r,{...a,Authorization:`Bearer ${l}`});if(o)return d;if(d.status===401)return console.log("401 Response",d),await e("SESSION_EXPIRED"),null;if(!d.ok){const u=await d.json();throw console.error(`API Error (${d.status}):`,u),{status:d.status,statusText:d.statusText,...u,message:u.error||u.message||`Server error: ${d.status}`}}return await d.json()}catch(c){throw console.error("API request failed:",r,c),c}},[e,t])};function ue(){const[e,t]=h.useState(new URLSearchParams(window.location.search));return h.useEffect(()=>{const n=()=>{t(new URLSearchParams(window.location.search))};return window.addEventListener("popstate",n),()=>{window.removeEventListener("popstate",n)}},[]),[e,t]}const Te=e=>{const t=N(),[n]=ue(),s=e??n.get("page"),r=k();return P.useQuery({queryKey:[y.GET_LANGUAGE_PAGES,s],staleTime:1/0,gcTime:0,placeholderData:[],queryFn:async()=>{if(!s)return null;const a=await r(t,{action:y.GET_LANGUAGE_PAGES,data:{id:s}});return p.reverse(p.sortBy(a,"primaryPage"))},enabled:!!s})},vr=Q.atom(null),Wn=()=>Q.useAtom(vr),gn=()=>{const[e]=Wn();return(e==null?void 0:e.slug)||""};function br(e,t){const[n,s]=h.useState(e);return h.useEffect(()=>{const r=setTimeout(()=>s(e),t);return()=>clearTimeout(r)},[e,t]),n}const Cr=({query:e,uuid:t})=>{const{selectedLang:n,fallbackLang:s}=g.useLanguages(),{data:r}=ne(),a=r==null?void 0:r.pageType,o=N(),l=k(),{data:c,isFetching:d}=P.useQuery({queryKey:[y.GET_DYNAMIC_PAGES,e,a,t],staleTime:3600*1e3,placeholderData:[],queryFn:async()=>await l(o,{action:y.GET_DYNAMIC_PAGES,data:{query:e,pageType:a,uuid:t}})||[],enabled:!!a}),u=h.useMemo(()=>n===""?c.filter(f=>f.lang===""||f.lang===s):c.filter(f=>f.lang===n),[n,s,c]);return{allLangPages:c,data:u,isFetching:d}},Yn=()=>{const{selectedLang:e,fallbackLang:t}=g.useLanguages(),[n,s]=Wn(),[r,a]=h.useState(""),o=br(r,500),{allLangPages:l,data:c,isFetching:d}=Cr({query:o}),u=h.useCallback(m=>s(m),[s]),f=h.useCallback(m=>a(m),[a]),E=h.useCallback(()=>{if(!n)return;const m=!(n!=null&&n.primaryPage),T=e.length===0,S=m?n==null?void 0:n.id:n==null?void 0:n.primaryPage,w=l.filter(A=>(A==null?void 0:A.primaryPage)===S||A.id===S).find(A=>T?A.lang===e||A.lang===t:A.lang===e);s(w||n)},[n,e,l,s,t]);return{isFetching:d,dynamicPage:n,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:u,updateSearchQuery:f,onChangeLanguage:E}},Ir=Q.atom({lastSaved:void 0}),mn=()=>Q.useAtom(Ir),ne=()=>{const[e]=ue(),t=e.get("page"),{data:n,isFetching:s}=Te();return{data:h.useMemo(()=>({...p.find(n,{id:t})||{}}),[n,t]),isFetching:s}},ge=()=>{const[e]=ue(),t=e.get("lang")??"",{data:n,isFetching:s}=Te();return{data:h.useMemo(()=>p.find(n,{lang:t})||{},[n,t]),isFetching:s}},Nr=Q.atom({}),Lr=()=>Q.useAtom(Nr),jr=()=>{const{data:e}=ge(),t=gn(),n=ae("getLiveUrl",p.noop),s=e==null?void 0:e.slug,r=n(s||"/");return t?r+t:r},re={...g.PERMISSIONS,ADD_PAGE:"add_page",EDIT_PAGE:"edit_page",DELETE_PAGE:"delete_page",CHANGE_PAGE_TYPE:"change_page_type",PUBLISH_PAGE:"publish_page",UNPUBLISH_PAGE:"unpublish_page",MARK_AS_TEMPLATE:"mark_as_template",EDIT_SEO:"edit_seo",RESTORE_REVISION:"restore_revision",DELETE_REVISION:"delete_revision",DELETE_LIBRARY_BLOCK:"delete_library_block"},me=()=>{const e=N(),t=k();return P.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},Jn=e=>{const{data:t}=me();return h.useMemo(()=>t==null?void 0:t.find(n=>n.key===e),[t,e])},Gr=()=>{const e=N(),t=k();return P.useMutation({mutationFn:async({pageType:n,query:s})=>{try{return t(e,{action:y.SEARCH_PAGES,data:{pageType:n,query:Array.isArray(s)&&s.length>0?s[0]:s}})||[]}catch(r){return console.error(r),[]}}})},Zn=({page:e,setDuplicatePage:t,setAddEditPage:n,setUnpublishPage:s,setDeletePage:r,setMarkAsTemplate:a,setUnmarkAsTemplate:o,children:l,isLanguagePage:c})=>{const{t:d}=he.useTranslation(),{hasPermission:u}=g.usePermissions(),{data:f}=me(),E=h.useMemo(()=>p.find(f,{key:e.pageType}),[f,e.pageType]),m=h.useMemo(()=>!!e.isTemplate,[e.isTemplate]),T=h.useMemo(()=>!!(E!=null&&E.hasSlug),[E==null?void 0:E.hasSlug]);return!u(re.EDIT_PAGE)&&!u(re.DELETE_PAGE)&&!u(re.UNPUBLISH_PAGE)||!e?null:i.jsxs(g.DropdownMenu,{children:[i.jsx(g.DropdownMenuTrigger,{asChild:!0,onClick:x=>x.stopPropagation(),children:l}),i.jsxs(g.DropdownMenuContent,{align:"center",className:"text-sm",children:[u(re.ADD_PAGE)&&!c&&i.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),t(e)},children:[i.jsx(b.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),u(re.EDIT_PAGE)&&i.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),n({...e,global:!(E!=null&&E.hasSlug)})},children:[i.jsx(b.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&u(re.UNPUBLISH_PAGE)&&i.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),s(e)},children:[i.jsx(b.Power,{className:"size-3"}),d("Unpublish")]}),u(re.DELETE_PAGE)&&i.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),r(e)},children:[i.jsx(b.Trash,{className:"size-3"}),d("Delete")]}),u(re.MARK_AS_TEMPLATE)&&T&&!c&&i.jsx(i.Fragment,{children:m?i.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),o(e)},children:[i.jsx(b.SquareLibrary,{className:"size-3"}),d("Unmark as template")]}):i.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),a(e)},children:[i.jsx(b.SquareLibrary,{className:"size-3"}),d("Mark as template")]})})]})]})},Pe=()=>{const e=N(),t=k();return P.useQuery({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS],staleTime:300*1e3,placeholderData:{languages:[],theme:yr.defaultThemeValues,appKey:"",fallbackLang:"",designTokens:{}},queryFn:async()=>t(e,{action:y.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})},Kt=()=>{const e=ae("currentUser"),t=ae("onLogout");return{isLoggedIn:!!e,user:e,logout:t}},J={LOCKED:"LOCKED",EDITING:"EDITING",CHECKING:"CHECKING",TAKE_OVER_REQUESTED:"TAKE_OVER_REQUESTED",ACTIVE_IN_ANOTHER_TAB:"ACTIVE_IN_ANOTHER_TAB",FORCE_TAKE_OVER:"FORCE_TAKE_OVER",CONNECTION_LOST:"CONNECTION_LOST"},X={FORCE_TAKE_OVER:"FORCE_TAKE_OVER",TAKE_OVER_REQUEST:"TAKE_OVER_REQUEST",TAKE_OVER_APPROVED:"TAKE_OVER_APPROVED",TAKE_OVER_REJECTED:"TAKE_OVER_REJECTED",FORCE_TAKE_OVER_REQUEST:"FORCE_TAKE_OVER_REQUEST",CONTINUE_EDITING_IN_THIS_CLIENT:"CONTINUE_EDITING_IN_THIS_CLIENT",CONTINUE_EDITING_IN_THIS_TAB_REQUEST:"CONTINUE_EDITING_IN_THIS_TAB_REQUEST"},kr=["sync","join","leave"],Or=[X.FORCE_TAKE_OVER,X.TAKE_OVER_REQUEST,X.TAKE_OVER_APPROVED,X.TAKE_OVER_REJECTED,X.FORCE_TAKE_OVER_REQUEST,X.CONTINUE_EDITING_IN_THIS_CLIENT,X.CONTINUE_EDITING_IN_THIS_TAB_REQUEST],Rr=Q.atom({}),Xn=Q.atom(null),Dr=Q.atom(J.CHECKING),Mr=Q.atom({}),Ur=e=>{const t={},n=p.groupBy(p.values(e).map(p.first).filter(Boolean),"pageId");return Object.entries(n).forEach(([s,r])=>t[s]=p.minBy(r,"onlineAt")),t},Br=e=>{const t=p.minBy(p.values(e).map(p.first).filter(Boolean),"onlineAt"),n=t==null?void 0:t.onlineAt;return n?n-100:+new Date-1e3*60*60*4},Pt=()=>{const{user:e}=Kt();return e==null?void 0:e.id},Fr=()=>{const{data:e}=Pe();return`WEBSITE:${e==null?void 0:e.appKey}`},xt=()=>{const{data:e}=ne();return e==null?void 0:e.id},pe=crypto.randomUUID();let Zt=null;const Je=10,qr=1e3,Kr=2,Vr=16e3,En=()=>{const[e,t]=Q.useAtom(Rr);return{pageToUser:e,setPageToUser:t}},ie=()=>{const[e,t]=Q.useAtom(Dr),n=[J.LOCKED,J.ACTIVE_IN_ANOTHER_TAB].includes(e),s=[J.EDITING].includes(e);return{pageStatus:e,setPageStatus:t,isLocked:n,isEditing:s}},pn=()=>{const[e,t]=Q.useAtom(Mr);return{pageLockMeta:e,setPageLockMeta:t}},es=()=>{const e=xt(),{pageToUser:t}=En();return h.useMemo(()=>t[e],[t,e])},yn=()=>{const e=hn(),{setPageStatus:t}=ie(),[n]=Q.useAtom(Xn);return h.useEffect(()=>{if(clearTimeout(Zt),!e)return Zt=setTimeout(()=>{e||t(J.EDITING)},500),()=>clearTimeout(Zt)},[e,t]),n},Hr=()=>{const e=xt(),t=Pt(),n=yn(),{setPageToUser:s}=En(),{setPageStatus:r,pageStatus:a}=ie(),o=h.useRef(e);return h.useEffect(()=>{o.current=e},[e]),h.useCallback(l=>{const c=l||n;if(!c)return[];const d=c==null?void 0:c.presenceState(),u=Ur(d);s(u);const f=u[o.current];if(!f)r(J.CHECKING);else if(!t)r(J.CHECKING);else if(f.userId===t&&f.clientId===pe){if(a===J.TAKE_OVER_REQUESTED)return;r(J.EDITING)}else f.userId===t&&f.clientId!==pe?r(J.ACTIVE_IN_ANOTHER_TAB):r(J.LOCKED)},[n,s,r,t,a])},ts=()=>{const e=Pt(),t=xt(),n=yn(),s=es(),{setPageLockMeta:r}=pn(),a=h.useRef(t);return h.useEffect(()=>{a.current=t},[t]),h.useCallback(async(o,l)=>{if(!n)return;const c=l||{};c.userId=e,c.pageId=a.current,c.senderClientId=pe,c.receiverClientId=(l==null?void 0:l.requestingClientId)||(s==null?void 0:s.clientId),await n.send(o,c),r({})},[n,e,s,r])},Qr=()=>{const e=Pt(),t=xt(),n=yn(),{setPageStatus:s}=ie(),{setPageLockMeta:r}=pn(),a=ts(),o=h.useRef(t),{savePageAsync:l}=g.useSavePage();return h.useEffect(()=>{o.current=t},[t]),h.useCallback(c=>async({payload:d})=>{const u=d||{};if(!(!(u!=null&&u.pageId)||(u==null?void 0:u.pageId)!==o.current||(u==null?void 0:u.receiverClientId)!==pe))switch(r({}),c){case X.FORCE_TAKE_OVER_REQUEST:case X.CONTINUE_EDITING_IN_THIS_TAB_REQUEST:{try{await l(!0)}catch(f){console.error("Failed to save page before releasing lock:",f)}await a(X.CONTINUE_EDITING_IN_THIS_CLIENT,{requestingClientId:u==null?void 0:u.senderClientId}),setTimeout(()=>r({type:c}),0);break}case X.TAKE_OVER_REQUEST:{r({requestingUserId:u==null?void 0:u.userId,requestingClientId:u==null?void 0:u.senderClientId}),s(J.TAKE_OVER_REQUESTED);break}case X.CONTINUE_EDITING_IN_THIS_CLIENT:{const f=Br(n==null?void 0:n.presenceState());s(J.CHECKING),await(n==null?void 0:n.track({onlineAt:f,pageId:o.current,userId:e,clientId:pe}));break}case X.TAKE_OVER_REJECTED:{r({type:X.TAKE_OVER_REJECTED});break}}},[a,r,s,n,e,l])},zr=()=>{const e=hn(),t=Pt(),n=xt(),s=Fr(),[r,a]=Q.useAtom(Xn),o=Qr(),l=Hr(),c=h.useRef(o),d=h.useRef(l),u=h.useRef(null),f=h.useRef(!1),E=h.useRef(0),m=h.useRef(r),T=h.useRef(()=>{});h.useEffect(()=>{c.current=o,d.current=l,m.current=r},[o,l,r]);const S=h.useCallback(w=>{Or.forEach(A=>{w.onBroadcast(A,v=>{c.current(A)(v)})}),kr.forEach(A=>{w.onPresence(A,()=>{d.current(w)})})},[]),x=h.useCallback(()=>{if(f.current||!e||!t||!s)return;if(E.current>=Je){console.error(`Maximum reconnection attempts (${Je}) reached. Stopping reconnection attempts.`);return}f.current=!0,E.current+=1,console.log(`Attempting to reconnect realtime channel (attempt ${E.current}/${Je})`),u.current&&(clearTimeout(u.current),u.current=null),m.current&&(m.current.unsubscribe(),a(null),m.current=null);const w=Math.min(qr*Math.pow(Kr,E.current-1),Vr);u.current=setTimeout(()=>{const A=e.channel(s,{config:{presence:{key:pe}}});S(A),A.subscribe(async v=>{v==="SUBSCRIBED"?(console.log("Realtime connection established successfully"),a(A),m.current=A,E.current=0,f.current=!1):v==="CHANNEL_ERROR"||v==="TIMED_OUT"?(console.log(`Realtime connection failed: ${v}. Attempt ${E.current}/${Je}`),E.current<Je?setTimeout(()=>{f.current=!1,T.current()},500):(console.error("Maximum reconnection attempts reached"),f.current=!1)):v==="CLOSED"&&(console.log("Realtime connection closed"),f.current=!1)})},w)},[e,t,s,a,S]);h.useEffect(()=>{T.current=x},[x]),h.useEffect(()=>{if(!e||!t||!s||r&&r.topic===s)return;E.current=0,f.current=!1;const w=e.channel(s,{config:{presence:{key:pe}}});return S(w),w.subscribe(async A=>{A==="SUBSCRIBED"?(console.log("Realtime connection established successfully"),a(w),m.current=w,E.current=0):A==="CHANNEL_ERROR"||A==="TIMED_OUT"?(console.log(`Realtime connection failed: ${A}. Will attempt to reconnect...`),f.current||x()):A==="CLOSED"&&console.log("Realtime connection closed")}),()=>{u.current&&(clearTimeout(u.current),u.current=null),f.current=!1,E.current=0,m.current===w&&(m.current=null),a(null),w.unsubscribe()}},[e,t,s,a,x,S]),h.useEffect(()=>{const w=()=>{if(document.visibilityState==="visible"){if(console.log("Tab became visible, checking realtime connection..."),!e||!t||!s){console.log("Required dependencies not available, skipping reconnection");return}if(f.current){console.log("Reconnection already in progress, skipping visibility change reconnect");return}m.current?m.current.getState()!=="JOINED"&&(console.log("Channel is not active, reconnecting..."),x()):(console.log("No active channel found, reconnecting..."),x())}};return document.addEventListener("visibilitychange",w),()=>{document.removeEventListener("visibilitychange",w)}},[e,t,s,x]),h.useEffect(()=>(r&&n&&t&&r.track({pageId:n,userId:t,clientId:pe,onlineAt:+new Date}),()=>{r&&n&&r.untrack()}),[r,n,t])},Vt=()=>{const{data:e}=Pe();return h.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},An=()=>{const e=k(),t=N();return P.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:n=>n||[]})},$r=e=>{const t=k(),n=N(),s=Vt();return P.useQuery({queryKey:[y.GET_WEBSITE_PAGES,e,s],staleTime:1e3*60*5,enabled:!!e,queryFn:async()=>{if(s===e)return{};const r=await t(n,{action:y.GET_WEBSITE_PAGES,data:{lang:e}})||[];return p.keyBy(p.map(r,a=>({...a,lang:e})),"primaryPage")},placeholderData:r=>r||{}})};function Sn(e,t,n=!1){const s=e.toString()?`?${e.toString()}`:"/";n?window.history.replaceState(null,"",s):window.history.pushState({},"",s),t(e),window.dispatchEvent(new PopStateEvent("popstate"))}const Wr=h.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-B90zLpRY.cjs"))),ns=({children:e})=>{const{t}=he.useTranslation(),[n,s]=ue(),r=n.get("page"),{data:a,isFetching:o}=ne(),{data:l,isFetching:c}=An(),[d,u]=h.useState(!1),[f,E]=h.useState(!0),{savePage:m}=g.useSavePage(),T=!!r&&!p.isEmpty(a),{isLocked:S}=ie(),x=h.useMemo(()=>{if(!l||c)return!1;const G=l.find(q=>q.slug==="/");return G==null?void 0:G.id},[l,c]);h.useEffect(()=>{if(c||!x||l.some(L=>L.id===r))return;const q=new URLSearchParams({page:x});Sn(q,s),!c&&l&&E(!1)},[r,c,l,x,s]);const w=!f&&!r,A=!f&&!o&&p.isEmpty(a),v=d||w||A;return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex items-center gap-x-1",children:i.jsx("div",{className:"relative",children:i.jsxs(g.Tooltip,{children:[i.jsx(g.TooltipTrigger,{asChild:!0,onClick:()=>{S||m(),u(!0)},children:e||i.jsx(I.Button,{variant:"outline",className:"flex w-full items-center space-x-2 py-1",children:i.jsx(b.LogsIcon,{className:"h-4 w-4"})},"template-viewer")}),i.jsx(g.TooltipContent,{side:"right",children:i.jsx("p",{children:t("Open pages manager")})})]})})}),i.jsx(g.Sheet,{open:v,onOpenChange:G=>!G&&T&&u(!1),children:i.jsxs(g.SheetContent,{side:"left","aria-describedby":"pages-manager-description",className:`z-50 !min-w-[50vh] !max-w-[800px] border-border p-0 ${T?"":"sheet-hide-close-btn"}`,children:[i.jsxs(g.SheetHeader,{className:"mb-3 px-4 pt-4",children:[i.jsxs(g.SheetTitle,{className:"flex items-center gap-2 text-sm font-semibold",children:[i.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:i.jsx(b.Folder,{className:"h-4 w-4"})}),i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"text-sm font-semibold",children:t("Pages")}),i.jsx("span",{id:"pages-manager-description",className:"text-xs font-normal text-muted-foreground",children:t("Manage your site structure")})]})]}),i.jsx(g.SheetDescription,{className:"sr-only",children:t("Manage your site structure")})]}),i.jsx("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:v&&i.jsx(h.Suspense,{children:i.jsx(Wr,{close:()=>u(!1)})})})]})})]})},Yr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-DbEBB3w7.cjs"))),Jr=h.lazy(()=>Promise.resolve().then(()=>require("./delete-page-D5mzl-ET.cjs"))),Zr=h.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-CEuF8dll.cjs"))),Xr=h.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-BH0W9p2G.cjs"))),ea=h.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-BYiyJloZ.cjs"))),ta=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-B0aY1JnO.cjs"))),na=()=>{const[e,t]=h.useState(null),[n,s]=h.useState(null),[r,a]=h.useState(null),[o,l]=h.useState(null),[c,d]=h.useState(null),[u,f]=h.useState(null),{data:E,isFetching:m}=ge(),{selectedLang:T,fallbackLang:S}=g.useLanguages(),{data:x}=Te(),w=x==null?void 0:x.find(L=>L.lang===T),{isLocked:A}=ie(),v=!(E!=null&&E.slug),G=Q.useSetAtom(rt);if(!E)return null;const q=L=>{T.length>0&&T!==S?G({edit:!0,id:L==null?void 0:L.id,primaryPage:L==null?void 0:L.primaryPage}):f(L)};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between rounded px-[2px] transition-colors duration-200",children:[i.jsx(ns,{children:i.jsx(I.Button,{className:"flex h-7 max-w-[200px] cursor-pointer items-center truncate rounded px-1 text-xs font-medium",variant:"ghost",children:m?i.jsx(b.Loader,{className:"h-4 w-4 animate-spin text-slate-400"}):i.jsxs("span",{className:"flex w-full cursor-pointer items-end overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-xs font-medium",children:[v?i.jsx(b.Hash,{className:"mr-1 h-4 w-4"}):i.jsx(b.File,{className:"mr-1 h-4 w-4"}),p.get(w||E,"name")??""]})})}),A?i.jsx(I.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 cursor-not-allowed rounded opacity-50 hover:bg-transparent",children:i.jsx(b.MoreHorizontal,{className:"h-4 w-4"})}):i.jsx(Zn,{page:E,setDuplicatePage:L=>d(L),setAddEditPage:L=>q(L),setUnpublishPage:L=>s(L),setDeletePage:L=>t(L),setMarkAsTemplate:L=>a(L),setUnmarkAsTemplate:L=>l(L),isLanguagePage:T.length>0&&T!==S,children:i.jsx(I.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:i.jsx(b.MoreHorizontal,{className:"h-4 w-4"})})})]}),u&&i.jsx(h.Suspense,{children:i.jsx(Yr,{closePanel:()=>f(null),editPage:()=>{},addEditPage:u,setAddEditPage:f})}),e&&i.jsx(h.Suspense,{children:i.jsx(Jr,{page:e,onClose:()=>t(null)})}),n&&i.jsx(h.Suspense,{children:i.jsx(ta,{page:n,onClose:()=>s(null)})}),r&&i.jsx(h.Suspense,{children:i.jsx(Xr,{page:r,onClose:()=>a(null)})}),o&&i.jsx(h.Suspense,{children:i.jsx(ea,{page:o,onClose:()=>l(null)})}),c&&i.jsx(h.Suspense,{children:i.jsx(Zr,{page:c,onClose:()=>d(null),closePanel:()=>f(null)})})]})},Ht=({children:e,className:t=""})=>i.jsx("div",{className:Gt.cn("fixed bottom-0 left-0 right-0 top-[50px] z-[20] flex w-screen flex-col items-center justify-center bg-black/40 transition-all",t),children:e}),sa=({hasDynamicPage:e})=>i.jsx(Ht,{children:i.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:[i.jsx("h1",{className:"text-lg font-medium",children:e?"Select a page":"No pages found"}),i.jsx("p",{className:"pt-2 text-center text-sm font-light text-gray-600",children:e?"Please select a page from the list in the top header. This will enable you to edit the page.":"Please add a new page"})]})}),Ze={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"},ra=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-B2BEmfil.cjs"))),aa=()=>{const e=ae("topLeftCorner",null);return e?i.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:h.createElement(e,{})}):null},ss=({showAdd:e=!0,variant:t="ghost",goToDefaultLang:n=!1})=>{const{fallbackLang:s,languages:r,selectedLang:a,setSelectedLang:o}=g.useLanguages(),l=p.isEmpty(a)?s:a,[,c]=ue(),{isLocked:d}=ie(),{t:u}=he.useTranslation();h.useEffect(()=>{const A=new URLSearchParams(window.location.search),v=A.get("lang");v&&(r.includes(v)?o(v):(A.delete("lang"),c(A),o("")))},[r,c,o]);const f=Q.useSetAtom(rt),{data:E}=ne(),{data:m}=Pe(),{data:T}=Te(),S=h.useMemo(()=>{const A=p.compact(p.map(p.get(m,"languages"),v=>{const G=p.find(T,{lang:v});return{key:v,value:p.get(Ze,v,v),isLangPageAdded:!!G}})).filter(Boolean);return[{key:s,value:p.get(Ze,s),isLangPageAdded:!0},...A]},[s,T,m]),x=A=>{if(document.querySelector('[data-panel-id="seo"]')){const G=new CustomEvent("seo-language-switch-check",{detail:{fromLang:l,toLang:A,switchHandler:()=>w(A)}});window.dispatchEvent(G);return}w(A)},w=A=>{o(A);const v=new URLSearchParams(window.location.search);A===s?v.delete("lang"):v.set("lang",A),Sn(v,c)};return p.isEmpty(r)?null:d?i.jsxs(I.Button,{variant:"ghost",size:"sm",className:"ml-px h-max cursor-not-allowed gap-2 py-1.5 opacity-50",children:[i.jsx(b.Languages,{className:"h-4 w-4"}),p.get(Ze,l,l),i.jsx(b.ChevronDown,{className:"h-4 w-4"})]}):n?i.jsx(I.Button,{onClick:()=>w(s),variant:"link",size:"sm",children:u("Switch to default language")}):i.jsx(i.Fragment,{children:i.jsxs(g.DropdownMenu,{children:[i.jsx(g.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:i.jsxs(I.Button,{disabled:!!d,variant:t,size:"sm",className:"ml-px h-max gap-2 py-1.5",children:[i.jsx(b.Languages,{className:"h-4 w-4"}),p.get(Ze,l,l),i.jsx(b.ChevronDown,{className:"h-4 w-4"})]})}),i.jsxs(g.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(S.filter(A=>A.isLangPageAdded),A=>i.jsxs(g.DropdownMenuItem,{className:Gt.cn("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",A.key===l&&"!bg-gray-200 text-gray-700"),onClick:()=>x(A.key),children:[i.jsx("div",{className:"text-slate-600",children:A.value}),A.key===s&&i.jsxs("small",{className:"flex items-center gap-x-1 text-[9px] leading-none text-orange-500",children:[i.jsx(b.Star,{fill:"orange",className:"h-2 w-2"}),"Primary"]})]},A.value)),e&&!p.isEmpty(S.filter(A=>!A.isLangPageAdded))&&i.jsxs(i.Fragment,{children:[i.jsx(g.Separator,{}),i.jsxs(I.Button,{size:"sm",variant:"ghost",onClick:()=>{E&&f({edit:!1,primaryPage:E.id})},className:"text-xs font-normal duration-200 hover:bg-slate-300 hover:text-slate-800",children:[i.jsx(b.Plus,{className:"mr-1 h-3 w-3"})," Add Language"]})]})]})]})})};function ia(){const e=Q.useAtomValue(rt),t=Q.useSetAtom(rt);return i.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[i.jsx(aa,{}),i.jsx(ns,{}),e&&i.jsx(h.Suspense,{children:i.jsx(ra,{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 oa(){return i.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((e,t)=>i.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[i.jsxs("div",{className:"flex-1 space-y-1",children:[i.jsx(g.Skeleton,{className:"h-4 w-3/4"}),i.jsx(g.Skeleton,{className:"h-3 w-1/2"}),i.jsx(g.Skeleton,{className:"mt-1 h-5 w-20"})]}),i.jsx(g.Skeleton,{className:"h-8 w-8 rounded-full"})]},t))})}const la=z.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-CVpi-467.cjs")));function ca(){const[e,t]=z.useState(!1);return i.jsx(g.TooltipProvider,{children:i.jsxs(g.Tooltip,{delayDuration:0,children:[i.jsxs(g.Sheet,{open:e,onOpenChange:t,children:[i.jsx(g.SheetTrigger,{asChild:!0,children:i.jsx(g.TooltipTrigger,{asChild:!0,children:i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsxs(I.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[i.jsx(b.History,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"View revision history"})]}),i.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})})}),i.jsx(g.SheetContent,{className:"flex h-[100vh] flex-col",children:e&&i.jsx(h.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(la,{isOpen:e})})})]}),i.jsx(g.TooltipContent,{side:"bottom",children:i.jsx("p",{children:"Revision history"})})]})})}const It=({permission:e,permissions:t,children:n,fallback:s=null})=>{const{hasPermission:r}=g.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?s:n},ua={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},da=()=>{const e=N(),t=P.useQueryClient(),n=k(),{data:s}=me();return P.useMutation({mutationFn:async r=>await n(e,{action:y.CREATE_PAGE,data:r}),onSuccess:(r,a)=>{var l;a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES,a==null?void 0:a.lang]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const o=a.template?`Page created from "${a.template.name}" template`:a.hasSlug===!1?"New "+((l=p.find(s,{key:a.pageType}))==null?void 0:l.name)+" added successfully":"New page added successfully";F.toast.success(o)},onError:(r,a)=>{const o=p.find(s,{key:a.pageType});F.toast.error(`Failed to add new ${o!=null&&o.hasSlug?"page":o.name}.`,{description:p.get(ua,r.message,r.message)})}})},fa=()=>{const e=N(),t=P.useQueryClient(),n=k(),{data:s}=ge(),{data:r}=me();return P.useMutation({mutationFn:async a=>await n(e,{action:y.UPDATE_PAGE,data:a}),onSuccess:(a,o)=>{(s==null?void 0:s.id)===(o==null?void 0:o.id)&&t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]}),o&&(o!=null&&o.primaryPage||o!=null&&o.seo)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,o==null?void 0:o.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(a,o)=>{const l=p.find(r,{key:o.pageType});F.toast.error(`Failed to update ${l!=null&&l.hasSlug?"page":l.name}.`,{description:a.message})}})},ha=()=>{const e=N(),t=P.useQueryClient(),n=k(),{data:s}=me();return P.useMutation({mutationFn:async r=>n(e,{action:y.DELETE_PAGE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{if(r.code==="PAGE_LOCKED"){F.toast.error("Delete not allowed",{description:"Page is currently being edited by another user."});return}a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(r,a)=>{const o=p.find(s,{key:a.pageType});F.toast.error(`Failed to delete ${o!=null&&o.hasSlug?"page":o.name}.`,{description:r.message})}})},ga=()=>{const e=N(),t=P.useQueryClient(),n=k(),{data:s}=me();return P.useMutation({mutationFn:async r=>n(e,{action:y.TAKE_OFFLINE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const o=p.find(s,{key:a.pageType});F.toast.success(o!=null&&o.hasSlug?"Page unpublished successfully.":"New "+o.name+" added successfully.")},onError:(r,a)=>{const o=p.find(s,{key:a.pageType});F.toast.error(`Failed to take offline ${o!=null&&o.hasSlug?"page":o.name}.`,{description:r.message})}})},Tn=()=>{const e=N(),t=k(),n=P.useQueryClient(),{data:s}=ne(),{savePageAsync:r}=g.useSavePage();return P.useMutation({mutationFn:async({ids:a})=>(await r(),t(e,{action:y.PUBLISH_CHANGES,data:{ids:a}})),onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_CHANGES]}),n.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),n.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,s==null?void 0:s.id]})},onError:a=>{console.log("##",a),F.toast.error("Failed to publish pages.")}})},ma=()=>{const e=N(),t=k(),n=P.useQueryClient();return P.useMutation({mutationFn:async s=>{var r;return t(e,{action:y.MARK_AS_TEMPLATE,data:{id:(r=s.page)==null?void 0:r.id,name:s.name,description:s.description,pageType:s.pageType,previewImage:s.previewImage}})},onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page marked as template successfully.")},onError:()=>{F.toast.error("Failed to mark page as template.")}})},Ea=()=>{const e=N(),t=k(),n=P.useQueryClient();return P.useMutation({mutationFn:async s=>t(e,{action:y.UNMARK_AS_TEMPLATE,data:{id:s==null?void 0:s.id}}),onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page unmarked as template successfully.")},onError:()=>{F.toast.error("Failed to unmark page as template.")}})},pa=()=>{const e=N(),t=k(),n=P.useQueryClient();return P.useMutation({mutationFn:async({id:s,slug:r})=>t(e,{action:y.CHANGE_SLUG,data:{id:s,slug:r}}),onSuccess:(s,{primaryPage:r})=>{F.toast.success("Slug changed successfully."),r?n.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,r]}):n.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:()=>{F.toast.error("Failed to change slug")}})},ya=h.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-BG1GIuIz.cjs")));function Aa({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:n,isPending:s}=Tn();return i.jsx(g.Dialog,{open:e,onOpenChange:s?()=>{}:t,children:e&&i.jsx(h.Suspense,{fallback:i.jsx("div",{className:"h-96 w-96 animate-pulse bg-gray-100"}),children:i.jsx(ya,{onClose:t,isPending:s,publishPage:n})})})}const rs=e=>{const{fallbackLang:t}=g.useLanguages(),{data:n}=Pe(),{data:s,isFetching:r}=Te(),a=h.useMemo(()=>{const o={[t]:!0};return p.each(p.get(n,"languages"),l=>{const c=p.find(s,{lang:l});o[l]=!!c}),o},[t,s,n]);return r||p.isEmpty(e)||e&&a[e]},Sa={particleCount:350,spread:120,origin:{y:.6},angle:90},Ta={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},Pa=async()=>{const{default:e}=await import("canvas-confetti");return e},Nt=e=>{let t=Ta[e];t||(t={});const n={...Sa,...t};Pa().then(s=>s(n))};function Qt({children:e,content:t,side:n="bottom",delayDuration:s=700,showTooltip:r=!0}){return r?i.jsx(g.TooltipProvider,{children:i.jsxs(g.Tooltip,{delayDuration:s,children:[i.jsx(g.TooltipTrigger,{asChild:!0,children:e}),i.jsx(g.TooltipContent,{side:n,sideOffset:10,children:i.jsx("p",{children:t})})]})}):e}const xa=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-B0aY1JnO.cjs"))),_a=h.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-ChL7oDO1.cjs"))),wa=h.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-BjCIlzd7.cjs"))),va=()=>{const{t:e}=he.useTranslation(),{selectedLang:t,fallbackLang:n}=g.useLanguages(),s=ae("getPreviewUrl",async E=>E),[r,a]=h.useState(""),{data:o}=ne(),{data:l}=Te(),{data:c}=me(),d=h.useMemo(()=>{var E;return(E=l==null?void 0:l.find(m=>(m==null?void 0:m.lang)===t))==null?void 0:E.slug},[t,l]),u=h.useCallback(E=>{var m;return(m=p.find(c,{key:E}))==null?void 0:m.hasSlug},[c]),f=t===n?"":t;return h.useEffect(()=>{(async()=>{if(typeof s=="function"){const E=!u(o==null?void 0:o.pageType),m=await s(E?`/_partial/${f!==""?f+"/":""}${o==null?void 0:o.id}`:d||"");a(m)}else a("")})()},[s,d,o==null?void 0:o.pageType,u,o==null?void 0:o.id,f]),i.jsx(i.Fragment,{children:i.jsx(Qt,{content:e("Open preview in new tab"),delayDuration:0,children:i.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:i.jsx(I.Button,{variant:"ghost",size:"sm",className:"gap-2",children:i.jsx(b.Play,{className:"h-4 w-4"})})})})})},ba=()=>{const{t:e}=he.useTranslation(),[t,n]=g.useRightPanel();return i.jsxs(i.Fragment,{children:[i.jsx(Qt,{content:e("Theme"),delayDuration:0,children:i.jsx(I.Button,{variant:t==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>n(t==="theme"?"block":"theme"),children:i.jsx(b.Palette,{className:"h-4 w-4"})})}),i.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})},Ca=()=>{const{t:e}=he.useTranslation(),[t,n]=h.useState(!1),{isLocked:s}=ie(),{savePageAsync:r,saveState:a}=g.useSavePage();h.useEffect(()=>{const u=f=>{a==="UNSAVED"&&(f.preventDefault(),f.returnValue=!1)};return a==="UNSAVED"&&window.addEventListener("beforeunload",u),()=>{window.removeEventListener("beforeunload",u)}},[a]);const o=h.useCallback(async()=>{t||(n(!0),await r(),n(!1))},[r,t]),{buttonIcon:l,buttonClass:c,tooltipContent:d}=h.useMemo(()=>{switch(a){case"UNSAVED":return{tooltipContent:e("Save draft"),buttonIcon:i.jsx(b.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:e("Saving"),buttonIcon:i.jsx(b.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:e("Saved"),buttonIcon:i.jsx(b.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[a,e]);return s?null:i.jsxs(I.Button,{size:"sm",variant:"ghost",onClick:o,className:`${c} w-24 max-w-24`,children:[l," ",d]})},Ia=()=>{const{t:e}=he.useTranslation(),{selectedLang:t}=g.useLanguages(),{data:n}=ge(),{data:s}=Te(),[r,a]=h.useState(!1),[o,l]=h.useState(!1),[c,d]=h.useState(null),[u,f]=h.useState(!1),{savePageAsync:E}=g.useSavePage(),[m,T]=h.useState(!1),{data:S}=ne(),{mutate:x,isPending:w}=Tn(),{needTranslations:A}=g.useSavePage(),v=A(),{buttonText:G,buttonClassName:q,isPublished:L,hasUnpublishedChanges:oe}=h.useMemo(()=>{const K=S&&(S==null?void 0:S.online),ee=!p.isEmpty(S==null?void 0:S.changes);let xe=K?"hover:bg-green-600 bg-green-500":"",se=e(K?"Published":"Publish");return K&&ee&&(xe="hover:bg-blue-600 bg-blue-500",se=e("Publish")),{buttonClassName:xe,isPublished:K,hasUnpublishedChanges:ee,buttonText:se}},[S,e]),de=async()=>{if(v){T(!0);return}V()},V=()=>{const K=[n==null?void 0:n.id,n==null?void 0:n.primaryPage];x({ids:p.compact(K)},{onSuccess:()=>Nt("TOP_RIGHT")})},j=()=>{T(!1),V()},O=async()=>{T(!1),await E()},$=h.useMemo(()=>p.map(s??[],"id"),[s]);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex",children:[i.jsxs(I.Button,{size:"sm",onClick:de,disabled:w||!(S!=null&&S.id),className:`relative flex items-center gap-1 overflow-hidden rounded-r-none text-white transition-all duration-300 ease-in-out ${q}`,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[i.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${o?"-translate-y-10":""}`,children:L?oe?i.jsx(b.Pencil,{className:"h-4 w-4"}):i.jsx(b.Send,{className:"h-4 w-4"}):i.jsx(b.Rocket,{className:"h-4 w-4"})}),i.jsx("span",{className:`absolute inset-0 left-3 flex items-center transition-transform duration-300 ease-in-out ${o?"":"translate-y-10"}`,children:L?i.jsx(b.Rocket,{className:"h-4 w-4"}):i.jsx(b.Send,{className:"h-4 w-4"})}),i.jsx("span",{children:G}),t?`(${p.upperCase(t)})`:""]}),i.jsxs(g.DropdownMenu,{children:[i.jsx(g.DropdownMenuTrigger,{asChild:!0,children:i.jsx(I.Button,{size:"sm",disabled:w||!(S!=null&&S.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${q}`,children:i.jsx(b.ChevronDown,{className:"h-4 w-4"})})}),i.jsxs(g.DropdownMenuContent,{align:"end",className:"w-52",children:[i.jsxs(g.DropdownMenuItem,{disabled:w,className:"cursor-pointer text-xs",onClick:()=>x({ids:$},{onSuccess:()=>Nt("TOP_RIGHT")}),children:[e("Publish")," with translation pages"]}),!L&&i.jsxs(g.DropdownMenuItem,{disabled:w,className:"cursor-pointer text-xs",onClick:()=>x({ids:[S==null?void 0:S.id]},{onSuccess:()=>Nt("TOP_RIGHT")}),children:[e("Publish")," page"]}),i.jsxs(g.DropdownMenuItem,{onClick:()=>a(!0),className:"cursor-pointer text-xs",children:[e("Open")," publish menu"]}),L&&oe&&i.jsx(g.DropdownMenuItem,{onClick:()=>f(!0),className:"cursor-pointer text-xs",children:e("View Unpublished changes")}),L&&i.jsxs(g.DropdownMenuItem,{onClick:()=>d(n),className:"cursor-pointer text-xs",children:[e("Unpublish")," page ",t?`(${p.upperCase(t)})`:""]})]})]})]}),i.jsx(Aa,{showModal:r,onClose:()=>a(!1)}),c&&i.jsx(h.Suspense,{children:i.jsx(xa,{page:c,onClose:()=>d(null)})}),u&&i.jsx(h.Suspense,{children:i.jsx(wa,{open:u,onOpenChange:f,compare:[{label:"draft",uid:`draft:${S==null?void 0:S.id}`,item:S},{label:"live",uid:`live:${S==null?void 0:S.id}`,item:{}}]})}),m&&i.jsx(h.Suspense,{children:i.jsx(_a,{isOpen:m,onClose:O,onContinue:j,isPending:w})})]})};function Na(){const{isLocked:e}=ie(),[t]=ue(),n=t.get("lang"),s=rs(n);return e||!s?i.jsx("div",{}):i.jsxs("div",{className:"flex items-center justify-end gap-1",children:[i.jsx(ca,{}),i.jsx(It,{permission:re.EDIT_THEME,children:i.jsx(ba,{})}),i.jsx(va,{}),i.jsx(It,{permission:re.SAVE_PAGE,children:i.jsx(Ca,{})}),i.jsx(It,{permission:re.PUBLISH_PAGE,children:i.jsx(Ia,{})})]})}const La=h.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-D4EWs4Qd.cjs"))),ja=()=>{const{dynamicPage:e,allLangPages:t,isFetching:n}=Yn(),s=t.length>0;return n?null:i.jsxs("div",{className:"relative",children:[!e&&i.jsx(sa,{hasDynamicPage:s}),i.jsx(h.Suspense,{children:i.jsx(La,{})})]})},Ga=()=>{const{data:e,isFetching:t}=ge(),{data:n,isFetching:s}=ne(),r=p.get(n,"dynamic",!1),a=gn(),o=I.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,d=jr(),u=t||s,E=(c?`Partial: ${e==null?void 0:e.name} `:`${l}${a}`).replace(window.location.host,"");return i.jsxs("div",{className:"relative flex items-center",children:[i.jsx("div",{className:Gt.cn("flex h-8 w-auto max-w-[600px] items-center rounded-l-md border border-r-0 border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800",u&&"max-w-0 overflow-hidden opacity-0"),children:i.jsx(na,{})}),i.jsxs("div",{className:Gt.cn("flex h-8 w-auto max-w-[600px] items-center rounded-r-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800"+(c?" pr-2":""),u&&"max-w-0 overflow-hidden opacity-0"),children:[i.jsx(ss,{}),i.jsxs("div",{className:"flex w-full items-center overflow-hidden",children:[i.jsx("div",{className:`w-full max-w-[200px] overflow-hidden overflow-ellipsis whitespace-nowrap pl-1 text-xs ${c?"italic text-gray-400":"font-mono text-gray-500"}`,children:E==="/"?i.jsxs("span",{className:"text-gray-900",children:["/",i.jsx("span",{className:"text-[11px] font-light italic text-gray-400",children:"(Homepage)"})]}):E}),!c&&i.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",children:i.jsx("div",{className:"ml-2 mr-px flex-shrink-0 rounded-sm p-1.5 text-gray-500 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300",children:i.jsx(b.ExternalLink,{className:"h-4 w-4",strokeWidth:1})})})]})]}),r&&o&&i.jsx(ja,{})]})},ka=()=>i.jsxs("div",{className:"grid h-full w-full grid-cols-3 items-center px-2",children:[i.jsx("div",{className:"flex justify-start",children:i.jsx(ia,{})}),i.jsx("div",{className:"flex justify-center",children:i.jsx(Ga,{})}),i.jsx("div",{className:"flex justify-end",children:i.jsx(Na,{})})]}),as=()=>{const e=P.useQueryClient(),{data:t}=P.useQuery({queryKey:[y.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:h.useCallback(s=>{e.setQueryData([y.AI_CONTEXT],s)},[e]),aiContext:t}},Oa=()=>{const e=N(),{aiContext:t}=as(),n=k();return h.useCallback(async(s,r,a,o)=>n(e,{action:y.ASK_AI,data:{type:s,prompt:r,blocks:a,context:t,lang:o}}),[e,t,n])},Ra=e=>h.useMemo(()=>{if(!e||p.isEmpty(e))return{blocks:[]};const t=p.filter(e,n=>!p.includes(n==null?void 0:n._type,"@chai/"));return{blocks:Ar.syncBlocksWithDefaultProps(t)}},[e]),Da=()=>{const[e]=ue(),t=e.get("page"),n=N(),{setAiContext:s}=as(),[,r]=mn(),[,a]=Lr(),[,o]=g.useIsPageLoaded(),l=k();return P.useQuery({queryKey:[y.GET_DRAFT_PAGE,t],staleTime:1/0,gcTime:0,queryFn:async()=>{o(!1);const c=await l(n,{action:y.GET_DRAFT_PAGE,data:{id:t,draft:!0}}),d=c.blocks??[],u=p.find(d,{_type:"@chai/ai-context"});return s(p.get(u,"_value","")||""),r(f=>({...f,lastSaved:c.lastSaved})),a(p.get(c,"metadata",{})),setTimeout(()=>o(!0),500),d},enabled:!!t})},is=()=>{const{data:e}=ne(),{data:t}=ge(),n=N(),s=k(),r=Vt(),a=gn();return P.useQuery({queryKey:[y.GET_BUILDER_PAGE_DATA,t==null?void 0:t.id,a],staleTime:1/0,gcTime:0,queryFn:async()=>s(n,{action:y.GET_BUILDER_PAGE_DATA,data:{pageType:e==null?void 0:e.pageType,lang:(t==null?void 0:t.lang)||r,dynamic:e==null?void 0:e.dynamic,pageProps:{slug:(t==null?void 0:t.slug)+a,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:r,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id,metadata:e.metadata||{}}}}),enabled:!!(e!=null&&e.pageType)&&!!t.id})},os=()=>{const e=N(),t=P.useQueryClient(),n=k();return P.useMutation({mutationFn:async s=>n(e,{action:y.UPDATE_WEBSITE_FIELDS,data:s}),onSuccess:(s,r)=>{var a;t.invalidateQueries({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS]}),(a=r==null?void 0:r.settings)!=null&&a.theme||F.toast.success("Website settings updated successfully.")},onError:s=>{F.toast.error("Failed to update website settings",{description:s.message})}})},Ma=()=>{const e=N(),t=P.useQueryClient(),n=k(),{selectedLang:s}=g.useLanguages();return P.useMutation({mutationFn:async r=>n(e,{action:y.ADD_GLOBAL_SCHEMA,data:{...r,lang:s}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema added successfully.")},onError:r=>{F.toast.error("Failed to add schema",{description:r.message})}})},Ua=()=>{const e=N(),t=P.useQueryClient(),n=k(),{selectedLang:s}=g.useLanguages();return P.useMutation({mutationFn:async r=>n(e,{action:y.UPDATE_GLOBAL_SCHEMA,data:{...r,lang:s}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema updated successfully.")},onError:r=>{F.toast.error("Failed to update schema",{description:r.message})}})},Ba=()=>{const e=N(),t=P.useQueryClient(),n=k();return P.useMutation({mutationFn:async s=>n(e,{action:y.DELETE_GLOBAL_SCHEMA,data:{id:s}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema deleted successfully.")},onError:s=>{F.toast.error("Failed to delete schema",{description:s.message})}})},Fa=()=>{const e=N(),t=k();return P.useMutation({mutationFn:async n=>t(e,{action:y.TOGGLE_PAGE_GLOBAL_SCHEMA,data:n}),onError:n=>{F.toast.error("Failed to toggle schema",{description:n.message})}})},qa=()=>{const e=N(),t=k();return P.useMutation({mutationFn:async n=>t(e,{action:y.APPLY_SCHEMA_TO_ALL_PAGES,data:{schemaId:n}}),onSuccess:n=>{F.toast.success(`Schema applied to ${n.count} page(s)`)},onError:n=>{F.toast.error("Failed to apply schema to all pages",{description:n.message})}})},Ka=()=>{const e=N(),t=k();return P.useMutation({mutationFn:async n=>t(e,{action:y.REMOVE_SCHEMA_FROM_ALL_PAGES,data:{schemaId:n}}),onSuccess:n=>{F.toast.success(`Schema removed from ${n.count} page(s)`)},onError:n=>{F.toast.error("Failed to remove schema from all pages",{description:n.message})}})},kn={async getUILibraryBlock(e,t,n){const s=await t(n,{action:"GET_LIBRARY_ITEM",data:{id:e.id}}),r=p.get(s,"html",""),a=p.get(s,"blocks",[]);return p.isArray(a)?a:Sr.getBlocksFromHTML(r)},async getUILibraryBlocks(e,t,n){return(await t(n,{action:"GET_LIBRARY_ITEMS",data:{id:e.id}})).map(r=>({...r}))}},Va=()=>{const e=N(),t=k();return P.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const s=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return s.forEach(r=>{I.registerChaiLibrary(r.id,{name:r.isSiteLibrary?r.name+" (Current Site) ":r.name,description:r.description,getBlocksList:a=>kn.getUILibraryBlocks(a,t,e),getBlock:({block:a})=>kn.getUILibraryBlock(a,t,e)})}),s}})},Ha=(e=300)=>{const t=ae("onLogout",p.noop),n=ae("getAccessToken"),s=N();return P.useQuery({queryKey:["check-user-access"],queryFn:async()=>{const r=await n(),o=await $n(s+"?action=check_user_access",{action:"CHECK_USER_ACCESS"},{Authorization:`Bearer ${r}`});if(o.status===401)throw console.log("401 Response",o),F.toast.error("You do not have access to edit this website. Please contact administrator"),await t("UNAUTHORIZED"),new Error("Unauthorized");return o},refetchInterval:e*1e3,refetchIntervalInBackground:!0,retry:!1})},ls=()=>{const e=N(),t=k(),{user:n}=Kt(),s=n==null?void 0:n.id;return P.useQuery({queryKey:[y.GET_ROLE_AND_PERMISSIONS,s],queryFn:()=>t(e,{action:y.GET_ROLE_AND_PERMISSIONS,data:{}}),enabled:!!s,staleTime:1/0})},Qa=()=>{const e=N(),t=k(),[,n]=mn(),s=P.useQueryClient();return{onSave:async({page:a,blocks:o,needTranslations:l})=>{try{const c=await t(e,{action:"UPDATE_PAGE",data:{id:a,blocks:o,needTranslations:l}});return c.code==="PAGE_LOCKED"?!0:(n(d=>({...d,lastSaved:new Date().toISOString()})),s.setQueryData([y.GET_LANGUAGE_PAGES,a],d=>d&&(d==null?void 0:d.map(u=>(u==null?void 0:u.id)===a?{...u,changes:["Page"]}:u))),s.setQueryData([y.GET_WEBSITE_PAGES],d=>d&&(d==null?void 0:d.map(u=>(u==null?void 0:u.id)===a?{...u,changes:["Page"]}:u))),c)}catch(c){return console.error(c),new Error("Failed to save blocks")}}}},za=()=>{const{data:e}=An(),t=N(),n=k();return{getPartialBlocks:h.useCallback(async()=>{const s={};for(const r of e??[])p.isEmpty(r==null?void 0:r.slug)&&(s[r.id]={type:r.pageType,name:p.startCase(r.name??r.slug),description:""});return s},[e]),getPartialBlockBlocks:h.useCallback(async s=>{if(!s)return[];try{const r=await n(t,{action:"GET_DRAFT_PAGE",data:{id:s,draft:!0,editor:!1,mergePartials:!0}});return p.filter(r.blocks,a=>p.has(a,"_id"))}catch(r){return console.error(r),[]}},[n,t])}},$a=h.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-content-Bf_ojKwt.cjs"))),cs="chai-chat-panel",Wa=({className:e="h-full w-full"})=>i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",version:"1.1",className:e,children:[i.jsx("title",{children:"ai"}),i.jsx("g",{id:"Page-1",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:i.jsx("g",{id:"icon",fill:"currentColor",transform:"translate(64.000000, 64.000000)",children:i.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"})})})]}),Ya=({isActive:e,show:t})=>g.useBuilderProp("flags.ai",!1)?i.jsx(I.Button,{size:"icon",className:"p-0 [&_svg]:size-6",onClick:t,variant:e?"default":"ghost",children:i.jsx(Wa,{className:e?"h-5 w-5 text-white":"h-5 w-5 text-primary"})}):null,Ja={id:cs,label:"AI Assistant",button:Ya,panel:$a,position:"top"},Za=h.lazy(()=>Promise.resolve().then(()=>require("./lang-panel--yfjRDE2.cjs"))),Xa=({isActive:e,show:t})=>{const{data:n}=Pe();return!p.has(n,"languages")||!p.get(n,"languages",[]).length?null:i.jsx(I.Button,{size:"sm",onClick:t,variant:e?"default":"ghost",children:i.jsx(b.LanguagesIcon,{className:"h-4 w-4"})})},us="lang",ei={id:us,label:"Languages",position:"top",panel:Za,button:Xa,view:"modal",width:400},ti=h.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-D9wnaLG-.cjs"))),ds="seo",ni=({isActive:e,show:t})=>{const{data:n}=ne(),s=Jn(n==null?void 0:n.pageType);return!p.has(s,"hasSlug")||!s.hasSlug?null:i.jsx(I.Button,{size:"icon",className:"my-1 p-0",onClick:t,variant:e?"default":"ghost",children:i.jsxs("svg",{stroke:"currentColor",fill:"none",style:{height:"20px",width:"20px"},strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",children:[i.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"}),i.jsx("path",{d:"M14 16h-4v-8h4"}),i.jsx("path",{d:"M11 12h2"}),i.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"})]})})},si={id:ds,label:"SEO",panel:ti,button:ni,position:"top",width:600,view:"modal"},fs="user-info",ri=()=>{const{t:e}=he.useTranslation(),{user:t,logout:n}=Kt(),s=ae("onLogout",p.noop);return t?i.jsxs(g.HoverCard,{children:[i.jsx(g.HoverCardTrigger,{asChild:!0,children:i.jsx(I.Button,{variant:"ghost",className:"text-sm font-medium",children:i.jsx(b.User,{className:"h-4 w-4"})})}),i.jsxs(g.HoverCardContent,{className:"w-auto space-y-2 p-4",children:[i.jsx("div",{className:"text-sm font-medium",children:t.name??t.email}),i.jsx("div",{className:"text-xs text-muted-foreground",children:t.email}),i.jsxs(g.AlertDialog,{children:[i.jsx(g.AlertDialogTrigger,{asChild:!0,children:i.jsx(I.Button,{variant:"outline",size:"sm",className:"w-full",children:e("Logout")})}),i.jsxs(g.AlertDialogContent,{children:[i.jsxs(g.AlertDialogHeader,{children:[i.jsx(g.AlertDialogTitle,{children:e("Are you sure you want to logout?")}),i.jsx(g.AlertDialogDescription,{children:e("You will be redirected to the login page.")})]}),i.jsxs(g.AlertDialogFooter,{children:[i.jsx(g.AlertDialogCancel,{children:e("Cancel")}),i.jsx(g.AlertDialogAction,{onClick:()=>{n(),p.isFunction(s)&&s()},children:e("Logout")})]})]})]})]})]}):null},ai={id:fs,label:"User Info",button:ri,position:"bottom"},ii=()=>{I.registerChaiSidebarPanel(ds,si),I.registerChaiSidebarPanel(us,ei),I.registerChaiSidebarPanel(fs,ai),I.registerChaiSidebarPanel(cs,Ja)};var C={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return On(this.context.count)},getNextContextId(){return On(this.context.count++)}};function On(e){const t=String(e),n=t.length-1;return C.context.id+(n?String.fromCharCode(96+n):"")+t}function Xe(e){C.context=e}var hs=!1,oi=(e,t)=>e===t,kt=Symbol("solid-proxy"),gs=typeof Proxy=="function",Pn=Symbol("solid-track"),Ot={equals:oi},ms=xs,Ee=1,Rt=2,Es={owned:null,cleanups:null,context:null,owner:null},Xt={},D=null,en=null,li=null,U=null,Z=null,fe=null,zt=0;function ye(e,t){const n=U,s=D,r=e.length===0,a=t===void 0?s:t,o=r?Es:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>Y(()=>at(o)));D=o,U=null;try{return ce(l,!0)}finally{U=n,D=s}}function H(e,t){t=t?Object.assign({},Ot,t):Ot;const n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},s=r=>(typeof r=="function"&&(r=r(n.value)),Ps(n,r));return[Ts.bind(n),s]}function ps(e,t,n){const s=$t(e,t,!0,Ee);Ye(s)}function Ae(e,t,n){const s=$t(e,t,!1,Ee);Ye(s)}function xn(e,t,n){ms=Ti;const s=$t(e,t,!1,Ee);(!n||!n.render)&&(s.user=!0),fe?fe.push(s):Ye(s)}function W(e,t,n){n=n?Object.assign({},Ot,n):Ot;const s=$t(e,t,!0,0);return s.observers=null,s.observerSlots=null,s.comparator=n.equals||void 0,Ye(s),Ts.bind(s)}function ci(e){return e&&typeof e=="object"&&"then"in e}function ui(e,t,n){let s,r,a;s=!0,r=e,a={};let o=null,l=Xt,c=null,d=!1,u="initialValue"in a,f=typeof s=="function"&&W(s);const E=new Set,[m,T]=(a.storage||H)(a.initialValue),[S,x]=H(void 0),[w,A]=H(void 0,{equals:!1}),[v,G]=H(u?"ready":"unresolved");C.context&&(c=C.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:C.load&&C.has(c)&&(l=C.load(c)));function q(j,O,$,K){return o===j&&(o=null,K!==void 0&&(u=!0),(j===l||O===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(K,{value:O})),l=Xt,L(O,$)),O}function L(j,O){ce(()=>{O===void 0&&T(()=>j),G(O!==void 0?"errored":u?"ready":"unresolved"),x(O);for(const $ of E.keys())$.decrement();E.clear()},!1)}function oe(){const j=yi,O=m(),$=S();if($!==void 0&&!o)throw $;return U&&U.user,O}function de(j=!0){if(j!==!1&&d)return;d=!1;const O=f?f():s;if(O==null||O===!1){q(o,Y(m));return}let $;const K=l!==Xt?l:Y(()=>{try{return r(O,{value:m(),refetching:j})}catch(ee){$=ee}});if($!==void 0){q(o,void 0,Lt($),O);return}else if(!ci(K))return q(o,K,void 0,O),K;return o=K,"v"in K?(K.s===1?q(o,K.v,void 0,O):q(o,void 0,Lt(K.v),O),K):(d=!0,queueMicrotask(()=>d=!1),ce(()=>{G(u?"refreshing":"pending"),A()},!1),K.then(ee=>q(K,ee,void 0,O),ee=>q(K,void 0,Lt(ee),O)))}Object.defineProperties(oe,{state:{get:()=>v()},error:{get:()=>S()},loading:{get(){const j=v();return j==="pending"||j==="refreshing"}},latest:{get(){if(!u)return oe();const j=S();if(j&&!o)throw j;return m()}}});let V=D;return f?ps(()=>(V=D,de(!1))):de(!1),[oe,{refetch:j=>As(V,()=>de(j)),mutate:T}]}function di(e){return ce(e,!1)}function Y(e){if(U===null)return e();const t=U;U=null;try{return e()}finally{U=t}}function fi(e,t,n){const s=Array.isArray(e);let r,a=n&&n.defer;return o=>{let l;if(s){l=Array(e.length);for(let d=0;d<e.length;d++)l[d]=e[d]()}else l=e();if(a)return a=!1,o;const c=Y(()=>t(l,r,o));return r=l,c}}function ys(e){xn(()=>Y(e))}function $e(e){return D===null||(D.cleanups===null?D.cleanups=[e]:D.cleanups.push(e)),e}function Rn(){return D}function As(e,t){const n=D,s=U;D=e,U=null;try{return ce(t,!0)}catch(r){_n(r)}finally{D=n,U=s}}function hi(e){const t=U,n=D;return Promise.resolve().then(()=>{U=t,D=n;let s;return ce(e,!1),U=D=null,s?s.done:void 0})}var[gi,Cl]=H(!1);function mi(){return[gi,hi]}function Ei(e,t){const n=Symbol("context");return{id:n,Provider:Pi(n),defaultValue:e}}function pi(e){let t;return D&&D.context&&(t=D.context[e.id])!==void 0?t:e.defaultValue}function Ss(e){const t=W(e),n=W(()=>sn(t()));return n.toArray=()=>{const s=n();return Array.isArray(s)?s:s!=null?[s]:[]},n}var yi;function Ts(){if(this.sources&&this.state)if(this.state===Ee)Ye(this);else{const e=Z;Z=null,ce(()=>Mt(this),!1),Z=e}if(U){const e=this.observers?this.observers.length:0;U.sources?(U.sources.push(this),U.sourceSlots.push(e)):(U.sources=[this],U.sourceSlots=[e]),this.observers?(this.observers.push(U),this.observerSlots.push(U.sources.length-1)):(this.observers=[U],this.observerSlots=[U.sources.length-1])}return this.value}function Ps(e,t,n){let s=e.value;return(!e.comparator||!e.comparator(s,t))&&(e.value=t,e.observers&&e.observers.length&&ce(()=>{for(let r=0;r<e.observers.length;r+=1){const a=e.observers[r],o=en&&en.running;o&&en.disposed.has(a),(o?!a.tState:!a.state)&&(a.pure?Z.push(a):fe.push(a),a.observers&&_s(a)),o||(a.state=Ee)}if(Z.length>1e6)throw Z=[],new Error},!1)),t}function Ye(e){if(!e.fn)return;at(e);const t=zt;Ai(e,e.value,t)}function Ai(e,t,n){let s;const r=D,a=U;U=D=e;try{s=e.fn(t)}catch(o){return e.pure&&(e.state=Ee,e.owned&&e.owned.forEach(at),e.owned=null),e.updatedAt=n+1,_n(o)}finally{U=a,D=r}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&"observers"in e?Ps(e,s):e.value=s,e.updatedAt=n)}function $t(e,t,n,s=Ee,r){const a={fn:e,state:s,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:D,context:D?D.context:null,pure:n};return D===null||D!==Es&&(D.owned?D.owned.push(a):D.owned=[a]),a}function Dt(e){if(e.state===0)return;if(e.state===Rt)return Mt(e);if(e.suspense&&Y(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<zt);)e.state&&t.push(e);for(let n=t.length-1;n>=0;n--)if(e=t[n],e.state===Ee)Ye(e);else if(e.state===Rt){const s=Z;Z=null,ce(()=>Mt(e,t[0]),!1),Z=s}}function ce(e,t){if(Z)return e();let n=!1;t||(Z=[]),fe?n=!0:fe=[],zt++;try{const s=e();return Si(n),s}catch(s){n||(fe=null),Z=null,_n(s)}}function Si(e){if(Z&&(xs(Z),Z=null),e)return;const t=fe;fe=null,t.length&&ce(()=>ms(t),!1)}function xs(e){for(let t=0;t<e.length;t++)Dt(e[t])}function Ti(e){let t,n=0;for(t=0;t<e.length;t++){const s=e[t];s.user?e[n++]=s:Dt(s)}if(C.context){if(C.count){C.effects||(C.effects=[]),C.effects.push(...e.slice(0,n));return}Xe()}for(C.effects&&(C.done||!C.count)&&(e=[...C.effects,...e],n+=C.effects.length,delete C.effects),t=0;t<n;t++)Dt(e[t])}function Mt(e,t){e.state=0;for(let n=0;n<e.sources.length;n+=1){const s=e.sources[n];if(s.sources){const r=s.state;r===Ee?s!==t&&(!s.updatedAt||s.updatedAt<zt)&&Dt(s):r===Rt&&Mt(s,t)}}}function _s(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=Rt,n.pure?Z.push(n):fe.push(n),n.observers&&_s(n))}}function at(e){let t;if(e.sources)for(;e.sources.length;){const n=e.sources.pop(),s=e.sourceSlots.pop(),r=n.observers;if(r&&r.length){const a=r.pop(),o=n.observerSlots.pop();s<r.length&&(a.sourceSlots[o]=s,r[s]=a,n.observerSlots[s]=o)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)at(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)at(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function Lt(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function _n(e,t=D){throw Lt(e)}function sn(e){if(typeof e=="function"&&!e.length)return sn(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const s=sn(e[n]);Array.isArray(s)?t.push.apply(t,s):t.push(s)}return t}return e}function Pi(e,t){return function(s){let r;return Ae(()=>r=Y(()=>(D.context={...D.context,[e]:s.value},Ss(()=>s.children))),void 0),r}}var rn=Symbol("fallback");function Ut(e){for(let t=0;t<e.length;t++)e[t]()}function xi(e,t,n={}){let s=[],r=[],a=[],o=0,l=t.length>1?[]:null;return $e(()=>Ut(a)),()=>{let c=e()||[],d=c.length,u,f;return c[Pn],Y(()=>{let m,T,S,x,w,A,v,G,q;if(d===0)o!==0&&(Ut(a),a=[],s=[],r=[],o=0,l&&(l=[])),n.fallback&&(s=[rn],r[0]=ye(L=>(a[0]=L,n.fallback())),o=1);else if(o===0){for(r=new Array(d),f=0;f<d;f++)s[f]=c[f],r[f]=ye(E);o=d}else{for(S=new Array(d),x=new Array(d),l&&(w=new Array(d)),A=0,v=Math.min(o,d);A<v&&s[A]===c[A];A++);for(v=o-1,G=d-1;v>=A&&G>=A&&s[v]===c[G];v--,G--)S[G]=r[v],x[G]=a[v],l&&(w[G]=l[v]);for(m=new Map,T=new Array(G+1),f=G;f>=A;f--)q=c[f],u=m.get(q),T[f]=u===void 0?-1:u,m.set(q,f);for(u=A;u<=v;u++)q=s[u],f=m.get(q),f!==void 0&&f!==-1?(S[f]=r[u],x[f]=a[u],l&&(w[f]=l[u]),f=T[f],m.set(q,f)):a[u]();for(f=A;f<d;f++)f in S?(r[f]=S[f],a[f]=x[f],l&&(l[f]=w[f],l[f](f))):r[f]=ye(E);r=r.slice(0,o=d),s=c.slice(0)}return r});function E(m){if(a[f]=m,l){const[T,S]=H(f);return l[f]=S,t(c[f],T)}return t(c[f])}}}function _i(e,t,n={}){let s=[],r=[],a=[],o=[],l=0,c;return $e(()=>Ut(a)),()=>{const d=e()||[],u=d.length;return d[Pn],Y(()=>{if(u===0)return l!==0&&(Ut(a),a=[],s=[],r=[],l=0,o=[]),n.fallback&&(s=[rn],r[0]=ye(E=>(a[0]=E,n.fallback())),l=1),r;for(s[0]===rn&&(a[0](),a=[],s=[],r=[],l=0),c=0;c<u;c++)c<s.length&&s[c]!==d[c]?o[c](()=>d[c]):c>=s.length&&(r[c]=ye(f));for(;c<s.length;c++)a[c]();return l=o.length=a.length=u,s=d.slice(0),r=r.slice(0,l)});function f(E){a[c]=E;const[m,T]=H(d[c]);return o[c]=T,t(m,c)}}}function wn(e,t){return Y(()=>e(t||{}))}function vt(){return!0}var an={get(e,t,n){return t===kt?n:e.get(t)},has(e,t){return t===kt?!0:e.has(t)},set:vt,deleteProperty:vt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:vt,deleteProperty:vt}},ownKeys(e){return e.keys()}};function tn(e){return(e=typeof e=="function"?e():e)?e:{}}function wi(){for(let e=0,t=this.length;e<t;++e){const n=this[e]();if(n!==void 0)return n}}function vn(...e){let t=!1;for(let o=0;o<e.length;o++){const l=e[o];t=t||!!l&&kt in l,e[o]=typeof l=="function"?(t=!0,W(l)):l}if(gs&&t)return new Proxy({get(o){for(let l=e.length-1;l>=0;l--){const c=tn(e[l])[o];if(c!==void 0)return c}},has(o){for(let l=e.length-1;l>=0;l--)if(o in tn(e[l]))return!0;return!1},keys(){const o=[];for(let l=0;l<e.length;l++)o.push(...Object.keys(tn(e[l])));return[...new Set(o)]}},an);const n={},s=Object.create(null);for(let o=e.length-1;o>=0;o--){const l=e[o];if(!l)continue;const c=Object.getOwnPropertyNames(l);for(let d=c.length-1;d>=0;d--){const u=c[d];if(u==="__proto__"||u==="constructor")continue;const f=Object.getOwnPropertyDescriptor(l,u);if(!s[u])s[u]=f.get?{enumerable:!0,configurable:!0,get:wi.bind(n[u]=[f.get.bind(l)])}:f.value!==void 0?f:void 0;else{const E=n[u];E&&(f.get?E.push(f.get.bind(l)):f.value!==void 0&&E.push(()=>f.value))}}}const r={},a=Object.keys(s);for(let o=a.length-1;o>=0;o--){const l=a[o],c=s[l];c&&c.get?Object.defineProperty(r,l,c):r[l]=c?c.value:void 0}return r}function ws(e,...t){if(gs&&kt in e){const r=new Set(t.length>1?t.flat():t[0]),a=t.map(o=>new Proxy({get(l){return o.includes(l)?e[l]:void 0},has(l){return o.includes(l)&&l in e},keys(){return o.filter(l=>l in e)}},an));return a.push(new Proxy({get(o){return r.has(o)?void 0:e[o]},has(o){return r.has(o)?!1:o in e},keys(){return Object.keys(e).filter(o=>!r.has(o))}},an)),a}const n={},s=t.map(()=>({}));for(const r of Object.getOwnPropertyNames(e)){const a=Object.getOwnPropertyDescriptor(e,r),o=!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,o?s[c][r]=a.value:Object.defineProperty(s[c],r,a)),++c;l||(o?n[r]=a.value:Object.defineProperty(n,r,a))}return[...s,n]}function vs(e){let t,n;const s=r=>{const a=C.context;if(a){const[l,c]=H();C.count||(C.count=0),C.count++,(n||(n=e())).then(d=>{!C.done&&Xe(a),C.count--,c(()=>d.default),Xe()}),t=l}else if(!t){const[l]=ui(()=>(n||(n=e())).then(c=>c.default));t=l}let o;return W(()=>(o=t())?Y(()=>{if(!a||C.done)return o(r);const l=C.context;Xe(a);const c=o(r);return Xe(l),c}):"")};return s.preload=()=>n||((n=e()).then(r=>t=()=>r.default),n),s}var vi=0;function bi(){return C.context?C.getNextContextId():`cl-${vi++}`}var bs=e=>`Stale read from <${e}>.`;function Ci(e){const t="fallback"in e&&{fallback:()=>e.fallback};return W(xi(()=>e.each,e.children,t||void 0))}function Ii(e){const t="fallback"in e&&{fallback:()=>e.fallback};return W(_i(()=>e.each,e.children,t||void 0))}function Ni(e){const t=e.keyed,n=W(()=>e.when,void 0,void 0),s=t?n:W(n,void 0,{equals:(r,a)=>!r==!a});return W(()=>{const r=s();if(r){const a=e.children;return typeof a=="function"&&a.length>0?Y(()=>a(t?r:()=>{if(!Y(s))throw bs("Show");return n()})):a}return e.fallback},void 0,void 0)}function Li(e){const t=Ss(()=>e.children),n=W(()=>{const s=t(),r=Array.isArray(s)?s:[s];let a=()=>{};for(let o=0;o<r.length;o++){const l=o,c=r[o],d=a,u=W(()=>d()?void 0:c.when,void 0,void 0),f=c.keyed?u:W(u,void 0,{equals:(E,m)=>!E==!m});a=()=>d()||(f()?[l,u,c]:void 0)}return a});return W(()=>{const s=n()();if(!s)return e.fallback;const[r,a,o]=s,l=o.children;return typeof l=="function"&&l.length>0?Y(()=>l(o.keyed?a():()=>{var d;if(((d=Y(n)())==null?void 0:d[0])!==r)throw bs("Match");return a()})):l},void 0,void 0)}function ji(e){return e}var Gi=["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"],ki=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",...Gi]),Oi=new Set(["innerHTML","textContent","innerText","children"]),Ri=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),Di=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 Mi(e,t){const n=Di[e];return typeof n=="object"?n[t]?n.$:void 0:n}var Ui=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),Bi=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"]),Fi={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},qi=e=>W(()=>e());function Ki(e,t,n){let s=n.length,r=t.length,a=s,o=0,l=0,c=t[r-1].nextSibling,d=null;for(;o<r||l<a;){if(t[o]===n[l]){o++,l++;continue}for(;t[r-1]===n[a-1];)r--,a--;if(r===o){const u=a<s?l?n[l-1].nextSibling:n[a-l]:c;for(;l<a;)e.insertBefore(n[l++],u)}else if(a===l)for(;o<r;)(!d||!d.has(t[o]))&&t[o].remove(),o++;else if(t[o]===n[a-1]&&n[l]===t[r-1]){const u=t[--r].nextSibling;e.insertBefore(n[l++],t[o++].nextSibling),e.insertBefore(n[--a],u),t[r]=n[a]}else{if(!d){d=new Map;let f=l;for(;f<a;)d.set(n[f],f++)}const u=d.get(t[o]);if(u!=null)if(l<u&&u<a){let f=o,E=1,m;for(;++f<r&&f<a&&!((m=d.get(t[f]))==null||m!==u+E);)E++;if(E>u-l){const T=t[o];for(;l<u;)e.insertBefore(n[l++],T)}else e.replaceChild(n[l++],t[o++])}else o++;else t[o++].remove()}}}var nt="_$DX_DELEGATE";function Cs(e,t,n,s={}){let r;return ye(a=>{r=a,t===document?e():Ft(t,e(),t.firstChild?null:void 0,n)},s.owner),()=>{r(),t.textContent=""}}function Vi(e,t,n,s){let r;const a=()=>{const l=document.createElement("template");return l.innerHTML=e,l.content.firstChild},o=()=>(r||(r=a())).cloneNode(!0);return o.cloneNode=o,o}function Is(e,t=window.document){const n=t[nt]||(t[nt]=new Set);for(let s=0,r=e.length;s<r;s++){const a=e[s];n.has(a)||(n.add(a),t.addEventListener(a,ks))}}function Hi(e=window.document){if(e[nt]){for(let t of e[nt].keys())e.removeEventListener(t,ks);delete e[nt]}}function Bt(e,t,n){be(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function Qi(e,t,n,s){be(e)||(s==null?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,s))}function zi(e,t,n){be(e)||(n?e.setAttribute(t,""):e.removeAttribute(t))}function Ns(e,t){be(e)||(t==null?e.removeAttribute("class"):e.className=t)}function Ls(e,t,n,s){if(s)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){const r=n[0];e.addEventListener(t,n[0]=a=>r.call(e,n[1],a))}else e.addEventListener(t,n,typeof n!="function"&&n)}function $i(e,t,n={}){const s=Object.keys(t||{}),r=Object.keys(n);let a,o;for(a=0,o=r.length;a<o;a++){const l=r[a];!l||l==="undefined"||t[l]||(Dn(e,l,!1),delete n[l])}for(a=0,o=s.length;a<o;a++){const l=s[a],c=!!t[l];!l||l==="undefined"||n[l]===c||!c||(Dn(e,l,!0),n[l]=c)}return n}function Wi(e,t,n){if(!t)return n?Bt(e,"style"):t;const s=e.style;if(typeof t=="string")return s.cssText=t;typeof n=="string"&&(s.cssText=n=void 0),n||(n={}),t||(t={});let r,a;for(a in n)t[a]==null&&s.removeProperty(a),delete n[a];for(a in t)r=t[a],r!==n[a]&&(s.setProperty(a,r),n[a]=r);return n}function js(e,t={},n,s){const r={};return s||Ae(()=>r.children=it(e,t.children,r.children)),Ae(()=>typeof t.ref=="function"&&Gs(t.ref,e)),Ae(()=>Yi(e,t,n,!0,r,!0)),r}function Gs(e,t,n){return Y(()=>e(t,n))}function Ft(e,t,n,s){if(n!==void 0&&!s&&(s=[]),typeof t!="function")return it(e,t,s,n);Ae(r=>it(e,t(),r,n),s)}function Yi(e,t,n,s,r={},a=!1){t||(t={});for(const o in r)if(!(o in t)){if(o==="children")continue;r[o]=Mn(e,o,null,r[o],n,a,t)}for(const o in t){if(o==="children")continue;const l=t[o];r[o]=Mn(e,o,l,r[o],n,a,t)}}function Ji(e){let t,n;return!be()||!(t=C.registry.get(n=Xi()))?e():(C.completed&&C.completed.add(t),C.registry.delete(n),t)}function be(e){return!!C.context&&!C.done&&(!e||e.isConnected)}function Zi(e){return e.toLowerCase().replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function Dn(e,t,n){const s=t.trim().split(/\s+/);for(let r=0,a=s.length;r<a;r++)e.classList.toggle(s[r],n)}function Mn(e,t,n,s,r,a,o){let l,c,d,u,f;if(t==="style")return Wi(e,n,s);if(t==="classList")return $i(e,n,s);if(n===s)return s;if(t==="ref")a||n(e);else if(t.slice(0,3)==="on:"){const E=t.slice(3);s&&e.removeEventListener(E,s,typeof s!="function"&&s),n&&e.addEventListener(E,n,typeof n!="function"&&n)}else if(t.slice(0,10)==="oncapture:"){const E=t.slice(10);s&&e.removeEventListener(E,s,!0),n&&e.addEventListener(E,n,!0)}else if(t.slice(0,2)==="on"){const E=t.slice(2).toLowerCase(),m=Ui.has(E);if(!m&&s){const T=Array.isArray(s)?s[0]:s;e.removeEventListener(E,T)}(m||n)&&(Ls(e,E,n,m),m&&Is([E]))}else if(t.slice(0,5)==="attr:")Bt(e,t.slice(5),n);else if(t.slice(0,5)==="bool:")zi(e,t.slice(5),n);else if((f=t.slice(0,5)==="prop:")||(d=Oi.has(t))||!r&&((u=Mi(t,e.tagName))||(c=ki.has(t)))||(l=e.nodeName.includes("-")||"is"in o)){if(f)t=t.slice(5),c=!0;else if(be(e))return n;t==="class"||t==="className"?Ns(e,n):l&&!c&&!d?e[Zi(t)]=n:e[u||t]=n}else{const E=r&&t.indexOf(":")>-1&&Fi[t.split(":")[0]];E?Qi(e,E,t,n):Bt(e,Ri[t]||t,n)}return n}function ks(e){if(C.registry&&C.events&&C.events.find(([c,d])=>d===e))return;let t=e.target;const n=`$$${e.type}`,s=e.target,r=e.currentTarget,a=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),o=()=>{const c=t[n];if(c&&!t.disabled){const d=t[`${n}Data`];if(d!==void 0?c.call(t,d,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&a(t.host),!0},l=()=>{for(;o()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),C.registry&&!C.done&&(C.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();a(c[0]);for(let d=0;d<c.length-2&&(t=c[d],!!o());d++){if(t._$host){t=t._$host,l();break}if(t.parentNode===r)break}}else l();a(s)}function it(e,t,n,s,r){const a=be(e);if(a){!n&&(n=[...e.childNodes]);let c=[];for(let d=0;d<n.length;d++){const u=n[d];u.nodeType===8&&u.data.slice(0,2)==="!$"?u.remove():c.push(u)}n=c}for(;typeof n=="function";)n=n();if(t===n)return n;const o=typeof t,l=s!==void 0;if(e=l&&n[0]&&n[0].parentNode||e,o==="string"||o==="number"){if(a||o==="number"&&(t=t.toString(),t===n))return n;if(l){let c=n[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),n=Ie(e,n,s,c)}else n!==""&&typeof n=="string"?n=e.firstChild.data=t:n=e.textContent=t}else if(t==null||o==="boolean"){if(a)return n;n=Ie(e,n,s)}else{if(o==="function")return Ae(()=>{let c=t();for(;typeof c=="function";)c=c();n=it(e,c,n,s)}),()=>n;if(Array.isArray(t)){const c=[],d=n&&Array.isArray(n);if(on(c,t,n,r))return Ae(()=>n=it(e,c,n,s,!0)),()=>n;if(a){if(!c.length)return n;if(s===void 0)return n=[...e.childNodes];let u=c[0];if(u.parentNode!==e)return n;const f=[u];for(;(u=u.nextSibling)!==s;)f.push(u);return n=f}if(c.length===0){if(n=Ie(e,n,s),l)return n}else d?n.length===0?Un(e,c,s):Ki(e,n,c):(n&&Ie(e),Un(e,c));n=c}else if(t.nodeType){if(a&&t.parentNode)return n=l?[t]:t;if(Array.isArray(n)){if(l)return n=Ie(e,n,s,t);Ie(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function on(e,t,n,s){let r=!1;for(let a=0,o=t.length;a<o;a++){let l=t[a],c=n&&n[e.length],d;if(!(l==null||l===!0||l===!1))if((d=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))r=on(e,l,c)||r;else if(d==="function")if(s){for(;typeof l=="function";)l=l();r=on(e,Array.isArray(l)?l:[l],Array.isArray(c)?c:[c])||r}else e.push(l),r=!0;else{const u=String(l);c&&c.nodeType===3&&c.data===u?e.push(c):e.push(document.createTextNode(u))}}return r}function Un(e,t,n=null){for(let s=0,r=t.length;s<r;s++)e.insertBefore(t[s],n)}function Ie(e,t,n,s){if(n===void 0)return e.textContent="";const r=s||document.createTextNode("");if(t.length){let a=!1;for(let o=t.length-1;o>=0;o--){const l=t[o];if(r!==l){const c=l.parentNode===e;!a&&!o?c?e.replaceChild(r,l):e.insertBefore(r,n):c&&l.remove()}else a=!0}}else e.insertBefore(r,n);return[r]}function Xi(){return C.getNextContextId()}var eo="http://www.w3.org/2000/svg";function Os(e,t=!1){return t?document.createElementNS(eo,e):document.createElement(e)}function to(e){const{useShadow:t}=e,n=document.createTextNode(""),s=()=>e.mount||document.body,r=Rn();let a,o=!!C.context;return xn(()=>{o&&(Rn().user=o=!1),a||(a=As(r,()=>W(()=>e.children)));const l=s();if(l instanceof HTMLHeadElement){const[c,d]=H(!1),u=()=>d(!0);ye(f=>Ft(l,()=>c()?f():a(),null)),$e(u)}else{const c=Os(e.isSVG?"g":"div",e.isSVG),d=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return n.parentNode},configurable:!0}),Ft(d,a),l.appendChild(c),e.ref&&e.ref(c),$e(()=>l.removeChild(c))}},void 0,{render:!o}),n}function no(e,t){const n=W(e);return W(()=>{const s=n();switch(typeof s){case"function":return Y(()=>s(t));case"string":const r=Bi.has(s),a=C.context?Ji():Os(s,r);return js(a,t,r),a}})}function so(e){const[,t]=ws(e,["component"]);return no(()=>e.component,t)}var ro=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()}},Rs=class{constructor(e){this.generateIdentifier=e,this.kv=new ro}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)}},ao=class extends Rs{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 io(e){if("values"in Object)return Object.values(e);const t=[];for(const n in e)e.hasOwnProperty(n)&&t.push(e[n]);return t}function oo(e,t){const n=io(e);if("find"in n)return n.find(t);const s=n;for(let r=0;r<s.length;r++){const a=s[r];if(t(a))return a}}function We(e,t){Object.entries(e).forEach(([n,s])=>t(s,n))}function jt(e,t){return e.indexOf(t)!==-1}function Bn(e,t){for(let n=0;n<e.length;n++){const s=e[n];if(t(s))return s}}var lo=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return oo(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},co=e=>Object.prototype.toString.call(e).slice(8,-1),Ds=e=>typeof e>"u",uo=e=>e===null,ot=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,ln=e=>ot(e)&&Object.keys(e).length===0,Se=e=>Array.isArray(e),fo=e=>typeof e=="string",ho=e=>typeof e=="number"&&!isNaN(e),go=e=>typeof e=="boolean",mo=e=>e instanceof RegExp,lt=e=>e instanceof Map,ct=e=>e instanceof Set,Ms=e=>co(e)==="Symbol",Eo=e=>e instanceof Date&&!isNaN(e.valueOf()),po=e=>e instanceof Error,Fn=e=>typeof e=="number"&&isNaN(e),yo=e=>go(e)||uo(e)||Ds(e)||ho(e)||fo(e)||Ms(e),Ao=e=>typeof e=="bigint",So=e=>e===1/0||e===-1/0,To=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),Po=e=>e instanceof URL,Us=e=>e.replace(/\./g,"\\."),nn=e=>e.map(String).map(Us).join("."),st=e=>{const t=[];let n="";for(let r=0;r<e.length;r++){let a=e.charAt(r);if(a==="\\"&&e.charAt(r+1)==="."){n+=".",r++;continue}if(a==="."){t.push(n),n="";continue}n+=a}const s=n;return t.push(s),t};function le(e,t,n,s){return{isApplicable:e,annotation:t,transform:n,untransform:s}}var Bs=[le(Ds,"undefined",()=>null,()=>{}),le(Ao,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),le(Eo,"Date",e=>e.toISOString(),e=>new Date(e)),le(po,"Error",(e,t)=>{const n={name:e.name,message:e.message};return t.allowedErrorProps.forEach(s=>{n[s]=e[s]}),n},(e,t)=>{const n=new Error(e.message);return n.name=e.name,n.stack=e.stack,t.allowedErrorProps.forEach(s=>{n[s]=e[s]}),n}),le(mo,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),n=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,n)}),le(ct,"set",e=>[...e.values()],e=>new Set(e)),le(lt,"map",e=>[...e.entries()],e=>new Map(e)),le(e=>Fn(e)||So(e),"number",e=>Fn(e)?"NaN":e>0?"Infinity":"-Infinity",Number),le(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),le(Po,"URL",e=>e.toString(),e=>new URL(e))];function Wt(e,t,n,s){return{isApplicable:e,annotation:t,transform:n,untransform:s}}var Fs=Wt((e,t)=>Ms(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,n)=>{const s=n.symbolRegistry.getValue(t[1]);if(!s)throw new Error("Trying to deserialize unknown symbol");return s}),xo=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),qs=Wt(To,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const n=xo[t[1]];if(!n)throw new Error("Trying to deserialize unknown typed array");return new n(e)});function Ks(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var Vs=Wt(Ks,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const n=t.classRegistry.getAllowedProps(e.constructor);if(!n)return{...e};const s={};return n.forEach(r=>{s[r]=e[r]}),s},(e,t,n)=>{const s=n.classRegistry.getValue(t[1]);if(!s)throw new Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(s.prototype),e)}),Hs=Wt((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,n)=>{const s=n.customTransformerRegistry.findByName(t[1]);if(!s)throw new Error("Trying to deserialize unknown custom value");return s.deserialize(e)}),_o=[Vs,Fs,Hs,qs],qn=(e,t)=>{const n=Bn(_o,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation(e,t)};const s=Bn(Bs,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation}},Qs={};Bs.forEach(e=>{Qs[e.annotation]=e});var wo=(e,t,n)=>{if(Se(t))switch(t[0]){case"symbol":return Fs.untransform(e,t,n);case"class":return Vs.untransform(e,t,n);case"custom":return Hs.untransform(e,t,n);case"typed-array":return qs.untransform(e,t,n);default:throw new Error("Unknown transformation: "+t)}else{const s=Qs[t];if(!s)throw new Error("Unknown transformation: "+t);return s.untransform(e,n)}},Ne=(e,t)=>{if(t>e.size)throw new Error("index out of bounds");const n=e.keys();for(;t>0;)n.next(),t--;return n.next().value};function zs(e){if(jt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(jt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(jt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var vo=(e,t)=>{zs(t);for(let n=0;n<t.length;n++){const s=t[n];if(ct(e))e=Ne(e,+s);else if(lt(e)){const r=+s,a=+t[++n]==0?"key":"value",o=Ne(e,r);switch(a){case"key":e=o;break;case"value":e=e.get(o);break}}else e=e[s]}return e},cn=(e,t,n)=>{if(zs(t),t.length===0)return n(e);let s=e;for(let a=0;a<t.length-1;a++){const o=t[a];if(Se(s)){const l=+o;s=s[l]}else if(ot(s))s=s[o];else if(ct(s)){const l=+o;s=Ne(s,l)}else if(lt(s)){if(a===t.length-2)break;const c=+o,d=+t[++a]==0?"key":"value",u=Ne(s,c);switch(d){case"key":s=u;break;case"value":s=s.get(u);break}}}const r=t[t.length-1];if(Se(s)?s[+r]=n(s[+r]):ot(s)&&(s[r]=n(s[r])),ct(s)){const a=Ne(s,+r),o=n(a);a!==o&&(s.delete(a),s.add(o))}if(lt(s)){const a=+t[t.length-2],o=Ne(s,a);switch(+r==0?"key":"value"){case"key":{const c=n(o);s.set(c,s.get(o)),c!==o&&s.delete(o);break}case"value":{s.set(o,n(s.get(o)));break}}}return e};function un(e,t,n=[]){if(!e)return;if(!Se(e)){We(e,(a,o)=>un(a,t,[...n,...st(o)]));return}const[s,r]=e;r&&We(r,(a,o)=>{un(a,t,[...n,...st(o)])}),t(s,n)}function bo(e,t,n){return un(t,(s,r)=>{e=cn(e,r,a=>wo(a,s,n))}),e}function Co(e,t){function n(s,r){const a=vo(e,st(r));s.map(st).forEach(o=>{e=cn(e,o,()=>a)})}if(Se(t)){const[s,r]=t;s.forEach(a=>{e=cn(e,st(a),()=>e)}),r&&We(r,n)}else We(t,n);return e}var Io=(e,t)=>ot(e)||Se(e)||lt(e)||ct(e)||Ks(e,t);function No(e,t,n){const s=n.get(e);s?s.push(t):n.set(e,[t])}function Lo(e,t){const n={};let s;return e.forEach(r=>{if(r.length<=1)return;t||(r=r.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[a,...o]=r;a.length===0?s=o.map(nn):n[nn(a)]=o.map(nn)}),s?ln(n)?[s]:[s,n]:ln(n)?void 0:n}var $s=(e,t,n,s,r=[],a=[],o=new Map)=>{const l=yo(e);if(!l){No(e,r,t);const m=o.get(e);if(m)return s?{transformedValue:null}:m}if(!Io(e,n)){const m=qn(e,n),T=m?{transformedValue:m.value,annotations:[m.type]}:{transformedValue:e};return l||o.set(e,T),T}if(jt(a,e))return{transformedValue:null};const c=qn(e,n),d=(c==null?void 0:c.value)??e,u=Se(d)?[]:{},f={};We(d,(m,T)=>{if(T==="__proto__"||T==="constructor"||T==="prototype")throw new Error(`Detected property ${T}. This is a prototype pollution risk, please remove it from your object.`);const S=$s(m,t,n,s,[...r,T],[...a,e],o);u[T]=S.transformedValue,Se(S.annotations)?f[T]=S.annotations:ot(S.annotations)&&We(S.annotations,(x,w)=>{f[Us(T)+"."+w]=x})});const E=ln(f)?{transformedValue:u,annotations:c?[c.type]:void 0}:{transformedValue:u,annotations:c?[c.type,f]:f};return l||o.set(e,E),E};function Ws(e){return Object.prototype.toString.call(e).slice(8,-1)}function Kn(e){return Ws(e)==="Array"}function jo(e){if(Ws(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function Go(e,t,n,s,r){const a={}.propertyIsEnumerable.call(s,t)?"enumerable":"nonenumerable";a==="enumerable"&&(e[t]=n),r&&a==="nonenumerable"&&Object.defineProperty(e,t,{value:n,enumerable:!1,writable:!0,configurable:!0})}function dn(e,t={}){if(Kn(e))return e.map(r=>dn(r,t));if(!jo(e))return e;const n=Object.getOwnPropertyNames(e),s=Object.getOwnPropertySymbols(e);return[...n,...s].reduce((r,a)=>{if(Kn(t.props)&&!t.props.includes(a))return r;const o=e[a],l=dn(o,t);return Go(r,a,l,e,t.nonenumerable),r},{})}var B=class{constructor({dedupe:e=!1}={}){this.classRegistry=new ao,this.symbolRegistry=new Rs(t=>t.description??""),this.customTransformerRegistry=new lo,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,n=$s(e,t,this,this.dedupe),s={json:n.transformedValue};n.annotations&&(s.meta={...s.meta,values:n.annotations});const r=Lo(t,this.dedupe);return r&&(s.meta={...s.meta,referentialEqualities:r}),s}deserialize(e){const{json:t,meta:n}=e;let s=dn(t);return n!=null&&n.values&&(s=bo(s,n.values,this)),n!=null&&n.referentialEqualities&&(s=Co(s,n.referentialEqualities)),s}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};B.defaultInstance=new B;B.serialize=B.defaultInstance.serialize.bind(B.defaultInstance);B.deserialize=B.defaultInstance.deserialize.bind(B.defaultInstance);B.stringify=B.defaultInstance.stringify.bind(B.defaultInstance);B.parse=B.defaultInstance.parse.bind(B.defaultInstance);B.registerClass=B.defaultInstance.registerClass.bind(B.defaultInstance);B.registerSymbol=B.defaultInstance.registerSymbol.bind(B.defaultInstance);B.registerCustom=B.defaultInstance.registerCustom.bind(B.defaultInstance);B.allowErrorProps=B.defaultInstance.allowErrorProps.bind(B.defaultInstance);var Ys=B.serialize,ko=B.stringify;function Oo(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function Ro(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function Do({queryState:e,observerCount:t,isStale:n}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":n?"yellow":"green":"gray"}function Mo({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function Uo(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var Bo=(e,t=!1)=>{const{json:n}=Ys(e);return JSON.stringify(n,null,t?2:void 0)},bt=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,Fo=(e,t)=>e.queryHash.localeCompare(t.queryHash),Js=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,qo=(e,t)=>bt(e)===bt(t)?Js(e,t):bt(e)>bt(t)?1:-1,Ko={status:qo,"query hash":Fo,"last updated":Js},Ct=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,Zs=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,Vo=(e,t)=>Ct(e)===Ct(t)?Zs(e,t):Ct(e)>Ct(t)?1:-1,Ho={status:Vo,"last updated":Zs},Qo=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),zo=()=>{const[e,t]=H("dark");return ys(()=>{const n=window.matchMedia("(prefers-color-scheme: dark)");t(n.matches?"dark":"light");const s=r=>{t(r.matches?"dark":"light")};n.addEventListener("change",s),$e(()=>n.removeEventListener("change",s))}),e},et=(e,t,n)=>{if(t.length===0)return n;if(e instanceof Map){const s=new Map(e);if(t.length===1)return s.set(t[0],n),s;const[r,...a]=t;return s.set(r,et(s.get(r),a,n)),s}if(e instanceof Set){const s=et(Array.from(e),t,n);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s[t[0]]=n,s;const[r,...a]=t;return s[r]=et(s[r],a,n),s}if(e instanceof Object){const s={...e};if(t.length===1)return s[t[0]]=n,s;const[r,...a]=t;return s[r]=et(s[r],a,n),s}return e},tt=(e,t)=>{if(e instanceof Map){const n=new Map(e);if(t.length===1)return n.delete(t[0]),n;const[s,...r]=t;return n.set(s,tt(n.get(s),r)),n}if(e instanceof Set){const n=tt(Array.from(e),t);return new Set(n)}if(Array.isArray(e)){const n=[...e];if(t.length===1)return n.filter((a,o)=>o.toString()!==t[0]);const[s,...r]=t;return n[s]=tt(n[s],r),n}if(e instanceof Object){const n={...e};if(t.length===1)return delete n[t[0]],n;const[s,...r]=t;return n[s]=tt(n[s],r),n}return e},Xs=(e,t)=>{if(!e||document.querySelector("#_goober")||(t==null?void 0:t.querySelector("#_goober")))return;const s=document.createElement("style"),r=document.createTextNode("");s.appendChild(r),s.id="_goober",s.setAttribute("nonce",e),t?t.appendChild(s):document.head.appendChild(s)},Le,ut,dt,ft,we,ht,je,Ge,ke,Oe,Re,gt,De,Me,mt,Qn,$o=(Qn=class{constructor(e){M(this,Le);M(this,ut);M(this,dt);M(this,ft);M(this,we,!1);M(this,ht);M(this,je);M(this,Ge);M(this,ke);M(this,Oe);M(this,Re);M(this,gt);M(this,De);M(this,Me);M(this,mt);const{client:t,queryFlavor:n,version:s,onlineManager:r,buttonPosition:a,position:o,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:u,hideDisabledQueries:f,theme:E}=e;R(this,Le,H(t)),R(this,dt,n),R(this,ft,s),R(this,ut,r),R(this,ht,d),R(this,je,u),R(this,Ge,H(a)),R(this,ke,H(o)),R(this,Oe,H(l)),R(this,Re,H(c)),R(this,gt,H(f)),R(this,Me,H(E))}setButtonPosition(e){_(this,Ge)[1](e)}setPosition(e){_(this,ke)[1](e)}setInitialIsOpen(e){_(this,Oe)[1](e)}setErrorTypes(e){_(this,Re)[1](e)}setClient(e){_(this,Le)[1](e)}setTheme(e){_(this,Me)[1](e)}mount(e){if(_(this,we))throw new Error("Devtools is already mounted");const t=Cs(()=>{const n=this,[s]=_(this,Ge),[r]=_(this,ke),[a]=_(this,Oe),[o]=_(this,Re),[l]=_(this,gt),[c]=_(this,Le),[d]=_(this,Me);let u;return _(this,De)?u=_(this,De):(u=vs(()=>Promise.resolve().then(()=>require("./WDYDFRGG-BpSteEEf.cjs"))),R(this,De,u)),Xs(_(this,ht),_(this,je)),wn(u,vn({get queryFlavor(){return _(n,dt)},get version(){return _(n,ft)},get onlineManager(){return _(n,ut)},get shadowDOMTarget(){return _(n,je)}},{get client(){return c()},get buttonPosition(){return s()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return o()},get hideDisabledQueries(){return l()},get theme(){return d()}}))},e);R(this,we,!0),R(this,mt,t)}unmount(){var e;if(!_(this,we))throw new Error("Devtools is not mounted");(e=_(this,mt))==null||e.call(this),R(this,we,!1)}},Le=new WeakMap,ut=new WeakMap,dt=new WeakMap,ft=new WeakMap,we=new WeakMap,ht=new WeakMap,je=new WeakMap,Ge=new WeakMap,ke=new WeakMap,Oe=new WeakMap,Re=new WeakMap,gt=new WeakMap,De=new WeakMap,Me=new WeakMap,mt=new WeakMap,Qn),Ue,Et,pt,yt,ve,At,Be,Fe,qe,Ke,Ve,St,He,Qe,ze,Tt,zn,Wo=(zn=class{constructor(e){M(this,Ue);M(this,Et);M(this,pt);M(this,yt);M(this,ve,!1);M(this,At);M(this,Be);M(this,Fe);M(this,qe);M(this,Ke);M(this,Ve);M(this,St);M(this,He);M(this,Qe);M(this,ze);M(this,Tt);const{client:t,queryFlavor:n,version:s,onlineManager:r,buttonPosition:a,position:o,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:u,onClose:f,hideDisabledQueries:E,theme:m}=e;R(this,Ue,H(t)),R(this,pt,n),R(this,yt,s),R(this,Et,r),R(this,At,d),R(this,Be,u),R(this,Fe,H(a)),R(this,qe,H(o)),R(this,Ke,H(l)),R(this,Ve,H(c)),R(this,St,H(E)),R(this,He,H(f)),R(this,ze,H(m))}setButtonPosition(e){_(this,Fe)[1](e)}setPosition(e){_(this,qe)[1](e)}setInitialIsOpen(e){_(this,Ke)[1](e)}setErrorTypes(e){_(this,Ve)[1](e)}setClient(e){_(this,Ue)[1](e)}setOnClose(e){_(this,He)[1](()=>e)}setTheme(e){_(this,ze)[1](e)}mount(e){if(_(this,ve))throw new Error("Devtools is already mounted");const t=Cs(()=>{const n=this,[s]=_(this,Fe),[r]=_(this,qe),[a]=_(this,Ke),[o]=_(this,Ve),[l]=_(this,St),[c]=_(this,Ue),[d]=_(this,He),[u]=_(this,ze);let f;return _(this,Qe)?f=_(this,Qe):(f=vs(()=>Promise.resolve().then(()=>require("./2SSKDMRQ-DVWVGtU8.cjs"))),R(this,Qe,f)),Xs(_(this,At),_(this,Be)),wn(f,vn({get queryFlavor(){return _(n,pt)},get version(){return _(n,yt)},get onlineManager(){return _(n,Et)},get shadowDOMTarget(){return _(n,Be)}},{get client(){return c()},get buttonPosition(){return s()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return o()},get hideDisabledQueries(){return l()},get onClose(){return d()},get theme(){return u()}}))},e);R(this,ve,!0),R(this,Tt,t)}unmount(){var e;if(!_(this,ve))throw new Error("Devtools is not mounted");(e=_(this,Tt))==null||e.call(this),R(this,ve,!1)}},Ue=new WeakMap,Et=new WeakMap,pt=new WeakMap,yt=new WeakMap,ve=new WeakMap,At=new WeakMap,Be=new WeakMap,Fe=new WeakMap,qe=new WeakMap,Ke=new WeakMap,Ve=new WeakMap,St=new WeakMap,He=new WeakMap,Qe=new WeakMap,ze=new WeakMap,Tt=new WeakMap,zn);function Yo(e){const t=P.useQueryClient(e.client),n=z.useRef(null),{buttonPosition:s,position:r,initialIsOpen:a,errorTypes:o,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d,theme:u}=e,[f]=z.useState(new $o({client:t,queryFlavor:"React Query",version:"5",onlineManager:P.onlineManager,buttonPosition:s,position:r,initialIsOpen:a,errorTypes:o,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d,theme:u}));return z.useEffect(()=>{f.setClient(t)},[t,f]),z.useEffect(()=>{s&&f.setButtonPosition(s)},[s,f]),z.useEffect(()=>{r&&f.setPosition(r)},[r,f]),z.useEffect(()=>{f.setInitialIsOpen(a||!1)},[a,f]),z.useEffect(()=>{f.setErrorTypes(o||[])},[o,f]),z.useEffect(()=>{f.setTheme(u)},[u,f]),z.useEffect(()=>(n.current&&f.mount(n.current),()=>{f.unmount()}),[f]),i.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:n})}function Jo(e){const t=P.useQueryClient(e.client),n=z.useRef(null),{errorTypes:s,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:o,theme:l}=e,[c]=z.useState(new Wo({client:t,queryFlavor:"React Query",version:"5",onlineManager:P.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:s,styleNonce:r,shadowDOMTarget:a,onClose:e.onClose,hideDisabledQueries:o,theme:l}));return z.useEffect(()=>{c.setClient(t)},[t,c]),z.useEffect(()=>{c.setOnClose(e.onClose??(()=>{}))},[e.onClose,c]),z.useEffect(()=>{c.setErrorTypes(s||[])},[s,c]),z.useEffect(()=>{c.setTheme(l)},[l,c]),z.useEffect(()=>(n.current&&c.mount(n.current),()=>{c.unmount()}),[c]),i.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:n})}var Vn=process.env.NODE_ENV!=="development"?function(){return null}:Yo;process.env.NODE_ENV;const er=Q.atom(""),Zo=()=>{I.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),I.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"})},Xo=()=>{const e=N(),t=k();return P.useQuery({queryKey:[y.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:y.GET_COLLECTIONS})})},el=()=>{const{data:e}=ne(),{data:t}=ge(),{data:n}=Pe(),s=N(),r=k(),a=h.useMemo(()=>(n==null?void 0:n.fallbackLang)||"en",[n==null?void 0:n.fallbackLang]),o=h.useRef(new Map);return P.useMutation({mutationFn:async({block:l})=>{const c=l._id,d=(t==null?void 0:t.lang)||a,u=`${c}:${d}`;if(o.current.has(u))return o.current.get(u);const f=r(s,{action:y.GET_BLOCK_ASYNC_PROPS,data:{block:l,lang:d,pageProps:{slug:t==null?void 0:t.slug,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:a,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id}}});return o.current.set(u,f),f.finally(()=>{o.current.delete(u)}),f}})},tr=()=>{const[,e]=ue();return h.useCallback((t,n)=>{const r=new URLSearchParams(window.location.search).get("lang"),a=new URLSearchParams({page:t});r&&a.set("lang",r),window.history.pushState({},"",`?${a.toString()}`),e(a),window.dispatchEvent(new PopStateEvent("popstate")),n==null||n()},[e])},nr=()=>{const e=tr();return h.useCallback(({pageId:t})=>{e(t)},[e])},tl={SITE_WIDE_USAGE:"SITE_WIDE_USAGE"},nl=e=>{const t=k(),n=N();return P.useQuery({queryKey:[tl.SITE_WIDE_USAGE],queryFn:async()=>e?t(n,{action:"GET_SITE_WIDE_USAGE"}):{},retry:!1})},sl=h.lazy(()=>Promise.resolve().then(()=>require("./page-lock-BrVqfmVm.cjs"))),rl=h.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-dialog-sYOmLnpY.cjs"))),al=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-v2LfDXwR.cjs"))),il=h.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-YvzDV5ee.cjs"))),ol=h.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-BMx5lGB4.cjs"))),ll=h.lazy(()=>Promise.resolve().then(()=>require("./web-preview-iQgiotU6.cjs")));Zo();Tr.loadWebBlocks();I.registerChaiTopBar(ka);ii();I.registerChaiMediaManager(al);I.registerChaiSaveToLibrary(il);const cl={role:"",permissions:null},Hn=e=>{const{isLoading:t}=Ha();return t?i.jsx(Ht,{className:"fixed inset-0 bg-white",children:i.jsx(b.Loader,{className:"h-6 w-6 animate-spin text-primary"})}):i.jsx(ul,{...e})},ul=e=>{var In;const{data:t}=Va(),n=Vt(),{data:s=cl,isFetching:r}=ls(),{data:a,isFetching:o}=me(),{data:l,isFetching:c}=Xo(),{data:d,isFetching:u}=Pe(),f=r||o||c||u,[E]=ue(),m=E.get("page"),{data:T}=ne(),{data:S,isFetching:x}=Da(),{blocks:w}=Ra(S),{data:A,isFetching:v}=is(),{pageStatus:G}=ie(),q=Oa(),{onSave:L}=Qa(),{mutateAsync:oe}=el(),{getPartialBlocks:de,getPartialBlockBlocks:V}=za(),{mutateAsync:j}=Gr(),{mutateAsync:O}=os(),{data:$}=nl(((In=e.flags)==null?void 0:In.designTokens)??!0),K=nr(),[ee,xe]=h.useState(!1),se=h.useRef([]),Ce=h.useMemo(()=>p.get(d,"theme",{})||{},[d]),_e=G===J.EDITING,ar=G===J.CHECKING,bn=x||ar||v;h.useEffect(()=>{se.current=w},[w]);const[ir]=Q.useAtom(er);h.useEffect(()=>{const te=()=>{document.hidden?xe(!0):xe(!1)};return window.addEventListener("visibilitychange",te),()=>window.removeEventListener("visibilitychange",te)},[]);const or=h.useMemo(()=>{const te={};return s&&(te.permissions=p.get(s,"permissions",null),te.role=p.get(s,"role","user")),te},[s]),Cn=h.useMemo(()=>t==null?void 0:t.some(te=>te.isSiteLibrary),[t]),lr=h.useCallback(async(te,_t)=>await j({pageType:te,query:_t}),[j]);return i.jsxs(i.Fragment,{children:[bn&&i.jsx(Ht,{className:f?"fixed inset-0 bg-white":"bg-white/75",children:i.jsx(b.Loader,{className:`animate-spin text-primary ${f?"h-6 w-6":"h-5 w-5"}`})}),ir&&i.jsx(h.Suspense,{fallback:i.jsx("div",{className:"absolute inset-0 z-[999999] flex min-h-screen w-screen items-center justify-center bg-gray-100",children:i.jsx(b.Loader,{className:"h-6 w-6 animate-spin text-primary"})}),children:i.jsx(ll,{})}),i.jsx(g.ChaiBuilderEditor,{siteWideUsage:$??{},flags:e.flags?{...e.flags,librarySite:Cn}:{librarySite:Cn},gotoPage:K,collections:l??[],getBlockAsyncProps:oe,pageExternalData:A,themePresets:e.themePresets??[],pageId:T==null?void 0:T.id,loading:x,fallbackLang:n,languages:(d==null?void 0:d.languages)||[],brandingOptions:(d==null?void 0:d.theme)||{},designTokens:(d==null?void 0:d.designTokens)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!ee&&_e&&(e.autoSave??!0),autoSaveActionsCount:e.autoSaveActionsCount??10,onError:e.onError||console.error,getPartialBlockBlocks:V,getPartialBlocks:de,blocks:x?[]:w,theme:p.cloneDeep(Ce),pageTypes:a,searchPageTypeItems:lr,askAiCallBack:q,onSave:async({blocks:te,theme:_t,needTranslations:cr,designTokens:Nn})=>{if(!m)return!0;se.current=te;const Ln=[...te];await L({page:m,blocks:Ln,needTranslations:cr}),se.current=Ln;const wt={};return p.isEqual(_t,Ce)||(wt.theme=_t),p.isEqual(Nn,d==null?void 0:d.designTokens)||(wt.designTokens=Nn),p.isEmpty(wt)||await O({settings:wt}),!0},themePanelComponent:ol,...or,children:i.jsx(sl,{isFetchingPageData:bn})}),i.jsx("div",{children:i.jsx(rl,{})})]})},dl=new P.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),fl=e=>{const[,t]=qt(),[n,s]=h.useState(!1);return h.useEffect(()=>(t(p.pick(e,["apiUrl","usersApiUrl","assetsApiUrl","getPreviewUrl","getLiveUrl","topLeftCorner","onLogout","getAccessToken","websocket","realtimeAdapter","getLoggedInUser","features","currentUser"])),setTimeout(()=>{s(!0)},200),()=>{s(!1),t({})}),[e,t]),n?p.get(e,"hasReactQueryProvider",!1)===!0?i.jsxs(i.Fragment,{children:[i.jsx(Hn,{...e}),i.jsx(Vn,{})]}):i.jsxs(P.QueryClientProvider,{client:dl,children:[i.jsx(Hn,{...e}),i.jsx(Vn,{})]}):i.jsx("div",{})},hl=z.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-CHYz7cdB.cjs")));function sr({data:e,onSelect:t,dataType:n="value",disabled:s=!1}){const[r,a]=z.useState(!1);return i.jsxs(g.Popover,{open:r,onOpenChange:a,children:[i.jsxs(g.Tooltip,{children:[i.jsx(g.TooltipTrigger,{asChild:!0,children:i.jsx(g.PopoverTrigger,{asChild:!0,children:i.jsx(I.Button,{size:"sm",variant:"outline",className:"h-6 w-6 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,disabled:s,children:i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:i.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"})})})})}),i.jsx(g.TooltipContent,{children:"Add field"})]}),r&&i.jsx(z.Suspense,{children:i.jsx(hl,{data:e,onSelect:t,dataType:n,open:r,setOpen:a})})]})}const gl=()=>{const{savePageAsync:e}=g.useSavePage(),t=P.useQueryClient(),{isLocked:n}=ie();return h.useCallback(async()=>{n||await e(),t.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]})},[e,t,n])},ml=()=>{const e=P.useQueryClient();return h.useCallback(()=>{e.clear()},[e])},El=()=>{const e=N(),t=k(),{data:n}=ge(),s=P.useQueryClient();return P.useMutation({mutationFn:async r=>{if(!(n!=null&&n.id))throw new Error("No active page found");return await t(`${e}`,{action:y.UPDATE_PAGE_METADATA,data:{id:n.id,metadata:r}})},onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]}),s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]})},onError:()=>{console.error("Failed to update metadata")}})},pl=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-v2LfDXwR.cjs"))),yl=({assetId:e,assetUrl:t,onChange:n,className:s="",placeholder:r="Select an image",disabled:a=!1})=>{const{t:o}=he.useTranslation(),[l,c]=h.useState(!1),d=()=>{a||c(!0)},u=()=>{c(!1)},f=T=>{const S=Array.isArray(T)?T[0]:T;S!=null&&S.url&&n(p.pick(S,["url","id"])),c(!1)},E=()=>{n({url:"",id:""})},m=(t==null?void 0:t.startsWith("{{"))&&(t==null?void 0:t.endsWith("}}"));return i.jsxs("div",{className:`w-full ${s}`,children:[t?i.jsxs("div",{className:"relative overflow-hidden rounded-md border",children:[m?i.jsx("div",{className:"flex h-12 items-center bg-gray-100 px-4",children:i.jsx("p",{className:"text-xs text-gray-500",children:t})}):i.jsx("img",{onClick:d,src:t,alt:o("Selected image"),className:"h-auto max-h-[100px] w-full bg-gray-100 object-contain"}),i.jsxs("div",{className:"absolute right-2 top-2 flex gap-2",children:[i.jsx(I.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white text-red-500",onClick:E,disabled:a,children:m?i.jsx(b.X,{className:"h-4 w-4"}):i.jsx(b.Trash2,{className:"h-4 w-4"})}),!m&&i.jsx(I.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white/80 hover:bg-white/90",onClick:d,disabled:a,children:i.jsx(b.ImageIcon,{className:"h-4 w-4"})})]})]}):i.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:i.jsxs("div",{className:"flex flex-col items-center gap-2",children:[i.jsx(b.ImageIcon,{className:"h-10 w-10 text-gray-400"}),i.jsx("p",{className:"text-sm text-gray-500",children:r})]})}),i.jsx(g.Dialog,{open:l,onOpenChange:c,children:i.jsxs(g.DialogContent,{className:"h-fit w-full max-w-7xl overflow-hidden p-0",children:[i.jsxs(g.DialogHeader,{className:"hidden border-b px-4 py-2",children:[i.jsx(g.DialogTitle,{children:o("Select Image")}),i.jsx(I.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:u,children:i.jsx(b.X,{className:"h-4 w-4"})})]}),i.jsx("div",{className:"h-full flex-1 p-4",children:i.jsx(h.Suspense,{children:i.jsx(pl,{close:u,onSelect:f,mode:"image",assetId:e})})})]})})]})},Al=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),fn=e=>{if(!e.trim())return{isValid:!1,parsed:null,placeholders:[],error:{message:"JSON is empty"}};try{return{isValid:!0,parsed:JSON.parse(e),error:null,placeholders:[]}}catch{}const t=/{{([^{}]+)}}/g,n=[];let s=e,r;for(;(r=t.exec(e))!==null;){const a=r[0],o=r.index,l=`"__placeholder_${n.length}__"`;n.push({original:a,replaced:l,position:o}),s=s.replace(a,l)}try{return{isValid:!0,parsed:JSON.parse(s),error:null,placeholders:n}}catch(a){const o=a,l=o.message.match(/position (\d+)/),c=l?parseInt(l[1]):void 0;let d,u;if(c!==void 0){const f=s.substring(0,c).split(`
2
- `);d=f.length,u=f[f.length-1].length+1}return{isValid:!1,parsed:null,placeholders:n,error:{message:o.message,line:d,column:u,position:c}}}},Sl=(e,t)=>{let s=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const o=`"__placeholder_${a}__"`,l=new RegExp(Al(o),"g");s=s.replace(l,r)}),s},Tl=(e,t)=>{if(!e)return"";let n=JSON.stringify(e,null,2);const s=/{{([^{}]+)}}/g;let r;for(;(r=s.exec(n))!==null;){const a=r[1],o=p.get(t,a,null);n=n.replace(r[0],o)}return n},Pl=h.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-ON6LaybZ.cjs"))),xl=({value:e,onChange:t,disabled:n=!1,readOnly:s=!1,placeholder:r="Enter JSON",rows:a=6,id:o="json-input",pageData:l={},handleFieldInsert:c,hasJsonLdForSelectedLang:d,copyJsonLDFromDefaultPage:u})=>{const[f,E]=h.useState("edit"),[m,T]=h.useState(null),[S,x]=h.useState(""),w=h.useRef(null),[A]=qt(),v=o==="jsonLD"&&p.get(A,"features.sharedJsonLD",!1),G=o==="jsonLD"&&!d&&!!u;h.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const q=V=>{if(s)return;const j=V.target.value;t(j)},L=V=>{if(V.key==="Tab"){V.preventDefault();const j=V.currentTarget,O=j.selectionStart,$=j.selectionEnd;if(O!==$){const ee=e.substring(O,$).split(`
1
+ "use strict";var ur=Object.create;var Yt=Object.defineProperty;var dr=Object.getOwnPropertyDescriptor;var fr=Object.getOwnPropertyNames;var hr=Object.getPrototypeOf,gr=Object.prototype.hasOwnProperty;var jn=e=>{throw TypeError(e)};var mr=(e,t,n)=>t in e?Yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Er=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of fr(t))!gr.call(e,r)&&r!==n&&Yt(e,r,{get:()=>t[r],enumerable:!(s=dr(t,r))||s.enumerable});return e};var pr=(e,t,n)=>(n=e!=null?ur(hr(e)):{},Er(t||!e||!e.__esModule?Yt(n,"default",{value:e,enumerable:!0}):n,e));var Jt=(e,t,n)=>mr(e,typeof t!="symbol"?t+"":t,n),Gn=(e,t,n)=>t.has(e)||jn("Cannot "+n);var _=(e,t,n)=>(Gn(e,t,"read from private field"),n?n.call(e):t.get(e)),M=(e,t,n)=>t.has(e)?jn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),R=(e,t,n,s)=>(Gn(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n);const i=require("react/jsx-runtime"),g=require("./index-EFWvSWoi.cjs"),I=require("./register-chai-top-bar-DWTuRU53.cjs"),Q=require("jotai"),p=require("lodash-es"),h=require("react"),P=require("@tanstack/react-query"),b=require("lucide-react"),he=require("react-i18next"),yr=require("./plugin-BfC_qpW2.cjs"),Gt=require("./common-functions-B3a4xKt_.cjs"),F=require("sonner"),Ar=require("./core-BWQrViOY.cjs"),Sr=require("./apply-binding-nqrhHgIz.cjs"),Tr=require("./web-blocks.cjs"),Pr=require("react-error-boundary");function xr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const z=xr(h),rt=Q.atom(null),y={GET_GLOBAL_JSONLD_ITEMS:"GET_GLOBAL_JSONLD_ITEMS",GENERATE_SEO_FIELD:"GENERATE_SEO_FIELD",UPDATE_PAGE_METADATA:"UPDATE_PAGE_METADATA",GET_BLOCK_ASYNC_PROPS:"GET_BLOCK_ASYNC_PROPS",ASK_AI:"ASK_AI",GET_DRAFT_PAGE:"GET_DRAFT_PAGE",CREATE_PAGE:"CREATE_PAGE",UPDATE_PAGE:"UPDATE_PAGE",DELETE_PAGE:"DELETE_PAGE",DUPLICATE_PAGE:"DUPLICATE_PAGE",CHANGE_SLUG:"CHANGE_SLUG",TAKE_OFFLINE:"TAKE_OFFLINE",PUBLISH_PAGE:"PUBLISH_PAGE",PUBLISH_CHANGES:"PUBLISH_CHANGES",ADD_NEW_LANGUAGE:"ADD_NEW_LANGUAGE",EDIT_LANGUAGE:"EDIT_LANGUAGE",DELETE_LANGUAGE:"DELETE_LANGUAGE",GET_CHANGES:"GET_CHANGES",GET_SERVER_BLOCK:"GET_SERVER_BLOCK",GET_LANGUAGE_PAGES:"GET_LANGUAGE_PAGES",GET_PROJECT_PAGES:"GET_PROJECT_PAGES",GET_WEBSITE_PAGES:"GET_WEBSITE_PAGES",UPDATE_WEBSITE_FIELDS:"UPDATE_WEBSITE_FIELDS",GET_COLLECTIONS:"GET_COLLECTIONS",GET_PAGE_TYPES:"GET_PAGE_TYPES",SEARCH_PAGES:"SEARCH_PAGES",GET_WEBSITE_DRAFT_SETTINGS:"GET_WEBSITE_DRAFT_SETTINGS",AI_CONTEXT:"AI_CONTEXT",GET_WEBSITE_DATA:"GET_WEBSITE_DATA",GET_CHAI_USER:"GET_CHAI_USER",GET_SEO_FIELDS:"GET_SEO_FIELDS",GET_BUILDER_PAGE_DATA:"GET_BUILDER_PAGE_DATA",GET_PAGE_REVISIONS:"GET_PAGE_REVISIONS",DELETE_PAGE_REVISION:"DELETE_PAGE_REVISION",RESTORE_PAGE_REVISION:"RESTORE_PAGE_REVISION",GET_REVISION_DATA:"GET_REVISION_DATA",GET_PAGE_DATA:"GET_PAGE_DATA",GET_COMPARE_DATA:"GET_COMPARE_DATA",GET_ROLE_AND_PERMISSIONS:"GET_ROLE_AND_PERMISSIONS",UPSERT_LIBRARY_ITEM:"UPSERT_LIBRARY_ITEM",GET_LIBRARIES:"GET_LIBRARIES",GET_LIBRARY_ITEM:"GET_LIBRARY_ITEM",GET_LIBRARY_ITEMS:"GET_LIBRARY_ITEMS",DELETE_LIBRARY_ITEM:"DELETE_LIBRARY_ITEM",MARK_AS_TEMPLATE:"MARK_AS_TEMPLATE",UNMARK_AS_TEMPLATE:"UNMARK_AS_TEMPLATE",GET_TEMPLATES_BY_TYPE:"GET_TEMPLATES_BY_TYPE",GET_DYNAMIC_PAGES:"GET_DYNAMIC_PAGES",GET_APP_SHARED_JSONLD:"GET_APP_SHARED_JSONLD",UPDATE_APP_SHARED_JSONLD:"UPDATE_APP_SHARED_JSONLD",ADD_GLOBAL_SCHEMA:"ADD_GLOBAL_SCHEMA",UPDATE_GLOBAL_SCHEMA:"UPDATE_GLOBAL_SCHEMA",DELETE_GLOBAL_SCHEMA:"DELETE_GLOBAL_SCHEMA",TOGGLE_PAGE_GLOBAL_SCHEMA:"TOGGLE_PAGE_GLOBAL_SCHEMA",APPLY_SCHEMA_TO_ALL_PAGES:"APPLY_SCHEMA_TO_ALL_PAGES",REMOVE_SCHEMA_FROM_ALL_PAGES:"REMOVE_SCHEMA_FROM_ALL_PAGES",UPLOAD_ASSET:"UPLOAD_ASSET",DELETE_ASSET:"DELETE_ASSET",UPDATE_ASSET:"UPDATE_ASSET",GET_ASSETS:"GET_ASSETS",GET_ASSET:"GET_ASSET"},_r=Q.atom({}),qt=()=>Q.useAtom(_r),ae=(e,t)=>{const[n]=qt();return h.useMemo(()=>p.get(n,e,t),[n,e,t])},N=()=>ae("apiUrl","/chai/api"),hn=()=>ae("realtimeAdapter",null),$n=async(e,t,n={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(t)}),wr=()=>{const e=k(),t=N();return h.useCallback(async({body:n,headers:s={},url:r=t,streamResponse:a=!1})=>e(r,n,s,a),[e])},k=()=>{const e=ae("onLogout",p.noop),t=ae("getAccessToken"),n=N();return h.useCallback(async(s=n,r,a={},o=!1)=>{const l=await t();try{const c=p.get(r,"action","").toLowerCase(),d=await $n(s+(c?`?action=${c}`:""),r,{...a,Authorization:`Bearer ${l}`});if(o)return d;if(d.status===401)return console.log("401 Response",d),await e("SESSION_EXPIRED"),null;if(!d.ok){const u=await d.json();throw console.error(`API Error (${d.status}):`,u),{status:d.status,statusText:d.statusText,...u,message:u.error||u.message||`Server error: ${d.status}`}}return await d.json()}catch(c){throw console.error("API request failed:",r,c),c}},[e,t])};function ue(){const[e,t]=h.useState(new URLSearchParams(window.location.search));return h.useEffect(()=>{const n=()=>{t(new URLSearchParams(window.location.search))};return window.addEventListener("popstate",n),()=>{window.removeEventListener("popstate",n)}},[]),[e,t]}const Te=e=>{const t=N(),[n]=ue(),s=e??n.get("page"),r=k();return P.useQuery({queryKey:[y.GET_LANGUAGE_PAGES,s],staleTime:1/0,gcTime:0,placeholderData:[],queryFn:async()=>{if(!s)return null;const a=await r(t,{action:y.GET_LANGUAGE_PAGES,data:{id:s}});return p.reverse(p.sortBy(a,"primaryPage"))},enabled:!!s})},vr=Q.atom(null),Wn=()=>Q.useAtom(vr),gn=()=>{const[e]=Wn();return(e==null?void 0:e.slug)||""};function br(e,t){const[n,s]=h.useState(e);return h.useEffect(()=>{const r=setTimeout(()=>s(e),t);return()=>clearTimeout(r)},[e,t]),n}const Cr=({query:e,uuid:t})=>{const{selectedLang:n,fallbackLang:s}=g.useLanguages(),{data:r}=ne(),a=r==null?void 0:r.pageType,o=N(),l=k(),{data:c,isFetching:d}=P.useQuery({queryKey:[y.GET_DYNAMIC_PAGES,e,a,t],staleTime:3600*1e3,placeholderData:[],queryFn:async()=>await l(o,{action:y.GET_DYNAMIC_PAGES,data:{query:e,pageType:a,uuid:t}})||[],enabled:!!a}),u=h.useMemo(()=>n===""?c.filter(f=>f.lang===""||f.lang===s):c.filter(f=>f.lang===n),[n,s,c]);return{allLangPages:c,data:u,isFetching:d}},Yn=()=>{const{selectedLang:e,fallbackLang:t}=g.useLanguages(),[n,s]=Wn(),[r,a]=h.useState(""),o=br(r,500),{allLangPages:l,data:c,isFetching:d}=Cr({query:o}),u=h.useCallback(m=>s(m),[s]),f=h.useCallback(m=>a(m),[a]),E=h.useCallback(()=>{if(!n)return;const m=!(n!=null&&n.primaryPage),T=e.length===0,S=m?n==null?void 0:n.id:n==null?void 0:n.primaryPage,w=l.filter(A=>(A==null?void 0:A.primaryPage)===S||A.id===S).find(A=>T?A.lang===e||A.lang===t:A.lang===e);s(w||n)},[n,e,l,s,t]);return{isFetching:d,dynamicPage:n,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:u,updateSearchQuery:f,onChangeLanguage:E}},Ir=Q.atom({lastSaved:void 0}),mn=()=>Q.useAtom(Ir),ne=()=>{const[e]=ue(),t=e.get("page"),{data:n,isFetching:s}=Te();return{data:h.useMemo(()=>({...p.find(n,{id:t})||{}}),[n,t]),isFetching:s}},ge=()=>{const[e]=ue(),t=e.get("lang")??"",{data:n,isFetching:s}=Te();return{data:h.useMemo(()=>p.find(n,{lang:t})||{},[n,t]),isFetching:s}},Nr=Q.atom({}),Lr=()=>Q.useAtom(Nr),jr=()=>{const{data:e}=ge(),t=gn(),n=ae("getLiveUrl",p.noop),s=e==null?void 0:e.slug,r=n(s||"/");return t?r+t:r},re={...g.PERMISSIONS,ADD_PAGE:"add_page",EDIT_PAGE:"edit_page",DELETE_PAGE:"delete_page",CHANGE_PAGE_TYPE:"change_page_type",PUBLISH_PAGE:"publish_page",UNPUBLISH_PAGE:"unpublish_page",MARK_AS_TEMPLATE:"mark_as_template",EDIT_SEO:"edit_seo",RESTORE_REVISION:"restore_revision",DELETE_REVISION:"delete_revision",DELETE_LIBRARY_BLOCK:"delete_library_block"},me=()=>{const e=N(),t=k();return P.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},Jn=e=>{const{data:t}=me();return h.useMemo(()=>t==null?void 0:t.find(n=>n.key===e),[t,e])},Gr=()=>{const e=N(),t=k();return P.useMutation({mutationFn:async({pageType:n,query:s})=>{try{return t(e,{action:y.SEARCH_PAGES,data:{pageType:n,query:Array.isArray(s)&&s.length>0?s[0]:s}})||[]}catch(r){return console.error(r),[]}}})},Zn=({page:e,setDuplicatePage:t,setAddEditPage:n,setUnpublishPage:s,setDeletePage:r,setMarkAsTemplate:a,setUnmarkAsTemplate:o,children:l,isLanguagePage:c})=>{const{t:d}=he.useTranslation(),{hasPermission:u}=g.usePermissions(),{data:f}=me(),E=h.useMemo(()=>p.find(f,{key:e.pageType}),[f,e.pageType]),m=h.useMemo(()=>!!e.isTemplate,[e.isTemplate]),T=h.useMemo(()=>!!(E!=null&&E.hasSlug),[E==null?void 0:E.hasSlug]);return!u(re.EDIT_PAGE)&&!u(re.DELETE_PAGE)&&!u(re.UNPUBLISH_PAGE)||!e?null:i.jsxs(g.DropdownMenu,{children:[i.jsx(g.DropdownMenuTrigger,{asChild:!0,onClick:x=>x.stopPropagation(),children:l}),i.jsxs(g.DropdownMenuContent,{align:"center",className:"text-sm",children:[u(re.ADD_PAGE)&&!c&&i.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),t(e)},children:[i.jsx(b.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),u(re.EDIT_PAGE)&&i.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),n({...e,global:!(E!=null&&E.hasSlug)})},children:[i.jsx(b.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&u(re.UNPUBLISH_PAGE)&&i.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),s(e)},children:[i.jsx(b.Power,{className:"size-3"}),d("Unpublish")]}),u(re.DELETE_PAGE)&&i.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),r(e)},children:[i.jsx(b.Trash,{className:"size-3"}),d("Delete")]}),u(re.MARK_AS_TEMPLATE)&&T&&!c&&i.jsx(i.Fragment,{children:m?i.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),o(e)},children:[i.jsx(b.SquareLibrary,{className:"size-3"}),d("Unmark as template")]}):i.jsxs(g.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:x=>{x.stopPropagation(),a(e)},children:[i.jsx(b.SquareLibrary,{className:"size-3"}),d("Mark as template")]})})]})]})},Pe=()=>{const e=N(),t=k();return P.useQuery({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS],staleTime:300*1e3,placeholderData:{languages:[],theme:yr.defaultThemeValues,appKey:"",fallbackLang:"",designTokens:{}},queryFn:async()=>t(e,{action:y.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})},Kt=()=>{const e=ae("currentUser"),t=ae("onLogout");return{isLoggedIn:!!e,user:e,logout:t}},J={LOCKED:"LOCKED",EDITING:"EDITING",CHECKING:"CHECKING",TAKE_OVER_REQUESTED:"TAKE_OVER_REQUESTED",ACTIVE_IN_ANOTHER_TAB:"ACTIVE_IN_ANOTHER_TAB",FORCE_TAKE_OVER:"FORCE_TAKE_OVER",CONNECTION_LOST:"CONNECTION_LOST"},X={FORCE_TAKE_OVER:"FORCE_TAKE_OVER",TAKE_OVER_REQUEST:"TAKE_OVER_REQUEST",TAKE_OVER_APPROVED:"TAKE_OVER_APPROVED",TAKE_OVER_REJECTED:"TAKE_OVER_REJECTED",FORCE_TAKE_OVER_REQUEST:"FORCE_TAKE_OVER_REQUEST",CONTINUE_EDITING_IN_THIS_CLIENT:"CONTINUE_EDITING_IN_THIS_CLIENT",CONTINUE_EDITING_IN_THIS_TAB_REQUEST:"CONTINUE_EDITING_IN_THIS_TAB_REQUEST"},kr=["sync","join","leave"],Or=[X.FORCE_TAKE_OVER,X.TAKE_OVER_REQUEST,X.TAKE_OVER_APPROVED,X.TAKE_OVER_REJECTED,X.FORCE_TAKE_OVER_REQUEST,X.CONTINUE_EDITING_IN_THIS_CLIENT,X.CONTINUE_EDITING_IN_THIS_TAB_REQUEST],Rr=Q.atom({}),Xn=Q.atom(null),Dr=Q.atom(J.CHECKING),Mr=Q.atom({}),Ur=e=>{const t={},n=p.groupBy(p.values(e).map(p.first).filter(Boolean),"pageId");return Object.entries(n).forEach(([s,r])=>t[s]=p.minBy(r,"onlineAt")),t},Br=e=>{const t=p.minBy(p.values(e).map(p.first).filter(Boolean),"onlineAt"),n=t==null?void 0:t.onlineAt;return n?n-100:+new Date-1e3*60*60*4},Pt=()=>{const{user:e}=Kt();return e==null?void 0:e.id},Fr=()=>{const{data:e}=Pe();return`WEBSITE:${e==null?void 0:e.appKey}`},xt=()=>{const{data:e}=ne();return e==null?void 0:e.id},pe=crypto.randomUUID();let Zt=null;const Je=10,qr=1e3,Kr=2,Vr=16e3,En=()=>{const[e,t]=Q.useAtom(Rr);return{pageToUser:e,setPageToUser:t}},ie=()=>{const[e,t]=Q.useAtom(Dr),n=[J.LOCKED,J.ACTIVE_IN_ANOTHER_TAB].includes(e),s=[J.EDITING].includes(e);return{pageStatus:e,setPageStatus:t,isLocked:n,isEditing:s}},pn=()=>{const[e,t]=Q.useAtom(Mr);return{pageLockMeta:e,setPageLockMeta:t}},es=()=>{const e=xt(),{pageToUser:t}=En();return h.useMemo(()=>t[e],[t,e])},yn=()=>{const e=hn(),{setPageStatus:t}=ie(),[n]=Q.useAtom(Xn);return h.useEffect(()=>{if(clearTimeout(Zt),!e)return Zt=setTimeout(()=>{e||t(J.EDITING)},500),()=>clearTimeout(Zt)},[e,t]),n},Hr=()=>{const e=xt(),t=Pt(),n=yn(),{setPageToUser:s}=En(),{setPageStatus:r,pageStatus:a}=ie(),o=h.useRef(e);return h.useEffect(()=>{o.current=e},[e]),h.useCallback(l=>{const c=l||n;if(!c)return[];const d=c==null?void 0:c.presenceState(),u=Ur(d);s(u);const f=u[o.current];if(!f)r(J.CHECKING);else if(!t)r(J.CHECKING);else if(f.userId===t&&f.clientId===pe){if(a===J.TAKE_OVER_REQUESTED)return;r(J.EDITING)}else f.userId===t&&f.clientId!==pe?r(J.ACTIVE_IN_ANOTHER_TAB):r(J.LOCKED)},[n,s,r,t,a])},ts=()=>{const e=Pt(),t=xt(),n=yn(),s=es(),{setPageLockMeta:r}=pn(),a=h.useRef(t);return h.useEffect(()=>{a.current=t},[t]),h.useCallback(async(o,l)=>{if(!n)return;const c=l||{};c.userId=e,c.pageId=a.current,c.senderClientId=pe,c.receiverClientId=(l==null?void 0:l.requestingClientId)||(s==null?void 0:s.clientId),await n.send(o,c),r({})},[n,e,s,r])},Qr=()=>{const e=Pt(),t=xt(),n=yn(),{setPageStatus:s}=ie(),{setPageLockMeta:r}=pn(),a=ts(),o=h.useRef(t),{savePageAsync:l}=g.useSavePage();return h.useEffect(()=>{o.current=t},[t]),h.useCallback(c=>async({payload:d})=>{const u=d||{};if(!(!(u!=null&&u.pageId)||(u==null?void 0:u.pageId)!==o.current||(u==null?void 0:u.receiverClientId)!==pe))switch(r({}),c){case X.FORCE_TAKE_OVER_REQUEST:case X.CONTINUE_EDITING_IN_THIS_TAB_REQUEST:{try{await l(!0)}catch(f){console.error("Failed to save page before releasing lock:",f)}await a(X.CONTINUE_EDITING_IN_THIS_CLIENT,{requestingClientId:u==null?void 0:u.senderClientId}),setTimeout(()=>r({type:c}),0);break}case X.TAKE_OVER_REQUEST:{r({requestingUserId:u==null?void 0:u.userId,requestingClientId:u==null?void 0:u.senderClientId}),s(J.TAKE_OVER_REQUESTED);break}case X.CONTINUE_EDITING_IN_THIS_CLIENT:{const f=Br(n==null?void 0:n.presenceState());s(J.CHECKING),await(n==null?void 0:n.track({onlineAt:f,pageId:o.current,userId:e,clientId:pe}));break}case X.TAKE_OVER_REJECTED:{r({type:X.TAKE_OVER_REJECTED});break}}},[a,r,s,n,e,l])},zr=()=>{const e=hn(),t=Pt(),n=xt(),s=Fr(),[r,a]=Q.useAtom(Xn),o=Qr(),l=Hr(),c=h.useRef(o),d=h.useRef(l),u=h.useRef(null),f=h.useRef(!1),E=h.useRef(0),m=h.useRef(r),T=h.useRef(()=>{});h.useEffect(()=>{c.current=o,d.current=l,m.current=r},[o,l,r]);const S=h.useCallback(w=>{Or.forEach(A=>{w.onBroadcast(A,v=>{c.current(A)(v)})}),kr.forEach(A=>{w.onPresence(A,()=>{d.current(w)})})},[]),x=h.useCallback(()=>{if(f.current||!e||!t||!s)return;if(E.current>=Je){console.error(`Maximum reconnection attempts (${Je}) reached. Stopping reconnection attempts.`);return}f.current=!0,E.current+=1,console.log(`Attempting to reconnect realtime channel (attempt ${E.current}/${Je})`),u.current&&(clearTimeout(u.current),u.current=null),m.current&&(m.current.unsubscribe(),a(null),m.current=null);const w=Math.min(qr*Math.pow(Kr,E.current-1),Vr);u.current=setTimeout(()=>{const A=e.channel(s,{config:{presence:{key:pe}}});S(A),A.subscribe(async v=>{v==="SUBSCRIBED"?(console.log("Realtime connection established successfully"),a(A),m.current=A,E.current=0,f.current=!1):v==="CHANNEL_ERROR"||v==="TIMED_OUT"?(console.log(`Realtime connection failed: ${v}. Attempt ${E.current}/${Je}`),E.current<Je?setTimeout(()=>{f.current=!1,T.current()},500):(console.error("Maximum reconnection attempts reached"),f.current=!1)):v==="CLOSED"&&(console.log("Realtime connection closed"),f.current=!1)})},w)},[e,t,s,a,S]);h.useEffect(()=>{T.current=x},[x]),h.useEffect(()=>{if(!e||!t||!s||r&&r.topic===s)return;E.current=0,f.current=!1;const w=e.channel(s,{config:{presence:{key:pe}}});return S(w),w.subscribe(async A=>{A==="SUBSCRIBED"?(console.log("Realtime connection established successfully"),a(w),m.current=w,E.current=0):A==="CHANNEL_ERROR"||A==="TIMED_OUT"?(console.log(`Realtime connection failed: ${A}. Will attempt to reconnect...`),f.current||x()):A==="CLOSED"&&console.log("Realtime connection closed")}),()=>{u.current&&(clearTimeout(u.current),u.current=null),f.current=!1,E.current=0,m.current===w&&(m.current=null),a(null),w.unsubscribe()}},[e,t,s,a,x,S]),h.useEffect(()=>{const w=()=>{if(document.visibilityState==="visible"){if(console.log("Tab became visible, checking realtime connection..."),!e||!t||!s){console.log("Required dependencies not available, skipping reconnection");return}if(f.current){console.log("Reconnection already in progress, skipping visibility change reconnect");return}m.current?m.current.getState()!=="JOINED"&&(console.log("Channel is not active, reconnecting..."),x()):(console.log("No active channel found, reconnecting..."),x())}};return document.addEventListener("visibilitychange",w),()=>{document.removeEventListener("visibilitychange",w)}},[e,t,s,x]),h.useEffect(()=>(r&&n&&t&&r.track({pageId:n,userId:t,clientId:pe,onlineAt:+new Date}),()=>{r&&n&&r.untrack()}),[r,n,t])},Vt=()=>{const{data:e}=Pe();return h.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},An=()=>{const e=k(),t=N();return P.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:n=>n||[]})},$r=e=>{const t=k(),n=N(),s=Vt();return P.useQuery({queryKey:[y.GET_WEBSITE_PAGES,e,s],staleTime:1e3*60*5,enabled:!!e,queryFn:async()=>{if(s===e)return{};const r=await t(n,{action:y.GET_WEBSITE_PAGES,data:{lang:e}})||[];return p.keyBy(p.map(r,a=>({...a,lang:e})),"primaryPage")},placeholderData:r=>r||{}})};function Sn(e,t,n=!1){const s=e.toString()?`?${e.toString()}`:"/";n?window.history.replaceState(null,"",s):window.history.pushState({},"",s),t(e),window.dispatchEvent(new PopStateEvent("popstate"))}const Wr=h.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-iYsDkUzG.cjs"))),ns=({children:e})=>{const{t}=he.useTranslation(),[n,s]=ue(),r=n.get("page"),{data:a,isFetching:o}=ne(),{data:l,isFetching:c}=An(),[d,u]=h.useState(!1),[f,E]=h.useState(!0),{savePage:m}=g.useSavePage(),T=!!r&&!p.isEmpty(a),{isLocked:S}=ie(),x=h.useMemo(()=>{if(!l||c)return!1;const G=l.find(q=>q.slug==="/");return G==null?void 0:G.id},[l,c]);h.useEffect(()=>{if(c||!x||l.some(L=>L.id===r))return;const q=new URLSearchParams({page:x});Sn(q,s),!c&&l&&E(!1)},[r,c,l,x,s]);const w=!f&&!r,A=!f&&!o&&p.isEmpty(a),v=d||w||A;return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex items-center gap-x-1",children:i.jsx("div",{className:"relative",children:i.jsxs(g.Tooltip,{children:[i.jsx(g.TooltipTrigger,{asChild:!0,onClick:()=>{S||m(),u(!0)},children:e||i.jsx(I.Button,{variant:"outline",className:"flex w-full items-center space-x-2 py-1",children:i.jsx(b.LogsIcon,{className:"h-4 w-4"})},"template-viewer")}),i.jsx(g.TooltipContent,{side:"right",children:i.jsx("p",{children:t("Open pages manager")})})]})})}),i.jsx(g.Sheet,{open:v,onOpenChange:G=>!G&&T&&u(!1),children:i.jsxs(g.SheetContent,{side:"left","aria-describedby":"pages-manager-description",className:`z-50 !min-w-[50vh] !max-w-[800px] border-border p-0 ${T?"":"sheet-hide-close-btn"}`,children:[i.jsxs(g.SheetHeader,{className:"mb-3 px-4 pt-4",children:[i.jsxs(g.SheetTitle,{className:"flex items-center gap-2 text-sm font-semibold",children:[i.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:i.jsx(b.Folder,{className:"h-4 w-4"})}),i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{className:"text-sm font-semibold",children:t("Pages")}),i.jsx("span",{id:"pages-manager-description",className:"text-xs font-normal text-muted-foreground",children:t("Manage your site structure")})]})]}),i.jsx(g.SheetDescription,{className:"sr-only",children:t("Manage your site structure")})]}),i.jsx("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:v&&i.jsx(h.Suspense,{children:i.jsx(Wr,{close:()=>u(!1)})})})]})})]})},Yr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-dzN_CD2c.cjs"))),Jr=h.lazy(()=>Promise.resolve().then(()=>require("./delete-page-6lInxYM_.cjs"))),Zr=h.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-rYeBMwHR.cjs"))),Xr=h.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-Co00KkhA.cjs"))),ea=h.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-C9EXTj0X.cjs"))),ta=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-B5rev9W3.cjs"))),na=()=>{const[e,t]=h.useState(null),[n,s]=h.useState(null),[r,a]=h.useState(null),[o,l]=h.useState(null),[c,d]=h.useState(null),[u,f]=h.useState(null),{data:E,isFetching:m}=ge(),{selectedLang:T,fallbackLang:S}=g.useLanguages(),{data:x}=Te(),w=x==null?void 0:x.find(L=>L.lang===T),{isLocked:A}=ie(),v=!(E!=null&&E.slug),G=Q.useSetAtom(rt);if(!E)return null;const q=L=>{T.length>0&&T!==S?G({edit:!0,id:L==null?void 0:L.id,primaryPage:L==null?void 0:L.primaryPage}):f(L)};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between rounded px-[2px] transition-colors duration-200",children:[i.jsx(ns,{children:i.jsx(I.Button,{className:"flex h-7 max-w-[200px] cursor-pointer items-center truncate rounded px-1 text-xs font-medium",variant:"ghost",children:m?i.jsx(b.Loader,{className:"h-4 w-4 animate-spin text-slate-400"}):i.jsxs("span",{className:"flex w-full cursor-pointer items-end overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-xs font-medium",children:[v?i.jsx(b.Hash,{className:"mr-1 h-4 w-4"}):i.jsx(b.File,{className:"mr-1 h-4 w-4"}),p.get(w||E,"name")??""]})})}),A?i.jsx(I.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 cursor-not-allowed rounded opacity-50 hover:bg-transparent",children:i.jsx(b.MoreHorizontal,{className:"h-4 w-4"})}):i.jsx(Zn,{page:E,setDuplicatePage:L=>d(L),setAddEditPage:L=>q(L),setUnpublishPage:L=>s(L),setDeletePage:L=>t(L),setMarkAsTemplate:L=>a(L),setUnmarkAsTemplate:L=>l(L),isLanguagePage:T.length>0&&T!==S,children:i.jsx(I.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:i.jsx(b.MoreHorizontal,{className:"h-4 w-4"})})})]}),u&&i.jsx(h.Suspense,{children:i.jsx(Yr,{closePanel:()=>f(null),editPage:()=>{},addEditPage:u,setAddEditPage:f})}),e&&i.jsx(h.Suspense,{children:i.jsx(Jr,{page:e,onClose:()=>t(null)})}),n&&i.jsx(h.Suspense,{children:i.jsx(ta,{page:n,onClose:()=>s(null)})}),r&&i.jsx(h.Suspense,{children:i.jsx(Xr,{page:r,onClose:()=>a(null)})}),o&&i.jsx(h.Suspense,{children:i.jsx(ea,{page:o,onClose:()=>l(null)})}),c&&i.jsx(h.Suspense,{children:i.jsx(Zr,{page:c,onClose:()=>d(null),closePanel:()=>f(null)})})]})},Ht=({children:e,className:t=""})=>i.jsx("div",{className:Gt.cn("fixed bottom-0 left-0 right-0 top-[50px] z-[20] flex w-screen flex-col items-center justify-center bg-black/40 transition-all",t),children:e}),sa=({hasDynamicPage:e})=>i.jsx(Ht,{children:i.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:[i.jsx("h1",{className:"text-lg font-medium",children:e?"Select a page":"No pages found"}),i.jsx("p",{className:"pt-2 text-center text-sm font-light text-gray-600",children:e?"Please select a page from the list in the top header. This will enable you to edit the page.":"Please add a new page"})]})}),Ze={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"},ra=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-CKIRTFjr.cjs"))),aa=()=>{const e=ae("topLeftCorner",null);return e?i.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:h.createElement(e,{})}):null},ss=({showAdd:e=!0,variant:t="ghost",goToDefaultLang:n=!1})=>{const{fallbackLang:s,languages:r,selectedLang:a,setSelectedLang:o}=g.useLanguages(),l=p.isEmpty(a)?s:a,[,c]=ue(),{isLocked:d}=ie(),{t:u}=he.useTranslation();h.useEffect(()=>{const A=new URLSearchParams(window.location.search),v=A.get("lang");v&&(r.includes(v)?o(v):(A.delete("lang"),c(A),o("")))},[r,c,o]);const f=Q.useSetAtom(rt),{data:E}=ne(),{data:m}=Pe(),{data:T}=Te(),S=h.useMemo(()=>{const A=p.compact(p.map(p.get(m,"languages"),v=>{const G=p.find(T,{lang:v});return{key:v,value:p.get(Ze,v,v),isLangPageAdded:!!G}})).filter(Boolean);return[{key:s,value:p.get(Ze,s),isLangPageAdded:!0},...A]},[s,T,m]),x=A=>{if(document.querySelector('[data-panel-id="seo"]')){const G=new CustomEvent("seo-language-switch-check",{detail:{fromLang:l,toLang:A,switchHandler:()=>w(A)}});window.dispatchEvent(G);return}w(A)},w=A=>{o(A);const v=new URLSearchParams(window.location.search);A===s?v.delete("lang"):v.set("lang",A),Sn(v,c)};return p.isEmpty(r)?null:d?i.jsxs(I.Button,{variant:"ghost",size:"sm",className:"ml-px h-max cursor-not-allowed gap-2 py-1.5 opacity-50",children:[i.jsx(b.Languages,{className:"h-4 w-4"}),p.get(Ze,l,l),i.jsx(b.ChevronDown,{className:"h-4 w-4"})]}):n?i.jsx(I.Button,{onClick:()=>w(s),variant:"link",size:"sm",children:u("Switch to default language")}):i.jsx(i.Fragment,{children:i.jsxs(g.DropdownMenu,{children:[i.jsx(g.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:i.jsxs(I.Button,{disabled:!!d,variant:t,size:"sm",className:"ml-px h-max gap-2 py-1.5",children:[i.jsx(b.Languages,{className:"h-4 w-4"}),p.get(Ze,l,l),i.jsx(b.ChevronDown,{className:"h-4 w-4"})]})}),i.jsxs(g.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(S.filter(A=>A.isLangPageAdded),A=>i.jsxs(g.DropdownMenuItem,{className:Gt.cn("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",A.key===l&&"!bg-gray-200 text-gray-700"),onClick:()=>x(A.key),children:[i.jsx("div",{className:"text-slate-600",children:A.value}),A.key===s&&i.jsxs("small",{className:"flex items-center gap-x-1 text-[9px] leading-none text-orange-500",children:[i.jsx(b.Star,{fill:"orange",className:"h-2 w-2"}),"Primary"]})]},A.value)),e&&!p.isEmpty(S.filter(A=>!A.isLangPageAdded))&&i.jsxs(i.Fragment,{children:[i.jsx(g.Separator,{}),i.jsxs(I.Button,{size:"sm",variant:"ghost",onClick:()=>{E&&f({edit:!1,primaryPage:E.id})},className:"text-xs font-normal duration-200 hover:bg-slate-300 hover:text-slate-800",children:[i.jsx(b.Plus,{className:"mr-1 h-3 w-3"})," Add Language"]})]})]})]})})};function ia(){const e=Q.useAtomValue(rt),t=Q.useSetAtom(rt);return i.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[i.jsx(aa,{}),i.jsx(ns,{}),e&&i.jsx(h.Suspense,{children:i.jsx(ra,{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 oa(){return i.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((e,t)=>i.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[i.jsxs("div",{className:"flex-1 space-y-1",children:[i.jsx(g.Skeleton,{className:"h-4 w-3/4"}),i.jsx(g.Skeleton,{className:"h-3 w-1/2"}),i.jsx(g.Skeleton,{className:"mt-1 h-5 w-20"})]}),i.jsx(g.Skeleton,{className:"h-8 w-8 rounded-full"})]},t))})}const la=z.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-B84UtAxm.cjs")));function ca(){const[e,t]=z.useState(!1);return i.jsx(g.TooltipProvider,{children:i.jsxs(g.Tooltip,{delayDuration:0,children:[i.jsxs(g.Sheet,{open:e,onOpenChange:t,children:[i.jsx(g.SheetTrigger,{asChild:!0,children:i.jsx(g.TooltipTrigger,{asChild:!0,children:i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsxs(I.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[i.jsx(b.History,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"View revision history"})]}),i.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})})}),i.jsx(g.SheetContent,{className:"flex h-[100vh] flex-col",children:e&&i.jsx(h.Suspense,{fallback:i.jsx(oa,{}),children:i.jsx(la,{isOpen:e})})})]}),i.jsx(g.TooltipContent,{side:"bottom",children:i.jsx("p",{children:"Revision history"})})]})})}const It=({permission:e,permissions:t,children:n,fallback:s=null})=>{const{hasPermission:r}=g.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?s:n},ua={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},da=()=>{const e=N(),t=P.useQueryClient(),n=k(),{data:s}=me();return P.useMutation({mutationFn:async r=>await n(e,{action:y.CREATE_PAGE,data:r}),onSuccess:(r,a)=>{var l;a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES,a==null?void 0:a.lang]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const o=a.template?`Page created from "${a.template.name}" template`:a.hasSlug===!1?"New "+((l=p.find(s,{key:a.pageType}))==null?void 0:l.name)+" added successfully":"New page added successfully";F.toast.success(o)},onError:(r,a)=>{const o=p.find(s,{key:a.pageType});F.toast.error(`Failed to add new ${o!=null&&o.hasSlug?"page":o.name}.`,{description:p.get(ua,r.message,r.message)})}})},fa=()=>{const e=N(),t=P.useQueryClient(),n=k(),{data:s}=ge(),{data:r}=me();return P.useMutation({mutationFn:async a=>await n(e,{action:y.UPDATE_PAGE,data:a}),onSuccess:(a,o)=>{(s==null?void 0:s.id)===(o==null?void 0:o.id)&&t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]}),o&&(o!=null&&o.primaryPage||o!=null&&o.seo)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,o==null?void 0:o.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(a,o)=>{const l=p.find(r,{key:o.pageType});F.toast.error(`Failed to update ${l!=null&&l.hasSlug?"page":l.name}.`,{description:a.message})}})},ha=()=>{const e=N(),t=P.useQueryClient(),n=k(),{data:s}=me();return P.useMutation({mutationFn:async r=>n(e,{action:y.DELETE_PAGE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{if(r.code==="PAGE_LOCKED"){F.toast.error("Delete not allowed",{description:"Page is currently being edited by another user."});return}a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(r,a)=>{const o=p.find(s,{key:a.pageType});F.toast.error(`Failed to delete ${o!=null&&o.hasSlug?"page":o.name}.`,{description:r.message})}})},ga=()=>{const e=N(),t=P.useQueryClient(),n=k(),{data:s}=me();return P.useMutation({mutationFn:async r=>n(e,{action:y.TAKE_OFFLINE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const o=p.find(s,{key:a.pageType});F.toast.success(o!=null&&o.hasSlug?"Page unpublished successfully.":"New "+o.name+" added successfully.")},onError:(r,a)=>{const o=p.find(s,{key:a.pageType});F.toast.error(`Failed to take offline ${o!=null&&o.hasSlug?"page":o.name}.`,{description:r.message})}})},Tn=()=>{const e=N(),t=k(),n=P.useQueryClient(),{data:s}=ne(),{savePageAsync:r}=g.useSavePage();return P.useMutation({mutationFn:async({ids:a})=>(await r(),t(e,{action:y.PUBLISH_CHANGES,data:{ids:a}})),onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_CHANGES]}),n.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),n.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,s==null?void 0:s.id]})},onError:a=>{console.log("##",a),F.toast.error("Failed to publish pages.")}})},ma=()=>{const e=N(),t=k(),n=P.useQueryClient();return P.useMutation({mutationFn:async s=>{var r;return t(e,{action:y.MARK_AS_TEMPLATE,data:{id:(r=s.page)==null?void 0:r.id,name:s.name,description:s.description,pageType:s.pageType,previewImage:s.previewImage}})},onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page marked as template successfully.")},onError:()=>{F.toast.error("Failed to mark page as template.")}})},Ea=()=>{const e=N(),t=k(),n=P.useQueryClient();return P.useMutation({mutationFn:async s=>t(e,{action:y.UNMARK_AS_TEMPLATE,data:{id:s==null?void 0:s.id}}),onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page unmarked as template successfully.")},onError:()=>{F.toast.error("Failed to unmark page as template.")}})},pa=()=>{const e=N(),t=k(),n=P.useQueryClient();return P.useMutation({mutationFn:async({id:s,slug:r})=>t(e,{action:y.CHANGE_SLUG,data:{id:s,slug:r}}),onSuccess:(s,{primaryPage:r})=>{F.toast.success("Slug changed successfully."),r?n.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,r]}):n.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:()=>{F.toast.error("Failed to change slug")}})},ya=h.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-ysv37LxZ.cjs")));function Aa({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:n,isPending:s}=Tn();return i.jsx(g.Dialog,{open:e,onOpenChange:s?()=>{}:t,children:e&&i.jsx(h.Suspense,{fallback:i.jsx("div",{className:"h-96 w-96 animate-pulse bg-gray-100"}),children:i.jsx(ya,{onClose:t,isPending:s,publishPage:n})})})}const rs=e=>{const{fallbackLang:t}=g.useLanguages(),{data:n}=Pe(),{data:s,isFetching:r}=Te(),a=h.useMemo(()=>{const o={[t]:!0};return p.each(p.get(n,"languages"),l=>{const c=p.find(s,{lang:l});o[l]=!!c}),o},[t,s,n]);return r||p.isEmpty(e)||e&&a[e]},Sa={particleCount:350,spread:120,origin:{y:.6},angle:90},Ta={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},Pa=async()=>{const{default:e}=await import("canvas-confetti");return e},Nt=e=>{let t=Ta[e];t||(t={});const n={...Sa,...t};Pa().then(s=>s(n))};function Qt({children:e,content:t,side:n="bottom",delayDuration:s=700,showTooltip:r=!0}){return r?i.jsx(g.TooltipProvider,{children:i.jsxs(g.Tooltip,{delayDuration:s,children:[i.jsx(g.TooltipTrigger,{asChild:!0,children:e}),i.jsx(g.TooltipContent,{side:n,sideOffset:10,children:i.jsx("p",{children:t})})]})}):e}const xa=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-B5rev9W3.cjs"))),_a=h.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-DTxxfo0H.cjs"))),wa=h.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-BeSMdSd5.cjs"))),va=()=>{const{t:e}=he.useTranslation(),{selectedLang:t,fallbackLang:n}=g.useLanguages(),s=ae("getPreviewUrl",async E=>E),[r,a]=h.useState(""),{data:o}=ne(),{data:l}=Te(),{data:c}=me(),d=h.useMemo(()=>{var E;return(E=l==null?void 0:l.find(m=>(m==null?void 0:m.lang)===t))==null?void 0:E.slug},[t,l]),u=h.useCallback(E=>{var m;return(m=p.find(c,{key:E}))==null?void 0:m.hasSlug},[c]),f=t===n?"":t;return h.useEffect(()=>{(async()=>{if(typeof s=="function"){const E=!u(o==null?void 0:o.pageType),m=await s(E?`/_partial/${f!==""?f+"/":""}${o==null?void 0:o.id}`:d||"");a(m)}else a("")})()},[s,d,o==null?void 0:o.pageType,u,o==null?void 0:o.id,f]),i.jsx(i.Fragment,{children:i.jsx(Qt,{content:e("Open preview in new tab"),delayDuration:0,children:i.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:i.jsx(I.Button,{variant:"ghost",size:"sm",className:"gap-2",children:i.jsx(b.Play,{className:"h-4 w-4"})})})})})},ba=()=>{const{t:e}=he.useTranslation(),[t,n]=g.useRightPanel();return i.jsxs(i.Fragment,{children:[i.jsx(Qt,{content:e("Theme"),delayDuration:0,children:i.jsx(I.Button,{variant:t==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>n(t==="theme"?"block":"theme"),children:i.jsx(b.Palette,{className:"h-4 w-4"})})}),i.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})},Ca=()=>{const{t:e}=he.useTranslation(),[t,n]=h.useState(!1),{isLocked:s}=ie(),{savePageAsync:r,saveState:a}=g.useSavePage();h.useEffect(()=>{const u=f=>{a==="UNSAVED"&&(f.preventDefault(),f.returnValue=!1)};return a==="UNSAVED"&&window.addEventListener("beforeunload",u),()=>{window.removeEventListener("beforeunload",u)}},[a]);const o=h.useCallback(async()=>{t||(n(!0),await r(),n(!1))},[r,t]),{buttonIcon:l,buttonClass:c,tooltipContent:d}=h.useMemo(()=>{switch(a){case"UNSAVED":return{tooltipContent:e("Save draft"),buttonIcon:i.jsx(b.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:e("Saving"),buttonIcon:i.jsx(b.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:e("Saved"),buttonIcon:i.jsx(b.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[a,e]);return s?null:i.jsxs(I.Button,{size:"sm",variant:"ghost",onClick:o,className:`${c} w-24 max-w-24`,children:[l," ",d]})},Ia=()=>{const{t:e}=he.useTranslation(),{selectedLang:t}=g.useLanguages(),{data:n}=ge(),{data:s}=Te(),[r,a]=h.useState(!1),[o,l]=h.useState(!1),[c,d]=h.useState(null),[u,f]=h.useState(!1),{savePageAsync:E}=g.useSavePage(),[m,T]=h.useState(!1),{data:S}=ne(),{mutate:x,isPending:w}=Tn(),{needTranslations:A}=g.useSavePage(),v=A(),{buttonText:G,buttonClassName:q,isPublished:L,hasUnpublishedChanges:oe}=h.useMemo(()=>{const K=S&&(S==null?void 0:S.online),ee=!p.isEmpty(S==null?void 0:S.changes);let xe=K?"hover:bg-green-600 bg-green-500":"",se=e(K?"Published":"Publish");return K&&ee&&(xe="hover:bg-blue-600 bg-blue-500",se=e("Publish")),{buttonClassName:xe,isPublished:K,hasUnpublishedChanges:ee,buttonText:se}},[S,e]),de=async()=>{if(v){T(!0);return}V()},V=()=>{const K=[n==null?void 0:n.id,n==null?void 0:n.primaryPage];x({ids:p.compact(K)},{onSuccess:()=>Nt("TOP_RIGHT")})},j=()=>{T(!1),V()},O=async()=>{T(!1),await E()},$=h.useMemo(()=>p.map(s??[],"id"),[s]);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex",children:[i.jsxs(I.Button,{size:"sm",onClick:de,disabled:w||!(S!=null&&S.id),className:`relative flex items-center gap-1 overflow-hidden rounded-r-none text-white transition-all duration-300 ease-in-out ${q}`,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[i.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${o?"-translate-y-10":""}`,children:L?oe?i.jsx(b.Pencil,{className:"h-4 w-4"}):i.jsx(b.Send,{className:"h-4 w-4"}):i.jsx(b.Rocket,{className:"h-4 w-4"})}),i.jsx("span",{className:`absolute inset-0 left-3 flex items-center transition-transform duration-300 ease-in-out ${o?"":"translate-y-10"}`,children:L?i.jsx(b.Rocket,{className:"h-4 w-4"}):i.jsx(b.Send,{className:"h-4 w-4"})}),i.jsx("span",{children:G}),t?`(${p.upperCase(t)})`:""]}),i.jsxs(g.DropdownMenu,{children:[i.jsx(g.DropdownMenuTrigger,{asChild:!0,children:i.jsx(I.Button,{size:"sm",disabled:w||!(S!=null&&S.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${q}`,children:i.jsx(b.ChevronDown,{className:"h-4 w-4"})})}),i.jsxs(g.DropdownMenuContent,{align:"end",className:"w-52",children:[i.jsxs(g.DropdownMenuItem,{disabled:w,className:"cursor-pointer text-xs",onClick:()=>x({ids:$},{onSuccess:()=>Nt("TOP_RIGHT")}),children:[e("Publish")," with translation pages"]}),!L&&i.jsxs(g.DropdownMenuItem,{disabled:w,className:"cursor-pointer text-xs",onClick:()=>x({ids:[S==null?void 0:S.id]},{onSuccess:()=>Nt("TOP_RIGHT")}),children:[e("Publish")," page"]}),i.jsxs(g.DropdownMenuItem,{onClick:()=>a(!0),className:"cursor-pointer text-xs",children:[e("Open")," publish menu"]}),L&&oe&&i.jsx(g.DropdownMenuItem,{onClick:()=>f(!0),className:"cursor-pointer text-xs",children:e("View Unpublished changes")}),L&&i.jsxs(g.DropdownMenuItem,{onClick:()=>d(n),className:"cursor-pointer text-xs",children:[e("Unpublish")," page ",t?`(${p.upperCase(t)})`:""]})]})]})]}),i.jsx(Aa,{showModal:r,onClose:()=>a(!1)}),c&&i.jsx(h.Suspense,{children:i.jsx(xa,{page:c,onClose:()=>d(null)})}),u&&i.jsx(h.Suspense,{children:i.jsx(wa,{open:u,onOpenChange:f,compare:[{label:"draft",uid:`draft:${S==null?void 0:S.id}`,item:S},{label:"live",uid:`live:${S==null?void 0:S.id}`,item:{}}]})}),m&&i.jsx(h.Suspense,{children:i.jsx(_a,{isOpen:m,onClose:O,onContinue:j,isPending:w})})]})};function Na(){const{isLocked:e}=ie(),[t]=ue(),n=t.get("lang"),s=rs(n);return e||!s?i.jsx("div",{}):i.jsxs("div",{className:"flex items-center justify-end gap-1",children:[i.jsx(ca,{}),i.jsx(It,{permission:re.EDIT_THEME,children:i.jsx(ba,{})}),i.jsx(va,{}),i.jsx(It,{permission:re.SAVE_PAGE,children:i.jsx(Ca,{})}),i.jsx(It,{permission:re.PUBLISH_PAGE,children:i.jsx(Ia,{})})]})}const La=h.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-zqGqpcww.cjs"))),ja=()=>{const{dynamicPage:e,allLangPages:t,isFetching:n}=Yn(),s=t.length>0;return n?null:i.jsxs("div",{className:"relative",children:[!e&&i.jsx(sa,{hasDynamicPage:s}),i.jsx(h.Suspense,{children:i.jsx(La,{})})]})},Ga=()=>{const{data:e,isFetching:t}=ge(),{data:n,isFetching:s}=ne(),r=p.get(n,"dynamic",!1),a=gn(),o=I.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,d=jr(),u=t||s,E=(c?`Partial: ${e==null?void 0:e.name} `:`${l}${a}`).replace(window.location.host,"");return i.jsxs("div",{className:"relative flex items-center",children:[i.jsx("div",{className:Gt.cn("flex h-8 w-auto max-w-[600px] items-center rounded-l-md border border-r-0 border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800",u&&"max-w-0 overflow-hidden opacity-0"),children:i.jsx(na,{})}),i.jsxs("div",{className:Gt.cn("flex h-8 w-auto max-w-[600px] items-center rounded-r-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800"+(c?" pr-2":""),u&&"max-w-0 overflow-hidden opacity-0"),children:[i.jsx(ss,{}),i.jsxs("div",{className:"flex w-full items-center overflow-hidden",children:[i.jsx("div",{className:`w-full max-w-[200px] overflow-hidden overflow-ellipsis whitespace-nowrap pl-1 text-xs ${c?"italic text-gray-400":"font-mono text-gray-500"}`,children:E==="/"?i.jsxs("span",{className:"text-gray-900",children:["/",i.jsx("span",{className:"text-[11px] font-light italic text-gray-400",children:"(Homepage)"})]}):E}),!c&&i.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",children:i.jsx("div",{className:"ml-2 mr-px flex-shrink-0 rounded-sm p-1.5 text-gray-500 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300",children:i.jsx(b.ExternalLink,{className:"h-4 w-4",strokeWidth:1})})})]})]}),r&&o&&i.jsx(ja,{})]})},ka=()=>i.jsxs("div",{className:"grid h-full w-full grid-cols-3 items-center px-2",children:[i.jsx("div",{className:"flex justify-start",children:i.jsx(ia,{})}),i.jsx("div",{className:"flex justify-center",children:i.jsx(Ga,{})}),i.jsx("div",{className:"flex justify-end",children:i.jsx(Na,{})})]}),as=()=>{const e=P.useQueryClient(),{data:t}=P.useQuery({queryKey:[y.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:h.useCallback(s=>{e.setQueryData([y.AI_CONTEXT],s)},[e]),aiContext:t}},Oa=()=>{const e=N(),{aiContext:t}=as(),n=k();return h.useCallback(async(s,r,a,o)=>n(e,{action:y.ASK_AI,data:{type:s,prompt:r,blocks:a,context:t,lang:o}}),[e,t,n])},Ra=e=>h.useMemo(()=>{if(!e||p.isEmpty(e))return{blocks:[]};const t=p.filter(e,n=>!p.includes(n==null?void 0:n._type,"@chai/"));return{blocks:Ar.syncBlocksWithDefaultProps(t)}},[e]),Da=()=>{const[e]=ue(),t=e.get("page"),n=N(),{setAiContext:s}=as(),[,r]=mn(),[,a]=Lr(),[,o]=g.useIsPageLoaded(),l=k();return P.useQuery({queryKey:[y.GET_DRAFT_PAGE,t],staleTime:1/0,gcTime:0,queryFn:async()=>{o(!1);const c=await l(n,{action:y.GET_DRAFT_PAGE,data:{id:t,draft:!0}}),d=c.blocks??[],u=p.find(d,{_type:"@chai/ai-context"});return s(p.get(u,"_value","")||""),r(f=>({...f,lastSaved:c.lastSaved})),a(p.get(c,"metadata",{})),setTimeout(()=>o(!0),500),d},enabled:!!t})},is=()=>{const{data:e}=ne(),{data:t}=ge(),n=N(),s=k(),r=Vt(),a=gn();return P.useQuery({queryKey:[y.GET_BUILDER_PAGE_DATA,t==null?void 0:t.id,a],staleTime:1/0,gcTime:0,queryFn:async()=>s(n,{action:y.GET_BUILDER_PAGE_DATA,data:{pageType:e==null?void 0:e.pageType,lang:(t==null?void 0:t.lang)||r,dynamic:e==null?void 0:e.dynamic,pageProps:{slug:(t==null?void 0:t.slug)+a,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:r,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id,metadata:e.metadata||{}}}}),enabled:!!(e!=null&&e.pageType)&&!!t.id})},os=()=>{const e=N(),t=P.useQueryClient(),n=k();return P.useMutation({mutationFn:async s=>n(e,{action:y.UPDATE_WEBSITE_FIELDS,data:s}),onSuccess:(s,r)=>{var a;t.invalidateQueries({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS]}),(a=r==null?void 0:r.settings)!=null&&a.theme||F.toast.success("Website settings updated successfully.")},onError:s=>{F.toast.error("Failed to update website settings",{description:s.message})}})},Ma=()=>{const e=N(),t=P.useQueryClient(),n=k(),{selectedLang:s}=g.useLanguages();return P.useMutation({mutationFn:async r=>n(e,{action:y.ADD_GLOBAL_SCHEMA,data:{...r,lang:s}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema added successfully.")},onError:r=>{F.toast.error("Failed to add schema",{description:r.message})}})},Ua=()=>{const e=N(),t=P.useQueryClient(),n=k(),{selectedLang:s}=g.useLanguages();return P.useMutation({mutationFn:async r=>n(e,{action:y.UPDATE_GLOBAL_SCHEMA,data:{...r,lang:s}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema updated successfully.")},onError:r=>{F.toast.error("Failed to update schema",{description:r.message})}})},Ba=()=>{const e=N(),t=P.useQueryClient(),n=k();return P.useMutation({mutationFn:async s=>n(e,{action:y.DELETE_GLOBAL_SCHEMA,data:{id:s}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema deleted successfully.")},onError:s=>{F.toast.error("Failed to delete schema",{description:s.message})}})},Fa=()=>{const e=N(),t=k();return P.useMutation({mutationFn:async n=>t(e,{action:y.TOGGLE_PAGE_GLOBAL_SCHEMA,data:n}),onError:n=>{F.toast.error("Failed to toggle schema",{description:n.message})}})},qa=()=>{const e=N(),t=k();return P.useMutation({mutationFn:async n=>t(e,{action:y.APPLY_SCHEMA_TO_ALL_PAGES,data:{schemaId:n}}),onSuccess:n=>{F.toast.success(`Schema applied to ${n.count} page(s)`)},onError:n=>{F.toast.error("Failed to apply schema to all pages",{description:n.message})}})},Ka=()=>{const e=N(),t=k();return P.useMutation({mutationFn:async n=>t(e,{action:y.REMOVE_SCHEMA_FROM_ALL_PAGES,data:{schemaId:n}}),onSuccess:n=>{F.toast.success(`Schema removed from ${n.count} page(s)`)},onError:n=>{F.toast.error("Failed to remove schema from all pages",{description:n.message})}})},kn={async getUILibraryBlock(e,t,n){const s=await t(n,{action:"GET_LIBRARY_ITEM",data:{id:e.id}}),r=p.get(s,"html",""),a=p.get(s,"blocks",[]);return p.isArray(a)?a:Sr.getBlocksFromHTML(r)},async getUILibraryBlocks(e,t,n){return(await t(n,{action:"GET_LIBRARY_ITEMS",data:{id:e.id}})).map(r=>({...r}))}},Va=()=>{const e=N(),t=k();return P.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const s=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return s.forEach(r=>{I.registerChaiLibrary(r.id,{name:r.isSiteLibrary?r.name+" (Current Site) ":r.name,description:r.description,getBlocksList:a=>kn.getUILibraryBlocks(a,t,e),getBlock:({block:a})=>kn.getUILibraryBlock(a,t,e)})}),s}})},Ha=(e=300)=>{const t=ae("onLogout",p.noop),n=ae("getAccessToken"),s=N();return P.useQuery({queryKey:["check-user-access"],queryFn:async()=>{const r=await n(),o=await $n(s+"?action=check_user_access",{action:"CHECK_USER_ACCESS"},{Authorization:`Bearer ${r}`});if(o.status===401)throw console.log("401 Response",o),F.toast.error("You do not have access to edit this website. Please contact administrator"),await t("UNAUTHORIZED"),new Error("Unauthorized");return o},refetchInterval:e*1e3,refetchIntervalInBackground:!0,retry:!1})},ls=()=>{const e=N(),t=k(),{user:n}=Kt(),s=n==null?void 0:n.id;return P.useQuery({queryKey:[y.GET_ROLE_AND_PERMISSIONS,s],queryFn:()=>t(e,{action:y.GET_ROLE_AND_PERMISSIONS,data:{}}),enabled:!!s,staleTime:1/0})},Qa=()=>{const e=N(),t=k(),[,n]=mn(),s=P.useQueryClient();return{onSave:async({page:a,blocks:o,needTranslations:l})=>{try{const c=await t(e,{action:"UPDATE_PAGE",data:{id:a,blocks:o,needTranslations:l}});return c.code==="PAGE_LOCKED"?!0:(n(d=>({...d,lastSaved:new Date().toISOString()})),s.setQueryData([y.GET_LANGUAGE_PAGES,a],d=>d&&(d==null?void 0:d.map(u=>(u==null?void 0:u.id)===a?{...u,changes:["Page"]}:u))),s.setQueryData([y.GET_WEBSITE_PAGES],d=>d&&(d==null?void 0:d.map(u=>(u==null?void 0:u.id)===a?{...u,changes:["Page"]}:u))),c)}catch(c){return console.error(c),new Error("Failed to save blocks")}}}},za=()=>{const{data:e}=An(),t=N(),n=k();return{getPartialBlocks:h.useCallback(async()=>{const s={};for(const r of e??[])p.isEmpty(r==null?void 0:r.slug)&&(s[r.id]={type:r.pageType,name:p.startCase(r.name??r.slug),description:""});return s},[e]),getPartialBlockBlocks:h.useCallback(async s=>{if(!s)return[];try{const r=await n(t,{action:"GET_DRAFT_PAGE",data:{id:s,draft:!0,editor:!1,mergePartials:!0}});return p.filter(r.blocks,a=>p.has(a,"_id"))}catch(r){return console.error(r),[]}},[n,t])}},$a=h.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-content-Dyw4RHCV.cjs"))),cs="chai-chat-panel",Wa=({className:e="h-full w-full"})=>i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",version:"1.1",className:e,children:[i.jsx("title",{children:"ai"}),i.jsx("g",{id:"Page-1",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:i.jsx("g",{id:"icon",fill:"currentColor",transform:"translate(64.000000, 64.000000)",children:i.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"})})})]}),Ya=({isActive:e,show:t})=>g.useBuilderProp("flags.ai",!1)?i.jsx(I.Button,{size:"icon",className:"p-0 [&_svg]:size-6",onClick:t,variant:e?"default":"ghost",children:i.jsx(Wa,{className:e?"h-5 w-5 text-white":"h-5 w-5 text-primary"})}):null,Ja={id:cs,label:"AI Assistant",button:Ya,panel:$a,position:"top"},Za=h.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-B-QUotOn.cjs"))),Xa=({isActive:e,show:t})=>{const{data:n}=Pe();return!p.has(n,"languages")||!p.get(n,"languages",[]).length?null:i.jsx(I.Button,{size:"sm",onClick:t,variant:e?"default":"ghost",children:i.jsx(b.LanguagesIcon,{className:"h-4 w-4"})})},us="lang",ei={id:us,label:"Languages",position:"top",panel:Za,button:Xa,view:"modal",width:400},ti=h.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-CHGdB8_7.cjs"))),ds="seo",ni=({isActive:e,show:t})=>{const{data:n}=ne(),s=Jn(n==null?void 0:n.pageType);return!p.has(s,"hasSlug")||!s.hasSlug?null:i.jsx(I.Button,{size:"icon",className:"my-1 p-0",onClick:t,variant:e?"default":"ghost",children:i.jsxs("svg",{stroke:"currentColor",fill:"none",style:{height:"20px",width:"20px"},strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",children:[i.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"}),i.jsx("path",{d:"M14 16h-4v-8h4"}),i.jsx("path",{d:"M11 12h2"}),i.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"})]})})},si={id:ds,label:"SEO",panel:ti,button:ni,position:"top",width:600,view:"modal"},fs="user-info",ri=()=>{const{t:e}=he.useTranslation(),{user:t,logout:n}=Kt(),s=ae("onLogout",p.noop);return t?i.jsxs(g.HoverCard,{children:[i.jsx(g.HoverCardTrigger,{asChild:!0,children:i.jsx(I.Button,{variant:"ghost",className:"text-sm font-medium",children:i.jsx(b.User,{className:"h-4 w-4"})})}),i.jsxs(g.HoverCardContent,{className:"w-auto space-y-2 p-4",children:[i.jsx("div",{className:"text-sm font-medium",children:t.name??t.email}),i.jsx("div",{className:"text-xs text-muted-foreground",children:t.email}),i.jsxs(g.AlertDialog,{children:[i.jsx(g.AlertDialogTrigger,{asChild:!0,children:i.jsx(I.Button,{variant:"outline",size:"sm",className:"w-full",children:e("Logout")})}),i.jsxs(g.AlertDialogContent,{children:[i.jsxs(g.AlertDialogHeader,{children:[i.jsx(g.AlertDialogTitle,{children:e("Are you sure you want to logout?")}),i.jsx(g.AlertDialogDescription,{children:e("You will be redirected to the login page.")})]}),i.jsxs(g.AlertDialogFooter,{children:[i.jsx(g.AlertDialogCancel,{children:e("Cancel")}),i.jsx(g.AlertDialogAction,{onClick:()=>{n(),p.isFunction(s)&&s()},children:e("Logout")})]})]})]})]})]}):null},ai={id:fs,label:"User Info",button:ri,position:"bottom"},ii=()=>{I.registerChaiSidebarPanel(ds,si),I.registerChaiSidebarPanel(us,ei),I.registerChaiSidebarPanel(fs,ai),I.registerChaiSidebarPanel(cs,Ja)};var C={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return On(this.context.count)},getNextContextId(){return On(this.context.count++)}};function On(e){const t=String(e),n=t.length-1;return C.context.id+(n?String.fromCharCode(96+n):"")+t}function Xe(e){C.context=e}var hs=!1,oi=(e,t)=>e===t,kt=Symbol("solid-proxy"),gs=typeof Proxy=="function",Pn=Symbol("solid-track"),Ot={equals:oi},ms=xs,Ee=1,Rt=2,Es={owned:null,cleanups:null,context:null,owner:null},Xt={},D=null,en=null,li=null,U=null,Z=null,fe=null,zt=0;function ye(e,t){const n=U,s=D,r=e.length===0,a=t===void 0?s:t,o=r?Es:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>Y(()=>at(o)));D=o,U=null;try{return ce(l,!0)}finally{U=n,D=s}}function H(e,t){t=t?Object.assign({},Ot,t):Ot;const n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},s=r=>(typeof r=="function"&&(r=r(n.value)),Ps(n,r));return[Ts.bind(n),s]}function ps(e,t,n){const s=$t(e,t,!0,Ee);Ye(s)}function Ae(e,t,n){const s=$t(e,t,!1,Ee);Ye(s)}function xn(e,t,n){ms=Ti;const s=$t(e,t,!1,Ee);(!n||!n.render)&&(s.user=!0),fe?fe.push(s):Ye(s)}function W(e,t,n){n=n?Object.assign({},Ot,n):Ot;const s=$t(e,t,!0,0);return s.observers=null,s.observerSlots=null,s.comparator=n.equals||void 0,Ye(s),Ts.bind(s)}function ci(e){return e&&typeof e=="object"&&"then"in e}function ui(e,t,n){let s,r,a;s=!0,r=e,a={};let o=null,l=Xt,c=null,d=!1,u="initialValue"in a,f=typeof s=="function"&&W(s);const E=new Set,[m,T]=(a.storage||H)(a.initialValue),[S,x]=H(void 0),[w,A]=H(void 0,{equals:!1}),[v,G]=H(u?"ready":"unresolved");C.context&&(c=C.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:C.load&&C.has(c)&&(l=C.load(c)));function q(j,O,$,K){return o===j&&(o=null,K!==void 0&&(u=!0),(j===l||O===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(K,{value:O})),l=Xt,L(O,$)),O}function L(j,O){ce(()=>{O===void 0&&T(()=>j),G(O!==void 0?"errored":u?"ready":"unresolved"),x(O);for(const $ of E.keys())$.decrement();E.clear()},!1)}function oe(){const j=yi,O=m(),$=S();if($!==void 0&&!o)throw $;return U&&U.user,O}function de(j=!0){if(j!==!1&&d)return;d=!1;const O=f?f():s;if(O==null||O===!1){q(o,Y(m));return}let $;const K=l!==Xt?l:Y(()=>{try{return r(O,{value:m(),refetching:j})}catch(ee){$=ee}});if($!==void 0){q(o,void 0,Lt($),O);return}else if(!ci(K))return q(o,K,void 0,O),K;return o=K,"v"in K?(K.s===1?q(o,K.v,void 0,O):q(o,void 0,Lt(K.v),O),K):(d=!0,queueMicrotask(()=>d=!1),ce(()=>{G(u?"refreshing":"pending"),A()},!1),K.then(ee=>q(K,ee,void 0,O),ee=>q(K,void 0,Lt(ee),O)))}Object.defineProperties(oe,{state:{get:()=>v()},error:{get:()=>S()},loading:{get(){const j=v();return j==="pending"||j==="refreshing"}},latest:{get(){if(!u)return oe();const j=S();if(j&&!o)throw j;return m()}}});let V=D;return f?ps(()=>(V=D,de(!1))):de(!1),[oe,{refetch:j=>As(V,()=>de(j)),mutate:T}]}function di(e){return ce(e,!1)}function Y(e){if(U===null)return e();const t=U;U=null;try{return e()}finally{U=t}}function fi(e,t,n){const s=Array.isArray(e);let r,a=n&&n.defer;return o=>{let l;if(s){l=Array(e.length);for(let d=0;d<e.length;d++)l[d]=e[d]()}else l=e();if(a)return a=!1,o;const c=Y(()=>t(l,r,o));return r=l,c}}function ys(e){xn(()=>Y(e))}function $e(e){return D===null||(D.cleanups===null?D.cleanups=[e]:D.cleanups.push(e)),e}function Rn(){return D}function As(e,t){const n=D,s=U;D=e,U=null;try{return ce(t,!0)}catch(r){_n(r)}finally{D=n,U=s}}function hi(e){const t=U,n=D;return Promise.resolve().then(()=>{U=t,D=n;let s;return ce(e,!1),U=D=null,s?s.done:void 0})}var[gi,Cl]=H(!1);function mi(){return[gi,hi]}function Ei(e,t){const n=Symbol("context");return{id:n,Provider:Pi(n),defaultValue:e}}function pi(e){let t;return D&&D.context&&(t=D.context[e.id])!==void 0?t:e.defaultValue}function Ss(e){const t=W(e),n=W(()=>sn(t()));return n.toArray=()=>{const s=n();return Array.isArray(s)?s:s!=null?[s]:[]},n}var yi;function Ts(){if(this.sources&&this.state)if(this.state===Ee)Ye(this);else{const e=Z;Z=null,ce(()=>Mt(this),!1),Z=e}if(U){const e=this.observers?this.observers.length:0;U.sources?(U.sources.push(this),U.sourceSlots.push(e)):(U.sources=[this],U.sourceSlots=[e]),this.observers?(this.observers.push(U),this.observerSlots.push(U.sources.length-1)):(this.observers=[U],this.observerSlots=[U.sources.length-1])}return this.value}function Ps(e,t,n){let s=e.value;return(!e.comparator||!e.comparator(s,t))&&(e.value=t,e.observers&&e.observers.length&&ce(()=>{for(let r=0;r<e.observers.length;r+=1){const a=e.observers[r],o=en&&en.running;o&&en.disposed.has(a),(o?!a.tState:!a.state)&&(a.pure?Z.push(a):fe.push(a),a.observers&&_s(a)),o||(a.state=Ee)}if(Z.length>1e6)throw Z=[],new Error},!1)),t}function Ye(e){if(!e.fn)return;at(e);const t=zt;Ai(e,e.value,t)}function Ai(e,t,n){let s;const r=D,a=U;U=D=e;try{s=e.fn(t)}catch(o){return e.pure&&(e.state=Ee,e.owned&&e.owned.forEach(at),e.owned=null),e.updatedAt=n+1,_n(o)}finally{U=a,D=r}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&"observers"in e?Ps(e,s):e.value=s,e.updatedAt=n)}function $t(e,t,n,s=Ee,r){const a={fn:e,state:s,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:D,context:D?D.context:null,pure:n};return D===null||D!==Es&&(D.owned?D.owned.push(a):D.owned=[a]),a}function Dt(e){if(e.state===0)return;if(e.state===Rt)return Mt(e);if(e.suspense&&Y(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<zt);)e.state&&t.push(e);for(let n=t.length-1;n>=0;n--)if(e=t[n],e.state===Ee)Ye(e);else if(e.state===Rt){const s=Z;Z=null,ce(()=>Mt(e,t[0]),!1),Z=s}}function ce(e,t){if(Z)return e();let n=!1;t||(Z=[]),fe?n=!0:fe=[],zt++;try{const s=e();return Si(n),s}catch(s){n||(fe=null),Z=null,_n(s)}}function Si(e){if(Z&&(xs(Z),Z=null),e)return;const t=fe;fe=null,t.length&&ce(()=>ms(t),!1)}function xs(e){for(let t=0;t<e.length;t++)Dt(e[t])}function Ti(e){let t,n=0;for(t=0;t<e.length;t++){const s=e[t];s.user?e[n++]=s:Dt(s)}if(C.context){if(C.count){C.effects||(C.effects=[]),C.effects.push(...e.slice(0,n));return}Xe()}for(C.effects&&(C.done||!C.count)&&(e=[...C.effects,...e],n+=C.effects.length,delete C.effects),t=0;t<n;t++)Dt(e[t])}function Mt(e,t){e.state=0;for(let n=0;n<e.sources.length;n+=1){const s=e.sources[n];if(s.sources){const r=s.state;r===Ee?s!==t&&(!s.updatedAt||s.updatedAt<zt)&&Dt(s):r===Rt&&Mt(s,t)}}}function _s(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=Rt,n.pure?Z.push(n):fe.push(n),n.observers&&_s(n))}}function at(e){let t;if(e.sources)for(;e.sources.length;){const n=e.sources.pop(),s=e.sourceSlots.pop(),r=n.observers;if(r&&r.length){const a=r.pop(),o=n.observerSlots.pop();s<r.length&&(a.sourceSlots[o]=s,r[s]=a,n.observerSlots[s]=o)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)at(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)at(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function Lt(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function _n(e,t=D){throw Lt(e)}function sn(e){if(typeof e=="function"&&!e.length)return sn(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const s=sn(e[n]);Array.isArray(s)?t.push.apply(t,s):t.push(s)}return t}return e}function Pi(e,t){return function(s){let r;return Ae(()=>r=Y(()=>(D.context={...D.context,[e]:s.value},Ss(()=>s.children))),void 0),r}}var rn=Symbol("fallback");function Ut(e){for(let t=0;t<e.length;t++)e[t]()}function xi(e,t,n={}){let s=[],r=[],a=[],o=0,l=t.length>1?[]:null;return $e(()=>Ut(a)),()=>{let c=e()||[],d=c.length,u,f;return c[Pn],Y(()=>{let m,T,S,x,w,A,v,G,q;if(d===0)o!==0&&(Ut(a),a=[],s=[],r=[],o=0,l&&(l=[])),n.fallback&&(s=[rn],r[0]=ye(L=>(a[0]=L,n.fallback())),o=1);else if(o===0){for(r=new Array(d),f=0;f<d;f++)s[f]=c[f],r[f]=ye(E);o=d}else{for(S=new Array(d),x=new Array(d),l&&(w=new Array(d)),A=0,v=Math.min(o,d);A<v&&s[A]===c[A];A++);for(v=o-1,G=d-1;v>=A&&G>=A&&s[v]===c[G];v--,G--)S[G]=r[v],x[G]=a[v],l&&(w[G]=l[v]);for(m=new Map,T=new Array(G+1),f=G;f>=A;f--)q=c[f],u=m.get(q),T[f]=u===void 0?-1:u,m.set(q,f);for(u=A;u<=v;u++)q=s[u],f=m.get(q),f!==void 0&&f!==-1?(S[f]=r[u],x[f]=a[u],l&&(w[f]=l[u]),f=T[f],m.set(q,f)):a[u]();for(f=A;f<d;f++)f in S?(r[f]=S[f],a[f]=x[f],l&&(l[f]=w[f],l[f](f))):r[f]=ye(E);r=r.slice(0,o=d),s=c.slice(0)}return r});function E(m){if(a[f]=m,l){const[T,S]=H(f);return l[f]=S,t(c[f],T)}return t(c[f])}}}function _i(e,t,n={}){let s=[],r=[],a=[],o=[],l=0,c;return $e(()=>Ut(a)),()=>{const d=e()||[],u=d.length;return d[Pn],Y(()=>{if(u===0)return l!==0&&(Ut(a),a=[],s=[],r=[],l=0,o=[]),n.fallback&&(s=[rn],r[0]=ye(E=>(a[0]=E,n.fallback())),l=1),r;for(s[0]===rn&&(a[0](),a=[],s=[],r=[],l=0),c=0;c<u;c++)c<s.length&&s[c]!==d[c]?o[c](()=>d[c]):c>=s.length&&(r[c]=ye(f));for(;c<s.length;c++)a[c]();return l=o.length=a.length=u,s=d.slice(0),r=r.slice(0,l)});function f(E){a[c]=E;const[m,T]=H(d[c]);return o[c]=T,t(m,c)}}}function wn(e,t){return Y(()=>e(t||{}))}function vt(){return!0}var an={get(e,t,n){return t===kt?n:e.get(t)},has(e,t){return t===kt?!0:e.has(t)},set:vt,deleteProperty:vt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:vt,deleteProperty:vt}},ownKeys(e){return e.keys()}};function tn(e){return(e=typeof e=="function"?e():e)?e:{}}function wi(){for(let e=0,t=this.length;e<t;++e){const n=this[e]();if(n!==void 0)return n}}function vn(...e){let t=!1;for(let o=0;o<e.length;o++){const l=e[o];t=t||!!l&&kt in l,e[o]=typeof l=="function"?(t=!0,W(l)):l}if(gs&&t)return new Proxy({get(o){for(let l=e.length-1;l>=0;l--){const c=tn(e[l])[o];if(c!==void 0)return c}},has(o){for(let l=e.length-1;l>=0;l--)if(o in tn(e[l]))return!0;return!1},keys(){const o=[];for(let l=0;l<e.length;l++)o.push(...Object.keys(tn(e[l])));return[...new Set(o)]}},an);const n={},s=Object.create(null);for(let o=e.length-1;o>=0;o--){const l=e[o];if(!l)continue;const c=Object.getOwnPropertyNames(l);for(let d=c.length-1;d>=0;d--){const u=c[d];if(u==="__proto__"||u==="constructor")continue;const f=Object.getOwnPropertyDescriptor(l,u);if(!s[u])s[u]=f.get?{enumerable:!0,configurable:!0,get:wi.bind(n[u]=[f.get.bind(l)])}:f.value!==void 0?f:void 0;else{const E=n[u];E&&(f.get?E.push(f.get.bind(l)):f.value!==void 0&&E.push(()=>f.value))}}}const r={},a=Object.keys(s);for(let o=a.length-1;o>=0;o--){const l=a[o],c=s[l];c&&c.get?Object.defineProperty(r,l,c):r[l]=c?c.value:void 0}return r}function ws(e,...t){if(gs&&kt in e){const r=new Set(t.length>1?t.flat():t[0]),a=t.map(o=>new Proxy({get(l){return o.includes(l)?e[l]:void 0},has(l){return o.includes(l)&&l in e},keys(){return o.filter(l=>l in e)}},an));return a.push(new Proxy({get(o){return r.has(o)?void 0:e[o]},has(o){return r.has(o)?!1:o in e},keys(){return Object.keys(e).filter(o=>!r.has(o))}},an)),a}const n={},s=t.map(()=>({}));for(const r of Object.getOwnPropertyNames(e)){const a=Object.getOwnPropertyDescriptor(e,r),o=!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,o?s[c][r]=a.value:Object.defineProperty(s[c],r,a)),++c;l||(o?n[r]=a.value:Object.defineProperty(n,r,a))}return[...s,n]}function vs(e){let t,n;const s=r=>{const a=C.context;if(a){const[l,c]=H();C.count||(C.count=0),C.count++,(n||(n=e())).then(d=>{!C.done&&Xe(a),C.count--,c(()=>d.default),Xe()}),t=l}else if(!t){const[l]=ui(()=>(n||(n=e())).then(c=>c.default));t=l}let o;return W(()=>(o=t())?Y(()=>{if(!a||C.done)return o(r);const l=C.context;Xe(a);const c=o(r);return Xe(l),c}):"")};return s.preload=()=>n||((n=e()).then(r=>t=()=>r.default),n),s}var vi=0;function bi(){return C.context?C.getNextContextId():`cl-${vi++}`}var bs=e=>`Stale read from <${e}>.`;function Ci(e){const t="fallback"in e&&{fallback:()=>e.fallback};return W(xi(()=>e.each,e.children,t||void 0))}function Ii(e){const t="fallback"in e&&{fallback:()=>e.fallback};return W(_i(()=>e.each,e.children,t||void 0))}function Ni(e){const t=e.keyed,n=W(()=>e.when,void 0,void 0),s=t?n:W(n,void 0,{equals:(r,a)=>!r==!a});return W(()=>{const r=s();if(r){const a=e.children;return typeof a=="function"&&a.length>0?Y(()=>a(t?r:()=>{if(!Y(s))throw bs("Show");return n()})):a}return e.fallback},void 0,void 0)}function Li(e){const t=Ss(()=>e.children),n=W(()=>{const s=t(),r=Array.isArray(s)?s:[s];let a=()=>{};for(let o=0;o<r.length;o++){const l=o,c=r[o],d=a,u=W(()=>d()?void 0:c.when,void 0,void 0),f=c.keyed?u:W(u,void 0,{equals:(E,m)=>!E==!m});a=()=>d()||(f()?[l,u,c]:void 0)}return a});return W(()=>{const s=n()();if(!s)return e.fallback;const[r,a,o]=s,l=o.children;return typeof l=="function"&&l.length>0?Y(()=>l(o.keyed?a():()=>{var d;if(((d=Y(n)())==null?void 0:d[0])!==r)throw bs("Match");return a()})):l},void 0,void 0)}function ji(e){return e}var Gi=["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"],ki=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",...Gi]),Oi=new Set(["innerHTML","textContent","innerText","children"]),Ri=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),Di=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 Mi(e,t){const n=Di[e];return typeof n=="object"?n[t]?n.$:void 0:n}var Ui=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),Bi=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"]),Fi={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},qi=e=>W(()=>e());function Ki(e,t,n){let s=n.length,r=t.length,a=s,o=0,l=0,c=t[r-1].nextSibling,d=null;for(;o<r||l<a;){if(t[o]===n[l]){o++,l++;continue}for(;t[r-1]===n[a-1];)r--,a--;if(r===o){const u=a<s?l?n[l-1].nextSibling:n[a-l]:c;for(;l<a;)e.insertBefore(n[l++],u)}else if(a===l)for(;o<r;)(!d||!d.has(t[o]))&&t[o].remove(),o++;else if(t[o]===n[a-1]&&n[l]===t[r-1]){const u=t[--r].nextSibling;e.insertBefore(n[l++],t[o++].nextSibling),e.insertBefore(n[--a],u),t[r]=n[a]}else{if(!d){d=new Map;let f=l;for(;f<a;)d.set(n[f],f++)}const u=d.get(t[o]);if(u!=null)if(l<u&&u<a){let f=o,E=1,m;for(;++f<r&&f<a&&!((m=d.get(t[f]))==null||m!==u+E);)E++;if(E>u-l){const T=t[o];for(;l<u;)e.insertBefore(n[l++],T)}else e.replaceChild(n[l++],t[o++])}else o++;else t[o++].remove()}}}var nt="_$DX_DELEGATE";function Cs(e,t,n,s={}){let r;return ye(a=>{r=a,t===document?e():Ft(t,e(),t.firstChild?null:void 0,n)},s.owner),()=>{r(),t.textContent=""}}function Vi(e,t,n,s){let r;const a=()=>{const l=document.createElement("template");return l.innerHTML=e,l.content.firstChild},o=()=>(r||(r=a())).cloneNode(!0);return o.cloneNode=o,o}function Is(e,t=window.document){const n=t[nt]||(t[nt]=new Set);for(let s=0,r=e.length;s<r;s++){const a=e[s];n.has(a)||(n.add(a),t.addEventListener(a,ks))}}function Hi(e=window.document){if(e[nt]){for(let t of e[nt].keys())e.removeEventListener(t,ks);delete e[nt]}}function Bt(e,t,n){be(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function Qi(e,t,n,s){be(e)||(s==null?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,s))}function zi(e,t,n){be(e)||(n?e.setAttribute(t,""):e.removeAttribute(t))}function Ns(e,t){be(e)||(t==null?e.removeAttribute("class"):e.className=t)}function Ls(e,t,n,s){if(s)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){const r=n[0];e.addEventListener(t,n[0]=a=>r.call(e,n[1],a))}else e.addEventListener(t,n,typeof n!="function"&&n)}function $i(e,t,n={}){const s=Object.keys(t||{}),r=Object.keys(n);let a,o;for(a=0,o=r.length;a<o;a++){const l=r[a];!l||l==="undefined"||t[l]||(Dn(e,l,!1),delete n[l])}for(a=0,o=s.length;a<o;a++){const l=s[a],c=!!t[l];!l||l==="undefined"||n[l]===c||!c||(Dn(e,l,!0),n[l]=c)}return n}function Wi(e,t,n){if(!t)return n?Bt(e,"style"):t;const s=e.style;if(typeof t=="string")return s.cssText=t;typeof n=="string"&&(s.cssText=n=void 0),n||(n={}),t||(t={});let r,a;for(a in n)t[a]==null&&s.removeProperty(a),delete n[a];for(a in t)r=t[a],r!==n[a]&&(s.setProperty(a,r),n[a]=r);return n}function js(e,t={},n,s){const r={};return s||Ae(()=>r.children=it(e,t.children,r.children)),Ae(()=>typeof t.ref=="function"&&Gs(t.ref,e)),Ae(()=>Yi(e,t,n,!0,r,!0)),r}function Gs(e,t,n){return Y(()=>e(t,n))}function Ft(e,t,n,s){if(n!==void 0&&!s&&(s=[]),typeof t!="function")return it(e,t,s,n);Ae(r=>it(e,t(),r,n),s)}function Yi(e,t,n,s,r={},a=!1){t||(t={});for(const o in r)if(!(o in t)){if(o==="children")continue;r[o]=Mn(e,o,null,r[o],n,a,t)}for(const o in t){if(o==="children")continue;const l=t[o];r[o]=Mn(e,o,l,r[o],n,a,t)}}function Ji(e){let t,n;return!be()||!(t=C.registry.get(n=Xi()))?e():(C.completed&&C.completed.add(t),C.registry.delete(n),t)}function be(e){return!!C.context&&!C.done&&(!e||e.isConnected)}function Zi(e){return e.toLowerCase().replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function Dn(e,t,n){const s=t.trim().split(/\s+/);for(let r=0,a=s.length;r<a;r++)e.classList.toggle(s[r],n)}function Mn(e,t,n,s,r,a,o){let l,c,d,u,f;if(t==="style")return Wi(e,n,s);if(t==="classList")return $i(e,n,s);if(n===s)return s;if(t==="ref")a||n(e);else if(t.slice(0,3)==="on:"){const E=t.slice(3);s&&e.removeEventListener(E,s,typeof s!="function"&&s),n&&e.addEventListener(E,n,typeof n!="function"&&n)}else if(t.slice(0,10)==="oncapture:"){const E=t.slice(10);s&&e.removeEventListener(E,s,!0),n&&e.addEventListener(E,n,!0)}else if(t.slice(0,2)==="on"){const E=t.slice(2).toLowerCase(),m=Ui.has(E);if(!m&&s){const T=Array.isArray(s)?s[0]:s;e.removeEventListener(E,T)}(m||n)&&(Ls(e,E,n,m),m&&Is([E]))}else if(t.slice(0,5)==="attr:")Bt(e,t.slice(5),n);else if(t.slice(0,5)==="bool:")zi(e,t.slice(5),n);else if((f=t.slice(0,5)==="prop:")||(d=Oi.has(t))||!r&&((u=Mi(t,e.tagName))||(c=ki.has(t)))||(l=e.nodeName.includes("-")||"is"in o)){if(f)t=t.slice(5),c=!0;else if(be(e))return n;t==="class"||t==="className"?Ns(e,n):l&&!c&&!d?e[Zi(t)]=n:e[u||t]=n}else{const E=r&&t.indexOf(":")>-1&&Fi[t.split(":")[0]];E?Qi(e,E,t,n):Bt(e,Ri[t]||t,n)}return n}function ks(e){if(C.registry&&C.events&&C.events.find(([c,d])=>d===e))return;let t=e.target;const n=`$$${e.type}`,s=e.target,r=e.currentTarget,a=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),o=()=>{const c=t[n];if(c&&!t.disabled){const d=t[`${n}Data`];if(d!==void 0?c.call(t,d,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&a(t.host),!0},l=()=>{for(;o()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),C.registry&&!C.done&&(C.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();a(c[0]);for(let d=0;d<c.length-2&&(t=c[d],!!o());d++){if(t._$host){t=t._$host,l();break}if(t.parentNode===r)break}}else l();a(s)}function it(e,t,n,s,r){const a=be(e);if(a){!n&&(n=[...e.childNodes]);let c=[];for(let d=0;d<n.length;d++){const u=n[d];u.nodeType===8&&u.data.slice(0,2)==="!$"?u.remove():c.push(u)}n=c}for(;typeof n=="function";)n=n();if(t===n)return n;const o=typeof t,l=s!==void 0;if(e=l&&n[0]&&n[0].parentNode||e,o==="string"||o==="number"){if(a||o==="number"&&(t=t.toString(),t===n))return n;if(l){let c=n[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),n=Ie(e,n,s,c)}else n!==""&&typeof n=="string"?n=e.firstChild.data=t:n=e.textContent=t}else if(t==null||o==="boolean"){if(a)return n;n=Ie(e,n,s)}else{if(o==="function")return Ae(()=>{let c=t();for(;typeof c=="function";)c=c();n=it(e,c,n,s)}),()=>n;if(Array.isArray(t)){const c=[],d=n&&Array.isArray(n);if(on(c,t,n,r))return Ae(()=>n=it(e,c,n,s,!0)),()=>n;if(a){if(!c.length)return n;if(s===void 0)return n=[...e.childNodes];let u=c[0];if(u.parentNode!==e)return n;const f=[u];for(;(u=u.nextSibling)!==s;)f.push(u);return n=f}if(c.length===0){if(n=Ie(e,n,s),l)return n}else d?n.length===0?Un(e,c,s):Ki(e,n,c):(n&&Ie(e),Un(e,c));n=c}else if(t.nodeType){if(a&&t.parentNode)return n=l?[t]:t;if(Array.isArray(n)){if(l)return n=Ie(e,n,s,t);Ie(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function on(e,t,n,s){let r=!1;for(let a=0,o=t.length;a<o;a++){let l=t[a],c=n&&n[e.length],d;if(!(l==null||l===!0||l===!1))if((d=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))r=on(e,l,c)||r;else if(d==="function")if(s){for(;typeof l=="function";)l=l();r=on(e,Array.isArray(l)?l:[l],Array.isArray(c)?c:[c])||r}else e.push(l),r=!0;else{const u=String(l);c&&c.nodeType===3&&c.data===u?e.push(c):e.push(document.createTextNode(u))}}return r}function Un(e,t,n=null){for(let s=0,r=t.length;s<r;s++)e.insertBefore(t[s],n)}function Ie(e,t,n,s){if(n===void 0)return e.textContent="";const r=s||document.createTextNode("");if(t.length){let a=!1;for(let o=t.length-1;o>=0;o--){const l=t[o];if(r!==l){const c=l.parentNode===e;!a&&!o?c?e.replaceChild(r,l):e.insertBefore(r,n):c&&l.remove()}else a=!0}}else e.insertBefore(r,n);return[r]}function Xi(){return C.getNextContextId()}var eo="http://www.w3.org/2000/svg";function Os(e,t=!1){return t?document.createElementNS(eo,e):document.createElement(e)}function to(e){const{useShadow:t}=e,n=document.createTextNode(""),s=()=>e.mount||document.body,r=Rn();let a,o=!!C.context;return xn(()=>{o&&(Rn().user=o=!1),a||(a=As(r,()=>W(()=>e.children)));const l=s();if(l instanceof HTMLHeadElement){const[c,d]=H(!1),u=()=>d(!0);ye(f=>Ft(l,()=>c()?f():a(),null)),$e(u)}else{const c=Os(e.isSVG?"g":"div",e.isSVG),d=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return n.parentNode},configurable:!0}),Ft(d,a),l.appendChild(c),e.ref&&e.ref(c),$e(()=>l.removeChild(c))}},void 0,{render:!o}),n}function no(e,t){const n=W(e);return W(()=>{const s=n();switch(typeof s){case"function":return Y(()=>s(t));case"string":const r=Bi.has(s),a=C.context?Ji():Os(s,r);return js(a,t,r),a}})}function so(e){const[,t]=ws(e,["component"]);return no(()=>e.component,t)}var ro=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()}},Rs=class{constructor(e){this.generateIdentifier=e,this.kv=new ro}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)}},ao=class extends Rs{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 io(e){if("values"in Object)return Object.values(e);const t=[];for(const n in e)e.hasOwnProperty(n)&&t.push(e[n]);return t}function oo(e,t){const n=io(e);if("find"in n)return n.find(t);const s=n;for(let r=0;r<s.length;r++){const a=s[r];if(t(a))return a}}function We(e,t){Object.entries(e).forEach(([n,s])=>t(s,n))}function jt(e,t){return e.indexOf(t)!==-1}function Bn(e,t){for(let n=0;n<e.length;n++){const s=e[n];if(t(s))return s}}var lo=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return oo(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},co=e=>Object.prototype.toString.call(e).slice(8,-1),Ds=e=>typeof e>"u",uo=e=>e===null,ot=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,ln=e=>ot(e)&&Object.keys(e).length===0,Se=e=>Array.isArray(e),fo=e=>typeof e=="string",ho=e=>typeof e=="number"&&!isNaN(e),go=e=>typeof e=="boolean",mo=e=>e instanceof RegExp,lt=e=>e instanceof Map,ct=e=>e instanceof Set,Ms=e=>co(e)==="Symbol",Eo=e=>e instanceof Date&&!isNaN(e.valueOf()),po=e=>e instanceof Error,Fn=e=>typeof e=="number"&&isNaN(e),yo=e=>go(e)||uo(e)||Ds(e)||ho(e)||fo(e)||Ms(e),Ao=e=>typeof e=="bigint",So=e=>e===1/0||e===-1/0,To=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),Po=e=>e instanceof URL,Us=e=>e.replace(/\./g,"\\."),nn=e=>e.map(String).map(Us).join("."),st=e=>{const t=[];let n="";for(let r=0;r<e.length;r++){let a=e.charAt(r);if(a==="\\"&&e.charAt(r+1)==="."){n+=".",r++;continue}if(a==="."){t.push(n),n="";continue}n+=a}const s=n;return t.push(s),t};function le(e,t,n,s){return{isApplicable:e,annotation:t,transform:n,untransform:s}}var Bs=[le(Ds,"undefined",()=>null,()=>{}),le(Ao,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),le(Eo,"Date",e=>e.toISOString(),e=>new Date(e)),le(po,"Error",(e,t)=>{const n={name:e.name,message:e.message};return t.allowedErrorProps.forEach(s=>{n[s]=e[s]}),n},(e,t)=>{const n=new Error(e.message);return n.name=e.name,n.stack=e.stack,t.allowedErrorProps.forEach(s=>{n[s]=e[s]}),n}),le(mo,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),n=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,n)}),le(ct,"set",e=>[...e.values()],e=>new Set(e)),le(lt,"map",e=>[...e.entries()],e=>new Map(e)),le(e=>Fn(e)||So(e),"number",e=>Fn(e)?"NaN":e>0?"Infinity":"-Infinity",Number),le(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),le(Po,"URL",e=>e.toString(),e=>new URL(e))];function Wt(e,t,n,s){return{isApplicable:e,annotation:t,transform:n,untransform:s}}var Fs=Wt((e,t)=>Ms(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,n)=>{const s=n.symbolRegistry.getValue(t[1]);if(!s)throw new Error("Trying to deserialize unknown symbol");return s}),xo=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),qs=Wt(To,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const n=xo[t[1]];if(!n)throw new Error("Trying to deserialize unknown typed array");return new n(e)});function Ks(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var Vs=Wt(Ks,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const n=t.classRegistry.getAllowedProps(e.constructor);if(!n)return{...e};const s={};return n.forEach(r=>{s[r]=e[r]}),s},(e,t,n)=>{const s=n.classRegistry.getValue(t[1]);if(!s)throw new Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(s.prototype),e)}),Hs=Wt((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,n)=>{const s=n.customTransformerRegistry.findByName(t[1]);if(!s)throw new Error("Trying to deserialize unknown custom value");return s.deserialize(e)}),_o=[Vs,Fs,Hs,qs],qn=(e,t)=>{const n=Bn(_o,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation(e,t)};const s=Bn(Bs,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation}},Qs={};Bs.forEach(e=>{Qs[e.annotation]=e});var wo=(e,t,n)=>{if(Se(t))switch(t[0]){case"symbol":return Fs.untransform(e,t,n);case"class":return Vs.untransform(e,t,n);case"custom":return Hs.untransform(e,t,n);case"typed-array":return qs.untransform(e,t,n);default:throw new Error("Unknown transformation: "+t)}else{const s=Qs[t];if(!s)throw new Error("Unknown transformation: "+t);return s.untransform(e,n)}},Ne=(e,t)=>{if(t>e.size)throw new Error("index out of bounds");const n=e.keys();for(;t>0;)n.next(),t--;return n.next().value};function zs(e){if(jt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(jt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(jt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var vo=(e,t)=>{zs(t);for(let n=0;n<t.length;n++){const s=t[n];if(ct(e))e=Ne(e,+s);else if(lt(e)){const r=+s,a=+t[++n]==0?"key":"value",o=Ne(e,r);switch(a){case"key":e=o;break;case"value":e=e.get(o);break}}else e=e[s]}return e},cn=(e,t,n)=>{if(zs(t),t.length===0)return n(e);let s=e;for(let a=0;a<t.length-1;a++){const o=t[a];if(Se(s)){const l=+o;s=s[l]}else if(ot(s))s=s[o];else if(ct(s)){const l=+o;s=Ne(s,l)}else if(lt(s)){if(a===t.length-2)break;const c=+o,d=+t[++a]==0?"key":"value",u=Ne(s,c);switch(d){case"key":s=u;break;case"value":s=s.get(u);break}}}const r=t[t.length-1];if(Se(s)?s[+r]=n(s[+r]):ot(s)&&(s[r]=n(s[r])),ct(s)){const a=Ne(s,+r),o=n(a);a!==o&&(s.delete(a),s.add(o))}if(lt(s)){const a=+t[t.length-2],o=Ne(s,a);switch(+r==0?"key":"value"){case"key":{const c=n(o);s.set(c,s.get(o)),c!==o&&s.delete(o);break}case"value":{s.set(o,n(s.get(o)));break}}}return e};function un(e,t,n=[]){if(!e)return;if(!Se(e)){We(e,(a,o)=>un(a,t,[...n,...st(o)]));return}const[s,r]=e;r&&We(r,(a,o)=>{un(a,t,[...n,...st(o)])}),t(s,n)}function bo(e,t,n){return un(t,(s,r)=>{e=cn(e,r,a=>wo(a,s,n))}),e}function Co(e,t){function n(s,r){const a=vo(e,st(r));s.map(st).forEach(o=>{e=cn(e,o,()=>a)})}if(Se(t)){const[s,r]=t;s.forEach(a=>{e=cn(e,st(a),()=>e)}),r&&We(r,n)}else We(t,n);return e}var Io=(e,t)=>ot(e)||Se(e)||lt(e)||ct(e)||Ks(e,t);function No(e,t,n){const s=n.get(e);s?s.push(t):n.set(e,[t])}function Lo(e,t){const n={};let s;return e.forEach(r=>{if(r.length<=1)return;t||(r=r.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[a,...o]=r;a.length===0?s=o.map(nn):n[nn(a)]=o.map(nn)}),s?ln(n)?[s]:[s,n]:ln(n)?void 0:n}var $s=(e,t,n,s,r=[],a=[],o=new Map)=>{const l=yo(e);if(!l){No(e,r,t);const m=o.get(e);if(m)return s?{transformedValue:null}:m}if(!Io(e,n)){const m=qn(e,n),T=m?{transformedValue:m.value,annotations:[m.type]}:{transformedValue:e};return l||o.set(e,T),T}if(jt(a,e))return{transformedValue:null};const c=qn(e,n),d=(c==null?void 0:c.value)??e,u=Se(d)?[]:{},f={};We(d,(m,T)=>{if(T==="__proto__"||T==="constructor"||T==="prototype")throw new Error(`Detected property ${T}. This is a prototype pollution risk, please remove it from your object.`);const S=$s(m,t,n,s,[...r,T],[...a,e],o);u[T]=S.transformedValue,Se(S.annotations)?f[T]=S.annotations:ot(S.annotations)&&We(S.annotations,(x,w)=>{f[Us(T)+"."+w]=x})});const E=ln(f)?{transformedValue:u,annotations:c?[c.type]:void 0}:{transformedValue:u,annotations:c?[c.type,f]:f};return l||o.set(e,E),E};function Ws(e){return Object.prototype.toString.call(e).slice(8,-1)}function Kn(e){return Ws(e)==="Array"}function jo(e){if(Ws(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function Go(e,t,n,s,r){const a={}.propertyIsEnumerable.call(s,t)?"enumerable":"nonenumerable";a==="enumerable"&&(e[t]=n),r&&a==="nonenumerable"&&Object.defineProperty(e,t,{value:n,enumerable:!1,writable:!0,configurable:!0})}function dn(e,t={}){if(Kn(e))return e.map(r=>dn(r,t));if(!jo(e))return e;const n=Object.getOwnPropertyNames(e),s=Object.getOwnPropertySymbols(e);return[...n,...s].reduce((r,a)=>{if(Kn(t.props)&&!t.props.includes(a))return r;const o=e[a],l=dn(o,t);return Go(r,a,l,e,t.nonenumerable),r},{})}var B=class{constructor({dedupe:e=!1}={}){this.classRegistry=new ao,this.symbolRegistry=new Rs(t=>t.description??""),this.customTransformerRegistry=new lo,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,n=$s(e,t,this,this.dedupe),s={json:n.transformedValue};n.annotations&&(s.meta={...s.meta,values:n.annotations});const r=Lo(t,this.dedupe);return r&&(s.meta={...s.meta,referentialEqualities:r}),s}deserialize(e){const{json:t,meta:n}=e;let s=dn(t);return n!=null&&n.values&&(s=bo(s,n.values,this)),n!=null&&n.referentialEqualities&&(s=Co(s,n.referentialEqualities)),s}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};B.defaultInstance=new B;B.serialize=B.defaultInstance.serialize.bind(B.defaultInstance);B.deserialize=B.defaultInstance.deserialize.bind(B.defaultInstance);B.stringify=B.defaultInstance.stringify.bind(B.defaultInstance);B.parse=B.defaultInstance.parse.bind(B.defaultInstance);B.registerClass=B.defaultInstance.registerClass.bind(B.defaultInstance);B.registerSymbol=B.defaultInstance.registerSymbol.bind(B.defaultInstance);B.registerCustom=B.defaultInstance.registerCustom.bind(B.defaultInstance);B.allowErrorProps=B.defaultInstance.allowErrorProps.bind(B.defaultInstance);var Ys=B.serialize,ko=B.stringify;function Oo(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function Ro(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function Do({queryState:e,observerCount:t,isStale:n}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":n?"yellow":"green":"gray"}function Mo({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function Uo(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var Bo=(e,t=!1)=>{const{json:n}=Ys(e);return JSON.stringify(n,null,t?2:void 0)},bt=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,Fo=(e,t)=>e.queryHash.localeCompare(t.queryHash),Js=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,qo=(e,t)=>bt(e)===bt(t)?Js(e,t):bt(e)>bt(t)?1:-1,Ko={status:qo,"query hash":Fo,"last updated":Js},Ct=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,Zs=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,Vo=(e,t)=>Ct(e)===Ct(t)?Zs(e,t):Ct(e)>Ct(t)?1:-1,Ho={status:Vo,"last updated":Zs},Qo=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),zo=()=>{const[e,t]=H("dark");return ys(()=>{const n=window.matchMedia("(prefers-color-scheme: dark)");t(n.matches?"dark":"light");const s=r=>{t(r.matches?"dark":"light")};n.addEventListener("change",s),$e(()=>n.removeEventListener("change",s))}),e},et=(e,t,n)=>{if(t.length===0)return n;if(e instanceof Map){const s=new Map(e);if(t.length===1)return s.set(t[0],n),s;const[r,...a]=t;return s.set(r,et(s.get(r),a,n)),s}if(e instanceof Set){const s=et(Array.from(e),t,n);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s[t[0]]=n,s;const[r,...a]=t;return s[r]=et(s[r],a,n),s}if(e instanceof Object){const s={...e};if(t.length===1)return s[t[0]]=n,s;const[r,...a]=t;return s[r]=et(s[r],a,n),s}return e},tt=(e,t)=>{if(e instanceof Map){const n=new Map(e);if(t.length===1)return n.delete(t[0]),n;const[s,...r]=t;return n.set(s,tt(n.get(s),r)),n}if(e instanceof Set){const n=tt(Array.from(e),t);return new Set(n)}if(Array.isArray(e)){const n=[...e];if(t.length===1)return n.filter((a,o)=>o.toString()!==t[0]);const[s,...r]=t;return n[s]=tt(n[s],r),n}if(e instanceof Object){const n={...e};if(t.length===1)return delete n[t[0]],n;const[s,...r]=t;return n[s]=tt(n[s],r),n}return e},Xs=(e,t)=>{if(!e||document.querySelector("#_goober")||(t==null?void 0:t.querySelector("#_goober")))return;const s=document.createElement("style"),r=document.createTextNode("");s.appendChild(r),s.id="_goober",s.setAttribute("nonce",e),t?t.appendChild(s):document.head.appendChild(s)},Le,ut,dt,ft,we,ht,je,Ge,ke,Oe,Re,gt,De,Me,mt,Qn,$o=(Qn=class{constructor(e){M(this,Le);M(this,ut);M(this,dt);M(this,ft);M(this,we,!1);M(this,ht);M(this,je);M(this,Ge);M(this,ke);M(this,Oe);M(this,Re);M(this,gt);M(this,De);M(this,Me);M(this,mt);const{client:t,queryFlavor:n,version:s,onlineManager:r,buttonPosition:a,position:o,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:u,hideDisabledQueries:f,theme:E}=e;R(this,Le,H(t)),R(this,dt,n),R(this,ft,s),R(this,ut,r),R(this,ht,d),R(this,je,u),R(this,Ge,H(a)),R(this,ke,H(o)),R(this,Oe,H(l)),R(this,Re,H(c)),R(this,gt,H(f)),R(this,Me,H(E))}setButtonPosition(e){_(this,Ge)[1](e)}setPosition(e){_(this,ke)[1](e)}setInitialIsOpen(e){_(this,Oe)[1](e)}setErrorTypes(e){_(this,Re)[1](e)}setClient(e){_(this,Le)[1](e)}setTheme(e){_(this,Me)[1](e)}mount(e){if(_(this,we))throw new Error("Devtools is already mounted");const t=Cs(()=>{const n=this,[s]=_(this,Ge),[r]=_(this,ke),[a]=_(this,Oe),[o]=_(this,Re),[l]=_(this,gt),[c]=_(this,Le),[d]=_(this,Me);let u;return _(this,De)?u=_(this,De):(u=vs(()=>Promise.resolve().then(()=>require("./WDYDFRGG-BtzyRDmj.cjs"))),R(this,De,u)),Xs(_(this,ht),_(this,je)),wn(u,vn({get queryFlavor(){return _(n,dt)},get version(){return _(n,ft)},get onlineManager(){return _(n,ut)},get shadowDOMTarget(){return _(n,je)}},{get client(){return c()},get buttonPosition(){return s()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return o()},get hideDisabledQueries(){return l()},get theme(){return d()}}))},e);R(this,we,!0),R(this,mt,t)}unmount(){var e;if(!_(this,we))throw new Error("Devtools is not mounted");(e=_(this,mt))==null||e.call(this),R(this,we,!1)}},Le=new WeakMap,ut=new WeakMap,dt=new WeakMap,ft=new WeakMap,we=new WeakMap,ht=new WeakMap,je=new WeakMap,Ge=new WeakMap,ke=new WeakMap,Oe=new WeakMap,Re=new WeakMap,gt=new WeakMap,De=new WeakMap,Me=new WeakMap,mt=new WeakMap,Qn),Ue,Et,pt,yt,ve,At,Be,Fe,qe,Ke,Ve,St,He,Qe,ze,Tt,zn,Wo=(zn=class{constructor(e){M(this,Ue);M(this,Et);M(this,pt);M(this,yt);M(this,ve,!1);M(this,At);M(this,Be);M(this,Fe);M(this,qe);M(this,Ke);M(this,Ve);M(this,St);M(this,He);M(this,Qe);M(this,ze);M(this,Tt);const{client:t,queryFlavor:n,version:s,onlineManager:r,buttonPosition:a,position:o,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:u,onClose:f,hideDisabledQueries:E,theme:m}=e;R(this,Ue,H(t)),R(this,pt,n),R(this,yt,s),R(this,Et,r),R(this,At,d),R(this,Be,u),R(this,Fe,H(a)),R(this,qe,H(o)),R(this,Ke,H(l)),R(this,Ve,H(c)),R(this,St,H(E)),R(this,He,H(f)),R(this,ze,H(m))}setButtonPosition(e){_(this,Fe)[1](e)}setPosition(e){_(this,qe)[1](e)}setInitialIsOpen(e){_(this,Ke)[1](e)}setErrorTypes(e){_(this,Ve)[1](e)}setClient(e){_(this,Ue)[1](e)}setOnClose(e){_(this,He)[1](()=>e)}setTheme(e){_(this,ze)[1](e)}mount(e){if(_(this,ve))throw new Error("Devtools is already mounted");const t=Cs(()=>{const n=this,[s]=_(this,Fe),[r]=_(this,qe),[a]=_(this,Ke),[o]=_(this,Ve),[l]=_(this,St),[c]=_(this,Ue),[d]=_(this,He),[u]=_(this,ze);let f;return _(this,Qe)?f=_(this,Qe):(f=vs(()=>Promise.resolve().then(()=>require("./2SSKDMRQ-C6XmPkPR.cjs"))),R(this,Qe,f)),Xs(_(this,At),_(this,Be)),wn(f,vn({get queryFlavor(){return _(n,pt)},get version(){return _(n,yt)},get onlineManager(){return _(n,Et)},get shadowDOMTarget(){return _(n,Be)}},{get client(){return c()},get buttonPosition(){return s()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return o()},get hideDisabledQueries(){return l()},get onClose(){return d()},get theme(){return u()}}))},e);R(this,ve,!0),R(this,Tt,t)}unmount(){var e;if(!_(this,ve))throw new Error("Devtools is not mounted");(e=_(this,Tt))==null||e.call(this),R(this,ve,!1)}},Ue=new WeakMap,Et=new WeakMap,pt=new WeakMap,yt=new WeakMap,ve=new WeakMap,At=new WeakMap,Be=new WeakMap,Fe=new WeakMap,qe=new WeakMap,Ke=new WeakMap,Ve=new WeakMap,St=new WeakMap,He=new WeakMap,Qe=new WeakMap,ze=new WeakMap,Tt=new WeakMap,zn);function Yo(e){const t=P.useQueryClient(e.client),n=z.useRef(null),{buttonPosition:s,position:r,initialIsOpen:a,errorTypes:o,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d,theme:u}=e,[f]=z.useState(new $o({client:t,queryFlavor:"React Query",version:"5",onlineManager:P.onlineManager,buttonPosition:s,position:r,initialIsOpen:a,errorTypes:o,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d,theme:u}));return z.useEffect(()=>{f.setClient(t)},[t,f]),z.useEffect(()=>{s&&f.setButtonPosition(s)},[s,f]),z.useEffect(()=>{r&&f.setPosition(r)},[r,f]),z.useEffect(()=>{f.setInitialIsOpen(a||!1)},[a,f]),z.useEffect(()=>{f.setErrorTypes(o||[])},[o,f]),z.useEffect(()=>{f.setTheme(u)},[u,f]),z.useEffect(()=>(n.current&&f.mount(n.current),()=>{f.unmount()}),[f]),i.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:n})}function Jo(e){const t=P.useQueryClient(e.client),n=z.useRef(null),{errorTypes:s,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:o,theme:l}=e,[c]=z.useState(new Wo({client:t,queryFlavor:"React Query",version:"5",onlineManager:P.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:s,styleNonce:r,shadowDOMTarget:a,onClose:e.onClose,hideDisabledQueries:o,theme:l}));return z.useEffect(()=>{c.setClient(t)},[t,c]),z.useEffect(()=>{c.setOnClose(e.onClose??(()=>{}))},[e.onClose,c]),z.useEffect(()=>{c.setErrorTypes(s||[])},[s,c]),z.useEffect(()=>{c.setTheme(l)},[l,c]),z.useEffect(()=>(n.current&&c.mount(n.current),()=>{c.unmount()}),[c]),i.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:n})}var Vn=process.env.NODE_ENV!=="development"?function(){return null}:Yo;process.env.NODE_ENV;const er=Q.atom(""),Zo=()=>{I.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),I.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"})},Xo=()=>{const e=N(),t=k();return P.useQuery({queryKey:[y.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:y.GET_COLLECTIONS})})},el=()=>{const{data:e}=ne(),{data:t}=ge(),{data:n}=Pe(),s=N(),r=k(),a=h.useMemo(()=>(n==null?void 0:n.fallbackLang)||"en",[n==null?void 0:n.fallbackLang]),o=h.useRef(new Map);return P.useMutation({mutationFn:async({block:l})=>{const c=l._id,d=(t==null?void 0:t.lang)||a,u=`${c}:${d}`;if(o.current.has(u))return o.current.get(u);const f=r(s,{action:y.GET_BLOCK_ASYNC_PROPS,data:{block:l,lang:d,pageProps:{slug:t==null?void 0:t.slug,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:a,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id}}});return o.current.set(u,f),f.finally(()=>{o.current.delete(u)}),f}})},tr=()=>{const[,e]=ue();return h.useCallback((t,n)=>{const r=new URLSearchParams(window.location.search).get("lang"),a=new URLSearchParams({page:t});r&&a.set("lang",r),window.history.pushState({},"",`?${a.toString()}`),e(a),window.dispatchEvent(new PopStateEvent("popstate")),n==null||n()},[e])},nr=()=>{const e=tr();return h.useCallback(({pageId:t})=>{e(t)},[e])},tl={SITE_WIDE_USAGE:"SITE_WIDE_USAGE"},nl=e=>{const t=k(),n=N();return P.useQuery({queryKey:[tl.SITE_WIDE_USAGE],queryFn:async()=>e?t(n,{action:"GET_SITE_WIDE_USAGE"}):{},retry:!1})},sl=h.lazy(()=>Promise.resolve().then(()=>require("./page-lock-DG5IvZaG.cjs"))),rl=h.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-dialog-C21Fq-UD.cjs"))),al=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-cGUpTcu3.cjs"))),il=h.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-ClCCNy6W.cjs"))),ol=h.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-XYoM6sn5.cjs"))),ll=h.lazy(()=>Promise.resolve().then(()=>require("./web-preview-CvpevNzM.cjs")));Zo();Tr.loadWebBlocks();I.registerChaiTopBar(ka);ii();I.registerChaiMediaManager(al);I.registerChaiSaveToLibrary(il);const cl={role:"",permissions:null},Hn=e=>{const{isLoading:t}=Ha();return t?i.jsx(Ht,{className:"fixed inset-0 bg-white",children:i.jsx(b.Loader,{className:"h-6 w-6 animate-spin text-primary"})}):i.jsx(ul,{...e})},ul=e=>{var In;const{data:t}=Va(),n=Vt(),{data:s=cl,isFetching:r}=ls(),{data:a,isFetching:o}=me(),{data:l,isFetching:c}=Xo(),{data:d,isFetching:u}=Pe(),f=r||o||c||u,[E]=ue(),m=E.get("page"),{data:T}=ne(),{data:S,isFetching:x}=Da(),{blocks:w}=Ra(S),{data:A,isFetching:v}=is(),{pageStatus:G}=ie(),q=Oa(),{onSave:L}=Qa(),{mutateAsync:oe}=el(),{getPartialBlocks:de,getPartialBlockBlocks:V}=za(),{mutateAsync:j}=Gr(),{mutateAsync:O}=os(),{data:$}=nl(((In=e.flags)==null?void 0:In.designTokens)??!0),K=nr(),[ee,xe]=h.useState(!1),se=h.useRef([]),Ce=h.useMemo(()=>p.get(d,"theme",{})||{},[d]),_e=G===J.EDITING,ar=G===J.CHECKING,bn=x||ar||v;h.useEffect(()=>{se.current=w},[w]);const[ir]=Q.useAtom(er);h.useEffect(()=>{const te=()=>{document.hidden?xe(!0):xe(!1)};return window.addEventListener("visibilitychange",te),()=>window.removeEventListener("visibilitychange",te)},[]);const or=h.useMemo(()=>{const te={};return s&&(te.permissions=p.get(s,"permissions",null),te.role=p.get(s,"role","user")),te},[s]),Cn=h.useMemo(()=>t==null?void 0:t.some(te=>te.isSiteLibrary),[t]),lr=h.useCallback(async(te,_t)=>await j({pageType:te,query:_t}),[j]);return i.jsxs(i.Fragment,{children:[bn&&i.jsx(Ht,{className:f?"fixed inset-0 bg-white":"bg-white/75",children:i.jsx(b.Loader,{className:`animate-spin text-primary ${f?"h-6 w-6":"h-5 w-5"}`})}),ir&&i.jsx(h.Suspense,{fallback:i.jsx("div",{className:"absolute inset-0 z-[999999] flex min-h-screen w-screen items-center justify-center bg-gray-100",children:i.jsx(b.Loader,{className:"h-6 w-6 animate-spin text-primary"})}),children:i.jsx(ll,{})}),i.jsx(g.ChaiBuilderEditor,{siteWideUsage:$??{},flags:e.flags?{...e.flags,librarySite:Cn}:{librarySite:Cn},gotoPage:K,collections:l??[],getBlockAsyncProps:oe,pageExternalData:A,themePresets:e.themePresets??[],pageId:T==null?void 0:T.id,loading:x,fallbackLang:n,languages:(d==null?void 0:d.languages)||[],brandingOptions:(d==null?void 0:d.theme)||{},designTokens:(d==null?void 0:d.designTokens)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!ee&&_e&&(e.autoSave??!0),autoSaveActionsCount:e.autoSaveActionsCount??10,onError:e.onError||console.error,getPartialBlockBlocks:V,getPartialBlocks:de,blocks:x?[]:w,theme:p.cloneDeep(Ce),pageTypes:a,searchPageTypeItems:lr,askAiCallBack:q,onSave:async({blocks:te,theme:_t,needTranslations:cr,designTokens:Nn})=>{if(!m)return!0;se.current=te;const Ln=[...te];await L({page:m,blocks:Ln,needTranslations:cr}),se.current=Ln;const wt={};return p.isEqual(_t,Ce)||(wt.theme=_t),p.isEqual(Nn,d==null?void 0:d.designTokens)||(wt.designTokens=Nn),p.isEmpty(wt)||await O({settings:wt}),!0},themePanelComponent:ol,...or,children:i.jsx(sl,{isFetchingPageData:bn})}),i.jsx("div",{children:i.jsx(rl,{})})]})},dl=new P.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),fl=e=>{const[,t]=qt(),[n,s]=h.useState(!1);return h.useEffect(()=>(t(p.pick(e,["apiUrl","usersApiUrl","assetsApiUrl","getPreviewUrl","getLiveUrl","topLeftCorner","onLogout","getAccessToken","websocket","realtimeAdapter","getLoggedInUser","features","currentUser"])),setTimeout(()=>{s(!0)},200),()=>{s(!1),t({})}),[e,t]),n?p.get(e,"hasReactQueryProvider",!1)===!0?i.jsxs(i.Fragment,{children:[i.jsx(Hn,{...e}),i.jsx(Vn,{})]}):i.jsxs(P.QueryClientProvider,{client:dl,children:[i.jsx(Hn,{...e}),i.jsx(Vn,{})]}):i.jsx("div",{})},hl=z.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-hBvmT_2A.cjs")));function sr({data:e,onSelect:t,dataType:n="value",disabled:s=!1}){const[r,a]=z.useState(!1);return i.jsxs(g.Popover,{open:r,onOpenChange:a,children:[i.jsxs(g.Tooltip,{children:[i.jsx(g.TooltipTrigger,{asChild:!0,children:i.jsx(g.PopoverTrigger,{asChild:!0,children:i.jsx(I.Button,{size:"sm",variant:"outline",className:"h-6 w-6 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,disabled:s,children:i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:i.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"})})})})}),i.jsx(g.TooltipContent,{children:"Add field"})]}),r&&i.jsx(z.Suspense,{children:i.jsx(hl,{data:e,onSelect:t,dataType:n,open:r,setOpen:a})})]})}const gl=()=>{const{savePageAsync:e}=g.useSavePage(),t=P.useQueryClient(),{isLocked:n}=ie();return h.useCallback(async()=>{n||await e(),t.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]})},[e,t,n])},ml=()=>{const e=P.useQueryClient();return h.useCallback(()=>{e.clear()},[e])},El=()=>{const e=N(),t=k(),{data:n}=ge(),s=P.useQueryClient();return P.useMutation({mutationFn:async r=>{if(!(n!=null&&n.id))throw new Error("No active page found");return await t(`${e}`,{action:y.UPDATE_PAGE_METADATA,data:{id:n.id,metadata:r}})},onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]}),s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]})},onError:()=>{console.error("Failed to update metadata")}})},pl=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-cGUpTcu3.cjs"))),yl=({assetId:e,assetUrl:t,onChange:n,className:s="",placeholder:r="Select an image",disabled:a=!1})=>{const{t:o}=he.useTranslation(),[l,c]=h.useState(!1),d=()=>{a||c(!0)},u=()=>{c(!1)},f=T=>{const S=Array.isArray(T)?T[0]:T;S!=null&&S.url&&n(p.pick(S,["url","id"])),c(!1)},E=()=>{n({url:"",id:""})},m=(t==null?void 0:t.startsWith("{{"))&&(t==null?void 0:t.endsWith("}}"));return i.jsxs("div",{className:`w-full ${s}`,children:[t?i.jsxs("div",{className:"relative overflow-hidden rounded-md border",children:[m?i.jsx("div",{className:"flex h-12 items-center bg-gray-100 px-4",children:i.jsx("p",{className:"text-xs text-gray-500",children:t})}):i.jsx("img",{onClick:d,src:t,alt:o("Selected image"),className:"h-auto max-h-[100px] w-full bg-gray-100 object-contain"}),i.jsxs("div",{className:"absolute right-2 top-2 flex gap-2",children:[i.jsx(I.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white text-red-500",onClick:E,disabled:a,children:m?i.jsx(b.X,{className:"h-4 w-4"}):i.jsx(b.Trash2,{className:"h-4 w-4"})}),!m&&i.jsx(I.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white/80 hover:bg-white/90",onClick:d,disabled:a,children:i.jsx(b.ImageIcon,{className:"h-4 w-4"})})]})]}):i.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:i.jsxs("div",{className:"flex flex-col items-center gap-2",children:[i.jsx(b.ImageIcon,{className:"h-10 w-10 text-gray-400"}),i.jsx("p",{className:"text-sm text-gray-500",children:r})]})}),i.jsx(g.Dialog,{open:l,onOpenChange:c,children:i.jsxs(g.DialogContent,{className:"h-fit w-full max-w-7xl overflow-hidden p-0",children:[i.jsxs(g.DialogHeader,{className:"hidden border-b px-4 py-2",children:[i.jsx(g.DialogTitle,{children:o("Select Image")}),i.jsx(I.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:u,children:i.jsx(b.X,{className:"h-4 w-4"})})]}),i.jsx("div",{className:"h-full flex-1 p-4",children:i.jsx(h.Suspense,{children:i.jsx(pl,{close:u,onSelect:f,mode:"image",assetId:e})})})]})})]})},Al=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),fn=e=>{if(!e.trim())return{isValid:!1,parsed:null,placeholders:[],error:{message:"JSON is empty"}};try{return{isValid:!0,parsed:JSON.parse(e),error:null,placeholders:[]}}catch{}const t=/{{([^{}]+)}}/g,n=[];let s=e,r;for(;(r=t.exec(e))!==null;){const a=r[0],o=r.index,l=`"__placeholder_${n.length}__"`;n.push({original:a,replaced:l,position:o}),s=s.replace(a,l)}try{return{isValid:!0,parsed:JSON.parse(s),error:null,placeholders:n}}catch(a){const o=a,l=o.message.match(/position (\d+)/),c=l?parseInt(l[1]):void 0;let d,u;if(c!==void 0){const f=s.substring(0,c).split(`
2
+ `);d=f.length,u=f[f.length-1].length+1}return{isValid:!1,parsed:null,placeholders:n,error:{message:o.message,line:d,column:u,position:c}}}},Sl=(e,t)=>{let s=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const o=`"__placeholder_${a}__"`,l=new RegExp(Al(o),"g");s=s.replace(l,r)}),s},Tl=(e,t)=>{if(!e)return"";let n=JSON.stringify(e,null,2);const s=/{{([^{}]+)}}/g;let r;for(;(r=s.exec(n))!==null;){const a=r[1],o=p.get(t,a,null);n=n.replace(r[0],o)}return n},Pl=h.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-DA0wz-k3.cjs"))),xl=({value:e,onChange:t,disabled:n=!1,readOnly:s=!1,placeholder:r="Enter JSON",rows:a=6,id:o="json-input",pageData:l={},handleFieldInsert:c,hasJsonLdForSelectedLang:d,copyJsonLDFromDefaultPage:u})=>{const[f,E]=h.useState("edit"),[m,T]=h.useState(null),[S,x]=h.useState(""),w=h.useRef(null),[A]=qt(),v=o==="jsonLD"&&p.get(A,"features.sharedJsonLD",!1),G=o==="jsonLD"&&!d&&!!u;h.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const q=V=>{if(s)return;const j=V.target.value;t(j)},L=V=>{if(V.key==="Tab"){V.preventDefault();const j=V.currentTarget,O=j.selectionStart,$=j.selectionEnd;if(O!==$){const ee=e.substring(O,$).split(`
3
3
  `);if(V.shiftKey){const se=ee.map(_e=>_e.startsWith(" ")?_e.substring(2):_e).join(`
4
4
  `),Ce=e.substring(0,O)+se+e.substring($);t(Ce),setTimeout(()=>{j.selectionStart=O,j.selectionEnd=O+se.length},0)}else{const se=ee.map(_e=>` ${_e}`).join(`
5
5
  `),Ce=e.substring(0,O)+se+e.substring($);t(Ce),setTimeout(()=>{j.selectionStart=O,j.selectionEnd=O+se.length},0)}}else{const K=e.substring(0,O)+" "+e.substring($);t(K),setTimeout(()=>{j.selectionStart=j.selectionEnd=O+2},0)}}};h.useEffect(()=>{const V=fn(e);V.isValid?h.startTransition(()=>{if(T(null),V.parsed){const j=Tl(V.parsed,l);x(j)}else x("")}):h.startTransition(()=>{T(V.error),x("")})},[e,l]);const oe=()=>{const V=fn(e);if(V.isValid&&V.parsed){const j=Sl(V.parsed,V.placeholders);t(j)}},de=()=>{m!=null&&m.position&&w.current&&(w.current.focus(),w.current.setSelectionRange(m.position,m.position+1))};return i.jsx(Pr.ErrorBoundary,{fallback:i.jsx("div",{children:"Some error"}),children:i.jsx("div",{className:"space-y-2",children:i.jsxs(g.Tabs,{value:f,onValueChange:E,className:"w-full",children:[i.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[i.jsxs(g.TabsList,{className:"w-max",children:[i.jsxs(g.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[i.jsx(b.Code,{className:"h-4 w-4"}),i.jsx("span",{children:"Edit"})]}),i.jsxs(g.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!e.trim()||m!==null||G,children:[i.jsx(b.Eye,{className:"h-4 w-4"}),i.jsx("span",{children:"Preview"})]}),v&&i.jsxs(g.TabsTrigger,{value:"shared",className:"flex items-center gap-1",disabled:!e.trim()||m!==null,children:[i.jsx(b.Share2,{className:"h-4 w-4"}),i.jsx("span",{children:"Shared"})]})]}),G?null:f==="edit"&&!s&&i.jsx("div",{className:"flex items-center gap-2",children:i.jsx(sr,{dataType:"value",data:l??{},onSelect:V=>c&&c(V,o)})})]}),i.jsxs(g.TabsContent,{value:"edit",className:"relative mt-0",children:[!G&&f==="edit"&&i.jsx(Qt,{content:"Format JSON",side:"right",showTooltip:!n&&!m,children:i.jsx(I.Button,{type:"button",variant:"outline",size:"icon",onClick:oe,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||n||m!==null,children:i.jsx(b.FileCode2,{})})}),G?i.jsx("div",{className:"flex h-40 items-center justify-center rounded-md bg-black/20",children:i.jsxs("div",{className:"flex max-w-[400px] flex-col items-center gap-2 rounded-md bg-white p-4 shadow-lg",children:[i.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."}),i.jsxs(I.Button,{type:"button",variant:"default",size:"sm",onClick:u,children:[i.jsx(b.Plus,{}),"Copy & Edit from default language"]})]})}):i.jsx(g.Textarea,{ref:w,id:o,name:o,className:`rounded-md border border-input text-xs ${m?"border-red-500":""}`,onChange:q,onKeyDown:L,value:e,placeholder:r,rows:a,disabled:n,readOnly:s}),m&&i.jsxs(I.Alert,{variant:"destructive",className:"mt-2",children:[i.jsx(b.AlertTriangle,{className:"h-4 w-4"}),i.jsxs(I.AlertDescription,{className:"flex flex-col",children:[i.jsx("span",{className:"font-medium",children:"Invalid JSON"}),i.jsx("span",{className:"text-sm",children:m.message}),m.line&&m.column&&i.jsxs("span",{className:"text-sm",children:["Error at line ",m.line,", column ",m.column]}),i.jsx(I.Button,{type:"button",variant:"link",size:"sm",className:"mt-1 h-auto self-start p-0 text-sm",onClick:de,children:"Show position"})]})]})]}),i.jsxs(g.TabsContent,{value:"preview",className:"mt-0",children:[i.jsx(g.Textarea,{rows:a,value:S,readOnly:!0,className:"cursor-default bg-muted font-mono text-sm"}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This is how the JSON will look after placeholder substitution."})]}),v&&i.jsx(g.TabsContent,{value:"shared",className:"mt-0",children:i.jsx(h.Suspense,{children:i.jsx(Pl,{})})})]})})})},_l=e=>{const t=N(),n=k();return P.useQuery({queryKey:[y.GET_CHAI_USER,e],queryFn:async()=>{const s=await n(t,{action:y.GET_CHAI_USER,data:{userId:e}}),r=(s==null?void 0:s.data)||{};return{...r,name:r.name||r.email}},enabled:!p.isEmpty(e),staleTime:"static"})};class wl{constructor(t){Jt(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(n=>{t(n)})}unsubscribe(){this.channel.unsubscribe()}onBroadcast(t,n){this.channel.on("broadcast",{event:t},n)}onPresence(t,n){this.channel.on("presence",{event:t},n)}async send(t,n){await this.channel.send({event:t,payload:n,type:"broadcast"})}async track(t){await this.channel.track(t)}untrack(){this.channel.untrack()}presenceState(){return this.channel.presenceState()}}class rr{constructor(t){Jt(this,"client");this.client=t}channel(t,n){const s=this.client.channel(t,n);return new wl(s)}}function vl(e){return new rr(e)}if(typeof window>"u")throw new Error("@chaibuilder/pages is not available on the server");exports.$TRACK=Pn;exports.ACTIONS=y;exports.BlurContainer=Ht;exports.ChaiWebsiteBuilder=fl;exports.Dynamic=so;exports.EVENT=X;exports.For=Ci;exports.ImagePicker=yl;exports.Index=Ii;exports.LANGUAGES=Ze;exports.LanguageSwitcher=ss;exports.Match=ji;exports.NestedPathSelector=sr;exports.PAGES_PERMISSIONS=re;exports.PAGE_STATUS=J;exports.PageActionsDropdown=Zn;exports.PermissionChecker=It;exports.Portal=to;exports.Show=Ni;exports.SmartJsonInput=xl;exports.SupabaseRealtimeAdapter=rr;exports.Switch=Li;exports.Tooltip=Qt;exports.addEventListener=Ls;exports.addNewLangAtom=rt;exports.batch=di;exports.className=Ns;exports.clearDelegatedEvents=Hi;exports.convertRemToPixels=Qo;exports.createComponent=wn;exports.createComputed=ps;exports.createContext=Ei;exports.createEffect=xn;exports.createMemo=W;exports.createRealtimeAdapter=vl;exports.createRenderEffect=Ae;exports.createRoot=ye;exports.createSignal=H;exports.createUniqueId=bi;exports.delegateEvents=Is;exports.deleteNestedDataByPath=tt;exports.displayValue=Bo;exports.getMutationStatusColor=Mo;exports.getPreferredColorScheme=zo;exports.getQueryStatusColor=Do;exports.getQueryStatusColorByLabel=Uo;exports.getQueryStatusLabel=Oo;exports.getSidedProp=Ro;exports.insert=Ft;exports.memo=qi;exports.mergeProps=vn;exports.mutationSortFns=Ho;exports.navigateToPage=Sn;exports.on=fi;exports.onCleanup=$e;exports.onMount=ys;exports.parseJSONWithPlaceholders=fn;exports.previewUrlAtom=er;exports.serialize=Ys;exports.setAttribute=Bt;exports.sortFns=Ko;exports.splitProps=ws;exports.spread=js;exports.stringify=ko;exports.template=Vi;exports.throwConfetti=Nt;exports.untrack=Y;exports.updateNestedDataByPath=et;exports.use=Gs;exports.useActivePage=ge;exports.useAddGlobalSchema=Ma;exports.useApiUrl=N;exports.useApplySchemaToAllPages=qa;exports.useBuilderFetch=wr;exports.useBuilderPageData=is;exports.useChaiAuth=Kt;exports.useChaiCurrentPage=ne;exports.useChaiUserInfo=_l;exports.useChaibuilderRealtime=zr;exports.useChangePage=tr;exports.useChangeSlug=pa;exports.useClearAll=ml;exports.useContext=pi;exports.useCreatePage=da;exports.useCurrentPageOwner=es;exports.useDeleteGlobalSchema=Ba;exports.useDeletePage=ha;exports.useDynamicPageSelector=Yn;exports.useFallbackLang=Vt;exports.useFetch=k;exports.useGotoPage=nr;exports.useIsLanguagePageCreated=rs;exports.useLanguagePages=Te;exports.useMarkAsTemplate=ma;exports.usePageEditInfo=mn;exports.usePageLockMeta=pn;exports.usePageLockStatus=ie;exports.usePageToUser=En;exports.usePageType=Jn;exports.usePageTypes=me;exports.usePagesProps=qt;exports.usePublishPages=Tn;exports.useRealtimeAdapter=hn;exports.useReloadPage=gl;exports.useRemoveSchemaFromAllPages=Ka;exports.useSearchParams=ue;exports.useSendRealtimeEvent=ts;exports.useTogglePageGlobalSchema=Fa;exports.useTransition=mi;exports.useUnmarkAsTemplate=Ea;exports.useUnpublishPage=ga;exports.useUpdateActivePageMetadata=El;exports.useUpdateGlobalSchema=Ua;exports.useUpdatePage=fa;exports.useUpdateWebsiteFields=os;exports.useUserId=Pt;exports.useUserRoleAndPermissions=ls;exports.useWebsiteLanguagePages=$r;exports.useWebsitePages=An;exports.useWebsiteSetting=Pe;