@templatical/editor 0.52.1 → 0.53.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 +1 -1
  2. package/dist/AiAltTextPopover-NMJqQKvD.js +106 -0
  3. package/dist/{AiAltTextReview-9ySsXOTU.js → AiAltTextReview-Ci4zHwRc.js} +68 -66
  4. package/dist/AiChatPanel-DdhtfsmO.js +561 -0
  5. package/dist/{AiPanels-DqT4PgQ0.js → AiPanels-HBx7xoJR.js} +6 -6
  6. package/dist/{AiRewriteMenu-28agTycW.js → AiRewriteMenu-DPzSekZt.js} +76 -105
  7. package/dist/BlockIssueBadge-eIXZJ9M3.js +33 -0
  8. package/dist/BlockPreviewCanvas-DO-2TP_6.js +140 -0
  9. package/dist/{CloudHeaderExtras-QI82yF54.js → CloudHeaderExtras-XpjJjn3o.js} +4 -4
  10. package/dist/{CloudPanels-BKJaLkUN.js → CloudPanels-i2kZdrdP.js} +53 -53
  11. package/dist/CollaborationNotices-DANsjl7c.js +65 -0
  12. package/dist/{CollaboratorBar-CXQqN3VP.js → CollaboratorBar-CbbAA0m1.js} +24 -24
  13. package/dist/CommentsPanel-CYW3LWis.js +16 -0
  14. package/dist/CommentsSidebar-CcF4ISMi.js +526 -0
  15. package/dist/{CountdownBlock-CU2yTWtF.js → CountdownBlock-BMezkFbJ.js} +15 -15
  16. package/dist/CountdownToolbar-D3Lv74kU.js +258 -0
  17. package/dist/IssuesPanel-BMAG9042.js +371 -0
  18. package/dist/LanguageMenu-FlP_Jbup.js +403 -0
  19. package/dist/{LoadingTrack-DM4g6j7b.js → LoadingTrack-BG8cg9xi.js} +2 -2
  20. package/dist/LocaleNotices-DAnVszWu.js +46 -0
  21. package/dist/LogicTagInsertButton-BjYs-UQX.js +1096 -0
  22. package/dist/{MediaEditModal-Dy08GEwE.js → MediaEditModal-LnG-cF_S.js} +451 -451
  23. package/dist/{MediaPanels-BgEp7iCp.js → MediaPanels-C2r5fiFo.js} +4 -4
  24. package/dist/{MergeTagInput-B9dtUthD.js → MergeTagInput-BsnogCeY.js} +30 -30
  25. package/dist/{MergeTagModeToggle-DxujhYJ4.js → MergeTagModeToggle-DiufIQ-_.js} +49 -49
  26. package/dist/MergeTagTextarea-BweI-Xsi.js +126 -0
  27. package/dist/ParagraphEditor-qgBp5yIB.js +825 -0
  28. package/dist/{RestoreVersionDialog-C4s_JYCx.js → RestoreVersionDialog-DdYUrFiK.js} +23 -23
  29. package/dist/{RichTextEditorContent-o6HmE8GR.js → RichTextEditorContent-C5MAzx3E.js} +47 -47
  30. package/dist/{SaveBlockDialog-CWLrly6l.js → SaveBlockDialog-eK6fjtTy.js} +86 -86
  31. package/dist/{cdn/chunks/SavedBlocksBrowserModal-BPYcRoGa.js → SavedBlocksBrowserModal-D2QHd2Yp.js} +135 -132
  32. package/dist/{SavedBlocksPanels-BE1N9rNZ.js → SavedBlocksPanels-Cl61f4Mf.js} +9 -9
  33. package/dist/{SavedBlocksPickBar-Dwl94xhP.js → SavedBlocksPickBar-CXP2dkeB.js} +15 -15
  34. package/dist/TemplateSettings-BKJrdZcH.js +294 -0
  35. package/dist/TestEmailModal-DQotJg6g.js +212 -0
  36. package/dist/{TestEmailPanel-DaFjP9QK.js → TestEmailPanel-CwiTzJsh.js} +4 -4
  37. package/dist/TitleEditor-CzSvsPAn.js +202 -0
  38. package/dist/ToggleSwitch-R3wCCYE6.js +43 -0
  39. package/dist/Toolbar-Cd75ci5W.js +3711 -0
  40. package/dist/{TplModal-DLMssVlt.js → TplModal-ZoXu40T9.js} +17 -17
  41. package/dist/{VersionHistoryMenu-BkbYUs0Q.js → VersionHistoryMenu-BvhN-Ofk.js} +39 -39
  42. package/dist/{VersionHistoryPanels-DP7HaYWv.js → VersionHistoryPanels-DPWMnYbd.js} +5 -5
  43. package/dist/VersionPreviewBanner-CuJnasxH.js +37 -0
  44. package/dist/WrapperBlock-D4fPwO0t.js +44 -0
  45. package/dist/{blockTypeIcons-BHjlPnPf.js → blockTypeIcons-BXMxu86H.js} +7 -7
  46. package/dist/bundle-stats.json +8 -8
  47. package/dist/{cdn/chunks/ca-CD-Kt1qz.js → ca-DOuIxWRv.js} +114 -2
  48. package/dist/cdn/chunks/AiAltTextPopover-ByZ0FEqI.js +107 -0
  49. package/dist/cdn/chunks/AiAltTextPopover-ByZ0FEqI.js.map +1 -0
  50. package/dist/cdn/chunks/{AiAltTextReview-BGLLSKLm.js → AiAltTextReview-Dtm3A2cD.js} +70 -68
  51. package/dist/cdn/chunks/AiAltTextReview-Dtm3A2cD.js.map +1 -0
  52. package/dist/cdn/chunks/AiChatPanel-DciEt27y.js +487 -0
  53. package/dist/cdn/chunks/AiChatPanel-DciEt27y.js.map +1 -0
  54. package/dist/cdn/chunks/{AiPanels-0wBarZSH.js → AiPanels-BV5D1itk.js} +11 -11
  55. package/dist/cdn/chunks/{AiPanels-0wBarZSH.js.map → AiPanels-BV5D1itk.js.map} +1 -1
  56. package/dist/cdn/chunks/{AiRewriteMenu-qf-cfEpy.js → AiRewriteMenu-D3jkh6Xb.js} +79 -79
  57. package/dist/cdn/chunks/AiRewriteMenu-D3jkh6Xb.js.map +1 -0
  58. package/dist/cdn/chunks/BlockIssueBadge-DyEgBZtR.js +34 -0
  59. package/dist/cdn/chunks/BlockIssueBadge-DyEgBZtR.js.map +1 -0
  60. package/dist/cdn/chunks/BlockPreviewCanvas-RQFilqXC.js +142 -0
  61. package/dist/cdn/chunks/{BlockPreviewCanvas-DGBh6mqe.js.map → BlockPreviewCanvas-RQFilqXC.js.map} +1 -1
  62. package/dist/cdn/chunks/{CloudHeaderExtras-BMNK_F9p.js → CloudHeaderExtras-BtqdN777.js} +4 -4
  63. package/dist/cdn/chunks/{CloudHeaderExtras-BMNK_F9p.js.map → CloudHeaderExtras-BtqdN777.js.map} +1 -1
  64. package/dist/cdn/chunks/{CloudPanels-JMWIoVWh.js → CloudPanels-BSJ-Z5Hw.js} +45 -45
  65. package/dist/cdn/chunks/{CloudPanels-JMWIoVWh.js.map → CloudPanels-BSJ-Z5Hw.js.map} +1 -1
  66. package/dist/cdn/chunks/CollaborationNotices-BS7xrlPE.js +67 -0
  67. package/dist/cdn/chunks/CollaborationNotices-BS7xrlPE.js.map +1 -0
  68. package/dist/cdn/chunks/{CollaboratorBar-CXByAoUz.js → CollaboratorBar-Bc9914Az.js} +17 -17
  69. package/dist/cdn/chunks/{CollaboratorBar-CXByAoUz.js.map → CollaboratorBar-Bc9914Az.js.map} +1 -1
  70. package/dist/cdn/chunks/CommentsPanel-DbR9phAk.js +18 -0
  71. package/dist/cdn/chunks/{CommentsPanel-DoJnKLXI.js.map → CommentsPanel-DbR9phAk.js.map} +1 -1
  72. package/dist/cdn/chunks/CommentsSidebar-BD4--XP2.js +496 -0
  73. package/dist/cdn/chunks/CommentsSidebar-BD4--XP2.js.map +1 -0
  74. package/dist/cdn/chunks/{CountdownBlock-BqRw147R.js → CountdownBlock-CjMhMhnv.js} +22 -22
  75. package/dist/cdn/chunks/{CountdownBlock-BqRw147R.js.map → CountdownBlock-CjMhMhnv.js.map} +1 -1
  76. package/dist/cdn/chunks/CountdownToolbar-DxwYBw-d.js +260 -0
  77. package/dist/cdn/chunks/CountdownToolbar-DxwYBw-d.js.map +1 -0
  78. package/dist/cdn/chunks/{IssuesPanel-C7LfxaAY.js → IssuesPanel-CUmI4HMm.js} +133 -121
  79. package/dist/cdn/chunks/IssuesPanel-CUmI4HMm.js.map +1 -0
  80. package/dist/cdn/chunks/LanguageMenu-3ydCozQJ.js +359 -0
  81. package/dist/cdn/chunks/LanguageMenu-3ydCozQJ.js.map +1 -0
  82. package/dist/cdn/chunks/{LoadingTrack-CZuLTazv.js → LoadingTrack-DUYcDHOV.js} +2 -2
  83. package/dist/cdn/chunks/{LoadingTrack-CZuLTazv.js.map → LoadingTrack-DUYcDHOV.js.map} +1 -1
  84. package/dist/cdn/chunks/LocaleNotices-BfoH6gST.js +47 -0
  85. package/dist/cdn/chunks/LocaleNotices-BfoH6gST.js.map +1 -0
  86. package/dist/{LogicTagInsertButton-CfscnwCn.js → cdn/chunks/LogicTagInsertButton-5Z3fFzjc.js} +422 -449
  87. package/dist/cdn/chunks/LogicTagInsertButton-5Z3fFzjc.js.map +1 -0
  88. package/dist/cdn/chunks/{MediaEditModal-Cpcod6_U.js → MediaEditModal-DDCIwr9U.js} +421 -421
  89. package/dist/cdn/chunks/MediaEditModal-DDCIwr9U.js.map +1 -0
  90. package/dist/cdn/chunks/{MediaPanels-BIdcW_1f.js → MediaPanels-Dz79oy8P.js} +5 -5
  91. package/dist/cdn/chunks/{MediaPanels-BIdcW_1f.js.map → MediaPanels-Dz79oy8P.js.map} +1 -1
  92. package/dist/cdn/chunks/{MergeTagInput-BvWg8o5E.js → MergeTagInput-CIWy-cXf.js} +28 -28
  93. package/dist/cdn/chunks/{MergeTagInput-BvWg8o5E.js.map → MergeTagInput-CIWy-cXf.js.map} +1 -1
  94. package/dist/cdn/chunks/{MergeTagModeToggle-BgKEVUtV.js → MergeTagModeToggle-BrP5GR-x.js} +52 -52
  95. package/dist/cdn/chunks/MergeTagModeToggle-BrP5GR-x.js.map +1 -0
  96. package/dist/cdn/chunks/MergeTagTextarea-D3nNDlhV.js +128 -0
  97. package/dist/cdn/chunks/MergeTagTextarea-D3nNDlhV.js.map +1 -0
  98. package/dist/cdn/chunks/ParagraphEditor-DDolH_Pf.js +660 -0
  99. package/dist/cdn/chunks/ParagraphEditor-DDolH_Pf.js.map +1 -0
  100. package/dist/cdn/chunks/{RestoreVersionDialog-CjOdD2xj.js → RestoreVersionDialog-Crj1DBqC.js} +22 -22
  101. package/dist/cdn/chunks/{RestoreVersionDialog-CjOdD2xj.js.map → RestoreVersionDialog-Crj1DBqC.js.map} +1 -1
  102. package/dist/cdn/chunks/{RichTextEditorContent-DNjR_sNN.js → RichTextEditorContent-rCCqFlwJ.js} +44 -44
  103. package/dist/cdn/chunks/{RichTextEditorContent-DNjR_sNN.js.map → RichTextEditorContent-rCCqFlwJ.js.map} +1 -1
  104. package/dist/cdn/chunks/{SaveBlockDialog-CUhpawq0.js → SaveBlockDialog-C34RW1aM.js} +77 -77
  105. package/dist/cdn/chunks/{SaveBlockDialog-CUhpawq0.js.map → SaveBlockDialog-C34RW1aM.js.map} +1 -1
  106. package/dist/{SavedBlocksBrowserModal-CE8n4EBS.js → cdn/chunks/SavedBlocksBrowserModal-CJnwWPT-.js} +103 -106
  107. package/dist/cdn/chunks/{SavedBlocksBrowserModal-BPYcRoGa.js.map → SavedBlocksBrowserModal-CJnwWPT-.js.map} +1 -1
  108. package/dist/cdn/chunks/{SavedBlocksPanels-C6--Bc81.js → SavedBlocksPanels-CA2PqXIH.js} +9 -9
  109. package/dist/cdn/chunks/{SavedBlocksPanels-C6--Bc81.js.map → SavedBlocksPanels-CA2PqXIH.js.map} +1 -1
  110. package/dist/cdn/chunks/{SavedBlocksPickBar-DUavxpbU.js → SavedBlocksPickBar-Dj3ortee.js} +16 -16
  111. package/dist/cdn/chunks/{SavedBlocksPickBar-DUavxpbU.js.map → SavedBlocksPickBar-Dj3ortee.js.map} +1 -1
  112. package/dist/cdn/chunks/TemplateSettings-sW0ZlDl1.js +266 -0
  113. package/dist/cdn/chunks/TemplateSettings-sW0ZlDl1.js.map +1 -0
  114. package/dist/cdn/chunks/TestEmailModal-BXeCtTjU.js +212 -0
  115. package/dist/cdn/chunks/TestEmailModal-BXeCtTjU.js.map +1 -0
  116. package/dist/cdn/chunks/{TestEmailPanel-CcUpEpAn.js → TestEmailPanel-CpZcpB9D.js} +5 -5
  117. package/dist/cdn/chunks/{TestEmailPanel-CcUpEpAn.js.map → TestEmailPanel-CpZcpB9D.js.map} +1 -1
  118. package/dist/cdn/chunks/TitleEditor-Bv3SmSO6.js +202 -0
  119. package/dist/cdn/chunks/TitleEditor-Bv3SmSO6.js.map +1 -0
  120. package/dist/cdn/chunks/ToggleSwitch-BSkySwA1.js +45 -0
  121. package/dist/cdn/chunks/ToggleSwitch-BSkySwA1.js.map +1 -0
  122. package/dist/cdn/chunks/Toolbar-BJKpJ2Mg.js +3626 -0
  123. package/dist/cdn/chunks/Toolbar-BJKpJ2Mg.js.map +1 -0
  124. package/dist/cdn/chunks/{TplModal-CFPDgbwQ.js → TplModal-DDDUDMYC.js} +20 -20
  125. package/dist/cdn/chunks/{TplModal-CFPDgbwQ.js.map → TplModal-DDDUDMYC.js.map} +1 -1
  126. package/dist/cdn/chunks/{VersionHistoryMenu-BYlLRvRJ.js → VersionHistoryMenu-DSElv3Sv.js} +33 -33
  127. package/dist/cdn/chunks/{VersionHistoryMenu-BYlLRvRJ.js.map → VersionHistoryMenu-DSElv3Sv.js.map} +1 -1
  128. package/dist/cdn/chunks/{VersionHistoryPanels-C6SOVoiT.js → VersionHistoryPanels-H2nuik1l.js} +6 -6
  129. package/dist/cdn/chunks/{VersionHistoryPanels-C6SOVoiT.js.map → VersionHistoryPanels-H2nuik1l.js.map} +1 -1
  130. package/dist/cdn/chunks/VersionPreviewBanner-Whwxh55w.js +39 -0
  131. package/dist/cdn/chunks/VersionPreviewBanner-Whwxh55w.js.map +1 -0
  132. package/dist/cdn/chunks/WrapperBlock-jTqsuLnS.js +46 -0
  133. package/dist/cdn/chunks/WrapperBlock-jTqsuLnS.js.map +1 -0
  134. package/dist/cdn/chunks/{blockTypeIcons-D7FW7Ypo.js → blockTypeIcons-DMgLcuI8.js} +5 -5
  135. package/dist/cdn/chunks/{blockTypeIcons-D7FW7Ypo.js.map → blockTypeIcons-DMgLcuI8.js.map} +1 -1
  136. package/dist/{ca-CD-Kt1qz.js → cdn/chunks/ca-DOuIxWRv.js} +116 -0
  137. package/dist/cdn/chunks/ca-DOuIxWRv.js.map +1 -0
  138. package/dist/cdn/chunks/composables-D0UYam2P.js +3039 -0
  139. package/dist/cdn/chunks/composables-D0UYam2P.js.map +1 -0
  140. package/dist/cdn/chunks/{createCloudRuntime-Cth2JCEh.js → createCloudRuntime-BdsclY8_.js} +75 -73
  141. package/dist/cdn/chunks/createCloudRuntime-BdsclY8_.js.map +1 -0
  142. package/dist/{de-CeFJ6wbM.js → cdn/chunks/de-DaOUfYBX.js} +116 -0
  143. package/dist/cdn/chunks/de-DaOUfYBX.js.map +1 -0
  144. package/dist/cdn/chunks/{dist-8ym3y-pH.js → dist-BzXULHvI.js} +48 -48
  145. package/dist/cdn/chunks/{dist-8ym3y-pH.js.map → dist-BzXULHvI.js.map} +1 -1
  146. package/dist/cdn/chunks/{dist-BMzNabtD.js → dist-DqGgijFI.js} +114 -114
  147. package/dist/cdn/chunks/{dist-BMzNabtD.js.map → dist-DqGgijFI.js.map} +1 -1
  148. package/dist/cdn/chunks/{draggable-Du8AUMFT.js → draggable-DepKdldn.js} +1491 -1486
  149. package/dist/cdn/chunks/draggable-DepKdldn.js.map +1 -0
  150. package/dist/cdn/chunks/{editor-modal-CyCe560f.js → editor-modal-CPbgthOv.js} +781 -781
  151. package/dist/cdn/chunks/{editor-modal-CyCe560f.js.map → editor-modal-CPbgthOv.js.map} +1 -1
  152. package/dist/{en-D14i5nFh.js → cdn/chunks/en-C0pHHMiR.js} +116 -0
  153. package/dist/cdn/chunks/en-C0pHHMiR.js.map +1 -0
  154. package/dist/cdn/chunks/en-IYVryJRl.js +1 -0
  155. package/dist/{es-zDacbMhs.js → cdn/chunks/es-CxyEKr6n.js} +116 -0
  156. package/dist/cdn/chunks/es-CxyEKr6n.js.map +1 -0
  157. package/dist/cdn/chunks/{extensions-CFF2KWy-.js → extensions-Uh9vuFfK.js} +59 -59
  158. package/dist/cdn/chunks/{extensions-CFF2KWy-.js.map → extensions-Uh9vuFfK.js.map} +1 -1
  159. package/dist/{fr-CSgYtjOd.js → cdn/chunks/fr-CYbamiI6.js} +116 -0
  160. package/dist/cdn/chunks/fr-CYbamiI6.js.map +1 -0
  161. package/dist/cdn/chunks/{icons-okSPsLOa.js → icons-CSSMtbGK.js} +150 -109
  162. package/dist/cdn/chunks/icons-CSSMtbGK.js.map +1 -0
  163. package/dist/{ja-B7H3ID8O.js → cdn/chunks/ja-DfaIAoGI.js} +116 -0
  164. package/dist/cdn/chunks/ja-DfaIAoGI.js.map +1 -0
  165. package/dist/cdn/chunks/keys-CoQtCqNv.js +11 -0
  166. package/dist/cdn/chunks/keys-CoQtCqNv.js.map +1 -0
  167. package/dist/cdn/chunks/languageName-DEEOhDWI.js +12 -0
  168. package/dist/cdn/chunks/languageName-DEEOhDWI.js.map +1 -0
  169. package/dist/{nl-176ySmc5.js → cdn/chunks/nl-DkrB-VKZ.js} +116 -0
  170. package/dist/cdn/chunks/nl-DkrB-VKZ.js.map +1 -0
  171. package/dist/cdn/chunks/normalizeMergeTagMarkup-oGhwVscw.js +290 -0
  172. package/dist/cdn/chunks/normalizeMergeTagMarkup-oGhwVscw.js.map +1 -0
  173. package/dist/cdn/chunks/noticeTones-D7BPu-Le.js +16 -0
  174. package/dist/cdn/chunks/noticeTones-D7BPu-Le.js.map +1 -0
  175. package/dist/cdn/chunks/plural-CyxrJXL1.js +17 -0
  176. package/dist/cdn/chunks/plural-CyxrJXL1.js.map +1 -0
  177. package/dist/cdn/chunks/{preRenderCustomBlocks-BcXIz7oJ.js → preRenderCustomBlocks-C8k7tw98.js} +5 -5
  178. package/dist/cdn/chunks/{preRenderCustomBlocks-BcXIz7oJ.js.map → preRenderCustomBlocks-C8k7tw98.js.map} +1 -1
  179. package/dist/{pt-BR-dDlTwX18.js → cdn/chunks/pt-BR-CY5Ye7eP.js} +116 -0
  180. package/dist/cdn/chunks/pt-BR-CY5Ye7eP.js.map +1 -0
  181. package/dist/cdn/chunks/sanitizeHtml-DYklmvgX.js +61 -0
  182. package/dist/cdn/chunks/sanitizeHtml-DYklmvgX.js.map +1 -0
  183. package/dist/cdn/chunks/socialIcons-BAiuHyJs.js +2638 -0
  184. package/dist/cdn/chunks/socialIcons-BAiuHyJs.js.map +1 -0
  185. package/dist/cdn/chunks/src-CACM3o--.js +2606 -0
  186. package/dist/cdn/chunks/src-CACM3o--.js.map +1 -0
  187. package/dist/cdn/chunks/{src-C7bkofBL.js → src-Ddpm4HsS.js} +222 -256
  188. package/dist/cdn/chunks/src-Ddpm4HsS.js.map +1 -0
  189. package/dist/cdn/chunks/{src-DEd87i_U.js → src-DheBmnvF.js} +635 -478
  190. package/dist/cdn/chunks/src-DheBmnvF.js.map +1 -0
  191. package/dist/{styleConstants-B8xVRiwX.js → cdn/chunks/styleConstants-CgiNKdnc.js} +7 -5
  192. package/dist/cdn/chunks/styleConstants-CgiNKdnc.js.map +1 -0
  193. package/dist/cdn/chunks/templateSettingsFields-cjlP-jdw.js.map +1 -1
  194. package/dist/cdn/chunks/{tiptap-CbiTlECY.js → tiptap-Dipw_zOQ.js} +40 -40
  195. package/dist/cdn/chunks/{tiptap-CbiTlECY.js.map → tiptap-Dipw_zOQ.js.map} +1 -1
  196. package/dist/cdn/chunks/{useCloudI18n-DY8_-ETE.js → useCloudI18n-Cc5NZqiI.js} +3 -3
  197. package/dist/cdn/chunks/{useCloudI18n-DY8_-ETE.js.map → useCloudI18n-Cc5NZqiI.js.map} +1 -1
  198. package/dist/cdn/chunks/useEditorRoot-D_LuZ_hE.js +9 -0
  199. package/dist/cdn/chunks/{useEditorRoot-vjZJwKrV.js.map → useEditorRoot-D_LuZ_hE.js.map} +1 -1
  200. package/dist/cdn/chunks/{useI18n-D8pY4LTq.js → useI18n-BnJYydPv.js} +3 -3
  201. package/dist/cdn/chunks/{useI18n-D8pY4LTq.js.map → useI18n-BnJYydPv.js.map} +1 -1
  202. package/dist/cdn/chunks/useLocalizedDisplay-yXbRKNrs.js +33 -0
  203. package/dist/cdn/chunks/useLocalizedDisplay-yXbRKNrs.js.map +1 -0
  204. package/dist/cdn/chunks/{useLogicTag-DBJDtpKA.js → useLogicTag-B7RpqVFQ.js} +5 -5
  205. package/dist/cdn/chunks/{useLogicTag-DBJDtpKA.js.map → useLogicTag-B7RpqVFQ.js.map} +1 -1
  206. package/dist/cdn/chunks/{useMergeTag-B-aG--s1.js → useMergeTag-C-32ETjj.js} +6 -6
  207. package/dist/cdn/chunks/{useMergeTag-B-aG--s1.js.map → useMergeTag-C-32ETjj.js.map} +1 -1
  208. package/dist/cdn/chunks/usePopoverPosition-BWAXWeBv.js +78 -0
  209. package/dist/cdn/chunks/usePopoverPosition-BWAXWeBv.js.map +1 -0
  210. package/dist/cdn/chunks/{useScrollToBlock-vjQ0fe-L.js → useScrollToBlock-Ct1AwLD-.js} +5 -5
  211. package/dist/cdn/chunks/useScrollToBlock-Ct1AwLD-.js.map +1 -0
  212. package/dist/cdn/chunks/{withCurrentFont-hZTvYBHO.js → withCurrentFont-D33ZXoWp.js} +2 -2
  213. package/dist/cdn/chunks/{withCurrentFont-hZTvYBHO.js.map → withCurrentFont-D33ZXoWp.js.map} +1 -1
  214. package/dist/cdn/editor.css +1 -1
  215. package/dist/cdn/editor.js +2190 -1496
  216. package/dist/cdn/editor.js.map +1 -1
  217. package/dist/{check-BZ8o0eet.js → check-ChQ0l8EQ.js} +1 -1
  218. package/dist/{chevron-down-DfAAfILv.js → chevron-down-Bh6cp6PI.js} +1 -1
  219. package/dist/{chevron-right-Bk4mGdr7.js → chevron-right-LUgdqdoW.js} +1 -1
  220. package/dist/{chevron-up-MhUf_azW.js → chevron-up-XsDeJxQN.js} +1 -1
  221. package/dist/{circle-alert-CShJwVFv.js → circle-alert-lODfDsrj.js} +1 -1
  222. package/dist/{clock-CTfD6OCt.js → clock-DrqFEZkT.js} +1 -1
  223. package/dist/composables-BOP3ERRP.js +4517 -0
  224. package/dist/{createCloudRuntime-DCgO4A1r.js → createCloudRuntime-DGV5a5Af.js} +54 -52
  225. package/dist/{createLucideIcon-CvhTA2KG.js → createLucideIcon-Dw5e5gVE.js} +11 -11
  226. package/dist/{cdn/chunks/de-CeFJ6wbM.js → de-DaOUfYBX.js} +114 -2
  227. package/dist/{dist-ByCWA2Tv.js → dist-0alKVRc_.js} +101 -101
  228. package/dist/{dist-Cy8I5scI.js → dist-54VCNoC0.js} +2 -2
  229. package/dist/dist-6DU0me3E.js +4 -0
  230. package/dist/{dist-p3wymUDt.js → dist-B8dY8drK.js} +2 -2
  231. package/dist/{dist-Dd5MU2Ev.js → dist-B9a7iVye.js} +2 -2
  232. package/dist/{dist-V7W1UhVr.js → dist-BWflWcpW.js} +2 -2
  233. package/dist/{dist-D6fZec6r.js → dist-C3hu_C3w.js} +2 -2
  234. package/dist/{dist-CVy-7PHQ.js → dist-CX7skkvG.js} +48 -48
  235. package/dist/dist-CcOn7WCo.js +4 -0
  236. package/dist/dist-Cdkm20M6.js +2542 -0
  237. package/dist/{dist-BS5uKktL.js → dist-ChOb5XHW.js} +2 -2
  238. package/dist/{dist-BF5zEHop.js → dist-DZ3X-uB8.js} +2 -2
  239. package/dist/{dist-CWSG7Kj0.js → dist-D_XrUEET.js} +5 -5
  240. package/dist/{dist-txQLT2sF.js → dist-TAv500j6.js} +2 -2
  241. package/dist/{dist-D6cMdrfG.js → dist-fqSers8_.js} +55 -55
  242. package/dist/{editor-modal-zaZHcmlO.js → editor-modal-B_2EAOjN.js} +953 -952
  243. package/dist/{cdn/chunks/en-D14i5nFh.js → en-C0pHHMiR.js} +114 -2
  244. package/dist/en-DTtwco2Q.js +1 -0
  245. package/dist/{cdn/chunks/es-zDacbMhs.js → es-CxyEKr6n.js} +114 -2
  246. package/dist/{extensions-fo_c-vqf.js → extensions-DOLZkLzV.js} +173 -173
  247. package/dist/{eye-7W4t5e0Q.js → eye-DChfk0gi.js} +1 -1
  248. package/dist/{cdn/chunks/fr-CSgYtjOd.js → fr-CYbamiI6.js} +114 -2
  249. package/dist/{image-BDiRFzSd.js → image--Hj2by1G.js} +1 -1
  250. package/dist/index.d.ts +182 -14
  251. package/dist/{info-Cxi3-Kh9.js → info-BbXgy82f.js} +1 -1
  252. package/dist/{cdn/chunks/ja-B7H3ID8O.js → ja-DfaIAoGI.js} +114 -2
  253. package/dist/keys-BCqskl51.js +9 -0
  254. package/dist/languageName-DEEOhDWI.js +10 -0
  255. package/dist/{link-ju_2Cmir.js → link-C2_8yJno.js} +1 -1
  256. package/dist/{list-DYZJf0aZ.js → list-DLGs2n0V.js} +1 -1
  257. package/dist/{loader-circle-BZRD0a4I.js → loader-circle-BbDItE_O.js} +1 -1
  258. package/dist/{message-circle-DuEw4Zfx.js → message-circle-NAModq0p.js} +1 -1
  259. package/dist/{cdn/chunks/nl-176ySmc5.js → nl-DkrB-VKZ.js} +114 -2
  260. package/dist/normalizeMergeTagMarkup-CUCo7B5X.js +288 -0
  261. package/dist/noticeTones-D7BPu-Le.js +14 -0
  262. package/dist/{package-CePMr2kK.js → package-BuzsfRyH.js} +1 -1
  263. package/dist/{pencil-D3aFCL7c.js → pencil-BTUUECH4.js} +1 -1
  264. package/dist/plural-CyxrJXL1.js +15 -0
  265. package/dist/plus-Dm7DN65T.js +13 -0
  266. package/dist/{preRenderCustomBlocks--_xc0XK3.js → preRenderCustomBlocks-Bs3N9no-.js} +4 -4
  267. package/dist/{cdn/chunks/pt-BR-dDlTwX18.js → pt-BR-CY5Ye7eP.js} +114 -2
  268. package/dist/{refresh-cw-xnro7_Sk.js → refresh-cw-xMURqGWi.js} +2 -12
  269. package/dist/rotate-ccw-DqVcEIn5.js +13 -0
  270. package/dist/{runtime-dom.esm-bundler-BURR-bj5.js → runtime-dom.esm-bundler-DlHp8xgy.js} +154 -154
  271. package/dist/sanitizeHtml-mKgNUdME.js +962 -0
  272. package/dist/{search-CDrstRBv.js → search-Cfr3W44N.js} +1 -1
  273. package/dist/{send-DROkPOaX.js → send-CH1SrvyB.js} +1 -1
  274. package/dist/{smartphone-Bx6u_tjn.js → smartphone-pAkvzjdI.js} +1 -1
  275. package/dist/socialIcons-Dqr4DJOz.js +2705 -0
  276. package/dist/{sparkles-CdaTtvoz.js → sparkles-CRO0cCnp.js} +1 -1
  277. package/dist/{square-BbCROH_f.js → square-CaQWMntx.js} +1 -1
  278. package/dist/style.css +1 -1
  279. package/dist/{cdn/chunks/styleConstants-B8xVRiwX.js → styleConstants-CgiNKdnc.js} +5 -7
  280. package/dist/templatical-editor.js +2438 -1752
  281. package/dist/{text-align-start-CGacJ9Vw.js → text-align-start-BQ39AaRK.js} +1 -1
  282. package/dist/{trash-DxCd7zIy.js → trash-BL5gEFHN.js} +1 -1
  283. package/dist/{triangle-alert-7_oaitpf.js → triangle-alert-BYbKu7zZ.js} +1 -1
  284. package/dist/{upload-DuFEOi_0.js → upload-BhmL4Vqx.js} +1 -1
  285. package/dist/{useCloudI18n-DEMmUKuO.js → useCloudI18n-Dh2iydo1.js} +4 -4
  286. package/dist/useEditorRoot-DY3mgcHm.js +7 -0
  287. package/dist/{useI18n-BBrHTdu8.js → useI18n-CgtvtF4C.js} +4 -4
  288. package/dist/useLocalizedDisplay-DNNwDRxL.js +31 -0
  289. package/dist/{useLogicTag-ZPC39rfH.js → useLogicTag-BXXXQQmi.js} +4 -4
  290. package/dist/{useMergeTag-BQ4qqWpQ.js → useMergeTag-C9Okr87y.js} +5 -5
  291. package/dist/usePopoverPosition-VDQjyX_A.js +76 -0
  292. package/dist/{useScrollToBlock-BSyAV4pk.js → useScrollToBlock-C0Kapxdh.js} +5 -5
  293. package/dist/{vue.runtime.esm-bundler-CnEeTfhs.js → vue.runtime.esm-bundler-BJXc_Mri.js} +1373 -1368
  294. package/dist/withCurrentFont-DJiQqZzL.js +18 -0
  295. package/dist/{x-BpfG7v9g.js → x-B7NZYzhx.js} +1 -1
  296. package/package.json +20 -20
  297. package/dist/AiAltTextPopover-DawbUywc.js +0 -105
  298. package/dist/AiChatPanel-CupPhmsN.js +0 -548
  299. package/dist/BlockIssueBadge-BxpDy3u-.js +0 -33
  300. package/dist/BlockPreviewCanvas-B-4bmJ3t.js +0 -140
  301. package/dist/CollaborationNotices-CTw4JThq.js +0 -75
  302. package/dist/CommentsPanel-DwwFuh1h.js +0 -16
  303. package/dist/CommentsSidebar-9ZfiC2DO.js +0 -500
  304. package/dist/CountdownToolbar-BqoYzf_6.js +0 -197
  305. package/dist/IssuesPanel-4ykrf1ax.js +0 -359
  306. package/dist/MergeTagTextarea-CPFEjJZd.js +0 -69
  307. package/dist/ParagraphEditor-CWXfurGh.js +0 -796
  308. package/dist/TemplateSettings-CS0f1Ues.js +0 -236
  309. package/dist/TestEmailModal-DBD0X5nV.js +0 -209
  310. package/dist/TitleEditor-DSqtle77.js +0 -198
  311. package/dist/ToggleSwitch-JykPyD_8.js +0 -36
  312. package/dist/Toolbar-BZPFfKrf.js +0 -3145
  313. package/dist/VersionPreviewBanner-DECaBwLq.js +0 -37
  314. package/dist/WrapperBlock-BsJv_Fiw.js +0 -44
  315. package/dist/cdn/chunks/AiAltTextPopover-SEEjkd-I.js +0 -106
  316. package/dist/cdn/chunks/AiAltTextPopover-SEEjkd-I.js.map +0 -1
  317. package/dist/cdn/chunks/AiAltTextReview-BGLLSKLm.js.map +0 -1
  318. package/dist/cdn/chunks/AiChatPanel-DKDAaBNi.js +0 -474
  319. package/dist/cdn/chunks/AiChatPanel-DKDAaBNi.js.map +0 -1
  320. package/dist/cdn/chunks/AiRewriteMenu-qf-cfEpy.js.map +0 -1
  321. package/dist/cdn/chunks/BlockIssueBadge-jdf91-nk.js +0 -34
  322. package/dist/cdn/chunks/BlockIssueBadge-jdf91-nk.js.map +0 -1
  323. package/dist/cdn/chunks/BlockPreviewCanvas-DGBh6mqe.js +0 -142
  324. package/dist/cdn/chunks/CollaborationNotices-Bsf1rGW9.js +0 -77
  325. package/dist/cdn/chunks/CollaborationNotices-Bsf1rGW9.js.map +0 -1
  326. package/dist/cdn/chunks/CommentsPanel-DoJnKLXI.js +0 -18
  327. package/dist/cdn/chunks/CommentsSidebar-CUtgvdBC.js +0 -470
  328. package/dist/cdn/chunks/CommentsSidebar-CUtgvdBC.js.map +0 -1
  329. package/dist/cdn/chunks/CountdownToolbar-xobieKoU.js +0 -199
  330. package/dist/cdn/chunks/CountdownToolbar-xobieKoU.js.map +0 -1
  331. package/dist/cdn/chunks/IssuesPanel-C7LfxaAY.js.map +0 -1
  332. package/dist/cdn/chunks/LogicTagInsertButton-BIi05UQu.js +0 -1051
  333. package/dist/cdn/chunks/LogicTagInsertButton-BIi05UQu.js.map +0 -1
  334. package/dist/cdn/chunks/MediaEditModal-Cpcod6_U.js.map +0 -1
  335. package/dist/cdn/chunks/MergeTagModeToggle-BgKEVUtV.js.map +0 -1
  336. package/dist/cdn/chunks/MergeTagTextarea-tBz8McZf.js +0 -71
  337. package/dist/cdn/chunks/MergeTagTextarea-tBz8McZf.js.map +0 -1
  338. package/dist/cdn/chunks/ParagraphEditor-B3Rj_cWF.js +0 -631
  339. package/dist/cdn/chunks/ParagraphEditor-B3Rj_cWF.js.map +0 -1
  340. package/dist/cdn/chunks/TemplateSettings-CKtI-dof.js +0 -208
  341. package/dist/cdn/chunks/TemplateSettings-CKtI-dof.js.map +0 -1
  342. package/dist/cdn/chunks/TestEmailModal-CDQTgESD.js +0 -209
  343. package/dist/cdn/chunks/TestEmailModal-CDQTgESD.js.map +0 -1
  344. package/dist/cdn/chunks/TitleEditor-Cob7RLyK.js +0 -198
  345. package/dist/cdn/chunks/TitleEditor-Cob7RLyK.js.map +0 -1
  346. package/dist/cdn/chunks/ToggleSwitch-J7Vwhvha.js +0 -38
  347. package/dist/cdn/chunks/ToggleSwitch-J7Vwhvha.js.map +0 -1
  348. package/dist/cdn/chunks/Toolbar-CdpsvNOR.js +0 -3061
  349. package/dist/cdn/chunks/Toolbar-CdpsvNOR.js.map +0 -1
  350. package/dist/cdn/chunks/VersionPreviewBanner-Dvg0ZfAW.js +0 -39
  351. package/dist/cdn/chunks/VersionPreviewBanner-Dvg0ZfAW.js.map +0 -1
  352. package/dist/cdn/chunks/WrapperBlock-C7Md56IT.js +0 -46
  353. package/dist/cdn/chunks/WrapperBlock-C7Md56IT.js.map +0 -1
  354. package/dist/cdn/chunks/ca-CD-Kt1qz.js.map +0 -1
  355. package/dist/cdn/chunks/createCloudRuntime-Cth2JCEh.js.map +0 -1
  356. package/dist/cdn/chunks/de-CeFJ6wbM.js.map +0 -1
  357. package/dist/cdn/chunks/draggable-Du8AUMFT.js.map +0 -1
  358. package/dist/cdn/chunks/en-D14i5nFh.js.map +0 -1
  359. package/dist/cdn/chunks/en-TIqv4ag3.js +0 -1
  360. package/dist/cdn/chunks/es-zDacbMhs.js.map +0 -1
  361. package/dist/cdn/chunks/fr-CSgYtjOd.js.map +0 -1
  362. package/dist/cdn/chunks/icons-okSPsLOa.js.map +0 -1
  363. package/dist/cdn/chunks/ja-B7H3ID8O.js.map +0 -1
  364. package/dist/cdn/chunks/keys-CUj6UA38.js +0 -11
  365. package/dist/cdn/chunks/keys-CUj6UA38.js.map +0 -1
  366. package/dist/cdn/chunks/nl-176ySmc5.js.map +0 -1
  367. package/dist/cdn/chunks/normalizeMergeTagMarkup-C_KlfSW4.js +0 -198
  368. package/dist/cdn/chunks/normalizeMergeTagMarkup-C_KlfSW4.js.map +0 -1
  369. package/dist/cdn/chunks/pt-BR-dDlTwX18.js.map +0 -1
  370. package/dist/cdn/chunks/sanitizeHtml-CN85EDrO.js +0 -72
  371. package/dist/cdn/chunks/sanitizeHtml-CN85EDrO.js.map +0 -1
  372. package/dist/cdn/chunks/socialIcons-jsTDmkbb.js +0 -2008
  373. package/dist/cdn/chunks/socialIcons-jsTDmkbb.js.map +0 -1
  374. package/dist/cdn/chunks/src-C7bkofBL.js.map +0 -1
  375. package/dist/cdn/chunks/src-DEd87i_U.js.map +0 -1
  376. package/dist/cdn/chunks/src-DwWrYnUj.js +0 -1404
  377. package/dist/cdn/chunks/src-DwWrYnUj.js.map +0 -1
  378. package/dist/cdn/chunks/styleConstants-B8xVRiwX.js.map +0 -1
  379. package/dist/cdn/chunks/useEditorCore-BrY66C2y.js +0 -2582
  380. package/dist/cdn/chunks/useEditorCore-BrY66C2y.js.map +0 -1
  381. package/dist/cdn/chunks/useEditorRoot-vjZJwKrV.js +0 -9
  382. package/dist/cdn/chunks/usePopoverPosition-DSMtmu2W.js +0 -70
  383. package/dist/cdn/chunks/usePopoverPosition-DSMtmu2W.js.map +0 -1
  384. package/dist/cdn/chunks/useScrollToBlock-vjQ0fe-L.js.map +0 -1
  385. package/dist/dist-CKi_npZM.js +0 -1344
  386. package/dist/dist-DyFArF_G.js +0 -4
  387. package/dist/dist-pA3ooG6N.js +0 -4
  388. package/dist/en-Db76vJbY.js +0 -1
  389. package/dist/keys-BgRERHzu.js +0 -9
  390. package/dist/normalizeMergeTagMarkup-CELnOlgK.js +0 -196
  391. package/dist/sanitizeHtml-BzfzpYJY.js +0 -942
  392. package/dist/socialIcons-D7MGsg0d.js +0 -2075
  393. package/dist/useEditorCore-BSo2sSID.js +0 -4059
  394. package/dist/useEditorRoot-BMcoCLBx.js +0 -7
  395. package/dist/usePopoverPosition-DV1PxL66.js +0 -68
  396. package/dist/withCurrentFont-B22FXAF5.js +0 -18
@@ -1,2008 +0,0 @@
1
- import { $ as e, C as t, D as n, J as r, K as i, P as a, Q as o, V as s, Z as c, _ as l, at as u, b as d, ct as f, dt as p, et as m, ft as h, j as g, nt as _, p as v, st as y, u as b, ut as x, x as S } from "./draggable-Du8AUMFT.js";
2
- import { A as C, Ct as w, Dt as T, Et as E, Ft as D, Kt as O, N as k, O as A, Ot as j, P as M, St as N, Tt as P, Z as ee, et as F, ft as I, k as L, kt as R, n as z, r as B, wt as V, xt as H, yt as U } from "./src-DwWrYnUj.js";
3
- import { r as W } from "./dist-BMzNabtD.js";
4
- import { L as G, P as te, c as ne, x as K } from "./keys-CUj6UA38.js";
5
- import { t as re } from "./useI18n-D8pY4LTq.js";
6
- import { o as ie, s as q } from "./usePopoverPosition-DSMtmu2W.js";
7
- import { at as ae, s as oe } from "./icons-okSPsLOa.js";
8
- // ../core/src/error-reporting.ts
9
- function se(e) {
10
- return e instanceof Error ? e : Error(String(e), { cause: e });
11
- }
12
- function J(e, t) {
13
- try {
14
- t();
15
- } catch (t) {
16
- e?.(se(t));
17
- }
18
- }
19
- // ../core/src/editor.ts
20
- function ce(t) {
21
- let n = t.content ?? F(t.defaultFontFamily, t.templateDefaults);
22
- L(n), C(n);
23
- let r = o({
24
- template: null,
25
- content: n,
26
- selectedBlockId: null,
27
- viewport: "desktop",
28
- darkMode: !1,
29
- previewMode: !1,
30
- isDirty: !1,
31
- isSaving: !1,
32
- isLoading: !1,
33
- uiTheme: "auto"
34
- }), a = m(0), s = 0, c = 0;
35
- function l() {
36
- r.isDirty = !0, c++;
37
- }
38
- let u = i({
39
- get: () => r.content,
40
- set: (e) => {
41
- r.content = e, l();
42
- }
43
- }), d = i(() => r.selectedBlockId ? f(r.content.blocks, r.selectedBlockId) : null);
44
- function f(e, t) {
45
- for (let n of e) {
46
- if (n.id === t) return n;
47
- if (n.type === "section") for (let e of n.children) {
48
- let n = f(e, t);
49
- if (n) return n;
50
- }
51
- }
52
- return null;
53
- }
54
- function p(e, t) {
55
- if (t.add(e.id), e.type === "section") for (let n of e.children) for (let e of n) p(e, t);
56
- }
57
- function h(e, t, n = { blocks: e }) {
58
- for (let r = 0; r < e.length; r++) {
59
- let i = e[r];
60
- if (i.id === t) return n;
61
- if (i.type === "section") for (let e = 0; e < i.children.length; e++) {
62
- let n = h(i.children[e], t, {
63
- blocks: i.children[e],
64
- sectionId: i.id,
65
- columnIndex: e
66
- });
67
- if (n) return n;
68
- }
69
- }
70
- return null;
71
- }
72
- function g(e) {
73
- return t.lockedBlocks?.value.has(e) ?? !1;
74
- }
75
- function _(e) {
76
- let t = h(r.content.blocks, e);
77
- if (!t) return null;
78
- let n = t.blocks.findIndex((t) => t.id === e);
79
- return n === -1 ? null : {
80
- targetSectionId: t.sectionId,
81
- columnIndex: t.columnIndex,
82
- index: n
83
- };
84
- }
85
- function v(e, t = !0) {
86
- L(e), C(e), r.content = e, t && l();
87
- }
88
- function y(e) {
89
- e && g(e) || (r.selectedBlockId = e);
90
- }
91
- function b(e) {
92
- r.viewport = e;
93
- }
94
- function x(e) {
95
- r.darkMode = e;
96
- }
97
- function S(e) {
98
- r.uiTheme = e;
99
- }
100
- function w(e) {
101
- r.previewMode = e, e && (r.selectedBlockId = null);
102
- }
103
- function T(e, t) {
104
- if (g(e)) return;
105
- let n = f(r.content.blocks, e);
106
- n && (Object.assign(n, t), l());
107
- }
108
- function D(e) {
109
- r.content.settings = {
110
- ...r.content.settings,
111
- ...e
112
- }, l();
113
- }
114
- function O(e, t, n = 0, i) {
115
- let a = {
116
- settings: r.content.settings,
117
- blocks: [e]
118
- };
119
- if (L(a), C(a), !(t && e.type === "section")) {
120
- if (t) {
121
- if (g(t)) return;
122
- let a = f(r.content.blocks, t);
123
- if (a && a.type === "section") {
124
- if (n < 0 || n >= E(a.columns)) return;
125
- a.children[n] = a.children[n] || [];
126
- let t = a.children[n];
127
- i !== void 0 && i < t.length ? t.splice(i, 0, e) : t.push(e);
128
- }
129
- } else i !== void 0 && i < r.content.blocks.length ? r.content.blocks.splice(i, 0, e) : r.content.blocks.push(e);
130
- l();
131
- }
132
- }
133
- function k(e) {
134
- if (g(e)) return;
135
- let t = h(r.content.blocks, e);
136
- if (t) {
137
- let n = t.blocks.findIndex((t) => t.id === e);
138
- if (n !== -1) {
139
- let [e] = t.blocks.splice(n, 1);
140
- if (r.selectedBlockId) {
141
- let t = /* @__PURE__ */ new Set();
142
- p(e, t), t.has(r.selectedBlockId) && (r.selectedBlockId = null);
143
- }
144
- l();
145
- }
146
- }
147
- }
148
- function A(e, t, n, i = 0) {
149
- if (g(e) || n && g(n)) return;
150
- let a = h(r.content.blocks, e);
151
- if (!a) return;
152
- let o = a.blocks.findIndex((t) => t.id === e);
153
- if (o === -1 || n && a.blocks[o].type === "section") return;
154
- let s;
155
- if (n) {
156
- let e = f(r.content.blocks, n);
157
- if (!e || e.type !== "section" || i < 0 || i >= E(e.columns)) return;
158
- e.children[i] = e.children[i] || [], s = e.children[i];
159
- } else s = r.content.blocks;
160
- let [c] = a.blocks.splice(o, 1);
161
- s.splice(t, 0, c), l();
162
- }
163
- function j() {
164
- l();
165
- }
166
- function M(e, t) {
167
- throw new H(`[Templatical] Templates: ${e} ${t}`);
168
- }
169
- function N(e) {
170
- J(t.onError, e);
171
- }
172
- function P(e) {
173
- let { templates: n } = t;
174
- return n || M(e, "needs a templates provider. Pass one as `init({ templates })` to enable saving and loading."), n;
175
- }
176
- function ee(e) {
177
- r.template && (r.template = {
178
- ...r.template,
179
- name: e
180
- }, l());
181
- }
182
- async function I(e) {
183
- let n = P("create()"), { create: i } = n;
184
- typeof i != "function" && M("create()", "is disabled by the provider — its `create` is `false`.");
185
- let o, l = ++s;
186
- r.isLoading = !0;
187
- try {
188
- e?.content && (r.content = e.content);
189
- let t = c;
190
- o = await i(e?.name === void 0 ? { content: r.content } : {
191
- name: e.name,
192
- content: r.content
193
- }), r.template = o, c === t && (r.isDirty = !1), a.value++;
194
- } catch (e) {
195
- throw t.onError?.(e), e;
196
- } finally {
197
- s === l && (r.isLoading = !1);
198
- }
199
- return N(() => n.onCreated?.(o)), o;
200
- }
201
- async function R(e, n) {
202
- let i = P("load()"), o, c = ++s;
203
- r.isLoading = !0;
204
- try {
205
- if (o = await i.load(e), L(o.content), C(o.content), n && !n()) return o;
206
- r.template = o, r.content = o.content, r.isDirty = !1, a.value++;
207
- } catch (e) {
208
- throw t.onError?.(e), e;
209
- } finally {
210
- s === c && (r.isLoading = !1);
211
- }
212
- return N(() => i.onLoaded?.(o)), o;
213
- }
214
- async function z(e = "api") {
215
- let n = P("save()"), { save: i } = n;
216
- typeof i != "function" && M("save()", "is disabled by the provider — its `save` is `false`.");
217
- let a = r.template;
218
- a || M("save()", "has no template loaded. Call create() or load() first.");
219
- let o = a.name === void 0 ? { content: r.content } : {
220
- name: a.name,
221
- content: r.content
222
- }, s;
223
- r.isSaving = !0;
224
- try {
225
- let e = c;
226
- if (s = await i(a.id, o), r.template?.id === a.id) {
227
- let e = r.template.name;
228
- r.template = e === a.name ? s : {
229
- ...s,
230
- name: e
231
- };
232
- }
233
- c === e && (r.isDirty = !1);
234
- } catch (e) {
235
- throw t.onError?.(e), e;
236
- } finally {
237
- r.isSaving = !1;
238
- }
239
- return N(() => n.onSaved?.(s, { trigger: e })), s;
240
- }
241
- function B() {
242
- return r.template?.id !== void 0;
243
- }
244
- return {
245
- state: e(r),
246
- loadVersion: e(a),
247
- content: u,
248
- selectedBlock: d,
249
- isBlockLocked: g,
250
- setContent: v,
251
- selectBlock: y,
252
- setViewport: b,
253
- setDarkMode: x,
254
- setUiTheme: S,
255
- setPreviewMode: w,
256
- updateBlock: T,
257
- updateSettings: D,
258
- addBlock: O,
259
- removeBlock: k,
260
- moveBlock: A,
261
- markDirty: j,
262
- findBlockLocation: _,
263
- setName: ee,
264
- create: I,
265
- load: R,
266
- save: z,
267
- hasTemplate: B
268
- };
269
- }
270
- // ../core/src/history.ts
271
- var le = 50, ue = 300, de = 1500;
272
- function Y(e) {
273
- let { content: t, setContent: n, maxSize: r = le } = e, a = m([]), o = m([]), s = m(!1), c = null, l = null, u = i(() => a.value.length > 0), d = i(() => o.value.length > 0);
274
- function f() {
275
- return j(t.value);
276
- }
277
- function p(e) {
278
- a.value.push(e), a.value.length > r && a.value.splice(0, a.value.length - r);
279
- }
280
- function h() {
281
- l &&= (clearTimeout(l.timeoutId), null);
282
- }
283
- function g() {
284
- h(), p(f()), o.value = [];
285
- }
286
- function _(e) {
287
- l && l.blockId === e ? (clearTimeout(l.timeoutId), l.timeoutId = setTimeout(() => {
288
- l = null;
289
- }, ue)) : (h(), p(f()), o.value = [], l = {
290
- blockId: e,
291
- timeoutId: setTimeout(() => {
292
- l = null;
293
- }, ue)
294
- });
295
- }
296
- function v() {
297
- s.value = !0, c && clearTimeout(c), c = setTimeout(() => {
298
- s.value = !1, c = null;
299
- }, de);
300
- }
301
- function y() {
302
- if (a.value.length === 0) return;
303
- h();
304
- let e = a.value.pop();
305
- o.value.push(f()), n(e, !0), v();
306
- }
307
- function b() {
308
- if (o.value.length === 0) return;
309
- h();
310
- let e = o.value.pop();
311
- a.value.push(f()), n(e, !0), v();
312
- }
313
- function x() {
314
- a.value = [], o.value = [], h();
315
- }
316
- function S() {
317
- x(), c &&= (clearTimeout(c), null);
318
- }
319
- return {
320
- canUndo: u,
321
- canRedo: d,
322
- isNavigating: s,
323
- undo: y,
324
- redo: b,
325
- record: g,
326
- recordDebounced: _,
327
- clear: x,
328
- destroy: S
329
- };
330
- }
331
- // ../core/src/block-actions.ts
332
- function fe(e) {
333
- let { addBlock: t, removeBlock: n, updateBlock: r, selectBlock: i, findBlockLocation: a } = e;
334
- function o(n, r, a) {
335
- let o = typeof e.blockDefaults == "function" ? e.blockDefaults() : e.blockDefaults, s = M(n, o);
336
- return t(s, r, a), i(s.id), s;
337
- }
338
- function s(e, n, r) {
339
- let o = k(e);
340
- if (n !== void 0 || r !== void 0) t(o, n, r);
341
- else {
342
- let i = a?.(e.id) ?? null;
343
- i ? t(o, i.targetSectionId, i.columnIndex, i.index + 1) : t(o, n, r);
344
- }
345
- return i(o.id), o;
346
- }
347
- function c(e) {
348
- n(e);
349
- }
350
- function l(e, t, n) {
351
- r(e, { [t]: n });
352
- }
353
- return {
354
- createAndAddBlock: o,
355
- duplicateBlock: s,
356
- deleteBlock: c,
357
- updateBlockProperty: l
358
- };
359
- }
360
- // ../core/src/auto-save.ts
361
- var pe = 2e3;
362
- function X(e) {
363
- let { content: t, isDirty: n, onChange: r, debounce: i = pe, enabled: a = !0 } = e, o = null, s = !1;
364
- function c() {
365
- return typeof a == "function" ? a() : a;
366
- }
367
- function l() {
368
- s = !0, d();
369
- }
370
- function u() {
371
- s = !1;
372
- }
373
- function d() {
374
- o &&= (clearTimeout(o), null);
375
- }
376
- function p() {
377
- d(), n() && r(JSON.parse(JSON.stringify(t.value)));
378
- }
379
- function m() {
380
- c() && !s && (d(), o = setTimeout(() => {
381
- o = null, c() && !s && n() && r(JSON.parse(JSON.stringify(t.value)));
382
- }, i));
383
- }
384
- let h = f(t, () => {
385
- m();
386
- }, { deep: !0 });
387
- function g() {
388
- h(), d();
389
- }
390
- return {
391
- flush: p,
392
- cancel: d,
393
- pause: l,
394
- resume: u,
395
- destroy: g
396
- };
397
- }
398
- // ../core/src/condition-preview.ts
399
- function me(e) {
400
- let t = o(/* @__PURE__ */ new Set()), n = i(() => t.size > 0);
401
- function r(e) {
402
- return t.has(e);
403
- }
404
- function a(n) {
405
- t.has(n) ? t.delete(n) : (t.add(n), e.state.selectedBlockId === n && e.selectBlock(null));
406
- }
407
- function s() {
408
- t.clear();
409
- }
410
- return {
411
- isHidden: r,
412
- toggleBlock: a,
413
- reset: s,
414
- hasHiddenBlocks: n
415
- };
416
- }
417
- // ../core/src/data-source-fetch.ts
418
- function he(e) {
419
- let t = m(!1), n = m(!1), r = i(() => !!e.definition.value?.dataSource), a = i(() => r.value && !e.block.value.dataSourceFetched);
420
- async function o() {
421
- let r = e.definition.value;
422
- if (r?.dataSource) {
423
- t.value = !0, n.value = !1;
424
- try {
425
- let t = await r.dataSource.onFetch({
426
- fieldValues: { ...e.block.value.fieldValues },
427
- blockId: e.block.value.id
428
- });
429
- if (t == null) return;
430
- let n = { ...e.block.value.fieldValues };
431
- for (let e of Object.keys(n)) e in t && (n[e] = t[e]);
432
- e.onUpdate(n, !0);
433
- } catch (e) {
434
- console.warn("[Templatical] Data source fetch error:", e), n.value = !0;
435
- } finally {
436
- t.value = !1;
437
- }
438
- }
439
- }
440
- return {
441
- isFetching: t,
442
- fetchError: n,
443
- fetch: o,
444
- hasDataSource: r,
445
- needsFetch: a
446
- };
447
- }
448
- // ../core/src/history-interceptor.ts
449
- function ge(e, t) {
450
- let n = e.addBlock, r = e.removeBlock, i = e.moveBlock, a = e.updateBlock, o = e.updateSettings;
451
- e.addBlock = (r, i, a, o) => {
452
- i && e.isBlockLocked(i) || (t.record(), n(r, i, a, o));
453
- }, e.removeBlock = (n) => {
454
- e.isBlockLocked(n) || (t.record(), r(n));
455
- }, e.moveBlock = (n, r, a, o) => {
456
- e.isBlockLocked(n) || a && e.isBlockLocked(a) || (t.record(), i(n, r, a, o));
457
- }, e.updateBlock = (n, r) => {
458
- e.isBlockLocked(n) || (t.recordDebounced(n), a(n, r));
459
- }, e.updateSettings = (e) => {
460
- t.record(), o(e);
461
- };
462
- }
463
- // ../core/src/diff-content.ts
464
- var _e = "root", ve = /* @__PURE__ */ new Set([
465
- "id",
466
- "type",
467
- "children"
468
- ]), ye = /* @__PURE__ */ new Set([
469
- "id",
470
- "type",
471
- "children",
472
- "columns"
473
- ]), be = /* @__PURE__ */ new Set();
474
- function xe(e) {
475
- return e === null ? _e : JSON.stringify([e.sectionId, e.column]);
476
- }
477
- function Z(e) {
478
- let t = e.children;
479
- return e.type === "section" && Array.isArray(t) ? t : [];
480
- }
481
- function Se(e) {
482
- let t = /* @__PURE__ */ new Map(), n = (e, r) => {
483
- e.forEach((e, i) => {
484
- t.has(e.id) || t.set(e.id, {
485
- block: e,
486
- key: xe(r),
487
- index: i
488
- }), Z(e).forEach((t, r) => {
489
- Array.isArray(t) && n(t, {
490
- sectionId: e.id,
491
- column: r
492
- });
493
- });
494
- });
495
- };
496
- return n(e, null), t;
497
- }
498
- function Ce(e) {
499
- let t = [], n = Array(e.length).fill(-1);
500
- e.forEach((r, i) => {
501
- let a = 0, o = t.length;
502
- for (; a < o;) {
503
- let n = a + o >> 1;
504
- e[t[n]] < r ? a = n + 1 : o = n;
505
- }
506
- a > 0 && (n[i] = t[a - 1]), t[a] = i;
507
- });
508
- let r = /* @__PURE__ */ new Set(), i = t.length > 0 ? t[t.length - 1] : -1;
509
- for (; i !== -1;) r.add(i), i = n[i];
510
- return r;
511
- }
512
- function we(e, t, n) {
513
- let r = {}, i = [];
514
- for (let i of Object.keys(t)) n.has(i) || t[i] === void 0 || T(e[i], t[i]) || (r[i] = j(t[i]));
515
- for (let r of Object.keys(e)) n.has(r) || e[r] === void 0 || t[r] === void 0 && i.push(r);
516
- return {
517
- set: r,
518
- unset: i
519
- };
520
- }
521
- function Te(e, t) {
522
- let n = Se(e.blocks), r = Se(t.blocks), i = [], a = (e) => {
523
- let t = r.get(e), i = n.get(e);
524
- return t !== void 0 && i !== void 0 && t.block.type !== i.block.type;
525
- }, o = (e) => r.has(e.id) && !a(e.id), s = (e) => Z(e).some((e) => Array.isArray(e) && e.some((e) => o(e) || !a(e.id) && s(e))), c = /* @__PURE__ */ new Set(), l = [], u = (e, t) => {
526
- let n = "kept";
527
- t === "dropped" ? (c.add(e.id), n = "dropped") : a(e.id) ? (i.push({
528
- op: "deleteBlock",
529
- blockId: e.id
530
- }), c.add(e.id), n = "dropped") : r.has(e.id) || (t === "deferred" ? n = "deferred" : s(e) ? (l.push(e.id), n = "deferred") : (i.push({
531
- op: "deleteBlock",
532
- blockId: e.id
533
- }), c.add(e.id), n = "dropped"));
534
- for (let t of Z(e)) if (Array.isArray(t)) for (let e of t) u(e, n);
535
- };
536
- for (let t of e.blocks) u(t, "kept");
537
- let d = (e) => n.has(e) && !c.has(e), f = (e) => {
538
- let t = j(e);
539
- return t.type === "section" && (t.children = Z(e).map((e) => Array.isArray(e) ? e.filter((e) => !d(e.id)).map((e) => j(e)) : e)), t;
540
- }, p = (e, t, r) => {
541
- let a = xe(e), o = [], s = [];
542
- t.forEach((e, t) => {
543
- let r = n.get(e.id);
544
- d(e.id) && r !== void 0 && r.key === a && (o.push(r.index), s.push(t));
545
- });
546
- let c = new Set([...Ce(o)].map((e) => s[e]));
547
- t.forEach((n, a) => {
548
- if (c.has(a) || r(n)) return;
549
- let o = a > 0 ? t[a - 1].id : null;
550
- i.push(d(n.id) ? {
551
- op: "moveBlock",
552
- blockId: n.id,
553
- parent: e,
554
- after: o
555
- } : {
556
- op: "addBlock",
557
- block: f(n),
558
- parent: e,
559
- after: o
560
- });
561
- });
562
- };
563
- p(null, t.blocks, () => !1);
564
- let m = t.blocks.filter((e) => e.type === "section"), h = /* @__PURE__ */ new Set(), g = (e) => {
565
- for (let t of m) {
566
- if (!d(t.id)) continue;
567
- let r = Z(n.get(t.id).block).length, a = Z(t).length;
568
- (e ? a > r : a < r) && (i.push({
569
- op: "updateBlock",
570
- blockId: t.id,
571
- set: { columns: t.columns }
572
- }), h.add(t.id));
573
- }
574
- };
575
- g(!0);
576
- for (let e of m) {
577
- let t = !d(e.id);
578
- Z(e).forEach((n, r) => {
579
- Array.isArray(n) && p({
580
- sectionId: e.id,
581
- column: r
582
- }, n, (e) => t && !d(e.id));
583
- });
584
- }
585
- g(!1);
586
- for (let e of l) i.push({
587
- op: "deleteBlock",
588
- blockId: e
589
- });
590
- for (let [e, t] of r) {
591
- if (!d(e)) continue;
592
- let { set: r, unset: a } = we(n.get(e).block, t.block, h.has(e) ? ye : ve);
593
- (Object.keys(r).length !== 0 || a.length !== 0) && i.push({
594
- op: "updateBlock",
595
- blockId: e,
596
- ...Object.keys(r).length > 0 ? { set: r } : {},
597
- ...a.length > 0 ? { unset: a } : {}
598
- });
599
- }
600
- let _ = we(e.settings, t.settings, be);
601
- return (Object.keys(_.set).length > 0 || _.unset.length > 0) && i.push({
602
- op: "updateSettings",
603
- ...Object.keys(_.set).length > 0 ? { set: _.set } : {},
604
- ..._.unset.length > 0 ? { unset: _.unset } : {}
605
- }), i;
606
- }
607
- var Ee = 1e3, De = 1e4, Oe = [
608
- 1e3,
609
- 2e3,
610
- 5e3,
611
- 1e4,
612
- 3e4
613
- ], ke = 50, Ae = 100, Q = /* @__PURE__ */ new Set([
614
- "block_exists",
615
- "block_missing",
616
- "anchor_missing",
617
- "precondition_failed",
618
- "lock_held",
619
- "locked_by_others",
620
- "invalid_operation",
621
- "lock_lost",
622
- "content_too_large"
623
- ]);
624
- function je(e) {
625
- let t = e?.code;
626
- return typeof t == "string" && Q.has(t) ? t : null;
627
- }
628
- function Me(e) {
629
- let t = e?.holder;
630
- return typeof t == "object" && t && typeof t.sessionId == "string" ? t : void 0;
631
- }
632
- function Ne(e) {
633
- let t = e?.statusCode;
634
- return typeof t != "number" || t >= 500 || t === 408 || t === 429;
635
- }
636
- function Pe(e, t) {
637
- return e.some((e) => {
638
- if (e.id === t) return !0;
639
- let n = e.children;
640
- return e.type === "section" && Array.isArray(n) && n.some((e) => Array.isArray(e) && Pe(e, t));
641
- });
642
- }
643
- function Fe(e) {
644
- if (e.length === 1 && e[0].op === "updateSettings") return !0;
645
- let t = e[0];
646
- return t.op === "updateBlock" && e.every((e) => e.op === "updateBlock" && e.blockId === t.blockId);
647
- }
648
- function Ie(e) {
649
- return e.map((e) => {
650
- if (!("expect" in e)) return e;
651
- let { expect: t, ...n } = e;
652
- return n;
653
- });
654
- }
655
- function Le(e) {
656
- let { provider: t } = e, n = e.sessionId ?? crypto.randomUUID(), a = e.maxUndo ?? ke, o = typeof t.acquireLock == "function" && typeof t.renewLock == "function" && typeof t.releaseLock == "function", s = _([]), l = _(/* @__PURE__ */ new Map()), u = m(null), d = m(0), p = m(0), h = null, g = null, v = !1, y = !1, b = !1, x = null, S = 0, C = !1, E = [], D = null, O = null, k = Promise.resolve(), A = null, M = i(() => (g?.undo.length ?? 0) > 0), ee = i(() => (g?.redo.length ?? 0) > 0);
657
- function F(t) {
658
- e.onError?.(t instanceof Error ? t : Error(String(t)));
659
- }
660
- function I(t, n = g) {
661
- n !== g || C || e.onNotice?.(t);
662
- }
663
- function L() {
664
- return {
665
- locks: [...l.value.values()].map((e) => ({
666
- blockId: e.blockId,
667
- sessionId: e.holder.sessionId
668
- })),
669
- session: n
670
- };
671
- }
672
- function R() {
673
- p.value++;
674
- }
675
- function z(e, t) {
676
- e.push(t), e.length > a && e.splice(0, e.length - a);
677
- }
678
- function B(e) {
679
- if (!h || v) return;
680
- y = !0;
681
- try {
682
- let t = h.content.value, n = Te(t, e);
683
- if (n.length > 0) try {
684
- P(t, n);
685
- } catch {
686
- h.setContent(j(e), !1);
687
- }
688
- T(h.content.value, e) || h.setContent(j(e), !1);
689
- } finally {
690
- y = !1;
691
- }
692
- let t = h.state.selectedBlockId;
693
- t && !Pe(e.blocks, t) && h.selectBlock(null);
694
- }
695
- function H() {
696
- y || b || (b = !0, queueMicrotask(() => {
697
- b = !1, W(!1);
698
- }));
699
- }
700
- function U() {
701
- x &&= (clearTimeout(x), null);
702
- }
703
- function W(e, t = !1) {
704
- let n = g;
705
- if (!h || !n || v || y || h.state.isLoading && !t || h.state.template?.id !== n.templateId) return;
706
- let r = Te(n.view, h.content.value);
707
- if (r.length === 0) U();
708
- else {
709
- if (!e && Fe(r)) {
710
- let e = Date.now();
711
- if (x === null && (S = e), e - S < 1e3) {
712
- x && clearTimeout(x), x = setTimeout(() => {
713
- x = null, W(!0);
714
- }, 300);
715
- return;
716
- }
717
- }
718
- U(), te(n, r);
719
- }
720
- }
721
- function G() {
722
- W(!0);
723
- }
724
- function te(e, t) {
725
- let n = t, r;
726
- try {
727
- r = V(e.view, n, L());
728
- } catch (t) {
729
- if (!(t instanceof w)) throw t;
730
- B(e.view);
731
- let n = t.blockId === void 0 ? void 0 : l.value.get(t.blockId)?.holder;
732
- I({
733
- type: "editRefused",
734
- code: t.code,
735
- ...n ? { holder: n } : {}
736
- }), t.code === "invalid_operation" && F(t);
737
- return;
738
- }
739
- let i = h.content.value;
740
- if (!T(r, i)) {
741
- F(/* @__PURE__ */ Error("[Templatical] Collaboration: a change couldn't be expressed as block operations, so the whole content was sent.")), n = [{
742
- op: "setContent",
743
- content: j(i)
744
- }];
745
- try {
746
- r = V(e.view, n, L());
747
- } catch (t) {
748
- if (!(t instanceof w)) throw t;
749
- B(e.view), I({
750
- type: "editRefused",
751
- code: t.code
752
- });
753
- return;
754
- }
755
- }
756
- let a = { ops: N(e.view, n) };
757
- z(e.undo, a), e.redo = [], R(), e.view = r, ne(e, n, "edit", a);
758
- }
759
- function ne(e, t, n, r) {
760
- let i = { dropped: !1 }, a = 0;
761
- do
762
- e.pending.push({
763
- batchId: crypto.randomUUID(),
764
- ops: t.slice(a, a + Ae),
765
- origin: n,
766
- entry: r,
767
- group: i,
768
- sent: !1,
769
- revision: null
770
- }), a += Ae;
771
- while (a < t.length);
772
- K(e);
773
- }
774
- function K(e) {
775
- if (e.inFlight) return;
776
- let t = e.pending.find((e) => !e.sent);
777
- t ? (t.sent = !0, e.inFlight = t, re(e, t, 0)) : J(e);
778
- }
779
- function re(e, n, r) {
780
- t.submit(e.templateId, {
781
- batchId: n.batchId,
782
- baseRevision: e.revision,
783
- ops: n.ops,
784
- ...n.origin === "ai" ? { origin: "ai" } : {}
785
- }).then(({ revision: t }) => {
786
- e.inFlight = null, ie(e, n, t), K(e);
787
- }, (t) => {
788
- if (je(t) !== null) e.inFlight = null, se(e, n, t), K(e);
789
- else if (Ne(t)) {
790
- ce(e, t);
791
- let i = Oe[Math.min(r, Oe.length - 1)];
792
- setTimeout(() => {
793
- C || re(e, n, r + 1);
794
- }, i);
795
- } else e.inFlight = null, F(t), se(e, n, t), K(e);
796
- });
797
- }
798
- function ie(e, t, n) {
799
- t.revision === null && (t.revision = n, n <= e.revision ? (q(e, t), Y(e)) : (e.own.set(n, t), de(e)));
800
- }
801
- function q(e, t) {
802
- e.pending = e.pending.filter((e) => e !== t), J(e);
803
- }
804
- function ae(e, t) {
805
- if (t.entry) {
806
- for (let n of [e.undo, e.redo]) {
807
- let e = n.indexOf(t.entry);
808
- e !== -1 && n.splice(e, 1);
809
- }
810
- R();
811
- }
812
- }
813
- function oe(e, t) {
814
- let n = !t.group.dropped;
815
- return t.group.dropped = !0, e.pending = e.pending.filter((e) => e.group !== t.group || e.sent), n && ae(e, t), J(e), n;
816
- }
817
- function se(e, t, n) {
818
- if (q(e, t), oe(e, t)) {
819
- let r = je(n) ?? "invalid_operation";
820
- if (t.origin === "edit" || t.origin === "ai") {
821
- let t = Me(n);
822
- I({
823
- type: "editRefused",
824
- code: r,
825
- ...t ? { holder: t } : {}
826
- }, e);
827
- } else I({
828
- type: "undoSkipped",
829
- code: r
830
- }, e);
831
- }
832
- Y(e), e === g && X();
833
- }
834
- function J(e) {
835
- if (!(e.pending.length > 0 || e.waiters.length === 0)) for (let t of e.waiters.splice(0)) t.resolve();
836
- }
837
- function ce(e, t) {
838
- let n = t instanceof Error ? t : Error(String(t));
839
- for (let t of e.waiters.splice(0)) t.reject(n);
840
- }
841
- function le(e, t) {
842
- if (t.revision <= e.revision) return;
843
- let n = e.pending.find((e) => e.batchId === t.batchId);
844
- n ? ie(e, n, t.revision) : (e.remote.set(t.revision, t), de(e));
845
- }
846
- function ue(t, n) {
847
- let r = n.ops;
848
- if (e.normalizeRemoteOperations) try {
849
- r = e.normalizeRemoteOperations(n.ops, t.confirmed);
850
- } catch (e) {
851
- F(e);
852
- }
853
- return Ie(r);
854
- }
855
- function de(t) {
856
- let n = [], r = !1;
857
- for (;;) {
858
- let e = t.revision + 1, i = t.remote.get(e), a = t.own.get(e);
859
- if (!i && !a) break;
860
- try {
861
- t.confirmed = V(t.confirmed, i ? ue(t, i) : a.ops);
862
- } catch {
863
- if (t.recovering) {
864
- t.remote.clear(), t.own.clear(), F(/* @__PURE__ */ Error("[Templatical] Collaboration: this editor can't follow the template's changes. Reload the page."));
865
- return;
866
- }
867
- me(t);
868
- return;
869
- }
870
- t.revision = e, i ? (t.remote.delete(e), n.push(i)) : (t.own.delete(e), a.group.dropped && (r = !0), q(t, a));
871
- }
872
- if (t === g && (d.value = t.revision), t.remote.size > 0 || t.own.size > 0 ? fe(t) : pe(t), (n.length !== 0 || r) && (Y(t), t === g)) for (let t of n) try {
873
- e.onRemoteChange?.({
874
- actor: t.actor,
875
- ops: t.ops
876
- });
877
- } catch (e) {
878
- F(e);
879
- }
880
- }
881
- function Y(e) {
882
- e === g && G();
883
- let t = e.confirmed;
884
- for (let n = 0; n < e.pending.length; n++) {
885
- let r = e.pending[n];
886
- try {
887
- t = V(t, r.ops);
888
- } catch (i) {
889
- if (r.sent) continue;
890
- if (oe(e, r)) {
891
- let t = i instanceof w ? i.code : "invalid_operation";
892
- I(r.origin === "edit" || r.origin === "ai" ? {
893
- type: "editRefused",
894
- code: t
895
- } : {
896
- type: "undoSkipped",
897
- code: t
898
- }, e);
899
- }
900
- t = e.confirmed, n = -1;
901
- }
902
- }
903
- e.view = t, J(e), e === g && B(t);
904
- }
905
- function fe(e) {
906
- e.gapTimer ||= setTimeout(() => {
907
- e.gapTimer = null, e === g && X();
908
- }, Ee);
909
- }
910
- function pe(e) {
911
- e.gapTimer &&= (clearTimeout(e.gapTimer), null);
912
- }
913
- function X() {
914
- let e = g;
915
- return e ? (e.catchingUp ||= (async () => {
916
- try {
917
- let n = await t.operationsAfter(e.templateId, e.revision);
918
- if (e.retired) return;
919
- if ("resync" in n) {
920
- await me(e);
921
- return;
922
- }
923
- for (let t of n.batches) le(e, t);
924
- } catch (e) {
925
- F(e);
926
- } finally {
927
- e.catchingUp = null;
928
- }
929
- })(), e.catchingUp) : Promise.resolve();
930
- }
931
- async function me(t) {
932
- t.recovering = !0;
933
- try {
934
- let n = await e.loadTemplate(t.templateId);
935
- if (t.retired) return;
936
- let r = n.revision ?? t.revision;
937
- t.confirmed = j(n.content), t.revision = r, t.remote = new Map([...t.remote].filter(([e]) => e > r));
938
- for (let [e, n] of [...t.own]) e <= r && (t.own.delete(e), q(t, n));
939
- t === g && (d.value = r), Y(t), de(t);
940
- } catch (e) {
941
- F(e);
942
- } finally {
943
- t.recovering = !1;
944
- }
945
- }
946
- function he(t) {
947
- let n = () => t === g && !t.retired;
948
- return {
949
- onBatch: (e) => {
950
- n() && le(t, e);
951
- },
952
- onResync: (r, i) => {
953
- if (!(!n() || r <= t.revision)) {
954
- if (i) try {
955
- e.onRemoteResync?.({
956
- revision: r,
957
- actor: i
958
- });
959
- } catch (e) {
960
- F(e);
961
- }
962
- X();
963
- }
964
- },
965
- onLock: (e) => {
966
- n() && xe(e);
967
- },
968
- onUnlock: (e, t) => {
969
- n() && Z(e, t);
970
- },
971
- onMembers: (e) => {
972
- n() && Ce(e);
973
- },
974
- onConnectionChange: (e) => {
975
- n() && ye(t, e);
976
- }
977
- };
978
- }
979
- function ge(e, r) {
980
- t.join(e.templateId, { sessionId: n }, he(e)).then((t) => {
981
- e.retired || e !== g ? r || t.leave() : (e.leave = t.leave, Se(t.locks, !r), Ce(t.members), t.members.length > 0 && (u.value = "connected"), t.revision > e.revision && X(), r && Q());
982
- }, (e) => F(e));
983
- }
984
- function _e(e) {
985
- let t = j(e.content), n = {
986
- templateId: e.id,
987
- confirmed: t,
988
- revision: e.revision ?? 0,
989
- pending: [],
990
- view: j(t),
991
- remote: /* @__PURE__ */ new Map(),
992
- own: /* @__PURE__ */ new Map(),
993
- inFlight: null,
994
- gapTimer: null,
995
- catchingUp: null,
996
- leave: null,
997
- retired: !1,
998
- recovering: !1,
999
- undo: [],
1000
- redo: [],
1001
- waiters: []
1002
- };
1003
- g = n, d.value = n.revision, R(), ge(n, !1), h?.state.selectedBlockId && Be(h.state.selectedBlockId), H();
1004
- }
1005
- function ve(e) {
1006
- e.retired = !0, pe(e), e.leave?.(), e.leave = null, ce(e, /* @__PURE__ */ Error("[Templatical] The template was closed."));
1007
- }
1008
- function ye(e, t) {
1009
- let n = u.value;
1010
- u.value = t, t === "connected" && n !== null && n !== "connected" && ge(e, !0);
1011
- }
1012
- function be(e) {
1013
- g && g.templateId === e?.id || (g &&= (U(), ve(g), null), s.value = [], l.value = /* @__PURE__ */ new Map(), u.value = null, D = null, Q(), R(), e && _e(e));
1014
- }
1015
- function xe(e) {
1016
- if (e.holder.sessionId === n) return;
1017
- let t = new Map([...l.value].filter(([, t]) => t.holder.sessionId !== e.holder.sessionId));
1018
- t.set(e.blockId, e), l.value = t, h?.state.selectedBlockId === e.blockId && (h.selectBlock(null), I({
1019
- type: "selectionRefused",
1020
- blockId: e.blockId,
1021
- holder: e.holder
1022
- }));
1023
- }
1024
- function Z(e, t) {
1025
- if (l.value.get(e)?.holder.sessionId !== t) return;
1026
- let n = new Map(l.value);
1027
- n.delete(e), l.value = n;
1028
- }
1029
- function Se(e, t) {
1030
- let r = t ? new Map(l.value) : /* @__PURE__ */ new Map();
1031
- for (let i of e) i.holder.sessionId !== n && (t && r.has(i.blockId) || r.set(i.blockId, i));
1032
- l.value = r;
1033
- }
1034
- function Ce(e) {
1035
- let t = new Set(e.map((e) => e.sessionId)), n = new Set(s.value.map((e) => e.sessionId).filter((e) => !t.has(e)));
1036
- if (s.value = e, n.size === 0) return;
1037
- let r = new Map([...l.value].filter(([, e]) => !n.has(e.holder.sessionId)));
1038
- r.size !== l.value.size && (l.value = r);
1039
- }
1040
- function we(e) {
1041
- k = k.then(e).catch(F);
1042
- }
1043
- function Q() {
1044
- o && we(async () => {
1045
- if (O && (D === null || O.templateId !== D.templateId)) {
1046
- let e = O;
1047
- O = null, $(), await t.releaseLock(e.templateId, e.blockId);
1048
- }
1049
- let e = D;
1050
- if (!(!e || O?.templateId === e.templateId && O.blockId === e.blockId)) try {
1051
- await t.acquireLock(e.templateId, e.blockId), O = e, ze(), Le(e.blockId);
1052
- } catch (n) {
1053
- if (O?.templateId === e.templateId) {
1054
- let e = O;
1055
- O = null, $(), await t.releaseLock(e.templateId, e.blockId).catch(() => {});
1056
- }
1057
- if (D !== e) return;
1058
- Re(e.blockId, n);
1059
- }
1060
- });
1061
- }
1062
- function Le(e) {
1063
- if (!l.value.has(e)) return;
1064
- let t = new Map(l.value);
1065
- t.delete(e), l.value = t;
1066
- }
1067
- function Re(e, t) {
1068
- let n = je(t);
1069
- if (n === "lock_held" || n === "block_missing") {
1070
- D = null;
1071
- let n = Me(t);
1072
- n ? xe({
1073
- blockId: e,
1074
- holder: n,
1075
- expiresAt: ""
1076
- }) : h?.state.selectedBlockId === e && h.selectBlock(null);
1077
- } else F(t), setTimeout(() => {
1078
- D?.blockId === e && Q();
1079
- }, Oe[0]);
1080
- }
1081
- function ze() {
1082
- A ||= setInterval(() => {
1083
- we(async () => {
1084
- let e = O;
1085
- if (e) try {
1086
- await t.renewLock(e.templateId, e.blockId);
1087
- } catch (e) {
1088
- if (je(e) === "lock_lost") {
1089
- O = null, $(), Q();
1090
- return;
1091
- }
1092
- F(e);
1093
- }
1094
- });
1095
- }, De);
1096
- }
1097
- function $() {
1098
- A &&= (clearInterval(A), null);
1099
- }
1100
- function Be(e) {
1101
- G(), g && (D = e ? {
1102
- templateId: g.templateId,
1103
- blockId: e
1104
- } : null, Q());
1105
- }
1106
- function Ve() {
1107
- G(), O && o && (t.releaseLock(O.templateId, O.blockId).catch(() => {}), O = null, $()), g?.leave?.(), g && (g.leave = null);
1108
- }
1109
- function He(e) {
1110
- let t = g;
1111
- if (!t || v) return;
1112
- G();
1113
- let n = (e === "undo" ? t.undo : t.redo).pop();
1114
- if (!n) return;
1115
- R();
1116
- let r;
1117
- try {
1118
- r = V(t.view, n.ops, L());
1119
- } catch (e) {
1120
- if (!(e instanceof w)) throw e;
1121
- I({
1122
- type: "undoSkipped",
1123
- code: e.code
1124
- });
1125
- return;
1126
- }
1127
- let i = { ops: N(t.view, n.ops) };
1128
- z(e === "undo" ? t.redo : t.undo, i), t.view = r, B(r), h?.markDirty(), ne(t, n.ops, e, i);
1129
- }
1130
- function Ue(e, t) {
1131
- let n = g;
1132
- if (!h || !n || v) return {
1133
- applied: !1,
1134
- error: new w("invalid_operation", 0, "No template is open for editing.")
1135
- };
1136
- G();
1137
- let r, i;
1138
- try {
1139
- r = V(n.view, e, L()), i = N(n.view, e);
1140
- } catch (e) {
1141
- if (e instanceof w) return {
1142
- applied: !1,
1143
- error: e
1144
- };
1145
- throw e;
1146
- }
1147
- let a = n.undo.at(-1), o;
1148
- return a && a.turn === t.turn ? (a.ops = [...i, ...a.ops], o = a) : (o = {
1149
- ops: i,
1150
- turn: t.turn
1151
- }, z(n.undo, o)), n.redo = [], R(), n.view = r, B(r), h.markDirty(), ne(n, e, t.origin, o), {
1152
- applied: !0,
1153
- inverse: i
1154
- };
1155
- }
1156
- function We(e) {
1157
- h = e, E.push(f(() => e.state.template, (e) => be(e), { immediate: !0 }), f(() => e.content.value, H, { deep: !0 }), f(() => e.state.selectedBlockId, Be), f(() => e.state.isLoading, (e) => e ? W(!0, !0) : H())), typeof window < "u" && (window.addEventListener("pagehide", Ve), window.addEventListener("blur", G)), r() && c(Je);
1158
- }
1159
- function Ge() {
1160
- G();
1161
- let e = g;
1162
- return !e || e.pending.length === 0 ? Promise.resolve() : new Promise((t, n) => e.waiters.push({
1163
- resolve: t,
1164
- reject: n
1165
- }));
1166
- }
1167
- function Ke() {
1168
- G(), v = !0;
1169
- }
1170
- function qe() {
1171
- v = !1, g && B(g.view);
1172
- }
1173
- function Je() {
1174
- if (!C) {
1175
- G();
1176
- for (let e of E.splice(0)) e();
1177
- U(), Ve(), C = !0, g && ve(g), g = null, $(), typeof window < "u" && (window.removeEventListener("pagehide", Ve), window.removeEventListener("blur", G));
1178
- }
1179
- }
1180
- return {
1181
- sessionId: n,
1182
- members: s,
1183
- locks: l,
1184
- connection: u,
1185
- revision: d,
1186
- canUndo: M,
1187
- canRedo: ee,
1188
- attach: We,
1189
- undo: () => He("undo"),
1190
- redo: () => He("redo"),
1191
- clearHistory: () => {
1192
- g && (g.undo = [], g.redo = [], R());
1193
- },
1194
- flush: G,
1195
- settle: Ge,
1196
- suspend: Ke,
1197
- resume: qe,
1198
- catchUp: X,
1199
- hasConfirmedBlock: (e) => g ? Pe(g.confirmed.blocks, e) : !1,
1200
- applyOperations: Ue,
1201
- destroy: Je
1202
- };
1203
- }
1204
- // ../core/src/saved-blocks.ts
1205
- function Re(e) {
1206
- let { provider: t } = e, n = m([]), r = m(!1), i = v(() => {
1207
- let e = /* @__PURE__ */ new Set();
1208
- for (let t of n.value) {
1209
- let n = t.category?.trim();
1210
- n && e.add(n);
1211
- }
1212
- return [...e].sort((e, t) => e.localeCompare(t));
1213
- }), a = v(() => typeof t.create == "function"), o = v(() => typeof t.update == "function"), s = v(() => typeof t.delete == "function");
1214
- function c(e) {
1215
- return o.value && e.canUpdate !== !1;
1216
- }
1217
- function l(e) {
1218
- return s.value && e.canDelete !== !1;
1219
- }
1220
- function u(e, t) {
1221
- throw new H(`[Templatical] Saved blocks: ${e} is ${t}. Check the capability before calling — the editor's own UI hides the action.`);
1222
- }
1223
- function d(t) {
1224
- J(e.onError, t);
1225
- }
1226
- async function f(i) {
1227
- r.value = !0;
1228
- try {
1229
- n.value = await t.list(i);
1230
- } catch (t) {
1231
- throw e.onError?.(t), t;
1232
- } finally {
1233
- r.value = !1;
1234
- }
1235
- }
1236
- async function p(r, i, a) {
1237
- let { create: o } = t;
1238
- typeof o != "function" && u("create", "disabled by the provider");
1239
- try {
1240
- let e = await o(a ? {
1241
- name: r,
1242
- content: i,
1243
- category: a
1244
- } : {
1245
- name: r,
1246
- content: i
1247
- });
1248
- return n.value = [e, ...n.value], d(() => t.onCreated?.(e)), e;
1249
- } catch (t) {
1250
- throw e.onError?.(t), t;
1251
- }
1252
- }
1253
- async function h(r, i) {
1254
- let { update: a } = t;
1255
- typeof a != "function" && u("update", "disabled by the provider");
1256
- let o = n.value.find((e) => e.id === r);
1257
- o && o.canUpdate === !1 && u("update", `not permitted for entry "${r}"`);
1258
- try {
1259
- let e = await a(r, i);
1260
- return n.value = n.value.map((t) => t.id === r ? e : t), d(() => t.onUpdated?.(e)), e;
1261
- } catch (t) {
1262
- throw e.onError?.(t), t;
1263
- }
1264
- }
1265
- async function g(r) {
1266
- let { delete: i } = t;
1267
- typeof i != "function" && u("delete", "disabled by the provider");
1268
- let a = n.value.find((e) => e.id === r) ?? null;
1269
- a && a.canDelete === !1 && u("delete", `not permitted for entry "${r}"`);
1270
- try {
1271
- await i(r), n.value = n.value.filter((e) => e.id !== r), a && d(() => t.onDeleted?.(a));
1272
- } catch (t) {
1273
- throw e.onError?.(t), t;
1274
- }
1275
- }
1276
- return {
1277
- savedBlocks: n,
1278
- isLoading: r,
1279
- categories: i,
1280
- canCreate: a,
1281
- canUpdate: o,
1282
- canDelete: s,
1283
- canUpdateBlock: c,
1284
- canDeleteBlock: l,
1285
- load: f,
1286
- create: p,
1287
- update: h,
1288
- remove: g
1289
- };
1290
- }
1291
- // ../core/src/saved-blocks-local.ts
1292
- var ze = "templatical:saved-blocks";
1293
- function $(e = {}) {
1294
- let t = e.key ?? ze;
1295
- function n() {
1296
- if (typeof localStorage > "u") throw Error("[Templatical] createLocalStorageSavedBlocksProvider requires a browser environment with localStorage. Supply your own SavedBlocksProvider for server-side or non-browser use.");
1297
- return localStorage;
1298
- }
1299
- function r() {
1300
- let e = n().getItem(t);
1301
- if (!e) return [];
1302
- try {
1303
- let t = JSON.parse(e);
1304
- return Array.isArray(t) ? t : [];
1305
- } catch {
1306
- return [];
1307
- }
1308
- }
1309
- function i(e) {
1310
- n().setItem(t, JSON.stringify(e));
1311
- }
1312
- return {
1313
- async list(e) {
1314
- let t = r(), n = e?.search?.trim().toLowerCase(), i = e?.category?.trim();
1315
- return t.filter((e) => !(n && !e.name.toLowerCase().includes(n) || i && e.category !== i));
1316
- },
1317
- async create(e) {
1318
- let t = (/* @__PURE__ */ new Date()).toISOString(), n = {
1319
- id: ee(),
1320
- name: e.name,
1321
- content: e.content,
1322
- ...e.category ? { category: e.category } : {},
1323
- createdAt: t,
1324
- updatedAt: t
1325
- };
1326
- return i([n, ...r()]), n;
1327
- },
1328
- async update(e, t) {
1329
- let n = r(), a = n.findIndex((t) => t.id === e);
1330
- if (a === -1) throw Error(`[Templatical] Saved block not found: ${e}`);
1331
- let o = {
1332
- ...n[a],
1333
- ...t,
1334
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1335
- }, s = [...n];
1336
- return s[a] = o, i(s), o;
1337
- },
1338
- async delete(e) {
1339
- let t = r();
1340
- if (!t.some((t) => t.id === e)) throw Error(`[Templatical] Saved block not found: ${e}`);
1341
- i(t.filter((t) => t.id !== e));
1342
- }
1343
- };
1344
- }
1345
- // ../core/src/media-local.ts
1346
- var Be = "templatical:media", Ve = 50;
1347
- function He(e = {}) {
1348
- let t = e.key ?? Be;
1349
- function n() {
1350
- if (typeof localStorage > "u") throw Error("[Templatical] createLocalStorageMediaProvider requires a browser environment with localStorage. Supply your own MediaProvider for server-side or non-browser use.");
1351
- return localStorage;
1352
- }
1353
- function r() {
1354
- let e = n().getItem(t);
1355
- if (!e) return [];
1356
- try {
1357
- let t = JSON.parse(e);
1358
- return Array.isArray(t) ? t : [];
1359
- } catch {
1360
- return [];
1361
- }
1362
- }
1363
- function i(e) {
1364
- n().setItem(t, JSON.stringify(e));
1365
- }
1366
- function a(e) {
1367
- return typeof FileReader > "u" ? Promise.reject(/* @__PURE__ */ Error("[Templatical] createLocalStorageMediaProvider requires a browser environment with FileReader.")) : new Promise((t, n) => {
1368
- let r = new FileReader();
1369
- r.onload = () => {
1370
- typeof r.result == "string" ? t(r.result) : n(/* @__PURE__ */ Error("[Templatical] Failed to read file as a data URL."));
1371
- }, r.onerror = () => {
1372
- n(r.error ?? /* @__PURE__ */ Error("[Templatical] Failed to read file as a data URL."));
1373
- }, r.readAsDataURL(e);
1374
- });
1375
- }
1376
- return {
1377
- async list(e) {
1378
- let t = r(), n = e?.search?.trim().toLowerCase(), i = n ? t.filter((e) => {
1379
- let t = e.filename?.toLowerCase() ?? "", r = e.alt?.toLowerCase() ?? "";
1380
- return t.includes(n) || r.includes(n);
1381
- }) : t, a = e?.cursor ? Number.parseInt(e.cursor, 10) : 0, o = Number.isFinite(a) && a > 0 ? a : 0, s = i.slice(o, o + Ve), c = { items: s }, l = o + s.length;
1382
- return l < i.length && (c.nextCursor = String(l)), c;
1383
- },
1384
- async create(e) {
1385
- let t = await a(e.file), n = (/* @__PURE__ */ new Date()).toISOString(), o = {
1386
- id: ee(),
1387
- url: t,
1388
- filename: e.filename || e.file.name,
1389
- createdAt: n,
1390
- updatedAt: n,
1391
- size: e.file.size
1392
- };
1393
- return e.alt !== void 0 && (o.alt = e.alt), e.file.type && (o.mimeType = e.file.type), e.folderId !== void 0 && (o.folderId = e.folderId), i([o, ...r()]), o;
1394
- },
1395
- async update(e, t) {
1396
- let n = r(), a = n.findIndex((t) => t.id === e);
1397
- if (a === -1) throw Error(`[Templatical] Media asset not found: ${e}`);
1398
- let o = n[a], s = {
1399
- ...o,
1400
- ...t,
1401
- id: o.id,
1402
- url: o.url,
1403
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1404
- }, c = [...n];
1405
- return c[a] = s, i(c), s;
1406
- },
1407
- async delete(e) {
1408
- let t = r();
1409
- for (let n of e) if (!t.some((e) => e.id === n)) throw Error(`[Templatical] Media asset not found: ${n}`);
1410
- let n = new Set(e);
1411
- i(t.filter((e) => !n.has(e.id)));
1412
- },
1413
- folders: !1,
1414
- replace: !1,
1415
- importFromUrl: !1,
1416
- checkUsage: !1,
1417
- frequentlyUsed: !1,
1418
- storage: !1
1419
- };
1420
- }
1421
- // ../core/src/version-history.ts
1422
- function Ue(e) {
1423
- let { provider: t, getTemplateId: n } = e, r = m([]), i = m(!1), a = m(void 0), o = m(!1), s = /* @__PURE__ */ new Map(), c = v(() => typeof t.create == "function"), l = v(() => typeof t.restore == "function");
1424
- function u(e) {
1425
- let t = n();
1426
- if (!t) throw new H(`[Templatical] Version history: ${e} needs a template. Call create() or load() first.`);
1427
- return t;
1428
- }
1429
- function d(e) {
1430
- throw new H(`[Templatical] Version history: ${e} is disabled by the provider. Check the capability before calling — the editor's own UI hides the action.`);
1431
- }
1432
- function f(t) {
1433
- J(e.onError, t);
1434
- }
1435
- async function p(n) {
1436
- let o = u("list");
1437
- i.value = !0;
1438
- try {
1439
- let e = await t.list(o, n);
1440
- r.value = e.versions, a.value = e.nextCursor;
1441
- } catch (t) {
1442
- throw e.onError?.(t), t;
1443
- } finally {
1444
- i.value = !1;
1445
- }
1446
- }
1447
- function h(e) {
1448
- return e.content ?? s.get(e.id) ?? null;
1449
- }
1450
- async function g(n) {
1451
- let r = h(n);
1452
- if (r) return r;
1453
- let i = u("get");
1454
- try {
1455
- let e = await t.get(i, n.id);
1456
- return s.set(n.id, e), e;
1457
- } catch (t) {
1458
- throw e.onError?.(t), t;
1459
- }
1460
- }
1461
- async function _(n, i) {
1462
- let { create: a } = t;
1463
- typeof a != "function" && d("create");
1464
- let o = u("create");
1465
- try {
1466
- let e = await a(o, n, i);
1467
- return r.value = [e, ...r.value], f(() => t.onCreated?.(e)), e;
1468
- } catch (t) {
1469
- throw e.onError?.(t), t;
1470
- }
1471
- }
1472
- async function y(n) {
1473
- let { restore: r } = t;
1474
- typeof r != "function" && d("restore");
1475
- let i = u("restore"), a;
1476
- o.value = !0;
1477
- try {
1478
- a = await r(i, n);
1479
- } catch (t) {
1480
- throw e.onError?.(t), t;
1481
- } finally {
1482
- o.value = !1;
1483
- }
1484
- return f(() => t.onRestored?.(a)), a;
1485
- }
1486
- return {
1487
- nextCursor: a,
1488
- versions: r,
1489
- isLoading: i,
1490
- isRestoring: o,
1491
- canCreate: c,
1492
- canRestore: l,
1493
- load: p,
1494
- peekContent: h,
1495
- resolveContent: g,
1496
- create: _,
1497
- restore: y
1498
- };
1499
- }
1500
- // ../core/src/comments.ts
1501
- function We(e) {
1502
- let { provider: t, getTemplateId: n, getUser: r } = e, i = m([]), a = m(!1), o = m(!1), s = v(() => typeof t.create == "function"), c = v(() => typeof t.update == "function"), l = v(() => typeof t.delete == "function"), u = v(() => typeof t.setResolved == "function"), d = v(() => i.value.reduce((e, t) => e + 1 + (t.replies?.length ?? 0), 0)), f = v(() => i.value.filter((e) => !e.resolvedAt).length), p = v(() => {
1503
- let e = /* @__PURE__ */ new Map();
1504
- for (let t of i.value) t.blockId && e.set(t.blockId, (e.get(t.blockId) ?? 0) + 1 + (t.replies?.length ?? 0));
1505
- return e;
1506
- });
1507
- function h(e) {
1508
- let t = n();
1509
- if (!t) throw new H(`[Templatical] Comments: ${e} needs a template. Call create() or load() first.`);
1510
- return t;
1511
- }
1512
- function g(e) {
1513
- let t = r();
1514
- if (!t) throw new H(`[Templatical] Comments: ${e} needs to know who is commenting. Pass init({ user: { id, name } }) — an unattributed comment is not written.`);
1515
- return t;
1516
- }
1517
- function _(e) {
1518
- throw new H(`[Templatical] Comments: ${e} is disabled by the provider. Check the capability before calling — the editor's own UI hides the action.`);
1519
- }
1520
- function y(e) {
1521
- for (let t of i.value) {
1522
- if (t.id === e) return t;
1523
- for (let n of t.replies ?? []) if (n.id === e) return n;
1524
- }
1525
- return null;
1526
- }
1527
- function b(e) {
1528
- let t = r();
1529
- return t !== null && e.author.id === t.id;
1530
- }
1531
- function x(t) {
1532
- let n = se(t);
1533
- throw e.onError?.(n), n;
1534
- }
1535
- function S(t) {
1536
- J(e.onError, t);
1537
- }
1538
- function C(e, t, n) {
1539
- return [
1540
- ...e.slice(0, t),
1541
- n,
1542
- ...e.slice(t + 1)
1543
- ];
1544
- }
1545
- function w(e, t) {
1546
- return e !== void 0 && JSON.stringify(e) === JSON.stringify(t);
1547
- }
1548
- function T(e) {
1549
- if (e.parentId) {
1550
- let t = !1, n = i.value.map((n) => {
1551
- if (n.id !== e.parentId) return n;
1552
- let r = n.replies ?? [], i = r.findIndex((t) => t.id === e.id);
1553
- return i !== -1 && w(r[i], e) ? n : (t = !0, {
1554
- ...n,
1555
- replies: i === -1 ? [...r, e] : C(r, i, e)
1556
- });
1557
- });
1558
- return t && (i.value = n), t;
1559
- }
1560
- let t = i.value.findIndex((t) => t.id === e.id);
1561
- if (t === -1) return i.value = [...i.value, e], !0;
1562
- let n = {
1563
- ...e,
1564
- replies: e.replies ?? i.value[t].replies
1565
- };
1566
- return !w(i.value[t], n) && (i.value = C(i.value, t, n), !0);
1567
- }
1568
- function E(e, t) {
1569
- let n = y(e), r = t ?? n?.parentId ?? null;
1570
- return r ? i.value = i.value.map((t) => t.id === r ? {
1571
- ...t,
1572
- replies: (t.replies ?? []).filter((t) => t.id !== e)
1573
- } : t) : i.value = i.value.filter((t) => t.id !== e), n;
1574
- }
1575
- async function D(e) {
1576
- let n = h("list");
1577
- a.value = !0;
1578
- try {
1579
- i.value = await t.list(n, e);
1580
- } catch (e) {
1581
- x(e);
1582
- } finally {
1583
- a.value = !1;
1584
- }
1585
- }
1586
- async function O(e) {
1587
- let { create: n } = t;
1588
- typeof n != "function" && _("create");
1589
- let r = h("create");
1590
- g("create"), o.value = !0;
1591
- try {
1592
- let i = await n(r, e);
1593
- return T(i), S(() => t.onCreated?.(i, { origin: "local" })), i;
1594
- } catch (e) {
1595
- x(e);
1596
- } finally {
1597
- o.value = !1;
1598
- }
1599
- }
1600
- async function k(e, n) {
1601
- let { update: r } = t;
1602
- typeof r != "function" && _("update");
1603
- let i = h("update");
1604
- g("update"), o.value = !0;
1605
- try {
1606
- let a = await r(i, e, n);
1607
- return T(a), S(() => t.onUpdated?.(a, { origin: "local" })), a;
1608
- } catch (e) {
1609
- x(e);
1610
- } finally {
1611
- o.value = !1;
1612
- }
1613
- }
1614
- async function A(e) {
1615
- let { delete: n } = t;
1616
- typeof n != "function" && _("delete");
1617
- let r = h("delete");
1618
- g("delete");
1619
- let i = y(e);
1620
- o.value = !0;
1621
- try {
1622
- await n(r, e), E(e), i && S(() => t.onDeleted?.(i, { origin: "local" }));
1623
- } catch (e) {
1624
- x(e);
1625
- } finally {
1626
- o.value = !1;
1627
- }
1628
- }
1629
- async function j(e, n) {
1630
- let { setResolved: r } = t;
1631
- typeof r != "function" && _("setResolved");
1632
- let i = h("setResolved");
1633
- g("setResolved"), o.value = !0;
1634
- try {
1635
- let a = await r(i, e, n);
1636
- return T(a), S(() => (a.resolvedAt ? t.onResolved : t.onUnresolved)?.(a, { origin: "local" })), a;
1637
- } catch (e) {
1638
- x(e);
1639
- } finally {
1640
- o.value = !1;
1641
- }
1642
- }
1643
- function M(e) {
1644
- T(e) && S(() => t.onCreated?.(e, { origin: "remote" }));
1645
- }
1646
- function N(e) {
1647
- T(e) && S(() => (e.resolvedAt ? t.onResolved : t.onUpdated)?.(e, { origin: "remote" }));
1648
- }
1649
- function P(e, n) {
1650
- let r = E(e, n);
1651
- r && S(() => t.onDeleted?.(r, { origin: "remote" }));
1652
- }
1653
- return {
1654
- comments: i,
1655
- isLoading: a,
1656
- isSubmitting: o,
1657
- canCreate: s,
1658
- canUpdate: c,
1659
- canDelete: l,
1660
- canResolve: u,
1661
- totalCount: d,
1662
- unresolvedCount: f,
1663
- commentCountByBlock: p,
1664
- load: D,
1665
- create: O,
1666
- update: k,
1667
- remove: A,
1668
- setResolved: j,
1669
- find: y,
1670
- isOwn: b,
1671
- applyRemoteCreate: M,
1672
- applyRemoteUpdate: N,
1673
- applyRemoteDelete: P
1674
- };
1675
- }
1676
- function Ge(e) {
1677
- let { comments: t, provider: n, getTemplateId: r } = e, { subscribe: i } = n;
1678
- if (typeof i != "function") return;
1679
- let a = null;
1680
- function o() {
1681
- a?.(), a = null;
1682
- }
1683
- s(() => r(), (e) => {
1684
- o(), e && (a = i(e, (e) => {
1685
- switch (e.type) {
1686
- case "created":
1687
- t.applyRemoteCreate(e.comment);
1688
- break;
1689
- case "updated":
1690
- t.applyRemoteUpdate(e.comment);
1691
- break;
1692
- case "deleted": t.applyRemoteDelete(e.commentId, e.parentId);
1693
- }
1694
- }));
1695
- }, { immediate: !0 }), c(o);
1696
- }
1697
- // src/constants/timeouts.ts
1698
- var Ke = 1e4;
1699
- // src/composables/useImageUrlResolver.ts
1700
- function qe(e) {
1701
- let t = o(/* @__PURE__ */ new Map()), n = /* @__PURE__ */ new Set();
1702
- function r(e) {
1703
- return t.get(e);
1704
- }
1705
- function i(e) {
1706
- return t.has(e) || n.has(e);
1707
- }
1708
- function a(r) {
1709
- if (i(r)) return;
1710
- let a;
1711
- try {
1712
- a = e(r);
1713
- } catch {
1714
- t.set(r, null);
1715
- return;
1716
- }
1717
- a === null || typeof a == "string" ? t.set(r, a) : (n.add(r), Promise.resolve(a).then((e) => {
1718
- t.set(r, typeof e == "string" ? e : null);
1719
- }, () => {
1720
- t.set(r, null);
1721
- }).finally(() => n.delete(r)));
1722
- }
1723
- return {
1724
- get: r,
1725
- has: i,
1726
- lookup: a
1727
- };
1728
- }
1729
- function Je(e) {
1730
- let t = n(K, null), i = v(e);
1731
- if (!t) return i;
1732
- let a;
1733
- function o() {
1734
- a !== void 0 && (clearTimeout(a), a = void 0);
1735
- }
1736
- r() && c(o);
1737
- let l = !0;
1738
- return s(i, (e) => {
1739
- o();
1740
- let n = l;
1741
- l = !1, e && !t.has(e) && (n ? t.lookup(e) : a = setTimeout(() => {
1742
- a = void 0, t.lookup(e);
1743
- }, 300));
1744
- }, { immediate: !0 }), v(() => {
1745
- let e = i.value;
1746
- if (!e) return e;
1747
- let n = t.get(e);
1748
- return typeof n == "string" && n.length > 0 ? n : e;
1749
- });
1750
- }
1751
- function Ye(e, t) {
1752
- if (!e || !t) return t;
1753
- let n = e.get(t);
1754
- return typeof n == "string" && n.length > 0 ? n : t;
1755
- }
1756
- function Xe(e, t) {
1757
- return typeof e?.url == "string" && B(e.url, t);
1758
- }
1759
- function Ze(e, t) {
1760
- let n = e?.url;
1761
- if (typeof n == "string" && n.trim() !== "") return B(n, t) ? void 0 : n;
1762
- }
1763
- function Qe(e) {
1764
- let t = n(te, z.liquid), r = Je(() => Ze(e(), t));
1765
- return v(() => Xe(e(), t) ? null : r.value);
1766
- }
1767
- function $e(e, t, n) {
1768
- return Xe(t, n) ? null : Ye(e, Ze(t, n));
1769
- }
1770
- // src/utils/blockTypeLabels.ts
1771
- function et(e, t) {
1772
- return t.blocks[e] ?? e;
1773
- }
1774
- function tt(e, t, n = []) {
1775
- if (e.type !== "custom") return et(e.type, t);
1776
- let { customType: r } = e;
1777
- return n.find((e) => e.type === r)?.name ?? r;
1778
- }
1779
- // src/utils/resolveFieldColors.ts
1780
- function nt(e, t) {
1781
- let n = q({ presets: e.presets }, ie), r = n.presets.length === 0;
1782
- return {
1783
- presets: r ? t.presets : n.presets,
1784
- allowCustom: t.allowCustom === !1 ? !1 : e.allowCustom ?? t.allowCustom,
1785
- invalidPresets: n.invalidPresets,
1786
- emptyPresets: e.presets !== void 0 && e.presets.length === 0,
1787
- presetsInherited: r,
1788
- allowCustomIgnored: e.allowCustom === !0 && t.allowCustom === !1
1789
- };
1790
- }
1791
- // src/utils/imageNaturalSize.ts
1792
- function rt(e) {
1793
- return typeof e == "number" && Number.isFinite(e) && e > 0;
1794
- }
1795
- function it(e, t) {
1796
- return rt(e) && rt(t) ? {
1797
- width: e,
1798
- height: t
1799
- } : null;
1800
- }
1801
- function at(e) {
1802
- return it(e.naturalWidth, e.naturalHeight);
1803
- }
1804
- function ot(e) {
1805
- return e ? {
1806
- naturalWidth: e.width,
1807
- naturalHeight: e.height
1808
- } : {
1809
- naturalWidth: void 0,
1810
- naturalHeight: void 0
1811
- };
1812
- }
1813
- function st(e, t) {
1814
- if (typeof Image > "u") return t(null), () => {};
1815
- let n = new Image(), r = () => {
1816
- n.onload = null, n.onerror = null;
1817
- };
1818
- return n.onload = () => {
1819
- r(), t(it(n.naturalWidth, n.naturalHeight));
1820
- }, n.onerror = () => {
1821
- r(), t(null);
1822
- }, n.src = e, r;
1823
- }
1824
- function ct(e) {
1825
- return new Promise((t) => {
1826
- let n = setTimeout(() => {
1827
- r(), t(null);
1828
- }, Ke), r = st(e, (e) => {
1829
- clearTimeout(n), t(e);
1830
- });
1831
- });
1832
- }
1833
- // src/components/MediaDropOverlay.vue
1834
- var lt = /* @__PURE__ */ t({
1835
- __name: "MediaDropOverlay",
1836
- props: {
1837
- uploading: { type: Boolean },
1838
- size: { default: "field" }
1839
- },
1840
- setup(e) {
1841
- let t = e, { t: n } = re(), r = {
1842
- field: {
1843
- gap: "tpl:gap-1.5",
1844
- icon: 18,
1845
- veil: "90%"
1846
- },
1847
- canvas: {
1848
- gap: "tpl:gap-2",
1849
- icon: 20,
1850
- veil: "85%"
1851
- }
1852
- }, i = v(() => r[t.size]);
1853
- return (t, r) => (a(), l("div", {
1854
- class: x(["tpl:pointer-events-none tpl:absolute tpl:inset-0 tpl:z-10 tpl:flex tpl:flex-col tpl:items-center tpl:justify-center tpl:rounded tpl:border-2 tpl:border-dashed tpl:text-xs tpl:font-medium tpl:border-[var(--tpl-primary)] tpl:text-[var(--tpl-primary)]", i.value.gap]),
1855
- style: p({ backgroundColor: `color-mix(in srgb, var(--tpl-bg) ${i.value.veil}, transparent)` })
1856
- }, [e.uploading ? (a(), l(b, { key: 0 }, [S(y(ae), {
1857
- class: "tpl-spinner",
1858
- size: i.value.icon,
1859
- "stroke-width": 2
1860
- }, null, 8, ["size"]), d(" " + h(y(n).image.uploading), 1)], 64)) : (a(), l(b, { key: 1 }, [S(y(oe), {
1861
- size: i.value.icon,
1862
- "stroke-width": 1.5
1863
- }, null, 8, ["size"]), d(" " + h(y(n).image.dropToUpload), 1)], 64))], 6));
1864
- }
1865
- });
1866
- // src/composables/useAliveFlag.ts
1867
- function ut() {
1868
- let e = { alive: !0 };
1869
- return g(() => {
1870
- e.alive = !1;
1871
- }), e;
1872
- }
1873
- // src/composables/useImageDrop.ts
1874
- var dt = "image/";
1875
- function ft(e) {
1876
- let { target: t, onFiles: n, enabled: r } = e, i = () => r === void 0 || u(r), { isOverDropZone: a } = W(t, {
1877
- preventDefaultForUnhandled: !0,
1878
- onDrop: (e) => {
1879
- if (!i()) return;
1880
- let t = (e ?? []).filter((e) => e.type.startsWith(dt));
1881
- t.length > 0 && n([t[0]]);
1882
- }
1883
- });
1884
- return { isOver: v(() => i() && a.value) };
1885
- }
1886
- // src/composables/useMediaDropField.ts
1887
- function pt(e) {
1888
- let { target: t, blocked: r, apply: i } = e, a = n(G, null), o = n(ne, null), s = ut();
1889
- async function c() {
1890
- let e = await a?.({ accept: ["images"] });
1891
- s.alive && e && i(e);
1892
- }
1893
- let l = m(!1), d = v(() => (o?.value ?? !!a) && !l.value && !u(r));
1894
- async function f(e) {
1895
- if (a) {
1896
- l.value = !0;
1897
- try {
1898
- let t = await a({
1899
- accept: ["images"],
1900
- files: e
1901
- });
1902
- if (!s.alive) return;
1903
- t && i(t);
1904
- } finally {
1905
- s.alive && (l.value = !1);
1906
- }
1907
- }
1908
- }
1909
- let { isOver: p } = ft({
1910
- target: t,
1911
- enabled: d,
1912
- onFiles: f
1913
- }), h = v(() => d.value && p.value || l.value);
1914
- return {
1915
- canBrowse: !!a,
1916
- dropEnabled: d,
1917
- isUploading: l,
1918
- showOverlay: h,
1919
- openMediaBrowser: c
1920
- };
1921
- }
1922
- function mt(e, t = "desktop") {
1923
- return t === "mobile" ? 375 : e?.width ?? 600;
1924
- }
1925
- var ht = "width 300ms cubic-bezier(0.34, 1.56, 0.64, 1)", gt = {
1926
- 1: [100],
1927
- 2: [50, 50],
1928
- 3: [
1929
- 33.33,
1930
- 33.33,
1931
- 33.34
1932
- ],
1933
- "1-2": [33.33, 66.67],
1934
- "2-1": [66.67, 33.33]
1935
- };
1936
- function _t(e, t) {
1937
- let n = (e) => Math.trunc(e ?? 0), r = (e) => O(e) === null ? 0 : Math.trunc(e.width);
1938
- return n(e?.left) + n(e?.right) + r(t?.left) + r(t?.right);
1939
- }
1940
- function vt(e, t) {
1941
- return Math.floor(e) - _t(t);
1942
- }
1943
- function yt(e, t) {
1944
- let n = "border" in e ? e.border : void 0;
1945
- return Math.floor(t) - _t(e.styles.padding, n);
1946
- }
1947
- function* bt(e, t) {
1948
- for (let n of e) U(n) ? yield* bt(n.children, vt(t, n.styles.padding)) : yield {
1949
- block: n,
1950
- bandWidth: I(n) && n.wrapper ? vt(t, n.wrapper.padding) : t
1951
- };
1952
- }
1953
- function xt(e, t) {
1954
- if (!t) return e;
1955
- try {
1956
- return A(t, e);
1957
- } catch {
1958
- return e;
1959
- }
1960
- }
1961
- function St(e, t, n) {
1962
- let r = xt(e, n);
1963
- for (let { block: e, bandWidth: n } of bt(r.blocks, r.settings.width)) if (I(e)) {
1964
- let r = D(e)?.applied ? void 0 : e.border, i = Math.floor(n) - _t(e.styles.padding, r), a = gt[e.columns] ?? [100];
1965
- for (let n = 0; n < e.children.length; n++) {
1966
- let r = Math.floor(i * (a[n] ?? 100) / 100), o = e.children[n].find((e) => e.id === t);
1967
- if (o) return yt(o, r);
1968
- }
1969
- } else if (e.id === t) return yt(e, n);
1970
- return null;
1971
- }
1972
- function Ct(e, t, n) {
1973
- let r = xt(e, n);
1974
- for (let { block: e, bandWidth: n } of bt(r.blocks, r.settings.width)) if (e.id === t) return Math.floor(n);
1975
- return null;
1976
- }
1977
- function wt(e, t, n) {
1978
- if (!I(e)) return;
1979
- let r = D(e);
1980
- if (r?.applied && r.height === "image") return (t ? Ct(t, e.id, n) : null) ?? mt(t?.settings);
1981
- }
1982
- // src/constants/socialIcons.ts
1983
- var Tt = R, Et = {
1984
- small: 24,
1985
- medium: 32,
1986
- large: 48
1987
- }, Dt = [
1988
- "facebook",
1989
- "twitter",
1990
- "instagram",
1991
- "linkedin",
1992
- "youtube",
1993
- "tiktok",
1994
- "pinterest",
1995
- "email",
1996
- "website",
1997
- "whatsapp",
1998
- "telegram",
1999
- "discord",
2000
- "snapchat",
2001
- "reddit",
2002
- "github",
2003
- "dribbble",
2004
- "behance"
2005
- ];
2006
- export { Re as A, Qe as C, Ue as D, We as E, pe as F, X as I, fe as L, ge as M, he as N, He as O, me as P, Y as R, $e as S, Ge as T, nt as _, wt as a, qe as b, mt as c, lt as d, st as f, it as g, at as h, St as i, Le as j, $ as k, pt as l, ot as m, Tt as n, Ct as o, ct as p, Dt as r, ht as s, Et as t, ut as u, tt as v, Je as w, Ze as x, et as y, ce as z };
2007
-
2008
- //# sourceMappingURL=socialIcons-jsTDmkbb.js.map