@chaibuilder/sdk 4.0.0-beta.3 → 4.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/{2SSKDMRQ-BnsZi3K3.cjs → 2SSKDMRQ-BIryEtW-.cjs} +1 -1
  2. package/dist/{2SSKDMRQ-CnSDkQcy.js → 2SSKDMRQ-trME0kvt.js} +2 -2
  3. package/dist/{AP7HFJJL-B31839PG.cjs → AP7HFJJL-5ZR38Hyh.cjs} +1 -1
  4. package/dist/{AP7HFJJL-CymCmW14.js → AP7HFJJL-CAGB9iMp.js} +1 -1
  5. package/dist/IconPicker-CQ-BgNNU.cjs +1 -0
  6. package/dist/{IconPicker-B1rWC-Ex.js → IconPicker-Mu75ni5T.js} +8 -7
  7. package/dist/{WDYDFRGG-BUVnbAci.js → WDYDFRGG-Cd4hRWj-.js} +2 -2
  8. package/dist/{WDYDFRGG-BxhOCHc3.cjs → WDYDFRGG-n8sBZVFG.cjs} +1 -1
  9. package/dist/{actions-registery-YnFmU21O.cjs → actions-registery-JdxhXhT6.cjs} +1 -1
  10. package/dist/{actions-registery-CZ1w0NKa.js → actions-registery-y_ENc8zj.js} +2 -2
  11. package/dist/actions.cjs +1 -1
  12. package/dist/actions.js +2 -2
  13. package/dist/active-in-another-tab-CZLV-uAW.cjs +1 -0
  14. package/dist/active-in-another-tab-Cb6tnX9u.js +35 -0
  15. package/dist/{add-new-language-page-WmlCnytQ.js → add-new-language-page-BKcBaqZu.js} +54 -53
  16. package/dist/add-new-language-page-C3UzNV7W.cjs +1 -0
  17. package/dist/{add-new-page-soZ8GAkN.cjs → add-new-page-mULv9r3z.cjs} +1 -1
  18. package/dist/{add-new-page-VW2wAYZp.js → add-new-page-pH3PwqJe.js} +2 -2
  19. package/dist/ai-panel-content-BPgRdgye.cjs +1 -0
  20. package/dist/{ai-panel-content-D_o7Q_A-.js → ai-panel-content-CNxN84pv.js} +12 -11
  21. package/dist/{ai-panel-default-lang-DnElspF0.js → ai-panel-default-lang-CYcHjk8U.js} +40 -40
  22. package/dist/{ai-panel-default-lang-COYaxNwn.cjs → ai-panel-default-lang-DhTPtPgD.cjs} +2 -2
  23. package/dist/{ai-panel-other-lang-CkynNlAU.cjs → ai-panel-other-lang-CGNU3-FI.cjs} +1 -1
  24. package/dist/{ai-panel-other-lang-Dp0E9_Hx.js → ai-panel-other-lang-D8Ofvj8F.js} +8 -8
  25. package/dist/ai-prompt-input-CUutJjlf.cjs +1 -0
  26. package/dist/{ai-prompt-input-Bhc0ds7X.js → ai-prompt-input-Ceuy5bs3.js} +68 -67
  27. package/dist/{ai-translation-prompt-CZ55HQmo.js → ai-translation-prompt-BiepZRcN.js} +2 -2
  28. package/dist/ai-translation-prompt-CoCPLEed.cjs +1 -0
  29. package/dist/{apply-binding-6iwlED02.js → apply-binding-BvWfJCSZ.js} +204 -196
  30. package/dist/apply-binding-IsUf6UWJ.cjs +1 -0
  31. package/dist/{code-display-DhD_RBcg.js → code-display-Ck81Id9K.js} +1 -1
  32. package/dist/code-display-DloSPyPr.cjs +1 -0
  33. package/dist/code-editor-C1ewJzDJ.cjs +1 -0
  34. package/dist/{code-editor-DRIAnNbb.js → code-editor-Z14ByBIv.js} +11 -10
  35. package/dist/{continue-editing-in-this-client-CS2aQ7yY.js → continue-editing-in-this-client-Byi6ER3L.js} +10 -9
  36. package/dist/continue-editing-in-this-client-k9Ab5E63.cjs +1 -0
  37. package/dist/core-Dr7QYemB.js +56 -0
  38. package/dist/core-Y0lXLwkq.cjs +1 -0
  39. package/dist/core.cjs +1 -1
  40. package/dist/core.d.ts +3 -3
  41. package/dist/core.js +32 -31
  42. package/dist/css-import-modal--bSJR-_y.cjs +13 -0
  43. package/dist/{css-import-modal-Byg6wV0O.js → css-import-modal-De7Kvg5C.js} +4 -3
  44. package/dist/{delete-design-token-BRZZiWtQ.js → delete-design-token-B97CnFDU.js} +1 -1
  45. package/dist/{delete-design-token-DkVs1oBf.cjs → delete-design-token-C6s-ESB_.cjs} +1 -1
  46. package/dist/delete-page-Djn97HiP.cjs +1 -0
  47. package/dist/{delete-page-BzyX9TN-.js → delete-page-Dnf97ZHP.js} +11 -10
  48. package/dist/{design-token-usage-xQs6SlaJ.js → design-token-usage-B-SykAjD.js} +14 -13
  49. package/dist/design-token-usage-OTd93kS8.cjs +1 -0
  50. package/dist/digital-asset-manager-DHYRXaaq.cjs +1 -0
  51. package/dist/{digital-asset-manager-DbtwzxRz.js → digital-asset-manager-b8gDuLnI.js} +6 -5
  52. package/dist/{duplicate-page-BR7Dlo9d.js → duplicate-page-Bdtpl7_R.js} +19 -18
  53. package/dist/duplicate-page-C4Ovp8Ff.cjs +1 -0
  54. package/dist/dynamic-page-selector-B8DdnfrF.cjs +1 -0
  55. package/dist/{dynamic-page-selector-Cb5r_W8s.js → dynamic-page-selector-BVnIM1Rq.js} +15 -14
  56. package/dist/get-chai-builder-tailwind-config-DNp8Vhme.cjs +1 -0
  57. package/dist/{get-chai-builder-tailwind-config-DjoVOuAf.js → get-chai-builder-tailwind-config-k8l5sdcw.js} +5 -5
  58. package/dist/{get-chai-builder-theme-Dl72X7cz.cjs → get-chai-builder-theme-BApShjRz.cjs} +1 -1
  59. package/dist/{get-chai-builder-theme-BYtp20KD.js → get-chai-builder-theme-DDVRJQ6Z.js} +1 -1
  60. package/dist/{image-editor-G-K28aTS.cjs → image-editor-C2zOHeKv.cjs} +1 -1
  61. package/dist/{image-editor-DV8kUKhl.js → image-editor-cckqPmk5.js} +1 -1
  62. package/dist/index-B0e71wJ1.cjs +160 -0
  63. package/dist/{index-ZuacEL1j.js → index-Bn0fFN58.js} +665 -663
  64. package/dist/{index-Ct7ElCGK.js → index-CAhEmHYP.js} +3744 -3920
  65. package/dist/index-DKuwxj1x.cjs +5 -0
  66. package/dist/{json-diff-viewer-D7z4zNvv.cjs → json-diff-viewer-D9DVIBz4.cjs} +3 -3
  67. package/dist/{json-diff-viewer-krslPepD.js → json-diff-viewer-DNizzMnu.js} +5 -4
  68. package/dist/lang-panel-C1dbn163.cjs +1 -0
  69. package/dist/{lang-panel-BwIewMyw.js → lang-panel-DL_BtSRD.js} +15 -14
  70. package/dist/manage-design-tokens-CXjYkarE.cjs +1 -0
  71. package/dist/{manage-design-tokens-Caz_20VK.js → manage-design-tokens-xxMO_RYg.js} +12 -11
  72. package/dist/{mark-as-template-D295ZQtU.js → mark-as-template-Ba2bmVd9.js} +17 -16
  73. package/dist/mark-as-template-DF1KIMr0.cjs +1 -0
  74. package/dist/{nested-path-selector-content-CKYYK-C5.js → nested-path-selector-content-Br1IWhK5.js} +24 -23
  75. package/dist/nested-path-selector-content-Cuk7NB-u.cjs +1 -0
  76. package/dist/{no-language-page-content-BvqRBP6y.js → no-language-page-content-9B2Fm-on.js} +10 -9
  77. package/dist/no-language-page-content-CxTp-LIM.cjs +1 -0
  78. package/dist/{no-language-page-dialog-PjNqTUpl.js → no-language-page-dialog-CPlKMyb8.js} +2 -2
  79. package/dist/{no-language-page-dialog-BcEoqyQB.cjs → no-language-page-dialog-DynACvgV.cjs} +1 -1
  80. package/dist/{page-creator-DiOITEMw.js → page-creator-BtyJz2sx.js} +115 -114
  81. package/dist/page-creator-Cbfv9N0P.cjs +1 -0
  82. package/dist/{page-lock-Bfbs6RgL.js → page-lock-CzsxrmN5.js} +2 -2
  83. package/dist/{page-lock-BdYmCks0.cjs → page-lock-fRos9wRU.cjs} +1 -1
  84. package/dist/{page-locked-dialog-B6MKTRfY.js → page-locked-dialog-D2q9qkPk.js} +18 -15
  85. package/dist/page-locked-dialog-D57d2gvn.cjs +1 -0
  86. package/dist/{page-manager-new-CzX22g2n.js → page-manager-new-D6DVIx2S.js} +30 -29
  87. package/dist/page-manager-new-aE198gKS.cjs +1 -0
  88. package/dist/{page-manager-search-and-filter-CM0UMb6U.js → page-manager-search-and-filter-CuZkQaZg.js} +13 -12
  89. package/dist/page-manager-search-and-filter-DGQEgKzy.cjs +1 -0
  90. package/dist/{page-revisions-content-NH9JK4Ey.js → page-revisions-content-5rbicFbD.js} +34 -31
  91. package/dist/page-revisions-content-CefqOvKX.cjs +1 -0
  92. package/dist/pages.cjs +1 -1
  93. package/dist/pages.d.ts +4 -4
  94. package/dist/pages.js +1 -1
  95. package/dist/{plugin-C6rgJDNQ.cjs → plugin-BGlQf0iy.cjs} +1 -1
  96. package/dist/{plugin-3ZKK6RXm.js → plugin-C-ht41UZ.js} +1 -1
  97. package/dist/publish-pages-content-DBb8M3TG.cjs +1 -0
  98. package/dist/{publish-pages-content-D9aixMN5.js → publish-pages-content-WeGk-YLC.js} +66 -65
  99. package/dist/register-chai-top-bar-BqwKw4uy.cjs +1 -0
  100. package/dist/register-chai-top-bar-ESJHs5s-.js +237 -0
  101. package/dist/render.cjs +2 -2
  102. package/dist/render.d.ts +2 -2
  103. package/dist/render.js +87 -80
  104. package/dist/rte-widget-modal-DBoPRXq-.cjs +1 -0
  105. package/dist/{rte-widget-modal-DOJEXLIf.js → rte-widget-modal-J-_AytmK.js} +15 -14
  106. package/dist/runtime.cjs +1 -1
  107. package/dist/runtime.d.ts +168 -4
  108. package/dist/runtime.js +68 -38
  109. package/dist/save-to-lib-0ysmXVbI.cjs +1 -0
  110. package/dist/{save-to-lib-eiOc_SSN.js → save-to-lib-CQQxoovF.js} +39 -38
  111. package/dist/sdk.css +1 -1
  112. package/dist/selected-block-display-BWupQFoQ.cjs +16 -0
  113. package/dist/{selected-block-display-CBFePS19.js → selected-block-display-CgoXS8Hr.js} +37 -36
  114. package/dist/{seo-panel-C1-iMOR1.js → seo-panel-B798Myp_.js} +12 -11
  115. package/dist/seo-panel-BkFbXIL0.cjs +2 -0
  116. package/dist/{shared-json-ld-B4PxAM_0.js → shared-json-ld-Clg_UEhd.js} +68 -67
  117. package/dist/shared-json-ld-Cn3MCW6I.cjs +1 -0
  118. package/dist/slug-input-BHyD8cxk.cjs +1 -0
  119. package/dist/{slug-input-AwNJs9im.js → slug-input-hX5VaZpj.js} +9 -8
  120. package/dist/supabase-actions.cjs +1 -1
  121. package/dist/supabase-actions.d.ts +1 -1
  122. package/dist/supabase-actions.js +1 -1
  123. package/dist/take-over-request-Dzczo20q.cjs +1 -0
  124. package/dist/{take-over-request-C4FeDtN_.js → take-over-request-s1L5Yofb.js} +17 -16
  125. package/dist/theme-panel-footer-NTNCL0SW.cjs +1 -0
  126. package/dist/{theme-panel-footer-uBQqSJXm.js → theme-panel-footer-sK6bYhEb.js} +11 -10
  127. package/dist/translation-warning-modal-BfM4HGck.cjs +1 -0
  128. package/dist/{translation-warning-modal-B64YqlbI.js → translation-warning-modal-Jadkcver.js} +9 -8
  129. package/dist/unmark-as-template-CqkHI3gR.cjs +1 -0
  130. package/dist/{unmark-as-template-CZ9sQp_P.js → unmark-as-template-D5b775eR.js} +11 -10
  131. package/dist/unpublish-page-BT5bCfs6.cjs +1 -0
  132. package/dist/unpublish-page-DLLLgY43.js +28 -0
  133. package/dist/utils.cjs +1 -1
  134. package/dist/utils.d.ts +3 -0
  135. package/dist/utils.js +2 -2
  136. package/dist/web-blocks.cjs +1 -1
  137. package/dist/web-blocks.js +5 -5
  138. package/dist/{web-preview-Djy6WIyj.js → web-preview-C_yFwxEe.js} +2 -2
  139. package/dist/web-preview-DU1MgppY.cjs +1 -0
  140. package/package.json +4 -2
  141. package/dist/IconPicker-DREyo007.cjs +0 -1
  142. package/dist/active-in-another-tab-B47YjQGN.cjs +0 -1
  143. package/dist/active-in-another-tab-CyjngVA6.js +0 -34
  144. package/dist/add-new-language-page-88xzrUy8.cjs +0 -1
  145. package/dist/ai-panel-content-7zCil042.cjs +0 -1
  146. package/dist/ai-prompt-input-CThbVp0_.cjs +0 -1
  147. package/dist/ai-translation-prompt-C2kJQFDX.cjs +0 -1
  148. package/dist/apply-binding-KKp5PnpZ.cjs +0 -1
  149. package/dist/code-display-BnqzqzoP.cjs +0 -1
  150. package/dist/code-editor-o3___nu2.cjs +0 -1
  151. package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +0 -1
  152. package/dist/core-BoRDjj4h.cjs +0 -1
  153. package/dist/core-yvI6kCyw.js +0 -56
  154. package/dist/css-import-modal-CyqkXWCO.cjs +0 -13
  155. package/dist/delete-page-DxX7PFIE.cjs +0 -1
  156. package/dist/design-token-usage-CAHzEGgJ.cjs +0 -1
  157. package/dist/digital-asset-manager--uO8Agia.cjs +0 -1
  158. package/dist/duplicate-page-CaNAbXwV.cjs +0 -1
  159. package/dist/dynamic-page-selector-Cxk_gjni.cjs +0 -1
  160. package/dist/get-chai-builder-tailwind-config-B9rCyiQo.cjs +0 -1
  161. package/dist/index-DF5DEvqb.cjs +0 -160
  162. package/dist/index-WQwzsC7A.cjs +0 -5
  163. package/dist/lang-panel-DT96k1xg.cjs +0 -1
  164. package/dist/manage-design-tokens-CrmLe7UT.cjs +0 -1
  165. package/dist/mark-as-template-W3LmpiqN.cjs +0 -1
  166. package/dist/nested-path-selector-content-CoS_d3dc.cjs +0 -1
  167. package/dist/no-language-page-content-DkfeMl90.cjs +0 -1
  168. package/dist/page-creator-C4gc5NSC.cjs +0 -1
  169. package/dist/page-locked-dialog-B1FAtK92.cjs +0 -1
  170. package/dist/page-manager-new-CHDueBDk.cjs +0 -1
  171. package/dist/page-manager-search-and-filter-DkkRIH86.cjs +0 -1
  172. package/dist/page-revisions-content-ChY-4f2V.cjs +0 -1
  173. package/dist/publish-pages-content-x-JuSFJ9.cjs +0 -1
  174. package/dist/rte-widget-modal-BaHIuEjF.cjs +0 -1
  175. package/dist/save-to-lib-Cgpxw8-g.cjs +0 -1
  176. package/dist/selected-block-display-BgRY82CT.cjs +0 -16
  177. package/dist/seo-panel-DfAb8U7W.cjs +0 -2
  178. package/dist/shared-json-ld-DzG398hr.cjs +0 -1
  179. package/dist/slug-input-C_ijLQ_X.cjs +0 -1
  180. package/dist/take-over-request-BNxcjY2j.cjs +0 -1
  181. package/dist/theme-panel-footer-Cq9pljro.cjs +0 -1
  182. package/dist/translation-warning-modal-BZAcwM2_.cjs +0 -1
  183. package/dist/unmark-as-template-EVvk0vmp.cjs +0 -1
  184. package/dist/unpublish-page-D4VwOlxc.js +0 -27
  185. package/dist/unpublish-page-bdSmwAVQ.cjs +0 -1
  186. package/dist/web-preview-Cio70gk5.cjs +0 -1
@@ -1,5 +0,0 @@
1
- "use strict";var or=Object.create;var vs=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var lr=Object.getOwnPropertyNames;var cr=Object.getPrototypeOf,ur=Object.prototype.hasOwnProperty;var bs=e=>{throw TypeError(e)};var dr=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of lr(t))!ur.call(e,r)&&r!==s&&vs(e,r,{get:()=>t[r],enumerable:!(n=ir(t,r))||n.enumerable});return e};var fr=(e,t,s)=>(s=e!=null?or(cr(e)):{},dr(t||!e||!e.__esModule?vs(s,"default",{value:e,enumerable:!0}):s,e));var Cs=(e,t,s)=>t.has(e)||bs("Cannot "+s);var P=(e,t,s)=>(Cs(e,t,"read from private field"),s?s.call(e):t.get(e)),O=(e,t,s)=>t.has(e)?bs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),k=(e,t,s,n)=>(Cs(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s);const o=require("react/jsx-runtime"),h=require("./index-DF5DEvqb.cjs"),V=require("jotai"),p=require("lodash-es"),g=require("react"),S=require("@tanstack/react-query"),x=require("lucide-react"),fe=require("react-i18next"),Nt=require("./common-functions-B3a4xKt_.cjs"),B=require("sonner"),Ks=require("./core-BoRDjj4h.cjs"),hr=require("./apply-binding-KKp5PnpZ.cjs"),gr=require("./web-blocks.cjs"),mr=require("react-error-boundary");function Er(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const H=Er(g),tt=V.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_SETTINGS:"UPDATE_WEBSITE_SETTINGS",GET_COLLECTIONS:"GET_COLLECTIONS",GET_PAGE_TYPES:"GET_PAGE_TYPES",SEARCH_PAGES:"SEARCH_PAGES",GET_WEBSITE_DRAFT_SETTINGS:"GET_WEBSITE_DRAFT_SETTINGS",AI_CONTEXT:"AI_CONTEXT",GET_WEBSITE_DATA:"GET_WEBSITE_DATA",UPDATE_WEBSITE_DATA:"UPDATE_WEBSITE_DATA",GET_CHAI_USER:"GET_CHAI_USER",GET_SEO_FIELDS:"GET_SEO_FIELDS",GET_BUILDER_PAGE_DATA:"GET_BUILDER_PAGE_DATA",GET_PAGE_REVISIONS:"GET_PAGE_REVISIONS",DELETE_PAGE_REVISION:"DELETE_PAGE_REVISION",RESTORE_PAGE_REVISION:"RESTORE_PAGE_REVISION",GET_REVISION_DATA:"GET_REVISION_DATA",GET_PAGE_DATA:"GET_PAGE_DATA",GET_COMPARE_DATA:"GET_COMPARE_DATA",GET_ROLE_AND_PERMISSIONS:"GET_ROLE_AND_PERMISSIONS",UPSERT_LIBRARY_ITEM:"UPSERT_LIBRARY_ITEM",GET_LIBRARIES:"GET_LIBRARIES",GET_LIBRARY_ITEM:"GET_LIBRARY_ITEM",GET_LIBRARY_ITEMS:"GET_LIBRARY_ITEMS",DELETE_LIBRARY_ITEM:"DELETE_LIBRARY_ITEM",MARK_AS_TEMPLATE:"MARK_AS_TEMPLATE",UNMARK_AS_TEMPLATE:"UNMARK_AS_TEMPLATE",GET_TEMPLATES_BY_TYPE:"GET_TEMPLATES_BY_TYPE",GET_DYNAMIC_PAGES:"GET_DYNAMIC_PAGES",GET_APP_SHARED_JSONLD:"GET_APP_SHARED_JSONLD",UPDATE_APP_SHARED_JSONLD:"UPDATE_APP_SHARED_JSONLD",ADD_GLOBAL_SCHEMA:"ADD_GLOBAL_SCHEMA",UPDATE_GLOBAL_SCHEMA:"UPDATE_GLOBAL_SCHEMA",DELETE_GLOBAL_SCHEMA:"DELETE_GLOBAL_SCHEMA",TOGGLE_PAGE_GLOBAL_SCHEMA:"TOGGLE_PAGE_GLOBAL_SCHEMA",APPLY_SCHEMA_TO_ALL_PAGES:"APPLY_SCHEMA_TO_ALL_PAGES",REMOVE_SCHEMA_FROM_ALL_PAGES:"REMOVE_SCHEMA_FROM_ALL_PAGES",UPLOAD_ASSET:"UPLOAD_ASSET",DELETE_ASSET:"DELETE_ASSET",UPDATE_ASSET:"UPDATE_ASSET",GET_ASSETS:"GET_ASSETS",GET_ASSET:"GET_ASSET"},pr=V.atom({}),Bt=()=>V.useAtom(pr),ae=(e,t)=>{const[s]=Bt();return g.useMemo(()=>p.get(s,e,t),[s,e,t])},L=()=>ae("apiUrl","/chai/api"),Vs=()=>ae("websocket",null),yr=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)}),Tr=()=>{const e=N(),t=L();return g.useCallback(async({body:s,headers:n={},url:r=t,streamResponse:a=!1})=>e(r,s,n,a),[e])},N=()=>{const e=ae("onLogout"),t=ae("getAccessToken"),s=L();return g.useCallback(async(n=s,r,a={},i=!1)=>{const l=await t();try{const c=p.get(r,"action","").toLowerCase(),f=await yr(n+(c?`?action=${c}`:""),r,{...a,Authorization:`Bearer ${l}`});if(i)return f;if(f.status===401)return console.log("401 Response",f),e(),window.location.reload(),null;if(!f.ok){const d=await f.json();throw console.error(`API Error (${f.status}):`,d),{status:f.status,statusText:f.statusText,...d,message:d.error||d.message||`Server error: ${f.status}`}}return await f.json()}catch(c){throw console.error("API request failed:",r,c),c}},[e,t])};function ie(){const[e,t]=g.useState(new URLSearchParams(window.location.search));return g.useEffect(()=>{const s=()=>{t(new URLSearchParams(window.location.search))};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[]),[e,t]}const Te=e=>{const t=L(),[s]=ie(),n=e??s.get("page"),r=N();return S.useQuery({queryKey:[y.GET_LANGUAGE_PAGES,n],staleTime:1/0,gcTime:0,placeholderData:[],queryFn:async()=>{if(!n)return null;const a=await r(t,{action:y.GET_LANGUAGE_PAGES,data:{id:n}});return p.reverse(p.sortBy(a,"primaryPage"))},enabled:!!n})},Ar=V.atom(null),Hs=()=>V.useAtom(Ar),is=()=>{const[e]=Hs();return(e==null?void 0:e.slug)||""};function Sr(e,t){const[s,n]=g.useState(e);return g.useEffect(()=>{const r=setTimeout(()=>n(e),t);return()=>clearTimeout(r)},[e,t]),s}const Pr=({query:e,uuid:t})=>{const{selectedLang:s,fallbackLang:n}=h.useLanguages(),{data:r}=ee(),a=r==null?void 0:r.pageType,i=L(),l=N(),{data:c,isFetching:f}=S.useQuery({queryKey:[y.GET_DYNAMIC_PAGES,e,a,t],staleTime:3600*1e3,placeholderData:[],queryFn:async()=>await l(i,{action:y.GET_DYNAMIC_PAGES,data:{query:e,pageType:a,uuid:t}})||[],enabled:!!a}),d=g.useMemo(()=>s===""?c.filter(u=>u.lang===""||u.lang===n):c.filter(u=>u.lang===s),[s,n,c]);return{allLangPages:c,data:d,isFetching:f}},Qs=()=>{const{selectedLang:e,fallbackLang:t}=h.useLanguages(),[s,n]=Hs(),[r,a]=g.useState(""),i=Sr(r,500),{allLangPages:l,data:c,isFetching:f}=Pr({query:i}),d=g.useCallback(m=>n(m),[n]),u=g.useCallback(m=>a(m),[a]),E=g.useCallback(()=>{if(!s)return;const m=!(s!=null&&s.primaryPage),T=e.length===0,_=m?s==null?void 0:s.id:s==null?void 0:s.primaryPage,R=l.filter(A=>(A==null?void 0:A.primaryPage)===_||A.id===_).find(A=>T?A.lang===e||A.lang===t:A.lang===e);n(R||s)},[s,e,l,n,t]);return{isFetching:f,dynamicPage:s,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:d,updateSearchQuery:u,onChangeLanguage:E}},xr=V.atom({lastSaved:void 0}),ls=()=>V.useAtom(xr),ee=()=>{const[e]=ie(),t=e.get("page"),{data:s,isFetching:n}=Te();return{data:g.useMemo(()=>({...p.find(s,{id:t})||{}}),[s,t]),isFetching:n}},he=()=>{const[e]=ie(),t=e.get("lang")??"",{data:s,isFetching:n}=Te();return{data:g.useMemo(()=>p.find(s,{lang:t})||{},[s,t]),isFetching:n}},_r=V.atom({}),wr=()=>V.useAtom(_r),vr=()=>{const{data:e}=he(),t=is(),s=ae("getLiveUrl",p.noop),n=e==null?void 0:e.slug,r=s(n||"/");return t?r+t:r},te={...h.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"},ge=()=>{const e=L(),t=N();return S.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},zs=e=>{const{data:t}=ge();return g.useMemo(()=>t==null?void 0:t.find(s=>s.key===e),[t,e])},br=()=>{const e=L(),t=N();return S.useMutation({mutationFn:async({pageType:s,query:n})=>{try{return t(e,{action:y.SEARCH_PAGES,data:{pageType:s,query:Array.isArray(n)&&n.length>0?n[0]:n}})||[]}catch(r){return console.error(r),[]}}})},$s=({page:e,setDuplicatePage:t,setAddEditPage:s,setUnpublishPage:n,setDeletePage:r,setMarkAsTemplate:a,setUnmarkAsTemplate:i,children:l,isLanguagePage:c})=>{const{t:f}=fe.useTranslation(),{hasPermission:d}=h.usePermissions(),{data:u}=ge(),E=g.useMemo(()=>p.find(u,{key:e.pageType}),[u,e.pageType]),m=g.useMemo(()=>!!e.isTemplate,[e.isTemplate]),T=g.useMemo(()=>!!(E!=null&&E.hasSlug),[E==null?void 0:E.hasSlug]);return!d(te.EDIT_PAGE)&&!d(te.DELETE_PAGE)&&!d(te.UNPUBLISH_PAGE)||!e?null:o.jsxs(h.DropdownMenu,{children:[o.jsx(h.DropdownMenuTrigger,{asChild:!0,onClick:w=>w.stopPropagation(),children:l}),o.jsxs(h.DropdownMenuContent,{align:"center",className:"text-sm",children:[d(te.ADD_PAGE)&&!c&&o.jsxs(h.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:w=>{w.stopPropagation(),t(e)},children:[o.jsx(x.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),d(te.EDIT_PAGE)&&o.jsxs(h.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:w=>{w.stopPropagation(),s({...e,global:!(E!=null&&E.hasSlug)})},children:[o.jsx(x.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&d(te.UNPUBLISH_PAGE)&&o.jsxs(h.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:w=>{w.stopPropagation(),n(e)},children:[o.jsx(x.Power,{className:"size-3"}),f("Unpublish")]}),d(te.DELETE_PAGE)&&o.jsxs(h.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:w=>{w.stopPropagation(),r(e)},children:[o.jsx(x.Trash,{className:"size-3"}),f("Delete")]}),d(te.MARK_AS_TEMPLATE)&&T&&!c&&o.jsx(o.Fragment,{children:m?o.jsxs(h.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:w=>{w.stopPropagation(),i(e)},children:[o.jsx(x.SquareLibrary,{className:"size-3"}),f("Unmark as template")]}):o.jsxs(h.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:w=>{w.stopPropagation(),a(e)},children:[o.jsx(x.SquareLibrary,{className:"size-3"}),f("Mark as template")]})})]})]})},Ae=()=>{const e=L(),t=N();return S.useQuery({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS],staleTime:300*1e3,placeholderData:{languages:[],theme:{fontFamily:"",borderRadius:"",colors:{}},appKey:"",fallbackLang:"",designTokens:{}},queryFn:async()=>t(e,{action:y.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})},Ft=()=>{const e=ae("currentUser"),t=ae("onLogout");return{isLoggedIn:!!e,user:e,logout:t}},Y={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"},Z={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"},Cr=["sync","join","leave"],Ir=[Z.FORCE_TAKE_OVER,Z.TAKE_OVER_REQUEST,Z.TAKE_OVER_APPROVED,Z.TAKE_OVER_REJECTED,Z.FORCE_TAKE_OVER_REQUEST,Z.CONTINUE_EDITING_IN_THIS_CLIENT,Z.CONTINUE_EDITING_IN_THIS_TAB_REQUEST],Lr=V.atom({}),Ws=V.atom(null),Nr=V.atom(Y.CHECKING),jr=V.atom({}),Gr=e=>{const t={},s=p.groupBy(p.values(e).map(p.first).filter(Boolean),"pageId");return Object.entries(s).forEach(([n,r])=>t[n]=p.minBy(r,"onlineAt")),t},kr=e=>{const t=p.minBy(p.values(e).map(p.first).filter(Boolean),"onlineAt"),s=t==null?void 0:t.onlineAt;return s?s-100:+new Date-1e3*60*60*4},Tt=()=>{const{user:e}=Ft();return e==null?void 0:e.id},Dr=()=>{const{data:e}=Ae();return`WEBSITE:${e==null?void 0:e.appKey}`},At=()=>{const{data:e}=ee();return e==null?void 0:e.id},_e=crypto.randomUUID();let zt=null;const cs=()=>{const[e,t]=V.useAtom(Lr);return{pageToUser:e,setPageToUser:t}},se=()=>{const[e,t]=V.useAtom(Nr),s=[Y.LOCKED,Y.ACTIVE_IN_ANOTHER_TAB].includes(e),n=[Y.EDITING].includes(e);return{pageStatus:e,setPageStatus:t,isLocked:s,isEditing:n}},us=()=>{const[e,t]=V.useAtom(jr);return{pageLockMeta:e,setPageLockMeta:t}},Ys=()=>{const e=At(),{pageToUser:t}=cs();return g.useMemo(()=>t[e],[t,e])},ds=()=>{const e=Vs(),{setPageStatus:t}=se(),[s]=V.useAtom(Ws);return g.useEffect(()=>{if(clearTimeout(zt),!e)return zt=setTimeout(()=>{e||t(Y.EDITING)},500),()=>clearTimeout(zt)},[e,t]),s},Or=()=>{const e=At(),t=Tt(),s=ds(),{setPageToUser:n}=cs(),{setPageStatus:r,pageStatus:a}=se(),i=g.useRef(e);return i.current=e,g.useCallback(l=>{const c=l||s;if(!c)return[];const f=c==null?void 0:c.presenceState(),d=Gr(f);n(d);const u=d[i.current];if(!u)r(Y.CHECKING);else if(!t)r(Y.CHECKING);else if(u.userId===t&&u.clientId===_e){if(a===Y.TAKE_OVER_REQUESTED)return;r(Y.EDITING)}else u.userId===t&&u.clientId!==_e?r(Y.ACTIVE_IN_ANOTHER_TAB):r(Y.LOCKED)},[s,n,r,t,a])},Js=()=>{const e=Tt(),t=At(),s=ds(),n=Ys(),{setPageLockMeta:r}=us(),a=g.useRef(t);return a.current=t,g.useCallback(async(i,l)=>{if(!s)return;const c=l||{};c.userId=e,c.pageId=a.current,c.senderClientId=_e,c.receiverClientId=(l==null?void 0:l.requestingClientId)||(n==null?void 0:n.clientId),await s.send({event:i,payload:c,type:"broadcast"}),r({})},[s,e,n,r])},Rr=()=>{const e=Tt(),t=At(),s=ds(),{setPageStatus:n}=se(),{setPageLockMeta:r}=us(),a=Js(),i=g.useRef(t),{savePageAsync:l}=h.useSavePage();return i.current=t,g.useCallback(c=>async({payload:f})=>{const d=f||{};if(!(!(d!=null&&d.pageId)||(d==null?void 0:d.pageId)!==i.current||(d==null?void 0:d.receiverClientId)!==_e))switch(r({}),c){case Z.FORCE_TAKE_OVER_REQUEST:case Z.CONTINUE_EDITING_IN_THIS_TAB_REQUEST:{try{await l(!0)}catch(u){console.error("Failed to save page before releasing lock:",u)}await a(Z.CONTINUE_EDITING_IN_THIS_CLIENT,{requestingClientId:d==null?void 0:d.senderClientId}),setTimeout(()=>r({type:c}),0);break}case Z.TAKE_OVER_REQUEST:{r({requestingUserId:d==null?void 0:d.userId,requestingClientId:d==null?void 0:d.senderClientId}),n(Y.TAKE_OVER_REQUESTED);break}case Z.CONTINUE_EDITING_IN_THIS_CLIENT:{const u=kr(s==null?void 0:s.presenceState());n(Y.CHECKING),await(s==null?void 0:s.track({onlineAt:u,pageId:i.current,userId:e,clientId:_e}));break}case Z.TAKE_OVER_REJECTED:{r({type:Z.TAKE_OVER_REJECTED});break}}},[a,r,n,s,e,l])},Mr=()=>{const e=Vs(),t=Tt(),s=At(),n=Dr(),[r,a]=V.useAtom(Ws),i=Rr(),l=Or(),c=g.useRef(i),f=g.useRef(l);g.useEffect(()=>{c.current=i,f.current=l},[i,l]),g.useEffect(()=>{if(!e||!t||!n||r&&r.topic===n)return;const d=e.channel(n,{config:{presence:{key:_e}}});return Ir.forEach(u=>{d.on("broadcast",{event:u},E=>{c.current(u)(E)})}),Cr.forEach(u=>{d.on("presence",{event:u},()=>{f.current(d)})}),d.subscribe(async u=>{u==="SUBSCRIBED"?a(d):(u==="CHANNEL_ERROR"||u==="TIMED_OUT")&&console.log("Realtime connection failed",u)}),()=>{d.unsubscribe()}},[e,t,n,a]),g.useEffect(()=>(r&&s&&t&&r.track({pageId:s,userId:t,clientId:_e,onlineAt:+new Date}),()=>{r&&s&&r.untrack()}),[r,s,t])},qt=()=>{const{data:e}=Ae();return g.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},fs=()=>{const e=N(),t=L();return S.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:s=>s||[]})},Ur=e=>{const t=N(),s=L(),n=qt();return S.useQuery({queryKey:[y.GET_WEBSITE_PAGES,e,n],staleTime:1e3*60*5,enabled:!!e,queryFn:async()=>{if(n===e)return{};const r=await t(s,{action:y.GET_WEBSITE_PAGES,data:{lang:e}})||[];return p.keyBy(p.map(r,a=>({...a,lang:e})),"primaryPage")},placeholderData:r=>r||{}})};function hs(e,t,s=!1){const n=e.toString()?`?${e.toString()}`:"/";s?window.history.replaceState(null,"",n):window.history.pushState({},"",n),t(e),window.dispatchEvent(new PopStateEvent("popstate"))}const Br=g.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-CHDueBDk.cjs"))),Zs=({children:e})=>{const{t}=fe.useTranslation(),[s,n]=ie(),r=s.get("page"),{data:a,isFetching:i}=ee(),{data:l,isFetching:c}=fs(),[f,d]=g.useState(!1),[u,E]=g.useState(!0),{savePage:m}=h.useSavePage(),T=!!r&&!p.isEmpty(a),{isLocked:_}=se(),w=g.useMemo(()=>{if(!l||c)return!1;const I=l.find(F=>F.slug==="/");return I==null?void 0:I.id},[l,c]);g.useEffect(()=>{if(c||!w||l.some(j=>j.id===r))return;const F=new URLSearchParams({page:w});hs(F,n),!c&&l&&E(!1)},[r,c,l,w,n]);const R=!u&&!r,A=!u&&!i&&p.isEmpty(a),C=f||R||A;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex items-center gap-x-1",children:o.jsx("div",{className:"relative",children:o.jsxs(h.Tooltip,{children:[o.jsx(h.TooltipTrigger,{asChild:!0,onClick:()=>{_||m(),d(!0)},children:e||o.jsx(h.Button,{variant:"outline",className:"flex w-full items-center space-x-2 py-1",children:o.jsx(x.LogsIcon,{className:"h-4 w-4"})},"template-viewer")}),o.jsx(h.TooltipContent,{side:"right",children:o.jsx("p",{children:t("Open pages manager")})})]})})}),o.jsx(h.Sheet,{open:C,onOpenChange:I=>!I&&T&&d(!1),children:o.jsxs(h.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:[o.jsxs(h.SheetHeader,{className:"mb-3 px-4 pt-4",children:[o.jsxs(h.SheetTitle,{className:"flex items-center gap-2 text-sm font-semibold",children:[o.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:o.jsx(x.Folder,{className:"h-4 w-4"})}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-semibold",children:t("Pages")}),o.jsx("span",{id:"pages-manager-description",className:"text-xs font-normal text-muted-foreground",children:t("Manage your site structure")})]})]}),o.jsx(h.SheetDescription,{className:"sr-only",children:t("Manage your site structure")})]}),o.jsx("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:C&&o.jsx(g.Suspense,{children:o.jsx(Br,{close:()=>d(!1)})})})]})})]})},Fr=g.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-soZ8GAkN.cjs"))),qr=g.lazy(()=>Promise.resolve().then(()=>require("./delete-page-DxX7PFIE.cjs"))),Kr=g.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-CaNAbXwV.cjs"))),Vr=g.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-W3LmpiqN.cjs"))),Hr=g.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-EVvk0vmp.cjs"))),Qr=g.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-bdSmwAVQ.cjs"))),zr=()=>{const[e,t]=g.useState(null),[s,n]=g.useState(null),[r,a]=g.useState(null),[i,l]=g.useState(null),[c,f]=g.useState(null),[d,u]=g.useState(null),{data:E,isFetching:m}=he(),{selectedLang:T,fallbackLang:_}=h.useLanguages(),{data:w}=Te(),R=w==null?void 0:w.find(j=>j.lang===T),{isLocked:A}=se(),C=!(E!=null&&E.slug),I=V.useSetAtom(tt);if(!E)return null;const F=j=>{T.length>0&&T!==_?I({edit:!0,id:j==null?void 0:j.id,primaryPage:j==null?void 0:j.primaryPage}):u(j)};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between rounded px-[2px] transition-colors duration-200",children:[o.jsx(Zs,{children:o.jsx(h.Button,{className:"flex h-7 max-w-[200px] cursor-pointer items-center truncate rounded px-1 text-xs font-medium",variant:"ghost",children:m?o.jsx(x.Loader,{className:"h-4 w-4 animate-spin text-slate-400"}):o.jsxs("span",{className:"flex w-full cursor-pointer items-end overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-xs font-medium",children:[C?o.jsx(x.Hash,{className:"mr-1 h-4 w-4"}):o.jsx(x.File,{className:"mr-1 h-4 w-4"}),p.get(R||E,"name")??""]})})}),A?o.jsx(h.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 cursor-not-allowed rounded opacity-50 hover:bg-transparent",children:o.jsx(x.MoreHorizontal,{className:"h-4 w-4"})}):o.jsx($s,{page:E,setDuplicatePage:j=>f(j),setAddEditPage:j=>F(j),setUnpublishPage:j=>n(j),setDeletePage:j=>t(j),setMarkAsTemplate:j=>a(j),setUnmarkAsTemplate:j=>l(j),isLanguagePage:T.length>0&&T!==_,children:o.jsx(h.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:o.jsx(x.MoreHorizontal,{className:"h-4 w-4"})})})]}),d&&o.jsx(g.Suspense,{children:o.jsx(Fr,{closePanel:()=>u(null),editPage:()=>{},addEditPage:d,setAddEditPage:u})}),e&&o.jsx(g.Suspense,{children:o.jsx(qr,{page:e,onClose:()=>t(null)})}),s&&o.jsx(g.Suspense,{children:o.jsx(Qr,{page:s,onClose:()=>n(null)})}),r&&o.jsx(g.Suspense,{children:o.jsx(Vr,{page:r,onClose:()=>a(null)})}),i&&o.jsx(g.Suspense,{children:o.jsx(Hr,{page:i,onClose:()=>l(null)})}),c&&o.jsx(g.Suspense,{children:o.jsx(Kr,{page:c,onClose:()=>f(null),closePanel:()=>u(null)})})]})},gs=({children:e,className:t=""})=>o.jsx("div",{className:Nt.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}),$r=({hasDynamicPage:e})=>o.jsx(gs,{children:o.jsxs("div",{className:"flex min-w-[300px] max-w-[400px] flex-col items-center justify-center rounded-lg border bg-white p-4 shadow-lg",children:[o.jsx("h1",{className:"text-lg font-medium",children:e?"Select a page":"No pages found"}),o.jsx("p",{className:"pt-2 text-center text-sm font-light text-gray-600",children:e?"Please select a page from the list in the top header. This will enable you to edit the page.":"Please add a new page"})]})}),We={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"},Wr=g.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-88xzrUy8.cjs"))),Yr=()=>{const e=ae("topLeftCorner",null);return e?o.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:g.createElement(e,{})}):null},Xs=({showAdd:e=!0,variant:t="ghost",goToDefaultLang:s=!1})=>{const{fallbackLang:n,languages:r,selectedLang:a,setSelectedLang:i}=h.useLanguages(),l=p.isEmpty(a)?n:a,[,c]=ie(),{isLocked:f}=se(),{t:d}=fe.useTranslation();g.useEffect(()=>{const A=new URLSearchParams(window.location.search),C=A.get("lang");C&&(r.includes(C)?i(C):(A.delete("lang"),c(A),i("")))},[r,c,i]);const u=V.useSetAtom(tt),{data:E}=ee(),{data:m}=Ae(),{data:T}=Te(),_=g.useMemo(()=>{const A=p.compact(p.map(p.get(m,"languages"),C=>{const I=p.find(T,{lang:C});return{key:C,value:p.get(We,C,C),isLangPageAdded:!!I}})).filter(Boolean);return[{key:n,value:p.get(We,n),isLangPageAdded:!0},...A]},[n,T,m]),w=A=>{if(document.querySelector('[data-panel-id="seo"]')){const I=new CustomEvent("seo-language-switch-check",{detail:{fromLang:l,toLang:A,switchHandler:()=>R(A)}});window.dispatchEvent(I);return}R(A)},R=A=>{i(A);const C=new URLSearchParams(window.location.search);A===n?C.delete("lang"):C.set("lang",A),hs(C,c)};return p.isEmpty(r)?null:f?o.jsxs(h.Button,{variant:"ghost",size:"sm",className:"ml-px h-max cursor-not-allowed gap-2 py-1.5 opacity-50",children:[o.jsx(x.Languages,{className:"h-4 w-4"}),p.get(We,l,l),o.jsx(x.ChevronDown,{className:"h-4 w-4"})]}):s?o.jsx(h.Button,{onClick:()=>R(n),variant:"link",size:"sm",children:d("Switch to default language")}):o.jsx(o.Fragment,{children:o.jsxs(h.DropdownMenu,{children:[o.jsx(h.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:o.jsxs(h.Button,{disabled:!!f,variant:t,size:"sm",className:"ml-px h-max gap-2 py-1.5",children:[o.jsx(x.Languages,{className:"h-4 w-4"}),p.get(We,l,l),o.jsx(x.ChevronDown,{className:"h-4 w-4"})]})}),o.jsxs(h.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(_.filter(A=>A.isLangPageAdded),A=>o.jsxs(h.DropdownMenuItem,{className:Nt.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:()=>w(A.key),children:[o.jsx("div",{className:"text-slate-600",children:A.value}),A.key===n&&o.jsxs("small",{className:"flex items-center gap-x-1 text-[9px] leading-none text-orange-500",children:[o.jsx(x.Star,{fill:"orange",className:"h-2 w-2"}),"Primary"]})]},A.value)),e&&!p.isEmpty(_.filter(A=>!A.isLangPageAdded))&&o.jsxs(o.Fragment,{children:[o.jsx(h.Separator,{}),o.jsxs(h.Button,{size:"sm",variant:"ghost",onClick:()=>{E&&u({edit:!1,primaryPage:E.id})},className:"text-xs font-normal duration-200 hover:bg-slate-300 hover:text-slate-800",children:[o.jsx(x.Plus,{className:"mr-1 h-3 w-3"})," Add Language"]})]})]})]})})};function Jr(){const e=V.useAtomValue(tt),t=V.useSetAtom(tt);return o.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[o.jsx(Yr,{}),o.jsx(Zs,{}),e&&o.jsx(g.Suspense,{children:o.jsx(Wr,{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 Zr(){return o.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((e,t)=>o.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[o.jsxs("div",{className:"flex-1 space-y-1",children:[o.jsx(h.Skeleton,{className:"h-4 w-3/4"}),o.jsx(h.Skeleton,{className:"h-3 w-1/2"}),o.jsx(h.Skeleton,{className:"mt-1 h-5 w-20"})]}),o.jsx(h.Skeleton,{className:"h-8 w-8 rounded-full"})]},t))})}const Xr=H.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-ChY-4f2V.cjs")));function ea(){const[e,t]=H.useState(!1);return o.jsx(h.TooltipProvider,{children:o.jsxs(h.Tooltip,{delayDuration:0,children:[o.jsxs(h.Sheet,{open:e,onOpenChange:t,children:[o.jsx(h.SheetTrigger,{asChild:!0,children:o.jsx(h.TooltipTrigger,{asChild:!0,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsxs(h.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[o.jsx(x.History,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"View revision history"})]}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})})}),o.jsx(h.SheetContent,{className:"flex h-[100vh] flex-col",children:e&&o.jsx(g.Suspense,{fallback:o.jsx(Zr,{}),children:o.jsx(Xr,{isOpen:e})})})]}),o.jsx(h.TooltipContent,{side:"bottom",children:o.jsx("p",{children:"Revision history"})})]})})}const bt=({permission:e,permissions:t,children:s,fallback:n=null})=>{const{hasPermission:r}=h.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?n:s},ta={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},sa=()=>{const e=L(),t=S.useQueryClient(),s=N(),{data:n}=ge();return S.useMutation({mutationFn:async r=>await s(e,{action:y.CREATE_PAGE,data:r}),onSuccess:(r,a)=>{var l;a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES,a==null?void 0:a.lang]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const i=a.template?`Page created from "${a.template.name}" template`:a.hasSlug===!1?"New "+((l=p.find(n,{key:a.pageType}))==null?void 0:l.name)+" added successfully":"New page added successfully";B.toast.success(i)},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});B.toast.error(`Failed to add new ${i!=null&&i.hasSlug?"page":i.name}.`,{description:p.get(ta,r.message,r.message)})}})},na=()=>{const e=L(),t=S.useQueryClient(),s=N(),{data:n}=he(),{data:r}=ge();return S.useMutation({mutationFn:async a=>await s(e,{action:y.UPDATE_PAGE,data:a}),onSuccess:(a,i)=>{(n==null?void 0:n.id)===(i==null?void 0:i.id)&&t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]}),i&&(i!=null&&i.primaryPage||i!=null&&i.seo)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(a,i)=>{const l=p.find(r,{key:i.pageType});B.toast.error(`Failed to update ${l!=null&&l.hasSlug?"page":l.name}.`,{description:a.message})}})},ra=()=>{const e=L(),t=S.useQueryClient(),s=N(),{data:n}=ge();return S.useMutation({mutationFn:async r=>s(e,{action:y.DELETE_PAGE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{if(r.code==="PAGE_LOCKED"){B.toast.error("Delete not allowed",{description:"Page is currently being edited by another user."});return}a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});B.toast.error(`Failed to delete ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},aa=()=>{const e=L(),t=S.useQueryClient(),s=N(),{data:n}=ge();return S.useMutation({mutationFn:async r=>s(e,{action:y.TAKE_OFFLINE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const i=p.find(n,{key:a.pageType});B.toast.success(i!=null&&i.hasSlug?"Page unpublished successfully.":"New "+i.name+" added successfully.")},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});B.toast.error(`Failed to take offline ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},ms=()=>{const e=L(),t=N(),s=S.useQueryClient(),{data:n}=ee(),{savePageAsync:r}=h.useSavePage();return S.useMutation({mutationFn:async({ids:a})=>(await r(),t(e,{action:y.PUBLISH_CHANGES,data:{ids:a}})),onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_CHANGES]}),s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,n==null?void 0:n.id]})},onError:a=>{console.log("##",a),B.toast.error("Failed to publish pages.")}})},oa=()=>{const e=L(),t=N(),s=S.useQueryClient();return S.useMutation({mutationFn:async n=>{var r;return t(e,{action:y.MARK_AS_TEMPLATE,data:{id:(r=n.page)==null?void 0:r.id,name:n.name,description:n.description,pageType:n.pageType,previewImage:n.previewImage}})},onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),B.toast.success("Page marked as template successfully.")},onError:()=>{B.toast.error("Failed to mark page as template.")}})},ia=()=>{const e=L(),t=N(),s=S.useQueryClient();return S.useMutation({mutationFn:async n=>t(e,{action:y.UNMARK_AS_TEMPLATE,data:{id:n==null?void 0:n.id}}),onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),B.toast.success("Page unmarked as template successfully.")},onError:()=>{B.toast.error("Failed to unmark page as template.")}})},la=()=>{const e=L(),t=N(),s=S.useQueryClient();return S.useMutation({mutationFn:async({id:n,slug:r})=>t(e,{action:y.CHANGE_SLUG,data:{id:n,slug:r}}),onSuccess:(n,{primaryPage:r})=>{B.toast.success("Slug changed successfully."),r?s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,r]}):s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:()=>{B.toast.error("Failed to change slug")}})},ca=g.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-x-JuSFJ9.cjs")));function ua({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:s,isPending:n}=ms();return o.jsx(h.Dialog,{open:e,onOpenChange:n?()=>{}:t,children:e&&o.jsx(g.Suspense,{fallback:o.jsx("div",{className:"h-96 w-96 animate-pulse bg-gray-100"}),children:o.jsx(ca,{onClose:t,isPending:n,publishPage:s})})})}const en=e=>{const{fallbackLang:t}=h.useLanguages(),{data:s}=Ae(),{data:n,isFetching:r}=Te(),a=g.useMemo(()=>{const i={[t]:!0};return p.each(p.get(s,"languages"),l=>{const c=p.find(n,{lang:l});i[l]=!!c}),i},[t,n,s]);return r||p.isEmpty(e)||e&&a[e]},da={particleCount:350,spread:120,origin:{y:.6},angle:90},fa={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},ha=async()=>{const{default:e}=await import("canvas-confetti");return e},Ct=e=>{let t=fa[e];t||(t={});const s={...da,...t};ha().then(n=>n(s))};function Kt({children:e,content:t,side:s="bottom",delayDuration:n=700,showTooltip:r=!0}){return r?o.jsx(h.TooltipProvider,{children:o.jsxs(h.Tooltip,{delayDuration:n,children:[o.jsx(h.TooltipTrigger,{asChild:!0,children:e}),o.jsx(h.TooltipContent,{side:s,sideOffset:10,children:o.jsx("p",{children:t})})]})}):e}const ga=g.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-bdSmwAVQ.cjs"))),ma=g.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-BZAcwM2_.cjs"))),Ea=()=>{const{t:e}=fe.useTranslation(),{selectedLang:t,fallbackLang:s}=h.useLanguages(),n=ae("getPreviewUrl",async E=>E),[r,a]=g.useState(""),{data:i}=ee(),{data:l}=Te(),{data:c}=ge(),f=g.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]),d=g.useCallback(E=>{var m;return(m=p.find(c,{key:E}))==null?void 0:m.hasSlug},[c]),u=t===s?"":t;return g.useEffect(()=>{(async()=>{if(typeof n=="function"){const E=!d(i==null?void 0:i.pageType),m=await n(E?`${u!==""?u+"/":""}${i==null?void 0:i.id}`:f||"");a(m)}else a("")})()},[n,f,i==null?void 0:i.pageType,d,i==null?void 0:i.id,u]),o.jsx(o.Fragment,{children:o.jsx(Kt,{content:e("Open preview in new tab"),delayDuration:0,children:o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:o.jsx(h.Button,{variant:"ghost",size:"sm",className:"gap-2",children:o.jsx(x.Play,{className:"h-4 w-4"})})})})})},pa=()=>{const{t:e}=fe.useTranslation(),[t,s]=h.useRightPanel();return o.jsxs(o.Fragment,{children:[o.jsx(Kt,{content:e("Theme"),delayDuration:0,children:o.jsx(h.Button,{variant:t==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>s(t==="theme"?"block":"theme"),children:o.jsx(x.Palette,{className:"h-4 w-4"})})}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})},ya=()=>{const{t:e}=fe.useTranslation(),[t,s]=g.useState(!1),{isLocked:n}=se(),{savePageAsync:r,saveState:a}=h.useSavePage();g.useEffect(()=>{const d=u=>{a==="UNSAVED"&&(u.preventDefault(),u.returnValue=!1)};return a==="UNSAVED"&&window.addEventListener("beforeunload",d),()=>{window.removeEventListener("beforeunload",d)}},[a]);const i=g.useCallback(async()=>{t||(s(!0),await r(),s(!1))},[r,t]),{buttonIcon:l,buttonClass:c,tooltipContent:f}=g.useMemo(()=>{switch(a){case"UNSAVED":return{tooltipContent:e("Save draft"),buttonIcon:o.jsx(x.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:e("Saving"),buttonIcon:o.jsx(x.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:e("Saved"),buttonIcon:o.jsx(x.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[a,e]);return n?null:o.jsxs(h.Button,{size:"sm",variant:"ghost",onClick:i,className:`${c} w-24 max-w-24`,children:[l," ",f]})},Ta=()=>{const{t:e}=fe.useTranslation(),{selectedLang:t}=h.useLanguages(),{data:s}=he(),{data:n}=Te(),[r,a]=g.useState(!1),[i,l]=g.useState(!1),[c,f]=g.useState(null),{savePageAsync:d}=h.useSavePage(),[u,E]=g.useState(!1),{data:m}=ee(),{mutate:T,isPending:_}=ms(),{needTranslations:w}=h.useSavePage(),R=w(),{buttonText:A,buttonClassName:C,isPublished:I}=g.useMemo(()=>{const b=m&&(m==null?void 0:m.online);return{buttonClassName:b?"hover:bg-green-600 bg-green-500":"",isPublished:b,buttonText:e(b?"Published":"Publish")}},[m,e]),F=async()=>{if(R){E(!0);return}j()},j=()=>{const b=[s==null?void 0:s.id,s==null?void 0:s.primaryPage];T({ids:p.compact(b)},{onSuccess:()=>Ct("TOP_RIGHT")})},le=()=>{E(!1),j()},ce=async()=>{E(!1),await d()},K=g.useMemo(()=>p.map(n??[],"id"),[n]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex",children:[o.jsxs(h.Button,{size:"sm",onClick:F,disabled:_||!(m!=null&&m.id),className:`relative flex items-center gap-1 overflow-hidden rounded-r-none text-white transition-all duration-300 ease-in-out ${C}`,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[o.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${i?"-translate-y-10":""}`,children:I?o.jsx(x.Send,{className:"h-4 w-4"}):o.jsx(x.Rocket,{className:"h-4 w-4"})}),o.jsx("span",{className:`absolute inset-0 left-3 flex items-center transition-transform duration-300 ease-in-out ${i?"":"translate-y-10"}`,children:I?o.jsx(x.Rocket,{className:"h-4 w-4"}):o.jsx(x.Send,{className:"h-4 w-4"})}),o.jsx("span",{children:A}),t?`(${p.upperCase(t)})`:""]}),o.jsxs(h.DropdownMenu,{children:[o.jsx(h.DropdownMenuTrigger,{asChild:!0,children:o.jsx(h.Button,{size:"sm",disabled:_||!(m!=null&&m.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${C}`,children:o.jsx(x.ChevronDown,{className:"h-4 w-4"})})}),o.jsxs(h.DropdownMenuContent,{align:"end",className:"w-52",children:[o.jsxs(h.DropdownMenuItem,{disabled:_,className:"cursor-pointer text-xs",onClick:()=>T({ids:K},{onSuccess:()=>Ct("TOP_RIGHT")}),children:[e("Publish")," with translation pages"]}),!I&&o.jsxs(h.DropdownMenuItem,{disabled:_,className:"cursor-pointer text-xs",onClick:()=>T({ids:[m==null?void 0:m.id]},{onSuccess:()=>Ct("TOP_RIGHT")}),children:[e("Publish")," page"]}),o.jsxs(h.DropdownMenuItem,{onClick:()=>a(!0),className:"cursor-pointer text-xs",children:[e("Open")," publish menu"]}),I&&o.jsxs(h.DropdownMenuItem,{onClick:()=>f(s),className:"cursor-pointer text-xs",children:[e("Unpublish")," page ",t?`(${p.upperCase(t)})`:""]})]})]})]}),o.jsx(ua,{showModal:r,onClose:()=>a(!1)}),c&&o.jsx(g.Suspense,{children:o.jsx(ga,{page:c,onClose:()=>f(null)})}),u&&o.jsx(g.Suspense,{children:o.jsx(ma,{isOpen:u,onClose:ce,onContinue:le,isPending:_})})]})};function Aa(){const{isLocked:e}=se(),[t]=ie(),s=t.get("lang"),n=en(s);return e||!n?o.jsx("div",{}):o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[o.jsx(ea,{}),o.jsx(bt,{permission:te.EDIT_THEME,children:o.jsx(pa,{})}),o.jsx(Ea,{}),o.jsx(bt,{permission:te.SAVE_PAGE,children:o.jsx(ya,{})}),o.jsx(bt,{permission:te.PUBLISH_PAGE,children:o.jsx(Ta,{})})]})}const Sa=g.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-Cxk_gjni.cjs"))),Pa=()=>{const{dynamicPage:e,allLangPages:t,isFetching:s}=Qs(),n=t.length>0;return s?null:o.jsxs("div",{className:"relative",children:[!e&&o.jsx($r,{hasDynamicPage:n}),o.jsx(g.Suspense,{children:o.jsx(Sa,{})})]})},xa=()=>{const{data:e,isFetching:t}=he(),{data:s,isFetching:n}=ee(),r=p.get(s,"dynamic",!1),a=is(),i=h.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,f=vr(),d=t||n,E=(c?`Partial: ${e==null?void 0:e.name} `:`${l}${a}`).replace(window.location.host,"");return o.jsxs("div",{className:"relative flex items-center gap-x-1",children:[o.jsx("div",{className:Nt.cn("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800",d&&"max-w-0 overflow-hidden opacity-0"),children:o.jsx(zr,{})}),o.jsxs("div",{className:Nt.cn("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800"+(c?" pr-2":""),d&&"max-w-0 overflow-hidden opacity-0"),children:[o.jsx(Xs,{}),o.jsxs("div",{className:"flex w-full items-center overflow-hidden",children:[o.jsx("div",{className:`w-full max-w-[200px] overflow-hidden overflow-ellipsis whitespace-nowrap pl-1 text-xs ${c?"italic text-gray-400":"font-mono text-gray-500"}`,children:E==="/"?o.jsxs("span",{className:"text-gray-900",children:["/",o.jsx("span",{className:"text-[11px] font-light italic text-gray-400",children:"(Homepage)"})]}):E}),!c&&o.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",children:o.jsx("div",{className:"ml-2 mr-px flex-shrink-0 rounded-sm p-1.5 text-gray-500 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300",children:o.jsx(x.ExternalLink,{className:"h-4 w-4",strokeWidth:1})})})]})]}),r&&i&&o.jsx(Pa,{})]})},_a=()=>o.jsxs("div",{className:"flex h-full w-full items-center justify-between px-2",children:[o.jsx(Jr,{}),o.jsx(xa,{}),o.jsx(Aa,{})]}),tn=()=>{const e=S.useQueryClient(),{data:t}=S.useQuery({queryKey:[y.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:g.useCallback(n=>{e.setQueryData([y.AI_CONTEXT],n)},[e]),aiContext:t}},wa=()=>{const e=L(),{aiContext:t}=tn(),s=N();return g.useCallback(async(n,r,a,i)=>s(e,{action:y.ASK_AI,data:{type:n,prompt:r,blocks:a,context:t,lang:i}}),[e,t,s])},va=(e,t)=>t.map(s=>{if(p.has(e,s._type)){const n=Ks.getDefaultBlockProps(s._type);return{...n,...p.pick(s,[...p.keys(n),"_type","_id","_name","_parent","_bindings"]),...p.pickBy(s,(r,a)=>p.endsWith(a,"_attrs")),...s}}return s}),ba=e=>{const t=Ks.useRegisteredChaiBlocks();return g.useMemo(()=>{if(!e||p.isEmpty(e))return{blocks:[]};const s=p.filter(e,n=>!p.includes(n==null?void 0:n._type,"@chai/"));return{blocks:va(t,s)}},[e,t])},Ca=()=>{const[e]=ie(),t=e.get("page"),s=L(),{setAiContext:n}=tn(),[,r]=ls(),[,a]=wr(),[,i]=h.useIsPageLoaded(),l=N();return S.useQuery({queryKey:[y.GET_DRAFT_PAGE,t],staleTime:1/0,gcTime:0,queryFn:async()=>{i(!1);const c=await l(s,{action:y.GET_DRAFT_PAGE,data:{id:t,draft:!0}}),f=c.blocks??[],d=p.find(f,{_type:"@chai/ai-context"});return n(p.get(d,"_value","")||""),r(u=>({...u,lastSaved:c.lastSaved})),a(p.get(c,"metadata",{})),setTimeout(()=>i(!0),500),f},enabled:!!t})},sn=()=>{const{data:e}=ee(),{data:t}=he(),s=L(),n=N(),r=qt(),a=is();return S.useQuery({queryKey:[y.GET_BUILDER_PAGE_DATA,t==null?void 0:t.id,a],staleTime:1/0,gcTime:0,queryFn:async()=>n(s,{action:y.GET_BUILDER_PAGE_DATA,data:{pageType:e==null?void 0:e.pageType,lang:(t==null?void 0:t.lang)||r,dynamic:e==null?void 0:e.dynamic,pageProps:{slug:(t==null?void 0:t.slug)+a,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:r,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id,metadata:e.metadata||{}}}}),enabled:!!(e!=null&&e.pageType)&&!!t.id})},nn=()=>{const e=L(),t=S.useQueryClient(),s=N();return S.useMutation({mutationFn:async n=>s(e,{action:y.UPDATE_WEBSITE_SETTINGS,data:n}),onSuccess:(n,r)=>{var a;t.invalidateQueries({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS]}),(a=r==null?void 0:r.settings)!=null&&a.theme||B.toast.success("Website settings updated successfully.")},onError:n=>{B.toast.error("Failed to update website settings",{description:n.message})}})},Ia=()=>{const e=L(),t=S.useQueryClient(),s=N(),{selectedLang:n}=h.useLanguages();return S.useMutation({mutationFn:async r=>s(e,{action:y.ADD_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),B.toast.success("Schema added successfully.")},onError:r=>{B.toast.error("Failed to add schema",{description:r.message})}})},La=()=>{const e=L(),t=S.useQueryClient(),s=N(),{selectedLang:n}=h.useLanguages();return S.useMutation({mutationFn:async r=>s(e,{action:y.UPDATE_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),B.toast.success("Schema updated successfully.")},onError:r=>{B.toast.error("Failed to update schema",{description:r.message})}})},Na=()=>{const e=L(),t=S.useQueryClient(),s=N();return S.useMutation({mutationFn:async n=>s(e,{action:y.DELETE_GLOBAL_SCHEMA,data:{id:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),B.toast.success("Schema deleted successfully.")},onError:n=>{B.toast.error("Failed to delete schema",{description:n.message})}})},ja=()=>{const e=L(),t=N();return S.useMutation({mutationFn:async s=>t(e,{action:y.TOGGLE_PAGE_GLOBAL_SCHEMA,data:s}),onError:s=>{B.toast.error("Failed to toggle schema",{description:s.message})}})},Ga=()=>{const e=L(),t=N();return S.useMutation({mutationFn:async s=>t(e,{action:y.APPLY_SCHEMA_TO_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{B.toast.success(`Schema applied to ${s.count} page(s)`)},onError:s=>{B.toast.error("Failed to apply schema to all pages",{description:s.message})}})},ka=()=>{const e=L(),t=N();return S.useMutation({mutationFn:async s=>t(e,{action:y.REMOVE_SCHEMA_FROM_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{B.toast.success(`Schema removed from ${s.count} page(s)`)},onError:s=>{B.toast.error("Failed to remove schema from all pages",{description:s.message})}})},Is={async getUILibraryBlock(e,t,s){const n=await t(s,{action:"GET_LIBRARY_ITEM",data:{id:e.id}}),r=p.get(n,"html",""),a=p.get(n,"blocks",[]);return p.isArray(a)?a:hr.getBlocksFromHTML(r)},async getUILibraryBlocks(e,t,s){try{return(await t(s,{action:"GET_LIBRARY_ITEMS",data:{id:e.id}})).map(r=>({...r}))}catch(n){return console.error(n),[]}}},Da=()=>{const e=L(),t=N();return S.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const n=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return n.forEach(r=>{h.registerChaiLibrary(r.id,{name:r.isSiteLibrary?r.name+" (Current Site) ":r.name,description:r.description,getBlocksList:a=>Is.getUILibraryBlocks(a,t,e),getBlock:({block:a})=>Is.getUILibraryBlock(a,t,e)})}),n}})},rn=()=>{const e=L(),t=N(),{user:s}=Ft(),n=s==null?void 0:s.id;return S.useQuery({queryKey:[y.GET_ROLE_AND_PERMISSIONS,n],queryFn:()=>t(e,{action:y.GET_ROLE_AND_PERMISSIONS,data:{}}),enabled:!!n,staleTime:1/0})},Oa=()=>{const e=L(),t=N(),[,s]=ls();return{onSave:async({page:r,blocks:a,needTranslations:i})=>{try{const l=await t(e,{action:"UPDATE_PAGE",data:{id:r,blocks:a,needTranslations:i}});return l.code==="PAGE_LOCKED"?!0:(s(c=>({...c,lastSaved:new Date().toISOString()})),l)}catch(l){return console.error(l),new Error("Failed to save blocks")}}}},Ra=()=>{const{data:e}=fs(),t=L(),s=N();return{getPartialBlocks:g.useCallback(async()=>{const n={};for(const r of e??[])p.isEmpty(r==null?void 0:r.slug)&&(n[r.id]={type:r.pageType,name:p.startCase(r.name??r.slug),description:""});return n},[e]),getPartialBlockBlocks:g.useCallback(async n=>{if(!n)return[];try{const r=await s(t,{action:"GET_DRAFT_PAGE",data:{id:n,draft:!0,editor:!1}});return p.filter(r.blocks,a=>p.has(a,"_id"))}catch(r){return console.error(r),[]}},[s,t])}},Ma=g.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-content-7zCil042.cjs"))),an="chai-chat-panel",Ua=({className:e="h-full w-full"})=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",version:"1.1",className:e,children:[o.jsx("title",{children:"ai"}),o.jsx("g",{id:"Page-1",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:o.jsx("g",{id:"icon",fill:"currentColor",transform:"translate(64.000000, 64.000000)",children:o.jsx("path",{d:"M320,64 L320,320 L64,320 L64,64 L320,64 Z M171.749388,128 L146.817842,128 L99.4840387,256 L121.976629,256 L130.913039,230.977 L187.575039,230.977 L196.319607,256 L220.167172,256 L171.749388,128 Z M260.093778,128 L237.691519,128 L237.691519,256 L260.093778,256 L260.093778,128 Z M159.094727,149.47526 L181.409039,213.333 L137.135039,213.333 L159.094727,149.47526 Z M341.333333,256 L384,256 L384,298.666667 L341.333333,298.666667 L341.333333,256 Z M85.3333333,341.333333 L128,341.333333 L128,384 L85.3333333,384 L85.3333333,341.333333 Z M170.666667,341.333333 L213.333333,341.333333 L213.333333,384 L170.666667,384 L170.666667,341.333333 Z M85.3333333,0 L128,0 L128,42.6666667 L85.3333333,42.6666667 L85.3333333,0 Z M256,341.333333 L298.666667,341.333333 L298.666667,384 L256,384 L256,341.333333 Z M170.666667,0 L213.333333,0 L213.333333,42.6666667 L170.666667,42.6666667 L170.666667,0 Z M256,0 L298.666667,0 L298.666667,42.6666667 L256,42.6666667 L256,0 Z M341.333333,170.666667 L384,170.666667 L384,213.333333 L341.333333,213.333333 L341.333333,170.666667 Z M0,256 L42.6666667,256 L42.6666667,298.666667 L0,298.666667 L0,256 Z M341.333333,85.3333333 L384,85.3333333 L384,128 L341.333333,128 L341.333333,85.3333333 Z M0,170.666667 L42.6666667,170.666667 L42.6666667,213.333333 L0,213.333333 L0,170.666667 Z M0,85.3333333 L42.6666667,85.3333333 L42.6666667,128 L0,128 L0,85.3333333 Z",id:"Combined-Shape"})})})]}),Ba=({isActive:e,show:t})=>o.jsx(h.Button,{size:"icon",className:"p-0 [&_svg]:size-6",onClick:t,variant:e?"default":"ghost",children:o.jsx(Ua,{className:e?"h-5 w-5 text-white":"h-5 w-5 text-primary"})}),Fa={id:an,label:"AI Assistant",button:Ba,panel:Ma,position:"top"},qa=g.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-DT96k1xg.cjs"))),Ka=({isActive:e,show:t})=>{const{data:s}=Ae();return!p.has(s,"languages")||!p.get(s,"languages",[]).length?null:o.jsx(h.Button,{size:"sm",onClick:t,variant:e?"default":"ghost",children:o.jsx(x.LanguagesIcon,{className:"h-4 w-4"})})},on="lang",Va={id:on,label:"Languages",position:"top",panel:qa,button:Ka,view:"modal",width:400},Ha=g.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-DfAb8U7W.cjs"))),ln="seo",Qa=({isActive:e,show:t})=>{const{data:s}=ee(),n=zs(s==null?void 0:s.pageType);return!p.has(n,"hasSlug")||!n.hasSlug?null:o.jsx(h.Button,{size:"icon",className:"my-1 p-0",onClick:t,variant:e?"default":"ghost",children:o.jsxs("svg",{stroke:"currentColor",fill:"none",style:{height:"20px",width:"20px"},strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M7 8h-3a1 1 0 0 0 -1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-3"}),o.jsx("path",{d:"M14 16h-4v-8h4"}),o.jsx("path",{d:"M11 12h2"}),o.jsx("path",{d:"M17 8m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]})})},za={id:ln,label:"SEO",panel:Ha,button:Qa,position:"top",width:600,view:"modal"},cn="user-info",$a=()=>{const{t:e}=fe.useTranslation(),{user:t,logout:s}=Ft(),n=ae("onLogout",p.noop);return t?o.jsxs(h.HoverCard,{children:[o.jsx(h.HoverCardTrigger,{asChild:!0,children:o.jsx(h.Button,{variant:"ghost",className:"text-sm font-medium",children:o.jsx(x.User,{className:"h-4 w-4"})})}),o.jsxs(h.HoverCardContent,{className:"w-auto space-y-2 p-4",children:[o.jsx("div",{className:"text-sm font-medium",children:t.name??t.email}),o.jsx("div",{className:"text-xs text-muted-foreground",children:t.email}),o.jsxs(h.AlertDialog,{children:[o.jsx(h.AlertDialogTrigger,{asChild:!0,children:o.jsx(h.Button,{variant:"outline",size:"sm",className:"w-full",children:e("Logout")})}),o.jsxs(h.AlertDialogContent,{children:[o.jsxs(h.AlertDialogHeader,{children:[o.jsx(h.AlertDialogTitle,{children:e("Are you sure you want to logout?")}),o.jsx(h.AlertDialogDescription,{children:e("You will be redirected to the login page.")})]}),o.jsxs(h.AlertDialogFooter,{children:[o.jsx(h.AlertDialogCancel,{children:e("Cancel")}),o.jsx(h.AlertDialogAction,{onClick:()=>{s(),p.isFunction(n)&&n()},children:e("Logout")})]})]})]})]})]}):null},Wa={id:cn,label:"User Info",button:$a,position:"bottom"},Ya=()=>{h.registerChaiSidebarPanel(ln,za),h.registerChaiSidebarPanel(on,Va),h.registerChaiSidebarPanel(cn,Wa),h.registerChaiSidebarPanel(an,Fa)};var v={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return Ls(this.context.count)},getNextContextId(){return Ls(this.context.count++)}};function Ls(e){const t=String(e),s=t.length-1;return v.context.id+(s?String.fromCharCode(96+s):"")+t}function Ye(e){v.context=e}var un=!1,Ja=(e,t)=>e===t,jt=Symbol("solid-proxy"),dn=typeof Proxy=="function",Es=Symbol("solid-track"),Gt={equals:Ja},fn=An,me=1,kt=2,hn={owned:null,cleanups:null,context:null,owner:null},$t={},D=null,Wt=null,Za=null,M=null,J=null,de=null,Vt=0;function Ee(e,t){const s=M,n=D,r=e.length===0,a=t===void 0?n:t,i=r?hn:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>W(()=>st(i)));D=i,M=null;try{return oe(l,!0)}finally{M=s,D=n}}function q(e,t){t=t?Object.assign({},Gt,t):Gt;const s={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},n=r=>(typeof r=="function"&&(r=r(s.value)),Tn(s,r));return[yn.bind(s),n]}function gn(e,t,s){const n=Ht(e,t,!0,me);$e(n)}function pe(e,t,s){const n=Ht(e,t,!1,me);$e(n)}function ps(e,t,s){fn=fo;const n=Ht(e,t,!1,me);(!s||!s.render)&&(n.user=!0),de?de.push(n):$e(n)}function z(e,t,s){s=s?Object.assign({},Gt,s):Gt;const n=Ht(e,t,!0,0);return n.observers=null,n.observerSlots=null,n.comparator=s.equals||void 0,$e(n),yn.bind(n)}function Xa(e){return e&&typeof e=="object"&&"then"in e}function eo(e,t,s){let n,r,a;n=!0,r=e,a={};let i=null,l=$t,c=null,f=!1,d="initialValue"in a,u=typeof n=="function"&&z(n);const E=new Set,[m,T]=(a.storage||q)(a.initialValue),[_,w]=q(void 0),[R,A]=q(void 0,{equals:!1}),[C,I]=q(d?"ready":"unresolved");v.context&&(c=v.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:v.load&&v.has(c)&&(l=v.load(c)));function F(b,G,$,Q){return i===b&&(i=null,Q!==void 0&&(d=!0),(b===l||G===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(Q,{value:G})),l=$t,j(G,$)),G}function j(b,G){oe(()=>{G===void 0&&T(()=>b),I(G!==void 0?"errored":d?"ready":"unresolved"),w(G);for(const $ of E.keys())$.decrement();E.clear()},!1)}function le(){const b=lo,G=m(),$=_();if($!==void 0&&!i)throw $;return M&&M.user,G}function ce(b=!0){if(b!==!1&&f)return;f=!1;const G=u?u():n;if(G==null||G===!1){F(i,W(m));return}let $;const Q=l!==$t?l:W(()=>{try{return r(G,{value:m(),refetching:b})}catch(ne){$=ne}});if($!==void 0){F(i,void 0,It($),G);return}else if(!Xa(Q))return F(i,Q,void 0,G),Q;return i=Q,"v"in Q?(Q.s===1?F(i,Q.v,void 0,G):F(i,void 0,It(Q.v),G),Q):(f=!0,queueMicrotask(()=>f=!1),oe(()=>{I(d?"refreshing":"pending"),A()},!1),Q.then(ne=>F(Q,ne,void 0,G),ne=>F(Q,void 0,It(ne),G)))}Object.defineProperties(le,{state:{get:()=>C()},error:{get:()=>_()},loading:{get(){const b=C();return b==="pending"||b==="refreshing"}},latest:{get(){if(!d)return le();const b=_();if(b&&!i)throw b;return m()}}});let K=D;return u?gn(()=>(K=D,ce(!1))):ce(!1),[le,{refetch:b=>En(K,()=>ce(b)),mutate:T}]}function to(e){return oe(e,!1)}function W(e){if(M===null)return e();const t=M;M=null;try{return e()}finally{M=t}}function so(e,t,s){const n=Array.isArray(e);let r,a=s&&s.defer;return i=>{let l;if(n){l=Array(e.length);for(let f=0;f<e.length;f++)l[f]=e[f]()}else l=e();if(a)return a=!1,i;const c=W(()=>t(l,r,i));return r=l,c}}function mn(e){ps(()=>W(e))}function Qe(e){return D===null||(D.cleanups===null?D.cleanups=[e]:D.cleanups.push(e)),e}function Ns(){return D}function En(e,t){const s=D,n=M;D=e,M=null;try{return oe(t,!0)}catch(r){ys(r)}finally{D=s,M=n}}function no(e){const t=M,s=D;return Promise.resolve().then(()=>{M=t,D=s;let n;return oe(e,!1),M=D=null,n?n.done:void 0})}var[ro,ml]=q(!1);function ao(){return[ro,no]}function oo(e,t){const s=Symbol("context");return{id:s,Provider:ho(s),defaultValue:e}}function io(e){let t;return D&&D.context&&(t=D.context[e.id])!==void 0?t:e.defaultValue}function pn(e){const t=z(e),s=z(()=>Zt(t()));return s.toArray=()=>{const n=s();return Array.isArray(n)?n:n!=null?[n]:[]},s}var lo;function yn(){if(this.sources&&this.state)if(this.state===me)$e(this);else{const e=J;J=null,oe(()=>Ot(this),!1),J=e}if(M){const e=this.observers?this.observers.length:0;M.sources?(M.sources.push(this),M.sourceSlots.push(e)):(M.sources=[this],M.sourceSlots=[e]),this.observers?(this.observers.push(M),this.observerSlots.push(M.sources.length-1)):(this.observers=[M],this.observerSlots=[M.sources.length-1])}return this.value}function Tn(e,t,s){let n=e.value;return(!e.comparator||!e.comparator(n,t))&&(e.value=t,e.observers&&e.observers.length&&oe(()=>{for(let r=0;r<e.observers.length;r+=1){const a=e.observers[r],i=Wt&&Wt.running;i&&Wt.disposed.has(a),(i?!a.tState:!a.state)&&(a.pure?J.push(a):de.push(a),a.observers&&Sn(a)),i||(a.state=me)}if(J.length>1e6)throw J=[],new Error},!1)),t}function $e(e){if(!e.fn)return;st(e);const t=Vt;co(e,e.value,t)}function co(e,t,s){let n;const r=D,a=M;M=D=e;try{n=e.fn(t)}catch(i){return e.pure&&(e.state=me,e.owned&&e.owned.forEach(st),e.owned=null),e.updatedAt=s+1,ys(i)}finally{M=a,D=r}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?Tn(e,n):e.value=n,e.updatedAt=s)}function Ht(e,t,s,n=me,r){const a={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:D,context:D?D.context:null,pure:s};return D===null||D!==hn&&(D.owned?D.owned.push(a):D.owned=[a]),a}function Dt(e){if(e.state===0)return;if(e.state===kt)return Ot(e);if(e.suspense&&W(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<Vt);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===me)$e(e);else if(e.state===kt){const n=J;J=null,oe(()=>Ot(e,t[0]),!1),J=n}}function oe(e,t){if(J)return e();let s=!1;t||(J=[]),de?s=!0:de=[],Vt++;try{const n=e();return uo(s),n}catch(n){s||(de=null),J=null,ys(n)}}function uo(e){if(J&&(An(J),J=null),e)return;const t=de;de=null,t.length&&oe(()=>fn(t),!1)}function An(e){for(let t=0;t<e.length;t++)Dt(e[t])}function fo(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:Dt(n)}if(v.context){if(v.count){v.effects||(v.effects=[]),v.effects.push(...e.slice(0,s));return}Ye()}for(v.effects&&(v.done||!v.count)&&(e=[...v.effects,...e],s+=v.effects.length,delete v.effects),t=0;t<s;t++)Dt(e[t])}function Ot(e,t){e.state=0;for(let s=0;s<e.sources.length;s+=1){const n=e.sources[s];if(n.sources){const r=n.state;r===me?n!==t&&(!n.updatedAt||n.updatedAt<Vt)&&Dt(n):r===kt&&Ot(n,t)}}}function Sn(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=kt,s.pure?J.push(s):de.push(s),s.observers&&Sn(s))}}function st(e){let t;if(e.sources)for(;e.sources.length;){const s=e.sources.pop(),n=e.sourceSlots.pop(),r=s.observers;if(r&&r.length){const a=r.pop(),i=s.observerSlots.pop();n<r.length&&(a.sourceSlots[i]=n,r[n]=a,s.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)st(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)st(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 It(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function ys(e,t=D){throw It(e)}function Zt(e){if(typeof e=="function"&&!e.length)return Zt(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const n=Zt(e[s]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function ho(e,t){return function(n){let r;return pe(()=>r=W(()=>(D.context={...D.context,[e]:n.value},pn(()=>n.children))),void 0),r}}var Xt=Symbol("fallback");function Rt(e){for(let t=0;t<e.length;t++)e[t]()}function go(e,t,s={}){let n=[],r=[],a=[],i=0,l=t.length>1?[]:null;return Qe(()=>Rt(a)),()=>{let c=e()||[],f=c.length,d,u;return c[Es],W(()=>{let m,T,_,w,R,A,C,I,F;if(f===0)i!==0&&(Rt(a),a=[],n=[],r=[],i=0,l&&(l=[])),s.fallback&&(n=[Xt],r[0]=Ee(j=>(a[0]=j,s.fallback())),i=1);else if(i===0){for(r=new Array(f),u=0;u<f;u++)n[u]=c[u],r[u]=Ee(E);i=f}else{for(_=new Array(f),w=new Array(f),l&&(R=new Array(f)),A=0,C=Math.min(i,f);A<C&&n[A]===c[A];A++);for(C=i-1,I=f-1;C>=A&&I>=A&&n[C]===c[I];C--,I--)_[I]=r[C],w[I]=a[C],l&&(R[I]=l[C]);for(m=new Map,T=new Array(I+1),u=I;u>=A;u--)F=c[u],d=m.get(F),T[u]=d===void 0?-1:d,m.set(F,u);for(d=A;d<=C;d++)F=n[d],u=m.get(F),u!==void 0&&u!==-1?(_[u]=r[d],w[u]=a[d],l&&(R[u]=l[d]),u=T[u],m.set(F,u)):a[d]();for(u=A;u<f;u++)u in _?(r[u]=_[u],a[u]=w[u],l&&(l[u]=R[u],l[u](u))):r[u]=Ee(E);r=r.slice(0,i=f),n=c.slice(0)}return r});function E(m){if(a[u]=m,l){const[T,_]=q(u);return l[u]=_,t(c[u],T)}return t(c[u])}}}function mo(e,t,s={}){let n=[],r=[],a=[],i=[],l=0,c;return Qe(()=>Rt(a)),()=>{const f=e()||[],d=f.length;return f[Es],W(()=>{if(d===0)return l!==0&&(Rt(a),a=[],n=[],r=[],l=0,i=[]),s.fallback&&(n=[Xt],r[0]=Ee(E=>(a[0]=E,s.fallback())),l=1),r;for(n[0]===Xt&&(a[0](),a=[],n=[],r=[],l=0),c=0;c<d;c++)c<n.length&&n[c]!==f[c]?i[c](()=>f[c]):c>=n.length&&(r[c]=Ee(u));for(;c<n.length;c++)a[c]();return l=i.length=a.length=d,n=f.slice(0),r=r.slice(0,l)});function u(E){a[c]=E;const[m,T]=q(f[c]);return i[c]=T,t(m,c)}}}function Ts(e,t){return W(()=>e(t||{}))}function _t(){return!0}var es={get(e,t,s){return t===jt?s:e.get(t)},has(e,t){return t===jt?!0:e.has(t)},set:_t,deleteProperty:_t,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:_t,deleteProperty:_t}},ownKeys(e){return e.keys()}};function Yt(e){return(e=typeof e=="function"?e():e)?e:{}}function Eo(){for(let e=0,t=this.length;e<t;++e){const s=this[e]();if(s!==void 0)return s}}function As(...e){let t=!1;for(let i=0;i<e.length;i++){const l=e[i];t=t||!!l&&jt in l,e[i]=typeof l=="function"?(t=!0,z(l)):l}if(dn&&t)return new Proxy({get(i){for(let l=e.length-1;l>=0;l--){const c=Yt(e[l])[i];if(c!==void 0)return c}},has(i){for(let l=e.length-1;l>=0;l--)if(i in Yt(e[l]))return!0;return!1},keys(){const i=[];for(let l=0;l<e.length;l++)i.push(...Object.keys(Yt(e[l])));return[...new Set(i)]}},es);const s={},n=Object.create(null);for(let i=e.length-1;i>=0;i--){const l=e[i];if(!l)continue;const c=Object.getOwnPropertyNames(l);for(let f=c.length-1;f>=0;f--){const d=c[f];if(d==="__proto__"||d==="constructor")continue;const u=Object.getOwnPropertyDescriptor(l,d);if(!n[d])n[d]=u.get?{enumerable:!0,configurable:!0,get:Eo.bind(s[d]=[u.get.bind(l)])}:u.value!==void 0?u:void 0;else{const E=s[d];E&&(u.get?E.push(u.get.bind(l)):u.value!==void 0&&E.push(()=>u.value))}}}const r={},a=Object.keys(n);for(let i=a.length-1;i>=0;i--){const l=a[i],c=n[l];c&&c.get?Object.defineProperty(r,l,c):r[l]=c?c.value:void 0}return r}function Pn(e,...t){if(dn&&jt in e){const r=new Set(t.length>1?t.flat():t[0]),a=t.map(i=>new Proxy({get(l){return i.includes(l)?e[l]:void 0},has(l){return i.includes(l)&&l in e},keys(){return i.filter(l=>l in e)}},es));return a.push(new Proxy({get(i){return r.has(i)?void 0:e[i]},has(i){return r.has(i)?!1:i in e},keys(){return Object.keys(e).filter(i=>!r.has(i))}},es)),a}const s={},n=t.map(()=>({}));for(const r of Object.getOwnPropertyNames(e)){const a=Object.getOwnPropertyDescriptor(e,r),i=!a.get&&!a.set&&a.enumerable&&a.writable&&a.configurable;let l=!1,c=0;for(const f of t)f.includes(r)&&(l=!0,i?n[c][r]=a.value:Object.defineProperty(n[c],r,a)),++c;l||(i?s[r]=a.value:Object.defineProperty(s,r,a))}return[...n,s]}function xn(e){let t,s;const n=r=>{const a=v.context;if(a){const[l,c]=q();v.count||(v.count=0),v.count++,(s||(s=e())).then(f=>{!v.done&&Ye(a),v.count--,c(()=>f.default),Ye()}),t=l}else if(!t){const[l]=eo(()=>(s||(s=e())).then(c=>c.default));t=l}let i;return z(()=>(i=t())?W(()=>{if(!a||v.done)return i(r);const l=v.context;Ye(a);const c=i(r);return Ye(l),c}):"")};return n.preload=()=>s||((s=e()).then(r=>t=()=>r.default),s),n}var po=0;function yo(){return v.context?v.getNextContextId():`cl-${po++}`}var _n=e=>`Stale read from <${e}>.`;function To(e){const t="fallback"in e&&{fallback:()=>e.fallback};return z(go(()=>e.each,e.children,t||void 0))}function Ao(e){const t="fallback"in e&&{fallback:()=>e.fallback};return z(mo(()=>e.each,e.children,t||void 0))}function So(e){const t=e.keyed,s=z(()=>e.when,void 0,void 0),n=t?s:z(s,void 0,{equals:(r,a)=>!r==!a});return z(()=>{const r=n();if(r){const a=e.children;return typeof a=="function"&&a.length>0?W(()=>a(t?r:()=>{if(!W(n))throw _n("Show");return s()})):a}return e.fallback},void 0,void 0)}function Po(e){const t=pn(()=>e.children),s=z(()=>{const n=t(),r=Array.isArray(n)?n:[n];let a=()=>{};for(let i=0;i<r.length;i++){const l=i,c=r[i],f=a,d=z(()=>f()?void 0:c.when,void 0,void 0),u=c.keyed?d:z(d,void 0,{equals:(E,m)=>!E==!m});a=()=>f()||(u()?[l,d,c]:void 0)}return a});return z(()=>{const n=s()();if(!n)return e.fallback;const[r,a,i]=n,l=i.children;return typeof l=="function"&&l.length>0?W(()=>l(i.keyed?a():()=>{var f;if(((f=W(s)())==null?void 0:f[0])!==r)throw _n("Match");return a()})):l},void 0,void 0)}function xo(e){return e}var _o=["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"],wo=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",..._o]),vo=new Set(["innerHTML","textContent","innerText","children"]),bo=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),Co=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 Io(e,t){const s=Co[e];return typeof s=="object"?s[t]?s.$:void 0:s}var Lo=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),No=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),jo={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},Go=e=>z(()=>e());function ko(e,t,s){let n=s.length,r=t.length,a=n,i=0,l=0,c=t[r-1].nextSibling,f=null;for(;i<r||l<a;){if(t[i]===s[l]){i++,l++;continue}for(;t[r-1]===s[a-1];)r--,a--;if(r===i){const d=a<n?l?s[l-1].nextSibling:s[a-l]:c;for(;l<a;)e.insertBefore(s[l++],d)}else if(a===l)for(;i<r;)(!f||!f.has(t[i]))&&t[i].remove(),i++;else if(t[i]===s[a-1]&&s[l]===t[r-1]){const d=t[--r].nextSibling;e.insertBefore(s[l++],t[i++].nextSibling),e.insertBefore(s[--a],d),t[r]=s[a]}else{if(!f){f=new Map;let u=l;for(;u<a;)f.set(s[u],u++)}const d=f.get(t[i]);if(d!=null)if(l<d&&d<a){let u=i,E=1,m;for(;++u<r&&u<a&&!((m=f.get(t[u]))==null||m!==d+E);)E++;if(E>d-l){const T=t[i];for(;l<d;)e.insertBefore(s[l++],T)}else e.replaceChild(s[l++],t[i++])}else i++;else t[i++].remove()}}}var Xe="_$DX_DELEGATE";function wn(e,t,s,n={}){let r;return Ee(a=>{r=a,t===document?e():Ut(t,e(),t.firstChild?null:void 0,s)},n.owner),()=>{r(),t.textContent=""}}function Do(e,t,s,n){let r;const a=()=>{const l=document.createElement("template");return l.innerHTML=e,l.content.firstChild},i=()=>(r||(r=a())).cloneNode(!0);return i.cloneNode=i,i}function vn(e,t=window.document){const s=t[Xe]||(t[Xe]=new Set);for(let n=0,r=e.length;n<r;n++){const a=e[n];s.has(a)||(s.add(a),t.addEventListener(a,Nn))}}function Oo(e=window.document){if(e[Xe]){for(let t of e[Xe].keys())e.removeEventListener(t,Nn);delete e[Xe]}}function Mt(e,t,s){we(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function Ro(e,t,s,n){we(e)||(n==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,n))}function Mo(e,t,s){we(e)||(s?e.setAttribute(t,""):e.removeAttribute(t))}function bn(e,t){we(e)||(t==null?e.removeAttribute("class"):e.className=t)}function Cn(e,t,s,n){if(n)Array.isArray(s)?(e[`$$${t}`]=s[0],e[`$$${t}Data`]=s[1]):e[`$$${t}`]=s;else if(Array.isArray(s)){const r=s[0];e.addEventListener(t,s[0]=a=>r.call(e,s[1],a))}else e.addEventListener(t,s,typeof s!="function"&&s)}function Uo(e,t,s={}){const n=Object.keys(t||{}),r=Object.keys(s);let a,i;for(a=0,i=r.length;a<i;a++){const l=r[a];!l||l==="undefined"||t[l]||(js(e,l,!1),delete s[l])}for(a=0,i=n.length;a<i;a++){const l=n[a],c=!!t[l];!l||l==="undefined"||s[l]===c||!c||(js(e,l,!0),s[l]=c)}return s}function Bo(e,t,s){if(!t)return s?Mt(e,"style"):t;const n=e.style;if(typeof t=="string")return n.cssText=t;typeof s=="string"&&(n.cssText=s=void 0),s||(s={}),t||(t={});let r,a;for(a in s)t[a]==null&&n.removeProperty(a),delete s[a];for(a in t)r=t[a],r!==s[a]&&(n.setProperty(a,r),s[a]=r);return s}function In(e,t={},s,n){const r={};return n||pe(()=>r.children=nt(e,t.children,r.children)),pe(()=>typeof t.ref=="function"&&Ln(t.ref,e)),pe(()=>Fo(e,t,s,!0,r,!0)),r}function Ln(e,t,s){return W(()=>e(t,s))}function Ut(e,t,s,n){if(s!==void 0&&!n&&(n=[]),typeof t!="function")return nt(e,t,n,s);pe(r=>nt(e,t(),r,s),n)}function Fo(e,t,s,n,r={},a=!1){t||(t={});for(const i in r)if(!(i in t)){if(i==="children")continue;r[i]=Gs(e,i,null,r[i],s,a,t)}for(const i in t){if(i==="children")continue;const l=t[i];r[i]=Gs(e,i,l,r[i],s,a,t)}}function qo(e){let t,s;return!we()||!(t=v.registry.get(s=Vo()))?e():(v.completed&&v.completed.add(t),v.registry.delete(s),t)}function we(e){return!!v.context&&!v.done&&(!e||e.isConnected)}function Ko(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function js(e,t,s){const n=t.trim().split(/\s+/);for(let r=0,a=n.length;r<a;r++)e.classList.toggle(n[r],s)}function Gs(e,t,s,n,r,a,i){let l,c,f,d,u;if(t==="style")return Bo(e,s,n);if(t==="classList")return Uo(e,s,n);if(s===n)return n;if(t==="ref")a||s(e);else if(t.slice(0,3)==="on:"){const E=t.slice(3);n&&e.removeEventListener(E,n,typeof n!="function"&&n),s&&e.addEventListener(E,s,typeof s!="function"&&s)}else if(t.slice(0,10)==="oncapture:"){const E=t.slice(10);n&&e.removeEventListener(E,n,!0),s&&e.addEventListener(E,s,!0)}else if(t.slice(0,2)==="on"){const E=t.slice(2).toLowerCase(),m=Lo.has(E);if(!m&&n){const T=Array.isArray(n)?n[0]:n;e.removeEventListener(E,T)}(m||s)&&(Cn(e,E,s,m),m&&vn([E]))}else if(t.slice(0,5)==="attr:")Mt(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")Mo(e,t.slice(5),s);else if((u=t.slice(0,5)==="prop:")||(f=vo.has(t))||!r&&((d=Io(t,e.tagName))||(c=wo.has(t)))||(l=e.nodeName.includes("-")||"is"in i)){if(u)t=t.slice(5),c=!0;else if(we(e))return s;t==="class"||t==="className"?bn(e,s):l&&!c&&!f?e[Ko(t)]=s:e[d||t]=s}else{const E=r&&t.indexOf(":")>-1&&jo[t.split(":")[0]];E?Ro(e,E,t,s):Mt(e,bo[t]||t,s)}return s}function Nn(e){if(v.registry&&v.events&&v.events.find(([c,f])=>f===e))return;let t=e.target;const s=`$$${e.type}`,n=e.target,r=e.currentTarget,a=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),i=()=>{const c=t[s];if(c&&!t.disabled){const f=t[`${s}Data`];if(f!==void 0?c.call(t,f,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&a(t.host),!0},l=()=>{for(;i()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),v.registry&&!v.done&&(v.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();a(c[0]);for(let f=0;f<c.length-2&&(t=c[f],!!i());f++){if(t._$host){t=t._$host,l();break}if(t.parentNode===r)break}}else l();a(n)}function nt(e,t,s,n,r){const a=we(e);if(a){!s&&(s=[...e.childNodes]);let c=[];for(let f=0;f<s.length;f++){const d=s[f];d.nodeType===8&&d.data.slice(0,2)==="!$"?d.remove():c.push(d)}s=c}for(;typeof s=="function";)s=s();if(t===s)return s;const i=typeof t,l=n!==void 0;if(e=l&&s[0]&&s[0].parentNode||e,i==="string"||i==="number"){if(a||i==="number"&&(t=t.toString(),t===s))return s;if(l){let c=s[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),s=be(e,s,n,c)}else s!==""&&typeof s=="string"?s=e.firstChild.data=t:s=e.textContent=t}else if(t==null||i==="boolean"){if(a)return s;s=be(e,s,n)}else{if(i==="function")return pe(()=>{let c=t();for(;typeof c=="function";)c=c();s=nt(e,c,s,n)}),()=>s;if(Array.isArray(t)){const c=[],f=s&&Array.isArray(s);if(ts(c,t,s,r))return pe(()=>s=nt(e,c,s,n,!0)),()=>s;if(a){if(!c.length)return s;if(n===void 0)return s=[...e.childNodes];let d=c[0];if(d.parentNode!==e)return s;const u=[d];for(;(d=d.nextSibling)!==n;)u.push(d);return s=u}if(c.length===0){if(s=be(e,s,n),l)return s}else f?s.length===0?ks(e,c,n):ko(e,s,c):(s&&be(e),ks(e,c));s=c}else if(t.nodeType){if(a&&t.parentNode)return s=l?[t]:t;if(Array.isArray(s)){if(l)return s=be(e,s,n,t);be(e,s,null,t)}else s==null||s===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);s=t}}return s}function ts(e,t,s,n){let r=!1;for(let a=0,i=t.length;a<i;a++){let l=t[a],c=s&&s[e.length],f;if(!(l==null||l===!0||l===!1))if((f=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))r=ts(e,l,c)||r;else if(f==="function")if(n){for(;typeof l=="function";)l=l();r=ts(e,Array.isArray(l)?l:[l],Array.isArray(c)?c:[c])||r}else e.push(l),r=!0;else{const d=String(l);c&&c.nodeType===3&&c.data===d?e.push(c):e.push(document.createTextNode(d))}}return r}function ks(e,t,s=null){for(let n=0,r=t.length;n<r;n++)e.insertBefore(t[n],s)}function be(e,t,s,n){if(s===void 0)return e.textContent="";const r=n||document.createTextNode("");if(t.length){let a=!1;for(let i=t.length-1;i>=0;i--){const l=t[i];if(r!==l){const c=l.parentNode===e;!a&&!i?c?e.replaceChild(r,l):e.insertBefore(r,s):c&&l.remove()}else a=!0}}else e.insertBefore(r,s);return[r]}function Vo(){return v.getNextContextId()}var Ho="http://www.w3.org/2000/svg";function jn(e,t=!1){return t?document.createElementNS(Ho,e):document.createElement(e)}function Qo(e){const{useShadow:t}=e,s=document.createTextNode(""),n=()=>e.mount||document.body,r=Ns();let a,i=!!v.context;return ps(()=>{i&&(Ns().user=i=!1),a||(a=En(r,()=>z(()=>e.children)));const l=n();if(l instanceof HTMLHeadElement){const[c,f]=q(!1),d=()=>f(!0);Ee(u=>Ut(l,()=>c()?u():a(),null)),Qe(d)}else{const c=jn(e.isSVG?"g":"div",e.isSVG),f=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return s.parentNode},configurable:!0}),Ut(f,a),l.appendChild(c),e.ref&&e.ref(c),Qe(()=>l.removeChild(c))}},void 0,{render:!i}),s}function zo(e,t){const s=z(e);return z(()=>{const n=s();switch(typeof n){case"function":return W(()=>n(t));case"string":const r=No.has(n),a=v.context?qo():jn(n,r);return In(a,t,r),a}})}function $o(e){const[,t]=Pn(e,["component"]);return zo(()=>e.component,t)}var Wo=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()}},Gn=class{constructor(e){this.generateIdentifier=e,this.kv=new Wo}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)}},Yo=class extends Gn{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 Jo(e){if("values"in Object)return Object.values(e);const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push(e[s]);return t}function Zo(e,t){const s=Jo(e);if("find"in s)return s.find(t);const n=s;for(let r=0;r<n.length;r++){const a=n[r];if(t(a))return a}}function ze(e,t){Object.entries(e).forEach(([s,n])=>t(n,s))}function Lt(e,t){return e.indexOf(t)!==-1}function Ds(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var Xo=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return Zo(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},ei=e=>Object.prototype.toString.call(e).slice(8,-1),kn=e=>typeof e>"u",ti=e=>e===null,rt=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,ss=e=>rt(e)&&Object.keys(e).length===0,ye=e=>Array.isArray(e),si=e=>typeof e=="string",ni=e=>typeof e=="number"&&!isNaN(e),ri=e=>typeof e=="boolean",ai=e=>e instanceof RegExp,at=e=>e instanceof Map,ot=e=>e instanceof Set,Dn=e=>ei(e)==="Symbol",oi=e=>e instanceof Date&&!isNaN(e.valueOf()),ii=e=>e instanceof Error,Os=e=>typeof e=="number"&&isNaN(e),li=e=>ri(e)||ti(e)||kn(e)||ni(e)||si(e)||Dn(e),ci=e=>typeof e=="bigint",ui=e=>e===1/0||e===-1/0,di=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),fi=e=>e instanceof URL,On=e=>e.replace(/\./g,"\\."),Jt=e=>e.map(String).map(On).join("."),et=e=>{const t=[];let s="";for(let r=0;r<e.length;r++){let a=e.charAt(r);if(a==="\\"&&e.charAt(r+1)==="."){s+=".",r++;continue}if(a==="."){t.push(s),s="";continue}s+=a}const n=s;return t.push(n),t};function re(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var Rn=[re(kn,"undefined",()=>null,()=>{}),re(ci,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),re(oi,"Date",e=>e.toISOString(),e=>new Date(e)),re(ii,"Error",(e,t)=>{const s={name:e.name,message:e.message};return t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s},(e,t)=>{const s=new Error(e.message);return s.name=e.name,s.stack=e.stack,t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s}),re(ai,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),re(ot,"set",e=>[...e.values()],e=>new Set(e)),re(at,"map",e=>[...e.entries()],e=>new Map(e)),re(e=>Os(e)||ui(e),"number",e=>Os(e)?"NaN":e>0?"Infinity":"-Infinity",Number),re(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),re(fi,"URL",e=>e.toString(),e=>new URL(e))];function Qt(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var Mn=Qt((e,t)=>Dn(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,s)=>{const n=s.symbolRegistry.getValue(t[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),hi=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),Un=Qt(di,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=hi[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function Bn(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var Fn=Qt(Bn,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const s=t.classRegistry.getAllowedProps(e.constructor);if(!s)return{...e};const n={};return s.forEach(r=>{n[r]=e[r]}),n},(e,t,s)=>{const n=s.classRegistry.getValue(t[1]);if(!n)throw new Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(n.prototype),e)}),qn=Qt((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,s)=>{const n=s.customTransformerRegistry.findByName(t[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(e)}),gi=[Fn,Mn,qn,Un],Rs=(e,t)=>{const s=Ds(gi,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=Ds(Rn,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},Kn={};Rn.forEach(e=>{Kn[e.annotation]=e});var mi=(e,t,s)=>{if(ye(t))switch(t[0]){case"symbol":return Mn.untransform(e,t,s);case"class":return Fn.untransform(e,t,s);case"custom":return qn.untransform(e,t,s);case"typed-array":return Un.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const n=Kn[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,s)}},Ce=(e,t)=>{if(t>e.size)throw new Error("index out of bounds");const s=e.keys();for(;t>0;)s.next(),t--;return s.next().value};function Vn(e){if(Lt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Lt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(Lt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var Ei=(e,t)=>{Vn(t);for(let s=0;s<t.length;s++){const n=t[s];if(ot(e))e=Ce(e,+n);else if(at(e)){const r=+n,a=+t[++s]==0?"key":"value",i=Ce(e,r);switch(a){case"key":e=i;break;case"value":e=e.get(i);break}}else e=e[n]}return e},ns=(e,t,s)=>{if(Vn(t),t.length===0)return s(e);let n=e;for(let a=0;a<t.length-1;a++){const i=t[a];if(ye(n)){const l=+i;n=n[l]}else if(rt(n))n=n[i];else if(ot(n)){const l=+i;n=Ce(n,l)}else if(at(n)){if(a===t.length-2)break;const c=+i,f=+t[++a]==0?"key":"value",d=Ce(n,c);switch(f){case"key":n=d;break;case"value":n=n.get(d);break}}}const r=t[t.length-1];if(ye(n)?n[+r]=s(n[+r]):rt(n)&&(n[r]=s(n[r])),ot(n)){const a=Ce(n,+r),i=s(a);a!==i&&(n.delete(a),n.add(i))}if(at(n)){const a=+t[t.length-2],i=Ce(n,a);switch(+r==0?"key":"value"){case"key":{const c=s(i);n.set(c,n.get(i)),c!==i&&n.delete(i);break}case"value":{n.set(i,s(n.get(i)));break}}}return e};function rs(e,t,s=[]){if(!e)return;if(!ye(e)){ze(e,(a,i)=>rs(a,t,[...s,...et(i)]));return}const[n,r]=e;r&&ze(r,(a,i)=>{rs(a,t,[...s,...et(i)])}),t(n,s)}function pi(e,t,s){return rs(t,(n,r)=>{e=ns(e,r,a=>mi(a,n,s))}),e}function yi(e,t){function s(n,r){const a=Ei(e,et(r));n.map(et).forEach(i=>{e=ns(e,i,()=>a)})}if(ye(t)){const[n,r]=t;n.forEach(a=>{e=ns(e,et(a),()=>e)}),r&&ze(r,s)}else ze(t,s);return e}var Ti=(e,t)=>rt(e)||ye(e)||at(e)||ot(e)||Bn(e,t);function Ai(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function Si(e,t){const s={};let n;return e.forEach(r=>{if(r.length<=1)return;t||(r=r.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[a,...i]=r;a.length===0?n=i.map(Jt):s[Jt(a)]=i.map(Jt)}),n?ss(s)?[n]:[n,s]:ss(s)?void 0:s}var Hn=(e,t,s,n,r=[],a=[],i=new Map)=>{const l=li(e);if(!l){Ai(e,r,t);const m=i.get(e);if(m)return n?{transformedValue:null}:m}if(!Ti(e,s)){const m=Rs(e,s),T=m?{transformedValue:m.value,annotations:[m.type]}:{transformedValue:e};return l||i.set(e,T),T}if(Lt(a,e))return{transformedValue:null};const c=Rs(e,s),f=(c==null?void 0:c.value)??e,d=ye(f)?[]:{},u={};ze(f,(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 _=Hn(m,t,s,n,[...r,T],[...a,e],i);d[T]=_.transformedValue,ye(_.annotations)?u[T]=_.annotations:rt(_.annotations)&&ze(_.annotations,(w,R)=>{u[On(T)+"."+R]=w})});const E=ss(u)?{transformedValue:d,annotations:c?[c.type]:void 0}:{transformedValue:d,annotations:c?[c.type,u]:u};return l||i.set(e,E),E};function Qn(e){return Object.prototype.toString.call(e).slice(8,-1)}function Ms(e){return Qn(e)==="Array"}function Pi(e){if(Qn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function xi(e,t,s,n,r){const a={}.propertyIsEnumerable.call(n,t)?"enumerable":"nonenumerable";a==="enumerable"&&(e[t]=s),r&&a==="nonenumerable"&&Object.defineProperty(e,t,{value:s,enumerable:!1,writable:!0,configurable:!0})}function as(e,t={}){if(Ms(e))return e.map(r=>as(r,t));if(!Pi(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((r,a)=>{if(Ms(t.props)&&!t.props.includes(a))return r;const i=e[a],l=as(i,t);return xi(r,a,l,e,t.nonenumerable),r},{})}var U=class{constructor({dedupe:e=!1}={}){this.classRegistry=new Yo,this.symbolRegistry=new Gn(t=>t.description??""),this.customTransformerRegistry=new Xo,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=Hn(e,t,this,this.dedupe),n={json:s.transformedValue};s.annotations&&(n.meta={...n.meta,values:s.annotations});const r=Si(t,this.dedupe);return r&&(n.meta={...n.meta,referentialEqualities:r}),n}deserialize(e){const{json:t,meta:s}=e;let n=as(t);return s!=null&&s.values&&(n=pi(n,s.values,this)),s!=null&&s.referentialEqualities&&(n=yi(n,s.referentialEqualities)),n}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};U.defaultInstance=new U;U.serialize=U.defaultInstance.serialize.bind(U.defaultInstance);U.deserialize=U.defaultInstance.deserialize.bind(U.defaultInstance);U.stringify=U.defaultInstance.stringify.bind(U.defaultInstance);U.parse=U.defaultInstance.parse.bind(U.defaultInstance);U.registerClass=U.defaultInstance.registerClass.bind(U.defaultInstance);U.registerSymbol=U.defaultInstance.registerSymbol.bind(U.defaultInstance);U.registerCustom=U.defaultInstance.registerCustom.bind(U.defaultInstance);U.allowErrorProps=U.defaultInstance.allowErrorProps.bind(U.defaultInstance);var zn=U.serialize,_i=U.stringify;function wi(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function vi(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function bi({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function Ci({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function Ii(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var Li=(e,t=!1)=>{const{json:s}=zn(e);return JSON.stringify(s,null,t?2:void 0)},wt=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,Ni=(e,t)=>e.queryHash.localeCompare(t.queryHash),$n=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,ji=(e,t)=>wt(e)===wt(t)?$n(e,t):wt(e)>wt(t)?1:-1,Gi={status:ji,"query hash":Ni,"last updated":$n},vt=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,Wn=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,ki=(e,t)=>vt(e)===vt(t)?Wn(e,t):vt(e)>vt(t)?1:-1,Di={status:ki,"last updated":Wn},Oi=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),Ri=()=>{const[e,t]=q("dark");return mn(()=>{const s=window.matchMedia("(prefers-color-scheme: dark)");t(s.matches?"dark":"light");const n=r=>{t(r.matches?"dark":"light")};s.addEventListener("change",n),Qe(()=>s.removeEventListener("change",n))}),e},Je=(e,t,s)=>{if(t.length===0)return s;if(e instanceof Map){const n=new Map(e);if(t.length===1)return n.set(t[0],s),n;const[r,...a]=t;return n.set(r,Je(n.get(r),a,s)),n}if(e instanceof Set){const n=Je(Array.from(e),t,s);return new Set(n)}if(Array.isArray(e)){const n=[...e];if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=Je(n[r],a,s),n}if(e instanceof Object){const n={...e};if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=Je(n[r],a,s),n}return e},Ze=(e,t)=>{if(e instanceof Map){const s=new Map(e);if(t.length===1)return s.delete(t[0]),s;const[n,...r]=t;return s.set(n,Ze(s.get(n),r)),s}if(e instanceof Set){const s=Ze(Array.from(e),t);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s.filter((a,i)=>i.toString()!==t[0]);const[n,...r]=t;return s[n]=Ze(s[n],r),s}if(e instanceof Object){const s={...e};if(t.length===1)return delete s[t[0]],s;const[n,...r]=t;return s[n]=Ze(s[n],r),s}return e},Yn=(e,t)=>{if(!e||document.querySelector("#_goober")||(t==null?void 0:t.querySelector("#_goober")))return;const n=document.createElement("style"),r=document.createTextNode("");n.appendChild(r),n.id="_goober",n.setAttribute("nonce",e),t?t.appendChild(n):document.head.appendChild(n)},Ie,it,lt,ct,Pe,ut,Le,Ne,je,Ge,ke,dt,De,Oe,ft,Fs,Mi=(Fs=class{constructor(e){O(this,Ie);O(this,it);O(this,lt);O(this,ct);O(this,Pe,!1);O(this,ut);O(this,Le);O(this,Ne);O(this,je);O(this,Ge);O(this,ke);O(this,dt);O(this,De);O(this,Oe);O(this,ft);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:f,shadowDOMTarget:d,hideDisabledQueries:u,theme:E}=e;k(this,Ie,q(t)),k(this,lt,s),k(this,ct,n),k(this,it,r),k(this,ut,f),k(this,Le,d),k(this,Ne,q(a)),k(this,je,q(i)),k(this,Ge,q(l)),k(this,ke,q(c)),k(this,dt,q(u)),k(this,Oe,q(E))}setButtonPosition(e){P(this,Ne)[1](e)}setPosition(e){P(this,je)[1](e)}setInitialIsOpen(e){P(this,Ge)[1](e)}setErrorTypes(e){P(this,ke)[1](e)}setClient(e){P(this,Ie)[1](e)}setTheme(e){P(this,Oe)[1](e)}mount(e){if(P(this,Pe))throw new Error("Devtools is already mounted");const t=wn(()=>{const s=this,[n]=P(this,Ne),[r]=P(this,je),[a]=P(this,Ge),[i]=P(this,ke),[l]=P(this,dt),[c]=P(this,Ie),[f]=P(this,Oe);let d;return P(this,De)?d=P(this,De):(d=xn(()=>Promise.resolve().then(()=>require("./WDYDFRGG-BxhOCHc3.cjs"))),k(this,De,d)),Yn(P(this,ut),P(this,Le)),Ts(d,As({get queryFlavor(){return P(s,lt)},get version(){return P(s,ct)},get onlineManager(){return P(s,it)},get shadowDOMTarget(){return P(s,Le)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()},get theme(){return f()}}))},e);k(this,Pe,!0),k(this,ft,t)}unmount(){var e;if(!P(this,Pe))throw new Error("Devtools is not mounted");(e=P(this,ft))==null||e.call(this),k(this,Pe,!1)}},Ie=new WeakMap,it=new WeakMap,lt=new WeakMap,ct=new WeakMap,Pe=new WeakMap,ut=new WeakMap,Le=new WeakMap,Ne=new WeakMap,je=new WeakMap,Ge=new WeakMap,ke=new WeakMap,dt=new WeakMap,De=new WeakMap,Oe=new WeakMap,ft=new WeakMap,Fs),Re,ht,gt,mt,xe,Et,Me,Ue,Be,Fe,qe,pt,Ke,Ve,He,yt,qs,Ui=(qs=class{constructor(e){O(this,Re);O(this,ht);O(this,gt);O(this,mt);O(this,xe,!1);O(this,Et);O(this,Me);O(this,Ue);O(this,Be);O(this,Fe);O(this,qe);O(this,pt);O(this,Ke);O(this,Ve);O(this,He);O(this,yt);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:f,shadowDOMTarget:d,onClose:u,hideDisabledQueries:E,theme:m}=e;k(this,Re,q(t)),k(this,gt,s),k(this,mt,n),k(this,ht,r),k(this,Et,f),k(this,Me,d),k(this,Ue,q(a)),k(this,Be,q(i)),k(this,Fe,q(l)),k(this,qe,q(c)),k(this,pt,q(E)),k(this,Ke,q(u)),k(this,He,q(m))}setButtonPosition(e){P(this,Ue)[1](e)}setPosition(e){P(this,Be)[1](e)}setInitialIsOpen(e){P(this,Fe)[1](e)}setErrorTypes(e){P(this,qe)[1](e)}setClient(e){P(this,Re)[1](e)}setOnClose(e){P(this,Ke)[1](()=>e)}setTheme(e){P(this,He)[1](e)}mount(e){if(P(this,xe))throw new Error("Devtools is already mounted");const t=wn(()=>{const s=this,[n]=P(this,Ue),[r]=P(this,Be),[a]=P(this,Fe),[i]=P(this,qe),[l]=P(this,pt),[c]=P(this,Re),[f]=P(this,Ke),[d]=P(this,He);let u;return P(this,Ve)?u=P(this,Ve):(u=xn(()=>Promise.resolve().then(()=>require("./2SSKDMRQ-BnsZi3K3.cjs"))),k(this,Ve,u)),Yn(P(this,Et),P(this,Me)),Ts(u,As({get queryFlavor(){return P(s,gt)},get version(){return P(s,mt)},get onlineManager(){return P(s,ht)},get shadowDOMTarget(){return P(s,Me)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()},get onClose(){return f()},get theme(){return d()}}))},e);k(this,xe,!0),k(this,yt,t)}unmount(){var e;if(!P(this,xe))throw new Error("Devtools is not mounted");(e=P(this,yt))==null||e.call(this),k(this,xe,!1)}},Re=new WeakMap,ht=new WeakMap,gt=new WeakMap,mt=new WeakMap,xe=new WeakMap,Et=new WeakMap,Me=new WeakMap,Ue=new WeakMap,Be=new WeakMap,Fe=new WeakMap,qe=new WeakMap,pt=new WeakMap,Ke=new WeakMap,Ve=new WeakMap,He=new WeakMap,yt=new WeakMap,qs);function Bi(e){const t=S.useQueryClient(e.client),s=H.useRef(null),{buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:f,theme:d}=e,[u]=H.useState(new Mi({client:t,queryFlavor:"React Query",version:"5",onlineManager:S.onlineManager,buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:f,theme:d}));return H.useEffect(()=>{u.setClient(t)},[t,u]),H.useEffect(()=>{n&&u.setButtonPosition(n)},[n,u]),H.useEffect(()=>{r&&u.setPosition(r)},[r,u]),H.useEffect(()=>{u.setInitialIsOpen(a||!1)},[a,u]),H.useEffect(()=>{u.setErrorTypes(i||[])},[i,u]),H.useEffect(()=>{u.setTheme(d)},[d,u]),H.useEffect(()=>(s.current&&u.mount(s.current),()=>{u.unmount()}),[u]),o.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:s})}function Fi(e){const t=S.useQueryClient(e.client),s=H.useRef(null),{errorTypes:n,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:i,theme:l}=e,[c]=H.useState(new Ui({client:t,queryFlavor:"React Query",version:"5",onlineManager:S.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:n,styleNonce:r,shadowDOMTarget:a,onClose:e.onClose,hideDisabledQueries:i,theme:l}));return H.useEffect(()=>{c.setClient(t)},[t,c]),H.useEffect(()=>{c.setOnClose(e.onClose??(()=>{}))},[e.onClose,c]),H.useEffect(()=>{c.setErrorTypes(n||[])},[n,c]),H.useEffect(()=>{c.setTheme(l)},[l,c]),H.useEffect(()=>(s.current&&c.mount(s.current),()=>{c.unmount()}),[c]),o.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:s})}var Us=process.env.NODE_ENV!=="development"?function(){return null}:Bi;process.env.NODE_ENV;const Jn=V.atom(""),qi=()=>{h.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),h.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"})},Ki=()=>{const e=L(),t=N();return S.useQuery({queryKey:[y.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:y.GET_COLLECTIONS})})},Vi=()=>{const{data:e}=ee(),{data:t}=he(),{data:s}=Ae(),n=L(),r=N(),a=g.useMemo(()=>(s==null?void 0:s.fallbackLang)||"en",[s==null?void 0:s.fallbackLang]),i=g.useRef(new Map);return S.useMutation({mutationFn:async({block:l})=>{const c=l._id,f=(t==null?void 0:t.lang)||a,d=`${c}:${f}`;if(i.current.has(d))return i.current.get(d);const u=r(n,{action:y.GET_BLOCK_ASYNC_PROPS,data:{block:l,lang:f,pageProps:{slug:t==null?void 0:t.slug,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:a,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id}}});return i.current.set(d,u),u.finally(()=>{i.current.delete(d)}),u}})},Zn=()=>{const[,e]=ie();return g.useCallback((t,s)=>{const r=new URLSearchParams(window.location.search).get("lang"),a=new URLSearchParams({page:t});r&&a.set("lang",r),window.history.pushState({},"",`?${a.toString()}`),e(a),window.dispatchEvent(new PopStateEvent("popstate")),s==null||s()},[e])},Xn=()=>{const e=Zn();return g.useCallback(({pageId:t})=>{e(t)},[e])},Hi={SITE_WIDE_USAGE:"SITE_WIDE_USAGE"},Qi=e=>{const t=N(),s=L();return S.useQuery({queryKey:[Hi.SITE_WIDE_USAGE],queryFn:async()=>e?t(s,{action:"GET_SITE_WIDE_USAGE"}):{},retry:!1})},zi=g.lazy(()=>Promise.resolve().then(()=>require("./page-lock-BdYmCks0.cjs"))),$i=g.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-dialog-BcEoqyQB.cjs"))),Wi=g.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager--uO8Agia.cjs"))),Yi=g.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-Cgpxw8-g.cjs"))),Ji=g.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-Cq9pljro.cjs"))),Zi=g.lazy(()=>Promise.resolve().then(()=>require("./web-preview-Cio70gk5.cjs")));qi();gr.loadWebBlocks();h.registerChaiTopBar(_a);Ya();h.registerChaiMediaManager(Wi);h.registerChaiSaveToLibrary(Yi);const Xi={role:"",permissions:null},Bs=e=>{var xs;const{data:t}=Da(),s=qt(),{data:n=Xi,isFetching:r}=rn(),{data:a,isFetching:i}=ge(),{data:l,isFetching:c}=Ki(),{data:f,isFetching:d}=Ae(),u=r||i||c||d,[E]=ie(),m=E.get("page"),{data:T}=ee(),{data:_,isFetching:w}=Ca(),{blocks:R}=ba(_),{data:A,isFetching:C}=sn(),{pageStatus:I}=se(),F=wa(),{onSave:j}=Oa(),{mutateAsync:le}=Vi(),{getPartialBlocks:ce,getPartialBlockBlocks:K}=Ra(),{mutateAsync:b}=br(),{mutateAsync:G}=nn(),{data:$}=Qi(((xs=e.flags)==null?void 0:xs.designTokens)??!1),Q=Xn(),[ne,St]=g.useState(!1),ue=g.useRef([]),ve=g.useMemo(()=>p.get(f,"theme",{})||{},[f]),Se=I===Y.EDITING,tr=I===Y.CHECKING,Ss=w||tr||C;ue.current=R;const[sr]=V.useAtom(Jn);g.useEffect(()=>{const X=()=>{document.hidden?St(!0):St(!1)};return window.addEventListener("visibilitychange",X),()=>window.removeEventListener("visibilitychange",X)},[]);const nr=g.useMemo(()=>{const X={};return n&&(X.permissions=p.get(n,"permissions",null),X.role=p.get(n,"role","user")),X},[n]),Ps=g.useMemo(()=>t==null?void 0:t.some(X=>X.isSiteLibrary),[t]),rr=g.useCallback(async(X,Pt)=>await b({pageType:X,query:Pt}),[b]);return o.jsxs(o.Fragment,{children:[Ss&&o.jsx(gs,{className:u?"fixed inset-0 bg-white":"bg-white/75",children:o.jsx(x.Loader,{className:`animate-spin text-primary ${u?"h-6 w-6":"h-5 w-5"}`})}),sr&&o.jsx(g.Suspense,{fallback:o.jsx("div",{className:"absolute inset-0 z-[999999] flex min-h-screen w-screen items-center justify-center bg-gray-100",children:o.jsx(x.Loader,{className:"h-6 w-6 animate-spin text-primary"})}),children:o.jsx(Zi,{})}),o.jsx(h.ChaiBuilderEditor,{siteWideUsage:$??{},flags:e.flags?{...e.flags,librarySite:Ps}:{librarySite:Ps},gotoPage:Q,collections:l??[],getBlockAsyncProps:le,pageExternalData:A,themePresets:e.themePresets??[],pageId:T==null?void 0:T.id,loading:w,fallbackLang:s,languages:(f==null?void 0:f.languages)||[],brandingOptions:(f==null?void 0:f.theme)||{},designTokens:(f==null?void 0:f.designTokens)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!ne&&Se&&(e.autoSave??!0),autoSaveActionsCount:e.autoSaveActionsCount??10,onError:e.onError||console.error,getPartialBlockBlocks:K,getPartialBlocks:ce,blocks:w?[]:R,theme:p.cloneDeep(ve),pageTypes:a,searchPageTypeItems:rr,askAiCallBack:F,onSave:async({blocks:X,theme:Pt,needTranslations:ar,designTokens:_s})=>{if(!m)return!0;ue.current=X;const ws=[...X];await j({page:m,blocks:ws,needTranslations:ar}),ue.current=ws;const xt={};return p.isEqual(Pt,ve)||(xt.theme=Pt),p.isEqual(_s,f==null?void 0:f.designTokens)||(xt.designTokens=_s),p.isEmpty(xt)||await G({settings:xt}),!0},themePanelComponent:Ji,...nr,children:o.jsx(zi,{isFetchingPageData:Ss})}),o.jsx("div",{children:o.jsx($i,{})})]})},el=new S.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),tl=e=>{const[,t]=Bt(),[s,n]=g.useState(!1);return g.useEffect(()=>(t(p.pick(e,["apiUrl","usersApiUrl","assetsApiUrl","getPreviewUrl","getLiveUrl","topLeftCorner","onLogout","getAccessToken","websocket","getLoggedInUser","features","currentUser"])),setTimeout(()=>{n(!0)},200),()=>{n(!1),t({})}),[e,t]),s?p.get(e,"hasReactQueryProvider",!1)===!0?o.jsxs(o.Fragment,{children:[o.jsx(Bs,{...e}),o.jsx(Us,{})]}):o.jsxs(S.QueryClientProvider,{client:el,children:[o.jsx(Bs,{...e}),o.jsx(Us,{})]}):o.jsx("div",{})},sl=H.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-CoS_d3dc.cjs")));function er({data:e,onSelect:t,dataType:s="value",disabled:n=!1}){const[r,a]=H.useState(!1);return o.jsxs(h.Popover,{open:r,onOpenChange:a,children:[o.jsxs(h.Tooltip,{children:[o.jsx(h.TooltipTrigger,{asChild:!0,children:o.jsx(h.PopoverTrigger,{asChild:!0,children:o.jsx(h.Button,{size:"sm",variant:"outline",className:"h-6 w-6 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,disabled:n,children:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:o.jsx("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"#000000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),o.jsx(h.TooltipContent,{children:"Add field"})]}),r&&o.jsx(H.Suspense,{children:o.jsx(sl,{data:e,onSelect:t,dataType:s,open:r,setOpen:a})})]})}const nl=()=>{const{savePageAsync:e}=h.useSavePage(),t=S.useQueryClient(),{isLocked:s}=se();return g.useCallback(async()=>{s||await e(),t.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]})},[e,t,s])},rl=()=>{const e=S.useQueryClient();return g.useCallback(()=>{e.clear()},[e])},al=()=>{const e=L(),t=N(),{data:s}=he(),n=S.useQueryClient();return S.useMutation({mutationFn:async r=>{if(!(s!=null&&s.id))throw new Error("No active page found");return await t(`${e}`,{action:y.UPDATE_PAGE_METADATA,data:{id:s.id,metadata:r}})},onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]}),n.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]})},onError:()=>{console.error("Failed to update metadata")}})},ol=g.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager--uO8Agia.cjs"))),il=({assetId:e,assetUrl:t,onChange:s,className:n="",placeholder:r="Select an image",disabled:a=!1})=>{const{t:i}=fe.useTranslation(),[l,c]=g.useState(!1),f=()=>{a||c(!0)},d=()=>{c(!1)},u=T=>{const _=Array.isArray(T)?T[0]:T;_!=null&&_.url&&s(p.pick(_,["url","id"])),c(!1)},E=()=>{s({url:"",id:""})},m=(t==null?void 0:t.startsWith("{{"))&&(t==null?void 0:t.endsWith("}}"));return o.jsxs("div",{className:`w-full ${n}`,children:[t?o.jsxs("div",{className:"relative overflow-hidden rounded-md border",children:[m?o.jsx("div",{className:"flex h-12 items-center bg-gray-100 px-4",children:o.jsx("p",{className:"text-xs text-gray-500",children:t})}):o.jsx("img",{onClick:f,src:t,alt:i("Selected image"),className:"h-auto max-h-[100px] w-full bg-gray-100 object-contain"}),o.jsxs("div",{className:"absolute right-2 top-2 flex gap-2",children:[o.jsx(h.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white text-red-500",onClick:E,disabled:a,children:m?o.jsx(x.X,{className:"h-4 w-4"}):o.jsx(x.Trash2,{className:"h-4 w-4"})}),!m&&o.jsx(h.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white/80 hover:bg-white/90",onClick:f,disabled:a,children:o.jsx(x.ImageIcon,{className:"h-4 w-4"})})]})]}):o.jsx("div",{className:`flex cursor-pointer items-center justify-center rounded-md border border-dashed p-6 ${a?"cursor-not-allowed opacity-50":"hover:border-gray-400"}`,onClick:f,children:o.jsxs("div",{className:"flex flex-col items-center gap-2",children:[o.jsx(x.ImageIcon,{className:"h-10 w-10 text-gray-400"}),o.jsx("p",{className:"text-sm text-gray-500",children:r})]})}),o.jsx(h.Dialog,{open:l,onOpenChange:c,children:o.jsxs(h.DialogContent,{className:"h-fit w-full max-w-7xl overflow-hidden p-0",children:[o.jsxs(h.DialogHeader,{className:"hidden border-b px-4 py-2",children:[o.jsx(h.DialogTitle,{children:i("Select Image")}),o.jsx(h.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:d,children:o.jsx(x.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"h-full flex-1 p-4",children:o.jsx(g.Suspense,{children:o.jsx(ol,{close:d,onSelect:u,mode:"image",assetId:e})})})]})})]})},ll=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),os=e=>{if(!e.trim())return{isValid:!1,parsed:null,placeholders:[],error:{message:"JSON is empty"}};try{return{isValid:!0,parsed:JSON.parse(e),error:null,placeholders:[]}}catch{}const t=/{{([^{}]+)}}/g,s=[];let n=e,r;for(;(r=t.exec(e))!==null;){const a=r[0],i=r.index,l=`"__placeholder_${s.length}__"`;s.push({original:a,replaced:l,position:i}),n=n.replace(a,l)}try{return{isValid:!0,parsed:JSON.parse(n),error:null,placeholders:s}}catch(a){const i=a,l=i.message.match(/position (\d+)/),c=l?parseInt(l[1]):void 0;let f,d;if(c!==void 0){const u=n.substring(0,c).split(`
2
- `);f=u.length,d=u[u.length-1].length+1}return{isValid:!1,parsed:null,placeholders:s,error:{message:i.message,line:f,column:d,position:c}}}},cl=(e,t)=>{let n=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const i=`"__placeholder_${a}__"`,l=new RegExp(ll(i),"g");n=n.replace(l,r)}),n},ul=(e,t)=>{if(!e)return"";let s=JSON.stringify(e,null,2);const n=/{{([^{}]+)}}/g;let r;for(;(r=n.exec(s))!==null;){const a=r[1],i=p.get(t,a,null);s=s.replace(r[0],i)}return s},dl=g.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-DzG398hr.cjs"))),fl=({value:e,onChange:t,disabled:s=!1,readOnly:n=!1,placeholder:r="Enter JSON",rows:a=6,id:i="json-input",pageData:l={},handleFieldInsert:c,hasJsonLdForSelectedLang:f,copyJsonLDFromDefaultPage:d})=>{const[u,E]=g.useState("edit"),[m,T]=g.useState(null),[_,w]=g.useState(""),R=g.useRef(null),[A]=Bt(),C=i==="jsonLD"&&p.get(A,"features.sharedJsonLD",!1),I=i==="jsonLD"&&!f&&!!d;g.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const F=K=>{if(n)return;const b=K.target.value;t(b)},j=K=>{if(K.key==="Tab"){K.preventDefault();const b=K.currentTarget,G=b.selectionStart,$=b.selectionEnd;if(G!==$){const ne=e.substring(G,$).split(`
3
- `);if(K.shiftKey){const ue=ne.map(Se=>Se.startsWith(" ")?Se.substring(2):Se).join(`
4
- `),ve=e.substring(0,G)+ue+e.substring($);t(ve),setTimeout(()=>{b.selectionStart=G,b.selectionEnd=G+ue.length},0)}else{const ue=ne.map(Se=>` ${Se}`).join(`
5
- `),ve=e.substring(0,G)+ue+e.substring($);t(ve),setTimeout(()=>{b.selectionStart=G,b.selectionEnd=G+ue.length},0)}}else{const Q=e.substring(0,G)+" "+e.substring($);t(Q),setTimeout(()=>{b.selectionStart=b.selectionEnd=G+2},0)}}};g.useEffect(()=>{const K=os(e);if(K.isValid)if(T(null),K.parsed){const b=ul(K.parsed,l);w(b)}else w("");else T(K.error),w("")},[e,l]);const le=()=>{const K=os(e);if(K.isValid&&K.parsed){const b=cl(K.parsed,K.placeholders);t(b)}},ce=()=>{m!=null&&m.position&&R.current&&(R.current.focus(),R.current.setSelectionRange(m.position,m.position+1))};return o.jsx(mr.ErrorBoundary,{fallback:o.jsx("div",{children:"Some error"}),children:o.jsx("div",{className:"space-y-2",children:o.jsxs(h.Tabs,{value:u,onValueChange:E,className:"w-full",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[o.jsxs(h.TabsList,{className:"w-max",children:[o.jsxs(h.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[o.jsx(x.Code,{className:"h-4 w-4"}),o.jsx("span",{children:"Edit"})]}),o.jsxs(h.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!e.trim()||m!==null||I,children:[o.jsx(x.Eye,{className:"h-4 w-4"}),o.jsx("span",{children:"Preview"})]}),C&&o.jsxs(h.TabsTrigger,{value:"shared",className:"flex items-center gap-1",disabled:!e.trim()||m!==null,children:[o.jsx(x.Share2,{className:"h-4 w-4"}),o.jsx("span",{children:"Shared"})]})]}),I?null:u==="edit"&&!n&&o.jsx("div",{className:"flex items-center gap-2",children:o.jsx(er,{dataType:"value",data:l??{},onSelect:K=>c&&c(K,i)})})]}),o.jsxs(h.TabsContent,{value:"edit",className:"relative mt-0",children:[!I&&u==="edit"&&o.jsx(Kt,{content:"Format JSON",side:"right",showTooltip:!s&&!m,children:o.jsx(h.Button,{type:"button",variant:"outline",size:"icon",onClick:le,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||s||m!==null,children:o.jsx(x.FileCode2,{})})}),I?o.jsx("div",{className:"flex h-40 items-center justify-center rounded-md bg-black/20",children:o.jsxs("div",{className:"flex max-w-[400px] flex-col items-center gap-2 rounded-md bg-white p-4 shadow-lg",children:[o.jsx("div",{className:"max-w-xl text-center text-xs text-gray-500",children:"JSON-LD for is not added for selected language. JSON LD will be used from default language."}),o.jsxs(h.Button,{type:"button",variant:"default",size:"sm",onClick:d,children:[o.jsx(x.Plus,{}),"Copy & Edit from default language"]})]})}):o.jsx(h.Textarea,{ref:R,id:i,name:i,className:`rounded-md border border-input text-xs ${m?"border-red-500":""}`,onChange:F,onKeyDown:j,value:e,placeholder:r,rows:a,disabled:s,readOnly:n}),m&&o.jsxs(h.Alert,{variant:"destructive",className:"mt-2",children:[o.jsx(x.AlertTriangle,{className:"h-4 w-4"}),o.jsxs(h.AlertDescription,{className:"flex flex-col",children:[o.jsx("span",{className:"font-medium",children:"Invalid JSON"}),o.jsx("span",{className:"text-sm",children:m.message}),m.line&&m.column&&o.jsxs("span",{className:"text-sm",children:["Error at line ",m.line,", column ",m.column]}),o.jsx(h.Button,{type:"button",variant:"link",size:"sm",className:"mt-1 h-auto self-start p-0 text-sm",onClick:ce,children:"Show position"})]})]})]}),o.jsxs(h.TabsContent,{value:"preview",className:"mt-0",children:[o.jsx(h.Textarea,{rows:a,value:_,readOnly:!0,className:"cursor-default bg-muted font-mono text-sm"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This is how the JSON will look after placeholder substitution."})]}),C&&o.jsx(h.TabsContent,{value:"shared",className:"mt-0",children:o.jsx(g.Suspense,{children:o.jsx(dl,{})})})]})})})},hl=e=>{const t=L(),s=N();return S.useQuery({queryKey:[y.GET_CHAI_USER,e],queryFn:async()=>{const r=await s(t,{action:y.GET_CHAI_USER,data:{userId:e}});return{...r,name:r.name||r.email}},enabled:!p.isEmpty(e),staleTime:"static"})};if(typeof window>"u")throw new Error("@chaibuilder/pages is not available on the server");exports.$TRACK=Es;exports.ACTIONS=y;exports.BlurContainer=gs;exports.ChaiWebsiteBuilder=tl;exports.Dynamic=$o;exports.EVENT=Z;exports.For=To;exports.ImagePicker=il;exports.Index=Ao;exports.LANGUAGES=We;exports.LanguageSwitcher=Xs;exports.Match=xo;exports.NestedPathSelector=er;exports.PAGES_PERMISSIONS=te;exports.PAGE_STATUS=Y;exports.PageActionsDropdown=$s;exports.PermissionChecker=bt;exports.Portal=Qo;exports.Show=So;exports.SmartJsonInput=fl;exports.Switch=Po;exports.Tooltip=Kt;exports.addEventListener=Cn;exports.addNewLangAtom=tt;exports.batch=to;exports.className=bn;exports.clearDelegatedEvents=Oo;exports.convertRemToPixels=Oi;exports.createComponent=Ts;exports.createComputed=gn;exports.createContext=oo;exports.createEffect=ps;exports.createMemo=z;exports.createRenderEffect=pe;exports.createRoot=Ee;exports.createSignal=q;exports.createUniqueId=yo;exports.delegateEvents=vn;exports.deleteNestedDataByPath=Ze;exports.displayValue=Li;exports.getMutationStatusColor=Ci;exports.getPreferredColorScheme=Ri;exports.getQueryStatusColor=bi;exports.getQueryStatusColorByLabel=Ii;exports.getQueryStatusLabel=wi;exports.getSidedProp=vi;exports.insert=Ut;exports.memo=Go;exports.mergeProps=As;exports.mutationSortFns=Di;exports.navigateToPage=hs;exports.on=so;exports.onCleanup=Qe;exports.onMount=mn;exports.parseJSONWithPlaceholders=os;exports.previewUrlAtom=Jn;exports.serialize=zn;exports.setAttribute=Mt;exports.sortFns=Gi;exports.splitProps=Pn;exports.spread=In;exports.stringify=_i;exports.template=Do;exports.throwConfetti=Ct;exports.untrack=W;exports.updateNestedDataByPath=Je;exports.use=Ln;exports.useActivePage=he;exports.useAddGlobalSchema=Ia;exports.useApiUrl=L;exports.useApplySchemaToAllPages=Ga;exports.useBuilderFetch=Tr;exports.useBuilderPageData=sn;exports.useChaiAuth=Ft;exports.useChaiCurrentPage=ee;exports.useChaiUserInfo=hl;exports.useChaibuilderRealtime=Mr;exports.useChangePage=Zn;exports.useChangeSlug=la;exports.useClearAll=rl;exports.useContext=io;exports.useCreatePage=sa;exports.useCurrentPageOwner=Ys;exports.useDeleteGlobalSchema=Na;exports.useDeletePage=ra;exports.useDynamicPageSelector=Qs;exports.useFallbackLang=qt;exports.useFetch=N;exports.useGotoPage=Xn;exports.useIsLanguagePageCreated=en;exports.useLanguagePages=Te;exports.useMarkAsTemplate=oa;exports.usePageEditInfo=ls;exports.usePageLockMeta=us;exports.usePageLockStatus=se;exports.usePageToUser=cs;exports.usePageType=zs;exports.usePageTypes=ge;exports.usePagesProps=Bt;exports.usePublishPages=ms;exports.useReloadPage=nl;exports.useRemoveSchemaFromAllPages=ka;exports.useSearchParams=ie;exports.useSendRealtimeEvent=Js;exports.useTogglePageGlobalSchema=ja;exports.useTransition=ao;exports.useUnmarkAsTemplate=ia;exports.useUnpublishPage=aa;exports.useUpdateActivePageMetadata=al;exports.useUpdateGlobalSchema=La;exports.useUpdatePage=na;exports.useUpdateWebsiteSettings=nn;exports.useUserId=Tt;exports.useUserRoleAndPermissions=rn;exports.useWebsiteLanguagePages=Ur;exports.useWebsitePages=fs;exports.useWebsiteSetting=Ae;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-DF5DEvqb.cjs"),n=require("./index-WQwzsC7A.cjs"),r=require("lodash-es"),j=require("lucide-react"),c=require("react"),w=require("react-i18next"),G=require("sonner"),L=require("jotai"),k=({page:s,onClose:S})=>{const{t:a}=w.useTranslation(),[o,E]=c.useState(s.slug||""),{mutate:N,isPending:y}=n.useChangeSlug(),{data:l}=n.usePageTypes(),d=r.find(l,{key:s==null?void 0:s.pageType}),f=h=>{if(h.preventDefault(),!(s!=null&&s.primaryPage)&&Object.keys(n.LANGUAGES).some(p=>o===`/${p}`||r.startsWith(o,`/${p}/`))){G.toast.error(a("Error"),{description:a("Slugs cannot start with a language code for primary page")});return}N({...s,slug:o},{onSuccess:S})},m=(s==null?void 0:s.lang)||"";return e.jsx(i.Dialog,{open:!!s,onOpenChange:S,children:e.jsxs(i.DialogContent,{children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:a("Change Slug")}),e.jsx(i.DialogDescription,{className:"text-xs",children:e.jsxs(i.Alert,{variant:"destructive",className:"mt-2",children:[e.jsx(j.AlertCircle,{className:"h-4 w-4"}),a("Changing the slug may have impact on your SEO. Please proceed with caution.")]})})]}),e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{className:"space-y-4 py-4 text-sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{children:[e.jsxs("span",{children:[a("Type"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(d==null?void 0:d.name)||(s==null?void 0:s.pageType)]})]}),e.jsxs("div",{children:[e.jsxs("span",{children:[a("Name"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",s.name]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(i.Label,{htmlFor:"slug",className:"text-right",children:[a("Slug")," ",e.jsxs("small",{className:"font-light text-gray-500",children:[a("Slug should start with")," /",m]})]}),e.jsx(i.Input,{id:"slug",value:o,onChange:h=>{const x=h.target.value;r.startsWith(x,`/${m}`)&&E(x)},className:"col-span-3",required:!0,pattern:"^/.*",title:a("Slug must start with /"),placeholder:a("Enter page slug")})]})]}),e.jsx(i.DialogFooter,{children:e.jsx(i.Button,{type:"submit",disabled:y||!r.startsWith(o,`/${m}`)||r.isEqual(s==null?void 0:s.slug,o),children:a(y?"Changing...":"Change Slug")})})]})]})})},M=c.lazy(()=>Promise.resolve().then(()=>require("./delete-page-DxX7PFIE.cjs"))),T=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-bdSmwAVQ.cjs"))),_=()=>{const{t:s}=w.useTranslation(),S=L.useSetAtom(n.addNewLangAtom),{selectedLang:a,fallbackLang:o,setSelectedLang:E}=i.useLanguages(),{data:N,isFetching:y}=n.useLanguagePages(),{data:l}=n.useChaiCurrentPage(),{data:d}=n.usePageTypes(),f=c.useMemo(()=>{const t=d==null?void 0:d.find(g=>g.key===(l==null?void 0:l.pageType));return l!=null&&l.dynamic?t==null?void 0:t.dynamicSlug:""},[d,l==null?void 0:l.pageType,l==null?void 0:l.dynamic]),[m,h]=c.useState(null),[x,P]=c.useState(null),[p,I]=c.useState(null),{data:C}=n.useWebsiteSetting(),A=r.filter(r.get(C,"languages")||["en"],t=>!r.find(N,{lang:t})&&t!==r.get(C,"fallbackLang"));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ul",{className:"space-y-2",children:y?e.jsxs("div",{className:"w-full space-y-3 py-4",children:[e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"})]}):r.map(N,t=>{const g=t.lang,v=t.slug,b=!t.primaryPage,D=g===a;return e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:`flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${D?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>E(g),children:[e.jsxs("div",{className:"flex-1 gap-x-3",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-[13px] text-slate-800",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),r.get(n.LANGUAGES,b?o:g,g)]}),e.jsxs("div",{children:[v&&e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Slug: ",e.jsx("b",{className:"font-mono font-medium",children:f?`${v}/${f}`:v})]}),e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Name:",e.jsxs("b",{className:"font-medium",children:[" ",t.name," "]})]})]})]}),b?e.jsxs("div",{className:"flex items-center gap-x-1 text-[11px] text-orange-500",children:[e.jsx(j.StarIcon,{fill:"orange",className:"h-3 w-3"}),e.jsx("b",{children:" Primary"})]}):e.jsx("div",{className:"flex items-center gap-x-3",children:e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE,n.PAGES_PERMISSIONS.DELETE_PAGE,n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,onClick:u=>u.stopPropagation(),children:e.jsx(i.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(j.MoreHorizontal,{className:"h-4 w-4"})})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"z-[9999] text-sm",children:[e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),S({edit:!0,id:t.id,primaryPage:t.primaryPage})},children:[e.jsx(j.PencilIcon,{className:"size-3"}),s("Edit")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:(t==null?void 0:t.online)&&e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),P(t)},children:[e.jsx(j.Power,{className:"size-3"}),s("Unpublish")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.DELETE_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),h(t)},children:[e.jsx(j.TrashIcon,{className:"size-3"}),s("Delete")]})})]})]})})})]},t.id),e.jsx("div",{className:"h-1 w-full border-b"})]})})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.ADD_PAGE],children:e.jsx("div",{className:"flex w-full justify-center",children:e.jsx(i.Button,{variant:"default",size:"sm",disabled:r.isEmpty(A),onClick:()=>{S({primaryPage:l==null?void 0:l.id,edit:!1})},children:s("Add new language page")})})}),m&&e.jsx(c.Suspense,{children:e.jsx(M,{page:m,onClose:()=>h(null)})}),x&&e.jsx(c.Suspense,{children:e.jsx(T,{page:x,onClose:()=>P(null)})}),p&&e.jsx(c.Suspense,{children:e.jsx(k,{page:p,onClose:()=>I(null)})})]})};exports.default=_;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index-DF5DEvqb.cjs"),W=require("./apply-binding-KKp5PnpZ.cjs"),m=require("@radix-ui/react-icons"),Z=require("jotai"),$=require("nanoid"),o=require("react"),U=require("react-i18next"),N=require("sonner"),Q=require("tailwind-merge"),B=t=>{const n=t.trim();return n.length===0||n.length>25?!1:/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(n)},_=(t,n,i,u=!1,l)=>{const x=t.trim();return x.length===0?"":x.length>25?i("Token name must be 25 characters or less"):/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(x)?Object.entries(n).find(([c,j])=>j.name===x&&(!u||c!==l))?i("Token name already exists"):"":i("Only alphanumeric characters and hyphens allowed")},H=t=>t.replace(/\s+/g,"-"),K=o.lazy(()=>Promise.resolve().then(()=>require("./delete-design-token-DkVs1oBf.cjs"))),X=o.lazy(()=>Promise.resolve().then(()=>require("./design-token-usage-CAHzEGgJ.cjs"))),J=({tokenId:t,token:n,isDisabled:i,onEdit:u,onDelete:l})=>e.jsxs("div",{className:"group relative flex items-center justify-between overflow-hidden rounded border p-2 transition-all duration-150 hover:bg-muted/90",children:[e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",children:[e.jsx("div",{className:"text-xs font-semibold",children:n.name}),e.jsx("div",{className:"w-full max-w-52 truncate text-[10px] font-light",children:n.value})]}),e.jsxs("div",{className:"absolute right-1 top-1 flex flex-shrink-0 items-center opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:[e.jsx(o.Suspense,{fallback:null,children:e.jsx(X,{tokenId:t,tokenName:n.name,children:e.jsx(a.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 rounded-full p-0 hover:bg-primary/10 hover:text-primary",children:e.jsx(m.EyeOpenIcon,{className:"h-3 w-3"})})})}),e.jsx(a.Button,{variant:"ghost",size:"sm",onClick:()=>u(t),disabled:i,className:"h-6 w-6 rounded-full p-0 hover:bg-primary/10 hover:text-primary",children:e.jsx(m.Pencil1Icon,{className:"h-3 w-3"})}),e.jsx(o.Suspense,{fallback:null,children:e.jsx(K,{tokenName:n.name,tokenValue:n.value,onDelete:()=>l(t),children:e.jsx(a.Button,{variant:"ghost",size:"sm",disabled:i,className:"h-6 w-6 rounded-full p-0 hover:bg-destructive/10",children:e.jsx(m.TrashIcon,{className:"h-3 w-3 text-destructive"})})})})]})]}),Y=({})=>{const{t}=U.useTranslation(),[n,i]=Z.useAtom(a.chaiDesignTokensAtom),u=a.useIncrementActionsCount(),[l,x]=o.useState("view"),[v,p]=o.useState(null),[c,j]=o.useState(""),[h,k]=o.useState(""),[b,T]=o.useState(""),[y,E]=o.useState(""),[q,w]=o.useState(!1),f=o.useRef(null),A=o.useMemo(()=>Object.entries(n).filter(([,s])=>s.name.toLowerCase().includes(y.toLowerCase())||s.value.toLowerCase().includes(y.toLowerCase())),[n,y]);o.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const I=o.useCallback((s,r)=>{!v||l!=="edit"||!s.trim()||!r.trim()||!B(s)||Object.entries(n).find(([g,V])=>V.name===s.trim()&&g!==v)||(w(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{const g={...n,[v]:{name:s.trim(),value:r.trim()}};i(g),u(),w(!1)},250))},[v,l,n,i,u]),z=()=>{if(!c.trim()||!h.trim()){N.toast.error(t("Please fill in both token name and classes"));return}if(!B(c)){N.toast.error(t("Invalid design token name format"));return}if(Object.values(n).find(g=>g.name===c.trim())){N.toast.error(t("Token already exists"));return}const r=`${W.DESIGN_TOKEN_PREFIX}${$.nanoid(12)}`,d={...n,[r]:{name:c.trim(),value:h.trim()}};i(d),u(),N.toast.success(t("Token added successfully")),C()},M=s=>{const r={...n};delete r[s],i(r),u(),N.toast.success(t("Token deleted successfully"))},P=s=>{const r=n[s];r&&(p(s),j(r.name),k(r.value),T(""),x("edit"))},S=()=>{p(null),j(""),k(""),T(""),x("add")},C=()=>{f.current&&clearTimeout(f.current),p(null),j(""),k(""),T(""),w(!1),x("view")},R=s=>{const r=H(s);j(r);const d=_(r,n,t,l==="edit",v||void 0);T(d),l==="edit"&&!d&&I(r,h)},D=s=>{k(s),l==="edit"&&!b&&c.trim()&&I(c,s)},O=s=>{const r=a.orderClassesByBreakpoint(a.removeDuplicateClasses(Q.twMerge(h,s)));D(r)},L=s=>{const r=h.split(" ").filter(d=>d!==s).join(" ");D(r)},F=()=>{const s=l==="edit",r=t(s?"Edit Design Token":"Add Design Token"),d=t(s?"Update design token. Auto-saved.":"Create a reusable design token");return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-border/50 bg-muted p-1.5",children:[e.jsx(a.Button,{variant:"ghost",size:"sm",onClick:C,className:"h-6 w-6 rounded-full p-0 hover:bg-muted",children:e.jsx(m.ArrowLeftIcon,{className:"h-3 w-3"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:r}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:d})]}),s&&q&&e.jsx("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:e.jsx("div",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-primary"})})]}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(a.Label,{htmlFor:"token-name",className:"text-xs font-medium",children:t("Token Name")}),e.jsx(a.Input,{id:"token-name",placeholder:"Button-Primary",value:c,onChange:g=>R(g.target.value),className:"h-7 text-xs"}),b?e.jsx("span",{className:"text-[10px] text-destructive",children:b}):e.jsx("span",{className:"text-[10px] font-light text-muted-foreground",children:t("Button-Primary, Card-Header, Text-Large etc.")})]}),e.jsx(a.ManualClasses,{from:"designToken",classFromProps:h,onAddNew:O,onRemove:L}),!s&&e.jsxs("div",{className:"mt-3 flex items-center justify-end gap-2 pt-3",children:[e.jsx(a.Button,{variant:"outline",onClick:C,className:"h-7 text-xs",children:t("Cancel")}),e.jsx(a.Button,{onClick:z,disabled:!c.trim()||!h.trim()||!!b,className:"h-7 text-xs",children:t("Add Token")})]})]})]})},G=()=>e.jsxs(e.Fragment,{children:[Object.entries(n).length>0&&e.jsxs("div",{className:"flex items-center justify-between gap-x-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(m.MagnifyingGlassIcon,{className:"absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground"}),e.jsx(a.Input,{placeholder:t("Search tokens"),value:y,onChange:s=>E(s.target.value),className:"h-6 pl-7 text-xs"})]}),e.jsxs(a.Button,{variant:"outline",onClick:S,size:"sm",className:"h-6 border-primary text-xs text-primary hover:bg-primary/10 hover:text-primary",children:[e.jsx(m.PlusIcon,{className:"h-3 w-3"}),t("Add")]})]}),e.jsx("div",{className:"no-scrollbar flex flex-1 flex-col overflow-hidden pt-2",children:e.jsx(a.ScrollArea,{className:"h-full flex-1",children:e.jsxs("div",{className:"space-y-1",children:[Object.entries(n).length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-muted bg-muted/20 py-8",children:[e.jsx("div",{className:"mb-2 text-3xl",children:e.jsx(m.TokensIcon,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:t("No design tokens yet")}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:t("Create reusable design tokens to streamline your styling")}),e.jsxs(a.Button,{variant:"default",onClick:S,size:"sm",className:"mt-4 h-7 text-xs leading-tight",children:[e.jsx(m.PlusIcon,{className:"mr-1 h-3 w-3"}),t("Add first design token")]})]}):A.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-muted bg-muted/20 py-8",children:[e.jsx("div",{className:"mb-2",children:e.jsx(m.MagnifyingGlassIcon,{className:"h-10 w-10 text-muted-foreground"})}),e.jsx("p",{className:"mb-1 text-sm font-medium text-foreground",children:t("No tokens found")}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:t("No design tokens match your search")})]}):A.map(([s,r])=>e.jsx(J,{token:r,tokenId:s,onEdit:P,onDelete:M,isDisabled:!1},s)),e.jsx("div",{className:"h-44"})]})})})]});return e.jsx("div",{className:"flex h-full w-full flex-col",children:l==="view"?G():F()})};exports.default=Y;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index-DF5DEvqb.cjs"),b=require("./index-WQwzsC7A.cjs"),y=require("lodash-es"),d=require("lucide-react"),l=require("react"),M=require("react-i18next"),w=require("sonner"),q=1*1024*1024,A=({page:r,onClose:m})=>{const{t:s}=M.useTranslation(),[g,u]=l.useState(!1),[f,k]=l.useState(""),[c,j]=l.useState(""),[N,p]=l.useState(!1),i=l.useRef(null),I=b.useMarkAsTemplate(),{data:x}=b.usePageTypes(),h=x==null?void 0:x.find(t=>t.key===r.pageType),T=(h==null?void 0:h.name)||y.startCase(r.pageType),C=l.useCallback(t=>{var v;const o=(v=t.target.files)==null?void 0:v[0];if(o){if(o.size>q){w.toast.error(s("File too large"),{description:`${s("Maximum file size is 1MB. Selected file is")} ${(o.size/1024).toFixed(2)}KB.`}),i.current&&(i.current.value="");return}try{p(!0);const n=new FileReader;n.onloadend=()=>{j(n.result),p(!1)},n.readAsDataURL(o)}catch(n){console.error("Error reading file:",n),p(!1),w.toast.error(s("Failed to process image"),{description:n instanceof Error?n.message:s("Unknown error")})}}},[s]),D=()=>{j(""),i.current&&(i.current.value="")},F=()=>{var t;(t=i.current)==null||t.click()},S=()=>{u(!0),I.mutate({page:r,name:r.name,description:f.trim()||void 0,pageType:r.pageType,...c?{previewImage:c}:{}},{onSuccess:()=>{u(!1),m()},onError:()=>{u(!1)}})};return e.jsx(a.Dialog,{open:!0,onOpenChange:m,children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:s("Mark as template")}),e.jsxs(a.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:[s("Are you sure you want to mark this page as a template?"),e.jsx("br",{}),s("Templates can be used to create new pages with the same content.")]})]}),e.jsxs("div",{className:"mb-4 space-y-4 text-xs",children:[e.jsxs("div",{className:"space-y-3 rounded border bg-slate-50 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d.Tag,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Page Name"),":"]}),e.jsx("span",{className:"font-semibold",children:y.startCase(r.name)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d.File,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Type"),":"]}),e.jsx("span",{className:"font-semibold",children:T})]})]}),e.jsxs("div",{children:[e.jsx(a.Label,{htmlFor:"description",className:"text-xs font-medium",children:s("Description (Optional)")}),e.jsx(a.Textarea,{id:"description",placeholder:s("Describe this template's purpose"),className:"mt-1 h-24 resize-none text-xs",value:f,onChange:t=>k(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"previewImage",className:"text-xs font-medium",children:s("Preview Image (Optional)")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Input,{type:"file",id:"previewImage",ref:i,onChange:C,accept:"image/*",className:"hidden"}),e.jsx(a.Button,{type:"button",variant:"outline",onClick:F,disabled:N,className:"w-full",children:N?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),s("Uploading...")]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(d.ImageIcon,{className:"h-4 w-4"}),s("Select image")]})}),c&&e.jsx(a.Button,{type:"button",variant:"outline",size:"icon",onClick:D,children:e.jsx(d.X,{className:"h-4 w-4"})})]}),c&&e.jsx("div",{className:"aspect-video overflow-hidden rounded-md border",children:e.jsx("img",{src:c,alt:s("Preview"),className:"h-full max-h-[200px] w-full object-contain"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("max 1mb")})]})]})]}),e.jsxs(a.DialogFooter,{className:g?"pointer-events-none opacity-75":"",children:[e.jsx(a.Button,{variant:"outline",onClick:t=>{t.stopPropagation(),m()},children:s("Cancel")}),e.jsx(a.Button,{variant:"default",disabled:g,onClick:S,children:s("Mark as template")})]})]})})};exports.default=A;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),d=require("lucide-react"),v=require("react"),s=require("./index-DF5DEvqb.cjs");function p(c){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const r in c)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(c,r);Object.defineProperty(l,r,i.get?i:{enumerable:!0,get:()=>c[r]})}}return l.default=c,Object.freeze(l)}const o=p(v);function C({data:c,onSelect:l,dataType:r="value",open:i,setOpen:m}){const[u,f]=o.useState([]),[h,j]=o.useState(c);o.useEffect(()=>{i||f([]),j(c)},[c,i]);const b=e=>Array.isArray(e)?"array":typeof e=="object"&&e!==null?"object":"value",y=o.useCallback(e=>{const n=a=>r==="value"?a==="value"||a==="object":r==="array"?a==="array":a===r;e.type==="object"?(f(a=>[...a,e.key]),j(e.value)):n(e.type)&&(l([...u,e.key].join(".")),m(!1))},[r,l,u,m]),x=o.useCallback(()=>{if(u.length>0){const e=u.slice(0,-1);f(e),j(e.reduce((n,a)=>n[a],c))}},[u,c]),g=o.useMemo(()=>Object.entries(h).map(([e,n])=>({key:e,value:n,type:b(n)})).filter(e=>r==="value"?e.type==="value"||e.type==="object":r==="array"?e.type==="array"||e.type==="object":r==="object"?e.type==="object":!0),[h,r]);return t.jsx(s.PopoverContent,{className:"z-[9999] w-[200px] p-0",children:t.jsxs(s.Command,{children:[t.jsx(s.CommandInput,{className:"border-none",placeholder:"Search..."}),t.jsxs(s.CommandList,{onWheel:e=>{try{e.preventDefault();const n=e.currentTarget;n.scrollTop+=e.deltaY}catch{e.preventDefault()}},children:[t.jsx(s.CommandEmpty,{children:"No option found."}),t.jsxs(s.CommandGroup,{children:[u.length>0&&t.jsxs(s.CommandItem,{onSelect:x,className:"flex items-center text-sm",children:[t.jsx(d.ChevronLeft,{className:"mr-2 h-4 w-4"}),"Back"]}),g.map(e=>t.jsxs(s.CommandItem,{onSelect:()=>y(e),className:"flex items-center justify-between",children:[t.jsx("span",{children:e.key}),t.jsxs("div",{className:"flex items-center gap-2",children:[r==="object"&&e.type==="object"&&t.jsx(s.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 hover:bg-primary hover:text-primary-foreground",onClick:n=>{n.stopPropagation(),l([...u,e.key].join(".")),m(!1)},children:"Select"}),(e.type==="object"||e.type==="array")&&t.jsx("div",{className:"cursor-pointer rounded p-1 hover:bg-muted",children:t.jsx(d.ChevronRight,{className:"h-4 w-4 opacity-50"})})]})]},e.key))]})]})]})})}exports.default=C;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index-DF5DEvqb.cjs"),n=require("./index-WQwzsC7A.cjs"),m=require("lodash-es"),w=require("lucide-react"),x=require("react-i18next"),P=()=>{const{t}=x.useTranslation(),[l,i]=n.useSearchParams(),c=l.get("lang"),g=n.useIsLanguagePageCreated(c),{setSelectedLang:u}=a.useLanguages(),d=()=>{const r=new URLSearchParams(window.location.search);r.delete("lang");const o=r.toString(),h=`${window.location.pathname}${o?`?${o}`:""}`;window.history.pushState({},"",h),i(r),u(""),window.dispatchEvent(new PopStateEvent("popstate"))};if(g)return null;const s=m.get(n.LANGUAGES,c);return e.jsx(n.BlurContainer,{children:e.jsxs(a.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(a.CardHeader,{className:"space-y-1",children:e.jsxs(a.CardTitle,{className:"flex items-center gap-2 text-2xl",children:[e.jsx(w.LockIcon,{className:"h-6 w-6 text-yellow-500"}),t("Page missing for"),' "',s,'" ',t("language"),"."]})}),e.jsx(a.CardContent,{className:"grid gap-4",children:e.jsxs("div",{children:[t("Page is not available in the"),' "',s,'" ',t("language. Either create the page in the"),' "',s,'"',t("language or switch to the base language.")]})}),e.jsx(a.CardFooter,{children:e.jsx(a.Button,{onClick:d,className:"w-full",variant:"destructive",children:t("Switch to default language")})})]})})};exports.default=P;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-DF5DEvqb.cjs"),i=require("react"),z=require("./slug-input-C_ijLQ_X.cjs"),b=require("lodash-es"),C=require("lucide-react"),w=require("./index-WQwzsC7A.cjs"),fe=require("@tanstack/react-query"),Z=require("sonner"),ge=require("./get-seo-defaults-Cw7vFt-B.cjs");function Me({value:t,onChange:c,placeholder:j="Enter custom slug part",dynamicPattern:p,onValidationChange:o}){const[f,m]=i.useState(null),h=i.useRef(null),[g,L]=i.useState(p+t);i.useEffect(()=>{L(p+t)},[t,p]);const q=v=>{const S=v.target.value;if(!S.startsWith(p)){const O=S.replace(p,""),R=p+O;L(R),c(O);return}const l=S.substring(p.length).replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),a=(l.match(/\./g)||[]).length,x=a<=1;a>1?m("Invalid slug. Only one dot (.) is allowed in the slug"):m(null),o&&o(x);const y=p+l;L(y),c(l)},N=()=>{if(h.current){const v=h.current;setTimeout(()=>{const S=p.length;v.setSelectionRange(S,S)},0)}},W=v=>{const S=v.currentTarget;(S.selectionStart||0)<=p.length&&setTimeout(()=>{const l=p.length;S.setSelectionRange(l,l)},0)};return e.jsx("div",{children:e.jsxs("div",{className:"relative",children:[e.jsxs("p",{className:"mb-2 text-xs text-gray-500",children:[`${p}`," is a dynamic segment of slug"]}),e.jsx(n.Input,{ref:h,value:g,onChange:q,onFocus:N,onClick:W,placeholder:j,className:f?"border-red-500":""}),f&&e.jsx("div",{className:"mt-1 text-xs text-red-500",children:f})]})})}const J=({children:t,onWheel:c,...j})=>{const p=o=>{try{o.preventDefault();const f=o.currentTarget;f.scrollTop+=o.deltaY}catch{o.preventDefault()}c&&c(o)};return e.jsx(n.CommandList,{...j,onWheel:p,children:t})},se=(...t)=>t.filter(Boolean).join(" ");function Ue({pages:t,selectedParentId:c,onChange:j,className:p,id:o="parentPage",currentPage:f}){const[m,h]=i.useState(!1),[g,L]=i.useState(""),q=n.useChaiFeatureFlag("enable-add-page-dropdown");q||(p="w-full rounded-md border border-gray-300 px-3 py-2");const N=i.useMemo(()=>!t||t.length===0?[]:t.filter(x=>!b.isEmpty(x.slug)).filter(x=>x.slug!=="/").sort((x,y)=>x.slug.localeCompare(y.slug)),[t]),W=i.useMemo(()=>{if(!g.trim())return N;const a=g.toLowerCase();return N.filter(x=>x.name.toLowerCase().includes(a)||x.slug.toLowerCase().includes(a))},[N,g]),v=a=>Math.max(0,(a.match(/\//g)||[]).length-1),S=a=>"    ".repeat(a),d=a=>{if(a==="/")return"/";const x=a.split("/").filter(Boolean);if(x.length<=1){const y=x[0]||"";return`/${z.removeSlugExtension(y)}`}return`/${z.removeSlugExtension(x[x.length-1])}`},l=()=>{if(!c||c==="none")return"None";const a=N.find(x=>x.id===c);return a?`${a.name} (${d(a.slug)})`:"None"};return e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:o,className:"text-sm",children:"Parent"}),q?e.jsxs(n.Popover,{open:m,onOpenChange:h,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{id:o,variant:"outline",role:"combobox",className:se("w-full justify-between",p),"data-testid":"parent-page-selector",children:[l(),e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"relative border-none py-2",children:e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search pages...",className:"h-8 pl-8 text-xs",value:g,onChange:a=>L(a.target.value)})]})})}),e.jsxs(J,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No pages found."}),e.jsxs(n.CommandGroup,{children:[e.jsxs(n.CommandItem,{value:"none",onSelect:()=>{j(""),h(!1),L("")},className:"flex cursor-pointer items-center justify-between",children:[e.jsx("span",{children:"None"}),e.jsx(C.Check,{className:se("mr-2 h-4 w-4",c?"opacity-0":"opacity-100")})]}),W.map(a=>{const x=S(v(a.slug)),y=d(a.slug),O=e.jsxs("span",{className:"flex items-center text-sm",children:[x,a.name,e.jsxs("span",{className:"text-xs text-gray-500",children:[" (",y,")"]})]});return e.jsxs(n.CommandItem,{value:a.id,onSelect:()=>{j(a.id),h(!1),L("")},className:"flex cursor-pointer items-center justify-between whitespace-pre-wrap",children:[e.jsx("span",{children:O}),e.jsx(C.Check,{className:se("mr-2 h-4 w-4 shrink-0",c===a.id?"opacity-100":"opacity-0")})]},a.id)})]})]})]})})]}):e.jsxs("select",{id:o,value:c||"none",onChange:a=>j(a.target.value),className:p,"data-testid":"parent-page-selector",children:[e.jsx("option",{value:"none",children:"None"}),N.map(a=>{const x=v(a.slug),y=x>0?S(x):"",O=d(a.slug);return(f==null?void 0:f.id)===a.id||a.slug.startsWith(f==null?void 0:f.slug)?null:e.jsxs("option",{value:a.id,children:[y,a.name," (",O,")"]},a.id)})]})]})}const ze=(...t)=>t.filter(Boolean).join(" "),_e=({templates:t,selectedTemplateId:c,onSelectTemplate:j,isLoading:p=!1})=>{const[o,f]=i.useState(""),[m,h]=i.useState(!1),[g,L]=i.useState(""),q=n.useChaiFeatureFlag("enable-add-page-dropdown");if(i.useEffect(()=>{if(c){const d=t.find(l=>l.id===c);f((d==null?void 0:d.preview)||"")}else f("")},[c,t]),p)return e.jsx("div",{className:"flex h-fit items-center justify-center text-sm text-gray-500",children:"Loading templates..."});if(t.length===0)return null;const N={};t.forEach(d=>{const l=d.libraryName;N[l]||(N[l]=[]),N[l].push(d)});const W=Object.entries(N).reduce((d,[l,a])=>{const x=a.filter(y=>y.name.toLowerCase().includes(g.toLowerCase())||l.toLowerCase().includes(g.toLowerCase()));return x.length>0&&(d[l]=x),d},{}),v=t.find(d=>d.id===c),S=v?b.startCase(v.name):"No Template";return e.jsxs("div",{className:"space-y-4",children:[q?e.jsxs(n.Popover,{open:m,onOpenChange:h,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:"outline",role:"combobox",className:"w-full justify-between",children:[S,e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search templates...",className:"h-8 pl-8 text-xs",value:g,onChange:d=>L(d.target.value)})]})}),e.jsxs(J,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No templates found."}),Object.entries(W).map(([d,l])=>e.jsx(n.CommandGroup,{heading:d,children:l.map(a=>e.jsxs(n.CommandItem,{value:a.id,onSelect:()=>{j(a.id),h(!1),L("")},className:"flex cursor-pointer items-center justify-between",children:[b.startCase(a.name),e.jsx(C.Check,{className:ze("mr-2 h-4 w-4",c===a.id?"opacity-100":"opacity-0")})]},a.id))},d))]})]})})]}):e.jsxs("select",{className:"w-full rounded-md border border-gray-300 px-3 py-2",value:c,onChange:d=>j(d.target.value),children:[e.jsx("option",{value:"",children:"No Template"}),Object.entries(N).map(([d,l])=>e.jsx("optgroup",{label:d,children:l.map(a=>e.jsx("option",{value:a.id,children:b.startCase(a.name)},a.id))},d))]}),o&&e.jsxs("div",{className:"mt-3 overflow-hidden rounded border",children:[e.jsx("div",{className:"max-h-[200px] overflow-auto",children:e.jsx("img",{src:o,alt:"Template Preview",className:"w-full object-contain"})}),e.jsx("div",{className:"border-t bg-gray-50 p-2 text-xs text-gray-500",children:"Template preview"})]})]})},Ve=()=>{const t=w.useApiUrl(),c=w.useFetch();return fe.useQuery({queryKey:[w.ACTIONS.GET_LIBRARIES],staleTime:"static",queryFn:async()=>await c(t,{action:w.ACTIONS.GET_LIBRARIES})||[]})},$e=t=>{const c=w.useApiUrl(),j=w.useFetch();return fe.useQuery({queryKey:[w.ACTIONS.GET_TEMPLATES_BY_TYPE,t],staleTime:"static",enabled:!!t,queryFn:async()=>{const p=await j(c,{action:w.ACTIONS.GET_TEMPLATES_BY_TYPE,data:{pageType:t}});return(t?b.filter(p,{pageType:t}):p)||[]}})},Qe=t=>{const{data:c=[],isLoading:j}=$e(t),{data:p=[],isLoading:o}=Ve(),f=i.useMemo(()=>j||o?[]:c.map(h=>{const g=b.find(p,{id:h.library});return{...h,libraryName:(g==null?void 0:g.type)!=="shared"?"Site Library":(g==null?void 0:g.name)+" Library",libraryType:g==null?void 0:g.type}}),[c,p,j,o]),m=i.useMemo(()=>b.groupBy(f,"libraryName"),[f]);return{data:f,groupedData:m,isLoading:j||o}},U=(...t)=>t.filter(Boolean).join(" ");function Ye({addEditPage:t,close:c,closePanel:j}){var de,xe;const{data:p}=w.usePageTypes(),o=i.useMemo(()=>p??[],[p]),f=w.useChangePage(),m=!!(t!=null&&t.id),{data:h}=w.useWebsitePages(),{mutate:g,isPending:L}=w.useCreatePage(),{mutate:q,isPending:N}=w.useUpdatePage(),[W,v]=i.useState(null),[S,d]=i.useState(!0),[l,a]=i.useState((t==null?void 0:t.pageType)??"page"),{hasPermission:x}=n.usePermissions(),y=x(w.PAGES_PERMISSIONS.CHANGE_PAGE_TYPE),[O,R]=i.useState(!1),[je,ye]=i.useState(""),{selectedLang:ve,fallbackLang:Se}=n.useLanguages(),te=ve||Se,[_,Y]=i.useState(""),[ne,$]=i.useState(!1),ae=i.useMemo(()=>{const s=o.find(u=>u.key===l);return(s==null?void 0:s.hasSlug)===!1},[l,o]),[T,Ce]=i.useState((t==null?void 0:t.parent)??""),[G,le]=i.useState((t==null?void 0:t.name)??""),[I,re]=i.useState((t==null?void 0:t.dynamic)??!1),[F,Q]=i.useState(I?"":((t==null?void 0:t.slug)??"").split("/").pop()||""),[oe,ie]=i.useState((t==null?void 0:t.dynamicSlugCustom)??""),[ce,Ne]=i.useState(!0),[be,X]=i.useState(!1),[P,we]=i.useState(""),{data:ue,isLoading:ke}=Qe(l),V=L||N,me=n.useChaiFeatureFlag("enable-add-page-dropdown"),E=i.useMemo(()=>!m||!(t!=null&&t.id)||!h?null:h.find(s=>s.id===t.id),[m,t==null?void 0:t.id,h]),Le=(E==null?void 0:E.online)||!1,Te=i.useMemo(()=>!m||!(t!=null&&t.id)||!h?!1:h.some(s=>s.parent===t.id),[m,t==null?void 0:t.id,h]),r=o.find(s=>s.key===l),M=s=>{if(m&&l!==s){ye(s),R(!0),Y(""),$(!1);return}a(s),Y(""),$(!1)},he=()=>{a(je),R(!1),re(!1)},De=s=>{re(s),s?Q(""):ie("")},Ie=s=>{if(Ce(s),s&&s!=="none"){const u=h==null?void 0:h.find(k=>k.id===s),A=(u==null?void 0:u.slug)||"";if(F.startsWith(A)){const k=F.slice(A.length).replace(/^\/+/,"");Q(k)}else Q(F.replace(/^\/+/,""))}else Q(F?`${F}`:"")},Fe=s=>{we(s)},Ae=()=>G.trim()?I&&!b.isEmpty(F)?(v("Slug must be empty when using dynamic slug"),!1):I&&!ce?(v("Dynamic slug is invalid"),!1):!0:(Z.toast.error("Name is required"),!1),Be=()=>{const s={pageType:r==null?void 0:r.key,name:G,slug:"",hasSlug:!1};m?q({id:t==null?void 0:t.id,name:G},{onSuccess:()=>{Z.toast.success((r==null?void 0:r.name)+" updated successfully"),c()}}):g(s,{onSuccess:u=>{c(),f(u.page.id,j)}})},qe=(s,u)=>{if(!s.trim()&&!I)return v("Child page slug is required"),!1;const A=z.removeSlugExtension(u),k=z.combineParentChildSlugs(A,s);return Object.keys(w.LANGUAGES).some(K=>k===`/${K}`||(k==null?void 0:k.startsWith(`/${K}/`)))?(v("Slugs cannot start with a language code for primary page"),!1):!0},Oe=(s,u)=>{const A=z.removeSlugExtension(u),k=z.combineParentChildSlugs(A,s),D={pageType:l,name:G,slug:k.replace(/\/$/,""),parent:T,dynamic:I,hasSlug:!0,template:P||void 0,tracking:{},seo:{},jsonLD:{}};if(I&&(D.dynamicSlugCustom=oe),m){const B=b.pick(D,["pageType","parent","name","slug","dynamic","dynamicSlugCustom"]);q({id:t==null?void 0:t.id,...B},{onSuccess:()=>{Z.toast.success("Page updated successfully"),c()}})}else{const B=b.find(o,{key:l});B!=null&&B.trackingDefault&&(D.tracking=B.trackingDefault);const{seo:K,jsonLD:Re}=ge.getSeoDefaults(B,te);b.set(D,"seo",K),b.set(D,"jsonLD",Re),g(D,{onSuccess:Ge=>{c(),f(Ge.page.id,j)}})}},We=()=>{const s={pageType:l,name:G,slug:F===""?"/":`/${F.replace(/\/$/,"")}`,template:P||void 0,parent:null,tracking:{}};if(m)q({id:t==null?void 0:t.id,...s},{onSuccess:()=>{Z.toast.success("Page updated successfully"),c()}});else{const u=b.find(o,{key:l});u!=null&&u.trackingDefault&&(s.tracking=u.trackingDefault);const{seo:A,jsonLD:k}=ge.getSeoDefaults(u,te);b.set(s,"seo",A),b.set(s,"jsonLD",k),g(s,{onSuccess:D=>{var B;(B=D==null?void 0:D.page)!=null&&B.id&&f(D.page.id,j),c()}})}},pe=s=>{if(s.preventDefault(),v(null),!!Ae()){if(!(r!=null&&r.hasSlug)){Be();return}if(T&&T!=="none"){const u=h==null?void 0:h.find(k=>k.id===T),A=(u==null?void 0:u.slug)||"";if(!qe(F,A))return;Oe(F,A)}else We()}},{pagesType:ee,partialsType:H}=i.useMemo(()=>{const s=u=>_?u.name.toLowerCase().includes(_.toLowerCase())||u.key.toLowerCase().includes(_.toLowerCase()):!0;return{pagesType:o.filter(u=>u.hasSlug!==!1&&s(u)),partialsType:o.filter(u=>u.hasSlug===!1&&s(u))}},[o,_]);return r!=null&&r.hasSlug?e.jsxs("form",{onSubmit:pe,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),me?e.jsxs(n.Popover,{open:ne,onOpenChange:$,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:U("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:_,onChange:s=>Y(s.target.value)})]})}),e.jsxs(J,{className:"overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No page type found."}),m?ae?e.jsx(n.CommandGroup,{heading:"Partials",children:H.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsx(n.CommandGroup,{heading:"Pages",children:ee.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsxs(e.Fragment,{children:[ee.length>0&&e.jsx(n.CommandGroup,{heading:"Pages",children:ee.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}),H.length>0&&e.jsx(n.CommandGroup,{heading:"Partials",children:H.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>M(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})]})})]}):e.jsx("select",{id:"pageType",value:l,disabled:m&&!y,onChange:s=>M(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${m&&!y?"cursor-not-allowed text-gray-500":""}`,children:m?ae?e.jsx("optgroup",{label:"Partials",children:o.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsx("optgroup",{label:"Pages",children:o.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsxs(e.Fragment,{children:[e.jsx("optgroup",{label:"Pages",children:o.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}),e.jsx("optgroup",{label:"Partials",children:o.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})]})}),O&&e.jsxs("div",{className:"mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3",children:[e.jsx("p",{className:"text-sm text-yellow-800",children:"Changing the page type may impact the page data. Are you sure you want to proceed?"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(n.Button,{variant:"outline",size:"sm",onClick:()=>R(!1),children:"Cancel"}),e.jsx(n.Button,{variant:"default",size:"sm",onClick:he,children:"Confirm"})]})]})]}),!m&&(r==null?void 0:r.hasSlug)&&ue.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(n.Label,{className:"mb-1 block text-sm",children:"Template"}),e.jsx(_e,{templates:ue,selectedTemplateId:P,onSelectTemplate:Fe,isLoading:ke})]}),e.jsx(Ue,{pages:h,selectedParentId:T,onChange:Ie,currentPage:t}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(n.Input,{id:"name",value:G,onChange:s=>le(s.target.value),required:!0,"aria-required":"true",placeholder:"Enter page name"})]}),(r==null?void 0:r.dynamicSegments)&&T&&T!=="none"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"useDynamicSlug",checked:I,onChange:s=>De(s.target.checked),className:"rounded border-gray-300"}),e.jsx(n.Label,{htmlFor:"useDynamicSlug",className:"text-sm",children:"Use Dynamic Slug"})]}),I&&e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"space-y-0.5",children:e.jsx(Me,{value:oe,onChange:ie,dynamicPattern:(r==null?void 0:r.dynamicSlug)||"{{id}}",placeholder:"Enter custom slug part (optional)",onValidationChange:Ne})})})]}),(!(r!=null&&r.dynamicSegments)||!I)&&e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"slug",className:"text-sm",children:"Slug"}),e.jsx(z.SlugInput,{value:F,onChange:s=>{var u;Q(s),m&&s!==(((u=t==null?void 0:t.slug)==null?void 0:u.split("/").pop())||"")?X(!!(Le||Te)):X(!1)},placeholder:T&&T!=="none"?"Enter page slug":l==="page"?"Leave empty for home page":"Required - e.g. your-slug",parentSlug:T&&T!=="none"?(xe=h==null?void 0:h.find(s=>s.id===T))==null?void 0:xe.slug:void 0,onValidationChange:d}),W&&e.jsx("p",{className:"text-xs text-red-500",children:W}),be&&e.jsx("div",{className:"mt-4 rounded-md border border-amber-200 bg-amber-50 p-3",children:e.jsxs("div",{className:"flex items-start space-x-2",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-amber-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-amber-800",children:"Slug Change Warning"}),e.jsx("div",{className:"mt-1 text-sm text-amber-700",children:e.jsx("p",{children:"The previous URL and any child pages will become inaccessible. You may want to set up a redirect to avoid broken links."})})]})]})})]}),e.jsx(n.Button,{disabled:V||!S&&(!(r!=null&&r.dynamicSegments)||!I)||I&&!ce,type:"submit",className:"w-full",children:m?V?"Updating...":"Update page":V?"Creating...":"Create Page"})]}):e.jsxs("form",{onSubmit:pe,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),me?e.jsxs(n.Popover,{open:ne,onOpenChange:$,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:U("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(C.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(n.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(n.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(C.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(n.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:_,onChange:s=>Y(s.target.value)})]})}),e.jsxs(J,{className:"max-h-[200px] overflow-y-auto",children:[e.jsx(n.CommandEmpty,{children:"No page type found."}),e.jsx(n.CommandGroup,{heading:"Partials",children:H.map(s=>e.jsxs(n.CommandItem,{value:s.key,onSelect:()=>{M(s.key),$(!1)},className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(C.Check,{className:U("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})})]}):e.jsx("select",{id:"pageType",value:l,disabled:m&&!y,onChange:s=>M(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${m&&!y?"cursor-not-allowed text-gray-500":""}`,children:e.jsx("optgroup",{label:"Partials",children:o.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})}),O&&e.jsxs("div",{className:"mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3",children:[e.jsx("p",{className:"text-sm text-yellow-800",children:"Changing the page type may impact the page data. Are you sure you want to proceed?"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(n.Button,{variant:"outline",size:"sm",onClick:()=>R(!1),children:"Cancel"}),e.jsx(n.Button,{variant:"default",size:"sm",onClick:he,children:"Confirm"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:(de=o.find(s=>s.key===l))==null?void 0:de.helpText})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(n.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(n.Input,{id:"name",value:G,onChange:s=>le(s.target.value),required:!0,"aria-required":"true"})]}),e.jsx(n.Button,{disabled:V,type:"submit",className:"w-full",children:m?V?"Updating...":"Update "+(r==null?void 0:r.name):V?"Creating...":"Create "+(r==null?void 0:r.name)})]})}exports.default=Ye;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./index-DF5DEvqb.cjs"),t=require("./index-WQwzsC7A.cjs"),c=require("lucide-react"),o=require("react"),C=require("react-i18next"),O=()=>{const m=t.useCurrentPageOwner(),p=t.useSendRealtimeEvent(),{setPageStatus:T}=t.usePageLockStatus(),{data:s,isFetching:j}=t.useChaiUserInfo((m==null?void 0:m.userId)||""),{pageLockMeta:d,setPageLockMeta:f}=t.usePageLockMeta(),{t:a}=C.useTranslation(),[u,i]=o.useState(""),[n,g]=o.useState({}),[N,v]=o.useState(!1),l=o.useRef(null);o.useEffect(()=>{d!=null&&d.type&&(l.current&&clearTimeout(l.current),g(d),f({}),i(""))},[d,f]);const k=()=>{u!==t.EVENT.TAKE_OVER_REQUEST&&(i(t.EVENT.TAKE_OVER_REQUEST),p(t.EVENT.TAKE_OVER_REQUEST),l.current=setTimeout(()=>i(""),2e4))},b=()=>{u!==t.EVENT.FORCE_TAKE_OVER_REQUEST&&(i(t.EVENT.FORCE_TAKE_OVER_REQUEST),p(t.EVENT.FORCE_TAKE_OVER_REQUEST),T(t.PAGE_STATUS.CHECKING),l.current=setTimeout(()=>i(""),2e4))},R=()=>{g({}),l.current&&clearTimeout(l.current),i("")},x=j?"Loading...":(s==null?void 0:s.name)||"Current editor",h=u===t.EVENT.TAKE_OVER_REQUEST,E=u===t.EVENT.FORCE_TAKE_OVER_REQUEST;return e.jsx(t.BlurContainer,{children:e.jsxs(r.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(r.CardHeader,{className:"space-y-1 border-b pb-3",children:e.jsxs(r.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(c.LockKeyhole,{className:"h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500"}),e.jsx("span",{children:a("Page Locked for Editing")})]})}),e.jsxs(r.CardContent,{className:"space-y-4 p-4",children:[e.jsxs("div",{className:"relative rounded-md border border-green-500 px-2 pb-2 pt-4",children:[e.jsx("div",{className:"absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white",children:"Current Editor"}),e.jsxs("div",{className:"flex items-center space-x-4 p-1",children:[s!=null&&s.avatar?e.jsx("img",{src:s.avatar,alt:s.name,className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}):e.jsx(c.UserIcon,{className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}),e.jsxs("div",{className:"flex-1 space-y-0",children:[e.jsx("div",{className:"truncate font-medium leading-tight text-black",children:x}),(s==null?void 0:s.email)&&e.jsx("p",{className:"truncate text-sm leading-tight text-muted-foreground",children:s.email})]})]})]}),((n==null?void 0:n.type)===t.EVENT.TAKE_OVER_REJECTED||(n==null?void 0:n.type)===t.EVENT.FORCE_TAKE_OVER_REQUEST)&&e.jsx("section",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-x-2 rounded border border-red-500 bg-red-500/10 py-2 pl-3 pr-2 text-sm font-medium text-red-500",children:[e.jsxs("div",{className:"flex items-start gap-x-2",children:[e.jsx(c.AlertCircleIcon,{className:"mt-px flex h-4 w-4 shrink-0"}),e.jsxs("div",{className:"font-light leading-tight",children:[e.jsx("span",{className:"font-medium",children:(s==null?void 0:s.name)||"The current editor"}),(n==null?void 0:n.type)===t.EVENT.TAKE_OVER_REJECTED?" rejected your take over request.":" forcefully took over this page."]})]}),e.jsx(r.Button,{size:"icon",variant:"ghost",onClick:R,className:"flex-shrink-0",children:e.jsx(c.X,{className:"h-4 w-4"})})]})})]}),e.jsx(r.CardFooter,{className:"flex flex-col gap-3 border-t pt-3",children:e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("Take Over Options")}),e.jsxs("div",{className:"rounded-md border bg-muted/40 p-3",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("p",{className:"text-sm font-medium",children:a("Take Over Request:")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a("Send a request to {{currentEditorName}} asking them to release the page. They can accept or decline your request.",{currentEditorName:x})})]}),e.jsxs(r.Button,{disabled:h,variant:"default",onClick:k,className:"mt-3 w-full gap-2",children:[e.jsx(c.Edit,{className:"h-4 w-4"}),h?"Take over request sent":"Send Take Over Request"]}),h&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:a("Request sent. If no response, try again or use force take over.")})]}),e.jsx(r.Accordion,{type:"single",collapsible:!0,className:"w-full",children:e.jsxs(r.AccordionItem,{value:"force-takeover",className:"rounded-md border border-destructive/40 bg-destructive/5",children:[e.jsx(r.AccordionTrigger,{className:"px-3 py-2 hover:no-underline",children:e.jsx("div",{className:"flex items-center gap-2 text-left",children:e.jsxs("div",{children:[e.jsxs("p",{className:"flex items-center gap-x-2 text-sm font-medium text-destructive",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4 text-destructive"}),a("Force Take Over")]}),e.jsx("p",{className:"pl-6 text-xs font-normal leading-tight text-muted-foreground",children:a("Immediately take control (use with caution)")})]})})}),e.jsx(r.AccordionContent,{className:"px-3 pb-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-background p-2",children:[e.jsx("input",{type:"checkbox",id:"force-takeover",checked:N,onChange:y=>v(y.target.checked),className:"mt-0.5 h-4 w-4 rounded border-gray-300"}),e.jsx("label",{htmlFor:"force-takeover",className:"flex-1 text-xs text-muted-foreground",children:a("I understand this will immediately close the editor for {{currentEditorName}}. I am using this option with caution.",{currentEditorName:x})})]}),e.jsxs(r.Button,{disabled:!N||E,variant:"destructive",onClick:b,className:"w-full gap-2",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4"}),a(E?"Take over page...":"Force Take Over")]}),E&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a("Attempting to forcefully take over this page. Please wait while we update the editing session.")})]})})]})})]})})]})})};exports.default=O;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),$=require("./index-DF5DEvqb.cjs"),f=require("./index-WQwzsC7A.cjs"),O=require("./use-page-expand-manager-B6XTvk0E.cjs"),r=require("lodash-es"),R=require("jotai"),b=require("lucide-react"),l=require("react"),ne=require("react-i18next"),Y=(e,n)=>!e||!Array.isArray(e)?[]:r.isEmpty(n)?e:r.compact(r.filter(e,a=>{const s=r.toLower(n);return r.includes(r.toLower((a==null?void 0:a.name)||""),s)||r.includes(r.toLower((a==null?void 0:a.slug)||""),s)})),re=(e,n)=>{const a=new Set,s=r.keyBy(e,"id");return n.forEach(c=>{let o=c;for(;o.parent&&s[o.parent];)a.add(o.parent),o=s[o.parent]}),Array.from(a).map(c=>s[c])},B=(e,n,a)=>r.isEmpty(n)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?B(s.children,n,a):[]};const c=s.children&&s.children.some(o=>r.includes(r.toLower(o.name||""),r.toLower(n))||r.includes(r.toLower(o.slug||""),r.toLower(n)));return{...s,shouldExpandOnSearch:c,children:s.children?B(s.children,n,a):[]}}),ae=e=>{if(!e||!e.length)return[];const n={};e.forEach(s=>{n[s.id]={...s,children:[]}});const a=[];return Object.values(n).forEach(s=>{s.parent&&n[s.parent]?n[s.parent].children.push(s):a.push(s)}),a},J=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?J(a.children):[]})),le=(e,n,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=r.compact(r.filter(e,{pageType:a}))),r.isEmpty(n))c=Y(c,n);else{const x=Y(c,n),u=re(e,x);c=r.uniqBy([...x,...u],"id")}const o=J(ae(c)),p=B(o,n,s),v=r.filter(p,x=>s(x.pageType)).sort((x,u)=>(x.name||"").localeCompare(u.name||"")),d=r.filter(p,x=>!s(x.pageType));let y=[];if(a==="all"){const x=r.keyBy(d,"pageType");y=Object.values(r.mapValues(x,(u,g)=>({...u,id:g,name:r.startCase(g),isPartialGroup:!0,children:p.filter(w=>w.pageType===g)})))}else y=d.sort((x,u)=>(x.name||"").localeCompare(u.name||""));return[...v,...y]},oe=R.atom({pageId:null,position:{x:0,y:0}}),ie=({pageId:e,children:n})=>{const[a,s]=R.useAtom(oe),c=l.useRef(null),o=a.pageId===e;l.useEffect(()=>{const d=()=>s({pageId:null,position:{x:0,y:0}});if(o)return document.addEventListener("click",d),()=>document.removeEventListener("click",d)},[o,s]);const p=d=>{d.preventDefault(),d.stopPropagation(),s({pageId:e,position:{x:d.clientX,y:d.clientY}})},v=()=>{const d=`${window.location.pathname}?page=${e}`;window.open(d,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:p,children:n}),o&&t.jsx("div",{ref:c,className:"fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",style:{top:a.position.y,left:a.position.x},children:t.jsx("div",{className:"",children:t.jsxs($.Button,{variant:"ghost",onClick:v,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(b.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},ce=({page:e})=>{var s,c;const{isExpanded:n,toggleExpanded:a}=O.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:o=>{o.stopPropagation(),a()},disabled:!((s=e==null?void 0:e.children)!=null&&s.length),className:`flex h-[calc(100%-2px)] w-5 items-center justify-center rounded text-gray-400 transition-colors hover:bg-gray-200 hover:px-1 hover:text-gray-500 ${(c=e==null?void 0:e.children)!=null&&c.length?"hover:text-blue-400":"opacity-0"}`,children:t.jsx(b.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${n?"rotate-90":""}`})})},de=({page:e,pageType:n})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(b.StarsIcon,{size:12,className:"text-yellow-400"}):n!=null&&n.icon?t.jsx("div",{className:"flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",dangerouslySetInnerHTML:{__html:n.icon}}):n!=null&&n.hasSlug?t.jsx(b.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(b.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),ue=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),me=({page:e,pageTypes:n,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:o,showUntranslatedPages:p})=>{const v=f.useUserId(),{pageToUser:d}=f.usePageToUser(),y=r.get(d,[e==null?void 0:e.id,"userId"]),{data:x}=f.useChaiUserInfo(y),u=x&&v!==y?x==null?void 0:x.name:null,g=f.useFallbackLang(),w=a===e.id,I=!!e.isTemplate,j=l.useMemo(()=>r.find(n,{key:e.pageType}),[n,e.pageType]);let h=r.get(c,e==null?void 0:e.id);h=r.get(h,"lang")===o?h:null;const E=o===g||!!h,L=(h==null?void 0:h.name)||(e==null?void 0:e.name)||"No name";let k=(h==null?void 0:h.slug)||(e==null?void 0:e.slug)||"";const C=k+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(k.startsWith("/")&&!p){const m=k.split("/").pop();k=k.endsWith(m)&&e.dynamic?"":`/${m}`}const M=l.useMemo(()=>{const m="flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]",T=`${w?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${m} ${T} ${u?"opacity-60":""}`:`${m} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,w,u]);return t.jsxs("div",{className:"group relative",children:[t.jsx(ie,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:M,children:[t.jsx(ce,{page:e}),!e.isPartialGroup&&t.jsx(ue,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&t.jsx(de,{page:e,pageType:j}),t.jsx(f.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(k||e.dynamic)&&t.jsx(f.Tooltip,{content:C,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[k,e.dynamic&&(j==null?void 0:j.dynamicSlug)&&t.jsxs("span",{className:"text-xs text-gray-500",children:["/",j==null?void 0:j.dynamicSlug,e.dynamicSlugCustom]})]})}),I&&t.jsx(f.Tooltip,{content:"Template",side:"top",children:t.jsx("span",{className:"text-blue-500",children:t.jsx(b.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!u?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(f.PageActionsDropdown,{isLanguagePage:!!h,page:h||e,setDuplicatePage:m=>s("duplicate",m),setAddEditPage:m=>s("edit",h||m),setUnpublishPage:m=>s("unpublish",m),setDeletePage:m=>s("delete",h||m),setMarkAsTemplate:m=>s("markAsTemplate",m),setUnmarkAsTemplate:m=>s("unmarkAsTemplate",m),children:t.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:t.jsx(b.MoreHorizontal,{className:"h-4 w-4",onClick:m=>m.stopPropagation()})})})}):u?t.jsx("span",{className:"duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:t.jsx(b.Lock,{className:"h-3.5 w-3.5 fill-red-200 text-red-500"})}):null]})}),t.jsx(t.Fragment,{children:u&&t.jsxs("button",{className:"absolute right-px top-1/2 flex h-6 -translate-y-1/2 items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100",children:[t.jsx(b.Edit,{size:12,className:"stroke-[3]"})," ",t.jsx("span",{className:"font-medium",children:u})," is editing this page"]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!u&&t.jsxs("button",{onClick:m=>{m.stopPropagation(),s("addLanguagePage",{language:o,page:e})},className:"absolute left-1/2 top-1 flex -translate-x-1/2 items-center gap-x-1 rounded bg-blue-500 px-2 py-0.5 text-xs text-white opacity-0 duration-200 hover:bg-blue-700 group-hover:opacity-100",children:[t.jsx(b.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",r.get(f.LANGUAGES,o)," Page"]})]})})]})},K=({pages:e,tier:n,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v})=>{const{expandedPages:d}=O.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${n*10}px`},children:e.map(y=>t.jsxs(t.Fragment,{children:[t.jsx(me,{page:y,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v}),y.children&&y.children.length>0&&(d==null?void 0:d.includes(y.id))&&t.jsx(K,{pages:y.children,tier:n+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v})]},y.id))})},xe=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-DkkRIH86.cjs"))),he=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-soZ8GAkN.cjs"))),fe=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-DxX7PFIE.cjs"))),pe=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-CaNAbXwV.cjs"))),ye=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-W3LmpiqN.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-EVvk0vmp.cjs"))),ge=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-bdSmwAVQ.cjs"))),je=({close:e})=>{const{t:n}=ne.useTranslation(),{languages:a,setSelectedLang:s}=$.useLanguages(),{data:c}=f.usePageTypes(),{data:o,isFetching:p}=f.useWebsitePages(),[v,d]=f.useSearchParams(),{updateForSelectedPage:y,expandPagesOnSearch:x}=O.usePageExpandManager(null),u=f.useFallbackLang(),g=v.get("page"),[w,I]=l.useState(""),[j,h]=l.useState(null),[E,L]=l.useState(null),[k,C]=l.useState(null),[M,m]=l.useState(null),[T,F]=l.useState(""),[G,D]=l.useState(null),[W,_]=l.useState(null),[S,Z]=l.useState(u),[ee,te]=l.useState(!1),H=R.useSetAtom(f.addNewLangAtom),q=ee&&S!==u,{data:A,isFetching:se}=f.useWebsiteLanguagePages(S),Q=l.useCallback(P=>{var i;return(i=r.find(c,{key:P}))==null?void 0:i.hasSlug},[c]),N=l.useMemo(()=>o?q?r.filter(o,P=>!(A!=null&&A[P.id])):le(o,w,T,Q):[],[o,Q,w,T,A,q]);l.useEffect(()=>{s(u)},[u,s]),l.useEffect(()=>{if(!r.isEmpty(T))return;const P=sessionStorage.getItem("pageTypeFilter")||"all";!r.isEmpty(c)&&P&&(r.find(c,{key:P})?F(P):F("all"))},[c,T]),l.useEffect(()=>{if(g&&!p&&!r.find(o,{id:g})){const i=r.find(o,{slug:"/"});if(i){const z=new URLSearchParams({page:i.id});f.navigateToPage(z,d)}else f.navigateToPage(new URLSearchParams({}),d,!0)}},[o,g,p,d]),l.useEffect(()=>{g&&!p&&!r.isEmpty(N)&&y(N,g)},[g,p,N,y]),l.useEffect(()=>{!r.isEmpty(w)&&!r.isEmpty(N)&&x(N)},[w,N,x]);const{setSelectedLang:U}=$.useLanguages(),V=l.useCallback(P=>{const i=new URLSearchParams({page:P});S!==u?(i.set("lang",S),U(S)):U(""),f.navigateToPage(i,d),e()},[e,d,U,S,u]),X=(P,i)=>{var z;if(i)switch(P){case"add":L(i);break;case"select":V(i);break;case"edit":S!==u?H({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):L(i);break;case"delete":h(i);break;case"unpublish":C(i);break;case"markAsTemplate":m(i);break;case"unmarkAsTemplate":_(i);break;case"duplicate":D(i);break;case"addLanguagePage":H({edit:!1,primaryPage:((z=i==null?void 0:i.page)==null?void 0:z.id)||"",preselectedLang:(i==null?void 0:i.language)||S});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(l.Suspense,{children:t.jsx(xe,{pages:N,search:w,setSearch:I,languages:[u,...a],selectedLanguage:S,setSelectedLanguage:Z,selectedPageType:T,setSelectedPageType:F,onAddPage:P=>X("add",P),showUntranslatedPages:q,setShowUntranslatedPages:te})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:p||se?t.jsx("div",{className:"space-y-2",children:r.map([...Array(15).keys()],P=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},P))}):r.isEmpty(N)?t.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[t.jsx(b.File,{className:"h-6 w-6 stroke-[1]"}),n("Empty List!"),t.jsx("span",{className:"font-light",children:n("Add new page to start")})]}):t.jsx(K,{tier:0,pages:N,pageTypes:c,currentPage:g||"",onClickAction:X,languagePages:A,selectedLanguage:S,showUntranslatedPages:q})})]}),E&&t.jsx(l.Suspense,{children:t.jsx(he,{closePanel:e,editPage:V,addEditPage:E,setAddEditPage:L})}),j&&t.jsx(l.Suspense,{children:t.jsx(fe,{page:j,onClose:()=>h(null)})}),k&&t.jsx(l.Suspense,{children:t.jsx(ge,{page:k,onClose:()=>C(null)})}),M&&t.jsx(l.Suspense,{children:t.jsx(ye,{page:M,onClose:()=>m(null)})}),W&&t.jsx(l.Suspense,{children:t.jsx(Pe,{page:W,onClose:()=>_(null)})}),G&&t.jsx(l.Suspense,{children:t.jsx(pe,{page:G,onClose:()=>D(null),closePanel:e})})]})};exports.default=je;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-DF5DEvqb.cjs"),j=require("./index-WQwzsC7A.cjs"),N=require("./use-page-expand-manager-B6XTvk0E.cjs"),w=require("@tanstack/react-query"),r=require("lodash-es"),d=require("lucide-react"),C=require("react"),m=require("react-i18next"),S=({selectedPageType:l,setSelectedPageType:i})=>{const{t:a}=m.useTranslation(),[n,o]=C.useState(""),{data:c}=j.usePageTypes(),h=t=>{if(!n)return!0;const x=n.toLowerCase(),p=g=>String(r.get(t,g,"")).toLowerCase().includes(x);return p("name")||p("key")},u=c.find(t=>t.key===l);return e.jsxs(s.Select,{onValueChange:i,value:l,children:[e.jsx(s.SelectTrigger,{className:`${l==="all"?"bg-gray-100/30 hover:bg-gray-100":"gap-x-1 border bg-gray-100/30 hover:bg-gray-100"} h-9 w-max min-w-[150px] overflow-hidden whitespace-nowrap rounded p-0 px-2 py-1 text-xs text-gray-600 shadow-none ring-0 focus:ring-0 [&>svg]:hidden`,children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-x-1.5",children:[e.jsx("span",{className:"max-w-[150px] overflow-hidden truncate whitespace-nowrap font-medium leading-tight",children:(u==null?void 0:u.name)||a("All")}),e.jsx(d.ListFilter,{className:`${l!=="all"?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`})]})}),e.jsxs(s.SelectContent,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white pb-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(d.Search,{strokeWidth:2,className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400"}),e.jsx(s.Input,{placeholder:a("Search page types..."),className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:n,onChange:t=>o(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(s.SelectItem,{value:"all",children:a("All")}),!r.isEmpty(r.filter(c,t=>t.hasSlug&&h(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:a("Pages")}),r.map([...r.filter(c,t=>t.hasSlug&&h(t))].sort((t,x)=>r.get(t,"name","").localeCompare(r.get(x,"name",""))),t=>e.jsx(s.SelectItem,{value:r.get(t,"key"),children:r.get(t,"name")},r.get(t,"key")))]}),!r.isEmpty(r.filter(c,t=>!t.hasSlug&&h(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:a("Partials")}),r.map([...r.filter(c,t=>!t.hasSlug&&h(t))].sort((t,x)=>r.get(t,"name","").localeCompare(r.get(x,"name",""))),t=>e.jsx(s.SelectItem,{value:r.get(t,"key"),children:r.get(t,"name")},r.get(t,"key")))]}),r.isEmpty(r.filter(c,h))&&e.jsx("div",{className:"px-3 py-2 text-center text-sm text-gray-500",children:a("No matching page types found")})]})]})},k=({search:l,setSearch:i})=>{const{t:a}=m.useTranslation();return e.jsxs("div",{className:"relative flex h-9 flex-1 items-center gap-2 rounded-md border px-2.5",children:[e.jsx("label",{htmlFor:"page-search-input",className:"sr-only",children:a("Search Pages")}),e.jsx(d.Search,{className:`${l?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground`,"aria-hidden":"true"}),e.jsx(s.Input,{id:"page-search-input",placeholder:a("Search pages"),value:l,onChange:n=>i(n.target.value),className:"border-none px-1.5 shadow-none outline-none ring-0 transition-none focus:outline-none focus:ring-0 focus-visible:ring-0",autoComplete:"off"})]})},T=({pages:l})=>{const{t:i}=m.useTranslation(),{expandAll:a,collapseAll:n,expandedPages:o}=N.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",size:"icon",onClick:()=>a(l),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsUpDown,{})})}),e.jsx(s.TooltipContent,{children:i("Expand All")})]}),e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{disabled:o.length===0,variant:"outline",size:"icon",onClick:()=>n(),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsDownUp,{})})}),e.jsx(s.TooltipContent,{children:i("Collapse All")})]})]})},y=({languages:l,selectedLanguage:i,setSelectedLanguage:a})=>{const n=j.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:l.map(o=>e.jsxs(s.Button,{variant:i===o?"default":"outline",size:"sm",className:`h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${i===o?"bg-black text-white hover:bg-black":"text-gray-500"}`,onClick:()=>a(o.toLowerCase()),children:[o===n&&e.jsx(d.Star,{size:4,className:`p-0.5 ${i===n?"fill-white":"fill-black"}`}),j.LANGUAGES[o]||""]},o))})},v=()=>{const{t:l}=m.useTranslation(),i=w.useQueryClient();return e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{size:"sm",variant:"ghost",onClick:()=>i.invalidateQueries({queryKey:[j.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(d.RefreshCw,{})})}),e.jsx(s.TooltipContent,{side:"bottom",children:l("Refresh pages list")})]})},E=({pages:l,search:i,setSearch:a,languages:n,onAddPage:o,selectedLanguage:c,setSelectedLanguage:h,selectedPageType:u,setSelectedPageType:t,showUntranslatedPages:x,setShowUntranslatedPages:p})=>{const{t:g}=m.useTranslation(),f=n.length>1;return e.jsxs("div",{className:"space-y-3 border-b border-b-gray-200 px-4 pb-1",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(S,{selectedPageType:u,setSelectedPageType:t}),e.jsx(k,{search:i,setSearch:a}),e.jsx(T,{pages:l}),e.jsxs(s.Button,{variant:"default",onClick:o,className:"rounded px-3 font-normal",children:[e.jsx(d.Plus,{strokeWidth:2,className:"stroke-white stroke-[3]"}),e.jsx("span",{className:"font-normal text-white",children:g("Add Page")})]}),!f&&e.jsx(v,{})]}),f?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(y,{languages:n,selectedLanguage:c,setSelectedLanguage:b=>{h(b),p(x&&(n==null?void 0:n[0])!==c)}}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[(n==null?void 0:n[0])!==c&&e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",onClick:()=>p(!x),className:"h-6 rounded px-3 py-1 text-xs font-normal",children:x?e.jsx(d.FilterXIcon,{}):e.jsx(d.Filter,{})})}),e.jsx(s.TooltipContent,{side:"bottom",children:g("Toggle Untranslated Pages")})]}),e.jsx(v,{})]})]}):e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=y;exports.default=E;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index-DF5DEvqb.cjs"),d=require("./index-WQwzsC7A.cjs"),N=require("@tanstack/react-query"),y=require("date-fns"),V=require("lodash-es"),p=require("lucide-react"),b=require("react");function L(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const l=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,l.get?l:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const v=L(b);function Q(s){const n=d.useApiUrl(),t=d.useFetch();return N.useQuery({queryKey:[d.ACTIONS.GET_PAGE_REVISIONS,s],queryFn:async()=>await t(n,{action:d.ACTIONS.GET_PAGE_REVISIONS,data:{pageId:s}}),enabled:!!s,refetchOnMount:!0})}const z=()=>{const s=d.useApiUrl(),n=d.useFetch(),t=N.useQueryClient();return N.useMutation({mutationFn:async l=>await n(s,{action:d.ACTIONS.DELETE_PAGE_REVISION,data:{revisionId:l}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},B=()=>{const s=d.useApiUrl(),n=d.useFetch(),t=N.useQueryClient();return N.useMutation({mutationFn:async({revisionId:l,discardCurrent:r})=>await n(s,{action:d.ACTIONS.RESTORE_PAGE_REVISION,data:{revisionId:l,discardCurrent:r}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},H=b.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-D7z4zNvv.cjs"))),g=({tag:s})=>s==="draft"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Draft"})]}):s==="live"?e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Live"})]}):s==="published"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-green-500/10 px-1.5 py-0.5 text-xs text-green-600",children:[e.jsx(p.Rocket,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Published"})]}):s==="unsaved"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-xs text-red-600",children:[e.jsx(p.Save,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Unsaved changes"})]}):e.jsx("span",{className:"rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600",children:s});function $({compare:s,setCompare:n}){const{data:t}=d.useChaiCurrentPage(),{saveState:l}=a.useSavePage(),[r]=d.usePageEditInfo();if(!t)return null;const c=!!s.find(u=>{var i;return(i=u==null?void 0:u.uid)==null?void 0:i.startsWith("draft:")}),x=s.length>=2&&!c,m=l==="UNSAVED";return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border bg-primary/5 p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-1 text-sm font-medium leading-none",children:[e.jsx(g,{tag:"draft"}),e.jsx("span",{className:"text-xs font-bold",children:"Currently editing"})]})}),e.jsx("div",{className:"flex items-center pl-2 text-[11px] text-muted-foreground",children:!V.isEmpty(r.lastSaved)&&e.jsxs("span",{children:["Last updated"," ",y.formatDistanceToNow(new Date(r.lastSaved),{addSuffix:!0})]})}),e.jsx("div",{className:"flex items-center gap-2 pt-0.5",children:m?e.jsx(g,{tag:"unsaved"}):null})]}),e.jsx(O,{checked:c,disabled:x,onChange:()=>{n(c?s.filter(u=>u.uid!==`draft:${t==null?void 0:t.id}`):[...s,{uid:`draft:${t==null?void 0:t.id}`,label:"draft",item:{createdAt:Date.now()}}])}})]})}function J(){return e.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((s,n)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(a.Skeleton,{className:"h-4 w-3/4"}),e.jsx(a.Skeleton,{className:"h-3 w-1/2"}),e.jsx(a.Skeleton,{className:"mt-1 h-5 w-20"})]}),e.jsx(a.Skeleton,{className:"h-8 w-8 rounded-full"})]},n))})}function I({revision:s,isLatest:n,onRestore:t,onDelete:l,revisionNumber:r,compare:c,setCompare:x,pageId:m}){const{data:u}=d.useChaiUserInfo(s.currentEditor),i=(u==null?void 0:u.name)||"Unknown",f=!!c.find(h=>{var j;return n?(j=h==null?void 0:h.uid)==null?void 0:j.startsWith("live"):(h==null?void 0:h.uid)===s.uid}),S=c.length>=2&&!f;return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"flex items-center gap-1 text-xs leading-none",children:[e.jsx(g,{tag:n?"live":`#${r}`}),s.type==="published"?"Published":"Draft"," by ",e.jsx("span",{className:"text-xs font-bold",children:i})]})}),e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:s.type==="published"?e.jsx(g,{tag:"published"}):e.jsx(g,{tag:"draft"})}),e.jsx("div",{className:"flex items-center text-[10px] text-muted-foreground",children:e.jsx("span",{className:"leading-tight",children:y.format(s.createdAt,"MMM d, h:mm a")})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(d.PermissionChecker,{permissions:[d.PAGES_PERMISSIONS.RESTORE_REVISION,d.PAGES_PERMISSIONS.DELETE_REVISION],children:e.jsx(W,{revision:s,onRestore:t,onDelete:l})})}),e.jsx(O,{checked:f,disabled:S,onChange:()=>{x(f?c.filter(h=>n?h.uid!==`live:${m}`:h.uid!==s.uid):[...c,{uid:n?`live:${m}`:s.uid,label:n?"live":`#${r}`,item:s}].sort((h,j)=>new Date(h.item.createdAt).getTime()-new Date(j.item.createdAt).getTime()))}})]})}function K({compare:s,setCompare:n,pageId:t}){const[l,r]=b.useState(!1),[c,x]=s;if(s.length===0)return null;const m=({tab:u})=>e.jsxs("span",{className:"flex items-center justify-between rounded border border-blue-100 p-1 font-medium",children:[e.jsx(g,{tag:u.label}),e.jsx("button",{className:"z-0 flex h-4 w-4 items-center justify-center rounded-full text-gray-400 hover:text-red-500",style:{lineHeight:1},onClick:()=>n(s.filter(i=>i.uid!==u.uid)),"aria-label":"Remove selection 1",children:e.jsx(p.X,{className:"h-3 w-3"})})]});return e.jsxs("div",{className:"mb-2 flex w-full max-w-md flex-col gap-1 rounded border bg-accent/60 p-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-xs",children:[e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"Compare"}),c&&e.jsx(m,{tab:c}),e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"with"}),x?e.jsx(m,{tab:x}):e.jsx("span",{className:"rounded border px-1 text-xs text-muted-foreground",children:"Choose another"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pb-0.5 pt-2",children:[e.jsx(a.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none text-gray-500",variant:"outline",onClick:()=>n([]),children:e.jsx("span",{children:" Clear"})}),e.jsxs(a.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none",variant:"default",onClick:()=>r(!0),disabled:s.length<2,children:[e.jsx(p.FileJson,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"pt-0.5",children:"Show JSON Diff"})]})]}),l&&(s==null?void 0:s.length)>1&&t&&e.jsx(b.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx("span",{className:"text-sm",children:"Loading diff viewer..."})}),children:e.jsx(H,{open:l,onOpenChange:r,compare:s})})]})}function O({checked:s,disabled:n,onChange:t,label:l="Compare"}){return e.jsx("div",{className:"absolute bottom-2 right-2",children:e.jsxs("label",{className:`flex cursor-pointer items-center gap-x-1 text-[11px] ${n?"opacity-50":""}`,children:[e.jsx("input",{type:"checkbox",className:"h-3 w-3 cursor-pointer rounded focus:ring-0 focus:ring-offset-0",checked:s,disabled:n,onChange:t}),e.jsx("span",{className:"select-none leading-tight",children:l})]})})}function W({revision:s,onRestore:n,onDelete:t}){return e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"ghost",size:"icon",className:"h-5 w-5",children:[e.jsx(p.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More options"})]})}),e.jsxs(a.DropdownMenuContent,{align:"end",className:"text-xs",children:[e.jsx(d.PermissionChecker,{permission:d.PAGES_PERMISSIONS.RESTORE_REVISION,children:e.jsxs(a.DropdownMenuItem,{onClick:n,className:"cursor-pointer text-sm",children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Restore this version"})]})}),e.jsx(d.PermissionChecker,{permission:d.PAGES_PERMISSIONS.DELETE_REVISION,children:s.uid!=="current"&&e.jsxs(e.Fragment,{children:[e.jsx(a.DropdownMenuSeparator,{}),e.jsxs(a.DropdownMenuItem,{onClick:t,className:"cursor-pointer text-destructive",children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Delete this version"})]})]})})]})]})}function Y({open:s,onOpenChange:n,revision:t,onRestore:l,isRestoring:r}){const{data:c}=d.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),x=(c==null?void 0:c.name)||"Unknown";return t?e.jsx(a.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(a.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Restore Revision"}),e.jsxs(a.DialogDescription,{children:["You are about to restore to revision ",t.uid.substring(0,8)," from"," ",y.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",x]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"How would you like to handle your current edits?"})}),e.jsxs(a.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(a.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>l(!1),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Saving as draft..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.CloudOff,{className:"mr-2 h-4 w-4"}),"Save as draft"]})}),e.jsx(a.Button,{variant:"default",className:"sm:flex-1",onClick:()=>l(!0),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Discarding current..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),"Discard current"]})})]})]})}):null}function X({open:s,onOpenChange:n,revision:t,onDelete:l,isDeleting:r}){const{data:c}=d.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),x=(c==null?void 0:c.name)||"Unknown";return t?e.jsx(a.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(a.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Delete Revision"}),e.jsxs(a.DialogDescription,{children:["You are about to delete revision ",t.uid.substring(0,8)," from"," ",y.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",x]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone. Are you sure you want to proceed?"})}),e.jsxs(a.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(a.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>n(!1),disabled:r,children:"Cancel"}),e.jsx(a.Button,{variant:"destructive",className:"sm:flex-1",onClick:l,disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),"Delete Revision"]})})]})]})}):null}function Z({isOpen:s}){var E,R;const[n,t]=v.useState([]),[l,r]=v.useState(null),[c,x]=v.useState(!1),[m,u]=v.useState(!1),{data:i}=d.useChaiCurrentPage(),{data:f,isFetching:S,error:h,refetch:j}=Q(i==null?void 0:i.id),{mutate:A,isPending:M}=z(),{mutate:k,isPending:T}=B(),F=N.useQueryClient(),{selectedLang:_,fallbackLang:P}=a.useLanguages(),q=_||P;b.useEffect(()=>t([]),[i==null?void 0:i.id]);const U=o=>{l&&k({revisionId:l.uid,discardCurrent:o},{onSuccess:()=>{x(!1),r(null),F.invalidateQueries({queryKey:[d.ACTIONS.GET_DRAFT_PAGE]})}})},D=o=>{r(o),x(!0)},C=o=>{r(o),u(!0)},G=()=>{l&&A(l.uid,{onSuccess:()=>{u(!1),r(null)}})};return b.useEffect(()=>{s&&j()},[s,j]),e.jsxs(e.Fragment,{children:[e.jsxs(a.SheetHeader,{children:[e.jsx(a.SheetTitle,{children:"Revision History"}),(i==null?void 0:i.createdAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Page created on ",y.format(new Date(i.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),S?e.jsx(J,{}):h?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Failed to load revisions. Please try again."}):e.jsxs("div",{className:"mt-2 flex h-full min-h-0 flex-1 flex-col space-y-2",children:[e.jsx(K,{lang:q,compare:n,setCompare:t,pageId:i==null?void 0:i.id}),e.jsx($,{compare:n,setCompare:t}),(E=f==null?void 0:f.filter(o=>o.uid==="current"))==null?void 0:E.map((o,w)=>e.jsx(I,{pageId:i==null?void 0:i.id,revision:o,isLatest:!0,onRestore:()=>D(o),onDelete:()=>C(o),revisionNumber:w,compare:n,setCompare:t},o.uid)),e.jsx(a.ScrollArea,{className:"min-h-0 flex-1",children:e.jsx("div",{className:"space-y-2",children:(R=f==null?void 0:f.filter(o=>o.uid!=="current"))==null?void 0:R.map((o,w)=>e.jsx(I,{pageId:i==null?void 0:i.id,revision:o,isLatest:o.uid==="current",onRestore:()=>D(o),onDelete:()=>C(o),revisionNumber:w+1,compare:n,setCompare:t},o.uid))})})]}),e.jsx(Y,{open:c,onOpenChange:x,revision:l,onRestore:U,isRestoring:T}),e.jsx(X,{open:m,onOpenChange:u,revision:l,onDelete:G,isDeleting:M})]})}exports.default=Z;