2 lines
43 KiB
JavaScript
2 lines
43 KiB
JavaScript
var Module=void 0!==Module?Module:{};!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():window.TreeSitter=t()}(0,function(){var e,t={};for(e in Module)Module.hasOwnProperty(e)&&(t[e]=Module[e]);var n,r,o=[],u="./this.program",i=function(e,t){throw t},s=!1,a=!1,l=!1;s="object"==typeof window,a="function"==typeof importScripts,n="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,l=n&&!s&&!a,r=!s&&!l&&!a;var _,d,c,f,p="";l?(p=__dirname+"/",_=function(e,t){var n;return c||(c=require("fs")),f||(f=require("path")),e=f.normalize(e),n=c.readFileSync(e),t?n:n.toString()},d=function(e){var t=_(e,!0);return t.buffer||(t=new Uint8Array(t)),O(t.buffer),t},process.argv.length>1&&(u=process.argv[1].replace(/\\/g,"/")),o=process.argv.slice(2),"undefined"!=typeof module&&(module.exports=Module),process.on("uncaughtException",function(e){if(!(e instanceof Qe))throw e}),process.on("unhandledRejection",ye),i=function(e){process.exit(e)},Module.inspect=function(){return"[Emscripten Module object]"}):r?("undefined"!=typeof read&&(_=function(e){return read(e)}),d=function(e){var t;return"function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(O("object"==typeof(t=read(e,"binary"))),t)},"undefined"!=typeof scriptArgs?o=scriptArgs:void 0!==arguments&&(o=arguments),"function"==typeof quit&&(i=function(e){quit(e)}),"undefined"!=typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print)):(s||a)&&(a?p=self.location.href:document.currentScript&&(p=document.currentScript.src),p=0!==p.indexOf("blob:")?p.substr(0,p.lastIndexOf("/")+1):"",_=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},a&&(d=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),function(e,t,n){var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=function(){200==r.status||0==r.status&&r.response?t(r.response):n()},r.onerror=n,r.send(null)});var m=Module.print||console.log.bind(console),h=Module.printErr||console.warn.bind(console);for(e in t)t.hasOwnProperty(e)&&(Module[e]=t[e]);t=null,Module.arguments&&(o=Module.arguments),Module.thisProgram&&(u=Module.thisProgram),Module.quit&&(i=Module.quit);var M=16;function g(e){var t=V[te>>2],n=t+e+15&-16;return n>Se()&&ye(),V[te>>2]=n,t}function y(e,t){return t||(t=M),Math.ceil(e/t)*t}function w(e){switch(e){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:if("*"===e[e.length-1])return 4;if("i"===e[0]){var t=parseInt(e.substr(1));return O(t%8==0,"getNativeTypeSize invalid bits "+t+", type "+e),t/8}return 0}}var b={"f64-rem":function(e,t){return e%t},debugger:function(){}},v={nextHandle:1,loadedLibs:{"-1":{refcount:1/0,name:"__self__",module:Module,global:!0}},loadedLibNames:{__self__:-1}};function E(e,t){t=t||{global:!0,nodelete:!0};var n,r=v.loadedLibNames[e];if(r)return n=v.loadedLibs[r],t.global&&!n.global&&(n.global=!0,"loading"!==n.module&&s(n.module)),t.nodelete&&n.refcount!==1/0&&(n.refcount=1/0),n.refcount++,t.loadAsync?Promise.resolve(r):r;function o(){if(t.fs){var n=t.fs.readFile(e,{encoding:"binary"});return n instanceof Uint8Array||(n=new Uint8Array(lib_data)),t.loadAsync?Promise.resolve(n):n}return t.loadAsync?(r=e,fetch(r,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load binary file at '"+r+"'";return e.arrayBuffer()}).then(function(e){return new Uint8Array(e)})):d(e);var r}function u(e){return I(e,t)}function i(){if(void 0!==Module.preloadedWasm&&void 0!==Module.preloadedWasm[e]){var n=Module.preloadedWasm[e];return t.loadAsync?Promise.resolve(n):n}return t.loadAsync?o().then(function(e){return u(e)}):u(o())}function s(e){for(var t in e)if(e.hasOwnProperty(t)){var n=t;"_"===t[0]&&(Module.hasOwnProperty(n)||(Module[n]=e[t]))}}function a(e){n.global&&s(e),n.module=e}return r=v.nextHandle++,n={refcount:t.nodelete?1/0:1,name:e,module:"loading",global:t.global},v.loadedLibNames[e]=r,v.loadedLibs[r]=n,t.loadAsync?i().then(function(e){return a(e),r}):(a(i()),r)}function A(e,t,n,r){var o={};for(var u in e){var i=e[u];"object"==typeof i&&(i=i.value),"number"==typeof i&&(i+=t),o[u]=i,r&&(r[u]=i)}return o}function I(e,t){O(1836278016==new Uint32Array(new Uint8Array(e.subarray(0,24)).buffer)[0],"need to see wasm magic number"),O(0===e[8],"need the dylink section to be first");var n=9;function r(){for(var t=0,r=1;;){var o=e[n++];if(t+=(127&o)*r,r*=128,!(128&o))break}return t}r();O(6===e[n]),O(e[++n]==="d".charCodeAt(0)),O(e[++n]==="y".charCodeAt(0)),O(e[++n]==="l".charCodeAt(0)),O(e[++n]==="i".charCodeAt(0)),O(e[++n]==="n".charCodeAt(0)),O(e[++n]==="k".charCodeAt(0)),n++;for(var o=r(),u=r(),i=r(),s=r(),a=r(),l=[],_=0;_<a;++_){var d=r(),c=e.subarray(n,n+d);n+=d;var f=j(c,0);l.push(f)}function p(){u=Math.pow(2,u),s=Math.pow(2,s),u=Math.max(u,M);for(var n=y($(o+u),u),r=n;r<n+o;++r)G[r]=0;var a=Ze,l=q,_=l.length,d=l;l.grow(i),O(l===d);for(r=n;r<n+o;r++)G[r]=0;for(r=_;r<_+i;r++)l.set(r,null);var c={},f=function(e,t){var n=Module[e];return n||(n=c[e]),n};for(var p in Module)p in a||(a[p]=Module[p]);var m={global:{NaN:NaN,Infinity:1/0},"global.Math":Math,env:new Proxy(a,{get:function(e,t){switch(t){case"__memory_base":case"gb":return n;case"__table_base":case"fb":return _}if(t in e)return e[t];if(t.startsWith("g$")){var r=t.substr(2);return e[t]=function(){return f(r)}}if(t.startsWith("fp$")){var o=t.split("$");O(3==o.length);r=o[1];var u=o[2],i=0;return e[t]=function(){if(!i){var e=f(r);i=N(e,u)}return i}}return t.startsWith("invoke_")?e[t]=invoke_X:e[t]=function(){return f(t).apply(null,arguments)}}}),asm2wasm:b};function h(e,t){var r=A(e.exports,n,0,t),o=r.__post_instantiate;return o&&(ae?o():ue.push(o)),r}return t.loadAsync?WebAssembly.instantiate(e,m).then(function(e){return h(e.instance,c)}):h(new WebAssembly.Instance(new WebAssembly.Module(e),m),c)}return t.loadAsync?Promise.all(l.map(function(e){return E(e,t)})).then(function(){return p()}):(l.forEach(function(e){E(e,t)}),p())}function C(e,t){var n=q,r=n.length;try{n.grow(1)}catch(e){if(!e instanceof RangeError)throw e;throw"Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH."}try{n.set(r,e)}catch(u){if(!u instanceof TypeError)throw u;O(void 0!==t,"Missing signature argument to addFunction");var o=function(e,t){var n=[1,0,1,96],r=t.slice(0,1),o=t.slice(1),u={i:127,j:126,f:125,d:124};n.push(o.length);for(var i=0;i<o.length;++i)n.push(u[o[i]]);"v"==r?n.push(0):n=n.concat([1,u[r]]),n[1]=n.length-2;var s=new Uint8Array([0,97,115,109,1,0,0,0].concat(n,[2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0])),a=new WebAssembly.Module(s);return new WebAssembly.Instance(a,{e:{f:e}}).exports.f}(e,t);n.set(r,o)}return r}function N(e,t){return C(e,t)}Module.loadWebAssemblyModule=I,Module.registerFunctions=function(e,t){e.forEach(function(e){Module["FUNCTION_TABLE_"+e]||(Module["FUNCTION_TABLE_"+e]=[])});var n=alignFunctionTables(),r=alignFunctionTables(t),o=n+r;e.forEach(function(e){var r=t["FUNCTION_TABLE_"+e],u=Module["FUNCTION_TABLE_"+e];O(r!==u),O(u.length===n);for(var i=0;i<r.length;i++)u.push(r[i]);O(u.length===o)}),O(o===alignFunctionTables())};var x,S,P,k=0,R=1024;function T(e,t,n,r){switch("*"===(n=n||"i8").charAt(n.length-1)&&(n="i32"),n){case"i1":case"i8":G[e>>0]=t;break;case"i16":K[e>>1]=t;break;case"i32":V[e>>2]=t;break;case"i64":Ae=[t>>>0,(Ee=t,+_e(Ee)>=1?Ee>0?(0|fe(+ce(Ee/4294967296),4294967295))>>>0:~~+de((Ee-+(~~Ee>>>0))/4294967296)>>>0:0)],V[e>>2]=Ae[0],V[e+4>>2]=Ae[1];break;case"float":Q[e>>2]=t;break;case"double":Y[e>>3]=t;break;default:ye("invalid type for setValue: "+n)}}function L(e,t,n){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return G[e>>0];case"i16":return K[e>>1];case"i32":case"i64":return V[e>>2];case"float":return Q[e>>2];case"double":return Y[e>>3];default:ye("invalid type for getValue: "+t)}return null}R=y(R,16),Module.wasmBinary&&(x=Module.wasmBinary),Module.noExitRuntime&&(S=Module.noExitRuntime),"object"!=typeof WebAssembly&&h("no native wasm support detected");var q=new WebAssembly.Table({initial:16,element:"anyfunc"}),F=!1;function O(e,t){e||ye("Assertion failed: "+t)}var W=3;function $(e){return ae?ze(e):g(e)}var U="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function j(e,t,n){for(var r=t+n,o=t;e[o]&&!(o>=r);)++o;if(o-t>16&&e.subarray&&U)return U.decode(e.subarray(t,o));for(var u="";t<o;){var i=e[t++];if(128&i){var s=63&e[t++];if(192!=(224&i)){var a=63&e[t++];if((i=224==(240&i)?(15&i)<<12|s<<6|a:(7&i)<<18|s<<12|a<<6|63&e[t++])<65536)u+=String.fromCharCode(i);else{var l=i-65536;u+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else u+=String.fromCharCode((31&i)<<6|s)}else u+=String.fromCharCode(i)}return u}function D(e,t){return e?j(X,e,t):""}function Z(e,t,n,r){if(!(r>0))return 0;for(var o=n,u=n+r-1,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343)s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i);if(s<=127){if(n>=u)break;t[n++]=s}else if(s<=2047){if(n+1>=u)break;t[n++]=192|s>>6,t[n++]=128|63&s}else if(s<=65535){if(n+2>=u)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|63&s}else{if(n+3>=u)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|63&s}}return t[n]=0,n-o}function B(e){for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);r>=55296&&r<=57343&&(r=65536+((1023&r)<<10)|1023&e.charCodeAt(++n)),r<=127?++t:t+=r<=2047?2:r<=65535?3:4}return t}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");function H(e){var t=B(e)+1,n=Ge(t);return Z(e,G,n,t),n}var z,G,X,K,V,Q,Y;function J(e,t){return e%t>0&&(e+=t-e%t),e}function ee(e){z=e,Module.HEAP8=G=new Int8Array(e),Module.HEAP16=K=new Int16Array(e),Module.HEAP32=V=new Int32Array(e),Module.HEAPU8=X=new Uint8Array(e),Module.HEAPU16=new Uint16Array(e),Module.HEAPU32=new Uint32Array(e),Module.HEAPF32=Q=new Float32Array(e),Module.HEAPF64=Y=new Float64Array(e)}var te=7872,ne=Module.TOTAL_MEMORY||33554432;function re(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var n=t.func;"number"==typeof n?void 0===t.arg?Module.dynCall_v(n):Module.dynCall_vi(n,t.arg):n(void 0===t.arg?null:t.arg)}else t()}}(P=Module.wasmMemory?Module.wasmMemory:new WebAssembly.Memory({initial:ne/65536}))&&(z=P.buffer),ne=z.byteLength,ee(z),V[te>>2]=5250960;var oe=[],ue=[],ie=[],se=[],ae=!1;function le(e){oe.unshift(e)}var _e=Math.abs,de=Math.ceil,ce=Math.floor,fe=Math.min,pe=0,me=null,he=null;function Me(e){pe++,Module.monitorRunDependencies&&Module.monitorRunDependencies(pe)}function ge(e){if(pe--,Module.monitorRunDependencies&&Module.monitorRunDependencies(pe),0==pe&&(null!==me&&(clearInterval(me),me=null),he)){var t=he;he=null,t()}}function ye(e){throw Module.onAbort&&Module.onAbort(e),m(e+=""),h(e),F=!0,1,"abort("+e+"). Build with -s ASSERTIONS=1 for more info."}Module.preloadedImages={},Module.preloadedAudios={},Module.preloadedWasm={},le(function(){if(Module.dynamicLibraries&&Module.dynamicLibraries.length>0&&!d)return Me(),void Promise.all(Module.dynamicLibraries.map(function(e){return E(e,{loadAsync:!0,global:!0,nodelete:!0})})).then(function(){ge()});var e;(e=Module.dynamicLibraries)&&e.forEach(function(e){E(e,{global:!0,nodelete:!0})})});var we="data:application/octet-stream;base64,";function be(e){return String.prototype.startsWith?e.startsWith(we):0===e.indexOf(we)}var ve,Ee,Ae,Ie="tree-sitter.wasm";function Ce(){try{if(x)return new Uint8Array(x);if(d)return d(Ie);throw"both async and sync fetching of the wasm failed"}catch(e){ye(e)}}be(Ie)||(ve=Ie,Ie=Module.locateFile?Module.locateFile(ve,p):p+ve),Module.asm=function(){var e={env:Ze,wasi_unstable:Ze,global:{NaN:NaN,Infinity:1/0},"global.Math":Math,asm2wasm:b};function t(e,t){var n=e.exports;n=A(n,R),Module.asm=n,ge()}function n(e){t(e.instance)}function r(t){return(x||!s&&!a||"function"!=typeof fetch?new Promise(function(e,t){e(Ce())}):fetch(Ie,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+Ie+"'";return e.arrayBuffer()}).catch(function(){return Ce()})).then(function(t){return WebAssembly.instantiate(t,e)}).then(t,function(e){h("failed to asynchronously prepare wasm: "+e),ye(e)})}if(Me(),Module.instantiateWasm)try{return Module.instantiateWasm(e,t)}catch(e){return h("Module.instantiateWasm callback failed with error: "+e),!1}return function(){if(x||"function"!=typeof WebAssembly.instantiateStreaming||be(Ie)||"function"!=typeof fetch)return r(n);fetch(Ie,{credentials:"same-origin"}).then(function(t){return WebAssembly.instantiateStreaming(t,e).then(n,function(e){h("wasm streaming compile failed: "+e),h("falling back to ArrayBuffer instantiation"),r(n)})})}(),{}},ue.push({func:function(){He()}});function Ne(){ye()}function xe(){ye()}function Se(){return G.length}function Pe(e,t,n){if(ht){const e=D(n);ht(e,0!==t)}}Module._abort=Ne,xe=l?function(){var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:"undefined"!=typeof dateNow?dateNow:"object"==typeof performance&&performance&&"function"==typeof performance.now?function(){return performance.now()}:Date.now;var ke=R;function Re(e){return e|=0,mftCall_X(e)}function Te(e){return e|=0,0|mftCall_i(e)}function Le(e,t){return e|=0,t|=0,0|mftCall_ii(e,0|t)}function qe(e,t,n,r,o,u,i){return e|=0,t|=0,n=+n,r|=0,o|=0,u|=0,i|=0,0|mftCall_iidiiii(e,0|t,+n,0|r,0|o,0|u,0|i)}function Fe(e,t,n){return e|=0,t|=0,n|=0,0|mftCall_iii(e,0|t,0|n)}function Oe(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,0|mftCall_iiii(e,0|t,0|n,0|r)}function We(e,t,n,r,o){return e|=0,t|=0,n|=0,r|=0,o|=0,0|mftCall_iiiii(e,0|t,0|n,0|r,0|o)}function $e(e){e|=0,mftCall_v(e)}function Ue(e,t){e|=0,t|=0,mftCall_vi(e,0|t)}function je(e,t,n){e|=0,t|=0,n|=0,mftCall_vii(e,0|t,0|n)}function De(e,t,n,r){e|=0,t|=0,n|=0,r|=0,mftCall_viii(e,0|t,0|n,0|r)}var Ze={d:8080,__memory_base:1024,__table_base:0,h:Ne,i:function(e,t){var n,r;if(0===e)n=Date.now();else{if(1!==e||!(l||"undefined"!=typeof dateNow||"object"==typeof performance&&performance&&"function"==typeof performance.now))return r=28,Module.___errno_location&&(V[Module.___errno_location()>>2]=r),-1;n=xe()}return V[t>>2]=n/1e3|0,V[t+4>>2]=n%1e3*1e3*1e3|0,0},m:Se,l:function(e,t,n){X.set(X.subarray(t,t+n),e)},k:function(e){var t=Se();if(e>2147418112)return!1;for(var n=Math.max(t,16777216);n<e;)n=n<=536870912?J(2*n,65536):Math.min(J((3*n+2147483648)/4,65536),2147418112);return!!function(e){try{return P.grow(e-z.byteLength+65535>>16),ee(P.buffer),1}catch(e){}}(n)},e:function(e){Je(e)},j:function(e,t,n,r,o){var u=mt(t,{row:n,column:r});"string"==typeof u?(T(o,u.length,"i32"),function(e,t,n){if(void 0===n&&(n=2147483647),n<2)return 0;for(var r=(n-=2)<2*e.length?n/2:e.length,o=0;o<r;++o){var u=e.charCodeAt(o);K[t>>1]=u,t+=2}K[t>>1]=0}(u,e,10240)):T(o,0,"i32")},o:ye,c:0,n:function(){if(!Module.fp$_tree_sitter_log_callback$viii){var e=N(Module._tree_sitter_log_callback||Pe,"viii");Module.fp$_tree_sitter_log_callback$viii=e}return Module.fp$_tree_sitter_log_callback$viii},b:ke,f:function(){return k},memory:P,g:function(e){k=e},table:q,a:8064},Be=Module.asm({},Ze,z);Module.asm=Be;Module.__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm=function(){return Module.asm.p.apply(null,arguments)},Module.__ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv=function(){return Module.asm.q.apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm=function(){return Module.asm.r.apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm=function(){return Module.asm.s.apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm=function(){return Module.asm.t.apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc=function(){return Module.asm.u.apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS5_=function(){return Module.asm.v.apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev=function(){return Module.asm.w.apply(null,arguments)},Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw=function(){return Module.asm.x.apply(null,arguments)},Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev=function(){return Module.asm.y.apply(null,arguments)},Module.__ZdlPv=function(){return Module.asm.z.apply(null,arguments)},Module.__Znwm=function(){return Module.asm.A.apply(null,arguments)};var He=Module.__apply_relocations=function(){return Module.asm.B.apply(null,arguments)},ze=(Module._calloc=function(){return Module.asm.C.apply(null,arguments)},Module._free=function(){return Module.asm.D.apply(null,arguments)},Module._iswalnum=function(){return Module.asm.E.apply(null,arguments)},Module._iswalpha=function(){return Module.asm.F.apply(null,arguments)},Module._iswdigit=function(){return Module.asm.G.apply(null,arguments)},Module._iswlower=function(){return Module.asm.H.apply(null,arguments)},Module._iswspace=function(){return Module.asm.I.apply(null,arguments)},Module._malloc=function(){return Module.asm.J.apply(null,arguments)}),Ge=(Module._memchr=function(){return Module.asm.K.apply(null,arguments)},Module._memcmp=function(){return Module.asm.L.apply(null,arguments)},Module._memcpy=function(){return Module.asm.M.apply(null,arguments)},Module._strlen=function(){return Module.asm.N.apply(null,arguments)},Module._towupper=function(){return Module.asm.O.apply(null,arguments)},Module._ts_init=function(){return Module.asm.P.apply(null,arguments)},Module._ts_language_field_count=function(){return Module.asm.Q.apply(null,arguments)},Module._ts_language_field_name_for_id=function(){return Module.asm.R.apply(null,arguments)},Module._ts_language_symbol_count=function(){return Module.asm.S.apply(null,arguments)},Module._ts_language_symbol_name=function(){return Module.asm.T.apply(null,arguments)},Module._ts_language_symbol_type=function(){return Module.asm.U.apply(null,arguments)},Module._ts_language_version=function(){return Module.asm.V.apply(null,arguments)},Module._ts_node_child_by_field_id_wasm=function(){return Module.asm.W.apply(null,arguments)},Module._ts_node_child_count_wasm=function(){return Module.asm.X.apply(null,arguments)},Module._ts_node_child_wasm=function(){return Module.asm.Y.apply(null,arguments)},Module._ts_node_children_wasm=function(){return Module.asm.Z.apply(null,arguments)},Module._ts_node_descendant_for_index_wasm=function(){return Module.asm._.apply(null,arguments)},Module._ts_node_descendant_for_position_wasm=function(){return Module.asm.$.apply(null,arguments)},Module._ts_node_descendants_of_type_wasm=function(){return Module.asm.aa.apply(null,arguments)},Module._ts_node_end_index_wasm=function(){return Module.asm.ba.apply(null,arguments)},Module._ts_node_end_point_wasm=function(){return Module.asm.ca.apply(null,arguments)},Module._ts_node_has_changes_wasm=function(){return Module.asm.da.apply(null,arguments)},Module._ts_node_has_error_wasm=function(){return Module.asm.ea.apply(null,arguments)},Module._ts_node_is_missing_wasm=function(){return Module.asm.fa.apply(null,arguments)},Module._ts_node_is_named_wasm=function(){return Module.asm.ga.apply(null,arguments)},Module._ts_node_named_child_count_wasm=function(){return Module.asm.ha.apply(null,arguments)},Module._ts_node_named_child_wasm=function(){return Module.asm.ia.apply(null,arguments)},Module._ts_node_named_children_wasm=function(){return Module.asm.ja.apply(null,arguments)},Module._ts_node_named_descendant_for_index_wasm=function(){return Module.asm.ka.apply(null,arguments)},Module._ts_node_named_descendant_for_position_wasm=function(){return Module.asm.la.apply(null,arguments)},Module._ts_node_next_named_sibling_wasm=function(){return Module.asm.ma.apply(null,arguments)},Module._ts_node_next_sibling_wasm=function(){return Module.asm.na.apply(null,arguments)},Module._ts_node_parent_wasm=function(){return Module.asm.oa.apply(null,arguments)},Module._ts_node_prev_named_sibling_wasm=function(){return Module.asm.pa.apply(null,arguments)},Module._ts_node_prev_sibling_wasm=function(){return Module.asm.qa.apply(null,arguments)},Module._ts_node_start_index_wasm=function(){return Module.asm.ra.apply(null,arguments)},Module._ts_node_start_point_wasm=function(){return Module.asm.sa.apply(null,arguments)},Module._ts_node_symbol_wasm=function(){return Module.asm.ta.apply(null,arguments)},Module._ts_node_to_string_wasm=function(){return Module.asm.ua.apply(null,arguments)},Module._ts_parser_delete=function(){return Module.asm.va.apply(null,arguments)},Module._ts_parser_enable_logger_wasm=function(){return Module.asm.wa.apply(null,arguments)},Module._ts_parser_new_wasm=function(){return Module.asm.xa.apply(null,arguments)},Module._ts_parser_parse_wasm=function(){return Module.asm.ya.apply(null,arguments)},Module._ts_parser_set_language=function(){return Module.asm.za.apply(null,arguments)},Module._ts_parser_set_timeout_micros=function(){return Module.asm.Aa.apply(null,arguments)},Module._ts_parser_timeout_micros=function(){return Module.asm.Ba.apply(null,arguments)},Module._ts_query_capture_count=function(){return Module.asm.Ca.apply(null,arguments)},Module._ts_query_capture_name_for_id=function(){return Module.asm.Da.apply(null,arguments)},Module._ts_query_captures_wasm=function(){return Module.asm.Ea.apply(null,arguments)},Module._ts_query_delete=function(){return Module.asm.Fa.apply(null,arguments)},Module._ts_query_matches_wasm=function(){return Module.asm.Ga.apply(null,arguments)},Module._ts_query_new=function(){return Module.asm.Ha.apply(null,arguments)},Module._ts_query_pattern_count=function(){return Module.asm.Ia.apply(null,arguments)},Module._ts_query_predicates_for_pattern=function(){return Module.asm.Ja.apply(null,arguments)},Module._ts_query_string_count=function(){return Module.asm.Ka.apply(null,arguments)},Module._ts_query_string_value_for_id=function(){return Module.asm.La.apply(null,arguments)},Module._ts_tree_cursor_current_field_id_wasm=function(){return Module.asm.Ma.apply(null,arguments)},Module._ts_tree_cursor_current_node_id_wasm=function(){return Module.asm.Na.apply(null,arguments)},Module._ts_tree_cursor_current_node_is_missing_wasm=function(){return Module.asm.Oa.apply(null,arguments)},Module._ts_tree_cursor_current_node_is_named_wasm=function(){return Module.asm.Pa.apply(null,arguments)},Module._ts_tree_cursor_current_node_type_id_wasm=function(){return Module.asm.Qa.apply(null,arguments)},Module._ts_tree_cursor_current_node_wasm=function(){return Module.asm.Ra.apply(null,arguments)},Module._ts_tree_cursor_delete_wasm=function(){return Module.asm.Sa.apply(null,arguments)},Module._ts_tree_cursor_end_index_wasm=function(){return Module.asm.Ta.apply(null,arguments)},Module._ts_tree_cursor_end_position_wasm=function(){return Module.asm.Ua.apply(null,arguments)},Module._ts_tree_cursor_goto_first_child_wasm=function(){return Module.asm.Va.apply(null,arguments)},Module._ts_tree_cursor_goto_next_sibling_wasm=function(){return Module.asm.Wa.apply(null,arguments)},Module._ts_tree_cursor_goto_parent_wasm=function(){return Module.asm.Xa.apply(null,arguments)},Module._ts_tree_cursor_new_wasm=function(){return Module.asm.Ya.apply(null,arguments)},Module._ts_tree_cursor_reset_wasm=function(){return Module.asm.Za.apply(null,arguments)},Module._ts_tree_cursor_start_index_wasm=function(){return Module.asm._a.apply(null,arguments)},Module._ts_tree_cursor_start_position_wasm=function(){return Module.asm.$a.apply(null,arguments)},Module._ts_tree_delete=function(){return Module.asm.ab.apply(null,arguments)},Module._ts_tree_edit_wasm=function(){return Module.asm.bb.apply(null,arguments)},Module._ts_tree_get_changed_ranges_wasm=function(){return Module.asm.cb.apply(null,arguments)},Module._ts_tree_root_node_wasm=function(){return Module.asm.db.apply(null,arguments)},Module.stackAlloc=function(){return Module.asm.pb.apply(null,arguments)}),Re=Module.dynCall_X=function(){return Module.asm.eb.apply(null,arguments)},Te=Module.dynCall_i=function(){return Module.asm.fb.apply(null,arguments)},Le=Module.dynCall_ii=function(){return Module.asm.gb.apply(null,arguments)},qe=Module.dynCall_iidiiii=function(){return Module.asm.hb.apply(null,arguments)},Fe=Module.dynCall_iii=function(){return Module.asm.ib.apply(null,arguments)},Oe=Module.dynCall_iiii=function(){return Module.asm.jb.apply(null,arguments)},We=Module.dynCall_iiiii=function(){return Module.asm.kb.apply(null,arguments)},$e=Module.dynCall_v=function(){return Module.asm.lb.apply(null,arguments)},Ue=Module.dynCall_vi=function(){return Module.asm.mb.apply(null,arguments)},je=Module.dynCall_vii=function(){return Module.asm.nb.apply(null,arguments)},De=Module.dynCall_viii=function(){return Module.asm.ob.apply(null,arguments)};Module.dynCall_X=Re,Module.dynCall_i=Te,Module.dynCall_ii=Le,Module.dynCall_iidiiii=qe,Module.dynCall_iii=Fe,Module.dynCall_iiii=Oe,Module.dynCall_iiiii=We,Module.dynCall_v=$e,Module.dynCall_vi=Ue,Module.dynCall_vii=je,Module.dynCall_viii=De;var Xe,Ke={};for(var Ve in Ke)Module["_"+Ve]=ke+Ke[Ve];for(var Ve in Module.NAMED_GLOBALS=Ke,Ke)!function(e){var t=Module["_"+e];Module["g$_"+e]=function(){return t}}(Ve);function Qe(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5_=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS5_,Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev,Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED1Ev=Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev,Module.asm=Be,Module.allocate=function(e,t,n,r){var o,u;"number"==typeof e?(o=!0,u=e):(o=!1,u=e.length);var i,s="string"==typeof t?t:null;if(i=n==W?r:[ze,Ge,g][n](Math.max(u,s?1:t.length)),o){var a;for(r=i,O(0==(3&i)),a=i+(-4&u);r<a;r+=4)V[r>>2]=0;for(a=i+u;r<a;)G[r++>>0]=0;return i}if("i8"===s)return e.subarray||e.slice?X.set(e,i):X.set(new Uint8Array(e),i),i;for(var l,_,d,c=0;c<u;){var f=e[c];0!==(l=s||t[c])?("i64"==l&&(l="i32"),T(i+c,f,l),d!==l&&(_=w(l),d=l),c+=_):c++}return i},Module.getMemory=$;function Ye(e){function t(){Xe||(Xe=!0,F||(ae=!0,re(ue),re(ie),Module.onRuntimeInitialized&&Module.onRuntimeInitialized(),et&&function(e){if(Module._main){var t=(e=e||[]).length+1,n=Ge(4*(t+1));V[n>>2]=H(u);for(var r=1;r<t;r++)V[(n>>2)+r]=H(e[r-1]);V[(n>>2)+t]=0;try{Je(Module._main(t,n),!0)}catch(e){if(e instanceof Qe)return;if("SimulateInfiniteLoop"==e)return void(S=!0);var o=e;e&&"object"==typeof e&&e.stack&&(o=[e,e.stack]),h("exception thrown: "+o),i(1,e)}finally{!0}}}(e),function(){if(Module.postRun)for("function"==typeof Module.postRun&&(Module.postRun=[Module.postRun]);Module.postRun.length;)e=Module.postRun.shift(),se.unshift(e);var e;re(se)}()))}e=e||o,pe>0||(!function(){if(Module.preRun)for("function"==typeof Module.preRun&&(Module.preRun=[Module.preRun]);Module.preRun.length;)le(Module.preRun.shift());re(oe)}(),pe>0||(Module.setStatus?(Module.setStatus("Running..."),setTimeout(function(){setTimeout(function(){Module.setStatus("")},1),t()},1)):t()))}function Je(e,t){t&&S&&0===e||(S||(F=!0,e,!0,Module.onExit&&Module.onExit(e)),i(e,new Qe(e)))}if(he=function e(){Xe||Ye(),Xe||(he=e)},Module.run=Ye,Module.preInit)for("function"==typeof Module.preInit&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.pop()();var et=!0;Module.noInitialRun&&(et=!1),S=!0,Ye();const tt=Module,nt={},rt=4,ot=5*rt,ut=2*rt,it=2*rt+2*ut,st={row:0,column:0},at=/[\w-.]*/g,lt=1,_t=2,dt=/^_?tree_sitter_\w+/;var ct,ft,pt,mt,ht,Mt=new Promise(e=>{Module.onRuntimeInitialized=e}).then(()=>{pt=tt._ts_init(),ct=L(pt,"i32"),ft=L(pt+rt,"i32")});class Parser{static init(){return Mt}constructor(){if(null==pt)throw new Error("You must first call Parser.init() and wait for it to resolve.");tt._ts_parser_new_wasm(),this[0]=L(pt,"i32"),this[1]=L(pt+rt,"i32")}delete(){tt._ts_parser_delete(this[0]),tt._free(this[1])}setLanguage(e){let t;if(e){if(e.constructor!==Language)throw new Error("Argument must be a Language");{t=e[0];const n=tt._ts_language_version(t);if(n<ft||ct<n)throw new Error(`Incompatible language version ${n}. `+`Compatibility range ${ft} through ${ct}.`)}}else t=0,e=null;return this.language=e,tt._ts_parser_set_language(this[0],t),this}getLanguage(){return this.language}parse(e,t,n){if("string"==typeof e)mt=((t,n,r)=>e.slice(t,r));else{if("function"!=typeof e)throw new Error("Argument must be a string or a function");mt=e}this.logCallback?(ht=this.logCallback,tt._ts_parser_enable_logger_wasm(this[0],1)):(ht=null,tt._ts_parser_enable_logger_wasm(this[0],0));let r=0,o=0;if(n&&n.includedRanges){r=n.includedRanges.length;let e=o=tt._calloc(r,it);for(let t=0;t<r;t++)xt(e,n.includedRanges[t]),e+=it}const u=tt._ts_parser_parse_wasm(this[0],this[1],t?t[0]:0,o,r);if(!u)throw mt=null,ht=null,new Error("Parsing failed");const i=new Tree(nt,u,this.language,mt);return mt=null,ht=null,i}reset(){tt._ts_parser_parse_wasm(this[0])}setTimeoutMicros(e){tt._ts_parser_set_timeout_micros(this[0],e)}getTimeoutMicros(){return tt._ts_parser_timeout_micros(this[0])}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,n,r){wt(e),this[0]=t,this.language=n,this.textCallback=r}copy(){const e=tt._ts_tree_copy(this[0]);return new Tree(nt,e,this.language,this.textCallback)}delete(){tt._ts_tree_delete(this[0])}edit(e){!function(e){let t=pt;Ct(t,e.startPosition),Ct(t+=ut,e.oldEndPosition),Ct(t+=ut,e.newEndPosition),T(t+=ut,e.startIndex,"i32"),T(t+=rt,e.oldEndIndex,"i32"),T(t+=rt,e.newEndIndex,"i32"),t+=rt}(e),tt._ts_tree_edit_wasm(this[0])}get rootNode(){return tt._ts_tree_root_node_wasm(this[0]),Et(this)}getLanguage(){return this.language}walk(){return this.rootNode.walk()}getChangedRanges(e){if(e.constructor!==Tree)throw new TypeError("Argument must be a Tree");tt._ts_tree_get_changed_ranges_wasm(this[0],e[0]);const t=L(pt,"i32"),n=L(pt+rt,"i32"),r=new Array(t);if(t>0){let e=n;for(let n=0;n<t;n++)r[n]=St(e),e+=it;tt._free(n)}return r}}class Node{constructor(e,t){wt(e),this.tree=t}get typeId(){return vt(this),tt._ts_node_symbol_wasm(this.tree[0])}get type(){return this.tree.language.types[this.typeId]||"ERROR"}get endPosition(){return vt(this),tt._ts_node_end_point_wasm(this.tree[0]),Nt(pt)}get endIndex(){return vt(this),tt._ts_node_end_index_wasm(this.tree[0])}get text(){return gt(this.tree,this.startIndex,this.endIndex)}isNamed(){return vt(this),1===tt._ts_node_is_named_wasm(this.tree[0])}hasError(){return vt(this),1===tt._ts_node_has_error_wasm(this.tree[0])}hasChanges(){return vt(this),1===tt._ts_node_has_changes_wasm(this.tree[0])}isMissing(){return vt(this),1===tt._ts_node_is_missing_wasm(this.tree[0])}equals(e){if(this===e)return!0;for(let t=0;t<5;t++)if(this[t]!==e[t])return!1;return!0}child(e){return vt(this),tt._ts_node_child_wasm(this.tree[0],e),Et(this.tree)}namedChild(e){return vt(this),tt._ts_node_named_child_wasm(this.tree[0],e),Et(this.tree)}childForFieldId(e){return vt(this),tt._ts_node_child_by_field_id_wasm(this.tree[0],e),Et(this.tree)}childForFieldName(e){const t=this.tree.language.fields.indexOf(e);if(-1!==t)return this.childForFieldId(t)}get childCount(){return vt(this),tt._ts_node_child_count_wasm(this.tree[0])}get namedChildCount(){return vt(this),tt._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){vt(this),tt._ts_node_children_wasm(this.tree[0]);const e=L(pt,"i32"),t=L(pt+rt,"i32");if(this._children=new Array(e),e>0){let n=t;for(let t=0;t<e;t++)this._children[t]=Et(this.tree,n),n+=ot;tt._free(t)}}return this._children}get namedChildren(){if(!this._namedChildren){vt(this),tt._ts_node_named_children_wasm(this.tree[0]);const e=L(pt,"i32"),t=L(pt+rt,"i32");if(this._namedChildren=new Array(e),e>0){let n=t;for(let t=0;t<e;t++)this._namedChildren[t]=Et(this.tree,n),n+=ot;tt._free(t)}}return this._namedChildren}descendantsOfType(e,t,n){Array.isArray(e)||(e=[e]),t||(t=st),n||(n=st);const r=[],o=this.tree.language.types;for(let t=0,n=o.length;t<n;t++)e.includes(o[t])&&r.push(t);const u=tt._malloc(rt*r.count);for(let e=0,t=r.length;e<t;e++)T(u+e*rt,r[e],"i32");vt(this),tt._ts_node_descendants_of_type_wasm(this.tree[0],u,r.length,t.row,t.column,n.row,n.column);const i=L(pt,"i32"),s=L(pt+rt,"i32"),a=new Array(i);if(i>0){let e=s;for(let t=0;t<i;t++)a[t]=Et(this.tree,e),e+=ot}return tt._free(s),tt._free(u),a}get nextSibling(){return vt(this),tt._ts_node_next_sibling_wasm(this.tree[0]),Et(this.tree)}get previousSibling(){return vt(this),tt._ts_node_prev_sibling_wasm(this.tree[0]),Et(this.tree)}get nextNamedSibling(){return vt(this),tt._ts_node_next_named_sibling_wasm(this.tree[0]),Et(this.tree)}get previousNamedSibling(){return vt(this),tt._ts_node_prev_named_sibling_wasm(this.tree[0]),Et(this.tree)}get parent(){return vt(this),tt._ts_node_parent_wasm(this.tree[0]),Et(this.tree)}descendantForIndex(e,t=e){if("number"!=typeof e||"number"!=typeof t)throw new Error("Arguments must be numbers");vt(this);let n=pt+ot;return T(n,e,"i32"),T(n+rt,t,"i32"),tt._ts_node_descendant_for_index_wasm(this.tree[0]),Et(this.tree)}namedDescendantForIndex(e,t=e){if("number"!=typeof e||"number"!=typeof t)throw new Error("Arguments must be numbers");vt(this);let n=pt+ot;return T(n,e,"i32"),T(n+rt,t,"i32"),tt._ts_node_named_descendant_for_index_wasm(this.tree[0]),Et(this.tree)}descendantForPosition(e,t=e){if(!bt(e)||!bt(t))throw new Error("Arguments must be {row, column} objects");vt(this);let n=pt+ot;return Ct(n,e),Ct(n+ut,t),tt._ts_node_descendant_for_position_wasm(this.tree[0]),Et(this.tree)}namedDescendantForPosition(e,t=e){if(!bt(e)||!bt(t))throw new Error("Arguments must be {row, column} objects");vt(this);let n=pt+ot;return Ct(n,e),Ct(n+ut,t),tt._ts_node_named_descendant_for_position_wasm(this.tree[0]),Et(this.tree)}walk(){return vt(this),tt._ts_tree_cursor_new_wasm(this.tree[0]),new TreeCursor(nt,this.tree)}toString(){vt(this);const e=tt._ts_node_to_string_wasm(this.tree[0]),t=function(e){for(var t="";;){var n=X[e++>>0];if(!n)return t;t+=String.fromCharCode(n)}}(e);return tt._free(e),t}}class TreeCursor{constructor(e,t){wt(e),this.tree=t,It(this)}delete(){At(this),tt._ts_tree_cursor_delete_wasm(this.tree[0])}reset(e){vt(e),At(this,pt+ot),tt._ts_tree_cursor_reset_wasm(this.tree[0]),It(this)}get nodeType(){return this.tree.language.types[this.nodeTypeId]||"ERROR"}get nodeTypeId(){return At(this),tt._ts_tree_cursor_current_node_type_id_wasm(this.tree[0])}get nodeId(){return At(this),tt._ts_tree_cursor_current_node_id_wasm(this.tree[0])}get nodeIsNamed(){return At(this),1===tt._ts_tree_cursor_current_node_is_named_wasm(this.tree[0])}get nodeIsMissing(){return At(this),1===tt._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0])}get nodeText(){At(this);const e=tt._ts_tree_cursor_start_index_wasm(this.tree[0]),t=tt._ts_tree_cursor_end_index_wasm(this.tree[0]);return gt(this.tree,e,t)}get startPosition(){return At(this),tt._ts_tree_cursor_start_position_wasm(this.tree[0]),Nt(pt)}get endPosition(){return At(this),tt._ts_tree_cursor_end_position_wasm(this.tree[0]),Nt(pt)}get startIndex(){return At(this),tt._ts_tree_cursor_start_index_wasm(this.tree[0])}get endIndex(){return At(this),tt._ts_tree_cursor_end_index_wasm(this.tree[0])}currentNode(){return At(this),tt._ts_tree_cursor_current_node_wasm(this.tree[0]),Et(this.tree)}currentFieldId(){return At(this),tt._ts_tree_cursor_current_field_id_wasm(this.tree[0])}currentFieldName(){return this.tree.language.fields[this.currentFieldId()]}gotoFirstChild(){At(this);const e=tt._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);return It(this),1===e}gotoNextSibling(){At(this);const e=tt._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);return It(this),1===e}gotoParent(){At(this);const e=tt._ts_tree_cursor_goto_parent_wasm(this.tree[0]);return It(this),1===e}}class Language{constructor(e,t){wt(e),this[0]=t,this.types=new Array(tt._ts_language_symbol_count(this[0]));for(let e=0,t=this.types.length;e<t;e++)tt._ts_language_symbol_type(this[0],e)<2&&(this.types[e]=D(tt._ts_language_symbol_name(this[0],e)));this.fields=new Array(tt._ts_language_field_count(this[0])+1);for(let e=0,t=this.fields.length;e<t;e++){const t=tt._ts_language_field_name_for_id(this[0],e);this.fields[e]=0!==t?D(t):null}}get version(){return tt._ts_language_version(this[0])}get fieldCount(){return this.fields.length-1}fieldIdForName(e){const t=this.fields.indexOf(e);return-1!==t?t:null}fieldNameForId(e){return this.fields[e]||null}query(e){const t=B(e),n=tt._malloc(t+1);Z(e,X,n,t+1);const r=tt._ts_query_new(this[0],n,t,pt,pt+rt);if(!r){const t=L(pt+rt,"i32"),r=D(n,L(pt,"i32")).length,o=e.substr(r,100),u=o.match(at)[0];let i;switch(t){case 2:i=new RangeError(`Bad node name '${u}'`);break;case 3:i=new RangeError(`Bad field name '${u}'`);break;case 4:i=new RangeError(`Bad capture name @${u}`);break;default:i=new SyntaxError(`Bad syntax at offset ${r}: '${o}'...`)}throw i.index=r,i.length=u.length,tt._free(n),i}const o=tt._ts_query_string_count(r),u=tt._ts_query_capture_count(r),i=tt._ts_query_pattern_count(r),s=new Array(u),a=new Array(o);for(let e=0;e<u;e++){const t=tt._ts_query_capture_name_for_id(r,e,pt),n=L(pt,"i32");s[e]=D(t,n)}for(let e=0;e<o;e++){const t=tt._ts_query_string_value_for_id(r,e,pt),n=L(pt,"i32");a[e]=D(t,n)}const l=new Array(i),_=new Array(i),d=new Array(i),c=new Array(i);for(let e=0;e<i;e++){const t=tt._ts_query_predicates_for_pattern(r,e,pt),n=L(pt,"i32");c[e]=[];const o=[];let u=t;for(let t=0;t<n;t++){const t=L(u,"i32"),n=L(u+=rt,"i32");if(u+=rt,t===lt)o.push({type:"capture",name:s[n]});else if(t===_t)o.push({type:"string",value:a[n]});else if(o.length>0){if("string"!==o[0].type)throw new Error("Predicates must begin with a literal value");const t=o[0].value;let n=!0;switch(t){case"not-eq?":n=!1;case"eq?":if(3!==o.length)throw new Error(`Wrong number of arguments to \`#eq?\` predicate. Expected 2, got ${o.length-1}`);if("capture"!==o[1].type)throw new Error(`First argument of \`#eq?\` predicate must be a capture. Got "${o[1].value}"`);if("capture"===o[2].type){const t=o[1].name,r=o[2].name;c[e].push(function(e){let o,u;for(const n of e)n.name===t&&(o=n.node),n.name===r&&(u=n.node);return o.text===u.text===n})}else{const t=o[1].name,r=o[2].value;c[e].push(function(e){for(const o of e)if(o.name===t)return o.node.text===r===n;return!1})}break;case"match?":if(3!==o.length)throw new Error(`Wrong number of arguments to \`#match?\` predicate. Expected 2, got ${o.length-1}.`);if("capture"!==o[1].type)throw new Error(`First argument of \`#match?\` predicate must be a capture. Got "${o[1].value}".`);if("string"!==o[2].type)throw new Error(`Second argument of \`#match?\` predicate must be a string. Got @${o[2].value}.`);const r=o[1].name,u=new RegExp(o[2].value);c[e].push(function(e){for(const t of e)if(t.name===r)return u.test(t.node.text);return!1});break;case"set!":if(o.length<2||o.length>3)throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${o.length-1}.`);if(o.some(e=>"string"!==e.type))throw new Error('Arguments to `#set!` predicate must be a strings.".');l[e]||(l[e]={}),l[e][o[1].value]=o[2]?o[2].value:null;break;case"is?":case"is-not?":if(o.length<2||o.length>3)throw new Error(`Wrong number of arguments to \`#${t}\` predicate. Expected 1 or 2. Got ${o.length-1}.`);if(o.some(e=>"string"!==e.type))throw new Error(`Arguments to \`#${t}\` predicate must be a strings.".`);const i="is?"===t?_:d;i[e]||(i[e]={}),i[e][o[1].value]=o[2]?o[2].value:null;break;default:throw new Error(`Unknown query predicate \`#${o[0].value}\``)}o.length=0}}Object.freeze(l[e]),Object.freeze(_[e]),Object.freeze(d[e])}return tt._free(n),new Query(nt,r,s,c,Object.freeze(l),Object.freeze(_),Object.freeze(d))}static load(e){let t;if("undefined"!=typeof process&&process.versions&&process.versions.node){const n=require("fs");t=Promise.resolve(n.readFileSync(e))}else t=fetch(e).then(e=>e.arrayBuffer().then(t=>{if(e.ok)return new Uint8Array(t);{const n=new TextDecoder("utf-8").decode(t);throw new Error(`Language.load failed with status ${e.status}.\n\n${n}`)}}));return t.then(e=>I(e,{loadAsync:!0})).then(e=>{const t=Object.keys(e),n=t.find(e=>dt.test(e)&&!e.includes("external_scanner_"));n||console.log(`Couldn't find language function in WASM file. Symbols:\n${JSON.stringify(t,null,2)}`);const r=e[n]();return new Language(nt,r)})}}class Query{constructor(e,t,n,r,o,u,i){wt(e),this[0]=t,this.captureNames=n,this.predicates=r,this.setProperties=o,this.assertedProperties=u,this.refutedProperties=i}delete(){tt._ts_query_delete(this[0])}matches(e,t,n){t||(t=st),n||(n=st),vt(e),tt._ts_query_matches_wasm(this[0],e.tree[0],t.row,t.column,n.row,n.column);const r=L(pt,"i32"),o=L(pt+rt,"i32"),u=new Array(r);let i=o;for(let t=0;t<r;t++){const n=L(i,"i32"),r=L(i+=rt,"i32");i+=rt;const o=new Array(r);if(i=yt(this,e.tree,i,o),this.predicates[n].every(e=>e(o))){u[t]={pattern:n,captures:o};const e=this.setProperties[n];e&&(u[t].setProperties=e);const r=this.assertedProperties[n];r&&(u[t].assertedProperties=r);const i=this.refutedProperties[n];i&&(u[t].refutedProperties=i)}}return tt._free(o),u}captures(e,t,n){t||(t=st),n||(n=st),vt(e),tt._ts_query_captures_wasm(this[0],e.tree[0],t.row,t.column,n.row,n.column);const r=L(pt,"i32"),o=L(pt+rt,"i32"),u=[],i=[];let s=o;for(let t=0;t<r;t++){const t=L(s,"i32"),n=L(s+=rt,"i32"),r=L(s+=rt,"i32");if(s+=rt,i.length=n,s=yt(this,e.tree,s,i),this.predicates[t].every(e=>e(i))){const e=i[r],n=this.setProperties[t];n&&(e.setProperties=n);const o=this.assertedProperties[t];o&&(e.assertedProperties=o);const s=this.refutedProperties[t];s&&(e.refutedProperties=s),u.push(e)}}return tt._free(o),u}}function gt(e,t,n){const r=n-t;let o=e.textCallback(t,null,n);for(t+=o.length;t<n;){const r=e.textCallback(t,null,n);if(!(r&&r.length>0))break;t+=r.length,o+=r}return t>n&&(o=o.slice(0,r)),o}function yt(e,t,n,r){for(let o=0,u=r.length;o<u;o++){const u=L(n,"i32"),i=Et(t,n+=rt);n+=ot,r[o]={name:e.captureNames[u],node:i}}return n}function wt(e){if(e!==nt)throw new Error("Illegal constructor")}function bt(e){return e&&"number"==typeof e.row&&"number"==typeof e.column}function vt(e){let t=pt;T(t,e.id,"i32"),T(t+=rt,e.startIndex,"i32"),T(t+=rt,e.startPosition.row,"i32"),T(t+=rt,e.startPosition.column,"i32"),T(t+=rt,e[0],"i32")}function Et(e,t=pt){const n=L(t,"i32");if(0===n)return null;const r=L(t+=rt,"i32"),o=L(t+=rt,"i32"),u=L(t+=rt,"i32"),i=L(t+=rt,"i32"),s=new Node(nt,e);return s.id=n,s.startIndex=r,s.startPosition={row:o,column:u},s[0]=i,s}function At(e,t=pt){T(t+0*rt,e[0],"i32"),T(t+1*rt,e[1],"i32"),T(t+2*rt,e[2],"i32")}function It(e){e[0]=L(pt+0*rt,"i32"),e[1]=L(pt+1*rt,"i32"),e[2]=L(pt+2*rt,"i32")}function Ct(e,t){T(e,t.row,"i32"),T(e+rt,t.column,"i32")}function Nt(e){return{row:L(e,"i32"),column:L(e+rt,"i32")}}function xt(e,t){Ct(e,t.startPosition),Ct(e+=ut,t.endPosition),T(e+=ut,t.startIndex,"i32"),T(e+=rt,t.endIndex,"i32"),e+=rt}function St(e){const t={};return t.startPosition=Nt(e),e+=ut,t.endPosition=Nt(e),e+=ut,t.startIndex=L(e,"i32"),e+=rt,t.endIndex=L(e,"i32"),t}return Parser.Language=Language,Parser});
|