@chaibuilder/sdk 4.0.0-beta.2 → 4.0.0-beta.4

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-C4VFVd-q.cjs → 2SSKDMRQ-CopJgtZb.cjs} +1 -1
  2. package/dist/{2SSKDMRQ-DSnzF_1o.js → 2SSKDMRQ-Difo_1pg.js} +2 -2
  3. package/dist/{AP7HFJJL-Cxwj01Aq.js → AP7HFJJL-BPuPBqj4.js} +1 -1
  4. package/dist/{AP7HFJJL-B7YYCY9q.cjs → AP7HFJJL-DYxDgaOs.cjs} +1 -1
  5. package/dist/{IconPicker-RqVvq6G2.js → IconPicker-B2-oriq2.js} +8 -7
  6. package/dist/IconPicker-C0oycHbs.cjs +1 -0
  7. package/dist/{WDYDFRGG-b3T2SQbz.cjs → WDYDFRGG-DbejaRPK.cjs} +1 -1
  8. package/dist/{WDYDFRGG-C7aSUcjs.js → WDYDFRGG-KK8pkcW1.js} +2 -2
  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-Cu_ASKtx.cjs +1 -0
  14. package/dist/active-in-another-tab-DkR2HWI4.js +35 -0
  15. package/dist/add-new-language-page-BXuwluuU.cjs +1 -0
  16. package/dist/{add-new-language-page-D7NDABl1.js → add-new-language-page-CBY0RR6q.js} +54 -53
  17. package/dist/{add-new-page-BNfwKjRd.cjs → add-new-page-C_PzKby8.cjs} +1 -1
  18. package/dist/{add-new-page-B4hc0B-g.js → add-new-page-DJLJFLAd.js} +2 -2
  19. package/dist/{ai-panel-content-BnbURb7j.js → ai-panel-content--YM01Aly.js} +12 -11
  20. package/dist/ai-panel-content-rRmJdH7L.cjs +1 -0
  21. package/dist/{ai-panel-default-lang-oVk4TDeb.js → ai-panel-default-lang-BZl0tPYo.js} +40 -40
  22. package/dist/{ai-panel-default-lang-3tCHzab5.cjs → ai-panel-default-lang-D2zhXvKP.cjs} +2 -2
  23. package/dist/{ai-panel-other-lang-DmQ3QMDD.js → ai-panel-other-lang-Bfjk2CYZ.js} +8 -8
  24. package/dist/{ai-panel-other-lang-BBHCCSen.cjs → ai-panel-other-lang-Y4bEKHoG.cjs} +1 -1
  25. package/dist/{ai-prompt-input-DaTyfib-.js → ai-prompt-input-DueQYNf-.js} +68 -67
  26. package/dist/ai-prompt-input-N9PcYCFa.cjs +1 -0
  27. package/dist/{ai-translation-prompt-DJPe2O-n.js → ai-translation-prompt-B36F3d7K.js} +2 -2
  28. package/dist/ai-translation-prompt-IAdWMNZb.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-BzBq5xSn.js → code-display-Ck81Id9K.js} +1 -1
  32. package/dist/code-display-DloSPyPr.cjs +1 -0
  33. package/dist/{code-editor-DWWnphW9.js → code-editor-Bb7JumZy.js} +11 -10
  34. package/dist/code-editor-DQB8lAOk.cjs +1 -0
  35. package/dist/{continue-editing-in-this-client-BllU94XG.js → continue-editing-in-this-client-Dm9cCj7K.js} +10 -9
  36. package/dist/continue-editing-in-this-client-DmGFLHXw.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 +41 -39
  42. package/dist/{css-import-modal-D72a-16X.js → css-import-modal-9P_0uNa4.js} +4 -3
  43. package/dist/css-import-modal-Rh1QAVxo.cjs +13 -0
  44. package/dist/{delete-design-token-D_TLlO3I.cjs → delete-design-token-BG8yHcS5.cjs} +1 -1
  45. package/dist/{delete-design-token-Cd1ZDtqT.js → delete-design-token-COvR4G1S.js} +1 -1
  46. package/dist/{delete-page-DC8pzvWW.js → delete-page-CNucxe4P.js} +11 -10
  47. package/dist/delete-page-DAvEjHwF.cjs +1 -0
  48. package/dist/design-token-usage-CXglXgcJ.cjs +1 -0
  49. package/dist/{design-token-usage-DE4XCDdn.js → design-token-usage-MNYsFlPG.js} +14 -13
  50. package/dist/digital-asset-manager-CB5MRBcW.cjs +1 -0
  51. package/dist/{digital-asset-manager-C_gL_0YY.js → digital-asset-manager-CqCWBO0s.js} +6 -5
  52. package/dist/{duplicate-page-BoVhko2q.js → duplicate-page-BknLfqr0.js} +19 -18
  53. package/dist/duplicate-page-DzZByALW.cjs +1 -0
  54. package/dist/{dynamic-page-selector-CSndg2-y.js → dynamic-page-selector-DoW7OyUB.js} +15 -14
  55. package/dist/dynamic-page-selector-WA007Sni.cjs +1 -0
  56. package/dist/get-chai-builder-tailwind-config-BFePCEIS.cjs +1 -0
  57. package/dist/{get-chai-builder-tailwind-config-DjoVOuAf.js → get-chai-builder-tailwind-config-BXf_xLHk.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-oypq8asR.js → image-editor-CQnNtak2.js} +1 -1
  61. package/dist/{image-editor-DTspjj_c.cjs → image-editor-CqwaVxO2.cjs} +1 -1
  62. package/dist/index-C0-pgg_p.cjs +5 -0
  63. package/dist/index-C99FhuF1.cjs +160 -0
  64. package/dist/{index-BDnwJqMw.js → index-Dno42B0a.js} +716 -714
  65. package/dist/{index-S8ibZk9Q.js → index-rAcNbjk_.js} +3744 -3920
  66. package/dist/{json-diff-viewer-XX1pgabt.cjs → json-diff-viewer-CLuUHiPU.cjs} +3 -3
  67. package/dist/{json-diff-viewer-B5dr-Y_L.js → json-diff-viewer-CMvGUvJ2.js} +5 -4
  68. package/dist/{lang-panel-Cn83SRzd.js → lang-panel-CnwTb05j.js} +15 -14
  69. package/dist/lang-panel-fDCYm5Jm.cjs +1 -0
  70. package/dist/{manage-design-tokens-lP4HLS0P.js → manage-design-tokens-BsSZE9Vs.js} +12 -11
  71. package/dist/manage-design-tokens-BvH5KTJX.cjs +1 -0
  72. package/dist/mark-as-template-CpWEBJGd.cjs +1 -0
  73. package/dist/{mark-as-template-jncsjfHm.js → mark-as-template-DBLshWb5.js} +17 -16
  74. package/dist/{nested-path-selector-content-B-8LqhXI.js → nested-path-selector-content-6OBJ8LG8.js} +24 -23
  75. package/dist/nested-path-selector-content-C2sD9dkq.cjs +1 -0
  76. package/dist/no-language-page-content-BvPDdccK.cjs +1 -0
  77. package/dist/{no-language-page-content-D_zd9Rb0.js → no-language-page-content-CzENgtnu.js} +10 -9
  78. package/dist/{no-language-page-dialog-C5Ps6YYL.js → no-language-page-dialog-CbYI2cVg.js} +2 -2
  79. package/dist/{no-language-page-dialog-fXmbQO7L.cjs → no-language-page-dialog-CgW4yJBC.cjs} +1 -1
  80. package/dist/{page-creator-wCMtlE6Z.js → page-creator-Cc83uQqw.js} +113 -112
  81. package/dist/page-creator-g8GqgcKH.cjs +1 -0
  82. package/dist/{page-lock-BPCxfv9J.js → page-lock-BJUkyxdh.js} +2 -2
  83. package/dist/{page-lock-DweiYy1w.cjs → page-lock-CT7SmQqp.cjs} +1 -1
  84. package/dist/page-locked-dialog-Co5b9XIZ.cjs +1 -0
  85. package/dist/{page-locked-dialog-ByGl18_m.js → page-locked-dialog-DsEbWRed.js} +18 -15
  86. package/dist/{page-manager-new-BWFE-S-O.js → page-manager-new-5rFP5DyQ.js} +30 -29
  87. package/dist/page-manager-new-BOkJImo2.cjs +1 -0
  88. package/dist/page-manager-search-and-filter-Bfm0j1gg.cjs +1 -0
  89. package/dist/{page-manager-search-and-filter-kNJFWJ86.js → page-manager-search-and-filter-zq-LfhQ1.js} +13 -12
  90. package/dist/{page-revisions-content-Ulr8slUN.js → page-revisions-content-D38G2tJM.js} +34 -31
  91. package/dist/page-revisions-content-ag-MHBGr.cjs +1 -0
  92. package/dist/pages.cjs +1 -1
  93. package/dist/pages.d.ts +22 -23
  94. package/dist/pages.js +12 -12
  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-BiX-GMLw.cjs +1 -0
  98. package/dist/{publish-pages-content-BTPzt_m4.js → publish-pages-content-CS7f41Ac.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-BKNx2wln.cjs +1 -0
  105. package/dist/{rte-widget-modal-Rk_NW3KU.js → rte-widget-modal-D6Zik0Ta.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-BK3uTFss.js → save-to-lib-WwOzbgiF.js} +39 -38
  110. package/dist/save-to-lib-ffjCZYJ5.cjs +1 -0
  111. package/dist/sdk.css +1 -1
  112. package/dist/{selected-block-display-CU3TwIMA.js → selected-block-display-B1SG_UXw.js} +37 -36
  113. package/dist/selected-block-display-BOgnQRLF.cjs +16 -0
  114. package/dist/{seo-panel-jbzxFioc.js → seo-panel-BkOgRoWd.js} +12 -11
  115. package/dist/seo-panel-FjS1UF_y.cjs +2 -0
  116. package/dist/{shared-json-ld-BL_dv3_q.js → shared-json-ld-uka9TOgA.js} +68 -67
  117. package/dist/shared-json-ld-yJkXjENy.cjs +1 -0
  118. package/dist/slug-input-Cyd6NR6J.cjs +1 -0
  119. package/dist/{slug-input-1qwKkXhA.js → slug-input-DHLmUNrH.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-DKvKi3mM.js → take-over-request-Ca0X-qyf.js} +17 -16
  124. package/dist/take-over-request-CmpJVe9T.cjs +1 -0
  125. package/dist/{theme-panel-footer-DbMDLYGI.js → theme-panel-footer-BUXIu252.js} +11 -10
  126. package/dist/theme-panel-footer-CKO9YYwZ.cjs +1 -0
  127. package/dist/{translation-warning-modal-9wTwIy_9.js → translation-warning-modal-DrpFeI83.js} +9 -8
  128. package/dist/translation-warning-modal-pSZVKcNW.cjs +1 -0
  129. package/dist/{unmark-as-template-Dulvf7Zw.js → unmark-as-template-BMqgelv-.js} +11 -10
  130. package/dist/unmark-as-template-DF1Ms4VN.cjs +1 -0
  131. package/dist/unpublish-page-BJ0Bsvt2.js +28 -0
  132. package/dist/unpublish-page-Bsq2yEqQ.cjs +1 -0
  133. package/dist/utils.cjs +1 -1
  134. package/dist/utils.d.ts +4 -1
  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-DXE4Jnf5.js → web-preview-D6h1L2nV.js} +2 -2
  139. package/dist/web-preview-kres0aG7.cjs +1 -0
  140. package/package.json +4 -2
  141. package/dist/IconPicker-C9-ieDWm.cjs +0 -1
  142. package/dist/active-in-another-tab-Clng6zpY.cjs +0 -1
  143. package/dist/active-in-another-tab-wb8qolB8.js +0 -34
  144. package/dist/add-new-language-page-C4BuMTaN.cjs +0 -1
  145. package/dist/ai-panel-content-DPy2jgKw.cjs +0 -1
  146. package/dist/ai-prompt-input-b5ty81RB.cjs +0 -1
  147. package/dist/ai-translation-prompt-c0Q3zkT2.cjs +0 -1
  148. package/dist/apply-binding-KKp5PnpZ.cjs +0 -1
  149. package/dist/code-display-Q3_sK_Ta.cjs +0 -1
  150. package/dist/code-editor-BQZi6-FB.cjs +0 -1
  151. package/dist/continue-editing-in-this-client-D9HyD4GP.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-BSMGKA2T.cjs +0 -13
  155. package/dist/delete-page-ByQwBupJ.cjs +0 -1
  156. package/dist/design-token-usage-BqZeR1sT.cjs +0 -1
  157. package/dist/digital-asset-manager-BYLKFEYi.cjs +0 -1
  158. package/dist/duplicate-page-vdvwLQLo.cjs +0 -1
  159. package/dist/dynamic-page-selector-DdnbCuQZ.cjs +0 -1
  160. package/dist/get-chai-builder-tailwind-config-B9rCyiQo.cjs +0 -1
  161. package/dist/index-CbwxUFy_.cjs +0 -5
  162. package/dist/index-CnSjWE1P.cjs +0 -160
  163. package/dist/lang-panel-BPxex-M2.cjs +0 -1
  164. package/dist/manage-design-tokens-ConiyuPr.cjs +0 -1
  165. package/dist/mark-as-template-DYRxre1f.cjs +0 -1
  166. package/dist/nested-path-selector-content-BYtLi7mC.cjs +0 -1
  167. package/dist/no-language-page-content-DAbLq0gX.cjs +0 -1
  168. package/dist/page-creator-VWIB2VAs.cjs +0 -1
  169. package/dist/page-locked-dialog-BlbgvaG2.cjs +0 -1
  170. package/dist/page-manager-new-D0lGfNnS.cjs +0 -1
  171. package/dist/page-manager-search-and-filter-DpGMoOII.cjs +0 -1
  172. package/dist/page-revisions-content-DYxXZqmh.cjs +0 -1
  173. package/dist/publish-pages-content-D6g8GAsd.cjs +0 -1
  174. package/dist/rte-widget-modal-DrMzWWjw.cjs +0 -1
  175. package/dist/save-to-lib-DHHUO12i.cjs +0 -1
  176. package/dist/selected-block-display-DSFhddPj.cjs +0 -16
  177. package/dist/seo-panel-Dl0IDV09.cjs +0 -2
  178. package/dist/shared-json-ld-DPNkqDC1.cjs +0 -1
  179. package/dist/slug-input-YVLjtTI3.cjs +0 -1
  180. package/dist/take-over-request-DvMIg_cZ.cjs +0 -1
  181. package/dist/theme-panel-footer-BMOaPLWc.cjs +0 -1
  182. package/dist/translation-warning-modal-DjTwz75c.cjs +0 -1
  183. package/dist/unmark-as-template-CdqIJJER.cjs +0 -1
  184. package/dist/unpublish-page-BwSVBf0_.cjs +0 -1
  185. package/dist/unpublish-page-Degu5Cy9.js +0 -27
  186. package/dist/web-preview-YzKxyXft.cjs +0 -1
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./register-chai-top-bar-BqwKw4uy.cjs"),a=require("./index-C99FhuF1.cjs"),w=require("lodash-es"),o=require("react"),_=require("./slug-input-Cyd6NR6J.cjs"),N=require("lucide-react"),k=require("./index-C0-pgg_p.cjs"),je=require("@tanstack/react-query"),J=require("sonner"),fe=require("./get-seo-defaults-Cw7vFt-B.cjs");function Ue({value:t,onChange:c,placeholder:j="Enter custom slug part",dynamicPattern:p,onValidationChange:i}){const[f,m]=o.useState(null),h=o.useRef(null),[g,T]=o.useState(p+t);o.useEffect(()=>{T(p+t)},[t,p]);const O=S=>{const C=S.target.value;if(!C.startsWith(p)){const W=C.replace(p,""),G=p+W;T(G),c(W);return}const l=C.substring(p.length).replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),n=(l.match(/\./g)||[]).length,x=n<=1;n>1?m("Invalid slug. Only one dot (.) is allowed in the slug"):m(null),i&&i(x);const y=p+l;T(y),c(l)},b=()=>{if(h.current){const S=h.current;setTimeout(()=>{const C=p.length;S.setSelectionRange(C,C)},0)}},R=S=>{const C=S.currentTarget;(C.selectionStart||0)<=p.length&&setTimeout(()=>{const l=p.length;C.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(v.Input,{ref:h,value:g,onChange:O,onFocus:b,onClick:R,placeholder:j,className:f?"border-red-500":""}),f&&e.jsx("div",{className:"mt-1 text-xs text-red-500",children:f})]})})}const X=({children:t,onWheel:c,...j})=>{const p=i=>{try{i.preventDefault();const f=i.currentTarget;f.scrollTop+=i.deltaY}catch{i.preventDefault()}c&&c(i)};return e.jsx(a.CommandList,{...j,onWheel:p,children:t})},te=(...t)=>t.filter(Boolean).join(" ");function ze({pages:t,selectedParentId:c,onChange:j,className:p,id:i="parentPage",currentPage:f}){const[m,h]=o.useState(!1),[g,T]=o.useState(""),O=v.useChaiFeatureFlag("enable-add-page-dropdown");O||(p="w-full rounded-md border border-gray-300 px-3 py-2");const b=o.useMemo(()=>!t||t.length===0?[]:t.filter(x=>!w.isEmpty(x.slug)).filter(x=>x.slug!=="/").sort((x,y)=>x.slug.localeCompare(y.slug)),[t]),R=o.useMemo(()=>{if(!g.trim())return b;const n=g.toLowerCase();return b.filter(x=>x.name.toLowerCase().includes(n)||x.slug.toLowerCase().includes(n))},[b,g]),S=n=>Math.max(0,(n.match(/\//g)||[]).length-1),C=n=>"    ".repeat(n),d=n=>{if(n==="/")return"/";const x=n.split("/").filter(Boolean);if(x.length<=1){const y=x[0]||"";return`/${_.removeSlugExtension(y)}`}return`/${_.removeSlugExtension(x[x.length-1])}`},l=()=>{if(!c||c==="none")return"None";const n=b.find(x=>x.id===c);return n?`${n.name} (${d(n.slug)})`:"None"};return e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:i,className:"text-sm",children:"Parent"}),O?e.jsxs(a.Popover,{open:m,onOpenChange:h,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{id:i,variant:"outline",role:"combobox",className:te("w-full justify-between",p),"data-testid":"parent-page-selector",children:[l(),e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.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(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search pages...",className:"h-8 pl-8 text-xs",value:g,onChange:n=>T(n.target.value)})]})})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No pages found."}),e.jsxs(a.CommandGroup,{children:[e.jsxs(a.CommandItem,{value:"none",onSelect:()=>{j(""),h(!1),T("")},className:"flex cursor-pointer items-center justify-between",children:[e.jsx("span",{children:"None"}),e.jsx(N.Check,{className:te("mr-2 h-4 w-4",c?"opacity-0":"opacity-100")})]}),R.map(n=>{const x=C(S(n.slug)),y=d(n.slug),W=e.jsxs("span",{className:"flex items-center text-sm",children:[x,n.name,e.jsxs("span",{className:"text-xs text-gray-500",children:[" (",y,")"]})]});return e.jsxs(a.CommandItem,{value:n.id,onSelect:()=>{j(n.id),h(!1),T("")},className:"flex cursor-pointer items-center justify-between whitespace-pre-wrap",children:[e.jsx("span",{children:W}),e.jsx(N.Check,{className:te("mr-2 h-4 w-4 shrink-0",c===n.id?"opacity-100":"opacity-0")})]},n.id)})]})]})]})})]}):e.jsxs("select",{id:i,value:c||"none",onChange:n=>j(n.target.value),className:p,"data-testid":"parent-page-selector",children:[e.jsx("option",{value:"none",children:"None"}),b.map(n=>{const x=S(n.slug),y=x>0?C(x):"",W=d(n.slug);return(f==null?void 0:f.id)===n.id||n.slug.startsWith(f==null?void 0:f.slug)?null:e.jsxs("option",{value:n.id,children:[y,n.name," (",W,")"]},n.id)})]})]})}const _e=(...t)=>t.filter(Boolean).join(" "),Ve=({templates:t,selectedTemplateId:c,onSelectTemplate:j,isLoading:p=!1})=>{const[i,f]=o.useState(""),[m,h]=o.useState(!1),[g,T]=o.useState(""),O=v.useChaiFeatureFlag("enable-add-page-dropdown");if(o.useEffect(()=>{if(c){const d=t.find(l=>l.id===c);o.startTransition(()=>f((d==null?void 0:d.preview)||""))}else o.startTransition(()=>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 b={};t.forEach(d=>{const l=d.libraryName;b[l]||(b[l]=[]),b[l].push(d)});const R=Object.entries(b).reduce((d,[l,n])=>{const x=n.filter(y=>y.name.toLowerCase().includes(g.toLowerCase())||l.toLowerCase().includes(g.toLowerCase()));return x.length>0&&(d[l]=x),d},{}),S=t.find(d=>d.id===c),C=S?w.startCase(S.name):"No Template";return e.jsxs("div",{className:"space-y-4",children:[O?e.jsxs(a.Popover,{open:m,onOpenChange:h,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",className:"w-full justify-between",children:[C,e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.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(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search templates...",className:"h-8 pl-8 text-xs",value:g,onChange:d=>T(d.target.value)})]})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No templates found."}),Object.entries(R).map(([d,l])=>e.jsx(a.CommandGroup,{heading:d,children:l.map(n=>e.jsxs(a.CommandItem,{value:n.id,onSelect:()=>{j(n.id),h(!1),T("")},className:"flex cursor-pointer items-center justify-between",children:[w.startCase(n.name),e.jsx(N.Check,{className:_e("mr-2 h-4 w-4",c===n.id?"opacity-100":"opacity-0")})]},n.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(b).map(([d,l])=>e.jsx("optgroup",{label:d,children:l.map(n=>e.jsx("option",{value:n.id,children:w.startCase(n.name)},n.id))},d))]}),i&&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:i,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"})]})]})},$e=()=>{const t=k.useApiUrl(),c=k.useFetch();return je.useQuery({queryKey:[k.ACTIONS.GET_LIBRARIES],staleTime:"static",queryFn:async()=>await c(t,{action:k.ACTIONS.GET_LIBRARIES})||[]})},Qe=t=>{const c=k.useApiUrl(),j=k.useFetch();return je.useQuery({queryKey:[k.ACTIONS.GET_TEMPLATES_BY_TYPE,t],staleTime:"static",enabled:!!t,queryFn:async()=>{const p=await j(c,{action:k.ACTIONS.GET_TEMPLATES_BY_TYPE,data:{pageType:t}});return(t?w.filter(p,{pageType:t}):p)||[]}})},Ye=t=>{const{data:c=[],isLoading:j}=Qe(t),{data:p=[],isLoading:i}=$e(),f=o.useMemo(()=>j||i?[]:c.map(h=>{const g=w.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,i]),m=o.useMemo(()=>w.groupBy(f,"libraryName"),[f]);return{data:f,groupedData:m,isLoading:j||i}},z=(...t)=>t.filter(Boolean).join(" ");function He({addEditPage:t,close:c,closePanel:j}){var xe,ge;const{data:p}=k.usePageTypes(),i=o.useMemo(()=>p??[],[p]),f=k.useChangePage(),m=!!(t!=null&&t.id),{data:h}=k.useWebsitePages(),{mutate:g,isPending:T}=k.useCreatePage(),{mutate:O,isPending:b}=k.useUpdatePage(),[R,S]=o.useState(null),[C,d]=o.useState(!0),[l,n]=o.useState((t==null?void 0:t.pageType)??"page"),{hasPermission:x}=a.usePermissions(),y=x(k.PAGES_PERMISSIONS.CHANGE_PAGE_TYPE),[W,G]=o.useState(!1),[ye,ve]=o.useState(""),{selectedLang:Se,fallbackLang:Ce}=a.useLanguages(),ne=Se||Ce,[V,H]=o.useState(""),[ae,Q]=o.useState(!1),le=o.useMemo(()=>{const s=i.find(u=>u.key===l);return(s==null?void 0:s.hasSlug)===!1},[l,i]),[D,Ne]=o.useState((t==null?void 0:t.parent)??""),[M,re]=o.useState((t==null?void 0:t.name)??""),[F,oe]=o.useState((t==null?void 0:t.dynamic)??!1),[B,Y]=o.useState(F?"":((t==null?void 0:t.slug)??"").split("/").pop()||""),[ie,ce]=o.useState((t==null?void 0:t.dynamicSlugCustom)??""),[ue,be]=o.useState(!0),[we,P]=o.useState(!1),[E,ke]=o.useState(""),{data:me,isLoading:Le}=Ye(l),$=T||b,he=v.useChaiFeatureFlag("enable-add-page-dropdown"),ee=o.useMemo(()=>!m||!(t!=null&&t.id)||!h?null:h.find(s=>s.id===t.id),[m,t==null?void 0:t.id,h]),Te=(ee==null?void 0:ee.online)||!1,De=o.useMemo(()=>!m||!(t!=null&&t.id)||!h?!1:h.some(s=>s.parent===t.id),[m,t==null?void 0:t.id,h]),r=i.find(s=>s.key===l),U=s=>{if(m&&l!==s){ve(s),G(!0),H(""),Q(!1);return}n(s),H(""),Q(!1)},pe=()=>{n(ye),G(!1),oe(!1)},Ie=s=>{oe(s),s?Y(""):ce("")},Fe=s=>{if(Ne(s),s&&s!=="none"){const u=h==null?void 0:h.find(L=>L.id===s),q=(u==null?void 0:u.slug)||"";if(B.startsWith(q)){const L=B.slice(q.length).replace(/^\/+/,"");Y(L)}else Y(B.replace(/^\/+/,""))}else Y(B?`${B}`:"")},Be=s=>{ke(s)},qe=()=>M.trim()?F&&!w.isEmpty(B)?(S("Slug must be empty when using dynamic slug"),!1):F&&!ue?(S("Dynamic slug is invalid"),!1):!0:(J.toast.error("Name is required"),!1),Ae=()=>{const s={pageType:r==null?void 0:r.key,name:M,slug:"",hasSlug:!1};m?O({id:t==null?void 0:t.id,name:M},{onSuccess:()=>{J.toast.success((r==null?void 0:r.name)+" updated successfully"),c()}}):g(s,{onSuccess:u=>{c(),f(u.page.id,j)}})},Oe=(s,u)=>{if(!s.trim()&&!F)return S("Child page slug is required"),!1;const q=_.removeSlugExtension(u),L=_.combineParentChildSlugs(q,s);return Object.keys(k.LANGUAGES).some(Z=>L===`/${Z}`||(L==null?void 0:L.startsWith(`/${Z}/`)))?(S("Slugs cannot start with a language code for primary page"),!1):!0},We=(s,u)=>{const q=_.removeSlugExtension(u),L=_.combineParentChildSlugs(q,s),I={pageType:l,name:M,slug:L.replace(/\/$/,""),parent:D,dynamic:F,hasSlug:!0,template:E||void 0,tracking:{},seo:{},jsonLD:{}};if(F&&(I.dynamicSlugCustom=ie),m){const A=w.pick(I,["pageType","parent","name","slug","dynamic","dynamicSlugCustom"]);O({id:t==null?void 0:t.id,...A},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}})}else{const A=w.find(i,{key:l});A!=null&&A.trackingDefault&&(I.tracking=A.trackingDefault);const{seo:Z,jsonLD:Ge}=fe.getSeoDefaults(A,ne);w.set(I,"seo",Z),w.set(I,"jsonLD",Ge),g(I,{onSuccess:Me=>{c(),f(Me.page.id,j)}})}},Re=()=>{const s={pageType:l,name:M,slug:B===""?"/":`/${B.replace(/\/$/,"")}`,template:E||void 0,parent:null,tracking:{}};if(m)O({id:t==null?void 0:t.id,...s},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}});else{const u=w.find(i,{key:l});u!=null&&u.trackingDefault&&(s.tracking=u.trackingDefault);const{seo:q,jsonLD:L}=fe.getSeoDefaults(u,ne);w.set(s,"seo",q),w.set(s,"jsonLD",L),g(s,{onSuccess:I=>{var A;(A=I==null?void 0:I.page)!=null&&A.id&&f(I.page.id,j),c()}})}},de=s=>{if(s.preventDefault(),S(null),!!qe()){if(!(r!=null&&r.hasSlug)){Ae();return}if(D&&D!=="none"){const u=h==null?void 0:h.find(L=>L.id===D),q=(u==null?void 0:u.slug)||"";if(!Oe(B,q))return;We(B,q)}else Re()}},{pagesType:se,partialsType:K}=o.useMemo(()=>{const s=u=>V?u.name.toLowerCase().includes(V.toLowerCase())||u.key.toLowerCase().includes(V.toLowerCase()):!0;return{pagesType:i.filter(u=>u.hasSlug!==!1&&s(u)),partialsType:i.filter(u=>u.hasSlug===!1&&s(u))}},[i,V]);return r!=null&&r.hasSlug?e.jsxs("form",{onSubmit:de,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(a.Popover,{open:ae,onOpenChange:Q,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:z("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.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(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:V,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No page type found."}),m?le?e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsx(a.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsxs(e.Fragment,{children:[se.length>0&&e.jsx(a.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}),K.length>0&&e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("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=>U(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?le?e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsx("optgroup",{label:"Pages",children:i.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:i.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}),e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})]})}),W&&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(v.Button,{variant:"outline",size:"sm",onClick:()=>G(!1),children:"Cancel"}),e.jsx(v.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]})]}),!m&&(r==null?void 0:r.hasSlug)&&me.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(a.Label,{className:"mb-1 block text-sm",children:"Template"}),e.jsx(Ve,{templates:me,selectedTemplateId:E,onSelectTemplate:Be,isLoading:Le})]}),e.jsx(ze,{pages:h,selectedParentId:D,onChange:Fe,currentPage:t}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(v.Input,{id:"name",value:M,onChange:s=>re(s.target.value),required:!0,"aria-required":"true",placeholder:"Enter page name"})]}),(r==null?void 0:r.dynamicSegments)&&D&&D!=="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:F,onChange:s=>Ie(s.target.checked),className:"rounded border-gray-300"}),e.jsx(a.Label,{htmlFor:"useDynamicSlug",className:"text-sm",children:"Use Dynamic Slug"})]}),F&&e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"space-y-0.5",children:e.jsx(Ue,{value:ie,onChange:ce,dynamicPattern:(r==null?void 0:r.dynamicSlug)||"{{id}}",placeholder:"Enter custom slug part (optional)",onValidationChange:be})})})]}),(!(r!=null&&r.dynamicSegments)||!F)&&e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"slug",className:"text-sm",children:"Slug"}),e.jsx(_.SlugInput,{value:B,onChange:s=>{var u;Y(s),m&&s!==(((u=t==null?void 0:t.slug)==null?void 0:u.split("/").pop())||"")?P(!!(Te||De)):P(!1)},placeholder:D&&D!=="none"?"Enter page slug":l==="page"?"Leave empty for home page":"Required - e.g. your-slug",parentSlug:D&&D!=="none"?(ge=h==null?void 0:h.find(s=>s.id===D))==null?void 0:ge.slug:void 0,onValidationChange:d}),R&&e.jsx("p",{className:"text-xs text-red-500",children:R}),we&&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(v.Button,{disabled:$||!C&&(!(r!=null&&r.dynamicSegments)||!F)||F&&!ue,type:"submit",className:"w-full",children:m?$?"Updating...":"Update page":$?"Creating...":"Create Page"})]}):e.jsxs("form",{onSubmit:de,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(a.Popover,{open:ae,onOpenChange:Q,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:z("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.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(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:V,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"max-h-[200px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No page type found."}),e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>{U(s.key),Q(!1)},className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("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=>U(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:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})}),W&&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(v.Button,{variant:"outline",size:"sm",onClick:()=>G(!1),children:"Cancel"}),e.jsx(v.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:(xe=i.find(s=>s.key===l))==null?void 0:xe.helpText})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(v.Input,{id:"name",value:M,onChange:s=>re(s.target.value),required:!0,"aria-required":"true"})]}),e.jsx(v.Button,{disabled:$,type:"submit",className:"w-full",children:m?$?"Updating...":"Update "+(r==null?void 0:r.name):$?"Creating...":"Create "+(r==null?void 0:r.name)})]})}exports.default=He;
@@ -1,8 +1,8 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
- import { u as E, a as c, b as T, P as e, A as l, B as I, E as _ } from "./index-BDnwJqMw.js";
2
+ import { u as E, a as c, b as T, P as e, A as l, B as I, E as _ } from "./index-Dno42B0a.js";
3
3
  import { useQueryClient as C } from "@tanstack/react-query";
4
4
  import { useRef as p, useEffect as N, Suspense as A, lazy as s } from "react";
5
- const m = s(() => import("./take-over-request-DKvKi3mM.js")), f = s(() => import("./page-locked-dialog-ByGl18_m.js")), O = s(() => import("./active-in-another-tab-wb8qolB8.js")), S = s(() => import("./continue-editing-in-this-client-BllU94XG.js")), r = (a) => /* @__PURE__ */ n(A, { children: /* @__PURE__ */ n(a, {}) }), L = ({ isFetchingPageData: a }) => {
5
+ const m = s(() => import("./take-over-request-Ca0X-qyf.js")), f = s(() => import("./page-locked-dialog-DsEbWRed.js")), O = s(() => import("./active-in-another-tab-DkR2HWI4.js")), S = s(() => import("./continue-editing-in-this-client-Dm9cCj7K.js")), r = (a) => /* @__PURE__ */ n(A, { children: /* @__PURE__ */ n(a, {}) }), L = ({ isFetchingPageData: a }) => {
6
6
  E();
7
7
  const { pageStatus: t } = c(), { pageLockMeta: o } = T(), u = C(), i = p(t);
8
8
  if (N(() => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),e=require("./index-CbwxUFy_.cjs"),E=require("@tanstack/react-query"),r=require("react"),c=r.lazy(()=>Promise.resolve().then(()=>require("./take-over-request-DvMIg_cZ.cjs"))),o=r.lazy(()=>Promise.resolve().then(()=>require("./page-locked-dialog-BlbgvaG2.cjs"))),l=r.lazy(()=>Promise.resolve().then(()=>require("./active-in-another-tab-Clng6zpY.cjs"))),S=r.lazy(()=>Promise.resolve().then(()=>require("./continue-editing-in-this-client-D9HyD4GP.cjs"))),s=n=>u.jsx(r.Suspense,{children:u.jsx(n,{})}),A=({isFetchingPageData:n})=>{e.useChaibuilderRealtime();const{pageStatus:t}=e.usePageLockStatus(),{pageLockMeta:a}=e.usePageLockMeta(),T=E.useQueryClient(),i=r.useRef(t);if(r.useEffect(()=>{t===e.PAGE_STATUS.EDITING&&i.current!==e.PAGE_STATUS.TAKE_OVER_REQUESTED&&T.invalidateQueries({queryKey:[e.ACTIONS.GET_DRAFT_PAGE]}),i.current=t},[t,T]),n)return null;switch(t){case e.PAGE_STATUS.EDITING:case e.PAGE_STATUS.CHECKING:case e.PAGE_STATUS.FORCE_TAKE_OVER:return a.type===e.EVENT.CONTINUE_EDITING_IN_THIS_CLIENT?s(S):null;case e.PAGE_STATUS.LOCKED:return s(o);case e.PAGE_STATUS.TAKE_OVER_REQUESTED:return s(c);case e.PAGE_STATUS.ACTIVE_IN_ANOTHER_TAB:return s(l);case e.PAGE_STATUS.CONNECTION_LOST:return u.jsx(e.BlurContainer,{children:null});default:return null}};exports.default=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),e=require("./index-C0-pgg_p.cjs"),E=require("@tanstack/react-query"),r=require("react"),c=r.lazy(()=>Promise.resolve().then(()=>require("./take-over-request-CmpJVe9T.cjs"))),o=r.lazy(()=>Promise.resolve().then(()=>require("./page-locked-dialog-Co5b9XIZ.cjs"))),l=r.lazy(()=>Promise.resolve().then(()=>require("./active-in-another-tab-Cu_ASKtx.cjs"))),S=r.lazy(()=>Promise.resolve().then(()=>require("./continue-editing-in-this-client-DmGFLHXw.cjs"))),s=n=>u.jsx(r.Suspense,{children:u.jsx(n,{})}),A=({isFetchingPageData:n})=>{e.useChaibuilderRealtime();const{pageStatus:t}=e.usePageLockStatus(),{pageLockMeta:a}=e.usePageLockMeta(),T=E.useQueryClient(),i=r.useRef(t);if(r.useEffect(()=>{t===e.PAGE_STATUS.EDITING&&i.current!==e.PAGE_STATUS.TAKE_OVER_REQUESTED&&T.invalidateQueries({queryKey:[e.ACTIONS.GET_DRAFT_PAGE]}),i.current=t},[t,T]),n)return null;switch(t){case e.PAGE_STATUS.EDITING:case e.PAGE_STATUS.CHECKING:case e.PAGE_STATUS.FORCE_TAKE_OVER:return a.type===e.EVENT.CONTINUE_EDITING_IN_THIS_CLIENT?s(S):null;case e.PAGE_STATUS.LOCKED:return s(o);case e.PAGE_STATUS.TAKE_OVER_REQUESTED:return s(c);case e.PAGE_STATUS.ACTIVE_IN_ANOTHER_TAB:return s(l);case e.PAGE_STATUS.CONNECTION_LOST:return u.jsx(e.BlurContainer,{children:null});default:return null}};exports.default=A;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-C99FhuF1.cjs"),p=require("./register-chai-top-bar-BqwKw4uy.cjs"),t=require("./index-C0-pgg_p.cjs"),c=require("lucide-react"),d=require("react"),O=require("react-i18next"),_=()=>{const m=t.useCurrentPageOwner(),f=t.useSendRealtimeEvent(),{setPageStatus:j}=t.usePageLockStatus(),{data:s,isFetching:v}=t.useChaiUserInfo((m==null?void 0:m.userId)||""),{pageLockMeta:o,setPageLockMeta:g}=t.usePageLockMeta(),{t:r}=O.useTranslation(),[u,i]=d.useState(""),[a,N]=d.useState({}),[T,k]=d.useState(!1),l=d.useRef(null);d.useEffect(()=>{o!=null&&o.type&&(l.current&&clearTimeout(l.current),d.startTransition(()=>{N(o),g({}),i("")}))},[o,g]);const b=()=>{u!==t.EVENT.TAKE_OVER_REQUEST&&(i(t.EVENT.TAKE_OVER_REQUEST),f(t.EVENT.TAKE_OVER_REQUEST),l.current=setTimeout(()=>i(""),2e4))},R=()=>{u!==t.EVENT.FORCE_TAKE_OVER_REQUEST&&(i(t.EVENT.FORCE_TAKE_OVER_REQUEST),f(t.EVENT.FORCE_TAKE_OVER_REQUEST),j(t.PAGE_STATUS.CHECKING),l.current=setTimeout(()=>i(""),2e4))},y=()=>{N({}),l.current&&clearTimeout(l.current),i("")},x=v?"Loading...":(s==null?void 0:s.name)||"Current editor",h=u===t.EVENT.TAKE_OVER_REQUEST,E=u===t.EVENT.FORCE_TAKE_OVER_REQUEST;return e.jsx(t.BlurContainer,{children:e.jsxs(n.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(n.CardHeader,{className:"space-y-1 border-b pb-3",children:e.jsxs(n.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(c.LockKeyhole,{className:"h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500"}),e.jsx("span",{children:r("Page Locked for Editing")})]})}),e.jsxs(n.CardContent,{className:"space-y-4 p-4",children:[e.jsxs("div",{className:"relative rounded-md border border-green-500 px-2 pb-2 pt-4",children:[e.jsx("div",{className:"absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white",children:"Current Editor"}),e.jsxs("div",{className:"flex items-center space-x-4 p-1",children:[s!=null&&s.avatar?e.jsx("img",{src:s.avatar,alt:s.name,className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}):e.jsx(c.UserIcon,{className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}),e.jsxs("div",{className:"flex-1 space-y-0",children:[e.jsx("div",{className:"truncate font-medium leading-tight text-black",children:x}),(s==null?void 0:s.email)&&e.jsx("p",{className:"truncate text-sm leading-tight text-muted-foreground",children:s.email})]})]})]}),((a==null?void 0:a.type)===t.EVENT.TAKE_OVER_REJECTED||(a==null?void 0:a.type)===t.EVENT.FORCE_TAKE_OVER_REQUEST)&&e.jsx("section",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-x-2 rounded border border-red-500 bg-red-500/10 py-2 pl-3 pr-2 text-sm font-medium text-red-500",children:[e.jsxs("div",{className:"flex items-start gap-x-2",children:[e.jsx(c.AlertCircleIcon,{className:"mt-px flex h-4 w-4 shrink-0"}),e.jsxs("div",{className:"font-light leading-tight",children:[e.jsx("span",{className:"font-medium",children:(s==null?void 0:s.name)||"The current editor"}),(a==null?void 0:a.type)===t.EVENT.TAKE_OVER_REJECTED?" rejected your take over request.":" forcefully took over this page."]})]}),e.jsx(p.Button,{size:"icon",variant:"ghost",onClick:y,className:"flex-shrink-0",children:e.jsx(c.X,{className:"h-4 w-4"})})]})})]}),e.jsx(n.CardFooter,{className:"flex flex-col gap-3 border-t pt-3",children:e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:r("Take Over Options")}),e.jsxs("div",{className:"rounded-md border bg-muted/40 p-3",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("p",{className:"text-sm font-medium",children:r("Take Over Request:")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r("Send a request to {{currentEditorName}} asking them to release the page. They can accept or decline your request.",{currentEditorName:x})})]}),e.jsxs(p.Button,{disabled:h,variant:"default",onClick:b,className:"mt-3 w-full gap-2",children:[e.jsx(c.Edit,{className:"h-4 w-4"}),h?"Take over request sent":"Send Take Over Request"]}),h&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:r("Request sent. If no response, try again or use force take over.")})]}),e.jsx(n.Accordion,{type:"single",collapsible:!0,className:"w-full",children:e.jsxs(n.AccordionItem,{value:"force-takeover",className:"rounded-md border border-destructive/40 bg-destructive/5",children:[e.jsx(n.AccordionTrigger,{className:"px-3 py-2 hover:no-underline",children:e.jsx("div",{className:"flex items-center gap-2 text-left",children:e.jsxs("div",{children:[e.jsxs("p",{className:"flex items-center gap-x-2 text-sm font-medium text-destructive",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4 text-destructive"}),r("Force Take Over")]}),e.jsx("p",{className:"pl-6 text-xs font-normal leading-tight text-muted-foreground",children:r("Immediately take control (use with caution)")})]})})}),e.jsx(n.AccordionContent,{className:"px-3 pb-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-background p-2",children:[e.jsx("input",{type:"checkbox",id:"force-takeover",checked:T,onChange:C=>k(C.target.checked),className:"mt-0.5 h-4 w-4 rounded border-gray-300"}),e.jsx("label",{htmlFor:"force-takeover",className:"flex-1 text-xs text-muted-foreground",children:r("I understand this will immediately close the editor for {{currentEditorName}}. I am using this option with caution.",{currentEditorName:x})})]}),e.jsxs(p.Button,{disabled:!T||E,variant:"destructive",onClick:R,className:"w-full gap-2",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4"}),r(E?"Take over page...":"Force Take Over")]}),E&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r("Attempting to forcefully take over this page. Please wait while we update the editing session.")})]})})]})})]})})]})})};exports.default=_;
@@ -1,21 +1,24 @@
1
1
  import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
- import { W as O, X as w, Y as A, Z as S, B as p, _ as F, $ as K, a0 as I, a1 as U, a2 as V } from "./index-S8ibZk9Q.js";
3
- import { aq as q, ao as Q, a as P, ap as j, b as B, B as D, E as a, P as L } from "./index-BDnwJqMw.js";
2
+ import { R as O, U as w, V as A, W as S, X as F, Y as K, Z as U, _ as V, $ as I } from "./index-rAcNbjk_.js";
3
+ import { B as p } from "./register-chai-top-bar-ESJHs5s-.js";
4
+ import { aq as q, ao as Q, a as P, ap as j, b as B, B as D, E as a, P as L } from "./index-Dno42B0a.js";
4
5
  import { LockKeyhole as G, UserIcon as H, AlertCircleIcon as J, X, Edit as z, ShieldAlert as v } from "lucide-react";
5
- import { useState as f, useRef as W, useEffect as Y } from "react";
6
- import { useTranslation as Z } from "react-i18next";
7
- const ae = () => {
8
- const o = q(), x = Q(), { setPageStatus: T } = P(), { data: r, isFetching: k } = j((o == null ? void 0 : o.userId) || ""), { pageLockMeta: l, setPageLockMeta: E } = B(), { t: s } = Z(), [d, c] = f(""), [n, g] = f({}), [N, b] = f(!1), i = W(null);
6
+ import { useState as f, useRef as W, useEffect as Y, startTransition as Z } from "react";
7
+ import { useTranslation as $ } from "react-i18next";
8
+ const ie = () => {
9
+ const d = q(), x = Q(), { setPageStatus: T } = P(), { data: r, isFetching: k } = j((d == null ? void 0 : d.userId) || ""), { pageLockMeta: l, setPageLockMeta: E } = B(), { t: s } = $(), [o, i] = f(""), [n, g] = f({}), [N, b] = f(!1), c = W(null);
9
10
  Y(() => {
10
- l != null && l.type && (i.current && clearTimeout(i.current), g(l), E({}), c(""));
11
+ l != null && l.type && (c.current && clearTimeout(c.current), Z(() => {
12
+ g(l), E({}), i("");
13
+ }));
11
14
  }, [l, E]);
12
15
  const R = () => {
13
- d !== a.TAKE_OVER_REQUEST && (c(a.TAKE_OVER_REQUEST), x(a.TAKE_OVER_REQUEST), i.current = setTimeout(() => c(""), 2e4));
16
+ o !== a.TAKE_OVER_REQUEST && (i(a.TAKE_OVER_REQUEST), x(a.TAKE_OVER_REQUEST), c.current = setTimeout(() => i(""), 2e4));
14
17
  }, C = () => {
15
- d !== a.FORCE_TAKE_OVER_REQUEST && (c(a.FORCE_TAKE_OVER_REQUEST), x(a.FORCE_TAKE_OVER_REQUEST), T(L.CHECKING), i.current = setTimeout(() => c(""), 2e4));
18
+ o !== a.FORCE_TAKE_OVER_REQUEST && (i(a.FORCE_TAKE_OVER_REQUEST), x(a.FORCE_TAKE_OVER_REQUEST), T(L.CHECKING), c.current = setTimeout(() => i(""), 2e4));
16
19
  }, _ = () => {
17
- g({}), i.current && clearTimeout(i.current), c("");
18
- }, m = k ? "Loading..." : (r == null ? void 0 : r.name) || "Current editor", u = d === a.TAKE_OVER_REQUEST, h = d === a.FORCE_TAKE_OVER_REQUEST;
20
+ g({}), c.current && clearTimeout(c.current), i("");
21
+ }, m = k ? "Loading..." : (r == null ? void 0 : r.name) || "Current editor", u = o === a.TAKE_OVER_REQUEST, h = o === a.FORCE_TAKE_OVER_REQUEST;
19
22
  return /* @__PURE__ */ e(D, { children: /* @__PURE__ */ t(O, { className: "mx-auto w-full max-w-md", children: [
20
23
  /* @__PURE__ */ e(w, { className: "space-y-1 border-b pb-3", children: /* @__PURE__ */ t(A, { className: "flex items-center gap-2 text-xl", children: [
21
24
  /* @__PURE__ */ e(G, { className: "h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500" }),
@@ -76,19 +79,19 @@ const ae = () => {
76
79
  u && /* @__PURE__ */ e("p", { className: "mt-2 text-xs text-muted-foreground", children: s("Request sent. If no response, try again or use force take over.") })
77
80
  ] }),
78
81
  /* @__PURE__ */ e(K, { type: "single", collapsible: !0, className: "w-full", children: /* @__PURE__ */ t(
79
- I,
82
+ U,
80
83
  {
81
84
  value: "force-takeover",
82
85
  className: "rounded-md border border-destructive/40 bg-destructive/5",
83
86
  children: [
84
- /* @__PURE__ */ e(U, { className: "px-3 py-2 hover:no-underline", children: /* @__PURE__ */ e("div", { className: "flex items-center gap-2 text-left", children: /* @__PURE__ */ t("div", { children: [
87
+ /* @__PURE__ */ e(V, { className: "px-3 py-2 hover:no-underline", children: /* @__PURE__ */ e("div", { className: "flex items-center gap-2 text-left", children: /* @__PURE__ */ t("div", { children: [
85
88
  /* @__PURE__ */ t("p", { className: "flex items-center gap-x-2 text-sm font-medium text-destructive", children: [
86
89
  /* @__PURE__ */ e(v, { className: "h-4 w-4 text-destructive" }),
87
90
  s("Force Take Over")
88
91
  ] }),
89
92
  /* @__PURE__ */ e("p", { className: "pl-6 text-xs font-normal leading-tight text-muted-foreground", children: s("Immediately take control (use with caution)") })
90
93
  ] }) }) }),
91
- /* @__PURE__ */ e(V, { className: "px-3 pb-3", children: /* @__PURE__ */ t("div", { className: "space-y-3", children: [
94
+ /* @__PURE__ */ e(I, { className: "px-3 pb-3", children: /* @__PURE__ */ t("div", { className: "space-y-3", children: [
92
95
  /* @__PURE__ */ t("div", { className: "flex items-start gap-2 rounded-md border border-destructive/40 bg-background p-2", children: [
93
96
  /* @__PURE__ */ e(
94
97
  "input",
@@ -129,5 +132,5 @@ const ae = () => {
129
132
  ] }) });
130
133
  };
131
134
  export {
132
- ae as default
135
+ ie as default
133
136
  };
@@ -1,12 +1,13 @@
1
1
  import { jsxs as y, Fragment as z, jsx as t } from "react/jsx-runtime";
2
- import { B as ye, n as ae } from "./index-S8ibZk9Q.js";
3
- import { aA as be, aB as ge, ap as ke, k as ie, T as q, aQ as we, L as Ne, m as ve, g as Se, c as Le, av as Ae, aR as Te, aS as Q } from "./index-BDnwJqMw.js";
2
+ import { n as ae } from "./index-rAcNbjk_.js";
3
+ import { aA as ye, aB as be, ap as ge, k as ie, T as q, aQ as ke, L as we, m as Ne, g as ve, c as Se, av as Le, aR as Ae, aS as Q } from "./index-Dno42B0a.js";
4
4
  import { u as Y } from "./use-page-expand-manager-Cf4MUEJw.js";
5
- import { compact as ce, filter as B, isEmpty as S, uniqBy as Ce, keyBy as de, mapValues as Ee, startCase as Me, toLower as E, includes as D, get as R, find as $, map as Ie } from "lodash-es";
6
- import { atom as Ue, useAtom as $e, useSetAtom as Be } from "jotai";
7
- import { ExternalLink as ze, NotepadText as Fe, MoreHorizontal as Oe, Lock as je, Edit as Ge, Plus as Re, ChevronRight as De, StarsIcon as We, Hash as _e, File as ue } from "lucide-react";
8
- import { useRef as He, useEffect as I, useMemo as V, useState as N, useCallback as oe, Suspense as C, lazy as M } from "react";
9
- import { useTranslation as qe } from "react-i18next";
5
+ import { compact as ce, filter as B, isEmpty as S, uniqBy as Te, keyBy as de, mapValues as Ce, startCase as Ee, toLower as E, includes as D, get as R, find as $, map as Me } from "lodash-es";
6
+ import { atom as Ie, useAtom as Ue, useSetAtom as $e } from "jotai";
7
+ import { ExternalLink as Be, NotepadText as ze, MoreHorizontal as Fe, Lock as Oe, Edit as je, Plus as Ge, ChevronRight as Re, StarsIcon as De, Hash as We, File as ue } from "lucide-react";
8
+ import { useRef as _e, useEffect as I, useMemo as V, useState as N, useCallback as oe, Suspense as C, lazy as M } from "react";
9
+ import { useTranslation as He } from "react-i18next";
10
+ import { B as qe } from "./register-chai-top-bar-ESJHs5s-.js";
10
11
  const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
11
12
  B(e, (r) => {
12
13
  const n = E(s);
@@ -56,17 +57,17 @@ const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
56
57
  l = le(l, s);
57
58
  else {
58
59
  const u = le(l, s), c = Qe(e, u);
59
- l = Ce([...u, ...c], "id");
60
+ l = Te([...u, ...c], "id");
60
61
  }
61
62
  const a = me(Ve(l)), h = X(a, s, n), b = B(h, (u) => n(u.pageType)).sort((u, c) => (u.name || "").localeCompare(c.name || "")), i = B(h, (u) => !n(u.pageType));
62
63
  let f = [];
63
64
  if (r === "all") {
64
65
  const u = de(i, "pageType");
65
66
  f = Object.values(
66
- Ee(u, (c, p) => ({
67
+ Ce(u, (c, p) => ({
67
68
  ...c,
68
69
  id: p,
69
- name: Me(p),
70
+ name: Ee(p),
70
71
  isPartialGroup: !0,
71
72
  children: h.filter((g) => g.pageType === p)
72
73
  }))
@@ -74,11 +75,11 @@ const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
74
75
  } else
75
76
  f = i.sort((u, c) => (u.name || "").localeCompare(c.name || ""));
76
77
  return [...b, ...f];
77
- }, Ye = Ue({
78
+ }, Ye = Ie({
78
79
  pageId: null,
79
80
  position: { x: 0, y: 0 }
80
81
  }), Je = ({ pageId: e, children: s }) => {
81
- const [r, n] = $e(Ye), l = He(null), a = r.pageId === e;
82
+ const [r, n] = Ue(Ye), l = _e(null), a = r.pageId === e;
82
83
  I(() => {
83
84
  const i = () => n({ pageId: null, position: { x: 0, y: 0 } });
84
85
  if (a)
@@ -99,13 +100,13 @@ const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
99
100
  className: "fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",
100
101
  style: { top: r.position.y, left: r.position.x },
101
102
  children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ y(
102
- ye,
103
+ qe,
103
104
  {
104
105
  variant: "ghost",
105
106
  onClick: b,
106
107
  className: "w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",
107
108
  children: [
108
- /* @__PURE__ */ t(ze, { className: "h-4 w-4" }),
109
+ /* @__PURE__ */ t(Be, { className: "h-4 w-4" }),
109
110
  "Open in new tab"
110
111
  ]
111
112
  }
@@ -125,7 +126,7 @@ const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
125
126
  disabled: !((n = e == null ? void 0 : e.children) != null && n.length),
126
127
  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 ${(l = e == null ? void 0 : e.children) != null && l.length ? "hover:text-blue-400" : "opacity-0"}`,
127
128
  children: /* @__PURE__ */ t(
128
- De,
129
+ Re,
129
130
  {
130
131
  size: 12,
131
132
  className: `stroke-[4] transition-transform duration-200 ${s ? "rotate-90" : ""}`
@@ -133,13 +134,13 @@ const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
133
134
  )
134
135
  }
135
136
  );
136
- }, Ze = ({ page: e, pageType: s }) => /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center gap-x-1", children: e.dynamic ? /* @__PURE__ */ t(We, { size: 12, className: "text-yellow-400" }) : s != null && s.icon ? /* @__PURE__ */ t(
137
+ }, Ze = ({ page: e, pageType: s }) => /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center gap-x-1", children: e.dynamic ? /* @__PURE__ */ t(De, { size: 12, className: "text-yellow-400" }) : s != null && s.icon ? /* @__PURE__ */ t(
137
138
  "div",
138
139
  {
139
140
  className: "flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",
140
141
  dangerouslySetInnerHTML: { __html: s.icon }
141
142
  }
142
- ) : s != null && s.hasSlug ? /* @__PURE__ */ t(ue, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ t(_e, { size: 12, className: "stroke-[1] text-slate-500" }) }), et = ({ isOnline: e }) => /* @__PURE__ */ t("div", { className: `h-2 w-2 rounded-full ${e ? "bg-green-300" : "bg-gray-300"}` }), tt = ({
143
+ ) : s != null && s.hasSlug ? /* @__PURE__ */ t(ue, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ t(We, { size: 12, className: "stroke-[1] text-slate-500" }) }), et = ({ isOnline: e }) => /* @__PURE__ */ t("div", { className: `h-2 w-2 rounded-full ${e ? "bg-green-300" : "bg-gray-300"}` }), tt = ({
143
144
  page: e,
144
145
  pageTypes: s,
145
146
  currentPage: r,
@@ -148,7 +149,7 @@ const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
148
149
  selectedLanguage: a,
149
150
  showUntranslatedPages: h
150
151
  }) => {
151
- const b = be(), { pageToUser: i } = ge(), f = R(i, [e == null ? void 0 : e.id, "userId"]), { data: u } = ke(f), c = u && b !== f ? u == null ? void 0 : u.name : null, p = ie(), g = r === e.id, W = !!e.isTemplate, P = V(() => $(s, { key: e.pageType }), [s, e.pageType]);
152
+ const b = ye(), { pageToUser: i } = be(), f = R(i, [e == null ? void 0 : e.id, "userId"]), { data: u } = ge(f), c = u && b !== f ? u == null ? void 0 : u.name : null, p = ie(), g = r === e.id, W = !!e.isTemplate, P = V(() => $(s, { key: e.pageType }), [s, e.pageType]);
152
153
  let m = R(l, e == null ? void 0 : e.id);
153
154
  m = R(m, "lang") === a ? m : null;
154
155
  const L = a === p || !!m, A = (m == null ? void 0 : m.name) || (e == null ? void 0 : e.name) || "No name";
@@ -181,9 +182,9 @@ const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
181
182
  e.dynamicSlugCustom
182
183
  ] })
183
184
  ] }) }),
184
- W && /* @__PURE__ */ t(q, { content: "Template", side: "top", children: /* @__PURE__ */ t("span", { className: "text-blue-500", children: /* @__PURE__ */ t(Fe, { size: 16 }) }) }),
185
+ W && /* @__PURE__ */ t(q, { content: "Template", side: "top", children: /* @__PURE__ */ t("span", { className: "text-blue-500", children: /* @__PURE__ */ t(ze, { size: 16 }) }) }),
185
186
  !e.isPartialGroup && L && !c ? /* @__PURE__ */ t("div", { className: "duration absolute right-0.5 top-[3px]", children: /* @__PURE__ */ t(
186
- we,
187
+ ke,
187
188
  {
188
189
  isLanguagePage: !!m,
189
190
  page: m || e,
@@ -193,14 +194,14 @@ const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
193
194
  setDeletePage: (d) => n("delete", m || d),
194
195
  setMarkAsTemplate: (d) => n("markAsTemplate", d),
195
196
  setUnmarkAsTemplate: (d) => n("unmarkAsTemplate", d),
196
- children: /* @__PURE__ */ t("div", { className: "m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white", children: /* @__PURE__ */ t(Oe, { className: "h-4 w-4", onClick: (d) => d.stopPropagation() }) })
197
+ children: /* @__PURE__ */ t("div", { className: "m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white", children: /* @__PURE__ */ t(Fe, { className: "h-4 w-4", onClick: (d) => d.stopPropagation() }) })
197
198
  }
198
- ) }) : c ? /* @__PURE__ */ t("span", { className: "duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500", children: /* @__PURE__ */ t(je, { className: "h-3.5 w-3.5 fill-red-200 text-red-500" }) }) : null
199
+ ) }) : c ? /* @__PURE__ */ t("span", { className: "duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500", children: /* @__PURE__ */ t(Oe, { className: "h-3.5 w-3.5 fill-red-200 text-red-500" }) }) : null
199
200
  ]
200
201
  }
201
202
  ) }),
202
203
  /* @__PURE__ */ t(z, { children: c && /* @__PURE__ */ y("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: [
203
- /* @__PURE__ */ t(Ge, { size: 12, className: "stroke-[3]" }),
204
+ /* @__PURE__ */ t(je, { size: 12, className: "stroke-[3]" }),
204
205
  " ",
205
206
  /* @__PURE__ */ t("span", { className: "font-medium", children: c }),
206
207
  " is editing this page"
@@ -213,11 +214,11 @@ const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
213
214
  },
214
215
  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",
215
216
  children: [
216
- /* @__PURE__ */ t(Re, { size: 12, className: "stroke-[3]" }),
217
+ /* @__PURE__ */ t(Ge, { size: 12, className: "stroke-[3]" }),
217
218
  " ",
218
219
  /* @__PURE__ */ y("span", { className: "text-[10px]", children: [
219
220
  "Add ",
220
- R(Ne, a),
221
+ R(we, a),
221
222
  " Page"
222
223
  ] })
223
224
  ]
@@ -262,8 +263,8 @@ const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
262
263
  }
263
264
  )
264
265
  ] }, f.id)) });
265
- }, nt = M(() => import("./page-manager-search-and-filter-kNJFWJ86.js")), st = M(() => import("./add-new-page-B4hc0B-g.js")), rt = M(() => import("./delete-page-DC8pzvWW.js")), at = M(() => import("./duplicate-page-BoVhko2q.js")), ot = M(() => import("./mark-as-template-jncsjfHm.js")), lt = M(() => import("./unmark-as-template-Dulvf7Zw.js")), it = M(() => import("./unpublish-page-Degu5Cy9.js")), yt = ({ close: e }) => {
266
- const { t: s } = qe(), { languages: r, setSelectedLang: n } = ae(), { data: l } = ve(), { data: a, isFetching: h } = Se(), [b, i] = Le(), { updateForSelectedPage: f, expandPagesOnSearch: u } = Y(null), c = ie(), p = b.get("page"), [g, W] = N(""), [P, m] = N(null), [L, A] = N(null), [k, F] = N(null), [O, d] = N(null), [T, _] = N(""), [J, K] = N(null), [Z, ee] = N(null), [w, fe] = N(c), [xe, pe] = N(!1), te = Be(Ae), j = xe && w !== c, { data: U, isFetching: Pe } = Te(w), ne = oe(
266
+ }, nt = M(() => import("./page-manager-search-and-filter-zq-LfhQ1.js")), st = M(() => import("./add-new-page-DJLJFLAd.js")), rt = M(() => import("./delete-page-CNucxe4P.js")), at = M(() => import("./duplicate-page-BknLfqr0.js")), ot = M(() => import("./mark-as-template-DBLshWb5.js")), lt = M(() => import("./unmark-as-template-BMqgelv-.js")), it = M(() => import("./unpublish-page-BJ0Bsvt2.js")), bt = ({ close: e }) => {
267
+ const { t: s } = He(), { languages: r, setSelectedLang: n } = ae(), { data: l } = Ne(), { data: a, isFetching: h } = ve(), [b, i] = Se(), { updateForSelectedPage: f, expandPagesOnSearch: u } = Y(null), c = ie(), p = b.get("page"), [g, W] = N(""), [P, m] = N(null), [L, A] = N(null), [k, F] = N(null), [O, d] = N(null), [T, _] = N(""), [J, K] = N(null), [Z, ee] = N(null), [w, fe] = N(c), [xe, pe] = N(!1), te = $e(Le), j = xe && w !== c, { data: U, isFetching: Pe } = Ae(w), ne = oe(
267
268
  (x) => {
268
269
  var o;
269
270
  return (o = $(l, { key: x })) == null ? void 0 : o.hasSlug;
@@ -355,7 +356,7 @@ const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
355
356
  setShowUntranslatedPages: pe
356
357
  }
357
358
  ) }),
358
- /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: h || Pe ? /* @__PURE__ */ t("div", { className: "space-y-2", children: Ie([...Array(15).keys()], (x) => /* @__PURE__ */ t("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, x)) }) : S(v) ? /* @__PURE__ */ y("div", { className: "flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500", children: [
359
+ /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: h || Pe ? /* @__PURE__ */ t("div", { className: "space-y-2", children: Me([...Array(15).keys()], (x) => /* @__PURE__ */ t("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, x)) }) : S(v) ? /* @__PURE__ */ y("div", { className: "flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500", children: [
359
360
  /* @__PURE__ */ t(ue, { className: "h-6 w-6 stroke-[1]" }),
360
361
  s("Empty List!"),
361
362
  /* @__PURE__ */ t("span", { className: "font-light", children: s("Add new page to start") })
@@ -390,5 +391,5 @@ const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
390
391
  ] });
391
392
  };
392
393
  export {
393
- yt as default
394
+ bt as default
394
395
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),X=require("./index-C99FhuF1.cjs"),f=require("./index-C0-pgg_p.cjs"),B=require("./use-page-expand-manager-B6XTvk0E.cjs"),r=require("lodash-es"),O=require("jotai"),b=require("lucide-react"),l=require("react"),ne=require("react-i18next"),re=require("./register-chai-top-bar-BqwKw4uy.cjs"),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)})),ae=(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])},$=(e,n,a)=>r.isEmpty(n)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?$(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?$(s.children,n,a):[]}}),le=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):[]})),oe=(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=ae(e,x);c=r.uniqBy([...x,...u],"id")}const o=J(le(c)),p=$(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]},ie=O.atom({pageId:null,position:{x:0,y:0}}),ce=({pageId:e,children:n})=>{const[a,s]=O.useAtom(ie),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(re.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"]})})})]})},de=({page:e})=>{var s,c;const{isExpanded:n,toggleExpanded:a}=B.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":""}`})})},ue=({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"})}),me=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),xe=({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(ce,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:M,children:[t.jsx(de,{page:e}),!e.isPartialGroup&&t.jsx(me,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&t.jsx(ue,{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}=B.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(xe,{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))})},he=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-Bfm0j1gg.cjs"))),fe=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-C_PzKby8.cjs"))),pe=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-DAvEjHwF.cjs"))),ye=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-DzZByALW.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-CpWEBJGd.cjs"))),ge=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-DF1Ms4VN.cjs"))),je=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-Bsq2yEqQ.cjs"))),be=({close:e})=>{const{t:n}=ne.useTranslation(),{languages:a,setSelectedLang:s}=X.useLanguages(),{data:c}=f.usePageTypes(),{data:o,isFetching:p}=f.useWebsitePages(),[v,d]=f.useSearchParams(),{updateForSelectedPage:y,expandPagesOnSearch:x}=B.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(""),[R,G]=l.useState(null),[D,W]=l.useState(null),[S,Z]=l.useState(u),[ee,te]=l.useState(!1),_=O.useSetAtom(f.addNewLangAtom),q=ee&&S!==u,{data:A,isFetching:se}=f.useWebsiteLanguagePages(S),H=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])):oe(o,w,T,H):[],[o,H,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}=X.useLanguages(),Q=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]),V=(P,i)=>{var z;if(i)switch(P){case"add":L(i);break;case"select":Q(i);break;case"edit":S!==u?_({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":W(i);break;case"duplicate":G(i);break;case"addLanguagePage":_({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(he,{pages:N,search:w,setSearch:I,languages:[u,...a],selectedLanguage:S,setSelectedLanguage:Z,selectedPageType:T,setSelectedPageType:F,onAddPage:P=>V("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:V,languagePages:A,selectedLanguage:S,showUntranslatedPages:q})})]}),E&&t.jsx(l.Suspense,{children:t.jsx(fe,{closePanel:e,editPage:Q,addEditPage:E,setAddEditPage:L})}),j&&t.jsx(l.Suspense,{children:t.jsx(pe,{page:j,onClose:()=>h(null)})}),k&&t.jsx(l.Suspense,{children:t.jsx(je,{page:k,onClose:()=>C(null)})}),M&&t.jsx(l.Suspense,{children:t.jsx(Pe,{page:M,onClose:()=>m(null)})}),D&&t.jsx(l.Suspense,{children:t.jsx(ge,{page:D,onClose:()=>W(null)})}),R&&t.jsx(l.Suspense,{children:t.jsx(ye,{page:R,onClose:()=>G(null),closePanel:e})})]})};exports.default=be;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-BqwKw4uy.cjs"),n=require("./index-C99FhuF1.cjs"),f=require("./index-C0-pgg_p.cjs"),w=require("./use-page-expand-manager-B6XTvk0E.cjs"),C=require("@tanstack/react-query"),s=require("lodash-es"),d=require("lucide-react"),S=require("react"),g=require("react-i18next"),k=({selectedPageType:l,setSelectedPageType:i})=>{const{t:a}=g.useTranslation(),[r,o]=S.useState(""),{data:c}=f.usePageTypes(),u=t=>{if(!r)return!0;const x=r.toLowerCase(),m=j=>String(s.get(t,j,"")).toLowerCase().includes(x);return m("name")||m("key")},p=c.find(t=>t.key===l);return e.jsxs(n.Select,{onValueChange:i,value:l,children:[e.jsx(n.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:(p==null?void 0:p.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(n.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(h.Input,{placeholder:a("Search page types..."),className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:r,onChange:t=>o(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(n.SelectItem,{value:"all",children:a("All")}),!s.isEmpty(s.filter(c,t=>t.hasSlug&&u(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")}),s.map([...s.filter(c,t=>t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),!s.isEmpty(s.filter(c,t=>!t.hasSlug&&u(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")}),s.map([...s.filter(c,t=>!t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),s.isEmpty(s.filter(c,u))&&e.jsx("div",{className:"px-3 py-2 text-center text-sm text-gray-500",children:a("No matching page types found")})]})]})},T=({search:l,setSearch:i})=>{const{t:a}=g.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(h.Input,{id:"page-search-input",placeholder:a("Search pages"),value:l,onChange:r=>i(r.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"})]})},E=({pages:l})=>{const{t:i}=g.useTranslation(),{expandAll:a,collapseAll:r,expandedPages:o}=w.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"outline",size:"icon",onClick:()=>a(l),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsUpDown,{})})}),e.jsx(n.TooltipContent,{children:i("Expand All")})]}),e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{disabled:o.length===0,variant:"outline",size:"icon",onClick:()=>r(),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsDownUp,{})})}),e.jsx(n.TooltipContent,{children:i("Collapse All")})]})]})},b=({languages:l,selectedLanguage:i,setSelectedLanguage:a})=>{const r=f.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:l.map(o=>e.jsxs(h.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===r&&e.jsx(d.Star,{size:4,className:`p-0.5 ${i===r?"fill-white":"fill-black"}`}),f.LANGUAGES[o]||""]},o))})},y=()=>{const{t:l}=g.useTranslation(),i=C.useQueryClient();return e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{size:"sm",variant:"ghost",onClick:()=>i.invalidateQueries({queryKey:[f.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(d.RefreshCw,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:l("Refresh pages list")})]})},q=({pages:l,search:i,setSearch:a,languages:r,onAddPage:o,selectedLanguage:c,setSelectedLanguage:u,selectedPageType:p,setSelectedPageType:t,showUntranslatedPages:x,setShowUntranslatedPages:m})=>{const{t:j}=g.useTranslation(),v=r.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(k,{selectedPageType:p,setSelectedPageType:t}),e.jsx(T,{search:i,setSearch:a}),e.jsx(E,{pages:l}),e.jsxs(h.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:j("Add Page")})]}),!v&&e.jsx(y,{})]}),v?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(b,{languages:r,selectedLanguage:c,setSelectedLanguage:N=>{u(N),m(x&&(r==null?void 0:r[0])!==c)}}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[(r==null?void 0:r[0])!==c&&e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"ghost",onClick:()=>m(!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(n.TooltipContent,{side:"bottom",children:j("Toggle Untranslated Pages")})]}),e.jsx(y,{})]})]}):e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=b;exports.default=q;
@@ -1,7 +1,8 @@
1
1
  import { jsx as e, jsxs as a, Fragment as k } from "react/jsx-runtime";
2
- import { B as m, w as g, x as b, y, S as I, z as L, E as z, I as E, F as w } from "./index-S8ibZk9Q.js";
3
- import { k as j, L as T, m as $, A as G } from "./index-BDnwJqMw.js";
4
- import { u as B } from "./use-page-expand-manager-Cf4MUEJw.js";
2
+ import { B as m, z as E } from "./register-chai-top-bar-ESJHs5s-.js";
3
+ import { w as g, x as b, y, S as L, z as F, A as I, B as w } from "./index-rAcNbjk_.js";
4
+ import { k as j, L as T, m as $, A as B } from "./index-Dno42B0a.js";
5
+ import { u as G } from "./use-page-expand-manager-Cf4MUEJw.js";
5
6
  import { useQueryClient as D } from "@tanstack/react-query";
6
7
  import { isEmpty as N, filter as x, map as S, get as o } from "lodash-es";
7
8
  import { Star as M, Plus as R, FilterXIcon as W, Filter as q, ListFilter as K, Search as P, ChevronsUpDown as Q, ChevronsDownUp as _, RefreshCw as O } from "lucide-react";
@@ -13,9 +14,9 @@ const V = ({ selectedPageType: n, setSelectedPageType: s }) => {
13
14
  const d = r.toLowerCase(), u = (v) => String(o(t, v, "")).toLowerCase().includes(d);
14
15
  return u("name") || u("key");
15
16
  }, p = c.find((t) => t.key === n);
16
- return /* @__PURE__ */ a(I, { onValueChange: s, value: n, children: [
17
+ return /* @__PURE__ */ a(L, { onValueChange: s, value: n, children: [
17
18
  /* @__PURE__ */ e(
18
- L,
19
+ F,
19
20
  {
20
21
  className: `${n === "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`,
21
22
  children: /* @__PURE__ */ a("div", { className: "flex w-full items-center justify-between gap-x-1.5", children: [
@@ -29,7 +30,7 @@ const V = ({ selectedPageType: n, setSelectedPageType: s }) => {
29
30
  ] })
30
31
  }
31
32
  ),
32
- /* @__PURE__ */ a(z, { children: [
33
+ /* @__PURE__ */ a(I, { children: [
33
34
  /* @__PURE__ */ e("div", { className: "sticky top-0 z-10 bg-white pb-2", children: /* @__PURE__ */ a("div", { className: "relative", children: [
34
35
  /* @__PURE__ */ e(P, { strokeWidth: 2, className: "absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400" }),
35
36
  /* @__PURE__ */ e(
@@ -89,7 +90,7 @@ const V = ({ selectedPageType: n, setSelectedPageType: s }) => {
89
90
  )
90
91
  ] });
91
92
  }, H = ({ pages: n }) => {
92
- const { t: s } = f(), { expandAll: l, collapseAll: r, expandedPages: i } = B(null);
93
+ const { t: s } = f(), { expandAll: l, collapseAll: r, expandedPages: i } = G(null);
93
94
  return /* @__PURE__ */ a("div", { className: "flex gap-1", children: [
94
95
  /* @__PURE__ */ a(g, { children: [
95
96
  /* @__PURE__ */ e(b, { asChild: !0, children: /* @__PURE__ */ e(m, { variant: "outline", size: "icon", onClick: () => l(n), className: "rounded p-1 text-gray-500", children: /* @__PURE__ */ e(Q, {}) }) }),
@@ -134,14 +135,14 @@ const V = ({ selectedPageType: n, setSelectedPageType: s }) => {
134
135
  {
135
136
  size: "sm",
136
137
  variant: "ghost",
137
- onClick: () => s.invalidateQueries({ queryKey: [G.GET_WEBSITE_PAGES] }),
138
+ onClick: () => s.invalidateQueries({ queryKey: [B.GET_WEBSITE_PAGES] }),
138
139
  className: "mt-1 h-6 w-6",
139
140
  children: /* @__PURE__ */ e(O, {})
140
141
  }
141
142
  ) }),
142
143
  /* @__PURE__ */ e(y, { side: "bottom", children: n("Refresh pages list") })
143
144
  ] });
144
- }, ie = ({
145
+ }, oe = ({
145
146
  pages: n,
146
147
  search: s,
147
148
  setSearch: l,
@@ -172,8 +173,8 @@ const V = ({ selectedPageType: n, setSelectedPageType: s }) => {
172
173
  {
173
174
  languages: r,
174
175
  selectedLanguage: c,
175
- setSelectedLanguage: (F) => {
176
- h(F), u(d && (r == null ? void 0 : r[0]) !== c);
176
+ setSelectedLanguage: (z) => {
177
+ h(z), u(d && (r == null ? void 0 : r[0]) !== c);
177
178
  }
178
179
  }
179
180
  ),
@@ -197,5 +198,5 @@ const V = ({ selectedPageType: n, setSelectedPageType: s }) => {
197
198
  };
198
199
  export {
199
200
  J as LanguageSelector,
200
- ie as default
201
+ oe as default
201
202
  };