@panphora/clayjs 1.15.2 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (506) hide show
  1. package/README.md +4 -5
  2. package/THIRD-PARTY-NOTICES.md +16 -0
  3. package/compat/highlight-11.9.0.min.js +1213 -0
  4. package/compat/highlight-LICENSE +29 -0
  5. package/compat/journal-assets.lock.json +22 -0
  6. package/compat/overtype-2.6.1.min.js +116 -0
  7. package/compat/overtype-LICENSE +21 -0
  8. package/dist/all.js +90 -0
  9. package/dist/clay-dom.js +84 -0
  10. package/dist/clay-events.js +103 -0
  11. package/dist/clay-internals.js +85 -0
  12. package/dist/clay-options.js +93 -0
  13. package/dist/clay-router.js +98 -0
  14. package/dist/clay-ui.js +95 -0
  15. package/dist/clay-utils.js +84 -0
  16. package/dist/clay.js +146 -0
  17. package/dist/clay.standalone.js +83090 -58706
  18. package/dist/m/attrs/add-from-T5LJXFFI.js +1 -0
  19. package/dist/m/attrs/onaftersave-OKSWEJQF.js +1 -0
  20. package/dist/m/attrs/refetch-on-save-NWPPXOCZ.js +1 -0
  21. package/dist/m/attrs/save-freeze-FUP4Q4X3.js +1 -0
  22. package/dist/m/c-2AZDZWCK.js +1 -0
  23. package/dist/m/c-2JL6E75N.js +1 -0
  24. package/dist/m/c-2M73252O.js +1 -0
  25. package/dist/m/c-2SPVQSHC.js +1 -0
  26. package/dist/m/c-33HUYEDI.js +1 -0
  27. package/dist/m/c-33JJ6CBX.js +2 -0
  28. package/dist/m/c-35NBGMZB.js +1 -0
  29. package/dist/m/c-3GJ4SDE2.js +1 -0
  30. package/dist/m/c-3IQRECYS.js +1 -0
  31. package/dist/m/c-3OWDMNJR.js +2 -0
  32. package/dist/m/c-46XYM55L.js +1 -0
  33. package/dist/m/c-4B6H4G5V.js +1 -0
  34. package/dist/m/c-4DRMS4QG.js +9 -0
  35. package/dist/m/c-4FFHZM32.js +1 -0
  36. package/dist/m/c-4JZDZFF6.js +1 -0
  37. package/dist/m/c-4L3BTFRK.js +1 -0
  38. package/dist/m/c-4Q2XTQ2N.js +2 -0
  39. package/dist/m/c-4WKFKEKF.js +1 -0
  40. package/dist/m/c-4YSCRICO.js +1 -0
  41. package/dist/m/c-54RCDCBU.js +1 -0
  42. package/dist/m/c-5M4YEKCX.js +4 -0
  43. package/dist/m/c-5R4PTRG2.js +1 -0
  44. package/dist/m/c-5V3MOVJT.js +1 -0
  45. package/dist/m/c-5VYOWDTI.js +1 -0
  46. package/dist/m/c-5Y6TNX5W.js +34 -0
  47. package/dist/m/c-5YIHJ3TJ.js +1 -0
  48. package/dist/m/c-66O32MV3.js +28 -0
  49. package/dist/m/c-6HMB24EV.js +1 -0
  50. package/dist/m/c-7DJDKPGL.js +1 -0
  51. package/dist/m/c-7O6AFR65.js +1 -0
  52. package/dist/m/c-7SWMYKAI.js +1 -0
  53. package/dist/m/c-7VGZ7RU5.js +1 -0
  54. package/dist/m/c-A7LS5UZW.js +1 -0
  55. package/dist/m/c-ANQTJ3B5.js +2 -0
  56. package/dist/m/c-AQLFEATB.js +1 -0
  57. package/dist/m/c-AYVOREBE.js +1 -0
  58. package/dist/m/c-B2ZXPOS3.js +3 -0
  59. package/dist/m/c-BBVGTQG7.js +1 -0
  60. package/dist/m/c-BMIZKMPV.js +1 -0
  61. package/dist/m/c-BTDI4Y23.js +1 -0
  62. package/dist/m/c-BWFVSBDF.js +1 -0
  63. package/dist/m/c-BYTKL6UX.js +1 -0
  64. package/dist/m/c-CFHW5AMY.js +6 -0
  65. package/dist/m/c-CJZSLMVQ.js +1 -0
  66. package/dist/m/c-CYWLPPUS.js +1 -0
  67. package/dist/m/c-CZUSOB7V.js +1 -0
  68. package/dist/m/c-DBE6ORSI.js +1 -0
  69. package/dist/m/c-DCFSEJZG.js +1 -0
  70. package/dist/m/c-DNZ5IFM6.js +1 -0
  71. package/dist/m/c-EDHUR4MX.js +1 -0
  72. package/dist/m/c-EJTGYSLN.js +1 -0
  73. package/dist/m/c-EY6UOM54.js +1 -0
  74. package/dist/m/c-F3CKJTJS.js +1 -0
  75. package/dist/m/c-F7Y6FLPY.js +1 -0
  76. package/dist/m/c-FA4DZVTC.js +1 -0
  77. package/dist/m/c-FILLTJA7.js +1 -0
  78. package/dist/m/c-G2BUZITR.js +1 -0
  79. package/dist/m/c-GB3JTV6E.js +1 -0
  80. package/dist/m/c-GBGWXTX4.js +1 -0
  81. package/dist/m/c-GHBCCVG4.js +1 -0
  82. package/dist/m/c-GJAEGGXY.js +1 -0
  83. package/dist/m/c-GOWBDM6J.js +1 -0
  84. package/dist/m/c-GQ6F6IDK.js +1 -0
  85. package/dist/m/c-H4LG442Q.js +1 -0
  86. package/dist/m/c-HA6INT6J.js +1 -0
  87. package/dist/m/c-HPURYVZS.js +2 -0
  88. package/dist/m/c-HRDCD3WN.js +67 -0
  89. package/dist/m/c-HT33EQRN.js +1 -0
  90. package/dist/m/c-HVYXIS72.js +1 -0
  91. package/dist/m/c-IB52R237.js +1 -0
  92. package/dist/m/c-IJUK2GPW.js +1 -0
  93. package/dist/m/c-IKWNE4R4.js +1 -0
  94. package/dist/m/c-IU3IYEU6.js +1 -0
  95. package/dist/m/c-IZ2EBRAJ.js +1 -0
  96. package/dist/m/c-J7CA54IP.js +1 -0
  97. package/dist/m/c-JAX2667S.js +6 -0
  98. package/dist/m/c-KI7M4AY3.js +1 -0
  99. package/dist/m/c-KIPQJX4B.js +1 -0
  100. package/dist/m/c-KKWLDOPM.js +1 -0
  101. package/dist/m/c-KR4UW4KW.js +1 -0
  102. package/dist/m/c-KY3VJGUA.js +8 -0
  103. package/dist/m/c-L4WQSC27.js +1 -0
  104. package/dist/m/c-LFPHCXY3.js +1 -0
  105. package/dist/m/c-LR4CGEPT.js +91 -0
  106. package/dist/m/c-LRPUO2MX.js +1 -0
  107. package/dist/m/c-LTGMXXKO.js +1 -0
  108. package/dist/m/c-LXENEBV7.js +1 -0
  109. package/dist/m/c-LZJPNR2W.js +1 -0
  110. package/dist/m/c-MMUIUUZG.js +2 -0
  111. package/dist/m/c-MTQHWQC3.js +1 -0
  112. package/dist/m/c-N326R2JD.js +1 -0
  113. package/dist/m/c-N7JPUPGC.js +1 -0
  114. package/dist/m/c-NMJRXKPC.js +8 -0
  115. package/dist/m/c-NRPJEVJS.js +1 -0
  116. package/dist/m/c-NUHP2XDB.js +1 -0
  117. package/dist/m/c-NZMNXVF6.js +1 -0
  118. package/dist/m/c-OCSZ4QGN.js +1 -0
  119. package/dist/m/c-OIBUTDXI.js +1 -0
  120. package/dist/m/c-OIDRZKAF.js +1 -0
  121. package/dist/m/c-OYTFP5QN.js +1 -0
  122. package/dist/m/c-P7KNDG34.js +1 -0
  123. package/dist/m/c-PPOSCAQD.js +1 -0
  124. package/dist/m/c-PQ5LK6QE.js +993 -0
  125. package/dist/m/c-PZ4XEPUP.js +2 -0
  126. package/dist/m/c-QHIWXHRO.js +1 -0
  127. package/dist/m/c-QHWJ5ZIJ.js +1 -0
  128. package/dist/m/c-QIX5BJYN.js +1 -0
  129. package/dist/m/c-QNKREOL6.js +1 -0
  130. package/dist/m/c-QQHEX6HA.js +1 -0
  131. package/dist/m/c-R7RMANJI.js +9 -0
  132. package/dist/m/c-RI4NT75Y.js +1 -0
  133. package/dist/m/c-RM7J7BV2.js +1 -0
  134. package/dist/m/c-RUJKSUQW.js +1 -0
  135. package/dist/m/c-RVMWGXEJ.js +1 -0
  136. package/dist/m/c-S7H2DRCB.js +1 -0
  137. package/dist/m/c-S7LK4KUE.js +1 -0
  138. package/dist/m/c-SGCCC4FW.js +25 -0
  139. package/dist/m/c-SGIA4IEQ.js +188 -0
  140. package/dist/m/c-SWRJFCNN.js +1 -0
  141. package/dist/m/c-T4VO4OCB.js +1 -0
  142. package/dist/m/c-TCCA5BZN.js +2 -0
  143. package/dist/m/c-TQEMVJCS.js +1 -0
  144. package/dist/m/c-TQZ2JYHD.js +1 -0
  145. package/dist/m/c-TR6RMDQ7.js +3 -0
  146. package/dist/m/c-TRS6TM6O.js +1 -0
  147. package/dist/m/c-UGHH4MB3.js +1 -0
  148. package/dist/m/c-UKHTLWUW.js +1 -0
  149. package/dist/m/c-UL2YUY52.js +1 -0
  150. package/dist/m/c-UNN7LWCT.js +1 -0
  151. package/dist/m/c-UXBMRDZB.js +235 -0
  152. package/dist/m/c-V7PZZRG7.js +1 -0
  153. package/dist/m/c-VAK7SG37.js +1 -0
  154. package/dist/m/c-VDSS4K3Z.js +1 -0
  155. package/dist/m/c-VFX45IZQ.js +1 -0
  156. package/dist/m/c-VHNSBD2M.js +1 -0
  157. package/dist/m/c-VKEDWYDF.js +1 -0
  158. package/dist/m/c-VL52ADDR.js +1 -0
  159. package/dist/m/c-WN5AY3OZ.js +1 -0
  160. package/dist/m/c-WNYBLIOZ.js +1 -0
  161. package/dist/m/c-WRBKEJD4.js +1 -0
  162. package/dist/m/c-WWDBYXLK.js +1 -0
  163. package/dist/m/c-WYFDLITL.js +1 -0
  164. package/dist/m/c-XN6MBKI6.js +67 -0
  165. package/dist/m/c-XNNW2CWK.js +1 -0
  166. package/dist/m/c-XPELB6E5.js +1 -0
  167. package/dist/m/c-XQXZAO7N.js +1 -0
  168. package/dist/m/c-Y6USGTS5.js +5 -0
  169. package/dist/m/c-YDH7Q3NY.js +1 -0
  170. package/dist/m/c-YG2NJYS6.js +135 -0
  171. package/dist/m/c-Z36J63PP.js +1 -0
  172. package/dist/m/c-Z4VRC7GU.js +7 -0
  173. package/dist/m/c-Z6K52OLP.js +19 -0
  174. package/dist/m/c-ZDY2MDAA.js +21 -0
  175. package/dist/m/c-ZE46QDIH.js +1 -0
  176. package/dist/m/c-ZUCOKOHT.js +1 -0
  177. package/dist/m/core/admin-attrs-VGNLAUDK.js +1 -0
  178. package/dist/m/core/autosave-E4PEFPZ6.js +1 -0
  179. package/dist/m/core/conflict-notice-VQ6Y64PH.js +1 -0
  180. package/dist/m/core/draft-mode-WSQAT67S.js +1 -0
  181. package/dist/m/core/host-permission-XN3K2IW3.js +1 -0
  182. package/dist/m/core/is-edit-mode-JXHDVGUL.js +1 -0
  183. package/dist/m/core/persist-HKHA66IY.js +3 -0
  184. package/dist/m/core/recovery-TBBSICE2.js +1 -0
  185. package/dist/m/core/save-WUCHTQBE.js +1 -0
  186. package/dist/m/core/save-core-FJVHT5M3.js +1 -0
  187. package/dist/m/core/snapshot-F3SWDZMM.js +1 -0
  188. package/dist/m/core/unsaved-warning-STKBHE6G.js +1 -0
  189. package/dist/m/dom/all-APS5ZSKP.js +1 -0
  190. package/dist/m/dom/dom-helpers-L7OSR6S4.js +1 -0
  191. package/dist/m/events/index-23DPTUT4.js +1 -0
  192. package/dist/m/internals/index-WOVAP3RU.js +1 -0
  193. package/dist/m/lib/cache-bust-CGWT6ZJI.js +1 -0
  194. package/dist/m/lib/region-policy-SB2AWVG5.js +1 -0
  195. package/dist/m/loader-HXX6YNH5.js +1 -0
  196. package/dist/m/manifest-F22DEDAC.js +1 -0
  197. package/dist/m/manifest-edit-C3C7376B.js +1 -0
  198. package/dist/m/manifest.json +3491 -0
  199. package/dist/m/options/options-2LH76JQ3.js +1 -0
  200. package/dist/m/page/editor-XUTB2HB2.js +189 -0
  201. package/dist/m/plugins/ai-edit-ZQ4CGWIP.js +6 -0
  202. package/dist/m/plugins/bind-text-NX46N5UV.js +1 -0
  203. package/dist/m/plugins/cms-HP3LSTPN.js +2293 -0
  204. package/dist/m/plugins/demo-ZIBFAA3R.js +1 -0
  205. package/dist/m/plugins/derive-UAAA4V4S.js +1 -0
  206. package/dist/m/plugins/indicator-PV4YW2ID.js +1 -0
  207. package/dist/m/plugins/live-NUTTXSBS.js +1 -0
  208. package/dist/m/plugins/menu-HCKO3DSP.js +138 -0
  209. package/dist/m/plugins/message-LQ6EDH4V.js +1 -0
  210. package/dist/m/plugins/page-KSUH7G6J.js +2 -0
  211. package/dist/m/plugins/page-view-W73OW7WI.js +1 -0
  212. package/dist/m/plugins/people-AJJ32YCG.js +1 -0
  213. package/dist/m/plugins/quickcrop-QNY3PKLD.js +26 -0
  214. package/dist/m/plugins/quickcrop-QNY3PKLD.js.LEGAL.txt +7 -0
  215. package/dist/m/plugins/richclay-RC3L2F6X.js +517 -0
  216. package/dist/m/plugins/richclay-RC3L2F6X.js.LEGAL.txt +1 -0
  217. package/dist/m/plugins/sortable-YRMQX3ZU.js +1 -0
  218. package/dist/m/plugins/source-KHK5UUSK.js +1 -0
  219. package/dist/m/plugins/undo-OF2L3CXU.js +1 -0
  220. package/dist/m/plugins/unsent-HJFLQJ2O.js +1 -0
  221. package/dist/m/plugins/upgrade-ZNYODP5Y.js +1 -0
  222. package/dist/m/plugins/upload-XSGNILUY.js +1 -0
  223. package/dist/m/plugins/visitor-drafts-XK5GW55Q.js +21 -0
  224. package/dist/m/plugins/visitor-drafts-owner-KSSH75EV.js +1 -0
  225. package/dist/m/plugins/wire-ZWVWKF76.js +1 -0
  226. package/dist/m/reader-core-ILWLXVMP.js +68 -0
  227. package/dist/m/route/route-KOCZSEGN.js +1 -0
  228. package/dist/m/sync/live-sync-4AUVXVJU.js +1 -0
  229. package/dist/m/ui/index-EVHKMKBL.js +1 -0
  230. package/dist/m/utils/index-4TJCVLT7.js +1 -0
  231. package/dist/m/vendor/Sortable.vendor-A755ITLN.js +3 -0
  232. package/dist/m/vendor/Sortable.vendor-A755ITLN.js.LEGAL.txt +1 -0
  233. package/dist/m/vendor/sap-core.vendor-A7BMUYZT.js +6 -0
  234. package/dist/offline-manifest.json +3800 -0
  235. package/dist/page/themes/light-1.css +406 -0
  236. package/dist/server/core.cjs +23662 -22860
  237. package/dist/server/offline-runtime.cjs +4954 -0
  238. package/dist/server/offline-runtime.mjs +4923 -0
  239. package/dist/server/rooms.mjs +9 -0
  240. package/docs/guide.md +1078 -669
  241. package/entries/all.js +2 -0
  242. package/entries/clay-data.js +1 -1
  243. package/entries/clay-dom.js +2 -0
  244. package/entries/clay-events.js +2 -0
  245. package/entries/clay-internals.js +2 -0
  246. package/entries/clay-options.js +2 -0
  247. package/entries/clay-router.js +2 -0
  248. package/entries/clay-ui.js +2 -0
  249. package/entries/clay-utils.js +2 -0
  250. package/entries/clay.js +2 -0
  251. package/entries/sap.js +6 -6
  252. package/fonts/ibm-plex-mono-LICENSE +93 -0
  253. package/fonts/ibm-plex-mono-latin-300-normal.woff2 +0 -0
  254. package/fonts/ibm-plex-mono-latin-400-italic.woff2 +0 -0
  255. package/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  256. package/fonts/ibm-plex-mono-latin-500-normal.woff2 +0 -0
  257. package/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
  258. package/fonts/ibm-plex-sans-LICENSE +93 -0
  259. package/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
  260. package/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
  261. package/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
  262. package/fonts/ibm-plex.css +71 -0
  263. package/fonts/inter-LICENSE +93 -0
  264. package/fonts/inter-cyrillic-ext-wght-normal.woff2 +0 -0
  265. package/fonts/inter-cyrillic-wght-normal.woff2 +0 -0
  266. package/fonts/inter-greek-ext-wght-normal.woff2 +0 -0
  267. package/fonts/inter-greek-wght-normal.woff2 +0 -0
  268. package/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
  269. package/fonts/inter-latin-wght-normal.woff2 +0 -0
  270. package/fonts/inter-vietnamese-wght-normal.woff2 +0 -0
  271. package/fonts/inter.css +62 -0
  272. package/fonts/newsreader-LICENSE +93 -0
  273. package/fonts/newsreader-latin-ext-opsz-normal.woff2 +0 -0
  274. package/fonts/newsreader-latin-opsz-normal.woff2 +0 -0
  275. package/fonts/newsreader-vietnamese-opsz-normal.woff2 +0 -0
  276. package/fonts/newsreader.css +26 -0
  277. package/fonts/work-sans-LICENSE +93 -0
  278. package/fonts/work-sans-latin-wght-normal.woff2 +0 -0
  279. package/fonts/work-sans.css +8 -0
  280. package/package.json +20 -3
  281. package/packed-contract.json +1 -0
  282. package/src/attrs/add-from.js +27 -4
  283. package/src/attrs/save-freeze.js +7 -52
  284. package/src/core/admin-attrs.js +119 -12
  285. package/src/core/admin-contenteditable.js +12 -10
  286. package/src/core/admin-inputs.js +14 -15
  287. package/src/core/admin-onclick.js +2 -0
  288. package/src/core/autosave.js +74 -21
  289. package/src/core/conflict-download.js +22 -0
  290. package/src/core/conflict-notice-ui.js +1173 -0
  291. package/src/core/conflict-notice.js +140 -697
  292. package/src/core/edit-mode.js +147 -14
  293. package/src/core/etag.js +30 -12
  294. package/src/core/host-meta.js +72 -8
  295. package/src/core/host-permission.js +29 -0
  296. package/src/core/is-edit-mode.js +145 -12
  297. package/src/core/mode-key.js +125 -0
  298. package/src/core/mode-lifecycle.js +544 -0
  299. package/src/core/mode-receipt.js +30 -0
  300. package/src/core/mode-refusal.js +13 -0
  301. package/src/core/mode-resources.js +52 -0
  302. package/src/core/mode-support.js +82 -0
  303. package/src/core/mode-switch.js +259 -0
  304. package/src/core/mode-transition.js +112 -0
  305. package/src/core/page-data-write.js +305 -0
  306. package/src/core/page-data.js +26 -227
  307. package/src/core/page-format-wire.js +4 -0
  308. package/src/core/page-format.js +58 -0
  309. package/src/core/persist.js +37 -9
  310. package/src/core/preserve-authored.js +114 -0
  311. package/src/core/recovery.js +772 -0
  312. package/src/core/runtime-url.js +105 -0
  313. package/src/core/save-core.js +109 -12
  314. package/src/core/save-replace.js +72 -0
  315. package/src/core/save-size-notice.js +134 -0
  316. package/src/core/save-size.js +140 -0
  317. package/src/core/save.js +805 -118
  318. package/src/core/snapshot.js +121 -11
  319. package/src/core/source-map.js +157 -9
  320. package/src/core/unsaved-warning.js +14 -4
  321. package/src/core/upgrade-run.js +408 -0
  322. package/src/core/version.js +18 -0
  323. package/src/lib/assets.js +30 -0
  324. package/src/lib/autosave-debug-gate.js +50 -0
  325. package/src/lib/autosave-scheduler.js +141 -0
  326. package/src/lib/boot-imports.js +8 -0
  327. package/src/lib/derived.js +3 -1
  328. package/src/lib/dirty-gate.js +15 -0
  329. package/src/lib/doc-storage.js +33 -0
  330. package/src/lib/effect.js +9 -4
  331. package/src/lib/mutation.js +4 -2
  332. package/src/lib/offline-runtime.js +226 -0
  333. package/src/lib/preload.js +48 -0
  334. package/src/lib/root-attrs.js +1 -1
  335. package/src/lib/trash.js +18 -0
  336. package/src/lib/undo/capture-move.js +152 -0
  337. package/src/live/local-channel.js +61 -0
  338. package/src/live/local-lane.js +60 -9
  339. package/src/live/server-lane.js +6 -3
  340. package/src/loader-logic.js +76 -15
  341. package/src/loader.js +218 -30
  342. package/src/page/adopt-boot.js +76 -22
  343. package/src/page/adopt.js +25 -4
  344. package/src/page/awareness.js +230 -0
  345. package/src/page/blocks.js +79 -5
  346. package/src/page/blocksel.js +20 -4
  347. package/src/page/board-face.js +13 -0
  348. package/src/page/board-panel.js +5 -17
  349. package/src/page/board-style.js +2 -13
  350. package/src/page/board-view.js +1 -11
  351. package/src/page/board-views.js +17 -0
  352. package/src/page/board.js +2 -2
  353. package/src/page/boot-pack.js +26 -0
  354. package/src/page/boot.js +237 -0
  355. package/src/page/checklist.js +1 -1
  356. package/src/page/chrome.js +411 -61
  357. package/src/page/csv-import.js +17 -2
  358. package/src/page/document-title-dom.js +40 -0
  359. package/src/page/document-title-runtime.js +76 -0
  360. package/src/page/document-title.js +9 -0
  361. package/src/page/drag.js +48 -13
  362. package/src/page/drop.js +2 -1
  363. package/src/page/editor.js +330 -86
  364. package/src/page/feature-loader.js +72 -0
  365. package/src/page/features/board.js +12 -0
  366. package/src/page/features/code.js +13 -0
  367. package/src/page/features/media.js +290 -0
  368. package/src/page/features/registry.js +23 -0
  369. package/src/page/features/table.js +383 -0
  370. package/src/page/{tool-view.js → features/tool.js} +33 -2
  371. package/src/page/format-codec.js +215 -0
  372. package/src/page/format-gate.js +179 -0
  373. package/src/page/format-level.js +157 -0
  374. package/src/page/highlight-slot.js +23 -0
  375. package/src/page/highlight.js +30 -16
  376. package/src/page/history-intent.js +78 -0
  377. package/src/page/inline.js +18 -25
  378. package/src/page/items.js +52 -11
  379. package/src/page/link.js +1 -0
  380. package/src/page/markdown.js +86 -1
  381. package/src/page/media-views.js +3 -0
  382. package/src/page/media.js +33 -245
  383. package/src/page/outline-cache.js +11 -0
  384. package/src/page/placeholder.js +27 -7
  385. package/src/page/projection.js +196 -50
  386. package/src/page/reader-patch.js +306 -0
  387. package/src/page/recover.js +1 -1
  388. package/src/page/rich/page-tool.js +1 -4
  389. package/src/page/runtime-owner.js +27 -0
  390. package/src/page/save-projection.js +7 -4
  391. package/src/page/schema.js +14 -0
  392. package/src/page/table-rect-key.js +3 -0
  393. package/src/page/table-select.js +4 -3
  394. package/src/page/table-style.js +1 -1
  395. package/src/page/table-views.js +3 -0
  396. package/src/page/table.js +8 -293
  397. package/src/page/themes/light-1.css +139 -2
  398. package/src/page/themes/light-1.source.css +269 -0
  399. package/src/page/tool-capability.js +3 -0
  400. package/src/page/tool-views.js +3 -0
  401. package/src/page/view.js +390 -107
  402. package/src/page/ybind/awareness.js +172 -0
  403. package/src/page/ybind/binding.js +9 -1
  404. package/src/page/ybind/bridge.js +50 -47
  405. package/src/page/ybind/decode.js +52 -19
  406. package/src/page/ybind/doc.js +27 -2
  407. package/src/page/ybind/group.js +12 -3
  408. package/src/page/ybind/index.js +2 -0
  409. package/src/page/ybind/lineage.js +71 -0
  410. package/src/page/ybind/marks.js +25 -1
  411. package/src/page/ybind/migrate.js +48 -13
  412. package/src/page/ybind/moves.js +32 -21
  413. package/src/page/ybind/positions.js +50 -0
  414. package/src/page/ybind/provider.js +84 -22
  415. package/src/page/ybind/recovery-proof.js +191 -0
  416. package/src/page/ybind/recovery-replay.js +130 -0
  417. package/src/page/ybind/tokens.js +15 -6
  418. package/src/page/ybind/walk.js +10 -3
  419. package/src/page/ybind/writer.js +48 -4
  420. package/src/plugins/ai-edit.js +167 -32
  421. package/src/plugins/bind-text.js +218 -0
  422. package/src/plugins/cms.js +93 -0
  423. package/src/plugins/indicator.js +57 -5
  424. package/src/plugins/live.js +282 -34
  425. package/src/plugins/menu/claygoo.svg.js +1 -0
  426. package/src/plugins/menu/seo-head.js +323 -0
  427. package/src/plugins/menu/seo.js +849 -0
  428. package/src/plugins/menu.js +425 -0
  429. package/src/plugins/page-view.js +131 -0
  430. package/src/plugins/page.js +1022 -275
  431. package/src/plugins/people.js +158 -31
  432. package/src/plugins/richclay.js +119 -9
  433. package/src/plugins/sortable.js +370 -60
  434. package/src/plugins/source.js +189 -366
  435. package/src/plugins/undo.js +289 -19
  436. package/src/plugins/unsent.js +132 -0
  437. package/src/plugins/upgrade-run.js +1 -0
  438. package/src/plugins/upgrade.js +210 -0
  439. package/src/plugins/upload-task.js +571 -0
  440. package/src/plugins/upload-ui.js +265 -0
  441. package/src/plugins/upload.js +34 -153
  442. package/src/plugins/visitor-drafts/inert.js +32 -0
  443. package/src/plugins/visitor-drafts/owner-chip.js +3 -0
  444. package/src/plugins/visitor-drafts/prompt.js +2 -2
  445. package/src/plugins/visitor-drafts-owner.js +85 -0
  446. package/src/plugins/visitor-drafts.js +31 -42
  447. package/src/plugins/wire.js +82 -1
  448. package/src/reader-core.js +26 -0
  449. package/src/recovery/conflicts.js +287 -0
  450. package/src/recovery/identity.js +154 -0
  451. package/src/recovery/store.js +792 -0
  452. package/src/recovery/undo.js +257 -0
  453. package/src/server/checkpoint/index.js +68 -4
  454. package/src/server/offline-runtime/index.js +214 -0
  455. package/src/server/rooms/index.js +2 -1
  456. package/src/server/rooms/live-data-rooms.js +2 -2
  457. package/src/server/rooms/page-admission.js +33 -0
  458. package/src/server/rooms/page-lineage.js +56 -0
  459. package/src/server/rooms/page-rebase.js +11 -5
  460. package/src/server/rooms/page-state.js +2 -0
  461. package/src/server/rooms/page-write-admission.js +9 -3
  462. package/src/source/session.js +705 -0
  463. package/src/sync/conflict-revert.js +5 -4
  464. package/src/sync/conflicts-edit.js +119 -0
  465. package/src/sync/conflicts-facade.js +49 -0
  466. package/src/sync/conflicts.js +99 -1
  467. package/src/sync/editing-marker.js +37 -6
  468. package/src/sync/editing-sender.js +8 -1
  469. package/src/sync/live-sync-edit.js +63 -0
  470. package/src/sync/live-sync.js +364 -119
  471. package/src/sync/local-presence.js +187 -0
  472. package/src/sync/merge-declarations.js +10 -0
  473. package/src/sync/merge-engine.js +12 -0
  474. package/src/sync/presence-store.js +412 -0
  475. package/src/sync/presence-target.js +243 -0
  476. package/src/sync/presence.js +72 -41
  477. package/src/sync/saved-handoff.js +200 -0
  478. package/src/sync/saved-stream.js +535 -0
  479. package/src/sync/version-guard.js +92 -0
  480. package/src/sync/wire-profile.js +81 -0
  481. package/src/ui/bevel-controls.js +2 -8
  482. package/src/ui/page-scheme.js +7 -0
  483. package/src/ui/skins/cms.js +1 -1
  484. package/src/ui/theme-config.js +150 -0
  485. package/src/ui/theme.js +6 -138
  486. package/src/ui/toast-lazy.js +11 -0
  487. package/src/vendor/LICENSES-optional.md +253 -0
  488. package/src/vendor/highlight.vendor.js +3 -0
  489. package/src/vendor/hljs-bash.vendor.js +2 -0
  490. package/src/vendor/hljs-css.vendor.js +2 -0
  491. package/src/vendor/hljs-javascript.vendor.js +2 -0
  492. package/src/vendor/hljs-json.vendor.js +2 -0
  493. package/src/vendor/hljs-python.vendor.js +2 -0
  494. package/src/vendor/hljs-xml.vendor.js +2 -0
  495. package/src/vendor/hyper-html-api-data.vendor.js +1 -1
  496. package/src/vendor/hyper-html-api-upgrade.vendor.js +5 -0
  497. package/src/vendor/hyper-morph-identity.vendor.js +2 -0
  498. package/src/vendor/hyper-morph-json.vendor.js +3 -0
  499. package/src/vendor/hyper-morph.vendor.js +6 -6
  500. package/src/vendor/hyper-undo.vendor.js +1 -1
  501. package/src/vendor/hypercms.vendor.js +169 -84
  502. package/src/vendor/marked.vendor.js +68 -0
  503. package/src/vendor/overtype.vendor.js +994 -0
  504. package/src/vendor/richclay.vendor.js +17 -17
  505. package/src/vendor/sap-core.vendor.js +5 -5
  506. package/src/vendor/sap-ownership.vendor.js +11 -7
@@ -0,0 +1,28 @@
1
+ var wa=Object.defineProperty,ft=(e,t)=>{for(var n in t)wa(e,n,{get:t[n],enumerable:!0})},pt={};ft(pt,{ContentMatch:()=>re,DOMParser:()=>Eo,DOMSerializer:()=>Le,Fragment:()=>v,Mark:()=>E,MarkType:()=>Do,Node:()=>Et,NodeRange:()=>Ps,NodeType:()=>ao,ReplaceError:()=>se,ResolvedPos:()=>io,Schema:()=>Ba,Slice:()=>k});function L(e){this.content=e}L.prototype={constructor:L,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 o=n&&n!=e?this.remove(n):this,i=o.find(e),s=o.content.slice();return i==-1?s.push(n||e,t):(s[i+1]=t,n&&(s[i]=n)),new L(s)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new L(n)},addToStart:function(e,t){return new L([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new L(n)},addBefore:function(e,t,n){var o=this.remove(t),i=o.content.slice(),s=o.find(e);return i.splice(s==-1?i.length:s,0,t,n),new L(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=L.from(e),e.size?new L(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=L.from(e),e.size?new L(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=L.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}};L.from=function(e){if(e instanceof L)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new L(t)};var xi=L;function Cs(e,t,n){for(let o=0;;o++){if(o==e.childCount||o==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(o),s=t.child(o);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){let r=i.text,l=s.text,a=0;for(;r[a]==l[a];a++)n++;return a&&a<r.length&&a<l.length&&Ds(r.charCodeAt(a-1))&&As(r.charCodeAt(a))&&n--,n}if(i.content.size||s.content.size){let r=Cs(i.content,s.content,n+1);if(r!=null)return r}n+=i.nodeSize}}function Ns(e,t,n,o){for(let i=e.childCount,s=t.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:o};let r=e.child(--i),l=t.child(--s),a=r.nodeSize;if(r==l){n-=a,o-=a;continue}if(!r.sameMarkup(l))return{a:n,b:o};if(r.isText&&r.text!=l.text){let c=r.text,h=l.text,d=c.length,p=h.length;for(;d>0&&p>0&&c[d-1]==h[p-1];)d--,p--,n--,o--;return d&&p&&d<c.length&&Ds(c.charCodeAt(d-1))&&As(c.charCodeAt(d))&&(n++,o++),{a:n,b:o}}if(r.content.size||l.content.size){let c=Ns(r.content,l.content,n-1,o-1);if(c)return c}n-=a,o-=a}}function As(e){return e>=56320&&e<57344}function Ds(e){return e>=55296&&e<56320}var v=class U{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let o=0;o<t.length;o++)this.size+=t[o].nodeSize}nodesBetween(t,n,o,i=0,s){for(let r=0,l=0;l<n;r++){let a=this.content[r],c=l+a.nodeSize;if(c>t&&o(a,i+l,s||null,r)!==!1&&a.content.size){let h=l+1;a.nodesBetween(Math.max(0,t-h),Math.min(a.content.size,n-h),o,i+h)}l=c}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,o,i){let s="",r=!0;return this.nodesBetween(t,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(t,a)-a,n-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&o&&(r?r=!1:s+=o),s+=c},0),s}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,o=t.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(o)&&(i[i.length-1]=n.withText(n.text+o.text),s=1);s<t.content.length;s++)i.push(t.content[s]);return new U(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let o=[],i=0;if(n>t)for(let s=0,r=0;r<n;s++){let l=this.content[s],a=r+l.nodeSize;a>t&&((r<t||a>n)&&(l.isText?l=l.cut(Math.max(0,t-r),Math.min(l.text.length,n-r)):l=l.cut(Math.max(0,t-r-1),Math.min(l.content.size,n-r-1))),o.push(l),i+=l.nodeSize),r=a}return new U(o,i)}cutByIndex(t,n){return t==n?U.empty:t==0&&n==this.content.length?this:new U(this.content.slice(t,n))}replaceChild(t,n){let o=this.content[t];if(o==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-o.nodeSize;return i[t]=n,new U(i,s)}addToStart(t){return new U([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new U(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,o=0;n<this.content.length;n++){let i=this.content[n];t(i,o,n),o+=i.nodeSize}}findDiffStart(t,n=0){return Cs(this,t,n)}findDiffEnd(t,n=this.size,o=t.size){return Ns(this,t,n,o)}findIndex(t){if(t==0)return ln(0,t);if(t==this.size)return ln(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,o=0;;n++){let i=this.child(n),s=o+i.nodeSize;if(s>=t)return s==t?ln(n+1,s):ln(n,o);o=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return U.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return U.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return U.empty;let n,o=0;for(let i=0;i<t.length;i++){let s=t[i];o+=s.nodeSize,i&&s.isText&&t[i-1].sameMarkup(s)?(n||(n=t.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new U(n||t,o)}static from(t){if(!t)return U.empty;if(t instanceof U)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new U([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};v.empty=new v([],0);var Jn={index:0,offset:0};function ln(e,t){return Jn.index=e,Jn.offset=t,Jn}function bn(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 o=0;o<e.length;o++)if(!bn(e[o],t[o]))return!1}else{for(let o in e)if(!(o in t)||!bn(e[o],t[o]))return!1;for(let o in t)if(!(o in e))return!1}return!0}var E=class no{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,o=!1;for(let i=0;i<t.length;i++){let s=t[i];if(this.eq(s))return t;if(this.type.excludes(s.type))n||(n=t.slice(0,i));else{if(s.type.excludes(this.type))return t;!o&&s.type.rank>this.type.rank&&(n||(n=t.slice(0,i)),n.push(this),o=!0),n&&n.push(s)}}return n||(n=t.slice()),o||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&bn(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let o=t.marks[n.type];if(!o)throw new RangeError(`There is no mark type ${n.type} in this schema`);return o.create(n.attrs)}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let o=0;o<t.length;o++)if(!t[o].eq(n[o]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return no.none;if(t instanceof no)return[t];let n=t.slice();return n.sort((o,i)=>o.type.rank-i.type.rank),n}};E.none=[];var se=class extends Error{},k=class _t{constructor(t,n,o){this.content=t,this.openStart=n,this.openEnd=o}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let o=Ts(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return o&&new _t(o,this.openStart,this.openEnd)}removeBetween(t,n){return new _t(Es(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return _t.empty;let o=n.openStart||0,i=n.openEnd||0;if(typeof o!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new _t(v.fromJSON(t,n.content),o,i)}static maxOpen(t,n=!0){let o=0,i=0;for(let s=t.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)o++;for(let s=t.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new _t(t,o,i)}};k.empty=new k(v.empty,0,0);function Es(e,t,n){let{index:o,offset:i}=e.findIndex(t),s=e.maybeChild(o),{index:r,offset:l}=e.findIndex(n);if(i==t||s.isText){if(l!=n&&!e.child(r).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(o!=r)throw new RangeError("Removing non-flat range");return e.replaceChild(o,s.copy(Es(s.content,t-i-1,n-i-1)))}function Ts(e,t,n,o,i,s){let{index:r,offset:l}=e.findIndex(t),a=e.maybeChild(r);if(l==t||a.isText)return s&&o<=0&&i<=0&&!s.canReplace(r,r,n)?null:e.cut(0,t).append(n).append(e.cut(t));let c=Ts(a.content,t-l-1,n,r==0?o-1:0,r==e.childCount-1?i-1:0,a);return c&&e.replaceChild(r,a.copy(c))}function ba(e,t,n){if(n.openStart>e.depth)throw new se("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new se("Inconsistent open depths");return $s(e,t,n,0)}function $s(e,t,n,o){let i=e.index(o),s=e.node(o);if(i==t.index(o)&&o<e.depth-n.openStart){let r=$s(e,t,n,o+1);return s.copy(s.content.replaceChild(i,r))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&e.depth==o&&t.depth==o){let r=e.parent,l=r.content;return Lt(r,l.cut(0,e.parentOffset).append(n.content).append(l.cut(t.parentOffset)))}else{let{start:r,end:l}=va(n,e);return Lt(s,Is(e,r,l,t,o))}else return Lt(s,vn(e,t,o))}function Rs(e,t){if(!t.type.compatibleContent(e.type))throw new se("Cannot join "+t.type.name+" onto "+e.type.name)}function oo(e,t,n){let o=e.node(n);return Rs(o,t.node(n)),o}function jt(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 Ne(e,t,n,o){let i=(t||e).node(n),s=0,r=t?t.index(n):i.childCount;e&&(s=e.index(n),e.depth>n?s++:e.textOffset&&(jt(e.nodeAfter,o),s++));for(let l=s;l<r;l++)jt(i.child(l),o);t&&t.depth==n&&t.textOffset&&jt(t.nodeBefore,o)}function Lt(e,t){if(!e.type.validContent(t))throw new se("Invalid content for node "+e.type.name);return e.copy(t)}function Is(e,t,n,o,i){let s=e.depth>i&&oo(e,t,i+1),r=o.depth>i&&oo(n,o,i+1),l=[];return Ne(null,e,i,l),s&&r&&t.index(i)==n.index(i)?(Rs(s,r),jt(Lt(s,Is(e,t,n,o,i+1)),l)):(s&&jt(Lt(s,vn(e,t,i+1)),l),Ne(t,n,i,l),r&&jt(Lt(r,vn(n,o,i+1)),l)),Ne(o,null,i,l),new v(l)}function vn(e,t,n){let o=[];if(Ne(null,e,n,o),e.depth>n){let i=oo(e,t,n+1);jt(Lt(i,vn(e,t,n+1)),o)}return Ne(t,null,n,o),new v(o)}function va(e,t){let n=t.depth-e.openStart,o=t.node(n).copy(e.content);for(let i=n-1;i>=0;i--)o=t.node(i).copy(v.from(o));return{start:o.resolveNoCache(e.openStart+n),end:o.resolveNoCache(o.content.size-e.openEnd-n)}}var io=class so{constructor(t,n,o){this.pos=t,this.path=n,this.parentOffset=o,this.depth=n.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,n=this.index(this.depth);if(n==t.childCount)return null;let o=this.pos-this.path[this.path.length-1],i=t.child(n);return o?t.child(n).cut(o):i}get nodeBefore(){let t=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(t).cut(0,n):t==0?null:this.parent.child(t-1)}posAtIndex(t,n){n=this.resolveDepth(n);let o=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<t;s++)i+=o.child(s).nodeSize;return i}marks(){let t=this.parent,n=this.index();if(t.content.size==0)return E.none;if(this.textOffset)return t.child(n).marks;let o=t.maybeChild(n-1),i=t.maybeChild(n);if(!o){let l=o;o=i,i=l}let s=o.marks;for(var r=0;r<s.length;r++)s[r].type.spec.inclusive===!1&&(!i||!s[r].isInSet(i.marks))&&(s=s[r--].removeFromSet(s));return s}marksAcross(t){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let o=n.marks,i=t.parent.maybeChild(t.index());for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}sharedDepth(t){for(let n=this.depth;n>0;n--)if(this.start(n)<=t&&this.end(n)>=t)return n;return 0}blockRange(t=this,n){if(t.pos<this.pos)return t.blockRange(this);for(let o=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);o>=0;o--)if(t.pos<=this.end(o)&&(!n||n(this.node(o))))return new Ps(this,t,o);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let n=1;n<=this.depth;n++)t+=(t?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return t+":"+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");let o=[],i=0,s=n;for(let r=t;;){let{index:l,offset:a}=r.content.findIndex(s),c=s-a;if(o.push(r,l,i+a),!c||(r=r.child(l),r.isText))break;s=c-1,i+=a+1}return new so(n,o,s)}static resolveCached(t,n){let o=Si.get(t);if(o)for(let s=0;s<o.elts.length;s++){let r=o.elts[s];if(r.pos==n)return r}else Si.set(t,o=new ka);let i=o.elts[o.i]=so.resolve(t,n);return o.i=(o.i+1)%xa,i}},ka=class{constructor(){this.elts=[],this.i=0}},xa=12,Si=new WeakMap,Ps=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)}},Sa=Object.create(null),Et=class ro{constructor(t,n,o,i=E.none){this.type=t,this.attrs=n,this.marks=i,this.content=o||v.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,n,o,i=0){this.content.nodesBetween(t,n,o,i,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,n,o,i){return this.content.textBetween(t,n,o,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,n,o){return this.type==t&&bn(this.attrs,n||t.defaultAttrs||Sa)&&E.sameSet(this.marks,o||E.none)}copy(t=null){return t==this.content?this:new ro(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new ro(this.type,this.attrs,this.content,t)}cut(t,n=this.content.size){return t==0&&n==this.content.size?this:this.copy(this.content.cut(t,n))}slice(t,n=this.content.size,o=!1){if(t==n)return k.empty;let i=this.resolve(t),s=this.resolve(n),r=o?0:i.sharedDepth(n),l=i.start(r),a=i.node(r).content.cut(i.pos-l,s.pos-l);return new k(a,i.depth-r,s.depth-r)}replace(t,n,o){return ba(this.resolve(t),this.resolve(n),o)}nodeAt(t){for(let n=this;;){let{index:o,offset:i}=n.content.findIndex(t);if(n=n.maybeChild(o),!n)return null;if(i==t||n.isText)return n;t-=i+1}}childAfter(t){let{index:n,offset:o}=this.content.findIndex(t);return{node:this.content.maybeChild(n),index:n,offset:o}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:n,offset:o}=this.content.findIndex(t);if(o<t)return{node:this.content.child(n),index:n,offset:o};let i=this.content.child(n-1);return{node:i,index:n-1,offset:o-i.nodeSize}}resolve(t){return io.resolveCached(this,t)}resolveNoCache(t){return io.resolve(this,t)}rangeHasMark(t,n,o){let i=!1;return n>t&&this.nodesBetween(t,n,s=>(o.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),Bs(this.marks,t)}contentMatchAt(t){let n=this.type.contentMatch.matchFragment(this.content,0,t);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(t,n,o=v.empty,i=0,s=o.childCount){let r=this.contentMatchAt(t).matchFragment(o,i,s),l=r&&r.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(o.child(a).marks))return!1;return!0}canReplaceWith(t,n,o,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(t).matchType(o),r=s&&s.matchFragment(this.content,n);return r?r.validEnd:!1}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),Oi(this.type.attrs,this.attrs,"node",this.type.name);let t=E.none;for(let n=0;n<this.marks.length;n++){let o=this.marks[n];Oi(o.type.attrs,o.attrs,"mark",o.type.name),t=o.addToSet(t)}if(!E.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(n=>n.toJSON())),t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let o;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");o=n.marks.map(t.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(n.text,o)}let i=v.fromJSON(t,n.content);return t.nodeType(n.type).create(n.attrs,i,o)}};Et.prototype.text=void 0;var Oa=class lo extends Et{constructor(t,n,o,i){if(super(t,n,null,i),!o)throw new RangeError("Empty text nodes are not allowed");this.text=o}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Bs(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,n){return this.text.slice(t,n)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new lo(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new lo(this.type,this.attrs,t,this.marks)}cut(t=0,n=this.text.length){return t==0&&n==this.text.length?this:this.withText(this.text.slice(t,n))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}};function Bs(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}function Oi(e,t,n,o){for(let i in t)if(!(i in e))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${o}`);for(let i in e)e[i].validate&&e[i].validate(t[i])}var re=class zs{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,n){let o=new Ma(t,n);if(o.next==null)return zs.empty;let i=Fs(o);o.next&&o.err("Unexpected trailing text");let s=$a(Ta(i));return Ra(s,o),s}matchType(t){for(let n=0;n<this.next.length;n++)if(this.next[n].type==t)return this.next[n].next;return null}matchFragment(t,n=0,o=t.childCount){let i=this;for(let s=n;i&&s<o;s++)i=i.matchType(t.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:n}=this.next[t];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(t){for(let n=0;n<this.next.length;n++)for(let o=0;o<t.next.length;o++)if(this.next[n].type==t.next[o].type)return!0;return!1}fillBefore(t,n=!1,o=0){let i=[this];function s(r,l){let a=r.matchFragment(t,o);if(a&&(!n||a.validEnd))return v.from(l.map(c=>c.createAndFill()));for(let c=0;c<r.next.length;c++){let{type:h,next:d}=r.next[c];if(!(h.isText||h.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let p=s(d,l.concat(h));if(p)return p}}return null}return s(this,[])}findWrapping(t){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==t)return this.wrapCache[o+1];let n=this.computeWrapping(t);return this.wrapCache.push(t,n),n}computeWrapping(t){let n=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let i=o.shift(),s=i.match;if(s.matchType(t)){let r=[];for(let l=i;l.type;l=l.via)r.push(l.type);return r.reverse()}for(let r=0;r<s.next.length;r++){let{type:l,next:a}=s.next[r];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||a.validEnd)&&(o.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function n(o){t.push(o);for(let i=0;i<o.next.length;i++)t.indexOf(o.next[i].next)==-1&&n(o.next[i].next)}return n(this),t.map((o,i)=>{let s=i+(o.validEnd?"*":" ")+" ";for(let r=0;r<o.next.length;r++)s+=(r?", ":"")+o.next[r].type.name+"->"+t.indexOf(o.next[r].next);return s}).join(`
2
+ `)}};re.empty=new re(!0);var Ma=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 new SyntaxError(e+" (in content expression '"+this.string+"')")}};function Fs(e){let t=[];do t.push(Ca(e));while(e.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function Ca(e){let t=[];do t.push(Na(e));while(e.next&&e.next!=")"&&e.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function Na(e){let t=Ea(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=Aa(e,t);else break;return t}function Mi(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function Aa(e,t){let n=Mi(e),o=n;return e.eat(",")&&(e.next!="}"?o=Mi(e):o=-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:o,expr:t}}function Da(e,t){let n=e.nodeTypes,o=n[t];if(o)return[o];let i=[];for(let s in n){let r=n[s];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err("No node type or group '"+t+"' found"),i}function Ea(e){if(e.eat("(")){let t=Fs(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=Da(e,e.next).map(n=>(e.inline==null?e.inline=n.isInline:e.inline!=n.isInline&&e.err("Mixing inline and block content"),{type:"name",value:n}));return e.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}function Ta(e){let t=[[]];return i(s(e,0),n()),t;function n(){return t.push([])-1}function o(r,l,a){let c={term:a,to:l};return t[r].push(c),c}function i(r,l){r.forEach(a=>a.to=l)}function s(r,l){if(r.type=="choice")return r.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(r.type=="seq")for(let a=0;;a++){let c=s(r.exprs[a],l);if(a==r.exprs.length-1)return c;i(c,l=n())}else if(r.type=="star"){let a=n();return o(l,a),i(s(r.expr,a),a),[o(a)]}else if(r.type=="plus"){let a=n();return i(s(r.expr,l),a),i(s(r.expr,a),a),[o(a)]}else{if(r.type=="opt")return[o(l)].concat(s(r.expr,l));if(r.type=="range"){let a=l;for(let c=0;c<r.min;c++){let h=n();i(s(r.expr,a),h),a=h}if(r.max==-1)i(s(r.expr,a),a);else for(let c=r.min;c<r.max;c++){let h=n();o(a,h),i(s(r.expr,a),h),a=h}return[o(a)]}else{if(r.type=="name")return[o(l,void 0,r.value)];throw new Error("Unknown expr type")}}}}function Vs(e,t){return t-e}function Ci(e,t){let n=[];return o(t),n.sort(Vs);function o(i){let s=e[i];if(s.length==1&&!s[0].term)return o(s[0].to);n.push(i);for(let r=0;r<s.length;r++){let{term:l,to:a}=s[r];!l&&n.indexOf(a)==-1&&o(a)}}}function $a(e){let t=Object.create(null);return n(Ci(e,0));function n(o){let i=[];o.forEach(r=>{e[r].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let h=0;h<i.length;h++)i[h][0]==l&&(c=i[h][1]);Ci(e,a).forEach(h=>{c||i.push([l,c=[]]),c.indexOf(h)==-1&&c.push(h)})})});let s=t[o.join(",")]=new re(o.indexOf(e.length-1)>-1);for(let r=0;r<i.length;r++){let l=i[r][1].sort(Vs);s.next.push({type:i[r][0],next:t[l.join(",")]||n(l)})}return s}}function Ra(e,t){for(let n=0,o=[e];n<o.length;n++){let i=o[n],s=!i.validEnd,r=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];r.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),o.indexOf(c)==-1&&o.push(c)}s&&t.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function js(e){let t=Object.create(null);for(let n in e){let o=e[n];if(!o.hasDefault)return null;t[n]=o.default}return t}function Ls(e,t){let n=Object.create(null);for(let o in e){let i=e[o],s=t&&t[o];if(s===void 0)if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+o);else i.validate&&i.validate(s);n[o]=s}return n}function Js(e,t){let n=Object.create(null);if(t)for(let o in t)n[o]=new Pa(e,o,t[o]);return n}var ao=class qs{constructor(t,n,o){this.name=t,this.schema=n,this.spec=o,this.markSet=null,this.groups=o.group?o.group.split(" "):[],this.attrs=Js(t,o.attrs),this.defaultAttrs=js(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(o.inline||t=="text"),this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==re.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:Ls(this.attrs,t)}create(t=null,n,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Et(this,this.computeAttrs(t),v.from(n),E.setFrom(o))}createChecked(t=null,n,o){return n=v.from(n),this.checkContent(n),new Et(this,this.computeAttrs(t),n,E.setFrom(o))}createAndFill(t=null,n,o){if(t=this.computeAttrs(t),n=v.from(n),n.size){let r=this.contentMatch.fillBefore(n);if(!r)return null;n=r.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(v.empty,!0);return s?new Et(this,t,n.append(s),E.setFrom(o)):null}validContent(t){let n=this.contentMatch.matchFragment(t);if(!n||!n.validEnd)return!1;for(let o=0;o<t.childCount;o++)if(!this.allowsMarks(t.child(o).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return!0;for(let n=0;n<t.length;n++)if(!this.allowsMarkType(t[n].type))return!1;return!0}allowedMarks(t){if(this.markSet==null)return t;let n;for(let o=0;o<t.length;o++)this.allowsMarkType(t[o].type)?n&&n.push(t[o]):n||(n=t.slice(0,o));return n?n.length?n:E.none:t}static compile(t,n){let o=Object.create(null);t.forEach((s,r)=>o[s]=new qs(s,n,r));let i=n.spec.topNode||"doc";if(!o[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let s in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function Ia(e,t,n){let o=n.split("|");return i=>{let s=i===null?"null":typeof i;if(o.indexOf(s)<0)throw new RangeError(`Expected value of type ${o} for attribute ${t} on type ${e}, got ${s}`)}}var Pa=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Ia(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Do=class Ws{constructor(t,n,o,i){this.name=t,this.rank=n,this.schema=o,this.spec=i,this.attrs=Js(t,i.attrs),this.excluded=null;let s=js(this.attrs);this.instance=s?new E(this,s):null}create(t=null){return!t&&this.instance?this.instance:new E(this,Ls(this.attrs,t))}static compile(t,n){let o=Object.create(null),i=0;return t.forEach((s,r)=>o[s]=new Ws(s,i++,n,r)),o}removeFromSet(t){for(var n=0;n<t.length;n++)t[n].type==this&&(t=t.slice(0,n).concat(t.slice(n+1)),n--);return t}isInSet(t){for(let n=0;n<t.length;n++)if(t[n].type==this)return t[n]}excludes(t){return this.excluded.indexOf(t)>-1}},Ba=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=xi.from(e.nodes),t.marks=xi.from(e.marks||{}),this.nodes=ao.compile(this.spec.nodes,this),this.marks=Do.compile(this.spec.marks,this);let n=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",r=i.spec.marks;if(i.contentMatch=n[s]||(n[s]=re.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=r=="_"?null:r?Ni(this,r.split(" ")):r==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:Ni(this,s.split(" "))}this.nodeFromJSON=o=>Et.fromJSON(this,o),this.markFromJSON=o=>E.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ao){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,n,o)}text(e,t){let n=this.nodes.text;return new Oa(n,n.defaultAttrs,e,E.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 new RangeError("Unknown node type: "+e);return t}};function Ni(e,t){let n=[];for(let o=0;o<t.length;o++){let i=t[o],s=e.marks[i],r=s;if(s)n.push(s);else for(let l in e.marks){let a=e.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&n.push(r=a)}if(!r)throw new SyntaxError("Unknown mark type: '"+t[o]+"'")}return n}function za(e){return e.tag!=null}function Fa(e){return e.style!=null}var Eo=class co{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let o=this.matchedStyles=[];n.forEach(i=>{if(za(i))this.tags.push(i);else if(Fa(i)){let s=/[^=]*/.exec(i.style)[0];o.indexOf(s)<0&&o.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=t.nodes[i.node];return s.contentMatch.matchType(s)})}parse(t,n={}){let o=new Di(this,n,!1);return o.addAll(t,E.none,n.from,n.to),o.finish()}parseSlice(t,n={}){let o=new Di(this,n,!0);return o.addAll(t,E.none,n.from,n.to),k.maxOpen(o.finish())}matchTag(t,n,o){for(let i=o?this.tags.indexOf(o)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(La(t,s.tag)&&(s.namespace===void 0||t.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let r=s.getAttrs(t);if(r===!1)continue;s.attrs=r||void 0}return s}}}matchStyle(t,n,o,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let r=this.styles[s],l=r.style;if(!(l.indexOf(t)!=0||r.context&&!o.matchesContext(r.context)||l.length>t.length&&(l.charCodeAt(t.length)!=61||l.slice(t.length+1)!=n))){if(r.getAttrs){let a=r.getAttrs(n);if(a===!1)continue;r.attrs=a||void 0}return r}}}static schemaRules(t){let n=[];function o(i){let s=i.priority==null?50:i.priority,r=0;for(;r<n.length;r++){let l=n[r];if((l.priority==null?50:l.priority)<s)break}n.splice(r,0,i)}for(let i in t.marks){let s=t.marks[i].spec.parseDOM;s&&s.forEach(r=>{o(r=Ei(r)),r.mark||r.ignore||r.clearMark||(r.mark=i)})}for(let i in t.nodes){let s=t.nodes[i].spec.parseDOM;s&&s.forEach(r=>{o(r=Ei(r)),r.node||r.ignore||r.mark||(r.node=i)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new co(t,co.schemaRules(t)))}},Ks={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Va={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Hs={ol:!0,ul:!0},Ie=1,ho=2,Ae=4;function Ai(e,t,n){return t!=null?(t?Ie:0)|(t==="full"?ho:0):e&&e.whitespace=="pre"?Ie|ho:n&~Ae}var an=class{constructor(e,t,n,o,i,s){this.type=e,this.attrs=t,this.marks=n,this.solid=o,this.options=s,this.content=[],this.activeMarks=E.none,this.match=i||(s&Ae?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(v.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,o;return(o=n.findWrapping(e.type))?(this.match=n,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ie)){let n=this.content[this.content.length-1],o;if(n&&n.isText&&(o=/[ \t\r\n\u000c]+$/.exec(n.text))){let i=n;n.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let t=v.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(v.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&&!Ks.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Di=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let o=t.topNode,i,s=Ai(null,t.preserveWhitespace,0)|(n?Ae:0);o?i=new an(o.type,o.attrs,E.none,!0,t.topMatch||o.type.contentMatch,s):n?i=new an(null,null,E.none,!0,null,s):i=new an(e.schema.topNodeType,null,E.none,!0,null,s),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,o=this.top,i=o.options&ho?"full":this.localPreserveWS||(o.options&Ie)>0,{schema:s}=this.parser;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(i)if(i==="full")n=n.replace(/\r\n?/g,`
3
+ `);else if(s.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(s.linebreakReplacement.create())){let r=n.split(/\r?\n|\r/);for(let l=0;l<r.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),t,!0),r[l]&&this.insertNode(s.text(r[l]),t,!/\S/.test(r[l]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let r=o.content[o.content.length-1],l=e.previousSibling;(!r||l&&l.nodeName=="BR"||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(n=n.slice(1))}n&&this.insertNode(s.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),r;Hs.hasOwnProperty(s)&&this.parser.normalizeLists&&ja(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(r=this.parser.matchTag(e,this,n));t:if(l?l.ignore:Va.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let a,c=this.needsBlock;if(Ks.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),a=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break t}let h=l&&l.skip?t:this.readStyles(e,t);h&&this.addAll(e,h),a&&this.sync(i),this.needsBlock=c}else{let a=this.readStyles(e,t);a&&this.addElementByRule(e,l,a,l.consuming===!1?r:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=n.getPropertyValue(i);if(s)for(let r=void 0;;){let l=this.parser.matchStyle(i,s,this,r);if(!l)break;if(l.ignore)return null;if(l.clearMark?t=t.filter(a=>!l.clearMark(a)):t=t.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)r=l;else break}}return t}addElementByRule(e,t,n,o){let i,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let l=this.enter(s,t.attrs||null,n,t.preserveWhitespace);l&&(i=!0,n=l)}else{let l=this.parser.schema.marks[t.mark];n=n.concat(l.create(t.attrs))}let r=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,n,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,n,!1));else{let l=e;typeof t.contentElement=="string"?l=e.querySelector(t.contentElement):typeof t.contentElement=="function"?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,n),this.findAround(e,l,!1)}i&&this.sync(r)&&this.open--}addAll(e,t,n,o){let i=n||0;for(let s=n?e.childNodes[n]:e.firstChild,r=o==null?null:e.childNodes[o];s!=r;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,t);this.findAtPoint(e,i)}findPlace(e,t,n){let o,i;for(let s=this.open,r=0;s>=0;s--){let l=this.nodes[s],a=l.findWrapping(e);if(a&&(!o||o.length>a.length+r)&&(o=a,i=l,!a.length))break;if(l.solid){if(n)break;r+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)t=this.enterInner(o[s],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let o=this.findPlace(e,t,n);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=E.none;for(let r of o.concat(e.marks))(i.type?i.type.allowsMarkType(r.type):Ti(r.type,e.type))&&(s=r.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,t,n,o){let i=this.findPlace(e.create(t),n,!1);return i&&(i=this.enterInner(e,t,n,!0,o)),i}enterInner(e,t,n,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let r=Ai(e,i,s.options);s.options&Ae&&s.content.length==0&&(r|=Ae);let l=E.none;return n=n.filter(a=>(s.type?s.type.allowsMarkType(a.type):Ti(a.type,e))?(l=a.addToSet(l),!1):!0),this.nodes.push(new an(e,t,l,o,null,r)),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;this.localPreserveWS&&(this.nodes[t].options|=Ie)}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 o=n.length-1;o>=0;o--)e+=n[o].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 o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(n?2:4)&&(this.find[o].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,o=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+(o?0:1),s=(r,l)=>{for(;r>=0;r--){let a=t[r];if(a==""){if(r==t.length-1||r==0)continue;for(;l>=i;l--)if(s(r-1,l))return!0;return!1}else{let c=l>0||l==0&&o?this.nodes[l].type:n&&l>=i?n.node(l-i).type:null;if(!c||c.name!=a&&!c.isInGroup(a))return!1;l--}}return!0};return s(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 t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}};function ja(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let o=t.nodeType==1?t.nodeName.toLowerCase():null;o&&Hs.hasOwnProperty(o)&&n?(n.appendChild(t),t=n):o=="li"?n=t:o&&(n=null)}}function La(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Ei(e){let t={};for(let n in e)t[n]=e[n];return t}function Ti(e,t){let n=t.schema.nodes;for(let o in n){let i=n[o];if(!i.allowsMarkType(e))continue;let s=[],r=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:h}=l.edge(a);if(c==t||s.indexOf(h)<0&&r(h))return!0}};if(r(i.contentMatch))return!0}}var Le=class Us{constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},o){o||(o=cn(n).createDocumentFragment());let i=o,s=[];return t.forEach(r=>{if(s.length||r.marks.length){let l=0,a=0;for(;l<s.length&&a<r.marks.length;){let c=r.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<r.marks.length;){let c=r.marks[a++],h=this.serializeMark(c,r.isInline,n);h&&(s.push([c,i]),i.appendChild(h.dom),i=h.contentDOM||h.dom)}}i.appendChild(this.serializeNodeInner(r,n))}),o}serializeNodeInner(t,n){if(t.isText)return cn(n).createTextNode(t.text);let{dom:o,contentDOM:i}=pn(cn(n),this.nodes[t.type.name](t),null,t.attrs);if(i){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,i)}return o}serializeNode(t,n={}){let o=this.serializeNodeInner(t,n);for(let i=t.marks.length-1;i>=0;i--){let s=this.serializeMark(t.marks[i],t.isInline,n);s&&((s.contentDOM||s.dom).appendChild(o),o=s.dom)}return o}serializeMark(t,n,o={}){let i=this.marks[t.type.name];return i&&pn(cn(o),i(t,n),null,t.attrs)}static renderSpec(t,n,o=null,i){return typeof n=="string"?{dom:t.createTextNode(n)}:pn(t,n,o,i)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new Us(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=$i(t.nodes);return n.text||(n.text=o=>o.text),n}static marksFromSchema(t){return $i(t.marks)}};function $i(e){let t={};for(let n in e){let o=e[n].spec.toDOM;o&&(t[n]=o)}return t}function cn(e){return e.document||window.document}var Ri=new WeakMap;function Ja(e){let t=Ri.get(e);return t===void 0&&Ri.set(e,t=qa(e)),t}function qa(e){let t=null;function n(o){if(o&&typeof o=="object")if(Array.isArray(o))if(typeof o[0]=="string")t||(t=[]),t.push(o);else for(let i=0;i<o.length;i++)n(o[i]);else for(let i in o)n(o[i])}return n(e),t}function pn(e,t,n,o){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(s=Ja(o))&&s.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let r=i.indexOf(" ");r>0&&(n=i.slice(0,r),i=i.slice(r+1));let l,a=n?e.createElementNS(n,i):e.createElement(i),c=t[1],h=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){h=2;for(let d in c)if(c[d]!=null){let p=d.indexOf(" ");p>0?a.setAttributeNS(d.slice(0,p),d.slice(p+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=h;d<t.length;d++){let p=t[d];if(p===0){if(d<t.length-1||d>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof p=="string")a.appendChild(e.createTextNode(p));else{let{dom:u,contentDOM:f}=pn(e,p,n,o);if(a.appendChild(u),f){if(l)throw new RangeError("Multiple content holes");l=f}}}return{dom:a,contentDOM:l}}var To={};ft(To,{AllSelection:()=>at,EditorState:()=>uc,NodeSelection:()=>O,Plugin:()=>fe,PluginKey:()=>jo,Selection:()=>C,SelectionRange:()=>xn,TextSelection:()=>N,Transaction:()=>dr});var he={};ft(he,{AddMarkStep:()=>Nn,AddNodeMarkStep:()=>An,AttrStep:()=>Fo,DocAttrStep:()=>Vo,MapResult:()=>kn,Mapping:()=>$o,RemoveMarkStep:()=>de,RemoveNodeMarkStep:()=>Pe,ReplaceAroundStep:()=>ht,ReplaceStep:()=>ot,Step:()=>V,StepMap:()=>$t,StepResult:()=>W,Transform:()=>lr,TransformError:()=>Wt,canJoin:()=>Ut,canSplit:()=>De,dropPoint:()=>zo,findWrapping:()=>Po,insertPoint:()=>nr,joinPoint:()=>Bo,liftTarget:()=>Je,replaceStep:()=>qe});var Gs=65535,Ys=Math.pow(2,16);function Wa(e,t){return e+t*Ys}function Ii(e){return e&Gs}function Ka(e){return(e-(e&Gs))/Ys}var Qs=1,Zs=2,un=4,_s=8,kn=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&_s)>0}get deletedBefore(){return(this.delInfo&(Qs|un))>0}get deletedAfter(){return(this.delInfo&(Zs|un))>0}get deletedAcross(){return(this.delInfo&un)>0}},$t=class Xt{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&Xt.empty)return Xt.empty}recover(t){let n=0,o=Ii(t);if(!this.inverted)for(let i=0;i<o;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[o*3]+n+Ka(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,o){let i=0,s=this.inverted?2:1,r=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>t)break;let c=this.ranges[l+s],h=this.ranges[l+r],d=a+c;if(t<=d){let p=c?t==a?-1:t==d?1:n:n,u=a+i+(p<0?0:h);if(o)return u;let f=t==(n<0?a:d)?null:Wa(l/3,t-a),m=0;return c&&(m|=t==a?Zs:t==d?Qs:un,(n<0?t!=a:t!=d)&&(m|=_s)),new kn(u,m,f)}i+=h-c}return o?t+i:new kn(t+i,0,null)}touches(t,n){let o=0,i=Ii(n),s=this.inverted?2:1,r=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>t)break;let c=this.ranges[l+s],h=a+c;if(t<=h&&l==i*3)return!0;o+=this.ranges[l+r]-c}return!1}forEach(t){let n=this.inverted?2:1,o=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let r=this.ranges[i],l=r-(this.inverted?s:0),a=r+(this.inverted?0:s),c=this.ranges[i+n],h=this.ranges[i+o];t(l,l+c,a,a+h),s+=h-c}}invert(){return new Xt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Xt.empty:new Xt(t<0?[0,-t,0]:[0,0,t])}};$t.empty=new $t([]);var $o=class fo{constructor(t,n,o=0,i=t?t.length:0){this.mirror=n,this.from=o,this.to=i,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new fo(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,o=this._maps.length;n<t._maps.length;n++){let i=t.getMirror(n);this.appendMap(t._maps[n],i!=null&&i<n?o+i:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,o=this._maps.length+t._maps.length;n>=0;n--){let i=t.getMirror(n);this.appendMap(t._maps[n].invert(),i!=null&&i>n?o-i-1:void 0)}}invert(){let t=new fo;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let o=this.from;o<this.to;o++)t=this._maps[o].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,o){let i=0;for(let s=this.from;s<this.to;s++){let r=this._maps[s],l=r.mapResult(t,n);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,t=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,t=l.pos}return o?t:new kn(t,i,null)}},qn=Object.create(null),V=class{getMap(){return $t.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=qn[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in qn)throw new RangeError("Duplicate use of step JSON ID "+e);return qn[e]=t,t.prototype.jsonID=e,t}},W=class ge{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new ge(t,null)}static fail(t){return new ge(null,t)}static fromReplace(t,n,o,i){try{return ge.ok(t.replace(n,o,i))}catch(s){if(s instanceof se)return ge.fail(s.message);throw s}}};function Ro(e,t,n){let o=[];for(let i=0;i<e.childCount;i++){let s=e.child(i);s.content.size&&(s=s.copy(Ro(s.content,t,s))),s.isInline&&(s=t(s,n,i)),o.push(s)}return v.fromArray(o)}var Nn=class ye extends V{constructor(t,n,o){super(),this.from=t,this.to=n,this.mark=o}apply(t){let n=t.slice(this.from,this.to),o=t.resolve(this.from),i=o.node(o.sharedDepth(this.to)),s=new k(Ro(n.content,(r,l)=>!r.isAtom||!l.type.allowsMarkType(this.mark.type)?r:r.mark(this.mark.addToSet(r.marks)),i),n.openStart,n.openEnd);return W.fromReplace(t,this.from,this.to,s)}invert(){return new de(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),o=t.mapResult(this.to,-1);return n.deleted&&o.deleted||n.pos>=o.pos?null:new ye(n.pos,o.pos,this.mark)}merge(t){return t instanceof ye&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new ye(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 new RangeError("Invalid input for AddMarkStep.fromJSON");return new ye(n.from,n.to,t.markFromJSON(n.mark))}};V.jsonID("addMark",Nn);var de=class we extends V{constructor(t,n,o){super(),this.from=t,this.to=n,this.mark=o}apply(t){let n=t.slice(this.from,this.to),o=new k(Ro(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),t),n.openStart,n.openEnd);return W.fromReplace(t,this.from,this.to,o)}invert(){return new Nn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),o=t.mapResult(this.to,-1);return n.deleted&&o.deleted||n.pos>=o.pos?null:new we(n.pos,o.pos,this.mark)}merge(t){return t instanceof we&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new we(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 new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new we(n.from,n.to,t.markFromJSON(n.mark))}};V.jsonID("removeMark",de);var An=class be extends V{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return W.fail("No node at mark step's position");let o=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return W.fromReplace(t,this.pos,this.pos+1,new k(v.from(o),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let o=this.mark.addToSet(n.marks);if(o.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(o))return new be(this.pos,n.marks[i]);return new be(this.pos,this.mark)}}return new Pe(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new be(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 new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new be(n.pos,t.markFromJSON(n.mark))}};V.jsonID("addNodeMark",An);var Pe=class po extends V{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return W.fail("No node at mark step's position");let o=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return W.fromReplace(t,this.pos,this.pos+1,new k(v.from(o),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new An(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new po(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 new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new po(n.pos,t.markFromJSON(n.mark))}};V.jsonID("removeNodeMark",Pe);var ot=class Ot extends V{constructor(t,n,o,i=!1){super(),this.from=t,this.to=n,this.slice=o,this.structure=i}apply(t){return this.structure&&uo(t,this.from,this.to)?W.fail("Structure replace would overwrite content"):W.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new $t([this.from,this.to-this.from,this.slice.size])}invert(t){return new Ot(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),o=this.from==this.to&&Ot.MAP_BIAS<0?n:t.mapResult(this.from,1);return o.deletedAcross&&n.deletedAcross?null:new Ot(o.pos,Math.max(o.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof Ot)||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?k.empty:new k(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Ot(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?k.empty:new k(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Ot(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ot(n.from,n.to,k.fromJSON(t,n.slice),!!n.structure)}};ot.MAP_BIAS=1;V.jsonID("replace",ot);var ht=class mn extends V{constructor(t,n,o,i,s,r,l=!1){super(),this.from=t,this.to=n,this.gapFrom=o,this.gapTo=i,this.slice=s,this.insert=r,this.structure=l}apply(t){if(this.structure&&(uo(t,this.from,this.gapFrom)||uo(t,this.gapTo,this.to)))return W.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return W.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,n.content);return o?W.fromReplace(t,this.from,this.to,o):W.fail("Content does not fit in gap")}getMap(){return new $t([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 mn(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),o=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),s=this.to==this.gapTo?o.pos:t.map(this.gapTo,1);return n.deletedAcross&&o.deletedAcross||i<n.pos||s>o.pos?null:new mn(n.pos,o.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new mn(n.from,n.to,n.gapFrom,n.gapTo,k.fromJSON(t,n.slice),n.insert,!!n.structure)}};V.jsonID("replaceAround",ht);function uo(e,t,n){let o=e.resolve(t),i=n-t,s=o.depth;for(;i>0&&s>0&&o.indexAfter(s)==o.node(s).childCount;)s--,i--;if(i>0){let r=o.node(s).maybeChild(o.indexAfter(s));for(;i>0;){if(!r||r.isLeaf)return!0;r=r.firstChild,i--}}return!1}function Ha(e,t,n,o){let i=[],s=[],r,l;e.doc.nodesBetween(t,n,(a,c,h)=>{if(!a.isInline)return;let d=a.marks;if(!o.isInSet(d)&&h.type.allowsMarkType(o.type)){let p=Math.max(c,t),u=Math.min(c+a.nodeSize,n),f=o.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(f)||(r&&r.to==p&&r.mark.eq(d[m])?r.to=u:i.push(r=new de(p,u,d[m])));l&&l.to==p?l.to=u:s.push(l=new Nn(p,u,o))}}),i.forEach(a=>e.step(a)),s.forEach(a=>e.step(a))}function Ua(e,t,n,o){let i=[],s=0;e.doc.nodesBetween(t,n,(r,l)=>{if(!r.isInline)return;s++;let a=null;if(o instanceof Do){let c=r.marks,h;for(;h=o.isInSet(c);)(a||(a=[])).push(h),c=h.removeFromSet(c)}else o?o.isInSet(r.marks)&&(a=[o]):a=r.marks;if(a&&a.length){let c=Math.min(l+r.nodeSize,n);for(let h=0;h<a.length;h++){let d=a[h],p;for(let u=0;u<i.length;u++){let f=i[u];f.step==s-1&&d.eq(i[u].style)&&(p=f)}p?(p.to=c,p.step=s):i.push({style:d,from:Math.max(l,t),to:c,step:s})}}}),i.forEach(r=>e.step(new de(r.from,r.to,r.style)))}function Io(e,t,n,o=n.contentMatch,i=!0){let s=e.doc.nodeAt(t),r=[],l=t+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),h=l+c.nodeSize,d=o.matchType(c.type);if(!d)r.push(new ot(l,h,k.empty));else{o=d;for(let p=0;p<c.marks.length;p++)n.allowsMarkType(c.marks[p].type)||e.step(new de(l,h,c.marks[p]));if(i&&c.isText&&n.whitespace!="pre"){let p,u=/\r?\n|\r/g,f;for(;p=u.exec(c.text);)f||(f=new k(v.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),r.push(new ot(l+p.index,l+p.index+p[0].length,f))}}l=h}if(!o.validEnd){let a=o.fillBefore(v.empty,!0);e.replace(l,l,new k(a,0,0))}for(let a=r.length-1;a>=0;a--)e.step(r[a])}function Ga(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Je(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,o=0,i=0;;--n){let s=e.$from.node(n),r=e.$from.index(n)+o,l=e.$to.indexAfter(n)-i;if(n<e.depth&&s.canReplace(r,l,t))return n;if(n==0||s.type.spec.isolating||!Ga(s,r,l))break;r&&(o=1),l<s.childCount&&(i=1)}return null}function Ya(e,t,n){let{$from:o,$to:i,depth:s}=t,r=o.before(s+1),l=i.after(s+1),a=r,c=l,h=v.empty,d=0;for(let f=s,m=!1;f>n;f--)m||o.index(f)>0?(m=!0,h=v.from(o.node(f).copy(h)),d++):a--;let p=v.empty,u=0;for(let f=s,m=!1;f>n;f--)m||i.after(f+1)<i.end(f)?(m=!0,p=v.from(i.node(f).copy(p)),u++):c++;e.step(new ht(a,c,r,l,new k(h.append(p),d,u),h.size-d,!0))}function Po(e,t,n=null,o=e){let i=Qa(e,t),s=i&&Za(o,t);return s?i.map(Pi).concat({type:t,attrs:n}).concat(s.map(Pi)):null}function Pi(e){return{type:e,attrs:null}}function Qa(e,t){let{parent:n,startIndex:o,endIndex:i}=e,s=n.contentMatchAt(o).findWrapping(t);if(!s)return null;let r=s.length?s[0]:t;return n.canReplaceWith(o,i,r)?s:null}function Za(e,t){let{parent:n,startIndex:o,endIndex:i}=e,s=n.child(o),r=t.contentMatch.findWrapping(s.type);if(!r)return null;let l=(r.length?r[r.length-1]:t).contentMatch;for(let a=o;l&&a<i;a++)l=l.matchType(n.child(a).type);return!l||!l.validEnd?null:r}function _a(e,t,n){let o=v.empty;for(let r=n.length-1;r>=0;r--){if(o.size){let l=n[r].type.contentMatch.matchFragment(o);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=v.from(n[r].type.create(n[r].attrs,o))}let i=t.start,s=t.end;e.step(new ht(i,s,i,s,new k(o,0,0),n.length,!0))}function Xa(e,t,n,o,i){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=e.steps.length;e.doc.nodesBetween(t,n,(r,l)=>{let a=typeof i=="function"?i(r):i;if(r.isTextblock&&!r.hasMarkup(o,a)&&tc(e.doc,e.mapping.slice(s).map(l),o)){let c=null;if(o.schema.linebreakReplacement){let u=o.whitespace=="pre",f=!!o.contentMatch.matchType(o.schema.linebreakReplacement);u&&!f?c=!1:!u&&f&&(c=!0)}c===!1&&tr(e,r,l,s),Io(e,e.mapping.slice(s).map(l,1),o,void 0,c===null);let h=e.mapping.slice(s),d=h.map(l,1),p=h.map(l+r.nodeSize,1);return e.step(new ht(d,p,d+1,p-1,new k(v.from(o.create(a,null,r.marks)),0,0),1,!0)),c===!0&&Xs(e,r,l,s),!1}})}function Xs(e,t,n,o){t.forEach((i,s)=>{if(i.isText){let r,l=/\r?\n|\r/g;for(;r=l.exec(i.text);){let a=e.mapping.slice(o).map(n+1+s+r.index);e.replaceWith(a,a+1,t.type.schema.linebreakReplacement.create())}}})}function tr(e,t,n,o){t.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let r=e.mapping.slice(o).map(n+1+s);e.replaceWith(r,r+1,t.type.schema.text(`
5
+ `))}})}function tc(e,t,n){let o=e.resolve(t),i=o.index();return o.parent.canReplaceWith(i,i+1,n)}function ec(e,t,n,o,i){let s=e.doc.nodeAt(t);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let r=n.create(o,null,i||s.marks);if(s.isLeaf)return e.replaceWith(t,t+s.nodeSize,r);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new ht(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new k(v.from(r),0,0),1,!0))}function De(e,t,n=1,o){let i=e.resolve(t),s=i.depth-n,r=o&&o[o.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!r.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,h=n-2;c>s;c--,h--){let d=i.node(c),p=i.index(c);if(d.type.spec.isolating)return!1;let u=d.content.cutByIndex(p,d.childCount),f=o&&o[h+1];f&&(u=u.replaceChild(0,f.type.create(f.attrs)));let m=o&&o[h]||d;if(!d.canReplace(p+1,d.childCount)||!m.type.validContent(u))return!1}let l=i.indexAfter(s),a=o&&o[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function nc(e,t,n=1,o){let i=e.doc.resolve(t),s=v.empty,r=v.empty;for(let l=i.depth,a=i.depth-n,c=n-1;l>a;l--,c--){s=v.from(i.node(l).copy(s));let h=o&&o[c];r=v.from(h?h.type.create(h.attrs,r):i.node(l).copy(r))}e.step(new ot(t,t,new k(s.append(r),n,n),!0))}function Ut(e,t){let n=e.resolve(t),o=n.index();return er(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(o,o+1)}function oc(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:o}=e.type.schema;for(let i=0;i<t.childCount;i++){let s=t.child(i),r=s.type==o?e.type.schema.nodes.text:s.type;if(n=n.matchType(r),!n||!e.type.allowsMarks(s.marks))return!1}return n.validEnd}function er(e,t){return!!(e&&t&&!e.isLeaf&&oc(e,t))}function Bo(e,t,n=-1){let o=e.resolve(t);for(let i=o.depth;;i--){let s,r,l=o.index(i);if(i==o.depth?(s=o.nodeBefore,r=o.nodeAfter):n>0?(s=o.node(i+1),l++,r=o.node(i).maybeChild(l)):(s=o.node(i).maybeChild(l-1),r=o.node(i+1)),s&&!s.isTextblock&&er(s,r)&&o.node(i).canReplace(l,l+1))return t;if(i==0)break;t=n<0?o.before(i):o.after(i)}}function ic(e,t,n){let o=null,{linebreakReplacement:i}=e.doc.type.schema,s=e.doc.resolve(t-n),r=s.node().type;if(i&&r.inlineContent){let h=r.whitespace=="pre",d=!!r.contentMatch.matchType(i);h&&!d?o=!1:!h&&d&&(o=!0)}let l=e.steps.length;if(o===!1){let h=e.doc.resolve(t+n);tr(e,h.node(),h.before(),l)}r.inlineContent&&Io(e,t+n-1,r,s.node().contentMatchAt(s.index()),o==null);let a=e.mapping.slice(l),c=a.map(t-n);if(e.step(new ot(c,a.map(t+n,-1),k.empty,!0)),o===!0){let h=e.doc.resolve(c);Xs(e,h.node(),h.before(),e.steps.length)}return e}function nr(e,t,n){let o=e.resolve(t);if(o.parent.canReplaceWith(o.index(),o.index(),n))return t;if(o.parentOffset==0)for(let i=o.depth-1;i>=0;i--){let s=o.index(i);if(o.node(i).canReplaceWith(s,s,n))return o.before(i+1);if(s>0)return null}if(o.parentOffset==o.parent.content.size)for(let i=o.depth-1;i>=0;i--){let s=o.indexAfter(i);if(o.node(i).canReplaceWith(s,s,n))return o.after(i+1);if(s<o.node(i).childCount)return null}return null}function zo(e,t,n){let o=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let s=0;s<n.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let r=o.depth;r>=0;r--){let l=r==o.depth?0:o.pos<=(o.start(r+1)+o.end(r+1))/2?-1:1,a=o.index(r)+(l>0?1:0),c=o.node(r),h=!1;if(s==1)h=c.canReplace(a,a,i);else{let d=c.contentMatchAt(a).findWrapping(i.firstChild.type);h=d&&c.canReplaceWith(a,a,d[0])}if(h)return l==0?o.pos:l<0?o.before(r+1):o.after(r+1)}return null}function qe(e,t,n=t,o=k.empty){if(t==n&&!o.size)return null;let i=e.resolve(t),s=e.resolve(n);return or(i,s,o)?new ot(t,n,o):new sc(i,s,o).fit()}function or(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var sc=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=v.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=v.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let a=this.findFittable();a?this.placeNodes(a):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(e<0?this.$to:n.doc.resolve(e));if(!o)return null;let i=this.placed,s=n.depth,r=o.depth;for(;s&&r&&i.childCount==1;)i=i.firstChild.content,s--,r--;let l=new k(i,s,r);return e>-1?new ht(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new ot(n.pos,o.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,o=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(o=0),i.type.spec.isolating&&o<=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 o,i=null;n?(i=Bi(this.unplaced.content,n-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let r=this.depth;r>=0;r--){let{type:l,match:a}=this.frontier[r],c,h=null;if(t==1&&(s?a.matchType(s.type)||(h=a.fillBefore(v.from(s),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:n,frontierDepth:r,parent:i,inject:h};if(t==2&&s&&(c=a.findWrapping(s.type)))return{sliceDepth:n,frontierDepth:r,parent:i,wrap:c};if(i&&a.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced;return zi(e,-1)<=t?!1:(this.unplaced.size>1&&zi(e,1)>n&&n++,this.unplaced=new k(e,t+1,n),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,o=Bi(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new k(ve(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new k(ve(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let f=0;f<i.length;f++)this.openFrontierNode(i[f]);let s=this.unplaced,r=n?n.content:s.content,l=s.openStart-e,a=0,c=[],{match:h,type:d}=this.frontier[t];if(o){for(let f=0;f<o.childCount;f++)c.push(o.child(f));h=h.matchFragment(o)}let p=r.size+e-(s.content.size-s.openEnd);for(;a<r.childCount;){let f=r.child(a),m=h.matchType(f.type);if(!m)break;a++,(a>1||l==0||f.content.size)&&(h=m,c.push(ir(f.mark(d.allowedMarks(f.marks)),a==1?l:0,a==r.childCount?p:-1)))}let u=a==r.childCount;u||(p=-1),this.placed=ke(this.placed,t,v.from(c)),this.frontier[t].match=h,u&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let f=0,m=r;f<p;f++){let g=m.lastChild;this.frontier.push({type:g.type,match:g.contentMatchAt(g.childCount)}),m=g.content}this.unplaced=u?e==0?k.empty:new k(ve(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new k(ve(s.content,e,a),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Wn(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,o=this.$to.after(n);for(;n>1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(e){t:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:o}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=Wn(e,t,o,n,i);if(s){for(let r=t-1;r>=0;r--){let{match:l,type:a}=this.frontier[r],c=Wn(e,r,a,l,!0);if(!c||c.childCount)continue t}return{depth:t,fit:s,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=ke(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let o=e.node(n),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(n));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=ke(this.placed,this.depth,v.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(v.empty,!0);e.childCount&&(this.placed=ke(this.placed,this.frontier.length,e))}};function ve(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(ve(e.firstChild.content,t-1,n)))}function ke(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(ke(e.lastChild.content,t-1,n)))}function Bi(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function ir(e,t,n){if(t<=0)return e;let o=e.content;return t>1&&(o=o.replaceChild(0,ir(o.firstChild,t-1,o.childCount==1?n-1:0))),t>0&&(o=e.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(e.type.contentMatch.matchFragment(o).fillBefore(v.empty,!0)))),e.copy(o)}function Wn(e,t,n,o,i){let s=e.node(t),r=i?e.indexAfter(t):e.index(t);if(r==s.childCount&&!n.compatibleContent(s.type))return null;let l=o.fillBefore(s.content,!0,r);return l&&!rc(n,s.content,r)?l:null}function rc(e,t,n){for(let o=n;o<t.childCount;o++)if(!e.allowsMarks(t.child(o).marks))return!0;return!1}function lc(e){return e.spec.defining||e.spec.definingForContent}function zi(e,t){for(let n=0;;n++){let o=t<0?e.firstChild:e.lastChild;if(!o||o.isAtom)return n;e=o.content}}function ac(e,t,n,o){if(!o.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),s=e.doc.resolve(n);if(or(i,s,o))return e.step(new ot(t,n,o));let r=rr(i,s);r[r.length-1]==0&&r.pop();let l=-(i.depth+1);r.unshift(l);for(let p=i.depth,u=i.pos-1;p>0;p--,u--){let f=i.node(p).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;r.indexOf(p)>-1?l=p:i.before(p)==u&&r.splice(1,0,-p)}let a=r.indexOf(l),c=[],h=o.openStart;for(let p=o.content,u=0;;u++){let f=p.firstChild;if(c.push(f),u==o.openStart)break;p=f.content}for(let p=h-1;p>=0;p--){let u=c[p],f=lc(u.type);if(f&&!u.sameMarkup(i.node(Math.abs(l)-1)))h=p;else if(f||!u.type.isTextblock)break}for(let p=o.openStart;p>=0;p--){let u=(p+h+1)%(o.openStart+1),f=c[u];if(f)for(let m=0;m<r.length;m++){let g=r[(m+a)%r.length],b=!0;g<0&&(b=!1,g=-g);let y=i.node(g-1),w=i.index(g-1);if(y.canReplaceWith(w,w,f.type,f.marks))return e.replace(i.before(g),b?s.after(g):n,new k(sr(o.content,0,o.openStart,u),u,o.openEnd))}}let d=e.steps.length;for(let p=r.length-1;p>=0&&(e.replace(t,n,o),!(e.steps.length>d));p--){let u=r[p];u<0||(t=i.before(u),n=s.after(u))}}function sr(e,t,n,o,i){if(t<n){let s=e.firstChild;e=e.replaceChild(0,s.copy(sr(s.content,t+1,n,o,s)))}if(t>o){let s=i.contentMatchAt(0),r=s.fillBefore(e).append(e);e=r.append(s.matchFragment(r).fillBefore(v.empty,!0))}return e}function cc(e,t,n,o){if(!o.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=nr(e.doc,t,o.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new k(v.from(o),0,0))}function hc(e,t,n){let o=e.doc.resolve(t),i=e.doc.resolve(n);if(o.parent.isTextblock&&i.parent.isTextblock&&o.start()!=i.start()&&o.parentOffset==0&&i.parentOffset==0){let r=o.sharedDepth(n),l=!1;for(let a=o.depth;a>r;a--)o.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>r;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=o.depth;a>0&&t==o.start(a);a--)t=o.before(a);for(let a=i.depth;a>0&&n==i.start(a);a--)n=i.before(a);o=e.doc.resolve(t),i=e.doc.resolve(n)}}let s=rr(o,i);for(let r=0;r<s.length;r++){let l=s[r],a=r==s.length-1;if(a&&l==0||o.node(l).type.contentMatch.validEnd)return e.delete(o.start(l),i.end(l));if(l>0&&(a||o.node(l-1).canReplace(o.index(l-1),i.indexAfter(l-1))))return e.delete(o.before(l),i.after(l))}for(let r=1;r<=o.depth&&r<=i.depth;r++)if(t-o.start(r)==o.depth-r&&n>o.end(r)&&i.end(r)-n!=i.depth-r&&o.start(r-1)==i.start(r-1)&&o.node(r-1).canReplace(o.index(r-1),i.index(r-1)))return e.delete(o.before(r),n);e.delete(t,n)}function rr(e,t){let n=[],o=Math.min(e.depth,t.depth);for(let i=o;i>=0;i--){let s=e.start(i);if(s<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;(s==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==s-1)&&n.push(i)}return n}var Fo=class gn extends V{constructor(t,n,o){super(),this.pos=t,this.attr=n,this.value=o}apply(t){let n=t.nodeAt(this.pos);if(!n)return W.fail("No node at attribute step's position");let o=Object.create(null);for(let s in n.attrs)o[s]=n.attrs[s];o[this.attr]=this.value;let i=n.type.create(o,null,n.marks);return W.fromReplace(t,this.pos,this.pos+1,new k(v.from(i),0,n.isLeaf?0:1))}getMap(){return $t.empty}invert(t){return new gn(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 gn(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 new RangeError("Invalid input for AttrStep.fromJSON");return new gn(n.pos,n.attr,n.value)}};V.jsonID("attr",Fo);var Vo=class mo extends V{constructor(t,n){super(),this.attr=t,this.value=n}apply(t){let n=Object.create(null);for(let i in t.attrs)n[i]=t.attrs[i];n[this.attr]=this.value;let o=t.type.create(n,t.content,t.marks);return W.ok(o)}getMap(){return $t.empty}invert(t){return new mo(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new mo(n.attr,n.value)}};V.jsonID("docAttr",Vo);var Wt=class extends Error{};Wt=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n};Wt.prototype=Object.create(Error.prototype);Wt.prototype.constructor=Wt;Wt.prototype.name="TransformError";var lr=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new $o}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Wt(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 o=this.mapping.maps[n];n&&(e=o.map(e,1),t=o.map(t,-1)),o.forEach((i,s,r,l)=>{e=Math.min(e,r),t=Math.max(t,l)})}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=k.empty){let o=qe(this.doc,e,t,n);return o&&this.step(o),this}replaceWith(e,t,n){return this.replace(e,t,new k(v.from(n),0,0))}delete(e,t){return this.replace(e,t,k.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return ac(this,e,t,n),this}replaceRangeWith(e,t,n){return cc(this,e,t,n),this}deleteRange(e,t){return hc(this,e,t),this}lift(e,t){return Ya(this,e,t),this}join(e,t=1){return ic(this,e,t),this}wrap(e,t){return _a(this,e,t),this}setBlockType(e,t=e,n,o=null){return Xa(this,e,t,n,o),this}setNodeMarkup(e,t,n=null,o){return ec(this,e,t,n,o),this}setNodeAttribute(e,t,n){return this.step(new Fo(e,t,n)),this}setDocAttribute(e,t){return this.step(new Vo(e,t)),this}addNodeMark(e,t){return this.step(new An(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof E)t.isInSet(n.marks)&&this.step(new Pe(e,t));else{let o=n.marks,i,s=[];for(;i=t.isInSet(o);)s.push(new Pe(e,i)),o=i.removeFromSet(o);for(let r=s.length-1;r>=0;r--)this.step(s[r])}return this}split(e,t=1,n){return nc(this,e,t,n),this}addMark(e,t,n){return Ha(this,e,t,n),this}removeMark(e,t,n){return Ua(this,e,t,n),this}clearIncompatible(e,t,n){return Io(this,e,t,n),this}},Kn=Object.create(null),C=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new xn(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=k.empty){let n=t.content.lastChild,o=null;for(let r=0;r<t.openEnd;r++)o=n,n=n.lastChild;let i=e.steps.length,s=this.ranges;for(let r=0;r<s.length;r++){let{$from:l,$to:a}=s[r],c=e.mapping.slice(i);e.replaceRange(c.map(l.pos),c.map(a.pos),r?k.empty:t),r==0&&ji(e,i,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:r}=o[i],l=e.mapping.slice(n),a=l.map(s.pos),c=l.map(r.pos);i?e.deleteRange(a,c):(e.replaceRangeWith(a,c,t),ji(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let o=e.parent.inlineContent?new N(e):te(e.node(0),e.parent,e.pos,e.index(),t,n);if(o)return o;for(let i=e.depth-1;i>=0;i--){let s=t<0?te(e.node(0),e.node(i),e.before(i+1),e.index(i),t,n):te(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,n);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new at(e.node(0))}static atStart(e){return te(e,e,0,0,1)||new at(e)}static atEnd(e){return te(e,e,e.content.size,e.childCount,-1)||new at(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Kn[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Kn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Kn[e]=t,t.prototype.jsonID=e,t}getBookmark(){return N.between(this.$anchor,this.$head).getBookmark()}};C.prototype.visible=!0;var xn=class{constructor(e,t){this.$from=e,this.$to=t}},Fi=!1;function Vi(e){!Fi&&!e.parent.inlineContent&&(Fi=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}var N=class xe extends C{constructor(t,n=t){Vi(t),Vi(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let o=t.resolve(n.map(this.head));if(!o.parent.inlineContent)return C.near(o);let i=t.resolve(n.map(this.anchor));return new xe(i.parent.inlineContent?i:o,o)}replace(t,n=k.empty){if(super.replace(t,n),n==k.empty){let o=this.$from.marksAcross(this.$to);o&&t.ensureMarks(o)}}eq(t){return t instanceof xe&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new ar(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 new RangeError("Invalid input for TextSelection.fromJSON");return new xe(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,o=n){let i=t.resolve(n);return new this(i,o==n?i:t.resolve(o))}static between(t,n,o){let i=t.pos-n.pos;if((!o||i)&&(o=i>=0?1:-1),!n.parent.inlineContent){let s=C.findFrom(n,o,!0)||C.findFrom(n,-o,!0);if(s)n=s.$head;else return C.near(n,o)}return t.parent.inlineContent||(i==0?t=n:(t=(C.findFrom(t,-o,!0)||C.findFrom(t,o,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new xe(t,n)}};C.jsonID("text",N);var ar=class cr{constructor(t,n){this.anchor=t,this.head=n}map(t){return new cr(t.map(this.anchor),t.map(this.head))}resolve(t){return N.between(t.resolve(this.anchor),t.resolve(this.head))}},O=class Se extends C{constructor(t){let n=t.nodeAfter,o=t.node(0).resolve(t.pos+n.nodeSize);super(t,o),this.node=n}map(t,n){let{deleted:o,pos:i}=n.mapResult(this.anchor),s=t.resolve(i);return o?C.near(s):new Se(s)}content(){return new k(v.from(this.node),0,0)}eq(t){return t instanceof Se&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new dc(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Se(t.resolve(n.anchor))}static create(t,n){return new Se(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}};O.prototype.visible=!1;C.jsonID("node",O);var dc=class hr{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:o}=t.mapResult(this.anchor);return n?new ar(o,o):new hr(o)}resolve(t){let n=t.resolve(this.anchor),o=n.nodeAfter;return o&&O.isSelectable(o)?new O(n):C.near(n)}},at=class yn extends C{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=k.empty){if(n==k.empty){t.delete(0,t.doc.content.size);let o=C.atStart(t.doc);o.eq(t.selection)||t.setSelection(o)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new yn(t)}map(t){return new yn(t)}eq(t){return t instanceof yn}getBookmark(){return fc}};C.jsonID("all",at);var fc={map(){return this},resolve(e){return new at(e)}};function te(e,t,n,o,i,s=!1){if(t.inlineContent)return N.create(e,n);for(let r=o-(i>0?0:1);i>0?r<t.childCount:r>=0;r+=i){let l=t.child(r);if(l.isAtom){if(!s&&O.isSelectable(l))return O.create(e,n-(i<0?l.nodeSize:0))}else{let a=te(e,l,n+i,i<0?l.childCount:0,i,s);if(a)return a}n+=l.nodeSize*i}return null}function ji(e,t,n){let o=e.steps.length-1;if(o<t)return;let i=e.steps[o];if(!(i instanceof ot||i instanceof ht))return;let s=e.mapping.maps[o],r;s.forEach((l,a,c,h)=>{r==null&&(r=h)}),e.setSelection(C.near(e.doc.resolve(r),n))}var Li=1,hn=2,Ji=4,dr=class extends lr{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 new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Li)&~hn,this.storedMarks=null,this}get selectionSet(){return(this.updated&Li)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=hn,this}ensureMarks(e){return E.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&hn)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~hn,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)||E.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let s=this.doc.resolve(t);i=n==t?s.marks():s.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,o.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(C.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|=Ji,this}get scrolledIntoView(){return(this.updated&Ji)>0}};function qi(e,t){return!t||!e?e:e.bind(t)}var Oe=class{constructor(e,t,n){this.name=e,this.init=qi(t.init,n),this.apply=qi(t.apply,n)}},pc=[new Oe("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new Oe("selection",{init(e,t){return e.selection||C.atStart(t.doc)},apply(e){return e.selection}}),new Oe("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,o){return o.selection.$cursor?e.storedMarks:null}}),new Oe("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],Hn=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=pc.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new Oe(n.key,n.spec.state,n))})}},uc=class Me{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,n=-1){for(let o=0;o<this.config.plugins.length;o++)if(o!=n){let i=this.config.plugins[o];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let n=[t],o=this.applyInner(t),i=null;for(;;){let s=!1;for(let r=0;r<this.config.plugins.length;r++){let l=this.config.plugins[r];if(l.spec.appendTransaction){let a=i?i[r].n:0,c=i?i[r].state:this,h=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,o);if(h&&o.filterTransaction(h,r)){if(h.setMeta("appendedTransaction",t),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<r?{state:o,n:n.length}:{state:this,n:0})}n.push(h),o=o.applyInner(h),s=!0}i&&(i[r]={state:o,n:n.length})}}if(!s)return{state:o,transactions:n}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Me(this.config),o=this.config.fields;for(let i=0;i<o.length;i++){let s=o[i];n[s.name]=s.apply(t,this[s.name],this,n)}return n}get tr(){return new dr(this)}static create(t){let n=new Hn(t.doc?t.doc.type.schema:t.schema,t.plugins),o=new Me(n);for(let i=0;i<n.fields.length;i++)o[n.fields[i].name]=n.fields[i].init(t,o);return o}reconfigure(t){let n=new Hn(this.schema,t.plugins),o=n.fields,i=new Me(n);for(let s=0;s<o.length;s++){let r=o[s].name;i[r]=this.hasOwnProperty(r)?this[r]:o[s].init(t,i)}return i}toJSON(t){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(o=>o.toJSON())),t&&typeof t=="object")for(let o in t){if(o=="doc"||o=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=t[o],s=i.spec.state;s&&s.toJSON&&(n[o]=s.toJSON.call(i,this[i.key]))}return n}static fromJSON(t,n,o){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let i=new Hn(t.schema,t.plugins),s=new Me(i);return i.fields.forEach(r=>{if(r.name=="doc")s.doc=Et.fromJSON(t.schema,n.doc);else if(r.name=="selection")s.selection=C.fromJSON(s.doc,n.selection);else if(r.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(o)for(let l in o){let a=o[l],c=a.spec.state;if(a.key==r.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){s[r.name]=c.fromJSON.call(a,t,n[l],s);return}}s[r.name]=r.init(t,s)}}),s}};function fr(e,t,n){for(let o in e){let i=e[o];i instanceof Function?i=i.bind(t):o=="handleDOMEvents"&&(i=fr(i,t,{})),n[o]=i}return n}var fe=class{constructor(e){this.spec=e,this.props={},e.props&&fr(e.props,this,this.props),this.key=e.key?e.key.key:pr("plugin")}getState(e){return e[this.key]}},Un=Object.create(null);function pr(e){return e in Un?e+"$"+ ++Un[e]:(Un[e]=0,e+"$")}var jo=class{constructor(e="key"){this.key=pr(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},mc={};ft(mc,{Decoration:()=>Pt,DecorationSet:()=>nt,EditorView:()=>el,__endComposition:()=>Xh,__parseFromClipboard:()=>_h});var B=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},le=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},go=null,gt=function(e,t,n){let o=go||(go=document.createRange());return o.setEnd(e,n??e.nodeValue.length),o.setStart(e,t||0),o},gc=function(){go=null},Kt=function(e,t,n,o){return n&&(Wi(e,t,n,o,-1)||Wi(e,t,n,o,1))},yc=/^(img|br|input|textarea|hr)$/i;function Wi(e,t,n,o,i){for(var s;;){if(e==n&&t==o)return!0;if(t==(i<0?0:q(e))){let r=e.parentNode;if(!r||!x(r)||We(e)||yc.test(e.nodeName)||e.contentEditable=="false")return!1;t=B(e)+(i<0?0:1),e=r}else if(x(e)){let r=e.childNodes[t+(i<0?-1:0)];if(x(r)&&r.contentEditable=="false")if(!((s=r.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)t+=i;else return!1;else e=r,t=i<0?q(e):0}else return!1}}function q(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function x(e){return e.nodeType==1}function I(e){return e.nodeType==3}function Ht(e,t){return t?e.contains(x(t)?t:t.parentNode):!1}function wc(e,t){for(;;){if(I(e)&&t)return e;if(x(e)&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=q(e)}else if(e.parentNode&&!We(e))t=B(e),e=e.parentNode;else return null}}function bc(e,t){for(;;){if(I(e)&&t<e.nodeValue.length)return e;if(x(e)&&t<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!We(e))t=B(e)+1,e=e.parentNode;else return null}}function vc(e,t,n){for(let o=t==0,i=t==q(e);o||i;){if(e==n)return!0;let s=B(e);if(e=e.parentNode,!e)return!1;o=o&&s==0,i=i&&s==q(e)}}function We(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 Dn=function(e){return e.focusNode&&Kt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function zt(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function kc(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function xc(e,t,n){if(e.caretPositionFromPoint)try{let o=e.caretPositionFromPoint(t,n);if(o)return{node:o.offsetNode,offset:Math.min(q(o.offsetNode),o.offset)}}catch{}if(e.caretRangeFromPoint){let o=e.caretRangeFromPoint(t,n);if(o)return{node:o.startContainer,offset:Math.min(q(o.startContainer),o.startOffset)}}}var dt=typeof navigator<"u"?navigator:null,Ki=typeof document<"u"?document:null,It=dt&&dt.userAgent||"",yo=/Edge\/(\d+)/.exec(It),ur=/MSIE \d/.exec(It),wo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(It),_=!!(ur||wo||yo),Tt=ur?document.documentMode:wo?+wo[1]:yo?+yo[1]:0,X=!_&&/gecko\/(\d+)/i.test(It);X&&+(/Firefox\/(\d+)/.exec(It)||[0,0])[1];var bo=!_&&/Chrome\/(\d+)/.exec(It),z=!!bo,mr=bo?+bo[1]:0,K=!_&&!!dt&&/Apple Computer/.test(dt.vendor),ae=K&&(/Mobile\/\w+/.test(It)||!!dt&&dt.maxTouchPoints>2),tt=ae||(dt?/Mac/.test(dt.platform):!1),gr=dt?/Win/.test(dt.platform):!1,yt=/Android \d/.test(It),En=!!Ki&&"webkitFontSmoothing"in Ki.documentElement.style,Sc=En?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Oc(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 mt(e,t){return typeof e=="number"?e:e[t]}function Mc(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,o=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*o}}function Hi(e,t,n){if(!vo(t)&&t.left==0)return;let o=e.someProp("scrollThreshold")||0,i=e.someProp("scrollMargin")||5,s=e.dom.ownerDocument;for(let r=n||e.dom;r;){if(!x(r)){r=le(r);continue}let l=r==s.body,a=l?Oc(s):Mc(r),c=0,h=0;if(t.top<a.top+mt(o,"top")?h=-(a.top-t.top+mt(i,"top")):t.bottom>a.bottom-mt(o,"bottom")&&(h=t.bottom-t.top>a.bottom-a.top?t.top+mt(i,"top")-a.top:t.bottom-a.bottom+mt(i,"bottom")),t.left<a.left+mt(o,"left")?c=-(a.left-t.left+mt(i,"left")):t.right>a.right-mt(o,"right")&&(c=t.right-a.right+mt(i,"right")),c||h)if(l)s.defaultView.scrollBy(c,h);else{let p=r.scrollLeft,u=r.scrollTop;h&&(r.scrollTop+=h),c&&(r.scrollLeft+=c);let f=r.scrollLeft-p,m=r.scrollTop-u;t={left:t.left-f,top:t.top-m,right:t.right-f,bottom:t.bottom-m}}let d=l?"fixed":getComputedStyle(r).position;if(/^(fixed|sticky)$/.test(d))break;r=d=="absolute"?r.offsetParent:le(r)}}function Cc(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),o,i;for(let s=(t.left+t.right)/2,r=n+1;r<Math.min(innerHeight,t.bottom);r+=5){let l=e.root.elementFromPoint(s,r);if(!l||l==e.dom||!e.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){o=l,i=a.top;break}}return{refDOM:o,refTop:i,stack:yr(e.dom)}}function yr(e){let t=[],n=e.ownerDocument;for(let o=e;o&&(t.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),e!=n);o=le(o));return t}function Nc({refDOM:e,refTop:t,stack:n}){let o=e?e.getBoundingClientRect().top:0;wr(n,o==0?0:o-t)}function wr(e,t){for(let n=0;n<e.length;n++){let{dom:o,top:i,left:s}=e[n];o.scrollTop!=i+t&&(o.scrollTop=i+t),o.scrollLeft!=s&&(o.scrollLeft=s)}}var Qt=null;function Ac(e){if(e.setActive)return e.setActive();if(Qt)return e.focus(Qt);let t=yr(e);e.focus(Qt==null?{get preventScroll(){return Qt={preventScroll:!0},!0}}:void 0),Qt||(Qt=!1,wr(t,0))}function br(e,t){let n,o=2e8,i,s=0,r=t.top,l=t.top,a,c;for(let h=e.firstChild,d=0;h;h=h.nextSibling,d++){let p;if(x(h))p=h.getClientRects();else if(I(h))p=gt(h).getClientRects();else continue;for(let u=0;u<p.length;u++){let f=p[u];if(f.top<=r&&f.bottom>=l){r=Math.max(f.bottom,r),l=Math.min(f.top,l);let m=f.left>t.left?f.left-t.left:f.right<t.left?t.left-f.right:0;if(m<o){n=h,o=m,i=m&&I(n)?{left:f.right<t.left?f.right:f.left,top:t.top}:t,x(h)&&m&&(s=d+(t.left>=(f.left+f.right)/2?1:0));continue}}else f.top>t.top&&!a&&f.left<=t.left&&f.right>=t.left&&(a=h,c={left:Math.max(f.left,Math.min(f.right,t.left)),top:f.top});!n&&(t.left>=f.right&&t.top>=f.top||t.left>=f.left&&t.top>=f.bottom)&&(s=d+1)}}return!n&&a&&(n=a,i=c,o=0),n&&I(n)?Dc(n,i):!n||o?{node:e,offset:s}:br(n,i)}function Dc(e,t){let n=e.nodeValue.length,o=document.createRange(),i;for(let s=0;s<n;s++){o.setEnd(e,s+1),o.setStart(e,s);let r=Mt(o,1);if(r.top!=r.bottom&&Lo(t,r)){i={node:e,offset:s+(t.left>=(r.left+r.right)/2?1:0)};break}}return o.detach(),i||{node:e,offset:0}}function Lo(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Ec(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function Tc(e,t,n){let{node:o,offset:i}=br(t,n),s=-1;if(x(o)&&!o.firstChild){let r=o.getBoundingClientRect();s=r.left!=r.right&&n.left>(r.left+r.right)/2?1:-1}return e.docView.posFromDOM(o,i,s)}function $c(e,t,n,o){let i=-1;for(let s=t,r=!1;s!=e.dom;){let l=e.docView.nearestDesc(s,!0),a;if(!l)return null;if(x(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!r&&a.left>o.left||a.top>o.top?i=l.posBefore:(!r&&a.right<o.left||a.bottom<o.top)&&(i=l.posAfter),r=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?o.top<(a.top+a.bottom)/2:o.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}function vr(e,t,n){let o=e.childNodes.length;if(o&&n.top<n.bottom)for(let i=Math.max(0,Math.min(o-1,Math.floor(o*(t.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let r=e.childNodes[s];if(x(r)){let l=r.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Lo(t,c))return vr(r,t,c)}}if((s=(s+1)%o)==i)break}return e}function Rc(e,t){let n=e.dom.ownerDocument,o,i=0,s=xc(n,t.left,t.top);s&&({node:o,offset:i}=s);let r=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),l;if(!r||!e.dom.contains(r)){let c=e.dom.getBoundingClientRect();if(!Lo(t,c)||(r=vr(e.dom,t,c),!r))return null}if(K)for(let c=r;o&&c;c=le(c))c.draggable&&(o=void 0);if(r=Ec(r,t),o){if(X&&x(o)&&(i=Math.min(i,o.childNodes.length),i<o.childNodes.length)){let h=o.childNodes[i],d;h.nodeName=="IMG"&&(d=h.getBoundingClientRect()).right<=t.left&&d.bottom>t.top&&i++}let c;En&&i&&x(o)&&x(c=o.childNodes[i-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=t.top&&i--,o==e.dom&&i==o.childNodes.length-1&&x(o.lastChild)&&t.top>o.lastChild.getBoundingClientRect().bottom?l=e.state.doc.content.size:(i==0||!x(o)||o.childNodes[i-1].nodeName!="BR")&&(l=$c(e,o,i,t))}l==null&&(l=Tc(e,r,t));let a=e.docView.nearestDesc(r,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function vo(e){return e.top<e.bottom||e.left<e.right}function Mt(e,t){let n=e.getClientRects();if(n.length){let o=n[t<0?0:n.length-1];if(vo(o))return o}return Array.prototype.find.call(n,vo)||e.getBoundingClientRect()}var Ic=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function kr(e,t,n){let{node:o,offset:i,atom:s}=e.docView.domFromPos(t,n<0?-1:1),r=En||X;if(I(o))if(r&&(Ic.test(o.nodeValue)||(n<0?!i:i==o.nodeValue.length))){let l=Mt(gt(o,i,i),n);if(X&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){let a=Mt(gt(o,i-1,i-1),-1);if(a.top==l.top){let c=Mt(gt(o,i,i+1),-1);if(c.top!=l.top)return ue(c,c.left<a.left)}}return l}else{let l=i,a=i,c=n<0?1:-1;return n<0&&!i?(a++,c=-1):n>=0&&i==o.nodeValue.length?(l--,c=1):n<0?l--:a++,ue(Mt(gt(o,l,a),c),c<0)}if(!e.state.doc.resolve(t-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==q(o))){let l=o.childNodes[i-1];if(x(l))return Gn(l.getBoundingClientRect(),!1)}if(s==null&&i<q(o)){let l=o.childNodes[i];if(x(l))return Gn(l.getBoundingClientRect(),!0)}return Gn(o.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==q(o))){let l=o.childNodes[i-1],a=I(l)?gt(l,q(l)-(r?0:1)):x(l)&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(a)return ue(Mt(a,1),!1)}if(s==null&&i<q(o)){let l=o.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let a=l?I(l)?gt(l,0,r?0:1):x(l)?l:null:null;if(a)return ue(Mt(a,-1),!0)}return ue(Mt(I(o)?gt(o):o,-n),n>=0)}function ue(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 Gn(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 xr(e,t,n){let o=e.state,i=e.root.activeElement;o!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{o!=t&&e.updateState(o),i!=e.dom&&i&&i.focus()}}function Pc(e,t,n){let o=t.selection,i=n=="up"?o.$from:o.$to;return xr(e,t,()=>{let{node:s}=e.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=e.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let r=kr(e,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(x(l))a=l.getClientRects();else if(I(l))a=gt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let h=a[c];if(h.bottom>h.top+1&&(n=="up"?r.top-h.top>(h.bottom-r.top)*2:h.bottom-r.bottom>(r.bottom-h.top)*2))return!1}}return!0})}var Bc=/[\u0590-\u08ac]/;function zc(e,t,n){let{$head:o}=t.selection;if(!o.parent.isTextblock)return!1;let i=o.parentOffset,s=!i,r=i==o.parent.content.size,l=e.domSelection();return l?!Bc.test(o.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:r:xr(e,t,()=>{let{focusNode:a,focusOffset:c,anchorNode:h,anchorOffset:d}=e.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",n,"character");let u=o.depth?e.docView.domAfterPos(o.before()):e.dom,{focusNode:f,focusOffset:m}=e.domSelectionRange(),g=f&&!Ht(u,f)||a==f&&c==m;try{l.collapse(h,d),a&&(a!=h||c!=d)&&l.extend&&l.extend(a,c)}catch{}return p!=null&&(l.caretBidiLevel=p),g}):o.pos==o.start()||o.pos==o.end()}var Ui=null,Gi=null,Yi=!1;function Fc(e,t,n){return Ui==t&&Gi==n?Yi:(Ui=t,Gi=n,Yi=n=="up"||n=="down"?Pc(e,t,n):zc(e,t,n))}var et=0,Qi=1,Ft=2,it=3,Ke=class{constructor(e,t,n,o){this.parent=e,this.children=t,this.dom=n,this.contentDOM=o,this.dirty=et,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){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 o=this.children[t];if(o==e)return n;n+=o.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&&Ht(this.contentDOM,e))if(n<0){let i,s;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>B(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=!!(e.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!t||i.node))if(n&&(s=i.nodeDOM)&&!(x(s)?Ht(s,e):s==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let o=this.children[t],i=n+o.size;if(n==e&&i!=n){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let r=o.children[s];if(r.size){o=r;break}}return o}if(e<i)return o.descAt(e-n-o.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,o=0;for(let i=0;n<this.children.length;n++){let s=this.children[n],r=i+s.size;if(r>e){o=e-i;break}i=r}if(o)return this.children[n].domFromPos(o-this.children[n].border,t);for(;n>0;n--){let i=this.children[n-1];if(i.size||!(i instanceof Nr||i instanceof Sr&&i.side>=0))break}if(t<=0){let i,s=!0;for(;i=n?this.children[n-1]:null,!(!i||i.dom.parentNode==this.contentDOM);n--,s=!1);return i&&t&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?B(i.dom)+1:0}}else{let i,s=!0;for(;i=n<this.children.length?this.children[n]:null,!(!i||i.dom.parentNode==this.contentDOM);n++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?B(i.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 o=-1,i=-1;for(let s=n,r=0;;r++){let l=this.children[r],a=s+l.size;if(o==-1&&e<=a){let c=s+l.border;if(e>=c&&t<=a-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,c);e=s;for(let h=r;h>0;h--){let d=this.children[h-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=B(d.dom)+1;break}e-=d.size}o==-1&&(o=0)}if(o>-1&&(a>t||r==this.children.length-1)){t=a;for(let c=r+1;c<this.children.length;c++){let h=this.children[c];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){i=B(h.dom);break}t+=h.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=a}return{node:this.contentDOM,from:e,to:t,fromOffset:o,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(!x(t)||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,o=!1){let i=Math.min(e,t),s=Math.max(e,t);for(let p=0,u=0;p<this.children.length;p++){let f=this.children[p],m=u+f.size;if(i>u&&s<m)return f.setSelection(e-u-f.border,t-u-f.border,n,o);u=m}let r=this.domFromPos(e,e?-1:1),l=t==e?r:this.domFromPos(t,t?-1:1),a=n.root.getSelection(),c=n.domSelectionRange(),h=!1;if((X||K)&&e==t){let{node:p,offset:u}=r;if(I(p)){if(h=!!(u&&p.nodeValue[u-1]==`
6
+ `),h&&u==p.nodeValue.length)for(let f=p,m;f;f=f.parentNode){if(m=f.nextSibling){m.nodeName=="BR"&&(r=l={node:m.parentNode,offset:B(m)+1});break}let g=f.pmViewDesc;if(g&&g.node&&g.node.isBlock)break}}else{let f=p.childNodes[u-1];h=f&&(f.nodeName=="BR"||f.contentEditable=="false")}}if(X&&c.focusNode&&c.focusNode!=l.node&&x(c.focusNode)){let p=c.focusNode.childNodes[c.focusOffset];p&&p.contentEditable=="false"&&(o=!0)}if(!(o||h&&K)&&Kt(r.node,r.offset,c.anchorNode,c.anchorOffset)&&Kt(l.node,l.offset,c.focusNode,c.focusOffset))return;let d=!1;if((a.extend||e==t)&&!(h&&X)){a.collapse(r.node,r.offset);try{e!=t&&a.extend(l.node,l.offset),d=!0}catch{}}if(!d){if(e>t){let u=r;r=l,l=u}let p=document.createRange();p.setEnd(l.node,l.offset),p.setStart(r.node,r.offset),a.removeAllRanges(),a.addRange(p)}}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,o=0;o<this.children.length;o++){let i=this.children[o],s=n+i.size;if(n==s?e<=s&&t>=n:e<s&&t>n){let r=n+i.border,l=s-i.border;if(e>=r&&t<=l){this.dirty=e==n||t==s?Ft:Qi,e==r&&t==l&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=it:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ft:it}n=s}this.dirty=Ft}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Ft:Qi;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Sr=class extends Ke{constructor(e,t,n,o){let i,s=t.type.toDOM;if(typeof s=="function"&&(s=s(n,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let r=x(s)?s:document.createElement("span");r!=s&&r.appendChild(s),r.hasAttribute("contenteditable")||(r.contentEditable="false"),r.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==et&&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}},Vc=class extends Ke{constructor(e,t,n,o){super(e,[],t,null),this.textDOM=n,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Ee=class ko extends Ke{constructor(t,n,o,i,s){super(t,[],o,i),this.mark=n,this.spec=s}static create(t,n,o,i){let s=i.nodeViews[n.type.name],r=s&&s(n,i,o);return(!r||!r.dom)&&(r=Le.renderSpec(document,n.type.spec.toDOM(n,o),null,n.attrs)),new ko(t,n,r.dom,r.contentDOM||r.dom,r)}parseRule(){return this.dirty&it||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=it&&this.mark.eq(t)}markDirty(t,n){if(super.markDirty(t,n),this.dirty!=et){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=et}}slice(t,n,o){let i=ko.create(this.parent,this.mark,!0,o),s=this.children,r=this.size;n<r&&(s=So(s,n,r,o)),t>0&&(s=So(s,0,t,o));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},ie=class Or extends Ke{constructor(t,n,o,i,s,r,l){super(t,[],s,r),this.node=n,this.outerDeco=o,this.innerDeco=i,this.nodeDOM=l}static create(t,n,o,i,s,r){let l=s.nodeViews[n.type.name],a,c=l&&l(n,s,()=>{if(!a)return r;if(a.parent)return a.parent.posBeforeChild(a)},o,i),h=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!h)h=document.createTextNode(n.text);else if(!I(h))throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:d}=Le.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),n.type.spec.draggable&&(h.draggable=!0));let p=h;return h=Er(h,o,n),c?a=new jc(t,n,o,i,h,d||null,p,c):n.isText?new Mr(t,n,o,i,h,p):new Or(t,n,o,i,h,d||null,p)}parseRule(t){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let o=this.children.length-1;o>=0;o--){let i=this.children[o];if(this.dom.contains(i.dom.parentNode)){n.contentElement=i.dom.parentNode;break}}if(!n.contentElement){let o=t&&t.find(i=>x(i)&&t.indexOf(i.parentNode)<0&&this.dom.contains(i));o?n.contentElement=o:n.getContent=()=>v.empty}}return n}matchesNode(t,n,o){return this.dirty==et&&t.eq(this.node)&&Sn(n,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,n){let o=this.node.inlineContent,i=n,s=t.composing?this.localCompositionInfo(t,n):null,r=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Jc(this,r&&r.node,t),c=this.node.inlineContent,h=c&&this.node.isBlock;Kc(this.node,this.innerDeco,(d,p,u)=>{d.spec.marks?a.syncToMarks(d.spec.marks,o,t,p):d.type.side>=0&&!u&&a.syncToMarks(p==this.node.childCount?E.none:this.node.child(p).marks,o,t,p),a.placeWidget(d,t,i)},(d,p,u,f)=>{a.syncToMarks(d.marks,o,t,f),h&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(d,p,u,f)||l&&t.state.selection.from>i&&t.state.selection.to<i+d.nodeSize&&(m=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(d,p,u,m,t)||a.updateNextNode(d,p,u,t,f,i)||a.addNode(d,p,u,t,i),i+=d.nodeSize,c&&(h=d.isAtom&&!d.isText)}),a.syncToMarks([],o,t,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Ft)&&(r&&this.protectLocalComposition(t,r),Ar(this.contentDOM,this.children,t),ae&&Hc(this.dom))}localCompositionInfo(t,n){let{from:o,to:i}=t.state.selection;if(!(t.state.selection instanceof N)||o<n||i>n+this.node.content.size)return null;let s=t.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let r=s.nodeValue,l=Uc(this.node.content,r,o-n,i-n);return l<0?null:{node:s,pos:l,text:r}}else return{node:s,pos:-1,text:""}}protectLocalComposition(t,{node:n,pos:o,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let r=new Vc(this,s,n,i);t.input.compositionNodes.push(r),this.children=So(this.children,o,o+i.length,t,r)}update(t,n,o,i){return this.dirty==it||!t.sameMarkup(this.node)?!1:(this.updateInner(t,n,o,i),!0)}updateInner(t,n,o,i){this.updateOuterDeco(n),this.node=t,this.innerDeco=o,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=et}updateOuterDeco(t){if(Sn(t,this.outerDeco))return;let n=!x(this.nodeDOM),o=this.dom;this.dom=Dr(this.dom,this.nodeDOM,xo(this.outerDeco,this.node,n),xo(t,this.node,n)),this.dom!=o&&(o.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){x(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){x(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Zi(e,t,n,o,i){Er(o,t,e);let s=new ie(void 0,e,t,n,o,o,o);return s.contentDOM&&s.updateChildren(i,0),s}var Mr=class Cr extends ie{constructor(t,n,o,i,s,r){super(t,n,o,i,s,null,r)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,n,o,i){return this.dirty==it||this.dirty!=et&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=et||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=t,this.dirty=et,!0)}inParent(){let t=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,n,o){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(t,n,o)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,n,o){let i=this.node.cut(t,n),s=document.createTextNode(i.text);return new Cr(this.parent,i,this.outerDeco,this.innerDeco,s,s)}markDirty(t,n){super.markDirty(t,n),this.dom!=this.nodeDOM&&(t==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=it)}get domAtom(){return!1}isText(t){return this.node.text==t}},Nr=class extends Ke{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==et&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},jc=class extends ie{constructor(e,t,n,o,i,s,r,l){super(e,t,n,o,i,s,r),this.spec=l}update(e,t,n,o){if(this.dirty==it)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,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,o){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,o)}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 Ar(e,t,n){let o=e.firstChild,i=!1;for(let s=0;s<t.length;s++){let r=t[s],l=r.dom;if(l.parentNode==e){for(;l!=o;)o=_i(o),i=!0;o=o.nextSibling}else i=!0,e.insertBefore(l,o);if(r instanceof Ee){let a=o?o.previousSibling:e.lastChild;Ar(r.contentDOM,r.children,n),o=a?a.nextSibling:e.firstChild}}for(;o;)o=_i(o),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var Te=function(e){e&&(this.nodeName=e)};Te.prototype=Object.create(null);var Vt=[new Te];function xo(e,t,n){if(e.length==0)return Vt;let o=n?Vt[0]:new Te,i=[o];for(let s=0;s<e.length;s++){let r=e[s].type.attrs;if(r){r.nodeName&&i.push(o=new Te(r.nodeName));for(let l in r){let a=r[l];a!=null&&(n&&i.length==1&&i.push(o=new Te(t.isInline?"span":"div")),l=="class"?o.class=(o.class?o.class+" ":"")+a:l=="style"?o.style=(o.style?o.style+";":"")+a:l!="nodeName"&&(o[l]=a))}}}return i}function Dr(e,t,n,o){if(n==Vt&&o==Vt)return t;let i=t;for(let s=0;s<o.length;s++){let r=o[s],l=n[s];if(s){let a;l&&l.nodeName==r.nodeName&&i!=e&&(a=i.parentNode)&&a.nodeName.toLowerCase()==r.nodeName||(a=document.createElement(r.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=Vt[0]),i=a}Lc(i,l||Vt[0],r)}return i}function Lc(e,t,n){for(let o in t)o!="class"&&o!="style"&&o!="nodeName"&&!(o in n)&&e.removeAttribute(o);for(let o in n)o!="class"&&o!="style"&&o!="nodeName"&&n[o]!=t[o]&&e.setAttribute(o,n[o]);if(t.class!=n.class){let o=t.class?t.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<o.length;s++)i.indexOf(o[s])==-1&&e.classList.remove(o[s]);for(let s=0;s<i.length;s++)o.indexOf(i[s])==-1&&e.classList.add(i[s]);e.classList.length==0&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=o.exec(t.style);)e.style.removeProperty(i[1])}n.style&&(e.style.cssText+=n.style)}}function Er(e,t,n){return Dr(e,e,Vt,xo(t,n,!x(e)))}function Sn(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 _i(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var Jc=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=qc(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,o){let i=0,s=this.stack.length>>1,r=Math.min(s,e.length);for(;i<r&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=et,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1,a=this.top.children.length;o<this.preMatch.index&&(a=Math.min(this.index+3,a));for(let c=this.index;c<a;c++){let h=this.top.children[c];if(h.matchesMark(e[s])&&!this.isLocked(h.dom)){l=c;break}}if(l<0&&this.index<this.top.children.length){let c=this.top.children[this.index];c instanceof Ee&&c.dirty!=it&&c.mark.type==e[s].type&&c.spec.update&&!this.isLocked(c.dom)&&c.spec.update(e[s])&&(c.mark=e[s],l=this.index,this.changed=!0)}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=Ee.create(this.top,e[s],t,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,n,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,n))i=this.top.children.indexOf(s,this.index);else for(let r=this.index,l=Math.min(this.top.children.length,r+5);r<l;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,o,i){let s=this.top.children[o];return s.dirty==it&&s.dom==s.contentDOM&&(s.dirty=Ft),s.update(e,t,n,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==n)return o}return-1}e=t}}updateNextNode(e,t,n,o,i,s){for(let r=this.index;r<this.top.children.length;r++){let l=this.top.children[r];if(l instanceof ie){let a=this.preMatch.matched.get(l);if(a!=null&&a!=i)return!1;let c=l.dom,h,d=this.isLocked(c)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=it&&Sn(t,l.outerDeco));if(!d&&l.update(e,t,n,o))return this.destroyBetween(this.index,r),l.dom!=c&&(this.changed=!0),this.index++,!0;if(!d&&(h=this.recreateWrapper(l,e,t,n,o,s)))return this.destroyBetween(this.index,r),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=Ft,h.updateChildren(o,s+1),h.dirty=et),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,o,i,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Sn(n,e.outerDeco)||!o.eq(e.innerDeco))return null;let r=ie.create(this.top,t,n,o,i,s);if(r.contentDOM){r.children=e.children,e.children=[];for(let l of r.children)l.parent=r}return e.destroy(),r}addNode(e,t,n,o,i){let s=ie.create(this.top,e,t,n,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,n){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new Sr(this.top,e,t,n);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ee;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Mr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((K||z)&&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 o=new Nr(this.top,[],n,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||x(e)&&e.contains(this.lock.parentNode))}};function qc(e,t){let n=t,o=n.children.length,i=e.childCount,s=new Map,r=[];t:for(;i>0;){let l;for(;;)if(o){let c=n.children[o-1];if(c instanceof Ee)n=c,o=c.children.length;else{l=c,o--;break}}else{if(n==t)break t;o=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(i-1))break;--i,s.set(l,i),r.push(l)}}return{index:i,matched:s,matches:r.reverse()}}function Wc(e,t){return e.type.side-t.type.side}function Kc(e,t,n,o){let i=t.locals(e),s=0;if(i.length==0){for(let c=0;c<e.childCount;c++){let h=e.child(c);o(h,i,t.forChild(s,h),c),s+=h.nodeSize}return}let r=0,l=[],a=null;for(let c=0;;){let h,d;for(;r<i.length&&i[r].to==s;){let g=i[r++];g.widget&&(h?(d||(d=[h])).push(g):h=g)}if(h)if(d){d.sort(Wc);for(let g=0;g<d.length;g++)n(d[g],c,!!a)}else n(h,c,!!a);let p,u;if(a)u=-1,p=a,a=null;else if(c<e.childCount)u=c,p=e.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;r<i.length&&i[r].from<=s&&i[r].to>s;)l.push(i[r++]);let f=s+p.nodeSize;if(p.isText){let g=f;r<i.length&&i[r].from<g&&(g=i[r].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<f&&(a=p.cut(g-s),p=p.cut(0,g-s),f=g,u=-1)}else for(;r<i.length&&i[r].to<f;)r++;let m=p.isInline&&!p.isLeaf?l.filter(g=>!g.inline):l.slice();o(p,m,t.forChild(s,p),u),s=f}}function Hc(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 Uc(e,t,n,o){for(let i=0,s=0;i<e.childCount&&s<=o;){let r=e.child(i++),l=s;if(s+=r.nodeSize,!r.isText)continue;let a=r.text;for(;i<e.childCount;){let c=e.child(i++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=n){if(s>=o&&a.slice(o-t.length-l,o-l)==t)return o-t.length;let c=l<o?a.lastIndexOf(t,o-l-1):-1;if(c>=0&&c+t.length+l>=n)return l+c;if(n==o&&a.length>=o+t.length-l&&a.slice(o-l,o-l+t.length)==t)return o}}return-1}function So(e,t,n,o,i){let s=[];for(let r=0,l=0;r<e.length;r++){let a=e[r],c=l,h=l+=a.size;c>=n||h<=t?s.push(a):(c<t&&s.push(a.slice(0,t-c,o)),i&&(s.push(i),i=void 0),h>n&&s.push(a.slice(n-c,a.size,o)))}return s}function Jo(e,t=null){let n=e.domSelectionRange(),o=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),s=i&&i.size==0,r=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(r<0)return null;let l=o.resolve(r),a,c;if(Dn(n)){for(a=r;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&O.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&vc(n.focusNode,n.focusOffset,i.dom))){let d=i.posBefore;c=new O(r==d?l:o.resolve(d))}else if(X&&t=="key"&&r>e.state.selection.to&&x(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&i&&i.posAtStart>e.state.selection.to)for(let d=n.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){c=C.findFrom(o.resolve(i.posAtStart),1);break}if(d==i.dom||d.nextSibling||!d.parentNode||!x(d.parentNode))break}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=r,p=r;for(let u=0;u<n.rangeCount;u++){let f=n.getRangeAt(u);d=Math.min(d,e.docView.posFromDOM(f.startContainer,f.startOffset,1)),p=Math.max(p,e.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(d<0)return null;[a,r]=p==e.state.selection.anchor?[p,d]:[d,p],l=o.resolve(r)}else a=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let h=o.resolve(a);if(!c){let d=t=="pointer"||e.state.selection.head<l.pos&&!s?1:-1;c=qo(e,h,l,d)}return c}function Tr(e){return e.editable?e.hasFocus():Rr(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function bt(e,t=!1){let n=e.state.selection;if($r(e,n),!Tr(e))return;let o=e.input.mouseDown;if(!t&&z&&o){let i=e.domSelectionRange(),s=e.domObserver.currentSelection;if(i.anchorNode&&s.anchorNode&&Kt(i.anchorNode,i.anchorOffset,s.anchorNode,s.anchorOffset)&&o.delaySelUpdate()){e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)Yc(e);else{let{anchor:i,head:s}=n,r,l;Xi&&!(n instanceof N)&&(n.$from.parent.inlineContent||(r=ts(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=ts(e,n.to))),e.docView.setSelection(i,s,e,t),Xi&&(r&&es(r),l&&es(l)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Gc(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}var Xi=K||z&&mr<63;function ts(e,t){let{node:n,offset:o}=e.docView.domFromPos(t,0),i=o<n.childNodes.length?n.childNodes[o]:null,s=o?n.childNodes[o-1]:null;if(K&&i&&i.contentEditable=="false")return Yn(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Yn(i);if(s)return Yn(s)}}function Yn(e){return e.contentEditable="true",K&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function es(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Gc(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),o=n.anchorNode,i=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=o||n.anchorOffset!=i)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!Tr(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function Yc(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,o=n.nodeName=="IMG";o?t.collapse(n.parentNode,B(n)+1):t.collapse(n,0),!o&&!e.state.selection.visible&&_&&Tt<=11&&(n.disabled=!0,n.disabled=!1)}function $r(e,t){if(t instanceof O){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ns(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ns(e)}function ns(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function qo(e,t,n,o){return e.someProp("createSelectionBetween",i=>i(e,t,n))||N.between(t,n,o)}function is(e){return e.editable&&!e.hasFocus()?!1:Rr(e)}function Rr(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return Ht(e.dom,t.anchorNode)&&(e.editable||Ht(e.dom,t.focusNode))}catch{return!1}}function Qc(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Kt(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Oo(e,t){let{$anchor:n,$head:o}=e.selection,i=t>0?n.max(o):n.min(o),s=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return s&&C.findFrom(s,t)}function At(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function ss(e,t,n){let o=e.state.selection;if(o instanceof N)if(n.indexOf("s")>-1){let{$head:i}=o,s=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let r=e.state.doc.resolve(i.pos+s.nodeSize*(t<0?-1:1));return At(e,new N(o.$anchor,r))}else if(o.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let i=Oo(e.state,t);return i&&i instanceof O?At(e,i):!1}else if(!(tt&&n.indexOf("m")>-1)){let i=o.$head,s=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter,r;if(!s||s.isText)return!1;let l=t<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(r=e.docView.descAt(l))&&!r.contentDOM?O.isSelectable(s)?At(e,new O(t<0?e.state.doc.resolve(i.pos-s.nodeSize):i)):At(e,new N(e.state.doc.resolve(t<0?l:l+s.nodeSize))):!1}}else return!1;else{if(o instanceof O&&o.node.isInline)return At(e,new N(t>0?o.$to:o.$from));{let i=Oo(e.state,t);return i?At(e,i):!1}}}function $e(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR"):x(e)&&e.contentEditable=="false"}function Zt(e,t){return t<0?Zc(e):_c(e)}function Zc(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let i,s,r=!1;for(X&&x(n)&&o<q(n)&&$e(n.childNodes[o],-1)&&(r=!0);;)if(o>0){if(!x(n))break;let l=n.childNodes[o-1];if($e(l,-1))i=n,s=--o;else if(I(l))n=l,o=n.nodeValue.length;else break}else{if(Ir(n))break;{let l=n.previousSibling;for(;l&&$e(l,-1);)i=n.parentNode,s=B(l),l=l.previousSibling;if(l)n=l,o=q(n);else{if(n=n.parentNode,n==e.dom)break;o=0}}}r?Mo(e,n,o):i&&Mo(e,i,s)}function _c(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let i=q(n),s,r;for(;;)if(o<i){if(!x(n))break;let l=n.childNodes[o];if($e(l,1))s=n,r=++o;else break}else{if(Ir(n))break;{let l=n.nextSibling;for(;l&&$e(l,1);)s=l.parentNode,r=B(l)+1,l=l.nextSibling;if(l)n=l,o=0,i=q(n);else{if(n=n.parentNode,n==e.dom)break;o=i=0}}}s&&Mo(e,s,r)}function Ir(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Xc(e,t){for(;e&&t==e.childNodes.length&&!We(e);)t=B(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(I(n))return n;if(x(n)&&n.contentEditable=="false")break;e=n,t=0}}function th(e,t){for(;e&&!t&&!We(e);)t=B(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(I(n))return n;if(x(n)&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function Mo(e,t,n){if(!I(t)){let s,r;(r=Xc(t,n))?(t=r,n=0):(s=th(t,n))&&(t=s,n=s.nodeValue.length)}let o=e.domSelection();if(!o)return;if(Dn(o)){let s=document.createRange();s.setEnd(t,n),s.setStart(t,n),o.removeAllRanges(),o.addRange(s)}else o.extend&&o.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&bt(e)},50)}function rs(e,t){let n=e.state.doc.resolve(t);if(!(z||gr)&&n.parent.inlineContent){let o=e.coordsAtPos(t);if(t>n.start()){let i=e.coordsAtPos(t-1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(t<n.end()){let i=e.coordsAtPos(t+1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function ls(e,t,n){let o=e.state.selection;if(o instanceof N&&!o.empty||n.indexOf("s")>-1||tt&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=o;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let r=Oo(e.state,t);if(r&&r instanceof O)return At(e,r)}if(!i.parent.inlineContent){let r=t<0?i:s,l=o instanceof at?C.near(r,t):C.findFrom(r,t);return l?At(e,l):!1}return!1}function as(e,t){if(!(e.state.selection instanceof N))return!0;let{$head:n,$anchor:o,empty:i}=e.state.selection;if(!n.sameParent(o))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let s=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=e.state.tr;return t<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),e.dispatch(r),!0}return!1}function cs(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function eh(e){if(!K||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&x(t)&&n==0&&t.firstChild&&x(t.firstChild)&&t.firstChild.contentEditable=="false"){let o=t.firstChild;cs(e,o,"true"),setTimeout(()=>cs(e,o,"false"),20)}return!1}function nh(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function oh(e,t){let n=t.keyCode,o=nh(t);if(n==8||tt&&n==72&&o=="c")return as(e,-1)||Zt(e,-1);if(n==46&&!t.shiftKey||tt&&n==68&&o=="c")return as(e,1)||Zt(e,1);if(n==13||n==27)return!0;if(n==37||tt&&n==66&&o=="c"){let i=n==37?rs(e,e.state.selection.from)=="ltr"?-1:1:-1;return ss(e,i,o)||Zt(e,i)}else if(n==39||tt&&n==70&&o=="c"){let i=n==39?rs(e,e.state.selection.from)=="ltr"?1:-1:1;return ss(e,i,o)||Zt(e,i)}else{if(n==38||tt&&n==80&&o=="c")return ls(e,-1,o)||Zt(e,-1);if(n==40||tt&&n==78&&o=="c")return eh(e)||ls(e,1,o)||Zt(e,1);if(o==(tt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Wo(e,t){e.someProp("transformCopied",u=>{t=u(t,e)});let n=[],{content:o,openStart:i,openEnd:s}=t;for(;i>1&&s>1&&o.childCount==1&&o.firstChild.childCount==1;){i--,s--;let u=o.firstChild;n.push(u.type.name,u.attrs!=u.type.defaultAttrs?u.attrs:null),o=u.content}let r=e.someProp("clipboardSerializer")||Le.fromSchema(e.state.schema),l=Vr(),a=l.createElement("div");a.appendChild(r.serializeFragment(o,{document:l}));let c=a.firstChild,h,d=0;for(;c&&x(c)&&(h=Fr[c.nodeName.toLowerCase()]);){for(let u=h.length-1;u>=0;u--){let f=l.createElement(h[u]);for(;a.firstChild;)f.appendChild(a.firstChild);a.appendChild(f),d++}c=a.firstChild}c&&x(c)&&c.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let p=e.someProp("clipboardTextSerializer",u=>u(t,e))||t.content.textBetween(0,t.content.size,`
7
+
8
+ `);return{dom:a,text:p,slice:t}}function Ko(e,t,n,o,i){let s=i.parent.type.spec.code,r,l;if(!n&&!t)return null;let a=!!t&&(o||s||!n);if(a){if(e.someProp("transformPastedText",p=>{t=p(t,s||o,e)}),s)return l=new k(v.from(e.state.schema.text(t.replace(/\r\n?/g,`
9
+ `))),0,0),e.someProp("transformPasted",p=>{l=p(l,e,!0)}),l;let d=e.someProp("clipboardTextParser",p=>p(t,i,o,e));if(d)l=d;else{let p=i.marks(),{schema:u}=e.state,f=Le.fromSchema(u);r=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=r.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(u.text(m,p)))})}}else e.someProp("transformPastedHTML",d=>{n=d(n,e)}),r=lh(n),En&&ah(r);let c=r&&r.querySelector("[data-pm-slice]"),h=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let d=+h[3];d>0;d--){let p=r.firstChild;for(;p&&!x(p);)p=p.nextSibling;if(!p)break;r=p}if(l||(l=(e.someProp("clipboardParser")||e.someProp("domParser")||Eo.fromSchema(e.state.schema)).parseSlice(r,{preserveWhitespace:!!(a||h),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!ih.test(d.parentNode.nodeName)?{ignore:!0}:null}})),h)l=ch(hs(l,+h[1],+h[2]),h[4]);else if(l=k.maxOpen(sh(l.content,i),!0),l.openStart||l.openEnd){let d=0,p=0;for(let u=l.content.firstChild;d<l.openStart&&!u.type.spec.isolating;d++,u=u.firstChild);for(let u=l.content.lastChild;p<l.openEnd&&!u.type.spec.isolating;p++,u=u.lastChild);l=hs(l,d,p)}return e.someProp("transformPasted",d=>{l=d(l,e,a)}),l}var ih=/^(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 sh(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let o=t.node(n).contentMatchAt(t.index(n)),i,s=[];if(e.forEach(r=>{if(!s)return;let l=o.findWrapping(r.type),a;if(!l)return s=null;if(a=s.length&&i.length&&Br(l,i,r,s[s.length-1],0))s[s.length-1]=a;else{s.length&&(s[s.length-1]=zr(s[s.length-1],i.length));let c=Pr(r,l);s.push(c),o=o.matchType(c.type),i=l}}),s)return v.from(s)}return e}function Pr(e,t,n=0){for(let o=t.length-1;o>=n;o--)e=t[o].create(null,v.from(e));return e}function Br(e,t,n,o,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let s=Br(e,t,n,o.lastChild,i+1);if(s)return o.copy(o.content.replaceChild(o.childCount-1,s));if(o.contentMatchAt(o.childCount).matchType(i==e.length-1?n.type:e[i+1]))return o.copy(o.content.append(v.from(Pr(n,e,i+1))))}}function zr(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,zr(e.lastChild,t-1)),o=e.contentMatchAt(e.childCount).fillBefore(v.empty,!0);return e.copy(n.append(o))}function Co(e,t,n,o,i,s){let r=t<0?e.firstChild:e.lastChild,l=r.content;return e.childCount>1&&(s=0),i<o-1&&(l=Co(l,t,n,o,i+1,s)),i>=n&&(l=t<0?r.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(r.contentMatchAt(r.childCount).fillBefore(v.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,r.copy(l))}function hs(e,t,n){return t<e.openStart&&(e=new k(Co(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new k(Co(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var Fr={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Vr(){return document.implementation.createHTMLDocument("title")}var me=null;function rh(e){let t=window.trustedTypes;if(!t)return e;if(!me){if(me=t.defaultPolicy)try{return me.createHTML(e)}catch{}me=t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return me.createHTML(e)}function lh(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=Vr(),o=n.body,i=/<([a-z][^>\s]+)/i.exec(e),s;if((s=i&&Fr[i[1].toLowerCase()])&&(e=s.map(r=>"<"+r+">").join("")+e+s.map(r=>"</"+r+">").reverse().join("")),o.innerHTML=rh(e),s)for(let r=0;r<s.length;r++)o=o.querySelector(s[r])||o;for(let r=0;r<n.styleSheets.length;r++){let l=n.styleSheets[r];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let h=o.querySelectorAll(c.selectorText);for(let d=0;d<h.length;d++)h[d].style.cssText+=c.style.cssText}}}return o}function ah(e){let t=e.querySelectorAll(z?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let o=t[n];o.childNodes.length==1&&o.textContent=="\xA0"&&o.parentNode&&o.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),o)}}function ch(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,o;try{o=JSON.parse(t)}catch{return e}let{content:i,openStart:s,openEnd:r}=e;for(let l=o.length-2;l>=0;l-=2){let a=n.nodes[o[l]];if(!a||a.hasRequiredAttrs())break;try{i=v.from(a.create(o[l+1],i))}catch{break}s++,r++}return new k(i,s,r)}var G={},Y={},hh={touchstart:!0,touchmove:!0},dh=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 fh(e){for(let t in G){let n=G[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=o=>{uh(e,o)&&!Ho(e,o)&&(e.editable||!(o.type in Y))&&n(e,o)},hh[t]?{passive:!0}:void 0)}K&&e.dom.addEventListener("input",()=>null),No(e)}function wt(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function ph(e){e.input.mouseDown&&e.input.mouseDown.done(),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 No(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=o=>Ho(e,o))})}function Ho(e,t){return e.someProp("handleDOMEvents",n=>{let o=n[t.type];return o?o(e,t)||t.defaultPrevented:!1})}function uh(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 mh(e,t){!Ho(e,t)&&G[t.type]&&(e.editable||!(t.type in Y))&&G[t.type](e,t)}Y.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!qr(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(yt&&z&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),ae&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let o=Date.now();e.input.lastIOSEnter=o,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==o&&(e.someProp("handleKeyDown",i=>i(e,zt(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",o=>o(e,n))||oh(e,n)?n.preventDefault():wt(e,"key")};Y.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};Y.keypress=(e,t)=>{let n=t;if(qr(e)||!n.charCode||n.ctrlKey&&!n.altKey||tt&&n.metaKey)return;if(e.someProp("handleKeyPress",i=>i(e,n))){n.preventDefault();return}let o=e.state.selection;if(!(o instanceof N)||!o.$from.sameParent(o.$to)){let i=String.fromCharCode(n.charCode),s=()=>e.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!e.someProp("handleTextInput",r=>r(e,o.$from.pos,o.$to.pos,i,s))&&e.dispatch(s()),n.preventDefault()}};function He(e){return{left:e.clientX,top:e.clientY}}function gh(e,t){let n=t.x-e.clientX,o=t.y-e.clientY;return n*n+o*o<100}function Uo(e,t,n,o,i){if(o==-1)return!1;let s=e.state.doc.resolve(o);for(let r=s.depth+1;r>0;r--)if(e.someProp(t,l=>r>s.depth?l(e,n,s.nodeAfter,s.before(r),i,!0):l(e,n,s.node(r),s.before(r),i,!1)))return!0;return!1}function Ue(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let o=e.state.tr.setSelection(t);o.setMeta("pointer",!0),e.dispatch(o)}function yh(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),o=n.nodeAfter;return o&&o.isAtom&&O.isSelectable(o)?(Ue(e,new O(n)),!0):!1}function wh(e,t){if(t==-1)return!1;let n=e.state.selection,o,i;n instanceof O&&(o=n.node);let s=e.state.doc.resolve(t);for(let r=s.depth+1;r>0;r--){let l=r>s.depth?s.nodeAfter:s.node(r);if(O.isSelectable(l)){o&&n.$from.depth>0&&r>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(r);break}}return i!=null?(Ue(e,O.create(e.state.doc,i)),!0):!1}function bh(e,t,n,o,i){return Uo(e,"handleClickOn",t,n,o)||e.someProp("handleClick",s=>s(e,t,o))||(i?wh(e,n):yh(e,n))}function vh(e,t,n,o){return Uo(e,"handleDoubleClickOn",t,n,o)||e.someProp("handleDoubleClick",i=>i(e,t,o))}function kh(e,t,n,o){return Uo(e,"handleTripleClickOn",t,n,o)||e.someProp("handleTripleClick",i=>i(e,t,o))||xh(e,n,o)}function xh(e,t,n){if(n.button!=0)return!1;let o=jr(e,t,!0),i=e.state.doc;return o?(Ue(e,o),o instanceof N&&i.eq(e.state.doc)&&(e.input.mouseDown=new Oh(e,o)),!0):!1}function jr(e,t,n){let o=e.state.doc;if(t==-1)return o.inlineContent?N.create(o,0,o.content.size):null;let i=o.resolve(t);for(let s=i.depth+1;s>0;s--){let r=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(r.inlineContent)return N.create(o,l+1,l+1+r.content.size);if(n&&O.isSelectable(r))return O.create(o,l)}return null}function Go(e){return Be(e)}var Lr=tt?"metaKey":"ctrlKey";G.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let o=Go(e),i=Date.now(),s="singleClick";i-e.input.lastClick.time<500&&gh(n,e.input.lastClick)&&!n[Lr]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?s="doubleClick":e.input.lastClick.type=="doubleClick"&&(s="tripleClick")),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let r=e.posAtCoords(He(n));r&&(s=="singleClick"?e.input.mouseDown=new Sh(e,r,n,!!o):(s=="doubleClick"?vh:kh)(e,r.pos,r.inside,n)?n.preventDefault():wt(e,"pointer"))};var Jr=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Sh=class extends Jr{constructor(e,t,n,o){super(e),this.pos=t,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[Lr],this.allowDefault=n.shiftKey;let i,s;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),s=t.inside;else{let c=e.state.doc.resolve(t.pos);i=c.parent,s=c.depth?c.before():0}let r=o?null:n.target,l=r?e.docView.nearestDesc(r,!0):null;this.target=l&&x(l.nodeDOM)?l.nodeDOM:null;let{selection:a}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||a instanceof O&&a.from<=s&&a.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&X&&!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()),wt(e,"pointer")}done(){super.done(),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(()=>{this.view.isDestroyed||bt(this.view)})}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(He(e))),this.updateAllowDefault(e),this.allowDefault||!t?wt(this.view,"pointer"):bh(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||K&&this.mightDrag&&!this.mightDrag.node.isAtom||z&&!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)?(Ue(this.view,C.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):wt(this.view,"pointer")}move(e){this.updateAllowDefault(e),wt(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Oh=class extends Jr{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),wt(this.view,"pointer");let t=this.view.posAtCoords(He(e)),n=t&&jr(this.view,t.inside,!1);if(!n)return;let{doc:o}=this.view.state,i=this.startSelection,[s,r]=n.from<i.from?[i.to,n.from]:[i.from,n.to];Ue(this.view,N.create(o,s,r))}};G.touchstart=e=>{e.input.lastTouch=Date.now(),Go(e),wt(e,"pointer")};G.touchmove=e=>{e.input.lastTouch=Date.now(),wt(e,"pointer")};G.contextmenu=e=>Go(e);function qr(e,t){return e.composing?!0:K&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Mh=yt?5e3:-1;Y.compositionstart=Y.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof N&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)||z&&gr&&Ch(e)))e.markCursor=e.state.storedMarks||n.marks(),Be(e,!0),e.markCursor=null;else if(Be(e,!t.selection.empty),X&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let o=e.domSelectionRange();for(let i=o.focusNode,s=o.focusOffset;i&&x(i)&&s!=0;){let r=s<0?i.lastChild:i.childNodes[s-1];if(!r)break;if(I(r)){let l=e.domSelection();l&&l.collapse(r,r.nodeValue.length);break}else i=r,s=-1}}e.input.composing=!0}Wr(e,Mh)};function Ch(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!x(t)||n>=t.childNodes.length)return!1;let o=t.childNodes[n];return x(o)&&o.contentEditable=="false"}Y.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),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++,Wr(e,20))};function Wr(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Be(e),t))}function Kr(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Nh(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=wc(t.focusNode,t.focusOffset),o=bc(t.focusNode,t.focusOffset);if(n&&o&&n!=o){let i=o.pmViewDesc,s=e.domObserver.lastChangedTextNode;if(n==s||o==s)return s;if(!i||!i.isText(o.nodeValue))return o;if(e.input.compositionNode==o){let r=n.pmViewDesc;if(!(!r||!r.isText(n.nodeValue)))return o}}return n||o}function Be(e,t=!1){if(!(yt&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Kr(e),t||e.docView&&e.docView.dirty){let n=Jo(e),o=e.state.selection;return n&&!n.eq(o)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Ah(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 o=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),o.removeAllRanges(),o.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var ze=_&&Tt<15||ae&&Sc<604;G.copy=Y.cut=(e,t)=>{let n=t,o=e.state.selection,i=n.type=="cut";if(o.empty)return;let s=ze?null:n.clipboardData,r=o.content(),{dom:l,text:a}=Wo(e,r);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Ah(e,l),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Dh(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Eh(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,o=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),o.parentNode&&o.parentNode.removeChild(o),n?Fe(e,o.value,null,i,t):Fe(e,o.textContent,o.innerHTML,i,t)},50)}function Fe(e,t,n,o,i){let s=Ko(e,t,n,o,e.state.selection.$from);if(e.someProp("handlePaste",a=>a(e,i,s||k.empty)))return!0;if(!s)return!1;let r=Dh(s),l=r?e.state.tr.replaceSelectionWith(r,o):e.state.tr.replaceSelection(s);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Hr(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," "):""}Y.paste=(e,t)=>{let n=t;if(e.composing&&!yt)return;let o=ze?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;o&&Fe(e,Hr(o),o.getData("text/html"),i,n)?n.preventDefault():Eh(e,n)};var Ur=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Th=tt?"altKey":"ctrlKey";function Gr(e,t){let n;return e.someProp("dragCopies",o=>{n=n||o(t)}),n!=null?!n:!t[Th]}G.dragstart=(e,t)=>{let n=t,o=e.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let i=e.state.selection,s=i.empty?null:e.posAtCoords(He(n)),r;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof O?i.to-1:i.to))){if(o&&o.mightDrag)r=O.create(e.state.doc,o.mightDrag.pos);else if(n.target&&x(n.target)){let d=e.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=e.docView&&(r=O.create(e.state.doc,d.posBefore))}}let l=(r||e.state.selection).content(),{dom:a,text:c,slice:h}=Wo(e,l);(!n.dataTransfer.files.length||!z||mr>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ze?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",ze||n.dataTransfer.setData("text/plain",c),e.dragging=new Ur(h,Gr(e,n),r)};G.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};Y.dragover=Y.dragenter=(e,t)=>t.preventDefault();Y.drop=(e,t)=>{try{$h(e,t,e.dragging)}finally{e.dragging=null}};function $h(e,t,n){if(!t.dataTransfer)return;let o=e.posAtCoords(He(t));if(!o)return;let i=e.state.doc.resolve(o.pos),s=n&&n.slice;s?e.someProp("transformPasted",u=>{s=u(s,e,!1)}):s=Ko(e,Hr(t.dataTransfer),ze?null:t.dataTransfer.getData("text/html"),!1,i);let r=!!(n&&Gr(e,t));if(e.someProp("handleDrop",u=>u(e,t,s||k.empty,r))){t.preventDefault();return}if(!s)return;t.preventDefault();let l=s?zo(e.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=e.state.tr;if(r){let{node:u}=n;u?u.replace(a):a.deleteSelection()}let c=a.mapping.map(l),h=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=a.doc;if(h?a.replaceRangeWith(c,c,s.content.firstChild):a.replaceRange(c,c,s),a.doc.eq(d))return;let p=a.doc.resolve(c);if(h&&O.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new O(p));else{let u=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((f,m,g,b)=>u=b),a.setSelection(qo(e,p,a.doc.resolve(u)))}e.focus(),e.dispatch(a.setMeta("uiEvent","drop"))}G.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())&&bt(e)},20))};G.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(),e.focused=!1)};G.beforeinput=(e,t)=>{if(yt&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:n}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=n||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",i=>i(e,zt(8,"Backspace")))))return;let{$cursor:o}=e.state.selection;o&&o.pos>0&&e.dispatch(e.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let e in Y)G[e]=Y[e];function Ve(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 ds=class Yr{constructor(t,n){this.toDOM=t,this.spec=n||Jt,this.side=this.spec.side||0}map(t,n,o,i){let{pos:s,deleted:r}=t.mapResult(n.from+i,this.side<0?-1:1);return r?null:new Pt(s-o,s-o,this)}valid(){return!0}eq(t){return this==t||t instanceof Yr&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Ve(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}},Re=class Ao{constructor(t,n){this.attrs=t,this.spec=n||Jt}map(t,n,o,i){let s=t.map(n.from+i,this.spec.inclusiveStart?-1:1)-o,r=t.map(n.to+i,this.spec.inclusiveEnd?1:-1)-o;return s>=r?null:new Pt(s,r,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof Ao&&Ve(this.attrs,t.attrs)&&Ve(this.spec,t.spec)}static is(t){return t.type instanceof Ao}destroy(){}},Rh=class Qr{constructor(t,n){this.attrs=t,this.spec=n||Jt}map(t,n,o,i){let s=t.mapResult(n.from+i,1);if(s.deleted)return null;let r=t.mapResult(n.to+i,-1);return r.deleted||r.pos<=s.pos?null:new Pt(s.pos-o,r.pos-o,this)}valid(t,n){let{index:o,offset:i}=t.content.findIndex(n.from),s;return i==n.from&&!(s=t.child(o)).isText&&i+s.nodeSize==n.to}eq(t){return this==t||t instanceof Qr&&Ve(this.attrs,t.attrs)&&Ve(this.spec,t.spec)}destroy(){}},Pt=class Ce{constructor(t,n,o){this.from=t,this.to=n,this.type=o}copy(t,n){return new Ce(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,o){return this.type.map(t,this,n,o)}static widget(t,n,o){return new Ce(t,t,new ds(n,o))}static inline(t,n,o,i){return new Ce(t,n,new Re(o,i))}static node(t,n,o,i){return new Ce(t,n,new Rh(o,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Re}get widget(){return this.type instanceof ds}},ee=[],Jt={},nt=class Ct{constructor(t,n){this.local=t.length?t:ee,this.children=n.length?n:ee}static create(t,n){return n.length?On(n,t,0,Jt):J}find(t,n,o){let i=[];return this.findInner(t??0,n??1e9,i,0,o),i}findInner(t,n,o,i,s){for(let r=0;r<this.local.length;r++){let l=this.local[r];l.from<=n&&l.to>=t&&(!s||s(l.spec))&&o.push(l.copy(l.from+i,l.to+i))}for(let r=0;r<this.children.length;r+=3)if(this.children[r]<n&&this.children[r+1]>t){let l=this.children[r]+1;this.children[r+2].findInner(t-l,n-l,o,i+l,s)}}map(t,n,o){return this==J||t.maps.length==0?this:this.mapInner(t,n,0,0,o||Jt)}mapInner(t,n,o,i,s){let r;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(t,o,i);a&&a.type.valid(n,a)?(r||(r=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Ih(this.children,r||[],t,n,o,i,s):r?new Ct(r.sort(qt),ee):J}add(t,n){return n.length?this==J?Ct.create(t,n):this.addInner(t,n,0):this}addInner(t,n,o){let i,s=0;t.forEach((l,a)=>{let c=a+o,h;if(h=Xr(n,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,h,c+1):i.splice(s,0,a,a+l.nodeSize,On(h,l,c+1,Jt)),s+=3}});let r=_r(s?tl(n):n,-o);for(let l=0;l<r.length;l++)r[l].type.valid(t,r[l])||r.splice(l--,1);return new Ct(r.length?this.local.concat(r).sort(qt):this.local,i||this.children)}remove(t){return t.length==0||this==J?this:this.removeInner(t,0)}removeInner(t,n){let o=this.children,i=this.local;for(let s=0;s<o.length;s+=3){let r,l=o[s]+n,a=o[s+1]+n;for(let h=0,d;h<t.length;h++)(d=t[h])&&d.from>l&&d.to<a&&(t[h]=null,(r||(r=[])).push(d));if(!r)continue;o==this.children&&(o=this.children.slice());let c=o[s+2].removeInner(r,l+1);c!=J?o[s+2]=c:(o.splice(s,3),s-=3)}if(i.length){for(let s=0,r;s<t.length;s++)if(r=t[s])for(let l=0;l<i.length;l++)i[l].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return o==this.children&&i==this.local?this:i.length||o.length?new Ct(i,o):J}forChild(t,n){if(this==J)return this;if(n.isLeaf)return Ct.empty;let o,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=t){this.children[l]==t&&(o=this.children[l+2]);break}let s=t+1,r=s+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<r&&a.to>s&&a.type instanceof Re){let c=Math.max(s,a.from)-s,h=Math.min(r,a.to)-s;c<h&&(i||(i=[])).push(a.copy(c,h))}}if(i){let l=new Ct(i.sort(qt),ee);return o?new Zr([l,o]):l}return o||J}eq(t){if(this==t)return!0;if(!(t instanceof Ct)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return Yo(this.localsInner(t))}localsInner(t){if(this==J)return ee;if(t.inlineContent||!this.local.some(Re.is))return this.local;let n=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof Re||n.push(this.local[o]);return n}forEachSet(t){t(this)}};nt.empty=new nt([],[]);nt.removeOverlap=Yo;var J=nt.empty,Zr=class ne{constructor(t){this.members=t}map(t,n){let o=this.members.map(i=>i.map(t,n,Jt));return ne.from(o)}forChild(t,n){if(n.isLeaf)return nt.empty;let o=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(t,n);s!=J&&(s instanceof ne?o=o.concat(s.members):o.push(s))}return ne.from(o)}eq(t){if(!(t instanceof ne)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,o=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(t);if(s.length)if(!n)n=s;else{o&&(n=n.slice(),o=!1);for(let r=0;r<s.length;r++)n.push(s[r])}}return n?Yo(o?n:n.sort(qt)):ee}static from(t){switch(t.length){case 0:return J;case 1:return t[0];default:return new ne(t.every(n=>n instanceof nt)?t:t.reduce((n,o)=>n.concat(o instanceof nt?o:o.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}};function Ih(e,t,n,o,i,s,r){let l=e.slice();for(let c=0,h=s;c<n.maps.length;c++){let d=0;n.maps[c].forEach((p,u,f,m)=>{let g=m-f-(u-p);for(let b=0;b<l.length;b+=3){let y=l[b+1];if(y<0||p>y+h-d)continue;let w=l[b]+h-d;u>=w?l[b+1]=p<=w?-2:-1:p>=h&&g&&(l[b]+=g,l[b+1]+=g)}d+=g}),h=n.maps[c].map(h,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let h=n.map(e[c]+s),d=h-i;if(d<0||d>=o.content.size){a=!0;continue}let p=n.map(e[c+1]+s,-1),u=p-i,{index:f,offset:m}=o.content.findIndex(d),g=o.maybeChild(f);if(g&&m==d&&m+g.nodeSize==u){let b=l[c+2].mapInner(n,g,h+1,e[c]+s+1,r);b!=J?(l[c]=d,l[c+1]=u,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Ph(l,e,t,n,i,s,r),h=On(c,o,0,r);t=h.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,p=0;d<h.children.length;d+=3){let u=h.children[d];for(;p<l.length&&l[p]<u;)p+=3;l.splice(p,0,h.children[d],h.children[d+1],h.children[d+2])}}return new nt(t.sort(qt),l)}function _r(e,t){if(!t||!e.length)return e;let n=[];for(let o=0;o<e.length;o++){let i=e[o];n.push(new Pt(i.from+t,i.to+t,i.type))}return n}function Ph(e,t,n,o,i,s,r){function l(a,c){for(let h=0;h<a.local.length;h++){let d=a.local[h].map(o,i,c);d?n.push(d):r.onRemove&&r.onRemove(a.local[h].spec)}for(let h=0;h<a.children.length;h+=3)l(a.children[h+2],a.children[h]+c+1)}for(let a=0;a<e.length;a+=3)e[a+1]==-1&&l(e[a+2],t[a]+s+1);return n}function Xr(e,t,n){if(t.isLeaf)return null;let o=n+t.nodeSize,i=null;for(let s=0,r;s<e.length;s++)(r=e[s])&&r.from>n&&r.to<o&&((i||(i=[])).push(r),e[s]=null);return i}function tl(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function On(e,t,n,o){let i=[],s=!1;t.forEach((l,a)=>{let c=Xr(e,l,a+n);if(c){s=!0;let h=On(c,l,n+a+1,o);h!=J&&i.push(a,a+l.nodeSize,h)}});let r=_r(s?tl(e):e,-n).sort(qt);for(let l=0;l<r.length;l++)r[l].type.valid(t,r[l])||(o.onRemove&&o.onRemove(r[l].spec),r.splice(l--,1));return r.length||i.length?new nt(r,i):J}function qt(e,t){return e.from-t.from||e.to-t.to}function Yo(e){let t=e;for(let n=0;n<t.length-1;n++){let o=t[n];if(o.from!=o.to)for(let i=n+1;i<t.length;i++){let s=t[i];if(s.from==o.from){s.to!=o.to&&(t==e&&(t=e.slice()),t[i]=s.copy(s.from,o.to),fs(t,i+1,s.copy(o.to,s.to)));continue}else{s.from<o.to&&(t==e&&(t=e.slice()),t[n]=o.copy(o.from,s.from),fs(t,i,o.copy(s.from,o.to)));break}}}return t}function fs(e,t,n){for(;t<e.length&&qt(n,e[t])>0;)t++;e.splice(t,0,n)}function Qn(e){let t=[];return e.someProp("decorations",n=>{let o=n(e.state);o&&o!=J&&t.push(o)}),e.cursorWrapper&&t.push(nt.create(e.state.doc,[e.cursorWrapper.deco])),Zr.from(t)}var Bh={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},zh=_&&Tt<=11,Fh=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}},Vh=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Fh,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let o=0;o<n.length;o++)this.queue.push(n[o]);_&&Tt<=11&&n.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():K&&e.composing&&n.some(o=>o.type=="childList"&&o.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),zh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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,Bh)),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(is(this.view)){if(this.suppressingSelectionUpdates)return bt(this.view);if(_&&Tt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Kt(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 i=e.focusNode;i;i=le(i))t.add(i);for(let i=e.anchorNode;i;i=le(i))if(t.has(i)){n=i;break}let o=n&&this.view.docView.nearestDesc(n);if(o&&o.ignoreMutation({type:"selection",target:I(n)?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(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&is(e)&&!this.ignoreSelectionChange(n),i=-1,s=-1,r=!1,l=[];if(e.editable)for(let c=0;c<t.length;c++){let h=this.registerMutation(t[c],l);h&&(i=i<0?h.from:Math.min(h.from,i),s=s<0?h.to:Math.max(h.to,s),h.typeOver&&(r=!0))}if(l.some(c=>c.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||z&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(c=>c.type=="childList"&&c.removedNodes.length))){for(let c of l)if(c.nodeName=="BR"&&c.parentNode){let h=c.nextSibling;for(;h&&x(h);){if(h.contentEditable=="false"){c.parentNode.removeChild(c);break}h=h.firstChild}}}else if(X&&l.length){let c=l.filter(h=>h.nodeName=="BR");if(c.length==2){let[h,d]=c;h.parentNode&&h.parentNode.parentNode==d.parentNode?d.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let d of c){let p=d.parentNode;p&&p.nodeName=="LI"&&(!h||Jh(e,h)!=p)&&d.remove()}}}let a=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Dn(n)&&(a=Jo(e))&&a.eq(C.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,bt(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,s),jh(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,qh(e,l)),this.handleDOMChange(i,s,r,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||bt(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 c=0;c<e.addedNodes.length;c++){let h=e.addedNodes[c];t.push(h),I(h)&&(this.lastChangedTextNode=h)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let o=e.previousSibling,i=e.nextSibling;if(_&&Tt<=11&&e.addedNodes.length)for(let c=0;c<e.addedNodes.length;c++){let{previousSibling:h,nextSibling:d}=e.addedNodes[c];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(o=h),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d)}let s=o&&o.parentNode==e.target?B(o)+1:0,r=n.localPosFromDOM(e.target,s,-1),l=i&&i.parentNode==e.target?B(i):e.target.childNodes.length,a=n.localPosFromDOM(e.target,l,1);return{from:r,to:a}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},ps=new WeakMap,us=!1;function jh(e){if(!ps.has(e)&&(ps.set(e,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=X,us)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."),us=!0}}function ms(e,t){let n=t.startContainer,o=t.startOffset,i=t.endContainer,s=t.endOffset,r=e.domAtPos(e.state.selection.anchor);return Kt(r.node,r.offset,i,s)&&([n,o,i,s]=[i,s,n,o]),{anchorNode:n,anchorOffset:o,focusNode:i,focusOffset:s}}function Lh(e,t){if(t.getComposedRanges){let i=t.getComposedRanges(e.root)[0];if(i)return ms(e,i)}let n;function o(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",o,!0),n?ms(e,n):null}function Jh(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let o=e.docView.nearestDesc(n,!0);if(o&&o.node.isBlock)return n}return null}function qh(e,t){var n;let{focusNode:o,focusOffset:i}=e.domSelectionRange();for(let s of t)if(((n=s.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let r=s.nextSibling;for(;r&&r.nodeName!="TD"&&r.nodeName!="TH";)r=r.nextSibling;if(r){let l=r;for(;;){let a=l.firstChild;if(!a||!x(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),o==s&&e.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function Wh(e,t,n,o){let{node:i,fromOffset:s,toOffset:r,from:l,to:a}=e.docView.parseRange(t,n),c=e.domSelectionRange(),h,d=c.anchorNode;if(d&&Ht(e.dom,d)&&(h=[{node:d,offset:c.anchorOffset}],Dn(c)||h.push({node:c.focusNode,offset:c.focusOffset})),z&&e.input.lastKeyCode===8)for(let b=r;b>s;b--){let y=i.childNodes[b-1],w=y.pmViewDesc;if(y.nodeName=="BR"&&!w){r=b;break}if(!w||w.size)break}let p=e.state.doc,u=e.someProp("domParser")||Eo.fromSchema(e.state.schema),f=p.resolve(l),m=null,g=u.parse(i,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:r,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:Kh(o),context:f});if(h&&h[0].pos!=null){let b=h[0].pos,y=h[1]&&h[1].pos;y==null&&(y=b),m={anchor:b+l,head:y+l}}return{doc:g,sel:m,from:l,to:a}}var Kh=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName=="BR"&&t.parentNode){if(K&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let o=document.createElement("div");return o.appendChild(document.createElement("li")),{skip:o}}else if(t.parentNode.lastChild==t||K&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null},Hh=/^(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 Uh(e,t,n,o,i){let s=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let M=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,D=Jo(e,M);if(D&&!e.state.selection.eq(D)){if(z&&yt&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",ya=>ya(e,zt(13,"Enter"))))return;let P=e.state.tr.setSelection(D);M=="pointer"?P.setMeta("pointer",!0):M=="key"&&P.scrollIntoView(),s&&P.setMeta("composition",s),e.dispatch(P)}return}let r=e.state.doc.resolve(t),l=r.sharedDepth(n);t=r.before(l+1),n=e.state.doc.resolve(n).after(l+1);let a=e.state.selection,c=Wh(e,t,n,i),h=e.state.doc,d=h.slice(c.from,c.to),p,u;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(p=e.state.selection.to,u="end"):(p=e.state.selection.from,u="start"),e.input.lastKeyCode=null;let f=Zh(d.content,c.doc.content,c.from,p,u);if(f&&e.input.domChangeCount++,(ae&&e.input.lastIOSEnter>Date.now()-225||yt)&&i.some(M=>x(M)&&!Hh.test(M.nodeName))&&(!f||f.endA>=f.endB)&&e.someProp("handleKeyDown",M=>M(e,zt(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!f)if(o&&a instanceof N&&!a.empty&&a.$head.sameParent(a.$anchor)&&!e.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))f={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let M=gs(e,e.state.doc,c.sel);if(M&&!M.eq(e.state.selection)){let D=e.state.tr.setSelection(M);s&&D.setMeta("composition",s),e.dispatch(D)}}return}e.state.selection.from<e.state.selection.to&&f.start==f.endB&&e.state.selection instanceof N&&(f.start>e.state.selection.from&&f.start<=e.state.selection.from+2&&e.state.selection.from>=c.from?f.start=e.state.selection.from:f.endA<e.state.selection.to&&f.endA>=e.state.selection.to-2&&e.state.selection.to<=c.to&&(f.endB+=e.state.selection.to-f.endA,f.endA=e.state.selection.to)),_&&Tt<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>c.from&&c.doc.textBetween(f.start-c.from-1,f.start-c.from+1)==" \xA0"&&(f.start--,f.endA--,f.endB--);let m=c.doc.resolveNoCache(f.start-c.from),g=c.doc.resolveNoCache(f.endB-c.from),b=h.resolve(f.start),y=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=f.endA;if((ae&&e.input.lastIOSEnter>Date.now()-225&&(!y||i.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!y&&Qh(c.doc,m.pos,g.pos))&&e.someProp("handleKeyDown",M=>M(e,zt(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>f.start&&Yh(h,f.start,f.endA,m,g)&&e.someProp("handleKeyDown",M=>M(e,zt(8,"Backspace")))){yt&&z&&e.domObserver.suppressSelectionUpdates();return}z&&f.endB==f.start&&(e.input.lastChromeDelete=Date.now()),yt&&!y&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==f.endA&&(f.endB-=2,g=c.doc.resolveNoCache(f.endB-c.from),setTimeout(()=>{e.someProp("handleKeyDown",function(M){return M(e,zt(13,"Enter"))})},20));let w=f.start,S=f.endA,T=M=>{let D=M||e.state.tr.replace(w,S,c.doc.slice(f.start-c.from,f.endB-c.from));if(c.sel){let P=gs(e,D.doc,c.sel);P&&!(z&&e.composing&&P.empty&&(f.start!=f.endB||e.input.lastChromeDelete<Date.now()-100)&&(P.head==w||P.head==D.mapping.map(S)-1)||_&&P.empty&&P.head==w)&&D.setSelection(P)}return s&&D.setMeta("composition",s),D.scrollIntoView()},rt;if(y)if(m.pos==g.pos){_&&Tt<=11&&m.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>bt(e),20));let M=T(e.state.tr.delete(w,S)),D=h.resolve(f.start).marksAcross(h.resolve(f.endA));D&&M.ensureMarks(D),e.dispatch(M)}else if(f.endA==f.endB&&(rt=Gh(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start())))){let M=T(e.state.tr);rt.type=="add"?M.addMark(w,S,rt.mark):M.removeMark(w,S,rt.mark),e.dispatch(M)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let M=m.parent.textBetween(m.parentOffset,g.parentOffset),D=()=>T(e.state.tr.insertText(M,w,S));e.someProp("handleTextInput",P=>P(e,w,S,M,D))||e.dispatch(D())}else e.dispatch(T());else e.dispatch(T())}function gs(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:qo(e,t.resolve(n.anchor),t.resolve(n.head))}function Gh(e,t){let n=e.firstChild.marks,o=t.firstChild.marks,i=n,s=o,r,l,a;for(let h=0;h<o.length;h++)i=o[h].removeFromSet(i);for(let h=0;h<n.length;h++)s=n[h].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],r="add",a=h=>h.mark(l.addToSet(h.marks));else if(i.length==0&&s.length==1)l=s[0],r="remove",a=h=>h.mark(l.removeFromSet(h.marks));else return null;let c=[];for(let h=0;h<t.childCount;h++)c.push(a(t.child(h)));if(v.from(c).eq(e))return{mark:l,type:r}}function Yh(e,t,n,o,i){if(n-t<=i.pos-o.pos||Zn(o,!0,!1)<i.pos)return!1;let s=e.resolve(t);if(!o.parent.isTextblock){let l=s.nodeAfter;return l!=null&&n==t+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let r=e.resolve(Zn(s,!0,!0));return!r.parent.isTextblock||r.pos>n||Zn(r,!0,!1)<n?!1:o.parent.content.cut(o.parentOffset).eq(r.parent.content)}function Qh(e,t,n){let o=0,i=0;return e.nodesBetween(t,n,(s,r)=>{s.isTextblock&&r>=t&&r<n?o++:(s.isText?/\S/.test(s.text.slice(Math.max(0,t-r),Math.min(s.nodeSize,n-r))):s.isLeaf)&&i++}),i==0&&o==1}function Zn(e,t,n){let o=e.depth,i=t?e.end():e.pos;for(;o>0&&(t||e.indexAfter(o)==e.node(o).childCount);)o--,i++,t=!1;if(n){let s=e.node(o).maybeChild(e.indexAfter(o));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function Zh(e,t,n,o,i){let s=e.findDiffStart(t,n),r=n+e.size,l=n+t.size;if(s==null)return null;let{a,b:c}=e.findDiffEnd(t,r,l);if(i=="end"){let h=Math.max(0,s-Math.min(a,c));o-=a+h-s}if(a<s&&r<l){let h=o<=s&&o>=a?s-o:0;s-=h,c=s+(c-a),a=s}else if(c<s){let h=o<=s&&o>=c?s-o:0;s-=h,a=s+(a-c),c=s}return{start:s,endA:a,endB:c}}var _h=Ko,Xh=Be,el=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 dh,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ks),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=bs(this),ws(this),this.nodeViews=vs(this),this.docView=Zi(this.state.doc,ys(this),Qn(this),this.dom,this),this.domObserver=new Vh(this,(n,o,i,s)=>Uh(this,n,o,i,s)),this.domObserver.start(),fh(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&&No(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ks),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];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){var n;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(Kr(this),s=!0),this.state=e;let r=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(r||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=vs(this);ed(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(r||t.handleDOMEvents!=this._props.handleDOMEvents)&&No(this),this.editable=bs(this),ws(this);let l=Qn(this),a=ys(this),c=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",h=i||!this.docView.matchesNode(e.doc,a,l);(h||!e.selection.eq(o.selection))&&(s=!0);let d=c=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Cc(this);if(s){this.domObserver.stop();let p=h&&(_||z)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&td(o.selection,e.selection);if(h){let f=z?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Nh(this)),(i||!this.docView.update(e.doc,a,l,this))&&(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=Zi(e.doc,a,l,this.dom,this)),f&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}let u=this.input.mouseDown;p||!(u&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Qc(this)&&u.delaySelUpdate())?bt(this,p):($r(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((n=this.dragging)===null||n===void 0)&&n.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():d&&Nc(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!Ht(this.dom,e))&&!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof O){let t=this.docView.domAfterPos(this.state.selection.from);x(t)&&Hi(this,t.getBoundingClientRect(),e)}else Hi(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 t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.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,o=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)o=n.from;else{let i=n.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==n.node&&(o=i)}this.dragging=new Ur(e.slice,e.move,o<0?void 0:O.create(this.state.doc,o))}someProp(e,t){let n=this._props&&this._props[e],o;if(n!=null&&(o=t?t(n):n))return o;for(let s=0;s<this.directPlugins.length;s++){let r=this.directPlugins[s].props[e];if(r!=null&&(o=t?t(r):r))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let r=i[s].props[e];if(r!=null&&(o=t?t(r):r))return o}}hasFocus(){if(_){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&&Ac(this.dom),bt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Rc(this,e)}coordsAtPos(e,t=1){return kr(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 o=this.docView.posFromDOM(e,t,n);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Fc(this,t||this.state,e)}pasteHTML(e,t){return Fe(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Fe(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Wo(this,e)}destroy(){this.docView&&(ph(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Qn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,gc())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return mh(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?K&&this.root.nodeType===11&&kc(this.dom.ownerDocument)==this.dom&&Lh(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};el.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function ys(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 o in n)o=="class"?t.class+=" "+n[o]:o=="style"?t.style=(t.style?t.style+";":"")+n[o]:!t[o]&&o!="contenteditable"&&o!="nodeName"&&(t[o]=String(n[o]))}),t.translate||(t.translate="no"),[Pt.node(0,e.state.doc.content.size,t)]}function ws(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:Pt.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function bs(e){return!e.someProp("editable",t=>t(e.state)===!1)}function td(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 vs(e){let t=Object.create(null);function n(o){for(let i in o)Object.prototype.hasOwnProperty.call(t,i)||(t[i]=o[i])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function ed(e,t){let n=0,o=0;for(let i in e){if(e[i]!=t[i])return!0;n++}for(let i in t)o++;return n!=o}function ks(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var nd={};ft(nd,{closeHistory:()=>hd,history:()=>dd,isHistoryTransaction:()=>gd,redo:()=>ll,redoDepth:()=>md,redoNoScroll:()=>pd,undo:()=>rl,undoDepth:()=>ud,undoNoScroll:()=>fd});var Mn=200,F=function(){};F.prototype.append=function(e){return e.length?(e=F.from(e),!this.length&&e||e.length<Mn&&this.leafAppend(e)||this.length<Mn&&e.leafPrepend(this)||this.appendInner(e)):this};F.prototype.prepend=function(e){return e.length?F.from(e).append(this):this};F.prototype.appendInner=function(e){return new od(this,e)};F.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?F.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};F.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};F.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)};F.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},t,n),o};F.from=function(e){return e instanceof F?e:e&&e.length?new nl(e):F.empty};var nl=(function(e){function t(o){e.call(this),this.values=o}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(o,i){return o==0&&i==this.length?this:new t(this.values.slice(o,i))},t.prototype.getInner=function(o){return this.values[o]},t.prototype.forEachInner=function(o,i,s,r){for(var l=i;l<s;l++)if(o(this.values[l],r+l)===!1)return!1},t.prototype.forEachInvertedInner=function(o,i,s,r){for(var l=i-1;l>=s;l--)if(o(this.values[l],r+l)===!1)return!1},t.prototype.leafAppend=function(o){if(this.length+o.length<=Mn)return new t(this.values.concat(o.flatten()))},t.prototype.leafPrepend=function(o){if(this.length+o.length<=Mn)return new t(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t})(F);F.empty=new nl([]);var od=(function(e){function t(n,o){e.call(this),this.left=n,this.right=o,this.length=n.length+o.length,this.depth=Math.max(n.depth,o.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(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},t.prototype.forEachInner=function(n,o,i,s){var r=this.left.length;if(o<r&&this.left.forEachInner(n,o,Math.min(i,r),s)===!1||i>r&&this.right.forEachInner(n,Math.max(o-r,0),Math.min(this.length,i)-r,s+r)===!1)return!1},t.prototype.forEachInvertedInner=function(n,o,i,s){var r=this.left.length;if(o>r&&this.right.forEachInvertedInner(n,o-r,Math.max(i,r)-r,s+r)===!1||i<r&&this.left.forEachInvertedInner(n,Math.min(o,r),i,s)===!1)return!1},t.prototype.sliceInner=function(n,o){if(n==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(n,o):n>=i?this.right.slice(n-i,o-i):this.left.slice(n,i).append(this.right.slice(0,o-i))},t.prototype.leafAppend=function(n){var o=this.right.leafAppend(n);if(o)return new t(this.left,o)},t.prototype.leafPrepend=function(n){var o=this.left.leafPrepend(n);if(o)return new t(o,this.right)},t.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new t(this.left,new t(this.right,n)):new t(this,n)},t})(F),ol=F,id=500,je=class oe{constructor(t,n){this.items=t,this.eventCount=n}popEvent(t,n){if(this.eventCount==0)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}let i,s;n&&(i=this.remapping(o,this.items.length),s=i.maps.length);let r=t.tr,l,a,c=[],h=[];return this.items.forEach((d,p)=>{if(!d.step){i||(i=this.remapping(o,p+1),s=i.maps.length),s--,h.push(d);return}if(i){h.push(new St(d.map));let u=d.step.map(i.slice(s)),f;u&&r.maybeStep(u).doc&&(f=r.mapping.maps[r.mapping.maps.length-1],c.push(new St(f,void 0,void 0,c.length+h.length))),s--,f&&i.appendMap(f,s)}else r.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(s)):d.selection,a=new oe(this.items.slice(0,o).append(h.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:r,selection:l}}addTransform(t,n,o,i){let s=[],r=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let h=0;h<t.steps.length;h++){let d=t.steps[h].invert(t.docs[h]),p=new St(t.mapping.maps[h],d,n),u;(u=a&&a.merge(p))&&(p=u,h?s.pop():l=l.slice(0,l.length-1)),s.push(p),n&&(r++,n=void 0),i||(a=p)}let c=r-o.depth;return c>rd&&(l=sd(l,c),r-=c),new oe(l.append(s),r)}remapping(t,n){let o=new $o;return this.items.forEach((i,s)=>{let r=i.mirrorOffset!=null&&s-i.mirrorOffset>=t?o.maps.length-i.mirrorOffset:void 0;o.appendMap(i.map,r)},t,n),o}addMaps(t){return this.eventCount==0?this:new oe(this.items.append(t.map(n=>new St(n))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let o=[],i=this.items.length-n,s=t.mapping,r=t.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},i);let a=n;this.items.forEach(p=>{let u=s.getMirror(--a);if(u==null)return;r=Math.min(r,u);let f=s.maps[u];if(p.step){let m=t.steps[u].invert(t.docs[u]),g=p.selection&&p.selection.map(s.slice(a+1,u));g&&l++,o.push(new St(f,m,g))}else o.push(new St(f))},i);let c=[];for(let p=n;p<r;p++)c.push(new St(s.maps[p]));let h=this.items.slice(0,i).append(c).append(o),d=new oe(h,l);return d.emptyItemCount()>id&&(d=d.compress(this.items.length-o.length)),d}emptyItemCount(){let t=0;return this.items.forEach(n=>{n.step||t++}),t}compress(t=this.items.length){let n=this.remapping(0,t),o=n.maps.length,i=[],s=0;return this.items.forEach((r,l)=>{if(l>=t)i.push(r),r.selection&&s++;else if(r.step){let a=r.step.map(n.slice(o)),c=a&&a.getMap();if(o--,c&&n.appendMap(c,o),a){let h=r.selection&&r.selection.map(n.slice(o));h&&s++;let d=new St(c.invert(),a,h),p,u=i.length-1;(p=i.length&&i[u].merge(d))?i[u]=p:i.push(d)}}else r.map&&o--},this.items.length,0),new oe(ol.from(i.reverse()),s)}};je.empty=new je(ol.empty,0);function sd(e,t){let n;return e.forEach((o,i)=>{if(o.selection&&t--==0)return n=i,!1}),e.slice(n)}var St=class il{constructor(t,n,o,i){this.map=t,this.step=n,this.selection=o,this.mirrorOffset=i}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new il(n.getMap().invert(),n,this.selection)}}},Dt=class{constructor(e,t,n,o,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=o,this.prevComposition=i}},rd=20;function ld(e,t,n,o){let i=n.getMeta(ct),s;if(i)return i.historyState;n.getMeta(sl)&&(e=new Dt(e.done,e.undone,null,0,-1));let r=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;if(r&&r.getMeta(ct))return r.getMeta(ct).redo?new Dt(e.done.addTransform(n,void 0,o,wn(t)),e.undone,xs(n.mapping.maps),e.prevTime,e.prevComposition):new Dt(e.done,e.undone.addTransform(n,void 0,o,wn(t)),null,e.prevTime,e.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(r&&r.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=e.prevTime==0||!r&&e.prevComposition!=l&&(e.prevTime<(n.time||0)-o.newGroupDelay||!ad(n,e.prevRanges)),c=r?_n(e.prevRanges,n.mapping):xs(n.mapping.maps);return new Dt(e.done.addTransform(n,a?t.selection.getBookmark():void 0,o,wn(t)),je.empty,c,n.time,l??e.prevComposition)}else return(s=n.getMeta("rebased"))?new Dt(e.done.rebased(n,s),e.undone.rebased(n,s),_n(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Dt(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),_n(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function ad(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((o,i)=>{for(let s=0;s<t.length;s+=2)o<=t[s+1]&&i>=t[s]&&(n=!0)}),n}function xs(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((o,i,s,r)=>t.push(s,r));return t}function _n(e,t){if(!e)return null;let n=[];for(let o=0;o<e.length;o+=2){let i=t.map(e[o],1),s=t.map(e[o+1],-1);i<=s&&n.push(i,s)}return n}function cd(e,t,n){let o=wn(t),i=ct.get(t).spec.config,s=(n?e.undone:e.done).popEvent(t,o);if(!s)return null;let r=s.selection.resolve(s.transform.doc),l=(n?e.done:e.undone).addTransform(s.transform,t.selection.getBookmark(),i,o),a=new Dt(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(r).setMeta(ct,{redo:n,historyState:a})}var Xn=!1,Ss=null;function wn(e){let t=e.plugins;if(Ss!=t){Xn=!1,Ss=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){Xn=!0;break}}return Xn}function hd(e){return e.setMeta(sl,!0)}var ct=new jo("history"),sl=new jo("closeHistory");function dd(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new fe({key:ct,state:{init(){return new Dt(je.empty,je.empty,null,0,-1)},apply(t,n,o){return ld(n,o,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let o=n.inputType,i=o=="historyUndo"?rl:o=="historyRedo"?ll:null;return!i||!t.editable?!1:(n.preventDefault(),i(t.state,t.dispatch))}}}})}function Tn(e,t){return(n,o)=>{let i=ct.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(o){let s=cd(i,n,e);s&&o(t?s.scrollIntoView():s)}return!0}}var rl=Tn(!1,!0),ll=Tn(!0,!0),fd=Tn(!1,!1),pd=Tn(!0,!1);function ud(e){let t=ct.getState(e);return t?t.done.eventCount:0}function md(e){let t=ct.getState(e);return t?t.undone.eventCount:0}function gd(e){return e.getMeta(ct)!=null}var yd={};ft(yd,{keydownHandler:()=>Qo,keymap:()=>Md});var Rt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Cn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},wd=typeof navigator<"u"&&/Mac/.test(navigator.platform),bd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for($=0;$<10;$++)Rt[48+$]=Rt[96+$]=String($);var $;for($=1;$<=24;$++)Rt[$+111]="F"+$;var $;for($=65;$<=90;$++)Rt[$]=String.fromCharCode($+32),Cn[$]=String.fromCharCode($);var $;for(dn in Rt)Cn.hasOwnProperty(dn)||(Cn[dn]=Rt[dn]);var dn;function vd(e){var t=wd&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||bd&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?Cn:Rt)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}var kd=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),xd=typeof navigator<"u"&&/Win/.test(navigator.platform);function Sd(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let o,i,s,r;for(let l=0;l<t.length-1;l++){let a=t[l];if(/^(cmd|meta|m)$/i.test(a))r=!0;else if(/^a(lt)?$/i.test(a))o=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))kd?r=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return o&&(n="Alt-"+n),i&&(n="Ctrl-"+n),r&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function Od(e){let t=Object.create(null);for(let n in e)t[Sd(n)]=e[n];return t}function to(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 Md(e){return new fe({props:{handleKeyDown:Qo(e)}})}function Qo(e){let t=Od(e);return function(n,o){let i=vd(o),s,r=t[to(i,o)];if(r&&r(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(o.shiftKey){let l=t[to(i,o,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((o.altKey||o.metaKey||o.ctrlKey)&&!(xd&&o.ctrlKey&&o.altKey)&&(s=Rt[o.keyCode])&&s!=i){let l=t[to(s,o)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Cd={};ft(Cd,{autoJoin:()=>Ld,baseKeymap:()=>qd,chainCommands:()=>$n,createParagraphNear:()=>yl,deleteSelection:()=>Zo,exitCode:()=>gl,joinBackward:()=>cl,joinDown:()=>Ed,joinForward:()=>pl,joinTextblockBackward:()=>Nd,joinTextblockForward:()=>Ad,joinUp:()=>Dd,lift:()=>Td,liftEmptyBlock:()=>wl,macBaseKeymap:()=>ni,newlineInCode:()=>ml,pcBaseKeymap:()=>lt,selectAll:()=>vl,selectNodeBackward:()=>dl,selectNodeForward:()=>ul,selectParentNode:()=>Rd,selectTextblockEnd:()=>Ol,selectTextblockStart:()=>Sl,setBlockType:()=>Bd,splitBlock:()=>ei,splitBlockAs:()=>bl,splitBlockKeepMarks:()=>$d,toggleMark:()=>Vd,wrapIn:()=>Pd});var Zo=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function al(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}var cl=(e,t,n)=>{let o=al(e,n);if(!o)return!1;let i=_o(o);if(!i){let r=o.blockRange(),l=r&&Je(r);return l==null?!1:(t&&t(e.tr.lift(r,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(kl(e,i,t,-1))return!0;if(o.parent.content.size==0&&(ce(s,"end")||O.isSelectable(s)))for(let r=o.depth;;r--){let l=qe(e.doc,o.before(r),o.after(r),k.empty);if(l&&l.slice.size<l.to-l.from){if(t){let a=e.tr.step(l);a.setSelection(ce(s,"end")?C.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):O.create(a.doc,i.pos-s.nodeSize)),t(a.scrollIntoView())}return!0}if(r==1||o.node(r-1).childCount>1)break}return s.isAtom&&i.depth==o.depth-1?(t&&t(e.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},Nd=(e,t,n)=>{let o=al(e,n);if(!o)return!1;let i=_o(o);return i?hl(e,i,t):!1},Ad=(e,t,n)=>{let o=fl(e,n);if(!o)return!1;let i=Xo(o);return i?hl(e,i,t):!1};function hl(e,t,n){let o=t.nodeBefore,i=o,s=t.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let h=i.lastChild;if(!h)return!1;i=h}let r=t.nodeAfter,l=r,a=t.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let h=l.firstChild;if(!h)return!1;l=h}let c=qe(e.doc,s,a,k.empty);if(!c||c.from!=s||c instanceof ot&&c.slice.size>=a-s)return!1;if(n){let h=e.tr.step(c);h.setSelection(N.create(h.doc,s)),n(h.scrollIntoView())}return!0}function ce(e,t,n=!1){for(let o=e;o;o=t=="start"?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(n&&o.childCount!=1)return!1}return!1}var dl=(e,t,n)=>{let{$head:o,empty:i}=e.selection,s=o;if(!i)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):o.parentOffset>0)return!1;s=_o(o)}let r=s&&s.nodeBefore;return!r||!O.isSelectable(r)?!1:(t&&t(e.tr.setSelection(O.create(e.doc,s.pos-r.nodeSize)).scrollIntoView()),!0)};function _o(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 fl(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}var pl=(e,t,n)=>{let o=fl(e,n);if(!o)return!1;let i=Xo(o);if(!i)return!1;let s=i.nodeAfter;if(kl(e,i,t,1))return!0;if(o.parent.content.size==0&&(ce(s,"start")||O.isSelectable(s))){let r=qe(e.doc,o.before(),o.after(),k.empty);if(r&&r.slice.size<r.to-r.from){if(t){let l=e.tr.step(r);l.setSelection(ce(s,"start")?C.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):O.create(l.doc,l.mapping.map(i.pos))),t(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==o.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},ul=(e,t,n)=>{let{$head:o,empty:i}=e.selection,s=o;if(!i)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):o.parentOffset<o.parent.content.size)return!1;s=Xo(o)}let r=s&&s.nodeAfter;return!r||!O.isSelectable(r)?!1:(t&&t(e.tr.setSelection(O.create(e.doc,s.pos)).scrollIntoView()),!0)};function Xo(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 Dd=(e,t)=>{let n=e.selection,o=n instanceof O,i;if(o){if(n.node.isTextblock||!Ut(e.doc,n.from))return!1;i=n.from}else if(i=Bo(e.doc,n.from,-1),i==null)return!1;if(t){let s=e.tr.join(i);o&&s.setSelection(O.create(s.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(s.scrollIntoView())}return!0},Ed=(e,t)=>{let n=e.selection,o;if(n instanceof O){if(n.node.isTextblock||!Ut(e.doc,n.to))return!1;o=n.to}else if(o=Bo(e.doc,n.to,1),o==null)return!1;return t&&t(e.tr.join(o).scrollIntoView()),!0},Td=(e,t)=>{let{$from:n,$to:o}=e.selection,i=n.blockRange(o),s=i&&Je(i);return s==null?!1:(t&&t(e.tr.lift(i,s).scrollIntoView()),!0)},ml=(e,t)=>{let{$head:n,$anchor:o}=e.selection;return!n.parent.type.spec.code||!n.sameParent(o)?!1:(t&&t(e.tr.insertText(`
10
+ `).scrollIntoView()),!0)};function ti(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 gl=(e,t)=>{let{$head:n,$anchor:o}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(o))return!1;let i=n.node(-1),s=n.indexAfter(-1),r=ti(i.contentMatchAt(s));if(!r||!i.canReplaceWith(s,s,r))return!1;if(t){let l=n.after(),a=e.tr.replaceWith(l,l,r.createAndFill());a.setSelection(C.near(a.doc.resolve(l),1)),t(a.scrollIntoView())}return!0},yl=(e,t)=>{let n=e.selection,{$from:o,$to:i}=n;if(n instanceof at||o.parent.inlineContent||i.parent.inlineContent)return!1;let s=ti(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(t){let r=(!o.parentOffset&&i.index()<i.parent.childCount?o:i).pos,l=e.tr.insert(r,s.createAndFill());l.setSelection(N.create(l.doc,r+1)),t(l.scrollIntoView())}return!0},wl=(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 s=n.before();if(De(e.doc,s))return t&&t(e.tr.split(s).scrollIntoView()),!0}let o=n.blockRange(),i=o&&Je(o);return i==null?!1:(t&&t(e.tr.lift(o,i).scrollIntoView()),!0)};function bl(e){return(t,n)=>{if(t.selection instanceof O&&t.selection.node.isBlock){let{$from:u}=t.selection;return!u.parentOffset||!De(t.doc,u.pos)?!1:(n&&n(t.tr.split(u.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let o=t.tr;!t.selection.empty&&(t.selection instanceof N||t.selection instanceof at)&&o.deleteSelection();let{$from:i}=o.selection,s=o.steps.length,r=[],l,a,c=!1,h=!1;for(let u=i.depth;;u--)if(i.node(u).isBlock){c=i.end(u)==i.pos+(i.depth-u),h=i.start(u)==i.pos-(i.depth-u),a=ti(i.node(u-1).contentMatchAt(i.indexAfter(u-1)));let f=e&&e(i.parent,c,i);r.unshift(f||(c&&a?{type:a}:null)),l=u;break}else{if(u==1)return!1;r.unshift(null)}let d=i.pos,p=De(o.doc,d,r.length,r);if(p||(r[0]=a?{type:a}:null,p=De(o.doc,d,r.length,r)),!p)return!1;if(o.split(d,r.length,r),!c&&h&&i.node(l).type!=a){let u=o.mapping.slice(s),f=u.map(i.before(l)),m=o.doc.resolve(f);a&&i.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&o.setNodeMarkup(u.map(i.before(l)),a)}return n&&n(o.scrollIntoView()),!0}}var ei=bl(),$d=(e,t)=>ei(e,t&&(n=>{let o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();o&&n.ensureMarks(o),t(n)})),Rd=(e,t)=>{let{$from:n,to:o}=e.selection,i,s=n.sharedDepth(o);return s==0?!1:(i=n.before(s),t&&t(e.tr.setSelection(O.create(e.doc,i))),!0)},vl=(e,t)=>(t&&t(e.tr.setSelection(new at(e.doc))),!0);function Id(e,t,n){let o=t.nodeBefore,i=t.nodeAfter,s=t.index();return!o||!i||!o.type.compatibleContent(i.type)?!1:!o.content.size&&t.parent.canReplace(s-1,s)?(n&&n(e.tr.delete(t.pos-o.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(s,s+1)||!(i.isTextblock||Ut(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function kl(e,t,n,o){let i=t.nodeBefore,s=t.nodeAfter,r,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Id(e,t,n))return!0;let c=!a&&t.parent.canReplace(t.index(),t.index()+1);if(c&&(r=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(r[0]||s.type).validEnd){if(n){let u=t.pos+s.nodeSize,f=v.empty;for(let b=r.length-1;b>=0;b--)f=v.from(r[b].create(null,f));f=v.from(i.copy(f));let m=e.tr.step(new ht(t.pos-1,u,t.pos,u,new k(f,1,0),r.length,!0)),g=m.doc.resolve(u+2*r.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Ut(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let h=s.type.spec.isolating||o>0&&a?null:C.findFrom(t,1),d=h&&h.$from.blockRange(h.$to),p=d&&Je(d);if(p!=null&&p>=t.depth)return n&&n(e.tr.lift(d,p).scrollIntoView()),!0;if(c&&ce(s,"start",!0)&&ce(i,"end")){let u=i,f=[];for(;f.push(u),!u.isTextblock;)u=u.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(u.canReplace(u.childCount,u.childCount,m.content)){if(n){let b=v.empty;for(let w=f.length-1;w>=0;w--)b=v.from(f[w].copy(b));let y=e.tr.step(new ht(t.pos-f.length,t.pos+s.nodeSize,t.pos+g,t.pos+s.nodeSize-g,new k(b,f.length,0),0,!0));n(y.scrollIntoView())}return!0}}return!1}function xl(e){return function(t,n){let o=t.selection,i=e<0?o.$from:o.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(t.tr.setSelection(N.create(t.doc,e<0?i.start(s):i.end(s)))),!0):!1}}var Sl=xl(-1),Ol=xl(1);function Pd(e,t=null){return function(n,o){let{$from:i,$to:s}=n.selection,r=i.blockRange(s),l=r&&Po(r,e,t);return l?(o&&o(n.tr.wrap(r,l).scrollIntoView()),!0):!1}}function Bd(e,t=null){return function(n,o){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:r},$to:{pos:l}}=n.selection.ranges[s];n.doc.nodesBetween(r,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(e,t)))if(a.type==e)i=!0;else{let h=n.doc.resolve(c),d=h.index();i=h.parent.canReplaceWith(d,d+1,e)}})}if(!i)return!1;if(o){let s=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[r];s.setBlockType(l,a,e,t)}o(s.scrollIntoView())}return!0}}function zd(e,t,n,o){for(let i=0;i<t.length;i++){let{$from:s,$to:r}=t[i],l=s.depth==0?e.inlineContent&&e.type.allowsMarkType(n):!1;if(e.nodesBetween(s.pos,r.pos,(a,c)=>{if(l||!o&&a.isAtom&&a.isInline&&c>=s.pos&&c+a.nodeSize<=r.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(n)}),l)return!0}return!1}function Fd(e){let t=[];for(let n=0;n<e.length;n++){let{$from:o,$to:i}=e[n];o.doc.nodesBetween(o.pos,i.pos,(s,r)=>{if(s.isAtom&&s.content.size&&s.isInline&&r>=o.pos&&r+s.nodeSize<=i.pos)return r+1>o.pos&&t.push(new xn(o,o.doc.resolve(r+1))),o=o.doc.resolve(r+1+s.content.size),!1}),o.pos<i.pos&&t.push(new xn(o,i))}return t}function Vd(e,t=null,n){let o=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,s=!(n&&n.includeWhitespace);return function(r,l){let{empty:a,$cursor:c,ranges:h}=r.selection;if(a&&!c||!zd(r.doc,h,e,i))return!1;if(l)if(c)e.isInSet(r.storedMarks||c.marks())?l(r.tr.removeStoredMark(e)):l(r.tr.addStoredMark(e.create(t)));else{let d,p=r.tr;i||(h=Fd(h)),o?d=!h.some(u=>r.doc.rangeHasMark(u.$from.pos,u.$to.pos,e)):d=!h.every(u=>{let f=!1;return p.doc.nodesBetween(u.$from.pos,u.$to.pos,(m,g,b)=>{if(f)return!1;f=!e.isInSet(m.marks)&&!!b&&b.type.allowsMarkType(e)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,u.$from.pos-g),Math.min(m.nodeSize,u.$to.pos-g))))}),!f});for(let u=0;u<h.length;u++){let{$from:f,$to:m}=h[u];if(!d)p.removeMark(f.pos,m.pos,e);else{let g=f.pos,b=m.pos,y=f.nodeAfter,w=m.nodeBefore,S=s&&y&&y.isText?/^\s*/.exec(y.text)[0].length:0,T=s&&w&&w.isText?/\s*$/.exec(w.text)[0].length:0;g+S<b&&(g+=S,b-=T),p.addMark(g,b,e.create(t))}}l(p.scrollIntoView())}return!0}}function jd(e,t){return n=>{if(!n.isGeneric)return e(n);let o=[];for(let s=0;s<n.mapping.maps.length;s++){let r=n.mapping.maps[s];for(let l=0;l<o.length;l++)o[l]=r.map(o[l]);r.forEach((l,a,c,h)=>o.push(c,h))}let i=[];for(let s=0;s<o.length;s+=2){let r=o[s],l=o[s+1],a=n.doc.resolve(r),c=a.sharedDepth(l),h=a.node(c);for(let d=a.indexAfter(c),p=a.after(c+1);p<=l;++d){let u=h.maybeChild(d);if(!u)break;if(d&&i.indexOf(p)==-1){let f=h.child(d-1);f.type==u.type&&t(f,u)&&i.push(p)}p+=u.nodeSize}}i.sort((s,r)=>s-r);for(let s=i.length-1;s>=0;s--)Ut(n.doc,i[s])&&n.join(i[s]);e(n)}}function Ld(e,t){let n=Array.isArray(t)?o=>t.indexOf(o.type.name)>-1:t;return(o,i,s)=>e(o,i&&jd(i,n),s)}function $n(...e){return function(t,n,o){for(let i=0;i<e.length;i++)if(e[i](t,n,o))return!0;return!1}}var eo=$n(Zo,cl,dl),Os=$n(Zo,pl,ul),lt={Enter:$n(ml,yl,wl,ei),"Mod-Enter":gl,Backspace:eo,"Mod-Backspace":eo,"Shift-Backspace":eo,Delete:Os,"Mod-Delete":Os,"Mod-a":vl},ni={"Ctrl-h":lt.Backspace,"Alt-Backspace":lt["Mod-Backspace"],"Ctrl-d":lt.Delete,"Ctrl-Alt-Backspace":lt["Mod-Delete"],"Alt-Delete":lt["Mod-Delete"],"Alt-d":lt["Mod-Delete"],"Ctrl-a":Sl,"Ctrl-e":Ol};for(let e in lt)ni[e]=lt[e];var Jd=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,qd=Jd?ni:lt,Wd={};ft(Wd,{InputRule:()=>vt,closeDoubleQuote:()=>Cl,closeSingleQuote:()=>Al,ellipsis:()=>Qd,emDash:()=>Yd,inputRules:()=>Ud,openDoubleQuote:()=>Ml,openSingleQuote:()=>Nl,smartQuotes:()=>Zd,textblockTypeInputRule:()=>Xd,undoInputRule:()=>Gd,wrappingInputRule:()=>_d});var vt=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Kd(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function Kd(e){return function(t,n,o,i){let s=e;if(n[1]){let r=n[0].lastIndexOf(n[1]);s+=n[0].slice(r+n[1].length),o+=r;let l=o-i;l>0&&(s=n[0].slice(r-l,r)+s,o=i)}return t.tr.insertText(s,o,i)}}var Hd=500;function Ud({rules:e}){let t=new fe({state:{init(){return null},apply(n,o){return n.getMeta(this)||(n.selectionSet||n.docChanged?null:o)}},props:{handleTextInput(n,o,i,s){return Ms(n,o,i,s,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:o}=n.state.selection;o&&Ms(n,o.pos,o.pos,"",e,t)})}}},isInputRules:!0});return t}function Ms(e,t,n,o,i,s){if(e.composing)return!1;let r=e.state,l=r.doc.resolve(t),a=l.parent.textBetween(Math.max(0,l.parentOffset-Hd),l.parentOffset,null,"\uFFFC")+o;for(let c=0;c<i.length;c++){let h=i[c];if(!h.inCodeMark&&l.marks().some(f=>f.type.spec.code))continue;if(l.parent.type.spec.code){if(!h.inCode)continue}else if(h.inCode==="only")continue;let d=h.match.exec(a);if(!d||d[0].length<o.length)continue;let p=t-(d[0].length-o.length);if(!h.inCodeMark){let f=!1;if(r.doc.nodesBetween(p,l.pos,m=>{m.isInline&&m.marks.some(g=>g.type.spec.code)&&(f=!0)}),f)continue}let u=h.handler(r,d,p,n);if(u)return h.undoable&&u.setMeta(s,{transform:u,from:t,to:n,text:o}),e.dispatch(u),!0}return!1}var Gd=(e,t)=>{let n=e.plugins;for(let o=0;o<n.length;o++){let i=n[o],s;if(i.spec.isInputRules&&(s=i.getState(e))){if(t){let r=e.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a--)r.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=r.doc.resolve(s.from).marks();r.replaceWith(s.from,s.to,e.schema.text(s.text,a))}else r.delete(s.from,s.to);t(r)}return!0}}return!1},Yd=new vt(/--$/,"\u2014",{inCodeMark:!1}),Qd=new vt(/\.\.\.$/,"\u2026",{inCodeMark:!1}),Ml=new vt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),Cl=new vt(/"$/,"\u201D",{inCodeMark:!1}),Nl=new vt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),Al=new vt(/'$/,"\u2019",{inCodeMark:!1}),Zd=[Ml,Cl,Nl,Al];function _d(e,t,n=null,o){return new vt(e,(i,s,r,l)=>{let a=n instanceof Function?n(s):n,c=i.tr.delete(r,l),h=c.doc.resolve(r),d=h.blockRange(),p=d&&Po(d,t,a);if(!p)return null;c.wrap(d,p);let u=c.doc.resolve(r-1).nodeBefore;return u&&u.type==t&&Ut(c.doc,r-1)&&(!o||o(s,u))&&c.join(r-1),c})}function Xd(e,t,n=null){return new vt(e,(o,i,s,r)=>{let l=o.doc.resolve(s),a=n instanceof Function?n(i):n;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),t)?o.tr.delete(s,r).setBlockType(s,s,t,a):null})}var tf={};ft(tf,{dropCursor:()=>ef});function ef(e={}){return new fe({view(t){return new nf(t,e)}})}var nf=class{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(n=t.width)!==null&&n!==void 0?n:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let n=this.computeTarget(this.lastDragEvent);n==this.cursorPos?this.updateOverlay():this.setCursor(n)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,r=i.height/o.offsetHeight;if(t){let h=e.nodeBefore,d=e.nodeAfter;if(h||d){let p=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(p){let u=p.getBoundingClientRect(),f=h?u.bottom:u.top;h&&d&&(f=(f+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*r;n={left:u.left,right:u.right,top:f-m,bottom:f+m}}}}if(!n){let h=this.editorView.coordsAtPos(this.cursorPos),d=this.width/2*s;n={left:h.left-d,right:h.left+d,top:h.top,bottom:h.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let a,c;if(!l||l==document.body&&getComputedStyle(l).position=="static")a=-pageXOffset,c=-pageYOffset;else{let h=l.getBoundingClientRect(),d=h.width/l.offsetWidth,p=h.height/l.offsetHeight;a=h.left-l.scrollLeft*d,c=h.top-l.scrollTop*p}this.element.style.left=(n.left-a)/s+"px",this.element.style.top=(n.top-c)/r+"px",this.element.style.width=(n.right-n.left)/s+"px",this.element.style.height=(n.bottom-n.top)/r+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=n&&n.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,t,e):o;if(!t||i)return null;let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let r=zo(this.editorView.state.doc,s,this.editorView.dragging.slice);r!=null&&(s=r)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},of={};ft(of,{GapCursor:()=>Q,gapCursor:()=>af});var Q=class Nt extends C{constructor(t){super(t,t)}map(t,n){let o=t.resolve(n.map(this.head));return Nt.valid(o)?new Nt(o):C.near(o)}content(){return k.empty}eq(t){return t instanceof Nt&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Nt(t.resolve(n.pos))}getBookmark(){return new sf(this.anchor)}static valid(t){let n=t.parent;if(n.inlineContent||!rf(t)||!lf(t))return!1;let o=n.type.spec.allowGapCursor;if(o!=null)return o;let i=n.contentMatchAt(t.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(t,n,o=!1){t:for(;;){if(!o&&Nt.valid(t))return t;let i=t.pos,s=null;for(let r=t.depth;;r--){let l=t.node(r);if(n>0?t.indexAfter(r)<l.childCount:t.index(r)>0){s=l.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let a=t.doc.resolve(i);if(Nt.valid(a))return a}for(;;){let r=n>0?s.firstChild:s.lastChild;if(!r){if(s.isAtom&&!s.isText&&!O.isSelectable(s)){t=t.doc.resolve(i+s.nodeSize*n),o=!1;continue t}break}s=r,i+=n;let l=t.doc.resolve(i);if(Nt.valid(l))return l}return null}}};Q.prototype.visible=!1;Q.findFrom=Q.findGapCursorFrom;C.jsonID("gapcursor",Q);var sf=class Dl{constructor(t){this.pos=t}map(t){return new Dl(t.map(this.pos))}resolve(t){let n=t.resolve(this.pos);return Q.valid(n)?new Q(n):C.near(n)}};function El(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function rf(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),o=e.node(t);if(n==0){if(o.type.spec.isolating)return!0;continue}for(let i=o.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||El(i.type))return!0;if(i.inlineContent)return!1}}return!0}function lf(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),o=e.node(t);if(n==o.childCount){if(o.type.spec.isolating)return!0;continue}for(let i=o.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||El(i.type))return!0;if(i.inlineContent)return!1}}return!0}function af(){return new fe({props:{decorations:ff,createSelectionBetween(e,t,n){return t.pos==n.pos&&Q.valid(n)?new Q(n):null},handleClick:hf,handleKeyDown:cf,handleDOMEvents:{beforeinput:df}}})}var cf=Qo({ArrowLeft:fn("horiz",-1),ArrowRight:fn("horiz",1),ArrowUp:fn("vert",-1),ArrowDown:fn("vert",1)});function fn(e,t){let n=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(o,i,s){let r=o.selection,l=t>0?r.$to:r.$from,a=r.empty;if(r instanceof N){if(!s.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=o.doc.resolve(t>0?l.after():l.before())}let c=Q.findGapCursorFrom(l,t,a);return c?(i&&i(o.tr.setSelection(new Q(c))),!0):!1}}function hf(e,t,n){if(!e||!e.editable)return!1;let o=e.state.doc.resolve(t);if(!Q.valid(o))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&O.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new Q(o))),!0)}function df(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof Q))return!1;let{$from:n}=e.state.selection,o=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!o)return!1;let i=v.empty;for(let r=o.length-1;r>=0;r--)i=v.from(o[r].createAndFill(null,i));let s=e.state.tr.replace(n.pos,n.pos,new k(i,0,0));return s.setSelection(N.near(s.doc.resolve(n.pos+1))),e.dispatch(s),!1}function ff(e){if(!(e.selection instanceof Q))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",nt.create(e.doc,[Pt.widget(e.selection.head,t,{key:"gapcursor"})])}var pf=/^(https?:|mailto:|tel:)/i;function Rn(e){let t=String(e??"").trim().replace(/[\u0000-\u001f\u007f]/g,"");return t?t.startsWith("#")||t.startsWith("/")&&!t.startsWith("//")||pf.test(t)?t:/^[a-z][a-z0-9+.-]*:/i.test(t)?null:/^(\/\/)?[\w-]+(\.[\w-]+)+(:\d+)?([/?#]\S*)?$/.test(t)?`https://${t.replace(/^\/\//,"")}`:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?`mailto:${t}`:null:null}var Hp=e=>e&&/^data:image\/(png|jpeg|gif|webp);/i.test(e)&&e.length<=21e5?e:Rn(e);function oi(e){if(typeof e!="string")return null;let t=Rn(e);return t&&/^(https?:|\/(?!\/))/i.test(t)?t:null}var Z={id:{default:null},pos:{default:null},parent:{default:null}},H=(e,t={})=>({"data-id":e.attrs.id,...t}),ii=new pt.Schema({nodes:{doc:{content:"block+"},paragraph:{group:"block",content:"inline*",attrs:Z,toDOM:e=>["p",H(e),0]},heading:{group:"block",content:"inline*",defining:!0,attrs:{...Z,level:{default:2}},toDOM:e=>[`h${e.attrs.level}`,H(e),0]},list_item:{group:"block",content:"inline*",attrs:{...Z,kind:{default:"bullet"},indent:{default:0},checked:{default:!1},owner:{default:null},due:{default:null}},toDOM:e=>["div",H(e,{class:"page-li","data-kind":e.attrs.kind,"data-indent":String(e.attrs.indent),"data-checked":e.attrs.checked?"true":"false"}),0]},callout:{group:"block",content:"inline*",attrs:Z,toDOM:e=>["aside",H(e,{class:"page-callout"}),0]},code_block:{group:"block",content:"text*",marks:"",code:!0,defining:!0,attrs:{...Z,lang:{default:""}},toDOM:e=>["pre",H(e,{"data-lang":e.attrs.lang}),["code",0]]},toggle:{group:"block",content:"inline*",attrs:{...Z,open:{default:!1}},toDOM:e=>["div",H(e,{class:"page-toggle","data-open":e.attrs.open?"true":"false"}),0]},divider:{group:"block",atom:!0,attrs:Z,toDOM:e=>["hr",H(e)]},image:{group:"block",atom:!0,draggable:!0,attrs:{...Z,src:{default:""},alt:{default:""},caption:{default:""},width:{default:null},align:{default:null}},toDOM:e=>["figure",H(e,{"data-type":"image",...e.attrs.width?{"data-width":String(e.attrs.width)}:{},...e.attrs.align?{"data-align":e.attrs.align}:{}}),["img",{src:e.attrs.src,alt:e.attrs.alt}],["figcaption",e.attrs.caption]]},file:{group:"block",atom:!0,attrs:{...Z,src:{default:""},name:{default:""},size:{default:null},mime:{default:null}},toDOM:e=>["div",H(e,{class:"page-file","data-type":"file","data-src":oi(e.attrs.src)??"","data-name":e.attrs.name,"data-size":e.attrs.size==null?"":String(e.attrs.size),"data-mime":e.attrs.mime??""}),["a",{href:oi(e.attrs.src),target:"_blank",rel:"noopener noreferrer"},e.attrs.name||"file"]]},table:{group:"block",content:"table_row+",isolating:!0,attrs:{...Z,cols:{default:{}},sort:{default:null}},toDOM:e=>["table",H(e),["tbody",0]]},table_row:{content:"table_cell+",attrs:{id:{default:null},pos:{default:null}},toDOM:e=>["tr",H(e),0]},table_cell:{content:"inline*",isolating:!0,attrs:{col:{default:null}},toDOM:e=>["td",{"data-col":e.attrs.col},0]},chart:{group:"block",atom:!0,attrs:{...Z,source:{default:null},kind:{default:"line"},x:{default:null},series:{default:[]},title:{default:""},highlight:{default:null}},toDOM:e=>["figure",H(e,{"data-type":"chart"})]},board:{group:"block",atom:!0,attrs:{...Z,columns:{default:{}},cards:{default:{}}},toDOM:e=>["section",H(e,{"data-type":"board"})]},tool:{group:"block",atom:!0,attrs:{...Z,artifact:{default:null},rev:{default:null},state:{default:{}}},toDOM:e=>["section",H(e,{"data-type":"tool"})]},preserved:{group:"block",atom:!0,attrs:{...Z,html:{default:""}},toDOM:e=>["div",H(e,{"data-type":"preserved"})]},opaque_block:{group:"block",content:"inline*",atom:!0,isolating:!0,selectable:!0,attrs:{...Z,raw:{default:null}},toDOM:e=>["div",H(e,{"data-type":"newer-format","data-format":String(e.attrs.raw?.t??""),contenteditable:"false"}),["span",{class:"page-newer-format"},`Newer format: ${String(e.attrs.raw?.t??"")}`],["span",{class:"page-newer-format-text"},e.textContent]]},text:{group:"inline"},hard_break:{group:"inline",inline:!0,selectable:!1,toDOM:()=>["br"]}},marks:{strong:{toDOM:()=>["strong",0]},em:{toDOM:()=>["em",0]},strike:{toDOM:()=>["s",0]},code:{toDOM:()=>["code",0]},link:{attrs:{href:{}},inclusive:!1,toDOM:e=>["a",{href:Rn(e.attrs.href)},0]}}});var uf='@{"type":"hard_break"}';function kt(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(e===null||typeof e!="object"||typeof e.c!="string")return"";let t=[];for(let o of Array.isArray(e.m)?e.m:[])if(!Array.isArray(o))t.push(o);else for(let i=0;i<o[0]&&t.length<e.c.length;i++)t.push(o[1]);let n="";for(let o=0;o<e.c.length;o++)n+=e.c[o]==="\uFFFC"&&t[o]===uf?`
11
+ `:e.c[o];return n}var Pl="opaque_marks",Gt="clay_opaque_code",Bl="x",zl=/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/,Tl=32,$l=1e4,mf=/[A-Za-z]/,Ge=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),si=e=>e===null||typeof e!="object"?e:JSON.parse(JSON.stringify(e));function In(e){let t=0,n=(o,i)=>{if(i>Tl)throw new RangeError(`page: inline JSON is deeper than ${Tl}`);if(!(o===null||typeof o!="object")){if(Array.isArray(o)){for(let s of o)n(s,i+1);return}for(let s of Object.keys(o)){if(++t>$l)throw new RangeError(`page: inline JSON has more than ${$l} keys`);n(o[s],i+1)}}};return n(e,1),e}function gf(e,t){let n=0,o=!1;for(;t<e.length;t++){let i=e[t];if(o)i==="\\"?t++:i==='"'&&(o=!1);else if(i==='"')o=!0;else if(i==="[")n++;else if(i==="]"&&--n===0)return t+1}throw new SyntaxError(`page: unterminated attrs in mark key ${e}`)}var Rl=e=>new SyntaxError(`page: malformed mark key ${e}`);function Ye(e){if(typeof e!="string")throw new TypeError("page: a mark key is not a string");let t=[];for(let n=0;n<e.length;){let o=e[n];if(!mf.test(o))throw Rl(e);let i=n+1,s=null;if(e[i]==="["&&(i=gf(e,i),s=In(JSON.parse(e.slice(n+1,i))),!Array.isArray(s)))throw Rl(e);if(o!==Bl)t.push({code:o,attrs:s,token:e.slice(n,i)});else{if(!s||s.length!==2||typeof s[0]!="string"||!zl.test(s[0])||!Ge(s[1]))throw new SyntaxError(`page: the named mark in ${e} is not [name, attrs]`);if(s[0]===Gt)throw new SyntaxError(`page: ${Gt} is reserved`);t.push({name:s[0],attrs:si(s[1])})}n=i}return t}var yf=(e,t)=>{if(e.name!==t.name)return e.name<t.name?-1:1;let n=JSON.stringify(e.attrs),o=JSON.stringify(t.attrs);return n===o?0:n<o?-1:1};function Qe(e){let t=[],n=[],o=new Set;for(let i of e)if(i.name===void 0){if(o.has(i.token))throw new TypeError(`page: duplicate mark descriptor ${i.token}`);o.add(i.token),n.push(i.token)}else{let s=JSON.stringify([i.name,i.attrs]);if(o.has(s))throw new TypeError(`page: duplicate mark descriptor ${s}`);o.add(s),t.push({name:i.name,attrs:si(i.attrs)})}return t.sort(yf),n.length?[...t,{tokens:n}]:t}function Bt(e){if(!Array.isArray(e))throw new TypeError("page: opaque entries are not a list");let t=[];for(let n of e){if(!Ge(n))throw new TypeError("page: an opaque entry is not an object");if(n.tokens!==void 0){if(Object.keys(n).length!==1||!Array.isArray(n.tokens))throw new TypeError("page: an opaque entry is not { tokens: [...] }");for(let o of n.tokens){let i=Ye(o);if(i.length!==1||i[0].name!==void 0)throw new SyntaxError(`page: malformed mark token ${o}`);t.push(i[0])}}else{if(Object.keys(n).length!==2||typeof n.name!="string"||!zl.test(n.name)||!Ge(n.attrs))throw new TypeError("page: an opaque entry is not { name, attrs }");if(n.name===Gt)throw new SyntaxError(`page: ${Gt} is reserved`);t.push({name:n.name,attrs:In(n.attrs)})}}return Qe(t)}function Pn(e){let t="";for(let n of Bt(e))n.tokens?t+=n.tokens.join(""):t+=Bl+JSON.stringify([n.name,n.attrs]);return t}var wf=(()=>{let e=new pt.MarkType(Pl,Object.keys(ii.marks).length,ii,{attrs:{entries:{default:[]}},inclusive:!1,excludes:"",toDOM:()=>["span",0]});return e.excluded=[],e})(),Fl=e=>e.type.name===Pl,Vl=e=>wf.create({entries:Bt(e)});function tu(e){let t=Object.create(null);for(let n of Bt(e))n.tokens?t[Gt]={tokens:[...n.tokens]}:t[n.name]=si(n.attrs);return t}var bf=e=>e.split("!")[0].split("~")[0],Il=e=>e.includes("!");function eu(e){let t=new Set;for(let o of Object.keys(e))Il(o)&&e[o]&&t.add(o.split("!")[0]);let n=[];for(let[o,i]of Object.entries(e)){if(i==null||Il(o)||t.has(o))continue;let s=bf(o);if(s===Gt){if(!Ge(i)||Object.keys(i).length!==1||!Array.isArray(i.tokens))throw new TypeError(`page: ${Gt} is not { tokens: [...] }`);n.push({tokens:i.tokens})}else n.push({name:s,attrs:Ge(i)?i:{}})}return Bt(n)}var ri="\uFFFC",Jl={strong:"b",em:"i",strike:"s",code:"c",link:"a"},vf=Object.fromEntries(Object.entries(Jl).map(([e,t])=>[t,e]));function kf(e){let t="";for(let n of e){if(Fl(n)){t+=Pn(n.attrs.entries);continue}let o=Jl[n.type.name];if(!o)throw new TypeError(`page: the mark ${n.type.name} has no key code`);t+=o;let i=Object.keys(n.type.attrs);i.length&&(t+=JSON.stringify(i.map(s=>n.attrs[s])))}return t}var jl=new WeakMap;function xf(e,t){if(!t)return pt.Mark.none;let n=jl.get(e);n||jl.set(e,n=new Map);let o=n.get(t);if(o)return o;o=[];let i=[];for(let s of Ye(t)){let r=s.code===void 0?null:vf[s.code];if(!r){i.push(s);continue}let l=e.marks[r];if(!l)throw new TypeError(`page: unknown mark code ${s.code} in ${t}`);let a=s.attrs?Object.fromEntries(Object.keys(l.attrs).map((c,h)=>[c,s.attrs[h]])):null;o=l.create(a).addToSet(o)}return i.length&&(o=Vl(Qe(i)).addToSet(o)),n.set(t,o),o}function li(e){let t="",n=[];return e.forEach(o=>{if(o.isText){let i=kf(o.marks);t+=o.text;for(let s=0;s<o.text.length;s++)n.push(i)}else t+=ri,n.push("@"+JSON.stringify(o.toJSON()))}),{c:t,m:n}}function ql(e){let t=[];for(let n of e){let o=t[t.length-1];o&&o[1]===n?o[0]++:t.push([1,n])}return t}var Sf=e=>Array.isArray(e)&&Array.isArray(e[0]);function ai(e,t){if(!Sf(e))return e;let n=[];for(let o of e){if(!Array.isArray(o)||!Number.isInteger(o[0])||o[0]<1||typeof o[1]!="string"||n.length+o[0]>t)return null;for(let i=0;i<o[0];i++)n.push(o[1])}return n.length===t?n:null}var Of=e=>e>=55296&&e<=56319,Ll=e=>e&&e[0]!=="@"?e:"";function ci(e,t,n,o=null){let i=[],s=r=>o?r.filter(l=>o.allowsMarkType(l.type)):r;for(let r=0;r<t.length;){let l=n&&n[r]||"";if(t[r]===ri&&l[0]==="@"){i.push(pt.Node.fromJSON(e,JSON.parse(l.slice(1)))),r++;continue}let a=Ll(l),c=r+1;for(;c<t.length&&!(t[c]===ri&&(n&&n[c]||"")[0]==="@")&&Ll(n&&n[c]||"")===a;)c++;c<t.length&&Of(t.charCodeAt(c-1))&&c++,i.push(e.text(t.slice(r,c),s(xf(e,a)))),r=c}return i}var Mf="clay-page-remote",Ze="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Cf=/^[0-9A-Za-z]*[1-9A-Za-z]$/,_e=e=>typeof e=="string"&&Cf.test(e);function hi(e,t){if(t!==null){let i=0;for(;(e[i]||"0")===t[i];)i++;if(i>0)return t.slice(0,i)+hi(e.slice(i),t.slice(i))}let n=e?Ze.indexOf(e[0]):0,o=t!==null?Ze.indexOf(t[0]):Ze.length;return o-n>1?Ze[Math.round((n+o)/2)]:t!==null&&t.length>1?t.slice(0,1):Ze[n]+hi(e.slice(1),null)}function Wl(e=null,t=null){if(e!==null&&!_e(e))throw new TypeError(`page: invalid order key ${e}`);if(t!==null&&!_e(t))throw new TypeError(`page: invalid order key ${t}`);if(e!==null&&t!==null&&e>=t)throw new RangeError(`page: order key ${e} is not before ${t}`);return hi(e??"",t)}function pe(e,t,n){if(n<=0)return[];if(n===1)return[Wl(e,t)];let o=Wl(e,t),i=Math.floor(n/2);return[...pe(e,o,i),o,...pe(o,t,n-i-1)]}function di(e){return Object.keys(e).sort((t,n)=>{let o=e[t].pos??"",i=e[n].pos??"";return o!==i?o<i?-1:1:t<n?-1:t>n?1:0})}function Nf(e="b"){let t=new Uint8Array(4);return globalThis.crypto.getRandomValues(t),`${e}-${Date.now().toString(36)}${Array.from(t,n=>(n%36).toString(36)).join("")}`}var Af=new Set(["id","pos"]),Df=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Ef=e=>e===null||typeof e!="object"?e:JSON.parse(JSON.stringify(e));function Tf(e){let t={};for(let[n,o]of Object.entries(e.type.spec.attrs||{}))Af.has(n)||Df(e.attrs[n],o.default)||(t[n]=Ef(e.attrs[n]));return t}function $f(e){let{c:t,m:n}=li(e.content);return n.some(Boolean)?{c:t,m:ql(n)}:t}function Rf(e,t){if(t!==null&&typeof t=="object"&&typeof t.c=="string"){let o=ai(t.m,t.c.length);if(o)return ci(e,t.c,o,e.nodes.table_cell)}let n=kt(t);return n?e.text(n):null}function If(e){let t={t:e.type.name,pos:e.attrs.pos,...Tf(e)};if(e.type.name==="table"){let n={};e.forEach(o=>{let i={};o.forEach(s=>{i[s.attrs.col]=$f(s)}),n[o.attrs.id]={pos:o.attrs.pos,cells:i}}),t.rows=n}else if(e.type.spec.content){let{c:n,m:o}=li(e.content);t.c=n,o.some(Boolean)&&(t.m=o)}return t}function cu(e){let t={};return e.forEach(n=>{t[n.attrs.id]=If(n)}),t}function Pf(e,t,n){let{t:o,pos:i,c:s,m:r,w:l,rows:a,...c}=n;if(o==="table"){let p=di(c.cols||{}),{table_row:u,table_cell:f}=e.nodes,m=di(a||{}).map(g=>u.createChecked({id:g,pos:a[g].pos},p.map(b=>f.createChecked({col:b},Rf(e,a[g].cells?.[b])))));return e.nodes.table.createChecked({...c,id:t,pos:i},m)}let h=e.nodes[o];if(!h)throw new RangeError(`page: unknown block type ${o}`);let d=typeof s=="string"?ci(e,s,ai(r,s.length),h):Array.isArray(s)&&s.length?pt.Fragment.fromJSON(e,s):null;return h.create({...c,id:t,pos:i},d)}function hu(e,t){let n=di(t).map(o=>Pf(e,o,t[o]));return n.length?e.nodes.doc.create(null,n):e.nodes.doc.createAndFill()}function Bf(e){let t=[],n=[],o=new Array(e.length).fill(-1);e.forEach((s,r)=>{if(s===null)return;let l=0,a=t.length;for(;l<a;){let c=l+a>>1;t[c]<s?l=c+1:a=c}l>0&&(o[r]=n[l-1]),t[l]=s,n[l]=r});let i=new Set;for(let s=n[t.length-1]??-1;s>=0;s=o[s])i.add(s);return i}function Kl(e,t){let n=new Map;e.forEach(({id:r,rank:l=0},a)=>{r&&(!n.has(r)||l>(e[n.get(r)].rank??0))&&n.set(r,a)});let o=e.map(({id:r},l)=>!r||n.get(r)!==l),i=Bf(e.map(({pos:r},l)=>!o[l]&&_e(r)?r:null)),s=e.map(()=>null);for(let r=0;r<e.length;){if(i.has(r)){r++;continue}let l=r;for(;l<e.length&&!i.has(l);)l++;let a=r>0?e[r-1].pos:null,c=l<e.length?e[l].pos:null,h=pe(a,c,l-r);for(let d=r;d<l;d++)s[d]={id:o[d]?Nf(t):e[d].id,pos:h[d-r]};r=l}return s}function zf(e){for(let t=0;t<e.steps.length;t++){let n=e.steps[t];if(n instanceof he.ReplaceStep){if(n.slice.openStart||n.slice.openEnd)return!1;for(let s=0;s<n.slice.content.childCount;s++)if(!n.slice.content.child(s).isInline)return!1}else if(!(n instanceof he.AddMarkStep||n instanceof he.RemoveMarkStep))return!1;let o=e.docs[t].resolve(n.from),i=e.docs[t].resolve(n.to);if(o.depth!==1||i.depth!==1||o.index(0)!==i.index(0)||!o.parent.isTextblock)return!1}return!0}function du(){let e=new WeakSet,t=n=>{let o=new Set,i=null,s=!0;return n.forEach(r=>{if((!r.attrs.id||o.has(r.attrs.id)||!_e(r.attrs.pos)||i!==null&&i>=r.attrs.pos)&&(s=!1),o.add(r.attrs.id),i=r.attrs.pos,r.type.name!=="table")return;let l=new Set,a=null;r.forEach(c=>{(!c.attrs.id||l.has(c.attrs.id)||!_e(c.attrs.pos)||a!==null&&a>=c.attrs.pos)&&(s=!1),l.add(c.attrs.id),a=c.attrs.pos})}),s};return new To.Plugin({state:{init(n,o){return t(o.doc)&&e.add(o.doc),null},apply(){return null}},appendTransaction(n,o,i){if(e.has(o.doc)&&n.every(zf))return e.add(i.doc),null;if(!n.some(u=>u.docChanged&&!u.getMeta(Mf)))return e.has(o.doc)&&t(i.doc)&&e.add(i.doc),null;let s=i.tr,r=(u,f,m)=>{m&&s.setNodeMarkup(f,null,{...u.attrs,...m})},l=new he.Mapping;for(let u of n)l.appendMapping(u.mapping);let a=new Map,c=(u,f)=>{if(!u.attrs.id)return;let m=l.mapResult(f,1);a.set(u.attrs.id,{node:u,at:m.deleted?null:m.pos})};o.doc.forEach((u,f)=>{c(u,f),u.type.name==="table"&&u.forEach((m,g)=>c(m,f+1+g))});let h=(u,f)=>{let m=a.get(u.attrs.id);return m?(m.node.content.eq(u.content)?2:0)+(m.at===f?1:0):0},d=u=>u.map(({node:f,at:m})=>({...f.attrs,rank:h(f,m)})),p=[];i.doc.forEach((u,f)=>p.push({node:u,at:f})),Kl(d(p),"b").forEach((u,f)=>r(p[f].node,p[f].at,u));for(let{node:u,at:f}of p){if(u.type.name!=="table")continue;let m=[];u.forEach((g,b)=>m.push({node:g,at:f+1+b})),Kl(d(m),"r").forEach((g,b)=>r(m[b].node,m[b].at,g))}return s.docChanged||e.add(i.doc),s.docChanged?s:null}})}var fi=class extends Error{constructor(t,n){super(`CSV ${t} at line ${n}`),this.name="CsvError",this.code=t,this.line=n}};function Ff(e){let t=new Map([[",",0],[";",0],[" ",0]]),n=!1;for(let o=0;o<e.length;o++){let i=e[o];if(i==='"')n&&e[o+1]==='"'?o++:n=!n;else{if(!n&&(i==="\r"||i===`
12
+ `))break;!n&&t.has(i)&&t.set(i,t.get(i)+1)}}return[...t].sort((o,i)=>i[1]-o[1])[0][0]}function uu(e,{delimiter:t}={}){if(e=String(e).replace(/^\uFEFF/,""),t??=Ff(e),typeof t!="string"||t.length!==1||/["\r\n]/.test(t))throw new TypeError("CSV delimiter must be one non-newline character");let n=[],o=[],i="",s=!1,r=1,l=1;for(let d=0;d<e.length;d++){let p=e[d];s?p==='"'?e[d+1]==='"'?(i+='"',d++):s=!1:p==="\r"||p===`
13
+ `?(i+=p,p==="\r"&&e[d+1]===`
14
+ `&&(i+=e[++d]),r++):i+=p:p==='"'&&i===""?(s=!0,l=r):p===t?(o.push(i),i=""):p==="\r"||p===`
15
+ `?(o.push(i),n.push(o),o=[],i="",p==="\r"&&e[d+1]===`
16
+ `&&d++,r++):i+=p}if(s)throw new fi("unterminated-quote",l);if((o.length||i!==""||e&&!/[\r\n]$/.test(e))&&n.push([...o,i]),!n.length)return{header:[],rows:[]};let[a,...c]=n,h=Math.max(a.length,...c.map(d=>d.length));a.length=h;for(let d=0;d<h;d++)a[d]??="";for(let d of c)for(let p=d.length;p<h;p++)d.push("");return{header:a,rows:c}}function pi(e){if(typeof e!="string"||!/^[+-]?(?:0|[1-9]\d*)(?:[.,]\d+)?$/.test(e))return null;let t=Number(e.replace(",","."));return Number.isFinite(t)?t:null}function Hl(e,t){return e.map((n,o)=>{let i=t.map(r=>r[o]??"").filter(r=>r.trim()!=="");return i.length?new Set(i.map(r=>r.includes(",")?",":r.includes(".")?".":null).filter(Boolean)).size<=1&&i.every(r=>pi(r)!==null)?"number":i.every(r=>{if(!/^\d{4}-\d{2}-\d{2}$/.test(r))return!1;let l=new Date(`${r}T00:00:00Z`);return!Number.isNaN(l.getTime())&&l.toISOString().slice(0,10)===r})?"date":"text":"text"})}var Vf=Object.freeze(["text","number","date"]);function mu(e,t){return Vf.includes(e)?e:Hl([""],t.map(n=>[n]))[0]}function gu({header:e,rows:t},{maxBytes:n=1/0,newId:o}={}){if(typeof o!="function")throw new TypeError("tableFromCsv needs newId");let i=Hl(e,t),s={},r=e.map(()=>o()),l=pe(null,null,e.length);e.forEach((u,f)=>{s[r[f]]={pos:l[f],name:u,kind:i[f]}});let a={},c=pe(null,null,t.length),h=new TextEncoder,d=h.encode(JSON.stringify({cols:s,rows:a})).length,p=0;for(let u=0;u<t.length;u++){let f=o(),m={pos:c[u],cells:Object.fromEntries(r.map((b,y)=>[b,t[u][y]??""]))},g=h.encode(`${p?",":""}${JSON.stringify(f)}:${JSON.stringify(m)}`).length;if(d+g>n)break;a[f]=m,d+=g,p++}return{cols:s,rows:a,truncated:p===t.length?null:{kept:p,total:t.length}}}var Yt=e=>String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),R=e=>Number(e.toFixed(2)).toString();function Ul(e,t,n){e===t&&(e-=Math.max(Math.abs(e)*.05,1),t+=Math.max(Math.abs(t)*.05,1));let o=(t-e)/(n-1),i=10**Math.floor(Math.log10(o)),s=[1,2,5,10].map(a=>a*i),r=s.find(a=>Math.floor(t/a)-Math.ceil(e/a)+1<=n)??s.at(-1);for(;Math.floor(t/r)-Math.ceil(e/r)+1>n;)r*=2;let l=[];for(let a=Math.ceil(e/r);a<=Math.floor(t/r);a++)l.push(Number((a*r).toPrecision(12)));return l.length?l:[Number(e.toFixed(2)),Number(t.toFixed(2))]}function Gl(e,t){if(!t)return{state:"missing",reason:"table"};let n=t.cols??[],o=t.rows??[];if(!n.find(h=>h.id===e.x)||!e.series?.length||e.series.some(h=>!n.some(d=>d.id===h)))return{state:"missing",reason:"column"};let s=e.series.map((h,d)=>{let p=n.find(f=>f.id===h),u=o.map((f,m)=>({id:`${e.id}:${f.id}:${h}`,rowId:f.id,colId:h,rowIndex:m,xLabel:kt(f.cells?.[e.x]),value:pi(kt(f.cells?.[h])),highlight:f.id===e.highlight}));return{id:h,name:p.name,color:`var(--chart-${d%6+1})`,points:u}}),r=s.flatMap(h=>h.points),l=r.map(h=>h.value).filter(h=>h!==null),a=l.length?l.reduce((h,d)=>Math.min(h,d),1/0):0,c=l.length?l.reduce((h,d)=>Math.max(h,d),-1/0):1;if(e.type==="bar")a=Math.min(a,0),c=Math.max(c,0);else{let h=(c-a||Math.max(Math.abs(c),1))*.05;a-=h,c+=h}return a===c&&(c=a+1),{state:"ok",type:e.type,title:e.title??"",series:s,points:r,xLabels:o.map(h=>kt(h.cells?.[e.x])),yTicks:Ul(a,c,6),narrowTicks:Ul(a,c,3),domain:[a,c]}}function Yl(e,{width:t=640,height:n=320,narrow:o=!1}={}){if(e.state==="missing")return`<svg xmlns="http://www.w3.org/2000/svg" role="img" width="${t}" height="80" viewBox="0 0 ${t} 80"><title>Chart source missing</title><text x="12" y="44">Chart source missing</text></svg>`;let i={left:52,right:72,top:28,bottom:48},s=Math.max(1,t-i.left-i.right),r=Math.max(1,n-i.top-i.bottom),[l,a]=e.domain,c=f=>i.top+(a-f)/(a-l)*r,h=e.xLabels.length,d=f=>i.left+(h<=1?s/2:f*s/(h-1)),p=[`<svg xmlns="http://www.w3.org/2000/svg" role="img" width="${t}" height="${n}" viewBox="0 0 ${t} ${n}">`,`<title>${Yt(e.title)}</title>`],u=e.series.map(f=>{let m=f.points.filter(g=>g.value!==null);return`${f.name}: ${m.length?`${R(m[0].value)} to ${R(m.at(-1).value)}`:"no values"}`}).join("; ");p.push(`<desc>${Yt(u)}</desc>`);for(let f of o?e.narrowTicks:e.yTicks){let m=R(c(f));p.push(`<line x1="${i.left}" y1="${m}" x2="${R(i.left+s)}" y2="${m}" stroke="currentColor" opacity="0.15"/><text x="${i.left-8}" y="${R(c(f)+4)}" text-anchor="end">${R(f)}</text>`)}if(e.type==="bar"){let f=s/Math.max(h,1),m=Math.max(1,Math.min(32,f*.7/e.series.length)),g=c(0);e.series.forEach((b,y)=>{b.points.forEach(S=>{if(S.value===null)return;let T=i.left+(S.rowIndex+.5)*f-e.series.length*m/2+y*m,rt=c(S.value);p.push(`<rect data-point="${Yt(S.id)}"${S.highlight?' data-highlight="true"':""} x="${R(T)}" y="${R(Math.min(rt,g))}" width="${R(m)}" height="${R(Math.abs(g-rt))}" fill="${b.color}"/>`)});let w=[...b.points].reverse().find(S=>S.value!==null);if(w){let S=i.left+(w.rowIndex+.5)*f-e.series.length*m/2+y*m;p.push(`<text x="${R(S+m/2)}" y="${R(Math.min(c(w.value),g)-7)}" text-anchor="middle">${Yt(b.name)}</text>`)}})}else e.series.forEach(f=>{let m=[],g=()=>{m.length>1&&p.push(`<polyline points="${m.join(" ")}" fill="none" stroke="${f.color}" stroke-width="2"/>`),m=[]};f.points.forEach(y=>{if(y.value===null){g();return}m.push(`${R(d(y.rowIndex))},${R(c(y.value))}`),p.push(`<circle data-point="${Yt(y.id)}"${y.highlight?' data-highlight="true"':""} cx="${R(d(y.rowIndex))}" cy="${R(c(y.value))}" r="3" fill="${f.color}"/>`)}),g();let b=[...f.points].reverse().find(y=>y.value!==null);b&&p.push(`<text x="${R(d(b.rowIndex)+7)}" y="${R(c(b.value)-5)}">${Yt(f.name)}</text>`)});return e.xLabels.forEach((f,m)=>{let g=e.type==="bar"?i.left+(m+.5)*s/Math.max(h,1):d(m);p.push(`<text x="${R(g)}" y="${R(n-14)}" text-anchor="middle">${Yt(f)}</text>`)}),p.push("</svg>"),p.join("")}var on="\uFFFC",yi='@{"type":"hard_break"}',Xl=["b","i","s","c","a"],jf={b:"strong",i:"em",s:"s",c:"code"},Lf=["a","b","i","s","c"],Jf=new Set(Xl),tn="data-clay-page-opaque",wi="data-clay-page-value",Bn="data-clay-page-marks",bi="1",ta=new Set(["id","t","parent","c","m"]),Vn=e=>Object.hasOwn(sn,e),sn={paragraph:{parent:null},heading:{parent:null,level:2},list_item:{parent:null,kind:"bullet",indent:0,checked:!1,owner:null,due:null},callout:{parent:null},code_block:{parent:null,lang:""},toggle:{parent:null,open:!1},divider:{parent:null},image:{parent:null,src:"",alt:"",caption:"",width:null,align:null},file:{parent:null,src:"",name:"",size:null,mime:null},table:{parent:null,cols:{},sort:null},chart:{parent:null,source:null,kind:"line",x:null,series:[],title:"",highlight:null},board:{parent:null,columns:{},cards:{}},tool:{parent:null,artifact:null,rev:null,state:{}},preserved:{parent:null,html:""}},qf=new Set(["paragraph","heading","list_item","callout","code_block","toggle"]),ea=(e,t)=>xt(e)===xt(t);function rn(e){return Object.keys(e).sort((t,n)=>{let o=e[t].pos??"",i=e[n].pos??"";return o!==i?o<i?-1:1:t<n?-1:t>n?1:0})}var jn=e=>{let t="";for(let n of new TextEncoder().encode(e))t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},Wf=e=>{let t=atob(String(e).replace(/-/g,"+").replace(/_/g,"/"));return new TextDecoder().decode(Uint8Array.from(t,n=>n.charCodeAt(0)))},mi=e=>e===null||typeof e!="object"?!1:Array.isArray(e)?e.some(mi):Object.keys(e).some(t=>t==="__proto__"||mi(e[t]));function na(e){let t;try{t=JSON.parse(Wf(e))}catch{throw new SyntaxError("page: an envelope is not readable canonical JSON")}try{In(t)}catch(n){throw new SyntaxError(n.message)}if(mi(t))throw new SyntaxError("page: an envelope holds a prototype key");return t}function Kf(e){let t=na(e);if(t===null||typeof t!="object"||Array.isArray(t))throw new SyntaxError("page: a block envelope is not a record");if("id"in t||"pos"in t)throw new SyntaxError("page: a block envelope holds a structural field");if("t"in t&&(typeof t.t!="string"||!t.t))throw new SyntaxError("page: a block envelope names no type");return t}function oa(e){try{return Bt(na(e))}catch(t){throw t instanceof SyntaxError?t:new SyntaxError(t.message)}}var Ou=e=>oa(e),ia=e=>` ${tn}="${bi}" ${wi}="${Ln(jn(xt(e)))}"`,Hf=e=>e.length?` ${Bn}="${Ln(jn(JSON.stringify(e)))}"`:"",Mu=e=>({[tn]:bi,[wi]:jn(xt(e))}),Cu=e=>({[Bn]:jn(JSON.stringify(Bt(e)))});function zn(e,t){if(!Array.isArray(e))return null;if(!Array.isArray(e[0]))return e.length===t?e:null;let n=[];for(let o of e){if(!Array.isArray(o)||!Number.isInteger(o[0])||o[0]<1||typeof o[1]!="string"||n.length+o[0]>t)return null;for(let i=0;i<o[0];i++)n.push(o[1])}return n.length===t?n:null}function sa(e){let t=[];for(let n of e){let o=t[t.length-1];o&&o[1]===n?o[0]++:t.push([1,n])}return t}function ra(e){let t={};if(!e||e[0]==="@")return{marks:t,entries:[]};let n=[];for(let o of Ye(e))o.name===void 0&&Jf.has(o.code)?t[o.code]=o.attrs??!0:n.push(o);return{marks:t,entries:n.length?Qe(n):[]}}var la=(e,t,n)=>{if(!e)return"";if(e[0]==="@")return e===yi&&t[n]===on?e:"";let{marks:o,entries:i}=ra(e);return ha(ca(o),i)},aa=/^(javascript|vbscript|data):/i,ca=e=>(e.a&&aa.test(String(e.a[0]).replace(/[\u0000-\u0020]/g,""))&&delete e.a,e);function ha(e,t=[]){let n="";for(let o of Xl)e[o]&&(n+=o,Array.isArray(e[o])&&(n+=JSON.stringify(e[o])));return t.length?n+Pn(t):n}function st(e,t){if(!e.includes(`
17
+ `)&&!e.includes("\r"))return{c:e,units:t};let n="",o=[];for(let i=0;i<e.length;)if(/\s/.test(e[i])&&e[i]!=="\xA0"){let s=i;for(;s<e.length&&/\s/.test(e[s])&&e[s]!=="\xA0";)s++;let r=e.slice(i,s);/[\n\r]/.test(r)?i>0&&s<e.length&&(n+=" ",o.push(t?t[i]:"")):(n+=r,t?o.push(...t.slice(i,s)):o.push(...r.split("").map(()=>""))),i=s}else n+=e[i],o.push(t?t[i]:""),i++;return{c:n,units:o}}function en(e,t){let n={c:e};return t&&t.some(Boolean)&&(n.m=sa(t)),n}function Nu(e){let t={};for(let n of e){if(!n||typeof n!="object")continue;let o=n.deleted||{};for(let[i,s]of Object.entries(n.blocks||{})){if(o[i]||!s||typeof s!="object")continue;let{w:r,...l}=s;t[i]=l}}return t}function Uf(e){let t=[],n=[],o=null;for(let i of rn(e)){let s=e[i],r=typeof s.t=="string"&&s.t?s.t:null,l=s.parent??null;if(l!==null){let h=n.lastIndexOf(l);h<0&&(l=null),n.length=h<0?0:h+1}else n.length=0;let a=0;if(r==="list_item"){let h=o&&o.t==="list_item"&&o.parent===l,d=Number.isInteger(s.indent)&&s.indent>0?s.indent:0;a=h?Math.min(d,o.indent+1):0}let c={id:i,b:s,t:r,parent:l,indent:a};t.push(c),o=c,r==="toggle"&&n.push(i)}return t}var j=(e,t)=>{let n={};for(let[o,i]of Object.entries(t))(!(o in sn[e])||!ea(i,sn[e][o]))&&(n[o]=i);return n},Fn=e=>typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):null;function Gf(e){if(e===null||typeof e!="object"||typeof e.c!="string")return st(kt(e),null).c;let t=zn(e.m,e.c.length),n=t&&t.map((s,r)=>la(s,e.c,r));if(!n)return st(kt(e),null).c;let o=st(e.c,n),i=en(o.c,o.units);return i.m?i:i.c}function Yf(e){let t=e.cols&&typeof e.cols=="object"?e.cols:{},n=e.rows&&typeof e.rows=="object"?e.rows:{},o=rn(t);return{cols:o.map(i=>({id:i,name:st(String(t[i].name??""),null).c,...t[i].kind!=null?{kind:String(t[i].kind)}:{},...Fn(t[i].width)?{width:Fn(t[i].width)}:{}})),rows:rn(n).map(i=>({id:i,cells:Object.fromEntries(o.map(s=>[s,Gf(n[i].cells?.[s])]))}))}}function Qf(e){let t=e.columns&&typeof e.columns=="object"?e.columns:{},n=e.cards&&typeof e.cards=="object"?e.cards:{},o=rn(t),i=[...new Set(Object.values(n).map(l=>String(l.col??"")))].filter(l=>!t[l]).sort(),s=[...o,...i],r=l=>rn(Object.fromEntries(Object.entries(n).filter(([,a])=>String(a.col??"")===l)));return{columns:o.map(l=>({id:l,name:st(String(t[l].name??""),null).c})),cards:s.flatMap(l=>r(l).map(a=>{let c=n[a];return{id:a,col:l,title:st(String(c.title??""),null).c,...c.owner!=null?{owner:String(c.owner)}:{},...c.due!=null?{due:String(c.due)}:{}}}))}}var Zf=e=>{let{t,parent:n,id:o,...i}=e;return{t,...i}},gi=e=>{let t={};for(let[n,o]of Object.entries(e))!ta.has(n)&&!(Vn(e.t)&&Object.hasOwn(sn[e.t],n))&&(t[n]=o);return Object.keys(t).length?ia(t):""},_f=(e,t)=>{let n={};for(let[o,i]of Object.entries(t))!ta.has(o)&&o!=="pos"&&!Object.hasOwn(sn[e],o)&&(n[o]=i);return n};function Xf({id:e,b:t,t:n,parent:o,indent:i}){if(!n)return{id:e,t:"preserved",html:""};if(!Vn(n)){let{t:S,id:T,pos:rt,parent:M,...D}=t;if(typeof D.c=="string"&&D.m!==void 0){let P=zn(D.m,D.c.length);P&&P.some(Boolean)?D.m=sa(P):delete D.m}return{id:e,t:n,...o?{parent:o}:{},...D}}let{t:s,id:r,pos:l,c:a,m:c,rows:h,cols:d,columns:p,cards:u,parent:f,indent:m,...g}=t,b=_f(n,g);for(let S of Object.keys(b))delete g[S];let y={...g,parent:o};n==="list_item"&&(y.indent=i),n==="heading"&&(y.level=tp(g.level??2)),n==="image"&&y.width!=null&&(y.width=da(String(y.width))),n==="image"&&(y.align=fa(y.align)),n==="image"&&typeof y.caption=="string"&&(y.caption=st(y.caption,null).c),n==="chart"&&typeof y.title=="string"&&(y.title=st(y.title,null).c),n==="table"?Object.assign(y,Yf(t)):n==="board"&&Object.assign(y,Qf(t));let w={id:e,t:n,...j(n,y),...b};if(n==="table"&&(w.cols=y.cols,w.rows=y.rows),n==="board"&&(w.columns=y.columns,w.cards=y.cards),qf.has(n)){let S=typeof a=="string"?a:"",T=zn(c,S.length),rt=T&&T.map((M,D)=>la(M,S,D));if(n==="code_block")Object.assign(w,{c:S.replace(/\r\n?/g,`
18
+ `)});else{let M=st(S,rt);Object.assign(w,en(M.c,M.units))}}return w}var tp=e=>Math.min(6,Math.max(1,Number.isInteger(e)?e:2)),da=e=>/^\d+$/.test(e)?Number(e):e,fa=e=>e==="left"||e==="right"?e:null;function Au(e){return Uf(e).map(Xf)}var xt=e=>Array.isArray(e)?`[${e.map(xt).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(t=>JSON.stringify(t)+":"+xt(e[t])).join(",")}}`:JSON.stringify(e??null);function pa(e){let t=2166136261,n=-1623754710;for(let o=0;o<e.length;o++){let i=e.charCodeAt(o);t=Math.imul(t^i,16777619)>>>0,n=Math.imul(n^i,1540483477)>>>0,n=(n^n>>>15)>>>0}return t.toString(16).padStart(8,"0")+n.toString(16).padStart(8,"0")}var Du=e=>pa(xt(e)),ut=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r/g,"&#13;"),Ln=e=>ut(String(e)).replace(/"/g,"&quot;"),A=(e,t)=>t==null?"":` ${e}="${Ln(t)}"`;function vi(e,t,n=!0){let o=zn(t,e.length)||[],i="",s=[],r=l=>{for(;s.length>l;)i+=`</${s.pop().tag}>`};for(let l=0;l<e.length;){let a=o[l]||"";if(e[l]===on&&a[0]==="@"){r(0),i+=a===yi?"<br>":`<span data-atom="${Ln(a)}"></span>`,l++;continue}let c=l+1;for(;c<e.length&&(o[c]||"")===a&&!(e[c]===on&&a[0]==="@");)c++;let{marks:h,entries:d}=ra(a),p=Lf.filter(f=>h[f]).map(f=>({code:f,sig:f+JSON.stringify(h[f]),tag:f==="a"?"a":jf[f],href:f==="a"?h.a[0]:null}));d.length&&n&&p.push({sig:`marks${xt(d)}`,tag:"span",entries:d});let u=0;for(;u<s.length&&u<p.length&&s[u].sig===p[u].sig;)u++;r(u);for(let f of p.slice(u))i+=f.entries?`<span${Hf(f.entries)}>`:f.tag==="a"?`<a${A("href",f.href)}>`:`<${f.tag}>`,s.push(f);i+=ut(e.slice(l,c)),l=c}return r(0),i}var nn=e=>vi(e.c??"",e.m),ua=e=>e.artifact||e.rev||e.state&&Object.keys(e.state).length?`<script type="application/json" data-tool>${xt({artifact:e.artifact??null,rev:e.rev??null,state:e.state??{}}).replace(/</g,"\\u003c")}<\/script>`:"",ep=e=>typeof e=="string"?ut(e):e&&typeof e=="object"?vi(String(e.c??""),e.m):"",np=e=>Object.entries(e).map(([t,n])=>A(`data-${t}`,n)).join("");function op(e,t,n){let o=A("data-id",e.id);if(!Vn(e.t))return`<div${o}${ia(Zf(e))}>${vi(e.c??"",e.m,!1)}</div>`;let i=o+gi(e);switch(e.t){case"paragraph":return`<p${i}>${nn(e)}</p>`;case"heading":{let s=`h${e.level??2}`;return`<${s}${i}>${nn(e)}</${s}>`}case"callout":return`<aside${i} class="page-callout">${nn(e)}</aside>`;case"code_block":return`<pre${i}${A("data-lang",e.lang||null)}><code>${ut(e.c??"")}</code></pre>`;case"divider":return`<hr${i}>`;case"image":return`<figure${i} data-type="image"${A("data-align",e.align??null)}><img${A("src",e.src??"")}${A("alt",e.alt??"")}${A("width",e.width??null)}>${e.caption?`<figcaption>${ut(e.caption)}</figcaption>`:""}</figure>`;case"file":{let s=/^(https?:\/\/|\/(?!\/))/i.test(e.src??"")?e.src:null;return`<div${i} data-type="file"${A("data-src",e.src??"")}${A("data-name",e.name??"")}${A("data-size",e.size??null)}${A("data-mime",e.mime??null)}><a${A("href",s)} rel="noopener noreferrer">${ut(e.name||"file")}</a></div>`}case"table":{let s=e.cols.map(l=>`<th${A("data-col",l.id)}${A("data-kind",l.kind??null)}${A("data-width",l.width??null)}${A("style",l.width?`width:${l.width}px`:null)}>${ut(l.name)}</th>`).join(""),r=e.rows.map(l=>`<tr${A("data-id",l.id)}>${e.cols.map(a=>`<td>${ep(l.cells[a.id])}</td>`).join("")}</tr>`).join(`
19
+ `);return`<table${i}${A("data-sort",e.sort!=null?JSON.stringify(e.sort):null)}>
20
+ <thead><tr>${s}</tr></thead>
21
+ <tbody>
22
+ ${r}
23
+ </tbody>
24
+ </table>`}case"chart":{let s=np({source:e.source??null,kind:e.kind??null,x:e.x??null,series:e.series?JSON.stringify(e.series):null,highlight:e.highlight??null}),r=Gl({id:e.id,type:e.kind??"line",x:e.x,series:e.series??[],title:e.title??"",highlight:e.highlight},n.get(e.source));return`<figure${i} data-type="chart"${s}>${Yl(r,{width:640,height:320})}<figcaption>${ut(e.title??"")}</figcaption></figure>`}case"board":{let r=[...e.columns.map(l=>({...l,known:!0})),...[...new Set(e.cards.map(l=>l.col))].filter(l=>!e.columns.some(a=>a.id===l)).map(l=>({id:l,known:!1}))].map(l=>{let a=e.cards.filter(c=>c.col===l.id).map(c=>`<li${A("data-id",c.id)}${A("data-owner",c.owner??null)}${A("data-due",c.due??null)}>${ut(c.title)}</li>`).join("");return`<div${A("data-col",l.id)}${l.known?"":" data-missing"}>${l.known?`<h4>${ut(l.name)}</h4>`:""}<ul>${a}</ul></div>`});return`<section${i} data-type="board">
25
+ ${r.join(`
26
+ `)}
27
+ </section>`}case"tool":return`<section${i} data-type="tool">${ua(e)}</section>`;case"preserved":return ip(e,t,i);default:return""}}var ip=(e,t,n=A("data-id",e.id))=>`<div${n} data-type="preserved">${t.preserved(e.html||"")}</div>`,sp={preserved:e=>e,fallback:e=>e};function Eu(e){let t=(n,o)=>{if(!n)return"";let i=e.createElement("template");if(i.innerHTML=n,o){for(let s of i.content.querySelectorAll("script"))s.remove();for(let s of i.content.querySelectorAll("*"))for(let{name:r,value:l}of[...s.attributes])(/^on/i.test(r)||/^(href|src|action|formaction|xlink:href)$/i.test(r)&&aa.test(l.replace(/[\u0000-\u0020]/g,"")))&&s.removeAttribute(r)}return i.innerHTML};return{preserved:n=>t(n,!1),fallback:n=>t(n,!0)}}function Tu(e,{fallbackOf:t=()=>"",clean:n=sp}={}){let o=[],i=new Map(e.filter(c=>c.t==="table").map(c=>[c.id,c])),s=[null],r=[],l=c=>{r.length?o[o.length-1]+=c:o.push(c)},a=()=>{for(;r.length;){let c=r[r.length-1];o[o.length-1]+=`</li></${c}>`,r.pop()}};for(let c of e){let h=c.parent??null;for(;s.length>1&&s[s.length-1]!==h;)a(),l("</details>"),s.pop();if(c.t!=="list_item"&&a(),c.t==="list_item"){let d=c.indent??0,p=c.kind==="ordered"?"ol":"ul";for(;r.length>d+1;)l(`</li></${r[r.length-1]}>`),r.pop();r.length===d+1&&(l(r[d]===p?"</li>":`</li></${r[d]}>`),r[d]!==p&&r.pop()),r.length<d+1&&(l(`<${p}>`),r.push(p));let u=c.kind==="check"?`<input type="checkbox" disabled${c.checked?" checked":""}>`:"";l(`<li${A("data-id",c.id)}${A("data-owner",c.owner??null)}${A("data-due",c.due??null)}${gi(c)}>${u}${nn(c)}`);continue}if(c.t==="toggle"){l(`<details${A("data-id",c.id)}${gi(c)}${c.open?" open":""}><summary>${nn(c)}</summary>`),s.push(c.id);continue}if(c.t==="tool"){l(`<section${A("data-id",c.id)} data-type="tool">${ua(c)}${n.fallback(t(c.id))}</section>`);continue}l(op(c,n,i))}for(a();s.length>1;)l("</details>"),s.pop();return o.join(`
28
+ `)}var ma=new Set(["SCRIPT","STYLE","TEMPLATE","NOSCRIPT"]),Ql=new Set(["A","ABBR","B","BDI","BDO","BR","CITE","CODE","DATA","DEL","DFN","EM","FONT","I","INS","KBD","LABEL","MARK","Q","S","SAMP","SMALL","SPAN","STRIKE","STRONG","SUB","SUP","TIME","U","VAR","WBR"]);function ui(e,t=()=>!1){let n="",o=[],i=(s,r,l)=>{for(let a of s.childNodes){if(t(a))continue;if(a.nodeType===3){n+=a.data;let d=ha(ca({...r}),l);for(let p=0;p<a.data.length;p++)o.push(d);continue}if(a.nodeType!==1||ma.has(a.tagName))continue;let c=a.tagName.toLowerCase();if(c==="br"){n+=on,o.push(yi);continue}if(c==="span"&&a.hasAttribute("data-atom")){n+=on,o.push(a.getAttribute("data-atom"));continue}let h={...r};if(c==="span"&&a.hasAttribute(Bn)){i(a,h,Bt([...l,...oa(a.getAttribute(Bn))]));continue}c==="strong"||c==="b"?h.b=!0:c==="em"||c==="i"?h.i=!0:c==="s"||c==="del"||c==="strike"?h.s=!0:c==="code"?h.c=!0:c==="a"&&a.hasAttribute("href")&&(h.a=[a.getAttribute("href")]),i(a,h,l)}};return i(e,{},[]),st(n,o)}var Xe=e=>st(e?e.textContent:"",null).c,ki=e=>{if(!e.hasAttribute(tn))return null;if(e.getAttribute(tn)!==bi)throw new SyntaxError(`page: unknown envelope version ${e.getAttribute(tn)}`);let t=e.getAttribute(wi);if(t===null)throw new SyntaxError("page: a block envelope holds no value");return Kf(t)},$u=e=>ki(e),Zl=e=>{let t=ki(e);return t&&typeof t.t!="string"?t:null};function rp(e){let t=[],n=(h,d)=>{let p=null,u=()=>{if(!p)return;let f=ui(p);f.c&&t.push({id:null,t:"paragraph",parent:d,...en(f.c,f.units)}),p=null};for(let f of[...h.childNodes]){if(f.nodeType===3&&!f.data.trim()){p&&p.appendChild(f.cloneNode());continue}if(!(f.nodeType===8||f.nodeType===1&&ma.has(f.tagName))){if(f.nodeType===3||f.nodeType===1&&Ql.has(f.tagName)){p??=h.ownerDocument.createElement("p"),p.appendChild(f.cloneNode(!0));continue}u(),f.nodeType===1&&r(f,d)}}u()},o=h=>h.getAttribute("data-id")||null,i=(h,d,p,u)=>{let f=Zl(h);t.push({id:o(h),t:d,parent:p,...f?{...f,...u}:u})},s=(h,d,p)=>{for(let u of h.children){if(u.tagName!=="LI")continue;let f=[...u.childNodes].find(w=>w.nodeType===1&&w.tagName==="INPUT"&&(w.getAttribute("type")||"").toLowerCase()==="checkbox"),m=[...u.children].filter(w=>w.tagName==="UL"||w.tagName==="OL"),g=ui(u,w=>w===f||m.includes(w)),b=f?"check":h.tagName==="OL"?"ordered":"bullet",y={parent:d,kind:b,indent:p,checked:!!(f&&f.hasAttribute("checked")),owner:u.getAttribute("data-owner"),due:u.getAttribute("data-due")};t.push({id:o(u),t:"list_item",...j("list_item",y),...Zl(u)??{},...en(g.c,g.units)});for(let w of m)s(w,d,p+1)}},r=(h,d)=>{let p=h.tagName,u={parent:d},f=ki(h);if(f&&typeof f.t=="string"){if(Vn(f.t)||f.t==="opaque_block")throw new SyntaxError(`page: an envelope names the known block type ${f.t}`);let{t:y,...w}=f;t.push({id:o(h),t:y,parent:d,...w});return}let m=p==="P"&&h.children.length===1&&h.children[0].tagName==="IMG"&&!h.textContent.trim();if(p==="P"&&!m)return i(h,"paragraph",d,{...j("paragraph",u),...l(h)});if(/^H[1-6]$/.test(p))return i(h,"heading",d,{...j("heading",{...u,level:+p[1]}),...l(h)});if(p==="ASIDE")return i(h,"callout",d,{...j("callout",u),...l(h)});if(p==="PRE"){let y=h.querySelector(":scope > code");return i(h,"code_block",d,{...j("code_block",{...u,lang:h.getAttribute("data-lang")||""}),c:(y||h).textContent})}if(p==="HR")return i(h,"divider",d,j("divider",u));if(p==="UL"||p==="OL")return s(h,d,0);if(p==="DETAILS"){let y=h.querySelector(":scope > summary"),w=t.length;i(h,"toggle",d,{...j("toggle",{...u,open:h.hasAttribute("open")}),...l(y)});let S=h.ownerDocument.createElement("div");for(let T of[...h.childNodes])T!==y&&S.appendChild(T.cloneNode(!0));n(S,{ref:w});return}if(p==="FIGURE"&&h.getAttribute("data-type")==="chart"){let y=S=>h.getAttribute(`data-${S}`),w=[];try{w=JSON.parse(y("series")||"[]")}catch{}return i(h,"chart",d,j("chart",{...u,source:y("source"),kind:y("kind")||"line",x:y("x"),series:w,title:Xe(h.querySelector(":scope > figcaption")),highlight:y("highlight")}))}if(p==="DIV"&&h.getAttribute("data-type")==="file"){let y=h.getAttribute("data-size");return i(h,"file",d,j("file",{...u,src:h.getAttribute("data-src")||"",name:h.getAttribute("data-name")||"",size:y===null||y===""||!Number.isFinite(+y)?null:+y,mime:h.getAttribute("data-mime")||null}))}let g=p==="IMG"?h:p==="FIGURE"||m?h.querySelector(":scope > img"):null;if(g){let y=g.getAttribute("width");return i(h,"image",d,j("image",{...u,src:g.getAttribute("src")||"",alt:g.getAttribute("alt")||"",caption:p==="FIGURE"?Xe(h.querySelector(":scope > figcaption")):"",width:y===null?null:da(y),align:p==="FIGURE"?fa(h.getAttribute("data-align")):null}))}if(p==="TABLE")return i(h,"table",d,a(h,u));if(p==="SECTION"&&h.getAttribute("data-type")==="board")return i(h,"board",d,c(h,u));if(p==="SECTION"&&h.getAttribute("data-type")==="tool"){let y=h.querySelector(':scope > script[type="application/json"][data-tool]'),w={};try{w=y?JSON.parse(y.textContent):{}}catch{}return i(h,"tool",d,j("tool",{...u,artifact:w.artifact??null,rev:w.rev??null,state:w.state??{}}))}if(p==="DIV"&&h.getAttribute("data-type")==="preserved")return i(h,"preserved",d,j("preserved",{...u,html:h.innerHTML}));if(p==="DIV"&&[...h.children].every(y=>Ql.has(y.tagName)))return i(h,"paragraph",d,{...j("paragraph",u),...l(h)});let b=h.cloneNode(!0);return b.removeAttribute("data-id"),i(h,"preserved",d,j("preserved",{...u,html:b.outerHTML}))},l=h=>{let d=h?ui(h):{c:"",units:[]};return en(d.c,d.units)},a=(h,d)=>{let p=h.querySelector(":scope > thead > tr")||null,f=(p?[...p.children]:[]).map(w=>({id:w.getAttribute("data-col"),name:Xe(w),...w.hasAttribute("data-kind")?{kind:w.getAttribute("data-kind")}:{},...Fn(Number(w.getAttribute("data-width")))?{width:Fn(Number(w.getAttribute("data-width")))}:{}})),m=[...h.querySelectorAll(":scope > tbody > tr, :scope > tr")],g=Math.max(f.length,...m.map(w=>w.children.length),0);for(;f.length<g;)f.push({id:null,name:""});let b=m.map(w=>({id:w.getAttribute("data-id"),cellsAt:[...w.children].map(S=>{let T=l(S);return T.m?T:T.c})})),y=null;try{y=h.hasAttribute("data-sort")?JSON.parse(h.getAttribute("data-sort")):null}catch{}return{...j("table",{...d,sort:y}),cols:f,rows:b}},c=(h,d)=>{let p=[],u=[];for(let f of h.querySelectorAll(":scope > div[data-col], :scope > div")){let m=f.getAttribute("data-col"),g=f.hasAttribute("data-missing"),b=g?{id:m}:{id:m,name:Xe(f.querySelector(":scope > h4"))};g||p.push(b);for(let y of f.querySelectorAll(":scope > ul > li"))u.push({id:y.getAttribute("data-id"),colRef:b,title:Xe(y),...y.hasAttribute("data-owner")?{owner:y.getAttribute("data-owner")}:{},...y.hasAttribute("data-due")?{due:y.getAttribute("data-due")}:{}})}return{...j("board",d),columns:p,cards:u}};return n(e,null),t}function lp(e,{seed:t="",known:n=new Map,taken:o=new Set}={}){let i=0,s=h=>`${h}-a${pa(`${t}|${h}|${i++}`).slice(0,12)}`,r=new Map;e.forEach((h,d)=>{h.id&&(r.get(h.id)??r.set(h.id,[]).get(h.id)).push(d)});let l=new Map;for(let[h,d]of r){let p=n.get(h),u=p?d.find(f=>ea(_l(e[f]),_l(p))):void 0;l.set(h,u??d[0])}let a=e.map((h,d)=>h.id&&!/^~|~\d+$/.test(h.id)&&l.get(h.id)===d?h.id:s("b"));return e.map((h,d)=>{let{id:p,parent:u,...f}=h,m=u&&typeof u=="object"?a[u.ref]:u,g={id:a[d],t:f.t,...m?{parent:m}:{},...ga(f,["t"])};if(g.t==="table"){let b=new Set,y=new Set;g.cols=g.cols.map(w=>({...w,id:w.id&&!b.has(w.id)?(b.add(w.id),w.id):s("c")})),g.rows=g.rows.map(w=>({id:w.id&&!y.has(w.id)?(y.add(w.id),w.id):s("r"),cells:Object.fromEntries(g.cols.map((S,T)=>[S.id,w.cellsAt[T]??""]))}))}if(g.t==="board"){let b=new Set,y=new Set;for(let w of g.columns)(!w.id||y.has(w.id))&&(w.id=s("c")),y.add(w.id);g.cards=g.cards.map(({colRef:w,...S})=>({id:S.id&&!b.has(S.id)?(b.add(S.id),S.id):s("k"),col:w.id??"",title:S.title,...S.owner!=null?{owner:S.owner}:{},...S.due!=null?{due:S.due}:{}})),g.columns=g.columns.map(({id:w,name:S})=>({id:w,name:S}))}return g})}var ga=(e,t)=>Object.fromEntries(Object.entries(e).filter(([n])=>!t.includes(n))),_l=e=>ga(e,["id","parent"]);function Ru(e,t={}){return lp(rp(e),t)}export{pt as a,To as b,he as c,mc as d,nd as e,yd as f,Cd as g,Wd as h,of as i,Rn as j,Hp as k,oi as l,ii as m,Pl as n,Fl as o,Vl as p,tu as q,eu as r,kf as s,xf as t,li as u,ql as v,ai as w,ci as x,kt as y,Mf as z,_e as A,Wl as B,pe as C,di as D,Nf as E,$f as F,Rf as G,If as H,cu as I,Pf as J,hu as K,Kl as L,zf as M,du as N,fi as O,uu as P,pi as Q,Vf as R,mu as S,gu as T,Gl as U,Yl as V,on as W,yi as X,tn as Y,Bn as Z,sn as _,rn as $,Ou as aa,Mu as ba,Cu as ca,zn as da,sa as ea,Nu as fa,Au as ga,xt as ha,pa as ia,Du as ja,Eu as ka,Tu as la,$u as ma,Ru as na};