@templatical/editor 0.49.0 → 0.51.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 (378) 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-BdpJwim0.js → BlockIssueBadge-CKwZ1Vgn.js} +11 -11
  9. package/dist/{BlockPreviewCanvas-D_sowkf0.js → BlockPreviewCanvas-BXNLLLYi.js} +33 -33
  10. package/dist/CloudHeaderExtras-CsJMEiyN.js +23 -0
  11. package/dist/{CloudPanels-1hwFiJ0G.js → CloudPanels-B4F5m7vy.js} +66 -85
  12. package/dist/{CollaborationNotices-BWpKzueF.js → CollaborationNotices-CNuDp7Y2.js} +19 -16
  13. package/dist/{CollaboratorBar-D87phJsw.js → CollaboratorBar-BtHPiuHq.js} +22 -22
  14. package/dist/{CommentsPanel-BUvUzO3T.js → CommentsPanel-CyCM-BvT.js} +4 -4
  15. package/dist/CommentsSidebar-Ca3DyFOX.js +500 -0
  16. package/dist/{cdn/chunks/CountdownBlock-DB4JNdqh.js → CountdownBlock-DR4Xm2-T.js} +24 -26
  17. package/dist/{CountdownToolbar-CLMIwfK7.js → CountdownToolbar-CEIMPojJ.js} +55 -55
  18. package/dist/IssuesPanel-C8nMUccy.js +360 -0
  19. package/dist/{LoadingTrack-BXOptf5g.js → LoadingTrack-B0RKQWq3.js} +2 -2
  20. package/dist/{LogicTagInsertButton-CR5E4jSG.js → LogicTagInsertButton-CqfU52CO.js} +273 -268
  21. package/dist/{cdn/chunks/MediaEditModal-DD0SZ-S3.js → MediaEditModal-DHtkZ4OU.js} +202 -186
  22. package/dist/{MediaPanels-BVXDkqtH.js → MediaPanels-CGcOB2pR.js} +4 -4
  23. package/dist/{MergeTagInput-BEw_r0PJ.js → MergeTagInput-YnEkorTZ.js} +25 -25
  24. package/dist/{MergeTagModeToggle-CJTpFmVd.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-BaDpy3cL.js → RestoreVersionDialog-Bq_IGOLJ.js} +21 -21
  28. package/dist/{RichTextEditorContent-CsvniFlI.js → RichTextEditorContent-AOM6fylS.js} +48 -48
  29. package/dist/{SaveBlockDialog-DzWURF_e.js → SaveBlockDialog-C8GngfQx.js} +87 -87
  30. package/dist/{cdn/chunks/SavedBlocksBrowserModal-BMtyUrUP.js → SavedBlocksBrowserModal-wnkvxpm_.js} +102 -99
  31. package/dist/{SavedBlocksPanels-B3Af8ns2.js → SavedBlocksPanels-C2s3q0pJ.js} +9 -9
  32. package/dist/{SavedBlocksPickBar-Dj11-Lqp.js → SavedBlocksPickBar-BjcTiV87.js} +13 -13
  33. package/dist/TemplateSettings-BVBWpiDU.js +237 -0
  34. package/dist/{TestEmailModal-BeRYV3eg.js → TestEmailModal-SyhO9bn3.js} +57 -57
  35. package/dist/{TestEmailPanel-B8c3fQi2.js → TestEmailPanel-BDd2Rtav.js} +4 -4
  36. package/dist/{TitleEditor-CvpNUoAp.js → TitleEditor-pxD53y_l.js} +75 -75
  37. package/dist/ToggleSwitch-D51U9cmR.js +37 -0
  38. package/dist/{Toolbar-BadDSkkF.js → Toolbar-CZSPZYbj.js} +1138 -1138
  39. package/dist/{TplModal-BZgi9Tes.js → TplModal-DCzBzicE.js} +19 -19
  40. package/dist/{VersionHistoryMenu-BRlcQ8wX.js → VersionHistoryMenu-BQeWPT85.js} +35 -35
  41. package/dist/{VersionHistoryPanels-DGkllN3a.js → VersionHistoryPanels-BBm7YbRQ.js} +5 -5
  42. package/dist/{VersionPreviewBanner-F-811aps.js → VersionPreviewBanner-DUGF0tUJ.js} +9 -9
  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-CayLluou.js → blockTypeIcons-NzaYvAI4.js} +15 -14
  48. package/dist/bundle-stats.json +8 -8
  49. package/dist/{cdn/chunks/ca-DSJwJ5ov.js → ca-C7mTzW1r.js} +130 -13
  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-D1VBS_6x.js → BlockIssueBadge-DAn2vsMJ.js} +13 -13
  63. package/dist/cdn/chunks/{BlockIssueBadge-D1VBS_6x.js.map → BlockIssueBadge-DAn2vsMJ.js.map} +1 -1
  64. package/dist/cdn/chunks/{BlockPreviewCanvas-m2tWRyWv.js → BlockPreviewCanvas-D0--EQkP.js} +38 -38
  65. package/dist/cdn/chunks/{BlockPreviewCanvas-m2tWRyWv.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-XufhBZYF.js → CloudPanels-C3jsxo_f.js} +52 -71
  69. package/dist/cdn/chunks/CloudPanels-C3jsxo_f.js.map +1 -0
  70. package/dist/cdn/chunks/{CollaborationNotices-CBvKEj1Q.js → CollaborationNotices-DjRI8gvs.js} +23 -20
  71. package/dist/cdn/chunks/CollaborationNotices-DjRI8gvs.js.map +1 -0
  72. package/dist/cdn/chunks/{CollaboratorBar-DWW54Bn_.js → CollaboratorBar-Dfzm6A9A.js} +20 -20
  73. package/dist/cdn/chunks/{CollaboratorBar-DWW54Bn_.js.map → CollaboratorBar-Dfzm6A9A.js.map} +1 -1
  74. package/dist/cdn/chunks/CommentsPanel-CSO79OeX.js +20 -0
  75. package/dist/cdn/chunks/{CommentsPanel-R8YLLO3v.js.map → CommentsPanel-CSO79OeX.js.map} +1 -1
  76. package/dist/cdn/chunks/CommentsSidebar-CCvplq1Z.js +470 -0
  77. package/dist/cdn/chunks/{CommentsSidebar-96NZHVq3.js.map → CommentsSidebar-CCvplq1Z.js.map} +1 -1
  78. package/dist/{CountdownBlock-DPQXWRvU.js → cdn/chunks/CountdownBlock-C6USdwk3.js} +19 -17
  79. package/dist/cdn/chunks/{CountdownBlock-DB4JNdqh.js.map → CountdownBlock-C6USdwk3.js.map} +1 -1
  80. package/dist/cdn/chunks/{CountdownToolbar-tmiTPEXm.js → CountdownToolbar-Cjud2Tos.js} +70 -70
  81. package/dist/cdn/chunks/{CountdownToolbar-tmiTPEXm.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-YU44CM8X.js → LoadingTrack-BIcL4NiY.js} +2 -2
  85. package/dist/cdn/chunks/{LoadingTrack-YU44CM8X.js.map → LoadingTrack-BIcL4NiY.js.map} +1 -1
  86. package/dist/cdn/chunks/{LogicTagInsertButton-BJ2t2vxC.js → LogicTagInsertButton-CsL2JDOG.js} +367 -362
  87. package/dist/cdn/chunks/LogicTagInsertButton-CsL2JDOG.js.map +1 -0
  88. package/dist/{MediaEditModal-C_wxoUMG.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-CkdJ_kGp.js.map → MediaPanels-DAgUf_T1.js.map} +1 -1
  92. package/dist/cdn/chunks/{MergeTagInput-7wXX71DH.js → MergeTagInput-C8U-7LxL.js} +33 -33
  93. package/dist/cdn/chunks/{MergeTagInput-7wXX71DH.js.map → MergeTagInput-C8U-7LxL.js.map} +1 -1
  94. package/dist/cdn/chunks/{MergeTagModeToggle-r9vHH4u_.js → MergeTagModeToggle-Mm-p0A52.js} +41 -41
  95. package/dist/cdn/chunks/{MergeTagModeToggle-r9vHH4u_.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-C5cxBRKi.js → RestoreVersionDialog-CdA5osuA.js} +25 -25
  101. package/dist/cdn/chunks/{RestoreVersionDialog-C5cxBRKi.js.map → RestoreVersionDialog-CdA5osuA.js.map} +1 -1
  102. package/dist/cdn/chunks/{RichTextEditorContent-BfE7Bkge.js → RichTextEditorContent-Q1d2xqBT.js} +46 -46
  103. package/dist/cdn/chunks/{RichTextEditorContent-BfE7Bkge.js.map → RichTextEditorContent-Q1d2xqBT.js.map} +1 -1
  104. package/dist/cdn/chunks/{SaveBlockDialog-BKbjUnPM.js → SaveBlockDialog-CijargAy.js} +77 -77
  105. package/dist/cdn/chunks/{SaveBlockDialog-BKbjUnPM.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-BMtyUrUP.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-s_gxi1im.js.map → SavedBlocksPanels-BowyED5h.js.map} +1 -1
  110. package/dist/cdn/chunks/{SavedBlocksPickBar-B8WHk5mI.js → SavedBlocksPickBar-BPRaJBv3.js} +18 -18
  111. package/dist/cdn/chunks/{SavedBlocksPickBar-B8WHk5mI.js.map → SavedBlocksPickBar-BPRaJBv3.js.map} +1 -1
  112. package/dist/cdn/chunks/TemplateSettings-ByZeBO34.js +209 -0
  113. package/dist/cdn/chunks/{TemplateSettings-CtrzzQWl.js.map → TemplateSettings-ByZeBO34.js.map} +1 -1
  114. package/dist/cdn/chunks/{TestEmailModal-DuZKYMWD.js → TestEmailModal-BUVTj3Ic.js} +54 -54
  115. package/dist/cdn/chunks/{TestEmailModal-DuZKYMWD.js.map → TestEmailModal-BUVTj3Ic.js.map} +1 -1
  116. package/dist/cdn/chunks/TestEmailPanel-BxutYoWg.js +35 -0
  117. package/dist/cdn/chunks/{TestEmailPanel-DERaCdpG.js.map → TestEmailPanel-BxutYoWg.js.map} +1 -1
  118. package/dist/cdn/chunks/TitleEditor-Ccv6uoTz.js +199 -0
  119. package/dist/cdn/chunks/{TitleEditor-CEgxjtUX.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-GFIZQHzw.js → Toolbar-DoprRgTn.js} +986 -987
  123. package/dist/cdn/chunks/{Toolbar-GFIZQHzw.js.map → Toolbar-DoprRgTn.js.map} +1 -1
  124. package/dist/cdn/chunks/{TplModal-DDrbWJcE.js → TplModal-BXQzmsJX.js} +21 -21
  125. package/dist/cdn/chunks/{TplModal-DDrbWJcE.js.map → TplModal-BXQzmsJX.js.map} +1 -1
  126. package/dist/cdn/chunks/{VersionHistoryMenu-MlxsUmuT.js → VersionHistoryMenu-BF2fNCvq.js} +41 -41
  127. package/dist/cdn/chunks/{VersionHistoryMenu-MlxsUmuT.js.map → VersionHistoryMenu-BF2fNCvq.js.map} +1 -1
  128. package/dist/cdn/chunks/VersionHistoryPanels-Dal0Uk69.js +48 -0
  129. package/dist/cdn/chunks/{VersionHistoryPanels-DVOV8QLv.js.map → VersionHistoryPanels-Dal0Uk69.js.map} +1 -1
  130. package/dist/cdn/chunks/{VersionPreviewBanner-BQwRKc6S.js → VersionPreviewBanner-BaGcn-b1.js} +12 -12
  131. package/dist/cdn/chunks/{VersionPreviewBanner-BQwRKc6S.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-CFuP4R0c.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-BnAd8qsP.js.map → blockTypeIcons-ikZAmd6U.js.map} +1 -1
  142. package/dist/{ca-DSJwJ5ov.js → cdn/chunks/ca-C7mTzW1r.js} +132 -11
  143. package/dist/cdn/chunks/ca-C7mTzW1r.js.map +1 -0
  144. package/dist/cdn/chunks/{cloud-CI_fgDyy.js → createCloudRuntime-DpBWhrv3.js} +489 -593
  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-CBE6O79z.js → cdn/chunks/de-DNuYQTmS.js} +132 -11
  149. package/dist/cdn/chunks/de-DNuYQTmS.js.map +1 -0
  150. package/dist/{dist-Bv_GBr2l.js → cdn/chunks/dist-Bo8Thh8v.js} +60 -58
  151. package/dist/cdn/chunks/{dist-Doy3r07H.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-DdwjXLme.js.map → dist-S-rLGqax.js.map} +1 -1
  154. package/dist/cdn/chunks/{draggable-akeQH_JP.js → draggable-DZ0gwUJ6.js} +1822 -1728
  155. package/dist/cdn/chunks/draggable-DZ0gwUJ6.js.map +1 -0
  156. package/dist/cdn/chunks/{editor-modal-HJBy9kLj.js → editor-modal-CI6EfeMd.js} +884 -884
  157. package/dist/cdn/chunks/{editor-modal-HJBy9kLj.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-CDexnk0p.js → cdn/chunks/en-CW71OK66.js} +132 -11
  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-BE42B6uN.js → cdn/chunks/es-DdK7zQfi.js} +132 -11
  164. package/dist/cdn/chunks/es-DdK7zQfi.js.map +1 -0
  165. package/dist/cdn/chunks/{extensions-koOuDeZS.js → extensions-taJTZlLK.js} +59 -59
  166. package/dist/cdn/chunks/{extensions-koOuDeZS.js.map → extensions-taJTZlLK.js.map} +1 -1
  167. package/dist/{fr-DlJFPDQR.js → cdn/chunks/fr-Dz5Bgb7-.js} +132 -11
  168. package/dist/cdn/chunks/fr-Dz5Bgb7-.js.map +1 -0
  169. package/dist/cdn/chunks/{icons-CjlNV8xD.js → icons-DNX6StSs.js} +178 -145
  170. package/dist/cdn/chunks/icons-DNX6StSs.js.map +1 -0
  171. package/dist/{ja-CUT8gkNI.js → cdn/chunks/ja-Di-zJiT8.js} +132 -11
  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-bXWqqRyS.js → cdn/chunks/nl-CvVuHYFL.js} +132 -11
  178. package/dist/cdn/chunks/{nl-bXWqqRyS.js.map → nl-CvVuHYFL.js.map} +1 -1
  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-DqKbdTJ8.js → preRenderCustomBlocks-Dc-QLntG.js} +4 -4
  182. package/dist/cdn/chunks/{preRenderCustomBlocks-DqKbdTJ8.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-2_H4-wlb.js → cdn/chunks/pt-BR-ZhO4vgyq.js} +132 -11
  186. package/dist/cdn/chunks/pt-BR-ZhO4vgyq.js.map +1 -0
  187. package/dist/cdn/chunks/sanitizeRichTextHtml-DeISfLFr.js +62 -0
  188. package/dist/cdn/chunks/sanitizeRichTextHtml-DeISfLFr.js.map +1 -0
  189. package/dist/cdn/chunks/socialIcons-BBvsTwCV.js +2032 -0
  190. package/dist/cdn/chunks/socialIcons-BBvsTwCV.js.map +1 -0
  191. package/dist/{dist-DBG3nh3k.js → cdn/chunks/src-BNFnxfrA.js} +552 -350
  192. package/dist/cdn/chunks/src-BNFnxfrA.js.map +1 -0
  193. package/dist/cdn/chunks/src-Bs_yxk3h.js +4392 -0
  194. package/dist/cdn/chunks/src-Bs_yxk3h.js.map +1 -0
  195. package/dist/cdn/chunks/{src-B77z1iw4.js → src-K6fw_35b.js} +113 -113
  196. package/dist/cdn/chunks/{src-B77z1iw4.js.map → src-K6fw_35b.js.map} +1 -1
  197. package/dist/cdn/chunks/{tiptap-B1RfWFzB.js → tiptap-CtVrAViq.js} +43 -43
  198. package/dist/cdn/chunks/{tiptap-B1RfWFzB.js.map → tiptap-CtVrAViq.js.map} +1 -1
  199. package/dist/cdn/chunks/{useCloudI18n-kp07GQmk.js → useCloudI18n-AVXhzbhQ.js} +4 -4
  200. package/dist/cdn/chunks/{useCloudI18n-kp07GQmk.js.map → useCloudI18n-AVXhzbhQ.js.map} +1 -1
  201. package/dist/cdn/chunks/useEditorCore-CCVFi1YZ.js +2586 -0
  202. package/dist/cdn/chunks/useEditorCore-CCVFi1YZ.js.map +1 -0
  203. package/dist/cdn/chunks/useEditorRoot-CR5GjJD6.js +10 -0
  204. package/dist/cdn/chunks/{useEditorRoot-5SBqm90x.js.map → useEditorRoot-CR5GjJD6.js.map} +1 -1
  205. package/dist/cdn/chunks/{useI18n-DEqtEgOs.js → useI18n-CbVubQhM.js} +3 -3
  206. package/dist/cdn/chunks/{useI18n-DEqtEgOs.js.map → useI18n-CbVubQhM.js.map} +1 -1
  207. package/dist/cdn/chunks/{useLogicTag-X8bc5qNl.js → useLogicTag-B49Nc53Y.js} +5 -5
  208. package/dist/cdn/chunks/{useLogicTag-X8bc5qNl.js.map → useLogicTag-B49Nc53Y.js.map} +1 -1
  209. package/dist/cdn/chunks/{useMergeTag-DFoOexIQ.js → useMergeTag-B0KryMj8.js} +5 -5
  210. package/dist/cdn/chunks/{useMergeTag-DFoOexIQ.js.map → useMergeTag-B0KryMj8.js.map} +1 -1
  211. package/dist/cdn/chunks/{usePopoverPosition-Cz9-XiXR.js → usePopoverPosition-C829ps5i.js} +4 -4
  212. package/dist/cdn/chunks/{usePopoverPosition-Cz9-XiXR.js.map → usePopoverPosition-C829ps5i.js.map} +1 -1
  213. package/dist/cdn/chunks/useScrollToBlock-CAwvulog.js +51 -0
  214. package/dist/cdn/chunks/useScrollToBlock-CAwvulog.js.map +1 -0
  215. package/dist/cdn/chunks/{withCurrentFont-D-f61ghC.js → withCurrentFont-DFPXeVfG.js} +2 -2
  216. package/dist/cdn/chunks/{withCurrentFont-D-f61ghC.js.map → withCurrentFont-DFPXeVfG.js.map} +1 -1
  217. package/dist/cdn/editor.css +1 -1
  218. package/dist/cdn/editor.js +2151 -1480
  219. package/dist/cdn/editor.js.map +1 -1
  220. package/dist/{check-DQQzkmIC.js → check-yYsp5Xpk.js} +1 -1
  221. package/dist/{chevron-down-CIF4bdon.js → chevron-down-DTmD06_j.js} +1 -1
  222. package/dist/{chevron-right-Cg7Xu-ev.js → chevron-right-BSeYZOxc.js} +1 -1
  223. package/dist/{chevron-up-Csu7ISD-.js → chevron-up-BOApwrxi.js} +1 -1
  224. package/dist/{circle-alert-YUvIJAgY.js → circle-alert-BMszY8im.js} +1 -1
  225. package/dist/{clock-CnSIGKQW.js → clock-HADxnl6-.js} +1 -1
  226. package/dist/{cloud-YUYDtdHt.js → createCloudRuntime-DVQI_ReU.js} +474 -570
  227. package/dist/{createLucideIcon-BcP1sjdp.js → createLucideIcon-0lYYH3EW.js} +6 -6
  228. package/dist/de-DBOTcDj2.js +20 -0
  229. package/dist/{cdn/chunks/de-CBE6O79z.js → de-DNuYQTmS.js} +130 -13
  230. package/dist/{cdn/chunks/dist-Doy3r07H.js → dist-C7EtxNCb.js} +49 -51
  231. package/dist/{dist-CNqjHA8e.js → dist-C_dV9QAx.js} +130 -130
  232. package/dist/{cdn/chunks/dist-DdwjXLme.js → dist-DI4_YSnG.js} +111 -110
  233. package/dist/{cdn/chunks/src-CvLTYGdO.js → dist-DtOF3bDW.js} +446 -393
  234. package/dist/{editor-modal--7_9A6j-.js → editor-modal-Bzhl-PgI.js} +832 -834
  235. package/dist/en-CDhWRrF_.js +20 -0
  236. package/dist/{cdn/chunks/en-CDexnk0p.js → en-CW71OK66.js} +130 -13
  237. package/dist/en-DwV15ltA.js +1 -0
  238. package/dist/{cdn/chunks/es-BE42B6uN.js → es-DdK7zQfi.js} +130 -13
  239. package/dist/{extensions-zwsZlWjH.js → extensions-CdyweA50.js} +57 -57
  240. package/dist/{eye-B1bua-ck.js → eye-DWkSvYpj.js} +1 -1
  241. package/dist/{cdn/chunks/fr-DlJFPDQR.js → fr-Dz5Bgb7-.js} +130 -13
  242. package/dist/image-DesWjcZ4.js +28 -0
  243. package/dist/index.d.ts +361 -24
  244. package/dist/{info-x26nGOo2.js → info-ClWJGoZy.js} +1 -1
  245. package/dist/{cdn/chunks/ja-CUT8gkNI.js → ja-Di-zJiT8.js} +130 -13
  246. package/dist/keys-Zd9KWRD1.js +10 -0
  247. package/dist/{link-CezhndyR.js → link-BqRicFTA.js} +1 -1
  248. package/dist/{list-DQqdptI0.js → list-bojQr9bn.js} +1 -1
  249. package/dist/{loader-circle-DCEeoYoi.js → loader-circle-B2B8LbUu.js} +1 -1
  250. package/dist/{cdn/chunks/logger-ByvdoAwq.js → logger-k9Nbj3Cp.js} +5 -3
  251. package/dist/{message-circle-BLGzfv_7.js → message-circle-BEuiNsyZ.js} +1 -1
  252. package/dist/{cdn/chunks/nl-bXWqqRyS.js → nl-CvVuHYFL.js} +130 -13
  253. package/dist/normalizeMergeTagMarkup-P6SUBuPv.js +197 -0
  254. package/dist/{package-D_kEQCMU.js → package-DCROB4aM.js} +1 -1
  255. package/dist/{pencil-Dct8zGLy.js → pencil-CEotCKbf.js} +1 -1
  256. package/dist/{preRenderCustomBlocks-CtKJecE-.js → preRenderCustomBlocks-D8rr61_z.js} +4 -4
  257. package/dist/pt-BR-CHM-ZKvE.js +20 -0
  258. package/dist/{cdn/chunks/pt-BR-2_H4-wlb.js → pt-BR-ZhO4vgyq.js} +130 -13
  259. package/dist/{refresh-cw-tGMRDxr8.js → refresh-cw-C6M2mHNC.js} +12 -2
  260. package/dist/{runtime-dom.esm-bundler-DYn1z2Xf.js → runtime-dom.esm-bundler-B8WCZWUm.js} +134 -134
  261. package/dist/sanitizeRichTextHtml-DeISfLFr.js +60 -0
  262. package/dist/{search-Bm2cCQpe.js → search-Cy99zPYf.js} +1 -1
  263. package/dist/{send-sVLaKZ7f.js → send-BDLJFsf3.js} +1 -1
  264. package/dist/{smartphone-B2W81p02.js → smartphone-CVvQaNA4.js} +1 -1
  265. package/dist/{cdn/chunks/socialIcons-CkZSYpoG.js → socialIcons-Dd-jRiVe.js} +688 -693
  266. package/dist/{sparkles-a1qkBZ8X.js → sparkles-Ce0Qz0ox.js} +1 -1
  267. package/dist/square-BWlolnXe.js +15 -0
  268. package/dist/style.css +1 -1
  269. package/dist/templatical-editor.js +2114 -1422
  270. package/dist/{text-align-start-CTuwQ5YW.js → text-align-start-D1V5gPTy.js} +1 -1
  271. package/dist/{trash-I3D2peFQ.js → trash-CZfiUFmw.js} +1 -1
  272. package/dist/{triangle-alert-CenxmLRE.js → triangle-alert-CFDzyFC7.js} +1 -1
  273. package/dist/upload-BJfvdIrD.js +36 -0
  274. package/dist/{useCloudI18n-CGVEZV3o.js → useCloudI18n-Dcjua65H.js} +5 -5
  275. package/dist/{useEditorCore-DRbMRe8F.js → useEditorCore-BTLeAVlM.js} +1463 -1499
  276. package/dist/{useEditorRoot-BVm2-1N8.js → useEditorRoot-DUy67lJu.js} +2 -2
  277. package/dist/{useI18n-CSh4gO5c.js → useI18n-BdoY7xDE.js} +4 -4
  278. package/dist/{useLogicTag-zcI6BWIf.js → useLogicTag-DKLZ1T9H.js} +3 -3
  279. package/dist/{useMergeTag-C-iBLlp0.js → useMergeTag-Bhdx7AKk.js} +3 -3
  280. package/dist/{usePopoverPosition-CMcsMBtK.js → usePopoverPosition-BZea45XK.js} +2 -2
  281. package/dist/useScrollToBlock-FmNMALM_.js +74 -0
  282. package/dist/{vue.runtime.esm-bundler-DV0Wx4r_.js → vue.runtime.esm-bundler-DgFJ6GPG.js} +1428 -1332
  283. package/dist/{withCurrentFont-D62njRLu.js → withCurrentFont-BATJHNve.js} +1 -1
  284. package/dist/{x-KFQ4S-Kz.js → x-CZ0Js0hA.js} +1 -1
  285. package/package.json +14 -12
  286. package/dist/AiChatSidebar-CdjTb9ej.js +0 -230
  287. package/dist/AiFeatureMenu-DKm7VYCs.js +0 -57
  288. package/dist/CloudHeaderExtras-CI8RR9hG.js +0 -55
  289. package/dist/CommentsSidebar-J65znlrH.js +0 -500
  290. package/dist/DesignReferenceSidebar-BTwCFgz8.js +0 -279
  291. package/dist/IssuesPanel-DeeVsfG7.js +0 -117
  292. package/dist/ParagraphEditor-zLV44z-R.js +0 -797
  293. package/dist/SavedBlocksBrowserModal-B8DCFW7t.js +0 -360
  294. package/dist/TemplateScoringPanel-Ba9sgvjS.js +0 -273
  295. package/dist/TemplateSettings-Cu5X9DgA.js +0 -246
  296. package/dist/ToggleSwitch-DHweVJOr.js +0 -102
  297. package/dist/WrapperBlock-DiiaxpMb.js +0 -45
  298. package/dist/cdn/chunks/AiChatSidebar-yXJ85Zcg.js +0 -205
  299. package/dist/cdn/chunks/AiChatSidebar-yXJ85Zcg.js.map +0 -1
  300. package/dist/cdn/chunks/AiFeatureMenu-4ydjrhsQ.js +0 -57
  301. package/dist/cdn/chunks/AiFeatureMenu-4ydjrhsQ.js.map +0 -1
  302. package/dist/cdn/chunks/CloudHeaderExtras-DEkRww7n.js +0 -56
  303. package/dist/cdn/chunks/CloudHeaderExtras-DEkRww7n.js.map +0 -1
  304. package/dist/cdn/chunks/CloudPanels-XufhBZYF.js.map +0 -1
  305. package/dist/cdn/chunks/CollaborationNotices-CBvKEj1Q.js.map +0 -1
  306. package/dist/cdn/chunks/CommentsPanel-R8YLLO3v.js +0 -20
  307. package/dist/cdn/chunks/CommentsSidebar-96NZHVq3.js +0 -470
  308. package/dist/cdn/chunks/DesignReferenceSidebar-D14IIu_P.js +0 -229
  309. package/dist/cdn/chunks/DesignReferenceSidebar-D14IIu_P.js.map +0 -1
  310. package/dist/cdn/chunks/IssuesPanel-BoPiCLGc.js +0 -100
  311. package/dist/cdn/chunks/IssuesPanel-BoPiCLGc.js.map +0 -1
  312. package/dist/cdn/chunks/LogicTagInsertButton-BJ2t2vxC.js.map +0 -1
  313. package/dist/cdn/chunks/MediaEditModal-DD0SZ-S3.js.map +0 -1
  314. package/dist/cdn/chunks/MediaPanels-CkdJ_kGp.js +0 -45
  315. package/dist/cdn/chunks/ParagraphEditor-CJQjRHXV.js +0 -632
  316. package/dist/cdn/chunks/ParagraphEditor-CJQjRHXV.js.map +0 -1
  317. package/dist/cdn/chunks/SavedBlocksPanels-s_gxi1im.js +0 -38
  318. package/dist/cdn/chunks/TemplateScoringPanel-BBPnHILC.js +0 -237
  319. package/dist/cdn/chunks/TemplateScoringPanel-BBPnHILC.js.map +0 -1
  320. package/dist/cdn/chunks/TemplateSettings-CtrzzQWl.js +0 -208
  321. package/dist/cdn/chunks/TestEmailPanel-DERaCdpG.js +0 -35
  322. package/dist/cdn/chunks/TitleEditor-CEgxjtUX.js +0 -199
  323. package/dist/cdn/chunks/ToggleSwitch-DGQ7iRc-.js +0 -104
  324. package/dist/cdn/chunks/ToggleSwitch-DGQ7iRc-.js.map +0 -1
  325. package/dist/cdn/chunks/VersionHistoryPanels-DVOV8QLv.js +0 -48
  326. package/dist/cdn/chunks/WrapperBlock-CFuP4R0c.js +0 -47
  327. package/dist/cdn/chunks/blockTypeIcons-BnAd8qsP.js +0 -22
  328. package/dist/cdn/chunks/ca-DSJwJ5ov.js.map +0 -1
  329. package/dist/cdn/chunks/cloud-CI_fgDyy.js.map +0 -1
  330. package/dist/cdn/chunks/createCloudRuntime-DiYCJ21w.js +0 -358
  331. package/dist/cdn/chunks/createCloudRuntime-DiYCJ21w.js.map +0 -1
  332. package/dist/cdn/chunks/de-CBE6O79z.js.map +0 -1
  333. package/dist/cdn/chunks/de-D_atmUVB.js +0 -89
  334. package/dist/cdn/chunks/de-D_atmUVB.js.map +0 -1
  335. package/dist/cdn/chunks/draggable-akeQH_JP.js.map +0 -1
  336. package/dist/cdn/chunks/en-CDexnk0p.js.map +0 -1
  337. package/dist/cdn/chunks/en-DhJLnaBx.js +0 -89
  338. package/dist/cdn/chunks/en-DhJLnaBx.js.map +0 -1
  339. package/dist/cdn/chunks/en-Ve-PWSXu.js +0 -1
  340. package/dist/cdn/chunks/es-BE42B6uN.js.map +0 -1
  341. package/dist/cdn/chunks/fr-DlJFPDQR.js.map +0 -1
  342. package/dist/cdn/chunks/icons-CjlNV8xD.js.map +0 -1
  343. package/dist/cdn/chunks/ja-CUT8gkNI.js.map +0 -1
  344. package/dist/cdn/chunks/keys-UAWhQ3zW.js +0 -12
  345. package/dist/cdn/chunks/keys-UAWhQ3zW.js.map +0 -1
  346. package/dist/cdn/chunks/logger-ByvdoAwq.js.map +0 -1
  347. package/dist/cdn/chunks/pt-BR-2_H4-wlb.js.map +0 -1
  348. package/dist/cdn/chunks/pt-BR-BphMoUTw.js +0 -89
  349. package/dist/cdn/chunks/pt-BR-BphMoUTw.js.map +0 -1
  350. package/dist/cdn/chunks/socialIcons-CkZSYpoG.js.map +0 -1
  351. package/dist/cdn/chunks/src-B1e5SSYP.js +0 -1272
  352. package/dist/cdn/chunks/src-B1e5SSYP.js.map +0 -1
  353. package/dist/cdn/chunks/src-CvLTYGdO.js.map +0 -1
  354. package/dist/cdn/chunks/timeouts-o5Y9BuqI.js +0 -6
  355. package/dist/cdn/chunks/timeouts-o5Y9BuqI.js.map +0 -1
  356. package/dist/cdn/chunks/useAliveFlag-PuXh83UK.js +0 -12
  357. package/dist/cdn/chunks/useAliveFlag-PuXh83UK.js.map +0 -1
  358. package/dist/cdn/chunks/useEditorCore-DpCFvHg_.js +0 -2623
  359. package/dist/cdn/chunks/useEditorCore-DpCFvHg_.js.map +0 -1
  360. package/dist/cdn/chunks/useEditorRoot-5SBqm90x.js +0 -10
  361. package/dist/cdn/chunks/useScrollToBlock-MNzurEZV.js +0 -21
  362. package/dist/cdn/chunks/useScrollToBlock-MNzurEZV.js.map +0 -1
  363. package/dist/copy-CUC43md_.js +0 -19
  364. package/dist/createCloudRuntime-BMDRjL0k.js +0 -356
  365. package/dist/de-D_atmUVB.js +0 -87
  366. package/dist/dist-CCqn-RqE.js +0 -407
  367. package/dist/en-BHCMzqib.js +0 -1
  368. package/dist/en-DhJLnaBx.js +0 -87
  369. package/dist/image-up-BqiO7KCO.js +0 -27
  370. package/dist/keys-BymCnLHD.js +0 -10
  371. package/dist/plus-BDd0gTEm.js +0 -14
  372. package/dist/pt-BR-BphMoUTw.js +0 -87
  373. package/dist/shield-check-YhsbXfQc.js +0 -14
  374. package/dist/socialIcons-Bwv-49EB.js +0 -2167
  375. package/dist/timeouts-o5Y9BuqI.js +0 -4
  376. package/dist/upload-uU2cK0Ce.js +0 -21
  377. package/dist/useAliveFlag-BjP0Gxza.js +0 -10
  378. package/dist/useScrollToBlock-CdCQK9QQ.js +0 -47
@@ -1,2167 +0,0 @@
1
- import { $ as e, A as t, At as n, H as r, J as i, R as a, S as o, W as s, X as c, Y as l, Z as u, at as d, d as f, g as p, h as m, jt as h, kt as g, ot as _, r as v, rt as y, s as b, v as x } from "./vue.runtime.esm-bundler-DV0Wx4r_.js";
2
- import { B as S, E as C, G as w, K as T, S as E, St as D, _ as O, b as k, c as A, d as j, f as M, ft as N, g as ee, gt as P, h as F, it as I, m as L, ot as R, u as te, v as z, y as ne } from "./dist-DBG3nh3k.js";
3
- import { r as B } from "./dist-CCqn-RqE.js";
4
- import { L as V, P as H, c as re, x as ie } from "./keys-BymCnLHD.js";
5
- import { n as U } from "./timeouts-o5Y9BuqI.js";
6
- import { t as ae } from "./useI18n-CSh4gO5c.js";
7
- import { o as oe, s as W } from "./usePopoverPosition-CMcsMBtK.js";
8
- import { t as G } from "./createLucideIcon-BcP1sjdp.js";
9
- import { t as se } from "./loader-circle-DCEeoYoi.js";
10
- import { t as ce } from "./upload-uU2cK0Ce.js";
11
- import { t as le } from "./useAliveFlag-BjP0Gxza.js";
12
- //#region ../core/dist/index.js
13
- function ue(e) {
14
- return e instanceof Error ? e : Error(String(e), { cause: e });
15
- }
16
- function K(e, t) {
17
- try {
18
- t();
19
- } catch (t) {
20
- e?.(ue(t));
21
- }
22
- }
23
- function de(e) {
24
- let t = e.content ?? C(e.defaultFontFamily, e.templateDefaults);
25
- O(t), z(t);
26
- let n = l({
27
- template: null,
28
- content: t,
29
- selectedBlockId: null,
30
- viewport: "desktop",
31
- darkMode: !1,
32
- previewMode: !1,
33
- isDirty: !1,
34
- isSaving: !1,
35
- isLoading: !1,
36
- uiTheme: "auto"
37
- }), i = 0;
38
- function a() {
39
- n.isDirty = !0, i++;
40
- }
41
- let o = r({
42
- get: () => n.content,
43
- set: (e) => {
44
- n.content = e, a();
45
- }
46
- }), s = r(() => n.selectedBlockId ? u(n.content.blocks, n.selectedBlockId) : null);
47
- function u(e, t) {
48
- for (let n of e) {
49
- if (n.id === t) return n;
50
- if (n.type === "section") for (let e of n.children) {
51
- let n = u(e, t);
52
- if (n) return n;
53
- }
54
- }
55
- return null;
56
- }
57
- function d(e, t) {
58
- if (t.add(e.id), e.type === "section") for (let n of e.children) for (let e of n) d(e, t);
59
- }
60
- function f(e, t, n = { blocks: e }) {
61
- for (let r = 0; r < e.length; r++) {
62
- let i = e[r];
63
- if (i.id === t) return n;
64
- if (i.type === "section") for (let e = 0; e < i.children.length; e++) {
65
- let n = f(i.children[e], t, {
66
- blocks: i.children[e],
67
- sectionId: i.id,
68
- columnIndex: e
69
- });
70
- if (n) return n;
71
- }
72
- }
73
- return null;
74
- }
75
- function p(t) {
76
- return e.lockedBlocks?.value.has(t) ?? !1;
77
- }
78
- function m(e) {
79
- let t = f(n.content.blocks, e);
80
- if (!t) return null;
81
- let r = t.blocks.findIndex((t) => t.id === e);
82
- return r === -1 ? null : {
83
- targetSectionId: t.sectionId,
84
- columnIndex: t.columnIndex,
85
- index: r
86
- };
87
- }
88
- function h(e, t = !0) {
89
- O(e), z(e), n.content = e, t && a();
90
- }
91
- function g(e) {
92
- e && p(e) || (n.selectedBlockId = e);
93
- }
94
- function _(e) {
95
- n.viewport = e;
96
- }
97
- function v(e) {
98
- n.darkMode = e;
99
- }
100
- function y(e) {
101
- n.uiTheme = e;
102
- }
103
- function b(e) {
104
- n.previewMode = e, e && (n.selectedBlockId = null);
105
- }
106
- function x(e, t) {
107
- if (p(e)) return;
108
- let r = u(n.content.blocks, e);
109
- r && (Object.assign(r, t), a());
110
- }
111
- function S(e) {
112
- n.content.settings = {
113
- ...n.content.settings,
114
- ...e
115
- }, a();
116
- }
117
- function w(e, t, r = 0, i) {
118
- let o = {
119
- settings: n.content.settings,
120
- blocks: [e]
121
- };
122
- if (O(o), z(o), !(t && e.type === "section")) {
123
- if (t) {
124
- if (p(t)) return;
125
- let a = u(n.content.blocks, t);
126
- if (a && a.type === "section") {
127
- if (r < 0 || r >= T(a.columns)) return;
128
- a.children[r] = a.children[r] || [];
129
- let t = a.children[r];
130
- i !== void 0 && i < t.length ? t.splice(i, 0, e) : t.push(e);
131
- }
132
- } else i !== void 0 && i < n.content.blocks.length ? n.content.blocks.splice(i, 0, e) : n.content.blocks.push(e);
133
- a();
134
- }
135
- }
136
- function E(e) {
137
- if (p(e)) return;
138
- let t = f(n.content.blocks, e);
139
- if (t) {
140
- let r = t.blocks.findIndex((t) => t.id === e);
141
- if (r !== -1) {
142
- let [e] = t.blocks.splice(r, 1);
143
- if (n.selectedBlockId) {
144
- let t = /* @__PURE__ */ new Set();
145
- d(e, t), t.has(n.selectedBlockId) && (n.selectedBlockId = null);
146
- }
147
- a();
148
- }
149
- }
150
- }
151
- function D(e, t, r, i = 0) {
152
- if (p(e) || r && p(r)) return;
153
- let o = f(n.content.blocks, e);
154
- if (!o) return;
155
- let s = o.blocks.findIndex((t) => t.id === e);
156
- if (s === -1 || r && o.blocks[s].type === "section") return;
157
- let c;
158
- if (r) {
159
- let e = u(n.content.blocks, r);
160
- if (!e || e.type !== "section" || i < 0 || i >= T(e.columns)) return;
161
- e.children[i] = e.children[i] || [], c = e.children[i];
162
- } else c = n.content.blocks;
163
- let [l] = o.blocks.splice(s, 1);
164
- c.splice(t, 0, l), a();
165
- }
166
- function k() {
167
- a();
168
- }
169
- function A(e, t) {
170
- throw new M(`[Templatical] Templates: ${e} ${t}`);
171
- }
172
- function j(t) {
173
- K(e.onError, t);
174
- }
175
- function N(t) {
176
- let { templates: n } = e;
177
- return n || A(t, "needs a templates provider. Pass one as `init({ templates })` to enable saving and loading."), n;
178
- }
179
- function ee(e) {
180
- n.template && (n.template = {
181
- ...n.template,
182
- name: e
183
- }, a());
184
- }
185
- async function P(t) {
186
- let r = N("create()"), { create: a } = r;
187
- typeof a != "function" && A("create()", "is disabled by the provider — its `create` is `false`.");
188
- let o;
189
- n.isLoading = !0;
190
- try {
191
- t?.content && (n.content = t.content);
192
- let e = i;
193
- o = await a(t?.name === void 0 ? { content: n.content } : {
194
- name: t.name,
195
- content: n.content
196
- }), n.template = o, i === e && (n.isDirty = !1);
197
- } catch (t) {
198
- throw e.onError?.(t), t;
199
- } finally {
200
- n.isLoading = !1;
201
- }
202
- return j(() => r.onCreated?.(o)), o;
203
- }
204
- async function F(t) {
205
- let r = N("load()"), i;
206
- n.isLoading = !0;
207
- try {
208
- i = await r.load(t), O(i.content), z(i.content), n.template = i, n.content = i.content, n.isDirty = !1;
209
- } catch (t) {
210
- throw e.onError?.(t), t;
211
- } finally {
212
- n.isLoading = !1;
213
- }
214
- return j(() => r.onLoaded?.(i)), i;
215
- }
216
- async function I(t = "api") {
217
- let r = N("save()"), { save: a } = r;
218
- typeof a != "function" && A("save()", "is disabled by the provider — its `save` is `false`.");
219
- let o = n.template;
220
- o || A("save()", "has no template loaded. Call create() or load() first.");
221
- let s = o.name === void 0 ? { content: n.content } : {
222
- name: o.name,
223
- content: n.content
224
- }, c;
225
- n.isSaving = !0;
226
- try {
227
- let e = i;
228
- if (c = await a(o.id, s), n.template?.id === o.id) {
229
- let e = n.template.name;
230
- n.template = e === o.name ? c : {
231
- ...c,
232
- name: e
233
- };
234
- }
235
- i === e && (n.isDirty = !1);
236
- } catch (t) {
237
- throw e.onError?.(t), t;
238
- } finally {
239
- n.isSaving = !1;
240
- }
241
- return j(() => r.onSaved?.(c, { trigger: t })), c;
242
- }
243
- function L() {
244
- return n.template?.id !== void 0;
245
- }
246
- return {
247
- state: c(n),
248
- content: o,
249
- selectedBlock: s,
250
- isBlockLocked: p,
251
- setContent: h,
252
- selectBlock: g,
253
- setViewport: _,
254
- setDarkMode: v,
255
- setUiTheme: y,
256
- setPreviewMode: b,
257
- updateBlock: x,
258
- updateSettings: S,
259
- addBlock: w,
260
- removeBlock: E,
261
- moveBlock: D,
262
- markDirty: k,
263
- findBlockLocation: m,
264
- setName: ee,
265
- create: P,
266
- load: F,
267
- save: I,
268
- hasTemplate: L
269
- };
270
- }
271
- var q = 50, fe = 300, pe = 1500;
272
- function J(e) {
273
- let { content: t, setContent: n, maxSize: i = q } = e, a = u([]), o = u([]), s = u(!1), c = null, l = null, d = r(() => a.value.length > 0), f = r(() => o.value.length > 0);
274
- function p() {
275
- return P(t.value);
276
- }
277
- function m(e) {
278
- a.value.push(e), a.value.length > i && a.value.splice(0, a.value.length - i);
279
- }
280
- function h() {
281
- l &&= (clearTimeout(l.timeoutId), null);
282
- }
283
- function g() {
284
- h(), m(p()), o.value = [];
285
- }
286
- function _(e) {
287
- l && l.blockId === e ? (clearTimeout(l.timeoutId), l.timeoutId = setTimeout(() => {
288
- l = null;
289
- }, fe)) : (h(), m(p()), o.value = [], l = {
290
- blockId: e,
291
- timeoutId: setTimeout(() => {
292
- l = null;
293
- }, fe)
294
- });
295
- }
296
- function v() {
297
- s.value = !0, c && clearTimeout(c), c = setTimeout(() => {
298
- s.value = !1, c = null;
299
- }, pe);
300
- }
301
- function y() {
302
- if (a.value.length === 0) return;
303
- h();
304
- let e = a.value.pop();
305
- o.value.push(p()), 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(p()), 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: d,
321
- canRedo: f,
322
- isNavigating: s,
323
- undo: y,
324
- redo: b,
325
- record: g,
326
- recordDebounced: _,
327
- clear: x,
328
- destroy: S
329
- };
330
- }
331
- function me(e) {
332
- let { addBlock: t, removeBlock: n, updateBlock: r, selectBlock: i, findBlockLocation: a } = e;
333
- function o(n, r, a) {
334
- let o = typeof e.blockDefaults == "function" ? e.blockDefaults() : e.blockDefaults, s = E(n, o);
335
- return t(s, r, a), i(s.id), s;
336
- }
337
- function s(e, n, r) {
338
- let o = ne(e);
339
- if (n !== void 0 || r !== void 0) t(o, n, r);
340
- else {
341
- let i = a?.(e.id) ?? null;
342
- i ? t(o, i.targetSectionId, i.columnIndex, i.index + 1) : t(o, n, r);
343
- }
344
- return i(o.id), o;
345
- }
346
- function c(e) {
347
- n(e);
348
- }
349
- function l(e, t, n) {
350
- r(e, { [t]: n });
351
- }
352
- return {
353
- createAndAddBlock: o,
354
- duplicateBlock: s,
355
- deleteBlock: c,
356
- updateBlockProperty: l
357
- };
358
- }
359
- var he = 2e3;
360
- function ge(e) {
361
- let { content: t, isDirty: n, onChange: r, debounce: i = he, enabled: a = !0 } = e, o = null, s = !1;
362
- function c() {
363
- return typeof a == "function" ? a() : a;
364
- }
365
- function l() {
366
- s = !0, d();
367
- }
368
- function u() {
369
- s = !1;
370
- }
371
- function d() {
372
- o &&= (clearTimeout(o), null);
373
- }
374
- function f() {
375
- d(), n() && r(JSON.parse(JSON.stringify(t.value)));
376
- }
377
- function p() {
378
- c() && !s && (d(), o = setTimeout(() => {
379
- o = null, c() && !s && n() && r(JSON.parse(JSON.stringify(t.value)));
380
- }, i));
381
- }
382
- let m = _(t, () => {
383
- p();
384
- }, { deep: !0 });
385
- function h() {
386
- m(), d();
387
- }
388
- return {
389
- flush: f,
390
- cancel: d,
391
- pause: l,
392
- resume: u,
393
- destroy: h
394
- };
395
- }
396
- function _e(e) {
397
- let t = l(/* @__PURE__ */ new Set()), n = r(() => t.size > 0);
398
- function i(e) {
399
- return t.has(e);
400
- }
401
- function a(n) {
402
- t.has(n) ? t.delete(n) : (t.add(n), e.state.selectedBlockId === n && e.selectBlock(null));
403
- }
404
- function o() {
405
- t.clear();
406
- }
407
- return {
408
- isHidden: i,
409
- toggleBlock: a,
410
- reset: o,
411
- hasHiddenBlocks: n
412
- };
413
- }
414
- function ve(e) {
415
- let t = u(!1), n = u(!1), i = r(() => !!e.definition.value?.dataSource), a = r(() => i.value && !e.block.value.dataSourceFetched);
416
- async function o() {
417
- let r = e.definition.value;
418
- if (r?.dataSource) {
419
- t.value = !0, n.value = !1;
420
- try {
421
- let t = await r.dataSource.onFetch({
422
- fieldValues: { ...e.block.value.fieldValues },
423
- blockId: e.block.value.id
424
- });
425
- if (t == null) return;
426
- let n = { ...e.block.value.fieldValues };
427
- for (let e of Object.keys(n)) e in t && (n[e] = t[e]);
428
- e.onUpdate(n, !0);
429
- } catch (e) {
430
- console.warn("[Templatical] Data source fetch error:", e), n.value = !0;
431
- } finally {
432
- t.value = !1;
433
- }
434
- }
435
- }
436
- return {
437
- isFetching: t,
438
- fetchError: n,
439
- fetch: o,
440
- hasDataSource: i,
441
- needsFetch: a
442
- };
443
- }
444
- function ye(e, t) {
445
- let n = e.addBlock, r = e.removeBlock, i = e.moveBlock, a = e.updateBlock, o = e.updateSettings;
446
- e.addBlock = (r, i, a, o) => {
447
- i && e.isBlockLocked(i) || (t.record(), n(r, i, a, o));
448
- }, e.removeBlock = (n) => {
449
- e.isBlockLocked(n) || (t.record(), r(n));
450
- }, e.moveBlock = (n, r, a, o) => {
451
- e.isBlockLocked(n) || a && e.isBlockLocked(a) || (t.record(), i(n, r, a, o));
452
- }, e.updateBlock = (n, r) => {
453
- e.isBlockLocked(n) || (t.recordDebounced(n), a(n, r));
454
- }, e.updateSettings = (e) => {
455
- t.record(), o(e);
456
- };
457
- }
458
- var be = "root", xe = /* @__PURE__ */ new Set([
459
- "id",
460
- "type",
461
- "children"
462
- ]), Se = /* @__PURE__ */ new Set([
463
- "id",
464
- "type",
465
- "children",
466
- "columns"
467
- ]), Ce = /* @__PURE__ */ new Set();
468
- function we(e) {
469
- return e === null ? be : JSON.stringify([e.sectionId, e.column]);
470
- }
471
- function Y(e) {
472
- let t = e.children;
473
- return e.type === "section" && Array.isArray(t) ? t : [];
474
- }
475
- function X(e) {
476
- let t = /* @__PURE__ */ new Map(), n = (e, r) => {
477
- e.forEach((e, i) => {
478
- t.has(e.id) || t.set(e.id, {
479
- block: e,
480
- key: we(r),
481
- index: i
482
- }), Y(e).forEach((t, r) => {
483
- Array.isArray(t) && n(t, {
484
- sectionId: e.id,
485
- column: r
486
- });
487
- });
488
- });
489
- };
490
- return n(e, null), t;
491
- }
492
- function Te(e) {
493
- let t = [], n = Array(e.length).fill(-1);
494
- e.forEach((r, i) => {
495
- let a = 0, o = t.length;
496
- for (; a < o;) {
497
- let n = a + o >> 1;
498
- e[t[n]] < r ? a = n + 1 : o = n;
499
- }
500
- a > 0 && (n[i] = t[a - 1]), t[a] = i;
501
- });
502
- let r = /* @__PURE__ */ new Set(), i = t.length > 0 ? t[t.length - 1] : -1;
503
- for (; i !== -1;) r.add(i), i = n[i];
504
- return r;
505
- }
506
- function Ee(e, t, n) {
507
- let r = {}, i = [];
508
- for (let i of Object.keys(t)) n.has(i) || t[i] === void 0 || S(e[i], t[i]) || (r[i] = P(t[i]));
509
- for (let r of Object.keys(e)) n.has(r) || e[r] === void 0 || t[r] === void 0 && i.push(r);
510
- return {
511
- set: r,
512
- unset: i
513
- };
514
- }
515
- function De(e, t) {
516
- let n = X(e.blocks), r = X(t.blocks), i = [], a = (e) => {
517
- let t = r.get(e), i = n.get(e);
518
- return t !== void 0 && i !== void 0 && t.block.type !== i.block.type;
519
- }, o = (e) => r.has(e.id) && !a(e.id), s = (e) => Y(e).some((e) => Array.isArray(e) && e.some((e) => o(e) || !a(e.id) && s(e))), c = /* @__PURE__ */ new Set(), l = [], u = (e, t) => {
520
- let n = "kept";
521
- t === "dropped" ? (c.add(e.id), n = "dropped") : a(e.id) ? (i.push({
522
- op: "deleteBlock",
523
- blockId: e.id
524
- }), c.add(e.id), n = "dropped") : r.has(e.id) || (t === "deferred" ? n = "deferred" : s(e) ? (l.push(e.id), n = "deferred") : (i.push({
525
- op: "deleteBlock",
526
- blockId: e.id
527
- }), c.add(e.id), n = "dropped"));
528
- for (let t of Y(e)) if (Array.isArray(t)) for (let e of t) u(e, n);
529
- };
530
- for (let t of e.blocks) u(t, "kept");
531
- let d = (e) => n.has(e) && !c.has(e), f = (e) => {
532
- let t = P(e);
533
- return t.type === "section" && (t.children = Y(e).map((e) => Array.isArray(e) ? e.filter((e) => !d(e.id)).map((e) => P(e)) : e)), t;
534
- }, p = (e, t, r) => {
535
- let a = we(e), o = [], s = [];
536
- t.forEach((e, t) => {
537
- let r = n.get(e.id);
538
- d(e.id) && r !== void 0 && r.key === a && (o.push(r.index), s.push(t));
539
- });
540
- let c = new Set([...Te(o)].map((e) => s[e]));
541
- t.forEach((n, a) => {
542
- if (c.has(a) || r(n)) return;
543
- let o = a > 0 ? t[a - 1].id : null;
544
- i.push(d(n.id) ? {
545
- op: "moveBlock",
546
- blockId: n.id,
547
- parent: e,
548
- after: o
549
- } : {
550
- op: "addBlock",
551
- block: f(n),
552
- parent: e,
553
- after: o
554
- });
555
- });
556
- };
557
- p(null, t.blocks, () => !1);
558
- let m = t.blocks.filter((e) => e.type === "section"), h = /* @__PURE__ */ new Set(), g = (e) => {
559
- for (let t of m) {
560
- if (!d(t.id)) continue;
561
- let r = Y(n.get(t.id).block).length, a = Y(t).length;
562
- (e ? a > r : a < r) && (i.push({
563
- op: "updateBlock",
564
- blockId: t.id,
565
- set: { columns: t.columns }
566
- }), h.add(t.id));
567
- }
568
- };
569
- g(!0);
570
- for (let e of m) {
571
- let t = !d(e.id);
572
- Y(e).forEach((n, r) => {
573
- Array.isArray(n) && p({
574
- sectionId: e.id,
575
- column: r
576
- }, n, (e) => t && !d(e.id));
577
- });
578
- }
579
- g(!1);
580
- for (let e of l) i.push({
581
- op: "deleteBlock",
582
- blockId: e
583
- });
584
- for (let [e, t] of r) {
585
- if (!d(e)) continue;
586
- let { set: r, unset: a } = Ee(n.get(e).block, t.block, h.has(e) ? Se : xe);
587
- (Object.keys(r).length !== 0 || a.length !== 0) && i.push({
588
- op: "updateBlock",
589
- blockId: e,
590
- ...Object.keys(r).length > 0 ? { set: r } : {},
591
- ...a.length > 0 ? { unset: a } : {}
592
- });
593
- }
594
- let _ = Ee(e.settings, t.settings, Ce);
595
- return (Object.keys(_.set).length > 0 || _.unset.length > 0) && i.push({
596
- op: "updateSettings",
597
- ...Object.keys(_.set).length > 0 ? { set: _.set } : {},
598
- ..._.unset.length > 0 ? { unset: _.unset } : {}
599
- }), i;
600
- }
601
- function Oe(e) {
602
- let t = e.children;
603
- return e.type === "section" && Array.isArray(t) ? t : [];
604
- }
605
- function Z(e, t, n = null) {
606
- for (let r = 0; r < e.length; r++) {
607
- let i = e[r];
608
- if (i.id === t) return {
609
- block: i,
610
- parent: n,
611
- after: r > 0 ? e[r - 1].id : null
612
- };
613
- let a = Oe(i);
614
- for (let e = 0; e < a.length; e++) {
615
- if (!Array.isArray(a[e])) continue;
616
- let n = Z(a[e], t, {
617
- sectionId: i.id,
618
- column: e
619
- });
620
- if (n) return n;
621
- }
622
- }
623
- return null;
624
- }
625
- function Q(e, t, n) {
626
- let r = Z(e.blocks, t);
627
- if (!r) throw new A("block_missing", n, `No block with id "${t}".`, t);
628
- return r;
629
- }
630
- function $(e, t, n) {
631
- let r = {}, i = [], a = {}, o = [.../* @__PURE__ */ new Set([...Object.keys(t ?? {}), ...n ?? []])];
632
- for (let n of o) {
633
- let o = e[n];
634
- o === void 0 ? i.push(n) : r[n] = P(o);
635
- let s = t && n in t ? t[n] : void 0;
636
- a[n] = s === void 0 ? null : P(s);
637
- }
638
- return {
639
- set: r,
640
- unset: i,
641
- expect: a
642
- };
643
- }
644
- function ke(e, t, n) {
645
- switch (t.op) {
646
- case "addBlock": return {
647
- op: "deleteBlock",
648
- blockId: t.block.id,
649
- expect: { block: P(t.block) }
650
- };
651
- case "deleteBlock": {
652
- let r = Q(e, t.blockId, n);
653
- return {
654
- op: "addBlock",
655
- block: P(r.block),
656
- parent: r.parent,
657
- after: r.after
658
- };
659
- }
660
- case "moveBlock": {
661
- let r = Q(e, t.blockId, n);
662
- return {
663
- op: "moveBlock",
664
- blockId: t.blockId,
665
- parent: r.parent,
666
- after: r.after,
667
- expect: {
668
- parent: t.parent,
669
- after: t.after
670
- }
671
- };
672
- }
673
- case "updateBlock": {
674
- let r = Q(e, t.blockId, n).block, { set: i, unset: a, expect: o } = $(r, t.set, t.unset);
675
- return {
676
- op: "updateBlock",
677
- blockId: t.blockId,
678
- ...Object.keys(i).length > 0 ? { set: i } : {},
679
- ...a.length > 0 ? { unset: a } : {},
680
- expect: o
681
- };
682
- }
683
- case "updateSettings": {
684
- let { set: n, unset: r, expect: i } = $(e.settings, t.set, t.unset);
685
- return {
686
- op: "updateSettings",
687
- ...Object.keys(n).length > 0 ? { set: n } : {},
688
- ...r.length > 0 ? { unset: r } : {},
689
- expect: i
690
- };
691
- }
692
- case "setContent": return {
693
- op: "setContent",
694
- content: {
695
- blocks: P(e.blocks),
696
- settings: P(e.settings)
697
- }
698
- };
699
- }
700
- }
701
- function Ae(e, t) {
702
- let n = P(e), r = [];
703
- return t.forEach((e, t) => {
704
- r.push(ke(n, e, t));
705
- try {
706
- ee(n, [e]);
707
- } catch (e) {
708
- throw e instanceof A ? new A(e.code, t, e.message, e.blockId) : e;
709
- }
710
- }), r.reverse();
711
- }
712
- var je = 1e3, Me = 1e4, Ne = [
713
- 1e3,
714
- 2e3,
715
- 5e3,
716
- 1e4,
717
- 3e4
718
- ], Pe = 50, Fe = /* @__PURE__ */ new Set([
719
- "block_exists",
720
- "block_missing",
721
- "anchor_missing",
722
- "precondition_failed",
723
- "lock_held",
724
- "locked_by_others",
725
- "invalid_operation",
726
- "lock_lost",
727
- "content_too_large"
728
- ]);
729
- function Ie(e) {
730
- let t = e?.code;
731
- return typeof t == "string" && Fe.has(t) ? t : null;
732
- }
733
- function Le(e) {
734
- let t = e?.holder;
735
- return typeof t == "object" && t && typeof t.sessionId == "string" ? t : void 0;
736
- }
737
- function Re(e) {
738
- let t = e?.statusCode;
739
- return typeof t != "number" || t >= 500 || t === 408 || t === 429;
740
- }
741
- function ze(e, t) {
742
- return e.some((e) => {
743
- if (e.id === t) return !0;
744
- let n = e.children;
745
- return e.type === "section" && Array.isArray(n) && n.some((e) => Array.isArray(e) && ze(e, t));
746
- });
747
- }
748
- function Be(e) {
749
- if (e.length === 1 && e[0].op === "updateSettings") return !0;
750
- let t = e[0];
751
- return t.op === "updateBlock" && e.every((e) => e.op === "updateBlock" && e.blockId === t.blockId);
752
- }
753
- function Ve(e) {
754
- return e.map((e) => {
755
- if (!("expect" in e)) return e;
756
- let { expect: t, ...n } = e;
757
- return n;
758
- });
759
- }
760
- function He(t) {
761
- let { provider: n } = t, a = t.sessionId ?? crypto.randomUUID(), o = t.maxUndo ?? Pe, c = typeof n.acquireLock == "function" && typeof n.renewLock == "function" && typeof n.releaseLock == "function", l = e([]), d = e(/* @__PURE__ */ new Map()), f = u(null), p = u(0), m = u(0), h = null, g = null, v = !1, y = !1, b = !1, x = null, C = 0, w = !1, T = [], E = null, D = null, O = Promise.resolve(), k = null, j = r(() => (m.value, (g?.undo.length ?? 0) > 0)), M = r(() => (m.value, (g?.redo.length ?? 0) > 0));
762
- function N(e) {
763
- t.onError?.(e instanceof Error ? e : Error(String(e)));
764
- }
765
- function I(e, n = g) {
766
- n !== g || w || t.onNotice?.(e);
767
- }
768
- function L() {
769
- return {
770
- locks: [...d.value.values()].map((e) => ({
771
- blockId: e.blockId,
772
- sessionId: e.holder.sessionId
773
- })),
774
- session: a
775
- };
776
- }
777
- function R() {
778
- m.value++;
779
- }
780
- function te(e, t) {
781
- e.push(t), e.length > o && e.splice(0, e.length - o);
782
- }
783
- function z(e) {
784
- if (!h || v) return;
785
- y = !0;
786
- try {
787
- let t = h.content.value, n = De(t, e);
788
- if (n.length > 0) try {
789
- ee(t, n);
790
- } catch {
791
- h.setContent(P(e), !1);
792
- }
793
- S(h.content.value, e) || h.setContent(P(e), !1);
794
- } finally {
795
- y = !1;
796
- }
797
- let t = h.state.selectedBlockId;
798
- t && !ze(e.blocks, t) && h.selectBlock(null);
799
- }
800
- function ne() {
801
- y || b || (b = !0, queueMicrotask(() => {
802
- b = !1, V(!1);
803
- }));
804
- }
805
- function B() {
806
- x &&= (clearTimeout(x), null);
807
- }
808
- function V(e, t = !1) {
809
- let n = g;
810
- if (!h || !n || v || y || h.state.isLoading && !t || h.state.template?.id !== n.templateId) return;
811
- let r = De(n.view, h.content.value);
812
- if (r.length === 0) B();
813
- else {
814
- if (!e && Be(r)) {
815
- let e = Date.now();
816
- if (x === null && (C = e), e - C < 1e3) {
817
- x && clearTimeout(x), x = setTimeout(() => {
818
- x = null, V(!0);
819
- }, 300);
820
- return;
821
- }
822
- }
823
- B(), re(n, r);
824
- }
825
- }
826
- function H() {
827
- V(!0);
828
- }
829
- function re(e, t) {
830
- let n = t, r;
831
- try {
832
- r = F(e.view, n, L());
833
- } catch (t) {
834
- if (!(t instanceof A)) throw t;
835
- z(e.view);
836
- let n = t.blockId === void 0 ? void 0 : d.value.get(t.blockId)?.holder;
837
- I({
838
- type: "editRefused",
839
- code: t.code,
840
- ...n ? { holder: n } : {}
841
- }), t.code === "invalid_operation" && N(t);
842
- return;
843
- }
844
- let i = h.content.value;
845
- if (!S(r, i)) {
846
- N(/* @__PURE__ */ Error("[Templatical] Collaboration: a change couldn't be expressed as block operations, so the whole content was sent.")), n = [{
847
- op: "setContent",
848
- content: P(i)
849
- }];
850
- try {
851
- r = F(e.view, n, L());
852
- } catch (t) {
853
- if (!(t instanceof A)) throw t;
854
- z(e.view), I({
855
- type: "editRefused",
856
- code: t.code
857
- });
858
- return;
859
- }
860
- }
861
- let a = { ops: Ae(e.view, n) };
862
- te(e.undo, a), e.redo = [], R(), e.view = r, ie(e, n, "edit", a);
863
- }
864
- function ie(e, t, n, r) {
865
- e.pending.push({
866
- batchId: crypto.randomUUID(),
867
- ops: t,
868
- origin: n,
869
- entry: r,
870
- sent: !1,
871
- revision: null
872
- }), U(e);
873
- }
874
- function U(e) {
875
- if (e.inFlight) return;
876
- let t = e.pending.find((e) => !e.sent);
877
- t ? (t.sent = !0, e.inFlight = t, ae(e, t, 0)) : ce(e);
878
- }
879
- function ae(e, t, r) {
880
- n.submit(e.templateId, {
881
- batchId: t.batchId,
882
- baseRevision: e.revision,
883
- ops: t.ops
884
- }).then(({ revision: n }) => {
885
- e.inFlight = null, oe(e, t, n), U(e);
886
- }, (n) => {
887
- if (Ie(n) !== null) e.inFlight = null, se(e, t, n), U(e);
888
- else if (Re(n)) {
889
- le(e, n);
890
- let i = Ne[Math.min(r, Ne.length - 1)];
891
- setTimeout(() => {
892
- w || ae(e, t, r + 1);
893
- }, i);
894
- } else e.inFlight = null, N(n), se(e, t, n), U(e);
895
- });
896
- }
897
- function oe(e, t, n) {
898
- t.revision === null && (t.revision = n, n <= e.revision ? (W(e, t), q(e)) : (e.own.set(n, t), de(e)));
899
- }
900
- function W(e, t) {
901
- e.pending = e.pending.filter((e) => e !== t), ce(e);
902
- }
903
- function G(e, t) {
904
- if (t.entry) {
905
- for (let n of [e.undo, e.redo]) {
906
- let e = n.indexOf(t.entry);
907
- e !== -1 && n.splice(e, 1);
908
- }
909
- R();
910
- }
911
- }
912
- function se(e, t, n) {
913
- W(e, t), G(e, t);
914
- let r = Ie(n) ?? "invalid_operation";
915
- if (t.origin === "edit") {
916
- let t = Le(n);
917
- I({
918
- type: "editRefused",
919
- code: r,
920
- ...t ? { holder: t } : {}
921
- }, e);
922
- } else I({
923
- type: "undoSkipped",
924
- code: r
925
- }, e);
926
- q(e), e === g && J();
927
- }
928
- function ce(e) {
929
- if (!(e.pending.length > 0 || e.waiters.length === 0)) for (let t of e.waiters.splice(0)) t.resolve();
930
- }
931
- function le(e, t) {
932
- let n = t instanceof Error ? t : Error(String(t));
933
- for (let t of e.waiters.splice(0)) t.reject(n);
934
- }
935
- function ue(e, t) {
936
- if (t.revision <= e.revision) return;
937
- let n = e.pending.find((e) => e.batchId === t.batchId);
938
- n ? oe(e, n, t.revision) : (e.remote.set(t.revision, t), de(e));
939
- }
940
- function K(e, n) {
941
- let r = n.ops;
942
- if (t.normalizeRemoteOperations) try {
943
- r = t.normalizeRemoteOperations(n.ops, e.confirmed);
944
- } catch (e) {
945
- N(e);
946
- }
947
- return Ve(r);
948
- }
949
- function de(e) {
950
- let n = [];
951
- for (;;) {
952
- let t = e.revision + 1, r = e.remote.get(t), i = e.own.get(t);
953
- if (!r && !i) break;
954
- try {
955
- e.confirmed = F(e.confirmed, r ? K(e, r) : i.ops);
956
- } catch {
957
- if (e.recovering) {
958
- e.remote.clear(), e.own.clear(), N(/* @__PURE__ */ Error("[Templatical] Collaboration: this editor can't follow the template's changes. Reload the page."));
959
- return;
960
- }
961
- me(e);
962
- return;
963
- }
964
- e.revision = t, r ? (e.remote.delete(t), n.push(r)) : (e.own.delete(t), W(e, i));
965
- }
966
- if (e === g && (p.value = e.revision), e.remote.size > 0 || e.own.size > 0 ? fe(e) : pe(e), n.length !== 0 && (q(e), e === g)) for (let e of n) try {
967
- t.onRemoteChange?.({
968
- actor: e.actor,
969
- ops: e.ops
970
- });
971
- } catch (e) {
972
- N(e);
973
- }
974
- }
975
- function q(e) {
976
- e === g && H();
977
- let t = e.confirmed, n = [];
978
- for (let r of e.pending) try {
979
- t = F(t, r.ops), n.push(r);
980
- } catch (t) {
981
- if (r.sent) {
982
- n.push(r);
983
- continue;
984
- }
985
- G(e, r);
986
- let i = t instanceof A ? t.code : "invalid_operation";
987
- I(r.origin === "edit" ? {
988
- type: "editRefused",
989
- code: i
990
- } : {
991
- type: "undoSkipped",
992
- code: i
993
- }, e);
994
- }
995
- e.pending = n, e.view = t, ce(e), e === g && z(t);
996
- }
997
- function fe(e) {
998
- e.gapTimer ||= setTimeout(() => {
999
- e.gapTimer = null, e === g && J();
1000
- }, je);
1001
- }
1002
- function pe(e) {
1003
- e.gapTimer &&= (clearTimeout(e.gapTimer), null);
1004
- }
1005
- function J() {
1006
- let e = g;
1007
- return e ? (e.catchingUp ||= (async () => {
1008
- try {
1009
- let t = await n.operationsAfter(e.templateId, e.revision);
1010
- if (e.retired) return;
1011
- if ("resync" in t) {
1012
- await me(e);
1013
- return;
1014
- }
1015
- for (let n of t.batches) ue(e, n);
1016
- } catch (e) {
1017
- N(e);
1018
- } finally {
1019
- e.catchingUp = null;
1020
- }
1021
- })(), e.catchingUp) : Promise.resolve();
1022
- }
1023
- async function me(e) {
1024
- e.recovering = !0;
1025
- try {
1026
- let n = await t.loadTemplate(e.templateId);
1027
- if (e.retired) return;
1028
- let r = n.revision ?? e.revision;
1029
- e.confirmed = P(n.content), e.revision = r, e.remote = new Map([...e.remote].filter(([e]) => e > r));
1030
- for (let [t, n] of [...e.own]) t <= r && (e.own.delete(t), W(e, n));
1031
- e === g && (p.value = r), q(e), de(e);
1032
- } catch (e) {
1033
- N(e);
1034
- } finally {
1035
- e.recovering = !1;
1036
- }
1037
- }
1038
- function he(e) {
1039
- let n = () => e === g && !e.retired;
1040
- return {
1041
- onBatch: (t) => {
1042
- n() && ue(e, t);
1043
- },
1044
- onResync: (r, i) => {
1045
- if (!(!n() || r <= e.revision)) {
1046
- if (i) try {
1047
- t.onRemoteResync?.({
1048
- revision: r,
1049
- actor: i
1050
- });
1051
- } catch (e) {
1052
- N(e);
1053
- }
1054
- J();
1055
- }
1056
- },
1057
- onLock: (e) => {
1058
- n() && xe(e);
1059
- },
1060
- onUnlock: (e, t) => {
1061
- n() && Se(e, t);
1062
- },
1063
- onMembers: (e) => {
1064
- n() && we(e);
1065
- },
1066
- onConnectionChange: (t) => {
1067
- n() && ye(e, t);
1068
- }
1069
- };
1070
- }
1071
- function ge(e, t) {
1072
- n.join(e.templateId, { sessionId: a }, he(e)).then((n) => {
1073
- e.retired || e !== g ? t || n.leave() : (e.leave = n.leave, Ce(n.locks, !t), we(n.members), n.members.length > 0 && (f.value = "connected"), n.revision > e.revision && J(), t && X());
1074
- }, (e) => N(e));
1075
- }
1076
- function _e(e) {
1077
- let t = P(e.content), n = {
1078
- templateId: e.id,
1079
- confirmed: t,
1080
- revision: e.revision ?? 0,
1081
- pending: [],
1082
- view: P(t),
1083
- remote: /* @__PURE__ */ new Map(),
1084
- own: /* @__PURE__ */ new Map(),
1085
- inFlight: null,
1086
- gapTimer: null,
1087
- catchingUp: null,
1088
- leave: null,
1089
- retired: !1,
1090
- recovering: !1,
1091
- undo: [],
1092
- redo: [],
1093
- waiters: []
1094
- };
1095
- g = n, p.value = n.revision, R(), ge(n, !1), h?.state.selectedBlockId && Q(h.state.selectedBlockId), ne();
1096
- }
1097
- function ve(e) {
1098
- e.retired = !0, pe(e), e.leave?.(), e.leave = null, le(e, /* @__PURE__ */ Error("[Templatical] The template was closed."));
1099
- }
1100
- function ye(e, t) {
1101
- let n = f.value;
1102
- f.value = t, t === "connected" && n !== null && n !== "connected" && ge(e, !0);
1103
- }
1104
- function be(e) {
1105
- g && g.templateId === e?.id || (g &&= (B(), ve(g), null), l.value = [], d.value = /* @__PURE__ */ new Map(), f.value = null, E = null, X(), R(), e && _e(e));
1106
- }
1107
- function xe(e) {
1108
- if (e.holder.sessionId === a) return;
1109
- let t = new Map([...d.value].filter(([, t]) => t.holder.sessionId !== e.holder.sessionId));
1110
- t.set(e.blockId, e), d.value = t, h?.state.selectedBlockId === e.blockId && (h.selectBlock(null), I({
1111
- type: "selectionRefused",
1112
- blockId: e.blockId,
1113
- holder: e.holder
1114
- }));
1115
- }
1116
- function Se(e, t) {
1117
- if (d.value.get(e)?.holder.sessionId !== t) return;
1118
- let n = new Map(d.value);
1119
- n.delete(e), d.value = n;
1120
- }
1121
- function Ce(e, t) {
1122
- let n = t ? new Map(d.value) : /* @__PURE__ */ new Map();
1123
- for (let r of e) r.holder.sessionId !== a && (t && n.has(r.blockId) || n.set(r.blockId, r));
1124
- d.value = n;
1125
- }
1126
- function we(e) {
1127
- let t = new Set(e.map((e) => e.sessionId)), n = new Set(l.value.map((e) => e.sessionId).filter((e) => !t.has(e)));
1128
- if (l.value = e, n.size === 0) return;
1129
- let r = new Map([...d.value].filter(([, e]) => !n.has(e.holder.sessionId)));
1130
- r.size !== d.value.size && (d.value = r);
1131
- }
1132
- function Y(e) {
1133
- O = O.then(e).catch(N);
1134
- }
1135
- function X() {
1136
- c && Y(async () => {
1137
- if (D && (E === null || D.templateId !== E.templateId)) {
1138
- let e = D;
1139
- D = null, Z(), await n.releaseLock(e.templateId, e.blockId);
1140
- }
1141
- let e = E;
1142
- if (!(!e || D?.templateId === e.templateId && D.blockId === e.blockId)) try {
1143
- await n.acquireLock(e.templateId, e.blockId), D = e, Oe(), Te(e.blockId);
1144
- } catch (t) {
1145
- if (D?.templateId === e.templateId) {
1146
- let e = D;
1147
- D = null, Z(), await n.releaseLock(e.templateId, e.blockId).catch(() => {});
1148
- }
1149
- if (E !== e) return;
1150
- Ee(e.blockId, t);
1151
- }
1152
- });
1153
- }
1154
- function Te(e) {
1155
- if (!d.value.has(e)) return;
1156
- let t = new Map(d.value);
1157
- t.delete(e), d.value = t;
1158
- }
1159
- function Ee(e, t) {
1160
- let n = Ie(t);
1161
- if (n === "lock_held" || n === "block_missing") {
1162
- E = null;
1163
- let n = Le(t);
1164
- n ? xe({
1165
- blockId: e,
1166
- holder: n,
1167
- expiresAt: ""
1168
- }) : h?.state.selectedBlockId === e && h.selectBlock(null);
1169
- } else N(t), setTimeout(() => {
1170
- E?.blockId === e && X();
1171
- }, Ne[0]);
1172
- }
1173
- function Oe() {
1174
- k ||= setInterval(() => {
1175
- Y(async () => {
1176
- let e = D;
1177
- if (e) try {
1178
- await n.renewLock(e.templateId, e.blockId);
1179
- } catch (e) {
1180
- if (Ie(e) === "lock_lost") {
1181
- D = null, Z(), X();
1182
- return;
1183
- }
1184
- N(e);
1185
- }
1186
- });
1187
- }, Me);
1188
- }
1189
- function Z() {
1190
- k &&= (clearInterval(k), null);
1191
- }
1192
- function Q(e) {
1193
- H(), g && (E = e ? {
1194
- templateId: g.templateId,
1195
- blockId: e
1196
- } : null, X());
1197
- }
1198
- function $() {
1199
- H(), D && c && (n.releaseLock(D.templateId, D.blockId).catch(() => {}), D = null, Z()), g?.leave?.(), g && (g.leave = null);
1200
- }
1201
- function ke(e) {
1202
- let t = g;
1203
- if (!t || v) return;
1204
- H();
1205
- let n = (e === "undo" ? t.undo : t.redo).pop();
1206
- if (!n) return;
1207
- R();
1208
- let r;
1209
- try {
1210
- r = F(t.view, n.ops, L());
1211
- } catch (e) {
1212
- if (!(e instanceof A)) throw e;
1213
- I({
1214
- type: "undoSkipped",
1215
- code: e.code
1216
- });
1217
- return;
1218
- }
1219
- let i = { ops: Ae(t.view, n.ops) };
1220
- te(e === "undo" ? t.redo : t.undo, i), t.view = r, z(r), h?.markDirty(), ie(t, n.ops, e, i);
1221
- }
1222
- function Fe(e) {
1223
- h = e, T.push(_(() => e.state.template, (e) => be(e), { immediate: !0 }), _(() => e.content.value, ne, { deep: !0 }), _(() => e.state.selectedBlockId, Q), _(() => e.state.isLoading, (e) => e ? V(!0, !0) : ne())), typeof window < "u" && (window.addEventListener("pagehide", $), window.addEventListener("blur", H)), s() && i(Ge);
1224
- }
1225
- function He() {
1226
- H();
1227
- let e = g;
1228
- return !e || e.pending.length === 0 ? Promise.resolve() : new Promise((t, n) => e.waiters.push({
1229
- resolve: t,
1230
- reject: n
1231
- }));
1232
- }
1233
- function Ue() {
1234
- H(), v = !0;
1235
- }
1236
- function We() {
1237
- v = !1, g && z(g.view);
1238
- }
1239
- function Ge() {
1240
- if (!w) {
1241
- H();
1242
- for (let e of T.splice(0)) e();
1243
- B(), $(), w = !0, g && ve(g), g = null, Z(), typeof window < "u" && (window.removeEventListener("pagehide", $), window.removeEventListener("blur", H));
1244
- }
1245
- }
1246
- return {
1247
- sessionId: a,
1248
- members: l,
1249
- locks: d,
1250
- connection: f,
1251
- revision: p,
1252
- canUndo: j,
1253
- canRedo: M,
1254
- attach: Fe,
1255
- undo: () => ke("undo"),
1256
- redo: () => ke("redo"),
1257
- clearHistory: () => {
1258
- g && (g.undo = [], g.redo = [], R());
1259
- },
1260
- flush: H,
1261
- settle: He,
1262
- suspend: Ue,
1263
- resume: We,
1264
- catchUp: J,
1265
- hasConfirmedBlock: (e) => g ? ze(g.confirmed.blocks, e) : !1,
1266
- destroy: Ge
1267
- };
1268
- }
1269
- function Ue(e) {
1270
- let { provider: t } = e, n = u([]), r = u(!1), i = b(() => {
1271
- let e = /* @__PURE__ */ new Set();
1272
- for (let t of n.value) {
1273
- let n = t.category?.trim();
1274
- n && e.add(n);
1275
- }
1276
- return [...e].sort((e, t) => e.localeCompare(t));
1277
- }), a = b(() => typeof t.create == "function"), o = b(() => typeof t.update == "function"), s = b(() => typeof t.delete == "function");
1278
- function c(e) {
1279
- return o.value && e.canUpdate !== !1;
1280
- }
1281
- function l(e) {
1282
- return s.value && e.canDelete !== !1;
1283
- }
1284
- function d(e, t) {
1285
- throw new M(`[Templatical] Saved blocks: ${e} is ${t}. Check the capability before calling — the editor's own UI hides the action.`);
1286
- }
1287
- function f(t) {
1288
- K(e.onError, t);
1289
- }
1290
- async function p(i) {
1291
- r.value = !0;
1292
- try {
1293
- n.value = await t.list(i);
1294
- } catch (t) {
1295
- throw e.onError?.(t), t;
1296
- } finally {
1297
- r.value = !1;
1298
- }
1299
- }
1300
- async function m(r, i, a) {
1301
- let { create: o } = t;
1302
- typeof o != "function" && d("create", "disabled by the provider");
1303
- try {
1304
- let e = await o(a ? {
1305
- name: r,
1306
- content: i,
1307
- category: a
1308
- } : {
1309
- name: r,
1310
- content: i
1311
- });
1312
- return n.value = [e, ...n.value], f(() => t.onCreated?.(e)), e;
1313
- } catch (t) {
1314
- throw e.onError?.(t), t;
1315
- }
1316
- }
1317
- async function h(r, i) {
1318
- let { update: a } = t;
1319
- typeof a != "function" && d("update", "disabled by the provider");
1320
- let o = n.value.find((e) => e.id === r);
1321
- o && o.canUpdate === !1 && d("update", `not permitted for entry "${r}"`);
1322
- try {
1323
- let e = await a(r, i);
1324
- return n.value = n.value.map((t) => t.id === r ? e : t), f(() => t.onUpdated?.(e)), e;
1325
- } catch (t) {
1326
- throw e.onError?.(t), t;
1327
- }
1328
- }
1329
- async function g(r) {
1330
- let { delete: i } = t;
1331
- typeof i != "function" && d("delete", "disabled by the provider");
1332
- let a = n.value.find((e) => e.id === r) ?? null;
1333
- a && a.canDelete === !1 && d("delete", `not permitted for entry "${r}"`);
1334
- try {
1335
- await i(r), n.value = n.value.filter((e) => e.id !== r), a && f(() => t.onDeleted?.(a));
1336
- } catch (t) {
1337
- throw e.onError?.(t), t;
1338
- }
1339
- }
1340
- return {
1341
- savedBlocks: n,
1342
- isLoading: r,
1343
- categories: i,
1344
- canCreate: a,
1345
- canUpdate: o,
1346
- canDelete: s,
1347
- canUpdateBlock: c,
1348
- canDeleteBlock: l,
1349
- load: p,
1350
- create: m,
1351
- update: h,
1352
- remove: g
1353
- };
1354
- }
1355
- var We = "templatical:saved-blocks";
1356
- function Ge(e = {}) {
1357
- let t = e.key ?? We;
1358
- function n() {
1359
- 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.");
1360
- return localStorage;
1361
- }
1362
- function r() {
1363
- let e = n().getItem(t);
1364
- if (!e) return [];
1365
- try {
1366
- let t = JSON.parse(e);
1367
- return Array.isArray(t) ? t : [];
1368
- } catch {
1369
- return [];
1370
- }
1371
- }
1372
- function i(e) {
1373
- n().setItem(t, JSON.stringify(e));
1374
- }
1375
- return {
1376
- async list(e) {
1377
- let t = r(), n = e?.search?.trim().toLowerCase(), i = e?.category?.trim();
1378
- return t.filter((e) => !(n && !e.name.toLowerCase().includes(n) || i && e.category !== i));
1379
- },
1380
- async create(e) {
1381
- let t = (/* @__PURE__ */ new Date()).toISOString(), n = {
1382
- id: w(),
1383
- name: e.name,
1384
- content: e.content,
1385
- ...e.category ? { category: e.category } : {},
1386
- createdAt: t,
1387
- updatedAt: t
1388
- };
1389
- return i([n, ...r()]), n;
1390
- },
1391
- async update(e, t) {
1392
- let n = r(), a = n.findIndex((t) => t.id === e);
1393
- if (a === -1) throw Error(`[Templatical] Saved block not found: ${e}`);
1394
- let o = {
1395
- ...n[a],
1396
- ...t,
1397
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1398
- }, s = [...n];
1399
- return s[a] = o, i(s), o;
1400
- },
1401
- async delete(e) {
1402
- let t = r();
1403
- if (!t.some((t) => t.id === e)) throw Error(`[Templatical] Saved block not found: ${e}`);
1404
- i(t.filter((t) => t.id !== e));
1405
- }
1406
- };
1407
- }
1408
- var Ke = "templatical:media", qe = 50;
1409
- function Je(e = {}) {
1410
- let t = e.key ?? Ke;
1411
- function n() {
1412
- 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.");
1413
- return localStorage;
1414
- }
1415
- function r() {
1416
- let e = n().getItem(t);
1417
- if (!e) return [];
1418
- try {
1419
- let t = JSON.parse(e);
1420
- return Array.isArray(t) ? t : [];
1421
- } catch {
1422
- return [];
1423
- }
1424
- }
1425
- function i(e) {
1426
- n().setItem(t, JSON.stringify(e));
1427
- }
1428
- function a(e) {
1429
- return typeof FileReader > "u" ? Promise.reject(/* @__PURE__ */ Error("[Templatical] createLocalStorageMediaProvider requires a browser environment with FileReader.")) : new Promise((t, n) => {
1430
- let r = new FileReader();
1431
- r.onload = () => {
1432
- typeof r.result == "string" ? t(r.result) : n(/* @__PURE__ */ Error("[Templatical] Failed to read file as a data URL."));
1433
- }, r.onerror = () => {
1434
- n(r.error ?? /* @__PURE__ */ Error("[Templatical] Failed to read file as a data URL."));
1435
- }, r.readAsDataURL(e);
1436
- });
1437
- }
1438
- return {
1439
- async list(e) {
1440
- let t = r(), n = e?.search?.trim().toLowerCase(), i = n ? t.filter((e) => {
1441
- let t = e.filename?.toLowerCase() ?? "", r = e.alt?.toLowerCase() ?? "";
1442
- return t.includes(n) || r.includes(n);
1443
- }) : t, a = e?.cursor ? Number.parseInt(e.cursor, 10) : 0, o = Number.isFinite(a) && a > 0 ? a : 0, s = i.slice(o, o + qe), c = { items: s }, l = o + s.length;
1444
- return l < i.length && (c.nextCursor = String(l)), c;
1445
- },
1446
- async create(e) {
1447
- let t = await a(e.file), n = (/* @__PURE__ */ new Date()).toISOString(), o = {
1448
- id: w(),
1449
- url: t,
1450
- filename: e.filename || e.file.name,
1451
- createdAt: n,
1452
- updatedAt: n,
1453
- size: e.file.size
1454
- };
1455
- 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;
1456
- },
1457
- async update(e, t) {
1458
- let n = r(), a = n.findIndex((t) => t.id === e);
1459
- if (a === -1) throw Error(`[Templatical] Media asset not found: ${e}`);
1460
- let o = n[a], s = {
1461
- ...o,
1462
- ...t,
1463
- id: o.id,
1464
- url: o.url,
1465
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1466
- }, c = [...n];
1467
- return c[a] = s, i(c), s;
1468
- },
1469
- async delete(e) {
1470
- let t = r();
1471
- for (let n of e) if (!t.some((e) => e.id === n)) throw Error(`[Templatical] Media asset not found: ${n}`);
1472
- let n = new Set(e);
1473
- i(t.filter((e) => !n.has(e.id)));
1474
- },
1475
- folders: !1,
1476
- replace: !1,
1477
- importFromUrl: !1,
1478
- checkUsage: !1,
1479
- frequentlyUsed: !1,
1480
- storage: !1
1481
- };
1482
- }
1483
- function Ye(e) {
1484
- let { provider: t, getTemplateId: n } = e, r = u([]), i = u(!1), a = u(void 0), o = u(!1), s = /* @__PURE__ */ new Map(), c = b(() => typeof t.create == "function"), l = b(() => typeof t.restore == "function");
1485
- function d(e) {
1486
- let t = n();
1487
- if (!t) throw new M(`[Templatical] Version history: ${e} needs a template. Call create() or load() first.`);
1488
- return t;
1489
- }
1490
- function f(e) {
1491
- throw new M(`[Templatical] Version history: ${e} is disabled by the provider. Check the capability before calling — the editor's own UI hides the action.`);
1492
- }
1493
- function p(t) {
1494
- K(e.onError, t);
1495
- }
1496
- async function m(n) {
1497
- let o = d("list");
1498
- i.value = !0;
1499
- try {
1500
- let e = await t.list(o, n);
1501
- r.value = e.versions, a.value = e.nextCursor;
1502
- } catch (t) {
1503
- throw e.onError?.(t), t;
1504
- } finally {
1505
- i.value = !1;
1506
- }
1507
- }
1508
- function h(e) {
1509
- return e.content ?? s.get(e.id) ?? null;
1510
- }
1511
- async function g(n) {
1512
- let r = h(n);
1513
- if (r) return r;
1514
- let i = d("get");
1515
- try {
1516
- let e = await t.get(i, n.id);
1517
- return s.set(n.id, e), e;
1518
- } catch (t) {
1519
- throw e.onError?.(t), t;
1520
- }
1521
- }
1522
- async function _(n, i) {
1523
- let { create: a } = t;
1524
- typeof a != "function" && f("create");
1525
- let o = d("create");
1526
- try {
1527
- let e = await a(o, n, i);
1528
- return r.value = [e, ...r.value], p(() => t.onCreated?.(e)), e;
1529
- } catch (t) {
1530
- throw e.onError?.(t), t;
1531
- }
1532
- }
1533
- async function v(n) {
1534
- let { restore: r } = t;
1535
- typeof r != "function" && f("restore");
1536
- let i = d("restore"), a;
1537
- o.value = !0;
1538
- try {
1539
- a = await r(i, n);
1540
- } catch (t) {
1541
- throw e.onError?.(t), t;
1542
- } finally {
1543
- o.value = !1;
1544
- }
1545
- return p(() => t.onRestored?.(a)), a;
1546
- }
1547
- return {
1548
- nextCursor: a,
1549
- versions: r,
1550
- isLoading: i,
1551
- isRestoring: o,
1552
- canCreate: c,
1553
- canRestore: l,
1554
- load: m,
1555
- peekContent: h,
1556
- resolveContent: g,
1557
- create: _,
1558
- restore: v
1559
- };
1560
- }
1561
- function Xe(e) {
1562
- let { provider: t, getTemplateId: n, getUser: r } = e, i = u([]), a = u(!1), o = u(!1), s = b(() => typeof t.create == "function"), c = b(() => typeof t.update == "function"), l = b(() => typeof t.delete == "function"), d = b(() => typeof t.setResolved == "function"), f = b(() => i.value.reduce((e, t) => e + 1 + (t.replies?.length ?? 0), 0)), p = b(() => i.value.filter((e) => !e.resolvedAt).length), m = b(() => {
1563
- let e = /* @__PURE__ */ new Map();
1564
- for (let t of i.value) t.blockId && e.set(t.blockId, (e.get(t.blockId) ?? 0) + 1 + (t.replies?.length ?? 0));
1565
- return e;
1566
- });
1567
- function h(e) {
1568
- let t = n();
1569
- if (!t) throw new M(`[Templatical] Comments: ${e} needs a template. Call create() or load() first.`);
1570
- return t;
1571
- }
1572
- function g(e) {
1573
- let t = r();
1574
- if (!t) throw new M(`[Templatical] Comments: ${e} needs to know who is commenting. Pass init({ user: { id, name } }) — an unattributed comment is not written.`);
1575
- return t;
1576
- }
1577
- function _(e) {
1578
- throw new M(`[Templatical] Comments: ${e} is disabled by the provider. Check the capability before calling — the editor's own UI hides the action.`);
1579
- }
1580
- function v(e) {
1581
- for (let t of i.value) {
1582
- if (t.id === e) return t;
1583
- for (let n of t.replies ?? []) if (n.id === e) return n;
1584
- }
1585
- return null;
1586
- }
1587
- function y(e) {
1588
- let t = r();
1589
- return t !== null && e.author.id === t.id;
1590
- }
1591
- function x(t) {
1592
- let n = ue(t);
1593
- throw e.onError?.(n), n;
1594
- }
1595
- function S(t) {
1596
- K(e.onError, t);
1597
- }
1598
- function C(e, t, n) {
1599
- return [
1600
- ...e.slice(0, t),
1601
- n,
1602
- ...e.slice(t + 1)
1603
- ];
1604
- }
1605
- function w(e, t) {
1606
- return e !== void 0 && JSON.stringify(e) === JSON.stringify(t);
1607
- }
1608
- function T(e) {
1609
- if (e.parentId) {
1610
- let t = !1, n = i.value.map((n) => {
1611
- if (n.id !== e.parentId) return n;
1612
- let r = n.replies ?? [], i = r.findIndex((t) => t.id === e.id);
1613
- return i !== -1 && w(r[i], e) ? n : (t = !0, {
1614
- ...n,
1615
- replies: i === -1 ? [...r, e] : C(r, i, e)
1616
- });
1617
- });
1618
- return t && (i.value = n), t;
1619
- }
1620
- let t = i.value.findIndex((t) => t.id === e.id);
1621
- if (t === -1) return i.value = [...i.value, e], !0;
1622
- let n = {
1623
- ...e,
1624
- replies: e.replies ?? i.value[t].replies
1625
- };
1626
- return !w(i.value[t], n) && (i.value = C(i.value, t, n), !0);
1627
- }
1628
- function E(e, t) {
1629
- let n = v(e), r = t ?? n?.parentId ?? null;
1630
- return r ? i.value = i.value.map((t) => t.id === r ? {
1631
- ...t,
1632
- replies: (t.replies ?? []).filter((t) => t.id !== e)
1633
- } : t) : i.value = i.value.filter((t) => t.id !== e), n;
1634
- }
1635
- async function D(e) {
1636
- let n = h("list");
1637
- a.value = !0;
1638
- try {
1639
- i.value = await t.list(n, e);
1640
- } catch (e) {
1641
- x(e);
1642
- } finally {
1643
- a.value = !1;
1644
- }
1645
- }
1646
- async function O(e) {
1647
- let { create: n } = t;
1648
- typeof n != "function" && _("create");
1649
- let r = h("create");
1650
- g("create"), o.value = !0;
1651
- try {
1652
- let i = await n(r, e);
1653
- return T(i), S(() => t.onCreated?.(i, { origin: "local" })), i;
1654
- } catch (e) {
1655
- x(e);
1656
- } finally {
1657
- o.value = !1;
1658
- }
1659
- }
1660
- async function k(e, n) {
1661
- let { update: r } = t;
1662
- typeof r != "function" && _("update");
1663
- let i = h("update");
1664
- g("update"), o.value = !0;
1665
- try {
1666
- let a = await r(i, e, n);
1667
- return T(a), S(() => t.onUpdated?.(a, { origin: "local" })), a;
1668
- } catch (e) {
1669
- x(e);
1670
- } finally {
1671
- o.value = !1;
1672
- }
1673
- }
1674
- async function A(e) {
1675
- let { delete: n } = t;
1676
- typeof n != "function" && _("delete");
1677
- let r = h("delete");
1678
- g("delete");
1679
- let i = v(e);
1680
- o.value = !0;
1681
- try {
1682
- await n(r, e), E(e), i && S(() => t.onDeleted?.(i, { origin: "local" }));
1683
- } catch (e) {
1684
- x(e);
1685
- } finally {
1686
- o.value = !1;
1687
- }
1688
- }
1689
- async function j(e, n) {
1690
- let { setResolved: r } = t;
1691
- typeof r != "function" && _("setResolved");
1692
- let i = h("setResolved");
1693
- g("setResolved"), o.value = !0;
1694
- try {
1695
- let a = await r(i, e, n);
1696
- return T(a), S(() => (a.resolvedAt ? t.onResolved : t.onUnresolved)?.(a, { origin: "local" })), a;
1697
- } catch (e) {
1698
- x(e);
1699
- } finally {
1700
- o.value = !1;
1701
- }
1702
- }
1703
- function N(e) {
1704
- T(e) && S(() => t.onCreated?.(e, { origin: "remote" }));
1705
- }
1706
- function ee(e) {
1707
- T(e) && S(() => (e.resolvedAt ? t.onResolved : t.onUpdated)?.(e, { origin: "remote" }));
1708
- }
1709
- function P(e, n) {
1710
- let r = E(e, n);
1711
- r && S(() => t.onDeleted?.(r, { origin: "remote" }));
1712
- }
1713
- return {
1714
- comments: i,
1715
- isLoading: a,
1716
- isSubmitting: o,
1717
- canCreate: s,
1718
- canUpdate: c,
1719
- canDelete: l,
1720
- canResolve: d,
1721
- totalCount: f,
1722
- unresolvedCount: p,
1723
- commentCountByBlock: m,
1724
- load: D,
1725
- create: O,
1726
- update: k,
1727
- remove: A,
1728
- setResolved: j,
1729
- find: v,
1730
- isOwn: y,
1731
- applyRemoteCreate: N,
1732
- applyRemoteUpdate: ee,
1733
- applyRemoteDelete: P
1734
- };
1735
- }
1736
- function Ze(e) {
1737
- let { comments: t, provider: n, getTemplateId: r } = e, { subscribe: o } = n;
1738
- if (typeof o != "function") return;
1739
- let s = null;
1740
- function c() {
1741
- s?.(), s = null;
1742
- }
1743
- a(() => r(), (e) => {
1744
- c(), e && (s = o(e, (e) => {
1745
- switch (e.type) {
1746
- case "created":
1747
- t.applyRemoteCreate(e.comment);
1748
- break;
1749
- case "updated":
1750
- t.applyRemoteUpdate(e.comment);
1751
- break;
1752
- case "deleted": t.applyRemoteDelete(e.commentId, e.parentId);
1753
- }
1754
- }));
1755
- }, { immediate: !0 }), i(c);
1756
- }
1757
- //#endregion
1758
- //#region src/composables/useImageUrlResolver.ts
1759
- function Qe(e) {
1760
- let t = l(/* @__PURE__ */ new Map()), n = /* @__PURE__ */ new Set();
1761
- function r(e) {
1762
- return t.get(e);
1763
- }
1764
- function i(e) {
1765
- return t.has(e) || n.has(e);
1766
- }
1767
- function a(r) {
1768
- if (i(r)) return;
1769
- let a;
1770
- try {
1771
- a = e(r);
1772
- } catch {
1773
- t.set(r, null);
1774
- return;
1775
- }
1776
- a === null || typeof a == "string" ? t.set(r, a) : (n.add(r), Promise.resolve(a).then((e) => {
1777
- t.set(r, typeof e == "string" ? e : null);
1778
- }, () => {
1779
- t.set(r, null);
1780
- }).finally(() => n.delete(r)));
1781
- }
1782
- return {
1783
- get: r,
1784
- has: i,
1785
- lookup: a
1786
- };
1787
- }
1788
- function $e(e) {
1789
- let t = o(ie, null), n = b(e);
1790
- if (!t) return n;
1791
- let r;
1792
- function c() {
1793
- r !== void 0 && (clearTimeout(r), r = void 0);
1794
- }
1795
- s() && i(c);
1796
- let l = !0;
1797
- return a(n, (e) => {
1798
- c();
1799
- let n = l;
1800
- l = !1, e && !t.has(e) && (n ? t.lookup(e) : r = setTimeout(() => {
1801
- r = void 0, t.lookup(e);
1802
- }, 300));
1803
- }, { immediate: !0 }), b(() => {
1804
- let e = n.value;
1805
- if (!e) return e;
1806
- let r = t.get(e);
1807
- return typeof r == "string" && r.length > 0 ? r : e;
1808
- });
1809
- }
1810
- function et(e, t) {
1811
- if (!e || !t) return t;
1812
- let n = e.get(t);
1813
- return typeof n == "string" && n.length > 0 ? n : t;
1814
- }
1815
- function tt(e, t) {
1816
- return typeof e?.url == "string" && k(e.url, t);
1817
- }
1818
- function nt(e, t) {
1819
- let n = e?.url;
1820
- if (typeof n == "string" && n.trim() !== "") return k(n, t) ? void 0 : n;
1821
- }
1822
- function rt(e) {
1823
- let t = o(H, j.liquid), n = $e(() => nt(e(), t));
1824
- return b(() => tt(e(), t) ? null : n.value);
1825
- }
1826
- function it(e, t, n) {
1827
- return tt(t, n) ? null : et(e, nt(t, n));
1828
- }
1829
- //#endregion
1830
- //#region src/utils/blockTypeLabels.ts
1831
- function at(e, t) {
1832
- return t.blocks[e] ?? e;
1833
- }
1834
- function ot(e, t, n = []) {
1835
- if (e.type !== "custom") return at(e.type, t);
1836
- let { customType: r } = e;
1837
- return n.find((e) => e.type === r)?.name ?? r;
1838
- }
1839
- //#endregion
1840
- //#region src/utils/resolveFieldColors.ts
1841
- function st(e, t) {
1842
- let n = W({ presets: e.presets }, oe), r = n.presets.length === 0, i = e.allowCustom ?? t.allowCustom;
1843
- return {
1844
- presets: r ? t.presets : n.presets,
1845
- allowCustom: t.allowCustom !== !1 && i,
1846
- invalidPresets: n.invalidPresets,
1847
- emptyPresets: e.presets !== void 0 && e.presets.length === 0,
1848
- presetsInherited: r,
1849
- allowCustomIgnored: e.allowCustom === !0 && t.allowCustom === !1
1850
- };
1851
- }
1852
- var ct = G({
1853
- name: "code",
1854
- size: 24,
1855
- node: [["path", {
1856
- d: "m16 18 6-6-6-6",
1857
- key: "eg8j8"
1858
- }], ["path", {
1859
- d: "m8 6-6 6 6 6",
1860
- key: "ppft3o"
1861
- }]]
1862
- }), lt = G({
1863
- name: "image",
1864
- size: 24,
1865
- node: [
1866
- ["rect", {
1867
- width: "18",
1868
- height: "18",
1869
- x: "3",
1870
- y: "3",
1871
- rx: "2",
1872
- ry: "2",
1873
- key: "1m3agn"
1874
- }],
1875
- ["circle", {
1876
- cx: "9",
1877
- cy: "9",
1878
- r: "2",
1879
- key: "af1f0g"
1880
- }],
1881
- ["path", {
1882
- d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",
1883
- key: "1xmnt7"
1884
- }]
1885
- ]
1886
- }), ut = G({
1887
- name: "navigation",
1888
- size: 24,
1889
- node: [["polygon", {
1890
- points: "3 11 22 2 13 21 11 13 3 11",
1891
- key: "1ltx0t"
1892
- }]]
1893
- }), dt = G({
1894
- name: "share-2",
1895
- size: 24,
1896
- node: [
1897
- ["circle", {
1898
- cx: "18",
1899
- cy: "5",
1900
- r: "3",
1901
- key: "gq8acd"
1902
- }],
1903
- ["circle", {
1904
- cx: "6",
1905
- cy: "12",
1906
- r: "3",
1907
- key: "w7nqdw"
1908
- }],
1909
- ["circle", {
1910
- cx: "18",
1911
- cy: "19",
1912
- r: "3",
1913
- key: "1xt0gg"
1914
- }],
1915
- ["line", {
1916
- x1: "8.59",
1917
- x2: "15.42",
1918
- y1: "13.51",
1919
- y2: "17.49",
1920
- key: "47mynk"
1921
- }],
1922
- ["line", {
1923
- x1: "15.41",
1924
- x2: "8.59",
1925
- y1: "6.51",
1926
- y2: "10.49",
1927
- key: "1n3mei"
1928
- }]
1929
- ]
1930
- }), ft = G({
1931
- name: "table",
1932
- size: 24,
1933
- node: [
1934
- ["path", {
1935
- d: "M12 3v18",
1936
- key: "108xh3"
1937
- }],
1938
- ["rect", {
1939
- width: "18",
1940
- height: "18",
1941
- x: "3",
1942
- y: "3",
1943
- rx: "2",
1944
- key: "afitv7"
1945
- }],
1946
- ["path", {
1947
- d: "M3 9h18",
1948
- key: "1pudct"
1949
- }],
1950
- ["path", {
1951
- d: "M3 15h18",
1952
- key: "5xshup"
1953
- }]
1954
- ]
1955
- });
1956
- //#endregion
1957
- //#region src/utils/imageNaturalSize.ts
1958
- function pt(e) {
1959
- return typeof e == "number" && Number.isFinite(e) && e > 0;
1960
- }
1961
- function mt(e, t) {
1962
- return pt(e) && pt(t) ? {
1963
- width: e,
1964
- height: t
1965
- } : null;
1966
- }
1967
- function ht(e) {
1968
- return mt(e.naturalWidth, e.naturalHeight);
1969
- }
1970
- function gt(e) {
1971
- return e ? {
1972
- naturalWidth: e.width,
1973
- naturalHeight: e.height
1974
- } : {
1975
- naturalWidth: void 0,
1976
- naturalHeight: void 0
1977
- };
1978
- }
1979
- function _t(e, t) {
1980
- if (typeof Image > "u") return t(null), () => {};
1981
- let n = new Image(), r = () => {
1982
- n.onload = null, n.onerror = null;
1983
- };
1984
- return n.onload = () => {
1985
- r(), t(mt(n.naturalWidth, n.naturalHeight));
1986
- }, n.onerror = () => {
1987
- r(), t(null);
1988
- }, n.src = e, r;
1989
- }
1990
- function vt(e) {
1991
- return new Promise((t) => {
1992
- let n = setTimeout(() => {
1993
- r(), t(null);
1994
- }, U), r = _t(e, (e) => {
1995
- clearTimeout(n), t(e);
1996
- });
1997
- });
1998
- }
1999
- //#endregion
2000
- //#region src/components/MediaDropOverlay.vue
2001
- var yt = /* @__PURE__ */ x({
2002
- __name: "MediaDropOverlay",
2003
- props: {
2004
- uploading: { type: Boolean },
2005
- size: { default: "field" }
2006
- },
2007
- setup(e) {
2008
- let r = e, { t: i } = ae(), a = {
2009
- field: {
2010
- gap: "tpl:gap-1.5",
2011
- icon: 18,
2012
- veil: "90%"
2013
- },
2014
- canvas: {
2015
- gap: "tpl:gap-2",
2016
- icon: 20,
2017
- veil: "85%"
2018
- }
2019
- }, o = b(() => a[r.size]);
2020
- return (r, a) => (t(), f("div", {
2021
- class: g(["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)]", o.value.gap]),
2022
- style: n({ backgroundColor: `color-mix(in srgb, var(--tpl-bg) ${o.value.veil}, transparent)` })
2023
- }, [e.uploading ? (t(), f(v, { key: 0 }, [p(d(se), {
2024
- class: "tpl-spinner",
2025
- size: o.value.icon,
2026
- "stroke-width": 2
2027
- }, null, 8, ["size"]), m(" " + h(d(i).image.uploading), 1)], 64)) : (t(), f(v, { key: 1 }, [p(d(ce), {
2028
- size: o.value.icon,
2029
- "stroke-width": 1.5
2030
- }, null, 8, ["size"]), m(" " + h(d(i).image.dropToUpload), 1)], 64))], 6));
2031
- }
2032
- }), bt = "image/";
2033
- function xt(e) {
2034
- let { target: t, onFiles: n, enabled: r } = e, i = () => r === void 0 || y(r), { isOverDropZone: a } = B(t, {
2035
- preventDefaultForUnhandled: !0,
2036
- onDrop: (e) => {
2037
- if (!i()) return;
2038
- let t = (e ?? []).filter((e) => e.type.startsWith(bt));
2039
- t.length > 0 && n([t[0]]);
2040
- }
2041
- });
2042
- return { isOver: b(() => i() && a.value) };
2043
- }
2044
- //#endregion
2045
- //#region src/composables/useMediaDropField.ts
2046
- function St(e) {
2047
- let { target: t, blocked: n, apply: r } = e, i = o(V, null), a = o(re, null), s = le();
2048
- async function c() {
2049
- let e = await i?.({ accept: ["images"] });
2050
- s.alive && e && r(e);
2051
- }
2052
- let l = u(!1), d = b(() => (a?.value ?? !!i) && !l.value && !y(n));
2053
- async function f(e) {
2054
- if (i) {
2055
- l.value = !0;
2056
- try {
2057
- let t = await i({
2058
- accept: ["images"],
2059
- files: e
2060
- });
2061
- if (!s.alive) return;
2062
- t && r(t);
2063
- } finally {
2064
- s.alive && (l.value = !1);
2065
- }
2066
- }
2067
- }
2068
- let { isOver: p } = xt({
2069
- target: t,
2070
- enabled: d,
2071
- onFiles: f
2072
- }), m = b(() => d.value && p.value || l.value);
2073
- return {
2074
- canBrowse: !!i,
2075
- dropEnabled: d,
2076
- isUploading: l,
2077
- showOverlay: m,
2078
- openMediaBrowser: c
2079
- };
2080
- }
2081
- function Ct(e, t = "desktop") {
2082
- return t === "mobile" ? 375 : e?.width ?? 600;
2083
- }
2084
- var wt = "width 300ms cubic-bezier(0.34, 1.56, 0.64, 1)", Tt = {
2085
- 1: [100],
2086
- 2: [50, 50],
2087
- 3: [
2088
- 33.33,
2089
- 33.33,
2090
- 33.34
2091
- ],
2092
- "1-2": [33.33, 66.67],
2093
- "2-1": [66.67, 33.33]
2094
- };
2095
- function Et(e, t) {
2096
- let n = (e) => Math.trunc(e ?? 0), r = (e) => D(e) === null ? 0 : Math.trunc(e.width);
2097
- return n(e?.left) + n(e?.right) + r(t?.left) + r(t?.right);
2098
- }
2099
- function Dt(e, t) {
2100
- return Math.floor(e) - Et(t);
2101
- }
2102
- function Ot(e, t) {
2103
- let n = "border" in e ? e.border : void 0;
2104
- return Math.floor(t) - Et(e.styles.padding, n);
2105
- }
2106
- function* kt(e, t) {
2107
- for (let n of e) R(n) ? yield* kt(n.children, Dt(t, n.styles.padding)) : yield {
2108
- block: n,
2109
- bandWidth: I(n) && n.wrapper ? Dt(t, n.wrapper.padding) : t
2110
- };
2111
- }
2112
- function At(e, t) {
2113
- if (!t) return e;
2114
- try {
2115
- return L(t, e);
2116
- } catch {
2117
- return e;
2118
- }
2119
- }
2120
- function jt(e, t, n) {
2121
- let r = At(e, n);
2122
- for (let { block: e, bandWidth: n } of kt(r.blocks, r.settings.width)) if (I(e)) {
2123
- let r = N(e)?.applied ? void 0 : e.border, i = Math.floor(n) - Et(e.styles.padding, r), a = Tt[e.columns] ?? [100];
2124
- for (let n = 0; n < e.children.length; n++) {
2125
- let r = Math.floor(i * (a[n] ?? 100) / 100), o = e.children[n].find((e) => e.id === t);
2126
- if (o) return Ot(o, r);
2127
- }
2128
- } else if (e.id === t) return Ot(e, n);
2129
- return null;
2130
- }
2131
- function Mt(e, t, n) {
2132
- let r = At(e, n);
2133
- for (let { block: e, bandWidth: n } of kt(r.blocks, r.settings.width)) if (e.id === t) return Math.floor(n);
2134
- return null;
2135
- }
2136
- function Nt(e, t, n) {
2137
- if (!I(e)) return;
2138
- let r = N(e);
2139
- if (r?.applied && r.height === "image") return (t ? Mt(t, e.id, n) : null) ?? Ct(t?.settings);
2140
- }
2141
- //#endregion
2142
- //#region src/constants/socialIcons.ts
2143
- var Pt = te, Ft = {
2144
- small: 24,
2145
- medium: 32,
2146
- large: 48
2147
- }, It = [
2148
- "facebook",
2149
- "twitter",
2150
- "instagram",
2151
- "linkedin",
2152
- "youtube",
2153
- "tiktok",
2154
- "pinterest",
2155
- "email",
2156
- "website",
2157
- "whatsapp",
2158
- "telegram",
2159
- "discord",
2160
- "snapchat",
2161
- "reddit",
2162
- "github",
2163
- "dribbble",
2164
- "behance"
2165
- ];
2166
- //#endregion
2167
- export { Je as A, J as B, at as C, rt as D, it as E, Ze as F, Ue as H, Xe as I, _e as L, ge as M, me as N, $e as O, He as P, ve as R, ot as S, nt as T, Ye as U, ye as V, dt as _, Nt as a, ct as b, Ct as c, _t as d, vt as f, ft as g, mt as h, jt as i, Ge as j, he as k, St as l, ht as m, Pt as n, Mt as o, gt as p, It as r, wt as s, Ft as t, yt as u, ut as v, Qe as w, st as x, lt as y, de as z };