cli-jaw 2.0.1 → 2.0.2

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 (607) hide show
  1. package/README.ko.md +3 -2
  2. package/README.md +41 -12
  3. package/dist/bin/_http-client.js +34 -0
  4. package/dist/bin/_http-client.js.map +1 -0
  5. package/dist/bin/cli-jaw.js +10 -5
  6. package/dist/bin/cli-jaw.js.map +1 -1
  7. package/dist/bin/commands/browser-web-ai.js +155 -38
  8. package/dist/bin/commands/browser-web-ai.js.map +1 -1
  9. package/dist/bin/commands/browser.js +265 -37
  10. package/dist/bin/commands/browser.js.map +1 -1
  11. package/dist/bin/commands/chat.js +18 -14
  12. package/dist/bin/commands/chat.js.map +1 -1
  13. package/dist/bin/commands/clone.js +3 -2
  14. package/dist/bin/commands/clone.js.map +1 -1
  15. package/dist/bin/commands/dashboard.js +22 -18
  16. package/dist/bin/commands/dashboard.js.map +1 -1
  17. package/dist/bin/commands/dispatch.js +9 -11
  18. package/dist/bin/commands/dispatch.js.map +1 -1
  19. package/dist/bin/commands/doctor.js +26 -14
  20. package/dist/bin/commands/doctor.js.map +1 -1
  21. package/dist/bin/commands/employee.js +12 -7
  22. package/dist/bin/commands/employee.js.map +1 -1
  23. package/dist/bin/commands/init.js +9 -9
  24. package/dist/bin/commands/init.js.map +1 -1
  25. package/dist/bin/commands/launchd.js +17 -7
  26. package/dist/bin/commands/launchd.js.map +1 -1
  27. package/dist/bin/commands/mcp.js +7 -4
  28. package/dist/bin/commands/mcp.js.map +1 -1
  29. package/dist/bin/commands/memory.js +7 -5
  30. package/dist/bin/commands/memory.js.map +1 -1
  31. package/dist/bin/commands/orchestrate.js +6 -3
  32. package/dist/bin/commands/orchestrate.js.map +1 -1
  33. package/dist/bin/commands/reset.js +4 -3
  34. package/dist/bin/commands/reset.js.map +1 -1
  35. package/dist/bin/commands/serve.js +3 -2
  36. package/dist/bin/commands/serve.js.map +1 -1
  37. package/dist/bin/commands/service.js +2 -2
  38. package/dist/bin/commands/service.js.map +1 -1
  39. package/dist/bin/commands/status.js +10 -9
  40. package/dist/bin/commands/status.js.map +1 -1
  41. package/dist/bin/commands/tui/api.js +26 -18
  42. package/dist/bin/commands/tui/api.js.map +1 -1
  43. package/dist/bin/commands/tui/overlays.js +3 -1
  44. package/dist/bin/commands/tui/overlays.js.map +1 -1
  45. package/dist/bin/commands/tui/simple-mode.js +1 -1
  46. package/dist/bin/commands/tui/simple-mode.js.map +1 -1
  47. package/dist/bin/commands/tui/types.js.map +1 -1
  48. package/dist/bin/postinstall.js +153 -65
  49. package/dist/bin/postinstall.js.map +1 -1
  50. package/dist/bin/star-prompt.js +4 -3
  51. package/dist/bin/star-prompt.js.map +1 -1
  52. package/dist/lib/mcp/format-converters.js +15 -10
  53. package/dist/lib/mcp/format-converters.js.map +1 -1
  54. package/dist/lib/mcp/mcp-install.js +2 -2
  55. package/dist/lib/mcp/mcp-install.js.map +1 -1
  56. package/dist/lib/mcp/skills-distribution.js +2 -2
  57. package/dist/lib/mcp/skills-distribution.js.map +1 -1
  58. package/dist/lib/mcp/skills-reset.js +5 -4
  59. package/dist/lib/mcp/skills-reset.js.map +1 -1
  60. package/dist/lib/mcp/skills-symlinks.js +9 -9
  61. package/dist/lib/mcp/skills-symlinks.js.map +1 -1
  62. package/dist/lib/mcp/skills-utils.js +5 -4
  63. package/dist/lib/mcp/skills-utils.js.map +1 -1
  64. package/dist/lib/mcp/unified-config.js +3 -2
  65. package/dist/lib/mcp/unified-config.js.map +1 -1
  66. package/dist/lib/mime-detect.js +65 -0
  67. package/dist/lib/mime-detect.js.map +1 -0
  68. package/dist/lib/quota-copilot.js +12 -10
  69. package/dist/lib/quota-copilot.js.map +1 -1
  70. package/dist/lib/stt.js +3 -3
  71. package/dist/lib/stt.js.map +1 -1
  72. package/dist/lib/upload.js +14 -5
  73. package/dist/lib/upload.js.map +1 -1
  74. package/dist/scripts/i18n-registry.js +4 -4
  75. package/dist/scripts/i18n-registry.js.map +1 -1
  76. package/dist/server.js +61 -57
  77. package/dist/server.js.map +1 -1
  78. package/dist/src/agent/alert-escalation.js +61 -0
  79. package/dist/src/agent/alert-escalation.js.map +1 -0
  80. package/dist/src/agent/args.js +71 -2
  81. package/dist/src/agent/args.js.map +1 -1
  82. package/dist/src/agent/error-classifier.js +9 -4
  83. package/dist/src/agent/error-classifier.js.map +1 -1
  84. package/dist/src/agent/events.js +130 -101
  85. package/dist/src/agent/events.js.map +1 -1
  86. package/dist/src/agent/lifecycle-handler.js +44 -19
  87. package/dist/src/agent/lifecycle-handler.js.map +1 -1
  88. package/dist/src/agent/live-run-state.js +7 -3
  89. package/dist/src/agent/live-run-state.js.map +1 -1
  90. package/dist/src/agent/memory-flush-controller.js +6 -4
  91. package/dist/src/agent/memory-flush-controller.js.map +1 -1
  92. package/dist/src/agent/opencode-diagnostics.js +7 -6
  93. package/dist/src/agent/opencode-diagnostics.js.map +1 -1
  94. package/dist/src/agent/session-persistence.js +1 -1
  95. package/dist/src/agent/session-persistence.js.map +1 -1
  96. package/dist/src/agent/spawn-env.js +33 -16
  97. package/dist/src/agent/spawn-env.js.map +1 -1
  98. package/dist/src/agent/spawn.js +176 -110
  99. package/dist/src/agent/spawn.js.map +1 -1
  100. package/dist/src/agent/watchdog.js +56 -0
  101. package/dist/src/agent/watchdog.js.map +1 -0
  102. package/dist/src/browser/actions.js +179 -70
  103. package/dist/src/browser/actions.js.map +1 -1
  104. package/dist/src/browser/connection.js +296 -19
  105. package/dist/src/browser/connection.js.map +1 -1
  106. package/dist/src/browser/index.js +4 -1
  107. package/dist/src/browser/index.js.map +1 -1
  108. package/dist/src/browser/launch-policy.js +1 -1
  109. package/dist/src/browser/launch-policy.js.map +1 -1
  110. package/dist/src/browser/primitives.js +11 -7
  111. package/dist/src/browser/primitives.js.map +1 -1
  112. package/dist/src/browser/runtime-diagnostics.js +45 -0
  113. package/dist/src/browser/runtime-diagnostics.js.map +1 -0
  114. package/dist/src/browser/runtime-orphans.js +127 -0
  115. package/dist/src/browser/runtime-orphans.js.map +1 -0
  116. package/dist/src/browser/runtime-owner-store.js +51 -0
  117. package/dist/src/browser/runtime-owner-store.js.map +1 -0
  118. package/dist/src/browser/runtime-owner.js +2 -2
  119. package/dist/src/browser/runtime-owner.js.map +1 -1
  120. package/dist/src/browser/tab-lifecycle.js +157 -0
  121. package/dist/src/browser/tab-lifecycle.js.map +1 -0
  122. package/dist/src/browser/vision.js +35 -11
  123. package/dist/src/browser/vision.js.map +1 -1
  124. package/dist/src/browser/web-ai/action-breadth.js +56 -0
  125. package/dist/src/browser/web-ai/action-breadth.js.map +1 -0
  126. package/dist/src/browser/web-ai/action-cache.js +9 -8
  127. package/dist/src/browser/web-ai/action-cache.js.map +1 -1
  128. package/dist/src/browser/web-ai/action-intent.js +64 -0
  129. package/dist/src/browser/web-ai/action-intent.js.map +1 -0
  130. package/dist/src/browser/web-ai/action-memory.js +82 -0
  131. package/dist/src/browser/web-ai/action-memory.js.map +1 -0
  132. package/dist/src/browser/web-ai/action-trace.js +11 -6
  133. package/dist/src/browser/web-ai/action-trace.js.map +1 -1
  134. package/dist/src/browser/web-ai/annotated-screenshot.js +2 -1
  135. package/dist/src/browser/web-ai/annotated-screenshot.js.map +1 -1
  136. package/dist/src/browser/web-ai/answer-artifact.js +97 -0
  137. package/dist/src/browser/web-ai/answer-artifact.js.map +1 -0
  138. package/dist/src/browser/web-ai/ax-snapshot.js +3 -2
  139. package/dist/src/browser/web-ai/ax-snapshot.js.map +1 -1
  140. package/dist/src/browser/web-ai/browser-primitives.js +10 -7
  141. package/dist/src/browser/web-ai/browser-primitives.js.map +1 -1
  142. package/dist/src/browser/web-ai/capability-registry.js +1 -1
  143. package/dist/src/browser/web-ai/capability-registry.js.map +1 -1
  144. package/dist/src/browser/web-ai/chatgpt-composer.js +12 -12
  145. package/dist/src/browser/web-ai/chatgpt-composer.js.map +1 -1
  146. package/dist/src/browser/web-ai/chatgpt-model.js +469 -50
  147. package/dist/src/browser/web-ai/chatgpt-model.js.map +1 -1
  148. package/dist/src/browser/web-ai/chatgpt-response.js +82 -10
  149. package/dist/src/browser/web-ai/chatgpt-response.js.map +1 -1
  150. package/dist/src/browser/web-ai/chatgpt.js +325 -49
  151. package/dist/src/browser/web-ai/chatgpt.js.map +1 -1
  152. package/dist/src/browser/web-ai/churn-log.js +1 -1
  153. package/dist/src/browser/web-ai/churn-log.js.map +1 -1
  154. package/dist/src/browser/web-ai/cli-sessions.js +42 -26
  155. package/dist/src/browser/web-ai/cli-sessions.js.map +1 -1
  156. package/dist/src/browser/web-ai/context-pack/builder.js +1 -1
  157. package/dist/src/browser/web-ai/context-pack/builder.js.map +1 -1
  158. package/dist/src/browser/web-ai/context-pack/file-selector.js +2 -2
  159. package/dist/src/browser/web-ai/context-pack/file-selector.js.map +1 -1
  160. package/dist/src/browser/web-ai/context-pack/report.js +1 -1
  161. package/dist/src/browser/web-ai/context-pack/report.js.map +1 -1
  162. package/dist/src/browser/web-ai/copy-markdown.js +25 -5
  163. package/dist/src/browser/web-ai/copy-markdown.js.map +1 -1
  164. package/dist/src/browser/web-ai/diagnostics.js +17 -14
  165. package/dist/src/browser/web-ai/diagnostics.js.map +1 -1
  166. package/dist/src/browser/web-ai/doctor.js +10 -6
  167. package/dist/src/browser/web-ai/doctor.js.map +1 -1
  168. package/dist/src/browser/web-ai/dom-hash.js.map +1 -1
  169. package/dist/src/browser/web-ai/errors.js +5 -22
  170. package/dist/src/browser/web-ai/errors.js.map +1 -1
  171. package/dist/src/browser/web-ai/gemini-live.js +7 -6
  172. package/dist/src/browser/web-ai/gemini-live.js.map +1 -1
  173. package/dist/src/browser/web-ai/grok-live.js +9 -5
  174. package/dist/src/browser/web-ai/grok-live.js.map +1 -1
  175. package/dist/src/browser/web-ai/index.js +5 -0
  176. package/dist/src/browser/web-ai/index.js.map +1 -1
  177. package/dist/src/browser/web-ai/observation-bundle.js +90 -0
  178. package/dist/src/browser/web-ai/observation-bundle.js.map +1 -0
  179. package/dist/src/browser/web-ai/observe-actions.js +186 -0
  180. package/dist/src/browser/web-ai/observe-actions.js.map +1 -0
  181. package/dist/src/browser/web-ai/observe-targets.js +6 -1
  182. package/dist/src/browser/web-ai/observe-targets.js.map +1 -1
  183. package/dist/src/browser/web-ai/planner-contract.js +18 -0
  184. package/dist/src/browser/web-ai/planner-contract.js.map +1 -0
  185. package/dist/src/browser/web-ai/post-action-assert.js +8 -7
  186. package/dist/src/browser/web-ai/post-action-assert.js.map +1 -1
  187. package/dist/src/browser/web-ai/product-surfaces.js +2 -1
  188. package/dist/src/browser/web-ai/product-surfaces.js.map +1 -1
  189. package/dist/src/browser/web-ai/provider-adapter.js.map +1 -1
  190. package/dist/src/browser/web-ai/question.js +14 -7
  191. package/dist/src/browser/web-ai/question.js.map +1 -1
  192. package/dist/src/browser/web-ai/ref-registry.js.map +1 -1
  193. package/dist/src/browser/web-ai/self-heal.js +20 -14
  194. package/dist/src/browser/web-ai/self-heal.js.map +1 -1
  195. package/dist/src/browser/web-ai/session-store.js +61 -1
  196. package/dist/src/browser/web-ai/session-store.js.map +1 -1
  197. package/dist/src/browser/web-ai/session.js +43 -2
  198. package/dist/src/browser/web-ai/session.js.map +1 -1
  199. package/dist/src/browser/web-ai/source-audit.js +116 -0
  200. package/dist/src/browser/web-ai/source-audit.js.map +1 -0
  201. package/dist/src/browser/web-ai/tab-finalizer.js +18 -0
  202. package/dist/src/browser/web-ai/tab-finalizer.js.map +1 -0
  203. package/dist/src/browser/web-ai/tab-lease-store.js +390 -0
  204. package/dist/src/browser/web-ai/tab-lease-store.js.map +1 -0
  205. package/dist/src/browser/web-ai/tab-pool.js +44 -0
  206. package/dist/src/browser/web-ai/tab-pool.js.map +1 -0
  207. package/dist/src/browser/web-ai/target-resolver.js +31 -0
  208. package/dist/src/browser/web-ai/target-resolver.js.map +1 -0
  209. package/dist/src/browser/web-ai/trace-persistence.js +4 -2
  210. package/dist/src/browser/web-ai/trace-persistence.js.map +1 -1
  211. package/dist/src/browser/web-ai/vendor-editor-contract.js.map +1 -1
  212. package/dist/src/browser/web-ai/watcher.js +8 -7
  213. package/dist/src/browser/web-ai/watcher.js.map +1 -1
  214. package/dist/src/cli/acp-client.js +40 -26
  215. package/dist/src/cli/acp-client.js.map +1 -1
  216. package/dist/src/cli/command-context.js +3 -3
  217. package/dist/src/cli/command-context.js.map +1 -1
  218. package/dist/src/cli/commands.js +25 -16
  219. package/dist/src/cli/commands.js.map +1 -1
  220. package/dist/src/cli/compact.js.map +1 -1
  221. package/dist/src/cli/handlers-completions.js +6 -4
  222. package/dist/src/cli/handlers-completions.js.map +1 -1
  223. package/dist/src/cli/handlers-runtime.js +45 -38
  224. package/dist/src/cli/handlers-runtime.js.map +1 -1
  225. package/dist/src/cli/handlers.js +44 -36
  226. package/dist/src/cli/handlers.js.map +1 -1
  227. package/dist/src/cli/readiness.js +3 -1
  228. package/dist/src/cli/readiness.js.map +1 -1
  229. package/dist/src/cli/registry.js +1 -1
  230. package/dist/src/cli/registry.js.map +1 -1
  231. package/dist/src/cli/tui/overlay.js +4 -1
  232. package/dist/src/cli/tui/overlay.js.map +1 -1
  233. package/dist/src/cli/types.js +4 -0
  234. package/dist/src/cli/types.js.map +1 -0
  235. package/dist/src/command-contract/catalog.js +1 -1
  236. package/dist/src/command-contract/catalog.js.map +1 -1
  237. package/dist/src/command-contract/help-renderer.js +1 -1
  238. package/dist/src/command-contract/help-renderer.js.map +1 -1
  239. package/dist/src/core/browser-open-default.js +13 -0
  240. package/dist/src/core/browser-open-default.js.map +1 -0
  241. package/dist/src/core/browser-open.js +41 -0
  242. package/dist/src/core/browser-open.js.map +1 -0
  243. package/dist/src/core/bus.js +13 -2
  244. package/dist/src/core/bus.js.map +1 -1
  245. package/dist/src/core/compact.js +5 -4
  246. package/dist/src/core/compact.js.map +1 -1
  247. package/dist/src/core/config.js +51 -52
  248. package/dist/src/core/config.js.map +1 -1
  249. package/dist/src/core/db.js +48 -6
  250. package/dist/src/core/db.js.map +1 -1
  251. package/dist/src/core/employees.js +9 -8
  252. package/dist/src/core/employees.js.map +1 -1
  253. package/dist/src/core/instance.js +7 -6
  254. package/dist/src/core/instance.js.map +1 -1
  255. package/dist/src/core/logger.js +1 -1
  256. package/dist/src/core/logger.js.map +1 -1
  257. package/dist/src/core/main-session.js +7 -7
  258. package/dist/src/core/main-session.js.map +1 -1
  259. package/dist/src/core/path-expand.js +10 -0
  260. package/dist/src/core/path-expand.js.map +1 -0
  261. package/dist/src/core/runtime-path.js +1 -1
  262. package/dist/src/core/runtime-path.js.map +1 -1
  263. package/dist/src/core/runtime-settings.js +13 -13
  264. package/dist/src/core/runtime-settings.js.map +1 -1
  265. package/dist/src/core/settings-merge.js +14 -14
  266. package/dist/src/core/settings-merge.js.map +1 -1
  267. package/dist/src/core/strip-undefined.js +13 -0
  268. package/dist/src/core/strip-undefined.js.map +1 -0
  269. package/dist/src/core/tcc.js +1 -1
  270. package/dist/src/core/tcc.js.map +1 -1
  271. package/dist/src/discord/bot.js +19 -18
  272. package/dist/src/discord/bot.js.map +1 -1
  273. package/dist/src/discord/channel-types.js +14 -0
  274. package/dist/src/discord/channel-types.js.map +1 -0
  275. package/dist/src/discord/commands.js +7 -6
  276. package/dist/src/discord/commands.js.map +1 -1
  277. package/dist/src/discord/discord-file.js.map +1 -1
  278. package/dist/src/discord/forwarder.js +3 -3
  279. package/dist/src/discord/forwarder.js.map +1 -1
  280. package/dist/src/http/error-middleware.js +3 -3
  281. package/dist/src/http/error-middleware.js.map +1 -1
  282. package/dist/src/http/response.js +2 -2
  283. package/dist/src/http/response.js.map +1 -1
  284. package/dist/src/ide/diff.js +7 -7
  285. package/dist/src/ide/diff.js.map +1 -1
  286. package/dist/src/manager/board/routes.js +28 -27
  287. package/dist/src/manager/board/routes.js.map +1 -1
  288. package/dist/src/manager/dashboard-home.js +3 -5
  289. package/dist/src/manager/dashboard-home.js.map +1 -1
  290. package/dist/src/manager/dashboard-service.js +2 -2
  291. package/dist/src/manager/dashboard-service.js.map +1 -1
  292. package/dist/src/manager/health-history.js +10 -9
  293. package/dist/src/manager/health-history.js.map +1 -1
  294. package/dist/src/manager/launchd-service.js +2 -2
  295. package/dist/src/manager/launchd-service.js.map +1 -1
  296. package/dist/src/manager/lifecycle-helpers.js +7 -6
  297. package/dist/src/manager/lifecycle-helpers.js.map +1 -1
  298. package/dist/src/manager/lifecycle.js +7 -6
  299. package/dist/src/manager/lifecycle.js.map +1 -1
  300. package/dist/src/manager/logs.js +18 -18
  301. package/dist/src/manager/logs.js.map +1 -1
  302. package/dist/src/manager/metadata.js +10 -2
  303. package/dist/src/manager/metadata.js.map +1 -1
  304. package/dist/src/manager/notes/assets.js +216 -0
  305. package/dist/src/manager/notes/assets.js.map +1 -0
  306. package/dist/src/manager/notes/capabilities.js +56 -0
  307. package/dist/src/manager/notes/capabilities.js.map +1 -0
  308. package/dist/src/manager/notes/constants.js +11 -0
  309. package/dist/src/manager/notes/constants.js.map +1 -0
  310. package/dist/src/manager/notes/frontmatter.js +120 -0
  311. package/dist/src/manager/notes/frontmatter.js.map +1 -0
  312. package/dist/src/manager/notes/link-resolver.js +96 -0
  313. package/dist/src/manager/notes/link-resolver.js.map +1 -0
  314. package/dist/src/manager/notes/path-guards.js +4 -0
  315. package/dist/src/manager/notes/path-guards.js.map +1 -1
  316. package/dist/src/manager/notes/remote-assets.js +128 -0
  317. package/dist/src/manager/notes/remote-assets.js.map +1 -0
  318. package/dist/src/manager/notes/routes.js +63 -13
  319. package/dist/src/manager/notes/routes.js.map +1 -1
  320. package/dist/src/manager/notes/store.js +3 -2
  321. package/dist/src/manager/notes/store.js.map +1 -1
  322. package/dist/src/manager/notes/system-trash.js +3 -3
  323. package/dist/src/manager/notes/system-trash.js.map +1 -1
  324. package/dist/src/manager/notes/vault-index.js +220 -0
  325. package/dist/src/manager/notes/vault-index.js.map +1 -0
  326. package/dist/src/manager/notes/watcher.js +27 -0
  327. package/dist/src/manager/notes/watcher.js.map +1 -0
  328. package/dist/src/manager/notes/wiki-links.js +109 -0
  329. package/dist/src/manager/notes/wiki-links.js.map +1 -0
  330. package/dist/src/manager/process-verify.js +29 -0
  331. package/dist/src/manager/process-verify.js.map +1 -1
  332. package/dist/src/manager/profiles.js +3 -2
  333. package/dist/src/manager/profiles.js.map +1 -1
  334. package/dist/src/manager/registry.js +60 -58
  335. package/dist/src/manager/registry.js.map +1 -1
  336. package/dist/src/manager/routes/electron-metrics.js +22 -22
  337. package/dist/src/manager/routes/electron-metrics.js.map +1 -1
  338. package/dist/src/manager/scan.js +2 -2
  339. package/dist/src/manager/scan.js.map +1 -1
  340. package/dist/src/manager/schedule/routes.js +24 -23
  341. package/dist/src/manager/schedule/routes.js.map +1 -1
  342. package/dist/src/manager/server.js +28 -28
  343. package/dist/src/manager/server.js.map +1 -1
  344. package/dist/src/manager/systemd-service.js +1 -1
  345. package/dist/src/manager/systemd-service.js.map +1 -1
  346. package/dist/src/memory/bootstrap.js +5 -4
  347. package/dist/src/memory/bootstrap.js.map +1 -1
  348. package/dist/src/memory/heartbeat-schedule.js +10 -10
  349. package/dist/src/memory/heartbeat-schedule.js.map +1 -1
  350. package/dist/src/memory/heartbeat.js +23 -22
  351. package/dist/src/memory/heartbeat.js.map +1 -1
  352. package/dist/src/memory/indexing.js.map +1 -1
  353. package/dist/src/memory/keyword-expand.js +1 -1
  354. package/dist/src/memory/keyword-expand.js.map +1 -1
  355. package/dist/src/memory/memory.js +2 -2
  356. package/dist/src/memory/memory.js.map +1 -1
  357. package/dist/src/memory/runtime.js +6 -5
  358. package/dist/src/memory/runtime.js.map +1 -1
  359. package/dist/src/memory/shared.js +2 -1
  360. package/dist/src/memory/shared.js.map +1 -1
  361. package/dist/src/memory/worklog.js +1 -1
  362. package/dist/src/memory/worklog.js.map +1 -1
  363. package/dist/src/messaging/runtime.js +13 -10
  364. package/dist/src/messaging/runtime.js.map +1 -1
  365. package/dist/src/messaging/send.js +16 -15
  366. package/dist/src/messaging/send.js.map +1 -1
  367. package/dist/src/orchestrator/collect.js +6 -6
  368. package/dist/src/orchestrator/collect.js.map +1 -1
  369. package/dist/src/orchestrator/distribute.js +112 -77
  370. package/dist/src/orchestrator/distribute.js.map +1 -1
  371. package/dist/src/orchestrator/gateway.js +6 -5
  372. package/dist/src/orchestrator/gateway.js.map +1 -1
  373. package/dist/src/orchestrator/pipeline.js +42 -42
  374. package/dist/src/orchestrator/pipeline.js.map +1 -1
  375. package/dist/src/orchestrator/state-machine.js +3 -3
  376. package/dist/src/orchestrator/state-machine.js.map +1 -1
  377. package/dist/src/orchestrator/worker-registry.js +4 -3
  378. package/dist/src/orchestrator/worker-registry.js.map +1 -1
  379. package/dist/src/prompt/builder.js +24 -19
  380. package/dist/src/prompt/builder.js.map +1 -1
  381. package/dist/src/prompt/templates/a1-system.md +15 -10
  382. package/dist/src/prompt/templates/control-system.md +9 -7
  383. package/dist/src/prompt/templates/employee.md +5 -4
  384. package/dist/src/prompt/templates/vision-click.md +1 -1
  385. package/dist/src/routes/_http-error.js +15 -0
  386. package/dist/src/routes/_http-error.js.map +1 -0
  387. package/dist/src/routes/avatar.js +6 -5
  388. package/dist/src/routes/avatar.js.map +1 -1
  389. package/dist/src/routes/browser.js +132 -45
  390. package/dist/src/routes/browser.js.map +1 -1
  391. package/dist/src/routes/employees.js +28 -21
  392. package/dist/src/routes/employees.js.map +1 -1
  393. package/dist/src/routes/heartbeat.js +12 -9
  394. package/dist/src/routes/heartbeat.js.map +1 -1
  395. package/dist/src/routes/i18n.js +13 -7
  396. package/dist/src/routes/i18n.js.map +1 -1
  397. package/dist/src/routes/jaw-memory.js +15 -11
  398. package/dist/src/routes/jaw-memory.js.map +1 -1
  399. package/dist/src/routes/memory.js +25 -20
  400. package/dist/src/routes/memory.js.map +1 -1
  401. package/dist/src/routes/messaging.js +50 -29
  402. package/dist/src/routes/messaging.js.map +1 -1
  403. package/dist/src/routes/orchestrate.js +38 -24
  404. package/dist/src/routes/orchestrate.js.map +1 -1
  405. package/dist/src/routes/quota.js +81 -17
  406. package/dist/src/routes/quota.js.map +1 -1
  407. package/dist/src/routes/settings.js +28 -18
  408. package/dist/src/routes/settings.js.map +1 -1
  409. package/dist/src/routes/skills.js +22 -13
  410. package/dist/src/routes/skills.js.map +1 -1
  411. package/dist/src/routes/traces.js +77 -0
  412. package/dist/src/routes/traces.js.map +1 -0
  413. package/dist/src/security/path-guards.js +2 -1
  414. package/dist/src/security/path-guards.js.map +1 -1
  415. package/dist/src/shared/tool-log-sanitize.js +191 -0
  416. package/dist/src/shared/tool-log-sanitize.js.map +1 -0
  417. package/dist/src/telegram/bot.js +65 -55
  418. package/dist/src/telegram/bot.js.map +1 -1
  419. package/dist/src/telegram/forwarder.js +5 -9
  420. package/dist/src/telegram/forwarder.js.map +1 -1
  421. package/dist/src/telegram/telegram-file.js +28 -24
  422. package/dist/src/telegram/telegram-file.js.map +1 -1
  423. package/dist/src/telegram/voice.js +4 -3
  424. package/dist/src/telegram/voice.js.map +1 -1
  425. package/dist/src/trace/redact.js +50 -0
  426. package/dist/src/trace/redact.js.map +1 -0
  427. package/dist/src/trace/store.js +162 -0
  428. package/dist/src/trace/store.js.map +1 -0
  429. package/dist/src/trace/types.js +2 -0
  430. package/dist/src/trace/types.js.map +1 -0
  431. package/dist/src/types/cli-engine.js +34 -0
  432. package/dist/src/types/cli-engine.js.map +1 -0
  433. package/dist/src/types/cli-events.js +31 -0
  434. package/dist/src/types/cli-events.js.map +1 -0
  435. package/package.json +22 -2
  436. package/public/css/tool-ui.css +3 -1
  437. package/public/css/trace-drawer.css +48 -0
  438. package/public/dist/assets/{AdvancedExport-3WAYIabE.js → AdvancedExport-DJZ2VmBR.js} +1 -1
  439. package/public/dist/assets/Agent-CgpLT8IY.js +1 -0
  440. package/public/dist/assets/Browser-CrkiQoB8.js +1 -0
  441. package/public/dist/assets/{ChannelsDiscord-UzFPlWT4.js → ChannelsDiscord-CVUC22D4.js} +1 -1
  442. package/public/dist/assets/{ChannelsTelegram-DNWtPX0w.js → ChannelsTelegram-DEatIQNM.js} +1 -1
  443. package/public/dist/assets/{DashboardMeta-Y_6nVeJO.js → DashboardMeta-BKoxRc7i.js} +1 -1
  444. package/public/dist/assets/{Display-D8vGOl4s.js → Display-DnNGV9Km.js} +1 -1
  445. package/public/dist/assets/{Employees-YR_sIRK4.js → Employees-DZ2iJYKy.js} +1 -1
  446. package/public/dist/assets/{HealthBadge-CPePajyU.js → HealthBadge-Cq2c7G9s.js} +1 -1
  447. package/public/dist/assets/{Heartbeat-DTpAULQR.js → Heartbeat-BML6eTXZ.js} +1 -1
  448. package/public/dist/assets/{Mcp-DM-PgG6z.js → Mcp-BlEviQ3h.js} +1 -1
  449. package/public/dist/assets/{Memory-C_LvJnkn.js → Memory-BRyH80He.js} +1 -1
  450. package/public/dist/assets/MilkdownWysiwygEditor-Cm3uXfWf.js +52 -0
  451. package/public/dist/assets/ModelProvider-DxyR7EL9.js +1 -0
  452. package/public/dist/assets/Network-DDOOESh1.js +1 -0
  453. package/public/dist/assets/{Permissions-B1naJjjw.js → Permissions-Br0eSbKb.js} +1 -1
  454. package/public/dist/assets/{Permissions-BKffrMJD.js → Permissions-QHkzStqQ.js} +1 -1
  455. package/public/dist/assets/{Profile-DIqjSe2C.js → Profile-C79NKumk.js} +1 -1
  456. package/public/dist/assets/{Prompts-BMfbV6Y4.js → Prompts-BmiIDiXW.js} +1 -1
  457. package/public/dist/assets/{SpeechKeys-DjiQTzSL.js → SpeechKeys-B8304XJK.js} +1 -1
  458. package/public/dist/assets/app-Be58Cs3Y.js +32 -0
  459. package/public/dist/assets/{app-BzvwJJiv.css → app-CphocJzo.css} +1 -1
  460. package/public/dist/assets/{dist-DTvxN3ux.js → dist-BD0UXfgF2.js} +1 -1
  461. package/public/dist/assets/{dist-CASeq-Tl.js → dist-BNfXO3Yr.js} +1 -1
  462. package/public/dist/assets/{dist-BMPiaUzF.js → dist-BUnPYbK3.js} +1 -1
  463. package/public/dist/assets/{dist-CT_X3hVT.js → dist-BZosRD2u.js} +1 -1
  464. package/public/dist/assets/{dist-4J6YbNXv.js → dist-Bd9PlnQm.js} +1 -1
  465. package/public/dist/assets/{dist-BcZjyn5g.js → dist-BsT5UdNP.js} +1 -1
  466. package/public/dist/assets/{dist-BfBhOPR-.js → dist-CIuXW-sc.js} +1 -1
  467. package/public/dist/assets/{dist-BMiCig3A2.js → dist-CL4PTYWf.js} +1 -1
  468. package/public/dist/assets/{dist-VyP6-HLb.js → dist-Ch5VAlV9.js} +1 -1
  469. package/public/dist/assets/dist-ClqO40BE.js +1 -0
  470. package/public/dist/assets/{dist-c98Tp7bP.js → dist-Cp42cMcI.js} +1 -1
  471. package/public/dist/assets/{dist-CIlYL1qe.js → dist-CpUK8ypo.js} +1 -1
  472. package/public/dist/assets/dist-CxeLAw2Y.js +1 -0
  473. package/public/dist/assets/dist-D2SH8nxa.js +1 -0
  474. package/public/dist/assets/{dist-84fwQ7bO.js → dist-D6cUXP7K.js} +1 -1
  475. package/public/dist/assets/{dist-BOCcQAyF.js → dist-D7bCuS3f.js} +1 -1
  476. package/public/dist/assets/{dist-DMmpfLVP.js → dist-DFYRUAjN.js} +1 -1
  477. package/public/dist/assets/{dist-DdY6pTJr.js → dist-DZsFVYF4.js} +1 -1
  478. package/public/dist/assets/{dist-B0p3Eyme.js → dist-Db16ogVk.js} +1 -1
  479. package/public/dist/assets/{dist-DlnNtr6L.js → dist-DfodGES_.js} +1 -1
  480. package/public/dist/assets/{dist-DO9so2a2.js → dist-SU-YTAIg.js} +1 -1
  481. package/public/dist/assets/{dist-DUjXiMLP.js → dist-UYn7T-GH.js} +1 -1
  482. package/public/dist/assets/{dist-BW1409rz.js → dist-W51oDoeA.js} +1 -1
  483. package/public/dist/assets/{dist-BimBQZx1.js → dist-eU7TyC86.js} +1 -1
  484. package/public/dist/assets/dist-l9HH00ip.js +1 -0
  485. package/public/dist/assets/{dist-BrOPNxdH.js → dist-urPTQzXL.js} +1 -1
  486. package/public/dist/assets/{dist-AloEV3J52.js → dist-yHP6L0Ty.js} +1 -1
  487. package/public/dist/assets/{employees-Bbabvbyx.js → employees-CxdghzoD.js} +7 -7
  488. package/public/dist/assets/{error-normalize-DdvKGLt_.js → error-normalize-5n-zlEQ3.js} +1 -1
  489. package/public/dist/assets/insert-image-markdown-DIEa-zjk.js +22 -0
  490. package/public/dist/assets/{manager-DyB2ZUr9.css → manager-DEiyrWDP.css} +1 -1
  491. package/public/dist/assets/manager-UEXd1_9T.js +25 -0
  492. package/public/dist/assets/{memory-B_plvcuQ.js → memory-CsMNkYtv.js} +9 -9
  493. package/public/dist/assets/memory-DXad_DPO.js +1 -0
  494. package/public/dist/assets/{page-shell-DML_HneX.js → page-shell-D5tbivHH.js} +1 -1
  495. package/public/dist/assets/{render-DEhbfUAW.js → render-DGQX46ei.js} +2 -2
  496. package/public/dist/assets/{settings-D7F-_kYG.js → settings-BH213Yv3.js} +14 -14
  497. package/public/dist/assets/settings-DXT87G2U.js +1 -0
  498. package/public/dist/assets/settings-client-ajlwI-oK.js +1 -0
  499. package/public/dist/assets/skills-5o_1v0nz.js +1 -0
  500. package/public/dist/assets/{skills-DoGJOc0D.js → skills-CQtCtHPA.js} +6 -6
  501. package/public/dist/assets/slash-commands-D4-hrrmh.js +1 -0
  502. package/public/dist/assets/{slash-commands-khNFPOyF.js → slash-commands-Dzk1xHWS.js} +1 -1
  503. package/public/dist/assets/trace-drawer-SRKcfm2S.js +15 -0
  504. package/public/dist/assets/ui-CdRKN2S6.js +141 -0
  505. package/public/dist/assets/ui-n43jmg_f.js +1 -0
  506. package/public/dist/assets/{ws-B2aJ-nD2.js → ws-CTHQFzM1.js} +8 -8
  507. package/public/dist/index.html +2 -2
  508. package/public/dist/manager/index.html +2 -2
  509. package/public/index.html +1 -0
  510. package/public/js/constants.ts +5 -5
  511. package/public/js/diagram/iframe-renderer.ts +11 -11
  512. package/public/js/features/chat.ts +1 -1
  513. package/public/js/features/memory.ts +10 -10
  514. package/public/js/features/pending-queue.ts +2 -2
  515. package/public/js/features/process-block.ts +257 -29
  516. package/public/js/features/process-step-match.ts +18 -0
  517. package/public/js/features/settings-cli-status.ts +1 -1
  518. package/public/js/features/settings-stt.ts +37 -11
  519. package/public/js/features/settings-templates.ts +2 -2
  520. package/public/js/features/slash-commands.ts +1 -1
  521. package/public/js/features/tool-ui.ts +13 -7
  522. package/public/js/features/trace-drawer.ts +122 -0
  523. package/public/js/icons.ts +1 -1
  524. package/public/js/main.ts +28 -28
  525. package/public/js/provider-icons.ts +1 -1
  526. package/public/js/render.ts +29 -27
  527. package/public/js/sanitizer.ts +4 -0
  528. package/public/js/ui.ts +234 -68
  529. package/public/js/virtual-scroll.ts +19 -33
  530. package/public/js/ws.ts +22 -10
  531. package/public/manager/src/App.tsx +34 -6
  532. package/public/manager/src/api.ts +55 -1
  533. package/public/manager/src/components/ActivityTimeline.tsx +1 -1
  534. package/public/manager/src/components/InstanceDetailPanel.tsx +2 -2
  535. package/public/manager/src/components/InstanceGroups.tsx +5 -5
  536. package/public/manager/src/components/InstanceListContent.tsx +1 -1
  537. package/public/manager/src/dashboard-features.ts +1 -1
  538. package/public/manager/src/manager-notes.css +49 -2
  539. package/public/manager/src/notes/MarkdownEditor.tsx +7 -3
  540. package/public/manager/src/notes/NotesFileTree.tsx +45 -6
  541. package/public/manager/src/notes/NotesSidebar.tsx +24 -55
  542. package/public/manager/src/notes/NotesWorkspace.tsx +50 -3
  543. package/public/manager/src/notes/image-assets/clipboard-images.ts +100 -0
  544. package/public/manager/src/notes/image-assets/insert-image-markdown.ts +85 -0
  545. package/public/manager/src/notes/notes-api.ts +2 -0
  546. package/public/manager/src/notes/notes-types.ts +8 -1
  547. package/public/manager/src/notes/rendering/MarkdownRenderer.tsx +6 -0
  548. package/public/manager/src/notes/rendering/markdown-render-security.ts +19 -1
  549. package/public/manager/src/notes/rich-markdown/paste-policy.ts +6 -2
  550. package/public/manager/src/notes/rich-markdown/rich-markdown-extension.ts +5 -5
  551. package/public/manager/src/notes/rich-markdown/rich-widget.ts +8 -8
  552. package/public/manager/src/notes/useNotesExternalSync.ts +37 -0
  553. package/public/manager/src/notes/useNotesModel.ts +91 -0
  554. package/public/manager/src/notes/wysiwyg/MilkdownWysiwygEditor.tsx +157 -17
  555. package/public/manager/src/notes/wysiwyg/milkdown-block-keymap.ts +14 -2
  556. package/public/manager/src/notes/wysiwyg/milkdown-code-block-view.ts +20 -20
  557. package/public/manager/src/notes/wysiwyg/milkdown-heading-source-view.ts +8 -8
  558. package/public/manager/src/notes/wysiwyg/milkdown-math.ts +25 -25
  559. package/public/manager/src/settings/pages/Browser.tsx +38 -20
  560. package/public/manager/src/settings/pages/ModelProvider.tsx +11 -9
  561. package/public/manager/src/settings/pages/Network.tsx +10 -10
  562. package/public/manager/src/settings/pages/components/HealthBadge.tsx +12 -12
  563. package/public/manager/src/settings/pages/components/agent/runtime-employees-helpers.ts +12 -10
  564. package/public/manager/src/settings/pages/components/employees-helpers.ts +9 -9
  565. package/public/manager/src/settings/pages/components/heartbeat-helpers.ts +13 -13
  566. package/public/manager/src/settings/pages/components/memory-helpers.ts +4 -4
  567. package/public/manager/src/settings/pages/mcp-helpers.ts +7 -7
  568. package/public/manager/src/settings/settings-client.ts +4 -3
  569. package/public/manager/src/sync/IframeBridge.tsx +29 -0
  570. package/public/manager/src/sync/VisibilityBridge.tsx +24 -0
  571. package/public/manager/src/sync/invalidation-bus.ts +30 -0
  572. package/public/manager/src/sync/useInvalidationSubscription.ts +19 -0
  573. package/public/manager/src/types.ts +101 -0
  574. package/scripts/check-strict-baseline.mjs +255 -0
  575. package/scripts/claim-audit.mjs +159 -0
  576. package/scripts/i18n-registry.ts +4 -4
  577. package/scripts/install-officecli.sh +2 -2
  578. package/scripts/install-wsl.sh +2 -1
  579. package/scripts/release-gates.mjs +347 -0
  580. package/scripts/release-preview.sh +3 -0
  581. package/scripts/release.sh +4 -0
  582. package/scripts/smoke/opencode-external-dir-smoke.ts +14 -5
  583. package/public/dist/assets/Agent-BYdzZwD0.js +0 -1
  584. package/public/dist/assets/Browser-CkGeczuN.js +0 -1
  585. package/public/dist/assets/MilkdownWysiwygEditor-B7k9bAey.js +0 -52
  586. package/public/dist/assets/ModelProvider-CX3Qhowu.js +0 -1
  587. package/public/dist/assets/Network-DfPLFAvw.js +0 -1
  588. package/public/dist/assets/app-DLYoRkU9.js +0 -32
  589. package/public/dist/assets/dist-8zNAQAIa.js +0 -1
  590. package/public/dist/assets/dist-BgeY6nvK.js +0 -1
  591. package/public/dist/assets/dist-BzDGGxHQ.js +0 -1
  592. package/public/dist/assets/dist-D3YKbVi-.js +0 -1
  593. package/public/dist/assets/manager-CUSgFbMO.js +0 -25
  594. package/public/dist/assets/markdown-render-security-DJfJPWO-.js +0 -22
  595. package/public/dist/assets/memory-DQ6dU0qs.js +0 -1
  596. package/public/dist/assets/settings-DxLPUbpj.js +0 -1
  597. package/public/dist/assets/settings-client-CGf3uPPf.js +0 -1
  598. package/public/dist/assets/skills-yMfNYJ8m.js +0 -1
  599. package/public/dist/assets/slash-commands-CZcwr1W6.js +0 -1
  600. package/public/dist/assets/ui-04YlOMgn.js +0 -136
  601. package/public/dist/assets/ui-D6hlMjRq.js +0 -1
  602. /package/public/dist/assets/{InlineWarn-CqgWEC41.js → InlineWarn-BooBRm7o.js} +0 -0
  603. /package/public/dist/assets/{agent-meta-puNn13DV.js → agent-meta-DHddpWHQ.js} +0 -0
  604. /package/public/dist/assets/{fields-DH9JS3mb.js → fields-BtncIZYA.js} +0 -0
  605. /package/public/dist/assets/{mermaid-loader-6XC0y10y.js → mermaid-loader-BEFIOoJn.js} +0 -0
  606. /package/public/dist/assets/{path-utils-CtsDDGZg.js → path-utils-BuEEtj9w.js} +0 -0
  607. /package/public/dist/assets/{w3c-keyname-VSld09PZ.js → w3c-keyname-IiiZScED.js} +0 -0
@@ -1,52 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DE9SaGGd.js";import{f as t}from"./vendor-render-984tPmpy.js";import{n,t as r}from"./jsx-runtime-DOs-BiPY.js";import{n as i,t as a}from"./w3c-keyname-VSld09PZ.js";import{_ as o,a as s,b as c,c as l,d as u,g as d,i as f,l as p,m,o as h,r as g,s as ee,u as _,v as te,x as ne}from"./markdown-render-security-DJfJPWO-.js";import{T as re}from"./vendor-utils-CWelFt6C.js";var ie={}.hasOwnProperty;function ae(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&ie.call(t,e)){let n=String(t[e]);i=ie.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var oe={}.hasOwnProperty;function se(e,t){let n=-1,r;if(t.extensions)for(;++n<t.extensions.length;)se(e,t.extensions[n]);for(r in t)if(oe.call(t,r))switch(r){case`extensions`:break;case`unsafe`:ce(e[r],t[r]);break;case`join`:ce(e[r],t[r]);break;case`handlers`:le(e[r],t[r]);break;default:e.options[r]=t[r]}return e}function ce(e,t){t&&e.push(...t)}function le(e,t){t&&Object.assign(e,t)}var ue=[de];function de(e,t,n,r){if(t.type===`code`&&_(t,r)&&(e.type===`list`||e.type===t.type&&_(e,r)))return!1;if(`spread`in n&&typeof n.spread==`boolean`)return e.type===`paragraph`&&(e.type===t.type||t.type===`definition`||t.type===`heading`&&l(t,r))?void 0:+!!n.spread}var fe=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`],pe=[{character:` `,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,before:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`]},{character:`\r`,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`,`codeFencedMetaGraveAccent`,`codeFencedMetaTilde`,`destinationLiteral`,`headingAtx`]},{character:`
2
- `,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`,`codeFencedMetaGraveAccent`,`codeFencedMetaTilde`,`destinationLiteral`,`headingAtx`]},{character:` `,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,before:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`]},{character:`!`,after:`\\[`,inConstruct:`phrasing`,notInConstruct:fe},{character:`"`,inConstruct:`titleQuote`},{atBreak:!0,character:`#`},{character:`#`,inConstruct:`headingAtx`,after:`(?:[\r
3
- ]|$)`},{character:`&`,after:`[#A-Za-z]`,inConstruct:`phrasing`},{character:`'`,inConstruct:`titleApostrophe`},{character:`(`,inConstruct:`destinationRaw`},{before:`\\]`,character:`(`,inConstruct:`phrasing`,notInConstruct:fe},{atBreak:!0,before:`\\d+`,character:`)`},{character:`)`,inConstruct:`destinationRaw`},{atBreak:!0,character:`*`,after:`(?:[ \r
4
- *])`},{character:`*`,inConstruct:`phrasing`,notInConstruct:fe},{atBreak:!0,character:`+`,after:`(?:[ \r
5
- ])`},{atBreak:!0,character:`-`,after:`(?:[ \r
6
- -])`},{atBreak:!0,before:`\\d+`,character:`.`,after:`(?:[ \r
7
- ]|$)`},{atBreak:!0,character:`<`,after:`[!/?A-Za-z]`},{character:`<`,after:`[!/?A-Za-z]`,inConstruct:`phrasing`,notInConstruct:fe},{character:`<`,inConstruct:`destinationLiteral`},{atBreak:!0,character:`=`},{atBreak:!0,character:`>`},{character:`>`,inConstruct:`destinationLiteral`},{atBreak:!0,character:`[`},{character:`[`,inConstruct:`phrasing`,notInConstruct:fe},{character:`[`,inConstruct:[`label`,`reference`]},{character:`\\`,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:`]`,inConstruct:[`label`,`reference`]},{atBreak:!0,character:`_`},{character:`_`,inConstruct:`phrasing`,notInConstruct:fe},{atBreak:!0,character:"`"},{character:"`",inConstruct:[`codeFencedLangGraveAccent`,`codeFencedMetaGraveAccent`]},{character:"`",inConstruct:`phrasing`,notInConstruct:fe},{atBreak:!0,character:`~`}];function me(e){return e.label||!e.identifier?e.label||``:ne(e.identifier)}function he(e){if(!e._compiled){let t=(e.atBreak?`[\\r\\n][\\t ]*`:``)+(e.before?`(?:`+e.before+`)`:``);e._compiled=RegExp((t?`(`+t+`)`:``)+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?`\\`:``)+e.character+(e.after?`(?:`+e.after+`)`:``),`g`)}return e._compiled}function ge(e,t,n){let r=t.indexStack,i=e.children||[],a=[],o=-1,s=n.before,c;r.push(-1);let l=t.createTracker(n);for(;++o<i.length;){let u=i[o],d;if(r[r.length-1]=o,o+1<i.length){let n=t.handle.handlers[i[o+1].type];n&&n.peek&&(n=n.peek),d=n?n(i[o+1],e,t,{before:``,after:``,...l.current()}).charAt(0):``}else d=n.after;a.length>0&&(s===`\r`||s===`
8
- `)&&u.type===`html`&&(a[a.length-1]=a[a.length-1].replace(/(\r?\n|\r)$/,` `),s=` `,l=t.createTracker(n),l.move(a.join(``)));let f=t.handle(u,e,t,{...l.current(),after:d,before:s});c&&c===f.slice(0,1)&&(f=p(c.charCodeAt(0))+f.slice(1));let m=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,c=void 0,m&&(a.length>0&&m.before&&s===a[a.length-1].slice(-1)&&(a[a.length-1]=a[a.length-1].slice(0,-1)+p(s.charCodeAt(0))),m.after&&(c=d)),l.move(f),a.push(f),s=f.slice(-1)}return r.pop(),a.join(``)}function _e(e,t,n){let r=t.indexStack,i=e.children||[],a=t.createTracker(n),o=[],s=-1;for(r.push(-1);++s<i.length;){let n=i[s];r[r.length-1]=s,o.push(a.move(t.handle(n,e,t,{before:`
9
- `,after:`
10
- `,...a.current()}))),n.type!==`list`&&(t.bulletLastUsed=void 0),s<i.length-1&&o.push(a.move(ve(n,i[s+1],e,t)))}return r.pop(),o.join(``)}function ve(e,t,n,r){let i=r.join.length;for(;i--;){let a=r.join[i](e,t,n,r);if(a===!0||a===1)break;if(typeof a==`number`)return`
11
- `.repeat(1+a);if(a===!1)return`
12
-
13
- <!---->
14
-
15
- `}return`
16
-
17
- `}var ye=/\r?\n|\r/g;function be(e,t){let n=[],r=0,i=0,a;for(;a=ye.exec(e);)o(e.slice(r,a.index)),n.push(a[0]),r=a.index+a[0].length,i++;return o(e.slice(r)),n.join(``);function o(e){n.push(t(e,i,!e))}}function xe(e,t,n){let r=(n.before||``)+(t||``)+(n.after||``),i=[],a=[],o={},s=-1;for(;++s<e.unsafe.length;){let t=e.unsafe[s];if(!u(e.stack,t))continue;let n=e.compilePattern(t),a;for(;a=n.exec(r);){let e=`before`in t||!!t.atBreak,n=`after`in t,r=a.index+(e?a[1].length:0);i.includes(r)?(o[r].before&&!e&&(o[r].before=!1),o[r].after&&!n&&(o[r].after=!1)):(i.push(r),o[r]={before:e,after:n})}}i.sort(Se);let c=n.before?n.before.length:0,l=r.length-(n.after?n.after.length:0);for(s=-1;++s<i.length;){let e=i[s];e<c||e>=l||e+1<l&&i[s+1]===e+1&&o[e].after&&!o[e+1].before&&!o[e+1].after||i[s-1]===e-1&&o[e].before&&!o[e-1].before&&!o[e-1].after||(c!==e&&a.push(Ce(r.slice(c,e),`\\`)),c=e,/[!-/:-@[-`{-~]/.test(r.charAt(e))&&(!n.encode||!n.encode.includes(r.charAt(e)))?a.push(`\\`):(a.push(p(r.charCodeAt(e))),c++))}return a.push(Ce(r.slice(c,l),n.after)),a.join(``)}function Se(e,t){return e-t}function Ce(e,t){let n=/\\(?=[!-/:-@[-`{-~])/g,r=[],i=[],a=e+t,o=-1,s=0,c;for(;c=n.exec(a);)r.push(c.index);for(;++o<r.length;)s!==r[o]&&i.push(e.slice(s,r[o])),i.push(`\\`),s=r[o];return i.push(e.slice(s)),i.join(``)}function we(e){let t=e||{},n=t.now||{},r=t.lineShift||0,i=n.line||1,a=n.column||1;return{move:c,current:o,shift:s};function o(){return{now:{line:i,column:a},lineShift:r}}function s(e){r+=e}function c(e){let t=e||``,n=t.split(/\r?\n|\r/g),o=n[n.length-1];return i+=n.length-1,a=n.length===1?a+o.length:1+o.length+r,t}}function Te(e,t){let n=t||{},r={associationId:me,containerPhrasing:ke,containerFlow:Ae,createTracker:we,compilePattern:he,enter:a,handlers:{...ee},handle:void 0,indentLines:be,indexStack:[],join:[...ue],options:{},safe:je,stack:[],unsafe:[...pe]};se(r,n),r.options.tightDefinitions&&r.join.push(Oe),r.handle=ae(`type`,{invalid:Ee,unknown:De,handlers:r.handlers});let i=r.handle(e,void 0,r,{before:`
18
- `,after:`
19
- `,now:{line:1,column:1},lineShift:0});return i&&i.charCodeAt(i.length-1)!==10&&i.charCodeAt(i.length-1)!==13&&(i+=`
20
- `),i;function a(e){return r.stack.push(e),t;function t(){r.stack.pop()}}}function Ee(e){throw Error("Cannot handle value `"+e+"`, expected node")}function De(e){throw Error("Cannot handle unknown node `"+e.type+"`")}function Oe(e,t){if(e.type===`definition`&&e.type===t.type)return 0}function ke(e,t){return ge(e,this,t)}function Ae(e,t){return _e(e,this,t)}function je(e,t){return xe(this,e,t)}var Me=function(e){return e.docTypeError=`docTypeError`,e.contextNotFound=`contextNotFound`,e.timerNotFound=`timerNotFound`,e.ctxCallOutOfScope=`ctxCallOutOfScope`,e.createNodeInParserFail=`createNodeInParserFail`,e.stackOverFlow=`stackOverFlow`,e.parserMatchError=`parserMatchError`,e.serializerMatchError=`serializerMatchError`,e.getAtomFromSchemaFail=`getAtomFromSchemaFail`,e.expectDomTypeError=`expectDomTypeError`,e.callCommandBeforeEditorView=`callCommandBeforeEditorView`,e.missingRootElement=`missingRootElement`,e.missingNodeInSchema=`missingNodeInSchema`,e.missingMarkInSchema=`missingMarkInSchema`,e.ctxNotBind=`ctxNotBind`,e.missingYjsDoc=`missingYjsDoc`,e}({}),Ne=class extends Error{constructor(e,t){super(t),this.name=`MilkdownError`,this.code=e}},Pe=(e,t)=>typeof t==`function`?`[Function]`:t,Fe=e=>JSON.stringify(e,Pe);function Ie(e){return new Ne(Me.docTypeError,`Doc type error, unsupported type: ${Fe(e)}`)}function Le(e){return new Ne(Me.contextNotFound,`Context "${e}" not found, do you forget to inject it?`)}function Re(e){return new Ne(Me.timerNotFound,`Timer "${e}" not found, do you forget to record it?`)}function ze(){return new Ne(Me.ctxCallOutOfScope,`Should not call a context out of the plugin.`)}function Be(e,t,n){let r=`Cannot create node for ${`name`in e?e.name:e}`,i=e=>{if(e==null)return`null`;if(Array.isArray(e))return`[${e.map(i).join(`, `)}]`;if(typeof e==`object`)return`toJSON`in e&&typeof e.toJSON==`function`?JSON.stringify(e.toJSON()):`spec`in e?JSON.stringify(e.spec):JSON.stringify(e);if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return JSON.stringify(e);if(typeof e==`function`)return`[Function: ${e.name||`anonymous`}]`;try{return String(e)}catch{return`[Unserializable]`}},a=[[`[Description]`,r],[`[Attributes]`,t],[`[Content]`,(n??[]).map(e=>e?typeof e==`object`&&`type`in e?`${e}`:i(e):`null`)]].reduce((e,[t,n])=>{let r=`${t}: ${i(n)}.`;return e.concat(r)},[]);return new Ne(Me.createNodeInParserFail,a.join(`
21
- `))}function Ve(){return new Ne(Me.stackOverFlow,`Stack over flow, cannot pop on an empty stack.`)}function He(e){return new Ne(Me.parserMatchError,`Cannot match target parser for node: ${Fe(e)}.`)}function Ue(e){return new Ne(Me.serializerMatchError,`Cannot match target serializer for node: ${Fe(e)}.`)}function We(e,t){return new Ne(Me.getAtomFromSchemaFail,`Cannot get ${e}: ${t} from schema.`)}function Ge(e){return new Ne(Me.expectDomTypeError,`Expect to be a dom, but get: ${Fe(e)}.`)}function Ke(){return new Ne(Me.callCommandBeforeEditorView,`You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized`)}function qe(e){return new Ne(Me.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`)}function Je(e){return new Ne(Me.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${e}" in schema.`)}var Ye=class{constructor(){this.sliceMap=new Map,this.get=e=>{let t=typeof e==`string`?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);if(!t)throw Le(typeof e==`string`?e:e.name);return t},this.remove=e=>{let t=typeof e==`string`?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>typeof e==`string`?[...this.sliceMap.values()].some(t=>t.type.name===e):this.sliceMap.has(e.id)}},Xe=class{#e=[];#t;#n=()=>{this.#e.forEach(e=>e(this.#t))};constructor(e,t,n){this.set=e=>{this.#t=e,this.#n()},this.get=()=>this.#t,this.update=e=>{this.#t=e(this.#t),this.#n()},this.type=n,this.#t=t,e.set(n.id,this)}on(e){return this.#e.push(e),()=>{this.#e=this.#e.filter(t=>t!==e)}}once(e){let t=this.on(n=>{e(n),t()});return t}off(e){this.#e=this.#e.filter(t=>t!==e)}offAll(){this.#e=[]}},Ze=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw ze()}}create(e,t=this._defaultValue){return new Xe(e,t,this)}},v=(e,t)=>new Ze(e,t),Qe=class{#e;#t;#n;#r=new Set;#i=new Set;#a=new Map;#o=new Map;constructor(e,t,n){this.read=()=>({metadata:this.#e,injectedSlices:[...this.#r].map(e=>({name:typeof e==`string`?e:e.name,value:this.#s(e)})),consumedSlices:[...this.#i].map(e=>({name:typeof e==`string`?e:e.name,value:this.#s(e)})),recordedTimers:[...this.#a].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#c(e)})),waitTimers:[...this.#o].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#c(e)}))}),this.onRecord=e=>{this.#a.set(e,{start:Date.now(),duration:0})},this.onClear=e=>{this.#a.delete(e)},this.onDone=e=>{let t=this.#a.get(e);t&&(t.duration=Date.now()-t.start)},this.onWait=(e,t)=>{let n=Date.now();t.finally(()=>{this.#o.set(e,{duration:Date.now()-n})}).catch(console.error)},this.onInject=e=>{this.#r.add(e)},this.onRemove=e=>{this.#r.delete(e)},this.onUse=e=>{this.#i.add(e)},this.#t=e,this.#n=t,this.#e=n}#s=e=>this.#t.get(e).get();#c=e=>this.#n.get(e).status},$e=class e{#e;#t;#n;#r;constructor(t,n,r){this.produce=t=>t&&Object.keys(t).length?new e(this.#e,this.#t,{...t}):this,this.inject=(e,t)=>{let n=e.create(this.#e.sliceMap);return t!=null&&n.set(t),this.#r?.onInject(e),this},this.remove=e=>(this.#e.remove(e),this.#r?.onRemove(e),this),this.record=e=>(e.create(this.#t.store),this.#r?.onRecord(e),this),this.clearTimer=e=>(this.#t.remove(e),this.#r?.onClear(e),this),this.isInjected=e=>this.#e.has(e),this.isRecorded=e=>this.#t.has(e),this.use=e=>(this.#r?.onUse(e),this.#e.get(e)),this.get=e=>this.use(e).get(),this.set=(e,t)=>this.use(e).set(t),this.update=(e,t)=>this.use(e).update(t),this.timer=e=>this.#t.get(e),this.done=e=>{this.timer(e).done(),this.#r?.onDone(e)},this.wait=e=>{let t=this.timer(e).start();return this.#r?.onWait(e,t),t},this.waitTimers=async e=>{await Promise.all(this.get(e).map(e=>this.wait(e)))},this.#e=t,this.#t=n,this.#n=r,r&&(this.#r=new Qe(t,n,r))}get meta(){return this.#n}get inspector(){return this.#r}},et=class{constructor(){this.store=new Map,this.get=e=>{let t=this.store.get(e.id);if(!t)throw Re(e.name);return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}},tt=class{#e=null;#t=null;#n;#r=`pending`;constructor(e,t){this.start=()=>(this.#e??=new Promise((e,t)=>{this.#t=t=>{t instanceof CustomEvent&&t.detail.id===this.#n&&(this.#r=`resolved`,this.#i(),t.stopImmediatePropagation(),e())},this.#a(()=>{this.#r===`pending`&&(this.#r=`rejected`),this.#i(),t(Error(`Timing ${this.type.name} timeout.`))}),this.#r=`pending`,addEventListener(this.type.name,this.#t)}),this.#e),this.done=()=>{let e=new CustomEvent(this.type.name,{detail:{id:this.#n}});dispatchEvent(e)},this.#n=Symbol(t.name),this.type=t,e.set(t.id,this)}get status(){return this.#r}#i=()=>{this.#t&&removeEventListener(this.type.name,this.#t)};#a=e=>{setTimeout(()=>{e()},this.type.timeout)}},nt=class{constructor(e,t=3e3){this.create=e=>new tt(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},rt=(e,t=3e3)=>new nt(e,t);function it(e){let t=this;t.compiler=n;function n(n){return Te(n,{...t.data(`settings`),...e,extensions:t.data(`toMarkdownExtensions`)||[]})}}function y(e){this.content=e}y.prototype={constructor:y,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new y(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new y(n)},addToStart:function(e,t){return new y([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new y(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new y(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=y.from(e),e.size?new y(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=y.from(e),e.size?new y(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=y.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},y.from=function(e){if(e instanceof y)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new y(t)};function at(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=at(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function ot(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=ot(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var b=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return at(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return ot(this,e,t,n)}findIndex(e){if(e==0)return ct(0,e);if(e==this.size)return ct(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?ct(t+1,i):ct(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};b.empty=new b([],0);var st={index:0,offset:0};function ct(e,t){return st.index=e,st.offset=t,st}function lt(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!lt(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!lt(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var x=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&lt(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};x.none=[];var ut=class extends Error{},S=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=ft(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(dt(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(b.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};S.empty=new S(b.empty,0,0);function dt(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(dt(a.content,t-i-1,n-i-1)))}function ft(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=ft(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function pt(e,t,n){if(n.openStart>e.depth)throw new ut(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ut(`Inconsistent open depths`);return mt(e,t,n,0)}function mt(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=mt(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return yt(a,xt(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return yt(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=St(n,e);return yt(a,bt(e,i,o,t,r))}}function ht(e,t){if(!t.type.compatibleContent(e.type))throw new ut(`Cannot join `+t.type.name+` onto `+e.type.name)}function gt(e,t,n){let r=e.node(n);return ht(r,t.node(n)),r}function _t(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function vt(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(_t(e.nodeAfter,r),a++));for(let e=a;e<o;e++)_t(i.child(e),r);t&&t.depth==n&&t.textOffset&&_t(t.nodeBefore,r)}function yt(e,t){return e.type.checkContent(t),e.copy(t)}function bt(e,t,n,r,i){let a=e.depth>i&&gt(e,t,i+1),o=r.depth>i&&gt(n,r,i+1),s=[];return vt(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(ht(a,o),_t(yt(a,bt(e,t,n,r,i+1)),s)):(a&&_t(yt(a,xt(e,t,i+1)),s),vt(t,n,i,s),o&&_t(yt(o,xt(n,r,i+1)),s)),vt(r,null,i,s),new b(s)}function xt(e,t,n){let r=[];return vt(null,e,n,r),e.depth>n&&_t(yt(gt(e,t,n+1),xt(e,t,n+1)),r),vt(t,null,n,r),new b(r)}function St(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(b.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Ct=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return x.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Dt(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Et.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Et.set(t,r=new wt);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Tt,i}},wt=class{constructor(){this.elts=[],this.i=0}},Tt=12,Et=new WeakMap,Dt=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Ot=Object.create(null),kt=class e{constructor(e,t,n,r=x.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||b.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&lt(this.attrs,t||e.defaultAttrs||Ot)&&x.sameSet(this.marks,n||x.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return S.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new S(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return pt(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ct.resolveCached(this,e)}resolveNoCache(e){return Ct.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),jt(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=b.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=x.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!x.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=b.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};kt.prototype.text=void 0;var At=class e extends kt{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):jt(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function jt(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var Mt=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Nt(t,n);if(r.next==null)return e.empty;let i=Pt(r);r.next&&r.err(`Unexpected trailing text`);let a=Wt(Vt(i));return Gt(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return b.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
22
- `)}};Mt.empty=new Mt(!0);var Nt=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function Pt(e){let t=[];do t.push(Ft(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function Ft(e){let t=[];do t.push(It(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function It(e){let t=Bt(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=Rt(e,t);else break;return t}function Lt(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function Rt(e,t){let n=Lt(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:Lt(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function zt(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function Bt(e){if(e.eat(`(`)){let t=Pt(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=zt(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function Vt(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function Ht(e,t){return t-e}function Ut(e,t){let n=[];return r(t),n.sort(Ht);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function Wt(e){let t=Object.create(null);return n(Ut(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);Ut(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new Mt(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Ht);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Gt(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function Kt(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function qt(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function Jt(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function Yt(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Qt(e,r,t[r]);return n}var Xt=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=Yt(e,n.attrs),this.defaultAttrs=Kt(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Mt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:qt(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new kt(this,this.computeAttrs(e),b.from(t),x.setFrom(n))}createChecked(e=null,t,n){return t=b.from(t),this.checkContent(t),new kt(this,this.computeAttrs(e),t,x.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=b.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(b.empty,!0);return i?new kt(this,e,t.append(i),x.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Jt(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:x.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Zt(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Qt=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Zt(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},$t=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Yt(e,r.attrs),this.excluded=null;let i=Kt(this.attrs);this.instance=i?new x(this,i):null}create(e=null){return!e&&this.instance?this.instance:new x(this,qt(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Jt(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},en=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=y.from(e.nodes),t.marks=y.from(e.marks||{}),this.nodes=Xt.compile(this.spec.nodes,this),this.marks=$t.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=Mt.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?tn(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:tn(this,n.split(` `))}this.nodeFromJSON=e=>kt.fromJSON(this,e),this.markFromJSON=e=>x.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof Xt))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new At(n,n.defaultAttrs,e,x.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function tn(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function nn(e){return e.tag!=null}function rn(e){return e.style!=null}var an=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(nn(e))this.tags.push(e);else if(rn(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new mn(this,t,!1);return n.addAll(e,x.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new mn(this,t,!0);return n.addAll(e,x.none,t.from,t.to),S.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(gn(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=_n(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=_n(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},on={address:!0,article:!0,aside:!0,blockquote:!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},sn={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},cn={ol:!0,ul:!0},ln=1,un=2,dn=4;function fn(e,t,n){return t==null?e&&e.whitespace==`pre`?ln|un:n&~dn:(t?ln:0)|(t===`full`?un:0)}var pn=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=x.none,this.match=i||(a&dn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(b.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ln)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=b.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(b.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!on.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},mn=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=fn(null,t.preserveWhitespace,0)|(n?dn:0);i=r?new pn(r.type,r.attrs,x.none,!0,t.topMatch||r.type.contentMatch,a):n?new pn(null,null,x.none,!0,null,a):new pn(e.schema.topNodeType,null,x.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&un?`full`:this.localPreserveWS||(r.options&ln)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
23
- `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;cn.hasOwnProperty(a)&&this.parser.normalizeLists&&hn(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:sn.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(on.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
24
- `),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=x.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):vn(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=fn(e,i,a.options);a.options&dn&&a.content.length==0&&(o|=dn);let s=x.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):vn(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new pn(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=ln);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function hn(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&cn.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function gn(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function _n(e){let t={};for(let n in e)t[n]=e[n];return t}function vn(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var yn=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=xn(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=Tn(xn(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Tn(xn(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return Tn(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=bn(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return bn(e.marks)}};function bn(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function xn(e){return e.document||window.document}var Sn=new WeakMap;function Cn(e){let t=Sn.get(e);return t===void 0&&Sn.set(e,t=wn(e)),t}function wn(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function Tn(e,t,n,r){if(typeof t==`string`)return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=Cn(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else{let{dom:t,contentDOM:i}=Tn(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var En=65535,Dn=2**16;function On(e,t){return e+t*Dn}function kn(e){return e&En}function An(e){return(e-(e&En))/Dn}var jn=1,Mn=2,Nn=4,Pn=8,Fn=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Pn)>0}get deletedBefore(){return(this.delInfo&(jn|Nn))>0}get deletedAfter(){return(this.delInfo&(Mn|Nn))>0}get deletedAcross(){return(this.delInfo&Nn)>0}},In=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=kn(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+An(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:On(o/3,e-s),f=e==s?Mn:e==u?jn:Nn;return(t<0?e!=s:e!=u)&&(f|=Pn),new Fn(a,f,d)}r+=l-c}return n?e+r:new Fn(e+r,0,null)}touches(e,t){let n=0,r=kn(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};In.empty=new In([]);var Ln=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new Fn(e,r,null)}},Rn=Object.create(null),C=class{getMap(){return In.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=Rn[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Rn)throw RangeError(`Duplicate use of step JSON ID `+e);return Rn[e]=t,t.prototype.jsonID=e,t}},w=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof ut)return e.fail(t.message);throw t}}};function zn(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(zn(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return b.fromArray(r)}var Bn=class e extends C{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new S(zn(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return w.fromReplace(e,this.from,this.to,i)}invert(){return new Vn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};C.jsonID(`addMark`,Bn);var Vn=class e extends C{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new S(zn(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return w.fromReplace(e,this.from,this.to,n)}invert(){return new Bn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};C.jsonID(`removeMark`,Vn);var Hn=class e extends C{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return w.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return w.fromReplace(e,this.pos,this.pos+1,new S(b.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new Un(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};C.jsonID(`addNodeMark`,Hn);var Un=class e extends C{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return w.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return w.fromReplace(e,this.pos,this.pos+1,new S(b.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Hn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};C.jsonID(`removeNodeMark`,Un);var Wn=class e extends C{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Kn(e,this.from,this.to)?w.fail(`Structure replace would overwrite content`):w.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new In([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?S.empty:new S(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?S.empty:new S(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,S.fromJSON(t,n.slice),!!n.structure)}};Wn.MAP_BIAS=1,C.jsonID(`replace`,Wn);var Gn=class e extends C{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(Kn(e,this.from,this.gapFrom)||Kn(e,this.gapTo,this.to)))return w.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return w.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?w.fromReplace(e,this.from,this.to,n):w.fail(`Content does not fit in gap`)}getMap(){return new In([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,S.fromJSON(t,n.slice),n.insert,!!n.structure)}};C.jsonID(`replaceAround`,Gn);function Kn(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function qn(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new Vn(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new Bn(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function Jn(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof $t){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new Vn(t.from,t.to,t.style)))}function Yn(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Wn(s,l,S.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new Vn(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new S(b.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new Wn(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(b.empty,!0);e.replace(s,s,new S(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Xn(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Zn(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Xn(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function Qn(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=b.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=b.from(r.node(e).copy(u)),d++):c--;let f=b.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=b.from(i.node(e).copy(f)),p++):l++;e.step(new Gn(c,l,o,s,new S(u.append(f),d,p),u.size-d,!0))}function $n(e,t,n=null,r=e){let i=tr(e,t),a=i&&nr(r,t);return a?i.map(er).concat({type:t,attrs:n}).concat(a.map(er)):null}function er(e){return{type:e,attrs:null}}function tr(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function nr(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function rr(e,t,n){let r=b.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=b.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new Gn(i,a,i,a,new S(r,0,0),n.length,!0))}function ir(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&sr(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&or(e,t,n,a),Yn(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new Gn(c,l,c+1,l-1,new S(b.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&ar(e,t,n,a),!1}})}function ar(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function or(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
25
- `))}})}function sr(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function cr(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new Gn(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new S(b.from(o),0,0),1,!0))}function lr(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function ur(e,t,n=1,r){let i=e.doc.resolve(t),a=b.empty,o=b.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=b.from(i.node(e).copy(a));let t=r&&r[s];o=b.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new Wn(t,t,new S(a.append(o),n,n),!0))}function dr(e,t){let n=e.resolve(t),r=n.index();return pr(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function fr(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function pr(e,t){return!!(e&&t&&!e.isLeaf&&fr(e,t))}function mr(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);or(e,r.node(),r.before(),s)}o.inlineContent&&Yn(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new Wn(l,c.map(t+n,-1),S.empty,!0)),r===!0){let t=e.doc.resolve(l);ar(e,t.node(),t.before(),e.steps.length)}return e}function hr(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function gr(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function _r(e,t,n=t,r=S.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return vr(i,a,r)?new Wn(t,n,r):new yr(i,a,r).fit()}function vr(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var yr=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=b.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=b.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new S(i,a,o);return e>-1?new Gn(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new Wn(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Sr(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(b.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Sr(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new S(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Sr(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new S(br(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new S(br(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let a=this.unplaced,o=n?n.content:a.content,s=a.openStart-e,c=0,l=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)l.push(r.child(e));u=u.matchFragment(r)}let f=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let e=o.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||s==0||e.content.size)&&(u=t,l.push(Cr(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=xr(this.placed,t,b.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?e==0?S.empty:new S(br(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new S(br(a.content,e,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!wr(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:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=wr(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=wr(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=xr(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=xr(this.placed,this.depth,b.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(b.empty,!0);e.childCount&&(this.placed=xr(this.placed,this.frontier.length,e))}};function br(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(br(e.firstChild.content,t-1,n)))}function xr(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(xr(e.lastChild.content,t-1,n)))}function Sr(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Cr(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Cr(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(b.empty,!0)))),e.copy(r)}function wr(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!Tr(n,a.content,o)?s:null}function Tr(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function Er(e){return e.spec.defining||e.spec.definingForContent}function Dr(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(vr(i,a,r))return e.step(new Wn(t,n,r));let o=jr(i,a);o[o.length-1]==0&&o.pop();let s=-(i.depth+1);o.unshift(s);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=Er(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t<o.length;t++){let l=o[(t+c)%o.length],u=!0;l<0&&(u=!1,l=-l);let f=i.node(l-1),p=i.index(l-1);if(f.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(l),u?a.after(l):n,new S(Or(r.content,0,r.openStart,s),s,r.openEnd))}}let d=e.steps.length;for(let s=o.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function Or(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(Or(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(b.empty,!0))}return e}function kr(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=hr(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new S(b.from(r),0,0))}function Ar(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=jr(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function jr(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var Mr=class e extends C{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return w.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return w.fromReplace(e,this.pos,this.pos+1,new S(b.from(r),0,+!t.isLeaf))}getMap(){return In.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};C.jsonID(`attr`,Mr);var Nr=class e extends C{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return w.ok(n)}getMap(){return In.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};C.jsonID(`docAttr`,Nr);var Pr=class extends Error{};Pr=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},Pr.prototype=Object.create(Error.prototype),Pr.prototype.constructor=Pr,Pr.prototype.name=`TransformError`;var Fr=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ln}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Pr(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=S.empty){let r=_r(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new S(b.from(n),0,0))}delete(e,t){return this.replace(e,t,S.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Dr(this,e,t,n),this}replaceRangeWith(e,t,n){return kr(this,e,t,n),this}deleteRange(e,t){return Ar(this,e,t),this}lift(e,t){return Qn(this,e,t),this}join(e,t=1){return mr(this,e,t),this}wrap(e,t){return rr(this,e,t),this}setBlockType(e,t=e,n,r=null){return ir(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return cr(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Mr(e,t,n)),this}setDocAttribute(e,t){return this.step(new Nr(e,t)),this}addNodeMark(e,t){return this.step(new Hn(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof x)t.isInSet(n.marks)&&this.step(new Un(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new Un(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return ur(this,e,t,n),this}addMark(e,t,n){return qn(this,e,t,n),this}removeMark(e,t,n){return Jn(this,e,t,n),this}clearIncompatible(e,t,n){return Yn(this,e,t,n),this}},Ir=Object.create(null),T=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Lr(e.min(t),e.max(t))]}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 e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=S.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?S.empty:t),o==0&&Gr(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),Gr(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new E(e):Wr(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?Wr(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Wr(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Hr(e.node(0))}static atStart(e){return Wr(e,e,0,0,1)||new Hr(e)}static atEnd(e){return Wr(e,e,e.content.size,e.childCount,-1)||new Hr(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=Ir[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Ir)throw RangeError(`Duplicate use of selection JSON ID `+e);return Ir[e]=t,t.prototype.jsonID=e,t}getBookmark(){return E.between(this.$anchor,this.$head).getBookmark()}};T.prototype.visible=!0;var Lr=class{constructor(e,t){this.$from=e,this.$to=t}},Rr=!1;function zr(e){!Rr&&!e.parent.inlineContent&&(Rr=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var E=class e extends T{constructor(e,t=e){zr(e),zr(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return T.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=S.empty){if(super.replace(e,t),t==S.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Br(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=T.findFrom(n,r,!0)||T.findFrom(n,-r,!0);if(e)n=e.$head;else return T.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(T.findFrom(t,-r,!0)||T.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};T.jsonID(`text`,E);var Br=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return E.between(e.resolve(this.anchor),e.resolve(this.head))}},D=class e extends T{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?T.near(a):new e(a)}content(){return new S(b.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new Vr(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};D.prototype.visible=!1,T.jsonID(`node`,D);var Vr=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new Br(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&D.isSelectable(n)?new D(t):T.near(t)}},Hr=class e extends T{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=S.empty){if(t==S.empty){e.delete(0,e.doc.content.size);let t=T.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return Ur}};T.jsonID(`all`,Hr);var Ur={map(){return this},resolve(e){return new Hr(e)}};function Wr(e,t,n,r,i,a=!1){if(t.inlineContent)return E.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=Wr(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&D.isSelectable(r))return D.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function Gr(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof Wn||i instanceof Gn))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(T.near(e.doc.resolve(o),n))}var Kr=1,qr=2,Jr=4,Yr=class extends Fr{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.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(e){if(e.$from.doc!=this.doc)throw RangeError(`Selection passed to setSelection must point at the current document`);return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Kr)&~qr,this.storedMarks=null,this}get selectionSet(){return(this.updated&Kr)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=qr,this}ensureMarks(e){return x.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&qr)>0}addStep(e,t){super.addStep(e,t),this.updated&=~qr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||x.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(T.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Jr,this}get scrolledIntoView(){return(this.updated&Jr)>0}};function Xr(e,t){return!t||!e?e:e.bind(t)}var Zr=class{constructor(e,t,n){this.name=e,this.init=Xr(t.init,n),this.apply=Xr(t.apply,n)}},Qr=[new Zr(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new Zr(`selection`,{init(e,t){return e.selection||T.atStart(t.doc)},apply(e){return e.selection}}),new Zr(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new Zr(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],$r=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Qr.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Zr(e.key,e.spec.state,e))})}},ei=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let s=r?r[a].n:0,c=r?r[a].state:this,l=s<t.length&&o.spec.appendTransaction.call(o,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,a)){if(l.setMeta(`appendedTransaction`,e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<a?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),i=!0}r&&(r[a]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw RangeError(`Applying a mismatched transaction`);let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new Yr(this)}static create(t){let n=new $r(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new $r(this.schema,t.plugins),r=n.fields,i=new e(n);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(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new $r(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=kt.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=T.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function ti(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=ti(i,t,{})),n[r]=i}return n}var O=class{constructor(e){this.spec=e,this.props={},e.props&&ti(e.props,this,this.props),this.key=e.key?e.key.key:ri(`plugin`)}getState(e){return e[this.key]}},ni=Object.create(null);function ri(e){return e in ni?e+`$`+ ++ni[e]:(ni[e]=0,e+`$`)}var k=class{constructor(e=`key`){this.key=ri(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},ii=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function ai(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var oi=(e,t,n)=>{let r=ai(e,n);if(!r)return!1;let i=di(r);if(!i){let n=r.blockRange(),i=n&&Zn(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(Ti(e,i,t,-1))return!0;if(r.parent.content.size==0&&(li(a,`end`)||D.isSelectable(a)))for(let n=r.depth;;n--){let o=_r(e.doc,r.before(n),r.after(n),S.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(li(a,`end`)?T.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):D.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},si=(e,t,n)=>{let r=ai(e,n);if(!r)return!1;let i=di(r);return i?ci(e,i,t):!1};function ci(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=_r(e.doc,i,o,S.empty);if(!s||s.from!=i||s instanceof Wn&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(E.create(t.doc,i)),n(t.scrollIntoView())}return!0}function li(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var ui=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=di(r)}let o=a&&a.nodeBefore;return!o||!D.isSelectable(o)?!1:(t&&t(e.tr.setSelection(D.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function di(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function fi(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var pi=(e,t,n)=>{let r=fi(e,n);if(!r)return!1;let i=hi(r);if(!i)return!1;let a=i.nodeAfter;if(Ti(e,i,t,1))return!0;if(r.parent.content.size==0&&(li(a,`start`)||D.isSelectable(a))){let n=_r(e.doc,r.before(),r.after(),S.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(li(a,`start`)?T.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):D.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},mi=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=hi(r)}let o=a&&a.nodeAfter;return!o||!D.isSelectable(o)?!1:(t&&t(e.tr.setSelection(D.create(e.doc,a.pos)).scrollIntoView()),!0)};function hi(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var gi=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
26
- `).scrollIntoView()),!0)};function _i(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var vi=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=_i(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(T.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},yi=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof Hr||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=_i(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(E.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},bi=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(lr(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Zn(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function xi(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof D&&t.selection.node.isBlock)return!r.parentOffset||!lr(t.doc,r.pos)?!1:(n&&n(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,s,c=!1,l=!1;for(let t=r.depth;;t--)if(r.node(t).isBlock){c=r.end(t)==r.pos+(r.depth-t),l=r.start(t)==r.pos-(r.depth-t),s=_i(r.node(t-1).contentMatchAt(r.indexAfter(t-1)));let n=e&&e(i.parent,c,r);a.unshift(n||(c&&s?{type:s}:null)),o=t;break}else{if(t==1)return!1;a.unshift(null)}let u=t.tr;(t.selection instanceof E||t.selection instanceof Hr)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=lr(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,lr(u.doc,d,a.length,a)),!f)return!1;if(u.split(d,a.length,a),!c&&l&&r.node(o).type!=s){let e=u.mapping.map(r.before(o)),t=u.doc.resolve(e);s&&r.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&u.setNodeMarkup(u.mapping.map(r.before(o)),s)}return n&&n(u.scrollIntoView()),!0}}var Si=xi(),Ci=(e,t)=>(t&&t(e.tr.setSelection(new Hr(e.doc))),!0);function wi(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||dr(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function Ti(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&wi(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=b.empty;for(let e=o.length-1;e>=0;e--)s=b.from(o[e].create(null,s));s=b.from(i.copy(s));let c=e.tr.step(new Gn(t.pos-1,r,t.pos,r,new S(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&dr(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:T.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&Zn(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&li(a,`start`,!0)&&li(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=b.empty;for(let e=o.length-1;e>=0;e--)r=b.from(o[e].copy(r));n(e.tr.step(new Gn(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new S(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Ei(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(E.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var Di=Ei(-1),Oi=Ei(1);function ki(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&$n(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function Ai(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function ji(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:a,$to:o}=t[i],s=a.depth==0?e.inlineContent&&e.type.allowsMarkType(n):!1;if(e.nodesBetween(a.pos,o.pos,(e,t)=>{if(s||!r&&e.isAtom&&e.isInline&&t>=a.pos&&t+e.nodeSize<=o.pos)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}function Mi(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new Lr(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new Lr(r,i))}return t}function Ni(e,t=null,n){let r=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,a=!(n&&n.includeWhitespace);return function(n,o){let{empty:s,$cursor:c,ranges:l}=n.selection;if(s&&!c||!ji(n.doc,l,e,i))return!1;if(o)if(c)e.isInSet(n.storedMarks||c.marks())?o(n.tr.removeStoredMark(e)):o(n.tr.addStoredMark(e.create(t)));else{let s,c=n.tr;i||(l=Mi(l)),s=r?!l.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!l.every(t=>{let n=!1;return c.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,a)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!a&&a.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<l.length;n++){let{$from:r,$to:i}=l[n];if(!s)c.removeMark(r.pos,i.pos,e);else{let n=r.pos,o=i.pos,s=r.nodeAfter,l=i.nodeBefore,u=a&&s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=a&&l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+u<o&&(n+=u,o-=d),c.addMark(n,o,e.create(t))}}o(c.scrollIntoView())}return!0}}function Pi(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var Fi=Pi(ii,oi,ui),Ii=Pi(ii,pi,mi),Li={Enter:Pi(gi,yi,bi,Si),"Mod-Enter":vi,Backspace:Fi,"Mod-Backspace":Fi,"Shift-Backspace":Fi,Delete:Ii,"Mod-Delete":Ii,"Mod-a":Ci},Ri={"Ctrl-h":Li.Backspace,"Alt-Backspace":Li[`Mod-Backspace`],"Ctrl-d":Li.Delete,"Ctrl-Alt-Backspace":Li[`Mod-Delete`],"Alt-Delete":Li[`Mod-Delete`],"Alt-d":Li[`Mod-Delete`],"Ctrl-a":Di,"Ctrl-e":Oi};for(let e in Li)Ri[e]=Li[e];var zi=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?Ri:Li,A=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?Bi(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function Bi(e){return function(t,n,r,i){let a=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);a+=n[0].slice(e+n[1].length),r+=e;let t=r-i;t>0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var Vi=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let n=e.tr,r=a.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(a.text){let t=n.doc.resolve(a.from).marks();n.replaceWith(a.from,a.to,e.schema.text(a.text,t))}else n.delete(a.from,a.to);t(n)}return!0}}return!1};new A(/--$/,`—`,{inCodeMark:!1}),new A(/\.\.\.$/,`…`,{inCodeMark:!1}),new A(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new A(/"$/,`”`,{inCodeMark:!1}),new A(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new A(/'$/,`’`,{inCodeMark:!1});function Hi(e,t,n=null,r){return new A(e,(e,i,a,o)=>{let s=n instanceof Function?n(i):n,c=e.tr.delete(a,o),l=c.doc.resolve(a).blockRange(),u=l&&$n(l,t,s);if(!u)return null;c.wrap(l,u);let d=c.doc.resolve(a-1).nodeBefore;return d&&d.type==t&&dr(c.doc,a-1)&&(!r||r(i,d))&&c.join(a-1),c})}function Ui(e,t,n=null){return new A(e,(e,r,i,a)=>{let o=e.doc.resolve(i),s=n instanceof Function?n(r):n;return o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t)?e.tr.delete(i,a).setBlockType(i,i,t,s):null})}var Wi=typeof navigator<`u`?navigator:null,Gi=typeof document<`u`?document:null,Ki=Wi&&Wi.userAgent||``,qi=/Edge\/(\d+)/.exec(Ki),Ji=/MSIE \d/.exec(Ki),Yi=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ki),Xi=!!(Ji||Yi||qi);Ji?document.documentMode:Yi?+Yi[1]:qi&&+qi[1],!Xi&&/gecko\/(\d+)/i.test(Ki)&&+(/Firefox\/(\d+)/.exec(Ki)||[0,0])[1];var Zi=!Xi&&/Chrome\/(\d+)/.exec(Ki),Qi=!!Zi;Zi&&+Zi[1],!Xi&&Wi&&/Apple Computer/.test(Wi.vendor)&&(/Mobile\/\w+/.test(Ki)||Wi&&Wi.maxTouchPoints>2)||Wi&&/Mac/.test(Wi.platform);var $i=/Android \d/.test(Ki);Gi&&`webkitFontSmoothing`in Gi.documentElement.style&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];function ea(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t);if(s.parent.type.spec.code)return!1;let c=s.parent.textBetween(Math.max(0,s.parentOffset-500),s.parentOffset,void 0,``)+r;for(let s of i){let i=s,l=i.match.exec(c),u=l&&l[0]&&i.handler(o,l,t-(l[0].length-r.length),n);if(u)return i.undoable!==!1&&u.setMeta(a,{transform:u,from:t,to:n,text:r}),e.dispatch(u),!0}return!1}var ta=new k(`MILKDOWN_CUSTOM_INPUTRULES`);function na({rules:e}){let t=new O({key:ta,isInputRules:!0,state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return ea(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>(setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&ea(n,r.pos,r.pos,``,e,t)}),!1),keydown:(e,t)=>!($i&&Qi&&t.key===`Enter`)||e.composing?!1:e.someProp(`handleKeyDown`,n=>n(e,t))?(t.preventDefault(),!0):!1},handleKeyDown(n,r){if(r.key!==`Enter`)return!1;let{$cursor:i}=n.state.selection;return i?ea(n,i.pos,i.pos,`
27
- `,e,t):!1}}});return t}function ra(e,t,n={}){return new A(e,(e,r,i,a)=>{var o;let{tr:s}=e,c=r[r.length-1],l=r[0],u=[],d,f={group:c,fullMatch:l,start:i,end:a},p=n.updateCaptured?.call(n,f);if(Object.assign(f,p),{group:c,fullMatch:l,start:i,end:a}=f,l===null||c?.trim()===``)return null;if(c){let e=l.search(/\S/),f=i+l.indexOf(c),p=f+c.length;u=s.storedMarks??[],p<a&&s.delete(p,a),f>i&&s.delete(i+e,f),d=i+e+c.length;let m=n.getAttr?.call(n,r);s.addMark(i,d,t.create(m)),s.setStoredMarks(u),(o=n.beforeDispatch)==null||o.call(n,{match:r,start:i,end:a,tr:s})}return s})}function ia(e){return Object.assign(Object.create(e),e).setTime(Date.now())}function aa(e,t){return Array.isArray(e)&&e.includes(t.type)||t.type===e}function oa(e){if(e.content.childCount===1){let t=e.content.firstChild;if(t?.type.name===`text`&&t.marks.length===0)return t;if(t?.type.name===`paragraph`&&t.childCount===1){let e=t.firstChild;if(e?.type.name===`text`&&e.marks.length===0)return e}}return!1}function sa(e){return t=>{for(let n=t.depth;n>0;--n){let r=t.node(n);if(e(r))return{from:t.before(n),to:t.after(n),node:r}}}}function ca(e,t){return sa(e=>e.type===t)(e)}function la(e,t){let n=t.nodes[e];if(!n)throw We(`node`,e);return n}function ua(e){return t=>{for(let n=t.depth;n>0;n--){let r=t.node(n);if(e(r))return{pos:t.before(n),start:t.start(n),depth:n,node:r}}}}function da(e,t){if(!(e instanceof D))return;let{node:n,$from:r}=e;if(aa(t,n))return{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}}var fa=(e,t)=>{let{selection:n,doc:r}=e;if(n instanceof D)return{hasNode:n.node.type===t,pos:n.from,target:n.node};let{from:i,to:a}=n,o=!1,s=-1,c=null;return r.nodesBetween(i,a,(e,n)=>c?!1:e.type===t?(o=!0,s=n,c=e,!1):!0),{hasNode:o,pos:s,target:c}},pa=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ma=typeof navigator<`u`&&/Win/.test(navigator.platform);function ha(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))pa?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function ga(e){let t=Object.create(null);for(let n in e)t[ha(n)]=e[n];return t}function _a(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function va(e){return new O({props:{handleKeyDown:ya(e)}})}function ya(e){let t=ga(e);return function(e,n){let r=i(n),o,s=t[_a(r,n)];if(s&&s(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[_a(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(ma&&n.ctrlKey&&n.altKey)&&(o=a[n.keyCode])&&o!=r){let r=t[_a(o,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var ba=class{},xa=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{let e=this.elements.pop();if(!e)throw Ve();return e}}},Sa=class e extends ba{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(t,n,r){return new e(t,n,r)}},Ca=class extends xa{#e=x.none;static{this.create=(e,t)=>{let n=new this(e);return e=>(n.run(t,e),n.toDoc())}}constructor(e){super(),this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(Sa.create(e,[],t)),this),this.closeNode=()=>{try{this.#a()}catch(e){console.error(e)}return this},this.addNode=(e,t,n)=>{try{this.#o(e,t,n)}catch(e){console.error(e)}return this},this.openMark=(e,t)=>(this.#e=e.create(t).addToSet(this.#e),this),this.closeMark=e=>(this.#e=e.removeFromSet(this.#e),this),this.addText=e=>{try{let t=this.top();if(!t)throw Ve();let n=t.pop(),r=this.schema.text(e,this.#e);if(!n)return t.push(r),this;let i=this.#n(n,r);return i?(t.push(i),this):(t.push(n,r),this)}catch(e){return console.error(e),this}},this.build=()=>{let e;do e=this.#a();while(this.size());return e},this.next=(e=[])=>([e].flat().forEach(e=>this.#i(e)),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{let n=e.runSync(e.parse(t),t);return this.next(n),this},this.schema=e}#t=e=>e.isText;#n=(e,t)=>{if(this.#t(e)&&this.#t(t)&&x.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)};#r=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.parseMarkdown.match(e));if(!t)throw He(e);return t};#i=e=>{let t=this.#r(e);t.spec.parseMarkdown.runner(this,e,t)};#a=()=>{this.#e=x.none;let e=this.close();return this.#o(e.type,e.attrs,e.content)};#o=(e,t,n)=>{let r=e.createAndFill(t,n,this.#e);if(!r)throw Be(e,t,n);return this.push(r),r}},wa=class e extends ba{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(e,...t)=>{this.children||=[],this.children.push(e,...t)},this.pop=()=>this.children?.pop()}static{this.create=(t,n,r,i={})=>new e(t,n,r,i)}},Ta=e=>Object.prototype.hasOwnProperty.call(e,`size`),Ea=class extends xa{#e=x.none;static{this.create=(e,t)=>{let n=new this(e);return e=>(n.run(e),n.toString(t))}}constructor(e){super(),this.openNode=(e,t,n)=>(this.open(wa.create(e,void 0,t,n)),this),this.closeNode=()=>(this.#l(),this),this.addNode=(e,t,n,r)=>(this.#u(e,t,n,r),this),this.withMark=(e,t,n,r)=>(this.#d(e,t,n,r),this),this.closeMark=e=>(this.#f(e),this),this.build=()=>{let e=null;do e=this.#l();while(this.size());return e},this.next=e=>Ta(e)?(e.forEach(e=>{this.#i(e)}),this):(this.#i(e),this),this.toString=e=>e.stringify(this.build()),this.run=e=>(this.next(e),this),this.schema=e}#t=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.toMarkdown.match(e));if(!t)throw Ue(e.type);return t};#n=e=>this.#t(e).spec.toMarkdown.runner(this,e);#r=(e,t)=>this.#t(e).spec.toMarkdown.runner(this,e,t);#i=e=>{let{marks:t}=e,n=e=>e.type.spec.priority??50;[...t].sort((e,t)=>n(e)-n(t)).every(t=>!this.#r(t,e))&&this.#n(e),t.forEach(e=>this.#f(e))};#a=(e,t)=>{if(e.type===t||e.children?.length!==1)return e;let n=e=>{if(e.type===t)return e.value==null?e:null;if(e.children?.length!==1)return null;let[r]=e.children;return r?n(r):null},r=n(e);if(!r)return e;let i=r.children?[...r.children]:void 0,a={...e,children:i};return a.children=i,r.children=[a],r};#o=e=>{let{children:t}=e;return t&&(e.children=t.reduce((e,t,n)=>{if(n===0)return[t];let r=e.at(-1);if(r&&r.isMark&&t.isMark){t=this.#a(t,r.type);let{children:n,...i}=t,{children:a,...o}=r;if(t.type===r.type&&n&&a&&JSON.stringify(i)===JSON.stringify(o)){let t={...o,children:[...a,...n]};return e.slice(0,-1).concat(this.#o(t))}}return e.concat(t)},[])),e};#s=e=>{let t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t};#c=(e,t)=>{let n=``,r=``,i=e.children,a=-1,o=-1,s=e=>{e&&e.forEach((e,t)=>{e.type===`text`&&e.value&&(a<0&&(a=t),o=t)})};if(i){s(i);let e=i?.[o],t=i?.[a];if(e&&e.value.endsWith(` `)){let t=e.value,n=t.trimEnd();r=t.slice(n.length),e.value=n}if(t&&t.value.startsWith(` `)){let e=t.value,r=e.trimStart();n=e.slice(0,e.length-r.length),t.value=r}}n.length&&this.#u(`text`,void 0,n);let c=t();return r.length&&this.#u(`text`,void 0,r),c};#l=(e=!1)=>{let t=this.close(),n=()=>this.#u(t.type,t.children,t.value,t.props);return e?this.#c(t,n):n()};#u=(e,t,n,r)=>{let i=wa.create(e,t,n,r),a=this.#o(this.#s(i));return this.push(a),a};#d=(e,t,n,r)=>e.isInSet(this.#e)?this:(this.#e=e.addToSet(this.#e),this.openNode(t,n,{...r,isMark:!0}));#f=e=>{e.isInSet(this.#e)&&(this.#e=e.type.removeFromSet(this.#e),this.#l(!0))}},j=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Da=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},Oa=null,ka=function(e,t,n){let r=Oa||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Aa=function(){Oa=null},ja=function(e,t,n,r){return n&&(Na(e,t,n,r,-1)||Na(e,t,n,r,1))},Ma=/^(img|br|input|textarea|hr)$/i;function Na(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Pa(e))){let n=e.parentNode;if(!n||n.nodeType!=1||Ra(e)||Ma.test(e.nodeName)||e.contentEditable==`false`)return!1;t=j(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`)if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1;else e=n,t=i<0?Pa(e):0}else return!1}}function Pa(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Fa(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=Pa(e)}else if(e.parentNode&&!Ra(e))t=j(e),e=e.parentNode;else return null}}function Ia(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable==`false`)return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!Ra(e))t=j(e)+1,e=e.parentNode;else return null}}function La(e,t,n){for(let r=t==0,i=t==Pa(e);r||i;){if(e==n)return!0;let t=j(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==Pa(e)}}function Ra(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var za=function(e){return e.focusNode&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Ba(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function Va(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function Ha(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Pa(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Pa(r.startContainer),r.startOffset)}}}var Ua=typeof navigator<`u`?navigator:null,Wa=typeof document<`u`?document:null,Ga=Ua&&Ua.userAgent||``,Ka=/Edge\/(\d+)/.exec(Ga),qa=/MSIE \d/.exec(Ga),Ja=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ga),M=!!(qa||Ja||Ka),Ya=qa?document.documentMode:Ja?+Ja[1]:Ka?+Ka[1]:0,Xa=!M&&/gecko\/(\d+)/i.test(Ga);Xa&&+(/Firefox\/(\d+)/.exec(Ga)||[0,0])[1];var Za=!M&&/Chrome\/(\d+)/.exec(Ga),N=!!Za,Qa=Za?+Za[1]:0,P=!M&&!!Ua&&/Apple Computer/.test(Ua.vendor),$a=P&&(/Mobile\/\w+/.test(Ga)||!!Ua&&Ua.maxTouchPoints>2),eo=$a||(Ua?/Mac/.test(Ua.platform):!1),to=Ua?/Win/.test(Ua.platform):!1,no=/Android \d/.test(Ga),ro=!!Wa&&`webkitFontSmoothing`in Wa.documentElement.style,io=ro?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ao(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function oo(e,t){return typeof e==`number`?e:e[t]}function so(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function co(e,t,n){let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=Da(o);continue}let e=o,n=e==a.body,s=n?ao(a):so(e),c=0,l=0;if(t.top<s.top+oo(r,`top`)?l=-(s.top-t.top+oo(i,`top`)):t.bottom>s.bottom-oo(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+oo(i,`top`)-s.top:t.bottom-s.bottom+oo(i,`bottom`)),t.left<s.left+oo(r,`left`)?c=-(s.left-t.left+oo(i,`left`)):t.right>s.right-oo(r,`right`)&&(c=t.right-s.right+oo(i,`right`)),c||l)if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:Da(o)}}function lo(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o<Math.min(innerHeight,t.bottom);o+=5){let t=e.root.elementFromPoint(a,o);if(!t||t==e.dom||!e.dom.contains(t))continue;let s=t.getBoundingClientRect();if(s.top>=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:uo(e.dom)}}function uo(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Da(r));return t}function fo({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;po(n,r==0?0:r-t)}function po(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:a}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var mo=null;function ho(e){if(e.setActive)return e.setActive();if(mo)return e.focus(mo);let t=uo(e);e.focus(mo==null?{get preventScroll(){return mo={preventScroll:!0},!0}}:void 0),mo||(mo=!1,po(t,0))}function go(e,t){let n,r=2e8,i,a=0,o=t.top,s=t.top,c,l;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(u.nodeType==1)e=u.getClientRects();else if(u.nodeType==3)e=ka(u).getClientRects();else continue;for(let f=0;f<e.length;f++){let p=e[f];if(p.top<=o&&p.bottom>=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=u,r=e,i=e&&n.nodeType==3?{left:p.right<t.left?p.right:p.left,top:t.top}:t,u.nodeType==1&&e&&(a=d+ +(t.left>=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?_o(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:go(n,i)}function _o(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(e,a+1),r.setStart(e,a);let n=To(r,1);if(n.top!=n.bottom&&vo(t,n)){i={node:e,offset:a+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function vo(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function yo(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function bo(e,t,n){let{node:r,offset:i}=go(t,n),a=-1;if(r.nodeType==1&&!r.firstChild){let e=r.getBoundingClientRect();a=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function xo(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right<r.left||o.bottom<r.top)&&(i=t.posAfter),a=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}function So(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let n=e.childNodes[a];if(n.nodeType==1){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(vo(t,i))return So(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function Co(e,t){let n=e.dom.ownerDocument,r,i=0,a=Ha(n,t.left,t.top);a&&({node:r,offset:i}=a);let o=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s;if(!o||!e.dom.contains(o.nodeType==1?o:o.parentNode)){let n=e.dom.getBoundingClientRect();if(!vo(t,n)||(o=So(e.dom,t,n),!o))return null}if(P)for(let e=o;r&&e;e=Da(e))e.draggable&&(r=void 0);if(o=yo(o,t),r){if(Xa&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let e=r.childNodes[i],n;e.nodeName==`IMG`&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&i++}let n;ro&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=xo(e,r,i,t))}s??=bo(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function wo(e){return e.top<e.bottom||e.left<e.right}function To(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(wo(e))return e}return Array.prototype.find.call(n,wo)||e.getBoundingClientRect()}var Eo=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Do(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=ro||Xa;if(r.nodeType==3)if(o&&(Eo.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=To(ka(r,i,i),n);if(Xa&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=To(ka(r,i-1,i-1),-1);if(t.top==e.top){let n=To(ka(r,i,i+1),-1);if(n.top!=e.top)return Oo(n,n.left<t.left)}}return e}else{let e=i,t=i,a=n<0?1:-1;return n<0&&!i?(t++,a=-1):n>=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,Oo(To(ka(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Pa(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return ko(e.getBoundingClientRect(),!1)}if(a==null&&i<Pa(r)){let e=r.childNodes[i];if(e.nodeType==1)return ko(e.getBoundingClientRect(),!0)}return ko(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==Pa(r))){let e=r.childNodes[i-1],t=e.nodeType==3?ka(e,Pa(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return Oo(To(t,1),!1)}if(a==null&&i<Pa(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?ka(e,0,+!o):e.nodeType==1?e:null:null;if(t)return Oo(To(t,-1),!0)}return Oo(To(r.nodeType==3?ka(r):r,-n),n>=0)}function Oo(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function ko(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Ao(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function jo(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return Ao(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Do(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=ka(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var Mo=/[\u0590-\u08ac]/;function No(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!Mo.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:Ao(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var Po=null,Fo=null,Io=!1;function Lo(e,t,n){return Po==t&&Fo==n?Io:(Po=t,Fo=n,Io=n==`up`||n==`down`?jo(e,t,n):No(e,t,n))}var Ro=0,zo=1,Bo=2,Vo=3,Ho=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=Ro,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>j(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node))if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],a=t+i.size;if(a>e||i instanceof Yo){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof Uo&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?j(e.dom)+1:0}}else{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,!(!e||e.dom.parentNode==this.contentDOM);n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?j(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let a=n,o=0;;o++){let n=this.children[o],s=a+n.size;if(r==-1&&e<=s){let i=a+n.border;if(e>=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=j(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=j(n.dom);break}t+=n.size}i==-1&&(i=this.contentDOM.childNodes.length);break}a=s}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw RangeError(`No node after pos `+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),a=Math.max(e,t);for(let o=0,s=0;o<this.children.length;o++){let c=this.children[o],l=s+c.size;if(i>s&&a<l)return c.setSelection(e-s-c.border,t-s-c.border,n,r);s=l}let o=this.domFromPos(e,e?-1:1),s=t==e?o:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),l=n.domSelectionRange(),u=!1;if((Xa||P)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
28
- `),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:j(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(Xa&&l.focusNode&&l.focusNode!=s.node&&l.focusNode.nodeType==1){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&P)&&ja(o.node,o.offset,l.anchorNode,l.anchorOffset)&&ja(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&Xa)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?Bo:zo,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Vo:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Bo:Vo}n=a}this.dirty=Bo}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Bo:zo;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Uo=class extends Ho{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Ro&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Wo=class extends Ho{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},Go=class e extends Ho{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=yn.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Vo||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Vo&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ro){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=Ro}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=ps(a,n,o,r)),t>0&&(a=ps(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Ko=class e extends Ho{constructor(e,t,n,r,i,a,o,s,c){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=yn.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=rs(u,r,n),l?c=new Xo(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new Jo(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(e.preserveWhitespace=`full`),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>b.empty)}return e}matchesNode(e,t,n){return this.dirty==Ro&&e.eq(this.node)&&is(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new ss(this,a&&a.node,e);us(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?x.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==Bo)&&(a&&this.protectLocalComposition(e,a),Zo(this.contentDOM,this.children,e),$a&&ds(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof E)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=fs(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&=void 0}let a=new Wo(this,i,t,r);e.input.compositionNodes.push(a),this.children=ps(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==Vo||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Ro}updateOuterDeco(e){if(is(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=ts(this.dom,this.nodeDOM,es(this.outerDeco,this.node,t),es(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function qo(e,t,n,r,i){rs(r,t,e);let a=new Ko(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var Jo=class e extends Ko{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==Vo||this.dirty!=Ro&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ro||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Ro,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Vo)}get domAtom(){return!1}isText(e){return this.node.text==e}},Yo=class extends Ho{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ro&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},Xo=class extends Ko{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==Vo)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Zo(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=as(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof Go){let t=r?r.previousSibling:e.lastChild;Zo(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=as(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var Qo=function(e){e&&(this.nodeName=e)};Qo.prototype=Object.create(null);var $o=[new Qo];function es(e,t,n){if(e.length==0)return $o;let r=n?$o[0]:new Qo,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new Qo(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new Qo(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function ts(e,t,n,r){if(n==$o&&r==$o)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName?i=t:(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=$o[0],i=t)}ns(i,o||$o[0],a)}return i}function ns(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function rs(e,t,n){return ts(e,e,$o,es(t,n,e.nodeType!=1))}function is(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function as(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var ss=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=cs(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=Ro,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=Go.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let a=this.top.children[r];return a.dirty==Vo&&a.dom==a.contentDOM&&(a.dirty=Bo),a.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof Ko){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=Vo&&is(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Bo,u.updateChildren(r,a+1),u.dirty=Ro),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!is(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=Ko.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=Ko.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new Uo(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Go;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Jo)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((P||N)&&e&&e.dom.contentEditable==`false`&&this.addHackNode(`IMG`,t),this.addHackNode(`BR`,this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e==`IMG`&&(n.className=`ProseMirror-separator`,n.alt=``),e==`BR`&&(n.className=`ProseMirror-trailingBreak`);let r=new Yo(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function cs(e,t){let n=t,r=n.children.length,i=e.childCount,a=new Map,o=[];outer:for(;i>0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof Go)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function ls(e,t){return e.type.side-t.type.side}function us(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u)if(d){d.sort(ls);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function ds(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function fs(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function ps(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function ms(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(za(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&D.isSelectable(e)&&i.parent&&!(e.isInline&&La(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new D(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let a=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(t<0)return null;[c,o]=i==e.state.selection.anchor?[i,t]:[t,i],s=r.resolve(o)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let n=t==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=Ts(e,u,s,n)}return l}function hs(e){return e.editable?e.hasFocus():Ds(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function gs(e,t=!1){let n=e.state.selection;if(Cs(e,n),hs(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&N){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&ja(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)Ss(e);else{let{anchor:r,head:i}=n,a,o;_s&&!(n instanceof E)&&(n.$from.parent.inlineContent||(a=vs(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=vs(e,n.to))),e.docView.setSelection(r,i,e,t),_s&&(a&&bs(a),o&&bs(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&xs(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var _s=P||N&&Qa<63;function vs(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(P&&i&&i.contentEditable==`false`)return ys(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return ys(i);if(a)return ys(a)}}function ys(e){return e.contentEditable=`true`,P&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function bs(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function xs(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!hs(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function Ss(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,j(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&M&&Ya<=11&&(n.disabled=!0,n.disabled=!1)}function Cs(e,t){if(t instanceof D){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ws(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ws(e)}function ws(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function Ts(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||E.between(t,n,r)}function Es(e){return e.editable&&!e.hasFocus()?!1:Ds(e)}function Ds(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Os(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return ja(t.node,t.offset,n.anchorNode,n.anchorOffset)}function ks(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&T.findFrom(a,t)}function As(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function js(e,t,n){let r=e.state.selection;if(r instanceof E){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return As(e,new E(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=ks(e.state,t);return n&&n instanceof D?As(e,n):!1}else if(!(eo&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?D.isSelectable(i)?As(e,new D(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):ro?As(e,new E(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof D&&r.node.isInline)return As(e,new E(t>0?r.$to:r.$from));else{let n=ks(e.state,t);return n?As(e,n):!1}}function Ms(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Ns(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function Ps(e,t){return t<0?Fs(e):Is(e)}function Fs(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(Xa&&n.nodeType==1&&r<Ms(n)&&Ns(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(Ns(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(Ls(n))break;else{let t=n.previousSibling;for(;t&&Ns(t,-1);)i=n.parentNode,a=j(t),t=t.previousSibling;if(t)n=t,r=Ms(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?Bs(e,n,r):i&&Bs(e,i,a)}function Is(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=Ms(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(Ns(e,1))a=n,o=++r;else break}else if(Ls(n))break;else{let t=n.nextSibling;for(;t&&Ns(t,1);)a=t.parentNode,o=j(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=Ms(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&Bs(e,a,o)}function Ls(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Rs(e,t){for(;e&&t==e.childNodes.length&&!Ra(e);)t=j(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=0}}function zs(e,t){for(;e&&!t&&!Ra(e);)t=j(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=e.childNodes.length}}function Bs(e,t,n){if(t.nodeType!=3){let e,r;(r=Rs(t,n))?(t=r,n=0):(e=zs(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(za(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&gs(e)},50)}function Vs(e,t){let n=e.state.doc.resolve(t);if(!(N||to)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?`ltr`:`rtl`}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function Hs(e,t,n){let r=e.state.selection;if(r instanceof E&&!r.empty||n.indexOf(`s`)>-1||eo&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=ks(e.state,t);if(n&&n instanceof D)return As(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof Hr?T.near(n,t):T.findFrom(n,t);return o?As(e,o):!1}return!1}function Us(e,t){if(!(e.state.selection instanceof E))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function Ws(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Gs(e){if(!P||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;Ws(e,n,`true`),setTimeout(()=>Ws(e,n,`false`),20)}return!1}function Ks(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function qs(e,t){let n=t.keyCode,r=Ks(t);if(n==8||eo&&n==72&&r==`c`)return Us(e,-1)||Ps(e,-1);if(n==46&&!t.shiftKey||eo&&n==68&&r==`c`)return Us(e,1)||Ps(e,1);if(n==13||n==27)return!0;if(n==37||eo&&n==66&&r==`c`){let t=n==37?Vs(e,e.state.selection.from)==`ltr`?-1:1:-1;return js(e,t,r)||Ps(e,t)}else if(n==39||eo&&n==70&&r==`c`){let t=n==39?Vs(e,e.state.selection.from)==`ltr`?1:-1:1;return js(e,t,r)||Ps(e,t)}else if(n==38||eo&&n==80&&r==`c`)return Hs(e,-1,r)||Ps(e,-1);else if(n==40||eo&&n==78&&r==`c`)return Gs(e)||Hs(e,1,r)||Ps(e,1);else if(r==(eo?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function Js(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||yn.fromSchema(e.state.schema),s=ac(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=rc[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
29
-
30
- `),slice:t}}function Ys(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new S(b.from(e.state.schema.text(t.replace(/\r\n?/g,`
31
- `))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=yn.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=cc(n),ro&&lc(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||an.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!Xs.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=uc(nc(s,+u[1],+u[2]),u[4]);else if(s=S.maxOpen(Zs(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=nc(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var Xs=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Zs(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&$s(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=ec(a[a.length-1],i.length));let n=Qs(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return b.from(a)}return e}function Qs(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,b.from(e));return e}function $s(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=$s(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(b.from(Qs(n,e,i+1))))}}function ec(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,ec(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(b.empty,!0);return e.copy(n.append(r))}function tc(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=tc(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(b.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function nc(e,t,n){return t<e.openStart&&(e=new S(tc(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new S(tc(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var rc={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},ic=null;function ac(){return ic||=document.implementation.createHTMLDocument(`title`)}var oc=null;function sc(e){let t=window.trustedTypes;return t?(oc||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),oc.createHTML(e)):e}function cc(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=ac().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&rc[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=sc(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function lc(e){let t=e.querySelectorAll(N?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function uc(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=b.from(t.create(r[e+1],i)),a++,o++}return new S(i,a,o)}var F={},I={},dc={touchstart:!0,touchmove:!0},fc=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function pc(e){for(let t in F){let n=F[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{vc(e,t)&&!_c(e,t)&&(e.editable||!(t.type in I))&&n(e,t)},dc[t]?{passive:!0}:void 0)}P&&e.dom.addEventListener(`input`,()=>null),gc(e)}function mc(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function hc(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function gc(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>_c(e,t))})}function _c(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function vc(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function yc(e,t){!_c(e,t)&&F[t.type]&&(e.editable||!(t.type in I))&&F[t.type](e,t)}I.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Nc(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(no&&N&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),$a&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,Ba(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||qs(e,n)?n.preventDefault():mc(e,`key`)},I.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},I.keypress=(e,t)=>{let n=t;if(Nc(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||eo&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof E)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function bc(e){return{left:e.clientX,top:e.clientY}}function xc(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Sc(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function Cc(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function wc(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&D.isSelectable(r)?(Cc(e,new D(n),`pointer`),!0):!1}function Tc(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof D&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(D.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(Cc(e,D.create(e.state.doc,i),`pointer`),!0)}function Ec(e,t,n,r,i){return Sc(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?Tc(e,n):wc(e,n))}function Dc(e,t,n,r){return Sc(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Oc(e,t,n,r){return Sc(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||kc(e,n,r)}function kc(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(Cc(e,E.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)Cc(e,E.create(r,a+1,a+1+n.content.size),`pointer`);else if(D.isSelectable(n))Cc(e,D.create(r,a),`pointer`);else continue;return!0}}function Ac(e){return Bc(e)}var jc=eo?`metaKey`:`ctrlKey`;F.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Ac(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&xc(n,e.input.lastClick)&&!n[jc]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(bc(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Mc(e,o,n,!!r)):(a==`doubleClick`?Dc:Oc)(e,o.pos,o.inside,n)?n.preventDefault():mc(e,`pointer`))};var Mc=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[jc],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof D&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Xa&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this)),mc(e,`pointer`)}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>gs(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(bc(e))),this.updateAllowDefault(e),this.allowDefault||!t?mc(this.view,`pointer`):Ec(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||P&&this.mightDrag&&!this.mightDrag.node.isAtom||N&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Cc(this.view,T.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):mc(this.view,`pointer`)}move(e){this.updateAllowDefault(e),mc(this.view,`pointer`),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};F.touchstart=e=>{e.input.lastTouch=Date.now(),Ac(e),mc(e,`pointer`)},F.touchmove=e=>{e.input.lastTouch=Date.now(),mc(e,`pointer`)},F.contextmenu=e=>Ac(e);function Nc(e,t){return e.composing?!0:P&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Pc=no?5e3:-1;I.compositionstart=I.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof E&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||N&&to&&Fc(e)))e.markCursor=e.state.storedMarks||n.marks(),Bc(e,!0),e.markCursor=null;else if(Bc(e,!t.selection.empty),Xa&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}Ic(e,Pc)};function Fc(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}I.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Ic(e,20))};function Ic(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Bc(e),t))}function Lc(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=zc());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Rc(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Fa(t.focusNode,t.focusOffset),r=Ia(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function zc(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function Bc(e,t=!1){if(!(no&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Lc(e),t||e.docView&&e.docView.dirty){let n=ms(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Vc(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var Hc=M&&Ya<15||$a&&io<604;F.copy=I.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Hc?null:n.clipboardData,{dom:o,text:s}=Js(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Vc(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function Uc(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Wc(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Gc(e,r.value,null,i,t):Gc(e,r.textContent,r.innerHTML,i,t)},50)}function Gc(e,t,n,r,i){let a=Ys(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||S.empty)))return!0;if(!a)return!1;let o=Uc(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function Kc(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}I.paste=(e,t)=>{let n=t;if(e.composing&&!no)return;let r=Hc?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Gc(e,Kc(r),r.getData(`text/html`),i,n)?n.preventDefault():Wc(e,n)};var qc=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Jc=eo?`altKey`:`ctrlKey`;function Yc(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[Jc]:!n}F.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(bc(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof D?i.to-1:i.to))){if(r&&r.mightDrag)o=D.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=D.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Js(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!N||Qa>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Hc?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Hc||n.dataTransfer.setData(`text/plain`,c),e.dragging=new qc(l,Yc(e,n),o)},F.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},I.dragover=I.dragenter=(e,t)=>t.preventDefault(),I.drop=(e,t)=>{try{Xc(e,t,e.dragging)}finally{e.dragging=null}};function Xc(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(bc(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=Ys(e,Kc(t.dataTransfer),Hc?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&Yc(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||S.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?gr(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&D.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new D(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(Ts(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}F.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&gs(e)},20))},F.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},F.beforeinput=(e,t)=>{if(N&&no&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,Ba(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in I)F[e]=I[e];function Zc(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var Qc=class e{constructor(e,t){this.toDOM=e,this.spec=t||rl,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new tl(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Zc(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},$c=class e{constructor(e,t){this.attrs=e,this.spec=t||rl}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new tl(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&Zc(this.attrs,t.attrs)&&Zc(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},el=class e{constructor(e,t){this.attrs=e,this.spec=t||rl}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new tl(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&Zc(this.attrs,t.attrs)&&Zc(this.spec,t.spec)}destroy(){}},tl=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new Qc(n,r))}static inline(t,n,r,i){return new e(t,n,new $c(r,i))}static node(t,n,r,i){return new e(t,n,new el(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof $c}get widget(){return this.type instanceof Qc}},nl=[],rl={},L=class e{constructor(e,t){this.local=e.length?e:nl,this.children=t.length?t:nl}static create(e,t){return t.length?ul(t,e,0,rl):R}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==R||e.maps.length==0?this:this.mapInner(e,t,0,0,n||rl)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?al(this.children,o||[],t,n,r,i,a):o?new e(o.sort(dl),nl):R}add(t,n){return n.length?this==R?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=cl(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,ul(s,e,o+1,rl)),a+=3}});let o=ol(a?ll(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(dl):this.local,i||this.children)}remove(e){return e.length==0||this==R?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==R?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):R}forChild(t,n){if(this==R)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof $c){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(dl),nl);return r?new il([t,r]):t}return r||R}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return fl(this.localsInner(e))}localsInner(e){if(this==R)return nl;if(e.inlineContent||!this.local.some($c.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof $c||t.push(this.local[e]);return t}forEachSet(e){e(this)}};L.empty=new L([],[]),L.removeOverlap=fl;var R=L.empty,il=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,rl));return e.from(r)}forChild(t,n){if(n.isLeaf)return L.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=R&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}return t?fl(n?t:t.sort(dl)):nl}static from(t){switch(t.length){case 0:return R;case 1:return t[0];default:return new e(t.every(e=>e instanceof L)?t:t.reduce((e,t)=>e.concat(t instanceof L?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function al(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==R?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=ul(sl(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new L(t.sort(dl),s)}function ol(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new tl(i.from+t,i.to+t,i.type))}return n}function sl(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function cl(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function ll(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function ul(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=cl(e,t,o+n);if(s){a=!0;let e=ul(s,t,n+o+1,r);e!=R&&i.push(o,o+t.nodeSize,e)}});let o=ol(a?ll(e):e,-n).sort(dl);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new L(o,i):R}function dl(e,t){return e.from-t.from||e.to-t.to}function fl(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),pl(t,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),pl(t,i,r.copy(a.from,r.to)));break}}}return t}function pl(e,t,n){for(;t<e.length&&dl(n,e[t])>0;)t++;e.splice(t,0,n)}function ml(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=R&&t.push(r)}),e.cursorWrapper&&t.push(L.create(e.state.doc,[e.cursorWrapper.deco])),il.from(t)}var hl={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},gl=M&&Ya<=11,_l=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},vl=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new _l,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);M&&Ya<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():P&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),gl&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,hl)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Es(this.view)){if(this.suppressingSelectionUpdates)return gs(this.view);if(M&&Ya<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=Da(n))t.add(n);for(let r=e.anchorNode;r;r=Da(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Es(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(Xa&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||wl(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&za(n)&&(c=ms(e))&&c.eq(T.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,gs(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),xl(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Tl(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||gs(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(M&&Ya<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?j(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?j(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}else if(e.type==`attributes`)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},yl=new WeakMap,bl=!1;function xl(e){if(!yl.has(e)&&(yl.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=Xa,bl)return;console.warn(`ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.`),bl=!0}}function Sl(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return ja(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Cl(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Sl(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?Sl(e,n):null}function wl(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Tl(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function El(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,u=c.anchorNode;if(u&&e.dom.contains(u.nodeType==1?u:u.parentNode)&&(l=[{node:u,offset:c.anchorOffset}],za(c)||l.push({node:c.focusNode,offset:c.focusOffset})),N&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||an.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:Dl,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function Dl(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(P&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(e.parentNode.lastChild==e||P&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var Ol=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function kl(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=ms(e,t);if(n&&!e.state.selection.eq(n)){if(N&&no&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,Ba(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=El(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=Pl(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,($a&&e.input.lastIOSEnter>Date.now()-225||no)&&i.some(e=>e.nodeType==1&&!Ol.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,Ba(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof E&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Al(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof E&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),M&&Ya<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),ee=u.resolve(m.start),_=h.sameParent(g)&&h.parent.inlineContent&&ee.end()>=m.endA;if(($a&&e.input.lastIOSEnter>Date.now()-225&&(!_||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!_&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,Ba(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&Ml(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,Ba(8,`Backspace`)))){no&&N&&e.domObserver.suppressSelectionUpdates();return}N&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),no&&!_&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,Ba(13,`Enter`))})},20));let te=m.start,ne=m.endA,re=t=>{let n=t||e.state.tr.replace(te,ne,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Al(e,n.doc,l.sel);t&&!(N&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==te||t.head==n.mapping.map(ne)-1)||M&&t.empty&&t.head==te)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},ie;if(_)if(h.pos==g.pos){M&&Ya<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>gs(e),20));let t=re(e.state.tr.delete(te,ne)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(ie=jl(h.parent.content.cut(h.parentOffset,g.parentOffset),ee.parent.content.cut(ee.parentOffset,m.endA-ee.start())))){let t=re(e.state.tr);ie.type==`add`?t.addMark(te,ne,ie.mark):t.removeMark(te,ne,ie.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>re(e.state.tr.insertText(t,te,ne));e.someProp(`handleTextInput`,r=>r(e,te,ne,t,n))||e.dispatch(n())}else e.dispatch(re());else e.dispatch(re())}function Al(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Ts(e,t.resolve(n.anchor),t.resolve(n.head))}function jl(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(b.from(l).eq(e))return{mark:s,type:o}}function Ml(e,t,n,r,i){if(n-t<=i.pos-r.pos||Nl(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(Nl(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Nl(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Nl(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function Pl(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&Fl(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&Fl(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function Fl(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var Il=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new fc,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ul),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=zl(this),Rl(this),this.nodeViews=Vl(this),this.docView=qo(this.state.doc,Ll(this),ml(this),this.dom,this),this.domObserver=new vl(this,(e,t,n,r)=>kl(this,e,t,n,r)),this.domObserver.start(),pc(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&gc(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ul),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Lc(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Vl(this);Hl(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&gc(this),this.editable=zl(this),Rl(this);let o=ml(this),s=Ll(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&lo(this);if(i){this.domObserver.stop();let t=l&&(M||N)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Bl(n.selection,e.selection);if(l){let n=N?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Rc(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=qo(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Os(this))?gs(this,t):(Cs(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&fo(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof D){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&co(this,t.getBoundingClientRect(),e)}else co(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new qc(e.slice,e.move,r<0?void 0:D.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(M){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable==`false`)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&ho(this.dom),gs(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Co(this,e)}coordsAtPos(e,t=1){return Do(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Lo(this,t||this.state,e)}pasteHTML(e,t){return Gc(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return Gc(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Js(this,e)}destroy(){this.docView&&(hc(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ml(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Aa())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return yc(this,e)}domSelectionRange(){let e=this.domSelection();return e?P&&this.root.nodeType===11&&Va(this.dom.ownerDocument)==this.dom&&Cl(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Il.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Ll(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[tl.node(0,e.state.doc.content.size,t)]}function Rl(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:tl.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function zl(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Bl(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function Vl(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function Hl(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function Ul(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}function Wl(e,t){return e.meta={package:`@milkdown/core`,group:`System`,...t},e}var Gl={text:(e,t,n,r)=>{let i=e.value;return/^[^*_\\]*\s+$/.test(i)?i:n.safe(i,{...r,encode:[]})},strong:(e,t,n,r)=>{let i=e.marker||n.options.strong||`*`,a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i+i),a(),s},emphasis:(e,t,n,r)=>{let i=e.marker||n.options.emphasis||`*`,a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i),a(),s}},z=v({},`editorView`),Kl=v({},`editorState`),ql=v([],`initTimer`),Jl=v({},`editor`),Yl=v([],`inputRules`),Xl=v([],`prosePlugins`),Zl=v([],`remarkPlugins`),Ql=v([],`nodeView`),$l=v([],`markView`),eu=v(m().use(c).use(it),`remark`),tu=v({handlers:Gl,encode:[]},`remarkStringifyOptions`),nu=rt(`ConfigReady`);function ru(e){let t=t=>(t.record(nu),async()=>(await e(t),t.done(nu),()=>{t.clearTimer(nu)}));return Wl(t,{displayName:`Config`}),t}var iu=rt(`InitReady`);function au(e){let t=t=>(t.inject(Jl,e).inject(Xl,[]).inject(Zl,[]).inject(Yl,[]).inject(Ql,[]).inject($l,[]).inject(tu,{handlers:Gl,encode:[]}).inject(eu,m().use(c).use(it)).inject(ql,[nu]).record(iu),async()=>{await t.waitTimers(ql);let e=t.get(tu);return t.set(eu,m().use(c).use(it,e)),t.done(iu),()=>{t.remove(Jl).remove(Xl).remove(Zl).remove(Yl).remove(Ql).remove($l).remove(tu).remove(eu).remove(ql).clearTimer(iu)}});return Wl(t,{displayName:`Init`}),t}var B=rt(`SchemaReady`),ou=v([],`schemaTimer`),V=v({},`schema`),su=v([],`nodes`),cu=v([],`marks`);function lu(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var uu=e=>(e.inject(V,{}).inject(su,[]).inject(cu,[]).inject(ou,[iu]).record(B),async()=>{await e.waitTimers(ou);let t=e.get(eu),n=e.get(Zl).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(eu,n);let r=new en({nodes:Object.fromEntries(e.get(su).map(([e,t])=>[e,lu(t)])),marks:Object.fromEntries(e.get(cu).map(([e,t])=>[e,lu(t)]))});return e.set(V,r),e.done(B),()=>{e.remove(V).remove(su).remove(cu).remove(ou).clearTimer(B)}});Wl(uu,{displayName:`Schema`});var du=class{constructor(){this.setCtx=e=>{this.#t=e},this.chain=()=>{if(this.#t==null)throw Ke();let e=this.#t,t=[],n=this.get.bind(this),r={run:()=>{let n=Pi(...t),r=e.get(z);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:i.bind(this)};function i(e,i){let a=n(e);return t.push(a(i)),r}return r}}#e=new Ye;#t=null;get ctx(){return this.#t}create(e,t){let n=e.create(this.#e.sliceMap);return n.set(t),n}get(e){return this.#e.get(e).get()}remove(e){return this.#e.remove(e)}call(e,t){if(this.#t==null)throw Ke();let n=this.get(e)(t),r=this.#t.get(z);return n(r.state,r.dispatch,r)}inline(e){if(this.#t==null)throw Ke();let t=this.#t.get(z);return e(t.state,t.dispatch,t)}};function fu(e=`cmdKey`){return v((()=>()=>!1),e)}var H=v(new du,`commands`),pu=v([B],`commandsTimer`),mu=rt(`CommandsReady`),hu=e=>{let t=new du;return t.setCtx(e),e.inject(H,t).inject(pu,[B]).record(mu),async()=>(await e.waitTimers(pu),e.done(mu),()=>{e.remove(H).remove(pu).clearTimer(mu)})};Wl(hu,{displayName:`Commands`});function gu(e){return e.Backspace=Pi(Vi,ii,si,ui),e}var _u=class{constructor(){this.setCtx=e=>{this.#e=e},this.add=e=>(this.#t.push(e),()=>{this.#t=this.#t.filter(t=>t!==e)}),this.addObjectKeymap=e=>{let t=[];return Object.entries(e).forEach(([e,n])=>{if(typeof n==`function`){let r={key:e,onRun:()=>n};this.#t.push(r),t.push(()=>{this.#t=this.#t.filter(e=>e!==r)})}else this.#t.push(n),t.push(()=>{this.#t=this.#t.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{let e=gu(zi);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#t.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,r)=>{let i=this.#e;if(i==null)throw ze();return Pi(...n.map(e=>e.onRun(i)))(e,t,r)}]}))}}#e=null;#t=[];get ctx(){return this.#e}},vu=v(new _u,`keymap`),yu=v([B],`keymapTimer`),bu=rt(`KeymapReady`),xu=e=>{let t=new _u;return t.setCtx(e),e.inject(vu,t).inject(yu,[B]).record(bu),async()=>(await e.waitTimers(yu),e.done(bu),()=>{e.remove(vu).remove(yu).clearTimer(bu)})},Su=rt(`ParserReady`),Cu=(()=>{throw ze()}),wu=v(Cu,`parser`),Tu=v([],`parserTimer`),Eu=e=>(e.inject(wu,Cu).inject(Tu,[B]).record(Su),async()=>{await e.waitTimers(Tu);let t=e.get(eu),n=e.get(V);return e.set(wu,Ca.create(n,t)),e.done(Su),()=>{e.remove(wu).remove(Tu).clearTimer(Su)}});Wl(Eu,{displayName:`Parser`});var Du=rt(`SerializerReady`),Ou=v([],`serializerTimer`),ku=(()=>{throw ze()}),Au=v(ku,`serializer`),ju=e=>(e.inject(Au,ku).inject(Ou,[B]).record(Du),async()=>{await e.waitTimers(Ou);let t=e.get(eu),n=e.get(V);return e.set(Au,Ea.create(n,t)),e.done(Du),()=>{e.remove(Au).remove(Ou).clearTimer(Du)}});Wl(ju,{displayName:`Serializer`});var Mu=v(``,`defaultValue`),Nu=v(e=>e,`stateOptions`),Pu=v([],`editorStateTimer`),Fu=rt(`EditorStateReady`);function Iu(e,t,n){if(typeof e==`string`)return t(e);if(e.type===`html`)return an.fromSchema(n).parse(e.dom);if(e.type===`json`)return kt.fromJSON(n,e.value);throw Ie(e)}var Lu=new k(`MILKDOWN_STATE_TRACKER`),Ru=e=>(e.inject(Mu,``).inject(Kl,{}).inject(Nu,e=>e).inject(Pu,[Su,Du,mu,bu]).record(Fu),async()=>{await e.waitTimers(Pu);let t=e.get(V),n=e.get(wu),r=e.get(Yl),i=e.get(Nu),a=e.get(Xl),o=Iu(e.get(Mu),n,t),s=e.get(vu),c=s.addBaseKeymap(),l=[...a,new O({key:Lu,state:{init:()=>{},apply:(t,n,r,i)=>{e.set(Kl,i)}}}),na({rules:r}),va(s.build())];e.set(Xl,l);let u=i({schema:t,doc:o,plugins:l}),d=ei.create(u);return e.set(Kl,d),e.done(Fu),()=>{c(),e.remove(Mu).remove(Kl).remove(Nu).remove(Pu).clearTimer(Fu)}});Wl(Ru,{displayName:`EditorState`});var zu=v([],`pasteRule`),Bu=v([B],`pasteRuleTimer`),Vu=rt(`PasteRuleReady`),Hu=e=>(e.inject(zu,[]).inject(Bu,[B]).record(Vu),async()=>(await e.waitTimers(Bu),e.done(Vu),()=>{e.remove(zu).remove(Bu).clearTimer(Vu)}));Wl(Hu,{displayName:`PasteRule`});var Uu=rt(`EditorViewReady`),Wu=v([],`editorViewTimer`),Gu=v({},`editorViewOptions`),Ku=v(null,`root`),qu=v(null,`rootDOM`),Ju=v({},`rootAttrs`);function Yu(e,t){let n=document.createElement(`div`);n.className=`milkdown`,e.appendChild(n),t.set(qu,n);let r=t.get(Ju);return Object.entries(r).forEach(([e,t])=>n.setAttribute(e,t)),n}function Xu(e){e.classList.add(`editor`),e.setAttribute(`role`,`textbox`)}var Zu=new k(`MILKDOWN_VIEW_CLEAR`),Qu=e=>(e.inject(Ku,document.body).inject(z,{}).inject(Gu,{}).inject(qu,null).inject(Ju,{}).inject(Wu,[Fu,Vu]).record(Uu),async()=>{await e.wait(iu);let t=e.get(Ku)||document.body,n=typeof t==`string`?document.querySelector(t):t;e.update(Xl,t=>[new O({key:Zu,view:t=>{let r=n?Yu(n,e):void 0;return(()=>{if(r&&n){let e=t.dom;n.replaceChild(r,e),r.appendChild(e)}})(),{destroy:()=>{r?.parentNode&&r?.parentNode.replaceChild(t.dom,r),r?.remove()}}}}),...t]),await e.waitTimers(Wu);let r=e.get(Kl),i=e.get(Gu),a=new Il(n,{state:r,nodeViews:Object.fromEntries(e.get(Ql)),markViews:Object.fromEntries(e.get($l)),transformPasted:(t,n,r)=>(e.get(zu).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...i});return Xu(a.dom),e.set(z,a),e.done(Uu),()=>{a?.destroy(),e.remove(Ku).remove(z).remove(Gu).remove(qu).remove(Ju).remove(Wu).clearTimer(Uu)}});Wl(Qu,{displayName:`EditorView`});var $u=function(e){return e.Idle=`Idle`,e.OnCreate=`OnCreate`,e.Created=`Created`,e.OnDestroy=`OnDestroy`,e.Destroyed=`Destroyed`,e}({}),ed=class e{constructor(){this.enableInspector=(e=!0)=>(this.#e=e,this),this.onStatusChange=e=>(this.#r=e,this),this.config=e=>(this.#n.push(e),this),this.removeConfig=e=>(this.#n=this.#n.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(e=>{this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#t===$u.Created&&this.#u(t,this.#o),this},this.remove=async e=>this.#t===$u.OnCreate?(console.warn(`[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code.`),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#d([e].flat(),!0),this),this.create=async()=>this.#t===$u.OnCreate?this:(this.#t===$u.Created&&await this.destroy(),this.#p($u.OnCreate),this.#l(),this.#u([...this.#o.keys()],this.#o),await Promise.all([this.#m(this.#s),this.#m(this.#o)].flat()),this.#p($u.Created),this),this.destroy=async(e=!1)=>this.#t===$u.Destroyed||this.#t===$u.OnDestroy?this:this.#t===$u.OnCreate?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#n=[]),this.#p($u.OnDestroy),await this.#d([...this.#o.keys()],e),await this.#f(),this.#p($u.Destroyed),this),this.action=e=>e(this.#c),this.inspect=()=>this.#e?[...this.#s.values(),...this.#o.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}#e=!1;#t=$u.Idle;#n=[];#r=()=>void 0;#i=new Ye;#a=new et;#o=new Map;#s=new Map;#c=new $e(this.#i,this.#a);#l=()=>{let e=ru(async e=>{await Promise.all(this.#n.map(t=>Promise.resolve(t(e))))}),t=[uu,Eu,ju,hu,xu,Hu,Ru,Qu,au(this),e];this.#u(t,this.#s)};#u=(e,t)=>{e.forEach(e=>{let n=this.#c.produce(this.#e?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})};#d=(e,t=!1)=>Promise.all([e].flat().map(async e=>{let n=this.#o.get(e)?.cleanup;return t?this.#o.delete(e):this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof n==`function`?n():n}));#f=async()=>{await Promise.all([...this.#s.entries()].map(async([e,{cleanup:t}])=>typeof t==`function`?t():t)),this.#s.clear()};#p=e=>{this.#t=e,this.#r(e)};#m=e=>[...e.entries()].map(async([t,n])=>{let{ctx:r,handler:i}=n;if(!i)return;let a=await i();e.set(t,{ctx:r,handler:i,cleanup:a})});get ctx(){return this.#c}get status(){return this.#t}},td=e=>crypto.getRandomValues(new Uint8Array(e)),nd=(e,t,n)=>{let r=256-256%e.length;if(r===256){let r=e.length-1;return(i=t)=>{if(!i)return``;let a=``;for(;;){let t=n(i),o=i;for(;o--;)if(a+=e[t[o]&r],a.length>=i)return a}}}let i=Math.ceil(1.6*256*t/r);return(a=t)=>{if(!a)return``;let o=``;for(;;){let t=n(i),s=i;for(;s--;)if(t[s]<r&&(o+=e[t[s]%e.length],o.length>=a))return o}}};((e,t=21)=>nd(e,t|0,td))(`abcedfghicklmn`,10);function U(e,t){let n=fu(e),r=i=>async()=>{r.key=n,await i.wait(mu);let a=t(i);return i.get(H).create(n,a),r.run=t=>i.get(H).call(e,t),()=>{i.get(H).remove(n)}};return r}function W(e){let t=n=>async()=>{await n.wait(B);let r=e(n);return n.update(Yl,e=>[...e,r]),t.inputRule=r,()=>{n.update(Yl,e=>e.filter(e=>e!==r))}};return t}function rd(e){let t=n=>async()=>{await n.wait(B);let r=e(n);return n.update(zu,e=>[...e,r]),t.pasteRule=r,()=>{n.update(zu,e=>e.filter(e=>e!==r))}};return t}function id(e,t){let n=r=>async()=>{let i=t(r);return r.update(cu,t=>[...t.filter(t=>t[0]!==e),[e,i]]),n.id=e,n.schema=i,()=>{r.update(cu,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{let n=t.get(V).marks[e];if(!n)throw Je(e);return n},n}function ad(e,t){let n=r=>async()=>{let i=t(r);return r.update(su,t=>[...t.filter(t=>t[0]!==e),[e,i]]),n.id=e,n.schema=i,()=>{r.update(su,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{let n=t.get(V).nodes[e];if(!n)throw qe(e);return n},n}function od(e){let t,n=n=>async()=>(await n.wait(B),t=e(n),n.update(Xl,e=>[...e,t]),()=>{n.update(Xl,e=>e.filter(e=>e!==t))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function sd(e){let t=n=>async()=>{await n.wait(bu);let r=n.get(vu),i=e(n),a=r.addObjectKeymap(i);return t.keymap=i,()=>{a()}};return t}function cd(e,t){let n=r=>async()=>{await r.wait(B);let i=t(r);return e.type(r)instanceof Xt?r.update(Ql,t=>[...t,[e.id,i]]):r.update($l,t=>[...t,[e.id,i]]),n.view=i,n.type=e,()=>{e.type(r)instanceof Xt?r.update(Ql,t=>t.filter(t=>t[0]!==e.id)):r.update($l,t=>t.filter(t=>t[0]!==e.id))}};return n}function ld(e,t){let n=v(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}function G(e,t){let n=ld(t,e),r=ad(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.node=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>G(e,n(t)),i}function ud(e,t){let n=ld(t,e),r=id(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.mark=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>ud(e,n(t)),i}function K(e,t){let n=ld(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),r=sd(e=>{let r=e.get(n.key),i=Object.entries(t).flatMap(([e,{command:t}])=>{let n=r[e],i=[n.shortcuts].flat(),a=n.priority;return i.map(e=>[e,{key:e,onRun:t,priority:a}])});return Object.fromEntries(i)}),i=[n,r];return i.ctx=n,i.shortcuts=r,i.key=n.key,i.keymap=r.keymap,i}var dd=(e,t=()=>({}))=>ld(t,`${e}Attr`),fd=(e,t=()=>({}))=>ld(t,`${e}Attr`);function pd(e,t,n){let r=ld(n??{},e),i=e=>async()=>{await e.wait(iu);let n={plugin:t(e),options:e.get(r.key)};return e.update(Zl,e=>[...e,n]),()=>{e.update(Zl,e=>e.filter(e=>e!==n))}},a=[r,i];return a.id=e,a.plugin=i,a.options=r,a}function md(e,t){return n=>n.get(H).call(e,t)}function hd(e){return t=>{let n=t.get(z),r=t.get(V),i=t.get(Au);if(!e)return i(n.state.doc);let a=n.state.doc.slice(e.from,e.to,!0),o=r.topNodeType.createAndFill(null,a.content);return o?i(o):(console.error(`No document found`),``)}}function gd(e,t=!1){return n=>{let r=n.get(z),i=n.get(wu)(e);if(!i)return;if(!t){let e=r.state.selection.content();return r.dispatch(r.state.tr.replaceSelection(new S(i.content,e.openStart,e.openEnd)).scrollIntoView())}let a=n.get(V),o=yn.fromSchema(a).serializeFragment(i.content),s=an.fromSchema(a).parseSlice(o),c=oa(s);if(c){r.dispatch(r.state.tr.replaceSelectionWith(c,!0));return}r.dispatch(r.state.tr.replaceSelection(s))}}function _d(e,t=!1){return n=>{let r=n.get(z),i=n.get(wu)(e);if(!i)return;if(!t){let{state:e}=r;return r.dispatch(e.tr.replace(0,e.doc.content.size,new S(i.content,0,0)))}let a=n.get(V),o=n.get(Nu)({schema:a,doc:i,plugins:n.get(Xl)}),s=ei.create(o);r.updateState(s)}}function vd(e,t){return function(n,r){let{$from:i,$to:a,node:o}=n.selection;if(o&&o.isBlock||i.depth<2||!i.sameParent(a))return!1;let s=i.node(-1);if(s.type!=e)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=e||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let t=b.empty,a=i.index(-1)?1:i.index(-2)?2:3;for(let e=i.depth-a;e>=i.depth-3;e--)t=b.from(i.node(e).copy(t));let o=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;t=t.append(b.from(e.createAndFill()));let s=i.before(i.depth-(a-1)),c=n.tr.replace(s,i.after(-o),new S(t,4-a,0)),l=-1;c.doc.nodesBetween(s,c.doc.content.size,(e,t)=>{if(l>-1)return!1;e.isTextblock&&e.content.size==0&&(l=t+1)}),l>-1&&c.setSelection(T.near(c.doc.resolve(l))),r(c.scrollIntoView())}return!0}let c=a.pos==i.end()?s.contentMatchAt(0).defaultType:null,l=n.tr.delete(i.pos,a.pos),u=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return lr(l.doc,i.pos,2,u)?(r&&r(l.split(i.pos,2,u).scrollIntoView()),!0):!1}}function yd(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?bd(t,n,e,a):xd(t,n,a):!0:!1}}function bd(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new Gn(a-1,o,a,o,new S(b.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Dt(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=Zn(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return dr(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function xd(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?b.empty:b.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new Gn(d-+!!s,f+ +!!c,d+1,f-1,new S((s?b.empty:b.from(i.copy(b.empty))).append(c?b.empty:b.from(i.copy(b.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function Sd(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=b.from(r?e.create():null),o=new S(b.from(e.create(null,b.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new Gn(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}function Cd(e){let t=new Map;if(!e||!e.type)throw Error(`mdast-util-definitions expected node`);return d(e,`definition`,function(e){let n=wd(e.identifier);n&&!t.get(n)&&t.set(n,e)}),n;function n(e){let n=wd(e);return t.get(n)}}function wd(e){return String(e||``).toUpperCase()}function Td(){return function(e){let t=Cd(e);d(e,function(e,n,r){if(e.type===`definition`&&r!==void 0&&typeof n==`number`)return r.children.splice(n,1),[o,n];if(e.type===`imageReference`||e.type===`linkReference`){let i=t(e.identifier);if(i&&r&&typeof n==`number`)return r.children[n]=e.type===`imageReference`?{type:`image`,url:i.url,title:i.title,alt:e.alt}:{type:`link`,url:i.url,title:i.title,children:e.children},[o,n]}})}}function Ed(e,t){if(!(t.childCount>=1&&t.lastChild?.type.name===`hardbreak`)){e.next(t.content);return}let n=[];t.content.forEach((e,r,i)=>{i!==t.childCount-1&&n.push(e)}),e.next(b.fromArray(n))}function q(e,t){return Object.assign(e,{meta:{package:`@milkdown/preset-commonmark`,...t}}),e}var Dd=fd(`emphasis`);q(Dd,{displayName:`Attr<emphasis>`,group:`Emphasis`});var Od=ud(`emphasis`,e=>({attrs:{marker:{default:e.get(tu).emphasis||`*`,validate:`string`}},parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style`,getAttrs:e=>e===`italic`}],toDOM:t=>[`em`,e.get(Dd.key)(t)],parseMarkdown:{match:e=>e.type===`emphasis`,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`emphasis`,runner:(e,t)=>{e.withMark(t,`emphasis`,void 0,{marker:t.attrs.marker})}}}));q(Od.mark,{displayName:`MarkSchema<emphasis>`,group:`Emphasis`}),q(Od.ctx,{displayName:`MarkSchemaCtx<emphasis>`,group:`Emphasis`});var kd=U(`ToggleEmphasis`,e=>()=>Ni(Od.type(e)));q(kd,{displayName:`Command<toggleEmphasisCommand>`,group:`Emphasis`});var Ad=W(e=>ra(/(?:^|[^*])\*([^*]+)\*$/,Od.type(e),{getAttr:()=>({marker:`*`}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith(`*`)?{}:{fullMatch:e.slice(1),start:t+1}}));q(Ad,{displayName:`InputRule<emphasis>|Star`,group:`Emphasis`});var jd=W(e=>ra(/\b_(?![_\s])(.*?[^_\s])_\b/,Od.type(e),{getAttr:()=>({marker:`_`}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith(`_`)?{}:{fullMatch:e.slice(1),start:t+1}}));q(jd,{displayName:`InputRule<emphasis>|Underscore`,group:`Emphasis`});var Md=K(`emphasisKeymap`,{ToggleEmphasis:{shortcuts:`Mod-i`,command:e=>{let t=e.get(H);return()=>t.call(kd.key)}}});q(Md.ctx,{displayName:`KeymapCtx<emphasis>`,group:`Emphasis`}),q(Md.shortcuts,{displayName:`Keymap<emphasis>`,group:`Emphasis`});var Nd=fd(`strong`);q(Nd,{displayName:`Attr<strong>`,group:`Strong`});var Pd=ud(`strong`,e=>({attrs:{marker:{default:e.get(tu).strong||`*`,validate:`string`}},parseDOM:[{tag:`b`,getAttrs:e=>e.style.fontWeight!=`normal`&&null},{tag:`strong`},{style:`font-style`,getAttrs:e=>e===`bold`},{style:`font-weight=400`,clearMark:e=>e.type.name==`strong`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:t=>[`strong`,e.get(Nd.key)(t)],parseMarkdown:{match:e=>e.type===`strong`,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`strong`,runner:(e,t)=>{e.withMark(t,`strong`,void 0,{marker:t.attrs.marker})}}}));q(Pd.mark,{displayName:`MarkSchema<strong>`,group:`Strong`}),q(Pd.ctx,{displayName:`MarkSchemaCtx<strong>`,group:`Strong`});var Fd=U(`ToggleStrong`,e=>()=>Ni(Pd.type(e)));q(Fd,{displayName:`Command<toggleStrongCommand>`,group:`Strong`});var Id=W(e=>ra(/(?<![\w:/])(?:\*\*|__)([^*_]+?)(?:\*\*|__)(?![\w/])$/,Pd.type(e),{getAttr:e=>({marker:e[0].startsWith(`*`)?`*`:`_`})}));q(Id,{displayName:`InputRule<strong>`,group:`Strong`});var Ld=K(`strongKeymap`,{ToggleBold:{shortcuts:[`Mod-b`],command:e=>{let t=e.get(H);return()=>t.call(Fd.key)}}});q(Ld.ctx,{displayName:`KeymapCtx<strong>`,group:`Strong`}),q(Ld.shortcuts,{displayName:`Keymap<strong>`,group:`Strong`});var Rd=fd(`inlineCode`);q(Rd,{displayName:`Attr<inlineCode>`,group:`InlineCode`});var zd=ud(`inlineCode`,e=>({priority:100,code:!0,parseDOM:[{tag:`code`}],toDOM:t=>[`code`,e.get(Rd.key)(t)],parseMarkdown:{match:e=>e.type===`inlineCode`,runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`inlineCode`,runner:(e,t,n)=>(e.withMark(t,`inlineCode`,n.text||``),!0)}}));q(zd.mark,{displayName:`MarkSchema<inlineCode>`,group:`InlineCode`}),q(zd.ctx,{displayName:`MarkSchemaCtx<inlineCode>`,group:`InlineCode`});var Bd=U(`ToggleInlineCode`,e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(r.empty)return!1;let{from:a,to:o}=r;return t.doc.rangeHasMark(a,o,zd.type(e))?(n?.(i.removeMark(a,o,zd.type(e))),!0):(Object.keys(t.schema.marks).filter(e=>e!==zd.type.name).map(e=>t.schema.marks[e]).forEach(e=>{i.removeMark(a,o,e)}),n?.(i.addMark(a,o,zd.type(e).create())),!0)});q(Bd,{displayName:`Command<toggleInlineCodeCommand>`,group:`InlineCode`});var Vd=W(e=>ra(/(?:`)([^`]+)(?:`)$/,zd.type(e)));q(Vd,{displayName:`InputRule<inlineCodeInputRule>`,group:`InlineCode`});var Hd=K(`inlineCodeKeymap`,{ToggleInlineCode:{shortcuts:`Mod-e`,command:e=>{let t=e.get(H);return()=>t.call(Bd.key)}}});q(Hd.ctx,{displayName:`KeymapCtx<inlineCode>`,group:`InlineCode`}),q(Hd.shortcuts,{displayName:`Keymap<inlineCode>`,group:`InlineCode`});var Ud=fd(`link`);q(Ud,{displayName:`Attr<link>`,group:`Link`});var Wd=ud(`link`,e=>({attrs:{href:{validate:`string`},title:{default:null,validate:`string|null`}},parseDOM:[{tag:`a[href]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ge(e);return{href:e.getAttribute(`href`),title:e.getAttribute(`title`)}}}],toDOM:t=>[`a`,{...e.get(Ud.key)(t),...t.attrs}],parseMarkdown:{match:e=>e.type===`link`,runner:(e,t,n)=>{let r=t.url,i=t.title;e.openMark(n,{href:r,title:i}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`link`,runner:(e,t)=>{e.withMark(t,`link`,void 0,{title:t.attrs.title,url:t.attrs.href})}}}));q(Wd.mark,{displayName:`MarkSchema<link>`,group:`Link`});var Gd=U(`ToggleLink`,e=>(t={})=>Ni(Wd.type(e),t));q(Gd,{displayName:`Command<toggleLinkCommand>`,group:`Link`});var Kd=U(`UpdateLink`,e=>(t={})=>(n,r)=>{if(!r)return!1;let i,a=-1,{selection:o}=n,{from:s,to:c}=o;if(n.doc.nodesBetween(s,s===c?c+1:c,(t,n)=>{if(Wd.type(e).isInSet(t.marks))return i=t,a=n,!1}),!i)return!1;let l=i.marks.find(({type:t})=>t===Wd.type(e));if(!l)return!1;let u=a,d=a+i.nodeSize,{tr:f}=n,p=Wd.type(e).create({...l.attrs,...t});return p?(r(f.removeMark(u,d,l).addMark(u,d,p).setSelection(new E(f.selection.$anchor)).scrollIntoView()),!0):!1});q(Kd,{displayName:`Command<updateLinkCommand>`,group:`Link`});var qd=ad(`doc`,()=>({content:`block+`,parseMarkdown:{match:({type:e})=>e===`root`,runner:(e,t,n)=>{e.injectRoot(t,n)}},toMarkdown:{match:e=>e.type.name===`doc`,runner:(e,t)=>{e.openNode(`root`),e.next(t.content)}}}));q(qd,{displayName:`NodeSchema<doc>`,group:`Doc`});function Jd(e){return te(e,e=>e.type===`html`&&[`<br />`,`<br>`,`<br >`,`<br/>`].includes(e.value?.trim()),(e,t)=>{if(!t.length)return;let n=t[t.length-1];if(!n)return;let r=n.children.indexOf(e);r!==-1&&n.children.splice(r,1)},!0)}var Yd=pd(`remark-preserve-empty-line`,()=>()=>Jd);q(Yd.plugin,{displayName:`Remark<remarkPreserveEmptyLine>`,group:`Remark`}),q(Yd.options,{displayName:`RemarkConfig<remarkPreserveEmptyLine>`,group:`Remark`});var Xd=dd(`paragraph`);q(Xd,{displayName:`Attr<paragraph>`,group:`Paragraph`});var Zd=G(`paragraph`,e=>({content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM:t=>[`p`,e.get(Xd.key)(t),0],parseMarkdown:{match:e=>e.type===`paragraph`,runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||``),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`paragraph`,runner:(t,n)=>{let r=e.get(z).state?.doc.lastChild;t.openNode(`paragraph`),(!n.content||n.content.size===0)&&n!==r&&Qd(e)?t.addNode(`html`,void 0,`<br />`):Ed(t,n),t.closeNode()}}}));function Qd(e){let t=!1;try{e.get(Yd.id),t=!0}catch{t=!1}return t}q(Zd.node,{displayName:`NodeSchema<paragraph>`,group:`Paragraph`}),q(Zd.ctx,{displayName:`NodeSchemaCtx<paragraph>`,group:`Paragraph`});var $d=U(`TurnIntoText`,e=>()=>Ai(Zd.type(e)));q($d,{displayName:`Command<turnIntoTextCommand>`,group:`Paragraph`});var ef=K(`paragraphKeymap`,{TurnIntoText:{shortcuts:`Mod-Alt-0`,command:e=>{let t=e.get(H);return()=>t.call($d.key)}}});q(ef.ctx,{displayName:`KeymapCtx<paragraph>`,group:`Paragraph`}),q(ef.shortcuts,{displayName:`Keymap<paragraph>`,group:`Paragraph`});var tf=[,,,,,,].fill(0).map((e,t)=>t+1);function nf(e){return e.textContent.toLowerCase().trim().replace(/\s+/g,`-`)}var rf=ld(nf,`headingIdGenerator`);q(rf,{displayName:`Ctx<HeadingIdGenerator>`,group:`Heading`});var af=dd(`heading`);q(af,{displayName:`Attr<heading>`,group:`Heading`});var of=G(`heading`,e=>{let t=e.get(rf.key);return{content:`inline*`,group:`block`,defining:!0,attrs:{id:{default:``,validate:`string`},level:{default:1,validate:`number`}},parseDOM:tf.map(e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw Ge(t);return{level:e,id:t.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...e.get(af.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>e===`heading`,runner:(e,t,n)=>{let r=t.depth;e.openNode(n,{level:r}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`heading`,runner:(e,t)=>{e.openNode(`heading`,void 0,{depth:t.attrs.level}),Ed(e,t),e.closeNode()}}}});q(of.node,{displayName:`NodeSchema<heading>`,group:`Heading`}),q(of.ctx,{displayName:`NodeSchemaCtx<heading>`,group:`Heading`});var sf=W(e=>Ui(/^(?<hashes>#+)\s$/,of.type(e),t=>{let n=t.groups?.hashes?.length||0,{$from:r}=e.get(z).state.selection,i=r.node();if(i.type.name===`heading`){let e=Number(i.attrs.level)+Number(n);return e>6&&(e=6),{level:e}}return{level:n}}));q(sf,{displayName:`InputRule<wrapInHeadingInputRule>`,group:`Heading`});var cf=U(`WrapInHeading`,e=>t=>(t??=1,t<1?Ai(Zd.type(e)):Ai(of.type(e),{level:t})));q(cf,{displayName:`Command<wrapInHeadingCommand>`,group:`Heading`});var lf=U(`DowngradeHeading`,e=>()=>(t,n,r)=>{let{$from:i}=t.selection,a=i.node();if(a.type!==of.type(e)||!t.selection.empty||i.parentOffset!==0)return!1;let o=a.attrs.level-1;return o?(n?.(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...a.attrs,level:o})),!0):Ai(Zd.type(e))(t,n,r)});q(lf,{displayName:`Command<downgradeHeadingCommand>`,group:`Heading`});var uf=K(`headingKeymap`,{TurnIntoH1:{shortcuts:`Mod-Alt-1`,command:e=>{let t=e.get(H);return()=>t.call(cf.key,1)}},TurnIntoH2:{shortcuts:`Mod-Alt-2`,command:e=>{let t=e.get(H);return()=>t.call(cf.key,2)}},TurnIntoH3:{shortcuts:`Mod-Alt-3`,command:e=>{let t=e.get(H);return()=>t.call(cf.key,3)}},TurnIntoH4:{shortcuts:`Mod-Alt-4`,command:e=>{let t=e.get(H);return()=>t.call(cf.key,4)}},TurnIntoH5:{shortcuts:`Mod-Alt-5`,command:e=>{let t=e.get(H);return()=>t.call(cf.key,5)}},TurnIntoH6:{shortcuts:`Mod-Alt-6`,command:e=>{let t=e.get(H);return()=>t.call(cf.key,6)}},DowngradeHeading:{shortcuts:[`Delete`,`Backspace`],command:e=>{let t=e.get(H);return()=>t.call(lf.key)}}});q(uf.ctx,{displayName:`KeymapCtx<heading>`,group:`Heading`}),q(uf.shortcuts,{displayName:`Keymap<heading>`,group:`Heading`});var df=dd(`blockquote`);q(df,{displayName:`Attr<blockquote>`,group:`Blockquote`});var ff=G(`blockquote`,e=>({content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM:t=>[`blockquote`,e.get(df.key)(t),0],parseMarkdown:{match:({type:e})=>e===`blockquote`,runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`blockquote`,runner:(e,t)=>{e.openNode(`blockquote`).next(t.content).closeNode()}}}));q(ff.node,{displayName:`NodeSchema<blockquote>`,group:`Blockquote`}),q(ff.ctx,{displayName:`NodeSchemaCtx<blockquote>`,group:`Blockquote`});var pf=W(e=>Hi(/^\s*>\s$/,ff.type(e)));q(pf,{displayName:`InputRule<wrapInBlockquoteInputRule>`,group:`Blockquote`});var mf=U(`WrapInBlockquote`,e=>()=>ki(ff.type(e)));q(mf,{displayName:`Command<wrapInBlockquoteCommand>`,group:`Blockquote`});var hf=K(`blockquoteKeymap`,{WrapInBlockquote:{shortcuts:`Mod-Shift-b`,command:e=>{let t=e.get(H);return()=>t.call(mf.key)}}});q(hf.ctx,{displayName:`KeymapCtx<blockquote>`,group:`Blockquote`}),q(hf.shortcuts,{displayName:`Keymap<blockquote>`,group:`Blockquote`});var gf=dd(`codeBlock`,()=>({pre:{},code:{}}));q(gf,{displayName:`Attr<codeBlock>`,group:`CodeBlock`});var _f=G(`code_block`,e=>({content:`text*`,group:`block`,marks:``,defining:!0,code:!0,attrs:{language:{default:``,validate:`string`}},parseDOM:[{tag:`pre`,preserveWhitespace:`full`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ge(e);return{language:e.dataset.language}}}],toDOM:t=>{let n=e.get(gf.key)(t),r=t.attrs.language,i=r&&r.length>0?{"data-language":r}:void 0;return[`pre`,{...n.pre,...i},[`code`,n.code,0]]},parseMarkdown:{match:({type:e})=>e===`code`,runner:(e,t,n)=>{let r=t.lang??``,i=t.value;e.openNode(n,{language:r}),i&&e.addText(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`code_block`,runner:(e,t)=>{e.addNode(`code`,void 0,t.content.firstChild?.text||``,{lang:t.attrs.language})}}}));q(_f.node,{displayName:`NodeSchema<codeBlock>`,group:`CodeBlock`}),q(_f.ctx,{displayName:`NodeSchemaCtx<codeBlock>`,group:`CodeBlock`});var vf=W(e=>Ui(/^```(?<language>[a-z]*)?[\s\n]$/,_f.type(e),e=>({language:e.groups?.language??``})));q(vf,{displayName:`InputRule<createCodeBlockInputRule>`,group:`CodeBlock`});var yf=U(`CreateCodeBlock`,e=>(t=``)=>Ai(_f.type(e),{language:t}));q(yf,{displayName:`Command<createCodeBlockCommand>`,group:`CodeBlock`}),q(U(`UpdateCodeBlockLanguage`,()=>({pos:e,language:t}={pos:-1,language:``})=>(n,r)=>e>=0?(r?.(n.tr.setNodeAttribute(e,`language`,t)),!0):!1),{displayName:`Command<updateCodeBlockLanguageCommand>`,group:`CodeBlock`});var bf=K(`codeBlockKeymap`,{CreateCodeBlock:{shortcuts:`Mod-Alt-c`,command:e=>{let t=e.get(H);return()=>t.call(yf.key)}}});q(bf.ctx,{displayName:`KeymapCtx<codeBlock>`,group:`CodeBlock`}),q(bf.shortcuts,{displayName:`Keymap<codeBlock>`,group:`CodeBlock`});var xf=dd(`image`);q(xf,{displayName:`Attr<image>`,group:`Image`});var Sf=G(`image`,e=>({inline:!0,group:`inline`,selectable:!0,draggable:!0,marks:``,atom:!0,defining:!0,isolating:!0,attrs:{src:{default:``,validate:`string`},alt:{default:``,validate:`string`},title:{default:``,validate:`string`}},parseDOM:[{tag:`img[src]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ge(e);return{src:e.getAttribute(`src`)||``,alt:e.getAttribute(`alt`)||``,title:e.getAttribute(`title`)||e.getAttribute(`alt`)||``}}}],toDOM:t=>[`img`,{...e.get(xf.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>e===`image`,runner:(e,t,n)=>{let r=t.url,i=t.alt,a=t.title;e.addNode(n,{src:r,alt:i,title:a})}},toMarkdown:{match:e=>e.type.name===`image`,runner:(e,t)=>{e.addNode(`image`,void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));q(Sf.node,{displayName:`NodeSchema<image>`,group:`Image`}),q(Sf.ctx,{displayName:`NodeSchemaCtx<image>`,group:`Image`});var Cf=U(`InsertImage`,e=>(t={})=>(n,r)=>{if(!r)return!0;let{src:i=``,alt:a=``,title:o=``}=t,s=Sf.type(e).create({src:i,alt:a,title:o});return s&&r(n.tr.replaceSelectionWith(s).scrollIntoView()),!0});q(Cf,{displayName:`Command<insertImageCommand>`,group:`Image`});var wf=U(`UpdateImage`,e=>(t={})=>(n,r)=>{let i=da(n.selection,Sf.type(e));if(!i)return!1;let{node:a,pos:o}=i,s={...a.attrs},{src:c,alt:l,title:u}=t;return c!==void 0&&(s.src=c),l!==void 0&&(s.alt=l),u!==void 0&&(s.title=u),r?.(n.tr.setNodeMarkup(o,void 0,s).scrollIntoView()),!0});q(wf,{displayName:`Command<updateImageCommand>`,group:`Image`}),q(W(e=>new A(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,n,r,i)=>{let[a,o,s=``,c]=n;return a?t.tr.replaceWith(r,i,Sf.type(e).create({src:s,alt:o,title:c})):null})),{displayName:`InputRule<insertImageInputRule>`,group:`Image`});var Tf=dd(`hardbreak`,e=>({"data-type":`hardbreak`,"data-is-inline":e.attrs.isInline}));q(Tf,{displayName:`Attr<hardbreak>`,group:`Hardbreak`});var Ef=G(`hardbreak`,e=>({inline:!0,group:`inline`,attrs:{isInline:{default:!1,validate:`boolean`}},selectable:!1,parseDOM:[{tag:`br`},{tag:`span[data-type="hardbreak"]`,getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?[`span`,e.get(Tf.key)(t),` `]:[`br`,e.get(Tf.key)(t)],parseMarkdown:{match:({type:e})=>e===`break`,runner:(e,t,n)=>{e.addNode(n,{isInline:!!t.data?.isInline})}},leafText:()=>`
32
- `,toMarkdown:{match:e=>e.type.name===`hardbreak`,runner:(e,t)=>{t.attrs.isInline?e.addNode(`text`,void 0,`
33
- `):e.addNode(`break`)}}}));q(Ef.node,{displayName:`NodeSchema<hardbreak>`,group:`Hardbreak`}),q(Ef.ctx,{displayName:`NodeSchemaCtx<hardbreak>`,group:`Hardbreak`});var Df=U(`InsertHardbreak`,e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(!(r instanceof E))return!1;if(r.empty){let e=r.$from.node();if(e.childCount>0&&e.lastChild?.type.name===`hardbreak`)return n?.(i.replaceRangeWith(r.to-1,r.to,t.schema.node(`paragraph`)).setSelection(T.near(i.doc.resolve(r.to))).scrollIntoView()),!0}return n?.(i.setMeta(`hardbreak`,!0).replaceSelectionWith(Ef.type(e).create()).scrollIntoView()),!0});q(Df,{displayName:`Command<insertHardbreakCommand>`,group:`Hardbreak`});var Of=K(`hardbreakKeymap`,{InsertHardbreak:{shortcuts:`Shift-Enter`,command:e=>{let t=e.get(H);return()=>t.call(Df.key)}}});q(Of.ctx,{displayName:`KeymapCtx<hardbreak>`,group:`Hardbreak`}),q(Of.shortcuts,{displayName:`Keymap<hardbreak>`,group:`Hardbreak`});var kf=dd(`hr`);q(kf,{displayName:`Attr<hr>`,group:`Hr`});var Af=G(`hr`,e=>({group:`block`,parseDOM:[{tag:`hr`}],toDOM:t=>[`hr`,e.get(kf.key)(t)],parseMarkdown:{match:({type:e})=>e===`thematicBreak`,runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>e.type.name===`hr`,runner:e=>{e.addNode(`thematicBreak`)}}}));q(Af.node,{displayName:`NodeSchema<hr>`,group:`Hr`}),q(Af.ctx,{displayName:`NodeSchemaCtx<hr>`,group:`Hr`});var jf=W(e=>new A(/^(?:---|___\s|\*\*\*\s)$/,(t,n,r,i)=>{let{tr:a}=t;return n[0]&&a.replaceWith(r-1,i,Af.type(e).create()),a}));q(jf,{displayName:`InputRule<insertHrInputRule>`,group:`Hr`});var Mf=U(`InsertHr`,e=>()=>(t,n)=>{if(!n)return!0;let r=Zd.node.type(e).create(),{tr:i,selection:a}=t,{from:o}=a,s=Af.type(e).create();if(!s)return!0;let c=i.replaceSelectionWith(s).insert(o,r),l=T.findFrom(c.doc.resolve(o),1,!0);return l&&n(c.setSelection(l).scrollIntoView()),!0});q(Mf,{displayName:`Command<insertHrCommand>`,group:`Hr`});var Nf=dd(`bulletList`);q(Nf,{displayName:`Attr<bulletList>`,group:`BulletList`});var Pf=G(`bullet_list`,e=>({content:`listItem+`,group:`block`,attrs:{spread:{default:!1,validate:`boolean`}},parseDOM:[{tag:`ul`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ge(e);return{spread:e.dataset.spread===`true`}}}],toDOM:t=>[`ul`,{...e.get(Nf.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e===`list`&&!t,runner:(e,t,n)=>{let r=t.spread==null?`false`:`${t.spread}`;e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`bullet_list`,runner:(e,t)=>{e.openNode(`list`,void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));q(Pf.node,{displayName:`NodeSchema<bulletList>`,group:`BulletList`}),q(Pf.ctx,{displayName:`NodeSchemaCtx<bulletList>`,group:`BulletList`});var Ff=W(e=>Hi(/^\s*([-+*])\s$/,Pf.type(e)));q(Ff,{displayName:`InputRule<wrapInBulletListInputRule>`,group:`BulletList`});var If=U(`WrapInBulletList`,e=>()=>ki(Pf.type(e)));q(If,{displayName:`Command<wrapInBulletListCommand>`,group:`BulletList`});var Lf=K(`bulletListKeymap`,{WrapInBulletList:{shortcuts:`Mod-Alt-8`,command:e=>{let t=e.get(H);return()=>t.call(If.key)}}});q(Lf.ctx,{displayName:`KeymapCtx<bulletListKeymap>`,group:`BulletList`}),q(Lf.shortcuts,{displayName:`Keymap<bulletListKeymap>`,group:`BulletList`});var Rf=dd(`orderedList`);q(Rf,{displayName:`Attr<orderedList>`,group:`OrderedList`});var zf=G(`ordered_list`,e=>({content:`listItem+`,group:`block`,attrs:{order:{default:1,validate:`number`},spread:{default:!1,validate:`boolean`}},parseDOM:[{tag:`ol`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ge(e);return{spread:e.dataset.spread,order:e.hasAttribute(`start`)?Number(e.getAttribute(`start`)):1}}}],toDOM:t=>[`ol`,{...e.get(Rf.key)(t),...t.attrs.order===1?{}:{start:t.attrs.order},"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e===`list`&&!!t,runner:(e,t,n)=>{let r=t.spread==null?`true`:`${t.spread}`;e.openNode(n,{spread:r,order:t.start??1}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`ordered_list`,runner:(e,t)=>{e.openNode(`list`,void 0,{ordered:!0,start:t.attrs.order??1,spread:t.attrs.spread===`true`}),e.next(t.content),e.closeNode()}}}));q(zf.node,{displayName:`NodeSchema<orderedList>`,group:`OrderedList`}),q(zf.ctx,{displayName:`NodeSchemaCtx<orderedList>`,group:`OrderedList`});var Bf=W(e=>Hi(/^\s*(\d+)\.\s$/,zf.type(e),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));q(Bf,{displayName:`InputRule<wrapInOrderedListInputRule>`,group:`OrderedList`});var Vf=U(`WrapInOrderedList`,e=>()=>ki(zf.type(e)));q(Vf,{displayName:`Command<wrapInOrderedListCommand>`,group:`OrderedList`});var Hf=K(`orderedListKeymap`,{WrapInOrderedList:{shortcuts:`Mod-Alt-7`,command:e=>{let t=e.get(H);return()=>t.call(Vf.key)}}});q(Hf.ctx,{displayName:`KeymapCtx<orderedList>`,group:`OrderedList`}),q(Hf.shortcuts,{displayName:`Keymap<orderedList>`,group:`OrderedList`});var Uf=dd(`listItem`);q(Uf,{displayName:`Attr<listItem>`,group:`ListItem`});var Wf=G(`list_item`,e=>({group:`listItem`,content:`paragraph block*`,attrs:{label:{default:`•`,validate:`string`},listType:{default:`bullet`,validate:`string`},spread:{default:!0,validate:`boolean`}},defining:!0,parseDOM:[{tag:`li`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ge(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread===`true`}}}],toDOM:t=>[`li`,{...e.get(Uf.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e})=>e===`listItem`,runner:(e,t,n)=>{let r=t.label==null?`•`:`${t.label}.`,i=t.label==null?`bullet`:`ordered`,a=t.spread==null?`true`:`${t.spread}`;e.openNode(n,{label:r,listType:i,spread:a}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`list_item`,runner:(e,t)=>{e.openNode(`listItem`,void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));q(Wf.node,{displayName:`NodeSchema<listItem>`,group:`ListItem`}),q(Wf.ctx,{displayName:`NodeSchemaCtx<listItem>`,group:`ListItem`});var Gf=U(`SinkListItem`,e=>()=>Sd(Wf.type(e)));q(Gf,{displayName:`Command<sinkListItemCommand>`,group:`ListItem`});var Kf=U(`LiftListItem`,e=>()=>yd(Wf.type(e)));q(Kf,{displayName:`Command<liftListItemCommand>`,group:`ListItem`});var qf=U(`SplitListItem`,e=>()=>vd(Wf.type(e)));q(qf,{displayName:`Command<splitListItemCommand>`,group:`ListItem`});function Jf(e){return(t,n,r)=>{let{selection:i}=t;if(!(i instanceof E))return!1;let{empty:a,$from:o}=i;return!a||o.parentOffset!==0||o.node(-1).type!==Wf.type(e)?!1:oi(t,n,r)}}var Yf=U(`LiftFirstListItem`,e=>()=>Jf(e));q(Yf,{displayName:`Command<liftFirstListItemCommand>`,group:`ListItem`});var Xf=K(`listItemKeymap`,{NextListItem:{shortcuts:`Enter`,command:e=>{let t=e.get(H);return()=>t.call(qf.key)}},SinkListItem:{shortcuts:[`Tab`,`Mod-]`],command:e=>{let t=e.get(H);return()=>t.call(Gf.key)}},LiftListItem:{shortcuts:[`Shift-Tab`,`Mod-[`],command:e=>{let t=e.get(H);return()=>t.call(Kf.key)}},LiftFirstListItem:{shortcuts:[`Backspace`,`Delete`],command:e=>{let t=e.get(H);return()=>t.call(Yf.key)}}});q(Xf.ctx,{displayName:`KeymapCtx<listItem>`,group:`ListItem`}),q(Xf.shortcuts,{displayName:`Keymap<listItem>`,group:`ListItem`});var Zf=ad(`text`,()=>({group:`inline`,parseMarkdown:{match:({type:e})=>e===`text`,runner:(e,t)=>{e.addText(t.value)}},toMarkdown:{match:e=>e.type.name===`text`,runner:(e,t)=>{e.addNode(`text`,void 0,t.text)}}}));q(Zf,{displayName:`NodeSchema<text>`,group:`Text`});var Qf=dd(`html`);q(Qf,{displayName:`Attr<html>`,group:`Html`});var $f=G(`html`,e=>({atom:!0,group:`inline`,inline:!0,attrs:{value:{default:``,validate:`string`}},toDOM:t=>{let n=document.createElement(`span`),r={...e.get(Qf.key)(t),"data-value":t.attrs.value,"data-type":`html`};return n.textContent=t.attrs.value,[`span`,r,t.attrs.value]},parseDOM:[{tag:`span[data-type="html"]`,getAttrs:e=>({value:e.dataset.value??``})}],parseMarkdown:{match:({type:e})=>e===`html`,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>e.type.name===`html`,runner:(e,t)=>{e.addNode(`html`,void 0,t.attrs.value)}}}));q($f.node,{displayName:`NodeSchema<html>`,group:`Html`}),q($f.ctx,{displayName:`NodeSchemaCtx<html>`,group:`Html`});var ep=[qd,Xd,Zd,rf,af,of,Tf,Ef,df,ff,gf,_f,kf,Af,xf,Sf,Nf,Pf,Rf,zf,Uf,Wf,Dd,Od,Nd,Pd,Rd,zd,Ud,Wd,Qf,$f,Zf].flat(),tp=[pf,Ff,Bf,vf,jf,sf].flat(),np=[Ad,jd,Vd,Id],rp=[$d,mf,cf,lf,yf,Df,Mf,Cf,wf,Vf,If,Gf,qf,Kf,Yf,kd,Bd,Fd,Gd,Kd,U(`IsMarkSelected`,()=>e=>t=>{if(!e)return!1;let{doc:n,selection:r}=t;return n.rangeHasMark(r.from,r.to,e)}),U(`IsNoteSelected`,()=>e=>t=>e?fa(t,e).hasNode:!1),U(`ClearTextInCurrentBlock`,()=>()=>(e,t)=>{let n=e.tr,{$from:r,$to:i}=n.selection,{pos:a}=r,{pos:o}=i,s=a-r.node().content.size;return s<0?!1:(n=n.deleteRange(s,o),t?.(n),!0)}),U(`SetBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr,{from:o,to:s}=a.selection;try{a.setBlockType(o,s,r,i)}catch{return!1}return n?.(a),!0}),U(`WrapInBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr;try{let{$from:e,$to:t}=a.selection,n=e.blockRange(t),o=n&&$n(n,r,i);if(!o)return!1;a=a.wrap(n,o)}catch{return!1}return n?.(a),!0}),U(`AddBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr;try{let e=r instanceof kt?r:r.createAndFill(i);if(!e)return!1;a.replaceSelectionWith(e)}catch{return!1}return n?.(a),!0}),U(`SelectTextNearPos`,()=>e=>(t,n)=>{let{pos:r}=e??{};if(r==null)return!1;let i=(e,t,n)=>Math.min(Math.max(e,t),n),a=t.tr;try{let e=t.doc.resolve(i(r,0,t.doc.content.size));a.setSelection(E.near(e))}catch{return!1}return n?.(a.scrollIntoView()),!0})],ip=[hf,bf,Of,uf,Xf,Hf,Lf,ef,Md,Hd,Ld].flat(),ap=pd(`remarkAddOrderInList`,()=>()=>e=>{d(e,`list`,e=>{if(e.ordered){let t=e.start??1;e.children.forEach((e,n)=>{e.label=n+t})}})});q(ap.plugin,{displayName:`Remark<remarkAddOrderInListPlugin>`,group:`Remark`}),q(ap.options,{displayName:`RemarkConfig<remarkAddOrderInListPlugin>`,group:`Remark`});var op=pd(`remarkLineBreak`,()=>()=>e=>{let t=/[\t ]*(?:\r?\n|\r)/g;d(e,`text`,(e,n,r)=>{if(!e.value||typeof e.value!=`string`)return;let i=[],a=0;t.lastIndex=0;let o=t.exec(e.value);for(;o;){let n=o.index;a!==n&&i.push({type:`text`,value:e.value.slice(a,n)}),i.push({type:`break`,data:{isInline:!0}}),a=n+o[0].length,o=t.exec(e.value)}if(i.length>0&&r&&typeof n==`number`)return a<e.value.length&&i.push({type:`text`,value:e.value.slice(a)}),r.children.splice(n,1,...i),n+i.length})});q(op.plugin,{displayName:`Remark<remarkLineBreak>`,group:`Remark`}),q(op.options,{displayName:`RemarkConfig<remarkLineBreak>`,group:`Remark`});var sp=pd(`remarkInlineLink`,()=>Td);q(sp.plugin,{displayName:`Remark<remarkInlineLinkPlugin>`,group:`Remark`}),q(sp.options,{displayName:`RemarkConfig<remarkInlineLinkPlugin>`,group:`Remark`});var cp=e=>!!e.children,lp=e=>e.type===`html`;function up(e,t){return n(e,0,null)[0];function n(e,r,i){if(cp(e)){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i){let a=n(i,r,e);if(a)for(let e=0,n=a.length;e<n;e++){let n=a[e];n&&t.push(n)}}}e.children=t}return t(e,r,i)}}var dp=[`root`,`blockquote`,`listItem`],fp=pd(`remarkHTMLTransformer`,()=>()=>e=>{up(e,(e,t,n)=>(lp(e)&&n&&dp.includes(n.type)&&(e.children=[{...e}],delete e.value,e.type=`paragraph`),[e]))});q(fp.plugin,{displayName:`Remark<remarkHtmlTransformer>`,group:`Remark`}),q(fp.options,{displayName:`RemarkConfig<remarkHtmlTransformer>`,group:`Remark`});var pp=pd(`remarkMarker`,()=>()=>(e,t)=>{let n=e=>t.value.charAt(e.position.start.offset);d(e,e=>[`strong`,`emphasis`].includes(e.type),e=>{e.marker=n(e)})});q(pp.plugin,{displayName:`Remark<remarkMarker>`,group:`Remark`}),q(pp.options,{displayName:`RemarkConfig<remarkMarker>`,group:`Remark`});var mp=od(()=>{let e=!1,t=new O({key:new k(`MILKDOWN_INLINE_NODES_CURSOR`),state:{init(){return!1},apply(e){if(!e.selection.empty)return!1;let t=e.selection.$from,n=t.nodeBefore,r=t.nodeAfter;return!!(n&&r&&n.isInline&&!n.isText&&r.isInline&&!r.isText)}},props:{handleDOMEvents:{compositionend:(n,r)=>e?(e=!1,requestAnimationFrame(()=>{if(t.getState(n.state)){let e=n.state.selection.from;r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||``,e))}}),!0):!1,compositionstart:n=>(t.getState(n.state)&&(e=!0),!1),beforeinput:(n,r)=>{if(t.getState(n.state)&&r instanceof InputEvent&&r.data&&!e){let e=n.state.selection.from;return r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||``,e)),!0}return!1}},decorations(e){if(t.getState(e)){let t=e.selection.$from.pos,n=document.createElement(`span`),r=tl.widget(t,n,{side:-1}),i=document.createElement(`span`),a=tl.widget(t,i);return setTimeout(()=>{n.contentEditable=`true`,i.contentEditable=`true`}),L.create(e.doc,[r,a])}return L.empty}}});return t});q(mp,{displayName:`Prose<inlineNodesCursorPlugin>`,group:`Prose`});var hp=od(e=>new O({key:new k(`MILKDOWN_HARDBREAK_MARKS`),appendTransaction:(t,n,r)=>{if(!t.length)return;let[i]=t;if(!i)return;let[a]=i.steps;if(i.getMeta(`hardbreak`)){if(!(a instanceof Wn))return;let{from:t}=a;return r.tr.setNodeMarkup(t,Ef.type(e),void 0,[])}if(a instanceof Bn){let t=r.tr,{from:n,to:i}=a;return r.doc.nodesBetween(n,i,(n,r)=>{n.type===Ef.type(e)&&(t=t.setNodeMarkup(r,Ef.type(e),void 0,[]))}),t}}}));q(hp,{displayName:`Prose<hardbreakClearMarkPlugin>`,group:`Prose`});var gp=ld([`table`,`code_block`],`hardbreakFilterNodes`);q(gp,{displayName:`Ctx<hardbreakFilterNodes>`,group:`Prose`});var _p=od(e=>{let t=e.get(gp.key);return new O({key:new k(`MILKDOWN_HARDBREAK_FILTER`),filterTransaction:(e,n)=>{let r=e.getMeta(`hardbreak`),[i]=e.steps;if(r&&i){let{from:e}=i,r=n.doc.resolve(e),a=r.depth,o=!0;for(;a>0;)t.includes(r.node(a).type.name)&&(o=!1),a--;return o}return!0}})});q(_p,{displayName:`Prose<hardbreakFilterPlugin>`,group:`Prose`});var vp=od(e=>{let t=new k(`MILKDOWN_HEADING_ID`),n=n=>{if(n.composing)return;let r=e.get(rf.key),i=n.state.tr.setMeta(`addToHistory`,!1),a=!1,o={};n.state.doc.descendants((n,s)=>{if(n.type===of.type(e)){if(n.textContent.trim().length===0)return;let e=n.attrs,c=r(n);o[c]?(o[c]+=1,c+=`-#${o[c]}`):o[c]=1,e.id!==c&&(a=!0,i.setMeta(t,!0).setNodeMarkup(s,void 0,{...e,id:c}))}}),a&&n.dispatch(i)};return new O({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})});q(vp,{displayName:`Prose<syncHeadingIdPlugin>`,group:`Prose`});var yp=od(e=>new O({key:new k(`MILKDOWN_KEEP_LIST_ORDER`),appendTransaction:(t,n,r)=>{if(!r.selection||t.some(e=>e.getMeta(`addToHistory`)===!1||!e.isGeneric))return null;let i=zf.type(e),a=Pf.type(e),o=Wf.type(e),s=(e,t,n=1)=>{let r=!1,i=`${t+n}.`;return e.label!==i&&(e.label=i,r=!0),r},c=r.tr,l=!1;return r.doc.descendants((e,t,n,r)=>{if(e.type===a){let n=e.maybeChild(0);n?.type===o&&n.attrs.listType===`ordered`&&(l=!0,c.setNodeMarkup(t,i,{spread:`true`}),e.descendants((e,t,n,r)=>{if(e.type===o){let n={...e.attrs};s(n,r)&&(c=c.setNodeMarkup(t,void 0,n))}return!1}))}else if(e.type===o&&n?.type===i){let i={...e.attrs},a=!1;i.listType!==`ordered`&&(i.listType=`ordered`,a=!0),n?.maybeChild(0)&&(a=s(i,r,n?.attrs.order??1)),a&&(c=c.setNodeMarkup(t,void 0,i),l=!0)}}),l?c.setMeta(`addToHistory`,!1):null}}));q(yp,{displayName:`Prose<syncListOrderPlugin>`,group:`Prose`});var bp=[ep,tp,np,rp,ip,[hp,gp,_p,mp,ap,sp,op,fp,pp,Yd,vp,yp].flat()].flat(),xp,Sp;if(typeof WeakMap<`u`){let e=new WeakMap;xp=t=>e.get(t),Sp=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;xp=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},Sp=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var J=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return xp(e)||Sp(e,Cp(e))}};function Cp(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=wp(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new J(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&Tp(s,o,e),s}function wp(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function Tp(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!c.colwidth||c.colwidth[n]!=r)&&((s||=Ep(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function Ep(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Dp(e,t){if(typeof e==`string`)return{};let n=e.getAttribute(`data-colwidth`),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(`,`).map(e=>Number(e)):null,i=Number(e.getAttribute(`colspan`)||1),a={colspan:i,rowspan:Number(e.getAttribute(`rowspan`)||1),colwidth:r&&r.length==i?r:null};for(let n in t){let r=t[n].getFromDOM,i=r&&r(e);i!=null&&(a[n]=i)}return a}function Op(e,t){let n={};e.attrs.colspan!=1&&(n.colspan=e.attrs.colspan),e.attrs.rowspan!=1&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n[`data-colwidth`]=e.attrs.colwidth.join(`,`));for(let r in t){let i=t[r].setDOMAttr;i&&i(e.attrs[r],n)}return n}function kp(e){if(e!==null){if(!Array.isArray(e))throw TypeError(`colwidth must be null or an array`);for(let t of e)if(typeof t!=`number`)throw TypeError(`colwidth must be null or an array of numbers`)}}function Ap(e){let t=e.cellAttributes||{},n={colspan:{default:1,validate:`number`},rowspan:{default:1,validate:`number`},colwidth:{default:null,validate:kp}};for(let e in t)n[e]={default:t[e].default,validate:t[e].validate};return{table:{content:`table_row+`,tableRole:`table`,isolating:!0,group:e.tableGroup,parseDOM:[{tag:`table`}],toDOM(){return[`table`,[`tbody`,0]]}},table_row:{content:`(table_cell | table_header)*`,tableRole:`row`,parseDOM:[{tag:`tr`}],toDOM(){return[`tr`,0]}},table_cell:{content:e.cellContent,attrs:n,tableRole:`cell`,isolating:!0,parseDOM:[{tag:`td`,getAttrs:e=>Dp(e,t)}],toDOM(e){return[`td`,Op(e,t),0]}},table_header:{content:e.cellContent,attrs:n,tableRole:`header_cell`,isolating:!0,parseDOM:[{tag:`th`,getAttrs:e=>Dp(e,t)}],toDOM(e){return[`th`,Op(e,t),0]}}}}function jp(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var Mp=new k(`selectingCells`);function Np(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function Pp(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function Fp(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=Np(t.$head)||Ip(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function Ip(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function Lp(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function Rp(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function zp(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Bp(e,t,n){let r=e.node(-1),i=J.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function Vp(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function Hp(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function Up(e,t,n){let r=jp(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var Y=class e extends T{constructor(e,t=e){let n=e.node(-1),r=J.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new Lr(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(Lp(r)&&Lp(i)&&zp(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return E.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=J.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=Vp(e,0,l)),u>0&&(e=Vp(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(b.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new S(b.from(o),1,1)}replace(e,t=S.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?S.empty:t)}let i=T.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new S(b.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=J.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=J.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=J.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=J.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new Wp(this.$anchorCell.pos,this.$headCell.pos)}};Y.prototype.visible=!1,T.jsonID(`cell`,Y);var Wp=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&zp(t,n)?new Y(t,n):T.near(n,1)}};function Gp(e){if(!(e.selection instanceof Y))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(tl.node(n,n+e.nodeSize,{class:`selectedCell`}))}),L.create(e.doc,t)}function Kp({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function qp({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function Jp(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof D&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=Y.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=Y.rowSelection(e,e)}else if(!n){let e=J.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=Y.create(i,t+1,n)}}else r instanceof E&&Kp(r)?a=E.create(i,r.from):r instanceof E&&qp(r)&&(a=E.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var Yp=new k(`fix-tables`);function Xp(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue outer}r(a,n),s<i&&e.child(s).sameMarkup(a)?Xp(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Zp(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=Qp(e,t,r,n))};return t?t.doc!=e.doc&&Xp(t.doc,e.doc,0,r):e.doc.descendants(r),n}function Qp(e,t,n,r){let i=J.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e<i.height;e++)a.push(0);for(let e=0;e<i.problems.length;e++){let o=i.problems[e];if(o.type==`collision`){let e=t.nodeAt(o.pos);if(!e)continue;let i=e.attrs;for(let e=0;e<i.rowspan;e++)a[o.row+e]+=o.n;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,Vp(i,i.colspan-o.n,o.n))}else if(o.type==`missing`)a[o.row]+=o.n;else if(o.type==`overlong_rowspan`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-o.n})}else if(o.type==`colwidth mismatch`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,colwidth:o.colwidth})}else if(o.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let o,s;for(let e=0;e<a.length;e++)a[e]&&(o??=e,s=e);for(let c=0,l=n+1;c<i.height;c++){let n=t.child(c),i=l+n.nodeSize,u=a[c];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n<u;n++){let n=jp(e.schema)[t].createAndFill();n&&a.push(n)}let d=(c==0||o==c-1)&&s==c?l+1:i-1;r.insert(r.mapping.map(d),a)}l=i}return r.setMeta(Yp,{fixTables:!0})}function $p(e){let t=J.get(e),n=[],r=t.height,i=t.width;for(let a=0;a<r;a++){let r=[];for(let n=0;n<i;n++){let o=a*i+n,s=t.map[o];if(a>0){let e=o-i;if(s===t.map[e]){r.push(null);continue}}if(n>0){let e=o-1;if(s===t.map[e]){r.push(null);continue}}r.push(e.nodeAt(s))}n.push(r)}return n}function em(e,t){let n=[],r=J.get(e),i=r.height,a=r.width;for(let o=0;o<i;o++){let i=e.child(o),s=[];for(let n=0;n<a;n++){let i=t[o][n];if(!i)continue;let a=r.map[o*r.width+n],c=e.nodeAt(a);if(!c)continue;let l=c.type.createChecked(i.attrs,i.content,i.marks);s.push(l)}let c=i.type.createChecked(i.attrs,s,i.marks);n.push(c)}return e.type.createChecked(e.attrs,n,e.marks)}function tm(e,t,n,r){let i=t[0]>n[0]?-1:1,a=e.splice(t[0],t.length),o=+(a.length%2==0),s;return s=r===-1&&i===1?n[0]-1:r===1&&i===-1?n[n.length-1]-o+1:i===-1?n[0]:n[n.length-1]-o,e.splice(s,0,...a),e}function nm(e){return rm(e=>e.type.spec.tableRole===`table`,e)}function rm(e,t){for(let n=t.depth;n>=0;--n){let r=t.node(n);if(e(r))return{node:r,pos:n===0?0:t.before(n),start:t.start(n),depth:n}}return null}function im(e,t){let n=nm(t.$from);if(!n)return;let r=J.get(n.node);if(!(e<0||e>r.width-1))return r.cellsInRect({left:e,right:e+1,top:0,bottom:r.height}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function am(e,t){let n=nm(t.$from);if(!n)return;let r=J.get(n.node);if(!(e<0||e>r.height-1))return r.cellsInRect({left:0,right:r.width,top:e,bottom:e+1}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function om(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=im(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=im(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;e.node.attrs.colspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=im(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=im(r,e.selection),s=am(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=im(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function sm(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=am(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=am(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;e.node.attrs.rowspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=am(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=am(r,e.selection),s=im(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=am(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function cm(e){return e[0].map((t,n)=>e.map(e=>e[n]))}function lm(e){let{tr:t,originIndex:n,targetIndex:r,select:i,pos:a}=e,o=nm(t.doc.resolve(a));if(!o)return!1;let s=om(t,n)?.indexes,c=om(t,r)?.indexes;if(!s||!c||s.includes(r))return!1;let l=um(o.node,s,c,0);if(t.replaceWith(o.pos,o.pos+o.node.nodeSize,l),!i)return!0;let u=J.get(l),d=o.start,f=r,p=u.positionAt(u.height-1,f,l),m=t.doc.resolve(d+p),h=u.positionAt(0,f,l),g=t.doc.resolve(d+h);return t.setSelection(Y.colSelection(m,g)),!0}function um(e,t,n,r){let i=cm($p(e));return i=tm(i,t,n,r),i=cm(i),em(e,i)}function dm(e){let{tr:t,originIndex:n,targetIndex:r,select:i,pos:a}=e,o=nm(t.doc.resolve(a));if(!o)return!1;let s=sm(t,n)?.indexes,c=sm(t,r)?.indexes;if(!s||!c||s.includes(r))return!1;let l=fm(o.node,s,c,0);if(t.replaceWith(o.pos,o.pos+o.node.nodeSize,l),!i)return!0;let u=J.get(l),d=o.start,f=r,p=u.positionAt(f,u.width-1,l),m=t.doc.resolve(d+p),h=u.positionAt(f,0,l),g=t.doc.resolve(d+h);return t.setSelection(Y.rowSelection(m,g)),!0}function fm(e,t,n,r){let i=$p(e);return i=tm(i,t,n,r),em(e,i)}function pm(e){let t=e.selection,n=Fp(e),r=n.node(-1),i=n.start(-1),a=J.get(r);return{...t instanceof Y?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function mm(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;Up(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,Hp(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?jp(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function hm(e,t){if(!Pp(e))return!1;if(t){let n=pm(e);t(mm(e.tr,n,n.left))}return!0}function gm(e,t){if(!Pp(e))return!1;if(t){let n=pm(e);t(mm(e.tr,n,n.right))}return!0}function _m(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,Vp(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function vm(e,t){if(!Pp(e))return!1;if(t){let n=pm(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;_m(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=J.get(e)}t(r)}return!0}function ym(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function bm(e,t){if(!Pp(e))return!1;if(t){let n=pm(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;ym(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=J.get(n.table)}t(r)}return!0}function xm(e,t){return function(n,r){if(!Pp(n))return!1;let i=Fp(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof Y?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function Sm(e){return function(t,n){if(!Pp(t))return!1;if(n){let r=jp(t.schema),i=pm(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function Cm(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function wm(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?Sm(e):function(t,n){if(!Pp(t))return!1;if(n){let r=jp(t.schema),i=pm(t),a=t.tr,o=Cm(`row`,i,r),s=Cm(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}wm(`row`,{useDeprecatedLogic:!0}),wm(`column`,{useDeprecatedLogic:!0}),wm(`cell`,{useDeprecatedLogic:!0});function Tm(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function Em(e){return function(t,n){if(!Pp(t))return!1;let r=Tm(Fp(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(E.between(e,Rp(e))).scrollIntoView())}return!0}}function Dm(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Om(e,t){let n=e.selection;if(!(n instanceof Y))return!1;if(t){let r=e.tr,i=jp(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new S(i,0,0))}),r.docChanged&&t(r)}return!0}function km(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return dm({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function Am(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return lm({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function jm(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e<t.childCount;e++){let i=t.child(e).content,a=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(a||c)&&(i=Nm(jp(o).row,new S(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?Nm(jp(o).row,new S(t,n,r)).content:t);else return null;return Mm(o,s)}function Mm(e,t){let n=[];for(let e=0;e<t.length;e++){let r=t[e];for(let t=r.childCount-1;t>=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t<e+i;t++)n[t]=(n[t]||0)+a}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(b.empty),n[i]<r){let a=jp(e).cell.createAndFill(),o=[];for(let e=n[i];e<r;e++)o.push(a);t[i]=t[i].append(b.from(o))}return{height:t.length,width:r,rows:t}}function Nm(e,t){let n=e.createAndFill();return new Fr(n).replace(0,n.content.size,t).doc}function Pm({width:e,height:t,rows:n},r,i){if(e!=r){let t=[],i=[];for(let e=0;e<n.length;e++){let a=n[e],o=[];for(let n=t[e]||0,i=0;n<r;i++){let s=a.child(i%a.childCount);n+s.attrs.colspan>r&&(s=s.type.createChecked(Vp(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}i.push(b.from(o))}n=i,e=r}if(t!=i){let e=[];for(let r=0,a=0;r<i;r++,a++){let o=[],s=n[a%t];for(let e=0;e<s.childCount;e++){let t=s.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(b.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function Fm(e,t,n,r,i,a,o){let s=e.doc.type.schema,c=jp(s),l,u;if(i>t.width)for(let a=0,s=0;a<t.height;a++){let d=n.child(a);s+=d.nodeSize;let f=[],p;p=d.lastChild==null||d.lastChild.type==c.cell?l||=c.cell.createAndFill():u||=c.header_cell.createAndFill();for(let e=t.width;e<i;e++)f.push(p);e.insert(e.mapping.slice(o).map(s-1+r),f)}if(a>t.height){let s=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){let i=e>=t.width?!1:n.nodeAt(t.map[r+e]).type==c.header_cell;s.push(i?u||=c.header_cell.createAndFill():l||=c.cell.createAndFill())}let d=c.row.create(null,b.from(s)),f=[];for(let e=t.height;e<a;e++)f.push(d);e.insert(e.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(l||u)}function Im(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function Lm(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,Vp(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(Vp(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function Rm(e,t,n,r,i){let a=n?e.doc.nodeAt(n-1):e.doc;if(!a)throw Error(`No table found`);let o=J.get(a),{top:s,left:c}=r,l=c+i.width,u=s+i.height,d=e.tr,f=0;function p(){if(a=n?d.doc.nodeAt(n-1):d.doc,!a)throw Error(`No table found`);o=J.get(a),f=d.mapping.maps.length}Fm(d,o,a,n,l,u,f)&&p(),Im(d,o,a,n,c,l,s,f)&&p(),Im(d,o,a,n,c,l,u,f)&&p(),Lm(d,o,a,n,s,u,c,f)&&p(),Lm(d,o,a,n,s,u,l,f)&&p();for(let e=s;e<u;e++){let t=o.positionAt(e,c,a),r=o.positionAt(e,l,a);d.replace(d.mapping.slice(f).map(t+n),d.mapping.slice(f).map(r+n),new S(i.rows[e-s],0,0))}p(),d.setSelection(new Y(d.doc.resolve(n+o.positionAt(s,c,a)),d.doc.resolve(n+o.positionAt(u-1,l-1,a)))),t(d)}var zm=ya({ArrowLeft:Vm(`horiz`,-1),ArrowRight:Vm(`horiz`,1),ArrowUp:Vm(`vert`,-1),ArrowDown:Vm(`vert`,1),"Shift-ArrowLeft":Hm(`horiz`,-1),"Shift-ArrowRight":Hm(`horiz`,1),"Shift-ArrowUp":Hm(`vert`,-1),"Shift-ArrowDown":Hm(`vert`,1),Backspace:Om,"Mod-Backspace":Om,Delete:Om,"Mod-Delete":Om});function Bm(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function Vm(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof Y)return Bm(n,r,T.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=Km(i,e,t);if(o==null)return!1;if(e==`horiz`)return Bm(n,r,T.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=Bp(i,e,t),s;return s=a?T.near(a,1):t<0?T.near(n.doc.resolve(i.before(-1)),-1):T.near(n.doc.resolve(i.after(-1)),1),Bm(n,r,s)}}}function Hm(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof Y)o=a;else{let r=Km(i,e,t);if(r==null)return!1;o=new Y(n.doc.resolve(r))}let s=Bp(o.$headCell,e,t);return s?Bm(n,r,new Y(o.$anchorCell,s)):!1}}function Um(e,t){let n=e.state.doc,r=Np(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new Y(r))),!0):!1}function Wm(e,t,n){if(!Pp(e.state))return!1;let r=jm(n),i=e.state.selection;if(i instanceof Y){r||={width:1,height:1,rows:[b.from(Nm(jp(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=J.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=Pm(r,o.right-o.left,o.bottom-o.top),Rm(e.state,e.dispatch,a,o,r),!0}else if(r){let t=Fp(e.state),n=t.start(-1);return Rm(e.state,e.dispatch,n,J.get(t.node(-1)).findCell(t.pos-n),r),!0}else return!1}function Gm(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=qm(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof Y)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=Np(e.state.selection.$anchor))!=null&&Jm(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=Jm(e,n),i=Mp.getState(e.state)==null;if(!r||!zp(t,r))if(i)r=t;else return;let a=new Y(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(Mp,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),Mp.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(Mp,-1))}function o(r){let o=r,s=Mp.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(qm(e,o.target)!=n&&(c=Jm(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function Km(e,t,n){if(!(e.state.selection instanceof E))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function qm(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function Jm(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Np(e.state.doc.resolve(r))||Np(e.state.doc.resolve(i))}var Ym=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,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`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),Xm(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type?(this.node=e,Xm(e,this.colgroup,this.table,this.defaultCellMinWidth),!0):!1}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function Xm(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var Zm=new k(`tableColumnResizing`);function Qm({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=Ym,lastColumnResizable:i=!0}={}){let a=new O({key:Zm,state:{init(e,t){var i;let o=(i=a.spec)==null||(i=i.props)==null?void 0:i.nodeViews,s=jp(t.schema).table.name;return r&&o&&(o[s]=(e,t)=>new r(e,n,t)),new $m(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=Zm.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{eh(t,n,e,i)},mouseleave:e=>{th(e)},mousedown:(e,r)=>{nh(e,r,t,n)}},decorations:e=>{let t=Zm.getState(e);if(t&&t.activeHandle>-1)return dh(e,t.activeHandle)},nodeViews:{}}});return a}var $m=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(Zm);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return Lp(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function eh(e,t,n,r){if(!e.editable)return;let i=Zm.getState(e.state);if(i&&!i.dragging){let a=ih(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=ah(e,t,`left`,n):i-t.clientX<=n&&(o=ah(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=J.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}sh(e,o)}}}function th(e){if(!e.editable)return;let t=Zm.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&sh(e,-1)}function nh(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=Zm.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=rh(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(Zm,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=Zm.getState(e.state);r?.dragging&&(ch(e,r.activeHandle,oh(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(Zm,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=Zm.getState(e.state);if(i&&i.dragging){let a=oh(i.dragging,t,n);lh(e,i.activeHandle,a,r)}}return lh(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function rh(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function ih(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function ah(e,t,n,r){let i=n==`right`?-r:r,a=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!a)return-1;let{pos:o}=a,s=Np(e.state.doc.resolve(o));if(!s)return-1;if(n==`right`)return s.pos;let c=J.get(s.node(-1)),l=s.start(-1),u=c.map.indexOf(s.pos-l);return u%c.width==0?-1:l+c.map[u-1]}function oh(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function sh(e,t){e.dispatch(e.state.tr.setMeta(Zm,{setHandle:t}))}function ch(e,t,n){let r=e.state.doc.resolve(t),i=r.node(-1),a=J.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,c=e.state.tr;for(let e=0;e<a.height;e++){let t=e*a.width+s;if(e&&a.map[t]==a.map[t-a.width])continue;let r=a.map[t],l=i.nodeAt(r).attrs,u=l.colspan==1?0:s-a.colCount(r);if(l.colwidth&&l.colwidth[u]==n)continue;let d=l.colwidth?l.colwidth.slice():uh(l.colspan);d[u]=n,c.setNodeMarkup(o+r,null,{...l,colwidth:d})}c.docChanged&&e.dispatch(c)}function lh(e,t,n,r){let i=e.state.doc.resolve(t),a=i.node(-1),o=i.start(-1),s=J.get(a).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,c=e.domAtPos(i.start(-1)).node;for(;c&&c.nodeName!=`TABLE`;)c=c.parentNode;c&&Xm(a,c.firstChild,c,r,s,n)}function uh(e){return Array(e).fill(0)}function dh(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return L.empty;let a=J.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<a.height;t++){let r=s+t*a.width;if((s==a.width-1||a.map[r]!=a.map[r+1])&&(t==0||a.map[r]!=a.map[r-a.width])){let t=a.map[r],s=o+t+i.nodeAt(t).nodeSize-1,c=document.createElement(`div`);c.className=`column-resize-handle`,Zm.getState(e)?.dragging&&n.push(tl.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:`column-resize-dragging`})),n.push(tl.widget(s,c))}}return L.create(e.doc,n)}function fh({allowTableNodeSelection:e=!1}={}){return new O({key:Mp,state:{init(){return null},apply(e,t){let n=e.getMeta(Mp);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:Gp,handleDOMEvents:{mousedown:Gm},createSelectionBetween(e){return Mp.getState(e.state)==null?null:e.state.selection},handleTripleClick:Um,handleKeyDown:zm,handlePaste:Wm},appendTransaction(t,n,r){return Jp(r,Zp(r,n),e)}})}var ph=typeof navigator<`u`?navigator:null,mh=ph&&ph.userAgent||``,hh=/Edge\/(\d+)/.exec(mh),gh=/MSIE \d/.exec(mh),_h=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(mh),vh=!(gh||_h||hh)&&!!ph&&/Apple Computer/.test(ph.vendor),yh=new k(`safari-ime-span`),bh=!1,xh={key:yh,props:{decorations:Sh,handleDOMEvents:{compositionstart:()=>{bh=!0},compositionend:()=>{bh=!1}}}};function Sh(e){let{$from:t,$to:n,to:r}=e.selection;if(bh&&t.sameParent(n)){let t=tl.widget(r,Ch,{ignoreSelection:!0,key:`safari-ime-span`});return L.create(e.doc,[t])}}function Ch(e){let t=e.dom.ownerDocument.createElement(`span`);return t.className=`ProseMirror-safari-ime-span`,t}var wh=new O(vh?xh:{key:yh});function X(e,t){return Object.assign(e,{meta:{package:`@milkdown/preset-gfm`,...t}}),e}var Th=fd(`strike_through`);X(Th,{displayName:`Attr<strikethrough>`,group:`Strikethrough`});var Eh=ud(`strike_through`,e=>({parseDOM:[{tag:`del`},{style:`text-decoration`,getAttrs:e=>e===`line-through`}],toDOM:t=>[`del`,e.get(Th.key)(t)],parseMarkdown:{match:e=>e.type===`delete`,runner:(e,t,n)=>{e.openMark(n),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`strike_through`,runner:(e,t)=>{e.withMark(t,`delete`)}}}));X(Eh.mark,{displayName:`MarkSchema<strikethrough>`,group:`Strikethrough`}),X(Eh.ctx,{displayName:`MarkSchemaCtx<strikethrough>`,group:`Strikethrough`});var Dh=U(`ToggleStrikeThrough`,e=>()=>Ni(Eh.type(e)));X(Dh,{displayName:`Command<ToggleStrikethrough>`,group:`Strikethrough`});var Oh=W(e=>ra(/(?<![\w:/])(~{1,2})(.+?)\1(?!\w|\/)/,Eh.type(e)));X(Oh,{displayName:`InputRule<strikethrough>`,group:`Strikethrough`});var kh=K(`strikeThroughKeymap`,{ToggleStrikethrough:{shortcuts:`Mod-Alt-x`,command:e=>{let t=e.get(H);return()=>t.call(Dh.key)}}});X(kh.ctx,{displayName:`KeymapCtx<strikethrough>`,group:`Strikethrough`}),X(kh.shortcuts,{displayName:`Keymap<strikethrough>`,group:`Strikethrough`});var Ah=Ap({tableGroup:`block`,cellContent:`paragraph`,cellAttributes:{alignment:{default:`left`,getFromDOM:e=>e.style.textAlign||`left`,setDOMAttr:(e,t)=>{t.style=`text-align: ${e||`left`}`}}}}),jh=G(`table`,()=>({...Ah.table,content:`table_header_row table_row+`,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`table`,runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,t)=>({...e,align:r,isHeader:t===0}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table`,runner:(e,t)=>{let n=t.content.firstChild?.content;if(!n)return;let r=[];n.forEach(e=>{r.push(e.attrs.alignment)}),e.openNode(`table`,void 0,{align:r}),e.next(t.content),e.closeNode()}}}));X(jh.node,{displayName:`NodeSchema<table>`,group:`Table`}),X(jh.ctx,{displayName:`NodeSchemaCtx<table>`,group:`Table`});var Mh=G(`table_header_row`,()=>({...Ah.table_row,disableDropCursor:!0,content:`(table_header)*`,parseDOM:[{tag:`tr[data-is-header]`},{tag:`tr`,getAttrs:e=>e instanceof HTMLElement&&e.querySelector(`th`)?{}:!1}],toDOM(){return[`tr`,{"data-is-header":!0},0]},parseMarkdown:{match:e=>!!(e.type===`tableRow`&&e.isHeader),runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,n)=>({...e,align:r[n],isHeader:t.isHeader}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_header_row`,runner:(e,t)=>{t.content.size!==0&&(e.openNode(`tableRow`,void 0,{isHeader:!0}),e.next(t.content),e.closeNode())}}}));X(Mh.node,{displayName:`NodeSchema<tableHeaderRow>`,group:`Table`}),X(Mh.ctx,{displayName:`NodeSchemaCtx<tableHeaderRow>`,group:`Table`});var Nh=G(`table_row`,()=>({...Ah.table_row,disableDropCursor:!0,content:`(table_cell)*`,parseMarkdown:{match:e=>e.type===`tableRow`,runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,t)=>({...e,align:r[t]}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_row`,runner:(e,t)=>{t.content.size!==0&&(e.openNode(`tableRow`),e.next(t.content),e.closeNode())}}}));X(Nh.node,{displayName:`NodeSchema<tableRow>`,group:`Table`}),X(Nh.ctx,{displayName:`NodeSchemaCtx<tableRow>`,group:`Table`});var Ph=G(`table_cell`,()=>({...Ah.table_cell,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`tableCell`&&!e.isHeader,runner:(e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode()}},toMarkdown:{match:e=>e.type.name===`table_cell`,runner:(e,t)=>{e.openNode(`tableCell`).next(t.content).closeNode()}}}));X(Ph.node,{displayName:`NodeSchema<tableCell>`,group:`Table`}),X(Ph.ctx,{displayName:`NodeSchemaCtx<tableCell>`,group:`Table`});var Fh=G(`table_header`,()=>({...Ah.table_header,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`tableCell`&&!!e.isHeader,runner:(e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}),e.openNode(e.schema.nodes.paragraph),e.next(t.children),e.closeNode(),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_header`,runner:(e,t)=>{e.openNode(`tableCell`),e.next(t.content),e.closeNode()}}}));X(Fh.node,{displayName:`NodeSchema<tableHeader>`,group:`Table`}),X(Fh.ctx,{displayName:`NodeSchemaCtx<tableHeader>`,group:`Table`});function Ih(e,t=3,n=3){let r=Array(n).fill(0).map(()=>Ph.type(e).createAndFill()),i=Array(n).fill(0).map(()=>Fh.type(e).createAndFill()),a=Array(t).fill(0).map((t,n)=>n===0?Mh.type(e).create(null,i):Nh.type(e).create(null,r));return jh.type(e).create(null,a)}function Lh(e){return(t,n)=>r=>{n??=r.selection.from;let i=r.doc.resolve(n),a=ua(e=>e.type.name===`table`)(i),o=a?{node:a.node,from:a.start}:void 0,s=e===`row`;if(o){let e=J.get(o.node);if(t>=0&&t<(s?e.height:e.width)){let n=e.positionAt(s?t:e.height-1,s?e.width-1:t,o.node),i=r.doc.resolve(o.from+n),a=s?Y.rowSelection:Y.colSelection,c=e.positionAt(s?t:0,s?0:t,o.node),l=r.doc.resolve(o.from+c);return ia(r.setSelection(a(i,l)))}}return r}}var Rh=Lh(`row`),zh=Lh(`col`);function Bh(e,t,{map:n,tableStart:r,table:i},a){let o=Array(a).fill(0).reduce((e,t,n)=>e+i.child(n).nodeSize,r),s=Array(n.width).fill(0).map((t,r)=>{let a=i.nodeAt(n.map[r]);return Ph.type(e).createAndFill({alignment:a?.attrs.alignment})});return t.insert(o,Nh.type(e).create(null,s)),t}function Vh(e){let t=nm(e.$from);if(!t)return;let n=J.get(t.node);return n.cellsInRect({left:0,right:n.width,top:0,bottom:n.height}).map(e=>{let n=t.node.nodeAt(e),r=e+t.start;return{pos:r,start:r+1,node:n}})}function Hh(e){let t=Vh(e.selection);if(t&&t[0]){let n=e.doc.resolve(t[0].pos),r=t[t.length-1];if(r){let t=e.doc.resolve(r.pos);return ia(e.setSelection(new Y(t,n)))}}return e}var Uh=U(`GoToPrevTableCell`,()=>()=>Em(-1));X(Uh,{displayName:`Command<goToPrevTableCellCommand>`,group:`Table`});var Wh=U(`GoToNextTableCell`,()=>()=>Em(1));X(Wh,{displayName:`Command<goToNextTableCellCommand>`,group:`Table`});var Gh=U(`ExitTable`,e=>()=>(t,n)=>{if(!Pp(t))return!1;let{$head:r}=t.selection,i=ca(r,jh.type(e));if(!i)return!1;let{to:a}=i,o=t.tr.replaceWith(a,a,Zd.type(e).createAndFill());return o.setSelection(T.near(o.doc.resolve(a),1)).scrollIntoView(),n?.(o),!0});X(Gh,{displayName:`Command<breakTableCommand>`,group:`Table`});var Kh=U(`InsertTable`,e=>({row:t,col:n}={})=>(r,i)=>{let{selection:a,tr:o}=r,{from:s}=a,c=Ih(e,t,n),l=o.replaceSelectionWith(c),u=T.findFrom(l.doc.resolve(s),1,!0);return u&&l.setSelection(u),i?.(l),!0});X(Kh,{displayName:`Command<insertTableCommand>`,group:`Table`});var qh=U(`MoveRow`,()=>({from:e,to:t,pos:n}={})=>km({from:e??0,to:t??0,pos:n}));X(qh,{displayName:`Command<moveRowCommand>`,group:`Table`});var Jh=U(`MoveCol`,()=>({from:e,to:t,pos:n}={})=>Am({from:e??0,to:t??0,pos:n}));X(Jh,{displayName:`Command<moveColCommand>`,group:`Table`});var Yh=U(`SelectRow`,()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.(Rh(e.index,e.pos)(r))});X(Yh,{displayName:`Command<selectRowCommand>`,group:`Table`});var Xh=U(`SelectCol`,()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.(zh(e.index,e.pos)(r))});X(Xh,{displayName:`Command<selectColCommand>`,group:`Table`});var Zh=U(`SelectTable`,()=>()=>(e,t)=>{let{tr:n}=e;return!!t?.(Hh(n))});X(Zh,{displayName:`Command<selectTableCommand>`,group:`Table`});var Qh=U(`DeleteSelectedCells`,()=>()=>(e,t)=>{let{selection:n}=e;if(!(n instanceof Y))return!1;let r=n.isRowSelection(),i=n.isColSelection();return r&&i?Dm(e,t):i?vm(e,t):bm(e,t)});X(Qh,{displayName:`Command<deleteSelectedCellsCommand>`,group:`Table`});var $h=U(`AddColBefore`,()=>()=>hm);X($h,{displayName:`Command<addColBeforeCommand>`,group:`Table`});var eg=U(`AddColAfter`,()=>()=>gm);X(eg,{displayName:`Command<addColAfterCommand>`,group:`Table`});var tg=U(`AddRowBefore`,e=>()=>(t,n)=>{if(!Pp(t))return!1;if(n){let r=pm(t);n(Bh(e,t.tr,r,r.top))}return!0});X(tg,{displayName:`Command<addRowBeforeCommand>`,group:`Table`});var ng=U(`AddRowAfter`,e=>()=>(t,n)=>{if(!Pp(t))return!1;if(n){let r=pm(t);n(Bh(e,t.tr,r,r.bottom))}return!0});X(ng,{displayName:`Command<addRowAfterCommand>`,group:`Table`});var rg=U(`SetAlign`,()=>(e=`left`)=>xm(`alignment`,e));X(rg,{displayName:`Command<setAlignCommand>`,group:`Table`});var ig=W(e=>new A(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(t,n,r,i)=>{let a=t.doc.resolve(r);if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),jh.type(e)))return null;let o=Ih(e,Math.max(Number(n.groups?.row??0),2),Number(n.groups?.col)),s=t.tr.replaceRangeWith(r,i,o);return s.setSelection(E.create(s.doc,r+3)).scrollIntoView()}));X(ig,{displayName:`InputRule<insertTableInputRule>`,group:`Table`});var ag=rd(e=>({run:(t,n,r)=>{if(r)return t;function i(t){let n=t.childCount,r=t.lastChild?.childCount??0;if(n===0||r===0)return Zd.type(e).create();let i=t.firstChild;if(!(r>0&&i&&i.childCount===0))return t;if(n>=3){let r=t.child(1),a=[];for(let t=0;t<r.childCount;t++){let n=r.child(t);a.push(Fh.type(e).create(n.attrs,n.content,n.marks))}let o=i.type.create(i.attrs,a),s=[];for(let e=2;e<n;e++)s.push(t.child(e));return t.type.create(t.attrs,[o,...s])}let a=Array(r).fill(0).map(()=>Fh.type(e).createAndFill()),o=new S(b.from(a),0,0),s=i.replace(0,0,o);return t.replace(0,i.nodeSize,new S(b.from(s),0,0))}function a(t){let n=Nh.type(e),r=[],a=[],o=!1;function s(){if(a.length===0)return;let t=Mh.type(e).createAndFill(),n=jh.type(e).create(null,[t,...a]);r.push(i(n)),a=[]}return t.forEach(e=>{e.type===n?(o=!0,a.push(e)):(s(),r.push(e))}),s(),o?b.from(r):t}function o(t){let n=a(t),r=n!==t,s=[];return n.forEach(t=>{if(t.type===jh.type(e)){let e=i(t);e!==t&&(r=!0),s.push(e)}else if(t.childCount>0){let e=o(t.content);e===t.content?s.push(t):(r=!0,s.push(t.copy(e)))}else s.push(t)}),r?b.from(s):t}function s(t){let n=[],r=[];t.forEach(e=>r.push(e));for(let t=0;t<r.length;t++){let i=r[t],a=r[t+1];i.type===Zd.type(e)&&i.content.size===0&&a&&a.type===jh.type(e)||n.push(i)}return n.length<r.length?b.from(n):t}let c=o(t.content);return c=s(c),new S(b.from(c),t.openStart,t.openEnd)}}));X(ag,{displayName:`PasteRule<table>`,group:`Table`});var og=K(`tableKeymap`,{NextCell:{priority:100,shortcuts:[`Mod-]`,`Tab`],command:e=>{let t=e.get(H);return()=>t.call(Wh.key)}},PrevCell:{shortcuts:[`Mod-[`,`Shift-Tab`],command:e=>{let t=e.get(H);return()=>t.call(Uh.key)}},ExitTable:{shortcuts:[`Mod-Enter`,`Enter`],command:e=>{let t=e.get(H);return()=>t.call(Gh.key)}}});X(og.ctx,{displayName:`KeymapCtx<table>`,group:`Table`}),X(og.shortcuts,{displayName:`Keymap<table>`,group:`Table`});var sg=`footnote_definition`,cg=`footnoteDefinition`,lg=G(`footnote_definition`,()=>({group:`block`,content:`block+`,defining:!0,attrs:{label:{default:``,validate:`string`}},parseDOM:[{tag:`dl[data-type="${sg}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ge(e);return{label:e.dataset.label}},contentElement:`dd`}],toDOM:e=>{let t=e.attrs.label;return[`dl`,{"data-label":t,"data-type":sg},[`dt`,t],[`dd`,0]]},parseMarkdown:{match:({type:e})=>e===cg,runner:(e,t,n)=>{e.openNode(n,{label:t.label}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===sg,runner:(e,t)=>{e.openNode(cg,void 0,{label:t.attrs.label,identifier:t.attrs.label}).next(t.content).closeNode()}}}));X(lg.ctx,{displayName:`NodeSchemaCtx<footnodeDef>`,group:`footnote`}),X(lg.node,{displayName:`NodeSchema<footnodeDef>`,group:`footnote`});var ug=`footnote_reference`,dg=G(`footnote_reference`,()=>({group:`inline`,inline:!0,atom:!0,attrs:{label:{default:``,validate:`string`}},parseDOM:[{tag:`sup[data-type="${ug}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ge(e);return{label:e.dataset.label}}}],toDOM:e=>{let t=e.attrs.label;return[`sup`,{"data-label":t,"data-type":ug},t]},parseMarkdown:{match:({type:e})=>e===`footnoteReference`,runner:(e,t,n)=>{e.addNode(n,{label:t.label})}},toMarkdown:{match:e=>e.type.name===ug,runner:(e,t)=>{e.addNode(`footnoteReference`,void 0,void 0,{label:t.attrs.label,identifier:t.attrs.label})}}}));X(dg.ctx,{displayName:`NodeSchemaCtx<footnodeRef>`,group:`footnote`}),X(dg.node,{displayName:`NodeSchema<footnodeRef>`,group:`footnote`});var fg=Wf.extendSchema(e=>t=>{let n=e(t);return{...n,attrs:{...n.attrs,checked:{default:null,validate:`boolean|null`}},parseDOM:[{tag:`li[data-item-type="task"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ge(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread,checked:e.dataset.checked?e.dataset.checked===`true`:null}}},...n?.parseDOM||[]],toDOM:e=>n.toDOM&&e.attrs.checked==null?n.toDOM(e):[`li`,{"data-item-type":`task`,"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread,"data-checked":e.attrs.checked},0],parseMarkdown:{match:({type:e})=>e===`listItem`,runner:(e,t,r)=>{if(t.checked==null){n.parseMarkdown.runner(e,t,r);return}let i=t.label==null?`•`:`${t.label}.`,a=t.checked==null?null:!!t.checked,o=t.label==null?`bullet`:`ordered`,s=t.spread==null?`true`:`${t.spread}`;e.openNode(r,{label:i,listType:o,spread:s,checked:a}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`list_item`,runner:(e,t)=>{if(t.attrs.checked==null){n.toMarkdown.runner(e,t);return}let r=t.attrs.label,i=t.attrs.listType,a=t.attrs.spread===`true`,o=t.attrs.checked;e.openNode(`listItem`,void 0,{label:r,listType:i,spread:a,checked:o}),e.next(t.content),e.closeNode()}}}});X(fg.node,{displayName:`NodeSchema<taskListItem>`,group:`ListItem`}),X(fg.ctx,{displayName:`NodeSchemaCtx<taskListItem>`,group:`ListItem`});var pg=W(()=>new A(/^\[(?<checked>\s|x)\]\s$/,(e,t,n,r)=>{let i=e.doc.resolve(n),a=0,o=i.node(a);for(;o&&o.type.name!==`list_item`;)a--,o=i.node(a);if(!o||o.attrs.checked!=null)return null;let s=t.groups?.checked===`x`,c=i.before(a),l=e.tr;return l.deleteRange(n,r).setNodeMarkup(c,void 0,{...o.attrs,checked:s}),l}));X(pg,{displayName:`InputRule<wrapInTaskListInputRule>`,group:`ListItem`});var mg=[kh,og].flat(),hg=[ig,pg],gg=[Oh],_g=[ag],vg=od(()=>wh);X(vg,{displayName:`Prose<autoInsertSpanPlugin>`,group:`Prose`}),X(od(()=>Qm({})),{displayName:`Prose<columnResizingPlugin>`,group:`Prose`});var yg=od(()=>fh({allowTableNodeSelection:!0}));X(yg,{displayName:`Prose<tableEditingPlugin>`,group:`Prose`});var bg=pd(`remarkGFM`,()=>h);X(bg.plugin,{displayName:`Remark<remarkGFMPlugin>`,group:`Remark`}),X(bg.options,{displayName:`RemarkConfig<remarkGFMPlugin>`,group:`Remark`});var xg=new k(`MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN`);function Sg(e,t){let n=0;return t.forEach((t,r,i)=>{t===e&&(n=i)}),n}var Cg=od(()=>new O({key:xg,appendTransaction:(e,t,n)=>{let r;return t.doc!==n.doc&&n.doc.descendants((e,t)=>{if(r||=n.tr,e.type.name!==`table_cell`)return;let i=n.doc.resolve(t),a=i.node(i.depth),o=i.node(i.depth-1).firstChild;if(!o)return;let s=Sg(e,a),c=o.maybeChild(s);if(!c)return;let l=c.attrs.alignment;l!==e.attrs.alignment&&r.setNodeMarkup(t,void 0,{...e.attrs,alignment:l})}),r}}));X(Cg,{displayName:`Prose<keepTableAlignPlugin>`,group:`Prose`});var wg=[Cg,vg,bg,yg].flat(),Tg=[fg,jh,Mh,Nh,Fh,Ph,lg,dg,Th,Eh].flat(),Eg=[Wh,Uh,Gh,Kh,qh,Jh,Yh,Xh,Zh,Qh,tg,ng,$h,eg,rg,Dh];[Tg,hg,_g,gg,mg,Eg,wg].flat();function Dg(e){if(!e)return!1;if(Array.isArray(e))return e.length>1?!1:Dg(e[0]);let t=e.content;return t?Dg(t):e.type===`text`}function Og(e,t){return Object.assign(e,{meta:{package:`@milkdown/plugin-clipboard`,...t}}),e}function kg(e,t){let n=oa(t);if(n)return e.dispatch(e.state.tr.replaceSelectionWith(n,!0)),!0;try{return e.dispatch(e.state.tr.replaceSelection(t)),!0}catch{return!1}}var Ag=od(e=>{let t=e.get(V);return e.update(Gu,e=>({...e,editable:e.editable??(()=>!0),transformPastedHTML:(t,n)=>{let r=e.transformPastedHTML;return r&&(t=r(t,n)),t.includes(`docs-internal-guid`)&&(t=t.replace(/<b[^>]*id="docs-internal-guid[^"]*"[^>]*>([\s\S]*)<\/b>/,`$1`),t=t.replace(/<div[^>]*>(<table[\s\S]*?<\/table>)<\/div>/g,`$1`)),t}})),new O({key:new k(`MILKDOWN_CLIPBOARD`),props:{handlePaste:(n,r,i)=>{let a=e.get(wu),o=n.props.editable?.(n.state),{clipboardData:s}=r;if(!o||!s||n.state.selection.$from.node().type.spec.code)return!1;let c=s.getData(`text/plain`),l=s.getData(`vscode-editor-data`);if(l){let e=JSON.parse(l)?.mode;if(c&&e){let{tr:r}=n.state,i=la(`code_block`,t);return r.replaceSelectionWith(i.create({language:e})).setSelection(E.near(r.doc.resolve(Math.max(0,r.selection.from-2)))).insertText(c.replace(/\r\n?/g,`
34
- `)),n.dispatch(r),!0}}let u=s.getData(`text/html`);if(u.length===0&&c.length===0)return!1;if(u.length>0&&i)return kg(n,i);let d=an.fromSchema(t),f;if(u.length===0){let e=a(c);if(!e||typeof e==`string`)return!1;f=yn.fromSchema(t).serializeFragment(e.content)}else{let e=document.createElement(`template`);e.innerHTML=u,f=e.content.cloneNode(!0),e.remove()}return kg(n,d.parseSlice(f))},clipboardTextSerializer:n=>{let r=e.get(Au);if(Dg(n.content.toJSON()))return n.content.textBetween(0,n.content.size,`
35
-
36
- `);let i=t.topNodeType.createAndFill(void 0,n.content);return i?r(i):``}}})});Og(Ag,{displayName:`Prose<clipboard>`});var jg=200,Z=function(){};Z.prototype.append=function(e){return e.length?(e=Z.from(e),!this.length&&e||e.length<jg&&this.leafAppend(e)||this.length<jg&&e.leafPrepend(this)||this.appendInner(e)):this},Z.prototype.prepend=function(e){return e.length?Z.from(e).append(this):this},Z.prototype.appendInner=function(e){return new Ng(this,e)},Z.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Z.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Z.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Z.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Z.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},Z.from=function(e){return e instanceof Z?e:e&&e.length?new Mg(e):Z.empty};var Mg=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=jg)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=jg)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Z);Z.empty=new Mg([]);var Ng=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Z),Pg=500,Fg=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new Lg(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new Lg(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new Lg(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>zg&&(s=Ig(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new Ln;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new Lg(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new Lg(i,o,l))}else r.push(new Lg(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new Lg(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>Pg&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new Lg(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(Z.from(i.reverse()),a)}};Fg.empty=new Fg(Z.empty,0);function Ig(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var Lg=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},Rg=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},zg=20;function Bg(e,t,n,r){let i=n.getMeta(Jg),a;if(i)return i.historyState;n.getMeta(Yg)&&(e=new Rg(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Jg))return o.getMeta(Jg).redo?new Rg(e.done.addTransform(n,void 0,r,qg(t)),e.undone,Hg(n.mapping.maps),e.prevTime,e.prevComposition):new Rg(e.done,e.undone.addTransform(n,void 0,r,qg(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Vg(n,e.prevRanges)),s=o?Ug(e.prevRanges,n.mapping):Hg(n.mapping.maps);return new Rg(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,qg(t)),Fg.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new Rg(e.done.rebased(n,a),e.undone.rebased(n,a),Ug(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new Rg(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Ug(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Vg(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function Hg(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function Ug(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function Wg(e,t,n){let r=qg(t),i=Jg.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new Rg(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(Jg,{redo:n,historyState:c})}var Gg=!1,Kg=null;function qg(e){let t=e.plugins;if(Kg!=t){Gg=!1,Kg=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Gg=!0;break}}return Gg}var Jg=new k(`history`),Yg=new k(`closeHistory`);function Xg(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new O({key:Jg,state:{init(){return new Rg(Fg.empty,Fg.empty,null,0,-1)},apply(t,n,r){return Bg(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?Qg:n==`historyRedo`?$g:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Zg(e,t){return(n,r)=>{let i=Jg.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=Wg(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var Qg=Zg(!1,!0),$g=Zg(!0,!0);function e_(e,t){return Object.assign(e,{meta:{package:`@milkdown/plugin-history`,...t}}),e}var t_=U(`Undo`,()=>()=>Qg);e_(t_,{displayName:`Command<undo>`});var n_=U(`Redo`,()=>()=>$g);e_(n_,{displayName:`Command<redo>`});var r_=ld({},`historyProviderConfig`);e_(r_,{displayName:`Ctx<historyProviderConfig>`});var i_=od(e=>Xg(e.get(r_.key)));e_(i_,{displayName:`Ctx<historyProviderPlugin>`});var a_=K(`historyKeymap`,{Undo:{shortcuts:`Mod-z`,command:e=>{let t=e.get(H);return()=>t.call(t_.key)}},Redo:{shortcuts:[`Mod-y`,`Shift-Mod-z`],command:e=>{let t=e.get(H);return()=>t.call(n_.key)}}});e_(a_.ctx,{displayName:`KeymapCtx<history>`}),e_(a_.shortcuts,{displayName:`Keymap<history>`});var o_=[r_,i_,a_,t_,n_].flat(),s_=class{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.selectionUpdatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=e=>(this.beforeMountedListeners.push(e),this),this.mounted=e=>(this.mountedListeners.push(e),this),this.updated=e=>(this.updatedListeners.push(e),this)}get listeners(){return{beforeMount:this.beforeMountedListeners,mounted:this.mountedListeners,updated:this.updatedListeners,markdownUpdated:this.markdownUpdatedListeners,blur:this.blurListeners,focus:this.focusListeners,destroy:this.destroyListeners,selectionUpdated:this.selectionUpdatedListeners}}markdownUpdated(e){return this.markdownUpdatedListeners.push(e),this}blur(e){return this.blurListeners.push(e),this}focus(e){return this.focusListeners.push(e),this}destroy(e){return this.destroyListeners.push(e),this}selectionUpdated(e){return this.selectionUpdatedListeners.push(e),this}},c_=v(new s_,`listener`),l_=new k(`MILKDOWN_LISTENER`),u_=e=>(e.inject(c_,new s_),async()=>{await e.wait(iu);let{listeners:t}=e.get(c_);t.beforeMount.forEach(t=>t(e)),await e.wait(Du);let n=e.get(Au),r=null,i=null,a=null,o=null,s=re(()=>{if(!o)return;let{doc:a}=o;if(t.updated.length>0&&r&&!r.eq(a)&&t.updated.forEach(t=>{t(e,a,r)}),t.markdownUpdated.length>0&&r&&!r.eq(a)){let r=n(a);t.markdownUpdated.forEach(t=>{t(e,r,i)}),i=r}r=a,o=null},200),c=new O({key:l_,view:()=>({destroy:()=>{t.destroy.forEach(t=>t(e))}}),props:{handleDOMEvents:{focus:()=>(t.focus.forEach(t=>t(e)),!1),blur:()=>(t.blur.forEach(t=>t(e)),!1)}},state:{init:(e,t)=>{r=t.doc,i=n(t.doc)},apply:n=>{let r=n.selection;(!a&&r||a&&!r.eq(a))&&(t.selectionUpdated.forEach(t=>{t(e,r,a)}),a=r),!(!(n.docChanged||n.storedMarksSet)||n.getMeta(`addToHistory`)===!1)&&(o=n,s())}}});e.update(Xl,e=>e.concat(c)),await e.wait(Uu),t.mounted.forEach(t=>t(e))});u_.meta={package:`@milkdown/plugin-listener`,displayName:`Listener`};var Q=e(n(),1),d_=new Set([`code_block`,`math_block`]),f_=new Set([`math_inline`]);function p_(e,t,n){let r=e.nodeDOM(t);return r instanceof HTMLElement?(r.dispatchEvent(new CustomEvent(`notes-enter-editing`,{bubbles:!1,detail:{caretPosition:n}})),!0):!1}function m_(e,t){if(!(e.selection instanceof E))return null;let{$cursor:n}=e.selection;if(!n||t===`prev`&&n.parentOffset!==0||t===`next`&&n.parentOffset!==n.parent.content.size)return null;let r=n.depth;if(r<1)return null;let i=r-1,a=n.index(i),o=n.node(i);if(t===`prev`){if(a===0)return null;let e=o.child(a-1);return d_.has(e.type.name)?{node:e,pos:n.before(r)-e.nodeSize}:null}if(a>=o.childCount-1)return null;let s=o.child(a+1);return d_.has(s.type.name)?{node:s,pos:n.after(r)}:null}var h_=[od(()=>va({Backspace:(e,t,n)=>{if(!(e.selection instanceof E))return!1;let{$cursor:r}=e.selection;if(!r||r.parentOffset!==0)return!1;let i=r.depth;if(i<1)return!1;let a=i-1,o=r.index(a);if(o===0)return!1;let s=r.node(a).child(o-1);if(!d_.has(s.type.name))return!1;if(!n)return!0;let c=r.before(i)-s.nodeSize,l=n.nodeDOM(c);return l instanceof HTMLElement&&l.dispatchEvent(new CustomEvent(`notes-enter-editing`,{bubbles:!1})),!0},Enter:(e,t)=>{if(!(e.selection instanceof D))return!1;let n=e.selection.node;if(!d_.has(n.type.name))return!1;if(!t)return!0;let r=e.selection.from+n.nodeSize,i=e.schema.nodes.paragraph?.create();if(!i)return!1;let a=e.tr.insert(r,i);return a.setSelection(E.create(a.doc,r+1)),t(a.scrollIntoView()),!0},ArrowDown:(e,t,n)=>{if(!n||!n.endOfTextblock(`down`))return!1;let r=m_(e,`next`);return r?p_(n,r.pos,`start`):!1},ArrowUp:(e,t,n)=>{if(!n||!n.endOfTextblock(`up`))return!1;let r=m_(e,`prev`);return r?p_(n,r.pos,`end`):!1},ArrowRight:(e,t,n)=>{if(!n||!(e.selection instanceof E))return!1;let{$cursor:r}=e.selection;if(!r)return!1;let i=r.nodeAfter;if(i&&f_.has(i.type.name))return p_(n,r.pos,`start`);if(r.parentOffset!==r.parent.content.size)return!1;let a=m_(e,`next`);return a?p_(n,a.pos,`start`):!1},ArrowLeft:(e,t,n)=>{if(!n||!(e.selection instanceof E))return!1;let{$cursor:r}=e.selection;if(!r)return!1;let i=r.nodeBefore;if(i&&f_.has(i.type.name))return p_(n,r.pos-i.nodeSize,`end`);if(r.parentOffset!==0)return!1;let a=m_(e,`prev`);return a?p_(n,a.pos,`end`):!1}}))].flat();function g_(e){return e.textContent}function __(e){return String(e.attrs.language??``)}function v_(e){return`\`\`\`${__(e)}\n${g_(e)}\n\`\`\``}function y_(e){let t=e.replace(/\r\n?/g,`
37
- `),n=t.match(/^```([^\n`]*)\n?([\s\S]*?)\n?```\s*$/);return n?{language:n[1]?.trim().toLowerCase().replace(/[^a-z0-9_+-]/g,``)??``,code:n[2]??``}:{language:``,code:t}}function b_(e){return/^```[^\n`]*\n?[\s\S]*?\n?```\s*$/.test(e.replace(/\r\n?/g,`
38
- `))}function x_(e){let{selectionStart:t,selectionEnd:n,value:r}=e;if(t!==n)return t===0&&n===r.length;if(t===0||t===r.length)return!0;let i=r.lastIndexOf(`
39
- `,t-1)+1,a=r.indexOf(`
40
- `,t),o=a===-1?r.length:a,s=r.slice(i,o);return/^```[^\n`]*$/.test(s)}function S_(e,t,n){let r=t();if(r===void 0)return;let i=e.state.doc.nodeAt(r);if(!i)return;let a=y_(n),o=a.code?e.state.schema.text(a.code):[],s=e.state.tr.setNodeMarkup(r,void 0,{...i.attrs,language:a.language}).replaceWith(r+1,r+i.nodeSize-1,o).scrollIntoView();e.dispatch(s)}function C_(e,t,n,r){let i=t();if(i===void 0)return;let a=e.state.doc.nodeAt(i);if(!a)return;let o=y_(n),s=o.code?e.state.schema.text(o.code):[],c=e.state.tr.setNodeMarkup(i,void 0,{...a.attrs,language:o.language}).replaceWith(i+1,i+a.nodeSize-1,s);if(r===`below`){let t=c.mapping.map(i+a.nodeSize),n=c.doc.resolve(i),r=n.index()+1;if(r<n.parent.childCount){let i=n.parent.child(r);if(i.isTextblock&&i.content.size===0){c.setSelection(E.create(c.doc,t+1)),e.dispatch(c.scrollIntoView());return}}let o=e.state.schema.nodes.paragraph?.create();if(!o)return;c.insert(t,o),c.setSelection(E.create(c.doc,t+1)),e.dispatch(c.scrollIntoView());return}let l=c.doc.resolve(i),u=l.index()-1;if(u>=0&&l.parent.child(u).isTextblock){let t=i-1;c.setSelection(E.create(c.doc,t)),e.dispatch(c.scrollIntoView());return}let d=e.state.schema.nodes.paragraph?.create();d&&(c.insert(i,d),c.setSelection(E.create(c.doc,i+1)),e.dispatch(c.scrollIntoView()))}function w_(e){let{selectionStart:t,value:n}=e;if(t===0)return`above`;if(t===n.length)return`below`;let r=n.lastIndexOf(`
41
- `,t-1)+1,i=n.indexOf(`
42
- `,t),a=i===-1?n.length:i,o=n.slice(r,a);return/^```[^\n`]*$/.test(o)&&r===0?`above`:`below`}function T_(){return(e,t,n)=>{let r=e,i=document.createElement(`div`),a=document.createElement(`div`),o=document.createElement(`div`),s=document.createElement(`pre`),c=document.createElement(`code`),l=document.createElement(`textarea`),u=document.createElement(`div`),d=document.createElement(`button`);i.className=`notes-code-source-node`;let p=document.createElement(`button`);a.className=`notes-code-rendered`,o.className=`notes-code-source-header`,p.className=`notes-code-copy-btn`,p.type=`button`,p.setAttribute(`aria-label`,`Copy code`),u.className=`notes-code-raw-controls`,d.className=`notes-code-done-btn`,d.type=`button`,d.textContent=`Done`,d.setAttribute(`aria-label`,`Done editing code block`),l.className=`notes-code-raw`,l.setAttribute(`aria-label`,`Edit fenced code source`),i.contentEditable=`false`,i.tabIndex=0,s.append(c),o.append(p),a.append(o,s),u.append(d),i.append(a,u,l);function m(){return __(r)||`copy`}function h(){let e=__(r),t=g_(r);i.dataset.language=e,s.dataset.language=e,p.textContent=m();let n=f(t,e);c.className=`hljs language-${n.language}`,c.dataset.highlighted=n.highlighted?`yes`:`no`,c.innerHTML=n.html,i.dataset.editing!==`true`&&(l.value=v_(r))}function g(e,a={}){if(!(i.dataset.editing===`true`&&e)&&!(!e&&i.dataset.editing!==`true`)){if(!e&&a.commit!==!1){let e=l.value;i.dataset.editing=`false`,l.blur(),S_(t,n,e);return}i.dataset.editing=e?`true`:`false`,e?(l.value=v_(r),l.focus(),l.select()):l.blur()}}function ee(e){i.dataset.editing===`true`&&(i.contains(e.target)||setTimeout(()=>{i.dataset.editing===`true`&&g(!1,{commit:!1})},0))}function _(e=`below`){let r=l.value;g(!1,{commit:!1}),C_(t,n,r,e),t.focus()}function te(e){if(!(e instanceof HTMLElement))return;let t=e.querySelector(`textarea.notes-code-raw`);t instanceof HTMLTextAreaElement&&(e.dataset.editing=`true`,t.focus(),t.select())}function ne(e){if(l.contains(e.target)||p.contains(e.target)||i.dataset.editing===`true`)return;e.preventDefault(),e.stopPropagation();let t=e instanceof PointerEvent||e instanceof MouseEvent?{x:e.clientX,y:e.clientY}:null;setTimeout(()=>{if(i.isConnected){g(!0);return}te(t?document.elementFromPoint(t.x,t.y)?.closest(`.notes-code-source-node`)??null:null)},0)}return i.addEventListener(`pointerdown`,ne,{capture:!0}),i.addEventListener(`mousedown`,ne,{capture:!0}),i.addEventListener(`click`,ne),i.addEventListener(`keydown`,e=>{e.target===i&&i.dataset.editing!==`true`&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),g(!0))}),l.addEventListener(`keydown`,e=>{if(e.key===`Escape`){e.preventDefault(),g(!1,{commit:!1}),t.focus();return}if(e.key===`Enter`&&b_(l.value)&&x_(l)){e.preventDefault(),_(w_(l));return}if(e.key===`ArrowUp`&&b_(l.value)&&!l.value.slice(0,l.selectionStart).includes(`
43
- `)){e.preventDefault(),_(`above`);return}if(e.key===`ArrowDown`&&b_(l.value)&&!l.value.slice(l.selectionEnd).includes(`
44
- `)){e.preventDefault(),_(`below`);return}if(e.key===`ArrowLeft`&&b_(l.value)&&l.selectionStart===0&&l.selectionEnd===0){e.preventDefault(),_(`above`);return}if(e.key===`ArrowRight`&&b_(l.value)&&l.selectionStart===l.value.length&&l.selectionEnd===l.value.length){e.preventDefault(),_(`below`);return}e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),g(!1,{commit:!1}),t.focus())}),l.addEventListener(`input`,()=>{S_(t,n,l.value)}),l.addEventListener(`blur`,()=>{setTimeout(()=>{i.dataset.editing===`true`&&document.activeElement!==l&&g(!1,{commit:!1})},0)}),l.addEventListener(`mousedown`,e=>e.stopPropagation()),l.addEventListener(`click`,e=>e.stopPropagation()),document.addEventListener(`pointerdown`,ee,!0),d.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),_(`below`)}),d.addEventListener(`mousedown`,e=>e.stopPropagation()),p.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation();let t=g_(r);navigator.clipboard.writeText(t).then(()=>{p.textContent=`Copied!`,setTimeout(()=>{p.textContent=m()},1500)})}),p.addEventListener(`mousedown`,e=>e.stopPropagation()),i.addEventListener(`notes-enter-editing`,e=>{g(!0);let t=e.detail?.caretPosition===`start`?0:l.value.length;l.setSelectionRange(t,t)}),h(),{dom:i,update:e=>e.type===r.type?(r=e,h(),!0):!1,selectNode:()=>{i.dataset.selected=`true`},deselectNode:()=>{i.dataset.selected=`false`,i.dataset.editing===`true`&&g(!1,{commit:!1})},stopEvent:e=>e.target===l||l.contains(e.target)||e.target===d||d.contains(e.target)||e.type===`pointerdown`||e.type===`mousedown`||e.type===`click`,ignoreMutation:e=>e.target===i||e.target===l||l.contains(e.target)||u.contains(e.target)||a.contains(e.target),destroy:()=>{document.removeEventListener(`pointerdown`,ee,!0)}}}}var E_=[cd(_f.node,()=>T_())].flat(),D_=[Tg,hg.filter(e=>e!==pg),gg,_g,mg,Eg,wg].flat(),O_=1,k_=6,A_=`notes-heading-source-updated`;function j_(e){let t=Number(e.attrs.level);return Number.isFinite(t)?Math.min(k_,Math.max(O_,Math.trunc(t))):O_}function M_(e){return`#`.repeat(e)}function N_(e){let t=e.trim();return t===``?0:/^#{1,6}$/.test(t)?t.length:null}function P_(e,t){return E.near(e.state.doc.resolve(Math.min(t,e.state.doc.content.size)),1)}function F_(e,t,n,r){let i=t();if(i===void 0)return;let a=e.state.doc.nodeAt(i);if(!a||a.type.name!==`heading`)return;let o=e.state.schema.nodes.paragraph,s=r===0&&o?e.state.tr.setNodeMarkup(i,o):e.state.tr.setNodeMarkup(i,void 0,{...n.attrs,level:r});r===0?s.setSelection(P_(e,i+1)):s.setSelection(e.state.selection.map(s.doc,s.mapping)),e.dispatch(s.scrollIntoView()),e.dom.dispatchEvent(new CustomEvent(A_,{bubbles:!0}))}function I_(){return(e,t,n)=>{let r=e,i=document.createElement(`div`),a=document.createElement(`input`),o=document.createElement(`span`);i.className=`notes-heading-source-node`,a.className=`notes-heading-source-marker`,a.type=`text`,a.inputMode=`text`,a.autocomplete=`off`,a.spellcheck=!1,a.setAttribute(`aria-label`,`Edit heading marker`),o.className=`notes-heading-source-content`,i.append(a,o);function s(){let e=j_(r);i.dataset.level=String(e),i.setAttribute(`role`,`heading`),i.setAttribute(`aria-level`,String(e)),i.setAttribute(`aria-label`,r.textContent),document.activeElement!==a&&(a.value=M_(e)),a.size=Math.max(1,a.value.length)}function c(){let e=N_(a.value);if(e===null){a.value=M_(j_(r)),s();return}F_(t,n,r,e),t.focus()}function l(e){a.contains(e.target)&&(e.preventDefault(),e.stopPropagation(),a.focus(),a.select(),window.setTimeout(()=>{a.focus(),a.select()},0))}function u(){i.dataset.editing=`true`,a.select()}function d(){a.size=Math.max(1,a.value.length);let e=N_(a.value);e===null||e===0||e===j_(r)||F_(t,n,r,e)}function f(){i.dataset.editing=`false`,c()}function p(e){e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),a.blur()),e.key===`Escape`&&(e.preventDefault(),a.value=M_(j_(r)),i.dataset.editing=`false`,a.blur(),t.focus())}return i.addEventListener(`pointerdown`,l,{capture:!0}),i.addEventListener(`mousedown`,l,{capture:!0}),i.addEventListener(`click`,l,{capture:!0}),a.addEventListener(`focus`,u),a.addEventListener(`input`,d),a.addEventListener(`blur`,f),a.addEventListener(`keydown`,p),s(),{dom:i,contentDOM:o,update(e){return e.type.name===`heading`?(r=e,s(),!0):!1},selectNode(){i.dataset.selected=`true`},deselectNode(){delete i.dataset.selected},stopEvent(e){return a.contains(e.target)||e.type===`pointerdown`||e.type===`mousedown`||e.type===`click`},ignoreMutation(e){return e.target===i||a.contains(e.target)},destroy(){i.removeEventListener(`pointerdown`,l,{capture:!0}),i.removeEventListener(`mousedown`,l,{capture:!0}),i.removeEventListener(`click`,l,{capture:!0}),a.removeEventListener(`focus`,u),a.removeEventListener(`input`,d),a.removeEventListener(`blur`,f),a.removeEventListener(`keydown`,p)}}}}var L_=[cd(of.node,()=>I_())].flat(),R_=`math_inline`,z_=`math_block`,B_=ld({},`notesKatexOptions`),V_=pd(`notesRemarkMath`,()=>s);function H_(e,n,r){e.textContent=``;try{t.render(n,e,r)}catch{e.textContent=n}}function U_(e,t,n){let r=t();if(r===void 0)return;let i=e.state.doc.nodeAt(r);i&&e.dispatch(e.state.tr.setNodeMarkup(r,void 0,{...i.attrs,value:n}).scrollIntoView())}function W_(e){return`$${e}$`}function G_(e){return`$$\n${e}\n$$`}function K_(e){let t=e.trim();return t.startsWith(`$$`)&&t.endsWith(`$$`)&&t.length>=4?t.slice(2,-2).trim():t.startsWith(`$`)&&t.endsWith(`$`)&&t.length>=2?t.slice(1,-1).trim():e}function q_(e){let t=e.trim();return t.startsWith(`$$`)&&t.endsWith(`$$`)&&t.length>=4?t.slice(2,-2).trim():e}function J_(e,t){let n=e.trim();return t?n.startsWith(`$$`)&&n.endsWith(`$$`)&&n.length>=4:n.startsWith(`$`)&&n.endsWith(`$`)&&n.length>=2}function Y_(e){return e.selectionStart===e.value.length&&e.selectionEnd===e.value.length}function X_(e,t){let n=e.selectionStart??0,r=e.selectionEnd??0,i=e.value;if(n!==r)return n===0&&r===i.length;if(n===0||n===i.length)return!0;if(!t)return!1;let a=i.lastIndexOf(`
45
- `,n-1)+1,o=i.indexOf(`
46
- `,n),s=o===-1?i.length:o,c=i.slice(a,s);return/^\$\$$/.test(c)}function Z_(e,t,n,r,i){let a=t();if(a===void 0)return;let o=e.state.doc.nodeAt(a);if(!o)return;let s=e.state.tr.setNodeMarkup(a,void 0,{...o.attrs,value:r});if(i===`above`&&n){let t=s.doc.resolve(a),n=t.index()-1;if(n>=0&&t.parent.child(n).isTextblock){s.setSelection(E.create(s.doc,a-1)),e.dispatch(s.scrollIntoView());return}let r=e.state.schema.nodes.paragraph?.create();if(!r)return;s.insert(a,r),s.setSelection(E.create(s.doc,a+1)),e.dispatch(s.scrollIntoView());return}let c=s.mapping.map(a+o.nodeSize);if(n){let t=s.doc.resolve(a),n=t.index()+1,r=!1;if(n<t.parent.childCount){let e=t.parent.child(n);e.isTextblock&&e.content.size===0&&(s.setSelection(E.create(s.doc,c+1)),r=!0)}if(!r){let t=e.state.schema.nodes.paragraph?.create();if(!t)return;s.insert(c,t),s.setSelection(E.create(s.doc,c+1))}}else i===`above`?s.setSelection(E.near(s.doc.resolve(a),-1)):s.setSelection(E.near(s.doc.resolve(c),1));e.dispatch(s.scrollIntoView())}function Q_(e,t){let n=e.selectionStart??0,r=e.value;if(n===0)return`above`;if(n===r.length||!t)return`below`;let i=r.lastIndexOf(`
47
- `,n-1)+1,a=r.indexOf(`
48
- `,n),o=a===-1?r.length:a,s=r.slice(i,o);return/^\$\$$/.test(s)&&i===0?`above`:`below`}function $_(e){return(t,n,r)=>{let i=t,a=document.createElement(e.block?`div`:`span`),o=document.createElement(e.block?`div`:`span`),s=e.block?document.createElement(`textarea`):document.createElement(`input`),c=e.block?document.createElement(`span`):null;a.className=e.block?`notes-math-node notes-math-block-node`:`notes-math-node notes-math-inline-node`,a.contentEditable=`false`,a.tabIndex=0,o.className=`notes-math-rendered`,s.className=`notes-math-raw`,s.setAttribute(`aria-label`,e.block?`Edit block math source`:`Edit inline math source`),s instanceof HTMLInputElement&&(s.type=`text`),c&&(c.className=`notes-math-label`,c.textContent=`math`,a.append(c)),a.append(o,s);function l(){return String(i.attrs.value??``)}function u(t){a.dataset.editing===`true`&&t||!t&&a.dataset.editing!==`true`||(a.dataset.editing=t?`true`:`false`,t?(s.value=e.block?G_(l()):W_(l()),s.focus(),s.select()):s.blur())}function d(t=`below`){let i=e.block?q_(s.value):K_(s.value);u(!1),Z_(n,r,e.block,i,t),n.focus()}function f(){let t=l();a.dataset.value=t,a.dataset.editing!==`true`&&(s.value=e.block?G_(t):W_(t)),e.render(o,t)}function p(e){if(!(e instanceof HTMLElement))return;let t=e.querySelector(`.notes-math-raw`);(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(e.dataset.editing=`true`,t.focus(),t.select())}function m(e){if(s.contains(e.target)||a.dataset.editing===`true`)return;e.preventDefault(),e.stopPropagation();let t=e instanceof PointerEvent||e instanceof MouseEvent?{x:e.clientX,y:e.clientY}:null;setTimeout(()=>{if(a.isConnected){u(!0);return}p(t?document.elementFromPoint(t.x,t.y)?.closest(`.notes-math-node`)??null:null)},0)}return a.addEventListener(`pointerdown`,m,{capture:!0}),a.addEventListener(`mousedown`,m,{capture:!0}),a.addEventListener(`click`,m),a.addEventListener(`keydown`,e=>{let t=e;t.target===a&&a.dataset.editing!==`true`&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),u(!0))}),s.addEventListener(`input`,()=>{U_(n,r,e.block?q_(s.value):K_(s.value)),e.block&&J_(s.value,e.block)&&Y_(s)&&queueMicrotask(d)}),s.addEventListener(`blur`,()=>u(!1)),s.addEventListener(`keydown`,t=>{let r=t;if(r.key===`Escape`){r.preventDefault(),u(!1),n.focus();return}if(r.key===`Enter`&&J_(s.value,e.block)&&X_(s,e.block)){r.preventDefault(),d(Q_(s,e.block));return}if(r.key===`ArrowUp`&&J_(s.value,e.block)&&!s.value.slice(0,s.selectionStart??0).includes(`
49
- `)){r.preventDefault(),d(`above`);return}if(r.key===`ArrowDown`&&J_(s.value,e.block)&&!s.value.slice(s.selectionEnd??s.value.length).includes(`
50
- `)){r.preventDefault(),d(`below`);return}if(r.key===`ArrowLeft`&&J_(s.value,e.block)&&(s.selectionStart??0)===0&&(s.selectionEnd??0)===0){r.preventDefault(),d(`above`);return}if(r.key===`ArrowRight`&&J_(s.value,e.block)&&(s.selectionStart??0)===s.value.length&&(s.selectionEnd??0)===s.value.length){r.preventDefault(),d(`below`);return}!e.block&&r.key===`Enter`&&(r.preventDefault(),u(!1),n.focus()),e.block&&r.key===`Enter`&&(r.metaKey||r.ctrlKey)&&(r.preventDefault(),u(!1),n.focus())}),s.addEventListener(`mousedown`,e=>e.stopPropagation()),s.addEventListener(`click`,e=>e.stopPropagation()),a.addEventListener(`notes-enter-editing`,e=>{u(!0);let t=e.detail?.caretPosition===`start`?0:s.value.length;s.setSelectionRange(t,t)}),f(),{dom:a,update:e=>e.type===i.type?(i=e,f(),!0):!1,selectNode:()=>{a.dataset.selected=`true`},deselectNode:()=>{a.dataset.selected=`false`},stopEvent:e=>e.target===s||s.contains(e.target)||e.type===`pointerdown`||e.type===`mousedown`||e.type===`click`,ignoreMutation:e=>e.target===a||e.target===s||s.contains(e.target)||o.contains(e.target)}}}var ev=G(R_,e=>({group:`inline`,inline:!0,atom:!0,attrs:{value:{default:``,validate:`string`}},parseDOM:[{tag:`span[data-type="${R_}"]`,getAttrs:e=>({value:e instanceof HTMLElement?e.dataset.value??``:``})}],toDOM:t=>{let n=t.attrs.value,r=document.createElement(`span`);return r.dataset.type=R_,r.dataset.value=n,H_(r,n,e.get(B_.key)),r},parseMarkdown:{match:e=>e.type===`inlineMath`,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>e.type.name===R_,runner:(e,t)=>{e.addNode(`inlineMath`,void 0,t.attrs.value)}}})),tv=G(z_,e=>({content:`text*`,group:`block`,marks:``,defining:!0,atom:!0,isolating:!0,attrs:{value:{default:``,validate:`string`}},parseDOM:[{tag:`div[data-type="${z_}"]`,preserveWhitespace:`full`,getAttrs:e=>({value:e instanceof HTMLElement?e.dataset.value??``:``})}],toDOM:t=>{let n=t.attrs.value,r=document.createElement(`div`);return r.dataset.type=z_,r.dataset.value=n,H_(r,n,e.get(B_.key)),r},parseMarkdown:{match:e=>e.type===`math`,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>e.type.name===z_,runner:(e,t)=>{e.addNode(`math`,void 0,t.attrs.value)}}})),nv=cd(ev.node,e=>$_({block:!1,render:(t,n)=>H_(t,n,e.get(B_.key))})),rv=cd(tv.node,e=>$_({block:!0,render:(t,n)=>H_(t,n,e.get(B_.key))})),iv=W(e=>new A(/(?:\$)([^$]+)(?:\$)$/,(t,n,r,i)=>{let a=n[1]?.trim();return a?t.tr.replaceWith(r,i,ev.type(e).create({value:a})):null})),av=[V_,B_,ev,tv,nv,rv,W(e=>new A(/^\$\$\s$/,(t,n,r,i)=>{let a=t.doc.resolve(r);return a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),tv.type(e))?t.tr.delete(r,i).setBlockType(r,r,tv.type(e)):null})),iv].flat(),ov=/^([ \t]*[-*+][ \t]+)\\?\[([ xX])\\?\]([ \t]*)/gm,sv=/^([ \t]*[-*+][ \t]+)\[([ xX])\]([ \t]*)/gm,cv=/^([ \t]*)\[\^([^\]\n]+)\]:/gm,lv=/^([ \t]*)\\\[\^([^\]\n]+)\]:/gm,uv=/(^|[^\]\\])\[\^([^\]\n]+)\]/g,dv=/(^|[^\\])\\\[\^([^\]\n]+)\]/g;function fv(e){return e.replace(sv,`$1\\[$2\\]$3`).replace(cv,`$1\\[^$2]:`).replace(uv,`$1\\[^$2]`)}function pv(e){return e.replace(ov,`$1[$2]$3`).replace(lv,`$1[^$2]:`).replace(dv,`$1[^$2]`)}var $=r();function mv(e){e?.querySelector(`.ProseMirror`)?.focus()}function hv(e){let t=document.createElement(`div`);return t.innerHTML=e,t.textContent??``}function gv(e){return e.trim().toLowerCase().replace(/[^a-z0-9_+-]/g,``)}function _v(e){let t=(0,Q.useRef)(null),n=(0,Q.useRef)(null),r=(0,Q.useRef)(e.content),i=(0,Q.useRef)(e.content),a=(0,Q.useRef)(e.onChange),o=(0,Q.useRef)(!0),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{a.current=e.onChange},[e.onChange]),(0,Q.useEffect)(()=>{i.current=e.content},[e.content]),(0,Q.useEffect)(()=>{let s=!1,l=null,d=t.current;if(d)return ed.make().config(e=>{e.set(Ku,d),e.set(Mu,fv(r.current)),e.set(B_.key,{throwOnError:!1,strict:`warn`}),e.get(c_).markdownUpdated((e,t)=>{let n=pv(t);r.current=n,!o.current&&a.current(n)})}).use(bp).use(D_).use(L_).use(av).use(E_).use(h_).use(o_).use(Ag).use(u_).create().then(t=>{if(s){t.destroy();return}l=t,n.current=t,i.current!==r.current&&(r.current=i.current,t.action(_d(fv(i.current),!0))),c(!0),queueMicrotask(()=>{o.current=!1}),e.active&&mv(d)}).catch(e=>{console.error(`[notes-wysiwyg]`,e),u(e instanceof Error?e.message:`WYSIWYG editor failed to load`),c(!1)}),()=>{s=!0,c(!1),n.current=null,l&&l.destroy()}},[]),(0,Q.useEffect)(()=>{let t=n.current;t&&e.content!==r.current&&(o.current=!0,r.current=e.content,t.action(_d(fv(e.content),!0)),queueMicrotask(()=>{o.current=!1}))},[e.content]),(0,Q.useEffect)(()=>{e.active&&s&&mv(t.current)},[e.active,s]),(0,Q.useEffect)(()=>{if(!s)return;let e=t.current;if(!e)return;function i(){n.current?.action(e=>{let t=pv(hd()(e));r.current=t,o.current||a.current(t)})}return e.addEventListener(`notes-heading-source-updated`,i),()=>{e.removeEventListener(`notes-heading-source-updated`,i)}},[s]);function d(e){let r=n.current;r&&(mv(t.current),e(r))}function f(){let e=window.prompt(`Link URL`);if(!e)return;let t=g(e.trim());t&&d(e=>e.action(gd(`[link](${t})`,!0)))}function p(){let e=window.prompt(`Inline math`);e&&d(t=>t.action(t=>{let n=t.get(z),r=t.get(V).nodes.math_inline?.create({value:e.trim()});r&&n.dispatch(n.state.tr.replaceSelectionWith(r,!0).scrollIntoView())}))}function m(){let e=window.prompt(`Block math`);e&&d(t=>t.action(t=>{let n=t.get(z),r=t.get(V).nodes.math_block?.create({value:e.trim()});r&&n.dispatch(n.state.tr.replaceSelectionWith(r,!1).scrollIntoView())}))}function h(){let e=gv(window.prompt(`Code block language`)??``);d(t=>t.action(md(yf.key,e)))}function ee(){d(e=>e.action(md(Kh.key,{row:3,col:3})))}function _(){let e=r.current.trimEnd(),t=`${e}${e?`
51
-
52
- `:``}- [ ] `;r.current=t,a.current(t),d(e=>e.action(_d(fv(t),!0)))}(0,Q.useEffect)(()=>{if(!s)return;let e=t.current;if(!e)return;function i(){e.querySelectorAll(`li[data-item-type="task"][data-checked]`).forEach(e=>{let t=e.dataset.checked===`true`;e.setAttribute(`role`,`checkbox`),e.setAttribute(`aria-checked`,t?`true`:`false`),e.setAttribute(`tabindex`,`0`),e.setAttribute(`aria-label`,e.textContent?.trim()||(t?`Checked task`:`Unchecked task`))})}function c(e){n.current?.action(t=>{let n=t.get(z),s=n.posAtDOM(e,0),c=n.state.doc.resolve(s);for(let e=c.depth;e>0;--e){let s=c.node(e);if(s.type.name!==`list_item`||s.attrs.checked==null)continue;let l=c.before(e);n.dispatch(n.state.tr.setNodeMarkup(l,void 0,{...s.attrs,checked:!s.attrs.checked}).scrollIntoView());let u=pv(hd()(t));r.current=u,o.current||a.current(u),queueMicrotask(i);return}})}function l(t){let n=t.target;if(!(n instanceof HTMLElement))return;let r=e,i=n.closest(`li[data-item-type="task"][data-checked]`),a=i&&r.contains(i)?i:Array.from(r.querySelectorAll(`li[data-item-type="task"][data-checked]`)).find(e=>{let n=e.getBoundingClientRect();return t.clientY>=n.top&&t.clientY<=n.bottom&&t.clientX>=n.left&&t.clientX<=n.left+26})??null;if(!a||!r.contains(a))return;let o=a.getBoundingClientRect();t.clientX>o.left+26||(t.preventDefault(),c(a))}function u(t){if(t.key!==` `&&t.key!==`Enter`)return;let n=t.target;if(!(n instanceof HTMLElement))return;let r=n.closest(`li[data-item-type="task"][data-checked]`);!r||!e.contains(r)||(t.preventDefault(),c(r))}i();let d=new MutationObserver(i);return d.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-checked`]}),e.addEventListener(`click`,l),e.addEventListener(`keydown`,u,!0),()=>{d.disconnect(),e.removeEventListener(`click`,l),e.removeEventListener(`keydown`,u,!0)}},[s]);function te(e){let t=e.clipboardData.getData(`text/html`);if(!t)return;e.preventDefault();let n=e.clipboardData.getData(`text/plain`)||hv(t);n&&d(e=>e.action(gd(n)))}return(0,$.jsxs)(`div`,{className:`notes-milkdown-shell`,onPasteCapture:te,children:[(0,$.jsxs)(`div`,{className:`notes-wysiwyg-toolbar`,"aria-label":`WYSIWYG formatting tools`,children:[(0,$.jsx)(`button`,{type:`button`,title:`Bold`,"aria-label":`Bold`,disabled:!s,onClick:()=>d(e=>e.action(md(Fd.key))),children:`B`}),(0,$.jsx)(`button`,{type:`button`,title:`Italic`,"aria-label":`Italic`,disabled:!s,onClick:()=>d(e=>e.action(md(kd.key))),children:`I`}),(0,$.jsx)(`button`,{type:`button`,title:`Strikethrough`,"aria-label":`Strikethrough`,disabled:!s,onClick:()=>d(e=>e.action(md(Dh.key))),children:`S`}),(0,$.jsx)(`button`,{type:`button`,title:`Inline code`,"aria-label":`Inline code`,disabled:!s,onClick:()=>d(e=>e.action(md(Bd.key))),children:`Code`}),(0,$.jsx)(`button`,{type:`button`,title:`Link`,"aria-label":`Link`,disabled:!s,onClick:f,children:`Link`}),(0,$.jsx)(`button`,{type:`button`,title:`Inline math`,"aria-label":`Inline math`,disabled:!s,onClick:p,children:`Math`}),(0,$.jsx)(`button`,{type:`button`,title:`Block math`,"aria-label":`Block math`,disabled:!s,onClick:m,children:`Math Block`}),(0,$.jsx)(`button`,{type:`button`,title:`Heading`,"aria-label":`Heading level 2`,disabled:!s,onClick:()=>d(e=>e.action(md(cf.key,2))),children:`H2`}),(0,$.jsx)(`button`,{type:`button`,title:`List`,"aria-label":`Bullet list`,disabled:!s,onClick:()=>d(e=>e.action(md(If.key))),children:`List`}),(0,$.jsx)(`button`,{type:`button`,title:`Task list`,"aria-label":`Task list`,disabled:!s,onMouseDown:e=>e.preventDefault(),onClick:_,children:`Task`}),(0,$.jsx)(`button`,{type:`button`,title:`Quote`,"aria-label":`Quote`,disabled:!s,onClick:()=>d(e=>e.action(md(mf.key))),children:`Quote`}),(0,$.jsx)(`button`,{type:`button`,title:`Table`,"aria-label":`Table`,disabled:!s,onClick:ee,children:`Table`}),(0,$.jsx)(`button`,{type:`button`,title:`Code block`,"aria-label":`Code block`,disabled:!s,onClick:h,children:`Block`})]}),l&&(0,$.jsx)(`div`,{className:`notes-wysiwyg-error`,role:`alert`,children:l}),(0,$.jsx)(`div`,{ref:t,className:`notes-milkdown-root`,"data-ready":s?`true`:`false`,"aria-label":`Milkdown WYSIWYG markdown editor`,role:`textbox`,"aria-multiline":`true`})]})}export{_v as MilkdownWysiwygEditor};