@xopcai/xopc 0.0.425 → 0.0.427

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 (448) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/src/adapters/security-adapter.js +1 -1
  3. package/dist/extensions/telegram/src/pairing-config-resolver.js +1 -1
  4. package/dist/extensions/telegram/src/plugin.js +2 -2
  5. package/dist/extensions/telegram/xopc.extension.json +1 -1
  6. package/dist/extensions/weixin/src/api/api.js +1 -1
  7. package/dist/extensions/weixin/src/auth/accounts.js +2 -2
  8. package/dist/extensions/weixin/src/auth/pairing.js +1 -1
  9. package/dist/extensions/weixin/src/cdn/upload.js +1 -1
  10. package/dist/extensions/weixin/src/cli/gateway-qr-login.js +1 -1
  11. package/dist/extensions/weixin/src/cli/qr-login.js +1 -1
  12. package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
  13. package/dist/extensions/weixin/src/messaging/inbound.js +2 -2
  14. package/dist/extensions/weixin/src/messaging/process-message.js +3 -3
  15. package/dist/extensions/weixin/src/messaging/send.js +12 -3
  16. package/dist/extensions/weixin/src/monitor/monitor.js +1 -1
  17. package/dist/extensions/weixin/src/outbound-send.js +12 -3
  18. package/dist/extensions/weixin/src/pairing-config-resolver.js +1 -1
  19. package/dist/extensions/weixin/src/plugin.js +1 -1
  20. package/dist/gateway/static/root/assets/{activity-store-CMw8qBuC.js → activity-store-D_DXNHba.js} +1 -1
  21. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-JI0YWOIm.js → agent-avatar-dicebear-CjaQxFQt.js} +1 -1
  22. package/dist/gateway/static/root/assets/{agent-avatar-display-YqmwzOSa.js → agent-avatar-display-6Z4m31Fz.js} +2 -2
  23. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-D4ClP_DJ.js +1 -0
  24. package/dist/gateway/static/root/assets/agent-plugin-dialog-m1A8wF9p.js +1 -0
  25. package/dist/gateway/static/root/assets/agents-B9slUA_1.js +77 -0
  26. package/dist/gateway/static/root/assets/{agents-admin-api-DLnmdC1h.js → agents-admin-api-u5c3GREg.js} +1 -1
  27. package/dist/gateway/static/root/assets/{api-Boc-CVh7.js → api-C3Tp9MkF.js} +1 -1
  28. package/dist/gateway/static/root/assets/{api-bL7sxjAF.js → api-CRT9ZyH0.js} +1 -1
  29. package/dist/gateway/static/root/assets/app-link-DRy3-k7j.js +1 -0
  30. package/dist/gateway/static/root/assets/{app-management-settings-panel-jIG5i7KE.js → app-management-settings-panel-XqoIBF2H.js} +1 -1
  31. package/dist/gateway/static/root/assets/{appearance-settings-BnaQW9Xd.js → appearance-settings-9ZtqCASo.js} +1 -1
  32. package/dist/gateway/static/root/assets/apps-page-DUeu_7iC.js +1 -0
  33. package/dist/gateway/static/root/assets/{archive-plugin-DjboG3kA.js → archive-plugin-BCQnOkV8.js} +1 -1
  34. package/dist/gateway/static/root/assets/attachment-load-DrVGNxJm.js +1 -0
  35. package/dist/gateway/static/root/assets/{automation-api-CZqL9l_d.js → automation-api-hRsGx-qe.js} +1 -1
  36. package/dist/gateway/static/root/assets/{automation-result-state-DRd-X_Ai.js → automation-result-state-CMfVTv_i.js} +1 -1
  37. package/dist/gateway/static/root/assets/automation-task-card-Bur78p68.js +3 -0
  38. package/dist/gateway/static/root/assets/{automations-page-HyBQIfmn.js → automations-page-DMIyWsP0.js} +1 -1
  39. package/dist/gateway/static/root/assets/automations-workspace-DEkDjxeU.js +9 -0
  40. package/dist/gateway/static/root/assets/{binary-plugins-Bg8ARZUH.js → binary-plugins-CIB5cbvQ.js} +1 -1
  41. package/dist/gateway/static/root/assets/{block-editor-DKohqFAW.js → block-editor-CXdlNAmZ.js} +2 -2
  42. package/dist/gateway/static/root/assets/{browser-automation-inputs-YeibTzw4.js → browser-automation-inputs-Fxo7HbK6.js} +1 -1
  43. package/dist/gateway/static/root/assets/{browser-automations-page-BWNcbuz2.js → browser-automations-page-Dn3LN5wo.js} +2 -2
  44. package/dist/gateway/static/root/assets/{browser-control-api-CDeuxy2x.js → browser-control-api-CbbPvhHR.js} +1 -1
  45. package/dist/gateway/static/root/assets/browser-settings-page-Cpm9fEPV.js +3 -0
  46. package/dist/gateway/static/root/assets/{button-CnRSIP6m.js → button-Cc4hUNTt.js} +1 -1
  47. package/dist/gateway/static/root/assets/{capabilities-BcQa8c9n.js → capabilities-BEvywfF9.js} +1 -1
  48. package/dist/gateway/static/root/assets/capabilities-Bo2qEJhH.js +1 -0
  49. package/dist/gateway/static/root/assets/capabilities-page-BCzsIzvC.js +2 -0
  50. package/dist/gateway/static/root/assets/capabilities-settings-panel-Cr67ziwX.js +8 -0
  51. package/dist/gateway/static/root/assets/{capability-header-actions-CTUCuBlW.js → capability-header-actions-BxMYfQ8y.js} +1 -1
  52. package/dist/gateway/static/root/assets/channels-CA5z5dGY.js +1 -0
  53. package/dist/gateway/static/root/assets/{chat-agents-api-B8JO6Tcj.js → chat-agents-api-D8YS5amE.js} +1 -1
  54. package/dist/gateway/static/root/assets/{chat-chart-block-DRtuFfF1.js → chat-chart-block-B39npsXj.js} +1 -1
  55. package/dist/gateway/static/root/assets/chat-page-D92AWJbh.js +72 -0
  56. package/dist/gateway/static/root/assets/{chat-terminal-dock-Dkqq5FSL.js → chat-terminal-dock-DjFnElAM.js} +2 -2
  57. package/dist/gateway/static/root/assets/{command-palette-api-qujvNqkK.js → command-palette-api-Dijix7V6.js} +1 -1
  58. package/dist/gateway/static/root/assets/composer-payload-handoff-BQXlFKf4.js +1 -0
  59. package/dist/gateway/static/root/assets/{computer-settings-page-8q4hRmoo.js → computer-settings-page-MkqyKyf3.js} +1 -1
  60. package/dist/gateway/static/root/assets/confirm-dialog-D7dQJytv.js +1 -0
  61. package/dist/gateway/static/root/assets/connected-providers-grid-BSvKP2u-.js +1 -0
  62. package/dist/gateway/static/root/assets/{connector-service-page-DQaTI21R.js → connector-service-page-DlIl9bLx.js} +1 -1
  63. package/dist/gateway/static/root/assets/{connectors-api-BjypBp2g.js → connectors-api-DEJU8mgn.js} +1 -1
  64. package/dist/gateway/static/root/assets/connectors-page-Vx8-MY0Y.js +1 -0
  65. package/dist/gateway/static/root/assets/{copy-text-row-CYIv7RfP.js → copy-text-row-CpiRzq4G.js} +1 -1
  66. package/dist/gateway/static/root/assets/{date-picker-D_PSHGpe.js → date-picker-BIfjfOTM.js} +1 -1
  67. package/dist/gateway/static/root/assets/dependency-picker-XjPB8FJS.js +1 -0
  68. package/dist/gateway/static/root/assets/{desktop-pet-1Et9VqkM.js → desktop-pet-DFNehTtd.js} +1 -1
  69. package/dist/gateway/static/root/assets/{desktop-pet-narrative-rADKU0FX.js → desktop-pet-narrative-ChwjpnsG.js} +1 -1
  70. package/dist/gateway/static/root/assets/{desktop-pet-settings-0fCGgaG7.js → desktop-pet-settings-BDjsFown.js} +1 -1
  71. package/dist/gateway/static/root/assets/{dev-view-store-TTj_djD8.js → dev-view-store-CeZZLOc6.js} +1 -1
  72. package/dist/gateway/static/root/assets/device-pairing-wizard-DH_uJ698.js +1 -0
  73. package/dist/gateway/static/root/assets/{directory-picker-path-field-C07a7wYX.js → directory-picker-path-field-DiZXY7jF.js} +1 -1
  74. package/dist/gateway/static/root/assets/{discussion-annotation-sync-BFqKm9ky.js → discussion-annotation-sync-BXqNuZnx.js} +1 -1
  75. package/dist/gateway/static/root/assets/dist-BGTk37IG.js +1 -0
  76. package/dist/gateway/static/root/assets/dist-BuHnPloF.js +1 -0
  77. package/dist/gateway/static/root/assets/dist-GJ8-1PAx.js +1 -0
  78. package/dist/gateway/static/root/assets/dist-ZrL34Ps4.js +1 -0
  79. package/dist/gateway/static/root/assets/{extension-debug-page-DFaVlqas.js → extension-debug-page-myQqsol2.js} +1 -1
  80. package/dist/gateway/static/root/assets/{extension-iframe-host-BfzPfXBq.js → extension-iframe-host-DaL-OcTw.js} +1 -1
  81. package/dist/gateway/static/root/assets/{extension-marketplace-api-ow0K1Y4_.js → extension-marketplace-api-DRBszrCR.js} +1 -1
  82. package/dist/gateway/static/root/assets/{extension-page-CrDADV5W.js → extension-page-DvlGhZLa.js} +1 -1
  83. package/dist/gateway/static/root/assets/{extension-provider-mnRoa63o.js → extension-provider-fOi6V6Cr.js} +1 -1
  84. package/dist/gateway/static/root/assets/{extension-settings-page-BLl02GFY.js → extension-settings-page-DOGlQpkx.js} +1 -1
  85. package/dist/gateway/static/root/assets/{file-preview-surface-TGdKqhCf.js → file-preview-surface-DfkXvFnc.js} +1 -1
  86. package/dist/gateway/static/root/assets/{gateway-config-swr-DfPQIHOL.js → gateway-config-swr-BOCt_zOo.js} +1 -1
  87. package/dist/gateway/static/root/assets/{gateway-realtime-67vWg_M2.js → gateway-realtime-BL_Cf0OQ.js} +1 -1
  88. package/dist/gateway/static/root/assets/gateway-realtime-store-BHBOPF_q.js +1 -0
  89. package/dist/gateway/static/root/assets/{gateway-restart-CLtR2wkL.js → gateway-restart-CHf8qY7H.js} +1 -1
  90. package/dist/gateway/static/root/assets/{gateway-settings-COvC3r-l.js → gateway-settings-Di41peSM.js} +1 -1
  91. package/dist/gateway/static/root/assets/{gateway-startup-retry-9YQllbw2.js → gateway-startup-retry-CvkJYurV.js} +1 -1
  92. package/dist/gateway/static/root/assets/{global-defaults-api-DYMRjGvd.js → global-defaults-api-BWMbKu72.js} +1 -1
  93. package/dist/gateway/static/root/assets/home-page-B3sgqrl3.js +2 -0
  94. package/dist/gateway/static/root/assets/{image-generation-api-Dzydfvy8.js → image-generation-api-Ce-IY7Ug.js} +1 -1
  95. package/dist/gateway/static/root/assets/{imports-page-Csd_YZXZ.js → imports-page-W7_cDbxy.js} +1 -1
  96. package/dist/gateway/static/root/assets/index-D4B6O8B3.js +11 -0
  97. package/dist/gateway/static/root/assets/index-DGWBJDAM.css +1 -0
  98. package/dist/gateway/static/root/assets/install-connector-dialog-DWVl9ekV.js +1 -0
  99. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-B201bMIa.js → keyboard-shortcuts-settings-Doyu0Q9e.js} +1 -1
  100. package/dist/gateway/static/root/assets/link-2-D_ZKYUW7.js +1 -0
  101. package/dist/gateway/static/root/assets/local-app-workbench-page-B3h3P6aI.js +1 -0
  102. package/dist/gateway/static/root/assets/{local-apps-page-BOwqNH0L.js → local-apps-page-D6D2bZGW.js} +1 -1
  103. package/dist/gateway/static/root/assets/{local-session-drafts-DjmK-SM9.js → local-session-drafts-BJ1B1dQ7.js} +1 -1
  104. package/dist/gateway/static/root/assets/{locale-store-Bg_XR36n.js → locale-store-Br7IfbXK.js} +1 -1
  105. package/dist/gateway/static/root/assets/{logs-page-gw3E9CMQ.js → logs-page-qiXos_12.js} +2 -2
  106. package/dist/gateway/static/root/assets/management-settings-C0WcSdK7.js +1 -0
  107. package/dist/gateway/static/root/assets/{markdown-view-BUpXJUPv.js → markdown-view-Ck5s16p9.js} +2 -2
  108. package/dist/gateway/static/root/assets/mcp-conversation-setup-page-CENs3hGU.js +1 -0
  109. package/dist/gateway/static/root/assets/{media-plugins-_shnaEMY.js → media-plugins-Ba6vUE4J.js} +1 -1
  110. package/dist/gateway/static/root/assets/messages-ByFlEbsu.js +3 -0
  111. package/dist/gateway/static/root/assets/model-selector-DCBmsHzj.js +1 -0
  112. package/dist/gateway/static/root/assets/{models-hub-cache-KOJC3z6Q.js → models-hub-cache-Bd-fYUrV.js} +1 -1
  113. package/dist/gateway/static/root/assets/note-detail-panel-CnuxqWMd.js +5 -0
  114. package/dist/gateway/static/root/assets/note-image-lightbox-BFKZ7qJr.js +1 -0
  115. package/dist/gateway/static/root/assets/{notes-api-BSmikUKI.js → notes-api-8kp0X1x6.js} +1 -1
  116. package/dist/gateway/static/root/assets/{notes-page-CA0NRL8O.js → notes-page-XMdy-H3H.js} +1 -1
  117. package/dist/gateway/static/root/assets/{oauth-api-D2t9HXoC.js → oauth-api-DMMdeaNd.js} +1 -1
  118. package/dist/gateway/static/root/assets/{oauth-provider-connect-DGGGGtcB.js → oauth-provider-connect-CfOK8mPM.js} +1 -1
  119. package/dist/gateway/static/root/assets/{page-context-capture-button-BH54VO0V.js → page-context-capture-button-CKlKWSJ7.js} +1 -1
  120. package/dist/gateway/static/root/assets/{page-context-draft-BS5y8Cx9.js → page-context-draft-LF33STHC.js} +1 -1
  121. package/dist/gateway/static/root/assets/page-header-store-Du44NIEJ.js +1 -0
  122. package/dist/gateway/static/root/assets/{personal-avatar-D8DtpDTa.js → personal-avatar-D6CzIIfo.js} +1 -1
  123. package/dist/gateway/static/root/assets/personal-page-CIMMSI25.js +1 -0
  124. package/dist/gateway/static/root/assets/{personal-settings-panel-9uDaNJy5.js → personal-settings-panel-wKdlrfPq.js} +1 -1
  125. package/dist/gateway/static/root/assets/{phone-dependencies-card-DLYrI0C4.js → phone-dependencies-card-CDhk5277.js} +1 -1
  126. package/dist/gateway/static/root/assets/phone-model-connection-DZ-ZunPz.js +1 -0
  127. package/dist/gateway/static/root/assets/{phone-model-picker-BbA2iI-3.js → phone-model-picker-DuZc5jYO.js} +1 -1
  128. package/dist/gateway/static/root/assets/phone-settings-page-0u0GQl_R.js +1 -0
  129. package/dist/gateway/static/root/assets/{phone-workspace-store-CVDk80Bf.js → phone-workspace-store-SN7hfddU.js} +1 -1
  130. package/dist/gateway/static/root/assets/plugin-details-dialog-Bfc-Wmrd.js +1 -0
  131. package/dist/gateway/static/root/assets/{popover-select-DD8fmrxH.js → popover-select-CEMWIrtY.js} +1 -1
  132. package/dist/gateway/static/root/assets/{preference-select-fields-BVoN-lAv.js → preference-select-fields-BKeHZLXZ.js} +1 -1
  133. package/dist/gateway/static/root/assets/{product-automation-feedback-DCo90zGh.js → product-automation-feedback-BPur0vyo.js} +2 -2
  134. package/dist/gateway/static/root/assets/{product-open-page-OWl8IAoY.js → product-open-page-Bfd7R483.js} +1 -1
  135. package/dist/gateway/static/root/assets/{product-preview-content-Cjas7UNe.js → product-preview-content-Bnq68oVw.js} +1 -1
  136. package/dist/gateway/static/root/assets/{product-preview-modal-CPWRvBI9.js → product-preview-modal-BPmTeweh.js} +2 -2
  137. package/dist/gateway/static/root/assets/project-detail-page-D9nnyvrI.js +7 -0
  138. package/dist/gateway/static/root/assets/{project-understanding-Ba02SFzB.js → project-understanding-DLvxAoTT.js} +1 -1
  139. package/dist/gateway/static/root/assets/projects-page-BGy1pw9a.js +1 -0
  140. package/dist/gateway/static/root/assets/{providers-api-rwQ4LWzr.js → providers-api-DOnNfkwQ.js} +1 -1
  141. package/dist/gateway/static/root/assets/{recording-upload-BSmvRrZQ.js → recording-upload-CHFJbqW1.js} +1 -1
  142. package/dist/gateway/static/root/assets/{refresh-button-bU_0NarN.js → refresh-button-DiWdGAaX.js} +1 -1
  143. package/dist/gateway/static/root/assets/{registry-api-Vy7LfH6E.js → registry-api-DFDvOTg4.js} +1 -1
  144. package/dist/gateway/static/root/assets/{remote-access-hub-UXrnpGev.js → remote-access-hub-BVqwnOqO.js} +1 -1
  145. package/dist/gateway/static/root/assets/{resource-unavailable-f9OzSi4W.js → resource-unavailable-TQcRCpAg.js} +1 -1
  146. package/dist/gateway/static/root/assets/route-preload-DI43HQV_.js +2 -0
  147. package/dist/gateway/static/root/assets/{runtime-tools-api-Bt8t37z5.js → runtime-tools-api-9o3Wfji1.js} +1 -1
  148. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DU4UXnBm.js → runtime-tools-settings-panel-ccVBG-bZ.js} +1 -1
  149. package/dist/gateway/static/root/assets/{schema-form-BKeP5G7b.js → schema-form-C-jw6Hid.js} +1 -1
  150. package/dist/gateway/static/root/assets/{secret-input-BQvFXqzz.js → secret-input-Dryrns2s.js} +1 -1
  151. package/dist/gateway/static/root/assets/{service-recommendation-list-CuYsRcBB.js → service-recommendation-list-CNghOavt.js} +1 -1
  152. package/dist/gateway/static/root/assets/{session-api-DJI9eSgw.js → session-api-Bs3r_d2_.js} +1 -1
  153. package/dist/gateway/static/root/assets/session-manager-Bnq3qpqy.js +23 -0
  154. package/dist/gateway/static/root/assets/sessions-page-CyBj1Xw2.js +1 -0
  155. package/dist/gateway/static/root/assets/settings-advanced-gate-BI4DMz4_.js +1 -0
  156. package/dist/gateway/static/root/assets/{settings-advanced-section-BxUuF_yi.js → settings-advanced-section-DwpPPxT0.js} +1 -1
  157. package/dist/gateway/static/root/assets/{settings-mode-store-CaoRh2gt.js → settings-mode-store-CiRpsdTJ.js} +1 -1
  158. package/dist/gateway/static/root/assets/{settings-page-qQ8-6dJ_.js → settings-page-Cd8Ermnn.js} +1 -1
  159. package/dist/gateway/static/root/assets/{settings-page-header-CyUHrn7c.js → settings-page-header-BZl4AMiN.js} +1 -1
  160. package/dist/gateway/static/root/assets/{settings-page-layout-DGVqXrlp.js → settings-page-layout-onhEgq-K.js} +1 -1
  161. package/dist/gateway/static/root/assets/setup-interaction-page-Cvvj6JyV.js +1 -0
  162. package/dist/gateway/static/root/assets/setup-status-panel-D4qgE7QM.js +1 -0
  163. package/dist/gateway/static/root/assets/share-link-dialog-DA0QuFOD.js +1 -0
  164. package/dist/gateway/static/root/assets/{share-preview-page-Cem96FbB.js → share-preview-page-YDpIY4dC.js} +1 -1
  165. package/dist/gateway/static/root/assets/{shares-api-Dowes16l.js → shares-api-D8Q-m46d.js} +1 -1
  166. package/dist/gateway/static/root/assets/shares-settings-DUvjOMmA.js +1 -0
  167. package/dist/gateway/static/root/assets/{skill-api-D8ZwFEVe.js → skill-api-uKU4sRiv.js} +1 -1
  168. package/dist/gateway/static/root/assets/{skill-list-api-B4gp00-f.js → skill-list-api-BzKzG-xG.js} +1 -1
  169. package/dist/gateway/static/root/assets/{skill-reload-api-ClmaaDXo.js → skill-reload-api-DkUXekcd.js} +1 -1
  170. package/dist/gateway/static/root/assets/skills-page-ClyNSh-7.js +2 -0
  171. package/dist/gateway/static/root/assets/{system-settings-panel-D095uacX.js → system-settings-panel-BN6sUX0H.js} +1 -1
  172. package/dist/gateway/static/root/assets/task-detail-page-CS9m7Ipo.js +2 -0
  173. package/dist/gateway/static/root/assets/{task-result-evidence-LUrJlUhb.js → task-result-evidence-DKygspo2.js} +1 -1
  174. package/dist/gateway/static/root/assets/{terminal-panel-store-BqEDB1Vl.js → terminal-panel-store-DJVC7HqA.js} +1 -1
  175. package/dist/gateway/static/root/assets/{theme-store-gAcojLgP.js → theme-store-Dlnmgryi.js} +1 -1
  176. package/dist/gateway/static/root/assets/tool-friendly-title-DcCc6g7o.js +1 -0
  177. package/dist/gateway/static/root/assets/tracing-settings-page-Bs76WeoF.js +1 -0
  178. package/dist/gateway/static/root/assets/{tunnel-api-C9u9E3UQ.js → tunnel-api-B7nx0NQJ.js} +1 -1
  179. package/dist/gateway/static/root/assets/{understanding-activity-store-BTrzsR6_.js → understanding-activity-store-C4bblRnQ.js} +1 -1
  180. package/dist/gateway/static/root/assets/{understanding-refresh-store-5Qava3jh.js → understanding-refresh-store-BvCj9-Ue.js} +1 -1
  181. package/dist/gateway/static/root/assets/{usage-page-DFMLYKAc.js → usage-page-anU5gslJ.js} +1 -1
  182. package/dist/gateway/static/root/assets/{use-autosave-3O-X7x15.js → use-autosave-YHxQ-UZg.js} +1 -1
  183. package/dist/gateway/static/root/assets/use-composer-attachments-DYY3Yz4a.js +2 -0
  184. package/dist/gateway/static/root/assets/use-file-preview-expanded-CYgWzDnv.js +2 -0
  185. package/dist/gateway/static/root/assets/{use-personal-profile-MusPgljM.js → use-personal-profile-D2Un8G1L.js} +1 -1
  186. package/dist/gateway/static/root/assets/{use-workspace-tree-Ck_U2yTw.js → use-workspace-tree-Dkg9tUr4.js} +1 -1
  187. package/dist/gateway/static/root/assets/user-model-page-DIgPL3tN.js +2 -0
  188. package/dist/gateway/static/root/assets/{voice-api-key-field-C5zJApoa.js → voice-api-key-field-BUes-Jlp.js} +1 -1
  189. package/dist/gateway/static/root/assets/{voice-config-api-DC1bYDt1.js → voice-config-api-CrULrSKC.js} +1 -1
  190. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-0SZjJdVV.js → voice-input-shortcut-events-DFMNIyy4.js} +1 -1
  191. package/dist/gateway/static/root/assets/voice-transcribe-api-Dy4hfftb.js +1 -0
  192. package/dist/gateway/static/root/assets/{work-discovery-overlay-DAQ8McVe.js → work-discovery-overlay-CFF4cRFl.js} +1 -1
  193. package/dist/gateway/static/root/assets/{work-discovery-page-DUQysEyb.js → work-discovery-page-BnYaVH3V.js} +1 -1
  194. package/dist/gateway/static/root/assets/working-directory-picker-modal-GFwVefVA.js +1 -0
  195. package/dist/gateway/static/root/assets/{workspace-api-ZrN6yUER.js → workspace-api-BdB4NEOh.js} +2 -2
  196. package/dist/gateway/static/root/assets/workspace-editor-agent-store-4cZ26iaD.js +1 -0
  197. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-Yj_kBWSb.js → workspace-file-preview-dialog-NRL3YRjg.js} +1 -1
  198. package/dist/gateway/static/root/assets/{workspace-open-location-menu-yxT7wajO.js → workspace-open-location-menu-Dcij7wvJ.js} +1 -1
  199. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-IcH9KDzx.js → xopc-cloud-account-card-DC9aG7Pl.js} +1 -1
  200. package/dist/gateway/static/root/index.html +100 -98
  201. package/dist/package.js +1 -1
  202. package/dist/packages/gateway-contract/src/automations.js +7 -0
  203. package/dist/packages/gateway-contract/src/capabilities.js +1 -1
  204. package/dist/src/agent/agent-manager.d.ts +1 -0
  205. package/dist/src/agent/agent-manager.js +1 -0
  206. package/dist/src/agent/child-agent-factory.js +1 -1
  207. package/dist/src/agent/data-acquisition/service.js +1 -1
  208. package/dist/src/agent/embedded/configuration-capability-correction.d.ts +3 -0
  209. package/dist/src/agent/embedded/configuration-capability-correction.js +14 -0
  210. package/dist/src/agent/embedded/run-for-session.js +20 -5
  211. package/dist/src/agent/embedded/run-turn.js +13 -1
  212. package/dist/src/agent/embedded/session-runner.js +6 -3
  213. package/dist/src/agent/image/generation/openai-images-provider.js +1 -1
  214. package/dist/src/agent/image/load-image-media.js +1 -1
  215. package/dist/src/agent/inbound/inbound-loop.js +4 -1
  216. package/dist/src/agent/independent-execution.js +1 -1
  217. package/dist/src/agent/mcp/config.js +1 -1
  218. package/dist/src/agent/mcp/connection-drafts.d.ts +3 -1
  219. package/dist/src/agent/mcp/connection-drafts.js +3 -2
  220. package/dist/src/agent/mcp/connection-setup.js +34 -2
  221. package/dist/src/agent/mcp/conversation-setup.d.ts +163 -0
  222. package/dist/src/agent/mcp/conversation-setup.js +621 -0
  223. package/dist/src/agent/mcp/native-mcp.d.ts +1 -0
  224. package/dist/src/agent/mcp/tool-catalog.d.ts +5 -0
  225. package/dist/src/agent/mcp/tool-catalog.js +19 -2
  226. package/dist/src/agent/mcp/weixin-setup-scope.d.ts +12 -0
  227. package/dist/src/agent/mcp/weixin-setup-scope.js +43 -0
  228. package/dist/src/agent/prompt/conversational-configuration-guide.js +2 -1
  229. package/dist/src/agent/prompt/sections/tooling.js +3 -2
  230. package/dist/src/agent/prompt/service-prompt-builder.js +1 -1
  231. package/dist/src/agent/service/direct-turn-helpers.js +1 -1
  232. package/dist/src/agent/service/process-direct-streaming.js +2 -2
  233. package/dist/src/agent/service.d.ts +2 -0
  234. package/dist/src/agent/service.js +11 -1
  235. package/dist/src/agent/service.types.d.ts +1 -0
  236. package/dist/src/agent/tasks/task-judge-service.js +2 -2
  237. package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +6 -4
  238. package/dist/src/agent/tool-manuals/xopc-configuration.js +92 -8
  239. package/dist/src/agent/tools/automation-tool.d.ts +9 -1
  240. package/dist/src/agent/tools/automation-tool.js +34 -5
  241. package/dist/src/agent/tools/create-share-tool.js +1 -1
  242. package/dist/src/agent/tools/factory.d.ts +3 -0
  243. package/dist/src/agent/tools/factory.js +34 -23
  244. package/dist/src/agent/tools/image-generate-tool.js +3 -3
  245. package/dist/src/agent/tools/index.d.ts +1 -0
  246. package/dist/src/agent/tools/index.js +5 -4
  247. package/dist/src/agent/tools/mcp-setup-tool.d.ts +9 -0
  248. package/dist/src/agent/tools/mcp-setup-tool.js +32 -0
  249. package/dist/src/agent/tools/personal-task-tool.js +2 -2
  250. package/dist/src/agent/tools/publish-artifacts.js +1 -1
  251. package/dist/src/agent/tools/read.js +1 -1
  252. package/dist/src/agent/tools/skill-install-tool.js +56 -1
  253. package/dist/src/agent/tools/skill-manage-tool.d.ts +4 -0
  254. package/dist/src/agent/tools/skill-manage-tool.js +74 -2
  255. package/dist/src/agent/tools/skills-tools.js +1 -1
  256. package/dist/src/agent/tools/task-collaboration-tool.js +1 -1
  257. package/dist/src/agent/tools/tool-manual-tool.d.ts +1 -1
  258. package/dist/src/agent/tools/tool-manual-tool.js +3 -1
  259. package/dist/src/agent/tools/toolExposure.js +2 -0
  260. package/dist/src/agent/tools/write.js +1 -1
  261. package/dist/src/agent/tools/xopc-use-tool.d.ts +4 -2
  262. package/dist/src/agent/tools/xopc-use-tool.js +60 -10
  263. package/dist/src/agent-catalog/service.d.ts +1 -1
  264. package/dist/src/agent-catalog/service.js +2 -1
  265. package/dist/src/automations/capabilities/drafts.js +5 -2
  266. package/dist/src/automations/capabilities/read.js +18 -7
  267. package/dist/src/automations/capabilities/write.d.ts +111 -52
  268. package/dist/src/automations/capabilities/write.js +44 -10
  269. package/dist/src/automations/delivery/delivery-router.d.ts +1 -0
  270. package/dist/src/automations/delivery/delivery-router.js +7 -1
  271. package/dist/src/automations/domain/types.d.ts +8 -0
  272. package/dist/src/automations/domain/validation.d.ts +24 -0
  273. package/dist/src/automations/domain/validation.js +7 -0
  274. package/dist/src/automations/draft/automation-draft-validator.d.ts +6 -0
  275. package/dist/src/automations/index.js +2 -2
  276. package/dist/src/automations/mcp-source.d.ts +60 -0
  277. package/dist/src/automations/mcp-source.js +173 -0
  278. package/dist/src/automations/service/action-executor.js +15 -1
  279. package/dist/src/automations/service/automation-service.d.ts +5 -0
  280. package/dist/src/automations/service/automation-service.js +52 -2
  281. package/dist/src/automations/service/index.js +2 -2
  282. package/dist/src/browser/setup/repository.d.ts +1 -0
  283. package/dist/src/browser/setup/repository.js +7 -1
  284. package/dist/src/browser/setup/service.d.ts +3 -0
  285. package/dist/src/browser/setup/service.js +41 -18
  286. package/dist/src/browser/setup/types.d.ts +1 -0
  287. package/dist/src/channels/attachments/voice-stt-webchat.js +1 -1
  288. package/dist/src/channels/index.js +1 -1
  289. package/dist/src/channels/manager.d.ts +1 -0
  290. package/dist/src/channels/outbound-sender.d.ts +1 -0
  291. package/dist/src/channels/outbound-sender.js +3 -0
  292. package/dist/src/channels/pairing/pairing-service.js +1 -1
  293. package/dist/src/channels/weixin/account-identity.d.ts +2 -0
  294. package/dist/src/channels/weixin/account-identity.js +15 -0
  295. package/dist/src/chat-commands/builtins/config.js +1 -1
  296. package/dist/src/cli/commands/backup.js +1 -1
  297. package/dist/src/cli/commands/channels.js +2 -2
  298. package/dist/src/cli/commands/doctor/checks/channel-pairing-pending.js +1 -1
  299. package/dist/src/cli/commands/mcp.js +1 -1
  300. package/dist/src/config/models-json.d.ts +12 -0
  301. package/dist/src/extensions/agent-plugins/credentials.js +1 -1
  302. package/dist/src/extensions/agent-plugins/setup.d.ts +1 -1
  303. package/dist/src/extensions/agent-plugins/setup.js +3 -3
  304. package/dist/src/extensions/api.js +1 -1
  305. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  306. package/dist/src/gateway/agents-admin.js +1 -1
  307. package/dist/src/gateway/device-routes.js +1 -1
  308. package/dist/src/gateway/global-defaults-admin.js +1 -1
  309. package/dist/src/gateway/hono/app.js +1 -1
  310. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  311. package/dist/src/gateway/hono/oauth-async.js +1 -1
  312. package/dist/src/gateway/hono/routes/channels.js +1 -1
  313. package/dist/src/gateway/hono/routes/config.js +1 -1
  314. package/dist/src/gateway/hono/routes/lazy-bundles.js +1 -1
  315. package/dist/src/gateway/hono/routes/mcp.js +39 -2
  316. package/dist/src/gateway/hono/routes/notes.js +2 -2
  317. package/dist/src/gateway/hono/routes/phone-setup.js +45 -16
  318. package/dist/src/gateway/hono/routes/phone.js +2 -4
  319. package/dist/src/gateway/hono/routes/projects.js +1 -1
  320. package/dist/src/gateway/hono/routes/provider-setup.js +1 -1
  321. package/dist/src/gateway/hono/routes/public-gateway.js +22 -0
  322. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  323. package/dist/src/gateway/hono/routes/shares.js +1 -1
  324. package/dist/src/gateway/hono/routes/site-shares.js +1 -1
  325. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  326. package/dist/src/gateway/media-access.js +1 -1
  327. package/dist/src/gateway/service/agent-runner.d.ts +1 -0
  328. package/dist/src/gateway/service/agent-runner.js +3 -1
  329. package/dist/src/gateway/service/config-coordinator.d.ts +1 -1
  330. package/dist/src/gateway/service/config-coordinator.js +2 -1
  331. package/dist/src/gateway/service/run-gateway-agent.js +1 -1
  332. package/dist/src/gateway/service/sessions-api.js +2 -1
  333. package/dist/src/gateway/service.d.ts +5 -1
  334. package/dist/src/gateway/service.js +86 -12
  335. package/dist/src/gateway/session-context-summary.js +1 -1
  336. package/dist/src/gateway/session-reset-service.d.ts +1 -0
  337. package/dist/src/gateway/session-reset-service.js +15 -2
  338. package/dist/src/gateway/xopc-cloud-capability-setup.js +9 -1
  339. package/dist/src/notes/service.js +1 -1
  340. package/dist/src/personal-agent/prompts.js +1 -1
  341. package/dist/src/personal-agent/reply-composer.js +2 -2
  342. package/dist/src/personal-agent/request-service.js +3 -3
  343. package/dist/src/personal-agent/service.js +1 -1
  344. package/dist/src/personal-agent/task-cancel.js +1 -1
  345. package/dist/src/phone/cloud-adb-connection.js +8 -5
  346. package/dist/src/phone/contracts.d.ts +4 -0
  347. package/dist/src/phone/contracts.js +6 -1
  348. package/dist/src/phone/gui-protocol.d.ts +7 -0
  349. package/dist/src/phone/gui-protocol.js +302 -0
  350. package/dist/src/phone/model-adapter.d.ts +1 -1
  351. package/dist/src/phone/model-adapter.js +7 -4
  352. package/dist/src/phone/runtime.js +8 -2
  353. package/dist/src/phone/setup/service.d.ts +14 -4
  354. package/dist/src/phone/setup/service.js +106 -28
  355. package/dist/src/phone/ui-dump-binary.d.ts +1 -1
  356. package/dist/src/phone/ui-dump-binary.js +1 -1
  357. package/dist/src/phone/ui-session.d.ts +2 -0
  358. package/dist/src/phone/ui-session.js +23 -4
  359. package/dist/src/projects/index.js +1 -1
  360. package/dist/src/projects/project-service.js +1 -1
  361. package/dist/src/providers/env-keys.js +2 -0
  362. package/dist/src/providers/index.js +11 -0
  363. package/dist/src/providers/model-catalog-types.d.ts +1 -1
  364. package/dist/src/providers/model-supplements.d.ts +1 -1
  365. package/dist/src/providers/model-supplements.js +6 -3
  366. package/dist/src/providers/phone-models.d.ts +3 -0
  367. package/dist/src/providers/phone-models.js +33 -0
  368. package/dist/src/providers/presentation.js +0 -1
  369. package/dist/src/runtime-tools/phone-dependencies.d.ts +2 -0
  370. package/dist/src/runtime-tools/phone-dependencies.js +10 -0
  371. package/dist/src/share/note-share-service.js +1 -1
  372. package/dist/src/share/site-proxy.js +1 -1
  373. package/dist/src/tasks/capabilities/write.js +1 -1
  374. package/dist/src/tasks/index.js +1 -1
  375. package/dist/src/tasks/task-allocation-service.js +3 -3
  376. package/dist/src/tasks/task-application-service.js +2 -2
  377. package/dist/src/tasks/task-context-assembler.js +1 -1
  378. package/dist/src/tasks/task-contract-planner.js +1 -1
  379. package/dist/src/tasks/task-handoff.js +1 -1
  380. package/dist/src/tasks/task-research-result.js +1 -1
  381. package/dist/src/tasks/task-run-coordinator.js +2 -2
  382. package/dist/src/tui/backends/embedded-backend.js +1 -1
  383. package/dist/src/tui/tui.js +1 -1
  384. package/dist/src/voice/platform-catalog.d.ts +1 -1
  385. package/package.json +3 -1
  386. package/skills/tools/configure-xopc/SKILL.md +10 -3
  387. package/skills/tools/configure-xopc/references/browser/chrome-extension.md +4 -1
  388. package/skills/tools/configure-xopc/references/browser/overview.md +2 -2
  389. package/skills/tools/configure-xopc/references/phone/aliyun.md +3 -2
  390. package/skills/tools/configure-xopc/references/phone/overview.md +2 -2
  391. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DlvjxWg6.js +0 -1
  392. package/dist/gateway/static/root/assets/agent-plugin-dialog-OBueuQSc.js +0 -1
  393. package/dist/gateway/static/root/assets/agents-Cp6_5OOQ.js +0 -77
  394. package/dist/gateway/static/root/assets/app-link-1j40sJ-z.js +0 -1
  395. package/dist/gateway/static/root/assets/apps-page-C2WKUwtN.js +0 -1
  396. package/dist/gateway/static/root/assets/attachment-load-qjPpQzYY.js +0 -1
  397. package/dist/gateway/static/root/assets/automation-task-card-wbnR5i6N.js +0 -3
  398. package/dist/gateway/static/root/assets/automations-workspace-D6cTOKr7.js +0 -9
  399. package/dist/gateway/static/root/assets/browser-settings-page-L0nBjfhG.js +0 -3
  400. package/dist/gateway/static/root/assets/capabilities-aT-QjNTl.js +0 -1
  401. package/dist/gateway/static/root/assets/capabilities-page-DlpuHdHi.js +0 -2
  402. package/dist/gateway/static/root/assets/capabilities-settings-panel-pvqkN2-2.js +0 -8
  403. package/dist/gateway/static/root/assets/channels-BUPtawh6.js +0 -1
  404. package/dist/gateway/static/root/assets/chat-page-BP0huA-W.js +0 -72
  405. package/dist/gateway/static/root/assets/composer-payload-handoff-CYIhcczq.js +0 -1
  406. package/dist/gateway/static/root/assets/confirm-dialog-XGclfBqe.js +0 -1
  407. package/dist/gateway/static/root/assets/connected-providers-grid-CKZfhHSD.js +0 -1
  408. package/dist/gateway/static/root/assets/connectors-page-Lf1ZzaVn.js +0 -1
  409. package/dist/gateway/static/root/assets/dependency-picker-UqKVJ9dv.js +0 -1
  410. package/dist/gateway/static/root/assets/device-pairing-wizard-ByEL5lvM.js +0 -1
  411. package/dist/gateway/static/root/assets/dist-CaUuvp8-.js +0 -1
  412. package/dist/gateway/static/root/assets/dist-D3lWNSe7.js +0 -1
  413. package/dist/gateway/static/root/assets/dist-DfWfZ9iu.js +0 -1
  414. package/dist/gateway/static/root/assets/dist-DusecO_p.js +0 -1
  415. package/dist/gateway/static/root/assets/gateway-realtime-store-Bkt1z-xo.js +0 -1
  416. package/dist/gateway/static/root/assets/home-page-k9LFXcVa.js +0 -2
  417. package/dist/gateway/static/root/assets/index-CpwPxKQ8.css +0 -1
  418. package/dist/gateway/static/root/assets/index-DKW7BeT_.js +0 -11
  419. package/dist/gateway/static/root/assets/install-connector-dialog-CTQAKTPv.js +0 -1
  420. package/dist/gateway/static/root/assets/local-app-workbench-page-CD_8_gd_.js +0 -1
  421. package/dist/gateway/static/root/assets/management-settings-t_Z2mCyw.js +0 -1
  422. package/dist/gateway/static/root/assets/messages-DG4HLOER.js +0 -3
  423. package/dist/gateway/static/root/assets/model-selector-a7PIT1Lk.js +0 -1
  424. package/dist/gateway/static/root/assets/note-detail-panel-BsHYUFgk.js +0 -5
  425. package/dist/gateway/static/root/assets/note-image-lightbox-B-bEtjhj.js +0 -1
  426. package/dist/gateway/static/root/assets/page-header-store-BdZnUh-D.js +0 -1
  427. package/dist/gateway/static/root/assets/personal-page-KJezmTKP.js +0 -1
  428. package/dist/gateway/static/root/assets/phone-settings-page-Cg_BPss4.js +0 -1
  429. package/dist/gateway/static/root/assets/plugin-details-dialog-DgibLkc3.js +0 -1
  430. package/dist/gateway/static/root/assets/project-detail-page-B_HlZux_.js +0 -7
  431. package/dist/gateway/static/root/assets/projects-page-CdfKjp95.js +0 -1
  432. package/dist/gateway/static/root/assets/route-preload-BtObM-co.js +0 -2
  433. package/dist/gateway/static/root/assets/session-manager-CtKgACGl.js +0 -23
  434. package/dist/gateway/static/root/assets/sessions-page-BAsKzRHt.js +0 -1
  435. package/dist/gateway/static/root/assets/settings-advanced-gate-CjAFqg2U.js +0 -1
  436. package/dist/gateway/static/root/assets/setup-status-panel-BpaPb625.js +0 -1
  437. package/dist/gateway/static/root/assets/share-link-dialog-CQJ6Ykm2.js +0 -1
  438. package/dist/gateway/static/root/assets/shares-settings-DZEkZDR0.js +0 -1
  439. package/dist/gateway/static/root/assets/skills-page-CV0X9rvG.js +0 -2
  440. package/dist/gateway/static/root/assets/task-detail-page-CY2C4AM2.js +0 -2
  441. package/dist/gateway/static/root/assets/tool-friendly-title-o6sxGVUu.js +0 -1
  442. package/dist/gateway/static/root/assets/tracing-settings-page-B1ZRh-Is.js +0 -1
  443. package/dist/gateway/static/root/assets/use-composer-attachments-BLc4dBfe.js +0 -2
  444. package/dist/gateway/static/root/assets/use-file-preview-expanded-BaOmTXsT.js +0 -2
  445. package/dist/gateway/static/root/assets/user-model-page-Den5Lg-k.js +0 -2
  446. package/dist/gateway/static/root/assets/voice-transcribe-api-CxVeANPX.js +0 -1
  447. package/dist/gateway/static/root/assets/working-directory-picker-modal-BO9qdJyZ.js +0 -1
  448. package/dist/gateway/static/root/assets/workspace-editor-agent-store-Bo5dwoWP.js +0 -1
@@ -1,4 +1,4 @@
1
- import{i as e,n as t,t as n}from"./rolldown-runtime-aKtaBQYM.js";import{a as r,i,n as a,t as o}from"./vendor-react-BOUWij0V.js";import{n as s}from"./locale-store-Bg_XR36n.js";import{t as c}from"./messages-DG4HLOER.js";import{a as l,c as u,d,f,h as p,i as m,l as h,m as g,n as _,o as v,p as y,r as b,s as x,t as S,u as C}from"./unlink-BEuthaaq.js";import{t as w}from"./check-DUBLcKHA.js";import{t as T}from"./copy-Dv6d4Dvw.js";import{t as E}from"./external-link-DjqjBmc3.js";import{A as D,D as O,F as k,N as A,j,k as ee}from"./notes-api-BSmikUKI.js";import{t as te}from"./list-todo-CTVRto8O.js";import{t as ne}from"./loader-circle-CifKLtgG.js";import{C as re,G as ie,S as ae,T as oe,_ as se,b as ce,r as le,t as ue,v as de,w as fe,x as pe}from"./markdown-view-BUpXJUPv.js";import{t as me}from"./mic-CuUb7zc-.js";import{t as he}from"./pause-DuPxgSxk.js";import{t as ge}from"./pencil-DmIY3Oa-.js";import{t as _e}from"./play-kxZvpBg8.js";import{t as ve}from"./cn-0WouolD0.js";import{a as ye,d as be,i as xe,l as Se,n as Ce,o as we,r as Te,s as Ee,t as De,u as Oe}from"./floating-ui.dom-seOukHzT.js";import{s as ke}from"./vendor-swr-CdRzEUwF.js";import{t as Ae}from"./copy-to-clipboard-HOJ79TWv.js";import{S as je,x as Me}from"./vendor-codemirror-aCQ0FcJT.js";import{t as Ne}from"./with-selector-xonYxPoM.js";import"./note-image-lightbox-B-bEtjhj.js";var M=e(r(),1),Pe=e(i(),1),N=o(),Fe=ke(),Ie=Object.defineProperty,Le=(e,t)=>{let n={};for(var r in e)Ie(n,r,{get:e[r],enumerable:!0});return t||Ie(n,Symbol.toStringTag,{value:`Module`}),n};function P(e){this.content=e}P.prototype={constructor:P,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new P(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new P(n)},addToStart:function(e,t){return new P([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new P(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new P(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=P.from(e),e.size?new P(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=P.from(e),e.size?new P(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=P.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},P.from=function(e){if(e instanceof P)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new P(t)};function Re(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&Ve(e.charCodeAt(r-1))&&Be(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=Re(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function ze(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&Ve(e.charCodeAt(i-1))&&Be(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=ze(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function Be(e){return e>=56320&&e<57344}function Ve(e){return e>=55296&&e<56320}var F=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Re(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return ze(this,e,t,n)}findIndex(e){if(e==0)return Ue(0,e);if(e==this.size)return Ue(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?Ue(t+1,i):Ue(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};F.empty=new F([],0);var He={index:0,offset:0};function Ue(e,t){return He.index=e,He.offset=t,He}function We(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!We(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!We(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var I=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&We(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};I.none=[];var Ge=class extends Error{},L=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=qe(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Ke(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(F.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};L.empty=new L(F.empty,0,0);function Ke(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Ke(a.content,t-i-1,n-i-1)))}function qe(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=qe(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function Je(e,t,n){if(n.openStart>e.depth)throw new Ge(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Ge(`Inconsistent open depths`);return Ye(e,t,n,0)}function Ye(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=Ye(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return et(a,nt(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return et(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=rt(n,e);return et(a,tt(e,i,o,t,r))}}function Xe(e,t){if(!t.type.compatibleContent(e.type))throw new Ge(`Cannot join `+t.type.name+` onto `+e.type.name)}function Ze(e,t,n){let r=e.node(n);return Xe(r,t.node(n)),r}function Qe(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function $e(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Qe(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Qe(i.child(e),r);t&&t.depth==n&&t.textOffset&&Qe(t.nodeBefore,r)}function et(e,t){if(!e.type.validContent(t))throw new Ge(`Invalid content for node `+e.type.name);return e.copy(t)}function tt(e,t,n,r,i){let a=e.depth>i&&Ze(e,t,i+1),o=r.depth>i&&Ze(n,r,i+1),s=[];return $e(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Xe(a,o),Qe(et(a,tt(e,t,n,r,i+1)),s)):(a&&Qe(et(a,nt(e,t,i+1)),s),$e(t,n,i,s),o&&Qe(et(o,nt(n,r,i+1)),s)),$e(r,null,i,s),new F(s)}function nt(e,t,n){let r=[];return $e(null,e,n,r),e.depth>n&&Qe(et(Ze(e,t,n+1),nt(e,t,n+1)),r),$e(t,null,n,r),new F(r)}function rt(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(F.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var it=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return I.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new ct(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=st.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else st.set(t,r=new at);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%ot,i}},at=class{constructor(){this.elts=[],this.i=0}},ot=12,st=new WeakMap,ct=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},lt=Object.create(null),ut=class e{constructor(e,t,n,r=I.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||F.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&We(this.attrs,t||e.defaultAttrs||lt)&&I.sameSet(this.marks,n||I.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return L.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new L(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Je(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return it.resolveCached(this,e)}resolveNoCache(e){return it.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),ft(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=F.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=I.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!I.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=F.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};ut.prototype.text=void 0;var dt=class e extends ut{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ft(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function ft(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var pt=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new mt(t,n);if(r.next==null)return e.empty;let i=ht(r);r.next&&r.err(`Unexpected trailing text`);let a=Tt(St(i));return Et(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return F.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
1
+ import{i as e,n as t,t as n}from"./rolldown-runtime-aKtaBQYM.js";import{a as r,i,n as a,t as o}from"./vendor-react-BOUWij0V.js";import{n as s}from"./locale-store-Br7IfbXK.js";import{t as c}from"./messages-ByFlEbsu.js";import{a as l,c as u,d,f,h as p,i as m,l as h,m as g,n as _,o as v,p as y,r as b,s as x,t as S,u as C}from"./unlink-BEuthaaq.js";import{t as w}from"./check-DUBLcKHA.js";import{t as T}from"./copy-Dv6d4Dvw.js";import{t as E}from"./external-link-DjqjBmc3.js";import{A as D,D as O,F as k,N as A,j,k as ee}from"./notes-api-8kp0X1x6.js";import{t as te}from"./list-todo-CTVRto8O.js";import{t as ne}from"./loader-circle-CifKLtgG.js";import{C as re,G as ie,S as ae,T as oe,_ as se,b as ce,r as le,t as ue,v as de,w as fe,x as pe}from"./markdown-view-Ck5s16p9.js";import{t as me}from"./mic-CuUb7zc-.js";import{t as he}from"./pause-DuPxgSxk.js";import{t as ge}from"./pencil-DmIY3Oa-.js";import{t as _e}from"./play-kxZvpBg8.js";import{t as ve}from"./cn-0WouolD0.js";import{s as ye}from"./vendor-swr-CdRzEUwF.js";import{a as be,d as xe,i as Se,l as Ce,n as we,o as Te,r as Ee,s as De,t as Oe,u as ke}from"./floating-ui.dom-seOukHzT.js";import{t as Ae}from"./copy-to-clipboard-HOJ79TWv.js";import{S as je,x as Me}from"./vendor-codemirror-aCQ0FcJT.js";import{t as Ne}from"./with-selector-xonYxPoM.js";import"./note-image-lightbox-BFKZ7qJr.js";var M=e(r(),1),Pe=e(i(),1),N=o(),Fe=ye(),Ie=Object.defineProperty,Le=(e,t)=>{let n={};for(var r in e)Ie(n,r,{get:e[r],enumerable:!0});return t||Ie(n,Symbol.toStringTag,{value:`Module`}),n};function P(e){this.content=e}P.prototype={constructor:P,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new P(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new P(n)},addToStart:function(e,t){return new P([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new P(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new P(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=P.from(e),e.size?new P(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=P.from(e),e.size?new P(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=P.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},P.from=function(e){if(e instanceof P)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new P(t)};function Re(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&Ve(e.charCodeAt(r-1))&&Be(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=Re(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function ze(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&Ve(e.charCodeAt(i-1))&&Be(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=ze(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function Be(e){return e>=56320&&e<57344}function Ve(e){return e>=55296&&e<56320}var F=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Re(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return ze(this,e,t,n)}findIndex(e){if(e==0)return Ue(0,e);if(e==this.size)return Ue(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?Ue(t+1,i):Ue(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};F.empty=new F([],0);var He={index:0,offset:0};function Ue(e,t){return He.index=e,He.offset=t,He}function We(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!We(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!We(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var I=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&We(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};I.none=[];var Ge=class extends Error{},L=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=qe(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Ke(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(F.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};L.empty=new L(F.empty,0,0);function Ke(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Ke(a.content,t-i-1,n-i-1)))}function qe(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=qe(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function Je(e,t,n){if(n.openStart>e.depth)throw new Ge(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Ge(`Inconsistent open depths`);return Ye(e,t,n,0)}function Ye(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=Ye(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return et(a,nt(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return et(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=rt(n,e);return et(a,tt(e,i,o,t,r))}}function Xe(e,t){if(!t.type.compatibleContent(e.type))throw new Ge(`Cannot join `+t.type.name+` onto `+e.type.name)}function Ze(e,t,n){let r=e.node(n);return Xe(r,t.node(n)),r}function Qe(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function $e(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Qe(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Qe(i.child(e),r);t&&t.depth==n&&t.textOffset&&Qe(t.nodeBefore,r)}function et(e,t){if(!e.type.validContent(t))throw new Ge(`Invalid content for node `+e.type.name);return e.copy(t)}function tt(e,t,n,r,i){let a=e.depth>i&&Ze(e,t,i+1),o=r.depth>i&&Ze(n,r,i+1),s=[];return $e(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Xe(a,o),Qe(et(a,tt(e,t,n,r,i+1)),s)):(a&&Qe(et(a,nt(e,t,i+1)),s),$e(t,n,i,s),o&&Qe(et(o,nt(n,r,i+1)),s)),$e(r,null,i,s),new F(s)}function nt(e,t,n){let r=[];return $e(null,e,n,r),e.depth>n&&Qe(et(Ze(e,t,n+1),nt(e,t,n+1)),r),$e(t,null,n,r),new F(r)}function rt(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(F.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var it=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return I.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new ct(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=st.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else st.set(t,r=new at);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%ot,i}},at=class{constructor(){this.elts=[],this.i=0}},ot=12,st=new WeakMap,ct=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},lt=Object.create(null),ut=class e{constructor(e,t,n,r=I.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||F.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&We(this.attrs,t||e.defaultAttrs||lt)&&I.sameSet(this.marks,n||I.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return L.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new L(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Je(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return it.resolveCached(this,e)}resolveNoCache(e){return it.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),ft(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=F.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=I.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!I.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=F.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};ut.prototype.text=void 0;var dt=class e extends ut{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ft(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function ft(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var pt=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new mt(t,n);if(r.next==null)return e.empty;let i=ht(r);r.next&&r.err(`Unexpected trailing text`);let a=Tt(St(i));return Et(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return F.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
2
2
  `)}};pt.empty=new pt(!0);var mt=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function ht(e){let t=[];do t.push(gt(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function gt(e){let t=[];do t.push(_t(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function _t(e){let t=xt(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=yt(e,t);else break;return t}function vt(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function yt(e,t){let n=vt(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:vt(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function bt(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function xt(e){if(e.eat(`(`)){let t=ht(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=bt(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function St(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function Ct(e,t){return t-e}function wt(e,t){let n=[];return r(t),n.sort(Ct);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function Tt(e){let t=Object.create(null);return n(wt(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);wt(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new pt(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Ct);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Et(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function Dt(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Ot(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function kt(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}function At(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Nt(e,r,t[r]);return n}var jt=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=At(e,n.attrs),this.defaultAttrs=Dt(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==pt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ot(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new ut(this,this.computeAttrs(e),F.from(t),I.setFrom(n))}createChecked(e=null,t,n){return t=F.from(t),this.checkContent(t),new ut(this,this.computeAttrs(e),t,I.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=F.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(F.empty,!0);return i?new ut(this,e,t.append(i),I.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){kt(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:I.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Mt(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Nt=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Mt(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Pt=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=At(e,r.attrs),this.excluded=null;let i=Dt(this.attrs);this.instance=i?new I(this,i):null}create(e=null){return!e&&this.instance?this.instance:new I(this,Ot(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){kt(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},Ft=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=P.from(e.nodes),t.marks=P.from(e.marks||{}),this.nodes=jt.compile(this.spec.nodes,this),this.marks=Pt.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=pt.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?It(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:It(this,n.split(` `))}this.nodeFromJSON=e=>ut.fromJSON(this,e),this.markFromJSON=e=>I.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof jt))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new dt(n,n.defaultAttrs,e,I.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function It(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function Lt(e){return e.tag!=null}function Rt(e){return e.style!=null}var zt=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(Lt(e))this.tags.push(e);else if(Rt(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new Jt(this,t,!1);return n.addAll(e,I.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Jt(this,t,!0);return n.addAll(e,I.none,t.from,t.to),L.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Xt(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Zt(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Zt(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},Bt={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Vt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ht={ol:!0,ul:!0},Ut=1,Wt=2,Gt=4;function Kt(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?Ut:0)|(t===`full`?Wt:0)}var qt=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=I.none,this.match=i||(a&Gt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(F.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ut)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=F.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(F.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Bt.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Jt=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=Kt(null,t.preserveWhitespace,0)|(n?Gt:0);i=r?new qt(r.type,r.attrs,I.none,!0,t.topMatch||r.type.contentMatch,a):n?new qt(null,null,I.none,!0,null,a):new qt(e.schema.topNodeType,null,I.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&Wt?`full`:this.localPreserveWS||(r.options&Ut)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
3
3
  `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;Ht.hasOwnProperty(a)&&this.parser.normalizeLists&&Yt(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:Vt.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(Bt.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
4
  `),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=I.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):Qt(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=Kt(e,i,a.options);a.options&Gt&&a.content.length==0&&(o|=Gt);let s=I.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):Qt(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new qt(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=Ut);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function Yt(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&Ht.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Xt(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Zt(e){let t={};for(let n in e)t[n]=e[n];return t}function Qt(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var $t=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=tn(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return tn(t).createTextNode(e.text);let{dom:n,contentDOM:r}=on(tn(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&on(tn(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:on(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=en(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return en(e.marks)}};function en(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function tn(e){return e.document||window.document}var nn=new WeakMap;function rn(e){let t=nn.get(e);return t===void 0&&nn.set(e,t=an(e)),t}function an(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function on(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=rn(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=on(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var sn=a(),cn=65535,ln=2**16;function un(e,t){return e+t*ln}function dn(e){return e&cn}function fn(e){return(e-(e&cn))/ln}var pn=1,mn=2,hn=4,gn=8,_n=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&gn)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&hn)>0}},vn=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=dn(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+fn(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:un(o/3,e-s),f=e==s?mn:e==u?pn:hn;return(t<0?e!=s:e!=u)&&(f|=gn),new _n(a,f,d)}r+=l-c}return n?e+r:new _n(e+r,0,null)}touches(e,t){let n=0,r=dn(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};vn.empty=new vn([]);var yn=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new _n(e,r,null)}},bn=Object.create(null),xn=class{getMap(){return vn.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=bn[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in bn)throw RangeError(`Duplicate use of step JSON ID `+e);return bn[e]=t,t.prototype.jsonID=e,t}},Sn=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof Ge)return e.fail(t.message);throw t}}};function Cn(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(Cn(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return F.fromArray(r)}var wn=class e extends xn{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new L(Cn(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return Sn.fromReplace(e,this.from,this.to,i)}invert(){return new Tn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};xn.jsonID(`addMark`,wn);var Tn=class e extends xn{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new L(Cn(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return Sn.fromReplace(e,this.from,this.to,n)}invert(){return new wn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};xn.jsonID(`removeMark`,Tn);var En=class e extends xn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Sn.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Sn.fromReplace(e,this.pos,this.pos+1,new L(F.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new Dn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};xn.jsonID(`addNodeMark`,En);var Dn=class e extends xn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Sn.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Sn.fromReplace(e,this.pos,this.pos+1,new L(F.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new En(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};xn.jsonID(`removeNodeMark`,Dn);var On=class e extends xn{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&An(e,this.from,this.to)?Sn.fail(`Structure replace would overwrite content`):Sn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new vn([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?L.empty:new L(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?L.empty:new L(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,L.fromJSON(t,n.slice),!!n.structure)}};On.MAP_BIAS=1,xn.jsonID(`replace`,On);var kn=class e extends xn{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(An(e,this.from,this.gapFrom)||An(e,this.gapTo,this.to)))return Sn.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Sn.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?Sn.fromReplace(e,this.from,this.to,n):Sn.fail(`Content does not fit in gap`)}getMap(){return new vn([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,L.fromJSON(t,n.slice),n.insert,!!n.structure)}};xn.jsonID(`replaceAround`,kn);function An(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function jn(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new Tn(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new wn(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function Mn(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof Pt){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new Tn(t.from,t.to,t.style)))}function Nn(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new On(s,l,L.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new Tn(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new L(F.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new On(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(F.empty,!0);e.replace(s,s,new L(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Pn(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Fn(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Pn(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function In(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=F.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=F.from(r.node(e).copy(u)),d++):c--;let f=F.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=F.from(i.node(e).copy(f)),p++):l++;e.step(new kn(c,l,o,s,new L(u.append(f),d,p),u.size-d,!0))}function Ln(e,t,n=null,r=e){let i=zn(e,t),a=i&&Bn(r,t);return a?i.map(Rn).concat({type:t,attrs:n}).concat(a.map(Rn)):null}function Rn(e){return{type:e,attrs:null}}function zn(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function Bn(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function Vn(e,t,n){let r=F.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=F.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new kn(i,a,i,a,new L(r,0,0),n.length,!0))}function Hn(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Gn(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&Wn(e,t,n,a),Nn(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new kn(c,l,c+1,l-1,new L(F.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Un(e,t,n,a),!1}})}function Un(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function Wn(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
@@ -157,4 +157,4 @@ ${t.innerHTML}
157
157
  `?t:t[t.length-1]===`
158
158
  `?t.slice(0,-1):t};return e.renderer.rules.hardbreak=t(e.renderer.rules.hardbreak),e.renderer.rules.softbreak=t(e.renderer.rules.softbreak),e.renderer.rules.fence=t(e.renderer.rules.fence),e.renderer.rules.code_block=t(e.renderer.rules.code_block),e.renderer.renderToken=t(e.renderer.renderToken.bind(e.renderer)),e}},GT=q.create({name:`markdownClipboard`,addOptions(){return{transformPastedText:!1,transformCopiedText:!1}},addProseMirrorPlugins(){return[new V({key:new H(`markdownClipboard`),props:{clipboardTextParser:(e,t,n)=>{if(n||!this.options.transformPastedText)return null;let r=this.editor.storage.markdown.parser.parse(e,{inline:!0});return zt.fromSchema(this.editor.schema).parseSlice(vT(r),{preserveWhitespace:!0,context:t})},clipboardTextSerializer:e=>this.options.transformCopiedText?this.editor.storage.markdown.serializer.serialize(e.content):null}})]}}),KT=q.create({name:`markdown`,priority:50,addOptions(){return{html:!0,tightLists:!0,tightListClass:`tight`,bulletListMarker:`-`,linkify:!1,breaks:!1,transformPastedText:!1,transformCopiedText:!1}},addCommands(){let e=op.Commands.config.addCommands();return{setContent:(t,n)=>r=>e.setContent(r.editor.storage.markdown.parser.parse(t),n)(r),insertContentAt:(t,n,r)=>i=>e.insertContentAt(t,i.editor.storage.markdown.parser.parse(n,{inline:!0}),r)(i)}},onBeforeCreate(){this.editor.storage.markdown={options:{...this.options},parser:new WT(this.editor,this.options),serializer:new UT(this.editor),getMarkdown:()=>this.editor.storage.markdown.serializer.serialize(this.editor.state.doc)},this.editor.options.initialContent=this.editor.options.content,this.editor.options.content=this.editor.storage.markdown.parser.parse(this.editor.options.content)},onCreate(){this.editor.options.content=this.editor.options.initialContent,delete this.editor.options.initialContent},addStorage(){return{}},addExtensions(){return[cT.configure({tight:this.options.tightLists,tightClass:this.options.tightListClass}),GT.configure({transformPastedText:this.options.transformPastedText,transformCopiedText:this.options.transformCopiedText})]}}),qT={heading:{levels:[1,2,3,4]},link:!1,underline:!1},JT={nested:!0},YT={autolink:!0,protocols:[`xopc`],openOnClick:!1,enableClickSelection:!0},XT={html:!0,transformCopiedText:!0,transformPastedText:!0};function ZT(e){let t=e.storage.markdown;if(!t?.getMarkdown)throw Error(`The note editor requires the Markdown extension`);return t.getMarkdown()}var QT=[1,1.5,2];function $T(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${String(n).padStart(2,`0`)}`}function eE(e){let t=(0,sn.c)(63),{noteId:n,attachment:r,transcript:i,className:a}=e,{playing:o,loading:s,currentTime:c,duration:l,noteId:u,attachmentId:d}=j(),f=j(nE),p=j(tE),m=u===n&&d===r.id,h=m&&o,g=m&&s,_=m?c:0,v=m&&l>0?l:r.duration??0,y=v>0?Math.min(_/v*100,100):0,[b,x]=(0,M.useState)(0),S=(0,M.useRef)(null),C;t[0]!==r.duration||t[1]!==r.id||t[2]!==n||t[3]!==f?(C=()=>{f(n,r.id,r.duration)},t[0]=r.duration,t[1]=r.id,t[2]=n,t[3]=f,t[4]=C):C=t[4];let w=C,T;t[5]===p?T=t[6]:(T=e=>{let t=Number(e.target.value);p(t)},t[5]=p,t[6]=T);let E=T,D;t[7]===b?D=t[8]:(D=()=>{let e=(b+1)%QT.length;x(e)},t[7]=b,t[8]=D);let O=D,k;t[9]!==m||t[10]!==b?(k=()=>{if(!m)return;let e=document.querySelector(`audio`);e&&(e.playbackRate=QT[b])},t[9]=m,t[10]=b,t[11]=k):k=t[11];let A;t[12]!==m||t[13]!==h||t[14]!==b?(A=[b,m,h],t[12]=m,t[13]=h,t[14]=b,t[15]=A):A=t[15],(0,M.useEffect)(k,A);let ee;t[16]===a?ee=t[17]:(ee=ve(`flex flex-col gap-3 rounded-xl border border-edge bg-surface-panel p-4`,a),t[16]=a,t[17]=ee);let te;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,N.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-full bg-accent/10`,children:(0,N.jsx)(me,{className:`size-5 text-accent`})}),t[18]=te):te=t[18];let re=h?`bg-accent text-on-accent`:`bg-accent/10 text-accent hover:bg-accent/20`,ie;t[19]===re?ie=t[20]:(ie=ve(`flex size-8 shrink-0 items-center justify-center rounded-full transition-colors`,re),t[19]=re,t[20]=ie);let ae=h?`Pause`:`Play`,oe;t[21]!==g||t[22]!==h?(oe=g?(0,N.jsx)(ne,{className:`size-4 animate-spin`}):h?(0,N.jsx)(he,{className:`size-4`}):(0,N.jsx)(_e,{className:`size-4 ml-0.5`}),t[21]=g,t[22]=h,t[23]=oe):oe=t[23];let se;t[24]!==w||t[25]!==ae||t[26]!==oe||t[27]!==ie?(se=(0,N.jsx)(`button`,{type:`button`,onClick:w,className:ie,"aria-label":ae,children:oe}),t[24]=w,t[25]=ae,t[26]=oe,t[27]=ie,t[28]=se):se=t[28];let ce=v||1,le=`linear-gradient(to right, var(--color-accent) ${y}%, var(--color-accent-alpha-10, rgba(59,130,246,0.1)) ${y}%)`,ue;t[29]===le?ue=t[30]:(ue={background:le},t[29]=le,t[30]=ue);let de;t[31]!==E||t[32]!==_||t[33]!==ce||t[34]!==ue?(de=(0,N.jsx)(`input`,{ref:S,type:`range`,min:0,max:ce,step:.1,value:_,onChange:E,className:`voice-progress-range h-1.5 w-full cursor-pointer appearance-none rounded-full bg-accent/10 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-accent`,style:ue}),t[31]=E,t[32]=_,t[33]=ce,t[34]=ue,t[35]=de):de=t[35];let fe;t[36]===_?fe=t[37]:(fe=$T(_),t[36]=_,t[37]=fe);let pe;t[38]===fe?pe=t[39]:(pe=(0,N.jsx)(`span`,{children:fe}),t[38]=fe,t[39]=pe);let ge;t[40]===v?ge=t[41]:(ge=$T(v),t[40]=v,t[41]=ge);let ye;t[42]===ge?ye=t[43]:(ye=(0,N.jsx)(`span`,{children:ge}),t[42]=ge,t[43]=ye);let be;t[44]!==pe||t[45]!==ye?(be=(0,N.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] tabular-nums text-fg-muted`,children:[pe,ye]}),t[44]=pe,t[45]=ye,t[46]=be):be=t[46];let xe;t[47]!==de||t[48]!==be?(xe=(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[de,be]}),t[47]=de,t[48]=be,t[49]=xe):xe=t[49];let Se=QT[b],Ce;t[50]!==O||t[51]!==Se?(Ce=(0,N.jsxs)(`button`,{type:`button`,onClick:O,className:`shrink-0 rounded-md px-1.5 py-0.5 text-[11px] font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,"aria-label":`Playback speed`,children:[Se,`x`]}),t[50]=O,t[51]=Se,t[52]=Ce):Ce=t[52];let we;t[53]!==se||t[54]!==xe||t[55]!==Ce?(we=(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[te,(0,N.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[se,xe,Ce]})})]}),t[53]=se,t[54]=xe,t[55]=Ce,t[56]=we):we=t[56];let Te;t[57]===i?Te=t[58]:(Te=i&&(0,N.jsx)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2`,children:(0,N.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:i})}),t[57]=i,t[58]=Te);let Ee;return t[59]!==we||t[60]!==Te||t[61]!==ee?(Ee=(0,N.jsxs)(`div`,{className:ee,children:[we,Te]}),t[59]=we,t[60]=Te,t[61]=ee,t[62]=Ee):Ee=t[62],Ee}function tE(e){return e.seek}function nE(e){return e.toggle}function rE(e){let t=(0,sn.c)(11),{node:n}=e,{href:r,label:i}=n.attrs,a;t[0]===r?a=t[1]:(a=A(r),t[0]=r,t[1]=a);let o=a;if(!o){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,N.jsx)(Im,{as:`span`,className:`inline text-fg-muted italic text-sm`,children:`[audio unavailable]`}),t[2]=e):e=t[2],e}let s;t[3]===i?s=t[4]:(s=i?.match(/(\d+):(\d+)/),t[3]=i,t[4]=s);let c=s,l=c?Number(c[1])*60+Number(c[2]):void 0,u;t[5]!==l||t[6]!==o.attachmentId?(u={id:o.attachmentId,type:`audio`,mimeType:`audio/webm`,fileName:``,size:0,relativePath:``,duration:l},t[5]=l,t[6]=o.attachmentId,t[7]=u):u=t[7];let d=u,f;return t[8]!==d||t[9]!==o.noteId?(f=(0,N.jsx)(Im,{className:`my-3`,children:(0,N.jsx)(eE,{noteId:o.noteId,attachment:d,className:`max-w-md`})}),t[8]=d,t[9]=o.noteId,t[10]=f):f=t[10],f}var iE=/^\[([^\]]*)\]\((xopc-attachment:\/\/notes\/[^)]+)\)$/,aE=J.create({name:`audioAttachment`,group:`block`,atom:!0,draggable:!1,selectable:!0,addAttributes(){return{href:{default:null},label:{default:null}}},parseHTML(){return[{tag:`a[data-audio-attachment]`,getAttrs:e=>typeof e!=`string`&&{href:e.getAttribute(`href`),label:e.textContent}}]},renderHTML({HTMLAttributes:e}){return[`a`,K(e,{"data-audio-attachment":``}),e.label||`Audio`]},addNodeView(){return Xm(rE)},addProseMirrorPlugins(){let e=this.type;return[new V({key:new H(`audioAttachmentTransform`),appendTransaction(t,n,r){let{tr:i}=r,a=!1;return r.doc.descendants((t,n)=>{if(t.type.name!==`paragraph`||t.childCount!==1)return;let r=t.firstChild;if(!r||r.type.name!==`text`)return;let o=r.text??``,s=o.match(iE);if(s){let r=s[1],o=s[2];if(o.includes(`xopc-attachment://notes/`)){let s=e.create({href:o,label:r});i.replaceWith(n,n+t.nodeSize,s),a=!0;return}}let c=r.marks.find(e=>e.type.name===`link`&&typeof e.attrs.href==`string`&&e.attrs.href.includes(`xopc-attachment://notes/`));if(c){let r=e.create({href:c.attrs.href,label:o});i.replaceWith(n,n+t.nodeSize,r),a=!0}}),a?i:null}})]}}),oE=new WeakSet;function sE(e,t={}){if(oE.has(e))return;oE.add(e),e.inline.ruler.before(`escape`,`xopc_math_inline`,(e,t)=>{let n=re(e.src,e.pos);if(!n)return!1;if(!t){let t=e.push(`xopc_math`,``,0);t.meta=n,t.content=n.raw}return e.pos=n.range.end,!0}),e.block.ruler.before(`fence`,`xopc_math_block`,(e,t,n,r)=>{if(e.sCount[t]-e.blkIndent>=4)return!1;let i=t+1;for(;i<n&&(e.isEmpty(i)||e.sCount[i]>=e.blkIndent);)i++;let a=e.getLines(t,i,e.blkIndent,!1),o=ae(a)??fe(a);if(!o)return!1;if(r)return!0;let s=a.slice(0,o.range.end).split(`
159
159
  `).length;e.line=Math.min(i,t+s);let c=e.push(`xopc_math`,``,0);return c.block=!0,c.map=[t,e.line],c.meta=o,!0},{alt:[`paragraph`,`reference`,`blockquote`,`list`]});let n=(e,n)=>t.placeholder?pe(e):(n.xopcMathCount=(n.xopcMathCount??0)+1,le(e,{streaming:n.streaming??!1},n.xopcMathCount>256));e.renderer.rules.xopc_math=(e,t,r,i={})=>n(e[t].meta,i);let r=e.renderer.rules.image;e.renderer.rules.image=(e,t,n,i,a)=>{for(let n of e[t].children??[])n.type===`xopc_math`&&(n.type=`text`);return r(e,t,n,i,a)};let i=e.renderer.rules.fence;e.renderer.rules.fence=(e,t,r,a={},o)=>{let s=e[t];if(s.info.trim()!==`math`)return i(e,t,r,a,o);let c=`${s.markup}math\n${s.content}${s.markup}`;return n(ce(c,s.content),a)}}function cE(e){let t=(0,sn.c)(7),{node:n,updateAttributes:r}=e,i=s(uE),a;t[0]===i?a=t[1]:(a=c(i),t[0]=i,t[1]=a);let o=a.chat,l=se(String(n.attrs.source)),[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)(l?.latex??``);if(!l){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,N.jsx)(Im,{children:`LaTeX`}),t[2]=e):e=t[2],e}let m=()=>{let e;if(l.delimiter===`math-fence`){let t=l.raw.match(/^ {0,3}(`{3,}|~{3,})/)?.[1]??"```",n=t[0].repeat(Math.max(t.length,...Array.from(f.matchAll(t[0]==="`"?/`+/g:/~+/g),lE)));e=`${n}math\n${f}\n${n}`}else{let[t,n]=l.delimiter===`paren`?[`\\(`,`\\)`]:l.delimiter===`dollar`?[`$`,`$`]:l.delimiter===`bracket`?[`\\[`,`\\]`]:[`$$`,`$$`];e=l.display?`${t}\n${f}\n${n}`:`${t}${f}${n}`}r({source:de({...l,latex:f,raw:e,state:`complete`,range:{start:0,end:e.length}})}),d(!1)},h=Im,g=l.display?`div`:`span`,_=u?(0,N.jsxs)(`span`,{className:`block-editor-math-edit`,children:[(0,N.jsx)(`textarea`,{"aria-label":`LaTeX`,value:f,onChange:e=>p(e.target.value)}),(0,N.jsx)(`button`,{type:`button`,onClick:m,children:o.mathSave}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>d(!1),children:o.mathCancel})]}):(0,N.jsx)(`span`,{role:`button`,tabIndex:0,"aria-label":`LaTeX`,onClick:()=>{p(l.latex),d(!0)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),p(l.latex),d(!0))},dangerouslySetInnerHTML:{__html:le(l)}}),v;return t[3]!==h||t[4]!==g||t[5]!==_?(v=(0,N.jsx)(h,{as:g,className:`block-editor-math`,contentEditable:!1,children:_}),t[3]=h,t[4]=g,t[5]=_,t[6]=v):v=t[6],v}function lE(e){return e[0].length+1}function uE(e){return e.language}function dE(e){return J.create({name:e?`blockMath`:`inlineMath`,priority:1e3,group:e?`block`:`inline`,inline:!e,atom:!0,addAttributes(){return{source:{default:``}}},parseHTML(){let t=t=>{let n=t.getAttribute(`data-xopc-math-source`)??t.querySelector(`code`)?.getAttribute(`data-xopc-math-source`)??``;return se(n)?.display===e&&{source:n}};return e?[{tag:`pre`,getAttrs:t},{tag:`div[data-xopc-math-source]`,getAttrs:t}]:[{tag:`code.math-inline[data-xopc-math-source]`,getAttrs:t},{tag:`span[data-xopc-math-source]`,getAttrs:t}]},renderHTML({node:t}){let n=se(String(t.attrs.source));return[e?`div`:`span`,{"data-xopc-math-source":t.attrs.source},n?.raw??``]},addNodeView(){return Xm(cE)},addStorage(){return{markdown:{serialize(t,n){let r=se(String(n.attrs.source));r&&(t.text(r.raw,!1),e&&t.closeBlock(n))},parse:{setup(e){sE(e,{placeholder:!0})}}}}}})}var fE=dE(!1),pE=dE(!0);function mE(e){let t=(0,sn.c)(27),{node:n,editor:r,getPos:i}=e,a=s(_E),o;t[0]===a?o=t[1]:(o=c(a),t[0]=a,t[1]=o);let l=o.notes,u=String(n.attrs.language??``),d;t[2]===u?d=t[3]:(d=u.toLowerCase(),t[2]=u,t[3]=d);let f=d===`mermaid`,[p,m]=(0,M.useState)(!1),h,g;t[4]!==r||t[5]!==i||t[6]!==f||t[7]!==n.nodeSize?(h=()=>{if(!f)return;let e=()=>{let e=i(),{from:t,to:a}=r.state.selection;typeof e==`number`&&t>e&&a<e+n.nodeSize&&m(!0)};return r.on(`selectionUpdate`,e),()=>{r.off(`selectionUpdate`,e)}},g=[r,i,f,n.nodeSize],t[4]=r,t[5]=i,t[6]=f,t[7]=n.nodeSize,t[8]=h,t[9]=g):(h=t[8],g=t[9]),(0,M.useEffect)(h,g);let _;t[10]===n.textContent?_=t[11]:(_="`".repeat(Math.max(3,...Array.from(n.textContent.matchAll(/`+/g),gE))),t[10]=n.textContent,t[11]=_);let v=_,y=f?`block-editor-mermaid min-w-0`:void 0,b;t[12]!==v||t[13]!==f||t[14]!==l||t[15]!==n.textContent||t[16]!==p?(b=f&&(0,N.jsxs)(`div`,{contentEditable:!1,children:[(0,N.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,N.jsx)(`span`,{children:`Mermaid`}),(0,N.jsx)(`button`,{type:`button`,"aria-pressed":p,className:`rounded-md px-2 py-1 hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-accent`,onClick:()=>m(hE),children:p?l.modePreview:l.modeSource})]}),!p&&(0,N.jsx)(ue,{content:`${v}mermaid\n${n.textContent}\n${v}`,mermaidActions:!0})]}),t[12]=v,t[13]=f,t[14]=l,t[15]=n.textContent,t[16]=p,t[17]=b):b=t[17];let x=f&&!p,S=n.attrs.language?`language-${n.attrs.language}`:void 0,C;t[18]===S?C=t[19]:(C=(0,N.jsx)(Fm,{as:`code`,className:S}),t[18]=S,t[19]=C);let w;t[20]!==C||t[21]!==x?(w=(0,N.jsx)(`pre`,{className:`block-editor-code`,hidden:x,children:C}),t[20]=C,t[21]=x,t[22]=w):w=t[22];let T;return t[23]!==w||t[24]!==y||t[25]!==b?(T=(0,N.jsxs)(Im,{className:y,children:[b,w]}),t[23]=w,t[24]=y,t[25]=b,t[26]=T):T=t[26],T}function hE(e){return!e}function gE(e){return e[0].length+1}function _E(e){return e.language}var vE=Ch.extend({addNodeView(){return Xm(mE)}});function yE(e){let{selection:t,doc:n}=e,r=n.type.schema,i=t.from;if(t instanceof B)i=t.to;else{if(n.resolve(i).parent.isTextblock)return!0;i=Math.min(i+1,n.content.size)}let a=n.resolve(Math.min(i,n.content.size));if(a.parent.isTextblock)return e.setSelection(z.near(a,1)),!0;let o=r.nodes.paragraph;if(!o)return!1;let s=n.content.size;return e.insert(s,o.create()),e.setSelection(z.near(e.doc.resolve(s+1),1)),!0}function bE(e){e.commands.command(({tr:e,dispatch:t})=>(t&&yE(e),!0))}var xE=q.create({name:`extraKeyboardShortcuts`,addKeyboardShortcuts(){return{"Mod-Shift-1":()=>this.editor.chain().focus().toggleHeading({level:1}).run(),"Mod-Shift-2":()=>this.editor.chain().focus().toggleHeading({level:2}).run(),"Mod-Shift-3":()=>this.editor.chain().focus().toggleHeading({level:3}).run(),"Mod-Shift-8":()=>this.editor.chain().focus().toggleBulletList().run(),"Mod-Shift-9":()=>this.editor.chain().focus().toggleOrderedList().run(),"Mod-Shift-0":()=>this.editor.chain().focus().toggleTaskList().run()}}});function SE(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=Ef(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v<o.pos&&y>=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function CE(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,`
160
- `);return/\s/.test(n)}):!1}function wE(e){return()=>{let t=e.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=e.view.coordsAtPos(t);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}}}function TE(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:wE(e)}function EE({match:e,dismissedRange:t,state:n,transaction:r,editor:i,shouldResetDismissed:a,effectiveAllowSpaces:o}){return a?.({editor:i,state:n,range:t,match:e,transaction:r,allowSpaces:o})?!1:o?e.range.from===t.from:e.range.from===t.from&&!CE(r)}function DE({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function OE({pluginKey:e,decorationTag:t,decorationClass:n,decorationContent:r,decorationEmptyClass:i,renderer:a,dispatchExit:o}){return{handleKeyDown(t,n){var r;let i=e.getState(t.state);if(!i.active)return!1;if(n.key===`Escape`||n.key===`Esc`){var s;return a==null||(s=a.onKeyDown)==null||s.call(a,{view:t,event:n,range:i.range}),o(t),!0}return(a==null||(r=a.onKeyDown)==null?void 0:r.call(a,{view:t,event:n,range:i.range}))||!1},decorations(a){let{active:o,range:s,decorationId:c,query:l}=e.getState(a);if(!o)return null;let u=!l?.length,d=[n];return u&&d.push(i),U.create(a.doc,[hc.inline(s.from,s.to,{nodeName:t,class:d.join(` `),"data-decoration-id":c||void 0,"data-decoration-content":r})])}}}function kE({editor:e,char:t,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,findSuggestionMatch:o,allow:s,shouldShow:c,shouldKeepDismissed:l,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,f,p,m){let{isEditable:h}=e,{composing:g}=e.view,{selection:_}=d,{empty:v,from:y}=_,b={...f},x=d.getMeta(u);if(x&&x.exit)return b.active=!1,b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null,b.dismissedRange=f.active?{...f.range}:f.dismissedRange,b;if(b.composing=g,d.docChanged&&b.dismissedRange!==null&&(b.dismissedRange={from:d.mapping.map(b.dismissedRange.from),to:d.mapping.map(b.dismissedRange.to)}),h&&(v||e.view.composing)){(y<f.range.from||y>f.range.to)&&!g&&!f.composing&&(b.active=!1);let u=o({char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:_.$from}),p=`id_${Math.floor(Math.random()*4294967295)}`;u&&s({editor:e,state:m,range:u.range,isActive:f.active})&&(!c||c({editor:e,range:u.range,query:u.query,text:u.text,transaction:d}))?(b.dismissedRange!==null&&!l({match:u,dismissedRange:b.dismissedRange,state:m,transaction:d})&&(b.dismissedRange=null),b.dismissedRange===null?(b.active=!0,b.decorationId=f.decorationId||p,b.range=u.range,b.query=u.query,b.text=u.text):b.active=!1):(u||(b.dismissedRange=null),b.active=!1)}else b.active=!1;return b.active||(b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null),b}}}function AE({editor:e,items:t}){let n=null,r=null,i=null,a=()=>{r!==null&&(clearTimeout(r),r=null),i?.(),i=null},o=e=>new Promise(t=>{i=t,r=setTimeout(()=>{r=null;let e=i;i=null,e?.()},e)}),s=()=>{n?.abort(),a(),n=null};return{abort:s,fetch:async(r,i)=>{s(),n=new AbortController;let a=n;if(i>0&&await o(i),n!==a||a.signal.aborted)return{status:`aborted`};try{let i=await t({editor:e,query:r,signal:a.signal});return n!==a||a.signal.aborted?{status:`aborted`}:{status:`resolved`,items:i}}catch{return n!==a||a.signal.aborted?{status:`aborted`}:{status:`error`}}}}}function jE({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[Se({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(ye()),!(r==null||(i=r.middleware)==null)&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function ME(e){if(e instanceof HTMLElement)return e;if(typeof e==`string`)try{let t=document.querySelector(e);if(t)return t}catch{return document.body}return document.body}function NE({getReferenceRect:e,contextElement:t,config:n,container:r,dismissOnOutsideClick:i,dismiss:a}){return(o,s={})=>{let c={getBoundingClientRect:()=>e()??new DOMRect,contextElement:t},l=!1,u=!o.isConnected;u&&ME(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=Te(c,o,()=>{xe(c,o,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:e,y:t,placement:n,strategy:r})=>{if(s.onPosition){s.onPosition({x:e,y:t,placement:n,strategy:r});return}Object.assign(o.style,{position:r,left:`${e}px`,top:`${t}px`}),l||(l=!0,o.style.visibility=``)})},s.autoUpdate),f;return i&&(f=e=>{let n=e.target;!(n instanceof Node)||o.contains(n)||t.contains(n)||a()},document.addEventListener(`pointerdown`,f,!0)),()=>{d(),f&&document.removeEventListener(`pointerdown`,f,!0),u&&o.remove()}}}function PE({editor:e,pluginKey:t,items:n,renderer:r,minQueryLength:i,debounce:a,initialItems:o,placement:s,offset:c,container:l,flip:u,floatingUi:d,dismissOnOutsideClick:f,command:p,clientRectFor:m,dispatchExit:h}){let g,_=AE({editor:e,items:n}),v=jE({placement:s,offset:c,flip:u,floatingUi:d});function y(e,t){switch(e){case`started`:var n;r==null||(n=r.onStart)==null||n.call(r,t);break;case`updated`:var i;r==null||(i=r.onUpdate)==null||i.call(r,t);break;case`stopped`:var a;r==null||(a=r.onExit)==null||a.call(r,t)}}return{update:async(n,d)=>{let b=t.getState(d),x=t.getState(n.state);if(!b||!x)return;let S=null,C=b.query!==x.query,w=b.text!==x.text,T=b.range.from!==x.range.from||b.range.to!==x.range.to,E=C||w||T;if(!b.active&&x.active)S=`started`;else if(b.active&&!x.active)S=`stopped`;else if(x.active&&E)S=`updated`;else return;let D=S===`stopped`?b:x,O=n.dom.querySelector(`[data-decoration-id="${D.decorationId}"]`),k=m(n,O),A=i===0||(D.query?D.query.length>=i:!1),j=(S===`started`||S===`updated`)&&A;if(g={editor:e,range:D.range,query:D.query||``,text:D.text||``,items:o??[],command:t=>p({editor:e,range:D.range,props:t}),decorationNode:O,clientRect:k,loading:j,placement:s,offset:{mainAxis:c.mainAxis??4,crossAxis:c.crossAxis??0},container:l,flip:u,floatingUi:v,mount:NE({getReferenceRect:k,contextElement:n.dom,config:v,container:l,dismissOnOutsideClick:f,dismiss:()=>h(e.view)})},S===`started`){var ee;r==null||(ee=r.onBeforeStart)==null||ee.call(r,g)}if(S===`updated`){var te;r==null||(te=r.onBeforeUpdate)==null||te.call(r,g)}if(S===`started`&&y(S,g),S===`started`||S===`updated`)if(!j)_.abort(),g={...g,items:o??[],loading:!1};else{g={...g,items:o??[],loading:!0},S=`updated`,y(S,g);let e=await _.fetch(D.query||``,a);if(e.status===`aborted`)return;if(!t.getState(n.state)?.active){_.abort();return}g=e.status===`resolved`?{...g,items:e.items,loading:!1}:{...g,loading:!1}}if(S===`stopped`){_.abort(),y(S,g),g=void 0;return}S===`updated`&&y(S,g)},destroy:()=>{var e;_.abort(),g&&(r==null||(e=r.onExit)==null||e.call(r,g))}}}var FE=new H(`suggestion`);function IE({pluginKey:e=FE,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],minQueryLength:p=0,debounce:m=0,initialItems:h,placement:g=`bottom-start`,offset:_={},container:v,flip:y=!0,floatingUi:b,dismissOnOutsideClick:x=!0,render:S=()=>({}),allow:C=()=>!0,findSuggestionMatch:w=SE,shouldShow:T,shouldResetDismissed:E}){let D=S?.(),O=r&&!i,k=(n,r)=>TE(t,n,r,e);function A(e){return EE({...e,editor:t,shouldResetDismissed:E,effectiveAllowSpaces:O})}let j=t=>DE({view:t,pluginKeyRef:e});return new V({key:e,view:()=>PE({editor:t,pluginKey:e,items:f,renderer:D,minQueryLength:p,debounce:m,initialItems:h,placement:g,offset:_,container:v,flip:y,floatingUi:b,dismissOnOutsideClick:x,command:d,clientRectFor:k,dispatchExit:j}),state:kE({editor:t,char:n,effectiveAllowSpaces:O,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,findSuggestionMatch:w,allow:C,shouldShow:T,shouldKeepDismissed:A,pluginKey:e}),props:OE({pluginKey:e,decorationTag:s,decorationClass:c,decorationContent:l,decorationEmptyClass:u,renderer:D,dispatchExit:j})})}var LE=IE,RE=[{id:`heading1`,label:`Heading 1`,description:`Large section heading`,keywords:[`h1`,`title`,`heading`]},{id:`heading2`,label:`Heading 2`,description:`Medium section heading`,keywords:[`h2`,`heading`]},{id:`heading3`,label:`Heading 3`,description:`Small section heading`,keywords:[`h3`,`heading`]},{id:`bulletList`,label:`Bullet List`,description:`Unordered list`,keywords:[`ul`,`list`,`bullet`]},{id:`orderedList`,label:`Numbered List`,description:`Ordered list`,keywords:[`ol`,`list`,`numbered`]},{id:`taskList`,label:`Task List`,description:`List with checkboxes`,keywords:[`todo`,`task`,`checkbox`]},{id:`blockquote`,label:`Quote`,description:`Block quotation`,keywords:[`quote`,`blockquote`]},{id:`codeBlock`,label:`Code Block`,description:`Fenced code snippet`,keywords:[`code`,`snippet`]},{id:`divider`,label:`Divider`,description:`Horizontal rule`,keywords:[`hr`,`rule`,`line`]},{id:`image`,label:`Image`,description:`Upload an image`,keywords:[`img`,`photo`,`picture`]}];function zE(e){let t=e.trim().toLowerCase();return t?RE.filter(e=>[e.label,e.description,...e.keywords].join(` `).toLowerCase().includes(t)):RE}function BE(e,t,n,r){if(e.id===`image`){t.chain().focus().deleteRange(n).run(),r.requestImagePicker&&setTimeout(()=>r.requestImagePicker?.(),0);return}let i=t.chain().focus().deleteRange(n);switch(e.id){case`heading1`:i.setHeading({level:1}).run();return;case`heading2`:i.setHeading({level:2}).run();return;case`heading3`:i.setHeading({level:3}).run();return;case`bulletList`:i.toggleBulletList().run();return;case`orderedList`:i.toggleOrderedList().run();return;case`taskList`:i.toggleTaskList().run();return;case`blockquote`:i.toggleBlockquote().run();return;case`codeBlock`:i.toggleCodeBlock().run();return;case`divider`:i.setHorizontalRule().run(),bE(t);return;default:return}}var VE=`slash-menu-panel fixed z-[9999] w-64 overflow-hidden rounded-lg border border-edge bg-surface-base shadow-lg`,HE=`flex w-full items-center gap-3 rounded-md px-2.5 py-2 text-left transition-colors text-fg-muted hover:bg-surface-hover hover:text-fg`,UE=`bg-surface-hover text-fg`;function WE({editor:e,getRuntime:t}){let n=null,r=null,i=null,a=null,o=0,s=``,c=null,l=()=>{n?.remove(),n=null,r=null,i=null,a=null,c=null,o=0,s=``},u=()=>{n||(n=document.createElement(`div`),n.setAttribute(`data-slash-menu-root`,`true`),r=document.createElement(`div`),r.className=VE,i=document.createElement(`div`),i.className=`slash-menu-scroll max-h-72 overflow-y-auto p-1`,a=document.createElement(`input`),a.type=`file`,a.accept=`image/*`,a.className=`hidden`,a.addEventListener(`change`,()=>{let e=a?.files?.[0],n=t();e&&n.onImageUpload&&n.onImageUpload(e),a&&(a.value=``)}),r.appendChild(i),n.append(r,a),document.body.appendChild(n))},d=()=>{if(!r||!c)return;let e=c.clientRect?.()??null;if(e){r.style.top=`${e.bottom+6}px`,r.style.left=`${e.left}px`;return}let t=c.editor.view.coordsAtPos(c.range.to);r.style.top=`${t.bottom+6}px`,r.style.left=`${t.left}px`},f=()=>{if(!c||!i||!r)return;i.replaceChildren();let e=i;c.items.forEach((n,r)=>{let i=document.createElement(`button`);i.type=`button`,i.className=`${HE}${r===o?` ${UE}`:``}`;let s=document.createElement(`span`);s.className=`flex size-8 shrink-0 items-center justify-center rounded-md border border-edge bg-surface-inset text-xs font-semibold uppercase text-fg-muted`,s.textContent=n.label.slice(0,2);let l=document.createElement(`span`);l.className=`min-w-0 flex-1`;let u=document.createElement(`span`);u.className=`block truncate text-sm font-medium text-fg`,u.textContent=n.label;let d=document.createElement(`span`);d.className=`block truncate text-xs text-fg-muted`,d.textContent=n.description,l.append(u,d),i.append(s,l),i.addEventListener(`mousedown`,e=>{if(e.preventDefault(),c){if(n.id===`image`){BE(n,c.editor,c.range,{...t(),requestImagePicker:t().requestImagePicker??(()=>a?.click())});return}c.command(n)}}),e.appendChild(i)}),d()},p=e=>{e.query!==s&&(o=0,s=e.query),c=e,u(),f()};return e.on(`destroy`,l),{onStart:e=>{p(e)},onUpdate:e=>{p(e)},onExit:()=>{l()},onKeyDown:({event:e})=>{let n=c?.items??[];if(!n.length)return!1;if(e.key===`ArrowDown`)return o=(o+1)%n.length,f(),!0;if(e.key===`ArrowUp`)return o=(o-1+n.length)%n.length,f(),!0;if(e.key===`Enter`){let e=n[o];return e&&c&&(e.id===`image`?BE(e,c.editor,c.range,{...t(),requestImagePicker:t().requestImagePicker??(()=>a?.click())}):c.command(e)),!0}return!1},destroy:l}}var GE=new H(`slashCommands`),KE=q.create({name:`slashCommands`,addOptions(){return{getRuntime:()=>({})}},addStorage(){return{active:!1}},onDestroy(){this.storage.active=!1},addProseMirrorPlugins(){let e=this,t=WE({editor:this.editor,getRuntime:()=>e.options.getRuntime()});return[LE({pluginKey:GE,editor:this.editor,char:`/`,allowedPrefixes:null,items:({query:e})=>zE(e),command:({editor:t,range:n,props:r})=>{BE(r,t,n,e.options.getRuntime())},render:()=>({onStart:n=>{e.storage.active=!0,t.onStart(n)},onUpdate:e=>{t.onUpdate(e)},onExit:()=>{e.storage.active=!1,t.onExit()},onKeyDown:t.onKeyDown})})]}}),qE=Sb.configure({node:`paragraph`,notAfter:[`paragraph`]});function JE(e){let t=String(e.getAttributes(`link`).href??``),n=window.prompt(`URL`,t);if(n!==null){if(!n.trim()){e.chain().focus().extendMarkRange(`link`).unsetLink().run();return}e.chain().focus().extendMarkRange(`link`).setLink({href:n.trim()}).run()}}function YE(e){return!e.metaKey&&!e.ctrlKey?null:(e.target instanceof Element?e.target:null)?.closest(`a[href]`)?.getAttribute(`href`)?.trim()||null}function XE(e){let t=(0,sn.c)(9),{onClick:n,isActive:r,disabled:i,title:a,children:o}=e,s=r&&`bg-surface-hover text-accent`,c=i&&`pointer-events-none opacity-40`,l;t[0]!==s||t[1]!==c?(l=ve(`rounded-md p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,s,c),t[0]=s,t[1]=c,t[2]=l):l=t[2];let u;return t[3]!==o||t[4]!==i||t[5]!==n||t[6]!==l||t[7]!==a?(u=(0,N.jsx)(`button`,{type:`button`,onClick:n,disabled:i,title:a,className:l,children:o}),t[3]=o,t[4]=i,t[5]=n,t[6]=l,t[7]=a,t[8]=u):u=t[8],u}function ZE(){let e=(0,sn.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,N.jsx)(`div`,{className:`mx-1 h-5 w-px bg-edge`}),e[0]=t):t=e[0],t}function QE(e){let t=(0,sn.c)(131),{editor:n,onImageUpload:r,imageUploading:i}=e,a=i!==void 0&&i,o=(0,M.useRef)(null),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{o.current?.click()},t[0]=s):s=t[0];let c=s,S;t[1]!==a||t[2]!==r?(S=e=>{let t=e.target.files?.[0];t&&r&&!a&&r(t),o.current&&(o.current.value=``)},t[1]=a,t[2]=r,t[3]=S):S=t[3];let w=S,T,E;t[4]===n?(T=t[5],E=t[6]):(T=()=>n.chain().focus().undo().run(),E=n.can().undo(),t[4]=n,t[5]=T,t[6]=E);let D=!E,O;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,N.jsx)(_,{size:16}),t[7]=O):O=t[7];let k;t[8]!==T||t[9]!==D?(k=(0,N.jsx)(XE,{onClick:T,disabled:D,title:`Undo`,children:O}),t[8]=T,t[9]=D,t[10]=k):k=t[10];let A,j;t[11]===n?(A=t[12],j=t[13]):(j=()=>n.chain().focus().redo().run(),A=n.can().redo(),t[11]=n,t[12]=A,t[13]=j);let ee=!A,ne;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,N.jsx)(m,{size:16}),t[14]=ne):ne=t[14];let re;t[15]!==ee||t[16]!==j?(re=(0,N.jsx)(XE,{onClick:j,disabled:ee,title:`Redo`,children:ne}),t[15]=ee,t[16]=j,t[17]=re):re=t[17];let ae;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,N.jsx)(ZE,{}),t[18]=ae):ae=t[18];let oe,se;t[19]===n?(oe=t[20],se=t[21]):(oe=()=>n.chain().focus().toggleHeading({level:1}).run(),se=n.isActive(`heading`,{level:1}),t[19]=n,t[20]=oe,t[21]=se);let ce;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,N.jsx)(y,{size:16}),t[22]=ce):ce=t[22];let le;t[23]!==oe||t[24]!==se?(le=(0,N.jsx)(XE,{onClick:oe,isActive:se,title:`Heading 1`,children:ce}),t[23]=oe,t[24]=se,t[25]=le):le=t[25];let ue,de;t[26]===n?(ue=t[27],de=t[28]):(ue=()=>n.chain().focus().toggleHeading({level:2}).run(),de=n.isActive(`heading`,{level:2}),t[26]=n,t[27]=ue,t[28]=de);let fe;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,N.jsx)(f,{size:16}),t[29]=fe):fe=t[29];let pe;t[30]!==ue||t[31]!==de?(pe=(0,N.jsx)(XE,{onClick:ue,isActive:de,title:`Heading 2`,children:fe}),t[30]=ue,t[31]=de,t[32]=pe):pe=t[32];let me,he;t[33]===n?(me=t[34],he=t[35]):(me=()=>n.chain().focus().toggleHeading({level:3}).run(),he=n.isActive(`heading`,{level:3}),t[33]=n,t[34]=me,t[35]=he);let ge;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,N.jsx)(d,{size:16}),t[36]=ge):ge=t[36];let _e;t[37]!==me||t[38]!==he?(_e=(0,N.jsx)(XE,{onClick:me,isActive:he,title:`Heading 3`,children:ge}),t[37]=me,t[38]=he,t[39]=_e):_e=t[39];let ve;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,N.jsx)(ZE,{}),t[40]=ve):ve=t[40];let ye,be;t[41]===n?(ye=t[42],be=t[43]):(ye=()=>n.chain().focus().toggleBold().run(),be=n.isActive(`bold`),t[41]=n,t[42]=ye,t[43]=be);let xe;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,N.jsx)(p,{size:16}),t[44]=xe):xe=t[44];let Se;t[45]!==ye||t[46]!==be?(Se=(0,N.jsx)(XE,{onClick:ye,isActive:be,title:`Bold (⌘B)`,children:xe}),t[45]=ye,t[46]=be,t[47]=Se):Se=t[47];let Ce,we;t[48]===n?(Ce=t[49],we=t[50]):(Ce=()=>n.chain().focus().toggleItalic().run(),we=n.isActive(`italic`),t[48]=n,t[49]=Ce,t[50]=we);let Te;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,N.jsx)(h,{size:16}),t[51]=Te):Te=t[51];let Ee;t[52]!==Ce||t[53]!==we?(Ee=(0,N.jsx)(XE,{onClick:Ce,isActive:we,title:`Italic (⌘I)`,children:Te}),t[52]=Ce,t[53]=we,t[54]=Ee):Ee=t[54];let De,Oe;t[55]===n?(De=t[56],Oe=t[57]):(De=()=>n.chain().focus().toggleStrike().run(),Oe=n.isActive(`strike`),t[55]=n,t[56]=De,t[57]=Oe);let ke;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,N.jsx)(b,{size:16}),t[58]=ke):ke=t[58];let Ae;t[59]!==De||t[60]!==Oe?(Ae=(0,N.jsx)(XE,{onClick:De,isActive:Oe,title:`Strikethrough`,children:ke}),t[59]=De,t[60]=Oe,t[61]=Ae):Ae=t[61];let je,Me;t[62]===n?(je=t[63],Me=t[64]):(je=()=>n.chain().focus().toggleCode().run(),Me=n.isActive(`code`),t[62]=n,t[63]=je,t[64]=Me);let Ne;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,N.jsx)(g,{size:16}),t[65]=Ne):Ne=t[65];let Pe;t[66]!==je||t[67]!==Me?(Pe=(0,N.jsx)(XE,{onClick:je,isActive:Me,title:`Inline code`,children:Ne}),t[66]=je,t[67]=Me,t[68]=Pe):Pe=t[68];let Fe,Ie;t[69]===n?(Fe=t[70],Ie=t[71]):(Fe=()=>JE(n),Ie=n.isActive(`link`),t[69]=n,t[70]=Fe,t[71]=Ie);let Le;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,N.jsx)(u,{size:16}),t[72]=Le):Le=t[72];let P;t[73]!==Fe||t[74]!==Ie?(P=(0,N.jsx)(XE,{onClick:Fe,isActive:Ie,title:`Link`,children:Le}),t[73]=Fe,t[74]=Ie,t[75]=P):P=t[75];let Re;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(0,N.jsx)(ZE,{}),t[76]=Re):Re=t[76];let ze,Be;t[77]===n?(ze=t[78],Be=t[79]):(ze=()=>n.chain().focus().toggleBulletList().run(),Be=n.isActive(`bulletList`),t[77]=n,t[78]=ze,t[79]=Be);let Ve;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=(0,N.jsx)(v,{size:16}),t[80]=Ve):Ve=t[80];let F;t[81]!==ze||t[82]!==Be?(F=(0,N.jsx)(XE,{onClick:ze,isActive:Be,title:`Bullet list`,children:Ve}),t[81]=ze,t[82]=Be,t[83]=F):F=t[83];let He,Ue;t[84]===n?(He=t[85],Ue=t[86]):(He=()=>n.chain().focus().toggleOrderedList().run(),Ue=n.isActive(`orderedList`),t[84]=n,t[85]=He,t[86]=Ue);let We;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(We=(0,N.jsx)(x,{size:16}),t[87]=We):We=t[87];let I;t[88]!==He||t[89]!==Ue?(I=(0,N.jsx)(XE,{onClick:He,isActive:Ue,title:`Ordered list`,children:We}),t[88]=He,t[89]=Ue,t[90]=I):I=t[90];let Ge,L;t[91]===n?(Ge=t[92],L=t[93]):(Ge=()=>n.chain().focus().toggleTaskList().run(),L=n.isActive(`taskList`),t[91]=n,t[92]=Ge,t[93]=L);let Ke;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,N.jsx)(te,{size:16}),t[94]=Ke):Ke=t[94];let qe;t[95]!==Ge||t[96]!==L?(qe=(0,N.jsx)(XE,{onClick:Ge,isActive:L,title:`Task list`,children:Ke}),t[95]=Ge,t[96]=L,t[97]=qe):qe=t[97];let Je,Ye;t[98]===n?(Je=t[99],Ye=t[100]):(Je=()=>n.chain().focus().toggleBlockquote().run(),Ye=n.isActive(`blockquote`),t[98]=n,t[99]=Je,t[100]=Ye);let Xe;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=(0,N.jsx)(l,{size:16}),t[101]=Xe):Xe=t[101];let Ze;t[102]!==Je||t[103]!==Ye?(Ze=(0,N.jsx)(XE,{onClick:Je,isActive:Ye,title:`Quote`,children:Xe}),t[102]=Je,t[103]=Ye,t[104]=Ze):Ze=t[104];let Qe;t[105]===n?Qe=t[106]:(Qe=()=>{n.chain().focus().setHorizontalRule().run(),bE(n)},t[105]=n,t[106]=Qe);let $e;t[107]===Symbol.for(`react.memo_cache_sentinel`)?($e=(0,N.jsx)(ie,{size:16}),t[107]=$e):$e=t[107];let et;t[108]===Qe?et=t[109]:(et=(0,N.jsx)(XE,{onClick:Qe,title:`Divider`,children:$e}),t[108]=Qe,t[109]=et);let tt;t[110]!==w||t[111]!==a||t[112]!==r?(tt=r&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(ZE,{}),(0,N.jsx)(XE,{onClick:c,disabled:a,title:a?`Uploading…`:`Insert image`,children:(0,N.jsx)(C,{size:16,className:a?`animate-pulse`:void 0})}),(0,N.jsx)(`input`,{ref:o,type:`file`,accept:`image/*`,onChange:w,className:`hidden`})]}),t[110]=w,t[111]=a,t[112]=r,t[113]=tt):tt=t[113];let nt;return t[114]!==re||t[115]!==le||t[116]!==pe||t[117]!==_e||t[118]!==Se||t[119]!==Ee||t[120]!==Ae||t[121]!==Pe||t[122]!==P||t[123]!==F||t[124]!==I||t[125]!==qe||t[126]!==Ze||t[127]!==et||t[128]!==tt||t[129]!==k?(nt=(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-0.5 border-b border-edge px-3 py-1.5`,children:[k,re,ae,le,pe,_e,ve,Se,Ee,Ae,Pe,P,Re,F,I,qe,Ze,et,tt]}),t[114]=re,t[115]=le,t[116]=pe,t[117]=_e,t[118]=Se,t[119]=Ee,t[120]=Ae,t[121]=Pe,t[122]=P,t[123]=F,t[124]=I,t[125]=qe,t[126]=Ze,t[127]=et,t[128]=tt,t[129]=k,t[130]=nt):nt=t[130],nt}var $E=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,eD=J.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,K(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?`![${n}](${t} "${r}")`:`![${n}](${t})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,i=new Set([`src`,`width`,`height`]);return({node:a,getPos:o,HTMLAttributes:s,editor:c})=>{let l=document.createElement(`img`);l.draggable=!1;let u=K(this.options.HTMLAttributes,s);Object.entries(u).forEach(([e,t])=>{if(t!=null)switch(e){case`src`:case`width`:case`height`:break;default:l.setAttribute(e,t)}}),u.src!==null&&(l.src=u.src);let d={...s},f=e=>{if(typeof e==`string`&&e!==``){l.getAttribute(`src`)!==e&&(l.src=e);return}l.hasAttribute(`src`)&&l.removeAttribute(`src`),l.src!==``&&(l.src=``)};f(s.src);let p=new _p({element:l,editor:c,node:a,getPos:o,onResize:(e,t)=>{l.style.width=`${e}px`,l.style.height=`${t}px`},onCommit:(e,t)=>{let n=o();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:e=>{if(e.type!==a.type)return!1;let t=Hu(e,c.extensionManager.attributes.filter(t=>t.type===e.type.name));return Object.keys(d).forEach(e=>{!i.has(e)&&!(e in t)&&l.removeAttribute(e)}),Object.entries(t).forEach(([e,t])=>{i.has(e)||(t==null?l.removeAttribute(e):l.setAttribute(e,t))}),f(t.src),d=t,!0},options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),m=p.dom,h=()=>{m.style.visibility=``,m.style.pointerEvents=``};return m.style.visibility=`hidden`,m.style.pointerEvents=`none`,l.complete&&l.naturalWidth>0?h():(l.onload=h,l.onerror=h),p}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[pp({find:$E,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});function tD(e){let t=(0,sn.c)(28),{node:n,updateAttributes:r,selected:i}=e,{src:a,alt:o,title:s}=n.attrs,{openImage:c}=k(),[l,u]=(0,M.useState)(!1),d=(0,M.useRef)(null),[f,p]=(0,M.useState)(!1),m=(0,M.useRef)(0),h=(0,M.useRef)(0),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=e=>{e.preventDefault(),e.stopPropagation(),p(!0),m.current=e.clientX,h.current=d.current?.offsetWidth??400},t[0]=g):g=t[0];let _=g,v,y;t[1]!==f||t[2]!==r?(v=()=>{if(!f)return;let e=e=>{let t=e.clientX-m.current,n=Math.max(100,h.current+t);r({width:n})},t=()=>{p(!1)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},y=[f,r],t[1]=f,t[2]=r,t[3]=v,t[4]=y):(v=t[3],y=t[4]),(0,M.useEffect)(v,y);let b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{u(!1)},t[5]=b):b=t[5];let x;t[6]===a?x=t[7]:(x=[a],t[6]=a,t[7]=x),(0,M.useEffect)(b,x);let S=n.attrs.width,C=i&&`ring-2 ring-accent ring-offset-2 ring-offset-surface-base rounded-lg`,w;t[8]===C?w=t[9]:(w=ve(`relative inline-block`,C),t[8]=C,t[9]=w);let T=S?`${S}px`:void 0,E;t[10]===T?E=t[11]:(E={width:T,maxWidth:`100%`},t[10]=T,t[11]=E);let D;t[12]!==o||t[13]!==l||t[14]!==c||t[15]!==a||t[16]!==s?(D=l?(0,N.jsx)(`div`,{className:`flex min-h-24 min-w-[12rem] items-center justify-center rounded-lg border border-dashed border-edge bg-surface-hover text-fg-muted`,children:(0,N.jsx)(`span`,{className:`text-xs`,children:`Image unavailable`})}):(0,N.jsx)(ee,{src:a,alt:o??``,title:s??void 0,className:`block h-auto w-full cursor-zoom-in rounded-lg`,draggable:!1,onClick:e=>c(e,o??void 0),onLoadFailed:()=>u(!0)}),t[12]=o,t[13]=l,t[14]=c,t[15]=a,t[16]=s,t[17]=D):D=t[17];let O=(i||f)&&`opacity-100`,A;t[18]===O?A=t[19]:(A=ve(`absolute bottom-1 right-1 size-4 cursor-se-resize rounded-sm opacity-0 transition-opacity`,`bg-accent/70 hover:bg-accent`,O),t[18]=O,t[19]=A);let j;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,N.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,className:`m-0.5 text-white`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,N.jsx)(`path`,{d:`M10 2L2 10M10 6L6 10M10 10L10 10`,strokeLinecap:`round`})}),t[20]=j):j=t[20];let te;t[21]===A?te=t[22]:(te=(0,N.jsx)(`div`,{onMouseDown:_,className:A,title:`Drag to resize`,children:j}),t[21]=A,t[22]=te);let ne;return t[23]!==D||t[24]!==te||t[25]!==w||t[26]!==E?(ne=(0,N.jsx)(Im,{className:`block-editor-image-wrapper`,children:(0,N.jsxs)(`div`,{ref:d,className:w,style:E,children:[D,te]})}),t[23]=D,t[24]=te,t[25]=w,t[26]=E,t[27]=ne):ne=t[27],ne}var nD=eD.extend({addAttributes(){return{...this.parent?.(),width:{default:null,parseHTML:e=>{let t=e.getAttribute(`width`)||e.style.width;return t?parseInt(t,10):null},renderHTML:e=>e.width?{width:e.width,style:`width: ${e.width}px`}:{}}}},addNodeView(){return Xm(tD)}}),rD,iD;if(typeof WeakMap<`u`){let e=new WeakMap;rD=t=>e.get(t),iD=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;rD=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},iD=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var aD=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return rD(e)||iD(e,oD(e))}};function oD(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=sD(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new aD(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&cD(s,o,e),s}function sD(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function cD(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!c.colwidth||c.colwidth[n]!=r)&&((s||=lD(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function lD(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function uD(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}new H(`selectingCells`);function dD(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function fD(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function pD(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=dD(t.$head)||mD(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function mD(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function hD(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function gD(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function _D(e,t,n){let r=e.node(-1),i=aD.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function vD(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}var yD=class e extends R{constructor(e,t=e){let n=e.node(-1),r=aD.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new Cr(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(hD(r)&&hD(i)&&gD(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return z.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=aD.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=vD(e,0,l)),u>0&&(e=vD(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(F.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new L(F.from(o),1,1)}replace(e,t=L.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?L.empty:t)}let i=R.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new L(F.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=aD.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=aD.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=aD.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=aD.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new bD(this.$anchorCell.pos,this.$headCell.pos)}};yD.prototype.visible=!1,R.jsonID(`cell`,yD);var bD=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&gD(t,n)?new yD(t,n):R.near(n,1)}};new H(`fix-tables`);function xD(e){let t=e.selection,n=pD(e),r=n.node(-1),i=n.start(-1),a=aD.get(r);return{...t instanceof yD?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function SD(e){return function(t,n){if(!fD(t))return!1;if(n){let r=uD(t.schema),i=xD(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function CD(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function wD(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?SD(e):function(t,n){if(!fD(t))return!1;if(n){let r=uD(t.schema),i=xD(t),a=t.tr,o=CD(`row`,i,r),s=CD(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}wD(`row`,{useDeprecatedLogic:!0}),wD(`column`,{useDeprecatedLogic:!0}),wD(`cell`,{useDeprecatedLogic:!0});function TD(e,t){let n=e.selection;if(!(n instanceof yD))return!1;if(t){let r=e.tr,i=uD(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new L(i,0,0))}),r.docChanged&&t(r)}return!0}ul({ArrowLeft:DD(`horiz`,-1),ArrowRight:DD(`horiz`,1),ArrowUp:DD(`vert`,-1),ArrowDown:DD(`vert`,1),"Shift-ArrowLeft":OD(`horiz`,-1),"Shift-ArrowRight":OD(`horiz`,1),"Shift-ArrowUp":OD(`vert`,-1),"Shift-ArrowDown":OD(`vert`,1),Backspace:TD,"Mod-Backspace":TD,Delete:TD,"Mod-Delete":TD});function ED(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function DD(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof yD)return ED(n,r,R.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=kD(i,e,t);if(o==null)return!1;if(e==`horiz`)return ED(n,r,R.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=_D(i,e,t),s;return s=a?R.near(a,1):t<0?R.near(n.doc.resolve(i.before(-1)),-1):R.near(n.doc.resolve(i.after(-1)),1),ED(n,r,s)}}}function OD(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof yD)o=a;else{let r=kD(i,e,t);if(r==null)return!1;o=new yD(n.doc.resolve(r))}let s=_D(o.$headCell,e,t);return s?ED(n,r,new yD(o.$anchorCell,s)):!1}}function kD(e,t,n){if(!(e.state.selection instanceof z))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}new H(`tableColumnResizing`);function AD(e,t){let n=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),a=Math.max(e.right,t.right)-i,o=r-n;return new DOMRect(i,n,a,o)}var jD=class{get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(ye(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Oe(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(Se(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(De(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(be(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(Ce(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(we(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Ee(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}get virtualElement(){var e;let{selection:t}=this.editor.state,n=this.getReferencedVirtualElement?.call(this);if(n)return n;if(!(!((e=this.view)==null||(e=e.dom)==null)&&e.parentNode))return;let r=Sd(this.view,t.from,t.to),i={getBoundingClientRect:()=>r,getClientRects:()=>[r]};if(t instanceof B){let e=this.view.nodeDOM(t.from),n=e.dataset.nodeViewWrapper?e:e.querySelector(`[data-node-view-wrapper]`);n&&(e=n),e&&(i={getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>[e.getBoundingClientRect()]})}if(t instanceof yD){let{$anchorCell:e,$headCell:n}=t,r=e?e.pos:n.pos,a=n?n.pos:e.pos,o=this.view.nodeDOM(r),s=this.view.nodeDOM(a);if(!o||!s)return;let c=o===s?o.getBoundingClientRect():AD(o.getBoundingClientRect(),s.getBoundingClientRect());i={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return i}constructor({editor:e,element:t,view:n,pluginKey:r=`bubbleMenu`,updateDelay:i=250,resizeDelay:a=60,shouldShow:o,appendTo:s,getReferencedVirtualElement:c,options:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:`absolute`,placement:`top`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:t,from:n,to:r})=>{let{doc:i,selection:a}=t,{empty:o}=a,s=!i.textBetween(n,r).length&&Ll(t.selection),c=this.element.contains(document.activeElement);return!(!(e.hasFocus()||c)||o||s||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);!n&&!r||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.show(),this.updatePosition()}},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=l?.scrollTarget??window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener(`dragstart`,this.dragstartHandler),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&xe(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(e,t);return}let i=!t?.selection.eq(e.state.selection),a=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,a,t)}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,element:this.element,view:this.view,state:t,oldState:e,from:i,to:a})||!1}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener(`dragstart`,this.dragstartHandler),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},MD=e=>new V({key:typeof e.pluginKey==`string`?new H(e.pluginKey):e.pluginKey,view:t=>new jD({view:t,...e})});q.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[MD({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var ND=class{getTextContent(e){return Qu(e,{textSerializers:$u(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(ye(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Oe(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(Se(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(De(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(be(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(Ce(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(we(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Ee(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}constructor({editor:e,element:t,view:n,pluginKey:r=`floatingMenu`,updateDelay:i=250,resizeDelay:a=60,options:o,appendTo:s,shouldShow:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:e,state:t})=>{let{selection:n}=t,{$anchor:r,empty:i}=n,a=r.depth===1,o=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&r.parent.childCount===0&&!this.getTextContent(r.parent);return!(!e.hasFocus()||!i||!a||!o||!this.editor.isEditable)},this.floatingUIOptions={strategy:`absolute`,placement:`right`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.updatePosition(),this.show()}},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=o?.scrollTarget??window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,c&&(this.shouldShow=c),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,view:this.view,state:t,oldState:e,from:i,to:a})}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){var e;if(!(!((e=this.view)==null||(e=e.dom)==null)&&e.parentNode))return;let{selection:t}=this.editor.state,n=Sd(this.view,t.from,t.to);xe({getBoundingClientRect:()=>n,getClientRects:()=>[n]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);this.updateHandler(e,n,r,t)}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},PD=e=>new V({key:typeof e.pluginKey==`string`?new H(e.pluginKey):e.pluginKey,view:t=>new ND({view:t,...e})});q.create({name:`floatingMenu`,addOptions(){return{element:null,options:{},pluginKey:`floatingMenu`,updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,`updatePosition`),!0)}},addProseMirrorPlugins(){return this.options.element?[PD({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function FD(e,t){return e??new H(t)}var ID=typeof window<`u`?M.useLayoutEffect:M.useEffect,LD=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),RD=new Set(`animationIterationCount.aspectRatio.borderImageOutset.borderImageSlice.borderImageWidth.columnCount.columns.fillOpacity.flex.flexGrow.flexShrink.fontWeight.gridArea.gridColumn.gridColumnEnd.gridColumnStart.gridRow.gridRowEnd.gridRowStart.lineClamp.lineHeight.opacity.order.orphans.scale.stopOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeOpacity.strokeWidth.tabSize.widows.zIndex.zoom`.split(`.`)),zD=new Set([`children`,`className`,`style`]),BD=new Set([`tabIndex`]),VD=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),HD={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function UD(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function WD(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function GD(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||VD.has(e)}function KD(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function qD(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:HD[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function JD(e,t){let n=t.defaultPrevented,r=!1,i=Object.create(t);return Object.defineProperties(i,{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>void 0},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,t.preventDefault()}},stopPropagation:{value:()=>{r=!0,t.stopPropagation()}}}),i}function YD(e){return BD.has(e)}function XD(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function ZD(e,t){if(t===`tabIndex`){e.removeAttribute(`tabindex`);return}let n=e[t];if(typeof n==`boolean`){e[t]=!1;return}if(typeof n==`number`){e[t]=0;return}e[t]=``}function QD(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||RD.has(e)?String(t):`${t}px`}function $D(e,t){LD.has(t)||e.style.removeProperty(KD(t))}function eO(e,t,n){LD.has(t)||e.style.setProperty(KD(t),QD(t,n))}function tO(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(zD.has(r)||!GD(r)||UD(r,t[r])||UD(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=WD(r);if(a==null||a===!1){YD(r)&&ZD(e,r),e.removeAttribute(o);return}if(a===!0){YD(r)&&XD(e,r,!0),e.setAttribute(o,``);return}if(YD(r)){XD(e,r,a);return}e.setAttribute(o,String(a))})}function nO(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function rO(e,t,n){let r=t??{},i=n??{};new Set([...Object.keys(r),...Object.keys(i)]).forEach(t=>{let n=r[t],a=i[t];if(n!==a){if(a==null){$D(e,t);return}eO(e,t,a)}})}function iO(e,t,n){t.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)});let r=[];return Object.entries(n).forEach(([t,n])=>{if(!UD(t,n))return;let{eventName:i,options:a}=qD(t),o=t=>{n(JD(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function aO(e,t){let n=(0,M.useRef)({}),r=(0,M.useRef)([]);ID(()=>{let i=n.current;return nO(e,i.className,t.className),rO(e,i.style,t.style),tO(e,i,t),r.current=iO(e,r.current,t),n.current=t,()=>{r.current.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)}),r.current=[]}},[e,t])}var oO=M.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:c,...l},u)=>{let d=(0,M.useRef)(document.createElement(`div`)),f=(0,M.useRef)(FD(e,`bubbleMenu`)).current;aO(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=Mm(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,getReferencedVirtualElement:o,options:s},g=(0,M.useRef)(h);g.current=h;let[_,v]=(0,M.useState)(!1),y=(0,M.useRef)(!0);return(0,M.useEffect)(()=>{if(m?.isDestroyed)return;if(!m){console.warn(`BubbleMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=d.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=MD({...g.current,editor:m,element:e});m.registerPlugin(t);let n=g.current.pluginKey;return y.current=!0,v(!0),()=>{v(!1),m.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[m]),(0,M.useEffect)(()=>{if(!(!_||!m||m.isDestroyed)){if(y.current){y.current=!1;return}m.view.dispatch(m.state.tr.setMeta(f,{type:`updateOptions`,options:g.current}))}},[_,m,n,r,a,s,i,o,f]),(0,Pe.createPortal)(c,d.current)});M.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...c},l)=>{let u=(0,M.useRef)(document.createElement(`div`)),d=(0,M.useRef)(FD(e,`floatingMenu`)).current;aO(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=Mm(),p=t||f,m={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:a,options:o},h=(0,M.useRef)(m);h.current=m;let[g,_]=(0,M.useState)(!1),v=(0,M.useRef)(!0);return(0,M.useEffect)(()=>{if(p?.isDestroyed)return;if(!p){console.warn(`FloatingMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=u.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=PD({...h.current,editor:p,element:e});p.registerPlugin(t);let n=h.current.pluginKey;return v.current=!0,_(!0),()=>{_(!1),p.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[p]),(0,M.useEffect)(()=>{if(!(!g||!p||p.isDestroyed)){if(v.current){v.current=!1;return}p.view.dispatch(p.state.tr.setMeta(d,{type:`updateOptions`,options:h.current}))}},[g,p,n,r,a,o,i,d]),(0,Pe.createPortal)(s,u.current)});function sO(e){let t=(0,sn.c)(49),{editor:n,labels:r}=e,i=oe(),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(null),l;t[0]===n?l=t[1]:(l={editor:n,selector:lO},t[0]=n,t[1]=l);let u=Em(l),d;t[2]!==u||t[3]!==r.openFailed||t[4]!==i?(d=async()=>{c(null),(await i(u)).ok||c(r.openFailed)},t[2]=u,t[3]=r.openFailed,t[4]=i,t[5]=d):d=t[5];let f=d,p;t[6]===u?p=t[7]:(p=async()=>{await Ae(u)&&(o(!0),window.setTimeout(()=>o(!1),1500))},t[6]=u,t[7]=p);let m=p,h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h={placement:`bottom`,offset:8},t[8]=h):h=t[8];let g;t[9]===u?g=t[10]:(g=(0,N.jsx)(`p`,{className:`max-w-xs truncate px-1 pb-2 text-xs text-fg-muted`,title:u,children:u}),t[9]=u,t[10]=g);let _;t[11]===f?_=t[12]:(_=()=>void f(),t[11]=f,t[12]=_);let v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,N.jsx)(E,{}),t[13]=v):v=t[13];let y;t[14]!==r.open||t[15]!==_?(y=(0,N.jsx)(uO,{label:r.open,onClick:_,children:v}),t[14]=r.open,t[15]=_,t[16]=y):y=t[16];let b;t[17]===n?b=t[18]:(b=()=>JE(n),t[17]=n,t[18]=b);let x;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,N.jsx)(ge,{}),t[19]=x):x=t[19];let C;t[20]!==r.edit||t[21]!==b?(C=(0,N.jsx)(uO,{label:r.edit,onClick:b,children:x}),t[20]=r.edit,t[21]=b,t[22]=C):C=t[22];let D=a?r.copied:r.copy,O;t[23]===m?O=t[24]:(O=()=>void m(),t[23]=m,t[24]=O);let k;t[25]===a?k=t[26]:(k=a?(0,N.jsx)(w,{}):(0,N.jsx)(T,{}),t[25]=a,t[26]=k);let A;t[27]!==D||t[28]!==O||t[29]!==k?(A=(0,N.jsx)(uO,{label:D,onClick:O,children:k}),t[27]=D,t[28]=O,t[29]=k,t[30]=A):A=t[30];let j;t[31]===n?j=t[32]:(j=()=>n.chain().focus().extendMarkRange(`link`).unsetLink().run(),t[31]=n,t[32]=j);let ee;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,N.jsx)(S,{}),t[33]=ee):ee=t[33];let te;t[34]!==r.remove||t[35]!==j?(te=(0,N.jsx)(uO,{label:r.remove,onClick:j,children:ee}),t[34]=r.remove,t[35]=j,t[36]=te):te=t[36];let ne;t[37]!==C||t[38]!==A||t[39]!==te||t[40]!==y?(ne=(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[y,C,A,te]}),t[37]=C,t[38]=A,t[39]=te,t[40]=y,t[41]=ne):ne=t[41];let re;t[42]===s?re=t[43]:(re=s?(0,N.jsx)(`p`,{className:`px-1 pt-2 text-xs text-danger`,role:`alert`,children:s}):null,t[42]=s,t[43]=re);let ie;return t[44]!==n||t[45]!==ne||t[46]!==re||t[47]!==g?(ie=(0,N.jsxs)(oO,{editor:n,shouldShow:cO,options:h,className:`max-w-sm rounded-lg border border-edge bg-surface-overlay p-2 shadow-xl`,children:[g,ne,re]}),t[44]=n,t[45]=ne,t[46]=re,t[47]=g,t[48]=ie):ie=t[48],ie}function cO(e){let{editor:t}=e;return t.isActive(`link`)}function lO(e){let{editor:t}=e;return String(t.getAttributes(`link`).href??``)}function uO(e){let t=(0,sn.c)(9),{children:n,label:r,onClick:i}=e,a;t[0]===n?a=t[1]:(a=(0,N.jsx)(`span`,{className:`[&_svg]:size-3.5`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,N.jsx)(`span`,{children:r}),t[2]=r,t[3]=o);let s;return t[4]!==r||t[5]!==i||t[6]!==a||t[7]!==o?(s=(0,N.jsxs)(`button`,{type:`button`,onClick:i,title:r,"aria-label":r,className:`inline-flex items-center gap-1 rounded-md px-2 py-1.5 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[a,o]}),t[4]=r,t[5]=i,t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function dO(e,t){let{doc:n}=e.state,r=n.resolve(t);return r.index(0)===0?`first`:r.index(0)===n.childCount-1?`last`:null}function fO({initialContent:e,onChange:t,placeholder:n=`Start writing, or type "/" for commands…`,className:r,noteId:i}){let a=c(s(e=>e.language)).notes,o=oe(),[l,u]=(0,M.useState)(!1),[d,f]=(0,M.useState)(null),p=(0,M.useRef)(t);p.current=t;let m=(0,M.useRef)(null),h=(0,M.useRef)({}),g=(0,M.useRef)(()=>void 0),_=(0,M.useRef)(e),v=(0,M.useRef)(e),y=(0,M.useRef)(!1),b=Am({extensions:[wb.configure({...qT,codeBlock:!1,trailingNode:!1}),vE.configure({HTMLAttributes:{class:`block-editor-code`}}),qE,nD.configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:`block-editor-image`}}),Tb,Eb.configure(JT),Db.configure({placeholder:({editor:e,node:t,pos:r})=>{if(t.type.name!==`paragraph`||t.content.size>0)return``;let i=dO(e,r);return i===`first`||i===`last`?n:``},includeChildren:!0}),tv.configure({...YT,HTMLAttributes:{class:`block-editor-link`}}),fE,pE,KT.configure(XT),aE,xE,KE.configure({getRuntime:()=>h.current})],content:``,onUpdate:({editor:e})=>{let t=ZT(e);_.current=t,v.current=t,p.current(t)},editorProps:{attributes:{class:`block-editor-content`},handlePaste:(e,t)=>{let n=t.clipboardData?.items;if(!n)return!1;for(let e of n)if(e.type.startsWith(`image/`)){t.preventDefault();let n=e.getAsFile();return n&&g.current(n),!0}return!1},handleClick:(e,t,n)=>{let r=YE(n);return r?(n.preventDefault(),o(r),!0):!1},handleDrop:(e,t)=>{let n=t.dataTransfer?.files;if(!n?.length)return!1;for(let e of n)if(e.type.startsWith(`image/`))return t.preventDefault(),g.current(e),!0;return!1}}}),x=(0,M.useCallback)(async e=>{if(!(!i||!b))try{u(!0),f(null);let t=await O(i,e);b.chain().focus().setImage({src:D(i,t.id),alt:e.name}).run(),bE(b)}catch(e){f(e instanceof Error?e.message:a.imageUploadFailedHint)}finally{u(!1)}},[b,i,a.imageUploadFailed,a.imageUploadFailedHint]);g.current=e=>{x(e)};let S=(0,M.useCallback)(()=>{m.current?.click()},[]);return h.current={onImageUpload:i?x:void 0,requestImagePicker:i?S:void 0},(0,M.useEffect)(()=>{if(!b)return;let t=e!==_.current,n=_.current===v.current;if(y.current&&(!t||!n))return;let r=!1,i=null,a=e,o=()=>{if(!(r||b.isDestroyed)){if(!b.isEditorContentInitialized){i=window.requestAnimationFrame(o);return}b.commands.setContent(a,{emitUpdate:!1}),_.current=a,v.current=a,y.current=!0}};return o(),()=>{r=!0,i!==null&&window.cancelAnimationFrame(i)}},[b,e]),b?(0,N.jsxs)(`div`,{className:ve(`flex h-full flex-col overflow-hidden`,r),children:[(0,N.jsx)(QE,{editor:b,onImageUpload:i?x:void 0,imageUploading:l}),d?(0,N.jsxs)(`div`,{className:`border-b border-danger/20 bg-danger-soft px-6 py-2 text-xs text-danger`,role:`alert`,children:[(0,N.jsx)(`span`,{className:`font-medium`,children:a.imageUploadFailed}),` · `,d]}):null,(0,N.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-y-auto px-6 py-4`,children:[(0,N.jsx)(Cm,{editor:b}),(0,N.jsx)(sO,{editor:b,labels:{open:a.linkOpen,edit:a.linkEdit,copy:a.linkCopy,copied:a.linkCopied,remove:a.linkRemove,openFailed:a.linkOpenFailed}})]}),(0,N.jsx)(`input`,{ref:m,type:`file`,accept:`image/*`,onChange:e=>{let t=e.target.files?.[0];t&&i&&x(t),m.current&&(m.current.value=``)},className:`hidden`})]}):null}export{fO as BlockEditor};
160
+ `);return/\s/.test(n)}):!1}function wE(e){return()=>{let t=e.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=e.view.coordsAtPos(t);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}}}function TE(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:wE(e)}function EE({match:e,dismissedRange:t,state:n,transaction:r,editor:i,shouldResetDismissed:a,effectiveAllowSpaces:o}){return a?.({editor:i,state:n,range:t,match:e,transaction:r,allowSpaces:o})?!1:o?e.range.from===t.from:e.range.from===t.from&&!CE(r)}function DE({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function OE({pluginKey:e,decorationTag:t,decorationClass:n,decorationContent:r,decorationEmptyClass:i,renderer:a,dispatchExit:o}){return{handleKeyDown(t,n){var r;let i=e.getState(t.state);if(!i.active)return!1;if(n.key===`Escape`||n.key===`Esc`){var s;return a==null||(s=a.onKeyDown)==null||s.call(a,{view:t,event:n,range:i.range}),o(t),!0}return(a==null||(r=a.onKeyDown)==null?void 0:r.call(a,{view:t,event:n,range:i.range}))||!1},decorations(a){let{active:o,range:s,decorationId:c,query:l}=e.getState(a);if(!o)return null;let u=!l?.length,d=[n];return u&&d.push(i),U.create(a.doc,[hc.inline(s.from,s.to,{nodeName:t,class:d.join(` `),"data-decoration-id":c||void 0,"data-decoration-content":r})])}}}function kE({editor:e,char:t,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,findSuggestionMatch:o,allow:s,shouldShow:c,shouldKeepDismissed:l,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,f,p,m){let{isEditable:h}=e,{composing:g}=e.view,{selection:_}=d,{empty:v,from:y}=_,b={...f},x=d.getMeta(u);if(x&&x.exit)return b.active=!1,b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null,b.dismissedRange=f.active?{...f.range}:f.dismissedRange,b;if(b.composing=g,d.docChanged&&b.dismissedRange!==null&&(b.dismissedRange={from:d.mapping.map(b.dismissedRange.from),to:d.mapping.map(b.dismissedRange.to)}),h&&(v||e.view.composing)){(y<f.range.from||y>f.range.to)&&!g&&!f.composing&&(b.active=!1);let u=o({char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:_.$from}),p=`id_${Math.floor(Math.random()*4294967295)}`;u&&s({editor:e,state:m,range:u.range,isActive:f.active})&&(!c||c({editor:e,range:u.range,query:u.query,text:u.text,transaction:d}))?(b.dismissedRange!==null&&!l({match:u,dismissedRange:b.dismissedRange,state:m,transaction:d})&&(b.dismissedRange=null),b.dismissedRange===null?(b.active=!0,b.decorationId=f.decorationId||p,b.range=u.range,b.query=u.query,b.text=u.text):b.active=!1):(u||(b.dismissedRange=null),b.active=!1)}else b.active=!1;return b.active||(b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null),b}}}function AE({editor:e,items:t}){let n=null,r=null,i=null,a=()=>{r!==null&&(clearTimeout(r),r=null),i?.(),i=null},o=e=>new Promise(t=>{i=t,r=setTimeout(()=>{r=null;let e=i;i=null,e?.()},e)}),s=()=>{n?.abort(),a(),n=null};return{abort:s,fetch:async(r,i)=>{s(),n=new AbortController;let a=n;if(i>0&&await o(i),n!==a||a.signal.aborted)return{status:`aborted`};try{let i=await t({editor:e,query:r,signal:a.signal});return n!==a||a.signal.aborted?{status:`aborted`}:{status:`resolved`,items:i}}catch{return n!==a||a.signal.aborted?{status:`aborted`}:{status:`error`}}}}}function jE({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[Ce({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(be()),!(r==null||(i=r.middleware)==null)&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function ME(e){if(e instanceof HTMLElement)return e;if(typeof e==`string`)try{let t=document.querySelector(e);if(t)return t}catch{return document.body}return document.body}function NE({getReferenceRect:e,contextElement:t,config:n,container:r,dismissOnOutsideClick:i,dismiss:a}){return(o,s={})=>{let c={getBoundingClientRect:()=>e()??new DOMRect,contextElement:t},l=!1,u=!o.isConnected;u&&ME(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=Ee(c,o,()=>{Se(c,o,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:e,y:t,placement:n,strategy:r})=>{if(s.onPosition){s.onPosition({x:e,y:t,placement:n,strategy:r});return}Object.assign(o.style,{position:r,left:`${e}px`,top:`${t}px`}),l||(l=!0,o.style.visibility=``)})},s.autoUpdate),f;return i&&(f=e=>{let n=e.target;!(n instanceof Node)||o.contains(n)||t.contains(n)||a()},document.addEventListener(`pointerdown`,f,!0)),()=>{d(),f&&document.removeEventListener(`pointerdown`,f,!0),u&&o.remove()}}}function PE({editor:e,pluginKey:t,items:n,renderer:r,minQueryLength:i,debounce:a,initialItems:o,placement:s,offset:c,container:l,flip:u,floatingUi:d,dismissOnOutsideClick:f,command:p,clientRectFor:m,dispatchExit:h}){let g,_=AE({editor:e,items:n}),v=jE({placement:s,offset:c,flip:u,floatingUi:d});function y(e,t){switch(e){case`started`:var n;r==null||(n=r.onStart)==null||n.call(r,t);break;case`updated`:var i;r==null||(i=r.onUpdate)==null||i.call(r,t);break;case`stopped`:var a;r==null||(a=r.onExit)==null||a.call(r,t)}}return{update:async(n,d)=>{let b=t.getState(d),x=t.getState(n.state);if(!b||!x)return;let S=null,C=b.query!==x.query,w=b.text!==x.text,T=b.range.from!==x.range.from||b.range.to!==x.range.to,E=C||w||T;if(!b.active&&x.active)S=`started`;else if(b.active&&!x.active)S=`stopped`;else if(x.active&&E)S=`updated`;else return;let D=S===`stopped`?b:x,O=n.dom.querySelector(`[data-decoration-id="${D.decorationId}"]`),k=m(n,O),A=i===0||(D.query?D.query.length>=i:!1),j=(S===`started`||S===`updated`)&&A;if(g={editor:e,range:D.range,query:D.query||``,text:D.text||``,items:o??[],command:t=>p({editor:e,range:D.range,props:t}),decorationNode:O,clientRect:k,loading:j,placement:s,offset:{mainAxis:c.mainAxis??4,crossAxis:c.crossAxis??0},container:l,flip:u,floatingUi:v,mount:NE({getReferenceRect:k,contextElement:n.dom,config:v,container:l,dismissOnOutsideClick:f,dismiss:()=>h(e.view)})},S===`started`){var ee;r==null||(ee=r.onBeforeStart)==null||ee.call(r,g)}if(S===`updated`){var te;r==null||(te=r.onBeforeUpdate)==null||te.call(r,g)}if(S===`started`&&y(S,g),S===`started`||S===`updated`)if(!j)_.abort(),g={...g,items:o??[],loading:!1};else{g={...g,items:o??[],loading:!0},S=`updated`,y(S,g);let e=await _.fetch(D.query||``,a);if(e.status===`aborted`)return;if(!t.getState(n.state)?.active){_.abort();return}g=e.status===`resolved`?{...g,items:e.items,loading:!1}:{...g,loading:!1}}if(S===`stopped`){_.abort(),y(S,g),g=void 0;return}S===`updated`&&y(S,g)},destroy:()=>{var e;_.abort(),g&&(r==null||(e=r.onExit)==null||e.call(r,g))}}}var FE=new H(`suggestion`);function IE({pluginKey:e=FE,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],minQueryLength:p=0,debounce:m=0,initialItems:h,placement:g=`bottom-start`,offset:_={},container:v,flip:y=!0,floatingUi:b,dismissOnOutsideClick:x=!0,render:S=()=>({}),allow:C=()=>!0,findSuggestionMatch:w=SE,shouldShow:T,shouldResetDismissed:E}){let D=S?.(),O=r&&!i,k=(n,r)=>TE(t,n,r,e);function A(e){return EE({...e,editor:t,shouldResetDismissed:E,effectiveAllowSpaces:O})}let j=t=>DE({view:t,pluginKeyRef:e});return new V({key:e,view:()=>PE({editor:t,pluginKey:e,items:f,renderer:D,minQueryLength:p,debounce:m,initialItems:h,placement:g,offset:_,container:v,flip:y,floatingUi:b,dismissOnOutsideClick:x,command:d,clientRectFor:k,dispatchExit:j}),state:kE({editor:t,char:n,effectiveAllowSpaces:O,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,findSuggestionMatch:w,allow:C,shouldShow:T,shouldKeepDismissed:A,pluginKey:e}),props:OE({pluginKey:e,decorationTag:s,decorationClass:c,decorationContent:l,decorationEmptyClass:u,renderer:D,dispatchExit:j})})}var LE=IE,RE=[{id:`heading1`,label:`Heading 1`,description:`Large section heading`,keywords:[`h1`,`title`,`heading`]},{id:`heading2`,label:`Heading 2`,description:`Medium section heading`,keywords:[`h2`,`heading`]},{id:`heading3`,label:`Heading 3`,description:`Small section heading`,keywords:[`h3`,`heading`]},{id:`bulletList`,label:`Bullet List`,description:`Unordered list`,keywords:[`ul`,`list`,`bullet`]},{id:`orderedList`,label:`Numbered List`,description:`Ordered list`,keywords:[`ol`,`list`,`numbered`]},{id:`taskList`,label:`Task List`,description:`List with checkboxes`,keywords:[`todo`,`task`,`checkbox`]},{id:`blockquote`,label:`Quote`,description:`Block quotation`,keywords:[`quote`,`blockquote`]},{id:`codeBlock`,label:`Code Block`,description:`Fenced code snippet`,keywords:[`code`,`snippet`]},{id:`divider`,label:`Divider`,description:`Horizontal rule`,keywords:[`hr`,`rule`,`line`]},{id:`image`,label:`Image`,description:`Upload an image`,keywords:[`img`,`photo`,`picture`]}];function zE(e){let t=e.trim().toLowerCase();return t?RE.filter(e=>[e.label,e.description,...e.keywords].join(` `).toLowerCase().includes(t)):RE}function BE(e,t,n,r){if(e.id===`image`){t.chain().focus().deleteRange(n).run(),r.requestImagePicker&&setTimeout(()=>r.requestImagePicker?.(),0);return}let i=t.chain().focus().deleteRange(n);switch(e.id){case`heading1`:i.setHeading({level:1}).run();return;case`heading2`:i.setHeading({level:2}).run();return;case`heading3`:i.setHeading({level:3}).run();return;case`bulletList`:i.toggleBulletList().run();return;case`orderedList`:i.toggleOrderedList().run();return;case`taskList`:i.toggleTaskList().run();return;case`blockquote`:i.toggleBlockquote().run();return;case`codeBlock`:i.toggleCodeBlock().run();return;case`divider`:i.setHorizontalRule().run(),bE(t);return;default:return}}var VE=`slash-menu-panel fixed z-[9999] w-64 overflow-hidden rounded-lg border border-edge bg-surface-base shadow-lg`,HE=`flex w-full items-center gap-3 rounded-md px-2.5 py-2 text-left transition-colors text-fg-muted hover:bg-surface-hover hover:text-fg`,UE=`bg-surface-hover text-fg`;function WE({editor:e,getRuntime:t}){let n=null,r=null,i=null,a=null,o=0,s=``,c=null,l=()=>{n?.remove(),n=null,r=null,i=null,a=null,c=null,o=0,s=``},u=()=>{n||(n=document.createElement(`div`),n.setAttribute(`data-slash-menu-root`,`true`),r=document.createElement(`div`),r.className=VE,i=document.createElement(`div`),i.className=`slash-menu-scroll max-h-72 overflow-y-auto p-1`,a=document.createElement(`input`),a.type=`file`,a.accept=`image/*`,a.className=`hidden`,a.addEventListener(`change`,()=>{let e=a?.files?.[0],n=t();e&&n.onImageUpload&&n.onImageUpload(e),a&&(a.value=``)}),r.appendChild(i),n.append(r,a),document.body.appendChild(n))},d=()=>{if(!r||!c)return;let e=c.clientRect?.()??null;if(e){r.style.top=`${e.bottom+6}px`,r.style.left=`${e.left}px`;return}let t=c.editor.view.coordsAtPos(c.range.to);r.style.top=`${t.bottom+6}px`,r.style.left=`${t.left}px`},f=()=>{if(!c||!i||!r)return;i.replaceChildren();let e=i;c.items.forEach((n,r)=>{let i=document.createElement(`button`);i.type=`button`,i.className=`${HE}${r===o?` ${UE}`:``}`;let s=document.createElement(`span`);s.className=`flex size-8 shrink-0 items-center justify-center rounded-md border border-edge bg-surface-inset text-xs font-semibold uppercase text-fg-muted`,s.textContent=n.label.slice(0,2);let l=document.createElement(`span`);l.className=`min-w-0 flex-1`;let u=document.createElement(`span`);u.className=`block truncate text-sm font-medium text-fg`,u.textContent=n.label;let d=document.createElement(`span`);d.className=`block truncate text-xs text-fg-muted`,d.textContent=n.description,l.append(u,d),i.append(s,l),i.addEventListener(`mousedown`,e=>{if(e.preventDefault(),c){if(n.id===`image`){BE(n,c.editor,c.range,{...t(),requestImagePicker:t().requestImagePicker??(()=>a?.click())});return}c.command(n)}}),e.appendChild(i)}),d()},p=e=>{e.query!==s&&(o=0,s=e.query),c=e,u(),f()};return e.on(`destroy`,l),{onStart:e=>{p(e)},onUpdate:e=>{p(e)},onExit:()=>{l()},onKeyDown:({event:e})=>{let n=c?.items??[];if(!n.length)return!1;if(e.key===`ArrowDown`)return o=(o+1)%n.length,f(),!0;if(e.key===`ArrowUp`)return o=(o-1+n.length)%n.length,f(),!0;if(e.key===`Enter`){let e=n[o];return e&&c&&(e.id===`image`?BE(e,c.editor,c.range,{...t(),requestImagePicker:t().requestImagePicker??(()=>a?.click())}):c.command(e)),!0}return!1},destroy:l}}var GE=new H(`slashCommands`),KE=q.create({name:`slashCommands`,addOptions(){return{getRuntime:()=>({})}},addStorage(){return{active:!1}},onDestroy(){this.storage.active=!1},addProseMirrorPlugins(){let e=this,t=WE({editor:this.editor,getRuntime:()=>e.options.getRuntime()});return[LE({pluginKey:GE,editor:this.editor,char:`/`,allowedPrefixes:null,items:({query:e})=>zE(e),command:({editor:t,range:n,props:r})=>{BE(r,t,n,e.options.getRuntime())},render:()=>({onStart:n=>{e.storage.active=!0,t.onStart(n)},onUpdate:e=>{t.onUpdate(e)},onExit:()=>{e.storage.active=!1,t.onExit()},onKeyDown:t.onKeyDown})})]}}),qE=Sb.configure({node:`paragraph`,notAfter:[`paragraph`]});function JE(e){let t=String(e.getAttributes(`link`).href??``),n=window.prompt(`URL`,t);if(n!==null){if(!n.trim()){e.chain().focus().extendMarkRange(`link`).unsetLink().run();return}e.chain().focus().extendMarkRange(`link`).setLink({href:n.trim()}).run()}}function YE(e){return!e.metaKey&&!e.ctrlKey?null:(e.target instanceof Element?e.target:null)?.closest(`a[href]`)?.getAttribute(`href`)?.trim()||null}function XE(e){let t=(0,sn.c)(9),{onClick:n,isActive:r,disabled:i,title:a,children:o}=e,s=r&&`bg-surface-hover text-accent`,c=i&&`pointer-events-none opacity-40`,l;t[0]!==s||t[1]!==c?(l=ve(`rounded-md p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,s,c),t[0]=s,t[1]=c,t[2]=l):l=t[2];let u;return t[3]!==o||t[4]!==i||t[5]!==n||t[6]!==l||t[7]!==a?(u=(0,N.jsx)(`button`,{type:`button`,onClick:n,disabled:i,title:a,className:l,children:o}),t[3]=o,t[4]=i,t[5]=n,t[6]=l,t[7]=a,t[8]=u):u=t[8],u}function ZE(){let e=(0,sn.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,N.jsx)(`div`,{className:`mx-1 h-5 w-px bg-edge`}),e[0]=t):t=e[0],t}function QE(e){let t=(0,sn.c)(131),{editor:n,onImageUpload:r,imageUploading:i}=e,a=i!==void 0&&i,o=(0,M.useRef)(null),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{o.current?.click()},t[0]=s):s=t[0];let c=s,S;t[1]!==a||t[2]!==r?(S=e=>{let t=e.target.files?.[0];t&&r&&!a&&r(t),o.current&&(o.current.value=``)},t[1]=a,t[2]=r,t[3]=S):S=t[3];let w=S,T,E;t[4]===n?(T=t[5],E=t[6]):(T=()=>n.chain().focus().undo().run(),E=n.can().undo(),t[4]=n,t[5]=T,t[6]=E);let D=!E,O;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,N.jsx)(_,{size:16}),t[7]=O):O=t[7];let k;t[8]!==T||t[9]!==D?(k=(0,N.jsx)(XE,{onClick:T,disabled:D,title:`Undo`,children:O}),t[8]=T,t[9]=D,t[10]=k):k=t[10];let A,j;t[11]===n?(A=t[12],j=t[13]):(j=()=>n.chain().focus().redo().run(),A=n.can().redo(),t[11]=n,t[12]=A,t[13]=j);let ee=!A,ne;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,N.jsx)(m,{size:16}),t[14]=ne):ne=t[14];let re;t[15]!==ee||t[16]!==j?(re=(0,N.jsx)(XE,{onClick:j,disabled:ee,title:`Redo`,children:ne}),t[15]=ee,t[16]=j,t[17]=re):re=t[17];let ae;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,N.jsx)(ZE,{}),t[18]=ae):ae=t[18];let oe,se;t[19]===n?(oe=t[20],se=t[21]):(oe=()=>n.chain().focus().toggleHeading({level:1}).run(),se=n.isActive(`heading`,{level:1}),t[19]=n,t[20]=oe,t[21]=se);let ce;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,N.jsx)(y,{size:16}),t[22]=ce):ce=t[22];let le;t[23]!==oe||t[24]!==se?(le=(0,N.jsx)(XE,{onClick:oe,isActive:se,title:`Heading 1`,children:ce}),t[23]=oe,t[24]=se,t[25]=le):le=t[25];let ue,de;t[26]===n?(ue=t[27],de=t[28]):(ue=()=>n.chain().focus().toggleHeading({level:2}).run(),de=n.isActive(`heading`,{level:2}),t[26]=n,t[27]=ue,t[28]=de);let fe;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,N.jsx)(f,{size:16}),t[29]=fe):fe=t[29];let pe;t[30]!==ue||t[31]!==de?(pe=(0,N.jsx)(XE,{onClick:ue,isActive:de,title:`Heading 2`,children:fe}),t[30]=ue,t[31]=de,t[32]=pe):pe=t[32];let me,he;t[33]===n?(me=t[34],he=t[35]):(me=()=>n.chain().focus().toggleHeading({level:3}).run(),he=n.isActive(`heading`,{level:3}),t[33]=n,t[34]=me,t[35]=he);let ge;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,N.jsx)(d,{size:16}),t[36]=ge):ge=t[36];let _e;t[37]!==me||t[38]!==he?(_e=(0,N.jsx)(XE,{onClick:me,isActive:he,title:`Heading 3`,children:ge}),t[37]=me,t[38]=he,t[39]=_e):_e=t[39];let ve;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,N.jsx)(ZE,{}),t[40]=ve):ve=t[40];let ye,be;t[41]===n?(ye=t[42],be=t[43]):(ye=()=>n.chain().focus().toggleBold().run(),be=n.isActive(`bold`),t[41]=n,t[42]=ye,t[43]=be);let xe;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,N.jsx)(p,{size:16}),t[44]=xe):xe=t[44];let Se;t[45]!==ye||t[46]!==be?(Se=(0,N.jsx)(XE,{onClick:ye,isActive:be,title:`Bold (⌘B)`,children:xe}),t[45]=ye,t[46]=be,t[47]=Se):Se=t[47];let Ce,we;t[48]===n?(Ce=t[49],we=t[50]):(Ce=()=>n.chain().focus().toggleItalic().run(),we=n.isActive(`italic`),t[48]=n,t[49]=Ce,t[50]=we);let Te;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,N.jsx)(h,{size:16}),t[51]=Te):Te=t[51];let Ee;t[52]!==Ce||t[53]!==we?(Ee=(0,N.jsx)(XE,{onClick:Ce,isActive:we,title:`Italic (⌘I)`,children:Te}),t[52]=Ce,t[53]=we,t[54]=Ee):Ee=t[54];let De,Oe;t[55]===n?(De=t[56],Oe=t[57]):(De=()=>n.chain().focus().toggleStrike().run(),Oe=n.isActive(`strike`),t[55]=n,t[56]=De,t[57]=Oe);let ke;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,N.jsx)(b,{size:16}),t[58]=ke):ke=t[58];let Ae;t[59]!==De||t[60]!==Oe?(Ae=(0,N.jsx)(XE,{onClick:De,isActive:Oe,title:`Strikethrough`,children:ke}),t[59]=De,t[60]=Oe,t[61]=Ae):Ae=t[61];let je,Me;t[62]===n?(je=t[63],Me=t[64]):(je=()=>n.chain().focus().toggleCode().run(),Me=n.isActive(`code`),t[62]=n,t[63]=je,t[64]=Me);let Ne;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,N.jsx)(g,{size:16}),t[65]=Ne):Ne=t[65];let Pe;t[66]!==je||t[67]!==Me?(Pe=(0,N.jsx)(XE,{onClick:je,isActive:Me,title:`Inline code`,children:Ne}),t[66]=je,t[67]=Me,t[68]=Pe):Pe=t[68];let Fe,Ie;t[69]===n?(Fe=t[70],Ie=t[71]):(Fe=()=>JE(n),Ie=n.isActive(`link`),t[69]=n,t[70]=Fe,t[71]=Ie);let Le;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,N.jsx)(u,{size:16}),t[72]=Le):Le=t[72];let P;t[73]!==Fe||t[74]!==Ie?(P=(0,N.jsx)(XE,{onClick:Fe,isActive:Ie,title:`Link`,children:Le}),t[73]=Fe,t[74]=Ie,t[75]=P):P=t[75];let Re;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(0,N.jsx)(ZE,{}),t[76]=Re):Re=t[76];let ze,Be;t[77]===n?(ze=t[78],Be=t[79]):(ze=()=>n.chain().focus().toggleBulletList().run(),Be=n.isActive(`bulletList`),t[77]=n,t[78]=ze,t[79]=Be);let Ve;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=(0,N.jsx)(v,{size:16}),t[80]=Ve):Ve=t[80];let F;t[81]!==ze||t[82]!==Be?(F=(0,N.jsx)(XE,{onClick:ze,isActive:Be,title:`Bullet list`,children:Ve}),t[81]=ze,t[82]=Be,t[83]=F):F=t[83];let He,Ue;t[84]===n?(He=t[85],Ue=t[86]):(He=()=>n.chain().focus().toggleOrderedList().run(),Ue=n.isActive(`orderedList`),t[84]=n,t[85]=He,t[86]=Ue);let We;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(We=(0,N.jsx)(x,{size:16}),t[87]=We):We=t[87];let I;t[88]!==He||t[89]!==Ue?(I=(0,N.jsx)(XE,{onClick:He,isActive:Ue,title:`Ordered list`,children:We}),t[88]=He,t[89]=Ue,t[90]=I):I=t[90];let Ge,L;t[91]===n?(Ge=t[92],L=t[93]):(Ge=()=>n.chain().focus().toggleTaskList().run(),L=n.isActive(`taskList`),t[91]=n,t[92]=Ge,t[93]=L);let Ke;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,N.jsx)(te,{size:16}),t[94]=Ke):Ke=t[94];let qe;t[95]!==Ge||t[96]!==L?(qe=(0,N.jsx)(XE,{onClick:Ge,isActive:L,title:`Task list`,children:Ke}),t[95]=Ge,t[96]=L,t[97]=qe):qe=t[97];let Je,Ye;t[98]===n?(Je=t[99],Ye=t[100]):(Je=()=>n.chain().focus().toggleBlockquote().run(),Ye=n.isActive(`blockquote`),t[98]=n,t[99]=Je,t[100]=Ye);let Xe;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=(0,N.jsx)(l,{size:16}),t[101]=Xe):Xe=t[101];let Ze;t[102]!==Je||t[103]!==Ye?(Ze=(0,N.jsx)(XE,{onClick:Je,isActive:Ye,title:`Quote`,children:Xe}),t[102]=Je,t[103]=Ye,t[104]=Ze):Ze=t[104];let Qe;t[105]===n?Qe=t[106]:(Qe=()=>{n.chain().focus().setHorizontalRule().run(),bE(n)},t[105]=n,t[106]=Qe);let $e;t[107]===Symbol.for(`react.memo_cache_sentinel`)?($e=(0,N.jsx)(ie,{size:16}),t[107]=$e):$e=t[107];let et;t[108]===Qe?et=t[109]:(et=(0,N.jsx)(XE,{onClick:Qe,title:`Divider`,children:$e}),t[108]=Qe,t[109]=et);let tt;t[110]!==w||t[111]!==a||t[112]!==r?(tt=r&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(ZE,{}),(0,N.jsx)(XE,{onClick:c,disabled:a,title:a?`Uploading…`:`Insert image`,children:(0,N.jsx)(C,{size:16,className:a?`animate-pulse`:void 0})}),(0,N.jsx)(`input`,{ref:o,type:`file`,accept:`image/*`,onChange:w,className:`hidden`})]}),t[110]=w,t[111]=a,t[112]=r,t[113]=tt):tt=t[113];let nt;return t[114]!==re||t[115]!==le||t[116]!==pe||t[117]!==_e||t[118]!==Se||t[119]!==Ee||t[120]!==Ae||t[121]!==Pe||t[122]!==P||t[123]!==F||t[124]!==I||t[125]!==qe||t[126]!==Ze||t[127]!==et||t[128]!==tt||t[129]!==k?(nt=(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-0.5 border-b border-edge px-3 py-1.5`,children:[k,re,ae,le,pe,_e,ve,Se,Ee,Ae,Pe,P,Re,F,I,qe,Ze,et,tt]}),t[114]=re,t[115]=le,t[116]=pe,t[117]=_e,t[118]=Se,t[119]=Ee,t[120]=Ae,t[121]=Pe,t[122]=P,t[123]=F,t[124]=I,t[125]=qe,t[126]=Ze,t[127]=et,t[128]=tt,t[129]=k,t[130]=nt):nt=t[130],nt}var $E=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,eD=J.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,K(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?`![${n}](${t} "${r}")`:`![${n}](${t})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,i=new Set([`src`,`width`,`height`]);return({node:a,getPos:o,HTMLAttributes:s,editor:c})=>{let l=document.createElement(`img`);l.draggable=!1;let u=K(this.options.HTMLAttributes,s);Object.entries(u).forEach(([e,t])=>{if(t!=null)switch(e){case`src`:case`width`:case`height`:break;default:l.setAttribute(e,t)}}),u.src!==null&&(l.src=u.src);let d={...s},f=e=>{if(typeof e==`string`&&e!==``){l.getAttribute(`src`)!==e&&(l.src=e);return}l.hasAttribute(`src`)&&l.removeAttribute(`src`),l.src!==``&&(l.src=``)};f(s.src);let p=new _p({element:l,editor:c,node:a,getPos:o,onResize:(e,t)=>{l.style.width=`${e}px`,l.style.height=`${t}px`},onCommit:(e,t)=>{let n=o();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:e=>{if(e.type!==a.type)return!1;let t=Hu(e,c.extensionManager.attributes.filter(t=>t.type===e.type.name));return Object.keys(d).forEach(e=>{!i.has(e)&&!(e in t)&&l.removeAttribute(e)}),Object.entries(t).forEach(([e,t])=>{i.has(e)||(t==null?l.removeAttribute(e):l.setAttribute(e,t))}),f(t.src),d=t,!0},options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),m=p.dom,h=()=>{m.style.visibility=``,m.style.pointerEvents=``};return m.style.visibility=`hidden`,m.style.pointerEvents=`none`,l.complete&&l.naturalWidth>0?h():(l.onload=h,l.onerror=h),p}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[pp({find:$E,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});function tD(e){let t=(0,sn.c)(28),{node:n,updateAttributes:r,selected:i}=e,{src:a,alt:o,title:s}=n.attrs,{openImage:c}=k(),[l,u]=(0,M.useState)(!1),d=(0,M.useRef)(null),[f,p]=(0,M.useState)(!1),m=(0,M.useRef)(0),h=(0,M.useRef)(0),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=e=>{e.preventDefault(),e.stopPropagation(),p(!0),m.current=e.clientX,h.current=d.current?.offsetWidth??400},t[0]=g):g=t[0];let _=g,v,y;t[1]!==f||t[2]!==r?(v=()=>{if(!f)return;let e=e=>{let t=e.clientX-m.current,n=Math.max(100,h.current+t);r({width:n})},t=()=>{p(!1)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},y=[f,r],t[1]=f,t[2]=r,t[3]=v,t[4]=y):(v=t[3],y=t[4]),(0,M.useEffect)(v,y);let b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{u(!1)},t[5]=b):b=t[5];let x;t[6]===a?x=t[7]:(x=[a],t[6]=a,t[7]=x),(0,M.useEffect)(b,x);let S=n.attrs.width,C=i&&`ring-2 ring-accent ring-offset-2 ring-offset-surface-base rounded-lg`,w;t[8]===C?w=t[9]:(w=ve(`relative inline-block`,C),t[8]=C,t[9]=w);let T=S?`${S}px`:void 0,E;t[10]===T?E=t[11]:(E={width:T,maxWidth:`100%`},t[10]=T,t[11]=E);let D;t[12]!==o||t[13]!==l||t[14]!==c||t[15]!==a||t[16]!==s?(D=l?(0,N.jsx)(`div`,{className:`flex min-h-24 min-w-[12rem] items-center justify-center rounded-lg border border-dashed border-edge bg-surface-hover text-fg-muted`,children:(0,N.jsx)(`span`,{className:`text-xs`,children:`Image unavailable`})}):(0,N.jsx)(ee,{src:a,alt:o??``,title:s??void 0,className:`block h-auto w-full cursor-zoom-in rounded-lg`,draggable:!1,onClick:e=>c(e,o??void 0),onLoadFailed:()=>u(!0)}),t[12]=o,t[13]=l,t[14]=c,t[15]=a,t[16]=s,t[17]=D):D=t[17];let O=(i||f)&&`opacity-100`,A;t[18]===O?A=t[19]:(A=ve(`absolute bottom-1 right-1 size-4 cursor-se-resize rounded-sm opacity-0 transition-opacity`,`bg-accent/70 hover:bg-accent`,O),t[18]=O,t[19]=A);let j;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,N.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,className:`m-0.5 text-white`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,N.jsx)(`path`,{d:`M10 2L2 10M10 6L6 10M10 10L10 10`,strokeLinecap:`round`})}),t[20]=j):j=t[20];let te;t[21]===A?te=t[22]:(te=(0,N.jsx)(`div`,{onMouseDown:_,className:A,title:`Drag to resize`,children:j}),t[21]=A,t[22]=te);let ne;return t[23]!==D||t[24]!==te||t[25]!==w||t[26]!==E?(ne=(0,N.jsx)(Im,{className:`block-editor-image-wrapper`,children:(0,N.jsxs)(`div`,{ref:d,className:w,style:E,children:[D,te]})}),t[23]=D,t[24]=te,t[25]=w,t[26]=E,t[27]=ne):ne=t[27],ne}var nD=eD.extend({addAttributes(){return{...this.parent?.(),width:{default:null,parseHTML:e=>{let t=e.getAttribute(`width`)||e.style.width;return t?parseInt(t,10):null},renderHTML:e=>e.width?{width:e.width,style:`width: ${e.width}px`}:{}}}},addNodeView(){return Xm(tD)}}),rD,iD;if(typeof WeakMap<`u`){let e=new WeakMap;rD=t=>e.get(t),iD=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;rD=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},iD=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var aD=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return rD(e)||iD(e,oD(e))}};function oD(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=sD(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new aD(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&cD(s,o,e),s}function sD(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function cD(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!c.colwidth||c.colwidth[n]!=r)&&((s||=lD(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function lD(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function uD(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}new H(`selectingCells`);function dD(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function fD(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function pD(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=dD(t.$head)||mD(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function mD(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function hD(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function gD(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function _D(e,t,n){let r=e.node(-1),i=aD.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function vD(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}var yD=class e extends R{constructor(e,t=e){let n=e.node(-1),r=aD.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new Cr(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(hD(r)&&hD(i)&&gD(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return z.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=aD.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=vD(e,0,l)),u>0&&(e=vD(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(F.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new L(F.from(o),1,1)}replace(e,t=L.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?L.empty:t)}let i=R.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new L(F.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=aD.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=aD.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=aD.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=aD.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new bD(this.$anchorCell.pos,this.$headCell.pos)}};yD.prototype.visible=!1,R.jsonID(`cell`,yD);var bD=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&gD(t,n)?new yD(t,n):R.near(n,1)}};new H(`fix-tables`);function xD(e){let t=e.selection,n=pD(e),r=n.node(-1),i=n.start(-1),a=aD.get(r);return{...t instanceof yD?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function SD(e){return function(t,n){if(!fD(t))return!1;if(n){let r=uD(t.schema),i=xD(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function CD(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function wD(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?SD(e):function(t,n){if(!fD(t))return!1;if(n){let r=uD(t.schema),i=xD(t),a=t.tr,o=CD(`row`,i,r),s=CD(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}wD(`row`,{useDeprecatedLogic:!0}),wD(`column`,{useDeprecatedLogic:!0}),wD(`cell`,{useDeprecatedLogic:!0});function TD(e,t){let n=e.selection;if(!(n instanceof yD))return!1;if(t){let r=e.tr,i=uD(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new L(i,0,0))}),r.docChanged&&t(r)}return!0}ul({ArrowLeft:DD(`horiz`,-1),ArrowRight:DD(`horiz`,1),ArrowUp:DD(`vert`,-1),ArrowDown:DD(`vert`,1),"Shift-ArrowLeft":OD(`horiz`,-1),"Shift-ArrowRight":OD(`horiz`,1),"Shift-ArrowUp":OD(`vert`,-1),"Shift-ArrowDown":OD(`vert`,1),Backspace:TD,"Mod-Backspace":TD,Delete:TD,"Mod-Delete":TD});function ED(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function DD(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof yD)return ED(n,r,R.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=kD(i,e,t);if(o==null)return!1;if(e==`horiz`)return ED(n,r,R.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=_D(i,e,t),s;return s=a?R.near(a,1):t<0?R.near(n.doc.resolve(i.before(-1)),-1):R.near(n.doc.resolve(i.after(-1)),1),ED(n,r,s)}}}function OD(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof yD)o=a;else{let r=kD(i,e,t);if(r==null)return!1;o=new yD(n.doc.resolve(r))}let s=_D(o.$headCell,e,t);return s?ED(n,r,new yD(o.$anchorCell,s)):!1}}function kD(e,t,n){if(!(e.state.selection instanceof z))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}new H(`tableColumnResizing`);function AD(e,t){let n=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),a=Math.max(e.right,t.right)-i,o=r-n;return new DOMRect(i,n,a,o)}var jD=class{get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(be(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(ke(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(Ce(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(Oe(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(xe(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(we(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(Te(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(De(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}get virtualElement(){var e;let{selection:t}=this.editor.state,n=this.getReferencedVirtualElement?.call(this);if(n)return n;if(!(!((e=this.view)==null||(e=e.dom)==null)&&e.parentNode))return;let r=Sd(this.view,t.from,t.to),i={getBoundingClientRect:()=>r,getClientRects:()=>[r]};if(t instanceof B){let e=this.view.nodeDOM(t.from),n=e.dataset.nodeViewWrapper?e:e.querySelector(`[data-node-view-wrapper]`);n&&(e=n),e&&(i={getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>[e.getBoundingClientRect()]})}if(t instanceof yD){let{$anchorCell:e,$headCell:n}=t,r=e?e.pos:n.pos,a=n?n.pos:e.pos,o=this.view.nodeDOM(r),s=this.view.nodeDOM(a);if(!o||!s)return;let c=o===s?o.getBoundingClientRect():AD(o.getBoundingClientRect(),s.getBoundingClientRect());i={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return i}constructor({editor:e,element:t,view:n,pluginKey:r=`bubbleMenu`,updateDelay:i=250,resizeDelay:a=60,shouldShow:o,appendTo:s,getReferencedVirtualElement:c,options:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:`absolute`,placement:`top`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:t,from:n,to:r})=>{let{doc:i,selection:a}=t,{empty:o}=a,s=!i.textBetween(n,r).length&&Ll(t.selection),c=this.element.contains(document.activeElement);return!(!(e.hasFocus()||c)||o||s||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);!n&&!r||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.show(),this.updatePosition()}},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=l?.scrollTarget??window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener(`dragstart`,this.dragstartHandler),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&Se(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(e,t);return}let i=!t?.selection.eq(e.state.selection),a=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,a,t)}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,element:this.element,view:this.view,state:t,oldState:e,from:i,to:a})||!1}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener(`dragstart`,this.dragstartHandler),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},MD=e=>new V({key:typeof e.pluginKey==`string`?new H(e.pluginKey):e.pluginKey,view:t=>new jD({view:t,...e})});q.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[MD({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var ND=class{getTextContent(e){return Qu(e,{textSerializers:$u(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(be(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(ke(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(Ce(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(Oe(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(xe(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(we(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(Te(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(De(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}constructor({editor:e,element:t,view:n,pluginKey:r=`floatingMenu`,updateDelay:i=250,resizeDelay:a=60,options:o,appendTo:s,shouldShow:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:e,state:t})=>{let{selection:n}=t,{$anchor:r,empty:i}=n,a=r.depth===1,o=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&r.parent.childCount===0&&!this.getTextContent(r.parent);return!(!e.hasFocus()||!i||!a||!o||!this.editor.isEditable)},this.floatingUIOptions={strategy:`absolute`,placement:`right`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.updatePosition(),this.show()}},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=o?.scrollTarget??window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,c&&(this.shouldShow=c),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,view:this.view,state:t,oldState:e,from:i,to:a})}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){var e;if(!(!((e=this.view)==null||(e=e.dom)==null)&&e.parentNode))return;let{selection:t}=this.editor.state,n=Sd(this.view,t.from,t.to);Se({getBoundingClientRect:()=>n,getClientRects:()=>[n]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);this.updateHandler(e,n,r,t)}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},PD=e=>new V({key:typeof e.pluginKey==`string`?new H(e.pluginKey):e.pluginKey,view:t=>new ND({view:t,...e})});q.create({name:`floatingMenu`,addOptions(){return{element:null,options:{},pluginKey:`floatingMenu`,updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,`updatePosition`),!0)}},addProseMirrorPlugins(){return this.options.element?[PD({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function FD(e,t){return e??new H(t)}var ID=typeof window<`u`?M.useLayoutEffect:M.useEffect,LD=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),RD=new Set(`animationIterationCount.aspectRatio.borderImageOutset.borderImageSlice.borderImageWidth.columnCount.columns.fillOpacity.flex.flexGrow.flexShrink.fontWeight.gridArea.gridColumn.gridColumnEnd.gridColumnStart.gridRow.gridRowEnd.gridRowStart.lineClamp.lineHeight.opacity.order.orphans.scale.stopOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeOpacity.strokeWidth.tabSize.widows.zIndex.zoom`.split(`.`)),zD=new Set([`children`,`className`,`style`]),BD=new Set([`tabIndex`]),VD=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),HD={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function UD(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function WD(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function GD(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||VD.has(e)}function KD(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function qD(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:HD[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function JD(e,t){let n=t.defaultPrevented,r=!1,i=Object.create(t);return Object.defineProperties(i,{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>void 0},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,t.preventDefault()}},stopPropagation:{value:()=>{r=!0,t.stopPropagation()}}}),i}function YD(e){return BD.has(e)}function XD(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function ZD(e,t){if(t===`tabIndex`){e.removeAttribute(`tabindex`);return}let n=e[t];if(typeof n==`boolean`){e[t]=!1;return}if(typeof n==`number`){e[t]=0;return}e[t]=``}function QD(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||RD.has(e)?String(t):`${t}px`}function $D(e,t){LD.has(t)||e.style.removeProperty(KD(t))}function eO(e,t,n){LD.has(t)||e.style.setProperty(KD(t),QD(t,n))}function tO(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(zD.has(r)||!GD(r)||UD(r,t[r])||UD(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=WD(r);if(a==null||a===!1){YD(r)&&ZD(e,r),e.removeAttribute(o);return}if(a===!0){YD(r)&&XD(e,r,!0),e.setAttribute(o,``);return}if(YD(r)){XD(e,r,a);return}e.setAttribute(o,String(a))})}function nO(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function rO(e,t,n){let r=t??{},i=n??{};new Set([...Object.keys(r),...Object.keys(i)]).forEach(t=>{let n=r[t],a=i[t];if(n!==a){if(a==null){$D(e,t);return}eO(e,t,a)}})}function iO(e,t,n){t.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)});let r=[];return Object.entries(n).forEach(([t,n])=>{if(!UD(t,n))return;let{eventName:i,options:a}=qD(t),o=t=>{n(JD(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function aO(e,t){let n=(0,M.useRef)({}),r=(0,M.useRef)([]);ID(()=>{let i=n.current;return nO(e,i.className,t.className),rO(e,i.style,t.style),tO(e,i,t),r.current=iO(e,r.current,t),n.current=t,()=>{r.current.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)}),r.current=[]}},[e,t])}var oO=M.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:c,...l},u)=>{let d=(0,M.useRef)(document.createElement(`div`)),f=(0,M.useRef)(FD(e,`bubbleMenu`)).current;aO(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=Mm(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,getReferencedVirtualElement:o,options:s},g=(0,M.useRef)(h);g.current=h;let[_,v]=(0,M.useState)(!1),y=(0,M.useRef)(!0);return(0,M.useEffect)(()=>{if(m?.isDestroyed)return;if(!m){console.warn(`BubbleMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=d.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=MD({...g.current,editor:m,element:e});m.registerPlugin(t);let n=g.current.pluginKey;return y.current=!0,v(!0),()=>{v(!1),m.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[m]),(0,M.useEffect)(()=>{if(!(!_||!m||m.isDestroyed)){if(y.current){y.current=!1;return}m.view.dispatch(m.state.tr.setMeta(f,{type:`updateOptions`,options:g.current}))}},[_,m,n,r,a,s,i,o,f]),(0,Pe.createPortal)(c,d.current)});M.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...c},l)=>{let u=(0,M.useRef)(document.createElement(`div`)),d=(0,M.useRef)(FD(e,`floatingMenu`)).current;aO(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=Mm(),p=t||f,m={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:a,options:o},h=(0,M.useRef)(m);h.current=m;let[g,_]=(0,M.useState)(!1),v=(0,M.useRef)(!0);return(0,M.useEffect)(()=>{if(p?.isDestroyed)return;if(!p){console.warn(`FloatingMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=u.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=PD({...h.current,editor:p,element:e});p.registerPlugin(t);let n=h.current.pluginKey;return v.current=!0,_(!0),()=>{_(!1),p.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[p]),(0,M.useEffect)(()=>{if(!(!g||!p||p.isDestroyed)){if(v.current){v.current=!1;return}p.view.dispatch(p.state.tr.setMeta(d,{type:`updateOptions`,options:h.current}))}},[g,p,n,r,a,o,i,d]),(0,Pe.createPortal)(s,u.current)});function sO(e){let t=(0,sn.c)(49),{editor:n,labels:r}=e,i=oe(),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(null),l;t[0]===n?l=t[1]:(l={editor:n,selector:lO},t[0]=n,t[1]=l);let u=Em(l),d;t[2]!==u||t[3]!==r.openFailed||t[4]!==i?(d=async()=>{c(null),(await i(u)).ok||c(r.openFailed)},t[2]=u,t[3]=r.openFailed,t[4]=i,t[5]=d):d=t[5];let f=d,p;t[6]===u?p=t[7]:(p=async()=>{await Ae(u)&&(o(!0),window.setTimeout(()=>o(!1),1500))},t[6]=u,t[7]=p);let m=p,h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h={placement:`bottom`,offset:8},t[8]=h):h=t[8];let g;t[9]===u?g=t[10]:(g=(0,N.jsx)(`p`,{className:`max-w-xs truncate px-1 pb-2 text-xs text-fg-muted`,title:u,children:u}),t[9]=u,t[10]=g);let _;t[11]===f?_=t[12]:(_=()=>void f(),t[11]=f,t[12]=_);let v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,N.jsx)(E,{}),t[13]=v):v=t[13];let y;t[14]!==r.open||t[15]!==_?(y=(0,N.jsx)(uO,{label:r.open,onClick:_,children:v}),t[14]=r.open,t[15]=_,t[16]=y):y=t[16];let b;t[17]===n?b=t[18]:(b=()=>JE(n),t[17]=n,t[18]=b);let x;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,N.jsx)(ge,{}),t[19]=x):x=t[19];let C;t[20]!==r.edit||t[21]!==b?(C=(0,N.jsx)(uO,{label:r.edit,onClick:b,children:x}),t[20]=r.edit,t[21]=b,t[22]=C):C=t[22];let D=a?r.copied:r.copy,O;t[23]===m?O=t[24]:(O=()=>void m(),t[23]=m,t[24]=O);let k;t[25]===a?k=t[26]:(k=a?(0,N.jsx)(w,{}):(0,N.jsx)(T,{}),t[25]=a,t[26]=k);let A;t[27]!==D||t[28]!==O||t[29]!==k?(A=(0,N.jsx)(uO,{label:D,onClick:O,children:k}),t[27]=D,t[28]=O,t[29]=k,t[30]=A):A=t[30];let j;t[31]===n?j=t[32]:(j=()=>n.chain().focus().extendMarkRange(`link`).unsetLink().run(),t[31]=n,t[32]=j);let ee;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,N.jsx)(S,{}),t[33]=ee):ee=t[33];let te;t[34]!==r.remove||t[35]!==j?(te=(0,N.jsx)(uO,{label:r.remove,onClick:j,children:ee}),t[34]=r.remove,t[35]=j,t[36]=te):te=t[36];let ne;t[37]!==C||t[38]!==A||t[39]!==te||t[40]!==y?(ne=(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[y,C,A,te]}),t[37]=C,t[38]=A,t[39]=te,t[40]=y,t[41]=ne):ne=t[41];let re;t[42]===s?re=t[43]:(re=s?(0,N.jsx)(`p`,{className:`px-1 pt-2 text-xs text-danger`,role:`alert`,children:s}):null,t[42]=s,t[43]=re);let ie;return t[44]!==n||t[45]!==ne||t[46]!==re||t[47]!==g?(ie=(0,N.jsxs)(oO,{editor:n,shouldShow:cO,options:h,className:`max-w-sm rounded-lg border border-edge bg-surface-overlay p-2 shadow-xl`,children:[g,ne,re]}),t[44]=n,t[45]=ne,t[46]=re,t[47]=g,t[48]=ie):ie=t[48],ie}function cO(e){let{editor:t}=e;return t.isActive(`link`)}function lO(e){let{editor:t}=e;return String(t.getAttributes(`link`).href??``)}function uO(e){let t=(0,sn.c)(9),{children:n,label:r,onClick:i}=e,a;t[0]===n?a=t[1]:(a=(0,N.jsx)(`span`,{className:`[&_svg]:size-3.5`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,N.jsx)(`span`,{children:r}),t[2]=r,t[3]=o);let s;return t[4]!==r||t[5]!==i||t[6]!==a||t[7]!==o?(s=(0,N.jsxs)(`button`,{type:`button`,onClick:i,title:r,"aria-label":r,className:`inline-flex items-center gap-1 rounded-md px-2 py-1.5 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[a,o]}),t[4]=r,t[5]=i,t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function dO(e,t){let{doc:n}=e.state,r=n.resolve(t);return r.index(0)===0?`first`:r.index(0)===n.childCount-1?`last`:null}function fO({initialContent:e,onChange:t,placeholder:n=`Start writing, or type "/" for commands…`,className:r,noteId:i}){let a=c(s(e=>e.language)).notes,o=oe(),[l,u]=(0,M.useState)(!1),[d,f]=(0,M.useState)(null),p=(0,M.useRef)(t);p.current=t;let m=(0,M.useRef)(null),h=(0,M.useRef)({}),g=(0,M.useRef)(()=>void 0),_=(0,M.useRef)(e),v=(0,M.useRef)(e),y=(0,M.useRef)(!1),b=Am({extensions:[wb.configure({...qT,codeBlock:!1,trailingNode:!1}),vE.configure({HTMLAttributes:{class:`block-editor-code`}}),qE,nD.configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:`block-editor-image`}}),Tb,Eb.configure(JT),Db.configure({placeholder:({editor:e,node:t,pos:r})=>{if(t.type.name!==`paragraph`||t.content.size>0)return``;let i=dO(e,r);return i===`first`||i===`last`?n:``},includeChildren:!0}),tv.configure({...YT,HTMLAttributes:{class:`block-editor-link`}}),fE,pE,KT.configure(XT),aE,xE,KE.configure({getRuntime:()=>h.current})],content:``,onUpdate:({editor:e})=>{let t=ZT(e);_.current=t,v.current=t,p.current(t)},editorProps:{attributes:{class:`block-editor-content`},handlePaste:(e,t)=>{let n=t.clipboardData?.items;if(!n)return!1;for(let e of n)if(e.type.startsWith(`image/`)){t.preventDefault();let n=e.getAsFile();return n&&g.current(n),!0}return!1},handleClick:(e,t,n)=>{let r=YE(n);return r?(n.preventDefault(),o(r),!0):!1},handleDrop:(e,t)=>{let n=t.dataTransfer?.files;if(!n?.length)return!1;for(let e of n)if(e.type.startsWith(`image/`))return t.preventDefault(),g.current(e),!0;return!1}}}),x=(0,M.useCallback)(async e=>{if(!(!i||!b))try{u(!0),f(null);let t=await O(i,e);b.chain().focus().setImage({src:D(i,t.id),alt:e.name}).run(),bE(b)}catch(e){f(e instanceof Error?e.message:a.imageUploadFailedHint)}finally{u(!1)}},[b,i,a.imageUploadFailed,a.imageUploadFailedHint]);g.current=e=>{x(e)};let S=(0,M.useCallback)(()=>{m.current?.click()},[]);return h.current={onImageUpload:i?x:void 0,requestImagePicker:i?S:void 0},(0,M.useEffect)(()=>{if(!b)return;let t=e!==_.current,n=_.current===v.current;if(y.current&&(!t||!n))return;let r=!1,i=null,a=e,o=()=>{if(!(r||b.isDestroyed)){if(!b.isEditorContentInitialized){i=window.requestAnimationFrame(o);return}b.commands.setContent(a,{emitUpdate:!1}),_.current=a,v.current=a,y.current=!0}};return o(),()=>{r=!0,i!==null&&window.cancelAnimationFrame(i)}},[b,e]),b?(0,N.jsxs)(`div`,{className:ve(`flex h-full flex-col overflow-hidden`,r),children:[(0,N.jsx)(QE,{editor:b,onImageUpload:i?x:void 0,imageUploading:l}),d?(0,N.jsxs)(`div`,{className:`border-b border-danger/20 bg-danger-soft px-6 py-2 text-xs text-danger`,role:`alert`,children:[(0,N.jsx)(`span`,{className:`font-medium`,children:a.imageUploadFailed}),` · `,d]}):null,(0,N.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-y-auto px-6 py-4`,children:[(0,N.jsx)(Cm,{editor:b}),(0,N.jsx)(sO,{editor:b,labels:{open:a.linkOpen,edit:a.linkEdit,copy:a.linkCopy,copied:a.linkCopied,remove:a.linkRemove,openFailed:a.linkOpenFailed}})]}),(0,N.jsx)(`input`,{ref:m,type:`file`,accept:`image/*`,onChange:e=>{let t=e.target.files?.[0];t&&i&&x(t),m.current&&(m.current.value=``)},className:`hidden`})]}):null}export{fO as BlockEditor};