@templatical/editor 0.48.0 → 0.50.0

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 (396) hide show
  1. package/README.md +4 -2
  2. package/dist/AiAltTextPopover-BZQ95GXL.js +106 -0
  3. package/dist/AiAltTextReview-DoBEudnE.js +206 -0
  4. package/dist/AiChatPanel-Bs6sES3b.js +550 -0
  5. package/dist/AiHeaderMenu-BEaTazx4.js +36 -0
  6. package/dist/AiPanels-CfN7A-ZA.js +33 -0
  7. package/dist/AiRewriteMenu-C3ZfDDYy.js +276 -0
  8. package/dist/{BlockIssueBadge-BShkuJis.js → BlockIssueBadge-CKwZ1Vgn.js} +11 -11
  9. package/dist/{BlockPreviewCanvas-tzAtDkXH.js → BlockPreviewCanvas-BXNLLLYi.js} +33 -33
  10. package/dist/CloudHeaderExtras-CsJMEiyN.js +23 -0
  11. package/dist/CloudPanels-B4F5m7vy.js +168 -0
  12. package/dist/CollaborationNotices-CNuDp7Y2.js +76 -0
  13. package/dist/CollaboratorBar-BtHPiuHq.js +123 -0
  14. package/dist/{CommentsPanel-DiWzYtnZ.js → CommentsPanel-CyCM-BvT.js} +4 -4
  15. package/dist/CommentsSidebar-Ca3DyFOX.js +500 -0
  16. package/dist/{cdn/chunks/CountdownBlock-Dasj191h.js → CountdownBlock-DR4Xm2-T.js} +24 -26
  17. package/dist/{CountdownToolbar-C4y3Ft7H.js → CountdownToolbar-CEIMPojJ.js} +56 -56
  18. package/dist/IssuesPanel-C8nMUccy.js +360 -0
  19. package/dist/{LoadingTrack-6XsqodoY.js → LoadingTrack-B0RKQWq3.js} +2 -2
  20. package/dist/{LogicTagInsertButton-B1_Wy0AN.js → LogicTagInsertButton-CqfU52CO.js} +272 -267
  21. package/dist/{cdn/chunks/MediaEditModal-zXfcArr4.js → MediaEditModal-DHtkZ4OU.js} +202 -186
  22. package/dist/{MediaPanels-9mDBv4aL.js → MediaPanels-CGcOB2pR.js} +4 -4
  23. package/dist/{MergeTagInput-fOewuF27.js → MergeTagInput-YnEkorTZ.js} +26 -26
  24. package/dist/{MergeTagModeToggle-BXamLcv7.js → MergeTagModeToggle-Dhb1DAcQ.js} +40 -40
  25. package/dist/MergeTagTextarea-e4lnwtqZ.js +70 -0
  26. package/dist/ParagraphEditor-B6NK0ytw.js +799 -0
  27. package/dist/{RestoreVersionDialog-BEKXx9xk.js → RestoreVersionDialog-Bq_IGOLJ.js} +22 -22
  28. package/dist/{RichTextEditorContent-D7kp7iig.js → RichTextEditorContent-AOM6fylS.js} +48 -48
  29. package/dist/{SaveBlockDialog-SJu0lecx.js → SaveBlockDialog-C8GngfQx.js} +88 -88
  30. package/dist/{cdn/chunks/SavedBlocksBrowserModal-CtnB58p_.js → SavedBlocksBrowserModal-wnkvxpm_.js} +102 -99
  31. package/dist/{SavedBlocksPanels-Dr5Fxx9Z.js → SavedBlocksPanels-C2s3q0pJ.js} +9 -9
  32. package/dist/{SavedBlocksPickBar-DnEWBZJy.js → SavedBlocksPickBar-BjcTiV87.js} +14 -14
  33. package/dist/TemplateSettings-BVBWpiDU.js +237 -0
  34. package/dist/{TestEmailModal-CbRY8HQx.js → TestEmailModal-SyhO9bn3.js} +57 -57
  35. package/dist/{TestEmailPanel-NAOmt3xi.js → TestEmailPanel-BDd2Rtav.js} +4 -4
  36. package/dist/{TitleEditor-Cc3DHbuN.js → TitleEditor-pxD53y_l.js} +75 -75
  37. package/dist/ToggleSwitch-D51U9cmR.js +37 -0
  38. package/dist/Toolbar-CZSPZYbj.js +3153 -0
  39. package/dist/{TplModal-Bz4-IZ9R.js → TplModal-DCzBzicE.js} +19 -19
  40. package/dist/{VersionHistoryMenu-CjV1d1zk.js → VersionHistoryMenu-BQeWPT85.js} +35 -35
  41. package/dist/{VersionHistoryPanels-BtwxrKJn.js → VersionHistoryPanels-BBm7YbRQ.js} +5 -5
  42. package/dist/{VersionPreviewBanner-BLAei1kj.js → VersionPreviewBanner-DUGF0tUJ.js} +10 -10
  43. package/dist/WrapperBlock-BO619LAb.js +45 -0
  44. package/dist/aiErrors-D5UOoYOt.js +41 -0
  45. package/dist/aiImageContext-BH4Ss1h3.js +48 -0
  46. package/dist/aiRewritePreview-DLGM05Ge.js +44 -0
  47. package/dist/{blockTypeIcons-CEDZytqP.js → blockTypeIcons-NzaYvAI4.js} +15 -14
  48. package/dist/bundle-stats.json +8 -8
  49. package/dist/{cdn/chunks/ca-CbNzJM3I.js → ca-C7mTzW1r.js} +147 -8
  50. package/dist/cdn/chunks/AiAltTextPopover-CQu0Q_ZX.js +107 -0
  51. package/dist/cdn/chunks/AiAltTextPopover-CQu0Q_ZX.js.map +1 -0
  52. package/dist/cdn/chunks/AiAltTextReview-CI2HbWfn.js +207 -0
  53. package/dist/cdn/chunks/AiAltTextReview-CI2HbWfn.js.map +1 -0
  54. package/dist/cdn/chunks/AiChatPanel-BYqn1bKu.js +476 -0
  55. package/dist/cdn/chunks/AiChatPanel-BYqn1bKu.js.map +1 -0
  56. package/dist/cdn/chunks/AiHeaderMenu-oldAAFyL.js +37 -0
  57. package/dist/cdn/chunks/AiHeaderMenu-oldAAFyL.js.map +1 -0
  58. package/dist/cdn/chunks/AiPanels-CIFKQv8Y.js +34 -0
  59. package/dist/cdn/chunks/AiPanels-CIFKQv8Y.js.map +1 -0
  60. package/dist/cdn/chunks/AiRewriteMenu-Bhh71zcc.js +208 -0
  61. package/dist/cdn/chunks/AiRewriteMenu-Bhh71zcc.js.map +1 -0
  62. package/dist/cdn/chunks/{BlockIssueBadge-C7sdnkrF.js → BlockIssueBadge-DAn2vsMJ.js} +13 -13
  63. package/dist/cdn/chunks/{BlockIssueBadge-C7sdnkrF.js.map → BlockIssueBadge-DAn2vsMJ.js.map} +1 -1
  64. package/dist/cdn/chunks/{BlockPreviewCanvas-vK5tBazr.js → BlockPreviewCanvas-D0--EQkP.js} +39 -39
  65. package/dist/cdn/chunks/{BlockPreviewCanvas-vK5tBazr.js.map → BlockPreviewCanvas-D0--EQkP.js.map} +1 -1
  66. package/dist/cdn/chunks/CloudHeaderExtras-DaUU8P8R.js +25 -0
  67. package/dist/cdn/chunks/CloudHeaderExtras-DaUU8P8R.js.map +1 -0
  68. package/dist/cdn/chunks/{CloudPanels-awqHfJqC.js → CloudPanels-C3jsxo_f.js} +52 -100
  69. package/dist/cdn/chunks/CloudPanels-C3jsxo_f.js.map +1 -0
  70. package/dist/cdn/chunks/CollaborationNotices-DjRI8gvs.js +78 -0
  71. package/dist/cdn/chunks/CollaborationNotices-DjRI8gvs.js.map +1 -0
  72. package/dist/cdn/chunks/CollaboratorBar-Dfzm6A9A.js +72 -0
  73. package/dist/cdn/chunks/CollaboratorBar-Dfzm6A9A.js.map +1 -0
  74. package/dist/cdn/chunks/CommentsPanel-CSO79OeX.js +20 -0
  75. package/dist/cdn/chunks/{CommentsPanel-CbzxwsyI.js.map → CommentsPanel-CSO79OeX.js.map} +1 -1
  76. package/dist/cdn/chunks/CommentsSidebar-CCvplq1Z.js +470 -0
  77. package/dist/cdn/chunks/{CommentsSidebar-DWPHZuQm.js.map → CommentsSidebar-CCvplq1Z.js.map} +1 -1
  78. package/dist/{CountdownBlock-zx39Dyby.js → cdn/chunks/CountdownBlock-C6USdwk3.js} +19 -17
  79. package/dist/cdn/chunks/{CountdownBlock-Dasj191h.js.map → CountdownBlock-C6USdwk3.js.map} +1 -1
  80. package/dist/cdn/chunks/{CountdownToolbar-Cqg8FUH-.js → CountdownToolbar-Cjud2Tos.js} +71 -71
  81. package/dist/cdn/chunks/{CountdownToolbar-Cqg8FUH-.js.map → CountdownToolbar-Cjud2Tos.js.map} +1 -1
  82. package/dist/cdn/chunks/IssuesPanel-BaWHPDxZ.js +340 -0
  83. package/dist/cdn/chunks/IssuesPanel-BaWHPDxZ.js.map +1 -0
  84. package/dist/cdn/chunks/{LoadingTrack-DbH97JR9.js → LoadingTrack-BIcL4NiY.js} +2 -2
  85. package/dist/cdn/chunks/{LoadingTrack-DbH97JR9.js.map → LoadingTrack-BIcL4NiY.js.map} +1 -1
  86. package/dist/cdn/chunks/{LogicTagInsertButton-BMB9vShs.js → LogicTagInsertButton-CsL2JDOG.js} +374 -369
  87. package/dist/cdn/chunks/LogicTagInsertButton-CsL2JDOG.js.map +1 -0
  88. package/dist/{MediaEditModal-ByOvznRC.js → cdn/chunks/MediaEditModal-BuHCiyMu.js} +544 -560
  89. package/dist/cdn/chunks/MediaEditModal-BuHCiyMu.js.map +1 -0
  90. package/dist/cdn/chunks/MediaPanels-DAgUf_T1.js +45 -0
  91. package/dist/cdn/chunks/{MediaPanels-Cp4XB_dH.js.map → MediaPanels-DAgUf_T1.js.map} +1 -1
  92. package/dist/cdn/chunks/{MergeTagInput-DLqrA9co.js → MergeTagInput-C8U-7LxL.js} +34 -34
  93. package/dist/cdn/chunks/{MergeTagInput-DLqrA9co.js.map → MergeTagInput-C8U-7LxL.js.map} +1 -1
  94. package/dist/cdn/chunks/{MergeTagModeToggle-BRiJzzn5.js → MergeTagModeToggle-Mm-p0A52.js} +41 -41
  95. package/dist/cdn/chunks/{MergeTagModeToggle-BRiJzzn5.js.map → MergeTagModeToggle-Mm-p0A52.js.map} +1 -1
  96. package/dist/cdn/chunks/MergeTagTextarea-DuLScsWM.js +72 -0
  97. package/dist/cdn/chunks/MergeTagTextarea-DuLScsWM.js.map +1 -0
  98. package/dist/cdn/chunks/ParagraphEditor-CqSj6Ayz.js +634 -0
  99. package/dist/cdn/chunks/ParagraphEditor-CqSj6Ayz.js.map +1 -0
  100. package/dist/cdn/chunks/{RestoreVersionDialog-BgR6RXSb.js → RestoreVersionDialog-CdA5osuA.js} +26 -26
  101. package/dist/cdn/chunks/{RestoreVersionDialog-BgR6RXSb.js.map → RestoreVersionDialog-CdA5osuA.js.map} +1 -1
  102. package/dist/cdn/chunks/{RichTextEditorContent-C4DMAn0g.js → RichTextEditorContent-Q1d2xqBT.js} +46 -46
  103. package/dist/cdn/chunks/{RichTextEditorContent-C4DMAn0g.js.map → RichTextEditorContent-Q1d2xqBT.js.map} +1 -1
  104. package/dist/cdn/chunks/{SaveBlockDialog-BaIsQd09.js → SaveBlockDialog-CijargAy.js} +78 -78
  105. package/dist/cdn/chunks/{SaveBlockDialog-BaIsQd09.js.map → SaveBlockDialog-CijargAy.js.map} +1 -1
  106. package/dist/cdn/chunks/SavedBlocksBrowserModal-DtOz_X5S.js +357 -0
  107. package/dist/cdn/chunks/{SavedBlocksBrowserModal-CtnB58p_.js.map → SavedBlocksBrowserModal-DtOz_X5S.js.map} +1 -1
  108. package/dist/cdn/chunks/SavedBlocksPanels-BowyED5h.js +38 -0
  109. package/dist/cdn/chunks/{SavedBlocksPanels-BhEOMzEQ.js.map → SavedBlocksPanels-BowyED5h.js.map} +1 -1
  110. package/dist/cdn/chunks/{SavedBlocksPickBar-CcdqTEIp.js → SavedBlocksPickBar-BPRaJBv3.js} +19 -19
  111. package/dist/cdn/chunks/{SavedBlocksPickBar-CcdqTEIp.js.map → SavedBlocksPickBar-BPRaJBv3.js.map} +1 -1
  112. package/dist/cdn/chunks/TemplateSettings-ByZeBO34.js +209 -0
  113. package/dist/cdn/chunks/{TemplateSettings-BkkWTDHD.js.map → TemplateSettings-ByZeBO34.js.map} +1 -1
  114. package/dist/cdn/chunks/{TestEmailModal-V5mwHsUV.js → TestEmailModal-BUVTj3Ic.js} +54 -54
  115. package/dist/cdn/chunks/{TestEmailModal-V5mwHsUV.js.map → TestEmailModal-BUVTj3Ic.js.map} +1 -1
  116. package/dist/cdn/chunks/TestEmailPanel-BxutYoWg.js +35 -0
  117. package/dist/cdn/chunks/{TestEmailPanel-DxrKuctP.js.map → TestEmailPanel-BxutYoWg.js.map} +1 -1
  118. package/dist/cdn/chunks/TitleEditor-Ccv6uoTz.js +199 -0
  119. package/dist/cdn/chunks/{TitleEditor-CsZiG3TT.js.map → TitleEditor-Ccv6uoTz.js.map} +1 -1
  120. package/dist/cdn/chunks/ToggleSwitch-Ctdmj621.js +39 -0
  121. package/dist/cdn/chunks/ToggleSwitch-Ctdmj621.js.map +1 -0
  122. package/dist/cdn/chunks/{Toolbar-C_x2TfFk.js → Toolbar-DoprRgTn.js} +1097 -1101
  123. package/dist/cdn/chunks/Toolbar-DoprRgTn.js.map +1 -0
  124. package/dist/cdn/chunks/{TplModal-DC_eodTV.js → TplModal-BXQzmsJX.js} +21 -21
  125. package/dist/cdn/chunks/{TplModal-DC_eodTV.js.map → TplModal-BXQzmsJX.js.map} +1 -1
  126. package/dist/cdn/chunks/{VersionHistoryMenu-DXnM5Df2.js → VersionHistoryMenu-BF2fNCvq.js} +41 -41
  127. package/dist/cdn/chunks/{VersionHistoryMenu-DXnM5Df2.js.map → VersionHistoryMenu-BF2fNCvq.js.map} +1 -1
  128. package/dist/cdn/chunks/VersionHistoryPanels-Dal0Uk69.js +48 -0
  129. package/dist/cdn/chunks/{VersionHistoryPanels-DXSqmaLS.js.map → VersionHistoryPanels-Dal0Uk69.js.map} +1 -1
  130. package/dist/cdn/chunks/{VersionPreviewBanner-DKyN6BhO.js → VersionPreviewBanner-BaGcn-b1.js} +13 -13
  131. package/dist/cdn/chunks/{VersionPreviewBanner-DKyN6BhO.js.map → VersionPreviewBanner-BaGcn-b1.js.map} +1 -1
  132. package/dist/cdn/chunks/WrapperBlock-DkQJtLz0.js +47 -0
  133. package/dist/cdn/chunks/{WrapperBlock-gG_Bleug.js.map → WrapperBlock-DkQJtLz0.js.map} +1 -1
  134. package/dist/cdn/chunks/aiErrors-D5UOoYOt.js +43 -0
  135. package/dist/cdn/chunks/aiErrors-D5UOoYOt.js.map +1 -0
  136. package/dist/cdn/chunks/aiImageContext-BH4Ss1h3.js +50 -0
  137. package/dist/cdn/chunks/aiImageContext-BH4Ss1h3.js.map +1 -0
  138. package/dist/cdn/chunks/aiRewritePreview-DLGM05Ge.js +46 -0
  139. package/dist/cdn/chunks/aiRewritePreview-DLGM05Ge.js.map +1 -0
  140. package/dist/cdn/chunks/blockTypeIcons-ikZAmd6U.js +22 -0
  141. package/dist/cdn/chunks/{blockTypeIcons-HrMJDfVg.js.map → blockTypeIcons-ikZAmd6U.js.map} +1 -1
  142. package/dist/{ca-CbNzJM3I.js → cdn/chunks/ca-C7mTzW1r.js} +149 -6
  143. package/dist/cdn/chunks/ca-C7mTzW1r.js.map +1 -0
  144. package/dist/cdn/chunks/createCloudRuntime-DpBWhrv3.js +1408 -0
  145. package/dist/cdn/chunks/createCloudRuntime-DpBWhrv3.js.map +1 -0
  146. package/dist/cdn/chunks/de-DBOTcDj2.js +22 -0
  147. package/dist/cdn/chunks/de-DBOTcDj2.js.map +1 -0
  148. package/dist/{de-DMquBpZM.js → cdn/chunks/de-DNuYQTmS.js} +149 -6
  149. package/dist/cdn/chunks/de-DNuYQTmS.js.map +1 -0
  150. package/dist/{dist-CUWI-IvA.js → cdn/chunks/dist-Bo8Thh8v.js} +60 -58
  151. package/dist/cdn/chunks/{dist-CjL6JHML.js.map → dist-Bo8Thh8v.js.map} +1 -1
  152. package/dist/cdn/chunks/dist-S-rLGqax.js +406 -0
  153. package/dist/cdn/chunks/{dist-MNQYSEWU.js.map → dist-S-rLGqax.js.map} +1 -1
  154. package/dist/cdn/chunks/{draggable-DrsNwZuB.js → draggable-DZ0gwUJ6.js} +1359 -1266
  155. package/dist/cdn/chunks/draggable-DZ0gwUJ6.js.map +1 -0
  156. package/dist/cdn/chunks/{editor-modal-vEEmZ8Tu.js → editor-modal-CI6EfeMd.js} +881 -881
  157. package/dist/cdn/chunks/{editor-modal-vEEmZ8Tu.js.map → editor-modal-CI6EfeMd.js.map} +1 -1
  158. package/dist/cdn/chunks/en-CDhWRrF_.js +22 -0
  159. package/dist/cdn/chunks/en-CDhWRrF_.js.map +1 -0
  160. package/dist/{en-C8Mp71sO.js → cdn/chunks/en-CW71OK66.js} +149 -6
  161. package/dist/cdn/chunks/en-CW71OK66.js.map +1 -0
  162. package/dist/cdn/chunks/en-ifvu6oPv.js +1 -0
  163. package/dist/{es-Byq4tthI.js → cdn/chunks/es-DdK7zQfi.js} +149 -6
  164. package/dist/cdn/chunks/es-DdK7zQfi.js.map +1 -0
  165. package/dist/cdn/chunks/{extensions-hJ9VqzDc.js → extensions-taJTZlLK.js} +71 -71
  166. package/dist/cdn/chunks/{extensions-hJ9VqzDc.js.map → extensions-taJTZlLK.js.map} +1 -1
  167. package/dist/{fr-B3j35HEw.js → cdn/chunks/fr-Dz5Bgb7-.js} +149 -6
  168. package/dist/cdn/chunks/fr-Dz5Bgb7-.js.map +1 -0
  169. package/dist/cdn/chunks/{icons-aTYwH5-g.js → icons-DNX6StSs.js} +183 -150
  170. package/dist/cdn/chunks/icons-DNX6StSs.js.map +1 -0
  171. package/dist/{ja-D7txAuGS.js → cdn/chunks/ja-Di-zJiT8.js} +149 -6
  172. package/dist/cdn/chunks/ja-Di-zJiT8.js.map +1 -0
  173. package/dist/cdn/chunks/keys-BTpmg2Tt.js +12 -0
  174. package/dist/cdn/chunks/keys-BTpmg2Tt.js.map +1 -0
  175. package/dist/{logger-BBlvSn6q.js → cdn/chunks/logger-Tj0RPskW.js} +7 -1
  176. package/dist/cdn/chunks/logger-Tj0RPskW.js.map +1 -0
  177. package/dist/{nl-ClJ3BY3F.js → cdn/chunks/nl-CvVuHYFL.js} +149 -6
  178. package/dist/cdn/chunks/nl-CvVuHYFL.js.map +1 -0
  179. package/dist/cdn/chunks/normalizeMergeTagMarkup-DyePIGqu.js +199 -0
  180. package/dist/cdn/chunks/normalizeMergeTagMarkup-DyePIGqu.js.map +1 -0
  181. package/dist/cdn/chunks/{preRenderCustomBlocks-ByfuSjtL.js → preRenderCustomBlocks-Dc-QLntG.js} +4 -4
  182. package/dist/cdn/chunks/{preRenderCustomBlocks-ByfuSjtL.js.map → preRenderCustomBlocks-Dc-QLntG.js.map} +1 -1
  183. package/dist/cdn/chunks/pt-BR-CHM-ZKvE.js +22 -0
  184. package/dist/cdn/chunks/pt-BR-CHM-ZKvE.js.map +1 -0
  185. package/dist/{pt-BR-DibcXcmv.js → cdn/chunks/pt-BR-ZhO4vgyq.js} +149 -6
  186. package/dist/cdn/chunks/pt-BR-ZhO4vgyq.js.map +1 -0
  187. package/dist/cdn/chunks/{pusher-C8DeiO2X.js → pusher-Cs4GGEtd.js} +2 -2
  188. package/dist/cdn/chunks/pusher-Cs4GGEtd.js.map +1 -0
  189. package/dist/cdn/chunks/{rolldown-runtime-B0aSnxlc.js → rolldown-runtime-Y_bBpyJl.js} +1 -1
  190. package/dist/cdn/chunks/sanitizeRichTextHtml-DeISfLFr.js +62 -0
  191. package/dist/cdn/chunks/sanitizeRichTextHtml-DeISfLFr.js.map +1 -0
  192. package/dist/cdn/chunks/socialIcons-BBvsTwCV.js +2032 -0
  193. package/dist/cdn/chunks/socialIcons-BBvsTwCV.js.map +1 -0
  194. package/dist/cdn/chunks/{src-DYCDeBDM.js → src-BNFnxfrA.js} +694 -329
  195. package/dist/cdn/chunks/src-BNFnxfrA.js.map +1 -0
  196. package/dist/cdn/chunks/{src-dZ4D_tuP.js → src-BcTUmgLe.js} +181 -181
  197. package/dist/cdn/chunks/src-BcTUmgLe.js.map +1 -0
  198. package/dist/cdn/chunks/src-Bs_yxk3h.js +4392 -0
  199. package/dist/cdn/chunks/src-Bs_yxk3h.js.map +1 -0
  200. package/dist/cdn/chunks/{styleConstants-D1Jz-TFU.js → styleConstants-v1dNKgJf.js} +2 -4
  201. package/dist/cdn/chunks/{styleConstants-D1Jz-TFU.js.map → styleConstants-v1dNKgJf.js.map} +1 -1
  202. package/dist/cdn/chunks/{tiptap-BPigZk5G.js → tiptap-CtVrAViq.js} +44 -44
  203. package/dist/cdn/chunks/tiptap-CtVrAViq.js.map +1 -0
  204. package/dist/cdn/chunks/{useCloudI18n-BBF4waXO.js → useCloudI18n-AVXhzbhQ.js} +4 -4
  205. package/dist/cdn/chunks/{useCloudI18n-BBF4waXO.js.map → useCloudI18n-AVXhzbhQ.js.map} +1 -1
  206. package/dist/cdn/chunks/useEditorCore-CCVFi1YZ.js +2586 -0
  207. package/dist/cdn/chunks/useEditorCore-CCVFi1YZ.js.map +1 -0
  208. package/dist/cdn/chunks/useEditorRoot-CR5GjJD6.js +10 -0
  209. package/dist/cdn/chunks/{useEditorRoot-CTc6O8al.js.map → useEditorRoot-CR5GjJD6.js.map} +1 -1
  210. package/dist/cdn/chunks/{useI18n-DUlyyIJJ.js → useI18n-CbVubQhM.js} +3 -3
  211. package/dist/cdn/chunks/{useI18n-DUlyyIJJ.js.map → useI18n-CbVubQhM.js.map} +1 -1
  212. package/dist/cdn/chunks/{useLogicTag-HsyUCQtl.js → useLogicTag-B49Nc53Y.js} +5 -5
  213. package/dist/cdn/chunks/{useLogicTag-HsyUCQtl.js.map → useLogicTag-B49Nc53Y.js.map} +1 -1
  214. package/dist/cdn/chunks/{useMergeTag-Dg9pE85U.js → useMergeTag-B0KryMj8.js} +7 -7
  215. package/dist/cdn/chunks/{useMergeTag-Dg9pE85U.js.map → useMergeTag-B0KryMj8.js.map} +1 -1
  216. package/dist/cdn/chunks/{usePopoverPosition-IbaW6-Ao.js → usePopoverPosition-C829ps5i.js} +4 -4
  217. package/dist/cdn/chunks/{usePopoverPosition-IbaW6-Ao.js.map → usePopoverPosition-C829ps5i.js.map} +1 -1
  218. package/dist/cdn/chunks/useScrollToBlock-CAwvulog.js +51 -0
  219. package/dist/cdn/chunks/useScrollToBlock-CAwvulog.js.map +1 -0
  220. package/dist/cdn/chunks/{withCurrentFont-oLcATrQ8.js → withCurrentFont-DFPXeVfG.js} +2 -2
  221. package/dist/cdn/chunks/{withCurrentFont-oLcATrQ8.js.map → withCurrentFont-DFPXeVfG.js.map} +1 -1
  222. package/dist/cdn/editor.css +1 -1
  223. package/dist/cdn/editor.js +2235 -1311
  224. package/dist/cdn/editor.js.map +1 -1
  225. package/dist/{check-ClwqRMgv.js → check-yYsp5Xpk.js} +1 -1
  226. package/dist/{chevron-down-te6qn-zE.js → chevron-down-DTmD06_j.js} +1 -1
  227. package/dist/{chevron-right-W2hbH1FM.js → chevron-right-BSeYZOxc.js} +1 -1
  228. package/dist/{chevron-up-Bf5Zo7o4.js → chevron-up-BOApwrxi.js} +1 -1
  229. package/dist/{circle-alert-CIEGV5DN.js → circle-alert-BMszY8im.js} +1 -1
  230. package/dist/{clock-Y4cx0gkJ.js → clock-HADxnl6-.js} +1 -1
  231. package/dist/createCloudRuntime-DVQI_ReU.js +1379 -0
  232. package/dist/{createLucideIcon-CYHXK9hn.js → createLucideIcon-0lYYH3EW.js} +6 -6
  233. package/dist/de-DBOTcDj2.js +20 -0
  234. package/dist/{cdn/chunks/de-DMquBpZM.js → de-DNuYQTmS.js} +147 -8
  235. package/dist/{cdn/chunks/dist-CjL6JHML.js → dist-C7EtxNCb.js} +49 -51
  236. package/dist/{dist-DuufrR8O.js → dist-C_dV9QAx.js} +130 -130
  237. package/dist/{cdn/chunks/dist-MNQYSEWU.js → dist-DI4_YSnG.js} +111 -110
  238. package/dist/{dist-tsmnQugO.js → dist-DtOF3bDW.js} +648 -294
  239. package/dist/{editor-modal-AlVLkU91.js → editor-modal-Bzhl-PgI.js} +832 -834
  240. package/dist/en-CDhWRrF_.js +20 -0
  241. package/dist/{cdn/chunks/en-C8Mp71sO.js → en-CW71OK66.js} +147 -8
  242. package/dist/en-DwV15ltA.js +1 -0
  243. package/dist/{cdn/chunks/es-Byq4tthI.js → es-DdK7zQfi.js} +147 -8
  244. package/dist/{extensions-pjO8VGkM.js → extensions-CdyweA50.js} +54 -54
  245. package/dist/{eye-Ddnz8nnm.js → eye-DWkSvYpj.js} +1 -1
  246. package/dist/{cdn/chunks/fr-B3j35HEw.js → fr-Dz5Bgb7-.js} +147 -8
  247. package/dist/image-DesWjcZ4.js +28 -0
  248. package/dist/index.d.ts +640 -48
  249. package/dist/{info-DXLmzoeY.js → info-ClWJGoZy.js} +1 -1
  250. package/dist/{cdn/chunks/ja-D7txAuGS.js → ja-Di-zJiT8.js} +147 -8
  251. package/dist/keys-Zd9KWRD1.js +10 -0
  252. package/dist/{link-Cel46wgo.js → link-BqRicFTA.js} +1 -1
  253. package/dist/{list-Cl0GwiV9.js → list-bojQr9bn.js} +1 -1
  254. package/dist/{loader-circle-uAwpvfys.js → loader-circle-B2B8LbUu.js} +1 -1
  255. package/dist/{cdn/chunks/logger-ByvdoAwq.js → logger-k9Nbj3Cp.js} +5 -3
  256. package/dist/{message-circle-DWU1pTM_.js → message-circle-BEuiNsyZ.js} +1 -1
  257. package/dist/{cdn/chunks/nl-ClJ3BY3F.js → nl-CvVuHYFL.js} +147 -8
  258. package/dist/normalizeMergeTagMarkup-P6SUBuPv.js +197 -0
  259. package/dist/{package-CbyG_yU_.js → package-DCROB4aM.js} +1 -1
  260. package/dist/{pencil-BzoDcwKu.js → pencil-CEotCKbf.js} +1 -1
  261. package/dist/{preRenderCustomBlocks-DMP5RuHl.js → preRenderCustomBlocks-D8rr61_z.js} +3 -3
  262. package/dist/pt-BR-CHM-ZKvE.js +20 -0
  263. package/dist/{cdn/chunks/pt-BR-DibcXcmv.js → pt-BR-ZhO4vgyq.js} +147 -8
  264. package/dist/{refresh-cw-9WinWixo.js → refresh-cw-C6M2mHNC.js} +12 -2
  265. package/dist/{runtime-dom.esm-bundler-lFF-QG3j.js → runtime-dom.esm-bundler-B8WCZWUm.js} +134 -134
  266. package/dist/sanitizeRichTextHtml-DeISfLFr.js +60 -0
  267. package/dist/{search-CqgGq1gG.js → search-Cy99zPYf.js} +1 -1
  268. package/dist/{send-Ceo3c9Db.js → send-BDLJFsf3.js} +1 -1
  269. package/dist/{smartphone-CcLaCpGK.js → smartphone-CVvQaNA4.js} +1 -1
  270. package/dist/socialIcons-Dd-jRiVe.js +2086 -0
  271. package/dist/{sparkles-Do9XjAuT.js → sparkles-Ce0Qz0ox.js} +1 -1
  272. package/dist/square-BWlolnXe.js +15 -0
  273. package/dist/style.css +1 -1
  274. package/dist/{styleConstants-D1Jz-TFU.js → styleConstants-v1dNKgJf.js} +1 -3
  275. package/dist/templatical-editor.js +2272 -1327
  276. package/dist/{text-align-start-DvzC0HQA.js → text-align-start-D1V5gPTy.js} +1 -1
  277. package/dist/{trash-vlINTx32.js → trash-CZfiUFmw.js} +1 -1
  278. package/dist/{triangle-alert-MRYSJ9T2.js → triangle-alert-CFDzyFC7.js} +1 -1
  279. package/dist/upload-BJfvdIrD.js +36 -0
  280. package/dist/{useCloudI18n-Nwqo7pI_.js → useCloudI18n-Dcjua65H.js} +5 -5
  281. package/dist/{useEditorCore-PvErWWsp.js → useEditorCore-BTLeAVlM.js} +1534 -1549
  282. package/dist/{useEditorRoot-BD3piYtD.js → useEditorRoot-DUy67lJu.js} +2 -2
  283. package/dist/{useI18n-CxVEpurs.js → useI18n-BdoY7xDE.js} +4 -4
  284. package/dist/{useLogicTag-BHn67tDd.js → useLogicTag-DKLZ1T9H.js} +3 -3
  285. package/dist/{useMergeTag-CRkm5Ig6.js → useMergeTag-Bhdx7AKk.js} +5 -5
  286. package/dist/{usePopoverPosition-CwnH1o5g.js → usePopoverPosition-BZea45XK.js} +2 -2
  287. package/dist/useScrollToBlock-FmNMALM_.js +74 -0
  288. package/dist/{vue.runtime.esm-bundler-CAzmrXdD.js → vue.runtime.esm-bundler-DgFJ6GPG.js} +1182 -1087
  289. package/dist/{withCurrentFont-CxRGeHO3.js → withCurrentFont-BATJHNve.js} +1 -1
  290. package/dist/{x-Cd6SFw8r.js → x-CZ0Js0hA.js} +1 -1
  291. package/package.json +17 -15
  292. package/dist/AiChatSidebar-DxPHFNoT.js +0 -230
  293. package/dist/AiFeatureMenu-C8GVqu1d.js +0 -57
  294. package/dist/CloudHeaderExtras-CUSftQdm.js +0 -59
  295. package/dist/CloudPanels-Dgw7tb4R.js +0 -216
  296. package/dist/CollaboratorBar-5rfopCPx.js +0 -103
  297. package/dist/CommentsSidebar-BOqj16Al.js +0 -500
  298. package/dist/DesignReferenceSidebar-BWAi3eQQ.js +0 -279
  299. package/dist/IssuesPanel-C-x3I012.js +0 -117
  300. package/dist/ParagraphEditor-BVjOwwHx.js +0 -797
  301. package/dist/SavedBlocksBrowserModal-DbmIS5uK.js +0 -360
  302. package/dist/TemplateScoringPanel-ynbGl-sr.js +0 -273
  303. package/dist/TemplateSettings-Bi01S3H3.js +0 -246
  304. package/dist/ToggleSwitch-Ozc7YU38.js +0 -102
  305. package/dist/Toolbar-B-2lO0I8.js +0 -3156
  306. package/dist/WrapperBlock-D0qgNqjD.js +0 -45
  307. package/dist/cdn/chunks/AiChatSidebar-Dk0rJBQN.js +0 -205
  308. package/dist/cdn/chunks/AiChatSidebar-Dk0rJBQN.js.map +0 -1
  309. package/dist/cdn/chunks/AiFeatureMenu-B7b0w8ZS.js +0 -57
  310. package/dist/cdn/chunks/AiFeatureMenu-B7b0w8ZS.js.map +0 -1
  311. package/dist/cdn/chunks/CloudHeaderExtras-B4fhuwc_.js +0 -60
  312. package/dist/cdn/chunks/CloudHeaderExtras-B4fhuwc_.js.map +0 -1
  313. package/dist/cdn/chunks/CloudPanels-awqHfJqC.js.map +0 -1
  314. package/dist/cdn/chunks/CollaboratorBar-CS0ivqkr.js +0 -52
  315. package/dist/cdn/chunks/CollaboratorBar-CS0ivqkr.js.map +0 -1
  316. package/dist/cdn/chunks/CommentsPanel-CbzxwsyI.js +0 -20
  317. package/dist/cdn/chunks/CommentsSidebar-DWPHZuQm.js +0 -470
  318. package/dist/cdn/chunks/DesignReferenceSidebar-BW9cHnA9.js +0 -229
  319. package/dist/cdn/chunks/DesignReferenceSidebar-BW9cHnA9.js.map +0 -1
  320. package/dist/cdn/chunks/IssuesPanel-cXf9ywA4.js +0 -100
  321. package/dist/cdn/chunks/IssuesPanel-cXf9ywA4.js.map +0 -1
  322. package/dist/cdn/chunks/LogicTagInsertButton-BMB9vShs.js.map +0 -1
  323. package/dist/cdn/chunks/MediaEditModal-zXfcArr4.js.map +0 -1
  324. package/dist/cdn/chunks/MediaPanels-Cp4XB_dH.js +0 -45
  325. package/dist/cdn/chunks/ParagraphEditor-D4aq9eeC.js +0 -632
  326. package/dist/cdn/chunks/ParagraphEditor-D4aq9eeC.js.map +0 -1
  327. package/dist/cdn/chunks/SavedBlocksPanels-BhEOMzEQ.js +0 -38
  328. package/dist/cdn/chunks/TemplateScoringPanel-BrWqJCSP.js +0 -237
  329. package/dist/cdn/chunks/TemplateScoringPanel-BrWqJCSP.js.map +0 -1
  330. package/dist/cdn/chunks/TemplateSettings-BkkWTDHD.js +0 -208
  331. package/dist/cdn/chunks/TestEmailPanel-DxrKuctP.js +0 -35
  332. package/dist/cdn/chunks/TitleEditor-CsZiG3TT.js +0 -199
  333. package/dist/cdn/chunks/ToggleSwitch-BB-bQADJ.js +0 -104
  334. package/dist/cdn/chunks/ToggleSwitch-BB-bQADJ.js.map +0 -1
  335. package/dist/cdn/chunks/Toolbar-C_x2TfFk.js.map +0 -1
  336. package/dist/cdn/chunks/VersionHistoryPanels-DXSqmaLS.js +0 -48
  337. package/dist/cdn/chunks/WrapperBlock-gG_Bleug.js +0 -47
  338. package/dist/cdn/chunks/blockTypeIcons-HrMJDfVg.js +0 -22
  339. package/dist/cdn/chunks/ca-CbNzJM3I.js.map +0 -1
  340. package/dist/cdn/chunks/cloud-BHClP3e2.js +0 -1736
  341. package/dist/cdn/chunks/cloud-BHClP3e2.js.map +0 -1
  342. package/dist/cdn/chunks/createCloudRuntime-Vd0N4elZ.js +0 -400
  343. package/dist/cdn/chunks/createCloudRuntime-Vd0N4elZ.js.map +0 -1
  344. package/dist/cdn/chunks/de-DMquBpZM.js.map +0 -1
  345. package/dist/cdn/chunks/de-mMY5yQJu.js +0 -93
  346. package/dist/cdn/chunks/de-mMY5yQJu.js.map +0 -1
  347. package/dist/cdn/chunks/draggable-DrsNwZuB.js.map +0 -1
  348. package/dist/cdn/chunks/en-C8Mp71sO.js.map +0 -1
  349. package/dist/cdn/chunks/en-ChVeGQBY.js +0 -93
  350. package/dist/cdn/chunks/en-ChVeGQBY.js.map +0 -1
  351. package/dist/cdn/chunks/en-eWpiXyZu.js +0 -1
  352. package/dist/cdn/chunks/es-Byq4tthI.js.map +0 -1
  353. package/dist/cdn/chunks/fr-B3j35HEw.js.map +0 -1
  354. package/dist/cdn/chunks/icons-aTYwH5-g.js.map +0 -1
  355. package/dist/cdn/chunks/ja-D7txAuGS.js.map +0 -1
  356. package/dist/cdn/chunks/keys-HI-INbkz.js +0 -12
  357. package/dist/cdn/chunks/keys-HI-INbkz.js.map +0 -1
  358. package/dist/cdn/chunks/logger-ByvdoAwq.js.map +0 -1
  359. package/dist/cdn/chunks/nl-ClJ3BY3F.js.map +0 -1
  360. package/dist/cdn/chunks/pt-BR-CoCwRUi0.js +0 -93
  361. package/dist/cdn/chunks/pt-BR-CoCwRUi0.js.map +0 -1
  362. package/dist/cdn/chunks/pt-BR-DibcXcmv.js.map +0 -1
  363. package/dist/cdn/chunks/pusher-C8DeiO2X.js.map +0 -1
  364. package/dist/cdn/chunks/socialIcons-C_lnkpG6.js +0 -1279
  365. package/dist/cdn/chunks/socialIcons-C_lnkpG6.js.map +0 -1
  366. package/dist/cdn/chunks/src-DYCDeBDM.js.map +0 -1
  367. package/dist/cdn/chunks/src-DlFlC9Tt.js +0 -1272
  368. package/dist/cdn/chunks/src-DlFlC9Tt.js.map +0 -1
  369. package/dist/cdn/chunks/src-dZ4D_tuP.js.map +0 -1
  370. package/dist/cdn/chunks/timeouts-Cv2jvusx.js +0 -6
  371. package/dist/cdn/chunks/timeouts-Cv2jvusx.js.map +0 -1
  372. package/dist/cdn/chunks/tiptap-BPigZk5G.js.map +0 -1
  373. package/dist/cdn/chunks/useAliveFlag-DCB96vzR.js +0 -12
  374. package/dist/cdn/chunks/useAliveFlag-DCB96vzR.js.map +0 -1
  375. package/dist/cdn/chunks/useEditorCore-Bb2UcB20.js +0 -2602
  376. package/dist/cdn/chunks/useEditorCore-Bb2UcB20.js.map +0 -1
  377. package/dist/cdn/chunks/useEditorRoot-CTc6O8al.js +0 -10
  378. package/dist/cdn/chunks/useScrollToBlock-uUa601I4.js +0 -21
  379. package/dist/cdn/chunks/useScrollToBlock-uUa601I4.js.map +0 -1
  380. package/dist/cloud-B5xwm_4X.js +0 -1689
  381. package/dist/copy-BEcsAlfB.js +0 -19
  382. package/dist/createCloudRuntime-zNPkF6T9.js +0 -398
  383. package/dist/de-mMY5yQJu.js +0 -91
  384. package/dist/dist-DAAJogrx.js +0 -407
  385. package/dist/en-B0FUfNwz.js +0 -1
  386. package/dist/en-ChVeGQBY.js +0 -91
  387. package/dist/image-up-CM_HC0Dx.js +0 -27
  388. package/dist/keys-BKFq19a2.js +0 -10
  389. package/dist/plus-8cDvoCjZ.js +0 -14
  390. package/dist/pt-BR-CoCwRUi0.js +0 -91
  391. package/dist/shield-check-uDAwur5D.js +0 -14
  392. package/dist/socialIcons-PTiwhLoC.js +0 -1359
  393. package/dist/timeouts-Cv2jvusx.js +0 -4
  394. package/dist/upload-CtNOI6J2.js +0 -21
  395. package/dist/useAliveFlag-Dd06mRxe.js +0 -10
  396. package/dist/useScrollToBlock-CXmcHQQN.js +0 -47
@@ -1,1736 +0,0 @@
1
- import { r as e } from "./rolldown-runtime-B0aSnxlc.js";
2
- import { B as t, Q as n, Y as r, f as i } from "./draggable-DrsNwZuB.js";
3
- import { t as a } from "./src-DYCDeBDM.js";
4
- //#region ../core/src/cloud/auth.ts
5
- function o(e) {
6
- let t = e instanceof a ? e.statusCode : void 0;
7
- return t !== void 0 && t >= 400 && t < 500;
8
- }
9
- var s = class e {
10
- static DEFAULT_BASE_URL = "https://templatical.com";
11
- accessToken = null;
12
- expiresAt = null;
13
- _projectId = null;
14
- _tenantId = null;
15
- _tenantSlug = null;
16
- _testEmailConfig = null;
17
- _userConfig = null;
18
- url;
19
- baseUrl;
20
- requestOptions;
21
- onError;
22
- refreshPromise = null;
23
- static REFRESH_THRESHOLD_MS = 6e4;
24
- constructor(t) {
25
- this.url = t.url, this.baseUrl = (t.baseUrl ?? e.DEFAULT_BASE_URL).replace(/\/$/, ""), this.requestOptions = t.requestOptions ?? {}, this.onError = t.onError;
26
- }
27
- resolveUrl(e) {
28
- if (e.startsWith("http://") || e.startsWith("https://")) return e;
29
- let t = e.startsWith("/") ? e : `/${e}`;
30
- return `${this.baseUrl}${t}`;
31
- }
32
- get projectId() {
33
- if (!this._projectId) throw Error("Project ID not available. Call initialize() first.");
34
- return this._projectId;
35
- }
36
- get tenantId() {
37
- if (!this._tenantId) throw Error("Tenant ID not available. Call initialize() first.");
38
- return this._tenantId;
39
- }
40
- get tenantSlug() {
41
- if (!this._tenantSlug) throw Error("Tenant slug not available. Call initialize() first.");
42
- return this._tenantSlug;
43
- }
44
- get testEmailConfig() {
45
- return this._testEmailConfig;
46
- }
47
- get userConfig() {
48
- return this._userConfig;
49
- }
50
- get accessTokenValue() {
51
- return this.accessToken;
52
- }
53
- async initialize() {
54
- await this.ensureToken();
55
- }
56
- async ensureToken() {
57
- return this.accessToken && !this.isTokenExpiringSoon() ? this.accessToken : this.refreshToken();
58
- }
59
- isTokenExpiringSoon() {
60
- return !this.expiresAt || this.expiresAt.getTime() - Date.now() < e.REFRESH_THRESHOLD_MS;
61
- }
62
- async refreshToken() {
63
- if (this.refreshPromise) return this.refreshPromise;
64
- this.refreshPromise = this.performRefresh();
65
- try {
66
- return await this.refreshPromise;
67
- } finally {
68
- this.refreshPromise = null;
69
- }
70
- }
71
- async performRefresh() {
72
- try {
73
- let e = this.requestOptions.method ?? "POST", t = {
74
- Accept: "application/json",
75
- ...this.requestOptions.headers
76
- }, n = {
77
- method: e,
78
- headers: t,
79
- credentials: this.requestOptions.credentials ?? "include"
80
- };
81
- e === "POST" && this.requestOptions.body && (t["Content-Type"] = "application/json", n.body = JSON.stringify(this.requestOptions.body));
82
- let r = await fetch(this.url, n);
83
- if (!r.ok) throw new a(`Token refresh failed: ${r.status}`, r.status);
84
- let i = await r.json();
85
- if (!i.token || !i.expiresAt || !i.projectId || !i.tenant) throw Error("Invalid token response: missing token, expiresAt, projectId, or tenant");
86
- return this.accessToken = i.token, this.expiresAt = /* @__PURE__ */ new Date(i.expiresAt * 1e3), this._projectId = i.projectId, this._tenantSlug = i.tenant, this._testEmailConfig = i.testEmail?.allowedEmails && i.testEmail?.signature ? {
87
- allowedEmails: i.testEmail.allowedEmails,
88
- signature: i.testEmail.signature
89
- } : null, this._userConfig = i.user?.id && i.user?.name && i.user?.signature ? {
90
- id: i.user.id,
91
- name: i.user.name,
92
- signature: i.user.signature
93
- } : null, this.accessToken;
94
- } catch (e) {
95
- let t = e instanceof Error ? e : Error("Token refresh failed", { cause: e });
96
- throw this.onError?.(t), t;
97
- }
98
- }
99
- async authenticatedFetch(e, t = {}) {
100
- let n = await this.ensureToken(), r = this.resolveUrl(e), i = async (e) => fetch(r, {
101
- ...t,
102
- headers: {
103
- ...t.headers,
104
- Authorization: `Bearer ${e}`
105
- }
106
- }), a = await i(n);
107
- return a.status === 401 && (a = await i(await this.refreshToken())), a;
108
- }
109
- };
110
- //#endregion
111
- //#region ../core/src/cloud/url-builder.ts
112
- function c(e, t) {
113
- return e.replace(/\{(\w+)\}/g, (e, n) => encodeURIComponent(t[n] ?? ""));
114
- }
115
- var l = "/api/v1/projects/{project}/tenants/{tenant}", u = `${l}/templates/{template}`, d = `${u}/ai`, f = `${l}/media`, p = `${f}/folders`, m = `${l}/saved-modules`, h = {
116
- health: "/api/v1/health",
117
- "projects.config": `${l}/config`,
118
- "broadcasting.auth": `${l}/broadcasting/auth`,
119
- "templates.store": `${l}/templates`,
120
- "templates.show": `${u}`,
121
- "templates.update": `${u}`,
122
- "templates.destroy": `${u}`,
123
- "templates.export": `${u}/export`,
124
- "templates.importFromBeefree": `${l}/templates/import/from-beefree`,
125
- "templates.sendTestEmail": `${u}/send-test-email`,
126
- "versions.index": `${u}/versions`,
127
- "versions.store": `${u}/versions`,
128
- "versions.show": `${u}/versions/{version}`,
129
- "versions.restore": `${u}/versions/{version}/restore`,
130
- "comments.index": `${u}/comments`,
131
- "comments.store": `${u}/comments`,
132
- "comments.update": `${u}/comments/{comment}`,
133
- "comments.destroy": `${u}/comments/{comment}`,
134
- "comments.resolve": `${u}/comments/{comment}/resolve`,
135
- "ai.generate": `${d}/generate`,
136
- "ai.conversationMessages": `${d}/conversation-messages`,
137
- "ai.suggestions": `${d}/suggestions`,
138
- "ai.rewriteText": `${d}/rewrite-text`,
139
- "ai.score": `${d}/score`,
140
- "ai.fixFinding": `${d}/fix-finding`,
141
- "ai.generateFromDesign": `${d}/generate-from-design`,
142
- "media.upload": `${f}/upload`,
143
- "media.browse": `${f}/browse`,
144
- "media.delete": `${f}/delete`,
145
- "media.move": `${f}/move`,
146
- "media.update": `${f}/{media}`,
147
- "media.replace": `${f}/{media}/replace`,
148
- "media.checkUsage": `${f}/check-usage`,
149
- "media.frequentlyUsed": `${f}/frequently-used`,
150
- "media.importFromUrl": `${f}/import-from-url`,
151
- "folders.index": `${p}`,
152
- "folders.store": `${p}`,
153
- "folders.update": `${p}/{mediaFolder}`,
154
- "folders.destroy": `${p}/{mediaFolder}`,
155
- "savedModules.index": `${m}`,
156
- "savedModules.store": `${m}`,
157
- "savedModules.update": `${m}/{savedModule}`,
158
- "savedModules.destroy": `${m}/{savedModule}`
159
- }, g = class {
160
- authManager;
161
- constructor(e) {
162
- this.authManager = e;
163
- }
164
- get projectId() {
165
- return this.authManager.projectId;
166
- }
167
- get tenantSlug() {
168
- return this.authManager.tenantSlug;
169
- }
170
- get baseParams() {
171
- return {
172
- project: this.projectId,
173
- tenant: this.tenantSlug
174
- };
175
- }
176
- async request(e, t = {}) {
177
- let n = await this.authManager.authenticatedFetch(e, {
178
- ...t,
179
- headers: {
180
- "Content-Type": "application/json",
181
- Accept: "application/json",
182
- ...t.headers
183
- }
184
- });
185
- if (!n.ok) {
186
- let e = await n.json().catch(() => ({ message: `HTTP error ${n.status}` })), t = this.extractFirstValidationError(e);
187
- throw new a(t, n.status);
188
- }
189
- if (n.status !== 204) return (await n.json()).data;
190
- }
191
- extractFirstValidationError(e) {
192
- if (e.errors) {
193
- let t = Object.keys(e.errors)[0];
194
- if (t && e.errors[t]?.length > 0) return e.errors[t][0];
195
- }
196
- return e.message;
197
- }
198
- async createTemplate(e, t) {
199
- return this.request(c(h["templates.store"], this.baseParams), {
200
- method: "POST",
201
- body: JSON.stringify(t === void 0 ? { content: e } : {
202
- content: e,
203
- name: t
204
- })
205
- });
206
- }
207
- async getTemplate(e) {
208
- return this.request(c(h["templates.show"], {
209
- ...this.baseParams,
210
- template: e
211
- }));
212
- }
213
- async updateTemplate(e, t) {
214
- return this.request(c(h["templates.update"], {
215
- ...this.baseParams,
216
- template: e
217
- }), {
218
- method: "PUT",
219
- body: JSON.stringify(t)
220
- });
221
- }
222
- async createVersion(e, t, n) {
223
- return this.request(c(h["versions.store"], {
224
- ...this.baseParams,
225
- template: e
226
- }), {
227
- method: "POST",
228
- body: JSON.stringify(n === void 0 ? { content: t } : {
229
- content: t,
230
- label: n
231
- })
232
- });
233
- }
234
- async deleteTemplate(e) {
235
- return this.request(c(h["templates.destroy"], {
236
- ...this.baseParams,
237
- template: e
238
- }), { method: "DELETE" });
239
- }
240
- async getVersions(e) {
241
- return this.request(c(h["versions.index"], {
242
- ...this.baseParams,
243
- template: e
244
- }));
245
- }
246
- async getVersion(e, t) {
247
- return this.request(c(h["versions.show"], {
248
- ...this.baseParams,
249
- template: e,
250
- version: t
251
- }));
252
- }
253
- async restoreVersion(e, t) {
254
- return this.request(c(h["versions.restore"], {
255
- ...this.baseParams,
256
- template: e,
257
- version: t
258
- }), { method: "POST" });
259
- }
260
- async exportTemplate(e, t) {
261
- let n = t ? JSON.stringify({
262
- custom_fonts: t.customFonts,
263
- default_fallback: t.defaultFallback
264
- }) : void 0;
265
- return this.request(c(h["templates.export"], {
266
- ...this.baseParams,
267
- template: e
268
- }), {
269
- method: "POST",
270
- body: n
271
- });
272
- }
273
- async sendTestEmail(e, t) {
274
- await this.request(c(h["templates.sendTestEmail"], {
275
- ...this.baseParams,
276
- template: e
277
- }), {
278
- method: "POST",
279
- body: JSON.stringify(t)
280
- });
281
- }
282
- commentsUrl(e, t) {
283
- return t ? c(h["comments.update"], {
284
- ...this.baseParams,
285
- template: e,
286
- comment: t
287
- }) : c(h["comments.index"], {
288
- ...this.baseParams,
289
- template: e
290
- });
291
- }
292
- async getComments(e) {
293
- return this.request(this.commentsUrl(e));
294
- }
295
- async createComment(e, t, n) {
296
- return this.request(this.commentsUrl(e), {
297
- method: "POST",
298
- body: JSON.stringify(t),
299
- headers: n
300
- });
301
- }
302
- async updateComment(e, t, n, r) {
303
- return this.request(this.commentsUrl(e, t), {
304
- method: "PUT",
305
- body: JSON.stringify(n),
306
- headers: r
307
- });
308
- }
309
- async deleteComment(e, t, n, r) {
310
- return this.request(this.commentsUrl(e, t), {
311
- method: "DELETE",
312
- body: JSON.stringify(n),
313
- headers: r
314
- });
315
- }
316
- async resolveComment(e, t, n, r) {
317
- return this.request(c(h["comments.resolve"], {
318
- ...this.baseParams,
319
- template: e,
320
- comment: t
321
- }), {
322
- method: "POST",
323
- body: JSON.stringify(n),
324
- headers: r
325
- });
326
- }
327
- async fetchConfig() {
328
- return this.request(c(h["projects.config"], this.baseParams));
329
- }
330
- async listModules(e, t) {
331
- let n = c(h["savedModules.index"], this.baseParams), r = new URLSearchParams();
332
- e && r.set("search", e), t && r.set("category", t);
333
- let i = r.size > 0 ? `?${r}` : "";
334
- return this.request(`${n}${i}`);
335
- }
336
- async createModule(e) {
337
- return this.request(c(h["savedModules.store"], this.baseParams), {
338
- method: "POST",
339
- body: JSON.stringify(e)
340
- });
341
- }
342
- async updateModule(e, t) {
343
- return this.request(c(h["savedModules.update"], {
344
- ...this.baseParams,
345
- savedModule: e
346
- }), {
347
- method: "PUT",
348
- body: JSON.stringify(t)
349
- });
350
- }
351
- async deleteModule(e) {
352
- return this.request(c(h["savedModules.destroy"], {
353
- ...this.baseParams,
354
- savedModule: e
355
- }), { method: "DELETE" });
356
- }
357
- }, _ = class {
358
- authManager;
359
- constructor(e) {
360
- this.authManager = e;
361
- }
362
- get projectId() {
363
- return this.authManager.projectId;
364
- }
365
- get tenantSlug() {
366
- return this.authManager.tenantSlug;
367
- }
368
- get baseParams() {
369
- return {
370
- project: this.projectId,
371
- tenant: this.tenantSlug
372
- };
373
- }
374
- async request(e, t = {}) {
375
- let n = await this.authManager.authenticatedFetch(e, {
376
- ...t,
377
- headers: {
378
- "Content-Type": "application/json",
379
- Accept: "application/json",
380
- ...t.headers
381
- }
382
- });
383
- if (!n.ok) {
384
- let e = await n.json().catch(() => ({ message: `HTTP error ${n.status}` }));
385
- throw Error(e.message, { cause: e });
386
- }
387
- if (n.status !== 204) return (await n.json()).data;
388
- }
389
- async browseMedia(e) {
390
- let t = new URLSearchParams();
391
- e.folderId && t.set("folderId", e.folderId), e.search && t.set("search", e.search), e.category && t.set("category", e.category), e.sort && t.set("sort", e.sort), e.cursor && t.set("cursor", e.cursor);
392
- let n = t.toString(), r = `${c(h["media.browse"], this.baseParams)}${n ? `?${n}` : ""}`, i = await this.authManager.authenticatedFetch(r, { headers: { Accept: "application/json" } });
393
- if (!i.ok) {
394
- let e = await i.json().catch(() => ({ message: `HTTP error ${i.status}` }));
395
- throw Error(e.message, { cause: e });
396
- }
397
- return i.json();
398
- }
399
- async uploadMedia(e, t) {
400
- let n = new FormData();
401
- n.append("file", e), t && n.append("folderId", t);
402
- let r = c(h["media.upload"], this.baseParams), i = await this.authManager.authenticatedFetch(r, {
403
- method: "POST",
404
- headers: { Accept: "application/json" },
405
- body: n
406
- });
407
- if (!i.ok) {
408
- let e = await i.json().catch(() => ({ message: `HTTP error ${i.status}` }));
409
- throw Error(e.message, { cause: e });
410
- }
411
- return (await i.json()).data;
412
- }
413
- async updateMedia(e, t, n) {
414
- let r = {};
415
- return t !== void 0 && (r.filename = t), n !== void 0 && (r.alt = n), this.request(c(h["media.update"], {
416
- ...this.baseParams,
417
- media: e
418
- }), {
419
- method: "PUT",
420
- body: JSON.stringify(r)
421
- });
422
- }
423
- async deleteMedia(e) {
424
- return this.request(c(h["media.delete"], this.baseParams), {
425
- method: "POST",
426
- body: JSON.stringify({ ids: e })
427
- });
428
- }
429
- async moveMedia(e, t) {
430
- return this.request(c(h["media.move"], this.baseParams), {
431
- method: "POST",
432
- body: JSON.stringify({
433
- ids: e,
434
- folderId: t
435
- })
436
- });
437
- }
438
- async getMediaFolders() {
439
- return this.request(c(h["folders.index"], this.baseParams));
440
- }
441
- async createMediaFolder(e, t) {
442
- return this.request(c(h["folders.store"], this.baseParams), {
443
- method: "POST",
444
- body: JSON.stringify({
445
- name: e,
446
- parentId: t ?? null
447
- })
448
- });
449
- }
450
- async renameMediaFolder(e, t) {
451
- return this.request(c(h["folders.update"], {
452
- ...this.baseParams,
453
- mediaFolder: e
454
- }), {
455
- method: "PUT",
456
- body: JSON.stringify({ name: t })
457
- });
458
- }
459
- async deleteMediaFolder(e) {
460
- return this.request(c(h["folders.destroy"], {
461
- ...this.baseParams,
462
- mediaFolder: e
463
- }), { method: "DELETE" });
464
- }
465
- async checkMediaUsage(e) {
466
- let t = await this.authManager.authenticatedFetch(c(h["media.checkUsage"], this.baseParams), {
467
- method: "POST",
468
- headers: {
469
- "Content-Type": "application/json",
470
- Accept: "application/json"
471
- },
472
- body: JSON.stringify({ ids: e })
473
- });
474
- if (!t.ok) {
475
- let e = await t.json().catch(() => ({ message: `HTTP error ${t.status}` }));
476
- throw Error(e.message, { cause: e });
477
- }
478
- return t.json();
479
- }
480
- async getFrequentlyUsed() {
481
- return this.request(c(h["media.frequentlyUsed"], this.baseParams));
482
- }
483
- async importFromUrl(e, t) {
484
- return this.request(c(h["media.importFromUrl"], this.baseParams), {
485
- method: "POST",
486
- body: JSON.stringify({
487
- url: e,
488
- folderId: t ?? null
489
- })
490
- });
491
- }
492
- async replaceMedia(e, t) {
493
- let n = new FormData();
494
- n.append("file", t);
495
- let r = c(h["media.replace"], {
496
- ...this.baseParams,
497
- media: e
498
- }), i = await this.authManager.authenticatedFetch(r, {
499
- method: "POST",
500
- headers: { Accept: "application/json" },
501
- body: n
502
- });
503
- if (!i.ok) {
504
- let e = await i.json().catch(() => ({ message: `HTTP error ${i.status}` }));
505
- throw Error(e.message, { cause: e });
506
- }
507
- return (await i.json()).data;
508
- }
509
- };
510
- //#endregion
511
- //#region ../core/src/cloud/websocket-client.ts
512
- function v(e) {
513
- return {
514
- host: e.host,
515
- port: e.port,
516
- appKey: e.appKey
517
- };
518
- }
519
- var y = class {
520
- pusher = null;
521
- authManager;
522
- config;
523
- onError;
524
- constructor(e) {
525
- this.authManager = e.authManager, this.config = e.config, this.onError = e.onError;
526
- }
527
- async connect() {
528
- if (this.pusher) return;
529
- let t;
530
- try {
531
- ({default: t} = await import("./pusher-C8DeiO2X.js").then((t) => /* @__PURE__ */ e(t.t(), 1)));
532
- } catch {
533
- throw Error("[Templatical] Cloud features require the optional peer dependency 'pusher-js'. Please install it.");
534
- }
535
- let { host: n, port: r, appKey: i } = this.config, a = this.authManager.resolveUrl(c(h["broadcasting.auth"], {
536
- project: this.authManager.projectId,
537
- tenant: this.authManager.tenantSlug
538
- }));
539
- this.pusher = new t(i, {
540
- wsHost: n,
541
- wsPort: r,
542
- wssPort: r,
543
- forceTLS: !0,
544
- disableStats: !0,
545
- enabledTransports: ["ws", "wss"],
546
- cluster: "",
547
- channelAuthorization: {
548
- transport: "ajax",
549
- endpoint: a,
550
- headers: {
551
- Authorization: `Bearer ${this.authManager.accessTokenValue}`,
552
- Accept: "application/json"
553
- },
554
- params: {
555
- userId: this.authManager.userConfig?.id ?? "",
556
- userName: this.authManager.userConfig?.name ?? "",
557
- userSignature: this.authManager.userConfig?.signature ?? ""
558
- }
559
- }
560
- }), this.pusher.connection.bind("error", (e) => {
561
- this.onError?.(e instanceof Error ? e : /* @__PURE__ */ Error("WebSocket connection error"));
562
- });
563
- }
564
- subscribePresence(e) {
565
- if (!this.pusher) throw Error("WebSocketClient not connected. Call connect() first.");
566
- return this.pusher.subscribe(e);
567
- }
568
- unsubscribe(e) {
569
- this.pusher?.unsubscribe(e);
570
- }
571
- getChannel(e) {
572
- return this.pusher?.channel(e);
573
- }
574
- disconnect() {
575
- this.pusher &&= (this.pusher.disconnect(), null);
576
- }
577
- getSocketId() {
578
- return this.pusher?.connection.socket_id ?? null;
579
- }
580
- get isConnected() {
581
- return this.pusher?.connection.state === "connected";
582
- }
583
- };
584
- //#endregion
585
- //#region ../core/src/cloud/mcp-operation-handler.ts
586
- function b(e, t) {
587
- let { operation: n, data: r } = t;
588
- switch (n) {
589
- case "addBlock":
590
- e.addBlock(r.block, r.sectionId, r.columnIndex, r.index);
591
- break;
592
- case "updateBlock":
593
- e.updateBlock(r.blockId, r.updates);
594
- break;
595
- case "deleteBlock":
596
- e.removeBlock(r.blockId);
597
- break;
598
- case "moveBlock":
599
- e.moveBlock(r.blockId, r.index, r.sectionId, r.columnIndex);
600
- break;
601
- case "updateSettings":
602
- e.updateSettings(r.updates);
603
- break;
604
- case "setContent":
605
- e.setContent(r.content);
606
- break;
607
- case "updateBlockStyle": e.updateBlock(r.blockId, { styles: r.styles });
608
- }
609
- }
610
- //#endregion
611
- //#region ../core/src/cloud/ai-chat.ts
612
- var x = 0;
613
- function S() {
614
- return `msg_${Date.now()}_${++x}`;
615
- }
616
- function C(e) {
617
- let { authManager: t, getTemplateId: r, onApply: i, onError: a } = e, o = n([]), s = n(!1), l = n(!1), u = n(null), d = n(null), f = n(null), p = n(null), m = n(null), g = n(null), _ = n(!1), v = n([]), y = n(!1);
618
- function b(e, t) {
619
- let n = o.value.findIndex((t) => t.id === e);
620
- if (n === -1) return;
621
- let r = {
622
- ...o.value[n],
623
- ...t
624
- };
625
- o.value = [
626
- ...o.value.slice(0, n),
627
- r,
628
- ...o.value.slice(n + 1)
629
- ];
630
- }
631
- async function x() {
632
- let e = r();
633
- if (e) {
634
- l.value = !0;
635
- try {
636
- let n = c(h["ai.conversationMessages"], {
637
- project: t.projectId,
638
- tenant: t.tenantSlug,
639
- template: e
640
- }), r = await t.authenticatedFetch(n, {
641
- method: "GET",
642
- headers: { Accept: "application/json" }
643
- });
644
- if (!r.ok) return;
645
- let i = await r.json();
646
- i.conversationId && (f.value = i.conversationId), Array.isArray(i.data) && i.data.length > 0 && (o.value = i.data.map((e) => ({
647
- id: e.id,
648
- role: e.role,
649
- content: e.content,
650
- timestamp: new Date(e.createdAt).getTime()
651
- })));
652
- } catch {} finally {
653
- l.value = !1;
654
- }
655
- }
656
- }
657
- async function C(e, n) {
658
- let i = r();
659
- if (i) {
660
- y.value = !0;
661
- try {
662
- let r = c(h["ai.suggestions"], {
663
- project: t.projectId,
664
- tenant: t.tenantSlug,
665
- template: i
666
- }), a = await t.authenticatedFetch(r, {
667
- method: "POST",
668
- headers: {
669
- "Content-Type": "application/json",
670
- Accept: "text/event-stream"
671
- },
672
- body: JSON.stringify({
673
- currentContent: e,
674
- mergeTags: n.map((e) => ({
675
- label: e.label,
676
- value: e.value
677
- }))
678
- })
679
- });
680
- if (!a.ok) return;
681
- let o = a.body?.getReader();
682
- if (!o) return;
683
- let s = new TextDecoder(), l = "";
684
- for (;;) {
685
- let { done: e, value: t } = await o.read();
686
- if (e) break;
687
- l += s.decode(t, { stream: !0 });
688
- let n = l.split("\n");
689
- l = n.pop() ?? "";
690
- for (let e of n) {
691
- if (!e.startsWith("data: ")) continue;
692
- let t;
693
- try {
694
- t = JSON.parse(e.slice(6));
695
- } catch {
696
- continue;
697
- }
698
- t.type === "done" && Array.isArray(t.suggestions) && (v.value = t.suggestions.slice(0, 3));
699
- }
700
- }
701
- } catch {} finally {
702
- y.value = !1;
703
- }
704
- }
705
- }
706
- async function w(e, n, l) {
707
- let y = r();
708
- if (!y) throw Error("Template must be saved before using AI generation");
709
- s.value = !0, u.value = null, d.value = null, v.value = [];
710
- let x = S();
711
- o.value = [...o.value, {
712
- id: x,
713
- role: "user",
714
- content: e,
715
- timestamp: Date.now()
716
- }];
717
- let C = S();
718
- o.value = [...o.value, {
719
- id: C,
720
- role: "assistant",
721
- content: "",
722
- timestamp: Date.now()
723
- }];
724
- try {
725
- let r = c(h["ai.generate"], {
726
- project: t.projectId,
727
- tenant: t.tenantSlug,
728
- template: y
729
- }), a = await t.authenticatedFetch(r, {
730
- method: "POST",
731
- headers: {
732
- "Content-Type": "application/json",
733
- Accept: "text/event-stream"
734
- },
735
- body: JSON.stringify({
736
- prompt: e,
737
- currentContent: n,
738
- mergeTags: l.map((e) => ({
739
- label: e.label,
740
- value: e.value
741
- })),
742
- conversationId: f.value
743
- })
744
- });
745
- if (!a.ok) {
746
- let e = await a.json().catch(() => null);
747
- throw Error(a.status === 403 ? "aiGenerationNotAvailable" : e?.message || "Failed to generate template");
748
- }
749
- let s = a.body?.getReader();
750
- if (!s) throw Error("Failed to read stream");
751
- let d = new TextDecoder(), v = "", x = null;
752
- try {
753
- for (;;) {
754
- let { done: e, value: t } = await s.read();
755
- if (e) break;
756
- v += d.decode(t, { stream: !0 });
757
- let r = v.split("\n");
758
- v = r.pop() ?? "";
759
- for (let e of r) {
760
- if (!e.startsWith("data: ")) continue;
761
- let t = e.slice(6), r;
762
- try {
763
- r = JSON.parse(t);
764
- } catch {
765
- continue;
766
- }
767
- if (r.type === "text") b(C, { content: (o.value.find((e) => e.id === C)?.content ?? "") + r.text });
768
- else if (r.type === "error") throw Error(r.message || "Failed to generate template");
769
- else r.type === "done" && (r.conversationId && (f.value = r.conversationId), b(C, { content: r.text }), x = r.content ?? null, x ? (m.value = n, g.value = x, p.value = C, _.value = !1, i?.(x)) : u.value = "ai_apply_failed");
770
- }
771
- }
772
- } finally {
773
- s.cancel().catch(() => {});
774
- }
775
- return x;
776
- } catch (t) {
777
- let n = t instanceof Error ? t : Error("Failed to generate template", { cause: t });
778
- return u.value = n.message, d.value = e, a?.(n), o.value = o.value.filter((e) => e.id !== x && e.id !== C), null;
779
- } finally {
780
- s.value = !1;
781
- }
782
- }
783
- function T() {
784
- _.value ? (g.value && i?.(g.value), _.value = !1) : (m.value && i?.(m.value), _.value = !0);
785
- }
786
- function E() {
787
- o.value = [], f.value = null, u.value = null, p.value = null, m.value = null, g.value = null, _.value = !1;
788
- }
789
- return {
790
- messages: o,
791
- isGenerating: s,
792
- isLoadingHistory: l,
793
- isLastChangeReverted: _,
794
- lastApplyMessageId: p,
795
- error: u,
796
- failedPrompt: d,
797
- suggestions: v,
798
- isLoadingSuggestions: y,
799
- sendPrompt: w,
800
- toggleLastRevert: T,
801
- loadConversation: x,
802
- loadSuggestions: C,
803
- clearChat: E
804
- };
805
- }
806
- //#endregion
807
- //#region ../core/src/cloud/ai-config.ts
808
- function w(e) {
809
- function t(t) {
810
- return e !== !1 && e?.[t] !== !1;
811
- }
812
- return {
813
- isFeatureEnabled: t,
814
- hasAnyMenuFeature: i(() => t("chat") || t("scoring") || t("designToTemplate"))
815
- };
816
- }
817
- //#endregion
818
- //#region ../core/src/cloud/template-scoring.ts
819
- function T(e) {
820
- let { authManager: t, getTemplateId: r } = e, i = n(!1), a = n(null), o = n(null), s = n(null), l = n(""), u = n(null);
821
- async function d(e, n) {
822
- let s = r();
823
- if (!s) return null;
824
- i.value = !0, o.value = null, a.value = null;
825
- try {
826
- let r = c(h["ai.score"], {
827
- project: t.projectId,
828
- tenant: t.tenantSlug,
829
- template: s
830
- }), i = await t.authenticatedFetch(r, {
831
- method: "POST",
832
- headers: {
833
- "Content-Type": "application/json",
834
- Accept: "text/event-stream"
835
- },
836
- body: JSON.stringify({
837
- currentContent: e,
838
- mergeTags: n.map((e) => ({
839
- label: e.label,
840
- value: e.value
841
- }))
842
- })
843
- });
844
- if (!i.ok) {
845
- if (i.status === 403) throw Error("aiGenerationNotAvailable");
846
- let e = await i.json().catch(() => null);
847
- throw Error(e?.message || "Failed to score template");
848
- }
849
- let o = i.body?.getReader();
850
- if (!o) throw Error("Failed to read stream");
851
- let l = new TextDecoder(), u = "", d = null;
852
- for (;;) {
853
- let { done: e, value: t } = await o.read();
854
- if (e) break;
855
- u += l.decode(t, { stream: !0 });
856
- let n = u.split("\n");
857
- u = n.pop() ?? "";
858
- for (let e of n) {
859
- if (!e.startsWith("data: ")) continue;
860
- let t;
861
- try {
862
- t = JSON.parse(e.slice(6));
863
- } catch {
864
- continue;
865
- }
866
- if (t.type === "error") throw Error(t.message || "Failed to score template");
867
- t.type === "done" && (d = t.result ?? null);
868
- }
869
- }
870
- if (d) for (let [e, t] of Object.entries(d.categories)) for (let n of t.findings) n.category = e;
871
- return a.value = d, d;
872
- } catch (e) {
873
- return o.value = e instanceof Error ? e.message : "Failed to score template", null;
874
- } finally {
875
- i.value = !1;
876
- }
877
- }
878
- async function f(e, n, i) {
879
- let a = r();
880
- if (!a) return null;
881
- s.value = n.id, l.value = "", u.value = null;
882
- try {
883
- let r = c(h["ai.fixFinding"], {
884
- project: t.projectId,
885
- tenant: t.tenantSlug,
886
- template: a
887
- }), o = await t.authenticatedFetch(r, {
888
- method: "POST",
889
- headers: {
890
- "Content-Type": "application/json",
891
- Accept: "text/event-stream"
892
- },
893
- body: JSON.stringify({
894
- content: e,
895
- finding: {
896
- id: n.id,
897
- message: n.message,
898
- suggestion: n.suggestion,
899
- category: n.category
900
- },
901
- mergeTags: i.map((e) => ({
902
- label: e.label,
903
- value: e.value
904
- }))
905
- })
906
- });
907
- if (!o.ok) {
908
- if (o.status === 403) throw Error("aiGenerationNotAvailable");
909
- let e = await o.json().catch(() => null);
910
- throw Error(e?.message || "Failed to fix finding");
911
- }
912
- let s = o.body?.getReader();
913
- if (!s) throw Error("Failed to read stream");
914
- let u = new TextDecoder(), d = "", f = null;
915
- for (;;) {
916
- let { done: e, value: t } = await s.read();
917
- if (e) break;
918
- d += u.decode(t, { stream: !0 });
919
- let n = d.split("\n");
920
- d = n.pop() ?? "";
921
- for (let e of n) {
922
- if (!e.startsWith("data: ")) continue;
923
- let t;
924
- try {
925
- t = JSON.parse(e.slice(6));
926
- } catch {
927
- continue;
928
- }
929
- if (t.type === "text") l.value += t.text;
930
- else if (t.type === "error") throw Error(t.message || "Failed to fix finding");
931
- else t.type === "done" && (f = t.content ?? null);
932
- }
933
- }
934
- return f;
935
- } catch (e) {
936
- return u.value = e instanceof Error ? e.message : "Failed to fix finding", null;
937
- } finally {
938
- s.value = null;
939
- }
940
- }
941
- function p(e, t) {
942
- if (!a.value) return;
943
- let n = a.value.categories[e];
944
- n && (n.findings = n.findings.filter((e) => e.id !== t));
945
- }
946
- function m() {
947
- i.value = !1, a.value = null, o.value = null, s.value = null, l.value = "", u.value = null;
948
- }
949
- return {
950
- isScoring: i,
951
- scoringResult: a,
952
- error: o,
953
- fixingFindingId: s,
954
- fixStreamingText: l,
955
- fixError: u,
956
- score: d,
957
- fixFinding: f,
958
- removeFinding: p,
959
- reset: m
960
- };
961
- }
962
- //#endregion
963
- //#region ../core/src/cloud/design-reference.ts
964
- function E(e) {
965
- let { authManager: t, getTemplateId: r, onApply: i, onError: a } = e, o = n(!1), s = n(null);
966
- async function l(e) {
967
- let n = r();
968
- if (!n) throw Error("Template must be saved before using design reference");
969
- o.value = !0, s.value = null;
970
- try {
971
- let r = new FormData();
972
- e.prompt && r.append("prompt", e.prompt), e.imageUpload && r.append("image_upload", e.imageUpload), e.pdfUpload && r.append("pdf_upload", e.pdfUpload);
973
- let a = c(h["ai.generateFromDesign"], {
974
- project: t.projectId,
975
- tenant: t.tenantSlug,
976
- template: n
977
- }), o = await t.authenticatedFetch(a, {
978
- method: "POST",
979
- headers: { Accept: "text/event-stream" },
980
- body: r
981
- });
982
- if (!o.ok) {
983
- let e = await o.json().catch(() => null);
984
- throw Error(o.status === 403 ? "aiGenerationNotAvailable" : e?.message || "Failed to generate template from design");
985
- }
986
- let s = o.body?.getReader();
987
- if (!s) throw Error("Failed to read stream");
988
- let l = new TextDecoder(), u = "", d = null;
989
- for (;;) {
990
- let { done: e, value: t } = await s.read();
991
- if (e) break;
992
- u += l.decode(t, { stream: !0 });
993
- let n = u.split("\n");
994
- u = n.pop() ?? "";
995
- for (let e of n) {
996
- if (!e.startsWith("data: ")) continue;
997
- let t = e.slice(6), n;
998
- try {
999
- n = JSON.parse(t);
1000
- } catch {
1001
- continue;
1002
- }
1003
- if (n.type === "error") throw Error(n.message || "Failed to generate template from design");
1004
- n.type === "done" && (d = n.content ?? null, d && i?.(d));
1005
- }
1006
- }
1007
- return d;
1008
- } catch (e) {
1009
- let t = e instanceof Error ? e : Error("Failed to generate template from design", { cause: e });
1010
- return s.value = t.message, a?.(t), null;
1011
- } finally {
1012
- o.value = !1;
1013
- }
1014
- }
1015
- function u() {
1016
- o.value = !1, s.value = null;
1017
- }
1018
- return {
1019
- isGenerating: o,
1020
- error: s,
1021
- generate: l,
1022
- reset: u
1023
- };
1024
- }
1025
- //#endregion
1026
- //#region ../core/src/cloud/comments-provider.ts
1027
- var D = "comment-broadcast";
1028
- function O(e) {
1029
- let t = {
1030
- id: e.id,
1031
- body: e.body,
1032
- author: e.author,
1033
- createdAt: e.createdAt,
1034
- blockId: e.blockId,
1035
- parentId: e.parentId,
1036
- resolvedAt: e.resolvedAt
1037
- };
1038
- return e.updatedAt !== e.createdAt && (t.updatedAt = e.updatedAt), e.resolvedBy && (t.resolvedBy = e.resolvedBy), e.replies?.length && (t.replies = e.replies.map(O)), t;
1039
- }
1040
- function k(e) {
1041
- let { authManager: n, channel: r, getSocketId: i } = e, a = new g(n);
1042
- function o() {
1043
- let e = n.userConfig;
1044
- if (!e) throw Error("[Templatical] Cloud comments need a signed user in the auth token. The project's token endpoint must include a `user` claim.");
1045
- return {
1046
- userId: e.id,
1047
- userName: e.name,
1048
- userSignature: e.signature
1049
- };
1050
- }
1051
- function s() {
1052
- let e = i?.();
1053
- return e ? { "X-Socket-ID": e } : void 0;
1054
- }
1055
- return {
1056
- async list(e) {
1057
- return (await a.getComments(e)).map(O);
1058
- },
1059
- async create(e, t) {
1060
- return O(await a.createComment(e, {
1061
- body: t.body,
1062
- blockId: t.blockId,
1063
- parentId: t.parentId,
1064
- ...o()
1065
- }, s()));
1066
- },
1067
- async update(e, t, n) {
1068
- if (n.body === void 0) throw Error("[Templatical] Cloud comments: update() needs a `body` in the patch.");
1069
- return O(await a.updateComment(e, t, {
1070
- body: n.body,
1071
- ...o()
1072
- }, s()));
1073
- },
1074
- async delete(e, t) {
1075
- await a.deleteComment(e, t, o(), s());
1076
- },
1077
- async setResolved(e, t, n) {
1078
- return O(await a.resolveComment(e, t, o(), s()));
1079
- },
1080
- subscribe(e, n) {
1081
- function i(e) {
1082
- let t = O(e.comment);
1083
- switch (e.action) {
1084
- case "commentCreated":
1085
- n({
1086
- type: "created",
1087
- comment: t
1088
- });
1089
- break;
1090
- case "commentDeleted":
1091
- n({
1092
- type: "deleted",
1093
- commentId: t.id,
1094
- parentId: t.parentId
1095
- });
1096
- break;
1097
- case "commentUpdated":
1098
- case "commentResolved":
1099
- case "commentUnresolved": n({
1100
- type: "updated",
1101
- comment: t
1102
- });
1103
- }
1104
- }
1105
- let a = t(r, (e, t) => {
1106
- t?.unbind(D, i), e?.bind(D, i);
1107
- }, { immediate: !0 });
1108
- return () => {
1109
- a(), r.value?.unbind(D, i);
1110
- };
1111
- }
1112
- };
1113
- }
1114
- //#endregion
1115
- //#region ../core/src/cloud/collaboration.ts
1116
- var A = [
1117
- "pusher:member_added",
1118
- "pusher:member_removed",
1119
- "client-blockLocked",
1120
- "client-blockUnlocked",
1121
- "client-operation",
1122
- "mcp-operation"
1123
- ];
1124
- function j(e) {
1125
- for (let t of A) e.unbind(t);
1126
- }
1127
- var M = [
1128
- "#3b82f6",
1129
- "#ef4444",
1130
- "#10b981",
1131
- "#f59e0b",
1132
- "#8b5cf6",
1133
- "#ec4899",
1134
- "#06b6d4",
1135
- "#f97316",
1136
- "#6366f1",
1137
- "#14b8a6"
1138
- ];
1139
- function N(e) {
1140
- let { authManager: a, editor: o, channel: s } = e, c = n([]), l = n(/* @__PURE__ */ new Map()), u = 0, d = !1, f = i(() => a.userConfig?.id ?? "");
1141
- function p() {
1142
- let e = M[u % M.length];
1143
- return u++, e;
1144
- }
1145
- function m(e) {
1146
- if (e.id === f.value || c.value.some((t) => t.id === e.id)) return;
1147
- let t = {
1148
- id: e.id,
1149
- name: e.name,
1150
- color: p(),
1151
- selectedBlockId: null
1152
- };
1153
- return c.value = [...c.value, t], t;
1154
- }
1155
- function h(e) {
1156
- let t = new Map(l.value);
1157
- for (let [n, r] of t) r.id === e && t.delete(n);
1158
- l.value = t, c.value = c.value.filter((t) => t.id !== e);
1159
- }
1160
- function g(e) {
1161
- let t = c.value.find((t) => t.id === e.userId);
1162
- if (!t) return;
1163
- c.value = c.value.map((t) => t.id === e.userId ? {
1164
- ...t,
1165
- selectedBlockId: e.blockId
1166
- } : t);
1167
- let n = new Map(l.value);
1168
- for (let [t, r] of n) r.id === e.userId && n.delete(t);
1169
- n.set(e.blockId, {
1170
- ...t,
1171
- selectedBlockId: e.blockId
1172
- }), l.value = n, o.state.selectedBlockId === e.blockId && o.selectBlock(null);
1173
- }
1174
- function _(e) {
1175
- let t = new Map(l.value), n = t.get(e.blockId);
1176
- t.delete(e.blockId), l.value = t, n && (c.value = c.value.map((e) => e.id === n.id ? {
1177
- ...e,
1178
- selectedBlockId: null
1179
- } : e));
1180
- }
1181
- function v(e) {
1182
- d = !0;
1183
- try {
1184
- b(o, e);
1185
- } finally {
1186
- d = !1;
1187
- }
1188
- }
1189
- function y(e) {
1190
- s.value && !d && s.value.trigger("client-operation", e);
1191
- }
1192
- function x(e) {
1193
- s.value && s.value.trigger("client-blockLocked", {
1194
- blockId: e,
1195
- userId: f.value
1196
- });
1197
- }
1198
- function S(e) {
1199
- s.value && s.value.trigger("client-blockUnlocked", { blockId: e });
1200
- }
1201
- return t(() => o.state.selectedBlockId, (e, t) => {
1202
- d || (t && S(t), e && x(e));
1203
- }), t(s, (t, n) => {
1204
- if (n && j(n), !t) {
1205
- c.value = [], l.value = /* @__PURE__ */ new Map(), u = 0;
1206
- return;
1207
- }
1208
- let r = t.members;
1209
- r && r.each((e) => {
1210
- m(e.info);
1211
- }), t.bind("pusher:member_added", (t) => {
1212
- let n = m(t.info);
1213
- n && e.onCollaboratorJoined?.(n);
1214
- }), t.bind("pusher:member_removed", (t) => {
1215
- let n = c.value.find((e) => e.id === t.id);
1216
- h(t.id), n && e.onCollaboratorLeft?.(n);
1217
- }), t.bind("client-blockLocked", (t) => {
1218
- g(t);
1219
- let n = c.value.find((e) => e.id === t.userId);
1220
- n && e.onBlockLocked?.({
1221
- blockId: t.blockId,
1222
- collaborator: n
1223
- });
1224
- }), t.bind("client-blockUnlocked", (t) => {
1225
- let n = l.value.get(t.blockId);
1226
- _(t), n && e.onBlockUnlocked?.({
1227
- blockId: t.blockId,
1228
- collaborator: n
1229
- });
1230
- }), t.bind("client-operation", (e) => {
1231
- v(e);
1232
- }), t.bind("mcp-operation", (e) => {
1233
- v(e);
1234
- });
1235
- }), r(() => {
1236
- s.value && j(s.value);
1237
- }), {
1238
- collaborators: c,
1239
- lockedBlocks: l,
1240
- _broadcastOperation: y,
1241
- _isProcessingRemoteOperation: () => d
1242
- };
1243
- }
1244
- //#endregion
1245
- //#region ../core/src/cloud/collaboration-broadcast.ts
1246
- function P(e, t) {
1247
- let n = e.addBlock, r = e.updateBlock, i = e.removeBlock, a = e.moveBlock, o = e.updateSettings, s = e.setContent;
1248
- e.addBlock = (e, r, i, a) => {
1249
- n(e, r, i, a), t._broadcastOperation({
1250
- operation: "addBlock",
1251
- data: {
1252
- block: e,
1253
- sectionId: r,
1254
- columnIndex: i,
1255
- index: a
1256
- },
1257
- timestamp: Date.now()
1258
- });
1259
- }, e.updateBlock = (e, n) => {
1260
- r(e, n), t._broadcastOperation({
1261
- operation: "updateBlock",
1262
- data: {
1263
- blockId: e,
1264
- updates: n
1265
- },
1266
- timestamp: Date.now()
1267
- });
1268
- }, e.removeBlock = (e) => {
1269
- i(e), t._broadcastOperation({
1270
- operation: "deleteBlock",
1271
- data: { blockId: e },
1272
- timestamp: Date.now()
1273
- });
1274
- }, e.moveBlock = (e, n, r, i) => {
1275
- a(e, n, r, i), t._broadcastOperation({
1276
- operation: "moveBlock",
1277
- data: {
1278
- blockId: e,
1279
- index: n,
1280
- sectionId: r,
1281
- columnIndex: i
1282
- },
1283
- timestamp: Date.now()
1284
- });
1285
- }, e.updateSettings = (e) => {
1286
- o(e), t._broadcastOperation({
1287
- operation: "updateSettings",
1288
- data: { updates: e },
1289
- timestamp: Date.now()
1290
- });
1291
- }, e.setContent = (e, n) => {
1292
- s(e, n), t._broadcastOperation({
1293
- operation: "setContent",
1294
- data: { content: e },
1295
- timestamp: Date.now()
1296
- });
1297
- };
1298
- }
1299
- //#endregion
1300
- //#region ../core/src/cloud/web-socket.ts
1301
- function F(e) {
1302
- let { authManager: t, onError: r } = e, i = n(null), a = n(!1), o = null, s = null;
1303
- async function c(e, n) {
1304
- if (o) return;
1305
- o = new y({
1306
- authManager: t,
1307
- config: n,
1308
- onError: r
1309
- }), await o.connect(), s = `presence-template.${e}`;
1310
- let c = o.subscribePresence(s);
1311
- c.bind("pusher:subscription_succeeded", () => {
1312
- a.value = !0, i.value = c;
1313
- }), c.bind("pusher:subscription_error", (e) => {
1314
- a.value = !1, i.value = null, r?.(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to subscribe to template channel"));
1315
- });
1316
- }
1317
- function l() {
1318
- s && o && o.unsubscribe(s), o?.disconnect(), o = null, s = null, i.value = null, a.value = !1;
1319
- }
1320
- function u() {
1321
- return o?.getSocketId() ?? null;
1322
- }
1323
- return {
1324
- channel: i,
1325
- isConnected: a,
1326
- connect: c,
1327
- disconnect: l,
1328
- getSocketId: u
1329
- };
1330
- }
1331
- //#endregion
1332
- //#region ../core/src/cloud/saved-blocks-provider.ts
1333
- function I(e) {
1334
- let t = new g(e);
1335
- return {
1336
- list(e) {
1337
- return t.listModules(e?.search, e?.category);
1338
- },
1339
- create(e) {
1340
- return t.createModule(e);
1341
- },
1342
- update(e, n) {
1343
- return t.updateModule(e, n);
1344
- },
1345
- delete(e) {
1346
- return t.deleteModule(e);
1347
- }
1348
- };
1349
- }
1350
- //#endregion
1351
- //#region ../core/src/cloud/media-provider.ts
1352
- function L(e) {
1353
- let t = {
1354
- id: e.id,
1355
- url: e.url,
1356
- filename: e.filename,
1357
- alt: e.alt,
1358
- mimeType: e.mimeType,
1359
- folderId: e.folderId,
1360
- createdAt: e.createdAt,
1361
- updatedAt: e.updatedAt,
1362
- size: e.size
1363
- };
1364
- return e.width != null && (t.width = e.width), e.height != null && (t.height = e.height), e.thumbnailUrl != null && (t.thumbnailUrl = e.thumbnailUrl), t;
1365
- }
1366
- function R(e, t = null) {
1367
- return {
1368
- id: e.id,
1369
- name: e.name,
1370
- parentId: e.parentId === void 0 ? t : e.parentId
1371
- };
1372
- }
1373
- function z(e, t = null) {
1374
- let n = [];
1375
- for (let r of e) n.push(R(r, t)), r.children?.length && n.push(...z(r.children, r.id));
1376
- return n;
1377
- }
1378
- function B(e) {
1379
- let t = e?.media?.categories;
1380
- if (!t) return;
1381
- let n = {};
1382
- for (let [e, r] of Object.entries(t)) n[e] = r.mimeTypes;
1383
- return n;
1384
- }
1385
- function V(e, t) {
1386
- let n = new _(e);
1387
- return {
1388
- async list(e) {
1389
- let t = await n.browseMedia({
1390
- search: e?.search,
1391
- cursor: e?.cursor,
1392
- folderId: e?.folderId,
1393
- category: e?.category
1394
- }), r = { items: t.data.map(L) };
1395
- return t.meta.nextCursor && (r.nextCursor = t.meta.nextCursor), r;
1396
- },
1397
- async create(e) {
1398
- return L(await n.uploadMedia(e.file, e.folderId));
1399
- },
1400
- async update(e, t) {
1401
- return L(await n.updateMedia(e, t.filename, t.alt));
1402
- },
1403
- delete(e) {
1404
- return n.deleteMedia(e);
1405
- },
1406
- folders: {
1407
- async list() {
1408
- return z(await n.getMediaFolders());
1409
- },
1410
- async create(e) {
1411
- return R(await n.createMediaFolder(e.name, e.parentId));
1412
- },
1413
- async update(e, t) {
1414
- return R(await n.renameMediaFolder(e, t.name));
1415
- },
1416
- delete(e) {
1417
- return n.deleteMediaFolder(e);
1418
- },
1419
- async move(e, t) {
1420
- return (await n.moveMedia(e, t)).map(L);
1421
- }
1422
- },
1423
- async replace(e, t) {
1424
- return L(await n.replaceMedia(e, t));
1425
- },
1426
- async importFromUrl(e, t) {
1427
- return L(await n.importFromUrl(e, t));
1428
- },
1429
- async checkUsage(e) {
1430
- let t = await n.checkMediaUsage(e), r = {};
1431
- for (let [e, n] of Object.entries(t.data)) r[e] = {
1432
- templateCount: n.templateCount,
1433
- templateNames: n.templateNames
1434
- };
1435
- return r;
1436
- },
1437
- async frequentlyUsed() {
1438
- return (await n.getFrequentlyUsed()).map(L);
1439
- },
1440
- async storage() {
1441
- return t?.()?.storage ?? null;
1442
- },
1443
- get maxFileSize() {
1444
- return t?.()?.media?.maxFileSize;
1445
- },
1446
- get mimeTypes() {
1447
- return B(t?.() ?? null);
1448
- }
1449
- };
1450
- }
1451
- //#endregion
1452
- //#region ../core/src/cloud/templates-provider.ts
1453
- var H = 6e4;
1454
- function U(e) {
1455
- let t = new g(e), n = 0;
1456
- function r(e, r) {
1457
- let i = Date.now();
1458
- i - n < H || (n = i, t.createVersion(e, r).catch((e) => {
1459
- console.warn("[Templatical] Automatic version not recorded — the save itself succeeded:", e);
1460
- }));
1461
- }
1462
- return {
1463
- load(e) {
1464
- return t.getTemplate(e);
1465
- },
1466
- create(e) {
1467
- return t.createTemplate(e.content, e.name);
1468
- },
1469
- async save(e, n) {
1470
- let i = await t.updateTemplate(e, n);
1471
- return n.content && r(e, n.content), i;
1472
- }
1473
- };
1474
- }
1475
- //#endregion
1476
- //#region ../core/src/cloud/export.ts
1477
- function W(e) {
1478
- return {
1479
- customFonts: e?.customFonts ?? [],
1480
- defaultFallback: e?.defaultFallback ?? "Arial, sans-serif"
1481
- };
1482
- }
1483
- function G(e) {
1484
- let t = new g(e.authManager);
1485
- async function n(e, n) {
1486
- let r = await t.exportTemplate(e, n);
1487
- return {
1488
- html: r.html,
1489
- mjml: r.mjml
1490
- };
1491
- }
1492
- async function r(e, n) {
1493
- return (await t.exportTemplate(e, n)).mjml;
1494
- }
1495
- return {
1496
- exportHtml: n,
1497
- getMjmlSource: r
1498
- };
1499
- }
1500
- //#endregion
1501
- //#region ../core/src/cloud/render-provider.ts
1502
- function K(e) {
1503
- let t = G({ authManager: e.authManager });
1504
- function n(e) {
1505
- return {
1506
- customFonts: e.fonts?.customFonts ?? [],
1507
- defaultFallback: e.fonts?.defaultFallback ?? "Arial, sans-serif"
1508
- };
1509
- }
1510
- async function r() {
1511
- if (e.getTemplateId() === null) throw Error("[Templatical] Cloud renders from the saved template, so one must exist first. Call create() or load() before toMjml() / toHtml().");
1512
- return (await e.save()).id;
1513
- }
1514
- return {
1515
- async toMjml(e) {
1516
- let i = n(e), a = await r();
1517
- return t.getMjmlSource(a, i);
1518
- },
1519
- async toHtml(e) {
1520
- let i = n(e), a = await r(), { html: o } = await t.exportHtml(a, i);
1521
- return o;
1522
- }
1523
- };
1524
- }
1525
- //#endregion
1526
- //#region ../core/src/cloud/version-history-provider.ts
1527
- function q(e) {
1528
- return {
1529
- id: e.id,
1530
- createdAt: e.createdAt,
1531
- isAutomatic: e.isAutomatic,
1532
- content: e.content
1533
- };
1534
- }
1535
- function J(e) {
1536
- let t = new g(e);
1537
- return {
1538
- async list(e) {
1539
- return { versions: (await t.getVersions(e)).map(q) };
1540
- },
1541
- async get(e, n) {
1542
- return (await t.getVersion(e, n)).content;
1543
- },
1544
- async create(e, n, r) {
1545
- return q(await t.createVersion(e, n, r?.label));
1546
- },
1547
- restore(e, n) {
1548
- return t.restoreVersion(e, n);
1549
- }
1550
- };
1551
- }
1552
- //#endregion
1553
- //#region ../core/src/cloud/test-email.ts
1554
- function Y(e) {
1555
- let { authManager: r, isAuthReady: a } = e, o = n(null);
1556
- a && t(a, (e) => {
1557
- e && (o.value = r.testEmailConfig);
1558
- }, { immediate: !0 });
1559
- let s = i(() => o.value !== null), c = i(() => o.value?.allowedEmails ?? []);
1560
- function l() {
1561
- return o.value?.signature ?? null;
1562
- }
1563
- return {
1564
- isEnabled: s,
1565
- allowedEmails: c,
1566
- getSignature: l
1567
- };
1568
- }
1569
- //#endregion
1570
- //#region ../core/src/cloud/test-email-provider.ts
1571
- function X(e) {
1572
- let t = new g(e.authManager);
1573
- return {
1574
- get allowedRecipients() {
1575
- return e.allowedEmails.value;
1576
- },
1577
- async send({ recipient: n }) {
1578
- let r = e.getSignature();
1579
- if (r === null) throw Error("Test email is not enabled for this project");
1580
- let i = e.getTemplateId();
1581
- if (i === null) throw Error("Template must be saved before sending a test email");
1582
- await e.save();
1583
- let { html: a } = await e.exportHtml(i);
1584
- e.onBeforeTestEmail && (a = await e.onBeforeTestEmail(a)), await t.sendTestEmail(i, {
1585
- recipient: n,
1586
- html: a,
1587
- allowedEmails: e.allowedEmails.value,
1588
- signature: r
1589
- });
1590
- }
1591
- };
1592
- }
1593
- //#endregion
1594
- //#region ../core/src/cloud/plan-config.ts
1595
- function Z(e) {
1596
- let { authManager: t, onError: r } = e, a = n(null), o = n(!1), s = new g(t), c = i(() => a.value?.features ?? null);
1597
- function l(e) {
1598
- return a.value?.features[e] ?? !1;
1599
- }
1600
- async function u() {
1601
- if (!o.value) {
1602
- o.value = !0;
1603
- try {
1604
- a.value = await s.fetchConfig();
1605
- } catch (e) {
1606
- r?.(e instanceof Error ? e : Error("Failed to fetch config", { cause: e }));
1607
- } finally {
1608
- o.value = !1;
1609
- }
1610
- }
1611
- }
1612
- return {
1613
- config: a,
1614
- isLoading: o,
1615
- hasFeature: l,
1616
- features: c,
1617
- fetchConfig: u
1618
- };
1619
- }
1620
- //#endregion
1621
- //#region ../core/src/cloud/health-check.ts
1622
- var Q = 5e3;
1623
- function $(e) {
1624
- return e.authManager ? e.authManager.resolveUrl(h.health) : `${(e.baseUrl ?? "https://templatical.com").replace(/\/$/, "")}${h.health}`;
1625
- }
1626
- async function ee(e, t) {
1627
- let n = performance.now();
1628
- try {
1629
- let r = t ? await t.authenticatedFetch(h.health, {
1630
- method: "GET",
1631
- headers: { Accept: "application/json" }
1632
- }) : await fetch(e, {
1633
- method: "GET",
1634
- headers: { Accept: "application/json" }
1635
- }), i = Math.round(performance.now() - n);
1636
- if (r.status === 401) return {
1637
- api: {
1638
- ok: !0,
1639
- latency: i
1640
- },
1641
- auth: {
1642
- ok: !1,
1643
- error: "HTTP 401"
1644
- }
1645
- };
1646
- if (!r.ok) return {
1647
- api: {
1648
- ok: !1,
1649
- latency: i
1650
- },
1651
- auth: {
1652
- ok: !t,
1653
- error: t ? `HTTP ${r.status}` : void 0
1654
- }
1655
- };
1656
- let a = await r.json();
1657
- return {
1658
- api: {
1659
- ok: a.status === "ok",
1660
- latency: i
1661
- },
1662
- auth: { ok: !0 },
1663
- wsConfig: a.websocket
1664
- };
1665
- } catch (e) {
1666
- return {
1667
- api: {
1668
- ok: !1,
1669
- latency: Math.round(performance.now() - n)
1670
- },
1671
- auth: {
1672
- ok: !t,
1673
- error: t ? e instanceof Error ? e.message : "Authentication check failed" : void 0
1674
- }
1675
- };
1676
- }
1677
- }
1678
- async function te(e) {
1679
- if (!e?.host || !e?.appKey) return {
1680
- ok: !1,
1681
- error: "WebSocket configuration not available"
1682
- };
1683
- if (typeof WebSocket > "u") return {
1684
- ok: !1,
1685
- error: "WebSocket not supported in this environment"
1686
- };
1687
- let t = `${e.port === 443 ? "wss" : "ws"}://${e.host}:${e.port}/app/${e.appKey}?protocol=7&client=js&version=8.4.0-rc2&flash=false`;
1688
- return new Promise((e) => {
1689
- let n = null, r = setTimeout(() => {
1690
- n?.close(), e({
1691
- ok: !1,
1692
- error: "WebSocket connection timed out"
1693
- });
1694
- }, Q);
1695
- try {
1696
- n = new WebSocket(t);
1697
- } catch (t) {
1698
- clearTimeout(r), e({
1699
- ok: !1,
1700
- error: t instanceof Error ? t.message : "WebSocket connection failed"
1701
- });
1702
- return;
1703
- }
1704
- n.onopen = () => {
1705
- clearTimeout(r), n?.close(), e({ ok: !0 });
1706
- }, n.onerror = () => {
1707
- clearTimeout(r), e({
1708
- ok: !1,
1709
- error: "WebSocket connection failed"
1710
- });
1711
- };
1712
- });
1713
- }
1714
- async function ne(e = {}) {
1715
- let t = await ee($(e), e.authManager), n = await te(t.wsConfig);
1716
- return {
1717
- api: t.api,
1718
- websocket: n,
1719
- auth: t.auth,
1720
- overall: t.api.ok && t.auth.ok
1721
- };
1722
- }
1723
- //#endregion
1724
- //#region ../core/src/cloud/mcp-listener.ts
1725
- function re(e) {
1726
- let { editor: n, channel: r, onOperation: i } = e;
1727
- t(r, (e, t) => {
1728
- t && t.unbind("mcp-operation"), e && e.bind("mcp-operation", (e) => {
1729
- b(n, e), i?.(e);
1730
- });
1731
- });
1732
- }
1733
- //#endregion
1734
- export { o as C, s as S, E as _, Y as a, C as b, W as c, V as d, I as f, k as g, N as h, X as i, G as l, P as m, ne as n, J as o, F as p, Z as r, K as s, re as t, U as u, T as v, v as x, w as y };
1735
-
1736
- //# sourceMappingURL=cloud-BHClP3e2.js.map