@vscode/tree-sitter-wasm 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,3284 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Parser = {}));
5
5
  })(this, (function () {
6
6
 
7
- var Module=void 0!==Module?Module:{},TreeSitter=function(){var initPromise,document="object"==typeof window?{currentScript:window.document.currentScript}:null;class Parser{constructor(){this.initialize()}initialize(){throw new Error("cannot construct a Parser before calling `init()`")}static init(moduleOptions){return initPromise||(Module=Object.assign({},Module,moduleOptions),initPromise=new Promise((resolveInitPromise=>{var moduleOverrides=Object.assign({},Module),arguments_=[],thisProgram="./this.program",quit_=(e,t)=>{throw t},ENVIRONMENT_IS_WEB="object"==typeof window,ENVIRONMENT_IS_WORKER="function"==typeof importScripts,ENVIRONMENT_IS_NODE="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,scriptDirectory="",read_,readAsync,readBinary;function locateFile(e){return Module.locateFile?Module.locateFile(e,scriptDirectory):scriptDirectory+e}if(ENVIRONMENT_IS_NODE){var fs=require("fs"),nodePath=require("path");scriptDirectory=ENVIRONMENT_IS_WORKER?nodePath.dirname(scriptDirectory)+"/":__dirname+"/",read_=(e,t)=>(e=isFileURI(e)?new URL(e):nodePath.normalize(e),fs.readFileSync(e,t?void 0:"utf8")),readBinary=e=>{var t=read_(e,!0);return t.buffer||(t=new Uint8Array(t)),t},readAsync=(e,t,_,s=!0)=>{e=isFileURI(e)?new URL(e):nodePath.normalize(e),fs.readFile(e,s?void 0:"utf8",((e,r)=>{e?_(e):t(s?r.buffer:r)}))},!Module.thisProgram&&process.argv.length>1&&(thisProgram=process.argv[1].replace(/\\/g,"/")),arguments_=process.argv.slice(2),"undefined"!=typeof module&&(module.exports=Module),quit_=(e,t)=>{throw process.exitCode=e,t}}else(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&(ENVIRONMENT_IS_WORKER?scriptDirectory=self.location.href:void 0!==document&&document.currentScript&&(scriptDirectory=document.currentScript.src),scriptDirectory=scriptDirectory.startsWith("blob:")?"":scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1),read_=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},ENVIRONMENT_IS_WORKER&&(readBinary=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),readAsync=(e,t,_)=>{var s=new XMLHttpRequest;s.open("GET",e,!0),s.responseType="arraybuffer",s.onload=()=>{200==s.status||0==s.status&&s.response?t(s.response):_()},s.onerror=_,s.send(null)});var out=Module.print||console.log.bind(console),err=Module.printErr||console.error.bind(console);Object.assign(Module,moduleOverrides),moduleOverrides=null,Module.arguments&&(arguments_=Module.arguments),Module.thisProgram&&(thisProgram=Module.thisProgram),Module.quit&&(quit_=Module.quit);var dynamicLibraries=Module.dynamicLibraries||[],wasmBinary,wasmMemory;Module.wasmBinary&&(wasmBinary=Module.wasmBinary),"object"!=typeof WebAssembly&&abort("no native wasm support detected");var ABORT=!1,EXITSTATUS,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateMemoryViews(){var e=wasmMemory.buffer;Module.HEAP8=HEAP8=new Int8Array(e),Module.HEAP16=HEAP16=new Int16Array(e),Module.HEAPU8=HEAPU8=new Uint8Array(e),Module.HEAPU16=HEAPU16=new Uint16Array(e),Module.HEAP32=HEAP32=new Int32Array(e),Module.HEAPU32=HEAPU32=new Uint32Array(e),Module.HEAPF32=HEAPF32=new Float32Array(e),Module.HEAPF64=HEAPF64=new Float64Array(e)}var INITIAL_MEMORY=Module.INITIAL_MEMORY||33554432;wasmMemory=Module.wasmMemory?Module.wasmMemory:new WebAssembly.Memory({initial:INITIAL_MEMORY/65536,maximum:32768}),updateMemoryViews(),INITIAL_MEMORY=wasmMemory.buffer.byteLength;var __ATPRERUN__=[],__ATINIT__=[],__ATMAIN__=[],__ATPOSTRUN__=[],__RELOC_FUNCS__=[],runtimeInitialized=!1;function preRun(){if(Module.preRun)for("function"==typeof Module.preRun&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=!0,callRuntimeCallbacks(__RELOC_FUNCS__),callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function postRun(){if(Module.postRun)for("function"==typeof Module.postRun&&(Module.postRun=[Module.postRun]);Module.postRun.length;)addOnPostRun(Module.postRun.shift());callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(e){__ATPRERUN__.unshift(e)}function addOnInit(e){__ATINIT__.unshift(e)}function addOnPostRun(e){__ATPOSTRUN__.unshift(e)}var runDependencies=0,runDependencyWatcher=null,dependenciesFulfilled=null;function getUniqueRunDependency(e){return e}function addRunDependency(e){runDependencies++,Module.monitorRunDependencies?.(runDependencies)}function removeRunDependency(e){if(runDependencies--,Module.monitorRunDependencies?.(runDependencies),0==runDependencies&&(null!==runDependencyWatcher&&(clearInterval(runDependencyWatcher),runDependencyWatcher=null),dependenciesFulfilled)){var t=dependenciesFulfilled;dependenciesFulfilled=null,t()}}function abort(e){throw Module.onAbort?.(e),err(e="Aborted("+e+")"),ABORT=!0,EXITSTATUS=1,e+=". Build with -sASSERTIONS for more info.",new WebAssembly.RuntimeError(e)}var dataURIPrefix="data:application/octet-stream;base64,",isDataURI=e=>e.startsWith(dataURIPrefix),isFileURI=e=>e.startsWith("file://"),wasmBinaryFile;function getBinarySync(e){if(e==wasmBinaryFile&&wasmBinary)return new Uint8Array(wasmBinary);if(readBinary)return readBinary(e);throw"both async and sync fetching of the wasm failed"}function getBinaryPromise(e){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if("function"==typeof fetch&&!isFileURI(e))return fetch(e,{credentials:"same-origin"}).then((t=>{if(!t.ok)throw`failed to load wasm binary file at '${e}'`;return t.arrayBuffer()})).catch((()=>getBinarySync(e)));if(readAsync)return new Promise(((t,_)=>{readAsync(e,(e=>t(new Uint8Array(e))),_)}))}return Promise.resolve().then((()=>getBinarySync(e)))}function instantiateArrayBuffer(e,t,_){return getBinaryPromise(e).then((e=>WebAssembly.instantiate(e,t))).then(_,(e=>{err(`failed to asynchronously prepare wasm: ${e}`),abort(e)}))}function instantiateAsync(e,t,_,s){return e||"function"!=typeof WebAssembly.instantiateStreaming||isDataURI(t)||isFileURI(t)||ENVIRONMENT_IS_NODE||"function"!=typeof fetch?instantiateArrayBuffer(t,_,s):fetch(t,{credentials:"same-origin"}).then((e=>WebAssembly.instantiateStreaming(e,_).then(s,(function(e){return err(`wasm streaming compile failed: ${e}`),err("falling back to ArrayBuffer instantiation"),instantiateArrayBuffer(t,_,s)}))))}function createWasm(){var e={env:wasmImports,wasi_snapshot_preview1:wasmImports,"GOT.mem":new Proxy(wasmImports,GOTHandler),"GOT.func":new Proxy(wasmImports,GOTHandler)};function t(e,t){wasmExports=e.exports,wasmExports=relocateExports(wasmExports,1024);var _=getDylinkMetadata(t);return _.neededDynlibs&&(dynamicLibraries=_.neededDynlibs.concat(dynamicLibraries)),mergeLibSymbols(wasmExports,"main"),LDSO.init(),loadDylibs(),addOnInit(wasmExports.__wasm_call_ctors),__RELOC_FUNCS__.push(wasmExports.__wasm_apply_data_relocs),removeRunDependency("wasm-instantiate"),wasmExports}if(addRunDependency("wasm-instantiate"),Module.instantiateWasm)try{return Module.instantiateWasm(e,t)}catch(e){return err(`Module.instantiateWasm callback failed with error: ${e}`),!1}return instantiateAsync(wasmBinary,wasmBinaryFile,e,(function(e){t(e.instance,e.module)})),{}}wasmBinaryFile="tree-sitter.wasm",isDataURI(wasmBinaryFile)||(wasmBinaryFile=locateFile(wasmBinaryFile));var ASM_CONSTS={};function ExitStatus(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var GOT={},currentModuleWeakSymbols=new Set([]),GOTHandler={get(e,t){var _=GOT[t];return _||(_=GOT[t]=new WebAssembly.Global({value:"i32",mutable:!0})),currentModuleWeakSymbols.has(t)||(_.required=!0),_}},callRuntimeCallbacks=e=>{for(;e.length>0;)e.shift()(Module)},UTF8Decoder="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,UTF8ArrayToString=(e,t,_)=>{for(var s=t+_,r=t;e[r]&&!(r>=s);)++r;if(r-t>16&&e.buffer&&UTF8Decoder)return UTF8Decoder.decode(e.subarray(t,r));for(var a="";t<r;){var o=e[t++];if(128&o){var n=63&e[t++];if(192!=(224&o)){var l=63&e[t++];if((o=224==(240&o)?(15&o)<<12|n<<6|l:(7&o)<<18|n<<12|l<<6|63&e[t++])<65536)a+=String.fromCharCode(o);else{var d=o-65536;a+=String.fromCharCode(55296|d>>10,56320|1023&d)}}else a+=String.fromCharCode((31&o)<<6|n)}else a+=String.fromCharCode(o)}return a},getDylinkMetadata=e=>{var t=0,_=0;function s(){for(var _=0,s=1;;){var r=e[t++];if(_+=(127&r)*s,s*=128,!(128&r))break}return _}function r(){var _=s();return UTF8ArrayToString(e,(t+=_)-_,_)}function a(e,t){if(e)throw new Error(t)}var o="dylink.0";if(e instanceof WebAssembly.Module){var n=WebAssembly.Module.customSections(e,o);0===n.length&&(o="dylink",n=WebAssembly.Module.customSections(e,o)),a(0===n.length,"need dylink section"),_=(e=new Uint8Array(n[0])).length}else{a(!(1836278016==new Uint32Array(new Uint8Array(e.subarray(0,24)).buffer)[0]),"need to see wasm magic number"),a(0!==e[8],"need the dylink section to be first"),t=9;var l=s();_=t+l,o=r()}var d={neededDynlibs:[],tlsExports:new Set,weakImports:new Set};if("dylink"==o){d.memorySize=s(),d.memoryAlign=s(),d.tableSize=s(),d.tableAlign=s();for(var u=s(),m=0;m<u;++m){var c=r();d.neededDynlibs.push(c)}}else{a("dylink.0"!==o);for(;t<_;){var w=e[t++],h=s();if(1===w)d.memorySize=s(),d.memoryAlign=s(),d.tableSize=s(),d.tableAlign=s();else if(2===w)for(u=s(),m=0;m<u;++m)c=r(),d.neededDynlibs.push(c);else if(3===w)for(var p=s();p--;){var g=r();256&s()&&d.tlsExports.add(g)}else if(4===w)for(p=s();p--;){r(),g=r();1==(3&s())&&d.weakImports.add(g)}else t+=h}}return d};function getValue(e,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":case"i8":return HEAP8[e];case"i16":return HEAP16[e>>1];case"i32":return HEAP32[e>>2];case"i64":abort("to do getValue(i64) use WASM_BIGINT");case"float":return HEAPF32[e>>2];case"double":return HEAPF64[e>>3];case"*":return HEAPU32[e>>2];default:abort(`invalid type for getValue: ${t}`)}}var newDSO=(e,t,_)=>{var s={refcount:1/0,name:e,exports:_,global:!0};return LDSO.loadedLibsByName[e]=s,null!=t&&(LDSO.loadedLibsByHandle[t]=s),s},LDSO={loadedLibsByName:{},loadedLibsByHandle:{},init(){newDSO("__main__",0,wasmImports)}},___heap_base=78096,zeroMemory=(e,t)=>(HEAPU8.fill(0,e,e+t),e),alignMemory=(e,t)=>Math.ceil(e/t)*t,getMemory=e=>{if(runtimeInitialized)return zeroMemory(_malloc(e),e);var t=___heap_base,_=t+alignMemory(e,16);return ___heap_base=_,GOT.__heap_base.value=_,t},isInternalSym=e=>["__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(e)||e.startsWith("__em_js__"),uleb128Encode=(e,t)=>{e<128?t.push(e):t.push(e%128|128,e>>7)},sigToWasmTypes=e=>{for(var t={i:"i32",j:"i64",f:"f32",d:"f64",e:"externref",p:"i32"},_={parameters:[],results:"v"==e[0]?[]:[t[e[0]]]},s=1;s<e.length;++s)_.parameters.push(t[e[s]]);return _},generateFuncType=(e,t)=>{var _=e.slice(0,1),s=e.slice(1),r={i:127,p:127,j:126,f:125,d:124,e:111};t.push(96),uleb128Encode(s.length,t);for(var a=0;a<s.length;++a)t.push(r[s[a]]);"v"==_?t.push(0):t.push(1,r[_])},convertJsFunctionToWasm=(e,t)=>{if("function"==typeof WebAssembly.Function)return new WebAssembly.Function(sigToWasmTypes(t),e);var _=[1];generateFuncType(t,_);var s=[0,97,115,109,1,0,0,0,1];uleb128Encode(_.length,s),s.push(..._),s.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var r=new WebAssembly.Module(new Uint8Array(s));return new WebAssembly.Instance(r,{e:{f:e}}).exports.f},wasmTableMirror=[],wasmTable=new WebAssembly.Table({initial:27,element:"anyfunc"}),getWasmTableEntry=e=>{var t=wasmTableMirror[e];return t||(e>=wasmTableMirror.length&&(wasmTableMirror.length=e+1),wasmTableMirror[e]=t=wasmTable.get(e)),t},updateTableMap=(e,t)=>{if(functionsInTableMap)for(var _=e;_<e+t;_++){var s=getWasmTableEntry(_);s&&functionsInTableMap.set(s,_)}},functionsInTableMap,getFunctionAddress=e=>(functionsInTableMap||(functionsInTableMap=new WeakMap,updateTableMap(0,wasmTable.length)),functionsInTableMap.get(e)||0),freeTableIndexes=[],getEmptyTableSlot=()=>{if(freeTableIndexes.length)return freeTableIndexes.pop();try{wasmTable.grow(1)}catch(e){if(!(e instanceof RangeError))throw e;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."}return wasmTable.length-1},setWasmTableEntry=(e,t)=>{wasmTable.set(e,t),wasmTableMirror[e]=wasmTable.get(e)},addFunction=(e,t)=>{var _=getFunctionAddress(e);if(_)return _;var s=getEmptyTableSlot();try{setWasmTableEntry(s,e)}catch(_){if(!(_ instanceof TypeError))throw _;var r=convertJsFunctionToWasm(e,t);setWasmTableEntry(s,r)}return functionsInTableMap.set(e,s),s},updateGOT=(e,t)=>{for(var _ in e)if(!isInternalSym(_)){var s=e[_];_.startsWith("orig$")&&(_=_.split("$")[1],t=!0),GOT[_]||=new WebAssembly.Global({value:"i32",mutable:!0}),(t||0==GOT[_].value)&&("function"==typeof s?GOT[_].value=addFunction(s):"number"==typeof s?GOT[_].value=s:err(`unhandled export type for '${_}': ${typeof s}`))}},relocateExports=(e,t,_)=>{var s={};for(var r in e){var a=e[r];"object"==typeof a&&(a=a.value),"number"==typeof a&&(a+=t),s[r]=a}return updateGOT(s,_),s},isSymbolDefined=e=>{var t=wasmImports[e];return!(!t||t.stub)},dynCallLegacy=(e,t,_)=>(0,Module["dynCall_"+e])(t,..._),dynCall=(e,t,_=[])=>e.includes("j")?dynCallLegacy(e,t,_):getWasmTableEntry(t)(..._),createInvokeFunction=e=>function(){var t=stackSave();try{return dynCall(e,arguments[0],Array.prototype.slice.call(arguments,1))}catch(e){if(stackRestore(t),e!==e+0)throw e;_setThrew(1,0)}},resolveGlobalSymbol=(e,t=!1)=>{var _;return t&&"orig$"+e in wasmImports&&(e="orig$"+e),isSymbolDefined(e)?_=wasmImports[e]:e.startsWith("invoke_")&&(_=wasmImports[e]=createInvokeFunction(e.split("_")[1])),{sym:_,name:e}},UTF8ToString=(e,t)=>e?UTF8ArrayToString(HEAPU8,e,t):"",loadWebAssemblyModule=(binary,flags,libName,localScope,handle)=>{var metadata=getDylinkMetadata(binary);function loadModule(){var firstLoad=!handle||!HEAP8[handle+8];if(firstLoad){var memAlign=Math.pow(2,metadata.memoryAlign),memoryBase=metadata.memorySize?alignMemory(getMemory(metadata.memorySize+memAlign),memAlign):0,tableBase=metadata.tableSize?wasmTable.length:0;handle&&(HEAP8[handle+8]=1,HEAPU32[handle+12>>2]=memoryBase,HEAP32[handle+16>>2]=metadata.memorySize,HEAPU32[handle+20>>2]=tableBase,HEAP32[handle+24>>2]=metadata.tableSize)}else memoryBase=HEAPU32[handle+12>>2],tableBase=HEAPU32[handle+20>>2];var tableGrowthNeeded=tableBase+metadata.tableSize-wasmTable.length,moduleExports;function resolveSymbol(e){var t=resolveGlobalSymbol(e).sym;return!t&&localScope&&(t=localScope[e]),t||(t=moduleExports[e]),t}tableGrowthNeeded>0&&wasmTable.grow(tableGrowthNeeded);var proxyHandler={get(e,t){switch(t){case"__memory_base":return memoryBase;case"__table_base":return tableBase}if(t in wasmImports&&!wasmImports[t].stub)return wasmImports[t];var _;t in e||(e[t]=(...e)=>(_||=resolveSymbol(t),_(...e)));return e[t]}},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){function addEmAsm(addr,body){for(var args=[],arity=0;arity<16&&-1!=body.indexOf("$"+arity);arity++)args.push("$"+arity);args=args.join(",");var func=`(${args}) => { ${body} };`;ASM_CONSTS[start]=eval(func)}if(updateTableMap(tableBase,metadata.tableSize),moduleExports=relocateExports(instance.exports,memoryBase),flags.allowUndefined||reportUndefinedSymbols(),"__start_em_asm"in moduleExports)for(var start=moduleExports.__start_em_asm,stop=moduleExports.__stop_em_asm;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),"void"!=cSig)for(var i in cSig=cSig.split(","),cSig){var jsArg=cSig[i].split(" ").pop();jsArgs.push(jsArg.replace("*",""))}var func=`(${jsArgs}) => ${body};`;moduleExports[name]=eval(func)}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;applyRelocs&&(runtimeInitialized?applyRelocs():__RELOC_FUNCS__.push(applyRelocs));var init=moduleExports.__wasm_call_ctors;return init&&(runtimeInitialized?init():__ATINIT__.push(init)),moduleExports}if(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((e=>postInstantiation(e.module,e.instance)))}var module=binary instanceof WebAssembly.Module?binary:new WebAssembly.Module(binary),instance=new WebAssembly.Instance(module,info);return postInstantiation(module,instance)}return currentModuleWeakSymbols=metadata.weakImports,flags.loadAsync?metadata.neededDynlibs.reduce(((e,t)=>e.then((()=>loadDynamicLibrary(t,flags)))),Promise.resolve()).then(loadModule):(metadata.neededDynlibs.forEach((e=>loadDynamicLibrary(e,flags,localScope))),loadModule())},mergeLibSymbols=(e,t)=>{for(var[_,s]of Object.entries(e)){const e=e=>{isSymbolDefined(e)||(wasmImports[e]=s)};e(_);const t="__main_argc_argv";"main"==_&&e(t),_==t&&e("main"),_.startsWith("dynCall_")&&!Module.hasOwnProperty(_)&&(Module[_]=s)}},asyncLoad=(e,t,_,s)=>{var r=s?"":getUniqueRunDependency(`al ${e}`);readAsync(e,(e=>{t(new Uint8Array(e)),r&&removeRunDependency(r)}),(t=>{if(!_)throw`Loading data file "${e}" failed.`;_()})),r&&addRunDependency(r)};function loadDynamicLibrary(e,t={global:!0,nodelete:!0},_,s){var r=LDSO.loadedLibsByName[e];if(r)return t.global?r.global||(r.global=!0,mergeLibSymbols(r.exports,e)):_&&Object.assign(_,r.exports),t.nodelete&&r.refcount!==1/0&&(r.refcount=1/0),r.refcount++,s&&(LDSO.loadedLibsByHandle[s]=r),!t.loadAsync||Promise.resolve(!0);function a(){if(s){var _=HEAPU32[s+28>>2],r=HEAPU32[s+32>>2];if(_&&r){var a=HEAP8.slice(_,_+r);return t.loadAsync?Promise.resolve(a):a}}var o=locateFile(e);if(t.loadAsync)return new Promise((function(e,t){asyncLoad(o,e,t)}));if(!readBinary)throw new Error(`${o}: file not found, and synchronous loading of external files is not available`);return readBinary(o)}function o(){return t.loadAsync?a().then((r=>loadWebAssemblyModule(r,t,e,_,s))):loadWebAssemblyModule(a(),t,e,_,s)}function n(t){r.global?mergeLibSymbols(t,e):_&&Object.assign(_,t),r.exports=t}return(r=newDSO(e,s,"loading")).refcount=t.nodelete?1/0:1,r.global=t.global,t.loadAsync?o().then((e=>(n(e),!0))):(n(o()),!0)}var reportUndefinedSymbols=()=>{for(var[e,t]of Object.entries(GOT))if(0==t.value){var _=resolveGlobalSymbol(e,!0).sym;if(!_&&!t.required)continue;if("function"==typeof _)t.value=addFunction(_,_.sig);else{if("number"!=typeof _)throw new Error(`bad export type for '${e}': ${typeof _}`);t.value=_}}},loadDylibs=()=>{dynamicLibraries.length?(addRunDependency("loadDylibs"),dynamicLibraries.reduce(((e,t)=>e.then((()=>loadDynamicLibrary(t,{loadAsync:!0,global:!0,nodelete:!0,allowUndefined:!0})))),Promise.resolve()).then((()=>{reportUndefinedSymbols(),removeRunDependency("loadDylibs")}))):reportUndefinedSymbols()},noExitRuntime=Module.noExitRuntime||!0;function setValue(e,t,_="i8"){switch(_.endsWith("*")&&(_="*"),_){case"i1":case"i8":HEAP8[e]=t;break;case"i16":HEAP16[e>>1]=t;break;case"i32":HEAP32[e>>2]=t;break;case"i64":abort("to do setValue(i64) use WASM_BIGINT");case"float":HEAPF32[e>>2]=t;break;case"double":HEAPF64[e>>3]=t;break;case"*":HEAPU32[e>>2]=t;break;default:abort(`invalid type for setValue: ${_}`)}}var ___memory_base=new WebAssembly.Global({value:"i32",mutable:!1},1024),___stack_pointer=new WebAssembly.Global({value:"i32",mutable:!0},78096),___table_base=new WebAssembly.Global({value:"i32",mutable:!1},1),nowIsMonotonic=1,__emscripten_get_now_is_monotonic=()=>nowIsMonotonic;__emscripten_get_now_is_monotonic.sig="i";var _abort=()=>{abort("")};_abort.sig="v";var _emscripten_date_now=()=>Date.now(),_emscripten_get_now;_emscripten_date_now.sig="d",_emscripten_get_now=()=>performance.now(),_emscripten_get_now.sig="d";var _emscripten_memcpy_js=(e,t,_)=>HEAPU8.copyWithin(e,t,t+_);_emscripten_memcpy_js.sig="vppp";var getHeapMax=()=>2147483648,growMemory=e=>{var t=(e-wasmMemory.buffer.byteLength+65535)/65536;try{return wasmMemory.grow(t),updateMemoryViews(),1}catch(e){}},_emscripten_resize_heap=e=>{var t=HEAPU8.length;e>>>=0;var _=getHeapMax();if(e>_)return!1;for(var s,r,a=1;a<=4;a*=2){var o=t*(1+.2/a);o=Math.min(o,e+100663296);var n=Math.min(_,(s=Math.max(e,o))+((r=65536)-s%r)%r);if(growMemory(n))return!0}return!1};_emscripten_resize_heap.sig="ip";var _fd_close=e=>52;_fd_close.sig="ii";var convertI32PairToI53Checked=(e,t)=>t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN;function _fd_seek(e,t,_,s,r){convertI32PairToI53Checked(t,_);return 70}_fd_seek.sig="iiiiip";var printCharBuffers=[null,[],[]],printChar=(e,t)=>{var _=printCharBuffers[e];0===t||10===t?((1===e?out:err)(UTF8ArrayToString(_,0)),_.length=0):_.push(t)},SYSCALLS={varargs:void 0,get(){var e=HEAP32[+SYSCALLS.varargs>>2];return SYSCALLS.varargs+=4,e},getp:()=>SYSCALLS.get(),getStr:e=>UTF8ToString(e)},_fd_write=(e,t,_,s)=>{for(var r=0,a=0;a<_;a++){var o=HEAPU32[t>>2],n=HEAPU32[t+4>>2];t+=8;for(var l=0;l<n;l++)printChar(e,HEAPU8[o+l]);r+=n}return HEAPU32[s>>2]=r,0};function _tree_sitter_log_callback(e,t){if(currentLogCallback){const _=UTF8ToString(t);currentLogCallback(_,0!==e)}}function _tree_sitter_parse_callback(e,t,_,s,r){const a=currentParseCallback(t,{row:_,column:s});"string"==typeof a?(setValue(r,a.length,"i32"),stringToUTF16(a,e,10240)):setValue(r,0,"i32")}_fd_write.sig="iippp";var runtimeKeepaliveCounter=0,keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0,_proc_exit=e=>{EXITSTATUS=e,keepRuntimeAlive()||(Module.onExit?.(e),ABORT=!0),quit_(e,new ExitStatus(e))};_proc_exit.sig="vi";var exitJS=(e,t)=>{EXITSTATUS=e,_proc_exit(e)},handleException=e=>{if(e instanceof ExitStatus||"unwind"==e)return EXITSTATUS;quit_(1,e)},lengthBytesUTF8=e=>{for(var t=0,_=0;_<e.length;++_){var s=e.charCodeAt(_);s<=127?t++:s<=2047?t+=2:s>=55296&&s<=57343?(t+=4,++_):t+=3}return t},stringToUTF8Array=(e,t,_,s)=>{if(!(s>0))return 0;for(var r=_,a=_+s-1,o=0;o<e.length;++o){var n=e.charCodeAt(o);if(n>=55296&&n<=57343)n=65536+((1023&n)<<10)|1023&e.charCodeAt(++o);if(n<=127){if(_>=a)break;t[_++]=n}else if(n<=2047){if(_+1>=a)break;t[_++]=192|n>>6,t[_++]=128|63&n}else if(n<=65535){if(_+2>=a)break;t[_++]=224|n>>12,t[_++]=128|n>>6&63,t[_++]=128|63&n}else{if(_+3>=a)break;t[_++]=240|n>>18,t[_++]=128|n>>12&63,t[_++]=128|n>>6&63,t[_++]=128|63&n}}return t[_]=0,_-r},stringToUTF8=(e,t,_)=>stringToUTF8Array(e,HEAPU8,t,_),stringToUTF8OnStack=e=>{var t=lengthBytesUTF8(e)+1,_=stackAlloc(t);return stringToUTF8(e,_,t),_},stringToUTF16=(e,t,_)=>{if(_??=2147483647,_<2)return 0;for(var s=t,r=(_-=2)<2*e.length?_/2:e.length,a=0;a<r;++a){var o=e.charCodeAt(a);HEAP16[t>>1]=o,t+=2}return HEAP16[t>>1]=0,t-s},AsciiToString=e=>{for(var t="";;){var _=HEAPU8[e++];if(!_)return t;t+=String.fromCharCode(_)}},wasmImports={__heap_base:___heap_base,__indirect_function_table:wasmTable,__memory_base:___memory_base,__stack_pointer:___stack_pointer,__table_base:___table_base,_emscripten_get_now_is_monotonic:__emscripten_get_now_is_monotonic,abort:_abort,emscripten_get_now:_emscripten_get_now,emscripten_memcpy_js:_emscripten_memcpy_js,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},wasmExports=createWasm(),___wasm_call_ctors=()=>(___wasm_call_ctors=wasmExports.__wasm_call_ctors)(),___wasm_apply_data_relocs=()=>(___wasm_apply_data_relocs=wasmExports.__wasm_apply_data_relocs)(),_malloc=Module._malloc=e=>(_malloc=Module._malloc=wasmExports.malloc)(e),_calloc=Module._calloc=(e,t)=>(_calloc=Module._calloc=wasmExports.calloc)(e,t),_realloc=Module._realloc=(e,t)=>(_realloc=Module._realloc=wasmExports.realloc)(e,t),_free=Module._free=e=>(_free=Module._free=wasmExports.free)(e),_ts_language_symbol_count=Module._ts_language_symbol_count=e=>(_ts_language_symbol_count=Module._ts_language_symbol_count=wasmExports.ts_language_symbol_count)(e),_ts_language_state_count=Module._ts_language_state_count=e=>(_ts_language_state_count=Module._ts_language_state_count=wasmExports.ts_language_state_count)(e),_ts_language_version=Module._ts_language_version=e=>(_ts_language_version=Module._ts_language_version=wasmExports.ts_language_version)(e),_ts_language_field_count=Module._ts_language_field_count=e=>(_ts_language_field_count=Module._ts_language_field_count=wasmExports.ts_language_field_count)(e),_ts_language_next_state=Module._ts_language_next_state=(e,t,_)=>(_ts_language_next_state=Module._ts_language_next_state=wasmExports.ts_language_next_state)(e,t,_),_ts_language_symbol_name=Module._ts_language_symbol_name=(e,t)=>(_ts_language_symbol_name=Module._ts_language_symbol_name=wasmExports.ts_language_symbol_name)(e,t),_ts_language_symbol_for_name=Module._ts_language_symbol_for_name=(e,t,_,s)=>(_ts_language_symbol_for_name=Module._ts_language_symbol_for_name=wasmExports.ts_language_symbol_for_name)(e,t,_,s),_ts_language_symbol_type=Module._ts_language_symbol_type=(e,t)=>(_ts_language_symbol_type=Module._ts_language_symbol_type=wasmExports.ts_language_symbol_type)(e,t),_ts_language_field_name_for_id=Module._ts_language_field_name_for_id=(e,t)=>(_ts_language_field_name_for_id=Module._ts_language_field_name_for_id=wasmExports.ts_language_field_name_for_id)(e,t),_ts_lookahead_iterator_new=Module._ts_lookahead_iterator_new=(e,t)=>(_ts_lookahead_iterator_new=Module._ts_lookahead_iterator_new=wasmExports.ts_lookahead_iterator_new)(e,t),_ts_lookahead_iterator_delete=Module._ts_lookahead_iterator_delete=e=>(_ts_lookahead_iterator_delete=Module._ts_lookahead_iterator_delete=wasmExports.ts_lookahead_iterator_delete)(e),_ts_lookahead_iterator_reset_state=Module._ts_lookahead_iterator_reset_state=(e,t)=>(_ts_lookahead_iterator_reset_state=Module._ts_lookahead_iterator_reset_state=wasmExports.ts_lookahead_iterator_reset_state)(e,t),_ts_lookahead_iterator_reset=Module._ts_lookahead_iterator_reset=(e,t,_)=>(_ts_lookahead_iterator_reset=Module._ts_lookahead_iterator_reset=wasmExports.ts_lookahead_iterator_reset)(e,t,_),_ts_lookahead_iterator_next=Module._ts_lookahead_iterator_next=e=>(_ts_lookahead_iterator_next=Module._ts_lookahead_iterator_next=wasmExports.ts_lookahead_iterator_next)(e),_ts_lookahead_iterator_current_symbol=Module._ts_lookahead_iterator_current_symbol=e=>(_ts_lookahead_iterator_current_symbol=Module._ts_lookahead_iterator_current_symbol=wasmExports.ts_lookahead_iterator_current_symbol)(e),_memset=Module._memset=(e,t,_)=>(_memset=Module._memset=wasmExports.memset)(e,t,_),_memcpy=Module._memcpy=(e,t,_)=>(_memcpy=Module._memcpy=wasmExports.memcpy)(e,t,_),_ts_parser_delete=Module._ts_parser_delete=e=>(_ts_parser_delete=Module._ts_parser_delete=wasmExports.ts_parser_delete)(e),_ts_parser_reset=Module._ts_parser_reset=e=>(_ts_parser_reset=Module._ts_parser_reset=wasmExports.ts_parser_reset)(e),_ts_parser_set_language=Module._ts_parser_set_language=(e,t)=>(_ts_parser_set_language=Module._ts_parser_set_language=wasmExports.ts_parser_set_language)(e,t),_ts_parser_timeout_micros=Module._ts_parser_timeout_micros=e=>(_ts_parser_timeout_micros=Module._ts_parser_timeout_micros=wasmExports.ts_parser_timeout_micros)(e),_ts_parser_set_timeout_micros=Module._ts_parser_set_timeout_micros=(e,t,_)=>(_ts_parser_set_timeout_micros=Module._ts_parser_set_timeout_micros=wasmExports.ts_parser_set_timeout_micros)(e,t,_),_ts_parser_set_included_ranges=Module._ts_parser_set_included_ranges=(e,t,_)=>(_ts_parser_set_included_ranges=Module._ts_parser_set_included_ranges=wasmExports.ts_parser_set_included_ranges)(e,t,_),_memmove=Module._memmove=(e,t,_)=>(_memmove=Module._memmove=wasmExports.memmove)(e,t,_),_memcmp=Module._memcmp=(e,t,_)=>(_memcmp=Module._memcmp=wasmExports.memcmp)(e,t,_),_ts_query_new=Module._ts_query_new=(e,t,_,s,r)=>(_ts_query_new=Module._ts_query_new=wasmExports.ts_query_new)(e,t,_,s,r),_ts_query_delete=Module._ts_query_delete=e=>(_ts_query_delete=Module._ts_query_delete=wasmExports.ts_query_delete)(e),_iswspace=Module._iswspace=e=>(_iswspace=Module._iswspace=wasmExports.iswspace)(e),_iswalnum=Module._iswalnum=e=>(_iswalnum=Module._iswalnum=wasmExports.iswalnum)(e),_ts_query_pattern_count=Module._ts_query_pattern_count=e=>(_ts_query_pattern_count=Module._ts_query_pattern_count=wasmExports.ts_query_pattern_count)(e),_ts_query_capture_count=Module._ts_query_capture_count=e=>(_ts_query_capture_count=Module._ts_query_capture_count=wasmExports.ts_query_capture_count)(e),_ts_query_string_count=Module._ts_query_string_count=e=>(_ts_query_string_count=Module._ts_query_string_count=wasmExports.ts_query_string_count)(e),_ts_query_capture_name_for_id=Module._ts_query_capture_name_for_id=(e,t,_)=>(_ts_query_capture_name_for_id=Module._ts_query_capture_name_for_id=wasmExports.ts_query_capture_name_for_id)(e,t,_),_ts_query_string_value_for_id=Module._ts_query_string_value_for_id=(e,t,_)=>(_ts_query_string_value_for_id=Module._ts_query_string_value_for_id=wasmExports.ts_query_string_value_for_id)(e,t,_),_ts_query_predicates_for_pattern=Module._ts_query_predicates_for_pattern=(e,t,_)=>(_ts_query_predicates_for_pattern=Module._ts_query_predicates_for_pattern=wasmExports.ts_query_predicates_for_pattern)(e,t,_),_ts_query_disable_capture=Module._ts_query_disable_capture=(e,t,_)=>(_ts_query_disable_capture=Module._ts_query_disable_capture=wasmExports.ts_query_disable_capture)(e,t,_),_ts_tree_copy=Module._ts_tree_copy=e=>(_ts_tree_copy=Module._ts_tree_copy=wasmExports.ts_tree_copy)(e),_ts_tree_delete=Module._ts_tree_delete=e=>(_ts_tree_delete=Module._ts_tree_delete=wasmExports.ts_tree_delete)(e),_ts_init=Module._ts_init=()=>(_ts_init=Module._ts_init=wasmExports.ts_init)(),_ts_parser_new_wasm=Module._ts_parser_new_wasm=()=>(_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=(e,t)=>(_ts_parser_enable_logger_wasm=Module._ts_parser_enable_logger_wasm=wasmExports.ts_parser_enable_logger_wasm)(e,t),_ts_parser_parse_wasm=Module._ts_parser_parse_wasm=(e,t,_,s,r)=>(_ts_parser_parse_wasm=Module._ts_parser_parse_wasm=wasmExports.ts_parser_parse_wasm)(e,t,_,s,r),_ts_parser_included_ranges_wasm=Module._ts_parser_included_ranges_wasm=e=>(_ts_parser_included_ranges_wasm=Module._ts_parser_included_ranges_wasm=wasmExports.ts_parser_included_ranges_wasm)(e),_ts_language_type_is_named_wasm=Module._ts_language_type_is_named_wasm=(e,t)=>(_ts_language_type_is_named_wasm=Module._ts_language_type_is_named_wasm=wasmExports.ts_language_type_is_named_wasm)(e,t),_ts_language_type_is_visible_wasm=Module._ts_language_type_is_visible_wasm=(e,t)=>(_ts_language_type_is_visible_wasm=Module._ts_language_type_is_visible_wasm=wasmExports.ts_language_type_is_visible_wasm)(e,t),_ts_tree_root_node_wasm=Module._ts_tree_root_node_wasm=e=>(_ts_tree_root_node_wasm=Module._ts_tree_root_node_wasm=wasmExports.ts_tree_root_node_wasm)(e),_ts_tree_root_node_with_offset_wasm=Module._ts_tree_root_node_with_offset_wasm=e=>(_ts_tree_root_node_with_offset_wasm=Module._ts_tree_root_node_with_offset_wasm=wasmExports.ts_tree_root_node_with_offset_wasm)(e),_ts_tree_edit_wasm=Module._ts_tree_edit_wasm=e=>(_ts_tree_edit_wasm=Module._ts_tree_edit_wasm=wasmExports.ts_tree_edit_wasm)(e),_ts_tree_included_ranges_wasm=Module._ts_tree_included_ranges_wasm=e=>(_ts_tree_included_ranges_wasm=Module._ts_tree_included_ranges_wasm=wasmExports.ts_tree_included_ranges_wasm)(e),_ts_tree_get_changed_ranges_wasm=Module._ts_tree_get_changed_ranges_wasm=(e,t)=>(_ts_tree_get_changed_ranges_wasm=Module._ts_tree_get_changed_ranges_wasm=wasmExports.ts_tree_get_changed_ranges_wasm)(e,t),_ts_tree_cursor_new_wasm=Module._ts_tree_cursor_new_wasm=e=>(_ts_tree_cursor_new_wasm=Module._ts_tree_cursor_new_wasm=wasmExports.ts_tree_cursor_new_wasm)(e),_ts_tree_cursor_delete_wasm=Module._ts_tree_cursor_delete_wasm=e=>(_ts_tree_cursor_delete_wasm=Module._ts_tree_cursor_delete_wasm=wasmExports.ts_tree_cursor_delete_wasm)(e),_ts_tree_cursor_reset_wasm=Module._ts_tree_cursor_reset_wasm=e=>(_ts_tree_cursor_reset_wasm=Module._ts_tree_cursor_reset_wasm=wasmExports.ts_tree_cursor_reset_wasm)(e),_ts_tree_cursor_reset_to_wasm=Module._ts_tree_cursor_reset_to_wasm=(e,t)=>(_ts_tree_cursor_reset_to_wasm=Module._ts_tree_cursor_reset_to_wasm=wasmExports.ts_tree_cursor_reset_to_wasm)(e,t),_ts_tree_cursor_goto_first_child_wasm=Module._ts_tree_cursor_goto_first_child_wasm=e=>(_ts_tree_cursor_goto_first_child_wasm=Module._ts_tree_cursor_goto_first_child_wasm=wasmExports.ts_tree_cursor_goto_first_child_wasm)(e),_ts_tree_cursor_goto_last_child_wasm=Module._ts_tree_cursor_goto_last_child_wasm=e=>(_ts_tree_cursor_goto_last_child_wasm=Module._ts_tree_cursor_goto_last_child_wasm=wasmExports.ts_tree_cursor_goto_last_child_wasm)(e),_ts_tree_cursor_goto_first_child_for_index_wasm=Module._ts_tree_cursor_goto_first_child_for_index_wasm=e=>(_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)(e),_ts_tree_cursor_goto_first_child_for_position_wasm=Module._ts_tree_cursor_goto_first_child_for_position_wasm=e=>(_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)(e),_ts_tree_cursor_goto_next_sibling_wasm=Module._ts_tree_cursor_goto_next_sibling_wasm=e=>(_ts_tree_cursor_goto_next_sibling_wasm=Module._ts_tree_cursor_goto_next_sibling_wasm=wasmExports.ts_tree_cursor_goto_next_sibling_wasm)(e),_ts_tree_cursor_goto_previous_sibling_wasm=Module._ts_tree_cursor_goto_previous_sibling_wasm=e=>(_ts_tree_cursor_goto_previous_sibling_wasm=Module._ts_tree_cursor_goto_previous_sibling_wasm=wasmExports.ts_tree_cursor_goto_previous_sibling_wasm)(e),_ts_tree_cursor_goto_descendant_wasm=Module._ts_tree_cursor_goto_descendant_wasm=(e,t)=>(_ts_tree_cursor_goto_descendant_wasm=Module._ts_tree_cursor_goto_descendant_wasm=wasmExports.ts_tree_cursor_goto_descendant_wasm)(e,t),_ts_tree_cursor_goto_parent_wasm=Module._ts_tree_cursor_goto_parent_wasm=e=>(_ts_tree_cursor_goto_parent_wasm=Module._ts_tree_cursor_goto_parent_wasm=wasmExports.ts_tree_cursor_goto_parent_wasm)(e),_ts_tree_cursor_current_node_type_id_wasm=Module._ts_tree_cursor_current_node_type_id_wasm=e=>(_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)(e),_ts_tree_cursor_current_node_state_id_wasm=Module._ts_tree_cursor_current_node_state_id_wasm=e=>(_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)(e),_ts_tree_cursor_current_node_is_named_wasm=Module._ts_tree_cursor_current_node_is_named_wasm=e=>(_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)(e),_ts_tree_cursor_current_node_is_missing_wasm=Module._ts_tree_cursor_current_node_is_missing_wasm=e=>(_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)(e),_ts_tree_cursor_current_node_id_wasm=Module._ts_tree_cursor_current_node_id_wasm=e=>(_ts_tree_cursor_current_node_id_wasm=Module._ts_tree_cursor_current_node_id_wasm=wasmExports.ts_tree_cursor_current_node_id_wasm)(e),_ts_tree_cursor_start_position_wasm=Module._ts_tree_cursor_start_position_wasm=e=>(_ts_tree_cursor_start_position_wasm=Module._ts_tree_cursor_start_position_wasm=wasmExports.ts_tree_cursor_start_position_wasm)(e),_ts_tree_cursor_end_position_wasm=Module._ts_tree_cursor_end_position_wasm=e=>(_ts_tree_cursor_end_position_wasm=Module._ts_tree_cursor_end_position_wasm=wasmExports.ts_tree_cursor_end_position_wasm)(e),_ts_tree_cursor_start_index_wasm=Module._ts_tree_cursor_start_index_wasm=e=>(_ts_tree_cursor_start_index_wasm=Module._ts_tree_cursor_start_index_wasm=wasmExports.ts_tree_cursor_start_index_wasm)(e),_ts_tree_cursor_end_index_wasm=Module._ts_tree_cursor_end_index_wasm=e=>(_ts_tree_cursor_end_index_wasm=Module._ts_tree_cursor_end_index_wasm=wasmExports.ts_tree_cursor_end_index_wasm)(e),_ts_tree_cursor_current_field_id_wasm=Module._ts_tree_cursor_current_field_id_wasm=e=>(_ts_tree_cursor_current_field_id_wasm=Module._ts_tree_cursor_current_field_id_wasm=wasmExports.ts_tree_cursor_current_field_id_wasm)(e),_ts_tree_cursor_current_depth_wasm=Module._ts_tree_cursor_current_depth_wasm=e=>(_ts_tree_cursor_current_depth_wasm=Module._ts_tree_cursor_current_depth_wasm=wasmExports.ts_tree_cursor_current_depth_wasm)(e),_ts_tree_cursor_current_descendant_index_wasm=Module._ts_tree_cursor_current_descendant_index_wasm=e=>(_ts_tree_cursor_current_descendant_index_wasm=Module._ts_tree_cursor_current_descendant_index_wasm=wasmExports.ts_tree_cursor_current_descendant_index_wasm)(e),_ts_tree_cursor_current_node_wasm=Module._ts_tree_cursor_current_node_wasm=e=>(_ts_tree_cursor_current_node_wasm=Module._ts_tree_cursor_current_node_wasm=wasmExports.ts_tree_cursor_current_node_wasm)(e),_ts_node_symbol_wasm=Module._ts_node_symbol_wasm=e=>(_ts_node_symbol_wasm=Module._ts_node_symbol_wasm=wasmExports.ts_node_symbol_wasm)(e),_ts_node_field_name_for_child_wasm=Module._ts_node_field_name_for_child_wasm=(e,t)=>(_ts_node_field_name_for_child_wasm=Module._ts_node_field_name_for_child_wasm=wasmExports.ts_node_field_name_for_child_wasm)(e,t),_ts_node_children_by_field_id_wasm=Module._ts_node_children_by_field_id_wasm=(e,t)=>(_ts_node_children_by_field_id_wasm=Module._ts_node_children_by_field_id_wasm=wasmExports.ts_node_children_by_field_id_wasm)(e,t),_ts_node_first_child_for_byte_wasm=Module._ts_node_first_child_for_byte_wasm=e=>(_ts_node_first_child_for_byte_wasm=Module._ts_node_first_child_for_byte_wasm=wasmExports.ts_node_first_child_for_byte_wasm)(e),_ts_node_first_named_child_for_byte_wasm=Module._ts_node_first_named_child_for_byte_wasm=e=>(_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)(e),_ts_node_grammar_symbol_wasm=Module._ts_node_grammar_symbol_wasm=e=>(_ts_node_grammar_symbol_wasm=Module._ts_node_grammar_symbol_wasm=wasmExports.ts_node_grammar_symbol_wasm)(e),_ts_node_child_count_wasm=Module._ts_node_child_count_wasm=e=>(_ts_node_child_count_wasm=Module._ts_node_child_count_wasm=wasmExports.ts_node_child_count_wasm)(e),_ts_node_named_child_count_wasm=Module._ts_node_named_child_count_wasm=e=>(_ts_node_named_child_count_wasm=Module._ts_node_named_child_count_wasm=wasmExports.ts_node_named_child_count_wasm)(e),_ts_node_child_wasm=Module._ts_node_child_wasm=(e,t)=>(_ts_node_child_wasm=Module._ts_node_child_wasm=wasmExports.ts_node_child_wasm)(e,t),_ts_node_named_child_wasm=Module._ts_node_named_child_wasm=(e,t)=>(_ts_node_named_child_wasm=Module._ts_node_named_child_wasm=wasmExports.ts_node_named_child_wasm)(e,t),_ts_node_child_by_field_id_wasm=Module._ts_node_child_by_field_id_wasm=(e,t)=>(_ts_node_child_by_field_id_wasm=Module._ts_node_child_by_field_id_wasm=wasmExports.ts_node_child_by_field_id_wasm)(e,t),_ts_node_next_sibling_wasm=Module._ts_node_next_sibling_wasm=e=>(_ts_node_next_sibling_wasm=Module._ts_node_next_sibling_wasm=wasmExports.ts_node_next_sibling_wasm)(e),_ts_node_prev_sibling_wasm=Module._ts_node_prev_sibling_wasm=e=>(_ts_node_prev_sibling_wasm=Module._ts_node_prev_sibling_wasm=wasmExports.ts_node_prev_sibling_wasm)(e),_ts_node_next_named_sibling_wasm=Module._ts_node_next_named_sibling_wasm=e=>(_ts_node_next_named_sibling_wasm=Module._ts_node_next_named_sibling_wasm=wasmExports.ts_node_next_named_sibling_wasm)(e),_ts_node_prev_named_sibling_wasm=Module._ts_node_prev_named_sibling_wasm=e=>(_ts_node_prev_named_sibling_wasm=Module._ts_node_prev_named_sibling_wasm=wasmExports.ts_node_prev_named_sibling_wasm)(e),_ts_node_descendant_count_wasm=Module._ts_node_descendant_count_wasm=e=>(_ts_node_descendant_count_wasm=Module._ts_node_descendant_count_wasm=wasmExports.ts_node_descendant_count_wasm)(e),_ts_node_parent_wasm=Module._ts_node_parent_wasm=e=>(_ts_node_parent_wasm=Module._ts_node_parent_wasm=wasmExports.ts_node_parent_wasm)(e),_ts_node_descendant_for_index_wasm=Module._ts_node_descendant_for_index_wasm=e=>(_ts_node_descendant_for_index_wasm=Module._ts_node_descendant_for_index_wasm=wasmExports.ts_node_descendant_for_index_wasm)(e),_ts_node_named_descendant_for_index_wasm=Module._ts_node_named_descendant_for_index_wasm=e=>(_ts_node_named_descendant_for_index_wasm=Module._ts_node_named_descendant_for_index_wasm=wasmExports.ts_node_named_descendant_for_index_wasm)(e),_ts_node_descendant_for_position_wasm=Module._ts_node_descendant_for_position_wasm=e=>(_ts_node_descendant_for_position_wasm=Module._ts_node_descendant_for_position_wasm=wasmExports.ts_node_descendant_for_position_wasm)(e),_ts_node_named_descendant_for_position_wasm=Module._ts_node_named_descendant_for_position_wasm=e=>(_ts_node_named_descendant_for_position_wasm=Module._ts_node_named_descendant_for_position_wasm=wasmExports.ts_node_named_descendant_for_position_wasm)(e),_ts_node_start_point_wasm=Module._ts_node_start_point_wasm=e=>(_ts_node_start_point_wasm=Module._ts_node_start_point_wasm=wasmExports.ts_node_start_point_wasm)(e),_ts_node_end_point_wasm=Module._ts_node_end_point_wasm=e=>(_ts_node_end_point_wasm=Module._ts_node_end_point_wasm=wasmExports.ts_node_end_point_wasm)(e),_ts_node_start_index_wasm=Module._ts_node_start_index_wasm=e=>(_ts_node_start_index_wasm=Module._ts_node_start_index_wasm=wasmExports.ts_node_start_index_wasm)(e),_ts_node_end_index_wasm=Module._ts_node_end_index_wasm=e=>(_ts_node_end_index_wasm=Module._ts_node_end_index_wasm=wasmExports.ts_node_end_index_wasm)(e),_ts_node_to_string_wasm=Module._ts_node_to_string_wasm=e=>(_ts_node_to_string_wasm=Module._ts_node_to_string_wasm=wasmExports.ts_node_to_string_wasm)(e),_ts_node_children_wasm=Module._ts_node_children_wasm=e=>(_ts_node_children_wasm=Module._ts_node_children_wasm=wasmExports.ts_node_children_wasm)(e),_ts_node_named_children_wasm=Module._ts_node_named_children_wasm=e=>(_ts_node_named_children_wasm=Module._ts_node_named_children_wasm=wasmExports.ts_node_named_children_wasm)(e),_ts_node_descendants_of_type_wasm=Module._ts_node_descendants_of_type_wasm=(e,t,_,s,r,a,o)=>(_ts_node_descendants_of_type_wasm=Module._ts_node_descendants_of_type_wasm=wasmExports.ts_node_descendants_of_type_wasm)(e,t,_,s,r,a,o),_ts_node_is_named_wasm=Module._ts_node_is_named_wasm=e=>(_ts_node_is_named_wasm=Module._ts_node_is_named_wasm=wasmExports.ts_node_is_named_wasm)(e),_ts_node_has_changes_wasm=Module._ts_node_has_changes_wasm=e=>(_ts_node_has_changes_wasm=Module._ts_node_has_changes_wasm=wasmExports.ts_node_has_changes_wasm)(e),_ts_node_has_error_wasm=Module._ts_node_has_error_wasm=e=>(_ts_node_has_error_wasm=Module._ts_node_has_error_wasm=wasmExports.ts_node_has_error_wasm)(e),_ts_node_is_error_wasm=Module._ts_node_is_error_wasm=e=>(_ts_node_is_error_wasm=Module._ts_node_is_error_wasm=wasmExports.ts_node_is_error_wasm)(e),_ts_node_is_missing_wasm=Module._ts_node_is_missing_wasm=e=>(_ts_node_is_missing_wasm=Module._ts_node_is_missing_wasm=wasmExports.ts_node_is_missing_wasm)(e),_ts_node_is_extra_wasm=Module._ts_node_is_extra_wasm=e=>(_ts_node_is_extra_wasm=Module._ts_node_is_extra_wasm=wasmExports.ts_node_is_extra_wasm)(e),_ts_node_parse_state_wasm=Module._ts_node_parse_state_wasm=e=>(_ts_node_parse_state_wasm=Module._ts_node_parse_state_wasm=wasmExports.ts_node_parse_state_wasm)(e),_ts_node_next_parse_state_wasm=Module._ts_node_next_parse_state_wasm=e=>(_ts_node_next_parse_state_wasm=Module._ts_node_next_parse_state_wasm=wasmExports.ts_node_next_parse_state_wasm)(e),_ts_query_matches_wasm=Module._ts_query_matches_wasm=(e,t,_,s,r,a,o,n,l,d)=>(_ts_query_matches_wasm=Module._ts_query_matches_wasm=wasmExports.ts_query_matches_wasm)(e,t,_,s,r,a,o,n,l,d),_ts_query_captures_wasm=Module._ts_query_captures_wasm=(e,t,_,s,r,a,o,n,l,d)=>(_ts_query_captures_wasm=Module._ts_query_captures_wasm=wasmExports.ts_query_captures_wasm)(e,t,_,s,r,a,o,n,l,d),_iswalpha=Module._iswalpha=e=>(_iswalpha=Module._iswalpha=wasmExports.iswalpha)(e),_iswblank=Module._iswblank=e=>(_iswblank=Module._iswblank=wasmExports.iswblank)(e),_iswdigit=Module._iswdigit=e=>(_iswdigit=Module._iswdigit=wasmExports.iswdigit)(e),_iswlower=Module._iswlower=e=>(_iswlower=Module._iswlower=wasmExports.iswlower)(e),_iswupper=Module._iswupper=e=>(_iswupper=Module._iswupper=wasmExports.iswupper)(e),_iswxdigit=Module._iswxdigit=e=>(_iswxdigit=Module._iswxdigit=wasmExports.iswxdigit)(e),_memchr=Module._memchr=(e,t,_)=>(_memchr=Module._memchr=wasmExports.memchr)(e,t,_),_strlen=Module._strlen=e=>(_strlen=Module._strlen=wasmExports.strlen)(e),_strcmp=Module._strcmp=(e,t)=>(_strcmp=Module._strcmp=wasmExports.strcmp)(e,t),_strncpy=Module._strncpy=(e,t,_)=>(_strncpy=Module._strncpy=wasmExports.strncpy)(e,t,_),_towlower=Module._towlower=e=>(_towlower=Module._towlower=wasmExports.towlower)(e),_towupper=Module._towupper=e=>(_towupper=Module._towupper=wasmExports.towupper)(e),_setThrew=(e,t)=>(_setThrew=wasmExports.setThrew)(e,t),stackSave=()=>(stackSave=wasmExports.stackSave)(),stackRestore=e=>(stackRestore=wasmExports.stackRestore)(e),stackAlloc=e=>(stackAlloc=wasmExports.stackAlloc)(e),dynCall_jiji=Module.dynCall_jiji=(e,t,_,s,r)=>(dynCall_jiji=Module.dynCall_jiji=wasmExports.dynCall_jiji)(e,t,_,s,r),_orig$ts_parser_timeout_micros=Module._orig$ts_parser_timeout_micros=e=>(_orig$ts_parser_timeout_micros=Module._orig$ts_parser_timeout_micros=wasmExports.orig$ts_parser_timeout_micros)(e),_orig$ts_parser_set_timeout_micros=Module._orig$ts_parser_set_timeout_micros=(e,t)=>(_orig$ts_parser_set_timeout_micros=Module._orig$ts_parser_set_timeout_micros=wasmExports.orig$ts_parser_set_timeout_micros)(e,t),calledRun;function callMain(e=[]){var t=resolveGlobalSymbol("main").sym;if(t){e.unshift(thisProgram);var _=e.length,s=stackAlloc(4*(_+1)),r=s;e.forEach((e=>{HEAPU32[r>>2]=stringToUTF8OnStack(e),r+=4})),HEAPU32[r>>2]=0;try{var a=t(_,s);return exitJS(a,!0),a}catch(e){return handleException(e)}}}function run(e=arguments_){function t(){calledRun||(calledRun=!0,Module.calledRun=!0,ABORT||(initRuntime(),preMain(),Module.onRuntimeInitialized&&Module.onRuntimeInitialized(),shouldRunNow&&callMain(e),postRun()))}runDependencies>0||(preRun(),runDependencies>0||(Module.setStatus?(Module.setStatus("Running..."),setTimeout((function(){setTimeout((function(){Module.setStatus("")}),1),t()}),1)):t()))}if(Module.AsciiToString=AsciiToString,Module.stringToUTF16=stringToUTF16,dependenciesFulfilled=function e(){calledRun||run(),calledRun||(dependenciesFulfilled=e)},Module.preInit)for("function"==typeof Module.preInit&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.pop()();var shouldRunNow=!0;Module.noInitialRun&&(shouldRunNow=!1),run();const C=Module,INTERNAL={},SIZE_OF_INT=4,SIZE_OF_CURSOR=3*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},QUERY_WORD_REGEX=/[\w-.]*/g,PREDICATE_STEP_TYPE_CAPTURE=1,PREDICATE_STEP_TYPE_STRING=2,LANGUAGE_FUNCTION_REGEX=/^_?tree_sitter_\w+/;let VERSION,MIN_COMPATIBLE_VERSION,TRANSFER_BUFFER,currentParseCallback,currentLogCallback;class ParserImpl{static init(){TRANSFER_BUFFER=C._ts_init(),VERSION=getValue(TRANSFER_BUFFER,"i32"),MIN_COMPATIBLE_VERSION=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32")}initialize(){C._ts_parser_new_wasm(),this[0]=getValue(TRANSFER_BUFFER,"i32"),this[1]=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(e){let t;if(e){if(e.constructor!==Language)throw new Error("Argument must be a Language");{t=e[0];const _=C._ts_language_version(t);if(_<MIN_COMPATIBLE_VERSION||VERSION<_)throw new Error(`Incompatible language version ${_}. Compatibility range ${MIN_COMPATIBLE_VERSION} through ${VERSION}.`)}}else t=0,e=null;return this.language=e,C._ts_parser_set_language(this[0],t),this}getLanguage(){return this.language}parse(e,t,_){if("string"==typeof e)currentParseCallback=(t,_)=>e.slice(t);else{if("function"!=typeof e)throw new Error("Argument must be a string or a function");currentParseCallback=e}this.logCallback?(currentLogCallback=this.logCallback,C._ts_parser_enable_logger_wasm(this[0],1)):(currentLogCallback=null,C._ts_parser_enable_logger_wasm(this[0],0));let s=0,r=0;if(_&&_.includedRanges){s=_.includedRanges.length,r=C._calloc(s,SIZE_OF_RANGE);let e=r;for(let t=0;t<s;t++)marshalRange(e,_.includedRanges[t]),e+=SIZE_OF_RANGE}const a=C._ts_parser_parse_wasm(this[0],this[1],t?t[0]:0,r,s);if(!a)throw currentParseCallback=null,currentLogCallback=null,new Error("Parsing failed");const o=new Tree(INTERNAL,a,this.language,currentParseCallback);return currentParseCallback=null,currentLogCallback=null,o}reset(){C._ts_parser_reset(this[0])}getIncludedRanges(){C._ts_parser_included_ranges_wasm(this[0]);const e=getValue(TRANSFER_BUFFER,"i32"),t=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),_=new Array(e);if(e>0){let s=t;for(let t=0;t<e;t++)_[t]=unmarshalRange(s),s+=SIZE_OF_RANGE;C._free(t)}return _}getTimeoutMicros(){return C._ts_parser_timeout_micros(this[0])}setTimeoutMicros(e){C._ts_parser_set_timeout_micros(this[0],e)}setLogger(e){if(e){if("function"!=typeof e)throw new Error("Logger callback must be a function")}else e=null;return this.logCallback=e,this}getLogger(){return this.logCallback}}class Tree{constructor(e,t,_,s){assertInternal(e),this[0]=t,this.language=_,this.textCallback=s}copy(){const e=C._ts_tree_copy(this[0]);return new Tree(INTERNAL,e,this.language,this.textCallback)}delete(){C._ts_tree_delete(this[0]),this[0]=0}edit(e){marshalEdit(e),C._ts_tree_edit_wasm(this[0])}get rootNode(){return C._ts_tree_root_node_wasm(this[0]),unmarshalNode(this)}rootNodeWithOffset(e,t){const _=TRANSFER_BUFFER+SIZE_OF_NODE;return setValue(_,e,"i32"),marshalPoint(_+SIZE_OF_INT,t),C._ts_tree_root_node_with_offset_wasm(this[0]),unmarshalNode(this)}getLanguage(){return this.language}walk(){return this.rootNode.walk()}getChangedRanges(e){if(e.constructor!==Tree)throw new TypeError("Argument must be a Tree");C._ts_tree_get_changed_ranges_wasm(this[0],e[0]);const t=getValue(TRANSFER_BUFFER,"i32"),_=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),s=new Array(t);if(t>0){let e=_;for(let _=0;_<t;_++)s[_]=unmarshalRange(e),e+=SIZE_OF_RANGE;C._free(_)}return s}getIncludedRanges(){C._ts_tree_included_ranges_wasm(this[0]);const e=getValue(TRANSFER_BUFFER,"i32"),t=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),_=new Array(e);if(e>0){let s=t;for(let t=0;t<e;t++)_[t]=unmarshalRange(s),s+=SIZE_OF_RANGE;C._free(t)}return _}}class Node{constructor(e,t){assertInternal(e),this.tree=t}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 endPosition(){return marshalNode(this),C._ts_node_end_point_wasm(this.tree[0]),unmarshalPoint(TRANSFER_BUFFER)}get endIndex(){return marshalNode(this),C._ts_node_end_index_wasm(this.tree[0])}get text(){return getText(this.tree,this.startIndex,this.endIndex)}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])}get isNamed(){return marshalNode(this),1===C._ts_node_is_named_wasm(this.tree[0])}get hasError(){return marshalNode(this),1===C._ts_node_has_error_wasm(this.tree[0])}get hasChanges(){return marshalNode(this),1===C._ts_node_has_changes_wasm(this.tree[0])}get isError(){return marshalNode(this),1===C._ts_node_is_error_wasm(this.tree[0])}get isMissing(){return marshalNode(this),1===C._ts_node_is_missing_wasm(this.tree[0])}get isExtra(){return marshalNode(this),1===C._ts_node_is_extra_wasm(this.tree[0])}equals(e){return this.id===e.id}child(e){return marshalNode(this),C._ts_node_child_wasm(this.tree[0],e),unmarshalNode(this.tree)}namedChild(e){return marshalNode(this),C._ts_node_named_child_wasm(this.tree[0],e),unmarshalNode(this.tree)}childForFieldId(e){return marshalNode(this),C._ts_node_child_by_field_id_wasm(this.tree[0],e),unmarshalNode(this.tree)}childForFieldName(e){const t=this.tree.language.fields.indexOf(e);if(-1!==t)return this.childForFieldId(t)}fieldNameForChild(e){marshalNode(this);const t=C._ts_node_field_name_for_child_wasm(this.tree[0],e);if(!t)return null;return AsciiToString(t)}childrenForFieldName(e){const t=this.tree.language.fields.indexOf(e);if(-1!==t&&0!==t)return this.childrenForFieldId(t)}childrenForFieldId(e){marshalNode(this),C._ts_node_children_by_field_id_wasm(this.tree[0],e);const t=getValue(TRANSFER_BUFFER,"i32"),_=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),s=new Array(t);if(t>0){let e=_;for(let _=0;_<t;_++)s[_]=unmarshalNode(this.tree,e),e+=SIZE_OF_NODE;C._free(_)}return s}firstChildForIndex(e){marshalNode(this);return setValue(TRANSFER_BUFFER+SIZE_OF_NODE,e,"i32"),C._ts_node_first_child_for_byte_wasm(this.tree[0]),unmarshalNode(this.tree)}firstNamedChildForIndex(e){marshalNode(this);return setValue(TRANSFER_BUFFER+SIZE_OF_NODE,e,"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]);const e=getValue(TRANSFER_BUFFER,"i32"),t=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32");if(this._children=new Array(e),e>0){let _=t;for(let t=0;t<e;t++)this._children[t]=unmarshalNode(this.tree,_),_+=SIZE_OF_NODE;C._free(t)}}return this._children}get namedChildren(){if(!this._namedChildren){marshalNode(this),C._ts_node_named_children_wasm(this.tree[0]);const e=getValue(TRANSFER_BUFFER,"i32"),t=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32");if(this._namedChildren=new Array(e),e>0){let _=t;for(let t=0;t<e;t++)this._namedChildren[t]=unmarshalNode(this.tree,_),_+=SIZE_OF_NODE;C._free(t)}}return this._namedChildren}descendantsOfType(e,t,_){Array.isArray(e)||(e=[e]),t||(t=ZERO_POINT),_||(_=ZERO_POINT);const s=[],r=this.tree.language.types;for(let t=0,_=r.length;t<_;t++)e.includes(r[t])&&s.push(t);const a=C._malloc(SIZE_OF_INT*s.length);for(let e=0,t=s.length;e<t;e++)setValue(a+e*SIZE_OF_INT,s[e],"i32");marshalNode(this),C._ts_node_descendants_of_type_wasm(this.tree[0],a,s.length,t.row,t.column,_.row,_.column);const o=getValue(TRANSFER_BUFFER,"i32"),n=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),l=new Array(o);if(o>0){let e=n;for(let t=0;t<o;t++)l[t]=unmarshalNode(this.tree,e),e+=SIZE_OF_NODE}return C._free(n),C._free(a),l}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)}descendantForIndex(e,t=e){if("number"!=typeof e||"number"!=typeof t)throw new Error("Arguments must be numbers");marshalNode(this);const _=TRANSFER_BUFFER+SIZE_OF_NODE;return setValue(_,e,"i32"),setValue(_+SIZE_OF_INT,t,"i32"),C._ts_node_descendant_for_index_wasm(this.tree[0]),unmarshalNode(this.tree)}namedDescendantForIndex(e,t=e){if("number"!=typeof e||"number"!=typeof t)throw new Error("Arguments must be numbers");marshalNode(this);const _=TRANSFER_BUFFER+SIZE_OF_NODE;return setValue(_,e,"i32"),setValue(_+SIZE_OF_INT,t,"i32"),C._ts_node_named_descendant_for_index_wasm(this.tree[0]),unmarshalNode(this.tree)}descendantForPosition(e,t=e){if(!isPoint(e)||!isPoint(t))throw new Error("Arguments must be {row, column} objects");marshalNode(this);const _=TRANSFER_BUFFER+SIZE_OF_NODE;return marshalPoint(_,e),marshalPoint(_+SIZE_OF_POINT,t),C._ts_node_descendant_for_position_wasm(this.tree[0]),unmarshalNode(this.tree)}namedDescendantForPosition(e,t=e){if(!isPoint(e)||!isPoint(t))throw new Error("Arguments must be {row, column} objects");marshalNode(this);const _=TRANSFER_BUFFER+SIZE_OF_NODE;return marshalPoint(_,e),marshalPoint(_+SIZE_OF_POINT,t),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)}toString(){marshalNode(this);const e=C._ts_node_to_string_wasm(this.tree[0]),t=AsciiToString(e);return C._free(e),t}}class TreeCursor{constructor(e,t){assertInternal(e),this.tree=t,unmarshalTreeCursor(this)}delete(){marshalTreeCursor(this),C._ts_tree_cursor_delete_wasm(this.tree[0]),this[0]=this[1]=this[2]=0}reset(e){marshalNode(e),marshalTreeCursor(this,TRANSFER_BUFFER+SIZE_OF_NODE),C._ts_tree_cursor_reset_wasm(this.tree[0]),unmarshalTreeCursor(this)}resetTo(e){marshalTreeCursor(this,TRANSFER_BUFFER),marshalTreeCursor(e,TRANSFER_BUFFER+SIZE_OF_CURSOR),C._ts_tree_cursor_reset_to_wasm(this.tree[0],e.tree[0]),unmarshalTreeCursor(this)}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),1===C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0])}get nodeIsMissing(){return marshalTreeCursor(this),1===C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0])}get nodeText(){marshalTreeCursor(this);const e=C._ts_tree_cursor_start_index_wasm(this.tree[0]),t=C._ts_tree_cursor_end_index_wasm(this.tree[0]);return getText(this.tree,e,t)}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])}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])}gotoFirstChild(){marshalTreeCursor(this);const e=C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===e}gotoLastChild(){marshalTreeCursor(this);const e=C._ts_tree_cursor_goto_last_child_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===e}gotoFirstChildForIndex(e){marshalTreeCursor(this),setValue(TRANSFER_BUFFER+SIZE_OF_CURSOR,e,"i32");const t=C._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===t}gotoFirstChildForPosition(e){marshalTreeCursor(this),marshalPoint(TRANSFER_BUFFER+SIZE_OF_CURSOR,e);const t=C._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===t}gotoNextSibling(){marshalTreeCursor(this);const e=C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===e}gotoPreviousSibling(){marshalTreeCursor(this);const e=C._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===e}gotoDescendant(e){marshalTreeCursor(this),C._ts_tree_cursor_goto_descendant_wasm(this.tree[0],e),unmarshalTreeCursor(this)}gotoParent(){marshalTreeCursor(this);const e=C._ts_tree_cursor_goto_parent_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===e}}class Language{constructor(e,t){assertInternal(e),this[0]=t,this.types=new Array(C._ts_language_symbol_count(this[0]));for(let e=0,t=this.types.length;e<t;e++)C._ts_language_symbol_type(this[0],e)<2&&(this.types[e]=UTF8ToString(C._ts_language_symbol_name(this[0],e)));this.fields=new Array(C._ts_language_field_count(this[0])+1);for(let e=0,t=this.fields.length;e<t;e++){const t=C._ts_language_field_name_for_id(this[0],e);this.fields[e]=0!==t?UTF8ToString(t):null}}get version(){return C._ts_language_version(this[0])}get fieldCount(){return this.fields.length-1}get stateCount(){return C._ts_language_state_count(this[0])}fieldIdForName(e){const t=this.fields.indexOf(e);return-1!==t?t:null}fieldNameForId(e){return this.fields[e]||null}idForNodeType(e,t){const _=lengthBytesUTF8(e),s=C._malloc(_+1);stringToUTF8(e,s,_+1);const r=C._ts_language_symbol_for_name(this[0],s,_,t);return C._free(s),r||null}get nodeTypeCount(){return C._ts_language_symbol_count(this[0])}nodeTypeForId(e){const t=C._ts_language_symbol_name(this[0],e);return t?UTF8ToString(t):null}nodeTypeIsNamed(e){return!!C._ts_language_type_is_named_wasm(this[0],e)}nodeTypeIsVisible(e){return!!C._ts_language_type_is_visible_wasm(this[0],e)}nextState(e,t){return C._ts_language_next_state(this[0],e,t)}lookaheadIterator(e){const t=C._ts_lookahead_iterator_new(this[0],e);if(t)return new LookaheadIterable(INTERNAL,t,this)}query(e){const t=lengthBytesUTF8(e),_=C._malloc(t+1);stringToUTF8(e,_,t+1);const s=C._ts_query_new(this[0],_,t,TRANSFER_BUFFER,TRANSFER_BUFFER+SIZE_OF_INT);if(!s){const t=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),s=getValue(TRANSFER_BUFFER,"i32"),r=UTF8ToString(_,s).length,a=e.substr(r,100).split("\n")[0];let o,n=a.match(QUERY_WORD_REGEX)[0];switch(t){case 2:o=new RangeError(`Bad node name '${n}'`);break;case 3:o=new RangeError(`Bad field name '${n}'`);break;case 4:o=new RangeError(`Bad capture name @${n}`);break;case 5:o=new TypeError(`Bad pattern structure at offset ${r}: '${a}'...`),n="";break;default:o=new SyntaxError(`Bad syntax at offset ${r}: '${a}'...`),n=""}throw o.index=r,o.length=n.length,C._free(_),o}const r=C._ts_query_string_count(s),a=C._ts_query_capture_count(s),o=C._ts_query_pattern_count(s),n=new Array(a),l=new Array(r);for(let e=0;e<a;e++){const t=C._ts_query_capture_name_for_id(s,e,TRANSFER_BUFFER),_=getValue(TRANSFER_BUFFER,"i32");n[e]=UTF8ToString(t,_)}for(let e=0;e<r;e++){const t=C._ts_query_string_value_for_id(s,e,TRANSFER_BUFFER),_=getValue(TRANSFER_BUFFER,"i32");l[e]=UTF8ToString(t,_)}const d=new Array(o),u=new Array(o),m=new Array(o),c=new Array(o),w=new Array(o);for(let e=0;e<o;e++){const t=C._ts_query_predicates_for_pattern(s,e,TRANSFER_BUFFER),_=getValue(TRANSFER_BUFFER,"i32");c[e]=[],w[e]=[];const r=[];let a=t;for(let t=0;t<_;t++){const t=getValue(a,"i32");a+=SIZE_OF_INT;const _=getValue(a,"i32");if(a+=SIZE_OF_INT,t===PREDICATE_STEP_TYPE_CAPTURE)r.push({type:"capture",name:n[_]});else if(t===PREDICATE_STEP_TYPE_STRING)r.push({type:"string",value:l[_]});else if(r.length>0){if("string"!==r[0].type)throw new Error("Predicates must begin with a literal value");const t=r[0].value;let _,s=!0,a=!0;switch(t){case"any-not-eq?":case"not-eq?":s=!1;case"any-eq?":case"eq?":if(3!==r.length)throw new Error(`Wrong number of arguments to \`#${t}\` predicate. Expected 2, got ${r.length-1}`);if("capture"!==r[1].type)throw new Error(`First argument of \`#${t}\` predicate must be a capture. Got "${r[1].value}"`);if(a=!t.startsWith("any-"),"capture"===r[2].type){const t=r[1].name,_=r[2].name;w[e].push((function(e){const r=[],o=[];for(const s of e)s.name===t&&r.push(s.node),s.name===_&&o.push(s.node);const n=(e,t,_)=>_?e.text===t.text:e.text!==t.text;return a?r.every((e=>o.some((t=>n(e,t,s))))):r.some((e=>o.some((t=>n(e,t,s)))))}))}else{_=r[1].name;const t=r[2].value,o=e=>e.text===t,n=e=>e.text!==t;w[e].push((function(e){const t=[];for(const s of e)s.name===_&&t.push(s.node);const r=s?o:n;return a?t.every(r):t.some(r)}))}break;case"any-not-match?":case"not-match?":s=!1;case"any-match?":case"match?":if(3!==r.length)throw new Error(`Wrong number of arguments to \`#${t}\` predicate. Expected 2, got ${r.length-1}.`);if("capture"!==r[1].type)throw new Error(`First argument of \`#${t}\` predicate must be a capture. Got "${r[1].value}".`);if("string"!==r[2].type)throw new Error(`Second argument of \`#${t}\` predicate must be a string. Got @${r[2].value}.`);_=r[1].name;const o=new RegExp(r[2].value);a=!t.startsWith("any-"),w[e].push((function(e){const t=[];for(const s of e)s.name===_&&t.push(s.node.text);const r=(e,t)=>t?o.test(e):!o.test(e);return 0===t.length?!s:a?t.every((e=>r(e,s))):t.some((e=>r(e,s)))}));break;case"set!":if(r.length<2||r.length>3)throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${r.length-1}.`);if(r.some((e=>"string"!==e.type)))throw new Error('Arguments to `#set!` predicate must be a strings.".');d[e]||(d[e]={}),d[e][r[1].value]=r[2]?r[2].value:null;break;case"is?":case"is-not?":if(r.length<2||r.length>3)throw new Error(`Wrong number of arguments to \`#${t}\` predicate. Expected 1 or 2. Got ${r.length-1}.`);if(r.some((e=>"string"!==e.type)))throw new Error(`Arguments to \`#${t}\` predicate must be a strings.".`);const n="is?"===t?u:m;n[e]||(n[e]={}),n[e][r[1].value]=r[2]?r[2].value:null;break;case"not-any-of?":s=!1;case"any-of?":if(r.length<2)throw new Error(`Wrong number of arguments to \`#${t}\` predicate. Expected at least 1. Got ${r.length-1}.`);if("capture"!==r[1].type)throw new Error(`First argument of \`#${t}\` predicate must be a capture. Got "${r[1].value}".`);for(let e=2;e<r.length;e++)if("string"!==r[e].type)throw new Error(`Arguments to \`#${t}\` predicate must be a strings.".`);_=r[1].name;const l=r.slice(2).map((e=>e.value));w[e].push((function(e){const t=[];for(const s of e)s.name===_&&t.push(s.node.text);return 0===t.length?!s:t.every((e=>l.includes(e)))===s}));break;default:c[e].push({operator:t,operands:r.slice(1)})}r.length=0}}Object.freeze(d[e]),Object.freeze(u[e]),Object.freeze(m[e])}return C._free(_),new Query(INTERNAL,s,n,w,c,Object.freeze(d),Object.freeze(u),Object.freeze(m))}static load(e){let t;if(e instanceof Uint8Array)t=Promise.resolve(e);else{const _=e;if("undefined"!=typeof process&&process.versions&&process.versions.node){const e=require("fs");t=Promise.resolve(e.readFileSync(_))}else t=fetch(_).then((e=>e.arrayBuffer().then((t=>{if(e.ok)return new Uint8Array(t);{const _=new TextDecoder("utf-8").decode(t);throw new Error(`Language.load failed with status ${e.status}.\n\n${_}`)}}))))}return t.then((e=>loadWebAssemblyModule(e,{loadAsync:!0}))).then((e=>{const t=Object.keys(e),_=t.find((e=>LANGUAGE_FUNCTION_REGEX.test(e)&&!e.includes("external_scanner_")));_||console.log(`Couldn't find language function in WASM file. Symbols:\n${JSON.stringify(t,null,2)}`);const s=e[_]();return new Language(INTERNAL,s)}))}}class LookaheadIterable{constructor(e,t,_){assertInternal(e),this[0]=t,this.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}resetState(e){return C._ts_lookahead_iterator_reset_state(this[0],e)}reset(e,t){return!!C._ts_lookahead_iterator_reset(this[0],e[0],t)&&(this.language=e,!0)}[Symbol.iterator](){const e=this;return{next:()=>C._ts_lookahead_iterator_next(e[0])?{done:!1,value:e.currentType}:{done:!0,value:""}}}}class Query{constructor(e,t,_,s,r,a,o,n){assertInternal(e),this[0]=t,this.captureNames=_,this.textPredicates=s,this.predicates=r,this.setProperties=a,this.assertedProperties=o,this.refutedProperties=n,this.exceededMatchLimit=!1}delete(){C._ts_query_delete(this[0]),this[0]=0}matches(e,{startPosition:t=ZERO_POINT,endPosition:_=ZERO_POINT,startIndex:s=0,endIndex:r=0,matchLimit:a=4294967295,maxStartDepth:o=4294967295}={}){if("number"!=typeof a)throw new Error("Arguments must be numbers");marshalNode(e),C._ts_query_matches_wasm(this[0],e.tree[0],t.row,t.column,_.row,_.column,s,r,a,o);const n=getValue(TRANSFER_BUFFER,"i32"),l=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),d=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),u=new Array(n);this.exceededMatchLimit=!!d;let m=0,c=l;for(let t=0;t<n;t++){const t=getValue(c,"i32");c+=SIZE_OF_INT;const _=getValue(c,"i32");c+=SIZE_OF_INT;const s=new Array(_);if(c=unmarshalCaptures(this,e.tree,c,s),this.textPredicates[t].every((e=>e(s)))){u[m]={pattern:t,captures:s};const e=this.setProperties[t];e&&(u[m].setProperties=e);const _=this.assertedProperties[t];_&&(u[m].assertedProperties=_);const r=this.refutedProperties[t];r&&(u[m].refutedProperties=r),m++}}return u.length=m,C._free(l),u}captures(e,{startPosition:t=ZERO_POINT,endPosition:_=ZERO_POINT,startIndex:s=0,endIndex:r=0,matchLimit:a=4294967295,maxStartDepth:o=4294967295}={}){if("number"!=typeof a)throw new Error("Arguments must be numbers");marshalNode(e),C._ts_query_captures_wasm(this[0],e.tree[0],t.row,t.column,_.row,_.column,s,r,a,o);const n=getValue(TRANSFER_BUFFER,"i32"),l=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),d=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),u=[];this.exceededMatchLimit=!!d;const m=[];let c=l;for(let t=0;t<n;t++){const t=getValue(c,"i32");c+=SIZE_OF_INT;const _=getValue(c,"i32");c+=SIZE_OF_INT;const s=getValue(c,"i32");if(c+=SIZE_OF_INT,m.length=_,c=unmarshalCaptures(this,e.tree,c,m),this.textPredicates[t].every((e=>e(m)))){const e=m[s],_=this.setProperties[t];_&&(e.setProperties=_);const r=this.assertedProperties[t];r&&(e.assertedProperties=r);const a=this.refutedProperties[t];a&&(e.refutedProperties=a),u.push(e)}}return C._free(l),u}predicatesForPattern(e){return this.predicates[e]}disableCapture(e){const t=lengthBytesUTF8(e),_=C._malloc(t+1);stringToUTF8(e,_,t+1),C._ts_query_disable_capture(this[0],_,t),C._free(_)}didExceedMatchLimit(){return this.exceededMatchLimit}}function getText(e,t,_){const s=_-t;let r=e.textCallback(t,null,_);for(t+=r.length;t<_;){const s=e.textCallback(t,null,_);if(!(s&&s.length>0))break;t+=s.length,r+=s}return t>_&&(r=r.slice(0,s)),r}function unmarshalCaptures(e,t,_,s){for(let r=0,a=s.length;r<a;r++){const a=getValue(_,"i32"),o=unmarshalNode(t,_+=SIZE_OF_INT);_+=SIZE_OF_NODE,s[r]={name:e.captureNames[a],node:o}}return _}function assertInternal(e){if(e!==INTERNAL)throw new Error("Illegal constructor")}function isPoint(e){return e&&"number"==typeof e.row&&"number"==typeof e.column}function marshalNode(e){let t=TRANSFER_BUFFER;setValue(t,e.id,"i32"),t+=SIZE_OF_INT,setValue(t,e.startIndex,"i32"),t+=SIZE_OF_INT,setValue(t,e.startPosition.row,"i32"),t+=SIZE_OF_INT,setValue(t,e.startPosition.column,"i32"),t+=SIZE_OF_INT,setValue(t,e[0],"i32")}function unmarshalNode(e,t=TRANSFER_BUFFER){const _=getValue(t,"i32");if(0===_)return null;const s=getValue(t+=SIZE_OF_INT,"i32"),r=getValue(t+=SIZE_OF_INT,"i32"),a=getValue(t+=SIZE_OF_INT,"i32"),o=getValue(t+=SIZE_OF_INT,"i32"),n=new Node(INTERNAL,e);return n.id=_,n.startIndex=s,n.startPosition={row:r,column:a},n[0]=o,n}function marshalTreeCursor(e,t=TRANSFER_BUFFER){setValue(t+0*SIZE_OF_INT,e[0],"i32"),setValue(t+1*SIZE_OF_INT,e[1],"i32"),setValue(t+2*SIZE_OF_INT,e[2],"i32")}function unmarshalTreeCursor(e){e[0]=getValue(TRANSFER_BUFFER+0*SIZE_OF_INT,"i32"),e[1]=getValue(TRANSFER_BUFFER+1*SIZE_OF_INT,"i32"),e[2]=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32")}function marshalPoint(e,t){setValue(e,t.row,"i32"),setValue(e+SIZE_OF_INT,t.column,"i32")}function unmarshalPoint(e){return{row:getValue(e,"i32")>>>0,column:getValue(e+SIZE_OF_INT,"i32")>>>0}}function marshalRange(e,t){marshalPoint(e,t.startPosition),marshalPoint(e+=SIZE_OF_POINT,t.endPosition),setValue(e+=SIZE_OF_POINT,t.startIndex,"i32"),setValue(e+=SIZE_OF_INT,t.endIndex,"i32"),e+=SIZE_OF_INT}function unmarshalRange(e){const t={};return t.startPosition=unmarshalPoint(e),e+=SIZE_OF_POINT,t.endPosition=unmarshalPoint(e),e+=SIZE_OF_POINT,t.startIndex=getValue(e,"i32")>>>0,e+=SIZE_OF_INT,t.endIndex=getValue(e,"i32")>>>0,t}function marshalEdit(e){let t=TRANSFER_BUFFER;marshalPoint(t,e.startPosition),t+=SIZE_OF_POINT,marshalPoint(t,e.oldEndPosition),t+=SIZE_OF_POINT,marshalPoint(t,e.newEndPosition),t+=SIZE_OF_POINT,setValue(t,e.startIndex,"i32"),t+=SIZE_OF_INT,setValue(t,e.oldEndIndex,"i32"),t+=SIZE_OF_INT,setValue(t,e.newEndIndex,"i32"),t+=SIZE_OF_INT}for(const e of Object.getOwnPropertyNames(ParserImpl.prototype))Object.defineProperty(Parser.prototype,e,{value:ParserImpl.prototype[e],enumerable:!1,writable:!1});Parser.Language=Language,Module.onRuntimeInitialized=()=>{ParserImpl.init(),resolveInitPromise()}})))}}return Parser}();"object"==typeof exports&&(module.exports=TreeSitter);
7
+ // include: shell.js
8
+ // The Module object: Our interface to the outside world. We import
9
+ // and export values on it. There are various ways Module can be used:
10
+ // 1. Not defined. We create it here
11
+ // 2. A function parameter, function(moduleArg) => Promise<Module>
12
+ // 3. pre-run appended it, var Module = {}; ..generated code..
13
+ // 4. External script tag defines var Module.
14
+ // We need to check if Module already exists (e.g. case 3 above).
15
+ // Substitution will be replaced with actual code on later stage of the build,
16
+ // this way Closure Compiler will not mangle it (e.g. case 4. above).
17
+ // Note that if you want to run closure, and also to use Module
18
+ // after the generated code, you will need to define var Module = {};
19
+ // before the code. Then that object will be used in the code, and you
20
+ // can continue to use Module afterwards as well.
21
+ var Module = typeof Module != "undefined" ? Module : {};
22
+
23
+ // Determine the runtime environment we are in. You can customize this by
24
+ // setting the ENVIRONMENT setting at compile time (see settings.js).
25
+ // Attempt to auto-detect the environment
26
+ var ENVIRONMENT_IS_WEB = typeof window == "object";
27
+
28
+ var ENVIRONMENT_IS_WORKER = typeof importScripts == "function";
29
+
30
+ // N.b. Electron.js environment is simultaneously a NODE-environment, but
31
+ // also a web environment.
32
+ var ENVIRONMENT_IS_NODE = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string";
33
+
34
+ if (ENVIRONMENT_IS_NODE) {}
35
+
36
+ // --pre-jses are emitted after the Module integration code, so that they can
37
+ // refer to Module (if they choose; they can also define Module)
38
+ // include: /mnt/vss/_work/1/s/tree-sitter/lib/binding_web/prefix.js
39
+ var TreeSitter = function() {
40
+ var initPromise;
41
+ var document = typeof window == "object" ? {
42
+ currentScript: window.document.currentScript
43
+ } : null;
44
+ class Parser {
45
+ constructor() {
46
+ this.initialize();
47
+ }
48
+ initialize() {
49
+ throw new Error("cannot construct a Parser before calling `init()`");
50
+ }
51
+ static init(moduleOptions) {
52
+ if (initPromise) return initPromise;
53
+ Module = Object.assign({}, Module, moduleOptions);
54
+ return initPromise = new Promise(resolveInitPromise => {
55
+ // end include: /mnt/vss/_work/1/s/tree-sitter/lib/binding_web/prefix.js
56
+ // Sometimes an existing Module object exists with properties
57
+ // meant to overwrite the default module functionality. Here
58
+ // we collect those properties and reapply _after_ we configure
59
+ // the current environment's defaults to avoid having to be so
60
+ // defensive during initialization.
61
+ var moduleOverrides = Object.assign({}, Module);
62
+ var arguments_ = [];
63
+ var thisProgram = "./this.program";
64
+ var quit_ = (status, toThrow) => {
65
+ throw toThrow;
66
+ };
67
+ // `/` should be present at the end if `scriptDirectory` is not empty
68
+ var scriptDirectory = "";
69
+ function locateFile(path) {
70
+ if (Module["locateFile"]) {
71
+ return Module["locateFile"](path, scriptDirectory);
72
+ }
73
+ return scriptDirectory + path;
74
+ }
75
+ // Hooks that are implemented differently in different runtime environments.
76
+ var readAsync, readBinary;
77
+ if (ENVIRONMENT_IS_NODE) {
78
+ // These modules will usually be used on Node.js. Load them eagerly to avoid
79
+ // the complexity of lazy-loading.
80
+ var fs = require("fs");
81
+ var nodePath = require("path");
82
+ scriptDirectory = __dirname + "/";
83
+ // include: node_shell_read.js
84
+ readBinary = filename => {
85
+ // We need to re-wrap `file://` strings to URLs. Normalizing isn't
86
+ // necessary in that case, the path should already be absolute.
87
+ filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
88
+ var ret = fs.readFileSync(filename);
89
+ return ret;
90
+ };
91
+ readAsync = (filename, binary = true) => {
92
+ // See the comment in the `readBinary` function.
93
+ filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
94
+ return new Promise((resolve, reject) => {
95
+ fs.readFile(filename, binary ? undefined : "utf8", (err, data) => {
96
+ if (err) reject(err); else resolve(binary ? data.buffer : data);
97
+ });
98
+ });
99
+ };
100
+ // end include: node_shell_read.js
101
+ if (!Module["thisProgram"] && process.argv.length > 1) {
102
+ thisProgram = process.argv[1].replace(/\\/g, "/");
103
+ }
104
+ arguments_ = process.argv.slice(2);
105
+ if (typeof module != "undefined") {
106
+ module["exports"] = Module;
107
+ }
108
+ quit_ = (status, toThrow) => {
109
+ process.exitCode = status;
110
+ throw toThrow;
111
+ };
112
+ } else // Note that this includes Node.js workers when relevant (pthreads is enabled).
113
+ // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
114
+ // ENVIRONMENT_IS_NODE.
115
+ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
116
+ if (ENVIRONMENT_IS_WORKER) {
117
+ // Check worker, not web, since window could be polyfilled
118
+ scriptDirectory = self.location.href;
119
+ } else if (typeof document != "undefined" && document.currentScript) {
120
+ // web
121
+ scriptDirectory = document.currentScript.src;
122
+ }
123
+ // blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them.
124
+ // otherwise, slice off the final part of the url to find the script directory.
125
+ // if scriptDirectory does not contain a slash, lastIndexOf will return -1,
126
+ // and scriptDirectory will correctly be replaced with an empty string.
127
+ // If scriptDirectory contains a query (starting with ?) or a fragment (starting with #),
128
+ // they are removed because they could contain a slash.
129
+ if (scriptDirectory.startsWith("blob:")) {
130
+ scriptDirectory = "";
131
+ } else {
132
+ scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
133
+ }
134
+ {
135
+ // include: web_or_worker_shell_read.js
136
+ if (ENVIRONMENT_IS_WORKER) {
137
+ readBinary = url => {
138
+ var xhr = new XMLHttpRequest;
139
+ xhr.open("GET", url, false);
140
+ xhr.responseType = "arraybuffer";
141
+ xhr.send(null);
142
+ return new Uint8Array(/** @type{!ArrayBuffer} */ (xhr.response));
143
+ };
144
+ }
145
+ readAsync = url => {
146
+ // Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
147
+ // See https://github.com/github/fetch/pull/92#issuecomment-140665932
148
+ // Cordova or Electron apps are typically loaded from a file:// url.
149
+ // So use XHR on webview if URL is a file URL.
150
+ if (isFileURI(url)) {
151
+ return new Promise((reject, resolve) => {
152
+ var xhr = new XMLHttpRequest;
153
+ xhr.open("GET", url, true);
154
+ xhr.responseType = "arraybuffer";
155
+ xhr.onload = () => {
156
+ if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) {
157
+ // file URLs can return 0
158
+ resolve(xhr.response);
159
+ }
160
+ reject(xhr.status);
161
+ };
162
+ xhr.onerror = reject;
163
+ xhr.send(null);
164
+ });
165
+ }
166
+ return fetch(url, {
167
+ credentials: "same-origin"
168
+ }).then(response => {
169
+ if (response.ok) {
170
+ return response.arrayBuffer();
171
+ }
172
+ return Promise.reject(new Error(response.status + " : " + response.url));
173
+ });
174
+ };
175
+ }
176
+ } else // end include: web_or_worker_shell_read.js
177
+ {}
178
+ var out = Module["print"] || console.log.bind(console);
179
+ var err = Module["printErr"] || console.error.bind(console);
180
+ // Merge back in the overrides
181
+ Object.assign(Module, moduleOverrides);
182
+ // Free the object hierarchy contained in the overrides, this lets the GC
183
+ // reclaim data used.
184
+ moduleOverrides = null;
185
+ // Emit code to handle expected values on the Module object. This applies Module.x
186
+ // to the proper local x. This has two benefits: first, we only emit it if it is
187
+ // expected to arrive, and second, by using a local everywhere else that can be
188
+ // minified.
189
+ if (Module["arguments"]) arguments_ = Module["arguments"];
190
+ if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
191
+ if (Module["quit"]) quit_ = Module["quit"];
192
+ // perform assertions in shell.js after we set up out() and err(), as otherwise if an assertion fails it cannot print the message
193
+ // end include: shell.js
194
+ // include: preamble.js
195
+ // === Preamble library stuff ===
196
+ // Documentation for the public APIs defined in this file must be updated in:
197
+ // site/source/docs/api_reference/preamble.js.rst
198
+ // A prebuilt local version of the documentation is available at:
199
+ // site/build/text/docs/api_reference/preamble.js.txt
200
+ // You can also build docs locally as HTML or other formats in site/
201
+ // An online HTML version (which may be of a different version of Emscripten)
202
+ // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
203
+ var dynamicLibraries = Module["dynamicLibraries"] || [];
204
+ var wasmBinary;
205
+ if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
206
+ // Wasm globals
207
+ var wasmMemory;
208
+ //========================================
209
+ // Runtime essentials
210
+ //========================================
211
+ // whether we are quitting the application. no code should run after this.
212
+ // set in exit() and abort()
213
+ var ABORT = false;
214
+ // set by exit() and abort(). Passed to 'onExit' handler.
215
+ // NOTE: This is also used as the process return code code in shell environments
216
+ // but only when noExitRuntime is false.
217
+ var EXITSTATUS;
218
+ // Memory management
219
+ var /** @type {!Int8Array} */ HEAP8, /** @type {!Uint8Array} */ HEAPU8, /** @type {!Int16Array} */ HEAP16, /** @type {!Uint16Array} */ HEAPU16, /** @type {!Int32Array} */ HEAP32, /** @type {!Uint32Array} */ HEAPU32, /** @type {!Float32Array} */ HEAPF32, /** @type {!Float64Array} */ HEAPF64;
220
+ var HEAP_DATA_VIEW;
221
+ // include: runtime_shared.js
222
+ function updateMemoryViews() {
223
+ var b = wasmMemory.buffer;
224
+ Module["HEAP_DATA_VIEW"] = HEAP_DATA_VIEW = new DataView(b);
225
+ Module["HEAP8"] = HEAP8 = new Int8Array(b);
226
+ Module["HEAP16"] = HEAP16 = new Int16Array(b);
227
+ Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
228
+ Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
229
+ Module["HEAP32"] = HEAP32 = new Int32Array(b);
230
+ Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
231
+ Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
232
+ Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
233
+ }
234
+ // end include: runtime_shared.js
235
+ // In non-standalone/normal mode, we create the memory here.
236
+ // include: runtime_init_memory.js
237
+ // Create the wasm memory. (Note: this only applies if IMPORTED_MEMORY is defined)
238
+ // check for full engine support (use string 'subarray' to avoid closure compiler confusion)
239
+ if (Module["wasmMemory"]) {
240
+ wasmMemory = Module["wasmMemory"];
241
+ } else {
242
+ var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 33554432;
243
+ wasmMemory = new WebAssembly.Memory({
244
+ "initial": INITIAL_MEMORY / 65536,
245
+ // In theory we should not need to emit the maximum if we want "unlimited"
246
+ // or 4GB of memory, but VMs error on that atm, see
247
+ // https://github.com/emscripten-core/emscripten/issues/14130
248
+ // And in the pthreads case we definitely need to emit a maximum. So
249
+ // always emit one.
250
+ "maximum": 2147483648 / 65536
251
+ });
252
+ }
253
+ updateMemoryViews();
254
+ // end include: runtime_init_memory.js
255
+ // include: runtime_stack_check.js
256
+ // end include: runtime_stack_check.js
257
+ // include: runtime_assertions.js
258
+ // end include: runtime_assertions.js
259
+ var __ATPRERUN__ = [];
260
+ // functions called before the runtime is initialized
261
+ var __ATINIT__ = [];
262
+ // functions called during startup
263
+ var __ATMAIN__ = [];
264
+ // functions called during shutdown
265
+ var __ATPOSTRUN__ = [];
266
+ // functions called after the main() is called
267
+ var __RELOC_FUNCS__ = [];
268
+ var runtimeInitialized = false;
269
+ function preRun() {
270
+ if (Module["preRun"]) {
271
+ if (typeof Module["preRun"] == "function") Module["preRun"] = [ Module["preRun"] ];
272
+ while (Module["preRun"].length) {
273
+ addOnPreRun(Module["preRun"].shift());
274
+ }
275
+ }
276
+ callRuntimeCallbacks(__ATPRERUN__);
277
+ }
278
+ function initRuntime() {
279
+ runtimeInitialized = true;
280
+ callRuntimeCallbacks(__RELOC_FUNCS__);
281
+ callRuntimeCallbacks(__ATINIT__);
282
+ }
283
+ function preMain() {
284
+ callRuntimeCallbacks(__ATMAIN__);
285
+ }
286
+ function postRun() {
287
+ if (Module["postRun"]) {
288
+ if (typeof Module["postRun"] == "function") Module["postRun"] = [ Module["postRun"] ];
289
+ while (Module["postRun"].length) {
290
+ addOnPostRun(Module["postRun"].shift());
291
+ }
292
+ }
293
+ callRuntimeCallbacks(__ATPOSTRUN__);
294
+ }
295
+ function addOnPreRun(cb) {
296
+ __ATPRERUN__.unshift(cb);
297
+ }
298
+ function addOnInit(cb) {
299
+ __ATINIT__.unshift(cb);
300
+ }
301
+ function addOnPostRun(cb) {
302
+ __ATPOSTRUN__.unshift(cb);
303
+ }
304
+ // include: runtime_math.js
305
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
306
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround
307
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
308
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc
309
+ // end include: runtime_math.js
310
+ // A counter of dependencies for calling run(). If we need to
311
+ // do asynchronous work before running, increment this and
312
+ // decrement it. Incrementing must happen in a place like
313
+ // Module.preRun (used by emcc to add file preloading).
314
+ // Note that you can add dependencies in preRun, even though
315
+ // it happens right before run - run will be postponed until
316
+ // the dependencies are met.
317
+ var runDependencies = 0;
318
+ var runDependencyWatcher = null;
319
+ var dependenciesFulfilled = null;
320
+ // overridden to take different actions when all run dependencies are fulfilled
321
+ function getUniqueRunDependency(id) {
322
+ return id;
323
+ }
324
+ function addRunDependency(id) {
325
+ runDependencies++;
326
+ Module["monitorRunDependencies"]?.(runDependencies);
327
+ }
328
+ function removeRunDependency(id) {
329
+ runDependencies--;
330
+ Module["monitorRunDependencies"]?.(runDependencies);
331
+ if (runDependencies == 0) {
332
+ if (runDependencyWatcher !== null) {
333
+ clearInterval(runDependencyWatcher);
334
+ runDependencyWatcher = null;
335
+ }
336
+ if (dependenciesFulfilled) {
337
+ var callback = dependenciesFulfilled;
338
+ dependenciesFulfilled = null;
339
+ callback();
340
+ }
341
+ }
342
+ }
343
+ /** @param {string|number=} what */ function abort(what) {
344
+ Module["onAbort"]?.(what);
345
+ what = "Aborted(" + what + ")";
346
+ // TODO(sbc): Should we remove printing and leave it up to whoever
347
+ // catches the exception?
348
+ err(what);
349
+ ABORT = true;
350
+ EXITSTATUS = 1;
351
+ what += ". Build with -sASSERTIONS for more info.";
352
+ // Use a wasm runtime error, because a JS error might be seen as a foreign
353
+ // exception, which means we'd run destructors on it. We need the error to
354
+ // simply make the program stop.
355
+ // FIXME This approach does not work in Wasm EH because it currently does not assume
356
+ // all RuntimeErrors are from traps; it decides whether a RuntimeError is from
357
+ // a trap or not based on a hidden field within the object. So at the moment
358
+ // we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that
359
+ // allows this in the wasm spec.
360
+ // Suppress closure compiler warning here. Closure compiler's builtin extern
361
+ // definition for WebAssembly.RuntimeError claims it takes no arguments even
362
+ // though it can.
363
+ // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
364
+ /** @suppress {checkTypes} */ var e = new WebAssembly.RuntimeError(what);
365
+ // Throw the error whether or not MODULARIZE is set because abort is used
366
+ // in code paths apart from instantiation where an exception is expected
367
+ // to be thrown when abort is called.
368
+ throw e;
369
+ }
370
+ // include: memoryprofiler.js
371
+ // end include: memoryprofiler.js
372
+ // include: URIUtils.js
373
+ // Prefix of data URIs emitted by SINGLE_FILE and related options.
374
+ var dataURIPrefix = "data:application/octet-stream;base64,";
375
+ /**
376
+ * Indicates whether filename is a base64 data URI.
377
+ * @noinline
378
+ */ var isDataURI = filename => filename.startsWith(dataURIPrefix);
379
+ /**
380
+ * Indicates whether filename is delivered via file protocol (as opposed to http/https)
381
+ * @noinline
382
+ */ var isFileURI = filename => filename.startsWith("file://");
383
+ // end include: URIUtils.js
384
+ // include: runtime_exceptions.js
385
+ // end include: runtime_exceptions.js
386
+ function findWasmBinary() {
387
+ var f = "tree-sitter.wasm";
388
+ if (!isDataURI(f)) {
389
+ return locateFile(f);
390
+ }
391
+ return f;
392
+ }
393
+ var wasmBinaryFile;
394
+ function getBinarySync(file) {
395
+ if (file == wasmBinaryFile && wasmBinary) {
396
+ return new Uint8Array(wasmBinary);
397
+ }
398
+ if (readBinary) {
399
+ return readBinary(file);
400
+ }
401
+ throw "both async and sync fetching of the wasm failed";
402
+ }
403
+ function getBinaryPromise(binaryFile) {
404
+ // If we don't have the binary yet, load it asynchronously using readAsync.
405
+ if (!wasmBinary) {
406
+ // Fetch the binary using readAsync
407
+ return readAsync(binaryFile).then(response => new Uint8Array(/** @type{!ArrayBuffer} */ (response)), // Fall back to getBinarySync if readAsync fails
408
+ () => getBinarySync(binaryFile));
409
+ }
410
+ // Otherwise, getBinarySync should be able to get it synchronously
411
+ return Promise.resolve().then(() => getBinarySync(binaryFile));
412
+ }
413
+ function instantiateArrayBuffer(binaryFile, imports, receiver) {
414
+ return getBinaryPromise(binaryFile).then(binary => WebAssembly.instantiate(binary, imports)).then(receiver, reason => {
415
+ err(`failed to asynchronously prepare wasm: ${reason}`);
416
+ abort(reason);
417
+ });
418
+ }
419
+ function instantiateAsync(binary, binaryFile, imports, callback) {
420
+ if (!binary && typeof WebAssembly.instantiateStreaming == "function" && !isDataURI(binaryFile) && // Don't use streaming for file:// delivered objects in a webview, fetch them synchronously.
421
+ !isFileURI(binaryFile) && // Avoid instantiateStreaming() on Node.js environment for now, as while
422
+ // Node.js v18.1.0 implements it, it does not have a full fetch()
423
+ // implementation yet.
424
+ // Reference:
425
+ // https://github.com/emscripten-core/emscripten/pull/16917
426
+ !ENVIRONMENT_IS_NODE && typeof fetch == "function") {
427
+ return fetch(binaryFile, {
428
+ credentials: "same-origin"
429
+ }).then(response => {
430
+ // Suppress closure warning here since the upstream definition for
431
+ // instantiateStreaming only allows Promise<Repsponse> rather than
432
+ // an actual Response.
433
+ // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure is fixed.
434
+ /** @suppress {checkTypes} */ var result = WebAssembly.instantiateStreaming(response, imports);
435
+ return result.then(callback, function(reason) {
436
+ // We expect the most common failure cause to be a bad MIME type for the binary,
437
+ // in which case falling back to ArrayBuffer instantiation should work.
438
+ err(`wasm streaming compile failed: ${reason}`);
439
+ err("falling back to ArrayBuffer instantiation");
440
+ return instantiateArrayBuffer(binaryFile, imports, callback);
441
+ });
442
+ });
443
+ }
444
+ return instantiateArrayBuffer(binaryFile, imports, callback);
445
+ }
446
+ function getWasmImports() {
447
+ // prepare imports
448
+ return {
449
+ "env": wasmImports,
450
+ "wasi_snapshot_preview1": wasmImports,
451
+ "GOT.mem": new Proxy(wasmImports, GOTHandler),
452
+ "GOT.func": new Proxy(wasmImports, GOTHandler)
453
+ };
454
+ }
455
+ // Create the wasm instance.
456
+ // Receives the wasm imports, returns the exports.
457
+ function createWasm() {
458
+ var info = getWasmImports();
459
+ // Load the wasm module and create an instance of using native support in the JS engine.
460
+ // handle a generated wasm instance, receiving its exports and
461
+ // performing other necessary setup
462
+ /** @param {WebAssembly.Module=} module*/ function receiveInstance(instance, module) {
463
+ wasmExports = instance.exports;
464
+ wasmExports = relocateExports(wasmExports, 1024);
465
+ var metadata = getDylinkMetadata(module);
466
+ if (metadata.neededDynlibs) {
467
+ dynamicLibraries = metadata.neededDynlibs.concat(dynamicLibraries);
468
+ }
469
+ mergeLibSymbols(wasmExports, "main");
470
+ LDSO.init();
471
+ loadDylibs();
472
+ addOnInit(wasmExports["__wasm_call_ctors"]);
473
+ __RELOC_FUNCS__.push(wasmExports["__wasm_apply_data_relocs"]);
474
+ removeRunDependency("wasm-instantiate");
475
+ return wasmExports;
476
+ }
477
+ // wait for the pthread pool (if any)
478
+ addRunDependency("wasm-instantiate");
479
+ // Prefer streaming instantiation if available.
480
+ function receiveInstantiationResult(result) {
481
+ // 'result' is a ResultObject object which has both the module and instance.
482
+ // receiveInstance() will swap in the exports (to Module.asm) so they can be called
483
+ receiveInstance(result["instance"], result["module"]);
484
+ }
485
+ // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
486
+ // to manually instantiate the Wasm module themselves. This allows pages to
487
+ // run the instantiation parallel to any other async startup actions they are
488
+ // performing.
489
+ // Also pthreads and wasm workers initialize the wasm instance through this
490
+ // path.
491
+ if (Module["instantiateWasm"]) {
492
+ try {
493
+ return Module["instantiateWasm"](info, receiveInstance);
494
+ } catch (e) {
495
+ err(`Module.instantiateWasm callback failed with error: ${e}`);
496
+ return false;
497
+ }
498
+ }
499
+ if (!wasmBinaryFile) wasmBinaryFile = findWasmBinary();
500
+ instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult);
501
+ return {};
502
+ }
503
+ // include: runtime_debug.js
504
+ // end include: runtime_debug.js
505
+ // === Body ===
506
+ var ASM_CONSTS = {};
507
+ // end include: preamble.js
508
+ /** @constructor */ function ExitStatus(status) {
509
+ this.name = "ExitStatus";
510
+ this.message = `Program terminated with exit(${status})`;
511
+ this.status = status;
512
+ }
513
+ var GOT = {};
514
+ var currentModuleWeakSymbols = new Set([]);
515
+ var GOTHandler = {
516
+ get(obj, symName) {
517
+ var rtn = GOT[symName];
518
+ if (!rtn) {
519
+ rtn = GOT[symName] = new WebAssembly.Global({
520
+ "value": "i32",
521
+ "mutable": true
522
+ });
523
+ }
524
+ if (!currentModuleWeakSymbols.has(symName)) {
525
+ // Any non-weak reference to a symbol marks it as `required`, which
526
+ // enabled `reportUndefinedSymbols` to report undefeind symbol errors
527
+ // correctly.
528
+ rtn.required = true;
529
+ }
530
+ return rtn;
531
+ }
532
+ };
533
+ var LE_HEAP_LOAD_F32 = byteOffset => HEAP_DATA_VIEW.getFloat32(byteOffset, true);
534
+ var LE_HEAP_LOAD_F64 = byteOffset => HEAP_DATA_VIEW.getFloat64(byteOffset, true);
535
+ var LE_HEAP_LOAD_I16 = byteOffset => HEAP_DATA_VIEW.getInt16(byteOffset, true);
536
+ var LE_HEAP_LOAD_I32 = byteOffset => HEAP_DATA_VIEW.getInt32(byteOffset, true);
537
+ var LE_HEAP_LOAD_U32 = byteOffset => HEAP_DATA_VIEW.getUint32(byteOffset, true);
538
+ var LE_HEAP_STORE_F32 = (byteOffset, value) => HEAP_DATA_VIEW.setFloat32(byteOffset, value, true);
539
+ var LE_HEAP_STORE_F64 = (byteOffset, value) => HEAP_DATA_VIEW.setFloat64(byteOffset, value, true);
540
+ var LE_HEAP_STORE_I16 = (byteOffset, value) => HEAP_DATA_VIEW.setInt16(byteOffset, value, true);
541
+ var LE_HEAP_STORE_I32 = (byteOffset, value) => HEAP_DATA_VIEW.setInt32(byteOffset, value, true);
542
+ var LE_HEAP_STORE_U32 = (byteOffset, value) => HEAP_DATA_VIEW.setUint32(byteOffset, value, true);
543
+ var callRuntimeCallbacks = callbacks => {
544
+ while (callbacks.length > 0) {
545
+ // Pass the module as the first argument.
546
+ callbacks.shift()(Module);
547
+ }
548
+ };
549
+ var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder : undefined;
550
+ /**
551
+ * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
552
+ * array that contains uint8 values, returns a copy of that string as a
553
+ * Javascript String object.
554
+ * heapOrArray is either a regular array, or a JavaScript typed array view.
555
+ * @param {number} idx
556
+ * @param {number=} maxBytesToRead
557
+ * @return {string}
558
+ */ var UTF8ArrayToString = (heapOrArray, idx, maxBytesToRead) => {
559
+ var endIdx = idx + maxBytesToRead;
560
+ var endPtr = idx;
561
+ // TextDecoder needs to know the byte length in advance, it doesn't stop on
562
+ // null terminator by itself. Also, use the length info to avoid running tiny
563
+ // strings through TextDecoder, since .subarray() allocates garbage.
564
+ // (As a tiny code save trick, compare endPtr against endIdx using a negation,
565
+ // so that undefined means Infinity)
566
+ while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
567
+ if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
568
+ return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
569
+ }
570
+ var str = "";
571
+ // If building with TextDecoder, we have already computed the string length
572
+ // above, so test loop end condition against that
573
+ while (idx < endPtr) {
574
+ // For UTF8 byte structure, see:
575
+ // http://en.wikipedia.org/wiki/UTF-8#Description
576
+ // https://www.ietf.org/rfc/rfc2279.txt
577
+ // https://tools.ietf.org/html/rfc3629
578
+ var u0 = heapOrArray[idx++];
579
+ if (!(u0 & 128)) {
580
+ str += String.fromCharCode(u0);
581
+ continue;
582
+ }
583
+ var u1 = heapOrArray[idx++] & 63;
584
+ if ((u0 & 224) == 192) {
585
+ str += String.fromCharCode(((u0 & 31) << 6) | u1);
586
+ continue;
587
+ }
588
+ var u2 = heapOrArray[idx++] & 63;
589
+ if ((u0 & 240) == 224) {
590
+ u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
591
+ } else {
592
+ u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
593
+ }
594
+ if (u0 < 65536) {
595
+ str += String.fromCharCode(u0);
596
+ } else {
597
+ var ch = u0 - 65536;
598
+ str += String.fromCharCode(55296 | (ch >> 10), 56320 | (ch & 1023));
599
+ }
600
+ }
601
+ return str;
602
+ };
603
+ var getDylinkMetadata = binary => {
604
+ var offset = 0;
605
+ var end = 0;
606
+ function getU8() {
607
+ return binary[offset++];
608
+ }
609
+ function getLEB() {
610
+ var ret = 0;
611
+ var mul = 1;
612
+ while (1) {
613
+ var byte = binary[offset++];
614
+ ret += ((byte & 127) * mul);
615
+ mul *= 128;
616
+ if (!(byte & 128)) break;
617
+ }
618
+ return ret;
619
+ }
620
+ function getString() {
621
+ var len = getLEB();
622
+ offset += len;
623
+ return UTF8ArrayToString(binary, offset - len, len);
624
+ }
625
+ /** @param {string=} message */ function failIf(condition, message) {
626
+ if (condition) throw new Error(message);
627
+ }
628
+ var name = "dylink.0";
629
+ if (binary instanceof WebAssembly.Module) {
630
+ var dylinkSection = WebAssembly.Module.customSections(binary, name);
631
+ if (dylinkSection.length === 0) {
632
+ name = "dylink";
633
+ dylinkSection = WebAssembly.Module.customSections(binary, name);
634
+ }
635
+ failIf(dylinkSection.length === 0, "need dylink section");
636
+ binary = new Uint8Array(dylinkSection[0]);
637
+ end = binary.length;
638
+ } else {
639
+ var int32View = new Uint32Array(new Uint8Array(binary.subarray(0, 24)).buffer);
640
+ var magicNumberFound = int32View[0] == 1836278016 || int32View[0] == 6386541;
641
+ failIf(!magicNumberFound, "need to see wasm magic number");
642
+ // \0asm
643
+ // we should see the dylink custom section right after the magic number and wasm version
644
+ failIf(binary[8] !== 0, "need the dylink section to be first");
645
+ offset = 9;
646
+ var section_size = getLEB();
647
+ //section size
648
+ end = offset + section_size;
649
+ name = getString();
650
+ }
651
+ var customSection = {
652
+ neededDynlibs: [],
653
+ tlsExports: new Set,
654
+ weakImports: new Set
655
+ };
656
+ if (name == "dylink") {
657
+ customSection.memorySize = getLEB();
658
+ customSection.memoryAlign = getLEB();
659
+ customSection.tableSize = getLEB();
660
+ customSection.tableAlign = getLEB();
661
+ // shared libraries this module needs. We need to load them first, so that
662
+ // current module could resolve its imports. (see tools/shared.py
663
+ // WebAssembly.make_shared_library() for "dylink" section extension format)
664
+ var neededDynlibsCount = getLEB();
665
+ for (var i = 0; i < neededDynlibsCount; ++i) {
666
+ var libname = getString();
667
+ customSection.neededDynlibs.push(libname);
668
+ }
669
+ } else {
670
+ failIf(name !== "dylink.0");
671
+ var WASM_DYLINK_MEM_INFO = 1;
672
+ var WASM_DYLINK_NEEDED = 2;
673
+ var WASM_DYLINK_EXPORT_INFO = 3;
674
+ var WASM_DYLINK_IMPORT_INFO = 4;
675
+ var WASM_SYMBOL_TLS = 256;
676
+ var WASM_SYMBOL_BINDING_MASK = 3;
677
+ var WASM_SYMBOL_BINDING_WEAK = 1;
678
+ while (offset < end) {
679
+ var subsectionType = getU8();
680
+ var subsectionSize = getLEB();
681
+ if (subsectionType === WASM_DYLINK_MEM_INFO) {
682
+ customSection.memorySize = getLEB();
683
+ customSection.memoryAlign = getLEB();
684
+ customSection.tableSize = getLEB();
685
+ customSection.tableAlign = getLEB();
686
+ } else if (subsectionType === WASM_DYLINK_NEEDED) {
687
+ var neededDynlibsCount = getLEB();
688
+ for (var i = 0; i < neededDynlibsCount; ++i) {
689
+ libname = getString();
690
+ customSection.neededDynlibs.push(libname);
691
+ }
692
+ } else if (subsectionType === WASM_DYLINK_EXPORT_INFO) {
693
+ var count = getLEB();
694
+ while (count--) {
695
+ var symname = getString();
696
+ var flags = getLEB();
697
+ if (flags & WASM_SYMBOL_TLS) {
698
+ customSection.tlsExports.add(symname);
699
+ }
700
+ }
701
+ } else if (subsectionType === WASM_DYLINK_IMPORT_INFO) {
702
+ var count = getLEB();
703
+ while (count--) {
704
+ var modname = getString();
705
+ var symname = getString();
706
+ var flags = getLEB();
707
+ if ((flags & WASM_SYMBOL_BINDING_MASK) == WASM_SYMBOL_BINDING_WEAK) {
708
+ customSection.weakImports.add(symname);
709
+ }
710
+ }
711
+ } else {
712
+ // unknown subsection
713
+ offset += subsectionSize;
714
+ }
715
+ }
716
+ }
717
+ return customSection;
718
+ };
719
+ /**
720
+ * @param {number} ptr
721
+ * @param {string} type
722
+ */ function getValue(ptr, type = "i8") {
723
+ if (type.endsWith("*")) type = "*";
724
+ switch (type) {
725
+ case "i1":
726
+ return HEAP8[ptr];
727
+
728
+ case "i8":
729
+ return HEAP8[ptr];
730
+
731
+ case "i16":
732
+ return LE_HEAP_LOAD_I16(((ptr) >> 1) * 2);
733
+
734
+ case "i32":
735
+ return LE_HEAP_LOAD_I32(((ptr) >> 2) * 4);
736
+
737
+ case "i64":
738
+ abort("to do getValue(i64) use WASM_BIGINT");
739
+
740
+ case "float":
741
+ return LE_HEAP_LOAD_F32(((ptr) >> 2) * 4);
742
+
743
+ case "double":
744
+ return LE_HEAP_LOAD_F64(((ptr) >> 3) * 8);
745
+
746
+ case "*":
747
+ return LE_HEAP_LOAD_U32(((ptr) >> 2) * 4);
748
+
749
+ default:
750
+ abort(`invalid type for getValue: ${type}`);
751
+ }
752
+ }
753
+ var newDSO = (name, handle, syms) => {
754
+ var dso = {
755
+ refcount: Infinity,
756
+ name: name,
757
+ exports: syms,
758
+ global: true
759
+ };
760
+ LDSO.loadedLibsByName[name] = dso;
761
+ if (handle != undefined) {
762
+ LDSO.loadedLibsByHandle[handle] = dso;
763
+ }
764
+ return dso;
765
+ };
766
+ var LDSO = {
767
+ loadedLibsByName: {},
768
+ loadedLibsByHandle: {},
769
+ init() {
770
+ newDSO("__main__", 0, wasmImports);
771
+ }
772
+ };
773
+ var ___heap_base = 78112;
774
+ var zeroMemory = (address, size) => {
775
+ HEAPU8.fill(0, address, address + size);
776
+ return address;
777
+ };
778
+ var alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment;
779
+ var getMemory = size => {
780
+ // After the runtime is initialized, we must only use sbrk() normally.
781
+ if (runtimeInitialized) {
782
+ // Currently we don't support freeing of static data when modules are
783
+ // unloaded via dlclose. This function is tagged as `noleakcheck` to
784
+ // avoid having this reported as leak.
785
+ return zeroMemory(_malloc(size), size);
786
+ }
787
+ var ret = ___heap_base;
788
+ // Keep __heap_base stack aligned.
789
+ var end = ret + alignMemory(size, 16);
790
+ ___heap_base = end;
791
+ GOT["__heap_base"].value = end;
792
+ return ret;
793
+ };
794
+ var isInternalSym = 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__");
795
+ var uleb128Encode = (n, target) => {
796
+ if (n < 128) {
797
+ target.push(n);
798
+ } else {
799
+ target.push((n % 128) | 128, n >> 7);
800
+ }
801
+ };
802
+ var sigToWasmTypes = sig => {
803
+ var typeNames = {
804
+ "i": "i32",
805
+ "j": "i64",
806
+ "f": "f32",
807
+ "d": "f64",
808
+ "e": "externref",
809
+ "p": "i32"
810
+ };
811
+ var type = {
812
+ parameters: [],
813
+ results: sig[0] == "v" ? [] : [ typeNames[sig[0]] ]
814
+ };
815
+ for (var i = 1; i < sig.length; ++i) {
816
+ type.parameters.push(typeNames[sig[i]]);
817
+ }
818
+ return type;
819
+ };
820
+ var generateFuncType = (sig, target) => {
821
+ var sigRet = sig.slice(0, 1);
822
+ var sigParam = sig.slice(1);
823
+ var typeCodes = {
824
+ "i": 127,
825
+ // i32
826
+ "p": 127,
827
+ // i32
828
+ "j": 126,
829
+ // i64
830
+ "f": 125,
831
+ // f32
832
+ "d": 124,
833
+ // f64
834
+ "e": 111
835
+ };
836
+ // Parameters, length + signatures
837
+ target.push(96);
838
+ /* form: func */ uleb128Encode(sigParam.length, target);
839
+ for (var i = 0; i < sigParam.length; ++i) {
840
+ target.push(typeCodes[sigParam[i]]);
841
+ }
842
+ // Return values, length + signatures
843
+ // With no multi-return in MVP, either 0 (void) or 1 (anything else)
844
+ if (sigRet == "v") {
845
+ target.push(0);
846
+ } else {
847
+ target.push(1, typeCodes[sigRet]);
848
+ }
849
+ };
850
+ var convertJsFunctionToWasm = (func, sig) => {
851
+ // If the type reflection proposal is available, use the new
852
+ // "WebAssembly.Function" constructor.
853
+ // Otherwise, construct a minimal wasm module importing the JS function and
854
+ // re-exporting it.
855
+ if (typeof WebAssembly.Function == "function") {
856
+ return new WebAssembly.Function(sigToWasmTypes(sig), func);
857
+ }
858
+ // The module is static, with the exception of the type section, which is
859
+ // generated based on the signature passed in.
860
+ var typeSectionBody = [ 1 ];
861
+ // count: 1
862
+ generateFuncType(sig, typeSectionBody);
863
+ // Rest of the module is static
864
+ var bytes = [ 0, 97, 115, 109, // magic ("\0asm")
865
+ 1, 0, 0, 0, // version: 1
866
+ 1 ];
867
+ // Write the overall length of the type section followed by the body
868
+ uleb128Encode(typeSectionBody.length, bytes);
869
+ bytes.push(...typeSectionBody);
870
+ // The rest of the module is static
871
+ bytes.push(2, 7, // import section
872
+ // (import "e" "f" (func 0 (type 0)))
873
+ 1, 1, 101, 1, 102, 0, 0, 7, 5, // export section
874
+ // (export "f" (func 0 (type 0)))
875
+ 1, 1, 102, 0, 0);
876
+ // We can compile this wasm module synchronously because it is very small.
877
+ // This accepts an import (at "e.f"), that it reroutes to an export (at "f")
878
+ var module = new WebAssembly.Module(new Uint8Array(bytes));
879
+ var instance = new WebAssembly.Instance(module, {
880
+ "e": {
881
+ "f": func
882
+ }
883
+ });
884
+ var wrappedFunc = instance.exports["f"];
885
+ return wrappedFunc;
886
+ };
887
+ var wasmTableMirror = [];
888
+ /** @type {WebAssembly.Table} */ var wasmTable = new WebAssembly.Table({
889
+ "initial": 28,
890
+ "element": "anyfunc"
891
+ });
892
+ var getWasmTableEntry = funcPtr => {
893
+ var func = wasmTableMirror[funcPtr];
894
+ if (!func) {
895
+ if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1;
896
+ wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
897
+ }
898
+ return func;
899
+ };
900
+ var updateTableMap = (offset, count) => {
901
+ if (functionsInTableMap) {
902
+ for (var i = offset; i < offset + count; i++) {
903
+ var item = getWasmTableEntry(i);
904
+ // Ignore null values.
905
+ if (item) {
906
+ functionsInTableMap.set(item, i);
907
+ }
908
+ }
909
+ }
910
+ };
911
+ var functionsInTableMap;
912
+ var getFunctionAddress = func => {
913
+ // First, create the map if this is the first use.
914
+ if (!functionsInTableMap) {
915
+ functionsInTableMap = new WeakMap;
916
+ updateTableMap(0, wasmTable.length);
917
+ }
918
+ return functionsInTableMap.get(func) || 0;
919
+ };
920
+ var freeTableIndexes = [];
921
+ var getEmptyTableSlot = () => {
922
+ // Reuse a free index if there is one, otherwise grow.
923
+ if (freeTableIndexes.length) {
924
+ return freeTableIndexes.pop();
925
+ }
926
+ // Grow the table
927
+ try {
928
+ wasmTable.grow(1);
929
+ } catch (err) {
930
+ if (!(err instanceof RangeError)) {
931
+ throw err;
932
+ }
933
+ throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";
934
+ }
935
+ return wasmTable.length - 1;
936
+ };
937
+ var setWasmTableEntry = (idx, func) => {
938
+ wasmTable.set(idx, func);
939
+ // With ABORT_ON_WASM_EXCEPTIONS wasmTable.get is overridden to return wrapped
940
+ // functions so we need to call it here to retrieve the potential wrapper correctly
941
+ // instead of just storing 'func' directly into wasmTableMirror
942
+ wasmTableMirror[idx] = wasmTable.get(idx);
943
+ };
944
+ /** @param {string=} sig */ var addFunction = (func, sig) => {
945
+ // Check if the function is already in the table, to ensure each function
946
+ // gets a unique index.
947
+ var rtn = getFunctionAddress(func);
948
+ if (rtn) {
949
+ return rtn;
950
+ }
951
+ // It's not in the table, add it now.
952
+ var ret = getEmptyTableSlot();
953
+ // Set the new value.
954
+ try {
955
+ // Attempting to call this with JS function will cause of table.set() to fail
956
+ setWasmTableEntry(ret, func);
957
+ } catch (err) {
958
+ if (!(err instanceof TypeError)) {
959
+ throw err;
960
+ }
961
+ var wrapped = convertJsFunctionToWasm(func, sig);
962
+ setWasmTableEntry(ret, wrapped);
963
+ }
964
+ functionsInTableMap.set(func, ret);
965
+ return ret;
966
+ };
967
+ var updateGOT = (exports, replace) => {
968
+ for (var symName in exports) {
969
+ if (isInternalSym(symName)) {
970
+ continue;
971
+ }
972
+ var value = exports[symName];
973
+ if (symName.startsWith("orig$")) {
974
+ symName = symName.split("$")[1];
975
+ replace = true;
976
+ }
977
+ GOT[symName] ||= new WebAssembly.Global({
978
+ "value": "i32",
979
+ "mutable": true
980
+ });
981
+ if (replace || GOT[symName].value == 0) {
982
+ if (typeof value == "function") {
983
+ GOT[symName].value = addFunction(value);
984
+ } else if (typeof value == "number") {
985
+ GOT[symName].value = value;
986
+ } else {
987
+ err(`unhandled export type for '${symName}': ${typeof value}`);
988
+ }
989
+ }
990
+ }
991
+ };
992
+ /** @param {boolean=} replace */ var relocateExports = (exports, memoryBase, replace) => {
993
+ var relocated = {};
994
+ for (var e in exports) {
995
+ var value = exports[e];
996
+ if (typeof value == "object") {
997
+ // a breaking change in the wasm spec, globals are now objects
998
+ // https://github.com/WebAssembly/mutable-global/issues/1
999
+ value = value.value;
1000
+ }
1001
+ if (typeof value == "number") {
1002
+ value += memoryBase;
1003
+ }
1004
+ relocated[e] = value;
1005
+ }
1006
+ updateGOT(relocated, replace);
1007
+ return relocated;
1008
+ };
1009
+ var isSymbolDefined = symName => {
1010
+ // Ignore 'stub' symbols that are auto-generated as part of the original
1011
+ // `wasmImports` used to instantiate the main module.
1012
+ var existing = wasmImports[symName];
1013
+ if (!existing || existing.stub) {
1014
+ return false;
1015
+ }
1016
+ return true;
1017
+ };
1018
+ var dynCallLegacy = (sig, ptr, args) => {
1019
+ sig = sig.replace(/p/g, "i");
1020
+ var f = Module["dynCall_" + sig];
1021
+ return f(ptr, ...args);
1022
+ };
1023
+ var dynCall = (sig, ptr, args = []) => {
1024
+ // Without WASM_BIGINT support we cannot directly call function with i64 as
1025
+ // part of their signature, so we rely on the dynCall functions generated by
1026
+ // wasm-emscripten-finalize
1027
+ if (sig.includes("j")) {
1028
+ return dynCallLegacy(sig, ptr, args);
1029
+ }
1030
+ var rtn = getWasmTableEntry(ptr)(...args);
1031
+ return rtn;
1032
+ };
1033
+ var stackSave = () => _emscripten_stack_get_current();
1034
+ var stackRestore = val => __emscripten_stack_restore(val);
1035
+ var createInvokeFunction = sig => (ptr, ...args) => {
1036
+ var sp = stackSave();
1037
+ try {
1038
+ return dynCall(sig, ptr, args);
1039
+ } catch (e) {
1040
+ stackRestore(sp);
1041
+ // Create a try-catch guard that rethrows the Emscripten EH exception.
1042
+ // Exceptions thrown from C++ will be a pointer (number) and longjmp
1043
+ // will throw the number Infinity. Use the compact and fast "e !== e+0"
1044
+ // test to check if e was not a Number.
1045
+ if (e !== e + 0) throw e;
1046
+ _setThrew(1, 0);
1047
+ }
1048
+ };
1049
+ var resolveGlobalSymbol = (symName, direct = false) => {
1050
+ var sym;
1051
+ // First look for the orig$ symbol which is the symbol without i64
1052
+ // legalization performed.
1053
+ if (direct && ("orig$" + symName in wasmImports)) {
1054
+ symName = "orig$" + symName;
1055
+ }
1056
+ if (isSymbolDefined(symName)) {
1057
+ sym = wasmImports[symName];
1058
+ } else // Asm.js-style exception handling: invoke wrapper generation
1059
+ if (symName.startsWith("invoke_")) {
1060
+ // Create (and cache) new invoke_ functions on demand.
1061
+ sym = wasmImports[symName] = createInvokeFunction(symName.split("_")[1]);
1062
+ }
1063
+ return {
1064
+ sym: sym,
1065
+ name: symName
1066
+ };
1067
+ };
1068
+ /**
1069
+ * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
1070
+ * emscripten HEAP, returns a copy of that string as a Javascript String object.
1071
+ *
1072
+ * @param {number} ptr
1073
+ * @param {number=} maxBytesToRead - An optional length that specifies the
1074
+ * maximum number of bytes to read. You can omit this parameter to scan the
1075
+ * string until the first 0 byte. If maxBytesToRead is passed, and the string
1076
+ * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
1077
+ * string will cut short at that byte index (i.e. maxBytesToRead will not
1078
+ * produce a string of exact length [ptr, ptr+maxBytesToRead[) N.B. mixing
1079
+ * frequent uses of UTF8ToString() with and without maxBytesToRead may throw
1080
+ * JS JIT optimizations off, so it is worth to consider consistently using one
1081
+ * @return {string}
1082
+ */ var UTF8ToString = (ptr, maxBytesToRead) => ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "";
1083
+ /**
1084
+ * @param {string=} libName
1085
+ * @param {Object=} localScope
1086
+ * @param {number=} handle
1087
+ */ var loadWebAssemblyModule = (binary, flags, libName, localScope, handle) => {
1088
+ var metadata = getDylinkMetadata(binary);
1089
+ currentModuleWeakSymbols = metadata.weakImports;
1090
+ // loadModule loads the wasm module after all its dependencies have been loaded.
1091
+ // can be called both sync/async.
1092
+ function loadModule() {
1093
+ // The first thread to load a given module needs to allocate the static
1094
+ // table and memory regions. Later threads re-use the same table region
1095
+ // and can ignore the memory region (since memory is shared between
1096
+ // threads already).
1097
+ // If `handle` is specified than it is assumed that the calling thread has
1098
+ // exclusive access to it for the duration of this function. See the
1099
+ // locking in `dynlink.c`.
1100
+ var firstLoad = !handle || !HEAP8[(handle) + (8)];
1101
+ if (firstLoad) {
1102
+ // alignments are powers of 2
1103
+ var memAlign = Math.pow(2, metadata.memoryAlign);
1104
+ // prepare memory
1105
+ var memoryBase = metadata.memorySize ? alignMemory(getMemory(metadata.memorySize + memAlign), memAlign) : 0;
1106
+ // TODO: add to cleanups
1107
+ var tableBase = metadata.tableSize ? wasmTable.length : 0;
1108
+ if (handle) {
1109
+ HEAP8[(handle) + (8)] = 1;
1110
+ LE_HEAP_STORE_U32((((handle) + (12)) >> 2) * 4, memoryBase);
1111
+ LE_HEAP_STORE_I32((((handle) + (16)) >> 2) * 4, metadata.memorySize);
1112
+ LE_HEAP_STORE_U32((((handle) + (20)) >> 2) * 4, tableBase);
1113
+ LE_HEAP_STORE_I32((((handle) + (24)) >> 2) * 4, metadata.tableSize);
1114
+ }
1115
+ } else {
1116
+ memoryBase = LE_HEAP_LOAD_U32((((handle) + (12)) >> 2) * 4);
1117
+ tableBase = LE_HEAP_LOAD_U32((((handle) + (20)) >> 2) * 4);
1118
+ }
1119
+ var tableGrowthNeeded = tableBase + metadata.tableSize - wasmTable.length;
1120
+ if (tableGrowthNeeded > 0) {
1121
+ wasmTable.grow(tableGrowthNeeded);
1122
+ }
1123
+ // This is the export map that we ultimately return. We declare it here
1124
+ // so it can be used within resolveSymbol. We resolve symbols against
1125
+ // this local symbol map in the case there they are not present on the
1126
+ // global Module object. We need this fallback because Modules sometime
1127
+ // need to import their own symbols
1128
+ var moduleExports;
1129
+ function resolveSymbol(sym) {
1130
+ var resolved = resolveGlobalSymbol(sym).sym;
1131
+ if (!resolved && localScope) {
1132
+ resolved = localScope[sym];
1133
+ }
1134
+ if (!resolved) {
1135
+ resolved = moduleExports[sym];
1136
+ }
1137
+ return resolved;
1138
+ }
1139
+ // TODO kill ↓↓↓ (except "symbols local to this module", it will likely be
1140
+ // not needed if we require that if A wants symbols from B it has to link
1141
+ // to B explicitly: similarly to -Wl,--no-undefined)
1142
+ // wasm dynamic libraries are pure wasm, so they cannot assist in
1143
+ // their own loading. When side module A wants to import something
1144
+ // provided by a side module B that is loaded later, we need to
1145
+ // add a layer of indirection, but worse, we can't even tell what
1146
+ // to add the indirection for, without inspecting what A's imports
1147
+ // are. To do that here, we use a JS proxy (another option would
1148
+ // be to inspect the binary directly).
1149
+ var proxyHandler = {
1150
+ get(stubs, prop) {
1151
+ // symbols that should be local to this module
1152
+ switch (prop) {
1153
+ case "__memory_base":
1154
+ return memoryBase;
1155
+
1156
+ case "__table_base":
1157
+ return tableBase;
1158
+ }
1159
+ if (prop in wasmImports && !wasmImports[prop].stub) {
1160
+ // No stub needed, symbol already exists in symbol table
1161
+ return wasmImports[prop];
1162
+ }
1163
+ // Return a stub function that will resolve the symbol
1164
+ // when first called.
1165
+ if (!(prop in stubs)) {
1166
+ var resolved;
1167
+ stubs[prop] = (...args) => {
1168
+ resolved ||= resolveSymbol(prop);
1169
+ return resolved(...args);
1170
+ };
1171
+ }
1172
+ return stubs[prop];
1173
+ }
1174
+ };
1175
+ var proxy = new Proxy({}, proxyHandler);
1176
+ var info = {
1177
+ "GOT.mem": new Proxy({}, GOTHandler),
1178
+ "GOT.func": new Proxy({}, GOTHandler),
1179
+ "env": proxy,
1180
+ "wasi_snapshot_preview1": proxy
1181
+ };
1182
+ function postInstantiation(module, instance) {
1183
+ // add new entries to functionsInTableMap
1184
+ updateTableMap(tableBase, metadata.tableSize);
1185
+ moduleExports = relocateExports(instance.exports, memoryBase);
1186
+ if (!flags.allowUndefined) {
1187
+ reportUndefinedSymbols();
1188
+ }
1189
+ function addEmAsm(addr, body) {
1190
+ var args = [];
1191
+ var arity = 0;
1192
+ for (;arity < 16; arity++) {
1193
+ if (body.indexOf("$" + arity) != -1) {
1194
+ args.push("$" + arity);
1195
+ } else {
1196
+ break;
1197
+ }
1198
+ }
1199
+ args = args.join(",");
1200
+ var func = `(${args}) => { ${body} };`;
1201
+ ASM_CONSTS[start] = eval(func);
1202
+ }
1203
+ // Add any EM_ASM function that exist in the side module
1204
+ if ("__start_em_asm" in moduleExports) {
1205
+ var start = moduleExports["__start_em_asm"];
1206
+ var stop = moduleExports["__stop_em_asm"];
1207
+ while (start < stop) {
1208
+ var jsString = UTF8ToString(start);
1209
+ addEmAsm(start, jsString);
1210
+ start = HEAPU8.indexOf(0, start) + 1;
1211
+ }
1212
+ }
1213
+ function addEmJs(name, cSig, body) {
1214
+ // The signature here is a C signature (e.g. "(int foo, char* bar)").
1215
+ // See `create_em_js` in emcc.py` for the build-time version of this
1216
+ // code.
1217
+ var jsArgs = [];
1218
+ cSig = cSig.slice(1, -1);
1219
+ if (cSig != "void") {
1220
+ cSig = cSig.split(",");
1221
+ for (var i in cSig) {
1222
+ var jsArg = cSig[i].split(" ").pop();
1223
+ jsArgs.push(jsArg.replace("*", ""));
1224
+ }
1225
+ }
1226
+ var func = `(${jsArgs}) => ${body};`;
1227
+ moduleExports[name] = eval(func);
1228
+ }
1229
+ for (var name in moduleExports) {
1230
+ if (name.startsWith("__em_js__")) {
1231
+ var start = moduleExports[name];
1232
+ var jsString = UTF8ToString(start);
1233
+ // EM_JS strings are stored in the data section in the form
1234
+ // SIG<::>BODY.
1235
+ var parts = jsString.split("<::>");
1236
+ addEmJs(name.replace("__em_js__", ""), parts[0], parts[1]);
1237
+ delete moduleExports[name];
1238
+ }
1239
+ }
1240
+ // initialize the module
1241
+ var applyRelocs = moduleExports["__wasm_apply_data_relocs"];
1242
+ if (applyRelocs) {
1243
+ if (runtimeInitialized) {
1244
+ applyRelocs();
1245
+ } else {
1246
+ __RELOC_FUNCS__.push(applyRelocs);
1247
+ }
1248
+ }
1249
+ var init = moduleExports["__wasm_call_ctors"];
1250
+ if (init) {
1251
+ if (runtimeInitialized) {
1252
+ init();
1253
+ } else {
1254
+ // we aren't ready to run compiled code yet
1255
+ __ATINIT__.push(init);
1256
+ }
1257
+ }
1258
+ return moduleExports;
1259
+ }
1260
+ if (flags.loadAsync) {
1261
+ if (binary instanceof WebAssembly.Module) {
1262
+ var instance = new WebAssembly.Instance(binary, info);
1263
+ return Promise.resolve(postInstantiation(binary, instance));
1264
+ }
1265
+ return WebAssembly.instantiate(binary, info).then(result => postInstantiation(result.module, result.instance));
1266
+ }
1267
+ var module = binary instanceof WebAssembly.Module ? binary : new WebAssembly.Module(binary);
1268
+ var instance = new WebAssembly.Instance(module, info);
1269
+ return postInstantiation(module, instance);
1270
+ }
1271
+ // now load needed libraries and the module itself.
1272
+ if (flags.loadAsync) {
1273
+ return metadata.neededDynlibs.reduce((chain, dynNeeded) => chain.then(() => loadDynamicLibrary(dynNeeded, flags, localScope)), Promise.resolve()).then(loadModule);
1274
+ }
1275
+ metadata.neededDynlibs.forEach(needed => loadDynamicLibrary(needed, flags, localScope));
1276
+ return loadModule();
1277
+ };
1278
+ var mergeLibSymbols = (exports, libName) => {
1279
+ // add symbols into global namespace TODO: weak linking etc.
1280
+ for (var [sym, exp] of Object.entries(exports)) {
1281
+ // When RTLD_GLOBAL is enabled, the symbols defined by this shared object
1282
+ // will be made available for symbol resolution of subsequently loaded
1283
+ // shared objects.
1284
+ // We should copy the symbols (which include methods and variables) from
1285
+ // SIDE_MODULE to MAIN_MODULE.
1286
+ const setImport = target => {
1287
+ if (!isSymbolDefined(target)) {
1288
+ wasmImports[target] = exp;
1289
+ }
1290
+ };
1291
+ setImport(sym);
1292
+ // Special case for handling of main symbol: If a side module exports
1293
+ // `main` that also acts a definition for `__main_argc_argv` and vice
1294
+ // versa.
1295
+ const main_alias = "__main_argc_argv";
1296
+ if (sym == "main") {
1297
+ setImport(main_alias);
1298
+ }
1299
+ if (sym == main_alias) {
1300
+ setImport("main");
1301
+ }
1302
+ if (sym.startsWith("dynCall_") && !Module.hasOwnProperty(sym)) {
1303
+ Module[sym] = exp;
1304
+ }
1305
+ }
1306
+ };
1307
+ /** @param {boolean=} noRunDep */ var asyncLoad = (url, onload, onerror, noRunDep) => {
1308
+ var dep = !noRunDep ? getUniqueRunDependency(`al ${url}`) : "";
1309
+ readAsync(url).then(arrayBuffer => {
1310
+ onload(new Uint8Array(arrayBuffer));
1311
+ if (dep) removeRunDependency(dep);
1312
+ }, err => {
1313
+ if (onerror) {
1314
+ onerror();
1315
+ } else {
1316
+ throw `Loading data file "${url}" failed.`;
1317
+ }
1318
+ });
1319
+ if (dep) addRunDependency(dep);
1320
+ };
1321
+ /**
1322
+ * @param {number=} handle
1323
+ * @param {Object=} localScope
1324
+ */ function loadDynamicLibrary(libName, flags = {
1325
+ global: true,
1326
+ nodelete: true
1327
+ }, localScope, handle) {
1328
+ // when loadDynamicLibrary did not have flags, libraries were loaded
1329
+ // globally & permanently
1330
+ var dso = LDSO.loadedLibsByName[libName];
1331
+ if (dso) {
1332
+ // the library is being loaded or has been loaded already.
1333
+ if (!flags.global) {
1334
+ if (localScope) {
1335
+ Object.assign(localScope, dso.exports);
1336
+ }
1337
+ } else if (!dso.global) {
1338
+ // The library was previously loaded only locally but not
1339
+ // we have a request with global=true.
1340
+ dso.global = true;
1341
+ mergeLibSymbols(dso.exports, libName);
1342
+ }
1343
+ // same for "nodelete"
1344
+ if (flags.nodelete && dso.refcount !== Infinity) {
1345
+ dso.refcount = Infinity;
1346
+ }
1347
+ dso.refcount++;
1348
+ if (handle) {
1349
+ LDSO.loadedLibsByHandle[handle] = dso;
1350
+ }
1351
+ return flags.loadAsync ? Promise.resolve(true) : true;
1352
+ }
1353
+ // allocate new DSO
1354
+ dso = newDSO(libName, handle, "loading");
1355
+ dso.refcount = flags.nodelete ? Infinity : 1;
1356
+ dso.global = flags.global;
1357
+ // libName -> libData
1358
+ function loadLibData() {
1359
+ // for wasm, we can use fetch for async, but for fs mode we can only imitate it
1360
+ if (handle) {
1361
+ var data = LE_HEAP_LOAD_U32((((handle) + (28)) >> 2) * 4);
1362
+ var dataSize = LE_HEAP_LOAD_U32((((handle) + (32)) >> 2) * 4);
1363
+ if (data && dataSize) {
1364
+ var libData = HEAP8.slice(data, data + dataSize);
1365
+ return flags.loadAsync ? Promise.resolve(libData) : libData;
1366
+ }
1367
+ }
1368
+ var libFile = locateFile(libName);
1369
+ if (flags.loadAsync) {
1370
+ return new Promise(function(resolve, reject) {
1371
+ asyncLoad(libFile, resolve, reject);
1372
+ });
1373
+ }
1374
+ // load the binary synchronously
1375
+ if (!readBinary) {
1376
+ throw new Error(`${libFile}: file not found, and synchronous loading of external files is not available`);
1377
+ }
1378
+ return readBinary(libFile);
1379
+ }
1380
+ // libName -> exports
1381
+ function getExports() {
1382
+ // module not preloaded - load lib data and create new module from it
1383
+ if (flags.loadAsync) {
1384
+ return loadLibData().then(libData => loadWebAssemblyModule(libData, flags, libName, localScope, handle));
1385
+ }
1386
+ return loadWebAssemblyModule(loadLibData(), flags, libName, localScope, handle);
1387
+ }
1388
+ // module for lib is loaded - update the dso & global namespace
1389
+ function moduleLoaded(exports) {
1390
+ if (dso.global) {
1391
+ mergeLibSymbols(exports, libName);
1392
+ } else if (localScope) {
1393
+ Object.assign(localScope, exports);
1394
+ }
1395
+ dso.exports = exports;
1396
+ }
1397
+ if (flags.loadAsync) {
1398
+ return getExports().then(exports => {
1399
+ moduleLoaded(exports);
1400
+ return true;
1401
+ });
1402
+ }
1403
+ moduleLoaded(getExports());
1404
+ return true;
1405
+ }
1406
+ var reportUndefinedSymbols = () => {
1407
+ for (var [symName, entry] of Object.entries(GOT)) {
1408
+ if (entry.value == 0) {
1409
+ var value = resolveGlobalSymbol(symName, true).sym;
1410
+ if (!value && !entry.required) {
1411
+ // Ignore undefined symbols that are imported as weak.
1412
+ continue;
1413
+ }
1414
+ if (typeof value == "function") {
1415
+ /** @suppress {checkTypes} */ entry.value = addFunction(value, value.sig);
1416
+ } else if (typeof value == "number") {
1417
+ entry.value = value;
1418
+ } else {
1419
+ throw new Error(`bad export type for '${symName}': ${typeof value}`);
1420
+ }
1421
+ }
1422
+ }
1423
+ };
1424
+ var loadDylibs = () => {
1425
+ if (!dynamicLibraries.length) {
1426
+ reportUndefinedSymbols();
1427
+ return;
1428
+ }
1429
+ // Load binaries asynchronously
1430
+ addRunDependency("loadDylibs");
1431
+ dynamicLibraries.reduce((chain, lib) => chain.then(() => loadDynamicLibrary(lib, {
1432
+ loadAsync: true,
1433
+ global: true,
1434
+ nodelete: true,
1435
+ allowUndefined: true
1436
+ })), Promise.resolve()).then(() => {
1437
+ // we got them all, wonderful
1438
+ reportUndefinedSymbols();
1439
+ removeRunDependency("loadDylibs");
1440
+ });
1441
+ };
1442
+ var noExitRuntime = Module["noExitRuntime"] || true;
1443
+ /**
1444
+ * @param {number} ptr
1445
+ * @param {number} value
1446
+ * @param {string} type
1447
+ */ function setValue(ptr, value, type = "i8") {
1448
+ if (type.endsWith("*")) type = "*";
1449
+ switch (type) {
1450
+ case "i1":
1451
+ HEAP8[ptr] = value;
1452
+ break;
1453
+
1454
+ case "i8":
1455
+ HEAP8[ptr] = value;
1456
+ break;
1457
+
1458
+ case "i16":
1459
+ LE_HEAP_STORE_I16(((ptr) >> 1) * 2, value);
1460
+ break;
1461
+
1462
+ case "i32":
1463
+ LE_HEAP_STORE_I32(((ptr) >> 2) * 4, value);
1464
+ break;
1465
+
1466
+ case "i64":
1467
+ abort("to do setValue(i64) use WASM_BIGINT");
1468
+
1469
+ case "float":
1470
+ LE_HEAP_STORE_F32(((ptr) >> 2) * 4, value);
1471
+ break;
1472
+
1473
+ case "double":
1474
+ LE_HEAP_STORE_F64(((ptr) >> 3) * 8, value);
1475
+ break;
1476
+
1477
+ case "*":
1478
+ LE_HEAP_STORE_U32(((ptr) >> 2) * 4, value);
1479
+ break;
1480
+
1481
+ default:
1482
+ abort(`invalid type for setValue: ${type}`);
1483
+ }
1484
+ }
1485
+ var ___memory_base = new WebAssembly.Global({
1486
+ "value": "i32",
1487
+ "mutable": false
1488
+ }, 1024);
1489
+ var ___stack_pointer = new WebAssembly.Global({
1490
+ "value": "i32",
1491
+ "mutable": true
1492
+ }, 78112);
1493
+ var ___table_base = new WebAssembly.Global({
1494
+ "value": "i32",
1495
+ "mutable": false
1496
+ }, 1);
1497
+ var __abort_js = () => {
1498
+ abort("");
1499
+ };
1500
+ __abort_js.sig = "v";
1501
+ var nowIsMonotonic = 1;
1502
+ var __emscripten_get_now_is_monotonic = () => nowIsMonotonic;
1503
+ __emscripten_get_now_is_monotonic.sig = "i";
1504
+ var __emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num);
1505
+ __emscripten_memcpy_js.sig = "vppp";
1506
+ var _emscripten_date_now = () => Date.now();
1507
+ _emscripten_date_now.sig = "d";
1508
+ var _emscripten_get_now;
1509
+ // Modern environment where performance.now() is supported:
1510
+ // N.B. a shorter form "_emscripten_get_now = performance.now;" is
1511
+ // unfortunately not allowed even in current browsers (e.g. FF Nightly 75).
1512
+ _emscripten_get_now = () => performance.now();
1513
+ _emscripten_get_now.sig = "d";
1514
+ var getHeapMax = () => // Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
1515
+ // full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
1516
+ // for any code that deals with heap sizes, which would require special
1517
+ // casing all heap size related code to treat 0 specially.
1518
+ 2147483648;
1519
+ var growMemory = size => {
1520
+ var b = wasmMemory.buffer;
1521
+ var pages = (size - b.byteLength + 65535) / 65536;
1522
+ try {
1523
+ // round size grow request up to wasm page size (fixed 64KB per spec)
1524
+ wasmMemory.grow(pages);
1525
+ // .grow() takes a delta compared to the previous size
1526
+ updateMemoryViews();
1527
+ return 1;
1528
+ } /*success*/ catch (e) {}
1529
+ };
1530
+ // implicit 0 return to save code size (caller will cast "undefined" into 0
1531
+ // anyhow)
1532
+ var _emscripten_resize_heap = requestedSize => {
1533
+ var oldSize = HEAPU8.length;
1534
+ // With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
1535
+ requestedSize >>>= 0;
1536
+ // With multithreaded builds, races can happen (another thread might increase the size
1537
+ // in between), so return a failure, and let the caller retry.
1538
+ // Memory resize rules:
1539
+ // 1. Always increase heap size to at least the requested size, rounded up
1540
+ // to next page multiple.
1541
+ // 2a. If MEMORY_GROWTH_LINEAR_STEP == -1, excessively resize the heap
1542
+ // geometrically: increase the heap size according to
1543
+ // MEMORY_GROWTH_GEOMETRIC_STEP factor (default +20%), At most
1544
+ // overreserve by MEMORY_GROWTH_GEOMETRIC_CAP bytes (default 96MB).
1545
+ // 2b. If MEMORY_GROWTH_LINEAR_STEP != -1, excessively resize the heap
1546
+ // linearly: increase the heap size by at least
1547
+ // MEMORY_GROWTH_LINEAR_STEP bytes.
1548
+ // 3. Max size for the heap is capped at 2048MB-WASM_PAGE_SIZE, or by
1549
+ // MAXIMUM_MEMORY, or by ASAN limit, depending on which is smallest
1550
+ // 4. If we were unable to allocate as much memory, it may be due to
1551
+ // over-eager decision to excessively reserve due to (3) above.
1552
+ // Hence if an allocation fails, cut down on the amount of excess
1553
+ // growth, in an attempt to succeed to perform a smaller allocation.
1554
+ // A limit is set for how much we can grow. We should not exceed that
1555
+ // (the wasm binary specifies it, so if we tried, we'd fail anyhow).
1556
+ var maxHeapSize = getHeapMax();
1557
+ if (requestedSize > maxHeapSize) {
1558
+ return false;
1559
+ }
1560
+ var alignUp = (x, multiple) => x + (multiple - x % multiple) % multiple;
1561
+ // Loop through potential heap size increases. If we attempt a too eager
1562
+ // reservation that fails, cut down on the attempted size and reserve a
1563
+ // smaller bump instead. (max 3 times, chosen somewhat arbitrarily)
1564
+ for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
1565
+ var overGrownHeapSize = oldSize * (1 + .2 / cutDown);
1566
+ // ensure geometric growth
1567
+ // but limit overreserving (default to capping at +96MB overgrowth at most)
1568
+ overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
1569
+ var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536));
1570
+ var replacement = growMemory(newSize);
1571
+ if (replacement) {
1572
+ return true;
1573
+ }
1574
+ }
1575
+ return false;
1576
+ };
1577
+ _emscripten_resize_heap.sig = "ip";
1578
+ var _fd_close = fd => 52;
1579
+ _fd_close.sig = "ii";
1580
+ var convertI32PairToI53Checked = (lo, hi) => ((hi + 2097152) >>> 0 < 4194305 - !!lo) ? (lo >>> 0) + hi * 4294967296 : NaN;
1581
+ function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {
1582
+ var offset = convertI32PairToI53Checked(offset_low, offset_high);
1583
+ return 70;
1584
+ }
1585
+ _fd_seek.sig = "iiiiip";
1586
+ var printCharBuffers = [ null, [], [] ];
1587
+ var printChar = (stream, curr) => {
1588
+ var buffer = printCharBuffers[stream];
1589
+ if (curr === 0 || curr === 10) {
1590
+ (stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0));
1591
+ buffer.length = 0;
1592
+ } else {
1593
+ buffer.push(curr);
1594
+ }
1595
+ };
1596
+ var _fd_write = (fd, iov, iovcnt, pnum) => {
1597
+ // hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
1598
+ var num = 0;
1599
+ for (var i = 0; i < iovcnt; i++) {
1600
+ var ptr = LE_HEAP_LOAD_U32(((iov) >> 2) * 4);
1601
+ var len = LE_HEAP_LOAD_U32((((iov) + (4)) >> 2) * 4);
1602
+ iov += 8;
1603
+ for (var j = 0; j < len; j++) {
1604
+ printChar(fd, HEAPU8[ptr + j]);
1605
+ }
1606
+ num += len;
1607
+ }
1608
+ LE_HEAP_STORE_U32(((pnum) >> 2) * 4, num);
1609
+ return 0;
1610
+ };
1611
+ _fd_write.sig = "iippp";
1612
+ function _tree_sitter_log_callback(isLexMessage, messageAddress) {
1613
+ if (currentLogCallback) {
1614
+ const message = UTF8ToString(messageAddress);
1615
+ currentLogCallback(message, isLexMessage !== 0);
1616
+ }
1617
+ }
1618
+ function _tree_sitter_parse_callback(inputBufferAddress, index, row, column, lengthAddress) {
1619
+ const INPUT_BUFFER_SIZE = 10 * 1024;
1620
+ const string = currentParseCallback(index, {
1621
+ row: row,
1622
+ column: column
1623
+ });
1624
+ if (typeof string === "string") {
1625
+ setValue(lengthAddress, string.length, "i32");
1626
+ stringToUTF16(string, inputBufferAddress, INPUT_BUFFER_SIZE);
1627
+ } else {
1628
+ setValue(lengthAddress, 0, "i32");
1629
+ }
1630
+ }
1631
+ var runtimeKeepaliveCounter = 0;
1632
+ var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
1633
+ var _proc_exit = code => {
1634
+ EXITSTATUS = code;
1635
+ if (!keepRuntimeAlive()) {
1636
+ Module["onExit"]?.(code);
1637
+ ABORT = true;
1638
+ }
1639
+ quit_(code, new ExitStatus(code));
1640
+ };
1641
+ _proc_exit.sig = "vi";
1642
+ /** @param {boolean|number=} implicit */ var exitJS = (status, implicit) => {
1643
+ EXITSTATUS = status;
1644
+ _proc_exit(status);
1645
+ };
1646
+ var handleException = e => {
1647
+ // Certain exception types we do not treat as errors since they are used for
1648
+ // internal control flow.
1649
+ // 1. ExitStatus, which is thrown by exit()
1650
+ // 2. "unwind", which is thrown by emscripten_unwind_to_js_event_loop() and others
1651
+ // that wish to return to JS event loop.
1652
+ if (e instanceof ExitStatus || e == "unwind") {
1653
+ return EXITSTATUS;
1654
+ }
1655
+ quit_(1, e);
1656
+ };
1657
+ var lengthBytesUTF8 = str => {
1658
+ var len = 0;
1659
+ for (var i = 0; i < str.length; ++i) {
1660
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
1661
+ // unit, not a Unicode code point of the character! So decode
1662
+ // UTF16->UTF32->UTF8.
1663
+ // See http://unicode.org/faq/utf_bom.html#utf16-3
1664
+ var c = str.charCodeAt(i);
1665
+ // possibly a lead surrogate
1666
+ if (c <= 127) {
1667
+ len++;
1668
+ } else if (c <= 2047) {
1669
+ len += 2;
1670
+ } else if (c >= 55296 && c <= 57343) {
1671
+ len += 4;
1672
+ ++i;
1673
+ } else {
1674
+ len += 3;
1675
+ }
1676
+ }
1677
+ return len;
1678
+ };
1679
+ var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
1680
+ // Parameter maxBytesToWrite is not optional. Negative values, 0, null,
1681
+ // undefined and false each don't write out any bytes.
1682
+ if (!(maxBytesToWrite > 0)) return 0;
1683
+ var startIdx = outIdx;
1684
+ var endIdx = outIdx + maxBytesToWrite - 1;
1685
+ // -1 for string null terminator.
1686
+ for (var i = 0; i < str.length; ++i) {
1687
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
1688
+ // unit, not a Unicode code point of the character! So decode
1689
+ // UTF16->UTF32->UTF8.
1690
+ // See http://unicode.org/faq/utf_bom.html#utf16-3
1691
+ // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
1692
+ // and https://www.ietf.org/rfc/rfc2279.txt
1693
+ // and https://tools.ietf.org/html/rfc3629
1694
+ var u = str.charCodeAt(i);
1695
+ // possibly a lead surrogate
1696
+ if (u >= 55296 && u <= 57343) {
1697
+ var u1 = str.charCodeAt(++i);
1698
+ u = 65536 + ((u & 1023) << 10) | (u1 & 1023);
1699
+ }
1700
+ if (u <= 127) {
1701
+ if (outIdx >= endIdx) break;
1702
+ heap[outIdx++] = u;
1703
+ } else if (u <= 2047) {
1704
+ if (outIdx + 1 >= endIdx) break;
1705
+ heap[outIdx++] = 192 | (u >> 6);
1706
+ heap[outIdx++] = 128 | (u & 63);
1707
+ } else if (u <= 65535) {
1708
+ if (outIdx + 2 >= endIdx) break;
1709
+ heap[outIdx++] = 224 | (u >> 12);
1710
+ heap[outIdx++] = 128 | ((u >> 6) & 63);
1711
+ heap[outIdx++] = 128 | (u & 63);
1712
+ } else {
1713
+ if (outIdx + 3 >= endIdx) break;
1714
+ heap[outIdx++] = 240 | (u >> 18);
1715
+ heap[outIdx++] = 128 | ((u >> 12) & 63);
1716
+ heap[outIdx++] = 128 | ((u >> 6) & 63);
1717
+ heap[outIdx++] = 128 | (u & 63);
1718
+ }
1719
+ }
1720
+ // Null-terminate the pointer to the buffer.
1721
+ heap[outIdx] = 0;
1722
+ return outIdx - startIdx;
1723
+ };
1724
+ var stringToUTF8 = (str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
1725
+ var stackAlloc = sz => __emscripten_stack_alloc(sz);
1726
+ var stringToUTF8OnStack = str => {
1727
+ var size = lengthBytesUTF8(str) + 1;
1728
+ var ret = stackAlloc(size);
1729
+ stringToUTF8(str, ret, size);
1730
+ return ret;
1731
+ };
1732
+ var stringToUTF16 = (str, outPtr, maxBytesToWrite) => {
1733
+ // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
1734
+ maxBytesToWrite ??= 2147483647;
1735
+ if (maxBytesToWrite < 2) return 0;
1736
+ maxBytesToWrite -= 2;
1737
+ // Null terminator.
1738
+ var startPtr = outPtr;
1739
+ var numCharsToWrite = (maxBytesToWrite < str.length * 2) ? (maxBytesToWrite / 2) : str.length;
1740
+ for (var i = 0; i < numCharsToWrite; ++i) {
1741
+ // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
1742
+ var codeUnit = str.charCodeAt(i);
1743
+ // possibly a lead surrogate
1744
+ LE_HEAP_STORE_I16(((outPtr) >> 1) * 2, codeUnit);
1745
+ outPtr += 2;
1746
+ }
1747
+ // Null-terminate the pointer to the HEAP.
1748
+ LE_HEAP_STORE_I16(((outPtr) >> 1) * 2, 0);
1749
+ return outPtr - startPtr;
1750
+ };
1751
+ var AsciiToString = ptr => {
1752
+ var str = "";
1753
+ while (1) {
1754
+ var ch = HEAPU8[ptr++];
1755
+ if (!ch) return str;
1756
+ str += String.fromCharCode(ch);
1757
+ }
1758
+ };
1759
+ var wasmImports = {
1760
+ /** @export */ __heap_base: ___heap_base,
1761
+ /** @export */ __indirect_function_table: wasmTable,
1762
+ /** @export */ __memory_base: ___memory_base,
1763
+ /** @export */ __stack_pointer: ___stack_pointer,
1764
+ /** @export */ __table_base: ___table_base,
1765
+ /** @export */ _abort_js: __abort_js,
1766
+ /** @export */ _emscripten_get_now_is_monotonic: __emscripten_get_now_is_monotonic,
1767
+ /** @export */ _emscripten_memcpy_js: __emscripten_memcpy_js,
1768
+ /** @export */ emscripten_get_now: _emscripten_get_now,
1769
+ /** @export */ emscripten_resize_heap: _emscripten_resize_heap,
1770
+ /** @export */ fd_close: _fd_close,
1771
+ /** @export */ fd_seek: _fd_seek,
1772
+ /** @export */ fd_write: _fd_write,
1773
+ /** @export */ memory: wasmMemory,
1774
+ /** @export */ tree_sitter_log_callback: _tree_sitter_log_callback,
1775
+ /** @export */ tree_sitter_parse_callback: _tree_sitter_parse_callback
1776
+ };
1777
+ var wasmExports = createWasm();
1778
+ var ___wasm_call_ctors = () => (___wasm_call_ctors = wasmExports["__wasm_call_ctors"])();
1779
+ var ___wasm_apply_data_relocs = () => (___wasm_apply_data_relocs = wasmExports["__wasm_apply_data_relocs"])();
1780
+ var _malloc = Module["_malloc"] = a0 => (_malloc = Module["_malloc"] = wasmExports["malloc"])(a0);
1781
+ var _calloc = Module["_calloc"] = (a0, a1) => (_calloc = Module["_calloc"] = wasmExports["calloc"])(a0, a1);
1782
+ var _realloc = Module["_realloc"] = (a0, a1) => (_realloc = Module["_realloc"] = wasmExports["realloc"])(a0, a1);
1783
+ var _free = Module["_free"] = a0 => (_free = Module["_free"] = wasmExports["free"])(a0);
1784
+ var _ts_language_symbol_count = Module["_ts_language_symbol_count"] = a0 => (_ts_language_symbol_count = Module["_ts_language_symbol_count"] = wasmExports["ts_language_symbol_count"])(a0);
1785
+ var _ts_language_state_count = Module["_ts_language_state_count"] = a0 => (_ts_language_state_count = Module["_ts_language_state_count"] = wasmExports["ts_language_state_count"])(a0);
1786
+ var _ts_language_version = Module["_ts_language_version"] = a0 => (_ts_language_version = Module["_ts_language_version"] = wasmExports["ts_language_version"])(a0);
1787
+ var _ts_language_field_count = Module["_ts_language_field_count"] = a0 => (_ts_language_field_count = Module["_ts_language_field_count"] = wasmExports["ts_language_field_count"])(a0);
1788
+ var _ts_language_next_state = Module["_ts_language_next_state"] = (a0, a1, a2) => (_ts_language_next_state = Module["_ts_language_next_state"] = wasmExports["ts_language_next_state"])(a0, a1, a2);
1789
+ var _ts_language_symbol_name = Module["_ts_language_symbol_name"] = (a0, a1) => (_ts_language_symbol_name = Module["_ts_language_symbol_name"] = wasmExports["ts_language_symbol_name"])(a0, a1);
1790
+ var _ts_language_symbol_for_name = Module["_ts_language_symbol_for_name"] = (a0, a1, a2, a3) => (_ts_language_symbol_for_name = Module["_ts_language_symbol_for_name"] = wasmExports["ts_language_symbol_for_name"])(a0, a1, a2, a3);
1791
+ var _strncmp = Module["_strncmp"] = (a0, a1, a2) => (_strncmp = Module["_strncmp"] = wasmExports["strncmp"])(a0, a1, a2);
1792
+ var _ts_language_symbol_type = Module["_ts_language_symbol_type"] = (a0, a1) => (_ts_language_symbol_type = Module["_ts_language_symbol_type"] = wasmExports["ts_language_symbol_type"])(a0, a1);
1793
+ var _ts_language_field_name_for_id = Module["_ts_language_field_name_for_id"] = (a0, a1) => (_ts_language_field_name_for_id = Module["_ts_language_field_name_for_id"] = wasmExports["ts_language_field_name_for_id"])(a0, a1);
1794
+ var _ts_lookahead_iterator_new = Module["_ts_lookahead_iterator_new"] = (a0, a1) => (_ts_lookahead_iterator_new = Module["_ts_lookahead_iterator_new"] = wasmExports["ts_lookahead_iterator_new"])(a0, a1);
1795
+ var _ts_lookahead_iterator_delete = Module["_ts_lookahead_iterator_delete"] = a0 => (_ts_lookahead_iterator_delete = Module["_ts_lookahead_iterator_delete"] = wasmExports["ts_lookahead_iterator_delete"])(a0);
1796
+ var _ts_lookahead_iterator_reset_state = Module["_ts_lookahead_iterator_reset_state"] = (a0, a1) => (_ts_lookahead_iterator_reset_state = Module["_ts_lookahead_iterator_reset_state"] = wasmExports["ts_lookahead_iterator_reset_state"])(a0, a1);
1797
+ var _ts_lookahead_iterator_reset = Module["_ts_lookahead_iterator_reset"] = (a0, a1, a2) => (_ts_lookahead_iterator_reset = Module["_ts_lookahead_iterator_reset"] = wasmExports["ts_lookahead_iterator_reset"])(a0, a1, a2);
1798
+ var _ts_lookahead_iterator_next = Module["_ts_lookahead_iterator_next"] = a0 => (_ts_lookahead_iterator_next = Module["_ts_lookahead_iterator_next"] = wasmExports["ts_lookahead_iterator_next"])(a0);
1799
+ var _ts_lookahead_iterator_current_symbol = Module["_ts_lookahead_iterator_current_symbol"] = a0 => (_ts_lookahead_iterator_current_symbol = Module["_ts_lookahead_iterator_current_symbol"] = wasmExports["ts_lookahead_iterator_current_symbol"])(a0);
1800
+ var _memset = Module["_memset"] = (a0, a1, a2) => (_memset = Module["_memset"] = wasmExports["memset"])(a0, a1, a2);
1801
+ var _memcpy = Module["_memcpy"] = (a0, a1, a2) => (_memcpy = Module["_memcpy"] = wasmExports["memcpy"])(a0, a1, a2);
1802
+ var _ts_parser_delete = Module["_ts_parser_delete"] = a0 => (_ts_parser_delete = Module["_ts_parser_delete"] = wasmExports["ts_parser_delete"])(a0);
1803
+ var _ts_parser_reset = Module["_ts_parser_reset"] = a0 => (_ts_parser_reset = Module["_ts_parser_reset"] = wasmExports["ts_parser_reset"])(a0);
1804
+ var _ts_parser_set_language = Module["_ts_parser_set_language"] = (a0, a1) => (_ts_parser_set_language = Module["_ts_parser_set_language"] = wasmExports["ts_parser_set_language"])(a0, a1);
1805
+ var _ts_parser_timeout_micros = Module["_ts_parser_timeout_micros"] = a0 => (_ts_parser_timeout_micros = Module["_ts_parser_timeout_micros"] = wasmExports["ts_parser_timeout_micros"])(a0);
1806
+ var _ts_parser_set_timeout_micros = Module["_ts_parser_set_timeout_micros"] = (a0, a1, a2) => (_ts_parser_set_timeout_micros = Module["_ts_parser_set_timeout_micros"] = wasmExports["ts_parser_set_timeout_micros"])(a0, a1, a2);
1807
+ var _ts_parser_set_included_ranges = Module["_ts_parser_set_included_ranges"] = (a0, a1, a2) => (_ts_parser_set_included_ranges = Module["_ts_parser_set_included_ranges"] = wasmExports["ts_parser_set_included_ranges"])(a0, a1, a2);
1808
+ var _memmove = Module["_memmove"] = (a0, a1, a2) => (_memmove = Module["_memmove"] = wasmExports["memmove"])(a0, a1, a2);
1809
+ var _memcmp = Module["_memcmp"] = (a0, a1, a2) => (_memcmp = Module["_memcmp"] = wasmExports["memcmp"])(a0, a1, a2);
1810
+ var _ts_query_new = Module["_ts_query_new"] = (a0, a1, a2, a3, a4) => (_ts_query_new = Module["_ts_query_new"] = wasmExports["ts_query_new"])(a0, a1, a2, a3, a4);
1811
+ var _ts_query_delete = Module["_ts_query_delete"] = a0 => (_ts_query_delete = Module["_ts_query_delete"] = wasmExports["ts_query_delete"])(a0);
1812
+ var _iswspace = Module["_iswspace"] = a0 => (_iswspace = Module["_iswspace"] = wasmExports["iswspace"])(a0);
1813
+ var _iswalnum = Module["_iswalnum"] = a0 => (_iswalnum = Module["_iswalnum"] = wasmExports["iswalnum"])(a0);
1814
+ var _ts_query_pattern_count = Module["_ts_query_pattern_count"] = a0 => (_ts_query_pattern_count = Module["_ts_query_pattern_count"] = wasmExports["ts_query_pattern_count"])(a0);
1815
+ var _ts_query_capture_count = Module["_ts_query_capture_count"] = a0 => (_ts_query_capture_count = Module["_ts_query_capture_count"] = wasmExports["ts_query_capture_count"])(a0);
1816
+ var _ts_query_string_count = Module["_ts_query_string_count"] = a0 => (_ts_query_string_count = Module["_ts_query_string_count"] = wasmExports["ts_query_string_count"])(a0);
1817
+ var _ts_query_capture_name_for_id = Module["_ts_query_capture_name_for_id"] = (a0, a1, a2) => (_ts_query_capture_name_for_id = Module["_ts_query_capture_name_for_id"] = wasmExports["ts_query_capture_name_for_id"])(a0, a1, a2);
1818
+ var _ts_query_string_value_for_id = Module["_ts_query_string_value_for_id"] = (a0, a1, a2) => (_ts_query_string_value_for_id = Module["_ts_query_string_value_for_id"] = wasmExports["ts_query_string_value_for_id"])(a0, a1, a2);
1819
+ var _ts_query_predicates_for_pattern = Module["_ts_query_predicates_for_pattern"] = (a0, a1, a2) => (_ts_query_predicates_for_pattern = Module["_ts_query_predicates_for_pattern"] = wasmExports["ts_query_predicates_for_pattern"])(a0, a1, a2);
1820
+ var _ts_query_disable_capture = Module["_ts_query_disable_capture"] = (a0, a1, a2) => (_ts_query_disable_capture = Module["_ts_query_disable_capture"] = wasmExports["ts_query_disable_capture"])(a0, a1, a2);
1821
+ var _ts_tree_copy = Module["_ts_tree_copy"] = a0 => (_ts_tree_copy = Module["_ts_tree_copy"] = wasmExports["ts_tree_copy"])(a0);
1822
+ var _ts_tree_delete = Module["_ts_tree_delete"] = a0 => (_ts_tree_delete = Module["_ts_tree_delete"] = wasmExports["ts_tree_delete"])(a0);
1823
+ var _ts_init = Module["_ts_init"] = () => (_ts_init = Module["_ts_init"] = wasmExports["ts_init"])();
1824
+ var _ts_parser_new_wasm = Module["_ts_parser_new_wasm"] = () => (_ts_parser_new_wasm = Module["_ts_parser_new_wasm"] = wasmExports["ts_parser_new_wasm"])();
1825
+ var _ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = (a0, a1) => (_ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = wasmExports["ts_parser_enable_logger_wasm"])(a0, a1);
1826
+ var _ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = (a0, a1, a2, a3, a4) => (_ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = wasmExports["ts_parser_parse_wasm"])(a0, a1, a2, a3, a4);
1827
+ var _ts_parser_included_ranges_wasm = Module["_ts_parser_included_ranges_wasm"] = a0 => (_ts_parser_included_ranges_wasm = Module["_ts_parser_included_ranges_wasm"] = wasmExports["ts_parser_included_ranges_wasm"])(a0);
1828
+ var _ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = (a0, a1) => (_ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = wasmExports["ts_language_type_is_named_wasm"])(a0, a1);
1829
+ var _ts_language_type_is_visible_wasm = Module["_ts_language_type_is_visible_wasm"] = (a0, a1) => (_ts_language_type_is_visible_wasm = Module["_ts_language_type_is_visible_wasm"] = wasmExports["ts_language_type_is_visible_wasm"])(a0, a1);
1830
+ var _ts_tree_root_node_wasm = Module["_ts_tree_root_node_wasm"] = a0 => (_ts_tree_root_node_wasm = Module["_ts_tree_root_node_wasm"] = wasmExports["ts_tree_root_node_wasm"])(a0);
1831
+ var _ts_tree_root_node_with_offset_wasm = Module["_ts_tree_root_node_with_offset_wasm"] = a0 => (_ts_tree_root_node_with_offset_wasm = Module["_ts_tree_root_node_with_offset_wasm"] = wasmExports["ts_tree_root_node_with_offset_wasm"])(a0);
1832
+ var _ts_tree_edit_wasm = Module["_ts_tree_edit_wasm"] = a0 => (_ts_tree_edit_wasm = Module["_ts_tree_edit_wasm"] = wasmExports["ts_tree_edit_wasm"])(a0);
1833
+ var _ts_tree_included_ranges_wasm = Module["_ts_tree_included_ranges_wasm"] = a0 => (_ts_tree_included_ranges_wasm = Module["_ts_tree_included_ranges_wasm"] = wasmExports["ts_tree_included_ranges_wasm"])(a0);
1834
+ var _ts_tree_get_changed_ranges_wasm = Module["_ts_tree_get_changed_ranges_wasm"] = (a0, a1) => (_ts_tree_get_changed_ranges_wasm = Module["_ts_tree_get_changed_ranges_wasm"] = wasmExports["ts_tree_get_changed_ranges_wasm"])(a0, a1);
1835
+ var _ts_tree_cursor_new_wasm = Module["_ts_tree_cursor_new_wasm"] = a0 => (_ts_tree_cursor_new_wasm = Module["_ts_tree_cursor_new_wasm"] = wasmExports["ts_tree_cursor_new_wasm"])(a0);
1836
+ var _ts_tree_cursor_delete_wasm = Module["_ts_tree_cursor_delete_wasm"] = a0 => (_ts_tree_cursor_delete_wasm = Module["_ts_tree_cursor_delete_wasm"] = wasmExports["ts_tree_cursor_delete_wasm"])(a0);
1837
+ var _ts_tree_cursor_reset_wasm = Module["_ts_tree_cursor_reset_wasm"] = a0 => (_ts_tree_cursor_reset_wasm = Module["_ts_tree_cursor_reset_wasm"] = wasmExports["ts_tree_cursor_reset_wasm"])(a0);
1838
+ var _ts_tree_cursor_reset_to_wasm = Module["_ts_tree_cursor_reset_to_wasm"] = (a0, a1) => (_ts_tree_cursor_reset_to_wasm = Module["_ts_tree_cursor_reset_to_wasm"] = wasmExports["ts_tree_cursor_reset_to_wasm"])(a0, a1);
1839
+ var _ts_tree_cursor_goto_first_child_wasm = Module["_ts_tree_cursor_goto_first_child_wasm"] = a0 => (_ts_tree_cursor_goto_first_child_wasm = Module["_ts_tree_cursor_goto_first_child_wasm"] = wasmExports["ts_tree_cursor_goto_first_child_wasm"])(a0);
1840
+ var _ts_tree_cursor_goto_last_child_wasm = Module["_ts_tree_cursor_goto_last_child_wasm"] = a0 => (_ts_tree_cursor_goto_last_child_wasm = Module["_ts_tree_cursor_goto_last_child_wasm"] = wasmExports["ts_tree_cursor_goto_last_child_wasm"])(a0);
1841
+ var _ts_tree_cursor_goto_first_child_for_index_wasm = Module["_ts_tree_cursor_goto_first_child_for_index_wasm"] = a0 => (_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"])(a0);
1842
+ var _ts_tree_cursor_goto_first_child_for_position_wasm = Module["_ts_tree_cursor_goto_first_child_for_position_wasm"] = a0 => (_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"])(a0);
1843
+ var _ts_tree_cursor_goto_next_sibling_wasm = Module["_ts_tree_cursor_goto_next_sibling_wasm"] = a0 => (_ts_tree_cursor_goto_next_sibling_wasm = Module["_ts_tree_cursor_goto_next_sibling_wasm"] = wasmExports["ts_tree_cursor_goto_next_sibling_wasm"])(a0);
1844
+ var _ts_tree_cursor_goto_previous_sibling_wasm = Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = a0 => (_ts_tree_cursor_goto_previous_sibling_wasm = Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = wasmExports["ts_tree_cursor_goto_previous_sibling_wasm"])(a0);
1845
+ var _ts_tree_cursor_goto_descendant_wasm = Module["_ts_tree_cursor_goto_descendant_wasm"] = (a0, a1) => (_ts_tree_cursor_goto_descendant_wasm = Module["_ts_tree_cursor_goto_descendant_wasm"] = wasmExports["ts_tree_cursor_goto_descendant_wasm"])(a0, a1);
1846
+ var _ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = a0 => (_ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = wasmExports["ts_tree_cursor_goto_parent_wasm"])(a0);
1847
+ var _ts_tree_cursor_current_node_type_id_wasm = Module["_ts_tree_cursor_current_node_type_id_wasm"] = a0 => (_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"])(a0);
1848
+ var _ts_tree_cursor_current_node_state_id_wasm = Module["_ts_tree_cursor_current_node_state_id_wasm"] = a0 => (_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"])(a0);
1849
+ var _ts_tree_cursor_current_node_is_named_wasm = Module["_ts_tree_cursor_current_node_is_named_wasm"] = a0 => (_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"])(a0);
1850
+ var _ts_tree_cursor_current_node_is_missing_wasm = Module["_ts_tree_cursor_current_node_is_missing_wasm"] = a0 => (_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"])(a0);
1851
+ var _ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = a0 => (_ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = wasmExports["ts_tree_cursor_current_node_id_wasm"])(a0);
1852
+ var _ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = a0 => (_ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = wasmExports["ts_tree_cursor_start_position_wasm"])(a0);
1853
+ var _ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = a0 => (_ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = wasmExports["ts_tree_cursor_end_position_wasm"])(a0);
1854
+ var _ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = a0 => (_ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = wasmExports["ts_tree_cursor_start_index_wasm"])(a0);
1855
+ var _ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = a0 => (_ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = wasmExports["ts_tree_cursor_end_index_wasm"])(a0);
1856
+ var _ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = a0 => (_ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = wasmExports["ts_tree_cursor_current_field_id_wasm"])(a0);
1857
+ var _ts_tree_cursor_current_depth_wasm = Module["_ts_tree_cursor_current_depth_wasm"] = a0 => (_ts_tree_cursor_current_depth_wasm = Module["_ts_tree_cursor_current_depth_wasm"] = wasmExports["ts_tree_cursor_current_depth_wasm"])(a0);
1858
+ var _ts_tree_cursor_current_descendant_index_wasm = Module["_ts_tree_cursor_current_descendant_index_wasm"] = a0 => (_ts_tree_cursor_current_descendant_index_wasm = Module["_ts_tree_cursor_current_descendant_index_wasm"] = wasmExports["ts_tree_cursor_current_descendant_index_wasm"])(a0);
1859
+ var _ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = a0 => (_ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = wasmExports["ts_tree_cursor_current_node_wasm"])(a0);
1860
+ var _ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = a0 => (_ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = wasmExports["ts_node_symbol_wasm"])(a0);
1861
+ var _ts_node_field_name_for_child_wasm = Module["_ts_node_field_name_for_child_wasm"] = (a0, a1) => (_ts_node_field_name_for_child_wasm = Module["_ts_node_field_name_for_child_wasm"] = wasmExports["ts_node_field_name_for_child_wasm"])(a0, a1);
1862
+ var _ts_node_children_by_field_id_wasm = Module["_ts_node_children_by_field_id_wasm"] = (a0, a1) => (_ts_node_children_by_field_id_wasm = Module["_ts_node_children_by_field_id_wasm"] = wasmExports["ts_node_children_by_field_id_wasm"])(a0, a1);
1863
+ var _ts_node_first_child_for_byte_wasm = Module["_ts_node_first_child_for_byte_wasm"] = a0 => (_ts_node_first_child_for_byte_wasm = Module["_ts_node_first_child_for_byte_wasm"] = wasmExports["ts_node_first_child_for_byte_wasm"])(a0);
1864
+ var _ts_node_first_named_child_for_byte_wasm = Module["_ts_node_first_named_child_for_byte_wasm"] = a0 => (_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"])(a0);
1865
+ var _ts_node_grammar_symbol_wasm = Module["_ts_node_grammar_symbol_wasm"] = a0 => (_ts_node_grammar_symbol_wasm = Module["_ts_node_grammar_symbol_wasm"] = wasmExports["ts_node_grammar_symbol_wasm"])(a0);
1866
+ var _ts_node_child_count_wasm = Module["_ts_node_child_count_wasm"] = a0 => (_ts_node_child_count_wasm = Module["_ts_node_child_count_wasm"] = wasmExports["ts_node_child_count_wasm"])(a0);
1867
+ var _ts_node_named_child_count_wasm = Module["_ts_node_named_child_count_wasm"] = a0 => (_ts_node_named_child_count_wasm = Module["_ts_node_named_child_count_wasm"] = wasmExports["ts_node_named_child_count_wasm"])(a0);
1868
+ var _ts_node_child_wasm = Module["_ts_node_child_wasm"] = (a0, a1) => (_ts_node_child_wasm = Module["_ts_node_child_wasm"] = wasmExports["ts_node_child_wasm"])(a0, a1);
1869
+ var _ts_node_named_child_wasm = Module["_ts_node_named_child_wasm"] = (a0, a1) => (_ts_node_named_child_wasm = Module["_ts_node_named_child_wasm"] = wasmExports["ts_node_named_child_wasm"])(a0, a1);
1870
+ var _ts_node_child_by_field_id_wasm = Module["_ts_node_child_by_field_id_wasm"] = (a0, a1) => (_ts_node_child_by_field_id_wasm = Module["_ts_node_child_by_field_id_wasm"] = wasmExports["ts_node_child_by_field_id_wasm"])(a0, a1);
1871
+ var _ts_node_next_sibling_wasm = Module["_ts_node_next_sibling_wasm"] = a0 => (_ts_node_next_sibling_wasm = Module["_ts_node_next_sibling_wasm"] = wasmExports["ts_node_next_sibling_wasm"])(a0);
1872
+ var _ts_node_prev_sibling_wasm = Module["_ts_node_prev_sibling_wasm"] = a0 => (_ts_node_prev_sibling_wasm = Module["_ts_node_prev_sibling_wasm"] = wasmExports["ts_node_prev_sibling_wasm"])(a0);
1873
+ var _ts_node_next_named_sibling_wasm = Module["_ts_node_next_named_sibling_wasm"] = a0 => (_ts_node_next_named_sibling_wasm = Module["_ts_node_next_named_sibling_wasm"] = wasmExports["ts_node_next_named_sibling_wasm"])(a0);
1874
+ var _ts_node_prev_named_sibling_wasm = Module["_ts_node_prev_named_sibling_wasm"] = a0 => (_ts_node_prev_named_sibling_wasm = Module["_ts_node_prev_named_sibling_wasm"] = wasmExports["ts_node_prev_named_sibling_wasm"])(a0);
1875
+ var _ts_node_descendant_count_wasm = Module["_ts_node_descendant_count_wasm"] = a0 => (_ts_node_descendant_count_wasm = Module["_ts_node_descendant_count_wasm"] = wasmExports["ts_node_descendant_count_wasm"])(a0);
1876
+ var _ts_node_parent_wasm = Module["_ts_node_parent_wasm"] = a0 => (_ts_node_parent_wasm = Module["_ts_node_parent_wasm"] = wasmExports["ts_node_parent_wasm"])(a0);
1877
+ var _ts_node_descendant_for_index_wasm = Module["_ts_node_descendant_for_index_wasm"] = a0 => (_ts_node_descendant_for_index_wasm = Module["_ts_node_descendant_for_index_wasm"] = wasmExports["ts_node_descendant_for_index_wasm"])(a0);
1878
+ var _ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = a0 => (_ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = wasmExports["ts_node_named_descendant_for_index_wasm"])(a0);
1879
+ var _ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = a0 => (_ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = wasmExports["ts_node_descendant_for_position_wasm"])(a0);
1880
+ var _ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = a0 => (_ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = wasmExports["ts_node_named_descendant_for_position_wasm"])(a0);
1881
+ var _ts_node_start_point_wasm = Module["_ts_node_start_point_wasm"] = a0 => (_ts_node_start_point_wasm = Module["_ts_node_start_point_wasm"] = wasmExports["ts_node_start_point_wasm"])(a0);
1882
+ var _ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = a0 => (_ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = wasmExports["ts_node_end_point_wasm"])(a0);
1883
+ var _ts_node_start_index_wasm = Module["_ts_node_start_index_wasm"] = a0 => (_ts_node_start_index_wasm = Module["_ts_node_start_index_wasm"] = wasmExports["ts_node_start_index_wasm"])(a0);
1884
+ var _ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = a0 => (_ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = wasmExports["ts_node_end_index_wasm"])(a0);
1885
+ var _ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = a0 => (_ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = wasmExports["ts_node_to_string_wasm"])(a0);
1886
+ var _ts_node_children_wasm = Module["_ts_node_children_wasm"] = a0 => (_ts_node_children_wasm = Module["_ts_node_children_wasm"] = wasmExports["ts_node_children_wasm"])(a0);
1887
+ var _ts_node_named_children_wasm = Module["_ts_node_named_children_wasm"] = a0 => (_ts_node_named_children_wasm = Module["_ts_node_named_children_wasm"] = wasmExports["ts_node_named_children_wasm"])(a0);
1888
+ var _ts_node_descendants_of_type_wasm = Module["_ts_node_descendants_of_type_wasm"] = (a0, a1, a2, a3, a4, a5, a6) => (_ts_node_descendants_of_type_wasm = Module["_ts_node_descendants_of_type_wasm"] = wasmExports["ts_node_descendants_of_type_wasm"])(a0, a1, a2, a3, a4, a5, a6);
1889
+ var _ts_node_is_named_wasm = Module["_ts_node_is_named_wasm"] = a0 => (_ts_node_is_named_wasm = Module["_ts_node_is_named_wasm"] = wasmExports["ts_node_is_named_wasm"])(a0);
1890
+ var _ts_node_has_changes_wasm = Module["_ts_node_has_changes_wasm"] = a0 => (_ts_node_has_changes_wasm = Module["_ts_node_has_changes_wasm"] = wasmExports["ts_node_has_changes_wasm"])(a0);
1891
+ var _ts_node_has_error_wasm = Module["_ts_node_has_error_wasm"] = a0 => (_ts_node_has_error_wasm = Module["_ts_node_has_error_wasm"] = wasmExports["ts_node_has_error_wasm"])(a0);
1892
+ var _ts_node_is_error_wasm = Module["_ts_node_is_error_wasm"] = a0 => (_ts_node_is_error_wasm = Module["_ts_node_is_error_wasm"] = wasmExports["ts_node_is_error_wasm"])(a0);
1893
+ var _ts_node_is_missing_wasm = Module["_ts_node_is_missing_wasm"] = a0 => (_ts_node_is_missing_wasm = Module["_ts_node_is_missing_wasm"] = wasmExports["ts_node_is_missing_wasm"])(a0);
1894
+ var _ts_node_is_extra_wasm = Module["_ts_node_is_extra_wasm"] = a0 => (_ts_node_is_extra_wasm = Module["_ts_node_is_extra_wasm"] = wasmExports["ts_node_is_extra_wasm"])(a0);
1895
+ var _ts_node_parse_state_wasm = Module["_ts_node_parse_state_wasm"] = a0 => (_ts_node_parse_state_wasm = Module["_ts_node_parse_state_wasm"] = wasmExports["ts_node_parse_state_wasm"])(a0);
1896
+ var _ts_node_next_parse_state_wasm = Module["_ts_node_next_parse_state_wasm"] = a0 => (_ts_node_next_parse_state_wasm = Module["_ts_node_next_parse_state_wasm"] = wasmExports["ts_node_next_parse_state_wasm"])(a0);
1897
+ var _ts_query_matches_wasm = Module["_ts_query_matches_wasm"] = (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) => (_ts_query_matches_wasm = Module["_ts_query_matches_wasm"] = wasmExports["ts_query_matches_wasm"])(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
1898
+ var _ts_query_captures_wasm = Module["_ts_query_captures_wasm"] = (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) => (_ts_query_captures_wasm = Module["_ts_query_captures_wasm"] = wasmExports["ts_query_captures_wasm"])(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
1899
+ var _iswalpha = Module["_iswalpha"] = a0 => (_iswalpha = Module["_iswalpha"] = wasmExports["iswalpha"])(a0);
1900
+ var _iswblank = Module["_iswblank"] = a0 => (_iswblank = Module["_iswblank"] = wasmExports["iswblank"])(a0);
1901
+ var _iswdigit = Module["_iswdigit"] = a0 => (_iswdigit = Module["_iswdigit"] = wasmExports["iswdigit"])(a0);
1902
+ var _iswlower = Module["_iswlower"] = a0 => (_iswlower = Module["_iswlower"] = wasmExports["iswlower"])(a0);
1903
+ var _iswupper = Module["_iswupper"] = a0 => (_iswupper = Module["_iswupper"] = wasmExports["iswupper"])(a0);
1904
+ var _iswxdigit = Module["_iswxdigit"] = a0 => (_iswxdigit = Module["_iswxdigit"] = wasmExports["iswxdigit"])(a0);
1905
+ var _memchr = Module["_memchr"] = (a0, a1, a2) => (_memchr = Module["_memchr"] = wasmExports["memchr"])(a0, a1, a2);
1906
+ var _strlen = Module["_strlen"] = a0 => (_strlen = Module["_strlen"] = wasmExports["strlen"])(a0);
1907
+ var _strcmp = Module["_strcmp"] = (a0, a1) => (_strcmp = Module["_strcmp"] = wasmExports["strcmp"])(a0, a1);
1908
+ var _strncat = Module["_strncat"] = (a0, a1, a2) => (_strncat = Module["_strncat"] = wasmExports["strncat"])(a0, a1, a2);
1909
+ var _strncpy = Module["_strncpy"] = (a0, a1, a2) => (_strncpy = Module["_strncpy"] = wasmExports["strncpy"])(a0, a1, a2);
1910
+ var _towlower = Module["_towlower"] = a0 => (_towlower = Module["_towlower"] = wasmExports["towlower"])(a0);
1911
+ var _towupper = Module["_towupper"] = a0 => (_towupper = Module["_towupper"] = wasmExports["towupper"])(a0);
1912
+ var _setThrew = (a0, a1) => (_setThrew = wasmExports["setThrew"])(a0, a1);
1913
+ var __emscripten_stack_restore = a0 => (__emscripten_stack_restore = wasmExports["_emscripten_stack_restore"])(a0);
1914
+ var __emscripten_stack_alloc = a0 => (__emscripten_stack_alloc = wasmExports["_emscripten_stack_alloc"])(a0);
1915
+ var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports["emscripten_stack_get_current"])();
1916
+ var dynCall_jiji = Module["dynCall_jiji"] = (a0, a1, a2, a3, a4) => (dynCall_jiji = Module["dynCall_jiji"] = wasmExports["dynCall_jiji"])(a0, a1, a2, a3, a4);
1917
+ var _orig$ts_parser_timeout_micros = Module["_orig$ts_parser_timeout_micros"] = a0 => (_orig$ts_parser_timeout_micros = Module["_orig$ts_parser_timeout_micros"] = wasmExports["orig$ts_parser_timeout_micros"])(a0);
1918
+ var _orig$ts_parser_set_timeout_micros = Module["_orig$ts_parser_set_timeout_micros"] = (a0, a1) => (_orig$ts_parser_set_timeout_micros = Module["_orig$ts_parser_set_timeout_micros"] = wasmExports["orig$ts_parser_set_timeout_micros"])(a0, a1);
1919
+ // include: postamble.js
1920
+ // === Auto-generated postamble setup entry stuff ===
1921
+ Module["AsciiToString"] = AsciiToString;
1922
+ Module["stringToUTF16"] = stringToUTF16;
1923
+ var calledRun;
1924
+ dependenciesFulfilled = function runCaller() {
1925
+ // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
1926
+ if (!calledRun) run();
1927
+ if (!calledRun) dependenciesFulfilled = runCaller;
1928
+ };
1929
+ // try this again later, after new deps are fulfilled
1930
+ function callMain(args = []) {
1931
+ var entryFunction = resolveGlobalSymbol("main").sym;
1932
+ // Main modules can't tell if they have main() at compile time, since it may
1933
+ // arrive from a dynamic library.
1934
+ if (!entryFunction) return;
1935
+ args.unshift(thisProgram);
1936
+ var argc = args.length;
1937
+ var argv = stackAlloc((argc + 1) * 4);
1938
+ var argv_ptr = argv;
1939
+ args.forEach(arg => {
1940
+ LE_HEAP_STORE_U32(((argv_ptr) >> 2) * 4, stringToUTF8OnStack(arg));
1941
+ argv_ptr += 4;
1942
+ });
1943
+ LE_HEAP_STORE_U32(((argv_ptr) >> 2) * 4, 0);
1944
+ try {
1945
+ var ret = entryFunction(argc, argv);
1946
+ // if we're not running an evented main loop, it's time to exit
1947
+ exitJS(ret, /* implicit = */ true);
1948
+ return ret;
1949
+ } catch (e) {
1950
+ return handleException(e);
1951
+ }
1952
+ }
1953
+ function run(args = arguments_) {
1954
+ if (runDependencies > 0) {
1955
+ return;
1956
+ }
1957
+ preRun();
1958
+ // a preRun added a dependency, run will be called later
1959
+ if (runDependencies > 0) {
1960
+ return;
1961
+ }
1962
+ function doRun() {
1963
+ // run may have just been called through dependencies being fulfilled just in this very frame,
1964
+ // or while the async setStatus time below was happening
1965
+ if (calledRun) return;
1966
+ calledRun = true;
1967
+ Module["calledRun"] = true;
1968
+ if (ABORT) return;
1969
+ initRuntime();
1970
+ preMain();
1971
+ Module["onRuntimeInitialized"]?.();
1972
+ if (shouldRunNow) callMain(args);
1973
+ postRun();
1974
+ }
1975
+ if (Module["setStatus"]) {
1976
+ Module["setStatus"]("Running...");
1977
+ setTimeout(function() {
1978
+ setTimeout(function() {
1979
+ Module["setStatus"]("");
1980
+ }, 1);
1981
+ doRun();
1982
+ }, 1);
1983
+ } else {
1984
+ doRun();
1985
+ }
1986
+ }
1987
+ if (Module["preInit"]) {
1988
+ if (typeof Module["preInit"] == "function") Module["preInit"] = [ Module["preInit"] ];
1989
+ while (Module["preInit"].length > 0) {
1990
+ Module["preInit"].pop()();
1991
+ }
1992
+ }
1993
+ // shouldRunNow refers to calling main(), not run().
1994
+ var shouldRunNow = true;
1995
+ if (Module["noInitialRun"]) shouldRunNow = false;
1996
+ run();
1997
+ // end include: postamble.js
1998
+ // include: /mnt/vss/_work/1/s/tree-sitter/lib/binding_web/binding.js
1999
+ /* eslint-disable-next-line spaced-comment */ /// <reference types="emscripten" />
2000
+ /* eslint-disable-next-line spaced-comment */ /// <reference path="tree-sitter-web.d.ts"/>
2001
+ const C = Module;
2002
+ const INTERNAL = {};
2003
+ const SIZE_OF_INT = 4;
2004
+ const SIZE_OF_CURSOR = 4 * SIZE_OF_INT;
2005
+ const SIZE_OF_NODE = 5 * SIZE_OF_INT;
2006
+ const SIZE_OF_POINT = 2 * SIZE_OF_INT;
2007
+ const SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT;
2008
+ const ZERO_POINT = {
2009
+ row: 0,
2010
+ column: 0
2011
+ };
2012
+ const QUERY_WORD_REGEX = /[\w-.]*/g;
2013
+ const PREDICATE_STEP_TYPE_CAPTURE = 1;
2014
+ const PREDICATE_STEP_TYPE_STRING = 2;
2015
+ const LANGUAGE_FUNCTION_REGEX = /^_?tree_sitter_\w+/;
2016
+ let VERSION;
2017
+ let MIN_COMPATIBLE_VERSION;
2018
+ let TRANSFER_BUFFER;
2019
+ let currentParseCallback;
2020
+ // eslint-disable-next-line no-unused-vars
2021
+ let currentLogCallback;
2022
+ // eslint-disable-next-line no-unused-vars
2023
+ class ParserImpl {
2024
+ static init() {
2025
+ TRANSFER_BUFFER = C._ts_init();
2026
+ VERSION = getValue(TRANSFER_BUFFER, "i32");
2027
+ MIN_COMPATIBLE_VERSION = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2028
+ }
2029
+ initialize() {
2030
+ C._ts_parser_new_wasm();
2031
+ this[0] = getValue(TRANSFER_BUFFER, "i32");
2032
+ this[1] = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2033
+ }
2034
+ delete() {
2035
+ C._ts_parser_delete(this[0]);
2036
+ C._free(this[1]);
2037
+ this[0] = 0;
2038
+ this[1] = 0;
2039
+ }
2040
+ setLanguage(language) {
2041
+ let address;
2042
+ if (!language) {
2043
+ address = 0;
2044
+ language = null;
2045
+ } else if (language.constructor === Language) {
2046
+ address = language[0];
2047
+ const version = C._ts_language_version(address);
2048
+ if (version < MIN_COMPATIBLE_VERSION || VERSION < version) {
2049
+ throw new Error(`Incompatible language version ${version}. ` + `Compatibility range ${MIN_COMPATIBLE_VERSION} through ${VERSION}.`);
2050
+ }
2051
+ } else {
2052
+ throw new Error("Argument must be a Language");
2053
+ }
2054
+ this.language = language;
2055
+ C._ts_parser_set_language(this[0], address);
2056
+ return this;
2057
+ }
2058
+ getLanguage() {
2059
+ return this.language;
2060
+ }
2061
+ parse(callback, oldTree, options) {
2062
+ if (typeof callback === "string") {
2063
+ currentParseCallback = (index, _) => callback.slice(index);
2064
+ } else if (typeof callback === "function") {
2065
+ currentParseCallback = callback;
2066
+ } else {
2067
+ throw new Error("Argument must be a string or a function");
2068
+ }
2069
+ if (this.logCallback) {
2070
+ currentLogCallback = this.logCallback;
2071
+ C._ts_parser_enable_logger_wasm(this[0], 1);
2072
+ } else {
2073
+ currentLogCallback = null;
2074
+ C._ts_parser_enable_logger_wasm(this[0], 0);
2075
+ }
2076
+ let rangeCount = 0;
2077
+ let rangeAddress = 0;
2078
+ if (options?.includedRanges) {
2079
+ rangeCount = options.includedRanges.length;
2080
+ rangeAddress = C._calloc(rangeCount, SIZE_OF_RANGE);
2081
+ let address = rangeAddress;
2082
+ for (let i = 0; i < rangeCount; i++) {
2083
+ marshalRange(address, options.includedRanges[i]);
2084
+ address += SIZE_OF_RANGE;
2085
+ }
2086
+ }
2087
+ const treeAddress = C._ts_parser_parse_wasm(this[0], this[1], oldTree ? oldTree[0] : 0, rangeAddress, rangeCount);
2088
+ if (!treeAddress) {
2089
+ currentParseCallback = null;
2090
+ currentLogCallback = null;
2091
+ throw new Error("Parsing failed");
2092
+ }
2093
+ const result = new Tree(INTERNAL, treeAddress, this.language, currentParseCallback);
2094
+ currentParseCallback = null;
2095
+ currentLogCallback = null;
2096
+ return result;
2097
+ }
2098
+ reset() {
2099
+ C._ts_parser_reset(this[0]);
2100
+ }
2101
+ getIncludedRanges() {
2102
+ C._ts_parser_included_ranges_wasm(this[0]);
2103
+ const count = getValue(TRANSFER_BUFFER, "i32");
2104
+ const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2105
+ const result = new Array(count);
2106
+ if (count > 0) {
2107
+ let address = buffer;
2108
+ for (let i = 0; i < count; i++) {
2109
+ result[i] = unmarshalRange(address);
2110
+ address += SIZE_OF_RANGE;
2111
+ }
2112
+ C._free(buffer);
2113
+ }
2114
+ return result;
2115
+ }
2116
+ getTimeoutMicros() {
2117
+ return C._ts_parser_timeout_micros(this[0]);
2118
+ }
2119
+ setTimeoutMicros(timeout) {
2120
+ C._ts_parser_set_timeout_micros(this[0], timeout);
2121
+ }
2122
+ setLogger(callback) {
2123
+ if (!callback) {
2124
+ callback = null;
2125
+ } else if (typeof callback !== "function") {
2126
+ throw new Error("Logger callback must be a function");
2127
+ }
2128
+ this.logCallback = callback;
2129
+ return this;
2130
+ }
2131
+ getLogger() {
2132
+ return this.logCallback;
2133
+ }
2134
+ }
2135
+ class Tree {
2136
+ constructor(internal, address, language, textCallback) {
2137
+ assertInternal(internal);
2138
+ this[0] = address;
2139
+ this.language = language;
2140
+ this.textCallback = textCallback;
2141
+ }
2142
+ copy() {
2143
+ const address = C._ts_tree_copy(this[0]);
2144
+ return new Tree(INTERNAL, address, this.language, this.textCallback);
2145
+ }
2146
+ delete() {
2147
+ C._ts_tree_delete(this[0]);
2148
+ this[0] = 0;
2149
+ }
2150
+ edit(edit) {
2151
+ marshalEdit(edit);
2152
+ C._ts_tree_edit_wasm(this[0]);
2153
+ }
2154
+ get rootNode() {
2155
+ C._ts_tree_root_node_wasm(this[0]);
2156
+ return unmarshalNode(this);
2157
+ }
2158
+ rootNodeWithOffset(offsetBytes, offsetExtent) {
2159
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
2160
+ setValue(address, offsetBytes, "i32");
2161
+ marshalPoint(address + SIZE_OF_INT, offsetExtent);
2162
+ C._ts_tree_root_node_with_offset_wasm(this[0]);
2163
+ return unmarshalNode(this);
2164
+ }
2165
+ getLanguage() {
2166
+ return this.language;
2167
+ }
2168
+ walk() {
2169
+ return this.rootNode.walk();
2170
+ }
2171
+ getChangedRanges(other) {
2172
+ if (other.constructor !== Tree) {
2173
+ throw new TypeError("Argument must be a Tree");
2174
+ }
2175
+ C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
2176
+ const count = getValue(TRANSFER_BUFFER, "i32");
2177
+ const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2178
+ const result = new Array(count);
2179
+ if (count > 0) {
2180
+ let address = buffer;
2181
+ for (let i = 0; i < count; i++) {
2182
+ result[i] = unmarshalRange(address);
2183
+ address += SIZE_OF_RANGE;
2184
+ }
2185
+ C._free(buffer);
2186
+ }
2187
+ return result;
2188
+ }
2189
+ getIncludedRanges() {
2190
+ C._ts_tree_included_ranges_wasm(this[0]);
2191
+ const count = getValue(TRANSFER_BUFFER, "i32");
2192
+ const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2193
+ const result = new Array(count);
2194
+ if (count > 0) {
2195
+ let address = buffer;
2196
+ for (let i = 0; i < count; i++) {
2197
+ result[i] = unmarshalRange(address);
2198
+ address += SIZE_OF_RANGE;
2199
+ }
2200
+ C._free(buffer);
2201
+ }
2202
+ return result;
2203
+ }
2204
+ }
2205
+ class Node {
2206
+ constructor(internal, tree) {
2207
+ assertInternal(internal);
2208
+ this.tree = tree;
2209
+ }
2210
+ get typeId() {
2211
+ marshalNode(this);
2212
+ return C._ts_node_symbol_wasm(this.tree[0]);
2213
+ }
2214
+ get grammarId() {
2215
+ marshalNode(this);
2216
+ return C._ts_node_grammar_symbol_wasm(this.tree[0]);
2217
+ }
2218
+ get type() {
2219
+ return this.tree.language.types[this.typeId] || "ERROR";
2220
+ }
2221
+ get grammarType() {
2222
+ return this.tree.language.types[this.grammarId] || "ERROR";
2223
+ }
2224
+ get endPosition() {
2225
+ marshalNode(this);
2226
+ C._ts_node_end_point_wasm(this.tree[0]);
2227
+ return unmarshalPoint(TRANSFER_BUFFER);
2228
+ }
2229
+ get endIndex() {
2230
+ marshalNode(this);
2231
+ return C._ts_node_end_index_wasm(this.tree[0]);
2232
+ }
2233
+ get text() {
2234
+ return getText(this.tree, this.startIndex, this.endIndex);
2235
+ }
2236
+ get parseState() {
2237
+ marshalNode(this);
2238
+ return C._ts_node_parse_state_wasm(this.tree[0]);
2239
+ }
2240
+ get nextParseState() {
2241
+ marshalNode(this);
2242
+ return C._ts_node_next_parse_state_wasm(this.tree[0]);
2243
+ }
2244
+ get isNamed() {
2245
+ marshalNode(this);
2246
+ return C._ts_node_is_named_wasm(this.tree[0]) === 1;
2247
+ }
2248
+ get hasError() {
2249
+ marshalNode(this);
2250
+ return C._ts_node_has_error_wasm(this.tree[0]) === 1;
2251
+ }
2252
+ get hasChanges() {
2253
+ marshalNode(this);
2254
+ return C._ts_node_has_changes_wasm(this.tree[0]) === 1;
2255
+ }
2256
+ get isError() {
2257
+ marshalNode(this);
2258
+ return C._ts_node_is_error_wasm(this.tree[0]) === 1;
2259
+ }
2260
+ get isMissing() {
2261
+ marshalNode(this);
2262
+ return C._ts_node_is_missing_wasm(this.tree[0]) === 1;
2263
+ }
2264
+ get isExtra() {
2265
+ marshalNode(this);
2266
+ return C._ts_node_is_extra_wasm(this.tree[0]) === 1;
2267
+ }
2268
+ equals(other) {
2269
+ return this.id === other.id;
2270
+ }
2271
+ child(index) {
2272
+ marshalNode(this);
2273
+ C._ts_node_child_wasm(this.tree[0], index);
2274
+ return unmarshalNode(this.tree);
2275
+ }
2276
+ namedChild(index) {
2277
+ marshalNode(this);
2278
+ C._ts_node_named_child_wasm(this.tree[0], index);
2279
+ return unmarshalNode(this.tree);
2280
+ }
2281
+ childForFieldId(fieldId) {
2282
+ marshalNode(this);
2283
+ C._ts_node_child_by_field_id_wasm(this.tree[0], fieldId);
2284
+ return unmarshalNode(this.tree);
2285
+ }
2286
+ childForFieldName(fieldName) {
2287
+ const fieldId = this.tree.language.fields.indexOf(fieldName);
2288
+ if (fieldId !== -1) return this.childForFieldId(fieldId);
2289
+ return null;
2290
+ }
2291
+ fieldNameForChild(index) {
2292
+ marshalNode(this);
2293
+ const address = C._ts_node_field_name_for_child_wasm(this.tree[0], index);
2294
+ if (!address) {
2295
+ return null;
2296
+ }
2297
+ const result = AsciiToString(address);
2298
+ // must not free, the string memory is owned by the language
2299
+ return result;
2300
+ }
2301
+ childrenForFieldName(fieldName) {
2302
+ const fieldId = this.tree.language.fields.indexOf(fieldName);
2303
+ if (fieldId !== -1 && fieldId !== 0) return this.childrenForFieldId(fieldId);
2304
+ return [];
2305
+ }
2306
+ childrenForFieldId(fieldId) {
2307
+ marshalNode(this);
2308
+ C._ts_node_children_by_field_id_wasm(this.tree[0], fieldId);
2309
+ const count = getValue(TRANSFER_BUFFER, "i32");
2310
+ const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2311
+ const result = new Array(count);
2312
+ if (count > 0) {
2313
+ let address = buffer;
2314
+ for (let i = 0; i < count; i++) {
2315
+ result[i] = unmarshalNode(this.tree, address);
2316
+ address += SIZE_OF_NODE;
2317
+ }
2318
+ C._free(buffer);
2319
+ }
2320
+ return result;
2321
+ }
2322
+ firstChildForIndex(index) {
2323
+ marshalNode(this);
2324
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
2325
+ setValue(address, index, "i32");
2326
+ C._ts_node_first_child_for_byte_wasm(this.tree[0]);
2327
+ return unmarshalNode(this.tree);
2328
+ }
2329
+ firstNamedChildForIndex(index) {
2330
+ marshalNode(this);
2331
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
2332
+ setValue(address, index, "i32");
2333
+ C._ts_node_first_named_child_for_byte_wasm(this.tree[0]);
2334
+ return unmarshalNode(this.tree);
2335
+ }
2336
+ get childCount() {
2337
+ marshalNode(this);
2338
+ return C._ts_node_child_count_wasm(this.tree[0]);
2339
+ }
2340
+ get namedChildCount() {
2341
+ marshalNode(this);
2342
+ return C._ts_node_named_child_count_wasm(this.tree[0]);
2343
+ }
2344
+ get firstChild() {
2345
+ return this.child(0);
2346
+ }
2347
+ get firstNamedChild() {
2348
+ return this.namedChild(0);
2349
+ }
2350
+ get lastChild() {
2351
+ return this.child(this.childCount - 1);
2352
+ }
2353
+ get lastNamedChild() {
2354
+ return this.namedChild(this.namedChildCount - 1);
2355
+ }
2356
+ get children() {
2357
+ if (!this._children) {
2358
+ marshalNode(this);
2359
+ C._ts_node_children_wasm(this.tree[0]);
2360
+ const count = getValue(TRANSFER_BUFFER, "i32");
2361
+ const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2362
+ this._children = new Array(count);
2363
+ if (count > 0) {
2364
+ let address = buffer;
2365
+ for (let i = 0; i < count; i++) {
2366
+ this._children[i] = unmarshalNode(this.tree, address);
2367
+ address += SIZE_OF_NODE;
2368
+ }
2369
+ C._free(buffer);
2370
+ }
2371
+ }
2372
+ return this._children;
2373
+ }
2374
+ get namedChildren() {
2375
+ if (!this._namedChildren) {
2376
+ marshalNode(this);
2377
+ C._ts_node_named_children_wasm(this.tree[0]);
2378
+ const count = getValue(TRANSFER_BUFFER, "i32");
2379
+ const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2380
+ this._namedChildren = new Array(count);
2381
+ if (count > 0) {
2382
+ let address = buffer;
2383
+ for (let i = 0; i < count; i++) {
2384
+ this._namedChildren[i] = unmarshalNode(this.tree, address);
2385
+ address += SIZE_OF_NODE;
2386
+ }
2387
+ C._free(buffer);
2388
+ }
2389
+ }
2390
+ return this._namedChildren;
2391
+ }
2392
+ descendantsOfType(types, startPosition, endPosition) {
2393
+ if (!Array.isArray(types)) types = [ types ];
2394
+ if (!startPosition) startPosition = ZERO_POINT;
2395
+ if (!endPosition) endPosition = ZERO_POINT;
2396
+ // Convert the type strings to numeric type symbols.
2397
+ const symbols = [];
2398
+ const typesBySymbol = this.tree.language.types;
2399
+ for (let i = 0, n = typesBySymbol.length; i < n; i++) {
2400
+ if (types.includes(typesBySymbol[i])) {
2401
+ symbols.push(i);
2402
+ }
2403
+ }
2404
+ // Copy the array of symbols to the WASM heap.
2405
+ const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
2406
+ for (let i = 0, n = symbols.length; i < n; i++) {
2407
+ setValue(symbolsAddress + i * SIZE_OF_INT, symbols[i], "i32");
2408
+ }
2409
+ // Call the C API to compute the descendants.
2410
+ marshalNode(this);
2411
+ C._ts_node_descendants_of_type_wasm(this.tree[0], symbolsAddress, symbols.length, startPosition.row, startPosition.column, endPosition.row, endPosition.column);
2412
+ // Instantiate the nodes based on the data returned.
2413
+ const descendantCount = getValue(TRANSFER_BUFFER, "i32");
2414
+ const descendantAddress = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2415
+ const result = new Array(descendantCount);
2416
+ if (descendantCount > 0) {
2417
+ let address = descendantAddress;
2418
+ for (let i = 0; i < descendantCount; i++) {
2419
+ result[i] = unmarshalNode(this.tree, address);
2420
+ address += SIZE_OF_NODE;
2421
+ }
2422
+ }
2423
+ // Free the intermediate buffers
2424
+ C._free(descendantAddress);
2425
+ C._free(symbolsAddress);
2426
+ return result;
2427
+ }
2428
+ get nextSibling() {
2429
+ marshalNode(this);
2430
+ C._ts_node_next_sibling_wasm(this.tree[0]);
2431
+ return unmarshalNode(this.tree);
2432
+ }
2433
+ get previousSibling() {
2434
+ marshalNode(this);
2435
+ C._ts_node_prev_sibling_wasm(this.tree[0]);
2436
+ return unmarshalNode(this.tree);
2437
+ }
2438
+ get nextNamedSibling() {
2439
+ marshalNode(this);
2440
+ C._ts_node_next_named_sibling_wasm(this.tree[0]);
2441
+ return unmarshalNode(this.tree);
2442
+ }
2443
+ get previousNamedSibling() {
2444
+ marshalNode(this);
2445
+ C._ts_node_prev_named_sibling_wasm(this.tree[0]);
2446
+ return unmarshalNode(this.tree);
2447
+ }
2448
+ get descendantCount() {
2449
+ marshalNode(this);
2450
+ return C._ts_node_descendant_count_wasm(this.tree[0]);
2451
+ }
2452
+ get parent() {
2453
+ marshalNode(this);
2454
+ C._ts_node_parent_wasm(this.tree[0]);
2455
+ return unmarshalNode(this.tree);
2456
+ }
2457
+ descendantForIndex(start, end = start) {
2458
+ if (typeof start !== "number" || typeof end !== "number") {
2459
+ throw new Error("Arguments must be numbers");
2460
+ }
2461
+ marshalNode(this);
2462
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
2463
+ setValue(address, start, "i32");
2464
+ setValue(address + SIZE_OF_INT, end, "i32");
2465
+ C._ts_node_descendant_for_index_wasm(this.tree[0]);
2466
+ return unmarshalNode(this.tree);
2467
+ }
2468
+ namedDescendantForIndex(start, end = start) {
2469
+ if (typeof start !== "number" || typeof end !== "number") {
2470
+ throw new Error("Arguments must be numbers");
2471
+ }
2472
+ marshalNode(this);
2473
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
2474
+ setValue(address, start, "i32");
2475
+ setValue(address + SIZE_OF_INT, end, "i32");
2476
+ C._ts_node_named_descendant_for_index_wasm(this.tree[0]);
2477
+ return unmarshalNode(this.tree);
2478
+ }
2479
+ descendantForPosition(start, end = start) {
2480
+ if (!isPoint(start) || !isPoint(end)) {
2481
+ throw new Error("Arguments must be {row, column} objects");
2482
+ }
2483
+ marshalNode(this);
2484
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
2485
+ marshalPoint(address, start);
2486
+ marshalPoint(address + SIZE_OF_POINT, end);
2487
+ C._ts_node_descendant_for_position_wasm(this.tree[0]);
2488
+ return unmarshalNode(this.tree);
2489
+ }
2490
+ namedDescendantForPosition(start, end = start) {
2491
+ if (!isPoint(start) || !isPoint(end)) {
2492
+ throw new Error("Arguments must be {row, column} objects");
2493
+ }
2494
+ marshalNode(this);
2495
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
2496
+ marshalPoint(address, start);
2497
+ marshalPoint(address + SIZE_OF_POINT, end);
2498
+ C._ts_node_named_descendant_for_position_wasm(this.tree[0]);
2499
+ return unmarshalNode(this.tree);
2500
+ }
2501
+ walk() {
2502
+ marshalNode(this);
2503
+ C._ts_tree_cursor_new_wasm(this.tree[0]);
2504
+ return new TreeCursor(INTERNAL, this.tree);
2505
+ }
2506
+ toString() {
2507
+ marshalNode(this);
2508
+ const address = C._ts_node_to_string_wasm(this.tree[0]);
2509
+ const result = AsciiToString(address);
2510
+ C._free(address);
2511
+ return result;
2512
+ }
2513
+ }
2514
+ class TreeCursor {
2515
+ constructor(internal, tree) {
2516
+ assertInternal(internal);
2517
+ this.tree = tree;
2518
+ unmarshalTreeCursor(this);
2519
+ }
2520
+ delete() {
2521
+ marshalTreeCursor(this);
2522
+ C._ts_tree_cursor_delete_wasm(this.tree[0]);
2523
+ this[0] = this[1] = this[2] = 0;
2524
+ }
2525
+ reset(node) {
2526
+ marshalNode(node);
2527
+ marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
2528
+ C._ts_tree_cursor_reset_wasm(this.tree[0]);
2529
+ unmarshalTreeCursor(this);
2530
+ }
2531
+ resetTo(cursor) {
2532
+ marshalTreeCursor(this, TRANSFER_BUFFER);
2533
+ marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
2534
+ C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
2535
+ unmarshalTreeCursor(this);
2536
+ }
2537
+ get nodeType() {
2538
+ return this.tree.language.types[this.nodeTypeId] || "ERROR";
2539
+ }
2540
+ get nodeTypeId() {
2541
+ marshalTreeCursor(this);
2542
+ return C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0]);
2543
+ }
2544
+ get nodeStateId() {
2545
+ marshalTreeCursor(this);
2546
+ return C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0]);
2547
+ }
2548
+ get nodeId() {
2549
+ marshalTreeCursor(this);
2550
+ return C._ts_tree_cursor_current_node_id_wasm(this.tree[0]);
2551
+ }
2552
+ get nodeIsNamed() {
2553
+ marshalTreeCursor(this);
2554
+ return C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0]) === 1;
2555
+ }
2556
+ get nodeIsMissing() {
2557
+ marshalTreeCursor(this);
2558
+ return C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0]) === 1;
2559
+ }
2560
+ get nodeText() {
2561
+ marshalTreeCursor(this);
2562
+ const startIndex = C._ts_tree_cursor_start_index_wasm(this.tree[0]);
2563
+ const endIndex = C._ts_tree_cursor_end_index_wasm(this.tree[0]);
2564
+ return getText(this.tree, startIndex, endIndex);
2565
+ }
2566
+ get startPosition() {
2567
+ marshalTreeCursor(this);
2568
+ C._ts_tree_cursor_start_position_wasm(this.tree[0]);
2569
+ return unmarshalPoint(TRANSFER_BUFFER);
2570
+ }
2571
+ get endPosition() {
2572
+ marshalTreeCursor(this);
2573
+ C._ts_tree_cursor_end_position_wasm(this.tree[0]);
2574
+ return unmarshalPoint(TRANSFER_BUFFER);
2575
+ }
2576
+ get startIndex() {
2577
+ marshalTreeCursor(this);
2578
+ return C._ts_tree_cursor_start_index_wasm(this.tree[0]);
2579
+ }
2580
+ get endIndex() {
2581
+ marshalTreeCursor(this);
2582
+ return C._ts_tree_cursor_end_index_wasm(this.tree[0]);
2583
+ }
2584
+ get currentNode() {
2585
+ marshalTreeCursor(this);
2586
+ C._ts_tree_cursor_current_node_wasm(this.tree[0]);
2587
+ return unmarshalNode(this.tree);
2588
+ }
2589
+ get currentFieldId() {
2590
+ marshalTreeCursor(this);
2591
+ return C._ts_tree_cursor_current_field_id_wasm(this.tree[0]);
2592
+ }
2593
+ get currentFieldName() {
2594
+ return this.tree.language.fields[this.currentFieldId];
2595
+ }
2596
+ get currentDepth() {
2597
+ marshalTreeCursor(this);
2598
+ return C._ts_tree_cursor_current_depth_wasm(this.tree[0]);
2599
+ }
2600
+ get currentDescendantIndex() {
2601
+ marshalTreeCursor(this);
2602
+ return C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0]);
2603
+ }
2604
+ gotoFirstChild() {
2605
+ marshalTreeCursor(this);
2606
+ const result = C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);
2607
+ unmarshalTreeCursor(this);
2608
+ return result === 1;
2609
+ }
2610
+ gotoLastChild() {
2611
+ marshalTreeCursor(this);
2612
+ const result = C._ts_tree_cursor_goto_last_child_wasm(this.tree[0]);
2613
+ unmarshalTreeCursor(this);
2614
+ return result === 1;
2615
+ }
2616
+ gotoFirstChildForIndex(goalIndex) {
2617
+ marshalTreeCursor(this);
2618
+ setValue(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalIndex, "i32");
2619
+ const result = C._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]);
2620
+ unmarshalTreeCursor(this);
2621
+ return result === 1;
2622
+ }
2623
+ gotoFirstChildForPosition(goalPosition) {
2624
+ marshalTreeCursor(this);
2625
+ marshalPoint(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalPosition);
2626
+ const result = C._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]);
2627
+ unmarshalTreeCursor(this);
2628
+ return result === 1;
2629
+ }
2630
+ gotoNextSibling() {
2631
+ marshalTreeCursor(this);
2632
+ const result = C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);
2633
+ unmarshalTreeCursor(this);
2634
+ return result === 1;
2635
+ }
2636
+ gotoPreviousSibling() {
2637
+ marshalTreeCursor(this);
2638
+ const result = C._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]);
2639
+ unmarshalTreeCursor(this);
2640
+ return result === 1;
2641
+ }
2642
+ gotoDescendant(goalDescendantindex) {
2643
+ marshalTreeCursor(this);
2644
+ C._ts_tree_cursor_goto_descendant_wasm(this.tree[0], goalDescendantindex);
2645
+ unmarshalTreeCursor(this);
2646
+ }
2647
+ gotoParent() {
2648
+ marshalTreeCursor(this);
2649
+ const result = C._ts_tree_cursor_goto_parent_wasm(this.tree[0]);
2650
+ unmarshalTreeCursor(this);
2651
+ return result === 1;
2652
+ }
2653
+ }
2654
+ class Language {
2655
+ constructor(internal, address) {
2656
+ assertInternal(internal);
2657
+ this[0] = address;
2658
+ this.types = new Array(C._ts_language_symbol_count(this[0]));
2659
+ for (let i = 0, n = this.types.length; i < n; i++) {
2660
+ if (C._ts_language_symbol_type(this[0], i) < 2) {
2661
+ this.types[i] = UTF8ToString(C._ts_language_symbol_name(this[0], i));
2662
+ }
2663
+ }
2664
+ this.fields = new Array(C._ts_language_field_count(this[0]) + 1);
2665
+ for (let i = 0, n = this.fields.length; i < n; i++) {
2666
+ const fieldName = C._ts_language_field_name_for_id(this[0], i);
2667
+ if (fieldName !== 0) {
2668
+ this.fields[i] = UTF8ToString(fieldName);
2669
+ } else {
2670
+ this.fields[i] = null;
2671
+ }
2672
+ }
2673
+ }
2674
+ get version() {
2675
+ return C._ts_language_version(this[0]);
2676
+ }
2677
+ get fieldCount() {
2678
+ return this.fields.length - 1;
2679
+ }
2680
+ get stateCount() {
2681
+ return C._ts_language_state_count(this[0]);
2682
+ }
2683
+ fieldIdForName(fieldName) {
2684
+ const result = this.fields.indexOf(fieldName);
2685
+ if (result !== -1) {
2686
+ return result;
2687
+ } else {
2688
+ return null;
2689
+ }
2690
+ }
2691
+ fieldNameForId(fieldId) {
2692
+ return this.fields[fieldId] || null;
2693
+ }
2694
+ idForNodeType(type, named) {
2695
+ const typeLength = lengthBytesUTF8(type);
2696
+ const typeAddress = C._malloc(typeLength + 1);
2697
+ stringToUTF8(type, typeAddress, typeLength + 1);
2698
+ const result = C._ts_language_symbol_for_name(this[0], typeAddress, typeLength, named);
2699
+ C._free(typeAddress);
2700
+ return result || null;
2701
+ }
2702
+ get nodeTypeCount() {
2703
+ return C._ts_language_symbol_count(this[0]);
2704
+ }
2705
+ nodeTypeForId(typeId) {
2706
+ const name = C._ts_language_symbol_name(this[0], typeId);
2707
+ return name ? UTF8ToString(name) : null;
2708
+ }
2709
+ nodeTypeIsNamed(typeId) {
2710
+ return C._ts_language_type_is_named_wasm(this[0], typeId) ? true : false;
2711
+ }
2712
+ nodeTypeIsVisible(typeId) {
2713
+ return C._ts_language_type_is_visible_wasm(this[0], typeId) ? true : false;
2714
+ }
2715
+ nextState(stateId, typeId) {
2716
+ return C._ts_language_next_state(this[0], stateId, typeId);
2717
+ }
2718
+ lookaheadIterator(stateId) {
2719
+ const address = C._ts_lookahead_iterator_new(this[0], stateId);
2720
+ if (address) return new LookaheadIterable(INTERNAL, address, this);
2721
+ return null;
2722
+ }
2723
+ query(source) {
2724
+ const sourceLength = lengthBytesUTF8(source);
2725
+ const sourceAddress = C._malloc(sourceLength + 1);
2726
+ stringToUTF8(source, sourceAddress, sourceLength + 1);
2727
+ const address = C._ts_query_new(this[0], sourceAddress, sourceLength, TRANSFER_BUFFER, TRANSFER_BUFFER + SIZE_OF_INT);
2728
+ if (!address) {
2729
+ const errorId = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2730
+ const errorByte = getValue(TRANSFER_BUFFER, "i32");
2731
+ const errorIndex = UTF8ToString(sourceAddress, errorByte).length;
2732
+ const suffix = source.substr(errorIndex, 100).split("\n")[0];
2733
+ let word = suffix.match(QUERY_WORD_REGEX)[0];
2734
+ let error;
2735
+ switch (errorId) {
2736
+ case 2:
2737
+ error = new RangeError(`Bad node name '${word}'`);
2738
+ break;
2739
+
2740
+ case 3:
2741
+ error = new RangeError(`Bad field name '${word}'`);
2742
+ break;
2743
+
2744
+ case 4:
2745
+ error = new RangeError(`Bad capture name @${word}`);
2746
+ break;
2747
+
2748
+ case 5:
2749
+ error = new TypeError(`Bad pattern structure at offset ${errorIndex}: '${suffix}'...`);
2750
+ word = "";
2751
+ break;
2752
+
2753
+ default:
2754
+ error = new SyntaxError(`Bad syntax at offset ${errorIndex}: '${suffix}'...`);
2755
+ word = "";
2756
+ break;
2757
+ }
2758
+ error.index = errorIndex;
2759
+ error.length = word.length;
2760
+ C._free(sourceAddress);
2761
+ throw error;
2762
+ }
2763
+ const stringCount = C._ts_query_string_count(address);
2764
+ const captureCount = C._ts_query_capture_count(address);
2765
+ const patternCount = C._ts_query_pattern_count(address);
2766
+ const captureNames = new Array(captureCount);
2767
+ const stringValues = new Array(stringCount);
2768
+ for (let i = 0; i < captureCount; i++) {
2769
+ const nameAddress = C._ts_query_capture_name_for_id(address, i, TRANSFER_BUFFER);
2770
+ const nameLength = getValue(TRANSFER_BUFFER, "i32");
2771
+ captureNames[i] = UTF8ToString(nameAddress, nameLength);
2772
+ }
2773
+ for (let i = 0; i < stringCount; i++) {
2774
+ const valueAddress = C._ts_query_string_value_for_id(address, i, TRANSFER_BUFFER);
2775
+ const nameLength = getValue(TRANSFER_BUFFER, "i32");
2776
+ stringValues[i] = UTF8ToString(valueAddress, nameLength);
2777
+ }
2778
+ const setProperties = new Array(patternCount);
2779
+ const assertedProperties = new Array(patternCount);
2780
+ const refutedProperties = new Array(patternCount);
2781
+ const predicates = new Array(patternCount);
2782
+ const textPredicates = new Array(patternCount);
2783
+ for (let i = 0; i < patternCount; i++) {
2784
+ const predicatesAddress = C._ts_query_predicates_for_pattern(address, i, TRANSFER_BUFFER);
2785
+ const stepCount = getValue(TRANSFER_BUFFER, "i32");
2786
+ predicates[i] = [];
2787
+ textPredicates[i] = [];
2788
+ const steps = [];
2789
+ let stepAddress = predicatesAddress;
2790
+ for (let j = 0; j < stepCount; j++) {
2791
+ const stepType = getValue(stepAddress, "i32");
2792
+ stepAddress += SIZE_OF_INT;
2793
+ const stepValueId = getValue(stepAddress, "i32");
2794
+ stepAddress += SIZE_OF_INT;
2795
+ if (stepType === PREDICATE_STEP_TYPE_CAPTURE) {
2796
+ steps.push({
2797
+ type: "capture",
2798
+ name: captureNames[stepValueId]
2799
+ });
2800
+ } else if (stepType === PREDICATE_STEP_TYPE_STRING) {
2801
+ steps.push({
2802
+ type: "string",
2803
+ value: stringValues[stepValueId]
2804
+ });
2805
+ } else if (steps.length > 0) {
2806
+ if (steps[0].type !== "string") {
2807
+ throw new Error("Predicates must begin with a literal value");
2808
+ }
2809
+ const operator = steps[0].value;
2810
+ let isPositive = true;
2811
+ let matchAll = true;
2812
+ let captureName;
2813
+ switch (operator) {
2814
+ case "any-not-eq?":
2815
+ case "not-eq?":
2816
+ isPositive = false;
2817
+
2818
+ case "any-eq?":
2819
+ case "eq?":
2820
+ if (steps.length !== 3) {
2821
+ throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length - 1}`);
2822
+ }
2823
+ if (steps[1].type !== "capture") {
2824
+ throw new Error(`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}"`);
2825
+ }
2826
+ matchAll = !operator.startsWith("any-");
2827
+ if (steps[2].type === "capture") {
2828
+ const captureName1 = steps[1].name;
2829
+ const captureName2 = steps[2].name;
2830
+ textPredicates[i].push(captures => {
2831
+ const nodes1 = [];
2832
+ const nodes2 = [];
2833
+ for (const c of captures) {
2834
+ if (c.name === captureName1) nodes1.push(c.node);
2835
+ if (c.name === captureName2) nodes2.push(c.node);
2836
+ }
2837
+ const compare = (n1, n2, positive) => positive ? n1.text === n2.text : n1.text !== n2.text;
2838
+ return matchAll ? nodes1.every(n1 => nodes2.some(n2 => compare(n1, n2, isPositive))) : nodes1.some(n1 => nodes2.some(n2 => compare(n1, n2, isPositive)));
2839
+ });
2840
+ } else {
2841
+ captureName = steps[1].name;
2842
+ const stringValue = steps[2].value;
2843
+ const matches = n => n.text === stringValue;
2844
+ const doesNotMatch = n => n.text !== stringValue;
2845
+ textPredicates[i].push(captures => {
2846
+ const nodes = [];
2847
+ for (const c of captures) {
2848
+ if (c.name === captureName) nodes.push(c.node);
2849
+ }
2850
+ const test = isPositive ? matches : doesNotMatch;
2851
+ return matchAll ? nodes.every(test) : nodes.some(test);
2852
+ });
2853
+ }
2854
+ break;
2855
+
2856
+ case "any-not-match?":
2857
+ case "not-match?":
2858
+ isPositive = false;
2859
+
2860
+ case "any-match?":
2861
+ case "match?":
2862
+ if (steps.length !== 3) {
2863
+ throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length - 1}.`);
2864
+ }
2865
+ if (steps[1].type !== "capture") {
2866
+ throw new Error(`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`);
2867
+ }
2868
+ if (steps[2].type !== "string") {
2869
+ throw new Error(`Second argument of \`#${operator}\` predicate must be a string. Got @${steps[2].value}.`);
2870
+ }
2871
+ captureName = steps[1].name;
2872
+ const regex = new RegExp(steps[2].value);
2873
+ matchAll = !operator.startsWith("any-");
2874
+ textPredicates[i].push(captures => {
2875
+ const nodes = [];
2876
+ for (const c of captures) {
2877
+ if (c.name === captureName) nodes.push(c.node.text);
2878
+ }
2879
+ const test = (text, positive) => positive ? regex.test(text) : !regex.test(text);
2880
+ if (nodes.length === 0) return !isPositive;
2881
+ return matchAll ? nodes.every(text => test(text, isPositive)) : nodes.some(text => test(text, isPositive));
2882
+ });
2883
+ break;
2884
+
2885
+ case "set!":
2886
+ if (steps.length < 2 || steps.length > 3) {
2887
+ throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`);
2888
+ }
2889
+ if (steps.some(s => s.type !== "string")) {
2890
+ throw new Error(`Arguments to \`#set!\` predicate must be a strings.".`);
2891
+ }
2892
+ if (!setProperties[i]) setProperties[i] = {};
2893
+ setProperties[i][steps[1].value] = steps[2] ? steps[2].value : null;
2894
+ break;
2895
+
2896
+ case "is?":
2897
+ case "is-not?":
2898
+ if (steps.length < 2 || steps.length > 3) {
2899
+ throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`);
2900
+ }
2901
+ if (steps.some(s => s.type !== "string")) {
2902
+ throw new Error(`Arguments to \`#${operator}\` predicate must be a strings.".`);
2903
+ }
2904
+ const properties = operator === "is?" ? assertedProperties : refutedProperties;
2905
+ if (!properties[i]) properties[i] = {};
2906
+ properties[i][steps[1].value] = steps[2] ? steps[2].value : null;
2907
+ break;
2908
+
2909
+ case "not-any-of?":
2910
+ isPositive = false;
2911
+
2912
+ case "any-of?":
2913
+ if (steps.length < 2) {
2914
+ throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected at least 1. Got ${steps.length - 1}.`);
2915
+ }
2916
+ if (steps[1].type !== "capture") {
2917
+ throw new Error(`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`);
2918
+ }
2919
+ for (let i = 2; i < steps.length; i++) {
2920
+ if (steps[i].type !== "string") {
2921
+ throw new Error(`Arguments to \`#${operator}\` predicate must be a strings.".`);
2922
+ }
2923
+ }
2924
+ captureName = steps[1].name;
2925
+ const values = steps.slice(2).map(s => s.value);
2926
+ textPredicates[i].push(captures => {
2927
+ const nodes = [];
2928
+ for (const c of captures) {
2929
+ if (c.name === captureName) nodes.push(c.node.text);
2930
+ }
2931
+ if (nodes.length === 0) return !isPositive;
2932
+ return nodes.every(text => values.includes(text)) === isPositive;
2933
+ });
2934
+ break;
2935
+
2936
+ default:
2937
+ predicates[i].push({
2938
+ operator: operator,
2939
+ operands: steps.slice(1)
2940
+ });
2941
+ }
2942
+ steps.length = 0;
2943
+ }
2944
+ }
2945
+ Object.freeze(setProperties[i]);
2946
+ Object.freeze(assertedProperties[i]);
2947
+ Object.freeze(refutedProperties[i]);
2948
+ }
2949
+ C._free(sourceAddress);
2950
+ return new Query(INTERNAL, address, captureNames, textPredicates, predicates, Object.freeze(setProperties), Object.freeze(assertedProperties), Object.freeze(refutedProperties));
2951
+ }
2952
+ static load(input) {
2953
+ let bytes;
2954
+ if (input instanceof Uint8Array) {
2955
+ bytes = Promise.resolve(input);
2956
+ } else {
2957
+ const url = input;
2958
+ if (typeof process !== "undefined" && process.versions && process.versions.node) {
2959
+ const fs = require("fs");
2960
+ bytes = Promise.resolve(fs.readFileSync(url));
2961
+ } else {
2962
+ bytes = fetch(url).then(response => response.arrayBuffer().then(buffer => {
2963
+ if (response.ok) {
2964
+ return new Uint8Array(buffer);
2965
+ } else {
2966
+ const body = new TextDecoder("utf-8").decode(buffer);
2967
+ throw new Error(`Language.load failed with status ${response.status}.\n\n${body}`);
2968
+ }
2969
+ }));
2970
+ }
2971
+ }
2972
+ return bytes.then(bytes => loadWebAssemblyModule(bytes, {
2973
+ loadAsync: true
2974
+ })).then(mod => {
2975
+ const symbolNames = Object.keys(mod);
2976
+ const functionName = symbolNames.find(key => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
2977
+ if (!functionName) {
2978
+ console.log(`Couldn't find language function in WASM file. Symbols:\n${JSON.stringify(symbolNames, null, 2)}`);
2979
+ }
2980
+ const languageAddress = mod[functionName]();
2981
+ return new Language(INTERNAL, languageAddress);
2982
+ });
2983
+ }
2984
+ }
2985
+ class LookaheadIterable {
2986
+ constructor(internal, address, language) {
2987
+ assertInternal(internal);
2988
+ this[0] = address;
2989
+ this.language = language;
2990
+ }
2991
+ get currentTypeId() {
2992
+ return C._ts_lookahead_iterator_current_symbol(this[0]);
2993
+ }
2994
+ get currentType() {
2995
+ return this.language.types[this.currentTypeId] || "ERROR";
2996
+ }
2997
+ delete() {
2998
+ C._ts_lookahead_iterator_delete(this[0]);
2999
+ this[0] = 0;
3000
+ }
3001
+ resetState(stateId) {
3002
+ return C._ts_lookahead_iterator_reset_state(this[0], stateId);
3003
+ }
3004
+ reset(language, stateId) {
3005
+ if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
3006
+ this.language = language;
3007
+ return true;
3008
+ }
3009
+ return false;
3010
+ }
3011
+ [Symbol.iterator]() {
3012
+ const self = this;
3013
+ return {
3014
+ next() {
3015
+ if (C._ts_lookahead_iterator_next(self[0])) {
3016
+ return {
3017
+ done: false,
3018
+ value: self.currentType
3019
+ };
3020
+ }
3021
+ return {
3022
+ done: true,
3023
+ value: ""
3024
+ };
3025
+ }
3026
+ };
3027
+ }
3028
+ }
3029
+ class Query {
3030
+ constructor(internal, address, captureNames, textPredicates, predicates, setProperties, assertedProperties, refutedProperties) {
3031
+ assertInternal(internal);
3032
+ this[0] = address;
3033
+ this.captureNames = captureNames;
3034
+ this.textPredicates = textPredicates;
3035
+ this.predicates = predicates;
3036
+ this.setProperties = setProperties;
3037
+ this.assertedProperties = assertedProperties;
3038
+ this.refutedProperties = refutedProperties;
3039
+ this.exceededMatchLimit = false;
3040
+ }
3041
+ delete() {
3042
+ C._ts_query_delete(this[0]);
3043
+ this[0] = 0;
3044
+ }
3045
+ matches(node, {startPosition: startPosition = ZERO_POINT, endPosition: endPosition = ZERO_POINT, startIndex: startIndex = 0, endIndex: endIndex = 0, matchLimit: matchLimit = 4294967295, maxStartDepth: maxStartDepth = 4294967295} = {}) {
3046
+ if (typeof matchLimit !== "number") {
3047
+ throw new Error("Arguments must be numbers");
3048
+ }
3049
+ marshalNode(node);
3050
+ C._ts_query_matches_wasm(this[0], node.tree[0], startPosition.row, startPosition.column, endPosition.row, endPosition.column, startIndex, endIndex, matchLimit, maxStartDepth);
3051
+ const rawCount = getValue(TRANSFER_BUFFER, "i32");
3052
+ const startAddress = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3053
+ const didExceedMatchLimit = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
3054
+ const result = new Array(rawCount);
3055
+ this.exceededMatchLimit = Boolean(didExceedMatchLimit);
3056
+ let filteredCount = 0;
3057
+ let address = startAddress;
3058
+ for (let i = 0; i < rawCount; i++) {
3059
+ const pattern = getValue(address, "i32");
3060
+ address += SIZE_OF_INT;
3061
+ const captureCount = getValue(address, "i32");
3062
+ address += SIZE_OF_INT;
3063
+ const captures = new Array(captureCount);
3064
+ address = unmarshalCaptures(this, node.tree, address, captures);
3065
+ if (this.textPredicates[pattern].every(p => p(captures))) {
3066
+ result[filteredCount] = {
3067
+ pattern: pattern,
3068
+ captures: captures
3069
+ };
3070
+ const setProperties = this.setProperties[pattern];
3071
+ if (setProperties) result[filteredCount].setProperties = setProperties;
3072
+ const assertedProperties = this.assertedProperties[pattern];
3073
+ if (assertedProperties) result[filteredCount].assertedProperties = assertedProperties;
3074
+ const refutedProperties = this.refutedProperties[pattern];
3075
+ if (refutedProperties) result[filteredCount].refutedProperties = refutedProperties;
3076
+ filteredCount++;
3077
+ }
3078
+ }
3079
+ result.length = filteredCount;
3080
+ C._free(startAddress);
3081
+ return result;
3082
+ }
3083
+ captures(node, {startPosition: startPosition = ZERO_POINT, endPosition: endPosition = ZERO_POINT, startIndex: startIndex = 0, endIndex: endIndex = 0, matchLimit: matchLimit = 4294967295, maxStartDepth: maxStartDepth = 4294967295} = {}) {
3084
+ if (typeof matchLimit !== "number") {
3085
+ throw new Error("Arguments must be numbers");
3086
+ }
3087
+ marshalNode(node);
3088
+ C._ts_query_captures_wasm(this[0], node.tree[0], startPosition.row, startPosition.column, endPosition.row, endPosition.column, startIndex, endIndex, matchLimit, maxStartDepth);
3089
+ const count = getValue(TRANSFER_BUFFER, "i32");
3090
+ const startAddress = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3091
+ const didExceedMatchLimit = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
3092
+ const result = [];
3093
+ this.exceededMatchLimit = Boolean(didExceedMatchLimit);
3094
+ const captures = [];
3095
+ let address = startAddress;
3096
+ for (let i = 0; i < count; i++) {
3097
+ const pattern = getValue(address, "i32");
3098
+ address += SIZE_OF_INT;
3099
+ const captureCount = getValue(address, "i32");
3100
+ address += SIZE_OF_INT;
3101
+ const captureIndex = getValue(address, "i32");
3102
+ address += SIZE_OF_INT;
3103
+ captures.length = captureCount;
3104
+ address = unmarshalCaptures(this, node.tree, address, captures);
3105
+ if (this.textPredicates[pattern].every(p => p(captures))) {
3106
+ const capture = captures[captureIndex];
3107
+ const setProperties = this.setProperties[pattern];
3108
+ if (setProperties) capture.setProperties = setProperties;
3109
+ const assertedProperties = this.assertedProperties[pattern];
3110
+ if (assertedProperties) capture.assertedProperties = assertedProperties;
3111
+ const refutedProperties = this.refutedProperties[pattern];
3112
+ if (refutedProperties) capture.refutedProperties = refutedProperties;
3113
+ result.push(capture);
3114
+ }
3115
+ }
3116
+ C._free(startAddress);
3117
+ return result;
3118
+ }
3119
+ predicatesForPattern(patternIndex) {
3120
+ return this.predicates[patternIndex];
3121
+ }
3122
+ disableCapture(captureName) {
3123
+ const captureNameLength = lengthBytesUTF8(captureName);
3124
+ const captureNameAddress = C._malloc(captureNameLength + 1);
3125
+ stringToUTF8(captureName, captureNameAddress, captureNameLength + 1);
3126
+ C._ts_query_disable_capture(this[0], captureNameAddress, captureNameLength);
3127
+ C._free(captureNameAddress);
3128
+ }
3129
+ didExceedMatchLimit() {
3130
+ return this.exceededMatchLimit;
3131
+ }
3132
+ }
3133
+ function getText(tree, startIndex, endIndex) {
3134
+ const length = endIndex - startIndex;
3135
+ let result = tree.textCallback(startIndex, null, endIndex);
3136
+ startIndex += result.length;
3137
+ while (startIndex < endIndex) {
3138
+ const string = tree.textCallback(startIndex, null, endIndex);
3139
+ if (string && string.length > 0) {
3140
+ startIndex += string.length;
3141
+ result += string;
3142
+ } else {
3143
+ break;
3144
+ }
3145
+ }
3146
+ if (startIndex > endIndex) {
3147
+ result = result.slice(0, length);
3148
+ }
3149
+ return result;
3150
+ }
3151
+ function unmarshalCaptures(query, tree, address, result) {
3152
+ for (let i = 0, n = result.length; i < n; i++) {
3153
+ const captureIndex = getValue(address, "i32");
3154
+ address += SIZE_OF_INT;
3155
+ const node = unmarshalNode(tree, address);
3156
+ address += SIZE_OF_NODE;
3157
+ result[i] = {
3158
+ name: query.captureNames[captureIndex],
3159
+ node: node
3160
+ };
3161
+ }
3162
+ return address;
3163
+ }
3164
+ function assertInternal(x) {
3165
+ if (x !== INTERNAL) throw new Error("Illegal constructor");
3166
+ }
3167
+ function isPoint(point) {
3168
+ return (point && typeof point.row === "number" && typeof point.column === "number");
3169
+ }
3170
+ function marshalNode(node) {
3171
+ let address = TRANSFER_BUFFER;
3172
+ setValue(address, node.id, "i32");
3173
+ address += SIZE_OF_INT;
3174
+ setValue(address, node.startIndex, "i32");
3175
+ address += SIZE_OF_INT;
3176
+ setValue(address, node.startPosition.row, "i32");
3177
+ address += SIZE_OF_INT;
3178
+ setValue(address, node.startPosition.column, "i32");
3179
+ address += SIZE_OF_INT;
3180
+ setValue(address, node[0], "i32");
3181
+ }
3182
+ function unmarshalNode(tree, address = TRANSFER_BUFFER) {
3183
+ const id = getValue(address, "i32");
3184
+ address += SIZE_OF_INT;
3185
+ if (id === 0) return null;
3186
+ const index = getValue(address, "i32");
3187
+ address += SIZE_OF_INT;
3188
+ const row = getValue(address, "i32");
3189
+ address += SIZE_OF_INT;
3190
+ const column = getValue(address, "i32");
3191
+ address += SIZE_OF_INT;
3192
+ const other = getValue(address, "i32");
3193
+ const result = new Node(INTERNAL, tree);
3194
+ result.id = id;
3195
+ result.startIndex = index;
3196
+ result.startPosition = {
3197
+ row: row,
3198
+ column: column
3199
+ };
3200
+ result[0] = other;
3201
+ return result;
3202
+ }
3203
+ function marshalTreeCursor(cursor, address = TRANSFER_BUFFER) {
3204
+ setValue(address + 0 * SIZE_OF_INT, cursor[0], "i32");
3205
+ setValue(address + 1 * SIZE_OF_INT, cursor[1], "i32");
3206
+ setValue(address + 2 * SIZE_OF_INT, cursor[2], "i32");
3207
+ setValue(address + 3 * SIZE_OF_INT, cursor[3], "i32");
3208
+ }
3209
+ function unmarshalTreeCursor(cursor) {
3210
+ cursor[0] = getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
3211
+ cursor[1] = getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
3212
+ cursor[2] = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
3213
+ cursor[3] = getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
3214
+ }
3215
+ function marshalPoint(address, point) {
3216
+ setValue(address, point.row, "i32");
3217
+ setValue(address + SIZE_OF_INT, point.column, "i32");
3218
+ }
3219
+ function unmarshalPoint(address) {
3220
+ const result = {
3221
+ row: getValue(address, "i32") >>> 0,
3222
+ column: getValue(address + SIZE_OF_INT, "i32") >>> 0
3223
+ };
3224
+ return result;
3225
+ }
3226
+ function marshalRange(address, range) {
3227
+ marshalPoint(address, range.startPosition);
3228
+ address += SIZE_OF_POINT;
3229
+ marshalPoint(address, range.endPosition);
3230
+ address += SIZE_OF_POINT;
3231
+ setValue(address, range.startIndex, "i32");
3232
+ address += SIZE_OF_INT;
3233
+ setValue(address, range.endIndex, "i32");
3234
+ address += SIZE_OF_INT;
3235
+ }
3236
+ function unmarshalRange(address) {
3237
+ const result = {};
3238
+ result.startPosition = unmarshalPoint(address);
3239
+ address += SIZE_OF_POINT;
3240
+ result.endPosition = unmarshalPoint(address);
3241
+ address += SIZE_OF_POINT;
3242
+ result.startIndex = getValue(address, "i32") >>> 0;
3243
+ address += SIZE_OF_INT;
3244
+ result.endIndex = getValue(address, "i32") >>> 0;
3245
+ return result;
3246
+ }
3247
+ function marshalEdit(edit) {
3248
+ let address = TRANSFER_BUFFER;
3249
+ marshalPoint(address, edit.startPosition);
3250
+ address += SIZE_OF_POINT;
3251
+ marshalPoint(address, edit.oldEndPosition);
3252
+ address += SIZE_OF_POINT;
3253
+ marshalPoint(address, edit.newEndPosition);
3254
+ address += SIZE_OF_POINT;
3255
+ setValue(address, edit.startIndex, "i32");
3256
+ address += SIZE_OF_INT;
3257
+ setValue(address, edit.oldEndIndex, "i32");
3258
+ address += SIZE_OF_INT;
3259
+ setValue(address, edit.newEndIndex, "i32");
3260
+ address += SIZE_OF_INT;
3261
+ }
3262
+ // end include: /mnt/vss/_work/1/s/tree-sitter/lib/binding_web/binding.js
3263
+ // include: /mnt/vss/_work/1/s/tree-sitter/lib/binding_web/suffix.js
3264
+ for (const name of Object.getOwnPropertyNames(ParserImpl.prototype)) {
3265
+ Object.defineProperty(Parser.prototype, name, {
3266
+ value: ParserImpl.prototype[name],
3267
+ enumerable: false,
3268
+ writable: false
3269
+ });
3270
+ }
3271
+ Parser.Language = Language;
3272
+ Module.onRuntimeInitialized = () => {
3273
+ ParserImpl.init();
3274
+ resolveInitPromise();
3275
+ };
3276
+ });
3277
+ }
3278
+ }
3279
+ return Parser;
3280
+ }();
3281
+
3282
+ if (typeof exports === "object") {
3283
+ module.exports = TreeSitter;
3284
+ }
8
3285
 
9
3286
 
10
3287
  return { Parser: TreeSitter };