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

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 (184) hide show
  1. package/README.md +27 -20
  2. package/dist/2SSKDMRQ-BnsZi3K3.cjs +1 -0
  3. package/dist/2SSKDMRQ-CnSDkQcy.js +42 -0
  4. package/dist/AP7HFJJL-B31839PG.cjs +1228 -0
  5. package/dist/AP7HFJJL-CymCmW14.js +9214 -0
  6. package/dist/IconPicker-B1rWC-Ex.js +59 -0
  7. package/dist/IconPicker-DREyo007.cjs +1 -0
  8. package/dist/WDYDFRGG-BUVnbAci.js +33 -0
  9. package/dist/WDYDFRGG-BxhOCHc3.cjs +1 -0
  10. package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
  11. package/dist/_commonjsHelpers-DwGv2jUC.cjs +1 -0
  12. package/dist/actions-registery-CZ1w0NKa.js +15545 -0
  13. package/dist/actions-registery-YnFmU21O.cjs +418 -0
  14. package/dist/actions.cjs +1 -0
  15. package/dist/actions.d.ts +3202 -0
  16. package/dist/actions.js +216 -0
  17. package/dist/active-in-another-tab-B47YjQGN.cjs +1 -0
  18. package/dist/active-in-another-tab-CyjngVA6.js +34 -0
  19. package/dist/add-new-language-page-88xzrUy8.cjs +1 -0
  20. package/dist/add-new-language-page-WmlCnytQ.js +401 -0
  21. package/dist/add-new-page-VW2wAYZp.js +31 -0
  22. package/dist/add-new-page-soZ8GAkN.cjs +1 -0
  23. package/dist/ai-panel-content-7zCil042.cjs +1 -0
  24. package/dist/ai-panel-content-D_o7Q_A-.js +61 -0
  25. package/dist/ai-panel-default-lang-COYaxNwn.cjs +3 -0
  26. package/dist/ai-panel-default-lang-DnElspF0.js +341 -0
  27. package/dist/ai-panel-other-lang-CkynNlAU.cjs +1 -0
  28. package/dist/ai-panel-other-lang-Dp0E9_Hx.js +162 -0
  29. package/dist/ai-prompt-input-Bhc0ds7X.js +655 -0
  30. package/dist/ai-prompt-input-CThbVp0_.cjs +1 -0
  31. package/dist/ai-translation-prompt-C2kJQFDX.cjs +1 -0
  32. package/dist/ai-translation-prompt-CZ55HQmo.js +28 -0
  33. package/dist/apply-binding-6iwlED02.js +833 -0
  34. package/dist/apply-binding-KKp5PnpZ.cjs +1 -0
  35. package/dist/code-display-BnqzqzoP.cjs +1 -0
  36. package/dist/{code-display-337R7Dev.js → code-display-DhD_RBcg.js} +1 -1
  37. package/dist/code-editor-DRIAnNbb.js +50 -0
  38. package/dist/code-editor-o3___nu2.cjs +1 -0
  39. package/dist/common-functions-B3a4xKt_.cjs +1 -0
  40. package/dist/common-functions-D2lMFR6K.js +13 -0
  41. package/dist/continue-editing-in-this-client-CS2aQ7yY.js +24 -0
  42. package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +1 -0
  43. package/dist/core-BoRDjj4h.cjs +1 -0
  44. package/dist/core-yvI6kCyw.js +56 -0
  45. package/dist/core.cjs +1 -1
  46. package/dist/core.d.ts +51 -383
  47. package/dist/core.js +39 -106
  48. package/dist/{css-import-modal-DA2L6kwP.js → css-import-modal-Byg6wV0O.js} +36 -36
  49. package/dist/css-import-modal-CyqkXWCO.cjs +13 -0
  50. package/dist/delete-design-token-BRZZiWtQ.js +40 -0
  51. package/dist/delete-design-token-DkVs1oBf.cjs +1 -0
  52. package/dist/delete-page-BzyX9TN-.js +70 -0
  53. package/dist/delete-page-DxX7PFIE.cjs +1 -0
  54. package/dist/design-token-usage-CAHzEGgJ.cjs +1 -0
  55. package/dist/design-token-usage-xQs6SlaJ.js +113 -0
  56. package/dist/digital-asset-manager--uO8Agia.cjs +1 -0
  57. package/dist/digital-asset-manager-DbtwzxRz.js +876 -0
  58. package/dist/duplicate-page-BR7Dlo9d.js +133 -0
  59. package/dist/duplicate-page-CaNAbXwV.cjs +1 -0
  60. package/dist/dynamic-page-selector-Cb5r_W8s.js +85 -0
  61. package/dist/dynamic-page-selector-Cxk_gjni.cjs +1 -0
  62. package/dist/fonts-B-Xt29pe.cjs +1 -0
  63. package/dist/fonts-DRly3Wzd.js +78 -0
  64. package/dist/{get-chai-builder-tailwind-config-C6MHaUM0.cjs → get-chai-builder-tailwind-config-B9rCyiQo.cjs} +1 -1
  65. package/dist/{get-chai-builder-tailwind-config-BqaIvg8p.js → get-chai-builder-tailwind-config-DjoVOuAf.js} +13 -10
  66. package/dist/{get-chai-builder-theme-D0IsUvK4.js → get-chai-builder-theme-BYtp20KD.js} +4 -4
  67. package/dist/get-chai-builder-theme-Dl72X7cz.cjs +1 -0
  68. package/dist/get-seo-defaults-9zHebckY.js +65 -0
  69. package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
  70. package/dist/image-compression-DZ9WMmyn.cjs +1 -0
  71. package/dist/image-compression-DsZ1oqpb.js +37 -0
  72. package/dist/image-editor-DV8kUKhl.js +108 -0
  73. package/dist/image-editor-G-K28aTS.cjs +1 -0
  74. package/dist/index-B-rSiAp_.cjs +1 -0
  75. package/dist/index-Ct7ElCGK.js +19069 -0
  76. package/dist/index-DF5DEvqb.cjs +160 -0
  77. package/dist/index-Dxfyt4d4.js +39 -0
  78. package/dist/index-WQwzsC7A.cjs +5 -0
  79. package/dist/index-ZuacEL1j.js +4732 -0
  80. package/dist/json-diff-viewer-D7z4zNvv.cjs +8 -0
  81. package/dist/json-diff-viewer-krslPepD.js +258 -0
  82. package/dist/lang-panel-BwIewMyw.js +215 -0
  83. package/dist/lang-panel-DT96k1xg.cjs +1 -0
  84. package/dist/manage-design-tokens-Caz_20VK.js +240 -0
  85. package/dist/manage-design-tokens-CrmLe7UT.cjs +1 -0
  86. package/dist/mark-as-template-D295ZQtU.js +156 -0
  87. package/dist/mark-as-template-W3LmpiqN.cjs +1 -0
  88. package/dist/models-5gOsRC56.cjs +1 -0
  89. package/dist/models-D95ZYr_x.js +70 -0
  90. package/dist/nested-path-selector-content-CKYYK-C5.js +87 -0
  91. package/dist/nested-path-selector-content-CoS_d3dc.cjs +1 -0
  92. package/dist/no-language-page-content-BvqRBP6y.js +42 -0
  93. package/dist/no-language-page-content-DkfeMl90.cjs +1 -0
  94. package/dist/no-language-page-dialog-BcEoqyQB.cjs +1 -0
  95. package/dist/no-language-page-dialog-PjNqTUpl.js +10 -0
  96. package/dist/page-creator-C4gc5NSC.cjs +1 -0
  97. package/dist/page-creator-DiOITEMw.js +795 -0
  98. package/dist/page-lock-BdYmCks0.cjs +1 -0
  99. package/dist/page-lock-Bfbs6RgL.js +30 -0
  100. package/dist/page-locked-dialog-B1FAtK92.cjs +1 -0
  101. package/dist/page-locked-dialog-B6MKTRfY.js +133 -0
  102. package/dist/page-manager-new-CHDueBDk.cjs +1 -0
  103. package/dist/page-manager-new-CzX22g2n.js +394 -0
  104. package/dist/page-manager-search-and-filter-CM0UMb6U.js +201 -0
  105. package/dist/page-manager-search-and-filter-DkkRIH86.cjs +1 -0
  106. package/dist/page-revisions-content-ChY-4f2V.cjs +1 -0
  107. package/dist/page-revisions-content-NH9JK4Ey.js +445 -0
  108. package/dist/pages.cjs +1 -0
  109. package/dist/pages.d.ts +491 -0
  110. package/dist/pages.js +27 -0
  111. package/dist/plugin-3ZKK6RXm.js +245 -0
  112. package/dist/plugin-C6rgJDNQ.cjs +22 -0
  113. package/dist/publish-pages-content-D9aixMN5.js +178 -0
  114. package/dist/publish-pages-content-x-JuSFJ9.cjs +1 -0
  115. package/dist/register-partial-type-BjtdfKHE.js +36 -0
  116. package/dist/register-partial-type-ig9fUWIJ.cjs +1 -0
  117. package/dist/render.cjs +2 -2
  118. package/dist/render.d.ts +26 -13
  119. package/dist/render.js +130 -124
  120. package/dist/rte-widget-modal-BaHIuEjF.cjs +1 -0
  121. package/dist/rte-widget-modal-DOJEXLIf.js +38 -0
  122. package/dist/runtime.cjs +1 -1
  123. package/dist/runtime.d.ts +306 -7
  124. package/dist/runtime.js +44 -1
  125. package/dist/save-to-lib-Cgpxw8-g.cjs +1 -0
  126. package/dist/save-to-lib-eiOc_SSN.js +422 -0
  127. package/dist/sdk.css +1 -1
  128. package/dist/selected-block-display-BgRY82CT.cjs +16 -0
  129. package/dist/selected-block-display-CBFePS19.js +319 -0
  130. package/dist/seo-panel-C1-iMOR1.js +798 -0
  131. package/dist/seo-panel-DfAb8U7W.cjs +2 -0
  132. package/dist/shared-json-ld-B4PxAM_0.js +565 -0
  133. package/dist/shared-json-ld-DzG398hr.cjs +1 -0
  134. package/dist/slug-input-AwNJs9im.js +86 -0
  135. package/dist/slug-input-C_ijLQ_X.cjs +1 -0
  136. package/dist/supabase-actions.cjs +1 -0
  137. package/dist/supabase-actions.d.ts +284 -0
  138. package/dist/supabase-actions.js +524 -0
  139. package/dist/take-over-request-BNxcjY2j.cjs +1 -0
  140. package/dist/take-over-request-C4FeDtN_.js +63 -0
  141. package/dist/theme-panel-footer-Cq9pljro.cjs +1 -0
  142. package/dist/theme-panel-footer-uBQqSJXm.js +25 -0
  143. package/dist/translation-warning-modal-B64YqlbI.js +26 -0
  144. package/dist/translation-warning-modal-BZAcwM2_.cjs +1 -0
  145. package/dist/unmark-as-template-CZ9sQp_P.js +39 -0
  146. package/dist/unmark-as-template-EVvk0vmp.cjs +1 -0
  147. package/dist/unpublish-page-D4VwOlxc.js +27 -0
  148. package/dist/unpublish-page-bdSmwAVQ.cjs +1 -0
  149. package/dist/use-page-expand-manager-B6XTvk0E.cjs +1 -0
  150. package/dist/use-page-expand-manager-Cf4MUEJw.js +85 -0
  151. package/dist/{tailwind.cjs → utils.cjs} +1 -1
  152. package/dist/{tailwind.d.ts → utils.d.ts} +12 -11
  153. package/dist/utils.js +7 -0
  154. package/dist/web-blocks.cjs +1 -1
  155. package/dist/web-blocks.d.ts +0 -6
  156. package/dist/web-blocks.js +248 -241
  157. package/dist/web-preview-Cio70gk5.cjs +1 -0
  158. package/dist/web-preview-Djy6WIyj.js +73 -0
  159. package/package.json +175 -105
  160. package/dist/IconPicker-CGWn9C4u.cjs +0 -1
  161. package/dist/IconPicker-QvxJ-4Ez.js +0 -64
  162. package/dist/apply-binding-DCno1xQL.js +0 -711
  163. package/dist/apply-binding-DvHNFLQD.cjs +0 -1
  164. package/dist/code-display-BZ1x7SqI.cjs +0 -1
  165. package/dist/code-editor-B28LoECM.cjs +0 -1
  166. package/dist/code-editor-CfG2FhJ-.js +0 -58
  167. package/dist/common-functions-BGzDsf1z.js +0 -14
  168. package/dist/common-functions-BZmyleS1.cjs +0 -1
  169. package/dist/css-import-modal-CENUYvcl.cjs +0 -13
  170. package/dist/get-chai-builder-theme-Ck_Z4Q-M.cjs +0 -1
  171. package/dist/index-CaGNHF7f.js +0 -12209
  172. package/dist/index-Gn6pJt2v.cjs +0 -166
  173. package/dist/mockServiceWorker.js +0 -307
  174. package/dist/plugin-B5627hMN.js +0 -195
  175. package/dist/plugin-UxTRfDum.cjs +0 -22
  176. package/dist/rte-widget-modal-DL739qeQ.cjs +0 -1
  177. package/dist/rte-widget-modal-Dte0od04.js +0 -41
  178. package/dist/tailwind.js +0 -7
  179. package/dist/tooltip-A4qGk781.cjs +0 -1
  180. package/dist/tooltip-tLiIOgjq.js +0 -1067
  181. package/dist/ui.cjs +0 -1
  182. package/dist/ui.d.ts +0 -415
  183. package/dist/ui.js +0 -129
  184. package/dist/vite.svg +0 -1
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("./index-DF5DEvqb.cjs"),z=require("date-fns"),p=require("lodash-es"),N=require("lucide-react"),b=require("react"),M=require("react-diff-view"),O=require("./index-WQwzsC7A.cjs"),B=require("@tanstack/react-query");function H(t,r){const o=O.useApiUrl(),n=O.useFetch(),f=p.startsWith(t.uid,"draft:")||p.startsWith(r.uid,"live:");return B.useQuery({queryKey:["revision-comparison",t.uid,r.uid],queryFn:async()=>{if(!t.uid||!r.uid)throw new Error("Both revision IDs are required for comparison");const l=u=>u==="draft"||u==="live"?u:"revision",s=u=>p.replace(u.uid,`${u.label}:`,"");return await n(o,{action:O.ACTIONS.GET_COMPARE_DATA,data:{versions:{version1:{type:l(t.label),id:s(t)},version2:{type:l(r.label),id:s(r)}}}})},enabled:!!t.uid&&!!r.uid,staleTime:f?0:1/0})}const K=({version:t})=>{const r=t==null?void 0:t.item,{data:o}=O.useChaiUserInfo(r==null?void 0:r.currentEditor),n=t.label==="live",f=t.label==="draft";return e.jsxs("span",{className:`flex items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${n?"border-green-500/30":f?"border-amber-500/30":"border-purple-500/30"}`,children:[e.jsx("div",{className:"h-full items-center rounded px-1.5 py-0.5 font-medium capitalize"+(n?" bg-green-500 text-green-50":f?" bg-amber-500 text-amber-50":" bg-purple-500 text-purple-50"),children:t.label}),e.jsxs("div",{className:"py-1 text-xs font-light leading-none text-gray-800",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-light opacity-90",children:f?"Currently editing":"Published by"}),!f&&e.jsx("span",{className:"pl-1 font-medium",children:(o==null?void 0:o.name)||"Unknown"})]}),e.jsx("div",{className:"text-[10px] leading-tight",children:z.formatDate(r.createdAt,"dd MMM yyyy, h:mm a")})]})]})},L=({version:t})=>e.jsx(K,{version:t});function V(t,r,o="data.json"){const n=JSON.stringify(t,null,2),f=JSON.stringify(r,null,2),l=n.split(`
2
+ `),s=f.split(`
3
+ `);let d=`--- a/${o}
4
+ `;d+=`+++ b/${o}
5
+ `;const u=[];let c=0,m=0;for(;c<l.length||m<s.length;){const g=l[c]||"",v=s[m]||"";if(g===v)u.push(` ${g}`),c++,m++;else{let h=-1,j=-1;for(let a=c+1;a<l.length;a++)if(s[m]===l[a]){h=a;break}for(let a=m+1;a<s.length;a++)if(l[c]===s[a]){j=a;break}if(h!==-1&&(j===-1||h-c<=j-m)){for(let a=c;a<h;a++)u.push(`-${l[a]}`);c=h}else if(j!==-1){for(let a=m;a<j;a++)u.push(`+${s[a]}`);m=j}else g&&u.push(`-${g}`),v&&u.push(`+${v}`),c++,m++}}const w=l.length,J=s.length;return d+=`@@ -1,${w} +1,${J} @@
6
+ `,d+=u.join(`
7
+ `)+`
8
+ `,d}function T(t,r=!0,o=!1){if(p.isString(t)){const n=p.trim(t);if(p.startsWith(n,"{")||p.startsWith(n,"[")||r&&(n==="true"||n==="false"||n==="null"||/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(n)))try{const l=JSON.parse(n);return T(l,r,o)}catch{if(o)throw new Error(`Invalid JSON string: ${n}`);return{}}return t}return p.isArray(t)?p.map(t,n=>T(n,r,o)):p.isPlainObject(t)?p.mapValues(t,n=>T(n,r,o)):t}const U=t=>{switch(t){case"blocks":return"Blocks";case"seo":return"SEO";case"tracking":return"Tracking";default:return t}},W=(t,r)=>{if(!t||!r)return[{key:"blocks",label:"Blocks"}];const o=Object.keys(t),n=Object.keys(r);return o.filter(s=>n.includes(s)).map(s=>({key:s,label:U(s)})).filter(s=>s.key.length>0)},_=(t,r=3)=>{const o=new Set;t.map((s,d)=>({change:s,index:d})).filter(({change:s})=>s.type!=="normal").map(({index:s})=>s).forEach(s=>{const d=Math.max(0,s-r),u=Math.min(t.length-1,s+r);for(let c=d;c<=u;c++)o.add(c)});const f=[];let l=-1;return t.forEach((s,d)=>{if(o.has(d)){if(l!==-1&&d-l>1){const u=t[l].lineNumber!=null?t[l].lineNumber+1:l+2,c=t[d].lineNumber!=null?t[d].lineNumber-1:d;f.push({content:e.jsx(x.Badge,{className:"pointer-events-none w-60 -translate-x-1/2 cursor-default border-none bg-transparent py-1 shadow-none",children:e.jsxs("span",{className:"rounded border border-border bg-muted px-3 py-1 text-xs font-light leading-none text-muted-foreground",children:["No changes from ",u," to ",c," line"]})})})}f.push(s),l=d}}),f};function P({open:t,compare:r,onOpenChange:o}){const n=r[0],f=r[1],[l,s]=b.useState(null),[d,u]=b.useState("split"),[c,m]=b.useState(!1),[w,J]=b.useState(!0),[g,v]=b.useState("blocks"),{data:h,isLoading:j}=H(n,f),{leftData:a,rightData:k,options:F}=b.useMemo(()=>{var y,R;const i=(y=h==null?void 0:h.version1)==null?void 0:y[g],C=(R=h==null?void 0:h.version2)==null?void 0:R[g],S=T(i),D=T(C),q=W(h==null?void 0:h.version1,h==null?void 0:h.version2);return{leftData:S,rightData:D,options:q}},[h,g]),$=b.useMemo(()=>!a||!k?"":V(a,k),[a,k]),A=b.useMemo(()=>{if(!$)return[];try{return M.parseDiff($)}catch(i){return console.error("Failed to parse diff:",i),[]}},[$]),I=async(i,C)=>{try{await navigator.clipboard.writeText(JSON.stringify(i,null,2)),s(C),setTimeout(()=>s(null),2e3)}catch(S){console.error("Failed to copy:",S)}},E=i=>JSON.stringify(i,null,2);return e.jsx(x.Dialog,{open:t,onOpenChange:o,children:e.jsxs(x.DialogContent,{className:"flex h-[90vh] w-[95vw] max-w-[1900px] flex-col p-6",children:[e.jsx(x.DialogHeader,{className:"pb-4 pt-0",children:e.jsxs(x.DialogTitle,{className:"flex items-center justify-between gap-2 leading-none",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N.FileJson,{className:"h-5 w-5"}),"Compare","",F.map(i=>e.jsx("div",{className:`cursor-pointer rounded-full border px-2.5 py-1 text-xs leading-none ${g===i.key?"border-blue-500 bg-blue-500 text-white":"border-gray-600 text-gray-600 hover:bg-gray-200"}`,onClick:()=>v(i.key),children:i.label},i.key))]}),e.jsx("div",{className:"flex flex-1 items-center justify-end pr-8",children:e.jsxs("div",{className:"flex w-max items-center justify-end gap-2 rounded-md border px-1.5 py-1",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx(x.Switch,{disabled:c,checked:c?!0:d==="split",onCheckedChange:i=>u(i?"split":"unified")}),e.jsx("label",{className:"text-sm",children:"Split View"})]}),e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx(x.Switch,{checked:c,onCheckedChange:i=>m(i)}),e.jsx("label",{className:"text-sm",children:"Show Raw Data"})]}),e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1",children:[e.jsx(x.Switch,{checked:w,onCheckedChange:i=>J(i)}),e.jsx("label",{className:"text-sm",children:"Hide Common Data"})]})]})})]})}),j?e.jsx("div",{className:"flex h-full w-full items-center justify-center",children:e.jsx(N.Loader,{className:"h-6 w-6 animate-spin text-primary"})}):e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsxs("div",{className:"relative min-h-0 flex-1",children:[e.jsxs("div",{className:"absolute -top-5 z-50 mt-0.5 flex w-full items-center justify-between gap-2",children:[e.jsx("div",{className:"flex w-1/2 items-center justify-center gap-2",children:e.jsx(L,{version:n})}),e.jsx("div",{className:"flex w-1/2 items-center justify-center gap-2",children:e.jsx(L,{version:f})})]}),c?e.jsxs("div",{className:"grid h-full grid-cols-2 gap-3 rounded-lg border",children:[e.jsxs("div",{className:"relative flex min-h-0 flex-col border-r",children:[e.jsx("div",{className:"absolute -top-4 right-4 z-50",children:e.jsxs(x.Button,{variant:"outline",size:"sm",onClick:()=>I(a,"left"),children:[l==="left"?e.jsx(N.Check,{className:"text-green-500"}):e.jsx(N.Copy,{}),"Copy"]})}),e.jsx(x.ScrollArea,{className:"flex-1 rounded-lg bg-slate-50 p-3 dark:bg-slate-900",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:E(a)})})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-col",children:[e.jsx("div",{className:"absolute -top-4 right-4 z-50",children:e.jsxs(x.Button,{variant:"outline",size:"sm",onClick:()=>I(k,"right"),children:[l==="right"?e.jsx(N.Check,{className:"text-green-500"}):e.jsx(N.Copy,{}),"Copy"]})}),e.jsx(x.ScrollArea,{className:"flex-1 rounded-lg bg-slate-50 p-3 dark:bg-slate-900",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:E(k)})})]})]}):e.jsx(x.ScrollArea,{className:"h-full overflow-y-auto rounded-lg border bg-slate-50 text-xs dark:bg-slate-900",children:A.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(N.FileJson,{className:"mx-auto mb-2 h-8 w-8 opacity-50"}),e.jsx("p",{children:"No differences found or unable to parse diff"})]})}):e.jsx("div",{children:A.map((i,C)=>e.jsx("div",{className:"relative mb-4",children:e.jsx(M.Diff,{viewType:d,diffType:i.type,hunks:i.hunks,className:"rounded-lg text-xs",children:S=>S.map((D,q)=>{const y=w?_(D.changes):D.changes;return(y==null?void 0:y.length)===0?e.jsx("div",{className:"absolute h-full w-full border-l pt-64 text-center font-sans text-sm",children:e.jsx("span",{children:"No difference found"})}):e.jsx(M.Hunk,{hunk:{...D,changes:y}},q)})},w?"hide-common-data":"show-common-data")},C))})})]})})]})})}exports.default=P;
@@ -0,0 +1,258 @@
1
+ import { jsx as e, jsxs as h } from "react/jsx-runtime";
2
+ import { D as V, d as _, e as q, f as G, aj as $, a5 as I, B as z, ak as P } from "./index-Ct7ElCGK.js";
3
+ import { formatDate as Q } from "date-fns";
4
+ import { startsWith as T, replace as W, isString as X, trim as Y, isArray as Z, map as ee, isPlainObject as te, mapValues as re } from "lodash-es";
5
+ import { FileJson as B, Loader as ne, Check as F, Copy as H } from "lucide-react";
6
+ import { useState as D, useMemo as A } from "react";
7
+ import { parseDiff as se, Diff as le, Hunk as ae } from "react-diff-view";
8
+ import { ar as ie, as as oe, A as ce, ap as de } from "./index-ZuacEL1j.js";
9
+ import { useQuery as fe } from "@tanstack/react-query";
10
+ function me(t, n) {
11
+ const o = ie(), s = oe(), u = T(t.uid, "draft:") || T(n.uid, "live:");
12
+ return fe({
13
+ queryKey: ["revision-comparison", t.uid, n.uid],
14
+ queryFn: async () => {
15
+ if (!t.uid || !n.uid)
16
+ throw new Error("Both revision IDs are required for comparison");
17
+ const l = (f) => f === "draft" || f === "live" ? f : "revision", r = (f) => W(f.uid, `${f.label}:`, "");
18
+ return await s(o, {
19
+ action: ce.GET_COMPARE_DATA,
20
+ data: {
21
+ versions: {
22
+ version1: { type: l(t.label), id: r(t) },
23
+ version2: { type: l(n.label), id: r(n) }
24
+ }
25
+ }
26
+ });
27
+ },
28
+ enabled: !!t.uid && !!n.uid,
29
+ staleTime: u ? 0 : 1 / 0
30
+ });
31
+ }
32
+ const he = ({ version: t }) => {
33
+ const n = t == null ? void 0 : t.item, { data: o } = de(n == null ? void 0 : n.currentEditor), s = t.label === "live", u = t.label === "draft";
34
+ return /* @__PURE__ */ h(
35
+ "span",
36
+ {
37
+ className: `flex items-center gap-x-2 rounded border bg-white px-2 text-xs shadow-lg ${s ? "border-green-500/30" : u ? "border-amber-500/30" : "border-purple-500/30"}`,
38
+ children: [
39
+ /* @__PURE__ */ e(
40
+ "div",
41
+ {
42
+ className: "h-full items-center rounded px-1.5 py-0.5 font-medium capitalize" + (s ? " bg-green-500 text-green-50" : u ? " bg-amber-500 text-amber-50" : " bg-purple-500 text-purple-50"),
43
+ children: t.label
44
+ }
45
+ ),
46
+ /* @__PURE__ */ h("div", { className: "py-1 text-xs font-light leading-none text-gray-800", children: [
47
+ /* @__PURE__ */ h("div", { children: [
48
+ /* @__PURE__ */ e("span", { className: "font-light opacity-90", children: u ? "Currently editing" : "Published by" }),
49
+ !u && /* @__PURE__ */ e("span", { className: "pl-1 font-medium", children: (o == null ? void 0 : o.name) || "Unknown" })
50
+ ] }),
51
+ /* @__PURE__ */ e("div", { className: "text-[10px] leading-tight", children: Q(n.createdAt, "dd MMM yyyy, h:mm a") })
52
+ ] })
53
+ ]
54
+ }
55
+ );
56
+ }, K = ({ version: t }) => /* @__PURE__ */ e(he, { version: t });
57
+ function ue(t, n, o = "data.json") {
58
+ const s = JSON.stringify(t, null, 2), u = JSON.stringify(n, null, 2), l = s.split(`
59
+ `), r = u.split(`
60
+ `);
61
+ let d = `--- a/${o}
62
+ `;
63
+ d += `+++ b/${o}
64
+ `;
65
+ const f = [];
66
+ let c = 0, p = 0;
67
+ for (; c < l.length || p < r.length; ) {
68
+ const g = l[c] || "", N = r[p] || "";
69
+ if (g === N)
70
+ f.push(` ${g}`), c++, p++;
71
+ else {
72
+ let m = -1, x = -1;
73
+ for (let a = c + 1; a < l.length; a++)
74
+ if (r[p] === l[a]) {
75
+ m = a;
76
+ break;
77
+ }
78
+ for (let a = p + 1; a < r.length; a++)
79
+ if (l[c] === r[a]) {
80
+ x = a;
81
+ break;
82
+ }
83
+ if (m !== -1 && (x === -1 || m - c <= x - p)) {
84
+ for (let a = c; a < m; a++)
85
+ f.push(`-${l[a]}`);
86
+ c = m;
87
+ } else if (x !== -1) {
88
+ for (let a = p; a < x; a++)
89
+ f.push(`+${r[a]}`);
90
+ p = x;
91
+ } else
92
+ g && f.push(`-${g}`), N && f.push(`+${N}`), c++, p++;
93
+ }
94
+ }
95
+ const y = l.length, j = r.length;
96
+ return d += `@@ -1,${y} +1,${j} @@
97
+ `, d += f.join(`
98
+ `) + `
99
+ `, d;
100
+ }
101
+ function S(t, n = !0, o = !1) {
102
+ if (X(t)) {
103
+ const s = Y(t);
104
+ if (T(s, "{") || T(s, "[") || n && (s === "true" || s === "false" || s === "null" || /^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(s)))
105
+ try {
106
+ const l = JSON.parse(s);
107
+ return S(l, n, o);
108
+ } catch {
109
+ if (o)
110
+ throw new Error(`Invalid JSON string: ${s}`);
111
+ return {};
112
+ }
113
+ return t;
114
+ }
115
+ return Z(t) ? ee(t, (s) => S(s, n, o)) : te(t) ? re(t, (s) => S(s, n, o)) : t;
116
+ }
117
+ const pe = (t) => {
118
+ switch (t) {
119
+ case "blocks":
120
+ return "Blocks";
121
+ case "seo":
122
+ return "SEO";
123
+ case "tracking":
124
+ return "Tracking";
125
+ default:
126
+ return t;
127
+ }
128
+ }, ge = (t, n) => {
129
+ if (!t || !n) return [{ key: "blocks", label: "Blocks" }];
130
+ const o = Object.keys(t), s = Object.keys(n);
131
+ return o.filter((r) => s.includes(r)).map((r) => ({ key: r, label: pe(r) })).filter((r) => r.key.length > 0);
132
+ }, xe = (t, n = 3) => {
133
+ const o = /* @__PURE__ */ new Set();
134
+ t.map((r, d) => ({ change: r, index: d })).filter(({ change: r }) => r.type !== "normal").map(({ index: r }) => r).forEach((r) => {
135
+ const d = Math.max(0, r - n), f = Math.min(t.length - 1, r + n);
136
+ for (let c = d; c <= f; c++)
137
+ o.add(c);
138
+ });
139
+ const u = [];
140
+ let l = -1;
141
+ return t.forEach((r, d) => {
142
+ if (o.has(d)) {
143
+ if (l !== -1 && d - l > 1) {
144
+ const f = t[l].lineNumber != null ? t[l].lineNumber + 1 : l + 2, c = t[d].lineNumber != null ? t[d].lineNumber - 1 : d;
145
+ u.push({
146
+ content: /* @__PURE__ */ e(P, { className: "pointer-events-none w-60 -translate-x-1/2 cursor-default border-none bg-transparent py-1 shadow-none", children: /* @__PURE__ */ h("span", { className: "rounded border border-border bg-muted px-3 py-1 text-xs font-light leading-none text-muted-foreground", children: [
147
+ "No changes from ",
148
+ f,
149
+ " to ",
150
+ c,
151
+ " line"
152
+ ] }) })
153
+ });
154
+ }
155
+ u.push(r), l = d;
156
+ }
157
+ }), u;
158
+ };
159
+ function Te({ open: t, compare: n, onOpenChange: o }) {
160
+ const s = n[0], u = n[1], [l, r] = D(null), [d, f] = D("split"), [c, p] = D(!1), [y, j] = D(!0), [g, N] = D("blocks"), { data: m, isLoading: x } = me(s, u), { leftData: a, rightData: w, options: U } = A(() => {
161
+ var b, R;
162
+ const i = (b = m == null ? void 0 : m.version1) == null ? void 0 : b[g], v = (R = m == null ? void 0 : m.version2) == null ? void 0 : R[g], k = S(i), C = S(v), J = ge(m == null ? void 0 : m.version1, m == null ? void 0 : m.version2);
163
+ return { leftData: k, rightData: C, options: J };
164
+ }, [m, g]), O = A(() => !a || !w ? "" : ue(a, w), [a, w]), E = A(() => {
165
+ if (!O) return [];
166
+ try {
167
+ return se(O);
168
+ } catch (i) {
169
+ return console.error("Failed to parse diff:", i), [];
170
+ }
171
+ }, [O]), L = async (i, v) => {
172
+ try {
173
+ await navigator.clipboard.writeText(JSON.stringify(i, null, 2)), r(v), setTimeout(() => r(null), 2e3);
174
+ } catch (k) {
175
+ console.error("Failed to copy:", k);
176
+ }
177
+ }, M = (i) => JSON.stringify(i, null, 2);
178
+ return /* @__PURE__ */ e(V, { open: t, onOpenChange: o, children: /* @__PURE__ */ h(_, { className: "flex h-[90vh] w-[95vw] max-w-[1900px] flex-col p-6", children: [
179
+ /* @__PURE__ */ e(q, { className: "pb-4 pt-0", children: /* @__PURE__ */ h(G, { className: "flex items-center justify-between gap-2 leading-none", children: [
180
+ /* @__PURE__ */ h("div", { className: "flex items-center gap-2", children: [
181
+ /* @__PURE__ */ e(B, { className: "h-5 w-5" }),
182
+ "Compare",
183
+ "",
184
+ U.map((i) => /* @__PURE__ */ e(
185
+ "div",
186
+ {
187
+ className: `cursor-pointer rounded-full border px-2.5 py-1 text-xs leading-none ${g === i.key ? "border-blue-500 bg-blue-500 text-white" : "border-gray-600 text-gray-600 hover:bg-gray-200"}`,
188
+ onClick: () => N(i.key),
189
+ children: i.label
190
+ },
191
+ i.key
192
+ ))
193
+ ] }),
194
+ /* @__PURE__ */ e("div", { className: "flex flex-1 items-center justify-end pr-8", children: /* @__PURE__ */ h("div", { className: "flex w-max items-center justify-end gap-2 rounded-md border px-1.5 py-1", children: [
195
+ /* @__PURE__ */ h("div", { className: "flex items-center gap-2 px-2 py-1", children: [
196
+ /* @__PURE__ */ e(
197
+ $,
198
+ {
199
+ disabled: c,
200
+ checked: c ? !0 : d === "split",
201
+ onCheckedChange: (i) => f(i ? "split" : "unified")
202
+ }
203
+ ),
204
+ /* @__PURE__ */ e("label", { className: "text-sm", children: "Split View" })
205
+ ] }),
206
+ /* @__PURE__ */ h("div", { className: "flex items-center gap-2 px-2 py-1", children: [
207
+ /* @__PURE__ */ e($, { checked: c, onCheckedChange: (i) => p(i) }),
208
+ /* @__PURE__ */ e("label", { className: "text-sm", children: "Show Raw Data" })
209
+ ] }),
210
+ /* @__PURE__ */ h("div", { className: "flex items-center gap-2 px-2 py-1", children: [
211
+ /* @__PURE__ */ e($, { checked: y, onCheckedChange: (i) => j(i) }),
212
+ /* @__PURE__ */ e("label", { className: "text-sm", children: "Hide Common Data" })
213
+ ] })
214
+ ] }) })
215
+ ] }) }),
216
+ x ? /* @__PURE__ */ e("div", { className: "flex h-full w-full items-center justify-center", children: /* @__PURE__ */ e(ne, { className: "h-6 w-6 animate-spin text-primary" }) }) : /* @__PURE__ */ e("div", { className: "flex min-h-0 flex-1 flex-col", children: /* @__PURE__ */ h("div", { className: "relative min-h-0 flex-1", children: [
217
+ /* @__PURE__ */ h("div", { className: "absolute -top-5 z-50 mt-0.5 flex w-full items-center justify-between gap-2", children: [
218
+ /* @__PURE__ */ e("div", { className: "flex w-1/2 items-center justify-center gap-2", children: /* @__PURE__ */ e(K, { version: s }) }),
219
+ /* @__PURE__ */ e("div", { className: "flex w-1/2 items-center justify-center gap-2", children: /* @__PURE__ */ e(K, { version: u }) })
220
+ ] }),
221
+ c ? /* @__PURE__ */ h("div", { className: "grid h-full grid-cols-2 gap-3 rounded-lg border", children: [
222
+ /* @__PURE__ */ h("div", { className: "relative flex min-h-0 flex-col border-r", children: [
223
+ /* @__PURE__ */ e("div", { className: "absolute -top-4 right-4 z-50", children: /* @__PURE__ */ h(z, { variant: "outline", size: "sm", onClick: () => L(a, "left"), children: [
224
+ l === "left" ? /* @__PURE__ */ e(F, { className: "text-green-500" }) : /* @__PURE__ */ e(H, {}),
225
+ "Copy"
226
+ ] }) }),
227
+ /* @__PURE__ */ e(I, { className: "flex-1 rounded-lg bg-slate-50 p-3 dark:bg-slate-900", children: /* @__PURE__ */ e("pre", { className: "whitespace-pre-wrap font-mono text-xs", children: M(a) }) })
228
+ ] }),
229
+ /* @__PURE__ */ h("div", { className: "relative flex min-h-0 flex-col", children: [
230
+ /* @__PURE__ */ e("div", { className: "absolute -top-4 right-4 z-50", children: /* @__PURE__ */ h(z, { variant: "outline", size: "sm", onClick: () => L(w, "right"), children: [
231
+ l === "right" ? /* @__PURE__ */ e(F, { className: "text-green-500" }) : /* @__PURE__ */ e(H, {}),
232
+ "Copy"
233
+ ] }) }),
234
+ /* @__PURE__ */ e(I, { className: "flex-1 rounded-lg bg-slate-50 p-3 dark:bg-slate-900", children: /* @__PURE__ */ e("pre", { className: "whitespace-pre-wrap font-mono text-xs", children: M(w) }) })
235
+ ] })
236
+ ] }) : /* @__PURE__ */ e(I, { className: "h-full overflow-y-auto rounded-lg border bg-slate-50 text-xs dark:bg-slate-900", children: E.length === 0 ? /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center p-6", children: /* @__PURE__ */ h("div", { className: "text-center text-muted-foreground", children: [
237
+ /* @__PURE__ */ e(B, { className: "mx-auto mb-2 h-8 w-8 opacity-50" }),
238
+ /* @__PURE__ */ e("p", { children: "No differences found or unable to parse diff" })
239
+ ] }) }) : /* @__PURE__ */ e("div", { children: E.map((i, v) => /* @__PURE__ */ e("div", { className: "relative mb-4", children: /* @__PURE__ */ e(
240
+ le,
241
+ {
242
+ viewType: d,
243
+ diffType: i.type,
244
+ hunks: i.hunks,
245
+ className: "rounded-lg text-xs",
246
+ children: (k) => k.map((C, J) => {
247
+ const b = y ? xe(C.changes) : C.changes;
248
+ return (b == null ? void 0 : b.length) === 0 ? /* @__PURE__ */ e("div", { className: "absolute h-full w-full border-l pt-64 text-center font-sans text-sm", children: /* @__PURE__ */ e("span", { children: "No difference found" }) }) : /* @__PURE__ */ e(ae, { hunk: { ...C, changes: b } }, J);
249
+ })
250
+ },
251
+ y ? "hide-common-data" : "show-common-data"
252
+ ) }, v)) }) })
253
+ ] }) })
254
+ ] }) });
255
+ }
256
+ export {
257
+ Te as default
258
+ };
@@ -0,0 +1,215 @@
1
+ import { jsx as e, jsxs as s, Fragment as M } from "react/jsx-runtime";
2
+ import { D as j, d as F, e as B, f as H, p as O, A as W, L as q, I as R, q as J, B as A, n as K, r as Q, s as V, t as X, v as w } from "./index-Ct7ElCGK.js";
3
+ import { au as Y, m as I, L as T, av as Z, l as ee, aw as se, j as ae, ax as f, ay as o } from "./index-ZuacEL1j.js";
4
+ import { find as G, startsWith as E, isEqual as ne, filter as te, get as D, map as le, isEmpty as ie } from "lodash-es";
5
+ import { AlertCircle as re, StarIcon as ce, MoreHorizontal as oe, PencilIcon as de, Power as me, TrashIcon as ue } from "lucide-react";
6
+ import { useState as S, useMemo as he, Suspense as L, lazy as z } from "react";
7
+ import { useTranslation as U } from "react-i18next";
8
+ import { toast as ge } from "sonner";
9
+ import { useSetAtom as pe } from "jotai";
10
+ const fe = ({ page: a, onClose: g }) => {
11
+ const { t: l } = U(), [i, v] = S(a.slug || ""), { mutate: N, isPending: y } = Y(), { data: t } = I(), r = G(t, { key: a == null ? void 0 : a.pageType }), x = (m) => {
12
+ if (m.preventDefault(), !(a != null && a.primaryPage) && Object.keys(T).some((p) => i === `/${p}` || E(i, `/${p}/`))) {
13
+ ge.error(l("Error"), {
14
+ description: l("Slugs cannot start with a language code for primary page")
15
+ });
16
+ return;
17
+ }
18
+ N({ ...a, slug: i }, { onSuccess: g });
19
+ }, d = (a == null ? void 0 : a.lang) || "";
20
+ return /* @__PURE__ */ e(j, { open: !!a, onOpenChange: g, children: /* @__PURE__ */ s(F, { children: [
21
+ /* @__PURE__ */ s(B, { children: [
22
+ /* @__PURE__ */ e(H, { children: l("Change Slug") }),
23
+ /* @__PURE__ */ e(O, { className: "text-xs", children: /* @__PURE__ */ s(W, { variant: "destructive", className: "mt-2", children: [
24
+ /* @__PURE__ */ e(re, { className: "h-4 w-4" }),
25
+ l("Changing the slug may have impact on your SEO. Please proceed with caution.")
26
+ ] }) })
27
+ ] }),
28
+ /* @__PURE__ */ s("form", { onSubmit: x, children: [
29
+ /* @__PURE__ */ s("div", { className: "space-y-4 py-4 text-sm", children: [
30
+ /* @__PURE__ */ s("div", { className: "space-y-1", children: [
31
+ /* @__PURE__ */ s("div", { children: [
32
+ /* @__PURE__ */ s("span", { children: [
33
+ l("Type"),
34
+ ":"
35
+ ] }),
36
+ /* @__PURE__ */ s("span", { className: "font-medium text-gray-600", children: [
37
+ " ",
38
+ (r == null ? void 0 : r.name) || (a == null ? void 0 : a.pageType)
39
+ ] })
40
+ ] }),
41
+ /* @__PURE__ */ s("div", { children: [
42
+ /* @__PURE__ */ s("span", { children: [
43
+ l("Name"),
44
+ ":"
45
+ ] }),
46
+ /* @__PURE__ */ s("span", { className: "font-medium text-gray-600", children: [
47
+ " ",
48
+ a.name
49
+ ] })
50
+ ] })
51
+ ] }),
52
+ /* @__PURE__ */ s("div", { className: "space-y-1", children: [
53
+ /* @__PURE__ */ s(q, { htmlFor: "slug", className: "text-right", children: [
54
+ l("Slug"),
55
+ " ",
56
+ /* @__PURE__ */ s("small", { className: "font-light text-gray-500", children: [
57
+ l("Slug should start with"),
58
+ " /",
59
+ d
60
+ ] })
61
+ ] }),
62
+ /* @__PURE__ */ e(
63
+ R,
64
+ {
65
+ id: "slug",
66
+ value: i,
67
+ onChange: (m) => {
68
+ const u = m.target.value;
69
+ E(u, `/${d}`) && v(u);
70
+ },
71
+ className: "col-span-3",
72
+ required: !0,
73
+ pattern: "^/.*",
74
+ title: l("Slug must start with /"),
75
+ placeholder: l("Enter page slug")
76
+ }
77
+ )
78
+ ] })
79
+ ] }),
80
+ /* @__PURE__ */ e(J, { children: /* @__PURE__ */ e(A, { type: "submit", disabled: y || !E(i, `/${d}`) || ne(a == null ? void 0 : a.slug, i), children: l(y ? "Changing..." : "Change Slug") }) })
81
+ ] })
82
+ ] }) });
83
+ }, Ne = z(() => import("./delete-page-BzyX9TN-.js")), ye = z(() => import("./unpublish-page-D4VwOlxc.js")), Pe = () => {
84
+ const { t: a } = U(), g = pe(Z), { selectedLang: l, fallbackLang: i, setSelectedLang: v } = K(), { data: N, isFetching: y } = ee(), { data: t } = se(), { data: r } = I(), x = he(() => {
85
+ const n = r == null ? void 0 : r.find((h) => h.key === (t == null ? void 0 : t.pageType));
86
+ return t != null && t.dynamic ? n == null ? void 0 : n.dynamicSlug : "";
87
+ }, [r, t == null ? void 0 : t.pageType, t == null ? void 0 : t.dynamic]), [d, m] = S(null), [u, C] = S(null), [p, _] = S(null), { data: P } = ae(), $ = te(
88
+ D(P, "languages") || ["en"],
89
+ (n) => !G(N, { lang: n }) && n !== D(P, "fallbackLang")
90
+ );
91
+ return /* @__PURE__ */ s("div", { className: "space-y-4", children: [
92
+ /* @__PURE__ */ e("ul", { className: "space-y-2", children: y ? /* @__PURE__ */ s("div", { className: "w-full space-y-3 py-4", children: [
93
+ /* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
94
+ /* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
95
+ /* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" })
96
+ ] }) : le(N, (n) => {
97
+ const h = n.lang, b = n.slug, k = !n.primaryPage;
98
+ return /* @__PURE__ */ s(M, { children: [
99
+ /* @__PURE__ */ s(
100
+ "li",
101
+ {
102
+ className: `flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${h === l ? "bg-gray-200" : "hover:bg-gray-100"}`,
103
+ onClick: () => v(h),
104
+ children: [
105
+ /* @__PURE__ */ s("div", { className: "flex-1 gap-x-3", children: [
106
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-x-2 text-[13px] text-slate-800", children: [
107
+ /* @__PURE__ */ e("div", { className: `h-2.5 w-2.5 rounded-full ${n.online ? "bg-green-300" : "bg-gray-300"}` }),
108
+ D(T, k ? i : h, h)
109
+ ] }),
110
+ /* @__PURE__ */ s("div", { children: [
111
+ b && /* @__PURE__ */ s("div", { className: "text-[11px] font-light text-slate-600", children: [
112
+ "Slug: ",
113
+ /* @__PURE__ */ e("b", { className: "font-mono font-medium", children: x ? `${b}/${x}` : b })
114
+ ] }),
115
+ /* @__PURE__ */ s("div", { className: "text-[11px] font-light text-slate-600", children: [
116
+ "Name:",
117
+ /* @__PURE__ */ s("b", { className: "font-medium", children: [
118
+ " ",
119
+ n.name,
120
+ " "
121
+ ] })
122
+ ] })
123
+ ] })
124
+ ] }),
125
+ k ? /* @__PURE__ */ s("div", { className: "flex items-center gap-x-1 text-[11px] text-orange-500", children: [
126
+ /* @__PURE__ */ e(ce, { fill: "orange", className: "h-3 w-3" }),
127
+ /* @__PURE__ */ e("b", { children: " Primary" })
128
+ ] }) : /* @__PURE__ */ e("div", { className: "flex items-center gap-x-3", children: /* @__PURE__ */ e(
129
+ f,
130
+ {
131
+ permissions: [
132
+ o.EDIT_PAGE,
133
+ o.DELETE_PAGE,
134
+ o.UNPUBLISH_PAGE
135
+ ],
136
+ children: /* @__PURE__ */ s(Q, { children: [
137
+ /* @__PURE__ */ e(V, { asChild: !0, onClick: (c) => c.stopPropagation(), children: /* @__PURE__ */ e(A, { variant: "ghost", size: "sm", className: "h-8 w-8 p-0", children: /* @__PURE__ */ e(oe, { className: "h-4 w-4" }) }) }),
138
+ /* @__PURE__ */ s(X, { align: "end", className: "z-[9999] text-sm", children: [
139
+ /* @__PURE__ */ e(f, { permissions: [o.EDIT_PAGE], children: /* @__PURE__ */ s(
140
+ w,
141
+ {
142
+ className: "flex cursor-pointer items-center gap-2",
143
+ onClick: (c) => {
144
+ c.stopPropagation(), g({
145
+ edit: !0,
146
+ id: n.id,
147
+ primaryPage: n.primaryPage
148
+ });
149
+ },
150
+ children: [
151
+ /* @__PURE__ */ e(de, { className: "size-3" }),
152
+ a("Edit")
153
+ ]
154
+ }
155
+ ) }),
156
+ /* @__PURE__ */ e(f, { permissions: [o.UNPUBLISH_PAGE], children: (n == null ? void 0 : n.online) && /* @__PURE__ */ s(
157
+ w,
158
+ {
159
+ className: "flex cursor-pointer items-center gap-2",
160
+ onClick: (c) => {
161
+ c.stopPropagation(), C(n);
162
+ },
163
+ children: [
164
+ /* @__PURE__ */ e(me, { className: "size-3" }),
165
+ a("Unpublish")
166
+ ]
167
+ }
168
+ ) }),
169
+ /* @__PURE__ */ e(f, { permissions: [o.DELETE_PAGE], children: /* @__PURE__ */ s(
170
+ w,
171
+ {
172
+ className: "flex cursor-pointer items-center gap-2",
173
+ onClick: (c) => {
174
+ c.stopPropagation(), m(n);
175
+ },
176
+ children: [
177
+ /* @__PURE__ */ e(ue, { className: "size-3" }),
178
+ a("Delete")
179
+ ]
180
+ }
181
+ ) })
182
+ ] })
183
+ ] })
184
+ }
185
+ ) })
186
+ ]
187
+ },
188
+ n.id
189
+ ),
190
+ /* @__PURE__ */ e("div", { className: "h-1 w-full border-b" })
191
+ ] });
192
+ }) }),
193
+ /* @__PURE__ */ e(f, { permissions: [o.ADD_PAGE], children: /* @__PURE__ */ e("div", { className: "flex w-full justify-center", children: /* @__PURE__ */ e(
194
+ A,
195
+ {
196
+ variant: "default",
197
+ size: "sm",
198
+ disabled: ie($),
199
+ onClick: () => {
200
+ g({
201
+ primaryPage: t == null ? void 0 : t.id,
202
+ edit: !1
203
+ });
204
+ },
205
+ children: a("Add new language page")
206
+ }
207
+ ) }) }),
208
+ d && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(Ne, { page: d, onClose: () => m(null) }) }),
209
+ u && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(ye, { page: u, onClose: () => C(null) }) }),
210
+ p && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(fe, { page: p, onClose: () => _(null) }) })
211
+ ] });
212
+ };
213
+ export {
214
+ Pe as default
215
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-DF5DEvqb.cjs"),n=require("./index-WQwzsC7A.cjs"),r=require("lodash-es"),j=require("lucide-react"),c=require("react"),w=require("react-i18next"),G=require("sonner"),L=require("jotai"),k=({page:s,onClose:S})=>{const{t:a}=w.useTranslation(),[o,E]=c.useState(s.slug||""),{mutate:N,isPending:y}=n.useChangeSlug(),{data:l}=n.usePageTypes(),d=r.find(l,{key:s==null?void 0:s.pageType}),f=h=>{if(h.preventDefault(),!(s!=null&&s.primaryPage)&&Object.keys(n.LANGUAGES).some(p=>o===`/${p}`||r.startsWith(o,`/${p}/`))){G.toast.error(a("Error"),{description:a("Slugs cannot start with a language code for primary page")});return}N({...s,slug:o},{onSuccess:S})},m=(s==null?void 0:s.lang)||"";return e.jsx(i.Dialog,{open:!!s,onOpenChange:S,children:e.jsxs(i.DialogContent,{children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:a("Change Slug")}),e.jsx(i.DialogDescription,{className:"text-xs",children:e.jsxs(i.Alert,{variant:"destructive",className:"mt-2",children:[e.jsx(j.AlertCircle,{className:"h-4 w-4"}),a("Changing the slug may have impact on your SEO. Please proceed with caution.")]})})]}),e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{className:"space-y-4 py-4 text-sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{children:[e.jsxs("span",{children:[a("Type"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(d==null?void 0:d.name)||(s==null?void 0:s.pageType)]})]}),e.jsxs("div",{children:[e.jsxs("span",{children:[a("Name"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",s.name]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(i.Label,{htmlFor:"slug",className:"text-right",children:[a("Slug")," ",e.jsxs("small",{className:"font-light text-gray-500",children:[a("Slug should start with")," /",m]})]}),e.jsx(i.Input,{id:"slug",value:o,onChange:h=>{const x=h.target.value;r.startsWith(x,`/${m}`)&&E(x)},className:"col-span-3",required:!0,pattern:"^/.*",title:a("Slug must start with /"),placeholder:a("Enter page slug")})]})]}),e.jsx(i.DialogFooter,{children:e.jsx(i.Button,{type:"submit",disabled:y||!r.startsWith(o,`/${m}`)||r.isEqual(s==null?void 0:s.slug,o),children:a(y?"Changing...":"Change Slug")})})]})]})})},M=c.lazy(()=>Promise.resolve().then(()=>require("./delete-page-DxX7PFIE.cjs"))),T=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-bdSmwAVQ.cjs"))),_=()=>{const{t:s}=w.useTranslation(),S=L.useSetAtom(n.addNewLangAtom),{selectedLang:a,fallbackLang:o,setSelectedLang:E}=i.useLanguages(),{data:N,isFetching:y}=n.useLanguagePages(),{data:l}=n.useChaiCurrentPage(),{data:d}=n.usePageTypes(),f=c.useMemo(()=>{const t=d==null?void 0:d.find(g=>g.key===(l==null?void 0:l.pageType));return l!=null&&l.dynamic?t==null?void 0:t.dynamicSlug:""},[d,l==null?void 0:l.pageType,l==null?void 0:l.dynamic]),[m,h]=c.useState(null),[x,P]=c.useState(null),[p,I]=c.useState(null),{data:C}=n.useWebsiteSetting(),A=r.filter(r.get(C,"languages")||["en"],t=>!r.find(N,{lang:t})&&t!==r.get(C,"fallbackLang"));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ul",{className:"space-y-2",children:y?e.jsxs("div",{className:"w-full space-y-3 py-4",children:[e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"})]}):r.map(N,t=>{const g=t.lang,v=t.slug,b=!t.primaryPage,D=g===a;return e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:`flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${D?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>E(g),children:[e.jsxs("div",{className:"flex-1 gap-x-3",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-[13px] text-slate-800",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),r.get(n.LANGUAGES,b?o:g,g)]}),e.jsxs("div",{children:[v&&e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Slug: ",e.jsx("b",{className:"font-mono font-medium",children:f?`${v}/${f}`:v})]}),e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Name:",e.jsxs("b",{className:"font-medium",children:[" ",t.name," "]})]})]})]}),b?e.jsxs("div",{className:"flex items-center gap-x-1 text-[11px] text-orange-500",children:[e.jsx(j.StarIcon,{fill:"orange",className:"h-3 w-3"}),e.jsx("b",{children:" Primary"})]}):e.jsx("div",{className:"flex items-center gap-x-3",children:e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE,n.PAGES_PERMISSIONS.DELETE_PAGE,n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,onClick:u=>u.stopPropagation(),children:e.jsx(i.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(j.MoreHorizontal,{className:"h-4 w-4"})})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"z-[9999] text-sm",children:[e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),S({edit:!0,id:t.id,primaryPage:t.primaryPage})},children:[e.jsx(j.PencilIcon,{className:"size-3"}),s("Edit")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:(t==null?void 0:t.online)&&e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),P(t)},children:[e.jsx(j.Power,{className:"size-3"}),s("Unpublish")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.DELETE_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),h(t)},children:[e.jsx(j.TrashIcon,{className:"size-3"}),s("Delete")]})})]})]})})})]},t.id),e.jsx("div",{className:"h-1 w-full border-b"})]})})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.ADD_PAGE],children:e.jsx("div",{className:"flex w-full justify-center",children:e.jsx(i.Button,{variant:"default",size:"sm",disabled:r.isEmpty(A),onClick:()=>{S({primaryPage:l==null?void 0:l.id,edit:!1})},children:s("Add new language page")})})}),m&&e.jsx(c.Suspense,{children:e.jsx(M,{page:m,onClose:()=>h(null)})}),x&&e.jsx(c.Suspense,{children:e.jsx(T,{page:x,onClose:()=>P(null)})}),p&&e.jsx(c.Suspense,{children:e.jsx(k,{page:p,onClose:()=>I(null)})})]})};exports.default=_;