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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/{2SSKDMRQ-DVWVGtU8.cjs → 2SSKDMRQ-C6XmPkPR.cjs} +1 -1
  2. package/dist/{2SSKDMRQ-SUA5eA2S.js → 2SSKDMRQ-DTcPSOGn.js} +2 -2
  3. package/dist/{AP7HFJJL-CUN5zddU.cjs → AP7HFJJL-6aBLUYOi.cjs} +1 -1
  4. package/dist/{AP7HFJJL-Co5bLh3I.js → AP7HFJJL-CVazlaEj.js} +1 -1
  5. package/dist/{IconPicker-BZvFj3cg.js → IconPicker-CcBoA1K0.js} +1 -1
  6. package/dist/{IconPicker-Bmz6vXB8.cjs → IconPicker-sbWeQ9M9.cjs} +1 -1
  7. package/dist/{WDYDFRGG-BpSteEEf.cjs → WDYDFRGG-BtzyRDmj.cjs} +1 -1
  8. package/dist/{WDYDFRGG-DjCIT9L-.js → WDYDFRGG-CwiYliX0.js} +2 -2
  9. package/dist/{active-in-another-tab-DfRJcvAz.js → active-in-another-tab-B4O3FEEg.js} +2 -2
  10. package/dist/{active-in-another-tab-C8-vpt8f.cjs → active-in-another-tab-DRJY0QqU.cjs} +1 -1
  11. package/dist/{add-new-language-page-jZ7Pg0Fv.js → add-new-language-page-BfYL9jXF.js} +3 -3
  12. package/dist/{add-new-language-page-B2BEmfil.cjs → add-new-language-page-CKIRTFjr.cjs} +1 -1
  13. package/dist/{add-new-page-YZF_XF8X.js → add-new-page-DVgxz4fs.js} +2 -2
  14. package/dist/{add-new-page-DbEBB3w7.cjs → add-new-page-dzN_CD2c.cjs} +1 -1
  15. package/dist/{ai-panel-content-C8ecaQnv.js → ai-panel-content-D5eFLI_B.js} +3 -3
  16. package/dist/{ai-panel-content-Bf_ojKwt.cjs → ai-panel-content-Dyw4RHCV.cjs} +1 -1
  17. package/dist/{ai-panel-default-lang-BC8Gq_jl.js → ai-panel-default-lang-Cj7meZBD.js} +3 -3
  18. package/dist/{ai-panel-default-lang-DokOmE_Q.cjs → ai-panel-default-lang-DEj9Qx2M.cjs} +2 -2
  19. package/dist/{ai-panel-other-lang-BJ30SL7z.js → ai-panel-other-lang-Cbi6HKzd.js} +3 -3
  20. package/dist/{ai-panel-other-lang-Ccx1t8pp.cjs → ai-panel-other-lang-Da2XLEcm.cjs} +1 -1
  21. package/dist/{ai-prompt-input-SfeB6a2j.js → ai-prompt-input-B6QoqT9B.js} +1 -1
  22. package/dist/{ai-prompt-input-ED14e6NE.cjs → ai-prompt-input-DXS8gzex.cjs} +1 -1
  23. package/dist/{ai-translation-prompt-BRRzei71.js → ai-translation-prompt-Dmq_Ahjf.js} +1 -1
  24. package/dist/{ai-translation-prompt-spS-OC6L.cjs → ai-translation-prompt-Uswft8iz.cjs} +1 -1
  25. package/dist/{code-editor-CIqswl5j.cjs → code-editor-DbSBrsUA.cjs} +1 -1
  26. package/dist/{code-editor-CYiIxUKp.js → code-editor-wQWmwFKW.js} +1 -1
  27. package/dist/{continue-editing-in-this-client-vICoETHN.js → continue-editing-in-this-client-BV0OrgEU.js} +2 -2
  28. package/dist/{continue-editing-in-this-client-B3CnmiZ2.cjs → continue-editing-in-this-client-Dkkzk8YZ.cjs} +1 -1
  29. package/dist/core.cjs +1 -1
  30. package/dist/core.d.ts +1 -0
  31. package/dist/core.js +1 -1
  32. package/dist/{css-import-modal-CHFZPXXQ.cjs → css-import-modal-C3f5sphx.cjs} +1 -1
  33. package/dist/{css-import-modal-DautOct0.js → css-import-modal-Co_YLkLB.js} +1 -1
  34. package/dist/{delete-design-token-BmWHk_Ap.js → delete-design-token-CJPAcsWp.js} +1 -1
  35. package/dist/{delete-design-token-D-wGR5qS.cjs → delete-design-token-zzNmNYLR.cjs} +1 -1
  36. package/dist/{delete-page-D5mzl-ET.cjs → delete-page-6lInxYM_.cjs} +1 -1
  37. package/dist/{delete-page-Dlv8srng.js → delete-page-CQTjB7ZZ.js} +2 -2
  38. package/dist/{design-token-usage-hl29qR_q.js → design-token-usage-BQY6eqzE.js} +1 -1
  39. package/dist/{design-token-usage-DIszlgJK.cjs → design-token-usage-blwlGuEE.cjs} +1 -1
  40. package/dist/{digital-asset-manager-v2LfDXwR.cjs → digital-asset-manager-cGUpTcu3.cjs} +1 -1
  41. package/dist/{digital-asset-manager-o_bNl9qj.js → digital-asset-manager-lPKoJ4FH.js} +3 -3
  42. package/dist/{duplicate-page-BjqgghN0.js → duplicate-page-Dmgqp93w.js} +3 -3
  43. package/dist/{duplicate-page-CEuF8dll.cjs → duplicate-page-rYeBMwHR.cjs} +1 -1
  44. package/dist/{dynamic-page-selector-BWC7kHJ1.js → dynamic-page-selector-CVyA9Zp0.js} +2 -2
  45. package/dist/{dynamic-page-selector-D4EWs4Qd.cjs → dynamic-page-selector-zqGqpcww.cjs} +1 -1
  46. package/dist/{get-chai-builder-theme-DDVRJQ6Z.js → get-chai-builder-theme-CfJkQYZc.js} +1 -1
  47. package/dist/{get-chai-builder-theme-BApShjRz.cjs → get-chai-builder-theme-Dm1z70lQ.cjs} +1 -1
  48. package/dist/{image-editor-2h5axNuk.cjs → image-editor-Cn1DgrNp.cjs} +1 -1
  49. package/dist/{image-editor-B1-bjvPd.js → image-editor-mVBb0VD_.js} +1 -1
  50. package/dist/{index-BJVYKKJq.cjs → index-B5qvHqN5.cjs} +2 -2
  51. package/dist/{index-DWGTiEak.cjs → index-EFWvSWoi.cjs} +11 -11
  52. package/dist/{index-BvluH-oT.js → index-GfOB5KV1.js} +20 -20
  53. package/dist/{index-BN6yEl-H.js → index-lm46VtIP.js} +889 -887
  54. package/dist/{json-diff-viewer-BjCIlzd7.cjs → json-diff-viewer-BeSMdSd5.cjs} +1 -1
  55. package/dist/{json-diff-viewer-WX0GIjq-.js → json-diff-viewer-D5yJoFh1.js} +2 -2
  56. package/dist/{lang-panel-C4x7bcyb.js → lang-panel-7qTejsLm.js} +3 -3
  57. package/dist/{lang-panel--yfjRDE2.cjs → lang-panel-B-QUotOn.cjs} +1 -1
  58. package/dist/{manage-design-tokens-CRwsErkx.js → manage-design-tokens-DeH-yNJN.js} +2 -2
  59. package/dist/{manage-design-tokens-DhdwhzQu.cjs → manage-design-tokens-TeWNZekH.cjs} +1 -1
  60. package/dist/{mark-as-template-BH0W9p2G.cjs → mark-as-template-Co00KkhA.cjs} +1 -1
  61. package/dist/{mark-as-template-DpZSFrLK.js → mark-as-template-RkfNETRW.js} +2 -2
  62. package/dist/{nested-path-selector-content-BDQmZzlf.js → nested-path-selector-content-Dimjyy8J.js} +1 -1
  63. package/dist/{nested-path-selector-content-CHYz7cdB.cjs → nested-path-selector-content-hBvmT_2A.cjs} +1 -1
  64. package/dist/{no-language-page-content-D0lcCseQ.js → no-language-page-content-Bk3sTsdM.js} +2 -2
  65. package/dist/{no-language-page-content-D7btm8zX.cjs → no-language-page-content-CLovr1bL.cjs} +1 -1
  66. package/dist/{no-language-page-dialog-sYOmLnpY.cjs → no-language-page-dialog-C21Fq-UD.cjs} +1 -1
  67. package/dist/{no-language-page-dialog-BdW7oXvt.js → no-language-page-dialog-Cx-YOrAd.js} +2 -2
  68. package/dist/{page-creator-O_QpbMlB.js → page-creator-BBuYY84G.js} +3 -3
  69. package/dist/{page-creator-B-jBAGZl.cjs → page-creator-BDmospqO.cjs} +1 -1
  70. package/dist/{page-lock-CmQKpw1U.js → page-lock-BrGWj326.js} +2 -2
  71. package/dist/{page-lock-BrVqfmVm.cjs → page-lock-DG5IvZaG.cjs} +1 -1
  72. package/dist/{page-locked-dialog-ChHVSk7X.cjs → page-locked-dialog-DKnQpIMB.cjs} +1 -1
  73. package/dist/{page-locked-dialog-BjeJOXuN.js → page-locked-dialog-DUktYJzU.js} +2 -2
  74. package/dist/{page-manager-new-wcsdorbd.js → page-manager-new-BfKYDWs7.js} +3 -3
  75. package/dist/{page-manager-new-B90zLpRY.cjs → page-manager-new-iYsDkUzG.cjs} +1 -1
  76. package/dist/{page-manager-search-and-filter-Bb_Zfpsj.cjs → page-manager-search-and-filter-CIspvIW2.cjs} +1 -1
  77. package/dist/{page-manager-search-and-filter-DY_NsetM.js → page-manager-search-and-filter-DVAGxnlw.js} +2 -2
  78. package/dist/{page-revisions-content-CVpi-467.cjs → page-revisions-content-B84UtAxm.cjs} +1 -1
  79. package/dist/{page-revisions-content-5h39VYXj.js → page-revisions-content-DB4mj_Cw.js} +3 -3
  80. package/dist/pages.cjs +1 -1
  81. package/dist/pages.d.ts +1 -0
  82. package/dist/pages.js +1 -1
  83. package/dist/{plugin-BGlQf0iy.cjs → plugin-BfC_qpW2.cjs} +10 -10
  84. package/dist/{plugin-C-ht41UZ.js → plugin-DVNaUexn.js} +86 -80
  85. package/dist/{publish-pages-content-rrfvXks4.js → publish-pages-content-BRKsIr9W.js} +3 -3
  86. package/dist/{publish-pages-content-BG1GIuIz.cjs → publish-pages-content-ysv37LxZ.cjs} +1 -1
  87. package/dist/render.cjs +1 -1
  88. package/dist/render.d.ts +4 -1
  89. package/dist/render.js +2 -2
  90. package/dist/{rte-widget-modal-JRoPPuju.cjs → rte-widget-modal-BS040t_9.cjs} +1 -1
  91. package/dist/{rte-widget-modal-29WtCMJs.js → rte-widget-modal-Dj5BvA-1.js} +1 -1
  92. package/dist/{save-to-lib-YvzDV5ee.cjs → save-to-lib-ClCCNy6W.cjs} +1 -1
  93. package/dist/{save-to-lib-Bm7R2K7j.js → save-to-lib-D3kp0ovZ.js} +2 -2
  94. package/dist/{selected-block-display-BAulh0Nz.js → selected-block-display-BtlTAkei.js} +2 -2
  95. package/dist/{selected-block-display-bdClAekS.cjs → selected-block-display-BvRoOMt9.cjs} +1 -1
  96. package/dist/{seo-panel-D9wnaLG-.cjs → seo-panel-CHGdB8_7.cjs} +1 -1
  97. package/dist/{seo-panel-CT0D3I44.js → seo-panel-C_Cnwj1-.js} +2 -2
  98. package/dist/{shared-json-ld-ON6LaybZ.cjs → shared-json-ld-DA0wz-k3.cjs} +1 -1
  99. package/dist/{shared-json-ld-CuhqVL8H.js → shared-json-ld-DPr0Douk.js} +2 -2
  100. package/dist/{slug-input-DNeh6LBv.js → slug-input-CqhlfgAe.js} +1 -1
  101. package/dist/{slug-input-CxmcQbTR.cjs → slug-input-DltqfQ3y.cjs} +1 -1
  102. package/dist/{take-over-request-CrILj_3q.cjs → take-over-request-Bq7OF5Gp.cjs} +1 -1
  103. package/dist/{take-over-request-BmeR6t3b.js → take-over-request-ByUlm_HK.js} +2 -2
  104. package/dist/{theme-panel-footer-D4oCAY2G.js → theme-panel-footer-DG7Z5YjD.js} +2 -2
  105. package/dist/{theme-panel-footer-BMx5lGB4.cjs → theme-panel-footer-XYoM6sn5.cjs} +1 -1
  106. package/dist/{translation-warning-modal-ChL7oDO1.cjs → translation-warning-modal-DTxxfo0H.cjs} +1 -1
  107. package/dist/{translation-warning-modal-BNG9m-FC.js → translation-warning-modal-DaBUipEY.js} +1 -1
  108. package/dist/types.d.ts +1 -0
  109. package/dist/{unmark-as-template-CEEMIY1A.js → unmark-as-template-BOFHOO0_.js} +2 -2
  110. package/dist/{unmark-as-template-BYiyJloZ.cjs → unmark-as-template-C9EXTj0X.cjs} +1 -1
  111. package/dist/{unpublish-page-B0aY1JnO.cjs → unpublish-page-B5rev9W3.cjs} +1 -1
  112. package/dist/{unpublish-page-Bm20P3TB.js → unpublish-page-KDM7kEEV.js} +2 -2
  113. package/dist/utils.cjs +1 -1
  114. package/dist/utils.js +1 -1
  115. package/dist/{web-preview-BtEn4Vc-.js → web-preview-BDgUTTr8.js} +1 -1
  116. package/dist/{web-preview-iQgiotU6.cjs → web-preview-CvpevNzM.cjs} +1 -1
  117. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),J=require("./index-DWGTiEak.cjs"),p=require("./index-BJVYKKJq.cjs"),O=require("./use-page-expand-manager-B6XTvk0E.cjs"),n=require("lodash-es"),R=require("jotai"),v=require("lucide-react"),l=require("react"),re=require("react-i18next"),ae=require("./register-chai-top-bar-DWTuRU53.cjs"),K=(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 i=c;for(;i.parent&&s[i.parent];)a.add(i.parent),i=s[i.parent]}),Array.from(a).map(c=>s[c])},B=(e,r,a)=>n.isEmpty(r)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?B(s.children,r,a):[]};const c=s.children&&s.children.some(i=>n.includes(n.toLower(i.name||""),n.toLower(r))||n.includes(n.toLower(i.slug||""),n.toLower(r)));return{...s,shouldExpandOnSearch:c,children:s.children?B(s.children,r,a):[]}}),ie=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},Z=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?Z(a.children):[]})),oe=(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=K(c,r);else{const f=K(c,r),u=le(e,f);c=n.uniqBy([...f,...u],"id")}const i=Z(ie(c)),y=B(i,r,s),k=n.filter(y,f=>s(f.pageType)).sort((f,u)=>(f.name||"").localeCompare(u.name||"")),m=n.filter(y,f=>!s(f.pageType));let P=[];if(a==="all"){const f=n.keyBy(m,"pageType");P=Object.values(n.mapValues(f,(u,g)=>({...u,id:g,name:n.startCase(g),isPartialGroup:!0,children:y.filter(w=>w.pageType===g)})))}else P=m.sort((f,u)=>(f.name||"").localeCompare(u.name||""));return[...k,...P]},ce=R.atom({pageId:null,position:{x:0,y:0}}),de=({pageId:e,children:r})=>{const[a,s]=R.useAtom(ce),c=l.useRef(null),i=a.pageId===e;l.useEffect(()=>{const m=()=>s({pageId:null,position:{x:0,y:0}});if(i)return document.addEventListener("click",m),()=>document.removeEventListener("click",m)},[i,s]);const y=m=>{m.preventDefault(),m.stopPropagation(),s({pageId:e,position:{x:m.clientX,y:m.clientY}})},k=()=>{const m=`${window.location.pathname}?page=${e}`;window.open(m,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:y,children:r}),i&&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(ae.Button,{variant:"ghost",onClick:k,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(v.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},ue=({page:e})=>{var s,c;const{isExpanded:r,toggleExpanded:a}=O.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:i=>{i.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(v.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},me=({page:e,pageType:r})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(v.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(v.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(v.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),he=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),xe=({page:e,pageTypes:r,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:i,showUntranslatedPages:y})=>{const k=p.useUserId(),{pageToUser:m}=p.usePageToUser(),P=n.get(m,[e==null?void 0:e.id,"userId"]),{data:f}=p.useChaiUserInfo(P),u=f&&k!==P?f==null?void 0:f.name:null,g=p.useFallbackLang(),w=a===e.id,F=!!e.isTemplate,j=l.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]);let h=n.get(c,e==null?void 0:e.id);h=n.get(h,"lang")===i?h:null;const E=i===g||!!h,L=(h==null?void 0:h.name)||(e==null?void 0:e.name)||"No name";let S=(h==null?void 0:h.slug)||(e==null?void 0:e.slug)||"";const M=S+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(S.startsWith("/")&&!y){const d=S.split("/").pop();S=S.endsWith(d)&&e.dynamic?"":`/${d}`}const q=l.useMemo(()=>{const d="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=`${w?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${d} ${C} ${u?"opacity-60":""}`:`${d} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,w,u]),z=l.useMemo(()=>{if(e.isPartialGroup)return!1;if(h){if(!h.online||n.isEmpty(h.changes))return!1}else if(e&&(!e.online||n.isEmpty(e.changes)))return!1;return!0},[h,e]);return t.jsxs("div",{className:"group relative",children:[t.jsx(de,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:q,children:[t.jsx(ue,{page:e}),!e.isPartialGroup&&t.jsx(he,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&t.jsx(me,{page:e,pageType:j}),t.jsx(p.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(S||e.dynamic)&&t.jsx(p.Tooltip,{content:M,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]})]})}),z&&t.jsx(p.Tooltip,{content:"Has unpublished changes",side:"top",children:t.jsx("span",{className:"text-amber-500",children:t.jsx(v.Pencil,{size:12,className:"stroke-[2]"})})}),F&&t.jsx(p.Tooltip,{content:"Template",side:"top",children:t.jsx("span",{className:"text-blue-500",children:t.jsx(v.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!u?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(p.PageActionsDropdown,{isLanguagePage:!!h,page:h||e,setDuplicatePage:d=>s("duplicate",d),setAddEditPage:d=>s("edit",h||d),setUnpublishPage:d=>s("unpublish",d),setDeletePage:d=>s("delete",h||d),setMarkAsTemplate:d=>s("markAsTemplate",d),setUnmarkAsTemplate:d=>s("unmarkAsTemplate",d),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(v.MoreHorizontal,{className:"h-4 w-4",onClick:d=>d.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(v.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(v.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:d=>{d.stopPropagation(),s("addLanguagePage",{language:i,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(v.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(p.LANGUAGES,i)," Page"]})]})})]})},ee=({pages:e,tier:r,pageTypes:a,currentPage:s,onClickAction:c,languagePages:i,selectedLanguage:y,showUntranslatedPages:k})=>{const{expandedPages:m}=O.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(xe,{page:P,pageTypes:a,currentPage:s,onClickAction:c,languagePages:i,selectedLanguage:y,showUntranslatedPages:k}),P.children&&P.children.length>0&&(m==null?void 0:m.includes(P.id))&&t.jsx(ee,{pages:P.children,tier:r+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:i,selectedLanguage:y,showUntranslatedPages:k})]},P.id))})},fe=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-Bb_Zfpsj.cjs"))),pe=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-DbEBB3w7.cjs"))),ye=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-D5mzl-ET.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-CEuF8dll.cjs"))),ge=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-BH0W9p2G.cjs"))),je=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-BYiyJloZ.cjs"))),be=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-B0aY1JnO.cjs"))),ve=({close:e})=>{const{t:r}=re.useTranslation(),{languages:a,setSelectedLang:s}=J.useLanguages(),{data:c}=p.usePageTypes(),{data:i,isFetching:y}=p.useWebsitePages(),[k,m]=p.useSearchParams(),{updateForSelectedPage:P,expandPagesOnSearch:f}=O.usePageExpandManager(null),u=p.useFallbackLang(),g=k.get("page"),[w,F]=l.useState(""),[j,h]=l.useState(null),[E,L]=l.useState(null),[S,M]=l.useState(null),[q,z]=l.useState(null),[d,C]=l.useState(""),[G,D]=l.useState(null),[W,H]=l.useState(null),[b,I]=l.useState(u),[te,se]=l.useState(!1),_=R.useSetAtom(p.addNewLangAtom),U=te&&b!==u,{data:A,isFetching:ne}=p.useWebsiteLanguagePages(b),V=l.useCallback(x=>{var o;return(o=n.find(c,{key:x}))==null?void 0:o.hasSlug},[c]),N=l.useMemo(()=>i?U?n.filter(i,x=>!(A!=null&&A[x.id])):oe(i,w,d,V):[],[i,V,w,d,A,U]);l.useEffect(()=>{s(u)},[u,s]),l.useEffect(()=>{const x=k.get("lang");if(x){const o=a,T=a[0]??u,Y=o.includes(x);l.startTransition(()=>{Y&&b!==x?I(x):!Y&&b!==T&&I(T)})}},[]),l.useEffect(()=>{if(!n.isEmpty(d))return;const x=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&x&&(n.find(c,{key:x})?C(x):C("all"))},[c,d]),l.useEffect(()=>{if(g&&!y&&!n.find(i,{id:g})){const o=n.find(i,{slug:"/"});if(o){const T=new URLSearchParams({page:o.id});p.navigateToPage(T,m)}else p.navigateToPage(new URLSearchParams({}),m,!0)}},[i,g,y,m]),l.useEffect(()=>{g&&!y&&!n.isEmpty(N)&&P(N,g)},[g,y,N,P]),l.useEffect(()=>{!n.isEmpty(w)&&!n.isEmpty(N)&&f(N)},[w,N,f]);const{setSelectedLang:$}=J.useLanguages(),Q=l.useCallback(x=>{const o=new URLSearchParams({page:x});b!==u?(o.set("lang",b),$(b)):$(""),p.navigateToPage(o,m),e()},[e,m,$,b,u]),X=(x,o)=>{var T;if(o)switch(x){case"add":L(o);break;case"select":Q(o);break;case"edit":b!==u?_({edit:!0,id:o==null?void 0:o.id,primaryPage:o==null?void 0:o.primaryPage}):L(o);break;case"delete":h(o);break;case"unpublish":M(o);break;case"markAsTemplate":z(o);break;case"unmarkAsTemplate":H(o);break;case"duplicate":D(o);break;case"addLanguagePage":_({edit:!1,primaryPage:((T=o==null?void 0:o.page)==null?void 0:T.id)||"",preselectedLang:(o==null?void 0:o.language)||b});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(fe,{pages:N,search:w,setSearch:F,languages:[u,...a],selectedLanguage:b,setSelectedLanguage:I,selectedPageType:d,setSelectedPageType:C,onAddPage:x=>X("add",x),showUntranslatedPages:U,setShowUntranslatedPages:se})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:y||ne?t.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],x=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},x))}):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(v.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(ee,{tier:0,pages:N,pageTypes:c,currentPage:g||"",onClickAction:X,languagePages:A,selectedLanguage:b,showUntranslatedPages:U})})]}),E&&t.jsx(l.Suspense,{children:t.jsx(pe,{closePanel:e,editPage:Q,addEditPage:E,setAddEditPage:L})}),j&&t.jsx(l.Suspense,{children:t.jsx(ye,{page:j,onClose:()=>h(null)})}),S&&t.jsx(l.Suspense,{children:t.jsx(be,{page:S,onClose:()=>M(null)})}),q&&t.jsx(l.Suspense,{children:t.jsx(ge,{page:q,onClose:()=>z(null)})}),W&&t.jsx(l.Suspense,{children:t.jsx(je,{page:W,onClose:()=>H(null)})}),G&&t.jsx(l.Suspense,{children:t.jsx(Pe,{page:G,onClose:()=>D(null),closePanel:e})})]})};exports.default=ve;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),J=require("./index-EFWvSWoi.cjs"),p=require("./index-B5qvHqN5.cjs"),O=require("./use-page-expand-manager-B6XTvk0E.cjs"),n=require("lodash-es"),R=require("jotai"),v=require("lucide-react"),l=require("react"),re=require("react-i18next"),ae=require("./register-chai-top-bar-DWTuRU53.cjs"),K=(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 i=c;for(;i.parent&&s[i.parent];)a.add(i.parent),i=s[i.parent]}),Array.from(a).map(c=>s[c])},B=(e,r,a)=>n.isEmpty(r)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?B(s.children,r,a):[]};const c=s.children&&s.children.some(i=>n.includes(n.toLower(i.name||""),n.toLower(r))||n.includes(n.toLower(i.slug||""),n.toLower(r)));return{...s,shouldExpandOnSearch:c,children:s.children?B(s.children,r,a):[]}}),ie=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},Z=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?Z(a.children):[]})),oe=(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=K(c,r);else{const f=K(c,r),u=le(e,f);c=n.uniqBy([...f,...u],"id")}const i=Z(ie(c)),y=B(i,r,s),k=n.filter(y,f=>s(f.pageType)).sort((f,u)=>(f.name||"").localeCompare(u.name||"")),m=n.filter(y,f=>!s(f.pageType));let P=[];if(a==="all"){const f=n.keyBy(m,"pageType");P=Object.values(n.mapValues(f,(u,g)=>({...u,id:g,name:n.startCase(g),isPartialGroup:!0,children:y.filter(w=>w.pageType===g)})))}else P=m.sort((f,u)=>(f.name||"").localeCompare(u.name||""));return[...k,...P]},ce=R.atom({pageId:null,position:{x:0,y:0}}),de=({pageId:e,children:r})=>{const[a,s]=R.useAtom(ce),c=l.useRef(null),i=a.pageId===e;l.useEffect(()=>{const m=()=>s({pageId:null,position:{x:0,y:0}});if(i)return document.addEventListener("click",m),()=>document.removeEventListener("click",m)},[i,s]);const y=m=>{m.preventDefault(),m.stopPropagation(),s({pageId:e,position:{x:m.clientX,y:m.clientY}})},k=()=>{const m=`${window.location.pathname}?page=${e}`;window.open(m,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:y,children:r}),i&&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(ae.Button,{variant:"ghost",onClick:k,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(v.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},ue=({page:e})=>{var s,c;const{isExpanded:r,toggleExpanded:a}=O.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:i=>{i.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(v.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},me=({page:e,pageType:r})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(v.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(v.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(v.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),he=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),xe=({page:e,pageTypes:r,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:i,showUntranslatedPages:y})=>{const k=p.useUserId(),{pageToUser:m}=p.usePageToUser(),P=n.get(m,[e==null?void 0:e.id,"userId"]),{data:f}=p.useChaiUserInfo(P),u=f&&k!==P?f==null?void 0:f.name:null,g=p.useFallbackLang(),w=a===e.id,F=!!e.isTemplate,j=l.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]);let h=n.get(c,e==null?void 0:e.id);h=n.get(h,"lang")===i?h:null;const E=i===g||!!h,L=(h==null?void 0:h.name)||(e==null?void 0:e.name)||"No name";let S=(h==null?void 0:h.slug)||(e==null?void 0:e.slug)||"";const M=S+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(S.startsWith("/")&&!y){const d=S.split("/").pop();S=S.endsWith(d)&&e.dynamic?"":`/${d}`}const q=l.useMemo(()=>{const d="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=`${w?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${d} ${C} ${u?"opacity-60":""}`:`${d} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,w,u]),z=l.useMemo(()=>{if(e.isPartialGroup)return!1;if(h){if(!h.online||n.isEmpty(h.changes))return!1}else if(e&&(!e.online||n.isEmpty(e.changes)))return!1;return!0},[h,e]);return t.jsxs("div",{className:"group relative",children:[t.jsx(de,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:q,children:[t.jsx(ue,{page:e}),!e.isPartialGroup&&t.jsx(he,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&t.jsx(me,{page:e,pageType:j}),t.jsx(p.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(S||e.dynamic)&&t.jsx(p.Tooltip,{content:M,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]})]})}),z&&t.jsx(p.Tooltip,{content:"Has unpublished changes",side:"top",children:t.jsx("span",{className:"text-amber-500",children:t.jsx(v.Pencil,{size:12,className:"stroke-[2]"})})}),F&&t.jsx(p.Tooltip,{content:"Template",side:"top",children:t.jsx("span",{className:"text-blue-500",children:t.jsx(v.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!u?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(p.PageActionsDropdown,{isLanguagePage:!!h,page:h||e,setDuplicatePage:d=>s("duplicate",d),setAddEditPage:d=>s("edit",h||d),setUnpublishPage:d=>s("unpublish",d),setDeletePage:d=>s("delete",h||d),setMarkAsTemplate:d=>s("markAsTemplate",d),setUnmarkAsTemplate:d=>s("unmarkAsTemplate",d),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(v.MoreHorizontal,{className:"h-4 w-4",onClick:d=>d.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(v.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(v.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:d=>{d.stopPropagation(),s("addLanguagePage",{language:i,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(v.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(p.LANGUAGES,i)," Page"]})]})})]})},ee=({pages:e,tier:r,pageTypes:a,currentPage:s,onClickAction:c,languagePages:i,selectedLanguage:y,showUntranslatedPages:k})=>{const{expandedPages:m}=O.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(xe,{page:P,pageTypes:a,currentPage:s,onClickAction:c,languagePages:i,selectedLanguage:y,showUntranslatedPages:k}),P.children&&P.children.length>0&&(m==null?void 0:m.includes(P.id))&&t.jsx(ee,{pages:P.children,tier:r+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:i,selectedLanguage:y,showUntranslatedPages:k})]},P.id))})},fe=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-CIspvIW2.cjs"))),pe=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-dzN_CD2c.cjs"))),ye=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-6lInxYM_.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-rYeBMwHR.cjs"))),ge=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-Co00KkhA.cjs"))),je=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-C9EXTj0X.cjs"))),be=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-B5rev9W3.cjs"))),ve=({close:e})=>{const{t:r}=re.useTranslation(),{languages:a,setSelectedLang:s}=J.useLanguages(),{data:c}=p.usePageTypes(),{data:i,isFetching:y}=p.useWebsitePages(),[k,m]=p.useSearchParams(),{updateForSelectedPage:P,expandPagesOnSearch:f}=O.usePageExpandManager(null),u=p.useFallbackLang(),g=k.get("page"),[w,F]=l.useState(""),[j,h]=l.useState(null),[E,L]=l.useState(null),[S,M]=l.useState(null),[q,z]=l.useState(null),[d,C]=l.useState(""),[G,D]=l.useState(null),[W,H]=l.useState(null),[b,I]=l.useState(u),[te,se]=l.useState(!1),_=R.useSetAtom(p.addNewLangAtom),U=te&&b!==u,{data:A,isFetching:ne}=p.useWebsiteLanguagePages(b),V=l.useCallback(x=>{var o;return(o=n.find(c,{key:x}))==null?void 0:o.hasSlug},[c]),N=l.useMemo(()=>i?U?n.filter(i,x=>!(A!=null&&A[x.id])):oe(i,w,d,V):[],[i,V,w,d,A,U]);l.useEffect(()=>{s(u)},[u,s]),l.useEffect(()=>{const x=k.get("lang");if(x){const o=a,T=a[0]??u,Y=o.includes(x);l.startTransition(()=>{Y&&b!==x?I(x):!Y&&b!==T&&I(T)})}},[]),l.useEffect(()=>{if(!n.isEmpty(d))return;const x=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&x&&(n.find(c,{key:x})?C(x):C("all"))},[c,d]),l.useEffect(()=>{if(g&&!y&&!n.find(i,{id:g})){const o=n.find(i,{slug:"/"});if(o){const T=new URLSearchParams({page:o.id});p.navigateToPage(T,m)}else p.navigateToPage(new URLSearchParams({}),m,!0)}},[i,g,y,m]),l.useEffect(()=>{g&&!y&&!n.isEmpty(N)&&P(N,g)},[g,y,N,P]),l.useEffect(()=>{!n.isEmpty(w)&&!n.isEmpty(N)&&f(N)},[w,N,f]);const{setSelectedLang:$}=J.useLanguages(),Q=l.useCallback(x=>{const o=new URLSearchParams({page:x});b!==u?(o.set("lang",b),$(b)):$(""),p.navigateToPage(o,m),e()},[e,m,$,b,u]),X=(x,o)=>{var T;if(o)switch(x){case"add":L(o);break;case"select":Q(o);break;case"edit":b!==u?_({edit:!0,id:o==null?void 0:o.id,primaryPage:o==null?void 0:o.primaryPage}):L(o);break;case"delete":h(o);break;case"unpublish":M(o);break;case"markAsTemplate":z(o);break;case"unmarkAsTemplate":H(o);break;case"duplicate":D(o);break;case"addLanguagePage":_({edit:!1,primaryPage:((T=o==null?void 0:o.page)==null?void 0:T.id)||"",preselectedLang:(o==null?void 0:o.language)||b});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(fe,{pages:N,search:w,setSearch:F,languages:[u,...a],selectedLanguage:b,setSelectedLanguage:I,selectedPageType:d,setSelectedPageType:C,onAddPage:x=>X("add",x),showUntranslatedPages:U,setShowUntranslatedPages:se})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:y||ne?t.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],x=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},x))}):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(v.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(ee,{tier:0,pages:N,pageTypes:c,currentPage:g||"",onClickAction:X,languagePages:A,selectedLanguage:b,showUntranslatedPages:U})})]}),E&&t.jsx(l.Suspense,{children:t.jsx(pe,{closePanel:e,editPage:Q,addEditPage:E,setAddEditPage:L})}),j&&t.jsx(l.Suspense,{children:t.jsx(ye,{page:j,onClose:()=>h(null)})}),S&&t.jsx(l.Suspense,{children:t.jsx(be,{page:S,onClose:()=>M(null)})}),q&&t.jsx(l.Suspense,{children:t.jsx(ge,{page:q,onClose:()=>z(null)})}),W&&t.jsx(l.Suspense,{children:t.jsx(je,{page:W,onClose:()=>H(null)})}),G&&t.jsx(l.Suspense,{children:t.jsx(Pe,{page:G,onClose:()=>D(null),closePanel:e})})]})};exports.default=ve;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-DWTuRU53.cjs"),n=require("./index-DWGTiEak.cjs"),f=require("./index-BJVYKKJq.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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-DWTuRU53.cjs"),n=require("./index-EFWvSWoi.cjs"),f=require("./index-B5qvHqN5.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,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-CX_JkRJn.js";
3
- import { x as g, y as b, z as y, S as L, A as F, B as I, E as N } from "./index-BN6yEl-H.js";
4
- import { k as j, L as T, m as $, A as B } from "./index-BvluH-oT.js";
3
+ import { x as g, y as b, z as y, S as L, A as F, B as I, E as N } from "./index-lm46VtIP.js";
4
+ import { k as j, L as T, m as $, A as B } from "./index-GfOB5KV1.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 w, filter as x, map as S, get as o } from "lodash-es";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("./register-chai-top-bar-DWTuRU53.cjs"),i=require("./index-DWGTiEak.cjs"),c=require("./index-BJVYKKJq.cjs"),y=require("@tanstack/react-query"),S=require("date-fns"),B=require("lodash-es"),f=require("lucide-react"),g=require("react");function L(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const w=L(g);function Q(s){const n=c.useApiUrl(),t=c.useFetch();return y.useQuery({queryKey:[c.ACTIONS.GET_PAGE_REVISIONS,s],queryFn:async()=>await t(n,{action:c.ACTIONS.GET_PAGE_REVISIONS,data:{pageId:s}}),enabled:!!s,refetchOnMount:!0})}const z=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async r=>await n(s,{action:c.ACTIONS.DELETE_PAGE_REVISION,data:{revisionId:r}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},H=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async({revisionId:r,discardCurrent:l,pageId:d})=>await n(s,{action:c.ACTIONS.RESTORE_PAGE_REVISION,data:{revisionId:r,discardCurrent:l,...d&&{pageId:d}}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},$=g.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-BjCIlzd7.cjs"))),b=({tag:s})=>s==="draft"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Draft"})]}):s==="live"?e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Live"})]}):s==="published"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-green-500/10 px-1.5 py-0.5 text-xs text-green-600",children:[e.jsx(f.Rocket,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Published"})]}):s==="unsaved"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-xs text-red-600",children:[e.jsx(f.Save,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Unsaved changes"})]}):e.jsx("span",{className:"rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600",children:s});function J({compare:s,setCompare:n}){const{data:t}=c.useChaiCurrentPage(),{saveState:r}=i.useSavePage(),[l]=c.usePageEditInfo();if(!t)return null;const d=!!s.find(x=>{var a;return(a=x==null?void 0:x.uid)==null?void 0:a.startsWith("draft:")}),u=s.length>=2&&!d,m=r==="UNSAVED";return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border bg-primary/5 p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-1 text-sm font-medium leading-none",children:[e.jsx(b,{tag:"draft"}),e.jsx("span",{className:"text-xs font-bold",children:"Currently editing"})]})}),e.jsx("div",{className:"flex items-center pl-2 text-[11px] text-muted-foreground",children:!B.isEmpty(l.lastSaved)&&e.jsxs("span",{children:["Last updated"," ",S.formatDistanceToNow(new Date(l.lastSaved),{addSuffix:!0})]})}),e.jsx("div",{className:"flex items-center gap-2 pt-0.5",children:m?e.jsx(b,{tag:"unsaved"}):null})]}),e.jsx(O,{checked:d,disabled:u,onChange:()=>{n(d?s.filter(x=>x.uid!==`draft:${t==null?void 0:t.id}`):[...s,{uid:`draft:${t==null?void 0:t.id}`,label:"draft",item:{createdAt:Date.now()}}])}})]})}function K(){return e.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((s,n)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(i.Skeleton,{className:"h-4 w-3/4"}),e.jsx(i.Skeleton,{className:"h-3 w-1/2"}),e.jsx(i.Skeleton,{className:"mt-1 h-5 w-20"})]}),e.jsx(i.Skeleton,{className:"h-8 w-8 rounded-full"})]},n))})}function I({revision:s,isLatest:n,onRestore:t,onDelete:r,revisionNumber:l,compare:d,setCompare:u,pageId:m}){const{data:x}=c.useChaiUserInfo(s.currentEditor),a=(x==null?void 0:x.name)||"Unknown",p=!!d.find(h=>{var j;return n?(j=h==null?void 0:h.uid)==null?void 0:j.startsWith("live"):(h==null?void 0:h.uid)===s.uid}),D=d.length>=2&&!p;return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"flex items-center gap-1 text-xs leading-none",children:[e.jsx(b,{tag:n?"live":`#${l}`}),s.type==="published"?"Published":"Draft"," by ",e.jsx("span",{className:"text-xs font-bold",children:a})]})}),e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:s.type==="published"?e.jsx(b,{tag:"published"}):e.jsx(b,{tag:"draft"})}),e.jsx("div",{className:"flex items-center text-[10px] text-muted-foreground",children:e.jsx("span",{className:"leading-tight",children:S.format(s.createdAt,"MMM d, yyyy, h:mm a")})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(c.PermissionChecker,{permissions:[c.PAGES_PERMISSIONS.RESTORE_REVISION,c.PAGES_PERMISSIONS.DELETE_REVISION],children:e.jsx(Y,{revision:s,onRestore:t,onDelete:r})})}),e.jsx(O,{checked:p,disabled:D,onChange:()=>{u(p?d.filter(h=>n?h.uid!==`live:${m}`:h.uid!==s.uid):[...d,{uid:n?`live:${m}`:s.uid,label:n?"live":`#${l}`,item:s}].sort((h,j)=>new Date(h.item.createdAt).getTime()-new Date(j.item.createdAt).getTime()))}})]})}function A({tab:s,onRemove:n}){return e.jsxs("span",{className:"flex items-center justify-between rounded border border-blue-100 p-1 font-medium",children:[e.jsx(b,{tag:s.label}),e.jsx("button",{className:"z-0 flex h-4 w-4 items-center justify-center rounded-full text-gray-400 hover:text-red-500",style:{lineHeight:1},onClick:()=>n(s.uid),"aria-label":"Remove selection",children:e.jsx(f.X,{className:"h-3 w-3"})})]})}function W({compare:s,setCompare:n,pageId:t}){const[r,l]=g.useState(!1),[d,u]=s;if(s.length===0)return null;const m=x=>n(s.filter(a=>a.uid!==x));return e.jsxs("div",{className:"mb-2 flex w-full max-w-md flex-col gap-1 rounded border bg-accent/60 p-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-xs",children:[e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"Compare"}),d&&e.jsx(A,{tab:d,onRemove:m}),e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"with"}),u?e.jsx(A,{tab:u,onRemove:m}):e.jsx("span",{className:"rounded border px-1 text-xs text-muted-foreground",children:"Choose another"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pb-0.5 pt-2",children:[e.jsx(N.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none text-gray-500",variant:"outline",onClick:()=>n([]),children:e.jsx("span",{children:" Clear"})}),e.jsxs(N.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none",variant:"default",onClick:()=>l(!0),disabled:s.length<2,children:[e.jsx(f.FileJson,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"pt-0.5",children:"Show JSON Diff"})]})]}),r&&(s==null?void 0:s.length)>1&&t&&e.jsx(g.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx("span",{className:"text-sm",children:"Loading diff viewer..."})}),children:e.jsx($,{open:r,onOpenChange:l,compare:s})})]})}function O({checked:s,disabled:n,onChange:t,label:r="Compare"}){return e.jsx("div",{className:"absolute bottom-2 right-2",children:e.jsxs("label",{className:`flex cursor-pointer items-center gap-x-1 text-[11px] ${n?"opacity-50":""}`,children:[e.jsx("input",{type:"checkbox",className:"h-3 w-3 cursor-pointer rounded focus:ring-0 focus:ring-offset-0",checked:s,disabled:n,onChange:t}),e.jsx("span",{className:"select-none leading-tight",children:r})]})})}function Y({revision:s,onRestore:n,onDelete:t}){return e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(N.Button,{variant:"ghost",size:"icon",className:"h-5 w-5",children:[e.jsx(f.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More options"})]})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"text-xs",children:[e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.RESTORE_REVISION,children:e.jsxs(i.DropdownMenuItem,{onClick:n,className:"cursor-pointer text-sm",children:[e.jsx(f.Undo2,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Restore this version"})]})}),e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.DELETE_REVISION,children:s.uid!=="current"&&e.jsxs(e.Fragment,{children:[e.jsx(i.DropdownMenuSeparator,{}),e.jsxs(i.DropdownMenuItem,{onClick:t,className:"cursor-pointer text-destructive",children:[e.jsx(f.Trash,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Delete this version"})]})]})})]})]})}function X({open:s,onOpenChange:n,revision:t,onRestore:r,isRestoring:l}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{l||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Restore Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to restore to revision ",t.uid.substring(0,8)," from"," ",S.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"How would you like to handle your current edits?"})}),e.jsxs(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>r(!1),disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Saving as draft..."]}):e.jsxs(e.Fragment,{children:[e.jsx(f.CloudOff,{className:"mr-2 h-4 w-4"}),"Save as draft"]})}),e.jsx(N.Button,{variant:"default",className:"sm:flex-1",onClick:()=>r(!0),disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Discarding current..."]}):e.jsxs(e.Fragment,{children:[e.jsx(f.Undo2,{className:"mr-2 h-4 w-4"}),"Discard current"]})})]})]})}):null}function Z({open:s,onOpenChange:n,revision:t,onDelete:r,isDeleting:l}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{l||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Delete Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to delete revision ",t.uid.substring(0,8)," from"," ",S.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone. Are you sure you want to proceed?"})}),e.jsxs(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>n(!1),disabled:l,children:"Cancel"}),e.jsx(N.Button,{variant:"destructive",className:"sm:flex-1",onClick:r,disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(f.Trash,{className:"mr-2 h-4 w-4"}),"Delete Revision"]})})]})]})}):null}function ee({isOpen:s}){var R;const[n,t]=w.useState([]),[r,l]=w.useState(null),[d,u]=w.useState(!1),[m,x]=w.useState(!1),{data:a}=c.useChaiCurrentPage(),{data:p,isFetching:D,error:h,refetch:j}=Q(a==null?void 0:a.id),{mutate:T,isPending:M}=z(),{mutate:k,isPending:F}=H(),_=y.useQueryClient(),{selectedLang:q,fallbackLang:P}=i.useLanguages(),U=q||P;g.useEffect(()=>{g.startTransition(()=>t([]))},[a==null?void 0:a.id]);const G=o=>{r&&k({revisionId:r.uid,discardCurrent:o,...r.uid==="current"&&(a==null?void 0:a.id)&&{pageId:a.id}},{onSuccess:()=>{u(!1),l(null),_.invalidateQueries({queryKey:[c.ACTIONS.GET_DRAFT_PAGE]})}})},C=o=>{l(o),u(!0)},E=o=>{l(o),x(!0)},V=()=>{r&&T(r.uid,{onSuccess:()=>{x(!1),l(null)}})};return g.useEffect(()=>{s&&j()},[s,j]),e.jsxs(e.Fragment,{children:[e.jsxs(i.SheetHeader,{children:[e.jsx(i.SheetTitle,{children:"Revision History"}),(a==null?void 0:a.createdAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Page created on ",S.format(new Date(a.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),D?e.jsx(K,{}):h?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Failed to load revisions. Please try again."}):e.jsxs("div",{className:"mt-2 flex h-full min-h-0 flex-1 flex-col space-y-2",children:[e.jsx(W,{lang:U,compare:n,setCompare:t,pageId:a==null?void 0:a.id}),e.jsx(J,{compare:n,setCompare:t}),(R=p==null?void 0:p.filter(o=>o.uid==="current"))==null?void 0:R.map((o,v)=>e.jsx(I,{pageId:a==null?void 0:a.id,revision:o,isLatest:!0,onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:v,compare:n,setCompare:t},o.uid)),e.jsx(i.ScrollArea,{className:"min-h-0 flex-1",children:e.jsx("div",{className:"space-y-2",children:[...p??[]].filter(o=>o.uid!=="current").sort((o,v)=>new Date(v.createdAt).getTime()-new Date(o.createdAt).getTime()).map((o,v)=>e.jsx(I,{pageId:a==null?void 0:a.id,revision:o,isLatest:o.uid==="current",onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:v+1,compare:n,setCompare:t},o.uid))})})]}),e.jsx(X,{open:d,onOpenChange:u,revision:r,onRestore:G,isRestoring:F}),e.jsx(Z,{open:m,onOpenChange:x,revision:r,onDelete:V,isDeleting:M})]})}exports.default=ee;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("./register-chai-top-bar-DWTuRU53.cjs"),i=require("./index-EFWvSWoi.cjs"),c=require("./index-B5qvHqN5.cjs"),y=require("@tanstack/react-query"),S=require("date-fns"),B=require("lodash-es"),f=require("lucide-react"),g=require("react");function L(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const w=L(g);function Q(s){const n=c.useApiUrl(),t=c.useFetch();return y.useQuery({queryKey:[c.ACTIONS.GET_PAGE_REVISIONS,s],queryFn:async()=>await t(n,{action:c.ACTIONS.GET_PAGE_REVISIONS,data:{pageId:s}}),enabled:!!s,refetchOnMount:!0})}const z=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async r=>await n(s,{action:c.ACTIONS.DELETE_PAGE_REVISION,data:{revisionId:r}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},H=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async({revisionId:r,discardCurrent:l,pageId:d})=>await n(s,{action:c.ACTIONS.RESTORE_PAGE_REVISION,data:{revisionId:r,discardCurrent:l,...d&&{pageId:d}}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},$=g.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-BeSMdSd5.cjs"))),b=({tag:s})=>s==="draft"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Draft"})]}):s==="live"?e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Live"})]}):s==="published"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-green-500/10 px-1.5 py-0.5 text-xs text-green-600",children:[e.jsx(f.Rocket,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Published"})]}):s==="unsaved"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-xs text-red-600",children:[e.jsx(f.Save,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Unsaved changes"})]}):e.jsx("span",{className:"rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600",children:s});function J({compare:s,setCompare:n}){const{data:t}=c.useChaiCurrentPage(),{saveState:r}=i.useSavePage(),[l]=c.usePageEditInfo();if(!t)return null;const d=!!s.find(x=>{var a;return(a=x==null?void 0:x.uid)==null?void 0:a.startsWith("draft:")}),u=s.length>=2&&!d,m=r==="UNSAVED";return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border bg-primary/5 p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-1 text-sm font-medium leading-none",children:[e.jsx(b,{tag:"draft"}),e.jsx("span",{className:"text-xs font-bold",children:"Currently editing"})]})}),e.jsx("div",{className:"flex items-center pl-2 text-[11px] text-muted-foreground",children:!B.isEmpty(l.lastSaved)&&e.jsxs("span",{children:["Last updated"," ",S.formatDistanceToNow(new Date(l.lastSaved),{addSuffix:!0})]})}),e.jsx("div",{className:"flex items-center gap-2 pt-0.5",children:m?e.jsx(b,{tag:"unsaved"}):null})]}),e.jsx(O,{checked:d,disabled:u,onChange:()=>{n(d?s.filter(x=>x.uid!==`draft:${t==null?void 0:t.id}`):[...s,{uid:`draft:${t==null?void 0:t.id}`,label:"draft",item:{createdAt:Date.now()}}])}})]})}function K(){return e.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((s,n)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(i.Skeleton,{className:"h-4 w-3/4"}),e.jsx(i.Skeleton,{className:"h-3 w-1/2"}),e.jsx(i.Skeleton,{className:"mt-1 h-5 w-20"})]}),e.jsx(i.Skeleton,{className:"h-8 w-8 rounded-full"})]},n))})}function I({revision:s,isLatest:n,onRestore:t,onDelete:r,revisionNumber:l,compare:d,setCompare:u,pageId:m}){const{data:x}=c.useChaiUserInfo(s.currentEditor),a=(x==null?void 0:x.name)||"Unknown",p=!!d.find(h=>{var j;return n?(j=h==null?void 0:h.uid)==null?void 0:j.startsWith("live"):(h==null?void 0:h.uid)===s.uid}),D=d.length>=2&&!p;return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"flex items-center gap-1 text-xs leading-none",children:[e.jsx(b,{tag:n?"live":`#${l}`}),s.type==="published"?"Published":"Draft"," by ",e.jsx("span",{className:"text-xs font-bold",children:a})]})}),e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:s.type==="published"?e.jsx(b,{tag:"published"}):e.jsx(b,{tag:"draft"})}),e.jsx("div",{className:"flex items-center text-[10px] text-muted-foreground",children:e.jsx("span",{className:"leading-tight",children:S.format(s.createdAt,"MMM d, yyyy, h:mm a")})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(c.PermissionChecker,{permissions:[c.PAGES_PERMISSIONS.RESTORE_REVISION,c.PAGES_PERMISSIONS.DELETE_REVISION],children:e.jsx(Y,{revision:s,onRestore:t,onDelete:r})})}),e.jsx(O,{checked:p,disabled:D,onChange:()=>{u(p?d.filter(h=>n?h.uid!==`live:${m}`:h.uid!==s.uid):[...d,{uid:n?`live:${m}`:s.uid,label:n?"live":`#${l}`,item:s}].sort((h,j)=>new Date(h.item.createdAt).getTime()-new Date(j.item.createdAt).getTime()))}})]})}function A({tab:s,onRemove:n}){return e.jsxs("span",{className:"flex items-center justify-between rounded border border-blue-100 p-1 font-medium",children:[e.jsx(b,{tag:s.label}),e.jsx("button",{className:"z-0 flex h-4 w-4 items-center justify-center rounded-full text-gray-400 hover:text-red-500",style:{lineHeight:1},onClick:()=>n(s.uid),"aria-label":"Remove selection",children:e.jsx(f.X,{className:"h-3 w-3"})})]})}function W({compare:s,setCompare:n,pageId:t}){const[r,l]=g.useState(!1),[d,u]=s;if(s.length===0)return null;const m=x=>n(s.filter(a=>a.uid!==x));return e.jsxs("div",{className:"mb-2 flex w-full max-w-md flex-col gap-1 rounded border bg-accent/60 p-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-xs",children:[e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"Compare"}),d&&e.jsx(A,{tab:d,onRemove:m}),e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"with"}),u?e.jsx(A,{tab:u,onRemove:m}):e.jsx("span",{className:"rounded border px-1 text-xs text-muted-foreground",children:"Choose another"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pb-0.5 pt-2",children:[e.jsx(N.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none text-gray-500",variant:"outline",onClick:()=>n([]),children:e.jsx("span",{children:" Clear"})}),e.jsxs(N.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none",variant:"default",onClick:()=>l(!0),disabled:s.length<2,children:[e.jsx(f.FileJson,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"pt-0.5",children:"Show JSON Diff"})]})]}),r&&(s==null?void 0:s.length)>1&&t&&e.jsx(g.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx("span",{className:"text-sm",children:"Loading diff viewer..."})}),children:e.jsx($,{open:r,onOpenChange:l,compare:s})})]})}function O({checked:s,disabled:n,onChange:t,label:r="Compare"}){return e.jsx("div",{className:"absolute bottom-2 right-2",children:e.jsxs("label",{className:`flex cursor-pointer items-center gap-x-1 text-[11px] ${n?"opacity-50":""}`,children:[e.jsx("input",{type:"checkbox",className:"h-3 w-3 cursor-pointer rounded focus:ring-0 focus:ring-offset-0",checked:s,disabled:n,onChange:t}),e.jsx("span",{className:"select-none leading-tight",children:r})]})})}function Y({revision:s,onRestore:n,onDelete:t}){return e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(N.Button,{variant:"ghost",size:"icon",className:"h-5 w-5",children:[e.jsx(f.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More options"})]})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"text-xs",children:[e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.RESTORE_REVISION,children:e.jsxs(i.DropdownMenuItem,{onClick:n,className:"cursor-pointer text-sm",children:[e.jsx(f.Undo2,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Restore this version"})]})}),e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.DELETE_REVISION,children:s.uid!=="current"&&e.jsxs(e.Fragment,{children:[e.jsx(i.DropdownMenuSeparator,{}),e.jsxs(i.DropdownMenuItem,{onClick:t,className:"cursor-pointer text-destructive",children:[e.jsx(f.Trash,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Delete this version"})]})]})})]})]})}function X({open:s,onOpenChange:n,revision:t,onRestore:r,isRestoring:l}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{l||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Restore Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to restore to revision ",t.uid.substring(0,8)," from"," ",S.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"How would you like to handle your current edits?"})}),e.jsxs(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>r(!1),disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Saving as draft..."]}):e.jsxs(e.Fragment,{children:[e.jsx(f.CloudOff,{className:"mr-2 h-4 w-4"}),"Save as draft"]})}),e.jsx(N.Button,{variant:"default",className:"sm:flex-1",onClick:()=>r(!0),disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Discarding current..."]}):e.jsxs(e.Fragment,{children:[e.jsx(f.Undo2,{className:"mr-2 h-4 w-4"}),"Discard current"]})})]})]})}):null}function Z({open:s,onOpenChange:n,revision:t,onDelete:r,isDeleting:l}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{l||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Delete Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to delete revision ",t.uid.substring(0,8)," from"," ",S.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone. Are you sure you want to proceed?"})}),e.jsxs(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>n(!1),disabled:l,children:"Cancel"}),e.jsx(N.Button,{variant:"destructive",className:"sm:flex-1",onClick:r,disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(f.Trash,{className:"mr-2 h-4 w-4"}),"Delete Revision"]})})]})]})}):null}function ee({isOpen:s}){var R;const[n,t]=w.useState([]),[r,l]=w.useState(null),[d,u]=w.useState(!1),[m,x]=w.useState(!1),{data:a}=c.useChaiCurrentPage(),{data:p,isFetching:D,error:h,refetch:j}=Q(a==null?void 0:a.id),{mutate:T,isPending:M}=z(),{mutate:k,isPending:F}=H(),_=y.useQueryClient(),{selectedLang:q,fallbackLang:P}=i.useLanguages(),U=q||P;g.useEffect(()=>{g.startTransition(()=>t([]))},[a==null?void 0:a.id]);const G=o=>{r&&k({revisionId:r.uid,discardCurrent:o,...r.uid==="current"&&(a==null?void 0:a.id)&&{pageId:a.id}},{onSuccess:()=>{u(!1),l(null),_.invalidateQueries({queryKey:[c.ACTIONS.GET_DRAFT_PAGE]})}})},C=o=>{l(o),u(!0)},E=o=>{l(o),x(!0)},V=()=>{r&&T(r.uid,{onSuccess:()=>{x(!1),l(null)}})};return g.useEffect(()=>{s&&j()},[s,j]),e.jsxs(e.Fragment,{children:[e.jsxs(i.SheetHeader,{children:[e.jsx(i.SheetTitle,{children:"Revision History"}),(a==null?void 0:a.createdAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Page created on ",S.format(new Date(a.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),D?e.jsx(K,{}):h?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Failed to load revisions. Please try again."}):e.jsxs("div",{className:"mt-2 flex h-full min-h-0 flex-1 flex-col space-y-2",children:[e.jsx(W,{lang:U,compare:n,setCompare:t,pageId:a==null?void 0:a.id}),e.jsx(J,{compare:n,setCompare:t}),(R=p==null?void 0:p.filter(o=>o.uid==="current"))==null?void 0:R.map((o,v)=>e.jsx(I,{pageId:a==null?void 0:a.id,revision:o,isLatest:!0,onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:v,compare:n,setCompare:t},o.uid)),e.jsx(i.ScrollArea,{className:"min-h-0 flex-1",children:e.jsx("div",{className:"space-y-2",children:[...p??[]].filter(o=>o.uid!=="current").sort((o,v)=>new Date(v.createdAt).getTime()-new Date(o.createdAt).getTime()).map((o,v)=>e.jsx(I,{pageId:a==null?void 0:a.id,revision:o,isLatest:o.uid==="current",onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:v+1,compare:n,setCompare:t},o.uid))})})]}),e.jsx(X,{open:d,onOpenChange:u,revision:r,onRestore:G,isRestoring:F}),e.jsx(Z,{open:m,onOpenChange:x,revision:r,onDelete:V,isDeleting:M})]})}exports.default=ee;
@@ -1,7 +1,7 @@
1
1
  import { jsxs as a, Fragment as p, jsx as e } from "react/jsx-runtime";
2
2
  import { B as g } from "./register-chai-top-bar-CX_JkRJn.js";
3
- import { d as le, ab as re, ac as ie, a3 as de, ad as v, R as ce, D as G, e as j, f as q, g as L, p as z, r as $, s as oe, t as ue, v as me, w as _, ae as he } from "./index-BN6yEl-H.js";
4
- import { ar as C, as as A, A as y, aw as H, az as fe, ap as I, ax as E, ay as D } from "./index-BvluH-oT.js";
3
+ import { d as le, ab as re, ac as ie, a3 as de, ad as v, R as ce, D as G, e as j, f as q, g as L, p as z, r as $, s as oe, t as ue, v as me, w as _, ae as he } from "./index-lm46VtIP.js";
4
+ import { ar as C, as as A, A as y, aw as H, az as fe, ap as I, ax as E, ay as D } from "./index-GfOB5KV1.js";
5
5
  import { useQuery as pe, useQueryClient as O, useMutation as J } from "@tanstack/react-query";
6
6
  import { format as S, formatDistanceToNow as xe } from "date-fns";
7
7
  import { isEmpty as ge } from "lodash-es";
@@ -50,7 +50,7 @@ const Ie = () => {
50
50
  });
51
51
  }
52
52
  });
53
- }, Te = Ce(() => import("./json-diff-viewer-WX0GIjq-.js")), N = ({ tag: t }) => t === "draft" ? /* @__PURE__ */ a("div", { className: "flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600", children: [
53
+ }, Te = Ce(() => import("./json-diff-viewer-D5yJoFh1.js")), N = ({ tag: t }) => t === "draft" ? /* @__PURE__ */ a("div", { className: "flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600", children: [
54
54
  /* @__PURE__ */ a("span", { className: "relative flex h-2 w-2", children: [
55
55
  /* @__PURE__ */ e("span", { className: "absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75" }),
56
56
  /* @__PURE__ */ e("span", { className: "relative inline-flex h-2 w-2 rounded-full bg-amber-500" })
package/dist/pages.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BJVYKKJq.cjs");exports.ChaiJsonInput=e.SmartJsonInput;exports.ChaiWebsiteBuilder=e.ChaiWebsiteBuilder;exports.ImagePicker=e.ImagePicker;exports.LanguageSwitcher=e.LanguageSwitcher;exports.NestedPathSelector=e.NestedPathSelector;exports.PermissionChecker=e.PermissionChecker;exports.SupabaseRealtimeAdapter=e.SupabaseRealtimeAdapter;exports.createRealtimeAdapter=e.createRealtimeAdapter;exports.useActivePage=e.useActivePage;exports.useApiUrl=e.useApiUrl;exports.useBuilderFetch=e.useBuilderFetch;exports.useBuilderPageData=e.useBuilderPageData;exports.useChaiAuth=e.useChaiAuth;exports.useChaiCurrentPage=e.useChaiCurrentPage;exports.useChaiUserInfo=e.useChaiUserInfo;exports.useClearAll=e.useClearAll;exports.useFallbackLang=e.useFallbackLang;exports.useFetch=e.useFetch;exports.useGotoPage=e.useGotoPage;exports.useLanguagePages=e.useLanguagePages;exports.usePageTypes=e.usePageTypes;exports.useRealtimeAdapter=e.useRealtimeAdapter;exports.useReloadPage=e.useReloadPage;exports.useUpdateActivePageMetadata=e.useUpdateActivePageMetadata;exports.useUserPermissions=e.useUserRoleAndPermissions;exports.useWebsitePages=e.useWebsitePages;exports.useWebsiteSetting=e.useWebsiteSetting;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-B5qvHqN5.cjs");exports.ChaiJsonInput=e.SmartJsonInput;exports.ChaiWebsiteBuilder=e.ChaiWebsiteBuilder;exports.ImagePicker=e.ImagePicker;exports.LanguageSwitcher=e.LanguageSwitcher;exports.NestedPathSelector=e.NestedPathSelector;exports.PermissionChecker=e.PermissionChecker;exports.SupabaseRealtimeAdapter=e.SupabaseRealtimeAdapter;exports.createRealtimeAdapter=e.createRealtimeAdapter;exports.useActivePage=e.useActivePage;exports.useApiUrl=e.useApiUrl;exports.useBuilderFetch=e.useBuilderFetch;exports.useBuilderPageData=e.useBuilderPageData;exports.useChaiAuth=e.useChaiAuth;exports.useChaiCurrentPage=e.useChaiCurrentPage;exports.useChaiUserInfo=e.useChaiUserInfo;exports.useClearAll=e.useClearAll;exports.useFallbackLang=e.useFallbackLang;exports.useFetch=e.useFetch;exports.useGotoPage=e.useGotoPage;exports.useLanguagePages=e.useLanguagePages;exports.usePageTypes=e.usePageTypes;exports.useRealtimeAdapter=e.useRealtimeAdapter;exports.useReloadPage=e.useReloadPage;exports.useUpdateActivePageMetadata=e.useUpdateActivePageMetadata;exports.useUserPermissions=e.useUserRoleAndPermissions;exports.useWebsitePages=e.useWebsitePages;exports.useWebsiteSetting=e.useWebsiteSetting;
package/dist/pages.d.ts CHANGED
@@ -196,6 +196,7 @@ declare interface ChaiBuilderEditorProps {
196
196
  validateStructure?: boolean;
197
197
  designTokens?: boolean;
198
198
  ai?: boolean;
199
+ fontsInTheme?: boolean;
199
200
  };
200
201
  structureRules?: StructureRule[];
201
202
  designTokens?: ChaiDesignTokens;
package/dist/pages.js CHANGED
@@ -1,4 +1,4 @@
1
- import { aE as s, aT as t, aP as u, aN as i, aO as r, ax as g, b0 as l, b1 as P, aU as h, ar as c, v as d, aK as n, a_ as o, aw as p, ap as m, aV as A, k as C, as as b, aW as U, l as k, m as R, aZ as S, aX as W, aY as v, a$ as B, g as F, j as I } from "./index-BvluH-oT.js";
1
+ import { aE as s, aT as t, aP as u, aN as i, aO as r, ax as g, b0 as l, b1 as P, aU as h, ar as c, v as d, aK as n, a_ as o, aw as p, ap as m, aV as A, k as C, as as b, aW as U, l as k, m as R, aZ as S, aX as W, aY as v, a$ as B, g as F, j as I } from "./index-GfOB5KV1.js";
2
2
  export {
3
3
  s as ChaiJsonInput,
4
4
  t as ChaiWebsiteBuilder,
@@ -1,17 +1,17 @@
1
- "use strict";const a=require("lodash-es"),h=require("./fonts-B-Xt29pe.cjs"),b=require("./_commonjsHelpers-DwGv2jUC.cjs"),B={fontFamily:{"font-heading":"Inter","font-body":"Inter"},borderRadius:"10px",colors:[{group:"Body",items:{background:["#FFFFFF","#121212"],foreground:["#121212","#FFFFFF"]}},{group:"Primary",items:{primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"]}},{group:"Secondary",items:{secondary:["#F3F4F6","#374151"],"secondary-foreground":["#1F2937","#F9FAFB"]}},{group:"Border, Input & Ring",items:{border:["#E5E7EB","#374151"],input:["#E5E7EB","#374151"],ring:["#2563EB","#3B82F6"]}},{group:"Card",items:{card:["#FFFFFF","#1F2937"],"card-foreground":["#121212","#FFFFFF"]}},{group:"Popover",items:{popover:["#FFFFFF","#1F2937"],"popover-foreground":["#121212","#FFFFFF"]}},{group:"Muted",items:{muted:["#F3F4F6","#374151"],"muted-foreground":["#6B7280","#9CA3AF"]}},{group:"Accent",items:{accent:["#F3F4F6","#374151"],"accent-foreground":["#1F2937","#FFFFFF"]}},{group:"Destructive",items:{destructive:["#DC2626","#EF4444"],"destructive-foreground":["#FFFFFF","#FFFFFF"]}}]},v={fontFamily:{heading:"Inter",body:"Inter"},borderRadius:"6px",colors:{background:["#FFFFFF","#09090B"],foreground:["#09090B","#FFFFFF"],primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"],secondary:["#F4F4F5","#27272A"],"secondary-foreground":["#09090B","#FFFFFF"],muted:["#F4F4F5","#27272A"],"muted-foreground":["#71717A","#A1A1AA"],accent:["#F4F4F5","#27272A"],"accent-foreground":["#09090B","#FFFFFF"],destructive:["#EF4444","#7F1D1D"],"destructive-foreground":["#FFFFFF","#FFFFFF"],border:["#E4E4E7","#27272A"],input:["#E4E4E7","#27272A"],ring:["#2563EB","#3B82F6"],card:["#FFFFFF","#09090B"],"card-foreground":["#09090B","#FFFFFF"],popover:["#FFFFFF","#09090B"],"popover-foreground":["#09090B","#FFFFFF"]}},_=e=>({fontFamily:e.fontFamily?a.keys(e.fontFamily).reduce((r,n)=>({...r,[n.replace("font-","")]:`var(--${n})`}),{}):{},borderRadius:e.borderRadius?{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"}:{},colors:e.colors?a.flatten(e.colors.map(r=>Object.entries(r.items))).reduce((r,[n])=>({...r,[n]:`hsl(var(--${n}))`}),{}):{}});function m(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let r=parseInt(t[1],16),n=parseInt(t[2],16),F=parseInt(t[3],16);r/=255,n/=255,F/=255;const o=Math.max(r,n,F),u=Math.min(r,n,F);let i=0,l=0;const g=(o+u)/2;if(o==u)i=l=0;else{const s=o-u;switch(l=g>.5?s/(2-o-u):s/(o+u),o){case r:i=(n-F)/s+(n<F?6:0);break;case n:i=(F-r)/s+2;break;case F:i=(r-n)/s+4;break}i/=6}return`${Math.round(i*360)} ${Math.round(l*100)}% ${Math.round(g*100)}%`}const E=e=>{const r=h.getAllRegisteredFonts().find(n=>n.family===e);return`"${e}", ${a.get(r,"fallback","")}`},C=e=>`:root {
2
- ${e.fontFamily&&Object.entries(e.fontFamily).map(([t,r])=>`--font-${t}: ${E(r)};`).join(`
1
+ "use strict";const a=require("lodash-es"),$=require("./fonts-B-Xt29pe.cjs"),b=require("./_commonjsHelpers-DwGv2jUC.cjs"),B={fontFamily:{"font-heading":"Inter","font-body":"Inter"},borderRadius:"10px",colors:[{group:"Body",items:{background:["#FFFFFF","#121212"],foreground:["#121212","#FFFFFF"]}},{group:"Primary",items:{primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"]}},{group:"Secondary",items:{secondary:["#F3F4F6","#374151"],"secondary-foreground":["#1F2937","#F9FAFB"]}},{group:"Border, Input & Ring",items:{border:["#E5E7EB","#374151"],input:["#E5E7EB","#374151"],ring:["#2563EB","#3B82F6"]}},{group:"Card",items:{card:["#FFFFFF","#1F2937"],"card-foreground":["#121212","#FFFFFF"]}},{group:"Popover",items:{popover:["#FFFFFF","#1F2937"],"popover-foreground":["#121212","#FFFFFF"]}},{group:"Muted",items:{muted:["#F3F4F6","#374151"],"muted-foreground":["#6B7280","#9CA3AF"]}},{group:"Accent",items:{accent:["#F3F4F6","#374151"],"accent-foreground":["#1F2937","#FFFFFF"]}},{group:"Destructive",items:{destructive:["#DC2626","#EF4444"],"destructive-foreground":["#FFFFFF","#FFFFFF"]}}]},v={fontFamily:{heading:"Inter",body:"Inter"},borderRadius:"6px",colors:{background:["#FFFFFF","#09090B"],foreground:["#09090B","#FFFFFF"],primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"],secondary:["#F4F4F5","#27272A"],"secondary-foreground":["#09090B","#FFFFFF"],muted:["#F4F4F5","#27272A"],"muted-foreground":["#71717A","#A1A1AA"],accent:["#F4F4F5","#27272A"],"accent-foreground":["#09090B","#FFFFFF"],destructive:["#EF4444","#7F1D1D"],"destructive-foreground":["#FFFFFF","#FFFFFF"],border:["#E4E4E7","#27272A"],input:["#E4E4E7","#27272A"],ring:["#2563EB","#3B82F6"],card:["#FFFFFF","#09090B"],"card-foreground":["#09090B","#FFFFFF"],popover:["#FFFFFF","#09090B"],"popover-foreground":["#09090B","#FFFFFF"]}},_=e=>({fontFamily:e.fontFamily?a.keys(e.fontFamily).reduce((r,t)=>({...r,[t.replace("font-","")]:`var(--${t})`}),{}):{},borderRadius:e.borderRadius?{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"}:{},colors:e.colors?a.flatten(e.colors.map(r=>Object.entries(r.items))).reduce((r,[t])=>({...r,[t]:`hsl(var(--${t}))`}),{}):{}});function m(e){const F=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let r=parseInt(F[1],16),t=parseInt(F[2],16),n=parseInt(F[3],16);r/=255,t/=255,n/=255;const o=Math.max(r,t,n),u=Math.min(r,t,n);let i=0,l=0;const g=(o+u)/2;if(o==u)i=l=0;else{const s=o-u;switch(l=g>.5?s/(2-o-u):s/(o+u),o){case r:i=(t-n)/s+(t<n?6:0);break;case t:i=(n-r)/s+2;break;case n:i=(r-t)/s+4;break}i/=6}return`${Math.round(i*360)} ${Math.round(l*100)}% ${Math.round(g*100)}%`}const E=e=>{const r=$.getAllRegisteredFonts().find(t=>t.family===e);return`"${e}", ${a.get(r,"fallback","")}`},C=({theme:e,fontVariables:F=!1})=>{const r=e;return`:root {
2
+ ${F&&e.fontFamily&&Object.entries(e.fontFamily).map(([t,n])=>`--font-${t}: ${E(n)};`).join(`
3
3
  `)}
4
- ${e.borderRadius&&`--radius: ${e.borderRadius};`}
5
- ${e.colors&&Object.entries(e.colors).map(([t,r])=>`--${t}: ${m(r[0])};`).join(`
4
+ ${r.borderRadius&&`--radius: ${r.borderRadius};`}
5
+ ${r.colors&&Object.entries(r.colors).map(([t,n])=>`--${t}: ${m(n[0])};`).join(`
6
6
  `)}
7
7
  }
8
8
  .dark {
9
- ${e.colors&&Object.entries(e.colors).map(([t,r])=>`--${t}: ${m(r[1])};`).join(`
9
+ ${r.colors&&Object.entries(r.colors).map(([t,n])=>`--${t}: ${m(n[1])};`).join(`
10
10
  `)}
11
- }`,P=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(t=>`<link rel="stylesheet" href="${t.url}" />`).join(`
12
- `),A=e=>!e||e.length===0?[]:a.uniqBy(e,"family").map(t=>t.url),j=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(t=>`@import url("${t.url}");`).join(`
13
- `),q=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(t=>t.src.map(r=>`@font-face {
14
- font-family: "${t.family}";
11
+ }`},P=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(F=>`<link rel="stylesheet" href="${F.url}" />`).join(`
12
+ `),A=e=>!e||e.length===0?[]:a.uniqBy(e,"family").map(F=>F.url),j=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(F=>`@import url("${F.url}");`).join(`
13
+ `),q=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(F=>F.src.map(r=>`@font-face {
14
+ font-family: "${F.family}";
15
15
  src: url("${r.url}") format("${r.format}");
16
16
  font-display: swap;
17
17
  ${r.fontWeight?`font-weight: ${r.fontWeight};`:""}
@@ -19,4 +19,4 @@
19
19
  ${r.fontStretch?`font-stretch: ${r.fontStretch};`:""}
20
20
  }`).join(`
21
21
  `)).join(`
22
- `);var d={},c={},p;function M(){return p||(p=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});function t(n,F){return{handler:n,config:F}}t.withOptions=function(n,F=()=>({})){const o=function(u){return{__options:u,handler:n(u),config:F(u)}};return o.__isOptionsFunction=!0,o.__pluginFunction=n,o.__configFunction=F,o};const r=t})(c)),c}var y;function k(){return y||(y=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const t=r(M());function r(F){return F&&F.__esModule?F:{default:F}}const n=t.default})(d)),d}var f,$;function R(){if($)return f;$=1;let e=k();return f=(e.__esModule?e:{default:e}).default,f}var I=R();const O=b.getDefaultExportFromCjs(I);exports.defaultThemeOptions=B;exports.defaultThemeValues=v;exports.getChaiThemeCssVariables=C;exports.getChaiThemeOptions=_;exports.getThemeCustomFontFace=q;exports.getThemeFontsCSSImport=j;exports.getThemeFontsLinkMarkup=P;exports.getThemeFontsUrls=A;exports.plugin=O;
22
+ `);var d={},c={},p;function T(){return p||(p=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});function F(t,n){return{handler:t,config:n}}F.withOptions=function(t,n=()=>({})){const o=function(u){return{__options:u,handler:t(u),config:n(u)}};return o.__isOptionsFunction=!0,o.__pluginFunction=t,o.__configFunction=n,o};const r=F})(c)),c}var h;function M(){return h||(h=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const F=r(T());function r(n){return n&&n.__esModule?n:{default:n}}const t=F.default})(d)),d}var f,y;function k(){if(y)return f;y=1;let e=M();return f=(e.__esModule?e:{default:e}).default,f}var R=k();const I=b.getDefaultExportFromCjs(R);exports.defaultThemeOptions=B;exports.defaultThemeValues=v;exports.getChaiThemeCssVariables=C;exports.getChaiThemeOptions=_;exports.getThemeCustomFontFace=q;exports.getThemeFontsCSSImport=j;exports.getThemeFontsLinkMarkup=P;exports.getThemeFontsUrls=A;exports.plugin=I;
@@ -1,6 +1,6 @@
1
- import { uniqBy as s, get as b, flatten as v, keys as B } from "lodash-es";
2
- import { a as _ } from "./fonts-DRly3Wzd.js";
3
- import { g as h } from "./_commonjsHelpers-C6fGbg64.js";
1
+ import { uniqBy as s, get as $, flatten as b, keys as v } from "lodash-es";
2
+ import { a as B } from "./fonts-DRly3Wzd.js";
3
+ import { g as _ } from "./_commonjsHelpers-C6fGbg64.js";
4
4
  const x = {
5
5
  fontFamily: {
6
6
  "font-heading": "Inter",
@@ -100,74 +100,80 @@ const x = {
100
100
  popover: ["#FFFFFF", "#09090B"],
101
101
  "popover-foreground": ["#09090B", "#FFFFFF"]
102
102
  }
103
- }, q = (r) => ({
104
- fontFamily: r.fontFamily ? B(r.fontFamily).reduce(
105
- (e, n) => ({
106
- ...e,
107
- [n.replace("font-", "")]: `var(--${n})`
103
+ }, q = (e) => ({
104
+ fontFamily: e.fontFamily ? v(e.fontFamily).reduce(
105
+ (r, t) => ({
106
+ ...r,
107
+ [t.replace("font-", "")]: `var(--${t})`
108
108
  }),
109
109
  {}
110
110
  ) : {},
111
- borderRadius: r.borderRadius ? {
111
+ borderRadius: e.borderRadius ? {
112
112
  lg: "var(--radius)",
113
113
  md: "calc(var(--radius) - 2px)",
114
114
  sm: "calc(var(--radius) - 4px)"
115
115
  } : {},
116
- colors: r.colors ? v(r.colors.map((e) => Object.entries(e.items))).reduce(
117
- (e, [n]) => ({ ...e, [n]: `hsl(var(--${n}))` }),
116
+ colors: e.colors ? b(e.colors.map((r) => Object.entries(r.items))).reduce(
117
+ (r, [t]) => ({ ...r, [t]: `hsl(var(--${t}))` }),
118
118
  {}
119
119
  ) : {}
120
120
  });
121
- function m(r) {
122
- const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r);
123
- let e = parseInt(t[1], 16), n = parseInt(t[2], 16), F = parseInt(t[3], 16);
124
- e /= 255, n /= 255, F /= 255;
125
- const o = Math.max(e, n, F), u = Math.min(e, n, F);
126
- let a = 0, d = 0;
127
- const g = (o + u) / 2;
128
- if (o == u)
129
- a = d = 0;
121
+ function m(e) {
122
+ const F = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
123
+ let r = parseInt(F[1], 16), t = parseInt(F[2], 16), n = parseInt(F[3], 16);
124
+ r /= 255, t /= 255, n /= 255;
125
+ const o = Math.max(r, t, n), a = Math.min(r, t, n);
126
+ let u = 0, d = 0;
127
+ const g = (o + a) / 2;
128
+ if (o == a)
129
+ u = d = 0;
130
130
  else {
131
- const i = o - u;
132
- switch (d = g > 0.5 ? i / (2 - o - u) : i / (o + u), o) {
133
- case e:
134
- a = (n - F) / i + (n < F ? 6 : 0);
131
+ const i = o - a;
132
+ switch (d = g > 0.5 ? i / (2 - o - a) : i / (o + a), o) {
133
+ case r:
134
+ u = (t - n) / i + (t < n ? 6 : 0);
135
135
  break;
136
- case n:
137
- a = (F - e) / i + 2;
136
+ case t:
137
+ u = (n - r) / i + 2;
138
138
  break;
139
- case F:
140
- a = (e - n) / i + 4;
139
+ case n:
140
+ u = (r - t) / i + 4;
141
141
  break;
142
142
  }
143
- a /= 6;
143
+ u /= 6;
144
144
  }
145
- return `${Math.round(a * 360)} ${Math.round(d * 100)}% ${Math.round(g * 100)}%`;
145
+ return `${Math.round(u * 360)} ${Math.round(d * 100)}% ${Math.round(g * 100)}%`;
146
146
  }
147
- const E = (r) => {
148
- const e = _().find((n) => n.family === r);
149
- return `"${r}", ${b(e, "fallback", "")}`;
150
- }, O = (r) => `:root {
151
- ${r.fontFamily && Object.entries(r.fontFamily).map(([t, e]) => `--font-${t}: ${E(e)};`).join(`
147
+ const E = (e) => {
148
+ const r = B().find((t) => t.family === e);
149
+ return `"${e}", ${$(r, "fallback", "")}`;
150
+ }, O = ({
151
+ theme: e,
152
+ fontVariables: F = !1
153
+ }) => {
154
+ const r = e;
155
+ return `:root {
156
+ ${F && e.fontFamily && Object.entries(e.fontFamily).map(([t, n]) => `--font-${t}: ${E(n)};`).join(`
152
157
  `)}
153
158
  ${r.borderRadius && `--radius: ${r.borderRadius};`}
154
- ${r.colors && Object.entries(r.colors).map(([t, e]) => `--${t}: ${m(e[0])};`).join(`
159
+ ${r.colors && Object.entries(r.colors).map(([t, n]) => `--${t}: ${m(n[0])};`).join(`
155
160
  `)}
156
161
  }
157
162
  .dark {
158
- ${r.colors && Object.entries(r.colors).map(([t, e]) => `--${t}: ${m(e[1])};`).join(`
163
+ ${r.colors && Object.entries(r.colors).map(([t, n]) => `--${t}: ${m(n[1])};`).join(`
159
164
  `)}
160
- }`, S = (r) => !r || r.length === 0 ? "" : s(r, "family").map((t) => `<link rel="stylesheet" href="${t.url}" />`).join(`
161
- `), D = (r) => !r || r.length === 0 ? [] : s(r, "family").map((t) => t.url), w = (r) => !r || r.length === 0 ? "" : s(r, "family").map((t) => `@import url("${t.url}");`).join(`
162
- `), L = (r) => !r || r.length === 0 ? "" : s(r, "family").map(
163
- (t) => t.src.map(
164
- (e) => `@font-face {
165
- font-family: "${t.family}";
166
- src: url("${e.url}") format("${e.format}");
165
+ }`;
166
+ }, S = (e) => !e || e.length === 0 ? "" : s(e, "family").map((F) => `<link rel="stylesheet" href="${F.url}" />`).join(`
167
+ `), T = (e) => !e || e.length === 0 ? [] : s(e, "family").map((F) => F.url), D = (e) => !e || e.length === 0 ? "" : s(e, "family").map((F) => `@import url("${F.url}");`).join(`
168
+ `), w = (e) => !e || e.length === 0 ? "" : s(e, "family").map(
169
+ (F) => F.src.map(
170
+ (r) => `@font-face {
171
+ font-family: "${F.family}";
172
+ src: url("${r.url}") format("${r.format}");
167
173
  font-display: swap;
168
- ${e.fontWeight ? `font-weight: ${e.fontWeight};` : ""}
169
- ${e.fontStyle ? `font-style: ${e.fontStyle};` : ""}
170
- ${e.fontStretch ? `font-stretch: ${e.fontStretch};` : ""}
174
+ ${r.fontWeight ? `font-weight: ${r.fontWeight};` : ""}
175
+ ${r.fontStyle ? `font-style: ${r.fontStyle};` : ""}
176
+ ${r.fontStretch ? `font-stretch: ${r.fontStretch};` : ""}
171
177
  }`
172
178
  ).join(`
173
179
  `)
@@ -175,71 +181,71 @@ const E = (r) => {
175
181
  `);
176
182
  var l = {}, c = {}, p;
177
183
  function P() {
178
- return p || (p = 1, (function(r) {
179
- Object.defineProperty(r, "__esModule", {
184
+ return p || (p = 1, (function(e) {
185
+ Object.defineProperty(e, "__esModule", {
180
186
  value: !0
181
- }), Object.defineProperty(r, "default", {
187
+ }), Object.defineProperty(e, "default", {
182
188
  enumerable: !0,
183
189
  get: function() {
184
- return e;
190
+ return r;
185
191
  }
186
192
  });
187
- function t(n, F) {
193
+ function F(t, n) {
188
194
  return {
189
- handler: n,
190
- config: F
195
+ handler: t,
196
+ config: n
191
197
  };
192
198
  }
193
- t.withOptions = function(n, F = () => ({})) {
194
- const o = function(u) {
199
+ F.withOptions = function(t, n = () => ({})) {
200
+ const o = function(a) {
195
201
  return {
196
- __options: u,
197
- handler: n(u),
198
- config: F(u)
202
+ __options: a,
203
+ handler: t(a),
204
+ config: n(a)
199
205
  };
200
206
  };
201
- return o.__isOptionsFunction = !0, o.__pluginFunction = n, o.__configFunction = F, o;
207
+ return o.__isOptionsFunction = !0, o.__pluginFunction = t, o.__configFunction = n, o;
202
208
  };
203
- const e = t;
209
+ const r = F;
204
210
  })(c)), c;
205
211
  }
206
212
  var y;
207
213
  function A() {
208
- return y || (y = 1, (function(r) {
209
- Object.defineProperty(r, "__esModule", {
214
+ return y || (y = 1, (function(e) {
215
+ Object.defineProperty(e, "__esModule", {
210
216
  value: !0
211
- }), Object.defineProperty(r, "default", {
217
+ }), Object.defineProperty(e, "default", {
212
218
  enumerable: !0,
213
219
  get: function() {
214
- return n;
220
+ return t;
215
221
  }
216
222
  });
217
- const t = /* @__PURE__ */ e(P());
218
- function e(F) {
219
- return F && F.__esModule ? F : {
220
- default: F
223
+ const F = /* @__PURE__ */ r(P());
224
+ function r(n) {
225
+ return n && n.__esModule ? n : {
226
+ default: n
221
227
  };
222
228
  }
223
- const n = t.default;
229
+ const t = F.default;
224
230
  })(l)), l;
225
231
  }
226
- var f, $;
232
+ var f, h;
227
233
  function j() {
228
- if ($) return f;
229
- $ = 1;
230
- let r = A();
231
- return f = (r.__esModule ? r : { default: r }).default, f;
234
+ if (h) return f;
235
+ h = 1;
236
+ let e = A();
237
+ return f = (e.__esModule ? e : { default: e }).default, f;
232
238
  }
233
239
  var C = j();
234
- const V = /* @__PURE__ */ h(C);
240
+ const L = /* @__PURE__ */ _(C);
235
241
  export {
236
242
  O as a,
237
- w as b,
243
+ D as b,
238
244
  S as c,
239
245
  x as d,
240
246
  I as e,
241
- D as f,
247
+ T as f,
242
248
  q as g,
243
- L as h,
244
- V as p
249
+ w as h,
250
+ L as p
245
251
  };
@@ -1,8 +1,8 @@
1
1
  import { jsxs as n, jsx as t, Fragment as $ } from "react/jsx-runtime";
2
2
  import { B as L } from "./register-chai-top-bar-CX_JkRJn.js";
3
- import { e as K, f as Q, g as J, p as V, r as W } from "./index-BN6yEl-H.js";
4
- import { ar as X, as as Y, A as I, aA as q, aB as Z, k as ee, m as te, ap as se, T as U, t as le } from "./index-BvluH-oT.js";
5
- import { LanguageSelector as ae } from "./page-manager-search-and-filter-DY_NsetM.js";
3
+ import { e as K, f as Q, g as J, p as V, r as W } from "./index-lm46VtIP.js";
4
+ import { ar as X, as as Y, A as I, aA as q, aB as Z, k as ee, m as te, ap as se, T as U, t as le } from "./index-GfOB5KV1.js";
5
+ import { LanguageSelector as ae } from "./page-manager-search-and-filter-DVAGxnlw.js";
6
6
  import { useQuery as ne } from "@tanstack/react-query";
7
7
  import { find as B, filter as a, map as b, keys as re, get as F, includes as C, orderBy as N, isEmpty as oe, uniq as G, first as ce, concat as ie } from "lodash-es";
8
8
  import { Lock as de, GlobeIcon as ue, File as me, Edit as he } from "lucide-react";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),q=require("./register-chai-top-bar-DWTuRU53.cjs"),f=require("./index-DWGTiEak.cjs"),r=require("./index-BJVYKKJq.cjs"),U=require("./page-manager-search-and-filter-Bb_Zfpsj.cjs"),F=require("@tanstack/react-query"),t=require("lodash-es"),b=require("lucide-react"),a=require("react"),M=()=>{const l=r.useApiUrl(),d=r.useFetch();return F.useQuery({queryKey:[r.ACTIONS.GET_CHANGES],queryFn:async()=>d(l,{action:r.ACTIONS.GET_CHANGES})})},G=({page:l,selectedPages:d,handleCheckboxChange:N,getPageType:y,hasSlug:h,currentOwnerId:c})=>{const x=r.useUserId(),{data:u}=r.useChaiUserInfo(c),o=c===x?null:u==null?void 0:u.name;return e.jsxs("tr",{className:"group relative border-b last:border-b-0 hover:bg-gray-50",children:[e.jsxs("td",{scope:"row",className:`flex items-center gap-x-1 whitespace-nowrap px-6 py-2 text-gray-900 dark:text-white ${o?"opacity-50":""}`,children:[o?e.jsx(b.Lock,{className:"h-4 w-4 fill-red-200 text-red-500"}):e.jsx("input",{checked:t.includes(d,l==null?void 0:l.id),onClick:p=>{p.stopPropagation(),N(l==null?void 0:l.id)},type:"checkbox",className:"cursor-pointer rounded focus:outline-none focus:ring-0"})," ",h(l.pageType)?e.jsx(b.File,{className:"h-4 w-4"}):e.jsx(b.GlobeIcon,{className:"h-4 w-4"}),e.jsx(r.Tooltip,{content:l.name,side:"top",showTooltip:l.name.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-medium text-black",children:l.name})}),l.slug&&e.jsx(r.Tooltip,{content:l.slug,side:"top",showTooltip:l.slug.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-mono text-xs text-muted-foreground",children:l.slug})})]}),e.jsx("td",{className:"px-2",children:y(l==null?void 0:l.pageType)}),e.jsx("td",{className:"px-4 text-right",children:t.first(l.changes)||""}),e.jsx(e.Fragment,{children:o&&e.jsxs("button",{className:"absolute right-0 top-0 flex h-full 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:[e.jsx(b.Edit,{size:12,className:"stroke-[3]"})," ",e.jsx("span",{className:"font-medium",children:o})," is editing this page"]})})]},l==null?void 0:l.id)},O=({onClose:l=()=>{},isPending:d,publishPage:N})=>{const y=r.useUserId(),{pageToUser:h}=r.usePageToUser(),[c,x]=a.useState([]),u=r.useFallbackLang(),[o,p]=a.useState(u),{data:T,isFetching:C}=M(),{data:m}=r.usePageTypes(),k=a.useCallback(s=>{var n;return(n=t.find(m,{key:s}))==null?void 0:n.hasSlug},[m]),j=a.useMemo(()=>t.filter(m,s=>!k(s.key)).map(s=>s.key),[k,m]),P=t.uniq(t.map(T,"lang")).filter(Boolean),i=a.useMemo(()=>t.filter(T,s=>s.pageType==="theme"?!1:o===u?s.lang===o||s.lang==="":s.lang===o),[T,o,u]),w=a.useMemo(()=>t.filter(i,s=>!j.includes(s.pageType)),[i,j]),S=a.useMemo(()=>t.filter(i,s=>j.includes(s.pageType)),[i,j]);a.useEffect(()=>{const s=t.map(t.filter(i,{online:!0}),"id");a.startTransition(()=>x(s))},[i]),a.useEffect(()=>{const s=t.filter(t.keys(h),n=>t.get(h,[n,"userId"])!==y);a.startTransition(()=>x(n=>t.filter(n,g=>!t.includes(s,g))))},[h,y]);const v=c.length===(i==null?void 0:i.length),E=s=>{x(n=>t.includes(n,s)?t.filter(n,g=>g!==s):t.concat(n,s))},B=()=>{x(v?[]:t.map(i,"id"))},I=()=>{N({ids:t.uniq(c)},{onSuccess:()=>{l(),r.throwConfetti("CENTER_CENTER"),p(u)}})},A=s=>{if(s==="theme")return"Theme";const n=t.find(m,{key:s});return n?n==null?void 0:n.name:s},L=a.useMemo(()=>{const s=[{label:"Updated",top:"pt-2"},...t.orderBy(t.filter(w,{online:!0}),"pageType"),...t.orderBy(t.filter(S,{online:!0}),"pageType")].filter(g=>g.pageType!=="theme"),n=[{label:"Offline",top:"pt-6"},...t.orderBy(t.filter(w,{online:!1}),"pageType"),...t.orderBy(t.filter(S,{online:!1}),"pageType")];return[...s,...n]},[w,S]);return e.jsxs(f.DialogContent,{className:"flex max-h-[80%] max-w-4xl flex-col",children:[e.jsxs(f.DialogHeader,{children:[e.jsx(f.DialogTitle,{children:"Publish changes"}),e.jsx(f.DialogDescription,{className:"text-xs",children:"Select the pages you want to publish. Click publish when you're done."})]}),P.length>0&&e.jsx("div",{className:"my-[2px] mt-0",children:e.jsx(U.LanguageSelector,{languages:[u,...P],selectedLanguage:o,setSelectedLanguage:p})}),e.jsx("div",{className:"no-scrollbar relative -mx-4 -mt-4 h-full max-h-full overflow-y-auto",children:C?e.jsxs("div",{className:"space-y-2 px-1",children:[e.jsx("div",{className:"mt-2 h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):e.jsxs("table",{className:"w-full text-left text-xs text-gray-500 dark:text-gray-400 rtl:text-right",children:[e.jsx("thead",{className:"sticky top-0 z-10 border-b bg-gray-50 text-gray-700 dark:bg-gray-700 dark:text-gray-400",children:e.jsxs("tr",{children:[e.jsxs("th",{scope:"col",className:"w-[1 50px] flex items-center gap-x-2 px-6 py-3",children:[e.jsx("input",{checked:v,onClick:s=>{s.stopPropagation(),B()},type:"checkbox",className:"mt-1 cursor-pointer rounded focus:outline-none focus:ring-0"}),"Name"]}),e.jsx("th",{scope:"col",className:"w-[150px] px-2 py-3",children:"Type"}),e.jsx("th",{scope:"col",className:"w-[150px] px-4 py-3 text-right",children:"Status"})]})}),e.jsx("tbody",{children:t.map(L,s=>s.label?e.jsx("tr",{children:e.jsxs("td",{colSpan:3,className:`relative px-6 py-2 text-xs font-medium text-gray-800 ${s.top}`,children:[e.jsx("div",{className:"absolute inset-0 left-6 flex items-center",children:e.jsx("div",{className:"order-gray-300 w-full"})}),e.jsx("div",{className:"relative flex justify-start",children:e.jsx("span",{className:"bg-gray-50 pr-2",children:s.label})})]})},"separator"):e.jsx(G,{page:s,selectedPages:c,handleCheckboxChange:E,getPageType:A,hasSlug:k,currentOwnerId:t.get(h,[(s==null?void 0:s.primaryPage)||(s==null?void 0:s.id),"userId"])}))})]})}),e.jsxs(f.DialogFooter,{className:"mt-10 flex items-center justify-center",children:[c.length>0&&e.jsxs("span",{className:"text-center text-sm text-muted-foreground",children:[c.length," Page",c.length!==1?"s":""," Selected"]}),e.jsx(q.Button,{disabled:d,variant:"outline",onClick:l,children:"Cancel"}),e.jsx(q.Button,{disabled:d||C||t.isEmpty(c),onClick:I,children:d?"Publishing...":"Publish Selected"})]})]})};exports.default=O;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),q=require("./register-chai-top-bar-DWTuRU53.cjs"),f=require("./index-EFWvSWoi.cjs"),r=require("./index-B5qvHqN5.cjs"),U=require("./page-manager-search-and-filter-CIspvIW2.cjs"),F=require("@tanstack/react-query"),t=require("lodash-es"),b=require("lucide-react"),a=require("react"),M=()=>{const l=r.useApiUrl(),d=r.useFetch();return F.useQuery({queryKey:[r.ACTIONS.GET_CHANGES],queryFn:async()=>d(l,{action:r.ACTIONS.GET_CHANGES})})},G=({page:l,selectedPages:d,handleCheckboxChange:N,getPageType:y,hasSlug:h,currentOwnerId:c})=>{const x=r.useUserId(),{data:u}=r.useChaiUserInfo(c),o=c===x?null:u==null?void 0:u.name;return e.jsxs("tr",{className:"group relative border-b last:border-b-0 hover:bg-gray-50",children:[e.jsxs("td",{scope:"row",className:`flex items-center gap-x-1 whitespace-nowrap px-6 py-2 text-gray-900 dark:text-white ${o?"opacity-50":""}`,children:[o?e.jsx(b.Lock,{className:"h-4 w-4 fill-red-200 text-red-500"}):e.jsx("input",{checked:t.includes(d,l==null?void 0:l.id),onClick:p=>{p.stopPropagation(),N(l==null?void 0:l.id)},type:"checkbox",className:"cursor-pointer rounded focus:outline-none focus:ring-0"})," ",h(l.pageType)?e.jsx(b.File,{className:"h-4 w-4"}):e.jsx(b.GlobeIcon,{className:"h-4 w-4"}),e.jsx(r.Tooltip,{content:l.name,side:"top",showTooltip:l.name.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-medium text-black",children:l.name})}),l.slug&&e.jsx(r.Tooltip,{content:l.slug,side:"top",showTooltip:l.slug.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-mono text-xs text-muted-foreground",children:l.slug})})]}),e.jsx("td",{className:"px-2",children:y(l==null?void 0:l.pageType)}),e.jsx("td",{className:"px-4 text-right",children:t.first(l.changes)||""}),e.jsx(e.Fragment,{children:o&&e.jsxs("button",{className:"absolute right-0 top-0 flex h-full 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:[e.jsx(b.Edit,{size:12,className:"stroke-[3]"})," ",e.jsx("span",{className:"font-medium",children:o})," is editing this page"]})})]},l==null?void 0:l.id)},O=({onClose:l=()=>{},isPending:d,publishPage:N})=>{const y=r.useUserId(),{pageToUser:h}=r.usePageToUser(),[c,x]=a.useState([]),u=r.useFallbackLang(),[o,p]=a.useState(u),{data:T,isFetching:C}=M(),{data:m}=r.usePageTypes(),k=a.useCallback(s=>{var n;return(n=t.find(m,{key:s}))==null?void 0:n.hasSlug},[m]),j=a.useMemo(()=>t.filter(m,s=>!k(s.key)).map(s=>s.key),[k,m]),P=t.uniq(t.map(T,"lang")).filter(Boolean),i=a.useMemo(()=>t.filter(T,s=>s.pageType==="theme"?!1:o===u?s.lang===o||s.lang==="":s.lang===o),[T,o,u]),w=a.useMemo(()=>t.filter(i,s=>!j.includes(s.pageType)),[i,j]),S=a.useMemo(()=>t.filter(i,s=>j.includes(s.pageType)),[i,j]);a.useEffect(()=>{const s=t.map(t.filter(i,{online:!0}),"id");a.startTransition(()=>x(s))},[i]),a.useEffect(()=>{const s=t.filter(t.keys(h),n=>t.get(h,[n,"userId"])!==y);a.startTransition(()=>x(n=>t.filter(n,g=>!t.includes(s,g))))},[h,y]);const v=c.length===(i==null?void 0:i.length),E=s=>{x(n=>t.includes(n,s)?t.filter(n,g=>g!==s):t.concat(n,s))},B=()=>{x(v?[]:t.map(i,"id"))},I=()=>{N({ids:t.uniq(c)},{onSuccess:()=>{l(),r.throwConfetti("CENTER_CENTER"),p(u)}})},A=s=>{if(s==="theme")return"Theme";const n=t.find(m,{key:s});return n?n==null?void 0:n.name:s},L=a.useMemo(()=>{const s=[{label:"Updated",top:"pt-2"},...t.orderBy(t.filter(w,{online:!0}),"pageType"),...t.orderBy(t.filter(S,{online:!0}),"pageType")].filter(g=>g.pageType!=="theme"),n=[{label:"Offline",top:"pt-6"},...t.orderBy(t.filter(w,{online:!1}),"pageType"),...t.orderBy(t.filter(S,{online:!1}),"pageType")];return[...s,...n]},[w,S]);return e.jsxs(f.DialogContent,{className:"flex max-h-[80%] max-w-4xl flex-col",children:[e.jsxs(f.DialogHeader,{children:[e.jsx(f.DialogTitle,{children:"Publish changes"}),e.jsx(f.DialogDescription,{className:"text-xs",children:"Select the pages you want to publish. Click publish when you're done."})]}),P.length>0&&e.jsx("div",{className:"my-[2px] mt-0",children:e.jsx(U.LanguageSelector,{languages:[u,...P],selectedLanguage:o,setSelectedLanguage:p})}),e.jsx("div",{className:"no-scrollbar relative -mx-4 -mt-4 h-full max-h-full overflow-y-auto",children:C?e.jsxs("div",{className:"space-y-2 px-1",children:[e.jsx("div",{className:"mt-2 h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):e.jsxs("table",{className:"w-full text-left text-xs text-gray-500 dark:text-gray-400 rtl:text-right",children:[e.jsx("thead",{className:"sticky top-0 z-10 border-b bg-gray-50 text-gray-700 dark:bg-gray-700 dark:text-gray-400",children:e.jsxs("tr",{children:[e.jsxs("th",{scope:"col",className:"w-[1 50px] flex items-center gap-x-2 px-6 py-3",children:[e.jsx("input",{checked:v,onClick:s=>{s.stopPropagation(),B()},type:"checkbox",className:"mt-1 cursor-pointer rounded focus:outline-none focus:ring-0"}),"Name"]}),e.jsx("th",{scope:"col",className:"w-[150px] px-2 py-3",children:"Type"}),e.jsx("th",{scope:"col",className:"w-[150px] px-4 py-3 text-right",children:"Status"})]})}),e.jsx("tbody",{children:t.map(L,s=>s.label?e.jsx("tr",{children:e.jsxs("td",{colSpan:3,className:`relative px-6 py-2 text-xs font-medium text-gray-800 ${s.top}`,children:[e.jsx("div",{className:"absolute inset-0 left-6 flex items-center",children:e.jsx("div",{className:"order-gray-300 w-full"})}),e.jsx("div",{className:"relative flex justify-start",children:e.jsx("span",{className:"bg-gray-50 pr-2",children:s.label})})]})},"separator"):e.jsx(G,{page:s,selectedPages:c,handleCheckboxChange:E,getPageType:A,hasSlug:k,currentOwnerId:t.get(h,[(s==null?void 0:s.primaryPage)||(s==null?void 0:s.id),"userId"])}))})]})}),e.jsxs(f.DialogFooter,{className:"mt-10 flex items-center justify-center",children:[c.length>0&&e.jsxs("span",{className:"text-center text-sm text-muted-foreground",children:[c.length," Page",c.length!==1?"s":""," Selected"]}),e.jsx(q.Button,{disabled:d,variant:"outline",onClick:l,children:"Cancel"}),e.jsx(q.Button,{disabled:d||C||t.isEmpty(c),onClick:I,children:d?"Publishing...":"Publish Selected"})]})]})};exports.default=O;