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

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 (127) hide show
  1. package/dist/{2SSKDMRQ-SUA5eA2S.js → 2SSKDMRQ-Bk_4y8lw.js} +2 -2
  2. package/dist/{2SSKDMRQ-DVWVGtU8.cjs → 2SSKDMRQ-vWeQ_IyI.cjs} +1 -1
  3. package/dist/{AP7HFJJL-CUN5zddU.cjs → AP7HFJJL-CMPLeI6t.cjs} +1 -1
  4. package/dist/{AP7HFJJL-Co5bLh3I.js → AP7HFJJL-D_mI2XSw.js} +1 -1
  5. package/dist/{IconPicker-Bmz6vXB8.cjs → IconPicker-DB_PpKvH.cjs} +1 -1
  6. package/dist/{IconPicker-BZvFj3cg.js → IconPicker-jc6_JzXf.js} +1 -1
  7. package/dist/{WDYDFRGG-DjCIT9L-.js → WDYDFRGG-B4H3RPcp.js} +2 -2
  8. package/dist/{WDYDFRGG-BpSteEEf.cjs → WDYDFRGG-D7vzbPjk.cjs} +1 -1
  9. package/dist/{active-in-another-tab-DfRJcvAz.js → active-in-another-tab-CDhFxBU7.js} +2 -2
  10. package/dist/{active-in-another-tab-C8-vpt8f.cjs → active-in-another-tab-CMPHyyHE.cjs} +1 -1
  11. package/dist/{add-new-language-page-jZ7Pg0Fv.js → add-new-language-page-BliZ46WW.js} +3 -3
  12. package/dist/{add-new-language-page-B2BEmfil.cjs → add-new-language-page-IbMzbf4v.cjs} +1 -1
  13. package/dist/{add-new-page-DbEBB3w7.cjs → add-new-page-BJJqSKp0.cjs} +1 -1
  14. package/dist/{add-new-page-YZF_XF8X.js → add-new-page-DUCKfyWo.js} +2 -2
  15. package/dist/{ai-panel-content-Bf_ojKwt.cjs → ai-panel-content-DWOqjq3Z.cjs} +1 -1
  16. package/dist/{ai-panel-content-C8ecaQnv.js → ai-panel-content-GeQIaXy8.js} +3 -3
  17. package/dist/{ai-panel-default-lang-DokOmE_Q.cjs → ai-panel-default-lang-DGNDrfam.cjs} +2 -2
  18. package/dist/{ai-panel-default-lang-BC8Gq_jl.js → ai-panel-default-lang-VQsV6KB3.js} +3 -3
  19. package/dist/{ai-panel-other-lang-Ccx1t8pp.cjs → ai-panel-other-lang-DvXF0Nn5.cjs} +1 -1
  20. package/dist/{ai-panel-other-lang-BJ30SL7z.js → ai-panel-other-lang-SuC8jyfr.js} +3 -3
  21. package/dist/{ai-prompt-input-SfeB6a2j.js → ai-prompt-input-CB6iQAmE.js} +1 -1
  22. package/dist/{ai-prompt-input-ED14e6NE.cjs → ai-prompt-input-a8s-JrZb.cjs} +1 -1
  23. package/dist/{ai-translation-prompt-BRRzei71.js → ai-translation-prompt-CoNVDclG.js} +1 -1
  24. package/dist/{ai-translation-prompt-spS-OC6L.cjs → ai-translation-prompt-Qn1Sz4BI.cjs} +1 -1
  25. package/dist/change-password-modal-BtdsU0mm.cjs +1 -0
  26. package/dist/change-password-modal-CMEo8lEm.js +137 -0
  27. package/dist/{code-editor-CYiIxUKp.js → code-editor-CTMQr0aU.js} +1 -1
  28. package/dist/{code-editor-CIqswl5j.cjs → code-editor-CjatfjZe.cjs} +1 -1
  29. package/dist/{continue-editing-in-this-client-B3CnmiZ2.cjs → continue-editing-in-this-client-7swLl0kq.cjs} +1 -1
  30. package/dist/{continue-editing-in-this-client-vICoETHN.js → continue-editing-in-this-client-CNVJZvXQ.js} +2 -2
  31. package/dist/core.cjs +1 -1
  32. package/dist/core.d.ts +1 -0
  33. package/dist/core.js +1 -1
  34. package/dist/{css-import-modal-DautOct0.js → css-import-modal-B3XY8Hzw.js} +1 -1
  35. package/dist/{css-import-modal-CHFZPXXQ.cjs → css-import-modal-D2RqE-V0.cjs} +1 -1
  36. package/dist/{delete-design-token-BmWHk_Ap.js → delete-design-token-DEyYFVHU.js} +1 -1
  37. package/dist/{delete-design-token-D-wGR5qS.cjs → delete-design-token-Dd3b86G7.cjs} +1 -1
  38. package/dist/{delete-page-Dlv8srng.js → delete-page-BSn5mRvk.js} +2 -2
  39. package/dist/{delete-page-D5mzl-ET.cjs → delete-page-BfsmsTek.cjs} +1 -1
  40. package/dist/{design-token-usage-DIszlgJK.cjs → design-token-usage-BY8meqAt.cjs} +1 -1
  41. package/dist/{design-token-usage-hl29qR_q.js → design-token-usage-f20BdlHE.js} +1 -1
  42. package/dist/{digital-asset-manager-v2LfDXwR.cjs → digital-asset-manager-Pi0YiB35.cjs} +1 -1
  43. package/dist/{digital-asset-manager-o_bNl9qj.js → digital-asset-manager-iXt27NlP.js} +3 -3
  44. package/dist/{duplicate-page-BjqgghN0.js → duplicate-page-BuVub6uY.js} +3 -3
  45. package/dist/{duplicate-page-CEuF8dll.cjs → duplicate-page-g5hiQkrZ.cjs} +1 -1
  46. package/dist/{dynamic-page-selector-BWC7kHJ1.js → dynamic-page-selector-NZ-rKLo3.js} +2 -2
  47. package/dist/{dynamic-page-selector-D4EWs4Qd.cjs → dynamic-page-selector-z6UGEjk1.cjs} +1 -1
  48. package/dist/{get-chai-builder-theme-DDVRJQ6Z.js → get-chai-builder-theme-CHXhAcdV.js} +1 -1
  49. package/dist/{get-chai-builder-theme-BApShjRz.cjs → get-chai-builder-theme-CMypjJk8.cjs} +1 -1
  50. package/dist/{image-editor-B1-bjvPd.js → image-editor--WT9183_.js} +1 -1
  51. package/dist/{image-editor-2h5axNuk.cjs → image-editor-C6cZZNbB.cjs} +1 -1
  52. package/dist/index-BGGNVIKx.cjs +5 -0
  53. package/dist/{index-DWGTiEak.cjs → index-CfsIhbT2.cjs} +11 -11
  54. package/dist/{index-BvluH-oT.js → index-ckjNCVor.js} +990 -978
  55. package/dist/{index-BN6yEl-H.js → index-iRqgNs2O.js} +897 -891
  56. package/dist/{json-diff-viewer-WX0GIjq-.js → json-diff-viewer-DAQ-qSHk.js} +2 -2
  57. package/dist/{json-diff-viewer-BjCIlzd7.cjs → json-diff-viewer-DheqS084.cjs} +1 -1
  58. package/dist/{lang-panel-C4x7bcyb.js → lang-panel-DRDPvY1i.js} +3 -3
  59. package/dist/{lang-panel--yfjRDE2.cjs → lang-panel-oLc-QyU4.cjs} +1 -1
  60. package/dist/{manage-design-tokens-DhdwhzQu.cjs → manage-design-tokens-Hu25ejcC.cjs} +1 -1
  61. package/dist/{manage-design-tokens-CRwsErkx.js → manage-design-tokens-rEzXQJRW.js} +2 -2
  62. package/dist/{mark-as-template-DpZSFrLK.js → mark-as-template-BNbn5zQG.js} +2 -2
  63. package/dist/{mark-as-template-BH0W9p2G.cjs → mark-as-template-DEThYoS6.cjs} +1 -1
  64. package/dist/{nested-path-selector-content-BDQmZzlf.js → nested-path-selector-content-BERhs6_L.js} +1 -1
  65. package/dist/{nested-path-selector-content-CHYz7cdB.cjs → nested-path-selector-content-Dz3-bNqT.cjs} +1 -1
  66. package/dist/{no-language-page-content-D0lcCseQ.js → no-language-page-content-CPVIz5rC.js} +2 -2
  67. package/dist/{no-language-page-content-D7btm8zX.cjs → no-language-page-content-CrUkIrUJ.cjs} +1 -1
  68. package/dist/{no-language-page-dialog-sYOmLnpY.cjs → no-language-page-dialog-964r8feg.cjs} +1 -1
  69. package/dist/{no-language-page-dialog-BdW7oXvt.js → no-language-page-dialog-DPDJ6gkQ.js} +2 -2
  70. package/dist/{page-creator-O_QpbMlB.js → page-creator-CDcfL4al.js} +3 -3
  71. package/dist/{page-creator-B-jBAGZl.cjs → page-creator-kvymje2i.cjs} +1 -1
  72. package/dist/{page-lock-CmQKpw1U.js → page-lock-BpUGSiCT.js} +2 -2
  73. package/dist/{page-lock-BrVqfmVm.cjs → page-lock-gOE-Tt7g.cjs} +1 -1
  74. package/dist/{page-locked-dialog-BjeJOXuN.js → page-locked-dialog-UQeYxWz1.js} +2 -2
  75. package/dist/{page-locked-dialog-ChHVSk7X.cjs → page-locked-dialog-aJFtoEzq.cjs} +1 -1
  76. package/dist/{page-manager-new-B90zLpRY.cjs → page-manager-new-DBomYOFT.cjs} +1 -1
  77. package/dist/{page-manager-new-wcsdorbd.js → page-manager-new-Dg02OZtc.js} +22 -22
  78. package/dist/{page-manager-search-and-filter-DY_NsetM.js → page-manager-search-and-filter-CCTh5gkC.js} +2 -2
  79. package/dist/{page-manager-search-and-filter-Bb_Zfpsj.cjs → page-manager-search-and-filter-pWHXOgMJ.cjs} +1 -1
  80. package/dist/{page-revisions-content-CVpi-467.cjs → page-revisions-content-BDY8RXJW.cjs} +1 -1
  81. package/dist/{page-revisions-content-5h39VYXj.js → page-revisions-content-C6YjUAx9.js} +7 -7
  82. package/dist/pages.cjs +1 -1
  83. package/dist/pages.d.ts +1 -0
  84. package/dist/pages.js +12 -12
  85. package/dist/plugin-DH3BDqys.js +251 -0
  86. package/dist/{plugin-BGlQf0iy.cjs → plugin-DO5QAuc1.cjs} +13 -13
  87. package/dist/{publish-pages-content-rrfvXks4.js → publish-pages-content-8MQN9iLc.js} +17 -17
  88. package/dist/{publish-pages-content-BG1GIuIz.cjs → publish-pages-content-DjUd9oWi.cjs} +1 -1
  89. package/dist/render.cjs +1 -1
  90. package/dist/render.d.ts +4 -1
  91. package/dist/render.js +2 -2
  92. package/dist/{rte-widget-modal-29WtCMJs.js → rte-widget-modal-Bj7lxFEs.js} +1 -1
  93. package/dist/{rte-widget-modal-JRoPPuju.cjs → rte-widget-modal-O31cHitM.cjs} +1 -1
  94. package/dist/{save-to-lib-Bm7R2K7j.js → save-to-lib-BMlowHNl.js} +2 -2
  95. package/dist/{save-to-lib-YvzDV5ee.cjs → save-to-lib-vxpiXsok.cjs} +1 -1
  96. package/dist/sdk.css +1 -1
  97. package/dist/{selected-block-display-bdClAekS.cjs → selected-block-display-BjhZTfSL.cjs} +1 -1
  98. package/dist/{selected-block-display-BAulh0Nz.js → selected-block-display-BxHTDLna.js} +2 -2
  99. package/dist/{seo-panel-CT0D3I44.js → seo-panel-197ULlty.js} +2 -2
  100. package/dist/{seo-panel-D9wnaLG-.cjs → seo-panel-MrGhioya.cjs} +1 -1
  101. package/dist/{shared-json-ld-ON6LaybZ.cjs → shared-json-ld-6ovlKZ7L.cjs} +1 -1
  102. package/dist/{shared-json-ld-CuhqVL8H.js → shared-json-ld-B2kfIim8.js} +24 -24
  103. package/dist/{slug-input-DNeh6LBv.js → slug-input-CSqTWSv8.js} +1 -1
  104. package/dist/{slug-input-CxmcQbTR.cjs → slug-input-CV-Dvosn.cjs} +1 -1
  105. package/dist/supabase-actions.cjs +1 -1
  106. package/dist/supabase-actions.d.ts +34 -0
  107. package/dist/supabase-actions.js +231 -192
  108. package/dist/{take-over-request-CrILj_3q.cjs → take-over-request-BFZbLBOK.cjs} +1 -1
  109. package/dist/{take-over-request-BmeR6t3b.js → take-over-request-Ds_-1dOv.js} +2 -2
  110. package/dist/{theme-panel-footer-D4oCAY2G.js → theme-panel-footer-C1f2KMBq.js} +2 -2
  111. package/dist/{theme-panel-footer-BMx5lGB4.cjs → theme-panel-footer-dHh8VGgj.cjs} +1 -1
  112. package/dist/{translation-warning-modal-BNG9m-FC.js → translation-warning-modal-DPdVK3CD.js} +1 -1
  113. package/dist/{translation-warning-modal-ChL7oDO1.cjs → translation-warning-modal-HD8Mlj1e.cjs} +1 -1
  114. package/dist/types.d.ts +1 -0
  115. package/dist/{unmark-as-template-BYiyJloZ.cjs → unmark-as-template-D8wEsu9z.cjs} +1 -1
  116. package/dist/{unmark-as-template-CEEMIY1A.js → unmark-as-template-DLVNotM_.js} +2 -2
  117. package/dist/{unpublish-page-B0aY1JnO.cjs → unpublish-page-Cl2R_dfN.cjs} +1 -1
  118. package/dist/{unpublish-page-Bm20P3TB.js → unpublish-page-ik9a66Rz.js} +2 -2
  119. package/dist/utils.cjs +1 -1
  120. package/dist/utils.js +1 -1
  121. package/dist/web-blocks.cjs +1 -1
  122. package/dist/web-blocks.js +23 -22
  123. package/dist/{web-preview-iQgiotU6.cjs → web-preview-CE39XTw0.cjs} +1 -1
  124. package/dist/{web-preview-BtEn4Vc-.js → web-preview-ztlGD_Xm.js} +1 -1
  125. package/package.json +1 -1
  126. package/dist/index-BJVYKKJq.cjs +0 -5
  127. package/dist/plugin-C-ht41UZ.js +0 -245
@@ -1,17 +1,17 @@
1
- "use strict";const a=require("lodash-es"),h=require("./fonts-B-Xt29pe.cjs"),b=require("./_commonjsHelpers-DwGv2jUC.cjs"),B={fontFamily:{"font-heading":"Inter","font-body":"Inter"},borderRadius:"10px",colors:[{group:"Body",items:{background:["#FFFFFF","#121212"],foreground:["#121212","#FFFFFF"]}},{group:"Primary",items:{primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"]}},{group:"Secondary",items:{secondary:["#F3F4F6","#374151"],"secondary-foreground":["#1F2937","#F9FAFB"]}},{group:"Border, Input & Ring",items:{border:["#E5E7EB","#374151"],input:["#E5E7EB","#374151"],ring:["#2563EB","#3B82F6"]}},{group:"Card",items:{card:["#FFFFFF","#1F2937"],"card-foreground":["#121212","#FFFFFF"]}},{group:"Popover",items:{popover:["#FFFFFF","#1F2937"],"popover-foreground":["#121212","#FFFFFF"]}},{group:"Muted",items:{muted:["#F3F4F6","#374151"],"muted-foreground":["#6B7280","#9CA3AF"]}},{group:"Accent",items:{accent:["#F3F4F6","#374151"],"accent-foreground":["#1F2937","#FFFFFF"]}},{group:"Destructive",items:{destructive:["#DC2626","#EF4444"],"destructive-foreground":["#FFFFFF","#FFFFFF"]}}]},v={fontFamily:{heading:"Inter",body:"Inter"},borderRadius:"6px",colors:{background:["#FFFFFF","#09090B"],foreground:["#09090B","#FFFFFF"],primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"],secondary:["#F4F4F5","#27272A"],"secondary-foreground":["#09090B","#FFFFFF"],muted:["#F4F4F5","#27272A"],"muted-foreground":["#71717A","#A1A1AA"],accent:["#F4F4F5","#27272A"],"accent-foreground":["#09090B","#FFFFFF"],destructive:["#EF4444","#7F1D1D"],"destructive-foreground":["#FFFFFF","#FFFFFF"],border:["#E4E4E7","#27272A"],input:["#E4E4E7","#27272A"],ring:["#2563EB","#3B82F6"],card:["#FFFFFF","#09090B"],"card-foreground":["#09090B","#FFFFFF"],popover:["#FFFFFF","#09090B"],"popover-foreground":["#09090B","#FFFFFF"]}},_=e=>({fontFamily:e.fontFamily?a.keys(e.fontFamily).reduce((r,n)=>({...r,[n.replace("font-","")]:`var(--${n})`}),{}):{},borderRadius:e.borderRadius?{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"}:{},colors:e.colors?a.flatten(e.colors.map(r=>Object.entries(r.items))).reduce((r,[n])=>({...r,[n]:`hsl(var(--${n}))`}),{}):{}});function m(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let r=parseInt(t[1],16),n=parseInt(t[2],16),F=parseInt(t[3],16);r/=255,n/=255,F/=255;const o=Math.max(r,n,F),u=Math.min(r,n,F);let i=0,l=0;const g=(o+u)/2;if(o==u)i=l=0;else{const s=o-u;switch(l=g>.5?s/(2-o-u):s/(o+u),o){case r:i=(n-F)/s+(n<F?6:0);break;case n:i=(F-r)/s+2;break;case F:i=(r-n)/s+4;break}i/=6}return`${Math.round(i*360)} ${Math.round(l*100)}% ${Math.round(g*100)}%`}const E=e=>{const r=h.getAllRegisteredFonts().find(n=>n.family===e);return`"${e}", ${a.get(r,"fallback","")}`},C=e=>`:root {
2
- ${e.fontFamily&&Object.entries(e.fontFamily).map(([t,r])=>`--font-${t}: ${E(r)};`).join(`
3
- `)}
4
- ${e.borderRadius&&`--radius: ${e.borderRadius};`}
5
- ${e.colors&&Object.entries(e.colors).map(([t,r])=>`--${t}: ${m(r[0])};`).join(`
6
- `)}
1
+ "use strict";const a=require("lodash-es"),$=require("./fonts-B-Xt29pe.cjs"),b=require("./_commonjsHelpers-DwGv2jUC.cjs"),B={fontFamily:{"font-heading":"Inter","font-body":"Inter"},borderRadius:"10px",colors:[{group:"Body",items:{background:["#FFFFFF","#121212"],foreground:["#121212","#FFFFFF"]}},{group:"Primary",items:{primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"]}},{group:"Secondary",items:{secondary:["#F3F4F6","#374151"],"secondary-foreground":["#1F2937","#F9FAFB"]}},{group:"Border, Input & Ring",items:{border:["#E5E7EB","#374151"],input:["#E5E7EB","#374151"],ring:["#2563EB","#3B82F6"]}},{group:"Card",items:{card:["#FFFFFF","#1F2937"],"card-foreground":["#121212","#FFFFFF"]}},{group:"Popover",items:{popover:["#FFFFFF","#1F2937"],"popover-foreground":["#121212","#FFFFFF"]}},{group:"Muted",items:{muted:["#F3F4F6","#374151"],"muted-foreground":["#6B7280","#9CA3AF"]}},{group:"Accent",items:{accent:["#F3F4F6","#374151"],"accent-foreground":["#1F2937","#FFFFFF"]}},{group:"Destructive",items:{destructive:["#DC2626","#EF4444"],"destructive-foreground":["#FFFFFF","#FFFFFF"]}}]},v={fontFamily:{heading:"Inter",body:"Inter"},borderRadius:"6px",colors:{background:["#FFFFFF","#09090B"],foreground:["#09090B","#FFFFFF"],primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"],secondary:["#F4F4F5","#27272A"],"secondary-foreground":["#09090B","#FFFFFF"],muted:["#F4F4F5","#27272A"],"muted-foreground":["#71717A","#A1A1AA"],accent:["#F4F4F5","#27272A"],"accent-foreground":["#09090B","#FFFFFF"],destructive:["#EF4444","#7F1D1D"],"destructive-foreground":["#FFFFFF","#FFFFFF"],border:["#E4E4E7","#27272A"],input:["#E4E4E7","#27272A"],ring:["#2563EB","#3B82F6"],card:["#FFFFFF","#09090B"],"card-foreground":["#09090B","#FFFFFF"],popover:["#FFFFFF","#09090B"],"popover-foreground":["#09090B","#FFFFFF"]}},_=e=>({fontFamily:e.fontFamily?a.keys(e.fontFamily).reduce((r,t)=>({...r,[t.replace("font-","")]:`var(--${t})`}),{}):{},borderRadius:e.borderRadius?{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"}:{},colors:e.colors?a.flatten(e.colors.map(r=>Object.entries(r.items))).reduce((r,[t])=>({...r,[t]:`hsl(var(--${t}))`}),{}):{}});function m(e){const F=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let r=parseInt(F[1],16),t=parseInt(F[2],16),n=parseInt(F[3],16);r/=255,t/=255,n/=255;const o=Math.max(r,t,n),u=Math.min(r,t,n);let i=0,l=0;const g=(o+u)/2;if(o==u)i=l=0;else{const s=o-u;switch(l=g>.5?s/(2-o-u):s/(o+u),o){case r:i=(t-n)/s+(t<n?6:0);break;case t:i=(n-r)/s+2;break;case n:i=(r-t)/s+4;break}i/=6}return`${Math.round(i*360)} ${Math.round(l*100)}% ${Math.round(g*100)}%`}const E=e=>{const r=$.getAllRegisteredFonts().find(t=>t.family===e);return`"${e}", ${a.get(r,"fallback","")}`},C=({theme:e,fontVariables:F=!1})=>{const r=e;return`:root {
2
+ ${F&&e.fontFamily?Object.entries(e.fontFamily).map(([t,n])=>`--font-${t}: ${E(n)};`).join(`
3
+ `):""}
4
+ ${r.borderRadius?`--radius: ${r.borderRadius};`:""}
5
+ ${r.colors?Object.entries(r.colors).map(([t,n])=>`--${t}: ${m(n[0])};`).join(`
6
+ `):""}
7
7
  }
8
8
  .dark {
9
- ${e.colors&&Object.entries(e.colors).map(([t,r])=>`--${t}: ${m(r[1])};`).join(`
10
- `)}
11
- }`,P=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(t=>`<link rel="stylesheet" href="${t.url}" />`).join(`
12
- `),A=e=>!e||e.length===0?[]:a.uniqBy(e,"family").map(t=>t.url),j=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(t=>`@import url("${t.url}");`).join(`
13
- `),q=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(t=>t.src.map(r=>`@font-face {
14
- font-family: "${t.family}";
9
+ ${r.colors?Object.entries(r.colors).map(([t,n])=>`--${t}: ${m(n[1])};`).join(`
10
+ `):""}
11
+ }`},P=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(F=>`<link rel="stylesheet" href="${F.url}" />`).join(`
12
+ `),A=e=>!e||e.length===0?[]:a.uniqBy(e,"family").map(F=>F.url),j=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(F=>`@import url("${F.url}");`).join(`
13
+ `),q=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(F=>F.src.map(r=>`@font-face {
14
+ font-family: "${F.family}";
15
15
  src: url("${r.url}") format("${r.format}");
16
16
  font-display: swap;
17
17
  ${r.fontWeight?`font-weight: ${r.fontWeight};`:""}
@@ -19,4 +19,4 @@
19
19
  ${r.fontStretch?`font-stretch: ${r.fontStretch};`:""}
20
20
  }`).join(`
21
21
  `)).join(`
22
- `);var d={},c={},p;function M(){return p||(p=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});function t(n,F){return{handler:n,config:F}}t.withOptions=function(n,F=()=>({})){const o=function(u){return{__options:u,handler:n(u),config:F(u)}};return o.__isOptionsFunction=!0,o.__pluginFunction=n,o.__configFunction=F,o};const r=t})(c)),c}var y;function k(){return y||(y=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const t=r(M());function r(F){return F&&F.__esModule?F:{default:F}}const n=t.default})(d)),d}var f,$;function R(){if($)return f;$=1;let e=k();return f=(e.__esModule?e:{default:e}).default,f}var I=R();const O=b.getDefaultExportFromCjs(I);exports.defaultThemeOptions=B;exports.defaultThemeValues=v;exports.getChaiThemeCssVariables=C;exports.getChaiThemeOptions=_;exports.getThemeCustomFontFace=q;exports.getThemeFontsCSSImport=j;exports.getThemeFontsLinkMarkup=P;exports.getThemeFontsUrls=A;exports.plugin=O;
22
+ `);var d={},c={},p;function T(){return p||(p=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});function F(t,n){return{handler:t,config:n}}F.withOptions=function(t,n=()=>({})){const o=function(u){return{__options:u,handler:t(u),config:n(u)}};return o.__isOptionsFunction=!0,o.__pluginFunction=t,o.__configFunction=n,o};const r=F})(c)),c}var h;function M(){return h||(h=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const F=r(T());function r(n){return n&&n.__esModule?n:{default:n}}const t=F.default})(d)),d}var f,y;function k(){if(y)return f;y=1;let e=M();return f=(e.__esModule?e:{default:e}).default,f}var R=k();const I=b.getDefaultExportFromCjs(R);exports.defaultThemeOptions=B;exports.defaultThemeValues=v;exports.getChaiThemeCssVariables=C;exports.getChaiThemeOptions=_;exports.getThemeCustomFontFace=q;exports.getThemeFontsCSSImport=j;exports.getThemeFontsLinkMarkup=P;exports.getThemeFontsUrls=A;exports.plugin=I;
@@ -1,10 +1,10 @@
1
1
  import { jsxs as n, jsx as t, Fragment as $ } from "react/jsx-runtime";
2
- import { B as L } from "./register-chai-top-bar-CX_JkRJn.js";
3
- import { e as K, f as Q, g as J, p as V, r as W } from "./index-BN6yEl-H.js";
4
- import { ar as X, as as Y, A as I, aA as q, aB as Z, k as ee, m as te, ap as se, T as U, t as le } from "./index-BvluH-oT.js";
5
- import { LanguageSelector as ae } from "./page-manager-search-and-filter-DY_NsetM.js";
2
+ import { B as A } from "./register-chai-top-bar-CX_JkRJn.js";
3
+ import { e as K, f as Q, g as J, p as V, r as W } from "./index-iRqgNs2O.js";
4
+ import { ar as X, as as Y, A as I, aB as q, aC as Z, k as ee, m as te, ap as se, T as U, t as le } from "./index-ckjNCVor.js";
5
+ import { LanguageSelector as ae } from "./page-manager-search-and-filter-CCTh5gkC.js";
6
6
  import { useQuery as ne } from "@tanstack/react-query";
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";
7
+ import { find as B, filter as a, map as b, keys as re, get as F, includes as P, 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";
9
9
  import { useState as D, useCallback as ge, useMemo as p, useEffect as j, startTransition as O } from "react";
10
10
  const pe = () => {
@@ -25,7 +25,7 @@ const pe = () => {
25
25
  o ? /* @__PURE__ */ t(de, { className: "h-4 w-4 fill-red-200 text-red-500" }) : /* @__PURE__ */ t(
26
26
  "input",
27
27
  {
28
- checked: C(d, s == null ? void 0 : s.id),
28
+ checked: P(d, s == null ? void 0 : s.id),
29
29
  onClick: (x) => {
30
30
  x.stopPropagation(), k(s == null ? void 0 : s.id);
31
31
  },
@@ -67,7 +67,7 @@ const pe = () => {
67
67
  ), S = p(
68
68
  () => a(c, (e) => !y.includes(e.pageType)),
69
69
  [c, y]
70
- ), P = p(
70
+ ), C = p(
71
71
  () => a(c, (e) => y.includes(e.pageType)),
72
72
  [c, y]
73
73
  );
@@ -76,12 +76,12 @@ const pe = () => {
76
76
  O(() => u(e));
77
77
  }, [c]), j(() => {
78
78
  const e = a(re(m), (l) => F(m, [l, "userId"]) !== f);
79
- O(() => u((l) => a(l, (g) => !C(e, g))));
79
+ O(() => u((l) => a(l, (g) => !P(e, g))));
80
80
  }, [m, f]);
81
- const A = r.length === (c == null ? void 0 : c.length), H = (e) => {
82
- u((l) => C(l, e) ? a(l, (g) => g !== e) : ie(l, e));
81
+ const L = r.length === (c == null ? void 0 : c.length), H = (e) => {
82
+ u((l) => P(l, e) ? a(l, (g) => g !== e) : ie(l, e));
83
83
  }, z = () => {
84
- u(A ? [] : b(c, "id"));
84
+ u(L ? [] : b(c, "id"));
85
85
  }, M = () => {
86
86
  k(
87
87
  { ids: G(r) },
@@ -99,14 +99,14 @@ const pe = () => {
99
99
  const e = [
100
100
  { label: "Updated", top: "pt-2" },
101
101
  ...N(a(S, { online: !0 }), "pageType"),
102
- ...N(a(P, { online: !0 }), "pageType")
102
+ ...N(a(C, { online: !0 }), "pageType")
103
103
  ].filter((g) => g.pageType !== "theme"), l = [
104
104
  { label: "Offline", top: "pt-6" },
105
105
  ...N(a(S, { online: !1 }), "pageType"),
106
- ...N(a(P, { online: !1 }), "pageType")
106
+ ...N(a(C, { online: !1 }), "pageType")
107
107
  ];
108
108
  return [...e, ...l];
109
- }, [S, P]);
109
+ }, [S, C]);
110
110
  return /* @__PURE__ */ n(K, { className: "flex max-h-[80%] max-w-4xl flex-col", children: [
111
111
  /* @__PURE__ */ n(Q, { children: [
112
112
  /* @__PURE__ */ t(J, { children: "Publish changes" }),
@@ -131,7 +131,7 @@ const pe = () => {
131
131
  /* @__PURE__ */ t(
132
132
  "input",
133
133
  {
134
- checked: A,
134
+ checked: L,
135
135
  onClick: (e) => {
136
136
  e.stopPropagation(), z();
137
137
  },
@@ -169,8 +169,8 @@ const pe = () => {
169
169
  r.length !== 1 ? "s" : "",
170
170
  " Selected"
171
171
  ] }),
172
- /* @__PURE__ */ t(L, { disabled: d, variant: "outline", onClick: s, children: "Cancel" }),
173
- /* @__PURE__ */ t(L, { disabled: d || v || oe(r), onClick: M, children: d ? "Publishing..." : "Publish Selected" })
172
+ /* @__PURE__ */ t(A, { disabled: d, variant: "outline", onClick: s, children: "Cancel" }),
173
+ /* @__PURE__ */ t(A, { disabled: d || v || oe(r), onClick: M, children: d ? "Publishing..." : "Publish Selected" })
174
174
  ] })
175
175
  ] });
176
176
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),q=require("./register-chai-top-bar-DWTuRU53.cjs"),f=require("./index-DWGTiEak.cjs"),r=require("./index-BJVYKKJq.cjs"),U=require("./page-manager-search-and-filter-Bb_Zfpsj.cjs"),F=require("@tanstack/react-query"),t=require("lodash-es"),b=require("lucide-react"),a=require("react"),M=()=>{const l=r.useApiUrl(),d=r.useFetch();return F.useQuery({queryKey:[r.ACTIONS.GET_CHANGES],queryFn:async()=>d(l,{action:r.ACTIONS.GET_CHANGES})})},G=({page:l,selectedPages:d,handleCheckboxChange:N,getPageType:y,hasSlug:h,currentOwnerId:c})=>{const x=r.useUserId(),{data:u}=r.useChaiUserInfo(c),o=c===x?null:u==null?void 0:u.name;return e.jsxs("tr",{className:"group relative border-b last:border-b-0 hover:bg-gray-50",children:[e.jsxs("td",{scope:"row",className:`flex items-center gap-x-1 whitespace-nowrap px-6 py-2 text-gray-900 dark:text-white ${o?"opacity-50":""}`,children:[o?e.jsx(b.Lock,{className:"h-4 w-4 fill-red-200 text-red-500"}):e.jsx("input",{checked:t.includes(d,l==null?void 0:l.id),onClick:p=>{p.stopPropagation(),N(l==null?void 0:l.id)},type:"checkbox",className:"cursor-pointer rounded focus:outline-none focus:ring-0"})," ",h(l.pageType)?e.jsx(b.File,{className:"h-4 w-4"}):e.jsx(b.GlobeIcon,{className:"h-4 w-4"}),e.jsx(r.Tooltip,{content:l.name,side:"top",showTooltip:l.name.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-medium text-black",children:l.name})}),l.slug&&e.jsx(r.Tooltip,{content:l.slug,side:"top",showTooltip:l.slug.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-mono text-xs text-muted-foreground",children:l.slug})})]}),e.jsx("td",{className:"px-2",children:y(l==null?void 0:l.pageType)}),e.jsx("td",{className:"px-4 text-right",children:t.first(l.changes)||""}),e.jsx(e.Fragment,{children:o&&e.jsxs("button",{className:"absolute right-0 top-0 flex h-full items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100",children:[e.jsx(b.Edit,{size:12,className:"stroke-[3]"})," ",e.jsx("span",{className:"font-medium",children:o})," is editing this page"]})})]},l==null?void 0:l.id)},O=({onClose:l=()=>{},isPending:d,publishPage:N})=>{const y=r.useUserId(),{pageToUser:h}=r.usePageToUser(),[c,x]=a.useState([]),u=r.useFallbackLang(),[o,p]=a.useState(u),{data:T,isFetching:C}=M(),{data:m}=r.usePageTypes(),k=a.useCallback(s=>{var n;return(n=t.find(m,{key:s}))==null?void 0:n.hasSlug},[m]),j=a.useMemo(()=>t.filter(m,s=>!k(s.key)).map(s=>s.key),[k,m]),P=t.uniq(t.map(T,"lang")).filter(Boolean),i=a.useMemo(()=>t.filter(T,s=>s.pageType==="theme"?!1:o===u?s.lang===o||s.lang==="":s.lang===o),[T,o,u]),w=a.useMemo(()=>t.filter(i,s=>!j.includes(s.pageType)),[i,j]),S=a.useMemo(()=>t.filter(i,s=>j.includes(s.pageType)),[i,j]);a.useEffect(()=>{const s=t.map(t.filter(i,{online:!0}),"id");a.startTransition(()=>x(s))},[i]),a.useEffect(()=>{const s=t.filter(t.keys(h),n=>t.get(h,[n,"userId"])!==y);a.startTransition(()=>x(n=>t.filter(n,g=>!t.includes(s,g))))},[h,y]);const v=c.length===(i==null?void 0:i.length),E=s=>{x(n=>t.includes(n,s)?t.filter(n,g=>g!==s):t.concat(n,s))},B=()=>{x(v?[]:t.map(i,"id"))},I=()=>{N({ids:t.uniq(c)},{onSuccess:()=>{l(),r.throwConfetti("CENTER_CENTER"),p(u)}})},A=s=>{if(s==="theme")return"Theme";const n=t.find(m,{key:s});return n?n==null?void 0:n.name:s},L=a.useMemo(()=>{const s=[{label:"Updated",top:"pt-2"},...t.orderBy(t.filter(w,{online:!0}),"pageType"),...t.orderBy(t.filter(S,{online:!0}),"pageType")].filter(g=>g.pageType!=="theme"),n=[{label:"Offline",top:"pt-6"},...t.orderBy(t.filter(w,{online:!1}),"pageType"),...t.orderBy(t.filter(S,{online:!1}),"pageType")];return[...s,...n]},[w,S]);return e.jsxs(f.DialogContent,{className:"flex max-h-[80%] max-w-4xl flex-col",children:[e.jsxs(f.DialogHeader,{children:[e.jsx(f.DialogTitle,{children:"Publish changes"}),e.jsx(f.DialogDescription,{className:"text-xs",children:"Select the pages you want to publish. Click publish when you're done."})]}),P.length>0&&e.jsx("div",{className:"my-[2px] mt-0",children:e.jsx(U.LanguageSelector,{languages:[u,...P],selectedLanguage:o,setSelectedLanguage:p})}),e.jsx("div",{className:"no-scrollbar relative -mx-4 -mt-4 h-full max-h-full overflow-y-auto",children:C?e.jsxs("div",{className:"space-y-2 px-1",children:[e.jsx("div",{className:"mt-2 h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):e.jsxs("table",{className:"w-full text-left text-xs text-gray-500 dark:text-gray-400 rtl:text-right",children:[e.jsx("thead",{className:"sticky top-0 z-10 border-b bg-gray-50 text-gray-700 dark:bg-gray-700 dark:text-gray-400",children:e.jsxs("tr",{children:[e.jsxs("th",{scope:"col",className:"w-[1 50px] flex items-center gap-x-2 px-6 py-3",children:[e.jsx("input",{checked:v,onClick:s=>{s.stopPropagation(),B()},type:"checkbox",className:"mt-1 cursor-pointer rounded focus:outline-none focus:ring-0"}),"Name"]}),e.jsx("th",{scope:"col",className:"w-[150px] px-2 py-3",children:"Type"}),e.jsx("th",{scope:"col",className:"w-[150px] px-4 py-3 text-right",children:"Status"})]})}),e.jsx("tbody",{children:t.map(L,s=>s.label?e.jsx("tr",{children:e.jsxs("td",{colSpan:3,className:`relative px-6 py-2 text-xs font-medium text-gray-800 ${s.top}`,children:[e.jsx("div",{className:"absolute inset-0 left-6 flex items-center",children:e.jsx("div",{className:"order-gray-300 w-full"})}),e.jsx("div",{className:"relative flex justify-start",children:e.jsx("span",{className:"bg-gray-50 pr-2",children:s.label})})]})},"separator"):e.jsx(G,{page:s,selectedPages:c,handleCheckboxChange:E,getPageType:A,hasSlug:k,currentOwnerId:t.get(h,[(s==null?void 0:s.primaryPage)||(s==null?void 0:s.id),"userId"])}))})]})}),e.jsxs(f.DialogFooter,{className:"mt-10 flex items-center justify-center",children:[c.length>0&&e.jsxs("span",{className:"text-center text-sm text-muted-foreground",children:[c.length," Page",c.length!==1?"s":""," Selected"]}),e.jsx(q.Button,{disabled:d,variant:"outline",onClick:l,children:"Cancel"}),e.jsx(q.Button,{disabled:d||C||t.isEmpty(c),onClick:I,children:d?"Publishing...":"Publish Selected"})]})]})};exports.default=O;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),q=require("./register-chai-top-bar-DWTuRU53.cjs"),f=require("./index-CfsIhbT2.cjs"),r=require("./index-BGGNVIKx.cjs"),U=require("./page-manager-search-and-filter-pWHXOgMJ.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;
package/dist/render.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./plugin-BGlQf0iy.cjs"),d=require("./apply-binding-nqrhHgIz.cjs"),m=require("react/jsx-runtime"),t=require("lodash-es"),g=require("react"),b=require("./core-BWQrViOY.cjs"),F=require("@mhsdesign/jit-browser-tailwindcss"),j=require("@tailwindcss/aspect-ratio"),q=require("@tailwindcss/container-queries"),K=require("@tailwindcss/forms"),M=require("@tailwindcss/typography"),x=require("./get-chai-builder-theme-BApShjRz.cjs");async function O(e){const a={pageProps:e.pageProps,block:e.block,lang:e.lang,draft:e.draft,inBuilder:!1},n=await e.dataProvider(a);return t.has(n,"$metadata")&&t.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,n.$metadata),e.children({...t.omit(n,"$metadata")})}const N=()=>m.jsx("div",{}),H=e=>{const{block:a,lang:n,fallbackLang:s,children:i,externalData:l,blocks:o,draft:r,pageProps:c,dataProviderMetadataCallback:f}=e,p=b.getRegisteredChaiBlock(a._type),u=t.get(p,"component",null),k=t.get(e.repeaterData,"index",-1),_=t.get(e.repeaterData,"dataKey",""),P=n===s?"":n??"",y=d.applyBindingToBlockProps(d.applyLanguage(a,P,p),l??{},{index:k,key:_}),h=d.getBlockTagAttributes(a,!1),T=D(o,a._id,d.getBlockRuntimeProps(a._type)),I=t.has(p,"dataProvider")&&t.isFunction(p.dataProvider),v={...y,...h,...T},B={blockProps:{},inBuilder:!1,lang:n||s||"en",draft:r??!1,pageData:l??{},...v},C=t.get(v,"_show",!0);if(t.isNull(u)||!C)return null;if(I){const $=t.get(p,"suspenseFallback",N);return m.jsx(g.Suspense,{fallback:g.createElement($),children:m.jsx(O,{lang:n??"",pageProps:c,block:v,dataProvider:p.dataProvider,...f?{dataProviderMetadataCallback:f}:{},draft:r??!1,children:S=>g.createElement(u,{...B,...S,children:i({_id:a._id,_type:a._type,...t.isArray(y.repeaterItems)?{repeaterItems:d.applyLimit(y.repeaterItems,a),$repeaterItemsKey:y.$repeaterItemsKey,repeaterTotalItems:y.repeaterTotalItems??-1}:{}})})})})}return m.jsx(g.Suspense,{children:g.createElement(u,{...B,children:i({_id:a._id,_type:a._type,...t.isArray(y.repeaterItems)?{repeaterItems:d.applyLimit(y.repeaterItems,a),$repeaterItemsKey:y.$repeaterItemsKey,repeaterTotalItems:y.repeaterTotalItems??-1}:{}})})})},E=e=>{const{blocks:a,parent:n,repeaterData:s,type:i}=e;let l=t.uniqBy(t.filter(a,r=>t.has(r,"_id")&&(t.isEmpty(n)?!r._parent:r._parent===n)),"_id");const o=r=>t.filter(a,c=>c._parent===r).length>0;return(i==="Heading"||i==="Paragraph"||i==="Link"||i==="Span")&&(l=d.adjustSpacingInContentBlocks(l)),t.map(l,(r,c)=>r?g.createElement(H,{...e,key:r._id?`${r._id}-${c}`:`block-${c}`,block:r},({_id:f,_type:p,repeaterItems:u,$repeaterItemsKey:k})=>p==="Repeater"?t.isArray(u)&&u.map((_,P)=>g.createElement(E,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${c}-${P}`,repeaterData:{index:P,dataKey:k}})):o(f)?g.createElement(E,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${c}`,repeaterData:s,type:r._type}):null):null)},D=(e,a,n)=>t.isEmpty(n)?{}:Object.entries(n).reduce((s,[i,l])=>{const o=[];let r=t.find(e,{_id:a});for(;r;)o.push(r),r=t.find(e,{_id:r._parent});const c=t.find(o,{_type:l.block});return c&&(s[i]=t.get(c,t.get(l,"prop"),null)),s},{});function J(e){if(t.isEmpty(e.lang)&&!t.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(t.isEmpty(e.blocks))return null;const a=e.lang??"en",n=e.fallbackLang??a;return m.jsx(E,{...e,lang:a,fallbackLang:n})}async function V(e){const a=await e.dataProvider;return t.has(a,"$metadata")&&t.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,a.$metadata),e.children({...t.omit(a,"$metadata")})}const W=()=>m.jsx("div",{}),U=async e=>{const{block:a,lang:n,fallbackLang:s,children:i,externalData:l,blocks:o,draft:r,pageProps:c,dataProviderMetadataCallback:f,dataProviders:p}=e,u=b.getRegisteredChaiBlock(a._type),k=t.get(u,"component",null),_=t.get(e.repeaterData,"index",-1),P=t.get(e.repeaterData,"dataKey",""),y=n===s?"":n??"en",h=d.applyBindingToBlockProps(d.applyLanguage(a,y,u),l??{},{index:_,key:P}),T=d.getBlockTagAttributes(a,!1),I=D(o,a._id,d.getBlockRuntimeProps(a._type)),v=t.has(u,"dataProvider")&&t.isFunction(u.dataProvider),B={...h,...T,...I},C={blockProps:{},inBuilder:!1,lang:n||s||"en",draft:r??!1,pageData:l??{},...B},$=t.get(B,"_show",!0);if(t.isNull(k)||!$)return null;if(v){const S=t.get(p,a._id,Promise.resolve({})),R=t.get(u,"suspenseFallback",W);return m.jsx(g.Suspense,{fallback:g.createElement(R),children:m.jsx(V,{lang:n??"",pageProps:c,block:B,dataProvider:S,...f?{dataProviderMetadataCallback:f}:{},draft:r??!1,children:A=>g.createElement(k,{...C,...A,children:i({_id:a._id,_type:a._type,...t.isArray(h.repeaterItems)?{repeaterItems:d.applyLimit(h.repeaterItems,a),$repeaterItemsKey:h.$repeaterItemsKey,repeaterTotalItems:h.repeaterTotalItems??-1}:{}})})})})}return g.createElement(k,{...C,children:i({_id:a._id,_type:a._type,...t.isArray(h.repeaterItems)?{repeaterItems:d.applyLimit(h.repeaterItems,a),$repeaterItemsKey:h.$repeaterItemsKey,repeaterTotalItems:h.repeaterTotalItems??-1}:{}})})},w=async e=>{const{blocks:a,parent:n,repeaterData:s,type:i}=e;let l=t.uniqBy(t.filter(a,r=>t.has(r,"_id")&&(t.isEmpty(n)?!r._parent:r._parent===n)),"_id");const o=r=>t.filter(a,c=>c._parent===r).length>0;return(i==="Heading"||i==="Paragraph"||i==="Link")&&(l=d.adjustSpacingInContentBlocks(l)),t.map(l,r=>r?g.createElement(U,{...e,dataProviders:e.dataProviders,key:r._id,block:r},({_id:c,_type:f,repeaterItems:p,$repeaterItemsKey:u})=>f==="Repeater"?t.isArray(p)&&p.map((k,_)=>g.createElement(w,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${_}`,repeaterData:{index:_,dataKey:u}})):o(c)?g.createElement(w,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}`,repeaterData:s,type:r._type}):null):null)};async function G(e){if(t.isEmpty(e.lang)&&!t.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(t.isEmpty(e.blocks))return null;const a=e.lang??"en",n=e.fallbackLang??a;if(e.dataProviders)return m.jsx(w,{...e,lang:a,fallbackLang:n,dataProviders:e.dataProviders});const i=e.blocks.filter(l=>{const o=b.getRegisteredChaiBlock(l._type);return!!(t.has(o,"dataProvider")&&t.isFunction(o.dataProvider))}).reduce((l,o)=>{const r=b.getRegisteredChaiBlock(o._type);if(!r||!r.dataProvider)return l;const c={pageProps:e.pageProps,block:o,lang:e.lang,draft:e.draft,inBuilder:!1};return l[o._id]=Promise.resolve(r.dataProvider(c)),l},{});return m.jsx(w,{...e,lang:a,fallbackLang:n,dataProviders:i})}function Q(e,a){const n=e.filter(s=>s._type==="GlobalBlock"||s._type==="PartialBlock");for(let s=0;s<n.length;s++){const i=n[s],l=t.get(i,"partialBlockId",t.get(i,"globalBlock",""));if(l==="")continue;let o=t.cloneDeep(t.get(a,l,[]));i._parent&&(o==null?void 0:o.length)>0&&(o=o.map(c=>(t.isEmpty(c._parent)&&(c._parent=i._parent),c)));const r=e.indexOf(i);e.splice(r,1,...o)}return e}const z=e=>{if(!e)return[];try{return JSON.parse(X(e)).filter(n=>!n._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function X(e){const a=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(a,n=>{const s=decodeURIComponent(n),i=s.indexOf("public");return i!==-1?s.substring(i+6):s})}async function Y(e,a=[],n=!1){return await F.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:a,theme:{extend:{...x.getChaiBuilderTheme(),keyframes:{"accordion-down":{from:{height:"0"},to:{height:"var(--radix-accordion-content-height)"}},"accordion-up":{from:{height:"var(--radix-accordion-content-height)"},to:{height:"0"}}},animation:{"accordion-down":"accordion-down 0.2s ease-out","accordion-up":"accordion-up 0.2s ease-out"}}},plugins:[K,M,j,q,x.chaiBuilderPlugin],corePlugins:{preflight:n}}}).generateStylesFromContent(` ${n?"@tailwind base;":""}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./plugin-DO5QAuc1.cjs"),d=require("./apply-binding-nqrhHgIz.cjs"),m=require("react/jsx-runtime"),t=require("lodash-es"),g=require("react"),b=require("./core-BWQrViOY.cjs"),F=require("@mhsdesign/jit-browser-tailwindcss"),j=require("@tailwindcss/aspect-ratio"),q=require("@tailwindcss/container-queries"),K=require("@tailwindcss/forms"),M=require("@tailwindcss/typography"),x=require("./get-chai-builder-theme-CMypjJk8.cjs");async function O(e){const a={pageProps:e.pageProps,block:e.block,lang:e.lang,draft:e.draft,inBuilder:!1},n=await e.dataProvider(a);return t.has(n,"$metadata")&&t.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,n.$metadata),e.children({...t.omit(n,"$metadata")})}const N=()=>m.jsx("div",{}),H=e=>{const{block:a,lang:n,fallbackLang:s,children:i,externalData:l,blocks:o,draft:r,pageProps:c,dataProviderMetadataCallback:f}=e,p=b.getRegisteredChaiBlock(a._type),u=t.get(p,"component",null),k=t.get(e.repeaterData,"index",-1),_=t.get(e.repeaterData,"dataKey",""),P=n===s?"":n??"",y=d.applyBindingToBlockProps(d.applyLanguage(a,P,p),l??{},{index:k,key:_}),h=d.getBlockTagAttributes(a,!1),T=D(o,a._id,d.getBlockRuntimeProps(a._type)),I=t.has(p,"dataProvider")&&t.isFunction(p.dataProvider),v={...y,...h,...T},B={blockProps:{},inBuilder:!1,lang:n||s||"en",draft:r??!1,pageData:l??{},...v},C=t.get(v,"_show",!0);if(t.isNull(u)||!C)return null;if(I){const $=t.get(p,"suspenseFallback",N);return m.jsx(g.Suspense,{fallback:g.createElement($),children:m.jsx(O,{lang:n??"",pageProps:c,block:v,dataProvider:p.dataProvider,...f?{dataProviderMetadataCallback:f}:{},draft:r??!1,children:S=>g.createElement(u,{...B,...S,children:i({_id:a._id,_type:a._type,...t.isArray(y.repeaterItems)?{repeaterItems:d.applyLimit(y.repeaterItems,a),$repeaterItemsKey:y.$repeaterItemsKey,repeaterTotalItems:y.repeaterTotalItems??-1}:{}})})})})}return m.jsx(g.Suspense,{children:g.createElement(u,{...B,children:i({_id:a._id,_type:a._type,...t.isArray(y.repeaterItems)?{repeaterItems:d.applyLimit(y.repeaterItems,a),$repeaterItemsKey:y.$repeaterItemsKey,repeaterTotalItems:y.repeaterTotalItems??-1}:{}})})})},E=e=>{const{blocks:a,parent:n,repeaterData:s,type:i}=e;let l=t.uniqBy(t.filter(a,r=>t.has(r,"_id")&&(t.isEmpty(n)?!r._parent:r._parent===n)),"_id");const o=r=>t.filter(a,c=>c._parent===r).length>0;return(i==="Heading"||i==="Paragraph"||i==="Link"||i==="Span")&&(l=d.adjustSpacingInContentBlocks(l)),t.map(l,(r,c)=>r?g.createElement(H,{...e,key:r._id?`${r._id}-${c}`:`block-${c}`,block:r},({_id:f,_type:p,repeaterItems:u,$repeaterItemsKey:k})=>p==="Repeater"?t.isArray(u)&&u.map((_,P)=>g.createElement(E,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${c}-${P}`,repeaterData:{index:P,dataKey:k}})):o(f)?g.createElement(E,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${c}`,repeaterData:s,type:r._type}):null):null)},D=(e,a,n)=>t.isEmpty(n)?{}:Object.entries(n).reduce((s,[i,l])=>{const o=[];let r=t.find(e,{_id:a});for(;r;)o.push(r),r=t.find(e,{_id:r._parent});const c=t.find(o,{_type:l.block});return c&&(s[i]=t.get(c,t.get(l,"prop"),null)),s},{});function J(e){if(t.isEmpty(e.lang)&&!t.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(t.isEmpty(e.blocks))return null;const a=e.lang??"en",n=e.fallbackLang??a;return m.jsx(E,{...e,lang:a,fallbackLang:n})}async function V(e){const a=await e.dataProvider;return t.has(a,"$metadata")&&t.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,a.$metadata),e.children({...t.omit(a,"$metadata")})}const W=()=>m.jsx("div",{}),U=async e=>{const{block:a,lang:n,fallbackLang:s,children:i,externalData:l,blocks:o,draft:r,pageProps:c,dataProviderMetadataCallback:f,dataProviders:p}=e,u=b.getRegisteredChaiBlock(a._type),k=t.get(u,"component",null),_=t.get(e.repeaterData,"index",-1),P=t.get(e.repeaterData,"dataKey",""),y=n===s?"":n??"en",h=d.applyBindingToBlockProps(d.applyLanguage(a,y,u),l??{},{index:_,key:P}),T=d.getBlockTagAttributes(a,!1),I=D(o,a._id,d.getBlockRuntimeProps(a._type)),v=t.has(u,"dataProvider")&&t.isFunction(u.dataProvider),B={...h,...T,...I},C={blockProps:{},inBuilder:!1,lang:n||s||"en",draft:r??!1,pageData:l??{},...B},$=t.get(B,"_show",!0);if(t.isNull(k)||!$)return null;if(v){const S=t.get(p,a._id,Promise.resolve({})),R=t.get(u,"suspenseFallback",W);return m.jsx(g.Suspense,{fallback:g.createElement(R),children:m.jsx(V,{lang:n??"",pageProps:c,block:B,dataProvider:S,...f?{dataProviderMetadataCallback:f}:{},draft:r??!1,children:A=>g.createElement(k,{...C,...A,children:i({_id:a._id,_type:a._type,...t.isArray(h.repeaterItems)?{repeaterItems:d.applyLimit(h.repeaterItems,a),$repeaterItemsKey:h.$repeaterItemsKey,repeaterTotalItems:h.repeaterTotalItems??-1}:{}})})})})}return g.createElement(k,{...C,children:i({_id:a._id,_type:a._type,...t.isArray(h.repeaterItems)?{repeaterItems:d.applyLimit(h.repeaterItems,a),$repeaterItemsKey:h.$repeaterItemsKey,repeaterTotalItems:h.repeaterTotalItems??-1}:{}})})},w=async e=>{const{blocks:a,parent:n,repeaterData:s,type:i}=e;let l=t.uniqBy(t.filter(a,r=>t.has(r,"_id")&&(t.isEmpty(n)?!r._parent:r._parent===n)),"_id");const o=r=>t.filter(a,c=>c._parent===r).length>0;return(i==="Heading"||i==="Paragraph"||i==="Link")&&(l=d.adjustSpacingInContentBlocks(l)),t.map(l,r=>r?g.createElement(U,{...e,dataProviders:e.dataProviders,key:r._id,block:r},({_id:c,_type:f,repeaterItems:p,$repeaterItemsKey:u})=>f==="Repeater"?t.isArray(p)&&p.map((k,_)=>g.createElement(w,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${_}`,repeaterData:{index:_,dataKey:u}})):o(c)?g.createElement(w,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}`,repeaterData:s,type:r._type}):null):null)};async function G(e){if(t.isEmpty(e.lang)&&!t.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(t.isEmpty(e.blocks))return null;const a=e.lang??"en",n=e.fallbackLang??a;if(e.dataProviders)return m.jsx(w,{...e,lang:a,fallbackLang:n,dataProviders:e.dataProviders});const i=e.blocks.filter(l=>{const o=b.getRegisteredChaiBlock(l._type);return!!(t.has(o,"dataProvider")&&t.isFunction(o.dataProvider))}).reduce((l,o)=>{const r=b.getRegisteredChaiBlock(o._type);if(!r||!r.dataProvider)return l;const c={pageProps:e.pageProps,block:o,lang:e.lang,draft:e.draft,inBuilder:!1};return l[o._id]=Promise.resolve(r.dataProvider(c)),l},{});return m.jsx(w,{...e,lang:a,fallbackLang:n,dataProviders:i})}function Q(e,a){const n=e.filter(s=>s._type==="GlobalBlock"||s._type==="PartialBlock");for(let s=0;s<n.length;s++){const i=n[s],l=t.get(i,"partialBlockId",t.get(i,"globalBlock",""));if(l==="")continue;let o=t.cloneDeep(t.get(a,l,[]));i._parent&&(o==null?void 0:o.length)>0&&(o=o.map(c=>(t.isEmpty(c._parent)&&(c._parent=i._parent),c)));const r=e.indexOf(i);e.splice(r,1,...o)}return e}const z=e=>{if(!e)return[];try{return JSON.parse(X(e)).filter(n=>!n._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function X(e){const a=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(a,n=>{const s=decodeURIComponent(n),i=s.indexOf("public");return i!==-1?s.substring(i+6):s})}async function Y(e,a=[],n=!1){return await F.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:a,theme:{extend:{...x.getChaiBuilderTheme(),keyframes:{"accordion-down":{from:{height:"0"},to:{height:"var(--radix-accordion-content-height)"}},"accordion-up":{from:{height:"var(--radix-accordion-content-height)"},to:{height:"0"}}},animation:{"accordion-down":"accordion-down 0.2s ease-out","accordion-up":"accordion-up 0.2s ease-out"}}},plugins:[K,M,j,q,x.chaiBuilderPlugin],corePlugins:{preflight:n}}}).generateStylesFromContent(` ${n?"@tailwind base;":""}
2
2
  @tailwind components;
3
3
  @tailwind utilities;`,e)}const Z=(e,a)=>{const n=JSON.stringify(e).replace(/#styles:([^"]*)/g,(s,i)=>`#styles:${i.replace(/^,/g," ")}`.replace(/#styles:/g,""));return Y([n],[],a)},ee=async(e,a=!1)=>await Z(e,a);exports.getChaiThemeCssVariables=L.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=L.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=L.getThemeFontsLinkMarkup;exports.applyChaiDataBinding=d.applyChaiDataBinding;exports.applyDesignTokens=d.applyDesignTokens;exports.convertHTMLToChaiBlocks=d.getBlocksFromHTML;exports.AsyncRenderChaiBlocks=G;exports.RenderChaiBlocks=J;exports.convertToBlocks=z;exports.getMergedPartialBlocks=Q;exports.getStylesForBlocks=ee;
package/dist/render.d.ts CHANGED
@@ -75,7 +75,10 @@ export declare const convertHTMLToChaiBlocks: (html: string) => ChaiBlock[];
75
75
  */
76
76
  export declare const convertToBlocks: (chaiFormatContent: string) => ChaiBlock[];
77
77
 
78
- export declare const getChaiThemeCssVariables: (chaiTheme: ChaiTheme) => string;
78
+ export declare const getChaiThemeCssVariables: ({ theme, fontVariables, }: {
79
+ theme: ChaiTheme;
80
+ fontVariables?: boolean;
81
+ }) => string;
79
82
 
80
83
  export declare function getMergedPartialBlocks(blocks: ChaiBlock[], partials: Record<string, ChaiBlock[]>): ChaiBlock[];
81
84
 
package/dist/render.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as De, b as xe, c as Ke } from "./plugin-C-ht41UZ.js";
1
+ import { a as De, b as xe, c as Ke } from "./plugin-DH3BDqys.js";
2
2
  import { a as O, b as N, c as E, d as J, e as C, f as j } from "./apply-binding-Bk2y-y_A.js";
3
3
  import { h as Ae, i as Fe, g as Me } from "./apply-binding-Bk2y-y_A.js";
4
4
  import { jsx as m } from "react/jsx-runtime";
@@ -10,7 +10,7 @@ import Y from "@tailwindcss/aspect-ratio";
10
10
  import Z from "@tailwindcss/container-queries";
11
11
  import ee from "@tailwindcss/forms";
12
12
  import te from "@tailwindcss/typography";
13
- import { c as ae, g as re } from "./get-chai-builder-theme-DDVRJQ6Z.js";
13
+ import { c as ae, g as re } from "./get-chai-builder-theme-CHXhAcdV.js";
14
14
  async function ne(e) {
15
15
  const t = {
16
16
  pageProps: e.pageProps,
@@ -1,5 +1,5 @@
1
1
  import { jsx as e, jsxs as l } from "react/jsx-runtime";
2
- import { h as D, D as N, e as S, f as j, g as v, N as w } from "./index-BN6yEl-H.js";
2
+ import { h as D, D as N, e as S, f as j, g as v, N as w } from "./index-iRqgNs2O.js";
3
3
  import { B } from "./register-chai-top-bar-CX_JkRJn.js";
4
4
  const M = ({
5
5
  isOpen: f,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-DWGTiEak.cjs"),p=require("./register-chai-top-bar-DWTuRU53.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"),s=require("./index-CfsIhbT2.cjs"),p=require("./register-chai-top-bar-DWTuRU53.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,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-CX_JkRJn.js";
3
- import { az as ne, c as M, a7 as ie, a8 as oe, P as le, aA as ce, ai as de, aB as ue, q as P } from "./index-BN6yEl-H.js";
4
- import { ar as D, as as G, A as _, ay as me } from "./index-BvluH-oT.js";
3
+ import { az as ne, c as M, a7 as ie, a8 as oe, P as le, aA as ce, ai as de, aB as ue, q as P } from "./index-iRqgNs2O.js";
4
+ import { ar as D, as as G, A as _, ay as me } from "./index-ckjNCVor.js";
5
5
  import { useQuery as K, useMutation as A, useQueryClient as pe } from "@tanstack/react-query";
6
6
  import { useSetAtom as fe } from "jotai";
7
7
  import { toast as N } from "sonner";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./register-chai-top-bar-DWTuRU53.cjs"),x=require("./index-DWGTiEak.cjs"),b=require("./index-BJVYKKJq.cjs"),C=require("@tanstack/react-query"),X=require("jotai"),j=require("sonner"),E=require("lucide-react"),i=require("react"),J=require("./image-compression-DZ9WMmyn.cjs"),R=require("lodash-es"),Z=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:b.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"})}})},ee=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useQuery({staleTime:"static",queryKey:[b.ACTIONS.GET_LIBRARY_ITEM,s],enabled:!!s,queryFn:async()=>{if(!s)return null;try{return await l(r,{action:b.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})},te=s=>{const r=b.useApiUrl(),l=b.useFetch(),t=X.useSetAtom(x.libraryBlocksAtom);return C.useMutation({mutationFn:async c=>l(r,{action:b.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:c}}),onSuccess:()=>{t(c=>{const m={...c};return Object.keys(m).forEach(u=>{m[u]={loading:"idle",blocks:[],error:!1}}),m}),s?s():j.toast.success("Block deleted successfully")},onError:c=>{console.error("Error deleting block:",c),j.toast.error("Failed to delete block",{description:c instanceof Error?c.message:"Unknown error"})}})},se=({blockId:s,libBlockId:r,isOpen:l,onClose:t,blockName:c,trigger:m})=>{const[u,o]=i.useState(!1),d=x.useUpdateBlocksPropsRealtime(),y=te(()=>{d([s],{_libBlockId:void 0}),j.toast.success("Block deleted successfully"),o(!1),t()}),h=()=>{o(!0),y.mutate(r)},g=e.jsxs(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:f=>f.preventDefault(),disabled:u,children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]});return e.jsxs(x.Popover,{open:l,onOpenChange:f=>!f&&t(),children:[e.jsx(x.PopoverTrigger,{asChild:!0,children:m||g}),e.jsx(x.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:[' "',c,'"']}),"?"]}),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(p.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:u,children:"Cancel"}),e.jsx(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:h,disabled:u,children:u?"Deleting...":"Delete"})]})]})})]})},re=({blockId:s,libBlockId:r,blockName:l,size:t="sm",className:c="",close:m})=>{const[u,o]=i.useState(!1);return e.jsx(se,{blockId:s,libBlockId:r,isOpen:u,onClose:()=>{o(!1),m()},blockName:l,trigger:e.jsxs(p.Button,{type:"button",variant:"destructive",size:t,className:c,onClick:()=>o(!0),children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})},ne=()=>{const s=b.useApiUrl(),r=b.useFetch(),l=C.useQueryClient(),{data:t=[],isLoading:c,error:m}=C.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await r(s,{action:"GET_LIBRARY_GROUPS"})||[]}catch(d){return console.error("Error fetching library groups:",d),[]}}}),{mutateAsync:u,isPending:o}=C.useMutation({mutationFn:async d=>{if(!d.trim())throw new Error("Group name is required");return r(s,{action:"CREATE_BLOCK_GROUP",data:{name:d}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),j.toast.success("Group created successfully")},onError:d=>{console.error("Error creating group:",d),j.toast.error("Failed to create group",{description:d instanceof Error?d.message:"Unknown error"})}});return{groups:t,isLoading:c,error:m,createGroup:u,isCreating:o}},ae=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),[c,m]=i.useState(""),u=i.useRef(null),{groups:o}=ne(),[d,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"}]),h=i.useMemo(()=>[...o,...d.filter(n=>!o.some(B=>B.id===n.id))],[o,d]),g=()=>{const n=c.trim();if(!n)return;const B={id:n,name:n};y(w=>[...w,B]),r(B.id),m(""),t(!1)};i.useEffect(()=>{l&&u.current&&u.current.focus()},[l]);const f=n=>{n.key==="Enter"&&(n.preventDefault(),g())};return i.useEffect(()=>{s&&!h.some(n=>n.id===s)&&r("")},[s,h,r]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(p.Input,{ref:u,placeholder:"Enter new group name",value:c,onChange:n=>m(n.target.value),onKeyDown:f}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(p.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(p.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}`))}),d.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:d.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(p.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(E.Plus,{className:"h-4 w-4"})})]})},oe=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),c=i.useRef(null),m=i.useCallback(async d=>{var h;const y=(h=d.target.files)==null?void 0:h[0];if(y)try{t(!0);let g=y;y.type.startsWith("image/")&&(g=await J.compressImageIfNeeded(y));const f=new FileReader;f.onloadend=()=>{r(f.result),t(!1)},f.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]),u=()=>{r(""),c.current&&(c.current.value="")},o=()=>{var d;(d=c.current)==null||d.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p.Input,{type:"file",ref:c,onChange:m,accept:"image/*",className:"hidden"}),e.jsx(p.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(p.Button,{type:"button",variant:"outline",size:"icon",onClick:u,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"})})]})},ie=s=>{const{blocks:r,close:l,blockId:t}=s,{getPartailBlocks:c}=x.usePartialBlocksStore(),m=r.find(a=>a._id===t),u=m==null?void 0:m._libBlockId,o=!!u,d=i.useMemo(()=>r.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[r]),y=i.useMemo(()=>{let a=[];for(const k of r)if(k._type==="PartialBlock"||k._type==="GlobalBlock"){let v=c(k.partialBlockId);k._parent&&(v==null?void 0:v.length)>0&&(v=v.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",k._parent),T))),a=[...a,...v]}else a.push(k);return a},[r,c]),[h,g]=i.useState(""),[f,n]=i.useState(""),[B,w]=i.useState(""),[S,_]=i.useState(""),[N,U]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=x.usePermissions(),Q=Y(b.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=x.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),j.toast.success("Block delinked from library"),l()},{data:I,isLoading:P,isError:G}=ee(u);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=h.trim().length>=2,k=f.trim()!=="";M(a&&k)},[h,f]);const W=()=>{const a={};return h.trim()?h.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",f||(a.group="Group is required"),U(a),Object.keys(a).length===0},{resetLibrary:$}=x.useLibraryBlocks({id:""}),A=Z(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 k=y.map(v=>(R.has(v,"_libBlockId")&&delete v._libBlockId,v));A.mutate({name:h.trim(),group:f,blocks:k,description:B.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:u}:{}})},L=A.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(p.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(p.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[d&&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(x.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(p.Input,{id:"name",placeholder:"Enter block name",value:h,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(x.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ae,{value:f,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(x.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(p.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(x.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(oe,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(re,{blockId:t,libBlockId:u,blockName:h,className:"mr-auto",close:l}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(p.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=ie;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./register-chai-top-bar-DWTuRU53.cjs"),x=require("./index-CfsIhbT2.cjs"),b=require("./index-BGGNVIKx.cjs"),C=require("@tanstack/react-query"),X=require("jotai"),j=require("sonner"),E=require("lucide-react"),i=require("react"),J=require("./image-compression-DZ9WMmyn.cjs"),R=require("lodash-es"),Z=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:b.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"})}})},ee=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useQuery({staleTime:"static",queryKey:[b.ACTIONS.GET_LIBRARY_ITEM,s],enabled:!!s,queryFn:async()=>{if(!s)return null;try{return await l(r,{action:b.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})},te=s=>{const r=b.useApiUrl(),l=b.useFetch(),t=X.useSetAtom(x.libraryBlocksAtom);return C.useMutation({mutationFn:async c=>l(r,{action:b.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:c}}),onSuccess:()=>{t(c=>{const m={...c};return Object.keys(m).forEach(u=>{m[u]={loading:"idle",blocks:[],error:!1}}),m}),s?s():j.toast.success("Block deleted successfully")},onError:c=>{console.error("Error deleting block:",c),j.toast.error("Failed to delete block",{description:c instanceof Error?c.message:"Unknown error"})}})},se=({blockId:s,libBlockId:r,isOpen:l,onClose:t,blockName:c,trigger:m})=>{const[u,o]=i.useState(!1),d=x.useUpdateBlocksPropsRealtime(),y=te(()=>{d([s],{_libBlockId:void 0}),j.toast.success("Block deleted successfully"),o(!1),t()}),h=()=>{o(!0),y.mutate(r)},g=e.jsxs(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:f=>f.preventDefault(),disabled:u,children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]});return e.jsxs(x.Popover,{open:l,onOpenChange:f=>!f&&t(),children:[e.jsx(x.PopoverTrigger,{asChild:!0,children:m||g}),e.jsx(x.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:[' "',c,'"']}),"?"]}),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(p.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:u,children:"Cancel"}),e.jsx(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:h,disabled:u,children:u?"Deleting...":"Delete"})]})]})})]})},re=({blockId:s,libBlockId:r,blockName:l,size:t="sm",className:c="",close:m})=>{const[u,o]=i.useState(!1);return e.jsx(se,{blockId:s,libBlockId:r,isOpen:u,onClose:()=>{o(!1),m()},blockName:l,trigger:e.jsxs(p.Button,{type:"button",variant:"destructive",size:t,className:c,onClick:()=>o(!0),children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})},ne=()=>{const s=b.useApiUrl(),r=b.useFetch(),l=C.useQueryClient(),{data:t=[],isLoading:c,error:m}=C.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await r(s,{action:"GET_LIBRARY_GROUPS"})||[]}catch(d){return console.error("Error fetching library groups:",d),[]}}}),{mutateAsync:u,isPending:o}=C.useMutation({mutationFn:async d=>{if(!d.trim())throw new Error("Group name is required");return r(s,{action:"CREATE_BLOCK_GROUP",data:{name:d}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),j.toast.success("Group created successfully")},onError:d=>{console.error("Error creating group:",d),j.toast.error("Failed to create group",{description:d instanceof Error?d.message:"Unknown error"})}});return{groups:t,isLoading:c,error:m,createGroup:u,isCreating:o}},ae=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),[c,m]=i.useState(""),u=i.useRef(null),{groups:o}=ne(),[d,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"}]),h=i.useMemo(()=>[...o,...d.filter(n=>!o.some(B=>B.id===n.id))],[o,d]),g=()=>{const n=c.trim();if(!n)return;const B={id:n,name:n};y(w=>[...w,B]),r(B.id),m(""),t(!1)};i.useEffect(()=>{l&&u.current&&u.current.focus()},[l]);const f=n=>{n.key==="Enter"&&(n.preventDefault(),g())};return i.useEffect(()=>{s&&!h.some(n=>n.id===s)&&r("")},[s,h,r]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(p.Input,{ref:u,placeholder:"Enter new group name",value:c,onChange:n=>m(n.target.value),onKeyDown:f}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(p.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(p.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}`))}),d.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:d.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(p.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(E.Plus,{className:"h-4 w-4"})})]})},oe=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),c=i.useRef(null),m=i.useCallback(async d=>{var h;const y=(h=d.target.files)==null?void 0:h[0];if(y)try{t(!0);let g=y;y.type.startsWith("image/")&&(g=await J.compressImageIfNeeded(y));const f=new FileReader;f.onloadend=()=>{r(f.result),t(!1)},f.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]),u=()=>{r(""),c.current&&(c.current.value="")},o=()=>{var d;(d=c.current)==null||d.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p.Input,{type:"file",ref:c,onChange:m,accept:"image/*",className:"hidden"}),e.jsx(p.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(p.Button,{type:"button",variant:"outline",size:"icon",onClick:u,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"})})]})},ie=s=>{const{blocks:r,close:l,blockId:t}=s,{getPartailBlocks:c}=x.usePartialBlocksStore(),m=r.find(a=>a._id===t),u=m==null?void 0:m._libBlockId,o=!!u,d=i.useMemo(()=>r.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[r]),y=i.useMemo(()=>{let a=[];for(const k of r)if(k._type==="PartialBlock"||k._type==="GlobalBlock"){let v=c(k.partialBlockId);k._parent&&(v==null?void 0:v.length)>0&&(v=v.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",k._parent),T))),a=[...a,...v]}else a.push(k);return a},[r,c]),[h,g]=i.useState(""),[f,n]=i.useState(""),[B,w]=i.useState(""),[S,_]=i.useState(""),[N,U]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=x.usePermissions(),Q=Y(b.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=x.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),j.toast.success("Block delinked from library"),l()},{data:I,isLoading:P,isError:G}=ee(u);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=h.trim().length>=2,k=f.trim()!=="";M(a&&k)},[h,f]);const W=()=>{const a={};return h.trim()?h.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",f||(a.group="Group is required"),U(a),Object.keys(a).length===0},{resetLibrary:$}=x.useLibraryBlocks({id:""}),A=Z(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 k=y.map(v=>(R.has(v,"_libBlockId")&&delete v._libBlockId,v));A.mutate({name:h.trim(),group:f,blocks:k,description:B.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:u}:{}})},L=A.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(p.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(p.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[d&&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(x.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(p.Input,{id:"name",placeholder:"Enter block name",value:h,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(x.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ae,{value:f,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(x.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(p.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(x.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(oe,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(re,{blockId:t,libBlockId:u,blockName:h,className:"mr-auto",close:l}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(p.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=ie;