@aquera/nile-elements 2.0.15 → 2.0.17

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 (376) hide show
  1. package/README.md +6 -0
  2. package/demo/nxtgen-classes.css +5 -5
  3. package/demo/nxtgen-dark.css +16 -16
  4. package/demo/nxtgen-properties.css +2 -2
  5. package/demo/nxtgen-utilities.css +5 -5
  6. package/demo/nxtgen.css +5 -5
  7. package/demo/utilities.css +2 -2
  8. package/demo/variables.css +2 -2
  9. package/dist/{index-f6944844.cjs.js → index-0c0c869d.cjs.js} +2 -2
  10. package/dist/{index-f6944844.cjs.js.map → index-0c0c869d.cjs.js.map} +1 -1
  11. package/dist/{index-403841c7.cjs.js → index-129ef6fb.cjs.js} +3 -3
  12. package/dist/{index-403841c7.cjs.js.map → index-129ef6fb.cjs.js.map} +1 -1
  13. package/dist/{index-1faa963c.esm.js → index-36f2a6b5.esm.js} +1 -1
  14. package/dist/index-4df50481.esm.js +1 -0
  15. package/dist/index-5d34cff1.esm.js +1 -0
  16. package/dist/index-7ae95edd.cjs.js +2 -0
  17. package/dist/{index-3ca67627.cjs.js.map → index-7ae95edd.cjs.js.map} +1 -1
  18. package/dist/index-7ca72b78.esm.js +1 -0
  19. package/dist/index-bbe23ad8.cjs.js +2 -0
  20. package/dist/index-bbe23ad8.cjs.js.map +1 -0
  21. package/dist/index-ccc6a799.cjs.js +5 -0
  22. package/dist/index-ccc6a799.cjs.js.map +1 -0
  23. package/dist/index.cjs.js +1 -1
  24. package/dist/index.esm.js +1 -1
  25. package/dist/index.js +124 -72
  26. package/dist/nile-auto-complete/index.cjs.js +1 -1
  27. package/dist/nile-auto-complete/nile-auto-complete.cjs.js +1 -1
  28. package/dist/nile-auto-complete/portal-manager.cjs.js +1 -1
  29. package/dist/nile-auto-complete/portal-utils.cjs.js +1 -1
  30. package/dist/nile-code-editor/extensionSetup.cjs.js +2 -2
  31. package/dist/nile-code-editor/index.cjs.js +1 -1
  32. package/dist/nile-code-editor/nile-code-editor.cjs.js +1 -1
  33. package/dist/nile-code-editor/theme.cjs.js +1 -1
  34. package/dist/nile-color-picker/index.cjs.js +1 -1
  35. package/dist/nile-color-picker/nile-color-picker.cjs.js +1 -1
  36. package/dist/nile-combobox/index.cjs.js +1 -1
  37. package/dist/nile-combobox/nile-combobox.cjs.js +1 -1
  38. package/dist/nile-combobox/portal-manager.cjs.js +1 -1
  39. package/dist/nile-context-menu/index.cjs.js +1 -1
  40. package/dist/nile-context-menu/nile-context-menu.cjs.js +1 -1
  41. package/dist/nile-context-submenu/index.cjs.js +1 -1
  42. package/dist/nile-context-submenu/nile-context-submenu.cjs.js +1 -1
  43. package/dist/nile-detail/index.cjs.js +1 -1
  44. package/dist/nile-detail/nile-detail.cjs.js +1 -1
  45. package/dist/nile-dropdown/index.cjs.js +1 -1
  46. package/dist/nile-dropdown/nile-dropdown.cjs.js +1 -1
  47. package/dist/nile-dropdown/portal-manager.cjs.js +1 -1
  48. package/dist/nile-file-upload/index.cjs.js +1 -1
  49. package/dist/nile-file-upload/nile-file-upload.cjs.js +1 -1
  50. package/dist/nile-file-upload/nile-file-upload.template.cjs.js +1 -1
  51. package/dist/nile-floating-panel/index.cjs.js +1 -1
  52. package/dist/nile-floating-panel/nile-floating-panel.cjs.js +1 -1
  53. package/dist/nile-lite-tooltip/index.cjs.js +1 -1
  54. package/dist/nile-lite-tooltip/nile-lite-tooltip.cjs.js +1 -1
  55. package/dist/nile-lite-tooltip/nile-lite-tooltip.css.cjs.js +1 -1
  56. package/dist/nile-lite-tooltip/nile-lite-tooltip.css.cjs.js.map +1 -1
  57. package/dist/nile-lite-tooltip/nile-lite-tooltip.css.esm.js +1 -1
  58. package/dist/nile-markdown-editor/index.cjs.js +1 -1
  59. package/dist/nile-markdown-editor/nile-markdown-editor.cjs.js +1 -1
  60. package/dist/nile-popover/index.cjs.js +1 -1
  61. package/dist/nile-popover/nile-popover.cjs.js +1 -1
  62. package/dist/nile-popover/portal-manager.cjs.js +1 -1
  63. package/dist/nile-popup/index.cjs.js +1 -1
  64. package/dist/nile-popup/nile-popup.cjs.js +1 -1
  65. package/dist/nile-segmented-progress-bar/index.cjs.js +1 -1
  66. package/dist/nile-segmented-progress-bar/nile-segmented-progress-bar.cjs.js +1 -1
  67. package/dist/nile-select/index.cjs.js +1 -1
  68. package/dist/nile-select/nile-select.cjs.js +1 -1
  69. package/dist/nile-select/portal-manager.cjs.js +1 -1
  70. package/dist/nile-side-bar-action/index.cjs.js +1 -1
  71. package/dist/nile-side-bar-action/nile-side-bar-action.cjs.js +1 -1
  72. package/dist/nile-side-bar-action/portal-manager.cjs.js +1 -1
  73. package/dist/nile-tooltip/index.cjs.js +1 -1
  74. package/dist/nile-tooltip/nile-tooltip.cjs.js +1 -1
  75. package/dist/nile-tooltip/nile-tooltip.css.cjs.js +1 -1
  76. package/dist/nile-tooltip/nile-tooltip.css.cjs.js.map +1 -1
  77. package/dist/nile-tooltip/nile-tooltip.css.esm.js +1 -1
  78. package/dist/nile-virtual-select/index.cjs.js +1 -1
  79. package/dist/nile-virtual-select/nile-virtual-select.cjs.js +1 -1
  80. package/dist/nile-virtual-select/portal-manager.cjs.js +1 -1
  81. package/dist/nile-virtual-select/renderer.cjs.js +1 -1
  82. package/dist/nile-wysiwyg-editor/engine/commands.cjs.js +1 -1
  83. package/dist/nile-wysiwyg-editor/engine/commands.cjs.js.map +1 -1
  84. package/dist/nile-wysiwyg-editor/engine/commands.esm.js +1 -1
  85. package/dist/nile-wysiwyg-editor/engine/create-state.cjs.js +1 -1
  86. package/dist/nile-wysiwyg-editor/engine/create-state.cjs.js.map +1 -1
  87. package/dist/nile-wysiwyg-editor/engine/create-state.esm.js +1 -1
  88. package/dist/nile-wysiwyg-editor/engine/email-css.cjs.js +2 -0
  89. package/dist/nile-wysiwyg-editor/engine/email-css.cjs.js.map +1 -0
  90. package/dist/nile-wysiwyg-editor/engine/email-css.esm.js +1 -0
  91. package/dist/nile-wysiwyg-editor/engine/email-render.cjs.js +2 -0
  92. package/dist/nile-wysiwyg-editor/engine/email-render.cjs.js.map +1 -0
  93. package/dist/nile-wysiwyg-editor/engine/email-render.esm.js +1 -0
  94. package/dist/nile-wysiwyg-editor/engine/html-detect.cjs.js +2 -0
  95. package/dist/nile-wysiwyg-editor/engine/html-detect.cjs.js.map +1 -0
  96. package/dist/nile-wysiwyg-editor/engine/html-detect.esm.js +1 -0
  97. package/dist/nile-wysiwyg-editor/engine/index.cjs.js +1 -1
  98. package/dist/nile-wysiwyg-editor/engine/index.esm.js +1 -1
  99. package/dist/nile-wysiwyg-editor/engine/inputrules.cjs.js +1 -1
  100. package/dist/nile-wysiwyg-editor/engine/inputrules.cjs.js.map +1 -1
  101. package/dist/nile-wysiwyg-editor/engine/inputrules.esm.js +1 -1
  102. package/dist/nile-wysiwyg-editor/engine/keymap.cjs.js +1 -1
  103. package/dist/nile-wysiwyg-editor/engine/keymap.cjs.js.map +1 -1
  104. package/dist/nile-wysiwyg-editor/engine/keymap.esm.js +1 -1
  105. package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.cjs.js +1 -1
  106. package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.cjs.js.map +1 -1
  107. package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.esm.js +1 -1
  108. package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.cjs.js +1 -1
  109. package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.cjs.js.map +1 -1
  110. package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.esm.js +1 -1
  111. package/dist/nile-wysiwyg-editor/engine/plugins/embeds.cjs.js +1 -1
  112. package/dist/nile-wysiwyg-editor/engine/plugins/embeds.cjs.js.map +1 -1
  113. package/dist/nile-wysiwyg-editor/engine/plugins/embeds.esm.js +1 -1
  114. package/dist/nile-wysiwyg-editor/engine/plugins/find-replace.cjs.js +1 -1
  115. package/dist/nile-wysiwyg-editor/engine/plugins/find-replace.cjs.js.map +1 -1
  116. package/dist/nile-wysiwyg-editor/engine/plugins/find-replace.esm.js +1 -1
  117. package/dist/nile-wysiwyg-editor/engine/plugins/format-painter.cjs.js +1 -1
  118. package/dist/nile-wysiwyg-editor/engine/plugins/format-painter.cjs.js.map +1 -1
  119. package/dist/nile-wysiwyg-editor/engine/plugins/format-painter.esm.js +1 -1
  120. package/dist/nile-wysiwyg-editor/engine/plugins/image-view.cjs.js +1 -1
  121. package/dist/nile-wysiwyg-editor/engine/plugins/image-view.cjs.js.map +1 -1
  122. package/dist/nile-wysiwyg-editor/engine/plugins/image-view.esm.js +1 -1
  123. package/dist/nile-wysiwyg-editor/engine/plugins/image.cjs.js +1 -1
  124. package/dist/nile-wysiwyg-editor/engine/plugins/image.cjs.js.map +1 -1
  125. package/dist/nile-wysiwyg-editor/engine/plugins/image.esm.js +1 -1
  126. package/dist/nile-wysiwyg-editor/engine/plugins/link.cjs.js +1 -1
  127. package/dist/nile-wysiwyg-editor/engine/plugins/link.cjs.js.map +1 -1
  128. package/dist/nile-wysiwyg-editor/engine/plugins/link.esm.js +1 -1
  129. package/dist/nile-wysiwyg-editor/engine/plugins/max-length.cjs.js +1 -1
  130. package/dist/nile-wysiwyg-editor/engine/plugins/max-length.cjs.js.map +1 -1
  131. package/dist/nile-wysiwyg-editor/engine/plugins/max-length.esm.js +1 -1
  132. package/dist/nile-wysiwyg-editor/engine/plugins/paste.cjs.js +1 -1
  133. package/dist/nile-wysiwyg-editor/engine/plugins/paste.cjs.js.map +1 -1
  134. package/dist/nile-wysiwyg-editor/engine/plugins/paste.esm.js +1 -1
  135. package/dist/nile-wysiwyg-editor/engine/plugins/placeholder.cjs.js +1 -1
  136. package/dist/nile-wysiwyg-editor/engine/plugins/placeholder.cjs.js.map +1 -1
  137. package/dist/nile-wysiwyg-editor/engine/plugins/placeholder.esm.js +1 -1
  138. package/dist/nile-wysiwyg-editor/engine/plugins/single-line.cjs.js +1 -1
  139. package/dist/nile-wysiwyg-editor/engine/plugins/single-line.cjs.js.map +1 -1
  140. package/dist/nile-wysiwyg-editor/engine/plugins/single-line.esm.js +1 -1
  141. package/dist/nile-wysiwyg-editor/engine/plugins/suggestions.cjs.js +1 -1
  142. package/dist/nile-wysiwyg-editor/engine/plugins/suggestions.cjs.js.map +1 -1
  143. package/dist/nile-wysiwyg-editor/engine/plugins/suggestions.esm.js +1 -1
  144. package/dist/nile-wysiwyg-editor/engine/plugins/tables.cjs.js +1 -1
  145. package/dist/nile-wysiwyg-editor/engine/plugins/tables.cjs.js.map +1 -1
  146. package/dist/nile-wysiwyg-editor/engine/plugins/tables.esm.js +1 -1
  147. package/dist/nile-wysiwyg-editor/engine/sanitize.cjs.js +2 -1
  148. package/dist/nile-wysiwyg-editor/engine/sanitize.cjs.js.map +1 -1
  149. package/dist/nile-wysiwyg-editor/engine/sanitize.esm.js +1 -1
  150. package/dist/nile-wysiwyg-editor/engine/schema.cjs.js +1 -1
  151. package/dist/nile-wysiwyg-editor/engine/schema.cjs.js.map +1 -1
  152. package/dist/nile-wysiwyg-editor/engine/schema.esm.js +1 -1
  153. package/dist/nile-wysiwyg-editor/engine/selection-state.cjs.js +1 -1
  154. package/dist/nile-wysiwyg-editor/engine/selection-state.cjs.js.map +1 -1
  155. package/dist/nile-wysiwyg-editor/engine/selection-state.esm.js +1 -1
  156. package/dist/nile-wysiwyg-editor/engine/serializer.cjs.js +1 -1
  157. package/dist/nile-wysiwyg-editor/engine/serializer.cjs.js.map +1 -1
  158. package/dist/nile-wysiwyg-editor/engine/serializer.esm.js +1 -1
  159. package/dist/nile-wysiwyg-editor/index.cjs.js +1 -1
  160. package/dist/nile-wysiwyg-editor/index.esm.js +1 -1
  161. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js +1 -1
  162. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js.map +1 -1
  163. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js +1 -1
  164. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js.map +1 -1
  165. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.esm.js +45 -4
  166. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.esm.js +2 -2
  167. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.cjs.js +1 -1
  168. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.cjs.js +1 -1
  169. package/dist/nile-wysiwyg-editor/ui/bookmark-panel.cjs.js +1 -1
  170. package/dist/nile-wysiwyg-editor/ui/bookmark-panel.cjs.js.map +1 -1
  171. package/dist/nile-wysiwyg-editor/ui/bookmark-panel.esm.js +2 -2
  172. package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js +1 -1
  173. package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js.map +1 -1
  174. package/dist/nile-wysiwyg-editor/ui/bubble-menu.esm.js +5 -5
  175. package/dist/nile-wysiwyg-editor/ui/code-block-menu.cjs.js +1 -1
  176. package/dist/nile-wysiwyg-editor/ui/code-block-menu.cjs.js.map +1 -1
  177. package/dist/nile-wysiwyg-editor/ui/code-block-menu.esm.js +1 -1
  178. package/dist/nile-wysiwyg-editor/ui/embed-menu.cjs.js +1 -1
  179. package/dist/nile-wysiwyg-editor/ui/embed-menu.cjs.js.map +1 -1
  180. package/dist/nile-wysiwyg-editor/ui/embed-menu.esm.js +1 -1
  181. package/dist/nile-wysiwyg-editor/ui/embed-panel.cjs.js +1 -1
  182. package/dist/nile-wysiwyg-editor/ui/embed-panel.cjs.js.map +1 -1
  183. package/dist/nile-wysiwyg-editor/ui/embed-panel.esm.js +2 -2
  184. package/dist/nile-wysiwyg-editor/ui/emoji-picker.cjs.js +1 -1
  185. package/dist/nile-wysiwyg-editor/ui/emoji-picker.cjs.js.map +1 -1
  186. package/dist/nile-wysiwyg-editor/ui/emoji-picker.esm.js +1 -1
  187. package/dist/nile-wysiwyg-editor/ui/find-replace.cjs.js +1 -1
  188. package/dist/nile-wysiwyg-editor/ui/find-replace.cjs.js.map +1 -1
  189. package/dist/nile-wysiwyg-editor/ui/find-replace.esm.js +3 -3
  190. package/dist/nile-wysiwyg-editor/ui/image-menu.cjs.js +1 -1
  191. package/dist/nile-wysiwyg-editor/ui/image-menu.cjs.js.map +1 -1
  192. package/dist/nile-wysiwyg-editor/ui/image-menu.esm.js +3 -3
  193. package/dist/nile-wysiwyg-editor/ui/image-panel.cjs.js +1 -1
  194. package/dist/nile-wysiwyg-editor/ui/image-panel.cjs.js.map +1 -1
  195. package/dist/nile-wysiwyg-editor/ui/image-panel.esm.js +1 -1
  196. package/dist/nile-wysiwyg-editor/ui/insert-menu.cjs.js +1 -1
  197. package/dist/nile-wysiwyg-editor/ui/insert-menu.cjs.js.map +1 -1
  198. package/dist/nile-wysiwyg-editor/ui/insert-menu.esm.js +1 -1
  199. package/dist/nile-wysiwyg-editor/ui/link-editor.cjs.js +1 -1
  200. package/dist/nile-wysiwyg-editor/ui/link-editor.cjs.js.map +1 -1
  201. package/dist/nile-wysiwyg-editor/ui/link-editor.esm.js +9 -9
  202. package/dist/nile-wysiwyg-editor/ui/markdown-panel.cjs.js +1 -1
  203. package/dist/nile-wysiwyg-editor/ui/markdown-panel.cjs.js.map +1 -1
  204. package/dist/nile-wysiwyg-editor/ui/markdown-panel.esm.js +1 -1
  205. package/dist/nile-wysiwyg-editor/ui/math-panel.cjs.js +1 -1
  206. package/dist/nile-wysiwyg-editor/ui/math-panel.cjs.js.map +1 -1
  207. package/dist/nile-wysiwyg-editor/ui/math-panel.esm.js +1 -1
  208. package/dist/nile-wysiwyg-editor/ui/shortcut-help.cjs.js +1 -1
  209. package/dist/nile-wysiwyg-editor/ui/shortcut-help.cjs.js.map +1 -1
  210. package/dist/nile-wysiwyg-editor/ui/shortcut-help.esm.js +1 -1
  211. package/dist/nile-wysiwyg-editor/ui/source-view.cjs.js +1 -1
  212. package/dist/nile-wysiwyg-editor/ui/source-view.cjs.js.map +1 -1
  213. package/dist/nile-wysiwyg-editor/ui/source-view.esm.js +4 -4
  214. package/dist/nile-wysiwyg-editor/ui/special-chars.cjs.js +1 -1
  215. package/dist/nile-wysiwyg-editor/ui/special-chars.cjs.js.map +1 -1
  216. package/dist/nile-wysiwyg-editor/ui/special-chars.esm.js +1 -1
  217. package/dist/nile-wysiwyg-editor/ui/suggest-list.cjs.js +1 -1
  218. package/dist/nile-wysiwyg-editor/ui/suggest-list.cjs.js.map +1 -1
  219. package/dist/nile-wysiwyg-editor/ui/suggest-list.esm.js +23 -12
  220. package/dist/nile-wysiwyg-editor/ui/table-grid-picker.cjs.js +1 -1
  221. package/dist/nile-wysiwyg-editor/ui/table-grid-picker.cjs.js.map +1 -1
  222. package/dist/nile-wysiwyg-editor/ui/table-grid-picker.esm.js +7 -7
  223. package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js +1 -1
  224. package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js.map +1 -1
  225. package/dist/nile-wysiwyg-editor/ui/table-menu.esm.js +1 -1
  226. package/dist/src/nile-lite-tooltip/nile-lite-tooltip.css.js +1 -1
  227. package/dist/src/nile-lite-tooltip/nile-lite-tooltip.css.js.map +1 -1
  228. package/dist/src/nile-tooltip/nile-tooltip.css.js +1 -1
  229. package/dist/src/nile-tooltip/nile-tooltip.css.js.map +1 -1
  230. package/dist/src/nile-wysiwyg-editor/engine/create-state.d.ts +5 -0
  231. package/dist/src/nile-wysiwyg-editor/engine/create-state.js +2 -0
  232. package/dist/src/nile-wysiwyg-editor/engine/create-state.js.map +1 -1
  233. package/dist/src/nile-wysiwyg-editor/engine/email-css.d.ts +14 -0
  234. package/dist/src/nile-wysiwyg-editor/engine/email-css.js +140 -0
  235. package/dist/src/nile-wysiwyg-editor/engine/email-css.js.map +1 -0
  236. package/dist/src/nile-wysiwyg-editor/engine/email-fidelity.test.d.ts +1 -0
  237. package/dist/src/nile-wysiwyg-editor/engine/email-fidelity.test.js +1045 -0
  238. package/dist/src/nile-wysiwyg-editor/engine/email-fidelity.test.js.map +1 -0
  239. package/dist/src/nile-wysiwyg-editor/engine/email-render.d.ts +11 -0
  240. package/dist/src/nile-wysiwyg-editor/engine/email-render.js +93 -0
  241. package/dist/src/nile-wysiwyg-editor/engine/email-render.js.map +1 -0
  242. package/dist/src/nile-wysiwyg-editor/engine/html-detect.d.ts +2 -0
  243. package/dist/src/nile-wysiwyg-editor/engine/html-detect.js +24 -0
  244. package/dist/src/nile-wysiwyg-editor/engine/html-detect.js.map +1 -0
  245. package/dist/src/nile-wysiwyg-editor/engine/index.d.ts +4 -1
  246. package/dist/src/nile-wysiwyg-editor/engine/index.js +3 -1
  247. package/dist/src/nile-wysiwyg-editor/engine/index.js.map +1 -1
  248. package/dist/src/nile-wysiwyg-editor/engine/inputrules.d.ts +0 -5
  249. package/dist/src/nile-wysiwyg-editor/engine/inputrules.js +19 -0
  250. package/dist/src/nile-wysiwyg-editor/engine/inputrules.js.map +1 -1
  251. package/dist/src/nile-wysiwyg-editor/engine/plugins/image-view.js +3 -2
  252. package/dist/src/nile-wysiwyg-editor/engine/plugins/image-view.js.map +1 -1
  253. package/dist/src/nile-wysiwyg-editor/engine/plugins/link.d.ts +4 -0
  254. package/dist/src/nile-wysiwyg-editor/engine/plugins/link.js +56 -1
  255. package/dist/src/nile-wysiwyg-editor/engine/plugins/link.js.map +1 -1
  256. package/dist/src/nile-wysiwyg-editor/engine/plugins/paste.d.ts +5 -0
  257. package/dist/src/nile-wysiwyg-editor/engine/plugins/paste.js +27 -6
  258. package/dist/src/nile-wysiwyg-editor/engine/plugins/paste.js.map +1 -1
  259. package/dist/src/nile-wysiwyg-editor/engine/plugins/tables.js +30 -7
  260. package/dist/src/nile-wysiwyg-editor/engine/plugins/tables.js.map +1 -1
  261. package/dist/src/nile-wysiwyg-editor/engine/pm.test.js +46 -0
  262. package/dist/src/nile-wysiwyg-editor/engine/pm.test.js.map +1 -1
  263. package/dist/src/nile-wysiwyg-editor/engine/sanitize.d.ts +9 -1
  264. package/dist/src/nile-wysiwyg-editor/engine/sanitize.js +730 -7
  265. package/dist/src/nile-wysiwyg-editor/engine/sanitize.js.map +1 -1
  266. package/dist/src/nile-wysiwyg-editor/engine/schema.d.ts +3 -0
  267. package/dist/src/nile-wysiwyg-editor/engine/schema.js +215 -34
  268. package/dist/src/nile-wysiwyg-editor/engine/schema.js.map +1 -1
  269. package/dist/src/nile-wysiwyg-editor/engine/selection-state.js +3 -1
  270. package/dist/src/nile-wysiwyg-editor/engine/selection-state.js.map +1 -1
  271. package/dist/src/nile-wysiwyg-editor/engine/serializer.d.ts +12 -4
  272. package/dist/src/nile-wysiwyg-editor/engine/serializer.js +18 -8
  273. package/dist/src/nile-wysiwyg-editor/engine/serializer.js.map +1 -1
  274. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor-email-fidelity.test.d.ts +1 -0
  275. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor-email-fidelity.test.js +287 -0
  276. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor-email-fidelity.test.js.map +1 -0
  277. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js +45 -4
  278. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js.map +1 -1
  279. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.d.ts +23 -0
  280. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js +113 -15
  281. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js.map +1 -1
  282. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.js +213 -0
  283. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.js.map +1 -1
  284. package/dist/src/nile-wysiwyg-editor/ui/bookmark-panel.js +2 -2
  285. package/dist/src/nile-wysiwyg-editor/ui/bookmark-panel.js.map +1 -1
  286. package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.js +1 -1
  287. package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.js.map +1 -1
  288. package/dist/src/nile-wysiwyg-editor/ui/embed-menu.js +1 -1
  289. package/dist/src/nile-wysiwyg-editor/ui/embed-menu.js.map +1 -1
  290. package/dist/src/nile-wysiwyg-editor/ui/embed-panel.js +1 -1
  291. package/dist/src/nile-wysiwyg-editor/ui/embed-panel.js.map +1 -1
  292. package/dist/src/nile-wysiwyg-editor/ui/emoji-picker.js +1 -1
  293. package/dist/src/nile-wysiwyg-editor/ui/emoji-picker.js.map +1 -1
  294. package/dist/src/nile-wysiwyg-editor/ui/find-replace.js +1 -1
  295. package/dist/src/nile-wysiwyg-editor/ui/find-replace.js.map +1 -1
  296. package/dist/src/nile-wysiwyg-editor/ui/image-menu.js +1 -1
  297. package/dist/src/nile-wysiwyg-editor/ui/image-menu.js.map +1 -1
  298. package/dist/src/nile-wysiwyg-editor/ui/image-panel.js +1 -1
  299. package/dist/src/nile-wysiwyg-editor/ui/image-panel.js.map +1 -1
  300. package/dist/src/nile-wysiwyg-editor/ui/insert-menu.js +1 -1
  301. package/dist/src/nile-wysiwyg-editor/ui/insert-menu.js.map +1 -1
  302. package/dist/src/nile-wysiwyg-editor/ui/link-editor.js +2 -2
  303. package/dist/src/nile-wysiwyg-editor/ui/link-editor.js.map +1 -1
  304. package/dist/src/nile-wysiwyg-editor/ui/markdown-panel.js +1 -1
  305. package/dist/src/nile-wysiwyg-editor/ui/markdown-panel.js.map +1 -1
  306. package/dist/src/nile-wysiwyg-editor/ui/math-panel.js +1 -1
  307. package/dist/src/nile-wysiwyg-editor/ui/math-panel.js.map +1 -1
  308. package/dist/src/nile-wysiwyg-editor/ui/shortcut-help.js +1 -1
  309. package/dist/src/nile-wysiwyg-editor/ui/shortcut-help.js.map +1 -1
  310. package/dist/src/nile-wysiwyg-editor/ui/source-view.js +2 -2
  311. package/dist/src/nile-wysiwyg-editor/ui/source-view.js.map +1 -1
  312. package/dist/src/nile-wysiwyg-editor/ui/special-chars.js +1 -1
  313. package/dist/src/nile-wysiwyg-editor/ui/special-chars.js.map +1 -1
  314. package/dist/src/nile-wysiwyg-editor/ui/suggest-list.js +14 -3
  315. package/dist/src/nile-wysiwyg-editor/ui/suggest-list.js.map +1 -1
  316. package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.js +2 -2
  317. package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.js.map +1 -1
  318. package/dist/src/nile-wysiwyg-editor/ui/table-menu.js +1 -1
  319. package/dist/src/nile-wysiwyg-editor/ui/table-menu.js.map +1 -1
  320. package/dist/src/version.js +1 -1
  321. package/dist/src/version.js.map +1 -1
  322. package/dist/tsconfig.tsbuildinfo +1 -1
  323. package/dist/version.cjs.js +1 -1
  324. package/dist/version.cjs.js.map +1 -1
  325. package/dist/version.esm.js +1 -1
  326. package/package.json +1 -1
  327. package/src/nile-lite-tooltip/nile-lite-tooltip.css.ts +1 -1
  328. package/src/nile-tooltip/nile-tooltip.css.ts +1 -1
  329. package/src/nile-wysiwyg-editor/engine/create-state.ts +7 -0
  330. package/src/nile-wysiwyg-editor/engine/email-css.ts +136 -0
  331. package/src/nile-wysiwyg-editor/engine/email-fidelity.test.ts +1347 -0
  332. package/src/nile-wysiwyg-editor/engine/email-render.ts +99 -0
  333. package/src/nile-wysiwyg-editor/engine/html-detect.ts +26 -0
  334. package/src/nile-wysiwyg-editor/engine/index.ts +10 -1
  335. package/src/nile-wysiwyg-editor/engine/inputrules.ts +18 -1
  336. package/src/nile-wysiwyg-editor/engine/plugins/image-view.ts +3 -2
  337. package/src/nile-wysiwyg-editor/engine/plugins/link.ts +58 -2
  338. package/src/nile-wysiwyg-editor/engine/plugins/paste.ts +31 -8
  339. package/src/nile-wysiwyg-editor/engine/plugins/tables.ts +29 -7
  340. package/src/nile-wysiwyg-editor/engine/pm.test.ts +73 -0
  341. package/src/nile-wysiwyg-editor/engine/sanitize.ts +729 -7
  342. package/src/nile-wysiwyg-editor/engine/schema.ts +206 -33
  343. package/src/nile-wysiwyg-editor/engine/selection-state.ts +3 -1
  344. package/src/nile-wysiwyg-editor/engine/serializer.ts +30 -8
  345. package/src/nile-wysiwyg-editor/nile-wysiwyg-editor-email-fidelity.test.ts +357 -0
  346. package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.ts +45 -4
  347. package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.ts +258 -0
  348. package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.ts +119 -12
  349. package/src/nile-wysiwyg-editor/ui/bookmark-panel.ts +2 -2
  350. package/src/nile-wysiwyg-editor/ui/bubble-menu.ts +1 -1
  351. package/src/nile-wysiwyg-editor/ui/embed-menu.ts +1 -1
  352. package/src/nile-wysiwyg-editor/ui/embed-panel.ts +1 -1
  353. package/src/nile-wysiwyg-editor/ui/emoji-picker.ts +1 -1
  354. package/src/nile-wysiwyg-editor/ui/find-replace.ts +1 -1
  355. package/src/nile-wysiwyg-editor/ui/image-menu.ts +1 -1
  356. package/src/nile-wysiwyg-editor/ui/image-panel.ts +1 -1
  357. package/src/nile-wysiwyg-editor/ui/insert-menu.ts +1 -1
  358. package/src/nile-wysiwyg-editor/ui/link-editor.ts +2 -2
  359. package/src/nile-wysiwyg-editor/ui/markdown-panel.ts +1 -1
  360. package/src/nile-wysiwyg-editor/ui/math-panel.ts +1 -1
  361. package/src/nile-wysiwyg-editor/ui/shortcut-help.ts +1 -1
  362. package/src/nile-wysiwyg-editor/ui/source-view.ts +2 -2
  363. package/src/nile-wysiwyg-editor/ui/special-chars.ts +1 -1
  364. package/src/nile-wysiwyg-editor/ui/suggest-list.ts +14 -3
  365. package/src/nile-wysiwyg-editor/ui/table-grid-picker.ts +2 -2
  366. package/src/nile-wysiwyg-editor/ui/table-menu.ts +1 -1
  367. package/vscode-html-custom-data.json +15 -1
  368. package/web-test-runner.config.mjs +4 -0
  369. package/dist/index-3ca67627.cjs.js +0 -2
  370. package/dist/index-6f3fa4ab.esm.js +0 -1
  371. package/dist/index-7b1c9857.esm.js +0 -1
  372. package/dist/index-89c520e9.cjs.js +0 -5
  373. package/dist/index-89c520e9.cjs.js.map +0 -1
  374. package/dist/index-ba47645d.esm.js +0 -1
  375. package/dist/index-c3210a9c.cjs.js +0 -2
  376. package/dist/index-c3210a9c.cjs.js.map +0 -1
@@ -1 +0,0 @@
1
- function t(t){this.content=t}function e(t,r,s){for(let h=0;;h++){if(h==t.childCount||h==r.childCount)return t.childCount==r.childCount?null:s;let l=t.child(h),o=r.child(h);if(l!=o){if(!l.sameMarkup(o))return s;if(l.isText&&l.text!=o.text){let t=l.text,e=o.text,r=0;for(;t[r]==e[r];r++)s++;return r&&r<t.length&&r<e.length&&n(t.charCodeAt(r-1))&&i(t.charCodeAt(r))&&s--,s}if(l.content.size||o.content.size){let t=e(l.content,o.content,s+1);if(null!=t)return t}s+=l.nodeSize}else s+=l.nodeSize}}function r(t,e,s,h){for(let l=t.childCount,o=e.childCount;;){if(0==l||0==o)return l==o?null:{a:s,b:h};let u=t.child(--l),f=e.child(--o),a=u.nodeSize;if(u!=f){if(!u.sameMarkup(f))return{a:s,b:h};if(u.isText&&u.text!=f.text){let t=u.text,e=f.text,r=t.length,l=e.length;for(;r>0&&l>0&&t[r-1]==e[l-1];)r--,l--,s--,h--;return r&&l&&r<t.length&&n(t.charCodeAt(r-1))&&i(t.charCodeAt(r))&&(s++,h++),{a:s,b:h}}if(u.content.size||f.content.size){let t=r(u.content,f.content,s-1,h-1);if(t)return t}s-=a,h-=a}else s-=a,h-=a}}function i(t){return t>=56320&&t<57344}function n(t){return t>=55296&&t<56320}t.prototype={constructor:t,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(e,r,i){var n=i&&i!=e?this.remove(i):this,s=n.find(e),h=n.content.slice();return-1==s?h.push(i||e,r):(h[s+1]=r,i&&(h[s]=i)),new t(h)},remove:function(e){var r=this.find(e);if(-1==r)return this;var i=this.content.slice();return i.splice(r,2),new t(i)},addToStart:function(e,r){return new t([e,r].concat(this.remove(e).content))},addToEnd:function(e,r){var i=this.remove(e).content.slice();return i.push(e,r),new t(i)},addBefore:function(e,r,i){var n=this.remove(r),s=n.content.slice(),h=n.find(e);return s.splice(-1==h?s.length:h,0,r,i),new t(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(e){return(e=t.from(e)).size?new t(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=t.from(e)).size?new t(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var r=this;e=t.from(e);for(var i=0;i<e.content.length;i+=2)r=r.remove(e.content[i]);return r},toObject:function(){var t={};return this.forEach((function(e,r){t[e]=r})),t},get size(){return this.content.length>>1}},t.from=function(e){if(e instanceof t)return e;var r=[];if(e)for(var i in e)r.push(i,e[i]);return new t(r)};class s{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,r,i=0,n){for(let s=0,h=0;h<e;s++){let l=this.content[s],o=h+l.nodeSize;if(o>t&&!1!==r(l,i+h,n||null,s)&&l.content.size){let n=h+1;l.nodesBetween(Math.max(0,t-n),Math.min(l.content.size,e-n),r,i+n)}h=o}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,i){let n="",s=!0;return this.nodesBetween(t,e,((h,l)=>{let o=h.isText?h.text.slice(Math.max(t,l)-l,e-l):h.isLeaf?i?"function"==typeof i?i(h):i:h.type.spec.leafText?h.type.spec.leafText(h):"":"";h.isBlock&&(h.isLeaf&&o||h.isTextblock)&&r&&(s?s=!1:n+=r),n+=o}),0),n}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,r=t.firstChild,i=this.content.slice(),n=0;for(e.isText&&e.sameMarkup(r)&&(i[i.length-1]=e.withText(e.text+r.text),n=1);n<t.content.length;n++)i.push(t.content[n]);return new s(i,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let r=[],i=0;if(e>t)for(let n=0,s=0;s<e;n++){let h=this.content[n],l=s+h.nodeSize;l>t&&((s<t||l>e)&&(h=h.isText?h.cut(Math.max(0,t-s),Math.min(h.text.length,e-s)):h.cut(Math.max(0,t-s-1),Math.min(h.content.size,e-s-1))),r.push(h),i+=h.nodeSize),s=l}return new s(r,i)}cutByIndex(t,e){return t==e?s.empty:0==t&&e==this.content.length?this:new s(this.content.slice(t,e))}replaceChild(t,e){let r=this.content[t];if(r==e)return this;let i=this.content.slice(),n=this.size+e.nodeSize-r.nodeSize;return i[t]=e,new s(i,n)}addToStart(t){return new s([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new s(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))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(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,r=0;e<this.content.length;e++){let i=this.content[e];t(i,r,e),r+=i.nodeSize}}findDiffStart(t,r=0){return e(this,t,r)}findDiffEnd(t,e=this.size,i=t.size){return r(this,t,e,i)}findIndex(t){if(0==t)return l(0,t);if(t==this.size)return l(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,r=0;;e++){let i=r+this.child(e).nodeSize;if(i>=t)return i==t?l(e+1,i):l(e,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return s.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return s.fromArray(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return s.empty;let e,r=0;for(let i=0;i<t.length;i++){let n=t[i];r+=n.nodeSize,i&&n.isText&&t[i-1].sameMarkup(n)?(e||(e=t.slice(0,i)),e[e.length-1]=n.withText(e[e.length-1].text+n.text)):e&&e.push(n)}return new s(e||t,r)}static from(t){if(!t)return s.empty;if(t instanceof s)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new s([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}s.empty=new s([],0);const h={index:0,offset:0};function l(t,e){return h.index=t,h.offset=e,h}function o(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let r=Array.isArray(t);if(Array.isArray(e)!=r)return!1;if(r){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!o(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!o(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class u{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,r=!1;for(let i=0;i<t.length;i++){let n=t[i];if(this.eq(n))return t;if(this.type.excludes(n.type))e||(e=t.slice(0,i));else{if(n.type.excludes(this.type))return t;!r&&n.type.rank>this.type.rank&&(e||(e=t.slice(0,i)),e.push(this),r=!0),e&&e.push(n)}}return e||(e=t.slice()),r||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&o(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[e.type];if(!r)throw new RangeError(`There is no mark type ${e.type} in this schema`);let i=r.create(e.attrs);return r.checkAttrs(i.attrs),i}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(e[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return u.none;if(t instanceof u)return[t];let e=t.slice();return e.sort(((t,e)=>t.type.rank-e.type.rank)),e}}u.none=[];class f extends Error{}class a{constructor(t,e,r){this.content=t,this.openStart=e,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let r=p(this.content,t+this.openStart,e,this.openStart+1,this.openEnd+1);return r&&new a(r,this.openStart,this.openEnd)}removeBetween(t,e){return new a(c(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return a.empty;let r=e.openStart||0,i=e.openEnd||0;if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid input for Slice.fromJSON");return new a(s.fromJSON(t,e.content),r,i)}static maxOpen(t,e=!0){let r=0,i=0;for(let i=t.firstChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.firstChild)r++;for(let r=t.lastChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.lastChild)i++;return new a(t,r,i)}}function c(t,e,r){let{index:i,offset:n}=t.findIndex(e),s=t.maybeChild(i),{index:h,offset:l}=t.findIndex(r);if(n==e||s.isText){if(l!=r&&!t.child(h).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(r))}if(i!=h)throw new RangeError("Removing non-flat range");return t.replaceChild(i,s.copy(c(s.content,e-n-1,r-n-1)))}function p(t,e,r,i,n,s){let{index:h,offset:l}=t.findIndex(e),o=t.maybeChild(h);if(l==e||o.isText)return s&&i<=0&&n<=0&&!s.canReplace(h,h,r)?null:t.cut(0,e).append(r).append(t.cut(e));let u=p(o.content,e-l-1,r,0==h?i-1:0,h==t.childCount-1?n-1:0,o);return u&&t.replaceChild(h,o.copy(u))}function d(t,e,r){if(r.openStart>t.depth)throw new f("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new f("Inconsistent open depths");return w(t,e,r,0)}function w(t,e,r,i){let n=t.index(i),h=t.node(i);if(n==e.index(i)&&i<t.depth-r.openStart){let s=w(t,e,r,i+1);return h.copy(h.content.replaceChild(n,s))}if(r.content.size){if(r.openStart||r.openEnd||t.depth!=i||e.depth!=i){let{start:n,end:l}=function(t,e){let r=e.depth-t.openStart,i=e.node(r).copy(t.content);for(let t=r-1;t>=0;t--)i=e.node(t).copy(s.from(i));return{start:i.resolveNoCache(t.openStart+r),end:i.resolveNoCache(i.content.size-t.openEnd-r)}}(r,t);return b(h,v(t,n,l,e,i))}{let i=t.parent,n=i.content;return b(i,n.cut(0,t.parentOffset).append(r.content).append(n.cut(e.parentOffset)))}}return b(h,k(t,e,i))}function g(t,e){if(!e.type.compatibleContent(t.type))throw new f("Cannot join "+e.type.name+" onto "+t.type.name)}function m(t,e,r){let i=t.node(r);return g(i,e.node(r)),i}function y(t,e){let r=e.length-1;r>=0&&t.isText&&t.sameMarkup(e[r])?e[r]=t.withText(e[r].text+t.text):e.push(t)}function S(t,e,r,i){let n=(e||t).node(r),s=0,h=e?e.index(r):n.childCount;t&&(s=t.index(r),t.depth>r?s++:t.textOffset&&(y(t.nodeAfter,i),s++));for(let t=s;t<h;t++)y(n.child(t),i);e&&e.depth==r&&e.textOffset&&y(e.nodeBefore,i)}function b(t,e){if(!t.type.validContent(e))throw new f("Invalid content for node "+t.type.name);return t.copy(e)}function v(t,e,r,i,n){let h=t.depth>n&&m(t,e,n+1),l=i.depth>n&&m(r,i,n+1),o=[];return S(null,t,n,o),h&&l&&e.index(n)==r.index(n)?(g(h,l),y(b(h,v(t,e,r,i,n+1)),o)):(h&&y(b(h,k(t,e,n+1)),o),S(e,r,n,o),l&&y(b(l,k(r,i,n+1)),o)),S(i,null,n,o),new s(o)}function k(t,e,r){let i=[];if(S(null,t,r,i),t.depth>r){y(b(m(t,e,r+1),k(t,e,r+1)),i)}return S(e,null,r,i),new s(i)}a.empty=new a(s.empty,0,0);class x{constructor(t,e,r){this.pos=t,this.path=e,this.parentOffset=r,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]}after(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=t.child(e);return r?t.child(e).cut(r):i}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let r=this.path[3*e],i=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)i+=r.child(e).nodeSize;return i}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return u.none;if(this.textOffset)return t.child(e).marks;let r=t.maybeChild(e-1),i=t.maybeChild(e);if(!r){let t=r;r=i,i=t}let n=r.marks;for(var s=0;s<n.length;s++)!1!==n[s].type.spec.inclusive||i&&n[s].isInSet(i.marks)||(n=n[s--].removeFromSet(n));return n}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let r=e.marks,i=t.parent.maybeChild(t.index());for(var n=0;n<r.length;n++)!1!==r[n].type.spec.inclusive||i&&r[n].isInSet(i.marks)||(r=r[n--].removeFromSet(r));return r}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);r>=0;r--)if(t.pos<=this.end(r)&&(!e||e(this.node(r))))return new R(this,t,r);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let r=[],i=0,n=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(n),h=n-s;if(r.push(e,t,i+s),!h)break;if(e=e.child(t),e.isText)break;n=h-1,i+=s+1}return new x(e,r,n)}static resolveCached(t,e){let r=O.get(t);if(r)for(let t=0;t<r.elts.length;t++){let i=r.elts[t];if(i.pos==e)return i}else O.set(t,r=new E);let i=r.elts[r.i]=x.resolve(t,e);return r.i=(r.i+1)%N,i}}class E{constructor(){this.elts=[],this.i=0}}const N=12,O=new WeakMap;class R{constructor(t,e,r){this.$from=t,this.$to=e,this.depth=r}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)}}const M=Object.create(null);class J{constructor(t,e,r,i=u.none){this.type=t,this.attrs=e,this.marks=i,this.content=r||s.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,r,i=0){this.content.nodesBetween(t,e,r,i,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,r,i){return this.content.textBetween(t,e,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,r){return this.type==t&&o(this.attrs,e||t.defaultAttrs||M)&&u.sameSet(this.marks,r||u.none)}copy(t=null){return t==this.content?this:new J(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new J(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,r=!1){if(t==e)return a.empty;let i=this.resolve(t),n=this.resolve(e),s=r?0:i.sharedDepth(e),h=i.start(s),l=i.node(s).content.cut(i.pos-h,n.pos-h);return new a(l,i.depth-s,n.depth-s)}replace(t,e,r){return d(this.resolve(t),this.resolve(e),r)}nodeAt(t){for(let e=this;;){let{index:r,offset:i}=e.content.findIndex(t);if(e=e.maybeChild(r),!e)return null;if(i==t||e.isText)return e;t-=i+1}}childAfter(t){let{index:e,offset:r}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:r}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:r}=this.content.findIndex(t);if(r<t)return{node:this.content.child(e),index:e,offset:r};let i=this.content.child(e-1);return{node:i,index:e-1,offset:r-i.nodeSize}}resolve(t){return x.resolveCached(this,t)}resolveNoCache(t){return x.resolve(this,t)}rangeHasMark(t,e,r){let i=!1;return e>t&&this.nodesBetween(t,e,(t=>(r.isInSet(t.marks)&&(i=!0),!i))),i}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 t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),T(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,r=s.empty,i=0,n=r.childCount){let h=this.contentMatchAt(t).matchFragment(r,i,n),l=h&&h.matchFragment(this.content,e);if(!l||!l.validEnd)return!1;for(let t=i;t<n;t++)if(!this.type.allowsMarks(r.child(t).marks))return!1;return!0}canReplaceWith(t,e,r,i){if(i&&!this.type.allowsMarks(i))return!1;let n=this.contentMatchAt(t).matchType(r),s=n&&n.matchFragment(this.content,e);return!!s&&s.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=u.none;for(let e=0;e<this.marks.length;e++){let r=this.marks[e];r.type.checkAttrs(r.attrs),t=r.addToSet(t)}if(!u.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((t=>t.toJSON()))),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let r;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,r)}let i=s.fromJSON(t,e.content),n=t.nodeType(e.type).create(e.attrs,i,r);return n.type.checkAttrs(n.attrs),n}}J.prototype.text=void 0;class I extends J{constructor(t,e,r,i){if(super(t,e,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):T(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new I(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new I(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function T(t,e){for(let r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}class A{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let r=new j(t,e);if(null==r.next)return A.empty;let i=C(r);r.next&&r.err("Unexpected trailing text");let n=function(t){let e=Object.create(null);return r(W(t,0));function r(i){let n=[];i.forEach((e=>{t[e].forEach((({term:e,to:r})=>{if(!e)return;let i;for(let t=0;t<n.length;t++)n[t][0]==e&&(i=n[t][1]);W(t,r).forEach((t=>{i||n.push([e,i=[]]),-1==i.indexOf(t)&&i.push(t)}))}))}));let s=e[i.join(",")]=new A(i.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let i=n[t][1].sort(q);s.next.push({type:n[t][0],next:e[i.join(",")]||r(i)})}return s}}(function(t){let e=[[]];return n(s(t,0),r()),e;function r(){return e.push([])-1}function i(t,r,i){let n={term:i,to:r};return e[t].push(n),n}function n(t,e){t.forEach((t=>t.to=e))}function s(t,e){if("choice"==t.type)return t.exprs.reduce(((t,r)=>t.concat(s(r,e))),[]);if("seq"!=t.type){if("star"==t.type){let h=r();return i(e,h),n(s(t.expr,h),h),[i(h)]}if("plus"==t.type){let h=r();return n(s(t.expr,e),h),n(s(t.expr,h),h),[i(h)]}if("opt"==t.type)return[i(e)].concat(s(t.expr,e));if("range"==t.type){let h=e;for(let e=0;e<t.min;e++){let e=r();n(s(t.expr,h),e),h=e}if(-1==t.max)n(s(t.expr,h),h);else for(let e=t.min;e<t.max;e++){let e=r();i(h,e),n(s(t.expr,h),e),h=e}return[i(h)]}if("name"==t.type)return[i(e,void 0,t.value)];throw new Error("Unknown expr type")}for(let i=0;;i++){let h=s(t.exprs[i],e);if(i==t.exprs.length-1)return h;n(h,e=r())}}}(i));return function(t,e){for(let r=0,i=[t];r<i.length;r++){let t=i[r],n=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:r,next:h}=t.next[e];s.push(r.name),!n||r.isText||r.hasRequiredAttrs()||(n=!1),-1==i.indexOf(h)&&i.push(h)}n&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(n,r),n}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,r=t.childCount){let i=this;for(let n=e;i&&n<r;n++)i=i.matchType(t.child(n).type);return i}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let r=0;r<t.next.length;r++)if(this.next[e].type==t.next[r].type)return!0;return!1}fillBefore(t,e=!1,r=0){let i=[this];return function n(h,l){let o=h.matchFragment(t,r);if(o&&(!e||o.validEnd))return s.from(l.map((t=>t.createAndFill())));for(let t=0;t<h.next.length;t++){let{type:e,next:r}=h.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==i.indexOf(r)){i.push(r);let t=n(r,l.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),n=i.match;if(n.matchType(t)){let t=[];for(let e=i;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<n.next.length;t++){let{type:s,next:h}=n.next[t];s.isLeaf||s.hasRequiredAttrs()||s.name in e||i.type&&!h.validEnd||(r.push({match:s.contentMatch,type:s,via:i}),e[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(r){t.push(r);for(let i=0;i<r.next.length;i++)-1==t.indexOf(r.next[i].next)&&e(r.next[i].next)}(this),t.map(((e,r)=>{let i=r+(e.validEnd?"*":" ")+" ";for(let r=0;r<e.next.length;r++)i+=(r?", ":"")+e.next[r].type.name+"->"+t.indexOf(e.next[r].next);return i})).join("\n")}}A.empty=new A(!0);class j{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.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(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function C(t){let e=[];do{e.push($(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function $(t){let e=[];do{e.push(D(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function D(t){let e=function(t){if(t.eat("(")){let e=C(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let r=t.nodeTypes,i=r[e];if(i)return[i];let n=[];for(let t in r){let i=r[t];i.isInGroup(e)&&n.push(i)}0==n.length&&t.err("No node type or group '"+e+"' found");return n}(t,t.next).map((e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e})));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=F(t,e)}return e}function B(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function F(t,e){let r=B(t),i=r;return t.eat(",")&&(i="}"!=t.next?B(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:i,expr:e}}function q(t,e){return e-t}function W(t,e){let r=[];return function e(i){let n=t[i];if(1==n.length&&!n[0].term)return e(n[0].to);r.push(i);for(let t=0;t<n.length;t++){let{term:i,to:s}=n[t];i||-1!=r.indexOf(s)||e(s)}}(e),r.sort(q)}function z(t){let e=Object.create(null);for(let r in t){let i=t[r];if(!i.hasDefault)return null;e[r]=i.default}return e}function P(t,e){let r=Object.create(null);for(let i in t){let n=e&&e[i];if(void 0===n){let e=t[i];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+i);n=e.default}r[i]=n}return r}function U(t,e,r,i){for(let n in e)if(!(n in t))throw new RangeError(`Unsupported attribute ${n} for ${r} of type ${i}`);for(let r in t)t[r].validate&&t[r].validate(e[r])}function _(t,e){let r=Object.create(null);if(e)for(let i in e)r[i]=new G(t,i,e[i]);return r}class L{constructor(t,e,r){this.name=t,this.schema=e,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=_(t,r.attrs),this.defaultAttrs=z(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||"text"==t),this.isText="text"==t}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==A.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:P(this.attrs,t)}create(t=null,e,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new J(this,this.computeAttrs(t),s.from(e),u.setFrom(r))}createChecked(t=null,e,r){return e=s.from(e),this.checkContent(e),new J(this,this.computeAttrs(t),e,u.setFrom(r))}createAndFill(t=null,e,r){if(t=this.computeAttrs(t),(e=s.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let i=this.contentMatch.matchFragment(e),n=i&&i.fillBefore(s.empty,!0);return n?new J(this,t,e.append(n),u.setFrom(r)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){U(this.attrs,t,"node",this.name)}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let r=0;r<t.length;r++)this.allowsMarkType(t[r].type)?e&&e.push(t[r]):e||(e=t.slice(0,r));return e?e.length?e:u.none:t}static compile(t,e){let r=Object.create(null);t.forEach(((t,i)=>r[t]=new L(t,e,i)));let i=e.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let t in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}}class G{constructor(t,e,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate="string"==typeof r.validate?function(t,e,r){let i=r.split("|");return r=>{let n=null===r?"null":typeof r;if(i.indexOf(n)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${t}, got ${n}`)}}(t,e,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class V{constructor(t,e,r,i){this.name=t,this.rank=e,this.schema=r,this.spec=i,this.attrs=_(t,i.attrs),this.excluded=null;let n=z(this.attrs);this.instance=n?new u(this,n):null}create(t=null){return!t&&this.instance?this.instance:new u(this,P(this.attrs,t))}static compile(t,e){let r=Object.create(null),i=0;return t.forEach(((t,n)=>r[t]=new V(t,i++,e,n))),r}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){U(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}}class H{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let r=this.spec={};for(let t in e)r[t]=e[t];r.nodes=t.from(e.nodes),r.marks=t.from(e.marks||{}),this.nodes=L.compile(this.spec.nodes,this),this.marks=V.compile(this.spec.marks,this);let i=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],r=e.spec.content||"",n=e.spec.marks;if(e.contentMatch=i[r]||(i[r]=A.parse(r,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==n?null:n?K(this,n.split(" ")):""!=n&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],r=e.spec.excludes;e.excluded=null==r?[e]:""==r?[]:K(this,r.split(" "))}this.nodeFromJSON=t=>J.fromJSON(this,t),this.markFromJSON=t=>u.fromJSON(this,t),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,r,i){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof L))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,r,i)}text(t,e){let r=this.nodes.text;return new I(r,r.defaultAttrs,t,u.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function K(t,e){let r=[];for(let i=0;i<e.length;i++){let n=e[i],s=t.marks[n],h=s;if(s)r.push(s);else for(let e in t.marks){let i=t.marks[e];("_"==n||i.spec.group&&i.spec.group.split(" ").indexOf(n)>-1)&&r.push(h=i)}if(!h)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return r}class Q{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[];let r=this.matchedStyles=[];e.forEach((t=>{if(function(t){return null!=t.tag}(t))this.tags.push(t);else if(function(t){return null!=t.style}(t)){let e=/[^=]*/.exec(t.style)[0];r.indexOf(e)<0&&r.push(e),this.styles.push(t)}})),this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let r=t.nodes[e.node];return r.contentMatch.matchType(r)}))}parse(t,e={}){let r=new rt(this,e,!1);return r.addAll(t,u.none,e.from,e.to),r.finish()}parseSlice(t,e={}){let r=new rt(this,e,!0);return r.addAll(t,u.none,e.from,e.to),a.maxOpen(r.finish())}matchTag(t,e,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let r=this.tags[i];if(it(t,r.tag)&&(void 0===r.namespace||t.namespaceURI==r.namespace)&&(!r.context||e.matchesContext(r.context))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}matchStyle(t,e,r,i){for(let n=i?this.styles.indexOf(i)+1:0;n<this.styles.length;n++){let i=this.styles[n],s=i.style;if(!(0!=s.indexOf(t)||i.context&&!r.matchesContext(i.context)||s.length>t.length&&(61!=s.charCodeAt(t.length)||s.slice(t.length+1)!=e))){if(i.getAttrs){let t=i.getAttrs(e);if(!1===t)continue;i.attrs=t||void 0}return i}}}static schemaRules(t){let e=[];function r(t){let r=null==t.priority?50:t.priority,i=0;for(;i<e.length;i++){let t=e[i];if((null==t.priority?50:t.priority)<r)break}e.splice(i,0,t)}for(let e in t.marks){let i=t.marks[e].spec.parseDOM;i&&i.forEach((t=>{r(t=nt(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)}))}for(let e in t.nodes){let i=t.nodes[e].spec.parseDOM;i&&i.forEach((t=>{r(t=nt(t)),t.node||t.ignore||t.mark||(t.node=e)}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Q(t,Q.schemaRules(t)))}}const X={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},Y={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Z={ol:!0,ul:!0};function tt(t,e,r){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&r}class et{constructor(t,e,r,i,n,s){this.type=t,this.attrs=e,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=u.none,this.match=n||(4&s?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(s.from(t));if(!e){let e,r=this.type.contentMatch;return(e=r.findWrapping(t.type))?(this.match=r,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let r=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-t[0].length))}}let e=s.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(s.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!X.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class rt{constructor(t,e,r){this.parser=t,this.options=e,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i,n=e.topNode,s=tt(null,e.preserveWhitespace,0)|(r?4:0);i=n?new et(n.type,n.attrs,u.none,!0,e.topMatch||n.type.contentMatch,s):new et(r?null:t.schema.topNodeType,null,u.none,!0,null,s),this.nodes=[i],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){3==t.nodeType?this.addTextNode(t,e):1==t.nodeType&&this.addElement(t,e)}addTextNode(t,e){let r=t.nodeValue,i=this.top,n=2&i.options?"full":this.localPreserveWS||(1&i.options)>0,{schema:s}=this.parser;if("full"===n||i.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(n)if("full"===n)r=r.replace(/\r\n?/g,"\n");else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let t=r.split(/\r?\n|\r/);for(let r=0;r<t.length;r++)r&&this.insertNode(s.linebreakReplacement.create(),e,!0),t[r]&&this.insertNode(s.text(t[r]),e,!/\S/.test(t[r]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let e=i.content[i.content.length-1],n=t.previousSibling;(!e||n&&"BR"==n.nodeName||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),e,!/\S/.test(r)),this.findInText(t)}else this.findInside(t)}addElement(t,e,r){let i=this.localPreserveWS,n=this.top;("PRE"==t.tagName||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let s,h=t.nodeName.toLowerCase();Z.hasOwnProperty(h)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,r=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&Z.hasOwnProperty(t)&&r?(r.appendChild(e),e=r):"li"==t?r=e:t&&(r=null)}}(t);let l=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(s=this.parser.matchTag(t,this,r));t:if(l?l.ignore:Y.hasOwnProperty(h))this.findInside(t),this.ignoreFallback(t,e);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(t=l.skip);let r,i=this.needsBlock;if(X.hasOwnProperty(h))n.content.length&&n.content[0].isInline&&this.open&&(this.open--,n=this.top),r=!0,n.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,e);break t}let s=l&&l.skip?e:this.readStyles(t,e);s&&this.addAll(t,s),r&&this.sync(n),this.needsBlock=i}else{let r=this.readStyles(t,e);r&&this.addElementByRule(t,l,r,!1===l.consuming?s:void 0)}this.localPreserveWS=i}leafFallback(t,e){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),e,!0)}readStyles(t,e){let r=t.style;if(r&&r.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let i=this.parser.matchedStyles[t],n=r.getPropertyValue(i);if(n)for(let t;;){let r=this.parser.matchStyle(i,n,this,t);if(!r)break;if(r.ignore)return null;if(e=r.clearMark?e.filter((t=>!r.clearMark(t))):e.concat(this.parser.schema.marks[r.mark].create(r.attrs)),!1!==r.consuming)break;t=r}}return e}addElementByRule(t,e,r,i){let n,s;if(e.node)if(s=this.parser.schema.nodes[e.node],s.isLeaf)this.insertNode(s.create(e.attrs),r,"BR"==t.nodeName)||this.leafFallback(t,r);else{let t=this.enter(s,e.attrs||null,r,e.preserveWhitespace);t&&(n=!0,r=t)}else{let t=this.parser.schema.marks[e.mark];r=r.concat(t.create(e.attrs))}let h=this.top;if(s&&s.isLeaf)this.findInside(t);else if(i)this.addElement(t,r,i);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,r,!1)));else{let i=t;"string"==typeof e.contentElement?i=t.querySelector(e.contentElement):"function"==typeof e.contentElement?i=e.contentElement(t):e.contentElement&&(i=e.contentElement),this.findAround(t,i,!0),this.addAll(i,r),this.findAround(t,i,!1)}n&&this.sync(h)&&this.open--}addAll(t,e,r,i){let n=r||0;for(let s=r?t.childNodes[r]:t.firstChild,h=null==i?null:t.childNodes[i];s!=h;s=s.nextSibling,++n)this.findAtPoint(t,n),this.addDOM(s,e);this.findAtPoint(t,n)}findPlace(t,e,r){let i,n;for(let e=this.open,s=0;e>=0;e--){let h=this.nodes[e],l=h.findWrapping(t);if(l&&(!i||i.length>l.length+s)&&(i=l,n=h,!l.length))break;if(h.solid){if(r)break;s+=2}}if(!i)return null;this.sync(n);for(let t=0;t<i.length;t++)e=this.enterInner(i[t],null,e,!1);return e}insertNode(t,e,r){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&(e=this.enterInner(t,null,e))}let i=this.findPlace(t,e,r);if(i){this.closeExtra();let e=this.top;e.match&&(e.match=e.match.matchType(t.type));let r=u.none;for(let n of i.concat(t.marks))(e.type?e.type.allowsMarkType(n.type):st(n.type,t.type))&&(r=n.addToSet(r));return e.content.push(t.mark(r)),!0}return!1}enter(t,e,r,i){let n=this.findPlace(t.create(e),r,!1);return n&&(n=this.enterInner(t,e,r,!0,i)),n}enterInner(t,e,r,i=!1,n){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let h=tt(t,n,s.options);4&s.options&&0==s.content.length&&(h|=4);let l=u.none;return r=r.filter((e=>!(s.type?s.type.allowsMarkType(e.type):st(e.type,t))||(l=e.addToSet(l),!1))),this.nodes.push(new et(t,e,l,i,null,h)),this.open++,r}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));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(t){for(let e=this.open;e>=0;e--){if(this.nodes[e]==t)return this.open=e,!0;this.localPreserveWS&&(this.nodes[e].options|=1)}return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let r=this.nodes[e].content;for(let e=r.length-1;e>=0;e--)t+=r[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==e&&(this.find[r].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,r){if(t!=e&&this.find)for(let i=0;i<this.find.length;i++)if(null==this.find[i].pos&&1==t.nodeType&&t.contains(this.find[i].node)){e.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),r=this.options.context,i=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),n=-(r?r.depth+1:0)+(i?0:1),s=(t,h)=>{for(;t>=0;t--){let l=e[t];if(""==l){if(t==e.length-1||0==t)continue;for(;h>=n;h--)if(s(t-1,h))return!0;return!1}{let t=h>0||0==h&&i?this.nodes[h].type:r&&h>=n?r.node(h-n).type:null;if(!t||t.name!=l&&!t.isInGroup(l))return!1;h--}}return!0};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let r=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function it(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function nt(t){let e={};for(let r in t)e[r]=t[r];return e}function st(t,e){let r=e.schema.nodes;for(let i in r){let n=r[i];if(!n.allowsMarkType(t))continue;let s=[],h=t=>{s.push(t);for(let r=0;r<t.edgeCount;r++){let{type:i,next:n}=t.edge(r);if(i==e)return!0;if(s.indexOf(n)<0&&h(n))return!0}};if(h(n.contentMatch))return!0}}class ht{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},r){r||(r=ot(e).createDocumentFragment());let i=r,n=[];return t.forEach((t=>{if(n.length||t.marks.length){let r=0,s=0;for(;r<n.length&&s<t.marks.length;){let e=t.marks[s];if(this.marks[e.type.name]){if(!e.eq(n[r][0])||!1===e.type.spec.spanning)break;r++,s++}else s++}for(;r<n.length;)i=n.pop()[1];for(;s<t.marks.length;){let r=t.marks[s++],h=this.serializeMark(r,t.isInline,e);h&&(n.push([r,i]),i.appendChild(h.dom),i=h.contentDOM||h.dom)}}i.appendChild(this.serializeNodeInner(t,e))})),r}serializeNodeInner(t,e){if(t.isText)return ot(e).createTextNode(t.text);let{dom:r,contentDOM:i}=at(ot(e),this.nodes[t.type.name](t),null,t.attrs);if(i){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,i)}return r}serializeNode(t,e={}){let r=this.serializeNodeInner(t,e);for(let i=t.marks.length-1;i>=0;i--){let n=this.serializeMark(t.marks[i],t.isInline,e);n&&((n.contentDOM||n.dom).appendChild(r),r=n.dom)}return r}serializeMark(t,e,r={}){let i=this.marks[t.type.name];return i&&at(ot(r),i(t,e),null,t.attrs)}static renderSpec(t,e,r=null,i){return"string"==typeof e?{dom:t.createTextNode(e)}:at(t,e,r,i)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new ht(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=lt(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return lt(t.marks)}}function lt(t){let e={};for(let r in t){let i=t[r].spec.toDOM;i&&(e[r]=i)}return e}function ot(t){return t.document||window.document}const ut=new WeakMap;function ft(t){let e=ut.get(t);return void 0===e&&ut.set(t,e=function(t){let e=null;function r(t){if(t&&"object"==typeof t)if(Array.isArray(t))if("string"==typeof t[0])e||(e=[]),e.push(t);else for(let e=0;e<t.length;e++)r(t[e]);else for(let e in t)r(t[e])}return r(t),e}(t)),e}function at(t,e,r,i){if(1==e.nodeType)return{dom:e};if(e.dom&&1==e.dom.nodeType)return e;let n,s=e[0];if("string"!=typeof s)throw new RangeError("Invalid array passed to renderSpec");if(i&&(n=ft(i))&&n.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let h,l=s.indexOf(" ");l>0&&(r=s.slice(0,l),s=s.slice(l+1));let o=r?t.createElementNS(r,s):t.createElement(s),u=e[1],f=1;if(u&&"object"==typeof u&&null==u.nodeType&&!Array.isArray(u)){f=2;for(let t in u)if(null!=u[t]){let e=t.indexOf(" ");e>0?o.setAttributeNS(t.slice(0,e),t.slice(e+1),u[t]):"style"==t&&o.style?o.style.cssText=u[t]:o.setAttribute(t,u[t])}}for(let n=f;n<e.length;n++){let s=e[n];if(0===s){if(n<e.length-1||n>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:o,contentDOM:o}}if("string"==typeof s)o.appendChild(t.createTextNode(s));else{let{dom:e,contentDOM:n}=at(t,s,r,i);if(o.appendChild(e),n){if(h)throw new RangeError("Multiple content holes");h=n}}}return{dom:o,contentDOM:h}}const ct=Math.pow(2,16);function pt(t){return 65535&t}class dt{constructor(t,e,r){this.pos=t,this.delInfo=e,this.recover=r}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class wt{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&wt.empty)return wt.empty}recover(t){let e=0,r=pt(t);if(!this.inverted)for(let t=0;t<r;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*r]+e+function(t){return(t-(65535&t))/ct}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,r){let i=0,n=this.inverted?2:1,s=this.inverted?1:2;for(let h=0;h<this.ranges.length;h+=3){let l=this.ranges[h]-(this.inverted?i:0);if(l>t)break;let o=this.ranges[h+n],u=this.ranges[h+s],f=l+o;if(t<=f){let n=l+i+((o?t==l?-1:t==f?1:e:e)<0?0:u);if(r)return n;let s=t==(e<0?l:f)?null:h/3+(t-l)*ct,a=t==l?2:t==f?1:4;return(e<0?t!=l:t!=f)&&(a|=8),new dt(n,a,s)}i+=u-o}return r?t+i:new dt(t+i,0,null)}touches(t,e){let r=0,i=pt(e),n=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let h=this.ranges[e]-(this.inverted?r:0);if(h>t)break;let l=this.ranges[e+n];if(t<=h+l&&e==3*i)return!0;r+=this.ranges[e+s]-l}return!1}forEach(t){let e=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,n=0;i<this.ranges.length;i+=3){let s=this.ranges[i],h=s-(this.inverted?n:0),l=s+(this.inverted?0:n),o=this.ranges[i+e],u=this.ranges[i+r];t(h,h+o,l,l+u),n+=u-o}}invert(){return new wt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?wt.empty:new wt(t<0?[0,-t,0]:[0,0,t])}}wt.empty=new wt([]);class gt{constructor(t,e,r=0,i=(t?t.length:0)){this.mirror=e,this.from=r,this.to=i,this._maps=t||[],this.ownData=!(t||e)}get maps(){return this._maps}slice(t=0,e=this.maps.length){return new gt(this._maps,this.mirror,t,e)}appendMap(t,e){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),null!=e&&this.setMirror(this._maps.length-1,e)}appendMapping(t){for(let e=0,r=this._maps.length;e<t._maps.length;e++){let i=t.getMirror(e);this.appendMap(t._maps[e],null!=i&&i<e?r+i:void 0)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,r=this._maps.length+t._maps.length;e>=0;e--){let i=t.getMirror(e);this.appendMap(t._maps[e].invert(),null!=i&&i>e?r-i-1:void 0)}}invert(){let t=new gt;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let r=this.from;r<this.to;r++)t=this._maps[r].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,!1)}_map(t,e,r){let i=0;for(let r=this.from;r<this.to;r++){let n=this._maps[r].mapResult(t,e);if(null!=n.recover){let e=this.getMirror(r);if(null!=e&&e>r&&e<this.to){r=e,t=this._maps[e].recover(n.recover);continue}}i|=n.delInfo,t=n.pos}return r?t:new dt(t,i,null)}}const mt=Object.create(null);class yt{getMap(){return wt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=mt[e.stepType];if(!r)throw new RangeError(`No step type ${e.stepType} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in mt)throw new RangeError("Duplicate use of step JSON ID "+t);return mt[t]=e,e.prototype.jsonID=t,e}}class St{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new St(t,null)}static fail(t){return new St(null,t)}static fromReplace(t,e,r,i){try{return St.ok(t.replace(e,r,i))}catch(t){if(t instanceof f)return St.fail(t.message);throw t}}}function bt(t,e,r){let i=[];for(let n=0;n<t.childCount;n++){let s=t.child(n);s.content.size&&(s=s.copy(bt(s.content,e,s))),s.isInline&&(s=e(s,r,n)),i.push(s)}return s.fromArray(i)}class vt extends yt{constructor(t,e,r){super(),this.from=t,this.to=e,this.mark=r}apply(t){let e=t.slice(this.from,this.to),r=t.resolve(this.from),i=r.node(r.sharedDepth(this.to)),n=new a(bt(e.content,((t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t),i),e.openStart,e.openEnd);return St.fromReplace(t,this.from,this.to,n)}invert(){return new kt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deleted&&r.deleted||e.pos>=r.pos?null:new vt(e.pos,r.pos,this.mark)}merge(t){return t instanceof vt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new vt(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,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new vt(e.from,e.to,t.markFromJSON(e.mark))}}yt.jsonID("addMark",vt);class kt extends yt{constructor(t,e,r){super(),this.from=t,this.to=e,this.mark=r}apply(t){let e=t.slice(this.from,this.to),r=new a(bt(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return St.fromReplace(t,this.from,this.to,r)}invert(){return new vt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deleted&&r.deleted||e.pos>=r.pos?null:new kt(e.pos,r.pos,this.mark)}merge(t){return t instanceof kt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new kt(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,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new kt(e.from,e.to,t.markFromJSON(e.mark))}}yt.jsonID("removeMark",kt);class xt extends yt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return St.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return St.fromReplace(t,this.pos,this.pos+1,new a(s.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let r=0;r<e.marks.length;r++)if(!e.marks[r].isInSet(t))return new xt(this.pos,e.marks[r]);return new xt(this.pos,this.mark)}}return new Et(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new xt(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new xt(e.pos,t.markFromJSON(e.mark))}}yt.jsonID("addNodeMark",xt);class Et extends yt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return St.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return St.fromReplace(t,this.pos,this.pos+1,new a(s.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new xt(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Et(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Et(e.pos,t.markFromJSON(e.mark))}}yt.jsonID("removeNodeMark",Et);class Nt extends yt{constructor(t,e,r,i=!1){super(),this.from=t,this.to=e,this.slice=r,this.structure=i}apply(t){return this.structure&&Rt(t,this.from,this.to)?St.fail("Structure replace would overwrite content"):St.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new wt([this.from,this.to-this.from,this.slice.size])}invert(t){return new Nt(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.to,-1),r=this.from==this.to&&Nt.MAP_BIAS<0?e:t.mapResult(this.from,1);return r.deletedAcross&&e.deletedAcross?null:new Nt(r.pos,Math.max(r.pos,e.pos),this.slice,this.structure)}merge(t){if(!(t instanceof Nt)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;{let e=this.slice.size+t.slice.size==0?a.empty:new a(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Nt(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?a.empty:new a(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Nt(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Nt(e.from,e.to,a.fromJSON(t,e.slice),!!e.structure)}}Nt.MAP_BIAS=1,yt.jsonID("replace",Nt);class Ot extends yt{constructor(t,e,r,i,n,s,h=!1){super(),this.from=t,this.to=e,this.gapFrom=r,this.gapTo=i,this.slice=n,this.insert=s,this.structure=h}apply(t){if(this.structure&&(Rt(t,this.from,this.gapFrom)||Rt(t,this.gapTo,this.to)))return St.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return St.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,e.content);return r?St.fromReplace(t,this.from,this.to,r):St.fail("Content does not fit in gap")}getMap(){return new wt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new Ot(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1),n=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return e.deletedAcross&&r.deletedAcross||i<e.pos||n>r.pos?null:new Ot(e.pos,r.pos,i,n,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ot(e.from,e.to,e.gapFrom,e.gapTo,a.fromJSON(t,e.slice),e.insert,!!e.structure)}}function Rt(t,e,r){let i=t.resolve(e),n=r-e,s=i.depth;for(;n>0&&s>0&&i.indexAfter(s)==i.node(s).childCount;)s--,n--;if(n>0){let t=i.node(s).maybeChild(i.indexAfter(s));for(;n>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,n--}}return!1}function Mt(t,e,r,i=r.contentMatch,n=!0){let h=t.doc.nodeAt(e),l=[],o=e+1;for(let e=0;e<h.childCount;e++){let u=h.child(e),f=o+u.nodeSize,c=i.matchType(u.type);if(c){i=c;for(let e=0;e<u.marks.length;e++)r.allowsMarkType(u.marks[e].type)||t.step(new kt(o,f,u.marks[e]));if(n&&u.isText&&"pre"!=r.whitespace){let t,e,i=/\r?\n|\r/g;for(;t=i.exec(u.text);)e||(e=new a(s.from(r.schema.text(" ",r.allowedMarks(u.marks))),0,0)),l.push(new Nt(o+t.index,o+t.index+t[0].length,e))}}else l.push(new Nt(o,f,a.empty));o=f}if(!i.validEnd){let e=i.fillBefore(s.empty,!0);t.replace(o,o,new a(e,0,0))}for(let e=l.length-1;e>=0;e--)t.step(l[e])}function Jt(t,e,r){return(0==e||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function It(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,n=0;;--r){let s=t.$from.node(r),h=t.$from.index(r)+i,l=t.$to.indexAfter(r)-n;if(r<t.depth&&s.canReplace(h,l,e))return r;if(0==r||s.type.spec.isolating||!Jt(s,h,l))break;h&&(i=1),l<s.childCount&&(n=1)}return null}function Tt(t,e,r=null,i=t){let n=function(t,e){let{parent:r,startIndex:i,endIndex:n}=t,s=r.contentMatchAt(i).findWrapping(e);if(!s)return null;let h=s.length?s[0]:e;return r.canReplaceWith(i,n,h)?s:null}(t,e),s=n&&function(t,e){let{parent:r,startIndex:i,endIndex:n}=t,s=r.child(i),h=e.contentMatch.findWrapping(s.type);if(!h)return null;let l=(h.length?h[h.length-1]:e).contentMatch;for(let t=i;l&&t<n;t++)l=l.matchType(r.child(t).type);return l&&l.validEnd?h:null}(i,e);return s?n.map(At).concat({type:e,attrs:r}).concat(s.map(At)):null}function At(t){return{type:t,attrs:null}}function jt(t,e,r,i){e.forEach(((n,s)=>{if(n.isText){let h,l=/\r?\n|\r/g;for(;h=l.exec(n.text);){let n=t.mapping.slice(i).map(r+1+s+h.index);t.replaceWith(n,n+1,e.type.schema.linebreakReplacement.create())}}}))}function Ct(t,e,r,i){e.forEach(((n,s)=>{if(n.type==n.type.schema.linebreakReplacement){let n=t.mapping.slice(i).map(r+1+s);t.replaceWith(n,n+1,e.type.schema.text("\n"))}}))}function $t(t,e,r=1,i){let n=t.resolve(e),s=n.depth-r,h=i&&i[i.length-1]||n.parent;if(s<0||n.parent.type.spec.isolating||!n.parent.canReplace(n.index(),n.parent.childCount)||!h.type.validContent(n.parent.content.cutByIndex(n.index(),n.parent.childCount)))return!1;for(let t=n.depth-1,e=r-2;t>s;t--,e--){let r=n.node(t),s=n.index(t);if(r.type.spec.isolating)return!1;let h=r.content.cutByIndex(s,r.childCount),l=i&&i[e+1];l&&(h=h.replaceChild(0,l.type.create(l.attrs)));let o=i&&i[e]||r;if(!r.canReplace(s+1,r.childCount)||!o.type.validContent(h))return!1}let l=n.indexAfter(s),o=i&&i[0];return n.node(s).canReplaceWith(l,l,o?o.type:n.node(s+1).type)}function Dt(t,e){let r=t.resolve(e),i=r.index();return n=r.nodeBefore,s=r.nodeAfter,!(!n||!s||n.isLeaf||!function(t,e){e.content.size||t.type.compatibleContent(e.type);let r=t.contentMatchAt(t.childCount),{linebreakReplacement:i}=t.type.schema;for(let n=0;n<e.childCount;n++){let s=e.child(n),h=s.type==i?t.type.schema.nodes.text:s.type;if(r=r.matchType(h),!r)return!1;if(!t.type.allowsMarks(s.marks))return!1}return r.validEnd}(n,s))&&r.parent.canReplace(i,i+1);var n,s}function Bt(t,e,r){let i=t.resolve(e);if(!r.content.size)return e;let n=r.content;for(let t=0;t<r.openStart;t++)n=n.firstChild.content;for(let t=1;t<=(0==r.openStart&&r.size?2:1);t++)for(let e=i.depth;e>=0;e--){let r=e==i.depth?0:i.pos<=(i.start(e+1)+i.end(e+1))/2?-1:1,s=i.index(e)+(r>0?1:0),h=i.node(e),l=!1;if(1==t)l=h.canReplace(s,s,n);else{let t=h.contentMatchAt(s).findWrapping(n.firstChild.type);l=t&&h.canReplaceWith(s,s,t[0])}if(l)return 0==r?i.pos:r<0?i.before(e+1):i.after(e+1)}return null}function Ft(t,e,r=e,i=a.empty){if(e==r&&!i.size)return null;let n=t.resolve(e),s=t.resolve(r);return qt(n,s,i)?new Nt(e,r,i):new Wt(n,s,i).fit()}function qt(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}yt.jsonID("replaceAround",Ot);class Wt{constructor(t,e,r){this.$from=t,this.$to=e,this.unplaced=r,this.frontier=[],this.placed=s.empty;for(let e=0;e<=t.depth;e++){let r=t.node(e);this.frontier.push({type:r.type,match:r.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=s.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(t<0?this.$to:r.doc.resolve(t));if(!i)return null;let n=this.placed,s=r.depth,h=i.depth;for(;s&&h&&1==n.childCount;)n=n.firstChild.content,s--,h--;let l=new a(n,s,h);return t>-1?new Ot(r.pos,t,this.$to.pos,this.$to.end(),l,e):l.size||r.pos!=this.$to.pos?new Nt(r.pos,i.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<t;r++){let n=e.firstChild;if(e.childCount>1&&(i=0),n.type.spec.isolating&&i<=r){t=r;break}e=n.content}for(let e=1;e<=2;e++)for(let r=1==e?t:this.unplaced.openStart;r>=0;r--){let t,i=null;r?(i=Ut(this.unplaced.content,r-1).firstChild,t=i.content):t=this.unplaced.content;let n=t.firstChild;for(let t=this.depth;t>=0;t--){let h,{type:l,match:o}=this.frontier[t],u=null;if(1==e&&(n?o.matchType(n.type)||(u=o.fillBefore(s.from(n),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:t,parent:i,inject:u};if(2==e&&n&&(h=o.findWrapping(n.type)))return{sliceDepth:r,frontierDepth:t,parent:i,wrap:h};if(i&&o.matchType(i.type))break}}}openMore(){let{content:t,openStart:e,openEnd:r}=this.unplaced,i=Ut(t,e);return!(!i.childCount||i.firstChild.isLeaf)&&(this.unplaced=new a(t,e+1,Math.max(r,i.size+e>=t.size-r?e+1:0)),!0)}dropNode(){let{content:t,openStart:e,openEnd:r}=this.unplaced,i=Ut(t,e);if(i.childCount<=1&&e>0){let n=t.size-e<=e+i.size;this.unplaced=new a(zt(t,e-1,1),e-1,n?e-1:r)}else this.unplaced=new a(zt(t,e,1),e,r)}placeNodes({sliceDepth:t,frontierDepth:e,parent:r,inject:i,wrap:n}){for(;this.depth>e;)this.closeFrontierNode();if(n)for(let t=0;t<n.length;t++)this.openFrontierNode(n[t]);let h=this.unplaced,l=r?r.content:h.content,o=h.openStart-t,u=0,f=[],{match:c,type:p}=this.frontier[e];if(i){for(let t=0;t<i.childCount;t++)f.push(i.child(t));c=c.matchFragment(i)}let d=l.size+t-(h.content.size-h.openEnd);for(;u<l.childCount;){let t=l.child(u),e=c.matchType(t.type);if(!e)break;u++,(u>1||0==o||t.content.size)&&(c=e,f.push(_t(t.mark(p.allowedMarks(t.marks)),1==u?o:0,u==l.childCount?d:-1)))}let w=u==l.childCount;w||(d=-1),this.placed=Pt(this.placed,e,s.from(f)),this.frontier[e].match=c,w&&d<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=l;t<d;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),e=t.content}this.unplaced=w?0==t?a.empty:new a(zt(h.content,t-1,1),t-1,d<0?h.openEnd:t-1):new a(zt(h.content,t,u),h.openStart,h.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t,e=this.frontier[this.depth];if(!e.type.isTextblock||!Lt(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:r,type:i}=this.frontier[e],n=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=Lt(t,e,i,r,n);if(s){for(let r=e-1;r>=0;r--){let{match:e,type:i}=this.frontier[r],n=Lt(t,r,i,e,!0);if(!n||n.childCount)continue t}return{depth:e,fit:s,move:n?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=Pt(this.placed,e.depth,e.fit)),t=e.move;for(let r=e.depth+1;r<=t.depth;r++){let e=t.node(r),i=e.type.contentMatch.fillBefore(e.content,!0,t.index(r));this.openFrontierNode(e.type,e.attrs,i)}return t}openFrontierNode(t,e=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(t),this.placed=Pt(this.placed,this.depth,s.from(t.create(e,r))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(s.empty,!0);t.childCount&&(this.placed=Pt(this.placed,this.frontier.length,t))}}function zt(t,e,r){return 0==e?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(zt(t.firstChild.content,e-1,r)))}function Pt(t,e,r){return 0==e?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(Pt(t.lastChild.content,e-1,r)))}function Ut(t,e){for(let r=0;r<e;r++)t=t.firstChild.content;return t}function _t(t,e,r){if(e<=0)return t;let i=t.content;return e>1&&(i=i.replaceChild(0,_t(i.firstChild,e-1,1==i.childCount?r-1:0))),e>0&&(i=t.type.contentMatch.fillBefore(i).append(i),r<=0&&(i=i.append(t.type.contentMatch.matchFragment(i).fillBefore(s.empty,!0)))),t.copy(i)}function Lt(t,e,r,i,n){let s=t.node(e),h=n?t.indexAfter(e):t.index(e);if(h==s.childCount&&!r.compatibleContent(s.type))return null;let l=i.fillBefore(s.content,!0,h);return l&&!function(t,e,r){for(let i=r;i<e.childCount;i++)if(!t.allowsMarks(e.child(i).marks))return!0;return!1}(r,s.content,h)?l:null}function Gt(t,e,r,i,n){if(e<r){let n=t.firstChild;t=t.replaceChild(0,n.copy(Gt(n.content,e+1,r,i,n)))}if(e>i){let e=n.contentMatchAt(0),r=e.fillBefore(t).append(t);t=r.append(e.matchFragment(r).fillBefore(s.empty,!0))}return t}function Vt(t,e){let r=[];for(let i=Math.min(t.depth,e.depth);i>=0;i--){let n=t.start(i);if(n<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(n==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==n-1)&&r.push(i)}return r}class Ht extends yt{constructor(t,e,r){super(),this.pos=t,this.attr=e,this.value=r}apply(t){let e=t.nodeAt(this.pos);if(!e)return St.fail("No node at attribute step's position");let r=Object.create(null);for(let t in e.attrs)r[t]=e.attrs[t];r[this.attr]=this.value;let i=e.type.create(r,null,e.marks);return St.fromReplace(t,this.pos,this.pos+1,new a(s.from(i),0,e.isLeaf?0:1))}getMap(){return wt.empty}invert(t){return new Ht(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Ht(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ht(e.pos,e.attr,e.value)}}yt.jsonID("attr",Ht);class Kt extends yt{constructor(t,e){super(),this.attr=t,this.value=e}apply(t){let e=Object.create(null);for(let r in t.attrs)e[r]=t.attrs[r];e[this.attr]=this.value;let r=t.type.create(e,t.content,t.marks);return St.ok(r)}getMap(){return wt.empty}invert(t){return new Kt(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if("string"!=typeof e.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Kt(e.attr,e.value)}}yt.jsonID("docAttr",Kt);let Qt=class extends Error{};Qt=function t(e){let r=Error.call(this,e);return r.__proto__=t.prototype,r},(Qt.prototype=Object.create(Error.prototype)).constructor=Qt,Qt.prototype.name="TransformError";class Xt{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new gt}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Qt(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}changedRange(){let t=1e9,e=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(t=i.map(t,1),e=i.map(e,-1)),i.forEach(((r,i,n,s)=>{t=Math.min(t,n),e=Math.max(e,s)}))}return 1e9==t?null:{from:t,to:e}}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,r=a.empty){let i=Ft(this.doc,t,e,r);return i&&this.step(i),this}replaceWith(t,e,r){return this.replace(t,e,new a(s.from(r),0,0))}delete(t,e){return this.replace(t,e,a.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,r){return function(t,e,r,i){if(!i.size)return t.deleteRange(e,r);let n=t.doc.resolve(e),s=t.doc.resolve(r);if(qt(n,s,i))return t.step(new Nt(e,r,i));let h=Vt(n,s);0==h[h.length-1]&&h.pop();let l=-(n.depth+1);h.unshift(l);for(let t=n.depth,e=n.pos-1;t>0;t--,e--){let r=n.node(t).type.spec;if(r.defining||r.definingAsContext||r.isolating)break;h.indexOf(t)>-1?l=t:n.before(t)==e&&h.splice(1,0,-t)}let o=h.indexOf(l),u=[],f=i.openStart;for(let t=i.content,e=0;;e++){let r=t.firstChild;if(u.push(r),e==i.openStart)break;t=r.content}for(let t=f-1;t>=0;t--){let e=u[t],r=(c=e.type).spec.defining||c.spec.definingForContent;if(r&&!e.sameMarkup(n.node(Math.abs(l)-1)))f=t;else if(r||!e.type.isTextblock)break}var c;for(let e=i.openStart;e>=0;e--){let l=(e+f+1)%(i.openStart+1),c=u[l];if(c)for(let e=0;e<h.length;e++){let u=h[(e+o)%h.length],f=!0;u<0&&(f=!1,u=-u);let p=n.node(u-1),d=n.index(u-1);if(p.canReplaceWith(d,d,c.type,c.marks))return t.replace(n.before(u),f?s.after(u):r,new a(Gt(i.content,0,i.openStart,l),l,i.openEnd))}}let p=t.steps.length;for(let l=h.length-1;l>=0&&(t.replace(e,r,i),!(t.steps.length>p));l--){let t=h[l];t<0||(e=n.before(t),r=s.after(t))}}(this,t,e,r),this}replaceRangeWith(t,e,r){return function(t,e,r,i){if(!i.isInline&&e==r&&t.doc.resolve(e).parent.content.size){let n=function(t,e,r){let i=t.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),r))return e;if(0==i.parentOffset)for(let t=i.depth-1;t>=0;t--){let e=i.index(t);if(i.node(t).canReplaceWith(e,e,r))return i.before(t+1);if(e>0)return null}if(i.parentOffset==i.parent.content.size)for(let t=i.depth-1;t>=0;t--){let e=i.indexAfter(t);if(i.node(t).canReplaceWith(e,e,r))return i.after(t+1);if(e<i.node(t).childCount)return null}return null}(t.doc,e,i.type);null!=n&&(e=r=n)}t.replaceRange(e,r,new a(s.from(i),0,0))}(this,t,e,r),this}deleteRange(t,e){return function(t,e,r){let i=t.doc.resolve(e),n=t.doc.resolve(r);if(i.parent.isTextblock&&n.parent.isTextblock&&i.start()!=n.start()&&0==i.parentOffset&&0==n.parentOffset){let s=i.sharedDepth(r),h=!1;for(let t=i.depth;t>s;t--)i.node(t).type.spec.isolating&&(h=!0);for(let t=n.depth;t>s;t--)n.node(t).type.spec.isolating&&(h=!0);if(!h){for(let t=i.depth;t>0&&e==i.start(t);t--)e=i.before(t);for(let t=n.depth;t>0&&r==n.start(t);t--)r=n.before(t);i=t.doc.resolve(e),n=t.doc.resolve(r)}}let s=Vt(i,n);for(let e=0;e<s.length;e++){let r=s[e],h=e==s.length-1;if(h&&0==r||i.node(r).type.contentMatch.validEnd)return t.delete(i.start(r),n.end(r));if(r>0&&(h||i.node(r-1).canReplace(i.index(r-1),n.indexAfter(r-1))))return t.delete(i.before(r),n.after(r))}for(let s=1;s<=i.depth&&s<=n.depth;s++)if(e-i.start(s)==i.depth-s&&r>i.end(s)&&n.end(s)-r!=n.depth-s&&i.start(s-1)==n.start(s-1)&&i.node(s-1).canReplace(i.index(s-1),n.index(s-1)))return t.delete(i.before(s),r);t.delete(e,r)}(this,t,e),this}lift(t,e){return function(t,e,r){let{$from:i,$to:n,depth:h}=e,l=i.before(h+1),o=n.after(h+1),u=l,f=o,c=s.empty,p=0;for(let t=h,e=!1;t>r;t--)e||i.index(t)>0?(e=!0,c=s.from(i.node(t).copy(c)),p++):u--;let d=s.empty,w=0;for(let t=h,e=!1;t>r;t--)e||n.after(t+1)<n.end(t)?(e=!0,d=s.from(n.node(t).copy(d)),w++):f++;t.step(new Ot(u,f,l,o,new a(c.append(d),p,w),c.size-p,!0))}(this,t,e),this}join(t,e=1){return function(t,e,r){let i=null,{linebreakReplacement:n}=t.doc.type.schema,s=t.doc.resolve(e-r),h=s.node().type;if(n&&h.inlineContent){let t="pre"==h.whitespace,e=!!h.contentMatch.matchType(n);t&&!e?i=!1:!t&&e&&(i=!0)}let l=t.steps.length;if(!1===i){let i=t.doc.resolve(e+r);Ct(t,i.node(),i.before(),l)}h.inlineContent&&Mt(t,e+r-1,h,s.node().contentMatchAt(s.index()),null==i);let o=t.mapping.slice(l),u=o.map(e-r);if(t.step(new Nt(u,o.map(e+r,-1),a.empty,!0)),!0===i){let e=t.doc.resolve(u);jt(t,e.node(),e.before(),t.steps.length)}}(this,t,e),this}wrap(t,e){return function(t,e,r){let i=s.empty;for(let t=r.length-1;t>=0;t--){if(i.size){let e=r[t].type.contentMatch.matchFragment(i);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=s.from(r[t].type.create(r[t].attrs,i))}let n=e.start,h=e.end;t.step(new Ot(n,h,n,h,new a(i,0,0),r.length,!0))}(this,t,e),this}setBlockType(t,e=t,r,i=null){return function(t,e,r,i,n){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let h=t.steps.length;t.doc.nodesBetween(e,r,((e,r)=>{let l="function"==typeof n?n(e):n;if(e.isTextblock&&!e.hasMarkup(i,l)&&function(t,e,r){let i=t.resolve(e),n=i.index();return i.parent.canReplaceWith(n,n+1,r)}(t.doc,t.mapping.slice(h).map(r),i)){let n=null;if(i.schema.linebreakReplacement){let t="pre"==i.whitespace,e=!!i.contentMatch.matchType(i.schema.linebreakReplacement);t&&!e?n=!1:!t&&e&&(n=!0)}!1===n&&Ct(t,e,r,h),Mt(t,t.mapping.slice(h).map(r,1),i,void 0,null===n);let o=t.mapping.slice(h),u=o.map(r,1),f=o.map(r+e.nodeSize,1);return t.step(new Ot(u,f,u+1,f-1,new a(s.from(i.create(l,null,e.marks)),0,0),1,!0)),!0===n&&jt(t,e,r,h),!1}}))}(this,t,e,r,i),this}setNodeMarkup(t,e,r=null,i){return function(t,e,r,i,n){let h=t.doc.nodeAt(e);if(!h)throw new RangeError("No node at given position");r||(r=h.type);let l=r.create(i,null,n||h.marks);if(h.isLeaf)return t.replaceWith(e,e+h.nodeSize,l);if(!r.validContent(h.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new Ot(e,e+h.nodeSize,e+1,e+h.nodeSize-1,new a(s.from(l),0,0),1,!0))}(this,t,e,r,i),this}setNodeAttribute(t,e,r){return this.step(new Ht(t,e,r)),this}setDocAttribute(t,e){return this.step(new Kt(t,e)),this}addNodeMark(t,e){return this.step(new xt(t,e)),this}removeNodeMark(t,e){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);if(e instanceof u)e.isInSet(r.marks)&&this.step(new Et(t,e));else{let i,n=r.marks,s=[];for(;i=e.isInSet(n);)s.push(new Et(t,i)),n=i.removeFromSet(n);for(let t=s.length-1;t>=0;t--)this.step(s[t])}return this}split(t,e=1,r){return function(t,e,r=1,i){let n=t.doc.resolve(e),h=s.empty,l=s.empty;for(let t=n.depth,e=n.depth-r,o=r-1;t>e;t--,o--){h=s.from(n.node(t).copy(h));let e=i&&i[o];l=s.from(e?e.type.create(e.attrs,l):n.node(t).copy(l))}t.step(new Nt(e,e,new a(h.append(l),r,r),!0))}(this,t,e,r),this}addMark(t,e,r){return function(t,e,r,i){let n,s,h=[],l=[];t.doc.nodesBetween(e,r,((t,o,u)=>{if(!t.isInline)return;let f=t.marks;if(!i.isInSet(f)&&u.type.allowsMarkType(i.type)){let u=Math.max(o,e),a=Math.min(o+t.nodeSize,r),c=i.addToSet(f);for(let t=0;t<f.length;t++)f[t].isInSet(c)||(n&&n.to==u&&n.mark.eq(f[t])?n.to=a:h.push(n=new kt(u,a,f[t])));s&&s.to==u?s.to=a:l.push(s=new vt(u,a,i))}})),h.forEach((e=>t.step(e))),l.forEach((e=>t.step(e)))}(this,t,e,r),this}removeMark(t,e,r){return function(t,e,r,i){let n=[],s=0;t.doc.nodesBetween(e,r,((t,h)=>{if(!t.isInline)return;s++;let l=null;if(i instanceof V){let e,r=t.marks;for(;e=i.isInSet(r);)(l||(l=[])).push(e),r=e.removeFromSet(r)}else i?i.isInSet(t.marks)&&(l=[i]):l=t.marks;if(l&&l.length){let i=Math.min(h+t.nodeSize,r);for(let t=0;t<l.length;t++){let r,o=l[t];for(let t=0;t<n.length;t++){let e=n[t];e.step==s-1&&o.eq(n[t].style)&&(r=e)}r?(r.to=i,r.step=s):n.push({style:o,from:Math.max(h,e),to:i,step:s})}}})),n.forEach((e=>t.step(new kt(e.from,e.to,e.style))))}(this,t,e,r),this}clearIncompatible(t,e,r){return Mt(this,t,e,r),this}}const Yt=Object.create(null);class Zt{constructor(t,e,r){this.$anchor=t,this.$head=e,this.ranges=r||[new te(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=a.empty){let r=e.content.lastChild,i=null;for(let t=0;t<e.openEnd;t++)i=r,r=r.lastChild;let n=t.steps.length,s=this.ranges;for(let h=0;h<s.length;h++){let{$from:l,$to:o}=s[h],u=t.mapping.slice(n);t.replaceRange(u.map(l.pos),u.map(o.pos),h?a.empty:e),0==h&&fe(t,n,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(t,e){let r=t.steps.length,i=this.ranges;for(let n=0;n<i.length;n++){let{$from:s,$to:h}=i[n],l=t.mapping.slice(r),o=l.map(s.pos),u=l.map(h.pos);n?t.deleteRange(o,u):(t.replaceRangeWith(o,u,e),fe(t,r,e.isInline?-1:1))}}static findFrom(t,e,r=!1){let i=t.parent.inlineContent?new ie(t):ue(t.node(0),t.parent,t.pos,t.index(),e,r);if(i)return i;for(let i=t.depth-1;i>=0;i--){let n=e<0?ue(t.node(0),t.node(i),t.before(i+1),t.index(i),e,r):ue(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,e,r);if(n)return n}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new le(t.node(0))}static atStart(t){return ue(t,t,0,0,1)||new le(t)}static atEnd(t){return ue(t,t,t.content.size,t.childCount,-1)||new le(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Yt[e.type];if(!r)throw new RangeError(`No selection type ${e.type} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in Yt)throw new RangeError("Duplicate use of selection JSON ID "+t);return Yt[t]=e,e.prototype.jsonID=t,e}getBookmark(){return ie.between(this.$anchor,this.$head).getBookmark()}}Zt.prototype.visible=!0;class te{constructor(t,e){this.$from=t,this.$to=e}}let ee=!1;function re(t){ee||t.parent.inlineContent||(ee=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ie extends Zt{constructor(t,e=t){re(t),re(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let r=t.resolve(e.map(this.head));if(!r.parent.inlineContent)return Zt.near(r);let i=t.resolve(e.map(this.anchor));return new ie(i.parent.inlineContent?i:r,r)}replace(t,e=a.empty){if(super.replace(t,e),e==a.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof ie&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new ne(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new ie(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,r=e){let i=t.resolve(e);return new this(i,r==e?i:t.resolve(r))}static between(t,e,r){let i=t.pos-e.pos;if(r&&!i||(r=i>=0?1:-1),!e.parent.inlineContent){let t=Zt.findFrom(e,r,!0)||Zt.findFrom(e,-r,!0);if(!t)return Zt.near(e,r);e=t.$head}return t.parent.inlineContent||(0==i||(t=(Zt.findFrom(t,-r,!0)||Zt.findFrom(t,r,!0)).$anchor).pos<e.pos!=i<0)&&(t=e),new ie(t,e)}}Zt.jsonID("text",ie);class ne{constructor(t,e){this.anchor=t,this.head=e}map(t){return new ne(t.map(this.anchor),t.map(this.head))}resolve(t){return ie.between(t.resolve(this.anchor),t.resolve(this.head))}}class se extends Zt{constructor(t){let e=t.nodeAfter,r=t.node(0).resolve(t.pos+e.nodeSize);super(t,r),this.node=e}map(t,e){let{deleted:r,pos:i}=e.mapResult(this.anchor),n=t.resolve(i);return r?Zt.near(n):new se(n)}content(){return new a(s.from(this.node),0,0)}eq(t){return t instanceof se&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new he(this.anchor)}static fromJSON(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new se(t.resolve(e.anchor))}static create(t,e){return new se(t.resolve(e))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}}se.prototype.visible=!1,Zt.jsonID("node",se);class he{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:r}=t.mapResult(this.anchor);return e?new ne(r,r):new he(r)}resolve(t){let e=t.resolve(this.anchor),r=e.nodeAfter;return r&&se.isSelectable(r)?new se(e):Zt.near(e)}}class le extends Zt{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=a.empty){if(e==a.empty){t.delete(0,t.doc.content.size);let e=Zt.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new le(t)}map(t){return new le(t)}eq(t){return t instanceof le}getBookmark(){return oe}}Zt.jsonID("all",le);const oe={map(){return this},resolve:t=>new le(t)};function ue(t,e,r,i,n,s=!1){if(e.inlineContent)return ie.create(t,r);for(let h=i-(n>0?0:1);n>0?h<e.childCount:h>=0;h+=n){let i=e.child(h);if(i.isAtom){if(!s&&se.isSelectable(i))return se.create(t,r-(n<0?i.nodeSize:0))}else{let e=ue(t,i,r+n,n<0?i.childCount:0,n,s);if(e)return e}r+=i.nodeSize*n}return null}function fe(t,e,r){let i=t.steps.length-1;if(i<e)return;let n,s=t.steps[i];(s instanceof Nt||s instanceof Ot)&&(t.mapping.maps[i].forEach(((t,e,r,i)=>{null==n&&(n=i)})),t.setSelection(Zt.near(t.doc.resolve(n),r)))}class ae extends Xt{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=2,this}ensureMarks(t){return u.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let r=this.selection;return e&&(t=t.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||u.none))),r.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,r){let i=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(i.text(t),!0):this.deleteSelection();{if(null==r&&(r=e),!t)return this.deleteRange(e,r);let n=this.storedMarks;if(!n){let t=this.doc.resolve(e);n=r==e?t.marks():t.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(e,r,i.text(t,n)),this.selection.empty||this.selection.to!=e+t.length||this.setSelection(Zt.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function ce(t,e){return e&&t?t.bind(e):t}class pe{constructor(t,e,r){this.name=t,this.init=ce(e.init,r),this.apply=ce(e.apply,r)}}const de=[new pe("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new pe("selection",{init:(t,e)=>t.selection||Zt.atStart(e.doc),apply:t=>t.selection}),new pe("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,r,i)=>i.selection.$cursor?t.storedMarks:null}),new pe("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e})];class we{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=de.slice(),e&&e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t),this.pluginsByKey[t.key]=t,t.spec.state&&this.fields.push(new pe(t.key,t.spec.state,t))}))}}class ge{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=e){let e=this.config.plugins[r];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],r=this.applyInner(t),i=null;for(;;){let n=!1;for(let s=0;s<this.config.plugins.length;s++){let h=this.config.plugins[s];if(h.spec.appendTransaction){let l=i?i[s].n:0,o=i?i[s].state:this,u=l<e.length&&h.spec.appendTransaction.call(h,l?e.slice(l):e,o,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",t),!i){i=[];for(let t=0;t<this.config.plugins.length;t++)i.push(t<s?{state:r,n:e.length}:{state:this,n:0})}e.push(u),r=r.applyInner(u),n=!0}i&&(i[s]={state:r,n:e.length})}}if(!n)return{state:r,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new ge(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let n=r[i];e[n.name]=n.apply(t,this[n.name],this,e)}return e}get tr(){return new ae(this)}static create(t){let e=new we(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new ge(e);for(let i=0;i<e.fields.length;i++)r[e.fields[i].name]=e.fields[i].init(t,r);return r}reconfigure(t){let e=new we(this.schema,t.plugins),r=e.fields,i=new ge(e);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((t=>t.toJSON()))),t&&"object"==typeof t)for(let r in t){if("doc"==r||"selection"==r)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=t[r],n=i.spec.state;n&&n.toJSON&&(e[r]=n.toJSON.call(i,this[i.key]))}return e}static fromJSON(t,e,r){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let i=new we(t.schema,t.plugins),n=new ge(i);return i.fields.forEach((i=>{if("doc"==i.name)n.doc=J.fromJSON(t.schema,e.doc);else if("selection"==i.name)n.selection=Zt.fromJSON(n.doc,e.selection);else if("storedMarks"==i.name)e.storedMarks&&(n.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let s in r){let h=r[s],l=h.spec.state;if(h.key==i.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,s))return void(n[i.name]=l.fromJSON.call(h,t,e[s],n))}n[i.name]=i.init(t,n)}})),n}}function me(t,e,r){for(let i in t){let n=t[i];n instanceof Function?n=n.bind(e):"handleDOMEvents"==i&&(n=me(n,e,{})),r[i]=n}return r}class ye{constructor(t){this.spec=t,this.props={},t.props&&me(t.props,this,this.props),this.key=t.key?t.key.key:be("plugin")}getState(t){return t[this.key]}}const Se=Object.create(null);function be(t){return t in Se?t+"$"+ ++Se[t]:(Se[t]=0,t+"$")}class ve{constructor(t="key"){this.key=be(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}export{le as A,Q as D,ge as E,s as F,u as M,J as N,t as O,ve as P,Ot as R,Zt as S,ie as T,ht as a,ye as b,se as c,a as d,Bt as e,Tt as f,Dt as g,R as h,$t as i,H as j,te as k,It as l,Xt as m,gt as n,Ft as r};
@@ -1 +0,0 @@
1
- import{b as t,P as n,S as e,k as o,T as r,F as i,d as l,c as s,m as c}from"./index-6f3fa4ab.esm.js";import{D as f,a as u}from"./index-ba47645d.esm.js";import{k as a,b as h}from"./index-920675c4.esm.js";const w="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),d="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function p(t){let n,e,o,r,i=t.split(/-(?!$)/),l=i[i.length-1];"Space"==l&&(l=" ");for(let t=0;t<i.length-1;t++){let l=i[t];if(/^(cmd|meta|m)$/i.test(l))r=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))e=!0;else if(/^s(hift)?$/i.test(l))o=!0;else{if(!/^mod$/i.test(l))throw new Error("Unrecognized modifier name: "+l);w?r=!0:e=!0}}return n&&(l="Alt-"+l),e&&(l="Ctrl-"+l),r&&(l="Meta-"+l),o&&(l="Shift-"+l),l}function m(t,n,e=!0){return n.altKey&&(t="Alt-"+t),n.ctrlKey&&(t="Ctrl-"+t),n.metaKey&&(t="Meta-"+t),e&&n.shiftKey&&(t="Shift-"+t),t}function g(n){return new t({props:{handleKeyDown:b(n)}})}function b(t){let n=function(t){let n=Object.create(null);for(let e in t)n[p(e)]=t[e];return n}(t);return function(t,e){let o,r=a(e),i=n[m(r,e)];if(i&&i(t.state,t.dispatch,t))return!0;if(1==r.length&&" "!=r){if(e.shiftKey){let o=n[m(r,e,!1)];if(o&&o(t.state,t.dispatch,t))return!0}if((e.altKey||e.metaKey||e.ctrlKey)&&!(d&&e.ctrlKey&&e.altKey)&&(o=h[e.keyCode])&&o!=r){let r=n[m(o,e)];if(r&&r(t.state,t.dispatch,t))return!0}}return!1}}let v,M;if("undefined"!=typeof WeakMap){let t=new WeakMap;v=n=>t.get(n),M=(n,e)=>(t.set(n,e),e)}else{const t=[],n=10;let e=0;v=n=>{for(let e=0;e<t.length;e+=2)if(t[e]==n)return t[e+1]},M=(o,r)=>(e==n&&(e=0),t[e++]=o,t[e++]=r)}var y=class{constructor(t,n,e,o){this.width=t,this.height=n,this.map=e,this.problems=o}findCell(t){for(let n=0;n<this.map.length;n++){const e=this.map[n];if(e!=t)continue;const o=n%this.width,r=n/this.width|0;let i=o+1,l=r+1;for(let t=1;i<this.width&&this.map[n+t]==e;t++)i++;for(let t=1;l<this.height&&this.map[n+this.width*t]==e;t++)l++;return{left:o,top:r,right:i,bottom:l}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let n=0;n<this.map.length;n++)if(this.map[n]==t)return n%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,n,e){const{left:o,right:r,top:i,bottom:l}=this.findCell(t);return"horiz"==n?(e<0?0==o:r==this.width)?null:this.map[i*this.width+(e<0?o-1:r)]:(e<0?0==i:l==this.height)?null:this.map[o+this.width*(e<0?i-1:l)]}rectBetween(t,n){const{left:e,right:o,top:r,bottom:i}=this.findCell(t),{left:l,right:s,top:c,bottom:f}=this.findCell(n);return{left:Math.min(e,l),top:Math.min(r,c),right:Math.max(o,s),bottom:Math.max(i,f)}}cellsInRect(t){const n=[],e={};for(let o=t.top;o<t.bottom;o++)for(let r=t.left;r<t.right;r++){const i=o*this.width+r,l=this.map[i];e[l]||(e[l]=!0,r==t.left&&r&&this.map[i-1]==l||o==t.top&&o&&this.map[i-this.width]==l||n.push(l))}return n}positionAt(t,n,e){for(let o=0,r=0;;o++){const i=r+e.child(o).nodeSize;if(o==t){let e=n+t*this.width;const o=(t+1)*this.width;for(;e<o&&this.map[e]<r;)e++;return e==o?i-1:this.map[e]}r=i}}static get(t){return v(t)||M(t,function(t){if("table"!=t.type.spec.tableRole)throw new RangeError("Not a table node: "+t.type.name);const n=function(t){let n=-1,e=!1;for(let o=0;o<t.childCount;o++){const r=t.child(o);let i=0;if(e)for(let n=0;n<o;n++){const e=t.child(n);for(let t=0;t<e.childCount;t++){const r=e.child(t);n+r.attrs.rowspan>o&&(i+=r.attrs.colspan)}}for(let t=0;t<r.childCount;t++){const n=r.child(t);i+=n.attrs.colspan,n.attrs.rowspan>1&&(e=!0)}-1==n?n=i:n!=i&&(n=Math.max(n,i))}return n}(t),e=t.childCount,o=[];let r=0,i=null;const l=[];for(let t=0,r=n*e;t<r;t++)o[t]=0;for(let s=0,c=0;s<e;s++){const f=t.child(s);c++;for(let t=0;;t++){for(;r<o.length&&0!=o[r];)r++;if(t==f.childCount)break;const u=f.child(t),{colspan:a,rowspan:h,colwidth:w}=u.attrs;for(let t=0;t<h;t++){if(t+s>=e){(i||(i=[])).push({type:"overlong_rowspan",pos:c,n:h-t});break}const f=r+t*n;for(let t=0;t<a;t++){0==o[f+t]?o[f+t]=c:(i||(i=[])).push({type:"collision",row:s,pos:c,n:a-t});const e=w&&w[t];if(e){const o=(f+t)%n*2,r=l[o];null==r||r!=e&&1==l[o+1]?(l[o]=e,l[o+1]=1):r==e&&l[o+1]++}}}r+=a,c+=u.nodeSize}const u=(s+1)*n;let a=0;for(;r<u;)0==o[r++]&&a++;a&&(i||(i=[])).push({type:"missing",row:s,n:a}),c++}0!==n&&0!==e||(i||(i=[])).push({type:"zero_sized"});const s=new y(n,e,o,i);let c=!1;for(let t=0;!c&&t<l.length;t+=2)null!=l[t]&&l[t+1]<e&&(c=!0);c&&function(t,n,e){t.problems||(t.problems=[]);const o={};for(let r=0;r<t.map.length;r++){const i=t.map[r];if(o[i])continue;o[i]=!0;const l=e.nodeAt(i);if(!l)throw new RangeError(`No cell with offset ${i} found`);let s=null;const c=l.attrs;for(let e=0;e<c.colspan;e++){const o=n[(r+e)%t.width*2];null==o||c.colwidth&&c.colwidth[e]==o||((s||(s=D(c)))[e]=o)}s&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:s})}}(s,l,t);return s}(t))}};function D(t){if(t.colwidth)return t.colwidth.slice();const n=[];for(let e=0;e<t.colspan;e++)n.push(0);return n}function S(t,n){if("string"==typeof t)return{};const e=t.getAttribute("data-colwidth"),o=e&&/^\d+(,\d+)*$/.test(e)?e.split(",").map((t=>Number(t))):null,r=Number(t.getAttribute("colspan")||1),i={colspan:r,rowspan:Number(t.getAttribute("rowspan")||1),colwidth:o&&o.length==r?o:null};for(const e in n){const o=n[e].getFromDOM,r=o&&o(t);null!=r&&(i[e]=r)}return i}function $(t,n){const e={};1!=t.attrs.colspan&&(e.colspan=t.attrs.colspan),1!=t.attrs.rowspan&&(e.rowspan=t.attrs.rowspan),t.attrs.colwidth&&(e["data-colwidth"]=t.attrs.colwidth.join(","));for(const o in n){const r=n[o].setDOMAttr;r&&r(t.attrs[o],e)}return e}function E(t){if(null!==t){if(!Array.isArray(t))throw new TypeError("colwidth must be null or an array");for(const n of t)if("number"!=typeof n)throw new TypeError("colwidth must be null or an array of numbers")}}function R(t){const n=t.cellAttributes||{},e={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:E}};for(const t in n)e[t]={default:n[t].default,validate:n[t].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:t.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:{content:t.cellContent,attrs:e,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:t=>S(t,n)}],toDOM:t=>["td",$(t,n),0]},table_header:{content:t.cellContent,attrs:e,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:t=>S(t,n)}],toDOM:t=>["th",$(t,n),0]}}}function _(t){let n=t.cached.tableNodeTypes;if(!n){n=t.cached.tableNodeTypes={};for(const e in t.nodes){const o=t.nodes[e],r=o.spec.tableRole;r&&(n[r]=o)}}return n}const N=new n("selectingCells");function z(t){for(let n=t.depth-1;n>0;n--)if("row"==t.node(n).type.spec.tableRole)return t.node(0).resolve(t.before(n+1));return null}function k(t){const n=t.selection.$head;for(let t=n.depth;t>0;t--)if("row"==n.node(t).type.spec.tableRole)return!0;return!1}function A(t){const n=t.selection;if("$anchorCell"in n&&n.$anchorCell)return n.$anchorCell.pos>n.$headCell.pos?n.$anchorCell:n.$headCell;if("node"in n&&n.node&&"cell"==n.node.type.spec.tableRole)return n.$anchor;const e=z(n.$head)||function(t){for(let n=t.nodeAfter,e=t.pos;n;n=n.firstChild,e++){const o=n.type.spec.tableRole;if("cell"==o||"header_cell"==o)return t.doc.resolve(e)}for(let n=t.nodeBefore,e=t.pos;n;n=n.lastChild,e--){const o=n.type.spec.tableRole;if("cell"==o||"header_cell"==o)return t.doc.resolve(e-n.nodeSize)}}(n.$head);if(e)return e;throw new RangeError(`No cell found around position ${n.head}`)}function C(t){return"row"==t.parent.type.spec.tableRole&&!!t.nodeAfter}function O(t,n){return t.depth==n.depth&&t.pos>=n.start(-1)&&t.pos<=n.end(-1)}function T(t,n,e){const o=t.node(-1),r=y.get(o),i=t.start(-1),l=r.nextCell(t.pos-i,n,e);return null==l?null:t.node(0).resolve(i+l)}function x(t,n,e=1){const o={...t,colspan:t.colspan-e};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(n,e),o.colwidth.some((t=>t>0))||(o.colwidth=null)),o}function W(t,n,e=1){const o={...t,colspan:t.colspan+e};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let t=0;t<e;t++)o.colwidth.splice(n,0,0)}return o}var L=class t extends e{constructor(t,n=t){const e=t.node(-1),r=y.get(e),i=t.start(-1),l=r.rectBetween(t.pos-i,n.pos-i),s=t.node(0),c=r.cellsInRect(l).filter((t=>t!=n.pos-i));c.unshift(n.pos-i);const f=c.map((t=>{const n=e.nodeAt(t);if(!n)throw new RangeError(`No cell with offset ${t} found`);const r=i+t+1;return new o(s.resolve(r),s.resolve(r+n.content.size))}));super(f[0].$from,f[0].$to,f),this.$anchorCell=t,this.$headCell=n}map(n,e){const o=n.resolve(e.map(this.$anchorCell.pos)),i=n.resolve(e.map(this.$headCell.pos));if(C(o)&&C(i)&&O(o,i)){const n=this.$anchorCell.node(-1)!=o.node(-1);return n&&this.isRowSelection()?t.rowSelection(o,i):n&&this.isColSelection()?t.colSelection(o,i):new t(o,i)}return r.between(o,i)}content(){const t=this.$anchorCell.node(-1),n=y.get(t),e=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-e,this.$headCell.pos-e),r={},s=[];for(let e=o.top;e<o.bottom;e++){const l=[];for(let i=e*n.width+o.left,s=o.left;s<o.right;s++,i++){const e=n.map[i];if(r[e])continue;r[e]=!0;const s=n.findCell(e);let c=t.nodeAt(e);if(!c)throw new RangeError(`No cell with offset ${e} found`);const f=o.left-s.left,u=s.right-o.right;if(f>0||u>0){let t=c.attrs;if(f>0&&(t=x(t,0,f)),u>0&&(t=x(t,t.colspan-u,u)),s.left<o.left){if(c=c.type.createAndFill(t),!c)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}else c=c.type.create(t,c.content)}if(s.top<o.top||s.bottom>o.bottom){const t={...c.attrs,rowspan:Math.min(s.bottom,o.bottom)-Math.max(s.top,o.top)};c=s.top<o.top?c.type.createAndFill(t):c.type.create(t,c.content)}l.push(c)}s.push(t.child(e).copy(i.from(l)))}const c=this.isColSelection()&&this.isRowSelection()?t:s;return new l(i.from(c),1,1)}replace(t,n=l.empty){const o=t.steps.length,r=this.ranges;for(let e=0;e<r.length;e++){const{$from:i,$to:s}=r[e],c=t.mapping.slice(o);t.replace(c.map(i.pos),c.map(s.pos),e?l.empty:n)}const i=e.findFrom(t.doc.resolve(t.mapping.slice(o).map(this.to)),-1);i&&t.setSelection(i)}replaceWith(t,n){this.replace(t,new l(i.from(n),0,0))}forEachCell(t){const n=this.$anchorCell.node(-1),e=y.get(n),o=this.$anchorCell.start(-1),r=e.cellsInRect(e.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let e=0;e<r.length;e++)t(n.nodeAt(r[e]),o+r[e])}isColSelection(){const t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;const e=t+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(e,o)==this.$headCell.node(-1).childCount}static colSelection(n,e=n){const o=n.node(-1),r=y.get(o),i=n.start(-1),l=r.findCell(n.pos-i),s=r.findCell(e.pos-i),c=n.node(0);return l.top<=s.top?(l.top>0&&(n=c.resolve(i+r.map[l.left])),s.bottom<r.height&&(e=c.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))):(s.top>0&&(e=c.resolve(i+r.map[s.left])),l.bottom<r.height&&(n=c.resolve(i+r.map[r.width*(r.height-1)+l.right-1]))),new t(n,e)}isRowSelection(){const t=this.$anchorCell.node(-1),n=y.get(t),e=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-e),r=n.colCount(this.$headCell.pos-e);if(Math.min(o,r)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,l=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==n.width}eq(n){return n instanceof t&&n.$anchorCell.pos==this.$anchorCell.pos&&n.$headCell.pos==this.$headCell.pos}static rowSelection(n,e=n){const o=n.node(-1),r=y.get(o),i=n.start(-1),l=r.findCell(n.pos-i),s=r.findCell(e.pos-i),c=n.node(0);return l.left<=s.left?(l.left>0&&(n=c.resolve(i+r.map[l.top*r.width])),s.right<r.width&&(e=c.resolve(i+r.map[r.width*(s.top+1)-1]))):(s.left>0&&(e=c.resolve(i+r.map[s.top*r.width])),l.right<r.width&&(n=c.resolve(i+r.map[r.width*(l.top+1)-1]))),new t(n,e)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(n,e){return new t(n.resolve(e.anchor),n.resolve(e.head))}static create(n,e,o=e){return new t(n.resolve(e),n.resolve(o))}getBookmark(){return new B(this.$anchorCell.pos,this.$headCell.pos)}};L.prototype.visible=!1,e.jsonID("cell",L);var B=class t{constructor(t,n){this.anchor=t,this.head=n}map(n){return new t(n.map(this.anchor),n.map(this.head))}resolve(t){const n=t.resolve(this.anchor),o=t.resolve(this.head);return"row"==n.parent.type.spec.tableRole&&"row"==o.parent.type.spec.tableRole&&n.index()<n.parent.childCount&&o.index()<o.parent.childCount&&O(n,o)?new L(n,o):e.near(o,1)}};function j(t){if(!(t.selection instanceof L))return null;const n=[];return t.selection.forEachCell(((t,e)=>{n.push(u.node(e,e+t.nodeSize,{class:"selectedCell"}))})),f.create(t.doc,n)}const P=new n("fix-tables");function H(t,n,e,o){const r=t.childCount,i=n.childCount;t:for(let l=0,s=0;l<i;l++){const i=n.child(l);for(let n=s,o=Math.min(r,l+3);n<o;n++)if(t.child(n)==i){s=n+1,e+=i.nodeSize;continue t}o(i,e),s<r&&t.child(s).sameMarkup(i)?H(t.child(s),i,e+1,o):i.nodesBetween(0,i.content.size,o,e+1),e+=i.nodeSize}}function J(t,n){let e;const o=(n,o)=>{"table"==n.type.spec.tableRole&&(e=function(t,n,e,o){const r=y.get(n);if(!r.problems)return o;o||(o=t.tr);const i=[];for(let t=0;t<r.height;t++)i.push(0);for(let t=0;t<r.problems.length;t++){const l=r.problems[t];if("collision"==l.type){const t=n.nodeAt(l.pos);if(!t)continue;const r=t.attrs;for(let t=0;t<r.rowspan;t++)i[l.row+t]+=l.n;o.setNodeMarkup(o.mapping.map(e+1+l.pos),null,x(r,r.colspan-l.n,l.n))}else if("missing"==l.type)i[l.row]+=l.n;else if("overlong_rowspan"==l.type){const t=n.nodeAt(l.pos);if(!t)continue;o.setNodeMarkup(o.mapping.map(e+1+l.pos),null,{...t.attrs,rowspan:t.attrs.rowspan-l.n})}else if("colwidth mismatch"==l.type){const t=n.nodeAt(l.pos);if(!t)continue;o.setNodeMarkup(o.mapping.map(e+1+l.pos),null,{...t.attrs,colwidth:l.colwidth})}else if("zero_sized"==l.type){const t=o.mapping.map(e);o.delete(t,t+n.nodeSize)}}let l,s;for(let t=0;t<i.length;t++)i[t]&&(null==l&&(l=t),s=t);for(let c=0,f=e+1;c<r.height;c++){const e=n.child(c),r=f+e.nodeSize,u=i[c];if(u>0){let n="cell";e.firstChild&&(n=e.firstChild.type.spec.tableRole);const i=[];for(let e=0;e<u;e++){const e=_(t.schema)[n].createAndFill();e&&i.push(e)}const a=0!=c&&l!=c-1||s!=c?r-1:f+1;o.insert(o.mapping.map(a),i)}f=r}return o.setMeta(P,{fixTables:!0})}(t,n,o,e))};return n?n.doc!=t.doc&&H(n.doc,t.doc,0,o):t.doc.descendants(o),e}function U(t){const n=t.selection,e=A(t),o=e.node(-1),r=e.start(-1),i=y.get(o);return{...n instanceof L?i.rectBetween(n.$anchorCell.pos-r,n.$headCell.pos-r):i.findCell(e.pos-r),tableStart:r,map:i,table:o}}function K(t,{map:n,tableStart:e,table:o},r){let i=r>0?-1:0;(function(t,n,e){const o=_(n.type.schema).header_cell;for(let r=0;r<t.height;r++)if(n.nodeAt(t.map[e+r*t.width]).type!=o)return!1;return!0})(n,o,r+i)&&(i=0==r||r==n.width?null:0);for(let l=0;l<n.height;l++){const s=l*n.width+r;if(r>0&&r<n.width&&n.map[s-1]==n.map[s]){const i=n.map[s],c=o.nodeAt(i);t.setNodeMarkup(t.mapping.map(e+i),null,W(c.attrs,r-n.colCount(i))),l+=c.attrs.rowspan-1}else{const c=null==i?_(o.type.schema).cell:o.nodeAt(n.map[s+i]).type,f=n.positionAt(l,r,o);t.insert(t.mapping.map(e+f),c.createAndFill())}}return t}function V(t,n){if(!k(t))return!1;if(n){const e=U(t);n(K(t.tr,e,e.left))}return!0}function q(t,n){if(!k(t))return!1;if(n){const e=U(t);n(K(t.tr,e,e.right))}return!0}function F(t,{map:n,table:e,tableStart:o},r){const i=t.mapping.maps.length;for(let l=0;l<n.height;){const s=l*n.width+r,c=n.map[s],f=e.nodeAt(c),u=f.attrs;if(r>0&&n.map[s-1]==c||r<n.width-1&&n.map[s+1]==c)t.setNodeMarkup(t.mapping.slice(i).map(o+c),null,x(u,r-n.colCount(c)));else{const n=t.mapping.slice(i).map(o+c);t.delete(n,n+f.nodeSize)}l+=u.rowspan}}function I(t,n){if(!k(t))return!1;if(n){const e=U(t),o=t.tr;if(0==e.left&&e.right==e.map.width)return!1;for(let t=e.right-1;F(o,e,t),t!=e.left;t--){const t=e.tableStart?o.doc.nodeAt(e.tableStart-1):o.doc;if(!t)throw new RangeError("No table found");e.table=t,e.map=y.get(t)}n(o)}return!0}function X(t,{map:n,tableStart:e,table:o},r){let i=e;for(let t=0;t<r;t++)i+=o.child(t).nodeSize;const l=[];let s=r>0?-1:0;(function(t,n,e){var o;const r=_(n.type.schema).header_cell;for(let i=0;i<t.width;i++)if((null===(o=n.nodeAt(t.map[i+e*t.width]))||void 0===o?void 0:o.type)!=r)return!1;return!0})(n,o,r+s)&&(s=0==r||r==n.height?null:0);for(let i=0,f=n.width*r;i<n.width;i++,f++)if(r>0&&r<n.height&&n.map[f]==n.map[f-n.width]){const r=n.map[f],l=o.nodeAt(r).attrs;t.setNodeMarkup(e+r,null,{...l,rowspan:l.rowspan+1}),i+=l.colspan-1}else{var c;const t=null==s?_(o.type.schema).cell:null===(c=o.nodeAt(n.map[f+s*n.width]))||void 0===c?void 0:c.type,e=null==t?void 0:t.createAndFill();e&&l.push(e)}return t.insert(i,_(o.type.schema).row.create(null,l)),t}function G(t,n){if(!k(t))return!1;if(n){const e=U(t);n(X(t.tr,e,e.top))}return!0}function Q(t,n){if(!k(t))return!1;if(n){const e=U(t);n(X(t.tr,e,e.bottom))}return!0}function Y(t,{map:n,table:e,tableStart:o},r){let i=0;for(let t=0;t<r;t++)i+=e.child(t).nodeSize;const l=i+e.child(r).nodeSize,s=t.mapping.maps.length;t.delete(i+o,l+o);const c=new Set;for(let i=0,l=r*n.width;i<n.width;i++,l++){const f=n.map[l];if(!c.has(f))if(c.add(f),r>0&&f==n.map[l-n.width]){const n=e.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(s).map(f+o),null,{...n,rowspan:n.rowspan-1}),i+=n.colspan-1}else if(r<n.height&&f==n.map[l+n.width]){const l=e.nodeAt(f),c=l.attrs,u=l.type.create({...c,rowspan:l.attrs.rowspan-1},l.content),a=n.positionAt(r+1,i,e);t.insert(t.mapping.slice(s).map(o+a),u),i+=c.colspan-1}}}function Z(t,n){if(!k(t))return!1;if(n){const e=U(t),o=t.tr;if(0==e.top&&e.bottom==e.map.height)return!1;for(let t=e.bottom-1;Y(o,e,t),t!=e.top;t--){const t=e.tableStart?o.doc.nodeAt(e.tableStart-1):o.doc;if(!t)throw new RangeError("No table found");e.table=t,e.map=y.get(e.table)}n(o)}return!0}function tt(t){const n=t.content;return 1==n.childCount&&n.child(0).isTextblock&&0==n.child(0).childCount}function nt(t,n){const e=t.selection;if(!(e instanceof L)||e.$anchorCell.pos==e.$headCell.pos)return!1;const o=U(t),{map:r}=o;if(function({width:t,height:n,map:e},o){let r=o.top*t+o.left,i=r,l=(o.bottom-1)*t+o.left,s=r+(o.right-o.left-1);for(let n=o.top;n<o.bottom;n++){if(o.left>0&&e[i]==e[i-1]||o.right<t&&e[s]==e[s+1])return!0;i+=t,s+=t}for(let i=o.left;i<o.right;i++){if(o.top>0&&e[r]==e[r-t]||o.bottom<n&&e[l]==e[l+t])return!0;r++,l++}return!1}(r,o))return!1;if(n){const e=t.tr,l={};let s,c,f=i.empty;for(let t=o.top;t<o.bottom;t++)for(let n=o.left;n<o.right;n++){const i=r.map[t*r.width+n],u=o.table.nodeAt(i);if(!l[i]&&u)if(l[i]=!0,null==s)s=i,c=u;else{tt(u)||(f=f.append(u.content));const t=e.mapping.map(i+o.tableStart);e.delete(t,t+u.nodeSize)}}if(null==s||null==c)return!0;if(e.setNodeMarkup(s+o.tableStart,null,{...W(c.attrs,c.attrs.colspan,o.right-o.left-c.attrs.colspan),rowspan:o.bottom-o.top}),f.size>0){const t=s+1+c.content.size,n=tt(c)?s+1:t;e.replaceWith(n+o.tableStart,t+o.tableStart,f)}e.setSelection(new L(e.doc.resolve(s+o.tableStart))),n(e)}return!0}function et(t,n){const e=_(t.schema);return(o=({node:t})=>e[t.type.spec.tableRole],(t,n)=>{const e=t.selection;let r,i;if(e instanceof L){if(e.$anchorCell.pos!=e.$headCell.pos)return!1;r=e.$anchorCell.nodeAfter,i=e.$anchorCell.pos}else{var l;if(r=function(t){for(let n=t.depth;n>0;n--){const e=t.node(n).type.spec.tableRole;if("cell"===e||"header_cell"===e)return t.node(n)}return null}(e.$from),!r)return!1;i=null===(l=z(e.$from))||void 0===l?void 0:l.pos}if(null==r||null==i)return!1;if(1==r.attrs.colspan&&1==r.attrs.rowspan)return!1;if(n){let l=r.attrs;const s=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const f=U(t),u=t.tr;for(let t=0;t<f.right-f.left;t++)s.push(c?{...l,colwidth:c&&c[t]?[c[t]]:null}:l);let a;for(let t=f.top;t<f.bottom;t++){let n=f.map.positionAt(t,f.left,f.table);t==f.top&&(n+=r.nodeSize);for(let e=f.left,i=0;e<f.right;e++,i++)e==f.left&&t==f.top||u.insert(a=u.mapping.map(n+f.tableStart,1),o({node:r,row:t,col:e}).createAndFill(s[i]))}u.setNodeMarkup(i,o({node:r,row:f.top,col:f.left}),s[0]),e instanceof L&&u.setSelection(new L(u.doc.resolve(e.$anchorCell.pos),a?u.doc.resolve(a):void 0)),n(u)}return!0})(t,n);var o}function ot(t,n,e){const o=n.map.cellsInRect({left:0,top:0,right:"row"==t?n.map.width:1,bottom:"column"==t?n.map.height:1});for(let t=0;t<o.length;t++){const r=n.table.nodeAt(o[t]);if(r&&r.type!==e.header_cell)return!1}return!0}function rt(t,n){return(n=n||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(t){return function(n,e){if(!k(n))return!1;if(e){const o=_(n.schema),r=U(n),i=n.tr,l=r.map.cellsInRect("column"==t?{left:r.left,top:0,right:r.right,bottom:r.map.height}:"row"==t?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),s=l.map((t=>r.table.nodeAt(t)));for(let t=0;t<l.length;t++)s[t].type==o.header_cell&&i.setNodeMarkup(r.tableStart+l[t],o.cell,s[t].attrs);if(0===i.steps.length)for(let t=0;t<l.length;t++)i.setNodeMarkup(r.tableStart+l[t],o.header_cell,s[t].attrs);e(i)}return!0}}(t):function(n,e){if(!k(n))return!1;if(e){const o=_(n.schema),r=U(n),i=n.tr,l=ot("row",r,o),s=ot("column",r,o),c=("column"===t?l:"row"===t&&s)?1:0,f="column"==t?{left:0,top:c,right:1,bottom:r.map.height}:"row"==t?{left:c,top:0,right:r.map.width,bottom:1}:r,u="column"==t?s?o.cell:o.header_cell:"row"==t?l?o.cell:o.header_cell:o.cell;r.map.cellsInRect(f).forEach((t=>{const n=t+r.tableStart,e=i.doc.nodeAt(n);e&&i.setNodeMarkup(n,u,e.attrs)})),e(i)}return!0}}const it=rt("row",{useDeprecatedLogic:!0});function lt(t,n){const e=t.selection.$anchor;for(let o=e.depth;o>0;o--)if("table"==e.node(o).type.spec.tableRole)return n&&n(t.tr.delete(e.before(o),e.after(o)).scrollIntoView()),!0;return!1}function st(t,n){const e=t.selection;if(!(e instanceof L))return!1;if(n){const o=t.tr,r=_(t.schema).cell.createAndFill().content;e.forEachCell(((t,n)=>{t.content.eq(r)||o.replace(o.mapping.map(n+1),o.mapping.map(n+t.nodeSize-1),new l(r,0,0))})),o.docChanged&&n(o)}return!0}function ct(t){if(0===t.size)return null;let{content:n,openStart:e,openEnd:o}=t;for(;1==n.childCount&&(e>0&&o>0||"table"==n.child(0).type.spec.tableRole);)e--,o--,n=n.child(0).content;const r=n.child(0),s=r.type.spec.tableRole,c=r.type.schema,f=[];if("row"==s)for(let t=0;t<n.childCount;t++){let r=n.child(t).content;const i=t?0:Math.max(0,e-1),s=t<n.childCount-1?0:Math.max(0,o-1);(i||s)&&(r=ft(_(c).row,new l(r,i,s)).content),f.push(r)}else{if("cell"!=s&&"header_cell"!=s)return null;f.push(e||o?ft(_(c).row,new l(n,e,o)).content:n)}return function(t,n){const e=[];for(let t=0;t<n.length;t++){const o=n[t];for(let n=o.childCount-1;n>=0;n--){const{rowspan:r,colspan:i}=o.child(n).attrs;for(let n=t;n<t+r;n++)e[n]=(e[n]||0)+i}}let o=0;for(let t=0;t<e.length;t++)o=Math.max(o,e[t]);for(let r=0;r<e.length;r++)if(r>=n.length&&n.push(i.empty),e[r]<o){const l=_(t).cell.createAndFill(),s=[];for(let t=e[r];t<o;t++)s.push(l);n[r]=n[r].append(i.from(s))}return{height:n.length,width:o,rows:n}}(c,f)}function ft(t,n){const e=t.createAndFill();return new c(e).replace(0,e.content.size,n).doc}function ut(t,n,e,o,r,i,l,s){if(0==l||l==n.height)return!1;let c=!1;for(let f=r;f<i;f++){const r=l*n.width+f,i=n.map[r];if(n.map[r-n.width]==i){c=!0;const r=e.nodeAt(i),{top:u,left:a}=n.findCell(i);t.setNodeMarkup(t.mapping.slice(s).map(i+o),null,{...r.attrs,rowspan:l-u}),t.insert(t.mapping.slice(s).map(n.positionAt(l,a,e)),r.type.createAndFill({...r.attrs,rowspan:u+r.attrs.rowspan-l})),f+=r.attrs.colspan-1}}return c}function at(t,n,e,o,r,i,l,s){if(0==l||l==n.width)return!1;let c=!1;for(let f=r;f<i;f++){const r=f*n.width+l,i=n.map[r];if(n.map[r-1]==i){c=!0;const r=e.nodeAt(i),u=n.colCount(i),a=t.mapping.slice(s).map(i+o);t.setNodeMarkup(a,null,x(r.attrs,l-u,r.attrs.colspan-(l-u))),t.insert(a+r.nodeSize,r.type.createAndFill(x(r.attrs,0,l-u))),f+=r.attrs.rowspan-1}}return c}function ht(t,n,e,o,r){let s=e?t.doc.nodeAt(e-1):t.doc;if(!s)throw new Error("No table found");let c=y.get(s);const{top:f,left:u}=o,a=u+r.width,h=f+r.height,w=t.tr;let d=0;function p(){if(s=e?w.doc.nodeAt(e-1):w.doc,!s)throw new Error("No table found");c=y.get(s),d=w.mapping.maps.length}(function(t,n,e,o,r,l,s){const c=_(t.doc.type.schema);let f,u;if(r>n.width)for(let i=0,l=0;i<n.height;i++){const a=e.child(i);l+=a.nodeSize;const h=[];let w;w=null==a.lastChild||a.lastChild.type==c.cell?f||(f=c.cell.createAndFill()):u||(u=c.header_cell.createAndFill());for(let t=n.width;t<r;t++)h.push(w);t.insert(t.mapping.slice(s).map(l-1+o),h)}if(l>n.height){const a=[];for(let t=0,o=(n.height-1)*n.width;t<Math.max(n.width,r);t++){const r=!(t>=n.width)&&e.nodeAt(n.map[o+t]).type==c.header_cell;a.push(r?u||(u=c.header_cell.createAndFill()):f||(f=c.cell.createAndFill()))}const h=c.row.create(null,i.from(a)),w=[];for(let t=n.height;t<l;t++)w.push(h);t.insert(t.mapping.slice(s).map(o+e.nodeSize-2),w)}return!(!f&&!u)})(w,c,s,e,a,h,d)&&p(),ut(w,c,s,e,u,a,f,d)&&p(),ut(w,c,s,e,u,a,h,d)&&p(),at(w,c,s,e,f,h,u,d)&&p(),at(w,c,s,e,f,h,a,d)&&p();for(let t=f;t<h;t++){const n=c.positionAt(t,u,s),o=c.positionAt(t,a,s);w.replace(w.mapping.slice(d).map(n+e),w.mapping.slice(d).map(o+e),new l(r.rows[t-f],0,0))}p(),w.setSelection(new L(w.doc.resolve(e+c.positionAt(f,u,s)),w.doc.resolve(e+c.positionAt(h-1,a-1,s)))),n(w)}rt("column",{useDeprecatedLogic:!0}),rt("cell",{useDeprecatedLogic:!0});const wt=b({ArrowLeft:pt("horiz",-1),ArrowRight:pt("horiz",1),ArrowUp:pt("vert",-1),ArrowDown:pt("vert",1),"Shift-ArrowLeft":mt("horiz",-1),"Shift-ArrowRight":mt("horiz",1),"Shift-ArrowUp":mt("vert",-1),"Shift-ArrowDown":mt("vert",1),Backspace:st,"Mod-Backspace":st,Delete:st,"Mod-Delete":st});function dt(t,n,e){return!e.eq(t.selection)&&(n&&n(t.tr.setSelection(e).scrollIntoView()),!0)}function pt(t,n){return(o,r,i)=>{if(!i)return!1;const l=o.selection;if(l instanceof L)return dt(o,r,e.near(l.$headCell,n));if("horiz"!=t&&!l.empty)return!1;const s=Mt(i,t,n);if(null==s)return!1;if("horiz"==t)return dt(o,r,e.near(o.doc.resolve(l.head+n),n));{const i=o.doc.resolve(s),l=T(i,t,n);let c;return c=l?e.near(l,1):n<0?e.near(o.doc.resolve(i.before(-1)),-1):e.near(o.doc.resolve(i.after(-1)),1),dt(o,r,c)}}}function mt(t,n){return(e,o,r)=>{if(!r)return!1;const i=e.selection;let l;if(i instanceof L)l=i;else{const o=Mt(r,t,n);if(null==o)return!1;l=new L(e.doc.resolve(o))}const s=T(l.$headCell,t,n);return!!s&&dt(e,o,new L(l.$anchorCell,s))}}function gt(t,n){const e=z(t.state.doc.resolve(n));return!!e&&(t.dispatch(t.state.tr.setSelection(new L(e))),!0)}function bt(t,n,e){if(!k(t.state))return!1;let o=ct(e);const r=t.state.selection;if(r instanceof L){o||(o={width:1,height:1,rows:[i.from(ft(_(t.state.schema).cell,e))]});const n=r.$anchorCell.node(-1),l=r.$anchorCell.start(-1),s=y.get(n).rectBetween(r.$anchorCell.pos-l,r.$headCell.pos-l);return o=function({width:t,height:n,rows:e},o,r){if(t!=o){const n=[],r=[];for(let t=0;t<e.length;t++){const l=e[t],s=[];for(let e=n[t]||0,r=0;e<o;r++){let i=l.child(r%l.childCount);e+i.attrs.colspan>o&&(i=i.type.createChecked(x(i.attrs,i.attrs.colspan,e+i.attrs.colspan-o),i.content)),s.push(i),e+=i.attrs.colspan;for(let e=1;e<i.attrs.rowspan;e++)n[t+e]=(n[t+e]||0)+i.attrs.colspan}r.push(i.from(s))}e=r,t=o}if(n!=r){const t=[];for(let o=0,l=0;o<r;o++,l++){const s=[],c=e[l%n];for(let t=0;t<c.childCount;t++){let n=c.child(t);o+n.attrs.rowspan>r&&(n=n.type.create({...n.attrs,rowspan:Math.max(1,r-n.attrs.rowspan)},n.content)),s.push(n)}t.push(i.from(s))}e=t,n=r}return{width:t,height:n,rows:e}}(o,s.right-s.left,s.bottom-s.top),ht(t.state,t.dispatch,l,s,o),!0}if(o){const n=A(t.state),e=n.start(-1);return ht(t.state,t.dispatch,e,y.get(n.node(-1)).findCell(n.pos-e),o),!0}return!1}function vt(t,n){var e;if(0!=n.button)return;if(n.ctrlKey||n.metaKey)return;const o=yt(t,n.target);let r;if(n.shiftKey&&t.state.selection instanceof L)i(t.state.selection.$anchorCell,n),n.preventDefault();else if(n.shiftKey&&o&&null!=(r=z(t.state.selection.$anchor))&&(null===(e=Dt(t,n))||void 0===e?void 0:e.pos)!=r.pos)i(r,n),n.preventDefault();else if(!o)return;function i(n,e){let o=Dt(t,e);const r=null==N.getState(t.state);if(!o||!O(n,o)){if(!r)return;o=n}const i=new L(n,o);if(r||!t.state.selection.eq(i)){const e=t.state.tr.setSelection(i);r&&e.setMeta(N,n.pos),t.dispatch(e)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",s),null!=N.getState(t.state)&&t.dispatch(t.state.tr.setMeta(N,-1))}function s(e){const r=e,s=N.getState(t.state);let c;if(null!=s)c=t.state.doc.resolve(s);else if(yt(t,r.target)!=o&&(c=Dt(t,n),!c))return l();c&&i(c,r)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",s)}function Mt(t,n,e){if(!(t.state.selection instanceof r))return null;const{$head:o}=t.state.selection;for(let r=o.depth-1;r>=0;r--){const i=o.node(r);if((e<0?o.index(r):o.indexAfter(r))!=(e<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=o.before(r),l="vert"==n?e>0?"down":"up":e>0?"right":"left";return t.endOfTextblock(l)?i:null}}return null}function yt(t,n){for(;n&&n!=t.dom;n=n.parentNode)if("TD"==n.nodeName||"TH"==n.nodeName)return n;return null}function Dt(t,n){const e=t.posAtCoords({left:n.clientX,top:n.clientY});if(!e)return null;let{inside:o,pos:r}=e;return o>=0&&z(t.state.doc.resolve(o))||z(t.state.doc.resolve(r))}var St=class{constructor(t,n){this.node=t,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),$t(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type==this.node.type&&(this.node=t,$t(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return"attributes"==t.type&&(t.target==this.table||this.colgroup.contains(t.target))}};function $t(t,n,e,o,r,i){let l=0,s=!0,c=n.firstChild;const f=t.firstChild;if(f){for(let t=0,e=0;t<f.childCount;t++){const{colspan:u,colwidth:a}=f.child(t).attrs;for(let t=0;t<u;t++,e++){const f=r==e?i:a&&a[t],u=f?f+"px":"";if(l+=f||o,f||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{const t=document.createElement("col");t.style.width=u,n.appendChild(t)}}}for(;c;){var u;const t=c.nextSibling;null===(u=c.parentNode)||void 0===u||u.removeChild(c),c=t}s?(e.style.width=l+"px",e.style.minWidth=""):(e.style.width="",e.style.minWidth=l+"px")}}const Et=new n("tableColumnResizing");function Rt({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:o=100,View:r=St,lastColumnResizable:i=!0}={}){const l=new t({key:Et,state:{init(t,n){var e;const i=null===(e=l.spec)||void 0===e||null===(e=e.props)||void 0===e?void 0:e.nodeViews,s=_(n.schema).table.name;return r&&i&&(i[s]=(t,n)=>new r(t,o,n)),new _t(-1,!1)},apply:(t,n)=>n.apply(t)},props:{attributes:t=>{const n=Et.getState(t);return n&&n.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,e)=>{!function(t,n,e,o){if(!t.editable)return;const r=Et.getState(t.state);if(!r)return;if(!r.dragging){const i=function(t){for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}(n.target);let l=-1;if(i){const{left:o,right:r}=i.getBoundingClientRect();n.clientX-o<=e?l=Nt(t,n,"left",e):r-n.clientX<=e&&(l=Nt(t,n,"right",e))}if(l!=r.activeHandle){if(!o&&-1!==l){const n=t.state.doc.resolve(l),e=n.node(-1),o=y.get(e),r=n.start(-1);if(o.colCount(n.pos-r)+n.nodeAfter.attrs.colspan-1==o.width-1)return}kt(t,l)}}}(t,e,n,i)},mouseleave:t=>{!function(t){if(!t.editable)return;const n=Et.getState(t.state);n&&n.activeHandle>-1&&!n.dragging&&kt(t,-1)}(t)},mousedown:(t,n)=>{!function(t,n,e,o){var r;if(!t.editable)return!1;const i=null!==(r=t.dom.ownerDocument.defaultView)&&void 0!==r?r:window,l=Et.getState(t.state);if(!l||-1==l.activeHandle||l.dragging)return!1;const s=t.state.doc.nodeAt(l.activeHandle),c=function(t,n,{colspan:e,colwidth:o}){const r=o&&o[o.length-1];if(r)return r;const i=t.domAtPos(n);let l=i.node.childNodes[i.offset].offsetWidth,s=e;if(o)for(let t=0;t<e;t++)o[t]&&(l-=o[t],s--);return l/s}(t,l.activeHandle,s.attrs);function f(n){i.removeEventListener("mouseup",f),i.removeEventListener("mousemove",u);const o=Et.getState(t.state);(null==o?void 0:o.dragging)&&(!function(t,n,e){const o=t.state.doc.resolve(n),r=o.node(-1),i=y.get(r),l=o.start(-1),s=i.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1,c=t.state.tr;for(let t=0;t<i.height;t++){const n=t*i.width+s;if(t&&i.map[n]==i.map[n-i.width])continue;const o=i.map[n],f=r.nodeAt(o).attrs,u=1==f.colspan?0:s-i.colCount(o);if(f.colwidth&&f.colwidth[u]==e)continue;const a=f.colwidth?f.colwidth.slice():Ct(f.colspan);a[u]=e,c.setNodeMarkup(l+o,null,{...f,colwidth:a})}c.docChanged&&t.dispatch(c)}(t,o.activeHandle,zt(o.dragging,n,e)),t.dispatch(t.state.tr.setMeta(Et,{setDragging:null})))}function u(n){if(!n.which)return f(n);const r=Et.getState(t.state);if(r&&r.dragging){const i=zt(r.dragging,n,e);At(t,r.activeHandle,i,o)}}t.dispatch(t.state.tr.setMeta(Et,{setDragging:{startX:n.clientX,startWidth:c}})),At(t,l.activeHandle,c,o),i.addEventListener("mouseup",f),i.addEventListener("mousemove",u),n.preventDefault()}(t,n,e,o)}},decorations:t=>{const n=Et.getState(t);if(n&&n.activeHandle>-1)return function(t,n){const e=[],o=t.doc.resolve(n),r=o.node(-1);if(!r)return f.empty;const i=y.get(r),l=o.start(-1),s=i.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let n=0;n<i.height;n++){const o=s+n*i.width;if(!(s!=i.width-1&&i.map[o]==i.map[o+1]||0!=n&&i.map[o]==i.map[o-i.width])){var c;const n=i.map[o],s=l+n+r.nodeAt(n).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(null===(c=Et.getState(t))||void 0===c?void 0:c.dragging)&&e.push(u.node(l+n,l+n+r.nodeAt(n).nodeSize,{class:"column-resize-dragging"})),e.push(u.widget(s,f))}}return f.create(t.doc,e)}(t,n.activeHandle)},nodeViews:{}}});return l}var _t=class t{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(n){const e=this,o=n.getMeta(Et);if(o&&null!=o.setHandle)return new t(o.setHandle,!1);if(o&&void 0!==o.setDragging)return new t(e.activeHandle,o.setDragging);if(e.activeHandle>-1&&n.docChanged){let o=n.mapping.map(e.activeHandle,-1);return C(n.doc.resolve(o))||(o=-1),new t(o,e.dragging)}return e}};function Nt(t,n,e,o){const r="right"==e?-o:o,i=t.posAtCoords({left:n.clientX+r,top:n.clientY});if(!i)return-1;const{pos:l}=i,s=z(t.state.doc.resolve(l));if(!s)return-1;if("right"==e)return s.pos;const c=y.get(s.node(-1)),f=s.start(-1),u=c.map.indexOf(s.pos-f);return u%c.width==0?-1:f+c.map[u-1]}function zt(t,n,e){const o=n.clientX-t.startX;return Math.max(e,t.startWidth+o)}function kt(t,n){t.dispatch(t.state.tr.setMeta(Et,{setHandle:n}))}function At(t,n,e,o){const r=t.state.doc.resolve(n),i=r.node(-1),l=r.start(-1),s=y.get(i).colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;let c=t.domAtPos(r.start(-1)).node;for(;c&&"TABLE"!=c.nodeName;)c=c.parentNode;c&&$t(i,c.firstChild,c,o,s,e)}function Ct(t){return Array(t).fill(0)}function Ot({allowTableNodeSelection:n=!1}={}){return new t({key:N,state:{init:()=>null,apply(t,n){const e=t.getMeta(N);if(null!=e)return-1==e?null:e;if(null==n||!t.docChanged)return n;const{deleted:o,pos:r}=t.mapping.mapResult(n);return o?null:r}},props:{decorations:j,handleDOMEvents:{mousedown:vt},createSelectionBetween:t=>null!=N.getState(t.state)?t.state.selection:null,handleTripleClick:gt,handleKeyDown:wt,handlePaste:bt},appendTransaction:(t,e,o)=>function(t,n,e){const o=(n||t).selection,i=(n||t).doc;let l,c;if(o instanceof s&&(c=o.node.type.spec.tableRole)){if("cell"==c||"header_cell"==c)l=L.create(i,o.from);else if("row"==c){const t=i.resolve(o.from+1);l=L.rowSelection(t,t)}else if(!e){const t=y.get(o.node),n=o.from+1,e=n+t.map[t.width*t.height-1];l=L.create(i,n+1,e)}}else o instanceof r&&function({$from:t,$to:n}){if(t.pos==n.pos||t.pos<n.pos-6)return!1;let e=t.pos,o=n.pos,r=t.depth;for(;r>=0&&!(t.after(r+1)<t.end(r));r--,e++);for(let t=n.depth;t>=0&&!(n.before(t+1)>n.start(t));t--,o--);return e==o&&/row|table/.test(t.node(r).type.spec.tableRole)}(o)?l=r.create(i,o.from):o instanceof r&&function({$from:t,$to:n}){let e,o;for(let n=t.depth;n>0;n--){const o=t.node(n);if("cell"===o.type.spec.tableRole||"header_cell"===o.type.spec.tableRole){e=o;break}}for(let t=n.depth;t>0;t--){const e=n.node(t);if("cell"===e.type.spec.tableRole||"header_cell"===e.type.spec.tableRole){o=e;break}}return e!==o&&0===n.parentOffset}(o)&&(l=r.create(i,o.$from.start(),o.$from.end()));return l&&(n||(n=t.tr)).setSelection(l),n}(o,J(o,e),n)})}export{St as T,R as a,b,Rt as c,lt as d,it as e,I as f,Z as g,q as h,V as i,Q as j,g as k,G as l,nt as m,et as s,Ot as t};