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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/{2SSKDMRQ-CopJgtZb.cjs → 2SSKDMRQ-BIryEtW-.cjs} +1 -1
  2. package/dist/{2SSKDMRQ-Difo_1pg.js → 2SSKDMRQ-trME0kvt.js} +2 -2
  3. package/dist/{AP7HFJJL-DYxDgaOs.cjs → AP7HFJJL-5ZR38Hyh.cjs} +1 -1
  4. package/dist/{AP7HFJJL-BPuPBqj4.js → AP7HFJJL-CAGB9iMp.js} +1 -1
  5. package/dist/{IconPicker-C0oycHbs.cjs → IconPicker-CQ-BgNNU.cjs} +1 -1
  6. package/dist/{IconPicker-B2-oriq2.js → IconPicker-Mu75ni5T.js} +1 -1
  7. package/dist/{WDYDFRGG-KK8pkcW1.js → WDYDFRGG-Cd4hRWj-.js} +2 -2
  8. package/dist/{WDYDFRGG-DbejaRPK.cjs → WDYDFRGG-n8sBZVFG.cjs} +1 -1
  9. package/dist/{active-in-another-tab-Cu_ASKtx.cjs → active-in-another-tab-CZLV-uAW.cjs} +1 -1
  10. package/dist/{active-in-another-tab-DkR2HWI4.js → active-in-another-tab-Cb6tnX9u.js} +2 -2
  11. package/dist/{add-new-language-page-CBY0RR6q.js → add-new-language-page-BKcBaqZu.js} +3 -3
  12. package/dist/{add-new-language-page-BXuwluuU.cjs → add-new-language-page-C3UzNV7W.cjs} +1 -1
  13. package/dist/{add-new-page-C_PzKby8.cjs → add-new-page-mULv9r3z.cjs} +1 -1
  14. package/dist/{add-new-page-DJLJFLAd.js → add-new-page-pH3PwqJe.js} +2 -2
  15. package/dist/{ai-panel-content-rRmJdH7L.cjs → ai-panel-content-BPgRdgye.cjs} +1 -1
  16. package/dist/{ai-panel-content--YM01Aly.js → ai-panel-content-CNxN84pv.js} +3 -3
  17. package/dist/{ai-panel-default-lang-BZl0tPYo.js → ai-panel-default-lang-CYcHjk8U.js} +3 -3
  18. package/dist/{ai-panel-default-lang-D2zhXvKP.cjs → ai-panel-default-lang-DhTPtPgD.cjs} +2 -2
  19. package/dist/{ai-panel-other-lang-Y4bEKHoG.cjs → ai-panel-other-lang-CGNU3-FI.cjs} +1 -1
  20. package/dist/{ai-panel-other-lang-Bfjk2CYZ.js → ai-panel-other-lang-D8Ofvj8F.js} +3 -3
  21. package/dist/{ai-prompt-input-N9PcYCFa.cjs → ai-prompt-input-CUutJjlf.cjs} +1 -1
  22. package/dist/{ai-prompt-input-DueQYNf-.js → ai-prompt-input-Ceuy5bs3.js} +1 -1
  23. package/dist/{ai-translation-prompt-B36F3d7K.js → ai-translation-prompt-BiepZRcN.js} +1 -1
  24. package/dist/{ai-translation-prompt-IAdWMNZb.cjs → ai-translation-prompt-CoCPLEed.cjs} +1 -1
  25. package/dist/{code-editor-DQB8lAOk.cjs → code-editor-C1ewJzDJ.cjs} +1 -1
  26. package/dist/{code-editor-Bb7JumZy.js → code-editor-Z14ByBIv.js} +1 -1
  27. package/dist/{continue-editing-in-this-client-Dm9cCj7K.js → continue-editing-in-this-client-Byi6ER3L.js} +2 -2
  28. package/dist/{continue-editing-in-this-client-DmGFLHXw.cjs → continue-editing-in-this-client-k9Ab5E63.cjs} +1 -1
  29. package/dist/core.cjs +1 -1
  30. package/dist/core.js +41 -42
  31. package/dist/css-import-modal--bSJR-_y.cjs +13 -0
  32. package/dist/{css-import-modal-9P_0uNa4.js → css-import-modal-De7Kvg5C.js} +3 -4
  33. package/dist/{delete-design-token-COvR4G1S.js → delete-design-token-B97CnFDU.js} +1 -1
  34. package/dist/{delete-design-token-BG8yHcS5.cjs → delete-design-token-C6s-ESB_.cjs} +1 -1
  35. package/dist/{delete-page-DAvEjHwF.cjs → delete-page-Djn97HiP.cjs} +1 -1
  36. package/dist/{delete-page-CNucxe4P.js → delete-page-Dnf97ZHP.js} +2 -2
  37. package/dist/{design-token-usage-MNYsFlPG.js → design-token-usage-B-SykAjD.js} +1 -1
  38. package/dist/{design-token-usage-CXglXgcJ.cjs → design-token-usage-OTd93kS8.cjs} +1 -1
  39. package/dist/{digital-asset-manager-CB5MRBcW.cjs → digital-asset-manager-DHYRXaaq.cjs} +1 -1
  40. package/dist/{digital-asset-manager-CqCWBO0s.js → digital-asset-manager-b8gDuLnI.js} +3 -3
  41. package/dist/{duplicate-page-BknLfqr0.js → duplicate-page-Bdtpl7_R.js} +3 -3
  42. package/dist/{duplicate-page-DzZByALW.cjs → duplicate-page-C4Ovp8Ff.cjs} +1 -1
  43. package/dist/{dynamic-page-selector-WA007Sni.cjs → dynamic-page-selector-B8DdnfrF.cjs} +1 -1
  44. package/dist/{dynamic-page-selector-DoW7OyUB.js → dynamic-page-selector-BVnIM1Rq.js} +2 -2
  45. package/dist/{get-chai-builder-tailwind-config-BFePCEIS.cjs → get-chai-builder-tailwind-config-DNp8Vhme.cjs} +1 -1
  46. package/dist/{get-chai-builder-tailwind-config-BXf_xLHk.js → get-chai-builder-tailwind-config-k8l5sdcw.js} +2 -2
  47. package/dist/{image-editor-CqwaVxO2.cjs → image-editor-C2zOHeKv.cjs} +1 -1
  48. package/dist/{image-editor-CQnNtak2.js → image-editor-cckqPmk5.js} +1 -1
  49. package/dist/{index-C99FhuF1.cjs → index-B0e71wJ1.cjs} +2 -2
  50. package/dist/{index-Dno42B0a.js → index-Bn0fFN58.js} +51 -51
  51. package/dist/{index-rAcNbjk_.js → index-CAhEmHYP.js} +6 -6
  52. package/dist/{index-C0-pgg_p.cjs → index-DKuwxj1x.cjs} +2 -2
  53. package/dist/{json-diff-viewer-CLuUHiPU.cjs → json-diff-viewer-D9DVIBz4.cjs} +1 -1
  54. package/dist/{json-diff-viewer-CMvGUvJ2.js → json-diff-viewer-DNizzMnu.js} +2 -2
  55. package/dist/{lang-panel-fDCYm5Jm.cjs → lang-panel-C1dbn163.cjs} +1 -1
  56. package/dist/{lang-panel-CnwTb05j.js → lang-panel-DL_BtSRD.js} +3 -3
  57. package/dist/{manage-design-tokens-BvH5KTJX.cjs → manage-design-tokens-CXjYkarE.cjs} +1 -1
  58. package/dist/{manage-design-tokens-BsSZE9Vs.js → manage-design-tokens-xxMO_RYg.js} +2 -2
  59. package/dist/{mark-as-template-DBLshWb5.js → mark-as-template-Ba2bmVd9.js} +2 -2
  60. package/dist/{mark-as-template-CpWEBJGd.cjs → mark-as-template-DF1KIMr0.cjs} +1 -1
  61. package/dist/{nested-path-selector-content-6OBJ8LG8.js → nested-path-selector-content-Br1IWhK5.js} +1 -1
  62. package/dist/{nested-path-selector-content-C2sD9dkq.cjs → nested-path-selector-content-Cuk7NB-u.cjs} +1 -1
  63. package/dist/{no-language-page-content-CzENgtnu.js → no-language-page-content-9B2Fm-on.js} +2 -2
  64. package/dist/{no-language-page-content-BvPDdccK.cjs → no-language-page-content-CxTp-LIM.cjs} +1 -1
  65. package/dist/{no-language-page-dialog-CbYI2cVg.js → no-language-page-dialog-CPlKMyb8.js} +2 -2
  66. package/dist/{no-language-page-dialog-CgW4yJBC.cjs → no-language-page-dialog-DynACvgV.cjs} +1 -1
  67. package/dist/{page-creator-Cc83uQqw.js → page-creator-BtyJz2sx.js} +14 -14
  68. package/dist/{page-creator-g8GqgcKH.cjs → page-creator-Cbfv9N0P.cjs} +1 -1
  69. package/dist/{page-lock-BJUkyxdh.js → page-lock-CzsxrmN5.js} +2 -2
  70. package/dist/{page-lock-CT7SmQqp.cjs → page-lock-fRos9wRU.cjs} +1 -1
  71. package/dist/{page-locked-dialog-DsEbWRed.js → page-locked-dialog-D2q9qkPk.js} +2 -2
  72. package/dist/{page-locked-dialog-Co5b9XIZ.cjs → page-locked-dialog-D57d2gvn.cjs} +1 -1
  73. package/dist/{page-manager-new-5rFP5DyQ.js → page-manager-new-D6DVIx2S.js} +3 -3
  74. package/dist/{page-manager-new-BOkJImo2.cjs → page-manager-new-aE198gKS.cjs} +1 -1
  75. package/dist/{page-manager-search-and-filter-zq-LfhQ1.js → page-manager-search-and-filter-CuZkQaZg.js} +2 -2
  76. package/dist/{page-manager-search-and-filter-Bfm0j1gg.cjs → page-manager-search-and-filter-DGQEgKzy.cjs} +1 -1
  77. package/dist/{page-revisions-content-D38G2tJM.js → page-revisions-content-5rbicFbD.js} +3 -3
  78. package/dist/{page-revisions-content-ag-MHBGr.cjs → page-revisions-content-CefqOvKX.cjs} +1 -1
  79. package/dist/pages.cjs +1 -1
  80. package/dist/pages.js +1 -1
  81. package/dist/{publish-pages-content-BiX-GMLw.cjs → publish-pages-content-DBb8M3TG.cjs} +1 -1
  82. package/dist/{publish-pages-content-CS7f41Ac.js → publish-pages-content-WeGk-YLC.js} +3 -3
  83. package/dist/{rte-widget-modal-BKNx2wln.cjs → rte-widget-modal-DBoPRXq-.cjs} +1 -1
  84. package/dist/{rte-widget-modal-D6Zik0Ta.js → rte-widget-modal-J-_AytmK.js} +1 -1
  85. package/dist/{save-to-lib-ffjCZYJ5.cjs → save-to-lib-0ysmXVbI.cjs} +1 -1
  86. package/dist/{save-to-lib-WwOzbgiF.js → save-to-lib-CQQxoovF.js} +2 -2
  87. package/dist/{selected-block-display-BOgnQRLF.cjs → selected-block-display-BWupQFoQ.cjs} +1 -1
  88. package/dist/{selected-block-display-B1SG_UXw.js → selected-block-display-CgoXS8Hr.js} +2 -2
  89. package/dist/{seo-panel-BkOgRoWd.js → seo-panel-B798Myp_.js} +2 -2
  90. package/dist/{seo-panel-FjS1UF_y.cjs → seo-panel-BkFbXIL0.cjs} +1 -1
  91. package/dist/{shared-json-ld-uka9TOgA.js → shared-json-ld-Clg_UEhd.js} +2 -2
  92. package/dist/{shared-json-ld-yJkXjENy.cjs → shared-json-ld-Cn3MCW6I.cjs} +1 -1
  93. package/dist/{slug-input-Cyd6NR6J.cjs → slug-input-BHyD8cxk.cjs} +1 -1
  94. package/dist/{slug-input-DHLmUNrH.js → slug-input-hX5VaZpj.js} +1 -1
  95. package/dist/{take-over-request-CmpJVe9T.cjs → take-over-request-Dzczo20q.cjs} +1 -1
  96. package/dist/{take-over-request-Ca0X-qyf.js → take-over-request-s1L5Yofb.js} +2 -2
  97. package/dist/{theme-panel-footer-CKO9YYwZ.cjs → theme-panel-footer-NTNCL0SW.cjs} +1 -1
  98. package/dist/{theme-panel-footer-BUXIu252.js → theme-panel-footer-sK6bYhEb.js} +2 -2
  99. package/dist/{translation-warning-modal-pSZVKcNW.cjs → translation-warning-modal-BfM4HGck.cjs} +1 -1
  100. package/dist/{translation-warning-modal-DrpFeI83.js → translation-warning-modal-Jadkcver.js} +1 -1
  101. package/dist/{unmark-as-template-DF1Ms4VN.cjs → unmark-as-template-CqkHI3gR.cjs} +1 -1
  102. package/dist/{unmark-as-template-BMqgelv-.js → unmark-as-template-D5b775eR.js} +2 -2
  103. package/dist/{unpublish-page-Bsq2yEqQ.cjs → unpublish-page-BT5bCfs6.cjs} +1 -1
  104. package/dist/{unpublish-page-BJ0Bsvt2.js → unpublish-page-DLLLgY43.js} +2 -2
  105. package/dist/utils.cjs +1 -1
  106. package/dist/utils.d.ts +1 -1
  107. package/dist/utils.js +1 -1
  108. package/dist/web-blocks.cjs +1 -1
  109. package/dist/web-blocks.js +42 -42
  110. package/dist/{web-preview-D6h1L2nV.js → web-preview-C_yFwxEe.js} +1 -1
  111. package/dist/{web-preview-kres0aG7.cjs → web-preview-DU1MgppY.cjs} +1 -1
  112. package/package.json +1 -1
  113. package/dist/css-import-modal-Rh1QAVxo.cjs +0 -13
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),X=require("./index-C99FhuF1.cjs"),f=require("./index-C0-pgg_p.cjs"),B=require("./use-page-expand-manager-B6XTvk0E.cjs"),r=require("lodash-es"),O=require("jotai"),b=require("lucide-react"),l=require("react"),ne=require("react-i18next"),re=require("./register-chai-top-bar-BqwKw4uy.cjs"),Y=(e,n)=>!e||!Array.isArray(e)?[]:r.isEmpty(n)?e:r.compact(r.filter(e,a=>{const s=r.toLower(n);return r.includes(r.toLower((a==null?void 0:a.name)||""),s)||r.includes(r.toLower((a==null?void 0:a.slug)||""),s)})),ae=(e,n)=>{const a=new Set,s=r.keyBy(e,"id");return n.forEach(c=>{let o=c;for(;o.parent&&s[o.parent];)a.add(o.parent),o=s[o.parent]}),Array.from(a).map(c=>s[c])},$=(e,n,a)=>r.isEmpty(n)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?$(s.children,n,a):[]};const c=s.children&&s.children.some(o=>r.includes(r.toLower(o.name||""),r.toLower(n))||r.includes(r.toLower(o.slug||""),r.toLower(n)));return{...s,shouldExpandOnSearch:c,children:s.children?$(s.children,n,a):[]}}),le=e=>{if(!e||!e.length)return[];const n={};e.forEach(s=>{n[s.id]={...s,children:[]}});const a=[];return Object.values(n).forEach(s=>{s.parent&&n[s.parent]?n[s.parent].children.push(s):a.push(s)}),a},J=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?J(a.children):[]})),oe=(e,n,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=r.compact(r.filter(e,{pageType:a}))),r.isEmpty(n))c=Y(c,n);else{const x=Y(c,n),u=ae(e,x);c=r.uniqBy([...x,...u],"id")}const o=J(le(c)),p=$(o,n,s),v=r.filter(p,x=>s(x.pageType)).sort((x,u)=>(x.name||"").localeCompare(u.name||"")),d=r.filter(p,x=>!s(x.pageType));let y=[];if(a==="all"){const x=r.keyBy(d,"pageType");y=Object.values(r.mapValues(x,(u,g)=>({...u,id:g,name:r.startCase(g),isPartialGroup:!0,children:p.filter(w=>w.pageType===g)})))}else y=d.sort((x,u)=>(x.name||"").localeCompare(u.name||""));return[...v,...y]},ie=O.atom({pageId:null,position:{x:0,y:0}}),ce=({pageId:e,children:n})=>{const[a,s]=O.useAtom(ie),c=l.useRef(null),o=a.pageId===e;l.useEffect(()=>{const d=()=>s({pageId:null,position:{x:0,y:0}});if(o)return document.addEventListener("click",d),()=>document.removeEventListener("click",d)},[o,s]);const p=d=>{d.preventDefault(),d.stopPropagation(),s({pageId:e,position:{x:d.clientX,y:d.clientY}})},v=()=>{const d=`${window.location.pathname}?page=${e}`;window.open(d,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:p,children:n}),o&&t.jsx("div",{ref:c,className:"fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",style:{top:a.position.y,left:a.position.x},children:t.jsx("div",{className:"",children:t.jsxs(re.Button,{variant:"ghost",onClick:v,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(b.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},de=({page:e})=>{var s,c;const{isExpanded:n,toggleExpanded:a}=B.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:o=>{o.stopPropagation(),a()},disabled:!((s=e==null?void 0:e.children)!=null&&s.length),className:`flex h-[calc(100%-2px)] w-5 items-center justify-center rounded text-gray-400 transition-colors hover:bg-gray-200 hover:px-1 hover:text-gray-500 ${(c=e==null?void 0:e.children)!=null&&c.length?"hover:text-blue-400":"opacity-0"}`,children:t.jsx(b.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${n?"rotate-90":""}`})})},ue=({page:e,pageType:n})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(b.StarsIcon,{size:12,className:"text-yellow-400"}):n!=null&&n.icon?t.jsx("div",{className:"flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",dangerouslySetInnerHTML:{__html:n.icon}}):n!=null&&n.hasSlug?t.jsx(b.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(b.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),me=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),xe=({page:e,pageTypes:n,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:o,showUntranslatedPages:p})=>{const v=f.useUserId(),{pageToUser:d}=f.usePageToUser(),y=r.get(d,[e==null?void 0:e.id,"userId"]),{data:x}=f.useChaiUserInfo(y),u=x&&v!==y?x==null?void 0:x.name:null,g=f.useFallbackLang(),w=a===e.id,I=!!e.isTemplate,j=l.useMemo(()=>r.find(n,{key:e.pageType}),[n,e.pageType]);let h=r.get(c,e==null?void 0:e.id);h=r.get(h,"lang")===o?h:null;const E=o===g||!!h,L=(h==null?void 0:h.name)||(e==null?void 0:e.name)||"No name";let k=(h==null?void 0:h.slug)||(e==null?void 0:e.slug)||"";const C=k+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(k.startsWith("/")&&!p){const m=k.split("/").pop();k=k.endsWith(m)&&e.dynamic?"":`/${m}`}const M=l.useMemo(()=>{const m="flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]",T=`${w?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${m} ${T} ${u?"opacity-60":""}`:`${m} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,w,u]);return t.jsxs("div",{className:"group relative",children:[t.jsx(ce,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:M,children:[t.jsx(de,{page:e}),!e.isPartialGroup&&t.jsx(me,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&t.jsx(ue,{page:e,pageType:j}),t.jsx(f.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(k||e.dynamic)&&t.jsx(f.Tooltip,{content:C,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[k,e.dynamic&&(j==null?void 0:j.dynamicSlug)&&t.jsxs("span",{className:"text-xs text-gray-500",children:["/",j==null?void 0:j.dynamicSlug,e.dynamicSlugCustom]})]})}),I&&t.jsx(f.Tooltip,{content:"Template",side:"top",children:t.jsx("span",{className:"text-blue-500",children:t.jsx(b.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!u?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(f.PageActionsDropdown,{isLanguagePage:!!h,page:h||e,setDuplicatePage:m=>s("duplicate",m),setAddEditPage:m=>s("edit",h||m),setUnpublishPage:m=>s("unpublish",m),setDeletePage:m=>s("delete",h||m),setMarkAsTemplate:m=>s("markAsTemplate",m),setUnmarkAsTemplate:m=>s("unmarkAsTemplate",m),children:t.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:t.jsx(b.MoreHorizontal,{className:"h-4 w-4",onClick:m=>m.stopPropagation()})})})}):u?t.jsx("span",{className:"duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:t.jsx(b.Lock,{className:"h-3.5 w-3.5 fill-red-200 text-red-500"})}):null]})}),t.jsx(t.Fragment,{children:u&&t.jsxs("button",{className:"absolute right-px top-1/2 flex h-6 -translate-y-1/2 items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100",children:[t.jsx(b.Edit,{size:12,className:"stroke-[3]"})," ",t.jsx("span",{className:"font-medium",children:u})," is editing this page"]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!u&&t.jsxs("button",{onClick:m=>{m.stopPropagation(),s("addLanguagePage",{language:o,page:e})},className:"absolute left-1/2 top-1 flex -translate-x-1/2 items-center gap-x-1 rounded bg-blue-500 px-2 py-0.5 text-xs text-white opacity-0 duration-200 hover:bg-blue-700 group-hover:opacity-100",children:[t.jsx(b.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",r.get(f.LANGUAGES,o)," Page"]})]})})]})},K=({pages:e,tier:n,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v})=>{const{expandedPages:d}=B.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${n*10}px`},children:e.map(y=>t.jsxs(t.Fragment,{children:[t.jsx(xe,{page:y,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v}),y.children&&y.children.length>0&&(d==null?void 0:d.includes(y.id))&&t.jsx(K,{pages:y.children,tier:n+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v})]},y.id))})},he=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-Bfm0j1gg.cjs"))),fe=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-C_PzKby8.cjs"))),pe=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-DAvEjHwF.cjs"))),ye=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-DzZByALW.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-CpWEBJGd.cjs"))),ge=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-DF1Ms4VN.cjs"))),je=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-Bsq2yEqQ.cjs"))),be=({close:e})=>{const{t:n}=ne.useTranslation(),{languages:a,setSelectedLang:s}=X.useLanguages(),{data:c}=f.usePageTypes(),{data:o,isFetching:p}=f.useWebsitePages(),[v,d]=f.useSearchParams(),{updateForSelectedPage:y,expandPagesOnSearch:x}=B.usePageExpandManager(null),u=f.useFallbackLang(),g=v.get("page"),[w,I]=l.useState(""),[j,h]=l.useState(null),[E,L]=l.useState(null),[k,C]=l.useState(null),[M,m]=l.useState(null),[T,F]=l.useState(""),[R,G]=l.useState(null),[D,W]=l.useState(null),[S,Z]=l.useState(u),[ee,te]=l.useState(!1),_=O.useSetAtom(f.addNewLangAtom),q=ee&&S!==u,{data:A,isFetching:se}=f.useWebsiteLanguagePages(S),H=l.useCallback(P=>{var i;return(i=r.find(c,{key:P}))==null?void 0:i.hasSlug},[c]),N=l.useMemo(()=>o?q?r.filter(o,P=>!(A!=null&&A[P.id])):oe(o,w,T,H):[],[o,H,w,T,A,q]);l.useEffect(()=>{s(u)},[u,s]),l.useEffect(()=>{if(!r.isEmpty(T))return;const P=sessionStorage.getItem("pageTypeFilter")||"all";!r.isEmpty(c)&&P&&(r.find(c,{key:P})?F(P):F("all"))},[c,T]),l.useEffect(()=>{if(g&&!p&&!r.find(o,{id:g})){const i=r.find(o,{slug:"/"});if(i){const z=new URLSearchParams({page:i.id});f.navigateToPage(z,d)}else f.navigateToPage(new URLSearchParams({}),d,!0)}},[o,g,p,d]),l.useEffect(()=>{g&&!p&&!r.isEmpty(N)&&y(N,g)},[g,p,N,y]),l.useEffect(()=>{!r.isEmpty(w)&&!r.isEmpty(N)&&x(N)},[w,N,x]);const{setSelectedLang:U}=X.useLanguages(),Q=l.useCallback(P=>{const i=new URLSearchParams({page:P});S!==u?(i.set("lang",S),U(S)):U(""),f.navigateToPage(i,d),e()},[e,d,U,S,u]),V=(P,i)=>{var z;if(i)switch(P){case"add":L(i);break;case"select":Q(i);break;case"edit":S!==u?_({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):L(i);break;case"delete":h(i);break;case"unpublish":C(i);break;case"markAsTemplate":m(i);break;case"unmarkAsTemplate":W(i);break;case"duplicate":G(i);break;case"addLanguagePage":_({edit:!1,primaryPage:((z=i==null?void 0:i.page)==null?void 0:z.id)||"",preselectedLang:(i==null?void 0:i.language)||S});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(l.Suspense,{children:t.jsx(he,{pages:N,search:w,setSearch:I,languages:[u,...a],selectedLanguage:S,setSelectedLanguage:Z,selectedPageType:T,setSelectedPageType:F,onAddPage:P=>V("add",P),showUntranslatedPages:q,setShowUntranslatedPages:te})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:p||se?t.jsx("div",{className:"space-y-2",children:r.map([...Array(15).keys()],P=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},P))}):r.isEmpty(N)?t.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[t.jsx(b.File,{className:"h-6 w-6 stroke-[1]"}),n("Empty List!"),t.jsx("span",{className:"font-light",children:n("Add new page to start")})]}):t.jsx(K,{tier:0,pages:N,pageTypes:c,currentPage:g||"",onClickAction:V,languagePages:A,selectedLanguage:S,showUntranslatedPages:q})})]}),E&&t.jsx(l.Suspense,{children:t.jsx(fe,{closePanel:e,editPage:Q,addEditPage:E,setAddEditPage:L})}),j&&t.jsx(l.Suspense,{children:t.jsx(pe,{page:j,onClose:()=>h(null)})}),k&&t.jsx(l.Suspense,{children:t.jsx(je,{page:k,onClose:()=>C(null)})}),M&&t.jsx(l.Suspense,{children:t.jsx(Pe,{page:M,onClose:()=>m(null)})}),D&&t.jsx(l.Suspense,{children:t.jsx(ge,{page:D,onClose:()=>W(null)})}),R&&t.jsx(l.Suspense,{children:t.jsx(ye,{page:R,onClose:()=>G(null),closePanel:e})})]})};exports.default=be;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),X=require("./index-B0e71wJ1.cjs"),f=require("./index-DKuwxj1x.cjs"),B=require("./use-page-expand-manager-B6XTvk0E.cjs"),r=require("lodash-es"),O=require("jotai"),b=require("lucide-react"),l=require("react"),ne=require("react-i18next"),re=require("./register-chai-top-bar-BqwKw4uy.cjs"),Y=(e,n)=>!e||!Array.isArray(e)?[]:r.isEmpty(n)?e:r.compact(r.filter(e,a=>{const s=r.toLower(n);return r.includes(r.toLower((a==null?void 0:a.name)||""),s)||r.includes(r.toLower((a==null?void 0:a.slug)||""),s)})),ae=(e,n)=>{const a=new Set,s=r.keyBy(e,"id");return n.forEach(c=>{let o=c;for(;o.parent&&s[o.parent];)a.add(o.parent),o=s[o.parent]}),Array.from(a).map(c=>s[c])},$=(e,n,a)=>r.isEmpty(n)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?$(s.children,n,a):[]};const c=s.children&&s.children.some(o=>r.includes(r.toLower(o.name||""),r.toLower(n))||r.includes(r.toLower(o.slug||""),r.toLower(n)));return{...s,shouldExpandOnSearch:c,children:s.children?$(s.children,n,a):[]}}),le=e=>{if(!e||!e.length)return[];const n={};e.forEach(s=>{n[s.id]={...s,children:[]}});const a=[];return Object.values(n).forEach(s=>{s.parent&&n[s.parent]?n[s.parent].children.push(s):a.push(s)}),a},J=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?J(a.children):[]})),oe=(e,n,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=r.compact(r.filter(e,{pageType:a}))),r.isEmpty(n))c=Y(c,n);else{const x=Y(c,n),u=ae(e,x);c=r.uniqBy([...x,...u],"id")}const o=J(le(c)),p=$(o,n,s),v=r.filter(p,x=>s(x.pageType)).sort((x,u)=>(x.name||"").localeCompare(u.name||"")),d=r.filter(p,x=>!s(x.pageType));let y=[];if(a==="all"){const x=r.keyBy(d,"pageType");y=Object.values(r.mapValues(x,(u,g)=>({...u,id:g,name:r.startCase(g),isPartialGroup:!0,children:p.filter(w=>w.pageType===g)})))}else y=d.sort((x,u)=>(x.name||"").localeCompare(u.name||""));return[...v,...y]},ie=O.atom({pageId:null,position:{x:0,y:0}}),ce=({pageId:e,children:n})=>{const[a,s]=O.useAtom(ie),c=l.useRef(null),o=a.pageId===e;l.useEffect(()=>{const d=()=>s({pageId:null,position:{x:0,y:0}});if(o)return document.addEventListener("click",d),()=>document.removeEventListener("click",d)},[o,s]);const p=d=>{d.preventDefault(),d.stopPropagation(),s({pageId:e,position:{x:d.clientX,y:d.clientY}})},v=()=>{const d=`${window.location.pathname}?page=${e}`;window.open(d,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:p,children:n}),o&&t.jsx("div",{ref:c,className:"fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",style:{top:a.position.y,left:a.position.x},children:t.jsx("div",{className:"",children:t.jsxs(re.Button,{variant:"ghost",onClick:v,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(b.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},de=({page:e})=>{var s,c;const{isExpanded:n,toggleExpanded:a}=B.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:o=>{o.stopPropagation(),a()},disabled:!((s=e==null?void 0:e.children)!=null&&s.length),className:`flex h-[calc(100%-2px)] w-5 items-center justify-center rounded text-gray-400 transition-colors hover:bg-gray-200 hover:px-1 hover:text-gray-500 ${(c=e==null?void 0:e.children)!=null&&c.length?"hover:text-blue-400":"opacity-0"}`,children:t.jsx(b.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${n?"rotate-90":""}`})})},ue=({page:e,pageType:n})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(b.StarsIcon,{size:12,className:"text-yellow-400"}):n!=null&&n.icon?t.jsx("div",{className:"flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",dangerouslySetInnerHTML:{__html:n.icon}}):n!=null&&n.hasSlug?t.jsx(b.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(b.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),me=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),xe=({page:e,pageTypes:n,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:o,showUntranslatedPages:p})=>{const v=f.useUserId(),{pageToUser:d}=f.usePageToUser(),y=r.get(d,[e==null?void 0:e.id,"userId"]),{data:x}=f.useChaiUserInfo(y),u=x&&v!==y?x==null?void 0:x.name:null,g=f.useFallbackLang(),w=a===e.id,I=!!e.isTemplate,j=l.useMemo(()=>r.find(n,{key:e.pageType}),[n,e.pageType]);let h=r.get(c,e==null?void 0:e.id);h=r.get(h,"lang")===o?h:null;const E=o===g||!!h,L=(h==null?void 0:h.name)||(e==null?void 0:e.name)||"No name";let k=(h==null?void 0:h.slug)||(e==null?void 0:e.slug)||"";const C=k+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(k.startsWith("/")&&!p){const m=k.split("/").pop();k=k.endsWith(m)&&e.dynamic?"":`/${m}`}const M=l.useMemo(()=>{const m="flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]",T=`${w?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${m} ${T} ${u?"opacity-60":""}`:`${m} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,w,u]);return t.jsxs("div",{className:"group relative",children:[t.jsx(ce,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:M,children:[t.jsx(de,{page:e}),!e.isPartialGroup&&t.jsx(me,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&t.jsx(ue,{page:e,pageType:j}),t.jsx(f.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(k||e.dynamic)&&t.jsx(f.Tooltip,{content:C,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[k,e.dynamic&&(j==null?void 0:j.dynamicSlug)&&t.jsxs("span",{className:"text-xs text-gray-500",children:["/",j==null?void 0:j.dynamicSlug,e.dynamicSlugCustom]})]})}),I&&t.jsx(f.Tooltip,{content:"Template",side:"top",children:t.jsx("span",{className:"text-blue-500",children:t.jsx(b.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!u?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(f.PageActionsDropdown,{isLanguagePage:!!h,page:h||e,setDuplicatePage:m=>s("duplicate",m),setAddEditPage:m=>s("edit",h||m),setUnpublishPage:m=>s("unpublish",m),setDeletePage:m=>s("delete",h||m),setMarkAsTemplate:m=>s("markAsTemplate",m),setUnmarkAsTemplate:m=>s("unmarkAsTemplate",m),children:t.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:t.jsx(b.MoreHorizontal,{className:"h-4 w-4",onClick:m=>m.stopPropagation()})})})}):u?t.jsx("span",{className:"duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:t.jsx(b.Lock,{className:"h-3.5 w-3.5 fill-red-200 text-red-500"})}):null]})}),t.jsx(t.Fragment,{children:u&&t.jsxs("button",{className:"absolute right-px top-1/2 flex h-6 -translate-y-1/2 items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100",children:[t.jsx(b.Edit,{size:12,className:"stroke-[3]"})," ",t.jsx("span",{className:"font-medium",children:u})," is editing this page"]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!u&&t.jsxs("button",{onClick:m=>{m.stopPropagation(),s("addLanguagePage",{language:o,page:e})},className:"absolute left-1/2 top-1 flex -translate-x-1/2 items-center gap-x-1 rounded bg-blue-500 px-2 py-0.5 text-xs text-white opacity-0 duration-200 hover:bg-blue-700 group-hover:opacity-100",children:[t.jsx(b.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",r.get(f.LANGUAGES,o)," Page"]})]})})]})},K=({pages:e,tier:n,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v})=>{const{expandedPages:d}=B.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${n*10}px`},children:e.map(y=>t.jsxs(t.Fragment,{children:[t.jsx(xe,{page:y,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v}),y.children&&y.children.length>0&&(d==null?void 0:d.includes(y.id))&&t.jsx(K,{pages:y.children,tier:n+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v})]},y.id))})},he=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-DGQEgKzy.cjs"))),fe=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-mULv9r3z.cjs"))),pe=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-Djn97HiP.cjs"))),ye=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-C4Ovp8Ff.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-DF1KIMr0.cjs"))),ge=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-CqkHI3gR.cjs"))),je=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BT5bCfs6.cjs"))),be=({close:e})=>{const{t:n}=ne.useTranslation(),{languages:a,setSelectedLang:s}=X.useLanguages(),{data:c}=f.usePageTypes(),{data:o,isFetching:p}=f.useWebsitePages(),[v,d]=f.useSearchParams(),{updateForSelectedPage:y,expandPagesOnSearch:x}=B.usePageExpandManager(null),u=f.useFallbackLang(),g=v.get("page"),[w,I]=l.useState(""),[j,h]=l.useState(null),[E,L]=l.useState(null),[k,C]=l.useState(null),[M,m]=l.useState(null),[T,F]=l.useState(""),[R,G]=l.useState(null),[D,W]=l.useState(null),[S,Z]=l.useState(u),[ee,te]=l.useState(!1),_=O.useSetAtom(f.addNewLangAtom),q=ee&&S!==u,{data:A,isFetching:se}=f.useWebsiteLanguagePages(S),H=l.useCallback(P=>{var i;return(i=r.find(c,{key:P}))==null?void 0:i.hasSlug},[c]),N=l.useMemo(()=>o?q?r.filter(o,P=>!(A!=null&&A[P.id])):oe(o,w,T,H):[],[o,H,w,T,A,q]);l.useEffect(()=>{s(u)},[u,s]),l.useEffect(()=>{if(!r.isEmpty(T))return;const P=sessionStorage.getItem("pageTypeFilter")||"all";!r.isEmpty(c)&&P&&(r.find(c,{key:P})?F(P):F("all"))},[c,T]),l.useEffect(()=>{if(g&&!p&&!r.find(o,{id:g})){const i=r.find(o,{slug:"/"});if(i){const z=new URLSearchParams({page:i.id});f.navigateToPage(z,d)}else f.navigateToPage(new URLSearchParams({}),d,!0)}},[o,g,p,d]),l.useEffect(()=>{g&&!p&&!r.isEmpty(N)&&y(N,g)},[g,p,N,y]),l.useEffect(()=>{!r.isEmpty(w)&&!r.isEmpty(N)&&x(N)},[w,N,x]);const{setSelectedLang:U}=X.useLanguages(),Q=l.useCallback(P=>{const i=new URLSearchParams({page:P});S!==u?(i.set("lang",S),U(S)):U(""),f.navigateToPage(i,d),e()},[e,d,U,S,u]),V=(P,i)=>{var z;if(i)switch(P){case"add":L(i);break;case"select":Q(i);break;case"edit":S!==u?_({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):L(i);break;case"delete":h(i);break;case"unpublish":C(i);break;case"markAsTemplate":m(i);break;case"unmarkAsTemplate":W(i);break;case"duplicate":G(i);break;case"addLanguagePage":_({edit:!1,primaryPage:((z=i==null?void 0:i.page)==null?void 0:z.id)||"",preselectedLang:(i==null?void 0:i.language)||S});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(l.Suspense,{children:t.jsx(he,{pages:N,search:w,setSearch:I,languages:[u,...a],selectedLanguage:S,setSelectedLanguage:Z,selectedPageType:T,setSelectedPageType:F,onAddPage:P=>V("add",P),showUntranslatedPages:q,setShowUntranslatedPages:te})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:p||se?t.jsx("div",{className:"space-y-2",children:r.map([...Array(15).keys()],P=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},P))}):r.isEmpty(N)?t.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[t.jsx(b.File,{className:"h-6 w-6 stroke-[1]"}),n("Empty List!"),t.jsx("span",{className:"font-light",children:n("Add new page to start")})]}):t.jsx(K,{tier:0,pages:N,pageTypes:c,currentPage:g||"",onClickAction:V,languagePages:A,selectedLanguage:S,showUntranslatedPages:q})})]}),E&&t.jsx(l.Suspense,{children:t.jsx(fe,{closePanel:e,editPage:Q,addEditPage:E,setAddEditPage:L})}),j&&t.jsx(l.Suspense,{children:t.jsx(pe,{page:j,onClose:()=>h(null)})}),k&&t.jsx(l.Suspense,{children:t.jsx(je,{page:k,onClose:()=>C(null)})}),M&&t.jsx(l.Suspense,{children:t.jsx(Pe,{page:M,onClose:()=>m(null)})}),D&&t.jsx(l.Suspense,{children:t.jsx(ge,{page:D,onClose:()=>W(null)})}),R&&t.jsx(l.Suspense,{children:t.jsx(ye,{page:R,onClose:()=>G(null),closePanel:e})})]})};exports.default=be;
@@ -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-ESJHs5s-.js";
3
- import { w as g, x as b, y, S as L, z as F, A as I, B as w } from "./index-rAcNbjk_.js";
4
- import { k as j, L as T, m as $, A as B } from "./index-Dno42B0a.js";
3
+ import { w as g, x as b, y, S as L, z as F, A as I, B as w } from "./index-CAhEmHYP.js";
4
+ import { k as j, L as T, m as $, A as B } from "./index-Bn0fFN58.js";
5
5
  import { u as G } from "./use-page-expand-manager-Cf4MUEJw.js";
6
6
  import { useQueryClient as D } from "@tanstack/react-query";
7
7
  import { isEmpty as N, filter as x, map as S, get as o } from "lodash-es";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-BqwKw4uy.cjs"),n=require("./index-C99FhuF1.cjs"),f=require("./index-C0-pgg_p.cjs"),w=require("./use-page-expand-manager-B6XTvk0E.cjs"),C=require("@tanstack/react-query"),s=require("lodash-es"),d=require("lucide-react"),S=require("react"),g=require("react-i18next"),k=({selectedPageType:l,setSelectedPageType:i})=>{const{t:a}=g.useTranslation(),[r,o]=S.useState(""),{data:c}=f.usePageTypes(),u=t=>{if(!r)return!0;const x=r.toLowerCase(),m=j=>String(s.get(t,j,"")).toLowerCase().includes(x);return m("name")||m("key")},p=c.find(t=>t.key===l);return e.jsxs(n.Select,{onValueChange:i,value:l,children:[e.jsx(n.SelectTrigger,{className:`${l==="all"?"bg-gray-100/30 hover:bg-gray-100":"gap-x-1 border bg-gray-100/30 hover:bg-gray-100"} h-9 w-max min-w-[150px] overflow-hidden whitespace-nowrap rounded p-0 px-2 py-1 text-xs text-gray-600 shadow-none ring-0 focus:ring-0 [&>svg]:hidden`,children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-x-1.5",children:[e.jsx("span",{className:"max-w-[150px] overflow-hidden truncate whitespace-nowrap font-medium leading-tight",children:(p==null?void 0:p.name)||a("All")}),e.jsx(d.ListFilter,{className:`${l!=="all"?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`})]})}),e.jsxs(n.SelectContent,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white pb-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(d.Search,{strokeWidth:2,className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400"}),e.jsx(h.Input,{placeholder:a("Search page types..."),className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:r,onChange:t=>o(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(n.SelectItem,{value:"all",children:a("All")}),!s.isEmpty(s.filter(c,t=>t.hasSlug&&u(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:a("Pages")}),s.map([...s.filter(c,t=>t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),!s.isEmpty(s.filter(c,t=>!t.hasSlug&&u(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:a("Partials")}),s.map([...s.filter(c,t=>!t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),s.isEmpty(s.filter(c,u))&&e.jsx("div",{className:"px-3 py-2 text-center text-sm text-gray-500",children:a("No matching page types found")})]})]})},T=({search:l,setSearch:i})=>{const{t:a}=g.useTranslation();return e.jsxs("div",{className:"relative flex h-9 flex-1 items-center gap-2 rounded-md border px-2.5",children:[e.jsx("label",{htmlFor:"page-search-input",className:"sr-only",children:a("Search Pages")}),e.jsx(d.Search,{className:`${l?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground`,"aria-hidden":"true"}),e.jsx(h.Input,{id:"page-search-input",placeholder:a("Search pages"),value:l,onChange:r=>i(r.target.value),className:"border-none px-1.5 shadow-none outline-none ring-0 transition-none focus:outline-none focus:ring-0 focus-visible:ring-0",autoComplete:"off"})]})},E=({pages:l})=>{const{t:i}=g.useTranslation(),{expandAll:a,collapseAll:r,expandedPages:o}=w.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"outline",size:"icon",onClick:()=>a(l),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsUpDown,{})})}),e.jsx(n.TooltipContent,{children:i("Expand All")})]}),e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{disabled:o.length===0,variant:"outline",size:"icon",onClick:()=>r(),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsDownUp,{})})}),e.jsx(n.TooltipContent,{children:i("Collapse All")})]})]})},b=({languages:l,selectedLanguage:i,setSelectedLanguage:a})=>{const r=f.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:l.map(o=>e.jsxs(h.Button,{variant:i===o?"default":"outline",size:"sm",className:`h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${i===o?"bg-black text-white hover:bg-black":"text-gray-500"}`,onClick:()=>a(o.toLowerCase()),children:[o===r&&e.jsx(d.Star,{size:4,className:`p-0.5 ${i===r?"fill-white":"fill-black"}`}),f.LANGUAGES[o]||""]},o))})},y=()=>{const{t:l}=g.useTranslation(),i=C.useQueryClient();return e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{size:"sm",variant:"ghost",onClick:()=>i.invalidateQueries({queryKey:[f.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(d.RefreshCw,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:l("Refresh pages list")})]})},q=({pages:l,search:i,setSearch:a,languages:r,onAddPage:o,selectedLanguage:c,setSelectedLanguage:u,selectedPageType:p,setSelectedPageType:t,showUntranslatedPages:x,setShowUntranslatedPages:m})=>{const{t:j}=g.useTranslation(),v=r.length>1;return e.jsxs("div",{className:"space-y-3 border-b border-b-gray-200 px-4 pb-1",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(k,{selectedPageType:p,setSelectedPageType:t}),e.jsx(T,{search:i,setSearch:a}),e.jsx(E,{pages:l}),e.jsxs(h.Button,{variant:"default",onClick:o,className:"rounded px-3 font-normal",children:[e.jsx(d.Plus,{strokeWidth:2,className:"stroke-white stroke-[3]"}),e.jsx("span",{className:"font-normal text-white",children:j("Add Page")})]}),!v&&e.jsx(y,{})]}),v?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(b,{languages:r,selectedLanguage:c,setSelectedLanguage:N=>{u(N),m(x&&(r==null?void 0:r[0])!==c)}}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[(r==null?void 0:r[0])!==c&&e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"ghost",onClick:()=>m(!x),className:"h-6 rounded px-3 py-1 text-xs font-normal",children:x?e.jsx(d.FilterXIcon,{}):e.jsx(d.Filter,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:j("Toggle Untranslated Pages")})]}),e.jsx(y,{})]})]}):e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=b;exports.default=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-BqwKw4uy.cjs"),n=require("./index-B0e71wJ1.cjs"),f=require("./index-DKuwxj1x.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 { jsxs as a, Fragment as p, jsx as e } from "react/jsx-runtime";
2
2
  import { B as g } from "./register-chai-top-bar-ESJHs5s-.js";
3
- import { n as le, a9 as re, aa as ie, a2 as de, ab as y, Q as ce, D as q, d as G, e as j, f as L, p as z, q as P, r as oe, s as ue, t as me, v as U, ac as he } from "./index-rAcNbjk_.js";
4
- import { ar as R, as as A, A as b, aw as $, az as fe, ap as I, ax as C, ay as w } from "./index-Dno42B0a.js";
3
+ import { n as le, a9 as re, aa as ie, a2 as de, ab as y, Q as ce, D as q, d as G, e as j, f as L, p as z, q as P, r as oe, s as ue, t as me, v as U, ac as he } from "./index-CAhEmHYP.js";
4
+ import { ar as R, as as A, A as b, aw as $, az as fe, ap as I, ax as C, ay as w } from "./index-Bn0fFN58.js";
5
5
  import { useQuery as pe, useQueryClient as O, useMutation as H } from "@tanstack/react-query";
6
6
  import { format as D, formatDistanceToNow as xe } from "date-fns";
7
7
  import { isEmpty as ge } from "lodash-es";
@@ -46,7 +46,7 @@ const Ie = () => {
46
46
  });
47
47
  }
48
48
  });
49
- }, ke = Re(() => import("./json-diff-viewer-CMvGUvJ2.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: [
49
+ }, ke = Re(() => import("./json-diff-viewer-DNizzMnu.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: [
50
50
  /* @__PURE__ */ a("span", { className: "relative flex h-2 w-2", children: [
51
51
  /* @__PURE__ */ e("span", { className: "absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75" }),
52
52
  /* @__PURE__ */ e("span", { className: "relative inline-flex h-2 w-2 rounded-full bg-amber-500" })
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("./register-chai-top-bar-BqwKw4uy.cjs"),l=require("./index-C99FhuF1.cjs"),d=require("./index-C0-pgg_p.cjs"),y=require("@tanstack/react-query"),v=require("date-fns"),B=require("lodash-es"),p=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 a=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,a.get?a:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const S=L(g);function Q(s){const n=d.useApiUrl(),t=d.useFetch();return y.useQuery({queryKey:[d.ACTIONS.GET_PAGE_REVISIONS,s],queryFn:async()=>await t(n,{action:d.ACTIONS.GET_PAGE_REVISIONS,data:{pageId:s}}),enabled:!!s,refetchOnMount:!0})}const z=()=>{const s=d.useApiUrl(),n=d.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async a=>await n(s,{action:d.ACTIONS.DELETE_PAGE_REVISION,data:{revisionId:a}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},H=()=>{const s=d.useApiUrl(),n=d.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async({revisionId:a,discardCurrent:r})=>await n(s,{action:d.ACTIONS.RESTORE_PAGE_REVISION,data:{revisionId:a,discardCurrent:r}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},$=g.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-CLuUHiPU.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(p.Rocket,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Published"})]}):s==="unsaved"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-xs text-red-600",children:[e.jsx(p.Save,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Unsaved changes"})]}):e.jsx("span",{className:"rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600",children:s});function J({compare:s,setCompare:n}){const{data:t}=d.useChaiCurrentPage(),{saveState:a}=l.useSavePage(),[r]=d.usePageEditInfo();if(!t)return null;const c=!!s.find(u=>{var i;return(i=u==null?void 0:u.uid)==null?void 0:i.startsWith("draft:")}),x=s.length>=2&&!c,m=a==="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(r.lastSaved)&&e.jsxs("span",{children:["Last updated"," ",v.formatDistanceToNow(new Date(r.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(A,{checked:c,disabled:x,onChange:()=>{n(c?s.filter(u=>u.uid!==`draft:${t==null?void 0:t.id}`):[...s,{uid:`draft:${t==null?void 0:t.id}`,label:"draft",item:{createdAt:Date.now()}}])}})]})}function 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(l.Skeleton,{className:"h-4 w-3/4"}),e.jsx(l.Skeleton,{className:"h-3 w-1/2"}),e.jsx(l.Skeleton,{className:"mt-1 h-5 w-20"})]}),e.jsx(l.Skeleton,{className:"h-8 w-8 rounded-full"})]},n))})}function O({revision:s,isLatest:n,onRestore:t,onDelete:a,revisionNumber:r,compare:c,setCompare:x,pageId:m}){const{data:u}=d.useChaiUserInfo(s.currentEditor),i=(u==null?void 0:u.name)||"Unknown",f=!!c.find(h=>{var j;return n?(j=h==null?void 0:h.uid)==null?void 0:j.startsWith("live"):(h==null?void 0:h.uid)===s.uid}),w=c.length>=2&&!f;return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"flex items-center gap-1 text-xs leading-none",children:[e.jsx(b,{tag:n?"live":`#${r}`}),s.type==="published"?"Published":"Draft"," by ",e.jsx("span",{className:"text-xs font-bold",children:i})]})}),e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:s.type==="published"?e.jsx(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:v.format(s.createdAt,"MMM d, h:mm a")})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(d.PermissionChecker,{permissions:[d.PAGES_PERMISSIONS.RESTORE_REVISION,d.PAGES_PERMISSIONS.DELETE_REVISION],children:e.jsx(Y,{revision:s,onRestore:t,onDelete:a})})}),e.jsx(A,{checked:f,disabled:w,onChange:()=>{x(f?c.filter(h=>n?h.uid!==`live:${m}`:h.uid!==s.uid):[...c,{uid:n?`live:${m}`:s.uid,label:n?"live":`#${r}`,item:s}].sort((h,j)=>new Date(h.item.createdAt).getTime()-new Date(j.item.createdAt).getTime()))}})]})}function W({compare:s,setCompare:n,pageId:t}){const[a,r]=g.useState(!1),[c,x]=s;if(s.length===0)return null;const m=({tab:u})=>e.jsxs("span",{className:"flex items-center justify-between rounded border border-blue-100 p-1 font-medium",children:[e.jsx(b,{tag:u.label}),e.jsx("button",{className:"z-0 flex h-4 w-4 items-center justify-center rounded-full text-gray-400 hover:text-red-500",style:{lineHeight:1},onClick:()=>n(s.filter(i=>i.uid!==u.uid)),"aria-label":"Remove selection 1",children:e.jsx(p.X,{className:"h-3 w-3"})})]});return e.jsxs("div",{className:"mb-2 flex w-full max-w-md flex-col gap-1 rounded border bg-accent/60 p-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-xs",children:[e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"Compare"}),c&&e.jsx(m,{tab:c}),e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"with"}),x?e.jsx(m,{tab:x}):e.jsx("span",{className:"rounded border px-1 text-xs text-muted-foreground",children:"Choose another"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pb-0.5 pt-2",children:[e.jsx(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:()=>r(!0),disabled:s.length<2,children:[e.jsx(p.FileJson,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"pt-0.5",children:"Show JSON Diff"})]})]}),a&&(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:a,onOpenChange:r,compare:s})})]})}function A({checked:s,disabled:n,onChange:t,label:a="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:a})]})})}function Y({revision:s,onRestore:n,onDelete:t}){return e.jsxs(l.DropdownMenu,{children:[e.jsx(l.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(N.Button,{variant:"ghost",size:"icon",className:"h-5 w-5",children:[e.jsx(p.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More options"})]})}),e.jsxs(l.DropdownMenuContent,{align:"end",className:"text-xs",children:[e.jsx(d.PermissionChecker,{permission:d.PAGES_PERMISSIONS.RESTORE_REVISION,children:e.jsxs(l.DropdownMenuItem,{onClick:n,className:"cursor-pointer text-sm",children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Restore this version"})]})}),e.jsx(d.PermissionChecker,{permission:d.PAGES_PERMISSIONS.DELETE_REVISION,children:s.uid!=="current"&&e.jsxs(e.Fragment,{children:[e.jsx(l.DropdownMenuSeparator,{}),e.jsxs(l.DropdownMenuItem,{onClick:t,className:"cursor-pointer text-destructive",children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Delete this version"})]})]})})]})]})}function X({open:s,onOpenChange:n,revision:t,onRestore:a,isRestoring:r}){const{data:c}=d.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),x=(c==null?void 0:c.name)||"Unknown";return t?e.jsx(l.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(l.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(l.DialogHeader,{children:[e.jsx(l.DialogTitle,{children:"Restore Revision"}),e.jsxs(l.DialogDescription,{children:["You are about to restore to revision ",t.uid.substring(0,8)," from"," ",v.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",x]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"How would you like to handle your current edits?"})}),e.jsxs(l.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>a(!1),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Saving as draft..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.CloudOff,{className:"mr-2 h-4 w-4"}),"Save as draft"]})}),e.jsx(N.Button,{variant:"default",className:"sm:flex-1",onClick:()=>a(!0),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Discarding current..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),"Discard current"]})})]})]})}):null}function Z({open:s,onOpenChange:n,revision:t,onDelete:a,isDeleting:r}){const{data:c}=d.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),x=(c==null?void 0:c.name)||"Unknown";return t?e.jsx(l.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(l.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(l.DialogHeader,{children:[e.jsx(l.DialogTitle,{children:"Delete Revision"}),e.jsxs(l.DialogDescription,{children:["You are about to delete revision ",t.uid.substring(0,8)," from"," ",v.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",x]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone. Are you sure you want to proceed?"})}),e.jsxs(l.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:r,children:"Cancel"}),e.jsx(N.Button,{variant:"destructive",className:"sm:flex-1",onClick:a,disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),"Delete Revision"]})})]})]})}):null}function ee({isOpen:s}){var R,I;const[n,t]=S.useState([]),[a,r]=S.useState(null),[c,x]=S.useState(!1),[m,u]=S.useState(!1),{data:i}=d.useChaiCurrentPage(),{data:f,isFetching:w,error:h,refetch:j}=Q(i==null?void 0:i.id),{mutate:T,isPending:M}=z(),{mutate:k,isPending:F}=H(),_=y.useQueryClient(),{selectedLang:P,fallbackLang:q}=l.useLanguages(),U=P||q;g.useEffect(()=>{g.startTransition(()=>t([]))},[i==null?void 0:i.id]);const G=o=>{a&&k({revisionId:a.uid,discardCurrent:o},{onSuccess:()=>{x(!1),r(null),_.invalidateQueries({queryKey:[d.ACTIONS.GET_DRAFT_PAGE]})}})},C=o=>{r(o),x(!0)},E=o=>{r(o),u(!0)},V=()=>{a&&T(a.uid,{onSuccess:()=>{u(!1),r(null)}})};return g.useEffect(()=>{s&&j()},[s,j]),e.jsxs(e.Fragment,{children:[e.jsxs(l.SheetHeader,{children:[e.jsx(l.SheetTitle,{children:"Revision History"}),(i==null?void 0:i.createdAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Page created on ",v.format(new Date(i.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),w?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:i==null?void 0:i.id}),e.jsx(J,{compare:n,setCompare:t}),(R=f==null?void 0:f.filter(o=>o.uid==="current"))==null?void 0:R.map((o,D)=>e.jsx(O,{pageId:i==null?void 0:i.id,revision:o,isLatest:!0,onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:D,compare:n,setCompare:t},o.uid)),e.jsx(l.ScrollArea,{className:"min-h-0 flex-1",children:e.jsx("div",{className:"space-y-2",children:(I=f==null?void 0:f.filter(o=>o.uid!=="current"))==null?void 0:I.map((o,D)=>e.jsx(O,{pageId:i==null?void 0:i.id,revision:o,isLatest:o.uid==="current",onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:D+1,compare:n,setCompare:t},o.uid))})})]}),e.jsx(X,{open:c,onOpenChange:x,revision:a,onRestore:G,isRestoring:F}),e.jsx(Z,{open:m,onOpenChange:u,revision:a,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-BqwKw4uy.cjs"),l=require("./index-B0e71wJ1.cjs"),d=require("./index-DKuwxj1x.cjs"),y=require("@tanstack/react-query"),v=require("date-fns"),B=require("lodash-es"),p=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 a=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,a.get?a:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const S=L(g);function Q(s){const n=d.useApiUrl(),t=d.useFetch();return y.useQuery({queryKey:[d.ACTIONS.GET_PAGE_REVISIONS,s],queryFn:async()=>await t(n,{action:d.ACTIONS.GET_PAGE_REVISIONS,data:{pageId:s}}),enabled:!!s,refetchOnMount:!0})}const z=()=>{const s=d.useApiUrl(),n=d.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async a=>await n(s,{action:d.ACTIONS.DELETE_PAGE_REVISION,data:{revisionId:a}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},H=()=>{const s=d.useApiUrl(),n=d.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async({revisionId:a,discardCurrent:r})=>await n(s,{action:d.ACTIONS.RESTORE_PAGE_REVISION,data:{revisionId:a,discardCurrent:r}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},$=g.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-D9DVIBz4.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(p.Rocket,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Published"})]}):s==="unsaved"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-xs text-red-600",children:[e.jsx(p.Save,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Unsaved changes"})]}):e.jsx("span",{className:"rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600",children:s});function J({compare:s,setCompare:n}){const{data:t}=d.useChaiCurrentPage(),{saveState:a}=l.useSavePage(),[r]=d.usePageEditInfo();if(!t)return null;const c=!!s.find(u=>{var i;return(i=u==null?void 0:u.uid)==null?void 0:i.startsWith("draft:")}),x=s.length>=2&&!c,m=a==="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(r.lastSaved)&&e.jsxs("span",{children:["Last updated"," ",v.formatDistanceToNow(new Date(r.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(A,{checked:c,disabled:x,onChange:()=>{n(c?s.filter(u=>u.uid!==`draft:${t==null?void 0:t.id}`):[...s,{uid:`draft:${t==null?void 0:t.id}`,label:"draft",item:{createdAt:Date.now()}}])}})]})}function 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(l.Skeleton,{className:"h-4 w-3/4"}),e.jsx(l.Skeleton,{className:"h-3 w-1/2"}),e.jsx(l.Skeleton,{className:"mt-1 h-5 w-20"})]}),e.jsx(l.Skeleton,{className:"h-8 w-8 rounded-full"})]},n))})}function O({revision:s,isLatest:n,onRestore:t,onDelete:a,revisionNumber:r,compare:c,setCompare:x,pageId:m}){const{data:u}=d.useChaiUserInfo(s.currentEditor),i=(u==null?void 0:u.name)||"Unknown",f=!!c.find(h=>{var j;return n?(j=h==null?void 0:h.uid)==null?void 0:j.startsWith("live"):(h==null?void 0:h.uid)===s.uid}),w=c.length>=2&&!f;return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"flex items-center gap-1 text-xs leading-none",children:[e.jsx(b,{tag:n?"live":`#${r}`}),s.type==="published"?"Published":"Draft"," by ",e.jsx("span",{className:"text-xs font-bold",children:i})]})}),e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:s.type==="published"?e.jsx(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:v.format(s.createdAt,"MMM d, h:mm a")})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(d.PermissionChecker,{permissions:[d.PAGES_PERMISSIONS.RESTORE_REVISION,d.PAGES_PERMISSIONS.DELETE_REVISION],children:e.jsx(Y,{revision:s,onRestore:t,onDelete:a})})}),e.jsx(A,{checked:f,disabled:w,onChange:()=>{x(f?c.filter(h=>n?h.uid!==`live:${m}`:h.uid!==s.uid):[...c,{uid:n?`live:${m}`:s.uid,label:n?"live":`#${r}`,item:s}].sort((h,j)=>new Date(h.item.createdAt).getTime()-new Date(j.item.createdAt).getTime()))}})]})}function W({compare:s,setCompare:n,pageId:t}){const[a,r]=g.useState(!1),[c,x]=s;if(s.length===0)return null;const m=({tab:u})=>e.jsxs("span",{className:"flex items-center justify-between rounded border border-blue-100 p-1 font-medium",children:[e.jsx(b,{tag:u.label}),e.jsx("button",{className:"z-0 flex h-4 w-4 items-center justify-center rounded-full text-gray-400 hover:text-red-500",style:{lineHeight:1},onClick:()=>n(s.filter(i=>i.uid!==u.uid)),"aria-label":"Remove selection 1",children:e.jsx(p.X,{className:"h-3 w-3"})})]});return e.jsxs("div",{className:"mb-2 flex w-full max-w-md flex-col gap-1 rounded border bg-accent/60 p-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-xs",children:[e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"Compare"}),c&&e.jsx(m,{tab:c}),e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"with"}),x?e.jsx(m,{tab:x}):e.jsx("span",{className:"rounded border px-1 text-xs text-muted-foreground",children:"Choose another"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pb-0.5 pt-2",children:[e.jsx(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:()=>r(!0),disabled:s.length<2,children:[e.jsx(p.FileJson,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"pt-0.5",children:"Show JSON Diff"})]})]}),a&&(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:a,onOpenChange:r,compare:s})})]})}function A({checked:s,disabled:n,onChange:t,label:a="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:a})]})})}function Y({revision:s,onRestore:n,onDelete:t}){return e.jsxs(l.DropdownMenu,{children:[e.jsx(l.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(N.Button,{variant:"ghost",size:"icon",className:"h-5 w-5",children:[e.jsx(p.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More options"})]})}),e.jsxs(l.DropdownMenuContent,{align:"end",className:"text-xs",children:[e.jsx(d.PermissionChecker,{permission:d.PAGES_PERMISSIONS.RESTORE_REVISION,children:e.jsxs(l.DropdownMenuItem,{onClick:n,className:"cursor-pointer text-sm",children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Restore this version"})]})}),e.jsx(d.PermissionChecker,{permission:d.PAGES_PERMISSIONS.DELETE_REVISION,children:s.uid!=="current"&&e.jsxs(e.Fragment,{children:[e.jsx(l.DropdownMenuSeparator,{}),e.jsxs(l.DropdownMenuItem,{onClick:t,className:"cursor-pointer text-destructive",children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Delete this version"})]})]})})]})]})}function X({open:s,onOpenChange:n,revision:t,onRestore:a,isRestoring:r}){const{data:c}=d.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),x=(c==null?void 0:c.name)||"Unknown";return t?e.jsx(l.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(l.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(l.DialogHeader,{children:[e.jsx(l.DialogTitle,{children:"Restore Revision"}),e.jsxs(l.DialogDescription,{children:["You are about to restore to revision ",t.uid.substring(0,8)," from"," ",v.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",x]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"How would you like to handle your current edits?"})}),e.jsxs(l.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>a(!1),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Saving as draft..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.CloudOff,{className:"mr-2 h-4 w-4"}),"Save as draft"]})}),e.jsx(N.Button,{variant:"default",className:"sm:flex-1",onClick:()=>a(!0),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Discarding current..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),"Discard current"]})})]})]})}):null}function Z({open:s,onOpenChange:n,revision:t,onDelete:a,isDeleting:r}){const{data:c}=d.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),x=(c==null?void 0:c.name)||"Unknown";return t?e.jsx(l.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(l.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(l.DialogHeader,{children:[e.jsx(l.DialogTitle,{children:"Delete Revision"}),e.jsxs(l.DialogDescription,{children:["You are about to delete revision ",t.uid.substring(0,8)," from"," ",v.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",x]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone. Are you sure you want to proceed?"})}),e.jsxs(l.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:r,children:"Cancel"}),e.jsx(N.Button,{variant:"destructive",className:"sm:flex-1",onClick:a,disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),"Delete Revision"]})})]})]})}):null}function ee({isOpen:s}){var R,I;const[n,t]=S.useState([]),[a,r]=S.useState(null),[c,x]=S.useState(!1),[m,u]=S.useState(!1),{data:i}=d.useChaiCurrentPage(),{data:f,isFetching:w,error:h,refetch:j}=Q(i==null?void 0:i.id),{mutate:T,isPending:M}=z(),{mutate:k,isPending:F}=H(),_=y.useQueryClient(),{selectedLang:P,fallbackLang:q}=l.useLanguages(),U=P||q;g.useEffect(()=>{g.startTransition(()=>t([]))},[i==null?void 0:i.id]);const G=o=>{a&&k({revisionId:a.uid,discardCurrent:o},{onSuccess:()=>{x(!1),r(null),_.invalidateQueries({queryKey:[d.ACTIONS.GET_DRAFT_PAGE]})}})},C=o=>{r(o),x(!0)},E=o=>{r(o),u(!0)},V=()=>{a&&T(a.uid,{onSuccess:()=>{u(!1),r(null)}})};return g.useEffect(()=>{s&&j()},[s,j]),e.jsxs(e.Fragment,{children:[e.jsxs(l.SheetHeader,{children:[e.jsx(l.SheetTitle,{children:"Revision History"}),(i==null?void 0:i.createdAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Page created on ",v.format(new Date(i.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),w?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:i==null?void 0:i.id}),e.jsx(J,{compare:n,setCompare:t}),(R=f==null?void 0:f.filter(o=>o.uid==="current"))==null?void 0:R.map((o,D)=>e.jsx(O,{pageId:i==null?void 0:i.id,revision:o,isLatest:!0,onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:D,compare:n,setCompare:t},o.uid)),e.jsx(l.ScrollArea,{className:"min-h-0 flex-1",children:e.jsx("div",{className:"space-y-2",children:(I=f==null?void 0:f.filter(o=>o.uid!=="current"))==null?void 0:I.map((o,D)=>e.jsx(O,{pageId:i==null?void 0:i.id,revision:o,isLatest:o.uid==="current",onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:D+1,compare:n,setCompare:t},o.uid))})})]}),e.jsx(X,{open:c,onOpenChange:x,revision:a,onRestore:G,isRestoring:F}),e.jsx(Z,{open:m,onOpenChange:u,revision:a,onDelete:V,isDeleting:M})]})}exports.default=ee;
package/dist/pages.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-C0-pgg_p.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.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.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-DKuwxj1x.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.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.useReloadPage=e.useReloadPage;exports.useUpdateActivePageMetadata=e.useUpdateActivePageMetadata;exports.useUserPermissions=e.useUserRoleAndPermissions;exports.useWebsitePages=e.useWebsitePages;exports.useWebsiteSetting=e.useWebsiteSetting;
package/dist/pages.js CHANGED
@@ -1,4 +1,4 @@
1
- import { aE as s, aT as u, aP as t, aN as i, aO as r, ax as g, aU as P, ar as l, v as h, aK as n, aZ as o, aw as c, ap as C, aV as d, k as p, as as m, aW as A, l as U, m as b, aX as k, aY as W, a_ as v, g as B, j as F } from "./index-Dno42B0a.js";
1
+ import { aE as s, aT as u, aP as t, aN as i, aO as r, ax as g, aU as P, ar as l, v as h, aK as n, aZ as o, aw as c, ap as C, aV as d, k as p, as as m, aW as A, l as U, m as b, aX as k, aY as W, a_ as v, g as B, j as F } from "./index-Bn0fFN58.js";
2
2
  export {
3
3
  s as ChaiJsonInput,
4
4
  u as ChaiWebsiteBuilder,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),q=require("./register-chai-top-bar-BqwKw4uy.cjs"),f=require("./index-C99FhuF1.cjs"),r=require("./index-C0-pgg_p.cjs"),U=require("./page-manager-search-and-filter-Bfm0j1gg.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-BqwKw4uy.cjs"),f=require("./index-B0e71wJ1.cjs"),r=require("./index-DKuwxj1x.cjs"),U=require("./page-manager-search-and-filter-DGQEgKzy.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,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-ESJHs5s-.js";
3
- import { d as K, e as Q, f as J, p as V, q as W } from "./index-rAcNbjk_.js";
4
- import { ar as X, as as Y, A as I, aA as O, aB as Z, k as ee, m as te, ap as se, T as U, t as le } from "./index-Dno42B0a.js";
5
- import { LanguageSelector as ae } from "./page-manager-search-and-filter-zq-LfhQ1.js";
3
+ import { d as K, e as Q, f as J, p as V, q as W } from "./index-CAhEmHYP.js";
4
+ import { ar as X, as as Y, A as I, aA as O, aB as Z, k as ee, m as te, ap as se, T as U, t as le } from "./index-Bn0fFN58.js";
5
+ import { LanguageSelector as ae } from "./page-manager-search-and-filter-CuZkQaZg.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"),p=require("./register-chai-top-bar-BqwKw4uy.cjs"),s=require("./index-C99FhuF1.cjs"),S=({isOpen:m,onClose:r,editor:t,rteElement:f})=>{const a=s.usePageExternalData(),u=o=>{if(!t)return;const i=`{{${o}}}`;t.commands.focus();const{from:j,to:g}=t.state.selection;if(j!==g)t.chain().deleteSelection().insertContent(i).run();else{const{state:c}=t,n=c.selection.from,x=c.doc.textBetween(Math.max(0,n-1),n),l=c.doc.textBetween(n,Math.min(n+1,c.doc.content.size));let d="";n>0&&x!==" "&&!/[.,!?;:]/.test(x)&&(d=" ");let h="";l&&l!==" "&&!/[.,!?;:]/.test(l)&&(h=" "),t.chain().insertContent(d+i+h).run()}};return e.jsx(s.Dialog,{open:m,onOpenChange:o=>!o&&r(),children:e.jsxs(s.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center justify-between pr-8",children:[e.jsx("span",{children:"Rich Text Editor"}),a&&Object.keys(a).length>0&&e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"mr-2 text-sm text-muted-foreground",children:"Add field:"}),e.jsx("div",{className:"rte-path-selector",children:e.jsx(s.NestedPathSelector,{data:a,onSelect:u})})]})]})}),f,e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(p.Button,{onClick:r,children:"Done"})})]})})};exports.default=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./register-chai-top-bar-BqwKw4uy.cjs"),s=require("./index-B0e71wJ1.cjs"),S=({isOpen:m,onClose:r,editor:t,rteElement:f})=>{const a=s.usePageExternalData(),u=o=>{if(!t)return;const i=`{{${o}}}`;t.commands.focus();const{from:j,to:g}=t.state.selection;if(j!==g)t.chain().deleteSelection().insertContent(i).run();else{const{state:c}=t,n=c.selection.from,x=c.doc.textBetween(Math.max(0,n-1),n),l=c.doc.textBetween(n,Math.min(n+1,c.doc.content.size));let d="";n>0&&x!==" "&&!/[.,!?;:]/.test(x)&&(d=" ");let h="";l&&l!==" "&&!/[.,!?;:]/.test(l)&&(h=" "),t.chain().insertContent(d+i+h).run()}};return e.jsx(s.Dialog,{open:m,onOpenChange:o=>!o&&r(),children:e.jsxs(s.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center justify-between pr-8",children:[e.jsx("span",{children:"Rich Text Editor"}),a&&Object.keys(a).length>0&&e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"mr-2 text-sm text-muted-foreground",children:"Add field:"}),e.jsx("div",{className:"rte-path-selector",children:e.jsx(s.NestedPathSelector,{data:a,onSelect:u})})]})]})}),f,e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(p.Button,{onClick:r,children:"Done"})})]})})};exports.default=S;
@@ -1,6 +1,6 @@
1
1
  import { jsx as e, jsxs as l } from "react/jsx-runtime";
2
2
  import { B as D } from "./register-chai-top-bar-ESJHs5s-.js";
3
- import { g as N, D as S, d as j, e as v, f as w, N as B } from "./index-rAcNbjk_.js";
3
+ import { g as N, D as S, d as j, e as v, f as w, N as B } from "./index-CAhEmHYP.js";
4
4
  const M = ({
5
5
  isOpen: f,
6
6
  onClose: r,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./register-chai-top-bar-BqwKw4uy.cjs"),b=require("./index-C99FhuF1.cjs"),x=require("./index-C0-pgg_p.cjs"),C=require("@tanstack/react-query"),j=require("sonner"),E=require("lucide-react"),i=require("react"),X=require("./image-compression-DZ9WMmyn.cjs"),R=require("lodash-es"),J=s=>{const r=x.useApiUrl(),l=x.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:x.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{s?s(t):j.toast.success("Block saved successfully")},onError:t=>{console.error("Error saving block:",t),j.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},Z=s=>{const r=x.useApiUrl(),l=x.useFetch();return C.useQuery({staleTime:"static",queryKey:[x.ACTIONS.GET_LIBRARY_ITEM,s],enabled:!!s,queryFn:async()=>{if(!s)return null;try{return await l(r,{action:x.ACTIONS.GET_LIBRARY_ITEM,data:{id:s}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},ee=s=>{const r=x.useApiUrl(),l=x.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:x.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:t}}),onSuccess:()=>{s?s():j.toast.success("Block deleted successfully")},onError:t=>{console.error("Error deleting block:",t),j.toast.error("Failed to delete block",{description:t instanceof Error?t.message:"Unknown error"})}})},te=({blockId:s,libBlockId:r,isOpen:l,onClose:t,blockName:m,trigger:f})=>{const[d,o]=i.useState(!1),c=b.useUpdateBlocksPropsRealtime(),y=ee(()=>{c([s],{_libBlockId:void 0}),j.toast.success("Block deleted successfully"),o(!1),t()}),p=()=>{o(!0),y.mutate(r)},g=e.jsxs(u.Button,{type:"button",variant:"destructive",size:"sm",onClick:h=>h.preventDefault(),disabled:d,children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]});return e.jsxs(b.Popover,{open:l,onOpenChange:h=>!h&&t(),children:[e.jsx(b.PopoverTrigger,{asChild:!0,children:f||g}),e.jsx(b.PopoverContent,{className:"z-[9999] w-72 p-4",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',m,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(u.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:d,children:"Cancel"}),e.jsx(u.Button,{type:"button",variant:"destructive",size:"sm",onClick:p,disabled:d,children:d?"Deleting...":"Delete"})]})]})})]})},se=({blockId:s,libBlockId:r,blockName:l,size:t="sm",className:m="",close:f})=>{const[d,o]=i.useState(!1);return e.jsx(te,{blockId:s,libBlockId:r,isOpen:d,onClose:()=>{o(!1),f()},blockName:l,trigger:e.jsxs(u.Button,{type:"button",variant:"destructive",size:t,className:m,onClick:()=>o(!0),children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})},re=()=>{const s=x.useApiUrl(),r=x.useFetch(),l=C.useQueryClient(),{data:t=[],isLoading:m,error:f}=C.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await r(s,{action:"GET_LIBRARY_GROUPS"})||[]}catch(c){return console.error("Error fetching library groups:",c),[]}}}),{mutateAsync:d,isPending:o}=C.useMutation({mutationFn:async c=>{if(!c.trim())throw new Error("Group name is required");return r(s,{action:"CREATE_BLOCK_GROUP",data:{name:c}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),j.toast.success("Group created successfully")},onError:c=>{console.error("Error creating group:",c),j.toast.error("Failed to create group",{description:c instanceof Error?c.message:"Unknown error"})}});return{groups:t,isLoading:m,error:f,createGroup:d,isCreating:o}},ne=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),[m,f]=i.useState(""),d=i.useRef(null),{groups:o}=re(),[c,y]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),p=i.useMemo(()=>[...o,...c.filter(n=>!o.some(B=>B.id===n.id))],[o,c]),g=()=>{const n=m.trim();if(!n)return;const B={id:n,name:n};y(w=>[...w,B]),r(B.id),f(""),t(!1)};i.useEffect(()=>{l&&d.current&&d.current.focus()},[l]);const h=n=>{n.key==="Enter"&&(n.preventDefault(),g())};return i.useEffect(()=>{s&&!p.some(n=>n.id===s)&&r("")},[s,p,r]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(u.Input,{ref:d,placeholder:"Enter new group name",value:m,onChange:n=>f(n.target.value),onKeyDown:h}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(u.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(u.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:s,onChange:n=>r(n.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(n=>e.jsx("option",{value:n.id,children:n.name},`lib-${n.id}`))}),c.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:c.filter(n=>!o.some(B=>B.id===n.id)).map(n=>e.jsx("option",{value:n.id,children:n.name},`local-${n.id}`))})]}),e.jsx(u.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(E.Plus,{className:"h-4 w-4"})})]})},ae=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),m=i.useRef(null),f=i.useCallback(async c=>{var p;const y=(p=c.target.files)==null?void 0:p[0];if(y)try{t(!0);let g=y;y.type.startsWith("image/")&&(g=await X.compressImageIfNeeded(y));const h=new FileReader;h.onloadend=()=>{r(h.result),t(!1)},h.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),j.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[r]),d=()=>{r(""),m.current&&(m.current.value="")},o=()=>{var c;(c=m.current)==null||c.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u.Input,{type:"file",ref:m,onChange:f,accept:"image/*",className:"hidden"}),e.jsx(u.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(E.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),s&&e.jsx(u.Button,{type:"button",variant:"outline",size:"icon",onClick:d,children:e.jsx(E.X,{className:"h-4 w-4"})})]}),s&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:s,alt:"Preview",className:"h-full w-full object-contain"})})]})},oe=s=>{const{blocks:r,close:l,blockId:t}=s,{getPartailBlocks:m}=b.usePartialBlocksStore(),f=r.find(a=>a._id===t),d=f==null?void 0:f._libBlockId,o=!!d,c=i.useMemo(()=>r.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[r]),y=i.useMemo(()=>{let a=[];for(const v of r)if(v._type==="PartialBlock"||v._type==="GlobalBlock"){let k=m(v.partialBlockId);v._parent&&(k==null?void 0:k.length)>0&&(k=k.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",v._parent),T))),a=[...a,...k]}else a.push(v);return a},[r,m]),[p,g]=i.useState(""),[h,n]=i.useState(""),[B,w]=i.useState(""),[S,_]=i.useState(""),[N,A]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=b.usePermissions(),Q=Y(x.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=b.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),j.toast.success("Block delinked from library"),l()},{data:I,isLoading:P,isError:G}=Z(d);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{I&&!P&&(g(I.name||""),n(I.group||""),w(I.description||""),_(I.preview||""),F(!1))},[I,P]),i.useEffect(()=>{const a=p.trim().length>=2,v=h.trim()!=="";M(a&&v)},[p,h]);const W=()=>{const a={};return p.trim()?p.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",h||(a.group="Group is required"),A(a),Object.keys(a).length===0},{resetLibrary:$}=b.useLibraryBlocks({id:""}),U=J(a=>{o||D([t],{_libBlockId:a.id}),j.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const v=y.map(k=>(R.has(k,"_libBlockId")&&delete k._libBlockId,k));U.mutate({name:p.trim(),group:h,blocks:v,description:B.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:d}:{}})},L=U.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(u.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(u.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[c&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(E.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(u.Input,{id:"name",placeholder:"Enter block name",value:p,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ne,{value:h,onChange:n}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(u.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:B,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(ae,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(se,{blockId:t,libBlockId:d,blockName:p,className:"mr-auto",close:l}),e.jsx(u.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(u.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=oe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./register-chai-top-bar-BqwKw4uy.cjs"),b=require("./index-B0e71wJ1.cjs"),x=require("./index-DKuwxj1x.cjs"),C=require("@tanstack/react-query"),j=require("sonner"),E=require("lucide-react"),i=require("react"),X=require("./image-compression-DZ9WMmyn.cjs"),R=require("lodash-es"),J=s=>{const r=x.useApiUrl(),l=x.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:x.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{s?s(t):j.toast.success("Block saved successfully")},onError:t=>{console.error("Error saving block:",t),j.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},Z=s=>{const r=x.useApiUrl(),l=x.useFetch();return C.useQuery({staleTime:"static",queryKey:[x.ACTIONS.GET_LIBRARY_ITEM,s],enabled:!!s,queryFn:async()=>{if(!s)return null;try{return await l(r,{action:x.ACTIONS.GET_LIBRARY_ITEM,data:{id:s}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},ee=s=>{const r=x.useApiUrl(),l=x.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:x.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:t}}),onSuccess:()=>{s?s():j.toast.success("Block deleted successfully")},onError:t=>{console.error("Error deleting block:",t),j.toast.error("Failed to delete block",{description:t instanceof Error?t.message:"Unknown error"})}})},te=({blockId:s,libBlockId:r,isOpen:l,onClose:t,blockName:m,trigger:f})=>{const[d,o]=i.useState(!1),c=b.useUpdateBlocksPropsRealtime(),y=ee(()=>{c([s],{_libBlockId:void 0}),j.toast.success("Block deleted successfully"),o(!1),t()}),p=()=>{o(!0),y.mutate(r)},g=e.jsxs(u.Button,{type:"button",variant:"destructive",size:"sm",onClick:h=>h.preventDefault(),disabled:d,children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]});return e.jsxs(b.Popover,{open:l,onOpenChange:h=>!h&&t(),children:[e.jsx(b.PopoverTrigger,{asChild:!0,children:f||g}),e.jsx(b.PopoverContent,{className:"z-[9999] w-72 p-4",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',m,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(u.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:d,children:"Cancel"}),e.jsx(u.Button,{type:"button",variant:"destructive",size:"sm",onClick:p,disabled:d,children:d?"Deleting...":"Delete"})]})]})})]})},se=({blockId:s,libBlockId:r,blockName:l,size:t="sm",className:m="",close:f})=>{const[d,o]=i.useState(!1);return e.jsx(te,{blockId:s,libBlockId:r,isOpen:d,onClose:()=>{o(!1),f()},blockName:l,trigger:e.jsxs(u.Button,{type:"button",variant:"destructive",size:t,className:m,onClick:()=>o(!0),children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})},re=()=>{const s=x.useApiUrl(),r=x.useFetch(),l=C.useQueryClient(),{data:t=[],isLoading:m,error:f}=C.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await r(s,{action:"GET_LIBRARY_GROUPS"})||[]}catch(c){return console.error("Error fetching library groups:",c),[]}}}),{mutateAsync:d,isPending:o}=C.useMutation({mutationFn:async c=>{if(!c.trim())throw new Error("Group name is required");return r(s,{action:"CREATE_BLOCK_GROUP",data:{name:c}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),j.toast.success("Group created successfully")},onError:c=>{console.error("Error creating group:",c),j.toast.error("Failed to create group",{description:c instanceof Error?c.message:"Unknown error"})}});return{groups:t,isLoading:m,error:f,createGroup:d,isCreating:o}},ne=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),[m,f]=i.useState(""),d=i.useRef(null),{groups:o}=re(),[c,y]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),p=i.useMemo(()=>[...o,...c.filter(n=>!o.some(B=>B.id===n.id))],[o,c]),g=()=>{const n=m.trim();if(!n)return;const B={id:n,name:n};y(w=>[...w,B]),r(B.id),f(""),t(!1)};i.useEffect(()=>{l&&d.current&&d.current.focus()},[l]);const h=n=>{n.key==="Enter"&&(n.preventDefault(),g())};return i.useEffect(()=>{s&&!p.some(n=>n.id===s)&&r("")},[s,p,r]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(u.Input,{ref:d,placeholder:"Enter new group name",value:m,onChange:n=>f(n.target.value),onKeyDown:h}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(u.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(u.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:s,onChange:n=>r(n.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(n=>e.jsx("option",{value:n.id,children:n.name},`lib-${n.id}`))}),c.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:c.filter(n=>!o.some(B=>B.id===n.id)).map(n=>e.jsx("option",{value:n.id,children:n.name},`local-${n.id}`))})]}),e.jsx(u.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(E.Plus,{className:"h-4 w-4"})})]})},ae=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),m=i.useRef(null),f=i.useCallback(async c=>{var p;const y=(p=c.target.files)==null?void 0:p[0];if(y)try{t(!0);let g=y;y.type.startsWith("image/")&&(g=await X.compressImageIfNeeded(y));const h=new FileReader;h.onloadend=()=>{r(h.result),t(!1)},h.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),j.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[r]),d=()=>{r(""),m.current&&(m.current.value="")},o=()=>{var c;(c=m.current)==null||c.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u.Input,{type:"file",ref:m,onChange:f,accept:"image/*",className:"hidden"}),e.jsx(u.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(E.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),s&&e.jsx(u.Button,{type:"button",variant:"outline",size:"icon",onClick:d,children:e.jsx(E.X,{className:"h-4 w-4"})})]}),s&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:s,alt:"Preview",className:"h-full w-full object-contain"})})]})},oe=s=>{const{blocks:r,close:l,blockId:t}=s,{getPartailBlocks:m}=b.usePartialBlocksStore(),f=r.find(a=>a._id===t),d=f==null?void 0:f._libBlockId,o=!!d,c=i.useMemo(()=>r.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[r]),y=i.useMemo(()=>{let a=[];for(const v of r)if(v._type==="PartialBlock"||v._type==="GlobalBlock"){let k=m(v.partialBlockId);v._parent&&(k==null?void 0:k.length)>0&&(k=k.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",v._parent),T))),a=[...a,...k]}else a.push(v);return a},[r,m]),[p,g]=i.useState(""),[h,n]=i.useState(""),[B,w]=i.useState(""),[S,_]=i.useState(""),[N,A]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=b.usePermissions(),Q=Y(x.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=b.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),j.toast.success("Block delinked from library"),l()},{data:I,isLoading:P,isError:G}=Z(d);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{I&&!P&&(g(I.name||""),n(I.group||""),w(I.description||""),_(I.preview||""),F(!1))},[I,P]),i.useEffect(()=>{const a=p.trim().length>=2,v=h.trim()!=="";M(a&&v)},[p,h]);const W=()=>{const a={};return p.trim()?p.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",h||(a.group="Group is required"),A(a),Object.keys(a).length===0},{resetLibrary:$}=b.useLibraryBlocks({id:""}),U=J(a=>{o||D([t],{_libBlockId:a.id}),j.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const v=y.map(k=>(R.has(k,"_libBlockId")&&delete k._libBlockId,k));U.mutate({name:p.trim(),group:h,blocks:v,description:B.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:d}:{}})},L=U.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(u.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(u.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[c&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(E.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(u.Input,{id:"name",placeholder:"Enter block name",value:p,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ne,{value:h,onChange:n}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(u.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:B,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(ae,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(se,{blockId:t,libBlockId:d,blockName:p,className:"mr-auto",close:l}),e.jsx(u.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(u.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=oe;
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as i } from "react/jsx-runtime";
2
2
  import { B as b, z as L } from "./register-chai-top-bar-ESJHs5s-.js";
3
- import { c as j, a6 as se, a7 as ie, P as oe, az as le, ai as ce, aA as de, L as P } from "./index-rAcNbjk_.js";
4
- import { ar as D, as as G, A as _, ay as ue } from "./index-Dno42B0a.js";
3
+ import { c as j, a6 as se, a7 as ie, P as oe, az as le, ai as ce, aA as de, L as P } from "./index-CAhEmHYP.js";
4
+ import { ar as D, as as G, A as _, ay as ue } from "./index-Bn0fFN58.js";
5
5
  import { useQuery as K, useMutation as U, useQueryClient as me } from "@tanstack/react-query";
6
6
  import { toast as N } from "sonner";
7
7
  import { Trash2 as Y, Plus as pe, ImageIcon as fe, X as he, AlertCircle as ge } from "lucide-react";
@@ -1,4 +1,4 @@
1
- "use strict";const o=require("react/jsx-runtime"),r=require("./register-chai-top-bar-BqwKw4uy.cjs"),m=require("lucide-react"),i=require("react"),p=require("use-stick-to-bottom"),T=require("streamdown");require("@radix-ui/react-slot");const P=require("class-variance-authority"),_=require("./index-C99FhuF1.cjs");require("clsx");require("tailwind-merge");const z=require("@radix-ui/react-tooltip"),j=require("@radix-ui/react-use-controllable-state"),B=require("@radix-ui/react-collapsible"),D=require("framer-motion"),f=require("./index-C0-pgg_p.cjs"),I=require("react-i18next");function h(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const L=h(i),S=h(z),b=h(B),G=({className:e,...t})=>o.jsx(p.StickToBottom,{className:r.cn("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),$=({className:e,...t})=>o.jsx(p.StickToBottom.Content,{className:r.cn("flex flex-col gap-8 p-4",e),...t}),F=({className:e,title:t="No messages yet",description:s="Start a conversation to see messages here",icon:n,children:a,...l})=>o.jsx("div",{className:r.cn("flex size-full flex-col items-center justify-center gap-3 p-8 text-center",e),...l,children:a??o.jsxs(o.Fragment,{children:[n&&o.jsx("div",{className:"text-muted-foreground",children:n}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h3",{className:"text-sm font-medium",children:t}),s&&o.jsx("p",{className:"text-sm text-muted-foreground",children:s})]})]})}),Q=({className:e,...t})=>{const{isAtBottom:s,scrollToBottom:n}=p.useStickToBottomContext(),a=i.useCallback(()=>{n()},[n]);return!s&&o.jsx(r.Button,{className:r.cn("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",e),onClick:a,size:"icon",type:"button",variant:"outline",...t,children:o.jsx(m.ArrowDownIcon,{className:"size-4"})})};P.cva("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});const V=L.forwardRef(({className:e,sideOffset:t=4,...s},n)=>o.jsx(S.Content,{ref:n,sideOffset:t,className:r.cn("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",e),...s}));V.displayName=S.Content.displayName;const K=({className:e,from:t,...s})=>o.jsx("div",{className:r.cn("group flex w-full max-w-[80%] flex-col gap-2",t==="user"?"is-user ml-auto justify-end":"is-assistant",e),...s}),Y=({children:e,className:t,...s})=>o.jsx("div",{className:r.cn("is-user:dark flex w-fit flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",t),...s,children:e});i.createContext(null);const w=i.memo(({className:e,...t})=>o.jsx(T.Streamdown,{className:r.cn("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);w.displayName="MessageResponse";const J=b.Root,X=b.CollapsibleTrigger,H=b.CollapsibleContent,W=({children:e,as:t="p",className:s,duration:n=2,spread:a=2})=>{const l=D.motion.create(t),g=i.useMemo(()=>((e==null?void 0:e.length)??0)*a,[e,a]);return o.jsx(l,{animate:{backgroundPosition:"0% center"},className:r.cn("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",s),initial:{backgroundPosition:"100% center"},style:{"--spread":`${g}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:n,ease:"linear"},children:e})},E=i.memo(W),R=i.createContext(null),Z=()=>{const e=i.useContext(R);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},ee=1e3,te=1e3,y=i.memo(({className:e,isStreaming:t=!1,open:s,defaultOpen:n=!0,onOpenChange:a,duration:l,children:g,...U})=>{const[c,d]=j.useControllableState({prop:s,defaultProp:n,onChange:a}),[M,v]=j.useControllableState({prop:l,defaultProp:void 0}),[N,q]=i.useState(!1),[u,C]=i.useState(null);i.useEffect(()=>{t?u===null&&C(Date.now()):u!==null&&(v(Math.ceil((Date.now()-u)/te)),C(null))},[t,u,v]),i.useEffect(()=>{if(n&&!t&&c&&!N){const x=setTimeout(()=>{d(!1),q(!0)},ee);return()=>clearTimeout(x)}},[t,c,n,d,N]);const O=x=>{d(x)};return o.jsx(R.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:d,duration:M},children:o.jsx(J,{className:r.cn("not-prose mb-4",e),onOpenChange:O,open:c,...U,children:g})})}),oe=(e,t)=>e||t===0?o.jsx(E,{duration:1,children:"Thinking..."}):t===void 0?o.jsx("p",{children:"Thought for a few seconds"}):o.jsxs("p",{children:["Thought for ",t," seconds"]}),A=i.memo(({className:e,children:t,...s})=>{const{isStreaming:n,isOpen:a,duration:l}=Z();return o.jsx(X,{className:r.cn("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...s,children:t??o.jsxs(o.Fragment,{children:[o.jsx(m.BrainIcon,{className:"size-4"}),oe(n,l),o.jsx(m.ChevronDownIcon,{className:r.cn("size-4 transition-transform",a?"rotate-180":"rotate-0")})]})})}),k=i.memo(({className:e,children:t,...s})=>o.jsx(H,{className:r.cn("mt-4 text-sm","text-muted-foreground outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2",e),...s,children:o.jsx(T.Streamdown,{...s,children:t})}));y.displayName="Reasoning";A.displayName="ReasoningTrigger";k.displayName="ReasoningContent";const se=({className:e,content:t,isLoading:s=!1,...n})=>o.jsx("div",{className:r.cn("is-assistant flex w-full max-w-[80%] flex-col gap-2",e),...n,children:o.jsx("div",{className:"flex w-fit flex-col gap-2 overflow-hidden text-sm",children:o.jsx("div",{className:"flex items-center gap-2 rounded-lg border border-muted-foreground/20 bg-muted/50 p-3",children:o.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[s&&o.jsx(E,{duration:1.5,children:t}),!s&&o.jsx("div",{className:"text-xs text-muted-foreground",children:t})]})})})});function ne({userInput:e,language:t="en",currentHtml:s}){const n=f.LANGUAGES[t]||"English";return s&&s.trim().length>0?`
1
+ "use strict";const o=require("react/jsx-runtime"),r=require("./register-chai-top-bar-BqwKw4uy.cjs"),m=require("lucide-react"),i=require("react"),p=require("use-stick-to-bottom"),T=require("streamdown");require("@radix-ui/react-slot");const P=require("class-variance-authority"),_=require("./index-B0e71wJ1.cjs");require("clsx");require("tailwind-merge");const z=require("@radix-ui/react-tooltip"),j=require("@radix-ui/react-use-controllable-state"),B=require("@radix-ui/react-collapsible"),D=require("framer-motion"),f=require("./index-DKuwxj1x.cjs"),I=require("react-i18next");function h(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const L=h(i),S=h(z),b=h(B),G=({className:e,...t})=>o.jsx(p.StickToBottom,{className:r.cn("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),$=({className:e,...t})=>o.jsx(p.StickToBottom.Content,{className:r.cn("flex flex-col gap-8 p-4",e),...t}),F=({className:e,title:t="No messages yet",description:s="Start a conversation to see messages here",icon:n,children:a,...l})=>o.jsx("div",{className:r.cn("flex size-full flex-col items-center justify-center gap-3 p-8 text-center",e),...l,children:a??o.jsxs(o.Fragment,{children:[n&&o.jsx("div",{className:"text-muted-foreground",children:n}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h3",{className:"text-sm font-medium",children:t}),s&&o.jsx("p",{className:"text-sm text-muted-foreground",children:s})]})]})}),Q=({className:e,...t})=>{const{isAtBottom:s,scrollToBottom:n}=p.useStickToBottomContext(),a=i.useCallback(()=>{n()},[n]);return!s&&o.jsx(r.Button,{className:r.cn("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",e),onClick:a,size:"icon",type:"button",variant:"outline",...t,children:o.jsx(m.ArrowDownIcon,{className:"size-4"})})};P.cva("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});const V=L.forwardRef(({className:e,sideOffset:t=4,...s},n)=>o.jsx(S.Content,{ref:n,sideOffset:t,className:r.cn("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",e),...s}));V.displayName=S.Content.displayName;const K=({className:e,from:t,...s})=>o.jsx("div",{className:r.cn("group flex w-full max-w-[80%] flex-col gap-2",t==="user"?"is-user ml-auto justify-end":"is-assistant",e),...s}),Y=({children:e,className:t,...s})=>o.jsx("div",{className:r.cn("is-user:dark flex w-fit flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",t),...s,children:e});i.createContext(null);const w=i.memo(({className:e,...t})=>o.jsx(T.Streamdown,{className:r.cn("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);w.displayName="MessageResponse";const J=b.Root,X=b.CollapsibleTrigger,H=b.CollapsibleContent,W=({children:e,as:t="p",className:s,duration:n=2,spread:a=2})=>{const l=D.motion.create(t),g=i.useMemo(()=>((e==null?void 0:e.length)??0)*a,[e,a]);return o.jsx(l,{animate:{backgroundPosition:"0% center"},className:r.cn("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",s),initial:{backgroundPosition:"100% center"},style:{"--spread":`${g}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:n,ease:"linear"},children:e})},E=i.memo(W),R=i.createContext(null),Z=()=>{const e=i.useContext(R);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},ee=1e3,te=1e3,y=i.memo(({className:e,isStreaming:t=!1,open:s,defaultOpen:n=!0,onOpenChange:a,duration:l,children:g,...U})=>{const[c,d]=j.useControllableState({prop:s,defaultProp:n,onChange:a}),[M,v]=j.useControllableState({prop:l,defaultProp:void 0}),[N,q]=i.useState(!1),[u,C]=i.useState(null);i.useEffect(()=>{t?u===null&&C(Date.now()):u!==null&&(v(Math.ceil((Date.now()-u)/te)),C(null))},[t,u,v]),i.useEffect(()=>{if(n&&!t&&c&&!N){const x=setTimeout(()=>{d(!1),q(!0)},ee);return()=>clearTimeout(x)}},[t,c,n,d,N]);const O=x=>{d(x)};return o.jsx(R.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:d,duration:M},children:o.jsx(J,{className:r.cn("not-prose mb-4",e),onOpenChange:O,open:c,...U,children:g})})}),oe=(e,t)=>e||t===0?o.jsx(E,{duration:1,children:"Thinking..."}):t===void 0?o.jsx("p",{children:"Thought for a few seconds"}):o.jsxs("p",{children:["Thought for ",t," seconds"]}),A=i.memo(({className:e,children:t,...s})=>{const{isStreaming:n,isOpen:a,duration:l}=Z();return o.jsx(X,{className:r.cn("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...s,children:t??o.jsxs(o.Fragment,{children:[o.jsx(m.BrainIcon,{className:"size-4"}),oe(n,l),o.jsx(m.ChevronDownIcon,{className:r.cn("size-4 transition-transform",a?"rotate-180":"rotate-0")})]})})}),k=i.memo(({className:e,children:t,...s})=>o.jsx(H,{className:r.cn("mt-4 text-sm","text-muted-foreground outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2",e),...s,children:o.jsx(T.Streamdown,{...s,children:t})}));y.displayName="Reasoning";A.displayName="ReasoningTrigger";k.displayName="ReasoningContent";const se=({className:e,content:t,isLoading:s=!1,...n})=>o.jsx("div",{className:r.cn("is-assistant flex w-full max-w-[80%] flex-col gap-2",e),...n,children:o.jsx("div",{className:"flex w-fit flex-col gap-2 overflow-hidden text-sm",children:o.jsx("div",{className:"flex items-center gap-2 rounded-lg border border-muted-foreground/20 bg-muted/50 p-3",children:o.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[s&&o.jsx(E,{duration:1.5,children:t}),!s&&o.jsx("div",{className:"text-xs text-muted-foreground",children:t})]})})})});function ne({userInput:e,language:t="en",currentHtml:s}){const n=f.LANGUAGES[t]||"English";return s&&s.trim().length>0?`
2
2
  MODE: EDIT
3
3
  CURRENT HTML:
4
4
  ${s}
@@ -7,14 +7,14 @@ import { StickToBottom as R, useStickToBottomContext as Q } from "use-stick-to-b
7
7
  import { Streamdown as y } from "streamdown";
8
8
  import "@radix-ui/react-slot";
9
9
  import { cva as F } from "class-variance-authority";
10
- import { ao as K } from "./index-rAcNbjk_.js";
10
+ import { ao as K } from "./index-CAhEmHYP.js";
11
11
  import "clsx";
12
12
  import "tailwind-merge";
13
13
  import * as A from "@radix-ui/react-tooltip";
14
14
  import { useControllableState as w } from "@radix-ui/react-use-controllable-state";
15
15
  import * as x from "@radix-ui/react-collapsible";
16
16
  import { motion as V } from "framer-motion";
17
- import { L as h } from "./index-Dno42B0a.js";
17
+ import { L as h } from "./index-Bn0fFN58.js";
18
18
  import { useTranslation as Y } from "react-i18next";
19
19
  const Te = ({ className: e, ...t }) => /* @__PURE__ */ o(
20
20
  R,
@@ -1,6 +1,6 @@
1
1
  import { jsx as t, jsxs as o } from "react/jsx-runtime";
2
- import { l as ve, as as xe, ar as Ne, A as we, L as ee, aw as Se, aK as De, aL as Oe, i as be, ay as je, aM as Le, aN as Ie, aO as T, aP as Ee, aE as te } from "./index-Dno42B0a.js";
3
- import { n as z, D as ke, d as Te, e as Ce, f as Fe, p as Je, o as Ae, ai as Pe, as as Re, at as Be, au as $, L as S, T as se } from "./index-rAcNbjk_.js";
2
+ import { l as ve, as as xe, ar as Ne, A as we, L as ee, aw as Se, aK as De, aL as Oe, i as be, ay as je, aM as Le, aN as Ie, aO as T, aP as Ee, aE as te } from "./index-Bn0fFN58.js";
3
+ import { n as z, D as ke, d as Te, e as Ce, f as Fe, p as Je, o as Ae, ai as Pe, as as Re, at as Be, au as $, L as S, T as se } from "./index-CAhEmHYP.js";
4
4
  import { find as qe, get as g, isEqual as ne, isEmpty as Ue } from "lodash-es";
5
5
  import { useMemo as _e, useRef as ae, useState as J, useEffect as oe } from "react";
6
6
  import { B as R, D as Ve, F as Ge, z as A } from "./register-chai-top-bar-ESJHs5s-.js";
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-C0-pgg_p.cjs"),r=require("./index-C99FhuF1.cjs"),u=require("lodash-es"),w=require("react"),f=require("./register-chai-top-bar-BqwKw4uy.cjs"),ie=require("react-i18next"),O=require("sonner"),de=require("@tanstack/react-query"),K=require("lucide-react"),G=require("./get-seo-defaults-Cw7vFt-B.cjs"),ue=()=>{const{selectedLang:t}=r.useLanguages(),{data:p,isFetching:n}=i.useLanguagePages();return{data:w.useMemo(()=>u.find(p,{lang:t||""})||{},[p,t]),isFetching:n}},pe=()=>{var x;const p=(x=document.getElementById("canvas-iframe").contentDocument)==null?void 0:x.body.innerHTML;if(!p)return null;const d=new DOMParser().parseFromString(p,"text/html");d.querySelectorAll("style, script, link, svg, [data-block-type='PartialBlock']").forEach(h=>h.remove()),d.querySelectorAll("*").forEach(h=>{Array.from(h.attributes).forEach(g=>h.removeAttribute(g.name))});const l=d.querySelectorAll("h1, h2, h3, h4, h5, h6, p");return Array.from(l).map(h=>`<${h.tagName.toLowerCase()}>${h.innerHTML}</${h.tagName.toLowerCase()}>`).join(" ").replace(/<p>Partial block. Double click to edit.<\/p>/,"")},R=({keyword:t,onComplete:p,field:n})=>{const d=i.useFetch(),l=i.useApiUrl(),{selectedLang:N,fallbackLang:x}=r.useLanguages(),{mutate:h,isPending:g}=de.useMutation({mutationFn:async()=>{const I=pe();return await d(l,{action:i.ACTIONS.GENERATE_SEO_FIELD,data:{pageContext:"",dynamic:!1,field:n,lang:N||x,pageContent:I,keyword:t}})},onSuccess:I=>{p({fieldValue:I.field})},onError:I=>{p({fieldValue:null,error:I.message})}});return e.jsx(f.Button,{disabled:g,type:"button",className:"h-5 w-5",variant:"ghost",size:"sm",onClick:()=>h(),children:g?e.jsx(K.Loader,{className:"h-3 w-3 animate-spin text-yellow-500"}):e.jsx(K.Wand2Icon,{className:"text-yellow-500"})})},he=(t,p)=>{if(!t)return{success:!1,error:"Empty response from AI"};try{let n=t;if(typeof n=="string"&&(/^".*"$/.test(n)&&(n=n.replace(/^"(.*)"$/,"$1"),n=n.replace(/\\\\/g,"___DOUBLE_BACKSLASH___").replace(/\\n/g,`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-DKuwxj1x.cjs"),r=require("./index-B0e71wJ1.cjs"),u=require("lodash-es"),w=require("react"),f=require("./register-chai-top-bar-BqwKw4uy.cjs"),ie=require("react-i18next"),O=require("sonner"),de=require("@tanstack/react-query"),K=require("lucide-react"),G=require("./get-seo-defaults-Cw7vFt-B.cjs"),ue=()=>{const{selectedLang:t}=r.useLanguages(),{data:p,isFetching:n}=i.useLanguagePages();return{data:w.useMemo(()=>u.find(p,{lang:t||""})||{},[p,t]),isFetching:n}},pe=()=>{var x;const p=(x=document.getElementById("canvas-iframe").contentDocument)==null?void 0:x.body.innerHTML;if(!p)return null;const d=new DOMParser().parseFromString(p,"text/html");d.querySelectorAll("style, script, link, svg, [data-block-type='PartialBlock']").forEach(h=>h.remove()),d.querySelectorAll("*").forEach(h=>{Array.from(h.attributes).forEach(g=>h.removeAttribute(g.name))});const l=d.querySelectorAll("h1, h2, h3, h4, h5, h6, p");return Array.from(l).map(h=>`<${h.tagName.toLowerCase()}>${h.innerHTML}</${h.tagName.toLowerCase()}>`).join(" ").replace(/<p>Partial block. Double click to edit.<\/p>/,"")},R=({keyword:t,onComplete:p,field:n})=>{const d=i.useFetch(),l=i.useApiUrl(),{selectedLang:N,fallbackLang:x}=r.useLanguages(),{mutate:h,isPending:g}=de.useMutation({mutationFn:async()=>{const I=pe();return await d(l,{action:i.ACTIONS.GENERATE_SEO_FIELD,data:{pageContext:"",dynamic:!1,field:n,lang:N||x,pageContent:I,keyword:t}})},onSuccess:I=>{p({fieldValue:I.field})},onError:I=>{p({fieldValue:null,error:I.message})}});return e.jsx(f.Button,{disabled:g,type:"button",className:"h-5 w-5",variant:"ghost",size:"sm",onClick:()=>h(),children:g?e.jsx(K.Loader,{className:"h-3 w-3 animate-spin text-yellow-500"}):e.jsx(K.Wand2Icon,{className:"text-yellow-500"})})},he=(t,p)=>{if(!t)return{success:!1,error:"Empty response from AI"};try{let n=t;if(typeof n=="string"&&(/^".*"$/.test(n)&&(n=n.replace(/^"(.*)"$/,"$1"),n=n.replace(/\\\\/g,"___DOUBLE_BACKSLASH___").replace(/\\n/g,`
2
2
  `).replace(/\\"/g,'"').replace(/___DOUBLE_BACKSLASH___/g,"\\")),p==="jsonLD"||p==="metaOther")){n.includes("```")&&(n=n.replace(/^```json\s*/i,"").replace(/^```\s*/,"").replace(/\s*```$/m,"")),n=n.trim();try{JSON.parse(n)}catch{return{success:!1,error:"The AI response is not valid JSON. Please try again or edit manually."}}}return{success:!0,value:n}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}}},ge=({isOpen:t,onClose:p,onSave:n,onDiscard:d,isSaving:l=!1,fromLanguage:N,toLanguage:x})=>{const h=i.LANGUAGES[N]||N,g=i.LANGUAGES[x]||x;return e.jsx(r.Dialog,{open:t,onOpenChange:p,children:e.jsxs(r.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(r.DialogHeader,{children:[e.jsx(r.DialogTitle,{children:"Unsaved SEO Changes"}),e.jsxs(r.DialogDescription,{children:['You have unsaved changes in the SEO for "',h,'" version. Do you want to save these changes before switching to "',g,'" version?']})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(f.Button,{variant:"outline",onClick:d,disabled:l,children:"Discard Changes"}),e.jsx(f.Button,{onClick:n,disabled:l,children:l?"Saving...":"Save & Switch"})]})]})})},me=t=>{if(!t)return!0;try{return JSON.parse(t),!0}catch{return!1}},xe=(t,p)=>{const n=t.selectionStart||0,d=t.selectionEnd||0,l=t.value,N=l.substring(0,n),x=l.substring(d),h=`{{${p}}}`,g=N+""+h+x,I=n+0+h.length;return{value:g,newCursorPos:I}},Q=()=>{const{t}=ie.useTranslation(),[,p]=r.useSidebarActivePanel(),{data:n}=i.useChaiCurrentPage(),{data:d}=i.useBuilderPageData(),{data:l,isFetching:N}=ue(),x=l==null?void 0:l.seo,h=w.useRef(null),[g,I]=w.useState("seo"),F=n==null?void 0:n.id,Y=n==null?void 0:n.pageType,E=i.usePageType(Y),{selectedLang:M,fallbackLang:X}=r.useLanguages(),m=M||X,[H,P]=w.useState(!1),[Z,$]=w.useState(!1),[ee,q]=w.useState(!1),[b,B]=w.useState(null),[o,D]=w.useState({keyword:"",title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",ogImageId:"",searchTitle:"",searchDescription:"",jsonLD:"{}",metaOther:"{}",...x}),A=w.useRef({}),{mutate:se,isPending:U}=i.useUpdatePage(),y=U||H||Z,{hasPermission:te}=r.usePermissions(),a=te(i.PAGES_PERMISSIONS.EDIT_SEO),[ne]=i.usePagesProps(),oe=u.get(ne,"features.canResetSeoToDefault",!1),W=!M||o.jsonLD!=="{}";w.useEffect(()=>{if(!N&&x&&F){const s={keyword:"",title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",ogImageId:"",searchTitle:"",searchDescription:"",jsonLD:"",metaOther:"",...x};D(s),A.current[m]=s}},[N,x,m,F]),w.useEffect(()=>{const s=c=>{const{fromLang:j,toLang:J,switchHandler:v}=c.detail,_=A.current[m];(_?!u.isEqual(_,o):!1)?(B({fromLang:j,toLang:J,switchHandler:v}),q(!0)):v()};return window.addEventListener("seo-language-switch-check",s),()=>{window.removeEventListener("seo-language-switch-check",s)}},[F,o,m]);const ae=async()=>{if(!(!E||!m))try{P(!0);const s=G.getSeoDefaults(E,m),c={...o,keyword:u.get(s,"seo.keyword",""),title:u.get(s,"seo.title",""),description:u.get(s,"seo.description",""),cononicalUrl:u.get(s,"seo.canonicalUrl",""),noIndex:u.get(s,"seo.noIndex",!1),noFollow:u.get(s,"seo.noFollow",!1),ogTitle:u.get(s,"seo.ogTitle",""),ogDescription:u.get(s,"seo.ogDescription","")};D(c),O.toast.success(t("SEO fields reset to defaults"))}catch(s){O.toast.error(t("Failed to reset SEO fields")),console.error("Reset SEO error:",s)}finally{P(!1)}},re=async()=>{if(!(!E||!m))try{$(!0);const s=G.getSeoDefaults(E,m),c={...o,jsonLD:u.get(s,"seo.jsonLD","")};D(c),O.toast.success(t("JSON-LD reset to default"))}catch(s){O.toast.error(t("Failed to reset JSON-LD")),console.error("Reset JSON-LD error:",s)}finally{$(!1)}},le=async()=>{if(!(!E||!m))try{P(!0);const s=G.getSeoDefaults(E,m),c={...o,ogTitle:u.get(s,"seo.ogTitle",""),ogDescription:u.get(s,"seo.ogDescription",""),ogImage:u.get(s,"seo.ogImage",""),ogImageId:u.get(s,"seo.ogImageId",""),metaOther:u.get(s,"seo.metaOther","{}")};D(c),O.toast.success(t("Meta Tag fields reset to defaults"))}catch(s){O.toast.error(t("Failed to reset Meta Tag fields")),console.error("Reset Meta Tag error:",s)}finally{P(!1)}},z=async()=>{se({id:l==null?void 0:l.id,seo:o,primaryPage:F},{onSuccess:()=>{console.log("SEO & JSON-LD updated successfully",o),A.current[m]=o,O.toast.success("SEO & JSON-LD updated successfully")}})},L=(s,c)=>{const j=document.getElementById(c);if(j){const{value:J,newCursorPos:v}=xe(j,s);h.current={id:c,position:v},j.tagName.toLowerCase()==="input"?(j.value=J,D(k=>({...k,[j.name]:J})),j.focus(),j.setSelectionRange(v,v),[0,10,50,100,200].forEach(k=>{setTimeout(()=>{const V=document.getElementById(c);V&&(V.focus(),V.setSelectionRange(v,v))},k)})):(D(T=>({...T,[j.name]:J})),requestAnimationFrame(()=>{const T=document.getElementById(c);T&&(T.focus(),T.setSelectionRange(v,v),setTimeout(()=>{const k=document.getElementById(c);k&&(k.focus(),k.setSelectionRange(v,v))},50))}))}},S=s=>{const c={...o,[s.target.name]:s.target.name==="noIndex"||s.target.name==="noFollow"?s.target.checked:s.target.value};D(c)},C=s=>c=>{if(!u.isEmpty(c.fieldValue)){const j=he(c.fieldValue,s);j.success?S({target:{name:s,value:j.value}}):O.toast.error(e.jsxs("div",{children:[e.jsx("h2",{children:"Failed to process AI response:"}),e.jsx("p",{children:j.error})]}))}c.error&&O.toast.error(e.jsxs("div",{children:[e.jsx("h2",{children:"Failed to generate:"}),e.jsx("p",{children:c.error})]}))},ce=()=>{const s=u.get(n,"seo.jsonLD","{}");if((s==null?void 0:s.trim())==="{}"){O.toast.error("Default page JSON-LD is empty");return}S({target:{name:"jsonLD",value:s}})};return e.jsxs("div",{className:"relative flex h-full flex-col","data-panel-id":"seo",children:[!a&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center backdrop-blur-sm",children:e.jsx(f.Alert,{variant:"default",className:"w-[80%] max-w-md text-xs",children:e.jsx(f.AlertDescription,{children:t("You don't have permission to edit SEO settings. Contact your administrator for access.")})})}),e.jsxs("div",{className:"no-scrollbar flex-grow overflow-y-auto px-2 pb-20",children:[e.jsxs("div",{className:"mb-4 flex w-full items-center justify-between rounded-md bg-gray-100 px-2 py-1 text-left text-sm",children:[e.jsxs("span",{children:[e.jsx("div",{className:"font-medium",children:l==null?void 0:l.name}),e.jsx("span",{className:"font-mono text-xs leading-tight text-gray-500",children:l==null?void 0:l.slug})]}),e.jsx(i.LanguageSwitcher,{variant:"outline",showAdd:!1})]}),e.jsx("form",{className:"space-y-8",children:e.jsxs(r.Tabs,{value:g,onValueChange:I,className:"w-full",children:[e.jsxs(r.TabsList,{className:"mb-4 grid w-full grid-cols-3",children:[e.jsx(r.TabsTrigger,{value:"seo",children:t("SEO")}),e.jsx(r.TabsTrigger,{value:"opengraph",children:t("Meta Tags")}),e.jsx(r.TabsTrigger,{value:"jsonld",children:t("JSON-LD")})]}),e.jsx("div",{className:g==="seo"?"":"sr-only",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"keyword",children:t("Keyword")}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>L(s,"keyword")})]}),e.jsx(f.Input,{type:"text",id:"keyword",name:"keyword",value:o.keyword,onChange:S,disabled:y||!a,placeholder:t("Enter keyword"),readOnly:!a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"title",children:t("SEO Title")}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(R,{keyword:o.keyword,onComplete:C("title"),field:"title"}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>L(s,"title")})]})]}),e.jsx(f.Input,{type:"text",id:"title",name:"title",value:o.title,onChange:S,disabled:y||!a,placeholder:t("Enter SEO title"),readOnly:!a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"description",children:t("SEO Description")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{keyword:o.keyword,onComplete:C("description"),field:"description"}),a&&e.jsx(i.NestedPathSelector,{data:d??{},onSelect:s=>L(s,"description")})]})]}),e.jsx(r.Textarea,{id:"description",name:"description",rows:5,value:o.description,onChange:S,disabled:y||!a,placeholder:t("Enter SEO description"),readOnly:!a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"title",children:t("Canonical URL")}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>L(s,"canonicalUrl")})]}),e.jsx(f.Input,{type:"text",id:"canonicalUrl",name:"canonicalUrl",value:o.canonicalUrl,onChange:S,disabled:y||!a,placeholder:t("Enter Canonical URL"),readOnly:!a})]}),e.jsxs("div",{className:"",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(f.Input,{type:"checkbox",id:"noIndex",name:"noIndex",checked:o.noIndex,onChange:S,disabled:y||!a,className:"h-4 w-4"}),e.jsx(r.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:t("No Index")})]}),e.jsx("p",{className:"mt-0 text-[10px] font-light leading-4 text-gray-400",children:t("Check this if you don't want search engines to index this page.")})]}),e.jsxs("div",{className:"",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(f.Input,{type:"checkbox",id:"noFollow",name:"noFollow",checked:o.noFollow,onChange:S,disabled:y||!a,className:"h-4 w-4"}),e.jsx(r.Label,{className:"pb-1 text-xs",htmlFor:"noIndex",children:t("No Follow")})]}),e.jsx("p",{className:"text-[10px] font-light leading-4 text-gray-400",children:t("Check this if you don't want search engines to follow links on this page.")})]})]})}),e.jsx("div",{className:g==="opengraph"?"":"sr-only",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"mb-4 font-semibold text-slate-700",children:t("Open Graph")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"ogTitle",children:t("OG Title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{keyword:o.keyword,onComplete:C("ogTitle"),field:"ogTitle"}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>L(s,"ogTitle")})]})]}),e.jsx(f.Input,{type:"text",id:"ogTitle",name:"ogTitle",value:o.ogTitle,onChange:S,disabled:y||!a,placeholder:t("Enter OG title"),readOnly:!a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"ogDescription",children:t("OG Description")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{keyword:o.keyword,onComplete:C("ogDescription"),field:"ogDescription"}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>L(s,"ogDescription")})]})]}),e.jsx(r.Textarea,{id:"ogDescription",name:"ogDescription",rows:5,value:o.ogDescription,onChange:S,disabled:y||!a,placeholder:t("Enter OG description"),readOnly:!a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"ogImage",children:t("OG Image")}),a&&e.jsx(i.NestedPathSelector,{dataType:"value",data:d??{},onSelect:s=>{D({...o,ogImage:`{{${s}}}`,ogImageId:""})}})]}),e.jsx(i.ImagePicker,{assetId:o.ogImageId,assetUrl:o.ogImage,onChange:s=>{D({...o,ogImage:s.url,ogImageId:s.id})},disabled:y||!a,placeholder:t("Select OG image"),className:"mb-2"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"metaOther",children:t("Meta Tags")}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{keyword:o.keyword,onComplete:C("metaOther"),field:"metaOther"})})]}),e.jsx(i.SmartJsonInput,{id:"metaOther",value:o.metaOther,onChange:s=>{S({target:{name:"metaOther",value:s}})},placeholder:t("Enter Meta Tags JSON"),disabled:y||!a,readOnly:!a,pageData:d||{},rows:8,handleFieldInsert:L})]})]})]})})}),e.jsx("div",{className:g==="jsonld"?"":"sr-only",children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r.Label,{className:"text-xs",htmlFor:"jsonLD",children:t("JSON-LD")}),W&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{keyword:o.keyword,onComplete:C("jsonLD"),field:"jsonLD"})})]}),e.jsx("div",{className:"hidden",children:JSON.stringify(d)}),e.jsx(i.SmartJsonInput,{id:"jsonLD",value:o.jsonLD,onChange:s=>{S({target:{name:"jsonLD",value:s}})},placeholder:t("Enter JSON-LD"),disabled:y||!a,readOnly:!a,pageData:d||{},rows:12,handleFieldInsert:L,hasJsonLdForSelectedLang:W,copyJsonLDFromDefaultPage:ce})]})})})]})})]}),a&&e.jsxs("div",{className:"fixed bottom-0 left-0 right-0 flex w-full flex-shrink-0 items-center justify-between border-t bg-background p-4",children:[oe?e.jsx(f.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>{g==="jsonld"?re():g==="opengraph"?le():ae()},disabled:y||!a||!E,children:t(H?"Resetting...":`Reset to ${g==="jsonld"?"Default JSON-LD":g==="opengraph"?"Default Open Graph":"Default SEO"}`)}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(f.Button,{onClick:z,disabled:!me(o==null?void 0:o.jsonLD)||(A.current[m]?u.isEqual(A.current[m],o):!1)||y||!a,children:t(U?"Saving...":"Save")}),e.jsx(f.Button,{variant:"link",className:"text-gray-500 hover:text-gray-700",onClick:()=>p("outline"),children:t("Cancel")})]})]}),e.jsx(ge,{isOpen:ee,onClose:()=>{q(!1),B(null)},onSave:async()=>{b&&(await z(),b.switchHandler(),q(!1),B(null))},onDiscard:()=>{if(b){const s=A.current[m];s&&D(s),b.switchHandler(),q(!1),B(null)}},isSaving:U,fromLanguage:(b==null?void 0:b.fromLang)||m,toLanguage:(b==null?void 0:b.toLang)||""})]})};Q.displayName="SeoPanel";exports.default=Q;
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as n, Fragment as G } from "react/jsx-runtime";
2
- import { D as W, d as $, e as Y, f as X, L as y, E as U, G as R, H as _, I as M, J as H, K as q, M as V, O as K, n as me, w as L, x as F, y as J, a2 as he, R as ue, U as ge, V as fe, F as pe, W as xe, T as Ne } from "./index-rAcNbjk_.js";
2
+ import { D as W, d as $, e as Y, f as X, L as y, E as U, G as R, H as _, I as M, J as H, K as q, M as V, O as K, n as me, w as L, x as F, y as J, a2 as he, R as ue, U as ge, V as fe, F as pe, W as xe, T as Ne } from "./index-CAhEmHYP.js";
3
3
  import { D as be, F as ye, z as j, B as v } from "./register-chai-top-bar-ESJHs5s-.js";
4
- import { ar as ve, as as we, A as Q, aw as te, aC as Ce, aD as se, aE as re, aF as de, aG as Ae, aH as Se, aI as Pe, l as Te, aJ as De } from "./index-Dno42B0a.js";
4
+ import { ar as ve, as as we, A as Q, aw as te, aC as Ce, aD as se, aE as re, aF as de, aG as Ae, aH as Se, aI as Pe, l as Te, aJ as De } from "./index-Bn0fFN58.js";
5
5
  import { useQuery as Ee, useQueryClient as Le } from "@tanstack/react-query";
6
6
  import { filter as Fe, find as Je } from "lodash-es";
7
7
  import { Info as Oe, Loader as O, Plus as ke, Eye as Ge, Edit as je, Trash as Be } from "lucide-react";