@chaibuilder/sdk 4.0.0-beta.34 → 4.0.0-beta.36

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 (119) hide show
  1. package/dist/{2SSKDMRQ-BM-tJzJS.cjs → 2SSKDMRQ-C3eivR9y.cjs} +1 -1
  2. package/dist/{2SSKDMRQ-hkjhJNfh.js → 2SSKDMRQ-rk5vFzuv.js} +5 -5
  3. package/dist/{AP7HFJJL-MEqeM2Ns.cjs → AP7HFJJL-2qWLZyWT.cjs} +1 -1
  4. package/dist/{AP7HFJJL-XRxLnRog.js → AP7HFJJL-BMK2jPSi.js} +1 -1
  5. package/dist/{IconPicker-Bl4iY4Cu.cjs → IconPicker-B-NfypT7.cjs} +1 -1
  6. package/dist/{IconPicker-D5wIkgWK.js → IconPicker-BzQ_r0nM.js} +1 -1
  7. package/dist/{WDYDFRGG-8UgG1Mx8.js → WDYDFRGG-1zoPbvu7.js} +6 -6
  8. package/dist/{WDYDFRGG-BitFxd1K.cjs → WDYDFRGG-Bfra_-3l.cjs} +1 -1
  9. package/dist/{actions-registery-CKEzH855.js → actions-registery-CMKfEXxX.js} +235 -301
  10. package/dist/{actions-registery-Byid-s6S.cjs → actions-registery-CqhNZFV3.cjs} +13 -13
  11. package/dist/actions.cjs +1 -1
  12. package/dist/actions.js +2 -2
  13. package/dist/{active-in-another-tab-BsdNjSxr.cjs → active-in-another-tab-DkOOxZwb.cjs} +1 -1
  14. package/dist/{active-in-another-tab-BBrqPDfn.js → active-in-another-tab-Zrq6x3L9.js} +2 -2
  15. package/dist/{add-new-language-page-BJUHnI7Z.cjs → add-new-language-page-Dsze4PNK.cjs} +1 -1
  16. package/dist/{add-new-language-page-DvSZenkC.js → add-new-language-page-alqCh26P.js} +3 -3
  17. package/dist/{add-new-page-BI7qCsmh.cjs → add-new-page-DtQYPRYM.cjs} +1 -1
  18. package/dist/{add-new-page-Dd16d2mC.js → add-new-page-HoFoI257.js} +2 -2
  19. package/dist/{ai-panel-content-CLNgM3Td.js → ai-panel-content-DZmolAf1.js} +3 -3
  20. package/dist/{ai-panel-content-CcqF0I9F.cjs → ai-panel-content-DcM2BBcL.cjs} +1 -1
  21. package/dist/{ai-panel-default-lang-XPtfrifL.cjs → ai-panel-default-lang-BmVJcDnH.cjs} +2 -2
  22. package/dist/{ai-panel-default-lang-BooHb2pz.js → ai-panel-default-lang-Bv8Fms5X.js} +3 -3
  23. package/dist/{ai-panel-other-lang-BwnRUTSF.cjs → ai-panel-other-lang-BGyP45jz.cjs} +1 -1
  24. package/dist/{ai-panel-other-lang-CcgIMR3N.js → ai-panel-other-lang-CCGz4Tql.js} +3 -3
  25. package/dist/{ai-prompt-input-CQ5SJPkx.cjs → ai-prompt-input-CJLPetgL.cjs} +1 -1
  26. package/dist/{ai-prompt-input-AUdUYGNa.js → ai-prompt-input-DO-zCSY_.js} +1 -1
  27. package/dist/{ai-translation-prompt-BTNGNtbf.cjs → ai-translation-prompt-DWj1gmKg.cjs} +1 -1
  28. package/dist/{ai-translation-prompt-BYUh4Mnb.js → ai-translation-prompt-DXhM0OnM.js} +1 -1
  29. package/dist/{change-password-modal-CYkUXUa5.cjs → change-password-modal-BcJsR8sq.cjs} +1 -1
  30. package/dist/{change-password-modal-DCd1gdCm.js → change-password-modal-D4wVoj8S.js} +2 -2
  31. package/dist/{code-editor-DWrVXxeA.js → code-editor-B87D8cT6.js} +1 -1
  32. package/dist/{code-editor-BC6Z10dU.cjs → code-editor-BTs3K_My.cjs} +1 -1
  33. package/dist/{continue-editing-in-this-client-D6Wc8hEK.cjs → continue-editing-in-this-client-BHbRZL8A.cjs} +1 -1
  34. package/dist/{continue-editing-in-this-client-Bdd5Ls6t.js → continue-editing-in-this-client-CoZnDfgk.js} +2 -2
  35. package/dist/core.cjs +1 -1
  36. package/dist/core.js +19 -19
  37. package/dist/{css-import-modal-Cpwll5L-.js → css-import-modal-DIgM4T8d.js} +1 -1
  38. package/dist/{css-import-modal-FHeYoxo2.cjs → css-import-modal-DgXSYibP.cjs} +1 -1
  39. package/dist/{delete-page-PQGa6Am5.cjs → delete-page-DKBN4nL1.cjs} +1 -1
  40. package/dist/{delete-page-DyP68v_N.js → delete-page-T2VWcbyP.js} +2 -2
  41. package/dist/{design-token-usage-CoaLw6EJ.cjs → design-token-usage-DMSy2KGp.cjs} +1 -1
  42. package/dist/{design-token-usage-dR3UlfIC.js → design-token-usage-DSpw3Kqi.js} +1 -1
  43. package/dist/{digital-asset-manager-BNj96Pnh.js → digital-asset-manager-B1KUqVJc.js} +3 -3
  44. package/dist/{digital-asset-manager-Bxkm-jdI.cjs → digital-asset-manager-DYMrQhJ7.cjs} +1 -1
  45. package/dist/{duplicate-page-Cg6WnFeY.js → duplicate-page-Bt36erFD.js} +15 -15
  46. package/dist/{duplicate-page-DV_lZ8jF.cjs → duplicate-page-Cop50Nuj.cjs} +1 -1
  47. package/dist/{dynamic-page-selector-C8ax7W_D.cjs → dynamic-page-selector-DxJ80Cpv.cjs} +1 -1
  48. package/dist/{dynamic-page-selector-DcQiWgiL.js → dynamic-page-selector-jMUcjGtc.js} +2 -2
  49. package/dist/{image-editor-DGp2-ImI.js → image-editor-CdNLsyhd.js} +1 -1
  50. package/dist/{image-editor-C5rYU8Ic.cjs → image-editor-CpUpmlCT.cjs} +1 -1
  51. package/dist/{index-94oA-Cgl.js → index-DZheQdw-.js} +3967 -3991
  52. package/dist/index-DvOWqGdC.cjs +5 -0
  53. package/dist/{index-CDUCqK5V.js → index-K4yKMKbY.js} +1803 -1788
  54. package/dist/index-W4Ur56bi.cjs +160 -0
  55. package/dist/{json-diff-viewer-CdU-gKRr.cjs → json-diff-viewer-BisiaC_I.cjs} +1 -1
  56. package/dist/{json-diff-viewer-CniMcSHL.js → json-diff-viewer-CivVPp1k.js} +34 -34
  57. package/dist/{lang-panel-YLNZisL2.js → lang-panel-DejZsTqE.js} +23 -23
  58. package/dist/{lang-panel-Dg7eZqIm.cjs → lang-panel-DoPGR_AP.cjs} +1 -1
  59. package/dist/{manage-design-tokens-Bct88PT-.js → manage-design-tokens-BxXReDdA.js} +2 -2
  60. package/dist/{manage-design-tokens-CMf-Vk72.cjs → manage-design-tokens-Cdi3Ma4y.cjs} +1 -1
  61. package/dist/{manage-design-tokens-modal-YPEBybz3.cjs → manage-design-tokens-modal-Dr5lwyr_.cjs} +1 -1
  62. package/dist/{manage-design-tokens-modal-CeSW9VV_.js → manage-design-tokens-modal-DyvSsIVv.js} +2 -2
  63. package/dist/{mark-as-template-WJ4kUyZK.js → mark-as-template-NPUbCfae.js} +2 -2
  64. package/dist/{mark-as-template-C5rPp_PV.cjs → mark-as-template-OqwiT2Zm.cjs} +1 -1
  65. package/dist/{nested-path-selector-content-D0hfMLC6.js → nested-path-selector-content-B4p9qltN.js} +1 -1
  66. package/dist/{nested-path-selector-content-COErdW8f.cjs → nested-path-selector-content-D6f2I80h.cjs} +1 -1
  67. package/dist/{no-language-page-content-CK_K6fh9.cjs → no-language-page-content-BGlAr__k.cjs} +1 -1
  68. package/dist/{no-language-page-content-BLnpbzwT.js → no-language-page-content-DfdMEUqE.js} +2 -2
  69. package/dist/{no-language-page-dialog-gZGw3Uzp.js → no-language-page-dialog-3obqd_9-.js} +2 -2
  70. package/dist/{no-language-page-dialog-BI55QXS_.cjs → no-language-page-dialog-d1oHBURV.cjs} +1 -1
  71. package/dist/{page-creator-hHpEaVpS.js → page-creator-4ElxexYm.js} +51 -51
  72. package/dist/{page-creator-C2ZwuF6M.cjs → page-creator-Il_h2vl4.cjs} +1 -1
  73. package/dist/{page-lock-DMzAREda.js → page-lock-CT54xDQL.js} +2 -2
  74. package/dist/{page-lock-BN8BI4J8.cjs → page-lock-s-pfopxQ.cjs} +1 -1
  75. package/dist/{page-locked-dialog-B_2Hy4PJ.cjs → page-locked-dialog-BORNeoXe.cjs} +1 -1
  76. package/dist/{page-locked-dialog-CZiVFSGf.js → page-locked-dialog-CBL04Nga.js} +3 -3
  77. package/dist/{page-manager-new-DLVIuTY7.cjs → page-manager-new-Bp5QkZD4.cjs} +1 -1
  78. package/dist/{page-manager-new-74gQK_vK.js → page-manager-new-DqCkZnWY.js} +92 -92
  79. package/dist/{page-manager-search-and-filter-C6XNDRT7.cjs → page-manager-search-and-filter-BMPaoTAI.cjs} +1 -1
  80. package/dist/{page-manager-search-and-filter-DYXCod2G.js → page-manager-search-and-filter-CUEUB4bN.js} +2 -2
  81. package/dist/{page-revisions-content-44SecMak.cjs → page-revisions-content-1kklUJZV.cjs} +1 -1
  82. package/dist/{page-revisions-content-BWLkqXrw.js → page-revisions-content-mU05KA_O.js} +7 -7
  83. package/dist/pages.cjs +1 -1
  84. package/dist/pages.d.ts +2 -2
  85. package/dist/pages.js +15 -15
  86. package/dist/{publish-pages-content-COHFXR-v.js → publish-pages-content-CcV-xLsk.js} +80 -73
  87. package/dist/publish-pages-content-CpdTUAds.cjs +1 -0
  88. package/dist/{rte-widget-modal-ck2hWBPv.cjs → rte-widget-modal-BCFhKLqA.cjs} +1 -1
  89. package/dist/{rte-widget-modal-muaFxwH1.js → rte-widget-modal-DcXHaT-t.js} +1 -1
  90. package/dist/{save-to-lib-JBs4ml12.js → save-to-lib-CXhaKw5V.js} +57 -57
  91. package/dist/{save-to-lib-NHLFZR6b.cjs → save-to-lib-Uw9LqY5V.cjs} +1 -1
  92. package/dist/sdk.css +1 -1
  93. package/dist/{selected-block-display-BhnCoV28.cjs → selected-block-display-DZz78Kuo.cjs} +1 -1
  94. package/dist/{selected-block-display-0rlYn5jN.js → selected-block-display-_r5ZoSSD.js} +2 -2
  95. package/dist/{seo-panel-D8QdAKVh.js → seo-panel-CMIMJh2W.js} +13 -13
  96. package/dist/{seo-panel-BLTekCWH.cjs → seo-panel-Cj8ky_W6.cjs} +2 -2
  97. package/dist/{shared-json-ld-CDYobqPW.cjs → shared-json-ld-C28DLkns.cjs} +1 -1
  98. package/dist/{shared-json-ld-DclZXKU6.js → shared-json-ld-LWZfxt-V.js} +2 -2
  99. package/dist/{slug-input-BOaNz0te.js → slug-input-BCs8-IRf.js} +1 -1
  100. package/dist/{slug-input-D3pjtp5_.cjs → slug-input-CQu9-5GT.cjs} +1 -1
  101. package/dist/supabase-actions.cjs +1 -1
  102. package/dist/supabase-actions.js +1 -1
  103. package/dist/{take-over-request-CbQfdDOW.js → take-over-request-eNwLOB2Q.js} +10 -10
  104. package/dist/{take-over-request-CF3ubryV.cjs → take-over-request-x9nLTelf.cjs} +1 -1
  105. package/dist/{translation-warning-modal-Bseflnj4.cjs → translation-warning-modal-BfFfRg7q.cjs} +1 -1
  106. package/dist/{translation-warning-modal-Bs5qTh3p.js → translation-warning-modal-KLjj1aXN.js} +1 -1
  107. package/dist/types.d.ts +1 -0
  108. package/dist/{unmark-as-template-CtiOyF4c.cjs → unmark-as-template-GdqfA8lm.cjs} +1 -1
  109. package/dist/{unmark-as-template-rGzNVgFR.js → unmark-as-template-YGONVpmY.js} +2 -2
  110. package/dist/{unpublish-page-CNR43LxM.cjs → unpublish-page-CmwSkit5.cjs} +1 -1
  111. package/dist/{unpublish-page-DhtGUDXp.js → unpublish-page-D-A9A9db.js} +2 -2
  112. package/dist/{unpublished-partials-modal-BmKRB4Tl.cjs → unpublished-partials-modal-Bx35iokR.cjs} +1 -1
  113. package/dist/{unpublished-partials-modal-j0zuOxDo.js → unpublished-partials-modal-UTkegPmZ.js} +1 -1
  114. package/dist/{web-preview-BCWqRDBW.js → web-preview-CZVcFxwF.js} +1 -1
  115. package/dist/{web-preview-DYyGglxW.cjs → web-preview-D4_3nlN-.cjs} +1 -1
  116. package/package.json +1 -1
  117. package/dist/index-Bg3Prrc_.cjs +0 -5
  118. package/dist/index-BsloTOgy.cjs +0 -160
  119. package/dist/publish-pages-content-msfUAXJy.cjs +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),K=require("./index-BsloTOgy.cjs"),y=require("./index-Bg3Prrc_.cjs"),G=require("./use-page-expand-manager-B6XTvk0E.cjs"),n=require("lodash-es"),R=require("jotai"),k=require("lucide-react"),o=require("react"),oe=require("react-i18next"),ie=require("./register-chai-top-bar-DyW9GPzV.cjs"),Z=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const s=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),s)||n.includes(n.toLower((a==null?void 0:a.slug)||""),s)})),le=(e,r)=>{const a=new Set,s=n.keyBy(e,"id");return r.forEach(c=>{let l=c;for(;l.parent&&s[l.parent];)a.add(l.parent),l=s[l.parent]}),Array.from(a).map(c=>s[c])},O=(e,r,a)=>n.isEmpty(r)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?O(s.children,r,a):[]};const c=s.children&&s.children.some(l=>n.includes(n.toLower(l.name||""),n.toLower(r))||n.includes(n.toLower(l.slug||""),n.toLower(r)));return{...s,shouldExpandOnSearch:c,children:s.children?O(s.children,r,a):[]}}),ce=e=>{if(!e||!e.length)return[];const r={};e.forEach(s=>{r[s.id]={...s,children:[]}});const a=[];return Object.values(r).forEach(s=>{s.parent&&r[s.parent]?r[s.parent].children.push(s):a.push(s)}),a},ee=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?ee(a.children):[]})),de=(e,r,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))c=Z(c,r);else{const x=Z(c,r),d=le(e,x);c=n.uniqBy([...x,...d],"id")}const l=ee(ce(c)),p=O(l,r,s),g=n.filter(p,x=>s(x.pageType)).sort((x,d)=>(x.name||"").localeCompare(d.name||"")),u=n.filter(p,x=>!s(x.pageType));let P=[];if(a==="all"){const x=n.keyBy(u,"pageType");P=Object.values(n.mapValues(x,(d,w)=>({...d,id:w,name:n.startCase(w),isPartialGroup:!0,children:p.filter(v=>v.pageType===w)})))}else P=u.sort((x,d)=>(x.name||"").localeCompare(d.name||""));return[...g,...P]},ue=R.atom({pageId:null,position:{x:0,y:0}}),me=({pageId:e,children:r})=>{const[a,s]=R.useAtom(ue),c=o.useRef(null),l=a.pageId===e;o.useEffect(()=>{const u=()=>s({pageId:null,position:{x:0,y:0}});if(l)return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[l,s]);const p=u=>{u.preventDefault(),u.stopPropagation(),s({pageId:e,position:{x:u.clientX,y:u.clientY}})},g=()=>{const u=`${window.location.pathname}?page=${e}`;window.open(u,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:p,children:r}),l&&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(ie.Button,{variant:"ghost",onClick:g,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(k.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},he=({page:e})=>{var s,c;const{isExpanded:r,toggleExpanded:a}=G.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:l=>{l.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(k.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},xe=({page:e,pageType:r})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(k.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.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:r.icon}}):r!=null&&r.hasSlug?t.jsx(k.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(k.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),fe=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),ye=({page:e,pageTypes:r,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:l,showUntranslatedPages:p})=>{const g=y.useUserId(),{pageToUser:u}=y.usePageToUser(),P=n.get(u,[e==null?void 0:e.id,"userId"]),{data:x}=y.useChaiUserInfo(P),d=x&&g!==P?x==null?void 0:x.name:null,w=y.useFallbackLang(),v=a===e.id,j=o.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]);let m=n.get(c,e==null?void 0:e.id);m=n.get(m,"lang")===l?m:null;const E=l===w||!!m,A=(m==null?void 0:m.name)||(e==null?void 0:e.name)||"No name";let S=(m==null?void 0:m.slug)||(e==null?void 0:e.slug)||"";const $=S+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(S.startsWith("/")&&!p){const f=S.split("/").pop();S=S.endsWith(f)&&e.dynamic?"":`/${f}`}const q=o.useMemo(()=>{const f="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]",C=`${v?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${f} ${C} ${d?"opacity-60":""}`:`${f} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,v,d]),I=o.useMemo(()=>{if(e.isPartialGroup)return!1;if(m){if(!m.online||n.isEmpty(m.changes))return!1}else if(e&&(!e.online||n.isEmpty(e.changes)))return!1;return!0},[m,e]);return t.jsxs("div",{className:"group relative",children:[t.jsx(me,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:q,children:[t.jsx(he,{page:e}),!e.isPartialGroup&&t.jsx(fe,{isOnline:m?m.online:e.online}),!e.isPartialGroup&&t.jsx(xe,{page:e,pageType:j}),t.jsx(y.Tooltip,{content:A,side:"top",showTooltip:A.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:A})}),(S||e.dynamic)&&t.jsx(y.Tooltip,{content:$,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[S,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(y.Tooltip,{content:"Has unpublished changes",side:"top",children:t.jsx("span",{className:"text-amber-500",children:t.jsx(k.Pencil,{size:12,className:"stroke-[2]"})})}),!e.isPartialGroup&&E&&!d?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(y.PageActionsDropdown,{isLanguagePage:!!m,page:m||e,setDuplicatePage:f=>s("duplicate",f),setAddEditPage:f=>s("edit",m||f),setUnpublishPage:f=>s("unpublish",f),setDeletePage:f=>s("delete",m||f),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(k.MoreHorizontal,{className:"h-4 w-4",onClick:f=>f.stopPropagation()})})})}):d?t.jsxs("span",{className:"duration absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-x-1 text-xs text-red-500",children:[t.jsx(k.Lock,{className:"h-3 w-3 fill-red-200 text-red-500"}),t.jsx(y.Tooltip,{content:`${d} is editing this page`,children:t.jsx("span",{className:"font-bold",children:d})})]}):null]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!d&&t.jsxs("button",{onClick:f=>{f.stopPropagation(),s("addLanguagePage",{language:l,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(k.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(y.LANGUAGES,l)," Page"]})]})})]})},te=({pages:e,tier:r,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g})=>{const{expandedPages:u}=G.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(P=>t.jsxs(t.Fragment,{children:[t.jsx(ye,{page:P,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g}),P.children&&P.children.length>0&&(u==null?void 0:u.includes(P.id))&&t.jsx(te,{pages:P.children,tier:r+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g})]},P.id))})},pe=o.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-C6XNDRT7.cjs"))),Pe=o.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-BI7qCsmh.cjs"))),we=o.lazy(()=>Promise.resolve().then(()=>require("./delete-page-PQGa6Am5.cjs"))),ge=o.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-DV_lZ8jF.cjs"))),je=o.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-C5rPp_PV.cjs"))),be=o.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-CtiOyF4c.cjs"))),Se=o.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-CNR43LxM.cjs"))),ve=({close:e})=>{const{t:r}=oe.useTranslation(),{languages:a,setSelectedLang:s}=K.useLanguages(),{data:c}=y.usePageTypes(),{data:l,isFetching:p}=y.useWebsitePrimaryPages(),[g,u]=y.useSearchParams(),{updateForSelectedPage:P,expandPagesOnSearch:x}=G.usePageExpandManager(null),d=y.useFallbackLang(),w=g.get("page"),[v,j]=o.useState(""),[m,E]=o.useState(null),[A,S]=o.useState(null),[$,q]=o.useState(null),[I,f]=o.useState(null),[C,z]=o.useState(""),[D,W]=o.useState(null),[H,_]=o.useState(null),[b,F]=o.useState(d),[se,ne]=o.useState(!1),V=R.useSetAtom(y.addNewLangAtom),U=se&&b!==d,{data:M,isFetching:re}=y.useWebsiteLanguagePages(b),Q=o.useCallback(h=>{var i;return(i=n.find(c,{key:h}))==null?void 0:i.hasSlug},[c]),N=o.useMemo(()=>l?U?n.filter(l,h=>!(M!=null&&M[h.id])):de(l,v,C,Q):[],[l,Q,v,C,M,U]);o.useEffect(()=>{s(d)},[d,s]),o.useEffect(()=>{const h=g.get("lang");if(h){const i=a,L=a[0]??d,T=i.includes(h);o.startTransition(()=>{T&&b!==h?F(h):!T&&b!==L&&F(L)})}},[]),o.useEffect(()=>{if(!n.isEmpty(C))return;const h=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&h&&(n.find(c,{key:h})?z(h):z("all"))},[c,C]),o.useEffect(()=>{if(w&&!p&&!n.find(l,{id:w})){const i=new URLSearchParams(g.toString());if(i.delete("page"),[...i.keys()].length>0){if(typeof window<"u"&&window.history&&window.location){const L=i.toString(),T=window.location.hash||"",J=window.location.pathname,ae=L?`${J}?${L}${T}`:`${J}${T}`;window.history.replaceState(window.history.state,"",ae)}u(i)}else typeof window<"u"&&window.history&&window.location&&(window.history.replaceState(window.history.state,"",window.location.pathname+window.location.hash),window.dispatchEvent(new PopStateEvent("popstate",{state:window.history.state}))),u(i)}},[l,w,p,u]),o.useEffect(()=>{w&&!p&&!n.isEmpty(N)&&P(N,w)},[w,p,N,P]),o.useEffect(()=>{!n.isEmpty(v)&&!n.isEmpty(N)&&x(N)},[v,N,x]);const{setSelectedLang:B}=K.useLanguages(),X=o.useCallback(h=>{const i=new URLSearchParams({page:h});b!==d?(i.set("lang",b),B(b)):B(""),y.navigateToPage(i,u),e()},[e,u,B,b,d]),Y=(h,i)=>{var L;if(i)switch(h){case"add":S(i);break;case"select":X(i);break;case"edit":b!==d?V({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):S(i);break;case"delete":E(i);break;case"unpublish":q(i);break;case"markAsTemplate":f(i);break;case"unmarkAsTemplate":_(i);break;case"duplicate":W(i);break;case"addLanguagePage":V({edit:!1,primaryPage:((L=i==null?void 0:i.page)==null?void 0:L.id)||"",preselectedLang:(i==null?void 0:i.language)||b});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(o.Suspense,{children:t.jsx(pe,{pages:N,search:v,setSearch:j,languages:[d,...a],selectedLanguage:b,setSelectedLanguage:F,selectedPageType:C,setSelectedPageType:z,onAddPage:h=>Y("add",h),showUntranslatedPages:U,setShowUntranslatedPages:ne})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:p||re?t.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],h=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},h))}):n.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(k.File,{className:"h-6 w-6 stroke-[1]"}),r("Empty List!"),t.jsx("span",{className:"font-light",children:r("Add new page to start")})]}):t.jsx(te,{tier:0,pages:N,pageTypes:c,currentPage:w||"",onClickAction:Y,languagePages:M,selectedLanguage:b,showUntranslatedPages:U})})]}),A&&t.jsx(o.Suspense,{children:t.jsx(Pe,{closePanel:e,editPage:X,addEditPage:A,setAddEditPage:S})}),m&&t.jsx(o.Suspense,{children:t.jsx(we,{page:m,onClose:()=>E(null)})}),$&&t.jsx(o.Suspense,{children:t.jsx(Se,{page:$,onClose:()=>q(null)})}),I&&t.jsx(o.Suspense,{children:t.jsx(je,{page:I,onClose:()=>f(null)})}),H&&t.jsx(o.Suspense,{children:t.jsx(be,{page:H,onClose:()=>_(null)})}),D&&t.jsx(o.Suspense,{children:t.jsx(ge,{page:D,onClose:()=>W(null),closePanel:e})})]})};exports.default=ve;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),K=require("./index-W4Ur56bi.cjs"),y=require("./index-DvOWqGdC.cjs"),G=require("./use-page-expand-manager-B6XTvk0E.cjs"),n=require("lodash-es"),R=require("jotai"),k=require("lucide-react"),o=require("react"),oe=require("react-i18next"),ie=require("./register-chai-top-bar-DyW9GPzV.cjs"),Z=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const s=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),s)||n.includes(n.toLower((a==null?void 0:a.slug)||""),s)})),le=(e,r)=>{const a=new Set,s=n.keyBy(e,"id");return r.forEach(c=>{let l=c;for(;l.parent&&s[l.parent];)a.add(l.parent),l=s[l.parent]}),Array.from(a).map(c=>s[c])},O=(e,r,a)=>n.isEmpty(r)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?O(s.children,r,a):[]};const c=s.children&&s.children.some(l=>n.includes(n.toLower(l.name||""),n.toLower(r))||n.includes(n.toLower(l.slug||""),n.toLower(r)));return{...s,shouldExpandOnSearch:c,children:s.children?O(s.children,r,a):[]}}),ce=e=>{if(!e||!e.length)return[];const r={};e.forEach(s=>{r[s.id]={...s,children:[]}});const a=[];return Object.values(r).forEach(s=>{s.parent&&r[s.parent]?r[s.parent].children.push(s):a.push(s)}),a},ee=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?ee(a.children):[]})),de=(e,r,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))c=Z(c,r);else{const x=Z(c,r),d=le(e,x);c=n.uniqBy([...x,...d],"id")}const l=ee(ce(c)),p=O(l,r,s),g=n.filter(p,x=>s(x.pageType)).sort((x,d)=>(x.name||"").localeCompare(d.name||"")),u=n.filter(p,x=>!s(x.pageType));let P=[];if(a==="all"){const x=n.keyBy(u,"pageType");P=Object.values(n.mapValues(x,(d,w)=>({...d,id:w,name:n.startCase(w),isPartialGroup:!0,children:p.filter(v=>v.pageType===w)})))}else P=u.sort((x,d)=>(x.name||"").localeCompare(d.name||""));return[...g,...P]},ue=R.atom({pageId:null,position:{x:0,y:0}}),me=({pageId:e,children:r})=>{const[a,s]=R.useAtom(ue),c=o.useRef(null),l=a.pageId===e;o.useEffect(()=>{const u=()=>s({pageId:null,position:{x:0,y:0}});if(l)return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[l,s]);const p=u=>{u.preventDefault(),u.stopPropagation(),s({pageId:e,position:{x:u.clientX,y:u.clientY}})},g=()=>{const u=`${window.location.pathname}?page=${e}`;window.open(u,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:p,children:r}),l&&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(ie.Button,{variant:"ghost",onClick:g,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(k.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},he=({page:e})=>{var s,c;const{isExpanded:r,toggleExpanded:a}=G.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:l=>{l.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(k.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},xe=({page:e,pageType:r})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(k.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.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:r.icon}}):r!=null&&r.hasSlug?t.jsx(k.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(k.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),fe=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),ye=({page:e,pageTypes:r,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:l,showUntranslatedPages:p})=>{const g=y.useUserId(),{pageToUser:u}=y.usePageToUser(),P=n.get(u,[e==null?void 0:e.id,"userId"]),{data:x}=y.useChaiUserInfo(P),d=x&&g!==P?x==null?void 0:x.name:null,w=y.useFallbackLang(),v=a===e.id,j=o.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]);let m=n.get(c,e==null?void 0:e.id);m=n.get(m,"lang")===l?m:null;const E=l===w||!!m,A=(m==null?void 0:m.name)||(e==null?void 0:e.name)||"No name";let S=(m==null?void 0:m.slug)||(e==null?void 0:e.slug)||"";const $=S+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(S.startsWith("/")&&!p){const f=S.split("/").pop();S=S.endsWith(f)&&e.dynamic?"":`/${f}`}const q=o.useMemo(()=>{const f="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]",C=`${v?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${f} ${C} ${d?"opacity-60":""}`:`${f} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,v,d]),I=o.useMemo(()=>{if(e.isPartialGroup)return!1;if(m){if(!m.online||n.isEmpty(m.changes))return!1}else if(e&&(!e.online||n.isEmpty(e.changes)))return!1;return!0},[m,e]);return t.jsxs("div",{className:"group relative",children:[t.jsx(me,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:q,children:[t.jsx(he,{page:e}),!e.isPartialGroup&&t.jsx(fe,{isOnline:m?m.online:e.online}),!e.isPartialGroup&&t.jsx(xe,{page:e,pageType:j}),t.jsx(y.Tooltip,{content:A,side:"top",showTooltip:A.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:A})}),(S||e.dynamic)&&t.jsx(y.Tooltip,{content:$,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[S,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(y.Tooltip,{content:"Has unpublished changes",side:"top",children:t.jsx("span",{className:"text-amber-500",children:t.jsx(k.Pencil,{size:12,className:"stroke-[2]"})})}),!e.isPartialGroup&&E&&!d?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(y.PageActionsDropdown,{isLanguagePage:!!m,page:m||e,setDuplicatePage:f=>s("duplicate",f),setAddEditPage:f=>s("edit",m||f),setUnpublishPage:f=>s("unpublish",f),setDeletePage:f=>s("delete",m||f),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(k.MoreHorizontal,{className:"h-4 w-4",onClick:f=>f.stopPropagation()})})})}):d?t.jsxs("span",{className:"duration absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-x-1 text-xs text-red-500",children:[t.jsx(k.Lock,{className:"h-3 w-3 fill-red-200 text-red-500"}),t.jsx(y.Tooltip,{content:`${d} is editing this page`,children:t.jsx("span",{className:"font-bold",children:d})})]}):null]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!d&&t.jsxs("button",{onClick:f=>{f.stopPropagation(),s("addLanguagePage",{language:l,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(k.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(y.LANGUAGES,l)," Page"]})]})})]})},te=({pages:e,tier:r,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g})=>{const{expandedPages:u}=G.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(P=>t.jsxs(t.Fragment,{children:[t.jsx(ye,{page:P,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g}),P.children&&P.children.length>0&&(u==null?void 0:u.includes(P.id))&&t.jsx(te,{pages:P.children,tier:r+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g})]},P.id))})},pe=o.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-BMPaoTAI.cjs"))),Pe=o.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-DtQYPRYM.cjs"))),we=o.lazy(()=>Promise.resolve().then(()=>require("./delete-page-DKBN4nL1.cjs"))),ge=o.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-Cop50Nuj.cjs"))),je=o.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-OqwiT2Zm.cjs"))),be=o.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-GdqfA8lm.cjs"))),Se=o.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-CmwSkit5.cjs"))),ve=({close:e})=>{const{t:r}=oe.useTranslation(),{languages:a,setSelectedLang:s}=K.useLanguages(),{data:c}=y.usePageTypes(),{data:l,isFetching:p}=y.useWebsitePrimaryPages(),[g,u]=y.useSearchParams(),{updateForSelectedPage:P,expandPagesOnSearch:x}=G.usePageExpandManager(null),d=y.useFallbackLang(),w=g.get("page"),[v,j]=o.useState(""),[m,E]=o.useState(null),[A,S]=o.useState(null),[$,q]=o.useState(null),[I,f]=o.useState(null),[C,z]=o.useState(""),[D,W]=o.useState(null),[H,_]=o.useState(null),[b,F]=o.useState(d),[se,ne]=o.useState(!1),V=R.useSetAtom(y.addNewLangAtom),U=se&&b!==d,{data:M,isFetching:re}=y.useWebsiteLanguagePages(b),Q=o.useCallback(h=>{var i;return(i=n.find(c,{key:h}))==null?void 0:i.hasSlug},[c]),N=o.useMemo(()=>l?U?n.filter(l,h=>!(M!=null&&M[h.id])):de(l,v,C,Q):[],[l,Q,v,C,M,U]);o.useEffect(()=>{s(d)},[d,s]),o.useEffect(()=>{const h=g.get("lang");if(h){const i=a,L=a[0]??d,T=i.includes(h);o.startTransition(()=>{T&&b!==h?F(h):!T&&b!==L&&F(L)})}},[]),o.useEffect(()=>{if(!n.isEmpty(C))return;const h=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&h&&(n.find(c,{key:h})?z(h):z("all"))},[c,C]),o.useEffect(()=>{if(w&&!p&&!n.find(l,{id:w})){const i=new URLSearchParams(g.toString());if(i.delete("page"),[...i.keys()].length>0){if(typeof window<"u"&&window.history&&window.location){const L=i.toString(),T=window.location.hash||"",J=window.location.pathname,ae=L?`${J}?${L}${T}`:`${J}${T}`;window.history.replaceState(window.history.state,"",ae)}u(i)}else typeof window<"u"&&window.history&&window.location&&(window.history.replaceState(window.history.state,"",window.location.pathname+window.location.hash),window.dispatchEvent(new PopStateEvent("popstate",{state:window.history.state}))),u(i)}},[l,w,p,u]),o.useEffect(()=>{w&&!p&&!n.isEmpty(N)&&P(N,w)},[w,p,N,P]),o.useEffect(()=>{!n.isEmpty(v)&&!n.isEmpty(N)&&x(N)},[v,N,x]);const{setSelectedLang:B}=K.useLanguages(),X=o.useCallback(h=>{const i=new URLSearchParams({page:h});b!==d?(i.set("lang",b),B(b)):B(""),y.navigateToPage(i,u),e()},[e,u,B,b,d]),Y=(h,i)=>{var L;if(i)switch(h){case"add":S(i);break;case"select":X(i);break;case"edit":b!==d?V({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):S(i);break;case"delete":E(i);break;case"unpublish":q(i);break;case"markAsTemplate":f(i);break;case"unmarkAsTemplate":_(i);break;case"duplicate":W(i);break;case"addLanguagePage":V({edit:!1,primaryPage:((L=i==null?void 0:i.page)==null?void 0:L.id)||"",preselectedLang:(i==null?void 0:i.language)||b});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(o.Suspense,{children:t.jsx(pe,{pages:N,search:v,setSearch:j,languages:[d,...a],selectedLanguage:b,setSelectedLanguage:F,selectedPageType:C,setSelectedPageType:z,onAddPage:h=>Y("add",h),showUntranslatedPages:U,setShowUntranslatedPages:ne})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:p||re?t.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],h=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},h))}):n.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(k.File,{className:"h-6 w-6 stroke-[1]"}),r("Empty List!"),t.jsx("span",{className:"font-light",children:r("Add new page to start")})]}):t.jsx(te,{tier:0,pages:N,pageTypes:c,currentPage:w||"",onClickAction:Y,languagePages:M,selectedLanguage:b,showUntranslatedPages:U})})]}),A&&t.jsx(o.Suspense,{children:t.jsx(Pe,{closePanel:e,editPage:X,addEditPage:A,setAddEditPage:S})}),m&&t.jsx(o.Suspense,{children:t.jsx(we,{page:m,onClose:()=>E(null)})}),$&&t.jsx(o.Suspense,{children:t.jsx(Se,{page:$,onClose:()=>q(null)})}),I&&t.jsx(o.Suspense,{children:t.jsx(je,{page:I,onClose:()=>f(null)})}),H&&t.jsx(o.Suspense,{children:t.jsx(be,{page:H,onClose:()=>_(null)})}),D&&t.jsx(o.Suspense,{children:t.jsx(ge,{page:D,onClose:()=>W(null),closePanel:e})})]})};exports.default=ve;
@@ -1,31 +1,31 @@
1
- import { jsxs as w, Fragment as q, jsx as t } from "react/jsx-runtime";
2
- import { d as ie } from "./index-94oA-Cgl.js";
3
- import { s as be, t as ge, w as ke, i as de, T as D, aQ as ve, L as Ne, k as Se, e as Le, c as Ce, aw as Ae, aR as Ee, aS as $e } from "./index-CDUCqK5V.js";
1
+ import { jsxs as y, Fragment as q, jsx as t } from "react/jsx-runtime";
2
+ import { d as ie } from "./index-DZheQdw-.js";
3
+ import { ay as be, az as ge, am as ke, i as de, T as D, aP as ve, L as Ne, k as Se, e as Le, c as Ce, as as Ae, aQ as Ee, aR as $e } from "./index-K4yKMKbY.js";
4
4
  import { u as J } from "./use-page-expand-manager-Cf4MUEJw.js";
5
- import { compact as ue, filter as z, isEmpty as k, uniqBy as Te, keyBy as me, mapValues as Me, startCase as Ue, toLower as T, includes as _, get as R, find as W, map as Ie } from "lodash-es";
6
- import { atom as Fe, useAtom as ze, useSetAtom as Be } from "jotai";
5
+ import { compact as ue, filter as F, isEmpty as k, uniqBy as Te, keyBy as me, mapValues as Me, startCase as Ue, toLower as T, includes as _, get as R, find as W, map as Ie } from "lodash-es";
6
+ import { atom as ze, useAtom as Fe, useSetAtom as Be } from "jotai";
7
7
  import { ExternalLink as Oe, Pencil as je, MoreHorizontal as Ge, Lock as De, Plus as Re, ChevronRight as We, StarsIcon as He, Hash as _e, File as he } from "lucide-react";
8
8
  import { useRef as qe, useEffect as $, useMemo as H, useState as N, useCallback as le, startTransition as Qe, Suspense as E, lazy as M } from "react";
9
9
  import { useTranslation as Ve } from "react-i18next";
10
10
  import { B as Xe } from "./register-chai-top-bar-D6GjnauV.js";
11
11
  const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
12
- z(e, (r) => {
12
+ F(e, (a) => {
13
13
  const n = T(s);
14
- return _(T((r == null ? void 0 : r.name) || ""), n) || _(T((r == null ? void 0 : r.slug) || ""), n);
14
+ return _(T((a == null ? void 0 : a.name) || ""), n) || _(T((a == null ? void 0 : a.slug) || ""), n);
15
15
  })
16
16
  ), Ye = (e, s) => {
17
- const r = /* @__PURE__ */ new Set(), n = me(e, "id");
17
+ const a = /* @__PURE__ */ new Set(), n = me(e, "id");
18
18
  return s.forEach((i) => {
19
19
  let o = i;
20
20
  for (; o.parent && n[o.parent]; )
21
- r.add(o.parent), o = n[o.parent];
22
- }), Array.from(r).map((i) => n[i]);
23
- }, Y = (e, s, r) => k(s) ? e : e.map((n) => {
24
- if (!r(n.pageType))
21
+ a.add(o.parent), o = n[o.parent];
22
+ }), Array.from(a).map((i) => n[i]);
23
+ }, Y = (e, s, a) => k(s) ? e : e.map((n) => {
24
+ if (!a(n.pageType))
25
25
  return {
26
26
  ...n,
27
27
  shouldExpandOnSearch: !0,
28
- children: n.children ? Y(n.children, s, r) : []
28
+ children: n.children ? Y(n.children, s, a) : []
29
29
  };
30
30
  const i = n.children && n.children.some(
31
31
  (o) => _(T(o.name || ""), T(s)) || _(T(o.slug || ""), T(s))
@@ -33,7 +33,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
33
33
  return {
34
34
  ...n,
35
35
  shouldExpandOnSearch: i,
36
- children: n.children ? Y(n.children, s, r) : []
36
+ children: n.children ? Y(n.children, s, a) : []
37
37
  };
38
38
  }), Je = (e) => {
39
39
  if (!e || !e.length) return [];
@@ -41,27 +41,27 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
41
41
  e.forEach((n) => {
42
42
  s[n.id] = { ...n, children: [] };
43
43
  });
44
- const r = [];
44
+ const a = [];
45
45
  return Object.values(s).forEach((n) => {
46
- n.parent && s[n.parent] ? s[n.parent].children.push(n) : r.push(n);
47
- }), r;
48
- }, fe = (e) => !e || !e.length ? [] : [...e].sort((r, n) => (r.name || "").localeCompare(n.name || "")).map((r) => ({
49
- ...r,
50
- children: r.children ? fe(r.children) : []
51
- })), Ke = (e, s, r, n) => {
46
+ n.parent && s[n.parent] ? s[n.parent].children.push(n) : a.push(n);
47
+ }), a;
48
+ }, fe = (e) => !e || !e.length ? [] : [...e].sort((a, n) => (a.name || "").localeCompare(n.name || "")).map((a) => ({
49
+ ...a,
50
+ children: a.children ? fe(a.children) : []
51
+ })), Ke = (e, s, a, n) => {
52
52
  if (!e || !e.length) return [];
53
53
  let i = e;
54
- if (r !== "all" && (i = ue(z(e, { pageType: r }))), k(s))
54
+ if (a !== "all" && (i = ue(F(e, { pageType: a }))), k(s))
55
55
  i = ce(i, s);
56
56
  else {
57
57
  const m = ce(i, s), l = Ye(e, m);
58
58
  i = Te([...m, ...l], "id");
59
59
  }
60
- const o = fe(Je(i)), f = Y(o, s, n), y = z(f, (m) => n(m.pageType)).sort(
60
+ const o = fe(Je(i)), f = Y(o, s, n), w = F(f, (m) => n(m.pageType)).sort(
61
61
  (m, l) => (m.name || "").localeCompare(l.name || "")
62
- ), c = z(f, (m) => !n(m.pageType));
62
+ ), c = F(f, (m) => !n(m.pageType));
63
63
  let x = [];
64
- if (r === "all") {
64
+ if (a === "all") {
65
65
  const m = me(c, "pageType");
66
66
  x = Object.values(
67
67
  Me(m, (l, p) => ({
@@ -74,12 +74,12 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
74
74
  );
75
75
  } else
76
76
  x = c.sort((m, l) => (m.name || "").localeCompare(l.name || ""));
77
- return [...y, ...x];
78
- }, Ze = Fe({
77
+ return [...w, ...x];
78
+ }, Ze = ze({
79
79
  pageId: null,
80
80
  position: { x: 0, y: 0 }
81
81
  }), et = ({ pageId: e, children: s }) => {
82
- const [r, n] = ze(Ze), i = qe(null), o = r.pageId === e;
82
+ const [a, n] = Fe(Ze), i = qe(null), o = a.pageId === e;
83
83
  $(() => {
84
84
  const c = () => n({ pageId: null, position: { x: 0, y: 0 } });
85
85
  if (o)
@@ -87,23 +87,23 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
87
87
  }, [o, n]);
88
88
  const f = (c) => {
89
89
  c.preventDefault(), c.stopPropagation(), n({ pageId: e, position: { x: c.clientX, y: c.clientY } });
90
- }, y = () => {
90
+ }, w = () => {
91
91
  const c = `${window.location.pathname}?page=${e}`;
92
92
  window.open(c, "_blank"), n({ pageId: null, position: { x: 0, y: 0 } });
93
93
  };
94
- return /* @__PURE__ */ w(q, { children: [
94
+ return /* @__PURE__ */ y(q, { children: [
95
95
  /* @__PURE__ */ t("span", { onContextMenu: f, children: s }),
96
96
  o && /* @__PURE__ */ t(
97
97
  "div",
98
98
  {
99
99
  ref: i,
100
100
  className: "fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",
101
- style: { top: r.position.y, left: r.position.x },
102
- children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ w(
101
+ style: { top: a.position.y, left: a.position.x },
102
+ children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ y(
103
103
  Xe,
104
104
  {
105
105
  variant: "ghost",
106
- onClick: y,
106
+ onClick: w,
107
107
  className: "w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",
108
108
  children: [
109
109
  /* @__PURE__ */ t(Oe, { className: "h-4 w-4" }),
@@ -116,12 +116,12 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
116
116
  ] });
117
117
  }, tt = ({ page: e }) => {
118
118
  var n, i;
119
- const { isExpanded: s, toggleExpanded: r } = J(e == null ? void 0 : e.id);
119
+ const { isExpanded: s, toggleExpanded: a } = J(e == null ? void 0 : e.id);
120
120
  return /* @__PURE__ */ t(
121
121
  "button",
122
122
  {
123
123
  onClick: (o) => {
124
- o.stopPropagation(), r();
124
+ o.stopPropagation(), a();
125
125
  },
126
126
  disabled: !((n = e == null ? void 0 : e.children) != null && n.length),
127
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 ${(i = e == null ? void 0 : e.children) != null && i.length ? "hover:text-blue-400" : "opacity-0"}`,
@@ -140,16 +140,16 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
140
140
  className: "flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",
141
141
  dangerouslySetInnerHTML: { __html: s.icon }
142
142
  }
143
- ) : s != null && s.hasSlug ? /* @__PURE__ */ t(he, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ t(_e, { size: 12, className: "stroke-[1] text-slate-500" }) }), st = ({ isOnline: e }) => /* @__PURE__ */ t("div", { className: `h-2 w-2 rounded-full ${e ? "bg-green-300" : "bg-gray-300"}` }), rt = ({
143
+ ) : s != null && s.hasSlug ? /* @__PURE__ */ t(he, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ t(_e, { size: 12, className: "stroke-[1] text-slate-500" }) }), st = ({ isOnline: e }) => /* @__PURE__ */ t("div", { className: `h-2 w-2 rounded-full ${e ? "bg-green-300" : "bg-gray-300"}` }), at = ({
144
144
  page: e,
145
145
  pageTypes: s,
146
- currentPage: r,
146
+ currentPage: a,
147
147
  onClickAction: n,
148
148
  languagePages: i,
149
149
  selectedLanguage: o,
150
150
  showUntranslatedPages: f
151
151
  }) => {
152
- const y = be(), { pageToUser: c } = ge(), x = R(c, [e == null ? void 0 : e.id, "userId"]), { data: m } = ke(x), l = m && y !== x ? m == null ? void 0 : m.name : null, p = de(), v = r === e.id, P = H(() => W(s, { key: e.pageType }), [s, e.pageType]);
152
+ const w = be(), { pageToUser: c } = ge(), x = R(c, [e == null ? void 0 : e.id, "userId"]), { data: m } = ke(x), l = m && w !== x ? m == null ? void 0 : m.name : null, p = de(), v = a === e.id, P = H(() => W(s, { key: e.pageType }), [s, e.pageType]);
153
153
  let d = R(i, e == null ? void 0 : e.id);
154
154
  d = R(d, "lang") === o ? d : null;
155
155
  const L = o === p || !!d, U = (d == null ? void 0 : d.name) || (e == null ? void 0 : e.name) || "No name";
@@ -170,8 +170,8 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
170
170
  return !1;
171
171
  return !0;
172
172
  }, [d, e]);
173
- return /* @__PURE__ */ w("div", { className: "group relative", children: [
174
- /* @__PURE__ */ t(et, { pageId: e.id, children: /* @__PURE__ */ w(
173
+ return /* @__PURE__ */ y("div", { className: "group relative", children: [
174
+ /* @__PURE__ */ t(et, { pageId: e.id, children: /* @__PURE__ */ y(
175
175
  "div",
176
176
  {
177
177
  onClick: () => !e.isPartialGroup && L && n("select", e == null ? void 0 : e.id),
@@ -181,9 +181,9 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
181
181
  !e.isPartialGroup && /* @__PURE__ */ t(st, { isOnline: d ? d.online : e.online }),
182
182
  !e.isPartialGroup && /* @__PURE__ */ t(nt, { page: e, pageType: P }),
183
183
  /* @__PURE__ */ t(D, { content: U, side: "top", showTooltip: U.length > 35, children: /* @__PURE__ */ t("span", { className: "max-w-[40%] truncate font-medium text-black", children: U }) }),
184
- (g || e.dynamic) && /* @__PURE__ */ t(D, { content: B, side: "top", showTooltip: !0, children: /* @__PURE__ */ w("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
184
+ (g || e.dynamic) && /* @__PURE__ */ t(D, { content: B, side: "top", showTooltip: !0, children: /* @__PURE__ */ y("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
185
185
  g,
186
- e.dynamic && (P == null ? void 0 : P.dynamicSlug) && /* @__PURE__ */ w("span", { className: "text-xs text-gray-500", children: [
186
+ e.dynamic && (P == null ? void 0 : P.dynamicSlug) && /* @__PURE__ */ y("span", { className: "text-xs text-gray-500", children: [
187
187
  "/",
188
188
  P == null ? void 0 : P.dynamicSlug,
189
189
  e.dynamicSlugCustom
@@ -201,14 +201,14 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
201
201
  setDeletePage: (h) => n("delete", d || h),
202
202
  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(Ge, { className: "h-4 w-4", onClick: (h) => h.stopPropagation() }) })
203
203
  }
204
- ) }) : l ? /* @__PURE__ */ w("span", { className: "duration absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-x-1 text-xs text-red-500", children: [
204
+ ) }) : l ? /* @__PURE__ */ y("span", { className: "duration absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-x-1 text-xs text-red-500", children: [
205
205
  /* @__PURE__ */ t(De, { className: "h-3 w-3 fill-red-200 text-red-500" }),
206
206
  /* @__PURE__ */ t(D, { content: `${l} is editing this page`, children: /* @__PURE__ */ t("span", { className: "font-bold", children: l }) })
207
207
  ] }) : null
208
208
  ]
209
209
  }
210
210
  ) }),
211
- /* @__PURE__ */ t(q, { children: !L && !e.isPartialGroup && !l && /* @__PURE__ */ w(
211
+ /* @__PURE__ */ t(q, { children: !L && !e.isPartialGroup && !l && /* @__PURE__ */ y(
212
212
  "button",
213
213
  {
214
214
  onClick: (h) => {
@@ -218,7 +218,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
218
218
  children: [
219
219
  /* @__PURE__ */ t(Re, { size: 12, className: "stroke-[3]" }),
220
220
  " ",
221
- /* @__PURE__ */ w("span", { className: "text-[10px]", children: [
221
+ /* @__PURE__ */ y("span", { className: "text-[10px]", children: [
222
222
  "Add ",
223
223
  R(Ne, o),
224
224
  " Page"
@@ -230,25 +230,25 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
230
230
  }, xe = ({
231
231
  pages: e,
232
232
  tier: s,
233
- pageTypes: r,
233
+ pageTypes: a,
234
234
  currentPage: n,
235
235
  onClickAction: i,
236
236
  languagePages: o,
237
237
  selectedLanguage: f,
238
- showUntranslatedPages: y
238
+ showUntranslatedPages: w
239
239
  }) => {
240
240
  const { expandedPages: c } = J();
241
- return /* @__PURE__ */ t("div", { className: "space-y-0.5", style: { paddingLeft: `${s * 10}px` }, children: e.map((x) => /* @__PURE__ */ w(q, { children: [
241
+ return /* @__PURE__ */ t("div", { className: "space-y-0.5", style: { paddingLeft: `${s * 10}px` }, children: e.map((x) => /* @__PURE__ */ y(q, { children: [
242
242
  /* @__PURE__ */ t(
243
- rt,
243
+ at,
244
244
  {
245
245
  page: x,
246
- pageTypes: r,
246
+ pageTypes: a,
247
247
  currentPage: n,
248
248
  onClickAction: i,
249
249
  languagePages: o,
250
250
  selectedLanguage: f,
251
- showUntranslatedPages: y
251
+ showUntranslatedPages: w
252
252
  }
253
253
  ),
254
254
  x.children && x.children.length > 0 && (c == null ? void 0 : c.includes(x.id)) && /* @__PURE__ */ t(
@@ -256,31 +256,31 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
256
256
  {
257
257
  pages: x.children,
258
258
  tier: s + 1,
259
- pageTypes: r,
259
+ pageTypes: a,
260
260
  currentPage: n,
261
261
  onClickAction: i,
262
262
  languagePages: o,
263
263
  selectedLanguage: f,
264
- showUntranslatedPages: y
264
+ showUntranslatedPages: w
265
265
  }
266
266
  )
267
267
  ] }, x.id)) });
268
- }, at = M(() => import("./page-manager-search-and-filter-DYXCod2G.js")), ot = M(() => import("./add-new-page-Dd16d2mC.js")), it = M(() => import("./delete-page-DyP68v_N.js")), lt = M(() => import("./duplicate-page-Cg6WnFeY.js")), ct = M(() => import("./mark-as-template-WJ4kUyZK.js")), dt = M(() => import("./unmark-as-template-rGzNVgFR.js")), ut = M(() => import("./unpublish-page-DhtGUDXp.js")), kt = ({ close: e }) => {
269
- const { t: s } = Ve(), { languages: r, setSelectedLang: n } = ie(), { data: i } = Se(), { data: o, isFetching: f } = Le(), [y, c] = Ce(), { updateForSelectedPage: x, expandPagesOnSearch: m } = J(null), l = de(), p = y.get("page"), [v, P] = N(""), [d, L] = N(null), [U, g] = N(null), [B, O] = N(null), [j, h] = N(null), [A, Q] = N(""), [K, Z] = N(null), [ee, te] = N(null), [b, V] = N(l), [pe, we] = N(!1), ne = Be(Ae), G = pe && b !== l, { data: I, isFetching: ye } = Ee(b), se = le(
268
+ }, rt = M(() => import("./page-manager-search-and-filter-CUEUB4bN.js")), ot = M(() => import("./add-new-page-HoFoI257.js")), it = M(() => import("./delete-page-T2VWcbyP.js")), lt = M(() => import("./duplicate-page-Bt36erFD.js")), ct = M(() => import("./mark-as-template-NPUbCfae.js")), dt = M(() => import("./unmark-as-template-YGONVpmY.js")), ut = M(() => import("./unpublish-page-D-A9A9db.js")), kt = ({ close: e }) => {
269
+ const { t: s } = Ve(), { languages: a, setSelectedLang: n } = ie(), { data: i } = Se(), { data: o, isFetching: f } = Le(), [w, c] = Ce(), { updateForSelectedPage: x, expandPagesOnSearch: m } = J(null), l = de(), p = w.get("page"), [v, P] = N(""), [d, L] = N(null), [U, g] = N(null), [B, O] = N(null), [j, h] = N(null), [A, Q] = N(""), [K, Z] = N(null), [ee, te] = N(null), [b, V] = N(l), [pe, ye] = N(!1), ne = Be(Ae), G = pe && b !== l, { data: I, isFetching: we } = Ee(b), se = le(
270
270
  (u) => {
271
- var a;
272
- return (a = W(i, { key: u })) == null ? void 0 : a.hasSlug;
271
+ var r;
272
+ return (r = W(i, { key: u })) == null ? void 0 : r.hasSlug;
273
273
  },
274
274
  [i]
275
- ), S = H(() => o ? G ? z(o, (u) => !(I != null && I[u.id])) : Ke(o, v, A, se) : [], [o, se, v, A, I, G]);
275
+ ), S = H(() => o ? G ? F(o, (u) => !(I != null && I[u.id])) : Ke(o, v, A, se) : [], [o, se, v, A, I, G]);
276
276
  $(() => {
277
277
  n(l);
278
278
  }, [l, n]), $(() => {
279
- const u = y.get("lang");
279
+ const u = w.get("lang");
280
280
  if (u) {
281
- const a = r, C = r[0] ?? l, F = a.includes(u);
281
+ const r = a, C = a[0] ?? l, z = r.includes(u);
282
282
  Qe(() => {
283
- F && b !== u ? V(u) : !F && b !== C && V(C);
283
+ z && b !== u ? V(u) : !z && b !== C && V(C);
284
284
  });
285
285
  }
286
286
  }, []), $(() => {
@@ -289,87 +289,87 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
289
289
  !k(i) && u && (W(i, { key: u }) ? Q(u) : Q("all"));
290
290
  }, [i, A]), $(() => {
291
291
  if (p && !f && !W(o, { id: p })) {
292
- const a = new URLSearchParams(y.toString());
293
- if (a.delete("page"), [...a.keys()].length > 0) {
292
+ const r = new URLSearchParams(w.toString());
293
+ if (r.delete("page"), [...r.keys()].length > 0) {
294
294
  if (typeof window < "u" && window.history && window.location) {
295
- const C = a.toString(), F = window.location.hash || "", oe = window.location.pathname, Pe = C ? `${oe}?${C}${F}` : `${oe}${F}`;
295
+ const C = r.toString(), z = window.location.hash || "", oe = window.location.pathname, Pe = C ? `${oe}?${C}${z}` : `${oe}${z}`;
296
296
  window.history.replaceState(window.history.state, "", Pe);
297
297
  }
298
- c(a);
298
+ c(r);
299
299
  } else
300
- typeof window < "u" && window.history && window.location && (window.history.replaceState(window.history.state, "", window.location.pathname + window.location.hash), window.dispatchEvent(new PopStateEvent("popstate", { state: window.history.state }))), c(a);
300
+ typeof window < "u" && window.history && window.location && (window.history.replaceState(window.history.state, "", window.location.pathname + window.location.hash), window.dispatchEvent(new PopStateEvent("popstate", { state: window.history.state }))), c(r);
301
301
  }
302
302
  }, [o, p, f, c]), $(() => {
303
303
  p && !f && !k(S) && x(S, p);
304
304
  }, [p, f, S, x]), $(() => {
305
305
  !k(v) && !k(S) && m(S);
306
306
  }, [v, S, m]);
307
- const { setSelectedLang: X } = ie(), re = le(
307
+ const { setSelectedLang: X } = ie(), ae = le(
308
308
  (u) => {
309
- const a = new URLSearchParams({ page: u });
310
- b !== l ? (a.set("lang", b), X(b)) : X(""), $e(a, c), e();
309
+ const r = new URLSearchParams({ page: u });
310
+ b !== l ? (r.set("lang", b), X(b)) : X(""), $e(r, c), e();
311
311
  },
312
312
  [e, c, X, b, l]
313
- ), ae = (u, a) => {
313
+ ), re = (u, r) => {
314
314
  var C;
315
- if (a)
315
+ if (r)
316
316
  switch (u) {
317
317
  case "add":
318
- g(a);
318
+ g(r);
319
319
  break;
320
320
  case "select":
321
- re(a);
321
+ ae(r);
322
322
  break;
323
323
  case "edit":
324
324
  b !== l ? ne({
325
325
  edit: !0,
326
- id: a == null ? void 0 : a.id,
327
- primaryPage: a == null ? void 0 : a.primaryPage
328
- }) : g(a);
326
+ id: r == null ? void 0 : r.id,
327
+ primaryPage: r == null ? void 0 : r.primaryPage
328
+ }) : g(r);
329
329
  break;
330
330
  case "delete":
331
- L(a);
331
+ L(r);
332
332
  break;
333
333
  case "unpublish":
334
- O(a);
334
+ O(r);
335
335
  break;
336
336
  case "markAsTemplate":
337
- h(a);
337
+ h(r);
338
338
  break;
339
339
  case "unmarkAsTemplate":
340
- te(a);
340
+ te(r);
341
341
  break;
342
342
  case "duplicate":
343
- Z(a);
343
+ Z(r);
344
344
  break;
345
345
  case "addLanguagePage":
346
346
  ne({
347
347
  edit: !1,
348
- primaryPage: ((C = a == null ? void 0 : a.page) == null ? void 0 : C.id) || "",
349
- preselectedLang: (a == null ? void 0 : a.language) || b
348
+ primaryPage: ((C = r == null ? void 0 : r.page) == null ? void 0 : C.id) || "",
349
+ preselectedLang: (r == null ? void 0 : r.language) || b
350
350
  });
351
351
  break;
352
352
  }
353
353
  };
354
- return /* @__PURE__ */ w(q, { children: [
355
- /* @__PURE__ */ w("div", { className: "flex h-full flex-col justify-between", children: [
354
+ return /* @__PURE__ */ y(q, { children: [
355
+ /* @__PURE__ */ y("div", { className: "flex h-full flex-col justify-between", children: [
356
356
  /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(
357
- at,
357
+ rt,
358
358
  {
359
359
  pages: S,
360
360
  search: v,
361
361
  setSearch: P,
362
- languages: [l, ...r],
362
+ languages: [l, ...a],
363
363
  selectedLanguage: b,
364
364
  setSelectedLanguage: V,
365
365
  selectedPageType: A,
366
366
  setSelectedPageType: Q,
367
- onAddPage: (u) => ae("add", u),
367
+ onAddPage: (u) => re("add", u),
368
368
  showUntranslatedPages: G,
369
- setShowUntranslatedPages: we
369
+ setShowUntranslatedPages: ye
370
370
  }
371
371
  ) }),
372
- /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: f || ye ? /* @__PURE__ */ t("div", { className: "space-y-2", children: Ie([...Array(15).keys()], (u) => /* @__PURE__ */ t("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, u)) }) : k(S) ? /* @__PURE__ */ w("div", { className: "flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500", children: [
372
+ /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: f || we ? /* @__PURE__ */ t("div", { className: "space-y-2", children: Ie([...Array(15).keys()], (u) => /* @__PURE__ */ t("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, u)) }) : k(S) ? /* @__PURE__ */ y("div", { className: "flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500", children: [
373
373
  /* @__PURE__ */ t(he, { className: "h-6 w-6 stroke-[1]" }),
374
374
  s("Empty List!"),
375
375
  /* @__PURE__ */ t("span", { className: "font-light", children: s("Add new page to start") })
@@ -380,7 +380,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
380
380
  pages: S,
381
381
  pageTypes: i,
382
382
  currentPage: p || "",
383
- onClickAction: ae,
383
+ onClickAction: re,
384
384
  languagePages: I,
385
385
  selectedLanguage: b,
386
386
  showUntranslatedPages: G
@@ -391,7 +391,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
391
391
  ot,
392
392
  {
393
393
  closePanel: e,
394
- editPage: re,
394
+ editPage: ae,
395
395
  addEditPage: U,
396
396
  setAddEditPage: g
397
397
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-BsloTOgy.cjs"),f=require("./index-Bg3Prrc_.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",autoFocus:!0})]})},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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-DyW9GPzV.cjs"),n=require("./index-W4Ur56bi.cjs"),f=require("./index-DvOWqGdC.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",autoFocus:!0})]})},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,7 @@
1
1
  import { jsx as e, jsxs as a, Fragment as k } from "react/jsx-runtime";
2
2
  import { B as m, z as E } from "./register-chai-top-bar-D6GjnauV.js";
3
- import { w as g, x as b, y, S as F, z as L, A as I, B as w } from "./index-94oA-Cgl.js";
4
- import { i as j, L as T, k as $, A as B } from "./index-CDUCqK5V.js";
3
+ import { w as g, x as b, y, S as F, z as L, A as I, B as w } from "./index-DZheQdw-.js";
4
+ import { i as j, L as T, k as $, A as B } from "./index-K4yKMKbY.js";
5
5
  import { u as G } from "./use-page-expand-manager-Cf4MUEJw.js";
6
6
  import { useQueryClient as D } from "@tanstack/react-query";
7
7
  import { isEmpty as N, filter as x, map as S, get as i } from "lodash-es";