@inkandswitch/patchwork-pkg-base 0.0.15 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (383) hide show
  1. package/init.js +1 -0
  2. package/modules.json +11 -1
  3. package/package.json +1 -1
  4. package/packages/account-picker/dist/AccountPicker-7VBUJTTB.js +8860 -0
  5. package/packages/account-picker/dist/AccountPicker-7VBUJTTB.js.map +7 -0
  6. package/packages/account-picker/dist/AccountPicker-CN73XGEW.css +371 -0
  7. package/packages/account-picker/dist/AccountPicker-CN73XGEW.css.map +7 -0
  8. package/packages/account-picker/dist/chunk-5WRI5ZAA.js +31 -0
  9. package/packages/account-picker/dist/chunk-5WRI5ZAA.js.map +7 -0
  10. package/packages/account-picker/dist/tool.css +371 -0
  11. package/packages/account-picker/dist/tool.css.map +7 -0
  12. package/packages/account-picker/dist/tool.js +19 -0
  13. package/packages/account-picker/dist/tool.js.map +7 -0
  14. package/packages/account-picker/package.json +39 -0
  15. package/packages/codemirror-base/dist/chunk-KMEIRH3R.js +490 -0
  16. package/packages/codemirror-base/dist/chunk-KMEIRH3R.js.map +7 -0
  17. package/packages/codemirror-base/dist/lib/codemirror.js +7 -0
  18. package/packages/codemirror-base/dist/lib/codemirror.js.map +7 -0
  19. package/packages/codemirror-base/dist/main.js +17 -0
  20. package/packages/codemirror-base/dist/main.js.map +7 -0
  21. package/packages/codemirror-base/dist/tool.js +1799 -0
  22. package/packages/codemirror-base/dist/tool.js.map +7 -0
  23. package/packages/codemirror-base/package.json +55 -0
  24. package/packages/codemirror-markdown/dist/apl-QAIM2KBM.js +142 -0
  25. package/packages/codemirror-markdown/dist/apl-QAIM2KBM.js.map +7 -0
  26. package/packages/codemirror-markdown/dist/asciiarmor-G7UKQURA.js +58 -0
  27. package/packages/codemirror-markdown/dist/asciiarmor-G7UKQURA.js.map +7 -0
  28. package/packages/codemirror-markdown/dist/asn1-JTUXKWKT.js +144 -0
  29. package/packages/codemirror-markdown/dist/asn1-JTUXKWKT.js.map +7 -0
  30. package/packages/codemirror-markdown/dist/asterisk-NM6JCXOL.js +351 -0
  31. package/packages/codemirror-markdown/dist/asterisk-NM6JCXOL.js.map +7 -0
  32. package/packages/codemirror-markdown/dist/brainfuck-X7FFM55E.js +55 -0
  33. package/packages/codemirror-markdown/dist/brainfuck-X7FFM55E.js.map +7 -0
  34. package/packages/codemirror-markdown/dist/chunk-46Z6CXSY.js +1062 -0
  35. package/packages/codemirror-markdown/dist/chunk-46Z6CXSY.js.map +7 -0
  36. package/packages/codemirror-markdown/dist/chunk-6JT2ASRP.js +1111 -0
  37. package/packages/codemirror-markdown/dist/chunk-6JT2ASRP.js.map +7 -0
  38. package/packages/codemirror-markdown/dist/chunk-CSJO4DNL.js +1424 -0
  39. package/packages/codemirror-markdown/dist/chunk-CSJO4DNL.js.map +7 -0
  40. package/packages/codemirror-markdown/dist/chunk-FLC3A4DL.js +133 -0
  41. package/packages/codemirror-markdown/dist/chunk-FLC3A4DL.js.map +7 -0
  42. package/packages/codemirror-markdown/dist/chunk-M3X2FRO3.js +998 -0
  43. package/packages/codemirror-markdown/dist/chunk-M3X2FRO3.js.map +7 -0
  44. package/packages/codemirror-markdown/dist/chunk-MAW6NPUW.js +4930 -0
  45. package/packages/codemirror-markdown/dist/chunk-MAW6NPUW.js.map +7 -0
  46. package/packages/codemirror-markdown/dist/chunk-MBTMKYFQ.js +1779 -0
  47. package/packages/codemirror-markdown/dist/chunk-MBTMKYFQ.js.map +7 -0
  48. package/packages/codemirror-markdown/dist/chunk-NEI7FGV4.js +697 -0
  49. package/packages/codemirror-markdown/dist/chunk-NEI7FGV4.js.map +7 -0
  50. package/packages/codemirror-markdown/dist/chunk-PPGERYN5.js +2528 -0
  51. package/packages/codemirror-markdown/dist/chunk-PPGERYN5.js.map +7 -0
  52. package/packages/codemirror-markdown/dist/clike-DOBZTBQN.js +808 -0
  53. package/packages/codemirror-markdown/dist/clike-DOBZTBQN.js.map +7 -0
  54. package/packages/codemirror-markdown/dist/clojure-PTADSDNF.js +851 -0
  55. package/packages/codemirror-markdown/dist/clojure-PTADSDNF.js.map +7 -0
  56. package/packages/codemirror-markdown/dist/cmake-5HAC7YMH.js +73 -0
  57. package/packages/codemirror-markdown/dist/cmake-5HAC7YMH.js.map +7 -0
  58. package/packages/codemirror-markdown/dist/cobol-HAM4C42S.js +131 -0
  59. package/packages/codemirror-markdown/dist/cobol-HAM4C42S.js.map +7 -0
  60. package/packages/codemirror-markdown/dist/coffeescript-IBRKASSJ.js +310 -0
  61. package/packages/codemirror-markdown/dist/coffeescript-IBRKASSJ.js.map +7 -0
  62. package/packages/codemirror-markdown/dist/commonlisp-KMRPB5EW.js +132 -0
  63. package/packages/codemirror-markdown/dist/commonlisp-KMRPB5EW.js.map +7 -0
  64. package/packages/codemirror-markdown/dist/crystal-2MDF4EKJ.js +400 -0
  65. package/packages/codemirror-markdown/dist/crystal-2MDF4EKJ.js.map +7 -0
  66. package/packages/codemirror-markdown/dist/css-VQQXA3AY.js +1795 -0
  67. package/packages/codemirror-markdown/dist/css-VQQXA3AY.js.map +7 -0
  68. package/packages/codemirror-markdown/dist/cypher-ZZEGDGDJ.js +123 -0
  69. package/packages/codemirror-markdown/dist/cypher-ZZEGDGDJ.js.map +7 -0
  70. package/packages/codemirror-markdown/dist/d-5S6PJOOT.js +187 -0
  71. package/packages/codemirror-markdown/dist/d-5S6PJOOT.js.map +7 -0
  72. package/packages/codemirror-markdown/dist/datatype.js +48 -0
  73. package/packages/codemirror-markdown/dist/datatype.js.map +7 -0
  74. package/packages/codemirror-markdown/dist/diff-S77XBOWF.js +27 -0
  75. package/packages/codemirror-markdown/dist/diff-S77XBOWF.js.map +7 -0
  76. package/packages/codemirror-markdown/dist/dist-2C6IPJHB.js +98 -0
  77. package/packages/codemirror-markdown/dist/dist-2C6IPJHB.js.map +7 -0
  78. package/packages/codemirror-markdown/dist/dist-2H653DKD.js +170 -0
  79. package/packages/codemirror-markdown/dist/dist-2H653DKD.js.map +7 -0
  80. package/packages/codemirror-markdown/dist/dist-2O4EI6YQ.js +140 -0
  81. package/packages/codemirror-markdown/dist/dist-2O4EI6YQ.js.map +7 -0
  82. package/packages/codemirror-markdown/dist/dist-2UJRV4FH.js +75 -0
  83. package/packages/codemirror-markdown/dist/dist-2UJRV4FH.js.map +7 -0
  84. package/packages/codemirror-markdown/dist/dist-52S6W6Z3.js +15 -0
  85. package/packages/codemirror-markdown/dist/dist-52S6W6Z3.js.map +7 -0
  86. package/packages/codemirror-markdown/dist/dist-5KN6ODPO.js +340 -0
  87. package/packages/codemirror-markdown/dist/dist-5KN6ODPO.js.map +7 -0
  88. package/packages/codemirror-markdown/dist/dist-BOGB4NCA.js +20 -0
  89. package/packages/codemirror-markdown/dist/dist-BOGB4NCA.js.map +7 -0
  90. package/packages/codemirror-markdown/dist/dist-DZ4PW5HP.js +318 -0
  91. package/packages/codemirror-markdown/dist/dist-DZ4PW5HP.js.map +7 -0
  92. package/packages/codemirror-markdown/dist/dist-FDBKXKIA.js +100 -0
  93. package/packages/codemirror-markdown/dist/dist-FDBKXKIA.js.map +7 -0
  94. package/packages/codemirror-markdown/dist/dist-G2KVVLNT.js +381 -0
  95. package/packages/codemirror-markdown/dist/dist-G2KVVLNT.js.map +7 -0
  96. package/packages/codemirror-markdown/dist/dist-HHNZE2GE.js +193 -0
  97. package/packages/codemirror-markdown/dist/dist-HHNZE2GE.js.map +7 -0
  98. package/packages/codemirror-markdown/dist/dist-HNH74YPL.js +32 -0
  99. package/packages/codemirror-markdown/dist/dist-HNH74YPL.js.map +7 -0
  100. package/packages/codemirror-markdown/dist/dist-LBQUKRIG.js +27 -0
  101. package/packages/codemirror-markdown/dist/dist-LBQUKRIG.js.map +7 -0
  102. package/packages/codemirror-markdown/dist/dist-MFKCWPLQ.js +416 -0
  103. package/packages/codemirror-markdown/dist/dist-MFKCWPLQ.js.map +7 -0
  104. package/packages/codemirror-markdown/dist/dist-NISFJM3T.js +423 -0
  105. package/packages/codemirror-markdown/dist/dist-NISFJM3T.js.map +7 -0
  106. package/packages/codemirror-markdown/dist/dist-Q7P6VH6H.js +786 -0
  107. package/packages/codemirror-markdown/dist/dist-Q7P6VH6H.js.map +7 -0
  108. package/packages/codemirror-markdown/dist/dist-RWF5A5GN.js +451 -0
  109. package/packages/codemirror-markdown/dist/dist-RWF5A5GN.js.map +7 -0
  110. package/packages/codemirror-markdown/dist/dist-UHUU7KLC.js +748 -0
  111. package/packages/codemirror-markdown/dist/dist-UHUU7KLC.js.map +7 -0
  112. package/packages/codemirror-markdown/dist/dist-WJMBFK7W.js +360 -0
  113. package/packages/codemirror-markdown/dist/dist-WJMBFK7W.js.map +7 -0
  114. package/packages/codemirror-markdown/dist/dist-XJYSXJ7H.js +115 -0
  115. package/packages/codemirror-markdown/dist/dist-XJYSXJ7H.js.map +7 -0
  116. package/packages/codemirror-markdown/dist/dist-YY24ZXZD.js +212 -0
  117. package/packages/codemirror-markdown/dist/dist-YY24ZXZD.js.map +7 -0
  118. package/packages/codemirror-markdown/dist/dockerfile-JECCOJWP.js +209 -0
  119. package/packages/codemirror-markdown/dist/dockerfile-JECCOJWP.js.map +7 -0
  120. package/packages/codemirror-markdown/dist/dtd-MNDWTW4Z.js +116 -0
  121. package/packages/codemirror-markdown/dist/dtd-MNDWTW4Z.js.map +7 -0
  122. package/packages/codemirror-markdown/dist/dylan-VQ4IHJDS.js +317 -0
  123. package/packages/codemirror-markdown/dist/dylan-VQ4IHJDS.js.map +7 -0
  124. package/packages/codemirror-markdown/dist/ebnf-IDZBFTCG.js +142 -0
  125. package/packages/codemirror-markdown/dist/ebnf-IDZBFTCG.js.map +7 -0
  126. package/packages/codemirror-markdown/dist/ecl-X3ROY7E6.js +180 -0
  127. package/packages/codemirror-markdown/dist/ecl-X3ROY7E6.js.map +7 -0
  128. package/packages/codemirror-markdown/dist/eiffel-WB3M7Y2E.js +136 -0
  129. package/packages/codemirror-markdown/dist/eiffel-WB3M7Y2E.js.map +7 -0
  130. package/packages/codemirror-markdown/dist/elm-VHXR6ZA3.js +178 -0
  131. package/packages/codemirror-markdown/dist/elm-VHXR6ZA3.js.map +7 -0
  132. package/packages/codemirror-markdown/dist/erlang-7ZBDDQDV.js +676 -0
  133. package/packages/codemirror-markdown/dist/erlang-7ZBDDQDV.js.map +7 -0
  134. package/packages/codemirror-markdown/dist/extensions/embed.js +325 -0
  135. package/packages/codemirror-markdown/dist/extensions/embed.js.map +7 -0
  136. package/packages/codemirror-markdown/dist/extensions/links.js +118 -0
  137. package/packages/codemirror-markdown/dist/extensions/links.js.map +7 -0
  138. package/packages/codemirror-markdown/dist/extensions/markdown.js +3476 -0
  139. package/packages/codemirror-markdown/dist/extensions/markdown.js.map +7 -0
  140. package/packages/codemirror-markdown/dist/factor-IKT2GQE2.js +70 -0
  141. package/packages/codemirror-markdown/dist/factor-IKT2GQE2.js.map +7 -0
  142. package/packages/codemirror-markdown/dist/fcl-CNBUVGUC.js +143 -0
  143. package/packages/codemirror-markdown/dist/fcl-CNBUVGUC.js.map +7 -0
  144. package/packages/codemirror-markdown/dist/forth-4BTPWSFZ.js +118 -0
  145. package/packages/codemirror-markdown/dist/forth-4BTPWSFZ.js.map +7 -0
  146. package/packages/codemirror-markdown/dist/fortran-V6F5DQPK.js +469 -0
  147. package/packages/codemirror-markdown/dist/fortran-V6F5DQPK.js.map +7 -0
  148. package/packages/codemirror-markdown/dist/gas-4DLP6BC4.js +296 -0
  149. package/packages/codemirror-markdown/dist/gas-4DLP6BC4.js.map +7 -0
  150. package/packages/codemirror-markdown/dist/gherkin-OSGPX6HI.js +117 -0
  151. package/packages/codemirror-markdown/dist/gherkin-OSGPX6HI.js.map +7 -0
  152. package/packages/codemirror-markdown/dist/groovy-R2JW63QF.js +225 -0
  153. package/packages/codemirror-markdown/dist/groovy-R2JW63QF.js.map +7 -0
  154. package/packages/codemirror-markdown/dist/haskell-GG7T4J6H.js +461 -0
  155. package/packages/codemirror-markdown/dist/haskell-GG7T4J6H.js.map +7 -0
  156. package/packages/codemirror-markdown/dist/haxe-ESFUJKSE.js +521 -0
  157. package/packages/codemirror-markdown/dist/haxe-ESFUJKSE.js.map +7 -0
  158. package/packages/codemirror-markdown/dist/http-SZLSACOW.js +81 -0
  159. package/packages/codemirror-markdown/dist/http-SZLSACOW.js.map +7 -0
  160. package/packages/codemirror-markdown/dist/idl-V7UH35RP.js +987 -0
  161. package/packages/codemirror-markdown/dist/idl-V7UH35RP.js.map +7 -0
  162. package/packages/codemirror-markdown/dist/javascript-MGRPKFDN.js +13 -0
  163. package/packages/codemirror-markdown/dist/javascript-MGRPKFDN.js.map +7 -0
  164. package/packages/codemirror-markdown/dist/julia-CWCVZVPG.js +409 -0
  165. package/packages/codemirror-markdown/dist/julia-CWCVZVPG.js.map +7 -0
  166. package/packages/codemirror-markdown/dist/livescript-IGKT2FL7.js +303 -0
  167. package/packages/codemirror-markdown/dist/livescript-IGKT2FL7.js.map +7 -0
  168. package/packages/codemirror-markdown/dist/lua-GHK7GCTS.js +258 -0
  169. package/packages/codemirror-markdown/dist/lua-GHK7GCTS.js.map +7 -0
  170. package/packages/codemirror-markdown/dist/main.js +58 -0
  171. package/packages/codemirror-markdown/dist/main.js.map +7 -0
  172. package/packages/codemirror-markdown/dist/mathematica-W5LMQI3M.js +112 -0
  173. package/packages/codemirror-markdown/dist/mathematica-W5LMQI3M.js.map +7 -0
  174. package/packages/codemirror-markdown/dist/mbox-A7CXJ4HZ.js +119 -0
  175. package/packages/codemirror-markdown/dist/mbox-A7CXJ4HZ.js.map +7 -0
  176. package/packages/codemirror-markdown/dist/mirc-WYJEQUBY.js +109 -0
  177. package/packages/codemirror-markdown/dist/mirc-WYJEQUBY.js.map +7 -0
  178. package/packages/codemirror-markdown/dist/mllike-C2YS6SJI.js +340 -0
  179. package/packages/codemirror-markdown/dist/mllike-C2YS6SJI.js.map +7 -0
  180. package/packages/codemirror-markdown/dist/modelica-BMJSLZS7.js +149 -0
  181. package/packages/codemirror-markdown/dist/modelica-BMJSLZS7.js.map +7 -0
  182. package/packages/codemirror-markdown/dist/mscgen-5BORDYHW.js +137 -0
  183. package/packages/codemirror-markdown/dist/mscgen-5BORDYHW.js.map +7 -0
  184. package/packages/codemirror-markdown/dist/mumps-BYE6H7ZX.js +95 -0
  185. package/packages/codemirror-markdown/dist/mumps-BYE6H7ZX.js.map +7 -0
  186. package/packages/codemirror-markdown/dist/nginx-Y54HR7MQ.js +143 -0
  187. package/packages/codemirror-markdown/dist/nginx-Y54HR7MQ.js.map +7 -0
  188. package/packages/codemirror-markdown/dist/nsis-UZLPE2DL.js +67 -0
  189. package/packages/codemirror-markdown/dist/nsis-UZLPE2DL.js.map +7 -0
  190. package/packages/codemirror-markdown/dist/ntriples-SAI3J2VH.js +155 -0
  191. package/packages/codemirror-markdown/dist/ntriples-SAI3J2VH.js.map +7 -0
  192. package/packages/codemirror-markdown/dist/octave-TLUBYOUX.js +213 -0
  193. package/packages/codemirror-markdown/dist/octave-TLUBYOUX.js.map +7 -0
  194. package/packages/codemirror-markdown/dist/oz-F6LNIR6Q.js +233 -0
  195. package/packages/codemirror-markdown/dist/oz-F6LNIR6Q.js.map +7 -0
  196. package/packages/codemirror-markdown/dist/pascal-WINE2FE6.js +107 -0
  197. package/packages/codemirror-markdown/dist/pascal-WINE2FE6.js.map +7 -0
  198. package/packages/codemirror-markdown/dist/perl-NZG3EIBE.js +1107 -0
  199. package/packages/codemirror-markdown/dist/perl-NZG3EIBE.js.map +7 -0
  200. package/packages/codemirror-markdown/dist/pig-U7OFLRCV.js +105 -0
  201. package/packages/codemirror-markdown/dist/pig-U7OFLRCV.js.map +7 -0
  202. package/packages/codemirror-markdown/dist/powershell-ZSUS7P6D.js +330 -0
  203. package/packages/codemirror-markdown/dist/powershell-ZSUS7P6D.js.map +7 -0
  204. package/packages/codemirror-markdown/dist/properties-IJRU6UJW.js +60 -0
  205. package/packages/codemirror-markdown/dist/properties-IJRU6UJW.js.map +7 -0
  206. package/packages/codemirror-markdown/dist/protobuf-2KETQIQ5.js +80 -0
  207. package/packages/codemirror-markdown/dist/protobuf-2KETQIQ5.js.map +7 -0
  208. package/packages/codemirror-markdown/dist/pug-IQCJJAZU.js +410 -0
  209. package/packages/codemirror-markdown/dist/pug-IQCJJAZU.js.map +7 -0
  210. package/packages/codemirror-markdown/dist/puppet-YIIDDH6A.js +139 -0
  211. package/packages/codemirror-markdown/dist/puppet-YIIDDH6A.js.map +7 -0
  212. package/packages/codemirror-markdown/dist/python-A6P3XTMX.js +429 -0
  213. package/packages/codemirror-markdown/dist/python-A6P3XTMX.js.map +7 -0
  214. package/packages/codemirror-markdown/dist/q-2KXN5RX7.js +135 -0
  215. package/packages/codemirror-markdown/dist/q-2KXN5RX7.js.map +7 -0
  216. package/packages/codemirror-markdown/dist/r-BB4MIIBH.js +174 -0
  217. package/packages/codemirror-markdown/dist/r-BB4MIIBH.js.map +7 -0
  218. package/packages/codemirror-markdown/dist/rpm-LMR25AQ3.js +111 -0
  219. package/packages/codemirror-markdown/dist/rpm-LMR25AQ3.js.map +7 -0
  220. package/packages/codemirror-markdown/dist/ruby-TSD6FT73.js +333 -0
  221. package/packages/codemirror-markdown/dist/ruby-TSD6FT73.js.map +7 -0
  222. package/packages/codemirror-markdown/dist/sas-6X4WWIGV.js +209 -0
  223. package/packages/codemirror-markdown/dist/sas-6X4WWIGV.js.map +7 -0
  224. package/packages/codemirror-markdown/dist/scheme-E3I46HBL.js +230 -0
  225. package/packages/codemirror-markdown/dist/scheme-E3I46HBL.js.map +7 -0
  226. package/packages/codemirror-markdown/dist/shell-GX3PRI4I.js +224 -0
  227. package/packages/codemirror-markdown/dist/shell-GX3PRI4I.js.map +7 -0
  228. package/packages/codemirror-markdown/dist/sieve-V65ZPL4F.js +137 -0
  229. package/packages/codemirror-markdown/dist/sieve-V65ZPL4F.js.map +7 -0
  230. package/packages/codemirror-markdown/dist/smalltalk-OVKP2CVW.js +123 -0
  231. package/packages/codemirror-markdown/dist/smalltalk-OVKP2CVW.js.map +7 -0
  232. package/packages/codemirror-markdown/dist/solr-C4DLQJCF.js +71 -0
  233. package/packages/codemirror-markdown/dist/solr-C4DLQJCF.js.map +7 -0
  234. package/packages/codemirror-markdown/dist/sparql-REKUW7B3.js +251 -0
  235. package/packages/codemirror-markdown/dist/sparql-REKUW7B3.js.map +7 -0
  236. package/packages/codemirror-markdown/dist/spreadsheet-S7NN2YTQ.js +89 -0
  237. package/packages/codemirror-markdown/dist/spreadsheet-S7NN2YTQ.js.map +7 -0
  238. package/packages/codemirror-markdown/dist/sql-ML2Q43YF.js +358 -0
  239. package/packages/codemirror-markdown/dist/sql-ML2Q43YF.js.map +7 -0
  240. package/packages/codemirror-markdown/dist/stex-TCOGKBT4.js +233 -0
  241. package/packages/codemirror-markdown/dist/stex-TCOGKBT4.js.map +7 -0
  242. package/packages/codemirror-markdown/dist/stylus-3ONNYZOM.js +591 -0
  243. package/packages/codemirror-markdown/dist/stylus-3ONNYZOM.js.map +7 -0
  244. package/packages/codemirror-markdown/dist/swift-CNWGZ22Y.js +293 -0
  245. package/packages/codemirror-markdown/dist/swift-CNWGZ22Y.js.map +7 -0
  246. package/packages/codemirror-markdown/dist/tcl-77IMAZYE.js +116 -0
  247. package/packages/codemirror-markdown/dist/tcl-77IMAZYE.js.map +7 -0
  248. package/packages/codemirror-markdown/dist/textile-6IWIIKFM.js +416 -0
  249. package/packages/codemirror-markdown/dist/textile-6IWIIKFM.js.map +7 -0
  250. package/packages/codemirror-markdown/dist/tiddlywiki-IJSZMUSA.js +231 -0
  251. package/packages/codemirror-markdown/dist/tiddlywiki-IJSZMUSA.js.map +7 -0
  252. package/packages/codemirror-markdown/dist/tiki-HG37JJIT.js +276 -0
  253. package/packages/codemirror-markdown/dist/tiki-HG37JJIT.js.map +7 -0
  254. package/packages/codemirror-markdown/dist/toml-NINU2IMM.js +78 -0
  255. package/packages/codemirror-markdown/dist/toml-NINU2IMM.js.map +7 -0
  256. package/packages/codemirror-markdown/dist/troff-AOQJ4Q4C.js +63 -0
  257. package/packages/codemirror-markdown/dist/troff-AOQJ4Q4C.js.map +7 -0
  258. package/packages/codemirror-markdown/dist/ttcn-TLOZ3FX3.js +211 -0
  259. package/packages/codemirror-markdown/dist/ttcn-TLOZ3FX3.js.map +7 -0
  260. package/packages/codemirror-markdown/dist/ttcn-cfg-3B6QY7QE.js +141 -0
  261. package/packages/codemirror-markdown/dist/ttcn-cfg-3B6QY7QE.js.map +7 -0
  262. package/packages/codemirror-markdown/dist/turtle-3N5KCGXP.js +132 -0
  263. package/packages/codemirror-markdown/dist/turtle-3N5KCGXP.js.map +7 -0
  264. package/packages/codemirror-markdown/dist/vb-I7M5DRLP.js +204 -0
  265. package/packages/codemirror-markdown/dist/vb-I7M5DRLP.js.map +7 -0
  266. package/packages/codemirror-markdown/dist/vbscript-U2ARSJLD.js +482 -0
  267. package/packages/codemirror-markdown/dist/vbscript-U2ARSJLD.js.map +7 -0
  268. package/packages/codemirror-markdown/dist/velocity-R3AYP5XJ.js +151 -0
  269. package/packages/codemirror-markdown/dist/velocity-R3AYP5XJ.js.map +7 -0
  270. package/packages/codemirror-markdown/dist/verilog-7VEWVDW6.js +456 -0
  271. package/packages/codemirror-markdown/dist/verilog-7VEWVDW6.js.map +7 -0
  272. package/packages/codemirror-markdown/dist/vhdl-JZUPPGBA.js +162 -0
  273. package/packages/codemirror-markdown/dist/vhdl-JZUPPGBA.js.map +7 -0
  274. package/packages/codemirror-markdown/dist/webidl-SLQFEELK.js +206 -0
  275. package/packages/codemirror-markdown/dist/webidl-SLQFEELK.js.map +7 -0
  276. package/packages/codemirror-markdown/dist/xquery-VXP5KJ6N.js +532 -0
  277. package/packages/codemirror-markdown/dist/xquery-VXP5KJ6N.js.map +7 -0
  278. package/packages/codemirror-markdown/dist/yacas-JRBC4BEV.js +132 -0
  279. package/packages/codemirror-markdown/dist/yacas-JRBC4BEV.js.map +7 -0
  280. package/packages/codemirror-markdown/dist/z80-AJF6WLUV.js +95 -0
  281. package/packages/codemirror-markdown/dist/z80-AJF6WLUV.js.map +7 -0
  282. package/packages/codemirror-markdown/example.js +46 -0
  283. package/packages/codemirror-markdown/package.json +62 -0
  284. package/packages/commands/dist/main.js +504 -0
  285. package/packages/commands/dist/main.js.map +7 -0
  286. package/packages/commands/package.json +28 -0
  287. package/packages/contact/dist/ContactAvatar-FP32ZZH2.js +161 -0
  288. package/packages/contact/dist/ContactAvatar-FP32ZZH2.js.map +7 -0
  289. package/packages/contact/dist/ContactViewer-ZHEE6INW.js +60 -0
  290. package/packages/contact/dist/ContactViewer-ZHEE6INW.js.map +7 -0
  291. package/packages/contact/dist/InlineContactAvatar-VZDPEZV2.js +46 -0
  292. package/packages/contact/dist/InlineContactAvatar-VZDPEZV2.js.map +7 -0
  293. package/packages/contact/dist/chunk-MOZI4Y4O.js +54 -0
  294. package/packages/contact/dist/chunk-MOZI4Y4O.js.map +7 -0
  295. package/packages/contact/dist/datatype-ABVDVPWS.js +27 -0
  296. package/packages/contact/dist/datatype-ABVDVPWS.js.map +7 -0
  297. package/packages/contact/dist/tool.css +81 -0
  298. package/packages/contact/dist/tool.css.map +7 -0
  299. package/packages/contact/dist/tool.js +70 -0
  300. package/packages/contact/dist/tool.js.map +7 -0
  301. package/packages/contact/package.json +46 -0
  302. package/packages/folder/dist/datatype-HWGUFBTQ.js +27 -0
  303. package/packages/folder/dist/datatype-HWGUFBTQ.js.map +7 -0
  304. package/packages/folder/dist/index.js +27 -0
  305. package/packages/folder/dist/index.js.map +7 -0
  306. package/packages/folder/dist/tool-62JZAZRP.js +366 -0
  307. package/packages/folder/dist/tool-62JZAZRP.js.map +7 -0
  308. package/packages/folder/package.json +32 -0
  309. package/packages/sideboard/dist/account-bar-OJQC3J6W.js +2 -0
  310. package/packages/sideboard/dist/account-bar-OJQC3J6W.js.map +7 -0
  311. package/packages/sideboard/dist/chunk-32FICX7K.js +26 -0
  312. package/packages/sideboard/dist/chunk-32FICX7K.js.map +7 -0
  313. package/packages/sideboard/dist/chunk-3OYP6TVA.js +2 -0
  314. package/packages/sideboard/dist/chunk-3OYP6TVA.js.map +7 -0
  315. package/packages/sideboard/dist/chunk-FW4363Y4.js +2 -0
  316. package/packages/sideboard/dist/chunk-FW4363Y4.js.map +7 -0
  317. package/packages/sideboard/dist/chunk-QKYKEZU4.js +2 -0
  318. package/packages/sideboard/dist/chunk-QKYKEZU4.js.map +7 -0
  319. package/packages/sideboard/dist/document-list-panel-42LSXXCO.js +2 -0
  320. package/packages/sideboard/dist/document-list-panel-42LSXXCO.js.map +7 -0
  321. package/packages/sideboard/dist/index.css +2 -0
  322. package/packages/sideboard/dist/index.css.map +7 -0
  323. package/packages/sideboard/dist/index.js +2 -0
  324. package/packages/sideboard/dist/index.js.map +7 -0
  325. package/packages/sideboard/dist/sideboard/sideboard.js +2 -0
  326. package/packages/sideboard/dist/sideboard/sideboard.js.map +7 -0
  327. package/packages/sideboard/package.json +56 -0
  328. package/packages/theming/dist/active-theme-K27UXDBG.js +26 -0
  329. package/packages/theming/dist/active-theme-K27UXDBG.js.map +7 -0
  330. package/packages/theming/dist/chunk-K4OOO2TK.js +281 -0
  331. package/packages/theming/dist/chunk-K4OOO2TK.js.map +7 -0
  332. package/packages/theming/dist/chunk-RATW7VZI.js +11 -0
  333. package/packages/theming/dist/chunk-RATW7VZI.js.map +7 -0
  334. package/packages/theming/dist/chunk-U7SC4JPE.js +86 -0
  335. package/packages/theming/dist/chunk-U7SC4JPE.js.map +7 -0
  336. package/packages/theming/dist/codemirror-theme.js +2415 -0
  337. package/packages/theming/dist/codemirror-theme.js.map +7 -0
  338. package/packages/theming/dist/datatype-UUJVIZM7.js +16 -0
  339. package/packages/theming/dist/datatype-UUJVIZM7.js.map +7 -0
  340. package/packages/theming/dist/gloom-JYQPEOHI.css +102 -0
  341. package/packages/theming/dist/lychee-BMLMUNP6.css +114 -0
  342. package/packages/theming/dist/main.js +112 -0
  343. package/packages/theming/dist/main.js.map +7 -0
  344. package/packages/theming/dist/theme-RC7MV6WP.css +691 -0
  345. package/packages/theming/dist/theme-editor-datatype-CIXRKEFF.js +11 -0
  346. package/packages/theming/dist/theme-editor-datatype-CIXRKEFF.js.map +7 -0
  347. package/packages/theming/dist/theme-editor.js +576 -0
  348. package/packages/theming/dist/theme-editor.js.map +7 -0
  349. package/packages/theming/dist/theme-titlebar-P2CODQGF.js +21 -0
  350. package/packages/theming/dist/theme-titlebar-P2CODQGF.js.map +7 -0
  351. package/packages/theming/dist/theme-tray-5L2KGCGD.js +351 -0
  352. package/packages/theming/dist/theme-tray-5L2KGCGD.js.map +7 -0
  353. package/packages/theming/dist/tool.js +405 -0
  354. package/packages/theming/dist/tool.js.map +7 -0
  355. package/packages/theming/package.json +48 -0
  356. package/packages/threepane/dist/IsolatedDocumentArea-LFSDWMIY.js +2 -0
  357. package/packages/threepane/dist/IsolatedDocumentArea-LFSDWMIY.js.map +7 -0
  358. package/packages/threepane/dist/PatchworkFrame-JTNZ6365.js +2 -0
  359. package/packages/threepane/dist/PatchworkFrame-JTNZ6365.js.map +7 -0
  360. package/packages/threepane/dist/chunk-7YXO2YGV.js +2 -0
  361. package/packages/threepane/dist/chunk-7YXO2YGV.js.map +7 -0
  362. package/packages/threepane/dist/chunk-FOMAU6H2.js +972 -0
  363. package/packages/threepane/dist/chunk-FOMAU6H2.js.map +7 -0
  364. package/packages/threepane/dist/chunk-FW4363Y4.js +2 -0
  365. package/packages/threepane/dist/chunk-FW4363Y4.js.map +7 -0
  366. package/packages/threepane/dist/datatypes-FKBTWAO7.js +2 -0
  367. package/packages/threepane/dist/datatypes-FKBTWAO7.js.map +7 -0
  368. package/packages/threepane/dist/index.js +2 -0
  369. package/packages/threepane/dist/index.js.map +7 -0
  370. package/packages/threepane/package.json +42 -0
  371. package/packages/tldraw4/dist/chunk-IKZWERSR.js +38 -0
  372. package/packages/tldraw4/dist/chunk-IKZWERSR.js.map +7 -0
  373. package/packages/tldraw4/dist/chunk-VF5CY24G.js +140894 -0
  374. package/packages/tldraw4/dist/chunk-VF5CY24G.js.map +7 -0
  375. package/packages/tldraw4/dist/datatype.js +46 -0
  376. package/packages/tldraw4/dist/datatype.js.map +7 -0
  377. package/packages/tldraw4/dist/main.css +3202 -0
  378. package/packages/tldraw4/dist/main.css.map +7 -0
  379. package/packages/tldraw4/dist/main.js +42 -0
  380. package/packages/tldraw4/dist/main.js.map +7 -0
  381. package/packages/tldraw4/dist/tool.js +8767 -0
  382. package/packages/tldraw4/dist/tool.js.map +7 -0
  383. package/packages/tldraw4/package.json +62 -0
@@ -0,0 +1,4930 @@
1
+ // ../node_modules/.pnpm/@lezer+common@1.5.2/node_modules/@lezer/common/dist/index.js
2
+ var DefaultBufferLength = 1024;
3
+ var nextPropID = 0;
4
+ var Range = class {
5
+ constructor(from, to) {
6
+ this.from = from;
7
+ this.to = to;
8
+ }
9
+ };
10
+ var NodeProp = class {
11
+ /**
12
+ Create a new node prop type.
13
+ */
14
+ constructor(config = {}) {
15
+ this.id = nextPropID++;
16
+ this.perNode = !!config.perNode;
17
+ this.deserialize = config.deserialize || (() => {
18
+ throw new Error("This node type doesn't define a deserialize function");
19
+ });
20
+ this.combine = config.combine || null;
21
+ }
22
+ /**
23
+ This is meant to be used with
24
+ [`NodeSet.extend`](#common.NodeSet.extend) or
25
+ [`LRParser.configure`](#lr.ParserConfig.props) to compute
26
+ prop values for each node type in the set. Takes a [match
27
+ object](#common.NodeType^match) or function that returns undefined
28
+ if the node type doesn't get this prop, and the prop's value if
29
+ it does.
30
+ */
31
+ add(match) {
32
+ if (this.perNode)
33
+ throw new RangeError("Can't add per-node props to node types");
34
+ if (typeof match != "function")
35
+ match = NodeType.match(match);
36
+ return (type) => {
37
+ let result = match(type);
38
+ return result === void 0 ? null : [this, result];
39
+ };
40
+ }
41
+ };
42
+ NodeProp.closedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
43
+ NodeProp.openedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
44
+ NodeProp.group = new NodeProp({ deserialize: (str) => str.split(" ") });
45
+ NodeProp.isolate = new NodeProp({ deserialize: (value) => {
46
+ if (value && value != "rtl" && value != "ltr" && value != "auto")
47
+ throw new RangeError("Invalid value for isolate: " + value);
48
+ return value || "auto";
49
+ } });
50
+ NodeProp.contextHash = new NodeProp({ perNode: true });
51
+ NodeProp.lookAhead = new NodeProp({ perNode: true });
52
+ NodeProp.mounted = new NodeProp({ perNode: true });
53
+ var MountedTree = class {
54
+ constructor(tree, overlay, parser, bracketed = false) {
55
+ this.tree = tree;
56
+ this.overlay = overlay;
57
+ this.parser = parser;
58
+ this.bracketed = bracketed;
59
+ }
60
+ /**
61
+ @internal
62
+ */
63
+ static get(tree) {
64
+ return tree && tree.props && tree.props[NodeProp.mounted.id];
65
+ }
66
+ };
67
+ var noProps = /* @__PURE__ */ Object.create(null);
68
+ var NodeType = class _NodeType {
69
+ /**
70
+ @internal
71
+ */
72
+ constructor(name2, props, id, flags = 0) {
73
+ this.name = name2;
74
+ this.props = props;
75
+ this.id = id;
76
+ this.flags = flags;
77
+ }
78
+ /**
79
+ Define a node type.
80
+ */
81
+ static define(spec) {
82
+ let props = spec.props && spec.props.length ? /* @__PURE__ */ Object.create(null) : noProps;
83
+ let flags = (spec.top ? 1 : 0) | (spec.skipped ? 2 : 0) | (spec.error ? 4 : 0) | (spec.name == null ? 8 : 0);
84
+ let type = new _NodeType(spec.name || "", props, spec.id, flags);
85
+ if (spec.props)
86
+ for (let src of spec.props) {
87
+ if (!Array.isArray(src))
88
+ src = src(type);
89
+ if (src) {
90
+ if (src[0].perNode)
91
+ throw new RangeError("Can't store a per-node prop on a node type");
92
+ props[src[0].id] = src[1];
93
+ }
94
+ }
95
+ return type;
96
+ }
97
+ /**
98
+ Retrieves a node prop for this type. Will return `undefined` if
99
+ the prop isn't present on this node.
100
+ */
101
+ prop(prop) {
102
+ return this.props[prop.id];
103
+ }
104
+ /**
105
+ True when this is the top node of a grammar.
106
+ */
107
+ get isTop() {
108
+ return (this.flags & 1) > 0;
109
+ }
110
+ /**
111
+ True when this node is produced by a skip rule.
112
+ */
113
+ get isSkipped() {
114
+ return (this.flags & 2) > 0;
115
+ }
116
+ /**
117
+ Indicates whether this is an error node.
118
+ */
119
+ get isError() {
120
+ return (this.flags & 4) > 0;
121
+ }
122
+ /**
123
+ When true, this node type doesn't correspond to a user-declared
124
+ named node, for example because it is used to cache repetition.
125
+ */
126
+ get isAnonymous() {
127
+ return (this.flags & 8) > 0;
128
+ }
129
+ /**
130
+ Returns true when this node's name or one of its
131
+ [groups](#common.NodeProp^group) matches the given string.
132
+ */
133
+ is(name2) {
134
+ if (typeof name2 == "string") {
135
+ if (this.name == name2)
136
+ return true;
137
+ let group = this.prop(NodeProp.group);
138
+ return group ? group.indexOf(name2) > -1 : false;
139
+ }
140
+ return this.id == name2;
141
+ }
142
+ /**
143
+ Create a function from node types to arbitrary values by
144
+ specifying an object whose property names are node or
145
+ [group](#common.NodeProp^group) names. Often useful with
146
+ [`NodeProp.add`](#common.NodeProp.add). You can put multiple
147
+ names, separated by spaces, in a single property name to map
148
+ multiple node names to a single value.
149
+ */
150
+ static match(map) {
151
+ let direct = /* @__PURE__ */ Object.create(null);
152
+ for (let prop in map)
153
+ for (let name2 of prop.split(" "))
154
+ direct[name2] = map[prop];
155
+ return (node) => {
156
+ for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {
157
+ let found = direct[i < 0 ? node.name : groups[i]];
158
+ if (found)
159
+ return found;
160
+ }
161
+ };
162
+ }
163
+ };
164
+ NodeType.none = new NodeType(
165
+ "",
166
+ /* @__PURE__ */ Object.create(null),
167
+ 0,
168
+ 8
169
+ /* NodeFlag.Anonymous */
170
+ );
171
+ var NodeSet = class _NodeSet {
172
+ /**
173
+ Create a set with the given types. The `id` property of each
174
+ type should correspond to its position within the array.
175
+ */
176
+ constructor(types) {
177
+ this.types = types;
178
+ for (let i = 0; i < types.length; i++)
179
+ if (types[i].id != i)
180
+ throw new RangeError("Node type ids should correspond to array positions when creating a node set");
181
+ }
182
+ /**
183
+ Create a copy of this set with some node properties added. The
184
+ arguments to this method can be created with
185
+ [`NodeProp.add`](#common.NodeProp.add).
186
+ */
187
+ extend(...props) {
188
+ let newTypes = [];
189
+ for (let type of this.types) {
190
+ let newProps = null;
191
+ for (let source of props) {
192
+ let add = source(type);
193
+ if (add) {
194
+ if (!newProps)
195
+ newProps = Object.assign({}, type.props);
196
+ let value = add[1], prop = add[0];
197
+ if (prop.combine && prop.id in newProps)
198
+ value = prop.combine(newProps[prop.id], value);
199
+ newProps[prop.id] = value;
200
+ }
201
+ }
202
+ newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);
203
+ }
204
+ return new _NodeSet(newTypes);
205
+ }
206
+ };
207
+ var CachedNode = /* @__PURE__ */ new WeakMap();
208
+ var CachedInnerNode = /* @__PURE__ */ new WeakMap();
209
+ var IterMode;
210
+ (function(IterMode2) {
211
+ IterMode2[IterMode2["ExcludeBuffers"] = 1] = "ExcludeBuffers";
212
+ IterMode2[IterMode2["IncludeAnonymous"] = 2] = "IncludeAnonymous";
213
+ IterMode2[IterMode2["IgnoreMounts"] = 4] = "IgnoreMounts";
214
+ IterMode2[IterMode2["IgnoreOverlays"] = 8] = "IgnoreOverlays";
215
+ IterMode2[IterMode2["EnterBracketed"] = 16] = "EnterBracketed";
216
+ })(IterMode || (IterMode = {}));
217
+ var Tree = class _Tree {
218
+ /**
219
+ Construct a new tree. See also [`Tree.build`](#common.Tree^build).
220
+ */
221
+ constructor(type, children, positions, length, props) {
222
+ this.type = type;
223
+ this.children = children;
224
+ this.positions = positions;
225
+ this.length = length;
226
+ this.props = null;
227
+ if (props && props.length) {
228
+ this.props = /* @__PURE__ */ Object.create(null);
229
+ for (let [prop, value] of props)
230
+ this.props[typeof prop == "number" ? prop : prop.id] = value;
231
+ }
232
+ }
233
+ /**
234
+ @internal
235
+ */
236
+ toString() {
237
+ let mounted = MountedTree.get(this);
238
+ if (mounted && !mounted.overlay)
239
+ return mounted.tree.toString();
240
+ let children = "";
241
+ for (let ch of this.children) {
242
+ let str = ch.toString();
243
+ if (str) {
244
+ if (children)
245
+ children += ",";
246
+ children += str;
247
+ }
248
+ }
249
+ return !this.type.name ? children : (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (children.length ? "(" + children + ")" : "");
250
+ }
251
+ /**
252
+ Get a [tree cursor](#common.TreeCursor) positioned at the top of
253
+ the tree. Mode can be used to [control](#common.IterMode) which
254
+ nodes the cursor visits.
255
+ */
256
+ cursor(mode = 0) {
257
+ return new TreeCursor(this.topNode, mode);
258
+ }
259
+ /**
260
+ Get a [tree cursor](#common.TreeCursor) pointing into this tree
261
+ at the given position and side (see
262
+ [`moveTo`](#common.TreeCursor.moveTo).
263
+ */
264
+ cursorAt(pos, side = 0, mode = 0) {
265
+ let scope = CachedNode.get(this) || this.topNode;
266
+ let cursor = new TreeCursor(scope);
267
+ cursor.moveTo(pos, side);
268
+ CachedNode.set(this, cursor._tree);
269
+ return cursor;
270
+ }
271
+ /**
272
+ Get a [syntax node](#common.SyntaxNode) object for the top of the
273
+ tree.
274
+ */
275
+ get topNode() {
276
+ return new TreeNode(this, 0, 0, null);
277
+ }
278
+ /**
279
+ Get the [syntax node](#common.SyntaxNode) at the given position.
280
+ If `side` is -1, this will move into nodes that end at the
281
+ position. If 1, it'll move into nodes that start at the
282
+ position. With 0, it'll only enter nodes that cover the position
283
+ from both sides.
284
+
285
+ Note that this will not enter
286
+ [overlays](#common.MountedTree.overlay), and you often want
287
+ [`resolveInner`](#common.Tree.resolveInner) instead.
288
+ */
289
+ resolve(pos, side = 0) {
290
+ let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
291
+ CachedNode.set(this, node);
292
+ return node;
293
+ }
294
+ /**
295
+ Like [`resolve`](#common.Tree.resolve), but will enter
296
+ [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
297
+ pointing into the innermost overlaid tree at the given position
298
+ (with parent links going through all parent structure, including
299
+ the host trees).
300
+ */
301
+ resolveInner(pos, side = 0) {
302
+ let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
303
+ CachedInnerNode.set(this, node);
304
+ return node;
305
+ }
306
+ /**
307
+ In some situations, it can be useful to iterate through all
308
+ nodes around a position, including those in overlays that don't
309
+ directly cover the position. This method gives you an iterator
310
+ that will produce all nodes, from small to big, around the given
311
+ position.
312
+ */
313
+ resolveStack(pos, side = 0) {
314
+ return stackIterator(this, pos, side);
315
+ }
316
+ /**
317
+ Iterate over the tree and its children, calling `enter` for any
318
+ node that touches the `from`/`to` region (if given) before
319
+ running over such a node's children, and `leave` (if given) when
320
+ leaving the node. When `enter` returns `false`, that node will
321
+ not have its children iterated over (or `leave` called).
322
+ */
323
+ iterate(spec) {
324
+ let { enter, leave, from = 0, to = this.length } = spec;
325
+ let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;
326
+ for (let c = this.cursor(mode | IterMode.IncludeAnonymous); ; ) {
327
+ let entered = false;
328
+ if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {
329
+ if (c.firstChild())
330
+ continue;
331
+ entered = true;
332
+ }
333
+ for (; ; ) {
334
+ if (entered && leave && (anon || !c.type.isAnonymous))
335
+ leave(c);
336
+ if (c.nextSibling())
337
+ break;
338
+ if (!c.parent())
339
+ return;
340
+ entered = true;
341
+ }
342
+ }
343
+ }
344
+ /**
345
+ Get the value of the given [node prop](#common.NodeProp) for this
346
+ node. Works with both per-node and per-type props.
347
+ */
348
+ prop(prop) {
349
+ return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : void 0;
350
+ }
351
+ /**
352
+ Returns the node's [per-node props](#common.NodeProp.perNode) in a
353
+ format that can be passed to the [`Tree`](#common.Tree)
354
+ constructor.
355
+ */
356
+ get propValues() {
357
+ let result = [];
358
+ if (this.props)
359
+ for (let id in this.props)
360
+ result.push([+id, this.props[id]]);
361
+ return result;
362
+ }
363
+ /**
364
+ Balance the direct children of this tree, producing a copy of
365
+ which may have children grouped into subtrees with type
366
+ [`NodeType.none`](#common.NodeType^none).
367
+ */
368
+ balance(config = {}) {
369
+ return this.children.length <= 8 ? this : balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new _Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new _Tree(NodeType.none, children, positions, length)));
370
+ }
371
+ /**
372
+ Build a tree from a postfix-ordered buffer of node information,
373
+ or a cursor over such a buffer.
374
+ */
375
+ static build(data) {
376
+ return buildTree(data);
377
+ }
378
+ };
379
+ Tree.empty = new Tree(NodeType.none, [], [], 0);
380
+ var FlatBufferCursor = class _FlatBufferCursor {
381
+ constructor(buffer, index) {
382
+ this.buffer = buffer;
383
+ this.index = index;
384
+ }
385
+ get id() {
386
+ return this.buffer[this.index - 4];
387
+ }
388
+ get start() {
389
+ return this.buffer[this.index - 3];
390
+ }
391
+ get end() {
392
+ return this.buffer[this.index - 2];
393
+ }
394
+ get size() {
395
+ return this.buffer[this.index - 1];
396
+ }
397
+ get pos() {
398
+ return this.index;
399
+ }
400
+ next() {
401
+ this.index -= 4;
402
+ }
403
+ fork() {
404
+ return new _FlatBufferCursor(this.buffer, this.index);
405
+ }
406
+ };
407
+ var TreeBuffer = class _TreeBuffer {
408
+ /**
409
+ Create a tree buffer.
410
+ */
411
+ constructor(buffer, length, set) {
412
+ this.buffer = buffer;
413
+ this.length = length;
414
+ this.set = set;
415
+ }
416
+ /**
417
+ @internal
418
+ */
419
+ get type() {
420
+ return NodeType.none;
421
+ }
422
+ /**
423
+ @internal
424
+ */
425
+ toString() {
426
+ let result = [];
427
+ for (let index = 0; index < this.buffer.length; ) {
428
+ result.push(this.childString(index));
429
+ index = this.buffer[index + 3];
430
+ }
431
+ return result.join(",");
432
+ }
433
+ /**
434
+ @internal
435
+ */
436
+ childString(index) {
437
+ let id = this.buffer[index], endIndex = this.buffer[index + 3];
438
+ let type = this.set.types[id], result = type.name;
439
+ if (/\W/.test(result) && !type.isError)
440
+ result = JSON.stringify(result);
441
+ index += 4;
442
+ if (endIndex == index)
443
+ return result;
444
+ let children = [];
445
+ while (index < endIndex) {
446
+ children.push(this.childString(index));
447
+ index = this.buffer[index + 3];
448
+ }
449
+ return result + "(" + children.join(",") + ")";
450
+ }
451
+ /**
452
+ @internal
453
+ */
454
+ findChild(startIndex, endIndex, dir, pos, side) {
455
+ let { buffer } = this, pick = -1;
456
+ for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
457
+ if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
458
+ pick = i;
459
+ if (dir > 0)
460
+ break;
461
+ }
462
+ }
463
+ return pick;
464
+ }
465
+ /**
466
+ @internal
467
+ */
468
+ slice(startI, endI, from) {
469
+ let b = this.buffer;
470
+ let copy = new Uint16Array(endI - startI), len = 0;
471
+ for (let i = startI, j = 0; i < endI; ) {
472
+ copy[j++] = b[i++];
473
+ copy[j++] = b[i++] - from;
474
+ let to = copy[j++] = b[i++] - from;
475
+ copy[j++] = b[i++] - startI;
476
+ len = Math.max(len, to);
477
+ }
478
+ return new _TreeBuffer(copy, len, this.set);
479
+ }
480
+ };
481
+ function checkSide(side, pos, from, to) {
482
+ switch (side) {
483
+ case -2:
484
+ return from < pos;
485
+ case -1:
486
+ return to >= pos && from < pos;
487
+ case 0:
488
+ return from < pos && to > pos;
489
+ case 1:
490
+ return from <= pos && to > pos;
491
+ case 2:
492
+ return to > pos;
493
+ case 4:
494
+ return true;
495
+ }
496
+ }
497
+ function resolveNode(node, pos, side, overlays) {
498
+ var _a2;
499
+ while (node.from == node.to || (side < 1 ? node.from >= pos : node.from > pos) || (side > -1 ? node.to <= pos : node.to < pos)) {
500
+ let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
501
+ if (!parent)
502
+ return node;
503
+ node = parent;
504
+ }
505
+ let mode = overlays ? 0 : IterMode.IgnoreOverlays;
506
+ if (overlays)
507
+ for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
508
+ if (scan instanceof TreeNode && scan.index < 0 && ((_a2 = parent.enter(pos, side, mode)) === null || _a2 === void 0 ? void 0 : _a2.from) != scan.from)
509
+ node = parent;
510
+ }
511
+ for (; ; ) {
512
+ let inner = node.enter(pos, side, mode);
513
+ if (!inner)
514
+ return node;
515
+ node = inner;
516
+ }
517
+ }
518
+ var BaseNode = class {
519
+ cursor(mode = 0) {
520
+ return new TreeCursor(this, mode);
521
+ }
522
+ getChild(type, before = null, after = null) {
523
+ let r = getChildren(this, type, before, after);
524
+ return r.length ? r[0] : null;
525
+ }
526
+ getChildren(type, before = null, after = null) {
527
+ return getChildren(this, type, before, after);
528
+ }
529
+ resolve(pos, side = 0) {
530
+ return resolveNode(this, pos, side, false);
531
+ }
532
+ resolveInner(pos, side = 0) {
533
+ return resolveNode(this, pos, side, true);
534
+ }
535
+ matchContext(context) {
536
+ return matchNodeContext(this.parent, context);
537
+ }
538
+ enterUnfinishedNodesBefore(pos) {
539
+ let scan = this.childBefore(pos), node = this;
540
+ while (scan) {
541
+ let last = scan.lastChild;
542
+ if (!last || last.to != scan.to)
543
+ break;
544
+ if (last.type.isError && last.from == last.to) {
545
+ node = scan;
546
+ scan = last.prevSibling;
547
+ } else {
548
+ scan = last;
549
+ }
550
+ }
551
+ return node;
552
+ }
553
+ get node() {
554
+ return this;
555
+ }
556
+ get next() {
557
+ return this.parent;
558
+ }
559
+ };
560
+ var TreeNode = class _TreeNode extends BaseNode {
561
+ constructor(_tree, from, index, _parent) {
562
+ super();
563
+ this._tree = _tree;
564
+ this.from = from;
565
+ this.index = index;
566
+ this._parent = _parent;
567
+ }
568
+ get type() {
569
+ return this._tree.type;
570
+ }
571
+ get name() {
572
+ return this._tree.type.name;
573
+ }
574
+ get to() {
575
+ return this.from + this._tree.length;
576
+ }
577
+ nextChild(i, dir, pos, side, mode = 0) {
578
+ for (let parent = this; ; ) {
579
+ for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
580
+ let next = children[i], start = positions[i] + parent.from, mounted;
581
+ if (!(mode & IterMode.EnterBracketed && next instanceof Tree && (mounted = MountedTree.get(next)) && !mounted.overlay && mounted.bracketed && pos >= start && pos <= start + next.length) && !checkSide(side, pos, start, start + next.length))
582
+ continue;
583
+ if (next instanceof TreeBuffer) {
584
+ if (mode & IterMode.ExcludeBuffers)
585
+ continue;
586
+ let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
587
+ if (index > -1)
588
+ return new BufferNode(new BufferContext(parent, next, i, start), null, index);
589
+ } else if (mode & IterMode.IncludeAnonymous || (!next.type.isAnonymous || hasChild(next))) {
590
+ let mounted2;
591
+ if (!(mode & IterMode.IgnoreMounts) && (mounted2 = MountedTree.get(next)) && !mounted2.overlay)
592
+ return new _TreeNode(mounted2.tree, start, i, parent);
593
+ let inner = new _TreeNode(next, start, i, parent);
594
+ return mode & IterMode.IncludeAnonymous || !inner.type.isAnonymous ? inner : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side, mode);
595
+ }
596
+ }
597
+ if (mode & IterMode.IncludeAnonymous || !parent.type.isAnonymous)
598
+ return null;
599
+ if (parent.index >= 0)
600
+ i = parent.index + dir;
601
+ else
602
+ i = dir < 0 ? -1 : parent._parent._tree.children.length;
603
+ parent = parent._parent;
604
+ if (!parent)
605
+ return null;
606
+ }
607
+ }
608
+ get firstChild() {
609
+ return this.nextChild(
610
+ 0,
611
+ 1,
612
+ 0,
613
+ 4
614
+ /* Side.DontCare */
615
+ );
616
+ }
617
+ get lastChild() {
618
+ return this.nextChild(
619
+ this._tree.children.length - 1,
620
+ -1,
621
+ 0,
622
+ 4
623
+ /* Side.DontCare */
624
+ );
625
+ }
626
+ childAfter(pos) {
627
+ return this.nextChild(
628
+ 0,
629
+ 1,
630
+ pos,
631
+ 2
632
+ /* Side.After */
633
+ );
634
+ }
635
+ childBefore(pos) {
636
+ return this.nextChild(
637
+ this._tree.children.length - 1,
638
+ -1,
639
+ pos,
640
+ -2
641
+ /* Side.Before */
642
+ );
643
+ }
644
+ prop(prop) {
645
+ return this._tree.prop(prop);
646
+ }
647
+ enter(pos, side, mode = 0) {
648
+ let mounted;
649
+ if (!(mode & IterMode.IgnoreOverlays) && (mounted = MountedTree.get(this._tree)) && mounted.overlay) {
650
+ let rPos = pos - this.from, enterBracketed = mode & IterMode.EnterBracketed && mounted.bracketed;
651
+ for (let { from, to } of mounted.overlay) {
652
+ if ((side > 0 || enterBracketed ? from <= rPos : from < rPos) && (side < 0 || enterBracketed ? to >= rPos : to > rPos))
653
+ return new _TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
654
+ }
655
+ }
656
+ return this.nextChild(0, 1, pos, side, mode);
657
+ }
658
+ nextSignificantParent() {
659
+ let val = this;
660
+ while (val.type.isAnonymous && val._parent)
661
+ val = val._parent;
662
+ return val;
663
+ }
664
+ get parent() {
665
+ return this._parent ? this._parent.nextSignificantParent() : null;
666
+ }
667
+ get nextSibling() {
668
+ return this._parent && this.index >= 0 ? this._parent.nextChild(
669
+ this.index + 1,
670
+ 1,
671
+ 0,
672
+ 4
673
+ /* Side.DontCare */
674
+ ) : null;
675
+ }
676
+ get prevSibling() {
677
+ return this._parent && this.index >= 0 ? this._parent.nextChild(
678
+ this.index - 1,
679
+ -1,
680
+ 0,
681
+ 4
682
+ /* Side.DontCare */
683
+ ) : null;
684
+ }
685
+ get tree() {
686
+ return this._tree;
687
+ }
688
+ toTree() {
689
+ return this._tree;
690
+ }
691
+ /**
692
+ @internal
693
+ */
694
+ toString() {
695
+ return this._tree.toString();
696
+ }
697
+ };
698
+ function getChildren(node, type, before, after) {
699
+ let cur = node.cursor(), result = [];
700
+ if (!cur.firstChild())
701
+ return result;
702
+ if (before != null)
703
+ for (let found = false; !found; ) {
704
+ found = cur.type.is(before);
705
+ if (!cur.nextSibling())
706
+ return result;
707
+ }
708
+ for (; ; ) {
709
+ if (after != null && cur.type.is(after))
710
+ return result;
711
+ if (cur.type.is(type))
712
+ result.push(cur.node);
713
+ if (!cur.nextSibling())
714
+ return after == null ? result : [];
715
+ }
716
+ }
717
+ function matchNodeContext(node, context, i = context.length - 1) {
718
+ for (let p = node; i >= 0; p = p.parent) {
719
+ if (!p)
720
+ return false;
721
+ if (!p.type.isAnonymous) {
722
+ if (context[i] && context[i] != p.name)
723
+ return false;
724
+ i--;
725
+ }
726
+ }
727
+ return true;
728
+ }
729
+ var BufferContext = class {
730
+ constructor(parent, buffer, index, start) {
731
+ this.parent = parent;
732
+ this.buffer = buffer;
733
+ this.index = index;
734
+ this.start = start;
735
+ }
736
+ };
737
+ var BufferNode = class _BufferNode extends BaseNode {
738
+ get name() {
739
+ return this.type.name;
740
+ }
741
+ get from() {
742
+ return this.context.start + this.context.buffer.buffer[this.index + 1];
743
+ }
744
+ get to() {
745
+ return this.context.start + this.context.buffer.buffer[this.index + 2];
746
+ }
747
+ constructor(context, _parent, index) {
748
+ super();
749
+ this.context = context;
750
+ this._parent = _parent;
751
+ this.index = index;
752
+ this.type = context.buffer.set.types[context.buffer.buffer[index]];
753
+ }
754
+ child(dir, pos, side) {
755
+ let { buffer } = this.context;
756
+ let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
757
+ return index < 0 ? null : new _BufferNode(this.context, this, index);
758
+ }
759
+ get firstChild() {
760
+ return this.child(
761
+ 1,
762
+ 0,
763
+ 4
764
+ /* Side.DontCare */
765
+ );
766
+ }
767
+ get lastChild() {
768
+ return this.child(
769
+ -1,
770
+ 0,
771
+ 4
772
+ /* Side.DontCare */
773
+ );
774
+ }
775
+ childAfter(pos) {
776
+ return this.child(
777
+ 1,
778
+ pos,
779
+ 2
780
+ /* Side.After */
781
+ );
782
+ }
783
+ childBefore(pos) {
784
+ return this.child(
785
+ -1,
786
+ pos,
787
+ -2
788
+ /* Side.Before */
789
+ );
790
+ }
791
+ prop(prop) {
792
+ return this.type.prop(prop);
793
+ }
794
+ enter(pos, side, mode = 0) {
795
+ if (mode & IterMode.ExcludeBuffers)
796
+ return null;
797
+ let { buffer } = this.context;
798
+ let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
799
+ return index < 0 ? null : new _BufferNode(this.context, this, index);
800
+ }
801
+ get parent() {
802
+ return this._parent || this.context.parent.nextSignificantParent();
803
+ }
804
+ externalSibling(dir) {
805
+ return this._parent ? null : this.context.parent.nextChild(
806
+ this.context.index + dir,
807
+ dir,
808
+ 0,
809
+ 4
810
+ /* Side.DontCare */
811
+ );
812
+ }
813
+ get nextSibling() {
814
+ let { buffer } = this.context;
815
+ let after = buffer.buffer[this.index + 3];
816
+ if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
817
+ return new _BufferNode(this.context, this._parent, after);
818
+ return this.externalSibling(1);
819
+ }
820
+ get prevSibling() {
821
+ let { buffer } = this.context;
822
+ let parentStart = this._parent ? this._parent.index + 4 : 0;
823
+ if (this.index == parentStart)
824
+ return this.externalSibling(-1);
825
+ return new _BufferNode(this.context, this._parent, buffer.findChild(
826
+ parentStart,
827
+ this.index,
828
+ -1,
829
+ 0,
830
+ 4
831
+ /* Side.DontCare */
832
+ ));
833
+ }
834
+ get tree() {
835
+ return null;
836
+ }
837
+ toTree() {
838
+ let children = [], positions = [];
839
+ let { buffer } = this.context;
840
+ let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
841
+ if (endI > startI) {
842
+ let from = buffer.buffer[this.index + 1];
843
+ children.push(buffer.slice(startI, endI, from));
844
+ positions.push(0);
845
+ }
846
+ return new Tree(this.type, children, positions, this.to - this.from);
847
+ }
848
+ /**
849
+ @internal
850
+ */
851
+ toString() {
852
+ return this.context.buffer.childString(this.index);
853
+ }
854
+ };
855
+ function iterStack(heads) {
856
+ if (!heads.length)
857
+ return null;
858
+ let pick = 0, picked = heads[0];
859
+ for (let i = 1; i < heads.length; i++) {
860
+ let node = heads[i];
861
+ if (node.from > picked.from || node.to < picked.to) {
862
+ picked = node;
863
+ pick = i;
864
+ }
865
+ }
866
+ let next = picked instanceof TreeNode && picked.index < 0 ? null : picked.parent;
867
+ let newHeads = heads.slice();
868
+ if (next)
869
+ newHeads[pick] = next;
870
+ else
871
+ newHeads.splice(pick, 1);
872
+ return new StackIterator(newHeads, picked);
873
+ }
874
+ var StackIterator = class {
875
+ constructor(heads, node) {
876
+ this.heads = heads;
877
+ this.node = node;
878
+ }
879
+ get next() {
880
+ return iterStack(this.heads);
881
+ }
882
+ };
883
+ function stackIterator(tree, pos, side) {
884
+ let inner = tree.resolveInner(pos, side), layers = null;
885
+ for (let scan = inner instanceof TreeNode ? inner : inner.context.parent; scan; scan = scan.parent) {
886
+ if (scan.index < 0) {
887
+ let parent = scan.parent;
888
+ (layers || (layers = [inner])).push(parent.resolve(pos, side));
889
+ scan = parent;
890
+ } else {
891
+ let mount = MountedTree.get(scan.tree);
892
+ if (mount && mount.overlay && mount.overlay[0].from <= pos && mount.overlay[mount.overlay.length - 1].to >= pos) {
893
+ let root = new TreeNode(mount.tree, mount.overlay[0].from + scan.from, -1, scan);
894
+ (layers || (layers = [inner])).push(resolveNode(root, pos, side, false));
895
+ }
896
+ }
897
+ }
898
+ return layers ? iterStack(layers) : inner;
899
+ }
900
+ var TreeCursor = class {
901
+ /**
902
+ Shorthand for `.type.name`.
903
+ */
904
+ get name() {
905
+ return this.type.name;
906
+ }
907
+ /**
908
+ @internal
909
+ */
910
+ constructor(node, mode = 0) {
911
+ this.buffer = null;
912
+ this.stack = [];
913
+ this.index = 0;
914
+ this.bufferNode = null;
915
+ this.mode = mode & ~IterMode.EnterBracketed;
916
+ if (node instanceof TreeNode) {
917
+ this.yieldNode(node);
918
+ } else {
919
+ this._tree = node.context.parent;
920
+ this.buffer = node.context;
921
+ for (let n = node._parent; n; n = n._parent)
922
+ this.stack.unshift(n.index);
923
+ this.bufferNode = node;
924
+ this.yieldBuf(node.index);
925
+ }
926
+ }
927
+ yieldNode(node) {
928
+ if (!node)
929
+ return false;
930
+ this._tree = node;
931
+ this.type = node.type;
932
+ this.from = node.from;
933
+ this.to = node.to;
934
+ return true;
935
+ }
936
+ yieldBuf(index, type) {
937
+ this.index = index;
938
+ let { start, buffer } = this.buffer;
939
+ this.type = type || buffer.set.types[buffer.buffer[index]];
940
+ this.from = start + buffer.buffer[index + 1];
941
+ this.to = start + buffer.buffer[index + 2];
942
+ return true;
943
+ }
944
+ /**
945
+ @internal
946
+ */
947
+ yield(node) {
948
+ if (!node)
949
+ return false;
950
+ if (node instanceof TreeNode) {
951
+ this.buffer = null;
952
+ return this.yieldNode(node);
953
+ }
954
+ this.buffer = node.context;
955
+ return this.yieldBuf(node.index, node.type);
956
+ }
957
+ /**
958
+ @internal
959
+ */
960
+ toString() {
961
+ return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
962
+ }
963
+ /**
964
+ @internal
965
+ */
966
+ enterChild(dir, pos, side) {
967
+ if (!this.buffer)
968
+ return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
969
+ let { buffer } = this.buffer;
970
+ let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
971
+ if (index < 0)
972
+ return false;
973
+ this.stack.push(this.index);
974
+ return this.yieldBuf(index);
975
+ }
976
+ /**
977
+ Move the cursor to this node's first child. When this returns
978
+ false, the node has no child, and the cursor has not been moved.
979
+ */
980
+ firstChild() {
981
+ return this.enterChild(
982
+ 1,
983
+ 0,
984
+ 4
985
+ /* Side.DontCare */
986
+ );
987
+ }
988
+ /**
989
+ Move the cursor to this node's last child.
990
+ */
991
+ lastChild() {
992
+ return this.enterChild(
993
+ -1,
994
+ 0,
995
+ 4
996
+ /* Side.DontCare */
997
+ );
998
+ }
999
+ /**
1000
+ Move the cursor to the first child that ends after `pos`.
1001
+ */
1002
+ childAfter(pos) {
1003
+ return this.enterChild(
1004
+ 1,
1005
+ pos,
1006
+ 2
1007
+ /* Side.After */
1008
+ );
1009
+ }
1010
+ /**
1011
+ Move to the last child that starts before `pos`.
1012
+ */
1013
+ childBefore(pos) {
1014
+ return this.enterChild(
1015
+ -1,
1016
+ pos,
1017
+ -2
1018
+ /* Side.Before */
1019
+ );
1020
+ }
1021
+ /**
1022
+ Move the cursor to the child around `pos`. If side is -1 the
1023
+ child may end at that position, when 1 it may start there. This
1024
+ will also enter [overlaid](#common.MountedTree.overlay)
1025
+ [mounted](#common.NodeProp^mounted) trees unless `overlays` is
1026
+ set to false.
1027
+ */
1028
+ enter(pos, side, mode = this.mode) {
1029
+ if (!this.buffer)
1030
+ return this.yield(this._tree.enter(pos, side, mode));
1031
+ return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);
1032
+ }
1033
+ /**
1034
+ Move to the node's parent node, if this isn't the top node.
1035
+ */
1036
+ parent() {
1037
+ if (!this.buffer)
1038
+ return this.yieldNode(this.mode & IterMode.IncludeAnonymous ? this._tree._parent : this._tree.parent);
1039
+ if (this.stack.length)
1040
+ return this.yieldBuf(this.stack.pop());
1041
+ let parent = this.mode & IterMode.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
1042
+ this.buffer = null;
1043
+ return this.yieldNode(parent);
1044
+ }
1045
+ /**
1046
+ @internal
1047
+ */
1048
+ sibling(dir) {
1049
+ if (!this.buffer)
1050
+ return !this._tree._parent ? false : this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4, this.mode));
1051
+ let { buffer } = this.buffer, d = this.stack.length - 1;
1052
+ if (dir < 0) {
1053
+ let parentStart = d < 0 ? 0 : this.stack[d] + 4;
1054
+ if (this.index != parentStart)
1055
+ return this.yieldBuf(buffer.findChild(
1056
+ parentStart,
1057
+ this.index,
1058
+ -1,
1059
+ 0,
1060
+ 4
1061
+ /* Side.DontCare */
1062
+ ));
1063
+ } else {
1064
+ let after = buffer.buffer[this.index + 3];
1065
+ if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
1066
+ return this.yieldBuf(after);
1067
+ }
1068
+ return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4, this.mode)) : false;
1069
+ }
1070
+ /**
1071
+ Move to this node's next sibling, if any.
1072
+ */
1073
+ nextSibling() {
1074
+ return this.sibling(1);
1075
+ }
1076
+ /**
1077
+ Move to this node's previous sibling, if any.
1078
+ */
1079
+ prevSibling() {
1080
+ return this.sibling(-1);
1081
+ }
1082
+ atLastNode(dir) {
1083
+ let index, parent, { buffer } = this;
1084
+ if (buffer) {
1085
+ if (dir > 0) {
1086
+ if (this.index < buffer.buffer.buffer.length)
1087
+ return false;
1088
+ } else {
1089
+ for (let i = 0; i < this.index; i++)
1090
+ if (buffer.buffer.buffer[i + 3] < this.index)
1091
+ return false;
1092
+ }
1093
+ ({ index, parent } = buffer);
1094
+ } else {
1095
+ ({ index, _parent: parent } = this._tree);
1096
+ }
1097
+ for (; parent; { index, _parent: parent } = parent) {
1098
+ if (index > -1)
1099
+ for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
1100
+ let child = parent._tree.children[i];
1101
+ if (this.mode & IterMode.IncludeAnonymous || child instanceof TreeBuffer || !child.type.isAnonymous || hasChild(child))
1102
+ return false;
1103
+ }
1104
+ }
1105
+ return true;
1106
+ }
1107
+ move(dir, enter) {
1108
+ if (enter && this.enterChild(
1109
+ dir,
1110
+ 0,
1111
+ 4
1112
+ /* Side.DontCare */
1113
+ ))
1114
+ return true;
1115
+ for (; ; ) {
1116
+ if (this.sibling(dir))
1117
+ return true;
1118
+ if (this.atLastNode(dir) || !this.parent())
1119
+ return false;
1120
+ }
1121
+ }
1122
+ /**
1123
+ Move to the next node in a
1124
+ [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
1125
+ traversal, going from a node to its first child or, if the
1126
+ current node is empty or `enter` is false, its next sibling or
1127
+ the next sibling of the first parent node that has one.
1128
+ */
1129
+ next(enter = true) {
1130
+ return this.move(1, enter);
1131
+ }
1132
+ /**
1133
+ Move to the next node in a last-to-first pre-order traversal. A
1134
+ node is followed by its last child or, if it has none, its
1135
+ previous sibling or the previous sibling of the first parent
1136
+ node that has one.
1137
+ */
1138
+ prev(enter = true) {
1139
+ return this.move(-1, enter);
1140
+ }
1141
+ /**
1142
+ Move the cursor to the innermost node that covers `pos`. If
1143
+ `side` is -1, it will enter nodes that end at `pos`. If it is 1,
1144
+ it will enter nodes that start at `pos`.
1145
+ */
1146
+ moveTo(pos, side = 0) {
1147
+ while (this.from == this.to || (side < 1 ? this.from >= pos : this.from > pos) || (side > -1 ? this.to <= pos : this.to < pos))
1148
+ if (!this.parent())
1149
+ break;
1150
+ while (this.enterChild(1, pos, side)) {
1151
+ }
1152
+ return this;
1153
+ }
1154
+ /**
1155
+ Get a [syntax node](#common.SyntaxNode) at the cursor's current
1156
+ position.
1157
+ */
1158
+ get node() {
1159
+ if (!this.buffer)
1160
+ return this._tree;
1161
+ let cache = this.bufferNode, result = null, depth = 0;
1162
+ if (cache && cache.context == this.buffer) {
1163
+ scan: for (let index = this.index, d = this.stack.length; d >= 0; ) {
1164
+ for (let c = cache; c; c = c._parent)
1165
+ if (c.index == index) {
1166
+ if (index == this.index)
1167
+ return c;
1168
+ result = c;
1169
+ depth = d + 1;
1170
+ break scan;
1171
+ }
1172
+ index = this.stack[--d];
1173
+ }
1174
+ }
1175
+ for (let i = depth; i < this.stack.length; i++)
1176
+ result = new BufferNode(this.buffer, result, this.stack[i]);
1177
+ return this.bufferNode = new BufferNode(this.buffer, result, this.index);
1178
+ }
1179
+ /**
1180
+ Get the [tree](#common.Tree) that represents the current node, if
1181
+ any. Will return null when the node is in a [tree
1182
+ buffer](#common.TreeBuffer).
1183
+ */
1184
+ get tree() {
1185
+ return this.buffer ? null : this._tree._tree;
1186
+ }
1187
+ /**
1188
+ Iterate over the current node and all its descendants, calling
1189
+ `enter` when entering a node and `leave`, if given, when leaving
1190
+ one. When `enter` returns `false`, any children of that node are
1191
+ skipped, and `leave` isn't called for it.
1192
+ */
1193
+ iterate(enter, leave) {
1194
+ for (let depth = 0; ; ) {
1195
+ let mustLeave = false;
1196
+ if (this.type.isAnonymous || enter(this) !== false) {
1197
+ if (this.firstChild()) {
1198
+ depth++;
1199
+ continue;
1200
+ }
1201
+ if (!this.type.isAnonymous)
1202
+ mustLeave = true;
1203
+ }
1204
+ for (; ; ) {
1205
+ if (mustLeave && leave)
1206
+ leave(this);
1207
+ mustLeave = this.type.isAnonymous;
1208
+ if (!depth)
1209
+ return;
1210
+ if (this.nextSibling())
1211
+ break;
1212
+ this.parent();
1213
+ depth--;
1214
+ mustLeave = true;
1215
+ }
1216
+ }
1217
+ }
1218
+ /**
1219
+ Test whether the current node matches a given context—a sequence
1220
+ of direct parent node names. Empty strings in the context array
1221
+ are treated as wildcards.
1222
+ */
1223
+ matchContext(context) {
1224
+ if (!this.buffer)
1225
+ return matchNodeContext(this.node.parent, context);
1226
+ let { buffer } = this.buffer, { types } = buffer.set;
1227
+ for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
1228
+ if (d < 0)
1229
+ return matchNodeContext(this._tree, context, i);
1230
+ let type = types[buffer.buffer[this.stack[d]]];
1231
+ if (!type.isAnonymous) {
1232
+ if (context[i] && context[i] != type.name)
1233
+ return false;
1234
+ i--;
1235
+ }
1236
+ }
1237
+ return true;
1238
+ }
1239
+ };
1240
+ function hasChild(tree) {
1241
+ return tree.children.some((ch) => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));
1242
+ }
1243
+ function buildTree(data) {
1244
+ var _a2;
1245
+ let { buffer, nodeSet: nodeSet2, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet2.types.length } = data;
1246
+ let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
1247
+ let types = nodeSet2.types;
1248
+ let contextHash = 0, lookAhead = 0;
1249
+ function takeNode(parentStart, minPos, children2, positions2, inRepeat, depth) {
1250
+ let { id, start, end, size } = cursor;
1251
+ let lookAheadAtStart = lookAhead, contextAtStart = contextHash;
1252
+ if (size < 0) {
1253
+ cursor.next();
1254
+ if (size == -1) {
1255
+ let node2 = reused[id];
1256
+ children2.push(node2);
1257
+ positions2.push(start - parentStart);
1258
+ return;
1259
+ } else if (size == -3) {
1260
+ contextHash = id;
1261
+ return;
1262
+ } else if (size == -4) {
1263
+ lookAhead = id;
1264
+ return;
1265
+ } else {
1266
+ throw new RangeError(`Unrecognized record size: ${size}`);
1267
+ }
1268
+ }
1269
+ let type = types[id], node, buffer2;
1270
+ let startPos = start - parentStart;
1271
+ if (end - start <= maxBufferLength && (buffer2 = findBufferSize(cursor.pos - minPos, inRepeat))) {
1272
+ let data2 = new Uint16Array(buffer2.size - buffer2.skip);
1273
+ let endPos = cursor.pos - buffer2.size, index = data2.length;
1274
+ while (cursor.pos > endPos)
1275
+ index = copyToBuffer(buffer2.start, data2, index);
1276
+ node = new TreeBuffer(data2, end - buffer2.start, nodeSet2);
1277
+ startPos = buffer2.start - parentStart;
1278
+ } else {
1279
+ let endPos = cursor.pos - size;
1280
+ cursor.next();
1281
+ let localChildren = [], localPositions = [];
1282
+ let localInRepeat = id >= minRepeatType ? id : -1;
1283
+ let lastGroup = 0, lastEnd = end;
1284
+ while (cursor.pos > endPos) {
1285
+ if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
1286
+ if (cursor.end <= lastEnd - maxBufferLength) {
1287
+ makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
1288
+ lastGroup = localChildren.length;
1289
+ lastEnd = cursor.end;
1290
+ }
1291
+ cursor.next();
1292
+ } else if (depth > 2500) {
1293
+ takeFlatNode(start, endPos, localChildren, localPositions);
1294
+ } else {
1295
+ takeNode(start, endPos, localChildren, localPositions, localInRepeat, depth + 1);
1296
+ }
1297
+ }
1298
+ if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
1299
+ makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
1300
+ localChildren.reverse();
1301
+ localPositions.reverse();
1302
+ if (localInRepeat > -1 && lastGroup > 0) {
1303
+ let make = makeBalanced(type, contextAtStart);
1304
+ node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
1305
+ } else {
1306
+ node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end, contextAtStart);
1307
+ }
1308
+ }
1309
+ children2.push(node);
1310
+ positions2.push(startPos);
1311
+ }
1312
+ function takeFlatNode(parentStart, minPos, children2, positions2) {
1313
+ let nodes = [];
1314
+ let nodeCount = 0, stopAt = -1;
1315
+ while (cursor.pos > minPos) {
1316
+ let { id, start, end, size } = cursor;
1317
+ if (size > 4) {
1318
+ cursor.next();
1319
+ } else if (stopAt > -1 && start < stopAt) {
1320
+ break;
1321
+ } else {
1322
+ if (stopAt < 0)
1323
+ stopAt = end - maxBufferLength;
1324
+ nodes.push(id, start, end);
1325
+ nodeCount++;
1326
+ cursor.next();
1327
+ }
1328
+ }
1329
+ if (nodeCount) {
1330
+ let buffer2 = new Uint16Array(nodeCount * 4);
1331
+ let start = nodes[nodes.length - 2];
1332
+ for (let i = nodes.length - 3, j = 0; i >= 0; i -= 3) {
1333
+ buffer2[j++] = nodes[i];
1334
+ buffer2[j++] = nodes[i + 1] - start;
1335
+ buffer2[j++] = nodes[i + 2] - start;
1336
+ buffer2[j++] = j;
1337
+ }
1338
+ children2.push(new TreeBuffer(buffer2, nodes[2] - start, nodeSet2));
1339
+ positions2.push(start - parentStart);
1340
+ }
1341
+ }
1342
+ function makeBalanced(type, contextHash2) {
1343
+ return (children2, positions2, length2) => {
1344
+ let lookAhead2 = 0, lastI = children2.length - 1, last, lookAheadProp;
1345
+ if (lastI >= 0 && (last = children2[lastI]) instanceof Tree) {
1346
+ if (!lastI && last.type == type && last.length == length2)
1347
+ return last;
1348
+ if (lookAheadProp = last.prop(NodeProp.lookAhead))
1349
+ lookAhead2 = positions2[lastI] + last.length + lookAheadProp;
1350
+ }
1351
+ return makeTree(type, children2, positions2, length2, lookAhead2, contextHash2);
1352
+ };
1353
+ }
1354
+ function makeRepeatLeaf(children2, positions2, base, i, from, to, type, lookAhead2, contextHash2) {
1355
+ let localChildren = [], localPositions = [];
1356
+ while (children2.length > i) {
1357
+ localChildren.push(children2.pop());
1358
+ localPositions.push(positions2.pop() + base - from);
1359
+ }
1360
+ children2.push(makeTree(nodeSet2.types[type], localChildren, localPositions, to - from, lookAhead2 - to, contextHash2));
1361
+ positions2.push(from - base);
1362
+ }
1363
+ function makeTree(type, children2, positions2, length2, lookAhead2, contextHash2, props) {
1364
+ if (contextHash2) {
1365
+ let pair = [NodeProp.contextHash, contextHash2];
1366
+ props = props ? [pair].concat(props) : [pair];
1367
+ }
1368
+ if (lookAhead2 > 25) {
1369
+ let pair = [NodeProp.lookAhead, lookAhead2];
1370
+ props = props ? [pair].concat(props) : [pair];
1371
+ }
1372
+ return new Tree(type, children2, positions2, length2, props);
1373
+ }
1374
+ function findBufferSize(maxSize, inRepeat) {
1375
+ let fork = cursor.fork();
1376
+ let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
1377
+ let result = { size: 0, start: 0, skip: 0 };
1378
+ scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos; ) {
1379
+ let nodeSize2 = fork.size;
1380
+ if (fork.id == inRepeat && nodeSize2 >= 0) {
1381
+ result.size = size;
1382
+ result.start = start;
1383
+ result.skip = skip;
1384
+ skip += 4;
1385
+ size += 4;
1386
+ fork.next();
1387
+ continue;
1388
+ }
1389
+ let startPos = fork.pos - nodeSize2;
1390
+ if (nodeSize2 < 0 || startPos < minPos || fork.start < minStart)
1391
+ break;
1392
+ let localSkipped = fork.id >= minRepeatType ? 4 : 0;
1393
+ let nodeStart = fork.start;
1394
+ fork.next();
1395
+ while (fork.pos > startPos) {
1396
+ if (fork.size < 0) {
1397
+ if (fork.size == -3 || fork.size == -4)
1398
+ localSkipped += 4;
1399
+ else
1400
+ break scan;
1401
+ } else if (fork.id >= minRepeatType) {
1402
+ localSkipped += 4;
1403
+ }
1404
+ fork.next();
1405
+ }
1406
+ start = nodeStart;
1407
+ size += nodeSize2;
1408
+ skip += localSkipped;
1409
+ }
1410
+ if (inRepeat < 0 || size == maxSize) {
1411
+ result.size = size;
1412
+ result.start = start;
1413
+ result.skip = skip;
1414
+ }
1415
+ return result.size > 4 ? result : void 0;
1416
+ }
1417
+ function copyToBuffer(bufferStart, buffer2, index) {
1418
+ let { id, start, end, size } = cursor;
1419
+ cursor.next();
1420
+ if (size >= 0 && id < minRepeatType) {
1421
+ let startIndex = index;
1422
+ if (size > 4) {
1423
+ let endPos = cursor.pos - (size - 4);
1424
+ while (cursor.pos > endPos)
1425
+ index = copyToBuffer(bufferStart, buffer2, index);
1426
+ }
1427
+ buffer2[--index] = startIndex;
1428
+ buffer2[--index] = end - bufferStart;
1429
+ buffer2[--index] = start - bufferStart;
1430
+ buffer2[--index] = id;
1431
+ } else if (size == -3) {
1432
+ contextHash = id;
1433
+ } else if (size == -4) {
1434
+ lookAhead = id;
1435
+ }
1436
+ return index;
1437
+ }
1438
+ let children = [], positions = [];
1439
+ while (cursor.pos > 0)
1440
+ takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1, 0);
1441
+ let length = (_a2 = data.length) !== null && _a2 !== void 0 ? _a2 : children.length ? positions[0] + children[0].length : 0;
1442
+ return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);
1443
+ }
1444
+ var nodeSizeCache = /* @__PURE__ */ new WeakMap();
1445
+ function nodeSize(balanceType, node) {
1446
+ if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType)
1447
+ return 1;
1448
+ let size = nodeSizeCache.get(node);
1449
+ if (size == null) {
1450
+ size = 1;
1451
+ for (let child of node.children) {
1452
+ if (child.type != balanceType || !(child instanceof Tree)) {
1453
+ size = 1;
1454
+ break;
1455
+ }
1456
+ size += nodeSize(balanceType, child);
1457
+ }
1458
+ nodeSizeCache.set(node, size);
1459
+ }
1460
+ return size;
1461
+ }
1462
+ function balanceRange(balanceType, children, positions, from, to, start, length, mkTop, mkTree) {
1463
+ let total = 0;
1464
+ for (let i = from; i < to; i++)
1465
+ total += nodeSize(balanceType, children[i]);
1466
+ let maxChild = Math.ceil(
1467
+ total * 1.5 / 8
1468
+ /* Balance.BranchFactor */
1469
+ );
1470
+ let localChildren = [], localPositions = [];
1471
+ function divide(children2, positions2, from2, to2, offset) {
1472
+ for (let i = from2; i < to2; ) {
1473
+ let groupFrom = i, groupStart = positions2[i], groupSize = nodeSize(balanceType, children2[i]);
1474
+ i++;
1475
+ for (; i < to2; i++) {
1476
+ let nextSize = nodeSize(balanceType, children2[i]);
1477
+ if (groupSize + nextSize >= maxChild)
1478
+ break;
1479
+ groupSize += nextSize;
1480
+ }
1481
+ if (i == groupFrom + 1) {
1482
+ if (groupSize > maxChild) {
1483
+ let only = children2[groupFrom];
1484
+ divide(only.children, only.positions, 0, only.children.length, positions2[groupFrom] + offset);
1485
+ continue;
1486
+ }
1487
+ localChildren.push(children2[groupFrom]);
1488
+ } else {
1489
+ let length2 = positions2[i - 1] + children2[i - 1].length - groupStart;
1490
+ localChildren.push(balanceRange(balanceType, children2, positions2, groupFrom, i, groupStart, length2, null, mkTree));
1491
+ }
1492
+ localPositions.push(groupStart + offset - start);
1493
+ }
1494
+ }
1495
+ divide(children, positions, from, to, 0);
1496
+ return (mkTop || mkTree)(localChildren, localPositions, length);
1497
+ }
1498
+ var NodeWeakMap = class {
1499
+ constructor() {
1500
+ this.map = /* @__PURE__ */ new WeakMap();
1501
+ }
1502
+ setBuffer(buffer, index, value) {
1503
+ let inner = this.map.get(buffer);
1504
+ if (!inner)
1505
+ this.map.set(buffer, inner = /* @__PURE__ */ new Map());
1506
+ inner.set(index, value);
1507
+ }
1508
+ getBuffer(buffer, index) {
1509
+ let inner = this.map.get(buffer);
1510
+ return inner && inner.get(index);
1511
+ }
1512
+ /**
1513
+ Set the value for this syntax node.
1514
+ */
1515
+ set(node, value) {
1516
+ if (node instanceof BufferNode)
1517
+ this.setBuffer(node.context.buffer, node.index, value);
1518
+ else if (node instanceof TreeNode)
1519
+ this.map.set(node.tree, value);
1520
+ }
1521
+ /**
1522
+ Retrieve value for this syntax node, if it exists in the map.
1523
+ */
1524
+ get(node) {
1525
+ return node instanceof BufferNode ? this.getBuffer(node.context.buffer, node.index) : node instanceof TreeNode ? this.map.get(node.tree) : void 0;
1526
+ }
1527
+ /**
1528
+ Set the value for the node that a cursor currently points to.
1529
+ */
1530
+ cursorSet(cursor, value) {
1531
+ if (cursor.buffer)
1532
+ this.setBuffer(cursor.buffer.buffer, cursor.index, value);
1533
+ else
1534
+ this.map.set(cursor.tree, value);
1535
+ }
1536
+ /**
1537
+ Retrieve the value for the node that a cursor currently points
1538
+ to.
1539
+ */
1540
+ cursorGet(cursor) {
1541
+ return cursor.buffer ? this.getBuffer(cursor.buffer.buffer, cursor.index) : this.map.get(cursor.tree);
1542
+ }
1543
+ };
1544
+ var TreeFragment = class _TreeFragment {
1545
+ /**
1546
+ Construct a tree fragment. You'll usually want to use
1547
+ [`addTree`](#common.TreeFragment^addTree) and
1548
+ [`applyChanges`](#common.TreeFragment^applyChanges) instead of
1549
+ calling this directly.
1550
+ */
1551
+ constructor(from, to, tree, offset, openStart = false, openEnd = false) {
1552
+ this.from = from;
1553
+ this.to = to;
1554
+ this.tree = tree;
1555
+ this.offset = offset;
1556
+ this.open = (openStart ? 1 : 0) | (openEnd ? 2 : 0);
1557
+ }
1558
+ /**
1559
+ Whether the start of the fragment represents the start of a
1560
+ parse, or the end of a change. (In the second case, it may not
1561
+ be safe to reuse some nodes at the start, depending on the
1562
+ parsing algorithm.)
1563
+ */
1564
+ get openStart() {
1565
+ return (this.open & 1) > 0;
1566
+ }
1567
+ /**
1568
+ Whether the end of the fragment represents the end of a
1569
+ full-document parse, or the start of a change.
1570
+ */
1571
+ get openEnd() {
1572
+ return (this.open & 2) > 0;
1573
+ }
1574
+ /**
1575
+ Create a set of fragments from a freshly parsed tree, or update
1576
+ an existing set of fragments by replacing the ones that overlap
1577
+ with a tree with content from the new tree. When `partial` is
1578
+ true, the parse is treated as incomplete, and the resulting
1579
+ fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
1580
+ true.
1581
+ */
1582
+ static addTree(tree, fragments = [], partial = false) {
1583
+ let result = [new _TreeFragment(0, tree.length, tree, 0, false, partial)];
1584
+ for (let f of fragments)
1585
+ if (f.to > tree.length)
1586
+ result.push(f);
1587
+ return result;
1588
+ }
1589
+ /**
1590
+ Apply a set of edits to an array of fragments, removing or
1591
+ splitting fragments as necessary to remove edited ranges, and
1592
+ adjusting offsets for fragments that moved.
1593
+ */
1594
+ static applyChanges(fragments, changes, minGap = 128) {
1595
+ if (!changes.length)
1596
+ return fragments;
1597
+ let result = [];
1598
+ let fI = 1, nextF = fragments.length ? fragments[0] : null;
1599
+ for (let cI = 0, pos = 0, off = 0; ; cI++) {
1600
+ let nextC = cI < changes.length ? changes[cI] : null;
1601
+ let nextPos = nextC ? nextC.fromA : 1e9;
1602
+ if (nextPos - pos >= minGap)
1603
+ while (nextF && nextF.from < nextPos) {
1604
+ let cut = nextF;
1605
+ if (pos >= cut.from || nextPos <= cut.to || off) {
1606
+ let fFrom = Math.max(cut.from, pos) - off, fTo = Math.min(cut.to, nextPos) - off;
1607
+ cut = fFrom >= fTo ? null : new _TreeFragment(fFrom, fTo, cut.tree, cut.offset + off, cI > 0, !!nextC);
1608
+ }
1609
+ if (cut)
1610
+ result.push(cut);
1611
+ if (nextF.to > nextPos)
1612
+ break;
1613
+ nextF = fI < fragments.length ? fragments[fI++] : null;
1614
+ }
1615
+ if (!nextC)
1616
+ break;
1617
+ pos = nextC.toA;
1618
+ off = nextC.toA - nextC.toB;
1619
+ }
1620
+ return result;
1621
+ }
1622
+ };
1623
+ var Parser = class {
1624
+ /**
1625
+ Start a parse, returning a [partial parse](#common.PartialParse)
1626
+ object. [`fragments`](#common.TreeFragment) can be passed in to
1627
+ make the parse incremental.
1628
+
1629
+ By default, the entire input is parsed. You can pass `ranges`,
1630
+ which should be a sorted array of non-empty, non-overlapping
1631
+ ranges, to parse only those ranges. The tree returned in that
1632
+ case will start at `ranges[0].from`.
1633
+ */
1634
+ startParse(input, fragments, ranges) {
1635
+ if (typeof input == "string")
1636
+ input = new StringInput(input);
1637
+ ranges = !ranges ? [new Range(0, input.length)] : ranges.length ? ranges.map((r) => new Range(r.from, r.to)) : [new Range(0, 0)];
1638
+ return this.createParse(input, fragments || [], ranges);
1639
+ }
1640
+ /**
1641
+ Run a full parse, returning the resulting tree.
1642
+ */
1643
+ parse(input, fragments, ranges) {
1644
+ let parse = this.startParse(input, fragments, ranges);
1645
+ for (; ; ) {
1646
+ let done = parse.advance();
1647
+ if (done)
1648
+ return done;
1649
+ }
1650
+ }
1651
+ };
1652
+ var StringInput = class {
1653
+ constructor(string2) {
1654
+ this.string = string2;
1655
+ }
1656
+ get length() {
1657
+ return this.string.length;
1658
+ }
1659
+ chunk(from) {
1660
+ return this.string.slice(from);
1661
+ }
1662
+ get lineChunks() {
1663
+ return false;
1664
+ }
1665
+ read(from, to) {
1666
+ return this.string.slice(from, to);
1667
+ }
1668
+ };
1669
+ function parseMixed(nest) {
1670
+ return (parse, input, fragments, ranges) => new MixedParse(parse, nest, input, fragments, ranges);
1671
+ }
1672
+ var InnerParse = class {
1673
+ constructor(parser, parse, overlay, bracketed, target, from) {
1674
+ this.parser = parser;
1675
+ this.parse = parse;
1676
+ this.overlay = overlay;
1677
+ this.bracketed = bracketed;
1678
+ this.target = target;
1679
+ this.from = from;
1680
+ }
1681
+ };
1682
+ function checkRanges(ranges) {
1683
+ if (!ranges.length || ranges.some((r) => r.from >= r.to))
1684
+ throw new RangeError("Invalid inner parse ranges given: " + JSON.stringify(ranges));
1685
+ }
1686
+ var ActiveOverlay = class {
1687
+ constructor(parser, predicate, mounts, index, start, bracketed, target, prev) {
1688
+ this.parser = parser;
1689
+ this.predicate = predicate;
1690
+ this.mounts = mounts;
1691
+ this.index = index;
1692
+ this.start = start;
1693
+ this.bracketed = bracketed;
1694
+ this.target = target;
1695
+ this.prev = prev;
1696
+ this.depth = 0;
1697
+ this.ranges = [];
1698
+ }
1699
+ };
1700
+ var stoppedInner = new NodeProp({ perNode: true });
1701
+ var MixedParse = class {
1702
+ constructor(base, nest, input, fragments, ranges) {
1703
+ this.nest = nest;
1704
+ this.input = input;
1705
+ this.fragments = fragments;
1706
+ this.ranges = ranges;
1707
+ this.inner = [];
1708
+ this.innerDone = 0;
1709
+ this.baseTree = null;
1710
+ this.stoppedAt = null;
1711
+ this.baseParse = base;
1712
+ }
1713
+ advance() {
1714
+ if (this.baseParse) {
1715
+ let done2 = this.baseParse.advance();
1716
+ if (!done2)
1717
+ return null;
1718
+ this.baseParse = null;
1719
+ this.baseTree = done2;
1720
+ this.startInner();
1721
+ if (this.stoppedAt != null)
1722
+ for (let inner2 of this.inner)
1723
+ inner2.parse.stopAt(this.stoppedAt);
1724
+ }
1725
+ if (this.innerDone == this.inner.length) {
1726
+ let result = this.baseTree;
1727
+ if (this.stoppedAt != null)
1728
+ result = new Tree(result.type, result.children, result.positions, result.length, result.propValues.concat([[stoppedInner, this.stoppedAt]]));
1729
+ return result;
1730
+ }
1731
+ let inner = this.inner[this.innerDone], done = inner.parse.advance();
1732
+ if (done) {
1733
+ this.innerDone++;
1734
+ let props = Object.assign(/* @__PURE__ */ Object.create(null), inner.target.props);
1735
+ props[NodeProp.mounted.id] = new MountedTree(done, inner.overlay, inner.parser, inner.bracketed);
1736
+ inner.target.props = props;
1737
+ }
1738
+ return null;
1739
+ }
1740
+ get parsedPos() {
1741
+ if (this.baseParse)
1742
+ return 0;
1743
+ let pos = this.input.length;
1744
+ for (let i = this.innerDone; i < this.inner.length; i++) {
1745
+ if (this.inner[i].from < pos)
1746
+ pos = Math.min(pos, this.inner[i].parse.parsedPos);
1747
+ }
1748
+ return pos;
1749
+ }
1750
+ stopAt(pos) {
1751
+ this.stoppedAt = pos;
1752
+ if (this.baseParse)
1753
+ this.baseParse.stopAt(pos);
1754
+ else
1755
+ for (let i = this.innerDone; i < this.inner.length; i++)
1756
+ this.inner[i].parse.stopAt(pos);
1757
+ }
1758
+ startInner() {
1759
+ let fragmentCursor = new FragmentCursor(this.fragments);
1760
+ let overlay = null;
1761
+ let covered = null;
1762
+ let cursor = new TreeCursor(new TreeNode(this.baseTree, this.ranges[0].from, 0, null), IterMode.IncludeAnonymous | IterMode.IgnoreMounts);
1763
+ scan: for (let nest, isCovered; ; ) {
1764
+ let enter = true, range;
1765
+ if (this.stoppedAt != null && cursor.from >= this.stoppedAt) {
1766
+ enter = false;
1767
+ } else if (fragmentCursor.hasNode(cursor)) {
1768
+ if (overlay) {
1769
+ let match = overlay.mounts.find((m) => m.frag.from <= cursor.from && m.frag.to >= cursor.to && m.mount.overlay);
1770
+ if (match)
1771
+ for (let r of match.mount.overlay) {
1772
+ let from = r.from + match.pos, to = r.to + match.pos;
1773
+ if (from >= cursor.from && to <= cursor.to && !overlay.ranges.some((r2) => r2.from < to && r2.to > from))
1774
+ overlay.ranges.push({ from, to });
1775
+ }
1776
+ }
1777
+ enter = false;
1778
+ } else if (covered && (isCovered = checkCover(covered.ranges, cursor.from, cursor.to))) {
1779
+ enter = isCovered != 2;
1780
+ } else if (!cursor.type.isAnonymous && (nest = this.nest(cursor, this.input)) && (cursor.from < cursor.to || !nest.overlay)) {
1781
+ if (!cursor.tree) {
1782
+ materialize(cursor);
1783
+ if (overlay)
1784
+ overlay.depth++;
1785
+ if (covered)
1786
+ covered.depth++;
1787
+ }
1788
+ let oldMounts = fragmentCursor.findMounts(cursor.from, nest.parser);
1789
+ if (typeof nest.overlay == "function") {
1790
+ overlay = new ActiveOverlay(nest.parser, nest.overlay, oldMounts, this.inner.length, cursor.from, !!nest.bracketed, cursor.tree, overlay);
1791
+ } else {
1792
+ let ranges = punchRanges(this.ranges, nest.overlay || (cursor.from < cursor.to ? [new Range(cursor.from, cursor.to)] : []));
1793
+ if (ranges.length)
1794
+ checkRanges(ranges);
1795
+ if (ranges.length || !nest.overlay)
1796
+ this.inner.push(new InnerParse(nest.parser, ranges.length ? nest.parser.startParse(this.input, enterFragments(oldMounts, ranges), ranges) : nest.parser.startParse(""), nest.overlay ? nest.overlay.map((r) => new Range(r.from - cursor.from, r.to - cursor.from)) : null, !!nest.bracketed, cursor.tree, ranges.length ? ranges[0].from : cursor.from));
1797
+ if (!nest.overlay)
1798
+ enter = false;
1799
+ else if (ranges.length)
1800
+ covered = { ranges, depth: 0, prev: covered };
1801
+ }
1802
+ } else if (overlay && (range = overlay.predicate(cursor))) {
1803
+ if (range === true)
1804
+ range = new Range(cursor.from, cursor.to);
1805
+ if (range.from < range.to) {
1806
+ let last = overlay.ranges.length - 1;
1807
+ if (last >= 0 && overlay.ranges[last].to == range.from)
1808
+ overlay.ranges[last] = { from: overlay.ranges[last].from, to: range.to };
1809
+ else
1810
+ overlay.ranges.push(range);
1811
+ }
1812
+ }
1813
+ if (enter && cursor.firstChild()) {
1814
+ if (overlay)
1815
+ overlay.depth++;
1816
+ if (covered)
1817
+ covered.depth++;
1818
+ } else {
1819
+ for (; ; ) {
1820
+ if (cursor.nextSibling())
1821
+ break;
1822
+ if (!cursor.parent())
1823
+ break scan;
1824
+ if (overlay && !--overlay.depth) {
1825
+ let ranges = punchRanges(this.ranges, overlay.ranges);
1826
+ if (ranges.length) {
1827
+ checkRanges(ranges);
1828
+ this.inner.splice(overlay.index, 0, new InnerParse(overlay.parser, overlay.parser.startParse(this.input, enterFragments(overlay.mounts, ranges), ranges), overlay.ranges.map((r) => new Range(r.from - overlay.start, r.to - overlay.start)), overlay.bracketed, overlay.target, ranges[0].from));
1829
+ }
1830
+ overlay = overlay.prev;
1831
+ }
1832
+ if (covered && !--covered.depth)
1833
+ covered = covered.prev;
1834
+ }
1835
+ }
1836
+ }
1837
+ }
1838
+ };
1839
+ function checkCover(covered, from, to) {
1840
+ for (let range of covered) {
1841
+ if (range.from >= to)
1842
+ break;
1843
+ if (range.to > from)
1844
+ return range.from <= from && range.to >= to ? 2 : 1;
1845
+ }
1846
+ return 0;
1847
+ }
1848
+ function sliceBuf(buf, startI, endI, nodes, positions, off) {
1849
+ if (startI < endI) {
1850
+ let from = buf.buffer[startI + 1];
1851
+ nodes.push(buf.slice(startI, endI, from));
1852
+ positions.push(from - off);
1853
+ }
1854
+ }
1855
+ function materialize(cursor) {
1856
+ let { node } = cursor, stack = [];
1857
+ let buffer = node.context.buffer;
1858
+ do {
1859
+ stack.push(cursor.index);
1860
+ cursor.parent();
1861
+ } while (!cursor.tree);
1862
+ let base = cursor.tree, i = base.children.indexOf(buffer);
1863
+ let buf = base.children[i], b = buf.buffer, newStack = [i];
1864
+ function split(startI, endI, type, innerOffset, length, stackPos) {
1865
+ let targetI = stack[stackPos];
1866
+ let children = [], positions = [];
1867
+ sliceBuf(buf, startI, targetI, children, positions, innerOffset);
1868
+ let from = b[targetI + 1], to = b[targetI + 2];
1869
+ newStack.push(children.length);
1870
+ let child = stackPos ? split(targetI + 4, b[targetI + 3], buf.set.types[b[targetI]], from, to - from, stackPos - 1) : node.toTree();
1871
+ children.push(child);
1872
+ positions.push(from - innerOffset);
1873
+ sliceBuf(buf, b[targetI + 3], endI, children, positions, innerOffset);
1874
+ return new Tree(type, children, positions, length);
1875
+ }
1876
+ base.children[i] = split(0, b.length, NodeType.none, 0, buf.length, stack.length - 1);
1877
+ for (let index of newStack) {
1878
+ let tree = cursor.tree.children[index], pos = cursor.tree.positions[index];
1879
+ cursor.yield(new TreeNode(tree, pos + cursor.from, index, cursor._tree));
1880
+ }
1881
+ }
1882
+ var StructureCursor = class {
1883
+ constructor(root, offset) {
1884
+ this.offset = offset;
1885
+ this.done = false;
1886
+ this.cursor = root.cursor(IterMode.IncludeAnonymous | IterMode.IgnoreMounts);
1887
+ }
1888
+ // Move to the first node (in pre-order) that starts at or after `pos`.
1889
+ moveTo(pos) {
1890
+ let { cursor } = this, p = pos - this.offset;
1891
+ while (!this.done && cursor.from < p) {
1892
+ if (cursor.to >= pos && cursor.enter(p, 1, IterMode.IgnoreOverlays | IterMode.ExcludeBuffers)) ;
1893
+ else if (cursor.to <= pos) {
1894
+ if (!cursor.next(false))
1895
+ this.done = true;
1896
+ } else {
1897
+ break;
1898
+ }
1899
+ }
1900
+ }
1901
+ hasNode(cursor) {
1902
+ this.moveTo(cursor.from);
1903
+ if (!this.done && this.cursor.from + this.offset == cursor.from && this.cursor.tree) {
1904
+ for (let tree = this.cursor.tree; ; ) {
1905
+ if (tree == cursor.tree)
1906
+ return true;
1907
+ if (tree.children.length && tree.positions[0] == 0 && tree.children[0] instanceof Tree)
1908
+ tree = tree.children[0];
1909
+ else
1910
+ break;
1911
+ }
1912
+ }
1913
+ return false;
1914
+ }
1915
+ };
1916
+ var FragmentCursor = class {
1917
+ constructor(fragments) {
1918
+ var _a2;
1919
+ this.fragments = fragments;
1920
+ this.curTo = 0;
1921
+ this.fragI = 0;
1922
+ if (fragments.length) {
1923
+ let first = this.curFrag = fragments[0];
1924
+ this.curTo = (_a2 = first.tree.prop(stoppedInner)) !== null && _a2 !== void 0 ? _a2 : first.to;
1925
+ this.inner = new StructureCursor(first.tree, -first.offset);
1926
+ } else {
1927
+ this.curFrag = this.inner = null;
1928
+ }
1929
+ }
1930
+ hasNode(node) {
1931
+ while (this.curFrag && node.from >= this.curTo)
1932
+ this.nextFrag();
1933
+ return this.curFrag && this.curFrag.from <= node.from && this.curTo >= node.to && this.inner.hasNode(node);
1934
+ }
1935
+ nextFrag() {
1936
+ var _a2;
1937
+ this.fragI++;
1938
+ if (this.fragI == this.fragments.length) {
1939
+ this.curFrag = this.inner = null;
1940
+ } else {
1941
+ let frag = this.curFrag = this.fragments[this.fragI];
1942
+ this.curTo = (_a2 = frag.tree.prop(stoppedInner)) !== null && _a2 !== void 0 ? _a2 : frag.to;
1943
+ this.inner = new StructureCursor(frag.tree, -frag.offset);
1944
+ }
1945
+ }
1946
+ findMounts(pos, parser) {
1947
+ var _a2;
1948
+ let result = [];
1949
+ if (this.inner) {
1950
+ this.inner.cursor.moveTo(pos, 1);
1951
+ for (let pos2 = this.inner.cursor.node; pos2; pos2 = pos2.parent) {
1952
+ let mount = (_a2 = pos2.tree) === null || _a2 === void 0 ? void 0 : _a2.prop(NodeProp.mounted);
1953
+ if (mount && mount.parser == parser) {
1954
+ for (let i = this.fragI; i < this.fragments.length; i++) {
1955
+ let frag = this.fragments[i];
1956
+ if (frag.from >= pos2.to)
1957
+ break;
1958
+ if (frag.tree == this.curFrag.tree)
1959
+ result.push({
1960
+ frag,
1961
+ pos: pos2.from - frag.offset,
1962
+ mount
1963
+ });
1964
+ }
1965
+ }
1966
+ }
1967
+ }
1968
+ return result;
1969
+ }
1970
+ };
1971
+ function punchRanges(outer, ranges) {
1972
+ let copy = null, current = ranges;
1973
+ for (let i = 1, j = 0; i < outer.length; i++) {
1974
+ let gapFrom = outer[i - 1].to, gapTo = outer[i].from;
1975
+ for (; j < current.length; j++) {
1976
+ let r = current[j];
1977
+ if (r.from >= gapTo)
1978
+ break;
1979
+ if (r.to <= gapFrom)
1980
+ continue;
1981
+ if (!copy)
1982
+ current = copy = ranges.slice();
1983
+ if (r.from < gapFrom) {
1984
+ copy[j] = new Range(r.from, gapFrom);
1985
+ if (r.to > gapTo)
1986
+ copy.splice(j + 1, 0, new Range(gapTo, r.to));
1987
+ } else if (r.to > gapTo) {
1988
+ copy[j--] = new Range(gapTo, r.to);
1989
+ } else {
1990
+ copy.splice(j--, 1);
1991
+ }
1992
+ }
1993
+ }
1994
+ return current;
1995
+ }
1996
+ function findCoverChanges(a, b, from, to) {
1997
+ let iA = 0, iB = 0, inA = false, inB = false, pos = -1e9;
1998
+ let result = [];
1999
+ for (; ; ) {
2000
+ let nextA = iA == a.length ? 1e9 : inA ? a[iA].to : a[iA].from;
2001
+ let nextB = iB == b.length ? 1e9 : inB ? b[iB].to : b[iB].from;
2002
+ if (inA != inB) {
2003
+ let start = Math.max(pos, from), end = Math.min(nextA, nextB, to);
2004
+ if (start < end)
2005
+ result.push(new Range(start, end));
2006
+ }
2007
+ pos = Math.min(nextA, nextB);
2008
+ if (pos == 1e9)
2009
+ break;
2010
+ if (nextA == pos) {
2011
+ if (!inA)
2012
+ inA = true;
2013
+ else {
2014
+ inA = false;
2015
+ iA++;
2016
+ }
2017
+ }
2018
+ if (nextB == pos) {
2019
+ if (!inB)
2020
+ inB = true;
2021
+ else {
2022
+ inB = false;
2023
+ iB++;
2024
+ }
2025
+ }
2026
+ }
2027
+ return result;
2028
+ }
2029
+ function enterFragments(mounts, ranges) {
2030
+ let result = [];
2031
+ for (let { pos, mount, frag } of mounts) {
2032
+ let startPos = pos + (mount.overlay ? mount.overlay[0].from : 0), endPos = startPos + mount.tree.length;
2033
+ let from = Math.max(frag.from, startPos), to = Math.min(frag.to, endPos);
2034
+ if (mount.overlay) {
2035
+ let overlay = mount.overlay.map((r) => new Range(r.from + pos, r.to + pos));
2036
+ let changes = findCoverChanges(ranges, overlay, from, to);
2037
+ for (let i = 0, pos2 = from; ; i++) {
2038
+ let last = i == changes.length, end = last ? to : changes[i].from;
2039
+ if (end > pos2)
2040
+ result.push(new TreeFragment(pos2, end, mount.tree, -startPos, frag.from >= pos2 || frag.openStart, frag.to <= end || frag.openEnd));
2041
+ if (last)
2042
+ break;
2043
+ pos2 = changes[i].to;
2044
+ }
2045
+ } else {
2046
+ result.push(new TreeFragment(from, to, mount.tree, -startPos, frag.from >= startPos || frag.openStart, frag.to <= endPos || frag.openEnd));
2047
+ }
2048
+ }
2049
+ return result;
2050
+ }
2051
+
2052
+ // ../node_modules/.pnpm/@lezer+highlight@1.2.3/node_modules/@lezer/highlight/dist/index.js
2053
+ var nextTagID = 0;
2054
+ var Tag = class _Tag {
2055
+ /**
2056
+ @internal
2057
+ */
2058
+ constructor(name2, set, base, modified) {
2059
+ this.name = name2;
2060
+ this.set = set;
2061
+ this.base = base;
2062
+ this.modified = modified;
2063
+ this.id = nextTagID++;
2064
+ }
2065
+ toString() {
2066
+ let { name: name2 } = this;
2067
+ for (let mod of this.modified)
2068
+ if (mod.name)
2069
+ name2 = `${mod.name}(${name2})`;
2070
+ return name2;
2071
+ }
2072
+ static define(nameOrParent, parent) {
2073
+ let name2 = typeof nameOrParent == "string" ? nameOrParent : "?";
2074
+ if (nameOrParent instanceof _Tag)
2075
+ parent = nameOrParent;
2076
+ if (parent === null || parent === void 0 ? void 0 : parent.base)
2077
+ throw new Error("Can not derive from a modified tag");
2078
+ let tag = new _Tag(name2, [], null, []);
2079
+ tag.set.push(tag);
2080
+ if (parent)
2081
+ for (let t2 of parent.set)
2082
+ tag.set.push(t2);
2083
+ return tag;
2084
+ }
2085
+ /**
2086
+ Define a tag _modifier_, which is a function that, given a tag,
2087
+ will return a tag that is a subtag of the original. Applying the
2088
+ same modifier to a twice tag will return the same value (`m1(t1)
2089
+ == m1(t1)`) and applying multiple modifiers will, regardless or
2090
+ order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
2091
+
2092
+ When multiple modifiers are applied to a given base tag, each
2093
+ smaller set of modifiers is registered as a parent, so that for
2094
+ example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
2095
+ `m1(m3(t1)`, and so on.
2096
+ */
2097
+ static defineModifier(name2) {
2098
+ let mod = new Modifier(name2);
2099
+ return (tag) => {
2100
+ if (tag.modified.indexOf(mod) > -1)
2101
+ return tag;
2102
+ return Modifier.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));
2103
+ };
2104
+ }
2105
+ };
2106
+ var nextModifierID = 0;
2107
+ var Modifier = class _Modifier {
2108
+ constructor(name2) {
2109
+ this.name = name2;
2110
+ this.instances = [];
2111
+ this.id = nextModifierID++;
2112
+ }
2113
+ static get(base, mods) {
2114
+ if (!mods.length)
2115
+ return base;
2116
+ let exists = mods[0].instances.find((t2) => t2.base == base && sameArray(mods, t2.modified));
2117
+ if (exists)
2118
+ return exists;
2119
+ let set = [], tag = new Tag(base.name, set, base, mods);
2120
+ for (let m of mods)
2121
+ m.instances.push(tag);
2122
+ let configs = powerSet(mods);
2123
+ for (let parent of base.set)
2124
+ if (!parent.modified.length)
2125
+ for (let config of configs)
2126
+ set.push(_Modifier.get(parent, config));
2127
+ return tag;
2128
+ }
2129
+ };
2130
+ function sameArray(a, b) {
2131
+ return a.length == b.length && a.every((x, i) => x == b[i]);
2132
+ }
2133
+ function powerSet(array) {
2134
+ let sets = [[]];
2135
+ for (let i = 0; i < array.length; i++) {
2136
+ for (let j = 0, e = sets.length; j < e; j++) {
2137
+ sets.push(sets[j].concat(array[i]));
2138
+ }
2139
+ }
2140
+ return sets.sort((a, b) => b.length - a.length);
2141
+ }
2142
+ function styleTags(spec) {
2143
+ let byName = /* @__PURE__ */ Object.create(null);
2144
+ for (let prop in spec) {
2145
+ let tags2 = spec[prop];
2146
+ if (!Array.isArray(tags2))
2147
+ tags2 = [tags2];
2148
+ for (let part of prop.split(" "))
2149
+ if (part) {
2150
+ let pieces = [], mode = 2, rest = part;
2151
+ for (let pos = 0; ; ) {
2152
+ if (rest == "..." && pos > 0 && pos + 3 == part.length) {
2153
+ mode = 1;
2154
+ break;
2155
+ }
2156
+ let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
2157
+ if (!m)
2158
+ throw new RangeError("Invalid path: " + part);
2159
+ pieces.push(m[0] == "*" ? "" : m[0][0] == '"' ? JSON.parse(m[0]) : m[0]);
2160
+ pos += m[0].length;
2161
+ if (pos == part.length)
2162
+ break;
2163
+ let next = part[pos++];
2164
+ if (pos == part.length && next == "!") {
2165
+ mode = 0;
2166
+ break;
2167
+ }
2168
+ if (next != "/")
2169
+ throw new RangeError("Invalid path: " + part);
2170
+ rest = part.slice(pos);
2171
+ }
2172
+ let last = pieces.length - 1, inner = pieces[last];
2173
+ if (!inner)
2174
+ throw new RangeError("Invalid path: " + part);
2175
+ let rule = new Rule(tags2, mode, last > 0 ? pieces.slice(0, last) : null);
2176
+ byName[inner] = rule.sort(byName[inner]);
2177
+ }
2178
+ }
2179
+ return ruleNodeProp.add(byName);
2180
+ }
2181
+ var ruleNodeProp = new NodeProp({
2182
+ combine(a, b) {
2183
+ let cur, root, take;
2184
+ while (a || b) {
2185
+ if (!a || b && a.depth >= b.depth) {
2186
+ take = b;
2187
+ b = b.next;
2188
+ } else {
2189
+ take = a;
2190
+ a = a.next;
2191
+ }
2192
+ if (cur && cur.mode == take.mode && !take.context && !cur.context)
2193
+ continue;
2194
+ let copy = new Rule(take.tags, take.mode, take.context);
2195
+ if (cur)
2196
+ cur.next = copy;
2197
+ else
2198
+ root = copy;
2199
+ cur = copy;
2200
+ }
2201
+ return root;
2202
+ }
2203
+ });
2204
+ var Rule = class {
2205
+ constructor(tags2, mode, context, next) {
2206
+ this.tags = tags2;
2207
+ this.mode = mode;
2208
+ this.context = context;
2209
+ this.next = next;
2210
+ }
2211
+ get opaque() {
2212
+ return this.mode == 0;
2213
+ }
2214
+ get inherit() {
2215
+ return this.mode == 1;
2216
+ }
2217
+ sort(other) {
2218
+ if (!other || other.depth < this.depth) {
2219
+ this.next = other;
2220
+ return this;
2221
+ }
2222
+ other.next = this.sort(other.next);
2223
+ return other;
2224
+ }
2225
+ get depth() {
2226
+ return this.context ? this.context.length : 0;
2227
+ }
2228
+ };
2229
+ Rule.empty = new Rule([], 2, null);
2230
+ function tagHighlighter(tags2, options) {
2231
+ let map = /* @__PURE__ */ Object.create(null);
2232
+ for (let style of tags2) {
2233
+ if (!Array.isArray(style.tag))
2234
+ map[style.tag.id] = style.class;
2235
+ else
2236
+ for (let tag of style.tag)
2237
+ map[tag.id] = style.class;
2238
+ }
2239
+ let { scope, all = null } = options || {};
2240
+ return {
2241
+ style: (tags3) => {
2242
+ let cls = all;
2243
+ for (let tag of tags3) {
2244
+ for (let sub of tag.set) {
2245
+ let tagClass = map[sub.id];
2246
+ if (tagClass) {
2247
+ cls = cls ? cls + " " + tagClass : tagClass;
2248
+ break;
2249
+ }
2250
+ }
2251
+ }
2252
+ return cls;
2253
+ },
2254
+ scope
2255
+ };
2256
+ }
2257
+ function highlightTags(highlighters, tags2) {
2258
+ let result = null;
2259
+ for (let highlighter of highlighters) {
2260
+ let value = highlighter.style(tags2);
2261
+ if (value)
2262
+ result = result ? result + " " + value : value;
2263
+ }
2264
+ return result;
2265
+ }
2266
+ function highlightTree(tree, highlighter, putStyle, from = 0, to = tree.length) {
2267
+ let builder = new HighlightBuilder(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);
2268
+ builder.highlightRange(tree.cursor(), from, to, "", builder.highlighters);
2269
+ builder.flush(to);
2270
+ }
2271
+ var HighlightBuilder = class {
2272
+ constructor(at, highlighters, span) {
2273
+ this.at = at;
2274
+ this.highlighters = highlighters;
2275
+ this.span = span;
2276
+ this.class = "";
2277
+ }
2278
+ startSpan(at, cls) {
2279
+ if (cls != this.class) {
2280
+ this.flush(at);
2281
+ if (at > this.at)
2282
+ this.at = at;
2283
+ this.class = cls;
2284
+ }
2285
+ }
2286
+ flush(to) {
2287
+ if (to > this.at && this.class)
2288
+ this.span(this.at, to, this.class);
2289
+ }
2290
+ highlightRange(cursor, from, to, inheritedClass, highlighters) {
2291
+ let { type, from: start, to: end } = cursor;
2292
+ if (start >= to || end <= from)
2293
+ return;
2294
+ if (type.isTop)
2295
+ highlighters = this.highlighters.filter((h) => !h.scope || h.scope(type));
2296
+ let cls = inheritedClass;
2297
+ let rule = getStyleTags(cursor) || Rule.empty;
2298
+ let tagCls = highlightTags(highlighters, rule.tags);
2299
+ if (tagCls) {
2300
+ if (cls)
2301
+ cls += " ";
2302
+ cls += tagCls;
2303
+ if (rule.mode == 1)
2304
+ inheritedClass += (inheritedClass ? " " : "") + tagCls;
2305
+ }
2306
+ this.startSpan(Math.max(from, start), cls);
2307
+ if (rule.opaque)
2308
+ return;
2309
+ let mounted = cursor.tree && cursor.tree.prop(NodeProp.mounted);
2310
+ if (mounted && mounted.overlay) {
2311
+ let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);
2312
+ let innerHighlighters = this.highlighters.filter((h) => !h.scope || h.scope(mounted.tree.type));
2313
+ let hasChild2 = cursor.firstChild();
2314
+ for (let i = 0, pos = start; ; i++) {
2315
+ let next = i < mounted.overlay.length ? mounted.overlay[i] : null;
2316
+ let nextPos = next ? next.from + start : end;
2317
+ let rangeFrom = Math.max(from, pos), rangeTo = Math.min(to, nextPos);
2318
+ if (rangeFrom < rangeTo && hasChild2) {
2319
+ while (cursor.from < rangeTo) {
2320
+ this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);
2321
+ this.startSpan(Math.min(rangeTo, cursor.to), cls);
2322
+ if (cursor.to >= nextPos || !cursor.nextSibling())
2323
+ break;
2324
+ }
2325
+ }
2326
+ if (!next || nextPos > to)
2327
+ break;
2328
+ pos = next.to + start;
2329
+ if (pos > from) {
2330
+ this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), "", innerHighlighters);
2331
+ this.startSpan(Math.min(to, pos), cls);
2332
+ }
2333
+ }
2334
+ if (hasChild2)
2335
+ cursor.parent();
2336
+ } else if (cursor.firstChild()) {
2337
+ if (mounted)
2338
+ inheritedClass = "";
2339
+ do {
2340
+ if (cursor.to <= from)
2341
+ continue;
2342
+ if (cursor.from >= to)
2343
+ break;
2344
+ this.highlightRange(cursor, from, to, inheritedClass, highlighters);
2345
+ this.startSpan(Math.min(to, cursor.to), cls);
2346
+ } while (cursor.nextSibling());
2347
+ cursor.parent();
2348
+ }
2349
+ }
2350
+ };
2351
+ function getStyleTags(node) {
2352
+ let rule = node.type.prop(ruleNodeProp);
2353
+ while (rule && rule.context && !node.matchContext(rule.context))
2354
+ rule = rule.next;
2355
+ return rule || null;
2356
+ }
2357
+ var t = Tag.define;
2358
+ var comment = t();
2359
+ var name = t();
2360
+ var typeName = t(name);
2361
+ var propertyName = t(name);
2362
+ var literal = t();
2363
+ var string = t(literal);
2364
+ var number = t(literal);
2365
+ var content = t();
2366
+ var heading = t(content);
2367
+ var keyword = t();
2368
+ var operator = t();
2369
+ var punctuation = t();
2370
+ var bracket = t(punctuation);
2371
+ var meta = t();
2372
+ var tags = {
2373
+ /**
2374
+ A comment.
2375
+ */
2376
+ comment,
2377
+ /**
2378
+ A line [comment](#highlight.tags.comment).
2379
+ */
2380
+ lineComment: t(comment),
2381
+ /**
2382
+ A block [comment](#highlight.tags.comment).
2383
+ */
2384
+ blockComment: t(comment),
2385
+ /**
2386
+ A documentation [comment](#highlight.tags.comment).
2387
+ */
2388
+ docComment: t(comment),
2389
+ /**
2390
+ Any kind of identifier.
2391
+ */
2392
+ name,
2393
+ /**
2394
+ The [name](#highlight.tags.name) of a variable.
2395
+ */
2396
+ variableName: t(name),
2397
+ /**
2398
+ A type [name](#highlight.tags.name).
2399
+ */
2400
+ typeName,
2401
+ /**
2402
+ A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
2403
+ */
2404
+ tagName: t(typeName),
2405
+ /**
2406
+ A property or field [name](#highlight.tags.name).
2407
+ */
2408
+ propertyName,
2409
+ /**
2410
+ An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
2411
+ */
2412
+ attributeName: t(propertyName),
2413
+ /**
2414
+ The [name](#highlight.tags.name) of a class.
2415
+ */
2416
+ className: t(name),
2417
+ /**
2418
+ A label [name](#highlight.tags.name).
2419
+ */
2420
+ labelName: t(name),
2421
+ /**
2422
+ A namespace [name](#highlight.tags.name).
2423
+ */
2424
+ namespace: t(name),
2425
+ /**
2426
+ The [name](#highlight.tags.name) of a macro.
2427
+ */
2428
+ macroName: t(name),
2429
+ /**
2430
+ A literal value.
2431
+ */
2432
+ literal,
2433
+ /**
2434
+ A string [literal](#highlight.tags.literal).
2435
+ */
2436
+ string,
2437
+ /**
2438
+ A documentation [string](#highlight.tags.string).
2439
+ */
2440
+ docString: t(string),
2441
+ /**
2442
+ A character literal (subtag of [string](#highlight.tags.string)).
2443
+ */
2444
+ character: t(string),
2445
+ /**
2446
+ An attribute value (subtag of [string](#highlight.tags.string)).
2447
+ */
2448
+ attributeValue: t(string),
2449
+ /**
2450
+ A number [literal](#highlight.tags.literal).
2451
+ */
2452
+ number,
2453
+ /**
2454
+ An integer [number](#highlight.tags.number) literal.
2455
+ */
2456
+ integer: t(number),
2457
+ /**
2458
+ A floating-point [number](#highlight.tags.number) literal.
2459
+ */
2460
+ float: t(number),
2461
+ /**
2462
+ A boolean [literal](#highlight.tags.literal).
2463
+ */
2464
+ bool: t(literal),
2465
+ /**
2466
+ Regular expression [literal](#highlight.tags.literal).
2467
+ */
2468
+ regexp: t(literal),
2469
+ /**
2470
+ An escape [literal](#highlight.tags.literal), for example a
2471
+ backslash escape in a string.
2472
+ */
2473
+ escape: t(literal),
2474
+ /**
2475
+ A color [literal](#highlight.tags.literal).
2476
+ */
2477
+ color: t(literal),
2478
+ /**
2479
+ A URL [literal](#highlight.tags.literal).
2480
+ */
2481
+ url: t(literal),
2482
+ /**
2483
+ A language keyword.
2484
+ */
2485
+ keyword,
2486
+ /**
2487
+ The [keyword](#highlight.tags.keyword) for the self or this
2488
+ object.
2489
+ */
2490
+ self: t(keyword),
2491
+ /**
2492
+ The [keyword](#highlight.tags.keyword) for null.
2493
+ */
2494
+ null: t(keyword),
2495
+ /**
2496
+ A [keyword](#highlight.tags.keyword) denoting some atomic value.
2497
+ */
2498
+ atom: t(keyword),
2499
+ /**
2500
+ A [keyword](#highlight.tags.keyword) that represents a unit.
2501
+ */
2502
+ unit: t(keyword),
2503
+ /**
2504
+ A modifier [keyword](#highlight.tags.keyword).
2505
+ */
2506
+ modifier: t(keyword),
2507
+ /**
2508
+ A [keyword](#highlight.tags.keyword) that acts as an operator.
2509
+ */
2510
+ operatorKeyword: t(keyword),
2511
+ /**
2512
+ A control-flow related [keyword](#highlight.tags.keyword).
2513
+ */
2514
+ controlKeyword: t(keyword),
2515
+ /**
2516
+ A [keyword](#highlight.tags.keyword) that defines something.
2517
+ */
2518
+ definitionKeyword: t(keyword),
2519
+ /**
2520
+ A [keyword](#highlight.tags.keyword) related to defining or
2521
+ interfacing with modules.
2522
+ */
2523
+ moduleKeyword: t(keyword),
2524
+ /**
2525
+ An operator.
2526
+ */
2527
+ operator,
2528
+ /**
2529
+ An [operator](#highlight.tags.operator) that dereferences something.
2530
+ */
2531
+ derefOperator: t(operator),
2532
+ /**
2533
+ Arithmetic-related [operator](#highlight.tags.operator).
2534
+ */
2535
+ arithmeticOperator: t(operator),
2536
+ /**
2537
+ Logical [operator](#highlight.tags.operator).
2538
+ */
2539
+ logicOperator: t(operator),
2540
+ /**
2541
+ Bit [operator](#highlight.tags.operator).
2542
+ */
2543
+ bitwiseOperator: t(operator),
2544
+ /**
2545
+ Comparison [operator](#highlight.tags.operator).
2546
+ */
2547
+ compareOperator: t(operator),
2548
+ /**
2549
+ [Operator](#highlight.tags.operator) that updates its operand.
2550
+ */
2551
+ updateOperator: t(operator),
2552
+ /**
2553
+ [Operator](#highlight.tags.operator) that defines something.
2554
+ */
2555
+ definitionOperator: t(operator),
2556
+ /**
2557
+ Type-related [operator](#highlight.tags.operator).
2558
+ */
2559
+ typeOperator: t(operator),
2560
+ /**
2561
+ Control-flow [operator](#highlight.tags.operator).
2562
+ */
2563
+ controlOperator: t(operator),
2564
+ /**
2565
+ Program or markup punctuation.
2566
+ */
2567
+ punctuation,
2568
+ /**
2569
+ [Punctuation](#highlight.tags.punctuation) that separates
2570
+ things.
2571
+ */
2572
+ separator: t(punctuation),
2573
+ /**
2574
+ Bracket-style [punctuation](#highlight.tags.punctuation).
2575
+ */
2576
+ bracket,
2577
+ /**
2578
+ Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
2579
+ tokens).
2580
+ */
2581
+ angleBracket: t(bracket),
2582
+ /**
2583
+ Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
2584
+ tokens).
2585
+ */
2586
+ squareBracket: t(bracket),
2587
+ /**
2588
+ Parentheses (usually `(` and `)` tokens). Subtag of
2589
+ [bracket](#highlight.tags.bracket).
2590
+ */
2591
+ paren: t(bracket),
2592
+ /**
2593
+ Braces (usually `{` and `}` tokens). Subtag of
2594
+ [bracket](#highlight.tags.bracket).
2595
+ */
2596
+ brace: t(bracket),
2597
+ /**
2598
+ Content, for example plain text in XML or markup documents.
2599
+ */
2600
+ content,
2601
+ /**
2602
+ [Content](#highlight.tags.content) that represents a heading.
2603
+ */
2604
+ heading,
2605
+ /**
2606
+ A level 1 [heading](#highlight.tags.heading).
2607
+ */
2608
+ heading1: t(heading),
2609
+ /**
2610
+ A level 2 [heading](#highlight.tags.heading).
2611
+ */
2612
+ heading2: t(heading),
2613
+ /**
2614
+ A level 3 [heading](#highlight.tags.heading).
2615
+ */
2616
+ heading3: t(heading),
2617
+ /**
2618
+ A level 4 [heading](#highlight.tags.heading).
2619
+ */
2620
+ heading4: t(heading),
2621
+ /**
2622
+ A level 5 [heading](#highlight.tags.heading).
2623
+ */
2624
+ heading5: t(heading),
2625
+ /**
2626
+ A level 6 [heading](#highlight.tags.heading).
2627
+ */
2628
+ heading6: t(heading),
2629
+ /**
2630
+ A prose [content](#highlight.tags.content) separator (such as a horizontal rule).
2631
+ */
2632
+ contentSeparator: t(content),
2633
+ /**
2634
+ [Content](#highlight.tags.content) that represents a list.
2635
+ */
2636
+ list: t(content),
2637
+ /**
2638
+ [Content](#highlight.tags.content) that represents a quote.
2639
+ */
2640
+ quote: t(content),
2641
+ /**
2642
+ [Content](#highlight.tags.content) that is emphasized.
2643
+ */
2644
+ emphasis: t(content),
2645
+ /**
2646
+ [Content](#highlight.tags.content) that is styled strong.
2647
+ */
2648
+ strong: t(content),
2649
+ /**
2650
+ [Content](#highlight.tags.content) that is part of a link.
2651
+ */
2652
+ link: t(content),
2653
+ /**
2654
+ [Content](#highlight.tags.content) that is styled as code or
2655
+ monospace.
2656
+ */
2657
+ monospace: t(content),
2658
+ /**
2659
+ [Content](#highlight.tags.content) that has a strike-through
2660
+ style.
2661
+ */
2662
+ strikethrough: t(content),
2663
+ /**
2664
+ Inserted text in a change-tracking format.
2665
+ */
2666
+ inserted: t(),
2667
+ /**
2668
+ Deleted text.
2669
+ */
2670
+ deleted: t(),
2671
+ /**
2672
+ Changed text.
2673
+ */
2674
+ changed: t(),
2675
+ /**
2676
+ An invalid or unsyntactic element.
2677
+ */
2678
+ invalid: t(),
2679
+ /**
2680
+ Metadata or meta-instruction.
2681
+ */
2682
+ meta,
2683
+ /**
2684
+ [Metadata](#highlight.tags.meta) that applies to the entire
2685
+ document.
2686
+ */
2687
+ documentMeta: t(meta),
2688
+ /**
2689
+ [Metadata](#highlight.tags.meta) that annotates or adds
2690
+ attributes to a given syntactic element.
2691
+ */
2692
+ annotation: t(meta),
2693
+ /**
2694
+ Processing instruction or preprocessor directive. Subtag of
2695
+ [meta](#highlight.tags.meta).
2696
+ */
2697
+ processingInstruction: t(meta),
2698
+ /**
2699
+ [Modifier](#highlight.Tag^defineModifier) that indicates that a
2700
+ given element is being defined. Expected to be used with the
2701
+ various [name](#highlight.tags.name) tags.
2702
+ */
2703
+ definition: Tag.defineModifier("definition"),
2704
+ /**
2705
+ [Modifier](#highlight.Tag^defineModifier) that indicates that
2706
+ something is constant. Mostly expected to be used with
2707
+ [variable names](#highlight.tags.variableName).
2708
+ */
2709
+ constant: Tag.defineModifier("constant"),
2710
+ /**
2711
+ [Modifier](#highlight.Tag^defineModifier) used to indicate that
2712
+ a [variable](#highlight.tags.variableName) or [property
2713
+ name](#highlight.tags.propertyName) is being called or defined
2714
+ as a function.
2715
+ */
2716
+ function: Tag.defineModifier("function"),
2717
+ /**
2718
+ [Modifier](#highlight.Tag^defineModifier) that can be applied to
2719
+ [names](#highlight.tags.name) to indicate that they belong to
2720
+ the language's standard environment.
2721
+ */
2722
+ standard: Tag.defineModifier("standard"),
2723
+ /**
2724
+ [Modifier](#highlight.Tag^defineModifier) that indicates a given
2725
+ [names](#highlight.tags.name) is local to some scope.
2726
+ */
2727
+ local: Tag.defineModifier("local"),
2728
+ /**
2729
+ A generic variant [modifier](#highlight.Tag^defineModifier) that
2730
+ can be used to tag language-specific alternative variants of
2731
+ some common tag. It is recommended for themes to define special
2732
+ forms of at least the [string](#highlight.tags.string) and
2733
+ [variable name](#highlight.tags.variableName) tags, since those
2734
+ come up a lot.
2735
+ */
2736
+ special: Tag.defineModifier("special")
2737
+ };
2738
+ for (let name2 in tags) {
2739
+ let val = tags[name2];
2740
+ if (val instanceof Tag)
2741
+ val.name = name2;
2742
+ }
2743
+ var classHighlighter = tagHighlighter([
2744
+ { tag: tags.link, class: "tok-link" },
2745
+ { tag: tags.heading, class: "tok-heading" },
2746
+ { tag: tags.emphasis, class: "tok-emphasis" },
2747
+ { tag: tags.strong, class: "tok-strong" },
2748
+ { tag: tags.keyword, class: "tok-keyword" },
2749
+ { tag: tags.atom, class: "tok-atom" },
2750
+ { tag: tags.bool, class: "tok-bool" },
2751
+ { tag: tags.url, class: "tok-url" },
2752
+ { tag: tags.labelName, class: "tok-labelName" },
2753
+ { tag: tags.inserted, class: "tok-inserted" },
2754
+ { tag: tags.deleted, class: "tok-deleted" },
2755
+ { tag: tags.literal, class: "tok-literal" },
2756
+ { tag: tags.string, class: "tok-string" },
2757
+ { tag: tags.number, class: "tok-number" },
2758
+ { tag: [tags.regexp, tags.escape, tags.special(tags.string)], class: "tok-string2" },
2759
+ { tag: tags.variableName, class: "tok-variableName" },
2760
+ { tag: tags.local(tags.variableName), class: "tok-variableName tok-local" },
2761
+ { tag: tags.definition(tags.variableName), class: "tok-variableName tok-definition" },
2762
+ { tag: tags.special(tags.variableName), class: "tok-variableName2" },
2763
+ { tag: tags.definition(tags.propertyName), class: "tok-propertyName tok-definition" },
2764
+ { tag: tags.typeName, class: "tok-typeName" },
2765
+ { tag: tags.namespace, class: "tok-namespace" },
2766
+ { tag: tags.className, class: "tok-className" },
2767
+ { tag: tags.macroName, class: "tok-macroName" },
2768
+ { tag: tags.propertyName, class: "tok-propertyName" },
2769
+ { tag: tags.operator, class: "tok-operator" },
2770
+ { tag: tags.comment, class: "tok-comment" },
2771
+ { tag: tags.meta, class: "tok-meta" },
2772
+ { tag: tags.invalid, class: "tok-invalid" },
2773
+ { tag: tags.punctuation, class: "tok-punctuation" }
2774
+ ]);
2775
+
2776
+ // ../node_modules/.pnpm/@codemirror+language@6.12.4/node_modules/@codemirror/language/dist/index.js
2777
+ import { StateEffect, StateField, Facet, EditorState, countColumn, combineConfig, RangeSet, RangeSetBuilder, Prec } from "@codemirror/state";
2778
+ import { ViewPlugin, logException, EditorView, Decoration, WidgetType, gutter, GutterMarker, Direction } from "@codemirror/view";
2779
+
2780
+ // ../node_modules/.pnpm/style-mod@4.1.3/node_modules/style-mod/src/style-mod.js
2781
+ var C = "\u037C";
2782
+ var COUNT = typeof Symbol == "undefined" ? "__" + C : Symbol.for(C);
2783
+ var SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet");
2784
+ var top = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : {};
2785
+ var StyleModule = class {
2786
+ // :: (Object<Style>, ?{finish: ?(string) → string})
2787
+ // Create a style module from the given spec.
2788
+ //
2789
+ // When `finish` is given, it is called on regular (non-`@`)
2790
+ // selectors (after `&` expansion) to compute the final selector.
2791
+ constructor(spec, options) {
2792
+ this.rules = [];
2793
+ let { finish } = options || {};
2794
+ function splitSelector(selector) {
2795
+ return /^@/.test(selector) ? [selector] : selector.split(/,\s*/);
2796
+ }
2797
+ function render(selectors, spec2, target, isKeyframes) {
2798
+ let local = [], isAt = /^@(\w+)\b/.exec(selectors[0]), keyframes = isAt && isAt[1] == "keyframes";
2799
+ if (isAt && spec2 == null) return target.push(selectors[0] + ";");
2800
+ for (let prop in spec2) {
2801
+ let value = spec2[prop];
2802
+ if (/&/.test(prop)) {
2803
+ render(
2804
+ prop.split(/,\s*/).map((part) => selectors.map((sel) => part.replace(/&/, sel))).reduce((a, b) => a.concat(b)),
2805
+ value,
2806
+ target
2807
+ );
2808
+ } else if (value && typeof value == "object") {
2809
+ if (!isAt) throw new RangeError("The value of a property (" + prop + ") should be a primitive value.");
2810
+ render(splitSelector(prop), value, local, keyframes);
2811
+ } else if (value != null) {
2812
+ local.push(prop.replace(/_.*/, "").replace(/[A-Z]/g, (l) => "-" + l.toLowerCase()) + ": " + value + ";");
2813
+ }
2814
+ }
2815
+ if (local.length || keyframes) {
2816
+ target.push((finish && !isAt && !isKeyframes ? selectors.map(finish) : selectors).join(", ") + " {" + local.join(" ") + "}");
2817
+ }
2818
+ }
2819
+ for (let prop in spec) render(splitSelector(prop), spec[prop], this.rules);
2820
+ }
2821
+ // :: () → string
2822
+ // Returns a string containing the module's CSS rules.
2823
+ getRules() {
2824
+ return this.rules.join("\n");
2825
+ }
2826
+ // :: () → string
2827
+ // Generate a new unique CSS class name.
2828
+ static newName() {
2829
+ let id = top[COUNT] || 1;
2830
+ top[COUNT] = id + 1;
2831
+ return C + id.toString(36);
2832
+ }
2833
+ // :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>, ?{nonce: ?string})
2834
+ //
2835
+ // Mount the given set of modules in the given DOM root, which ensures
2836
+ // that the CSS rules defined by the module are available in that
2837
+ // context.
2838
+ //
2839
+ // Rules are only added to the document once per root.
2840
+ //
2841
+ // Rule order will follow the order of the modules, so that rules from
2842
+ // modules later in the array take precedence of those from earlier
2843
+ // modules. If you call this function multiple times for the same root
2844
+ // in a way that changes the order of already mounted modules, the old
2845
+ // order will be changed.
2846
+ //
2847
+ // If a Content Security Policy nonce is provided, it is added to
2848
+ // the `<style>` tag generated by the library.
2849
+ static mount(root, modules, options) {
2850
+ let set = root[SET], nonce = options && options.nonce;
2851
+ if (!set) set = new StyleSet(root, nonce);
2852
+ else if (nonce) set.setNonce(nonce);
2853
+ set.mount(Array.isArray(modules) ? modules : [modules], root);
2854
+ }
2855
+ };
2856
+ var adoptedSet = /* @__PURE__ */ new Map();
2857
+ var StyleSet = class {
2858
+ constructor(root, nonce) {
2859
+ let doc = root.ownerDocument || root, win = doc.defaultView;
2860
+ if (!root.head && root.adoptedStyleSheets && win.CSSStyleSheet) {
2861
+ let adopted = adoptedSet.get(doc);
2862
+ if (adopted) return root[SET] = adopted;
2863
+ this.sheet = new win.CSSStyleSheet();
2864
+ adoptedSet.set(doc, this);
2865
+ } else {
2866
+ this.styleTag = doc.createElement("style");
2867
+ if (nonce) this.styleTag.setAttribute("nonce", nonce);
2868
+ }
2869
+ this.modules = [];
2870
+ root[SET] = this;
2871
+ }
2872
+ mount(modules, root) {
2873
+ let sheet = this.sheet;
2874
+ let pos = 0, j = 0;
2875
+ for (let i = 0; i < modules.length; i++) {
2876
+ let mod = modules[i], index = this.modules.indexOf(mod);
2877
+ if (index < j && index > -1) {
2878
+ this.modules.splice(index, 1);
2879
+ j--;
2880
+ index = -1;
2881
+ }
2882
+ if (index == -1) {
2883
+ this.modules.splice(j++, 0, mod);
2884
+ if (sheet) for (let k = 0; k < mod.rules.length; k++)
2885
+ sheet.insertRule(mod.rules[k], pos++);
2886
+ } else {
2887
+ while (j < index) pos += this.modules[j++].rules.length;
2888
+ pos += mod.rules.length;
2889
+ j++;
2890
+ }
2891
+ }
2892
+ if (sheet) {
2893
+ if (root.adoptedStyleSheets.indexOf(this.sheet) < 0)
2894
+ root.adoptedStyleSheets = [this.sheet, ...root.adoptedStyleSheets];
2895
+ } else {
2896
+ let text = "";
2897
+ for (let i = 0; i < this.modules.length; i++)
2898
+ text += this.modules[i].getRules() + "\n";
2899
+ this.styleTag.textContent = text;
2900
+ let target = root.head || root;
2901
+ if (this.styleTag.parentNode != target)
2902
+ target.insertBefore(this.styleTag, target.firstChild);
2903
+ }
2904
+ }
2905
+ setNonce(nonce) {
2906
+ if (this.styleTag && this.styleTag.getAttribute("nonce") != nonce)
2907
+ this.styleTag.setAttribute("nonce", nonce);
2908
+ }
2909
+ };
2910
+
2911
+ // ../node_modules/.pnpm/@codemirror+language@6.12.4/node_modules/@codemirror/language/dist/index.js
2912
+ var _a;
2913
+ var languageDataProp = /* @__PURE__ */ new NodeProp();
2914
+ function defineLanguageFacet(baseData) {
2915
+ return Facet.define({
2916
+ combine: baseData ? (values) => values.concat(baseData) : void 0
2917
+ });
2918
+ }
2919
+ var sublanguageProp = /* @__PURE__ */ new NodeProp();
2920
+ var Language = class {
2921
+ /**
2922
+ Construct a language object. If you need to invoke this
2923
+ directly, first define a data facet with
2924
+ [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
2925
+ configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
2926
+ to the language's outer syntax node.
2927
+ */
2928
+ constructor(data, parser, extraExtensions = [], name2 = "") {
2929
+ this.data = data;
2930
+ this.name = name2;
2931
+ if (!EditorState.prototype.hasOwnProperty("tree"))
2932
+ Object.defineProperty(EditorState.prototype, "tree", { get() {
2933
+ return syntaxTree(this);
2934
+ } });
2935
+ this.parser = parser;
2936
+ this.extension = [
2937
+ language.of(this),
2938
+ EditorState.languageData.of((state, pos, side) => {
2939
+ let top2 = topNodeAt(state, pos, side), data2 = top2.type.prop(languageDataProp);
2940
+ if (!data2)
2941
+ return [];
2942
+ let base = state.facet(data2), sub = top2.type.prop(sublanguageProp);
2943
+ if (sub) {
2944
+ let innerNode = top2.resolve(pos - top2.from, side);
2945
+ for (let sublang of sub)
2946
+ if (sublang.test(innerNode, state)) {
2947
+ let data3 = state.facet(sublang.facet);
2948
+ return sublang.type == "replace" ? data3 : data3.concat(base);
2949
+ }
2950
+ }
2951
+ return base;
2952
+ })
2953
+ ].concat(extraExtensions);
2954
+ }
2955
+ /**
2956
+ Query whether this language is active at the given position.
2957
+ */
2958
+ isActiveAt(state, pos, side = -1) {
2959
+ return topNodeAt(state, pos, side).type.prop(languageDataProp) == this.data;
2960
+ }
2961
+ /**
2962
+ Find the document regions that were parsed using this language.
2963
+ The returned regions will _include_ any nested languages rooted
2964
+ in this language, when those exist.
2965
+ */
2966
+ findRegions(state) {
2967
+ let lang = state.facet(language);
2968
+ if ((lang === null || lang === void 0 ? void 0 : lang.data) == this.data)
2969
+ return [{ from: 0, to: state.doc.length }];
2970
+ if (!lang || !lang.allowsNesting)
2971
+ return [];
2972
+ let result = [];
2973
+ let explore = (tree, from) => {
2974
+ if (tree.prop(languageDataProp) == this.data) {
2975
+ result.push({ from, to: from + tree.length });
2976
+ return;
2977
+ }
2978
+ let mount = tree.prop(NodeProp.mounted);
2979
+ if (mount) {
2980
+ if (mount.tree.prop(languageDataProp) == this.data) {
2981
+ if (mount.overlay)
2982
+ for (let r of mount.overlay)
2983
+ result.push({ from: r.from + from, to: r.to + from });
2984
+ else
2985
+ result.push({ from, to: from + tree.length });
2986
+ return;
2987
+ } else if (mount.overlay) {
2988
+ let size = result.length;
2989
+ explore(mount.tree, mount.overlay[0].from + from);
2990
+ if (result.length > size)
2991
+ return;
2992
+ }
2993
+ }
2994
+ for (let i = 0; i < tree.children.length; i++) {
2995
+ let ch = tree.children[i];
2996
+ if (ch instanceof Tree)
2997
+ explore(ch, tree.positions[i] + from);
2998
+ }
2999
+ };
3000
+ explore(syntaxTree(state), 0);
3001
+ return result;
3002
+ }
3003
+ /**
3004
+ Indicates whether this language allows nested languages. The
3005
+ default implementation returns true.
3006
+ */
3007
+ get allowsNesting() {
3008
+ return true;
3009
+ }
3010
+ };
3011
+ Language.setState = /* @__PURE__ */ StateEffect.define();
3012
+ function topNodeAt(state, pos, side) {
3013
+ let topLang = state.facet(language), tree = syntaxTree(state).topNode;
3014
+ if (!topLang || topLang.allowsNesting) {
3015
+ for (let node = tree; node; node = node.enter(pos, side, IterMode.ExcludeBuffers | IterMode.EnterBracketed))
3016
+ if (node.type.isTop)
3017
+ tree = node;
3018
+ }
3019
+ return tree;
3020
+ }
3021
+ var LRLanguage = class _LRLanguage extends Language {
3022
+ constructor(data, parser, name2) {
3023
+ super(data, parser, [], name2);
3024
+ this.parser = parser;
3025
+ }
3026
+ /**
3027
+ Define a language from a parser.
3028
+ */
3029
+ static define(spec) {
3030
+ let data = defineLanguageFacet(spec.languageData);
3031
+ return new _LRLanguage(data, spec.parser.configure({
3032
+ props: [languageDataProp.add((type) => type.isTop ? data : void 0)]
3033
+ }), spec.name);
3034
+ }
3035
+ /**
3036
+ Create a new instance of this language with a reconfigured
3037
+ version of its parser and optionally a new name.
3038
+ */
3039
+ configure(options, name2) {
3040
+ return new _LRLanguage(this.data, this.parser.configure(options), name2 || this.name);
3041
+ }
3042
+ get allowsNesting() {
3043
+ return this.parser.hasWrappers();
3044
+ }
3045
+ };
3046
+ function syntaxTree(state) {
3047
+ let field = state.field(Language.state, false);
3048
+ return field ? field.tree : Tree.empty;
3049
+ }
3050
+ var DocInput = class {
3051
+ /**
3052
+ Create an input object for the given document.
3053
+ */
3054
+ constructor(doc) {
3055
+ this.doc = doc;
3056
+ this.cursorPos = 0;
3057
+ this.string = "";
3058
+ this.cursor = doc.iter();
3059
+ }
3060
+ get length() {
3061
+ return this.doc.length;
3062
+ }
3063
+ syncTo(pos) {
3064
+ this.string = this.cursor.next(pos - this.cursorPos).value;
3065
+ this.cursorPos = pos + this.string.length;
3066
+ return this.cursorPos - this.string.length;
3067
+ }
3068
+ chunk(pos) {
3069
+ this.syncTo(pos);
3070
+ return this.string;
3071
+ }
3072
+ get lineChunks() {
3073
+ return true;
3074
+ }
3075
+ read(from, to) {
3076
+ let stringStart = this.cursorPos - this.string.length;
3077
+ if (from < stringStart || to >= this.cursorPos)
3078
+ return this.doc.sliceString(from, to);
3079
+ else
3080
+ return this.string.slice(from - stringStart, to - stringStart);
3081
+ }
3082
+ };
3083
+ var currentContext = null;
3084
+ var ParseContext = class _ParseContext {
3085
+ constructor(parser, state, fragments = [], tree, treeLen, viewport, skipped, scheduleOn) {
3086
+ this.parser = parser;
3087
+ this.state = state;
3088
+ this.fragments = fragments;
3089
+ this.tree = tree;
3090
+ this.treeLen = treeLen;
3091
+ this.viewport = viewport;
3092
+ this.skipped = skipped;
3093
+ this.scheduleOn = scheduleOn;
3094
+ this.parse = null;
3095
+ this.tempSkipped = [];
3096
+ }
3097
+ /**
3098
+ @internal
3099
+ */
3100
+ static create(parser, state, viewport) {
3101
+ return new _ParseContext(parser, state, [], Tree.empty, 0, viewport, [], null);
3102
+ }
3103
+ startParse() {
3104
+ return this.parser.startParse(new DocInput(this.state.doc), this.fragments);
3105
+ }
3106
+ /**
3107
+ @internal
3108
+ */
3109
+ work(until, upto) {
3110
+ if (upto != null && upto >= this.state.doc.length)
3111
+ upto = void 0;
3112
+ if (this.tree != Tree.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {
3113
+ this.takeTree();
3114
+ return true;
3115
+ }
3116
+ return this.withContext(() => {
3117
+ var _a2;
3118
+ if (typeof until == "number") {
3119
+ let endTime = Date.now() + until;
3120
+ until = () => Date.now() > endTime;
3121
+ }
3122
+ if (!this.parse)
3123
+ this.parse = this.startParse();
3124
+ if (upto != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > upto) && upto < this.state.doc.length)
3125
+ this.parse.stopAt(upto);
3126
+ for (; ; ) {
3127
+ let done = this.parse.advance();
3128
+ if (done) {
3129
+ this.fragments = this.withoutTempSkipped(TreeFragment.addTree(done, this.fragments, this.parse.stoppedAt != null));
3130
+ this.treeLen = (_a2 = this.parse.stoppedAt) !== null && _a2 !== void 0 ? _a2 : this.state.doc.length;
3131
+ this.tree = done;
3132
+ this.parse = null;
3133
+ if (this.treeLen < (upto !== null && upto !== void 0 ? upto : this.state.doc.length))
3134
+ this.parse = this.startParse();
3135
+ else
3136
+ return true;
3137
+ }
3138
+ if (until())
3139
+ return false;
3140
+ }
3141
+ });
3142
+ }
3143
+ /**
3144
+ @internal
3145
+ */
3146
+ takeTree() {
3147
+ let pos, tree;
3148
+ if (this.parse && (pos = this.parse.parsedPos) >= this.treeLen) {
3149
+ if (this.parse.stoppedAt == null || this.parse.stoppedAt > pos)
3150
+ this.parse.stopAt(pos);
3151
+ this.withContext(() => {
3152
+ while (!(tree = this.parse.advance())) {
3153
+ }
3154
+ });
3155
+ this.treeLen = pos;
3156
+ this.tree = tree;
3157
+ this.fragments = this.withoutTempSkipped(TreeFragment.addTree(this.tree, this.fragments, true));
3158
+ this.parse = null;
3159
+ }
3160
+ }
3161
+ withContext(f) {
3162
+ let prev = currentContext;
3163
+ currentContext = this;
3164
+ try {
3165
+ return f();
3166
+ } finally {
3167
+ currentContext = prev;
3168
+ }
3169
+ }
3170
+ withoutTempSkipped(fragments) {
3171
+ for (let r; r = this.tempSkipped.pop(); )
3172
+ fragments = cutFragments(fragments, r.from, r.to);
3173
+ return fragments;
3174
+ }
3175
+ /**
3176
+ @internal
3177
+ */
3178
+ changes(changes, newState) {
3179
+ let { fragments, tree, treeLen, viewport, skipped } = this;
3180
+ this.takeTree();
3181
+ if (!changes.empty) {
3182
+ let ranges = [];
3183
+ changes.iterChangedRanges((fromA, toA, fromB, toB) => ranges.push({ fromA, toA, fromB, toB }));
3184
+ fragments = TreeFragment.applyChanges(fragments, ranges);
3185
+ tree = Tree.empty;
3186
+ treeLen = 0;
3187
+ viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };
3188
+ if (this.skipped.length) {
3189
+ skipped = [];
3190
+ for (let r of this.skipped) {
3191
+ let from = changes.mapPos(r.from, 1), to = changes.mapPos(r.to, -1);
3192
+ if (from < to)
3193
+ skipped.push({ from, to });
3194
+ }
3195
+ }
3196
+ }
3197
+ return new _ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);
3198
+ }
3199
+ /**
3200
+ @internal
3201
+ */
3202
+ updateViewport(viewport) {
3203
+ if (this.viewport.from == viewport.from && this.viewport.to == viewport.to)
3204
+ return false;
3205
+ this.viewport = viewport;
3206
+ let startLen = this.skipped.length;
3207
+ for (let i = 0; i < this.skipped.length; i++) {
3208
+ let { from, to } = this.skipped[i];
3209
+ if (from < viewport.to && to > viewport.from) {
3210
+ this.fragments = cutFragments(this.fragments, from, to);
3211
+ this.skipped.splice(i--, 1);
3212
+ }
3213
+ }
3214
+ if (this.skipped.length >= startLen)
3215
+ return false;
3216
+ this.reset();
3217
+ return true;
3218
+ }
3219
+ /**
3220
+ @internal
3221
+ */
3222
+ reset() {
3223
+ if (this.parse) {
3224
+ this.takeTree();
3225
+ this.parse = null;
3226
+ }
3227
+ }
3228
+ /**
3229
+ Notify the parse scheduler that the given region was skipped
3230
+ because it wasn't in view, and the parse should be restarted
3231
+ when it comes into view.
3232
+ */
3233
+ skipUntilInView(from, to) {
3234
+ this.skipped.push({ from, to });
3235
+ }
3236
+ /**
3237
+ Returns a parser intended to be used as placeholder when
3238
+ asynchronously loading a nested parser. It'll skip its input and
3239
+ mark it as not-really-parsed, so that the next update will parse
3240
+ it again.
3241
+
3242
+ When `until` is given, a reparse will be scheduled when that
3243
+ promise resolves.
3244
+ */
3245
+ static getSkippingParser(until) {
3246
+ return new class extends Parser {
3247
+ createParse(input, fragments, ranges) {
3248
+ let from = ranges[0].from, to = ranges[ranges.length - 1].to;
3249
+ let parser = {
3250
+ parsedPos: from,
3251
+ advance() {
3252
+ let cx = currentContext;
3253
+ if (cx) {
3254
+ for (let r of ranges)
3255
+ cx.tempSkipped.push(r);
3256
+ if (until)
3257
+ cx.scheduleOn = cx.scheduleOn ? Promise.all([cx.scheduleOn, until]) : until;
3258
+ }
3259
+ this.parsedPos = to;
3260
+ return new Tree(NodeType.none, [], [], to - from);
3261
+ },
3262
+ stoppedAt: null,
3263
+ stopAt() {
3264
+ }
3265
+ };
3266
+ return parser;
3267
+ }
3268
+ }();
3269
+ }
3270
+ /**
3271
+ @internal
3272
+ */
3273
+ isDone(upto) {
3274
+ upto = Math.min(upto, this.state.doc.length);
3275
+ let frags = this.fragments;
3276
+ return this.treeLen >= upto && frags.length && frags[0].from == 0 && frags[0].to >= upto;
3277
+ }
3278
+ /**
3279
+ Get the context for the current parse, or `null` if no editor
3280
+ parse is in progress.
3281
+ */
3282
+ static get() {
3283
+ return currentContext;
3284
+ }
3285
+ };
3286
+ function cutFragments(fragments, from, to) {
3287
+ return TreeFragment.applyChanges(fragments, [{ fromA: from, toA: to, fromB: from, toB: to }]);
3288
+ }
3289
+ var LanguageState = class _LanguageState {
3290
+ constructor(context) {
3291
+ this.context = context;
3292
+ this.tree = context.tree;
3293
+ }
3294
+ apply(tr) {
3295
+ if (!tr.docChanged && this.tree == this.context.tree)
3296
+ return this;
3297
+ let newCx = this.context.changes(tr.changes, tr.state);
3298
+ let upto = this.context.treeLen == tr.startState.doc.length ? void 0 : Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);
3299
+ if (!newCx.work(20, upto))
3300
+ newCx.takeTree();
3301
+ return new _LanguageState(newCx);
3302
+ }
3303
+ static init(state) {
3304
+ let vpTo = Math.min(3e3, state.doc.length);
3305
+ let parseState = ParseContext.create(state.facet(language).parser, state, { from: 0, to: vpTo });
3306
+ if (!parseState.work(20, vpTo))
3307
+ parseState.takeTree();
3308
+ return new _LanguageState(parseState);
3309
+ }
3310
+ };
3311
+ Language.state = /* @__PURE__ */ StateField.define({
3312
+ create: LanguageState.init,
3313
+ update(value, tr) {
3314
+ for (let e of tr.effects)
3315
+ if (e.is(Language.setState))
3316
+ return e.value;
3317
+ if (tr.startState.facet(language) != tr.state.facet(language))
3318
+ return LanguageState.init(tr.state);
3319
+ return value.apply(tr);
3320
+ }
3321
+ });
3322
+ var requestIdle = (callback) => {
3323
+ let timeout = setTimeout(
3324
+ () => callback(),
3325
+ 500
3326
+ /* Work.MaxPause */
3327
+ );
3328
+ return () => clearTimeout(timeout);
3329
+ };
3330
+ if (typeof requestIdleCallback != "undefined")
3331
+ requestIdle = (callback) => {
3332
+ let idle = -1, timeout = setTimeout(
3333
+ () => {
3334
+ idle = requestIdleCallback(callback, {
3335
+ timeout: 500 - 100
3336
+ /* Work.MinPause */
3337
+ });
3338
+ },
3339
+ 100
3340
+ /* Work.MinPause */
3341
+ );
3342
+ return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);
3343
+ };
3344
+ var isInputPending = typeof navigator != "undefined" && ((_a = navigator.scheduling) === null || _a === void 0 ? void 0 : _a.isInputPending) ? () => navigator.scheduling.isInputPending() : null;
3345
+ var parseWorker = /* @__PURE__ */ ViewPlugin.fromClass(class ParseWorker {
3346
+ constructor(view) {
3347
+ this.view = view;
3348
+ this.working = null;
3349
+ this.workScheduled = 0;
3350
+ this.chunkEnd = -1;
3351
+ this.chunkBudget = -1;
3352
+ this.work = this.work.bind(this);
3353
+ this.scheduleWork();
3354
+ }
3355
+ update(update) {
3356
+ let cx = this.view.state.field(Language.state).context;
3357
+ if (cx.updateViewport(update.view.viewport) || this.view.viewport.to > cx.treeLen)
3358
+ this.scheduleWork();
3359
+ if (update.docChanged || update.selectionSet) {
3360
+ if (this.view.hasFocus)
3361
+ this.chunkBudget += 50;
3362
+ this.scheduleWork();
3363
+ }
3364
+ this.checkAsyncSchedule(cx);
3365
+ }
3366
+ scheduleWork() {
3367
+ if (this.working)
3368
+ return;
3369
+ let { state } = this.view, field = state.field(Language.state);
3370
+ if (field.tree != field.context.tree || !field.context.isDone(state.doc.length))
3371
+ this.working = requestIdle(this.work);
3372
+ }
3373
+ work(deadline) {
3374
+ this.working = null;
3375
+ let now = Date.now();
3376
+ if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) {
3377
+ this.chunkEnd = now + 3e4;
3378
+ this.chunkBudget = 3e3;
3379
+ }
3380
+ if (this.chunkBudget <= 0)
3381
+ return;
3382
+ let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language.state);
3383
+ if (field.tree == field.context.tree && field.context.isDone(
3384
+ vpTo + 1e5
3385
+ /* Work.MaxParseAhead */
3386
+ ))
3387
+ return;
3388
+ let endTime = Date.now() + Math.min(this.chunkBudget, 100, deadline && !isInputPending ? Math.max(25, deadline.timeRemaining() - 5) : 1e9);
3389
+ let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1e3;
3390
+ let done = field.context.work(() => {
3391
+ return isInputPending && isInputPending() || Date.now() > endTime;
3392
+ }, vpTo + (viewportFirst ? 0 : 1e5));
3393
+ this.chunkBudget -= Date.now() - now;
3394
+ if (done || this.chunkBudget <= 0) {
3395
+ field.context.takeTree();
3396
+ this.view.dispatch({ effects: Language.setState.of(new LanguageState(field.context)) });
3397
+ }
3398
+ if (this.chunkBudget > 0 && !(done && !viewportFirst))
3399
+ this.scheduleWork();
3400
+ this.checkAsyncSchedule(field.context);
3401
+ }
3402
+ checkAsyncSchedule(cx) {
3403
+ if (cx.scheduleOn) {
3404
+ this.workScheduled++;
3405
+ cx.scheduleOn.then(() => this.scheduleWork()).catch((err) => logException(this.view.state, err)).then(() => this.workScheduled--);
3406
+ cx.scheduleOn = null;
3407
+ }
3408
+ }
3409
+ destroy() {
3410
+ if (this.working)
3411
+ this.working();
3412
+ }
3413
+ isWorking() {
3414
+ return !!(this.working || this.workScheduled > 0);
3415
+ }
3416
+ }, {
3417
+ eventHandlers: { focus() {
3418
+ this.scheduleWork();
3419
+ } }
3420
+ });
3421
+ var language = /* @__PURE__ */ Facet.define({
3422
+ combine(languages) {
3423
+ return languages.length ? languages[0] : null;
3424
+ },
3425
+ enables: (language2) => [
3426
+ Language.state,
3427
+ parseWorker,
3428
+ EditorView.contentAttributes.compute([language2], (state) => {
3429
+ let lang = state.facet(language2);
3430
+ return lang && lang.name ? { "data-language": lang.name } : {};
3431
+ })
3432
+ ]
3433
+ });
3434
+ var LanguageSupport = class {
3435
+ /**
3436
+ Create a language support object.
3437
+ */
3438
+ constructor(language2, support = []) {
3439
+ this.language = language2;
3440
+ this.support = support;
3441
+ this.extension = [language2, support];
3442
+ }
3443
+ };
3444
+ var LanguageDescription = class _LanguageDescription {
3445
+ constructor(name2, alias, extensions, filename, loadFunc, support = void 0) {
3446
+ this.name = name2;
3447
+ this.alias = alias;
3448
+ this.extensions = extensions;
3449
+ this.filename = filename;
3450
+ this.loadFunc = loadFunc;
3451
+ this.support = support;
3452
+ this.loading = null;
3453
+ }
3454
+ /**
3455
+ Start loading the the language. Will return a promise that
3456
+ resolves to a [`LanguageSupport`](https://codemirror.net/6/docs/ref/#language.LanguageSupport)
3457
+ object when the language successfully loads.
3458
+ */
3459
+ load() {
3460
+ return this.loading || (this.loading = this.loadFunc().then((support) => this.support = support, (err) => {
3461
+ this.loading = null;
3462
+ throw err;
3463
+ }));
3464
+ }
3465
+ /**
3466
+ Create a language description.
3467
+ */
3468
+ static of(spec) {
3469
+ let { load, support } = spec;
3470
+ if (!load) {
3471
+ if (!support)
3472
+ throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");
3473
+ load = () => Promise.resolve(support);
3474
+ }
3475
+ return new _LanguageDescription(spec.name, (spec.alias || []).concat(spec.name).map((s) => s.toLowerCase()), spec.extensions || [], spec.filename, load, support);
3476
+ }
3477
+ /**
3478
+ Look for a language in the given array of descriptions that
3479
+ matches the filename. Will first match
3480
+ [`filename`](https://codemirror.net/6/docs/ref/#language.LanguageDescription.filename) patterns,
3481
+ and then [extensions](https://codemirror.net/6/docs/ref/#language.LanguageDescription.extensions),
3482
+ and return the first language that matches.
3483
+ */
3484
+ static matchFilename(descs, filename) {
3485
+ for (let d of descs)
3486
+ if (d.filename && d.filename.test(filename))
3487
+ return d;
3488
+ let ext = /\.([^.]+)$/.exec(filename);
3489
+ if (ext) {
3490
+ for (let d of descs)
3491
+ if (d.extensions.indexOf(ext[1]) > -1)
3492
+ return d;
3493
+ }
3494
+ return null;
3495
+ }
3496
+ /**
3497
+ Look for a language whose name or alias matches the the given
3498
+ name (case-insensitively). If `fuzzy` is true, and no direct
3499
+ matchs is found, this'll also search for a language whose name
3500
+ or alias occurs in the string (for names shorter than three
3501
+ characters, only when surrounded by non-word characters).
3502
+ */
3503
+ static matchLanguageName(descs, name2, fuzzy = true) {
3504
+ name2 = name2.toLowerCase();
3505
+ for (let d of descs)
3506
+ if (d.alias.some((a) => a == name2))
3507
+ return d;
3508
+ if (fuzzy)
3509
+ for (let d of descs)
3510
+ for (let a of d.alias) {
3511
+ let found = name2.indexOf(a);
3512
+ if (found > -1 && (a.length > 2 || !/\w/.test(name2[found - 1]) && !/\w/.test(name2[found + a.length])))
3513
+ return d;
3514
+ }
3515
+ return null;
3516
+ }
3517
+ };
3518
+ var indentService = /* @__PURE__ */ Facet.define();
3519
+ var indentUnit = /* @__PURE__ */ Facet.define({
3520
+ combine: (values) => {
3521
+ if (!values.length)
3522
+ return " ";
3523
+ let unit = values[0];
3524
+ if (!unit || /\S/.test(unit) || Array.from(unit).some((e) => e != unit[0]))
3525
+ throw new Error("Invalid indent unit: " + JSON.stringify(values[0]));
3526
+ return unit;
3527
+ }
3528
+ });
3529
+ function getIndentUnit(state) {
3530
+ let unit = state.facet(indentUnit);
3531
+ return unit.charCodeAt(0) == 9 ? state.tabSize * unit.length : unit.length;
3532
+ }
3533
+ function indentString(state, cols) {
3534
+ let result = "", ts = state.tabSize, ch = state.facet(indentUnit)[0];
3535
+ if (ch == " ") {
3536
+ while (cols >= ts) {
3537
+ result += " ";
3538
+ cols -= ts;
3539
+ }
3540
+ ch = " ";
3541
+ }
3542
+ for (let i = 0; i < cols; i++)
3543
+ result += ch;
3544
+ return result;
3545
+ }
3546
+ function getIndentation(context, pos) {
3547
+ if (context instanceof EditorState)
3548
+ context = new IndentContext(context);
3549
+ for (let service of context.state.facet(indentService)) {
3550
+ let result = service(context, pos);
3551
+ if (result !== void 0)
3552
+ return result;
3553
+ }
3554
+ let tree = syntaxTree(context.state);
3555
+ return tree.length >= pos ? syntaxIndentation(context, tree, pos) : null;
3556
+ }
3557
+ var IndentContext = class {
3558
+ /**
3559
+ Create an indent context.
3560
+ */
3561
+ constructor(state, options = {}) {
3562
+ this.state = state;
3563
+ this.options = options;
3564
+ this.unit = getIndentUnit(state);
3565
+ }
3566
+ /**
3567
+ Get a description of the line at the given position, taking
3568
+ [simulated line
3569
+ breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
3570
+ into account. If there is such a break at `pos`, the `bias`
3571
+ argument determines whether the part of the line line before or
3572
+ after the break is used.
3573
+ */
3574
+ lineAt(pos, bias = 1) {
3575
+ let line = this.state.doc.lineAt(pos);
3576
+ let { simulateBreak, simulateDoubleBreak } = this.options;
3577
+ if (simulateBreak != null && simulateBreak >= line.from && simulateBreak <= line.to) {
3578
+ if (simulateDoubleBreak && simulateBreak == pos)
3579
+ return { text: "", from: pos };
3580
+ else if (bias < 0 ? simulateBreak < pos : simulateBreak <= pos)
3581
+ return { text: line.text.slice(simulateBreak - line.from), from: simulateBreak };
3582
+ else
3583
+ return { text: line.text.slice(0, simulateBreak - line.from), from: line.from };
3584
+ }
3585
+ return line;
3586
+ }
3587
+ /**
3588
+ Get the text directly after `pos`, either the entire line
3589
+ or the next 100 characters, whichever is shorter.
3590
+ */
3591
+ textAfterPos(pos, bias = 1) {
3592
+ if (this.options.simulateDoubleBreak && pos == this.options.simulateBreak)
3593
+ return "";
3594
+ let { text, from } = this.lineAt(pos, bias);
3595
+ return text.slice(pos - from, Math.min(text.length, pos + 100 - from));
3596
+ }
3597
+ /**
3598
+ Find the column for the given position.
3599
+ */
3600
+ column(pos, bias = 1) {
3601
+ let { text, from } = this.lineAt(pos, bias);
3602
+ let result = this.countColumn(text, pos - from);
3603
+ let override = this.options.overrideIndentation ? this.options.overrideIndentation(from) : -1;
3604
+ if (override > -1)
3605
+ result += override - this.countColumn(text, text.search(/\S|$/));
3606
+ return result;
3607
+ }
3608
+ /**
3609
+ Find the column position (taking tabs into account) of the given
3610
+ position in the given string.
3611
+ */
3612
+ countColumn(line, pos = line.length) {
3613
+ return countColumn(line, this.state.tabSize, pos);
3614
+ }
3615
+ /**
3616
+ Find the indentation column of the line at the given point.
3617
+ */
3618
+ lineIndent(pos, bias = 1) {
3619
+ let { text, from } = this.lineAt(pos, bias);
3620
+ let override = this.options.overrideIndentation;
3621
+ if (override) {
3622
+ let overriden = override(from);
3623
+ if (overriden > -1)
3624
+ return overriden;
3625
+ }
3626
+ return this.countColumn(text, text.search(/\S|$/));
3627
+ }
3628
+ /**
3629
+ Returns the [simulated line
3630
+ break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
3631
+ for this context, if any.
3632
+ */
3633
+ get simulatedBreak() {
3634
+ return this.options.simulateBreak || null;
3635
+ }
3636
+ };
3637
+ var indentNodeProp = /* @__PURE__ */ new NodeProp();
3638
+ function syntaxIndentation(cx, ast, pos) {
3639
+ let stack = ast.resolveStack(pos);
3640
+ let inner = ast.resolveInner(pos, -1).resolve(pos, 0).enterUnfinishedNodesBefore(pos);
3641
+ if (inner != stack.node) {
3642
+ let add = [];
3643
+ for (let cur = inner; cur && !(cur.from < stack.node.from || cur.to > stack.node.to || cur.from == stack.node.from && cur.type == stack.node.type); cur = cur.parent)
3644
+ add.push(cur);
3645
+ for (let i = add.length - 1; i >= 0; i--)
3646
+ stack = { node: add[i], next: stack };
3647
+ }
3648
+ return indentFor(stack, cx, pos);
3649
+ }
3650
+ function indentFor(stack, cx, pos) {
3651
+ for (let cur = stack; cur; cur = cur.next) {
3652
+ let strategy = indentStrategy(cur.node);
3653
+ if (strategy)
3654
+ return strategy(TreeIndentContext.create(cx, pos, cur));
3655
+ }
3656
+ return 0;
3657
+ }
3658
+ function ignoreClosed(cx) {
3659
+ return cx.pos == cx.options.simulateBreak && cx.options.simulateDoubleBreak;
3660
+ }
3661
+ function indentStrategy(tree) {
3662
+ let strategy = tree.type.prop(indentNodeProp);
3663
+ if (strategy)
3664
+ return strategy;
3665
+ let first = tree.firstChild, close;
3666
+ if (first && (close = first.type.prop(NodeProp.closedBy))) {
3667
+ let last = tree.lastChild, closed = last && close.indexOf(last.name) > -1;
3668
+ return (cx) => delimitedStrategy(cx, true, 1, void 0, closed && !ignoreClosed(cx) ? last.from : void 0);
3669
+ }
3670
+ return tree.parent == null ? topIndent : null;
3671
+ }
3672
+ function topIndent() {
3673
+ return 0;
3674
+ }
3675
+ var TreeIndentContext = class _TreeIndentContext extends IndentContext {
3676
+ constructor(base, pos, context) {
3677
+ super(base.state, base.options);
3678
+ this.base = base;
3679
+ this.pos = pos;
3680
+ this.context = context;
3681
+ }
3682
+ /**
3683
+ The syntax tree node to which the indentation strategy
3684
+ applies.
3685
+ */
3686
+ get node() {
3687
+ return this.context.node;
3688
+ }
3689
+ /**
3690
+ @internal
3691
+ */
3692
+ static create(base, pos, context) {
3693
+ return new _TreeIndentContext(base, pos, context);
3694
+ }
3695
+ /**
3696
+ Get the text directly after `this.pos`, either the entire line
3697
+ or the next 100 characters, whichever is shorter.
3698
+ */
3699
+ get textAfter() {
3700
+ return this.textAfterPos(this.pos);
3701
+ }
3702
+ /**
3703
+ Get the indentation at the reference line for `this.node`, which
3704
+ is the line on which it starts, unless there is a node that is
3705
+ _not_ a parent of this node covering the start of that line. If
3706
+ so, the line at the start of that node is tried, again skipping
3707
+ on if it is covered by another such node.
3708
+ */
3709
+ get baseIndent() {
3710
+ return this.baseIndentFor(this.node);
3711
+ }
3712
+ /**
3713
+ Get the indentation for the reference line of the given node
3714
+ (see [`baseIndent`](https://codemirror.net/6/docs/ref/#language.TreeIndentContext.baseIndent)).
3715
+ */
3716
+ baseIndentFor(node) {
3717
+ let line = this.state.doc.lineAt(node.from);
3718
+ for (; ; ) {
3719
+ let atBreak = node.resolve(line.from);
3720
+ while (atBreak.parent && atBreak.parent.from == atBreak.from)
3721
+ atBreak = atBreak.parent;
3722
+ if (isParent(atBreak, node))
3723
+ break;
3724
+ line = this.state.doc.lineAt(atBreak.from);
3725
+ }
3726
+ return this.lineIndent(line.from);
3727
+ }
3728
+ /**
3729
+ Continue looking for indentations in the node's parent nodes,
3730
+ and return the result of that.
3731
+ */
3732
+ continue() {
3733
+ return indentFor(this.context.next, this.base, this.pos);
3734
+ }
3735
+ };
3736
+ function isParent(parent, of) {
3737
+ for (let cur = of; cur; cur = cur.parent)
3738
+ if (parent == cur)
3739
+ return true;
3740
+ return false;
3741
+ }
3742
+ function bracketedAligned(context) {
3743
+ let tree = context.node;
3744
+ let openToken = tree.childAfter(tree.from), last = tree.lastChild;
3745
+ if (!openToken)
3746
+ return null;
3747
+ let sim = context.options.simulateBreak;
3748
+ let openLine = context.state.doc.lineAt(openToken.from);
3749
+ let lineEnd = sim == null || sim <= openLine.from ? openLine.to : Math.min(openLine.to, sim);
3750
+ for (let pos = openToken.to; ; ) {
3751
+ let next = tree.childAfter(pos);
3752
+ if (!next || next == last)
3753
+ return null;
3754
+ if (!next.type.isSkipped) {
3755
+ if (next.from >= lineEnd)
3756
+ return null;
3757
+ let space = /^ */.exec(openLine.text.slice(openToken.to - openLine.from))[0].length;
3758
+ return { from: openToken.from, to: openToken.to + space };
3759
+ }
3760
+ pos = next.to;
3761
+ }
3762
+ }
3763
+ function delimitedIndent({ closing, align = true, units = 1 }) {
3764
+ return (context) => delimitedStrategy(context, align, units, closing);
3765
+ }
3766
+ function delimitedStrategy(context, align, units, closing, closedAt) {
3767
+ let after = context.textAfter, space = after.match(/^\s*/)[0].length;
3768
+ let closed = closing && after.slice(space, space + closing.length) == closing || closedAt == context.pos + space;
3769
+ let aligned = align ? bracketedAligned(context) : null;
3770
+ if (aligned)
3771
+ return closed ? context.column(aligned.from) : context.column(aligned.to);
3772
+ return context.baseIndent + (closed ? 0 : context.unit * units);
3773
+ }
3774
+ var flatIndent = (context) => context.baseIndent;
3775
+ function continuedIndent({ except, units = 1 } = {}) {
3776
+ return (context) => {
3777
+ let matchExcept = except && except.test(context.textAfter);
3778
+ return context.baseIndent + (matchExcept ? 0 : units * context.unit);
3779
+ };
3780
+ }
3781
+ var DontIndentBeyond = 200;
3782
+ function indentOnInput() {
3783
+ return EditorState.transactionFilter.of((tr) => {
3784
+ if (!tr.docChanged || !tr.isUserEvent("input.type") && !tr.isUserEvent("input.complete"))
3785
+ return tr;
3786
+ let rules = tr.startState.languageDataAt("indentOnInput", tr.startState.selection.main.head);
3787
+ if (!rules.length)
3788
+ return tr;
3789
+ let doc = tr.newDoc, { head } = tr.newSelection.main, line = doc.lineAt(head);
3790
+ if (head > line.from + DontIndentBeyond)
3791
+ return tr;
3792
+ let lineStart = doc.sliceString(line.from, head);
3793
+ if (!rules.some((r) => r.test(lineStart)))
3794
+ return tr;
3795
+ let { state } = tr, last = -1, changes = [];
3796
+ for (let { head: head2 } of state.selection.ranges) {
3797
+ let line2 = state.doc.lineAt(head2);
3798
+ if (line2.from == last)
3799
+ continue;
3800
+ last = line2.from;
3801
+ let indent = getIndentation(state, line2.from);
3802
+ if (indent == null)
3803
+ continue;
3804
+ let cur = /^\s*/.exec(line2.text)[0];
3805
+ let norm = indentString(state, indent);
3806
+ if (cur != norm)
3807
+ changes.push({ from: line2.from, to: line2.from + cur.length, insert: norm });
3808
+ }
3809
+ return changes.length ? [tr, { changes, sequential: true }] : tr;
3810
+ });
3811
+ }
3812
+ var foldService = /* @__PURE__ */ Facet.define();
3813
+ var foldNodeProp = /* @__PURE__ */ new NodeProp();
3814
+ function foldInside(node) {
3815
+ let first = node.firstChild, last = node.lastChild;
3816
+ return first && first.to < last.from ? { from: first.to, to: last.type.isError ? node.to : last.from } : null;
3817
+ }
3818
+ function syntaxFolding(state, start, end) {
3819
+ let tree = syntaxTree(state);
3820
+ if (tree.length < end)
3821
+ return null;
3822
+ let stack = tree.resolveStack(end, 1);
3823
+ let found = null;
3824
+ for (let iter = stack; iter; iter = iter.next) {
3825
+ let cur = iter.node;
3826
+ if (cur.to <= end || cur.from > end)
3827
+ continue;
3828
+ if (found && cur.from < start)
3829
+ break;
3830
+ let prop = cur.type.prop(foldNodeProp);
3831
+ if (prop && (cur.to < tree.length - 50 || tree.length == state.doc.length || !isUnfinished(cur))) {
3832
+ let value = prop(cur, state);
3833
+ if (value && value.from <= end && value.from >= start && value.to > end)
3834
+ found = value;
3835
+ }
3836
+ }
3837
+ return found;
3838
+ }
3839
+ function isUnfinished(node) {
3840
+ let ch = node.lastChild;
3841
+ return ch && ch.to == node.to && ch.type.isError;
3842
+ }
3843
+ function foldable(state, lineStart, lineEnd) {
3844
+ for (let service of state.facet(foldService)) {
3845
+ let result = service(state, lineStart, lineEnd);
3846
+ if (result)
3847
+ return result;
3848
+ }
3849
+ return syntaxFolding(state, lineStart, lineEnd);
3850
+ }
3851
+ function mapRange(range, mapping) {
3852
+ let from = mapping.mapPos(range.from, 1), to = mapping.mapPos(range.to, -1);
3853
+ return from >= to ? void 0 : { from, to };
3854
+ }
3855
+ var foldEffect = /* @__PURE__ */ StateEffect.define({ map: mapRange });
3856
+ var unfoldEffect = /* @__PURE__ */ StateEffect.define({ map: mapRange });
3857
+ function selectedLines(view) {
3858
+ let lines = [];
3859
+ for (let { head } of view.state.selection.ranges) {
3860
+ if (lines.some((l) => l.from <= head && l.to >= head))
3861
+ continue;
3862
+ lines.push(view.lineBlockAt(head));
3863
+ }
3864
+ return lines;
3865
+ }
3866
+ var foldState = /* @__PURE__ */ StateField.define({
3867
+ create() {
3868
+ return Decoration.none;
3869
+ },
3870
+ update(folded, tr) {
3871
+ if (tr.isUserEvent("delete"))
3872
+ tr.changes.iterChangedRanges((fromA, toA) => folded = clearTouchedFolds(folded, fromA, toA));
3873
+ folded = folded.map(tr.changes);
3874
+ let rangesToFold = [];
3875
+ for (let e of tr.effects) {
3876
+ if (e.is(foldEffect) && !foldExists(folded, e.value.from, e.value.to)) {
3877
+ rangesToFold.push(e.value);
3878
+ } else if (e.is(unfoldEffect)) {
3879
+ folded = folded.update({
3880
+ filter: (from, to) => e.value.from != from || e.value.to != to,
3881
+ filterFrom: e.value.from,
3882
+ filterTo: e.value.to
3883
+ });
3884
+ }
3885
+ }
3886
+ if (rangesToFold.length) {
3887
+ let { preparePlaceholder } = tr.state.facet(foldConfig);
3888
+ let decorations = rangesToFold.map((value) => {
3889
+ let widget = !preparePlaceholder ? foldWidget : Decoration.replace({ widget: new PreparedFoldWidget(preparePlaceholder(tr.state, value)) });
3890
+ return widget.range(value.from, value.to);
3891
+ });
3892
+ folded = folded.update({ add: decorations });
3893
+ }
3894
+ if (tr.selection)
3895
+ folded = clearTouchedFolds(folded, tr.selection.main.head);
3896
+ return folded;
3897
+ },
3898
+ provide: (f) => EditorView.decorations.from(f),
3899
+ toJSON(folded, state) {
3900
+ let ranges = [];
3901
+ folded.between(0, state.doc.length, (from, to) => {
3902
+ ranges.push(from, to);
3903
+ });
3904
+ return ranges;
3905
+ },
3906
+ fromJSON(value) {
3907
+ if (!Array.isArray(value) || value.length % 2)
3908
+ throw new RangeError("Invalid JSON for fold state");
3909
+ let ranges = [];
3910
+ for (let i = 0; i < value.length; ) {
3911
+ let from = value[i++], to = value[i++];
3912
+ if (typeof from != "number" || typeof to != "number")
3913
+ throw new RangeError("Invalid JSON for fold state");
3914
+ ranges.push(foldWidget.range(from, to));
3915
+ }
3916
+ return Decoration.set(ranges, true);
3917
+ }
3918
+ });
3919
+ function clearTouchedFolds(folded, from, to = from) {
3920
+ let touched = false;
3921
+ folded.between(from, to, (a, b) => {
3922
+ if (a < to && b > from)
3923
+ touched = true;
3924
+ });
3925
+ return !touched ? folded : folded.update({
3926
+ filterFrom: from,
3927
+ filterTo: to,
3928
+ filter: (a, b) => a >= to || b <= from
3929
+ });
3930
+ }
3931
+ function findFold(state, from, to) {
3932
+ var _a2;
3933
+ let found = null;
3934
+ (_a2 = state.field(foldState, false)) === null || _a2 === void 0 ? void 0 : _a2.between(from, to, (from2, to2) => {
3935
+ if (!found || found.from > from2)
3936
+ found = { from: from2, to: to2 };
3937
+ });
3938
+ return found;
3939
+ }
3940
+ function foldExists(folded, from, to) {
3941
+ let found = false;
3942
+ folded.between(from, from, (a, b) => {
3943
+ if (a == from && b == to)
3944
+ found = true;
3945
+ });
3946
+ return found;
3947
+ }
3948
+ function maybeEnable(state, other) {
3949
+ return state.field(foldState, false) ? other : other.concat(StateEffect.appendConfig.of(codeFolding()));
3950
+ }
3951
+ var foldCode = (view) => {
3952
+ for (let line of selectedLines(view)) {
3953
+ let range = foldable(view.state, line.from, line.to);
3954
+ if (range) {
3955
+ view.dispatch({ effects: maybeEnable(view.state, [foldEffect.of(range), announceFold(view, range)]) });
3956
+ return true;
3957
+ }
3958
+ }
3959
+ return false;
3960
+ };
3961
+ var unfoldCode = (view) => {
3962
+ if (!view.state.field(foldState, false))
3963
+ return false;
3964
+ let effects = [];
3965
+ for (let line of selectedLines(view)) {
3966
+ let folded = findFold(view.state, line.from, line.to);
3967
+ if (folded)
3968
+ effects.push(unfoldEffect.of(folded), announceFold(view, folded, false));
3969
+ }
3970
+ if (effects.length)
3971
+ view.dispatch({ effects });
3972
+ return effects.length > 0;
3973
+ };
3974
+ function announceFold(view, range, fold = true) {
3975
+ let lineFrom = view.state.doc.lineAt(range.from).number, lineTo = view.state.doc.lineAt(range.to).number;
3976
+ return EditorView.announce.of(`${view.state.phrase(fold ? "Folded lines" : "Unfolded lines")} ${lineFrom} ${view.state.phrase("to")} ${lineTo}.`);
3977
+ }
3978
+ var foldAll = (view) => {
3979
+ let { state } = view, effects = [];
3980
+ for (let pos = 0; pos < state.doc.length; ) {
3981
+ let line = view.lineBlockAt(pos), range = foldable(state, line.from, line.to);
3982
+ if (range)
3983
+ effects.push(foldEffect.of(range));
3984
+ pos = (range ? view.lineBlockAt(range.to) : line).to + 1;
3985
+ }
3986
+ if (effects.length)
3987
+ view.dispatch({ effects: maybeEnable(view.state, effects) });
3988
+ return !!effects.length;
3989
+ };
3990
+ var unfoldAll = (view) => {
3991
+ let field = view.state.field(foldState, false);
3992
+ if (!field || !field.size)
3993
+ return false;
3994
+ let effects = [];
3995
+ field.between(0, view.state.doc.length, (from, to) => {
3996
+ effects.push(unfoldEffect.of({ from, to }));
3997
+ });
3998
+ view.dispatch({ effects });
3999
+ return true;
4000
+ };
4001
+ var foldKeymap = [
4002
+ { key: "Ctrl-Shift-[", mac: "Cmd-Alt-[", run: foldCode },
4003
+ { key: "Ctrl-Shift-]", mac: "Cmd-Alt-]", run: unfoldCode },
4004
+ { key: "Ctrl-Alt-[", run: foldAll },
4005
+ { key: "Ctrl-Alt-]", run: unfoldAll }
4006
+ ];
4007
+ var defaultConfig = {
4008
+ placeholderDOM: null,
4009
+ preparePlaceholder: null,
4010
+ placeholderText: "\u2026"
4011
+ };
4012
+ var foldConfig = /* @__PURE__ */ Facet.define({
4013
+ combine(values) {
4014
+ return combineConfig(values, defaultConfig);
4015
+ }
4016
+ });
4017
+ function codeFolding(config) {
4018
+ let result = [foldState, baseTheme$1];
4019
+ if (config)
4020
+ result.push(foldConfig.of(config));
4021
+ return result;
4022
+ }
4023
+ function widgetToDOM(view, prepared) {
4024
+ let { state } = view, conf = state.facet(foldConfig);
4025
+ let onclick = (event) => {
4026
+ let line = view.lineBlockAt(view.posAtDOM(event.target));
4027
+ let folded = findFold(view.state, line.from, line.to);
4028
+ if (folded)
4029
+ view.dispatch({ effects: unfoldEffect.of(folded) });
4030
+ event.preventDefault();
4031
+ };
4032
+ if (conf.placeholderDOM)
4033
+ return conf.placeholderDOM(view, onclick, prepared);
4034
+ let element = document.createElement("span");
4035
+ element.textContent = conf.placeholderText;
4036
+ element.setAttribute("aria-label", state.phrase("folded code"));
4037
+ element.title = state.phrase("unfold");
4038
+ element.className = "cm-foldPlaceholder";
4039
+ element.onclick = onclick;
4040
+ return element;
4041
+ }
4042
+ var foldWidget = /* @__PURE__ */ Decoration.replace({ widget: /* @__PURE__ */ new class extends WidgetType {
4043
+ toDOM(view) {
4044
+ return widgetToDOM(view, null);
4045
+ }
4046
+ }() });
4047
+ var PreparedFoldWidget = class extends WidgetType {
4048
+ constructor(value) {
4049
+ super();
4050
+ this.value = value;
4051
+ }
4052
+ eq(other) {
4053
+ return this.value == other.value;
4054
+ }
4055
+ toDOM(view) {
4056
+ return widgetToDOM(view, this.value);
4057
+ }
4058
+ };
4059
+ var baseTheme$1 = /* @__PURE__ */ EditorView.baseTheme({
4060
+ ".cm-foldPlaceholder": {
4061
+ backgroundColor: "#eee",
4062
+ border: "1px solid #ddd",
4063
+ color: "#888",
4064
+ borderRadius: ".2em",
4065
+ margin: "0 1px",
4066
+ padding: "0 1px",
4067
+ cursor: "pointer"
4068
+ },
4069
+ ".cm-foldGutter span": {
4070
+ padding: "0 1px",
4071
+ cursor: "pointer"
4072
+ }
4073
+ });
4074
+ var HighlightStyle = class _HighlightStyle {
4075
+ constructor(specs, options) {
4076
+ this.specs = specs;
4077
+ let modSpec;
4078
+ function def(spec) {
4079
+ let cls = StyleModule.newName();
4080
+ (modSpec || (modSpec = /* @__PURE__ */ Object.create(null)))["." + cls] = spec;
4081
+ return cls;
4082
+ }
4083
+ const all = typeof options.all == "string" ? options.all : options.all ? def(options.all) : void 0;
4084
+ const scopeOpt = options.scope;
4085
+ this.scope = scopeOpt instanceof Language ? (type) => type.prop(languageDataProp) == scopeOpt.data : scopeOpt ? (type) => type == scopeOpt : void 0;
4086
+ this.style = tagHighlighter(specs.map((style) => ({
4087
+ tag: style.tag,
4088
+ class: style.class || def(Object.assign({}, style, { tag: null }))
4089
+ })), {
4090
+ all
4091
+ }).style;
4092
+ this.module = modSpec ? new StyleModule(modSpec) : null;
4093
+ this.themeType = options.themeType;
4094
+ }
4095
+ /**
4096
+ Create a highlighter style that associates the given styles to
4097
+ the given tags. The specs must be objects that hold a style tag
4098
+ or array of tags in their `tag` property, and either a single
4099
+ `class` property providing a static CSS class (for highlighter
4100
+ that rely on external styling), or a
4101
+ [`style-mod`](https://code.haverbeke.berlin/marijn/style-mod#documentation)-style
4102
+ set of CSS properties (which define the styling for those tags).
4103
+
4104
+ The CSS rules created for a highlighter will be emitted in the
4105
+ order of the spec's properties. That means that for elements that
4106
+ have multiple tags associated with them, styles defined further
4107
+ down in the list will have a higher CSS precedence than styles
4108
+ defined earlier.
4109
+ */
4110
+ static define(specs, options) {
4111
+ return new _HighlightStyle(specs, options || {});
4112
+ }
4113
+ };
4114
+ var highlighterFacet = /* @__PURE__ */ Facet.define();
4115
+ var fallbackHighlighter = /* @__PURE__ */ Facet.define({
4116
+ combine(values) {
4117
+ return values.length ? [values[0]] : null;
4118
+ }
4119
+ });
4120
+ function getHighlighters(state) {
4121
+ let main = state.facet(highlighterFacet);
4122
+ return main.length ? main : state.facet(fallbackHighlighter);
4123
+ }
4124
+ function syntaxHighlighting(highlighter, options) {
4125
+ let ext = [treeHighlighter], themeType;
4126
+ if (highlighter instanceof HighlightStyle) {
4127
+ if (highlighter.module)
4128
+ ext.push(EditorView.styleModule.of(highlighter.module));
4129
+ themeType = highlighter.themeType;
4130
+ }
4131
+ if (options === null || options === void 0 ? void 0 : options.fallback)
4132
+ ext.push(fallbackHighlighter.of(highlighter));
4133
+ else if (themeType)
4134
+ ext.push(highlighterFacet.computeN([EditorView.darkTheme], (state) => {
4135
+ return state.facet(EditorView.darkTheme) == (themeType == "dark") ? [highlighter] : [];
4136
+ }));
4137
+ else
4138
+ ext.push(highlighterFacet.of(highlighter));
4139
+ return ext;
4140
+ }
4141
+ var TreeHighlighter = class {
4142
+ constructor(view) {
4143
+ this.markCache = /* @__PURE__ */ Object.create(null);
4144
+ this.tree = syntaxTree(view.state);
4145
+ this.decorations = this.buildDeco(view, getHighlighters(view.state));
4146
+ this.decoratedTo = view.viewport.to;
4147
+ }
4148
+ update(update) {
4149
+ let tree = syntaxTree(update.state), highlighters = getHighlighters(update.state);
4150
+ let styleChange = highlighters != getHighlighters(update.startState);
4151
+ let { viewport } = update.view, decoratedToMapped = update.changes.mapPos(this.decoratedTo, 1);
4152
+ if (tree.length < viewport.to && !styleChange && tree.type == this.tree.type && decoratedToMapped >= viewport.to) {
4153
+ this.decorations = this.decorations.map(update.changes);
4154
+ this.decoratedTo = decoratedToMapped;
4155
+ } else if (tree != this.tree || update.viewportChanged || styleChange) {
4156
+ this.tree = tree;
4157
+ this.decorations = this.buildDeco(update.view, highlighters);
4158
+ this.decoratedTo = viewport.to;
4159
+ }
4160
+ }
4161
+ buildDeco(view, highlighters) {
4162
+ if (!highlighters || !this.tree.length)
4163
+ return Decoration.none;
4164
+ let builder = new RangeSetBuilder();
4165
+ for (let { from, to } of view.visibleRanges) {
4166
+ highlightTree(this.tree, highlighters, (from2, to2, style) => {
4167
+ builder.add(from2, to2, this.markCache[style] || (this.markCache[style] = Decoration.mark({ class: style })));
4168
+ }, from, to);
4169
+ }
4170
+ return builder.finish();
4171
+ }
4172
+ };
4173
+ var treeHighlighter = /* @__PURE__ */ Prec.high(/* @__PURE__ */ ViewPlugin.fromClass(TreeHighlighter, {
4174
+ decorations: (v) => v.decorations
4175
+ }));
4176
+ var defaultHighlightStyle = /* @__PURE__ */ HighlightStyle.define([
4177
+ {
4178
+ tag: tags.meta,
4179
+ color: "#404740"
4180
+ },
4181
+ {
4182
+ tag: tags.link,
4183
+ textDecoration: "underline"
4184
+ },
4185
+ {
4186
+ tag: tags.heading,
4187
+ textDecoration: "underline",
4188
+ fontWeight: "bold"
4189
+ },
4190
+ {
4191
+ tag: tags.emphasis,
4192
+ fontStyle: "italic"
4193
+ },
4194
+ {
4195
+ tag: tags.strong,
4196
+ fontWeight: "bold"
4197
+ },
4198
+ {
4199
+ tag: tags.strikethrough,
4200
+ textDecoration: "line-through"
4201
+ },
4202
+ {
4203
+ tag: tags.keyword,
4204
+ color: "#708"
4205
+ },
4206
+ {
4207
+ tag: [tags.atom, tags.bool, tags.url, tags.contentSeparator, tags.labelName],
4208
+ color: "#219"
4209
+ },
4210
+ {
4211
+ tag: [tags.literal, tags.inserted],
4212
+ color: "#164"
4213
+ },
4214
+ {
4215
+ tag: [tags.string, tags.deleted],
4216
+ color: "#a11"
4217
+ },
4218
+ {
4219
+ tag: [tags.regexp, tags.escape, /* @__PURE__ */ tags.special(tags.string)],
4220
+ color: "#e40"
4221
+ },
4222
+ {
4223
+ tag: /* @__PURE__ */ tags.definition(tags.variableName),
4224
+ color: "#00f"
4225
+ },
4226
+ {
4227
+ tag: /* @__PURE__ */ tags.local(tags.variableName),
4228
+ color: "#30a"
4229
+ },
4230
+ {
4231
+ tag: [tags.typeName, tags.namespace],
4232
+ color: "#085"
4233
+ },
4234
+ {
4235
+ tag: tags.className,
4236
+ color: "#167"
4237
+ },
4238
+ {
4239
+ tag: [/* @__PURE__ */ tags.special(tags.variableName), tags.macroName],
4240
+ color: "#256"
4241
+ },
4242
+ {
4243
+ tag: /* @__PURE__ */ tags.definition(tags.propertyName),
4244
+ color: "#00c"
4245
+ },
4246
+ {
4247
+ tag: tags.comment,
4248
+ color: "#940"
4249
+ },
4250
+ {
4251
+ tag: tags.invalid,
4252
+ color: "#f00"
4253
+ }
4254
+ ]);
4255
+ var DefaultScanDist = 1e4;
4256
+ var DefaultBrackets = "()[]{}";
4257
+ var bracketMatchingHandle = /* @__PURE__ */ new NodeProp();
4258
+ function matchingNodes(node, dir, brackets) {
4259
+ let byProp = node.prop(dir < 0 ? NodeProp.openedBy : NodeProp.closedBy);
4260
+ if (byProp)
4261
+ return byProp;
4262
+ if (node.name.length == 1) {
4263
+ let index = brackets.indexOf(node.name);
4264
+ if (index > -1 && index % 2 == (dir < 0 ? 1 : 0))
4265
+ return [brackets[index + dir]];
4266
+ }
4267
+ return null;
4268
+ }
4269
+ function findHandle(node) {
4270
+ let hasHandle = node.type.prop(bracketMatchingHandle);
4271
+ return hasHandle ? hasHandle(node.node) : node;
4272
+ }
4273
+ function matchBrackets(state, pos, dir, config = {}) {
4274
+ let maxScanDistance = config.maxScanDistance || DefaultScanDist, brackets = config.brackets || DefaultBrackets;
4275
+ let tree = syntaxTree(state), node = tree.resolveInner(pos, dir);
4276
+ for (let cur = node; cur; cur = cur.parent) {
4277
+ let matches = matchingNodes(cur.type, dir, brackets);
4278
+ if (matches && cur.from < cur.to) {
4279
+ let handle = findHandle(cur);
4280
+ if (handle && (dir > 0 ? pos >= handle.from && pos < handle.to : pos > handle.from && pos <= handle.to))
4281
+ return matchMarkedBrackets(state, pos, dir, cur, handle, matches, brackets);
4282
+ }
4283
+ }
4284
+ return matchPlainBrackets(state, pos, dir, tree, node.type, maxScanDistance, brackets);
4285
+ }
4286
+ function matchMarkedBrackets(_state, _pos, dir, token, handle, matching, brackets) {
4287
+ let parent = token.parent, firstToken = { from: handle.from, to: handle.to };
4288
+ let depth = 0, cursor = parent === null || parent === void 0 ? void 0 : parent.cursor();
4289
+ if (cursor && (dir < 0 ? cursor.childBefore(token.from) : cursor.childAfter(token.to)))
4290
+ do {
4291
+ if (dir < 0 ? cursor.to <= token.from : cursor.from >= token.to) {
4292
+ if (depth == 0 && matching.indexOf(cursor.type.name) > -1 && cursor.from < cursor.to) {
4293
+ let endHandle = findHandle(cursor);
4294
+ return { start: firstToken, end: endHandle ? { from: endHandle.from, to: endHandle.to } : void 0, matched: true };
4295
+ } else if (matchingNodes(cursor.type, dir, brackets)) {
4296
+ depth++;
4297
+ } else if (matchingNodes(cursor.type, -dir, brackets)) {
4298
+ if (depth == 0) {
4299
+ let endHandle = findHandle(cursor);
4300
+ return {
4301
+ start: firstToken,
4302
+ end: endHandle && endHandle.from < endHandle.to ? { from: endHandle.from, to: endHandle.to } : void 0,
4303
+ matched: false
4304
+ };
4305
+ }
4306
+ depth--;
4307
+ }
4308
+ }
4309
+ } while (dir < 0 ? cursor.prevSibling() : cursor.nextSibling());
4310
+ return { start: firstToken, matched: false };
4311
+ }
4312
+ function matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, brackets) {
4313
+ if (dir < 0 ? !pos : pos == state.doc.length)
4314
+ return null;
4315
+ let startCh = dir < 0 ? state.sliceDoc(pos - 1, pos) : state.sliceDoc(pos, pos + 1);
4316
+ let bracket2 = brackets.indexOf(startCh);
4317
+ if (bracket2 < 0 || bracket2 % 2 == 0 != dir > 0)
4318
+ return null;
4319
+ let startToken = { from: dir < 0 ? pos - 1 : pos, to: dir > 0 ? pos + 1 : pos };
4320
+ let iter = state.doc.iterRange(pos, dir > 0 ? state.doc.length : 0), depth = 0;
4321
+ for (let distance = 0; !iter.next().done && distance <= maxScanDistance; ) {
4322
+ let text = iter.value;
4323
+ if (dir < 0)
4324
+ distance += text.length;
4325
+ let basePos = pos + distance * dir;
4326
+ for (let pos2 = dir > 0 ? 0 : text.length - 1, end = dir > 0 ? text.length : -1; pos2 != end; pos2 += dir) {
4327
+ let found = brackets.indexOf(text[pos2]);
4328
+ if (found < 0 || tree.resolveInner(basePos + pos2, 1).type != tokenType)
4329
+ continue;
4330
+ if (found % 2 == 0 == dir > 0) {
4331
+ depth++;
4332
+ } else if (depth == 1) {
4333
+ return { start: startToken, end: { from: basePos + pos2, to: basePos + pos2 + 1 }, matched: found >> 1 == bracket2 >> 1 };
4334
+ } else {
4335
+ depth--;
4336
+ }
4337
+ }
4338
+ if (dir > 0)
4339
+ distance += text.length;
4340
+ }
4341
+ return iter.done ? { start: startToken, matched: false } : null;
4342
+ }
4343
+ function countCol(string2, end, tabSize, startIndex = 0, startValue = 0) {
4344
+ if (end == null) {
4345
+ end = string2.search(/[^\s\u00a0]/);
4346
+ if (end == -1)
4347
+ end = string2.length;
4348
+ }
4349
+ let n = startValue;
4350
+ for (let i = startIndex; i < end; i++) {
4351
+ if (string2.charCodeAt(i) == 9)
4352
+ n += tabSize - n % tabSize;
4353
+ else
4354
+ n++;
4355
+ }
4356
+ return n;
4357
+ }
4358
+ var StringStream = class {
4359
+ /**
4360
+ Create a stream.
4361
+ */
4362
+ constructor(string2, tabSize, indentUnit2, overrideIndent) {
4363
+ this.string = string2;
4364
+ this.tabSize = tabSize;
4365
+ this.indentUnit = indentUnit2;
4366
+ this.overrideIndent = overrideIndent;
4367
+ this.pos = 0;
4368
+ this.start = 0;
4369
+ this.lastColumnPos = 0;
4370
+ this.lastColumnValue = 0;
4371
+ }
4372
+ /**
4373
+ True if we are at the end of the line.
4374
+ */
4375
+ eol() {
4376
+ return this.pos >= this.string.length;
4377
+ }
4378
+ /**
4379
+ True if we are at the start of the line.
4380
+ */
4381
+ sol() {
4382
+ return this.pos == 0;
4383
+ }
4384
+ /**
4385
+ Get the next code unit after the current position, or undefined
4386
+ if we're at the end of the line.
4387
+ */
4388
+ peek() {
4389
+ return this.string.charAt(this.pos) || void 0;
4390
+ }
4391
+ /**
4392
+ Read the next code unit and advance `this.pos`.
4393
+ */
4394
+ next() {
4395
+ if (this.pos < this.string.length)
4396
+ return this.string.charAt(this.pos++);
4397
+ }
4398
+ /**
4399
+ Match the next character against the given string, regular
4400
+ expression, or predicate. Consume and return it if it matches.
4401
+ */
4402
+ eat(match) {
4403
+ let ch = this.string.charAt(this.pos);
4404
+ let ok;
4405
+ if (typeof match == "string")
4406
+ ok = ch == match;
4407
+ else
4408
+ ok = ch && (match instanceof RegExp ? match.test(ch) : match(ch));
4409
+ if (ok) {
4410
+ ++this.pos;
4411
+ return ch;
4412
+ }
4413
+ }
4414
+ /**
4415
+ Continue matching characters that match the given string,
4416
+ regular expression, or predicate function. Return true if any
4417
+ characters were consumed.
4418
+ */
4419
+ eatWhile(match) {
4420
+ let start = this.pos;
4421
+ while (this.eat(match)) {
4422
+ }
4423
+ return this.pos > start;
4424
+ }
4425
+ /**
4426
+ Consume whitespace ahead of `this.pos`. Return true if any was
4427
+ found.
4428
+ */
4429
+ eatSpace() {
4430
+ let start = this.pos;
4431
+ while (/[\s\u00a0]/.test(this.string.charAt(this.pos)))
4432
+ ++this.pos;
4433
+ return this.pos > start;
4434
+ }
4435
+ /**
4436
+ Move to the end of the line.
4437
+ */
4438
+ skipToEnd() {
4439
+ this.pos = this.string.length;
4440
+ }
4441
+ /**
4442
+ Move to directly before the given character, if found on the
4443
+ current line.
4444
+ */
4445
+ skipTo(ch) {
4446
+ let found = this.string.indexOf(ch, this.pos);
4447
+ if (found > -1) {
4448
+ this.pos = found;
4449
+ return true;
4450
+ }
4451
+ }
4452
+ /**
4453
+ Move back `n` characters.
4454
+ */
4455
+ backUp(n) {
4456
+ this.pos -= n;
4457
+ }
4458
+ /**
4459
+ Get the column position at `this.pos`.
4460
+ */
4461
+ column() {
4462
+ if (this.lastColumnPos < this.start) {
4463
+ this.lastColumnValue = countCol(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
4464
+ this.lastColumnPos = this.start;
4465
+ }
4466
+ return this.lastColumnValue;
4467
+ }
4468
+ /**
4469
+ Get the indentation column of the current line.
4470
+ */
4471
+ indentation() {
4472
+ var _a2;
4473
+ return (_a2 = this.overrideIndent) !== null && _a2 !== void 0 ? _a2 : countCol(this.string, null, this.tabSize);
4474
+ }
4475
+ /**
4476
+ Match the input against the given string or regular expression
4477
+ (which should start with a `^`). Return true or the regexp match
4478
+ if it matches.
4479
+
4480
+ Unless `consume` is set to `false`, this will move `this.pos`
4481
+ past the matched text.
4482
+
4483
+ When matching a string `caseInsensitive` can be set to true to
4484
+ make the match case-insensitive.
4485
+ */
4486
+ match(pattern, consume, caseInsensitive) {
4487
+ if (typeof pattern == "string") {
4488
+ let cased = (str) => caseInsensitive ? str.toLowerCase() : str;
4489
+ let substr = this.string.substr(this.pos, pattern.length);
4490
+ if (cased(substr) == cased(pattern)) {
4491
+ if (consume !== false)
4492
+ this.pos += pattern.length;
4493
+ return true;
4494
+ } else
4495
+ return null;
4496
+ } else {
4497
+ let match = this.string.slice(this.pos).match(pattern);
4498
+ if (match && match.index > 0)
4499
+ return null;
4500
+ if (match && consume !== false)
4501
+ this.pos += match[0].length;
4502
+ return match;
4503
+ }
4504
+ }
4505
+ /**
4506
+ Get the current token.
4507
+ */
4508
+ current() {
4509
+ return this.string.slice(this.start, this.pos);
4510
+ }
4511
+ };
4512
+ function fullParser(spec) {
4513
+ return {
4514
+ name: spec.name || "",
4515
+ token: spec.token,
4516
+ blankLine: spec.blankLine || (() => {
4517
+ }),
4518
+ startState: spec.startState || (() => true),
4519
+ copyState: spec.copyState || defaultCopyState,
4520
+ indent: spec.indent || (() => null),
4521
+ languageData: spec.languageData || {},
4522
+ tokenTable: spec.tokenTable || noTokens,
4523
+ mergeTokens: spec.mergeTokens !== false
4524
+ };
4525
+ }
4526
+ function defaultCopyState(state) {
4527
+ if (typeof state != "object")
4528
+ return state;
4529
+ let newState = {};
4530
+ for (let prop in state) {
4531
+ let val = state[prop];
4532
+ newState[prop] = val instanceof Array ? val.slice() : val;
4533
+ }
4534
+ return newState;
4535
+ }
4536
+ var IndentedFrom = /* @__PURE__ */ new WeakMap();
4537
+ var StreamLanguage = class _StreamLanguage extends Language {
4538
+ constructor(parser) {
4539
+ let data = defineLanguageFacet(parser.languageData);
4540
+ let p = fullParser(parser), self;
4541
+ let impl = new class extends Parser {
4542
+ createParse(input, fragments, ranges) {
4543
+ return new Parse(self, input, fragments, ranges);
4544
+ }
4545
+ }();
4546
+ super(data, impl, [], parser.name);
4547
+ this.topNode = docID(data, this);
4548
+ self = this;
4549
+ this.streamParser = p;
4550
+ this.stateAfter = new NodeProp({ perNode: true });
4551
+ this.tokenTable = parser.tokenTable ? new TokenTable(p.tokenTable) : defaultTokenTable;
4552
+ }
4553
+ /**
4554
+ Define a stream language.
4555
+ */
4556
+ static define(spec) {
4557
+ return new _StreamLanguage(spec);
4558
+ }
4559
+ /**
4560
+ @internal
4561
+ */
4562
+ getIndent(cx) {
4563
+ let from = void 0;
4564
+ let { overrideIndentation } = cx.options;
4565
+ if (overrideIndentation) {
4566
+ from = IndentedFrom.get(cx.state);
4567
+ if (from != null && from < cx.pos - 1e4)
4568
+ from = void 0;
4569
+ }
4570
+ let start = findState(this, cx.node.tree, cx.node.from, cx.node.from, from !== null && from !== void 0 ? from : cx.pos), statePos, state;
4571
+ if (start) {
4572
+ state = start.state;
4573
+ statePos = start.pos + 1;
4574
+ } else {
4575
+ state = this.streamParser.startState(cx.unit);
4576
+ statePos = cx.node.from;
4577
+ }
4578
+ if (cx.pos - statePos > 1e4)
4579
+ return null;
4580
+ while (statePos < cx.pos) {
4581
+ let line2 = cx.state.doc.lineAt(statePos), end = Math.min(cx.pos, line2.to);
4582
+ if (line2.length) {
4583
+ let indentation = overrideIndentation ? overrideIndentation(line2.from) : -1;
4584
+ let stream = new StringStream(line2.text, cx.state.tabSize, cx.unit, indentation < 0 ? void 0 : indentation);
4585
+ while (stream.pos < end - line2.from)
4586
+ readToken(this.streamParser.token, stream, state);
4587
+ } else {
4588
+ this.streamParser.blankLine(state, cx.unit);
4589
+ }
4590
+ if (end == cx.pos)
4591
+ break;
4592
+ statePos = line2.to + 1;
4593
+ }
4594
+ let line = cx.lineAt(cx.pos);
4595
+ if (overrideIndentation && from == null)
4596
+ IndentedFrom.set(cx.state, line.from);
4597
+ return this.streamParser.indent(state, /^\s*(.*)/.exec(line.text)[1], cx);
4598
+ }
4599
+ get allowsNesting() {
4600
+ return false;
4601
+ }
4602
+ };
4603
+ function findState(lang, tree, off, startPos, before) {
4604
+ let state = off >= startPos && off + tree.length <= before && tree.prop(lang.stateAfter);
4605
+ if (state)
4606
+ return { state: lang.streamParser.copyState(state), pos: off + tree.length };
4607
+ for (let i = tree.children.length - 1; i >= 0; i--) {
4608
+ let child = tree.children[i], pos = off + tree.positions[i];
4609
+ let found = child instanceof Tree && pos < before && findState(lang, child, pos, startPos, before);
4610
+ if (found)
4611
+ return found;
4612
+ }
4613
+ return null;
4614
+ }
4615
+ function cutTree(lang, tree, from, to, inside) {
4616
+ if (inside && from <= 0 && to >= tree.length)
4617
+ return tree;
4618
+ if (!inside && from == 0 && tree.type == lang.topNode)
4619
+ inside = true;
4620
+ for (let i = tree.children.length - 1; i >= 0; i--) {
4621
+ let pos = tree.positions[i], child = tree.children[i], inner;
4622
+ if (pos < to && child instanceof Tree) {
4623
+ if (!(inner = cutTree(lang, child, from - pos, to - pos, inside)))
4624
+ break;
4625
+ return !inside ? inner : new Tree(tree.type, tree.children.slice(0, i).concat(inner), tree.positions.slice(0, i + 1), pos + inner.length);
4626
+ }
4627
+ }
4628
+ return null;
4629
+ }
4630
+ function findStartInFragments(lang, fragments, startPos, endPos, editorState) {
4631
+ for (let f of fragments) {
4632
+ let from = f.from + (f.openStart ? 25 : 0), to = f.to - (f.openEnd ? 25 : 0);
4633
+ let found = from <= startPos && to > startPos && findState(lang, f.tree, 0 - f.offset, startPos, to), tree;
4634
+ if (found && found.pos <= endPos && (tree = cutTree(lang, f.tree, startPos + f.offset, found.pos + f.offset, false)))
4635
+ return { state: found.state, tree };
4636
+ }
4637
+ return { state: lang.streamParser.startState(editorState ? getIndentUnit(editorState) : 4), tree: Tree.empty };
4638
+ }
4639
+ var Parse = class {
4640
+ constructor(lang, input, fragments, ranges) {
4641
+ this.lang = lang;
4642
+ this.input = input;
4643
+ this.fragments = fragments;
4644
+ this.ranges = ranges;
4645
+ this.stoppedAt = null;
4646
+ this.chunks = [];
4647
+ this.chunkPos = [];
4648
+ this.chunk = [];
4649
+ this.chunkReused = void 0;
4650
+ this.rangeIndex = 0;
4651
+ this.to = ranges[ranges.length - 1].to;
4652
+ let context = ParseContext.get(), from = ranges[0].from;
4653
+ let { state, tree } = findStartInFragments(lang, fragments, from, this.to, context === null || context === void 0 ? void 0 : context.state);
4654
+ this.state = state;
4655
+ this.parsedPos = this.chunkStart = from + tree.length;
4656
+ for (let i = 0; i < tree.children.length; i++) {
4657
+ this.chunks.push(tree.children[i]);
4658
+ this.chunkPos.push(tree.positions[i]);
4659
+ }
4660
+ if (context && this.parsedPos < context.viewport.from - 1e5 && ranges.some((r) => r.from <= context.viewport.from && r.to >= context.viewport.from)) {
4661
+ this.state = this.lang.streamParser.startState(getIndentUnit(context.state));
4662
+ context.skipUntilInView(this.parsedPos, context.viewport.from);
4663
+ this.parsedPos = context.viewport.from;
4664
+ }
4665
+ this.moveRangeIndex();
4666
+ }
4667
+ advance() {
4668
+ let context = ParseContext.get();
4669
+ let parseEnd = this.stoppedAt == null ? this.to : Math.min(this.to, this.stoppedAt);
4670
+ let end = Math.min(
4671
+ parseEnd,
4672
+ this.chunkStart + 512
4673
+ /* C.ChunkSize */
4674
+ );
4675
+ if (context)
4676
+ end = Math.min(end, context.viewport.to);
4677
+ while (this.parsedPos < end)
4678
+ this.parseLine(context);
4679
+ if (this.chunkStart < this.parsedPos)
4680
+ this.finishChunk();
4681
+ if (this.parsedPos >= parseEnd)
4682
+ return this.finish();
4683
+ if (context && this.parsedPos >= context.viewport.to) {
4684
+ context.skipUntilInView(this.parsedPos, parseEnd);
4685
+ return this.finish();
4686
+ }
4687
+ return null;
4688
+ }
4689
+ stopAt(pos) {
4690
+ this.stoppedAt = pos;
4691
+ }
4692
+ lineAfter(pos) {
4693
+ let chunk = this.input.chunk(pos);
4694
+ if (!this.input.lineChunks) {
4695
+ let eol = chunk.indexOf("\n");
4696
+ if (eol > -1)
4697
+ chunk = chunk.slice(0, eol);
4698
+ } else if (chunk == "\n") {
4699
+ chunk = "";
4700
+ }
4701
+ return pos + chunk.length <= this.to ? chunk : chunk.slice(0, this.to - pos);
4702
+ }
4703
+ nextLine() {
4704
+ let from = this.parsedPos, line = this.lineAfter(from), end = from + line.length;
4705
+ for (let index = this.rangeIndex; ; ) {
4706
+ let rangeEnd = this.ranges[index].to;
4707
+ if (rangeEnd >= end)
4708
+ break;
4709
+ line = line.slice(0, rangeEnd - (end - line.length));
4710
+ index++;
4711
+ if (index == this.ranges.length)
4712
+ break;
4713
+ let rangeStart = this.ranges[index].from;
4714
+ let after = this.lineAfter(rangeStart);
4715
+ line += after;
4716
+ end = rangeStart + after.length;
4717
+ }
4718
+ return { line, end };
4719
+ }
4720
+ skipGapsTo(pos, offset, side) {
4721
+ for (; ; ) {
4722
+ let end = this.ranges[this.rangeIndex].to, offPos = pos + offset;
4723
+ if (side > 0 ? end > offPos : end >= offPos)
4724
+ break;
4725
+ let start = this.ranges[++this.rangeIndex].from;
4726
+ offset += start - end;
4727
+ }
4728
+ return offset;
4729
+ }
4730
+ moveRangeIndex() {
4731
+ while (this.ranges[this.rangeIndex].to < this.parsedPos)
4732
+ this.rangeIndex++;
4733
+ }
4734
+ emitToken(id, from, to, offset) {
4735
+ let size = 4;
4736
+ if (this.ranges.length > 1) {
4737
+ offset = this.skipGapsTo(from, offset, 1);
4738
+ from += offset;
4739
+ let len0 = this.chunk.length;
4740
+ offset = this.skipGapsTo(to, offset, -1);
4741
+ to += offset;
4742
+ size += this.chunk.length - len0;
4743
+ }
4744
+ let last = this.chunk.length - 4;
4745
+ if (this.lang.streamParser.mergeTokens && size == 4 && last >= 0 && this.chunk[last] == id && this.chunk[last + 2] == from)
4746
+ this.chunk[last + 2] = to;
4747
+ else
4748
+ this.chunk.push(id, from, to, size);
4749
+ return offset;
4750
+ }
4751
+ parseLine(context) {
4752
+ let { line, end } = this.nextLine(), offset = 0, { streamParser } = this.lang;
4753
+ let stream = new StringStream(line, context ? context.state.tabSize : 4, context ? getIndentUnit(context.state) : 2);
4754
+ if (stream.eol()) {
4755
+ streamParser.blankLine(this.state, stream.indentUnit);
4756
+ } else {
4757
+ while (!stream.eol()) {
4758
+ let token = readToken(streamParser.token, stream, this.state);
4759
+ if (token)
4760
+ offset = this.emitToken(this.lang.tokenTable.resolve(token), this.parsedPos + stream.start, this.parsedPos + stream.pos, offset);
4761
+ if (stream.start > 1e4)
4762
+ break;
4763
+ }
4764
+ }
4765
+ this.parsedPos = end;
4766
+ this.moveRangeIndex();
4767
+ if (this.parsedPos < this.to)
4768
+ this.parsedPos++;
4769
+ }
4770
+ finishChunk() {
4771
+ let tree = Tree.build({
4772
+ buffer: this.chunk,
4773
+ start: this.chunkStart,
4774
+ length: this.parsedPos - this.chunkStart,
4775
+ nodeSet,
4776
+ topID: 0,
4777
+ maxBufferLength: 512,
4778
+ reused: this.chunkReused
4779
+ });
4780
+ tree = new Tree(tree.type, tree.children, tree.positions, tree.length, [[this.lang.stateAfter, this.lang.streamParser.copyState(this.state)]]);
4781
+ this.chunks.push(tree);
4782
+ this.chunkPos.push(this.chunkStart - this.ranges[0].from);
4783
+ this.chunk = [];
4784
+ this.chunkReused = void 0;
4785
+ this.chunkStart = this.parsedPos;
4786
+ }
4787
+ finish() {
4788
+ return new Tree(this.lang.topNode, this.chunks, this.chunkPos, this.parsedPos - this.ranges[0].from).balance();
4789
+ }
4790
+ };
4791
+ function readToken(token, stream, state) {
4792
+ stream.start = stream.pos;
4793
+ for (let i = 0; i < 10; i++) {
4794
+ let result = token(stream, state);
4795
+ if (stream.pos > stream.start)
4796
+ return result;
4797
+ }
4798
+ throw new Error("Stream parser failed to advance stream.");
4799
+ }
4800
+ var noTokens = /* @__PURE__ */ Object.create(null);
4801
+ var typeArray = [NodeType.none];
4802
+ var nodeSet = /* @__PURE__ */ new NodeSet(typeArray);
4803
+ var warned = [];
4804
+ var byTag = /* @__PURE__ */ Object.create(null);
4805
+ var defaultTable = /* @__PURE__ */ Object.create(null);
4806
+ for (let [legacyName, name2] of [
4807
+ ["variable", "variableName"],
4808
+ ["variable-2", "variableName.special"],
4809
+ ["string-2", "string.special"],
4810
+ ["def", "variableName.definition"],
4811
+ ["tag", "tagName"],
4812
+ ["attribute", "attributeName"],
4813
+ ["type", "typeName"],
4814
+ ["builtin", "variableName.standard"],
4815
+ ["qualifier", "modifier"],
4816
+ ["error", "invalid"],
4817
+ ["header", "heading"],
4818
+ ["property", "propertyName"]
4819
+ ])
4820
+ defaultTable[legacyName] = /* @__PURE__ */ createTokenType(noTokens, name2);
4821
+ var TokenTable = class {
4822
+ constructor(extra) {
4823
+ this.extra = extra;
4824
+ this.table = Object.assign(/* @__PURE__ */ Object.create(null), defaultTable);
4825
+ }
4826
+ resolve(tag) {
4827
+ return !tag ? 0 : this.table[tag] || (this.table[tag] = createTokenType(this.extra, tag));
4828
+ }
4829
+ };
4830
+ var defaultTokenTable = /* @__PURE__ */ new TokenTable(noTokens);
4831
+ function warnForPart(part, msg) {
4832
+ if (warned.indexOf(part) > -1)
4833
+ return;
4834
+ warned.push(part);
4835
+ console.warn(msg);
4836
+ }
4837
+ function createTokenType(extra, tagStr) {
4838
+ let tags$1 = [];
4839
+ for (let name3 of tagStr.split(" ")) {
4840
+ let found = [];
4841
+ for (let part of name3.split(".")) {
4842
+ let value = extra[part] || tags[part];
4843
+ if (!value) {
4844
+ warnForPart(part, `Unknown highlighting tag ${part}`);
4845
+ } else if (typeof value == "function") {
4846
+ if (!found.length)
4847
+ warnForPart(part, `Modifier ${part} used at start of tag`);
4848
+ else
4849
+ found = found.map(value);
4850
+ } else {
4851
+ if (found.length)
4852
+ warnForPart(part, `Tag ${part} used as modifier`);
4853
+ else
4854
+ found = Array.isArray(value) ? value : [value];
4855
+ }
4856
+ }
4857
+ for (let tag of found)
4858
+ tags$1.push(tag);
4859
+ }
4860
+ if (!tags$1.length)
4861
+ return 0;
4862
+ let name2 = tagStr.replace(/ /g, "_"), key = name2 + " " + tags$1.map((t2) => t2.id);
4863
+ let known = byTag[key];
4864
+ if (known)
4865
+ return known.id;
4866
+ let type = byTag[key] = NodeType.define({
4867
+ id: typeArray.length,
4868
+ name: name2,
4869
+ props: [styleTags({ [name2]: tags$1 })]
4870
+ });
4871
+ typeArray.push(type);
4872
+ return type.id;
4873
+ }
4874
+ function docID(data, lang) {
4875
+ let type = NodeType.define({ id: typeArray.length, name: "Document", props: [
4876
+ languageDataProp.add(() => data),
4877
+ indentNodeProp.add(() => (cx) => lang.getIndent(cx))
4878
+ ], top: true });
4879
+ typeArray.push(type);
4880
+ return type;
4881
+ }
4882
+ var marks = {
4883
+ rtl: /* @__PURE__ */ Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "rtl" }, bidiIsolate: Direction.RTL }),
4884
+ ltr: /* @__PURE__ */ Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "ltr" }, bidiIsolate: Direction.LTR }),
4885
+ auto: /* @__PURE__ */ Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "auto" }, bidiIsolate: null })
4886
+ };
4887
+
4888
+ export {
4889
+ DefaultBufferLength,
4890
+ NodeProp,
4891
+ NodeType,
4892
+ NodeSet,
4893
+ IterMode,
4894
+ Tree,
4895
+ NodeWeakMap,
4896
+ Parser,
4897
+ parseMixed,
4898
+ Tag,
4899
+ styleTags,
4900
+ tags,
4901
+ languageDataProp,
4902
+ defineLanguageFacet,
4903
+ sublanguageProp,
4904
+ Language,
4905
+ LRLanguage,
4906
+ syntaxTree,
4907
+ ParseContext,
4908
+ LanguageSupport,
4909
+ LanguageDescription,
4910
+ indentUnit,
4911
+ getIndentUnit,
4912
+ indentString,
4913
+ getIndentation,
4914
+ IndentContext,
4915
+ indentNodeProp,
4916
+ delimitedIndent,
4917
+ flatIndent,
4918
+ continuedIndent,
4919
+ indentOnInput,
4920
+ foldService,
4921
+ foldNodeProp,
4922
+ foldInside,
4923
+ foldKeymap,
4924
+ HighlightStyle,
4925
+ syntaxHighlighting,
4926
+ bracketMatchingHandle,
4927
+ matchBrackets,
4928
+ StreamLanguage
4929
+ };
4930
+ //# sourceMappingURL=chunk-MAW6NPUW.js.map