@box/threaded-annotations 1.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/LICENSE +379 -0
  2. package/README.md +57 -0
  3. package/dist/chunks/annotation-badge.js +49 -0
  4. package/dist/chunks/custom-placeholder.js +72 -0
  5. package/dist/chunks/delete-annotations-message-popover.js +46 -0
  6. package/dist/chunks/delete-confirmation-popover.js +59 -0
  7. package/dist/chunks/dist.js +1749 -0
  8. package/dist/chunks/mention-component.js +96 -0
  9. package/dist/chunks/message-editor.module.js +12 -0
  10. package/dist/chunks/message-editor2.module.js +27 -0
  11. package/dist/chunks/message-footer.js +42 -0
  12. package/dist/chunks/message-header.js +49 -0
  13. package/dist/chunks/messages-view.js +83 -0
  14. package/dist/chunks/mock-collaboration-props.js +19379 -0
  15. package/dist/chunks/resolved-state.js +55 -0
  16. package/dist/chunks/show-replies-button.js +60 -0
  17. package/dist/chunks/text-message.js +21 -0
  18. package/dist/chunks/threaded-annotations.js +71 -0
  19. package/dist/chunks/threaded-annotations2.js +68 -0
  20. package/dist/chunks/virtualized-messages.js +30 -0
  21. package/dist/esm/index.js +7 -0
  22. package/dist/esm/lib/components/mention-component/mention-component.js +2 -0
  23. package/dist/esm/lib/components/mention-component/mention-context.js +26 -0
  24. package/dist/esm/lib/components/message-editor/editor-extensions/custom-mention/custom-mention-suggestions.js +23 -0
  25. package/dist/esm/lib/components/message-editor/editor-extensions/custom-mention/custom-mention.js +59 -0
  26. package/dist/esm/lib/components/message-editor/editor-extensions/custom-mention/useMentionState.js +24 -0
  27. package/dist/esm/lib/components/message-editor/editor-extensions/custom-paragraph.js +13 -0
  28. package/dist/esm/lib/components/message-editor/editor-extensions/custom-placeholder/custom-placeholder-utils.js +26 -0
  29. package/dist/esm/lib/components/message-editor/editor-extensions/custom-placeholder/custom-placeholder.js +2 -0
  30. package/dist/esm/lib/components/message-editor/error-message.js +17 -0
  31. package/dist/esm/lib/components/message-editor/hooks/useMessageEditor.js +68 -0
  32. package/dist/esm/lib/components/message-editor/hooks/useMessagePost.js +35 -0
  33. package/dist/esm/lib/components/message-editor/message-editor-actions.js +29 -0
  34. package/dist/esm/lib/components/message-editor/message-editor-context.js +7 -0
  35. package/dist/esm/lib/components/message-editor/message-editor.js +74 -0
  36. package/dist/esm/lib/components/message-editor/messages.js +44 -0
  37. package/dist/esm/lib/components/message-editor/utils/getMessageEditorState.js +9 -0
  38. package/dist/esm/lib/components/message-header/delete-annotations-message-popover.js +2 -0
  39. package/dist/esm/lib/components/message-header/message-header.js +2 -0
  40. package/dist/esm/lib/components/message-header/messages.js +32 -0
  41. package/dist/esm/lib/components/messages-view/consts.js +2 -0
  42. package/dist/esm/lib/components/messages-view/hooks/useAutoScroll.js +43 -0
  43. package/dist/esm/lib/components/messages-view/hooks/useShowMoreReplies.js +26 -0
  44. package/dist/esm/lib/components/messages-view/hooks/useVirtualizedMessages.js +17 -0
  45. package/dist/esm/lib/components/messages-view/messages-view.js +61 -0
  46. package/dist/esm/lib/components/messages-view/messages.js +12 -0
  47. package/dist/esm/lib/components/messages-view/virtualized-messages.js +2 -0
  48. package/dist/esm/lib/components/text-message/message-renderer.js +58 -0
  49. package/dist/esm/lib/components/text-message/text-message.js +2 -0
  50. package/dist/esm/lib/components/user-avatar/getInitials.js +5 -0
  51. package/dist/esm/lib/components/user-avatar/messages.js +12 -0
  52. package/dist/esm/lib/components/user-avatar/user-avatar.js +31 -0
  53. package/dist/esm/lib/components/v2/annotation-badge/annotation-badge.js +2 -0
  54. package/dist/esm/lib/components/v2/annotation-badge/index.js +2 -0
  55. package/dist/esm/lib/components/v2/annotation-badge/messages.js +6 -0
  56. package/dist/esm/lib/components/v2/message-editor/editor-extensions/custom-mention/custom-mention-suggestions.js +23 -0
  57. package/dist/esm/lib/components/v2/message-editor/editor-extensions/custom-mention/custom-mention.js +59 -0
  58. package/dist/esm/lib/components/v2/message-editor/editor-extensions/custom-mention/mention-trigger-normalization.js +2 -0
  59. package/dist/esm/lib/components/v2/message-editor/editor-extensions/custom-mention/useMentionState.js +24 -0
  60. package/dist/esm/lib/components/v2/message-editor/editor-extensions/custom-paragraph.js +13 -0
  61. package/dist/esm/lib/components/v2/message-editor/hooks/useCharacterLimit.js +24 -0
  62. package/dist/esm/lib/components/v2/message-editor/hooks/useEditorContainerState.js +21 -0
  63. package/dist/esm/lib/components/v2/message-editor/hooks/useMentionUserSelection.js +22 -0
  64. package/dist/esm/lib/components/v2/message-editor/hooks/useMessageSubmit.js +24 -0
  65. package/dist/esm/lib/components/v2/message-editor/message-editor-context.js +19 -0
  66. package/dist/esm/lib/components/v2/message-editor/message-editor.js +159 -0
  67. package/dist/esm/lib/components/v2/message-editor/message-editor.types.js +4 -0
  68. package/dist/esm/lib/components/v2/message-editor/messages.js +44 -0
  69. package/dist/esm/lib/components/v2/message-editor/subcomponents/character-limit-counter.js +26 -0
  70. package/dist/esm/lib/components/v2/message-editor/subcomponents/edit-buttons.js +32 -0
  71. package/dist/esm/lib/components/v2/message-editor/subcomponents/error-message.js +22 -0
  72. package/dist/esm/lib/components/v2/message-editor/subcomponents/post-button.js +27 -0
  73. package/dist/esm/lib/components/v2/message-header/delete-confirmation-popover.js +2 -0
  74. package/dist/esm/lib/components/v2/message-header/message-header.js +74 -0
  75. package/dist/esm/lib/components/v2/message-header/message-options-menu.js +36 -0
  76. package/dist/esm/lib/components/v2/message-header/messages.js +44 -0
  77. package/dist/esm/lib/components/v2/messages-view/hooks/useAutoScroll.js +64 -0
  78. package/dist/esm/lib/components/v2/messages-view/messages-view.js +2 -0
  79. package/dist/esm/lib/components/v2/resolved-state/messages.js +12 -0
  80. package/dist/esm/lib/components/v2/resolved-state/resolved-state.js +2 -0
  81. package/dist/esm/lib/components/v2/show-replies-button/messages.js +12 -0
  82. package/dist/esm/lib/components/v2/show-replies-button/show-replies-button.js +2 -0
  83. package/dist/esm/lib/components/v2/text-message/messages.js +20 -0
  84. package/dist/esm/lib/components/v2/text-message/subcomponents/message-footer.js +2 -0
  85. package/dist/esm/lib/components/v2/text-message/subcomponents/message-renderer.js +60 -0
  86. package/dist/esm/lib/components/v2/text-message/text-message.js +57 -0
  87. package/dist/esm/lib/components/v2/user-avatar/getInitials.js +5 -0
  88. package/dist/esm/lib/components/v2/user-avatar/messages.js +12 -0
  89. package/dist/esm/lib/components/v2/user-avatar/user-avatar.js +35 -0
  90. package/dist/esm/lib/document-node-types.js +0 -0
  91. package/dist/esm/lib/messages.js +24 -0
  92. package/dist/esm/lib/threaded-annotations.js +2 -0
  93. package/dist/esm/lib/utils/getErrorMessage.js +2 -0
  94. package/dist/esm/lib/v2/constants.js +2 -0
  95. package/dist/esm/lib/v2/messages.js +6 -0
  96. package/dist/esm/lib/v2/test-utils/mocks/index.js +7 -0
  97. package/dist/esm/lib/v2/test-utils/mocks/mock-callbacks.js +15 -0
  98. package/dist/esm/lib/v2/test-utils/mocks/mock-collaboration-props.js +2 -0
  99. package/dist/esm/lib/v2/test-utils/mocks/mock-messages-long-strings.js +27 -0
  100. package/dist/esm/lib/v2/test-utils/mocks/mock-messages.js +198 -0
  101. package/dist/esm/lib/v2/test-utils/mocks/mock-users.js +86 -0
  102. package/dist/esm/lib/v2/test-utils/mocks/mock-utilities.js +9 -0
  103. package/dist/esm/lib/v2/threaded-annotations-context.js +49 -0
  104. package/dist/esm/lib/v2/threaded-annotations.js +3 -0
  105. package/dist/esm/lib/v2/types/annotation-badge-types.js +4 -0
  106. package/dist/esm/lib/v2/types/document-node-types.js +0 -0
  107. package/dist/esm/lib/v2/types/index.js +2 -0
  108. package/dist/esm/lib/v2/types/message-types.js +0 -0
  109. package/dist/esm/lib/v2/utils/build-mention-content.js +20 -0
  110. package/dist/esm/lib/v2/utils/serialize-mention-markup.js +12 -0
  111. package/dist/i18n/bn-IN.js +44 -0
  112. package/dist/i18n/bn-IN.properties +84 -0
  113. package/dist/i18n/da-DK.js +44 -0
  114. package/dist/i18n/da-DK.properties +84 -0
  115. package/dist/i18n/de-DE.js +44 -0
  116. package/dist/i18n/de-DE.properties +84 -0
  117. package/dist/i18n/en-AU.js +44 -0
  118. package/dist/i18n/en-AU.properties +84 -0
  119. package/dist/i18n/en-CA.js +44 -0
  120. package/dist/i18n/en-CA.properties +84 -0
  121. package/dist/i18n/en-GB.js +44 -0
  122. package/dist/i18n/en-GB.properties +84 -0
  123. package/dist/i18n/en-US.js +44 -0
  124. package/dist/i18n/en-US.properties +84 -0
  125. package/dist/i18n/en-x-pseudo.js +44 -0
  126. package/dist/i18n/en-x-pseudo.properties +84 -0
  127. package/dist/i18n/es-419.js +44 -0
  128. package/dist/i18n/es-419.properties +84 -0
  129. package/dist/i18n/es-ES.js +44 -0
  130. package/dist/i18n/es-ES.properties +84 -0
  131. package/dist/i18n/fi-FI.js +44 -0
  132. package/dist/i18n/fi-FI.properties +84 -0
  133. package/dist/i18n/fr-CA.js +44 -0
  134. package/dist/i18n/fr-CA.properties +84 -0
  135. package/dist/i18n/fr-FR.js +44 -0
  136. package/dist/i18n/fr-FR.properties +84 -0
  137. package/dist/i18n/hi-IN.js +44 -0
  138. package/dist/i18n/hi-IN.properties +84 -0
  139. package/dist/i18n/it-IT.js +44 -0
  140. package/dist/i18n/it-IT.properties +84 -0
  141. package/dist/i18n/ja-JP.js +44 -0
  142. package/dist/i18n/ja-JP.properties +84 -0
  143. package/dist/i18n/json/src/lib/components/message-editor/messages.json +1 -0
  144. package/dist/i18n/json/src/lib/components/message-header/messages.json +1 -0
  145. package/dist/i18n/json/src/lib/components/messages-view/messages.json +1 -0
  146. package/dist/i18n/json/src/lib/components/user-avatar/messages.json +1 -0
  147. package/dist/i18n/json/src/lib/components/v2/annotation-badge/messages.json +1 -0
  148. package/dist/i18n/json/src/lib/components/v2/message-editor/messages.json +1 -0
  149. package/dist/i18n/json/src/lib/components/v2/message-header/messages.json +1 -0
  150. package/dist/i18n/json/src/lib/components/v2/resolved-state/messages.json +1 -0
  151. package/dist/i18n/json/src/lib/components/v2/show-replies-button/messages.json +1 -0
  152. package/dist/i18n/json/src/lib/components/v2/text-message/messages.json +1 -0
  153. package/dist/i18n/json/src/lib/components/v2/user-avatar/messages.json +1 -0
  154. package/dist/i18n/json/src/lib/messages.json +1 -0
  155. package/dist/i18n/json/src/lib/v2/messages.json +1 -0
  156. package/dist/i18n/ko-KR.js +44 -0
  157. package/dist/i18n/ko-KR.properties +84 -0
  158. package/dist/i18n/nb-NO.js +44 -0
  159. package/dist/i18n/nb-NO.properties +84 -0
  160. package/dist/i18n/nl-NL.js +44 -0
  161. package/dist/i18n/nl-NL.properties +84 -0
  162. package/dist/i18n/pl-PL.js +44 -0
  163. package/dist/i18n/pl-PL.properties +84 -0
  164. package/dist/i18n/pt-BR.js +44 -0
  165. package/dist/i18n/pt-BR.properties +84 -0
  166. package/dist/i18n/ru-RU.js +44 -0
  167. package/dist/i18n/ru-RU.properties +84 -0
  168. package/dist/i18n/sv-SE.js +44 -0
  169. package/dist/i18n/sv-SE.properties +84 -0
  170. package/dist/i18n/tr-TR.js +44 -0
  171. package/dist/i18n/tr-TR.properties +84 -0
  172. package/dist/i18n/zh-CN.js +44 -0
  173. package/dist/i18n/zh-CN.properties +84 -0
  174. package/dist/i18n/zh-TW.js +44 -0
  175. package/dist/i18n/zh-TW.properties +84 -0
  176. package/dist/styles/annotation-badge.css +1 -0
  177. package/dist/styles/custom-placeholder.css +1 -0
  178. package/dist/styles/delete-annotations-message-popover.css +1 -0
  179. package/dist/styles/delete-confirmation-popover.css +1 -0
  180. package/dist/styles/mention-component.css +1 -0
  181. package/dist/styles/message-editor.css +1 -0
  182. package/dist/styles/message-editor2.css +1 -0
  183. package/dist/styles/message-footer.css +1 -0
  184. package/dist/styles/message-header.css +1 -0
  185. package/dist/styles/messages-view.css +1 -0
  186. package/dist/styles/resolved-state.css +1 -0
  187. package/dist/styles/show-replies-button.css +1 -0
  188. package/dist/styles/text-message.css +1 -0
  189. package/dist/styles/threaded-annotations.css +1 -0
  190. package/dist/styles/threaded-annotations2.css +1 -0
  191. package/dist/styles/virtualized-messages.css +1 -0
  192. package/dist/types/index.d.ts +9 -0
  193. package/dist/types/lib/components/mention-component/mention-component.d.ts +12 -0
  194. package/dist/types/lib/components/mention-component/mention-context.d.ts +31 -0
  195. package/dist/types/lib/components/message-editor/editor-extensions/custom-mention/custom-mention-suggestions.d.ts +15 -0
  196. package/dist/types/lib/components/message-editor/editor-extensions/custom-mention/custom-mention.d.ts +1 -0
  197. package/dist/types/lib/components/message-editor/editor-extensions/custom-mention/useMentionState.d.ts +15 -0
  198. package/dist/types/lib/components/message-editor/editor-extensions/custom-paragraph.d.ts +1 -0
  199. package/dist/types/lib/components/message-editor/editor-extensions/custom-placeholder/custom-placeholder-utils.d.ts +38 -0
  200. package/dist/types/lib/components/message-editor/editor-extensions/custom-placeholder/custom-placeholder.d.ts +2 -0
  201. package/dist/types/lib/components/message-editor/error-message.d.ts +3 -0
  202. package/dist/types/lib/components/message-editor/hooks/useMessageEditor.d.ts +12 -0
  203. package/dist/types/lib/components/message-editor/hooks/useMessagePost.d.ts +18 -0
  204. package/dist/types/lib/components/message-editor/message-editor-actions.d.ts +9 -0
  205. package/dist/types/lib/components/message-editor/message-editor-context.d.ts +13 -0
  206. package/dist/types/lib/components/message-editor/message-editor.d.ts +36 -0
  207. package/dist/types/lib/components/message-editor/messages.d.ts +53 -0
  208. package/dist/types/lib/components/message-editor/stories/shared.d.ts +4 -0
  209. package/dist/types/lib/components/message-editor/stories/utils/mock-props.d.ts +4 -0
  210. package/dist/types/lib/components/message-editor/stories/utils/test-utils.d.ts +2 -0
  211. package/dist/types/lib/components/message-editor/utils/getMessageEditorState.d.ts +13 -0
  212. package/dist/types/lib/components/message-header/delete-annotations-message-popover.d.ts +11 -0
  213. package/dist/types/lib/components/message-header/message-header.d.ts +18 -0
  214. package/dist/types/lib/components/message-header/messages.d.ts +38 -0
  215. package/dist/types/lib/components/messages-view/consts.d.ts +4 -0
  216. package/dist/types/lib/components/messages-view/hooks/useAutoScroll.d.ts +9 -0
  217. package/dist/types/lib/components/messages-view/hooks/useShowMoreReplies.d.ts +10 -0
  218. package/dist/types/lib/components/messages-view/hooks/useVirtualizedMessages.d.ts +13 -0
  219. package/dist/types/lib/components/messages-view/messages-view.d.ts +20 -0
  220. package/dist/types/lib/components/messages-view/messages.d.ts +13 -0
  221. package/dist/types/lib/components/messages-view/virtualized-messages.d.ts +22 -0
  222. package/dist/types/lib/components/text-message/message-renderer.d.ts +6 -0
  223. package/dist/types/lib/components/text-message/stories/shared.d.ts +2 -0
  224. package/dist/types/lib/components/text-message/stories/utils/test-utils.d.ts +2 -0
  225. package/dist/types/lib/components/text-message/text-message.d.ts +17 -0
  226. package/dist/types/lib/components/text-message/types.d.ts +35 -0
  227. package/dist/types/lib/components/user-avatar/getInitials.d.ts +1 -0
  228. package/dist/types/lib/components/user-avatar/messages.d.ts +13 -0
  229. package/dist/types/lib/components/user-avatar/user-avatar.d.ts +10 -0
  230. package/dist/types/lib/components/v2/annotation-badge/annotation-badge.d.ts +7 -0
  231. package/dist/types/lib/components/v2/annotation-badge/index.d.ts +1 -0
  232. package/dist/types/lib/components/v2/annotation-badge/messages.d.ts +8 -0
  233. package/dist/types/lib/components/v2/message-editor/editor-extensions/custom-mention/custom-mention-suggestions.d.ts +15 -0
  234. package/dist/types/lib/components/v2/message-editor/editor-extensions/custom-mention/custom-mention.d.ts +1 -0
  235. package/dist/types/lib/components/v2/message-editor/editor-extensions/custom-mention/mention-trigger-normalization.d.ts +5 -0
  236. package/dist/types/lib/components/v2/message-editor/editor-extensions/custom-mention/useMentionState.d.ts +15 -0
  237. package/dist/types/lib/components/v2/message-editor/editor-extensions/custom-paragraph.d.ts +1 -0
  238. package/dist/types/lib/components/v2/message-editor/hooks/useCharacterLimit.d.ts +15 -0
  239. package/dist/types/lib/components/v2/message-editor/hooks/useEditorContainerState.d.ts +27 -0
  240. package/dist/types/lib/components/v2/message-editor/hooks/useMentionUserSelection.d.ts +5 -0
  241. package/dist/types/lib/components/v2/message-editor/hooks/useMessageSubmit.d.ts +13 -0
  242. package/dist/types/lib/components/v2/message-editor/message-editor-context.d.ts +12 -0
  243. package/dist/types/lib/components/v2/message-editor/message-editor.d.ts +3 -0
  244. package/dist/types/lib/components/v2/message-editor/message-editor.types.d.ts +69 -0
  245. package/dist/types/lib/components/v2/message-editor/messages.d.ts +53 -0
  246. package/dist/types/lib/components/v2/message-editor/stories/shared.d.ts +3 -0
  247. package/dist/types/lib/components/v2/message-editor/stories/utils/mock-props.d.ts +6 -0
  248. package/dist/types/lib/components/v2/message-editor/stories/utils/test-utils.d.ts +10 -0
  249. package/dist/types/lib/components/v2/message-editor/subcomponents/character-limit-counter.d.ts +7 -0
  250. package/dist/types/lib/components/v2/message-editor/subcomponents/edit-buttons.d.ts +11 -0
  251. package/dist/types/lib/components/v2/message-editor/subcomponents/error-message.d.ts +3 -0
  252. package/dist/types/lib/components/v2/message-editor/subcomponents/post-button.d.ts +11 -0
  253. package/dist/types/lib/components/v2/message-header/delete-confirmation-popover.d.ts +11 -0
  254. package/dist/types/lib/components/v2/message-header/message-header.d.ts +32 -0
  255. package/dist/types/lib/components/v2/message-header/message-options-menu.d.ts +12 -0
  256. package/dist/types/lib/components/v2/message-header/messages.d.ts +53 -0
  257. package/dist/types/lib/components/v2/message-header/stories/shared.d.ts +2 -0
  258. package/dist/types/lib/components/v2/message-header/stories/utils/test-utils.d.ts +1 -0
  259. package/dist/types/lib/components/v2/messages-view/hooks/useAutoScroll.d.ts +12 -0
  260. package/dist/types/lib/components/v2/messages-view/messages-view.d.ts +17 -0
  261. package/dist/types/lib/components/v2/messages-view/stories/shared.d.ts +7 -0
  262. package/dist/types/lib/components/v2/resolved-state/messages.d.ts +13 -0
  263. package/dist/types/lib/components/v2/resolved-state/resolved-state.d.ts +11 -0
  264. package/dist/types/lib/components/v2/resolved-state/stories/shared.d.ts +2 -0
  265. package/dist/types/lib/components/v2/show-replies-button/messages.d.ts +13 -0
  266. package/dist/types/lib/components/v2/show-replies-button/show-replies-button.d.ts +8 -0
  267. package/dist/types/lib/components/v2/text-message/messages.d.ts +23 -0
  268. package/dist/types/lib/components/v2/text-message/stories/shared.d.ts +2 -0
  269. package/dist/types/lib/components/v2/text-message/stories/utils/test-utils.d.ts +2 -0
  270. package/dist/types/lib/components/v2/text-message/subcomponents/message-footer.d.ts +10 -0
  271. package/dist/types/lib/components/v2/text-message/subcomponents/message-renderer.d.ts +6 -0
  272. package/dist/types/lib/components/v2/text-message/text-message.d.ts +26 -0
  273. package/dist/types/lib/components/v2/user-avatar/getInitials.d.ts +1 -0
  274. package/dist/types/lib/components/v2/user-avatar/messages.d.ts +13 -0
  275. package/dist/types/lib/components/v2/user-avatar/user-avatar.d.ts +12 -0
  276. package/dist/types/lib/document-node-types.d.ts +32 -0
  277. package/dist/types/lib/messages.d.ts +28 -0
  278. package/dist/types/lib/stories/mock/index.d.ts +5 -0
  279. package/dist/types/lib/stories/mock/mock-callbacks.d.ts +6 -0
  280. package/dist/types/lib/stories/mock/mock-messages-long-strings.d.ts +11 -0
  281. package/dist/types/lib/stories/mock/mock-messages.d.ts +8 -0
  282. package/dist/types/lib/stories/mock/mock-users.d.ts +56 -0
  283. package/dist/types/lib/stories/mock/mock-utilities.d.ts +6 -0
  284. package/dist/types/lib/stories/shared.d.ts +9 -0
  285. package/dist/types/lib/stories/utils/mock-collaboration-props.d.ts +13 -0
  286. package/dist/types/lib/stories/utils/mock-props.d.ts +20 -0
  287. package/dist/types/lib/stories/utils/mock-state.d.ts +8 -0
  288. package/dist/types/lib/stories/utils/shared/button-utils.d.ts +6 -0
  289. package/dist/types/lib/stories/utils/shared/index.d.ts +4 -0
  290. package/dist/types/lib/stories/utils/shared/interaction-utils.d.ts +4 -0
  291. package/dist/types/lib/stories/utils/shared/test-selectors.d.ts +7 -0
  292. package/dist/types/lib/stories/utils/shared/text-utils.d.ts +4 -0
  293. package/dist/types/lib/stories/utils/shared/verify-mention-elements.d.ts +2 -0
  294. package/dist/types/lib/stories/utils/test-utils.d.ts +3 -0
  295. package/dist/types/lib/threaded-annotations.d.ts +51 -0
  296. package/dist/types/lib/utils/getErrorMessage.d.ts +1 -0
  297. package/dist/types/lib/v2/constants.d.ts +8 -0
  298. package/dist/types/lib/v2/messages.d.ts +8 -0
  299. package/dist/types/lib/v2/stories/shared.d.ts +18 -0
  300. package/dist/types/lib/v2/test-utils/button-utils.d.ts +15 -0
  301. package/dist/types/lib/v2/test-utils/default-user-selector-props.d.ts +2 -0
  302. package/dist/types/lib/v2/test-utils/index.d.ts +7 -0
  303. package/dist/types/lib/v2/test-utils/interaction-utils.d.ts +9 -0
  304. package/dist/types/lib/v2/test-utils/mocks/index.d.ts +6 -0
  305. package/dist/types/lib/v2/test-utils/mocks/mock-callbacks.d.ts +8 -0
  306. package/dist/types/lib/v2/test-utils/mocks/mock-collaboration-props.d.ts +13 -0
  307. package/dist/types/lib/v2/test-utils/mocks/mock-messages-long-strings.d.ts +5 -0
  308. package/dist/types/lib/v2/test-utils/mocks/mock-messages.d.ts +10 -0
  309. package/dist/types/lib/v2/test-utils/mocks/mock-users.d.ts +55 -0
  310. package/dist/types/lib/v2/test-utils/mocks/mock-utilities.d.ts +6 -0
  311. package/dist/types/lib/v2/test-utils/test-selectors.d.ts +12 -0
  312. package/dist/types/lib/v2/test-utils/text-utils.d.ts +3 -0
  313. package/dist/types/lib/v2/test-utils/verify-mention-elements.d.ts +2 -0
  314. package/dist/types/lib/v2/threaded-annotations-context.d.ts +47 -0
  315. package/dist/types/lib/v2/threaded-annotations.d.ts +42 -0
  316. package/dist/types/lib/v2/types/annotation-badge-types.d.ts +23 -0
  317. package/dist/types/lib/v2/types/document-node-types.d.ts +32 -0
  318. package/dist/types/lib/v2/types/index.d.ts +3 -0
  319. package/dist/types/lib/v2/types/message-types.d.ts +33 -0
  320. package/dist/types/lib/v2/utils/build-mention-content.d.ts +3 -0
  321. package/dist/types/lib/v2/utils/serialize-mention-markup.d.ts +16 -0
  322. package/package.json +66 -0
@@ -0,0 +1,1749 @@
1
+ function e(t, n, r) {
2
+ for (let i = 0;; i++) {
3
+ if (i == t.childCount || i == n.childCount) return t.childCount == n.childCount ? null : r;
4
+ let a = t.child(i), o = n.child(i);
5
+ if (a == o) {
6
+ r += a.nodeSize;
7
+ continue;
8
+ }
9
+ if (!a.sameMarkup(o)) return r;
10
+ if (a.isText && a.text != o.text) {
11
+ for (let e = 0; a.text[e] == o.text[e]; e++) r++;
12
+ return r;
13
+ }
14
+ if (a.content.size || o.content.size) {
15
+ let t = e(a.content, o.content, r + 1);
16
+ if (t != null) return t;
17
+ }
18
+ r += a.nodeSize;
19
+ }
20
+ }
21
+ function t(e, n, r, i) {
22
+ for (let a = e.childCount, o = n.childCount;;) {
23
+ if (a == 0 || o == 0) return a == o ? null : {
24
+ a: r,
25
+ b: i
26
+ };
27
+ let s = e.child(--a), c = n.child(--o), l = s.nodeSize;
28
+ if (s == c) {
29
+ r -= l, i -= l;
30
+ continue;
31
+ }
32
+ if (!s.sameMarkup(c)) return {
33
+ a: r,
34
+ b: i
35
+ };
36
+ if (s.isText && s.text != c.text) {
37
+ let e = 0, t = Math.min(s.text.length, c.text.length);
38
+ for (; e < t && s.text[s.text.length - e - 1] == c.text[c.text.length - e - 1];) e++, r--, i--;
39
+ return {
40
+ a: r,
41
+ b: i
42
+ };
43
+ }
44
+ if (s.content.size || c.content.size) {
45
+ let e = t(s.content, c.content, r - 1, i - 1);
46
+ if (e) return e;
47
+ }
48
+ r -= l, i -= l;
49
+ }
50
+ }
51
+ var n = class n {
52
+ constructor(e, t) {
53
+ if (this.content = e, this.size = t || 0, t == null) for (let t = 0; t < e.length; t++) this.size += e[t].nodeSize;
54
+ }
55
+ nodesBetween(e, t, n, r = 0, i) {
56
+ for (let a = 0, o = 0; o < t; a++) {
57
+ let s = this.content[a], c = o + s.nodeSize;
58
+ if (c > e && n(s, r + o, i || null, a) !== !1 && s.content.size) {
59
+ let i = o + 1;
60
+ s.nodesBetween(Math.max(0, e - i), Math.min(s.content.size, t - i), n, r + i);
61
+ }
62
+ o = c;
63
+ }
64
+ }
65
+ descendants(e) {
66
+ this.nodesBetween(0, this.size, e);
67
+ }
68
+ textBetween(e, t, n, r) {
69
+ let i = "", a = !0;
70
+ return this.nodesBetween(e, t, (o, s) => {
71
+ let c = o.isText ? o.text.slice(Math.max(e, s) - s, t - s) : o.isLeaf ? r ? typeof r == "function" ? r(o) : r : o.type.spec.leafText ? o.type.spec.leafText(o) : "" : "";
72
+ o.isBlock && (o.isLeaf && c || o.isTextblock) && n && (a ? a = !1 : i += n), i += c;
73
+ }, 0), i;
74
+ }
75
+ append(e) {
76
+ if (!e.size) return this;
77
+ if (!this.size) return e;
78
+ let t = this.lastChild, r = e.firstChild, i = this.content.slice(), a = 0;
79
+ for (t.isText && t.sameMarkup(r) && (i[i.length - 1] = t.withText(t.text + r.text), a = 1); a < e.content.length; a++) i.push(e.content[a]);
80
+ return new n(i, this.size + e.size);
81
+ }
82
+ cut(e, t = this.size) {
83
+ if (e == 0 && t == this.size) return this;
84
+ let r = [], i = 0;
85
+ if (t > e) for (let n = 0, a = 0; a < t; n++) {
86
+ let o = this.content[n], s = a + o.nodeSize;
87
+ s > e && ((a < e || s > t) && (o = o.isText ? o.cut(Math.max(0, e - a), Math.min(o.text.length, t - a)) : o.cut(Math.max(0, e - a - 1), Math.min(o.content.size, t - a - 1))), r.push(o), i += o.nodeSize), a = s;
88
+ }
89
+ return new n(r, i);
90
+ }
91
+ cutByIndex(e, t) {
92
+ return e == t ? n.empty : e == 0 && t == this.content.length ? this : new n(this.content.slice(e, t));
93
+ }
94
+ replaceChild(e, t) {
95
+ let r = this.content[e];
96
+ if (r == t) return this;
97
+ let i = this.content.slice(), a = this.size + t.nodeSize - r.nodeSize;
98
+ return i[e] = t, new n(i, a);
99
+ }
100
+ addToStart(e) {
101
+ return new n([e].concat(this.content), this.size + e.nodeSize);
102
+ }
103
+ addToEnd(e) {
104
+ return new n(this.content.concat(e), this.size + e.nodeSize);
105
+ }
106
+ eq(e) {
107
+ if (this.content.length != e.content.length) return !1;
108
+ for (let t = 0; t < this.content.length; t++) if (!this.content[t].eq(e.content[t])) return !1;
109
+ return !0;
110
+ }
111
+ get firstChild() {
112
+ return this.content.length ? this.content[0] : null;
113
+ }
114
+ get lastChild() {
115
+ return this.content.length ? this.content[this.content.length - 1] : null;
116
+ }
117
+ get childCount() {
118
+ return this.content.length;
119
+ }
120
+ child(e) {
121
+ let t = this.content[e];
122
+ if (!t) throw RangeError("Index " + e + " out of range for " + this);
123
+ return t;
124
+ }
125
+ maybeChild(e) {
126
+ return this.content[e] || null;
127
+ }
128
+ forEach(e) {
129
+ for (let t = 0, n = 0; t < this.content.length; t++) {
130
+ let r = this.content[t];
131
+ e(r, n, t), n += r.nodeSize;
132
+ }
133
+ }
134
+ findDiffStart(t, n = 0) {
135
+ return e(this, t, n);
136
+ }
137
+ findDiffEnd(e, n = this.size, r = e.size) {
138
+ return t(this, e, n, r);
139
+ }
140
+ findIndex(e) {
141
+ if (e == 0) return i(0, e);
142
+ if (e == this.size) return i(this.content.length, e);
143
+ if (e > this.size || e < 0) throw RangeError(`Position ${e} outside of fragment (${this})`);
144
+ for (let t = 0, n = 0;; t++) {
145
+ let r = this.child(t), a = n + r.nodeSize;
146
+ if (a >= e) return a == e ? i(t + 1, a) : i(t, n);
147
+ n = a;
148
+ }
149
+ }
150
+ toString() {
151
+ return "<" + this.toStringInner() + ">";
152
+ }
153
+ toStringInner() {
154
+ return this.content.join(", ");
155
+ }
156
+ toJSON() {
157
+ return this.content.length ? this.content.map((e) => e.toJSON()) : null;
158
+ }
159
+ static fromJSON(e, t) {
160
+ if (!t) return n.empty;
161
+ if (!Array.isArray(t)) throw RangeError("Invalid input for Fragment.fromJSON");
162
+ return new n(t.map(e.nodeFromJSON));
163
+ }
164
+ static fromArray(e) {
165
+ if (!e.length) return n.empty;
166
+ let t, r = 0;
167
+ for (let n = 0; n < e.length; n++) {
168
+ let i = e[n];
169
+ r += i.nodeSize, n && i.isText && e[n - 1].sameMarkup(i) ? (t ||= e.slice(0, n), t[t.length - 1] = i.withText(t[t.length - 1].text + i.text)) : t && t.push(i);
170
+ }
171
+ return new n(t || e, r);
172
+ }
173
+ static from(e) {
174
+ if (!e) return n.empty;
175
+ if (e instanceof n) return e;
176
+ if (Array.isArray(e)) return this.fromArray(e);
177
+ if (e.attrs) return new n([e], e.nodeSize);
178
+ throw RangeError("Can not convert " + e + " to a Fragment" + (e.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
179
+ }
180
+ };
181
+ n.empty = new n([], 0);
182
+ var r = {
183
+ index: 0,
184
+ offset: 0
185
+ };
186
+ function i(e, t) {
187
+ return r.index = e, r.offset = t, r;
188
+ }
189
+ function a(e, t) {
190
+ if (e === t) return !0;
191
+ if (!(e && typeof e == "object") || !(t && typeof t == "object")) return !1;
192
+ let n = Array.isArray(e);
193
+ if (Array.isArray(t) != n) return !1;
194
+ if (n) {
195
+ if (e.length != t.length) return !1;
196
+ for (let n = 0; n < e.length; n++) if (!a(e[n], t[n])) return !1;
197
+ } else {
198
+ for (let n in e) if (!(n in t) || !a(e[n], t[n])) return !1;
199
+ for (let n in t) if (!(n in e)) return !1;
200
+ }
201
+ return !0;
202
+ }
203
+ var o = class e {
204
+ constructor(e, t) {
205
+ this.type = e, this.attrs = t;
206
+ }
207
+ addToSet(e) {
208
+ let t, n = !1;
209
+ for (let r = 0; r < e.length; r++) {
210
+ let i = e[r];
211
+ if (this.eq(i)) return e;
212
+ if (this.type.excludes(i.type)) t ||= e.slice(0, r);
213
+ else if (i.type.excludes(this.type)) return e;
214
+ else !n && i.type.rank > this.type.rank && (t ||= e.slice(0, r), t.push(this), n = !0), t && t.push(i);
215
+ }
216
+ return t ||= e.slice(), n || t.push(this), t;
217
+ }
218
+ removeFromSet(e) {
219
+ for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return e.slice(0, t).concat(e.slice(t + 1));
220
+ return e;
221
+ }
222
+ isInSet(e) {
223
+ for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return !0;
224
+ return !1;
225
+ }
226
+ eq(e) {
227
+ return this == e || this.type == e.type && a(this.attrs, e.attrs);
228
+ }
229
+ toJSON() {
230
+ let e = { type: this.type.name };
231
+ for (let t in this.attrs) {
232
+ e.attrs = this.attrs;
233
+ break;
234
+ }
235
+ return e;
236
+ }
237
+ static fromJSON(e, t) {
238
+ if (!t) throw RangeError("Invalid input for Mark.fromJSON");
239
+ let n = e.marks[t.type];
240
+ if (!n) throw RangeError(`There is no mark type ${t.type} in this schema`);
241
+ let r = n.create(t.attrs);
242
+ return n.checkAttrs(r.attrs), r;
243
+ }
244
+ static sameSet(e, t) {
245
+ if (e == t) return !0;
246
+ if (e.length != t.length) return !1;
247
+ for (let n = 0; n < e.length; n++) if (!e[n].eq(t[n])) return !1;
248
+ return !0;
249
+ }
250
+ static setFrom(t) {
251
+ if (!t || Array.isArray(t) && t.length == 0) return e.none;
252
+ if (t instanceof e) return [t];
253
+ let n = t.slice();
254
+ return n.sort((e, t) => e.type.rank - t.type.rank), n;
255
+ }
256
+ };
257
+ o.none = [];
258
+ var s = class extends Error {}, c = class e {
259
+ constructor(e, t, n) {
260
+ this.content = e, this.openStart = t, this.openEnd = n;
261
+ }
262
+ get size() {
263
+ return this.content.size - this.openStart - this.openEnd;
264
+ }
265
+ insertAt(t, n) {
266
+ let r = u(this.content, t + this.openStart, n);
267
+ return r && new e(r, this.openStart, this.openEnd);
268
+ }
269
+ removeBetween(t, n) {
270
+ return new e(l(this.content, t + this.openStart, n + this.openStart), this.openStart, this.openEnd);
271
+ }
272
+ eq(e) {
273
+ return this.content.eq(e.content) && this.openStart == e.openStart && this.openEnd == e.openEnd;
274
+ }
275
+ toString() {
276
+ return this.content + "(" + this.openStart + "," + this.openEnd + ")";
277
+ }
278
+ toJSON() {
279
+ if (!this.content.size) return null;
280
+ let e = { content: this.content.toJSON() };
281
+ return this.openStart > 0 && (e.openStart = this.openStart), this.openEnd > 0 && (e.openEnd = this.openEnd), e;
282
+ }
283
+ static fromJSON(t, r) {
284
+ if (!r) return e.empty;
285
+ let i = r.openStart || 0, a = r.openEnd || 0;
286
+ if (typeof i != "number" || typeof a != "number") throw RangeError("Invalid input for Slice.fromJSON");
287
+ return new e(n.fromJSON(t, r.content), i, a);
288
+ }
289
+ static maxOpen(t, n = !0) {
290
+ let r = 0, i = 0;
291
+ for (let e = t.firstChild; e && !e.isLeaf && (n || !e.type.spec.isolating); e = e.firstChild) r++;
292
+ for (let e = t.lastChild; e && !e.isLeaf && (n || !e.type.spec.isolating); e = e.lastChild) i++;
293
+ return new e(t, r, i);
294
+ }
295
+ };
296
+ c.empty = new c(n.empty, 0, 0);
297
+ function l(e, t, n) {
298
+ let { index: r, offset: i } = e.findIndex(t), a = e.maybeChild(r), { index: o, offset: s } = e.findIndex(n);
299
+ if (i == t || a.isText) {
300
+ if (s != n && !e.child(o).isText) throw RangeError("Removing non-flat range");
301
+ return e.cut(0, t).append(e.cut(n));
302
+ }
303
+ if (r != o) throw RangeError("Removing non-flat range");
304
+ return e.replaceChild(r, a.copy(l(a.content, t - i - 1, n - i - 1)));
305
+ }
306
+ function u(e, t, n, r) {
307
+ let { index: i, offset: a } = e.findIndex(t), o = e.maybeChild(i);
308
+ if (a == t || o.isText) return r && !r.canReplace(i, i, n) ? null : e.cut(0, t).append(n).append(e.cut(t));
309
+ let s = u(o.content, t - a - 1, n, o);
310
+ return s && e.replaceChild(i, o.copy(s));
311
+ }
312
+ function d(e, t, n) {
313
+ if (n.openStart > e.depth) throw new s("Inserted content deeper than insertion position");
314
+ if (e.depth - n.openStart != t.depth - n.openEnd) throw new s("Inconsistent open depths");
315
+ return f(e, t, n, 0);
316
+ }
317
+ function f(e, t, n, r) {
318
+ let i = e.index(r), a = e.node(r);
319
+ if (i == t.index(r) && r < e.depth - n.openStart) {
320
+ let o = f(e, t, n, r + 1);
321
+ return a.copy(a.content.replaceChild(i, o));
322
+ } else if (!n.content.size) return g(a, v(e, t, r));
323
+ else if (!n.openStart && !n.openEnd && e.depth == r && t.depth == r) {
324
+ let r = e.parent, i = r.content;
325
+ return g(r, i.cut(0, e.parentOffset).append(n.content).append(i.cut(t.parentOffset)));
326
+ } else {
327
+ let { start: i, end: o } = te(n, e);
328
+ return g(a, _(e, i, o, t, r));
329
+ }
330
+ }
331
+ function ee(e, t) {
332
+ if (!t.type.compatibleContent(e.type)) throw new s("Cannot join " + t.type.name + " onto " + e.type.name);
333
+ }
334
+ function p(e, t, n) {
335
+ let r = e.node(n);
336
+ return ee(r, t.node(n)), r;
337
+ }
338
+ function m(e, t) {
339
+ let n = t.length - 1;
340
+ n >= 0 && e.isText && e.sameMarkup(t[n]) ? t[n] = e.withText(t[n].text + e.text) : t.push(e);
341
+ }
342
+ function h(e, t, n, r) {
343
+ let i = (t || e).node(n), a = 0, o = t ? t.index(n) : i.childCount;
344
+ e && (a = e.index(n), e.depth > n ? a++ : e.textOffset && (m(e.nodeAfter, r), a++));
345
+ for (let e = a; e < o; e++) m(i.child(e), r);
346
+ t && t.depth == n && t.textOffset && m(t.nodeBefore, r);
347
+ }
348
+ function g(e, t) {
349
+ return e.type.checkContent(t), e.copy(t);
350
+ }
351
+ function _(e, t, r, i, a) {
352
+ let o = e.depth > a && p(e, t, a + 1), s = i.depth > a && p(r, i, a + 1), c = [];
353
+ return h(null, e, a, c), o && s && t.index(a) == r.index(a) ? (ee(o, s), m(g(o, _(e, t, r, i, a + 1)), c)) : (o && m(g(o, v(e, t, a + 1)), c), h(t, r, a, c), s && m(g(s, v(r, i, a + 1)), c)), h(i, null, a, c), new n(c);
354
+ }
355
+ function v(e, t, r) {
356
+ let i = [];
357
+ return h(null, e, r, i), e.depth > r && m(g(p(e, t, r + 1), v(e, t, r + 1)), i), h(t, null, r, i), new n(i);
358
+ }
359
+ function te(e, t) {
360
+ let r = t.depth - e.openStart, i = t.node(r).copy(e.content);
361
+ for (let e = r - 1; e >= 0; e--) i = t.node(e).copy(n.from(i));
362
+ return {
363
+ start: i.resolveNoCache(e.openStart + r),
364
+ end: i.resolveNoCache(i.content.size - e.openEnd - r)
365
+ };
366
+ }
367
+ var y = class e {
368
+ constructor(e, t, n) {
369
+ this.pos = e, this.path = t, this.parentOffset = n, this.depth = t.length / 3 - 1;
370
+ }
371
+ resolveDepth(e) {
372
+ return e == null ? this.depth : e < 0 ? this.depth + e : e;
373
+ }
374
+ get parent() {
375
+ return this.node(this.depth);
376
+ }
377
+ get doc() {
378
+ return this.node(0);
379
+ }
380
+ node(e) {
381
+ return this.path[this.resolveDepth(e) * 3];
382
+ }
383
+ index(e) {
384
+ return this.path[this.resolveDepth(e) * 3 + 1];
385
+ }
386
+ indexAfter(e) {
387
+ return e = this.resolveDepth(e), this.index(e) + (e == this.depth && !this.textOffset ? 0 : 1);
388
+ }
389
+ start(e) {
390
+ return e = this.resolveDepth(e), e == 0 ? 0 : this.path[e * 3 - 1] + 1;
391
+ }
392
+ end(e) {
393
+ return e = this.resolveDepth(e), this.start(e) + this.node(e).content.size;
394
+ }
395
+ before(e) {
396
+ if (e = this.resolveDepth(e), !e) throw RangeError("There is no position before the top-level node");
397
+ return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1];
398
+ }
399
+ after(e) {
400
+ if (e = this.resolveDepth(e), !e) throw RangeError("There is no position after the top-level node");
401
+ return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1] + this.path[e * 3].nodeSize;
402
+ }
403
+ get textOffset() {
404
+ return this.pos - this.path[this.path.length - 1];
405
+ }
406
+ get nodeAfter() {
407
+ let e = this.parent, t = this.index(this.depth);
408
+ if (t == e.childCount) return null;
409
+ let n = this.pos - this.path[this.path.length - 1], r = e.child(t);
410
+ return n ? e.child(t).cut(n) : r;
411
+ }
412
+ get nodeBefore() {
413
+ let e = this.index(this.depth), t = this.pos - this.path[this.path.length - 1];
414
+ return t ? this.parent.child(e).cut(0, t) : e == 0 ? null : this.parent.child(e - 1);
415
+ }
416
+ posAtIndex(e, t) {
417
+ t = this.resolveDepth(t);
418
+ let n = this.path[t * 3], r = t == 0 ? 0 : this.path[t * 3 - 1] + 1;
419
+ for (let t = 0; t < e; t++) r += n.child(t).nodeSize;
420
+ return r;
421
+ }
422
+ marks() {
423
+ let e = this.parent, t = this.index();
424
+ if (e.content.size == 0) return o.none;
425
+ if (this.textOffset) return e.child(t).marks;
426
+ let n = e.maybeChild(t - 1), r = e.maybeChild(t);
427
+ if (!n) {
428
+ let e = n;
429
+ n = r, r = e;
430
+ }
431
+ let i = n.marks;
432
+ for (var a = 0; a < i.length; a++) i[a].type.spec.inclusive === !1 && (!r || !i[a].isInSet(r.marks)) && (i = i[a--].removeFromSet(i));
433
+ return i;
434
+ }
435
+ marksAcross(e) {
436
+ let t = this.parent.maybeChild(this.index());
437
+ if (!t || !t.isInline) return null;
438
+ let n = t.marks, r = e.parent.maybeChild(e.index());
439
+ for (var i = 0; i < n.length; i++) n[i].type.spec.inclusive === !1 && (!r || !n[i].isInSet(r.marks)) && (n = n[i--].removeFromSet(n));
440
+ return n;
441
+ }
442
+ sharedDepth(e) {
443
+ for (let t = this.depth; t > 0; t--) if (this.start(t) <= e && this.end(t) >= e) return t;
444
+ return 0;
445
+ }
446
+ blockRange(e = this, t) {
447
+ if (e.pos < this.pos) return e.blockRange(this);
448
+ for (let n = this.depth - (this.parent.inlineContent || this.pos == e.pos ? 1 : 0); n >= 0; n--) if (e.pos <= this.end(n) && (!t || t(this.node(n)))) return new ie(this, e, n);
449
+ return null;
450
+ }
451
+ sameParent(e) {
452
+ return this.pos - this.parentOffset == e.pos - e.parentOffset;
453
+ }
454
+ max(e) {
455
+ return e.pos > this.pos ? e : this;
456
+ }
457
+ min(e) {
458
+ return e.pos < this.pos ? e : this;
459
+ }
460
+ toString() {
461
+ let e = "";
462
+ for (let t = 1; t <= this.depth; t++) e += (e ? "/" : "") + this.node(t).type.name + "_" + this.index(t - 1);
463
+ return e + ":" + this.parentOffset;
464
+ }
465
+ static resolve(t, n) {
466
+ if (!(n >= 0 && n <= t.content.size)) throw RangeError("Position " + n + " out of range");
467
+ let r = [], i = 0, a = n;
468
+ for (let e = t;;) {
469
+ let { index: t, offset: n } = e.content.findIndex(a), o = a - n;
470
+ if (r.push(e, t, i + n), !o || (e = e.child(t), e.isText)) break;
471
+ a = o - 1, i += n + 1;
472
+ }
473
+ return new e(n, r, a);
474
+ }
475
+ static resolveCached(t, n) {
476
+ let r = b.get(t);
477
+ if (r) for (let e = 0; e < r.elts.length; e++) {
478
+ let t = r.elts[e];
479
+ if (t.pos == n) return t;
480
+ }
481
+ else b.set(t, r = new ne());
482
+ let i = r.elts[r.i] = e.resolve(t, n);
483
+ return r.i = (r.i + 1) % re, i;
484
+ }
485
+ }, ne = class {
486
+ constructor() {
487
+ this.elts = [], this.i = 0;
488
+ }
489
+ }, re = 12, b = /* @__PURE__ */ new WeakMap(), ie = class {
490
+ constructor(e, t, n) {
491
+ this.$from = e, this.$to = t, this.depth = n;
492
+ }
493
+ get start() {
494
+ return this.$from.before(this.depth + 1);
495
+ }
496
+ get end() {
497
+ return this.$to.after(this.depth + 1);
498
+ }
499
+ get parent() {
500
+ return this.$from.node(this.depth);
501
+ }
502
+ get startIndex() {
503
+ return this.$from.index(this.depth);
504
+ }
505
+ get endIndex() {
506
+ return this.$to.indexAfter(this.depth);
507
+ }
508
+ }, ae = Object.create(null), oe = class e {
509
+ constructor(e, t, r, i = o.none) {
510
+ this.type = e, this.attrs = t, this.marks = i, this.content = r || n.empty;
511
+ }
512
+ get children() {
513
+ return this.content.content;
514
+ }
515
+ get nodeSize() {
516
+ return this.isLeaf ? 1 : 2 + this.content.size;
517
+ }
518
+ get childCount() {
519
+ return this.content.childCount;
520
+ }
521
+ child(e) {
522
+ return this.content.child(e);
523
+ }
524
+ maybeChild(e) {
525
+ return this.content.maybeChild(e);
526
+ }
527
+ forEach(e) {
528
+ this.content.forEach(e);
529
+ }
530
+ nodesBetween(e, t, n, r = 0) {
531
+ this.content.nodesBetween(e, t, n, r, this);
532
+ }
533
+ descendants(e) {
534
+ this.nodesBetween(0, this.content.size, e);
535
+ }
536
+ get textContent() {
537
+ return this.isLeaf && this.type.spec.leafText ? this.type.spec.leafText(this) : this.textBetween(0, this.content.size, "");
538
+ }
539
+ textBetween(e, t, n, r) {
540
+ return this.content.textBetween(e, t, n, r);
541
+ }
542
+ get firstChild() {
543
+ return this.content.firstChild;
544
+ }
545
+ get lastChild() {
546
+ return this.content.lastChild;
547
+ }
548
+ eq(e) {
549
+ return this == e || this.sameMarkup(e) && this.content.eq(e.content);
550
+ }
551
+ sameMarkup(e) {
552
+ return this.hasMarkup(e.type, e.attrs, e.marks);
553
+ }
554
+ hasMarkup(e, t, n) {
555
+ return this.type == e && a(this.attrs, t || e.defaultAttrs || ae) && o.sameSet(this.marks, n || o.none);
556
+ }
557
+ copy(t = null) {
558
+ return t == this.content ? this : new e(this.type, this.attrs, t, this.marks);
559
+ }
560
+ mark(t) {
561
+ return t == this.marks ? this : new e(this.type, this.attrs, this.content, t);
562
+ }
563
+ cut(e, t = this.content.size) {
564
+ return e == 0 && t == this.content.size ? this : this.copy(this.content.cut(e, t));
565
+ }
566
+ slice(e, t = this.content.size, n = !1) {
567
+ if (e == t) return c.empty;
568
+ let r = this.resolve(e), i = this.resolve(t), a = n ? 0 : r.sharedDepth(t), o = r.start(a);
569
+ return new c(r.node(a).content.cut(r.pos - o, i.pos - o), r.depth - a, i.depth - a);
570
+ }
571
+ replace(e, t, n) {
572
+ return d(this.resolve(e), this.resolve(t), n);
573
+ }
574
+ nodeAt(e) {
575
+ for (let t = this;;) {
576
+ let { index: n, offset: r } = t.content.findIndex(e);
577
+ if (t = t.maybeChild(n), !t) return null;
578
+ if (r == e || t.isText) return t;
579
+ e -= r + 1;
580
+ }
581
+ }
582
+ childAfter(e) {
583
+ let { index: t, offset: n } = this.content.findIndex(e);
584
+ return {
585
+ node: this.content.maybeChild(t),
586
+ index: t,
587
+ offset: n
588
+ };
589
+ }
590
+ childBefore(e) {
591
+ if (e == 0) return {
592
+ node: null,
593
+ index: 0,
594
+ offset: 0
595
+ };
596
+ let { index: t, offset: n } = this.content.findIndex(e);
597
+ if (n < e) return {
598
+ node: this.content.child(t),
599
+ index: t,
600
+ offset: n
601
+ };
602
+ let r = this.content.child(t - 1);
603
+ return {
604
+ node: r,
605
+ index: t - 1,
606
+ offset: n - r.nodeSize
607
+ };
608
+ }
609
+ resolve(e) {
610
+ return y.resolveCached(this, e);
611
+ }
612
+ resolveNoCache(e) {
613
+ return y.resolve(this, e);
614
+ }
615
+ rangeHasMark(e, t, n) {
616
+ let r = !1;
617
+ return t > e && this.nodesBetween(e, t, (e) => (n.isInSet(e.marks) && (r = !0), !r)), r;
618
+ }
619
+ get isBlock() {
620
+ return this.type.isBlock;
621
+ }
622
+ get isTextblock() {
623
+ return this.type.isTextblock;
624
+ }
625
+ get inlineContent() {
626
+ return this.type.inlineContent;
627
+ }
628
+ get isInline() {
629
+ return this.type.isInline;
630
+ }
631
+ get isText() {
632
+ return this.type.isText;
633
+ }
634
+ get isLeaf() {
635
+ return this.type.isLeaf;
636
+ }
637
+ get isAtom() {
638
+ return this.type.isAtom;
639
+ }
640
+ toString() {
641
+ if (this.type.spec.toDebugString) return this.type.spec.toDebugString(this);
642
+ let e = this.type.name;
643
+ return this.content.size && (e += "(" + this.content.toStringInner() + ")"), se(this.marks, e);
644
+ }
645
+ contentMatchAt(e) {
646
+ let t = this.type.contentMatch.matchFragment(this.content, 0, e);
647
+ if (!t) throw Error("Called contentMatchAt on a node with invalid content");
648
+ return t;
649
+ }
650
+ canReplace(e, t, r = n.empty, i = 0, a = r.childCount) {
651
+ let o = this.contentMatchAt(e).matchFragment(r, i, a), s = o && o.matchFragment(this.content, t);
652
+ if (!s || !s.validEnd) return !1;
653
+ for (let e = i; e < a; e++) if (!this.type.allowsMarks(r.child(e).marks)) return !1;
654
+ return !0;
655
+ }
656
+ canReplaceWith(e, t, n, r) {
657
+ if (r && !this.type.allowsMarks(r)) return !1;
658
+ let i = this.contentMatchAt(e).matchType(n), a = i && i.matchFragment(this.content, t);
659
+ return a ? a.validEnd : !1;
660
+ }
661
+ canAppend(e) {
662
+ return e.content.size ? this.canReplace(this.childCount, this.childCount, e.content) : this.type.compatibleContent(e.type);
663
+ }
664
+ check() {
665
+ this.type.checkContent(this.content), this.type.checkAttrs(this.attrs);
666
+ let e = o.none;
667
+ for (let t = 0; t < this.marks.length; t++) {
668
+ let n = this.marks[t];
669
+ n.type.checkAttrs(n.attrs), e = n.addToSet(e);
670
+ }
671
+ if (!o.sameSet(e, this.marks)) throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e) => e.type.name)}`);
672
+ this.content.forEach((e) => e.check());
673
+ }
674
+ toJSON() {
675
+ let e = { type: this.type.name };
676
+ for (let t in this.attrs) {
677
+ e.attrs = this.attrs;
678
+ break;
679
+ }
680
+ return this.content.size && (e.content = this.content.toJSON()), this.marks.length && (e.marks = this.marks.map((e) => e.toJSON())), e;
681
+ }
682
+ static fromJSON(e, t) {
683
+ if (!t) throw RangeError("Invalid input for Node.fromJSON");
684
+ let r;
685
+ if (t.marks) {
686
+ if (!Array.isArray(t.marks)) throw RangeError("Invalid mark data for Node.fromJSON");
687
+ r = t.marks.map(e.markFromJSON);
688
+ }
689
+ if (t.type == "text") {
690
+ if (typeof t.text != "string") throw RangeError("Invalid text node in JSON");
691
+ return e.text(t.text, r);
692
+ }
693
+ let i = n.fromJSON(e, t.content), a = e.nodeType(t.type).create(t.attrs, i, r);
694
+ return a.type.checkAttrs(a.attrs), a;
695
+ }
696
+ };
697
+ oe.prototype.text = void 0;
698
+ function se(e, t) {
699
+ for (let n = e.length - 1; n >= 0; n--) t = e[n].type.name + "(" + t + ")";
700
+ return t;
701
+ }
702
+ var x = class e {
703
+ constructor(e) {
704
+ this.validEnd = e, this.next = [], this.wrapCache = [];
705
+ }
706
+ static parse(t, n) {
707
+ let r = new ce(t, n);
708
+ if (r.next == null) return e.empty;
709
+ let i = le(r);
710
+ r.next && r.err("Unexpected trailing text");
711
+ let a = ge(he(i));
712
+ return _e(a, r), a;
713
+ }
714
+ matchType(e) {
715
+ for (let t = 0; t < this.next.length; t++) if (this.next[t].type == e) return this.next[t].next;
716
+ return null;
717
+ }
718
+ matchFragment(e, t = 0, n = e.childCount) {
719
+ let r = this;
720
+ for (let i = t; r && i < n; i++) r = r.matchType(e.child(i).type);
721
+ return r;
722
+ }
723
+ get inlineContent() {
724
+ return this.next.length != 0 && this.next[0].type.isInline;
725
+ }
726
+ get defaultType() {
727
+ for (let e = 0; e < this.next.length; e++) {
728
+ let { type: t } = this.next[e];
729
+ if (!(t.isText || t.hasRequiredAttrs())) return t;
730
+ }
731
+ return null;
732
+ }
733
+ compatible(e) {
734
+ for (let t = 0; t < this.next.length; t++) for (let n = 0; n < e.next.length; n++) if (this.next[t].type == e.next[n].type) return !0;
735
+ return !1;
736
+ }
737
+ fillBefore(e, t = !1, r = 0) {
738
+ let i = [this];
739
+ function a(o, s) {
740
+ let c = o.matchFragment(e, r);
741
+ if (c && (!t || c.validEnd)) return n.from(s.map((e) => e.createAndFill()));
742
+ for (let e = 0; e < o.next.length; e++) {
743
+ let { type: t, next: n } = o.next[e];
744
+ if (!(t.isText || t.hasRequiredAttrs()) && i.indexOf(n) == -1) {
745
+ i.push(n);
746
+ let e = a(n, s.concat(t));
747
+ if (e) return e;
748
+ }
749
+ }
750
+ return null;
751
+ }
752
+ return a(this, []);
753
+ }
754
+ findWrapping(e) {
755
+ for (let t = 0; t < this.wrapCache.length; t += 2) if (this.wrapCache[t] == e) return this.wrapCache[t + 1];
756
+ let t = this.computeWrapping(e);
757
+ return this.wrapCache.push(e, t), t;
758
+ }
759
+ computeWrapping(e) {
760
+ let t = Object.create(null), n = [{
761
+ match: this,
762
+ type: null,
763
+ via: null
764
+ }];
765
+ for (; n.length;) {
766
+ let r = n.shift(), i = r.match;
767
+ if (i.matchType(e)) {
768
+ let e = [];
769
+ for (let t = r; t.type; t = t.via) e.push(t.type);
770
+ return e.reverse();
771
+ }
772
+ for (let e = 0; e < i.next.length; e++) {
773
+ let { type: a, next: o } = i.next[e];
774
+ !a.isLeaf && !a.hasRequiredAttrs() && !(a.name in t) && (!r.type || o.validEnd) && (n.push({
775
+ match: a.contentMatch,
776
+ type: a,
777
+ via: r
778
+ }), t[a.name] = !0);
779
+ }
780
+ }
781
+ return null;
782
+ }
783
+ get edgeCount() {
784
+ return this.next.length;
785
+ }
786
+ edge(e) {
787
+ if (e >= this.next.length) throw RangeError(`There's no ${e}th edge in this content match`);
788
+ return this.next[e];
789
+ }
790
+ toString() {
791
+ let e = [];
792
+ function t(n) {
793
+ e.push(n);
794
+ for (let r = 0; r < n.next.length; r++) e.indexOf(n.next[r].next) == -1 && t(n.next[r].next);
795
+ }
796
+ return t(this), e.map((t, n) => {
797
+ let r = n + (t.validEnd ? "*" : " ") + " ";
798
+ for (let n = 0; n < t.next.length; n++) r += (n ? ", " : "") + t.next[n].type.name + "->" + e.indexOf(t.next[n].next);
799
+ return r;
800
+ }).join("\n");
801
+ }
802
+ };
803
+ x.empty = new x(!0);
804
+ var ce = class {
805
+ constructor(e, t) {
806
+ this.string = e, this.nodeTypes = t, this.inline = null, this.pos = 0, this.tokens = e.split(/\s*(?=\b|\W|$)/), this.tokens[this.tokens.length - 1] == "" && this.tokens.pop(), this.tokens[0] == "" && this.tokens.shift();
807
+ }
808
+ get next() {
809
+ return this.tokens[this.pos];
810
+ }
811
+ eat(e) {
812
+ return this.next == e && (this.pos++ || !0);
813
+ }
814
+ err(e) {
815
+ throw SyntaxError(e + " (in content expression '" + this.string + "')");
816
+ }
817
+ };
818
+ function le(e) {
819
+ let t = [];
820
+ do
821
+ t.push(ue(e));
822
+ while (e.eat("|"));
823
+ return t.length == 1 ? t[0] : {
824
+ type: "choice",
825
+ exprs: t
826
+ };
827
+ }
828
+ function ue(e) {
829
+ let t = [];
830
+ do
831
+ t.push(de(e));
832
+ while (e.next && e.next != ")" && e.next != "|");
833
+ return t.length == 1 ? t[0] : {
834
+ type: "seq",
835
+ exprs: t
836
+ };
837
+ }
838
+ function de(e) {
839
+ let t = me(e);
840
+ for (;;) if (e.eat("+")) t = {
841
+ type: "plus",
842
+ expr: t
843
+ };
844
+ else if (e.eat("*")) t = {
845
+ type: "star",
846
+ expr: t
847
+ };
848
+ else if (e.eat("?")) t = {
849
+ type: "opt",
850
+ expr: t
851
+ };
852
+ else if (e.eat("{")) t = fe(e, t);
853
+ else break;
854
+ return t;
855
+ }
856
+ function S(e) {
857
+ /\D/.test(e.next) && e.err("Expected number, got '" + e.next + "'");
858
+ let t = Number(e.next);
859
+ return e.pos++, t;
860
+ }
861
+ function fe(e, t) {
862
+ let n = S(e), r = n;
863
+ return e.eat(",") && (r = e.next == "}" ? -1 : S(e)), e.eat("}") || e.err("Unclosed braced range"), {
864
+ type: "range",
865
+ min: n,
866
+ max: r,
867
+ expr: t
868
+ };
869
+ }
870
+ function pe(e, t) {
871
+ let n = e.nodeTypes, r = n[t];
872
+ if (r) return [r];
873
+ let i = [];
874
+ for (let e in n) {
875
+ let r = n[e];
876
+ r.isInGroup(t) && i.push(r);
877
+ }
878
+ return i.length == 0 && e.err("No node type or group '" + t + "' found"), i;
879
+ }
880
+ function me(e) {
881
+ if (e.eat("(")) {
882
+ let t = le(e);
883
+ return e.eat(")") || e.err("Missing closing paren"), t;
884
+ } else if (/\W/.test(e.next)) e.err("Unexpected token '" + e.next + "'");
885
+ else {
886
+ let t = pe(e, e.next).map((t) => (e.inline == null ? e.inline = t.isInline : e.inline != t.isInline && e.err("Mixing inline and block content"), {
887
+ type: "name",
888
+ value: t
889
+ }));
890
+ return e.pos++, t.length == 1 ? t[0] : {
891
+ type: "choice",
892
+ exprs: t
893
+ };
894
+ }
895
+ }
896
+ function he(e) {
897
+ let t = [[]];
898
+ return i(a(e, 0), n()), t;
899
+ function n() {
900
+ return t.push([]) - 1;
901
+ }
902
+ function r(e, n, r) {
903
+ let i = {
904
+ term: r,
905
+ to: n
906
+ };
907
+ return t[e].push(i), i;
908
+ }
909
+ function i(e, t) {
910
+ e.forEach((e) => e.to = t);
911
+ }
912
+ function a(e, t) {
913
+ if (e.type == "choice") return e.exprs.reduce((e, n) => e.concat(a(n, t)), []);
914
+ if (e.type == "seq") for (let r = 0;; r++) {
915
+ let o = a(e.exprs[r], t);
916
+ if (r == e.exprs.length - 1) return o;
917
+ i(o, t = n());
918
+ }
919
+ else if (e.type == "star") {
920
+ let o = n();
921
+ return r(t, o), i(a(e.expr, o), o), [r(o)];
922
+ } else if (e.type == "plus") {
923
+ let o = n();
924
+ return i(a(e.expr, t), o), i(a(e.expr, o), o), [r(o)];
925
+ } else if (e.type == "opt") return [r(t)].concat(a(e.expr, t));
926
+ else if (e.type == "range") {
927
+ let o = t;
928
+ for (let t = 0; t < e.min; t++) {
929
+ let t = n();
930
+ i(a(e.expr, o), t), o = t;
931
+ }
932
+ if (e.max == -1) i(a(e.expr, o), o);
933
+ else for (let t = e.min; t < e.max; t++) {
934
+ let t = n();
935
+ r(o, t), i(a(e.expr, o), t), o = t;
936
+ }
937
+ return [r(o)];
938
+ } else if (e.type == "name") return [r(t, void 0, e.value)];
939
+ else throw Error("Unknown expr type");
940
+ }
941
+ }
942
+ function C(e, t) {
943
+ return t - e;
944
+ }
945
+ function w(e, t) {
946
+ let n = [];
947
+ return r(t), n.sort(C);
948
+ function r(t) {
949
+ let i = e[t];
950
+ if (i.length == 1 && !i[0].term) return r(i[0].to);
951
+ n.push(t);
952
+ for (let e = 0; e < i.length; e++) {
953
+ let { term: t, to: a } = i[e];
954
+ !t && n.indexOf(a) == -1 && r(a);
955
+ }
956
+ }
957
+ }
958
+ function ge(e) {
959
+ let t = Object.create(null);
960
+ return n(w(e, 0));
961
+ function n(r) {
962
+ let i = [];
963
+ r.forEach((t) => {
964
+ e[t].forEach(({ term: t, to: n }) => {
965
+ if (!t) return;
966
+ let r;
967
+ for (let e = 0; e < i.length; e++) i[e][0] == t && (r = i[e][1]);
968
+ w(e, n).forEach((e) => {
969
+ r || i.push([t, r = []]), r.indexOf(e) == -1 && r.push(e);
970
+ });
971
+ });
972
+ });
973
+ let a = t[r.join(",")] = new x(r.indexOf(e.length - 1) > -1);
974
+ for (let e = 0; e < i.length; e++) {
975
+ let r = i[e][1].sort(C);
976
+ a.next.push({
977
+ type: i[e][0],
978
+ next: t[r.join(",")] || n(r)
979
+ });
980
+ }
981
+ return a;
982
+ }
983
+ }
984
+ function _e(e, t) {
985
+ for (let n = 0, r = [e]; n < r.length; n++) {
986
+ let e = r[n], i = !e.validEnd, a = [];
987
+ for (let t = 0; t < e.next.length; t++) {
988
+ let { type: n, next: o } = e.next[t];
989
+ a.push(n.name), i && !(n.isText || n.hasRequiredAttrs()) && (i = !1), r.indexOf(o) == -1 && r.push(o);
990
+ }
991
+ i && t.err("Only non-generatable nodes (" + a.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)");
992
+ }
993
+ }
994
+ var T = 65535, E = 2 ** 16;
995
+ function ve(e, t) {
996
+ return e + t * E;
997
+ }
998
+ function D(e) {
999
+ return e & T;
1000
+ }
1001
+ function ye(e) {
1002
+ return (e - (e & T)) / E;
1003
+ }
1004
+ var O = 1, k = 2, A = 4, j = 8, M = class {
1005
+ constructor(e, t, n) {
1006
+ this.pos = e, this.delInfo = t, this.recover = n;
1007
+ }
1008
+ get deleted() {
1009
+ return (this.delInfo & j) > 0;
1010
+ }
1011
+ get deletedBefore() {
1012
+ return (this.delInfo & (O | A)) > 0;
1013
+ }
1014
+ get deletedAfter() {
1015
+ return (this.delInfo & (k | A)) > 0;
1016
+ }
1017
+ get deletedAcross() {
1018
+ return (this.delInfo & A) > 0;
1019
+ }
1020
+ }, N = class e {
1021
+ constructor(t, n = !1) {
1022
+ if (this.ranges = t, this.inverted = n, !t.length && e.empty) return e.empty;
1023
+ }
1024
+ recover(e) {
1025
+ let t = 0, n = D(e);
1026
+ if (!this.inverted) for (let e = 0; e < n; e++) t += this.ranges[e * 3 + 2] - this.ranges[e * 3 + 1];
1027
+ return this.ranges[n * 3] + t + ye(e);
1028
+ }
1029
+ mapResult(e, t = 1) {
1030
+ return this._map(e, t, !1);
1031
+ }
1032
+ map(e, t = 1) {
1033
+ return this._map(e, t, !0);
1034
+ }
1035
+ _map(e, t, n) {
1036
+ let r = 0, i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2;
1037
+ for (let o = 0; o < this.ranges.length; o += 3) {
1038
+ let s = this.ranges[o] - (this.inverted ? r : 0);
1039
+ if (s > e) break;
1040
+ let c = this.ranges[o + i], l = this.ranges[o + a], u = s + c;
1041
+ if (e <= u) {
1042
+ let i = c ? e == s ? -1 : e == u ? 1 : t : t, a = s + r + (i < 0 ? 0 : l);
1043
+ if (n) return a;
1044
+ let d = e == (t < 0 ? s : u) ? null : ve(o / 3, e - s), f = e == s ? k : e == u ? O : A;
1045
+ return (t < 0 ? e != s : e != u) && (f |= j), new M(a, f, d);
1046
+ }
1047
+ r += l - c;
1048
+ }
1049
+ return n ? e + r : new M(e + r, 0, null);
1050
+ }
1051
+ touches(e, t) {
1052
+ let n = 0, r = D(t), i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2;
1053
+ for (let t = 0; t < this.ranges.length; t += 3) {
1054
+ let o = this.ranges[t] - (this.inverted ? n : 0);
1055
+ if (o > e) break;
1056
+ let s = this.ranges[t + i];
1057
+ if (e <= o + s && t == r * 3) return !0;
1058
+ n += this.ranges[t + a] - s;
1059
+ }
1060
+ return !1;
1061
+ }
1062
+ forEach(e) {
1063
+ let t = this.inverted ? 2 : 1, n = this.inverted ? 1 : 2;
1064
+ for (let r = 0, i = 0; r < this.ranges.length; r += 3) {
1065
+ let a = this.ranges[r], o = a - (this.inverted ? i : 0), s = a + (this.inverted ? 0 : i), c = this.ranges[r + t], l = this.ranges[r + n];
1066
+ e(o, o + c, s, s + l), i += l - c;
1067
+ }
1068
+ }
1069
+ invert() {
1070
+ return new e(this.ranges, !this.inverted);
1071
+ }
1072
+ toString() {
1073
+ return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
1074
+ }
1075
+ static offset(t) {
1076
+ return t == 0 ? e.empty : new e(t < 0 ? [
1077
+ 0,
1078
+ -t,
1079
+ 0
1080
+ ] : [
1081
+ 0,
1082
+ 0,
1083
+ t
1084
+ ]);
1085
+ }
1086
+ };
1087
+ N.empty = new N([]);
1088
+ var P = Object.create(null), F = class {
1089
+ getMap() {
1090
+ return N.empty;
1091
+ }
1092
+ merge(e) {
1093
+ return null;
1094
+ }
1095
+ static fromJSON(e, t) {
1096
+ if (!t || !t.stepType) throw RangeError("Invalid input for Step.fromJSON");
1097
+ let n = P[t.stepType];
1098
+ if (!n) throw RangeError(`No step type ${t.stepType} defined`);
1099
+ return n.fromJSON(e, t);
1100
+ }
1101
+ static jsonID(e, t) {
1102
+ if (e in P) throw RangeError("Duplicate use of step JSON ID " + e);
1103
+ return P[e] = t, t.prototype.jsonID = e, t;
1104
+ }
1105
+ }, I = class e {
1106
+ constructor(e, t) {
1107
+ this.doc = e, this.failed = t;
1108
+ }
1109
+ static ok(t) {
1110
+ return new e(t, null);
1111
+ }
1112
+ static fail(t) {
1113
+ return new e(null, t);
1114
+ }
1115
+ static fromReplace(t, n, r, i) {
1116
+ try {
1117
+ return e.ok(t.replace(n, r, i));
1118
+ } catch (t) {
1119
+ if (t instanceof s) return e.fail(t.message);
1120
+ throw t;
1121
+ }
1122
+ }
1123
+ };
1124
+ function L(e, t, r) {
1125
+ let i = [];
1126
+ for (let n = 0; n < e.childCount; n++) {
1127
+ let a = e.child(n);
1128
+ a.content.size && (a = a.copy(L(a.content, t, a))), a.isInline && (a = t(a, r, n)), i.push(a);
1129
+ }
1130
+ return n.fromArray(i);
1131
+ }
1132
+ var R = class e extends F {
1133
+ constructor(e, t, n) {
1134
+ super(), this.from = e, this.to = t, this.mark = n;
1135
+ }
1136
+ apply(e) {
1137
+ let t = e.slice(this.from, this.to), n = e.resolve(this.from), r = n.node(n.sharedDepth(this.to)), i = new c(L(t.content, (e, t) => !e.isAtom || !t.type.allowsMarkType(this.mark.type) ? e : e.mark(this.mark.addToSet(e.marks)), r), t.openStart, t.openEnd);
1138
+ return I.fromReplace(e, this.from, this.to, i);
1139
+ }
1140
+ invert() {
1141
+ return new be(this.from, this.to, this.mark);
1142
+ }
1143
+ map(t) {
1144
+ let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
1145
+ return n.deleted && r.deleted || n.pos >= r.pos ? null : new e(n.pos, r.pos, this.mark);
1146
+ }
1147
+ merge(t) {
1148
+ return t instanceof e && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new e(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null;
1149
+ }
1150
+ toJSON() {
1151
+ return {
1152
+ stepType: "addMark",
1153
+ mark: this.mark.toJSON(),
1154
+ from: this.from,
1155
+ to: this.to
1156
+ };
1157
+ }
1158
+ static fromJSON(t, n) {
1159
+ if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for AddMarkStep.fromJSON");
1160
+ return new e(n.from, n.to, t.markFromJSON(n.mark));
1161
+ }
1162
+ };
1163
+ F.jsonID("addMark", R);
1164
+ var be = class e extends F {
1165
+ constructor(e, t, n) {
1166
+ super(), this.from = e, this.to = t, this.mark = n;
1167
+ }
1168
+ apply(e) {
1169
+ let t = e.slice(this.from, this.to), n = new c(L(t.content, (e) => e.mark(this.mark.removeFromSet(e.marks)), e), t.openStart, t.openEnd);
1170
+ return I.fromReplace(e, this.from, this.to, n);
1171
+ }
1172
+ invert() {
1173
+ return new R(this.from, this.to, this.mark);
1174
+ }
1175
+ map(t) {
1176
+ let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
1177
+ return n.deleted && r.deleted || n.pos >= r.pos ? null : new e(n.pos, r.pos, this.mark);
1178
+ }
1179
+ merge(t) {
1180
+ return t instanceof e && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new e(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null;
1181
+ }
1182
+ toJSON() {
1183
+ return {
1184
+ stepType: "removeMark",
1185
+ mark: this.mark.toJSON(),
1186
+ from: this.from,
1187
+ to: this.to
1188
+ };
1189
+ }
1190
+ static fromJSON(t, n) {
1191
+ if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for RemoveMarkStep.fromJSON");
1192
+ return new e(n.from, n.to, t.markFromJSON(n.mark));
1193
+ }
1194
+ };
1195
+ F.jsonID("removeMark", be);
1196
+ var z = class e extends F {
1197
+ constructor(e, t) {
1198
+ super(), this.pos = e, this.mark = t;
1199
+ }
1200
+ apply(e) {
1201
+ let t = e.nodeAt(this.pos);
1202
+ if (!t) return I.fail("No node at mark step's position");
1203
+ let r = t.type.create(t.attrs, null, this.mark.addToSet(t.marks));
1204
+ return I.fromReplace(e, this.pos, this.pos + 1, new c(n.from(r), 0, +!t.isLeaf));
1205
+ }
1206
+ invert(t) {
1207
+ let n = t.nodeAt(this.pos);
1208
+ if (n) {
1209
+ let t = this.mark.addToSet(n.marks);
1210
+ if (t.length == n.marks.length) {
1211
+ for (let r = 0; r < n.marks.length; r++) if (!n.marks[r].isInSet(t)) return new e(this.pos, n.marks[r]);
1212
+ return new e(this.pos, this.mark);
1213
+ }
1214
+ }
1215
+ return new B(this.pos, this.mark);
1216
+ }
1217
+ map(t) {
1218
+ let n = t.mapResult(this.pos, 1);
1219
+ return n.deletedAfter ? null : new e(n.pos, this.mark);
1220
+ }
1221
+ toJSON() {
1222
+ return {
1223
+ stepType: "addNodeMark",
1224
+ pos: this.pos,
1225
+ mark: this.mark.toJSON()
1226
+ };
1227
+ }
1228
+ static fromJSON(t, n) {
1229
+ if (typeof n.pos != "number") throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");
1230
+ return new e(n.pos, t.markFromJSON(n.mark));
1231
+ }
1232
+ };
1233
+ F.jsonID("addNodeMark", z);
1234
+ var B = class e extends F {
1235
+ constructor(e, t) {
1236
+ super(), this.pos = e, this.mark = t;
1237
+ }
1238
+ apply(e) {
1239
+ let t = e.nodeAt(this.pos);
1240
+ if (!t) return I.fail("No node at mark step's position");
1241
+ let r = t.type.create(t.attrs, null, this.mark.removeFromSet(t.marks));
1242
+ return I.fromReplace(e, this.pos, this.pos + 1, new c(n.from(r), 0, +!t.isLeaf));
1243
+ }
1244
+ invert(e) {
1245
+ let t = e.nodeAt(this.pos);
1246
+ return !t || !this.mark.isInSet(t.marks) ? this : new z(this.pos, this.mark);
1247
+ }
1248
+ map(t) {
1249
+ let n = t.mapResult(this.pos, 1);
1250
+ return n.deletedAfter ? null : new e(n.pos, this.mark);
1251
+ }
1252
+ toJSON() {
1253
+ return {
1254
+ stepType: "removeNodeMark",
1255
+ pos: this.pos,
1256
+ mark: this.mark.toJSON()
1257
+ };
1258
+ }
1259
+ static fromJSON(t, n) {
1260
+ if (typeof n.pos != "number") throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
1261
+ return new e(n.pos, t.markFromJSON(n.mark));
1262
+ }
1263
+ };
1264
+ F.jsonID("removeNodeMark", B);
1265
+ var V = class e extends F {
1266
+ constructor(e, t, n, r = !1) {
1267
+ super(), this.from = e, this.to = t, this.slice = n, this.structure = r;
1268
+ }
1269
+ apply(e) {
1270
+ return this.structure && U(e, this.from, this.to) ? I.fail("Structure replace would overwrite content") : I.fromReplace(e, this.from, this.to, this.slice);
1271
+ }
1272
+ getMap() {
1273
+ return new N([
1274
+ this.from,
1275
+ this.to - this.from,
1276
+ this.slice.size
1277
+ ]);
1278
+ }
1279
+ invert(t) {
1280
+ return new e(this.from, this.from + this.slice.size, t.slice(this.from, this.to));
1281
+ }
1282
+ map(t) {
1283
+ let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
1284
+ return n.deletedAcross && r.deletedAcross ? null : new e(n.pos, Math.max(n.pos, r.pos), this.slice, this.structure);
1285
+ }
1286
+ merge(t) {
1287
+ if (!(t instanceof e) || t.structure || this.structure) return null;
1288
+ if (this.from + this.slice.size == t.from && !this.slice.openEnd && !t.slice.openStart) {
1289
+ let n = this.slice.size + t.slice.size == 0 ? c.empty : new c(this.slice.content.append(t.slice.content), this.slice.openStart, t.slice.openEnd);
1290
+ return new e(this.from, this.to + (t.to - t.from), n, this.structure);
1291
+ } else if (t.to == this.from && !this.slice.openStart && !t.slice.openEnd) {
1292
+ let n = this.slice.size + t.slice.size == 0 ? c.empty : new c(t.slice.content.append(this.slice.content), t.slice.openStart, this.slice.openEnd);
1293
+ return new e(t.from, this.to, n, this.structure);
1294
+ } else return null;
1295
+ }
1296
+ toJSON() {
1297
+ let e = {
1298
+ stepType: "replace",
1299
+ from: this.from,
1300
+ to: this.to
1301
+ };
1302
+ return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
1303
+ }
1304
+ static fromJSON(t, n) {
1305
+ if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for ReplaceStep.fromJSON");
1306
+ return new e(n.from, n.to, c.fromJSON(t, n.slice), !!n.structure);
1307
+ }
1308
+ };
1309
+ F.jsonID("replace", V);
1310
+ var H = class e extends F {
1311
+ constructor(e, t, n, r, i, a, o = !1) {
1312
+ super(), this.from = e, this.to = t, this.gapFrom = n, this.gapTo = r, this.slice = i, this.insert = a, this.structure = o;
1313
+ }
1314
+ apply(e) {
1315
+ if (this.structure && (U(e, this.from, this.gapFrom) || U(e, this.gapTo, this.to))) return I.fail("Structure gap-replace would overwrite content");
1316
+ let t = e.slice(this.gapFrom, this.gapTo);
1317
+ if (t.openStart || t.openEnd) return I.fail("Gap is not a flat range");
1318
+ let n = this.slice.insertAt(this.insert, t.content);
1319
+ return n ? I.fromReplace(e, this.from, this.to, n) : I.fail("Content does not fit in gap");
1320
+ }
1321
+ getMap() {
1322
+ return new N([
1323
+ this.from,
1324
+ this.gapFrom - this.from,
1325
+ this.insert,
1326
+ this.gapTo,
1327
+ this.to - this.gapTo,
1328
+ this.slice.size - this.insert
1329
+ ]);
1330
+ }
1331
+ invert(t) {
1332
+ let n = this.gapTo - this.gapFrom;
1333
+ return new e(this.from, this.from + this.slice.size + n, this.from + this.insert, this.from + this.insert + n, t.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
1334
+ }
1335
+ map(t) {
1336
+ let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1), i = this.from == this.gapFrom ? n.pos : t.map(this.gapFrom, -1), a = this.to == this.gapTo ? r.pos : t.map(this.gapTo, 1);
1337
+ return n.deletedAcross && r.deletedAcross || i < n.pos || a > r.pos ? null : new e(n.pos, r.pos, i, a, this.slice, this.insert, this.structure);
1338
+ }
1339
+ toJSON() {
1340
+ let e = {
1341
+ stepType: "replaceAround",
1342
+ from: this.from,
1343
+ to: this.to,
1344
+ gapFrom: this.gapFrom,
1345
+ gapTo: this.gapTo,
1346
+ insert: this.insert
1347
+ };
1348
+ return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
1349
+ }
1350
+ static fromJSON(t, n) {
1351
+ if (typeof n.from != "number" || typeof n.to != "number" || typeof n.gapFrom != "number" || typeof n.gapTo != "number" || typeof n.insert != "number") throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");
1352
+ return new e(n.from, n.to, n.gapFrom, n.gapTo, c.fromJSON(t, n.slice), n.insert, !!n.structure);
1353
+ }
1354
+ };
1355
+ F.jsonID("replaceAround", H);
1356
+ function U(e, t, n) {
1357
+ let r = e.resolve(t), i = n - t, a = r.depth;
1358
+ for (; i > 0 && a > 0 && r.indexAfter(a) == r.node(a).childCount;) a--, i--;
1359
+ if (i > 0) {
1360
+ let e = r.node(a).maybeChild(r.indexAfter(a));
1361
+ for (; i > 0;) {
1362
+ if (!e || e.isLeaf) return !0;
1363
+ e = e.firstChild, i--;
1364
+ }
1365
+ }
1366
+ return !1;
1367
+ }
1368
+ var xe = class e extends F {
1369
+ constructor(e, t, n) {
1370
+ super(), this.pos = e, this.attr = t, this.value = n;
1371
+ }
1372
+ apply(e) {
1373
+ let t = e.nodeAt(this.pos);
1374
+ if (!t) return I.fail("No node at attribute step's position");
1375
+ let r = Object.create(null);
1376
+ for (let e in t.attrs) r[e] = t.attrs[e];
1377
+ r[this.attr] = this.value;
1378
+ let i = t.type.create(r, null, t.marks);
1379
+ return I.fromReplace(e, this.pos, this.pos + 1, new c(n.from(i), 0, +!t.isLeaf));
1380
+ }
1381
+ getMap() {
1382
+ return N.empty;
1383
+ }
1384
+ invert(t) {
1385
+ return new e(this.pos, this.attr, t.nodeAt(this.pos).attrs[this.attr]);
1386
+ }
1387
+ map(t) {
1388
+ let n = t.mapResult(this.pos, 1);
1389
+ return n.deletedAfter ? null : new e(n.pos, this.attr, this.value);
1390
+ }
1391
+ toJSON() {
1392
+ return {
1393
+ stepType: "attr",
1394
+ pos: this.pos,
1395
+ attr: this.attr,
1396
+ value: this.value
1397
+ };
1398
+ }
1399
+ static fromJSON(t, n) {
1400
+ if (typeof n.pos != "number" || typeof n.attr != "string") throw RangeError("Invalid input for AttrStep.fromJSON");
1401
+ return new e(n.pos, n.attr, n.value);
1402
+ }
1403
+ };
1404
+ F.jsonID("attr", xe);
1405
+ var Se = class e extends F {
1406
+ constructor(e, t) {
1407
+ super(), this.attr = e, this.value = t;
1408
+ }
1409
+ apply(e) {
1410
+ let t = Object.create(null);
1411
+ for (let n in e.attrs) t[n] = e.attrs[n];
1412
+ t[this.attr] = this.value;
1413
+ let n = e.type.create(t, e.content, e.marks);
1414
+ return I.ok(n);
1415
+ }
1416
+ getMap() {
1417
+ return N.empty;
1418
+ }
1419
+ invert(t) {
1420
+ return new e(this.attr, t.attrs[this.attr]);
1421
+ }
1422
+ map(e) {
1423
+ return this;
1424
+ }
1425
+ toJSON() {
1426
+ return {
1427
+ stepType: "docAttr",
1428
+ attr: this.attr,
1429
+ value: this.value
1430
+ };
1431
+ }
1432
+ static fromJSON(t, n) {
1433
+ if (typeof n.attr != "string") throw RangeError("Invalid input for DocAttrStep.fromJSON");
1434
+ return new e(n.attr, n.value);
1435
+ }
1436
+ };
1437
+ F.jsonID("docAttr", Se);
1438
+ var W = class extends Error {};
1439
+ W = function e(t) {
1440
+ let n = Error.call(this, t);
1441
+ return n.__proto__ = e.prototype, n;
1442
+ }, W.prototype = Object.create(Error.prototype), W.prototype.constructor = W, W.prototype.name = "TransformError";
1443
+ var G = Object.create(null), K = class {
1444
+ constructor(e, t, n) {
1445
+ this.$anchor = e, this.$head = t, this.ranges = n || [new Ce(e.min(t), e.max(t))];
1446
+ }
1447
+ get anchor() {
1448
+ return this.$anchor.pos;
1449
+ }
1450
+ get head() {
1451
+ return this.$head.pos;
1452
+ }
1453
+ get from() {
1454
+ return this.$from.pos;
1455
+ }
1456
+ get to() {
1457
+ return this.$to.pos;
1458
+ }
1459
+ get $from() {
1460
+ return this.ranges[0].$from;
1461
+ }
1462
+ get $to() {
1463
+ return this.ranges[0].$to;
1464
+ }
1465
+ get empty() {
1466
+ let e = this.ranges;
1467
+ for (let t = 0; t < e.length; t++) if (e[t].$from.pos != e[t].$to.pos) return !1;
1468
+ return !0;
1469
+ }
1470
+ content() {
1471
+ return this.$from.doc.slice(this.from, this.to, !0);
1472
+ }
1473
+ replace(e, t = c.empty) {
1474
+ let n = t.content.lastChild, r = null;
1475
+ for (let e = 0; e < t.openEnd; e++) r = n, n = n.lastChild;
1476
+ let i = e.steps.length, a = this.ranges;
1477
+ for (let o = 0; o < a.length; o++) {
1478
+ let { $from: s, $to: l } = a[o], u = e.mapping.slice(i);
1479
+ e.replaceRange(u.map(s.pos), u.map(l.pos), o ? c.empty : t), o == 0 && Oe(e, i, (n ? n.isInline : r && r.isTextblock) ? -1 : 1);
1480
+ }
1481
+ }
1482
+ replaceWith(e, t) {
1483
+ let n = e.steps.length, r = this.ranges;
1484
+ for (let i = 0; i < r.length; i++) {
1485
+ let { $from: a, $to: o } = r[i], s = e.mapping.slice(n), c = s.map(a.pos), l = s.map(o.pos);
1486
+ i ? e.deleteRange(c, l) : (e.replaceRangeWith(c, l, t), Oe(e, n, t.isInline ? -1 : 1));
1487
+ }
1488
+ }
1489
+ static findFrom(e, t, n = !1) {
1490
+ let r = e.parent.inlineContent ? new q(e) : Z(e.node(0), e.parent, e.pos, e.index(), t, n);
1491
+ if (r) return r;
1492
+ for (let r = e.depth - 1; r >= 0; r--) {
1493
+ let i = t < 0 ? Z(e.node(0), e.node(r), e.before(r + 1), e.index(r), t, n) : Z(e.node(0), e.node(r), e.after(r + 1), e.index(r) + 1, t, n);
1494
+ if (i) return i;
1495
+ }
1496
+ return null;
1497
+ }
1498
+ static near(e, t = 1) {
1499
+ return this.findFrom(e, t) || this.findFrom(e, -t) || new X(e.node(0));
1500
+ }
1501
+ static atStart(e) {
1502
+ return Z(e, e, 0, 0, 1) || new X(e);
1503
+ }
1504
+ static atEnd(e) {
1505
+ return Z(e, e, e.content.size, e.childCount, -1) || new X(e);
1506
+ }
1507
+ static fromJSON(e, t) {
1508
+ if (!t || !t.type) throw RangeError("Invalid input for Selection.fromJSON");
1509
+ let n = G[t.type];
1510
+ if (!n) throw RangeError(`No selection type ${t.type} defined`);
1511
+ return n.fromJSON(e, t);
1512
+ }
1513
+ static jsonID(e, t) {
1514
+ if (e in G) throw RangeError("Duplicate use of selection JSON ID " + e);
1515
+ return G[e] = t, t.prototype.jsonID = e, t;
1516
+ }
1517
+ getBookmark() {
1518
+ return q.between(this.$anchor, this.$head).getBookmark();
1519
+ }
1520
+ };
1521
+ K.prototype.visible = !0;
1522
+ var Ce = class {
1523
+ constructor(e, t) {
1524
+ this.$from = e, this.$to = t;
1525
+ }
1526
+ }, we = !1;
1527
+ function Te(e) {
1528
+ !we && !e.parent.inlineContent && (we = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + e.parent.type.name + ")"));
1529
+ }
1530
+ var q = class e extends K {
1531
+ constructor(e, t = e) {
1532
+ Te(e), Te(t), super(e, t);
1533
+ }
1534
+ get $cursor() {
1535
+ return this.$anchor.pos == this.$head.pos ? this.$head : null;
1536
+ }
1537
+ map(t, n) {
1538
+ let r = t.resolve(n.map(this.head));
1539
+ if (!r.parent.inlineContent) return K.near(r);
1540
+ let i = t.resolve(n.map(this.anchor));
1541
+ return new e(i.parent.inlineContent ? i : r, r);
1542
+ }
1543
+ replace(e, t = c.empty) {
1544
+ if (super.replace(e, t), t == c.empty) {
1545
+ let t = this.$from.marksAcross(this.$to);
1546
+ t && e.ensureMarks(t);
1547
+ }
1548
+ }
1549
+ eq(t) {
1550
+ return t instanceof e && t.anchor == this.anchor && t.head == this.head;
1551
+ }
1552
+ getBookmark() {
1553
+ return new J(this.anchor, this.head);
1554
+ }
1555
+ toJSON() {
1556
+ return {
1557
+ type: "text",
1558
+ anchor: this.anchor,
1559
+ head: this.head
1560
+ };
1561
+ }
1562
+ static fromJSON(t, n) {
1563
+ if (typeof n.anchor != "number" || typeof n.head != "number") throw RangeError("Invalid input for TextSelection.fromJSON");
1564
+ return new e(t.resolve(n.anchor), t.resolve(n.head));
1565
+ }
1566
+ static create(e, t, n = t) {
1567
+ let r = e.resolve(t);
1568
+ return new this(r, n == t ? r : e.resolve(n));
1569
+ }
1570
+ static between(t, n, r) {
1571
+ let i = t.pos - n.pos;
1572
+ if ((!r || i) && (r = i >= 0 ? 1 : -1), !n.parent.inlineContent) {
1573
+ let e = K.findFrom(n, r, !0) || K.findFrom(n, -r, !0);
1574
+ if (e) n = e.$head;
1575
+ else return K.near(n, r);
1576
+ }
1577
+ return t.parent.inlineContent || (i == 0 ? t = n : (t = (K.findFrom(t, -r, !0) || K.findFrom(t, r, !0)).$anchor, t.pos < n.pos != i < 0 && (t = n))), new e(t, n);
1578
+ }
1579
+ };
1580
+ K.jsonID("text", q);
1581
+ var J = class e {
1582
+ constructor(e, t) {
1583
+ this.anchor = e, this.head = t;
1584
+ }
1585
+ map(t) {
1586
+ return new e(t.map(this.anchor), t.map(this.head));
1587
+ }
1588
+ resolve(e) {
1589
+ return q.between(e.resolve(this.anchor), e.resolve(this.head));
1590
+ }
1591
+ }, Y = class e extends K {
1592
+ constructor(e) {
1593
+ let t = e.nodeAfter, n = e.node(0).resolve(e.pos + t.nodeSize);
1594
+ super(e, n), this.node = t;
1595
+ }
1596
+ map(t, n) {
1597
+ let { deleted: r, pos: i } = n.mapResult(this.anchor), a = t.resolve(i);
1598
+ return r ? K.near(a) : new e(a);
1599
+ }
1600
+ content() {
1601
+ return new c(n.from(this.node), 0, 0);
1602
+ }
1603
+ eq(t) {
1604
+ return t instanceof e && t.anchor == this.anchor;
1605
+ }
1606
+ toJSON() {
1607
+ return {
1608
+ type: "node",
1609
+ anchor: this.anchor
1610
+ };
1611
+ }
1612
+ getBookmark() {
1613
+ return new Ee(this.anchor);
1614
+ }
1615
+ static fromJSON(t, n) {
1616
+ if (typeof n.anchor != "number") throw RangeError("Invalid input for NodeSelection.fromJSON");
1617
+ return new e(t.resolve(n.anchor));
1618
+ }
1619
+ static create(t, n) {
1620
+ return new e(t.resolve(n));
1621
+ }
1622
+ static isSelectable(e) {
1623
+ return !e.isText && e.type.spec.selectable !== !1;
1624
+ }
1625
+ };
1626
+ Y.prototype.visible = !1, K.jsonID("node", Y);
1627
+ var Ee = class e {
1628
+ constructor(e) {
1629
+ this.anchor = e;
1630
+ }
1631
+ map(t) {
1632
+ let { deleted: n, pos: r } = t.mapResult(this.anchor);
1633
+ return n ? new J(r, r) : new e(r);
1634
+ }
1635
+ resolve(e) {
1636
+ let t = e.resolve(this.anchor), n = t.nodeAfter;
1637
+ return n && Y.isSelectable(n) ? new Y(t) : K.near(t);
1638
+ }
1639
+ }, X = class e extends K {
1640
+ constructor(e) {
1641
+ super(e.resolve(0), e.resolve(e.content.size));
1642
+ }
1643
+ replace(e, t = c.empty) {
1644
+ if (t == c.empty) {
1645
+ e.delete(0, e.doc.content.size);
1646
+ let t = K.atStart(e.doc);
1647
+ t.eq(e.selection) || e.setSelection(t);
1648
+ } else super.replace(e, t);
1649
+ }
1650
+ toJSON() {
1651
+ return { type: "all" };
1652
+ }
1653
+ static fromJSON(t) {
1654
+ return new e(t);
1655
+ }
1656
+ map(t) {
1657
+ return new e(t);
1658
+ }
1659
+ eq(t) {
1660
+ return t instanceof e;
1661
+ }
1662
+ getBookmark() {
1663
+ return De;
1664
+ }
1665
+ };
1666
+ K.jsonID("all", X);
1667
+ var De = {
1668
+ map() {
1669
+ return this;
1670
+ },
1671
+ resolve(e) {
1672
+ return new X(e);
1673
+ }
1674
+ };
1675
+ function Z(e, t, n, r, i, a = !1) {
1676
+ if (t.inlineContent) return q.create(e, n);
1677
+ for (let o = r - (i > 0 ? 0 : 1); i > 0 ? o < t.childCount : o >= 0; o += i) {
1678
+ let r = t.child(o);
1679
+ if (!r.isAtom) {
1680
+ let t = Z(e, r, n + i, i < 0 ? r.childCount : 0, i, a);
1681
+ if (t) return t;
1682
+ } else if (!a && Y.isSelectable(r)) return Y.create(e, n - (i < 0 ? r.nodeSize : 0));
1683
+ n += r.nodeSize * i;
1684
+ }
1685
+ return null;
1686
+ }
1687
+ function Oe(e, t, n) {
1688
+ let r = e.steps.length - 1;
1689
+ if (r < t) return;
1690
+ let i = e.steps[r];
1691
+ if (!(i instanceof V || i instanceof H)) return;
1692
+ let a = e.mapping.maps[r], o;
1693
+ a.forEach((e, t, n, r) => {
1694
+ o ??= r;
1695
+ }), e.setSelection(K.near(e.doc.resolve(o), n));
1696
+ }
1697
+ function ke(e, t) {
1698
+ return !t || !e ? e : e.bind(t);
1699
+ }
1700
+ var Q = class {
1701
+ constructor(e, t, n) {
1702
+ this.name = e, this.init = ke(t.init, n), this.apply = ke(t.apply, n);
1703
+ }
1704
+ };
1705
+ new Q("doc", {
1706
+ init(e) {
1707
+ return e.doc || e.schema.topNodeType.createAndFill();
1708
+ },
1709
+ apply(e) {
1710
+ return e.doc;
1711
+ }
1712
+ }), new Q("selection", {
1713
+ init(e, t) {
1714
+ return e.selection || K.atStart(t.doc);
1715
+ },
1716
+ apply(e) {
1717
+ return e.selection;
1718
+ }
1719
+ }), new Q("storedMarks", {
1720
+ init(e) {
1721
+ return e.storedMarks || null;
1722
+ },
1723
+ apply(e, t, n, r) {
1724
+ return r.selection.$cursor ? e.storedMarks : null;
1725
+ }
1726
+ }), new Q("scrollToSelection", {
1727
+ init() {
1728
+ return 0;
1729
+ },
1730
+ apply(e, t) {
1731
+ return e.scrolledIntoView ? t + 1 : t;
1732
+ }
1733
+ });
1734
+ var $ = Object.create(null);
1735
+ function Ae(e) {
1736
+ return e in $ ? e + "$" + ++$[e] : ($[e] = 0, e + "$");
1737
+ }
1738
+ var je = class {
1739
+ constructor(e = "key") {
1740
+ this.key = Ae(e);
1741
+ }
1742
+ get(e) {
1743
+ return e.config.pluginsByKey[this.key];
1744
+ }
1745
+ getState(e) {
1746
+ return e[this.key];
1747
+ }
1748
+ };
1749
+ export { je as t };