herm-tui 1.0.0-dev.1 → 1.0.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/highlights-eq9cgrbb.scm +604 -0
  2. package/highlights-ghv9g403.scm +205 -0
  3. package/highlights-hk7bwhj4.scm +284 -0
  4. package/highlights-r812a2qc.scm +150 -0
  5. package/highlights-x6tmsnaa.scm +115 -0
  6. package/index.js +10375 -0
  7. package/injections-73j83es3.scm +27 -0
  8. package/package.json +14 -64
  9. package/parser.worker.js +8 -0
  10. package/tree-sitter-3jzf13jk.wasm +0 -0
  11. package/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
  12. package/tree-sitter-markdown-411r6y9b.wasm +0 -0
  13. package/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
  14. package/tree-sitter-typescript-zxjzwt75.wasm +0 -0
  15. package/tree-sitter-zig-e78zbjpm.wasm +0 -0
  16. package/scripts/postinstall.ts +0 -29
  17. package/src/app/gateway.tsx +0 -83
  18. package/src/app/gatewayEvents.ts +0 -203
  19. package/src/app/launch.ts +0 -41
  20. package/src/app/skin.tsx +0 -31
  21. package/src/app/spawnHistory.ts +0 -75
  22. package/src/app/tabs.ts +0 -23
  23. package/src/app/turnReducer.ts +0 -390
  24. package/src/app/useAppKeys.ts +0 -268
  25. package/src/app/useAtRefPopover.ts +0 -99
  26. package/src/app/useInputHistory.ts +0 -66
  27. package/src/app/useSession.ts +0 -102
  28. package/src/app/useSlashCommands.ts +0 -70
  29. package/src/app/useSlashPopover.ts +0 -48
  30. package/src/app.tsx +0 -917
  31. package/src/commands/slash.ts +0 -151
  32. package/src/components/avatar/AnimatedAvatar.tsx +0 -66
  33. package/src/components/avatar/eikon.ts +0 -144
  34. package/src/components/avatar/states/error.ts +0 -1155
  35. package/src/components/avatar/states/idle.ts +0 -1155
  36. package/src/components/avatar/states/index.ts +0 -30
  37. package/src/components/avatar/states/listening.ts +0 -1155
  38. package/src/components/avatar/states/speaking.ts +0 -1155
  39. package/src/components/avatar/states/thinking.ts +0 -1155
  40. package/src/components/avatar/states/working.ts +0 -1155
  41. package/src/components/chat/AtRefPopover.tsx +0 -54
  42. package/src/components/chat/CodeBlock.tsx +0 -67
  43. package/src/components/chat/Composer.tsx +0 -347
  44. package/src/components/chat/DiffBlock.tsx +0 -116
  45. package/src/components/chat/ErrorBlock.tsx +0 -70
  46. package/src/components/chat/MediaChip.tsx +0 -114
  47. package/src/components/chat/MessageItem.tsx +0 -282
  48. package/src/components/chat/MessageList.tsx +0 -114
  49. package/src/components/chat/PromptCard.tsx +0 -359
  50. package/src/components/chat/SlashPopover.tsx +0 -158
  51. package/src/components/chat/ThoughtCloud.tsx +0 -185
  52. package/src/components/chat/TypingIndicator.tsx +0 -25
  53. package/src/components/chat/tool/Subagent.tsx +0 -75
  54. package/src/components/chat/tool/frame.tsx +0 -69
  55. package/src/components/chat/tool/index.tsx +0 -65
  56. package/src/components/chat/tool/preview.ts +0 -57
  57. package/src/components/sidebar/ContextGauge.tsx +0 -102
  58. package/src/components/sidebar/Sidebar.tsx +0 -143
  59. package/src/components/tabs/TabBar.tsx +0 -50
  60. package/src/components/ui/FileLink.tsx +0 -52
  61. package/src/config/index.ts +0 -156
  62. package/src/config/lane.ts +0 -161
  63. package/src/config/models.ts +0 -95
  64. package/src/config/rules.ts +0 -80
  65. package/src/config/schema.ts +0 -308
  66. package/src/dialogs/alert.tsx +0 -52
  67. package/src/dialogs/chafa.tsx +0 -72
  68. package/src/dialogs/confirm.tsx +0 -58
  69. package/src/dialogs/curator.tsx +0 -153
  70. package/src/dialogs/eikon-picker.tsx +0 -95
  71. package/src/dialogs/help.tsx +0 -80
  72. package/src/dialogs/history.tsx +0 -92
  73. package/src/dialogs/info.tsx +0 -115
  74. package/src/dialogs/keys.tsx +0 -170
  75. package/src/dialogs/logs.tsx +0 -42
  76. package/src/dialogs/message.tsx +0 -38
  77. package/src/dialogs/model-picker.tsx +0 -123
  78. package/src/dialogs/new-profile.tsx +0 -69
  79. package/src/dialogs/new-task.tsx +0 -103
  80. package/src/dialogs/profile.tsx +0 -55
  81. package/src/dialogs/rollback.tsx +0 -190
  82. package/src/dialogs/spawn-history.tsx +0 -80
  83. package/src/dialogs/text-prompt.tsx +0 -68
  84. package/src/dialogs/theme-picker.tsx +0 -50
  85. package/src/home/index.ts +0 -23
  86. package/src/home/store.ts +0 -267
  87. package/src/index.tsx +0 -113
  88. package/src/keys/catalog.ts +0 -115
  89. package/src/keys/chord.ts +0 -125
  90. package/src/keys/conflicts.ts +0 -48
  91. package/src/keys/context.tsx +0 -112
  92. package/src/keys/index.ts +0 -5
  93. package/src/keys/list.ts +0 -94
  94. package/src/keys/oc-compat.ts +0 -87
  95. package/src/tabs/Agents.tsx +0 -607
  96. package/src/tabs/Analytics.tsx +0 -154
  97. package/src/tabs/Chat.tsx +0 -50
  98. package/src/tabs/Config.tsx +0 -605
  99. package/src/tabs/Context.tsx +0 -599
  100. package/src/tabs/Cron.tsx +0 -294
  101. package/src/tabs/Env.tsx +0 -227
  102. package/src/tabs/Kanban.tsx +0 -367
  103. package/src/tabs/Memory.tsx +0 -294
  104. package/src/tabs/Sessions.tsx +0 -786
  105. package/src/tabs/Skills.tsx +0 -507
  106. package/src/tabs/Toolsets.tsx +0 -266
  107. package/src/theme/builtin.ts +0 -78
  108. package/src/theme/context.tsx +0 -106
  109. package/src/theme/index.ts +0 -4
  110. package/src/theme/resolve.ts +0 -134
  111. package/src/theme/syntax.ts +0 -31
  112. package/src/theme/themes/aura.json +0 -69
  113. package/src/theme/themes/ayu.json +0 -80
  114. package/src/theme/themes/carbonfox.json +0 -248
  115. package/src/theme/themes/catppuccin-frappe.json +0 -233
  116. package/src/theme/themes/catppuccin-macchiato.json +0 -233
  117. package/src/theme/themes/catppuccin.json +0 -112
  118. package/src/theme/themes/cobalt2.json +0 -228
  119. package/src/theme/themes/cursor.json +0 -249
  120. package/src/theme/themes/dracula.json +0 -219
  121. package/src/theme/themes/everforest.json +0 -241
  122. package/src/theme/themes/flexoki.json +0 -237
  123. package/src/theme/themes/github.json +0 -233
  124. package/src/theme/themes/gruvbox.json +0 -242
  125. package/src/theme/themes/kanagawa.json +0 -77
  126. package/src/theme/themes/lucent-orng.json +0 -237
  127. package/src/theme/themes/material.json +0 -235
  128. package/src/theme/themes/matrix.json +0 -77
  129. package/src/theme/themes/mercury.json +0 -252
  130. package/src/theme/themes/monokai.json +0 -221
  131. package/src/theme/themes/nightowl.json +0 -221
  132. package/src/theme/themes/nord.json +0 -223
  133. package/src/theme/themes/one-dark.json +0 -84
  134. package/src/theme/themes/opencode.json +0 -245
  135. package/src/theme/themes/orng.json +0 -249
  136. package/src/theme/themes/osaka-jade.json +0 -93
  137. package/src/theme/themes/palenight.json +0 -222
  138. package/src/theme/themes/rosepine.json +0 -234
  139. package/src/theme/themes/solarized.json +0 -223
  140. package/src/theme/themes/synthwave84.json +0 -226
  141. package/src/theme/themes/tokyonight.json +0 -243
  142. package/src/theme/themes/vercel.json +0 -245
  143. package/src/theme/themes/vesper.json +0 -218
  144. package/src/theme/themes/zenburn.json +0 -223
  145. package/src/theme/types.ts +0 -119
  146. package/src/types/message.ts +0 -97
  147. package/src/ui/ChafaImage.tsx +0 -64
  148. package/src/ui/Splash.tsx +0 -118
  149. package/src/ui/borders.ts +0 -28
  150. package/src/ui/command.tsx +0 -104
  151. package/src/ui/dialog-select.tsx +0 -164
  152. package/src/ui/dialog.tsx +0 -102
  153. package/src/ui/fmt.ts +0 -82
  154. package/src/ui/kv.tsx +0 -28
  155. package/src/ui/shell.tsx +0 -45
  156. package/src/ui/spinner.tsx +0 -59
  157. package/src/ui/splash-art.ts +0 -123
  158. package/src/ui/table.tsx +0 -117
  159. package/src/ui/ticker.tsx +0 -90
  160. package/src/ui/toast.tsx +0 -130
  161. package/src/utils/categorical.ts +0 -77
  162. package/src/utils/chafa.ts +0 -173
  163. package/src/utils/clipboard.ts +0 -67
  164. package/src/utils/context-segments.ts +0 -317
  165. package/src/utils/control.ts +0 -495
  166. package/src/utils/drop.ts +0 -25
  167. package/src/utils/editor.ts +0 -33
  168. package/src/utils/fuzzy.ts +0 -45
  169. package/src/utils/gateway-client.ts +0 -253
  170. package/src/utils/gateway-types.ts +0 -282
  171. package/src/utils/git.ts +0 -57
  172. package/src/utils/hermes-analytics.ts +0 -134
  173. package/src/utils/hermes-home.ts +0 -821
  174. package/src/utils/hermes-kanban.ts +0 -154
  175. package/src/utils/hermes-profiles.ts +0 -217
  176. package/src/utils/interpolate.ts +0 -31
  177. package/src/utils/math-unicode.ts +0 -818
  178. package/src/utils/memory-activity.ts +0 -140
  179. package/src/utils/open-file.ts +0 -13
  180. package/src/utils/paths.ts +0 -52
  181. package/src/utils/perf.ts +0 -235
  182. package/src/utils/preferences.ts +0 -150
  183. package/src/utils/sessions-db.ts +0 -396
  184. package/src/utils/subagent-tree.ts +0 -146
  185. package/src/utils/terminal-reset.ts +0 -129
  186. package/src/utils/tips.ts +0 -67
  187. package/src/utils/tokens.ts +0 -87
@@ -0,0 +1,27 @@
1
+ ; Query from: https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/refs/heads/master/queries/markdown/injections.scm
2
+ (fenced_code_block
3
+ (info_string
4
+ (language) @_lang)
5
+ (code_fence_content) @injection.content
6
+ (#set-lang-from-info-string! @_lang))
7
+
8
+ ((html_block) @injection.content
9
+ (#set! injection.language "html")
10
+ (#set! injection.combined)
11
+ (#set! injection.include-children))
12
+
13
+ ((minus_metadata) @injection.content
14
+ (#set! injection.language "yaml")
15
+ (#offset! @injection.content 1 0 -1 0)
16
+ (#set! injection.include-children))
17
+
18
+ ((plus_metadata) @injection.content
19
+ (#set! injection.language "toml")
20
+ (#offset! @injection.content 1 0 -1 0)
21
+ (#set! injection.include-children))
22
+
23
+ ([
24
+ (inline)
25
+ (pipe_table_cell)
26
+ ] @injection.content
27
+ (#set! injection.language "markdown_inline"))
package/package.json CHANGED
@@ -1,13 +1,8 @@
1
1
  {
2
2
  "name": "herm-tui",
3
- "version": "1.0.0-dev.1",
3
+ "version": "1.0.0-dev.2",
4
4
  "description": "A modern TUI for Hermes Agent",
5
- "type": "module",
6
5
  "license": "MIT",
7
- "publishConfig": {
8
- "access": "public",
9
- "provenance": true
10
- },
11
6
  "repository": {
12
7
  "type": "git",
13
8
  "url": "https://github.com/liftaris/herm.git"
@@ -16,67 +11,22 @@
16
11
  "bugs": {
17
12
  "url": "https://github.com/liftaris/herm/issues"
18
13
  },
19
- "bin": {
20
- "herm": "src/index.tsx"
21
- },
22
14
  "engines": {
23
15
  "bun": ">=1.3.0"
24
16
  },
25
- "files": [
26
- "src",
27
- "!src/**/*.test.*",
28
- "scripts/postinstall.ts",
29
- "README.md",
30
- "LICENSE"
31
- ],
32
- "scripts": {
33
- "dev": "bun run --watch src/index.tsx",
34
- "dev:perf": "PERF=1 bun run --watch src/index.tsx",
35
- "dev:perf:verbose": "PERF=verbose bun run --watch src/index.tsx",
36
- "dev:smol": "bun --smol run --watch src/index.tsx",
37
- "dev:profile": "bun --cpu-prof --cpu-prof-dir=./profiles run src/index.tsx",
38
- "dev:heap": "bun --heap-prof --heap-prof-dir=./profiles run src/index.tsx",
39
- "dev:control": "CONTROL=1 bun run --watch src/index.tsx",
40
- "dev:full": "PERF=1 CONTROL=1 bun run --watch src/index.tsx",
41
- "gen-schema": "bun scripts/gen-schema.ts",
42
- "showcase": "scripts/showcase/record.sh",
43
- "build": "bun scripts/gen-schema.ts && bun build src/index.tsx node_modules/@opentui/core/parser.worker.js scripts/parser-worker-shim.ts --target=bun --outdir=dist --minify --entry-naming='[name].[ext]' && mv dist/parser-worker-shim.js dist/parser.worker.shim.js && test -f dist/parser.worker.js && test -f dist/parser.worker.shim.js",
44
- "start": "bun run dist/index.js",
45
- "test": "bun test",
46
- "typecheck": "bunx tsc --noEmit",
47
- "postinstall": "bun run scripts/postinstall.ts"
48
- },
49
- "dependencies": {
50
- "@opentui/core": "0.1.99",
51
- "@opentui/react": "0.1.99",
52
- "gpt-tokenizer": "^3.4.0",
53
- "open": "^11.0.0",
54
- "react": "^19.2.5",
55
- "web-tree-sitter": "0.25.10",
56
- "yaml": "^2.8.3"
57
- },
58
- "devDependencies": {
59
- "@semantic-release/changelog": "^6.0.3",
60
- "@semantic-release/git": "^10.0.1",
61
- "@types/bun": "1.3.13",
62
- "@types/react": "^19.2.14",
63
- "semantic-release": "^25.0.3",
64
- "typescript": "^5.8.2"
17
+ "publishConfig": {
18
+ "access": "public",
19
+ "provenance": true
65
20
  },
66
- "overrides": {
67
- "three": "npm:empty-npm-package@1.0.0",
68
- "planck": "npm:empty-npm-package@1.0.0",
69
- "bun-webgpu": "npm:empty-npm-package@1.0.0",
70
- "@dimforge/rapier2d-simd-compat": "npm:empty-npm-package@1.0.0",
71
- "jimp": "npm:empty-npm-package@1.0.0",
72
- "@jimp/core": "npm:empty-npm-package@1.0.0",
73
- "@jimp/js-bmp": "npm:empty-npm-package@1.0.0",
74
- "@jimp/js-gif": "npm:empty-npm-package@1.0.0",
75
- "@jimp/js-jpeg": "npm:empty-npm-package@1.0.0",
76
- "@jimp/js-png": "npm:empty-npm-package@1.0.0",
77
- "@jimp/js-tiff": "npm:empty-npm-package@1.0.0",
78
- "@jimp/plugin-resize": "npm:empty-npm-package@1.0.0",
79
- "@jimp/types": "npm:empty-npm-package@1.0.0",
80
- "@jimp/utils": "npm:empty-npm-package@1.0.0"
21
+ "bin": {
22
+ "herm": "index.js"
23
+ },
24
+ "optionalDependencies": {
25
+ "@opentui/core-darwin-arm64": "0.2.2",
26
+ "@opentui/core-darwin-x64": "0.2.2",
27
+ "@opentui/core-linux-arm64": "0.2.2",
28
+ "@opentui/core-linux-x64": "0.2.2",
29
+ "@opentui/core-win32-arm64": "0.2.2",
30
+ "@opentui/core-win32-x64": "0.2.2"
81
31
  }
82
32
  }
@@ -0,0 +1,8 @@
1
+ // @bun
2
+ var __create=Object.create;var{getPrototypeOf:__getProtoOf,defineProperty:__defProp,getOwnPropertyNames:__getOwnPropNames}=Object;var __hasOwnProp=Object.prototype.hasOwnProperty;function __accessProp(key){return this[key]}var __toESMCache_node,__toESMCache_esm,__toESM=(mod,isNodeMode,target)=>{var canCache=mod!=null&&typeof mod==="object";if(canCache){var cache=isNodeMode?__toESMCache_node??=new WeakMap:__toESMCache_esm??=new WeakMap,cached=cache.get(mod);if(cached)return cached}target=mod!=null?__create(__getProtoOf(mod)):{};let to=isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target;for(let key of __getOwnPropNames(mod))if(!__hasOwnProp.call(to,key))__defProp(to,key,{get:__accessProp.bind(mod,key),enumerable:!0});if(canCache)cache.set(mod,to);return to};var __commonJS=(cb,mod)=>()=>(mod||cb((mod={exports:{}}).exports,mod),mod.exports);var __returnValue=(v)=>v;function __exportSetter(name2,newValue){this[name2]=__returnValue.bind(null,newValue)}var __export=(target,all)=>{for(var name2 in all)__defProp(target,name2,{get:all[name2],enumerable:!0,configurable:!0,set:__exportSetter.bind(all,name2)})};var __esm=(fn,res)=>()=>(fn&&(res=fn(fn=0)),res);var __require=import.meta.require;var require_tree_sitter=__commonJS((exports,module2)=>{module2.exports=import.meta.dirname+"/tree-sitter-3jzf13jk.wasm"});var __defProp2=Object.defineProperty,__name=(target,value)=>__defProp2(target,"name",{value,configurable:!0}),SIZE_OF_SHORT=2,SIZE_OF_INT=4,SIZE_OF_CURSOR=4*SIZE_OF_INT,SIZE_OF_NODE=5*SIZE_OF_INT,SIZE_OF_POINT=2*SIZE_OF_INT,SIZE_OF_RANGE=2*SIZE_OF_INT+2*SIZE_OF_POINT,ZERO_POINT={row:0,column:0},INTERNAL=Symbol("INTERNAL");function assertInternal(x){if(x!==INTERNAL)throw Error("Illegal constructor")}__name(assertInternal,"assertInternal");function isPoint(point){return!!point&&typeof point.row==="number"&&typeof point.column==="number"}__name(isPoint,"isPoint");function setModule(module2){C=module2}__name(setModule,"setModule");var C,LookaheadIterator=class{static{__name(this,"LookaheadIterator")}[0]=0;language;constructor(internal,address,language){assertInternal(internal),this[0]=address,this.language=language}get currentTypeId(){return C._ts_lookahead_iterator_current_symbol(this[0])}get currentType(){return this.language.types[this.currentTypeId]||"ERROR"}delete(){C._ts_lookahead_iterator_delete(this[0]),this[0]=0}reset(language,stateId){if(C._ts_lookahead_iterator_reset(this[0],language[0],stateId))return this.language=language,!0;return!1}resetState(stateId){return Boolean(C._ts_lookahead_iterator_reset_state(this[0],stateId))}[Symbol.iterator](){return{next:__name(()=>{if(C._ts_lookahead_iterator_next(this[0]))return{done:!1,value:this.currentType};return{done:!0,value:""}},"next")}}};function getText(tree,startIndex,endIndex,startPosition){let length=endIndex-startIndex,result=tree.textCallback(startIndex,startPosition);if(result){startIndex+=result.length;while(startIndex<endIndex){let string=tree.textCallback(startIndex,startPosition);if(string&&string.length>0)startIndex+=string.length,result+=string;else break}if(startIndex>endIndex)result=result.slice(0,length)}return result??""}__name(getText,"getText");var Tree=class _Tree{static{__name(this,"Tree")}[0]=0;textCallback;language;constructor(internal,address,language,textCallback){assertInternal(internal),this[0]=address,this.language=language,this.textCallback=textCallback}copy(){let address=C._ts_tree_copy(this[0]);return new _Tree(INTERNAL,address,this.language,this.textCallback)}delete(){C._ts_tree_delete(this[0]),this[0]=0}get rootNode(){return C._ts_tree_root_node_wasm(this[0]),unmarshalNode(this)}rootNodeWithOffset(offsetBytes,offsetExtent){let address=TRANSFER_BUFFER+SIZE_OF_NODE;return C.setValue(address,offsetBytes,"i32"),marshalPoint(address+SIZE_OF_INT,offsetExtent),C._ts_tree_root_node_with_offset_wasm(this[0]),unmarshalNode(this)}edit(edit){marshalEdit(edit),C._ts_tree_edit_wasm(this[0])}walk(){return this.rootNode.walk()}getChangedRanges(other){if(!(other instanceof _Tree))throw TypeError("Argument must be a Tree");C._ts_tree_get_changed_ranges_wasm(this[0],other[0]);let count=C.getValue(TRANSFER_BUFFER,"i32"),buffer=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),result=Array(count);if(count>0){let address=buffer;for(let i2=0;i2<count;i2++)result[i2]=unmarshalRange(address),address+=SIZE_OF_RANGE;C._free(buffer)}return result}getIncludedRanges(){C._ts_tree_included_ranges_wasm(this[0]);let count=C.getValue(TRANSFER_BUFFER,"i32"),buffer=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),result=Array(count);if(count>0){let address=buffer;for(let i2=0;i2<count;i2++)result[i2]=unmarshalRange(address),address+=SIZE_OF_RANGE;C._free(buffer)}return result}},TreeCursor=class _TreeCursor{static{__name(this,"TreeCursor")}[0]=0;[1]=0;[2]=0;[3]=0;tree;constructor(internal,tree){assertInternal(internal),this.tree=tree,unmarshalTreeCursor(this)}copy(){let copy=new _TreeCursor(INTERNAL,this.tree);return C._ts_tree_cursor_copy_wasm(this.tree[0]),unmarshalTreeCursor(copy),copy}delete(){marshalTreeCursor(this),C._ts_tree_cursor_delete_wasm(this.tree[0]),this[0]=this[1]=this[2]=0}get currentNode(){return marshalTreeCursor(this),C._ts_tree_cursor_current_node_wasm(this.tree[0]),unmarshalNode(this.tree)}get currentFieldId(){return marshalTreeCursor(this),C._ts_tree_cursor_current_field_id_wasm(this.tree[0])}get currentFieldName(){return this.tree.language.fields[this.currentFieldId]}get currentDepth(){return marshalTreeCursor(this),C._ts_tree_cursor_current_depth_wasm(this.tree[0])}get currentDescendantIndex(){return marshalTreeCursor(this),C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0])}get nodeType(){return this.tree.language.types[this.nodeTypeId]||"ERROR"}get nodeTypeId(){return marshalTreeCursor(this),C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0])}get nodeStateId(){return marshalTreeCursor(this),C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0])}get nodeId(){return marshalTreeCursor(this),C._ts_tree_cursor_current_node_id_wasm(this.tree[0])}get nodeIsNamed(){return marshalTreeCursor(this),C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0])===1}get nodeIsMissing(){return marshalTreeCursor(this),C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0])===1}get nodeText(){marshalTreeCursor(this);let startIndex=C._ts_tree_cursor_start_index_wasm(this.tree[0]),endIndex=C._ts_tree_cursor_end_index_wasm(this.tree[0]);C._ts_tree_cursor_start_position_wasm(this.tree[0]);let startPosition=unmarshalPoint(TRANSFER_BUFFER);return getText(this.tree,startIndex,endIndex,startPosition)}get startPosition(){return marshalTreeCursor(this),C._ts_tree_cursor_start_position_wasm(this.tree[0]),unmarshalPoint(TRANSFER_BUFFER)}get endPosition(){return marshalTreeCursor(this),C._ts_tree_cursor_end_position_wasm(this.tree[0]),unmarshalPoint(TRANSFER_BUFFER)}get startIndex(){return marshalTreeCursor(this),C._ts_tree_cursor_start_index_wasm(this.tree[0])}get endIndex(){return marshalTreeCursor(this),C._ts_tree_cursor_end_index_wasm(this.tree[0])}gotoFirstChild(){marshalTreeCursor(this);let result=C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);return unmarshalTreeCursor(this),result===1}gotoLastChild(){marshalTreeCursor(this);let result=C._ts_tree_cursor_goto_last_child_wasm(this.tree[0]);return unmarshalTreeCursor(this),result===1}gotoParent(){marshalTreeCursor(this);let result=C._ts_tree_cursor_goto_parent_wasm(this.tree[0]);return unmarshalTreeCursor(this),result===1}gotoNextSibling(){marshalTreeCursor(this);let result=C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);return unmarshalTreeCursor(this),result===1}gotoPreviousSibling(){marshalTreeCursor(this);let result=C._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]);return unmarshalTreeCursor(this),result===1}gotoDescendant(goalDescendantIndex){marshalTreeCursor(this),C._ts_tree_cursor_goto_descendant_wasm(this.tree[0],goalDescendantIndex),unmarshalTreeCursor(this)}gotoFirstChildForIndex(goalIndex){marshalTreeCursor(this),C.setValue(TRANSFER_BUFFER+SIZE_OF_CURSOR,goalIndex,"i32");let result=C._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]);return unmarshalTreeCursor(this),result===1}gotoFirstChildForPosition(goalPosition){marshalTreeCursor(this),marshalPoint(TRANSFER_BUFFER+SIZE_OF_CURSOR,goalPosition);let result=C._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]);return unmarshalTreeCursor(this),result===1}reset(node){marshalNode(node),marshalTreeCursor(this,TRANSFER_BUFFER+SIZE_OF_NODE),C._ts_tree_cursor_reset_wasm(this.tree[0]),unmarshalTreeCursor(this)}resetTo(cursor){marshalTreeCursor(this,TRANSFER_BUFFER),marshalTreeCursor(cursor,TRANSFER_BUFFER+SIZE_OF_CURSOR),C._ts_tree_cursor_reset_to_wasm(this.tree[0],cursor.tree[0]),unmarshalTreeCursor(this)}},Node=class{static{__name(this,"Node")}[0]=0;_children;_namedChildren;constructor(internal,{id,tree,startIndex,startPosition,other}){assertInternal(internal),this[0]=other,this.id=id,this.tree=tree,this.startIndex=startIndex,this.startPosition=startPosition}id;startIndex;startPosition;tree;get typeId(){return marshalNode(this),C._ts_node_symbol_wasm(this.tree[0])}get grammarId(){return marshalNode(this),C._ts_node_grammar_symbol_wasm(this.tree[0])}get type(){return this.tree.language.types[this.typeId]||"ERROR"}get grammarType(){return this.tree.language.types[this.grammarId]||"ERROR"}get isNamed(){return marshalNode(this),C._ts_node_is_named_wasm(this.tree[0])===1}get isExtra(){return marshalNode(this),C._ts_node_is_extra_wasm(this.tree[0])===1}get isError(){return marshalNode(this),C._ts_node_is_error_wasm(this.tree[0])===1}get isMissing(){return marshalNode(this),C._ts_node_is_missing_wasm(this.tree[0])===1}get hasChanges(){return marshalNode(this),C._ts_node_has_changes_wasm(this.tree[0])===1}get hasError(){return marshalNode(this),C._ts_node_has_error_wasm(this.tree[0])===1}get endIndex(){return marshalNode(this),C._ts_node_end_index_wasm(this.tree[0])}get endPosition(){return marshalNode(this),C._ts_node_end_point_wasm(this.tree[0]),unmarshalPoint(TRANSFER_BUFFER)}get text(){return getText(this.tree,this.startIndex,this.endIndex,this.startPosition)}get parseState(){return marshalNode(this),C._ts_node_parse_state_wasm(this.tree[0])}get nextParseState(){return marshalNode(this),C._ts_node_next_parse_state_wasm(this.tree[0])}equals(other){return this.tree===other.tree&&this.id===other.id}child(index){return marshalNode(this),C._ts_node_child_wasm(this.tree[0],index),unmarshalNode(this.tree)}namedChild(index){return marshalNode(this),C._ts_node_named_child_wasm(this.tree[0],index),unmarshalNode(this.tree)}childForFieldId(fieldId){return marshalNode(this),C._ts_node_child_by_field_id_wasm(this.tree[0],fieldId),unmarshalNode(this.tree)}childForFieldName(fieldName){let fieldId=this.tree.language.fields.indexOf(fieldName);if(fieldId!==-1)return this.childForFieldId(fieldId);return null}fieldNameForChild(index){marshalNode(this);let address=C._ts_node_field_name_for_child_wasm(this.tree[0],index);if(!address)return null;return C.AsciiToString(address)}fieldNameForNamedChild(index){marshalNode(this);let address=C._ts_node_field_name_for_named_child_wasm(this.tree[0],index);if(!address)return null;return C.AsciiToString(address)}childrenForFieldName(fieldName){let fieldId=this.tree.language.fields.indexOf(fieldName);if(fieldId!==-1&&fieldId!==0)return this.childrenForFieldId(fieldId);return[]}childrenForFieldId(fieldId){marshalNode(this),C._ts_node_children_by_field_id_wasm(this.tree[0],fieldId);let count=C.getValue(TRANSFER_BUFFER,"i32"),buffer=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),result=Array(count);if(count>0){let address=buffer;for(let i2=0;i2<count;i2++)result[i2]=unmarshalNode(this.tree,address),address+=SIZE_OF_NODE;C._free(buffer)}return result}firstChildForIndex(index){marshalNode(this);let address=TRANSFER_BUFFER+SIZE_OF_NODE;return C.setValue(address,index,"i32"),C._ts_node_first_child_for_byte_wasm(this.tree[0]),unmarshalNode(this.tree)}firstNamedChildForIndex(index){marshalNode(this);let address=TRANSFER_BUFFER+SIZE_OF_NODE;return C.setValue(address,index,"i32"),C._ts_node_first_named_child_for_byte_wasm(this.tree[0]),unmarshalNode(this.tree)}get childCount(){return marshalNode(this),C._ts_node_child_count_wasm(this.tree[0])}get namedChildCount(){return marshalNode(this),C._ts_node_named_child_count_wasm(this.tree[0])}get firstChild(){return this.child(0)}get firstNamedChild(){return this.namedChild(0)}get lastChild(){return this.child(this.childCount-1)}get lastNamedChild(){return this.namedChild(this.namedChildCount-1)}get children(){if(!this._children){marshalNode(this),C._ts_node_children_wasm(this.tree[0]);let count=C.getValue(TRANSFER_BUFFER,"i32"),buffer=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32");if(this._children=Array(count),count>0){let address=buffer;for(let i2=0;i2<count;i2++)this._children[i2]=unmarshalNode(this.tree,address),address+=SIZE_OF_NODE;C._free(buffer)}}return this._children}get namedChildren(){if(!this._namedChildren){marshalNode(this),C._ts_node_named_children_wasm(this.tree[0]);let count=C.getValue(TRANSFER_BUFFER,"i32"),buffer=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32");if(this._namedChildren=Array(count),count>0){let address=buffer;for(let i2=0;i2<count;i2++)this._namedChildren[i2]=unmarshalNode(this.tree,address),address+=SIZE_OF_NODE;C._free(buffer)}}return this._namedChildren}descendantsOfType(types,startPosition=ZERO_POINT,endPosition=ZERO_POINT){if(!Array.isArray(types))types=[types];let symbols=[],typesBySymbol=this.tree.language.types;for(let node_type of types)if(node_type=="ERROR")symbols.push(65535);for(let i2=0,n=typesBySymbol.length;i2<n;i2++)if(types.includes(typesBySymbol[i2]))symbols.push(i2);let symbolsAddress=C._malloc(SIZE_OF_INT*symbols.length);for(let i2=0,n=symbols.length;i2<n;i2++)C.setValue(symbolsAddress+i2*SIZE_OF_INT,symbols[i2],"i32");marshalNode(this),C._ts_node_descendants_of_type_wasm(this.tree[0],symbolsAddress,symbols.length,startPosition.row,startPosition.column,endPosition.row,endPosition.column);let descendantCount=C.getValue(TRANSFER_BUFFER,"i32"),descendantAddress=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),result=Array(descendantCount);if(descendantCount>0){let address=descendantAddress;for(let i2=0;i2<descendantCount;i2++)result[i2]=unmarshalNode(this.tree,address),address+=SIZE_OF_NODE}return C._free(descendantAddress),C._free(symbolsAddress),result}get nextSibling(){return marshalNode(this),C._ts_node_next_sibling_wasm(this.tree[0]),unmarshalNode(this.tree)}get previousSibling(){return marshalNode(this),C._ts_node_prev_sibling_wasm(this.tree[0]),unmarshalNode(this.tree)}get nextNamedSibling(){return marshalNode(this),C._ts_node_next_named_sibling_wasm(this.tree[0]),unmarshalNode(this.tree)}get previousNamedSibling(){return marshalNode(this),C._ts_node_prev_named_sibling_wasm(this.tree[0]),unmarshalNode(this.tree)}get descendantCount(){return marshalNode(this),C._ts_node_descendant_count_wasm(this.tree[0])}get parent(){return marshalNode(this),C._ts_node_parent_wasm(this.tree[0]),unmarshalNode(this.tree)}childWithDescendant(descendant){return marshalNode(this),marshalNode(descendant,1),C._ts_node_child_with_descendant_wasm(this.tree[0]),unmarshalNode(this.tree)}descendantForIndex(start2,end=start2){if(typeof start2!=="number"||typeof end!=="number")throw Error("Arguments must be numbers");marshalNode(this);let address=TRANSFER_BUFFER+SIZE_OF_NODE;return C.setValue(address,start2,"i32"),C.setValue(address+SIZE_OF_INT,end,"i32"),C._ts_node_descendant_for_index_wasm(this.tree[0]),unmarshalNode(this.tree)}namedDescendantForIndex(start2,end=start2){if(typeof start2!=="number"||typeof end!=="number")throw Error("Arguments must be numbers");marshalNode(this);let address=TRANSFER_BUFFER+SIZE_OF_NODE;return C.setValue(address,start2,"i32"),C.setValue(address+SIZE_OF_INT,end,"i32"),C._ts_node_named_descendant_for_index_wasm(this.tree[0]),unmarshalNode(this.tree)}descendantForPosition(start2,end=start2){if(!isPoint(start2)||!isPoint(end))throw Error("Arguments must be {row, column} objects");marshalNode(this);let address=TRANSFER_BUFFER+SIZE_OF_NODE;return marshalPoint(address,start2),marshalPoint(address+SIZE_OF_POINT,end),C._ts_node_descendant_for_position_wasm(this.tree[0]),unmarshalNode(this.tree)}namedDescendantForPosition(start2,end=start2){if(!isPoint(start2)||!isPoint(end))throw Error("Arguments must be {row, column} objects");marshalNode(this);let address=TRANSFER_BUFFER+SIZE_OF_NODE;return marshalPoint(address,start2),marshalPoint(address+SIZE_OF_POINT,end),C._ts_node_named_descendant_for_position_wasm(this.tree[0]),unmarshalNode(this.tree)}walk(){return marshalNode(this),C._ts_tree_cursor_new_wasm(this.tree[0]),new TreeCursor(INTERNAL,this.tree)}edit(edit){if(this.startIndex>=edit.oldEndIndex){this.startIndex=edit.newEndIndex+(this.startIndex-edit.oldEndIndex);let subbedPointRow,subbedPointColumn;if(this.startPosition.row>edit.oldEndPosition.row)subbedPointRow=this.startPosition.row-edit.oldEndPosition.row,subbedPointColumn=this.startPosition.column;else if(subbedPointRow=0,subbedPointColumn=this.startPosition.column,this.startPosition.column>=edit.oldEndPosition.column)subbedPointColumn=this.startPosition.column-edit.oldEndPosition.column;if(subbedPointRow>0)this.startPosition.row+=subbedPointRow,this.startPosition.column=subbedPointColumn;else this.startPosition.column+=subbedPointColumn}else if(this.startIndex>edit.startIndex)this.startIndex=edit.newEndIndex,this.startPosition.row=edit.newEndPosition.row,this.startPosition.column=edit.newEndPosition.column}toString(){marshalNode(this);let address=C._ts_node_to_string_wasm(this.tree[0]),result=C.AsciiToString(address);return C._free(address),result}};function unmarshalCaptures(query,tree,address,patternIndex,result){for(let i2=0,n=result.length;i2<n;i2++){let captureIndex=C.getValue(address,"i32");address+=SIZE_OF_INT;let node=unmarshalNode(tree,address);address+=SIZE_OF_NODE,result[i2]={patternIndex,name:query.captureNames[captureIndex],node}}return address}__name(unmarshalCaptures,"unmarshalCaptures");function marshalNode(node,index=0){let address=TRANSFER_BUFFER+index*SIZE_OF_NODE;C.setValue(address,node.id,"i32"),address+=SIZE_OF_INT,C.setValue(address,node.startIndex,"i32"),address+=SIZE_OF_INT,C.setValue(address,node.startPosition.row,"i32"),address+=SIZE_OF_INT,C.setValue(address,node.startPosition.column,"i32"),address+=SIZE_OF_INT,C.setValue(address,node[0],"i32")}__name(marshalNode,"marshalNode");function unmarshalNode(tree,address=TRANSFER_BUFFER){let id=C.getValue(address,"i32");if(address+=SIZE_OF_INT,id===0)return null;let index=C.getValue(address,"i32");address+=SIZE_OF_INT;let row=C.getValue(address,"i32");address+=SIZE_OF_INT;let column=C.getValue(address,"i32");address+=SIZE_OF_INT;let other=C.getValue(address,"i32");return new Node(INTERNAL,{id,tree,startIndex:index,startPosition:{row,column},other})}__name(unmarshalNode,"unmarshalNode");function marshalTreeCursor(cursor,address=TRANSFER_BUFFER){C.setValue(address+0*SIZE_OF_INT,cursor[0],"i32"),C.setValue(address+1*SIZE_OF_INT,cursor[1],"i32"),C.setValue(address+2*SIZE_OF_INT,cursor[2],"i32"),C.setValue(address+3*SIZE_OF_INT,cursor[3],"i32")}__name(marshalTreeCursor,"marshalTreeCursor");function unmarshalTreeCursor(cursor){cursor[0]=C.getValue(TRANSFER_BUFFER+0*SIZE_OF_INT,"i32"),cursor[1]=C.getValue(TRANSFER_BUFFER+1*SIZE_OF_INT,"i32"),cursor[2]=C.getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),cursor[3]=C.getValue(TRANSFER_BUFFER+3*SIZE_OF_INT,"i32")}__name(unmarshalTreeCursor,"unmarshalTreeCursor");function marshalPoint(address,point){C.setValue(address,point.row,"i32"),C.setValue(address+SIZE_OF_INT,point.column,"i32")}__name(marshalPoint,"marshalPoint");function unmarshalPoint(address){return{row:C.getValue(address,"i32")>>>0,column:C.getValue(address+SIZE_OF_INT,"i32")>>>0}}__name(unmarshalPoint,"unmarshalPoint");function marshalRange(address,range){marshalPoint(address,range.startPosition),address+=SIZE_OF_POINT,marshalPoint(address,range.endPosition),address+=SIZE_OF_POINT,C.setValue(address,range.startIndex,"i32"),address+=SIZE_OF_INT,C.setValue(address,range.endIndex,"i32"),address+=SIZE_OF_INT}__name(marshalRange,"marshalRange");function unmarshalRange(address){let result={};return result.startPosition=unmarshalPoint(address),address+=SIZE_OF_POINT,result.endPosition=unmarshalPoint(address),address+=SIZE_OF_POINT,result.startIndex=C.getValue(address,"i32")>>>0,address+=SIZE_OF_INT,result.endIndex=C.getValue(address,"i32")>>>0,result}__name(unmarshalRange,"unmarshalRange");function marshalEdit(edit,address=TRANSFER_BUFFER){marshalPoint(address,edit.startPosition),address+=SIZE_OF_POINT,marshalPoint(address,edit.oldEndPosition),address+=SIZE_OF_POINT,marshalPoint(address,edit.newEndPosition),address+=SIZE_OF_POINT,C.setValue(address,edit.startIndex,"i32"),address+=SIZE_OF_INT,C.setValue(address,edit.oldEndIndex,"i32"),address+=SIZE_OF_INT,C.setValue(address,edit.newEndIndex,"i32"),address+=SIZE_OF_INT}__name(marshalEdit,"marshalEdit");function unmarshalLanguageMetadata(address){let major_version=C.getValue(address,"i32"),minor_version=C.getValue(address+=SIZE_OF_INT,"i32"),patch_version=C.getValue(address+=SIZE_OF_INT,"i32");return{major_version,minor_version,patch_version}}__name(unmarshalLanguageMetadata,"unmarshalLanguageMetadata");var PREDICATE_STEP_TYPE_CAPTURE=1,PREDICATE_STEP_TYPE_STRING=2,QUERY_WORD_REGEX=/[\w-]+/g,CaptureQuantifier={Zero:0,ZeroOrOne:1,ZeroOrMore:2,One:3,OneOrMore:4},isCaptureStep=__name((step)=>step.type==="capture","isCaptureStep"),isStringStep=__name((step)=>step.type==="string","isStringStep"),QueryErrorKind={Syntax:1,NodeName:2,FieldName:3,CaptureName:4,PatternStructure:5},QueryError=class _QueryError extends Error{constructor(kind,info2,index,length){super(_QueryError.formatMessage(kind,info2));this.kind=kind,this.info=info2,this.index=index,this.length=length,this.name="QueryError"}static{__name(this,"QueryError")}static formatMessage(kind,info2){switch(kind){case QueryErrorKind.NodeName:return`Bad node name '${info2.word}'`;case QueryErrorKind.FieldName:return`Bad field name '${info2.word}'`;case QueryErrorKind.CaptureName:return`Bad capture name @${info2.word}`;case QueryErrorKind.PatternStructure:return`Bad pattern structure at offset ${info2.suffix}`;case QueryErrorKind.Syntax:return`Bad syntax at offset ${info2.suffix}`}}};function parseAnyPredicate(steps,index,operator,textPredicates){if(steps.length!==3)throw Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length-1}`);if(!isCaptureStep(steps[1]))throw Error(`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}"`);let isPositive=operator==="eq?"||operator==="any-eq?",matchAll=!operator.startsWith("any-");if(isCaptureStep(steps[2])){let captureName1=steps[1].name,captureName2=steps[2].name;textPredicates[index].push((captures)=>{let nodes1=[],nodes2=[];for(let c of captures){if(c.name===captureName1)nodes1.push(c.node);if(c.name===captureName2)nodes2.push(c.node)}let compare=__name((n1,n2,positive)=>{return positive?n1.text===n2.text:n1.text!==n2.text},"compare");return matchAll?nodes1.every((n1)=>nodes2.some((n2)=>compare(n1,n2,isPositive))):nodes1.some((n1)=>nodes2.some((n2)=>compare(n1,n2,isPositive)))})}else{let captureName=steps[1].name,stringValue=steps[2].value,matches=__name((n)=>n.text===stringValue,"matches"),doesNotMatch=__name((n)=>n.text!==stringValue,"doesNotMatch");textPredicates[index].push((captures)=>{let nodes=[];for(let c of captures)if(c.name===captureName)nodes.push(c.node);let test=isPositive?matches:doesNotMatch;return matchAll?nodes.every(test):nodes.some(test)})}}__name(parseAnyPredicate,"parseAnyPredicate");function parseMatchPredicate(steps,index,operator,textPredicates){if(steps.length!==3)throw Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length-1}.`);if(steps[1].type!=="capture")throw Error(`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`);if(steps[2].type!=="string")throw Error(`Second argument of \`#${operator}\` predicate must be a string. Got @${steps[2].name}.`);let isPositive=operator==="match?"||operator==="any-match?",matchAll=!operator.startsWith("any-"),captureName=steps[1].name,regex=new RegExp(steps[2].value);textPredicates[index].push((captures)=>{let nodes=[];for(let c of captures)if(c.name===captureName)nodes.push(c.node.text);let test=__name((text,positive)=>{return positive?regex.test(text):!regex.test(text)},"test");if(nodes.length===0)return!isPositive;return matchAll?nodes.every((text)=>test(text,isPositive)):nodes.some((text)=>test(text,isPositive))})}__name(parseMatchPredicate,"parseMatchPredicate");function parseAnyOfPredicate(steps,index,operator,textPredicates){if(steps.length<2)throw Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected at least 1. Got ${steps.length-1}.`);if(steps[1].type!=="capture")throw Error(`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`);let isPositive=operator==="any-of?",captureName=steps[1].name,stringSteps=steps.slice(2);if(!stringSteps.every(isStringStep))throw Error(`Arguments to \`#${operator}\` predicate must be strings.".`);let values=stringSteps.map((s)=>s.value);textPredicates[index].push((captures)=>{let nodes=[];for(let c of captures)if(c.name===captureName)nodes.push(c.node.text);if(nodes.length===0)return!isPositive;return nodes.every((text)=>values.includes(text))===isPositive})}__name(parseAnyOfPredicate,"parseAnyOfPredicate");function parseIsPredicate(steps,index,operator,assertedProperties,refutedProperties){if(steps.length<2||steps.length>3)throw Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 1 or 2. Got ${steps.length-1}.`);if(!steps.every(isStringStep))throw Error(`Arguments to \`#${operator}\` predicate must be strings.".`);let properties=operator==="is?"?assertedProperties:refutedProperties;if(!properties[index])properties[index]={};properties[index][steps[1].value]=steps[2]?.value??null}__name(parseIsPredicate,"parseIsPredicate");function parseSetDirective(steps,index,setProperties){if(steps.length<2||steps.length>3)throw Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${steps.length-1}.`);if(!steps.every(isStringStep))throw Error('Arguments to `#set!` predicate must be strings.".');if(!setProperties[index])setProperties[index]={};setProperties[index][steps[1].value]=steps[2]?.value??null}__name(parseSetDirective,"parseSetDirective");function parsePattern(index,stepType,stepValueId,captureNames,stringValues,steps,textPredicates,predicates,setProperties,assertedProperties,refutedProperties){if(stepType===PREDICATE_STEP_TYPE_CAPTURE){let name2=captureNames[stepValueId];steps.push({type:"capture",name:name2})}else if(stepType===PREDICATE_STEP_TYPE_STRING)steps.push({type:"string",value:stringValues[stepValueId]});else if(steps.length>0){if(steps[0].type!=="string")throw Error("Predicates must begin with a literal value");let operator=steps[0].value;switch(operator){case"any-not-eq?":case"not-eq?":case"any-eq?":case"eq?":parseAnyPredicate(steps,index,operator,textPredicates);break;case"any-not-match?":case"not-match?":case"any-match?":case"match?":parseMatchPredicate(steps,index,operator,textPredicates);break;case"not-any-of?":case"any-of?":parseAnyOfPredicate(steps,index,operator,textPredicates);break;case"is?":case"is-not?":parseIsPredicate(steps,index,operator,assertedProperties,refutedProperties);break;case"set!":parseSetDirective(steps,index,setProperties);break;default:predicates[index].push({operator,operands:steps.slice(1)})}steps.length=0}}__name(parsePattern,"parsePattern");var Query=class{static{__name(this,"Query")}[0]=0;exceededMatchLimit;textPredicates;captureNames;captureQuantifiers;predicates;setProperties;assertedProperties;refutedProperties;matchLimit;constructor(language,source){let sourceLength=C.lengthBytesUTF8(source),sourceAddress=C._malloc(sourceLength+1);C.stringToUTF8(source,sourceAddress,sourceLength+1);let address=C._ts_query_new(language[0],sourceAddress,sourceLength,TRANSFER_BUFFER,TRANSFER_BUFFER+SIZE_OF_INT);if(!address){let errorId=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),errorByte=C.getValue(TRANSFER_BUFFER,"i32"),errorIndex=C.UTF8ToString(sourceAddress,errorByte).length,suffix=source.slice(errorIndex,errorIndex+100).split(`
3
+ `)[0],word=suffix.match(QUERY_WORD_REGEX)?.[0]??"";switch(C._free(sourceAddress),errorId){case QueryErrorKind.Syntax:throw new QueryError(QueryErrorKind.Syntax,{suffix:`${errorIndex}: '${suffix}'...`},errorIndex,0);case QueryErrorKind.NodeName:throw new QueryError(errorId,{word},errorIndex,word.length);case QueryErrorKind.FieldName:throw new QueryError(errorId,{word},errorIndex,word.length);case QueryErrorKind.CaptureName:throw new QueryError(errorId,{word},errorIndex,word.length);case QueryErrorKind.PatternStructure:throw new QueryError(errorId,{suffix:`${errorIndex}: '${suffix}'...`},errorIndex,0)}}let stringCount=C._ts_query_string_count(address),captureCount=C._ts_query_capture_count(address),patternCount=C._ts_query_pattern_count(address),captureNames=Array(captureCount),captureQuantifiers=Array(patternCount),stringValues=Array(stringCount);for(let i2=0;i2<captureCount;i2++){let nameAddress=C._ts_query_capture_name_for_id(address,i2,TRANSFER_BUFFER),nameLength=C.getValue(TRANSFER_BUFFER,"i32");captureNames[i2]=C.UTF8ToString(nameAddress,nameLength)}for(let i2=0;i2<patternCount;i2++){let captureQuantifiersArray=Array(captureCount);for(let j=0;j<captureCount;j++){let quantifier=C._ts_query_capture_quantifier_for_id(address,i2,j);captureQuantifiersArray[j]=quantifier}captureQuantifiers[i2]=captureQuantifiersArray}for(let i2=0;i2<stringCount;i2++){let valueAddress=C._ts_query_string_value_for_id(address,i2,TRANSFER_BUFFER),nameLength=C.getValue(TRANSFER_BUFFER,"i32");stringValues[i2]=C.UTF8ToString(valueAddress,nameLength)}let setProperties=Array(patternCount),assertedProperties=Array(patternCount),refutedProperties=Array(patternCount),predicates=Array(patternCount),textPredicates=Array(patternCount);for(let i2=0;i2<patternCount;i2++){let predicatesAddress=C._ts_query_predicates_for_pattern(address,i2,TRANSFER_BUFFER),stepCount=C.getValue(TRANSFER_BUFFER,"i32");predicates[i2]=[],textPredicates[i2]=[];let steps=[],stepAddress=predicatesAddress;for(let j=0;j<stepCount;j++){let stepType=C.getValue(stepAddress,"i32");stepAddress+=SIZE_OF_INT;let stepValueId=C.getValue(stepAddress,"i32");stepAddress+=SIZE_OF_INT,parsePattern(i2,stepType,stepValueId,captureNames,stringValues,steps,textPredicates,predicates,setProperties,assertedProperties,refutedProperties)}Object.freeze(textPredicates[i2]),Object.freeze(predicates[i2]),Object.freeze(setProperties[i2]),Object.freeze(assertedProperties[i2]),Object.freeze(refutedProperties[i2])}C._free(sourceAddress),this[0]=address,this.captureNames=captureNames,this.captureQuantifiers=captureQuantifiers,this.textPredicates=textPredicates,this.predicates=predicates,this.setProperties=setProperties,this.assertedProperties=assertedProperties,this.refutedProperties=refutedProperties,this.exceededMatchLimit=!1}delete(){C._ts_query_delete(this[0]),this[0]=0}matches(node,options={}){let startPosition=options.startPosition??ZERO_POINT,endPosition=options.endPosition??ZERO_POINT,startIndex=options.startIndex??0,endIndex=options.endIndex??0,matchLimit=options.matchLimit??4294967295,maxStartDepth=options.maxStartDepth??4294967295,timeoutMicros=options.timeoutMicros??0,progressCallback=options.progressCallback;if(typeof matchLimit!=="number")throw Error("Arguments must be numbers");if(this.matchLimit=matchLimit,endIndex!==0&&startIndex>endIndex)throw Error("`startIndex` cannot be greater than `endIndex`");if(endPosition!==ZERO_POINT&&(startPosition.row>endPosition.row||startPosition.row===endPosition.row&&startPosition.column>endPosition.column))throw Error("`startPosition` cannot be greater than `endPosition`");if(progressCallback)C.currentQueryProgressCallback=progressCallback;marshalNode(node),C._ts_query_matches_wasm(this[0],node.tree[0],startPosition.row,startPosition.column,endPosition.row,endPosition.column,startIndex,endIndex,matchLimit,maxStartDepth,timeoutMicros);let rawCount=C.getValue(TRANSFER_BUFFER,"i32"),startAddress=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),didExceedMatchLimit=C.getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),result=Array(rawCount);this.exceededMatchLimit=Boolean(didExceedMatchLimit);let filteredCount=0,address=startAddress;for(let i2=0;i2<rawCount;i2++){let patternIndex=C.getValue(address,"i32");address+=SIZE_OF_INT;let captureCount=C.getValue(address,"i32");address+=SIZE_OF_INT;let captures=Array(captureCount);if(address=unmarshalCaptures(this,node.tree,address,patternIndex,captures),this.textPredicates[patternIndex].every((p)=>p(captures))){result[filteredCount]={pattern:patternIndex,patternIndex,captures};let setProperties=this.setProperties[patternIndex];result[filteredCount].setProperties=setProperties;let assertedProperties=this.assertedProperties[patternIndex];result[filteredCount].assertedProperties=assertedProperties;let refutedProperties=this.refutedProperties[patternIndex];result[filteredCount].refutedProperties=refutedProperties,filteredCount++}}return result.length=filteredCount,C._free(startAddress),C.currentQueryProgressCallback=null,result}captures(node,options={}){let startPosition=options.startPosition??ZERO_POINT,endPosition=options.endPosition??ZERO_POINT,startIndex=options.startIndex??0,endIndex=options.endIndex??0,matchLimit=options.matchLimit??4294967295,maxStartDepth=options.maxStartDepth??4294967295,timeoutMicros=options.timeoutMicros??0,progressCallback=options.progressCallback;if(typeof matchLimit!=="number")throw Error("Arguments must be numbers");if(this.matchLimit=matchLimit,endIndex!==0&&startIndex>endIndex)throw Error("`startIndex` cannot be greater than `endIndex`");if(endPosition!==ZERO_POINT&&(startPosition.row>endPosition.row||startPosition.row===endPosition.row&&startPosition.column>endPosition.column))throw Error("`startPosition` cannot be greater than `endPosition`");if(progressCallback)C.currentQueryProgressCallback=progressCallback;marshalNode(node),C._ts_query_captures_wasm(this[0],node.tree[0],startPosition.row,startPosition.column,endPosition.row,endPosition.column,startIndex,endIndex,matchLimit,maxStartDepth,timeoutMicros);let count=C.getValue(TRANSFER_BUFFER,"i32"),startAddress=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),didExceedMatchLimit=C.getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),result=[];this.exceededMatchLimit=Boolean(didExceedMatchLimit);let captures=[],address=startAddress;for(let i2=0;i2<count;i2++){let patternIndex=C.getValue(address,"i32");address+=SIZE_OF_INT;let captureCount=C.getValue(address,"i32");address+=SIZE_OF_INT;let captureIndex=C.getValue(address,"i32");if(address+=SIZE_OF_INT,captures.length=captureCount,address=unmarshalCaptures(this,node.tree,address,patternIndex,captures),this.textPredicates[patternIndex].every((p)=>p(captures))){let capture=captures[captureIndex],setProperties=this.setProperties[patternIndex];capture.setProperties=setProperties;let assertedProperties=this.assertedProperties[patternIndex];capture.assertedProperties=assertedProperties;let refutedProperties=this.refutedProperties[patternIndex];capture.refutedProperties=refutedProperties,result.push(capture)}}return C._free(startAddress),C.currentQueryProgressCallback=null,result}predicatesForPattern(patternIndex){return this.predicates[patternIndex]}disableCapture(captureName){let captureNameLength=C.lengthBytesUTF8(captureName),captureNameAddress=C._malloc(captureNameLength+1);C.stringToUTF8(captureName,captureNameAddress,captureNameLength+1),C._ts_query_disable_capture(this[0],captureNameAddress,captureNameLength),C._free(captureNameAddress)}disablePattern(patternIndex){if(patternIndex>=this.predicates.length)throw Error(`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`);C._ts_query_disable_pattern(this[0],patternIndex)}didExceedMatchLimit(){return this.exceededMatchLimit}startIndexForPattern(patternIndex){if(patternIndex>=this.predicates.length)throw Error(`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`);return C._ts_query_start_byte_for_pattern(this[0],patternIndex)}endIndexForPattern(patternIndex){if(patternIndex>=this.predicates.length)throw Error(`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`);return C._ts_query_end_byte_for_pattern(this[0],patternIndex)}patternCount(){return C._ts_query_pattern_count(this[0])}captureIndexForName(captureName){return this.captureNames.indexOf(captureName)}isPatternRooted(patternIndex){return C._ts_query_is_pattern_rooted(this[0],patternIndex)===1}isPatternNonLocal(patternIndex){return C._ts_query_is_pattern_non_local(this[0],patternIndex)===1}isPatternGuaranteedAtStep(byteIndex){return C._ts_query_is_pattern_guaranteed_at_step(this[0],byteIndex)===1}},LANGUAGE_FUNCTION_REGEX=/^tree_sitter_\w+$/,Language=class _Language{static{__name(this,"Language")}[0]=0;types;fields;constructor(internal,address){assertInternal(internal),this[0]=address,this.types=Array(C._ts_language_symbol_count(this[0]));for(let i2=0,n=this.types.length;i2<n;i2++)if(C._ts_language_symbol_type(this[0],i2)<2)this.types[i2]=C.UTF8ToString(C._ts_language_symbol_name(this[0],i2));this.fields=Array(C._ts_language_field_count(this[0])+1);for(let i2=0,n=this.fields.length;i2<n;i2++){let fieldName=C._ts_language_field_name_for_id(this[0],i2);if(fieldName!==0)this.fields[i2]=C.UTF8ToString(fieldName);else this.fields[i2]=null}}get name(){let ptr=C._ts_language_name(this[0]);if(ptr===0)return null;return C.UTF8ToString(ptr)}get version(){return C._ts_language_version(this[0])}get abiVersion(){return C._ts_language_abi_version(this[0])}get metadata(){C._ts_language_metadata(this[0]);let length=C.getValue(TRANSFER_BUFFER,"i32"),address=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32");if(length===0)return null;return unmarshalLanguageMetadata(address)}get fieldCount(){return this.fields.length-1}get stateCount(){return C._ts_language_state_count(this[0])}fieldIdForName(fieldName){let result=this.fields.indexOf(fieldName);return result!==-1?result:null}fieldNameForId(fieldId){return this.fields[fieldId]??null}idForNodeType(type,named){let typeLength=C.lengthBytesUTF8(type),typeAddress=C._malloc(typeLength+1);C.stringToUTF8(type,typeAddress,typeLength+1);let result=C._ts_language_symbol_for_name(this[0],typeAddress,typeLength,named?1:0);return C._free(typeAddress),result||null}get nodeTypeCount(){return C._ts_language_symbol_count(this[0])}nodeTypeForId(typeId){let name2=C._ts_language_symbol_name(this[0],typeId);return name2?C.UTF8ToString(name2):null}nodeTypeIsNamed(typeId){return C._ts_language_type_is_named_wasm(this[0],typeId)?!0:!1}nodeTypeIsVisible(typeId){return C._ts_language_type_is_visible_wasm(this[0],typeId)?!0:!1}get supertypes(){C._ts_language_supertypes_wasm(this[0]);let count=C.getValue(TRANSFER_BUFFER,"i32"),buffer=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),result=Array(count);if(count>0){let address=buffer;for(let i2=0;i2<count;i2++)result[i2]=C.getValue(address,"i16"),address+=SIZE_OF_SHORT}return result}subtypes(supertype){C._ts_language_subtypes_wasm(this[0],supertype);let count=C.getValue(TRANSFER_BUFFER,"i32"),buffer=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),result=Array(count);if(count>0){let address=buffer;for(let i2=0;i2<count;i2++)result[i2]=C.getValue(address,"i16"),address+=SIZE_OF_SHORT}return result}nextState(stateId,typeId){return C._ts_language_next_state(this[0],stateId,typeId)}lookaheadIterator(stateId){let address=C._ts_lookahead_iterator_new(this[0],stateId);if(address)return new LookaheadIterator(INTERNAL,address,this);return null}query(source){return console.warn("Language.query is deprecated. Use new Query(language, source) instead."),new Query(this,source)}static async load(input){let bytes;if(input instanceof Uint8Array)bytes=Promise.resolve(input);else if(globalThis.process?.versions.node)bytes=(await import("fs/promises")).readFile(input);else bytes=fetch(input).then((response)=>response.arrayBuffer().then((buffer)=>{if(response.ok)return new Uint8Array(buffer);else{let body2=new TextDecoder("utf-8").decode(buffer);throw Error(`Language.load failed with status ${response.status}.
4
+
5
+ ${body2}`)}}));let mod=await C.loadWebAssemblyModule(await bytes,{loadAsync:!0}),symbolNames=Object.keys(mod),functionName=symbolNames.find((key)=>LANGUAGE_FUNCTION_REGEX.test(key)&&!key.includes("external_scanner_"));if(!functionName)throw console.log(`Couldn't find language function in WASM file. Symbols:
6
+ ${JSON.stringify(symbolNames,null,2)}`),Error("Language.load failed: no language function found in WASM file");let languageAddress=mod[functionName]();return new _Language(INTERNAL,languageAddress)}},Module2=(()=>{var _scriptName=import.meta.url;return async function(moduleArg={}){var moduleRtn,Module=moduleArg,readyPromiseResolve,readyPromiseReject,readyPromise=new Promise((resolve,reject)=>{readyPromiseResolve=resolve,readyPromiseReject=reject}),ENVIRONMENT_IS_WEB=typeof window=="object",ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope<"u",ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer",ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){let{createRequire}=await import("module");var require=createRequire(import.meta.url)}Module.currentQueryProgressCallback=null,Module.currentProgressCallback=null,Module.currentLogCallback=null,Module.currentParseCallback=null;var moduleOverrides=Object.assign({},Module),arguments_=[],thisProgram="./this.program",quit_=__name((status,toThrow)=>{throw toThrow},"quit_"),scriptDirectory="";function locateFile(path){if(Module.locateFile)return Module.locateFile(path,scriptDirectory);return scriptDirectory+path}__name(locateFile,"locateFile");var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs"),nodePath=require("path");if(!import.meta.url.startsWith("data:"))scriptDirectory=nodePath.dirname(require("url").fileURLToPath(import.meta.url))+"/";if(readBinary=__name((filename)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret},"readBinary"),readAsync=__name(async(filename,binary2=!0)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary2?void 0:"utf8");return ret},"readAsync"),!Module.thisProgram&&process.argv.length>1)thisProgram=process.argv[1].replace(/\\/g,"/");arguments_=process.argv.slice(2),quit_=__name((status,toThrow)=>{throw process.exitCode=status,toThrow},"quit_")}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER)scriptDirectory=self.location.href;else if(typeof document<"u"&&document.currentScript)scriptDirectory=document.currentScript.src;if(_scriptName)scriptDirectory=_scriptName;if(scriptDirectory.startsWith("blob:"))scriptDirectory="";else scriptDirectory=scriptDirectory.slice(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1);{if(ENVIRONMENT_IS_WORKER)readBinary=__name((url)=>{var xhr=new XMLHttpRequest;return xhr.open("GET",url,!1),xhr.responseType="arraybuffer",xhr.send(null),new Uint8Array(xhr.response)},"readBinary");readAsync=__name(async(url)=>{if(isFileURI(url))return new Promise((resolve,reject)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,!0),xhr.responseType="arraybuffer",xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){resolve(xhr.response);return}reject(xhr.status)},xhr.onerror=reject,xhr.send(null)});var response=await fetch(url,{credentials:"same-origin"});if(response.ok)return response.arrayBuffer();throw Error(response.status+" : "+response.url)},"readAsync")}}var out=Module.print||console.log.bind(console),err=Module.printErr||console.error.bind(console);if(Object.assign(Module,moduleOverrides),moduleOverrides=null,Module.arguments)arguments_=Module.arguments;if(Module.thisProgram)thisProgram=Module.thisProgram;var dynamicLibraries=Module.dynamicLibraries||[],wasmBinary=Module.wasmBinary,wasmMemory,ABORT=!1,EXITSTATUS;function assert(condition,text){if(!condition)abort(text)}__name(assert,"assert");var HEAP,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAP64,HEAPU64,HEAPF64,HEAP_DATA_VIEW,runtimeInitialized=!1,isFileURI=__name((filename)=>filename.startsWith("file://"),"isFileURI");function updateMemoryViews(){var b=wasmMemory.buffer;Module.HEAP_DATA_VIEW=HEAP_DATA_VIEW=new DataView(b),Module.HEAP8=HEAP8=new Int8Array(b),Module.HEAP16=HEAP16=new Int16Array(b),Module.HEAPU8=HEAPU8=new Uint8Array(b),Module.HEAPU16=HEAPU16=new Uint16Array(b),Module.HEAP32=HEAP32=new Int32Array(b),Module.HEAPU32=HEAPU32=new Uint32Array(b),Module.HEAPF32=HEAPF32=new Float32Array(b),Module.HEAPF64=HEAPF64=new Float64Array(b),Module.HEAP64=HEAP64=new BigInt64Array(b),Module.HEAPU64=HEAPU64=new BigUint64Array(b)}if(__name(updateMemoryViews,"updateMemoryViews"),Module.wasmMemory)wasmMemory=Module.wasmMemory;else{var INITIAL_MEMORY=Module.INITIAL_MEMORY||33554432;wasmMemory=new WebAssembly.Memory({initial:INITIAL_MEMORY/65536,maximum:32768})}updateMemoryViews();var __RELOC_FUNCS__=[];function preRun(){if(Module.preRun){if(typeof Module.preRun=="function")Module.preRun=[Module.preRun];while(Module.preRun.length)addOnPreRun(Module.preRun.shift())}callRuntimeCallbacks(onPreRuns)}__name(preRun,"preRun");function initRuntime(){runtimeInitialized=!0,callRuntimeCallbacks(__RELOC_FUNCS__),wasmExports.__wasm_call_ctors(),callRuntimeCallbacks(onPostCtors)}__name(initRuntime,"initRuntime");function preMain(){}__name(preMain,"preMain");function postRun(){if(Module.postRun){if(typeof Module.postRun=="function")Module.postRun=[Module.postRun];while(Module.postRun.length)addOnPostRun(Module.postRun.shift())}callRuntimeCallbacks(onPostRuns)}__name(postRun,"postRun");var runDependencies=0,dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}__name(getUniqueRunDependency,"getUniqueRunDependency");function addRunDependency(id){runDependencies++,Module.monitorRunDependencies?.(runDependencies)}__name(addRunDependency,"addRunDependency");function removeRunDependency(id){if(runDependencies--,Module.monitorRunDependencies?.(runDependencies),runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null,callback()}}}__name(removeRunDependency,"removeRunDependency");function abort(what){Module.onAbort?.(what),what="Aborted("+what+")",err(what),ABORT=!0,what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);throw readyPromiseReject(e),e}__name(abort,"abort");var wasmBinaryFile;function findWasmBinary(){if(Module.locateFile)return locateFile("tree-sitter.wasm");return new URL("tree-sitter.wasm",import.meta.url).href}__name(findWasmBinary,"findWasmBinary");function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary)return new Uint8Array(wasmBinary);if(readBinary)return readBinary(file);throw"both async and sync fetching of the wasm failed"}__name(getBinarySync,"getBinarySync");async function getWasmBinary(binaryFile){if(!wasmBinary)try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}return getBinarySync(binaryFile)}__name(getWasmBinary,"getWasmBinary");async function instantiateArrayBuffer(binaryFile,imports){try{var binary2=await getWasmBinary(binaryFile),instance2=await WebAssembly.instantiate(binary2,imports);return instance2}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`),abort(reason)}}__name(instantiateArrayBuffer,"instantiateArrayBuffer");async function instantiateAsync(binary2,binaryFile,imports){if(!binary2&&typeof WebAssembly.instantiateStreaming=="function"&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE)try{var response=fetch(binaryFile,{credentials:"same-origin"}),instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`),err("falling back to ArrayBuffer instantiation")}return instantiateArrayBuffer(binaryFile,imports)}__name(instantiateAsync,"instantiateAsync");function getWasmImports(){return{env:wasmImports,wasi_snapshot_preview1:wasmImports,"GOT.mem":new Proxy(wasmImports,GOTHandler),"GOT.func":new Proxy(wasmImports,GOTHandler)}}__name(getWasmImports,"getWasmImports");async function createWasm(){function receiveInstance(instance2,module2){wasmExports=instance2.exports,wasmExports=relocateExports(wasmExports,1024);var metadata2=getDylinkMetadata(module2);if(metadata2.neededDynlibs)dynamicLibraries=metadata2.neededDynlibs.concat(dynamicLibraries);return mergeLibSymbols(wasmExports,"main"),LDSO.init(),loadDylibs(),__RELOC_FUNCS__.push(wasmExports.__wasm_apply_data_relocs),removeRunDependency("wasm-instantiate"),wasmExports}__name(receiveInstance,"receiveInstance"),addRunDependency("wasm-instantiate");function receiveInstantiationResult(result2){return receiveInstance(result2.instance,result2.module)}__name(receiveInstantiationResult,"receiveInstantiationResult");var info2=getWasmImports();if(Module.instantiateWasm)return new Promise((resolve,reject)=>{Module.instantiateWasm(info2,(mod,inst)=>{receiveInstance(mod,inst),resolve(mod.exports)})});wasmBinaryFile??=findWasmBinary();try{var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info2),exports=receiveInstantiationResult(result);return exports}catch(e){return readyPromiseReject(e),Promise.reject(e)}}__name(createWasm,"createWasm");var ASM_CONSTS={};class ExitStatus{static{__name(this,"ExitStatus")}name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`,this.status=status}}var GOT={},currentModuleWeakSymbols=new Set([]),GOTHandler={get(obj,symName){var rtn=GOT[symName];if(!rtn)rtn=GOT[symName]=new WebAssembly.Global({value:"i32",mutable:!0});if(!currentModuleWeakSymbols.has(symName))rtn.required=!0;return rtn}},LE_HEAP_LOAD_F32=__name((byteOffset)=>HEAP_DATA_VIEW.getFloat32(byteOffset,!0),"LE_HEAP_LOAD_F32"),LE_HEAP_LOAD_F64=__name((byteOffset)=>HEAP_DATA_VIEW.getFloat64(byteOffset,!0),"LE_HEAP_LOAD_F64"),LE_HEAP_LOAD_I16=__name((byteOffset)=>HEAP_DATA_VIEW.getInt16(byteOffset,!0),"LE_HEAP_LOAD_I16"),LE_HEAP_LOAD_I32=__name((byteOffset)=>HEAP_DATA_VIEW.getInt32(byteOffset,!0),"LE_HEAP_LOAD_I32"),LE_HEAP_LOAD_U16=__name((byteOffset)=>HEAP_DATA_VIEW.getUint16(byteOffset,!0),"LE_HEAP_LOAD_U16"),LE_HEAP_LOAD_U32=__name((byteOffset)=>HEAP_DATA_VIEW.getUint32(byteOffset,!0),"LE_HEAP_LOAD_U32"),LE_HEAP_STORE_F32=__name((byteOffset,value)=>HEAP_DATA_VIEW.setFloat32(byteOffset,value,!0),"LE_HEAP_STORE_F32"),LE_HEAP_STORE_F64=__name((byteOffset,value)=>HEAP_DATA_VIEW.setFloat64(byteOffset,value,!0),"LE_HEAP_STORE_F64"),LE_HEAP_STORE_I16=__name((byteOffset,value)=>HEAP_DATA_VIEW.setInt16(byteOffset,value,!0),"LE_HEAP_STORE_I16"),LE_HEAP_STORE_I32=__name((byteOffset,value)=>HEAP_DATA_VIEW.setInt32(byteOffset,value,!0),"LE_HEAP_STORE_I32"),LE_HEAP_STORE_U16=__name((byteOffset,value)=>HEAP_DATA_VIEW.setUint16(byteOffset,value,!0),"LE_HEAP_STORE_U16"),LE_HEAP_STORE_U32=__name((byteOffset,value)=>HEAP_DATA_VIEW.setUint32(byteOffset,value,!0),"LE_HEAP_STORE_U32"),callRuntimeCallbacks=__name((callbacks)=>{while(callbacks.length>0)callbacks.shift()(Module)},"callRuntimeCallbacks"),onPostRuns=[],addOnPostRun=__name((cb)=>onPostRuns.unshift(cb),"addOnPostRun"),onPreRuns=[],addOnPreRun=__name((cb)=>onPreRuns.unshift(cb),"addOnPreRun"),UTF8Decoder=typeof TextDecoder<"u"?new TextDecoder:void 0,UTF8ArrayToString=__name((heapOrArray,idx=0,maxBytesToRead=NaN)=>{var endIdx=idx+maxBytesToRead,endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder)return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr));var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224)u0=(u0&15)<<12|u1<<6|u2;else u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63;if(u0<65536)str+=String.fromCharCode(u0);else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str},"UTF8ArrayToString"),getDylinkMetadata=__name((binary2)=>{var offset=0,end=0;function getU8(){return binary2[offset++]}__name(getU8,"getU8");function getLEB(){var ret=0,mul=1;while(!0){var byte=binary2[offset++];if(ret+=(byte&127)*mul,mul*=128,!(byte&128))break}return ret}__name(getLEB,"getLEB");function getString(){var len=getLEB();return offset+=len,UTF8ArrayToString(binary2,offset-len,len)}__name(getString,"getString");function failIf(condition,message){if(condition)throw Error(message)}__name(failIf,"failIf");var name2="dylink.0";if(binary2 instanceof WebAssembly.Module){var dylinkSection=WebAssembly.Module.customSections(binary2,name2);if(dylinkSection.length===0)name2="dylink",dylinkSection=WebAssembly.Module.customSections(binary2,name2);failIf(dylinkSection.length===0,"need dylink section"),binary2=new Uint8Array(dylinkSection[0]),end=binary2.length}else{var int32View=new Uint32Array(new Uint8Array(binary2.subarray(0,24)).buffer),magicNumberFound=int32View[0]==1836278016||int32View[0]==6386541;failIf(!magicNumberFound,"need to see wasm magic number"),failIf(binary2[8]!==0,"need the dylink section to be first"),offset=9;var section_size=getLEB();end=offset+section_size,name2=getString()}var customSection={neededDynlibs:[],tlsExports:new Set,weakImports:new Set};if(name2=="dylink"){customSection.memorySize=getLEB(),customSection.memoryAlign=getLEB(),customSection.tableSize=getLEB(),customSection.tableAlign=getLEB();var neededDynlibsCount=getLEB();for(var i2=0;i2<neededDynlibsCount;++i2){var libname=getString();customSection.neededDynlibs.push(libname)}}else{failIf(name2!=="dylink.0");var WASM_DYLINK_MEM_INFO=1,WASM_DYLINK_NEEDED=2,WASM_DYLINK_EXPORT_INFO=3,WASM_DYLINK_IMPORT_INFO=4,WASM_SYMBOL_TLS=256,WASM_SYMBOL_BINDING_MASK=3,WASM_SYMBOL_BINDING_WEAK=1;while(offset<end){var subsectionType=getU8(),subsectionSize=getLEB();if(subsectionType===WASM_DYLINK_MEM_INFO)customSection.memorySize=getLEB(),customSection.memoryAlign=getLEB(),customSection.tableSize=getLEB(),customSection.tableAlign=getLEB();else if(subsectionType===WASM_DYLINK_NEEDED){var neededDynlibsCount=getLEB();for(var i2=0;i2<neededDynlibsCount;++i2)libname=getString(),customSection.neededDynlibs.push(libname)}else if(subsectionType===WASM_DYLINK_EXPORT_INFO){var count=getLEB();while(count--){var symname=getString(),flags2=getLEB();if(flags2&WASM_SYMBOL_TLS)customSection.tlsExports.add(symname)}}else if(subsectionType===WASM_DYLINK_IMPORT_INFO){var count=getLEB();while(count--){var modname=getString(),symname=getString(),flags2=getLEB();if((flags2&WASM_SYMBOL_BINDING_MASK)==WASM_SYMBOL_BINDING_WEAK)customSection.weakImports.add(symname)}}else offset+=subsectionSize}}return customSection},"getDylinkMetadata");function getValue(ptr,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":return HEAP8[ptr];case"i8":return HEAP8[ptr];case"i16":return LE_HEAP_LOAD_I16((ptr>>1)*2);case"i32":return LE_HEAP_LOAD_I32((ptr>>2)*4);case"i64":return HEAP64[ptr>>3];case"float":return LE_HEAP_LOAD_F32((ptr>>2)*4);case"double":return LE_HEAP_LOAD_F64((ptr>>3)*8);case"*":return LE_HEAP_LOAD_U32((ptr>>2)*4);default:abort(`invalid type for getValue: ${type}`)}}__name(getValue,"getValue");var newDSO=__name((name2,handle2,syms)=>{var dso={refcount:1/0,name:name2,exports:syms,global:!0};if(LDSO.loadedLibsByName[name2]=dso,handle2!=null)LDSO.loadedLibsByHandle[handle2]=dso;return dso},"newDSO"),LDSO={loadedLibsByName:{},loadedLibsByHandle:{},init(){newDSO("__main__",0,wasmImports)}},___heap_base=78224,alignMemory=__name((size,alignment)=>Math.ceil(size/alignment)*alignment,"alignMemory"),getMemory=__name((size)=>{if(runtimeInitialized)return _calloc(size,1);var ret=___heap_base,end=ret+alignMemory(size,16);return ___heap_base=end,GOT.__heap_base.value=end,ret},"getMemory"),isInternalSym=__name((symName)=>["__cpp_exception","__c_longjmp","__wasm_apply_data_relocs","__dso_handle","__tls_size","__tls_align","__set_stack_limits","_emscripten_tls_init","__wasm_init_tls","__wasm_call_ctors","__start_em_asm","__stop_em_asm","__start_em_js","__stop_em_js"].includes(symName)||symName.startsWith("__em_js__"),"isInternalSym"),uleb128Encode=__name((n,target)=>{if(n<128)target.push(n);else target.push(n%128|128,n>>7)},"uleb128Encode"),sigToWasmTypes=__name((sig)=>{var typeNames={i:"i32",j:"i64",f:"f32",d:"f64",e:"externref",p:"i32"},type={parameters:[],results:sig[0]=="v"?[]:[typeNames[sig[0]]]};for(var i2=1;i2<sig.length;++i2)type.parameters.push(typeNames[sig[i2]]);return type},"sigToWasmTypes"),generateFuncType=__name((sig,target)=>{var sigRet=sig.slice(0,1),sigParam=sig.slice(1),typeCodes={i:127,p:127,j:126,f:125,d:124,e:111};target.push(96),uleb128Encode(sigParam.length,target);for(var i2=0;i2<sigParam.length;++i2)target.push(typeCodes[sigParam[i2]]);if(sigRet=="v")target.push(0);else target.push(1,typeCodes[sigRet])},"generateFuncType"),convertJsFunctionToWasm=__name((func2,sig)=>{if(typeof WebAssembly.Function=="function")return new WebAssembly.Function(sigToWasmTypes(sig),func2);var typeSectionBody=[1];generateFuncType(sig,typeSectionBody);var bytes=[0,97,115,109,1,0,0,0,1];uleb128Encode(typeSectionBody.length,bytes),bytes.push(...typeSectionBody),bytes.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var module2=new WebAssembly.Module(new Uint8Array(bytes)),instance2=new WebAssembly.Instance(module2,{e:{f:func2}}),wrappedFunc=instance2.exports.f;return wrappedFunc},"convertJsFunctionToWasm"),wasmTableMirror=[],wasmTable=new WebAssembly.Table({initial:31,element:"anyfunc"}),getWasmTableEntry=__name((funcPtr)=>{var func2=wasmTableMirror[funcPtr];if(!func2){if(funcPtr>=wasmTableMirror.length)wasmTableMirror.length=funcPtr+1;wasmTableMirror[funcPtr]=func2=wasmTable.get(funcPtr)}return func2},"getWasmTableEntry"),updateTableMap=__name((offset,count)=>{if(functionsInTableMap)for(var i2=offset;i2<offset+count;i2++){var item=getWasmTableEntry(i2);if(item)functionsInTableMap.set(item,i2)}},"updateTableMap"),functionsInTableMap,getFunctionAddress=__name((func2)=>{if(!functionsInTableMap)functionsInTableMap=new WeakMap,updateTableMap(0,wasmTable.length);return functionsInTableMap.get(func2)||0},"getFunctionAddress"),freeTableIndexes=[],getEmptyTableSlot=__name(()=>{if(freeTableIndexes.length)return freeTableIndexes.pop();try{wasmTable.grow(1)}catch(err2){if(!(err2 instanceof RangeError))throw err2;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."}return wasmTable.length-1},"getEmptyTableSlot"),setWasmTableEntry=__name((idx,func2)=>{wasmTable.set(idx,func2),wasmTableMirror[idx]=wasmTable.get(idx)},"setWasmTableEntry"),addFunction=__name((func2,sig)=>{var rtn=getFunctionAddress(func2);if(rtn)return rtn;var ret=getEmptyTableSlot();try{setWasmTableEntry(ret,func2)}catch(err2){if(!(err2 instanceof TypeError))throw err2;var wrapped=convertJsFunctionToWasm(func2,sig);setWasmTableEntry(ret,wrapped)}return functionsInTableMap.set(func2,ret),ret},"addFunction"),updateGOT=__name((exports,replace)=>{for(var symName in exports){if(isInternalSym(symName))continue;var value=exports[symName];if(GOT[symName]||=new WebAssembly.Global({value:"i32",mutable:!0}),replace||GOT[symName].value==0)if(typeof value=="function")GOT[symName].value=addFunction(value);else if(typeof value=="number")GOT[symName].value=value;else err(`unhandled export type for '${symName}': ${typeof value}`)}},"updateGOT"),relocateExports=__name((exports,memoryBase2,replace)=>{var relocated={};for(var e in exports){var value=exports[e];if(typeof value=="object")value=value.value;if(typeof value=="number")value+=memoryBase2;relocated[e]=value}return updateGOT(relocated,replace),relocated},"relocateExports"),isSymbolDefined=__name((symName)=>{var existing=wasmImports[symName];if(!existing||existing.stub)return!1;return!0},"isSymbolDefined"),dynCall=__name((sig,ptr,args2=[])=>{var rtn=getWasmTableEntry(ptr)(...args2);return rtn},"dynCall"),stackSave=__name(()=>_emscripten_stack_get_current(),"stackSave"),stackRestore=__name((val)=>__emscripten_stack_restore(val),"stackRestore"),createInvokeFunction=__name((sig)=>(ptr,...args2)=>{var sp=stackSave();try{return dynCall(sig,ptr,args2)}catch(e){if(stackRestore(sp),e!==e+0)throw e;if(_setThrew(1,0),sig[0]=="j")return 0n}},"createInvokeFunction"),resolveGlobalSymbol=__name((symName,direct=!1)=>{var sym;if(isSymbolDefined(symName))sym=wasmImports[symName];else if(symName.startsWith("invoke_"))sym=wasmImports[symName]=createInvokeFunction(symName.split("_")[1]);return{sym,name:symName}},"resolveGlobalSymbol"),onPostCtors=[],addOnPostCtor=__name((cb)=>onPostCtors.unshift(cb),"addOnPostCtor"),UTF8ToString=__name((ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):"","UTF8ToString"),loadWebAssemblyModule=__name((binary,flags,libName,localScope,handle)=>{var metadata=getDylinkMetadata(binary);currentModuleWeakSymbols=metadata.weakImports;function loadModule(){var memAlign=Math.pow(2,metadata.memoryAlign),memoryBase=metadata.memorySize?alignMemory(getMemory(metadata.memorySize+memAlign),memAlign):0,tableBase=metadata.tableSize?wasmTable.length:0;if(handle)HEAP8[handle+8]=1,LE_HEAP_STORE_U32((handle+12>>2)*4,memoryBase),LE_HEAP_STORE_I32((handle+16>>2)*4,metadata.memorySize),LE_HEAP_STORE_U32((handle+20>>2)*4,tableBase),LE_HEAP_STORE_I32((handle+24>>2)*4,metadata.tableSize);if(metadata.tableSize)wasmTable.grow(metadata.tableSize);var moduleExports;function resolveSymbol(sym){var resolved=resolveGlobalSymbol(sym).sym;if(!resolved&&localScope)resolved=localScope[sym];if(!resolved)resolved=moduleExports[sym];return resolved}__name(resolveSymbol,"resolveSymbol");var proxyHandler={get(stubs,prop){switch(prop){case"__memory_base":return memoryBase;case"__table_base":return tableBase}if(prop in wasmImports&&!wasmImports[prop].stub){var res=wasmImports[prop];return res}if(!(prop in stubs)){var resolved;stubs[prop]=(...args2)=>{return resolved||=resolveSymbol(prop),resolved(...args2)}}return stubs[prop]}},proxy=new Proxy({},proxyHandler),info={"GOT.mem":new Proxy({},GOTHandler),"GOT.func":new Proxy({},GOTHandler),env:proxy,wasi_snapshot_preview1:proxy};function postInstantiation(module,instance){if(updateTableMap(tableBase,metadata.tableSize),moduleExports=relocateExports(instance.exports,memoryBase),!flags.allowUndefined)reportUndefinedSymbols();function addEmAsm(addr,body){var args=[],arity=0;for(;arity<16;arity++)if(body.indexOf("$"+arity)!=-1)args.push("$"+arity);else break;args=args.join(",");var func=`(${args}) => { ${body} };`;ASM_CONSTS[start]=eval(func)}if(__name(addEmAsm,"addEmAsm"),"__start_em_asm"in moduleExports){var{__start_em_asm:start,__stop_em_asm:stop}=moduleExports;while(start<stop){var jsString=UTF8ToString(start);addEmAsm(start,jsString),start=HEAPU8.indexOf(0,start)+1}}function addEmJs(name,cSig,body){var jsArgs=[];if(cSig=cSig.slice(1,-1),cSig!="void"){cSig=cSig.split(",");for(var i in cSig){var jsArg=cSig[i].split(" ").pop();jsArgs.push(jsArg.replace("*",""))}}var func=`(${jsArgs}) => ${body};`;moduleExports[name]=eval(func)}__name(addEmJs,"addEmJs");for(var name in moduleExports)if(name.startsWith("__em_js__")){var start=moduleExports[name],jsString=UTF8ToString(start),parts=jsString.split("<::>");addEmJs(name.replace("__em_js__",""),parts[0],parts[1]),delete moduleExports[name]}var applyRelocs=moduleExports.__wasm_apply_data_relocs;if(applyRelocs)if(runtimeInitialized)applyRelocs();else __RELOC_FUNCS__.push(applyRelocs);var init=moduleExports.__wasm_call_ctors;if(init)if(runtimeInitialized)init();else addOnPostCtor(init);return moduleExports}if(__name(postInstantiation,"postInstantiation"),flags.loadAsync){if(binary instanceof WebAssembly.Module){var instance=new WebAssembly.Instance(binary,info);return Promise.resolve(postInstantiation(binary,instance))}return WebAssembly.instantiate(binary,info).then((result)=>postInstantiation(result.module,result.instance))}var module=binary instanceof WebAssembly.Module?binary:new WebAssembly.Module(binary),instance=new WebAssembly.Instance(module,info);return postInstantiation(module,instance)}if(__name(loadModule,"loadModule"),flags.loadAsync)return metadata.neededDynlibs.reduce((chain,dynNeeded)=>chain.then(()=>loadDynamicLibrary(dynNeeded,flags,localScope)),Promise.resolve()).then(loadModule);return metadata.neededDynlibs.forEach((needed)=>loadDynamicLibrary(needed,flags,localScope)),loadModule()},"loadWebAssemblyModule"),mergeLibSymbols=__name((exports,libName2)=>{for(var[sym,exp]of Object.entries(exports)){let setImport=__name((target)=>{if(!isSymbolDefined(target))wasmImports[target]=exp},"setImport");setImport(sym);let main_alias="__main_argc_argv";if(sym=="main")setImport(main_alias);if(sym==main_alias)setImport("main")}},"mergeLibSymbols"),asyncLoad=__name(async(url)=>{var arrayBuffer=await readAsync(url);return new Uint8Array(arrayBuffer)},"asyncLoad");function loadDynamicLibrary(libName2,flags2={global:!0,nodelete:!0},localScope2,handle2){var dso=LDSO.loadedLibsByName[libName2];if(dso){if(!flags2.global){if(localScope2)Object.assign(localScope2,dso.exports)}else if(!dso.global)dso.global=!0,mergeLibSymbols(dso.exports,libName2);if(flags2.nodelete&&dso.refcount!==1/0)dso.refcount=1/0;if(dso.refcount++,handle2)LDSO.loadedLibsByHandle[handle2]=dso;return flags2.loadAsync?Promise.resolve(!0):!0}dso=newDSO(libName2,handle2,"loading"),dso.refcount=flags2.nodelete?1/0:1,dso.global=flags2.global;function loadLibData(){if(handle2){var data=LE_HEAP_LOAD_U32((handle2+28>>2)*4),dataSize=LE_HEAP_LOAD_U32((handle2+32>>2)*4);if(data&&dataSize){var libData=HEAP8.slice(data,data+dataSize);return flags2.loadAsync?Promise.resolve(libData):libData}}var libFile=locateFile(libName2);if(flags2.loadAsync)return asyncLoad(libFile);if(!readBinary)throw Error(`${libFile}: file not found, and synchronous loading of external files is not available`);return readBinary(libFile)}__name(loadLibData,"loadLibData");function getExports(){if(flags2.loadAsync)return loadLibData().then((libData)=>loadWebAssemblyModule(libData,flags2,libName2,localScope2,handle2));return loadWebAssemblyModule(loadLibData(),flags2,libName2,localScope2,handle2)}__name(getExports,"getExports");function moduleLoaded(exports){if(dso.global)mergeLibSymbols(exports,libName2);else if(localScope2)Object.assign(localScope2,exports);dso.exports=exports}if(__name(moduleLoaded,"moduleLoaded"),flags2.loadAsync)return getExports().then((exports)=>{return moduleLoaded(exports),!0});return moduleLoaded(getExports()),!0}__name(loadDynamicLibrary,"loadDynamicLibrary");var reportUndefinedSymbols=__name(()=>{for(var[symName,entry]of Object.entries(GOT))if(entry.value==0){var value=resolveGlobalSymbol(symName,!0).sym;if(!value&&!entry.required)continue;if(typeof value=="function")entry.value=addFunction(value,value.sig);else if(typeof value=="number")entry.value=value;else throw Error(`bad export type for '${symName}': ${typeof value}`)}},"reportUndefinedSymbols"),loadDylibs=__name(()=>{if(!dynamicLibraries.length){reportUndefinedSymbols();return}addRunDependency("loadDylibs"),dynamicLibraries.reduce((chain,lib)=>chain.then(()=>loadDynamicLibrary(lib,{loadAsync:!0,global:!0,nodelete:!0,allowUndefined:!0})),Promise.resolve()).then(()=>{reportUndefinedSymbols(),removeRunDependency("loadDylibs")})},"loadDylibs"),noExitRuntime=Module.noExitRuntime||!0;function setValue(ptr,value,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":HEAP8[ptr]=value;break;case"i8":HEAP8[ptr]=value;break;case"i16":LE_HEAP_STORE_I16((ptr>>1)*2,value);break;case"i32":LE_HEAP_STORE_I32((ptr>>2)*4,value);break;case"i64":HEAP64[ptr>>3]=BigInt(value);break;case"float":LE_HEAP_STORE_F32((ptr>>2)*4,value);break;case"double":LE_HEAP_STORE_F64((ptr>>3)*8,value);break;case"*":LE_HEAP_STORE_U32((ptr>>2)*4,value);break;default:abort(`invalid type for setValue: ${type}`)}}__name(setValue,"setValue");var ___memory_base=new WebAssembly.Global({value:"i32",mutable:!1},1024),___stack_pointer=new WebAssembly.Global({value:"i32",mutable:!0},78224),___table_base=new WebAssembly.Global({value:"i32",mutable:!1},1),__abort_js=__name(()=>abort(""),"__abort_js");__abort_js.sig="v";var _emscripten_get_now=__name(()=>performance.now(),"_emscripten_get_now");_emscripten_get_now.sig="d";var _emscripten_date_now=__name(()=>Date.now(),"_emscripten_date_now");_emscripten_date_now.sig="d";var nowIsMonotonic=1,checkWasiClock=__name((clock_id)=>clock_id>=0&&clock_id<=3,"checkWasiClock"),INT53_MAX=9007199254740992,INT53_MIN=-9007199254740992,bigintToI53Checked=__name((num)=>num<INT53_MIN||num>INT53_MAX?NaN:Number(num),"bigintToI53Checked");function _clock_time_get(clk_id,ignored_precision,ptime){if(ignored_precision=bigintToI53Checked(ignored_precision),!checkWasiClock(clk_id))return 28;var now;if(clk_id===0)now=_emscripten_date_now();else if(nowIsMonotonic)now=_emscripten_get_now();else return 52;var nsec=Math.round(now*1000*1000);return HEAP64[ptime>>3]=BigInt(nsec),0}__name(_clock_time_get,"_clock_time_get"),_clock_time_get.sig="iijp";var getHeapMax=__name(()=>2147483648,"getHeapMax"),growMemory=__name((size)=>{var b=wasmMemory.buffer,pages=(size-b.byteLength+65535)/65536|0;try{return wasmMemory.grow(pages),updateMemoryViews(),1}catch(e){}},"growMemory"),_emscripten_resize_heap=__name((requestedSize)=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize)return!1;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+0.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536)),replacement=growMemory(newSize);if(replacement)return!0}return!1},"_emscripten_resize_heap");_emscripten_resize_heap.sig="ip";var _fd_close=__name((fd)=>52,"_fd_close");_fd_close.sig="ii";function _fd_seek(fd,offset,whence,newOffset){return offset=bigintToI53Checked(offset),70}__name(_fd_seek,"_fd_seek"),_fd_seek.sig="iijip";var printCharBuffers=[null,[],[]],printChar=__name((stream,curr)=>{var buffer=printCharBuffers[stream];if(curr===0||curr===10)(stream===1?out:err)(UTF8ArrayToString(buffer)),buffer.length=0;else buffer.push(curr)},"printChar"),flush_NO_FILESYSTEM=__name(()=>{if(printCharBuffers[1].length)printChar(1,10);if(printCharBuffers[2].length)printChar(2,10)},"flush_NO_FILESYSTEM"),SYSCALLS={varargs:void 0,getStr(ptr){var ret=UTF8ToString(ptr);return ret}},_fd_write=__name((fd,iov,iovcnt,pnum)=>{var num=0;for(var i2=0;i2<iovcnt;i2++){var ptr=LE_HEAP_LOAD_U32((iov>>2)*4),len=LE_HEAP_LOAD_U32((iov+4>>2)*4);iov+=8;for(var j=0;j<len;j++)printChar(fd,HEAPU8[ptr+j]);num+=len}return LE_HEAP_STORE_U32((pnum>>2)*4,num),0},"_fd_write");_fd_write.sig="iippp";function _tree_sitter_log_callback(isLexMessage,messageAddress){if(Module.currentLogCallback){let message=UTF8ToString(messageAddress);Module.currentLogCallback(message,isLexMessage!==0)}}__name(_tree_sitter_log_callback,"_tree_sitter_log_callback");function _tree_sitter_parse_callback(inputBufferAddress,index,row,column,lengthAddress){let string=Module.currentParseCallback(index,{row,column});if(typeof string==="string")setValue(lengthAddress,string.length,"i32"),stringToUTF16(string,inputBufferAddress,10240);else setValue(lengthAddress,0,"i32")}__name(_tree_sitter_parse_callback,"_tree_sitter_parse_callback");function _tree_sitter_progress_callback(currentOffset,hasError){if(Module.currentProgressCallback)return Module.currentProgressCallback({currentOffset,hasError});return!1}__name(_tree_sitter_progress_callback,"_tree_sitter_progress_callback");function _tree_sitter_query_progress_callback(currentOffset){if(Module.currentQueryProgressCallback)return Module.currentQueryProgressCallback({currentOffset});return!1}__name(_tree_sitter_query_progress_callback,"_tree_sitter_query_progress_callback");var runtimeKeepaliveCounter=0,keepRuntimeAlive=__name(()=>noExitRuntime||runtimeKeepaliveCounter>0,"keepRuntimeAlive"),_proc_exit=__name((code)=>{if(EXITSTATUS=code,!keepRuntimeAlive())Module.onExit?.(code),ABORT=!0;quit_(code,new ExitStatus(code))},"_proc_exit");_proc_exit.sig="vi";var exitJS=__name((status,implicit)=>{EXITSTATUS=status,_proc_exit(status)},"exitJS"),handleException=__name((e)=>{if(e instanceof ExitStatus||e=="unwind")return EXITSTATUS;quit_(1,e)},"handleException"),lengthBytesUTF8=__name((str)=>{var len=0;for(var i2=0;i2<str.length;++i2){var c=str.charCodeAt(i2);if(c<=127)len++;else if(c<=2047)len+=2;else if(c>=55296&&c<=57343)len+=4,++i2;else len+=3}return len},"lengthBytesUTF8"),stringToUTF8Array=__name((str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx,endIdx=outIdx+maxBytesToWrite-1;for(var i2=0;i2<str.length;++i2){var u=str.charCodeAt(i2);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i2);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6,heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12,heap[outIdx++]=128|u>>6&63,heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18,heap[outIdx++]=128|u>>12&63,heap[outIdx++]=128|u>>6&63,heap[outIdx++]=128|u&63}}return heap[outIdx]=0,outIdx-startIdx},"stringToUTF8Array"),stringToUTF8=__name((str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite),"stringToUTF8"),stackAlloc=__name((sz)=>__emscripten_stack_alloc(sz),"stackAlloc"),stringToUTF8OnStack=__name((str)=>{var size=lengthBytesUTF8(str)+1,ret=stackAlloc(size);return stringToUTF8(str,ret,size),ret},"stringToUTF8OnStack"),AsciiToString=__name((ptr)=>{var str="";while(!0){var ch=HEAPU8[ptr++];if(!ch)return str;str+=String.fromCharCode(ch)}},"AsciiToString"),stringToUTF16=__name((str,outPtr,maxBytesToWrite)=>{if(maxBytesToWrite??=2147483647,maxBytesToWrite<2)return 0;maxBytesToWrite-=2;var startPtr=outPtr,numCharsToWrite=maxBytesToWrite<str.length*2?maxBytesToWrite/2:str.length;for(var i2=0;i2<numCharsToWrite;++i2){var codeUnit=str.charCodeAt(i2);LE_HEAP_STORE_I16((outPtr>>1)*2,codeUnit),outPtr+=2}return LE_HEAP_STORE_I16((outPtr>>1)*2,0),outPtr-startPtr},"stringToUTF16"),wasmImports={__heap_base:___heap_base,__indirect_function_table:wasmTable,__memory_base:___memory_base,__stack_pointer:___stack_pointer,__table_base:___table_base,_abort_js:__abort_js,clock_time_get:_clock_time_get,emscripten_resize_heap:_emscripten_resize_heap,fd_close:_fd_close,fd_seek:_fd_seek,fd_write:_fd_write,memory:wasmMemory,tree_sitter_log_callback:_tree_sitter_log_callback,tree_sitter_parse_callback:_tree_sitter_parse_callback,tree_sitter_progress_callback:_tree_sitter_progress_callback,tree_sitter_query_progress_callback:_tree_sitter_query_progress_callback},wasmExports=await createWasm(),___wasm_call_ctors=wasmExports.__wasm_call_ctors,_malloc=Module._malloc=wasmExports.malloc,_calloc=Module._calloc=wasmExports.calloc,_realloc=Module._realloc=wasmExports.realloc,_free=Module._free=wasmExports.free,_memcmp=Module._memcmp=wasmExports.memcmp,_ts_language_symbol_count=Module._ts_language_symbol_count=wasmExports.ts_language_symbol_count,_ts_language_state_count=Module._ts_language_state_count=wasmExports.ts_language_state_count,_ts_language_version=Module._ts_language_version=wasmExports.ts_language_version,_ts_language_abi_version=Module._ts_language_abi_version=wasmExports.ts_language_abi_version,_ts_language_metadata=Module._ts_language_metadata=wasmExports.ts_language_metadata,_ts_language_name=Module._ts_language_name=wasmExports.ts_language_name,_ts_language_field_count=Module._ts_language_field_count=wasmExports.ts_language_field_count,_ts_language_next_state=Module._ts_language_next_state=wasmExports.ts_language_next_state,_ts_language_symbol_name=Module._ts_language_symbol_name=wasmExports.ts_language_symbol_name,_ts_language_symbol_for_name=Module._ts_language_symbol_for_name=wasmExports.ts_language_symbol_for_name,_strncmp=Module._strncmp=wasmExports.strncmp,_ts_language_symbol_type=Module._ts_language_symbol_type=wasmExports.ts_language_symbol_type,_ts_language_field_name_for_id=Module._ts_language_field_name_for_id=wasmExports.ts_language_field_name_for_id,_ts_lookahead_iterator_new=Module._ts_lookahead_iterator_new=wasmExports.ts_lookahead_iterator_new,_ts_lookahead_iterator_delete=Module._ts_lookahead_iterator_delete=wasmExports.ts_lookahead_iterator_delete,_ts_lookahead_iterator_reset_state=Module._ts_lookahead_iterator_reset_state=wasmExports.ts_lookahead_iterator_reset_state,_ts_lookahead_iterator_reset=Module._ts_lookahead_iterator_reset=wasmExports.ts_lookahead_iterator_reset,_ts_lookahead_iterator_next=Module._ts_lookahead_iterator_next=wasmExports.ts_lookahead_iterator_next,_ts_lookahead_iterator_current_symbol=Module._ts_lookahead_iterator_current_symbol=wasmExports.ts_lookahead_iterator_current_symbol,_ts_parser_delete=Module._ts_parser_delete=wasmExports.ts_parser_delete,_ts_parser_reset=Module._ts_parser_reset=wasmExports.ts_parser_reset,_ts_parser_set_language=Module._ts_parser_set_language=wasmExports.ts_parser_set_language,_ts_parser_timeout_micros=Module._ts_parser_timeout_micros=wasmExports.ts_parser_timeout_micros,_ts_parser_set_timeout_micros=Module._ts_parser_set_timeout_micros=wasmExports.ts_parser_set_timeout_micros,_ts_parser_set_included_ranges=Module._ts_parser_set_included_ranges=wasmExports.ts_parser_set_included_ranges,_ts_query_new=Module._ts_query_new=wasmExports.ts_query_new,_ts_query_delete=Module._ts_query_delete=wasmExports.ts_query_delete,_iswspace=Module._iswspace=wasmExports.iswspace,_iswalnum=Module._iswalnum=wasmExports.iswalnum,_ts_query_pattern_count=Module._ts_query_pattern_count=wasmExports.ts_query_pattern_count,_ts_query_capture_count=Module._ts_query_capture_count=wasmExports.ts_query_capture_count,_ts_query_string_count=Module._ts_query_string_count=wasmExports.ts_query_string_count,_ts_query_capture_name_for_id=Module._ts_query_capture_name_for_id=wasmExports.ts_query_capture_name_for_id,_ts_query_capture_quantifier_for_id=Module._ts_query_capture_quantifier_for_id=wasmExports.ts_query_capture_quantifier_for_id,_ts_query_string_value_for_id=Module._ts_query_string_value_for_id=wasmExports.ts_query_string_value_for_id,_ts_query_predicates_for_pattern=Module._ts_query_predicates_for_pattern=wasmExports.ts_query_predicates_for_pattern,_ts_query_start_byte_for_pattern=Module._ts_query_start_byte_for_pattern=wasmExports.ts_query_start_byte_for_pattern,_ts_query_end_byte_for_pattern=Module._ts_query_end_byte_for_pattern=wasmExports.ts_query_end_byte_for_pattern,_ts_query_is_pattern_rooted=Module._ts_query_is_pattern_rooted=wasmExports.ts_query_is_pattern_rooted,_ts_query_is_pattern_non_local=Module._ts_query_is_pattern_non_local=wasmExports.ts_query_is_pattern_non_local,_ts_query_is_pattern_guaranteed_at_step=Module._ts_query_is_pattern_guaranteed_at_step=wasmExports.ts_query_is_pattern_guaranteed_at_step,_ts_query_disable_capture=Module._ts_query_disable_capture=wasmExports.ts_query_disable_capture,_ts_query_disable_pattern=Module._ts_query_disable_pattern=wasmExports.ts_query_disable_pattern,_ts_tree_copy=Module._ts_tree_copy=wasmExports.ts_tree_copy,_ts_tree_delete=Module._ts_tree_delete=wasmExports.ts_tree_delete,_ts_init=Module._ts_init=wasmExports.ts_init,_ts_parser_new_wasm=Module._ts_parser_new_wasm=wasmExports.ts_parser_new_wasm,_ts_parser_enable_logger_wasm=Module._ts_parser_enable_logger_wasm=wasmExports.ts_parser_enable_logger_wasm,_ts_parser_parse_wasm=Module._ts_parser_parse_wasm=wasmExports.ts_parser_parse_wasm,_ts_parser_included_ranges_wasm=Module._ts_parser_included_ranges_wasm=wasmExports.ts_parser_included_ranges_wasm,_ts_language_type_is_named_wasm=Module._ts_language_type_is_named_wasm=wasmExports.ts_language_type_is_named_wasm,_ts_language_type_is_visible_wasm=Module._ts_language_type_is_visible_wasm=wasmExports.ts_language_type_is_visible_wasm,_ts_language_supertypes_wasm=Module._ts_language_supertypes_wasm=wasmExports.ts_language_supertypes_wasm,_ts_language_subtypes_wasm=Module._ts_language_subtypes_wasm=wasmExports.ts_language_subtypes_wasm,_ts_tree_root_node_wasm=Module._ts_tree_root_node_wasm=wasmExports.ts_tree_root_node_wasm,_ts_tree_root_node_with_offset_wasm=Module._ts_tree_root_node_with_offset_wasm=wasmExports.ts_tree_root_node_with_offset_wasm,_ts_tree_edit_wasm=Module._ts_tree_edit_wasm=wasmExports.ts_tree_edit_wasm,_ts_tree_included_ranges_wasm=Module._ts_tree_included_ranges_wasm=wasmExports.ts_tree_included_ranges_wasm,_ts_tree_get_changed_ranges_wasm=Module._ts_tree_get_changed_ranges_wasm=wasmExports.ts_tree_get_changed_ranges_wasm,_ts_tree_cursor_new_wasm=Module._ts_tree_cursor_new_wasm=wasmExports.ts_tree_cursor_new_wasm,_ts_tree_cursor_copy_wasm=Module._ts_tree_cursor_copy_wasm=wasmExports.ts_tree_cursor_copy_wasm,_ts_tree_cursor_delete_wasm=Module._ts_tree_cursor_delete_wasm=wasmExports.ts_tree_cursor_delete_wasm,_ts_tree_cursor_reset_wasm=Module._ts_tree_cursor_reset_wasm=wasmExports.ts_tree_cursor_reset_wasm,_ts_tree_cursor_reset_to_wasm=Module._ts_tree_cursor_reset_to_wasm=wasmExports.ts_tree_cursor_reset_to_wasm,_ts_tree_cursor_goto_first_child_wasm=Module._ts_tree_cursor_goto_first_child_wasm=wasmExports.ts_tree_cursor_goto_first_child_wasm,_ts_tree_cursor_goto_last_child_wasm=Module._ts_tree_cursor_goto_last_child_wasm=wasmExports.ts_tree_cursor_goto_last_child_wasm,_ts_tree_cursor_goto_first_child_for_index_wasm=Module._ts_tree_cursor_goto_first_child_for_index_wasm=wasmExports.ts_tree_cursor_goto_first_child_for_index_wasm,_ts_tree_cursor_goto_first_child_for_position_wasm=Module._ts_tree_cursor_goto_first_child_for_position_wasm=wasmExports.ts_tree_cursor_goto_first_child_for_position_wasm,_ts_tree_cursor_goto_next_sibling_wasm=Module._ts_tree_cursor_goto_next_sibling_wasm=wasmExports.ts_tree_cursor_goto_next_sibling_wasm,_ts_tree_cursor_goto_previous_sibling_wasm=Module._ts_tree_cursor_goto_previous_sibling_wasm=wasmExports.ts_tree_cursor_goto_previous_sibling_wasm,_ts_tree_cursor_goto_descendant_wasm=Module._ts_tree_cursor_goto_descendant_wasm=wasmExports.ts_tree_cursor_goto_descendant_wasm,_ts_tree_cursor_goto_parent_wasm=Module._ts_tree_cursor_goto_parent_wasm=wasmExports.ts_tree_cursor_goto_parent_wasm,_ts_tree_cursor_current_node_type_id_wasm=Module._ts_tree_cursor_current_node_type_id_wasm=wasmExports.ts_tree_cursor_current_node_type_id_wasm,_ts_tree_cursor_current_node_state_id_wasm=Module._ts_tree_cursor_current_node_state_id_wasm=wasmExports.ts_tree_cursor_current_node_state_id_wasm,_ts_tree_cursor_current_node_is_named_wasm=Module._ts_tree_cursor_current_node_is_named_wasm=wasmExports.ts_tree_cursor_current_node_is_named_wasm,_ts_tree_cursor_current_node_is_missing_wasm=Module._ts_tree_cursor_current_node_is_missing_wasm=wasmExports.ts_tree_cursor_current_node_is_missing_wasm,_ts_tree_cursor_current_node_id_wasm=Module._ts_tree_cursor_current_node_id_wasm=wasmExports.ts_tree_cursor_current_node_id_wasm,_ts_tree_cursor_start_position_wasm=Module._ts_tree_cursor_start_position_wasm=wasmExports.ts_tree_cursor_start_position_wasm,_ts_tree_cursor_end_position_wasm=Module._ts_tree_cursor_end_position_wasm=wasmExports.ts_tree_cursor_end_position_wasm,_ts_tree_cursor_start_index_wasm=Module._ts_tree_cursor_start_index_wasm=wasmExports.ts_tree_cursor_start_index_wasm,_ts_tree_cursor_end_index_wasm=Module._ts_tree_cursor_end_index_wasm=wasmExports.ts_tree_cursor_end_index_wasm,_ts_tree_cursor_current_field_id_wasm=Module._ts_tree_cursor_current_field_id_wasm=wasmExports.ts_tree_cursor_current_field_id_wasm,_ts_tree_cursor_current_depth_wasm=Module._ts_tree_cursor_current_depth_wasm=wasmExports.ts_tree_cursor_current_depth_wasm,_ts_tree_cursor_current_descendant_index_wasm=Module._ts_tree_cursor_current_descendant_index_wasm=wasmExports.ts_tree_cursor_current_descendant_index_wasm,_ts_tree_cursor_current_node_wasm=Module._ts_tree_cursor_current_node_wasm=wasmExports.ts_tree_cursor_current_node_wasm,_ts_node_symbol_wasm=Module._ts_node_symbol_wasm=wasmExports.ts_node_symbol_wasm,_ts_node_field_name_for_child_wasm=Module._ts_node_field_name_for_child_wasm=wasmExports.ts_node_field_name_for_child_wasm,_ts_node_field_name_for_named_child_wasm=Module._ts_node_field_name_for_named_child_wasm=wasmExports.ts_node_field_name_for_named_child_wasm,_ts_node_children_by_field_id_wasm=Module._ts_node_children_by_field_id_wasm=wasmExports.ts_node_children_by_field_id_wasm,_ts_node_first_child_for_byte_wasm=Module._ts_node_first_child_for_byte_wasm=wasmExports.ts_node_first_child_for_byte_wasm,_ts_node_first_named_child_for_byte_wasm=Module._ts_node_first_named_child_for_byte_wasm=wasmExports.ts_node_first_named_child_for_byte_wasm,_ts_node_grammar_symbol_wasm=Module._ts_node_grammar_symbol_wasm=wasmExports.ts_node_grammar_symbol_wasm,_ts_node_child_count_wasm=Module._ts_node_child_count_wasm=wasmExports.ts_node_child_count_wasm,_ts_node_named_child_count_wasm=Module._ts_node_named_child_count_wasm=wasmExports.ts_node_named_child_count_wasm,_ts_node_child_wasm=Module._ts_node_child_wasm=wasmExports.ts_node_child_wasm,_ts_node_named_child_wasm=Module._ts_node_named_child_wasm=wasmExports.ts_node_named_child_wasm,_ts_node_child_by_field_id_wasm=Module._ts_node_child_by_field_id_wasm=wasmExports.ts_node_child_by_field_id_wasm,_ts_node_next_sibling_wasm=Module._ts_node_next_sibling_wasm=wasmExports.ts_node_next_sibling_wasm,_ts_node_prev_sibling_wasm=Module._ts_node_prev_sibling_wasm=wasmExports.ts_node_prev_sibling_wasm,_ts_node_next_named_sibling_wasm=Module._ts_node_next_named_sibling_wasm=wasmExports.ts_node_next_named_sibling_wasm,_ts_node_prev_named_sibling_wasm=Module._ts_node_prev_named_sibling_wasm=wasmExports.ts_node_prev_named_sibling_wasm,_ts_node_descendant_count_wasm=Module._ts_node_descendant_count_wasm=wasmExports.ts_node_descendant_count_wasm,_ts_node_parent_wasm=Module._ts_node_parent_wasm=wasmExports.ts_node_parent_wasm,_ts_node_child_with_descendant_wasm=Module._ts_node_child_with_descendant_wasm=wasmExports.ts_node_child_with_descendant_wasm,_ts_node_descendant_for_index_wasm=Module._ts_node_descendant_for_index_wasm=wasmExports.ts_node_descendant_for_index_wasm,_ts_node_named_descendant_for_index_wasm=Module._ts_node_named_descendant_for_index_wasm=wasmExports.ts_node_named_descendant_for_index_wasm,_ts_node_descendant_for_position_wasm=Module._ts_node_descendant_for_position_wasm=wasmExports.ts_node_descendant_for_position_wasm,_ts_node_named_descendant_for_position_wasm=Module._ts_node_named_descendant_for_position_wasm=wasmExports.ts_node_named_descendant_for_position_wasm,_ts_node_start_point_wasm=Module._ts_node_start_point_wasm=wasmExports.ts_node_start_point_wasm,_ts_node_end_point_wasm=Module._ts_node_end_point_wasm=wasmExports.ts_node_end_point_wasm,_ts_node_start_index_wasm=Module._ts_node_start_index_wasm=wasmExports.ts_node_start_index_wasm,_ts_node_end_index_wasm=Module._ts_node_end_index_wasm=wasmExports.ts_node_end_index_wasm,_ts_node_to_string_wasm=Module._ts_node_to_string_wasm=wasmExports.ts_node_to_string_wasm,_ts_node_children_wasm=Module._ts_node_children_wasm=wasmExports.ts_node_children_wasm,_ts_node_named_children_wasm=Module._ts_node_named_children_wasm=wasmExports.ts_node_named_children_wasm,_ts_node_descendants_of_type_wasm=Module._ts_node_descendants_of_type_wasm=wasmExports.ts_node_descendants_of_type_wasm,_ts_node_is_named_wasm=Module._ts_node_is_named_wasm=wasmExports.ts_node_is_named_wasm,_ts_node_has_changes_wasm=Module._ts_node_has_changes_wasm=wasmExports.ts_node_has_changes_wasm,_ts_node_has_error_wasm=Module._ts_node_has_error_wasm=wasmExports.ts_node_has_error_wasm,_ts_node_is_error_wasm=Module._ts_node_is_error_wasm=wasmExports.ts_node_is_error_wasm,_ts_node_is_missing_wasm=Module._ts_node_is_missing_wasm=wasmExports.ts_node_is_missing_wasm,_ts_node_is_extra_wasm=Module._ts_node_is_extra_wasm=wasmExports.ts_node_is_extra_wasm,_ts_node_parse_state_wasm=Module._ts_node_parse_state_wasm=wasmExports.ts_node_parse_state_wasm,_ts_node_next_parse_state_wasm=Module._ts_node_next_parse_state_wasm=wasmExports.ts_node_next_parse_state_wasm,_ts_query_matches_wasm=Module._ts_query_matches_wasm=wasmExports.ts_query_matches_wasm,_ts_query_captures_wasm=Module._ts_query_captures_wasm=wasmExports.ts_query_captures_wasm,_memset=Module._memset=wasmExports.memset,_memcpy=Module._memcpy=wasmExports.memcpy,_memmove=Module._memmove=wasmExports.memmove,_iswalpha=Module._iswalpha=wasmExports.iswalpha,_iswblank=Module._iswblank=wasmExports.iswblank,_iswdigit=Module._iswdigit=wasmExports.iswdigit,_iswlower=Module._iswlower=wasmExports.iswlower,_iswupper=Module._iswupper=wasmExports.iswupper,_iswxdigit=Module._iswxdigit=wasmExports.iswxdigit,_memchr=Module._memchr=wasmExports.memchr,_strlen=Module._strlen=wasmExports.strlen,_strcmp=Module._strcmp=wasmExports.strcmp,_strncat=Module._strncat=wasmExports.strncat,_strncpy=Module._strncpy=wasmExports.strncpy,_towlower=Module._towlower=wasmExports.towlower,_towupper=Module._towupper=wasmExports.towupper,_setThrew=wasmExports.setThrew,__emscripten_stack_restore=wasmExports._emscripten_stack_restore,__emscripten_stack_alloc=wasmExports._emscripten_stack_alloc,_emscripten_stack_get_current=wasmExports.emscripten_stack_get_current,___wasm_apply_data_relocs=wasmExports.__wasm_apply_data_relocs;Module.setValue=setValue,Module.getValue=getValue,Module.UTF8ToString=UTF8ToString,Module.stringToUTF8=stringToUTF8,Module.lengthBytesUTF8=lengthBytesUTF8,Module.AsciiToString=AsciiToString,Module.stringToUTF16=stringToUTF16,Module.loadWebAssemblyModule=loadWebAssemblyModule;function callMain(args2=[]){var entryFunction=resolveGlobalSymbol("main").sym;if(!entryFunction)return;args2.unshift(thisProgram);var argc=args2.length,argv=stackAlloc((argc+1)*4),argv_ptr=argv;args2.forEach((arg)=>{LE_HEAP_STORE_U32((argv_ptr>>2)*4,stringToUTF8OnStack(arg)),argv_ptr+=4}),LE_HEAP_STORE_U32((argv_ptr>>2)*4,0);try{var ret=entryFunction(argc,argv);return exitJS(ret,!0),ret}catch(e){return handleException(e)}}__name(callMain,"callMain");function run(args2=arguments_){if(runDependencies>0){dependenciesFulfilled=run;return}if(preRun(),runDependencies>0){dependenciesFulfilled=run;return}function doRun(){if(Module.calledRun=!0,ABORT)return;initRuntime(),preMain(),readyPromiseResolve(Module),Module.onRuntimeInitialized?.();var noInitialRun=Module.noInitialRun;if(!noInitialRun)callMain(args2);postRun()}if(__name(doRun,"doRun"),Module.setStatus)Module.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>Module.setStatus(""),1),doRun()},1);else doRun()}if(__name(run,"run"),Module.preInit){if(typeof Module.preInit=="function")Module.preInit=[Module.preInit];while(Module.preInit.length>0)Module.preInit.pop()()}return run(),moduleRtn=readyPromise,moduleRtn}})(),tree_sitter_default=Module2,Module3=null;async function initializeBinding(moduleOptions){if(!Module3)Module3=await tree_sitter_default(moduleOptions);return Module3}__name(initializeBinding,"initializeBinding");function checkModule(){return!!Module3}__name(checkModule,"checkModule");var TRANSFER_BUFFER,LANGUAGE_VERSION,MIN_COMPATIBLE_VERSION,Parser=class{static{__name(this,"Parser")}[0]=0;[1]=0;logCallback=null;language=null;static async init(moduleOptions){setModule(await initializeBinding(moduleOptions)),TRANSFER_BUFFER=C._ts_init(),LANGUAGE_VERSION=C.getValue(TRANSFER_BUFFER,"i32"),MIN_COMPATIBLE_VERSION=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32")}constructor(){this.initialize()}initialize(){if(!checkModule())throw Error("cannot construct a Parser before calling `init()`");C._ts_parser_new_wasm(),this[0]=C.getValue(TRANSFER_BUFFER,"i32"),this[1]=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32")}delete(){C._ts_parser_delete(this[0]),C._free(this[1]),this[0]=0,this[1]=0}setLanguage(language){let address;if(!language)address=0,this.language=null;else if(language.constructor===Language){address=language[0];let version=C._ts_language_version(address);if(version<MIN_COMPATIBLE_VERSION||LANGUAGE_VERSION<version)throw Error(`Incompatible language version ${version}. Compatibility range ${MIN_COMPATIBLE_VERSION} through ${LANGUAGE_VERSION}.`);this.language=language}else throw Error("Argument must be a Language");return C._ts_parser_set_language(this[0],address),this}parse(callback,oldTree,options){if(typeof callback==="string")C.currentParseCallback=(index)=>callback.slice(index);else if(typeof callback==="function")C.currentParseCallback=callback;else throw Error("Argument must be a string or a function");if(options?.progressCallback)C.currentProgressCallback=options.progressCallback;else C.currentProgressCallback=null;if(this.logCallback)C.currentLogCallback=this.logCallback,C._ts_parser_enable_logger_wasm(this[0],1);else C.currentLogCallback=null,C._ts_parser_enable_logger_wasm(this[0],0);let rangeCount=0,rangeAddress=0;if(options?.includedRanges){rangeCount=options.includedRanges.length,rangeAddress=C._calloc(rangeCount,SIZE_OF_RANGE);let address=rangeAddress;for(let i2=0;i2<rangeCount;i2++)marshalRange(address,options.includedRanges[i2]),address+=SIZE_OF_RANGE}let treeAddress=C._ts_parser_parse_wasm(this[0],this[1],oldTree?oldTree[0]:0,rangeAddress,rangeCount);if(!treeAddress)return C.currentParseCallback=null,C.currentLogCallback=null,C.currentProgressCallback=null,null;if(!this.language)throw Error("Parser must have a language to parse");let result=new Tree(INTERNAL,treeAddress,this.language,C.currentParseCallback);return C.currentParseCallback=null,C.currentLogCallback=null,C.currentProgressCallback=null,result}reset(){C._ts_parser_reset(this[0])}getIncludedRanges(){C._ts_parser_included_ranges_wasm(this[0]);let count=C.getValue(TRANSFER_BUFFER,"i32"),buffer=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),result=Array(count);if(count>0){let address=buffer;for(let i2=0;i2<count;i2++)result[i2]=unmarshalRange(address),address+=SIZE_OF_RANGE;C._free(buffer)}return result}getTimeoutMicros(){return C._ts_parser_timeout_micros(this[0])}setTimeoutMicros(timeout){C._ts_parser_set_timeout_micros(this[0],0,timeout)}setLogger(callback){if(!callback)this.logCallback=null;else if(typeof callback!=="function")throw Error("Logger callback must be a function");else this.logCallback=callback;return this}getLogger(){return this.logCallback}};import{mkdir as mkdir2}from"fs/promises";import*as path2 from"path";import{mkdir,readFile,writeFile}from"fs/promises";import*as path from"path";import{isMainThread}from"worker_threads";import{basename as basename2,join as join22}from"path";class DownloadUtils{static hashUrl(url){let hash=0;for(let i2=0;i2<url.length;i2++){let char=url.charCodeAt(i2);hash=(hash<<5)-hash+char,hash=hash&hash}return Math.abs(hash).toString(16)}static async downloadOrLoad(source,cacheDir,cacheSubdir,fileExtension,useHashForCache=!0,filetype){if(source.startsWith("http://")||source.startsWith("https://")){let cacheFileName;if(useHashForCache){let hash=this.hashUrl(source);cacheFileName=filetype?`${filetype}-${hash}${fileExtension}`:`${hash}${fileExtension}`}else cacheFileName=path.basename(source);let cacheFile=path.join(cacheDir,cacheSubdir,cacheFileName);await mkdir(path.dirname(cacheFile),{recursive:!0});try{let cachedContent=await readFile(cacheFile);if(cachedContent.byteLength>0)return console.log(`Loaded from cache: ${cacheFile} (${source})`),{content:cachedContent,filePath:cacheFile}}catch(error){}try{console.log(`Downloading from URL: ${source}`);let response=await fetch(source);if(!response.ok)return{error:`Failed to fetch from ${source}: ${response.statusText}`};let content=Buffer.from(await response.arrayBuffer());try{await writeFile(cacheFile,Buffer.from(content)),console.log(`Cached: ${source}`)}catch(cacheError){console.warn(`Failed to cache: ${cacheError}`)}return{content,filePath:cacheFile}}catch(error){return{error:`Error downloading from ${source}: ${error}`}}}else try{return console.log(`Loading from local path: ${source}`),{content:await readFile(source),filePath:source}}catch(error){return{error:`Error loading from local path ${source}: ${error}`}}}static async downloadToPath(source,targetPath){let isUrl=source.startsWith("http://")||source.startsWith("https://");if(await mkdir(path.dirname(targetPath),{recursive:!0}),isUrl)try{console.log(`Downloading from URL: ${source}`);let response=await fetch(source);if(!response.ok)return{error:`Failed to fetch from ${source}: ${response.statusText}`};let content=Buffer.from(await response.arrayBuffer());return await writeFile(targetPath,Buffer.from(content)),console.log(`Downloaded: ${source} -> ${targetPath}`),{content,filePath:targetPath}}catch(error){return{error:`Error downloading from ${source}: ${error}`}}else try{console.log(`Copying from local path: ${source}`);let content=await readFile(source);return await writeFile(targetPath,Buffer.from(content)),{content,filePath:targetPath}}catch(error){return{error:`Error copying from local path ${source}: ${error}`}}}static async fetchHighlightQueries(sources,cacheDir,filetype){let queryPromises=sources.map((source)=>this.fetchHighlightQuery(source,cacheDir,filetype));return(await Promise.all(queryPromises)).filter((query)=>query.trim().length>0).join(`
7
+ `)}static async fetchHighlightQuery(source,cacheDir,filetype){let result=await this.downloadOrLoad(source,cacheDir,"queries",".scm",!0,filetype);if(result.error)return console.error(`Error fetching highlight query from ${source}:`,result.error),"";if(result.content)return new TextDecoder().decode(result.content);return""}}function isBunfsPath(path22){return path22.includes("$bunfs")||/^B:[\\/]~BUN/i.test(path22)}function getBunfsRootPath(){return process.platform==="win32"?"B:\\~BUN\\root":"/$bunfs/root"}function normalizeBunfsPath(fileName){return join22(getBunfsRootPath(),basename2(fileName))}var self2=globalThis;class ParserWorker{bufferParsers=new Map;filetypeParserOptions=new Map;filetypeAliases=new Map;filetypeParsers=new Map;filetypeParserPromises=new Map;reusableParsers=new Map;reusableParserPromises=new Map;initializePromise;performance;dataPath;tsDataPath;initialized=!1;constructor(){this.performance={averageParseTime:0,parseTimes:[],averageQueryTime:0,queryTimes:[]}}async fetchQueries(sources,filetype){if(!this.tsDataPath)return"";return DownloadUtils.fetchHighlightQueries(sources,this.tsDataPath,filetype)}async initialize({dataPath}){if(this.initializePromise)return this.initializePromise;return this.initializePromise=(async()=>{this.dataPath=dataPath,this.tsDataPath=path2.join(dataPath,"tree-sitter"),await mkdir2(path2.join(this.tsDataPath,"languages"),{recursive:!0}),await mkdir2(path2.join(this.tsDataPath,"queries"),{recursive:!0});let{default:treeWasm}=await Promise.resolve().then(() => __toESM(require_tree_sitter(),1));if(isBunfsPath(treeWasm))treeWasm=normalizeBunfsPath(path2.parse(treeWasm).base);await Parser.init({locateFile(){return treeWasm}}),this.initialized=!0})(),this.initializePromise}addFiletypeParser(filetypeParser){let previousAliases=this.filetypeParserOptions.get(filetypeParser.filetype)?.aliases??[];for(let alias of previousAliases)if(this.filetypeAliases.get(alias)===filetypeParser.filetype)this.filetypeAliases.delete(alias);let aliases=[...new Set((filetypeParser.aliases??[]).filter((alias)=>alias!==filetypeParser.filetype))];this.filetypeAliases.delete(filetypeParser.filetype),this.filetypeParserOptions.set(filetypeParser.filetype,{...filetypeParser,aliases});for(let alias of aliases)this.filetypeAliases.set(alias,filetypeParser.filetype);this.invalidateParserCaches(filetypeParser.filetype)}resolveCanonicalFiletype(filetype){if(this.filetypeParserOptions.has(filetype))return filetype;return this.filetypeAliases.get(filetype)??filetype}invalidateParserCaches(filetype){this.filetypeParsers.delete(filetype),this.filetypeParserPromises.delete(filetype);let reusableParser=this.reusableParsers.get(filetype);if(reusableParser)reusableParser.parser.delete(),this.reusableParsers.delete(filetype);this.reusableParserPromises.delete(filetype)}async createQueries(filetypeParser,language){try{let highlightQueryContent=await this.fetchQueries(filetypeParser.queries.highlights,filetypeParser.filetype);if(!highlightQueryContent){console.error("Failed to fetch highlight queries for:",filetypeParser.filetype);return}let result={highlights:new Query(language,highlightQueryContent)};if(filetypeParser.queries.injections&&filetypeParser.queries.injections.length>0){let injectionQueryContent=await this.fetchQueries(filetypeParser.queries.injections,filetypeParser.filetype);if(injectionQueryContent)result.injections=new Query(language,injectionQueryContent)}return result}catch(error){console.error("Error creating queries for",filetypeParser.filetype,filetypeParser.queries),console.error(error);return}}async loadLanguage(languageSource){if(!this.initialized||!this.tsDataPath)return;let result=await DownloadUtils.downloadOrLoad(languageSource,this.tsDataPath,"languages",".wasm",!1);if(result.error){console.error(`Error loading language ${languageSource}:`,result.error);return}if(!result.filePath)return;let normalizedPath=result.filePath.replaceAll("\\","/");try{return await Language.load(normalizedPath)}catch(error){console.error(`Error loading language from ${normalizedPath}:`,error);return}}async resolveFiletypeParser(filetype){let canonicalFiletype=this.resolveCanonicalFiletype(filetype);if(this.filetypeParsers.has(canonicalFiletype))return this.filetypeParsers.get(canonicalFiletype);if(this.filetypeParserPromises.has(canonicalFiletype))return this.filetypeParserPromises.get(canonicalFiletype);let loadingPromise=this.loadFiletypeParser(canonicalFiletype);this.filetypeParserPromises.set(canonicalFiletype,loadingPromise);try{let result=await loadingPromise;if(result)this.filetypeParsers.set(canonicalFiletype,result);return result}finally{this.filetypeParserPromises.delete(canonicalFiletype)}}async loadFiletypeParser(filetype){let filetypeParserOptions=this.filetypeParserOptions.get(filetype);if(!filetypeParserOptions)return;let language=await this.loadLanguage(filetypeParserOptions.wasm);if(!language)return;let queries=await this.createQueries(filetypeParserOptions,language);if(!queries){console.error("Failed to create queries for:",filetype);return}return{...filetypeParserOptions,queries,language}}async preloadParser(filetype){return this.resolveFiletypeParser(filetype)}async getReusableParser(filetype){let canonicalFiletype=this.resolveCanonicalFiletype(filetype);if(this.reusableParsers.has(canonicalFiletype))return this.reusableParsers.get(canonicalFiletype);if(this.reusableParserPromises.has(canonicalFiletype))return this.reusableParserPromises.get(canonicalFiletype);let creationPromise=this.createReusableParser(canonicalFiletype);this.reusableParserPromises.set(canonicalFiletype,creationPromise);try{let result=await creationPromise;if(result)this.reusableParsers.set(canonicalFiletype,result);return result}finally{this.reusableParserPromises.delete(canonicalFiletype)}}async createReusableParser(filetype){let filetypeParser=await this.resolveFiletypeParser(filetype);if(!filetypeParser)return;let parser=new Parser;return parser.setLanguage(filetypeParser.language),{parser,filetypeParser,queries:filetypeParser.queries}}async handleInitializeParser(bufferId,version,content,filetype,messageId){let filetypeParser=await this.resolveFiletypeParser(filetype);if(!filetypeParser){self2.postMessage({type:"PARSER_INIT_RESPONSE",bufferId,messageId,hasParser:!1,warning:`No parser available for filetype ${filetype}`});return}let parser=new Parser;parser.setLanguage(filetypeParser.language);let tree=parser.parse(content);if(!tree){self2.postMessage({type:"PARSER_INIT_RESPONSE",bufferId,messageId,hasParser:!1,error:"Failed to parse buffer"});return}let parserState={parser,tree,queries:filetypeParser.queries,filetype,content,injectionMapping:filetypeParser.injectionMapping};this.bufferParsers.set(bufferId,parserState),self2.postMessage({type:"PARSER_INIT_RESPONSE",bufferId,messageId,hasParser:!0});let highlights=await this.initialQuery(parserState);self2.postMessage({type:"HIGHLIGHT_RESPONSE",bufferId,version,...highlights})}async initialQuery(parserState){let matches=parserState.queries.highlights.captures(parserState.tree.rootNode),injectionRanges=new Map;if(parserState.queries.injections){let injectionResult=await this.processInjections(parserState);matches.push(...injectionResult.captures),injectionRanges=injectionResult.injectionRanges}return this.getHighlights(parserState,matches,injectionRanges)}getNodeText(node,content){return content.substring(node.startIndex,node.endIndex)}async processInjections(parserState){let injectionMatches=[],injectionRanges=new Map;if(!parserState.queries.injections)return{captures:injectionMatches,injectionRanges};let content=parserState.content,injectionCaptures=parserState.queries.injections.captures(parserState.tree.rootNode),languageGroups=new Map,injectionMapping=parserState.injectionMapping;for(let capture of injectionCaptures){let captureName=capture.name;if(captureName==="injection.content"||captureName.includes("injection")){let nodeType=capture.node.type,targetLanguage;if(injectionMapping?.nodeTypes&&injectionMapping.nodeTypes[nodeType])targetLanguage=injectionMapping.nodeTypes[nodeType];else if(nodeType==="code_fence_content"){let parent=capture.node.parent;if(parent){let infoString=parent.children.find((child)=>child.type==="info_string");if(infoString){let languageNode=infoString.children.find((child)=>child.type==="language");if(languageNode){let languageName=this.getNodeText(languageNode,content);if(injectionMapping?.infoStringMap&&injectionMapping.infoStringMap[languageName])targetLanguage=injectionMapping.infoStringMap[languageName];else targetLanguage=languageName}}}}if(targetLanguage){if(!languageGroups.has(targetLanguage))languageGroups.set(targetLanguage,[]);languageGroups.get(targetLanguage).push({node:capture.node,name:capture.name})}}}for(let[language,captures]of languageGroups.entries()){let injectedParser=await this.getReusableParser(language);if(!injectedParser){console.warn(`No parser found for injection language: ${language}`);continue}if(!injectionRanges.has(language))injectionRanges.set(language,[]);let parser=injectedParser.parser;for(let{node:injectionNode}of captures)try{injectionRanges.get(language).push({start:injectionNode.startIndex,end:injectionNode.endIndex});let injectionContent=this.getNodeText(injectionNode,content),tree=parser.parse(injectionContent);if(tree){let matches=injectedParser.queries.highlights.captures(tree.rootNode);for(let match of matches){let offsetCapture={name:match.name,patternIndex:match.patternIndex,_injectedQuery:injectedParser.queries.highlights,node:{...match.node,startPosition:{row:match.node.startPosition.row+injectionNode.startPosition.row,column:match.node.startPosition.row===0?match.node.startPosition.column+injectionNode.startPosition.column:match.node.startPosition.column},endPosition:{row:match.node.endPosition.row+injectionNode.startPosition.row,column:match.node.endPosition.row===0?match.node.endPosition.column+injectionNode.startPosition.column:match.node.endPosition.column},startIndex:match.node.startIndex+injectionNode.startIndex,endIndex:match.node.endIndex+injectionNode.startIndex}};injectionMatches.push(offsetCapture)}tree.delete()}}catch(error){console.error(`Error processing injection for language ${language}:`,error)}}return{captures:injectionMatches,injectionRanges}}editToRange(edit){return{startPosition:{column:edit.startPosition.column,row:edit.startPosition.row},endPosition:{column:edit.newEndPosition.column,row:edit.newEndPosition.row},startIndex:edit.startIndex,endIndex:edit.newEndIndex}}async handleEdits(bufferId,content,edits){let parserState=this.bufferParsers.get(bufferId);if(!parserState)return{warning:"No parser state found for buffer"};parserState.content=content;for(let edit of edits)parserState.tree.edit(edit);let startParse=performance.now(),newTree=parserState.parser.parse(content,parserState.tree),parseTime=performance.now()-startParse;if(this.performance.parseTimes.push(parseTime),this.performance.parseTimes.length>10)this.performance.parseTimes.shift();if(this.performance.averageParseTime=this.performance.parseTimes.reduce((acc,time)=>acc+time,0)/this.performance.parseTimes.length,!newTree)return{error:"Failed to parse buffer"};let changedRanges=parserState.tree.getChangedRanges(newTree);parserState.tree=newTree;let startQuery=performance.now(),matches=[];if(changedRanges.length===0)edits.forEach((edit)=>{let range=this.editToRange(edit);changedRanges.push(range)});for(let range of changedRanges){let node=parserState.tree.rootNode.descendantForPosition(range.startPosition,range.endPosition);if(!node)continue;if(node.equals(parserState.tree.rootNode)){let rangeCaptures=parserState.queries.highlights.captures(node,{startIndex:range.startIndex-100,endIndex:range.endIndex+1000});matches.push(...rangeCaptures);continue}while(node&&!this.nodeContainsRange(node,range))node=node.parent;if(!node)node=parserState.tree.rootNode;let nodeCaptures=parserState.queries.highlights.captures(node);matches.push(...nodeCaptures)}let injectionRanges=new Map;if(parserState.queries.injections){let injectionResult=await this.processInjections(parserState);matches.push(...injectionResult.captures),injectionRanges=injectionResult.injectionRanges}let queryTime=performance.now()-startQuery;if(this.performance.queryTimes.push(queryTime),this.performance.queryTimes.length>10)this.performance.queryTimes.shift();return this.performance.averageQueryTime=this.performance.queryTimes.reduce((acc,time)=>acc+time,0)/this.performance.queryTimes.length,this.getHighlights(parserState,matches,injectionRanges)}nodeContainsRange(node,range){return node.startPosition.row<=range.startPosition.row&&node.endPosition.row>=range.endPosition.row&&(node.startPosition.row<range.startPosition.row||node.startPosition.column<=range.startPosition.column)&&(node.endPosition.row>range.endPosition.row||node.endPosition.column>=range.endPosition.column)}getHighlights(parserState,matches,injectionRanges){let lineHighlights=new Map,droppedHighlights=new Map;for(let match of matches){let node=match.node,startLine=node.startPosition.row,endLine=node.endPosition.row,highlight={startCol:node.startPosition.column,endCol:node.endPosition.column,group:match.name};if(!lineHighlights.has(startLine))lineHighlights.set(startLine,new Map),droppedHighlights.set(startLine,new Map);if(lineHighlights.get(startLine)?.has(node.id))droppedHighlights.get(startLine)?.set(node.id,lineHighlights.get(startLine)?.get(node.id));if(lineHighlights.get(startLine)?.set(node.id,highlight),startLine!==endLine)for(let line=startLine+1;line<=endLine;line++){if(!lineHighlights.has(line))lineHighlights.set(line,new Map);let hl={startCol:0,endCol:node.endPosition.column,group:match.name};lineHighlights.get(line)?.set(node.id,hl)}}return{highlights:Array.from(lineHighlights.entries()).map(([line,lineHighlights2])=>({line,highlights:Array.from(lineHighlights2.values()),droppedHighlights:droppedHighlights.get(line)?Array.from(droppedHighlights.get(line).values()):[]}))}}getSimpleHighlights(matches,injectionRanges){let highlights=[],flatInjectionRanges=[];for(let[lang,ranges]of injectionRanges.entries())for(let range of ranges)flatInjectionRanges.push({...range,lang});for(let match of matches){let node=match.node,isInjection=!1,injectionLang,containsInjection=!1;for(let injRange of flatInjectionRanges)if(node.startIndex>=injRange.start&&node.endIndex<=injRange.end){isInjection=!0,injectionLang=injRange.lang;break}else if(node.startIndex<=injRange.start&&node.endIndex>=injRange.end){containsInjection=!0;break}let patternProperties=match._injectedQuery?.setProperties?.[match.patternIndex],concealValue=patternProperties?.conceal??match.setProperties?.conceal,concealLines=patternProperties?.conceal_lines??match.setProperties?.conceal_lines,meta={};if(isInjection&&injectionLang)meta.isInjection=!0,meta.injectionLang=injectionLang;if(containsInjection)meta.containsInjection=!0;if(concealValue!==void 0)meta.conceal=concealValue;if(concealLines!==void 0)meta.concealLines=concealLines;if(Object.keys(meta).length>0)highlights.push([node.startIndex,node.endIndex,match.name,meta]);else highlights.push([node.startIndex,node.endIndex,match.name])}return highlights.sort((a,b)=>a[0]-b[0]),highlights}async handleResetBuffer(bufferId,version,content){let parserState=this.bufferParsers.get(bufferId);if(!parserState)return{warning:"No parser state found for buffer"};parserState.content=content;let newTree=parserState.parser.parse(content);if(!newTree)return{error:"Failed to parse buffer during reset"};parserState.tree=newTree;let matches=parserState.queries.highlights.captures(parserState.tree.rootNode),injectionRanges=new Map;if(parserState.queries.injections){let injectionResult=await this.processInjections(parserState);matches.push(...injectionResult.captures),injectionRanges=injectionResult.injectionRanges}return this.getHighlights(parserState,matches,injectionRanges)}disposeBuffer(bufferId){let parserState=this.bufferParsers.get(bufferId);if(!parserState)return;parserState.tree.delete(),parserState.parser.delete(),this.bufferParsers.delete(bufferId)}async handleOneShotHighlight(content,filetype,messageId){let reusableState=await this.getReusableParser(filetype);if(!reusableState){self2.postMessage({type:"ONESHOT_HIGHLIGHT_RESPONSE",messageId,hasParser:!1,warning:`No parser available for filetype ${filetype}`});return}let parseContent=filetype==="markdown"&&content.endsWith("```")?content+`
8
+ `:content,tree=reusableState.parser.parse(parseContent);if(!tree){self2.postMessage({type:"ONESHOT_HIGHLIGHT_RESPONSE",messageId,hasParser:!1,error:"Failed to parse content"});return}try{let matches=reusableState.filetypeParser.queries.highlights.captures(tree.rootNode),injectionRanges=new Map;if(reusableState.filetypeParser.queries.injections){let parserState={parser:reusableState.parser,tree,queries:reusableState.filetypeParser.queries,filetype,content,injectionMapping:reusableState.filetypeParser.injectionMapping},injectionResult=await this.processInjections(parserState);matches.push(...injectionResult.captures),injectionRanges=injectionResult.injectionRanges}let highlights=this.getSimpleHighlights(matches,injectionRanges);self2.postMessage({type:"ONESHOT_HIGHLIGHT_RESPONSE",messageId,hasParser:!0,highlights})}finally{tree.delete()}}async updateDataPath(dataPath){this.dataPath=dataPath,this.tsDataPath=path2.join(dataPath,"tree-sitter");try{await mkdir2(path2.join(this.tsDataPath,"languages"),{recursive:!0}),await mkdir2(path2.join(this.tsDataPath,"queries"),{recursive:!0})}catch(error){throw Error(`Failed to update data path: ${error}`)}}async clearCache(){if(!this.dataPath||!this.tsDataPath)throw Error("No data path configured");let{rm}=await import("fs/promises");try{let treeSitterPath=path2.join(this.dataPath,"tree-sitter");await rm(treeSitterPath,{recursive:!0,force:!0}),await mkdir2(path2.join(treeSitterPath,"languages"),{recursive:!0}),await mkdir2(path2.join(treeSitterPath,"queries"),{recursive:!0}),this.filetypeParsers.clear(),this.filetypeParserPromises.clear(),this.reusableParsers.clear(),this.reusableParserPromises.clear()}catch(error){throw Error(`Failed to clear cache: ${error}`)}}}if(!isMainThread){let logMessage=function(type,...args2){self2.postMessage({type:"WORKER_LOG",logType:type,data:args2})},worker=new ParserWorker;console.log=(...args2)=>logMessage("log",...args2),console.error=(...args2)=>logMessage("error",...args2),console.warn=(...args2)=>logMessage("warn",...args2),self2.onmessage=async(e)=>{let{type,bufferId,version,content,filetype,edits,filetypeParser,messageId,dataPath}=e.data;try{switch(type){case"INIT":try{await worker.initialize({dataPath}),self2.postMessage({type:"INIT_RESPONSE"})}catch(error){self2.postMessage({type:"INIT_RESPONSE",error:error instanceof Error?error.stack||error.message:String(error)})}break;case"ADD_FILETYPE_PARSER":worker.addFiletypeParser(filetypeParser);break;case"PRELOAD_PARSER":let maybeParser=await worker.preloadParser(filetype);self2.postMessage({type:"PRELOAD_PARSER_RESPONSE",messageId,hasParser:!!maybeParser});break;case"INITIALIZE_PARSER":await worker.handleInitializeParser(bufferId,version,content,filetype,messageId);break;case"HANDLE_EDITS":let response=await worker.handleEdits(bufferId,content,edits);if(response.highlights&&response.highlights.length>0)self2.postMessage({type:"HIGHLIGHT_RESPONSE",bufferId,version,...response});else if(response.warning)self2.postMessage({type:"WARNING",bufferId,warning:response.warning});else if(response.error)self2.postMessage({type:"ERROR",bufferId,error:response.error});break;case"GET_PERFORMANCE":self2.postMessage({type:"PERFORMANCE_RESPONSE",performance:worker.performance,messageId});break;case"RESET_BUFFER":let resetResponse=await worker.handleResetBuffer(bufferId,version,content);if(resetResponse.highlights&&resetResponse.highlights.length>0)self2.postMessage({type:"HIGHLIGHT_RESPONSE",bufferId,version,...resetResponse});else if(resetResponse.warning)self2.postMessage({type:"WARNING",bufferId,warning:resetResponse.warning});else if(resetResponse.error)self2.postMessage({type:"ERROR",bufferId,error:resetResponse.error});break;case"DISPOSE_BUFFER":worker.disposeBuffer(bufferId),self2.postMessage({type:"BUFFER_DISPOSED",bufferId});break;case"ONESHOT_HIGHLIGHT":await worker.handleOneShotHighlight(content,filetype,messageId);break;case"UPDATE_DATA_PATH":try{await worker.updateDataPath(dataPath),self2.postMessage({type:"UPDATE_DATA_PATH_RESPONSE",messageId})}catch(error){self2.postMessage({type:"UPDATE_DATA_PATH_RESPONSE",messageId,error:error instanceof Error?error.message:String(error)})}break;case"CLEAR_CACHE":try{await worker.clearCache(),self2.postMessage({type:"CLEAR_CACHE_RESPONSE",messageId})}catch(error){self2.postMessage({type:"CLEAR_CACHE_RESPONSE",messageId,error:error instanceof Error?error.message:String(error)})}break;default:self2.postMessage({type:"ERROR",bufferId,error:`Unknown message type: ${type}`})}}catch(error){self2.postMessage({type:"ERROR",bufferId,error:error instanceof Error?error.stack||error.message:String(error)})}}}
Binary file
Binary file
@@ -1,29 +0,0 @@
1
- /**
2
- * postinstall — stub out heavy optional dependencies that @opentui/core
3
- * and @opentui/react pull in but Herm never uses.
4
- *
5
- * react-devtools-core is imported statically by @opentui/react, so it needs
6
- * a real module that exports the expected API shape (not just an empty package).
7
- */
8
- import { mkdirSync, writeFileSync, existsSync } from "fs"
9
- import { join } from "path"
10
-
11
- const nm = join(import.meta.dir, "..", "node_modules")
12
-
13
- // Stub react-devtools-core with noop exports
14
- const rdcDir = join(nm, "react-devtools-core")
15
- if (!existsSync(rdcDir)) {
16
- mkdirSync(rdcDir, { recursive: true })
17
- writeFileSync(
18
- join(rdcDir, "package.json"),
19
- JSON.stringify({ name: "react-devtools-core", version: "0.0.0", main: "index.js" })
20
- )
21
- writeFileSync(
22
- join(rdcDir, "index.js"),
23
- [
24
- "const noop = () => {};",
25
- "module.exports = { initialize: noop, connectToDevTools: noop };",
26
- "module.exports.default = module.exports;",
27
- ].join("\n")
28
- )
29
- }
@@ -1,83 +0,0 @@
1
- // GatewayClient exposed via React context. The provider accepts an
2
- // injected client so tests can substitute a MockGateway without
3
- // spawning the Python tui_gateway subprocess.
4
-
5
- import { createContext, useContext, useEffect, useRef, useState, useMemo } from "react"
6
- import type { ReactNode } from "react"
7
- import { EventEmitter } from "events"
8
- import { GatewayClient } from "../utils/gateway-client"
9
- import type { GatewayEvent } from "../utils/gateway-types"
10
-
11
- /** Minimal surface consumers depend on. GatewayClient satisfies this. */
12
- export interface Gateway extends EventEmitter {
13
- request<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>
14
- setSession(sid: string): void
15
- start(): void
16
- drain(): void
17
- kill(): void
18
- tail(n?: number): string
19
- readonly ready: boolean
20
- }
21
-
22
- type Ctx = {
23
- client: Gateway
24
- ready: boolean
25
- }
26
-
27
- const Gw = createContext<Ctx | null>(null)
28
-
29
- export const GatewayProvider = ({ client, children }: { client?: Gateway; children: ReactNode }) => {
30
- const ref = useRef<Gateway | null>(null)
31
- if (!ref.current) ref.current = client ?? new GatewayClient()
32
- const [ready, setReady] = useState(ref.current.ready)
33
-
34
- useEffect(() => {
35
- const c = ref.current!
36
- const onEvent = (ev: GatewayEvent) => {
37
- if (ev.type === "gateway.ready" || ev.type === "session.info") setReady(true)
38
- }
39
- c.on("event", onEvent)
40
- c.start()
41
- c.drain()
42
- return () => {
43
- c.off("event", onEvent)
44
- c.removeAllListeners()
45
- c.kill()
46
- }
47
- }, [])
48
-
49
- const value = useMemo<Ctx>(() => ({ client: ref.current!, ready }), [ready])
50
- return <Gw.Provider value={value}>{children}</Gw.Provider>
51
- }
52
-
53
- export function useGateway(): Gateway {
54
- const ctx = useContext(Gw)
55
- if (!ctx) throw new Error("useGateway() must be inside <GatewayProvider>")
56
- return ctx.client
57
- }
58
-
59
- /**
60
- * Subscribe to all gateway events. The first subscription drains any
61
- * events buffered before React mounted, so nothing is lost between
62
- * `client.start()` and component wiring.
63
- */
64
- export function useGatewayEvent(handler: (ev: GatewayEvent) => void): void {
65
- const ctx = useContext(Gw)
66
- if (!ctx) throw new Error("useGatewayEvent() must be inside <GatewayProvider>")
67
- const ref = useRef(handler)
68
- ref.current = handler
69
- useEffect(() => {
70
- const c = ctx.client
71
- const fn = (ev: GatewayEvent) => ref.current(ev)
72
- c.on("event", fn)
73
- c.drain()
74
- return () => { c.off("event", fn) }
75
- }, [ctx.client])
76
- }
77
-
78
- /** True once gateway.ready or session.info has fired. */
79
- export function useGatewayReady(): boolean {
80
- const ctx = useContext(Gw)
81
- if (!ctx) throw new Error("useGatewayReady() must be inside <GatewayProvider>")
82
- return ctx.ready
83
- }