@thebase/ui 0.0.5 → 0.0.7

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 (236) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +2 -2
  3. package/dist/baseui.esm.js +10 -10
  4. package/dist/baseui.min.css +1 -1
  5. package/dist/baseui.min.js +10 -10
  6. package/dist/baseui.registry.json +5 -6
  7. package/dist/runtime/milkdown/apl-A2CKMNHU.js +1 -0
  8. package/dist/runtime/milkdown/asciiarmor-LYWOUGA4.js +1 -0
  9. package/dist/runtime/milkdown/asn1-NB5F53MP.js +1 -0
  10. package/dist/runtime/milkdown/asterisk-SIDVUCAX.js +1 -0
  11. package/dist/runtime/milkdown/block-G2R773CV.js +1 -0
  12. package/dist/runtime/milkdown/brainfuck-K7DBLI5P.js +1 -0
  13. package/dist/runtime/milkdown/chunk-2EZOVVY4.js +13 -0
  14. package/dist/runtime/milkdown/chunk-2FDN6WYA.js +0 -0
  15. package/dist/runtime/milkdown/chunk-2TBUBNYK.js +3 -0
  16. package/dist/runtime/milkdown/chunk-2XECCVBE.js +3 -0
  17. package/dist/runtime/milkdown/chunk-5ILY25KD.js +1 -0
  18. package/dist/runtime/milkdown/chunk-7GZI2HGN.js +1 -0
  19. package/dist/runtime/milkdown/chunk-7YQMEBMQ.js +1 -0
  20. package/dist/runtime/milkdown/chunk-BJC3HW5B.js +1 -0
  21. package/dist/runtime/milkdown/chunk-CFWAU3WN.js +1 -0
  22. package/dist/runtime/milkdown/chunk-DLMWAKB5.js +0 -0
  23. package/dist/runtime/milkdown/chunk-DO4RO6KD.js +0 -0
  24. package/dist/runtime/milkdown/chunk-DWBFWB4X.js +1 -0
  25. package/dist/runtime/milkdown/chunk-ILE44FN6.js +1 -0
  26. package/dist/runtime/milkdown/chunk-IPNUYGNC.js +0 -0
  27. package/dist/runtime/milkdown/chunk-JA3LDFRC.js +1 -0
  28. package/dist/runtime/milkdown/chunk-K2ROPYIW.js +1 -0
  29. package/dist/runtime/milkdown/chunk-KP5VFDTE.js +1 -0
  30. package/dist/runtime/milkdown/chunk-LDCXUKI3.js +1 -0
  31. package/dist/runtime/milkdown/chunk-MYC7FIB2.js +4 -0
  32. package/dist/runtime/milkdown/chunk-NX66TKTH.js +1 -0
  33. package/dist/runtime/milkdown/chunk-NXQJDWPI.js +1 -0
  34. package/dist/runtime/milkdown/chunk-OF2BVG4E.js +1 -0
  35. package/dist/runtime/milkdown/chunk-OQJVATGH.js +4 -0
  36. package/dist/runtime/milkdown/chunk-R43NMSZO.js +1 -0
  37. package/dist/runtime/milkdown/chunk-SIRQEE7R.js +1 -0
  38. package/dist/runtime/milkdown/chunk-SZCOI4YV.js +1 -0
  39. package/dist/runtime/milkdown/chunk-TEMVRH7B.js +1 -0
  40. package/dist/runtime/milkdown/chunk-TFG5E5LZ.js +5 -0
  41. package/dist/runtime/{streaming-WPAF6YN6.js → milkdown/chunk-TOUPIB5N.js} +2 -2
  42. package/dist/runtime/milkdown/chunk-U6C7MJSD.js +0 -0
  43. package/dist/runtime/milkdown/chunk-VFZ7ST3H.js +1 -0
  44. package/dist/runtime/{chunk-SGGMD6DA.js → milkdown/chunk-VJBGANAS.js} +4 -4
  45. package/dist/runtime/milkdown/chunk-WMT3RNOX.js +13 -0
  46. package/dist/runtime/milkdown/chunk-XNCXGIZE.js +41 -0
  47. package/dist/runtime/milkdown/chunk-Y4CBBIL4.js +1 -0
  48. package/dist/runtime/{chunk-7R75J74M.js → milkdown/chunk-ZGHJJLEG.js} +1 -1
  49. package/dist/runtime/milkdown/chunk-ZIYJY6SA.js +1 -0
  50. package/dist/runtime/milkdown/clike-EOWJN572.js +1 -0
  51. package/dist/runtime/milkdown/clipboard-5NOA4E34.js +1 -0
  52. package/dist/runtime/milkdown/clojure-VLG72YFE.js +1 -0
  53. package/dist/runtime/milkdown/cmake-2PXWCEDK.js +1 -0
  54. package/dist/runtime/milkdown/cobol-PMRFKEKB.js +1 -0
  55. package/dist/runtime/milkdown/coffeescript-B5G6C2AR.js +1 -0
  56. package/dist/runtime/milkdown/commonlisp-CFTTVW6U.js +1 -0
  57. package/dist/runtime/milkdown/commonmark-263P63KC.js +1 -0
  58. package/dist/runtime/milkdown/core-T2SC7EXQ.js +1 -0
  59. package/dist/runtime/milkdown/crystal-M6S3MKED.js +1 -0
  60. package/dist/runtime/milkdown/css-HESFBL5J.js +1 -0
  61. package/dist/runtime/milkdown/cursor-Z4UWEH5V.js +1 -0
  62. package/dist/runtime/milkdown/cypher-IIJXY2ZS.js +1 -0
  63. package/dist/runtime/milkdown/d-ZHLFM7BM.js +1 -0
  64. package/dist/runtime/milkdown/diff-7YFE6XTG.js +1 -0
  65. package/dist/runtime/milkdown/diff-K3BORLOX.js +1 -0
  66. package/dist/runtime/milkdown/dist-24V6SL4V.js +1 -0
  67. package/dist/runtime/milkdown/dist-34ZP4UZ2.js +1 -0
  68. package/dist/runtime/milkdown/dist-3LQISA7E.js +3 -0
  69. package/dist/runtime/milkdown/dist-4QC5HFKT.js +1 -0
  70. package/dist/runtime/milkdown/dist-562GM6I6.js +1 -0
  71. package/dist/runtime/milkdown/dist-5QJ34QYN.js +1 -0
  72. package/dist/runtime/milkdown/dist-657PKZSF.js +1 -0
  73. package/dist/runtime/milkdown/dist-6TS6SSJR.js +1 -0
  74. package/dist/runtime/milkdown/dist-7JICPTVR.js +1 -0
  75. package/dist/runtime/milkdown/dist-DERKVUMC.js +1 -0
  76. package/dist/runtime/milkdown/dist-MK4VEXBD.js +1 -0
  77. package/dist/runtime/milkdown/dist-NYN7ZJXK.js +1 -0
  78. package/dist/runtime/milkdown/dist-OPQE4Z43.js +1 -0
  79. package/dist/runtime/milkdown/dist-P4TF777A.js +1 -0
  80. package/dist/runtime/milkdown/dist-PEJBUU6H.js +6 -0
  81. package/dist/runtime/milkdown/dist-R2X7SQDZ.js +2 -0
  82. package/dist/runtime/milkdown/dist-RE2FJN7S.js +1 -0
  83. package/dist/runtime/milkdown/dist-THIQIX3E.js +1 -0
  84. package/dist/runtime/milkdown/dist-VEPIKH2V.js +7 -0
  85. package/dist/runtime/milkdown/dist-X22ABN6K.js +1 -0
  86. package/dist/runtime/milkdown/dist-YH3NI4VG.js +1 -0
  87. package/dist/runtime/milkdown/dockerfile-2B5D6FTU.js +1 -0
  88. package/dist/runtime/milkdown/dtd-NPOQOSDS.js +1 -0
  89. package/dist/runtime/milkdown/dylan-KB7QIKGL.js +1 -0
  90. package/dist/runtime/milkdown/ebnf-TBCUHQC6.js +1 -0
  91. package/dist/runtime/milkdown/ecl-OXWKHIHJ.js +1 -0
  92. package/dist/runtime/milkdown/eiffel-WRBXQVBO.js +1 -0
  93. package/dist/runtime/milkdown/elm-MZAQSXJY.js +1 -0
  94. package/dist/runtime/milkdown/erlang-PNSW52ER.js +1 -0
  95. package/dist/runtime/milkdown/esm-H2D66MX5.js +997 -0
  96. package/dist/runtime/milkdown/factor-JBYSQG3O.js +1 -0
  97. package/dist/runtime/milkdown/fcl-6ZY3XINI.js +1 -0
  98. package/dist/runtime/milkdown/forth-BAIG3TGB.js +1 -0
  99. package/dist/runtime/milkdown/fortran-MQWYHO5L.js +1 -0
  100. package/dist/runtime/milkdown/gas-Q6YL6AQO.js +1 -0
  101. package/dist/runtime/milkdown/gfm-IHXC5DQO.js +1 -0
  102. package/dist/runtime/milkdown/gherkin-W5ZB2USN.js +1 -0
  103. package/dist/runtime/milkdown/groovy-JTF2GBED.js +1 -0
  104. package/dist/runtime/milkdown/haskell-HFE6BWET.js +1 -0
  105. package/dist/runtime/milkdown/haxe-WWIJK4Z5.js +1 -0
  106. package/dist/runtime/milkdown/history-VOPZ3HXQ.js +1 -0
  107. package/dist/runtime/milkdown/http-NZKSSIDP.js +1 -0
  108. package/dist/runtime/milkdown/idl-CMM2WWSO.js +1 -0
  109. package/dist/runtime/milkdown/indent-WYLZY3CZ.js +1 -0
  110. package/dist/runtime/milkdown/javascript-375RXK5M.js +1 -0
  111. package/dist/runtime/milkdown/julia-BMA4W7GB.js +1 -0
  112. package/dist/runtime/milkdown/lib-32AGHSKT.js +1 -0
  113. package/dist/runtime/milkdown/lib-QZEOHNSS.js +1 -0
  114. package/dist/runtime/milkdown/listener-GNT2L5RH.js +1 -0
  115. package/dist/runtime/milkdown/livescript-3UKKDN45.js +1 -0
  116. package/dist/runtime/milkdown/lua-SWEBXZV4.js +1 -0
  117. package/dist/runtime/milkdown/mathematica-CJOQYQFY.js +1 -0
  118. package/dist/runtime/milkdown/mbox-Y4XZOKOO.js +1 -0
  119. package/dist/runtime/{milkdown-editor.js → milkdown/milkdown-editor.js} +1 -1
  120. package/dist/runtime/milkdown/milkdown-text-editor.js +1 -0
  121. package/dist/runtime/milkdown/mirc-5HDV5JC4.js +1 -0
  122. package/dist/runtime/milkdown/mllike-2EOQGIBG.js +1 -0
  123. package/dist/runtime/milkdown/model-VKXPTJEQ.js +1 -0
  124. package/dist/runtime/milkdown/modelica-XKNFUSSN.js +1 -0
  125. package/dist/runtime/milkdown/mscgen-2X7TXJM6.js +1 -0
  126. package/dist/runtime/milkdown/mumps-R6QPEBAR.js +1 -0
  127. package/dist/runtime/milkdown/nginx-7TJP7GQA.js +1 -0
  128. package/dist/runtime/milkdown/nsis-XAIDIMGO.js +1 -0
  129. package/dist/runtime/milkdown/ntriples-SCDRUUH2.js +1 -0
  130. package/dist/runtime/milkdown/octave-RV2OSSMQ.js +1 -0
  131. package/dist/runtime/milkdown/oz-6VL77R5Z.js +1 -0
  132. package/dist/runtime/milkdown/pascal-TQWMLNUO.js +1 -0
  133. package/dist/runtime/milkdown/perl-MJLZUOI2.js +1 -0
  134. package/dist/runtime/milkdown/pig-MQKMXNXN.js +1 -0
  135. package/dist/runtime/milkdown/powershell-RJOL52GR.js +1 -0
  136. package/dist/runtime/milkdown/properties-XL2YBZDU.js +1 -0
  137. package/dist/runtime/milkdown/protobuf-NQWTK3Z6.js +1 -0
  138. package/dist/runtime/milkdown/pug-SMVC7NDW.js +1 -0
  139. package/dist/runtime/milkdown/puppet-POQGMO34.js +1 -0
  140. package/dist/runtime/milkdown/python-NMGCKPUX.js +1 -0
  141. package/dist/runtime/milkdown/q-ILHJCNOR.js +1 -0
  142. package/dist/runtime/milkdown/r-XNO7UDHK.js +1 -0
  143. package/dist/runtime/milkdown/rpm-TPSVG357.js +1 -0
  144. package/dist/runtime/milkdown/ruby-3ZLDCDCY.js +1 -0
  145. package/dist/runtime/milkdown/sas-X4IZVM55.js +1 -0
  146. package/dist/runtime/milkdown/scheme-JSRTR252.js +1 -0
  147. package/dist/runtime/milkdown/shell-IJ2JLDQQ.js +1 -0
  148. package/dist/runtime/milkdown/sieve-4ACSKBHV.js +1 -0
  149. package/dist/runtime/milkdown/slash-3TY5YM2E.js +1 -0
  150. package/dist/runtime/milkdown/smalltalk-AHTDIHSN.js +1 -0
  151. package/dist/runtime/milkdown/solr-HDS3YMCJ.js +1 -0
  152. package/dist/runtime/milkdown/sparql-OPR2SX5E.js +1 -0
  153. package/dist/runtime/milkdown/spreadsheet-YMJBRXJ6.js +1 -0
  154. package/dist/runtime/milkdown/sql-4LK5AARR.js +1 -0
  155. package/dist/runtime/milkdown/stex-CBOLYXFQ.js +1 -0
  156. package/dist/runtime/milkdown/streaming-S7JA52O3.js +1 -0
  157. package/dist/runtime/milkdown/stylus-5SYL4OMN.js +1 -0
  158. package/dist/runtime/milkdown/swift-W3IKYGAN.js +1 -0
  159. package/dist/runtime/milkdown/tcl-QKBH3MVM.js +1 -0
  160. package/dist/runtime/milkdown/textile-KRYPADXN.js +1 -0
  161. package/dist/runtime/milkdown/theme/common/@milkdown/kit/prose/gapcursor/style/gapcursor.css +25 -0
  162. package/dist/runtime/milkdown/theme/common/@milkdown/kit/prose/tables/style/tables.css +48 -0
  163. package/dist/runtime/milkdown/theme/common/@milkdown/kit/prose/view/style/prosemirror.css +54 -0
  164. package/dist/runtime/milkdown/theme/common/ai.css +446 -0
  165. package/dist/runtime/milkdown/theme/common/block-edit.css +131 -0
  166. package/dist/runtime/milkdown/theme/common/code-mirror.css +347 -0
  167. package/dist/runtime/milkdown/theme/common/cursor.css +22 -0
  168. package/dist/runtime/milkdown/theme/common/diff.css +177 -0
  169. package/dist/runtime/milkdown/theme/common/image-block.css +384 -0
  170. package/dist/runtime/milkdown/theme/common/latex.css +42 -0
  171. package/dist/runtime/milkdown/theme/common/link-tooltip.css +107 -0
  172. package/dist/runtime/milkdown/theme/common/list-item.css +50 -0
  173. package/dist/runtime/milkdown/theme/common/placeholder.css +11 -0
  174. package/dist/runtime/milkdown/theme/common/prosemirror-virtual-cursor/style/virtual-cursor.css +51 -0
  175. package/dist/runtime/milkdown/theme/common/prosemirror.css +1 -0
  176. package/dist/runtime/milkdown/theme/common/reset.css +289 -0
  177. package/dist/runtime/milkdown/theme/common/style.css +15 -0
  178. package/dist/runtime/milkdown/theme/common/table.css +219 -0
  179. package/dist/runtime/milkdown/theme/common/toolbar.css +50 -0
  180. package/dist/runtime/milkdown/theme/common/top-bar.css +152 -0
  181. package/dist/runtime/milkdown/tiddlywiki-XNSPF27C.js +1 -0
  182. package/dist/runtime/milkdown/tiki-ZZLJUPPJ.js +1 -0
  183. package/dist/runtime/milkdown/toml-FCAM6ZFK.js +1 -0
  184. package/dist/runtime/milkdown/tooltip-5CTXOYIA.js +1 -0
  185. package/dist/runtime/milkdown/troff-7BWGQP4Z.js +1 -0
  186. package/dist/runtime/milkdown/ttcn-K3WYQPKS.js +1 -0
  187. package/dist/runtime/milkdown/ttcn-cfg-LDHTKWFO.js +1 -0
  188. package/dist/runtime/milkdown/turtle-6Q2P3NLY.js +1 -0
  189. package/dist/runtime/milkdown/upload-DA4OHNVQ.js +1 -0
  190. package/dist/runtime/milkdown/utils-H6AH4ARX.js +1 -0
  191. package/dist/runtime/milkdown/vb-BYDJL3EX.js +1 -0
  192. package/dist/runtime/milkdown/vbscript-WOMP2PYW.js +1 -0
  193. package/dist/runtime/milkdown/velocity-ZG7EESTK.js +1 -0
  194. package/dist/runtime/milkdown/verilog-MW2R7Q2Y.js +1 -0
  195. package/dist/runtime/milkdown/vhdl-GQOJ6JVT.js +1 -0
  196. package/dist/runtime/milkdown/webidl-5Q6QYACY.js +1 -0
  197. package/dist/runtime/milkdown/xquery-MD4ZCF7M.js +1 -0
  198. package/dist/runtime/milkdown/y-webrtc-VQGJXSXG.js +2 -0
  199. package/dist/runtime/milkdown/y-websocket-YOL5ECIU.js +2 -0
  200. package/dist/runtime/milkdown/yacas-EKNE7G24.js +1 -0
  201. package/dist/runtime/milkdown/yjs-H3MVN7TP.js +1 -0
  202. package/dist/runtime/milkdown/z80-44FRSRYD.js +1 -0
  203. package/docs/components/markdown.md +2 -2
  204. package/docs/components/text-editor.md +73 -7
  205. package/package.json +4 -2
  206. package/dist/runtime/block-N5MIBOMO.js +0 -1
  207. package/dist/runtime/chunk-6X7NT7KH.js +0 -2
  208. package/dist/runtime/chunk-7R5G6FRT.js +0 -1
  209. package/dist/runtime/chunk-EAFZBBCI.js +0 -10
  210. package/dist/runtime/chunk-GF2LJCG5.js +0 -1
  211. package/dist/runtime/chunk-HKUJH2VC.js +0 -1
  212. package/dist/runtime/chunk-KX3KYRT7.js +0 -1
  213. package/dist/runtime/chunk-OESZ7FEN.js +0 -1
  214. package/dist/runtime/chunk-P3WV3MLS.js +0 -35
  215. package/dist/runtime/chunk-URTGZHMG.js +0 -3
  216. package/dist/runtime/chunk-XLIC2WFB.js +0 -1
  217. package/dist/runtime/clipboard-6EHVQ6GB.js +0 -4
  218. package/dist/runtime/commonmark-FAT3C7WA.js +0 -1
  219. package/dist/runtime/core-IEFFKRMW.js +0 -1
  220. package/dist/runtime/cursor-3BFXMKNC.js +0 -1
  221. package/dist/runtime/diff-ALMDXB3Z.js +0 -1
  222. package/dist/runtime/gfm-JUXF3E6O.js +0 -5
  223. package/dist/runtime/history-OU6CQBOY.js +0 -1
  224. package/dist/runtime/indent-RP5Y5HNK.js +0 -1
  225. package/dist/runtime/lib-TTIE4EGJ.js +0 -1
  226. package/dist/runtime/listener-JBODN3BE.js +0 -1
  227. package/dist/runtime/prosemirror-text-editor.js +0 -1
  228. package/dist/runtime/slash-I56NP4SS.js +0 -1
  229. package/dist/runtime/tooltip-XDWVKIO5.js +0 -1
  230. package/dist/runtime/upload-MYBCHYBD.js +0 -1
  231. package/dist/runtime/y-webrtc-WDTQEBWZ.js +0 -1
  232. package/dist/runtime/yjs-SRZJJJEG.js +0 -1
  233. /package/dist/runtime/{marked.min.js → marked/marked.min.js} +0 -0
  234. /package/dist/runtime/{mermaid.esm.min.mjs → mermaid/mermaid.esm.min.mjs} +0 -0
  235. /package/dist/runtime/{chunk-23NN352E.js → milkdown/chunk-23NN352E.js} +0 -0
  236. /package/dist/runtime/{chunk-MAWHENWJ.js → milkdown/chunk-MAWHENWJ.js} +0 -0
@@ -1,10 +0,0 @@
1
- function B(r){this.content=r}B.prototype={constructor:B,find:function(r){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===r)return e;return-1},get:function(r){var e=this.find(r);return e==-1?void 0:this.content[e+1]},update:function(r,e,t){var n=t&&t!=r?this.remove(t):this,i=n.find(r),s=n.content.slice();return i==-1?s.push(t||r,e):(s[i+1]=e,t&&(s[i]=t)),new B(s)},remove:function(r){var e=this.find(r);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new B(t)},addToStart:function(r,e){return new B([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new B(t)},addBefore:function(r,e,t){var n=this.remove(e),i=n.content.slice(),s=n.find(r);return i.splice(s==-1?i.length:s,0,e,t),new B(i)},forEach:function(r){for(var e=0;e<this.content.length;e+=2)r(this.content[e],this.content[e+1])},prepend:function(r){return r=B.from(r),r.size?new B(r.content.concat(this.subtract(r).content)):this},append:function(r){return r=B.from(r),r.size?new B(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=B.from(r);for(var t=0;t<r.content.length;t+=2)e=e.remove(r.content[t]);return e},toObject:function(){var r={};return this.forEach(function(e,t){r[e]=t}),r},get size(){return this.content.length>>1}};B.from=function(r){if(r instanceof B)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new B(e)};var Jt=B;function ir(r,e,t){for(let n=0;;n++){if(n==r.childCount||n==e.childCount)return r.childCount==e.childCount?null:t;let i=r.child(n),s=e.child(n);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){let o=i.text,l=s.text,a=0;for(;o[a]==l[a];a++)t++;return a&&a<o.length&&a<l.length&&lr(o.charCodeAt(a-1))&&or(o.charCodeAt(a))&&t--,t}if(i.content.size||s.content.size){let o=ir(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function sr(r,e,t,n){for(let i=r.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:n};let o=r.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,n-=a;continue}if(!o.sameMarkup(l))return{a:t,b:n};if(o.isText&&o.text!=l.text){let c=o.text,f=l.text,h=c.length,d=f.length;for(;h>0&&d>0&&c[h-1]==f[d-1];)h--,d--,t--,n--;return h&&d&&h<c.length&&lr(c.charCodeAt(h-1))&&or(c.charCodeAt(h))&&(t++,n++),{a:t,b:n}}if(o.content.size||l.content.size){let c=sr(o.content,l.content,t-1,n-1);if(c)return c}t-=a,n-=a}}function or(r){return r>=56320&&r<57344}function lr(r){return r>=55296&&r<56320}var y=class r{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&n(a,i+l,s||null,o)!==!1&&a.content.size){let f=l+1;a.nodesBetween(Math.max(0,e-f),Math.min(a.content.size,t-f),n,i+f)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-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)&&n&&(o?o=!1:s+=n),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(n)&&(i[i.length-1]=t.withText(t.text+n.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new r(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),n.push(l),i+=l.nodeSize),o=a}return new r(n,i)}cutByIndex(e,t){return e==t?r.empty:e==0&&t==this.content.length?this:new r(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-n.nodeSize;return i[e]=t,new r(i,s)}addToStart(e){return new r([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new r(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let i=this.content[t];e(i,n,t),n+=i.nodeSize}}findDiffStart(e,t=0){return ir(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return sr(this,e,t,n)}findIndex(e){if(e==0)return ht(0,e);if(e==this.size)return ht(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let i=this.child(t),s=n+i.nodeSize;if(s>=e)return s==e?ht(t+1,s):ht(t,n);n=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return r.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return r.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return r.empty;let t,n=0;for(let i=0;i<e.length;i++){let s=e[i];n+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new r(t||e,n)}static from(e){if(!e)return r.empty;if(e instanceof r)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new r([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};y.empty=new y([],0);var vt={index:0,offset:0};function ht(r,e){return vt.index=r,vt.offset=e,vt}function pt(r,e){if(r===e)return!0;if(!(r&&typeof r=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(r);if(Array.isArray(e)!=t)return!1;if(t){if(r.length!=e.length)return!1;for(let n=0;n<r.length;n++)if(!pt(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!pt(r[n],e[n]))return!1;for(let n in e)if(!(n in r))return!1}return!0}var N=class r{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!n&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(s)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&pt(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=n.create(t.attrs);return n.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return r.none;if(e instanceof r)return[e];let t=e.slice();return t.sort((n,i)=>n.type.rank-i.type.rank),t}};N.none=[];var oe=class extends Error{},S=class r{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=cr(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new r(n,this.openStart,this.openEnd)}removeBetween(e,t){return new r(ar(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return r.empty;let n=t.openStart||0,i=t.openEnd||0;if(typeof n!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new r(y.fromJSON(e,t.content),n,i)}static maxOpen(e,t=!0){let n=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)n++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new r(e,n,i)}};S.empty=new S(y.empty,0,0);function ar(r,e,t){let{index:n,offset:i}=r.findIndex(e),s=r.maybeChild(n),{index:o,offset:l}=r.findIndex(t);if(i==e||s.isText){if(l!=t&&!r.child(o).isText)throw new RangeError("Removing non-flat range");return r.cut(0,e).append(r.cut(t))}if(n!=o)throw new RangeError("Removing non-flat range");return r.replaceChild(n,s.copy(ar(s.content,e-i-1,t-i-1)))}function cr(r,e,t,n,i,s){let{index:o,offset:l}=r.findIndex(e),a=r.maybeChild(o);if(l==e||a.isText)return s&&n<=0&&i<=0&&!s.canReplace(o,o,t)?null:r.cut(0,e).append(t).append(r.cut(e));let c=cr(a.content,e-l-1,t,o==0?n-1:0,o==r.childCount-1?i-1:0,a);return c&&r.replaceChild(o,a.copy(c))}function hs(r,e,t){if(t.openStart>r.depth)throw new oe("Inserted content deeper than insertion position");if(r.depth-t.openStart!=e.depth-t.openEnd)throw new oe("Inconsistent open depths");return fr(r,e,t,0)}function fr(r,e,t,n){let i=r.index(n),s=r.node(n);if(i==e.index(n)&&n<r.depth-t.openStart){let o=fr(r,e,t,n+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&r.depth==n&&e.depth==n){let o=r.parent,l=o.content;return me(o,l.cut(0,r.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=ds(t,r);return me(s,dr(r,o,l,e,n))}else return me(s,mt(r,e,n))}function hr(r,e){if(!e.type.compatibleContent(r.type))throw new oe("Cannot join "+e.type.name+" onto "+r.type.name)}function qt(r,e,t){let n=r.node(t);return hr(n,e.node(t)),n}function pe(r,e){let t=e.length-1;t>=0&&r.isText&&r.sameMarkup(e[t])?e[t]=r.withText(e[t].text+r.text):e.push(r)}function Je(r,e,t,n){let i=(e||r).node(t),s=0,o=e?e.index(t):i.childCount;r&&(s=r.index(t),r.depth>t?s++:r.textOffset&&(pe(r.nodeAfter,n),s++));for(let l=s;l<o;l++)pe(i.child(l),n);e&&e.depth==t&&e.textOffset&&pe(e.nodeBefore,n)}function me(r,e){if(!r.type.validContent(e))throw new oe("Invalid content for node "+r.type.name);return r.copy(e)}function dr(r,e,t,n,i){let s=r.depth>i&&qt(r,e,i+1),o=n.depth>i&&qt(t,n,i+1),l=[];return Je(null,r,i,l),s&&o&&e.index(i)==t.index(i)?(hr(s,o),pe(me(s,dr(r,e,t,n,i+1)),l)):(s&&pe(me(s,mt(r,e,i+1)),l),Je(e,t,i,l),o&&pe(me(o,mt(t,n,i+1)),l)),Je(n,null,i,l),new y(l)}function mt(r,e,t){let n=[];if(Je(null,r,t,n),r.depth>t){let i=qt(r,e,t+1);pe(me(i,mt(r,e,t+1)),n)}return Je(e,null,t,n),new y(n)}function ds(r,e){let t=e.depth-r.openStart,i=e.node(t).copy(r.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(y.from(i));return{start:i.resolveNoCache(r.openStart+t),end:i.resolveNoCache(i.content.size-r.openEnd-t)}}var gt=class r{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],i=e.child(t);return n?e.child(t).cut(n):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=n.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return N.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),i=e.maybeChild(t);if(!n){let l=n;n=i,i=l}let s=n.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<n.length;s++)n[s].type.spec.inclusive===!1&&(!i||!n[s].isInSet(i.marks))&&(n=n[s--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Kt(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(n.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new r(t,n,s)}static resolveCached(e,t){let n=Gn.get(e);if(n)for(let s=0;s<n.elts.length;s++){let o=n.elts[s];if(o.pos==t)return o}else Gn.set(e,n=new $t);let i=n.elts[n.i]=r.resolve(e,t);return n.i=(n.i+1)%us,i}},$t=class{constructor(){this.elts=[],this.i=0}},us=12,Gn=new WeakMap,Kt=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)}},ps=Object.create(null),X=class r{constructor(e,t,n,i=N.none){this.type=e,this.attrs=t,this.marks=i,this.content=n||y.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,i=0){this.content.nodesBetween(e,t,n,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,i){return this.content.textBetween(e,t,n,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&pt(this.attrs,t||e.defaultAttrs||ps)&&N.sameSet(this.marks,n||N.none)}copy(e=null){return e==this.content?this:new r(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new r(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return S.empty;let i=this.resolve(e),s=this.resolve(t),o=n?0:i.sharedDepth(t),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new S(c,i.depth-o,s.depth-o)}replace(e,t,n){return hs(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let i=this.content.child(t-1);return{node:i,index:t-1,offset:n-i.nodeSize}}resolve(e){return gt.resolveCached(this,e)}resolveNoCache(e){return gt.resolve(this,e)}rangeHasMark(e,t,n){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(n.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 e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),ur(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=y.empty,i=0,s=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}canReplaceWith(e,t,n,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(n),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=N.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!N.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let i=y.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,n);return s.type.checkAttrs(s.attrs),s}};X.prototype.text=void 0;var Ht=class r extends X{constructor(e,t,n,i){if(super(e,t,null,i),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ur(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new r(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new r(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function ur(r,e){for(let t=r.length-1;t>=0;t--)e=r[t].type.name+"("+e+")";return e}var ge=class r{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new Ut(e,t);if(n.next==null)return r.empty;let i=pr(n);n.next&&n.err("Unexpected trailing text");let s=ks(bs(i));return Cs(s,n),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let i=this;for(let s=t;i&&s<n;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let i=[this];function s(o,l){let a=o.matchFragment(e,n);if(a&&(!t||a.validEnd))return y.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:f,next:h}=o.next[c];if(!(f.isText||f.hasRequiredAttrs())&&i.indexOf(h)==-1){i.push(h);let d=s(h,l.concat(f));if(d)return d}}return null}return s(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let i=n.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(n.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let i=0;i<n.next.length;i++)e.indexOf(n.next[i].next)==-1&&t(n.next[i].next)}return t(this),e.map((n,i)=>{let s=i+(n.validEnd?"*":" ")+" ";for(let o=0;o<n.next.length;o++)s+=(o?", ":"")+n.next[o].type.name+"->"+e.indexOf(n.next[o].next);return s}).join(`
2
- `)}};ge.empty=new ge(!0);var Ut=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 pr(r){let e=[];do e.push(ms(r));while(r.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function ms(r){let e=[];do e.push(gs(r));while(r.next&&r.next!=")"&&r.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function gs(r){let e=xs(r);for(;;)if(r.eat("+"))e={type:"plus",expr:e};else if(r.eat("*"))e={type:"star",expr:e};else if(r.eat("?"))e={type:"opt",expr:e};else if(r.eat("{"))e=ys(r,e);else break;return e}function Yn(r){/\D/.test(r.next)&&r.err("Expected number, got '"+r.next+"'");let e=Number(r.next);return r.pos++,e}function ys(r,e){let t=Yn(r),n=t;return r.eat(",")&&(r.next!="}"?n=Yn(r):n=-1),r.eat("}")||r.err("Unclosed braced range"),{type:"range",min:t,max:n,expr:e}}function Ss(r,e){let t=r.nodeTypes,n=t[e];if(n)return[n];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&r.err("No node type or group '"+e+"' found"),i}function xs(r){if(r.eat("(")){let e=pr(r);return r.eat(")")||r.err("Missing closing paren"),e}else if(/\W/.test(r.next))r.err("Unexpected token '"+r.next+"'");else{let e=Ss(r,r.next).map(t=>(r.inline==null?r.inline=t.isInline:r.inline!=t.isInline&&r.err("Mixing inline and block content"),{type:"name",value:t}));return r.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function bs(r){let e=[[]];return i(s(r,0),t()),e;function t(){return e.push([])-1}function n(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=t())}else if(o.type=="star"){let a=t();return n(l,a),i(s(o.expr,a),a),[n(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[n(a)]}else{if(o.type=="opt")return[n(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let f=t();i(s(o.expr,a),f),a=f}if(o.max==-1)i(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let f=t();n(a,f),i(s(o.expr,a),f),a=f}return[n(a)]}else{if(o.type=="name")return[n(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function mr(r,e){return e-r}function Xn(r,e){let t=[];return n(e),t.sort(mr);function n(i){let s=r[i];if(s.length==1&&!s[0].term)return n(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&n(a)}}}function ks(r){let e=Object.create(null);return t(Xn(r,0));function t(n){let i=[];n.forEach(o=>{r[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let f=0;f<i.length;f++)i[f][0]==l&&(c=i[f][1]);Xn(r,a).forEach(f=>{c||i.push([l,c=[]]),c.indexOf(f)==-1&&c.push(f)})})});let s=e[n.join(",")]=new ge(n.indexOf(r.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(mr);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function Cs(r,e){for(let t=0,n=[r];t<n.length;t++){let i=n[t],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),n.indexOf(c)==-1&&n.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function gr(r){let e=Object.create(null);for(let t in r){let n=r[t];if(!n.hasDefault)return null;e[t]=n.default}return e}function yr(r,e){let t=Object.create(null);for(let n in r){let i=e&&e[n];if(i===void 0){let s=r[n];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+n)}t[n]=i}return t}function Sr(r,e,t,n){for(let i in e)if(!(i in r))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${n}`);for(let i in r)r[i].validate&&r[i].validate(e[i])}function xr(r,e){let t=Object.create(null);if(e)for(let n in e)t[n]=new jt(r,n,e[n]);return t}var yt=class r{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=xr(e,n.attrs),this.defaultAttrs=gr(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ge.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:yr(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new X(this,this.computeAttrs(e),y.from(t),N.setFrom(n))}createChecked(e=null,t,n){return t=y.from(t),this.checkContent(t),new X(this,this.computeAttrs(e),t,N.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=y.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(y.empty,!0);return s?new X(this,e,t.append(s),N.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Sr(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:N.none:e}static compile(e,t){let n=Object.create(null);e.forEach((s,o)=>n[s]=new r(s,t,o));let i=t.spec.topNode||"doc";if(!n[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let s in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function Ns(r,e,t){let n=t.split("|");return i=>{let s=i===null?"null":typeof i;if(n.indexOf(s)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${r}, got ${s}`)}}var jt=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Ns(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},qe=class r{constructor(e,t,n,i){this.name=e,this.rank=t,this.schema=n,this.spec=i,this.attrs=xr(e,i.attrs),this.excluded=null;let s=gr(this.attrs);this.instance=s?new N(this,s):null}create(e=null){return!e&&this.instance?this.instance:new N(this,yr(this.attrs,e))}static compile(e,t){let n=Object.create(null),i=0;return e.forEach((s,o)=>n[s]=new r(s,i++,t,o)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Sr(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},Zn=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Jt.from(e.nodes),t.marks=Jt.from(e.marks||{}),this.nodes=yt.compile(this.spec.nodes,this),this.marks=qe.compile(this.spec.marks,this);let n=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=n[o]||(n[o]=ge.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Qn(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Qn(this,o.split(" "))}this.nodeFromJSON=i=>X.fromJSON(this,i),this.markFromJSON=i=>N.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof yt){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,i)}text(e,t){let n=this.nodes.text;return new Ht(n,n.defaultAttrs,e,N.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 Qn(r,e){let t=[];for(let n=0;n<e.length;n++){let i=e[n],s=r.marks[i],o=s;if(s)t.push(s);else for(let l in r.marks){let a=r.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return t}function Os(r){return r.tag!=null}function Ms(r){return r.style!=null}var $e=class r{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(i=>{if(Os(i))this.tags.push(i);else if(Ms(i)){let s=/[^=]*/.exec(i.style)[0];n.indexOf(s)<0&&n.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=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let n=new St(this,t,!1);return n.addAll(e,N.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new St(this,t,!0);return n.addAll(e,N.none,t.from,t.to),S.maxOpen(n.finish())}matchTag(e,t,n){for(let i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(ws(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,n,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!n.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function n(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{n(o=er(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{n(o=er(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new r(e,r.schemaRules(e)))}},br={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},Ts={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},kr={ol:!0,ul:!0},Ke=1,Gt=2,ve=4;function _n(r,e,t){return e!=null?(e?Ke:0)|(e==="full"?Gt:0):r&&r.whitespace=="pre"?Ke|Gt:t&~ve}var Ee=class{constructor(e,t,n,i,s,o){this.type=e,this.attrs=t,this.marks=n,this.solid=i,this.options=o,this.content=[],this.activeMarks=N.none,this.match=s||(o&ve?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(y.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,i;return(i=n.findWrapping(e.type))?(this.match=n,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ke)){let n=this.content[this.content.length-1],i;if(n&&n.isText&&(i=/[ \t\r\n\u000c]+$/.exec(n.text))){let s=n;n.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=y.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(y.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&&!br.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},St=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=_n(null,t.preserveWhitespace,0)|(n?ve:0);i?s=new Ee(i.type,i.attrs,N.none,!0,t.topMatch||i.type.contentMatch,o):n?s=new Ee(null,null,N.none,!0,null,o):s=new Ee(e.schema.topNodeType,null,N.none,!0,null,o),this.nodes=[s],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,i=this.top,s=i.options&Gt?"full":this.localPreserveWS||(i.options&Ke)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(s)if(s==="full")n=n.replace(/\r\n?/g,`
3
- `);else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=n.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));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 l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;kr.hasOwnProperty(o)&&this.parser.normalizeLists&&Ds(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,n));e:if(a?a.ignore:Ts.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,f=this.needsBlock;if(br.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let h=a&&a.skip?t:this.readStyles(e,t);h&&this.addAll(e,h),c&&this.sync(s),this.needsBlock=f}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}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 i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=n.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,n,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let a=this.enter(o,t.attrs||null,n,t.preserveWhitespace);a&&(s=!0,n=a)}else{let a=this.parser.schema.marks[t.mark];n=n.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,n,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,n),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,n,i){let s=n||0;for(let o=n?e.childNodes[n]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,n){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(n)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,n);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=N.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):tr(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,n,i){let s=this.findPlace(e.create(t),n,!1);return s&&(s=this.enterInner(e,t,n,!0,i)),s}enterInner(e,t,n,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=_n(e,s,o.options);o.options&ve&&o.content.length==0&&(l|=ve);let a=N.none;return n=n.filter(c=>(o.type?o.type.allowsMarkType(c.type):tr(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Ee(e,t,a,i,null,l)),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|=Ke)}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 i=n.length-1;i>=0;i--)e+=n[i].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 i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].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,i=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),s=-(n?n.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let f=a>0||a==0&&i?this.nodes[a].type:n&&a>=s?n.node(a-s).type:null;if(!f||f.name!=c&&!f.isInGroup(c))return!1;a--}}return!0};return o(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 Ds(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&kr.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function ws(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function er(r){let e={};for(let t in r)e[t]=r[t];return e}function tr(r,e){let t=e.schema.nodes;for(let n in t){let i=t[n];if(!i.allowsMarkType(r))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:f}=l.edge(a);if(c==e||s.indexOf(f)<0&&o(f))return!0}};if(o(i.contentMatch))return!0}}var ye=class r{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=dt(t).createDocumentFragment());let i=n,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.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<o.marks.length;){let c=o.marks[a++],f=this.serializeMark(c,o.isInline,t);f&&(s.push([c,i]),i.appendChild(f.dom),i=f.contentDOM||f.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),n}serializeNodeInner(e,t){if(e.isText)return dt(t).createTextNode(e.text);let{dom:n,contentDOM:i}=ut(dt(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(n),n=s.dom)}return n}serializeMark(e,t,n={}){let i=this.marks[e.type.name];return i&&ut(dt(n),i(e,t),null,e.attrs)}static renderSpec(e,t,n=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:ut(e,t,n,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new r(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=nr(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return nr(e.marks)}};function nr(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function dt(r){return r.document||window.document}var rr=new WeakMap;function Es(r){let e=rr.get(r);return e===void 0&&rr.set(r,e=As(r)),e}function As(r){let e=null;function t(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")e||(e=[]),e.push(n);else for(let i=0;i<n.length;i++)t(n[i]);else for(let i in n)t(n[i])}return t(r),e}function ut(r,e,t,n){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(s=Es(n))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?r.createElementNS(t,i):r.createElement(i),c=e[1],f=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){f=2;for(let h in c)if(c[h]!=null){let d=h.indexOf(" ");d>0?a.setAttributeNS(h.slice(0,d),h.slice(d+1),c[h]):h=="style"&&a.style?a.style.cssText=c[h]:a.setAttribute(h,c[h])}}for(let h=f;h<e.length;h++){let d=e[h];if(d===0){if(h<e.length-1||h>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof d=="string")a.appendChild(r.createTextNode(d));else{let{dom:p,contentDOM:u}=ut(r,d,t,n);if(a.appendChild(p),u){if(l)throw new RangeError("Multiple content holes");l=u}}}return{dom:a,contentDOM:l}}var Or=65535,Mr=Math.pow(2,16);function Rs(r,e){return r+e*Mr}function Cr(r){return r&Or}function Is(r){return(r-(r&Or))/Mr}var Tr=1,Dr=2,xt=4,wr=8,je=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&wr)>0}get deletedBefore(){return(this.delInfo&(Tr|xt))>0}get deletedAfter(){return(this.delInfo&(Dr|xt))>0}get deletedAcross(){return(this.delInfo&xt)>0}},Q=class r{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&r.empty)return r.empty}recover(e){let t=0,n=Cr(e);if(!this.inverted)for(let i=0;i<n;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[n*3]+t+Is(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,s=this.inverted?2:1,o=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>e)break;let c=this.ranges[l+s],f=this.ranges[l+o],h=a+c;if(e<=h){let d=c?e==a?-1:e==h?1:t:t,p=a+i+(d<0?0:f);if(n)return p;let u=e==(t<0?a:h)?null:Rs(l/3,e-a),m=e==a?Dr:e==h?Tr:xt;return(t<0?e!=a:e!=h)&&(m|=wr),new je(p,m,u)}i+=f-c}return n?e+i:new je(e+i,0,null)}touches(e,t){let n=0,i=Cr(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?n:0);if(a>e)break;let c=this.ranges[l+s],f=a+c;if(e<=f&&l==i*3)return!0;n+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],f=this.ranges[i+n];e(l,l+c,a,a+f),s+=f-c}}invert(){return new r(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?r.empty:new r(e<0?[0,-e,0]:[0,0,e])}};Q.empty=new Q([]);var Qt=class r{constructor(e,t,n=0,i=e?e.length:0){this.mirror=t,this.from=n,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new r(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?n-i-1:void 0)}}invert(){let e=new r;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return n?e:new je(e,i,null)}},Yt=Object.create(null),E=class{getMap(){return Q.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Yt[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 Yt)throw new RangeError("Duplicate use of step JSON ID "+e);return Yt[e]=t,t.prototype.jsonID=e,t}},A=class r{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new r(e,null)}static fail(e){return new r(null,e)}static fromReplace(e,t,n,i){try{return r.ok(e.replace(t,n,i))}catch(s){if(s instanceof oe)return r.fail(s.message);throw s}}};function tn(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let s=r.child(i);s.content.size&&(s=s.copy(tn(s.content,e,s))),s.isInline&&(s=e(s,t,i)),n.push(s)}return y.fromArray(n)}var Ge=class r extends E{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),s=new S(tn(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return A.fromReplace(e,this.from,this.to,s)}invert(){return new Se(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new r(t.pos,n.pos,this.mark)}merge(e){return e instanceof r&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new r(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new r(t.from,t.to,e.markFromJSON(t.mark))}};E.jsonID("addMark",Ge);var Se=class r extends E{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new S(tn(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return A.fromReplace(e,this.from,this.to,n)}invert(){return new Ge(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new r(t.pos,n.pos,this.mark)}merge(e){return e instanceof r&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new r(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new r(t.from,t.to,e.markFromJSON(t.mark))}};E.jsonID("removeMark",Se);var Ye=class r extends E{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return A.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return A.fromReplace(e,this.pos,this.pos+1,new S(y.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(n))return new r(this.pos,t.marks[i]);return new r(this.pos,this.mark)}}return new Ae(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new r(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new r(t.pos,e.markFromJSON(t.mark))}};E.jsonID("addNodeMark",Ye);var Ae=class r extends E{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return A.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return A.fromReplace(e,this.pos,this.pos+1,new S(y.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ye(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new r(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new r(t.pos,e.markFromJSON(t.mark))}};E.jsonID("removeNodeMark",Ae);var F=class r extends E{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&_t(e,this.from,this.to)?A.fail("Structure replace would overwrite content"):A.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Q([this.from,this.to-this.from,this.slice.size])}invert(e){return new r(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&r.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new r(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof r)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?S.empty:new S(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new r(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?S.empty:new S(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new r(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new r(t.from,t.to,S.fromJSON(e,t.slice),!!t.structure)}};F.MAP_BIAS=1;E.jsonID("replace",F);var v=class r extends E{constructor(e,t,n,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(_t(e,this.from,this.gapFrom)||_t(e,this.gapTo,this.to)))return A.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return A.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?A.fromReplace(e,this.from,this.to,n):A.fail("Content does not fit in gap")}getMap(){return new Q([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new r(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||s>n.pos?null:new r(t.pos,n.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new r(t.from,t.to,t.gapFrom,t.gapTo,S.fromJSON(e,t.slice),t.insert,!!t.structure)}};E.jsonID("replaceAround",v);function _t(r,e,t){let n=r.resolve(e),i=t-e,s=n.depth;for(;i>0&&s>0&&n.indexAfter(s)==n.node(s).childCount;)s--,i--;if(i>0){let o=n.node(s).maybeChild(n.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Bs(r,e,t,n){let i=[],s=[],o,l;r.doc.nodesBetween(e,t,(a,c,f)=>{if(!a.isInline)return;let h=a.marks;if(!n.isInSet(h)&&f.type.allowsMarkType(n.type)){let d=Math.max(c,e),p=Math.min(c+a.nodeSize,t),u=n.addToSet(h);for(let m=0;m<h.length;m++)h[m].isInSet(u)||(o&&o.to==d&&o.mark.eq(h[m])?o.to=p:i.push(o=new Se(d,p,h[m])));l&&l.to==d?l.to=p:s.push(l=new Ge(d,p,n))}}),i.forEach(a=>r.step(a)),s.forEach(a=>r.step(a))}function zs(r,e,t,n){let i=[],s=0;r.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(n instanceof qe){let c=o.marks,f;for(;f=n.isInSet(c);)(a||(a=[])).push(f),c=f.removeFromSet(c)}else n?n.isInSet(o.marks)&&(a=[n]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let f=0;f<a.length;f++){let h=a[f],d;for(let p=0;p<i.length;p++){let u=i[p];u.step==s-1&&h.eq(i[p].style)&&(d=u)}d?(d.to=c,d.step=s):i.push({style:h,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>r.step(new Se(o.from,o.to,o.style)))}function nn(r,e,t,n=t.contentMatch,i=!0){let s=r.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),f=l+c.nodeSize,h=n.matchType(c.type);if(!h)o.push(new F(l,f,S.empty));else{n=h;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||r.step(new Se(l,f,c.marks[d]));if(i&&c.isText&&t.whitespace!="pre"){let d,p=/\r?\n|\r/g,u;for(;d=p.exec(c.text);)u||(u=new S(y.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new F(l+d.index,l+d.index+d[0].length,u))}}l=f}if(!n.validEnd){let a=n.fillBefore(y.empty,!0);r.replace(l,l,new S(a,0,0))}for(let a=o.length-1;a>=0;a--)r.step(o[a])}function Ps(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function Xe(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth,i=0,s=0;;--n){let o=r.$from.node(n),l=r.$from.index(n)+i,a=r.$to.indexAfter(n)-s;if(n<r.depth&&o.canReplace(l,a,t))return n;if(n==0||o.type.spec.isolating||!Ps(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function Fs(r,e,t){let{$from:n,$to:i,depth:s}=e,o=n.before(s+1),l=i.after(s+1),a=o,c=l,f=y.empty,h=0;for(let u=s,m=!1;u>t;u--)m||n.index(u)>0?(m=!0,f=y.from(n.node(u).copy(f)),h++):a--;let d=y.empty,p=0;for(let u=s,m=!1;u>t;u--)m||i.after(u+1)<i.end(u)?(m=!0,d=y.from(i.node(u).copy(d)),p++):c++;r.step(new v(a,c,o,l,new S(f.append(d),h,p),f.size-h,!0))}function Er(r,e,t=null,n=r){let i=Vs(r,e),s=i&&Ls(n,e);return s?i.map(Nr).concat({type:e,attrs:t}).concat(s.map(Nr)):null}function Nr(r){return{type:r,attrs:null}}function Vs(r,e){let{parent:t,startIndex:n,endIndex:i}=r,s=t.contentMatchAt(n).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(n,i,o)?s:null}function Ls(r,e){let{parent:t,startIndex:n,endIndex:i}=r,s=t.child(n),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=n;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function Ws(r,e,t){let n=y.empty;for(let o=t.length-1;o>=0;o--){if(n.size){let l=t[o].type.contentMatch.matchFragment(n);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=y.from(t[o].type.create(t[o].attrs,n))}let i=e.start,s=e.end;r.step(new v(i,s,i,s,new S(n,0,0),t.length,!0))}function Js(r,e,t,n,i){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=r.steps.length;r.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(n,a)&&vs(r.doc,r.mapping.slice(s).map(l),n)){let c=null;if(n.schema.linebreakReplacement){let p=n.whitespace=="pre",u=!!n.contentMatch.matchType(n.schema.linebreakReplacement);p&&!u?c=!1:!p&&u&&(c=!0)}c===!1&&Rr(r,o,l,s),nn(r,r.mapping.slice(s).map(l,1),n,void 0,c===null);let f=r.mapping.slice(s),h=f.map(l,1),d=f.map(l+o.nodeSize,1);return r.step(new v(h,d,h+1,d-1,new S(y.from(n.create(a,null,o.marks)),0,0),1,!0)),c===!0&&Ar(r,o,l,s),!1}})}function Ar(r,e,t,n){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=r.mapping.slice(n).map(t+1+s+o.index);r.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Rr(r,e,t,n){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=r.mapping.slice(n).map(t+1+s);r.replaceWith(o,o+1,e.type.schema.text(`
5
- `))}})}function vs(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function qs(r,e,t,n,i){let s=r.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(n,null,i||s.marks);if(s.isLeaf)return r.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);r.step(new v(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new S(y.from(o),0,0),1,!0))}function Ze(r,e,t=1,n){let i=r.resolve(e),s=i.depth-t,o=n&&n[n.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,f=t-2;c>s;c--,f--){let h=i.node(c),d=i.index(c);if(h.type.spec.isolating)return!1;let p=h.content.cutByIndex(d,h.childCount),u=n&&n[f+1];u&&(p=p.replaceChild(0,u.type.create(u.attrs)));let m=n&&n[f]||h;if(!h.canReplace(d+1,h.childCount)||!m.type.validContent(p))return!1}let l=i.indexAfter(s),a=n&&n[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function $s(r,e,t=1,n){let i=r.doc.resolve(e),s=y.empty,o=y.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=y.from(i.node(l).copy(s));let f=n&&n[c];o=y.from(f?f.type.create(f.attrs,o):i.node(l).copy(o))}r.step(new F(e,e,new S(s.append(o),t,t),!0))}function rn(r,e){let t=r.resolve(e),n=t.index();return Hs(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function Ks(r,e){e.content.size||r.type.compatibleContent(e.type);let t=r.contentMatchAt(r.childCount),{linebreakReplacement:n}=r.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==n?r.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!r.type.allowsMarks(s.marks))return!1}return t.validEnd}function Hs(r,e){return!!(r&&e&&!r.isLeaf&&Ks(r,e))}function Us(r,e,t){let n=null,{linebreakReplacement:i}=r.doc.type.schema,s=r.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let f=o.whitespace=="pre",h=!!o.contentMatch.matchType(i);f&&!h?n=!1:!f&&h&&(n=!0)}let l=r.steps.length;if(n===!1){let f=r.doc.resolve(e+t);Rr(r,f.node(),f.before(),l)}o.inlineContent&&nn(r,e+t-1,o,s.node().contentMatchAt(s.index()),n==null);let a=r.mapping.slice(l),c=a.map(e-t);if(r.step(new F(c,a.map(e+t,-1),S.empty,!0)),n===!0){let f=r.doc.resolve(c);Ar(r,f.node(),f.before(),r.steps.length)}return r}function js(r,e,t){let n=r.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),t))return e;if(n.parentOffset==0)for(let i=n.depth-1;i>=0;i--){let s=n.index(i);if(n.node(i).canReplaceWith(s,s,t))return n.before(i+1);if(s>0)return null}if(n.parentOffset==n.parent.content.size)for(let i=n.depth-1;i>=0;i--){let s=n.indexAfter(i);if(n.node(i).canReplaceWith(s,s,t))return n.after(i+1);if(s<n.node(i).childCount)return null}return null}function Ir(r,e,t){let n=r.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=n.depth;o>=0;o--){let l=o==n.depth?0:n.pos<=(n.start(o+1)+n.end(o+1))/2?-1:1,a=n.index(o)+(l>0?1:0),c=n.node(o),f=!1;if(s==1)f=c.canReplace(a,a,i);else{let h=c.contentMatchAt(a).findWrapping(i.firstChild.type);f=h&&c.canReplaceWith(a,a,h[0])}if(f)return l==0?n.pos:l<0?n.before(o+1):n.after(o+1)}return null}function Qe(r,e,t=e,n=S.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),s=r.resolve(t);return Br(i,s,n)?new F(e,t,n):new en(i,s,n).fit()}function Br(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}var en=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=y.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=y.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let s=this.placed,o=n.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new S(s,o,l);return e>-1?new v(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new F(n.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=n){e=n;break}t=s.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let i,s=null;n?(s=Xt(this.unplaced.content,n-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],f,h=null;if(t==1&&(o?c.matchType(o.type)||(h=c.fillBefore(y.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:n,frontierDepth:l,parent:s,inject:h};if(t==2&&o&&(f=c.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:l,parent:s,wrap:f};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=Xt(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new S(e,t+1,Math.max(n,i.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=Xt(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new S(He(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new S(He(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,l=n?n.content:o.content,a=o.openStart-e,c=0,f=[],{match:h,type:d}=this.frontier[t];if(i){for(let m=0;m<i.childCount;m++)f.push(i.child(m));h=h.matchFragment(i)}let p=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let m=l.child(c),g=h.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(h=g,f.push(zr(m.mark(d.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?p:-1)))}let u=c==l.childCount;u||(p=-1),this.placed=Ue(this.placed,t,y.from(f)),this.frontier[t].match=h,u&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<p;m++){let x=g.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),g=x.content}this.unplaced=u?e==0?S.empty:new S(He(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new S(He(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Zt(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,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Zt(e,t,i,n,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],f=Zt(e,l,c,a,!0);if(!f||f.childCount)continue e}return{depth:t,fit:o,move:s?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=Ue(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let i=e.node(n),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Ue(this.placed,this.depth,y.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(y.empty,!0);t.childCount&&(this.placed=Ue(this.placed,this.frontier.length,t))}};function He(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(He(r.firstChild.content,e-1,t)))}function Ue(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(Ue(r.lastChild.content,e-1,t)))}function Xt(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function zr(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,zr(n.firstChild,e-1,n.childCount==1?t-1:0))),e>0&&(n=r.type.contentMatch.fillBefore(n).append(n),t<=0&&(n=n.append(r.type.contentMatch.matchFragment(n).fillBefore(y.empty,!0)))),r.copy(n)}function Zt(r,e,t,n,i){let s=r.node(e),o=i?r.indexAfter(e):r.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=n.fillBefore(s.content,!0,o);return l&&!Gs(t,s.content,o)?l:null}function Gs(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function Ys(r){return r.spec.defining||r.spec.definingForContent}function Xs(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),s=r.doc.resolve(t);if(Br(i,s,n))return r.step(new F(e,t,n));let o=Fr(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let d=i.depth,p=i.pos-1;d>0;d--,p--){let u=i.node(d).type.spec;if(u.defining||u.definingAsContext||u.isolating)break;o.indexOf(d)>-1?l=d:i.before(d)==p&&o.splice(1,0,-d)}let a=o.indexOf(l),c=[],f=n.openStart;for(let d=n.content,p=0;;p++){let u=d.firstChild;if(c.push(u),p==n.openStart)break;d=u.content}for(let d=f-1;d>=0;d--){let p=c[d],u=Ys(p.type);if(u&&!p.sameMarkup(i.node(Math.abs(l)-1)))f=d;else if(u||!p.type.isTextblock)break}for(let d=n.openStart;d>=0;d--){let p=(d+f+1)%(n.openStart+1),u=c[p];if(u)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],x=!0;g<0&&(x=!1,g=-g);let T=i.node(g-1),M=i.index(g-1);if(T.canReplaceWith(M,M,u.type,u.marks))return r.replace(i.before(g),x?s.after(g):t,new S(Pr(n.content,0,n.openStart,p),p,n.openEnd))}}let h=r.steps.length;for(let d=o.length-1;d>=0&&(r.replace(e,t,n),!(r.steps.length>h));d--){let p=o[d];p<0||(e=i.before(p),t=s.after(p))}}function Pr(r,e,t,n,i){if(e<t){let s=r.firstChild;r=r.replaceChild(0,s.copy(Pr(s.content,e+1,t,n,s)))}if(e>n){let s=i.contentMatchAt(0),o=s.fillBefore(r).append(r);r=o.append(s.matchFragment(o).fillBefore(y.empty,!0))}return r}function Zs(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=js(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new S(y.from(n),0,0))}function Qs(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t);if(n.parent.isTextblock&&i.parent.isTextblock&&n.start()!=i.start()&&n.parentOffset==0&&i.parentOffset==0){let o=n.sharedDepth(t),l=!1;for(let a=n.depth;a>o;a--)n.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>o;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=n.depth;a>0&&e==n.start(a);a--)e=n.before(a);for(let a=i.depth;a>0&&t==i.start(a);a--)t=i.before(a);n=r.doc.resolve(e),i=r.doc.resolve(t)}}let s=Fr(n,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||n.node(l).type.contentMatch.validEnd)return r.delete(n.start(l),i.end(l));if(l>0&&(a||n.node(l-1).canReplace(n.index(l-1),i.indexAfter(l-1))))return r.delete(n.before(l),i.after(l))}for(let o=1;o<=n.depth&&o<=i.depth;o++)if(e-n.start(o)==n.depth-o&&t>n.end(o)&&i.end(o)-t!=i.depth-o&&n.start(o-1)==i.start(o-1)&&n.node(o-1).canReplace(n.index(o-1),i.index(o-1)))return r.delete(n.before(o),t);r.delete(e,t)}function Fr(r,e){let t=[],n=Math.min(r.depth,e.depth);for(let i=n;i>=0;i--){let s=r.start(i);if(s<r.pos-(r.depth-i)||e.end(i)>e.pos+(e.depth-i)||r.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==r.depth&&i==e.depth&&r.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}var bt=class r extends E{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return A.fail("No node at attribute step's position");let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return A.fromReplace(e,this.pos,this.pos+1,new S(y.from(i),0,t.isLeaf?0:1))}getMap(){return Q.empty}invert(e){return new r(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new r(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new r(t.pos,t.attr,t.value)}};E.jsonID("attr",bt);var kt=class r extends E{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return A.ok(n)}getMap(){return Q.empty}invert(e){return new r(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new r(t.attr,t.value)}};E.jsonID("docAttr",kt);var Re=class extends Error{};Re=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t};Re.prototype=Object.create(Error.prototype);Re.prototype.constructor=Re;Re.prototype.name="TransformError";var Ct=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Qt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Re(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 i=this.mapping.maps[n];n&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((s,o,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=S.empty){let i=Qe(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new S(y.from(n),0,0))}delete(e,t){return this.replace(e,t,S.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Xs(this,e,t,n),this}replaceRangeWith(e,t,n){return Zs(this,e,t,n),this}deleteRange(e,t){return Qs(this,e,t),this}lift(e,t){return Fs(this,e,t),this}join(e,t=1){return Us(this,e,t),this}wrap(e,t){return Ws(this,e,t),this}setBlockType(e,t=e,n,i=null){return Js(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return qs(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new bt(e,t,n)),this}setDocAttribute(e,t){return this.step(new kt(e,t)),this}addNodeMark(e,t){return this.step(new Ye(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 N)t.isInSet(n.marks)&&this.step(new Ae(e,t));else{let i=n.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new Ae(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,n){return $s(this,e,t,n),this}addMark(e,t,n){return Bs(this,e,t,n),this}removeMark(e,t,n){return zs(this,e,t,n),this}clearIncompatible(e,t,n){return nn(this,e,t,n),this}};var sn=Object.create(null),C=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Be(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=S.empty){let n=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=n,n=n.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],f=e.mapping.slice(s);e.replaceRange(f.map(a.pos),f.map(c.pos),l?S.empty:t),l==0&&Wr(e,s,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(n),c=a.map(o.pos),f=a.map(l.pos);s?e.deleteRange(c,f):(e.replaceRangeWith(c,f,t),Wr(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new O(e):Ie(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?Ie(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):Ie(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new q(e.node(0))}static atStart(e){return Ie(e,e,0,0,1)||new q(e)}static atEnd(e){return Ie(e,e,e.content.size,e.childCount,-1)||new q(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=sn[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 sn)throw new RangeError("Duplicate use of selection JSON ID "+e);return sn[e]=t,t.prototype.jsonID=e,t}getBookmark(){return O.between(this.$anchor,this.$head).getBookmark()}};C.prototype.visible=!0;var Be=class{constructor(e,t){this.$from=e,this.$to=t}},Vr=!1;function Lr(r){!Vr&&!r.parent.inlineContent&&(Vr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}var O=class r extends C{constructor(e,t=e){Lr(e),Lr(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return C.near(n);let i=e.resolve(t.map(this.anchor));return new r(i.parent.inlineContent?i:n,n)}replace(e,t=S.empty){if(super.replace(e,t),t==S.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof r&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Ot(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new r(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let s=C.findFrom(t,n,!0)||C.findFrom(t,-n,!0);if(s)t=s.$head;else return C.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(C.findFrom(e,-n,!0)||C.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new r(e,t)}};C.jsonID("text",O);var Ot=class r{constructor(e,t){this.anchor=e,this.head=t}map(e){return new r(e.map(this.anchor),e.map(this.head))}resolve(e){return O.between(e.resolve(this.anchor),e.resolve(this.head))}},b=class r extends C{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return n?C.near(s):new r(s)}content(){return new S(y.from(this.node),0,0)}eq(e){return e instanceof r&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ln(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new r(e.resolve(t.anchor))}static create(e,t){return new r(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};b.prototype.visible=!1;C.jsonID("node",b);var ln=class r{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Ot(n,n):new r(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&b.isSelectable(n)?new b(t):C.near(t)}},q=class r extends C{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=S.empty){if(t==S.empty){e.delete(0,e.doc.content.size);let n=C.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new r(e)}map(e){return new r(e)}eq(e){return e instanceof r}getBookmark(){return _s}};C.jsonID("all",q);var _s={map(){return this},resolve(r){return new q(r)}};function Ie(r,e,t,n,i,s=!1){if(e.inlineContent)return O.create(r,t);for(let o=n-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&b.isSelectable(l))return b.create(r,t-(i<0?l.nodeSize:0))}else{let a=Ie(r,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function Wr(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof F||i instanceof v))return;let s=r.mapping.maps[n],o;s.forEach((l,a,c,f)=>{o==null&&(o=f)}),r.setSelection(C.near(r.doc.resolve(o),t))}var Jr=1,Nt=2,vr=4,an=class extends Ct{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|Jr)&~Nt,this.storedMarks=null,this}get selectionSet(){return(this.updated&Jr)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Nt,this}ensureMarks(e){return N.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&Nt)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Nt,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)||N.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),!e)return this.deleteRange(t,n);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=n==t?o.marks():o.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,s)),!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|=vr,this}get scrolledIntoView(){return(this.updated&vr)>0}};function qr(r,e){return!e||!r?r:r.bind(e)}var xe=class{constructor(e,t,n){this.name=e,this.init=qr(t.init,n),this.apply=qr(t.apply,n)}},eo=[new xe("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new xe("selection",{init(r,e){return r.selection||C.atStart(e.doc)},apply(r){return r.selection}}),new xe("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new xe("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})],_e=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=eo.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 xe(n.key,n.spec.state,n))})}},$r=class r{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let i=this.config.plugins[n];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=i?i[o].n:0,c=i?i[o].state:this,f=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,n);if(f&&n.filterTransaction(f,o)){if(f.setMeta("appendedTransaction",e),!i){i=[];for(let h=0;h<this.config.plugins.length;h++)i.push(h<o?{state:n,n:t.length}:{state:this,n:0})}t.push(f),n=n.applyInner(f),s=!0}i&&(i[o]={state:n,n:t.length})}}if(!s)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new r(this.config),n=this.config.fields;for(let i=0;i<n.length;i++){let s=n[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new an(this)}static create(e){let t=new _e(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new r(t);for(let i=0;i<t.fields.length;i++)n[t.fields[i].name]=t.fields[i].init(e,n);return n}reconfigure(e){let t=new _e(this.schema,e.plugins),n=t.fields,i=new r(t);for(let s=0;s<n.length;s++){let o=n[s].name;i[o]=this.hasOwnProperty(o)?this[o]:n[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[n],s=i.spec.state;s&&s.toJSON&&(t[n]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new _e(e.schema,e.plugins),s=new r(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=X.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=C.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let l in n){let a=n[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=c.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}};function Hr(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=Hr(i,e,{})),t[n]=i}return t}var Mt=class{constructor(e){this.spec=e,this.props={},e.props&&Hr(e.props,this,this.props),this.key=e.key?e.key.key:Ur("plugin")}getState(e){return e[this.key]}},on=Object.create(null);function Ur(r){return r in on?r+"$"+ ++on[r]:(on[r]=0,r+"$")}var Kr=class{constructor(e="key"){this.key=Ur(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Gr=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function Yr(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}var to=(r,e,t)=>{let n=Yr(r,t);if(!n)return!1;let i=fn(n);if(!i){let o=n.blockRange(),l=o&&Xe(o);return l==null?!1:(e&&e(r.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Zr(r,i,e,-1))return!0;if(n.parent.content.size==0&&(ze(s,"end")||b.isSelectable(s)))for(let o=n.depth;;o--){let l=Qe(r.doc,n.before(o),n.after(o),S.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=r.tr.step(l);a.setSelection(ze(s,"end")?C.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):b.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||n.node(o-1).childCount>1)break}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},ma=(r,e,t)=>{let n=Yr(r,t);if(!n)return!1;let i=fn(n);return i?no(r,i,e):!1};function no(r,e,t){let n=e.nodeBefore,i=n,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let f=i.lastChild;if(!f)return!1;i=f}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let f=l.firstChild;if(!f)return!1;l=f}let c=Qe(r.doc,s,a,S.empty);if(!c||c.from!=s||c instanceof F&&c.slice.size>=a-s)return!1;if(t){let f=r.tr.step(c);f.setSelection(O.create(f.doc,s)),t(f.scrollIntoView())}return!0}function ze(r,e,t=!1){for(let n=r;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(t&&n.childCount!=1)return!1}return!1}var ro=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",r):n.parentOffset>0)return!1;s=fn(n)}let o=s&&s.nodeBefore;return!o||!b.isSelectable(o)?!1:(e&&e(r.tr.setSelection(b.create(r.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function fn(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){if(r.index(e)>0)return r.doc.resolve(r.before(e+1));if(r.node(e).type.spec.isolating)break}return null}function io(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}var so=(r,e,t)=>{let n=io(r,t);if(!n)return!1;let i=Xr(n);if(!i)return!1;let s=i.nodeAfter;if(Zr(r,i,e,1))return!0;if(n.parent.content.size==0&&(ze(s,"start")||b.isSelectable(s))){let o=Qe(r.doc,n.before(),n.after(),S.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=r.tr.step(o);l.setSelection(ze(s,"start")?C.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):b.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},oo=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",r):n.parentOffset<n.parent.content.size)return!1;s=Xr(n)}let o=s&&s.nodeAfter;return!o||!b.isSelectable(o)?!1:(e&&e(r.tr.setSelection(b.create(r.doc,s.pos)).scrollIntoView()),!0)};function Xr(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){let t=r.node(e);if(r.index(e)+1<t.childCount)return r.doc.resolve(r.after(e+1));if(t.type.spec.isolating)break}return null}var ga=(r,e)=>{let{$from:t,$to:n}=r.selection,i=t.blockRange(n),s=i&&Xe(i);return s==null?!1:(e&&e(r.tr.lift(i,s).scrollIntoView()),!0)},lo=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
6
- `).scrollIntoView()),!0)};function hn(r){for(let e=0;e<r.edgeCount;e++){let{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var ao=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=hn(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=r.tr.replaceWith(l,l,o.createAndFill());a.setSelection(C.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},co=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof q||n.parent.inlineContent||i.parent.inlineContent)return!1;let s=hn(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos,l=r.tr.insert(o,s.createAndFill());l.setSelection(O.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},fo=(r,e)=>{let{$cursor:t}=r.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Ze(r.doc,s))return e&&e(r.tr.split(s).scrollIntoView()),!0}let n=t.blockRange(),i=n&&Xe(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)};function ho(r){return(e,t)=>{if(e.selection instanceof b&&e.selection.node.isBlock){let{$from:p}=e.selection;return!p.parentOffset||!Ze(e.doc,p.pos)?!1:(t&&t(e.tr.split(p.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let n=e.tr;!e.selection.empty&&(e.selection instanceof O||e.selection instanceof q)&&n.deleteSelection();let{$from:i}=n.selection,s=n.steps.length,o=[],l,a,c=!1,f=!1;for(let p=i.depth;;p--)if(i.node(p).isBlock){c=i.end(p)==i.pos+(i.depth-p),f=i.start(p)==i.pos-(i.depth-p),a=hn(i.node(p-1).contentMatchAt(i.indexAfter(p-1)));let m=r&&r(i.parent,c,i);o.unshift(m||(c&&a?{type:a}:null)),l=p;break}else{if(p==1)return!1;o.unshift(null)}let h=i.pos,d=Ze(n.doc,h,o.length,o);if(d||(o[0]=a?{type:a}:null,d=Ze(n.doc,h,o.length,o)),!d)return!1;if(n.split(h,o.length,o),!c&&f&&i.node(l).type!=a){let p=n.mapping.slice(s),u=p.map(i.before(l)),m=n.doc.resolve(u);a&&i.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&n.setNodeMarkup(p.map(i.before(l)),a)}return t&&t(n.scrollIntoView()),!0}}var uo=ho();var po=(r,e)=>(e&&e(r.tr.setSelection(new q(r.doc))),!0);function mo(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,s=e.index();return!n||!i||!n.type.compatibleContent(i.type)?!1:!n.content.size&&e.parent.canReplace(s-1,s)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||rn(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function Zr(r,e,t,n){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&mo(r,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let p=e.pos+s.nodeSize,u=y.empty;for(let x=o.length-1;x>=0;x--)u=y.from(o[x].create(null,u));u=y.from(i.copy(u));let m=r.tr.step(new v(e.pos-1,p,e.pos,p,new S(u,1,0),o.length,!0)),g=m.doc.resolve(p+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&rn(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let f=s.type.spec.isolating||n>0&&a?null:C.findFrom(e,1),h=f&&f.$from.blockRange(f.$to),d=h&&Xe(h);if(d!=null&&d>=e.depth)return t&&t(r.tr.lift(h,d).scrollIntoView()),!0;if(c&&ze(s,"start",!0)&&ze(i,"end")){let p=i,u=[];for(;u.push(p),!p.isTextblock;)p=p.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,m.content)){if(t){let x=y.empty;for(let M=u.length-1;M>=0;M--)x=y.from(u[M].copy(x));let T=r.tr.step(new v(e.pos-u.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new S(x,u.length,0),0,!0));t(T.scrollIntoView())}return!0}}return!1}function Qr(r){return function(e,t){let n=e.selection,i=r<0?n.$from:n.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(O.create(e.doc,r<0?i.start(s):i.end(s)))),!0):!1}}var go=Qr(-1),yo=Qr(1);function ya(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&Er(o,r,e);return l?(n&&n(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Sa(r,e=null){return function(t,n){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(r,e)))if(a.type==r)i=!0;else{let f=t.doc.resolve(c),h=f.index();i=f.parent.canReplaceWith(h,h+1,r)}})}if(!i)return!1;if(n){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,r,e)}n(s.scrollIntoView())}return!0}}function So(r,e,t,n){for(let i=0;i<e.length;i++){let{$from:s,$to:o}=e[i],l=s.depth==0?r.inlineContent&&r.type.allowsMarkType(t):!1;if(r.nodesBetween(s.pos,o.pos,(a,c)=>{if(l||!n&&a.isAtom&&a.isInline&&c>=s.pos&&c+a.nodeSize<=o.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function xo(r){let e=[];for(let t=0;t<r.length;t++){let{$from:n,$to:i}=r[t];n.doc.nodesBetween(n.pos,i.pos,(s,o)=>{if(s.isAtom&&s.content.size&&s.isInline&&o>=n.pos&&o+s.nodeSize<=i.pos)return o+1>n.pos&&e.push(new Be(n,n.doc.resolve(o+1))),n=n.doc.resolve(o+1+s.content.size),!1}),n.pos<i.pos&&e.push(new Be(n,i))}return e}function xa(r,e=null,t){let n=(t&&t.removeWhenPresent)!==!1,i=(t&&t.enterInlineAtoms)!==!1,s=!(t&&t.includeWhitespace);return function(o,l){let{empty:a,$cursor:c,ranges:f}=o.selection;if(a&&!c||!So(o.doc,f,r,i))return!1;if(l)if(c)r.isInSet(o.storedMarks||c.marks())?l(o.tr.removeStoredMark(r)):l(o.tr.addStoredMark(r.create(e)));else{let h,d=o.tr;i||(f=xo(f)),n?h=!f.some(p=>o.doc.rangeHasMark(p.$from.pos,p.$to.pos,r)):h=!f.every(p=>{let u=!1;return d.doc.nodesBetween(p.$from.pos,p.$to.pos,(m,g,x)=>{if(u)return!1;u=!r.isInSet(m.marks)&&!!x&&x.type.allowsMarkType(r)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,p.$from.pos-g),Math.min(m.nodeSize,p.$to.pos-g))))}),!u});for(let p=0;p<f.length;p++){let{$from:u,$to:m}=f[p];if(!h)d.removeMark(u.pos,m.pos,r);else{let g=u.pos,x=m.pos,T=u.nodeAfter,M=m.nodeBefore,Y=s&&T&&T.isText?/^\s*/.exec(T.text)[0].length:0,ue=s&&M&&M.isText?/\s*$/.exec(M.text)[0].length:0;g+Y<x&&(g+=Y,x-=ue),d.addMark(g,x,r.create(e))}}l(d.scrollIntoView())}return!0}}function dn(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}var cn=dn(Gr,to,ro),jr=dn(Gr,so,oo),_={Enter:dn(lo,co,fo,uo),"Mod-Enter":ao,Backspace:cn,"Mod-Backspace":cn,"Shift-Backspace":cn,Delete:jr,"Mod-Delete":jr,"Mod-a":po},_r={"Ctrl-h":_.Backspace,"Alt-Backspace":_["Mod-Backspace"],"Ctrl-d":_.Delete,"Ctrl-Alt-Backspace":_["Mod-Delete"],"Alt-Delete":_["Mod-Delete"],"Alt-d":_["Mod-Delete"],"Ctrl-a":go,"Ctrl-e":yo};for(let r in _)_r[r]=_[r];var bo=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,ba=bo?_r:_;var ee={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:"'"},Dt={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ko=typeof navigator<"u"&&/Mac/.test(navigator.platform),Co=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(D=0;D<10;D++)ee[48+D]=ee[96+D]=String(D);var D;for(D=1;D<=24;D++)ee[D+111]="F"+D;var D;for(D=65;D<=90;D++)ee[D]=String.fromCharCode(D+32),Dt[D]=String.fromCharCode(D);var D;for(Tt in ee)Dt.hasOwnProperty(Tt)||(Dt[Tt]=ee[Tt]);var Tt;function ei(r){var e=ko&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||Co&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?Dt:ee)[r.keyCode]||r.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var No=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Oo=typeof navigator<"u"&&/Win/.test(navigator.platform);function Mo(r){let e=r.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,i,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))n=!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))No?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return n&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function To(r){let e=Object.create(null);for(let t in r)e[Mo(t)]=r[t];return e}function un(r,e,t=!0){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t&&e.shiftKey&&(r="Shift-"+r),r}function Ma(r){return new Mt({props:{handleKeyDown:Do(r)}})}function Do(r){let e=To(r);return function(t,n){let i=ei(n),s,o=e[un(i,n)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(n.shiftKey){let l=e[un(i,n,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Oo&&n.ctrlKey&&n.altKey)&&(s=ee[n.keyCode])&&s!=i){let l=e[un(s,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var R=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},Le=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e},xn=null,ne=function(r,e,t){let n=xn||(xn=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},wo=function(){xn=null},De=function(r,e,t,n){return t&&(ti(r,e,t,n,-1)||ti(r,e,t,n,1))},Eo=/^(img|br|input|textarea|hr)$/i;function ti(r,e,t,n,i){for(var s;;){if(r==t&&e==n)return!0;if(e==(i<0?0:K(r))){let o=r.parentNode;if(!o||o.nodeType!=1||ot(r)||Eo.test(r.nodeName)||r.contentEditable=="false")return!1;e=R(r)+(i<0?0:1),r=o}else if(r.nodeType==1){let o=r.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else r=o,e=i<0?K(r):0}else return!1}}function K(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Ao(r,e){for(;;){if(r.nodeType==3&&e)return r;if(r.nodeType==1&&e>0){if(r.contentEditable=="false")return null;r=r.childNodes[e-1],e=K(r)}else if(r.parentNode&&!ot(r))e=R(r),r=r.parentNode;else return null}}function Ro(r,e){for(;;){if(r.nodeType==3&&e<r.nodeValue.length)return r;if(r.nodeType==1&&e<r.childNodes.length){if(r.contentEditable=="false")return null;r=r.childNodes[e],e=0}else if(r.parentNode&&!ot(r))e=R(r)+1,r=r.parentNode;else return null}}function Io(r,e,t){for(let n=e==0,i=e==K(r);n||i;){if(r==t)return!0;let s=R(r);if(r=r.parentNode,!r)return!1;n=n&&s==0,i=i&&s==K(r)}}function ot(r){let e;for(let t=r;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==r||e.contentDOM==r)}var Wt=function(r){return r.focusNode&&De(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function be(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function Bo(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function zo(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(K(n.offsetNode),n.offset)}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(K(n.startContainer),n.startOffset)}}}var Z=typeof navigator<"u"?navigator:null,ni=typeof document<"u"?document:null,de=Z&&Z.userAgent||"",bn=/Edge\/(\d+)/.exec(de),Ri=/MSIE \d/.exec(de),kn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(de),J=!!(Ri||kn||bn),ce=Ri?document.documentMode:kn?+kn[1]:bn?+bn[1]:0,H=!J&&/gecko\/(\d+)/i.test(de);H&&+(/Firefox\/(\d+)/.exec(de)||[0,0])[1];var Cn=!J&&/Chrome\/(\d+)/.exec(de),I=!!Cn,Ii=Cn?+Cn[1]:0,P=!J&&!!Z&&/Apple Computer/.test(Z.vendor),We=P&&(/Mobile\/\w+/.test(de)||!!Z&&Z.maxTouchPoints>2),$=We||(Z?/Mac/.test(Z.platform):!1),Bi=Z?/Win/.test(Z.platform):!1,re=/Android \d/.test(de),lt=!!ni&&"webkitFontSmoothing"in ni.documentElement.style,Po=lt?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Fo(r){let e=r.defaultView&&r.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.documentElement.clientWidth,top:0,bottom:r.documentElement.clientHeight}}function te(r,e){return typeof r=="number"?r:r[e]}function Vo(r){let e=r.getBoundingClientRect(),t=e.width/r.offsetWidth||1,n=e.height/r.offsetHeight||1;return{left:e.left,right:e.left+r.clientWidth*t,top:e.top,bottom:e.top+r.clientHeight*n}}function ri(r,e,t){if(!Nn(e)&&e.left==0)return;let n=r.someProp("scrollThreshold")||0,i=r.someProp("scrollMargin")||5,s=r.dom.ownerDocument;for(let o=t||r.dom;o;){if(o.nodeType!=1){o=Le(o);continue}let l=o,a=l==s.body,c=a?Fo(s):Vo(l),f=0,h=0;if(e.top<c.top+te(n,"top")?h=-(c.top-e.top+te(i,"top")):e.bottom>c.bottom-te(n,"bottom")&&(h=e.bottom-e.top>c.bottom-c.top?e.top+te(i,"top")-c.top:e.bottom-c.bottom+te(i,"bottom")),e.left<c.left+te(n,"left")?f=-(c.left-e.left+te(i,"left")):e.right>c.right-te(n,"right")&&(f=e.right-c.right+te(i,"right")),f||h)if(a)s.defaultView.scrollBy(f,h);else{let p=l.scrollLeft,u=l.scrollTop;h&&(l.scrollTop+=h),f&&(l.scrollLeft+=f);let m=l.scrollLeft-p,g=l.scrollTop-u;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let d=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(d))break;o=d=="absolute"?o.offsetParent:Le(o)}}function Lo(r){let e=r.dom.getBoundingClientRect(),t=Math.max(0,e.top),n,i;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=r.root.elementFromPoint(s,o);if(!l||l==r.dom||!r.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){n=l,i=a.top;break}}return{refDOM:n,refTop:i,stack:zi(r.dom)}}function zi(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=Le(n));return e}function Wo({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;Pi(t,n==0?0:n-e)}function Pi(r,e){for(let t=0;t<r.length;t++){let{dom:n,top:i,left:s}=r[t];n.scrollTop!=i+e&&(n.scrollTop=i+e),n.scrollLeft!=s&&(n.scrollLeft=s)}}var Pe=null;function Jo(r){if(r.setActive)return r.setActive();if(Pe)return r.focus(Pe);let e=zi(r);r.focus(Pe==null?{get preventScroll(){return Pe={preventScroll:!0},!0}}:void 0),Pe||(Pe=!1,Pi(e,0))}function Fi(r,e){let t,n=2e8,i,s=0,o=e.top,l=e.top,a,c;for(let f=r.firstChild,h=0;f;f=f.nextSibling,h++){let d;if(f.nodeType==1)d=f.getClientRects();else if(f.nodeType==3)d=ne(f).getClientRects();else continue;for(let p=0;p<d.length;p++){let u=d[p];if(u.top<=o&&u.bottom>=l){o=Math.max(u.bottom,o),l=Math.min(u.top,l);let m=u.left>e.left?u.left-e.left:u.right<e.left?e.left-u.right:0;if(m<n){t=f,n=m,i=m&&t.nodeType==3?{left:u.right<e.left?u.right:u.left,top:e.top}:e,f.nodeType==1&&m&&(s=h+(e.left>=(u.left+u.right)/2?1:0));continue}}else u.top>e.top&&!a&&u.left<=e.left&&u.right>=e.left&&(a=f,c={left:Math.max(u.left,Math.min(u.right,e.left)),top:u.top});!t&&(e.left>=u.right&&e.top>=u.top||e.left>=u.left&&e.top>=u.bottom)&&(s=h+1)}}return!t&&a&&(t=a,i=c,n=0),t&&t.nodeType==3?vo(t,i):!t||n&&t.nodeType==1?{node:r,offset:s}:Fi(t,i)}function vo(r,e){let t=r.nodeValue.length,n=document.createRange(),i;for(let s=0;s<t;s++){n.setEnd(r,s+1),n.setStart(r,s);let o=le(n,1);if(o.top!=o.bottom&&Jn(e,o)){i={node:r,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return n.detach(),i||{node:r,offset:0}}function Jn(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function qo(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function $o(r,e,t){let{node:n,offset:i}=Fi(e,t),s=-1;if(n.nodeType==1&&!n.firstChild){let o=n.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return r.docView.posFromDOM(n,i,s)}function Ko(r,e,t,n){let i=-1;for(let s=e,o=!1;s!=r.dom;){let l=r.docView.nearestDesc(s,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(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)&&(!o&&a.left>n.left||a.top>n.top?i=l.posBefore:(!o&&a.right<n.left||a.bottom<n.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?n.top<(a.top+a.bottom)/2:n.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:r.docView.posFromDOM(e,t,-1)}function Vi(r,e,t){let n=r.childNodes.length;if(n&&t.top<t.bottom)for(let i=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let o=r.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Jn(e,c))return Vi(o,e,c)}}if((s=(s+1)%n)==i)break}return r}function Ho(r,e){let t=r.dom.ownerDocument,n,i=0,s=zo(t,e.left,e.top);s&&({node:n,offset:i}=s);let o=(r.root.elementFromPoint?r.root:t).elementFromPoint(e.left,e.top),l;if(!o||!r.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=r.dom.getBoundingClientRect();if(!Jn(e,c)||(o=Vi(r.dom,e,c),!o))return null}if(P)for(let c=o;n&&c;c=Le(c))c.draggable&&(n=void 0);if(o=qo(o,e),n){if(H&&n.nodeType==1&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let f=n.childNodes[i],h;f.nodeName=="IMG"&&(h=f.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&i++}let c;lt&&i&&n.nodeType==1&&(c=n.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,n==r.dom&&i==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom?l=r.state.doc.content.size:(i==0||n.nodeType!=1||n.childNodes[i-1].nodeName!="BR")&&(l=Ko(r,n,i,e))}l==null&&(l=$o(r,o,e));let a=r.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Nn(r){return r.top<r.bottom||r.left<r.right}function le(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(Nn(n))return n}return Array.prototype.find.call(t,Nn)||r.getBoundingClientRect()}var Uo=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Li(r,e,t){let{node:n,offset:i,atom:s}=r.docView.domFromPos(e,t<0?-1:1),o=lt||H;if(n.nodeType==3)if(o&&(Uo.test(n.nodeValue)||(t<0?!i:i==n.nodeValue.length))){let a=le(ne(n,i,i),t);if(H&&i&&/\s/.test(n.nodeValue[i-1])&&i<n.nodeValue.length){let c=le(ne(n,i-1,i-1),-1);if(c.top==a.top){let f=le(ne(n,i,i+1),-1);if(f.top!=a.top)return et(f,f.left<c.left)}}return a}else{let a=i,c=i,f=t<0?1:-1;return t<0&&!i?(c++,f=-1):t>=0&&i==n.nodeValue.length?(a--,f=1):t<0?a--:c++,et(le(ne(n,a,c),f),f<0)}if(!r.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==K(n))){let a=n.childNodes[i-1];if(a.nodeType==1)return pn(a.getBoundingClientRect(),!1)}if(s==null&&i<K(n)){let a=n.childNodes[i];if(a.nodeType==1)return pn(a.getBoundingClientRect(),!0)}return pn(n.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==K(n))){let a=n.childNodes[i-1],c=a.nodeType==3?ne(a,K(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return et(le(c,1),!1)}if(s==null&&i<K(n)){let a=n.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?ne(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return et(le(c,-1),!0)}return et(le(n.nodeType==3?ne(n):n,-t),t>=0)}function et(r,e){if(r.width==0)return r;let t=e?r.left:r.right;return{top:r.top,bottom:r.bottom,left:t,right:t}}function pn(r,e){if(r.height==0)return r;let t=e?r.top:r.bottom;return{top:t,bottom:t,left:r.left,right:r.right}}function Wi(r,e,t){let n=r.state,i=r.root.activeElement;n!=e&&r.updateState(e),i!=r.dom&&r.focus();try{return t()}finally{n!=e&&r.updateState(n),i!=r.dom&&i&&i.focus()}}function jo(r,e,t){let n=e.selection,i=t=="up"?n.$from:n.$to;return Wi(r,e,()=>{let{node:s}=r.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=r.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Li(r,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=ne(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let f=a[c];if(f.bottom>f.top+1&&(t=="up"?o.top-f.top>(f.bottom-o.top)*2:f.bottom-o.bottom>(o.bottom-f.top)*2))return!1}}return!0})}var Go=/[\u0590-\u08ac]/;function Yo(r,e,t){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let i=n.parentOffset,s=!i,o=i==n.parent.content.size,l=r.domSelection();return l?!Go.test(n.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Wi(r,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:f,anchorOffset:h}=r.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let p=n.depth?r.docView.domAfterPos(n.before()):r.dom,{focusNode:u,focusOffset:m}=r.domSelectionRange(),g=u&&!p.contains(u.nodeType==1?u:u.parentNode)||a==u&&c==m;try{l.collapse(f,h),a&&(a!=f||c!=h)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),g}):n.pos==n.start()||n.pos==n.end()}var ii=null,si=null,oi=!1;function Xo(r,e,t){return ii==e&&si==t?oi:(ii=e,si=t,oi=t=="up"||t=="down"?jo(r,e,t):Yo(r,e,t))}var U=0,li=1,ke=2,G=3,we=class{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=U,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 i=this.children[t];if(i==e)return n;n+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>R(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||s.node))if(n&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))n=!1;else return s}}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 i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let i=this.children[t],s=n+i.size;if(n==e&&s!=n){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<s)return i.descAt(e-n-i.border);n=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,i=0;for(let s=0;n<this.children.length;n++){let o=this.children[n],l=s+o.size;if(l>e||o instanceof At){i=e-s;break}s=l}if(i)return this.children[n].domFromPos(i-this.children[n].border,t);for(let s;n&&!(s=this.children[n-1]).size&&s instanceof wt&&s.side>=0;n--);if(t<=0){let s,o=!0;for(;s=n?this.children[n-1]:null,!(!s||s.dom.parentNode==this.contentDOM);n--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?R(s.dom)+1:0}}else{let s,o=!0;for(;s=n<this.children.length?this.children[n]:null,!(!s||s.dom.parentNode==this.contentDOM);n++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?R(s.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 i=-1,s=-1;for(let o=n,l=0;;l++){let a=this.children[l],c=o+a.size;if(i==-1&&e<=c){let f=o+a.border;if(e>=f&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,f);e=o;for(let h=l;h>0;h--){let d=this.children[h-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=R(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let f=l+1;f<this.children.length;f++){let h=this.children[f];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){s=R(h.dom);break}t+=h.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let p=0,u=0;p<this.children.length;p++){let m=this.children[p],g=u+m.size;if(s>u&&o<g)return m.setSelection(e-u-m.border,t-u-m.border,n,i);u=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),f=n.domSelectionRange(),h=!1;if((H||P)&&e==t){let{node:p,offset:u}=l;if(p.nodeType==3){if(h=!!(u&&p.nodeValue[u-1]==`
7
- `),h&&u==p.nodeValue.length)for(let m=p,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:R(g)+1});break}let x=m.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let m=p.childNodes[u-1];h=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(H&&f.focusNode&&f.focusNode!=a.node&&f.focusNode.nodeType==1){let p=f.focusNode.childNodes[f.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||h&&P)&&De(l.node,l.offset,f.anchorNode,f.anchorOffset)&&De(a.node,a.offset,f.focusNode,f.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(h&&H)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){let u=l;l=a,a=u}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.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,i=0;i<this.children.length;i++){let s=this.children[i],o=n+s.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let l=n+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==n||t==o?ke:li,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=G:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?ke:G}n=o}this.dirty=ke}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?ke:li;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},wt=class extends we{constructor(e,t,n,i){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(n,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==U&&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}},On=class extends we{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}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}},Ne=class r extends we{constructor(e,t,n,i,s){super(e,[],n,i),this.mark=t,this.spec=s}static create(e,t,n,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,n);return(!o||!o.dom)&&(o=ye.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new r(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&G||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=G&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=U){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=U}}slice(e,t,n){let i=r.create(this.parent,this.mark,!0,n),s=this.children,o=this.size;t<o&&(s=wn(s,t,o,n)),e>0&&(s=wn(s,0,e,n));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},fe=class r extends we{constructor(e,t,n,i,s,o,l){super(e,[],s,o),this.node=t,this.outerDeco=n,this.innerDeco=i,this.nodeDOM=l}static create(e,t,n,i,s,o){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},n,i),f=c&&c.dom,h=c&&c.contentDOM;if(t.isText){if(!f)f=document.createTextNode(t.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:h}=ye.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!h&&!t.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),t.type.spec.draggable&&(f.draggable=!0));let d=f;return f=qi(f,n,t),c?a=new Mn(e,t,n,i,f,h||null,d,c):t.isText?new Et(e,t,n,i,f,d):new r(e,t,n,i,f,h||null,d)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let i=this.children[n];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(i=>i.nodeType==1&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));n?t.contentElement=n:t.getContent=()=>y.empty}}return t}matchesNode(e,t,n){return this.dirty==U&&e.eq(this.node)&&Rt(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Dn(this,o&&o.node,e);el(this.node,this.innerDeco,(c,f,h)=>{c.spec.marks?a.syncToMarks(c.spec.marks,n,e,f):c.type.side>=0&&!h&&a.syncToMarks(f==this.node.childCount?N.none:this.node.child(f).marks,n,e,f),a.placeWidget(c,e,i)},(c,f,h,d)=>{a.syncToMarks(c.marks,n,e,d);let p;a.findNodeMatch(c,f,h,d)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(p=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,f,h,p,e)||a.updateNextNode(c,f,h,e,d,i)||a.addNode(c,f,h,e,i),i+=c.nodeSize}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==ke)&&(o&&this.protectLocalComposition(e,o),Ji(this.contentDOM,this.children,e),We&&tl(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof O)||n<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=nl(this.node.content,o,n-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let s=t;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 o=new On(this,s,t,i);e.input.compositionNodes.push(o),this.children=wn(this.children,n,n+i.length,e,o)}update(e,t,n,i){return this.dirty==G||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=U}updateOuterDeco(e){if(Rt(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=vi(this.dom,this.nodeDOM,Tn(this.outerDeco,this.node,t),Tn(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function ai(r,e,t,n,i){qi(n,e,r);let s=new fe(void 0,r,e,t,n,n,n);return s.contentDOM&&s.updateChildren(i,0),s}var Et=class r extends fe{constructor(e,t,n,i,s,o){super(e,t,n,i,s,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return this.dirty==G||this.dirty!=U&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=U||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=U,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new r(this.parent,i,this.outerDeco,this.innerDeco,s,s)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=G)}get domAtom(){return!1}isText(e){return this.node.text==e}},At=class extends we{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==U&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Mn=class extends fe{constructor(e,t,n,i,s,o,l,a){super(e,t,n,i,s,o,l),this.spec=a}update(e,t,n,i){if(this.dirty==G)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,n);return s&&this.updateInner(e,t,n,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,i)}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 Ji(r,e,t){let n=r.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==r){for(;l!=n;)n=ci(n),i=!0;n=n.nextSibling}else i=!0,r.insertBefore(l,n);if(o instanceof Ne){let a=n?n.previousSibling:r.lastChild;Ji(o.contentDOM,o.children,t),n=a?a.nextSibling:r.firstChild}}for(;n;)n=ci(n),i=!0;i&&t.trackWrites==r&&(t.trackWrites=null)}var tt=function(r){r&&(this.nodeName=r)};tt.prototype=Object.create(null);var Ce=[new tt];function Tn(r,e,t){if(r.length==0)return Ce;let n=t?Ce[0]:new tt,i=[n];for(let s=0;s<r.length;s++){let o=r[s].type.attrs;if(o){o.nodeName&&i.push(n=new tt(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(n=new tt(e.isInline?"span":"div")),l=="class"?n.class=(n.class?n.class+" ":"")+a:l=="style"?n.style=(n.style?n.style+";":"")+a:l!="nodeName"&&(n[l]=a))}}}return i}function vi(r,e,t,n){if(t==Ce&&n==Ce)return e;let i=e;for(let s=0;s<n.length;s++){let o=n[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=r&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=Ce[0]),i=a}Zo(i,l||Ce[0],o)}return i}function Zo(r,e,t){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in t)&&r.removeAttribute(n);for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&t[n]!=e[n]&&r.setAttribute(n,t[n]);if(e.class!=t.class){let n=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<n.length;s++)i.indexOf(n[s])==-1&&r.classList.remove(n[s]);for(let s=0;s<i.length;s++)n.indexOf(i[s])==-1&&r.classList.add(i[s]);r.classList.length==0&&r.removeAttribute("class")}if(e.style!=t.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=n.exec(e.style);)r.style.removeProperty(i[1])}t.style&&(r.style.cssText+=t.style)}}function qi(r,e,t){return vi(r,r,Ce,Tn(e,t,r.nodeType!=1))}function Rt(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].type.eq(e[t].type))return!1;return!0}function ci(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}var Dn=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Qo(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,i){let s=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;s<l&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=U,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let f=this.index;f<c;f++){let h=this.top.children[f];if(h.matchesMark(e[o])&&!this.isLocked(h.dom)){a=f;break}}if(a<0&&this.index<this.top.children.length){let f=this.top.children[this.index];f instanceof Ne&&f.dirty!=G&&f.mark.type==e[o].type&&f.spec.update&&!this.isLocked(f.dom)&&f.spec.update(e[o])&&(f.mark=e[o],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let f=Ne.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,n,i,s){let o=this.top.children[i];return o.dirty==G&&o.dom==o.contentDOM&&(o.dirty=ke),o.update(e,t,n,s)?(this.destroyBetween(this.index,i),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 i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==n)return i}return-1}e=t}}updateNextNode(e,t,n,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof fe){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let f=a.dom,h,d=this.isLocked(f)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=G&&Rt(t,a.outerDeco));if(!d&&a.update(e,t,n,i))return this.destroyBetween(this.index,l),a.dom!=f&&(this.changed=!0),this.index++,!0;if(!d&&(h=this.recreateWrapper(a,e,t,n,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=ke,h.updateChildren(i,o+1),h.dirty=U),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,i,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Rt(n,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=fe.create(this.top,t,n,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,n,i,s){let o=fe.create(this.top,e,t,n,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new wt(this.top,e,t,n);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ne;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Et)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((P||I)&&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 i=new At(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function Qo(r,e){let t=e,n=t.children.length,i=r.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(n){let c=t.children[n-1];if(c instanceof Ne)t=c,n=c.children.length;else{l=c,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=r.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function _o(r,e){return r.type.side-e.type.side}function el(r,e,t,n){let i=e.locals(r),s=0;if(i.length==0){for(let c=0;c<r.childCount;c++){let f=r.child(c);n(f,i,e.forChild(s,f),c),s+=f.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let f,h;for(;o<i.length&&i[o].to==s;){let g=i[o++];g.widget&&(f?(h||(h=[f])).push(g):f=g)}if(f)if(h){h.sort(_o);for(let g=0;g<h.length;g++)t(h[g],c,!!a)}else t(f,c,!!a);let d,p;if(a)p=-1,d=a,a=null;else if(c<r.childCount)p=c,d=r.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let u=s+d.nodeSize;if(d.isText){let g=u;o<i.length&&i[o].from<g&&(g=i[o].from);for(let x=0;x<l.length;x++)l[x].to<g&&(g=l[x].to);g<u&&(a=d.cut(g-s),d=d.cut(0,g-s),u=g,p=-1)}else for(;o<i.length&&i[o].to<u;)o++;let m=d.isInline&&!d.isLeaf?l.filter(g=>!g.inline):l.slice();n(d,m,e.forChild(s,d),p),s=u}}function tl(r){if(r.nodeName=="UL"||r.nodeName=="OL"){let e=r.style.cssText;r.style.cssText=e+"; list-style: square !important",window.getComputedStyle(r).listStyle,r.style.cssText=e}}function nl(r,e,t,n){for(let i=0,s=0;i<r.childCount&&s<=n;){let o=r.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<r.childCount;){let c=r.child(i++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=n&&a.slice(n-e.length-l,n-l)==e)return n-e.length;let c=l<n?a.lastIndexOf(e,n-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==n&&a.length>=n+e.length-l&&a.slice(n-l,n-l+e.length)==e)return n}}return-1}function wn(r,e,t,n,i){let s=[];for(let o=0,l=0;o<r.length;o++){let a=r[o],c=l,f=l+=a.size;c>=t||f<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,n)),i&&(s.push(i),i=void 0),f>t&&s.push(a.slice(t-c,a.size,n)))}return s}function vn(r,e=null){let t=r.domSelectionRange(),n=r.state.doc;if(!t.focusNode)return null;let i=r.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=r.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=n.resolve(o),a,c;if(Wt(t)){for(a=o;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&b.isSelectable(h)&&i.parent&&!(h.isInline&&Io(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;c=new b(o==d?l:n.resolve(d))}}else{if(t instanceof r.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let h=o,d=o;for(let p=0;p<t.rangeCount;p++){let u=t.getRangeAt(p);h=Math.min(h,r.docView.posFromDOM(u.startContainer,u.startOffset,1)),d=Math.max(d,r.docView.posFromDOM(u.endContainer,u.endOffset,-1))}if(h<0)return null;[a,o]=d==r.state.selection.anchor?[d,h]:[h,d],l=n.resolve(o)}else a=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let f=n.resolve(a);if(!c){let h=e=="pointer"||r.state.selection.head<l.pos&&!s?1:-1;c=qn(r,f,l,h)}return c}function $i(r){return r.editable?r.hasFocus():Hi(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function se(r,e=!1){let t=r.state.selection;if(Ki(r,t),!$i(r))return;let n=r.input.mouseDown;if(!e&&I&&n){let i=r.domSelectionRange(),s=r.domObserver.currentSelection;if(i.anchorNode&&s.anchorNode&&De(i.anchorNode,i.anchorOffset,s.anchorNode,s.anchorOffset)&&n.delaySelUpdate()){r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)il(r);else{let{anchor:i,head:s}=t,o,l;fi&&!(t instanceof O)&&(t.$from.parent.inlineContent||(o=hi(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=hi(r,t.to))),r.docView.setSelection(i,s,r,e),fi&&(o&&di(o),l&&di(l)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&rl(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}var fi=P||I&&Ii<63;function hi(r,e){let{node:t,offset:n}=r.docView.domFromPos(e,0),i=n<t.childNodes.length?t.childNodes[n]:null,s=n?t.childNodes[n-1]:null;if(P&&i&&i.contentEditable=="false")return mn(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return mn(i);if(s)return mn(s)}}function mn(r){return r.contentEditable="true",P&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function di(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function rl(r){let e=r.dom.ownerDocument;e.removeEventListener("selectionchange",r.input.hideSelectionGuard);let t=r.domSelectionRange(),n=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(t.anchorNode!=n||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!$i(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function il(r){let e=r.domSelection();if(!e)return;let t=r.cursorWrapper.dom,n=t.nodeName=="IMG";n?e.collapse(t.parentNode,R(t)+1):e.collapse(t,0),!n&&!r.state.selection.visible&&J&&ce<=11&&(t.disabled=!0,t.disabled=!1)}function Ki(r,e){if(e instanceof b){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(ui(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else ui(r)}function ui(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function qn(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||O.between(e,t,n)}function pi(r){return r.editable&&!r.hasFocus()?!1:Hi(r)}function Hi(r){let e=r.domSelectionRange();if(!e.anchorNode)return!1;try{return r.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(r.editable||r.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function sl(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return De(e.node,e.offset,t.anchorNode,t.anchorOffset)}function En(r,e){let{$anchor:t,$head:n}=r.selection,i=e>0?t.max(n):t.min(n),s=i.parent.inlineContent?i.depth?r.doc.resolve(e>0?i.after():i.before()):null:i;return s&&C.findFrom(s,e)}function ae(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function mi(r,e,t){let n=r.state.selection;if(n instanceof O)if(t.indexOf("s")>-1){let{$head:i}=n,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=r.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return ae(r,new O(n.$anchor,o))}else if(n.empty){if(r.endOfTextblock(e>0?"forward":"backward")){let i=En(r.state,e);return i&&i instanceof b?ae(r,i):!1}else if(!($&&t.indexOf("m")>-1)){let i=n.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=r.docView.descAt(l))&&!o.contentDOM?b.isSelectable(s)?ae(r,new b(e<0?r.state.doc.resolve(i.pos-s.nodeSize):i)):lt?ae(r,new O(r.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(n instanceof b&&n.node.isInline)return ae(r,new O(e>0?n.$to:n.$from));{let i=En(r.state,e);return i?ae(r,i):!1}}}function It(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function nt(r,e){let t=r.pmViewDesc;return t&&t.size==0&&(e<0||r.nextSibling||r.nodeName!="BR")}function Fe(r,e){return e<0?ol(r):ll(r)}function ol(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i,s,o=!1;for(H&&t.nodeType==1&&n<It(t)&&nt(t.childNodes[n],-1)&&(o=!0);;)if(n>0){if(t.nodeType!=1)break;{let l=t.childNodes[n-1];if(nt(l,-1))i=t,s=--n;else if(l.nodeType==3)t=l,n=t.nodeValue.length;else break}}else{if(Ui(t))break;{let l=t.previousSibling;for(;l&&nt(l,-1);)i=t.parentNode,s=R(l),l=l.previousSibling;if(l)t=l,n=It(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}o?An(r,t,n):i&&An(r,i,s)}function ll(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i=It(t),s,o;for(;;)if(n<i){if(t.nodeType!=1)break;let l=t.childNodes[n];if(nt(l,1))s=t,o=++n;else break}else{if(Ui(t))break;{let l=t.nextSibling;for(;l&&nt(l,1);)s=l.parentNode,o=R(l)+1,l=l.nextSibling;if(l)t=l,n=0,i=It(t);else{if(t=t.parentNode,t==r.dom)break;n=i=0}}}s&&An(r,s,o)}function Ui(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function al(r,e){for(;r&&e==r.childNodes.length&&!ot(r);)e=R(r)+1,r=r.parentNode;for(;r&&e<r.childNodes.length;){let t=r.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=0}}function cl(r,e){for(;r&&!e&&!ot(r);)e=R(r),r=r.parentNode;for(;r&&e;){let t=r.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=r.childNodes.length}}function An(r,e,t){if(e.nodeType!=3){let s,o;(o=al(e,t))?(e=o,t=0):(s=cl(e,t))&&(e=s,t=s.nodeValue.length)}let n=r.domSelection();if(!n)return;if(Wt(n)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),n.removeAllRanges(),n.addRange(s)}else n.extend&&n.extend(e,t);r.domObserver.setCurSelection();let{state:i}=r;setTimeout(()=>{r.state==i&&se(r)},50)}function gi(r,e){let t=r.state.doc.resolve(e);if(!(I||Bi)&&t.parent.inlineContent){let i=r.coordsAtPos(e);if(e>t.start()){let s=r.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=r.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(r.dom).direction=="rtl"?"rtl":"ltr"}function yi(r,e,t){let n=r.state.selection;if(n instanceof O&&!n.empty||t.indexOf("s")>-1||$&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=n;if(!i.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let o=En(r.state,e);if(o&&o instanceof b)return ae(r,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=n instanceof q?C.near(o,e):C.findFrom(o,e);return l?ae(r,l):!1}return!1}function Si(r,e){if(!(r.state.selection instanceof O))return!0;let{$head:t,$anchor:n,empty:i}=r.state.selection;if(!t.sameParent(n))return!0;if(!i)return!1;if(r.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=r.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),r.dispatch(o),!0}return!1}function xi(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function fl(r){if(!P||r.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;xi(r,n,"true"),setTimeout(()=>xi(r,n,"false"),20)}return!1}function hl(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function dl(r,e){let t=e.keyCode,n=hl(e);if(t==8||$&&t==72&&n=="c")return Si(r,-1)||Fe(r,-1);if(t==46&&!e.shiftKey||$&&t==68&&n=="c")return Si(r,1)||Fe(r,1);if(t==13||t==27)return!0;if(t==37||$&&t==66&&n=="c"){let i=t==37?gi(r,r.state.selection.from)=="ltr"?-1:1:-1;return mi(r,i,n)||Fe(r,i)}else if(t==39||$&&t==70&&n=="c"){let i=t==39?gi(r,r.state.selection.from)=="ltr"?1:-1:1;return mi(r,i,n)||Fe(r,i)}else{if(t==38||$&&t==80&&n=="c")return yi(r,-1,n)||Fe(r,-1);if(t==40||$&&t==78&&n=="c")return fl(r)||yi(r,1,n)||Fe(r,1);if(n==($?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function $n(r,e){r.someProp("transformCopied",p=>{e=p(e,r)});let t=[],{content:n,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&n.childCount==1&&n.firstChild.childCount==1;){i--,s--;let p=n.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),n=p.content}let o=r.someProp("clipboardSerializer")||ye.fromSchema(r.state.schema),l=Qi(),a=l.createElement("div");a.appendChild(o.serializeFragment(n,{document:l}));let c=a.firstChild,f,h=0;for(;c&&c.nodeType==1&&(f=Zi[c.nodeName.toLowerCase()]);){for(let p=f.length-1;p>=0;p--){let u=l.createElement(f[p]);for(;a.firstChild;)u.appendChild(a.firstChild);a.appendChild(u),h++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(t)}`);let d=r.someProp("clipboardTextSerializer",p=>p(e,r))||e.content.textBetween(0,e.content.size,`
8
-
9
- `);return{dom:a,text:d,slice:e}}function ji(r,e,t,n,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=!!e&&(n||s||!t);if(a){if(r.someProp("transformPastedText",d=>{e=d(e,s||n,r)}),s)return l=new S(y.from(r.state.schema.text(e.replace(/\r\n?/g,`
10
- `))),0,0),r.someProp("transformPasted",d=>{l=d(l,r,!0)}),l;let h=r.someProp("clipboardTextParser",d=>d(e,i,n,r));if(h)l=h;else{let d=i.marks(),{schema:p}=r.state,u=ye.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(u.serializeNode(p.text(m,d)))})}}else r.someProp("transformPastedHTML",h=>{t=h(t,r)}),o=gl(t),lt&&yl(o);let c=o&&o.querySelector("[data-pm-slice]"),f=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let h=+f[3];h>0;h--){let d=o.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;o=d}if(l||(l=(r.someProp("clipboardParser")||r.someProp("domParser")||$e.fromSchema(r.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||f),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!ul.test(d.parentNode.nodeName)?{ignore:!0}:null}})),f)l=Sl(bi(l,+f[1],+f[2]),f[4]);else if(l=S.maxOpen(pl(l.content,i),!0),l.openStart||l.openEnd){let h=0,d=0;for(let p=l.content.firstChild;h<l.openStart&&!p.type.spec.isolating;h++,p=p.firstChild);for(let p=l.content.lastChild;d<l.openEnd&&!p.type.spec.isolating;d++,p=p.lastChild);l=bi(l,h,d)}return r.someProp("transformPasted",h=>{l=h(l,r,a)}),l}var ul=/^(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 pl(r,e){if(r.childCount<2)return r;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(r.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&Yi(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Xi(o[o.length-1],s.length));let f=Gi(l,a);o.push(f),i=i.matchType(f.type),s=a}}),o)return y.from(o)}return r}function Gi(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,y.from(r));return r}function Yi(r,e,t,n,i){if(i<r.length&&i<e.length&&r[i]==e[i]){let s=Yi(r,e,t,n.lastChild,i+1);if(s)return n.copy(n.content.replaceChild(n.childCount-1,s));if(n.contentMatchAt(n.childCount).matchType(i==r.length-1?t.type:r[i+1]))return n.copy(n.content.append(y.from(Gi(t,r,i+1))))}}function Xi(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,Xi(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(y.empty,!0);return r.copy(t.append(n))}function Rn(r,e,t,n,i,s){let o=e<0?r.firstChild:r.lastChild,l=o.content;return r.childCount>1&&(s=0),i<n-1&&(l=Rn(l,e,t,n,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(y.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,o.copy(l))}function bi(r,e,t){return e<r.openStart&&(r=new S(Rn(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new S(Rn(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}var Zi={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 Qi(){return document.implementation.createHTMLDocument("title")}var gn=null;function ml(r){let e=window.trustedTypes;return e?(gn||(gn=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),gn.createHTML(r)):r}function gl(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=Qi(),n=t.body,i=/<([a-z][^>\s]+)/i.exec(r),s;if((s=i&&Zi[i[1].toLowerCase()])&&(r=s.map(o=>"<"+o+">").join("")+r+s.map(o=>"</"+o+">").reverse().join("")),n.innerHTML=ml(r),s)for(let o=0;o<s.length;o++)n=n.querySelector(s[o])||n;for(let o=0;o<t.styleSheets.length;o++){let l=t.styleSheets[o];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let f=n.querySelectorAll(c.selectorText);for(let h=0;h<f.length;h++)f[h].style.cssText+=c.style.cssText}}}return n}function yl(r){let e=r.querySelectorAll(I?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent=="\xA0"&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function Sl(r,e){if(!r.size)return r;let t=r.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return r}let{content:i,openStart:s,openEnd:o}=r;for(let l=n.length-2;l>=0;l-=2){let a=t.nodes[n[l]];if(!a||a.hasRequiredAttrs())break;i=y.from(a.create(n[l+1],i)),s++,o++}return new S(i,s,o)}var V={},L={},xl={touchstart:!0,touchmove:!0},In=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 bl(r){for(let e in V){let t=V[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{Cl(r,n)&&!Kn(r,n)&&(r.editable||!(n.type in L))&&t(r,n)},xl[e]?{passive:!0}:void 0)}P&&r.dom.addEventListener("input",()=>null),Bn(r)}function ie(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function kl(r){r.input.mouseDown&&r.input.mouseDown.done(),r.domObserver.stop();for(let e in r.input.eventHandlers)r.dom.removeEventListener(e,r.input.eventHandlers[e]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function Bn(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>Kn(r,n))})}function Kn(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function Cl(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=r.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Nl(r,e){!Kn(r,e)&&V[e.type]&&(r.editable||!(e.type in L))&&V[e.type](r,e)}L.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!ts(r)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(re&&I&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),We&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",i=>i(r,be(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||dl(r,t)?t.preventDefault():ie(r,"key")};L.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)};L.keypress=(r,e)=>{let t=e;if(ts(r)||!t.charCode||t.ctrlKey&&!t.altKey||$&&t.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof O)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode),s=()=>r.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",o=>o(r,n.$from.pos,n.$to.pos,i,s))&&r.dispatch(s()),t.preventDefault()}};function at(r){return{left:r.clientX,top:r.clientY}}function Ol(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function Hn(r,e,t,n,i){if(n==-1)return!1;let s=r.state.doc.resolve(n);for(let o=s.depth+1;o>0;o--)if(r.someProp(e,l=>o>s.depth?l(r,t,s.nodeAfter,s.before(o),i,!0):l(r,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function ct(r,e,t){if(r.focused||r.focus(),r.state.selection.eq(e))return;let n=r.state.tr.setSelection(e);t=="pointer"&&n.setMeta("pointer",!0),r.dispatch(n)}function Ml(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&b.isSelectable(n)?(ct(r,new b(t),"pointer"),!0):!1}function Tl(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof b&&(n=t.node);let s=r.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(b.isSelectable(l)){n&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(ct(r,b.create(r.state.doc,i),"pointer"),!0):!1}function Dl(r,e,t,n,i){return Hn(r,"handleClickOn",e,t,n)||r.someProp("handleClick",s=>s(r,e,n))||(i?Tl(r,t):Ml(r,t))}function wl(r,e,t,n){return Hn(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function El(r,e,t,n){return Hn(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||Al(r,t,n)}function Al(r,e,t){if(t.button!=0)return!1;let n=_i(r,e,!0),i=r.state.doc;return n?(ct(r,n,"pointer"),n instanceof O&&i.eq(r.state.doc)&&(r.input.mouseDown=new Pn(r,n)),!0):!1}function _i(r,e,t){let n=r.state.doc;if(e==-1)return n.inlineContent?O.create(n,0,n.content.size):null;let i=n.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)return O.create(n,l+1,l+1+o.content.size);if(t&&b.isSelectable(o))return b.create(n,l)}return null}function Un(r){return zt(r)}var es=$?"metaKey":"ctrlKey";V.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=Un(r),i=Date.now(),s="singleClick";i-r.input.lastClick.time<500&&Ol(t,r.input.lastClick)&&!t[es]&&r.input.lastClick.button==t.button&&(r.input.lastClick.type=="singleClick"?s="doubleClick":r.input.lastClick.type=="doubleClick"&&(s="tripleClick")),r.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s,button:t.button},r.input.mouseDown&&r.input.mouseDown.done();let o=r.posAtCoords(at(t));o&&(s=="singleClick"?r.input.mouseDown=new zn(r,o,t,!!n):(s=="doubleClick"?wl:El)(r,o.pos,o.inside,t)?t.preventDefault():ie(r,"pointer"))};var Bt=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}},zn=class extends Bt{constructor(e,t,n,i){super(e),this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[es],this.allowDefault=n.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let f=e.state.doc.resolve(t.pos);s=f.parent,o=f.depth?f.before():0}let l=i?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof b&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&H&&!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()),ie(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||se(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(at(e))),this.updateAllowDefault(e),this.allowDefault||!t?ie(this.view,"pointer"):Dl(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||P&&this.mightDrag&&!this.mightDrag.node.isAtom||I&&!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)?(ct(this.view,C.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):ie(this.view,"pointer")}move(e){this.updateAllowDefault(e),ie(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}},Pn=class extends Bt{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(),ie(this.view,"pointer");let t=this.view.posAtCoords(at(e)),n=t&&_i(this.view,t.inside,!1);if(!n)return;let{doc:i}=this.view.state,s=this.startSelection,[o,l]=n.from<s.from?[s.to,n.from]:[s.from,n.to];ct(this.view,O.create(i,o,l),"pointer")}};V.touchstart=r=>{r.input.lastTouch=Date.now(),Un(r),ie(r,"pointer")};V.touchmove=r=>{r.input.lastTouch=Date.now(),ie(r,"pointer")};V.contextmenu=r=>Un(r);function ts(r,e){return r.composing?!0:P&&Math.abs(Date.now()-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}var Rl=re?5e3:-1;L.compositionstart=L.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$to;if(e.selection instanceof O&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||I&&Bi&&Il(r)))r.markCursor=r.state.storedMarks||t.marks(),zt(r,!0),r.markCursor=null;else if(zt(r,!e.selection.empty),H&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=r.domSelectionRange();for(let i=n.focusNode,s=n.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=r.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}r.input.composing=!0}ns(r,Rl)};function Il(r){let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let n=e.childNodes[t];return n.nodeType==1&&n.contentEditable=="false"}L.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Date.now(),r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionNode=null,r.input.badSafariComposition?r.domObserver.forceFlush():r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,ns(r,20))};function ns(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>zt(r),e))}function rs(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Date.now());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function Bl(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=Ao(e.focusNode,e.focusOffset),n=Ro(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let i=n.pmViewDesc,s=r.domObserver.lastChangedTextNode;if(t==s||n==s)return s;if(!i||!i.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return n}}return t||n}function zt(r,e=!1){if(!(re&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),rs(r),e||r.docView&&r.docView.dirty){let t=vn(r),n=r.state.selection;return t&&!t.eq(n)?r.dispatch(r.state.tr.setSelection(t)):(r.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?r.dispatch(r.state.tr.deleteSelection()):r.updateState(r.state),!0}return!1}}function zl(r,e){if(!r.dom.parentNode)return;let t=r.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(e),r.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),r.focus()},50)}var rt=J&&ce<15||We&&Po<604;V.copy=L.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let s=rt?null:t.clipboardData,o=n.content(),{dom:l,text:a}=$n(r,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):zl(r,l),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Pl(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function Fl(r,e){if(!r.dom.parentNode)return;let t=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let i=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?it(r,n.value,null,i,e):it(r,n.textContent,n.innerHTML,i,e)},50)}function it(r,e,t,n,i){let s=ji(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",a=>a(r,i,s||S.empty)))return!0;if(!s)return!1;let o=Pl(s),l=o?r.state.tr.replaceSelectionWith(o,n):r.state.tr.replaceSelection(s);return r.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function is(r){let e=r.getData("text/plain")||r.getData("Text");if(e)return e;let t=r.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}L.paste=(r,e)=>{let t=e;if(r.composing&&!re)return;let n=rt?null:t.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&it(r,is(n),n.getData("text/html"),i,t)?t.preventDefault():Fl(r,t)};var Pt=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Vl=$?"altKey":"ctrlKey";function ss(r,e){let t;return r.someProp("dragCopies",n=>{t=t||n(e)}),t!=null?!t:!e[Vl]}V.dragstart=(r,e)=>{let t=e,n=r.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let i=r.state.selection,s=i.empty?null:r.posAtCoords(at(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof b?i.to-1:i.to))){if(n&&n.mightDrag)o=b.create(r.state.doc,n.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let h=r.docView.nearestDesc(t.target,!0);h&&h.node.type.spec.draggable&&h!=r.docView&&(o=b.create(r.state.doc,h.posBefore))}}let l=(o||r.state.selection).content(),{dom:a,text:c,slice:f}=$n(r,l);(!t.dataTransfer.files.length||!I||Ii>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(rt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",rt||t.dataTransfer.setData("text/plain",c),r.dragging=new Pt(f,ss(r,t),o)};V.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)};L.dragover=L.dragenter=(r,e)=>e.preventDefault();L.drop=(r,e)=>{try{Ll(r,e,r.dragging)}finally{r.dragging=null}};function Ll(r,e,t){if(!e.dataTransfer)return;let n=r.posAtCoords(at(e));if(!n)return;let i=r.state.doc.resolve(n.pos),s=t&&t.slice;s?r.someProp("transformPasted",p=>{s=p(s,r,!1)}):s=ji(r,is(e.dataTransfer),rt?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&ss(r,e));if(r.someProp("handleDrop",p=>p(r,e,s||S.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Ir(r.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=r.state.tr;if(o){let{node:p}=t;p?p.replace(a):a.deleteSelection()}let c=a.mapping.map(l),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,h=a.doc;if(f?a.replaceRangeWith(c,c,s.content.firstChild):a.replaceRange(c,c,s),a.doc.eq(h))return;let d=a.doc.resolve(c);if(f&&b.isSelectable(s.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new b(d));else{let p=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((u,m,g,x)=>p=x),a.setSelection(qn(r,d,a.doc.resolve(p)))}r.focus(),r.dispatch(a.setMeta("uiEvent","drop"))}V.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&se(r)},20))};V.blur=(r,e)=>{let t=e;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),t.relatedTarget&&r.dom.contains(t.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)};V.beforeinput=(r,e)=>{if(re&&e.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",s=>s(r,be(8,"Backspace")))))return;let{$cursor:i}=r.state.selection;i&&i.pos>0&&r.dispatch(r.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let r in L)V[r]=L[r];function st(r,e){if(r==e)return!0;for(let t in r)if(r[t]!==e[t])return!1;for(let t in e)if(!(t in r))return!1;return!0}var Ft=class r{constructor(e,t){this.toDOM=e,this.spec=t||Me,this.side=this.spec.side||0}map(e,t,n,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new he(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof r&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&st(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Oe=class r{constructor(e,t){this.attrs=e,this.spec=t||Me}map(e,t,n,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return s>=o?null:new he(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof r&&st(this.attrs,e.attrs)&&st(this.spec,e.spec)}static is(e){return e.type instanceof r}destroy(){}},Fn=class r{constructor(e,t){this.attrs=e,this.spec=t||Me}map(e,t,n,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new he(s.pos-n,o.pos-n,this)}valid(e,t){let{index:n,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(n)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof r&&st(this.attrs,e.attrs)&&st(this.spec,e.spec)}destroy(){}},he=class r{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new r(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new r(e,e,new Ft(t,n))}static inline(e,t,n,i){return new r(e,t,new Oe(n,i))}static node(e,t,n,i){return new r(e,t,new Fn(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Oe}get widget(){return this.type instanceof Ft}},Ve=[],Me={},j=class r{constructor(e,t){this.local=e.length?e:Ve,this.children=t.length?t:Ve}static create(e,t){return t.length?Lt(t,e,0,Me):z}find(e,t,n){let i=[];return this.findInner(e??0,t??1e9,i,0,n),i}findInner(e,t,n,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&n.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,n,i+l,s)}}map(e,t,n){return this==z||e.maps.length==0?this:this.mapInner(e,t,0,0,n||Me)}mapInner(e,t,n,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,n,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Wl(this.children,o||[],e,t,n,i,s):o?new r(o.sort(Te),Ve):z}add(e,t){return t.length?this==z?r.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let i,s=0;e.forEach((l,a)=>{let c=a+n,f;if(f=as(t,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,f,c+1):i.splice(s,0,a,a+l.nodeSize,Lt(f,l,c+1,Me)),s+=3}});let o=ls(s?cs(t):t,-n);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new r(o.length?this.local.concat(o).sort(Te):this.local,i||this.children)}remove(e){return e.length==0||this==z?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,i=this.local;for(let s=0;s<n.length;s+=3){let o,l=n[s]+t,a=n[s+1]+t;for(let f=0,h;f<e.length;f++)(h=e[f])&&h.from>l&&h.to<a&&(e[f]=null,(o||(o=[])).push(h));if(!o)continue;n==this.children&&(n=this.children.slice());let c=n[s+2].removeInner(o,l+1);c!=z?n[s+2]=c:(n.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return n==this.children&&i==this.local?this:i.length||n.length?new r(i,n):z}forChild(e,t){if(this==z)return this;if(t.isLeaf)return r.empty;let n,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(n=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof Oe){let c=Math.max(s,a.from)-s,f=Math.min(o,a.to)-s;c<f&&(i||(i=[])).push(a.copy(c,f))}}if(i){let l=new r(i.sort(Te),Ve);return n?new Vt([l,n]):l}return n||z}eq(e){if(this==e)return!0;if(!(e instanceof r)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return jn(this.localsInner(e))}localsInner(e){if(this==z)return Ve;if(e.inlineContent||!this.local.some(Oe.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof Oe||t.push(this.local[n]);return t}forEachSet(e){e(this)}};j.empty=new j([],[]);j.removeOverlap=jn;var z=j.empty,Vt=class r{constructor(e){this.members=e}map(e,t){let n=this.members.map(i=>i.map(e,t,Me));return r.from(n)}forChild(e,t){if(t.isLeaf)return j.empty;let n=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=z&&(s instanceof r?n=n.concat(s.members):n.push(s))}return r.from(n)}eq(e){if(!(e instanceof r)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{n&&(t=t.slice(),n=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?jn(n?t:t.sort(Te)):Ve}static from(e){switch(e.length){case 0:return z;case 1:return e[0];default:return new r(e.every(t=>t instanceof j)?e:e.reduce((t,n)=>t.concat(n instanceof j?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Wl(r,e,t,n,i,s,o){let l=r.slice();for(let c=0,f=s;c<t.maps.length;c++){let h=0;t.maps[c].forEach((d,p,u,m)=>{let g=m-u-(p-d);for(let x=0;x<l.length;x+=3){let T=l[x+1];if(T<0||d>T+f-h)continue;let M=l[x]+f-h;p>=M?l[x+1]=d<=M?-2:-1:d>=f&&g&&(l[x]+=g,l[x+1]+=g)}h+=g}),f=t.maps[c].map(f,-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 f=t.map(r[c]+s),h=f-i;if(h<0||h>=n.content.size){a=!0;continue}let d=t.map(r[c+1]+s,-1),p=d-i,{index:u,offset:m}=n.content.findIndex(h),g=n.maybeChild(u);if(g&&m==h&&m+g.nodeSize==p){let x=l[c+2].mapInner(t,g,f+1,r[c]+s+1,o);x!=z?(l[c]=h,l[c+1]=p,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Jl(l,r,e,t,i,s,o),f=Lt(c,n,0,o);e=f.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,d=0;h<f.children.length;h+=3){let p=f.children[h];for(;d<l.length&&l[d]<p;)d+=3;l.splice(d,0,f.children[h],f.children[h+1],f.children[h+2])}}return new j(e.sort(Te),l)}function ls(r,e){if(!e||!r.length)return r;let t=[];for(let n=0;n<r.length;n++){let i=r[n];t.push(new he(i.from+e,i.to+e,i.type))}return t}function Jl(r,e,t,n,i,s,o){function l(a,c){for(let f=0;f<a.local.length;f++){let h=a.local[f].map(n,i,c);h?t.push(h):o.onRemove&&o.onRemove(a.local[f].spec)}for(let f=0;f<a.children.length;f+=3)l(a.children[f+2],a.children[f]+c+1)}for(let a=0;a<r.length;a+=3)r[a+1]==-1&&l(r[a+2],e[a]+s+1);return t}function as(r,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,i=null;for(let s=0,o;s<r.length;s++)(o=r[s])&&o.from>t&&o.to<n&&((i||(i=[])).push(o),r[s]=null);return i}function cs(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function Lt(r,e,t,n){let i=[],s=!1;e.forEach((l,a)=>{let c=as(r,l,a+t);if(c){s=!0;let f=Lt(c,l,t+a+1,n);f!=z&&i.push(a,a+l.nodeSize,f)}});let o=ls(s?cs(r):r,-t).sort(Te);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(n.onRemove&&n.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new j(o,i):z}function Te(r,e){return r.from-e.from||r.to-e.to}function jn(r){let e=r;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==n.from){s.to!=n.to&&(e==r&&(e=r.slice()),e[i]=s.copy(s.from,n.to),ki(e,i+1,s.copy(n.to,s.to)));continue}else{s.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,s.from),ki(e,i,n.copy(s.from,n.to)));break}}}return e}function ki(r,e,t){for(;e<r.length&&Te(t,r[e])>0;)e++;r.splice(e,0,t)}function yn(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=z&&e.push(n)}),r.cursorWrapper&&e.push(j.create(r.state.doc,[r.cursorWrapper.deco])),Vt.from(e)}var vl={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ql=J&&ce<=11,Vn=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}},Ln=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Vn,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);J&&ce<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():P&&e.composing&&n.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),ql&&(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,vl)),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(pi(this.view)){if(this.suppressingSelectionUpdates)return se(this.view);if(J&&ce<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&De(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 s=e.focusNode;s;s=Le(s))t.add(s);for(let s=e.anchorNode;s;s=Le(s))if(t.has(s)){n=s;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&pi(e)&&!this.ignoreSelectionChange(n),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let f=0;f<t.length;f++){let h=this.registerMutation(t[f],a);h&&(s=s<0?h.from:Math.min(h.from,s),o=o<0?h.to:Math.max(h.to,o),h.typeOver&&(l=!0))}if(a.some(f=>f.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||I&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(f=>f.type=="childList"&&f.removedNodes.length))){for(let f of a)if(f.nodeName=="BR"&&f.parentNode){let h=f.nextSibling;for(;h&&h.nodeType==1;){if(h.contentEditable=="false"){f.parentNode.removeChild(f);break}h=h.firstChild}}}else if(H&&a.length){let f=a.filter(h=>h.nodeName=="BR");if(f.length==2){let[h,d]=f;h.parentNode&&h.parentNode.parentNode==d.parentNode?d.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let d of f){let p=d.parentNode;p&&p.nodeName=="LI"&&(!h||Hl(e,h)!=p)&&d.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Wt(n)&&(c=vn(e))&&c.eq(C.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,se(e),this.currentSelection.set(n),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),$l(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Ul(e,a)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||se(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 f=0;f<e.addedNodes.length;f++){let h=e.addedNodes[f];t.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,s=e.nextSibling;if(J&&ce<=11&&e.addedNodes.length)for(let f=0;f<e.addedNodes.length;f++){let{previousSibling:h,nextSibling:d}=e.addedNodes[f];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d)}let o=i&&i.parentNode==e.target?R(i)+1:0,l=n.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?R(s):e.target.childNodes.length,c=n.localPosFromDOM(e.target,a,1);return{from:l,to:c}}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})}},Ci=new WeakMap,Ni=!1;function $l(r){if(!Ci.has(r)&&(Ci.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=H,Ni)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."),Ni=!0}}function Oi(r,e){let t=e.startContainer,n=e.startOffset,i=e.endContainer,s=e.endOffset,o=r.domAtPos(r.state.selection.anchor);return De(o.node,o.offset,i,s)&&([t,n,i,s]=[i,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:s}}function Kl(r,e){if(e.getComposedRanges){let i=e.getComposedRanges(r.root)[0];if(i)return Oi(r,i)}let t;function n(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),t?Oi(r,t):null}function Hl(r,e){for(let t=e.parentNode;t&&t!=r.dom;t=t.parentNode){let n=r.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function Ul(r,e){var t;let{focusNode:n,focusOffset:i}=r.domSelectionRange();for(let s of e)if(((t=s.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),n==s&&r.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function jl(r,e,t,n){let{node:i,fromOffset:s,toOffset:o,from:l,to:a}=r.docView.parseRange(e,t),c=r.domSelectionRange(),f,h=c.anchorNode;if(h&&r.dom.contains(h.nodeType==1?h:h.parentNode)&&(f=[{node:h,offset:c.anchorOffset}],Wt(c)||f.push({node:c.focusNode,offset:c.focusOffset})),I&&r.input.lastKeyCode===8)for(let x=o;x>s;x--){let T=i.childNodes[x-1],M=T.pmViewDesc;if(T.nodeName=="BR"&&!M){o=x;break}if(!M||M.size)break}let d=r.state.doc,p=r.someProp("domParser")||$e.fromSchema(r.state.schema),u=d.resolve(l),m=null,g=p.parse(i,{topNode:u.parent,topMatch:u.parent.contentMatchAt(u.index()),topOpen:!0,from:s,to:o,preserveWhitespace:u.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:Gl(n),context:u});if(f&&f[0].pos!=null){let x=f[0].pos,T=f[1]&&f[1].pos;T==null&&(T=x),m={anchor:x+l,head:T+l}}return{doc:g,sel:m,from:l,to:a}}var Gl=r=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(r);if(e.nodeName=="BR"&&e.parentNode){if(P&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(e.parentNode.lastChild==e||P&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},Yl=/^(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 Xl(r,e,t,n,i){let s=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let k=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,w=vn(r,k);if(w&&!r.state.selection.eq(w)){if(I&&re&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",fs=>fs(r,be(13,"Enter"))))return;let W=r.state.tr.setSelection(w);k=="pointer"?W.setMeta("pointer",!0):k=="key"&&W.scrollIntoView(),s&&W.setMeta("composition",s),r.dispatch(W)}return}let o=r.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=r.state.doc.resolve(t).after(l+1);let a=r.state.selection,c=jl(r,e,t,i),f=r.state.doc,h=f.slice(c.from,c.to),d,p;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(d=r.state.selection.to,p="end"):(d=r.state.selection.from,p="start"),r.input.lastKeyCode=null;let u=_l(h.content,c.doc.content,c.from,d,p);if(u&&r.input.domChangeCount++,(We&&r.input.lastIOSEnter>Date.now()-225||re)&&i.some(k=>k.nodeType==1&&!Yl.test(k.nodeName))&&(!u||u.endA>=u.endB)&&r.someProp("handleKeyDown",k=>k(r,be(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!u)if(n&&a instanceof O&&!a.empty&&a.$head.sameParent(a.$anchor)&&!r.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))u={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let k=Mi(r,r.state.doc,c.sel);if(k&&!k.eq(r.state.selection)){let w=r.state.tr.setSelection(k);s&&w.setMeta("composition",s),r.dispatch(w)}}return}r.state.selection.from<r.state.selection.to&&u.start==u.endB&&r.state.selection instanceof O&&(u.start>r.state.selection.from&&u.start<=r.state.selection.from+2&&r.state.selection.from>=c.from?u.start=r.state.selection.from:u.endA<r.state.selection.to&&u.endA>=r.state.selection.to-2&&r.state.selection.to<=c.to&&(u.endB+=r.state.selection.to-u.endA,u.endA=r.state.selection.to)),J&&ce<=11&&u.endB==u.start+1&&u.endA==u.start&&u.start>c.from&&c.doc.textBetween(u.start-c.from-1,u.start-c.from+1)==" \xA0"&&(u.start--,u.endA--,u.endB--);let m=c.doc.resolveNoCache(u.start-c.from),g=c.doc.resolveNoCache(u.endB-c.from),x=f.resolve(u.start),T=m.sameParent(g)&&m.parent.inlineContent&&x.end()>=u.endA;if((We&&r.input.lastIOSEnter>Date.now()-225&&(!T||i.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!T&&m.pos<c.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(c.doc.textBetween(m.pos,g.pos,"","")))&&r.someProp("handleKeyDown",k=>k(r,be(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>u.start&&Ql(f,u.start,u.endA,m,g)&&r.someProp("handleKeyDown",k=>k(r,be(8,"Backspace")))){re&&I&&r.domObserver.suppressSelectionUpdates();return}I&&u.endB==u.start&&(r.input.lastChromeDelete=Date.now()),re&&!T&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==u.endA&&(u.endB-=2,g=c.doc.resolveNoCache(u.endB-c.from),setTimeout(()=>{r.someProp("handleKeyDown",function(k){return k(r,be(13,"Enter"))})},20));let M=u.start,Y=u.endA,ue=k=>{let w=k||r.state.tr.replace(M,Y,c.doc.slice(u.start-c.from,u.endB-c.from));if(c.sel){let W=Mi(r,w.doc,c.sel);W&&!(I&&r.composing&&W.empty&&(u.start!=u.endB||r.input.lastChromeDelete<Date.now()-100)&&(W.head==M||W.head==w.mapping.map(Y)-1)||J&&W.empty&&W.head==M)&&w.setSelection(W)}return s&&w.setMeta("composition",s),w.scrollIntoView()},ft;if(T)if(m.pos==g.pos){J&&ce<=11&&m.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>se(r),20));let k=ue(r.state.tr.delete(M,Y)),w=f.resolve(u.start).marksAcross(f.resolve(u.endA));w&&k.ensureMarks(w),r.dispatch(k)}else if(u.endA==u.endB&&(ft=Zl(m.parent.content.cut(m.parentOffset,g.parentOffset),x.parent.content.cut(x.parentOffset,u.endA-x.start())))){let k=ue(r.state.tr);ft.type=="add"?k.addMark(M,Y,ft.mark):k.removeMark(M,Y,ft.mark),r.dispatch(k)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let k=m.parent.textBetween(m.parentOffset,g.parentOffset),w=()=>ue(r.state.tr.insertText(k,M,Y));r.someProp("handleTextInput",W=>W(r,M,Y,k,w))||r.dispatch(w())}else r.dispatch(ue());else r.dispatch(ue())}function Mi(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:qn(r,e.resolve(t.anchor),e.resolve(t.head))}function Zl(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,i=t,s=n,o,l,a;for(let f=0;f<n.length;f++)i=n[f].removeFromSet(i);for(let f=0;f<t.length;f++)s=t[f].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=f=>f.mark(l.addToSet(f.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=f=>f.mark(l.removeFromSet(f.marks));else return null;let c=[];for(let f=0;f<e.childCount;f++)c.push(a(e.child(f)));if(y.from(c).eq(r))return{mark:l,type:o}}function Ql(r,e,t,n,i){if(t-e<=i.pos-n.pos||Sn(n,!0,!1)<i.pos)return!1;let s=r.resolve(e);if(!n.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=r.resolve(Sn(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Sn(o,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(o.parent.content)}function Sn(r,e,t){let n=r.depth,i=e?r.end():r.pos;for(;n>0&&(e||r.indexAfter(n)==r.node(n).childCount);)n--,i++,e=!1;if(t){let s=r.node(n).maybeChild(r.indexAfter(n));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function _l(r,e,t,n,i){let s=r.findDiffStart(e,t),o=t+r.size,l=t+e.size;if(s==null)return null;let{a,b:c}=r.findDiffEnd(e,o,l);if(i=="end"){let f=Math.max(0,s-Math.min(a,c));n-=a+f-s}if(a<s&&o<l){let f=n<=s&&n>=a?s-n:0;s-=f,c=s+(c-a),a=s}else if(c<s){let f=n<=s&&n>=c?s-n:0;s-=f,a=s+(a-c),c=s}return{start:s,endA:a,endB:c}}var Wn=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 In,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ai),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=wi(this),Di(this),this.nodeViews=Ei(this),this.docView=ai(this.state.doc,Ti(this),yn(this),this.dom,this),this.domObserver=new Ln(this,(n,i,s,o)=>Xl(this,n,i,s,o)),this.domObserver.start(),bl(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&&Bn(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ai),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 i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(rs(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Ei(this);ta(p,this.nodeViews)&&(this.nodeViews=p,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Bn(this),this.editable=wi(this),Di(this);let a=yn(this),c=Ti(this),f=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,c,a);(h||!e.selection.eq(i.selection))&&(o=!0);let d=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Lo(this);if(o){this.domObserver.stop();let p=h&&(J||I)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&ea(i.selection,e.selection);if(h){let m=I?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Bl(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=ai(e.doc,c,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}let u=this.input.mouseDown;p||!(u&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&sl(this)&&u.delaySelUpdate())?se(this,p):(Ki(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((n=this.dragging)===null||n===void 0)&&n.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():d&&Wo(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof b){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ri(this,t.getBoundingClientRect(),e)}else ri(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,i=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{let s=n.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&s<this.state.doc.content.size&&this.state.doc.nodeAt(s))==n.node&&(i=s)}this.dragging=new Pt(e.slice,e.move,i<0?void 0:b.create(this.state.doc,i))}someProp(e,t){let n=this._props&&this._props[e],i;if(n!=null&&(i=t?t(n):n))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(J){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&&Jo(this.dom),se(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 Ho(this,e)}coordsAtPos(e,t=1){return Li(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 i=this.docView.posFromDOM(e,t,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Xo(this,t||this.state,e)}pasteHTML(e,t){return it(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return it(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return $n(this,e)}destroy(){this.docView&&(kl(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],yn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,wo())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Nl(this,e)}domSelectionRange(){let e=this.domSelection();return e?P&&this.root.nodeType===11&&Bo(this.dom.ownerDocument)==this.dom&&Kl(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Wn.prototype.dispatch=function(r){let e=this._props.dispatchTransaction;e?e.call(this,r):this.updateState(this.state.apply(r))};function Ti(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),r.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(r.state)),t)for(let n in t)n=="class"?e.class+=" "+t[n]:n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),e.translate||(e.translate="no"),[he.node(0,r.state.doc.content.size,e)]}function Di(r){if(r.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),r.cursorWrapper={dom:e,deco:he.widget(r.state.selection.from,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function wi(r){return!r.someProp("editable",e=>e(r.state)===!1)}function ea(r,e){let t=Math.min(r.$anchor.sharedDepth(r.head),e.$anchor.sharedDepth(e.head));return r.$anchor.start(t)!=e.$anchor.start(t)}function Ei(r){let e=Object.create(null);function t(n){for(let i in n)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=n[i])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function ta(r,e){let t=0,n=0;for(let i in r){if(r[i]!=e[i])return!0;t++}for(let i in e)n++;return t!=n}function Ai(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}export{y as a,N as b,S as c,Kt as d,X as e,Zn as f,$e as g,ye as h,Qt as i,Ge as j,F as k,v as l,Xe as m,Er as n,Ze as o,rn as p,Ct as q,C as r,Be as s,O as t,b as u,q as v,$r as w,Mt as x,Kr as y,Gr as z,to as A,ma as B,ro as C,ga as D,ao as E,ya as F,Sa as G,xa as H,dn as I,ba as J,Ma as K,Do as L,he as M,j as N,Wn as O};
@@ -1 +0,0 @@
1
- import{Ia as k,U as d,V as f,W as y,b as C,ba as T,c as $,da as p,f as A,fa as g,ga as w,ha as h,ka as R,la as m,na as O,qa as b,sa as M}from"./chunk-P3WV3MLS.js";var V=r=>crypto.getRandomValues(new Uint8Array(r)),I=(r,a,t)=>{let n=256-256%r.length;if(n===256){let o=r.length-1;return(s=a)=>{if(!s)return"";let i="";for(;;){let c=t(s),u=s;for(;u--;)if(i+=r[c[u]&o],i.length>=s)return i}}}let e=Math.ceil(1.6*256*a/n);return(o=a)=>{if(!o)return"";let s="";for(;;){let i=t(e),c=e;for(;c--;)if(i[c]<n&&(s+=r[i[c]%r.length],s.length>=o))return s}}},j=(r,a=21)=>I(r,a|0,V);var oe=j("abcedfghicklmn",10);function P(r,a,t){let n=r.findIndex(([o])=>o===a);if(n===-1)return[...r,t];let e=r.slice();return e[n]=t,e}function ae(r,a){let t=R(r),n=e=>async()=>{n.key=t,await e.wait(O);let o=a(e);return e.get(m).create(t,o),n.run=s=>e.get(m).call(r,s),()=>{e.get(m).remove(t)}};return n}function se(r){let a=t=>async()=>{await t.wait(p);let n=r(t);return t.update(d,e=>[...e,n]),a.inputRule=n,()=>{t.update(d,e=>e.filter(o=>o!==n))}};return a}function ie(r){let a=t=>async()=>{await t.wait(p);let n=r(t);return t.update(k,e=>[...e,n]),a.pasteRule=n,()=>{t.update(k,e=>e.filter(o=>o!==n))}};return a}function N(r,a){let t=n=>async()=>{let e=a(n);return n.update(h,o=>P(o,r,[r,e])),t.id=r,t.schema=e,()=>{n.update(h,o=>o.filter(([s])=>s!==r))}};return t.type=n=>{let e=n.get(g).marks[r];if(!e)throw $(r);return e},t}function D(r,a){let t=n=>async()=>{let e=a(n);return n.update(w,o=>P(o,r,[r,e])),t.id=r,t.schema=e,()=>{n.update(w,o=>o.filter(([s])=>s!==r))}};return t.type=n=>{let e=n.get(g).nodes[r];if(!e)throw C(r);return e},t}function ce(r){let a,t=n=>async()=>(await n.wait(p),a=r(n),n.update(f,e=>[...e,a]),()=>{n.update(f,e=>e.filter(o=>o!==a))});return t.plugin=()=>a,t.key=()=>a.spec.key,t}function F(r){let a=t=>async()=>{await t.wait(M);let n=t.get(b),e=r(t),o=n.addObjectKeymap(e);return a.keymap=e,()=>{o()}};return a}function l(r,a){let t=A(r,a),n=e=>(e.inject(t),()=>()=>{e.remove(t)});return n.key=t,n}function U(r,a){let t=l(a,r),n=D(r,o=>o.get(t.key)(o)),e=[t,n];return e.id=n.id,e.node=n,e.type=o=>n.type(o),e.ctx=t,e.key=t.key,e.extendSchema=o=>U(r,o(a)),e}function B(r,a){let t=l(a,r),n=N(r,o=>o.get(t.key)(o)),e=[t,n];return e.id=n.id,e.mark=n,e.type=o=>n.type(o),e.ctx=t,e.key=t.key,e.extendSchema=o=>B(r,o(a)),e}function ue(r,a){let t=l(Object.fromEntries(Object.entries(a).map(([o,{shortcuts:s,priority:i}])=>[o,{shortcuts:s,priority:i}])),`${r}Keymap`),n=F(o=>{let s=o.get(t.key),i=Object.entries(a).flatMap(([c,{command:u}])=>{let S=s[c],E=[S.shortcuts].flat(),K=S.priority;return E.map(v=>[v,{key:v,onRun:u,priority:K}])});return Object.fromEntries(i)}),e=[t,n];return e.ctx=t,e.shortcuts=n,e.key=t.key,e.keymap=n.keymap,e}var le=(r,a=()=>({}))=>l(a,`${r}Attr`),pe=(r,a=()=>({}))=>l(a,`${r}Attr`);function me(r,a,t){let n=l(t??{},r),e=s=>async()=>{await s.wait(T);let i={plugin:a(s),options:s.get(n.key)};return s.update(y,c=>[...c,i]),()=>{s.update(y,c=>c.filter(u=>u!==i))}},o=[n,e];return o.id=r,o.plugin=e,o.options=n,o}export{ae as a,se as b,ie as c,D as d,ce as e,F as f,l as g,U as h,B as i,ue as j,le as k,pe as l,me as m};
@@ -1 +0,0 @@
1
- import{i as A,x,y as C}from"./chunk-EAFZBBCI.js";var y=200,u=function(){};u.prototype.append=function(e){return e.length?(e=u.from(e),!this.length&&e||e.length<y&&this.leafAppend(e)||this.length<y&&e.leafPrepend(this)||this.appendInner(e)):this};u.prototype.prepend=function(e){return e.length?u.from(e).append(this):this};u.prototype.appendInner=function(e){return new L(this,e)};u.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?u.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};u.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};u.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)};u.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(s,p){return i.push(e(s,p))},t,n),i};u.from=function(e){return e instanceof u?e:e&&e.length?new D(e):u.empty};var D=(function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,p,l){for(var a=s;a<p;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,p,l){for(var a=s-1;a>=p;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=y)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=y)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(u);u.empty=new D([]);var L=(function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,i,s,p){var l=this.left.length;if(i<l&&this.left.forEachInner(n,i,Math.min(s,l),p)===!1||s>l&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,s)-l,p+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,s,p){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(s,l)-l,p+l)===!1||s<l&&this.left.forEachInvertedInner(n,Math.min(i,l),s,p)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(n,i):n>=s?this.right.slice(n-s,i-s):this.left.slice(n,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new e(i,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e})(u),T=u;var j=500,w=class r{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,s;t&&(i=this.remapping(n,this.items.length),s=i.maps.length);let p=e.tr,l,a,h=[],c=[];return this.items.forEach((o,f)=>{if(!o.step){i||(i=this.remapping(n,f+1),s=i.maps.length),s--,c.push(o);return}if(i){c.push(new g(o.map));let d=o.step.map(i.slice(s)),v;d&&p.maybeStep(d).doc&&(v=p.mapping.maps[p.mapping.maps.length-1],h.push(new g(v,void 0,void 0,h.length+c.length))),s--,v&&i.appendMap(v,s)}else p.maybeStep(o.step);if(o.selection)return l=i?o.selection.map(i.slice(s)):o.selection,a=new r(this.items.slice(0,n).append(c.reverse().concat(h)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:p,selection:l}}addTransform(e,t,n,i){let s=[],p=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let c=0;c<e.steps.length;c++){let o=e.steps[c].invert(e.docs[c]),f=new g(e.mapping.maps[c],o,t),d;(d=a&&a.merge(f))&&(f=d,c?s.pop():l=l.slice(0,l.length-1)),s.push(f),t&&(p++,t=void 0),i||(a=f)}let h=p-n.depth;return h>G&&(l=F(l,h),p-=h),new r(l.append(s),p)}remapping(e,t){let n=new A;return this.items.forEach((i,s)=>{let p=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,p)},e,t),n}addMaps(e){return this.eventCount==0?this:new r(this.items.append(e.map(t=>new g(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),s=e.mapping,p=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=t;this.items.forEach(f=>{let d=s.getMirror(--a);if(d==null)return;p=Math.min(p,d);let v=s.maps[d];if(f.step){let H=e.steps[d].invert(e.docs[d]),O=f.selection&&f.selection.map(s.slice(a+1,d));O&&l++,n.push(new g(v,H,O))}else n.push(new g(v))},i);let h=[];for(let f=t;f<p;f++)h.push(new g(s.maps[f]));let c=this.items.slice(0,i).append(h).append(n),o=new r(c,l);return o.emptyItemCount()>j&&(o=o.compress(this.items.length-n.length)),o}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],s=0;return this.items.forEach((p,l)=>{if(l>=e)i.push(p),p.selection&&s++;else if(p.step){let a=p.step.map(t.slice(n)),h=a&&a.getMap();if(n--,h&&t.appendMap(h,n),a){let c=p.selection&&p.selection.map(t.slice(n));c&&s++;let o=new g(h.invert(),a,c),f,d=i.length-1;(f=i.length&&i[d].merge(o))?i[d]=f:i.push(o)}}else p.map&&n--},this.items.length,0),new r(T.from(i.reverse()),s)}};w.empty=new w(T.empty,0);function F(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}var g=class r{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new r(t.getMap().invert(),t,this.selection)}}},m=class{constructor(e,t,n,i,s){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=s}},G=20;function S(r,e,t,n){let i=t.getMeta(I),s;if(i)return i.historyState;t.getMeta(N)&&(r=new m(r.done,r.undone,null,0,-1));let p=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(p&&p.getMeta(I))return p.getMeta(I).redo?new m(r.done.addTransform(t,void 0,n,M(e)),r.undone,_(t.mapping.maps),r.prevTime,r.prevComposition):new m(r.done,r.undone.addTransform(t,void 0,n,M(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(p&&p.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!p&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!K(t,r.prevRanges)),h=p?P(r.prevRanges,t.mapping):_(t.mapping.maps);return new m(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,M(e)),w.empty,h,t.time,l??r.prevComposition)}else return(s=t.getMeta("rebased"))?new m(r.done.rebased(t,s),r.undone.rebased(t,s),P(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new m(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),P(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function K(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let s=0;s<e.length;s+=2)n<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function _(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,i,s,p)=>e.push(s,p));return e}function P(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let i=e.map(r[n],1),s=e.map(r[n+1],-1);i<=s&&t.push(i,s)}return t}function B(r,e,t){let n=M(e),i=I.get(e).spec.config,s=(t?r.undone:r.done).popEvent(e,n);if(!s)return null;let p=s.selection.resolve(s.transform.doc),l=(t?r.done:r.undone).addTransform(s.transform,e.selection.getBookmark(),i,n),a=new m(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(p).setMeta(I,{redo:t,historyState:a})}var b=!1,k=null;function M(r){let e=r.plugins;if(k!=e){b=!1,k=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){b=!0;break}}return b}var I=new C("history"),N=new C("closeHistory");function J(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new x({key:I,state:{init(){return new m(w.empty,w.empty,null,0,-1)},apply(e,t,n){return S(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?R:n=="historyRedo"?U:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function E(r,e){return(t,n)=>{let i=I.getState(t);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let s=B(i,t,r);s&&n(e?s.scrollIntoView():s)}return!0}}var R=E(!1,!0),U=E(!0,!0),Q=E(!1,!1),X=E(!0,!1);export{J as a,R as b,U as c};